@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | * @var array |
| 90 | 90 | */ |
| 91 | 91 | public static $ssl_types = array( |
| 92 | - self::SSL_TLS => 'TLS', // SSL with minimum TLS (no SSL v.2 or v.3), requires Horde_Imap_Client-2.16.0/Horde_Socket_Client-1.1.0 |
|
| 92 | + self::SSL_TLS => 'TLS', // SSL with minimum TLS (no SSL v.2 or v.3), requires Horde_Imap_Client-2.16.0/Horde_Socket_Client-1.1.0 |
|
| 93 | 93 | self::SSL_SSL => 'SSL', |
| 94 | 94 | self::SSL_STARTTLS => 'STARTTLS', |
| 95 | 95 | 'no' => 'no', |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | public static $ssl2secure = array( |
| 103 | 103 | 'SSL' => 'ssl', |
| 104 | 104 | 'STARTTLS' => 'tls', |
| 105 | - 'TLS' => 'tlsv1', // SSL with minimum TLS (no SSL v.2 or v.3), requires Horde_Imap_Client-2.16.0/Horde_Socket_Client-1.1.0 |
|
| 105 | + 'TLS' => 'tlsv1', // SSL with minimum TLS (no SSL v.2 or v.3), requires Horde_Imap_Client-2.16.0/Horde_Socket_Client-1.1.0 |
|
| 106 | 106 | ); |
| 107 | 107 | /** |
| 108 | 108 | * Convert ssl-type to eMailAdmin acc_(imap|sieve|smtp)_ssl integer value |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | * @param array $content |
| 169 | 169 | * @param type $msg |
| 170 | 170 | */ |
| 171 | - public function add(array $content=array(), $msg='', $msg_type='success') |
|
| 171 | + public function add(array $content = array(), $msg = '', $msg_type = 'success') |
|
| 172 | 172 | { |
| 173 | 173 | // otherwise we cant switch to ckeditor in edit |
| 174 | 174 | Api\Html\CkEditorConfig::set_csp_script_src_attrs(); |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | if ($content['button'] && key($content['button']) == 'skip_imap') |
| 209 | 209 | { |
| 210 | 210 | unset($content['button']); |
| 211 | - if (!isset($content['acc_smtp_host'])) $content['acc_smtp_host'] = ''; // do manual mode right away |
|
| 211 | + if (!isset($content['acc_smtp_host'])) $content['acc_smtp_host'] = ''; // do manual mode right away |
|
| 212 | 212 | return $this->smtp($content, lang('Skipping IMAP configuration!')); |
| 213 | 213 | } |
| 214 | 214 | $content['output'] = ''; |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | if (!empty($content['acc_imap_host'])) |
| 223 | 223 | { |
| 224 | 224 | $hosts = array($content['acc_imap_host'] => true); |
| 225 | - if ($content['acc_imap_port'] > 0 && !in_array($content['acc_imap_port'], array(143,993))) |
|
| 225 | + if ($content['acc_imap_port'] > 0 && !in_array($content['acc_imap_port'], array(143, 993))) |
|
| 226 | 226 | { |
| 227 | 227 | $ssl_type = (string)array_search($content['acc_imap_ssl'], self::$ssl2type); |
| 228 | 228 | if ($ssl_type === '') $ssl_type = 'insecure'; |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | $content['ispdb'] = $ispdb; |
| 237 | 237 | $content['output'] .= lang('Using data from Mozilla ISPDB for provider %1', $ispdb['displayName'])."\n"; |
| 238 | 238 | $hosts = array(); |
| 239 | - foreach($ispdb['imap'] as $server) |
|
| 239 | + foreach ($ispdb['imap'] as $server) |
|
| 240 | 240 | { |
| 241 | 241 | if (!isset($hosts[$server['hostname']])) |
| 242 | 242 | { |
@@ -260,13 +260,13 @@ discard block |
||
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | // iterate over all hosts and try to connect |
| 263 | - foreach($hosts as $host => $data) |
|
| 263 | + foreach ($hosts as $host => $data) |
|
| 264 | 264 | { |
| 265 | 265 | $content['acc_imap_host'] = $host; |
| 266 | 266 | // by default we check SSL, STARTTLS and at last an insecure connection |
| 267 | 267 | if (!is_array($data)) $data = array('TLS' => 993, 'SSL' => 993, 'STARTTLS' => 143, 'insecure' => 143); |
| 268 | 268 | |
| 269 | - foreach($data as $ssl => $port) |
|
| 269 | + foreach ($data as $ssl => $port) |
|
| 270 | 270 | { |
| 271 | 271 | if ($ssl === 'username') continue; |
| 272 | 272 | |
@@ -291,17 +291,17 @@ discard block |
||
| 291 | 291 | $content['connected'] = $connected = true; |
| 292 | 292 | break 2; |
| 293 | 293 | } |
| 294 | - catch(Horde_Imap_Client_Exception $e) |
|
| 294 | + catch (Horde_Imap_Client_Exception $e) |
|
| 295 | 295 | { |
| 296 | - switch($e->getCode()) |
|
| 296 | + switch ($e->getCode()) |
|
| 297 | 297 | { |
| 298 | 298 | case Horde_Imap_Client_Exception::LOGIN_AUTHENTICATIONFAILED: |
| 299 | 299 | $content['output'] .= "\n".$e->getMessage()."\n"; |
| 300 | - break 3; // no need to try other SSL or non-SSL connections, if auth failed |
|
| 300 | + break 3; // no need to try other SSL or non-SSL connections, if auth failed |
|
| 301 | 301 | |
| 302 | 302 | case Horde_Imap_Client_Exception::SERVER_CONNECT: |
| 303 | 303 | $content['output'] .= "\n".$e->getMessage()."\n"; |
| 304 | - if ($ssl == 'STARTTLS') break 2; // no need to try insecure connection on same port |
|
| 304 | + if ($ssl == 'STARTTLS') break 2; // no need to try insecure connection on same port |
|
| 305 | 305 | break; |
| 306 | 306 | |
| 307 | 307 | default: |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | } |
| 311 | 311 | if (self::$debug) _egw_log_exception($e); |
| 312 | 312 | } |
| 313 | - catch(Exception $e) { |
|
| 313 | + catch (Exception $e) { |
|
| 314 | 314 | $content['output'] .= "\n".get_class($e).': '.$e->getMessage().' ('.$e->getCode().')'."\n"; |
| 315 | 315 | //$content['output'] .= $e->getTraceAsString()."\n"; |
| 316 | 316 | if (self::$debug) _egw_log_exception($e); |
@@ -326,7 +326,7 @@ discard block |
||
| 326 | 326 | // add validation error, if we can identify a field |
| 327 | 327 | if (!$connected && $e instanceof Horde_Imap_Client_Exception) |
| 328 | 328 | { |
| 329 | - switch($e->getCode()) |
|
| 329 | + switch ($e->getCode()) |
|
| 330 | 330 | { |
| 331 | 331 | case Horde_Imap_Client_Exception::LOGIN_AUTHENTICATIONFAILED: |
| 332 | 332 | Etemplate::set_validation_error('acc_imap_username', lang($e->getMessage())); |
@@ -352,13 +352,13 @@ discard block |
||
| 352 | 352 | * @param string $msg ='' |
| 353 | 353 | * @param Horde_Imap_Client_Socket $imap =null |
| 354 | 354 | */ |
| 355 | - public function folder(array $content, $msg='', Horde_Imap_Client_Socket $imap=null) |
|
| 355 | + public function folder(array $content, $msg = '', Horde_Imap_Client_Socket $imap = null) |
|
| 356 | 356 | { |
| 357 | 357 | if (isset($content['button'])) |
| 358 | 358 | { |
| 359 | 359 | list($button) = each($content['button']); |
| 360 | 360 | unset($content['button']); |
| 361 | - switch($button) |
|
| 361 | + switch ($button) |
|
| 362 | 362 | { |
| 363 | 363 | case 'back': |
| 364 | 364 | return $this->add($content); |
@@ -368,7 +368,7 @@ discard block |
||
| 368 | 368 | } |
| 369 | 369 | } |
| 370 | 370 | $content['msg'] = $msg; |
| 371 | - if (!isset($imap)) $imap = self::imap_client ($content); |
|
| 371 | + if (!isset($imap)) $imap = self::imap_client($content); |
|
| 372 | 372 | |
| 373 | 373 | try { |
| 374 | 374 | //_debug_array($content); |
@@ -376,7 +376,7 @@ discard block |
||
| 376 | 376 | $sel_options['acc_folder_draft'] = $sel_options['acc_folder_template'] = |
| 377 | 377 | $sel_options['acc_folder_junk'] = $sel_options['acc_folder_archive'] = self::mailboxes($imap, $content); |
| 378 | 378 | } |
| 379 | - catch(Exception $e) { |
|
| 379 | + catch (Exception $e) { |
|
| 380 | 380 | $content['msg'] = $e->getMessage(); |
| 381 | 381 | if (self::$debug) _egw_log_exception($e); |
| 382 | 382 | } |
@@ -393,27 +393,27 @@ discard block |
||
| 393 | 393 | * @return array with folders as key AND value |
| 394 | 394 | * @throws Horde_Imap_Client_Exception |
| 395 | 395 | */ |
| 396 | - public static function mailboxes(Horde_Imap_Client_Socket $imap, array &$content=null) |
|
| 396 | + public static function mailboxes(Horde_Imap_Client_Socket $imap, array &$content = null) |
|
| 397 | 397 | { |
| 398 | 398 | // query all subscribed mailboxes |
| 399 | 399 | $mailboxes = $imap->listMailboxes('*', Horde_Imap_Client::MBOX_SUBSCRIBED, array( |
| 400 | 400 | 'special_use' => true, |
| 401 | - 'attributes' => true, // otherwise special_use is only queried, but not returned ;-) |
|
| 401 | + 'attributes' => true, // otherwise special_use is only queried, but not returned ;-) |
|
| 402 | 402 | 'delimiter' => true, |
| 403 | 403 | )); |
| 404 | 404 | //_debug_array($mailboxes); |
| 405 | 405 | // list mailboxes by special-use attributes |
| 406 | 406 | $folders = $attributes = $all = array(); |
| 407 | - foreach($mailboxes as $mailbox => $data) |
|
| 407 | + foreach ($mailboxes as $mailbox => $data) |
|
| 408 | 408 | { |
| 409 | - foreach($data['attributes'] as $attribute) |
|
| 409 | + foreach ($data['attributes'] as $attribute) |
|
| 410 | 410 | { |
| 411 | 411 | $attributes[$attribute][] = $mailbox; |
| 412 | 412 | } |
| 413 | 413 | $folders[$mailbox] = $mailbox.': '.implode(', ', $data['attributes']); |
| 414 | 414 | } |
| 415 | 415 | // pre-select send, trash, ... folder for user, by checking special-use attributes or common name(s) |
| 416 | - foreach(array( |
|
| 416 | + foreach (array( |
|
| 417 | 417 | 'acc_folder_sent' => array('\\sent', 'sent'), |
| 418 | 418 | 'acc_folder_trash' => array('\\trash', 'trash'), |
| 419 | 419 | 'acc_folder_draft' => array('\\drafts', 'drafts'), |
@@ -425,7 +425,7 @@ discard block |
||
| 425 | 425 | // first check special-use attributes |
| 426 | 426 | if (($special_use = array_shift($common_names))) |
| 427 | 427 | { |
| 428 | - foreach((array)$attributes[$special_use] as $mailbox) |
|
| 428 | + foreach ((array)$attributes[$special_use] as $mailbox) |
|
| 429 | 429 | { |
| 430 | 430 | if (empty($content[$name]) || strlen($mailbox) < strlen($content[$name])) |
| 431 | 431 | { |
@@ -436,7 +436,7 @@ discard block |
||
| 436 | 436 | // no special use folder found, try common names |
| 437 | 437 | if (empty($content[$name])) |
| 438 | 438 | { |
| 439 | - foreach($mailboxes as $mailbox => $data) |
|
| 439 | + foreach ($mailboxes as $mailbox => $data) |
|
| 440 | 440 | { |
| 441 | 441 | $delimiter = !empty($data['delimiter']) ? $data['delimiter'] : '.'; |
| 442 | 442 | $name_parts = explode($delimiter, strtolower($mailbox)); |
@@ -463,7 +463,7 @@ discard block |
||
| 463 | 463 | * @param array $content |
| 464 | 464 | * @param string $msg ='' |
| 465 | 465 | */ |
| 466 | - public function sieve(array $content, $msg='') |
|
| 466 | + public function sieve(array $content, $msg = '') |
|
| 467 | 467 | { |
| 468 | 468 | static $sieve_ssl2port = array( |
| 469 | 469 | self::SSL_TLS => 5190, |
@@ -477,7 +477,7 @@ discard block |
||
| 477 | 477 | { |
| 478 | 478 | list($button) = each($content['button']); |
| 479 | 479 | unset($content['button']); |
| 480 | - switch($button) |
|
| 480 | + switch ($button) |
|
| 481 | 481 | { |
| 482 | 482 | case 'back': |
| 483 | 483 | return $this->folder($content); |
@@ -526,9 +526,9 @@ discard block |
||
| 526 | 526 | { |
| 527 | 527 | $data = $sieve_ssl2port; |
| 528 | 528 | } |
| 529 | - foreach($data as $ssl => $ports) |
|
| 529 | + foreach ($data as $ssl => $ports) |
|
| 530 | 530 | { |
| 531 | - foreach((array)$ports as $port) |
|
| 531 | + foreach ((array)$ports as $port) |
|
| 532 | 532 | { |
| 533 | 533 | $content['acc_sieve_ssl'] = $ssl; |
| 534 | 534 | $ssl_label = self::$ssl_types[$ssl]; |
@@ -546,7 +546,7 @@ discard block |
||
| 546 | 546 | )); |
| 547 | 547 | // connect to sieve server |
| 548 | 548 | $sieve->connect(); |
| 549 | - $content['sieve_output'] .= "\n".lang('Successful connected to %1 server%2.', 'Sieve',''); |
|
| 549 | + $content['sieve_output'] .= "\n".lang('Successful connected to %1 server%2.', 'Sieve', ''); |
|
| 550 | 550 | // and log in |
| 551 | 551 | $sieve->login($content['acc_imap_username'], $content['acc_imap_password']); |
| 552 | 552 | $content['sieve_output'] .= ' '.lang('and logged in')."\n"; |
@@ -556,10 +556,10 @@ discard block |
||
| 556 | 556 | return $this->smtp($content, lang('Successful connected to %1 server%2.', 'Sieve', |
| 557 | 557 | ' '.lang('and logged in'))); |
| 558 | 558 | } |
| 559 | - catch(Horde\ManageSieve\Exception\ConnectionFailed $e) { |
|
| 559 | + catch (Horde\ManageSieve\Exception\ConnectionFailed $e) { |
|
| 560 | 560 | $content['sieve_output'] .= "\n".$e->getMessage().' '.$e->details."\n"; |
| 561 | 561 | } |
| 562 | - catch(Exception $e) { |
|
| 562 | + catch (Exception $e) { |
|
| 563 | 563 | $content['sieve_output'] .= "\n".get_class($e).': '.$e->getMessage(). |
| 564 | 564 | ($e->details ? ' '.$e->details : '').' ('.$e->getCode().')'."\n"; |
| 565 | 565 | $content['sieve_output'] .= $e->getTraceAsString()."\n"; |
@@ -577,7 +577,7 @@ discard block |
||
| 577 | 577 | // add validation error, if we can identify a field |
| 578 | 578 | if (!$content['sieve_connected'] && $e instanceof Exception) |
| 579 | 579 | { |
| 580 | - switch($e->getCode()) |
|
| 580 | + switch ($e->getCode()) |
|
| 581 | 581 | { |
| 582 | 582 | case 61: // connection refused |
| 583 | 583 | case 60: // connection timed out (imap.googlemail.com returns that for none-ssl/4190/2000) |
@@ -600,7 +600,7 @@ discard block |
||
| 600 | 600 | * @param array $content |
| 601 | 601 | * @param string $msg ='' |
| 602 | 602 | */ |
| 603 | - public function smtp(array $content, $msg='') |
|
| 603 | + public function smtp(array $content, $msg = '') |
|
| 604 | 604 | { |
| 605 | 605 | static $smtp_ssl2port = array( |
| 606 | 606 | self::SSL_NONE => 25, |
@@ -614,7 +614,7 @@ discard block |
||
| 614 | 614 | { |
| 615 | 615 | list($button) = each($content['button']); |
| 616 | 616 | unset($content['button']); |
| 617 | - switch($button) |
|
| 617 | + switch ($button) |
|
| 618 | 618 | { |
| 619 | 619 | case 'back': |
| 620 | 620 | return $this->sieve($content); |
@@ -655,11 +655,11 @@ discard block |
||
| 655 | 655 | ); |
| 656 | 656 | } |
| 657 | 657 | } |
| 658 | - elseif($content['ispdb'] && !empty($content['ispdb']['smtp'])) |
|
| 658 | + elseif ($content['ispdb'] && !empty($content['ispdb']['smtp'])) |
|
| 659 | 659 | { |
| 660 | 660 | $content['smtp_output'] .= lang('Using data from Mozilla ISPDB for provider %1', $content['ispdb']['displayName'])."\n"; |
| 661 | 661 | $hosts = array(); |
| 662 | - foreach($content['ispdb']['smtp'] as $server) |
|
| 662 | + foreach ($content['ispdb']['smtp'] as $server) |
|
| 663 | 663 | { |
| 664 | 664 | if (!isset($hosts[$server['hostname']])) |
| 665 | 665 | { |
@@ -681,14 +681,14 @@ discard block |
||
| 681 | 681 | { |
| 682 | 682 | $hosts = $this->guess_hosts($content['ident_email'], 'smtp'); |
| 683 | 683 | } |
| 684 | - foreach($hosts as $host => $data) |
|
| 684 | + foreach ($hosts as $host => $data) |
|
| 685 | 685 | { |
| 686 | 686 | $content['acc_smtp_host'] = $host; |
| 687 | 687 | if (!is_array($data)) |
| 688 | 688 | { |
| 689 | 689 | $data = array('TLS' => 465, 'SSL' => 465, 'STARTTLS' => 587, '' => 25); |
| 690 | 690 | } |
| 691 | - foreach($data as $ssl => $port) |
|
| 691 | + foreach ($data as $ssl => $port) |
|
| 692 | 692 | { |
| 693 | 693 | if ($ssl === 'username') continue; |
| 694 | 694 | |
@@ -699,7 +699,7 @@ discard block |
||
| 699 | 699 | $content['smtp_output'] .= "\n".Api\DateTime::to('now', 'H:i:s').": Trying $ssl connection to $host:$port ...\n"; |
| 700 | 700 | $content['acc_smtp_port'] = $port; |
| 701 | 701 | |
| 702 | - $mail = new Horde_Mail_Transport_Smtphorde($params=array( |
|
| 702 | + $mail = new Horde_Mail_Transport_Smtphorde($params = array( |
|
| 703 | 703 | 'username' => $content['acc_smtp_username'], |
| 704 | 704 | 'password' => $content['acc_smtp_password'], |
| 705 | 705 | 'host' => $content['acc_smtp_host'], |
@@ -739,9 +739,9 @@ discard block |
||
| 739 | 739 | } |
| 740 | 740 | // unfortunately LOGIN_AUTHENTICATIONFAILED and SERVER_CONNECT are thrown as Horde_Mail_Exception |
| 741 | 741 | // while others are thrown as Horde_Smtp_Exception --> using common base Horde_Exception_Wrapped |
| 742 | - catch(Horde_Exception_Wrapped $e) |
|
| 742 | + catch (Horde_Exception_Wrapped $e) |
|
| 743 | 743 | { |
| 744 | - switch($e->getCode()) |
|
| 744 | + switch ($e->getCode()) |
|
| 745 | 745 | { |
| 746 | 746 | case Horde_Smtp_Exception::LOGIN_AUTHENTICATIONFAILED: |
| 747 | 747 | case Horde_Smtp_Exception::LOGIN_REQUIREAUTHENTICATION: |
@@ -757,14 +757,14 @@ discard block |
||
| 757 | 757 | } |
| 758 | 758 | if (self::$debug) _egw_log_exception($e); |
| 759 | 759 | } |
| 760 | - catch(Horde_Smtp_Exception $e) |
|
| 760 | + catch (Horde_Smtp_Exception $e) |
|
| 761 | 761 | { |
| 762 | 762 | // prever $e->details over $e->getMessage() as it contains original message from SMTP server (eg. relay access denied) |
| 763 | 763 | $content['smtp_output'] .= "\n".(empty($e->details) ? $e->getMessage().' ('.$e->getCode().')' : $e->details)."\n"; |
| 764 | 764 | //$content['smtp_output'] .= $e->getTraceAsString()."\n"; |
| 765 | 765 | if (self::$debug) _egw_log_exception($e); |
| 766 | 766 | } |
| 767 | - catch(Exception $e) { |
|
| 767 | + catch (Exception $e) { |
|
| 768 | 768 | $content['smtp_output'] .= "\n".get_class($e).': '.$e->getMessage().' ('.$e->getCode().')'."\n"; |
| 769 | 769 | //$content['smtp_output'] .= $e->getTraceAsString()."\n"; |
| 770 | 770 | if (self::$debug) _egw_log_exception($e); |
@@ -775,7 +775,7 @@ discard block |
||
| 775 | 775 | // add validation error, if we can identify a field |
| 776 | 776 | if (!$content['smtp_connected'] && $e instanceof Horde_Exception_Wrapped) |
| 777 | 777 | { |
| 778 | - switch($e->getCode()) |
|
| 778 | + switch ($e->getCode()) |
|
| 779 | 779 | { |
| 780 | 780 | case Horde_Smtp_Exception::LOGIN_AUTHENTICATIONFAILED: |
| 781 | 781 | case Horde_Smtp_Exception::LOGIN_REQUIREAUTHENTICATION: |
@@ -809,14 +809,14 @@ discard block |
||
| 809 | 809 | * @param string $msg ='' |
| 810 | 810 | * @param string $msg_type ='success' |
| 811 | 811 | */ |
| 812 | - public function edit(array $content=null, $msg='', $msg_type='success') |
|
| 812 | + public function edit(array $content = null, $msg = '', $msg_type = 'success') |
|
| 813 | 813 | { |
| 814 | 814 | // app is trying to tell something, while redirecting to wizard |
| 815 | - if (empty($content) && $_GET['acc_id'] && empty($msg) && !empty( $_GET['msg'])) |
|
| 815 | + if (empty($content) && $_GET['acc_id'] && empty($msg) && !empty($_GET['msg'])) |
|
| 816 | 816 | { |
| 817 | - if (stripos($_GET['msg'],'fatal error:')!==false || $_GET['msg_type'] == 'error') $msg_type = 'error'; |
|
| 817 | + if (stripos($_GET['msg'], 'fatal error:') !== false || $_GET['msg_type'] == 'error') $msg_type = 'error'; |
|
| 818 | 818 | } |
| 819 | - if ($content['acc_id'] || (isset($_GET['acc_id']) && (int)$_GET['acc_id'] > 0) ) Mail::unsetCachedObjects($content['acc_id']?$content['acc_id']:$_GET['acc_id']); |
|
| 819 | + if ($content['acc_id'] || (isset($_GET['acc_id']) && (int)$_GET['acc_id'] > 0)) Mail::unsetCachedObjects($content['acc_id'] ? $content['acc_id'] : $_GET['acc_id']); |
|
| 820 | 820 | $tpl = new Etemplate('admin.mailaccount'); |
| 821 | 821 | |
| 822 | 822 | if (!is_array($content) || !empty($content['acc_id']) && isset($content['old_acc_id']) && $content['acc_id'] != $content['old_acc_id']) |
@@ -831,7 +831,7 @@ discard block |
||
| 831 | 831 | list($content['acc_id']) = each($content['accounts']); |
| 832 | 832 | //error_log(__METHOD__.__LINE__.'.'.array2string($content['acc_id'])); |
| 833 | 833 | // test if the "to be selected" acccount is imap or not |
| 834 | - if (count($content['accounts'])>1 && Mail\Account::is_multiple($content['acc_id'])) |
|
| 834 | + if (count($content['accounts']) > 1 && Mail\Account::is_multiple($content['acc_id'])) |
|
| 835 | 835 | { |
| 836 | 836 | try { |
| 837 | 837 | $account = Mail\Account::read($content['acc_id'], $content['called_for']); |
@@ -842,7 +842,7 @@ discard block |
||
| 842 | 842 | //error_log(__METHOD__.__LINE__.'.'.array2string($content['acc_id'])); |
| 843 | 843 | } |
| 844 | 844 | } |
| 845 | - catch(Api\Exception\NotFound $e) { |
|
| 845 | + catch (Api\Exception\NotFound $e) { |
|
| 846 | 846 | if (self::$debug) _egw_log_exception($e); |
| 847 | 847 | } |
| 848 | 848 | } |
@@ -865,7 +865,7 @@ discard block |
||
| 865 | 865 | try { |
| 866 | 866 | $account = Mail\Account::read($content['acc_id'], $this->is_admin && $content['called_for'] ? |
| 867 | 867 | $content['called_for'] : $GLOBALS['egw_info']['user']['account_id']); |
| 868 | - $account->getUserData(); // quota, aliases, forwards etc. |
|
| 868 | + $account->getUserData(); // quota, aliases, forwards etc. |
|
| 869 | 869 | $content += $account->params; |
| 870 | 870 | $content['acc_sieve_enabled'] = (string)($content['acc_sieve_enabled']); |
| 871 | 871 | $content['notify_use_default'] = !$content['notify_account_id']; |
@@ -876,16 +876,16 @@ discard block |
||
| 876 | 876 | $content['std_ident_id'] = $content['ident_id']; |
| 877 | 877 | $content['identities'][$content['std_ident_id']] = lang('Standard identity'); |
| 878 | 878 | // change self::SSL_NONE (=0) to "no" used in sel_options |
| 879 | - foreach(array('imap','smtp','sieve') as $type) |
|
| 879 | + foreach (array('imap', 'smtp', 'sieve') as $type) |
|
| 880 | 880 | { |
| 881 | 881 | if (!$content['acc_'.$type.'_ssl']) $content['acc_'.$type.'_ssl'] = 'no'; |
| 882 | 882 | } |
| 883 | 883 | } |
| 884 | - catch(Api\Exception\NotFound $e) { |
|
| 884 | + catch (Api\Exception\NotFound $e) { |
|
| 885 | 885 | if (self::$debug) _egw_log_exception($e); |
| 886 | 886 | Framework::window_close(lang('Account not found!')); |
| 887 | 887 | } |
| 888 | - catch(Exception $e) { |
|
| 888 | + catch (Exception $e) { |
|
| 889 | 889 | if (self::$debug) _egw_log_exception($e); |
| 890 | 890 | Framework::window_close($e->getMessage().' ('.get_class($e).': '.$e->getCode().')'); |
| 891 | 891 | } |
@@ -893,7 +893,7 @@ discard block |
||
| 893 | 893 | elseif ($content['acc_id'] === 'new') |
| 894 | 894 | { |
| 895 | 895 | $content['account_id'] = $content['called_for']; |
| 896 | - $content['old_acc_id'] = $content['acc_id']; // to not call add/wizard, if we return from to |
|
| 896 | + $content['old_acc_id'] = $content['acc_id']; // to not call add/wizard, if we return from to |
|
| 897 | 897 | unset($content['tabs']); |
| 898 | 898 | return $this->add($content); |
| 899 | 899 | } |
@@ -903,7 +903,7 @@ discard block |
||
| 903 | 903 | { |
| 904 | 904 | if (!isset($content['account_id'])) $content['account_id'] = array($GLOBALS['egw_info']['user']['account_id']); |
| 905 | 905 | $content['acc_user_editable'] = $content['acc_further_identities'] = true; |
| 906 | - $readonlys['ident_id'] = true; // need to create standard identity first |
|
| 906 | + $readonlys['ident_id'] = true; // need to create standard identity first |
|
| 907 | 907 | } |
| 908 | 908 | if (empty($content['acc_name'])) |
| 909 | 909 | { |
@@ -939,7 +939,7 @@ discard block |
||
| 939 | 939 | { |
| 940 | 940 | list($button) = each($content['button']); |
| 941 | 941 | unset($content['button']); |
| 942 | - switch($button) |
|
| 942 | + switch ($button) |
|
| 943 | 943 | { |
| 944 | 944 | case 'wizard': |
| 945 | 945 | // if we just came from wizard, go back to last page/step |
@@ -972,7 +972,7 @@ discard block |
||
| 972 | 972 | { |
| 973 | 973 | $content['ident_id'] = Mail\Account::save_identity(array( |
| 974 | 974 | 'account_id' => $content['called_for'] ? $content['called_for'] : $GLOBALS['egw_info']['user']['account_id'], |
| 975 | - )+$content); |
|
| 975 | + ) + $content); |
|
| 976 | 976 | $content['identities'][$content['ident_id']] = Mail\Account::identity_name($content); |
| 977 | 977 | $msg = lang('Identity saved.'); |
| 978 | 978 | if ($edit_access) $msg .= ' '.lang('Switch back to standard identity to save account.'); |
@@ -1076,17 +1076,17 @@ discard block |
||
| 1076 | 1076 | catch (Horde_Imap_Client_Exception $e) |
| 1077 | 1077 | { |
| 1078 | 1078 | _egw_log_exception($e); |
| 1079 | - $tpl->set_validation_error('acc_imap_admin_username', $msg=lang($e->getMessage()).($e->details?', '.lang($e->details):'')); |
|
| 1079 | + $tpl->set_validation_error('acc_imap_admin_username', $msg = lang($e->getMessage()).($e->details ? ', '.lang($e->details) : '')); |
|
| 1080 | 1080 | $msg_type = 'error'; |
| 1081 | - $content['tabs'] = 'admin.mailaccount.imap'; // should happen automatic |
|
| 1081 | + $content['tabs'] = 'admin.mailaccount.imap'; // should happen automatic |
|
| 1082 | 1082 | break; |
| 1083 | 1083 | } |
| 1084 | 1084 | catch (Horde\ManageSieve\Exception\ConnectionFailed $e) |
| 1085 | 1085 | { |
| 1086 | 1086 | _egw_log_exception($e); |
| 1087 | - $tpl->set_validation_error('acc_sieve_port', $msg=lang($e->getMessage())); |
|
| 1087 | + $tpl->set_validation_error('acc_sieve_port', $msg = lang($e->getMessage())); |
|
| 1088 | 1088 | $msg_type = 'error'; |
| 1089 | - $content['tabs'] = 'admin.mailaccount.sieve'; // should happen automatic |
|
| 1089 | + $content['tabs'] = 'admin.mailaccount.sieve'; // should happen automatic |
|
| 1090 | 1090 | break; |
| 1091 | 1091 | } |
| 1092 | 1092 | catch (Exception $e) { |
@@ -1095,7 +1095,7 @@ discard block |
||
| 1095 | 1095 | $msg_type = 'error'; |
| 1096 | 1096 | } |
| 1097 | 1097 | if ($content['acc_id']) Mail::unsetCachedObjects($content['acc_id']); |
| 1098 | - if (stripos($msg,'fatal error:')!==false) $msg_type = 'error'; |
|
| 1098 | + if (stripos($msg, 'fatal error:') !== false) $msg_type = 'error'; |
|
| 1099 | 1099 | Framework::refresh_opener($msg, 'emailadmin', $content['acc_id'], $new_account ? 'add' : 'update', null, null, null, $msg_type); |
| 1100 | 1100 | if ($button == 'save') Framework::window_close(); |
| 1101 | 1101 | break; |
@@ -1148,7 +1148,7 @@ discard block |
||
| 1148 | 1148 | if ($this->is_admin && (empty($content['acc_imap_username']) || empty($content['acc_imap_host']) || $content['called_for'])) |
| 1149 | 1149 | { |
| 1150 | 1150 | // cant connection to imap --> allow free entries in taglists |
| 1151 | - foreach(array('acc_folder_sent', 'acc_folder_trash', 'acc_folder_draft', 'acc_folder_template', 'acc_folder_junk') as $folder) |
|
| 1151 | + foreach (array('acc_folder_sent', 'acc_folder_trash', 'acc_folder_draft', 'acc_folder_template', 'acc_folder_junk') as $folder) |
|
| 1152 | 1152 | { |
| 1153 | 1153 | $tpl->setElementAttribute($folder, 'allowFreeEntries', true); |
| 1154 | 1154 | } |
@@ -1159,15 +1159,15 @@ discard block |
||
| 1159 | 1159 | $sel_options['acc_folder_sent'] = $sel_options['acc_folder_trash'] = |
| 1160 | 1160 | $sel_options['acc_folder_draft'] = $sel_options['acc_folder_template'] = |
| 1161 | 1161 | $sel_options['acc_folder_junk'] = $sel_options['acc_folder_archive'] = $sel_options['notify_folders'] = |
| 1162 | - self::mailboxes(self::imap_client ($content)); |
|
| 1162 | + self::mailboxes(self::imap_client($content)); |
|
| 1163 | 1163 | } |
| 1164 | - catch(Exception $e) { |
|
| 1164 | + catch (Exception $e) { |
|
| 1165 | 1165 | if (self::$debug) _egw_log_exception($e); |
| 1166 | 1166 | // let user know what the problem is and that he can fix it using wizard or deleting |
| 1167 | 1167 | $msg = lang($e->getMessage())."\n\n".lang('You can use wizard to fix account settings or delete account.'); |
| 1168 | 1168 | $msg_type = 'error'; |
| 1169 | 1169 | // cant connection to imap --> allow free entries in taglists |
| 1170 | - foreach(array('acc_folder_sent', 'acc_folder_trash', 'acc_folder_draft', 'acc_folder_template', 'acc_folder_junk') as $folder) |
|
| 1170 | + foreach (array('acc_folder_sent', 'acc_folder_trash', 'acc_folder_draft', 'acc_folder_template', 'acc_folder_junk') as $folder) |
|
| 1171 | 1171 | { |
| 1172 | 1172 | $tpl->setElementAttribute($folder, 'allowFreeEntries', true); |
| 1173 | 1173 | } |
@@ -1264,7 +1264,7 @@ discard block |
||
| 1264 | 1264 | if ($content['called_for'] && $content['acc_id'] > 0) |
| 1265 | 1265 | { |
| 1266 | 1266 | $admin_actions = array(); |
| 1267 | - foreach(Api\Hooks::process(array( |
|
| 1267 | + foreach (Api\Hooks::process(array( |
|
| 1268 | 1268 | 'location' => 'emailadmin_edit', |
| 1269 | 1269 | 'account_id' => $content['called_for'], |
| 1270 | 1270 | 'acc_id' => $content['acc_id'], |
@@ -1285,7 +1285,7 @@ discard block |
||
| 1285 | 1285 | * @param string|array &$account_id on return always array |
| 1286 | 1286 | * @param boolean $back =false |
| 1287 | 1287 | */ |
| 1288 | - private static function fix_account_id_0(&$account_id=null, $back=false) |
|
| 1288 | + private static function fix_account_id_0(&$account_id = null, $back = false) |
|
| 1289 | 1289 | { |
| 1290 | 1290 | if (!isset($account_id)) return; |
| 1291 | 1291 | |
@@ -1293,7 +1293,7 @@ discard block |
||
| 1293 | 1293 | { |
| 1294 | 1294 | $account_id = explode(',', $account_id); |
| 1295 | 1295 | } |
| 1296 | - if (($k = array_search($back?'':'0', $account_id)) !== false) |
|
| 1296 | + if (($k = array_search($back ? '' : '0', $account_id)) !== false) |
|
| 1297 | 1297 | { |
| 1298 | 1298 | $account_id[$k] = $back ? '0' : ''; |
| 1299 | 1299 | } |
@@ -1306,7 +1306,7 @@ discard block |
||
| 1306 | 1306 | * @param int $timeout =null default use value returned by Mail\Imap::getTimeOut() |
| 1307 | 1307 | * @return Horde_Imap_Client_Socket |
| 1308 | 1308 | */ |
| 1309 | - protected static function imap_client(array $content, $timeout=null) |
|
| 1309 | + protected static function imap_client(array $content, $timeout = null) |
|
| 1310 | 1310 | { |
| 1311 | 1311 | return new Horde_Imap_Client_Socket(array( |
| 1312 | 1312 | 'username' => $content['acc_imap_username'], |
@@ -1328,7 +1328,7 @@ discard block |
||
| 1328 | 1328 | protected static function fix_ssl_order($data) |
| 1329 | 1329 | { |
| 1330 | 1330 | $ordered = array(); |
| 1331 | - foreach(array_merge(array('TLS', 'SSL', 'STARTTLS'), array_keys($data)) as $key) |
|
| 1331 | + foreach (array_merge(array('TLS', 'SSL', 'STARTTLS'), array_keys($data)) as $key) |
|
| 1332 | 1332 | { |
| 1333 | 1333 | if (array_key_exists($key, $data)) $ordered[$key] = $data[$key]; |
| 1334 | 1334 | } |
@@ -1346,7 +1346,7 @@ discard block |
||
| 1346 | 1346 | * @return array with values for keys 'displayName', 'imap', 'smtp', 'pop3', which each contain |
| 1347 | 1347 | * array of arrays with values for keys 'hostname', 'port', 'socketType'=(SSL|STARTTLS), 'username'=%EMAILADDRESS% |
| 1348 | 1348 | */ |
| 1349 | - protected static function mozilla_ispdb($domain, $try_mx=true) |
|
| 1349 | + protected static function mozilla_ispdb($domain, $try_mx = true) |
|
| 1350 | 1350 | { |
| 1351 | 1351 | if (strpos($domain, '@') !== false) list(,$domain) = explode('@', $domain); |
| 1352 | 1352 | |
@@ -1357,17 +1357,17 @@ discard block |
||
| 1357 | 1357 | $provider = array( |
| 1358 | 1358 | 'displayName' => (string)$xml->emailProvider->displayName, |
| 1359 | 1359 | ); |
| 1360 | - foreach($xml->emailProvider->children() as $tag => $server) |
|
| 1360 | + foreach ($xml->emailProvider->children() as $tag => $server) |
|
| 1361 | 1361 | { |
| 1362 | 1362 | if (!in_array($tag, array('incomingServer', 'outgoingServer'))) continue; |
| 1363 | - foreach($server->attributes() as $name => $value) |
|
| 1363 | + foreach ($server->attributes() as $name => $value) |
|
| 1364 | 1364 | { |
| 1365 | 1365 | if ($name == 'type') $type = (string)$value; |
| 1366 | 1366 | } |
| 1367 | 1367 | $data = array(); |
| 1368 | - foreach($server as $name => $value) |
|
| 1368 | + foreach ($server as $name => $value) |
|
| 1369 | 1369 | { |
| 1370 | - foreach($value->children() as $tag => $val) |
|
| 1370 | + foreach ($value->children() as $tag => $val) |
|
| 1371 | 1371 | { |
| 1372 | 1372 | $data[$name][$tag] = (string)$val; |
| 1373 | 1373 | } |
@@ -1376,7 +1376,7 @@ discard block |
||
| 1376 | 1376 | $provider[$type][] = $data; |
| 1377 | 1377 | } |
| 1378 | 1378 | } |
| 1379 | - catch(Exception $e) { |
|
| 1379 | + catch (Exception $e) { |
|
| 1380 | 1380 | // ignore own not-found exception or xml parsing execptions |
| 1381 | 1381 | unset($e); |
| 1382 | 1382 | |
@@ -1408,7 +1408,7 @@ discard block |
||
| 1408 | 1408 | * @param string $type ='imap' 'imap' or 'smtp', used as hostname beside 'mail' |
| 1409 | 1409 | * @return array of hostname => true pairs |
| 1410 | 1410 | */ |
| 1411 | - protected function guess_hosts($email, $type='imap') |
|
| 1411 | + protected function guess_hosts($email, $type = 'imap') |
|
| 1412 | 1412 | { |
| 1413 | 1413 | list(,$domain) = explode('@', $email); |
| 1414 | 1414 | |
@@ -1434,7 +1434,7 @@ discard block |
||
| 1434 | 1434 | } |
| 1435 | 1435 | |
| 1436 | 1436 | // verify hosts in dns |
| 1437 | - foreach(array_keys($hosts) as $host) |
|
| 1437 | + foreach (array_keys($hosts) as $host) |
|
| 1438 | 1438 | { |
| 1439 | 1439 | if (!dns_get_record($host, DNS_A)) unset($hosts[$host]); |
| 1440 | 1440 | } |
@@ -1471,12 +1471,12 @@ discard block |
||
| 1471 | 1471 | } |
| 1472 | 1472 | |
| 1473 | 1473 | $ea_account = Mail\Account::read($emailadmin->acc_id, $_data['id']); |
| 1474 | - if (($userData = $ea_account->getUserData ())) |
|
| 1474 | + if (($userData = $ea_account->getUserData())) |
|
| 1475 | 1475 | { |
| 1476 | 1476 | $userData = array( |
| 1477 | 1477 | 'acc_smtp_type' => $ea_account->acc_smtp_type, |
| 1478 | 1478 | 'accountStatus' => $_data['status'], |
| 1479 | - 'quotaLimit' => $_data['qouta']? $_data['qouta']: $userData['qoutaLimit'], |
|
| 1479 | + 'quotaLimit' => $_data['qouta'] ? $_data['qouta'] : $userData['qoutaLimit'], |
|
| 1480 | 1480 | 'mailLocalAddress' => $userData['mailLocalAddress'] |
| 1481 | 1481 | ); |
| 1482 | 1482 | |
@@ -1484,7 +1484,7 @@ discard block |
||
| 1484 | 1484 | { |
| 1485 | 1485 | $userData['mailLocalAddress'] = preg_replace('/@'.preg_quote($ea_account->acc_domain).'$/', '@'.$_data['domain'], $userData['mailLocalAddress']); |
| 1486 | 1486 | |
| 1487 | - foreach($userData['mailAlternateAddress'] as &$alias) |
|
| 1487 | + foreach ($userData['mailAlternateAddress'] as &$alias) |
|
| 1488 | 1488 | { |
| 1489 | 1489 | $alias = preg_replace('/@'.preg_quote($ea_account->acc_domain).'$/', '@'.$_data['domain'], $alias); |
| 1490 | 1490 | } |
@@ -1492,7 +1492,7 @@ discard block |
||
| 1492 | 1492 | // fullfill the saveUserData requirements |
| 1493 | 1493 | $userData += $ea_account->params; |
| 1494 | 1494 | $ea_account->saveUserData($_data['id'], $userData); |
| 1495 | - $msg = '#'.$_data['id'].' '.$account['account_fullname']. ' '.($userData['accountStatus'] == 'active'? lang('activated'):lang('deactivated')); |
|
| 1495 | + $msg = '#'.$_data['id'].' '.$account['account_fullname'].' '.($userData['accountStatus'] == 'active' ? lang('activated') : lang('deactivated')); |
|
| 1496 | 1496 | } |
| 1497 | 1497 | else |
| 1498 | 1498 | { |