Passed
Push — 17.1 ( 431f3f...4dae72 )
by Ralf
01:23 queued 12s
created
api/src/Auth/Nis.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -26,22 +26,22 @@  discard block
 block discarded – undo
26 26
 	 * @param string $passwd_type ='text' 'text' for cleartext passwords (default)
27 27
 	 * @return boolean true if successful authenticated, false otherwise
28 28
 	 */
29
-	function authenticate($username, $passwd, $passwd_type='text')
29
+	function authenticate($username, $passwd, $passwd_type = 'text')
30 30
 	{
31
-		unset($passwd_type);	// not used but required by interface
31
+		unset($passwd_type); // not used but required by interface
32 32
 
33 33
 		$domain = yp_get_default_domain();
34
-		if(!empty($GLOBALS['egw_info']['server']['nis_domain']))
34
+		if (!empty($GLOBALS['egw_info']['server']['nis_domain']))
35 35
 		{
36 36
 			$domain = $GLOBALS['egw_info']['server']['nis_domain'];
37 37
 		}
38 38
 
39 39
 		$map = "passwd.byname";
40
-		if(!empty($GLOBALS['egw_info']['server']['nis_map']))
40
+		if (!empty($GLOBALS['egw_info']['server']['nis_map']))
41 41
 		{
42 42
 			$map = $GLOBALS['egw_info']['server']['nis_map'];
43 43
 		}
44
-		$entry = yp_match( $domain, $map, $username );
44
+		$entry = yp_match($domain, $map, $username);
45 45
 
46 46
 		/*
47 47
 		 * we assume that the map is structured in the usual
@@ -63,11 +63,11 @@  discard block
 block discarded – undo
63 63
 	 * @param int $account_id =0 account id of user whose passwd should be changed
64 64
 	 * @return boolean true if password successful changed, false otherwise
65 65
 	 */
66
-	function change_password($old_passwd, $new_passwd, $account_id=0)
66
+	function change_password($old_passwd, $new_passwd, $account_id = 0)
67 67
 	{
68
-		unset($old_passwd, $new_passwd, $account_id);	// not used but required by interface
68
+		unset($old_passwd, $new_passwd, $account_id); // not used but required by interface
69 69
 
70 70
 		// can't change passwords unless server runs as root (bad idea)
71
-		return( False );
71
+		return(False);
72 72
 	}
73 73
 }
Please login to merge, or discard this patch.
api/src/Auth/Sqlssl.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -29,21 +29,21 @@  discard block
 block discarded – undo
29 29
 	 * @param string $passwd_type ='text' 'text' for cleartext passwords (default)
30 30
 	 * @return boolean true if successful authenticated, false otherwise
31 31
 	 */
