@@ -32,7 +32,7 @@ |
||
32 | 32 | parent::__construct(); |
33 | 33 | |
34 | 34 | // need emailadmin's app.css file |
35 | - Framework::includeCSS('admin','app'); |
|
35 | + Framework::includeCSS('admin', 'app'); |
|
36 | 36 | |
37 | 37 | // and translations |
38 | 38 | Api\Translation::add_app('admin'); |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | |
276 | 276 | //$ruleID is calculated by priority from the selected rule and is an unique ID |
277 | 277 | $content['ruleID'] = $ruleID = ($this->rulesByID['priority'] -1) / 2; |
278 | - $error = 0; |
|
278 | + $error = 0; |
|
279 | 279 | switch ($button) |
280 | 280 | { |
281 | 281 | case 'save': |
@@ -1202,7 +1202,7 @@ discard block |
||
1202 | 1202 | /** |
1203 | 1203 | * |
1204 | 1204 | * Get the data for iterating the rows on rules list grid |
1205 | - * |
|
1205 | + * |
|
1206 | 1206 | * @return {boolean|array} Array of rows | false if failed |
1207 | 1207 | */ |
1208 | 1208 | function get_rows() |
@@ -1222,7 +1222,7 @@ discard block |
||
1222 | 1222 | { |
1223 | 1223 | $row['class'] = 'mail_sieve_DISABLED'; |
1224 | 1224 | } |
1225 | - } |
|
1225 | + } |
|
1226 | 1226 | } |
1227 | 1227 | else |
1228 | 1228 | { |
@@ -1247,7 +1247,7 @@ discard block |
||
1247 | 1247 | 'caption' => 'Edit', |
1248 | 1248 | 'default' => true, |
1249 | 1249 | 'onExecute' => 'javaScript:app.mail.action', |
1250 | - 'disableClass' => 'th' |
|
1250 | + 'disableClass' => 'th' |
|
1251 | 1251 | ), |
1252 | 1252 | 'add' => array( |
1253 | 1253 | 'caption' => 'Add', |
@@ -1257,13 +1257,13 @@ discard block |
||
1257 | 1257 | 'caption' => 'Enable', |
1258 | 1258 | 'onExecute' => 'javaScript:app.mail.action', |
1259 | 1259 | 'enableClass' => 'mail_sieve_DISABLED', |
1260 | - 'hideOnDisabled' => true |
|
1260 | + 'hideOnDisabled' => true |
|
1261 | 1261 | ), |
1262 | 1262 | 'disable' => array( |
1263 | 1263 | 'caption' => 'Disable', |
1264 | 1264 | 'onExecute' => 'javaScript:app.mail.action', |
1265 | 1265 | 'disableClass' => 'mail_sieve_DISABLED', |
1266 | - 'hideOnDisabled' => true |
|
1266 | + 'hideOnDisabled' => true |
|
1267 | 1267 | ), |
1268 | 1268 | 'delete' => array( |
1269 | 1269 | 'caption' => 'Delete', |
@@ -305,11 +305,21 @@ discard block |
||
305 | 305 | unset($newRule['action_reject_text']); |
306 | 306 | |
307 | 307 | $newRule['flg'] = 0 ; |
308 | - if( $newRule['continue'] ) { $newRule['flg'] += 1; } |
|
309 | - if( $newRule['gthan'] ) { $newRule['flg'] += 2; } |
|
310 | - if( $newRule['anyof'] ) { $newRule['flg'] += 4; } |
|
311 | - if( $newRule['keep'] ) { $newRule['flg'] += 8; } |
|
312 | - if( $newRule['regexp'] ) { $newRule['flg'] += 128; } |
|
308 | + if( $newRule['continue'] ) |
|
309 | + { |
|
310 | +$newRule['flg'] += 1; } |
|
311 | + if( $newRule['gthan'] ) |
|
312 | + { |
|
313 | +$newRule['flg'] += 2; } |
|
314 | + if( $newRule['anyof'] ) |
|
315 | + { |
|
316 | +$newRule['flg'] += 4; } |
|
317 | + if( $newRule['keep'] ) |
|
318 | + { |
|
319 | +$newRule['flg'] += 8; } |
|
320 | + if( $newRule['regexp'] ) |
|
321 | + { |
|
322 | +$newRule['flg'] += 128; } |
|
313 | 323 | |
314 | 324 | if($newRule['action'] && $this->rulesByID['priority']) |
315 | 325 | { |
@@ -443,7 +453,10 @@ discard block |
||
443 | 453 | { |
444 | 454 | Framework::window_close(lang($e->getMessage())); |
445 | 455 | } |
446 | - if (is_null($accountID)) $accountID = $GLOBALS['egw_info']['user']['account_id']; |
|
456 | + if (is_null($accountID)) |
|
457 | + { |
|
458 | + $accountID = $GLOBALS['egw_info']['user']['account_id']; |
|
459 | + } |
|
447 | 460 | |
448 | 461 | $account_email = Api\Accounts::id2name($accountID, 'account_email'); |
449 | 462 | $accAllIdentities = $this->account->smtpServer()->getAccountEmailAddress(Api\Accounts::id2name($accountID)); |
@@ -484,7 +497,10 @@ discard block |
||
484 | 497 | $vtmpl = new Etemplate('mail.sieve.vacation'); |
485 | 498 | $vacation = array(); |
486 | 499 | |
487 | - if (isset($_GET['account_id'])) $account_id = $preserv['account_id'] = $_GET['account_id']; |
|
500 | + if (isset($_GET['account_id'])) |
|
501 | + { |
|
502 | + $account_id = $preserv['account_id'] = $_GET['account_id']; |
|
503 | + } |
|
488 | 504 | |
489 | 505 | if (isset($content['account_id'])) |
490 | 506 | { |
@@ -554,7 +570,10 @@ discard block |
||
554 | 570 | if (!is_array($content) || ($content['acc_id'] && !isset($content['button'])) || (strlen(trim($content['text']))==0 && in_array($content['status'],array('on','by_date')))) |
555 | 571 | { |
556 | 572 | $content = $vacation = $vacRules['vacation']; |
557 | - if (!empty($profileID)) $content['acc_id'] = $profileID; |
|
573 | + if (!empty($profileID)) |
|
574 | + { |
|
575 | + $content['acc_id'] = $profileID; |
|
576 | + } |
|
558 | 577 | if (empty($vacation['addresses']) || implode('',$vacation['addresses']) == '') |
559 | 578 | { |
560 | 579 | $content['addresses'] = $vacRules['aliases']; |
@@ -567,7 +586,10 @@ discard block |
||
567 | 586 | { |
568 | 587 | $content['forwards'] = ''; |
569 | 588 | } |
570 | - if (strlen(trim($vacation['text']))==0 && $this->mailConfig['default_vacation_text']) $content['text'] = $this->mailConfig['default_vacation_text']; |
|
589 | + if (strlen(trim($vacation['text']))==0 && $this->mailConfig['default_vacation_text']) |
|
590 | + { |
|
591 | + $content['text'] = $this->mailConfig['default_vacation_text']; |
|
592 | + } |
|
571 | 593 | if (strlen(trim($content['text']))==0) |
572 | 594 | { |
573 | 595 | $content['msg'] = $msg = lang('error').': '.lang('No vacation notice text provided. Please enter a message.'); |
@@ -757,7 +779,10 @@ discard block |
||
757 | 779 | } |
758 | 780 | // setting up an async job to enable/disable the vacation message |
759 | 781 | $async = new Api\Asyncservice(); |
760 | - if (empty($_vacation['account_id'])) $_vacation['account_id'] = $GLOBALS['egw_info']['user']['account_id']; |
|
782 | + if (empty($_vacation['account_id'])) |
|
783 | + { |
|
784 | + $_vacation['account_id'] = $GLOBALS['egw_info']['user']['account_id']; |
|
785 | + } |
|
761 | 786 | $async_id = !empty($_vacation['id']) ? $_vacation['id'] : 'mail-vacation-'.$_vacation['account_id']; |
762 | 787 | $async->delete($async_id); |
763 | 788 | |
@@ -1294,7 +1319,10 @@ discard block |
||
1294 | 1319 | function ajax_getFolders ($_searchStringLength=2, $_returnList=false, $_mailaccountToSearch=null, $_noPrefixId=false) |
1295 | 1320 | { |
1296 | 1321 | $mailCompose = new mail_compose(); |
1297 | - if ($_REQUEST['noPrefixId']) $_noPrefixId = $_REQUEST['noPrefixId']; |
|
1322 | + if ($_REQUEST['noPrefixId']) |
|
1323 | + { |
|
1324 | + $_noPrefixId = $_REQUEST['noPrefixId']; |
|
1325 | + } |
|
1298 | 1326 | $mailCompose->ajax_searchFolder($_searchStringLength, $_returnList, $_mailaccountToSearch, $_noPrefixId); |
1299 | 1327 | } |
1300 | 1328 | } |
@@ -74,8 +74,8 @@ discard block |
||
74 | 74 | if ($acc_id > 0) |
75 | 75 | { |
76 | 76 | $this->account = Mail\Account::read($acc_id); |
77 | - $identity = Mail\Account::read_identity($this->account->ident_id,true); |
|
78 | - $this->currentIdentity = Mail::generateIdentityString($identity,false); |
|
77 | + $identity = Mail\Account::read_identity($this->account->ident_id, true); |
|
78 | + $this->currentIdentity = Mail::generateIdentityString($identity, false); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | $this->restoreSessionData(); |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | * @param {array} $content |
88 | 88 | * @param {string} $msg |
89 | 89 | */ |
90 | - function index(array $content=null,$msg=null) |
|
90 | + function index(array $content = null, $msg = null) |
|
91 | 91 | { |
92 | 92 | if (!is_array($content)) |
93 | 93 | { |
@@ -104,10 +104,10 @@ discard block |
||
104 | 104 | if ($this->account->acc_sieve_enabled) |
105 | 105 | { |
106 | 106 | //Initializes the Grid contents |
107 | - $content['rg']= $this->get_rows(); |
|
107 | + $content['rg'] = $this->get_rows(); |
|
108 | 108 | |
109 | 109 | // Set content-menu actions |
110 | - $tmpl->setElementAttribute('rg', 'actions',$this->get_actions()); |
|
110 | + $tmpl->setElementAttribute('rg', 'actions', $this->get_actions()); |
|
111 | 111 | |
112 | 112 | $sel_options = array( |
113 | 113 | 'status' => array( |
@@ -118,10 +118,10 @@ discard block |
||
118 | 118 | } |
119 | 119 | else |
120 | 120 | { |
121 | - $content['msg'] = lang('error').':'.lang('Serverside Filterrules (Sieve) are not activated').'. '.lang('Please contact your Administrator to validate if your Server supports Serverside Filterrules, and how to enable them in EGroupware for your active Account (%1) with ID:%2.',$this->currentIdentity,$this->account->acc_id); |
|
122 | - $content['hideIfSieveDisabled']='mail_DisplayNone'; |
|
121 | + $content['msg'] = lang('error').':'.lang('Serverside Filterrules (Sieve) are not activated').'. '.lang('Please contact your Administrator to validate if your Server supports Serverside Filterrules, and how to enable them in EGroupware for your active Account (%1) with ID:%2.', $this->currentIdentity, $this->account->acc_id); |
|
122 | + $content['hideIfSieveDisabled'] = 'mail_DisplayNone'; |
|
123 | 123 | } |
124 | - $tmpl->exec('mail.mail_sieve.index',$content,$sel_options,array()); |
|
124 | + $tmpl->exec('mail.mail_sieve.index', $content, $sel_options, array()); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | * @param {array} $content |
132 | 132 | * @param {string} $msg |
133 | 133 | */ |
134 | - function editEmailNotification($content=null, $msg='') |
|
134 | + function editEmailNotification($content = null, $msg = '') |
|
135 | 135 | { |
136 | 136 | //Instantiate an eTemplate object, representing sieve.emailNotification |
137 | 137 | $eNotitmpl = new Etemplate('mail.sieve.emailNotification'); |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | |
147 | 147 | if (!empty($eNotification['externalEmail'])) |
148 | 148 | { |
149 | - $content['externalEmail'] = explode(",",$eNotification['externalEmail']); |
|
149 | + $content['externalEmail'] = explode(",", $eNotification['externalEmail']); |
|
150 | 150 | } |
151 | 151 | } |
152 | 152 | else |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | $button = @key($content['button']); |
156 | 156 | unset ($content['button']); |
157 | 157 | |
158 | - switch($button) |
|
158 | + switch ($button) |
|
159 | 159 | { |
160 | 160 | case 'save': |
161 | 161 | case 'apply': |
@@ -163,11 +163,11 @@ discard block |
||
163 | 163 | { |
164 | 164 | $newEmailNotification = $content; |
165 | 165 | if (empty($this->mailConfig['prefpreventforwarding']) || |
166 | - $this->mailConfig['prefpreventforwarding'] == 0 ) |
|
166 | + $this->mailConfig['prefpreventforwarding'] == 0) |
|
167 | 167 | { |
168 | 168 | if (is_array($content['externalEmail']) && !empty($content['externalEmail'])) |
169 | 169 | { |
170 | - $newEmailNotification['externalEmail'] = implode(",",$content['externalEmail']); |
|
170 | + $newEmailNotification['externalEmail'] = implode(",", $content['externalEmail']); |
|
171 | 171 | } |
172 | 172 | } |
173 | 173 | } |
@@ -215,10 +215,10 @@ discard block |
||
215 | 215 | } |
216 | 216 | else |
217 | 217 | { |
218 | - $content['msg'] = lang('error').':'.lang('Serverside Filterrules (Sieve) are not activated').'. '.lang('Please contact your Administrator to validate if your Server supports Serverside Filterrules, and how to enable them in EGroupware for your active Account (%1) with ID:%2.',$this->currentIdentity,$this->account->acc_id); |
|
219 | - $content['hideIfSieveDisabled']='mail_DisplayNone'; |
|
218 | + $content['msg'] = lang('error').':'.lang('Serverside Filterrules (Sieve) are not activated').'. '.lang('Please contact your Administrator to validate if your Server supports Serverside Filterrules, and how to enable them in EGroupware for your active Account (%1) with ID:%2.', $this->currentIdentity, $this->account->acc_id); |
|
219 | + $content['hideIfSieveDisabled'] = 'mail_DisplayNone'; |
|
220 | 220 | } |
221 | - $eNotitmpl->exec('mail.mail_sieve.editEmailNotification', $content,$sel_options); |
|
221 | + $eNotitmpl->exec('mail.mail_sieve.editEmailNotification', $content, $sel_options); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | /** |
@@ -226,18 +226,18 @@ discard block |
||
226 | 226 | * |
227 | 227 | * @param {array} $content |
228 | 228 | */ |
229 | - function edit ($content=null) |
|
229 | + function edit($content = null) |
|
230 | 230 | { |
231 | 231 | //Instantiate an eTemplate object, representing sieve.edit template |
232 | 232 | $etmpl = new Etemplate('mail.sieve.edit'); |
233 | - $etmpl->setElementAttribute('action_folder_text','autocomplete_params', array('noPrefixId'=> true)); |
|
233 | + $etmpl->setElementAttribute('action_folder_text', 'autocomplete_params', array('noPrefixId'=> true)); |
|
234 | 234 | if (!is_array($content)) |
235 | 235 | { |
236 | - if ( $this->getRules($_GET['ruleID']) && isset($_GET['ruleID'])) |
|
236 | + if ($this->getRules($_GET['ruleID']) && isset($_GET['ruleID'])) |
|
237 | 237 | { |
238 | 238 | |
239 | 239 | $rules = $this->rulesByID; |
240 | - $content= $rules; |
|
240 | + $content = $rules; |
|
241 | 241 | $content ['ruleID'] = $_GET['ruleID']; |
242 | 242 | switch ($rules['action']) |
243 | 243 | { |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | { |
258 | 258 | |
259 | 259 | $this->getRules(null); |
260 | - $newRulePriority = count($this->rules)*2+1; |
|
260 | + $newRulePriority = count($this->rules) * 2 + 1; |
|
261 | 261 | $newRules ['priority'] = $newRulePriority; |
262 | 262 | $newRules ['status'] = 'ENABLED'; |
263 | 263 | $readonlys = array( |
@@ -274,19 +274,19 @@ discard block |
||
274 | 274 | $button = @key($content['button']); |
275 | 275 | |
276 | 276 | //$ruleID is calculated by priority from the selected rule and is an unique ID |
277 | - $content['ruleID'] = $ruleID = ($this->rulesByID['priority'] -1) / 2; |
|
277 | + $content['ruleID'] = $ruleID = ($this->rulesByID['priority'] - 1) / 2; |
|
278 | 278 | $error = 0; |
279 | 279 | switch ($button) |
280 | 280 | { |
281 | 281 | case 'save': |
282 | 282 | case 'apply': |
283 | - if($content) |
|
283 | + if ($content) |
|
284 | 284 | { |
285 | 285 | unset($content['button']); |
286 | 286 | |
287 | 287 | $newRule = $content; |
288 | - $newRule['priority'] = $this->rulesByID['priority']; |
|
289 | - $newRule['status'] = $this->rulesByID['status']; |
|
288 | + $newRule['priority'] = $this->rulesByID['priority']; |
|
289 | + $newRule['status'] = $this->rulesByID['status']; |
|
290 | 290 | |
291 | 291 | switch ($content['action']) |
292 | 292 | { |
@@ -304,14 +304,14 @@ discard block |
||
304 | 304 | unset($newRule['action_address_text']); |
305 | 305 | unset($newRule['action_reject_text']); |
306 | 306 | |
307 | - $newRule['flg'] = 0 ; |
|
308 | - if( $newRule['continue'] ) { $newRule['flg'] += 1; } |
|
309 | - if( $newRule['gthan'] ) { $newRule['flg'] += 2; } |
|
310 | - if( $newRule['anyof'] ) { $newRule['flg'] += 4; } |
|
311 | - if( $newRule['keep'] ) { $newRule['flg'] += 8; } |
|
312 | - if( $newRule['regexp'] ) { $newRule['flg'] += 128; } |
|
307 | + $newRule['flg'] = 0; |
|
308 | + if ($newRule['continue']) { $newRule['flg'] += 1; } |
|
309 | + if ($newRule['gthan']) { $newRule['flg'] += 2; } |
|
310 | + if ($newRule['anyof']) { $newRule['flg'] += 4; } |
|
311 | + if ($newRule['keep']) { $newRule['flg'] += 8; } |
|
312 | + if ($newRule['regexp']) { $newRule['flg'] += 128; } |
|
313 | 313 | |
314 | - if($newRule['action'] && $this->rulesByID['priority']) |
|
314 | + if ($newRule['action'] && $this->rulesByID['priority']) |
|
315 | 315 | { |
316 | 316 | $this->rules[$ruleID] = $newRule; |
317 | 317 | $ret = $this->account->imapServer()->setRules($this->rules); |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | } |
322 | 322 | else |
323 | 323 | { |
324 | - $msg .= lang("The rule with priority %1 successfully saved!",$ruleID); |
|
324 | + $msg .= lang("The rule with priority %1 successfully saved!", $ruleID); |
|
325 | 325 | } |
326 | 326 | $this->saveSessionData(); |
327 | 327 | } |
@@ -346,14 +346,14 @@ discard block |
||
346 | 346 | case 'delete': |
347 | 347 | if ($button == "delete") |
348 | 348 | { |
349 | - if ($ruleID === count($this->rules)-1) |
|
349 | + if ($ruleID === count($this->rules) - 1) |
|
350 | 350 | { |
351 | - $msg = lang('rule with priority ') . $ruleID . lang(' deleted!'); |
|
351 | + $msg = lang('rule with priority ').$ruleID.lang(' deleted!'); |
|
352 | 352 | } |
353 | 353 | else |
354 | 354 | { |
355 | 355 | |
356 | - $msg = lang('rule with priority ') . $ruleID . lang(' deleted!') . lang(' And the rule with priority %1, now got the priority %2',$ruleID+1,$ruleID); |
|
356 | + $msg = lang('rule with priority ').$ruleID.lang(' deleted!').lang(' And the rule with priority %1, now got the priority %2', $ruleID + 1, $ruleID); |
|
357 | 357 | } |
358 | 358 | unset($this->rules[$ruleID]); |
359 | 359 | $this->rules = array_values($this->rules); |
@@ -384,9 +384,9 @@ discard block |
||
384 | 384 | ); |
385 | 385 | |
386 | 386 | //Set the preselect_options for mail/folders as we are not allow free entry for folder taglist |
387 | - $sel_options['action_folder_text'] = $this->ajax_getFolders(0,true,null,true); |
|
387 | + $sel_options['action_folder_text'] = $this->ajax_getFolders(0, true, null, true); |
|
388 | 388 | |
389 | - return $etmpl->exec('mail.mail_sieve.edit',$content,$sel_options,$readonlys,array(),2); |
|
389 | + return $etmpl->exec('mail.mail_sieve.edit', $content, $sel_options, $readonlys, array(), 2); |
|
390 | 390 | } |
391 | 391 | |
392 | 392 | /** |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | */ |
399 | 399 | function getEmailNotification() |
400 | 400 | { |
401 | - if(!(empty($this->mailConfig['prefpreventnotificationformailviaemail']) || $this->mailConfig['prefpreventnotificationformailviaemail'] == 0)) |
|
401 | + if (!(empty($this->mailConfig['prefpreventnotificationformailviaemail']) || $this->mailConfig['prefpreventnotificationformailviaemail'] == 0)) |
|
402 | 402 | { |
403 | 403 | throw new Api\Exception\NoPermission(); |
404 | 404 | } |
@@ -406,7 +406,7 @@ discard block |
||
406 | 406 | try { |
407 | 407 | $emailNotification = $this->account->imapServer()->getEmailNotification(); |
408 | 408 | } |
409 | - catch(Exception $e) { |
|
409 | + catch (Exception $e) { |
|
410 | 410 | unset($e); |
411 | 411 | $emailNotification = array(); |
412 | 412 | } |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | */ |
423 | 423 | function getVacation($accountID = null) |
424 | 424 | { |
425 | - if(!(empty($this->mailConfig['prefpreventabsentnotice']) || $this->mailConfig['prefpreventabsentnotice'] == 0)) |
|
425 | + if (!(empty($this->mailConfig['prefpreventabsentnotice']) || $this->mailConfig['prefpreventabsentnotice'] == 0)) |
|
426 | 426 | { |
427 | 427 | throw new Api\Exception\NoPermission(); |
428 | 428 | } |
@@ -439,25 +439,25 @@ discard block |
||
439 | 439 | $vacation = $icServer->getVacation(); |
440 | 440 | } |
441 | 441 | } |
442 | - catch(Exception $e) |
|
442 | + catch (Exception $e) |
|
443 | 443 | { |
444 | 444 | Framework::window_close(lang($e->getMessage())); |
445 | 445 | } |
446 | 446 | if (is_null($accountID)) $accountID = $GLOBALS['egw_info']['user']['account_id']; |
447 | 447 | |
448 | - $account_email = Api\Accounts::id2name($accountID, 'account_email'); |
|
448 | + $account_email = Api\Accounts::id2name($accountID, 'account_email'); |
|
449 | 449 | $accAllIdentities = $this->account->smtpServer()->getAccountEmailAddress(Api\Accounts::id2name($accountID)); |
450 | - $allAliases = $this->account->ident_email !=''? |
|
450 | + $allAliases = $this->account->ident_email != '' ? |
|
451 | 451 | // Fix ident_email with no domain part set |
452 | 452 | array(Mail::fixInvalidAliasAddress($account_email, $this->account->ident_email)) |
453 | 453 | : array(); |
454 | 454 | foreach ($accAllIdentities as &$val) |
455 | 455 | { |
456 | - if ($val['type'] !='default') |
|
456 | + if ($val['type'] != 'default') |
|
457 | 457 | { |
458 | 458 | // if the alias has no domain part set try to add |
459 | 459 | // default domain extracted from ident_email address |
460 | - $allAliases[] = Mail::fixInvalidAliasAddress($account_email, $val['address']); |
|
460 | + $allAliases[] = Mail::fixInvalidAliasAddress($account_email, $val['address']); |
|
461 | 461 | } |
462 | 462 | } |
463 | 463 | // try to fix already stored aliases |
@@ -478,7 +478,7 @@ discard block |
||
478 | 478 | * @param {array} $content |
479 | 479 | * @param {string} $msg |
480 | 480 | */ |
481 | - function editVacation($content=null, $msg='') |
|
481 | + function editVacation($content = null, $msg = '') |
|
482 | 482 | { |
483 | 483 | //Instantiate an eTemplate object, representing the sieve.vacation template |
484 | 484 | $vtmpl = new Etemplate('mail.sieve.vacation'); |
@@ -491,27 +491,27 @@ discard block |
||
491 | 491 | $account_id = $content['account_id']; |
492 | 492 | $preserv['acc_id'] = $content['acc_id']; |
493 | 493 | } |
494 | - if(isset($account_id) && $this->mail_admin) |
|
494 | + if (isset($account_id) && $this->mail_admin) |
|
495 | 495 | { |
496 | - foreach(Mail\Account::search($account_id, false, null, false, 0, false) as $account) |
|
496 | + foreach (Mail\Account::search($account_id, false, null, false, 0, false) as $account) |
|
497 | 497 | { |
498 | 498 | try { |
499 | 499 | // check if account is valid for multiple users, has admin credentials and sieve enabled |
500 | 500 | if (Mail\Account::is_multiple($account) && |
501 | - ($icServer = $account->imapServer(true)) && // check on icServer object, so plugins can overwrite |
|
501 | + ($icServer = $account->imapServer(true)) && // check on icServer object, so plugins can overwrite |
|
502 | 502 | $icServer->acc_imap_admin_username && $icServer->acc_sieve_enabled) |
503 | 503 | { |
504 | 504 | $allAccounts[$account->acc_id] = $account->acc_name; |
505 | 505 | $accounts[$account->acc_id] = $account; |
506 | 506 | } |
507 | 507 | } |
508 | - catch(Exception $e) { |
|
508 | + catch (Exception $e) { |
|
509 | 509 | unset($e); |
510 | 510 | // ignore broken accounts |
511 | 511 | } |
512 | 512 | } |
513 | 513 | |
514 | - $profileID = !isset($content['acc_id']) ? key($accounts):$content['acc_id']; |
|
514 | + $profileID = !isset($content['acc_id']) ? key($accounts) : $content['acc_id']; |
|
515 | 515 | if (isset($_GET['acc_id']) && isset($allAccounts[$_GET['acc_id']])) |
516 | 516 | { |
517 | 517 | $profileID = $content['acc_id'] = (int)$_GET['acc_id']; |
@@ -523,7 +523,7 @@ discard block |
||
523 | 523 | $this->is_admin_vac = true; |
524 | 524 | $preserv['account_id'] = $account_id; |
525 | 525 | } |
526 | - elseif(!is_array($content) && isset($_GET['acc_id'])) |
|
526 | + elseif (!is_array($content) && isset($_GET['acc_id'])) |
|
527 | 527 | { |
528 | 528 | $this->account = Mail\Account::read($_GET['acc_id']); |
529 | 529 | $preserv['acc_id'] = $this->account->acc_id; |
@@ -539,11 +539,11 @@ discard block |
||
539 | 539 | if ($icServer->acc_sieve_enabled) |
540 | 540 | { |
541 | 541 | $vacRules = $this->getVacation($account_id); |
542 | - if ($vacRules['vacation']===false) |
|
542 | + if ($vacRules['vacation'] === false) |
|
543 | 543 | { |
544 | 544 | $content['msg'] = lang('error').':'.lang('Serverside Vacationnotice (via Sieve) are not activated').'. '. |
545 | - lang('Please contact your Administrator to validate if your Server supports Serverside Vacationmessages, and how to enable them in EGroupware for your active Account (%1) with ID:%2.',$this->currentIdentity,$icServer->ImapServerId); |
|
546 | - $content['hideIfSieveDisabled']='mail_DisplayNone'; |
|
545 | + lang('Please contact your Administrator to validate if your Server supports Serverside Vacationmessages, and how to enable them in EGroupware for your active Account (%1) with ID:%2.', $this->currentIdentity, $icServer->ImapServerId); |
|
546 | + $content['hideIfSieveDisabled'] = 'mail_DisplayNone'; |
|
547 | 547 | } |
548 | 548 | else |
549 | 549 | { |
@@ -551,24 +551,24 @@ discard block |
||
551 | 551 | { |
552 | 552 | $ByDate = array('by_date' => lang('By date')); |
553 | 553 | } |
554 | - if (!is_array($content) || ($content['acc_id'] && !isset($content['button'])) || (strlen(trim($content['text']))==0 && in_array($content['status'],array('on','by_date')))) |
|
554 | + if (!is_array($content) || ($content['acc_id'] && !isset($content['button'])) || (strlen(trim($content['text'])) == 0 && in_array($content['status'], array('on', 'by_date')))) |
|
555 | 555 | { |
556 | 556 | $content = $vacation = $vacRules['vacation']; |
557 | 557 | if (!empty($profileID)) $content['acc_id'] = $profileID; |
558 | - if (empty($vacation['addresses']) || implode('',$vacation['addresses']) == '') |
|
558 | + if (empty($vacation['addresses']) || implode('', $vacation['addresses']) == '') |
|
559 | 559 | { |
560 | 560 | $content['addresses'] = $vacRules['aliases']; |
561 | 561 | } |
562 | 562 | if (!empty($vacation['forwards'])) |
563 | 563 | { |
564 | - $content['forwards'] = explode(",",$vacation['forwards']); |
|
564 | + $content['forwards'] = explode(",", $vacation['forwards']); |
|
565 | 565 | } |
566 | 566 | else |
567 | 567 | { |
568 | 568 | $content['forwards'] = ''; |
569 | 569 | } |
570 | - if (strlen(trim($vacation['text']))==0 && $this->mailConfig['default_vacation_text']) $content['text'] = $this->mailConfig['default_vacation_text']; |
|
571 | - if (strlen(trim($content['text']))==0) |
|
570 | + if (strlen(trim($vacation['text'])) == 0 && $this->mailConfig['default_vacation_text']) $content['text'] = $this->mailConfig['default_vacation_text']; |
|
571 | + if (strlen(trim($content['text'])) == 0) |
|
572 | 572 | { |
573 | 573 | $content['msg'] = $msg = lang('error').': '.lang('No vacation notice text provided. Please enter a message.'); |
574 | 574 | Framework::refresh_opener($msg, 'mail'); |
@@ -586,7 +586,7 @@ discard block |
||
586 | 586 | $button = @key($content['button']); |
587 | 587 | unset ($content['button']); |
588 | 588 | |
589 | - switch($button) |
|
589 | + switch ($button) |
|
590 | 590 | { |
591 | 591 | case 'save': |
592 | 592 | case 'apply': |
@@ -604,7 +604,7 @@ discard block |
||
604 | 604 | $newVacation = $content; |
605 | 605 | |
606 | 606 | if (empty($this->mailConfig['prefpreventforwarding']) || |
607 | - $this->mailConfig['prefpreventforwarding'] == 0 ) |
|
607 | + $this->mailConfig['prefpreventforwarding'] == 0) |
|
608 | 608 | { |
609 | 609 | $content['forwards'] = self::strip_rfc882_addresses($content['forwards']); |
610 | 610 | $newVacation['forwards'] = implode(',', $content['forwards']); |
@@ -614,7 +614,7 @@ discard block |
||
614 | 614 | unset($newVacation ['forwards']); |
615 | 615 | } |
616 | 616 | |
617 | - if (!in_array($newVacation['status'],array('on','off','by_date'))) |
|
617 | + if (!in_array($newVacation['status'], array('on', 'off', 'by_date'))) |
|
618 | 618 | { |
619 | 619 | $newVacation['status'] = 'off'; |
620 | 620 | } |
@@ -626,7 +626,7 @@ discard block |
||
626 | 626 | self::strip_rfc882_addresses($content['addresses']); |
627 | 627 | } |
628 | 628 | |
629 | - if($this->checkRule($newVacation,$checkAddresses)) |
|
629 | + if ($this->checkRule($newVacation, $checkAddresses)) |
|
630 | 630 | { |
631 | 631 | if (isset($account_id) && $this->mail_admin) |
632 | 632 | { |
@@ -639,13 +639,13 @@ discard block |
||
639 | 639 | |
640 | 640 | if (!$resSetvac) |
641 | 641 | { |
642 | - $msg = lang('vacation update failed') . "\n" . lang('Vacation notice update failed') . ":" . $this->account->imapServer()->error; |
|
642 | + $msg = lang('vacation update failed')."\n".lang('Vacation notice update failed').":".$this->account->imapServer()->error; |
|
643 | 643 | break; |
644 | 644 | } |
645 | 645 | // schedule job to switch message on/off, if request and not already in past |
646 | 646 | else |
647 | 647 | { |
648 | - if ($newVacation['status'] == 'by_date' && $newVacation['end_date']+24*3600 > time() || |
|
648 | + if ($newVacation['status'] == 'by_date' && $newVacation['end_date'] + 24 * 3600 > time() || |
|
649 | 649 | $vacRules && $vacRules['vacation']['status'] == 'by_date') |
650 | 650 | { |
651 | 651 | self::setAsyncJob($newVacation); |
@@ -653,29 +653,29 @@ discard block |
||
653 | 653 | //Reset vacationNotice cache which is used in mail_ui get_rows |
654 | 654 | if (isset($account_id) && $this->mail_admin) |
655 | 655 | { |
656 | - $account_lid = Api\Accounts::id2name($account_id,'account_lid'); |
|
656 | + $account_lid = Api\Accounts::id2name($account_id, 'account_lid'); |
|
657 | 657 | $cachedVacations = array($icServer->acc_id => $newVacation) + (array)Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'vacationNotice'.$account_lid); |
658 | 658 | //error_log(__METHOD__.__LINE__.' Setting Cache for '.$account_lid.':'.array2string($cachedVacations)); |
659 | - Api\Cache::setCache(Api\Cache::INSTANCE,'email', 'vacationNotice'.$account_lid, $cachedVacations); |
|
659 | + Api\Cache::setCache(Api\Cache::INSTANCE, 'email', 'vacationNotice'.$account_lid, $cachedVacations); |
|
660 | 660 | } |
661 | 661 | else |
662 | 662 | { |
663 | 663 | $cachedVacations = array($icServer->acc_id => $newVacation) + (array)Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'vacationNotice'.$GLOBALS['egw_info']['user']['account_lid']); |
664 | 664 | //error_log(__METHOD__.__LINE__.' Setting Cache for own ('.$GLOBALS['egw_info']['user']['account_lid'].'):'.array2string($cachedVacations)); |
665 | - Api\Cache::setCache(Api\Cache::INSTANCE,'email', 'vacationNotice'.$GLOBALS['egw_info']['user']['account_lid'], $cachedVacations); |
|
665 | + Api\Cache::setCache(Api\Cache::INSTANCE, 'email', 'vacationNotice'.$GLOBALS['egw_info']['user']['account_lid'], $cachedVacations); |
|
666 | 666 | } |
667 | 667 | $msg = lang('Vacation notice sucessfully updated.'); |
668 | 668 | } |
669 | 669 | } |
670 | 670 | else |
671 | 671 | { |
672 | - $msg .= implode("\n",$this->errorStack); |
|
672 | + $msg .= implode("\n", $this->errorStack); |
|
673 | 673 | } |
674 | 674 | // refresh vacationNotice on index |
675 | 675 | $response = Api\Json\Response::get(); |
676 | - $response->call('app.mail.mail_callRefreshVacationNotice',$icServer->ImapServerId); |
|
676 | + $response->call('app.mail.mail_callRefreshVacationNotice', $icServer->ImapServerId); |
|
677 | 677 | Framework::refresh_opener($msg, 'mail'); |
678 | - if ($button === 'apply' || $icServer->error !=="") |
|
678 | + if ($button === 'apply' || $icServer->error !== "") |
|
679 | 679 | { |
680 | 680 | break; |
681 | 681 | } |
@@ -691,7 +691,7 @@ discard block |
||
691 | 691 | 'on' => lang('Active'), |
692 | 692 | 'off' => lang('Deactive'), |
693 | 693 | ), |
694 | - 'addresses' => array_combine($vacRules['aliases'],$vacRules['aliases']), |
|
694 | + 'addresses' => array_combine($vacRules['aliases'], $vacRules['aliases']), |
|
695 | 695 | ); |
696 | 696 | if (!isset($account_id)) |
697 | 697 | { |
@@ -715,10 +715,10 @@ discard block |
||
715 | 715 | } |
716 | 716 | else |
717 | 717 | { |
718 | - $content['msg'] = lang('error').':'.lang('Serverside Filterrules (Sieve) are not activated').'. '.lang('Please contact your Administrator to validate if your Server supports Serverside Filterrules, and how to enable them in EGroupware for your active Account (%1) with ID:%2.',$this->currentIdentity,$icServer->ImapServerId); |
|
719 | - $content['hideIfSieveDisabled']='mail_DisplayNone'; |
|
718 | + $content['msg'] = lang('error').':'.lang('Serverside Filterrules (Sieve) are not activated').'. '.lang('Please contact your Administrator to validate if your Server supports Serverside Filterrules, and how to enable them in EGroupware for your active Account (%1) with ID:%2.', $this->currentIdentity, $icServer->ImapServerId); |
|
719 | + $content['hideIfSieveDisabled'] = 'mail_DisplayNone'; |
|
720 | 720 | } |
721 | - $vtmpl->exec('mail.mail_sieve.editVacation',$content,$sel_options,$readonlys,$preserv,2); |
|
721 | + $vtmpl->exec('mail.mail_sieve.editVacation', $content, $sel_options, $readonlys, $preserv, 2); |
|
722 | 722 | } |
723 | 723 | |
724 | 724 | /** |
@@ -732,7 +732,7 @@ discard block |
||
732 | 732 | static function strip_rfc882_addresses($_addresses) |
733 | 733 | { |
734 | 734 | $addresses = array(); |
735 | - foreach(Mail::parseAddressList($_addresses) as $addr) |
|
735 | + foreach (Mail::parseAddressList($_addresses) as $addr) |
|
736 | 736 | { |
737 | 737 | if ($addr->valid) |
738 | 738 | { |
@@ -749,7 +749,7 @@ discard block |
||
749 | 749 | * @param boolean $_reschedule do nothing but reschedule the job by 3 minutes |
750 | 750 | * @return void |
751 | 751 | */ |
752 | - static function setAsyncJob (array $_vacation, $_reschedule=false) |
|
752 | + static function setAsyncJob(array $_vacation, $_reschedule = false) |
|
753 | 753 | { |
754 | 754 | if (!($_vacation['acc_id'] > 0)) |
755 | 755 | { |
@@ -761,19 +761,19 @@ discard block |
||
761 | 761 | $async_id = !empty($_vacation['id']) ? $_vacation['id'] : 'mail-vacation-'.$_vacation['account_id']; |
762 | 762 | $async->delete($async_id); |
763 | 763 | |
764 | - $end_date = $_vacation['end_date'] + 24*3600; // end-date is inclusive, so we have to add 24h |
|
764 | + $end_date = $_vacation['end_date'] + 24 * 3600; // end-date is inclusive, so we have to add 24h |
|
765 | 765 | if ($_vacation['status'] == 'by_date' && time() < $end_date && !$_reschedule) |
766 | 766 | { |
767 | 767 | $time = time() < $_vacation['start_date'] ? $_vacation['start_date'] : $end_date; |
768 | - $async->set_timer($time,$async_id, 'mail_sieve::async_vacation', $_vacation, $_vacation['account_id']); |
|
768 | + $async->set_timer($time, $async_id, 'mail_sieve::async_vacation', $_vacation, $_vacation['account_id']); |
|
769 | 769 | } |
770 | 770 | if ($_reschedule) |
771 | 771 | { |
772 | - $_vacation['rescheduled'] = $_vacation['rescheduled'] ? 2*$_vacation['rescheduled'] : 5; |
|
772 | + $_vacation['rescheduled'] = $_vacation['rescheduled'] ? 2 * $_vacation['rescheduled'] : 5; |
|
773 | 773 | // only try to reschedule for 2 days max |
774 | 774 | if ($_vacation['rescheduled'] <= 2 * 24 * 60) |
775 | 775 | { |
776 | - $time = time() + 60*($_vacation['rescheduled']); |
|
776 | + $time = time() + 60 * ($_vacation['rescheduled']); |
|
777 | 777 | unset($_vacation['next']); |
778 | 778 | unset($_vacation['times']); |
779 | 779 | $async->set_timer($time, $async_id, 'mail_sieve::async_vacation', $_vacation, $_vacation['account_id']); |
@@ -809,7 +809,7 @@ discard block |
||
809 | 809 | } |
810 | 810 | catch (Exception $e) { |
811 | 811 | error_log(__METHOD__.'('.array2string($_vacation).' failed '.$e->getMessage()); |
812 | - self::setAsyncJob($_vacation, true); // reschedule |
|
812 | + self::setAsyncJob($_vacation, true); // reschedule |
|
813 | 813 | $ret = false; |
814 | 814 | } |
815 | 815 | |
@@ -824,7 +824,7 @@ discard block |
||
824 | 824 | * |
825 | 825 | * @return boolean |
826 | 826 | */ |
827 | - function checkRule($_vacation,$_checkAddresses=true) |
|
827 | + function checkRule($_vacation, $_checkAddresses = true) |
|
828 | 828 | { |
829 | 829 | $this->errorStack = array(); |
830 | 830 | |
@@ -838,12 +838,12 @@ discard block |
||
838 | 838 | $this->errorStack['days'] = lang('Please select the number of days to wait between responses').'!'; |
839 | 839 | } |
840 | 840 | |
841 | - if(is_array($_vacation['addresses']) && !empty($_vacation['addresses'])) |
|
841 | + if (is_array($_vacation['addresses']) && !empty($_vacation['addresses'])) |
|
842 | 842 | { |
843 | - $regexp="/^[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\.-][a-z0-9]+)*)+\\.[a-z]{2,}$/i"; |
|
843 | + $regexp = "/^[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\.-][a-z0-9]+)*)+\\.[a-z]{2,}$/i"; |
|
844 | 844 | foreach ($_vacation['addresses'] as $addr) |
845 | 845 | { |
846 | - if (!preg_match($regexp,$addr) && $_checkAddresses) |
|
846 | + if (!preg_match($regexp, $addr) && $_checkAddresses) |
|
847 | 847 | { |
848 | 848 | $this->errorStack['addresses'] = lang('One address is not valid').'!'; |
849 | 849 | } |
@@ -859,23 +859,23 @@ discard block |
||
859 | 859 | { |
860 | 860 | $this->errorStack['status'] = lang('Activating by date requires a start- AND end-date!'); |
861 | 861 | } |
862 | - elseif($_vacation['start_date'] > $_vacation['end_date']) |
|
862 | + elseif ($_vacation['start_date'] > $_vacation['end_date']) |
|
863 | 863 | { |
864 | 864 | $this->errorStack['status'] = lang('Vacation start-date must be BEFORE the end-date!'); |
865 | 865 | } |
866 | 866 | } |
867 | 867 | if ($_vacation['forwards']) |
868 | 868 | { |
869 | - foreach(preg_split('/, ?/',$_vacation['forwards']) as $addr) |
|
869 | + foreach (preg_split('/, ?/', $_vacation['forwards']) as $addr) |
|
870 | 870 | { |
871 | - if (!preg_match($regexp,$addr) && $_checkAddresses) |
|
871 | + if (!preg_match($regexp, $addr) && $_checkAddresses) |
|
872 | 872 | { |
873 | 873 | $this->errorStack['forwards'] = lang('One address is not valid'.'!'); |
874 | 874 | } |
875 | 875 | } |
876 | 876 | } |
877 | 877 | //error_log(__METHOD__. array2string($this->errorStack)); |
878 | - if(count($this->errorStack) == 0) |
|
878 | + if (count($this->errorStack) == 0) |
|
879 | 879 | { |
880 | 880 | return true; |
881 | 881 | } |
@@ -896,14 +896,14 @@ discard block |
||
896 | 896 | |
897 | 897 | foreach ($orders as $keys => $val) |
898 | 898 | { |
899 | - $orders[$keys] = $val -1; |
|
899 | + $orders[$keys] = $val - 1; |
|
900 | 900 | } |
901 | 901 | |
902 | 902 | $this->getRules(null); |
903 | 903 | |
904 | 904 | $newrules = $this->rules; |
905 | 905 | |
906 | - foreach($orders as $keys => $ruleID) |
|
906 | + foreach ($orders as $keys => $ruleID) |
|
907 | 907 | { |
908 | 908 | $newrules[$keys] = $this->rules[$ruleID]; |
909 | 909 | } |
@@ -932,24 +932,24 @@ discard block |
||
932 | 932 | switch ($action) |
933 | 933 | { |
934 | 934 | case 'delete': |
935 | - if ($checked === count($this->rules)-1) |
|
935 | + if ($checked === count($this->rules) - 1) |
|
936 | 936 | { |
937 | - $msg = lang('rule with priority ') . $checked . lang(' deleted!'); |
|
937 | + $msg = lang('rule with priority ').$checked.lang(' deleted!'); |
|
938 | 938 | } |
939 | 939 | else |
940 | 940 | { |
941 | 941 | |
942 | - $msg = lang('rule with priority ') . $checked . lang(' deleted!') . lang(' And the rule with priority %1, now got the priority %2',$checked+1,$checked); |
|
942 | + $msg = lang('rule with priority ').$checked.lang(' deleted!').lang(' And the rule with priority %1, now got the priority %2', $checked + 1, $checked); |
|
943 | 943 | } |
944 | 944 | unset($this->rules[$checked]); |
945 | 945 | $this->rules = array_values($this->rules); |
946 | 946 | break; |
947 | 947 | case 'enable': |
948 | - $msg = lang('rule with priority ') . $checked . lang(' enabled!'); |
|
948 | + $msg = lang('rule with priority ').$checked.lang(' enabled!'); |
|
949 | 949 | $this->rules[$checked][status] = 'ENABLED'; |
950 | 950 | break; |
951 | 951 | case 'disable': |
952 | - $msg = lang('rule with priority ') . $checked . lang(' disabled!'); |
|
952 | + $msg = lang('rule with priority ').$checked.lang(' disabled!'); |
|
953 | 953 | $this->rules[$checked][status] = 'DISABLED'; |
954 | 954 | break; |
955 | 955 | case 'move': |
@@ -961,7 +961,7 @@ discard block |
||
961 | 961 | |
962 | 962 | $response = Api\Json\Response::get(); |
963 | 963 | |
964 | - if($result) |
|
964 | + if ($result) |
|
965 | 965 | { |
966 | 966 | $response->message($result); |
967 | 967 | return; |
@@ -979,11 +979,11 @@ discard block |
||
979 | 979 | */ |
980 | 980 | function buildRule($rule) |
981 | 981 | { |
982 | - $andor = ' '. lang('and') .' '; |
|
982 | + $andor = ' '.lang('and').' '; |
|
983 | 983 | $started = 0; |
984 | 984 | if ($rule['anyof']) |
985 | 985 | { |
986 | - $andor = ' '. lang('or') .' '; |
|
986 | + $andor = ' '.lang('or').' '; |
|
987 | 987 | } |
988 | 988 | $complete = lang('IF').' '; |
989 | 989 | if ($rule['unconditional']) |
@@ -992,8 +992,8 @@ discard block |
||
992 | 992 | } |
993 | 993 | if ($rule['from']) |
994 | 994 | { |
995 | - $match = $this->setMatchType($rule['from'],$rule['regexp']); |
|
996 | - $complete .= "'From:' " . $match . " '" . $rule['from'] . "'"; |
|
995 | + $match = $this->setMatchType($rule['from'], $rule['regexp']); |
|
996 | + $complete .= "'From:' ".$match." '".$rule['from']."'"; |
|
997 | 997 | $started = 1; |
998 | 998 | } |
999 | 999 | if ($rule['to']) |
@@ -1002,8 +1002,8 @@ discard block |
||
1002 | 1002 | { |
1003 | 1003 | $complete .= $andor; |
1004 | 1004 | } |
1005 | - $match = $this->setMatchType($rule['to'],$rule['regexp']); |
|
1006 | - $complete .= "'To:' " . $match . " '" . $rule['to'] . "'"; |
|
1005 | + $match = $this->setMatchType($rule['to'], $rule['regexp']); |
|
1006 | + $complete .= "'To:' ".$match." '".$rule['to']."'"; |
|
1007 | 1007 | $started = 1; |
1008 | 1008 | } |
1009 | 1009 | if ($rule['subject']) |
@@ -1012,8 +1012,8 @@ discard block |
||
1012 | 1012 | { |
1013 | 1013 | $complete .= $andor; |
1014 | 1014 | } |
1015 | - $match = $this->setMatchType($rule['subject'],$rule['regexp']); |
|
1016 | - $complete .= "'Subject:' " . $match . " '" . $rule['subject'] . "'"; |
|
1015 | + $match = $this->setMatchType($rule['subject'], $rule['regexp']); |
|
1016 | + $complete .= "'Subject:' ".$match." '".$rule['subject']."'"; |
|
1017 | 1017 | $started = 1; |
1018 | 1018 | } |
1019 | 1019 | if ($rule['field'] && $rule['field_val']) |
@@ -1022,8 +1022,8 @@ discard block |
||
1022 | 1022 | { |
1023 | 1023 | $complete .= $andor; |
1024 | 1024 | } |
1025 | - $match = $this->setMatchType($rule['field_val'],$rule['regexp']); |
|
1026 | - $complete .= "'" . $rule['field'] . "' " . $match . " '" . $rule['field_val'] . "'"; |
|
1025 | + $match = $this->setMatchType($rule['field_val'], $rule['regexp']); |
|
1026 | + $complete .= "'".$rule['field']."' ".$match." '".$rule['field_val']."'"; |
|
1027 | 1027 | $started = 1; |
1028 | 1028 | } |
1029 | 1029 | if ($rule['size']) |
@@ -1037,7 +1037,7 @@ discard block |
||
1037 | 1037 | { |
1038 | 1038 | $complete .= $andor; |
1039 | 1039 | } |
1040 | - $complete .= "message " . $xthan . $rule['size'] . "KB'"; |
|
1040 | + $complete .= "message ".$xthan.$rule['size']."KB'"; |
|
1041 | 1041 | $started = 1; |
1042 | 1042 | } |
1043 | 1043 | if (!empty($rule['field_bodytransform'])) |
@@ -1046,7 +1046,7 @@ discard block |
||
1046 | 1046 | { |
1047 | 1047 | $newruletext .= ", "; |
1048 | 1048 | } |
1049 | - $btransform = " :raw "; |
|
1049 | + $btransform = " :raw "; |
|
1050 | 1050 | $match = ' :contains'; |
1051 | 1051 | if ($rule['bodytransform']) |
1052 | 1052 | { |
@@ -1060,11 +1060,11 @@ discard block |
||
1060 | 1060 | { |
1061 | 1061 | $match = ':regex'; |
1062 | 1062 | } |
1063 | - $complete .= " body " . $btransform . $match . " \"" . $rule['field_bodytransform'] . "\""; |
|
1063 | + $complete .= " body ".$btransform.$match." \"".$rule['field_bodytransform']."\""; |
|
1064 | 1064 | $started = 1; |
1065 | 1065 | |
1066 | 1066 | } |
1067 | - if ($rule['ctype']!= '0' && !empty($rule['ctype'])) |
|
1067 | + if ($rule['ctype'] != '0' && !empty($rule['ctype'])) |
|
1068 | 1068 | { |
1069 | 1069 | if ($started) |
1070 | 1070 | { |
@@ -1076,7 +1076,7 @@ discard block |
||
1076 | 1076 | { |
1077 | 1077 | $ctype_subtype = "/"; |
1078 | 1078 | } |
1079 | - $complete .= " body :content " . " \"" . $btransform_ctype . $ctype_subtype . $rule['field_ctype_val'] . "\"" . " :contains \"\""; |
|
1079 | + $complete .= " body :content "." \"".$btransform_ctype.$ctype_subtype.$rule['field_ctype_val']."\""." :contains \"\""; |
|
1080 | 1080 | $started = 1; |
1081 | 1081 | //error_log(__CLASS__."::".__METHOD__.array2string(Mail\Script::$btransform_ctype_array)); |
1082 | 1082 | } |
@@ -1084,19 +1084,19 @@ discard block |
||
1084 | 1084 | { |
1085 | 1085 | $complete .= ' '.lang('THEN').' '; |
1086 | 1086 | } |
1087 | - if (preg_match("/folder/i",$rule['action'])) |
|
1087 | + if (preg_match("/folder/i", $rule['action'])) |
|
1088 | 1088 | { |
1089 | - $complete .= lang('file into')." '" . $rule['action_arg'] . "';"; |
|
1089 | + $complete .= lang('file into')." '".$rule['action_arg']."';"; |
|
1090 | 1090 | } |
1091 | - if (preg_match("/reject/i",$rule['action'])) |
|
1091 | + if (preg_match("/reject/i", $rule['action'])) |
|
1092 | 1092 | { |
1093 | - $complete .= lang('reject with')." '" . $rule['action_arg'] . "'."; |
|
1093 | + $complete .= lang('reject with')." '".$rule['action_arg']."'."; |
|
1094 | 1094 | } |
1095 | - if (preg_match("/address/i",$rule['action'])) |
|
1095 | + if (preg_match("/address/i", $rule['action'])) |
|
1096 | 1096 | { |
1097 | - $complete .= lang('forward to').' ' . $rule['action_arg'] .'.'; |
|
1097 | + $complete .= lang('forward to').' '.$rule['action_arg'].'.'; |
|
1098 | 1098 | } |
1099 | - if (preg_match("/discard/i",$rule['action'])) |
|
1099 | + if (preg_match("/discard/i", $rule['action'])) |
|
1100 | 1100 | { |
1101 | 1101 | $complete .= lang('discard').'.'; |
1102 | 1102 | } |
@@ -1118,7 +1118,7 @@ discard block |
||
1118 | 1118 | * @param {string} $regex regular expresion as pattern to be matched |
1119 | 1119 | * @return {string} return the type |
1120 | 1120 | */ |
1121 | - function setMatchType (&$matchstr, $regex = false) |
|
1121 | + function setMatchType(&$matchstr, $regex = false) |
|
1122 | 1122 | { |
1123 | 1123 | $match = lang('contains'); |
1124 | 1124 | if (preg_match("/^\s*!/", $matchstr)) |
@@ -1143,11 +1143,11 @@ discard block |
||
1143 | 1143 | } |
1144 | 1144 | if ($regex && preg_match("/^\s*\\\\!/", $matchstr)) |
1145 | 1145 | { |
1146 | - $matchstr = preg_replace("/^\s*\\\\!/","!",$matchstr); |
|
1146 | + $matchstr = preg_replace("/^\s*\\\\!/", "!", $matchstr); |
|
1147 | 1147 | } |
1148 | 1148 | else |
1149 | 1149 | { |
1150 | - $matchstr = preg_replace("/^\s*!/","",$matchstr); |
|
1150 | + $matchstr = preg_replace("/^\s*!/", "", $matchstr); |
|
1151 | 1151 | } |
1152 | 1152 | return $match; |
1153 | 1153 | } |
@@ -1157,9 +1157,9 @@ discard block |
||
1157 | 1157 | */ |
1158 | 1158 | function saveSessionData() |
1159 | 1159 | { |
1160 | - $sessionData['sieve_rules'] = $this->rules; |
|
1160 | + $sessionData['sieve_rules'] = $this->rules; |
|
1161 | 1161 | $sessionData['sieve_rulesByID'] = $this->rulesByID; |
1162 | - $sessionData['sieve_scriptToEdit'] = $this->scriptToEdit; |
|
1162 | + $sessionData['sieve_scriptToEdit'] = $this->scriptToEdit; |
|
1163 | 1163 | Api\Cache::setSession(__CLASS__, 'sieve_session_data', $sessionData); |
1164 | 1164 | } |
1165 | 1165 | |
@@ -1185,15 +1185,15 @@ discard block |
||
1185 | 1185 | { |
1186 | 1186 | try { |
1187 | 1187 | $this->account->imapServer()->retrieveRules(); |
1188 | - $this->rules = $this->account->imapServer()->getRules(); |
|
1188 | + $this->rules = $this->account->imapServer()->getRules(); |
|
1189 | 1189 | $this->rulesByID = $this->rules[$ruleID]; |
1190 | - $this->vacation = $this->account->imapServer()->getVacation(); |
|
1190 | + $this->vacation = $this->account->imapServer()->getVacation(); |
|
1191 | 1191 | } |
1192 | - catch(Exception $e) { |
|
1192 | + catch (Exception $e) { |
|
1193 | 1193 | error_log(__METHOD__.__LINE__.$e->getMessage().': '.$e->details); |
1194 | - $this->rules = array(); |
|
1194 | + $this->rules = array(); |
|
1195 | 1195 | $this->rulesByID = array(); |
1196 | - $this->vacation = array(); |
|
1196 | + $this->vacation = array(); |
|
1197 | 1197 | return false; |
1198 | 1198 | } |
1199 | 1199 | return true; |
@@ -1205,9 +1205,9 @@ discard block |
||
1205 | 1205 | function restoreSessionData() |
1206 | 1206 | { |
1207 | 1207 | $sessionData = Api\Cache::getSession(__CLASS__, 'sieve_session_data'); |
1208 | - $this->rules = $sessionData['sieve_rules']; |
|
1208 | + $this->rules = $sessionData['sieve_rules']; |
|
1209 | 1209 | $this->rulesByID = $sessionData['sieve_rulesByID']; |
1210 | - $this->scriptToEdit = $sessionData['sieve_scriptToEdit']; |
|
1210 | + $this->scriptToEdit = $sessionData['sieve_scriptToEdit']; |
|
1211 | 1211 | } |
1212 | 1212 | |
1213 | 1213 | /** |
@@ -1221,14 +1221,14 @@ discard block |
||
1221 | 1221 | $rows = array(); |
1222 | 1222 | $this->getRules(null); |
1223 | 1223 | |
1224 | - if (is_array($this->rules) && !empty($this->rules) ) |
|
1224 | + if (is_array($this->rules) && !empty($this->rules)) |
|
1225 | 1225 | { |
1226 | 1226 | $rows = $this->rules; |
1227 | 1227 | |
1228 | - foreach ($rows as &$row ) |
|
1228 | + foreach ($rows as &$row) |
|
1229 | 1229 | { |
1230 | 1230 | $row['rules'] = $this->buildRule($row); |
1231 | - $row['ruleID'] =(string)(($row['priority'] -1) / 2 ); |
|
1231 | + $row['ruleID'] = (string)(($row['priority'] - 1) / 2); |
|
1232 | 1232 | if ($row ['status'] === 'DISABLED') |
1233 | 1233 | { |
1234 | 1234 | $row['class'] = 'mail_sieve_DISABLED'; |
@@ -1241,7 +1241,7 @@ discard block |
||
1241 | 1241 | return false; |
1242 | 1242 | } |
1243 | 1243 | // Shift one down, because in grid the first row is reserved for header |
1244 | - array_unshift($rows,array(''=> '')); |
|
1244 | + array_unshift($rows, array(''=> '')); |
|
1245 | 1245 | return $rows; |
1246 | 1246 | } |
1247 | 1247 | |
@@ -1252,7 +1252,7 @@ discard block |
||
1252 | 1252 | */ |
1253 | 1253 | private function get_actions() |
1254 | 1254 | { |
1255 | - $actions =array( |
|
1255 | + $actions = array( |
|
1256 | 1256 | |
1257 | 1257 | 'edit' => array( |
1258 | 1258 | 'caption' => 'Edit', |
@@ -1291,7 +1291,7 @@ discard block |
||
1291 | 1291 | * @param int $_mailaccountToSearch |
1292 | 1292 | * @param boolean $_noPrefixID = false, if set to true folders name does not get prefixed by account id |
1293 | 1293 | */ |
1294 | - function ajax_getFolders ($_searchStringLength=2, $_returnList=false, $_mailaccountToSearch=null, $_noPrefixId=false) |
|
1294 | + function ajax_getFolders($_searchStringLength = 2, $_returnList = false, $_mailaccountToSearch = null, $_noPrefixId = false) |
|
1295 | 1295 | { |
1296 | 1296 | $mailCompose = new mail_compose(); |
1297 | 1297 | if ($_REQUEST['noPrefixId']) $_noPrefixId = $_REQUEST['noPrefixId']; |
@@ -2126,11 +2126,11 @@ discard block |
||
2126 | 2126 | } else { |
2127 | 2127 | //$this->sessionData['body'] = @htmlspecialchars(lang("on")." ".$headers['DATE']." ".$mail_bo->decode_header($fromAddress), ENT_QUOTES) . " ".lang("wrote").":\r\n"; |
2128 | 2128 | // take care the way the ReplyHeader is created here, is used later on in uicompose::compose, in case you force replys to be HTML (prefs) |
2129 | - $this->sessionData['body'] = " \r\n \r\n".'----------------'.lang("original message").'-----------------'."\r\n". |
|
2130 | - @htmlspecialchars(lang("from")).": ".$fromAddress."\r\n". |
|
2129 | + $this->sessionData['body'] = " \r\n \r\n".'----------------'.lang("original message").'-----------------'."\r\n". |
|
2130 | + @htmlspecialchars(lang("from")).": ".$fromAddress."\r\n". |
|
2131 | 2131 | $toAddress.$ccAddress. |
2132 | 2132 | @htmlspecialchars(lang("date").": ".$headers['DATE'], ENT_QUOTES | ENT_IGNORE,Mail::$displayCharset, false)."\r\n". |
2133 | - '-------------------------------------------------'."\r\n \r\n "; |
|
2133 | + '-------------------------------------------------'."\r\n \r\n "; |
|
2134 | 2134 | $this->sessionData['mimeType'] = 'plain'; |
2135 | 2135 | |
2136 | 2136 | for($i=0; $i<count($bodyParts); $i++) { |
@@ -2968,7 +2968,7 @@ discard block |
||
2968 | 2968 | //error_log(__METHOD__.__LINE__."Number of Folders to move copy the message to:".count($folder)); |
2969 | 2969 | //error_log(__METHOD__.__LINE__.array2string($folder)); |
2970 | 2970 | if ((count($folder) > 0) || (isset($this->sessionData['uid']) && isset($this->sessionData['messageFolder'])) |
2971 | - || (isset($this->sessionData['forwardFlag']) && isset($this->sessionData['sourceFolder']))) { |
|
2971 | + || (isset($this->sessionData['forwardFlag']) && isset($this->sessionData['sourceFolder']))) { |
|
2972 | 2972 | $mail_bo = $this->mail_bo; |
2973 | 2973 | $mail_bo->openConnection(); |
2974 | 2974 | //$mail_bo->reopen($this->sessionData['messageFolder']); |
@@ -82,7 +82,10 @@ discard block |
||
82 | 82 | { |
83 | 83 | $this->mailPreferences['message_forwarding'] = 'asmail'; |
84 | 84 | } |
85 | - if (is_null(Mail::$mailConfig)) Mail::$mailConfig = Api\Config::read('mail'); |
|
85 | + if (is_null(Mail::$mailConfig)) |
|
86 | + { |
|
87 | + Mail::$mailConfig = Api\Config::read('mail'); |
|
88 | + } |
|
86 | 89 | |
87 | 90 | $this->mailPreferences =& $this->mail_bo->mailPreferences; |
88 | 91 | } |
@@ -96,11 +99,21 @@ discard block |
||
96 | 99 | { |
97 | 100 | if ($this->mail_bo->profileID!=$_icServerID) |
98 | 101 | { |
99 | - if (Mail::$debug) error_log(__METHOD__.__LINE__.'->'.$this->mail_bo->profileID.'<->'.$_icServerID); |
|
102 | + if (Mail::$debug) |
|
103 | + { |
|
104 | + error_log(__METHOD__.__LINE__.'->'.$this->mail_bo->profileID.'<->'.$_icServerID); |
|
105 | + } |
|
100 | 106 | $this->mail_bo = Mail::getInstance(false,$_icServerID); |
101 | - if (Mail::$debug) error_log(__METHOD__.__LINE__.' Fetched IC Server:'.$this->mail_bo->profileID.':'.function_backtrace()); |
|
107 | + if (Mail::$debug) |
|
108 | + { |
|
109 | + error_log(__METHOD__.__LINE__.' Fetched IC Server:'.$this->mail_bo->profileID.':'.function_backtrace()); |
|
110 | + } |
|
102 | 111 | // no icServer Object: something failed big time |
103 | - if (!isset($this->mail_bo->icServer)) exit; // ToDo: Exception or the dialog for setting up a server config |
|
112 | + if (!isset($this->mail_bo->icServer)) |
|
113 | + { |
|
114 | + exit; |
|
115 | + } |
|
116 | + // ToDo: Exception or the dialog for setting up a server config |
|
104 | 117 | $this->mail_bo->openConnection($this->mail_bo->profileID); |
105 | 118 | $this->mailPreferences =& $this->mail_bo->mailPreferences; |
106 | 119 | } |
@@ -265,13 +278,17 @@ discard block |
||
265 | 278 | { |
266 | 279 | foreach (array_keys($actions) as $key) |
267 | 280 | { |
268 | - if (!in_array($key, array('send','button[saveAsDraft]','uploadForCompose' ))) { |
|
281 | + if (!in_array($key, array('send','button[saveAsDraft]','uploadForCompose' ))) |
|
282 | + { |
|
269 | 283 | $actions[$key]['toolbarDefault'] = false; |
270 | 284 | } |
271 | 285 | } |
272 | 286 | unset($actions['pgp']); |
273 | 287 | } |
274 | - if ($GLOBALS['egw_info']['server']['disable_pgp_encryption']) unset($actions['pgp']); |
|
288 | + if ($GLOBALS['egw_info']['server']['disable_pgp_encryption']) |
|
289 | + { |
|
290 | + unset($actions['pgp']); |
|
291 | + } |
|
275 | 292 | // remove vfs actions if the user has no run access to filemanager |
276 | 293 | if (!$GLOBALS['egw_info']['user']['apps']['filemanager']) |
277 | 294 | { |
@@ -292,7 +309,10 @@ discard block |
||
292 | 309 | */ |
293 | 310 | function compose(array $_content=null,$msg=null, $_focusElement='to',$suppressSigOnTop=false, $isReply=false) |
294 | 311 | { |
295 | - if ($msg) Framework::message($msg); |
|
312 | + if ($msg) |
|
313 | + { |
|
314 | + Framework::message($msg); |
|
315 | + } |
|
296 | 316 | |
297 | 317 | if (!empty($GLOBALS['egw_info']['user']['preferences']['mail']['LastSignatureIDUsed'])) |
298 | 318 | { |
@@ -324,21 +344,31 @@ discard block |
||
324 | 344 | if ($appendix_data['emails']) |
325 | 345 | { |
326 | 346 | try { |
327 | - if ($appendix_data['emails']['processedmail_id']) $_content['processedmail_id'] .= ','.$appendix_data['emails']['processedmail_id']; |
|
347 | + if ($appendix_data['emails']['processedmail_id']) |
|
348 | + { |
|
349 | + $_content['processedmail_id'] .= ','.$appendix_data['emails']['processedmail_id']; |
|
350 | + } |
|
328 | 351 | $attched_uids = $this->_get_uids_as_attachments($appendix_data['emails']['ids'], $_content['serverID']); |
329 | 352 | if (is_array($attched_uids)) |
330 | 353 | { |
331 | 354 | $_content['attachments'] = array_merge_recursive((array)$_content['attachments'], $attched_uids); |
332 | 355 | } |
333 | - } catch (Exception $ex) { |
|
356 | + } |
|
357 | + catch (Exception $ex) { |
|
334 | 358 | Framework::message($ex->getMessage(), 'error'); |
335 | 359 | } |
336 | 360 | $suppressSigOnTop = true; |
337 | 361 | unset($appendix_data); |
338 | 362 | } |
339 | 363 | |
340 | - if (isset($_GET['reply_id'])) $replyID = $_GET['reply_id']; |
|
341 | - if (!$replyID && isset($_GET['id'])) $replyID = $_GET['id']; |
|
364 | + if (isset($_GET['reply_id'])) |
|
365 | + { |
|
366 | + $replyID = $_GET['reply_id']; |
|
367 | + } |
|
368 | + if (!$replyID && isset($_GET['id'])) |
|
369 | + { |
|
370 | + $replyID = $_GET['id']; |
|
371 | + } |
|
342 | 372 | |
343 | 373 | // Process different places we can use as a start for composing an email |
344 | 374 | $actionToProcess = 'compose'; |
@@ -352,7 +382,10 @@ discard block |
||
352 | 382 | )); |
353 | 383 | if (Mail\Smime::get_acc_smime($this->mail_bo->profileID)) |
354 | 384 | { |
355 | - if (isset($_GET['smime_type'])) $smime_type = $_GET['smime_type']; |
|
385 | + if (isset($_GET['smime_type'])) |
|
386 | + { |
|
387 | + $smime_type = $_GET['smime_type']; |
|
388 | + } |
|
356 | 389 | // pre set smime_sign and smime_encrypt actions if the original |
357 | 390 | // message is smime. |
358 | 391 | $_content['smime_sign'] = $smime_type == (Mail\Smime::TYPE_SIGN || |
@@ -415,7 +448,10 @@ discard block |
||
415 | 448 | $suppressSigOnTop = true; |
416 | 449 | foreach ($_content['uploadForCompose'] as $i => &$upload) |
417 | 450 | { |
418 | - if (!isset($upload['file'])) $upload['file'] = $upload['tmp_name']; |
|
451 | + if (!isset($upload['file'])) |
|
452 | + { |
|
453 | + $upload['file'] = $upload['tmp_name']; |
|
454 | + } |
|
419 | 455 | try |
420 | 456 | { |
421 | 457 | $upload['file'] = $upload['tmp_name'] = Mail::checkFileBasics($upload,$this->composeID,false); |
@@ -449,9 +485,15 @@ discard block |
||
449 | 485 | $remove=false; |
450 | 486 | foreach(array_keys($toDelete) as $k) |
451 | 487 | { |
452 | - if ($att['tmp_name']==$k) $remove=true; |
|
488 | + if ($att['tmp_name']==$k) |
|
489 | + { |
|
490 | + $remove=true; |
|
491 | + } |
|
492 | + } |
|
493 | + if (!$remove) |
|
494 | + { |
|
495 | + $_content['attachments'][] = $att; |
|
453 | 496 | } |
454 | - if (!$remove) $_content['attachments'][] = $att; |
|
455 | 497 | } |
456 | 498 | } |
457 | 499 | // someone clicked something like send, or saveAsDraft |
@@ -466,8 +508,7 @@ discard block |
||
466 | 508 | //error_log(__METHOD__.__LINE__.array2string($_content)); |
467 | 509 | if (!empty($_content['serverID']) && $_content['serverID'] != $this->mail_bo->profileID && |
468 | 510 | ($_content['composeToolbar'] === 'send' || $_content['button']['saveAsDraft']||$_content['button']['saveAsDraftAndPrint']) |
469 | - ) |
|
470 | - { |
|
511 | + ) { |
|
471 | 512 | $this->changeProfile($_content['serverID']); |
472 | 513 | $composeProfile = $this->mail_bo->profileID; |
473 | 514 | } |
@@ -547,7 +588,10 @@ discard block |
||
547 | 588 | //$this->sessionData['uid'][] = $fhA['msgUID']; |
548 | 589 | //$this->sessionData['forwardedUID'][] = $fhA['msgUID']; |
549 | 590 | $idsForRefresh[] = mail_ui::generateRowID($fhA['profileID'], $fhA['folder'], $fhA['msgUID'], $_prependApp=false); |
550 | - if (!empty($fhA['folder'])) $workingFolder = $fhA['folder']; |
|
591 | + if (!empty($fhA['folder'])) |
|
592 | + { |
|
593 | + $workingFolder = $fhA['folder']; |
|
594 | + } |
|
551 | 595 | } |
552 | 596 | } |
553 | 597 | if ($_content['mode']=='reply' && !empty($_content['processedmail_id'])) |
@@ -598,7 +642,10 @@ discard block |
||
598 | 642 | } |
599 | 643 | } |
600 | 644 | |
601 | - if ($activeProfile != $composeProfile) $this->changeProfile($activeProfile); |
|
645 | + if ($activeProfile != $composeProfile) |
|
646 | + { |
|
647 | + $this->changeProfile($activeProfile); |
|
648 | + } |
|
602 | 649 | $insertSigOnTop = false; |
603 | 650 | $content = (is_array($_content)?$_content:array()); |
604 | 651 | if ($_contentHasMimeType) |
@@ -627,7 +674,10 @@ discard block |
||
627 | 674 | { |
628 | 675 | foreach ($contentArr as $k =>&$elem) |
629 | 676 | { |
630 | - if (stripos($elem,'<pre>')!==false) $elem = str_replace(array("\r\n","\n","\r"),array("<br>","<br>","<br>"),$elem); |
|
677 | + if (stripos($elem,'<pre>')!==false) |
|
678 | + { |
|
679 | + $elem = str_replace(array("\r\n","\n","\r"),array("<br>","<br>","<br>"),$elem); |
|
680 | + } |
|
631 | 681 | } |
632 | 682 | $content['mail_htmltext'] = implode('',$contentArr); |
633 | 683 | } |
@@ -669,8 +719,7 @@ discard block |
||
669 | 719 | if ( !empty($content['body']) && |
670 | 720 | (!empty($composeCache['mailaccount']) && !empty($_content['mailaccount']) && $_content['mailaccount'] != $composeCache['mailaccount']) || |
671 | 721 | (!empty($composeCache['mailidentity']) && !empty($_content['mailidentity']) && $_content['mailidentity'] != $composeCache['mailidentity']) |
672 | - ) |
|
673 | - { |
|
722 | + ) { |
|
674 | 723 | $buttonClicked = true; |
675 | 724 | $suppressSigOnTop = true; |
676 | 725 | if (!empty($composeCache['mailaccount']) && !empty($_content['mailaccount']) && $_content['mailaccount'] != $composeCache['mailaccount']) |
@@ -686,7 +735,10 @@ discard block |
||
686 | 735 | else |
687 | 736 | { |
688 | 737 | $newSig = $this->mail_bo->getDefaultIdentity(); |
689 | - if ($newSig === false) $newSig = -2; |
|
738 | + if ($newSig === false) |
|
739 | + { |
|
740 | + $newSig = -2; |
|
741 | + } |
|
690 | 742 | } |
691 | 743 | } |
692 | 744 | $_oldSig = $composeCache['mailidentity']; |
@@ -694,7 +746,10 @@ discard block |
||
694 | 746 | |
695 | 747 | if ($_oldSig != $_signatureid) |
696 | 748 | { |
697 | - if($this->_debug) error_log(__METHOD__.__LINE__.' old,new ->'.$_oldSig.','.$_signatureid.'#'.$content['body']); |
|
749 | + if($this->_debug) |
|
750 | + { |
|
751 | + error_log(__METHOD__.__LINE__.' old,new ->'.$_oldSig.','.$_signatureid.'#'.$content['body']); |
|
752 | + } |
|
698 | 753 | // prepare signatures, the selected sig may be used on top of the body |
699 | 754 | try |
700 | 755 | { |
@@ -724,7 +779,10 @@ discard block |
||
724 | 779 | { |
725 | 780 | $oldSigText = $this->convertHTMLToText($oldSigText,true,true); |
726 | 781 | $sigText = $this->convertHTMLToText($sigText,true,true); |
727 | - if($this->_debug) error_log(__METHOD__." Old signature:".$oldSigText); |
|
782 | + if($this->_debug) |
|
783 | + { |
|
784 | + error_log(__METHOD__." Old signature:".$oldSigText); |
|
785 | + } |
|
728 | 786 | } |
729 | 787 | |
730 | 788 | //$oldSigText = Mail::merge($oldSigText,array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id'))); |
@@ -740,7 +798,11 @@ discard block |
||
740 | 798 | { |
741 | 799 | $content['body'] = str_replace("\n",'\n',$content['body']); // dont know why, but \n screws up preg_replace |
742 | 800 | $styles = Mail::getStyles(array(array('body'=>$content['body']))); |
743 | - if (stripos($content['body'],'style')!==false) Api\Mail\Html::replaceTagsCompletley($content['body'],'style',$endtag='',true); // clean out empty or pagewide style definitions / left over tags |
|
801 | + if (stripos($content['body'],'style')!==false) |
|
802 | + { |
|
803 | + Api\Mail\Html::replaceTagsCompletley($content['body'],'style',$endtag='',true); |
|
804 | + } |
|
805 | + // clean out empty or pagewide style definitions / left over tags |
|
744 | 806 | } |
745 | 807 | $content['body'] = str_replace(array("\r", "\t", "<br />\n", ": "), array("", "", "<br />", ":"), |
746 | 808 | $_currentMode == 'html' ? Api\Html::purify($content['body'], Mail::$htmLawed_config, array(), true) : $content['body']); |
@@ -785,8 +847,14 @@ discard block |
||
785 | 847 | |
786 | 848 | if ($found === false) |
787 | 849 | { |
788 | - if($this->_debug) error_log(__METHOD__." Old Signature failed to match:".$oldSigTextCleaned); |
|
789 | - if($this->_debug) error_log(__METHOD__." Compare content:".$content['body']); |
|
850 | + if($this->_debug) |
|
851 | + { |
|
852 | + error_log(__METHOD__." Old Signature failed to match:".$oldSigTextCleaned); |
|
853 | + } |
|
854 | + if($this->_debug) |
|
855 | + { |
|
856 | + error_log(__METHOD__." Compare content:".$content['body']); |
|
857 | + } |
|
790 | 858 | } |
791 | 859 | else |
792 | 860 | { |
@@ -804,7 +872,10 @@ discard block |
||
804 | 872 | $_currentMode == 'html' ? Api\Html::purify($content['body'], Mail::$htmLawed_config, array(), true) : $content['body']); |
805 | 873 | |
806 | 874 | // do not double insert a signature on a server roundtrip |
807 | - if ($buttonClicked) $suppressSigOnTop = true; |
|
875 | + if ($buttonClicked) |
|
876 | + { |
|
877 | + $suppressSigOnTop = true; |
|
878 | + } |
|
808 | 879 | |
809 | 880 | // On submit reads external_vcard widget's value and addes them as attachments. |
810 | 881 | // this happens when we send vcards from addressbook to an opened compose |
@@ -859,7 +930,8 @@ discard block |
||
859 | 930 | } |
860 | 931 | } |
861 | 932 | $content['subject'] = lang($app).' #'.$res['id'].': '; |
862 | - foreach(array('subject','body','mimetype') as $name) { |
|
933 | + foreach(array('subject','body','mimetype') as $name) |
|
934 | + { |
|
863 | 935 | $sName = $name; |
864 | 936 | if ($name=='mimetype'&&$res[$name]) |
865 | 937 | { |
@@ -868,7 +940,10 @@ discard block |
||
868 | 940 | } |
869 | 941 | else |
870 | 942 | { |
871 | - if ($res[$name]) $content[$sName] .= (strlen($content[$sName])>0 ? ' ':'') .$res[$name]; |
|
943 | + if ($res[$name]) |
|
944 | + { |
|
945 | + $content[$sName] .= (strlen($content[$sName])>0 ? ' ':'') .$res[$name]; |
|
946 | + } |
|
872 | 947 | } |
873 | 948 | } |
874 | 949 | } |
@@ -879,7 +954,8 @@ discard block |
||
879 | 954 | { |
880 | 955 | $alreadyProcessed=array(); |
881 | 956 | //_debug_array($_REQUEST); |
882 | - if ($_REQUEST['preset']['mailto']) { |
|
957 | + if ($_REQUEST['preset']['mailto']) |
|
958 | + { |
|
883 | 959 | // handle mailto strings such as |
884 | 960 | // mailto:larry,dan?cc=mike&bcc=sue&subject=test&body=type+your&body=message+here |
885 | 961 | // the above string may be htmlentyty encoded, then multiple body tags are supported |
@@ -887,10 +963,12 @@ discard block |
||
887 | 963 | $tmp_send_to = (stripos($_REQUEST['preset']['mailto'],'mailto')===false?$_REQUEST['preset']['mailto']:trim(substr(html_entity_decode($_REQUEST['preset']['mailto']),7))); |
888 | 964 | // check if there is more than the to address |
889 | 965 | $mailtoArray = explode('?',$tmp_send_to,2); |
890 | - if ($mailtoArray[1]) { |
|
966 | + if ($mailtoArray[1]) |
|
967 | + { |
|
891 | 968 | // check if there are more than one requests |
892 | 969 | $addRequests = explode('&',$mailtoArray[1]); |
893 | - foreach ($addRequests as $key => $reqval) { |
|
970 | + foreach ($addRequests as $key => $reqval) |
|
971 | + { |
|
894 | 972 | // the additional requests should have a =, to separate key from value. |
895 | 973 | $reqval = preg_replace('/__AMPERSAND__/i', "&", $reqval); |
896 | 974 | $keyValuePair = explode('=',$reqval,2); |
@@ -900,17 +978,24 @@ discard block |
||
900 | 978 | $content['to']= preg_replace('/__AMPERSAND__/i', "&", $mailtoArray[0]); |
901 | 979 | $alreadyProcessed['to']='to'; |
902 | 980 | // if the mailto string is not htmlentity decoded the arguments are passed as simple requests |
903 | - foreach(array('cc','bcc','subject','body') as $name) { |
|
981 | + foreach(array('cc','bcc','subject','body') as $name) |
|
982 | + { |
|
904 | 983 | $alreadyProcessed[$name]=$name; |
905 | - if ($_REQUEST[$name]) $content[$name] .= (strlen($content[$name])>0 ? ( $name == 'cc' || $name == 'bcc' ? ',' : ' ') : '') . $_REQUEST[$name]; |
|
984 | + if ($_REQUEST[$name]) |
|
985 | + { |
|
986 | + $content[$name] .= (strlen($content[$name])>0 ? ( $name == 'cc' || $name == 'bcc' ? ',' : ' ') : '') . $_REQUEST[$name]; |
|
987 | + } |
|
906 | 988 | } |
907 | 989 | } |
908 | 990 | |
909 | - if ($_REQUEST['preset']['mailtocontactbyid']) { |
|
910 | - if ($GLOBALS['egw_info']['user']['apps']['addressbook']) { |
|
991 | + if ($_REQUEST['preset']['mailtocontactbyid']) |
|
992 | + { |
|
993 | + if ($GLOBALS['egw_info']['user']['apps']['addressbook']) |
|
994 | + { |
|
911 | 995 | $contacts_obj = new Api\Contacts(); |
912 | 996 | $addressbookprefs =& $GLOBALS['egw_info']['user']['preferences']['addressbook']; |
913 | - if (method_exists($contacts_obj,'search')) { |
|
997 | + if (method_exists($contacts_obj,'search')) |
|
998 | + { |
|
914 | 999 | |
915 | 1000 | $addressArray = explode(',',$_REQUEST['preset']['mailtocontactbyid']); |
916 | 1001 | foreach ((array)$addressArray as $id => $addressID) |
@@ -951,21 +1036,28 @@ discard block |
||
951 | 1036 | unset($accounts); |
952 | 1037 | } |
953 | 1038 | } |
954 | - if(is_array($contacts)) { |
|
1039 | + if(is_array($contacts)) |
|
1040 | + { |
|
955 | 1041 | $mailtoArray = array(); |
956 | 1042 | $primary = $addressbookprefs['distributionListPreferredMail']; |
957 | - if ($primary != 'email' && $primary != 'email_home') $primary = 'email'; |
|
1043 | + if ($primary != 'email' && $primary != 'email_home') |
|
1044 | + { |
|
1045 | + $primary = 'email'; |
|
1046 | + } |
|
958 | 1047 | $secondary = ($primary == 'email'?'email_home':'email'); |
959 | 1048 | //error_log(__METHOD__.__LINE__.array2string($contacts)); |
960 | - foreach($contacts as $contact) { |
|
1049 | + foreach($contacts as $contact) |
|
1050 | + { |
|
961 | 1051 | $innerCounter=0; |
962 | - foreach(array($contact[$primary],$contact[$secondary]) as $email) { |
|
1052 | + foreach(array($contact[$primary],$contact[$secondary]) as $email) |
|
1053 | + { |
|
963 | 1054 | // use pref distributionListPreferredMail for the primary address |
964 | 1055 | // avoid wrong addresses, if an rfc822 encoded address is in addressbook |
965 | 1056 | $email = preg_replace("/(^.*<)([a-zA-Z0-9_\-]+@[a-zA-Z0-9_\-\.]+)(.*)/",'$2',$email); |
966 | 1057 | $contact['n_fn'] = str_replace(array(',','@'),' ',$contact['n_fn']); |
967 | 1058 | $completeMailString = addslashes(trim($contact['n_fn'] ? $contact['n_fn'] : $contact['fn']) .' <'. trim($email) .'>'); |
968 | - if($innerCounter==0 && !empty($email) && in_array($completeMailString ,$mailtoArray) === false) { |
|
1059 | + if($innerCounter==0 && !empty($email) && in_array($completeMailString ,$mailtoArray) === false) |
|
1060 | + { |
|
969 | 1061 | $i++; |
970 | 1062 | $innerCounter++; |
971 | 1063 | $mailtoArray[$i] = $completeMailString; |
@@ -999,7 +1091,10 @@ discard block |
||
999 | 1091 | } |
1000 | 1092 | } |
1001 | 1093 | } |
1002 | - if(!empty($remember)) $content = array_merge($content,$remember); |
|
1094 | + if(!empty($remember)) |
|
1095 | + { |
|
1096 | + $content = array_merge($content,$remember); |
|
1097 | + } |
|
1003 | 1098 | } |
1004 | 1099 | foreach(array('to','cc','bcc','subject','body','mimeType') as $name) |
1005 | 1100 | { |
@@ -1009,9 +1104,15 @@ discard block |
||
1009 | 1104 | $_content[$name]=$content[$name]=$_REQUEST['preset'][$name]; |
1010 | 1105 | } |
1011 | 1106 | //skip if already processed by "preset Routines" |
1012 | - if ($alreadyProcessed[$name]) continue; |
|
1107 | + if ($alreadyProcessed[$name]) |
|
1108 | + { |
|
1109 | + continue; |
|
1110 | + } |
|
1013 | 1111 | //error_log(__METHOD__.__LINE__.':'.$name.'->'. $_REQUEST['preset'][$name]); |
1014 | - if ($_REQUEST['preset'][$name]) $content[$name] = $_REQUEST['preset'][$name]; |
|
1112 | + if ($_REQUEST['preset'][$name]) |
|
1113 | + { |
|
1114 | + $content[$name] = $_REQUEST['preset'][$name]; |
|
1115 | + } |
|
1015 | 1116 | } |
1016 | 1117 | } |
1017 | 1118 | // is the to address set already? |
@@ -1019,7 +1120,10 @@ discard block |
||
1019 | 1120 | { |
1020 | 1121 | $content['to'] = base64_decode($_REQUEST['send_to']); |
1021 | 1122 | // first check if there is a questionmark or ampersand |
1022 | - if (strpos($content['to'],'?')!== false) list($content['to'],$rest) = explode('?',$content['to'],2); |
|
1123 | + if (strpos($content['to'],'?')!== false) |
|
1124 | + { |
|
1125 | + list($content['to'],$rest) = explode('?',$content['to'],2); |
|
1126 | + } |
|
1023 | 1127 | $content['to'] = html_entity_decode($content['to']); |
1024 | 1128 | if (($at_pos = strpos($content['to'],'@')) !== false) |
1025 | 1129 | { |
@@ -1032,9 +1136,15 @@ discard block |
||
1032 | 1136 | $content['to'] = $email; |
1033 | 1137 | } |
1034 | 1138 | } |
1035 | - if (strpos($content['to'],'%40')!== false) $content['to'] = Api\Html::purify(str_replace('%40','@',$content['to'])); |
|
1139 | + if (strpos($content['to'],'%40')!== false) |
|
1140 | + { |
|
1141 | + $content['to'] = Api\Html::purify(str_replace('%40','@',$content['to'])); |
|
1142 | + } |
|
1036 | 1143 | $rarr = array(Api\Html::purify($rest)); |
1037 | - if (isset($rest)&&!empty($rest) && strpos($rest,'&')!== false) $rarr = explode('&',$rest); |
|
1144 | + if (isset($rest)&&!empty($rest) && strpos($rest,'&')!== false) |
|
1145 | + { |
|
1146 | + $rarr = explode('&',$rest); |
|
1147 | + } |
|
1038 | 1148 | //error_log(__METHOD__.__LINE__.$content['to'].'->'.array2string($rarr)); |
1039 | 1149 | $karr = array(); |
1040 | 1150 | foreach ($rarr as &$rval) |
@@ -1050,9 +1160,15 @@ discard block |
||
1050 | 1160 | //error_log(__METHOD__.__LINE__.$content['to'].'->'.array2string($karr)); |
1051 | 1161 | foreach(array('cc','bcc','subject','body') as $name) |
1052 | 1162 | { |
1053 | - if ($karr[$name]) $content[$name] = $karr[$name]; |
|
1163 | + if ($karr[$name]) |
|
1164 | + { |
|
1165 | + $content[$name] = $karr[$name]; |
|
1166 | + } |
|
1167 | + } |
|
1168 | + if (!empty($_REQUEST['subject'])) |
|
1169 | + { |
|
1170 | + $content['subject'] = Api\Html::purify(trim(html_entity_decode($_REQUEST['subject']))); |
|
1054 | 1171 | } |
1055 | - if (!empty($_REQUEST['subject'])) $content['subject'] = Api\Html::purify(trim(html_entity_decode($_REQUEST['subject']))); |
|
1056 | 1172 | } |
1057 | 1173 | } |
1058 | 1174 | //error_log(__METHOD__.__LINE__.array2string($content)); |
@@ -1070,7 +1186,10 @@ discard block |
||
1070 | 1186 | $_content['mimeType'] = $content['mimeType'] = 'html'; |
1071 | 1187 | $content['body'] = "<pre>".$content['body']."</pre>"; |
1072 | 1188 | // take care this assumption is made on the creation of the reply header in bocompose::getReplyData |
1073 | - if (strpos($content['body'],"<pre> \r\n \r\n---")===0) $content['body'] = substr_replace($content['body']," <br>\r\n<pre>---",0,strlen("<pre> \r\n \r\n---")-1); |
|
1189 | + if (strpos($content['body'],"<pre> \r\n \r\n---")===0) |
|
1190 | + { |
|
1191 | + $content['body'] = substr_replace($content['body']," <br>\r\n<pre>---",0,strlen("<pre> \r\n \r\n---")-1); |
|
1192 | + } |
|
1074 | 1193 | } |
1075 | 1194 | } |
1076 | 1195 | else |
@@ -1090,7 +1209,10 @@ discard block |
||
1090 | 1209 | $_content['mimeType'] = $content['mimeType'] = 'html'; |
1091 | 1210 | $content['body'] = "<pre>".$content['body']."</pre>"; |
1092 | 1211 | // take care this assumption is made on the creation of the reply header in bocompose::getReplyData |
1093 | - if (strpos($content['body'],"<pre> \r\n \r\n---")===0) $content['body'] = substr_replace($content['body']," <br>\r\n<pre>---",0,strlen("<pre> \r\n \r\n---")-1); |
|
1212 | + if (strpos($content['body'],"<pre> \r\n \r\n---")===0) |
|
1213 | + { |
|
1214 | + $content['body'] = substr_replace($content['body']," <br>\r\n<pre>---",0,strlen("<pre> \r\n \r\n---")-1); |
|
1215 | + } |
|
1094 | 1216 | } |
1095 | 1217 | } |
1096 | 1218 | } |
@@ -1130,24 +1252,33 @@ discard block |
||
1130 | 1252 | $disableRuler = true; |
1131 | 1253 | } |
1132 | 1254 | $font_span = $font_part = ''; |
1133 | - if($content['mimeType'] == 'html') { |
|
1255 | + if($content['mimeType'] == 'html') |
|
1256 | + { |
|
1134 | 1257 | // User preferences for style |
1135 | 1258 | $font = $GLOBALS['egw_info']['user']['preferences']['common']['rte_font']; |
1136 | 1259 | $font_size = Etemplate\Widget\HtmlArea::font_size_from_prefs(); |
1137 | 1260 | $font_part = '<span style="width:100%; display: inline; '.($font?'font-family:'.$font.'; ':'').($font_size?'font-size:'.$font_size.'; ':'').'">'; |
1138 | 1261 | $font_span = $font_part.'​</span>'; |
1139 | - if (empty($font) && empty($font_size)) $font_span = ''; |
|
1262 | + if (empty($font) && empty($font_size)) |
|
1263 | + { |
|
1264 | + $font_span = ''; |
|
1265 | + } |
|
1140 | 1266 | } |
1141 | 1267 | // the font span should only be applied on first load or on switch plain->html and the absence of the font_part of the span |
1142 | - if (!$isFirstLoad && !empty($font_span) && stripos($content['body'],$font_part)===false) $font_span = ''; |
|
1268 | + if (!$isFirstLoad && !empty($font_span) && stripos($content['body'],$font_part)===false) |
|
1269 | + { |
|
1270 | + $font_span = ''; |
|
1271 | + } |
|
1143 | 1272 | //remove possible html header stuff |
1144 | - if (stripos($content['body'],'<html><head></head><body>')!==false) $content['body'] = str_ireplace(array('<html><head></head><body>','</body></html>'),array('',''),$content['body']); |
|
1273 | + if (stripos($content['body'],'<html><head></head><body>')!==false) |
|
1274 | + { |
|
1275 | + $content['body'] = str_ireplace(array('<html><head></head><body>','</body></html>'),array('',''),$content['body']); |
|
1276 | + } |
|
1145 | 1277 | //error_log(__METHOD__.__LINE__.array2string($this->mailPreferences)); |
1146 | 1278 | $blockElements = array('address','blockquote','center','del','dir','div','dl','fieldset','form','h1','h2','h3','h4','h5','h6','hr','ins','isindex','menu','noframes','noscript','ol','p','pre','table','ul'); |
1147 | 1279 | if ($this->mailPreferences['insertSignatureAtTopOfMessage']!='no_belowaftersend' && |
1148 | 1280 | !(isset($_POST['mySigID']) && !empty($_POST['mySigID']) ) && !$suppressSigOnTop |
1149 | - ) |
|
1150 | - { |
|
1281 | + ) { |
|
1151 | 1282 | // ON tOP OR BELOW? pREF CAN TELL |
1152 | 1283 | /* |
1153 | 1284 | Signature behavior preference changed. New default, if not set -> 0 |
@@ -1162,14 +1293,23 @@ discard block |
||
1162 | 1293 | $sigTextStartsWithBlockElement = ($disableRuler?false:true); |
1163 | 1294 | foreach($blockElements as $e) |
1164 | 1295 | { |
1165 | - if ($sigTextStartsWithBlockElement) break; |
|
1166 | - if (stripos(trim($sigText),'<'.$e)===0) $sigTextStartsWithBlockElement = true; |
|
1296 | + if ($sigTextStartsWithBlockElement) |
|
1297 | + { |
|
1298 | + break; |
|
1299 | + } |
|
1300 | + if (stripos(trim($sigText),'<'.$e)===0) |
|
1301 | + { |
|
1302 | + $sigTextStartsWithBlockElement = true; |
|
1303 | + } |
|
1167 | 1304 | } |
1168 | 1305 | } |
1169 | - if($content['mimeType'] == 'html') { |
|
1306 | + if($content['mimeType'] == 'html') |
|
1307 | + { |
|
1170 | 1308 | $before = $disableRuler ? '' : '<hr style="border:1px dotted silver; width:100%;">'; |
1171 | 1309 | $inbetween = ''; |
1172 | - } else { |
|
1310 | + } |
|
1311 | + else |
|
1312 | + { |
|
1173 | 1313 | $before = ($disableRuler ?"\r\n\r\n":"\r\n\r\n-- \r\n"); |
1174 | 1314 | $inbetween = "\r\n"; |
1175 | 1315 | } |
@@ -1203,7 +1343,10 @@ discard block |
||
1203 | 1343 | foreach(Mail\Account::search(true,false) as $acc_id => $account) |
1204 | 1344 | { |
1205 | 1345 | // do NOT add SMTP only accounts as identities |
1206 | - if (!$account->is_imap(false)) continue; |
|
1346 | + if (!$account->is_imap(false)) |
|
1347 | + { |
|
1348 | + continue; |
|
1349 | + } |
|
1207 | 1350 | |
1208 | 1351 | foreach($account->identities($acc_id) as $ident_id => $identity) |
1209 | 1352 | { |
@@ -1216,16 +1359,24 @@ discard block |
||
1216 | 1359 | //$content['bcc'] = array('[email protected]','[email protected]'); |
1217 | 1360 | // address stuff like from, to, cc, replyto |
1218 | 1361 | $destinationRows = 0; |
1219 | - foreach(self::$destinations as $destination) { |
|
1362 | + foreach(self::$destinations as $destination) |
|
1363 | + { |
|
1220 | 1364 | if (!is_array($content[$destination])) |
1221 | 1365 | { |
1222 | - if (!empty($content[$destination])) $content[$destination] = (array)$content[$destination]; |
|
1366 | + if (!empty($content[$destination])) |
|
1367 | + { |
|
1368 | + $content[$destination] = (array)$content[$destination]; |
|
1369 | + } |
|
1223 | 1370 | } |
1224 | 1371 | $addr_content = $content[strtolower($destination)]; |
1225 | 1372 | // we clear the given address array and rebuild it |
1226 | 1373 | unset($content[strtolower($destination)]); |
1227 | - foreach((array)$addr_content as $key => $value) { |
|
1228 | - if ($value=="NIL@NIL") continue; |
|
1374 | + foreach((array)$addr_content as $key => $value) |
|
1375 | + { |
|
1376 | + if ($value=="NIL@NIL") |
|
1377 | + { |
|
1378 | + continue; |
|
1379 | + } |
|
1229 | 1380 | if ($destination=='replyto' && str_replace('"','',$value) == |
1230 | 1381 | str_replace('"','',$identities[$this->mail_bo->getDefaultIdentity()])) |
1231 | 1382 | { |
@@ -1235,8 +1386,12 @@ discard block |
||
1235 | 1386 | } |
1236 | 1387 | //error_log(__METHOD__.__LINE__.array2string(array('key'=>$key,'value'=>$value))); |
1237 | 1388 | $value = str_replace("\"\"",'"', htmlspecialchars_decode($value, ENT_COMPAT)); |
1238 | - foreach(Mail::parseAddressList($value) as $addressObject) { |
|
1239 | - if ($addressObject->host == '.SYNTAX-ERROR.') continue; |
|
1389 | + foreach(Mail::parseAddressList($value) as $addressObject) |
|
1390 | + { |
|
1391 | + if ($addressObject->host == '.SYNTAX-ERROR.') |
|
1392 | + { |
|
1393 | + continue; |
|
1394 | + } |
|
1240 | 1395 | $address = imap_rfc822_write_address($addressObject->mailbox,$addressObject->host,$addressObject->personal); |
1241 | 1396 | //$address = Mail::htmlentities($address, $this->displayCharset); |
1242 | 1397 | $content[strtolower($destination)][]=$address; |
@@ -1247,11 +1402,20 @@ discard block |
||
1247 | 1402 | if ($_content) |
1248 | 1403 | { |
1249 | 1404 | //input array of _content had no signature information but was seeded later, and content has a valid setting |
1250 | - if (!$_contentHasSigID && $content['mailidentity'] && array_key_exists('mailidentity',$_content)) unset($_content['mailidentity']); |
|
1405 | + if (!$_contentHasSigID && $content['mailidentity'] && array_key_exists('mailidentity',$_content)) |
|
1406 | + { |
|
1407 | + unset($_content['mailidentity']); |
|
1408 | + } |
|
1251 | 1409 | $content = array_merge($content,$_content); |
1252 | 1410 | |
1253 | - if (!empty($content['folder'])) $sel_options['folder']=$this->ajax_searchFolder(0,true); |
|
1254 | - if (empty($content['mailaccount'])) $content['mailaccount'] = $this->mail_bo->profileID; |
|
1411 | + if (!empty($content['folder'])) |
|
1412 | + { |
|
1413 | + $sel_options['folder']=$this->ajax_searchFolder(0,true); |
|
1414 | + } |
|
1415 | + if (empty($content['mailaccount'])) |
|
1416 | + { |
|
1417 | + $content['mailaccount'] = $this->mail_bo->profileID; |
|
1418 | + } |
|
1255 | 1419 | } |
1256 | 1420 | else |
1257 | 1421 | { |
@@ -1294,11 +1458,17 @@ discard block |
||
1294 | 1458 | //error_log(__METHOD__.__LINE__.' ComposeID:'.$preserv['composeID']); |
1295 | 1459 | $preserv['is_html'] = $content['is_html']; |
1296 | 1460 | $preserv['is_plain'] = $content['is_plain']; |
1297 | - if (isset($content['mimeType'])) $preserv['mimeType'] = $content['mimeType']; |
|
1461 | + if (isset($content['mimeType'])) |
|
1462 | + { |
|
1463 | + $preserv['mimeType'] = $content['mimeType']; |
|
1464 | + } |
|
1298 | 1465 | $sel_options['mimeType'] = self::$mimeTypes; |
1299 | 1466 | $sel_options['priority'] = self::$priorities; |
1300 | 1467 | $sel_options['filemode'] = Vfs\Sharing::$modes; |
1301 | - if (!isset($content['priority']) || empty($content['priority'])) $content['priority']=3; |
|
1468 | + if (!isset($content['priority']) || empty($content['priority'])) |
|
1469 | + { |
|
1470 | + $content['priority']=3; |
|
1471 | + } |
|
1302 | 1472 | //$GLOBALS['egw_info']['flags']['currentapp'] = 'mail';//should not be needed |
1303 | 1473 | $etpl = new Etemplate('mail.compose'); |
1304 | 1474 | |
@@ -1338,9 +1508,12 @@ discard block |
||
1338 | 1508 | $preserv['list-id'] = $content['list-id']; |
1339 | 1509 | $preserv['mode'] = $content['mode']; |
1340 | 1510 | // convert it back to checkbox expectations |
1341 | - if($content['mimeType'] == 'html') { |
|
1511 | + if($content['mimeType'] == 'html') |
|
1512 | + { |
|
1342 | 1513 | $content['mimeType']=1; |
1343 | - } else { |
|
1514 | + } |
|
1515 | + else |
|
1516 | + { |
|
1344 | 1517 | $content['mimeType']=0; |
1345 | 1518 | } |
1346 | 1519 | // set the current selected mailaccount as param for folderselection |
@@ -1365,7 +1538,10 @@ discard block |
||
1365 | 1538 | // Resolve distribution list before send content to client |
1366 | 1539 | foreach(array('to', 'cc', 'bcc', 'replyto') as $f) |
1367 | 1540 | { |
1368 | - if (is_array($content[$f])) $content[$f]= self::resolveEmailAddressList ($content[$f]); |
|
1541 | + if (is_array($content[$f])) |
|
1542 | + { |
|
1543 | + $content[$f]= self::resolveEmailAddressList ($content[$f]); |
|
1544 | + } |
|
1369 | 1545 | } |
1370 | 1546 | |
1371 | 1547 | // set filemode icons for all attachments |
@@ -1521,7 +1697,10 @@ discard block |
||
1521 | 1697 | case 'composefromdraft': |
1522 | 1698 | case 'composeasnew': |
1523 | 1699 | $content = $this->getDraftData($icServer, $folder, $msgUID, $part_id); |
1524 | - if ($from =='composefromdraft') $content['mode'] = 'composefromdraft'; |
|
1700 | + if ($from =='composefromdraft') |
|
1701 | + { |
|
1702 | + $content['mode'] = 'composefromdraft'; |
|
1703 | + } |
|
1525 | 1704 | $content['processedmail_id'] = $mail_id; |
1526 | 1705 | |
1527 | 1706 | $_focusElement = 'body'; |
@@ -1569,7 +1748,10 @@ discard block |
||
1569 | 1748 | $document_merge = new $merge_class(); |
1570 | 1749 | $this->mail_bo->openConnection(); |
1571 | 1750 | $merge_ids = $_REQUEST['preset']['mailtocontactbyid'] ? $_REQUEST['preset']['mailtocontactbyid'] : $mail_id; |
1572 | - if (!is_array($merge_ids)) $merge_ids = explode(',',$merge_ids); |
|
1751 | + if (!is_array($merge_ids)) |
|
1752 | + { |
|
1753 | + $merge_ids = explode(',',$merge_ids); |
|
1754 | + } |
|
1573 | 1755 | try |
1574 | 1756 | { |
1575 | 1757 | $merged_mail_id = ''; |
@@ -1600,7 +1782,10 @@ discard block |
||
1600 | 1782 | { |
1601 | 1783 | $success = implode(', ',$results['success']); |
1602 | 1784 | $fail = implode(', ', $results['failed']); |
1603 | - if($success) Framework::message($success, 'success'); |
|
1785 | + if($success) |
|
1786 | + { |
|
1787 | + Framework::message($success, 'success'); |
|
1788 | + } |
|
1604 | 1789 | Framework::window_close($fail); |
1605 | 1790 | } |
1606 | 1791 | } |
@@ -1632,17 +1817,25 @@ discard block |
||
1632 | 1817 | { |
1633 | 1818 | $stripalltags = true; |
1634 | 1819 | // third param is stripalltags, we may not need that, if the source is already in ascii |
1635 | - if (!$sourceishtml) $stripalltags=false; |
|
1820 | + if (!$sourceishtml) |
|
1821 | + { |
|
1822 | + $stripalltags=false; |
|
1823 | + } |
|
1636 | 1824 | return Api\Mail\Html::convertHTMLToText($_html,$this->displayCharset,$stripcrl,$stripalltags, $noRepEmailAddr); |
1637 | 1825 | } |
1638 | 1826 | |
1639 | 1827 | function generateRFC822Address($_addressObject) |
1640 | 1828 | { |
1641 | - if($_addressObject->personal && $_addressObject->mailbox && $_addressObject->host) { |
|
1829 | + if($_addressObject->personal && $_addressObject->mailbox && $_addressObject->host) |
|
1830 | + { |
|
1642 | 1831 | return sprintf('"%s" <%s@%s>', $this->mail_bo->decode_header($_addressObject->personal), $_addressObject->mailbox, $this->mail_bo->decode_header($_addressObject->host,'FORCE')); |
1643 | - } elseif($_addressObject->mailbox && $_addressObject->host) { |
|
1832 | + } |
|
1833 | + elseif($_addressObject->mailbox && $_addressObject->host) |
|
1834 | + { |
|
1644 | 1835 | return sprintf("%s@%s", $_addressObject->mailbox, $this->mail_bo->decode_header($_addressObject->host,'FORCE')); |
1645 | - } else { |
|
1836 | + } |
|
1837 | + else |
|
1838 | + { |
|
1646 | 1839 | return $this->mail_bo->decode_header($_addressObject->mailbox,true); |
1647 | 1840 | } |
1648 | 1841 | } |
@@ -1676,16 +1869,28 @@ discard block |
||
1676 | 1869 | //if ($addHeadInfo['THREAD-TOPIC']) $this->sessionData['thread-topic'] = $addHeadInfo['THREAD-TOPIC']; |
1677 | 1870 | |
1678 | 1871 | //error_log(__METHOD__.__LINE__.array2string($headers)); |
1679 | - if (!empty($addHeadInfo['X-MAILFOLDER'])) { |
|
1680 | - foreach ( explode('|',$addHeadInfo['X-MAILFOLDER']) as $val ) { |
|
1872 | + if (!empty($addHeadInfo['X-MAILFOLDER'])) |
|
1873 | + { |
|
1874 | + foreach ( explode('|',$addHeadInfo['X-MAILFOLDER']) as $val ) |
|
1875 | + { |
|
1681 | 1876 | $fval=$val; |
1682 | 1877 | $icServerID = $mail_bo->icServer->ImapServerId; |
1683 | - if (stripos($val,'::')!==false) list($icServerID,$fval) = explode('::',$val,2); |
|
1684 | - if ($icServerID != $mail_bo->icServer->ImapServerId) continue; |
|
1685 | - if ($mail_bo->folderExists($fval)) $this->sessionData['folder'][] = $val; |
|
1878 | + if (stripos($val,'::')!==false) |
|
1879 | + { |
|
1880 | + list($icServerID,$fval) = explode('::',$val,2); |
|
1881 | + } |
|
1882 | + if ($icServerID != $mail_bo->icServer->ImapServerId) |
|
1883 | + { |
|
1884 | + continue; |
|
1885 | + } |
|
1886 | + if ($mail_bo->folderExists($fval)) |
|
1887 | + { |
|
1888 | + $this->sessionData['folder'][] = $val; |
|
1889 | + } |
|
1686 | 1890 | } |
1687 | 1891 | } |
1688 | - if (!empty($addHeadInfo['X-MAILIDENTITY'])) { |
|
1892 | + if (!empty($addHeadInfo['X-MAILIDENTITY'])) |
|
1893 | + { |
|
1689 | 1894 | // with the new system it would be the identity |
1690 | 1895 | try |
1691 | 1896 | { |
@@ -1701,7 +1906,8 @@ discard block |
||
1701 | 1906 | $this->sessionData['stationeryID'] = $addHeadInfo['X-STATIONERY']; |
1702 | 1907 | } |
1703 | 1908 | */ |
1704 | - if (!empty($addHeadInfo['X-MAILACCOUNT'])) { |
|
1909 | + if (!empty($addHeadInfo['X-MAILACCOUNT'])) |
|
1910 | + { |
|
1705 | 1911 | // with the new system it would the identity is the account id |
1706 | 1912 | try |
1707 | 1913 | { |
@@ -1716,27 +1922,38 @@ discard block |
||
1716 | 1922 | } |
1717 | 1923 | } |
1718 | 1924 | // if the message is located within the draft folder, add it as last drafted version (for possible cleanup on abort)) |
1719 | - if ($mail_bo->isDraftFolder($_folder)) $this->sessionData['lastDrafted'] = mail_ui::generateRowID($this->mail_bo->profileID, $_folder, $_uid);//array('uid'=>$_uid,'folder'=>$_folder); |
|
1925 | + if ($mail_bo->isDraftFolder($_folder)) |
|
1926 | + { |
|
1927 | + $this->sessionData['lastDrafted'] = mail_ui::generateRowID($this->mail_bo->profileID, $_folder, $_uid); |
|
1928 | + } |
|
1929 | + //array('uid'=>$_uid,'folder'=>$_folder); |
|
1720 | 1930 | $this->sessionData['uid'] = $_uid; |
1721 | 1931 | $this->sessionData['messageFolder'] = $_folder; |
1722 | 1932 | $this->sessionData['isDraft'] = true; |
1723 | 1933 | $foundAddresses = array(); |
1724 | - foreach((array)$headers['CC'] as $val) { |
|
1934 | + foreach((array)$headers['CC'] as $val) |
|
1935 | + { |
|
1725 | 1936 | $rfcAddr=Mail::parseAddressList($val); |
1726 | 1937 | $_rfcAddr = $rfcAddr[0]; |
1727 | - if (!$_rfcAddr->valid) continue; |
|
1728 | - if($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host) ) { |
|
1938 | + if (!$_rfcAddr->valid) |
|
1939 | + { |
|
1940 | + continue; |
|
1941 | + } |
|
1942 | + if($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host) ) |
|
1943 | + { |
|
1729 | 1944 | continue; |
1730 | 1945 | } |
1731 | 1946 | $keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host; |
1732 | - if(!$foundAddresses[$keyemail]) { |
|
1947 | + if(!$foundAddresses[$keyemail]) |
|
1948 | + { |
|
1733 | 1949 | $address = $this->mail_bo->decode_header($val,true); |
1734 | 1950 | $this->sessionData['cc'][] = $val; |
1735 | 1951 | $foundAddresses[$keyemail] = true; |
1736 | 1952 | } |
1737 | 1953 | } |
1738 | 1954 | |
1739 | - foreach((array)$headers['TO'] as $val) { |
|
1955 | + foreach((array)$headers['TO'] as $val) |
|
1956 | + { |
|
1740 | 1957 | if(!is_array($val)) |
1741 | 1958 | { |
1742 | 1959 | $this->sessionData['to'][] = $val; |
@@ -1744,12 +1961,17 @@ discard block |
||
1744 | 1961 | } |
1745 | 1962 | $rfcAddr=Mail::parseAddressList($val); |
1746 | 1963 | $_rfcAddr = $rfcAddr[0]; |
1747 | - if (!$_rfcAddr->valid) continue; |
|
1748 | - if($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host) ) { |
|
1964 | + if (!$_rfcAddr->valid) |
|
1965 | + { |
|
1966 | + continue; |
|
1967 | + } |
|
1968 | + if($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host) ) |
|
1969 | + { |
|
1749 | 1970 | continue; |
1750 | 1971 | } |
1751 | 1972 | $keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host; |
1752 | - if(!$foundAddresses[$keyemail]) { |
|
1973 | + if(!$foundAddresses[$keyemail]) |
|
1974 | + { |
|
1753 | 1975 | $address = $this->mail_bo->decode_header($val,true); |
1754 | 1976 | $this->sessionData['to'][] = $val; |
1755 | 1977 | $foundAddresses[$keyemail] = true; |
@@ -1757,30 +1979,42 @@ discard block |
||
1757 | 1979 | } |
1758 | 1980 | |
1759 | 1981 | $fromAddr = Mail::parseAddressList($addHeadInfo['FROM'])[0]; |
1760 | - foreach((array)$headers['REPLY-TO'] as $val) { |
|
1982 | + foreach((array)$headers['REPLY-TO'] as $val) |
|
1983 | + { |
|
1761 | 1984 | $rfcAddr=Mail::parseAddressList($val); |
1762 | 1985 | $_rfcAddr = $rfcAddr[0]; |
1763 | - if (!$_rfcAddr->valid || ($_rfcAddr->mailbox == $fromAddr->mailbox && $_rfcAddr->host == $fromAddr->host)) continue; |
|
1764 | - if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) ) { |
|
1986 | + if (!$_rfcAddr->valid || ($_rfcAddr->mailbox == $fromAddr->mailbox && $_rfcAddr->host == $fromAddr->host)) |
|
1987 | + { |
|
1988 | + continue; |
|
1989 | + } |
|
1990 | + if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) ) |
|
1991 | + { |
|
1765 | 1992 | continue; |
1766 | 1993 | } |
1767 | 1994 | $keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host; |
1768 | - if(!$foundAddresses[$keyemail]) { |
|
1995 | + if(!$foundAddresses[$keyemail]) |
|
1996 | + { |
|
1769 | 1997 | $address = $this->mail_bo->decode_header($val,true); |
1770 | 1998 | $this->sessionData['replyto'][] = $val; |
1771 | 1999 | $foundAddresses[$keyemail] = true; |
1772 | 2000 | } |
1773 | 2001 | } |
1774 | 2002 | |
1775 | - foreach((array)$headers['BCC'] as $val) { |
|
2003 | + foreach((array)$headers['BCC'] as $val) |
|
2004 | + { |
|
1776 | 2005 | $rfcAddr=Mail::parseAddressList($val); |
1777 | 2006 | $_rfcAddr = $rfcAddr[0]; |
1778 | - if (!$_rfcAddr->valid) continue; |
|
1779 | - if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) ) { |
|
2007 | + if (!$_rfcAddr->valid) |
|
2008 | + { |
|
2009 | + continue; |
|
2010 | + } |
|
2011 | + if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) ) |
|
2012 | + { |
|
1780 | 2013 | continue; |
1781 | 2014 | } |
1782 | 2015 | $keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host; |
1783 | - if(!$foundAddresses[$keyemail]) { |
|
2016 | + if(!$foundAddresses[$keyemail]) |
|
2017 | + { |
|
1784 | 2018 | $address = $this->mail_bo->decode_header($val,true); |
1785 | 2019 | $this->sessionData['bcc'][] = $val; |
1786 | 2020 | $foundAddresses[$keyemail] = true; |
@@ -1794,32 +2028,46 @@ discard block |
||
1794 | 2028 | $bodyParts = $mail_bo->getMessageBody($_uid,'always_display', $_partID); |
1795 | 2029 | //_debug_array($bodyParts); |
1796 | 2030 | #$fromAddress = ($headers['FROM'][0]['PERSONAL_NAME'] != 'NIL') ? $headers['FROM'][0]['RFC822_EMAIL'] : $headers['FROM'][0]['EMAIL']; |
1797 | - if($bodyParts['0']['mimeType'] == 'text/html') { |
|
2031 | + if($bodyParts['0']['mimeType'] == 'text/html') |
|
2032 | + { |
|
1798 | 2033 | $this->sessionData['mimeType'] = 'html'; |
1799 | 2034 | |
1800 | - for($i=0; $i<count($bodyParts); $i++) { |
|
1801 | - if($i>0) { |
|
2035 | + for($i=0; $i<count($bodyParts); $i++) |
|
2036 | + { |
|
2037 | + if($i>0) |
|
2038 | + { |
|
1802 | 2039 | $this->sessionData['body'] .= '<hr>'; |
1803 | 2040 | } |
1804 | - if($bodyParts[$i]['mimeType'] == 'text/plain') { |
|
2041 | + if($bodyParts[$i]['mimeType'] == 'text/plain') |
|
2042 | + { |
|
1805 | 2043 | #$bodyParts[$i]['body'] = nl2br($bodyParts[$i]['body']); |
1806 | 2044 | $bodyParts[$i]['body'] = "<pre>".$bodyParts[$i]['body']."</pre>"; |
1807 | 2045 | } |
1808 | - if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']); |
|
2046 | + if ($bodyParts[$i]['charSet']===false) |
|
2047 | + { |
|
2048 | + $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']); |
|
2049 | + } |
|
1809 | 2050 | $bodyParts[$i]['body'] = Api\Translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']); |
1810 | 2051 | #error_log( "GetDraftData (HTML) CharSet:".mb_detect_encoding($bodyParts[$i]['body'] . 'a' , strtoupper($bodyParts[$i]['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1')); |
1811 | 2052 | $this->sessionData['body'] .= ($i>0?"<br>":""). $bodyParts[$i]['body'] ; |
1812 | 2053 | } |
1813 | 2054 | $this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID); |
1814 | 2055 | |
1815 | - } else { |
|
2056 | + } |
|
2057 | + else |
|
2058 | + { |
|
1816 | 2059 | $this->sessionData['mimeType'] = 'plain'; |
1817 | 2060 | |
1818 | - for($i=0; $i<count($bodyParts); $i++) { |
|
1819 | - if($i>0) { |
|
2061 | + for($i=0; $i<count($bodyParts); $i++) |
|
2062 | + { |
|
2063 | + if($i>0) |
|
2064 | + { |
|
1820 | 2065 | $this->sessionData['body'] .= "<hr>"; |
1821 | 2066 | } |
1822 | - if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']); |
|
2067 | + if ($bodyParts[$i]['charSet']===false) |
|
2068 | + { |
|
2069 | + $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']); |
|
2070 | + } |
|
1823 | 2071 | $bodyParts[$i]['body'] = Api\Translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']); |
1824 | 2072 | #error_log( "GetDraftData (Plain) CharSet".mb_detect_encoding($bodyParts[$i]['body'] . 'a' , strtoupper($bodyParts[$i]['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1')); |
1825 | 2073 | $this->sessionData['body'] .= ($i>0?"\r\n":""). $bodyParts[$i]['body'] ; |
@@ -1827,8 +2075,10 @@ discard block |
||
1827 | 2075 | $this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID,'plain'); |
1828 | 2076 | } |
1829 | 2077 | |
1830 | - if(($attachments = $mail_bo->getMessageAttachments($_uid,$_partID))) { |
|
1831 | - foreach($attachments as $attachment) { |
|
2078 | + if(($attachments = $mail_bo->getMessageAttachments($_uid,$_partID))) |
|
2079 | + { |
|
2080 | + foreach($attachments as $attachment) |
|
2081 | + { |
|
1832 | 2082 | //error_log(__METHOD__.__LINE__.array2string($attachment)); |
1833 | 2083 | $cid = $attachment['cid']; |
1834 | 2084 | $match=null; |
@@ -1851,7 +2101,8 @@ discard block |
||
1851 | 2101 | |
1852 | 2102 | function getErrorInfo() |
1853 | 2103 | { |
1854 | - if(isset($this->errorInfo)) { |
|
2104 | + if(isset($this->errorInfo)) |
|
2105 | + { |
|
1855 | 2106 | $errorInfo = $this->errorInfo; |
1856 | 2107 | unset($this->errorInfo); |
1857 | 2108 | return $errorInfo; |
@@ -1866,7 +2117,8 @@ discard block |
||
1866 | 2117 | $modebuff = $this->mailPreferences['message_forwarding']; |
1867 | 2118 | $this->mailPreferences['message_forwarding'] = $_mode; |
1868 | 2119 | } |
1869 | - if ($this->mailPreferences['message_forwarding'] == 'inline') { |
|
2120 | + if ($this->mailPreferences['message_forwarding'] == 'inline') |
|
2121 | + { |
|
1870 | 2122 | $this->getReplyData('forward', $_icServer, $_folder, $_uid, $_partID); |
1871 | 2123 | } |
1872 | 2124 | $mail_bo = $this->mail_bo; |
@@ -1883,12 +2135,16 @@ discard block |
||
1883 | 2135 | //$this->sessionData['sourceFolder']=$_folder; |
1884 | 2136 | //$this->sessionData['forwardFlag']='forwarded'; |
1885 | 2137 | //$this->sessionData['forwardedUID']=$_uid; |
1886 | - if ($this->mailPreferences['message_forwarding'] == 'asmail') { |
|
2138 | + if ($this->mailPreferences['message_forwarding'] == 'asmail') |
|
2139 | + { |
|
1887 | 2140 | $this->sessionData['mimeType'] = $this->mailPreferences['composeOptions']; |
1888 | 2141 | if($headers['SIZE']) |
1889 | - $size = $headers['SIZE']; |
|
1890 | - else |
|
1891 | - $size = lang('unknown'); |
|
2142 | + { |
|
2143 | + $size = $headers['SIZE']; |
|
2144 | + } |
|
2145 | + else { |
|
2146 | + $size = lang('unknown'); |
|
2147 | + } |
|
1892 | 2148 | |
1893 | 2149 | $this->addMessageAttachment($_uid, $_partID, $_folder, |
1894 | 2150 | $mail_bo->decode_header(($headers['SUBJECT']?$headers['SUBJECT']:lang('no subject'))).'.eml', |
@@ -1901,9 +2157,11 @@ discard block |
||
1901 | 2157 | unset($this->sessionData['cc']); |
1902 | 2158 | try |
1903 | 2159 | { |
1904 | - if(($attachments = $mail_bo->getMessageAttachments($_uid,$_partID,null,true,false,false))) { |
|
2160 | + if(($attachments = $mail_bo->getMessageAttachments($_uid,$_partID,null,true,false,false))) |
|
2161 | + { |
|
1905 | 2162 | //error_log(__METHOD__.__LINE__.':'.array2string($attachments)); |
1906 | - foreach($attachments as $attachment) { |
|
2163 | + foreach($attachments as $attachment) |
|
2164 | + { |
|
1907 | 2165 | if (!($attachment['cid'] && preg_match("/image\//",$attachment['mimeType'])) || $attachment['disposition'] == 'attachment') |
1908 | 2166 | { |
1909 | 2167 | $this->addMessageAttachment($_uid, $attachment['partID'], |
@@ -1969,7 +2227,10 @@ discard block |
||
1969 | 2227 | { |
1970 | 2228 | if ($attach['name'] && $attach['name'] == $_formData['name'] && |
1971 | 2229 | strtolower($_formData['type'])== strtolower($attach['type']) && |
1972 | - stripos($_formData['file'],'vfs://') !== false) return; |
|
2230 | + stripos($_formData['file'],'vfs://') !== false) |
|
2231 | + { |
|
2232 | + return; |
|
2233 | + } |
|
1973 | 2234 | } |
1974 | 2235 | } |
1975 | 2236 | if ($attachfailed === false) |
@@ -1981,7 +2242,10 @@ discard block |
||
1981 | 2242 | 'tmp_name' => $tmpFileName, |
1982 | 2243 | 'size' => $_formData['size'] |
1983 | 2244 | ); |
1984 | - if (!is_array($_content['attachments'])) $_content['attachments']=array(); |
|
2245 | + if (!is_array($_content['attachments'])) |
|
2246 | + { |
|
2247 | + $_content['attachments']=array(); |
|
2248 | + } |
|
1985 | 2249 | $_content['attachments'][] = $buffer; |
1986 | 2250 | unset($buffer); |
1987 | 2251 | } |
@@ -2012,7 +2276,10 @@ discard block |
||
2012 | 2276 | { |
2013 | 2277 | foreach($request->preserv['attachments'] as $attachment) |
2014 | 2278 | { |
2015 | - if ($_GET['tmpname'] === $attachment['tmp_name']) break; |
|
2279 | + if ($_GET['tmpname'] === $attachment['tmp_name']) |
|
2280 | + { |
|
2281 | + break; |
|
2282 | + } |
|
2016 | 2283 | } |
2017 | 2284 | } |
2018 | 2285 | if (!$request || $_GET['tmpname'] !== $attachment['tmp_name']) |
@@ -2046,10 +2313,20 @@ discard block |
||
2046 | 2313 | $sfxMimeType = $attachment['type']; |
2047 | 2314 | $buff = explode('.',$attachment['tmp_name']); |
2048 | 2315 | $suffix = ''; |
2049 | - if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime |
|
2050 | - if (!empty($suffix)) $sfxMimeType = Api\MimeMagic::ext2mime($suffix); |
|
2316 | + if (is_array($buff)) |
|
2317 | + { |
|
2318 | + $suffix = array_pop($buff); |
|
2319 | + } |
|
2320 | + // take the last extension to check with ext2mime |
|
2321 | + if (!empty($suffix)) |
|
2322 | + { |
|
2323 | + $sfxMimeType = Api\MimeMagic::ext2mime($suffix); |
|
2324 | + } |
|
2051 | 2325 | $attachment['type'] = $sfxMimeType; |
2052 | - if (strtoupper($sfxMimeType) == 'TEXT/VCARD' || strtoupper($sfxMimeType) == 'TEXT/X-VCARD') $attachment['type'] = strtoupper($sfxMimeType); |
|
2326 | + if (strtoupper($sfxMimeType) == 'TEXT/VCARD' || strtoupper($sfxMimeType) == 'TEXT/X-VCARD') |
|
2327 | + { |
|
2328 | + $attachment['type'] = strtoupper($sfxMimeType); |
|
2329 | + } |
|
2053 | 2330 | } |
2054 | 2331 | //error_log(__METHOD__.print_r($attachment,true)); |
2055 | 2332 | if (strtoupper($attachment['type']) == 'TEXT/CALENDAR' || strtoupper($attachment['type']) == 'TEXT/X-VCALENDAR') |
@@ -2058,7 +2335,10 @@ discard block |
||
2058 | 2335 | $calendar_ical = new calendar_ical(); |
2059 | 2336 | $eventid = $calendar_ical->search($attachment['attachment'],-1); |
2060 | 2337 | //error_log(__METHOD__.array2string($eventid)); |
2061 | - if (!$eventid) $eventid = -1; |
|
2338 | + if (!$eventid) |
|
2339 | + { |
|
2340 | + $eventid = -1; |
|
2341 | + } |
|
2062 | 2342 | $event = $calendar_ical->importVCal($attachment['attachment'],(is_array($eventid)?$eventid[0]:$eventid),null,true); |
2063 | 2343 | //error_log(__METHOD__.$event); |
2064 | 2344 | if ((int)$event > 0) |
@@ -2084,7 +2364,10 @@ discard block |
||
2084 | 2364 | //error_log(__METHOD__.__LINE__.print_r($vcard,true)); |
2085 | 2365 | $contact = $addressbook_vcal->find_contact($vcard,false); |
2086 | 2366 | } |
2087 | - if (!$contact) $contact = null; |
|
2367 | + if (!$contact) |
|
2368 | + { |
|
2369 | + $contact = null; |
|
2370 | + } |
|
2088 | 2371 | // if there are not enough fields in the vcard (or the parser was unable to correctly parse the vcard (as of VERSION:3.0 created by MSO)) |
2089 | 2372 | if ($contact || count($vcard)>2) |
2090 | 2373 | { |
@@ -2115,7 +2398,8 @@ discard block |
||
2115 | 2398 | * @param string haystack |
2116 | 2399 | * @return boolean |
2117 | 2400 | */ |
2118 | - function testIfOneKeyInArrayDoesExistInString($arrayToTestAgainst,$haystack) { |
|
2401 | + function testIfOneKeyInArrayDoesExistInString($arrayToTestAgainst,$haystack) |
|
2402 | + { |
|
2119 | 2403 | foreach (array_keys($arrayToTestAgainst) as $k) |
2120 | 2404 | { |
2121 | 2405 | //error_log(__METHOD__.__LINE__.':'.$k.'<->'.$haystack); |
@@ -2172,21 +2456,34 @@ discard block |
||
2172 | 2456 | // thread-topic is a proprietary microsoft header and deprecated with the current version |
2173 | 2457 | // horde does not support the encoding of thread-topic, and probably will not no so in the future |
2174 | 2458 | //if ($headers['THREAD-TOPIC']) $this->sessionData['thread-topic'] = $headers['THREAD-TOPIC']; |
2175 | - if ($headers['THREAD-INDEX']) $this->sessionData['thread-index'] = $headers['THREAD-INDEX']; |
|
2176 | - if ($headers['LIST-ID']) $this->sessionData['list-id'] = $headers['LIST-ID']; |
|
2459 | + if ($headers['THREAD-INDEX']) |
|
2460 | + { |
|
2461 | + $this->sessionData['thread-index'] = $headers['THREAD-INDEX']; |
|
2462 | + } |
|
2463 | + if ($headers['LIST-ID']) |
|
2464 | + { |
|
2465 | + $this->sessionData['list-id'] = $headers['LIST-ID']; |
|
2466 | + } |
|
2177 | 2467 | //error_log(__METHOD__.__LINE__.' Mode:'.$_mode.':'.array2string($headers)); |
2178 | 2468 | // check for Reply-To: header and use if available |
2179 | - if(!empty($headers['REPLY-TO']) && ($headers['REPLY-TO'] != $headers['FROM'])) { |
|
2180 | - foreach($headers['REPLY-TO'] as $val) { |
|
2181 | - if(!$foundAddresses[$val]) { |
|
2469 | + if(!empty($headers['REPLY-TO']) && ($headers['REPLY-TO'] != $headers['FROM'])) |
|
2470 | + { |
|
2471 | + foreach($headers['REPLY-TO'] as $val) |
|
2472 | + { |
|
2473 | + if(!$foundAddresses[$val]) |
|
2474 | + { |
|
2182 | 2475 | $oldTo[] = $val; |
2183 | 2476 | $foundAddresses[$val] = true; |
2184 | 2477 | } |
2185 | 2478 | } |
2186 | 2479 | $oldToAddress = (is_array($headers['REPLY-TO'])?$headers['REPLY-TO'][0]:$headers['REPLY-TO']); |
2187 | - } else { |
|
2188 | - foreach($headers['FROM'] as $val) { |
|
2189 | - if(!$foundAddresses[$val]) { |
|
2480 | + } |
|
2481 | + else |
|
2482 | + { |
|
2483 | + foreach($headers['FROM'] as $val) |
|
2484 | + { |
|
2485 | + if(!$foundAddresses[$val]) |
|
2486 | + { |
|
2190 | 2487 | $oldTo[] = $val; |
2191 | 2488 | $foundAddresses[$val] = true; |
2192 | 2489 | } |
@@ -2194,18 +2491,23 @@ discard block |
||
2194 | 2491 | $oldToAddress = (is_array($headers['FROM'])?$headers['FROM'][0]:$headers['FROM']); |
2195 | 2492 | } |
2196 | 2493 | //error_log(__METHOD__.__LINE__.' OldToAddress:'.$oldToAddress.'#'); |
2197 | - if($_mode != 'all' || ($_mode == 'all' && !empty($oldToAddress) && !$this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$oldToAddress)) ) { |
|
2494 | + if($_mode != 'all' || ($_mode == 'all' && !empty($oldToAddress) && !$this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$oldToAddress)) ) |
|
2495 | + { |
|
2198 | 2496 | $this->sessionData['to'] = $oldTo; |
2199 | 2497 | } |
2200 | 2498 | |
2201 | - if($_mode == 'all') { |
|
2499 | + if($_mode == 'all') |
|
2500 | + { |
|
2202 | 2501 | // reply to any address which is cc, but not to my self |
2203 | 2502 | #if($headers->cc) { |
2204 | - foreach($headers['CC'] as $val) { |
|
2205 | - if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) { |
|
2503 | + foreach($headers['CC'] as $val) |
|
2504 | + { |
|
2505 | + if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) |
|
2506 | + { |
|
2206 | 2507 | continue; |
2207 | 2508 | } |
2208 | - if(!$foundAddresses[$val]) { |
|
2509 | + if(!$foundAddresses[$val]) |
|
2510 | + { |
|
2209 | 2511 | $this->sessionData['cc'][] = $val; |
2210 | 2512 | $foundAddresses[$val] = true; |
2211 | 2513 | } |
@@ -2214,11 +2516,14 @@ discard block |
||
2214 | 2516 | |
2215 | 2517 | // reply to any address which is to, but not to my self |
2216 | 2518 | #if($headers->to) { |
2217 | - foreach($headers['TO'] as $val) { |
|
2218 | - if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) { |
|
2519 | + foreach($headers['TO'] as $val) |
|
2520 | + { |
|
2521 | + if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) |
|
2522 | + { |
|
2219 | 2523 | continue; |
2220 | 2524 | } |
2221 | - if(!$foundAddresses[$val]) { |
|
2525 | + if(!$foundAddresses[$val]) |
|
2526 | + { |
|
2222 | 2527 | $this->sessionData['to'][] = $val; |
2223 | 2528 | $foundAddresses[$val] = true; |
2224 | 2529 | } |
@@ -2226,12 +2531,15 @@ discard block |
||
2226 | 2531 | #} |
2227 | 2532 | |
2228 | 2533 | #if($headers->from) { |
2229 | - foreach($headers['FROM'] as $val) { |
|
2230 | - if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) { |
|
2534 | + foreach($headers['FROM'] as $val) |
|
2535 | + { |
|
2536 | + if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) |
|
2537 | + { |
|
2231 | 2538 | continue; |
2232 | 2539 | } |
2233 | 2540 | //error_log(__METHOD__.__LINE__.' '.$val); |
2234 | - if(!$foundAddresses[$val]) { |
|
2541 | + if(!$foundAddresses[$val]) |
|
2542 | + { |
|
2235 | 2543 | $this->sessionData['to'][] = $val; |
2236 | 2544 | $foundAddresses[$val] = true; |
2237 | 2545 | } |
@@ -2240,9 +2548,12 @@ discard block |
||
2240 | 2548 | } |
2241 | 2549 | |
2242 | 2550 | // check for Re: in subject header |
2243 | - if(strtolower(substr(trim($mail_bo->decode_header($headers['SUBJECT'])), 0, 3)) == "re:") { |
|
2551 | + if(strtolower(substr(trim($mail_bo->decode_header($headers['SUBJECT'])), 0, 3)) == "re:") |
|
2552 | + { |
|
2244 | 2553 | $this->sessionData['subject'] = $mail_bo->decode_header($headers['SUBJECT']); |
2245 | - } else { |
|
2554 | + } |
|
2555 | + else |
|
2556 | + { |
|
2246 | 2557 | $this->sessionData['subject'] = "Re: " . $mail_bo->decode_header($headers['SUBJECT']); |
2247 | 2558 | } |
2248 | 2559 | |
@@ -2268,7 +2579,8 @@ discard block |
||
2268 | 2579 | |
2269 | 2580 | $toAddressA = array(); |
2270 | 2581 | $toAddress = ''; |
2271 | - foreach ($headers['TO'] as $mailheader) { |
|
2582 | + foreach ($headers['TO'] as $mailheader) |
|
2583 | + { |
|
2272 | 2584 | $toAddressA[] = $mailheader; |
2273 | 2585 | } |
2274 | 2586 | if (count($toAddressA)>0) |
@@ -2278,7 +2590,8 @@ discard block |
||
2278 | 2590 | } |
2279 | 2591 | $ccAddressA = array(); |
2280 | 2592 | $ccAddress = ''; |
2281 | - foreach ($headers['CC'] as $mailheader) { |
|
2593 | + foreach ($headers['CC'] as $mailheader) |
|
2594 | + { |
|
2282 | 2595 | $ccAddressA[] = $mailheader; |
2283 | 2596 | } |
2284 | 2597 | if (count($ccAddressA)>0) |
@@ -2286,25 +2599,35 @@ discard block |
||
2286 | 2599 | $ccAddress = implode(', ', str_replace(array('<','>'),array('[',']'),$ccAddressA)); |
2287 | 2600 | $ccAddress = @htmlspecialchars(lang("cc")).": ".$ccAddress.($bodyParts['0']['mimeType'] == 'text/html'?"<br>":"\r\n"); |
2288 | 2601 | } |
2289 | - if($bodyParts['0']['mimeType'] == 'text/html') { |
|
2602 | + if($bodyParts['0']['mimeType'] == 'text/html') |
|
2603 | + { |
|
2290 | 2604 | $this->sessionData['body'] = /*"<br>".*//*" ".*/"<div>".'----------------'.lang("original message").'-----------------'."".'<br>'. |
2291 | 2605 | @htmlspecialchars(lang("from")).": ".$fromAddress."<br>". |
2292 | 2606 | $toAddress.$ccAddress. |
2293 | 2607 | @htmlspecialchars(lang("date").": ".$headers['DATE'],ENT_QUOTES | ENT_IGNORE,Mail::$displayCharset, false)."<br>". |
2294 | 2608 | '----------------------------------------------------------'."</div>"; |
2295 | 2609 | $this->sessionData['mimeType'] = 'html'; |
2296 | - if (!empty($styles)) $this->sessionData['body'] .= $styles; |
|
2610 | + if (!empty($styles)) |
|
2611 | + { |
|
2612 | + $this->sessionData['body'] .= $styles; |
|
2613 | + } |
|
2297 | 2614 | $this->sessionData['body'] .= '<blockquote type="cite">'; |
2298 | 2615 | |
2299 | - for($i=0; $i<count($bodyParts); $i++) { |
|
2300 | - if($i>0) { |
|
2616 | + for($i=0; $i<count($bodyParts); $i++) |
|
2617 | + { |
|
2618 | + if($i>0) |
|
2619 | + { |
|
2301 | 2620 | $this->sessionData['body'] .= '<hr>'; |
2302 | 2621 | } |
2303 | - if($bodyParts[$i]['mimeType'] == 'text/plain') { |
|
2622 | + if($bodyParts[$i]['mimeType'] == 'text/plain') |
|
2623 | + { |
|
2304 | 2624 | #$bodyParts[$i]['body'] = nl2br($bodyParts[$i]['body'])."<br>"; |
2305 | 2625 | $bodyParts[$i]['body'] = "<pre>".$bodyParts[$i]['body']."</pre>"; |
2306 | 2626 | } |
2307 | - if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']); |
|
2627 | + if ($bodyParts[$i]['charSet']===false) |
|
2628 | + { |
|
2629 | + $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']); |
|
2630 | + } |
|
2308 | 2631 | |
2309 | 2632 | $_htmlConfig = Mail::$htmLawed_config; |
2310 | 2633 | Mail::$htmLawed_config['comment'] = 2; |
@@ -2316,7 +2639,9 @@ discard block |
||
2316 | 2639 | |
2317 | 2640 | $this->sessionData['body'] .= '</blockquote><br>'; |
2318 | 2641 | $this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID, 'html'); |
2319 | - } else { |
|
2642 | + } |
|
2643 | + else |
|
2644 | + { |
|
2320 | 2645 | //$this->sessionData['body'] = @htmlspecialchars(lang("on")." ".$headers['DATE']." ".$mail_bo->decode_header($fromAddress), ENT_QUOTES) . " ".lang("wrote").":\r\n"; |
2321 | 2646 | // take care the way the ReplyHeader is created here, is used later on in uicompose::compose, in case you force replys to be HTML (prefs) |
2322 | 2647 | $this->sessionData['body'] = " \r\n \r\n".'----------------'.lang("original message").'-----------------'."\r\n". |
@@ -2326,8 +2651,10 @@ discard block |
||
2326 | 2651 | '-------------------------------------------------'."\r\n \r\n "; |
2327 | 2652 | $this->sessionData['mimeType'] = 'plain'; |
2328 | 2653 | |
2329 | - for($i=0; $i<count($bodyParts); $i++) { |
|
2330 | - if($i>0) { |
|
2654 | + for($i=0; $i<count($bodyParts); $i++) |
|
2655 | + { |
|
2656 | + if($i>0) |
|
2657 | + { |
|
2331 | 2658 | $this->sessionData['body'] .= "<hr>"; |
2332 | 2659 | } |
2333 | 2660 | |
@@ -2338,7 +2665,8 @@ discard block |
||
2338 | 2665 | $this->sessionData['body'] .= "\r\n"; |
2339 | 2666 | $hasSignature = false; |
2340 | 2667 | // create body new, with good line breaks and indention |
2341 | - foreach(explode("\n",$newBody) as $value) { |
|
2668 | + foreach(explode("\n",$newBody) as $value) |
|
2669 | + { |
|
2342 | 2670 | // the explode is removing the character |
2343 | 2671 | //$value .= 'ee'; |
2344 | 2672 | |
@@ -2354,9 +2682,12 @@ discard block |
||
2354 | 2682 | |
2355 | 2683 | $bodyAppend = $this->mail_bo->wordwrap($value, 76-strlen("\r\n$appendString "), "\r\n$appendString ",'>'); |
2356 | 2684 | |
2357 | - if($bodyAppend[0] == '>') { |
|
2685 | + if($bodyAppend[0] == '>') |
|
2686 | + { |
|
2358 | 2687 | $bodyAppend = '>'. $bodyAppend; |
2359 | - } else { |
|
2688 | + } |
|
2689 | + else |
|
2690 | + { |
|
2360 | 2691 | $bodyAppend = '> '. $bodyAppend; |
2361 | 2692 | } |
2362 | 2693 | |
@@ -2405,9 +2736,12 @@ discard block |
||
2405 | 2736 | |
2406 | 2737 | static function _getHostName() |
2407 | 2738 | { |
2408 | - if (isset($_SERVER['SERVER_NAME'])) { |
|
2739 | + if (isset($_SERVER['SERVER_NAME'])) |
|
2740 | + { |
|
2409 | 2741 | $result = $_SERVER['SERVER_NAME']; |
2410 | - } else { |
|
2742 | + } |
|
2743 | + else |
|
2744 | + { |
|
2411 | 2745 | $result = 'localhost.localdomain'; |
2412 | 2746 | } |
2413 | 2747 | return $result; |
@@ -2445,11 +2779,16 @@ discard block |
||
2445 | 2779 | |
2446 | 2780 | $_mailObject->addHeader('X-Priority', $_formData['priority']); |
2447 | 2781 | $_mailObject->addHeader('X-Mailer', 'EGroupware-Mail'); |
2448 | - if(!empty($_formData['in-reply-to'])) { |
|
2449 | - if (stripos($_formData['in-reply-to'],'<')===false) $_formData['in-reply-to']='<'.trim($_formData['in-reply-to']).'>'; |
|
2782 | + if(!empty($_formData['in-reply-to'])) |
|
2783 | + { |
|
2784 | + if (stripos($_formData['in-reply-to'],'<')===false) |
|
2785 | + { |
|
2786 | + $_formData['in-reply-to']='<'.trim($_formData['in-reply-to']).'>'; |
|
2787 | + } |
|
2450 | 2788 | $_mailObject->addHeader('In-Reply-To', $_formData['in-reply-to']); |
2451 | 2789 | } |
2452 | - if(!empty($_formData['references'])) { |
|
2790 | + if(!empty($_formData['references'])) |
|
2791 | + { |
|
2453 | 2792 | if (stripos($_formData['references'],'<')===false) |
2454 | 2793 | { |
2455 | 2794 | $_formData['references']='<'.trim($_formData['references']).'>'; |
@@ -2457,28 +2796,38 @@ discard block |
||
2457 | 2796 | $_mailObject->addHeader('References', $_formData['references']); |
2458 | 2797 | } |
2459 | 2798 | |
2460 | - if(!empty($_formData['thread-index'])) { |
|
2799 | + if(!empty($_formData['thread-index'])) |
|
2800 | + { |
|
2461 | 2801 | $_mailObject->addHeader('Thread-Index', $_formData['thread-index']); |
2462 | 2802 | } |
2463 | - if(!empty($_formData['list-id'])) { |
|
2803 | + if(!empty($_formData['list-id'])) |
|
2804 | + { |
|
2464 | 2805 | $_mailObject->addHeader('List-Id', $_formData['list-id']); |
2465 | 2806 | } |
2466 | - if($_formData['disposition']=='on') { |
|
2807 | + if($_formData['disposition']=='on') |
|
2808 | + { |
|
2467 | 2809 | $_mailObject->addHeader('Disposition-Notification-To', $_identity['ident_email']); |
2468 | 2810 | } |
2469 | 2811 | |
2470 | 2812 | // Expand any mailing lists |
2471 | 2813 | foreach(array('to', 'cc', 'bcc', 'replyto') as $field) |
2472 | 2814 | { |
2473 | - if ($field != 'replyto') $_formData[$field] = self::resolveEmailAddressList($_formData[$field]); |
|
2815 | + if ($field != 'replyto') |
|
2816 | + { |
|
2817 | + $_formData[$field] = self::resolveEmailAddressList($_formData[$field]); |
|
2818 | + } |
|
2474 | 2819 | |
2475 | - if ($_formData[$field]) $_mailObject->addAddress($_formData[$field], '', $field); |
|
2820 | + if ($_formData[$field]) |
|
2821 | + { |
|
2822 | + $_mailObject->addAddress($_formData[$field], '', $field); |
|
2823 | + } |
|
2476 | 2824 | } |
2477 | 2825 | |
2478 | 2826 | $_mailObject->addHeader('Subject', $_formData['subject']); |
2479 | 2827 | |
2480 | 2828 | // this should never happen since we come from the edit dialog |
2481 | - if (Mail::detect_qp($_formData['body'])) { |
|
2829 | + if (Mail::detect_qp($_formData['body'])) |
|
2830 | + { |
|
2482 | 2831 | $_formData['body'] = preg_replace('/=\r\n/', '', $_formData['body']); |
2483 | 2832 | $_formData['body'] = quoted_printable_decode($_formData['body']); |
2484 | 2833 | } |
@@ -2532,7 +2881,10 @@ discard block |
||
2532 | 2881 | $_mailObject->setBody($this->convertHTMLToText($body, true, true)); |
2533 | 2882 | } |
2534 | 2883 | // convert URL Images to inline images - if possible |
2535 | - if (!$_autosaving) $inline_images = Mail::processURL2InlineImages($_mailObject, $body, $mail_bo); |
|
2884 | + if (!$_autosaving) |
|
2885 | + { |
|
2886 | + $inline_images = Mail::processURL2InlineImages($_mailObject, $body, $mail_bo); |
|
2887 | + } |
|
2536 | 2888 | if (strpos($body,"<!-- HTMLSIGBEGIN -->")!==false) |
2537 | 2889 | { |
2538 | 2890 | $body = str_replace(array('<!-- HTMLSIGBEGIN -->','<!-- HTMLSIGEND -->'),'',$body); |
@@ -2545,10 +2897,14 @@ discard block |
||
2545 | 2897 | default: |
2546 | 2898 | $body = $this->convertHTMLToText($_formData['body'],false, false, true, true); |
2547 | 2899 | |
2548 | - if ($attachment_links) $body .= $attachment_links; |
|
2900 | + if ($attachment_links) |
|
2901 | + { |
|
2902 | + $body .= $attachment_links; |
|
2903 | + } |
|
2549 | 2904 | |
2550 | 2905 | #$_mailObject->Body = $_formData['body']; |
2551 | - if(!empty($signature)) { |
|
2906 | + if(!empty($signature)) |
|
2907 | + { |
|
2552 | 2908 | $body .= ($disableRuler ?"\r\n":"\r\n-- \r\n"). |
2553 | 2909 | $this->convertHTMLToText($signature,true,true); |
2554 | 2910 | } |
@@ -2559,10 +2915,12 @@ discard block |
||
2559 | 2915 | { |
2560 | 2916 | $connection_opened = false; |
2561 | 2917 | $tnfattachments = null; |
2562 | - foreach((array)$_formData['attachments'] as $attachment) { |
|
2918 | + foreach((array)$_formData['attachments'] as $attachment) |
|
2919 | + { |
|
2563 | 2920 | if(is_array($attachment)) |
2564 | 2921 | { |
2565 | - if (!empty($attachment['uid']) && !empty($attachment['folder'])) { |
|
2922 | + if (!empty($attachment['uid']) && !empty($attachment['folder'])) |
|
2923 | + { |
|
2566 | 2924 | /* Example: |
2567 | 2925 | Array([0] => Array( |
2568 | 2926 | [uid] => 21178 |
@@ -2578,14 +2936,18 @@ discard block |
||
2578 | 2936 | $connection_opened = true; |
2579 | 2937 | } |
2580 | 2938 | $mail_bo->reopen($attachment['folder']); |
2581 | - switch(strtoupper($attachment['type'])) { |
|
2939 | + switch(strtoupper($attachment['type'])) |
|
2940 | + { |
|
2582 | 2941 | case 'MESSAGE/RFC': |
2583 | 2942 | case 'MESSAGE/RFC822': |
2584 | 2943 | $rawBody=''; |
2585 | - if (isset($attachment['partID'])) { |
|
2944 | + if (isset($attachment['partID'])) |
|
2945 | + { |
|
2586 | 2946 | $eml = $mail_bo->getAttachment($attachment['uid'],$attachment['partID'],0,false,true,$attachment['folder']); |
2587 | 2947 | $rawBody=$eml['attachment']; |
2588 | - } else { |
|
2948 | + } |
|
2949 | + else |
|
2950 | + { |
|
2589 | 2951 | $rawBody = $mail_bo->getMessageRawBody($attachment['uid'], $attachment['partID'],$attachment['folder']); |
2590 | 2952 | } |
2591 | 2953 | $_mailObject->addStringAttachment($rawBody, $attachment['name'], 'message/rfc822'); |
@@ -2594,7 +2956,10 @@ discard block |
||
2594 | 2956 | $attachmentData = $mail_bo->getAttachment($attachment['uid'], $attachment['partID'],0,false); |
2595 | 2957 | if ($attachmentData['type'] == 'APPLICATION/MS-TNEF') |
2596 | 2958 | { |
2597 | - if (!is_array($tnfattachments)) $tnfattachments = $mail_bo->decode_winmail($attachment['uid'], $attachment['partID']); |
|
2959 | + if (!is_array($tnfattachments)) |
|
2960 | + { |
|
2961 | + $tnfattachments = $mail_bo->decode_winmail($attachment['uid'], $attachment['partID']); |
|
2962 | + } |
|
2598 | 2963 | foreach ($tnfattachments as $k) |
2599 | 2964 | { |
2600 | 2965 | if ($k['name'] == $attachment['name']) |
@@ -2629,7 +2994,10 @@ discard block |
||
2629 | 2994 | } |
2630 | 2995 | } |
2631 | 2996 | } |
2632 | - if ($connection_opened) $mail_bo->closeConnection(); |
|
2997 | + if ($connection_opened) |
|
2998 | + { |
|
2999 | + $mail_bo->closeConnection(); |
|
3000 | + } |
|
2633 | 3001 | } |
2634 | 3002 | return is_array($inline_images)?$inline_images:array(); |
2635 | 3003 | } |
@@ -2649,13 +3017,20 @@ discard block |
||
2649 | 3017 | */ |
2650 | 3018 | protected function _getAttachmentLinks(array $attachments, $filemode, $html, $recipients=array(), $expiration=null, $password=null) |
2651 | 3019 | { |
2652 | - if ($filemode == Vfs\Sharing::ATTACH) return ''; |
|
3020 | + if ($filemode == Vfs\Sharing::ATTACH) |
|
3021 | + { |
|
3022 | + return ''; |
|
3023 | + } |
|
2653 | 3024 | |
2654 | 3025 | $links = array(); |
2655 | 3026 | foreach($attachments as $attachment) |
2656 | 3027 | { |
2657 | 3028 | $path = $attachment['file']; |
2658 | - if (empty($path)) continue; // we only care about file attachments, not forwarded messages or parts |
|
3029 | + if (empty($path)) |
|
3030 | + { |
|
3031 | + continue; |
|
3032 | + } |
|
3033 | + // we only care about file attachments, not forwarded messages or parts |
|
2659 | 3034 | if (parse_url($attachment['file'],PHP_URL_SCHEME) != 'vfs') |
2660 | 3035 | { |
2661 | 3036 | $path = $GLOBALS['egw_info']['server']['temp_dir'].'/'.basename($path); |
@@ -2758,13 +3133,19 @@ discard block |
||
2758 | 3133 | $success = false; |
2759 | 3134 | error_log(__METHOD__.__LINE__.$msg); |
2760 | 3135 | } |
2761 | - } else { |
|
3136 | + } |
|
3137 | + else |
|
3138 | + { |
|
2762 | 3139 | error_log(__METHOD__.__LINE__.': original message ('.$pMuid.') has attachments and lastDrafted ID ('.$duid.') equals the former'); |
2763 | 3140 | } |
2764 | - } else { |
|
3141 | + } |
|
3142 | + else |
|
3143 | + { |
|
2765 | 3144 | error_log(__METHOD__.__LINE__." No current draftID (".$draft_id."), or no lastDrafted Info (".$content['lastDrafted'].") or the former being equal:".array2string($content)."(, action=$action)"); |
2766 | 3145 | } |
2767 | - } else { |
|
3146 | + } |
|
3147 | + else |
|
3148 | + { |
|
2768 | 3149 | error_log(__METHOD__.__LINE__.' No headerdata found for messageUID='.$messageUid.' in Folder:'.$folder.':'.array2string($content)."(, action=$action)"); |
2769 | 3150 | } |
2770 | 3151 | } |
@@ -2780,7 +3161,10 @@ discard block |
||
2780 | 3161 | $success = false; |
2781 | 3162 | } |
2782 | 3163 | |
2783 | - if ($success) $msg = lang('Message saved successfully.'); |
|
3164 | + if ($success) |
|
3165 | + { |
|
3166 | + $msg = lang('Message saved successfully.'); |
|
3167 | + } |
|
2784 | 3168 | |
2785 | 3169 | // Include new information to json respose, because we need them in client-side callback |
2786 | 3170 | $response->data(array( |
@@ -2804,7 +3188,10 @@ discard block |
||
2804 | 3188 | { |
2805 | 3189 | if(is_int($address)) |
2806 | 3190 | { |
2807 | - if (!isset($contacts_obs)) $contacts_obj = new Api\Contacts(); |
|
3191 | + if (!isset($contacts_obs)) |
|
3192 | + { |
|
3193 | + $contacts_obj = new Api\Contacts(); |
|
3194 | + } |
|
2808 | 3195 | // List was selected, expand to addresses |
2809 | 3196 | unset($_emailAddressList[$ak]); |
2810 | 3197 | $list = $contacts_obj->search('',array('n_fn','n_prefix','n_given','n_family','org_name','email','email_home'),'','','',False,'AND',false,array('list' =>(int)$address)); |
@@ -2819,7 +3206,10 @@ discard block |
||
2819 | 3206 | { |
2820 | 3207 | foreach ($addrFromList as $addr) |
2821 | 3208 | { |
2822 | - if (!empty($addr)) $_emailAddressList[]=$addr; |
|
3209 | + if (!empty($addr)) |
|
3210 | + { |
|
3211 | + $_emailAddressList[]=$addr; |
|
3212 | + } |
|
2823 | 3213 | } |
2824 | 3214 | } |
2825 | 3215 | return is_array($_emailAddressList) ? array_values($_emailAddressList) : (array)$_emailAddressList; |
@@ -2873,7 +3263,10 @@ discard block |
||
2873 | 3263 | // decide where to save the message (default to draft folder, if we find nothing else) |
2874 | 3264 | // if the current folder is in draft or template folder save it there |
2875 | 3265 | // if it is called from printview then save it with the draft folder |
2876 | - if (empty($savingDestination)) $savingDestination = $mail_bo->getDraftFolder(); |
|
3266 | + if (empty($savingDestination)) |
|
3267 | + { |
|
3268 | + $savingDestination = $mail_bo->getDraftFolder(); |
|
3269 | + } |
|
2877 | 3270 | if (empty($this->sessionData['messageFolder']) && !empty($this->sessionData['mailbox'])) |
2878 | 3271 | { |
2879 | 3272 | $this->sessionData['messageFolder'] = $this->sessionData['mailbox']; |
@@ -2884,13 +3277,17 @@ discard block |
||
2884 | 3277 | $savingDestination = $this->sessionData['messageFolder']; |
2885 | 3278 | //error_log(__METHOD__.__LINE__.' SavingDestination:'.$savingDestination); |
2886 | 3279 | } |
2887 | - if ( !empty($_formData['printit']) && $_formData['printit'] == 0 ) $savingDestination = $mail_bo->getDraftFolder(); |
|
3280 | + if ( !empty($_formData['printit']) && $_formData['printit'] == 0 ) |
|
3281 | + { |
|
3282 | + $savingDestination = $mail_bo->getDraftFolder(); |
|
3283 | + } |
|
2888 | 3284 | |
2889 | 3285 | // normaly Bcc is only added to recipients, but not as header visible to all recipients |
2890 | 3286 | $mail->forceBccHeader(); |
2891 | 3287 | |
2892 | 3288 | $mail_bo->openConnection(); |
2893 | - if ($mail_bo->folderExists($savingDestination,true)) { |
|
3289 | + if ($mail_bo->folderExists($savingDestination,true)) |
|
3290 | + { |
|
2894 | 3291 | try |
2895 | 3292 | { |
2896 | 3293 | $messageUid = $mail_bo->appendMessage($savingDestination, $mail->getRaw(), null, $flags); |
@@ -2901,7 +3298,9 @@ discard block |
||
2901 | 3298 | return false; |
2902 | 3299 | } |
2903 | 3300 | |
2904 | - } else { |
|
3301 | + } |
|
3302 | + else |
|
3303 | + { |
|
2905 | 3304 | error_log(__METHOD__.__LINE__."->".lang("folder")." ". $savingDestination." ".lang("does not exist on IMAP Server.")); |
2906 | 3305 | return false; |
2907 | 3306 | } |
@@ -2951,7 +3350,10 @@ discard block |
||
2951 | 3350 | $fhA = mail_ui::splitRowID($rowid); |
2952 | 3351 | $this->sessionData['uid'][] = $fhA['msgUID']; |
2953 | 3352 | $this->sessionData['forwardedUID'][] = $fhA['msgUID']; |
2954 | - if (!empty($fhA['folder'])) $this->sessionData['sourceFolder'] = $fhA['folder']; |
|
3353 | + if (!empty($fhA['folder'])) |
|
3354 | + { |
|
3355 | + $this->sessionData['sourceFolder'] = $fhA['folder']; |
|
3356 | + } |
|
2955 | 3357 | } |
2956 | 3358 | } |
2957 | 3359 | if ($_formData['mode']=='reply' && !empty($_formData['processedmail_id'])) |
@@ -2983,7 +3385,8 @@ discard block |
||
2983 | 3385 | #error_log($this->sessionData['body']); |
2984 | 3386 | } |
2985 | 3387 | if(empty($this->sessionData['to']) && empty($this->sessionData['cc']) && |
2986 | - empty($this->sessionData['bcc']) && empty($this->sessionData['folder'])) { |
|
3388 | + empty($this->sessionData['bcc']) && empty($this->sessionData['folder'])) |
|
3389 | + { |
|
2987 | 3390 | $messageIsDraft = true; |
2988 | 3391 | } |
2989 | 3392 | try |
@@ -2999,7 +3402,11 @@ discard block |
||
2999 | 3402 | // create the messages and store inline images |
3000 | 3403 | $inline_images = $this->createMessage($mail, $_formData, $identity); |
3001 | 3404 | // remember the identity |
3002 | - if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on') $fromAddress = $mail->From;//$mail->FromName.($mail->FromName?' <':'').$mail->From.($mail->FromName?'>':''); |
|
3405 | + if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on') |
|
3406 | + { |
|
3407 | + $fromAddress = $mail->From; |
|
3408 | + } |
|
3409 | + //$mail->FromName.($mail->FromName?' <':'').$mail->From.($mail->FromName?'>':''); |
|
3003 | 3410 | #print "<pre>". $mail->getMessageHeader() ."</pre><hr><br>"; |
3004 | 3411 | #print "<pre>". $mail->getMessageBody() ."</pre><hr><br>"; |
3005 | 3412 | #exit; |
@@ -3012,7 +3419,10 @@ discard block |
||
3012 | 3419 | { |
3013 | 3420 | $fval=$f; |
3014 | 3421 | $icServerID = $_formData['serverID'];//folders always assumed with serverID |
3015 | - if (stripos($f,'::')!==false) list($icServerID,$fval) = explode('::',$f,2); |
|
3422 | + if (stripos($f,'::')!==false) |
|
3423 | + { |
|
3424 | + list($icServerID,$fval) = explode('::',$f,2); |
|
3425 | + } |
|
3016 | 3426 | if ($_formData['serverID']!=$_formData['mailaccount']) |
3017 | 3427 | { |
3018 | 3428 | if ($icServerID == $_formData['serverID'] ) |
@@ -3053,13 +3463,19 @@ discard block |
||
3053 | 3463 | // sentFolder is account specific |
3054 | 3464 | $sentFolder = $this->mail_bo->getSentFolder(); |
3055 | 3465 | //error_log(__METHOD__.__LINE__.' SentFolder configured:'.$sentFolder.'#'); |
3056 | - if ($sentFolder&& $sentFolder!= 'none' && !$this->mail_bo->folderExists($sentFolder, true)) $sentFolder=false; |
|
3466 | + if ($sentFolder&& $sentFolder!= 'none' && !$this->mail_bo->folderExists($sentFolder, true)) |
|
3467 | + { |
|
3468 | + $sentFolder=false; |
|
3469 | + } |
|
3057 | 3470 | } |
3058 | 3471 | else |
3059 | 3472 | { |
3060 | 3473 | $sentFolder = $mail_bo->getSentFolder(); |
3061 | 3474 | //error_log(__METHOD__.__LINE__.' SentFolder configured:'.$sentFolder.'#'); |
3062 | - if ($sentFolder&& $sentFolder!= 'none' && !$mail_bo->folderExists($sentFolder, true)) $sentFolder=false; |
|
3475 | + if ($sentFolder&& $sentFolder!= 'none' && !$mail_bo->folderExists($sentFolder, true)) |
|
3476 | + { |
|
3477 | + $sentFolder=false; |
|
3478 | + } |
|
3063 | 3479 | } |
3064 | 3480 | //error_log(__METHOD__.__LINE__.' SentFolder configured:'.$sentFolder.'#'); |
3065 | 3481 | |
@@ -3095,19 +3511,30 @@ discard block |
||
3095 | 3511 | { |
3096 | 3512 | if (((!isset($sentFolder)||$sentFolder==false) && $this->mailPreferences['sendOptions'] != 'send_only') || |
3097 | 3513 | ($this->mailPreferences['sendOptions'] != 'send_only' && |
3098 | - $sentFolder != 'none')) $this->errorInfo = lang("No Send Folder set in preferences"); |
|
3514 | + $sentFolder != 'none')) |
|
3515 | + { |
|
3516 | + $this->errorInfo = lang("No Send Folder set in preferences"); |
|
3517 | + } |
|
3099 | 3518 | } |
3100 | 3519 | // draftFolder is on Server we start from |
3101 | - if($messageIsDraft == true) { |
|
3520 | + if($messageIsDraft == true) |
|
3521 | + { |
|
3102 | 3522 | $draftFolder = $mail_bo->getDraftFolder(); |
3103 | - if(!empty($draftFolder) && $mail_bo->folderExists($draftFolder,true)) { |
|
3523 | + if(!empty($draftFolder) && $mail_bo->folderExists($draftFolder,true)) |
|
3524 | + { |
|
3104 | 3525 | $this->sessionData['folder'] = array($draftFolder); |
3105 | 3526 | $folderOnServerID[] = $draftFolder; |
3106 | 3527 | $folder[$draftFolder] = $draftFolder; |
3107 | 3528 | } |
3108 | 3529 | } |
3109 | - if ($folderOnServerID) $folderOnServerID = array_unique($folderOnServerID); |
|
3110 | - if ($folderOnMailAccount) $folderOnMailAccount = array_unique($folderOnMailAccount); |
|
3530 | + if ($folderOnServerID) |
|
3531 | + { |
|
3532 | + $folderOnServerID = array_unique($folderOnServerID); |
|
3533 | + } |
|
3534 | + if ($folderOnMailAccount) |
|
3535 | + { |
|
3536 | + $folderOnMailAccount = array_unique($folderOnMailAccount); |
|
3537 | + } |
|
3111 | 3538 | if (($this->mailPreferences['sendOptions'] != 'send_only' && $sentFolder != 'none') && |
3112 | 3539 | !( count($folder) > 0) && |
3113 | 3540 | !($_formData['to_infolog']=='on' || $_formData['to_tracker']=='on')) |
@@ -3123,7 +3550,8 @@ discard block |
||
3123 | 3550 | try { |
3124 | 3551 | if ($_formData['smime_sign'] == 'on') |
3125 | 3552 | { |
3126 | - if ($_formData['smime_passphrase'] != '') { |
|
3553 | + if ($_formData['smime_passphrase'] != '') |
|
3554 | + { |
|
3127 | 3555 | Api\Cache::setSession( |
3128 | 3556 | 'mail', |
3129 | 3557 | 'smime_passphrase', |
@@ -3170,7 +3598,8 @@ discard block |
||
3170 | 3598 | @set_time_limit(120); |
3171 | 3599 | //$mail->SMTPDebug = 10; |
3172 | 3600 | //error_log("Folder:".count(array($this->sessionData['folder']))."To:".count((array)$this->sessionData['to'])."CC:". count((array)$this->sessionData['cc']) ."bcc:".count((array)$this->sessionData['bcc'])); |
3173 | - if(count((array)$this->sessionData['to']) > 0 || count((array)$this->sessionData['cc']) > 0 || count((array)$this->sessionData['bcc']) > 0) { |
|
3601 | + if(count((array)$this->sessionData['to']) > 0 || count((array)$this->sessionData['cc']) > 0 || count((array)$this->sessionData['bcc']) > 0) |
|
3602 | + { |
|
3174 | 3603 | try { |
3175 | 3604 | // do no close the session before sending, if we have to store the send text for infolog or other integration in the session |
3176 | 3605 | if (!($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on' || $_formData['to_calendar'] == 'on' )) |
@@ -3185,10 +3614,15 @@ discard block |
||
3185 | 3614 | $this->errorInfo = $e->getMessage().($e->details?'<br/>'.$e->details:''); |
3186 | 3615 | return false; |
3187 | 3616 | } |
3188 | - } else { |
|
3189 | - if (count(array($this->sessionData['folder']))>0 && !empty($this->sessionData['folder'])) { |
|
3617 | + } |
|
3618 | + else |
|
3619 | + { |
|
3620 | + if (count(array($this->sessionData['folder']))>0 && !empty($this->sessionData['folder'])) |
|
3621 | + { |
|
3190 | 3622 | //error_log(__METHOD__.__LINE__."Folders:".print_r($this->sessionData['folder'],true)); |
3191 | - } else { |
|
3623 | + } |
|
3624 | + else |
|
3625 | + { |
|
3192 | 3626 | $this->errorInfo = lang("Error: ").lang("No Address TO/CC/BCC supplied, and no folder to save message to provided."); |
3193 | 3627 | //error_log(__METHOD__.__LINE__.$this->errorInfo); |
3194 | 3628 | return false; |
@@ -3198,14 +3632,16 @@ discard block |
||
3198 | 3632 | //error_log(__METHOD__.__LINE__."Number of Folders to move copy the message to:".count($folder)); |
3199 | 3633 | //error_log(__METHOD__.__LINE__.array2string($folder)); |
3200 | 3634 | if ((count($folder) > 0) || (isset($this->sessionData['uid']) && isset($this->sessionData['messageFolder'])) |
3201 | - || (isset($this->sessionData['forwardFlag']) && isset($this->sessionData['sourceFolder']))) { |
|
3635 | + || (isset($this->sessionData['forwardFlag']) && isset($this->sessionData['sourceFolder']))) |
|
3636 | + { |
|
3202 | 3637 | $mail_bo = $this->mail_bo; |
3203 | 3638 | $mail_bo->openConnection(); |
3204 | 3639 | //$mail_bo->reopen($this->sessionData['messageFolder']); |
3205 | 3640 | #error_log("(re)opened Connection"); |
3206 | 3641 | } |
3207 | 3642 | // if copying mail to folder, or saving mail to infolog, we need to gather the needed information |
3208 | - if (count($folder) > 0 || $_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on') { |
|
3643 | + if (count($folder) > 0 || $_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on') |
|
3644 | + { |
|
3209 | 3645 | //error_log(__METHOD__.__LINE__.array2string($this->sessionData['bcc'])); |
3210 | 3646 | |
3211 | 3647 | // normaly Bcc is only added to recipients, but not as header visible to all recipients |
@@ -3214,17 +3650,28 @@ discard block |
||
3214 | 3650 | // copying mail to folder |
3215 | 3651 | if (count($folder) > 0) |
3216 | 3652 | { |
3217 | - foreach($folderOnServerID as $folderName) { |
|
3218 | - if (is_array($folderName)) $folderName = array_shift($folderName); // should not happen at all |
|
3653 | + foreach($folderOnServerID as $folderName) |
|
3654 | + { |
|
3655 | + if (is_array($folderName)) |
|
3656 | + { |
|
3657 | + $folderName = array_shift($folderName); |
|
3658 | + } |
|
3659 | + // should not happen at all |
|
3219 | 3660 | //error_log(__METHOD__.__LINE__." attempt to save message to:".array2string($folderName)); |
3220 | 3661 | // if $_formData['serverID']!=$_formData['mailaccount'] skip copying to sentfolder on serverID |
3221 | 3662 | // if($_formData['serverID']!=$_formData['mailaccount'] && $folderName==$sentFolder && $changeProfileOnSentFolderNeeded) continue; |
3222 | - if ($mail_bo->folderExists($folderName,true)) { |
|
3223 | - if($mail_bo->isSentFolder($folderName)) { |
|
3663 | + if ($mail_bo->folderExists($folderName,true)) |
|
3664 | + { |
|
3665 | + if($mail_bo->isSentFolder($folderName)) |
|
3666 | + { |
|
3224 | 3667 | $flags = '\\Seen'; |
3225 | - } elseif($mail_bo->isDraftFolder($folderName)) { |
|
3668 | + } |
|
3669 | + elseif($mail_bo->isDraftFolder($folderName)) |
|
3670 | + { |
|
3226 | 3671 | $flags = '\\Draft'; |
3227 | - } else { |
|
3672 | + } |
|
3673 | + else |
|
3674 | + { |
|
3228 | 3675 | $flags = '\\Seen'; |
3229 | 3676 | } |
3230 | 3677 | #$mailHeader=explode('From:',$mail->getMessageHeader()); |
@@ -3247,18 +3694,32 @@ discard block |
||
3247 | 3694 | } |
3248 | 3695 | } |
3249 | 3696 | // if we choose to send from a differing profile |
3250 | - if ($folderOnMailAccount) $this->changeProfile($_formData['mailaccount']); |
|
3251 | - foreach($folderOnMailAccount as $folderName) { |
|
3252 | - if (is_array($folderName)) $folderName = array_shift($folderName); // should not happen at all |
|
3697 | + if ($folderOnMailAccount) |
|
3698 | + { |
|
3699 | + $this->changeProfile($_formData['mailaccount']); |
|
3700 | + } |
|
3701 | + foreach($folderOnMailAccount as $folderName) |
|
3702 | + { |
|
3703 | + if (is_array($folderName)) |
|
3704 | + { |
|
3705 | + $folderName = array_shift($folderName); |
|
3706 | + } |
|
3707 | + // should not happen at all |
|
3253 | 3708 | //error_log(__METHOD__.__LINE__." attempt to save message to:".array2string($folderName)); |
3254 | 3709 | // if $_formData['serverID']!=$_formData['mailaccount'] skip copying to sentfolder on serverID |
3255 | 3710 | // if($_formData['serverID']!=$_formData['mailaccount'] && $folderName==$sentFolder && $changeProfileOnSentFolderNeeded) continue; |
3256 | - if ($this->mail_bo->folderExists($folderName,true)) { |
|
3257 | - if($this->mail_bo->isSentFolder($folderName)) { |
|
3711 | + if ($this->mail_bo->folderExists($folderName,true)) |
|
3712 | + { |
|
3713 | + if($this->mail_bo->isSentFolder($folderName)) |
|
3714 | + { |
|
3258 | 3715 | $flags = '\\Seen'; |
3259 | - } elseif($this->mail_bo->isDraftFolder($folderName)) { |
|
3716 | + } |
|
3717 | + elseif($this->mail_bo->isDraftFolder($folderName)) |
|
3718 | + { |
|
3260 | 3719 | $flags = '\\Draft'; |
3261 | - } else { |
|
3720 | + } |
|
3721 | + else |
|
3722 | + { |
|
3262 | 3723 | $flags = '\\Seen'; |
3263 | 3724 | } |
3264 | 3725 | #$mailHeader=explode('From:',$mail->getMessageHeader()); |
@@ -3280,7 +3741,10 @@ discard block |
||
3280 | 3741 | error_log(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.",$this->sessionData['subject'],$folderName)); |
3281 | 3742 | } |
3282 | 3743 | } |
3283 | - if ($folderOnMailAccount) $this->changeProfile($_formData['serverID']); |
|
3744 | + if ($folderOnMailAccount) |
|
3745 | + { |
|
3746 | + $this->changeProfile($_formData['serverID']); |
|
3747 | + } |
|
3284 | 3748 | |
3285 | 3749 | //$mail_bo->closeConnection(); |
3286 | 3750 | } |
@@ -3292,10 +3756,16 @@ discard block |
||
3292 | 3756 | $dhA = mail_ui::splitRowID($this->sessionData['lastDrafted']); |
3293 | 3757 | $lastDrafted['uid'] = $dhA['msgUID']; |
3294 | 3758 | $lastDrafted['folder'] = $dhA['folder']; |
3295 | - if (isset($lastDrafted['uid']) && !empty($lastDrafted['uid'])) $lastDrafted['uid']=trim($lastDrafted['uid']); |
|
3759 | + if (isset($lastDrafted['uid']) && !empty($lastDrafted['uid'])) |
|
3760 | + { |
|
3761 | + $lastDrafted['uid']=trim($lastDrafted['uid']); |
|
3762 | + } |
|
3296 | 3763 | // manually drafted, do not delete |
3297 | 3764 | // will be handled later on IF mode was $_formData['mode']=='composefromdraft' |
3298 | - if (isset($lastDrafted['uid']) && (empty($lastDrafted['uid']) || $lastDrafted['uid'] == $this->sessionData['uid'])) $lastDrafted=false; |
|
3765 | + if (isset($lastDrafted['uid']) && (empty($lastDrafted['uid']) || $lastDrafted['uid'] == $this->sessionData['uid'])) |
|
3766 | + { |
|
3767 | + $lastDrafted=false; |
|
3768 | + } |
|
3299 | 3769 | //error_log(__METHOD__.__LINE__.array2string($lastDrafted)); |
3300 | 3770 | } |
3301 | 3771 | if ($lastDrafted && is_array($lastDrafted) && $mail_bo->isDraftFolder($lastDrafted['folder'])) |
@@ -3321,7 +3791,8 @@ discard block |
||
3321 | 3791 | |
3322 | 3792 | //error_log("handling draft messages, flagging and such"); |
3323 | 3793 | if((isset($this->sessionData['uid']) && isset($this->sessionData['messageFolder'])) |
3324 | - || (isset($this->sessionData['forwardFlag']) && isset($this->sessionData['sourceFolder']))) { |
|
3794 | + || (isset($this->sessionData['forwardFlag']) && isset($this->sessionData['sourceFolder']))) |
|
3795 | + { |
|
3325 | 3796 | // mark message as answered |
3326 | 3797 | $mail_bo->openConnection(); |
3327 | 3798 | $mail_bo->reopen(($this->sessionData['messageFolder']?$this->sessionData['messageFolder']:$this->sessionData['sourceFolder'])); |
@@ -3343,7 +3814,9 @@ discard block |
||
3343 | 3814 | //error_log(__METHOD__.__LINE__." ". str_replace('"',"'",$e->getMessage())); |
3344 | 3815 | unset($e); |
3345 | 3816 | } |
3346 | - } else { |
|
3817 | + } |
|
3818 | + else |
|
3819 | + { |
|
3347 | 3820 | $mail_bo->flagMessages("answered", $this->sessionData['uid'],($this->sessionData['messageFolder']?$this->sessionData['messageFolder']:$this->sessionData['sourceFolder'])); |
3348 | 3821 | //error_log(__METHOD__.__LINE__.array2string(array_keys($this->sessionData)).':'.array2string($this->sessionData['forwardedUID']).' F:'.$this->sessionData['sourceFolder']); |
3349 | 3822 | if (array_key_exists('forwardFlag',$this->sessionData) && $this->sessionData['forwardFlag']=='forwarded') |
@@ -3362,7 +3835,10 @@ discard block |
||
3362 | 3835 | } |
3363 | 3836 | //$mail_bo->closeConnection(); |
3364 | 3837 | } |
3365 | - if ($mail_bo) $mail_bo->closeConnection(); |
|
3838 | + if ($mail_bo) |
|
3839 | + { |
|
3840 | + $mail_bo->closeConnection(); |
|
3841 | + } |
|
3366 | 3842 | //error_log("performing Infolog Stuff"); |
3367 | 3843 | //error_log(print_r($this->sessionData['to'],true)); |
3368 | 3844 | //error_log(print_r($this->sessionData['cc'],true)); |
@@ -3375,9 +3851,18 @@ discard block |
||
3375 | 3851 | { |
3376 | 3852 | $mailaddresses = array(); |
3377 | 3853 | } |
3378 | - if (is_array($this->sessionData['cc'])) $mailaddresses['cc'] = $this->sessionData['cc']; |
|
3379 | - if (is_array($this->sessionData['bcc'])) $mailaddresses['bcc'] = $this->sessionData['bcc']; |
|
3380 | - if (!empty($mailaddresses)) $mailaddresses['from'] = Mail\Html::decodeMailHeader($fromAddress); |
|
3854 | + if (is_array($this->sessionData['cc'])) |
|
3855 | + { |
|
3856 | + $mailaddresses['cc'] = $this->sessionData['cc']; |
|
3857 | + } |
|
3858 | + if (is_array($this->sessionData['bcc'])) |
|
3859 | + { |
|
3860 | + $mailaddresses['bcc'] = $this->sessionData['bcc']; |
|
3861 | + } |
|
3862 | + if (!empty($mailaddresses)) |
|
3863 | + { |
|
3864 | + $mailaddresses['from'] = Mail\Html::decodeMailHeader($fromAddress); |
|
3865 | + } |
|
3381 | 3866 | |
3382 | 3867 | if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on' || $_formData['to_calendar'] == 'on' ) |
3383 | 3868 | { |
@@ -3409,7 +3894,10 @@ discard block |
||
3409 | 3894 | $_formData['serverID']),true), |
3410 | 3895 | 'app' => $app_name |
3411 | 3896 | ); |
3412 | - if ($entryid) $target['entry_id'] = $entryid; |
|
3897 | + if ($entryid) |
|
3898 | + { |
|
3899 | + $target['entry_id'] = $entryid; |
|
3900 | + } |
|
3413 | 3901 | // Open the app called for integration in a popup |
3414 | 3902 | // and store the mail raw data as egw_data, in order to |
3415 | 3903 | // be stored from registered app method later |
@@ -3420,8 +3908,11 @@ discard block |
||
3420 | 3908 | // only clean up temp-files, if we dont need them for mail_integration::integrate |
3421 | 3909 | elseif(is_array($this->sessionData['attachments'])) |
3422 | 3910 | { |
3423 | - foreach($this->sessionData['attachments'] as $value) { |
|
3424 | - if (!empty($value['file']) && parse_url($value['file'],PHP_URL_SCHEME) != 'vfs') { // happens when forwarding mails |
|
3911 | + foreach($this->sessionData['attachments'] as $value) |
|
3912 | + { |
|
3913 | + if (!empty($value['file']) && parse_url($value['file'],PHP_URL_SCHEME) != 'vfs') |
|
3914 | + { |
|
3915 | +// happens when forwarding mails |
|
3425 | 3916 | unlink($GLOBALS['egw_info']['server']['temp_dir'].'/'.$value['file']); |
3426 | 3917 | } |
3427 | 3918 | } |
@@ -3458,7 +3949,10 @@ discard block |
||
3458 | 3949 | $default_identity = null; |
3459 | 3950 | foreach(Mail\Account::identities($this->mail_bo->profileID, true, 'params') as $identity) |
3460 | 3951 | { |
3461 | - if (!isset($default_identity)) $default_identity = $identity['ident_id']; |
|
3952 | + if (!isset($default_identity)) |
|
3953 | + { |
|
3954 | + $default_identity = $identity['ident_id']; |
|
3955 | + } |
|
3462 | 3956 | if (!empty($identity['ident_signature'])) |
3463 | 3957 | { |
3464 | 3958 | $content['mailidentity'] = $identity['ident_id']; |
@@ -3466,12 +3960,18 @@ discard block |
||
3466 | 3960 | } |
3467 | 3961 | } |
3468 | 3962 | } |
3469 | - if (empty($content['mailidentity'])) $content['mailidentity'] = $default_identity; |
|
3963 | + if (empty($content['mailidentity'])) |
|
3964 | + { |
|
3965 | + $content['mailidentity'] = $default_identity; |
|
3966 | + } |
|
3470 | 3967 | } |
3471 | 3968 | if (!isset($content['mimeType']) || empty($content['mimeType'])) |
3472 | 3969 | { |
3473 | 3970 | $content['mimeType'] = 'html'; |
3474 | - if (!empty($this->mailPreferences['composeOptions']) && $this->mailPreferences['composeOptions']=="text") $content['mimeType'] = 'plain'; |
|
3971 | + if (!empty($this->mailPreferences['composeOptions']) && $this->mailPreferences['composeOptions']=="text") |
|
3972 | + { |
|
3973 | + $content['mimeType'] = 'plain'; |
|
3974 | + } |
|
3475 | 3975 | } |
3476 | 3976 | return $content; |
3477 | 3977 | |
@@ -3479,9 +3979,12 @@ discard block |
||
3479 | 3979 | |
3480 | 3980 | function stripSlashes($_string) |
3481 | 3981 | { |
3482 | - if (get_magic_quotes_gpc()) { |
|
3982 | + if (get_magic_quotes_gpc()) |
|
3983 | + { |
|
3483 | 3984 | return stripslashes($_string); |
3484 | - } else { |
|
3985 | + } |
|
3986 | + else |
|
3987 | + { |
|
3485 | 3988 | return $_string; |
3486 | 3989 | } |
3487 | 3990 | } |
@@ -3494,15 +3997,25 @@ discard block |
||
3494 | 3997 | * @param boolean $_noPrefixId = false, if set to true folders name does not get prefixed by account id |
3495 | 3998 | * @return type |
3496 | 3999 | */ |
3497 | - function ajax_searchFolder($_searchStringLength=2, $_returnList=false, $_mailaccountToSearch=null, $_noPrefixId=false) { |
|
4000 | + function ajax_searchFolder($_searchStringLength=2, $_returnList=false, $_mailaccountToSearch=null, $_noPrefixId=false) |
|
4001 | + { |
|
3498 | 4002 | //error_log(__METHOD__.__LINE__.':'.array2string($_REQUEST)); |
3499 | 4003 | static $useCacheIfPossible = null; |
3500 | - if (is_null($useCacheIfPossible)) $useCacheIfPossible = true; |
|
4004 | + if (is_null($useCacheIfPossible)) |
|
4005 | + { |
|
4006 | + $useCacheIfPossible = true; |
|
4007 | + } |
|
3501 | 4008 | $_searchString = trim($_REQUEST['query']); |
3502 | 4009 | $results = array(); |
3503 | 4010 | $rememberServerID = $this->mail_bo->icServer->ImapServerId; |
3504 | - if (is_null($_mailaccountToSearch) && !empty($_REQUEST['mailaccount'])) $_mailaccountToSearch = $_REQUEST['mailaccount']; |
|
3505 | - if (empty($_mailaccountToSearch)) $_mailaccountToSearch = $this->mail_bo->icServer->ImapServerId; |
|
4011 | + if (is_null($_mailaccountToSearch) && !empty($_REQUEST['mailaccount'])) |
|
4012 | + { |
|
4013 | + $_mailaccountToSearch = $_REQUEST['mailaccount']; |
|
4014 | + } |
|
4015 | + if (empty($_mailaccountToSearch)) |
|
4016 | + { |
|
4017 | + $_mailaccountToSearch = $this->mail_bo->icServer->ImapServerId; |
|
4018 | + } |
|
3506 | 4019 | if ($this->mail_bo->icServer && $_mailaccountToSearch && $this->mail_bo->icServer->ImapServerId != $_mailaccountToSearch) |
3507 | 4020 | { |
3508 | 4021 | $this->changeProfile($_mailaccountToSearch); |
@@ -3513,7 +4026,8 @@ discard block |
||
3513 | 4026 | $this->mail_bo->openConnection($this->mail_bo->icServer->ImapServerId); |
3514 | 4027 | //error_log(__METHOD__.__LINE__.array2string($_searchString).'<->'.$searchString); |
3515 | 4028 | $folderObjects = $this->mail_bo->getFolderObjects(true,false,true,$useCacheIfPossible); |
3516 | - if (count($folderObjects)<=1) { |
|
4029 | + if (count($folderObjects)<=1) |
|
4030 | + { |
|
3517 | 4031 | $useCacheIfPossible = false; |
3518 | 4032 | } |
3519 | 4033 | else |
@@ -3564,7 +4078,8 @@ discard block |
||
3564 | 4078 | exit(); |
3565 | 4079 | } |
3566 | 4080 | |
3567 | - public static function ajax_searchAddress($_searchStringLength=2) { |
|
4081 | + public static function ajax_searchAddress($_searchStringLength=2) |
|
4082 | + { |
|
3568 | 4083 | //error_log(__METHOD__. "request from seachAddress " . $_REQUEST['query']); |
3569 | 4084 | $_searchString = trim($_REQUEST['query']); |
3570 | 4085 | $include_lists = (boolean)$_REQUEST['include_lists']; |
@@ -3585,7 +4100,10 @@ discard block |
||
3585 | 4100 | $search = explode(' ', $_searchString); |
3586 | 4101 | foreach ($search as $k => $v) |
3587 | 4102 | { |
3588 | - if (mb_strlen($v) < 3) unset($search[$k]); |
|
4103 | + if (mb_strlen($v) < 3) |
|
4104 | + { |
|
4105 | + unset($search[$k]); |
|
4106 | + } |
|
3589 | 4107 | } |
3590 | 4108 | $search_str = implode(' +', $search); // tell contacts/so_sql to AND search patterns |
3591 | 4109 | //error_log(__METHOD__.__LINE__.$_searchString); |
@@ -3616,10 +4134,13 @@ discard block |
||
3616 | 4134 | } |
3617 | 4135 | } |
3618 | 4136 | |
3619 | - if(is_array($contacts)) { |
|
3620 | - foreach($contacts as $contact) { |
|
4137 | + if(is_array($contacts)) |
|
4138 | + { |
|
4139 | + foreach($contacts as $contact) |
|
4140 | + { |
|
3621 | 4141 | $cf_emails = (array)array_values(array_values($contacts_obj->read_customfields($contact['id'], $cfs_type_email))[0]); |
3622 | - foreach(array_merge(array($contact['email'],$contact['email_home']), $cf_emails) as $email) { |
|
4142 | + foreach(array_merge(array($contact['email'],$contact['email_home']), $cf_emails) as $email) |
|
4143 | + { |
|
3623 | 4144 | // avoid wrong addresses, if an rfc822 encoded address is in addressbook |
3624 | 4145 | //$email = preg_replace("/(^.*<)([a-zA-Z0-9_\-]+@[a-zA-Z0-9_\-\.]+)(.*)/",'$2',$email); |
3625 | 4146 | $rfcAddr = Mail::parseAddressList($email); |
@@ -3633,10 +4154,22 @@ discard block |
||
3633 | 4154 | if (method_exists($contacts_obj,'search')) |
3634 | 4155 | { |
3635 | 4156 | $contact['n_fn']=''; |
3636 | - if (!empty($contact['n_prefix'])) $contact['n_fn'] = $contact['n_prefix']; |
|
3637 | - if (!empty($contact['n_given'])) $contact['n_fn'] .= ($contact['n_fn']?' ':'').$contact['n_given']; |
|
3638 | - if (!empty($contact['n_family'])) $contact['n_fn'] .= ($contact['n_fn']?' ':'').$contact['n_family']; |
|
3639 | - if (!empty($contact['org_name'])) $contact['n_fn'] .= ($contact['n_fn']?' ':'').'('.$contact['org_name'].')'; |
|
4157 | + if (!empty($contact['n_prefix'])) |
|
4158 | + { |
|
4159 | + $contact['n_fn'] = $contact['n_prefix']; |
|
4160 | + } |
|
4161 | + if (!empty($contact['n_given'])) |
|
4162 | + { |
|
4163 | + $contact['n_fn'] .= ($contact['n_fn']?' ':'').$contact['n_given']; |
|
4164 | + } |
|
4165 | + if (!empty($contact['n_family'])) |
|
4166 | + { |
|
4167 | + $contact['n_fn'] .= ($contact['n_fn']?' ':'').$contact['n_family']; |
|
4168 | + } |
|
4169 | + if (!empty($contact['org_name'])) |
|
4170 | + { |
|
4171 | + $contact['n_fn'] .= ($contact['n_fn']?' ':'').'('.$contact['org_name'].')'; |
|
4172 | + } |
|
3640 | 4173 | $contact['n_fn'] = str_replace(array(',','@'),' ',$contact['n_fn']); |
3641 | 4174 | } |
3642 | 4175 | else |
@@ -3646,7 +4179,8 @@ discard block |
||
3646 | 4179 | $args = explode('@', trim($email)); |
3647 | 4180 | $args[] = trim($contact['n_fn'] ? $contact['n_fn'] : $contact['fn']); |
3648 | 4181 | $completeMailString = call_user_func_array('imap_rfc822_write_address', $args); |
3649 | - if(!empty($email) && in_array($completeMailString ,$results) === false) { |
|
4182 | + if(!empty($email) && in_array($completeMailString ,$results) === false) |
|
4183 | + { |
|
3650 | 4184 | $results[] = array( |
3651 | 4185 | 'id'=>$completeMailString, |
3652 | 4186 | 'label' => $completeMailString, |
@@ -3669,7 +4203,10 @@ discard block |
||
3669 | 4203 | foreach($groups as $g_id => $name) |
3670 | 4204 | { |
3671 | 4205 | $group = $GLOBALS['egw']->accounts->read($g_id); |
3672 | - if(!$group['account_email']) continue; |
|
4206 | + if(!$group['account_email']) |
|
4207 | + { |
|
4208 | + continue; |
|
4209 | + } |
|
3673 | 4210 | $args = explode('@', trim($group['account_email'])); |
3674 | 4211 | $args[] = $name; |
3675 | 4212 | $completeMailString = call_user_func_array('imap_rfc822_write_address', $args); |
@@ -3705,7 +4242,8 @@ discard block |
||
3705 | 4242 | $manual_lists = array(); |
3706 | 4243 | $lists = array_filter( |
3707 | 4244 | $contacts_obj->get_lists(Acl::READ), |
3708 | - function($element) use($_searchString) { |
|
4245 | + function($element) use($_searchString) |
|
4246 | + { |
|
3709 | 4247 | return (stripos($element, $_searchString) !== false); |
3710 | 4248 | } |
3711 | 4249 | ); |
@@ -3723,9 +4261,13 @@ discard block |
||
3723 | 4261 | ); |
3724 | 4262 | ${"${type}_lists"}[] = $list; |
3725 | 4263 | } |
3726 | - $trim = function($list) { |
|
4264 | + $trim = function($list) |
|
4265 | + { |
|
3727 | 4266 | $limit = 10; |
3728 | - if(count($list) <= $limit) return $list; |
|
4267 | + if(count($list) <= $limit) |
|
4268 | + { |
|
4269 | + return $list; |
|
4270 | + } |
|
3729 | 4271 | $list[$limit-1]['class'].= ' more_results'; |
3730 | 4272 | $list[$limit-1]['title'] .= ' (' . lang('%1 more', count($list) - $limit) . ')'; |
3731 | 4273 | return array_slice($list, 0, $limit); |
@@ -3828,7 +4370,10 @@ discard block |
||
3828 | 4370 | try |
3829 | 4371 | { |
3830 | 4372 | $sender_cert = $AB->get_smime_keys($sender); |
3831 | - if (!$sender_cert) throw new Exception("S/MIME Encryption failed because no certificate has been found for sender address: " . $sender); |
|
4373 | + if (!$sender_cert) |
|
4374 | + { |
|
4375 | + throw new Exception("S/MIME Encryption failed because no certificate has been found for sender address: " . $sender); |
|
4376 | + } |
|
3832 | 4377 | $params['senderPubKey'] = $sender_cert[strtolower($sender)]; |
3833 | 4378 | |
3834 | 4379 | if (isset($sender) && ($type == Mail\Smime::TYPE_SIGN || $type == Mail\Smime::TYPE_SIGN_ENCRYPT)) |
@@ -3843,9 +4388,15 @@ discard block |
||
3843 | 4388 | $params['recipientsCerts'] = $AB->get_smime_keys($recipients); |
3844 | 4389 | foreach ($recipients as &$recipient) |
3845 | 4390 | { |
3846 | - if (!$params['recipientsCerts'][strtolower($recipient)]) $missingCerts []= $recipient; |
|
4391 | + if (!$params['recipientsCerts'][strtolower($recipient)]) |
|
4392 | + { |
|
4393 | + $missingCerts []= $recipient; |
|
4394 | + } |
|
4395 | + } |
|
4396 | + if (is_array($missingCerts)) |
|
4397 | + { |
|
4398 | + throw new Exception ('S/MIME Encryption failed because no certificate has been found for following addresses: '. implode ('|', $missingCerts)); |
|
3847 | 4399 | } |
3848 | - if (is_array($missingCerts)) throw new Exception ('S/MIME Encryption failed because no certificate has been found for following addresses: '. implode ('|', $missingCerts)); |
|
3849 | 4400 | } |
3850 | 4401 | |
3851 | 4402 | return $mail->smimeEncrypt($type, $params); |
@@ -24,8 +24,7 @@ discard block |
||
24 | 24 | */ |
25 | 25 | class mail_compose |
26 | 26 | { |
27 | - var $public_functions = array |
|
28 | - ( |
|
27 | + var $public_functions = array( |
|
29 | 28 | 'compose' => True, |
30 | 29 | 'getAttachment' => True, |
31 | 30 | ); |
@@ -34,8 +33,8 @@ discard block |
||
34 | 33 | * class vars for destination, priorities, mimeTypes |
35 | 34 | */ |
36 | 35 | static $destinations = array( |
37 | - 'to' => 'to', // lang('to') |
|
38 | - 'cc' => 'cc', // lang('cc') |
|
36 | + 'to' => 'to', // lang('to') |
|
37 | + 'cc' => 'cc', // lang('cc') |
|
39 | 38 | 'bcc' => 'bcc', // lang('bcc') |
40 | 39 | 'replyto' => 'replyto', // lang('replyto') |
41 | 40 | 'folder' => 'folder' // lang('folder') |
@@ -63,20 +62,20 @@ discard block |
||
63 | 62 | * @var array |
64 | 63 | */ |
65 | 64 | var $mailPreferences; |
66 | - var $attachments; // Array of attachments |
|
65 | + var $attachments; // Array of attachments |
|
67 | 66 | var $displayCharset; |
68 | 67 | var $composeID; |
69 | 68 | var $sessionData; |
70 | 69 | |
71 | 70 | function __construct() |
72 | 71 | { |
73 | - $this->displayCharset = Api\Translation::charset(); |
|
72 | + $this->displayCharset = Api\Translation::charset(); |
|
74 | 73 | |
75 | 74 | $profileID = (int)$GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID']; |
76 | - $this->mail_bo = Mail::getInstance(true,$profileID); |
|
75 | + $this->mail_bo = Mail::getInstance(true, $profileID); |
|
77 | 76 | $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'] = $this->mail_bo->profileID; |
78 | 77 | |
79 | - $this->mailPreferences =& $this->mail_bo->mailPreferences; |
|
78 | + $this->mailPreferences = & $this->mail_bo->mailPreferences; |
|
80 | 79 | //force the default for the forwarding -> asmail |
81 | 80 | if (!is_array($this->mailPreferences) || empty($this->mailPreferences['message_forwarding'])) |
82 | 81 | { |
@@ -84,7 +83,7 @@ discard block |
||
84 | 83 | } |
85 | 84 | if (is_null(Mail::$mailConfig)) Mail::$mailConfig = Api\Config::read('mail'); |
86 | 85 | |
87 | - $this->mailPreferences =& $this->mail_bo->mailPreferences; |
|
86 | + $this->mailPreferences = & $this->mail_bo->mailPreferences; |
|
88 | 87 | } |
89 | 88 | |
90 | 89 | /** |
@@ -94,15 +93,15 @@ discard block |
||
94 | 93 | */ |
95 | 94 | function changeProfile($_icServerID) |
96 | 95 | { |
97 | - if ($this->mail_bo->profileID!=$_icServerID) |
|
96 | + if ($this->mail_bo->profileID != $_icServerID) |
|
98 | 97 | { |
99 | 98 | if (Mail::$debug) error_log(__METHOD__.__LINE__.'->'.$this->mail_bo->profileID.'<->'.$_icServerID); |
100 | - $this->mail_bo = Mail::getInstance(false,$_icServerID); |
|
99 | + $this->mail_bo = Mail::getInstance(false, $_icServerID); |
|
101 | 100 | if (Mail::$debug) error_log(__METHOD__.__LINE__.' Fetched IC Server:'.$this->mail_bo->profileID.':'.function_backtrace()); |
102 | 101 | // no icServer Object: something failed big time |
103 | 102 | if (!isset($this->mail_bo->icServer)) exit; // ToDo: Exception or the dialog for setting up a server config |
104 | 103 | $this->mail_bo->openConnection($this->mail_bo->profileID); |
105 | - $this->mailPreferences =& $this->mail_bo->mailPreferences; |
|
104 | + $this->mailPreferences = & $this->mail_bo->mailPreferences; |
|
106 | 105 | } |
107 | 106 | } |
108 | 107 | |
@@ -140,7 +139,7 @@ discard block |
||
140 | 139 | 'onExecute' => 'javaScript:app.mail.saveAsDraft', |
141 | 140 | 'hint' => 'Save as Draft and Print' |
142 | 141 | ), |
143 | - 'save2vfs' => array ( |
|
142 | + 'save2vfs' => array( |
|
144 | 143 | 'caption' => 'Save to filemanager', |
145 | 144 | 'icon' => 'filesave', |
146 | 145 | 'group' => $group, |
@@ -179,7 +178,7 @@ discard block |
||
179 | 178 | 'checkbox' => true, |
180 | 179 | 'hint' => 'check to save as tracker entry on send', |
181 | 180 | 'onExecute' => 'javaScript:app.mail.compose_setToggle', |
182 | - 'mail_import' => Api\Hooks::single(array('location' => 'mail_import'),'tracker'), |
|
181 | + 'mail_import' => Api\Hooks::single(array('location' => 'mail_import'), 'tracker'), |
|
183 | 182 | ), |
184 | 183 | 'to_calendar' => array( |
185 | 184 | 'caption' => 'Calendar', |
@@ -219,7 +218,7 @@ discard block |
||
219 | 218 | if ($acc_smime['acc_smime_password']) |
220 | 219 | { |
221 | 220 | $actions = array_merge($actions, array( |
222 | - 'smime_sign' => array ( |
|
221 | + 'smime_sign' => array( |
|
223 | 222 | 'caption' => 'SMIME Sign', |
224 | 223 | 'icon' => 'smime_sign', |
225 | 224 | 'group' => ++$group, |
@@ -227,7 +226,7 @@ discard block |
||
227 | 226 | 'checkbox' => true, |
228 | 227 | 'hint' => 'Sign your message with smime certificate' |
229 | 228 | ), |
230 | - 'smime_encrypt' => array ( |
|
229 | + 'smime_encrypt' => array( |
|
231 | 230 | 'caption' => 'SMIME Encryption', |
232 | 231 | 'icon' => 'smime_encrypt', |
233 | 232 | 'group' => $group, |
@@ -265,7 +264,7 @@ discard block |
||
265 | 264 | { |
266 | 265 | foreach (array_keys($actions) as $key) |
267 | 266 | { |
268 | - if (!in_array($key, array('send','button[saveAsDraft]','uploadForCompose' ))) { |
|
267 | + if (!in_array($key, array('send', 'button[saveAsDraft]', 'uploadForCompose'))) { |
|
269 | 268 | $actions[$key]['toolbarDefault'] = false; |
270 | 269 | } |
271 | 270 | } |
@@ -290,7 +289,7 @@ discard block |
||
290 | 289 | * @var boolean $suppressSigOnTop =false |
291 | 290 | * @var boolean $isReply =false |
292 | 291 | */ |
293 | - function compose(array $_content=null,$msg=null, $_focusElement='to',$suppressSigOnTop=false, $isReply=false) |
|
292 | + function compose(array $_content = null, $msg = null, $_focusElement = 'to', $suppressSigOnTop = false, $isReply = false) |
|
294 | 293 | { |
295 | 294 | if ($msg) Framework::message($msg); |
296 | 295 | |
@@ -311,8 +310,8 @@ discard block |
||
311 | 310 | //lang('compose'),lang('from') // needed to be found by translationtools |
312 | 311 | //error_log(__METHOD__.__LINE__.array2string($_REQUEST).function_backtrace()); |
313 | 312 | //error_log(__METHOD__.__LINE__.array2string($_content).function_backtrace()); |
314 | - $_contentHasSigID = $_content?array_key_exists('mailidentity',(array)$_content):false; |
|
315 | - $_contentHasMimeType = $_content? array_key_exists('mimeType',(array)$_content):false; |
|
313 | + $_contentHasSigID = $_content ?array_key_exists('mailidentity', (array)$_content) : false; |
|
314 | + $_contentHasMimeType = $_content ? array_key_exists('mimeType', (array)$_content) : false; |
|
316 | 315 | |
317 | 316 | // fetch appendix data which is an assistance input value consisiting of json data |
318 | 317 | if ($_content['appendix_data']) |
@@ -342,7 +341,7 @@ discard block |
||
342 | 341 | |
343 | 342 | // Process different places we can use as a start for composing an email |
344 | 343 | $actionToProcess = 'compose'; |
345 | - if($_GET['from'] && $replyID) |
|
344 | + if ($_GET['from'] && $replyID) |
|
346 | 345 | { |
347 | 346 | $_content = array_merge((array)$_content, $this->getComposeFrom( |
348 | 347 | // Parameters needed for fetching appropriate data |
@@ -370,10 +369,10 @@ discard block |
||
370 | 369 | } |
371 | 370 | |
372 | 371 | $composeCache = array(); |
373 | - if (isset($_content['composeID'])&&!empty($_content['composeID'])) |
|
372 | + if (isset($_content['composeID']) && !empty($_content['composeID'])) |
|
374 | 373 | { |
375 | 374 | $isFirstLoad = false; |
376 | - $composeCache = Api\Cache::getCache(Api\Cache::SESSION,'mail','composeCache'.trim($GLOBALS['egw_info']['user']['account_id']).'_'.$_content['composeID'],$callback=null,$callback_params=array(),$expiration=60*60*2); |
|
375 | + $composeCache = Api\Cache::getCache(Api\Cache::SESSION, 'mail', 'composeCache'.trim($GLOBALS['egw_info']['user']['account_id']).'_'.$_content['composeID'], $callback = null, $callback_params = array(), $expiration = 60 * 60 * 2); |
|
377 | 376 | $this->composeID = $_content['composeID']; |
378 | 377 | //error_log(__METHOD__.__LINE__.array2string($composeCache)); |
379 | 378 | } |
@@ -383,7 +382,7 @@ discard block |
||
383 | 382 | // respect that composeasnew may not want that, as we assume there |
384 | 383 | // is some style already set and our initalStyle always adds a span with |
385 | 384 | // and we want to avoid that |
386 | - $isFirstLoad = !($actionToProcess=='composeasnew');//true; |
|
385 | + $isFirstLoad = !($actionToProcess == 'composeasnew'); //true; |
|
387 | 386 | $this->composeID = $_content['composeID'] = $this->generateComposeID(); |
388 | 387 | if (!is_array($_content)) |
389 | 388 | { |
@@ -418,7 +417,7 @@ discard block |
||
418 | 417 | if (!isset($upload['file'])) $upload['file'] = $upload['tmp_name']; |
419 | 418 | try |
420 | 419 | { |
421 | - $upload['file'] = $upload['tmp_name'] = Mail::checkFileBasics($upload,$this->composeID,false); |
|
420 | + $upload['file'] = $upload['tmp_name'] = Mail::checkFileBasics($upload, $this->composeID, false); |
|
422 | 421 | } |
423 | 422 | catch (Api\Exception\WrongUserinput $e) |
424 | 423 | { |
@@ -444,12 +443,12 @@ discard block |
||
444 | 443 | unset($_content['attachments']['delete']); |
445 | 444 | $attachments = $_content['attachments']; |
446 | 445 | unset($_content['attachments']); |
447 | - foreach($attachments as $i => $att) |
|
446 | + foreach ($attachments as $i => $att) |
|
448 | 447 | { |
449 | - $remove=false; |
|
450 | - foreach(array_keys($toDelete) as $k) |
|
448 | + $remove = false; |
|
449 | + foreach (array_keys($toDelete) as $k) |
|
451 | 450 | { |
452 | - if ($att['tmp_name']==$k) $remove=true; |
|
451 | + if ($att['tmp_name'] == $k) $remove = true; |
|
453 | 452 | } |
454 | 453 | if (!$remove) $_content['attachments'][] = $att; |
455 | 454 | } |
@@ -457,7 +456,7 @@ discard block |
||
457 | 456 | // someone clicked something like send, or saveAsDraft |
458 | 457 | // make sure, we are connected to the correct server for sending and storing the send message |
459 | 458 | $activeProfile = $composeProfile = $this->mail_bo->profileID; // active profile may not be the profile uised in/for compose |
460 | - $activeFolderCache = Api\Cache::getCache(Api\Cache::INSTANCE,'email','activeMailbox'.trim($GLOBALS['egw_info']['user']['account_id']),$callback=null,$callback_params=array(),$expiration=60*60*10); |
|
459 | + $activeFolderCache = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'activeMailbox'.trim($GLOBALS['egw_info']['user']['account_id']), $callback = null, $callback_params = array(), $expiration = 60 * 60 * 10); |
|
461 | 460 | if (!empty($activeFolderCache[$this->mail_bo->profileID])) |
462 | 461 | { |
463 | 462 | //error_log(__METHOD__.__LINE__.' CurrentFolder:'.$activeFolderCache[$this->mail_bo->profileID]); |
@@ -465,7 +464,7 @@ discard block |
||
465 | 464 | } |
466 | 465 | //error_log(__METHOD__.__LINE__.array2string($_content)); |
467 | 466 | if (!empty($_content['serverID']) && $_content['serverID'] != $this->mail_bo->profileID && |
468 | - ($_content['composeToolbar'] === 'send' || $_content['button']['saveAsDraft']||$_content['button']['saveAsDraftAndPrint']) |
|
467 | + ($_content['composeToolbar'] === 'send' || $_content['button']['saveAsDraft'] || $_content['button']['saveAsDraftAndPrint']) |
|
469 | 468 | ) |
470 | 469 | { |
471 | 470 | $this->changeProfile($_content['serverID']); |
@@ -479,19 +478,19 @@ discard block |
||
479 | 478 | { |
480 | 479 | $buttonClicked = $suppressSigOnTop = true; |
481 | 480 | $sendOK = true; |
482 | - $_content['body'] = ($_content['body'] ? $_content['body'] : $_content['mail_'.($_content['mimeType'] == 'html'?'html':'plain').'text']); |
|
481 | + $_content['body'] = ($_content['body'] ? $_content['body'] : $_content['mail_'.($_content['mimeType'] == 'html' ? 'html' : 'plain').'text']); |
|
483 | 482 | /* |
484 | 483 | perform some simple checks, before trying to send on: |
485 | 484 | $_content['to'];$_content['cc'];$_content['bcc']; |
486 | 485 | trim($_content['subject']); |
487 | 486 | trim(strip_tags(str_replace(' ','',$_content['body']))); |
488 | 487 | */ |
489 | - if (strlen(trim(strip_tags(str_replace(' ','',$_content['body']))))==0 && count($_content['attachments'])==0) |
|
488 | + if (strlen(trim(strip_tags(str_replace(' ', '', $_content['body'])))) == 0 && count($_content['attachments']) == 0) |
|
490 | 489 | { |
491 | 490 | $sendOK = false; |
492 | 491 | $_content['msg'] = $message = lang("no message body supplied"); |
493 | 492 | } |
494 | - if ($sendOK && strlen(trim($_content['subject']))==0) |
|
493 | + if ($sendOK && strlen(trim($_content['subject'])) == 0) |
|
495 | 494 | { |
496 | 495 | $sendOK = false; |
497 | 496 | $_content['msg'] = $message = lang("no subject supplied"); |
@@ -506,15 +505,15 @@ discard block |
||
506 | 505 | try |
507 | 506 | { |
508 | 507 | $success = $this->send($_content); |
509 | - if ($success==false) |
|
508 | + if ($success == false) |
|
510 | 509 | { |
511 | - $sendOK=false; |
|
510 | + $sendOK = false; |
|
512 | 511 | $message = $this->errorInfo; |
513 | 512 | } |
514 | 513 | if (!empty($_content['mailidentity']) && $_content['mailidentity'] != $sigPref[$this->mail_bo->profileID]) |
515 | 514 | { |
516 | - $sigPref[$this->mail_bo->profileID]=$_content['mailidentity']; |
|
517 | - $GLOBALS['egw']->preferences->add('mail','LastSignatureIDUsed',$sigPref,'user'); |
|
515 | + $sigPref[$this->mail_bo->profileID] = $_content['mailidentity']; |
|
516 | + $GLOBALS['egw']->preferences->add('mail', 'LastSignatureIDUsed', $sigPref, 'user'); |
|
518 | 517 | // save prefs |
519 | 518 | $GLOBALS['egw']->preferences->save_repository(true); |
520 | 519 | } |
@@ -538,23 +537,23 @@ discard block |
||
538 | 537 | if (isset($_content['mode']) && !empty($_content['mode'])) |
539 | 538 | { |
540 | 539 | $mode = $_content['mode']; |
541 | - if ($_content['mode']=='forward' && !empty($_content['processedmail_id'])) |
|
540 | + if ($_content['mode'] == 'forward' && !empty($_content['processedmail_id'])) |
|
542 | 541 | { |
543 | - $_content['processedmail_id'] = explode(',',$_content['processedmail_id']); |
|
542 | + $_content['processedmail_id'] = explode(',', $_content['processedmail_id']); |
|
544 | 543 | foreach ($_content['processedmail_id'] as $k =>$rowid) |
545 | 544 | { |
546 | 545 | $fhA = mail_ui::splitRowID($rowid); |
547 | 546 | //$this->sessionData['uid'][] = $fhA['msgUID']; |
548 | 547 | //$this->sessionData['forwardedUID'][] = $fhA['msgUID']; |
549 | - $idsForRefresh[] = mail_ui::generateRowID($fhA['profileID'], $fhA['folder'], $fhA['msgUID'], $_prependApp=false); |
|
548 | + $idsForRefresh[] = mail_ui::generateRowID($fhA['profileID'], $fhA['folder'], $fhA['msgUID'], $_prependApp = false); |
|
550 | 549 | if (!empty($fhA['folder'])) $workingFolder = $fhA['folder']; |
551 | 550 | } |
552 | 551 | } |
553 | - if ($_content['mode']=='reply' && !empty($_content['processedmail_id'])) |
|
552 | + if ($_content['mode'] == 'reply' && !empty($_content['processedmail_id'])) |
|
554 | 553 | { |
555 | 554 | $rhA = mail_ui::splitRowID($_content['processedmail_id']); |
556 | 555 | //$this->sessionData['uid'] = $rhA['msgUID']; |
557 | - $idsForRefresh[] = mail_ui::generateRowID($rhA['profileID'], $rhA['folder'], $rhA['msgUID'], $_prependApp=false); |
|
556 | + $idsForRefresh[] = mail_ui::generateRowID($rhA['profileID'], $rhA['folder'], $rhA['msgUID'], $_prependApp = false); |
|
558 | 557 | $workingFolder = $rhA['folder']; |
559 | 558 | } |
560 | 559 | } |
@@ -562,30 +561,30 @@ discard block |
||
562 | 561 | if (empty($idsForRefresh) && !empty($_content['processedmail_id'])) |
563 | 562 | { |
564 | 563 | $rhA = mail_ui::splitRowID($_content['processedmail_id']); |
565 | - $idsForRefresh[] = mail_ui::generateRowID($rhA['profileID'], $rhA['folder'], $rhA['msgUID'], $_prependApp=false); |
|
564 | + $idsForRefresh[] = mail_ui::generateRowID($rhA['profileID'], $rhA['folder'], $rhA['msgUID'], $_prependApp = false); |
|
566 | 565 | } |
567 | 566 | $response = Api\Json\Response::get(); |
568 | 567 | if ($activeProfile != $composeProfile) |
569 | 568 | { |
570 | 569 | // we need a message only, when account ids (composeProfile vs. activeProfile) differ |
571 | - $response->call('opener.egw_message',lang('Message send successfully.')); |
|
570 | + $response->call('opener.egw_message', lang('Message send successfully.')); |
|
572 | 571 | } |
573 | - elseif ($activeProfile == $composeProfile && ($workingFolder==$activeFolder['mailbox'] && $mode != 'compose') || ($this->mail_bo->isSentFolder($workingFolder)||$this->mail_bo->isDraftFolder($workingFolder))) |
|
572 | + elseif ($activeProfile == $composeProfile && ($workingFolder == $activeFolder['mailbox'] && $mode != 'compose') || ($this->mail_bo->isSentFolder($workingFolder) || $this->mail_bo->isDraftFolder($workingFolder))) |
|
574 | 573 | { |
575 | - if ($this->mail_bo->isSentFolder($workingFolder)||$this->mail_bo->isDraftFolder($workingFolder)) |
|
574 | + if ($this->mail_bo->isSentFolder($workingFolder) || $this->mail_bo->isDraftFolder($workingFolder)) |
|
576 | 575 | { |
577 | 576 | // we may need a refresh when on sent folder or in drafts, as drafted messages will/should be deleted after succeeded send action |
578 | - $response->call('opener.egw_refresh',lang('Message send successfully.'),'mail'); |
|
577 | + $response->call('opener.egw_refresh', lang('Message send successfully.'), 'mail'); |
|
579 | 578 | } |
580 | 579 | else |
581 | 580 | { |
582 | 581 | //error_log(__METHOD__.__LINE__.array2string($idsForRefresh)); |
583 | - $response->call('opener.egw_refresh',lang('Message send successfully.'),'mail',$idsForRefresh,'update'); |
|
582 | + $response->call('opener.egw_refresh', lang('Message send successfully.'), 'mail', $idsForRefresh, 'update'); |
|
584 | 583 | } |
585 | 584 | } |
586 | 585 | else |
587 | 586 | { |
588 | - $response->call('opener.egw_message',lang('Message send successfully.')); |
|
587 | + $response->call('opener.egw_message', lang('Message send successfully.')); |
|
589 | 588 | } |
590 | 589 | //egw_framework::refresh_opener(lang('Message send successfully.'),'mail'); |
591 | 590 | Framework::window_close(); |
@@ -593,60 +592,60 @@ discard block |
||
593 | 592 | if ($sendOK == false) |
594 | 593 | { |
595 | 594 | $response = Api\Json\Response::get(); |
596 | - Framework::message(lang('Message send failed: %1',$message),'error');// maybe error is more appropriate |
|
595 | + Framework::message(lang('Message send failed: %1', $message), 'error'); // maybe error is more appropriate |
|
597 | 596 | $response->call('app.mail.clearIntevals'); |
598 | 597 | } |
599 | 598 | } |
600 | 599 | |
601 | 600 | if ($activeProfile != $composeProfile) $this->changeProfile($activeProfile); |
602 | 601 | $insertSigOnTop = false; |
603 | - $content = (is_array($_content)?$_content:array()); |
|
602 | + $content = (is_array($_content) ? $_content : array()); |
|
604 | 603 | if ($_contentHasMimeType) |
605 | 604 | { |
606 | 605 | // mimeType is now a checkbox; convert it here to match expectations |
607 | 606 | // ToDo: match Code to meet checkbox value |
608 | - if ($content['mimeType']==1) |
|
607 | + if ($content['mimeType'] == 1) |
|
609 | 608 | { |
610 | - $_content['mimeType'] = $content['mimeType']='html'; |
|
609 | + $_content['mimeType'] = $content['mimeType'] = 'html'; |
|
611 | 610 | } |
612 | 611 | else |
613 | 612 | { |
614 | - $_content['mimeType'] = $content['mimeType']='plain'; |
|
613 | + $_content['mimeType'] = $content['mimeType'] = 'plain'; |
|
615 | 614 | } |
616 | 615 | |
617 | 616 | } |
618 | 617 | // user might have switched desired mimetype, so we should convert |
619 | - if ($content['is_html'] && $content['mimeType']=='plain') |
|
618 | + if ($content['is_html'] && $content['mimeType'] == 'plain') |
|
620 | 619 | { |
621 | 620 | //error_log(__METHOD__.__LINE__.$content['mail_htmltext']); |
622 | 621 | $suppressSigOnTop = true; |
623 | - if (stripos($content['mail_htmltext'],'<pre>')!==false) |
|
622 | + if (stripos($content['mail_htmltext'], '<pre>') !== false) |
|
624 | 623 | { |
625 | 624 | $contentArr = Api\Mail\Html::splithtmlByPRE($content['mail_htmltext']); |
626 | 625 | if (is_array($contentArr)) |
627 | 626 | { |
628 | 627 | foreach ($contentArr as $k =>&$elem) |
629 | 628 | { |
630 | - if (stripos($elem,'<pre>')!==false) $elem = str_replace(array("\r\n","\n","\r"),array("<br>","<br>","<br>"),$elem); |
|
629 | + if (stripos($elem, '<pre>') !== false) $elem = str_replace(array("\r\n", "\n", "\r"), array("<br>", "<br>", "<br>"), $elem); |
|
631 | 630 | } |
632 | - $content['mail_htmltext'] = implode('',$contentArr); |
|
631 | + $content['mail_htmltext'] = implode('', $contentArr); |
|
633 | 632 | } |
634 | 633 | } |
635 | 634 | $content['mail_htmltext'] = $this->_getCleanHTML($content['mail_htmltext']); |
636 | - $content['mail_htmltext'] = Api\Mail\Html::convertHTMLToText($content['mail_htmltext'],$charset=false,false,true); |
|
635 | + $content['mail_htmltext'] = Api\Mail\Html::convertHTMLToText($content['mail_htmltext'], $charset = false, false, true); |
|
637 | 636 | |
638 | 637 | $content['body'] = $content['mail_htmltext']; |
639 | 638 | unset($content['mail_htmltext']); |
640 | 639 | $content['is_html'] = false; |
641 | 640 | $content['is_plain'] = true; |
642 | 641 | } |
643 | - if ($content['is_plain'] && $content['mimeType']=='html') |
|
642 | + if ($content['is_plain'] && $content['mimeType'] == 'html') |
|
644 | 643 | { |
645 | 644 | // the possible font span should only be applied on first load or on switch plain->html |
646 | 645 | $isFirstLoad = "switchedplaintohtml"; |
647 | 646 | //error_log(__METHOD__.__LINE__.$content['mail_plaintext']); |
648 | 647 | $suppressSigOnTop = true; |
649 | - $content['mail_plaintext'] = str_replace(array("\r\n","\n","\r"),array("<br>","<br>","<br>"),$content['mail_plaintext']); |
|
648 | + $content['mail_plaintext'] = str_replace(array("\r\n", "\n", "\r"), array("<br>", "<br>", "<br>"), $content['mail_plaintext']); |
|
650 | 649 | //$this->replaceEmailAdresses($content['mail_plaintext']); |
651 | 650 | $content['body'] = $content['mail_plaintext']; |
652 | 651 | unset($content['mail_plaintext']); |
@@ -654,7 +653,7 @@ discard block |
||
654 | 653 | $content['is_plain'] = false; |
655 | 654 | } |
656 | 655 | |
657 | - $content['body'] = ($content['body'] ? $content['body'] : $content['mail_'.($content['mimeType'] == 'html'?'html':'plain').'text']); |
|
656 | + $content['body'] = ($content['body'] ? $content['body'] : $content['mail_'.($content['mimeType'] == 'html' ? 'html' : 'plain').'text']); |
|
658 | 657 | unset($_content['body']); |
659 | 658 | unset($_content['mail_htmltext']); |
660 | 659 | unset($_content['mail_plaintext']); |
@@ -666,7 +665,7 @@ discard block |
||
666 | 665 | |
667 | 666 | // form was submitted either by clicking a button or by changing one of the triggering selectboxes |
668 | 667 | // identity and signatureid; this might trigger that the signature in mail body may have to be altered |
669 | - if ( !empty($content['body']) && |
|
668 | + if (!empty($content['body']) && |
|
670 | 669 | (!empty($composeCache['mailaccount']) && !empty($_content['mailaccount']) && $_content['mailaccount'] != $composeCache['mailaccount']) || |
671 | 670 | (!empty($composeCache['mailidentity']) && !empty($_content['mailidentity']) && $_content['mailidentity'] != $composeCache['mailidentity']) |
672 | 671 | ) |
@@ -677,7 +676,7 @@ discard block |
||
677 | 676 | { |
678 | 677 | $acc = Mail\Account::read($_content['mailaccount']); |
679 | 678 | //error_log(__METHOD__.__LINE__.array2string($acc)); |
680 | - $Identities = Mail\Account::read_identity($acc['ident_id'],true); |
|
679 | + $Identities = Mail\Account::read_identity($acc['ident_id'], true); |
|
681 | 680 | //error_log(__METHOD__.__LINE__.array2string($Identities)); |
682 | 681 | if ($Identities['ident_id']) |
683 | 682 | { |
@@ -690,41 +689,41 @@ discard block |
||
690 | 689 | } |
691 | 690 | } |
692 | 691 | $_oldSig = $composeCache['mailidentity']; |
693 | - $_signatureid = ($newSig?$newSig:$_content['mailidentity']); |
|
692 | + $_signatureid = ($newSig ? $newSig : $_content['mailidentity']); |
|
694 | 693 | |
695 | 694 | if ($_oldSig != $_signatureid) |
696 | 695 | { |
697 | - if($this->_debug) error_log(__METHOD__.__LINE__.' old,new ->'.$_oldSig.','.$_signatureid.'#'.$content['body']); |
|
696 | + if ($this->_debug) error_log(__METHOD__.__LINE__.' old,new ->'.$_oldSig.','.$_signatureid.'#'.$content['body']); |
|
698 | 697 | // prepare signatures, the selected sig may be used on top of the body |
699 | 698 | try |
700 | 699 | { |
701 | - $oldSignature = Mail\Account::read_identity($_oldSig,true); |
|
700 | + $oldSignature = Mail\Account::read_identity($_oldSig, true); |
|
702 | 701 | //error_log(__METHOD__.__LINE__.'Old:'.array2string($oldSignature).'#'); |
703 | 702 | $oldSigText = $oldSignature['ident_signature']; |
704 | 703 | } |
705 | 704 | catch (Exception $e) |
706 | 705 | { |
707 | - $oldSignature=array(); |
|
706 | + $oldSignature = array(); |
|
708 | 707 | $oldSigText = null; |
709 | 708 | } |
710 | 709 | try |
711 | 710 | { |
712 | - $signature = Mail\Account::read_identity($_signatureid,true); |
|
711 | + $signature = Mail\Account::read_identity($_signatureid, true); |
|
713 | 712 | //error_log(__METHOD__.__LINE__.'New:'.array2string($signature).'#'); |
714 | 713 | $sigText = $signature['ident_signature']; |
715 | 714 | } |
716 | 715 | catch (Exception $e) |
717 | 716 | { |
718 | - $signature=array(); |
|
717 | + $signature = array(); |
|
719 | 718 | $sigText = null; |
720 | 719 | } |
721 | 720 | //error_log(__METHOD__.'Old:'.$oldSigText.'#'); |
722 | 721 | //error_log(__METHOD__.'New:'.$sigText.'#'); |
723 | 722 | if ($_currentMode == 'plain') |
724 | 723 | { |
725 | - $oldSigText = $this->convertHTMLToText($oldSigText,true,true); |
|
726 | - $sigText = $this->convertHTMLToText($sigText,true,true); |
|
727 | - if($this->_debug) error_log(__METHOD__." Old signature:".$oldSigText); |
|
724 | + $oldSigText = $this->convertHTMLToText($oldSigText, true, true); |
|
725 | + $sigText = $this->convertHTMLToText($sigText, true, true); |
|
726 | + if ($this->_debug) error_log(__METHOD__." Old signature:".$oldSigText); |
|
728 | 727 | } |
729 | 728 | |
730 | 729 | //$oldSigText = Mail::merge($oldSigText,array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id'))); |
@@ -738,9 +737,9 @@ discard block |
||
738 | 737 | //error_log(__METHOD__.'Old(clean):'.$oldSigTextCleaned.'#'); |
739 | 738 | if ($_currentMode == 'html') |
740 | 739 | { |
741 | - $content['body'] = str_replace("\n",'\n',$content['body']); // dont know why, but \n screws up preg_replace |
|
740 | + $content['body'] = str_replace("\n", '\n', $content['body']); // dont know why, but \n screws up preg_replace |
|
742 | 741 | $styles = Mail::getStyles(array(array('body'=>$content['body']))); |
743 | - if (stripos($content['body'],'style')!==false) Api\Mail\Html::replaceTagsCompletley($content['body'],'style',$endtag='',true); // clean out empty or pagewide style definitions / left over tags |
|
742 | + if (stripos($content['body'], 'style') !== false) Api\Mail\Html::replaceTagsCompletley($content['body'], 'style', $endtag = '', true); // clean out empty or pagewide style definitions / left over tags |
|
744 | 743 | } |
745 | 744 | $content['body'] = str_replace(array("\r", "\t", "<br />\n", ": "), array("", "", "<br />", ":"), |
746 | 745 | $_currentMode == 'html' ? Api\Html::purify($content['body'], Mail::$htmLawed_config, array(), true) : $content['body']); |
@@ -748,9 +747,9 @@ discard block |
||
748 | 747 | if ($_currentMode == 'html') |
749 | 748 | { |
750 | 749 | $replaced = null; |
751 | - $content['body'] = preg_replace($reg='|'.preg_quote('<!-- HTMLSIGBEGIN -->','|').'.*'.preg_quote('<!-- HTMLSIGEND -->','|').'|u', |
|
752 | - $rep='<!-- HTMLSIGBEGIN -->'.$sigText.'<!-- HTMLSIGEND -->', $in=$content['body'], -1, $replaced); |
|
753 | - $content['body'] = str_replace(array('\n',"\xe2\x80\x93","\xe2\x80\x94","\xe2\x82\xac"),array("\n",'–','—','€'),$content['body']); |
|
750 | + $content['body'] = preg_replace($reg = '|'.preg_quote('<!-- HTMLSIGBEGIN -->', '|').'.*'.preg_quote('<!-- HTMLSIGEND -->', '|').'|u', |
|
751 | + $rep = '<!-- HTMLSIGBEGIN -->'.$sigText.'<!-- HTMLSIGEND -->', $in = $content['body'], -1, $replaced); |
|
752 | + $content['body'] = str_replace(array('\n', "\xe2\x80\x93", "\xe2\x80\x94", "\xe2\x82\xac"), array("\n", '–', '—', '€'), $content['body']); |
|
754 | 753 | //error_log(__METHOD__."() preg_replace('$reg', '$rep', '$in', -1)='".$content['body']."', replaced=$replaced"); |
755 | 754 | unset($rep, $in); |
756 | 755 | if ($replaced) |
@@ -761,32 +760,32 @@ discard block |
||
761 | 760 | else |
762 | 761 | { |
763 | 762 | // try the old way |
764 | - $found = (strlen(trim($oldSigTextCleaned))>0?strpos($content['body'],trim($oldSigTextCleaned)):false); |
|
763 | + $found = (strlen(trim($oldSigTextCleaned)) > 0 ?strpos($content['body'], trim($oldSigTextCleaned)) : false); |
|
765 | 764 | } |
766 | 765 | } |
767 | 766 | else |
768 | 767 | { |
769 | - $found = (strlen(trim($oldSigTextCleaned))>0?strpos($content['body'],trim($oldSigTextCleaned)):false); |
|
768 | + $found = (strlen(trim($oldSigTextCleaned)) > 0 ?strpos($content['body'], trim($oldSigTextCleaned)) : false); |
|
770 | 769 | } |
771 | 770 | |
772 | - if ($found !== false && $_oldSig != -2 && !(empty($oldSigTextCleaned) || trim($this->convertHTMLToText($oldSigTextCleaned,true,true)) =='')) |
|
771 | + if ($found !== false && $_oldSig != -2 && !(empty($oldSigTextCleaned) || trim($this->convertHTMLToText($oldSigTextCleaned, true, true)) == '')) |
|
773 | 772 | { |
774 | 773 | //error_log(__METHOD__.'Old Content:'.$content['body'].'#'); |
775 | - $_oldSigText = preg_quote($oldSigTextCleaned,'~'); |
|
774 | + $_oldSigText = preg_quote($oldSigTextCleaned, '~'); |
|
776 | 775 | //error_log(__METHOD__.'Old(masked):'.$_oldSigText.'#'); |
777 | - $content['body'] = preg_replace('~'.$_oldSigText.'~mi',$sigText,$content['body'],1); |
|
776 | + $content['body'] = preg_replace('~'.$_oldSigText.'~mi', $sigText, $content['body'], 1); |
|
778 | 777 | //error_log(__METHOD__.'new Content:'.$content['body'].'#'); |
779 | 778 | } |
780 | 779 | |
781 | - if ($_oldSig == -2 && (empty($oldSigTextCleaned) || trim($this->convertHTMLToText($oldSigTextCleaned,true,true)) =='')) |
|
780 | + if ($_oldSig == -2 && (empty($oldSigTextCleaned) || trim($this->convertHTMLToText($oldSigTextCleaned, true, true)) == '')) |
|
782 | 781 | { |
783 | 782 | // if there is no sig selected, there is no way to replace a signature |
784 | 783 | } |
785 | 784 | |
786 | 785 | if ($found === false) |
787 | 786 | { |
788 | - if($this->_debug) error_log(__METHOD__." Old Signature failed to match:".$oldSigTextCleaned); |
|
789 | - if($this->_debug) error_log(__METHOD__." Compare content:".$content['body']); |
|
787 | + if ($this->_debug) error_log(__METHOD__." Old Signature failed to match:".$oldSigTextCleaned); |
|
788 | + if ($this->_debug) error_log(__METHOD__." Compare content:".$content['body']); |
|
790 | 789 | } |
791 | 790 | else |
792 | 791 | { |
@@ -824,7 +823,7 @@ discard block |
||
824 | 823 | if ($isFirstLoad) |
825 | 824 | { |
826 | 825 | $alwaysAttachVCardAtCompose = false; // we use this to eliminate double attachments, if users VCard is already present/attached |
827 | - if ( isset($GLOBALS['egw_info']['apps']['stylite']) && (isset($this->mailPreferences['attachVCardAtCompose']) && |
|
826 | + if (isset($GLOBALS['egw_info']['apps']['stylite']) && (isset($this->mailPreferences['attachVCardAtCompose']) && |
|
828 | 827 | $this->mailPreferences['attachVCardAtCompose'])) |
829 | 828 | { |
830 | 829 | $alwaysAttachVCardAtCompose = true; |
@@ -833,7 +832,7 @@ discard block |
||
833 | 832 | $f = $_REQUEST['preset']['file']; |
834 | 833 | $_REQUEST['preset']['file'] = array($f); |
835 | 834 | } |
836 | - $_REQUEST['preset']['file'][] = "vfs://default/apps/addressbook/".$GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id')."/.entry"; |
|
835 | + $_REQUEST['preset']['file'][] = "vfs://default/apps/addressbook/".$GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'], 'person_id')."/.entry"; |
|
837 | 836 | } |
838 | 837 | // an app passed the request for fetching and mailing an entry |
839 | 838 | if (isset($_REQUEST['app']) && isset($_REQUEST['method']) && isset($_REQUEST['id'])) |
@@ -842,33 +841,33 @@ discard block |
||
842 | 841 | $mt = $_REQUEST['method']; |
843 | 842 | $id = $_REQUEST['id']; |
844 | 843 | // passed method MUST be registered |
845 | - $method = Link::get_registry($app,$mt); |
|
844 | + $method = Link::get_registry($app, $mt); |
|
846 | 845 | //error_log(__METHOD__.__LINE__.array2string($method)); |
847 | 846 | if ($method) |
848 | 847 | { |
849 | - $res = ExecMethod($method,array($id,'html')); |
|
848 | + $res = ExecMethod($method, array($id, 'html')); |
|
850 | 849 | //error_log(__METHOD__.__LINE__.array2string($res)); |
851 | 850 | if (!empty($res)) |
852 | 851 | { |
853 | 852 | $insertSigOnTop = 'below'; |
854 | 853 | if (isset($res['attachments']) && is_array($res['attachments'])) |
855 | 854 | { |
856 | - foreach($res['attachments'] as $f) |
|
855 | + foreach ($res['attachments'] as $f) |
|
857 | 856 | { |
858 | 857 | $_REQUEST['preset']['file'][] = $f; |
859 | 858 | } |
860 | 859 | } |
861 | 860 | $content['subject'] = lang($app).' #'.$res['id'].': '; |
862 | - foreach(array('subject','body','mimetype') as $name) { |
|
861 | + foreach (array('subject', 'body', 'mimetype') as $name) { |
|
863 | 862 | $sName = $name; |
864 | - if ($name=='mimetype'&&$res[$name]) |
|
863 | + if ($name == 'mimetype' && $res[$name]) |
|
865 | 864 | { |
866 | 865 | $sName = 'mimeType'; |
867 | 866 | $content[$sName] = $res[$name]; |
868 | 867 | } |
869 | 868 | else |
870 | 869 | { |
871 | - if ($res[$name]) $content[$sName] .= (strlen($content[$sName])>0 ? ' ':'') .$res[$name]; |
|
870 | + if ($res[$name]) $content[$sName] .= (strlen($content[$sName]) > 0 ? ' ' : '').$res[$name]; |
|
872 | 871 | } |
873 | 872 | } |
874 | 873 | } |
@@ -877,46 +876,46 @@ discard block |
||
877 | 876 | // handle preset info/values |
878 | 877 | if (is_array($_REQUEST['preset'])) |
879 | 878 | { |
880 | - $alreadyProcessed=array(); |
|
879 | + $alreadyProcessed = array(); |
|
881 | 880 | //_debug_array($_REQUEST); |
882 | 881 | if ($_REQUEST['preset']['mailto']) { |
883 | 882 | // handle mailto strings such as |
884 | 883 | // mailto:larry,dan?cc=mike&bcc=sue&subject=test&body=type+your&body=message+here |
885 | 884 | // the above string may be htmlentyty encoded, then multiple body tags are supported |
886 | 885 | // first, strip the mailto: string out of the mailto URL |
887 | - $tmp_send_to = (stripos($_REQUEST['preset']['mailto'],'mailto')===false?$_REQUEST['preset']['mailto']:trim(substr(html_entity_decode($_REQUEST['preset']['mailto']),7))); |
|
886 | + $tmp_send_to = (stripos($_REQUEST['preset']['mailto'], 'mailto') === false ? $_REQUEST['preset']['mailto'] : trim(substr(html_entity_decode($_REQUEST['preset']['mailto']), 7))); |
|
888 | 887 | // check if there is more than the to address |
889 | - $mailtoArray = explode('?',$tmp_send_to,2); |
|
888 | + $mailtoArray = explode('?', $tmp_send_to, 2); |
|
890 | 889 | if ($mailtoArray[1]) { |
891 | 890 | // check if there are more than one requests |
892 | - $addRequests = explode('&',$mailtoArray[1]); |
|
891 | + $addRequests = explode('&', $mailtoArray[1]); |
|
893 | 892 | foreach ($addRequests as $key => $reqval) { |
894 | 893 | // the additional requests should have a =, to separate key from value. |
895 | 894 | $reqval = preg_replace('/__AMPERSAND__/i', "&", $reqval); |
896 | - $keyValuePair = explode('=',$reqval,2); |
|
897 | - $content[$keyValuePair[0]] .= (strlen($content[$keyValuePair[0]])>0 ? ' ':'') . $keyValuePair[1]; |
|
895 | + $keyValuePair = explode('=', $reqval, 2); |
|
896 | + $content[$keyValuePair[0]] .= (strlen($content[$keyValuePair[0]]) > 0 ? ' ' : '').$keyValuePair[1]; |
|
898 | 897 | } |
899 | 898 | } |
900 | - $content['to']= preg_replace('/__AMPERSAND__/i', "&", $mailtoArray[0]); |
|
901 | - $alreadyProcessed['to']='to'; |
|
899 | + $content['to'] = preg_replace('/__AMPERSAND__/i', "&", $mailtoArray[0]); |
|
900 | + $alreadyProcessed['to'] = 'to'; |
|
902 | 901 | // if the mailto string is not htmlentity decoded the arguments are passed as simple requests |
903 | - foreach(array('cc','bcc','subject','body') as $name) { |
|
904 | - $alreadyProcessed[$name]=$name; |
|
905 | - if ($_REQUEST[$name]) $content[$name] .= (strlen($content[$name])>0 ? ( $name == 'cc' || $name == 'bcc' ? ',' : ' ') : '') . $_REQUEST[$name]; |
|
902 | + foreach (array('cc', 'bcc', 'subject', 'body') as $name) { |
|
903 | + $alreadyProcessed[$name] = $name; |
|
904 | + if ($_REQUEST[$name]) $content[$name] .= (strlen($content[$name]) > 0 ? ($name == 'cc' || $name == 'bcc' ? ',' : ' ') : '').$_REQUEST[$name]; |
|
906 | 905 | } |
907 | 906 | } |
908 | 907 | |
909 | 908 | if ($_REQUEST['preset']['mailtocontactbyid']) { |
910 | 909 | if ($GLOBALS['egw_info']['user']['apps']['addressbook']) { |
911 | 910 | $contacts_obj = new Api\Contacts(); |
912 | - $addressbookprefs =& $GLOBALS['egw_info']['user']['preferences']['addressbook']; |
|
913 | - if (method_exists($contacts_obj,'search')) { |
|
911 | + $addressbookprefs = & $GLOBALS['egw_info']['user']['preferences']['addressbook']; |
|
912 | + if (method_exists($contacts_obj, 'search')) { |
|
914 | 913 | |
915 | - $addressArray = explode(',',$_REQUEST['preset']['mailtocontactbyid']); |
|
914 | + $addressArray = explode(',', $_REQUEST['preset']['mailtocontactbyid']); |
|
916 | 915 | foreach ((array)$addressArray as $id => $addressID) |
917 | 916 | { |
918 | - $addressID = (int) $addressID; |
|
919 | - if (!($addressID>0)) |
|
917 | + $addressID = (int)$addressID; |
|
918 | + if (!($addressID > 0)) |
|
920 | 919 | { |
921 | 920 | unset($addressArray[$id]); |
922 | 921 | } |
@@ -925,47 +924,47 @@ discard block |
||
925 | 924 | { |
926 | 925 | $_searchCond = array('contact_id'=>$addressArray); |
927 | 926 | //error_log(__METHOD__.__LINE__.$_searchString); |
928 | - $showAccounts= $GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] !== '1'; |
|
929 | - $filter = ($showAccounts?array():array('account_id' => null)); |
|
930 | - $filter['cols_to_search']=array('n_fn','email','email_home'); |
|
931 | - $contacts = $contacts_obj->search($_searchCond,array('n_fn','email','email_home'),'n_fn','','%',false,'OR',array(0,100),$filter); |
|
927 | + $showAccounts = $GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] !== '1'; |
|
928 | + $filter = ($showAccounts ? array() : array('account_id' => null)); |
|
929 | + $filter['cols_to_search'] = array('n_fn', 'email', 'email_home'); |
|
930 | + $contacts = $contacts_obj->search($_searchCond, array('n_fn', 'email', 'email_home'), 'n_fn', '', '%', false, 'OR', array(0, 100), $filter); |
|
932 | 931 | // additionally search the accounts, if the contact storage is not the account storage |
933 | 932 | if ($showAccounts && |
934 | 933 | $GLOBALS['egw_info']['server']['account_repository'] == 'ldap' && |
935 | 934 | $GLOBALS['egw_info']['server']['contact_repository'] == 'sql') |
936 | 935 | { |
937 | - $accounts = $contacts_obj->search($_searchCond,array('n_fn','email','email_home'),'n_fn','','%',false,'OR',array(0,100),array('owner' => 0)); |
|
936 | + $accounts = $contacts_obj->search($_searchCond, array('n_fn', 'email', 'email_home'), 'n_fn', '', '%', false, 'OR', array(0, 100), array('owner' => 0)); |
|
938 | 937 | |
939 | 938 | if ($contacts && $accounts) |
940 | 939 | { |
941 | - $contacts = array_merge($contacts,$accounts); |
|
940 | + $contacts = array_merge($contacts, $accounts); |
|
942 | 941 | usort($contacts, function($a, $b) |
943 | 942 | { |
944 | 943 | return strcasecmp($a['n_fn'], $b['n_fn']); |
945 | 944 | }); |
946 | 945 | } |
947 | - elseif($accounts) |
|
946 | + elseif ($accounts) |
|
948 | 947 | { |
949 | - $contacts =& $accounts; |
|
948 | + $contacts = & $accounts; |
|
950 | 949 | } |
951 | 950 | unset($accounts); |
952 | 951 | } |
953 | 952 | } |
954 | - if(is_array($contacts)) { |
|
953 | + if (is_array($contacts)) { |
|
955 | 954 | $mailtoArray = array(); |
956 | 955 | $primary = $addressbookprefs['distributionListPreferredMail']; |
957 | 956 | if ($primary != 'email' && $primary != 'email_home') $primary = 'email'; |
958 | - $secondary = ($primary == 'email'?'email_home':'email'); |
|
957 | + $secondary = ($primary == 'email' ? 'email_home' : 'email'); |
|
959 | 958 | //error_log(__METHOD__.__LINE__.array2string($contacts)); |
960 | - foreach($contacts as $contact) { |
|
961 | - $innerCounter=0; |
|
962 | - foreach(array($contact[$primary],$contact[$secondary]) as $email) { |
|
959 | + foreach ($contacts as $contact) { |
|
960 | + $innerCounter = 0; |
|
961 | + foreach (array($contact[$primary], $contact[$secondary]) as $email) { |
|
963 | 962 | // use pref distributionListPreferredMail for the primary address |
964 | 963 | // avoid wrong addresses, if an rfc822 encoded address is in addressbook |
965 | - $email = preg_replace("/(^.*<)([a-zA-Z0-9_\-]+@[a-zA-Z0-9_\-\.]+)(.*)/",'$2',$email); |
|
966 | - $contact['n_fn'] = str_replace(array(',','@'),' ',$contact['n_fn']); |
|
967 | - $completeMailString = addslashes(trim($contact['n_fn'] ? $contact['n_fn'] : $contact['fn']) .' <'. trim($email) .'>'); |
|
968 | - if($innerCounter==0 && !empty($email) && in_array($completeMailString ,$mailtoArray) === false) { |
|
964 | + $email = preg_replace("/(^.*<)([a-zA-Z0-9_\-]+@[a-zA-Z0-9_\-\.]+)(.*)/", '$2', $email); |
|
965 | + $contact['n_fn'] = str_replace(array(',', '@'), ' ', $contact['n_fn']); |
|
966 | + $completeMailString = addslashes(trim($contact['n_fn'] ? $contact['n_fn'] : $contact['fn']).' <'.trim($email).'>'); |
|
967 | + if ($innerCounter == 0 && !empty($email) && in_array($completeMailString, $mailtoArray) === false) { |
|
969 | 968 | $i++; |
970 | 969 | $innerCounter++; |
971 | 970 | $mailtoArray[$i] = $completeMailString; |
@@ -974,8 +973,8 @@ discard block |
||
974 | 973 | } |
975 | 974 | } |
976 | 975 | //error_log(__METHOD__.__LINE__.array2string($mailtoArray)); |
977 | - $alreadyProcessed['to']='to'; |
|
978 | - $content['to']=$mailtoArray; |
|
976 | + $alreadyProcessed['to'] = 'to'; |
|
977 | + $content['to'] = $mailtoArray; |
|
979 | 978 | } |
980 | 979 | } |
981 | 980 | } |
@@ -990,23 +989,23 @@ discard block |
||
990 | 989 | $remember = array(); |
991 | 990 | if (isset($_REQUEST['preset']['mailto']) || (isset($_REQUEST['app']) && isset($_REQUEST['method']) && isset($_REQUEST['id']))) |
992 | 991 | { |
993 | - foreach(array_keys($content) as $k) |
|
992 | + foreach (array_keys($content) as $k) |
|
994 | 993 | { |
995 | - if (in_array($k,array('to','cc','bcc','subject','body','mimeType'))&&isset($this->sessionData[$k])) |
|
994 | + if (in_array($k, array('to', 'cc', 'bcc', 'subject', 'body', 'mimeType')) && isset($this->sessionData[$k])) |
|
996 | 995 | { |
997 | - $alreadyProcessed[$k]=$k; |
|
996 | + $alreadyProcessed[$k] = $k; |
|
998 | 997 | $remember[$k] = $this->sessionData[$k]; |
999 | 998 | } |
1000 | 999 | } |
1001 | 1000 | } |
1002 | - if(!empty($remember)) $content = array_merge($content,$remember); |
|
1001 | + if (!empty($remember)) $content = array_merge($content, $remember); |
|
1003 | 1002 | } |
1004 | - foreach(array('to','cc','bcc','subject','body','mimeType') as $name) |
|
1003 | + foreach (array('to', 'cc', 'bcc', 'subject', 'body', 'mimeType') as $name) |
|
1005 | 1004 | { |
1006 | 1005 | //always handle mimeType |
1007 | - if ($name=='mimeType' && $_REQUEST['preset'][$name]) |
|
1006 | + if ($name == 'mimeType' && $_REQUEST['preset'][$name]) |
|
1008 | 1007 | { |
1009 | - $_content[$name]=$content[$name]=$_REQUEST['preset'][$name]; |
|
1008 | + $_content[$name] = $content[$name] = $_REQUEST['preset'][$name]; |
|
1010 | 1009 | } |
1011 | 1010 | //skip if already processed by "preset Routines" |
1012 | 1011 | if ($alreadyProcessed[$name]) continue; |
@@ -1019,36 +1018,36 @@ discard block |
||
1019 | 1018 | { |
1020 | 1019 | $content['to'] = base64_decode($_REQUEST['send_to']); |
1021 | 1020 | // first check if there is a questionmark or ampersand |
1022 | - if (strpos($content['to'],'?')!== false) list($content['to'],$rest) = explode('?',$content['to'],2); |
|
1021 | + if (strpos($content['to'], '?') !== false) list($content['to'], $rest) = explode('?', $content['to'], 2); |
|
1023 | 1022 | $content['to'] = html_entity_decode($content['to']); |
1024 | - if (($at_pos = strpos($content['to'],'@')) !== false) |
|
1023 | + if (($at_pos = strpos($content['to'], '@')) !== false) |
|
1025 | 1024 | { |
1026 | - if (($amp_pos = strpos(substr($content['to'],$at_pos),'&')) !== false) |
|
1025 | + if (($amp_pos = strpos(substr($content['to'], $at_pos), '&')) !== false) |
|
1027 | 1026 | { |
1028 | 1027 | //list($email,$addoptions) = explode('&',$value,2); |
1029 | - $email = substr($content['to'],0,$amp_pos+$at_pos); |
|
1030 | - $rest = substr($content['to'], $amp_pos+$at_pos+1); |
|
1028 | + $email = substr($content['to'], 0, $amp_pos + $at_pos); |
|
1029 | + $rest = substr($content['to'], $amp_pos + $at_pos + 1); |
|
1031 | 1030 | //error_log(__METHOD__.__LINE__.$email.' '.$rest); |
1032 | 1031 | $content['to'] = $email; |
1033 | 1032 | } |
1034 | 1033 | } |
1035 | - if (strpos($content['to'],'%40')!== false) $content['to'] = Api\Html::purify(str_replace('%40','@',$content['to'])); |
|
1034 | + if (strpos($content['to'], '%40') !== false) $content['to'] = Api\Html::purify(str_replace('%40', '@', $content['to'])); |
|
1036 | 1035 | $rarr = array(Api\Html::purify($rest)); |
1037 | - if (isset($rest)&&!empty($rest) && strpos($rest,'&')!== false) $rarr = explode('&',$rest); |
|
1036 | + if (isset($rest) && !empty($rest) && strpos($rest, '&') !== false) $rarr = explode('&', $rest); |
|
1038 | 1037 | //error_log(__METHOD__.__LINE__.$content['to'].'->'.array2string($rarr)); |
1039 | 1038 | $karr = array(); |
1040 | 1039 | foreach ($rarr as &$rval) |
1041 | 1040 | { |
1042 | 1041 | //must contain = |
1043 | - if (strpos($rval,'=')!== false) |
|
1042 | + if (strpos($rval, '=') !== false) |
|
1044 | 1043 | { |
1045 | - list($k,$v) = explode('=',$rval,2); |
|
1044 | + list($k, $v) = explode('=', $rval, 2); |
|
1046 | 1045 | $karr[$k] = (string)$v; |
1047 | - unset($k,$v); |
|
1046 | + unset($k, $v); |
|
1048 | 1047 | } |
1049 | 1048 | } |
1050 | 1049 | //error_log(__METHOD__.__LINE__.$content['to'].'->'.array2string($karr)); |
1051 | - foreach(array('cc','bcc','subject','body') as $name) |
|
1050 | + foreach (array('cc', 'bcc', 'subject', 'body') as $name) |
|
1052 | 1051 | { |
1053 | 1052 | if ($karr[$name]) $content[$name] = $karr[$name]; |
1054 | 1053 | } |
@@ -1060,17 +1059,17 @@ discard block |
||
1060 | 1059 | if ($isFirstLoad && !empty($_REQUEST['mimeType'])) |
1061 | 1060 | { |
1062 | 1061 | $_content['mimeType'] = $content['mimeType']; |
1063 | - if (($_REQUEST['mimeType']=="text" ||$_REQUEST['mimeType']=="plain") && $content['mimeType'] == 'html') |
|
1062 | + if (($_REQUEST['mimeType'] == "text" || $_REQUEST['mimeType'] == "plain") && $content['mimeType'] == 'html') |
|
1064 | 1063 | { |
1065 | - $_content['mimeType'] = $content['mimeType'] = 'plain'; |
|
1066 | - $content['body'] = $this->convertHTMLToText(str_replace(array("\n\r","\n"),' ',$content['body'])); |
|
1064 | + $_content['mimeType'] = $content['mimeType'] = 'plain'; |
|
1065 | + $content['body'] = $this->convertHTMLToText(str_replace(array("\n\r", "\n"), ' ', $content['body'])); |
|
1067 | 1066 | } |
1068 | - if ($_REQUEST['mimeType']=="html" && $content['mimeType'] != 'html') |
|
1067 | + if ($_REQUEST['mimeType'] == "html" && $content['mimeType'] != 'html') |
|
1069 | 1068 | { |
1070 | - $_content['mimeType'] = $content['mimeType'] = 'html'; |
|
1069 | + $_content['mimeType'] = $content['mimeType'] = 'html'; |
|
1071 | 1070 | $content['body'] = "<pre>".$content['body']."</pre>"; |
1072 | 1071 | // take care this assumption is made on the creation of the reply header in bocompose::getReplyData |
1073 | - if (strpos($content['body'],"<pre> \r\n \r\n---")===0) $content['body'] = substr_replace($content['body']," <br>\r\n<pre>---",0,strlen("<pre> \r\n \r\n---")-1); |
|
1072 | + if (strpos($content['body'], "<pre> \r\n \r\n---") === 0) $content['body'] = substr_replace($content['body'], " <br>\r\n<pre>---", 0, strlen("<pre> \r\n \r\n---") - 1); |
|
1074 | 1073 | } |
1075 | 1074 | } |
1076 | 1075 | else |
@@ -1078,24 +1077,24 @@ discard block |
||
1078 | 1077 | // try to enforce a mimeType on reply ( if type is not of the wanted type ) |
1079 | 1078 | if ($isReply) |
1080 | 1079 | { |
1081 | - if (!empty($this->mailPreferences['replyOptions']) && $this->mailPreferences['replyOptions']=="text" && |
|
1080 | + if (!empty($this->mailPreferences['replyOptions']) && $this->mailPreferences['replyOptions'] == "text" && |
|
1082 | 1081 | $content['mimeType'] == 'html') |
1083 | 1082 | { |
1084 | - $_content['mimeType'] = $content['mimeType'] = 'plain'; |
|
1085 | - $content['body'] = $this->convertHTMLToText(str_replace(array("\n\r","\n"),' ',$content['body'])); |
|
1083 | + $_content['mimeType'] = $content['mimeType'] = 'plain'; |
|
1084 | + $content['body'] = $this->convertHTMLToText(str_replace(array("\n\r", "\n"), ' ', $content['body'])); |
|
1086 | 1085 | } |
1087 | - if (!empty($this->mailPreferences['replyOptions']) && $this->mailPreferences['replyOptions']=="html" && |
|
1086 | + if (!empty($this->mailPreferences['replyOptions']) && $this->mailPreferences['replyOptions'] == "html" && |
|
1088 | 1087 | $content['mimeType'] != 'html') |
1089 | 1088 | { |
1090 | - $_content['mimeType'] = $content['mimeType'] = 'html'; |
|
1089 | + $_content['mimeType'] = $content['mimeType'] = 'html'; |
|
1091 | 1090 | $content['body'] = "<pre>".$content['body']."</pre>"; |
1092 | 1091 | // take care this assumption is made on the creation of the reply header in bocompose::getReplyData |
1093 | - if (strpos($content['body'],"<pre> \r\n \r\n---")===0) $content['body'] = substr_replace($content['body']," <br>\r\n<pre>---",0,strlen("<pre> \r\n \r\n---")-1); |
|
1092 | + if (strpos($content['body'], "<pre> \r\n \r\n---") === 0) $content['body'] = substr_replace($content['body'], " <br>\r\n<pre>---", 0, strlen("<pre> \r\n \r\n---") - 1); |
|
1094 | 1093 | } |
1095 | 1094 | } |
1096 | 1095 | } |
1097 | 1096 | |
1098 | - if ($content['mimeType'] == 'html' && Api\Html::htmlarea_availible()===false) |
|
1097 | + if ($content['mimeType'] == 'html' && Api\Html::htmlarea_availible() === false) |
|
1099 | 1098 | { |
1100 | 1099 | $_content['mimeType'] = $content['mimeType'] = 'plain'; |
1101 | 1100 | $content['body'] = $this->convertHTMLToText($content['body']); |
@@ -1114,38 +1113,38 @@ discard block |
||
1114 | 1113 | //_debug_array(($presetSig ? $presetSig : $content['mailidentity'])); |
1115 | 1114 | try |
1116 | 1115 | { |
1117 | - $signature = Mail\Account::read_identity($content['mailidentity'] ? $content['mailidentity'] : $presetSig,true); |
|
1116 | + $signature = Mail\Account::read_identity($content['mailidentity'] ? $content['mailidentity'] : $presetSig, true); |
|
1118 | 1117 | } |
1119 | 1118 | catch (Exception $e) |
1120 | 1119 | { |
1121 | 1120 | //PROBABLY NOT FOUND |
1122 | - $signature=array(); |
|
1121 | + $signature = array(); |
|
1123 | 1122 | } |
1124 | 1123 | if ((isset($this->mailPreferences['disableRulerForSignatureSeparation']) && |
1125 | 1124 | $this->mailPreferences['disableRulerForSignatureSeparation']) || |
1126 | 1125 | empty($signature['ident_signature']) || |
1127 | - trim($this->convertHTMLToText($signature['ident_signature'],true,true)) =='' || |
|
1126 | + trim($this->convertHTMLToText($signature['ident_signature'], true, true)) == '' || |
|
1128 | 1127 | $this->mailPreferences['insertSignatureAtTopOfMessage'] == '1') |
1129 | 1128 | { |
1130 | 1129 | $disableRuler = true; |
1131 | 1130 | } |
1132 | 1131 | $font_span = $font_part = ''; |
1133 | - if($content['mimeType'] == 'html') { |
|
1132 | + if ($content['mimeType'] == 'html') { |
|
1134 | 1133 | // User preferences for style |
1135 | 1134 | $font = $GLOBALS['egw_info']['user']['preferences']['common']['rte_font']; |
1136 | 1135 | $font_size = Etemplate\Widget\HtmlArea::font_size_from_prefs(); |
1137 | - $font_part = '<span style="width:100%; display: inline; '.($font?'font-family:'.$font.'; ':'').($font_size?'font-size:'.$font_size.'; ':'').'">'; |
|
1136 | + $font_part = '<span style="width:100%; display: inline; '.($font ? 'font-family:'.$font.'; ' : '').($font_size ? 'font-size:'.$font_size.'; ' : '').'">'; |
|
1138 | 1137 | $font_span = $font_part.'​</span>'; |
1139 | 1138 | if (empty($font) && empty($font_size)) $font_span = ''; |
1140 | 1139 | } |
1141 | 1140 | // the font span should only be applied on first load or on switch plain->html and the absence of the font_part of the span |
1142 | - if (!$isFirstLoad && !empty($font_span) && stripos($content['body'],$font_part)===false) $font_span = ''; |
|
1141 | + if (!$isFirstLoad && !empty($font_span) && stripos($content['body'], $font_part) === false) $font_span = ''; |
|
1143 | 1142 | //remove possible html header stuff |
1144 | - if (stripos($content['body'],'<html><head></head><body>')!==false) $content['body'] = str_ireplace(array('<html><head></head><body>','</body></html>'),array('',''),$content['body']); |
|
1143 | + if (stripos($content['body'], '<html><head></head><body>') !== false) $content['body'] = str_ireplace(array('<html><head></head><body>', '</body></html>'), array('', ''), $content['body']); |
|
1145 | 1144 | //error_log(__METHOD__.__LINE__.array2string($this->mailPreferences)); |
1146 | - $blockElements = array('address','blockquote','center','del','dir','div','dl','fieldset','form','h1','h2','h3','h4','h5','h6','hr','ins','isindex','menu','noframes','noscript','ol','p','pre','table','ul'); |
|
1147 | - if ($this->mailPreferences['insertSignatureAtTopOfMessage']!='no_belowaftersend' && |
|
1148 | - !(isset($_POST['mySigID']) && !empty($_POST['mySigID']) ) && !$suppressSigOnTop |
|
1145 | + $blockElements = array('address', 'blockquote', 'center', 'del', 'dir', 'div', 'dl', 'fieldset', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'hr', 'ins', 'isindex', 'menu', 'noframes', 'noscript', 'ol', 'p', 'pre', 'table', 'ul'); |
|
1146 | + if ($this->mailPreferences['insertSignatureAtTopOfMessage'] != 'no_belowaftersend' && |
|
1147 | + !(isset($_POST['mySigID']) && !empty($_POST['mySigID'])) && !$suppressSigOnTop |
|
1149 | 1148 | ) |
1150 | 1149 | { |
1151 | 1150 | // ON tOP OR BELOW? pREF CAN TELL |
@@ -1155,58 +1154,58 @@ discard block |
||
1155 | 1154 | '1' => 'before reply, visible during compose', |
1156 | 1155 | 'no_belowaftersend' => 'appended after reply before sending', |
1157 | 1156 | */ |
1158 | - $insertSigOnTop = ($insertSigOnTop?$insertSigOnTop:($this->mailPreferences['insertSignatureAtTopOfMessage']?$this->mailPreferences['insertSignatureAtTopOfMessage']:'below')); |
|
1159 | - $sigText = Mail::merge($signature['ident_signature'],array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id'))); |
|
1157 | + $insertSigOnTop = ($insertSigOnTop ? $insertSigOnTop : ($this->mailPreferences['insertSignatureAtTopOfMessage'] ? $this->mailPreferences['insertSignatureAtTopOfMessage'] : 'below')); |
|
1158 | + $sigText = Mail::merge($signature['ident_signature'], array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'], 'person_id'))); |
|
1160 | 1159 | if ($content['mimeType'] == 'html') |
1161 | 1160 | { |
1162 | - $sigTextStartsWithBlockElement = ($disableRuler?false:true); |
|
1163 | - foreach($blockElements as $e) |
|
1161 | + $sigTextStartsWithBlockElement = ($disableRuler ?false:true); |
|
1162 | + foreach ($blockElements as $e) |
|
1164 | 1163 | { |
1165 | 1164 | if ($sigTextStartsWithBlockElement) break; |
1166 | - if (stripos(trim($sigText),'<'.$e)===0) $sigTextStartsWithBlockElement = true; |
|
1165 | + if (stripos(trim($sigText), '<'.$e) === 0) $sigTextStartsWithBlockElement = true; |
|
1167 | 1166 | } |
1168 | 1167 | } |
1169 | - if($content['mimeType'] == 'html') { |
|
1168 | + if ($content['mimeType'] == 'html') { |
|
1170 | 1169 | $before = $disableRuler ? '' : '<hr style="border:1px dotted silver; width:100%;">'; |
1171 | 1170 | $inbetween = ''; |
1172 | 1171 | } else { |
1173 | - $before = ($disableRuler ?"\r\n\r\n":"\r\n\r\n-- \r\n"); |
|
1172 | + $before = ($disableRuler ? "\r\n\r\n" : "\r\n\r\n-- \r\n"); |
|
1174 | 1173 | $inbetween = "\r\n"; |
1175 | 1174 | } |
1176 | 1175 | if ($content['mimeType'] == 'html') |
1177 | 1176 | { |
1178 | - $sigText = ($sigTextStartsWithBlockElement?'':"<div>")."<!-- HTMLSIGBEGIN -->".$sigText."<!-- HTMLSIGEND -->".($sigTextStartsWithBlockElement?'':"</div>"); |
|
1177 | + $sigText = ($sigTextStartsWithBlockElement ? '' : "<div>")."<!-- HTMLSIGBEGIN -->".$sigText."<!-- HTMLSIGEND -->".($sigTextStartsWithBlockElement ? '' : "</div>"); |
|
1179 | 1178 | } |
1180 | 1179 | |
1181 | 1180 | if ($insertSigOnTop === 'below') |
1182 | 1181 | { |
1183 | - $content['body'] = $font_span.$content['body'].$before.($content['mimeType'] == 'html'?$sigText:$this->convertHTMLToText($sigText,true,true)); |
|
1182 | + $content['body'] = $font_span.$content['body'].$before.($content['mimeType'] == 'html' ? $sigText : $this->convertHTMLToText($sigText, true, true)); |
|
1184 | 1183 | } |
1185 | 1184 | else |
1186 | 1185 | { |
1187 | - $content['body'] = $font_span.$before.($content['mimeType'] == 'html'?$sigText:$this->convertHTMLToText($sigText,true,true)).$inbetween.$content['body']; |
|
1186 | + $content['body'] = $font_span.$before.($content['mimeType'] == 'html' ? $sigText : $this->convertHTMLToText($sigText, true, true)).$inbetween.$content['body']; |
|
1188 | 1187 | } |
1189 | 1188 | } |
1190 | 1189 | // Skip this part if we're merging, it would add an extra line at the top |
1191 | 1190 | else if (!$content['body']) |
1192 | 1191 | { |
1193 | - $content['body'] = ($font_span?($isFirstLoad === "switchedplaintohtml"?$font_part:$font_span):'').($isFirstLoad === "switchedplaintohtml"?"</span>":""); |
|
1192 | + $content['body'] = ($font_span ? ($isFirstLoad === "switchedplaintohtml" ? $font_part : $font_span) : '').($isFirstLoad === "switchedplaintohtml" ? "</span>" : ""); |
|
1194 | 1193 | } |
1195 | 1194 | //error_log(__METHOD__.__LINE__.$content['body']); |
1196 | 1195 | |
1197 | 1196 | // prepare body |
1198 | 1197 | // in a way, this tests if we are having real utf-8 (the displayCharset) by now; we should if charsets reported (or detected) are correct |
1199 | - $content['body'] = Api\Translation::convert_jsonsafe($content['body'],'utf-8'); |
|
1198 | + $content['body'] = Api\Translation::convert_jsonsafe($content['body'], 'utf-8'); |
|
1200 | 1199 | //error_log(__METHOD__.__LINE__.array2string($content)); |
1201 | 1200 | |
1202 | 1201 | // get identities of all accounts as "$acc_id:$ident_id" => $identity |
1203 | 1202 | $sel_options['mailaccount'] = $identities = array(); |
1204 | - foreach(Mail\Account::search(true,false) as $acc_id => $account) |
|
1203 | + foreach (Mail\Account::search(true, false) as $acc_id => $account) |
|
1205 | 1204 | { |
1206 | 1205 | // do NOT add SMTP only accounts as identities |
1207 | 1206 | if (!$account->is_imap(false)) continue; |
1208 | 1207 | |
1209 | - foreach($account->identities($acc_id) as $ident_id => $identity) |
|
1208 | + foreach ($account->identities($acc_id) as $ident_id => $identity) |
|
1210 | 1209 | { |
1211 | 1210 | $sel_options['mailaccount'][$acc_id.':'.$ident_id] = $identity; |
1212 | 1211 | $identities[$ident_id] = $identity; |
@@ -1217,7 +1216,7 @@ discard block |
||
1217 | 1216 | //$content['bcc'] = array('[email protected]','[email protected]'); |
1218 | 1217 | // address stuff like from, to, cc, replyto |
1219 | 1218 | $destinationRows = 0; |
1220 | - foreach(self::$destinations as $destination) { |
|
1219 | + foreach (self::$destinations as $destination) { |
|
1221 | 1220 | if (!is_array($content[$destination])) |
1222 | 1221 | { |
1223 | 1222 | if (!empty($content[$destination])) $content[$destination] = (array)$content[$destination]; |
@@ -1225,22 +1224,22 @@ discard block |
||
1225 | 1224 | $addr_content = $content[strtolower($destination)]; |
1226 | 1225 | // we clear the given address array and rebuild it |
1227 | 1226 | unset($content[strtolower($destination)]); |
1228 | - foreach((array)$addr_content as $key => $value) { |
|
1229 | - if ($value=="NIL@NIL") continue; |
|
1230 | - if ($destination=='replyto' && str_replace('"','',$value) == |
|
1231 | - str_replace('"','',$identities[$this->mail_bo->getDefaultIdentity()])) |
|
1227 | + foreach ((array)$addr_content as $key => $value) { |
|
1228 | + if ($value == "NIL@NIL") continue; |
|
1229 | + if ($destination == 'replyto' && str_replace('"', '', $value) == |
|
1230 | + str_replace('"', '', $identities[$this->mail_bo->getDefaultIdentity()])) |
|
1232 | 1231 | { |
1233 | 1232 | // preserve/restore the value to content. |
1234 | - $content[strtolower($destination)][]=$value; |
|
1233 | + $content[strtolower($destination)][] = $value; |
|
1235 | 1234 | continue; |
1236 | 1235 | } |
1237 | 1236 | //error_log(__METHOD__.__LINE__.array2string(array('key'=>$key,'value'=>$value))); |
1238 | - $value = str_replace("\"\"",'"', htmlspecialchars_decode($value, ENT_COMPAT)); |
|
1239 | - foreach(Mail::parseAddressList($value) as $addressObject) { |
|
1237 | + $value = str_replace("\"\"", '"', htmlspecialchars_decode($value, ENT_COMPAT)); |
|
1238 | + foreach (Mail::parseAddressList($value) as $addressObject) { |
|
1240 | 1239 | if ($addressObject->host == '.SYNTAX-ERROR.') continue; |
1241 | - $address = imap_rfc822_write_address($addressObject->mailbox,$addressObject->host,$addressObject->personal); |
|
1240 | + $address = imap_rfc822_write_address($addressObject->mailbox, $addressObject->host, $addressObject->personal); |
|
1242 | 1241 | //$address = Mail::htmlentities($address, $this->displayCharset); |
1243 | - $content[strtolower($destination)][]=$address; |
|
1242 | + $content[strtolower($destination)][] = $address; |
|
1244 | 1243 | $destinationRows++; |
1245 | 1244 | } |
1246 | 1245 | } |
@@ -1248,10 +1247,10 @@ discard block |
||
1248 | 1247 | if ($_content) |
1249 | 1248 | { |
1250 | 1249 | //input array of _content had no signature information but was seeded later, and content has a valid setting |
1251 | - if (!$_contentHasSigID && $content['mailidentity'] && array_key_exists('mailidentity',$_content)) unset($_content['mailidentity']); |
|
1252 | - $content = array_merge($content,$_content); |
|
1250 | + if (!$_contentHasSigID && $content['mailidentity'] && array_key_exists('mailidentity', $_content)) unset($_content['mailidentity']); |
|
1251 | + $content = array_merge($content, $_content); |
|
1253 | 1252 | |
1254 | - if (!empty($content['folder'])) $sel_options['folder']=$this->ajax_searchFolder(0,true); |
|
1253 | + if (!empty($content['folder'])) $sel_options['folder'] = $this->ajax_searchFolder(0, true); |
|
1255 | 1254 | if (empty($content['mailaccount'])) $content['mailaccount'] = $this->mail_bo->profileID; |
1256 | 1255 | } |
1257 | 1256 | else |
@@ -1260,12 +1259,12 @@ discard block |
||
1260 | 1259 | $content['mailaccount'] = $this->mail_bo->profileID; |
1261 | 1260 | //error_log(__METHOD__.__LINE__.$content['body']); |
1262 | 1261 | } |
1263 | - $content['is_html'] = ($content['mimeType'] == 'html'?true:''); |
|
1264 | - $content['is_plain'] = ($content['mimeType'] == 'html'?'':true); |
|
1265 | - $content['mail_'.($content['mimeType'] == 'html'?'html':'plain').'text'] =$content['body']; |
|
1266 | - $content['showtempname']=0; |
|
1262 | + $content['is_html'] = ($content['mimeType'] == 'html' ?true:''); |
|
1263 | + $content['is_plain'] = ($content['mimeType'] == 'html' ? '' : true); |
|
1264 | + $content['mail_'.($content['mimeType'] == 'html' ? 'html' : 'plain').'text'] = $content['body']; |
|
1265 | + $content['showtempname'] = 0; |
|
1267 | 1266 | //if (is_array($content['attachments']))error_log(__METHOD__.__LINE__.'before merging content with uploadforCompose:'.array2string($content['attachments'])); |
1268 | - $content['attachments']=(is_array($content['attachments'])&&is_array($content['uploadForCompose'])?array_merge($content['attachments'],(!empty($content['uploadForCompose'])?$content['uploadForCompose']:array())):(is_array($content['uploadForCompose'])?$content['uploadForCompose']:(is_array($content['attachments'])?$content['attachments']:null))); |
|
1267 | + $content['attachments'] = (is_array($content['attachments']) && is_array($content['uploadForCompose']) ?array_merge($content['attachments'], (!empty($content['uploadForCompose']) ? $content['uploadForCompose'] : array())) : (is_array($content['uploadForCompose']) ? $content['uploadForCompose'] : (is_array($content['attachments']) ? $content['attachments'] : null))); |
|
1269 | 1268 | //if (is_array($content['attachments'])) foreach($content['attachments'] as $k => &$file) $file['delete['.$file['tmp_name'].']']=0; |
1270 | 1269 | $content['no_griddata'] = empty($content['attachments']); |
1271 | 1270 | $preserv['attachments'] = $content['attachments']; |
@@ -1299,31 +1298,31 @@ discard block |
||
1299 | 1298 | $sel_options['mimeType'] = self::$mimeTypes; |
1300 | 1299 | $sel_options['priority'] = self::$priorities; |
1301 | 1300 | $sel_options['filemode'] = Vfs\Sharing::$modes; |
1302 | - if (!isset($content['priority']) || empty($content['priority'])) $content['priority']=3; |
|
1301 | + if (!isset($content['priority']) || empty($content['priority'])) $content['priority'] = 3; |
|
1303 | 1302 | //$GLOBALS['egw_info']['flags']['currentapp'] = 'mail';//should not be needed |
1304 | 1303 | $etpl = new Etemplate('mail.compose'); |
1305 | 1304 | |
1306 | 1305 | $etpl->setElementAttribute('composeToolbar', 'actions', self::getToolbarActions($content)); |
1307 | - if ($content['mimeType']=='html') |
|
1306 | + if ($content['mimeType'] == 'html') |
|
1308 | 1307 | { |
1309 | 1308 | //mode="$cont[rtfEditorFeatures]" validation_rules="$cont[validation_rules]" base_href="$cont[upload_dir]" |
1310 | 1309 | $_htmlConfig = Mail::$htmLawed_config; |
1311 | 1310 | Mail::$htmLawed_config['comment'] = 2; |
1312 | 1311 | Mail::$htmLawed_config['transform_anchor'] = false; |
1313 | - $content['validation_rules']= json_encode(Mail::$htmLawed_config); |
|
1314 | - $etpl->setElementAttribute('mail_htmltext','validation_rules',$content['validation_rules']); |
|
1312 | + $content['validation_rules'] = json_encode(Mail::$htmLawed_config); |
|
1313 | + $etpl->setElementAttribute('mail_htmltext', 'validation_rules', $content['validation_rules']); |
|
1315 | 1314 | Mail::$htmLawed_config = $_htmlConfig; |
1316 | 1315 | } |
1317 | 1316 | |
1318 | - if (isset($content['composeID'])&&!empty($content['composeID'])) |
|
1317 | + if (isset($content['composeID']) && !empty($content['composeID'])) |
|
1319 | 1318 | { |
1320 | 1319 | $composeCache = $content; |
1321 | 1320 | unset($composeCache['body']); |
1322 | 1321 | unset($composeCache['mail_htmltext']); |
1323 | 1322 | unset($composeCache['mail_plaintext']); |
1324 | - Api\Cache::setCache(Api\Cache::SESSION,'mail','composeCache'.trim($GLOBALS['egw_info']['user']['account_id']).'_'.$this->composeID,$composeCache,$expiration=60*60*2); |
|
1323 | + Api\Cache::setCache(Api\Cache::SESSION, 'mail', 'composeCache'.trim($GLOBALS['egw_info']['user']['account_id']).'_'.$this->composeID, $composeCache, $expiration = 60 * 60 * 2); |
|
1325 | 1324 | } |
1326 | - if (!isset($_content['serverID'])||empty($_content['serverID'])) |
|
1325 | + if (!isset($_content['serverID']) || empty($_content['serverID'])) |
|
1327 | 1326 | { |
1328 | 1327 | $content['serverID'] = $this->mail_bo->profileID; |
1329 | 1328 | } |
@@ -1339,13 +1338,13 @@ discard block |
||
1339 | 1338 | $preserv['list-id'] = $content['list-id']; |
1340 | 1339 | $preserv['mode'] = $content['mode']; |
1341 | 1340 | // convert it back to checkbox expectations |
1342 | - if($content['mimeType'] == 'html') { |
|
1343 | - $content['mimeType']=1; |
|
1341 | + if ($content['mimeType'] == 'html') { |
|
1342 | + $content['mimeType'] = 1; |
|
1344 | 1343 | } else { |
1345 | - $content['mimeType']=0; |
|
1344 | + $content['mimeType'] = 0; |
|
1346 | 1345 | } |
1347 | 1346 | // set the current selected mailaccount as param for folderselection |
1348 | - $etpl->setElementAttribute('folder','autocomplete_params',array('mailaccount'=>$content['mailaccount'])); |
|
1347 | + $etpl->setElementAttribute('folder', 'autocomplete_params', array('mailaccount'=>$content['mailaccount'])); |
|
1349 | 1348 | // join again mailaccount and identity |
1350 | 1349 | $content['mailaccount'] .= ':'.$content['mailidentity']; |
1351 | 1350 | //Try to set the initial selected account to the first identity match found |
@@ -1364,15 +1363,15 @@ discard block |
||
1364 | 1363 | } |
1365 | 1364 | } |
1366 | 1365 | // Resolve distribution list before send content to client |
1367 | - foreach(array('to', 'cc', 'bcc', 'replyto') as $f) |
|
1366 | + foreach (array('to', 'cc', 'bcc', 'replyto') as $f) |
|
1368 | 1367 | { |
1369 | - if (is_array($content[$f])) $content[$f]= self::resolveEmailAddressList ($content[$f]); |
|
1368 | + if (is_array($content[$f])) $content[$f] = self::resolveEmailAddressList($content[$f]); |
|
1370 | 1369 | } |
1371 | 1370 | |
1372 | 1371 | // set filemode icons for all attachments |
1373 | - if($content['attachments'] && is_array($content['attachments'])) |
|
1372 | + if ($content['attachments'] && is_array($content['attachments'])) |
|
1374 | 1373 | { |
1375 | - foreach($content['attachments'] as &$attach) |
|
1374 | + foreach ($content['attachments'] as &$attach) |
|
1376 | 1375 | { |
1377 | 1376 | $attach['is_dir'] = is_dir($attach['file']); |
1378 | 1377 | $attach['filemode_icon'] = !is_dir($attach['file']) && |
@@ -1384,7 +1383,7 @@ discard block |
||
1384 | 1383 | |
1385 | 1384 | $content['to'] = self::resolveEmailAddressList($content['to']); |
1386 | 1385 | //error_log(__METHOD__.__LINE__.array2string($content)); |
1387 | - $etpl->exec('mail.mail_compose.compose',$content,$sel_options,array(),$preserv,2); |
|
1386 | + $etpl->exec('mail.mail_compose.compose', $content, $sel_options, array(), $preserv, 2); |
|
1388 | 1387 | } |
1389 | 1388 | |
1390 | 1389 | /** |
@@ -1399,7 +1398,7 @@ discard block |
||
1399 | 1398 | * @param string $_insertSigOnTop |
1400 | 1399 | * @param boolean $_eliminateDoubleAttachments |
1401 | 1400 | */ |
1402 | - function addPresetFiles (&$_content, &$_insertSigOnTop, $_eliminateDoubleAttachments) |
|
1401 | + function addPresetFiles(&$_content, &$_insertSigOnTop, $_eliminateDoubleAttachments) |
|
1403 | 1402 | { |
1404 | 1403 | // check if JSON was used |
1405 | 1404 | if (!is_array($_REQUEST['preset']['file']) && |
@@ -1421,19 +1420,19 @@ discard block |
||
1421 | 1420 | (array)$_REQUEST['preset']['name'] : array(); |
1422 | 1421 | } |
1423 | 1422 | |
1424 | - foreach($files as $k => $path) |
|
1423 | + foreach ($files as $k => $path) |
|
1425 | 1424 | { |
1426 | - if (!empty($types[$k]) && stripos($types[$k],'text/calendar')!==false) |
|
1425 | + if (!empty($types[$k]) && stripos($types[$k], 'text/calendar') !== false) |
|
1427 | 1426 | { |
1428 | 1427 | $_insertSigOnTop = 'below'; |
1429 | 1428 | } |
1430 | 1429 | //error_log(__METHOD__.__LINE__.$path.'->'.array2string(parse_url($path,PHP_URL_SCHEME == 'vfs'))); |
1431 | - if (($scheme = parse_url($path,PHP_URL_SCHEME)) === 'vfs') |
|
1430 | + if (($scheme = parse_url($path, PHP_URL_SCHEME)) === 'vfs') |
|
1432 | 1431 | { |
1433 | 1432 | $type = Vfs::mime_content_type($path); |
1434 | 1433 | // special handling for attaching vCard of iCal --> use their link-title as name |
1435 | - if (substr($path,-7) != '/.entry' || |
|
1436 | - !(list($app,$id) = array_slice(explode('/',$path),-3)) || |
|
1434 | + if (substr($path, -7) != '/.entry' || |
|
1435 | + !(list($app, $id) = array_slice(explode('/', $path), -3)) || |
|
1437 | 1436 | !($name = Link::title($app, $id))) |
1438 | 1437 | { |
1439 | 1438 | $name = Vfs::decodePath(Vfs::basename($path)); |
@@ -1447,7 +1446,7 @@ discard block |
||
1447 | 1446 | { |
1448 | 1447 | $type = $types[$k]; |
1449 | 1448 | } |
1450 | - $path = str_replace('+','%2B',$path); |
|
1449 | + $path = str_replace('+', '%2B', $path); |
|
1451 | 1450 | $formData = array( |
1452 | 1451 | 'name' => $name, |
1453 | 1452 | 'type' => $type, |
@@ -1465,7 +1464,7 @@ discard block |
||
1465 | 1464 | { |
1466 | 1465 | error_log(__METHOD__."() Attaching '$path' outside configured temp. directory '{$GLOBALS['egw_info']['server']['temp_dir']}' denied!"); |
1467 | 1466 | } |
1468 | - elseif(is_readable($path)) |
|
1467 | + elseif (is_readable($path)) |
|
1469 | 1468 | { |
1470 | 1469 | $formData = array( |
1471 | 1470 | 'name' => isset($names[$k]) ? $names[$k] : basename($path), |
@@ -1478,7 +1477,7 @@ discard block |
||
1478 | 1477 | { |
1479 | 1478 | continue; |
1480 | 1479 | } |
1481 | - $this->addAttachment($formData,$_content, $_eliminateDoubleAttachments); |
|
1480 | + $this->addAttachment($formData, $_content, $_eliminateDoubleAttachments); |
|
1482 | 1481 | } |
1483 | 1482 | } |
1484 | 1483 | |
@@ -1500,9 +1499,9 @@ discard block |
||
1500 | 1499 | $content = array(); |
1501 | 1500 | //error_log(__METHOD__.__LINE__.array2string($mail_id).", $part_id, $from, $_focusElement, $suppressSigOnTop, $isReply"); |
1502 | 1501 | // on forward we may have to support multiple ids |
1503 | - if ($from=='forward') |
|
1502 | + if ($from == 'forward') |
|
1504 | 1503 | { |
1505 | - $replyIds = explode(',',$mail_id); |
|
1504 | + $replyIds = explode(',', $mail_id); |
|
1506 | 1505 | $mail_id = $replyIds[0]; |
1507 | 1506 | } |
1508 | 1507 | $hA = mail_ui::splitRowID($mail_id); |
@@ -1514,15 +1513,15 @@ discard block |
||
1514 | 1513 | $this->changeProfile($icServerID); |
1515 | 1514 | } |
1516 | 1515 | $icServer = $this->mail_bo->icServer; |
1517 | - if (!empty($folder) && !empty($msgUID) ) |
|
1516 | + if (!empty($folder) && !empty($msgUID)) |
|
1518 | 1517 | { |
1519 | 1518 | // this fill the session data with the values from the original email |
1520 | - switch($from) |
|
1519 | + switch ($from) |
|
1521 | 1520 | { |
1522 | 1521 | case 'composefromdraft': |
1523 | 1522 | case 'composeasnew': |
1524 | 1523 | $content = $this->getDraftData($icServer, $folder, $msgUID, $part_id); |
1525 | - if ($from =='composefromdraft') $content['mode'] = 'composefromdraft'; |
|
1524 | + if ($from == 'composefromdraft') $content['mode'] = 'composefromdraft'; |
|
1526 | 1525 | $content['processedmail_id'] = $mail_id; |
1527 | 1526 | |
1528 | 1527 | $_focusElement = 'body'; |
@@ -1538,7 +1537,7 @@ discard block |
||
1538 | 1537 | $isReply = true; |
1539 | 1538 | break; |
1540 | 1539 | case 'forward': |
1541 | - $mode = ($_GET['mode']=='forwardinline'?'inline':'asmail'); |
|
1540 | + $mode = ($_GET['mode'] == 'forwardinline' ? 'inline' : 'asmail'); |
|
1542 | 1541 | // this fill the session data with the values from the original email |
1543 | 1542 | foreach ($replyIds as &$mail_id) |
1544 | 1543 | { |
@@ -1548,14 +1547,14 @@ discard block |
||
1548 | 1547 | $folder = $hA['folder']; |
1549 | 1548 | $content = $this->getForwardData($icServer, $folder, $msgUID, $part_id, $mode); |
1550 | 1549 | } |
1551 | - $content['processedmail_id'] = implode(',',$replyIds); |
|
1550 | + $content['processedmail_id'] = implode(',', $replyIds); |
|
1552 | 1551 | $content['mode'] = 'forward'; |
1553 | - $isReply = ($mode?$mode=='inline':$this->mailPreferences['message_forwarding'] == 'inline'); |
|
1554 | - $suppressSigOnTop = false;// ($mode && $mode=='inline'?true:false);// may be a better solution |
|
1552 | + $isReply = ($mode ? $mode == 'inline' : $this->mailPreferences['message_forwarding'] == 'inline'); |
|
1553 | + $suppressSigOnTop = false; // ($mode && $mode=='inline'?true:false);// may be a better solution |
|
1555 | 1554 | $_focusElement = 'to'; |
1556 | 1555 | break; |
1557 | 1556 | default: |
1558 | - error_log('Unhandled compose source: ' . $from); |
|
1557 | + error_log('Unhandled compose source: '.$from); |
|
1559 | 1558 | } |
1560 | 1559 | } |
1561 | 1560 | else if ($from == 'merge' && $_REQUEST['document']) |
@@ -1570,12 +1569,12 @@ discard block |
||
1570 | 1569 | $document_merge = new $merge_class(); |
1571 | 1570 | $this->mail_bo->openConnection(); |
1572 | 1571 | $merge_ids = $_REQUEST['preset']['mailtocontactbyid'] ? $_REQUEST['preset']['mailtocontactbyid'] : $mail_id; |
1573 | - if (!is_array($merge_ids)) $merge_ids = explode(',',$merge_ids); |
|
1572 | + if (!is_array($merge_ids)) $merge_ids = explode(',', $merge_ids); |
|
1574 | 1573 | try |
1575 | 1574 | { |
1576 | 1575 | $merged_mail_id = ''; |
1577 | 1576 | $folder = $this->mail_bo->getDraftFolder(); |
1578 | - if(($error = $document_merge->check_document($_REQUEST['document'],''))) |
|
1577 | + if (($error = $document_merge->check_document($_REQUEST['document'], ''))) |
|
1579 | 1578 | { |
1580 | 1579 | $content['msg'] = $error; |
1581 | 1580 | return $content; |
@@ -1585,10 +1584,10 @@ discard block |
||
1585 | 1584 | //$GLOBALS['egw_info']['flags']['currentapp'] = 'addressbook'; |
1586 | 1585 | |
1587 | 1586 | // Actually do the merge |
1588 | - if(count($merge_ids) <= 1) |
|
1587 | + if (count($merge_ids) <= 1) |
|
1589 | 1588 | { |
1590 | 1589 | $results = $this->mail_bo->importMessageToMergeAndSend( |
1591 | - $document_merge, Vfs::PREFIX . $_REQUEST['document'], $merge_ids, $folder, $merged_mail_id |
|
1590 | + $document_merge, Vfs::PREFIX.$_REQUEST['document'], $merge_ids, $folder, $merged_mail_id |
|
1592 | 1591 | ); |
1593 | 1592 | |
1594 | 1593 | // Open compose |
@@ -1599,9 +1598,9 @@ discard block |
||
1599 | 1598 | } |
1600 | 1599 | else |
1601 | 1600 | { |
1602 | - $success = implode(', ',$results['success']); |
|
1601 | + $success = implode(', ', $results['success']); |
|
1603 | 1602 | $fail = implode(', ', $results['failed']); |
1604 | - if($success) Framework::message($success, 'success'); |
|
1603 | + if ($success) Framework::message($success, 'success'); |
|
1605 | 1604 | Framework::window_close($fail); |
1606 | 1605 | } |
1607 | 1606 | } |
@@ -1629,22 +1628,22 @@ discard block |
||
1629 | 1628 | return 1; |
1630 | 1629 | } |
1631 | 1630 | |
1632 | - function convertHTMLToText(&$_html,$sourceishtml = true, $stripcrl=false, $noRepEmailAddr = false) |
|
1631 | + function convertHTMLToText(&$_html, $sourceishtml = true, $stripcrl = false, $noRepEmailAddr = false) |
|
1633 | 1632 | { |
1634 | 1633 | $stripalltags = true; |
1635 | 1634 | // third param is stripalltags, we may not need that, if the source is already in ascii |
1636 | - if (!$sourceishtml) $stripalltags=false; |
|
1637 | - return Api\Mail\Html::convertHTMLToText($_html,$this->displayCharset,$stripcrl,$stripalltags, $noRepEmailAddr); |
|
1635 | + if (!$sourceishtml) $stripalltags = false; |
|
1636 | + return Api\Mail\Html::convertHTMLToText($_html, $this->displayCharset, $stripcrl, $stripalltags, $noRepEmailAddr); |
|
1638 | 1637 | } |
1639 | 1638 | |
1640 | 1639 | function generateRFC822Address($_addressObject) |
1641 | 1640 | { |
1642 | - if($_addressObject->personal && $_addressObject->mailbox && $_addressObject->host) { |
|
1643 | - return sprintf('"%s" <%s@%s>', $this->mail_bo->decode_header($_addressObject->personal), $_addressObject->mailbox, $this->mail_bo->decode_header($_addressObject->host,'FORCE')); |
|
1644 | - } elseif($_addressObject->mailbox && $_addressObject->host) { |
|
1645 | - return sprintf("%s@%s", $_addressObject->mailbox, $this->mail_bo->decode_header($_addressObject->host,'FORCE')); |
|
1641 | + if ($_addressObject->personal && $_addressObject->mailbox && $_addressObject->host) { |
|
1642 | + return sprintf('"%s" <%s@%s>', $this->mail_bo->decode_header($_addressObject->personal), $_addressObject->mailbox, $this->mail_bo->decode_header($_addressObject->host, 'FORCE')); |
|
1643 | + } elseif ($_addressObject->mailbox && $_addressObject->host) { |
|
1644 | + return sprintf("%s@%s", $_addressObject->mailbox, $this->mail_bo->decode_header($_addressObject->host, 'FORCE')); |
|
1646 | 1645 | } else { |
1647 | - return $this->mail_bo->decode_header($_addressObject->mailbox,true); |
|
1646 | + return $this->mail_bo->decode_header($_addressObject->mailbox, true); |
|
1648 | 1647 | } |
1649 | 1648 | } |
1650 | 1649 | |
@@ -1659,9 +1658,9 @@ discard block |
||
1659 | 1658 | // $_mode can be: |
1660 | 1659 | // single: for a reply to one address |
1661 | 1660 | // all: for a reply to all |
1662 | - function getDraftData($_icServer, $_folder, $_uid, $_partID=NULL) |
|
1661 | + function getDraftData($_icServer, $_folder, $_uid, $_partID = NULL) |
|
1663 | 1662 | { |
1664 | - unset($_icServer); // not used |
|
1663 | + unset($_icServer); // not used |
|
1665 | 1664 | $this->sessionData['to'] = array(); |
1666 | 1665 | |
1667 | 1666 | $mail_bo = $this->mail_bo; |
@@ -1670,7 +1669,7 @@ discard block |
||
1670 | 1669 | |
1671 | 1670 | // get message headers for specified message |
1672 | 1671 | #$headers = $mail_bo->getMessageHeader($_folder, $_uid); |
1673 | - $headers = $mail_bo->getMessageEnvelope($_uid, $_partID); |
|
1672 | + $headers = $mail_bo->getMessageEnvelope($_uid, $_partID); |
|
1674 | 1673 | $addHeadInfo = $mail_bo->getMessageHeader($_uid, $_partID); |
1675 | 1674 | // thread-topic is a proprietary microsoft header and deprecated with the current version |
1676 | 1675 | // horde does not support the encoding of thread-topic, and probably will not no so in the future |
@@ -1678,10 +1677,10 @@ discard block |
||
1678 | 1677 | |
1679 | 1678 | //error_log(__METHOD__.__LINE__.array2string($headers)); |
1680 | 1679 | if (!empty($addHeadInfo['X-MAILFOLDER'])) { |
1681 | - foreach ( explode('|',$addHeadInfo['X-MAILFOLDER']) as $val ) { |
|
1682 | - $fval=$val; |
|
1680 | + foreach (explode('|', $addHeadInfo['X-MAILFOLDER']) as $val) { |
|
1681 | + $fval = $val; |
|
1683 | 1682 | $icServerID = $mail_bo->icServer->ImapServerId; |
1684 | - if (stripos($val,'::')!==false) list($icServerID,$fval) = explode('::',$val,2); |
|
1683 | + if (stripos($val, '::') !== false) list($icServerID, $fval) = explode('::', $val, 2); |
|
1685 | 1684 | if ($icServerID != $mail_bo->icServer->ImapServerId) continue; |
1686 | 1685 | if ($mail_bo->folderExists($fval)) $this->sessionData['folder'][] = $val; |
1687 | 1686 | } |
@@ -1717,72 +1716,72 @@ discard block |
||
1717 | 1716 | } |
1718 | 1717 | } |
1719 | 1718 | // if the message is located within the draft folder, add it as last drafted version (for possible cleanup on abort)) |
1720 | - if ($mail_bo->isDraftFolder($_folder)) $this->sessionData['lastDrafted'] = mail_ui::generateRowID($this->mail_bo->profileID, $_folder, $_uid);//array('uid'=>$_uid,'folder'=>$_folder); |
|
1719 | + if ($mail_bo->isDraftFolder($_folder)) $this->sessionData['lastDrafted'] = mail_ui::generateRowID($this->mail_bo->profileID, $_folder, $_uid); //array('uid'=>$_uid,'folder'=>$_folder); |
|
1721 | 1720 | $this->sessionData['uid'] = $_uid; |
1722 | 1721 | $this->sessionData['messageFolder'] = $_folder; |
1723 | 1722 | $this->sessionData['isDraft'] = true; |
1724 | 1723 | $foundAddresses = array(); |
1725 | - foreach((array)$headers['CC'] as $val) { |
|
1726 | - $rfcAddr=Mail::parseAddressList($val); |
|
1724 | + foreach ((array)$headers['CC'] as $val) { |
|
1725 | + $rfcAddr = Mail::parseAddressList($val); |
|
1727 | 1726 | $_rfcAddr = $rfcAddr[0]; |
1728 | 1727 | if (!$_rfcAddr->valid) continue; |
1729 | - if($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host) ) { |
|
1728 | + if ($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host)) { |
|
1730 | 1729 | continue; |
1731 | 1730 | } |
1732 | - $keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host; |
|
1733 | - if(!$foundAddresses[$keyemail]) { |
|
1734 | - $address = $this->mail_bo->decode_header($val,true); |
|
1731 | + $keyemail = $_rfcAddr->mailbox.'@'.$_rfcAddr->host; |
|
1732 | + if (!$foundAddresses[$keyemail]) { |
|
1733 | + $address = $this->mail_bo->decode_header($val, true); |
|
1735 | 1734 | $this->sessionData['cc'][] = $val; |
1736 | 1735 | $foundAddresses[$keyemail] = true; |
1737 | 1736 | } |
1738 | 1737 | } |
1739 | 1738 | |
1740 | - foreach((array)$headers['TO'] as $val) { |
|
1741 | - if(!is_array($val)) |
|
1739 | + foreach ((array)$headers['TO'] as $val) { |
|
1740 | + if (!is_array($val)) |
|
1742 | 1741 | { |
1743 | 1742 | $this->sessionData['to'][] = $val; |
1744 | 1743 | continue; |
1745 | 1744 | } |
1746 | - $rfcAddr=Mail::parseAddressList($val); |
|
1745 | + $rfcAddr = Mail::parseAddressList($val); |
|
1747 | 1746 | $_rfcAddr = $rfcAddr[0]; |
1748 | 1747 | if (!$_rfcAddr->valid) continue; |
1749 | - if($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host) ) { |
|
1748 | + if ($_rfcAddr->mailbox == 'undisclosed-recipients' || (!$_rfcAddr->mailbox && !$_rfcAddr->host)) { |
|
1750 | 1749 | continue; |
1751 | 1750 | } |
1752 | - $keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host; |
|
1753 | - if(!$foundAddresses[$keyemail]) { |
|
1754 | - $address = $this->mail_bo->decode_header($val,true); |
|
1751 | + $keyemail = $_rfcAddr->mailbox.'@'.$_rfcAddr->host; |
|
1752 | + if (!$foundAddresses[$keyemail]) { |
|
1753 | + $address = $this->mail_bo->decode_header($val, true); |
|
1755 | 1754 | $this->sessionData['to'][] = $val; |
1756 | 1755 | $foundAddresses[$keyemail] = true; |
1757 | 1756 | } |
1758 | 1757 | } |
1759 | 1758 | |
1760 | 1759 | $fromAddr = Mail::parseAddressList($addHeadInfo['FROM'])[0]; |
1761 | - foreach((array)$headers['REPLY-TO'] as $val) { |
|
1762 | - $rfcAddr=Mail::parseAddressList($val); |
|
1760 | + foreach ((array)$headers['REPLY-TO'] as $val) { |
|
1761 | + $rfcAddr = Mail::parseAddressList($val); |
|
1763 | 1762 | $_rfcAddr = $rfcAddr[0]; |
1764 | 1763 | if (!$_rfcAddr->valid || ($_rfcAddr->mailbox == $fromAddr->mailbox && $_rfcAddr->host == $fromAddr->host)) continue; |
1765 | - if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) ) { |
|
1764 | + if ($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host))) { |
|
1766 | 1765 | continue; |
1767 | 1766 | } |
1768 | - $keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host; |
|
1769 | - if(!$foundAddresses[$keyemail]) { |
|
1770 | - $address = $this->mail_bo->decode_header($val,true); |
|
1767 | + $keyemail = $_rfcAddr->mailbox.'@'.$_rfcAddr->host; |
|
1768 | + if (!$foundAddresses[$keyemail]) { |
|
1769 | + $address = $this->mail_bo->decode_header($val, true); |
|
1771 | 1770 | $this->sessionData['replyto'][] = $val; |
1772 | 1771 | $foundAddresses[$keyemail] = true; |
1773 | 1772 | } |
1774 | 1773 | } |
1775 | 1774 | |
1776 | - foreach((array)$headers['BCC'] as $val) { |
|
1777 | - $rfcAddr=Mail::parseAddressList($val); |
|
1775 | + foreach ((array)$headers['BCC'] as $val) { |
|
1776 | + $rfcAddr = Mail::parseAddressList($val); |
|
1778 | 1777 | $_rfcAddr = $rfcAddr[0]; |
1779 | 1778 | if (!$_rfcAddr->valid) continue; |
1780 | - if($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host)) ) { |
|
1779 | + if ($_rfcAddr->mailbox == 'undisclosed-recipients' || (empty($_rfcAddr->mailbox) && empty($_rfcAddr->host))) { |
|
1781 | 1780 | continue; |
1782 | 1781 | } |
1783 | - $keyemail=$_rfcAddr->mailbox.'@'.$_rfcAddr->host; |
|
1784 | - if(!$foundAddresses[$keyemail]) { |
|
1785 | - $address = $this->mail_bo->decode_header($val,true); |
|
1782 | + $keyemail = $_rfcAddr->mailbox.'@'.$_rfcAddr->host; |
|
1783 | + if (!$foundAddresses[$keyemail]) { |
|
1784 | + $address = $this->mail_bo->decode_header($val, true); |
|
1786 | 1785 | $this->sessionData['bcc'][] = $val; |
1787 | 1786 | $foundAddresses[$keyemail] = true; |
1788 | 1787 | } |
@@ -1791,48 +1790,48 @@ discard block |
||
1791 | 1790 | $this->sessionData['subject'] = $mail_bo->decode_header($headers['SUBJECT']); |
1792 | 1791 | // remove a printview tag if composing |
1793 | 1792 | $searchfor = '/^\['.lang('printview').':\]/'; |
1794 | - $this->sessionData['subject'] = preg_replace($searchfor,'',$this->sessionData['subject']); |
|
1795 | - $bodyParts = $mail_bo->getMessageBody($_uid,'always_display', $_partID); |
|
1793 | + $this->sessionData['subject'] = preg_replace($searchfor, '', $this->sessionData['subject']); |
|
1794 | + $bodyParts = $mail_bo->getMessageBody($_uid, 'always_display', $_partID); |
|
1796 | 1795 | //_debug_array($bodyParts); |
1797 | 1796 | #$fromAddress = ($headers['FROM'][0]['PERSONAL_NAME'] != 'NIL') ? $headers['FROM'][0]['RFC822_EMAIL'] : $headers['FROM'][0]['EMAIL']; |
1798 | - if($bodyParts['0']['mimeType'] == 'text/html') { |
|
1799 | - $this->sessionData['mimeType'] = 'html'; |
|
1797 | + if ($bodyParts['0']['mimeType'] == 'text/html') { |
|
1798 | + $this->sessionData['mimeType'] = 'html'; |
|
1800 | 1799 | |
1801 | - for($i=0; $i<count($bodyParts); $i++) { |
|
1802 | - if($i>0) { |
|
1800 | + for ($i = 0; $i < count($bodyParts); $i++) { |
|
1801 | + if ($i > 0) { |
|
1803 | 1802 | $this->sessionData['body'] .= '<hr>'; |
1804 | 1803 | } |
1805 | - if($bodyParts[$i]['mimeType'] == 'text/plain') { |
|
1804 | + if ($bodyParts[$i]['mimeType'] == 'text/plain') { |
|
1806 | 1805 | #$bodyParts[$i]['body'] = nl2br($bodyParts[$i]['body']); |
1807 | 1806 | $bodyParts[$i]['body'] = "<pre>".$bodyParts[$i]['body']."</pre>"; |
1808 | 1807 | } |
1809 | - if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']); |
|
1808 | + if ($bodyParts[$i]['charSet'] === false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']); |
|
1810 | 1809 | $bodyParts[$i]['body'] = Api\Translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']); |
1811 | 1810 | #error_log( "GetDraftData (HTML) CharSet:".mb_detect_encoding($bodyParts[$i]['body'] . 'a' , strtoupper($bodyParts[$i]['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1')); |
1812 | - $this->sessionData['body'] .= ($i>0?"<br>":""). $bodyParts[$i]['body'] ; |
|
1811 | + $this->sessionData['body'] .= ($i > 0 ? "<br>" : "").$bodyParts[$i]['body']; |
|
1813 | 1812 | } |
1814 | 1813 | $this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID); |
1815 | 1814 | |
1816 | 1815 | } else { |
1817 | - $this->sessionData['mimeType'] = 'plain'; |
|
1816 | + $this->sessionData['mimeType'] = 'plain'; |
|
1818 | 1817 | |
1819 | - for($i=0; $i<count($bodyParts); $i++) { |
|
1820 | - if($i>0) { |
|
1818 | + for ($i = 0; $i < count($bodyParts); $i++) { |
|
1819 | + if ($i > 0) { |
|
1821 | 1820 | $this->sessionData['body'] .= "<hr>"; |
1822 | 1821 | } |
1823 | - if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']); |
|
1822 | + if ($bodyParts[$i]['charSet'] === false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']); |
|
1824 | 1823 | $bodyParts[$i]['body'] = Api\Translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']); |
1825 | 1824 | #error_log( "GetDraftData (Plain) CharSet".mb_detect_encoding($bodyParts[$i]['body'] . 'a' , strtoupper($bodyParts[$i]['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1')); |
1826 | - $this->sessionData['body'] .= ($i>0?"\r\n":""). $bodyParts[$i]['body'] ; |
|
1825 | + $this->sessionData['body'] .= ($i > 0 ? "\r\n" : "").$bodyParts[$i]['body']; |
|
1827 | 1826 | } |
1828 | - $this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID,'plain'); |
|
1827 | + $this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID, 'plain'); |
|
1829 | 1828 | } |
1830 | 1829 | |
1831 | - if(($attachments = $mail_bo->getMessageAttachments($_uid,$_partID))) { |
|
1832 | - foreach($attachments as $attachment) { |
|
1830 | + if (($attachments = $mail_bo->getMessageAttachments($_uid, $_partID))) { |
|
1831 | + foreach ($attachments as $attachment) { |
|
1833 | 1832 | //error_log(__METHOD__.__LINE__.array2string($attachment)); |
1834 | 1833 | $cid = $attachment['cid']; |
1835 | - $match=null; |
|
1834 | + $match = null; |
|
1836 | 1835 | preg_match("/cid:{$cid}/", $bodyParts['0']['body'], $match); |
1837 | 1836 | //error_log(__METHOD__.__LINE__.'searching for cid:'."/cid:{$cid}/".'#'.$r.'#'.array2string($match)); |
1838 | 1837 | if (!$match || !$attachment['cid']) |
@@ -1852,7 +1851,7 @@ discard block |
||
1852 | 1851 | |
1853 | 1852 | function getErrorInfo() |
1854 | 1853 | { |
1855 | - if(isset($this->errorInfo)) { |
|
1854 | + if (isset($this->errorInfo)) { |
|
1856 | 1855 | $errorInfo = $this->errorInfo; |
1857 | 1856 | unset($this->errorInfo); |
1858 | 1857 | return $errorInfo; |
@@ -1860,39 +1859,39 @@ discard block |
||
1860 | 1859 | return false; |
1861 | 1860 | } |
1862 | 1861 | |
1863 | - function getForwardData($_icServer, $_folder, $_uid, $_partID, $_mode=false) |
|
1862 | + function getForwardData($_icServer, $_folder, $_uid, $_partID, $_mode = false) |
|
1864 | 1863 | { |
1865 | 1864 | if ($_mode) |
1866 | 1865 | { |
1867 | 1866 | $modebuff = $this->mailPreferences['message_forwarding']; |
1868 | 1867 | $this->mailPreferences['message_forwarding'] = $_mode; |
1869 | 1868 | } |
1870 | - if ($this->mailPreferences['message_forwarding'] == 'inline') { |
|
1869 | + if ($this->mailPreferences['message_forwarding'] == 'inline') { |
|
1871 | 1870 | $this->getReplyData('forward', $_icServer, $_folder, $_uid, $_partID); |
1872 | 1871 | } |
1873 | - $mail_bo = $this->mail_bo; |
|
1872 | + $mail_bo = $this->mail_bo; |
|
1874 | 1873 | $mail_bo->openConnection(); |
1875 | 1874 | $mail_bo->reopen($_folder); |
1876 | 1875 | |
1877 | 1876 | // get message headers for specified message |
1878 | - $headers = $mail_bo->getMessageEnvelope($_uid, $_partID,false,$_folder); |
|
1877 | + $headers = $mail_bo->getMessageEnvelope($_uid, $_partID, false, $_folder); |
|
1879 | 1878 | //error_log(__METHOD__.__LINE__.array2string($headers)); |
1880 | 1879 | //_debug_array($headers); exit; |
1881 | 1880 | // check for Re: in subject header |
1882 | - $this->sessionData['subject'] = "[FWD] " . $mail_bo->decode_header($headers['SUBJECT']); |
|
1881 | + $this->sessionData['subject'] = "[FWD] ".$mail_bo->decode_header($headers['SUBJECT']); |
|
1883 | 1882 | // the three attributes below are substituted by processedmail_id and mode |
1884 | 1883 | //$this->sessionData['sourceFolder']=$_folder; |
1885 | 1884 | //$this->sessionData['forwardFlag']='forwarded'; |
1886 | 1885 | //$this->sessionData['forwardedUID']=$_uid; |
1887 | - if ($this->mailPreferences['message_forwarding'] == 'asmail') { |
|
1888 | - $this->sessionData['mimeType'] = $this->mailPreferences['composeOptions']; |
|
1889 | - if($headers['SIZE']) |
|
1886 | + if ($this->mailPreferences['message_forwarding'] == 'asmail') { |
|
1887 | + $this->sessionData['mimeType'] = $this->mailPreferences['composeOptions']; |
|
1888 | + if ($headers['SIZE']) |
|
1890 | 1889 | $size = $headers['SIZE']; |
1891 | 1890 | else |
1892 | 1891 | $size = lang('unknown'); |
1893 | 1892 | |
1894 | 1893 | $this->addMessageAttachment($_uid, $_partID, $_folder, |
1895 | - $mail_bo->decode_header(($headers['SUBJECT']?$headers['SUBJECT']:lang('no subject'))).'.eml', |
|
1894 | + $mail_bo->decode_header(($headers['SUBJECT'] ? $headers['SUBJECT'] : lang('no subject'))).'.eml', |
|
1896 | 1895 | 'MESSAGE/RFC822', $size); |
1897 | 1896 | } |
1898 | 1897 | else |
@@ -1902,10 +1901,10 @@ discard block |
||
1902 | 1901 | unset($this->sessionData['cc']); |
1903 | 1902 | try |
1904 | 1903 | { |
1905 | - if(($attachments = $mail_bo->getMessageAttachments($_uid,$_partID,null,true,false,false))) { |
|
1904 | + if (($attachments = $mail_bo->getMessageAttachments($_uid, $_partID, null, true, false, false))) { |
|
1906 | 1905 | //error_log(__METHOD__.__LINE__.':'.array2string($attachments)); |
1907 | - foreach($attachments as $attachment) { |
|
1908 | - if (!($attachment['cid'] && preg_match("/image\//",$attachment['mimeType'])) || $attachment['disposition'] == 'attachment') |
|
1906 | + foreach ($attachments as $attachment) { |
|
1907 | + if (!($attachment['cid'] && preg_match("/image\//", $attachment['mimeType'])) || $attachment['disposition'] == 'attachment') |
|
1909 | 1908 | { |
1910 | 1909 | $this->addMessageAttachment($_uid, $attachment['partID'], |
1911 | 1910 | $_folder, |
@@ -1923,7 +1922,7 @@ discard block |
||
1923 | 1922 | ' because the content of this message seems to be encrypted'. |
1924 | 1923 | ' and can not be decrypted properly. If you still wish to'. |
1925 | 1924 | ' forward content of this encrypted message, you may try'. |
1926 | - ' to use forward as attachment instead.'),'error'); |
|
1925 | + ' to use forward as attachment instead.'), 'error'); |
|
1927 | 1926 | } |
1928 | 1927 | } |
1929 | 1928 | $mail_bo->closeConnection(); |
@@ -1944,7 +1943,7 @@ discard block |
||
1944 | 1943 | * @param array $_content the content passed to the function and to be modified |
1945 | 1944 | * @return void |
1946 | 1945 | */ |
1947 | - function addAttachment($_formData,&$_content,$eliminateDoubleAttachments=false) |
|
1946 | + function addAttachment($_formData, &$_content, $eliminateDoubleAttachments = false) |
|
1948 | 1947 | { |
1949 | 1948 | //error_log(__METHOD__.__LINE__.' Formdata:'.array2string($_formData).' Content:'.array2string($_content)); |
1950 | 1949 | |
@@ -1953,7 +1952,7 @@ discard block |
||
1953 | 1952 | // check if formdata meets basic restrictions (in tmp dir, or vfs, mimetype, etc.) |
1954 | 1953 | try |
1955 | 1954 | { |
1956 | - $tmpFileName = Mail::checkFileBasics($_formData,$this->composeID,false); |
|
1955 | + $tmpFileName = Mail::checkFileBasics($_formData, $this->composeID, false); |
|
1957 | 1956 | } |
1958 | 1957 | catch (Api\Exception\WrongUserinput $e) |
1959 | 1958 | { |
@@ -1969,8 +1968,8 @@ discard block |
||
1969 | 1968 | foreach ((array)$_content['attachments'] as $attach) |
1970 | 1969 | { |
1971 | 1970 | if ($attach['name'] && $attach['name'] == $_formData['name'] && |
1972 | - strtolower($_formData['type'])== strtolower($attach['type']) && |
|
1973 | - stripos($_formData['file'],'vfs://') !== false) return; |
|
1971 | + strtolower($_formData['type']) == strtolower($attach['type']) && |
|
1972 | + stripos($_formData['file'], 'vfs://') !== false) return; |
|
1974 | 1973 | } |
1975 | 1974 | } |
1976 | 1975 | if ($attachfailed === false) |
@@ -1982,7 +1981,7 @@ discard block |
||
1982 | 1981 | 'tmp_name' => $tmpFileName, |
1983 | 1982 | 'size' => $_formData['size'] |
1984 | 1983 | ); |
1985 | - if (!is_array($_content['attachments'])) $_content['attachments']=array(); |
|
1984 | + if (!is_array($_content['attachments'])) $_content['attachments'] = array(); |
|
1986 | 1985 | $_content['attachments'][] = $buffer; |
1987 | 1986 | unset($buffer); |
1988 | 1987 | } |
@@ -1992,9 +1991,9 @@ discard block |
||
1992 | 1991 | } |
1993 | 1992 | } |
1994 | 1993 | |
1995 | - function addMessageAttachment($_uid, $_partID, $_folder, $_name, $_type, $_size, $_is_winmail= null) |
|
1994 | + function addMessageAttachment($_uid, $_partID, $_folder, $_name, $_type, $_size, $_is_winmail = null) |
|
1996 | 1995 | { |
1997 | - $this->sessionData['attachments'][]=array ( |
|
1996 | + $this->sessionData['attachments'][] = array( |
|
1998 | 1997 | 'uid' => $_uid, |
1999 | 1998 | 'partID' => $_partID, |
2000 | 1999 | 'name' => $_name, |
@@ -2002,7 +2001,7 @@ discard block |
||
2002 | 2001 | 'size' => $_size, |
2003 | 2002 | 'folder' => $_folder, |
2004 | 2003 | 'winmailFlag' => $_is_winmail, |
2005 | - 'tmp_name' => mail_ui::generateRowID($this->mail_bo->profileID, $_folder, $_uid).'_'.(!empty($_partID)?$_partID:count($this->sessionData['attachments'])+1), |
|
2004 | + 'tmp_name' => mail_ui::generateRowID($this->mail_bo->profileID, $_folder, $_uid).'_'.(!empty($_partID) ? $_partID : count($this->sessionData['attachments']) + 1), |
|
2006 | 2005 | ); |
2007 | 2006 | } |
2008 | 2007 | |
@@ -2011,7 +2010,7 @@ discard block |
||
2011 | 2010 | // read attachment data from etemplate request, use tmpname only to identify it |
2012 | 2011 | if (($request = Etemplate\Request::read($_GET['etemplate_exec_id']))) |
2013 | 2012 | { |
2014 | - foreach($request->preserv['attachments'] as $attachment) |
|
2013 | + foreach ($request->preserv['attachments'] as $attachment) |
|
2015 | 2014 | { |
2016 | 2015 | if ($_GET['tmpname'] === $attachment['tmp_name']) break; |
2017 | 2016 | } |
@@ -2023,7 +2022,7 @@ discard block |
||
2023 | 2022 | } |
2024 | 2023 | |
2025 | 2024 | //error_log(__METHOD__.__LINE__.array2string($_GET)); |
2026 | - if (parse_url($attachment['tmp_name'],PHP_URL_SCHEME) == 'vfs') |
|
2025 | + if (parse_url($attachment['tmp_name'], PHP_URL_SCHEME) == 'vfs') |
|
2027 | 2026 | { |
2028 | 2027 | Vfs::load_wrapper('vfs'); |
2029 | 2028 | } |
@@ -2032,7 +2031,7 @@ discard block |
||
2032 | 2031 | { |
2033 | 2032 | $attachment['tmp_name'] = $GLOBALS['egw_info']['server']['temp_dir'].'/'.basename($attachment['tmp_name']); |
2034 | 2033 | } |
2035 | - if(!file_exists($attachment['tmp_name'])) |
|
2034 | + if (!file_exists($attachment['tmp_name'])) |
|
2036 | 2035 | { |
2037 | 2036 | header('HTTP/1.1 404 Not found'); |
2038 | 2037 | die('Attachment '.htmlspecialchars($attachment['tmp_name']).' NOT found!'); |
@@ -2045,7 +2044,7 @@ discard block |
||
2045 | 2044 | if (strtoupper($attachment['type']) == 'TEXT/DIRECTORY') |
2046 | 2045 | { |
2047 | 2046 | $sfxMimeType = $attachment['type']; |
2048 | - $buff = explode('.',$attachment['tmp_name']); |
|
2047 | + $buff = explode('.', $attachment['tmp_name']); |
|
2049 | 2048 | $suffix = ''; |
2050 | 2049 | if (is_array($buff)) $suffix = array_pop($buff); // take the last extension to check with ext2mime |
2051 | 2050 | if (!empty($suffix)) $sfxMimeType = Api\MimeMagic::ext2mime($suffix); |
@@ -2057,10 +2056,10 @@ discard block |
||
2057 | 2056 | { |
2058 | 2057 | //error_log(__METHOD__."about to call calendar_ical"); |
2059 | 2058 | $calendar_ical = new calendar_ical(); |
2060 | - $eventid = $calendar_ical->search($attachment['attachment'],-1); |
|
2059 | + $eventid = $calendar_ical->search($attachment['attachment'], -1); |
|
2061 | 2060 | //error_log(__METHOD__.array2string($eventid)); |
2062 | 2061 | if (!$eventid) $eventid = -1; |
2063 | - $event = $calendar_ical->importVCal($attachment['attachment'],(is_array($eventid)?$eventid[0]:$eventid),null,true); |
|
2062 | + $event = $calendar_ical->importVCal($attachment['attachment'], (is_array($eventid) ? $eventid[0] : $eventid), null, true); |
|
2064 | 2063 | //error_log(__METHOD__.$event); |
2065 | 2064 | if ((int)$event > 0) |
2066 | 2065 | { |
@@ -2068,7 +2067,7 @@ discard block |
||
2068 | 2067 | 'menuaction' => 'calendar.calendar_uiforms.edit', |
2069 | 2068 | 'cal_id' => $event, |
2070 | 2069 | ); |
2071 | - $GLOBALS['egw']->redirect_link('../index.php',$vars); |
|
2070 | + $GLOBALS['egw']->redirect_link('../index.php', $vars); |
|
2072 | 2071 | } |
2073 | 2072 | //Import failed, download content anyway |
2074 | 2073 | } |
@@ -2083,13 +2082,13 @@ discard block |
||
2083 | 2082 | { |
2084 | 2083 | $vcard['uid'] = trim($vcard['uid']); |
2085 | 2084 | //error_log(__METHOD__.__LINE__.print_r($vcard,true)); |
2086 | - $contact = $addressbook_vcal->find_contact($vcard,false); |
|
2085 | + $contact = $addressbook_vcal->find_contact($vcard, false); |
|
2087 | 2086 | } |
2088 | 2087 | if (!$contact) $contact = null; |
2089 | 2088 | // if there are not enough fields in the vcard (or the parser was unable to correctly parse the vcard (as of VERSION:3.0 created by MSO)) |
2090 | - if ($contact || count($vcard)>2) |
|
2089 | + if ($contact || count($vcard) > 2) |
|
2091 | 2090 | { |
2092 | - $contact = $addressbook_vcal->addVCard($attachment['attachment'],(is_array($contact)?array_shift($contact):$contact),true); |
|
2091 | + $contact = $addressbook_vcal->addVCard($attachment['attachment'], (is_array($contact) ?array_shift($contact) : $contact), true); |
|
2093 | 2092 | } |
2094 | 2093 | if ((int)$contact > 0) |
2095 | 2094 | { |
@@ -2097,13 +2096,13 @@ discard block |
||
2097 | 2096 | 'menuaction' => 'addressbook.addressbook_ui.edit', |
2098 | 2097 | 'contact_id' => $contact, |
2099 | 2098 | ); |
2100 | - $GLOBALS['egw']->redirect_link('../index.php',$vars); |
|
2099 | + $GLOBALS['egw']->redirect_link('../index.php', $vars); |
|
2101 | 2100 | } |
2102 | 2101 | //Import failed, download content anyway |
2103 | 2102 | } |
2104 | 2103 | } |
2105 | 2104 | //error_log(__METHOD__.__LINE__.'->'.array2string($attachment)); |
2106 | - Api\Header\Content::safe($attachment['attachment'], $attachment['name'], $attachment['type'], $size=0, true, $_GET['mode'] == "save"); |
|
2105 | + Api\Header\Content::safe($attachment['attachment'], $attachment['name'], $attachment['type'], $size = 0, true, $_GET['mode'] == "save"); |
|
2107 | 2106 | echo $attachment['attachment']; |
2108 | 2107 | |
2109 | 2108 | exit(); |
@@ -2116,11 +2115,11 @@ discard block |
||
2116 | 2115 | * @param string haystack |
2117 | 2116 | * @return boolean |
2118 | 2117 | */ |
2119 | - function testIfOneKeyInArrayDoesExistInString($arrayToTestAgainst,$haystack) { |
|
2118 | + function testIfOneKeyInArrayDoesExistInString($arrayToTestAgainst, $haystack) { |
|
2120 | 2119 | foreach (array_keys($arrayToTestAgainst) as $k) |
2121 | 2120 | { |
2122 | 2121 | //error_log(__METHOD__.__LINE__.':'.$k.'<->'.$haystack); |
2123 | - if (stripos($haystack,$k)!==false) |
|
2122 | + if (stripos($haystack, $k) !== false) |
|
2124 | 2123 | { |
2125 | 2124 | //error_log(__METHOD__.__LINE__.':FOUND:'.$k.'<->'.$haystack.function_backtrace()); |
2126 | 2125 | return true; |
@@ -2143,10 +2142,10 @@ discard block |
||
2143 | 2142 | */ |
2144 | 2143 | function getReplyData($_mode, $_icServer, $_folder, $_uid, $_partID) |
2145 | 2144 | { |
2146 | - unset($_icServer); // not used |
|
2145 | + unset($_icServer); // not used |
|
2147 | 2146 | $foundAddresses = array(); |
2148 | 2147 | |
2149 | - $mail_bo = $this->mail_bo; |
|
2148 | + $mail_bo = $this->mail_bo; |
|
2150 | 2149 | $mail_bo->openConnection(); |
2151 | 2150 | $mail_bo->reopen($_folder); |
2152 | 2151 | |
@@ -2154,20 +2153,20 @@ discard block |
||
2154 | 2153 | |
2155 | 2154 | // get message headers for specified message |
2156 | 2155 | //print "AAAA: $_folder, $_uid, $_partID<br>"; |
2157 | - $headers = $mail_bo->getMessageEnvelope($_uid, $_partID,false,$_folder,$useHeaderInsteadOfEnvelope=true); |
|
2156 | + $headers = $mail_bo->getMessageEnvelope($_uid, $_partID, false, $_folder, $useHeaderInsteadOfEnvelope = true); |
|
2158 | 2157 | //$headers = $mail_bo->getMessageHeader($_uid, $_partID, true, true, $_folder); |
2159 | 2158 | $this->sessionData['uid'] = $_uid; |
2160 | 2159 | $this->sessionData['messageFolder'] = $_folder; |
2161 | - $this->sessionData['in-reply-to'] = ($headers['IN-REPLY-TO']?$headers['IN-REPLY-TO']:$headers['MESSAGE_ID']); |
|
2162 | - $this->sessionData['references'] = ($headers['REFERENCES']?$headers['REFERENCES']:$headers['MESSAGE_ID']); |
|
2160 | + $this->sessionData['in-reply-to'] = ($headers['IN-REPLY-TO'] ? $headers['IN-REPLY-TO'] : $headers['MESSAGE_ID']); |
|
2161 | + $this->sessionData['references'] = ($headers['REFERENCES'] ? $headers['REFERENCES'] : $headers['MESSAGE_ID']); |
|
2163 | 2162 | |
2164 | 2163 | // break reference into multiple lines if they're greater than 998 chars |
2165 | 2164 | // and remove comma seperation. Fix error serer does not support binary |
2166 | 2165 | // data due to long references. |
2167 | - if (strlen($this->sessionData['references'])> 998) |
|
2166 | + if (strlen($this->sessionData['references']) > 998) |
|
2168 | 2167 | { |
2169 | - $temp_refs = explode(',',$this->sessionData['references']); |
|
2170 | - $this->sessionData['references'] = implode(" ",$temp_refs); |
|
2168 | + $temp_refs = explode(',', $this->sessionData['references']); |
|
2169 | + $this->sessionData['references'] = implode(" ", $temp_refs); |
|
2171 | 2170 | } |
2172 | 2171 | |
2173 | 2172 | // thread-topic is a proprietary microsoft header and deprecated with the current version |
@@ -2177,36 +2176,36 @@ discard block |
||
2177 | 2176 | if ($headers['LIST-ID']) $this->sessionData['list-id'] = $headers['LIST-ID']; |
2178 | 2177 | //error_log(__METHOD__.__LINE__.' Mode:'.$_mode.':'.array2string($headers)); |
2179 | 2178 | // check for Reply-To: header and use if available |
2180 | - if(!empty($headers['REPLY-TO']) && ($headers['REPLY-TO'] != $headers['FROM'])) { |
|
2181 | - foreach($headers['REPLY-TO'] as $val) { |
|
2182 | - if(!$foundAddresses[$val]) { |
|
2179 | + if (!empty($headers['REPLY-TO']) && ($headers['REPLY-TO'] != $headers['FROM'])) { |
|
2180 | + foreach ($headers['REPLY-TO'] as $val) { |
|
2181 | + if (!$foundAddresses[$val]) { |
|
2183 | 2182 | $oldTo[] = $val; |
2184 | 2183 | $foundAddresses[$val] = true; |
2185 | 2184 | } |
2186 | 2185 | } |
2187 | - $oldToAddress = (is_array($headers['REPLY-TO'])?$headers['REPLY-TO'][0]:$headers['REPLY-TO']); |
|
2186 | + $oldToAddress = (is_array($headers['REPLY-TO']) ? $headers['REPLY-TO'][0] : $headers['REPLY-TO']); |
|
2188 | 2187 | } else { |
2189 | - foreach($headers['FROM'] as $val) { |
|
2190 | - if(!$foundAddresses[$val]) { |
|
2188 | + foreach ($headers['FROM'] as $val) { |
|
2189 | + if (!$foundAddresses[$val]) { |
|
2191 | 2190 | $oldTo[] = $val; |
2192 | 2191 | $foundAddresses[$val] = true; |
2193 | 2192 | } |
2194 | 2193 | } |
2195 | - $oldToAddress = (is_array($headers['FROM'])?$headers['FROM'][0]:$headers['FROM']); |
|
2194 | + $oldToAddress = (is_array($headers['FROM']) ? $headers['FROM'][0] : $headers['FROM']); |
|
2196 | 2195 | } |
2197 | 2196 | //error_log(__METHOD__.__LINE__.' OldToAddress:'.$oldToAddress.'#'); |
2198 | - if($_mode != 'all' || ($_mode == 'all' && !empty($oldToAddress) && !$this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$oldToAddress)) ) { |
|
2197 | + if ($_mode != 'all' || ($_mode == 'all' && !empty($oldToAddress) && !$this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses, $oldToAddress))) { |
|
2199 | 2198 | $this->sessionData['to'] = $oldTo; |
2200 | 2199 | } |
2201 | 2200 | |
2202 | - if($_mode == 'all') { |
|
2201 | + if ($_mode == 'all') { |
|
2203 | 2202 | // reply to any address which is cc, but not to my self |
2204 | 2203 | #if($headers->cc) { |
2205 | - foreach($headers['CC'] as $val) { |
|
2206 | - if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) { |
|
2204 | + foreach ($headers['CC'] as $val) { |
|
2205 | + if ($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses, $val)) { |
|
2207 | 2206 | continue; |
2208 | 2207 | } |
2209 | - if(!$foundAddresses[$val]) { |
|
2208 | + if (!$foundAddresses[$val]) { |
|
2210 | 2209 | $this->sessionData['cc'][] = $val; |
2211 | 2210 | $foundAddresses[$val] = true; |
2212 | 2211 | } |
@@ -2215,11 +2214,11 @@ discard block |
||
2215 | 2214 | |
2216 | 2215 | // reply to any address which is to, but not to my self |
2217 | 2216 | #if($headers->to) { |
2218 | - foreach($headers['TO'] as $val) { |
|
2219 | - if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) { |
|
2217 | + foreach ($headers['TO'] as $val) { |
|
2218 | + if ($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses, $val)) { |
|
2220 | 2219 | continue; |
2221 | 2220 | } |
2222 | - if(!$foundAddresses[$val]) { |
|
2221 | + if (!$foundAddresses[$val]) { |
|
2223 | 2222 | $this->sessionData['to'][] = $val; |
2224 | 2223 | $foundAddresses[$val] = true; |
2225 | 2224 | } |
@@ -2227,12 +2226,12 @@ discard block |
||
2227 | 2226 | #} |
2228 | 2227 | |
2229 | 2228 | #if($headers->from) { |
2230 | - foreach($headers['FROM'] as $val) { |
|
2231 | - if($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses,$val)) { |
|
2229 | + foreach ($headers['FROM'] as $val) { |
|
2230 | + if ($this->testIfOneKeyInArrayDoesExistInString($userEMailAddresses, $val)) { |
|
2232 | 2231 | continue; |
2233 | 2232 | } |
2234 | 2233 | //error_log(__METHOD__.__LINE__.' '.$val); |
2235 | - if(!$foundAddresses[$val]) { |
|
2234 | + if (!$foundAddresses[$val]) { |
|
2236 | 2235 | $this->sessionData['to'][] = $val; |
2237 | 2236 | $foundAddresses[$val] = true; |
2238 | 2237 | } |
@@ -2241,16 +2240,16 @@ discard block |
||
2241 | 2240 | } |
2242 | 2241 | |
2243 | 2242 | // check for Re: in subject header |
2244 | - if(strtolower(substr(trim($mail_bo->decode_header($headers['SUBJECT'])), 0, 3)) == "re:") { |
|
2243 | + if (strtolower(substr(trim($mail_bo->decode_header($headers['SUBJECT'])), 0, 3)) == "re:") { |
|
2245 | 2244 | $this->sessionData['subject'] = $mail_bo->decode_header($headers['SUBJECT']); |
2246 | 2245 | } else { |
2247 | - $this->sessionData['subject'] = "Re: " . $mail_bo->decode_header($headers['SUBJECT']); |
|
2246 | + $this->sessionData['subject'] = "Re: ".$mail_bo->decode_header($headers['SUBJECT']); |
|
2248 | 2247 | } |
2249 | 2248 | |
2250 | 2249 | //_debug_array($headers); |
2251 | 2250 | //error_log(__METHOD__.__LINE__.'->'.array2string($this->mailPreferences['htmlOptions'])); |
2252 | 2251 | try { |
2253 | - $bodyParts = $mail_bo->getMessageBody($_uid, ($this->mailPreferences['htmlOptions']?$this->mailPreferences['htmlOptions']:''), $_partID); |
|
2252 | + $bodyParts = $mail_bo->getMessageBody($_uid, ($this->mailPreferences['htmlOptions'] ? $this->mailPreferences['htmlOptions'] : ''), $_partID); |
|
2254 | 2253 | } |
2255 | 2254 | catch (Mail\Smime\PassphraseMissing $e) |
2256 | 2255 | { |
@@ -2260,52 +2259,52 @@ discard block |
||
2260 | 2259 | ' because the content of this message seems to be encrypted'. |
2261 | 2260 | ' and can not be decrypted properly. If you still wish to include'. |
2262 | 2261 | ' content of this encrypted message, you may try to use forward as'. |
2263 | - ' attachment instead.'),'error'); |
|
2262 | + ' attachment instead.'), 'error'); |
|
2264 | 2263 | } |
2265 | 2264 | //_debug_array($bodyParts); |
2266 | 2265 | $styles = Mail::getStyles($bodyParts); |
2267 | 2266 | |
2268 | - $fromAddress = implode(', ', str_replace(array('<','>'),array('[',']'),$headers['FROM'])); |
|
2267 | + $fromAddress = implode(', ', str_replace(array('<', '>'), array('[', ']'), $headers['FROM'])); |
|
2269 | 2268 | |
2270 | 2269 | $toAddressA = array(); |
2271 | 2270 | $toAddress = ''; |
2272 | 2271 | foreach ($headers['TO'] as $mailheader) { |
2273 | - $toAddressA[] = $mailheader; |
|
2272 | + $toAddressA[] = $mailheader; |
|
2274 | 2273 | } |
2275 | - if (count($toAddressA)>0) |
|
2274 | + if (count($toAddressA) > 0) |
|
2276 | 2275 | { |
2277 | - $toAddress = implode(', ', str_replace(array('<','>'),array('[',']'),$toAddressA)); |
|
2278 | - $toAddress = @htmlspecialchars(lang("to")).": ".$toAddress.($bodyParts['0']['mimeType'] == 'text/html'?"<br>":"\r\n"); |
|
2276 | + $toAddress = implode(', ', str_replace(array('<', '>'), array('[', ']'), $toAddressA)); |
|
2277 | + $toAddress = @htmlspecialchars(lang("to")).": ".$toAddress.($bodyParts['0']['mimeType'] == 'text/html' ? "<br>" : "\r\n"); |
|
2279 | 2278 | } |
2280 | 2279 | $ccAddressA = array(); |
2281 | 2280 | $ccAddress = ''; |
2282 | 2281 | foreach ($headers['CC'] as $mailheader) { |
2283 | - $ccAddressA[] = $mailheader; |
|
2282 | + $ccAddressA[] = $mailheader; |
|
2284 | 2283 | } |
2285 | - if (count($ccAddressA)>0) |
|
2284 | + if (count($ccAddressA) > 0) |
|
2286 | 2285 | { |
2287 | - $ccAddress = implode(', ', str_replace(array('<','>'),array('[',']'),$ccAddressA)); |
|
2288 | - $ccAddress = @htmlspecialchars(lang("cc")).": ".$ccAddress.($bodyParts['0']['mimeType'] == 'text/html'?"<br>":"\r\n"); |
|
2286 | + $ccAddress = implode(', ', str_replace(array('<', '>'), array('[', ']'), $ccAddressA)); |
|
2287 | + $ccAddress = @htmlspecialchars(lang("cc")).": ".$ccAddress.($bodyParts['0']['mimeType'] == 'text/html' ? "<br>" : "\r\n"); |
|
2289 | 2288 | } |
2290 | - if($bodyParts['0']['mimeType'] == 'text/html') { |
|
2291 | - $this->sessionData['body'] = /*"<br>".*//*" ".*/"<div>".'----------------'.lang("original message").'-----------------'."".'<br>'. |
|
2289 | + if ($bodyParts['0']['mimeType'] == 'text/html') { |
|
2290 | + $this->sessionData['body'] = /*"<br>".*//*" ".*/"<div>".'----------------'.lang("original message").'-----------------'."".'<br>'. |
|
2292 | 2291 | @htmlspecialchars(lang("from")).": ".$fromAddress."<br>". |
2293 | 2292 | $toAddress.$ccAddress. |
2294 | - @htmlspecialchars(lang("date").": ".$headers['DATE'],ENT_QUOTES | ENT_IGNORE,Mail::$displayCharset, false)."<br>". |
|
2293 | + @htmlspecialchars(lang("date").": ".$headers['DATE'], ENT_QUOTES|ENT_IGNORE, Mail::$displayCharset, false)."<br>". |
|
2295 | 2294 | '----------------------------------------------------------'."</div>"; |
2296 | - $this->sessionData['mimeType'] = 'html'; |
|
2295 | + $this->sessionData['mimeType'] = 'html'; |
|
2297 | 2296 | if (!empty($styles)) $this->sessionData['body'] .= $styles; |
2298 | - $this->sessionData['body'] .= '<blockquote type="cite">'; |
|
2297 | + $this->sessionData['body'] .= '<blockquote type="cite">'; |
|
2299 | 2298 | |
2300 | - for($i=0; $i<count($bodyParts); $i++) { |
|
2301 | - if($i>0) { |
|
2299 | + for ($i = 0; $i < count($bodyParts); $i++) { |
|
2300 | + if ($i > 0) { |
|
2302 | 2301 | $this->sessionData['body'] .= '<hr>'; |
2303 | 2302 | } |
2304 | - if($bodyParts[$i]['mimeType'] == 'text/plain') { |
|
2303 | + if ($bodyParts[$i]['mimeType'] == 'text/plain') { |
|
2305 | 2304 | #$bodyParts[$i]['body'] = nl2br($bodyParts[$i]['body'])."<br>"; |
2306 | 2305 | $bodyParts[$i]['body'] = "<pre>".$bodyParts[$i]['body']."</pre>"; |
2307 | 2306 | } |
2308 | - if ($bodyParts[$i]['charSet']===false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']); |
|
2307 | + if ($bodyParts[$i]['charSet'] === false) $bodyParts[$i]['charSet'] = Mail::detect_encoding($bodyParts[$i]['body']); |
|
2309 | 2308 | |
2310 | 2309 | $_htmlConfig = Mail::$htmLawed_config; |
2311 | 2310 | Mail::$htmLawed_config['comment'] = 2; |
@@ -2315,37 +2314,37 @@ discard block |
||
2315 | 2314 | #error_log( "GetReplyData (HTML) CharSet:".mb_detect_encoding($bodyParts[$i]['body'] . 'a' , strtoupper($bodyParts[$i]['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1')); |
2316 | 2315 | } |
2317 | 2316 | |
2318 | - $this->sessionData['body'] .= '</blockquote><br>'; |
|
2319 | - $this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID, 'html'); |
|
2317 | + $this->sessionData['body'] .= '</blockquote><br>'; |
|
2318 | + $this->sessionData['body'] = mail_ui::resolve_inline_images($this->sessionData['body'], $_folder, $_uid, $_partID, 'html'); |
|
2320 | 2319 | } else { |
2321 | 2320 | //$this->sessionData['body'] = @htmlspecialchars(lang("on")." ".$headers['DATE']." ".$mail_bo->decode_header($fromAddress), ENT_QUOTES) . " ".lang("wrote").":\r\n"; |
2322 | 2321 | // take care the way the ReplyHeader is created here, is used later on in uicompose::compose, in case you force replys to be HTML (prefs) |
2323 | - $this->sessionData['body'] = " \r\n \r\n".'----------------'.lang("original message").'-----------------'."\r\n". |
|
2322 | + $this->sessionData['body'] = " \r\n \r\n".'----------------'.lang("original message").'-----------------'."\r\n". |
|
2324 | 2323 | @htmlspecialchars(lang("from")).": ".$fromAddress."\r\n". |
2325 | 2324 | $toAddress.$ccAddress. |
2326 | - @htmlspecialchars(lang("date").": ".$headers['DATE'], ENT_QUOTES | ENT_IGNORE,Mail::$displayCharset, false)."\r\n". |
|
2325 | + @htmlspecialchars(lang("date").": ".$headers['DATE'], ENT_QUOTES|ENT_IGNORE, Mail::$displayCharset, false)."\r\n". |
|
2327 | 2326 | '-------------------------------------------------'."\r\n \r\n "; |
2328 | - $this->sessionData['mimeType'] = 'plain'; |
|
2327 | + $this->sessionData['mimeType'] = 'plain'; |
|
2329 | 2328 | |
2330 | - for($i=0; $i<count($bodyParts); $i++) { |
|
2331 | - if($i>0) { |
|
2329 | + for ($i = 0; $i < count($bodyParts); $i++) { |
|
2330 | + if ($i > 0) { |
|
2332 | 2331 | $this->sessionData['body'] .= "<hr>"; |
2333 | 2332 | } |
2334 | 2333 | |
2335 | 2334 | // add line breaks to $bodyParts |
2336 | - $newBody2 = Api\Translation::convert_jsonsafe($bodyParts[$i]['body'],$bodyParts[$i]['charSet']); |
|
2335 | + $newBody2 = Api\Translation::convert_jsonsafe($bodyParts[$i]['body'], $bodyParts[$i]['charSet']); |
|
2337 | 2336 | #error_log( "GetReplyData (Plain) CharSet:".mb_detect_encoding($bodyParts[$i]['body'] . 'a' , strtoupper($bodyParts[$i]['charSet']).','.strtoupper($this->displayCharset).',UTF-8, ISO-8859-1')); |
2338 | 2337 | $newBody = mail_ui::resolve_inline_images($newBody2, $_folder, $_uid, $_partID, 'plain'); |
2339 | 2338 | $this->sessionData['body'] .= "\r\n"; |
2340 | 2339 | $hasSignature = false; |
2341 | 2340 | // create body new, with good line breaks and indention |
2342 | - foreach(explode("\n",$newBody) as $value) { |
|
2341 | + foreach (explode("\n", $newBody) as $value) { |
|
2343 | 2342 | // the explode is removing the character |
2344 | 2343 | //$value .= 'ee'; |
2345 | 2344 | |
2346 | 2345 | // Try to remove signatures from qouted parts to avoid multiple |
2347 | 2346 | // signatures problem in reply (rfc3676#section-4.3). |
2348 | - if ($_mode != 'forward' && ($hasSignature || ($hasSignature = preg_match("/^--\s[\r\n]$/",$value)))) |
|
2347 | + if ($_mode != 'forward' && ($hasSignature || ($hasSignature = preg_match("/^--\s[\r\n]$/", $value)))) |
|
2349 | 2348 | { |
2350 | 2349 | continue; |
2351 | 2350 | } |
@@ -2353,12 +2352,12 @@ discard block |
||
2353 | 2352 | $numberOfChars = strspn(trim($value), ">"); |
2354 | 2353 | $appendString = str_repeat('>', $numberOfChars + 1); |
2355 | 2354 | |
2356 | - $bodyAppend = $this->mail_bo->wordwrap($value, 76-strlen("\r\n$appendString "), "\r\n$appendString ",'>'); |
|
2355 | + $bodyAppend = $this->mail_bo->wordwrap($value, 76 - strlen("\r\n$appendString "), "\r\n$appendString ", '>'); |
|
2357 | 2356 | |
2358 | - if($bodyAppend[0] == '>') { |
|
2359 | - $bodyAppend = '>'. $bodyAppend; |
|
2357 | + if ($bodyAppend[0] == '>') { |
|
2358 | + $bodyAppend = '>'.$bodyAppend; |
|
2360 | 2359 | } else { |
2361 | - $bodyAppend = '> '. $bodyAppend; |
|
2360 | + $bodyAppend = '> '.$bodyAppend; |
|
2362 | 2361 | } |
2363 | 2362 | |
2364 | 2363 | $this->sessionData['body'] .= $bodyAppend; |
@@ -2381,16 +2380,16 @@ discard block |
||
2381 | 2380 | */ |
2382 | 2381 | static function _getCleanHTML($_body, $_useTidy = false) |
2383 | 2382 | { |
2384 | - static $nonDisplayAbleCharacters = array('[\016]','[\017]', |
|
2385 | - '[\020]','[\021]','[\022]','[\023]','[\024]','[\025]','[\026]','[\027]', |
|
2386 | - '[\030]','[\031]','[\032]','[\033]','[\034]','[\035]','[\036]','[\037]'); |
|
2383 | + static $nonDisplayAbleCharacters = array('[\016]', '[\017]', |
|
2384 | + '[\020]', '[\021]', '[\022]', '[\023]', '[\024]', '[\025]', '[\026]', '[\027]', |
|
2385 | + '[\030]', '[\031]', '[\032]', '[\033]', '[\034]', '[\035]', '[\036]', '[\037]'); |
|
2387 | 2386 | |
2388 | - if ($_useTidy && extension_loaded('tidy') ) |
|
2387 | + if ($_useTidy && extension_loaded('tidy')) |
|
2389 | 2388 | { |
2390 | 2389 | $tidy = new tidy(); |
2391 | - $cleaned = $tidy->repairString($_body, Mail::$tidy_config,'utf8'); |
|
2390 | + $cleaned = $tidy->repairString($_body, Mail::$tidy_config, 'utf8'); |
|
2392 | 2391 | // Found errors. Strip it all so there's some output |
2393 | - if($tidy->getStatus() == 2) |
|
2392 | + if ($tidy->getStatus() == 2) |
|
2394 | 2393 | { |
2395 | 2394 | error_log(__METHOD__.' ('.__LINE__.') '.' ->'.$tidy->errorBuffer); |
2396 | 2395 | } |
@@ -2424,13 +2423,13 @@ discard block |
||
2424 | 2423 | * |
2425 | 2424 | * @return array returns found inline images as attachment structure |
2426 | 2425 | */ |
2427 | - function createMessage(Api\Mailer $_mailObject, array $_formData, array $_identity, $_autosaving=false) |
|
2426 | + function createMessage(Api\Mailer $_mailObject, array $_formData, array $_identity, $_autosaving = false) |
|
2428 | 2427 | { |
2429 | 2428 | if (substr($_formData['body'], 0, 27) == '-----BEGIN PGP MESSAGE-----') |
2430 | 2429 | { |
2431 | 2430 | $_formData['mimeType'] = 'openpgp'; |
2432 | 2431 | } |
2433 | - $mail_bo = $this->mail_bo; |
|
2432 | + $mail_bo = $this->mail_bo; |
|
2434 | 2433 | $activeMailProfile = Mail\Account::read($this->mail_bo->profileID); |
2435 | 2434 | |
2436 | 2435 | // you need to set the sender, if you work with different identities, since most smtp servers, dont allow |
@@ -2439,37 +2438,37 @@ discard block |
||
2439 | 2438 | { |
2440 | 2439 | error_log(__METHOD__.__LINE__.' Faking From/SenderInfo for '.$activeMailProfile['ident_email'].' with ID:'.$activeMailProfile['ident_id'].'. Identitiy to use for sending:'.array2string($_identity)); |
2441 | 2440 | } |
2442 | - $email_From = $_identity['ident_email'] ? $_identity['ident_email'] : $activeMailProfile['ident_email']; |
|
2441 | + $email_From = $_identity['ident_email'] ? $_identity['ident_email'] : $activeMailProfile['ident_email']; |
|
2443 | 2442 | // Try to fix identity email with no domain part set |
2444 | 2443 | $_mailObject->setFrom(Mail::fixInvalidAliasAddress(Api\Accounts::id2name($_identity['account_id'], 'account_email'), $email_From), |
2445 | - Mail::generateIdentityString($_identity,false)); |
|
2444 | + Mail::generateIdentityString($_identity, false)); |
|
2446 | 2445 | |
2447 | 2446 | $_mailObject->addHeader('X-Priority', $_formData['priority']); |
2448 | 2447 | $_mailObject->addHeader('X-Mailer', 'EGroupware-Mail'); |
2449 | - if(!empty($_formData['in-reply-to'])) { |
|
2450 | - if (stripos($_formData['in-reply-to'],'<')===false) $_formData['in-reply-to']='<'.trim($_formData['in-reply-to']).'>'; |
|
2448 | + if (!empty($_formData['in-reply-to'])) { |
|
2449 | + if (stripos($_formData['in-reply-to'], '<') === false) $_formData['in-reply-to'] = '<'.trim($_formData['in-reply-to']).'>'; |
|
2451 | 2450 | $_mailObject->addHeader('In-Reply-To', $_formData['in-reply-to']); |
2452 | 2451 | } |
2453 | - if(!empty($_formData['references'])) { |
|
2454 | - if (stripos($_formData['references'],'<')===false) |
|
2452 | + if (!empty($_formData['references'])) { |
|
2453 | + if (stripos($_formData['references'], '<') === false) |
|
2455 | 2454 | { |
2456 | - $_formData['references']='<'.trim($_formData['references']).'>'; |
|
2455 | + $_formData['references'] = '<'.trim($_formData['references']).'>'; |
|
2457 | 2456 | } |
2458 | 2457 | $_mailObject->addHeader('References', $_formData['references']); |
2459 | 2458 | } |
2460 | 2459 | |
2461 | - if(!empty($_formData['thread-index'])) { |
|
2460 | + if (!empty($_formData['thread-index'])) { |
|
2462 | 2461 | $_mailObject->addHeader('Thread-Index', $_formData['thread-index']); |
2463 | 2462 | } |
2464 | - if(!empty($_formData['list-id'])) { |
|
2463 | + if (!empty($_formData['list-id'])) { |
|
2465 | 2464 | $_mailObject->addHeader('List-Id', $_formData['list-id']); |
2466 | 2465 | } |
2467 | - if($_formData['disposition']=='on') { |
|
2466 | + if ($_formData['disposition'] == 'on') { |
|
2468 | 2467 | $_mailObject->addHeader('Disposition-Notification-To', $_identity['ident_email']); |
2469 | 2468 | } |
2470 | 2469 | |
2471 | 2470 | // Expand any mailing lists |
2472 | - foreach(array('to', 'cc', 'bcc', 'replyto') as $field) |
|
2471 | + foreach (array('to', 'cc', 'bcc', 'replyto') as $field) |
|
2473 | 2472 | { |
2474 | 2473 | if ($field != 'replyto') $_formData[$field] = self::resolveEmailAddressList($_formData[$field]); |
2475 | 2474 | |
@@ -2485,7 +2484,7 @@ discard block |
||
2485 | 2484 | } |
2486 | 2485 | $disableRuler = false; |
2487 | 2486 | $signature = $_identity['ident_signature']; |
2488 | - $sigAlreadyThere = $this->mailPreferences['insertSignatureAtTopOfMessage']!='no_belowaftersend'?1:0; |
|
2487 | + $sigAlreadyThere = $this->mailPreferences['insertSignatureAtTopOfMessage'] != 'no_belowaftersend' ? 1 : 0; |
|
2489 | 2488 | if ($sigAlreadyThere) |
2490 | 2489 | { |
2491 | 2490 | // note: if you use stationery ' s the insert signatures at the top does not apply here anymore, as the signature |
@@ -2494,7 +2493,7 @@ discard block |
||
2494 | 2493 | } |
2495 | 2494 | if ((isset($this->mailPreferences['disableRulerForSignatureSeparation']) && |
2496 | 2495 | $this->mailPreferences['disableRulerForSignatureSeparation']) || |
2497 | - empty($signature) || trim($this->convertHTMLToText($signature)) =='') |
|
2496 | + empty($signature) || trim($this->convertHTMLToText($signature)) == '') |
|
2498 | 2497 | { |
2499 | 2498 | $disableRuler = true; |
2500 | 2499 | } |
@@ -2520,13 +2519,13 @@ discard block |
||
2520 | 2519 | $body .= $attachment_links; |
2521 | 2520 | } |
2522 | 2521 | } |
2523 | - if(!empty($signature)) |
|
2522 | + if (!empty($signature)) |
|
2524 | 2523 | { |
2525 | 2524 | $_mailObject->setBody($this->convertHTMLToText($body, true, true). |
2526 | 2525 | ($disableRuler ? "\r\n" : "\r\n-- \r\n"). |
2527 | 2526 | $this->convertHTMLToText($signature, true, true)); |
2528 | 2527 | |
2529 | - $body .= ($disableRuler ?'<br>':'<hr style="border:1px dotted silver; width:90%;">').$signature; |
|
2528 | + $body .= ($disableRuler ? '<br>' : '<hr style="border:1px dotted silver; width:90%;">').$signature; |
|
2530 | 2529 | } |
2531 | 2530 | else |
2532 | 2531 | { |
@@ -2534,24 +2533,24 @@ discard block |
||
2534 | 2533 | } |
2535 | 2534 | // convert URL Images to inline images - if possible |
2536 | 2535 | if (!$_autosaving) $inline_images = Mail::processURL2InlineImages($_mailObject, $body, $mail_bo); |
2537 | - if (strpos($body,"<!-- HTMLSIGBEGIN -->")!==false) |
|
2536 | + if (strpos($body, "<!-- HTMLSIGBEGIN -->") !== false) |
|
2538 | 2537 | { |
2539 | - $body = str_replace(array('<!-- HTMLSIGBEGIN -->','<!-- HTMLSIGEND -->'),'',$body); |
|
2538 | + $body = str_replace(array('<!-- HTMLSIGBEGIN -->', '<!-- HTMLSIGEND -->'), '', $body); |
|
2540 | 2539 | } |
2541 | - $_mailObject->setHtmlBody($body, null, false); // false = no automatic alternative, we called setBody() |
|
2540 | + $_mailObject->setHtmlBody($body, null, false); // false = no automatic alternative, we called setBody() |
|
2542 | 2541 | break; |
2543 | 2542 | case 'openpgp': |
2544 | 2543 | $_mailObject->setOpenPgpBody($_formData['body']); |
2545 | 2544 | break; |
2546 | 2545 | default: |
2547 | - $body = $this->convertHTMLToText($_formData['body'],false, false, true, true); |
|
2546 | + $body = $this->convertHTMLToText($_formData['body'], false, false, true, true); |
|
2548 | 2547 | |
2549 | 2548 | if ($attachment_links) $body .= $attachment_links; |
2550 | 2549 | |
2551 | 2550 | #$_mailObject->Body = $_formData['body']; |
2552 | - if(!empty($signature)) { |
|
2553 | - $body .= ($disableRuler ?"\r\n":"\r\n-- \r\n"). |
|
2554 | - $this->convertHTMLToText($signature,true,true); |
|
2551 | + if (!empty($signature)) { |
|
2552 | + $body .= ($disableRuler ? "\r\n" : "\r\n-- \r\n"). |
|
2553 | + $this->convertHTMLToText($signature, true, true); |
|
2555 | 2554 | } |
2556 | 2555 | $_mailObject->setBody($body); |
2557 | 2556 | } |
@@ -2560,8 +2559,8 @@ discard block |
||
2560 | 2559 | { |
2561 | 2560 | $connection_opened = false; |
2562 | 2561 | $tnfattachments = null; |
2563 | - foreach((array)$_formData['attachments'] as $attachment) { |
|
2564 | - if(is_array($attachment)) |
|
2562 | + foreach ((array)$_formData['attachments'] as $attachment) { |
|
2563 | + if (is_array($attachment)) |
|
2565 | 2564 | { |
2566 | 2565 | if (!empty($attachment['uid']) && !empty($attachment['folder'])) { |
2567 | 2566 | /* Example: |
@@ -2579,20 +2578,20 @@ discard block |
||
2579 | 2578 | $connection_opened = true; |
2580 | 2579 | } |
2581 | 2580 | $mail_bo->reopen($attachment['folder']); |
2582 | - switch(strtoupper($attachment['type'])) { |
|
2581 | + switch (strtoupper($attachment['type'])) { |
|
2583 | 2582 | case 'MESSAGE/RFC': |
2584 | 2583 | case 'MESSAGE/RFC822': |
2585 | - $rawBody=''; |
|
2584 | + $rawBody = ''; |
|
2586 | 2585 | if (isset($attachment['partID'])) { |
2587 | - $eml = $mail_bo->getAttachment($attachment['uid'],$attachment['partID'],0,false,true,$attachment['folder']); |
|
2588 | - $rawBody=$eml['attachment']; |
|
2586 | + $eml = $mail_bo->getAttachment($attachment['uid'], $attachment['partID'], 0, false, true, $attachment['folder']); |
|
2587 | + $rawBody = $eml['attachment']; |
|
2589 | 2588 | } else { |
2590 | - $rawBody = $mail_bo->getMessageRawBody($attachment['uid'], $attachment['partID'],$attachment['folder']); |
|
2589 | + $rawBody = $mail_bo->getMessageRawBody($attachment['uid'], $attachment['partID'], $attachment['folder']); |
|
2591 | 2590 | } |
2592 | 2591 | $_mailObject->addStringAttachment($rawBody, $attachment['name'], 'message/rfc822'); |
2593 | 2592 | break; |
2594 | 2593 | default: |
2595 | - $attachmentData = $mail_bo->getAttachment($attachment['uid'], $attachment['partID'],0,false); |
|
2594 | + $attachmentData = $mail_bo->getAttachment($attachment['uid'], $attachment['partID'], 0, false); |
|
2596 | 2595 | if ($attachmentData['type'] == 'APPLICATION/MS-TNEF') |
2597 | 2596 | { |
2598 | 2597 | if (!is_array($tnfattachments)) $tnfattachments = $mail_bo->decode_winmail($attachment['uid'], $attachment['partID']); |
@@ -2600,7 +2599,7 @@ discard block |
||
2600 | 2599 | { |
2601 | 2600 | if ($k['name'] == $attachment['name']) |
2602 | 2601 | { |
2603 | - $tnfpart = $mail_bo->decode_winmail($attachment['uid'], $attachment['partID'],$k['is_winmail']); |
|
2602 | + $tnfpart = $mail_bo->decode_winmail($attachment['uid'], $attachment['partID'], $k['is_winmail']); |
|
2604 | 2603 | $attachmentData['attachment'] = $tnfpart['attachment']; |
2605 | 2604 | break; |
2606 | 2605 | } |
@@ -2613,7 +2612,7 @@ discard block |
||
2613 | 2612 | // attach files not for autosaving |
2614 | 2613 | elseif ($_formData['filemode'] == Vfs\Sharing::ATTACH && !$_autosaving) |
2615 | 2614 | { |
2616 | - if (isset($attachment['file']) && parse_url($attachment['file'],PHP_URL_SCHEME) == 'vfs') |
|
2615 | + if (isset($attachment['file']) && parse_url($attachment['file'], PHP_URL_SCHEME) == 'vfs') |
|
2617 | 2616 | { |
2618 | 2617 | Vfs::load_wrapper('vfs'); |
2619 | 2618 | $tmp_path = $attachment['file']; |
@@ -2622,7 +2621,7 @@ discard block |
||
2622 | 2621 | { |
2623 | 2622 | $tmp_path = $GLOBALS['egw_info']['server']['temp_dir'].'/'.basename($attachment['file']); |
2624 | 2623 | } |
2625 | - $_mailObject->addAttachment ( |
|
2624 | + $_mailObject->addAttachment( |
|
2626 | 2625 | $tmp_path, |
2627 | 2626 | $attachment['name'], |
2628 | 2627 | $attachment['type'] |
@@ -2632,7 +2631,7 @@ discard block |
||
2632 | 2631 | } |
2633 | 2632 | if ($connection_opened) $mail_bo->closeConnection(); |
2634 | 2633 | } |
2635 | - return is_array($inline_images)?$inline_images:array(); |
|
2634 | + return is_array($inline_images) ? $inline_images : array(); |
|
2636 | 2635 | } |
2637 | 2636 | |
2638 | 2637 | /** |
@@ -2648,16 +2647,16 @@ discard block |
||
2648 | 2647 | * @param string $password =null |
2649 | 2648 | * @return string might be empty if no file attachments found |
2650 | 2649 | */ |
2651 | - protected function _getAttachmentLinks(array $attachments, $filemode, $html, $recipients=array(), $expiration=null, $password=null) |
|
2650 | + protected function _getAttachmentLinks(array $attachments, $filemode, $html, $recipients = array(), $expiration = null, $password = null) |
|
2652 | 2651 | { |
2653 | 2652 | if ($filemode == Vfs\Sharing::ATTACH) return ''; |
2654 | 2653 | |
2655 | 2654 | $links = array(); |
2656 | - foreach($attachments as $attachment) |
|
2655 | + foreach ($attachments as $attachment) |
|
2657 | 2656 | { |
2658 | 2657 | $path = $attachment['file']; |
2659 | - if (empty($path)) continue; // we only care about file attachments, not forwarded messages or parts |
|
2660 | - if (parse_url($attachment['file'],PHP_URL_SCHEME) != 'vfs') |
|
2658 | + if (empty($path)) continue; // we only care about file attachments, not forwarded messages or parts |
|
2659 | + if (parse_url($attachment['file'], PHP_URL_SCHEME) != 'vfs') |
|
2661 | 2660 | { |
2662 | 2661 | $path = $GLOBALS['egw_info']['server']['temp_dir'].'/'.basename($path); |
2663 | 2662 | } |
@@ -2687,7 +2686,7 @@ discard block |
||
2687 | 2686 | } |
2688 | 2687 | if (!$links) |
2689 | 2688 | { |
2690 | - return null; // no file attachments found |
|
2689 | + return null; // no file attachments found |
|
2691 | 2690 | } |
2692 | 2691 | elseif ($html) |
2693 | 2692 | { |
@@ -2702,7 +2701,7 @@ discard block |
||
2702 | 2701 | * @param array $content content sent from client-side |
2703 | 2702 | * @param string $action ='button[saveAsDraft]' 'autosaving', 'button[saveAsDraft]' or 'button[saveAsDraftAndPrint]' |
2704 | 2703 | */ |
2705 | - public function ajax_saveAsDraft ($content, $action='button[saveAsDraft]') |
|
2704 | + public function ajax_saveAsDraft($content, $action = 'button[saveAsDraft]') |
|
2706 | 2705 | { |
2707 | 2706 | //error_log(__METHOD__.__LINE__.array2string($content)."(, action=$action)"); |
2708 | 2707 | $response = Api\Json\Response::get(); |
@@ -2716,8 +2715,8 @@ discard block |
||
2716 | 2715 | |
2717 | 2716 | $formData = array_merge($content, array( |
2718 | 2717 | 'isDrafted' => 1, |
2719 | - 'body' => $content['mail_'.($content['mimeType']?'htmltext':'plaintext')], |
|
2720 | - 'mimeType' => $content['mimeType']?'html':'plain' // checkbox has only true|false value |
|
2718 | + 'body' => $content['mail_'.($content['mimeType'] ? 'htmltext' : 'plaintext')], |
|
2719 | + 'mimeType' => $content['mimeType'] ? 'html' : 'plain' // checkbox has only true|false value |
|
2721 | 2720 | )); |
2722 | 2721 | |
2723 | 2722 | //Saving draft procedure |
@@ -2729,8 +2728,8 @@ discard block |
||
2729 | 2728 | if (($messageUid = $this->saveAsDraft($formData, $folder, $action))) |
2730 | 2729 | { |
2731 | 2730 | // saving as draft, does not mean closing the message |
2732 | - $messageUid = ($messageUid===true ? $status['uidnext'] : $messageUid); |
|
2733 | - if (is_array($this->mail_bo->getMessageHeader($messageUid, '',false, false, $folder))) |
|
2731 | + $messageUid = ($messageUid === true ? $status['uidnext'] : $messageUid); |
|
2732 | + if (is_array($this->mail_bo->getMessageHeader($messageUid, '', false, false, $folder))) |
|
2734 | 2733 | { |
2735 | 2734 | $draft_id = mail_ui::generateRowID($this->mail_bo->profileID, $folder, $messageUid); |
2736 | 2735 | if ($content['lastDrafted'] != $draft_id && isset($content['lastDrafted'])) |
@@ -2739,7 +2738,7 @@ discard block |
||
2739 | 2738 | $duid = $dhA['msgUID']; |
2740 | 2739 | $dmailbox = $dhA['folder']; |
2741 | 2740 | // beware: do not delete the original mail as found in processedmail_id |
2742 | - $pMuid=''; |
|
2741 | + $pMuid = ''; |
|
2743 | 2742 | if ($content['processedmail_id']) |
2744 | 2743 | { |
2745 | 2744 | $pMhA = mail_ui::splitRowID($content['processedmail_id']); |
@@ -2747,15 +2746,15 @@ discard block |
||
2747 | 2746 | } |
2748 | 2747 | //error_log(__METHOD__.__LINE__."#$pMuid#$pMuid!=$duid#".array2string($content['attachments'])); |
2749 | 2748 | // do not delete the original message if attachments are present |
2750 | - if (empty($pMuid) || $pMuid!=$duid || empty($content['attachments'])) |
|
2749 | + if (empty($pMuid) || $pMuid != $duid || empty($content['attachments'])) |
|
2751 | 2750 | { |
2752 | 2751 | try |
2753 | 2752 | { |
2754 | - $this->mail_bo->deleteMessages($duid,$dmailbox,'remove_immediately'); |
|
2753 | + $this->mail_bo->deleteMessages($duid, $dmailbox, 'remove_immediately'); |
|
2755 | 2754 | } |
2756 | 2755 | catch (Api\Exception $e) |
2757 | 2756 | { |
2758 | - $msg = str_replace('"',"'",$e->getMessage()); |
|
2757 | + $msg = str_replace('"', "'", $e->getMessage()); |
|
2759 | 2758 | $success = false; |
2760 | 2759 | error_log(__METHOD__.__LINE__.$msg); |
2761 | 2760 | } |
@@ -2776,7 +2775,7 @@ discard block |
||
2776 | 2775 | } |
2777 | 2776 | catch (Api\Exception\WrongUserinput $e) |
2778 | 2777 | { |
2779 | - $msg = str_replace('"',"'",$e->getMessage()); |
|
2778 | + $msg = str_replace('"', "'", $e->getMessage()); |
|
2780 | 2779 | error_log(__METHOD__.__LINE__.$msg); |
2781 | 2780 | $success = false; |
2782 | 2781 | } |
@@ -2800,17 +2799,17 @@ discard block |
||
2800 | 2799 | static function resolveEmailAddressList($_emailAddressList) |
2801 | 2800 | { |
2802 | 2801 | $contacts_obs = null; |
2803 | - $addrFromList=array(); |
|
2804 | - foreach((array)$_emailAddressList as $ak => $address) |
|
2802 | + $addrFromList = array(); |
|
2803 | + foreach ((array)$_emailAddressList as $ak => $address) |
|
2805 | 2804 | { |
2806 | - if(is_int($address)) |
|
2805 | + if (is_int($address)) |
|
2807 | 2806 | { |
2808 | 2807 | if (!isset($contacts_obs)) $contacts_obj = new Api\Contacts(); |
2809 | 2808 | // List was selected, expand to addresses |
2810 | 2809 | unset($_emailAddressList[$ak]); |
2811 | - $list = $contacts_obj->search('',array('n_fn','n_prefix','n_given','n_family','org_name','email','email_home'),'','','',False,'AND',false,array('list' =>(int)$address)); |
|
2810 | + $list = $contacts_obj->search('', array('n_fn', 'n_prefix', 'n_given', 'n_family', 'org_name', 'email', 'email_home'), '', '', '', False, 'AND', false, array('list' =>(int)$address)); |
|
2812 | 2811 | // Just add email addresses, they'll be checked below |
2813 | - foreach($list as $email) |
|
2812 | + foreach ($list as $email) |
|
2814 | 2813 | { |
2815 | 2814 | $addrFromList[] = $email['email'] ? $email['email'] : $email['email_home']; |
2816 | 2815 | } |
@@ -2820,7 +2819,7 @@ discard block |
||
2820 | 2819 | { |
2821 | 2820 | foreach ($addrFromList as $addr) |
2822 | 2821 | { |
2823 | - if (!empty($addr)) $_emailAddressList[]=$addr; |
|
2822 | + if (!empty($addr)) $_emailAddressList[] = $addr; |
|
2824 | 2823 | } |
2825 | 2824 | } |
2826 | 2825 | return is_array($_emailAddressList) ? array_values($_emailAddressList) : (array)$_emailAddressList; |
@@ -2834,15 +2833,15 @@ discard block |
||
2834 | 2833 | * @param string $action ='button[saveAsDraft]' 'autosaving', 'button[saveAsDraft]' or 'button[saveAsDraftAndPrint]' |
2835 | 2834 | * @return boolean return messageUID| false due to an error |
2836 | 2835 | */ |
2837 | - function saveAsDraft($_formData, &$savingDestination='', $action='button[saveAsDraft]') |
|
2836 | + function saveAsDraft($_formData, &$savingDestination = '', $action = 'button[saveAsDraft]') |
|
2838 | 2837 | { |
2839 | 2838 | //error_log(__METHOD__."(..., $savingDestination, action=$action)"); |
2840 | - $mail_bo = $this->mail_bo; |
|
2841 | - $mail = new Api\Mailer($this->mail_bo->profileID); |
|
2839 | + $mail_bo = $this->mail_bo; |
|
2840 | + $mail = new Api\Mailer($this->mail_bo->profileID); |
|
2842 | 2841 | |
2843 | 2842 | // preserve the bcc and if possible the save to folder information |
2844 | - $this->sessionData['folder'] = $_formData['folder']; |
|
2845 | - $this->sessionData['bcc'] = $_formData['bcc']; |
|
2843 | + $this->sessionData['folder'] = $_formData['folder']; |
|
2844 | + $this->sessionData['bcc'] = $_formData['bcc']; |
|
2846 | 2845 | $this->sessionData['mailidentity'] = $_formData['mailidentity']; |
2847 | 2846 | //$this->sessionData['stationeryID'] = $_formData['stationeryID']; |
2848 | 2847 | $this->sessionData['mailaccount'] = $_formData['mailaccount']; |
@@ -2851,11 +2850,11 @@ discard block |
||
2851 | 2850 | { |
2852 | 2851 | $acc = Mail\Account::read($this->sessionData['mailaccount']); |
2853 | 2852 | //error_log(__METHOD__.__LINE__.array2string($acc)); |
2854 | - $identity = Mail\Account::read_identity($acc['ident_id'],true); |
|
2853 | + $identity = Mail\Account::read_identity($acc['ident_id'], true); |
|
2855 | 2854 | } |
2856 | 2855 | catch (Exception $e) |
2857 | 2856 | { |
2858 | - $identity=array(); |
|
2857 | + $identity = array(); |
|
2859 | 2858 | } |
2860 | 2859 | |
2861 | 2860 | $flags = '\\Seen \\Draft'; |
@@ -2865,7 +2864,7 @@ discard block |
||
2865 | 2864 | // folder list as Customheader |
2866 | 2865 | if (!empty($this->sessionData['folder'])) |
2867 | 2866 | { |
2868 | - $folders = implode('|',array_unique($this->sessionData['folder'])); |
|
2867 | + $folders = implode('|', array_unique($this->sessionData['folder'])); |
|
2869 | 2868 | $mail->addHeader('X-Mailfolder', $folders); |
2870 | 2869 | } |
2871 | 2870 | $mail->addHeader('X-Mailidentity', $this->sessionData['mailidentity']); |
@@ -2885,25 +2884,25 @@ discard block |
||
2885 | 2884 | $savingDestination = $this->sessionData['messageFolder']; |
2886 | 2885 | //error_log(__METHOD__.__LINE__.' SavingDestination:'.$savingDestination); |
2887 | 2886 | } |
2888 | - if ( !empty($_formData['printit']) && $_formData['printit'] == 0 ) $savingDestination = $mail_bo->getDraftFolder(); |
|
2887 | + if (!empty($_formData['printit']) && $_formData['printit'] == 0) $savingDestination = $mail_bo->getDraftFolder(); |
|
2889 | 2888 | |
2890 | 2889 | // normaly Bcc is only added to recipients, but not as header visible to all recipients |
2891 | 2890 | $mail->forceBccHeader(); |
2892 | 2891 | |
2893 | 2892 | $mail_bo->openConnection(); |
2894 | - if ($mail_bo->folderExists($savingDestination,true)) { |
|
2893 | + if ($mail_bo->folderExists($savingDestination, true)) { |
|
2895 | 2894 | try |
2896 | 2895 | { |
2897 | 2896 | $messageUid = $mail_bo->appendMessage($savingDestination, $mail->getRaw(), null, $flags); |
2898 | 2897 | } |
2899 | 2898 | catch (Api\Exception\WrongUserinput $e) |
2900 | 2899 | { |
2901 | - error_log(__METHOD__.__LINE__.lang("Save of message %1 failed. Could not save message to folder %2 due to: %3",__METHOD__,$savingDestination,$e->getMessage())); |
|
2900 | + error_log(__METHOD__.__LINE__.lang("Save of message %1 failed. Could not save message to folder %2 due to: %3", __METHOD__, $savingDestination, $e->getMessage())); |
|
2902 | 2901 | return false; |
2903 | 2902 | } |
2904 | 2903 | |
2905 | 2904 | } else { |
2906 | - error_log(__METHOD__.__LINE__."->".lang("folder")." ". $savingDestination." ".lang("does not exist on IMAP Server.")); |
|
2905 | + error_log(__METHOD__.__LINE__."->".lang("folder")." ".$savingDestination." ".lang("does not exist on IMAP Server.")); |
|
2907 | 2906 | return false; |
2908 | 2907 | } |
2909 | 2908 | $mail_bo->closeConnection(); |
@@ -2912,28 +2911,28 @@ discard block |
||
2912 | 2911 | |
2913 | 2912 | function send($_formData) |
2914 | 2913 | { |
2915 | - $mail_bo = $this->mail_bo; |
|
2916 | - $mail = new Api\Mailer($mail_bo->profileID); |
|
2917 | - $messageIsDraft = false; |
|
2914 | + $mail_bo = $this->mail_bo; |
|
2915 | + $mail = new Api\Mailer($mail_bo->profileID); |
|
2916 | + $messageIsDraft = false; |
|
2918 | 2917 | |
2919 | - $this->sessionData['mailaccount'] = $_formData['mailaccount']; |
|
2918 | + $this->sessionData['mailaccount'] = $_formData['mailaccount']; |
|
2920 | 2919 | $this->sessionData['to'] = self::resolveEmailAddressList($_formData['to']); |
2921 | 2920 | $this->sessionData['cc'] = self::resolveEmailAddressList($_formData['cc']); |
2922 | - $this->sessionData['bcc'] = self::resolveEmailAddressList($_formData['bcc']); |
|
2923 | - $this->sessionData['folder'] = $_formData['folder']; |
|
2921 | + $this->sessionData['bcc'] = self::resolveEmailAddressList($_formData['bcc']); |
|
2922 | + $this->sessionData['folder'] = $_formData['folder']; |
|
2924 | 2923 | $this->sessionData['replyto'] = $_formData['replyto']; |
2925 | 2924 | $this->sessionData['subject'] = trim($_formData['subject']); |
2926 | - $this->sessionData['body'] = $_formData['body']; |
|
2927 | - $this->sessionData['priority'] = $_formData['priority']; |
|
2925 | + $this->sessionData['body'] = $_formData['body']; |
|
2926 | + $this->sessionData['priority'] = $_formData['priority']; |
|
2928 | 2927 | $this->sessionData['mailidentity'] = $_formData['mailidentity']; |
2929 | 2928 | //$this->sessionData['stationeryID'] = $_formData['stationeryID']; |
2930 | 2929 | $this->sessionData['disposition'] = $_formData['disposition']; |
2931 | - $this->sessionData['mimeType'] = $_formData['mimeType']; |
|
2930 | + $this->sessionData['mimeType'] = $_formData['mimeType']; |
|
2932 | 2931 | $this->sessionData['to_infolog'] = $_formData['to_infolog']; |
2933 | 2932 | $this->sessionData['to_tracker'] = $_formData['to_tracker']; |
2934 | - $this->sessionData['attachments'] = $_formData['attachments']; |
|
2935 | - $this->sessionData['smime_sign'] = $_formData['smime_sign']; |
|
2936 | - $this->sessionData['smime_encrypt'] = $_formData['smime_encrypt']; |
|
2933 | + $this->sessionData['attachments'] = $_formData['attachments']; |
|
2934 | + $this->sessionData['smime_sign'] = $_formData['smime_sign']; |
|
2935 | + $this->sessionData['smime_encrypt'] = $_formData['smime_encrypt']; |
|
2937 | 2936 | |
2938 | 2937 | if (isset($_formData['lastDrafted']) && !empty($_formData['lastDrafted'])) |
2939 | 2938 | { |
@@ -2942,11 +2941,11 @@ discard block |
||
2942 | 2941 | //error_log(__METHOD__.__LINE__.' Mode:'.$_formData['mode'].' PID:'.$_formData['processedmail_id']); |
2943 | 2942 | if (isset($_formData['mode']) && !empty($_formData['mode'])) |
2944 | 2943 | { |
2945 | - if ($_formData['mode']=='forward' && !empty($_formData['processedmail_id'])) |
|
2944 | + if ($_formData['mode'] == 'forward' && !empty($_formData['processedmail_id'])) |
|
2946 | 2945 | { |
2947 | - $this->sessionData['forwardFlag']='forwarded'; |
|
2948 | - $_formData['processedmail_id'] = explode(',',$_formData['processedmail_id']); |
|
2949 | - $this->sessionData['uid']=array(); |
|
2946 | + $this->sessionData['forwardFlag'] = 'forwarded'; |
|
2947 | + $_formData['processedmail_id'] = explode(',', $_formData['processedmail_id']); |
|
2948 | + $this->sessionData['uid'] = array(); |
|
2950 | 2949 | foreach ($_formData['processedmail_id'] as $k =>$rowid) |
2951 | 2950 | { |
2952 | 2951 | $fhA = mail_ui::splitRowID($rowid); |
@@ -2955,13 +2954,13 @@ discard block |
||
2955 | 2954 | if (!empty($fhA['folder'])) $this->sessionData['sourceFolder'] = $fhA['folder']; |
2956 | 2955 | } |
2957 | 2956 | } |
2958 | - if ($_formData['mode']=='reply' && !empty($_formData['processedmail_id'])) |
|
2957 | + if ($_formData['mode'] == 'reply' && !empty($_formData['processedmail_id'])) |
|
2959 | 2958 | { |
2960 | 2959 | $rhA = mail_ui::splitRowID($_formData['processedmail_id']); |
2961 | 2960 | $this->sessionData['uid'] = $rhA['msgUID']; |
2962 | 2961 | $this->sessionData['messageFolder'] = $rhA['folder']; |
2963 | 2962 | } |
2964 | - if ($_formData['mode']=='composefromdraft' && !empty($_formData['processedmail_id'])) |
|
2963 | + if ($_formData['mode'] == 'composefromdraft' && !empty($_formData['processedmail_id'])) |
|
2965 | 2964 | { |
2966 | 2965 | $dhA = mail_ui::splitRowID($_formData['processedmail_id']); |
2967 | 2966 | $this->sessionData['uid'] = $dhA['msgUID']; |
@@ -2970,26 +2969,26 @@ discard block |
||
2970 | 2969 | } |
2971 | 2970 | // if the body is empty, maybe someone pasted something with scripts, into the message body |
2972 | 2971 | // this should not happen anymore, unless you call send directly, since the check was introduced with the action command |
2973 | - if(empty($this->sessionData['body'])) |
|
2972 | + if (empty($this->sessionData['body'])) |
|
2974 | 2973 | { |
2975 | 2974 | // this is to be found with the egw_unset_vars array for the _POST['body'] array |
2976 | - $name='_POST'; |
|
2977 | - $key='body'; |
|
2975 | + $name = '_POST'; |
|
2976 | + $key = 'body'; |
|
2978 | 2977 | #error_log($GLOBALS['egw_unset_vars'][$name.'['.$key.']']); |
2979 | 2978 | if (isset($GLOBALS['egw_unset_vars'][$name.'['.$key.']'])) |
2980 | 2979 | { |
2981 | - $this->sessionData['body'] = self::_getCleanHTML( $GLOBALS['egw_unset_vars'][$name.'['.$key.']']); |
|
2982 | - $_formData['body']=$this->sessionData['body']; |
|
2980 | + $this->sessionData['body'] = self::_getCleanHTML($GLOBALS['egw_unset_vars'][$name.'['.$key.']']); |
|
2981 | + $_formData['body'] = $this->sessionData['body']; |
|
2983 | 2982 | } |
2984 | 2983 | #error_log($this->sessionData['body']); |
2985 | 2984 | } |
2986 | - if(empty($this->sessionData['to']) && empty($this->sessionData['cc']) && |
|
2985 | + if (empty($this->sessionData['to']) && empty($this->sessionData['cc']) && |
|
2987 | 2986 | empty($this->sessionData['bcc']) && empty($this->sessionData['folder'])) { |
2988 | 2987 | $messageIsDraft = true; |
2989 | 2988 | } |
2990 | 2989 | try |
2991 | 2990 | { |
2992 | - $identity = Mail\Account::read_identity((int)$this->sessionData['mailidentity'],true); |
|
2991 | + $identity = Mail\Account::read_identity((int)$this->sessionData['mailidentity'], true); |
|
2993 | 2992 | } |
2994 | 2993 | catch (Exception $e) |
2995 | 2994 | { |
@@ -3000,7 +2999,7 @@ discard block |
||
3000 | 2999 | // create the messages and store inline images |
3001 | 3000 | $inline_images = $this->createMessage($mail, $_formData, $identity); |
3002 | 3001 | // remember the identity |
3003 | - if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on') $fromAddress = $mail->From;//$mail->FromName.($mail->FromName?' <':'').$mail->From.($mail->FromName?'>':''); |
|
3002 | + if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on') $fromAddress = $mail->From; //$mail->FromName.($mail->FromName?' <':'').$mail->From.($mail->FromName?'>':''); |
|
3004 | 3003 | #print "<pre>". $mail->getMessageHeader() ."</pre><hr><br>"; |
3005 | 3004 | #print "<pre>". $mail->getMessageBody() ."</pre><hr><br>"; |
3006 | 3005 | #exit; |
@@ -3011,12 +3010,12 @@ discard block |
||
3011 | 3010 | $folderOnMailAccount = array(); |
3012 | 3011 | foreach ($folderToCheck as $k => $f) |
3013 | 3012 | { |
3014 | - $fval=$f; |
|
3015 | - $icServerID = $_formData['serverID'];//folders always assumed with serverID |
|
3016 | - if (stripos($f,'::')!==false) list($icServerID,$fval) = explode('::',$f,2); |
|
3017 | - if ($_formData['serverID']!=$_formData['mailaccount']) |
|
3013 | + $fval = $f; |
|
3014 | + $icServerID = $_formData['serverID']; //folders always assumed with serverID |
|
3015 | + if (stripos($f, '::') !== false) list($icServerID, $fval) = explode('::', $f, 2); |
|
3016 | + if ($_formData['serverID'] != $_formData['mailaccount']) |
|
3018 | 3017 | { |
3019 | - if ($icServerID == $_formData['serverID'] ) |
|
3018 | + if ($icServerID == $_formData['serverID']) |
|
3020 | 3019 | { |
3021 | 3020 | $folder[$fval] = $fval; |
3022 | 3021 | $folderOnServerID[] = $fval; |
@@ -3029,7 +3028,7 @@ discard block |
||
3029 | 3028 | } |
3030 | 3029 | else |
3031 | 3030 | { |
3032 | - if ($icServerID == $_formData['serverID'] ) |
|
3031 | + if ($icServerID == $_formData['serverID']) |
|
3033 | 3032 | { |
3034 | 3033 | $folder[$fval] = $fval; |
3035 | 3034 | $folderOnServerID[] = $fval; |
@@ -3046,7 +3045,7 @@ discard block |
||
3046 | 3045 | // we use the sentFolder settings of the choosen mailaccount |
3047 | 3046 | // sentFolder is account specific |
3048 | 3047 | $changeProfileOnSentFolderNeeded = false; |
3049 | - if ($_formData['serverID']!=$_formData['mailaccount']) |
|
3048 | + if ($_formData['serverID'] != $_formData['mailaccount']) |
|
3050 | 3049 | { |
3051 | 3050 | $this->changeProfile($_formData['mailaccount']); |
3052 | 3051 | //error_log(__METHOD__.__LINE__.'#'.$this->mail_bo->profileID.'<->'.$mail_bo->profileID.'#'); |
@@ -3054,30 +3053,30 @@ discard block |
||
3054 | 3053 | // sentFolder is account specific |
3055 | 3054 | $sentFolder = $this->mail_bo->getSentFolder(); |
3056 | 3055 | //error_log(__METHOD__.__LINE__.' SentFolder configured:'.$sentFolder.'#'); |
3057 | - if ($sentFolder&& $sentFolder!= 'none' && !$this->mail_bo->folderExists($sentFolder, true)) $sentFolder=false; |
|
3056 | + if ($sentFolder && $sentFolder != 'none' && !$this->mail_bo->folderExists($sentFolder, true)) $sentFolder = false; |
|
3058 | 3057 | } |
3059 | 3058 | else |
3060 | 3059 | { |
3061 | 3060 | $sentFolder = $mail_bo->getSentFolder(); |
3062 | 3061 | //error_log(__METHOD__.__LINE__.' SentFolder configured:'.$sentFolder.'#'); |
3063 | - if ($sentFolder&& $sentFolder!= 'none' && !$mail_bo->folderExists($sentFolder, true)) $sentFolder=false; |
|
3062 | + if ($sentFolder && $sentFolder != 'none' && !$mail_bo->folderExists($sentFolder, true)) $sentFolder = false; |
|
3064 | 3063 | } |
3065 | 3064 | //error_log(__METHOD__.__LINE__.' SentFolder configured:'.$sentFolder.'#'); |
3066 | 3065 | |
3067 | 3066 | // we switch $this->mail_bo back to the account we used to work on |
3068 | - if ($_formData['serverID']!=$_formData['mailaccount']) |
|
3067 | + if ($_formData['serverID'] != $_formData['mailaccount']) |
|
3069 | 3068 | { |
3070 | 3069 | $this->changeProfile($_formData['serverID']); |
3071 | 3070 | } |
3072 | 3071 | |
3073 | 3072 | |
3074 | - if(isset($sentFolder) && $sentFolder && $sentFolder != 'none' && |
|
3073 | + if (isset($sentFolder) && $sentFolder && $sentFolder != 'none' && |
|
3075 | 3074 | $this->mailPreferences['sendOptions'] != 'send_only' && |
3076 | 3075 | $messageIsDraft == false) |
3077 | 3076 | { |
3078 | 3077 | if ($sentFolder) |
3079 | 3078 | { |
3080 | - if ($_formData['serverID']!=$_formData['mailaccount']) |
|
3079 | + if ($_formData['serverID'] != $_formData['mailaccount']) |
|
3081 | 3080 | { |
3082 | 3081 | $folderOnMailAccount[] = $sentFolder; |
3083 | 3082 | } |
@@ -3094,14 +3093,14 @@ discard block |
||
3094 | 3093 | } |
3095 | 3094 | else |
3096 | 3095 | { |
3097 | - if (((!isset($sentFolder)||$sentFolder==false) && $this->mailPreferences['sendOptions'] != 'send_only') || |
|
3096 | + if (((!isset($sentFolder) || $sentFolder == false) && $this->mailPreferences['sendOptions'] != 'send_only') || |
|
3098 | 3097 | ($this->mailPreferences['sendOptions'] != 'send_only' && |
3099 | 3098 | $sentFolder != 'none')) $this->errorInfo = lang("No Send Folder set in preferences"); |
3100 | 3099 | } |
3101 | 3100 | // draftFolder is on Server we start from |
3102 | - if($messageIsDraft == true) { |
|
3101 | + if ($messageIsDraft == true) { |
|
3103 | 3102 | $draftFolder = $mail_bo->getDraftFolder(); |
3104 | - if(!empty($draftFolder) && $mail_bo->folderExists($draftFolder,true)) { |
|
3103 | + if (!empty($draftFolder) && $mail_bo->folderExists($draftFolder, true)) { |
|
3105 | 3104 | $this->sessionData['folder'] = array($draftFolder); |
3106 | 3105 | $folderOnServerID[] = $draftFolder; |
3107 | 3106 | $folder[$draftFolder] = $draftFolder; |
@@ -3110,18 +3109,18 @@ discard block |
||
3110 | 3109 | if ($folderOnServerID) $folderOnServerID = array_unique($folderOnServerID); |
3111 | 3110 | if ($folderOnMailAccount) $folderOnMailAccount = array_unique($folderOnMailAccount); |
3112 | 3111 | if (($this->mailPreferences['sendOptions'] != 'send_only' && $sentFolder != 'none') && |
3113 | - !( count($folder) > 0) && |
|
3114 | - !($_formData['to_infolog']=='on' || $_formData['to_tracker']=='on')) |
|
3112 | + !(count($folder) > 0) && |
|
3113 | + !($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on')) |
|
3115 | 3114 | { |
3116 | - $this->errorInfo = lang("Error: ").lang("No Folder destination supplied, and no folder to save message or other measure to store the mail (save to infolog/tracker) provided, but required.").($this->errorInfo?' '.$this->errorInfo:''); |
|
3115 | + $this->errorInfo = lang("Error: ").lang("No Folder destination supplied, and no folder to save message or other measure to store the mail (save to infolog/tracker) provided, but required.").($this->errorInfo ? ' '.$this->errorInfo : ''); |
|
3117 | 3116 | #error_log($this->errorInfo); |
3118 | 3117 | return false; |
3119 | 3118 | } |
3120 | 3119 | // SMIME SIGN/ENCRYPTION |
3121 | - if ($_formData['smime_sign'] == 'on' || $_formData['smime_encrypt'] == 'on' ) |
|
3120 | + if ($_formData['smime_sign'] == 'on' || $_formData['smime_encrypt'] == 'on') |
|
3122 | 3121 | { |
3123 | - $recipients = array_merge($_formData['to'], (array) $_formData['cc'], (array) $_formData['bcc']); |
|
3124 | - try { |
|
3122 | + $recipients = array_merge($_formData['to'], (array)$_formData['cc'], (array)$_formData['bcc']); |
|
3123 | + try { |
|
3125 | 3124 | if ($_formData['smime_sign'] == 'on') |
3126 | 3125 | { |
3127 | 3126 | if ($_formData['smime_passphrase'] != '') { |
@@ -3134,7 +3133,7 @@ discard block |
||
3134 | 3133 | } |
3135 | 3134 | $smime_success = $this->_encrypt( |
3136 | 3135 | $mail, |
3137 | - $_formData['smime_encrypt'] == 'on'? Mail\Smime::TYPE_SIGN_ENCRYPT: Mail\Smime::TYPE_SIGN, |
|
3136 | + $_formData['smime_encrypt'] == 'on' ? Mail\Smime::TYPE_SIGN_ENCRYPT : Mail\Smime::TYPE_SIGN, |
|
3138 | 3137 | Mail::stripRFC822Addresses($recipients), |
3139 | 3138 | $identity['ident_email'], |
3140 | 3139 | $_formData['smime_passphrase'] |
@@ -3142,16 +3141,15 @@ discard block |
||
3142 | 3141 | if (!$smime_success) |
3143 | 3142 | { |
3144 | 3143 | $response = Api\Json\Response::get(); |
3145 | - $this->errorInfo = $_formData['smime_passphrase'] == ''? |
|
3146 | - lang('You need to enter your S/MIME passphrase to send this message.'): |
|
3147 | - lang('The entered passphrase is not correct! Please try again.'); |
|
3144 | + $this->errorInfo = $_formData['smime_passphrase'] == '' ? |
|
3145 | + lang('You need to enter your S/MIME passphrase to send this message.') : lang('The entered passphrase is not correct! Please try again.'); |
|
3148 | 3146 | $response->call('app.mail.smimePassDialog', $this->errorInfo); |
3149 | 3147 | return false; |
3150 | 3148 | } |
3151 | 3149 | } |
3152 | 3150 | elseif ($_formData['smime_sign'] == 'off' && $_formData['smime_encrypt'] == 'on') |
3153 | 3151 | { |
3154 | - $smime_success = $this->_encrypt( |
|
3152 | + $smime_success = $this->_encrypt( |
|
3155 | 3153 | $mail, |
3156 | 3154 | Mail\Smime::TYPE_ENCRYPT, |
3157 | 3155 | Mail::stripRFC822Addresses($recipients), |
@@ -3171,23 +3169,23 @@ discard block |
||
3171 | 3169 | @set_time_limit(120); |
3172 | 3170 | //$mail->SMTPDebug = 10; |
3173 | 3171 | //error_log("Folder:".count(array($this->sessionData['folder']))."To:".count((array)$this->sessionData['to'])."CC:". count((array)$this->sessionData['cc']) ."bcc:".count((array)$this->sessionData['bcc'])); |
3174 | - if(count((array)$this->sessionData['to']) > 0 || count((array)$this->sessionData['cc']) > 0 || count((array)$this->sessionData['bcc']) > 0) { |
|
3172 | + if (count((array)$this->sessionData['to']) > 0 || count((array)$this->sessionData['cc']) > 0 || count((array)$this->sessionData['bcc']) > 0) { |
|
3175 | 3173 | try { |
3176 | 3174 | // do no close the session before sending, if we have to store the send text for infolog or other integration in the session |
3177 | - if (!($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on' || $_formData['to_calendar'] == 'on' )) |
|
3175 | + if (!($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on' || $_formData['to_calendar'] == 'on')) |
|
3178 | 3176 | { |
3179 | 3177 | $GLOBALS['egw']->session->commit_session(); |
3180 | 3178 | } |
3181 | 3179 | $mail->send(); |
3182 | 3180 | } |
3183 | - catch(Exception $e) { |
|
3181 | + catch (Exception $e) { |
|
3184 | 3182 | _egw_log_exception($e); |
3185 | 3183 | //if( $e->details ) error_log(__METHOD__.__LINE__.array2string($e->details)); |
3186 | - $this->errorInfo = $e->getMessage().($e->details?'<br/>'.$e->details:''); |
|
3184 | + $this->errorInfo = $e->getMessage().($e->details ? '<br/>'.$e->details : ''); |
|
3187 | 3185 | return false; |
3188 | 3186 | } |
3189 | 3187 | } else { |
3190 | - if (count(array($this->sessionData['folder']))>0 && !empty($this->sessionData['folder'])) { |
|
3188 | + if (count(array($this->sessionData['folder'])) > 0 && !empty($this->sessionData['folder'])) { |
|
3191 | 3189 | //error_log(__METHOD__.__LINE__."Folders:".print_r($this->sessionData['folder'],true)); |
3192 | 3190 | } else { |
3193 | 3191 | $this->errorInfo = lang("Error: ").lang("No Address TO/CC/BCC supplied, and no folder to save message to provided."); |
@@ -3215,15 +3213,15 @@ discard block |
||
3215 | 3213 | // copying mail to folder |
3216 | 3214 | if (count($folder) > 0) |
3217 | 3215 | { |
3218 | - foreach($folderOnServerID as $folderName) { |
|
3216 | + foreach ($folderOnServerID as $folderName) { |
|
3219 | 3217 | if (is_array($folderName)) $folderName = array_shift($folderName); // should not happen at all |
3220 | 3218 | //error_log(__METHOD__.__LINE__." attempt to save message to:".array2string($folderName)); |
3221 | 3219 | // if $_formData['serverID']!=$_formData['mailaccount'] skip copying to sentfolder on serverID |
3222 | 3220 | // if($_formData['serverID']!=$_formData['mailaccount'] && $folderName==$sentFolder && $changeProfileOnSentFolderNeeded) continue; |
3223 | - if ($mail_bo->folderExists($folderName,true)) { |
|
3224 | - if($mail_bo->isSentFolder($folderName)) { |
|
3221 | + if ($mail_bo->folderExists($folderName, true)) { |
|
3222 | + if ($mail_bo->isSentFolder($folderName)) { |
|
3225 | 3223 | $flags = '\\Seen'; |
3226 | - } elseif($mail_bo->isDraftFolder($folderName)) { |
|
3224 | + } elseif ($mail_bo->isDraftFolder($folderName)) { |
|
3227 | 3225 | $flags = '\\Draft'; |
3228 | 3226 | } else { |
3229 | 3227 | $flags = '\\Seen'; |
@@ -3239,25 +3237,25 @@ discard block |
||
3239 | 3237 | } |
3240 | 3238 | catch (Api\Exception\WrongUserinput $e) |
3241 | 3239 | { |
3242 | - error_log(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Could not save message to folder %2 due to: %3",$this->sessionData['subject'],$folderName,$e->getMessage())); |
|
3240 | + error_log(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Could not save message to folder %2 due to: %3", $this->sessionData['subject'], $folderName, $e->getMessage())); |
|
3243 | 3241 | } |
3244 | 3242 | } |
3245 | 3243 | else |
3246 | 3244 | { |
3247 | - error_log(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.",$this->sessionData['subject'],$folderName)); |
|
3245 | + error_log(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.", $this->sessionData['subject'], $folderName)); |
|
3248 | 3246 | } |
3249 | 3247 | } |
3250 | 3248 | // if we choose to send from a differing profile |
3251 | 3249 | if ($folderOnMailAccount) $this->changeProfile($_formData['mailaccount']); |
3252 | - foreach($folderOnMailAccount as $folderName) { |
|
3250 | + foreach ($folderOnMailAccount as $folderName) { |
|
3253 | 3251 | if (is_array($folderName)) $folderName = array_shift($folderName); // should not happen at all |
3254 | 3252 | //error_log(__METHOD__.__LINE__." attempt to save message to:".array2string($folderName)); |
3255 | 3253 | // if $_formData['serverID']!=$_formData['mailaccount'] skip copying to sentfolder on serverID |
3256 | 3254 | // if($_formData['serverID']!=$_formData['mailaccount'] && $folderName==$sentFolder && $changeProfileOnSentFolderNeeded) continue; |
3257 | - if ($this->mail_bo->folderExists($folderName,true)) { |
|
3258 | - if($this->mail_bo->isSentFolder($folderName)) { |
|
3255 | + if ($this->mail_bo->folderExists($folderName, true)) { |
|
3256 | + if ($this->mail_bo->isSentFolder($folderName)) { |
|
3259 | 3257 | $flags = '\\Seen'; |
3260 | - } elseif($this->mail_bo->isDraftFolder($folderName)) { |
|
3258 | + } elseif ($this->mail_bo->isDraftFolder($folderName)) { |
|
3261 | 3259 | $flags = '\\Draft'; |
3262 | 3260 | } else { |
3263 | 3261 | $flags = '\\Seen'; |
@@ -3273,12 +3271,12 @@ discard block |
||
3273 | 3271 | } |
3274 | 3272 | catch (Api\Exception\WrongUserinput $e) |
3275 | 3273 | { |
3276 | - error_log(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Could not save message to folder %2 due to: %3",$this->sessionData['subject'],$folderName,$e->getMessage())); |
|
3274 | + error_log(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Could not save message to folder %2 due to: %3", $this->sessionData['subject'], $folderName, $e->getMessage())); |
|
3277 | 3275 | } |
3278 | 3276 | } |
3279 | 3277 | else |
3280 | 3278 | { |
3281 | - error_log(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.",$this->sessionData['subject'],$folderName)); |
|
3279 | + error_log(__METHOD__.__LINE__.'->'.lang("Import of message %1 failed. Destination Folder %2 does not exist.", $this->sessionData['subject'], $folderName)); |
|
3282 | 3280 | } |
3283 | 3281 | } |
3284 | 3282 | if ($folderOnMailAccount) $this->changeProfile($_formData['serverID']); |
@@ -3289,27 +3287,27 @@ discard block |
||
3289 | 3287 | $lastDrafted = false; |
3290 | 3288 | if (isset($this->sessionData['lastDrafted'])) |
3291 | 3289 | { |
3292 | - $lastDrafted=array(); |
|
3290 | + $lastDrafted = array(); |
|
3293 | 3291 | $dhA = mail_ui::splitRowID($this->sessionData['lastDrafted']); |
3294 | 3292 | $lastDrafted['uid'] = $dhA['msgUID']; |
3295 | 3293 | $lastDrafted['folder'] = $dhA['folder']; |
3296 | - if (isset($lastDrafted['uid']) && !empty($lastDrafted['uid'])) $lastDrafted['uid']=trim($lastDrafted['uid']); |
|
3294 | + if (isset($lastDrafted['uid']) && !empty($lastDrafted['uid'])) $lastDrafted['uid'] = trim($lastDrafted['uid']); |
|
3297 | 3295 | // manually drafted, do not delete |
3298 | 3296 | // will be handled later on IF mode was $_formData['mode']=='composefromdraft' |
3299 | - if (isset($lastDrafted['uid']) && (empty($lastDrafted['uid']) || $lastDrafted['uid'] == $this->sessionData['uid'])) $lastDrafted=false; |
|
3297 | + if (isset($lastDrafted['uid']) && (empty($lastDrafted['uid']) || $lastDrafted['uid'] == $this->sessionData['uid'])) $lastDrafted = false; |
|
3300 | 3298 | //error_log(__METHOD__.__LINE__.array2string($lastDrafted)); |
3301 | 3299 | } |
3302 | 3300 | if ($lastDrafted && is_array($lastDrafted) && $mail_bo->isDraftFolder($lastDrafted['folder'])) |
3303 | 3301 | { |
3304 | 3302 | try |
3305 | 3303 | { |
3306 | - if ($this->sessionData['lastDrafted'] != $this->sessionData['uid'] || !($_formData['mode']=='composefromdraft' && |
|
3307 | - ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on' || $_formData['to_calendar'] == 'on' )&&$this->sessionData['attachments'])) |
|
3304 | + if ($this->sessionData['lastDrafted'] != $this->sessionData['uid'] || !($_formData['mode'] == 'composefromdraft' && |
|
3305 | + ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on' || $_formData['to_calendar'] == 'on') && $this->sessionData['attachments'])) |
|
3308 | 3306 | { |
3309 | 3307 | //error_log(__METHOD__.__LINE__."#".$lastDrafted['uid'].'#'.$lastDrafted['folder'].array2string($_formData)); |
3310 | 3308 | //error_log(__METHOD__.__LINE__."#".array2string($_formData)); |
3311 | 3309 | //error_log(__METHOD__.__LINE__."#".array2string($this->sessionData)); |
3312 | - $mail_bo->deleteMessages($lastDrafted['uid'],$lastDrafted['folder'],'remove_immediately'); |
|
3310 | + $mail_bo->deleteMessages($lastDrafted['uid'], $lastDrafted['folder'], 'remove_immediately'); |
|
3313 | 3311 | } |
3314 | 3312 | } |
3315 | 3313 | catch (Api\Exception $e) |
@@ -3321,22 +3319,22 @@ discard block |
||
3321 | 3319 | unset($this->sessionData['lastDrafted']); |
3322 | 3320 | |
3323 | 3321 | //error_log("handling draft messages, flagging and such"); |
3324 | - if((isset($this->sessionData['uid']) && isset($this->sessionData['messageFolder'])) |
|
3322 | + if ((isset($this->sessionData['uid']) && isset($this->sessionData['messageFolder'])) |
|
3325 | 3323 | || (isset($this->sessionData['forwardFlag']) && isset($this->sessionData['sourceFolder']))) { |
3326 | 3324 | // mark message as answered |
3327 | 3325 | $mail_bo->openConnection(); |
3328 | - $mail_bo->reopen(($this->sessionData['messageFolder']?$this->sessionData['messageFolder']:$this->sessionData['sourceFolder'])); |
|
3326 | + $mail_bo->reopen(($this->sessionData['messageFolder'] ? $this->sessionData['messageFolder'] : $this->sessionData['sourceFolder'])); |
|
3329 | 3327 | // if the draft folder is a starting part of the messages folder, the draft message will be deleted after the send |
3330 | 3328 | // unless your templatefolder is a subfolder of your draftfolder, and the message is in there |
3331 | 3329 | if ($mail_bo->isDraftFolder($this->sessionData['messageFolder']) && !$mail_bo->isTemplateFolder($this->sessionData['messageFolder'])) |
3332 | 3330 | { |
3333 | 3331 | try // message may be deleted already, as it maybe done by autosave |
3334 | 3332 | { |
3335 | - if ($_formData['mode']=='composefromdraft' && |
|
3333 | + if ($_formData['mode'] == 'composefromdraft' && |
|
3336 | 3334 | !(($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on' || $_formData['to_calendar'] == 'on') && $this->sessionData['attachments'])) |
3337 | 3335 | { |
3338 | 3336 | //error_log(__METHOD__.__LINE__."#".$this->sessionData['uid'].'#'.$this->sessionData['messageFolder']); |
3339 | - $mail_bo->deleteMessages(array($this->sessionData['uid']),$this->sessionData['messageFolder'], 'remove_immediately'); |
|
3337 | + $mail_bo->deleteMessages(array($this->sessionData['uid']), $this->sessionData['messageFolder'], 'remove_immediately'); |
|
3340 | 3338 | } |
3341 | 3339 | } |
3342 | 3340 | catch (Api\Exception $e) |
@@ -3345,14 +3343,14 @@ discard block |
||
3345 | 3343 | unset($e); |
3346 | 3344 | } |
3347 | 3345 | } else { |
3348 | - $mail_bo->flagMessages("answered", $this->sessionData['uid'],($this->sessionData['messageFolder']?$this->sessionData['messageFolder']:$this->sessionData['sourceFolder'])); |
|
3346 | + $mail_bo->flagMessages("answered", $this->sessionData['uid'], ($this->sessionData['messageFolder'] ? $this->sessionData['messageFolder'] : $this->sessionData['sourceFolder'])); |
|
3349 | 3347 | //error_log(__METHOD__.__LINE__.array2string(array_keys($this->sessionData)).':'.array2string($this->sessionData['forwardedUID']).' F:'.$this->sessionData['sourceFolder']); |
3350 | - if (array_key_exists('forwardFlag',$this->sessionData) && $this->sessionData['forwardFlag']=='forwarded') |
|
3348 | + if (array_key_exists('forwardFlag', $this->sessionData) && $this->sessionData['forwardFlag'] == 'forwarded') |
|
3351 | 3349 | { |
3352 | 3350 | try |
3353 | 3351 | { |
3354 | 3352 | //error_log(__METHOD__.__LINE__.':'.array2string($this->sessionData['forwardedUID']).' F:'.$this->sessionData['sourceFolder']); |
3355 | - $mail_bo->flagMessages("forwarded", $this->sessionData['forwardedUID'],$this->sessionData['sourceFolder']); |
|
3353 | + $mail_bo->flagMessages("forwarded", $this->sessionData['forwardedUID'], $this->sessionData['sourceFolder']); |
|
3356 | 3354 | } |
3357 | 3355 | catch (Api\Exception $e) |
3358 | 3356 | { |
@@ -3380,49 +3378,49 @@ discard block |
||
3380 | 3378 | if (is_array($this->sessionData['bcc'])) $mailaddresses['bcc'] = $this->sessionData['bcc']; |
3381 | 3379 | if (!empty($mailaddresses)) $mailaddresses['from'] = Mail\Html::decodeMailHeader($fromAddress); |
3382 | 3380 | |
3383 | - if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on' || $_formData['to_calendar'] == 'on' ) |
|
3381 | + if ($_formData['to_infolog'] == 'on' || $_formData['to_tracker'] == 'on' || $_formData['to_calendar'] == 'on') |
|
3384 | 3382 | { |
3385 | 3383 | $this->sessionData['attachments'] = array_merge((array)$this->sessionData['attachments'], (array)$inline_images); |
3386 | 3384 | |
3387 | - foreach(array('to_infolog','to_tracker','to_calendar') as $app_key) |
|
3385 | + foreach (array('to_infolog', 'to_tracker', 'to_calendar') as $app_key) |
|
3388 | 3386 | { |
3389 | 3387 | $entryid = $_formData['to_integrate_ids'][0][$app_key]; |
3390 | 3388 | if ($_formData[$app_key] == 'on') |
3391 | 3389 | { |
3392 | - $app_name = substr($app_key,3); |
|
3390 | + $app_name = substr($app_key, 3); |
|
3393 | 3391 | // Get registered hook data of the app called for integration |
3394 | - $hook = Api\Hooks::single(array('location'=> 'mail_import'),$app_name); |
|
3392 | + $hook = Api\Hooks::single(array('location'=> 'mail_import'), $app_name); |
|
3395 | 3393 | |
3396 | 3394 | // store mail / eml in temp. file to not have to download it from mail-server again |
3397 | - $eml = tempnam($GLOBALS['egw_info']['server']['temp_dir'],'mail_integrate'); |
|
3395 | + $eml = tempnam($GLOBALS['egw_info']['server']['temp_dir'], 'mail_integrate'); |
|
3398 | 3396 | $eml_fp = fopen($eml, 'w'); |
3399 | 3397 | stream_copy_to_stream($mail->getRaw(), $eml_fp); |
3400 | 3398 | fclose($eml_fp); |
3401 | 3399 | $target = array( |
3402 | 3400 | 'menuaction' => $hook['menuaction'], |
3403 | - 'egw_data' => Link::set_data(null,'mail_integration::integrate',array( |
|
3401 | + 'egw_data' => Link::set_data(null, 'mail_integration::integrate', array( |
|
3404 | 3402 | $mailaddresses, |
3405 | 3403 | $this->sessionData['subject'], |
3406 | 3404 | $this->convertHTMLToText($this->sessionData['body']), |
3407 | 3405 | $this->sessionData['attachments'], |
3408 | 3406 | false, // date |
3409 | 3407 | $eml, |
3410 | - $_formData['serverID']),true), |
|
3408 | + $_formData['serverID']), true), |
|
3411 | 3409 | 'app' => $app_name |
3412 | 3410 | ); |
3413 | 3411 | if ($entryid) $target['entry_id'] = $entryid; |
3414 | 3412 | // Open the app called for integration in a popup |
3415 | 3413 | // and store the mail raw data as egw_data, in order to |
3416 | 3414 | // be stored from registered app method later |
3417 | - Framework::popup(Egw::link('/index.php', $target),'_blank',$hook['popup']); |
|
3415 | + Framework::popup(Egw::link('/index.php', $target), '_blank', $hook['popup']); |
|
3418 | 3416 | } |
3419 | 3417 | } |
3420 | 3418 | } |
3421 | 3419 | // only clean up temp-files, if we dont need them for mail_integration::integrate |
3422 | - elseif(is_array($this->sessionData['attachments'])) |
|
3420 | + elseif (is_array($this->sessionData['attachments'])) |
|
3423 | 3421 | { |
3424 | - foreach($this->sessionData['attachments'] as $value) { |
|
3425 | - if (!empty($value['file']) && parse_url($value['file'],PHP_URL_SCHEME) != 'vfs') { // happens when forwarding mails |
|
3422 | + foreach ($this->sessionData['attachments'] as $value) { |
|
3423 | + if (!empty($value['file']) && parse_url($value['file'], PHP_URL_SCHEME) != 'vfs') { // happens when forwarding mails |
|
3426 | 3424 | unlink($GLOBALS['egw_info']['server']['temp_dir'].'/'.$value['file']); |
3427 | 3425 | } |
3428 | 3426 | } |
@@ -3439,7 +3437,7 @@ discard block |
||
3439 | 3437 | * @param array $content |
3440 | 3438 | * @return array - the input, enriched with some not set attributes |
3441 | 3439 | */ |
3442 | - function setDefaults($content=array()) |
|
3440 | + function setDefaults($content = array()) |
|
3443 | 3441 | { |
3444 | 3442 | // if there's not already an identity selected for current account |
3445 | 3443 | if (empty($content['mailidentity'])) |
@@ -3448,7 +3446,7 @@ discard block |
||
3448 | 3446 | if (!empty($GLOBALS['egw_info']['user']['preferences']['mail']['LastSignatureIDUsed'])) |
3449 | 3447 | { |
3450 | 3448 | $sigPref = $GLOBALS['egw_info']['user']['preferences']['mail']['LastSignatureIDUsed']; |
3451 | - if (!empty($sigPref[$this->mail_bo->profileID]) && $sigPref[$this->mail_bo->profileID]>0) |
|
3449 | + if (!empty($sigPref[$this->mail_bo->profileID]) && $sigPref[$this->mail_bo->profileID] > 0) |
|
3452 | 3450 | { |
3453 | 3451 | $content['mailidentity'] = $sigPref[$this->mail_bo->profileID]; |
3454 | 3452 | } |
@@ -3457,7 +3455,7 @@ discard block |
||
3457 | 3455 | if (empty($content['mailidentity'])) |
3458 | 3456 | { |
3459 | 3457 | $default_identity = null; |
3460 | - foreach(Mail\Account::identities($this->mail_bo->profileID, true, 'params') as $identity) |
|
3458 | + foreach (Mail\Account::identities($this->mail_bo->profileID, true, 'params') as $identity) |
|
3461 | 3459 | { |
3462 | 3460 | if (!isset($default_identity)) $default_identity = $identity['ident_id']; |
3463 | 3461 | if (!empty($identity['ident_signature'])) |
@@ -3472,7 +3470,7 @@ discard block |
||
3472 | 3470 | if (!isset($content['mimeType']) || empty($content['mimeType'])) |
3473 | 3471 | { |
3474 | 3472 | $content['mimeType'] = 'html'; |
3475 | - if (!empty($this->mailPreferences['composeOptions']) && $this->mailPreferences['composeOptions']=="text") $content['mimeType'] = 'plain'; |
|
3473 | + if (!empty($this->mailPreferences['composeOptions']) && $this->mailPreferences['composeOptions'] == "text") $content['mimeType'] = 'plain'; |
|
3476 | 3474 | } |
3477 | 3475 | return $content; |
3478 | 3476 | |
@@ -3495,7 +3493,7 @@ discard block |
||
3495 | 3493 | * @param boolean $_noPrefixId = false, if set to true folders name does not get prefixed by account id |
3496 | 3494 | * @return type |
3497 | 3495 | */ |
3498 | - function ajax_searchFolder($_searchStringLength=2, $_returnList=false, $_mailaccountToSearch=null, $_noPrefixId=false) { |
|
3496 | + function ajax_searchFolder($_searchStringLength = 2, $_returnList = false, $_mailaccountToSearch = null, $_noPrefixId = false) { |
|
3499 | 3497 | //error_log(__METHOD__.__LINE__.':'.array2string($_REQUEST)); |
3500 | 3498 | static $useCacheIfPossible = null; |
3501 | 3499 | if (is_null($useCacheIfPossible)) $useCacheIfPossible = true; |
@@ -3508,36 +3506,36 @@ discard block |
||
3508 | 3506 | { |
3509 | 3507 | $this->changeProfile($_mailaccountToSearch); |
3510 | 3508 | } |
3511 | - if (strlen($_searchString)>=$_searchStringLength && isset($this->mail_bo->icServer)) |
|
3509 | + if (strlen($_searchString) >= $_searchStringLength && isset($this->mail_bo->icServer)) |
|
3512 | 3510 | { |
3513 | 3511 | //error_log(__METHOD__.__LINE__.':'.$this->mail_bo->icServer->ImapServerId); |
3514 | 3512 | $this->mail_bo->openConnection($this->mail_bo->icServer->ImapServerId); |
3515 | 3513 | //error_log(__METHOD__.__LINE__.array2string($_searchString).'<->'.$searchString); |
3516 | - $folderObjects = $this->mail_bo->getFolderObjects(true,false,true,$useCacheIfPossible); |
|
3517 | - if (count($folderObjects)<=1) { |
|
3514 | + $folderObjects = $this->mail_bo->getFolderObjects(true, false, true, $useCacheIfPossible); |
|
3515 | + if (count($folderObjects) <= 1) { |
|
3518 | 3516 | $useCacheIfPossible = false; |
3519 | 3517 | } |
3520 | 3518 | else |
3521 | 3519 | { |
3522 | 3520 | $useCacheIfPossible = true; |
3523 | 3521 | } |
3524 | - $searchString = Api\Translation::convert($_searchString, Mail::$displayCharset,'UTF7-IMAP'); |
|
3522 | + $searchString = Api\Translation::convert($_searchString, Mail::$displayCharset, 'UTF7-IMAP'); |
|
3525 | 3523 | foreach ($folderObjects as $k =>$fA) |
3526 | 3524 | { |
3527 | 3525 | //error_log(__METHOD__.__LINE__.$_searchString.'/'.$searchString.' in '.$k.'->'.$fA->displayName); |
3528 | - $f=false; |
|
3529 | - $key = $_noPrefixId?$k:$_mailaccountToSearch.'::'.$k; |
|
3530 | - if ($_searchStringLength<=0) |
|
3526 | + $f = false; |
|
3527 | + $key = $_noPrefixId ? $k : $_mailaccountToSearch.'::'.$k; |
|
3528 | + if ($_searchStringLength <= 0) |
|
3531 | 3529 | { |
3532 | - $f=true; |
|
3530 | + $f = true; |
|
3533 | 3531 | $results[] = array('id'=>$key, 'label' => htmlspecialchars($fA->displayName)); |
3534 | 3532 | } |
3535 | - if ($f==false && stripos($fA->displayName,$_searchString)!==false) |
|
3533 | + if ($f == false && stripos($fA->displayName, $_searchString) !== false) |
|
3536 | 3534 | { |
3537 | - $f=true; |
|
3535 | + $f = true; |
|
3538 | 3536 | $results[] = array('id'=>$key, 'label' => htmlspecialchars($fA->displayName)); |
3539 | 3537 | } |
3540 | - if ($f==false && stripos($k,$searchString)!==false) |
|
3538 | + if ($f == false && stripos($k, $searchString) !== false) |
|
3541 | 3539 | { |
3542 | 3540 | $results[] = array('id'=>$key, 'label' => htmlspecialchars($fA->displayName)); |
3543 | 3541 | } |
@@ -3565,7 +3563,7 @@ discard block |
||
3565 | 3563 | exit(); |
3566 | 3564 | } |
3567 | 3565 | |
3568 | - public static function ajax_searchAddress($_searchStringLength=2) { |
|
3566 | + public static function ajax_searchAddress($_searchStringLength = 2) { |
|
3569 | 3567 | //error_log(__METHOD__. "request from seachAddress " . $_REQUEST['query']); |
3570 | 3568 | $_searchString = trim($_REQUEST['query']); |
3571 | 3569 | $include_lists = (boolean)$_REQUEST['include_lists']; |
@@ -3574,12 +3572,12 @@ discard block |
||
3574 | 3572 | $results = array(); |
3575 | 3573 | |
3576 | 3574 | // Add up to 10 matching mailing lists, and 10 groups |
3577 | - if($include_lists) |
|
3575 | + if ($include_lists) |
|
3578 | 3576 | { |
3579 | 3577 | $results += static::get_lists($_searchString, $contacts_obj); |
3580 | 3578 | } |
3581 | 3579 | |
3582 | - if ($GLOBALS['egw_info']['user']['apps']['addressbook'] && strlen($_searchString)>=$_searchStringLength) |
|
3580 | + if ($GLOBALS['egw_info']['user']['apps']['addressbook'] && strlen($_searchString) >= $_searchStringLength) |
|
3583 | 3581 | { |
3584 | 3582 | //error_log(__METHOD__.__LINE__.array2string($_searchString)); |
3585 | 3583 | $showAccounts = $GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] !== '1'; |
@@ -3588,66 +3586,66 @@ discard block |
||
3588 | 3586 | { |
3589 | 3587 | if (mb_strlen($v) < 3) unset($search[$k]); |
3590 | 3588 | } |
3591 | - $search_str = implode(' +', $search); // tell contacts/so_sql to AND search patterns |
|
3589 | + $search_str = implode(' +', $search); // tell contacts/so_sql to AND search patterns |
|
3592 | 3590 | //error_log(__METHOD__.__LINE__.$_searchString); |
3593 | 3591 | $filter = $showAccounts ? array() : array('account_id' => null); |
3594 | - $filter['cols_to_search'] = array('n_prefix','n_given','n_family','org_name','email','email_home', 'contact_id'); |
|
3595 | - $cols = array('n_fn','n_prefix','n_given','n_family','org_name','email','email_home', 'contact_id', 'etag'); |
|
3596 | - $contacts = $contacts_obj->search($search_str, $cols, 'n_fn', '', '%', false, 'OR', array(0,100), $filter); |
|
3592 | + $filter['cols_to_search'] = array('n_prefix', 'n_given', 'n_family', 'org_name', 'email', 'email_home', 'contact_id'); |
|
3593 | + $cols = array('n_fn', 'n_prefix', 'n_given', 'n_family', 'org_name', 'email', 'email_home', 'contact_id', 'etag'); |
|
3594 | + $contacts = $contacts_obj->search($search_str, $cols, 'n_fn', '', '%', false, 'OR', array(0, 100), $filter); |
|
3597 | 3595 | $cfs_type_email = Api\Storage\Customfields::get_email_cfs('addressbook'); |
3598 | 3596 | // additionally search the accounts, if the contact storage is not the account storage |
3599 | 3597 | if ($showAccounts && $contacts_obj->so_accounts) |
3600 | 3598 | { |
3601 | 3599 | $filter['owner'] = 0; |
3602 | - $accounts = $contacts_obj->search($search_str, $cols, 'n_fn', '', '%', false,'OR', array(0,100), $filter); |
|
3600 | + $accounts = $contacts_obj->search($search_str, $cols, 'n_fn', '', '%', false, 'OR', array(0, 100), $filter); |
|
3603 | 3601 | |
3604 | 3602 | if ($contacts && $accounts) |
3605 | 3603 | { |
3606 | - $contacts = array_merge($contacts,$accounts); |
|
3607 | - usort($contacts,function($a, $b) |
|
3604 | + $contacts = array_merge($contacts, $accounts); |
|
3605 | + usort($contacts, function($a, $b) |
|
3608 | 3606 | { |
3609 | 3607 | return strcasecmp($a['n_fn'], $b['n_fn']); |
3610 | 3608 | }); |
3611 | 3609 | } |
3612 | - elseif($accounts) |
|
3610 | + elseif ($accounts) |
|
3613 | 3611 | { |
3614 | - $contacts =& $accounts; |
|
3612 | + $contacts = & $accounts; |
|
3615 | 3613 | } |
3616 | 3614 | unset($accounts); |
3617 | 3615 | } |
3618 | 3616 | } |
3619 | 3617 | |
3620 | - if(is_array($contacts)) { |
|
3621 | - foreach($contacts as $contact) { |
|
3618 | + if (is_array($contacts)) { |
|
3619 | + foreach ($contacts as $contact) { |
|
3622 | 3620 | $cf_emails = (array)array_values(array_values($contacts_obj->read_customfields($contact['id'], $cfs_type_email))[0]); |
3623 | - foreach(array_merge(array($contact['email'],$contact['email_home']), $cf_emails) as $email) { |
|
3621 | + foreach (array_merge(array($contact['email'], $contact['email_home']), $cf_emails) as $email) { |
|
3624 | 3622 | // avoid wrong addresses, if an rfc822 encoded address is in addressbook |
3625 | 3623 | //$email = preg_replace("/(^.*<)([a-zA-Z0-9_\-]+@[a-zA-Z0-9_\-\.]+)(.*)/",'$2',$email); |
3626 | 3624 | $rfcAddr = Mail::parseAddressList($email); |
3627 | - $_rfcAddr=$rfcAddr->first(); |
|
3625 | + $_rfcAddr = $rfcAddr->first(); |
|
3628 | 3626 | if (!$_rfcAddr->valid) |
3629 | 3627 | { |
3630 | 3628 | continue; // skip address if we encounter an error here |
3631 | 3629 | } |
3632 | 3630 | $email = $_rfcAddr->mailbox.'@'.$_rfcAddr->host; |
3633 | 3631 | |
3634 | - if (method_exists($contacts_obj,'search')) |
|
3632 | + if (method_exists($contacts_obj, 'search')) |
|
3635 | 3633 | { |
3636 | - $contact['n_fn']=''; |
|
3634 | + $contact['n_fn'] = ''; |
|
3637 | 3635 | if (!empty($contact['n_prefix'])) $contact['n_fn'] = $contact['n_prefix']; |
3638 | - if (!empty($contact['n_given'])) $contact['n_fn'] .= ($contact['n_fn']?' ':'').$contact['n_given']; |
|
3639 | - if (!empty($contact['n_family'])) $contact['n_fn'] .= ($contact['n_fn']?' ':'').$contact['n_family']; |
|
3640 | - if (!empty($contact['org_name'])) $contact['n_fn'] .= ($contact['n_fn']?' ':'').'('.$contact['org_name'].')'; |
|
3641 | - $contact['n_fn'] = str_replace(array(',','@'),' ',$contact['n_fn']); |
|
3636 | + if (!empty($contact['n_given'])) $contact['n_fn'] .= ($contact['n_fn'] ? ' ' : '').$contact['n_given']; |
|
3637 | + if (!empty($contact['n_family'])) $contact['n_fn'] .= ($contact['n_fn'] ? ' ' : '').$contact['n_family']; |
|
3638 | + if (!empty($contact['org_name'])) $contact['n_fn'] .= ($contact['n_fn'] ? ' ' : '').'('.$contact['org_name'].')'; |
|
3639 | + $contact['n_fn'] = str_replace(array(',', '@'), ' ', $contact['n_fn']); |
|
3642 | 3640 | } |
3643 | 3641 | else |
3644 | 3642 | { |
3645 | - $contact['n_fn'] = str_replace(array(',','@'),' ',$contact['n_fn']); |
|
3643 | + $contact['n_fn'] = str_replace(array(',', '@'), ' ', $contact['n_fn']); |
|
3646 | 3644 | } |
3647 | 3645 | $args = explode('@', trim($email)); |
3648 | 3646 | $args[] = trim($contact['n_fn'] ? $contact['n_fn'] : $contact['fn']); |
3649 | 3647 | $completeMailString = call_user_func_array('imap_rfc822_write_address', $args); |
3650 | - if(!empty($email) && in_array($completeMailString ,$results) === false) { |
|
3648 | + if (!empty($email) && in_array($completeMailString, $results) === false) { |
|
3651 | 3649 | $results[] = array( |
3652 | 3650 | 'id'=>$completeMailString, |
3653 | 3651 | 'label' => $completeMailString, |
@@ -3667,10 +3665,10 @@ discard block |
||
3667 | 3665 | // Add groups |
3668 | 3666 | $group_options = array('account_type' => 'groups'); |
3669 | 3667 | $groups = $GLOBALS['egw']->accounts->link_query($_searchString, $group_options); |
3670 | - foreach($groups as $g_id => $name) |
|
3668 | + foreach ($groups as $g_id => $name) |
|
3671 | 3669 | { |
3672 | 3670 | $group = $GLOBALS['egw']->accounts->read($g_id); |
3673 | - if(!$group['account_email']) continue; |
|
3671 | + if (!$group['account_email']) continue; |
|
3674 | 3672 | $args = explode('@', trim($group['account_email'])); |
3675 | 3673 | $args[] = $name; |
3676 | 3674 | $completeMailString = call_user_func_array('imap_rfc822_write_address', $args); |
@@ -3711,14 +3709,14 @@ discard block |
||
3711 | 3709 | } |
3712 | 3710 | ); |
3713 | 3711 | |
3714 | - foreach($lists as $key => $list_name) |
|
3712 | + foreach ($lists as $key => $list_name) |
|
3715 | 3713 | { |
3716 | 3714 | $type = $key > 0 ? 'manual' : 'group'; |
3717 | 3715 | $list = array( |
3718 | 3716 | 'id' => $key, |
3719 | 3717 | 'name' => $list_name, |
3720 | 3718 | 'label' => $list_name, |
3721 | - 'class' => 'mailinglist ' . "{$type}_list", |
|
3719 | + 'class' => 'mailinglist '."{$type}_list", |
|
3722 | 3720 | 'title' => lang('Mailinglist'), |
3723 | 3721 | 'data' => $key |
3724 | 3722 | ); |
@@ -3726,9 +3724,9 @@ discard block |
||
3726 | 3724 | } |
3727 | 3725 | $trim = function($list) { |
3728 | 3726 | $limit = 10; |
3729 | - if(count($list) <= $limit) return $list; |
|
3730 | - $list[$limit-1]['class'].= ' more_results'; |
|
3731 | - $list[$limit-1]['title'] .= ' (' . lang('%1 more', count($list) - $limit) . ')'; |
|
3727 | + if (count($list) <= $limit) return $list; |
|
3728 | + $list[$limit - 1]['class'] .= ' more_results'; |
|
3729 | + $list[$limit - 1]['title'] .= ' ('.lang('%1 more', count($list) - $limit).')'; |
|
3732 | 3730 | return array_slice($list, 0, $limit); |
3733 | 3731 | }; |
3734 | 3732 | return array_merge($trim($group_lists), $trim($manual_lists)); |
@@ -3742,7 +3740,7 @@ discard block |
||
3742 | 3740 | public function ajax_merge($contact_id) |
3743 | 3741 | { |
3744 | 3742 | $response = Api\Json\Response::get(); |
3745 | - if(class_exists($_REQUEST['merge']) && is_subclass_of($_REQUEST['merge'], 'EGroupware\\Api\\Storage\\Merge')) |
|
3743 | + if (class_exists($_REQUEST['merge']) && is_subclass_of($_REQUEST['merge'], 'EGroupware\\Api\\Storage\\Merge')) |
|
3746 | 3744 | { |
3747 | 3745 | $document_merge = new $_REQUEST['merge'](); |
3748 | 3746 | } |
@@ -3752,7 +3750,7 @@ discard block |
||
3752 | 3750 | } |
3753 | 3751 | $this->mail_bo->openConnection(); |
3754 | 3752 | |
3755 | - if(($error = $document_merge->check_document($_REQUEST['document'],''))) |
|
3753 | + if (($error = $document_merge->check_document($_REQUEST['document'], ''))) |
|
3756 | 3754 | { |
3757 | 3755 | $response->error($error); |
3758 | 3756 | return; |
@@ -3763,23 +3761,23 @@ discard block |
||
3763 | 3761 | try |
3764 | 3762 | { |
3765 | 3763 | $results = $this->mail_bo->importMessageToMergeAndSend( |
3766 | - $document_merge, Vfs::PREFIX . $_REQUEST['document'], |
|
3764 | + $document_merge, Vfs::PREFIX.$_REQUEST['document'], |
|
3767 | 3765 | // Send an extra non-numeric ID to force actual send of document |
3768 | 3766 | // instead of save as draft |
3769 | 3767 | array((int)$contact_id, ''), |
3770 | - $folder,$merged_mail_id |
|
3768 | + $folder, $merged_mail_id |
|
3771 | 3769 | ); |
3772 | 3770 | |
3773 | 3771 | // Also save as infolog |
3774 | - if($merged_mail_id && $_REQUEST['to_app'] && isset($GLOBALS['egw_info']['user']['apps'][$_REQUEST['to_app']])) |
|
3772 | + if ($merged_mail_id && $_REQUEST['to_app'] && isset($GLOBALS['egw_info']['user']['apps'][$_REQUEST['to_app']])) |
|
3775 | 3773 | { |
3776 | 3774 | $rowid = mail_ui::generateRowID($this->mail_bo->profileID, $folder, $merged_mail_id, true); |
3777 | 3775 | $data = mail_integration::get_integrate_data($rowid); |
3778 | - if($data && $_REQUEST['to_app'] == 'infolog') |
|
3776 | + if ($data && $_REQUEST['to_app'] == 'infolog') |
|
3779 | 3777 | { |
3780 | 3778 | $bo = new infolog_bo(); |
3781 | - $entry = $bo->import_mail($data['addresses'],$data['subject'],$data['message'],$data['attachments'],$data['date']); |
|
3782 | - if($_REQUEST['info_type'] && isset($bo->enums['type'][$_REQUEST['info_type']])) |
|
3779 | + $entry = $bo->import_mail($data['addresses'], $data['subject'], $data['message'], $data['attachments'], $data['date']); |
|
3780 | + if ($_REQUEST['info_type'] && isset($bo->enums['type'][$_REQUEST['info_type']])) |
|
3783 | 3781 | { |
3784 | 3782 | $entry['info_type'] = $_REQUEST['info_type']; |
3785 | 3783 | } |
@@ -3798,13 +3796,13 @@ discard block |
||
3798 | 3796 | ); |
3799 | 3797 | } |
3800 | 3798 | |
3801 | - if($results['success']) |
|
3799 | + if ($results['success']) |
|
3802 | 3800 | { |
3803 | - $response->data(implode(',',$results['success'])); |
|
3801 | + $response->data(implode(',', $results['success'])); |
|
3804 | 3802 | } |
3805 | - if($results['failed']) |
|
3803 | + if ($results['failed']) |
|
3806 | 3804 | { |
3807 | - $response->error(implode(',',$results['failed'])); |
|
3805 | + $response->error(implode(',', $results['failed'])); |
|
3808 | 3806 | } |
3809 | 3807 | } |
3810 | 3808 | |
@@ -3820,7 +3818,7 @@ discard block |
||
3820 | 3818 | * @return boolean returns true if successful and false if passphrase required |
3821 | 3819 | * @throws Api\Exception\WrongUserinput if no certificate found |
3822 | 3820 | */ |
3823 | - protected function _encrypt($mail, $type, $recipients, $sender, $passphrase='') |
|
3821 | + protected function _encrypt($mail, $type, $recipients, $sender, $passphrase = '') |
|
3824 | 3822 | { |
3825 | 3823 | $AB = new addressbook_bo(); |
3826 | 3824 | // passphrase of sender private key |
@@ -3829,7 +3827,7 @@ discard block |
||
3829 | 3827 | try |
3830 | 3828 | { |
3831 | 3829 | $sender_cert = $AB->get_smime_keys($sender); |
3832 | - if (!$sender_cert) throw new Exception("S/MIME Encryption failed because no certificate has been found for sender address: " . $sender); |
|
3830 | + if (!$sender_cert) throw new Exception("S/MIME Encryption failed because no certificate has been found for sender address: ".$sender); |
|
3833 | 3831 | $params['senderPubKey'] = $sender_cert[strtolower($sender)]; |
3834 | 3832 | |
3835 | 3833 | if (isset($sender) && ($type == Mail\Smime::TYPE_SIGN || $type == Mail\Smime::TYPE_SIGN_ENCRYPT)) |
@@ -3844,14 +3842,14 @@ discard block |
||
3844 | 3842 | $params['recipientsCerts'] = $AB->get_smime_keys($recipients); |
3845 | 3843 | foreach ($recipients as &$recipient) |
3846 | 3844 | { |
3847 | - if (!$params['recipientsCerts'][strtolower($recipient)]) $missingCerts []= $recipient; |
|
3845 | + if (!$params['recipientsCerts'][strtolower($recipient)]) $missingCerts [] = $recipient; |
|
3848 | 3846 | } |
3849 | - if (is_array($missingCerts)) throw new Exception ('S/MIME Encryption failed because no certificate has been found for following addresses: '. implode ('|', $missingCerts)); |
|
3847 | + if (is_array($missingCerts)) throw new Exception('S/MIME Encryption failed because no certificate has been found for following addresses: '.implode('|', $missingCerts)); |
|
3850 | 3848 | } |
3851 | 3849 | |
3852 | 3850 | return $mail->smimeEncrypt($type, $params); |
3853 | 3851 | } |
3854 | - catch(Api\Exception\WrongUserinput $e) |
|
3852 | + catch (Api\Exception\WrongUserinput $e) |
|
3855 | 3853 | { |
3856 | 3854 | throw new $e; |
3857 | 3855 | } |
@@ -3867,7 +3865,7 @@ discard block |
||
3867 | 3865 | * |
3868 | 3866 | * @throws Exception throws exception on cross account attempt |
3869 | 3867 | */ |
3870 | - function _get_uids_as_attachments ($_ids, $_serverID) |
|
3868 | + function _get_uids_as_attachments($_ids, $_serverID) |
|
3871 | 3869 | { |
3872 | 3870 | $ids = is_array($_ids) ? $_ids : explode(',', $_ids); |
3873 | 3871 | if (is_array($ids) && $_serverID) |
@@ -3881,12 +3879,12 @@ discard block |
||
3881 | 3879 | foreach ($ids as &$id) |
3882 | 3880 | { |
3883 | 3881 | $parts = mail_ui::splitRowID($id); |
3884 | - $mail_bo = $this->mail_bo; |
|
3882 | + $mail_bo = $this->mail_bo; |
|
3885 | 3883 | $mail_bo->openConnection(); |
3886 | 3884 | $mail_bo->reopen($parts['folder']); |
3887 | - $headers = $mail_bo->getMessageEnvelope($parts['msgUID'], null,false,$parts['folder']); |
|
3885 | + $headers = $mail_bo->getMessageEnvelope($parts['msgUID'], null, false, $parts['folder']); |
|
3888 | 3886 | $this->addMessageAttachment($parts['msgUID'], null, $parts['folder'], |
3889 | - $mail_bo->decode_header(($headers['SUBJECT']?$headers['SUBJECT']:lang('no subject'))).'.eml', |
|
3887 | + $mail_bo->decode_header(($headers['SUBJECT'] ? $headers['SUBJECT'] : lang('no subject'))).'.eml', |
|
3890 | 3888 | 'MESSAGE/RFC822', $headers['SIZE'] ? $headers['SIZE'] : lang('unknown')); |
3891 | 3889 | $mail_bo->closeConnection(); |
3892 | 3890 | } |
@@ -69,16 +69,16 @@ discard block |
||
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
72 | - * Hook called by link-class to include mail in the appregistry of the linkage |
|
73 | - * |
|
74 | - * @param array|string $location location and other parameters (not used) |
|
75 | - * @return array with method-names |
|
76 | - */ |
|
77 | - static function search_link($location) |
|
78 | - { |
|
72 | + * Hook called by link-class to include mail in the appregistry of the linkage |
|
73 | + * |
|
74 | + * @param array|string $location location and other parameters (not used) |
|
75 | + * @return array with method-names |
|
76 | + */ |
|
77 | + static function search_link($location) |
|
78 | + { |
|
79 | 79 | unset($location); // not used, but required by function signature |
80 | 80 | |
81 | - return array( |
|
81 | + return array( |
|
82 | 82 | 'view' => array( |
83 | 83 | 'menuaction' => 'mail.mail_ui.displayMessage', |
84 | 84 | ), |
@@ -107,8 +107,8 @@ discard block |
||
107 | 107 | ), |
108 | 108 | 'entry' => 'Mail', |
109 | 109 | 'entries' => 'Mails', |
110 | - ); |
|
111 | - } |
|
110 | + ); |
|
111 | + } |
|
112 | 112 | |
113 | 113 | /** |
114 | 114 | * Settings hook |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | if (isset($GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'])) |
374 | 374 | $profileID = (int)$GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID']; |
375 | 375 | |
376 | - $file = Array( |
|
376 | + $file = array( |
|
377 | 377 | 'Site Configuration' => Egw::link('/index.php',array('menuaction'=>'admin.uiconfig.index','appname'=>'mail')), |
378 | 378 | ); |
379 | 379 | display_section($appname,$title,$file); |
@@ -465,7 +465,7 @@ discard block |
||
465 | 465 | |
466 | 466 | if ($GLOBALS['egw_info']['user']['apps']['admin'] && !Api\Header\UserAgent::mobile()) |
467 | 467 | { |
468 | - $file = Array( |
|
468 | + $file = array( |
|
469 | 469 | 'Site Configuration' => Egw::link('/index.php','menuaction=admin.uiconfig.index&appname=' . $appname), |
470 | 470 | ); |
471 | 471 | display_sidebox($appname,lang('Admin'),$file); |
@@ -118,13 +118,18 @@ discard block |
||
118 | 118 | static function settings($hook_data) |
119 | 119 | { |
120 | 120 | unset($GLOBALS['egw_info']['user']['preferences']['common']['auto_hide_sidebox']); |
121 | - if (!$hook_data['setup']) // does not work on setup time |
|
121 | + if (!$hook_data['setup']) |
|
122 | + { |
|
123 | + // does not work on setup time |
|
122 | 124 | { |
123 | 125 | $folderList = array(); |
126 | + } |
|
124 | 127 | |
125 | 128 | $profileID = 0; |
126 | 129 | if (isset($GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'])) |
127 | - $profileID = (int)$GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID']; |
|
130 | + { |
|
131 | + $profileID = (int)$GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID']; |
|
132 | + } |
|
128 | 133 | } |
129 | 134 | |
130 | 135 | $no_yes = array( |
@@ -176,7 +181,10 @@ discard block |
||
176 | 181 | ); |
177 | 182 | |
178 | 183 | // otherwise we get warnings during setup |
179 | - if (!is_array($folderList)) $folderList = array(); |
|
184 | + if (!is_array($folderList)) |
|
185 | + { |
|
186 | + $folderList = array(); |
|
187 | + } |
|
180 | 188 | |
181 | 189 | // modify folderlist, add a none entry, to be able to force the regarding settings, if no folders apply |
182 | 190 | $folderList['none'] = lang('no folders'); |
@@ -438,7 +446,10 @@ discard block |
||
438 | 446 | 'default' => 7 |
439 | 447 | ) |
440 | 448 | ); |
441 | - if (!$GLOBALS['egw_info']['apps']['stylite']) unset($settingsArray['attachVCardAtCompose']); |
|
449 | + if (!$GLOBALS['egw_info']['apps']['stylite']) |
|
450 | + { |
|
451 | + unset($settingsArray['attachVCardAtCompose']); |
|
452 | + } |
|
442 | 453 | return $settingsArray; |
443 | 454 | } |
444 | 455 | |
@@ -456,7 +467,9 @@ discard block |
||
456 | 467 | $title = $appname = 'mail'; |
457 | 468 | $profileID = 0; |
458 | 469 | if (isset($GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'])) |
459 | - $profileID = (int)$GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID']; |
|
470 | + { |
|
471 | + $profileID = (int)$GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID']; |
|
472 | + } |
|
460 | 473 | |
461 | 474 | $file = Array( |
462 | 475 | 'Site Configuration' => Egw::link('/index.php',array('menuaction'=>'admin.uiconfig.index','appname'=>'mail')), |
@@ -551,21 +564,26 @@ discard block |
||
551 | 564 | $accountsToSearchArray[$acc_id] = str_replace(array('<','>'),array('[',']'),$identity_name); |
552 | 565 | } |
553 | 566 | $notified_mail_uidsCache = Api\Cache::getCache(Api\Cache::INSTANCE,'email','notified_mail_uids'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),$expiration=60*60*24*2); |
554 | - if (!is_array($folders2notify)) return true; |
|
567 | + if (!is_array($folders2notify)) |
|
568 | + { |
|
569 | + return true; |
|
570 | + } |
|
555 | 571 | foreach ($folders2notify as $nFKey =>$notifyfolders) |
556 | 572 | { |
557 | 573 | try |
558 | 574 | { |
559 | 575 | $currentRecipient = (object)$GLOBALS['egw']->accounts->read(($notifyfolders['notify_account_id']?$notifyfolders['notify_account_id']:$GLOBALS['egw_info']['user']['account_id'])); |
560 | 576 | $notify_folders = $notifyfolders['notify_folders']; |
561 | - if(count($notify_folders) == 0) { |
|
577 | + if(count($notify_folders) == 0) |
|
578 | + { |
|
562 | 579 | continue; //no folders configured for notifying |
563 | 580 | } |
564 | 581 | $activeProfile = $nFKey; |
565 | 582 | try |
566 | 583 | { |
567 | 584 | $bomail = Mail::getInstance(false, $activeProfile,false); |
568 | - } catch (Exception $e) |
|
585 | + } |
|
586 | + catch (Exception $e) |
|
569 | 587 | { |
570 | 588 | error_log(__METHOD__.__LINE__.' (user: '.$currentRecipient->account_lid.') notification for Profile:'.$activeProfile.' failed.'.$e->getMessage()); |
571 | 589 | continue; //fail silently |
@@ -579,23 +597,32 @@ discard block |
||
579 | 597 | try |
580 | 598 | { |
581 | 599 | $bomail->openConnection($activeProfile); |
582 | - } catch (Exception $e) { |
|
600 | + } |
|
601 | + catch (Exception $e) { |
|
583 | 602 | // TODO: This is ugly. Log a bit nicer! |
584 | 603 | $error = $e->getMessage(); |
585 | 604 | error_log(__METHOD__.__LINE__.' # '.' (user: '.$currentRecipient->account_lid.'): cannot connect to mailbox with Profile:'.$activeProfile.'. Please check your prefs!'); |
586 | - if (!empty($error)) error_log(__METHOD__.__LINE__.' # '.$error); |
|
605 | + if (!empty($error)) |
|
606 | + { |
|
607 | + error_log(__METHOD__.__LINE__.' # '.$error); |
|
608 | + } |
|
587 | 609 | error_log(__METHOD__.__LINE__.' # Instance='.$GLOBALS['egw_info']['user']['domain'].', User='.$GLOBALS['egw_info']['user']['account_lid']); |
588 | 610 | return false; // cannot connect to mailbox |
589 | 611 | } |
590 | 612 | //$notified_mail_uidsCache = array(); |
591 | 613 | $recent_messages = array(); |
592 | 614 | $folder_status = array(); |
593 | - foreach($notify_folders as $id=>$notify_folder) { |
|
615 | + foreach($notify_folders as $id=>$notify_folder) |
|
616 | + { |
|
594 | 617 | // Allow folder notification on INBOX for popup_only chain |
595 | 618 | if (empty($notify_folder) || |
596 | 619 | ($notify_folder == 'INBOX' && |
597 | - $GLOBALS['egw_info']['user']['preferences']['notifications']['notification_chain'] != 'popup_only')) continue; |
|
598 | - if(!is_array($notified_mail_uidsCache[$activeProfile][$notify_folder])) { |
|
620 | + $GLOBALS['egw_info']['user']['preferences']['notifications']['notification_chain'] != 'popup_only')) |
|
621 | + { |
|
622 | + continue; |
|
623 | + } |
|
624 | + if(!is_array($notified_mail_uidsCache[$activeProfile][$notify_folder])) |
|
625 | + { |
|
599 | 626 | $notified_mail_uidsCache[$activeProfile][$notify_folder] = array(); |
600 | 627 | } |
601 | 628 | $folder_status[$notify_folder] = $bomail->getFolderStatus($notify_folder); |
@@ -603,11 +630,14 @@ discard block |
||
603 | 630 | $_filter = array('status'=>array('UNSEEN','UNDELETED'),'type'=>"SINCE",'string'=> date("d-M-Y", $cutoffdate)); |
604 | 631 | // $_folderName, $_startMessage, $_numberOfMessages, $_sort, $_reverse, $_filter, $_thisUIDOnly=null, $_cacheResult=true |
605 | 632 | $headers = $bomail->getHeaders($notify_folder, 1, 999, 0, true, $_filter,null,false); |
606 | - if(is_array($headers['header']) && count($headers['header']) > 0) { |
|
607 | - foreach($headers['header'] as $id=>$header) { |
|
633 | + if(is_array($headers['header']) && count($headers['header']) > 0) |
|
634 | + { |
|
635 | + foreach($headers['header'] as $id=>$header) |
|
636 | + { |
|
608 | 637 | // check if unseen mail has already been notified |
609 | 638 | $headerrowid = mail_ui::generateRowID($activeProfile, $notify_folder, $header['uid'], $_prependApp=false); |
610 | - if(!in_array($headerrowid, $notified_mail_uidsCache[$activeProfile][$notify_folder])) { |
|
639 | + if(!in_array($headerrowid, $notified_mail_uidsCache[$activeProfile][$notify_folder])) |
|
640 | + { |
|
611 | 641 | // got a REAL recent message |
612 | 642 | $header['folder'] = $notify_folder; |
613 | 643 | $header['folder_display_name'] = $folder_status[$notify_folder]['displayName']; |
@@ -617,12 +647,14 @@ discard block |
||
617 | 647 | } |
618 | 648 | } |
619 | 649 | } |
620 | - if(count($recent_messages) > 0) { |
|
650 | + if(count($recent_messages) > 0) |
|
651 | + { |
|
621 | 652 | // create notify message |
622 | 653 | $notification_subject = lang("You've got new mail").':'.$accountsToSearchArray[$activeProfile]; |
623 | 654 | $values = array(); |
624 | 655 | $values[] = array(); // content array starts at index 1 |
625 | - foreach($recent_messages as $id=>$recent_message) { |
|
656 | + foreach($recent_messages as $id=>$recent_message) |
|
657 | + { |
|
626 | 658 | $values[] = array( |
627 | 659 | 'mail_uid' => $recent_message['uid'], |
628 | 660 | 'mail_folder' => $recent_message['folder_display_name'], |
@@ -655,7 +687,8 @@ discard block |
||
655 | 687 | $notification->send(); |
656 | 688 | } |
657 | 689 | Api\Cache::setCache(Api\Cache::INSTANCE,'email','notified_mail_uids'.trim($GLOBALS['egw_info']['user']['account_id']),$notified_mail_uidsCache, $expiration=60*60*24*2); |
658 | - } catch (Exception $e) { |
|
690 | + } |
|
691 | + catch (Exception $e) { |
|
659 | 692 | // fail silently per server, if possible |
660 | 693 | error_log(__METHOD__.__LINE__.' Notification on new messages for Profile '.$activeProfile.' ('.$accountsToSearchArray[$activeProfile].') failed:'.$e->getMessage()); |
661 | 694 | } |
@@ -680,7 +713,10 @@ discard block |
||
680 | 713 | { |
681 | 714 | return true; // allways give admins or emailadmins all rights, even if they are in a denied group |
682 | 715 | } |
683 | - if (!isset($config)) $config = (array)Api\Config::read('mail'); |
|
716 | + if (!isset($config)) |
|
717 | + { |
|
718 | + $config = (array)Api\Config::read('mail'); |
|
719 | + } |
|
684 | 720 | //error_log(__METHOD__.__LINE__.' '.$feature.':'.array2string($config['deny_'.$feature])); |
685 | 721 | if (!empty($config['deny_'.$feature])) |
686 | 722 | { |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | |
37 | 37 | if (true /* ToDo check ACL available */ || $account['acc_imap_type'] == 'managementserver_imap') |
38 | 38 | { |
39 | - $actions[] = array ( |
|
39 | + $actions[] = array( |
|
40 | 40 | 'id' => 'mail_acl', |
41 | 41 | 'caption' => 'Folder ACL', |
42 | 42 | 'icon' => 'lock', |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | } |
52 | 52 | if ($account['acc_sieve_enabled'] || $account['acc_imap_type'] == 'managementserver_imap') |
53 | 53 | { |
54 | - $actions[] = array ( |
|
54 | + $actions[] = array( |
|
55 | 55 | 'id' => 'mail_vacation', |
56 | 56 | 'caption' => 'Vacation notice', |
57 | 57 | 'icon' => 'mail/navbar', |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | */ |
77 | 77 | static function search_link($location) |
78 | 78 | { |
79 | - unset($location); // not used, but required by function signature |
|
79 | + unset($location); // not used, but required by function signature |
|
80 | 80 | |
81 | 81 | return array( |
82 | 82 | 'view' => array( |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | '0' => lang('no'), |
132 | 132 | '1' => lang('yes') |
133 | 133 | ); |
134 | - $no_yes_copy = array_merge($no_yes,array('2'=>lang('yes, offer copy option'))); |
|
134 | + $no_yes_copy = array_merge($no_yes, array('2'=>lang('yes, offer copy option'))); |
|
135 | 135 | |
136 | 136 | $forwardOptions = array( |
137 | 137 | 'asmail' => lang('forward as attachment'), |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | ); |
140 | 140 | $trustServersUnseenOptions = array_merge( |
141 | 141 | $no_yes, |
142 | - array('2' => lang('yes') . ' - ' . lang('but check shared folders')) |
|
142 | + array('2' => lang('yes').' - '.lang('but check shared folders')) |
|
143 | 143 | ); |
144 | 144 | |
145 | 145 | $deleteOptions = array( |
@@ -186,12 +186,12 @@ discard block |
||
186 | 186 | 'priority' => true, |
187 | 187 | 'mailaccount' => $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'] |
188 | 188 | )); |
189 | - $toggledOnActions = array ( |
|
190 | - 'cc_expander' => array ( |
|
189 | + $toggledOnActions = array( |
|
190 | + 'cc_expander' => array( |
|
191 | 191 | 'id' => 'cc_expander', |
192 | 192 | 'label' => lang('Cc'), |
193 | 193 | ), |
194 | - 'bcc_expander' => array ( |
|
194 | + 'bcc_expander' => array( |
|
195 | 195 | 'id' => 'bcc_expander', |
196 | 196 | 'label' => lang('Bcc') |
197 | 197 | ), |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | ) |
206 | 206 | ); |
207 | 207 | |
208 | - foreach($allActions as $name => $action) |
|
208 | + foreach ($allActions as $name => $action) |
|
209 | 209 | { |
210 | 210 | if ($action['checkbox']) |
211 | 211 | { |
@@ -449,7 +449,7 @@ discard block |
||
449 | 449 | */ |
450 | 450 | static function admin($hook_data) |
451 | 451 | { |
452 | - unset($hook_data); // not used, but required by function signature |
|
452 | + unset($hook_data); // not used, but required by function signature |
|
453 | 453 | |
454 | 454 | unset($GLOBALS['egw_info']['user']['preferences']['common']['auto_hide_sidebox']); |
455 | 455 | // Only Modify the $file and $title variables..... |
@@ -459,9 +459,9 @@ discard block |
||
459 | 459 | $profileID = (int)$GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID']; |
460 | 460 | |
461 | 461 | $file = Array( |
462 | - 'Site Configuration' => Egw::link('/index.php',array('menuaction'=>'admin.uiconfig.index','appname'=>'mail')), |
|
462 | + 'Site Configuration' => Egw::link('/index.php', array('menuaction'=>'admin.uiconfig.index', 'appname'=>'mail')), |
|
463 | 463 | ); |
464 | - display_section($appname,$title,$file); |
|
464 | + display_section($appname, $title, $file); |
|
465 | 465 | } |
466 | 466 | |
467 | 467 | /** |
@@ -471,7 +471,7 @@ discard block |
||
471 | 471 | */ |
472 | 472 | static function sidebox_menu($hook_data) |
473 | 473 | { |
474 | - unset($hook_data); // not used, but required by function signature |
|
474 | + unset($hook_data); // not used, but required by function signature |
|
475 | 475 | |
476 | 476 | //error_log(__METHOD__); |
477 | 477 | // always show the side bar |
@@ -479,7 +479,7 @@ discard block |
||
479 | 479 | $appname = 'mail'; |
480 | 480 | $menu_title = $GLOBALS['egw_info']['apps'][$appname]['title']; |
481 | 481 | |
482 | - $file=array(); |
|
482 | + $file = array(); |
|
483 | 483 | // Destination div for folder tree |
484 | 484 | $file[] = array( |
485 | 485 | 'no_lang' => true, |
@@ -494,34 +494,34 @@ discard block |
||
494 | 494 | 'icon' => false |
495 | 495 | ); |
496 | 496 | // display Mail Tree |
497 | - display_sidebox($appname,$menu_title,$file); |
|
497 | + display_sidebox($appname, $menu_title, $file); |
|
498 | 498 | |
499 | 499 | $linkData = array( |
500 | 500 | 'menuaction' => 'mail.mail_ui.importMessage', |
501 | 501 | ); |
502 | 502 | |
503 | 503 | $file = array( |
504 | - 'import message' => "javascript:egw_openWindowCentered2('".Egw::link('/index.php', $linkData,false)."','importMessageDialog',600,100,'no','$appname');", |
|
504 | + 'import message' => "javascript:egw_openWindowCentered2('".Egw::link('/index.php', $linkData, false)."','importMessageDialog',600,100,'no','$appname');", |
|
505 | 505 | ); |
506 | 506 | |
507 | 507 | // create account wizard |
508 | 508 | if (self::access('createaccount')) |
509 | 509 | { |
510 | 510 | $file += array( |
511 | - 'create new account' => "javascript:egw_openWindowCentered2('" . |
|
511 | + 'create new account' => "javascript:egw_openWindowCentered2('". |
|
512 | 512 | Egw::link('/index.php', array('menuaction' => 'mail.mail_wizard.add'), ''). |
513 | 513 | "','_blank',640,480,'yes')", |
514 | 514 | ); |
515 | 515 | } |
516 | 516 | // display Mail Menu |
517 | - display_sidebox($appname,$GLOBALS['egw_info']['apps'][$appname]['title'].' '.lang('Menu'),$file); |
|
517 | + display_sidebox($appname, $GLOBALS['egw_info']['apps'][$appname]['title'].' '.lang('Menu'), $file); |
|
518 | 518 | |
519 | 519 | if ($GLOBALS['egw_info']['user']['apps']['admin'] && !Api\Header\UserAgent::mobile()) |
520 | 520 | { |
521 | 521 | $file = Array( |
522 | - 'Site Configuration' => Egw::link('/index.php','menuaction=admin.uiconfig.index&appname=' . $appname), |
|
522 | + 'Site Configuration' => Egw::link('/index.php', 'menuaction=admin.uiconfig.index&appname='.$appname), |
|
523 | 523 | ); |
524 | - display_sidebox($appname,lang('Admin'),$file); |
|
524 | + display_sidebox($appname, lang('Admin'), $file); |
|
525 | 525 | } |
526 | 526 | |
527 | 527 | // add pgp encryption menu at the end |
@@ -537,40 +537,40 @@ discard block |
||
537 | 537 | static function notification_check_mailbox() |
538 | 538 | { |
539 | 539 | // should not run more often then every 3 minutes; |
540 | - $lastRun = Api\Cache::getCache(Api\Cache::INSTANCE,'email','mailNotifyLastRun'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),$expiration=60*60*24*2); |
|
540 | + $lastRun = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'mailNotifyLastRun'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), $expiration = 60 * 60 * 24 * 2); |
|
541 | 541 | $currentTime = time(); |
542 | - if (!empty($lastRun) && $lastRun>$currentTime-3*60) |
|
542 | + if (!empty($lastRun) && $lastRun > $currentTime - 3 * 60) |
|
543 | 543 | { |
544 | 544 | return true; |
545 | 545 | } |
546 | 546 | $accountsToSearchObj = Mail\Account::search(true, true); |
547 | 547 | |
548 | - foreach($accountsToSearchObj as $acc_id => $identity_name) |
|
548 | + foreach ($accountsToSearchObj as $acc_id => $identity_name) |
|
549 | 549 | { |
550 | - $folders2notify[$acc_id] = Mail\Notifications::read($acc_id);// read all, even those set for acc_id 0 (folders for all acounts?) |
|
551 | - $accountsToSearchArray[$acc_id] = str_replace(array('<','>'),array('[',']'),$identity_name); |
|
550 | + $folders2notify[$acc_id] = Mail\Notifications::read($acc_id); // read all, even those set for acc_id 0 (folders for all acounts?) |
|
551 | + $accountsToSearchArray[$acc_id] = str_replace(array('<', '>'), array('[', ']'), $identity_name); |
|
552 | 552 | } |
553 | - $notified_mail_uidsCache = Api\Cache::getCache(Api\Cache::INSTANCE,'email','notified_mail_uids'.trim($GLOBALS['egw_info']['user']['account_id']),null,array(),$expiration=60*60*24*2); |
|
553 | + $notified_mail_uidsCache = Api\Cache::getCache(Api\Cache::INSTANCE, 'email', 'notified_mail_uids'.trim($GLOBALS['egw_info']['user']['account_id']), null, array(), $expiration = 60 * 60 * 24 * 2); |
|
554 | 554 | if (!is_array($folders2notify)) return true; |
555 | 555 | foreach ($folders2notify as $nFKey =>$notifyfolders) |
556 | 556 | { |
557 | 557 | try |
558 | 558 | { |
559 | - $currentRecipient = (object)$GLOBALS['egw']->accounts->read(($notifyfolders['notify_account_id']?$notifyfolders['notify_account_id']:$GLOBALS['egw_info']['user']['account_id'])); |
|
559 | + $currentRecipient = (object)$GLOBALS['egw']->accounts->read(($notifyfolders['notify_account_id'] ? $notifyfolders['notify_account_id'] : $GLOBALS['egw_info']['user']['account_id'])); |
|
560 | 560 | $notify_folders = $notifyfolders['notify_folders']; |
561 | - if(count($notify_folders) == 0) { |
|
561 | + if (count($notify_folders) == 0) { |
|
562 | 562 | continue; //no folders configured for notifying |
563 | 563 | } |
564 | 564 | $activeProfile = $nFKey; |
565 | 565 | try |
566 | 566 | { |
567 | - $bomail = Mail::getInstance(false, $activeProfile,false); |
|
567 | + $bomail = Mail::getInstance(false, $activeProfile, false); |
|
568 | 568 | } catch (Exception $e) |
569 | 569 | { |
570 | 570 | error_log(__METHOD__.__LINE__.' (user: '.$currentRecipient->account_lid.') notification for Profile:'.$activeProfile.' failed.'.$e->getMessage()); |
571 | 571 | continue; //fail silently |
572 | 572 | } |
573 | - $icServerParams=$bomail->icServer->params; |
|
573 | + $icServerParams = $bomail->icServer->params; |
|
574 | 574 | if (empty($icServerParams['acc_imap_host'])) |
575 | 575 | { |
576 | 576 | error_log(__METHOD__.__LINE__.' (user: '.$currentRecipient->account_lid.') notification for Profile:'.$activeProfile.' failed: NO IMAP HOST configured!'); |
@@ -590,40 +590,40 @@ discard block |
||
590 | 590 | //$notified_mail_uidsCache = array(); |
591 | 591 | $recent_messages = array(); |
592 | 592 | $folder_status = array(); |
593 | - foreach($notify_folders as $id=>$notify_folder) { |
|
593 | + foreach ($notify_folders as $id=>$notify_folder) { |
|
594 | 594 | // Allow folder notification on INBOX for popup_only chain |
595 | 595 | if (empty($notify_folder) || |
596 | 596 | ($notify_folder == 'INBOX' && |
597 | 597 | $GLOBALS['egw_info']['user']['preferences']['notifications']['notification_chain'] != 'popup_only')) continue; |
598 | - if(!is_array($notified_mail_uidsCache[$activeProfile][$notify_folder])) { |
|
598 | + if (!is_array($notified_mail_uidsCache[$activeProfile][$notify_folder])) { |
|
599 | 599 | $notified_mail_uidsCache[$activeProfile][$notify_folder] = array(); |
600 | 600 | } |
601 | 601 | $folder_status[$notify_folder] = $bomail->getFolderStatus($notify_folder); |
602 | - $cutoffdate = time() - (60*60*24*14); // last 14 days |
|
603 | - $_filter = array('status'=>array('UNSEEN','UNDELETED'),'type'=>"SINCE",'string'=> date("d-M-Y", $cutoffdate)); |
|
602 | + $cutoffdate = time() - (60 * 60 * 24 * 14); // last 14 days |
|
603 | + $_filter = array('status'=>array('UNSEEN', 'UNDELETED'), 'type'=>"SINCE", 'string'=> date("d-M-Y", $cutoffdate)); |
|
604 | 604 | // $_folderName, $_startMessage, $_numberOfMessages, $_sort, $_reverse, $_filter, $_thisUIDOnly=null, $_cacheResult=true |
605 | - $headers = $bomail->getHeaders($notify_folder, 1, 999, 0, true, $_filter,null,false); |
|
606 | - if(is_array($headers['header']) && count($headers['header']) > 0) { |
|
607 | - foreach($headers['header'] as $id=>$header) { |
|
605 | + $headers = $bomail->getHeaders($notify_folder, 1, 999, 0, true, $_filter, null, false); |
|
606 | + if (is_array($headers['header']) && count($headers['header']) > 0) { |
|
607 | + foreach ($headers['header'] as $id=>$header) { |
|
608 | 608 | // check if unseen mail has already been notified |
609 | - $headerrowid = mail_ui::generateRowID($activeProfile, $notify_folder, $header['uid'], $_prependApp=false); |
|
610 | - if(!in_array($headerrowid, $notified_mail_uidsCache[$activeProfile][$notify_folder])) { |
|
609 | + $headerrowid = mail_ui::generateRowID($activeProfile, $notify_folder, $header['uid'], $_prependApp = false); |
|
610 | + if (!in_array($headerrowid, $notified_mail_uidsCache[$activeProfile][$notify_folder])) { |
|
611 | 611 | // got a REAL recent message |
612 | 612 | $header['folder'] = $notify_folder; |
613 | 613 | $header['folder_display_name'] = $folder_status[$notify_folder]['displayName']; |
614 | - $header['folder_base64'] = base64_encode($notify_folder); |
|
614 | + $header['folder_base64'] = base64_encode($notify_folder); |
|
615 | 615 | $recent_messages[] = $header; |
616 | 616 | } |
617 | 617 | } |
618 | 618 | } |
619 | 619 | } |
620 | - if(count($recent_messages) > 0) { |
|
620 | + if (count($recent_messages) > 0) { |
|
621 | 621 | // create notify message |
622 | 622 | $notification_subject = lang("You've got new mail").':'.$accountsToSearchArray[$activeProfile]; |
623 | 623 | $values = array(); |
624 | 624 | $values[] = array(); // content array starts at index 1 |
625 | - foreach($recent_messages as $id=>$recent_message) { |
|
626 | - $values[] = array( |
|
625 | + foreach ($recent_messages as $id=>$recent_message) { |
|
626 | + $values[] = array( |
|
627 | 627 | 'mail_uid' => $recent_message['uid'], |
628 | 628 | 'mail_folder' => $recent_message['folder_display_name'], |
629 | 629 | 'mail_folder_base64' => $recent_message['folder_base64'], |
@@ -633,15 +633,15 @@ discard block |
||
633 | 633 | 'mail_to' => $recent_message['to_address'], |
634 | 634 | ); |
635 | 635 | // save notification status |
636 | - $notified_mail_uidsCache[$activeProfile][$recent_message['folder']][] = mail_ui::generateRowID($activeProfile, $recent_message['folder'], $recent_message['uid'], $_prependApp=false); |
|
636 | + $notified_mail_uidsCache[$activeProfile][$recent_message['folder']][] = mail_ui::generateRowID($activeProfile, $recent_message['folder'], $recent_message['uid'], $_prependApp = false); |
|
637 | 637 | } |
638 | 638 | foreach ($values as &$mail) |
639 | 639 | { |
640 | 640 | if ($mail['mail_from']) |
641 | 641 | { |
642 | - $notification_message .= "<br/><strong>".lang("From").':</strong>'. $mail["mail_from"]. |
|
643 | - "<br/><strong>".lang("To").':</strong>'. $mail["mail_to"]. |
|
644 | - "<br/><strong>".lang ("subject"). ':</strong>' . $mail["mail_subject"]. |
|
642 | + $notification_message .= "<br/><strong>".lang("From").':</strong>'.$mail["mail_from"]. |
|
643 | + "<br/><strong>".lang("To").':</strong>'.$mail["mail_to"]. |
|
644 | + "<br/><strong>".lang("subject").':</strong>'.$mail["mail_subject"]. |
|
645 | 645 | "<br/><br/> -------------------------------------------------------- </br>"; |
646 | 646 | } |
647 | 647 | } |
@@ -654,13 +654,13 @@ discard block |
||
654 | 654 | $notification->set_skip_backends(array('email')); |
655 | 655 | $notification->send(); |
656 | 656 | } |
657 | - Api\Cache::setCache(Api\Cache::INSTANCE,'email','notified_mail_uids'.trim($GLOBALS['egw_info']['user']['account_id']),$notified_mail_uidsCache, $expiration=60*60*24*2); |
|
657 | + Api\Cache::setCache(Api\Cache::INSTANCE, 'email', 'notified_mail_uids'.trim($GLOBALS['egw_info']['user']['account_id']), $notified_mail_uidsCache, $expiration = 60 * 60 * 24 * 2); |
|
658 | 658 | } catch (Exception $e) { |
659 | 659 | // fail silently per server, if possible |
660 | 660 | error_log(__METHOD__.__LINE__.' Notification on new messages for Profile '.$activeProfile.' ('.$accountsToSearchArray[$activeProfile].') failed:'.$e->getMessage()); |
661 | 661 | } |
662 | 662 | } |
663 | - Api\Cache::setCache(Api\Cache::INSTANCE,'email','mailNotifyLastRun'.trim($GLOBALS['egw_info']['user']['account_id']),time(), $expiration=60*60*24*2); |
|
663 | + Api\Cache::setCache(Api\Cache::INSTANCE, 'email', 'mailNotifyLastRun'.trim($GLOBALS['egw_info']['user']['account_id']), time(), $expiration = 60 * 60 * 24 * 2); |
|
664 | 664 | return true; |
665 | 665 | } |
666 | 666 | |
@@ -675,21 +675,21 @@ discard block |
||
675 | 675 | */ |
676 | 676 | public static function access($feature) |
677 | 677 | { |
678 | - static $config=null; |
|
678 | + static $config = null; |
|
679 | 679 | if ($GLOBALS['egw_info']['user']['apps']['admin']) |
680 | 680 | { |
681 | - return true; // allways give admins or emailadmins all rights, even if they are in a denied group |
|
681 | + return true; // allways give admins or emailadmins all rights, even if they are in a denied group |
|
682 | 682 | } |
683 | 683 | if (!isset($config)) $config = (array)Api\Config::read('mail'); |
684 | 684 | //error_log(__METHOD__.__LINE__.' '.$feature.':'.array2string($config['deny_'.$feature])); |
685 | 685 | if (!empty($config['deny_'.$feature])) |
686 | 686 | { |
687 | 687 | //error_log(__METHOD__.__LINE__.' feature:'.$feature.':'.array2string($config['deny_'.$feature])); |
688 | - $denied_groups = (is_array($config['deny_'.$feature])?$config['deny_'.$feature]:explode(',', $config['deny_'.$feature])); |
|
688 | + $denied_groups = (is_array($config['deny_'.$feature]) ? $config['deny_'.$feature] : explode(',', $config['deny_'.$feature])); |
|
689 | 689 | //error_log(__METHOD__.__LINE__.array2string($GLOBALS['egw']->accounts->memberships($GLOBALS['egw_info']['user']['account_id'], true))); |
690 | 690 | //error_log(__METHOD__.__LINE__.array2string(array_intersect($denied_groups, $GLOBALS['egw']->accounts->memberships($GLOBALS['egw_info']['user']['account_id'], true)))); |
691 | 691 | // since access asks positively, the stored deny_$feature must return false if we find the denied group in the users membership-list |
692 | - return (array_intersect($denied_groups, $GLOBALS['egw']->accounts->memberships($GLOBALS['egw_info']['user']['account_id'], true))?false:true); |
|
692 | + return (array_intersect($denied_groups, $GLOBALS['egw']->accounts->memberships($GLOBALS['egw_info']['user']['account_id'], true)) ?false:true); |
|
693 | 693 | } |
694 | 694 | return true; |
695 | 695 | } |
@@ -699,7 +699,7 @@ discard block |
||
699 | 699 | * |
700 | 700 | * @return array returns array of actions |
701 | 701 | */ |
702 | - public static function get_status_actions () |
|
702 | + public static function get_status_actions() |
|
703 | 703 | { |
704 | 704 | return [ |
705 | 705 | 'mail' => [ |
@@ -11,4 +11,4 @@ |
||
11 | 11 | * @version $Id$ |
12 | 12 | */ |
13 | 13 | header('Location: ../index.php?menuaction=mail.mail_ui.index'. |
14 | - (isset($_GET['sessionid']) ? '&sessionid='.$_GET['sessionid'].'&kp3='.$_GET['kp3'] : '')); |
|
14 | + (isset($_GET['sessionid']) ? '&sessionid='.$_GET['sessionid'].'&kp3='.$_GET['kp3'] : '')); |
@@ -32,11 +32,11 @@ discard block |
||
32 | 32 | } |
33 | 33 | if ($args[0] == '-c') |
34 | 34 | { |
35 | - $color = explode(',',$args[1]); |
|
35 | + $color = explode(',', $args[1]); |
|
36 | 36 | array_shift($args); |
37 | 37 | array_shift($args); |
38 | 38 | } |
39 | -foreach($args as $path) |
|
39 | +foreach ($args as $path) |
|
40 | 40 | { |
41 | 41 | if (!preg_match('|^([^/]+)/.*/(.*).svg$|', $path, $matches) || !($svg = file_get_contents($path))) |
42 | 42 | { |
@@ -53,11 +53,11 @@ discard block |
||
53 | 53 | $svg = preg_replace('/(<svg.*) id="[^"]+"/', '\\1 id="'.$id.'"', $svg); |
54 | 54 | |
55 | 55 | // Replace fill color with color[0] |
56 | - $svg = preg_replace('/(<.*) fill="[^"]*"/','\\1 fill="'.$color[0] .'"', $svg); |
|
56 | + $svg = preg_replace('/(<.*) fill="[^"]*"/', '\\1 fill="'.$color[0].'"', $svg); |
|
57 | 57 | // Replace stroke color with color[1] |
58 | - $svg = preg_replace('/(<.*) stroke="[^"]*"/', '\\1 stroke="'.$color[1] .'"', $svg); |
|
58 | + $svg = preg_replace('/(<.*) stroke="[^"]*"/', '\\1 stroke="'.$color[1].'"', $svg); |
|
59 | 59 | |
60 | - error_log(__METHOD__."svg: ". var_dump($svg)); |
|
60 | + error_log(__METHOD__."svg: ".var_dump($svg)); |
|
61 | 61 | // store image again |
62 | 62 | file_put_contents($path, $svg); |
63 | 63 | echo "$path: added $style_url and id=\"$id\"\n"; |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | array_pop($i_parts); |
70 | 70 | $rel_parts = $s_parts = explode('/', $stylesheet); |
71 | 71 | |
72 | - foreach($i_parts as $n => $i_part) |
|
72 | + foreach ($i_parts as $n => $i_part) |
|
73 | 73 | { |
74 | 74 | if (isset($s_parts[$n]) && $s_parts[$n] === $i_part) |
75 | 75 | { |
@@ -10,18 +10,24 @@ |
||
10 | 10 | * @version $Id$ |
11 | 11 | */ |
12 | 12 | |
13 | -if (php_sapi_name() !== 'cli') die("This is a commandline ONLY tool!\n"); |
|
13 | +if (php_sapi_name() !== 'cli') |
|
14 | +{ |
|
15 | + die("This is a commandline ONLY tool!\n"); |
|
16 | +} |
|
14 | 17 | |
15 | 18 | $args = $_SERVER['argv']; |
16 | 19 | $prog = array_shift($args); |
17 | 20 | |
18 | -if ($_SERVER['argc'] <= 1 || $prog != 'pixelegg/stylesheet2svg.php') die(" |
|
21 | +if ($_SERVER['argc'] <= 1 || $prog != 'pixelegg/stylesheet2svg.php') |
|
22 | +{ |
|
23 | + die(" |
|
19 | 24 | Usage: pixelegg/stylesheet2svg [-s stylesheet|-c color] svg-image(s) |
20 | 25 | Add an external stylesheet to an svg image and sets id of svg tag to app_image |
21 | 26 | Examples: |
22 | 27 | - pixelegg/stylesheet2svg -s pixelegg/less/svg.css */templates/pixelegg/images/*.svg pixelegg/images/*.svg |
23 | 28 | - pixelegg/stylesheet2svg -c '#6e6e6e,#939393' */templates/pixelegg/images/*.svg pixelegg/images/*.svg |
24 | 29 | \n"); |
30 | +} |
|
25 | 31 | |
26 | 32 | $stylesheet = 'pixelegg/less/svg.css'; |
27 | 33 | if ($args[0] == '-s') |
@@ -98,13 +98,13 @@ |
||
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
101 | - * generate the module content AND process submitted forms |
|
102 | - * Overridden from parent to pass arguments |
|
103 | - * |
|
104 | - * @param array &$arguments $arguments['arg1']-$arguments['arg3'] will be passed for non-submitted forms (first call) |
|
105 | - * @param array $properties |
|
106 | - * @return string the Api\Html content |
|
107 | - */ |
|
101 | + * generate the module content AND process submitted forms |
|
102 | + * Overridden from parent to pass arguments |
|
103 | + * |
|
104 | + * @param array &$arguments $arguments['arg1']-$arguments['arg3'] will be passed for non-submitted forms (first call) |
|
105 | + * @param array $properties |
|
106 | + * @return string the Api\Html content |
|
107 | + */ |
|
108 | 108 | function get_content(&$arguments,$properties) |
109 | 109 | { |
110 | 110 | list($app) = explode('.',$this->etemplate_method); |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | $categories = new Api\Categories('', 'resources'); |
27 | 27 | $cat_list = $categories->return_sorted_array(); |
28 | 28 | $cat_options = array(); |
29 | - foreach($cat_list as $category) |
|
29 | + foreach ($cat_list as $category) |
|
30 | 30 | { |
31 | 31 | $cat_options[$category['id']] = $category['name']; |
32 | 32 | } |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | 'email_message' => array( |
55 | 55 | 'type' => 'textarea', |
56 | 56 | 'large' => true, |
57 | - 'label' => lang('Confirmation email text').'<br />%1 = ' . lang('Event start').'<br/>%2 = link<br />%3 = '.lang('expiry'), |
|
57 | + 'label' => lang('Confirmation email text').'<br />%1 = '.lang('Event start').'<br/>%2 = link<br />%3 = '.lang('expiry'), |
|
58 | 58 | 'params' => array( |
59 | 59 | 'rows' => 8, |
60 | 60 | 'cols' => 110 |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | 'label' => lang('Confirmed addressbook.').' ('.lang('The anonymous user needs add rights for it!').')', |
66 | 66 | 'options' => array( |
67 | 67 | '' => lang('None'), |
68 | - )+registration_bo::get_allowed_addressbooks(registration_bo::CONFIRMED) |
|
68 | + ) + registration_bo::get_allowed_addressbooks(registration_bo::CONFIRMED) |
|
69 | 69 | ), |
70 | 70 | 'include_group' => array( |
71 | 71 | 'type' => 'select', |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | // Add resources from selected category |
91 | 91 | $bo = new resources_bo(); |
92 | 92 | $bo->get_rows($query, $list, $readonlys); |
93 | - foreach($list as $resource) |
|
93 | + foreach ($list as $resource) |
|
94 | 94 | { |
95 | 95 | $this->arguments['resource']['options'][$resource['res_id']] = $resource['name']; |
96 | 96 | } |
@@ -105,9 +105,9 @@ discard block |
||
105 | 105 | * @param array $properties |
106 | 106 | * @return string the Api\Html content |
107 | 107 | */ |
108 | - function get_content(&$arguments,$properties) |
|
108 | + function get_content(&$arguments, $properties) |
|
109 | 109 | { |
110 | - list($app) = explode('.',$this->etemplate_method); |
|
110 | + list($app) = explode('.', $this->etemplate_method); |
|
111 | 111 | Api\Translation::add_app($app); |
112 | 112 | |
113 | 113 | $extra = "<style type=\"text/css\">\n<!--\n@import url(".$GLOBALS['egw_info']['server']['webserver_url']. |
@@ -122,14 +122,14 @@ discard block |
||
122 | 122 | $extra .= "-->\n</style>\n"; |
123 | 123 | $extra .= '<script src="'.$GLOBALS['egw_info']['server']['webserver_url'].'/etemplate/js/etemplate.js" type="text/javascript"></script>'."\n"; |
124 | 124 | $ret = false; |
125 | - if($_POST['etemplate_exec_id']) |
|
125 | + if ($_POST['etemplate_exec_id']) |
|
126 | 126 | { |
127 | 127 | $ret = ExecMethod('etemplate.etemplate.process_exec'); |
128 | 128 | } |
129 | - if($_GET['date']) $arguments['date'] = strtotime($_GET['date']); |
|
129 | + if ($_GET['date']) $arguments['date'] = strtotime($_GET['date']); |
|
130 | 130 | $arguments['link'] = $this->link(); |
131 | 131 | $arguments['sitemgr_version'] = $this->block->version; |
132 | - return $extra.($ret ? $ret : ExecMethod2($this->etemplate_method,null,$arguments)); |
|
132 | + return $extra.($ret ? $ret : ExecMethod2($this->etemplate_method, null, $arguments)); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | } |
@@ -126,7 +126,10 @@ |
||
126 | 126 | { |
127 | 127 | $ret = ExecMethod('etemplate.etemplate.process_exec'); |
128 | 128 | } |
129 | - if($_GET['date']) $arguments['date'] = strtotime($_GET['date']); |
|
129 | + if($_GET['date']) |
|
130 | + { |
|
131 | + $arguments['date'] = strtotime($_GET['date']); |
|
132 | + } |
|
130 | 133 | $arguments['link'] = $this->link(); |
131 | 134 | $arguments['sitemgr_version'] = $this->block->version; |
132 | 135 | return $extra.($ret ? $ret : ExecMethod2($this->etemplate_method,null,$arguments)); |
@@ -14,26 +14,26 @@ discard block |
||
14 | 14 | $resources_table_prefix = 'egw_resources'; |
15 | 15 | |
16 | 16 | // Add a general category for resources |
17 | -$GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->cats_table,array('cat_parent' => 0, 'cat_owner' => Api\Categories::GLOBAL_ACCOUNT,'cat_access' => 'public','cat_appname' => 'resources','cat_name' => 'General resources','cat_description' => 'This category has been added by setup','last_mod' => time()),false,__LINE__,__FILE__); |
|
18 | -$cat_id = $GLOBALS['egw_setup']->db->get_last_insert_id($GLOBALS['egw_setup']->cats_table,'cat_id'); |
|
19 | -$GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->cats_table,array('cat_parent' => 0, 'cat_owner' => Api\Categories::GLOBAL_ACCOUNT,'cat_access' => 'public','cat_appname' => 'resources','cat_name' => 'Locations','cat_description' => 'This category has been added by setup','last_mod' => time()),false,__LINE__,__FILE__); |
|
20 | -$locations_cat_id = $GLOBALS['egw_setup']->db->get_last_insert_id($GLOBALS['egw_setup']->cats_table,'cat_id'); |
|
17 | +$GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->cats_table, array('cat_parent' => 0, 'cat_owner' => Api\Categories::GLOBAL_ACCOUNT, 'cat_access' => 'public', 'cat_appname' => 'resources', 'cat_name' => 'General resources', 'cat_description' => 'This category has been added by setup', 'last_mod' => time()), false, __LINE__, __FILE__); |
|
18 | +$cat_id = $GLOBALS['egw_setup']->db->get_last_insert_id($GLOBALS['egw_setup']->cats_table, 'cat_id'); |
|
19 | +$GLOBALS['egw_setup']->db->insert($GLOBALS['egw_setup']->cats_table, array('cat_parent' => 0, 'cat_owner' => Api\Categories::GLOBAL_ACCOUNT, 'cat_access' => 'public', 'cat_appname' => 'resources', 'cat_name' => 'Locations', 'cat_description' => 'This category has been added by setup', 'last_mod' => time()), false, __LINE__, __FILE__); |
|
20 | +$locations_cat_id = $GLOBALS['egw_setup']->db->get_last_insert_id($GLOBALS['egw_setup']->cats_table, 'cat_id'); |
|
21 | 21 | Api\Config::save_value('location_cats', $locations_cat_id, 'resources'); |
22 | 22 | |
23 | 23 | // Give default group all rights to this general cat |
24 | -$defaultgroup = $GLOBALS['egw_setup']->add_account('Default','Default','Group',False,False); |
|
25 | -$GLOBALS['egw_setup']->add_acl('resources','run',$defaultgroup); |
|
26 | -$GLOBALS['egw_setup']->add_acl('resources',"L$cat_id",$defaultgroup,399); |
|
27 | -$GLOBALS['egw_setup']->add_acl('resources',"L$locations_cat_id",$defaultgroup,399); |
|
24 | +$defaultgroup = $GLOBALS['egw_setup']->add_account('Default', 'Default', 'Group', False, False); |
|
25 | +$GLOBALS['egw_setup']->add_acl('resources', 'run', $defaultgroup); |
|
26 | +$GLOBALS['egw_setup']->add_acl('resources', "L$cat_id", $defaultgroup, 399); |
|
27 | +$GLOBALS['egw_setup']->add_acl('resources', "L$locations_cat_id", $defaultgroup, 399); |
|
28 | 28 | |
29 | 29 | // Add two rooms to give user an idea of what resources is... |
30 | 30 | $oProc->query("INSERT INTO {$resources_table_prefix} (name,cat_id,bookable,picture_src,accessory_of) VALUES ( 'Meeting room 1',$locations_cat_id,1,'cat_src',-1)"); |
31 | 31 | $oProc->query("INSERT INTO {$resources_table_prefix} (name,cat_id,bookable,picture_src,accessory_of) VALUES ( 'Meeting room 2',$locations_cat_id,1,'cat_src',-1)"); |
32 | -$res_id = $oProc->m_odb->get_last_insert_id($resources_table_prefix,'res_id'); |
|
32 | +$res_id = $oProc->m_odb->get_last_insert_id($resources_table_prefix, 'res_id'); |
|
33 | 33 | $oProc->query("INSERT INTO {$resources_table_prefix} (name,cat_id,bookable,picture_src,accessory_of) VALUES ( 'Fixed Beamer',$cat_id,0,'cat_src',$res_id)"); |
34 | 34 | |
35 | 35 | // Turn on history by default |
36 | -foreach(array( |
|
36 | +foreach (array( |
|
37 | 37 | 'history' => 'history', |
38 | 38 | ) as $name => $value) |
39 | 39 | { |
@@ -43,10 +43,10 @@ discard block |
||
43 | 43 | 'config_app' => 'resources', |
44 | 44 | 'config_name' => $name, |
45 | 45 | 'config_value' => $value, |
46 | - ),array( |
|
46 | + ), array( |
|
47 | 47 | 'config_app' => 'resources', |
48 | 48 | 'config_name' => $name, |
49 | - ),__LINE__,__FILE__ |
|
49 | + ), __LINE__, __FILE__ |
|
50 | 50 | ); |
51 | 51 | } |
52 | 52 |
@@ -23,8 +23,8 @@ |
||
23 | 23 | // Give default group all rights to this general cat |
24 | 24 | $defaultgroup = $GLOBALS['egw_setup']->add_account('Default','Default','Group',False,False); |
25 | 25 | $GLOBALS['egw_setup']->add_acl('resources','run',$defaultgroup); |
26 | -$GLOBALS['egw_setup']->add_acl('resources',"L$cat_id",$defaultgroup,399); |
|
27 | -$GLOBALS['egw_setup']->add_acl('resources',"L$locations_cat_id",$defaultgroup,399); |
|
26 | +$GLOBALS['egw_setup']->add_acl('resources',"l$cat_id",$defaultgroup,399); |
|
27 | +$GLOBALS['egw_setup']->add_acl('resources',"l$locations_cat_id",$defaultgroup,399); |
|
28 | 28 | |
29 | 29 | // Add two rooms to give user an idea of what resources is... |
30 | 30 | $oProc->query("INSERT INTO {$resources_table_prefix} (name,cat_id,bookable,picture_src,accessory_of) VALUES ( 'Meeting room 1',$locations_cat_id,1,'cat_src',-1)"); |
@@ -44,7 +44,7 @@ |
||
44 | 44 | 'long_description' => lang('Long description'), |
45 | 45 | 'inventory_number' => lang('inventory number'), |
46 | 46 | 'accessory_of' => lang('Accessory of') |
47 | - ); |
|
47 | + ); |
|
48 | 48 | |
49 | 49 | $custom = Api\Storage\Customfields::get('resources', true); |
50 | 50 | foreach($custom as $name => $data) { |
@@ -47,7 +47,7 @@ |
||
47 | 47 | ); |
48 | 48 | |
49 | 49 | $custom = Api\Storage\Customfields::get('resources', true); |
50 | - foreach($custom as $name => $data) { |
|
50 | + foreach ($custom as $name => $data) { |
|
51 | 51 | $this->mapping_fields['#'.$name] = $data['label']; |
52 | 52 | } |
53 | 53 |
@@ -47,7 +47,8 @@ |
||
47 | 47 | ); |
48 | 48 | |
49 | 49 | $custom = Api\Storage\Customfields::get('resources', true); |
50 | - foreach($custom as $name => $data) { |
|
50 | + foreach($custom as $name => $data) |
|
51 | + { |
|
51 | 52 | $this->mapping_fields['#'.$name] = $data['label']; |
52 | 53 | } |
53 | 54 |