@@ -80,8 +80,8 @@ function user_insert($event_name,$data) {
8080 global $ app , $ conf ;
8181
8282 //* get the config
83- $ app ->uses (" getconf,system " );
84- $ mail_config = $ app ->getconf ->get_server_config ($ conf [" server_id " ], 'mail ' );
83+ $ app ->uses (' getconf,system ' );
84+ $ mail_config = $ app ->getconf ->get_server_config ($ conf [' server_id ' ], 'mail ' );
8585
8686 // convert to lower case - it could cause problems if some directory above has upper case name
8787// $data['new']['maildir'] = strtolower($data['new']['maildir']);
@@ -110,7 +110,7 @@ function user_insert($event_name,$data) {
110110 //* When the mail user dir exists but it is not a valid maildir, remove it
111111 if (!empty ($ maildomain_path ) && is_dir ($ maildomain_path ) && !is_dir ($ maildomain_path .'/new ' ) && !is_dir ($ maildomain_path .'/cur ' )) {
112112 exec ("su -c 'rm -rf " .escapeshellcmd ($ data ['new ' ]['maildir ' ])."' vmail " );
113- $ app ->log (" Removed invalid maildir and rebuild it: " .escapeshellcmd ($ data ['new ' ]['maildir ' ]),LOGLEVEL_WARN );
113+ $ app ->log (' Removed invalid maildir and rebuild it: ' .escapeshellcmd ($ data ['new ' ]['maildir ' ]),LOGLEVEL_WARN );
114114 }
115115
116116 //* Create the maildir, if it doesn not exist, set permissions, set quota.
@@ -120,7 +120,7 @@ function user_insert($event_name,$data) {
120120 $ app ->system ->maildirmake ($ maildomain_path ,$ mail_config ['mailuser_name ' ]);
121121
122122 exec ('chown -R ' .$ mail_config ['mailuser_name ' ].': ' .$ mail_config ['mailuser_group ' ].' ' .escapeshellcmd ($ data ['new ' ]['maildir ' ]));
123- $ app ->log (" Set ownership on " .escapeshellcmd ($ data ['new ' ]['maildir ' ]),LOGLEVEL_DEBUG );
123+ $ app ->log (' Set ownership on ' .escapeshellcmd ($ data ['new ' ]['maildir ' ]),LOGLEVEL_DEBUG );
124124
125125 //* This is to fix the maildrop quota not being rebuilt after the quota is changed.
126126 if ($ mail_config ['pop3_imap_daemon ' ] != 'dovecot ' ) {
@@ -161,17 +161,18 @@ function user_update($event_name,$data) {
161161 global $ app , $ conf ;
162162
163163 // get the config
164- $ app ->uses (" getconf,system " );
165- $ mail_config = $ app ->getconf ->get_server_config ($ conf [" server_id " ], 'mail ' );
164+ $ app ->uses (' getconf,system ' );
165+ $ mail_config = $ app ->getconf ->get_server_config ($ conf [' server_id ' ], 'mail ' );
166166
167167 // convert to lower case - it could cause problems if some directory above has upper case name
168168 // $data['new']['maildir'] = strtolower($data['new']['maildir']);
169169
170170 // Create the maildir, if it does not exist
171171 /*
172172 if(!is_dir($data['new']['maildir'])) {
173- exec('mkdir -p '.escapeshellcmd($data['new']['maildir']));
174- exec('chown '.$mail_config['mailuser_name'].':'.$mail_config['mailuser_group'].' '.escapeshellcmd($data['new']['maildir']));
173+ mkdir(escapeshellcmd($data['new']['maildir']), 0, true);
174+ chown(escapeshellcmd($data['new']['maildir']), $mail_config['mailuser_name']);
175+ chgrp(escapeshellcmd($data['new']['maildir']), $mail_config['mailuser_group']);
175176 $app->log('Created Maildir: '.$data['new']['maildir'],LOGLEVEL_DEBUG);
176177 }
177178 */
@@ -198,7 +199,7 @@ function user_update($event_name,$data) {
198199 //* When the mail user dir exists but it is not a valid maildir, remove it
199200 if (!empty ($ maildomain_path ) && is_dir ($ maildomain_path ) && !is_dir ($ maildomain_path .'/new ' ) && !is_dir ($ maildomain_path .'/cur ' )) {
200201 exec ("su -c 'rm -rf " .escapeshellcmd ($ data ['new ' ]['maildir ' ])."' vmail " );
201- $ app ->log (" Removed invalid maildir and rebuild it: " .escapeshellcmd ($ data ['new ' ]['maildir ' ]),LOGLEVEL_WARN );
202+ $ app ->log (' Removed invalid maildir and rebuild it: ' .escapeshellcmd ($ data ['new ' ]['maildir ' ]),LOGLEVEL_WARN );
202203 }
203204
204205 //* Create the maildir, if it doesn not exist, set permissions, set quota.
@@ -208,7 +209,7 @@ function user_update($event_name,$data) {
208209 $ app ->system ->maildirmake ($ maildomain_path ,$ mail_config ['mailuser_name ' ]);
209210
210211 exec ('chown -R ' .$ mail_config ['mailuser_name ' ].': ' .$ mail_config ['mailuser_group ' ].' ' .escapeshellcmd ($ data ['new ' ]['maildir ' ]));
211- $ app ->log (" Set ownership on " .escapeshellcmd ($ data ['new ' ]['maildir ' ]),LOGLEVEL_DEBUG );
212+ $ app ->log (' Set ownership on ' .escapeshellcmd ($ data ['new ' ]['maildir ' ]),LOGLEVEL_DEBUG );
212213 //* This is to fix the maildrop quota not being rebuilt after the quota is changed.
213214 if ($ mail_config ['pop3_imap_daemon ' ] != 'dovecot ' ) {
214215 exec ("su -c 'maildirmake -q " .$ data ['new ' ]['quota ' ]."S " .escapeshellcmd ($ maildomain_path )."' " .$ mail_config ['mailuser_name ' ]); // Avoid maildirmake quota bug, see debian bug #214911
@@ -274,7 +275,7 @@ function domain_delete($event_name,$data) {
274275
275276 // get the config
276277 $ app ->uses ("getconf " );
277- $ mail_config = $ app ->getconf ->get_server_config ($ conf [" server_id " ], 'mail ' );
278+ $ mail_config = $ app ->getconf ->get_server_config ($ conf [' server_id ' ], 'mail ' );
278279
279280 //* Delete maildomain path
280281 $ old_maildomain_path = escapeshellcmd ($ mail_config ['homedir_path ' ].'/ ' .$ data ['old ' ]['domain ' ]);
@@ -298,7 +299,7 @@ function domain_delete($event_name,$data) {
298299 function transport_update ($ event_name ,$ data ) {
299300 global $ app , $ conf ;
300301
301- exec (' /etc/init.d/ postfix reload &> /dev/null ' );
302+ exec ($ conf [ ' init_scripts ' ] . ' / ' . ' postfix reload &> /dev/null ' );
302303 $ app ->log ('Postfix config reloaded ' ,LOGLEVEL_DEBUG );
303304
304305 }
@@ -308,4 +309,4 @@ function transport_update($event_name,$data) {
308309
309310} // end class
310311
311- ?>
312+ ?>
0 commit comments