32
-	function authenticate($username, $passwd, $passwd_type='text')
32
+	function authenticate($username, $passwd, $passwd_type = 'text')
33 33
 	{
34
-		unset($passwd_type);	// not used but required by interface
34
+		unset($passwd_type); // not used but required by interface
35 35
 
36 36
 		$local_debug = False;
37 37
 
38
-		if($local_debug)
38
+		if ($local_debug)
39 39
 		{
40 40
 			echo "<b>Debug SQL: uid - $username passwd - $passwd</b>";
41 41
 		}
42
-		if (!($row = $this->db->select($this->table,'account_lid,account_pwd',array(
42
+		if (!($row = $this->db->select($this->table, 'account_lid,account_pwd', array(
43 43
 			'account_lid' => $username,
44 44
 			'account_status' => 'A',
45 45
 			'account_type'   => 'u',
46
-		),__LINE__,__FILE__)->fetch()) || $GLOBALS['egw_info']['server']['case_sensitive_username'] && $row['account_lid'] != $username)
46
+		), __LINE__, __FILE__)->fetch()) || $GLOBALS['egw_info']['server']['case_sensitive_username'] && $row['account_lid'] != $username)
47 47
 		{
48 48
 			return false;
49 49
 		}
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 		# Apache + mod_ssl provide the data in the environment
52 52
 		# Certificate (chain) verification occurs inside mod_ssl
53 53
 		# see http://www.modssl.org/docs/2.8/ssl_howto.html#ToC6
54
-		if(!isset($_SERVER['SSL_CLIENT_S_DN']))
54
+		if (!isset($_SERVER['SSL_CLIENT_S_DN']))
55 55
 		{
56 56
 			# if we're not doing SSL authentication, behave like auth_sql
57 57
 			return Api\Auth::compare_password($passwd, $row['account_pwd'], 'md5', strtolower($username));
@@ -67,9 +67,9 @@  discard block
 block discarded – undo
67 67
 	 * @param int $account_id =0 account id of user whose passwd should be changed
68 68
 	 * @return boolean true if password successful changed, false otherwise
69 69
 	 */
70
-	function change_password($old_passwd, $new_passwd, $account_id=0)
70
+	function change_password($old_passwd, $new_passwd, $account_id = 0)
71 71
 	{
72
-		unset($old_passwd, $new_passwd, $account_id);	// not used but required by interface
72
+		unset($old_passwd, $new_passwd, $account_id); // not used but required by interface
73 73
 
74 74
 		// deny password changes.
75 75
 		return False;
Please login to merge, or discard this patch.
api/src/Auth/Pam.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -30,9 +30,9 @@  discard block
 block discarded – undo
30 30
 	 * @param string $passwd_type ='text' 'text' for cleartext passwords (default)
31 31
 	 * @return boolean true if successful authenticated, false otherwise
32 32
 	 */
33
-	function authenticate($username, $passwd, $passwd_type='text')
33
+	function authenticate($username, $passwd, $passwd_type = 'text')
34 34
 	{
35
-		unset($passwd_type);	// not used but required by interface
35
+		unset($passwd_type); // not used but required by interface
36 36
 
37 37
 		if (pam_auth($username, get_magic_quotes_gpc() ? stripslashes($passwd) : $passwd))
38 38
 		{
@@ -40,12 +40,12 @@  discard block
 block discarded – undo
40 40
 			if (!$GLOBALS['egw']->accounts->name2id($username) &&
41 41
 				function_exists('posix_getpwnam') && ($data = posix_getpwnam($username)))
42 42
 			{
43
-				list($fullname) = explode(',',$data['gecos']);
44
-				$parts = explode(' ',$fullname);
43
+				list($fullname) = explode(',', $data['gecos']);
44
+				$parts = explode(' ', $fullname);
45 45
 				if (count($parts) > 1)
46 46
 				{
47 47
 					$lastname = array_pop($parts);
48
-					$firstname = implode(' ',$parts);
48
+					$firstname = implode(' ', $parts);
49 49
 					$email = Api\Accounts::email($firstname, $lastname, $username);
50 50
 
51 51
 					$GLOBALS['auto_create_acct'] = array(
@@ -69,9 +69,9 @@  discard block
 block discarded – undo
69 69
 	 * @param int $account_id =0 account id of user whose passwd should be changed
70 70
 	 * @return boolean true if password successful changed, false otherwise
71 71
 	 */
72
-	function change_password($old_passwd, $new_passwd, $account_id=0)
72
+	function change_password($old_passwd, $new_passwd, $account_id = 0)
73 73
 	{
74
-		unset($old_passwd, $new_passwd, $account_id);	// not used but required by interface
74
+		unset($old_passwd, $new_passwd, $account_id); // not used but required by interface
75 75
 
76 76
 		// deny password changes.
77 77
 		return False;
Please login to merge, or discard this patch.
api/src/Auth/Mail.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -34,14 +34,14 @@  discard block
 block discarded – undo
34 34
 	 * @param string $passwd_type ='text' 'text' for cleartext passwords (default)
35 35
 	 * @return boolean true if successful authenticated, false otherwise
36 36
 	 */
37
-	function authenticate($username, $passwd, $passwd_type='text')
37
+	function authenticate($username, $passwd, $passwd_type = 'text')
38 38
 	{
39
-		unset($passwd_type);	// not used but required by function signature
39
+		unset($passwd_type); // not used but required by function signature
40 40
 
41 41
 		switch ($GLOBALS['egw_info']['server']['mail_login_type'])
42 42
 		{
43 43
 			case 'vmailmgr':
44
-				$username = $username . '@' . $GLOBALS['egw_info']['server']['mail_suffix'];
44
+				$username = $username.'@'.$GLOBALS['egw_info']['server']['mail_suffix'];
45 45
 				break;
46 46
 			case 'email':
47 47
 				$username = $GLOBALS['egw']->accounts->id2name($username, 'account_email');
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 				$mailauth = true;
69 69
 				$imap->logout();
70 70
 			}
71
-			catch(Horde_Imap_Client_Exception $e) {
71
+			catch (Horde_Imap_Client_Exception $e) {
72 72
 				// throw everything but authentication failed as exception
73 73
 				if ($e->getCode() != Horde_Imap_Client_Exception::LOGIN_AUTHENTICATIONFAILED) throw $e;
74 74
 
@@ -85,19 +85,19 @@  discard block
 block discarded – undo
85 85
 				case 'imap':
86 86
 				default:
87 87
 					if (!isset($port)) $port = 143;
88
-					$mailauth = imap_open('{'.$host.':'.$port.'/imap/novalidate-cert}INBOX', $username , $passwd);
88
+					$mailauth = imap_open('{'.$host.':'.$port.'/imap/novalidate-cert}INBOX', $username, $passwd);
89 89
 					break;
90 90
 				case 'imaps':
91 91
 					if (!isset($port)) $port = 993;
92
-					$mailauth = imap_open('{'.$host.'/imap/ssl/novalidate-cert:'.$port.'}INBOX', $username , $passwd);
92
+					$mailauth = imap_open('{'.$host.'/imap/ssl/novalidate-cert:'.$port.'}INBOX', $username, $passwd);
93 93
 					break;
94 94
 				case 'pop3':
95 95
 					if (!isset($port)) $port = 110;
96
-					$mailauth = imap_open('{'.$host.'/pop3/novalidate-cert:'.$port.'}INBOX', $username , $passwd);
96
+					$mailauth = imap_open('{'.$host.'/pop3/novalidate-cert:'.$port.'}INBOX', $username, $passwd);
97 97
 					break;
98 98
 				case 'pop3s':
99 99
 					if (!isset($port)) $port = 995;
100
-					$mailauth = imap_open('{'.$host.'/pop3/ssl/novalidate-cert:'.$port.'}INBOX', $username , $passwd);
100
+					$mailauth = imap_open('{'.$host.'/pop3/ssl/novalidate-cert:'.$port.'}INBOX', $username, $passwd);
101 101
 					break;
102 102
 			}
103 103
 			if ($mailauth) imap_close($mailauth);
@@ -113,9 +113,9 @@  discard block
 block discarded – undo
113 113
 	 * @param int $account_id =0 account id of user whose passwd should be changed
114 114
 	 * @return boolean true if password successful changed, false otherwise
115 115
 	 */
116
-	function change_password($old_passwd, $new_passwd, $account_id=0)
116
+	function change_password($old_passwd, $new_passwd, $account_id = 0)
117 117
 	{
118
-		unset($old_passwd, $new_passwd, $account_id);	// not used but required by function sigature
118
+		unset($old_passwd, $new_passwd, $account_id); // not used but required by function sigature
119 119
 
120 120
 		return False;
121 121
 	}
Please login to merge, or discard this patch.
Braces   +24 added lines, -6 removed lines patch added patch discarded remove patch
@@ -70,7 +70,10 @@  discard block
 block discarded – undo
70 70
 			}
71 71
 			catch(Horde_Imap_Client_Exception $e) {
72 72
 				// throw everything but authentication failed as exception
73
-				if ($e->getCode() != Horde_Imap_Client_Exception::LOGIN_AUTHENTICATIONFAILED) throw $e;
73
+				if ($e->getCode() != Horde_Imap_Client_Exception::LOGIN_AUTHENTICATIONFAILED)
74
+				{
75
+					throw $e;
76
+				}
74 77
 
75 78
 				$mailauth = false;
76 79
 			}
@@ -84,23 +87,38 @@  discard block
 block discarded – undo
84 87
 			{
85 88
 				case 'imap':
86 89
 				default:
87
-					if (!isset($port)) $port = 143;
90
+					if (!isset($port))
91
+					{
92
+						$port = 143;
93
+					}
88 94
 					$mailauth = imap_open('{'.$host.':'.$port.'/imap/novalidate-cert}INBOX', $username , $passwd);
89 95
 					break;
90 96
 				case 'imaps':
91
-					if (!isset($port)) $port = 993;
97
+					if (!isset($port))
98
+					{
99
+						$port = 993;
100
+					}
92 101
 					$mailauth = imap_open('{'.$host.'/imap/ssl/novalidate-cert:'.$port.'}INBOX', $username , $passwd);
93 102
 					break;
94 103
 				case 'pop3':
95
-					if (!isset($port)) $port = 110;
104
+					if (!isset($port))
105
+					{
106
+						$port = 110;
107
+					}
96 108
 					$mailauth = imap_open('{'.$host.'/pop3/novalidate-cert:'.$port.'}INBOX', $username , $passwd);
97 109
 					break;
98 110
 				case 'pop3s':
99
-					if (!isset($port)) $port = 995;
111
+					if (!isset($port))
112
+					{
113
+						$port = 995;
114
+					}
100 115
 					$mailauth = imap_open('{'.$host.'/pop3/ssl/novalidate-cert:'.$port.'}INBOX', $username , $passwd);
101 116
 					break;
102 117
 			}
103
-			if ($mailauth) imap_close($mailauth);
118
+			if ($mailauth)
119
+			{
120
+				imap_close($mailauth);
121
+			}
104 122
 		}
105 123
 		return !!$mailauth;
106 124
 	}
Please login to merge, or discard this patch.
api/src/Auth/Backend.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 	 * @param string $passwd_type ='text' 'text' for cleartext passwords (default)
26 26
 	 * @return boolean true if successful authenticated, false otherwise
27 27
 	 */
28
-	function authenticate($username, $passwd, $passwd_type='text');
28
+	function authenticate($username, $passwd, $passwd_type = 'text');
29 29
 
30 30
 	/**
31 31
 	 * changes password in sql datababse
@@ -36,5 +36,5 @@  discard block
 block discarded – undo
36 36
 	 * @throws Exception to give a verbose error, why changing password failed
37 37
 	 * @return boolean true if password successful changed, false otherwise
38 38
 	 */
39
-	function change_password($old_passwd, $new_passwd, $account_id=0);
39
+	function change_password($old_passwd, $new_passwd, $account_id = 0);
40 40
 }
Please login to merge, or discard this patch.
api/src/Auth/Cas.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -29,18 +29,18 @@  discard block
 block discarded – undo
29 29
 	 * @param string $passwd_type ='text' 'text' for cleartext passwords (default)
30 30
 	 * @return boolean true if successful authenticated, false otherwise
31 31
 	 */
32
-	function authenticate($username, $passwd, $passwd_type='text')
32
+	function authenticate($username, $passwd, $passwd_type = 'text')
33 33
 	{
34 34
 		/* if program goes here, authenticate is, normaly, already verified by CAS */
35 35
 		if ($GLOBALS['egw_info']['server']['account_repository'] != 'ldap' &&
36 36
 			$GLOBALS['egw_info']['server']['account_repository'] != 'ldsq') /* For anonymous LDAP connection */
37 37
 		{
38
-			if (!($id = $GLOBALS['egw']->accounts->name2id($username,'account_lid','u')) &&
38
+			if (!($id = $GLOBALS['egw']->accounts->name2id($username, 'account_lid', 'u')) &&
39 39
 				$GLOBALS['egw_info']['server']['auto_create_acct'])
40 40
 			{
41 41
 				// create a global array with all availible info about that account
42 42
 				$GLOBALS['auto_create_acct'] = array();
43
-				foreach(array(
43
+				foreach (array(
44 44
 					'givenname' => 'firstname',
45 45
 					'sn'        => 'lastname',
46 46
 					'uidnumber' => 'id',
@@ -48,11 +48,11 @@  discard block
 block discarded – undo
48 48
 					'gidnumber' => 'primary_group',
49 49
 					) as $ldap_name => $acct_name)
50 50
 				{
51
-					$GLOBALS['auto_create_acct'][$acct_name] = Api\Translation::convert($allValues[0][$ldap_name][0],'utf-8');
51
+					$GLOBALS['auto_create_acct'][$acct_name] = Api\Translation::convert($allValues[0][$ldap_name][0], 'utf-8');
52 52
 				}
53 53
 				return True;
54 54
 			}
55
-			return $id && $GLOBALS['egw']->accounts->id2name($id,'account_status') == 'A' && phpCAS::checkAuthentication();
55
+			return $id && $GLOBALS['egw']->accounts->id2name($id, 'account_status') == 'A' && phpCAS::checkAuthentication();
56 56
 		}
57 57
 		return phpCAS::checkAuthentication();
58 58
 	}
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 	 * @param int $account_id =0 account id of user whose passwd should be changed
66 66
 	 * @return boolean true if password successful changed, false otherwise
67 67
 	 */
68
-	function change_password($old_passwd, $new_passwd, $account_id=0)
68
+	function change_password($old_passwd, $new_passwd, $account_id = 0)
69 69
 	{
70 70
 		/* Not allowed */
71 71
 		return false;
Please login to merge, or discard this patch.
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,13 +33,16 @@
 block discarded – undo
33 33
 	{
34 34
 		/* if program goes here, authenticate is, normaly, already verified by CAS */
35 35
 		if ($GLOBALS['egw_info']['server']['account_repository'] != 'ldap' &&
36
-			$GLOBALS['egw_info']['server']['account_repository'] != 'ldsq') /* For anonymous LDAP connection */
36
+			$GLOBALS['egw_info']['server']['account_repository'] != 'ldsq')
37
+		{
38
+			/* For anonymous LDAP connection */
37 39
 		{
38 40
 			if (!($id = $GLOBALS['egw']->accounts->name2id($username,'account_lid','u')) &&
39 41
 				$GLOBALS['egw_info']['server']['auto_create_acct'])
40 42
 			{
41 43
 				// create a global array with all availible info about that account
42 44
 				$GLOBALS['auto_create_acct'] = array();
45
+		}
43 46
 				foreach(array(
44 47
 					'givenname' => 'firstname',
45 48
 					'sn'        => 'lastname',
Please login to merge, or discard this patch.
api/src/Csrf.php 2 patches
Spacing   +3 added lines, -4 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	 * @param mixed $_purpose =true if given it need to be used in validate too! (It must NOT be NULL)
33 33
 	 * @return string CSRF token
34 34
 	 */
35
-	public static function token($_purpose=true)
35
+	public static function token($_purpose = true)
36 36
 	{
37 37
 		if (is_null($_purpose))
38 38
 		{
@@ -40,8 +40,7 @@  discard block
 block discarded – undo
40 40
 		}
41 41
 		// generate random token (using oppenssl if available otherwise mt_rand based Auth::randomstring)
42 42
 		$token = function_exists('openssl_random_pseudo_bytes') ?
43
-			base64_encode(openssl_random_pseudo_bytes(64)) :
44
-			Auth::randomstring(64);
43
+			base64_encode(openssl_random_pseudo_bytes(64)) : Auth::randomstring(64);
45 44
 
46 45
 		// store it in session for later validation
47 46
 		Cache::setSession(__CLASS__, $token, $_purpose);
@@ -56,7 +55,7 @@  discard block
 block discarded – undo
56 55
 	 * @param string $_purpose =true optional purpose string passed to token method
57 56
 	 * @param boolean $_delete_token =true true if token should be deleted after validation, it will validate no second time
58 57
 	 */
59
-	public static function validate($_token, $_purpose=true, $_delete_token=true)
58
+	public static function validate($_token, $_purpose = true, $_delete_token = true)
60 59
 	{
61 60
 		$stored_purpose = Cache::getSession(__CLASS__, $_token);
62 61
 
Please login to merge, or discard this patch.
Braces   +8 added lines, -2 removed lines patch added patch discarded remove patch
@@ -64,10 +64,16 @@
 block discarded – undo
64 64
 		if (!isset($stored_purpose) || $stored_purpose !== $_purpose)
65 65
 		{
66 66
 			error_log('CSRF detected from IP '.$_SERVER['REMOTE_ADDR'].' to '.$_SERVER['REQUEST_METHOD'].' '.$_SERVER['REQUEST_URI']);
67
-			if ($_POST) error_log(array2string($_POST));
67
+			if ($_POST)
68
+			{
69
+				error_log(array2string($_POST));
70
+			}
68 71
 			// we are not throwing an exception here, but die, to not allow catching it!
69 72
 			die("CSRF detected, request terminated!");
70 73
 		}
71
-		if ($_delete_token) Cache::unsetSession(__CLASS__, $_token);
74
+		if ($_delete_token)
75
+		{
76
+			Cache::unsetSession(__CLASS__, $_token);
77
+		}
72 78
 	}
73 79
 }
74 80
\ No newline at end of file
Please login to merge, or discard this patch.
api/src/Mail/Imap.php 4 patches
Switch Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -580,16 +580,16 @@  discard block
 block discarded – undo
580 580
 		$mailbox = '';
581 581
 		if ( is_int( $restriction_search ) ){
582 582
 			switch ( $restriction_search ) {
583
-			case 0:
584
-				$searchstring = $reference."*";
585
-				break;
586
-			case 1:
587
-				$mailbox = $searchstring = $reference;
588
-				//$reference = '%';
589
-				break;
590
-			case 2:
591
-				$searchstring = $reference."%";
592
-				break;
583
+				case 0:
584
+					$searchstring = $reference."*";
585
+					break;
586
+				case 1:
587
+					$mailbox = $searchstring = $reference;
588
+					//$reference = '%';
589
+					break;
590
+				case 2:
591
+					$searchstring = $reference."%";
592
+					break;
593 593
 			}
594 594
 		}else{
595 595
 			if ( is_string( $restriction_search ) ){
@@ -664,16 +664,16 @@  discard block
 block discarded – undo
664 664
 		$mailbox = '';
665 665
 		if ( is_int( $restriction_search ) ){
666 666
 			switch ( $restriction_search ) {
667
-			case 0:
668
-				$searchstring = $reference."*";
669
-				break;
670
-			case 1:
671
-				$mailbox = $searchstring = $reference;
672
-				//$reference = '%';
673
-				break;
674
-			case 2:
675
-				$searchstring = $reference."%";
676
-				break;
667
+				case 0:
668
+					$searchstring = $reference."*";
669
+					break;
670
+				case 1:
671
+					$mailbox = $searchstring = $reference;
672
+					//$reference = '%';
673
+					break;
674
+				case 2:
675
+					$searchstring = $reference."%";
676
+					break;
677 677
 			}
678 678
 		}else{
679 679
 			if ( is_string( $restriction_search ) ){
@@ -730,16 +730,16 @@  discard block
 block discarded – undo
730 730
 
731 731
 		if ( is_int( $restriction_search ) ){
732 732
 			switch ( $restriction_search ) {
733
-			case 0:
734
-				$mailbox = $reference."*";
735
-				break;
736
-			case 1:
737
-				$mailbox = $reference;
738
-				$reference = '%';
739
-				break;
740
-			case 2:
741
-				$mailbox = "%";
742
-				break;
733
+				case 0:
734
+					$mailbox = $reference."*";
735
+					break;
736
+				case 1:
737
+					$mailbox = $reference;
738
+					$reference = '%';
739
+					break;
740
+				case 2:
741
+					$mailbox = "%";
742
+					break;
743 743
 			}
744 744
 		}else{
745 745
 			if ( is_string( $restriction_search ) ){
Please login to merge, or discard this patch.
Spacing   +138 added lines, -138 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 	static public $default_params = array(
67 67
 		//'debug' => '/tmp/imap.log', // uncomment to log communitcation with IMAP server
68 68
 		//'debug_literal' => true,    // uncomment to log mail contents returned by IMAP server
69
-		'cache' => true,              // default caching via Cache / Api\Cache
69
+		'cache' => true, // default caching via Cache / Api\Cache
70 70
 	);
71 71
 
72 72
 	/**
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 	 * @param int $_timeout =null timeout in secs, if none given fmail pref or default of 20 is used
145 145
 	 * @return void
146 146
 	 */
147
-	function __construct(array $params, $_adminConnection=false, $_timeout=null)
147
+	function __construct(array $params, $_adminConnection = false, $_timeout = null)
148 148
 	{
149 149
 		if (function_exists('mb_convert_encoding'))
150 150
 		{
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 		$this->loginType = $this->params['acc_imap_logintype'];
157 157
 		$this->domainName = $this->params['acc_domain'];
158 158
 
159
-		if (is_null($_timeout)) $_timeout = $this->params['acc_imap_timeout']?$this->params['acc_imap_timeout']:self::getTimeOut ();
159
+		if (is_null($_timeout)) $_timeout = $this->params['acc_imap_timeout'] ? $this->params['acc_imap_timeout'] : self::getTimeOut();
160 160
 
161 161
 		// Horde use locale for translation of error messages
162 162
 		// need to set LC_CTYPE for charachter classification (eg. Umlauts)
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
 			'port' => $this->params['acc_imap_port'],
178 178
 			'secure' => Account::ssl2secure($this->params['acc_imap_ssl']),
179 179
 			'timeout' => $_timeout,
180
-		)+self::$default_params;
180
+		) + self::$default_params;
181 181
 
182 182
 		if ($parent_params['cache'] === true)
183 183
 		{
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 				// as we have no way to tell this apart we ignore BINARY this affects
205 205
 				// Horde_Imap_Client_Fetch_Query::bodyPart for its fetch parameter decode=true is ignored
206 206
 				// (other functionality depending on BINARY is, of cause, affected too)
207
-				$parent_params['capability_ignore']= array_merge((array)$parent_params['capability_ignore'],array('BINARY'));
207
+				$parent_params['capability_ignore'] = array_merge((array)$parent_params['capability_ignore'], array('BINARY'));
208 208
 				break;
209 209
 		}
210 210
 		parent::__construct($parent_params);
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 	 *
218 218
 	 * @param string $_username =true create an admin connection for given user or $this->acc_imap_username
219 219
 	 */
220
-	function adminConnection($_username=true)
220
+	function adminConnection($_username = true)
221 221
 	{
222 222
 		if ($this->isAdminConnection !== $_username)
223 223
 		{
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 	 * @param string $_username =null create an admin connection for given user or $this->acc_imap_username
235 235
 	 * @throws Horde_IMAP_Client_Exception
236 236
 	 */
237
-	public function checkAdminConnection($_username=true)
237
+	public function checkAdminConnection($_username = true)
238 238
 	{
239 239
 		if ($this->acc_imap_administration)
240 240
 		{
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 	 *
249 249
 	 * @var array
250 250
 	 */
251
-	protected $run_on_login=array();
251
+	protected $run_on_login = array();
252 252
 
253 253
 	/**
254 254
 	 * Run given function on successful login
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 	 * @param callable $func
257 257
 	 * @param array $params =array()
258 258
 	 */
259
-	public function runOnLogin($func, array $params=array())
259
+	public function runOnLogin($func, array $params = array())
260 260
 	{
261 261
 		$this->run_on_login[] = array($func, $params);
262 262
 	}
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 	{
271 271
 		parent::login();
272 272
 
273
-		foreach($this->run_on_login as $key => $data)
273
+		foreach ($this->run_on_login as $key => $data)
274 274
 		{
275 275
 			call_user_func_array($data[0], $data[1]);
276 276
 
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 	 */
287 287
 	public function __get($name)
288 288
 	{
289
-		switch($name)
289
+		switch ($name)
290 290
 		{
291 291
 			case 'acc_imap_administration':
292 292
 				return !empty($this->params['acc_imap_admin_username']);
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
 				{
305 305
 					return $this->$name;
306 306
 				}
307
-				if (array_key_exists($name,$this->params))
307
+				if (array_key_exists($name, $this->params))
308 308
 				{
309 309
 					return $this->params[$name];
310 310
 				}
@@ -325,9 +325,9 @@  discard block
 block discarded – undo
325 325
 	 * @deprecated allready called by constructor automatic, parameters must be passed to constructor!
326 326
 	 * @throws Api\Exception\WrongParameter
327 327
 	 */
328
-	function openConnection($_adminConnection=false, $_timeout=null)
328
+	function openConnection($_adminConnection = false, $_timeout = null)
329 329
 	{
330
-		unset($_timeout);	// not used
330
+		unset($_timeout); // not used
331 331
 		if ($_adminConnection !== $this->params['adminConnection'])
332 332
 		{
333 333
 			throw new Api\Exception\WrongParameter('need to set parameters on calling Account->imapServer()!');
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
 	 * @param string _use decide if the use is for IMAP or SIEVE, by now only the default differs
341 341
 	 * @return int - timeout (either set or default 20/10)
342 342
 	 */
343
-	static function getTimeOut($_use='IMAP')
343
+	static function getTimeOut($_use = 'IMAP')
344 344
 	{
345 345
 		$timeout = $GLOBALS['egw_info']['user']['preferences']['mail']['connectionTimeout'];
346 346
 		if (empty($timeout) || !($timeout > 0)) $timeout = $_use == 'SIEVE' ? 10 : 20; // this is the default value
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
 	 */
366 366
 	function addAccount($_hookValues)
367 367
 	{
368
-		unset($_hookValues);	// not used
368
+		unset($_hookValues); // not used
369 369
 		return true;
370 370
 	}
371 371
 
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
 	 */
378 378
 	function updateAccount($_hookValues)
379 379
 	{
380
-		unset($_hookValues);	// not used
380
+		unset($_hookValues); // not used
381 381
 		return true;
382 382
 	}
383 383
 
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
 	 */
390 390
 	function deleteAccount($_hookValues)
391 391
 	{
392
-		unset($_hookValues);	// not used
392
+		unset($_hookValues); // not used
393 393
 		return true;
394 394
 	}
395 395
 
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
 	 */
407 407
 	function encodeFolderName($_folderName)
408 408
 	{
409
-		if($this->mbAvailable) {
409
+		if ($this->mbAvailable) {
410 410
 			return mb_convert_encoding($_folderName, "UTF7-IMAP", Api\Translation::charset());
411 411
 		}
412 412
 
@@ -423,17 +423,17 @@  discard block
 block discarded – undo
423 423
 	 */
424 424
 	function getMailbox($mailbox)
425 425
 	{
426
-		$mailboxes = $this->listMailboxes($mailbox,Horde_Imap_Client::MBOX_ALL);
427
-		if (empty($mailboxes)) $mailboxes = $this->listMailboxes($mailbox,Horde_Imap_Client::MBOX_UNSUBSCRIBED);
426
+		$mailboxes = $this->listMailboxes($mailbox, Horde_Imap_Client::MBOX_ALL);
427
+		if (empty($mailboxes)) $mailboxes = $this->listMailboxes($mailbox, Horde_Imap_Client::MBOX_UNSUBSCRIBED);
428 428
 		//error_log(__METHOD__.__LINE__.'->'.$mailbox.'/'.array2string($mailboxes));
429 429
 		$mboxes = new Horde_Imap_Client_Mailbox_List($mailboxes);
430 430
 		//_debug_array($mboxes->count());
431 431
 		foreach ($mboxes->getIterator() as $k =>$box)
432 432
 		{
433 433
 			//error_log(__METHOD__.__LINE__.'->'.$k);
434
-			if ($k!='user' && $k != '' && $k==$mailbox) return $box['mailbox']; //_debug_array(array($k => $client->status($k)));
434
+			if ($k != 'user' && $k != '' && $k == $mailbox) return $box['mailbox']; //_debug_array(array($k => $client->status($k)));
435 435
 		}
436
-		return ($this->mailboxExist($mailbox)?$mailbox:false);
436
+		return ($this->mailboxExist($mailbox) ? $mailbox : false);
437 437
 	}
438 438
 
439 439
 	/**
@@ -449,23 +449,23 @@  discard block
 block discarded – undo
449 449
 			//error_log(__METHOD__.__LINE__.':'.$mailbox);
450 450
 			$currentMailbox = $this->currentMailbox();
451 451
 		}
452
-		catch(\Exception $e)
452
+		catch (\Exception $e)
453 453
 		{
454 454
 			//error_log(__METHOD__.__LINE__.' failed detecting currentMailbox:'.$currentMailbox.':'.$e->getMessage());
455
-			$currentMailbox=null;
455
+			$currentMailbox = null;
456 456
 			unset($e);
457 457
 		}
458 458
 		try
459 459
 		{
460 460
 			//error_log(__METHOD__.__LINE__.':'.$mailbox);
461 461
 			$this->openMailbox($mailbox);
462
-			$returnvalue=true;
462
+			$returnvalue = true;
463 463
 		}
464
-		catch(\Exception $e)
464
+		catch (\Exception $e)
465 465
 		{
466 466
 			//error_log(__METHOD__.__LINE__.' failed opening:'.$mailbox.':'.$e->getMessage().' Called by:'.function_backtrace());
467 467
 			unset($e);
468
-			$returnvalue=false;
468
+			$returnvalue = false;
469 469
 		}
470 470
 		if (!empty($currentMailbox) && $currentMailbox['mailbox'] != $mailbox)
471 471
 		{
@@ -474,7 +474,7 @@  discard block
 block discarded – undo
474 474
 				//error_log(__METHOD__.__LINE__.':'.$currentMailbox .'<->'.$mailbox);
475 475
 				$this->openMailbox($currentMailbox['mailbox']);
476 476
 			}
477
-			catch(\Exception $e)
477
+			catch (\Exception $e)
478 478
 			{
479 479
 				//error_log(__METHOD__.__LINE__.' failed reopening:'.$currentMailbox.':'.$e->getMessage());
480 480
 				unset($e);
@@ -494,7 +494,7 @@  discard block
 block discarded – undo
494 494
 		{
495 495
 			$mailbox = $this->currentMailbox();
496 496
 		}
497
-		catch(\Exception $e)
497
+		catch (\Exception $e)
498 498
 		{
499 499
 			error_log(__METHOD__.' ('.__LINE__.') failed fetching currentMailbox:'.$e->getMessage());
500 500
 			//throw new egw_exception(__METHOD__.' ('.__LINE__.") failed to ".__METHOD__." :".$e->getMessage());
@@ -512,16 +512,16 @@  discard block
 block discarded – undo
512 512
 	 */
513 513
 	function getSpecialUseFolders()
514 514
 	{
515
-		$mailboxes = $this->getMailboxes('',0,true);
515
+		$mailboxes = $this->getMailboxes('', 0, true);
516 516
 		$suF = array();
517 517
 		foreach ($mailboxes as $box)
518 518
 		{
519
-			if ($box['MAILBOX']!='user' && $box['MAILBOX'] != '')
519
+			if ($box['MAILBOX'] != 'user' && $box['MAILBOX'] != '')
520 520
 			{
521 521
 				//error_log(__METHOD__.__LINE__.$k.'->'.array2string($box));
522
-				if (isset($box['ATTRIBUTES'])&&!empty($box['ATTRIBUTES'])&&
523
-					stripos(strtolower(array2string($box['ATTRIBUTES'])),'\noselect')=== false&&
524
-					stripos(strtolower(array2string($box['ATTRIBUTES'])),'\nonexistent')=== false)
522
+				if (isset($box['ATTRIBUTES']) && !empty($box['ATTRIBUTES']) &&
523
+					stripos(strtolower(array2string($box['ATTRIBUTES'])), '\noselect') === false &&
524
+					stripos(strtolower(array2string($box['ATTRIBUTES'])), '\nonexistent') === false)
525 525
 				{
526 526
 					$suF[$box['MAILBOX']] = $box;
527 527
 				}
@@ -543,7 +543,7 @@  discard block
 block discarded – undo
543 543
 			$status = $this->status($mailbox);
544 544
 			foreach ($status as $key => $v)
545 545
 			{
546
-				$_status[strtoupper($key)]=$v;
546
+				$_status[strtoupper($key)] = $v;
547 547
 			}
548 548
 			return $_status;
549 549
 		}
@@ -561,9 +561,9 @@  discard block
 block discarded – undo
561 561
 	 * @param ignoreStatusCache bool ignore the cache used for counters
562 562
 	 * @return array with counters
563 563
 	 */
564
-	function getStatus($mailbox, $ignoreStatusCache=false)
564
+	function getStatus($mailbox, $ignoreStatusCache = false)
565 565
 	{
566
-		$mailboxes = $this->listMailboxes($mailbox,Horde_Imap_Client::MBOX_ALL,array(
566
+		$mailboxes = $this->listMailboxes($mailbox, Horde_Imap_Client::MBOX_ALL, array(
567 567
 				'attributes'=>true,
568 568
 				'children'=>true, //child info
569 569
 				'delimiter'=>true,
@@ -577,16 +577,16 @@  discard block
 block discarded – undo
577 577
 		//error_log(__METHOD__.__LINE__.array2string($mboxes->count()));
578 578
 		foreach ($mboxes->getIterator() as $k =>$box)
579 579
 		{
580
-			if ($k!='user' && $k != '' && $k==$mailbox)
580
+			if ($k != 'user' && $k != '' && $k == $mailbox)
581 581
 			{
582
-				if (stripos(array2string($box['attributes']),'\noselect')=== false)
582
+				if (stripos(array2string($box['attributes']), '\noselect') === false)
583 583
 				{
584 584
 					$status = $this->status($k, $flags);
585 585
 					foreach ($status as $key => $v)
586 586
 					{
587
-						$_status[strtoupper($key)]=$v;
587
+						$_status[strtoupper($key)] = $v;
588 588
 					}
589
-					$_status['HIERACHY_DELIMITER'] = $_status['delimiter'] = ($box['delimiter']?$box['delimiter']:$this->getDelimiter('personal'));
589
+					$_status['HIERACHY_DELIMITER'] = $_status['delimiter'] = ($box['delimiter'] ? $box['delimiter'] : $this->getDelimiter('personal'));
590 590
 					$_status['ATTRIBUTES'] = $box['attributes'];
591 591
 					//error_log(__METHOD__.__LINE__.$k.'->'.array2string($_status));
592 592
 					return $_status;
@@ -612,14 +612,14 @@  discard block
 block discarded – undo
612 612
 	 *
613 613
 	 * @return  mixed   array of mailboxes
614 614
 	 */
615
-	function getMailboxes($reference = ''  , $restriction_search = 0, $returnAttributes = false)
615
+	function getMailboxes($reference = '', $restriction_search = 0, $returnAttributes = false)
616 616
 	{
617
-		if ( is_bool($restriction_search) ){
618
-			$restriction_search = (int) $restriction_search;
617
+		if (is_bool($restriction_search)) {
618
+			$restriction_search = (int)$restriction_search;
619 619
 		}
620 620
 		$mailbox = '';
621
-		if ( is_int( $restriction_search ) ){
622
-			switch ( $restriction_search ) {
621
+		if (is_int($restriction_search)) {
622
+			switch ($restriction_search) {
623 623
 			case 0:
624 624
 				$searchstring = $reference."*";
625 625
 				break;
@@ -631,8 +631,8 @@  discard block
 block discarded – undo
631 631
 				$searchstring = $reference."%";
632 632
 				break;
633 633
 			}
634
-		}else{
635
-			if ( is_string( $restriction_search ) ){
634
+		} else {
635
+			if (is_string($restriction_search)) {
636 636
 				$mailbox = $searchstring = $restriction_search;
637 637
 			}
638 638
 		}
@@ -645,35 +645,35 @@  discard block
 block discarded – undo
645 645
 				'special_use'=>true,
646 646
 				'sort'=>true,
647 647
 			);
648
-		if ($returnAttributes==false)
648
+		if ($returnAttributes == false)
649 649
 		{
650 650
 			unset($options['attributes']);
651 651
 			unset($options['children']);
652 652
 			unset($options['special_use']);
653 653
 		}
654
-		$mailboxes = $this->listMailboxes($searchstring,Horde_Imap_Client::MBOX_ALL, $options);
654
+		$mailboxes = $this->listMailboxes($searchstring, Horde_Imap_Client::MBOX_ALL, $options);
655 655
 		//$mboxes = new Horde_Imap_Client_Mailbox_List($mailboxes);
656 656
 		//_debug_array($mboxes->count());
657 657
 		foreach ((array)$mailboxes as $k =>$box)
658 658
 		{
659 659
 			//error_log(__METHOD__.__LINE__.' Box:'.$k.'->'.array2string($box));
660
-			$ret[$k]=array('MAILBOX'=>$k,'ATTRIBUTES'=>$box['attributes'],'delimiter'=>($box['delimiter']?$box['delimiter']:$this->getDelimiter('personal')),'SUBSCRIBED'=>true);
660
+			$ret[$k] = array('MAILBOX'=>$k, 'ATTRIBUTES'=>$box['attributes'], 'delimiter'=>($box['delimiter'] ? $box['delimiter'] : $this->getDelimiter('personal')), 'SUBSCRIBED'=>true);
661 661
 		}
662 662
 		// for unknown reasons on ALL, UNSUBSCRIBED are not returned
663 663
 		//always fetch unsubscribed, think about only fetching it when $options['attributes'] is set
664 664
 		//but then allMailboxes are not all, ....
665 665
 		//if (!empty($mailbox) && !isset($ret[$mailbox]))
666 666
 		{
667
-			$unsub_mailboxes = $this->listMailboxes($searchstring,Horde_Imap_Client::MBOX_UNSUBSCRIBED, $options);
667
+			$unsub_mailboxes = $this->listMailboxes($searchstring, Horde_Imap_Client::MBOX_UNSUBSCRIBED, $options);
668 668
 			//$mboxes = new Horde_Imap_Client_Mailbox_List($mailboxes);
669 669
 			//_debug_array($mboxes->count());
670 670
 			//error_log(__METHOD__.__LINE__.' '.$mailbox.':'.count((array)$mailboxes).'->'.function_backtrace());
671 671
 			foreach ((array)$unsub_mailboxes as $k =>$box)
672 672
 			{
673 673
 				//error_log(__METHOD__.__LINE__.' Box:'.$k.' already In?'.array_key_exists($k,$boxexists).'->'.array2string($box));
674
-				if(!array_key_exists($k,$ret))
674
+				if (!array_key_exists($k, $ret))
675 675
 				{
676
-					$ret[$k]=array('MAILBOX'=>$k,'ATTRIBUTES'=>$box['attributes'],'delimiter'=>($box['delimiter']?$box['delimiter']:$this->getDelimiter('personal')),'SUBSCRIBED'=>false);
676
+					$ret[$k] = array('MAILBOX'=>$k, 'ATTRIBUTES'=>$box['attributes'], 'delimiter'=>($box['delimiter'] ? $box['delimiter'] : $this->getDelimiter('personal')), 'SUBSCRIBED'=>false);
677 677
 				}
678 678
 				else
679 679
 				{
@@ -696,14 +696,14 @@  discard block
 block discarded – undo
696 696
 	 *
697 697
 	 * @return  mixed   array of mailboxes
698 698
 	 */
699
-	function listSubscribedMailboxes($reference = ''  , $restriction_search = 0, $returnAttributes = false)
699
+	function listSubscribedMailboxes($reference = '', $restriction_search = 0, $returnAttributes = false)
700 700
 	{
701
-		if ( is_bool($restriction_search) ){
702
-			$restriction_search = (int) $restriction_search;
701
+		if (is_bool($restriction_search)) {
702
+			$restriction_search = (int)$restriction_search;
703 703
 		}
704 704
 		$mailbox = '';
705
-		if ( is_int( $restriction_search ) ){
706
-			switch ( $restriction_search ) {
705
+		if (is_int($restriction_search)) {
706
+			switch ($restriction_search) {
707 707
 			case 0:
708 708
 				$searchstring = $reference."*";
709 709
 				break;
@@ -715,8 +715,8 @@  discard block
 block discarded – undo
715 715
 				$searchstring = $reference."%";
716 716
 				break;
717 717
 			}
718
-		}else{
719
-			if ( is_string( $restriction_search ) ){
718
+		} else {
719
+			if (is_string($restriction_search)) {
720 720
 				$mailbox = $searchstring = $restriction_search;
721 721
 			}
722 722
 		}
@@ -728,25 +728,25 @@  discard block
 block discarded – undo
728 728
 				'special_use'=>true,
729 729
 				'sort'=>true,
730 730
 			);
731
-		if ($returnAttributes==false)
731
+		if ($returnAttributes == false)
732 732
 		{
733 733
 			unset($options['attributes']);
734 734
 			unset($options['children']);
735 735
 			unset($options['special_use']);
736 736
 		}
737
-		$mailboxes = $this->listMailboxes($searchstring,Horde_Imap_Client::MBOX_SUBSCRIBED_EXISTS, $options);
737
+		$mailboxes = $this->listMailboxes($searchstring, Horde_Imap_Client::MBOX_SUBSCRIBED_EXISTS, $options);
738 738
 		//$mboxes = new Horde_Imap_Client_Mailbox_List($mailboxes);
739 739
 		//_debug_array($mboxes->count());
740 740
 		foreach ((array)$mailboxes as $k =>$box)
741 741
 		{
742 742
 			//error_log(__METHOD__.__LINE__.' Searched for:'.$mailbox.' got Box:'.$k.'->'.array2string($box).function_backtrace());
743
-			if ($returnAttributes==false)
743
+			if ($returnAttributes == false)
744 744
 			{
745
-				$ret[]=$k;
745
+				$ret[] = $k;
746 746
 			}
747 747
 			else
748 748
 			{
749
-				$ret[$k]=array('MAILBOX'=>$k,'ATTRIBUTES'=>$box['attributes'],'delimiter'=>($box['delimiter']?$box['delimiter']:$this->getDelimiter('personal')),'SUBSCRIBED'=>true);
749
+				$ret[$k] = array('MAILBOX'=>$k, 'ATTRIBUTES'=>$box['attributes'], 'delimiter'=>($box['delimiter'] ? $box['delimiter'] : $this->getDelimiter('personal')), 'SUBSCRIBED'=>true);
750 750
 			}
751 751
 		}
752 752
 		return $ret;
@@ -762,14 +762,14 @@  discard block
 block discarded – undo
762 762
 	 *
763 763
 	 * @return  mixed   array of mailboxes
764 764
 	 */
765
-	function listUnSubscribedMailboxes($reference = ''  , $restriction_search = 0)
765
+	function listUnSubscribedMailboxes($reference = '', $restriction_search = 0)
766 766
 	{
767
-		if ( is_bool($restriction_search) ){
768
-			$restriction_search = (int) $restriction_search;
767
+		if (is_bool($restriction_search)) {
768
+			$restriction_search = (int)$restriction_search;
769 769
 		}
770 770
 
771
-		if ( is_int( $restriction_search ) ){
772
-			switch ( $restriction_search ) {
771
+		if (is_int($restriction_search)) {
772
+			switch ($restriction_search) {
773 773
 			case 0:
774 774
 				$mailbox = $reference."*";
775 775
 				break;
@@ -781,8 +781,8 @@  discard block
 block discarded – undo
781 781
 				$mailbox = "%";
782 782
 				break;
783 783
 			}
784
-		}else{
785
-			if ( is_string( $restriction_search ) ){
784
+		} else {
785
+			if (is_string($restriction_search)) {
786 786
 				$mailbox = $restriction_search;
787 787
 			}
788 788
 		}
@@ -791,17 +791,17 @@  discard block
 block discarded – undo
791 791
 			'sort'=>true,
792 792
 			//'flat'=>true,
793 793
 		);
794
-		$mailboxes = $this->listMailboxes($mailbox,Horde_Imap_Client::MBOX_SUBSCRIBED_EXISTS, $options);
794
+		$mailboxes = $this->listMailboxes($mailbox, Horde_Imap_Client::MBOX_SUBSCRIBED_EXISTS, $options);
795 795
 		foreach ($mailboxes as $box)
796 796
 		{
797 797
 			//error_log(__METHOD__.__LINE__.' Box:'.$k.'->'.array2string($box['mailbox']->utf8));
798
-			$sret[]=$box['mailbox']->utf8;
798
+			$sret[] = $box['mailbox']->utf8;
799 799
 		}
800
-		$unsubscribed = $this->listMailboxes($mailbox,Horde_Imap_Client::MBOX_UNSUBSCRIBED, $options);
800
+		$unsubscribed = $this->listMailboxes($mailbox, Horde_Imap_Client::MBOX_UNSUBSCRIBED, $options);
801 801
 		foreach ($unsubscribed as $box)
802 802
 		{
803 803
 			//error_log(__METHOD__.__LINE__.' Box:'.$k.'->'.array2string($box['mailbox']->utf8));
804
-			if (!in_array($box['mailbox']->utf8,$sret) && $box['mailbox']->utf8!='INBOX') $ret[]=$box['mailbox']->utf8;
804
+			if (!in_array($box['mailbox']->utf8, $sret) && $box['mailbox']->utf8 != 'INBOX') $ret[] = $box['mailbox']->utf8;
805 805
 		}
806 806
 		return $ret;
807 807
 	}
@@ -813,12 +813,12 @@  discard block
 block discarded – undo
813 813
 	 * @param int $flags =null default Horde_Imap_Client::STATUS_ALL | Horde_Imap_Client::STATUS_FLAGS | Horde_Imap_Client::STATUS_PERMFLAGS
814 814
 	 * @return array of counters for mailbox
815 815
 	 */
816
-	function examineMailbox($mailbox, $flags=null)
816
+	function examineMailbox($mailbox, $flags = null)
817 817
 	{
818
-		if ($mailbox=='') return false;
818
+		if ($mailbox == '') return false;
819 819
 		$mailboxes = $this->listMailboxes($mailbox);
820 820
 
821
-		if (is_null($flags)) $flags = Horde_Imap_Client::STATUS_ALL | Horde_Imap_Client::STATUS_FLAGS | Horde_Imap_Client::STATUS_PERMFLAGS;
821
+		if (is_null($flags)) $flags = Horde_Imap_Client::STATUS_ALL|Horde_Imap_Client::STATUS_FLAGS|Horde_Imap_Client::STATUS_PERMFLAGS;
822 822
 
823 823
 		$mboxes = new Horde_Imap_Client_Mailbox_List($mailboxes);
824 824
 		//_debug_array($mboxes->count());
@@ -826,18 +826,18 @@  discard block
 block discarded – undo
826 826
 		{
827 827
 			//error_log(__METHOD__.__LINE__.array2string($box));
828 828
 			unset($box);
829
-			if ($k!='user' && $k != '' && $k==$mailbox)
829
+			if ($k != 'user' && $k != '' && $k == $mailbox)
830 830
 			{
831 831
 				$status = $this->status($k, $flags);
832 832
 				//error_log(__METHOD__.__LINE__.array2string($status));
833 833
 				foreach ($status as $key => $v)
834 834
 				{
835
-					$_status[strtoupper($key)]=$v;
835
+					$_status[strtoupper($key)] = $v;
836 836
 				}
837
-				if ($flags & (Horde_Imap_Client::STATUS_FLAGS|Horde_Imap_Client::STATUS_PERMFLAGS))
837
+				if ($flags&(Horde_Imap_Client::STATUS_FLAGS|Horde_Imap_Client::STATUS_PERMFLAGS))
838 838
 				{
839 839
 					self::$supports_keywords[$this->ImapServerId] = stripos(implode('', $status['flags']), '$label') !== false ||
840
-						in_array('\\*', $status['permflags']);	// arbitrary keyswords also allow keywords
840
+						in_array('\\*', $status['permflags']); // arbitrary keyswords also allow keywords
841 841
 				}
842 842
 				return $_status;
843 843
 			}
@@ -876,7 +876,7 @@  discard block
 block discarded – undo
876 876
 	 */
877 877
 	function hasCapability($capability)
878 878
 	{
879
-		if ($capability=='SUPPORTS_KEYWORDS')
879
+		if ($capability == 'SUPPORTS_KEYWORDS')
880 880
 		{
881 881
 			// if pseudo-flag is not set, call examineMailbox now to set it (no STATUS_ALL = counters necessary)
882 882
 			if (!isset(self::$supports_keywords[$this->ImapServerId]))
@@ -888,7 +888,7 @@  discard block
 block discarded – undo
888 888
 				catch (\Exception $e)
889 889
 				{
890 890
 					error_log(__METHOD__.__LINE__.' (examineServer for detection) '.$capability.'->'.array2string(self::$supports_keywords).' failed '.function_backtrace());
891
-					self::$supports_keywords[$this->ImapServerId]=false;
891
+					self::$supports_keywords[$this->ImapServerId] = false;
892 892
 				}
893 893
 			}
894 894
 			//error_log(__METHOD__.__LINE__.' '.$capability.'->'.array2string(self::$supports_keywords).' '.function_backtrace());
@@ -938,9 +938,9 @@  discard block
 block discarded – undo
938 938
 	 */
939 939
 	static function getFolderPrefixFromNamespace($_nameSpace, $_folderName)
940 940
 	{
941
-		foreach($_nameSpace as &$singleNameSpace)
941
+		foreach ($_nameSpace as &$singleNameSpace)
942 942
 		{
943
-			if (substr($_folderName,0,strlen($singleNameSpace['prefix'])) == $singleNameSpace['prefix']) return $singleNameSpace['prefix'];
943
+			if (substr($_folderName, 0, strlen($singleNameSpace['prefix'])) == $singleNameSpace['prefix']) return $singleNameSpace['prefix'];
944 944
 		}
945 945
 		return "";
946 946
 	}
@@ -955,33 +955,33 @@  discard block
 block discarded – undo
955 955
 	 * @param string $reclevel = 0, counter to keep track of the current recursionlevel
956 956
 	 * @return array of mailboxes
957 957
 	 */
958
-	function getMailBoxesRecursive($_mailbox, $delimiter, $prefix, $reclevel=0)
958
+	function getMailBoxesRecursive($_mailbox, $delimiter, $prefix, $reclevel = 0)
959 959
 	{
960 960
 		if ($reclevel > 25) {
961
-			error_log( __METHOD__." Recursion Level Exeeded ($reclevel) while looking up $_mailbox$delimiter ");
961
+			error_log(__METHOD__." Recursion Level Exeeded ($reclevel) while looking up $_mailbox$delimiter ");
962 962
 			return array();
963 963
 		}
964 964
 		$reclevel++;
965 965
 		// clean up double delimiters
966
-		$mailbox = preg_replace('~'.($delimiter == '.' ? "\\".$delimiter:$delimiter).'+~s',$delimiter,$_mailbox);
966
+		$mailbox = preg_replace('~'.($delimiter == '.' ? "\\".$delimiter : $delimiter).'+~s', $delimiter, $_mailbox);
967 967
 		//get that mailbox in question
968
-		$mbx = $this->getMailboxes($mailbox,1,true);
968
+		$mbx = $this->getMailboxes($mailbox, 1, true);
969 969
 		$mbxkeys = array_keys($mbx);
970 970
 
971 971
 		// Example: Array([INBOX/GaGa] => Array([MAILBOX] => INBOX/GaGa[ATTRIBUTES] => Array([0] => \\unmarked)[delimiter] => /))
972
-		if (is_array($mbx[$mbxkeys[0]]["ATTRIBUTES"]) && (in_array('\HasChildren',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\Haschildren',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\haschildren',$mbx[$mbxkeys[0]]["ATTRIBUTES"])))
972
+		if (is_array($mbx[$mbxkeys[0]]["ATTRIBUTES"]) && (in_array('\HasChildren', $mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\Haschildren', $mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\haschildren', $mbx[$mbxkeys[0]]["ATTRIBUTES"])))
973 973
 		{
974
-			$buff = $this->getMailboxes($mbx[$mbxkeys[0]]['MAILBOX'].($mbx[$mbxkeys[0]]['MAILBOX'] == $prefix ? '':$delimiter),2,false);
974
+			$buff = $this->getMailboxes($mbx[$mbxkeys[0]]['MAILBOX'].($mbx[$mbxkeys[0]]['MAILBOX'] == $prefix ? '' : $delimiter), 2, false);
975 975
 			$allMailboxes = array();
976 976
 			foreach ($buff as $mbxname) {
977
-				$mbxname = preg_replace('~'.($delimiter == '.' ? "\\".$delimiter:$delimiter).'+~s',$delimiter,$mbxname['MAILBOX']);
977
+				$mbxname = preg_replace('~'.($delimiter == '.' ? "\\".$delimiter : $delimiter).'+~s', $delimiter, $mbxname['MAILBOX']);
978 978
 				#echo "About to recur in level $reclevel:".$mbxname."<br>";
979
-				if ( $mbxname != $mbx[$mbxkeys[0]]['MAILBOX'] && $mbxname != $prefix  && $mbxname != $mbx[$mbxkeys[0]]['MAILBOX'].$delimiter)
979
+				if ($mbxname != $mbx[$mbxkeys[0]]['MAILBOX'] && $mbxname != $prefix && $mbxname != $mbx[$mbxkeys[0]]['MAILBOX'].$delimiter)
980 980
 				{
981 981
 					$allMailboxes = array_merge($allMailboxes, self::getMailBoxesRecursive($mbxname, $delimiter, $prefix, $reclevel));
982 982
 				}
983 983
 			}
984
-			if (!(in_array('\NoSelect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\Noselect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\noselect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]))) $allMailboxes[] = $mbx[$mbxkeys[0]]['MAILBOX'];
984
+			if (!(in_array('\NoSelect', $mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\Noselect', $mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\noselect', $mbx[$mbxkeys[0]]["ATTRIBUTES"]))) $allMailboxes[] = $mbx[$mbxkeys[0]]['MAILBOX'];
985 985
 			return $allMailboxes;
986 986
 		}
987 987
 		else
@@ -1000,24 +1000,24 @@  discard block
 block discarded – undo
1000 1000
 	 */
1001 1001
 	function getNameSpace()
1002 1002
 	{
1003
-		static $nameSpace=null;
1003
+		static $nameSpace = null;
1004 1004
 		$foldersNameSpace = array();
1005 1005
 		$delimiter = $this->getDelimiter();
1006
-		if (empty($delimiter)) $delimiter='/';
1006
+		if (empty($delimiter)) $delimiter = '/';
1007 1007
 		if (is_null($nameSpace)) $nameSpace = $this->getNameSpaceArray();
1008 1008
 		if (is_array($nameSpace)) {
1009
-			foreach($nameSpace as $type => $singleNameSpaceArray)
1009
+			foreach ($nameSpace as $type => $singleNameSpaceArray)
1010 1010
 			{
1011 1011
 				foreach ($singleNameSpaceArray as $singleNameSpace)
1012 1012
 				{
1013 1013
 					$_foldersNameSpace = array();
1014
-					if($type == 'personal' && $singleNameSpace['name'] == '#mh/' && ($this->folderExists('Mail')||$this->folderExists('INBOX')))
1014
+					if ($type == 'personal' && $singleNameSpace['name'] == '#mh/' && ($this->folderExists('Mail') || $this->folderExists('INBOX')))
1015 1015
 					{
1016 1016
 						$_foldersNameSpace['prefix_present'] = 'forced';
1017 1017
 						// uw-imap server with mailbox prefix or dovecot maybe
1018
-						$_foldersNameSpace['prefix'] = ($this->folderExists('Mail')?'Mail':(!empty($singleNameSpace['name'])?$singleNameSpace['name']:''));
1018
+						$_foldersNameSpace['prefix'] = ($this->folderExists('Mail') ? 'Mail' : (!empty($singleNameSpace['name']) ? $singleNameSpace['name'] : ''));
1019 1019
 					}
1020
-					elseif($type == 'personal' && ($singleNameSpace['name'] == '#mh/') && $this->folderExists('mail'))
1020
+					elseif ($type == 'personal' && ($singleNameSpace['name'] == '#mh/') && $this->folderExists('mail'))
1021 1021
 					{
1022 1022
 						$_foldersNameSpace['prefix_present'] = 'forced';
1023 1023
 						// uw-imap server with mailbox prefix or dovecot maybe
@@ -1026,9 +1026,9 @@  discard block
 block discarded – undo
1026 1026
 						$_foldersNameSpace['prefix_present'] = !empty($singleNameSpace['name']);
1027 1027
 						$_foldersNameSpace['prefix'] = $singleNameSpace['name'];
1028 1028
 					}
1029
-					$_foldersNameSpace['delimiter'] = ($singleNameSpace['delimiter']?$singleNameSpace['delimiter']:$delimiter);
1029
+					$_foldersNameSpace['delimiter'] = ($singleNameSpace['delimiter'] ? $singleNameSpace['delimiter'] : $delimiter);
1030 1030
 					$_foldersNameSpace['type'] = $type;
1031
-					$foldersNameSpace[] =$_foldersNameSpace;
1031
+					$foldersNameSpace[] = $_foldersNameSpace;
1032 1032
 				}
1033 1033
 			}
1034 1034
 		}
@@ -1040,29 +1040,29 @@  discard block
 block discarded – undo
1040 1040
 	 * @param mixed _type (1=personal, 2=user/other, 3=shared)
1041 1041
 	 * @return string the delimimiter
1042 1042
 	 */
1043
-	function getDelimiter($_type=1)
1043
+	function getDelimiter($_type = 1)
1044 1044
 	{
1045 1045
 		switch ($_type)
1046 1046
 		{
1047 1047
 			case 'user':
1048 1048
 			case 'other':
1049 1049
 			case 2:
1050
-				$type=2;
1050
+				$type = 2;
1051 1051
 				break;
1052 1052
 			case 'shared':
1053 1053
 			case '':
1054 1054
 			case 3:
1055
-				$type=3;
1055
+				$type = 3;
1056 1056
 				break;
1057 1057
 			case 'personal':
1058 1058
 			case 1:
1059 1059
 			default:
1060
-				$type=1;
1060
+				$type = 1;
1061 1061
 		}
1062 1062
 		$namespaces = $this->getNamespaces();
1063 1063
 		foreach ($namespaces as $nsp)
1064 1064
 		{
1065
-			if ($nsp['type']==$type && $nsp['delimiter']) return $nsp['delimiter'];
1065
+			if ($nsp['type'] == $type && $nsp['delimiter']) return $nsp['delimiter'];
1066 1066
 		}
1067 1067
 		return "/";
1068 1068
 	}
@@ -1090,7 +1090,7 @@  discard block
 block discarded – undo
1090 1090
 	{
1091 1091
 		if (is_numeric($_username))
1092 1092
 		{
1093
-			$_username = $GLOBALS['egw']->accounts->id2name($accountID=$_username);
1093
+			$_username = $GLOBALS['egw']->accounts->id2name($accountID = $_username);
1094 1094
 		}
1095 1095
 		else
1096 1096
 		{
@@ -1099,7 +1099,7 @@  discard block
 block discarded – undo
1099 1099
 		switch ($this->loginType)
1100 1100
 		{
1101 1101
 			case 'email':
1102
-				$_username = $GLOBALS['egw']->accounts->id2name($accountID,'account_email');
1102
+				$_username = $GLOBALS['egw']->accounts->id2name($accountID, 'account_email');
1103 1103
 				break;
1104 1104
 
1105 1105
 			case 'vmailmgr':
@@ -1114,8 +1114,8 @@  discard block
 block discarded – undo
1114 1114
 				if (empty($this->loginType))
1115 1115
 				{
1116 1116
 					// try to figure out by params['acc_imap_username']
1117
-					list($lusername,$domain) = explode('@',$this->params['acc_imap_username'],2);
1118
-					if (strpos($_username,'@')===false && !empty($domain) && !empty($lusername))
1117
+					list($lusername, $domain) = explode('@', $this->params['acc_imap_username'], 2);
1118
+					if (strpos($_username, '@') === false && !empty($domain) && !empty($lusername))
1119 1119
 					{
1120 1120
 						$_username = $_username.'@'.$domain;
1121 1121
 					}
@@ -1154,20 +1154,20 @@  discard block
 block discarded – undo
1154 1154
 	 * @param string $_folderName=''
1155 1155
 	 * @return string utf-7 encoded (done in getMailboxName)
1156 1156
 	 */
1157
-	function getUserMailboxString($_username, $_folderName='')
1157
+	function getUserMailboxString($_username, $_folderName = '')
1158 1158
 	{
1159 1159
 		$nameSpaces = $this->getNameSpaceArray();
1160 1160
 
1161
-		if(!isset($nameSpaces['others'])) {
1161
+		if (!isset($nameSpaces['others'])) {
1162 1162
 			return false;
1163 1163
 		}
1164 1164
 
1165 1165
 		$username = $this->getMailBoxUserName($_username);
1166
-		if($this->loginType == 'vmailmgr' || $this->loginType == 'uidNumber') {
1167
-			$username .= '@'. $this->domainName;
1166
+		if ($this->loginType == 'vmailmgr' || $this->loginType == 'uidNumber') {
1167
+			$username .= '@'.$this->domainName;
1168 1168
 		}
1169 1169
 
1170
-		$mailboxString = $nameSpaces['others'][0]['name'] . $username . (!empty($_folderName) ? ($nameSpaces['others'][0]['delimiter']?$nameSpaces['others'][0]['delimiter']:'/') . $_folderName : '');
1170
+		$mailboxString = $nameSpaces['others'][0]['name'].$username.(!empty($_folderName) ? ($nameSpaces['others'][0]['delimiter'] ? $nameSpaces['others'][0]['delimiter'] : '/').$_folderName : '');
1171 1171
 
1172 1172
 		return $mailboxString;
1173 1173
 	}
@@ -1186,7 +1186,7 @@  discard block
 block discarded – undo
1186 1186
 		);
1187 1187
 		//error_log(__METHOD__.__LINE__.array2string($types));
1188 1188
 		$result = array();
1189
-		foreach($this->getNamespaces() as $data)
1189
+		foreach ($this->getNamespaces() as $data)
1190 1190
 		{
1191 1191
 			//error_log(__METHOD__.__LINE__.array2string($data));
1192 1192
 			if (isset($types[$data['type']]))
@@ -1196,7 +1196,7 @@  discard block
 block discarded – undo
1196 1196
 					'name' => $data['name'],
1197 1197
 					'prefix' => $data['name'],
1198 1198
 					'prefix_present' => !empty($data['name']),
1199
-					'delimiter' => ($data['delimiter']?$data['delimiter']:'/'),
1199
+					'delimiter' => ($data['delimiter'] ? $data['delimiter'] : '/'),
1200 1200
 				);
1201 1201
 			}
1202 1202
 		}
@@ -1217,7 +1217,7 @@  discard block
 block discarded – undo
1217 1217
 		{
1218 1218
 			if ($qInfo['storage'])
1219 1219
 			{
1220
-				return array('USED'=>$qInfo['storage']['usage'],'QMAX'=>$qInfo['storage']['limit']);
1220
+				return array('USED'=>$qInfo['storage']['usage'], 'QMAX'=>$qInfo['storage']['limit']);
1221 1221
 			}
1222 1222
 		}
1223 1223
 		return false;
@@ -1231,7 +1231,7 @@  discard block
 block discarded – undo
1231 1231
 	 * @param string $_what - what to retrieve either limit/QMAX, usage/USED or ALL is supported
1232 1232
 	 * @return int|array|boolean the quota for specified user (by what) or array with values for "limit" and "usage", or false
1233 1233
 	 */
1234
-	function getQuotaByUser($_username, $_what='QMAX')
1234
+	function getQuotaByUser($_username, $_what = 'QMAX')
1235 1235
 	{
1236 1236
 		$mailboxName = $this->getUserMailboxString($_username);
1237 1237
 		$storageQuota = $this->getQuotaRoot($mailboxName);
@@ -1240,7 +1240,7 @@  discard block
 block discarded – undo
1240 1240
 		if (is_array($storageQuota) && isset($storageQuota[$mailboxName]) && is_array($storageQuota[$mailboxName]) &&
1241 1241
 			isset($storageQuota[$mailboxName]['storage']) && is_array($storageQuota[$mailboxName]['storage']))
1242 1242
 		{
1243
-			switch($_what)
1243
+			switch ($_what)
1244 1244
 			{
1245 1245
 				case 'QMAX':
1246 1246
 					$_what = 'limit';
@@ -1266,7 +1266,7 @@  discard block
 block discarded – undo
1266 1266
 	 */
1267 1267
 	function getUserData($_username)
1268 1268
 	{
1269
-		unset($_username);	// not used
1269
+		unset($_username); // not used
1270 1270
 		return array();
1271 1271
 	}
1272 1272
 
@@ -1279,7 +1279,7 @@  discard block
 block discarded – undo
1279 1279
 	 */
1280 1280
 	function setUserData($_username, $_quota)
1281 1281
 	{
1282
-		unset($_username, $_quota);	// not used
1282
+		unset($_username, $_quota); // not used
1283 1283
 		return true;
1284 1284
 	}
1285 1285
 
@@ -1313,10 +1313,10 @@  discard block
 block discarded – undo
1313 1313
 	 * @param array $params
1314 1314
 	 * @throws Api\Exception\WrongParameter
1315 1315
 	 */
1316
-	public function __call($name,array $params=null)
1316
+	public function __call($name, array $params = null)
1317 1317
 	{
1318 1318
 		if ($this->debug) error_log(__METHOD__.'->'.$name.' with params:'.array2string($params));
1319
-		switch($name)
1319
+		switch ($name)
1320 1320
 		{
1321 1321
 			case 'installScript':
1322 1322
 			case 'getScript':
@@ -1331,9 +1331,9 @@  discard block
 block discarded – undo
1331 1331
 				if (is_null($this->sieve))
1332 1332
 				{
1333 1333
 					$this->sieve = new Sieve($this);
1334
-					$this->error =& $this->sieve->error;
1334
+					$this->error = & $this->sieve->error;
1335 1335
 				}
1336
-				$ret = call_user_func_array(array($this->sieve,$name),$params);
1336
+				$ret = call_user_func_array(array($this->sieve, $name), $params);
1337 1337
 				//error_log(__CLASS__.'->'.$name.'('.array2string($params).') returns '.array2string($ret));
1338 1338
 				return $ret;
1339 1339
 		}
@@ -1348,7 +1348,7 @@  discard block
 block discarded – undo
1348 1348
 	 * @param string $_scriptName =null
1349 1349
 	 * @return boolean
1350 1350
 	 */
1351
-	public function setVacationUser($_euser, array $_vacation, $_scriptName=null)
1351
+	public function setVacationUser($_euser, array $_vacation, $_scriptName = null)
1352 1352
 	{
1353 1353
 		if ($this->debug) error_log(__METHOD__.' User:'.array2string($_euser).' Scriptname:'.array2string($_scriptName).' VacationMessage:'.array2string($_vacation));
1354 1354
 
@@ -1360,8 +1360,8 @@  discard block
 block discarded – undo
1360 1360
 		{
1361 1361
 			$this->adminConnection($_euser);
1362 1362
 			$this->sieve = new Sieve($this, $_euser, $_scriptName);
1363
-			$this->scriptName =& $this->sieve->scriptName;
1364
-			$this->error =& $this->sieve->error;
1363
+			$this->scriptName = & $this->sieve->scriptName;
1364
+			$this->error = & $this->sieve->error;
1365 1365
 		}
1366 1366
 		$ret = $this->setVacation($_vacation, $_scriptName);
1367 1367
 
@@ -1376,7 +1376,7 @@  discard block
 block discarded – undo
1376 1376
 	 * @throws Exception on connection error or authentication failure
1377 1377
 	 * @return array
1378 1378
 	 */
1379
-	public function getVacationUser($_euser, $_scriptName=null)
1379
+	public function getVacationUser($_euser, $_scriptName = null)
1380 1380
 	{
1381 1381
 		if ($this->debug) error_log(__METHOD__.' User:'.array2string($_euser));
1382 1382
 
@@ -1388,8 +1388,8 @@  discard block
 block discarded – undo
1388 1388
 		{
1389 1389
 			$this->adminConnection($_euser);
1390 1390
 			$this->sieve = new Sieve($this, $_euser, $_scriptName);
1391
-			$this->error =& $this->sieve->error;
1392
-			$this->scriptName =& $this->sieve->scriptName;
1391
+			$this->error = & $this->sieve->error;
1392
+			$this->scriptName = & $this->sieve->scriptName;
1393 1393
 		}
1394 1394
 		return $this->sieve->getVacation();
1395 1395
 	}
@@ -1409,7 +1409,7 @@  discard block
 block discarded – undo
1409 1409
 	 */
1410 1410
 	public static function init_static()
1411 1411
 	{
1412
-		self::$supports_keywords =& Api\Cache::getSession (__CLASS__, 'supports_keywords');
1412
+		self::$supports_keywords = & Api\Cache::getSession(__CLASS__, 'supports_keywords');
1413 1413
 	}
1414 1414
 }
1415 1415
 Imap::init_static();
Please login to merge, or discard this patch.
Braces   +130 added lines, -42 removed lines patch added patch discarded remove patch
@@ -156,7 +156,10 @@  discard block
 block discarded – undo
156 156
 		$this->loginType = $this->params['acc_imap_logintype'];
157 157
 		$this->domainName = $this->params['acc_domain'];
158 158
 
159
-		if (is_null($_timeout)) $_timeout = $this->params['acc_imap_timeout']?$this->params['acc_imap_timeout']:self::getTimeOut ();
159
+		if (is_null($_timeout))
160
+		{
161
+			$_timeout = $this->params['acc_imap_timeout']?$this->params['acc_imap_timeout']:self::getTimeOut ();
162
+		}
160 163
 
161 164
 		// Horde use locale for translation of error messages
162 165
 		// need to set LC_CTYPE for charachter classification (eg. Umlauts)
@@ -169,7 +172,10 @@  discard block
 block discarded – undo
169 172
 		{
170 173
 			$username = $this->getMailBoxUserName($username);
171 174
 		}
172
-		if ($_adminConnection) $this->adminConnection($username);
175
+		if ($_adminConnection)
176
+		{
177
+			$this->adminConnection($username);
178
+		}
173 179
 		$parent_params = array(
174 180
 			'username' => $this->params[$_adminConnection ? 'acc_imap_admin_username' : 'acc_imap_username'],
175 181
 			'password' => $this->params[$_adminConnection ? 'acc_imap_admin_password' : 'acc_imap_password'],
@@ -343,7 +349,11 @@  discard block
 block discarded – undo
343 349
 	static function getTimeOut($_use='IMAP')
344 350
 	{
345 351
 		$timeout = $GLOBALS['egw_info']['user']['preferences']['mail']['connectionTimeout'];
346
-		if (empty($timeout) || !($timeout > 0)) $timeout = $_use == 'SIEVE' ? 10 : 20; // this is the default value
352
+		if (empty($timeout) || !($timeout > 0))
353
+		{
354
+			$timeout = $_use == 'SIEVE' ? 10 : 20;
355
+		}
356
+		// this is the default value
347 357
 		return $timeout;
348 358
 	}
349 359
 
@@ -406,7 +416,8 @@  discard block
 block discarded – undo
406 416
 	 */
407 417
 	function encodeFolderName($_folderName)
408 418
 	{
409
-		if($this->mbAvailable) {
419
+		if($this->mbAvailable)
420
+		{
410 421
 			return mb_convert_encoding($_folderName, "UTF7-IMAP", Api\Translation::charset());
411 422
 		}
412 423
 
@@ -424,14 +435,21 @@  discard block
 block discarded – undo
424 435
 	function getMailbox($mailbox)
425 436
 	{
426 437
 		$mailboxes = $this->listMailboxes($mailbox,Horde_Imap_Client::MBOX_ALL);
427
-		if (empty($mailboxes)) $mailboxes = $this->listMailboxes($mailbox,Horde_Imap_Client::MBOX_UNSUBSCRIBED);
438
+		if (empty($mailboxes))
439
+		{
440
+			$mailboxes = $this->listMailboxes($mailbox,Horde_Imap_Client::MBOX_UNSUBSCRIBED);
441
+		}
428 442
 		//error_log(__METHOD__.__LINE__.'->'.$mailbox.'/'.array2string($mailboxes));
429 443
 		$mboxes = new Horde_Imap_Client_Mailbox_List($mailboxes);
430 444
 		//_debug_array($mboxes->count());
431 445
 		foreach ($mboxes->getIterator() as $k =>$box)
432 446
 		{
433 447
 			//error_log(__METHOD__.__LINE__.'->'.$k);
434
-			if ($k!='user' && $k != '' && $k==$mailbox) return $box['mailbox']; //_debug_array(array($k => $client->status($k)));
448
+			if ($k!='user' && $k != '' && $k==$mailbox)
449
+			{
450
+				return $box['mailbox'];
451
+			}
452
+			//_debug_array(array($k => $client->status($k)));
435 453
 		}
436 454
 		return ($this->mailboxExist($mailbox)?$mailbox:false);
437 455
 	}
@@ -500,8 +518,14 @@  discard block
 block discarded – undo
500 518
 			//throw new egw_exception(__METHOD__.' ('.__LINE__.") failed to ".__METHOD__." :".$e->getMessage());
501 519
 			unset($e);
502 520
 		}
503
-		if (!empty($mailbox)) return $mailbox['mailbox'];
504
-		if (empty($mailbox) && $this->mailboxExist('INBOX')) return 'INBOX';
521
+		if (!empty($mailbox))
522
+		{
523
+			return $mailbox['mailbox'];
524
+		}
525
+		if (empty($mailbox) && $this->mailboxExist('INBOX'))
526
+		{
527
+			return 'INBOX';
528
+		}
505 529
 		return null;
506 530
 	}
507 531
 
@@ -571,7 +595,10 @@  discard block
 block discarded – undo
571 595
 			));
572 596
 
573 597
 		$flags = Horde_Imap_Client::STATUS_ALL;
574
-		if ($ignoreStatusCache) $flags |= Horde_Imap_Client::STATUS_FORCE_REFRESH;
598
+		if ($ignoreStatusCache)
599
+		{
600
+			$flags |= Horde_Imap_Client::STATUS_FORCE_REFRESH;
601
+		}
575 602
 
576 603
 		$mboxes = new Horde_Imap_Client_Mailbox_List($mailboxes);
577 604
 		//error_log(__METHOD__.__LINE__.array2string($mboxes->count()));
@@ -614,12 +641,15 @@  discard block
 block discarded – undo
614 641
 	 */
615 642
 	function getMailboxes($reference = ''  , $restriction_search = 0, $returnAttributes = false)
616 643
 	{
617
-		if ( is_bool($restriction_search) ){
644
+		if ( is_bool($restriction_search) )
645
+		{
618 646
 			$restriction_search = (int) $restriction_search;
619 647
 		}
620 648
 		$mailbox = '';
621
-		if ( is_int( $restriction_search ) ){
622
-			switch ( $restriction_search ) {
649
+		if ( is_int( $restriction_search ) )
650
+		{
651
+			switch ( $restriction_search )
652
+			{
623 653
 			case 0:
624 654
 				$searchstring = $reference."*";
625 655
 				break;
@@ -631,8 +661,11 @@  discard block
 block discarded – undo
631 661
 				$searchstring = $reference."%";
632 662
 				break;
633 663
 			}
634
-		}else{
635
-			if ( is_string( $restriction_search ) ){
664
+		}
665
+		else
666
+		{
667
+			if ( is_string( $restriction_search ) )
668
+			{
636 669
 				$mailbox = $searchstring = $restriction_search;
637 670
 			}
638 671
 		}
@@ -698,12 +731,15 @@  discard block
 block discarded – undo
698 731
 	 */
699 732
 	function listSubscribedMailboxes($reference = ''  , $restriction_search = 0, $returnAttributes = false)
700 733
 	{
701
-		if ( is_bool($restriction_search) ){
734
+		if ( is_bool($restriction_search) )
735
+		{
702 736
 			$restriction_search = (int) $restriction_search;
703 737
 		}
704 738
 		$mailbox = '';
705
-		if ( is_int( $restriction_search ) ){
706
-			switch ( $restriction_search ) {
739
+		if ( is_int( $restriction_search ) )
740
+		{
741
+			switch ( $restriction_search )
742
+			{
707 743
 			case 0:
708 744
 				$searchstring = $reference."*";
709 745
 				break;
@@ -715,8 +751,11 @@  discard block
 block discarded – undo
715 751
 				$searchstring = $reference."%";
716 752
 				break;
717 753
 			}
718
-		}else{
719
-			if ( is_string( $restriction_search ) ){
754
+		}
755
+		else
756
+		{
757
+			if ( is_string( $restriction_search ) )
758
+			{
720 759
 				$mailbox = $searchstring = $restriction_search;
721 760
 			}
722 761
 		}
@@ -764,12 +803,15 @@  discard block
 block discarded – undo
764 803
 	 */
765 804
 	function listUnSubscribedMailboxes($reference = ''  , $restriction_search = 0)
766 805
 	{
767
-		if ( is_bool($restriction_search) ){
806
+		if ( is_bool($restriction_search) )
807
+		{
768 808
 			$restriction_search = (int) $restriction_search;
769 809
 		}
770 810
 
771
-		if ( is_int( $restriction_search ) ){
772
-			switch ( $restriction_search ) {
811
+		if ( is_int( $restriction_search ) )
812
+		{
813
+			switch ( $restriction_search )
814
+			{
773 815
 			case 0:
774 816
 				$mailbox = $reference."*";
775 817
 				break;
@@ -781,8 +823,11 @@  discard block
 block discarded – undo
781 823
 				$mailbox = "%";
782 824
 				break;
783 825
 			}
784
-		}else{
785
-			if ( is_string( $restriction_search ) ){
826
+		}
827
+		else
828
+		{
829
+			if ( is_string( $restriction_search ) )
830
+			{
786 831
 				$mailbox = $restriction_search;
787 832
 			}
788 833
 		}
@@ -801,7 +846,10 @@  discard block
 block discarded – undo
801 846
 		foreach ($unsubscribed as $box)
802 847
 		{
803 848
 			//error_log(__METHOD__.__LINE__.' Box:'.$k.'->'.array2string($box['mailbox']->utf8));
804
-			if (!in_array($box['mailbox']->utf8,$sret) && $box['mailbox']->utf8!='INBOX') $ret[]=$box['mailbox']->utf8;
849
+			if (!in_array($box['mailbox']->utf8,$sret) && $box['mailbox']->utf8!='INBOX')
850
+			{
851
+				$ret[]=$box['mailbox']->utf8;
852
+			}
805 853
 		}
806 854
 		return $ret;
807 855
 	}
@@ -815,10 +863,16 @@  discard block
 block discarded – undo
815 863
 	 */
816 864
 	function examineMailbox($mailbox, $flags=null)
817 865
 	{
818
-		if ($mailbox=='') return false;
866
+		if ($mailbox=='')
867
+		{
868
+			return false;
869
+		}
819 870
 		$mailboxes = $this->listMailboxes($mailbox);
820 871
 
821
-		if (is_null($flags)) $flags = Horde_Imap_Client::STATUS_ALL | Horde_Imap_Client::STATUS_FLAGS | Horde_Imap_Client::STATUS_PERMFLAGS;
872
+		if (is_null($flags))
873
+		{
874
+			$flags = Horde_Imap_Client::STATUS_ALL | Horde_Imap_Client::STATUS_FLAGS | Horde_Imap_Client::STATUS_PERMFLAGS;
875
+		}
822 876
 
823 877
 		$mboxes = new Horde_Imap_Client_Mailbox_List($mailboxes);
824 878
 		//_debug_array($mboxes->count());
@@ -900,7 +954,10 @@  discard block
 block discarded – undo
900 954
 		}
901 955
 		catch (\Exception $e)
902 956
 		{
903
-			if ($this->debug) error_log(__METHOD__.__LINE__.' error querying for capability:'.$capability.' ->'.$e->getMessage());
957
+			if ($this->debug)
958
+			{
959
+				error_log(__METHOD__.__LINE__.' error querying for capability:'.$capability.' ->'.$e->getMessage());
960
+			}
904 961
 			return false;
905 962
 		}
906 963
 		if (!is_array($cap))
@@ -940,7 +997,10 @@  discard block
 block discarded – undo
940 997
 	{
941 998
 		foreach($_nameSpace as &$singleNameSpace)
942 999
 		{
943
-			if (substr($_folderName,0,strlen($singleNameSpace['prefix'])) == $singleNameSpace['prefix']) return $singleNameSpace['prefix'];
1000
+			if (substr($_folderName,0,strlen($singleNameSpace['prefix'])) == $singleNameSpace['prefix'])
1001
+			{
1002
+				return $singleNameSpace['prefix'];
1003
+			}
944 1004
 		}
945 1005
 		return "";
946 1006
 	}
@@ -957,7 +1017,8 @@  discard block
 block discarded – undo
957 1017
 	 */
958 1018
 	function getMailBoxesRecursive($_mailbox, $delimiter, $prefix, $reclevel=0)
959 1019
 	{
960
-		if ($reclevel > 25) {
1020
+		if ($reclevel > 25)
1021
+		{
961 1022
 			error_log( __METHOD__." Recursion Level Exeeded ($reclevel) while looking up $_mailbox$delimiter ");
962 1023
 			return array();
963 1024
 		}
@@ -973,7 +1034,8 @@  discard block
 block discarded – undo
973 1034
 		{
974 1035
 			$buff = $this->getMailboxes($mbx[$mbxkeys[0]]['MAILBOX'].($mbx[$mbxkeys[0]]['MAILBOX'] == $prefix ? '':$delimiter),2,false);
975 1036
 			$allMailboxes = array();
976
-			foreach ($buff as $mbxname) {
1037
+			foreach ($buff as $mbxname)
1038
+			{
977 1039
 				$mbxname = preg_replace('~'.($delimiter == '.' ? "\\".$delimiter:$delimiter).'+~s',$delimiter,$mbxname['MAILBOX']);
978 1040
 				#echo "About to recur in level $reclevel:".$mbxname."<br>";
979 1041
 				if ( $mbxname != $mbx[$mbxkeys[0]]['MAILBOX'] && $mbxname != $prefix  && $mbxname != $mbx[$mbxkeys[0]]['MAILBOX'].$delimiter)
@@ -981,7 +1043,10 @@  discard block
 block discarded – undo
981 1043
 					$allMailboxes = array_merge($allMailboxes, self::getMailBoxesRecursive($mbxname, $delimiter, $prefix, $reclevel));
982 1044
 				}
983 1045
 			}
984
-			if (!(in_array('\NoSelect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\Noselect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\noselect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]))) $allMailboxes[] = $mbx[$mbxkeys[0]]['MAILBOX'];
1046
+			if (!(in_array('\NoSelect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\Noselect',$mbx[$mbxkeys[0]]["ATTRIBUTES"]) || in_array('\noselect',$mbx[$mbxkeys[0]]["ATTRIBUTES"])))
1047
+			{
1048
+				$allMailboxes[] = $mbx[$mbxkeys[0]]['MAILBOX'];
1049
+			}
985 1050
 			return $allMailboxes;
986 1051
 		}
987 1052
 		else
@@ -1003,9 +1068,16 @@  discard block
 block discarded – undo
1003 1068
 		static $nameSpace=null;
1004 1069
 		$foldersNameSpace = array();
1005 1070
 		$delimiter = $this->getDelimiter();
1006
-		if (empty($delimiter)) $delimiter='/';
1007
-		if (is_null($nameSpace)) $nameSpace = $this->getNameSpaceArray();
1008
-		if (is_array($nameSpace)) {
1071
+		if (empty($delimiter))
1072
+		{
1073
+			$delimiter='/';
1074
+		}
1075
+		if (is_null($nameSpace))
1076
+		{
1077
+			$nameSpace = $this->getNameSpaceArray();
1078
+		}
1079
+		if (is_array($nameSpace))
1080
+		{
1009 1081
 			foreach($nameSpace as $type => $singleNameSpaceArray)
1010 1082
 			{
1011 1083
 				foreach ($singleNameSpaceArray as $singleNameSpace)
@@ -1022,7 +1094,9 @@  discard block
 block discarded – undo
1022 1094
 						$_foldersNameSpace['prefix_present'] = 'forced';
1023 1095
 						// uw-imap server with mailbox prefix or dovecot maybe
1024 1096
 						$_foldersNameSpace['prefix'] = 'mail';
1025
-					} else {
1097
+					}
1098
+					else
1099
+					{
1026 1100
 						$_foldersNameSpace['prefix_present'] = !empty($singleNameSpace['name']);
1027 1101
 						$_foldersNameSpace['prefix'] = $singleNameSpace['name'];
1028 1102
 					}
@@ -1062,7 +1136,10 @@  discard block
 block discarded – undo
1062 1136
 		$namespaces = $this->getNamespaces();
1063 1137
 		foreach ($namespaces as $nsp)
1064 1138
 		{
1065
-			if ($nsp['type']==$type && $nsp['delimiter']) return $nsp['delimiter'];
1139
+			if ($nsp['type']==$type && $nsp['delimiter'])
1140
+			{
1141
+				return $nsp['delimiter'];
1142
+			}
1066 1143
 		}
1067 1144
 		return "/";
1068 1145
 	}
@@ -1158,12 +1235,14 @@  discard block
 block discarded – undo
1158 1235
 	{
1159 1236
 		$nameSpaces = $this->getNameSpaceArray();
1160 1237
 
1161
-		if(!isset($nameSpaces['others'])) {
1238
+		if(!isset($nameSpaces['others']))
1239
+		{
1162 1240
 			return false;
1163 1241
 		}
1164 1242
 
1165 1243
 		$username = $this->getMailBoxUserName($_username);
1166
-		if($this->loginType == 'vmailmgr' || $this->loginType == 'uidNumber') {
1244
+		if($this->loginType == 'vmailmgr' || $this->loginType == 'uidNumber')
1245
+		{
1167 1246
 			$username .= '@'. $this->domainName;
1168 1247
 		}
1169 1248
 
@@ -1315,7 +1394,10 @@  discard block
 block discarded – undo
1315 1394
 	 */
1316 1395
 	public function __call($name,array $params=null)
1317 1396
 	{
1318
-		if ($this->debug) error_log(__METHOD__.'->'.$name.' with params:'.array2string($params));
1397
+		if ($this->debug)
1398
+		{
1399
+			error_log(__METHOD__.'->'.$name.' with params:'.array2string($params));
1400
+		}
1319 1401
 		switch($name)
1320 1402
 		{
1321 1403
 			case 'installScript':
@@ -1350,7 +1432,10 @@  discard block
 block discarded – undo
1350 1432
 	 */
1351 1433
 	public function setVacationUser($_euser, array $_vacation, $_scriptName=null)
1352 1434
 	{
1353
-		if ($this->debug) error_log(__METHOD__.' User:'.array2string($_euser).' Scriptname:'.array2string($_scriptName).' VacationMessage:'.array2string($_vacation));
1435
+		if ($this->debug)
1436
+		{
1437
+			error_log(__METHOD__.' User:'.array2string($_euser).' Scriptname:'.array2string($_scriptName).' VacationMessage:'.array2string($_vacation));
1438
+		}
1354 1439
 
1355 1440
 		if (is_numeric($_euser))
1356 1441
 		{
@@ -1378,7 +1463,10 @@  discard block
 block discarded – undo
1378 1463
 	 */
1379 1464
 	public function getVacationUser($_euser, $_scriptName=null)
1380 1465
 	{
1381
-		if ($this->debug) error_log(__METHOD__.' User:'.array2string($_euser));
1466
+		if ($this->debug)
1467
+		{
1468
+			error_log(__METHOD__.' User:'.array2string($_euser));
1469
+		}
1382 1470
 
1383 1471
 		if (is_numeric($_euser))
1384 1472
 		{
Please login to merge, or discard this patch.
Doc Comments   +8 added lines, -7 removed lines patch added patch discarded remove patch
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 	 * Construtor
133 133
 	 *
134 134
 	 * @param array
135
-	 * @param bool|int|string $_adminConnection create admin connection if true or account_id or imap username
135
+	 * @param boolean|string $_adminConnection create admin connection if true or account_id or imap username
136 136
 	 * @param int $_timeout =null timeout in secs, if none given fmail pref or default of 20 is used
137 137
 	 * @return void
138 138
 	 */
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
 	/**
451 451
 	 * getSpecialUseFolders
452 452
 	 *
453
-	 * @return current mailbox, or if none check on INBOX, and return upon existance
453
+	 * @return string mailbox, or if none check on INBOX, and return upon existance
454 454
 	 */
455 455
 	function getCurrentMailbox()
456 456
 	{
@@ -568,7 +568,7 @@  discard block
 block discarded – undo
568 568
 	 * Returns an array containing the names of the selected mailboxes
569 569
 	 *
570 570
 	 * @param   string  $reference          base mailbox to start the search (default is current mailbox)
571
-	 * @param   string  $restriction_search false or 0 means return all mailboxes
571
+	 * @param   integer  $restriction_search false or 0 means return all mailboxes
572 572
 	 *                                      true or 1 return only the mailbox that contains that exact name
573 573
 	 *                                      2 return all mailboxes in that hierarchy level
574 574
 	 * @param   string  $returnAttributes   true means return an assoc array containing mailbox names and mailbox attributes
@@ -652,7 +652,7 @@  discard block
 block discarded – undo
652 652
 	 * Returns an array containing the names of the subscribed selected mailboxes
653 653
 	 *
654 654
 	 * @param   string  $reference          base mailbox to start the search
655
-	 * @param   string  $restriction_search false or 0 means return all mailboxes
655
+	 * @param   integer  $restriction_search false or 0 means return all mailboxes
656 656
 	 *                                      true or 1 return only the mailbox that contains that exact name
657 657
 	 *                                      2 return all mailboxes in that hierarchy level
658 658
 	 * @param   string  $returnAttributes   true means return an assoc array containing mailbox names and mailbox attributes
@@ -720,7 +720,7 @@  discard block
 block discarded – undo
720 720
 	 * Returns an array containing the names of the selected unsubscribed mailboxes
721 721
 	 *
722 722
 	 * @param   string  $reference          base mailbox to start the search
723
-	 * @param   string  $restriction_search false or 0 means return all mailboxes
723
+	 * @param   integer  $restriction_search false or 0 means return all mailboxes
724 724
 	 *                                      true or 1 return only the mailbox that contains that exact name
725 725
 	 *                                      2 return all mailboxes in that hierarchy level
726 726
 	 *
@@ -898,6 +898,7 @@  discard block
 block discarded – undo
898 898
 	 *
899 899
 	 * @var array $_nameSpace
900 900
 	 * @var string $_folderName
901
+	 * @param string $_folderName
901 902
 	 * @return string the prefix (may be an empty string)
902 903
 	 */
903 904
 	static function getFolderPrefixFromNamespace($_nameSpace, $_folderName)
@@ -916,7 +917,7 @@  discard block
 block discarded – undo
916 917
 	 * @param string $_mailbox
917 918
 	 * @param string $delimiter
918 919
 	 * @param string $prefix
919
-	 * @param string $reclevel = 0, counter to keep track of the current recursionlevel
920
+	 * @param integer $reclevel = 0, counter to keep track of the current recursionlevel
920 921
 	 * @return array of mailboxes
921 922
 	 */
922 923
 	function getMailBoxesRecursive($_mailbox, $delimiter, $prefix, $reclevel=0)
@@ -1355,7 +1356,7 @@  discard block
 block discarded – undo
1355 1356
 	/**
1356 1357
 	 * Get vacation message for given user
1357 1358
 	 *
1358
-	 * @param int|string $_euser nummeric account_id or imap username
1359
+	 * @param string|null $_euser nummeric account_id or imap username
1359 1360
 	 * @param string $_scriptName =null
1360 1361
 	 * @throws Exception on connection error or authentication failure
1361 1362
 	 * @return array
Please login to merge, or discard this patch.
api/src/Mail/Imap/Cyrus.php 2 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -62,8 +62,8 @@  discard block
 block discarded – undo
62 62
 	function deleteAccount($_hookValues)
63 63
 	{
64 64
 		// some precausion to really delete just _one_ account
65
-		if (strpos($_hookValues['account_lid'],'%') !== false ||
66
-			strpos($_hookValues['account_lid'],'*') !== false)
65
+		if (strpos($_hookValues['account_lid'], '%') !== false ||
66
+			strpos($_hookValues['account_lid'], '*') !== false)
67 67
 		{
68 68
 			return false;
69 69
 		}
@@ -78,9 +78,9 @@  discard block
 block discarded – undo
78 78
 	 * @return string $username='%' username containing wildcards, default '%' for all users of a domain
79 79
 	 * @return int|boolean number of deleted mailboxes on success or false on error
80 80
 	 */
81
-	function deleteUsers($username='%')
81
+	function deleteUsers($username = '%')
82 82
 	{
83
-		if(!$this->acc_imap_administration || empty($username))
83
+		if (!$this->acc_imap_administration || empty($username))
84 84
 		{
85 85
 			return false;
86 86
 		}
@@ -94,14 +94,14 @@  discard block
 block discarded – undo
94 94
 			$mboxes = (array)$this->getMailboxes($mailboxName, 1);
95 95
 			//error_log(__METHOD__."('$username') getMailboxes('$reference','$username$restriction') = ".array2string($mboxes));
96 96
 
97
-			foreach(array_keys($mboxes) as $mbox)
97
+			foreach (array_keys($mboxes) as $mbox)
98 98
 			{
99 99
 				// give the admin account the rights to delete this mailbox
100 100
 				$this->setACL($mbox, $this->acc_imap_admin_username, array('rights' => 'aeiklprstwx'));
101 101
 				$this->deleteMailbox($mbox);
102 102
 			}
103 103
 		}
104
-		catch(Horde_Imap_Client_Exception $e) {
104
+		catch (Horde_Imap_Client_Exception $e) {
105 105
 			_egw_log_exception($e);
106 106
 			$this->disconnect();
107 107
 			return false;
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 		if ($_username !== $GLOBALS['egw_info']['user']['account_lid']) $this->adminConnection();
125 125
 		$userData = array();
126 126
 
127
-		if(($quota = $this->getQuotaByUser($_username,'ALL')))
127
+		if (($quota = $this->getQuotaByUser($_username, 'ALL')))
128 128
 		{
129 129
 			$userData['quotaLimit'] = (int)($quota['limit'] / 1024);
130 130
 			$userData['quotaUsed'] = (int)($quota['usage'] / 1024);
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 	 */
146 146
 	function setUserData($_username, $_quota)
147 147
 	{
148
-		if(!$this->acc_imap_administration)
148
+		if (!$this->acc_imap_administration)
149 149
 		{
150 150
 			return false;
151 151
 		}
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 
156 156
 		$mailboxName = $this->getUserMailboxString($_username);
157 157
 
158
-		$this->setQuota($mailboxName, array('STORAGE' => (int)$_quota > 0 ? (int)$_quota*1024 : -1));
158
+		$this->setQuota($mailboxName, array('STORAGE' => (int)$_quota > 0 ? (int)$_quota * 1024 : -1));
159 159
 
160 160
 		$this->disconnect();
161 161
 
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 	 */
170 170
 	function updateAccount($_hookValues)
171 171
 	{
172
-		if(!$this->acc_imap_administration)
172
+		if (!$this->acc_imap_administration)
173 173
 		{
174 174
 			return false;
175 175
 		}
@@ -182,14 +182,14 @@  discard block
 block discarded – undo
182 182
 		// make sure we use the correct username here.
183 183
 		$username = $this->getMailBoxUserName($_hookValues['account_lid']);
184 184
 		$folderInfo = $this->getMailboxes('', $mailboxName, true);
185
-		if(empty($folderInfo))
185
+		if (empty($folderInfo))
186 186
 		{
187 187
 			try {
188 188
 				$this->createMailbox($mailboxName);
189 189
 				$this->setACL($mailboxName, $username, array('rights' => 'aeiklprstwx'));
190 190
 				// create defined folders and subscribe them (have to use user-credentials to subscribe!)
191 191
 				$userimap = null;
192
-				foreach($this->params as $name => $value)
192
+				foreach ($this->params as $name => $value)
193 193
 				{
194 194
 					if (substr($name, 0, 11) == 'acc_folder_' && !empty($value))
195 195
 					{
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 				}
207 207
 				if (isset($userimap)) $userimap->logout();
208 208
 			}
209
-			catch(Horde_Imap_Client_Exception $e) {
209
+			catch (Horde_Imap_Client_Exception $e) {
210 210
 				_egw_log_exception($e);
211 211
 			}
212 212
 		}
@@ -220,9 +220,9 @@  discard block
 block discarded – undo
220 220
 	 * @param array $params
221 221
 	 * @throws Exception
222 222
 	 */
223
-	public function __call($name,array $params=null)
223
+	public function __call($name, array $params = null)
224 224
 	{
225
-		switch($name)
225
+		switch ($name)
226 226
 		{
227 227
 			case 'setRules':	// call setRules with 3. param of true, to enable utf7imap fileinto for Cyrus
228 228
 				$params += array(null, null, true);
Please login to merge, or discard this patch.
Braces   +12 added lines, -3 removed lines patch added patch discarded remove patch
@@ -121,7 +121,10 @@  discard block
 block discarded – undo
121 121
 	function getUserData($_username)
122 122
 	{
123 123
 		// no need to switch to admin-connection for reading quota of current user
124
-		if ($_username !== $GLOBALS['egw_info']['user']['account_lid']) $this->adminConnection();
124
+		if ($_username !== $GLOBALS['egw_info']['user']['account_lid'])
125
+		{
126
+			$this->adminConnection();
127
+		}
125 128
 		$userData = array();
126 129
 
127 130
 		if(($quota = $this->getQuotaByUser($_username,'ALL')))
@@ -131,7 +134,10 @@  discard block
 block discarded – undo
131 134
 		}
132 135
 		//error_log(__LINE__.': '.__METHOD__."('$_username') quota=".array2string($quota).' returning '.array2string($userData));
133 136
 
134
-		if ($_username !== $GLOBALS['egw_info']['user']['account_lid']) $this->disconnect();
137
+		if ($_username !== $GLOBALS['egw_info']['user']['account_lid'])
138
+		{
139
+			$this->disconnect();
140
+		}
135 141
 
136 142
 		return $userData;
137 143
 	}
@@ -204,7 +210,10 @@  discard block
 block discarded – undo
204 210
 						$userimap->subscribeMailbox($value);
205 211
 					}
206 212
 				}
207
-				if (isset($userimap)) $userimap->logout();
213
+				if (isset($userimap))
214
+				{
215
+					$userimap->logout();
216
+				}
208 217
 			}
209 218
 			catch(Horde_Imap_Client_Exception $e) {
210 219
 				_egw_log_exception($e);
Please login to merge, or discard this patch.