1+ <?php
2+ /*
3+ Copyright (c) 2005, Till Brehm, projektfarm Gmbh
4+ All rights reserved.
5+
6+ Redistribution and use in source and binary forms, with or without modification,
7+ are permitted provided that the following conditions are met:
8+
9+ * Redistributions of source code must retain the above copyright notice,
10+ this list of conditions and the following disclaimer.
11+ * Redistributions in binary form must reproduce the above copyright notice,
12+ this list of conditions and the following disclaimer in the documentation
13+ and/or other materials provided with the distribution.
14+ * Neither the name of ISPConfig nor the names of its contributors
15+ may be used to endorse or promote products derived from this software without
16+ specific prior written permission.
17+
18+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21+ IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
22+ INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23+ BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
25+ OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
27+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+ */
29+
30+
31+ /******************************************
32+ * Begin Form configuration
33+ ******************************************/
34+
35+ $ tform_def_file = "form/mail_alias.tform.php " ;
36+
37+ /******************************************
38+ * End Form configuration
39+ ******************************************/
40+
41+ require_once ('../../lib/config.inc.php ' );
42+ require_once ('../../lib/app.inc.php ' );
43+
44+ // Checking module permissions
45+ if (!stristr ($ _SESSION ["s " ]["user " ]["modules " ],$ _SESSION ["s " ]["module " ]["name " ])) {
46+ header ("Location: ../index.php " );
47+ exit ;
48+ }
49+
50+ // Loading classes
51+ $ app ->uses ('tpl,tform,tform_actions ' );
52+ $ app ->load ('tform_actions ' );
53+
54+ class page_action extends tform_actions {
55+
56+ function onShowEnd () {
57+ global $ app , $ conf ;
58+
59+ $ email = $ this ->dataRecord ["email " ];
60+ $ email_parts = explode ("@ " ,$ email );
61+ $ app ->tpl ->setVar ("email_local_part " ,$ email_parts [0 ]);
62+
63+ // Getting Domains of the user
64+ $ sql = "SELECT domain FROM mail_domain WHERE type = 'local' AND " .$ app ->tform ->getAuthSQL ('r ' );
65+ $ domains = $ app ->db ->queryAllRecords ($ sql );
66+ $ domain_select = '' ;
67+ foreach ( $ domains as $ domain ) {
68+ $ selected = ($ domain ["domain " ] == $ email_parts [1 ])?'SELECTED ' :'' ;
69+ $ domain_select .= "<option value=' $ domain [domain]' $ selected> $ domain [domain]</option> \r\n" ;
70+ }
71+ $ app ->tpl ->setVar ("email_domain " ,$ domain_select );
72+
73+ parent ::onShowEnd ();
74+ }
75+
76+ function onSubmit () {
77+ global $ app , $ conf ;
78+
79+ // Check if Domain belongs to user
80+ $ domain = $ app ->db ->queryOneRecord ("SELECT server_id, domain FROM mail_domain WHERE domain = ' " .$ app ->db ->quote ($ _POST ["email_domain " ])."' AND " .$ app ->tform ->getAuthSQL ('r ' ));
81+ if ($ domain ["domain " ] != $ _POST ["email_domain " ]) $ app ->tform ->errorMessage .= $ app ->tform ->wordbook ["no_domain_perm " ];
82+
83+ // compose the email field
84+ $ this ->dataRecord ["email " ] = $ _POST ["email_local_part " ]."@ " .$ _POST ["email_domain " ];
85+ // Set the server id of the mailbox = server ID of mail domain.
86+ $ this ->dataRecord ["server_id " ] = $ domain ["server_id " ];
87+
88+ unset($ this ->dataRecord ["email_local_part " ]);
89+ unset($ this ->dataRecord ["email_domain " ]);
90+
91+ parent ::onSubmit ();
92+ }
93+
94+ }
95+
96+ $ page = new page_action ;
97+ $ page ->onLoad ();
98+
99+ ?>
0 commit comments