Completed
Push — 16.1 ( ed43f0...afa191 )
by Hadi
40:48 queued 23:19
created
api/src/Mail/Imap.php 2 patches
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.
Spacing   +135 added lines, -135 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
 		{
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 				// as we have no way to tell this apart we ignore BINARY this affects
202 202
 				// Horde_Imap_Client_Fetch_Query::bodyPart for its fetch parameter decode=true is ignored
203 203
 				// (other functionality depending on BINARY is, of cause, affected too)
204
-				$parent_params['capability_ignore']= array_merge((array)$parent_params['capability_ignore'],array('BINARY'));
204
+				$parent_params['capability_ignore'] = array_merge((array)$parent_params['capability_ignore'], array('BINARY'));
205 205
 				break;
206 206
 		}
207 207
 		parent::__construct($parent_params);
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 	 *
215 215
 	 * @param string $_username =true create an admin connection for given user or $this->acc_imap_username
216 216
 	 */
217
-	function adminConnection($_username=true)
217
+	function adminConnection($_username = true)
218 218
 	{
219 219
 		if ($this->isAdminConnection !== $_username)
220 220
 		{
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 	 * @param string $_username =null create an admin connection for given user or $this->acc_imap_username
232 232
 	 * @throws Horde_IMAP_Client_Exception
233 233
 	 */
234
-	public function checkAdminConnection($_username=true)
234
+	public function checkAdminConnection($_username = true)
235 235
 	{
236 236
 		if ($this->acc_imap_administration)
237 237
 		{
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 	 */
249 249
 	public function __get($name)
250 250
 	{
251
-		switch($name)
251
+		switch ($name)
252 252
 		{
253 253
 			case 'acc_imap_administration':
254 254
 				return !empty($this->params['acc_imap_admin_username']);
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
 				{
267 267
 					return $this->$name;
268 268
 				}
269
-				if (array_key_exists($name,$this->params))
269
+				if (array_key_exists($name, $this->params))
270 270
 				{
271 271
 					return $this->params[$name];
272 272
 				}
@@ -287,9 +287,9 @@  discard block
 block discarded – undo
287 287
 	 * @deprecated allready called by constructor automatic, parameters must be passed to constructor!
288 288
 	 * @throws Api\Exception\WrongParameter
289 289
 	 */
290
-	function openConnection($_adminConnection=false, $_timeout=null)
290
+	function openConnection($_adminConnection = false, $_timeout = null)
291 291
 	{
292
-		unset($_timeout);	// not used
292
+		unset($_timeout); // not used
293 293
 		if ($_adminConnection !== $this->params['adminConnection'])
294 294
 		{
295 295
 			throw new Api\Exception\WrongParameter('need to set parameters on calling Account->imapServer()!');
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 	 * @param string _use decide if the use is for IMAP or SIEVE, by now only the default differs
303 303
 	 * @return int - timeout (either set or default 20/10)
304 304
 	 */
305
-	static function getTimeOut($_use='IMAP')
305
+	static function getTimeOut($_use = 'IMAP')
306 306
 	{
307 307
 		$timeout = $GLOBALS['egw_info']['user']['preferences']['mail']['connectionTimeout'];
308 308
 		if (empty($timeout) || !($timeout > 0)) $timeout = $_use == 'SIEVE' ? 10 : 20; // this is the default value
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
 	 */
328 328
 	function addAccount($_hookValues)
329 329
 	{
330
-		unset($_hookValues);	// not used
330
+		unset($_hookValues); // not used
331 331
 		return true;
332 332
 	}
333 333
 
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
 	 */
340 340
 	function updateAccount($_hookValues)
341 341
 	{
342
-		unset($_hookValues);	// not used
342
+		unset($_hookValues); // not used
343 343
 		return true;
344 344
 	}
345 345
 
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
 	 */
352 352
 	function deleteAccount($_hookValues)
353 353
 	{
354
-		unset($_hookValues);	// not used
354
+		unset($_hookValues); // not used
355 355
 		return true;
356 356
 	}
357 357
 
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
 	 */
369 369
 	function encodeFolderName($_folderName)
370 370
 	{
371
-		if($this->mbAvailable) {
371
+		if ($this->mbAvailable) {
372 372
 			return mb_convert_encoding($_folderName, "UTF7-IMAP", Api\Translation::charset());
373 373
 		}
374 374
 
@@ -385,17 +385,17 @@  discard block
 block discarded – undo
385 385
 	 */
386 386
 	function getMailbox($mailbox)
387 387
 	{
388
-		$mailboxes = $this->listMailboxes($mailbox,Horde_Imap_Client::MBOX_ALL);
389
-		if (empty($mailboxes)) $mailboxes = $this->listMailboxes($mailbox,Horde_Imap_Client::MBOX_UNSUBSCRIBED);
388
+		$mailboxes = $this->listMailboxes($mailbox, Horde_Imap_Client::MBOX_ALL);
389
+		if (empty($mailboxes)) $mailboxes = $this->listMailboxes($mailbox, Horde_Imap_Client::MBOX_UNSUBSCRIBED);
390 390
 		//error_log(__METHOD__.__LINE__.'->'.$mailbox.'/'.array2string($mailboxes));
391 391
 		$mboxes = new Horde_Imap_Client_Mailbox_List($mailboxes);
392 392
 		//_debug_array($mboxes->count());
393 393
 		foreach ($mboxes->getIterator() as $k =>$box)
394 394
 		{
395 395
 			//error_log(__METHOD__.__LINE__.'->'.$k);
396
-			if ($k!='user' && $k != '' && $k==$mailbox) return $box['mailbox']; //_debug_array(array($k => $client->status($k)));
396
+			if ($k != 'user' && $k != '' && $k == $mailbox) return $box['mailbox']; //_debug_array(array($k => $client->status($k)));
397 397
 		}
398
-		return ($this->mailboxExist($mailbox)?$mailbox:false);
398
+		return ($this->mailboxExist($mailbox) ? $mailbox : false);
399 399
 	}
400 400
 
401 401
 	/**
@@ -411,23 +411,23 @@  discard block
 block discarded – undo
411 411
 			//error_log(__METHOD__.__LINE__.':'.$mailbox);
412 412
 			$currentMailbox = $this->currentMailbox();
413 413
 		}
414
-		catch(\Exception $e)
414
+		catch (\Exception $e)
415 415
 		{
416 416
 			//error_log(__METHOD__.__LINE__.' failed detecting currentMailbox:'.$currentMailbox.':'.$e->getMessage());
417
-			$currentMailbox=null;
417
+			$currentMailbox = null;
418 418
 			unset($e);
419 419
 		}
420 420
 		try
421 421
 		{
422 422
 			//error_log(__METHOD__.__LINE__.':'.$mailbox);
423 423
 			$this->openMailbox($mailbox);
424
-			$returnvalue=true;
424
+			$returnvalue = true;
425 425
 		}
426
-		catch(\Exception $e)
426
+		catch (\Exception $e)
427 427
 		{
428 428
 			//error_log(__METHOD__.__LINE__.' failed opening:'.$mailbox.':'.$e->getMessage().' Called by:'.function_backtrace());
429 429
 			unset($e);
430
-			$returnvalue=false;
430
+			$returnvalue = false;
431 431
 		}
432 432
 		if (!empty($currentMailbox) && $currentMailbox['mailbox'] != $mailbox)
433 433
 		{
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
 				//error_log(__METHOD__.__LINE__.':'.$currentMailbox .'<->'.$mailbox);
437 437
 				$this->openMailbox($currentMailbox['mailbox']);
438 438
 			}
439
-			catch(\Exception $e)
439
+			catch (\Exception $e)
440 440
 			{
441 441
 				//error_log(__METHOD__.__LINE__.' failed reopening:'.$currentMailbox.':'.$e->getMessage());
442 442
 				unset($e);
@@ -456,7 +456,7 @@  discard block
 block discarded – undo
456 456
 		{
457 457
 			$mailbox = $this->currentMailbox();
458 458
 		}
459
-		catch(\Exception $e)
459
+		catch (\Exception $e)
460 460
 		{
461 461
 			error_log(__METHOD__.' ('.__LINE__.') failed fetching currentMailbox:'.$e->getMessage());
462 462
 			//throw new egw_exception(__METHOD__.' ('.__LINE__.") failed to ".__METHOD__." :".$e->getMessage());
@@ -474,16 +474,16 @@  discard block
 block discarded – undo
474 474
 	 */
475 475
 	function getSpecialUseFolders()
476 476
 	{
477
-		$mailboxes = $this->getMailboxes('',0,true);
477
+		$mailboxes = $this->getMailboxes('', 0, true);
478 478
 		$suF = array();
479 479
 		foreach ($mailboxes as $box)
480 480
 		{
481
-			if ($box['MAILBOX']!='user' && $box['MAILBOX'] != '')
481
+			if ($box['MAILBOX'] != 'user' && $box['MAILBOX'] != '')
482 482
 			{
483 483
 				//error_log(__METHOD__.__LINE__.$k.'->'.array2string($box));
484
-				if (isset($box['ATTRIBUTES'])&&!empty($box['ATTRIBUTES'])&&
485
-					stripos(strtolower(array2string($box['ATTRIBUTES'])),'\noselect')=== false&&
486
-					stripos(strtolower(array2string($box['ATTRIBUTES'])),'\nonexistent')=== false)
484
+				if (isset($box['ATTRIBUTES']) && !empty($box['ATTRIBUTES']) &&
485
+					stripos(strtolower(array2string($box['ATTRIBUTES'])), '\noselect') === false &&
486
+					stripos(strtolower(array2string($box['ATTRIBUTES'])), '\nonexistent') === false)
487 487
 				{
488 488
 					$suF[$box['MAILBOX']] = $box;
489 489
 				}
@@ -505,7 +505,7 @@  discard block
 block discarded – undo
505 505
 			$status = $this->status($mailbox);
506 506
 			foreach ($status as $key => $v)
507 507
 			{
508
-				$_status[strtoupper($key)]=$v;
508
+				$_status[strtoupper($key)] = $v;
509 509
 			}
510 510
 			return $_status;
511 511
 		}
@@ -523,9 +523,9 @@  discard block
 block discarded – undo
523 523
 	 * @param ignoreStatusCache bool ignore the cache used for counters
524 524
 	 * @return array with counters
525 525
 	 */
526
-	function getStatus($mailbox, $ignoreStatusCache=false)
526
+	function getStatus($mailbox, $ignoreStatusCache = false)
527 527
 	{
528
-		$mailboxes = $this->listMailboxes($mailbox,Horde_Imap_Client::MBOX_ALL,array(
528
+		$mailboxes = $this->listMailboxes($mailbox, Horde_Imap_Client::MBOX_ALL, array(
529 529
 				'attributes'=>true,
530 530
 				'children'=>true, //child info
531 531
 				'delimiter'=>true,
@@ -539,16 +539,16 @@  discard block
 block discarded – undo
539 539
 		//error_log(__METHOD__.__LINE__.array2string($mboxes->count()));
540 540
 		foreach ($mboxes->getIterator() as $k =>$box)
541 541
 		{
542
-			if ($k!='user' && $k != '' && $k==$mailbox)
542
+			if ($k != 'user' && $k != '' && $k == $mailbox)
543 543
 			{
544
-				if (stripos(array2string($box['attributes']),'\noselect')=== false)
544
+				if (stripos(array2string($box['attributes']), '\noselect') === false)
545 545
 				{
546 546
 					$status = $this->status($k, $flags);
547 547
 					foreach ($status as $key => $v)
548 548
 					{
549
-						$_status[strtoupper($key)]=$v;
549
+						$_status[strtoupper($key)] = $v;
550 550
 					}
551
-					$_status['HIERACHY_DELIMITER'] = $_status['delimiter'] = ($box['delimiter']?$box['delimiter']:$this->getDelimiter('personal'));
551
+					$_status['HIERACHY_DELIMITER'] = $_status['delimiter'] = ($box['delimiter'] ? $box['delimiter'] : $this->getDelimiter('personal'));
552 552
 					$_status['ATTRIBUTES'] = $box['attributes'];
553 553
 					//error_log(__METHOD__.__LINE__.$k.'->'.array2string($_status));
554 554
 					return $_status;
@@ -574,14 +574,14 @@  discard block
 block discarded – undo
574 574
 	 *
575 575
 	 * @return  mixed   array of mailboxes
576 576
 	 */
577
-	function getMailboxes($reference = ''  , $restriction_search = 0, $returnAttributes = false)
577
+	function getMailboxes($reference = '', $restriction_search = 0, $returnAttributes = false)
578 578
 	{
579
-		if ( is_bool($restriction_search) ){
580
-			$restriction_search = (int) $restriction_search;
579
+		if (is_bool($restriction_search)) {
580
+			$restriction_search = (int)$restriction_search;
581 581
 		}
582 582
 		$mailbox = '';
583
-		if ( is_int( $restriction_search ) ){
584
-			switch ( $restriction_search ) {
583
+		if (is_int($restriction_search)) {
584
+			switch ($restriction_search) {
585 585
 			case 0:
586 586
 				$searchstring = $reference."*";
587 587
 				break;
@@ -593,8 +593,8 @@  discard block
 block discarded – undo
593 593
 				$searchstring = $reference."%";
594 594
 				break;
595 595
 			}
596
-		}else{
597
-			if ( is_string( $restriction_search ) ){
596
+		} else {
597
+			if (is_string($restriction_search)) {
598 598
 				$mailbox = $searchstring = $restriction_search;
599 599
 			}
600 600
 		}
@@ -607,35 +607,35 @@  discard block
 block discarded – undo
607 607
 				'special_use'=>true,
608 608
 				'sort'=>true,
609 609
 			);
610
-		if ($returnAttributes==false)
610
+		if ($returnAttributes == false)
611 611
 		{
612 612
 			unset($options['attributes']);
613 613
 			unset($options['children']);
614 614
 			unset($options['special_use']);
615 615
 		}
616
-		$mailboxes = $this->listMailboxes($searchstring,Horde_Imap_Client::MBOX_ALL, $options);
616
+		$mailboxes = $this->listMailboxes($searchstring, Horde_Imap_Client::MBOX_ALL, $options);
617 617
 		//$mboxes = new Horde_Imap_Client_Mailbox_List($mailboxes);
618 618
 		//_debug_array($mboxes->count());
619 619
 		foreach ((array)$mailboxes as $k =>$box)
620 620
 		{
621 621
 			//error_log(__METHOD__.__LINE__.' Box:'.$k.'->'.array2string($box));
622
-			$ret[$k]=array('MAILBOX'=>$k,'ATTRIBUTES'=>$box['attributes'],'delimiter'=>($box['delimiter']?$box['delimiter']:$this->getDelimiter('personal')),'SUBSCRIBED'=>true);
622
+			$ret[$k] = array('MAILBOX'=>$k, 'ATTRIBUTES'=>$box['attributes'], 'delimiter'=>($box['delimiter'] ? $box['delimiter'] : $this->getDelimiter('personal')), 'SUBSCRIBED'=>true);
623 623
 		}
624 624
 		// for unknown reasons on ALL, UNSUBSCRIBED are not returned
625 625
 		//always fetch unsubscribed, think about only fetching it when $options['attributes'] is set
626 626
 		//but then allMailboxes are not all, ....
627 627
 		//if (!empty($mailbox) && !isset($ret[$mailbox]))
628 628
 		{
629
-			$unsub_mailboxes = $this->listMailboxes($searchstring,Horde_Imap_Client::MBOX_UNSUBSCRIBED, $options);
629
+			$unsub_mailboxes = $this->listMailboxes($searchstring, Horde_Imap_Client::MBOX_UNSUBSCRIBED, $options);
630 630
 			//$mboxes = new Horde_Imap_Client_Mailbox_List($mailboxes);
631 631
 			//_debug_array($mboxes->count());
632 632
 			//error_log(__METHOD__.__LINE__.' '.$mailbox.':'.count((array)$mailboxes).'->'.function_backtrace());
633 633
 			foreach ((array)$unsub_mailboxes as $k =>$box)
634 634
 			{
635 635
 				//error_log(__METHOD__.__LINE__.' Box:'.$k.' already In?'.array_key_exists($k,$boxexists).'->'.array2string($box));
636
-				if(!array_key_exists($k,$ret))
636
+				if (!array_key_exists($k, $ret))
637 637
 				{
638
-					$ret[$k]=array('MAILBOX'=>$k,'ATTRIBUTES'=>$box['attributes'],'delimiter'=>($box['delimiter']?$box['delimiter']:$this->getDelimiter('personal')),'SUBSCRIBED'=>false);
638
+					$ret[$k] = array('MAILBOX'=>$k, 'ATTRIBUTES'=>$box['attributes'], 'delimiter'=>($box['delimiter'] ? $box['delimiter'] : $this->getDelimiter('personal')), 'SUBSCRIBED'=>false);
639 639
 				}
640 640
 				else
641 641
 				{
@@ -658,14 +658,14 @@  discard block
 block discarded – undo
658 658
 	 *
659 659
 	 * @return  mixed   array of mailboxes
660 660
 	 */
661
-	function listSubscribedMailboxes($reference = ''  , $restriction_search = 0, $returnAttributes = false)
661
+	function listSubscribedMailboxes($reference = '', $restriction_search = 0, $returnAttributes = false)
662 662
 	{
663
-		if ( is_bool($restriction_search) ){
664
-			$restriction_search = (int) $restriction_search;
663
+		if (is_bool($restriction_search)) {
664
+			$restriction_search = (int)$restriction_search;
665 665
 		}
666 666
 		$mailbox = '';
667
-		if ( is_int( $restriction_search ) ){
668
-			switch ( $restriction_search ) {
667
+		if (is_int($restriction_search)) {
668
+			switch ($restriction_search) {
669 669
 			case 0:
670 670
 				$searchstring = $reference."*";
671 671
 				break;
@@ -677,8 +677,8 @@  discard block
 block discarded – undo
677 677
 				$searchstring = $reference."%";
678 678
 				break;
679 679
 			}
680
-		}else{
681
-			if ( is_string( $restriction_search ) ){
680
+		} else {
681
+			if (is_string($restriction_search)) {
682 682
 				$mailbox = $searchstring = $restriction_search;
683 683
 			}
684 684
 		}
@@ -690,25 +690,25 @@  discard block
 block discarded – undo
690 690
 				'special_use'=>true,
691 691
 				'sort'=>true,
692 692
 			);
693
-		if ($returnAttributes==false)
693
+		if ($returnAttributes == false)
694 694
 		{
695 695
 			unset($options['attributes']);
696 696
 			unset($options['children']);
697 697
 			unset($options['special_use']);
698 698
 		}
699
-		$mailboxes = $this->listMailboxes($searchstring,Horde_Imap_Client::MBOX_SUBSCRIBED_EXISTS, $options);
699
+		$mailboxes = $this->listMailboxes($searchstring, Horde_Imap_Client::MBOX_SUBSCRIBED_EXISTS, $options);
700 700
 		//$mboxes = new Horde_Imap_Client_Mailbox_List($mailboxes);
701 701
 		//_debug_array($mboxes->count());
702 702
 		foreach ((array)$mailboxes as $k =>$box)
703 703
 		{
704 704
 			//error_log(__METHOD__.__LINE__.' Searched for:'.$mailbox.' got Box:'.$k.'->'.array2string($box).function_backtrace());
705
-			if ($returnAttributes==false)
705
+			if ($returnAttributes == false)
706 706
 			{
707
-				$ret[]=$k;
707
+				$ret[] = $k;
708 708
 			}
709 709
 			else
710 710
 			{
711
-				$ret[$k]=array('MAILBOX'=>$k,'ATTRIBUTES'=>$box['attributes'],'delimiter'=>($box['delimiter']?$box['delimiter']:$this->getDelimiter('personal')),'SUBSCRIBED'=>true);
711
+				$ret[$k] = array('MAILBOX'=>$k, 'ATTRIBUTES'=>$box['attributes'], 'delimiter'=>($box['delimiter'] ? $box['delimiter'] : $this->getDelimiter('personal')), 'SUBSCRIBED'=>true);
712 712
 			}
713 713
 		}
714 714
 		return $ret;
@@ -724,14 +724,14 @@  discard block
 block discarded – undo
724 724
 	 *
725 725
 	 * @return  mixed   array of mailboxes
726 726
 	 */
727
-	function listUnSubscribedMailboxes($reference = ''  , $restriction_search = 0)
727
+	function listUnSubscribedMailboxes($reference = '', $restriction_search = 0)
728 728
 	{
729
-		if ( is_bool($restriction_search) ){
730
-			$restriction_search = (int) $restriction_search;
729
+		if (is_bool($restriction_search)) {
730
+			$restriction_search = (int)$restriction_search;
731 731
 		}
732 732
 
733
-		if ( is_int( $restriction_search ) ){
734
-			switch ( $restriction_search ) {
733
+		if (is_int($restriction_search)) {
734
+			switch ($restriction_search) {
735 735
 			case 0:
736 736
 				$mailbox = $reference."*";
737 737
 				break;
@@ -743,8 +743,8 @@  discard block
 block discarded – undo
743 743
 				$mailbox = "%";
744 744
 				break;
745 745
 			}
746
-		}else{
747
-			if ( is_string( $restriction_search ) ){
746
+		} else {
747
+			if (is_string($restriction_search)) {
748 748
 				$mailbox = $restriction_search;
749 749
 			}
750 750
 		}
@@ -753,17 +753,17 @@  discard block
 block discarded – undo
753 753
 			'sort'=>true,
754 754
 			//'flat'=>true,
755 755
 		);
756
-		$mailboxes = $this->listMailboxes($mailbox,Horde_Imap_Client::MBOX_SUBSCRIBED_EXISTS, $options);
756
+		$mailboxes = $this->listMailboxes($mailbox, Horde_Imap_Client::MBOX_SUBSCRIBED_EXISTS, $options);
757 757
 		foreach ($mailboxes as $box)
758 758
 		{
759 759
 			//error_log(__METHOD__.__LINE__.' Box:'.$k.'->'.array2string($box['mailbox']->utf8));
760
-			$sret[]=$box['mailbox']->utf8;
760
+			$sret[] = $box['mailbox']->utf8;
761 761
 		}
762
-		$unsubscribed = $this->listMailboxes($mailbox,Horde_Imap_Client::MBOX_UNSUBSCRIBED, $options);
762
+		$unsubscribed = $this->listMailboxes($mailbox, Horde_Imap_Client::MBOX_UNSUBSCRIBED, $options);
763 763
 		foreach ($unsubscribed as $box)
764 764
 		{
765 765
 			//error_log(__METHOD__.__LINE__.' Box:'.$k.'->'.array2string($box['mailbox']->utf8));
766
-			if (!in_array($box['mailbox']->utf8,$sret) && $box['mailbox']->utf8!='INBOX') $ret[]=$box['mailbox']->utf8;
766
+			if (!in_array($box['mailbox']->utf8, $sret) && $box['mailbox']->utf8 != 'INBOX') $ret[] = $box['mailbox']->utf8;
767 767
 		}
768 768
 		return $ret;
769 769
 	}
@@ -775,12 +775,12 @@  discard block
 block discarded – undo
775 775
 	 * @param int $flags =null default Horde_Imap_Client::STATUS_ALL | Horde_Imap_Client::STATUS_FLAGS | Horde_Imap_Client::STATUS_PERMFLAGS
776 776
 	 * @return array of counters for mailbox
777 777
 	 */
778
-	function examineMailbox($mailbox, $flags=null)
778
+	function examineMailbox($mailbox, $flags = null)
779 779
 	{
780
-		if ($mailbox=='') return false;
780
+		if ($mailbox == '') return false;
781 781
 		$mailboxes = $this->listMailboxes($mailbox);
782 782
 
783
-		if (is_null($flags)) $flags = Horde_Imap_Client::STATUS_ALL | Horde_Imap_Client::STATUS_FLAGS | Horde_Imap_Client::STATUS_PERMFLAGS;
783
+		if (is_null($flags)) $flags = Horde_Imap_Client::STATUS_ALL|Horde_Imap_Client::STATUS_FLAGS|Horde_Imap_Client::STATUS_PERMFLAGS;
784 784
 
785 785
 		$mboxes = new Horde_Imap_Client_Mailbox_List($mailboxes);
786 786
 		//_debug_array($mboxes->count());
@@ -788,18 +788,18 @@  discard block
 block discarded – undo
788 788
 		{
789 789
 			//error_log(__METHOD__.__LINE__.array2string($box));
790 790
 			unset($box);
791
-			if ($k!='user' && $k != '' && $k==$mailbox)
791
+			if ($k != 'user' && $k != '' && $k == $mailbox)
792 792
 			{
793 793
 				$status = $this->status($k, $flags);
794 794
 				//error_log(__METHOD__.__LINE__.array2string($status));
795 795
 				foreach ($status as $key => $v)
796 796
 				{
797
-					$_status[strtoupper($key)]=$v;
797
+					$_status[strtoupper($key)] = $v;
798 798
 				}
799
-				if ($flags & (Horde_Imap_Client::STATUS_FLAGS|Horde_Imap_Client::STATUS_PERMFLAGS))
799
+				if ($flags&(Horde_Imap_Client::STATUS_FLAGS|Horde_Imap_Client::STATUS_PERMFLAGS))
800 800
 				{
801 801
 					self::$supports_keywords[$this->ImapServerId] = stripos(implode('', $status['flags']), '$label') !== false ||
802
-						in_array('\\*', $status['permflags']);	// arbitrary keyswords also allow keywords
802
+						in_array('\\*', $status['permflags']); // arbitrary keyswords also allow keywords
803 803
 				}
804 804
 				return $_status;
805 805
 			}
@@ -838,7 +838,7 @@  discard block
 block discarded – undo
838 838
 	 */
839 839
 	function hasCapability($capability)
840 840
 	{
841
-		if ($capability=='SUPPORTS_KEYWORDS')
841
+		if ($capability == 'SUPPORTS_KEYWORDS')
842 842
 		{
843 843
 			// if pseudo-flag is not set, call examineMailbox now to set it (no STATUS_ALL = counters necessary)
844 844
 			if (!isset(self::$supports_keywords[$this->ImapServerId]))
@@ -850,7 +850,7 @@  discard block
 block discarded – undo
850 850
 				catch (\Exception $e)
851 851
 				{
852 852
 					error_log(__METHOD__.__LINE__.' (examineServer for detection) '.$capability.'->'.array2string(self::$supports_keywords).' failed '.function_backtrace());
853
-					self::$supports_keywords[$this->ImapServerId]=false;
853
+					self::$supports_keywords[$this->ImapServerId] = false;
854 854
 				}
855 855
 			}
856 856
 			//error_log(__METHOD__.__LINE__.' '.$capability.'->'.array2string(self::$supports_keywords).' '.function_backtrace());
@@ -900,9 +900,9 @@  discard block
 block discarded – undo
900 900
 	 */
901 901
 	static function getFolderPrefixFromNamespace($_nameSpace, $_folderName)
902 902
 	{
903
-		foreach($_nameSpace as &$singleNameSpace)
903
+		foreach ($_nameSpace as &$singleNameSpace)
904 904
 		{
905
-			if (substr($_folderName,0,strlen($singleNameSpace['prefix'])) == $singleNameSpace['prefix']) return $singleNameSpace['prefix'];
905
+			if (substr($_folderName, 0, strlen($singleNameSpace['prefix'])) == $singleNameSpace['prefix']) return $singleNameSpace['prefix'];
906 906
 		}
907 907
 		return "";
908 908
 	}
@@ -917,33 +917,33 @@  discard block
 block discarded – undo
917 917
 	 * @param string $reclevel = 0, counter to keep track of the current recursionlevel
918 918
 	 * @return array of mailboxes
919 919
 	 */
920
-	function getMailBoxesRecursive($_mailbox, $delimiter, $prefix, $reclevel=0)
920
+	function getMailBoxesRecursive($_mailbox, $delimiter, $prefix, $reclevel = 0)
921 921
 	{
922 922
 		if ($reclevel > 25) {
923
-			error_log( __METHOD__." Recursion Level Exeeded ($reclevel) while looking up $_mailbox$delimiter ");
923
+			error_log(__METHOD__." Recursion Level Exeeded ($reclevel) while looking up $_mailbox$delimiter ");
924 924
 			return array();
925 925
 		}
926 926
 		$reclevel++;
927 927
 		// clean up double delimiters
928
-		$mailbox = preg_replace('~'.($delimiter == '.' ? "\\".$delimiter:$delimiter).'+~s',$delimiter,$_mailbox);
928
+		$mailbox = preg_replace('~'.($delimiter == '.' ? "\\".$delimiter : $delimiter).'+~s', $delimiter, $_mailbox);
929 929
 		//get that mailbox in question
930
-		$mbx = $this->getMailboxes($mailbox,1,true);
930
+		$mbx = $this->getMailboxes($mailbox, 1, true);
931 931
 		$mbxkeys = array_keys($mbx);
932 932
 
933 933
 		// Example: Array([INBOX/GaGa] => Array([MAILBOX] => INBOX/GaGa[ATTRIBUTES] => Array([0] => \\unmarked)[delimiter] => /))
934
-		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"])))
934
+		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"])))
935 935
 		{
936
-			$buff = $this->getMailboxes($mbx[$mbxkeys[0]]['MAILBOX'].($mbx[$mbxkeys[0]]['MAILBOX'] == $prefix ? '':$delimiter),2,false);
936
+			$buff = $this->getMailboxes($mbx[$mbxkeys[0]]['MAILBOX'].($mbx[$mbxkeys[0]]['MAILBOX'] == $prefix ? '' : $delimiter), 2, false);
937 937
 			$allMailboxes = array();
938 938
 			foreach ($buff as $mbxname) {
939
-				$mbxname = preg_replace('~'.($delimiter == '.' ? "\\".$delimiter:$delimiter).'+~s',$delimiter,$mbxname['MAILBOX']);
939
+				$mbxname = preg_replace('~'.($delimiter == '.' ? "\\".$delimiter : $delimiter).'+~s', $delimiter, $mbxname['MAILBOX']);
940 940
 				#echo "About to recur in level $reclevel:".$mbxname."<br>";
941
-				if ( $mbxname != $mbx[$mbxkeys[0]]['MAILBOX'] && $mbxname != $prefix  && $mbxname != $mbx[$mbxkeys[0]]['MAILBOX'].$delimiter)
941
+				if ($mbxname != $mbx[$mbxkeys[0]]['MAILBOX'] && $mbxname != $prefix && $mbxname != $mbx[$mbxkeys[0]]['MAILBOX'].$delimiter)
942 942
 				{
943 943
 					$allMailboxes = array_merge($allMailboxes, self::getMailBoxesRecursive($mbxname, $delimiter, $prefix, $reclevel));
944 944
 				}
945 945
 			}
946
-			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'];
946
+			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'];
947 947
 			return $allMailboxes;
948 948
 		}
949 949
 		else
@@ -962,24 +962,24 @@  discard block
 block discarded – undo
962 962
 	 */
963 963
 	function getNameSpace()
964 964
 	{
965
-		static $nameSpace=null;
965
+		static $nameSpace = null;
966 966
 		$foldersNameSpace = array();
967 967
 		$delimiter = $this->getDelimiter();
968
-		if (empty($delimiter)) $delimiter='/';
968
+		if (empty($delimiter)) $delimiter = '/';
969 969
 		if (is_null($nameSpace)) $nameSpace = $this->getNameSpaceArray();
970 970
 		if (is_array($nameSpace)) {
971
-			foreach($nameSpace as $type => $singleNameSpaceArray)
971
+			foreach ($nameSpace as $type => $singleNameSpaceArray)
972 972
 			{
973 973
 				foreach ($singleNameSpaceArray as $singleNameSpace)
974 974
 				{
975 975
 					$_foldersNameSpace = array();
976
-					if($type == 'personal' && $singleNameSpace['name'] == '#mh/' && ($this->folderExists('Mail')||$this->folderExists('INBOX')))
976
+					if ($type == 'personal' && $singleNameSpace['name'] == '#mh/' && ($this->folderExists('Mail') || $this->folderExists('INBOX')))
977 977
 					{
978 978
 						$_foldersNameSpace['prefix_present'] = 'forced';
979 979
 						// uw-imap server with mailbox prefix or dovecot maybe
980
-						$_foldersNameSpace['prefix'] = ($this->folderExists('Mail')?'Mail':(!empty($singleNameSpace['name'])?$singleNameSpace['name']:''));
980
+						$_foldersNameSpace['prefix'] = ($this->folderExists('Mail') ? 'Mail' : (!empty($singleNameSpace['name']) ? $singleNameSpace['name'] : ''));
981 981
 					}
982
-					elseif($type == 'personal' && ($singleNameSpace['name'] == '#mh/') && $this->folderExists('mail'))
982
+					elseif ($type == 'personal' && ($singleNameSpace['name'] == '#mh/') && $this->folderExists('mail'))
983 983
 					{
984 984
 						$_foldersNameSpace['prefix_present'] = 'forced';
985 985
 						// uw-imap server with mailbox prefix or dovecot maybe
@@ -988,9 +988,9 @@  discard block
 block discarded – undo
988 988
 						$_foldersNameSpace['prefix_present'] = !empty($singleNameSpace['name']);
989 989
 						$_foldersNameSpace['prefix'] = $singleNameSpace['name'];
990 990
 					}
991
-					$_foldersNameSpace['delimiter'] = ($singleNameSpace['delimiter']?$singleNameSpace['delimiter']:$delimiter);
991
+					$_foldersNameSpace['delimiter'] = ($singleNameSpace['delimiter'] ? $singleNameSpace['delimiter'] : $delimiter);
992 992
 					$_foldersNameSpace['type'] = $type;
993
-					$foldersNameSpace[] =$_foldersNameSpace;
993
+					$foldersNameSpace[] = $_foldersNameSpace;
994 994
 				}
995 995
 			}
996 996
 		}
@@ -1002,29 +1002,29 @@  discard block
 block discarded – undo
1002 1002
 	 * @param mixed _type (1=personal, 2=user/other, 3=shared)
1003 1003
 	 * @return string the delimimiter
1004 1004
 	 */
1005
-	function getDelimiter($_type=1)
1005
+	function getDelimiter($_type = 1)
1006 1006
 	{
1007 1007
 		switch ($_type)
1008 1008
 		{
1009 1009
 			case 'user':
1010 1010
 			case 'other':
1011 1011
 			case 2:
1012
-				$type=2;
1012
+				$type = 2;
1013 1013
 				break;
1014 1014
 			case 'shared':
1015 1015
 			case '':
1016 1016
 			case 3:
1017
-				$type=3;
1017
+				$type = 3;
1018 1018
 				break;
1019 1019
 			case 'personal':
1020 1020
 			case 1:
1021 1021
 			default:
1022
-				$type=1;
1022
+				$type = 1;
1023 1023
 		}
1024 1024
 		$namespaces = $this->getNamespaces();
1025 1025
 		foreach ($namespaces as $nsp)
1026 1026
 		{
1027
-			if ($nsp['type']==$type && $nsp['delimiter']) return $nsp['delimiter'];
1027
+			if ($nsp['type'] == $type && $nsp['delimiter']) return $nsp['delimiter'];
1028 1028
 		}
1029 1029
 		return "/";
1030 1030
 	}
@@ -1052,7 +1052,7 @@  discard block
 block discarded – undo
1052 1052
 	{
1053 1053
 		if (is_numeric($_username))
1054 1054
 		{
1055
-			$_username = $GLOBALS['egw']->accounts->id2name($accountID=$_username);
1055
+			$_username = $GLOBALS['egw']->accounts->id2name($accountID = $_username);
1056 1056
 		}
1057 1057
 		else
1058 1058
 		{
@@ -1061,7 +1061,7 @@  discard block
 block discarded – undo
1061 1061
 		switch ($this->loginType)
1062 1062
 		{
1063 1063
 			case 'email':
1064
-				$_username = $GLOBALS['egw']->accounts->id2name($accountID,'account_email');
1064
+				$_username = $GLOBALS['egw']->accounts->id2name($accountID, 'account_email');
1065 1065
 				break;
1066 1066
 
1067 1067
 			case 'vmailmgr':
@@ -1076,8 +1076,8 @@  discard block
 block discarded – undo
1076 1076
 				if (empty($this->loginType))
1077 1077
 				{
1078 1078
 					// try to figure out by params['acc_imap_username']
1079
-					list($lusername,$domain) = explode('@',$this->params['acc_imap_username'],2);
1080
-					if (strpos($_username,'@')===false && !empty($domain) && !empty($lusername))
1079
+					list($lusername, $domain) = explode('@', $this->params['acc_imap_username'], 2);
1080
+					if (strpos($_username, '@') === false && !empty($domain) && !empty($lusername))
1081 1081
 					{
1082 1082
 						$_username = $_username.'@'.$domain;
1083 1083
 					}
@@ -1116,20 +1116,20 @@  discard block
 block discarded – undo
1116 1116
 	 * @param string $_folderName=''
1117 1117
 	 * @return string utf-7 encoded (done in getMailboxName)
1118 1118
 	 */
1119
-	function getUserMailboxString($_username, $_folderName='')
1119
+	function getUserMailboxString($_username, $_folderName = '')
1120 1120
 	{
1121 1121
 		$nameSpaces = $this->getNameSpaceArray();
1122 1122
 
1123
-		if(!isset($nameSpaces['others'])) {
1123
+		if (!isset($nameSpaces['others'])) {
1124 1124
 			return false;
1125 1125
 		}
1126 1126
 
1127 1127
 		$username = $this->getMailBoxUserName($_username);
1128
-		if($this->loginType == 'vmailmgr' || $this->loginType == 'uidNumber') {
1129
-			$username .= '@'. $this->domainName;
1128
+		if ($this->loginType == 'vmailmgr' || $this->loginType == 'uidNumber') {
1129
+			$username .= '@'.$this->domainName;
1130 1130
 		}
1131 1131
 
1132
-		$mailboxString = $nameSpaces['others'][0]['name'] . $username . (!empty($_folderName) ? ($nameSpaces['others'][0]['delimiter']?$nameSpaces['others'][0]['delimiter']:'/') . $_folderName : '');
1132
+		$mailboxString = $nameSpaces['others'][0]['name'].$username.(!empty($_folderName) ? ($nameSpaces['others'][0]['delimiter'] ? $nameSpaces['others'][0]['delimiter'] : '/').$_folderName : '');
1133 1133
 
1134 1134
 		return $mailboxString;
1135 1135
 	}
@@ -1148,7 +1148,7 @@  discard block
 block discarded – undo
1148 1148
 		);
1149 1149
 		//error_log(__METHOD__.__LINE__.array2string($types));
1150 1150
 		$result = array();
1151
-		foreach($this->getNamespaces() as $data)
1151
+		foreach ($this->getNamespaces() as $data)
1152 1152
 		{
1153 1153
 			//error_log(__METHOD__.__LINE__.array2string($data));
1154 1154
 			if (isset($types[$data['type']]))
@@ -1158,7 +1158,7 @@  discard block
 block discarded – undo
1158 1158
 					'name' => $data['name'],
1159 1159
 					'prefix' => $data['name'],
1160 1160
 					'prefix_present' => !empty($data['name']),
1161
-					'delimiter' => ($data['delimiter']?$data['delimiter']:'/'),
1161
+					'delimiter' => ($data['delimiter'] ? $data['delimiter'] : '/'),
1162 1162
 				);
1163 1163
 			}
1164 1164
 		}
@@ -1179,7 +1179,7 @@  discard block
 block discarded – undo
1179 1179
 		{
1180 1180
 			if ($qInfo['storage'])
1181 1181
 			{
1182
-				return array('USED'=>$qInfo['storage']['usage'],'QMAX'=>$qInfo['storage']['limit']);
1182
+				return array('USED'=>$qInfo['storage']['usage'], 'QMAX'=>$qInfo['storage']['limit']);
1183 1183
 			}
1184 1184
 		}
1185 1185
 		return false;
@@ -1193,7 +1193,7 @@  discard block
 block discarded – undo
1193 1193
 	 * @param string $_what - what to retrieve either limit/QMAX, usage/USED or ALL is supported
1194 1194
 	 * @return int|array|boolean the quota for specified user (by what) or array with values for "limit" and "usage", or false
1195 1195
 	 */
1196
-	function getQuotaByUser($_username, $_what='QMAX')
1196
+	function getQuotaByUser($_username, $_what = 'QMAX')
1197 1197
 	{
1198 1198
 		$mailboxName = $this->getUserMailboxString($_username);
1199 1199
 		$storageQuota = $this->getQuotaRoot($mailboxName);
@@ -1202,7 +1202,7 @@  discard block
 block discarded – undo
1202 1202
 		if (is_array($storageQuota) && isset($storageQuota[$mailboxName]) && is_array($storageQuota[$mailboxName]) &&
1203 1203
 			isset($storageQuota[$mailboxName]['storage']) && is_array($storageQuota[$mailboxName]['storage']))
1204 1204
 		{
1205
-			switch($_what)
1205
+			switch ($_what)
1206 1206
 			{
1207 1207
 				case 'QMAX':
1208 1208
 					$_what = 'limit';
@@ -1228,7 +1228,7 @@  discard block
 block discarded – undo
1228 1228
 	 */
1229 1229
 	function getUserData($_username)
1230 1230
 	{
1231
-		unset($_username);	// not used
1231
+		unset($_username); // not used
1232 1232
 		return array();
1233 1233
 	}
1234 1234
 
@@ -1241,7 +1241,7 @@  discard block
 block discarded – undo
1241 1241
 	 */
1242 1242
 	function setUserData($_username, $_quota)
1243 1243
 	{
1244
-		unset($_username, $_quota);	// not used
1244
+		unset($_username, $_quota); // not used
1245 1245
 		return true;
1246 1246
 	}
1247 1247
 
@@ -1275,10 +1275,10 @@  discard block
 block discarded – undo
1275 1275
 	 * @param array $params
1276 1276
 	 * @throws Api\Exception\WrongParameter
1277 1277
 	 */
1278
-	public function __call($name,array $params=null)
1278
+	public function __call($name, array $params = null)
1279 1279
 	{
1280 1280
 		if ($this->debug) error_log(__METHOD__.'->'.$name.' with params:'.array2string($params));
1281
-		switch($name)
1281
+		switch ($name)
1282 1282
 		{
1283 1283
 			case 'installScript':
1284 1284
 			case 'getScript':
@@ -1293,9 +1293,9 @@  discard block
 block discarded – undo
1293 1293
 				if (is_null($this->sieve))
1294 1294
 				{
1295 1295
 					$this->sieve = new Sieve($this);
1296
-					$this->error =& $this->sieve->error;
1296
+					$this->error = & $this->sieve->error;
1297 1297
 				}
1298
-				$ret = call_user_func_array(array($this->sieve,$name),$params);
1298
+				$ret = call_user_func_array(array($this->sieve, $name), $params);
1299 1299
 				//error_log(__CLASS__.'->'.$name.'('.array2string($params).') returns '.array2string($ret));
1300 1300
 				return $ret;
1301 1301
 		}
@@ -1310,7 +1310,7 @@  discard block
 block discarded – undo
1310 1310
 	 * @param string $_scriptName =null
1311 1311
 	 * @return boolean
1312 1312
 	 */
1313
-	public function setVacationUser($_euser, array $_vacation, $_scriptName=null)
1313
+	public function setVacationUser($_euser, array $_vacation, $_scriptName = null)
1314 1314
 	{
1315 1315
 		if ($this->debug) error_log(__METHOD__.' User:'.array2string($_euser).' Scriptname:'.array2string($_scriptName).' VacationMessage:'.array2string($_vacation));
1316 1316
 
@@ -1322,8 +1322,8 @@  discard block
 block discarded – undo
1322 1322
 		{
1323 1323
 			$this->adminConnection($_euser);
1324 1324
 			$this->sieve = new Sieve($this, $_euser, $_scriptName);
1325
-			$this->scriptName =& $this->sieve->scriptName;
1326
-			$this->error =& $this->sieve->error;
1325
+			$this->scriptName = & $this->sieve->scriptName;
1326
+			$this->error = & $this->sieve->error;
1327 1327
 		}
1328 1328
 		$ret = $this->setVacation($_vacation, $_scriptName);
1329 1329
 
@@ -1338,7 +1338,7 @@  discard block
 block discarded – undo
1338 1338
 	 * @throws Exception on connection error or authentication failure
1339 1339
 	 * @return array
1340 1340
 	 */
1341
-	public function getVacationUser($_euser, $_scriptName=null)
1341
+	public function getVacationUser($_euser, $_scriptName = null)
1342 1342
 	{
1343 1343
 		if ($this->debug) error_log(__METHOD__.' User:'.array2string($_euser));
1344 1344
 
@@ -1350,8 +1350,8 @@  discard block
 block discarded – undo
1350 1350
 		{
1351 1351
 			$this->adminConnection($_euser);
1352 1352
 			$this->sieve = new Sieve($this, $_euser, $_scriptName);
1353
-			$this->error =& $this->sieve->error;
1354
-			$this->scriptName =& $this->sieve->scriptName;
1353
+			$this->error = & $this->sieve->error;
1354
+			$this->scriptName = & $this->sieve->scriptName;
1355 1355
 		}
1356 1356
 		return $this->sieve->getVacation();
1357 1357
 	}
@@ -1371,7 +1371,7 @@  discard block
 block discarded – undo
1371 1371
 	 */
1372 1372
 	public static function init_static()
1373 1373
 	{
1374
-		self::$supports_keywords =& Api\Cache::getSession (__CLASS__, 'supports_keywords');
1374
+		self::$supports_keywords = & Api\Cache::getSession(__CLASS__, 'supports_keywords');
1375 1375
 	}
1376 1376
 }
1377 1377
 Imap::init_static();
Please login to merge, or discard this patch.