Passed
Push — 17.1 ( 431f3f...4dae72 )
by Ralf
01:23 queued 12s
created
api/src/Db/Exception.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -27,10 +27,10 @@
 block discarded – undo
27 27
 	 * @param string $msg =null message, default "Database error!"
28 28
 	 * @param int $code =100
29 29
 	 */
30
-	function __construct($msg=null,$code=100)
30
+	function __construct($msg = null, $code = 100)
31 31
 	{
32 32
 		if (is_null($msg)) $msg = lang('Database error!');
33 33
 
34
-		parent::__construct($msg,$code);
34
+		parent::__construct($msg, $code);
35 35
 	}
36 36
 }
Please login to merge, or discard this patch.
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,7 +29,10 @@
 block discarded – undo
29 29
 	 */
30 30
 	function __construct($msg=null,$code=100)
31 31
 	{
32
-		if (is_null($msg)) $msg = lang('Database error!');
32
+		if (is_null($msg))
33
+		{
34
+			$msg = lang('Database error!');
35
+		}
33 36
 
34 37
 		parent::__construct($msg,$code);
35 38
 	}
Please login to merge, or discard this patch.
api/src/Egw/Base.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -64,12 +64,12 @@  discard block
 block discarded – undo
64 64
 	 */
65 65
 	static $sub_objects = array(
66 66
 		'log' => 'errorlog',
67
-		'link' => 'bolink',		// depricated use static egw_link methods
67
+		'link' => 'bolink', // depricated use static egw_link methods
68 68
 		'datetime' => 'egw_datetime',
69 69
 		// classes moved to new api dir
70 70
 		'template' => true,
71 71
 		'applications' => 'EGroupware\\Api\\Egw\\Applications',
72
-		'framework' => true,	// special handling in __get()
72
+		'framework' => true, // special handling in __get()
73 73
 		'ldap' => true,
74 74
 	);
75 75
 
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 	{
96 96
 		//error_log(__METHOD__."($name)".function_backtrace());
97 97
 
98
-		if ($name == 'js') $name = 'framework';	// javascript class is integrated now into framework
98
+		if ($name == 'js') $name = 'framework'; // javascript class is integrated now into framework
99 99
 
100 100
 		if (isset($this->$name))
101 101
 		{
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 			if ($name != 'ADOdb') error_log(__METHOD__.": There's NO $name object! ".function_backtrace());
108 108
 			return null;
109 109
 		}
110
-		switch($name)
110
+		switch ($name)
111 111
 		{
112 112
 			case 'framework':
113 113
 				return $this->framework = Api\Framework::factory();
Please login to merge, or discard this patch.
Braces   +13 added lines, -3 removed lines patch added patch discarded remove patch
@@ -95,7 +95,11 @@  discard block
 block discarded – undo
95 95
 	{
96 96
 		//error_log(__METHOD__."($name)".function_backtrace());
97 97
 
98
-		if ($name == 'js') $name = 'framework';	// javascript class is integrated now into framework
98
+		if ($name == 'js')
99
+		{
100
+			$name = 'framework';
101
+		}
102
+		// javascript class is integrated now into framework
99 103
 
100 104
 		if (isset($this->$name))
101 105
 		{
@@ -104,7 +108,10 @@  discard block
 block discarded – undo
104 108
 
105 109
 		if (!isset(self::$sub_objects[$name]) && !class_exists('EGroupware\\Api\\'.ucfirst($name)) && !class_exists($name))
106 110
 		{
107
-			if ($name != 'ADOdb') error_log(__METHOD__.": There's NO $name object! ".function_backtrace());
111
+			if ($name != 'ADOdb')
112
+			{
113
+				error_log(__METHOD__.": There's NO $name object! ".function_backtrace());
114
+			}
108 115
 			return null;
109 116
 		}
110 117
 		switch($name)
@@ -121,7 +128,10 @@  discard block
 block discarded – undo
121 128
 				return $this->ldap = Api\Ldap::factory(false);
122 129
 			default:
123 130
 				$class = isset(self::$sub_objects[$name]) ? self::$sub_objects[$name] : 'EGroupware\\Api\\'.ucfirst($name);
124
-				if (!class_exists($class)) $class = $name;
131
+				if (!class_exists($class))
132
+				{
133
+					$class = $name;
134
+				}
125 135
 				break;
126 136
 		}
127 137
 		return $this->$name = new $class();
Please login to merge, or discard this patch.
api/src/Contacts/Univention.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@
 block discarded – undo
35 35
 	 * @param array $keys if given $keys are copied to data before saveing => allows a save as
36 36
 	 * @return int 0 on success and errno != 0 else
37 37
 	 */
38
-	function save($keys=null)
38
+	function save($keys = null)
39 39
 	{
40 40
 		// UCS lowercases email when storing
41 41
 		$keys['email'] = strtolower(!empty($keys['email']) ? $keys['email'] : $this->data['email']);
Please login to merge, or discard this patch.
api/src/Contacts/Ldap.php 4 patches
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -41,33 +41,33 @@  discard block
 block discarded – undo
41 41
 	var $contacts_id='id';
42 42
 
43 43
 	/**
44
-	* @var string $accountName holds the accountname of the current user
45
-	*/
44
+	 * @var string $accountName holds the accountname of the current user
45
+	 */
46 46
 	var $accountName;
47 47
 
48 48
 	/**
49
-	* @var object $ldapServerInfo holds the information about the current used ldap server
50
-	*/
49
+	 * @var object $ldapServerInfo holds the information about the current used ldap server
50
+	 */
51 51
 	var $ldapServerInfo;
52 52
 
53 53
 	/**
54
-	* @var int $ldapLimit how many rows to fetch from ldap server
55
-	*/
54
+	 * @var int $ldapLimit how many rows to fetch from ldap server
55
+	 */
56 56
 	var $ldapLimit = 2000;
57 57
 
58 58
 	/**
59
-	* @var string $personalContactsDN holds the base DN for the personal addressbooks
60
-	*/
59
+	 * @var string $personalContactsDN holds the base DN for the personal addressbooks
60
+	 */
61 61
 	var $personalContactsDN;
62 62
 
63 63
 	/**
64
-	* @var string $sharedContactsDN holds the base DN for the shared addressbooks
65
-	*/
64
+	 * @var string $sharedContactsDN holds the base DN for the shared addressbooks
65
+	 */
66 66
 	var $sharedContactsDN;
67 67
 
68 68
 	/**
69
-	* @var string $accountContactsDN holds the base DN for accounts addressbook
70
-	*/
69
+	 * @var string $accountContactsDN holds the base DN for accounts addressbook
70
+	 */
71 71
 	var $accountContactsDN;
72 72
 
73 73
 	/**
@@ -77,8 +77,8 @@  discard block
 block discarded – undo
77 77
 	var $accountsFilter = '(objectclass=posixaccount)';
78 78
 
79 79
 	/**
80
-	* @var string $allContactsDN holds the base DN of all addressbook
81
-	*/
80
+	 * @var string $allContactsDN holds the base DN of all addressbook
81
+	 */
82 82
 	var $allContactsDN;
83 83
 
84 84
 	/**
@@ -96,8 +96,8 @@  discard block
 block discarded – undo
96 96
 	var $never_change_dn = false;
97 97
 
98 98
 	/**
99
-	* @var int $total holds the total count of found rows
100
-	*/
99
+	 * @var int $total holds the total count of found rows
100
+	 */
101 101
 	var $total;
102 102
 
103 103
 	/**
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
 	 *
404 404
 	 * @param string|array $contact_id contact_id or array with values for id or account_id
405 405
 	 * @return array/boolean data if row could be retrived else False
406
-	*/
406
+	 */
407 407
 	function read($contact_id)
408 408
 	{
409 409
 		if (is_array($contact_id) && isset($contact_id['account_id']) ||
Please login to merge, or discard this patch.
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -213,7 +213,6 @@
 block discarded – undo
213 213
 	/**
214 214
 	 * Remove attributes we are not allowed to update
215 215
 	 *
216
-	 * @param array $attributes
217 216
 	 */
218 217
 	function sanitize_update(array &$ldapContact)
219 218
 	{
Please login to merge, or discard this patch.
Spacing   +183 added lines, -185 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 	 *
39 39
 	 * @var string
40 40
 	 */
41
-	var $contacts_id='id';
41
+	var $contacts_id = 'id';
42 42
 
43 43
 	/**
44 44
 	* @var string $accountName holds the accountname of the current user
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 	 *
87 87
 	 * @var string
88 88
 	 */
89
-	var $dn_attribute='uid';
89
+	var $dn_attribute = 'uid';
90 90
 
91 91
 	/**
92 92
 	 * Do NOT attempt to change DN (dn-attribute can NOT be part of schemas used in addressbook!)
@@ -113,9 +113,9 @@  discard block
 block discarded – undo
113 113
 	 * minimum: $this->columns_to_search = array('n_family','n_given','org_name','email');
114 114
 	 */
115 115
 	var $search_attributes = array(
116
-		'n_family','n_middle','n_given','org_name','org_unit',
117
-		'adr_one_locality','adr_two_locality','note',
118
-		'email','mozillasecondemail','uidnumber',
116
+		'n_family', 'n_middle', 'n_given', 'org_name', 'org_unit',
117
+		'adr_one_locality', 'adr_two_locality', 'note',
118
+		'email', 'mozillasecondemail', 'uidnumber',
119 119
 	);
120 120
 
121 121
 	/**
@@ -171,8 +171,8 @@  discard block
 block discarded – undo
171 171
 		#postOfficeBox
172 172
 		'mozillaabpersonalpha' => array(
173 173
 			'adr_one_street2'	=> 'mozillaworkstreet2',
174
-			'adr_one_countryname'	=> 'c',	// 2 letter country code
175
-			'adr_one_countrycode'	=> 'c',	// 2 letter country code
174
+			'adr_one_countryname'	=> 'c', // 2 letter country code
175
+			'adr_one_countrycode'	=> 'c', // 2 letter country code
176 176
 			'adr_two_street'	=> 'mozillahomestreet',
177 177
 			'adr_two_street2'	=> 'mozillahomestreet2',
178 178
 			'adr_two_locality'	=> 'mozillahomelocalityname',
@@ -186,8 +186,8 @@  discard block
 block discarded – undo
186 186
 		// similar to the newer mozillaAbPerson, but uses mozillaPostalAddress2 instead of mozillaStreet2
187 187
 		'mozillaorgperson' => array(
188 188
 			'adr_one_street2'	=> 'mozillapostaladdress2',
189
-			'adr_one_countrycode'	=> 'c',	// 2 letter country code
190
-			'adr_one_countryname'	=> 'co',	// human readable country name, must be after 'c' to take precedence on read!
189
+			'adr_one_countrycode'	=> 'c', // 2 letter country code
190
+			'adr_one_countryname'	=> 'co', // human readable country name, must be after 'c' to take precedence on read!
191 191
 			'adr_two_street'	=> 'mozillahomestreet',
192 192
 			'adr_two_street2'	=> 'mozillahomepostaladdress2',
193 193
 			'adr_two_locality'	=> 'mozillahomelocalityname',
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
 			'note'			=> 'note',
214 214
 			'tel_car'		=> 'carphone',
215 215
 			'tel_prefer'	=> 'primaryphone',
216
-			'cat_id'		=> 'category',	// special handling in _egw2evolutionperson method
216
+			'cat_id'		=> 'category', // special handling in _egw2evolutionperson method
217 217
 			'role'			=> 'businessrole',
218 218
 			'tel_assistent'	=> 'assistantphone',
219 219
 			'assistent'		=> 'assistantname',
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 			'freebusy_uri'	=> 'freeBusyuri',
223 223
 			'calendar_uri'	=> 'calendaruri',
224 224
 			'tel_other'		=> 'otherphone',
225
-			'tel_cell_private' => 'callbackphone',	// not the best choice, but better then nothing
225
+			'tel_cell_private' => 'callbackphone', // not the best choice, but better then nothing
226 226
 		),
227 227
 		// additional schema can be added here, including special functions
228 228
 
@@ -270,10 +270,10 @@  discard block
 block discarded – undo
270 270
 	 * @param array $ldap_config =null default use from $GLOBALS['egw_info']['server']
271 271
 	 * @param resource $ds =null ldap connection to use
272 272
 	 */
273
-	function __construct(array $ldap_config=null, $ds=null)
273
+	function __construct(array $ldap_config = null, $ds = null)
274 274
 	{
275 275
 		//$this->db_data_cols 	= $this->stock_contact_fields + $this->non_contact_fields;
276
-		$this->accountName 		= $GLOBALS['egw_info']['user']['account_lid'];
276
+		$this->accountName = $GLOBALS['egw_info']['user']['account_lid'];
277 277
 
278 278
 		if ($ldap_config)
279 279
 		{
@@ -281,12 +281,12 @@  discard block
 block discarded – undo
281 281
 		}
282 282
 		else
283 283
 		{
284
-			$this->ldap_config =& $GLOBALS['egw_info']['server'];
284
+			$this->ldap_config = & $GLOBALS['egw_info']['server'];
285 285
 		}
286 286
 		$this->accountContactsDN	= $this->ldap_config['ldap_context'];
287
-		$this->allContactsDN		= $this->ldap_config['ldap_contact_context'];
288
-		$this->personalContactsDN	= 'ou=personal,ou=contacts,'. $this->allContactsDN;
289
-		$this->sharedContactsDN		= 'ou=shared,ou=contacts,'. $this->allContactsDN;
287
+		$this->allContactsDN = $this->ldap_config['ldap_contact_context'];
288
+		$this->personalContactsDN = 'ou=personal,ou=contacts,'.$this->allContactsDN;
289
+		$this->sharedContactsDN		= 'ou=shared,ou=contacts,'.$this->allContactsDN;
290 290
 
291 291
 		if ($ds)
292 292
 		{
@@ -298,9 +298,9 @@  discard block
 block discarded – undo
298 298
 		}
299 299
 		$this->ldapServerInfo = $GLOBALS['egw']->ldap->getLDAPServerInfo($this->ldap_config['ldap_contact_host']);
300 300
 
301
-		foreach($this->schema2egw as $attributes)
301
+		foreach ($this->schema2egw as $attributes)
302 302
 		{
303
-			$this->all_attributes = array_merge($this->all_attributes,array_values($attributes));
303
+			$this->all_attributes = array_merge($this->all_attributes, array_values($attributes));
304 304
 		}
305 305
 		$this->all_attributes = array_values(array_unique($this->all_attributes));
306 306
 
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
 			$this->ds = Api\Ldap::factory();
328 328
 		}
329 329
 		// if ldap is NOT the contact repository, we only do accounts and need to use the account-data
330
-		elseif (substr($GLOBALS['egw_info']['server']['contact_repository'],-4) != 'ldap')	// not (ldap or sql-ldap)
330
+		elseif (substr($GLOBALS['egw_info']['server']['contact_repository'], -4) != 'ldap')	// not (ldap or sql-ldap)
331 331
 		{
332 332
 			$this->ldap_config['ldap_contact_host'] = $this->ldap_config['ldap_host'];
333 333
 			$this->allContactsDN = $this->ldap_config['ldap_context'];
@@ -351,17 +351,17 @@  discard block
 block discarded – undo
351 351
 	function supported_fields()
352 352
 	{
353 353
 		$fields = array(
354
-			'id','tid','owner',
355
-			'n_middle','n_prefix','n_suffix',	// stored in the cn
356
-			'created','modified',				// automatic timestamps
357
-			'creator','modifier',				// automatic for non accounts
358
-			'private',							// true for personal addressbooks, false otherwise
354
+			'id', 'tid', 'owner',
355
+			'n_middle', 'n_prefix', 'n_suffix', // stored in the cn
356
+			'created', 'modified', // automatic timestamps
357
+			'creator', 'modifier', // automatic for non accounts
358
+			'private', // true for personal addressbooks, false otherwise
359 359
 		);
360
-		foreach($this->schema2egw as $objectclass => $mapping)
360
+		foreach ($this->schema2egw as $objectclass => $mapping)
361 361
 		{
362
-			if($this->ldapServerInfo->supportsObjectClass($objectclass))
362
+			if ($this->ldapServerInfo->supportsObjectClass($objectclass))
363 363
 			{
364
-				$fields = array_merge($fields,array_keys($mapping));
364
+				$fields = array_merge($fields, array_keys($mapping));
365 365
 			}
366 366
 		}
367 367
 		return array_values(array_unique($fields));
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
 			return $this->id_filter(is_array($ids) ? array_shift($ids) : $ids);
392 392
 		}
393 393
 		$filter = array();
394
-		foreach($ids as $id)
394
+		foreach ($ids as $id)
395 395
 		{
396 396
 			$filter[] = $this->id_filter($id);
397 397
 		}
@@ -407,9 +407,9 @@  discard block
 block discarded – undo
407 407
 	function read($contact_id)
408 408
 	{
409 409
 		if (is_array($contact_id) && isset($contact_id['account_id']) ||
410
-			!is_array($contact_id) && substr($contact_id,0,8) == 'account:')
410
+			!is_array($contact_id) && substr($contact_id, 0, 8) == 'account:')
411 411
 		{
412
-			$filter = 'uidNumber='.(int)(is_array($contact_id) ? $contact_id['account_id'] : substr($contact_id,8));
412
+			$filter = 'uidNumber='.(int)(is_array($contact_id) ? $contact_id['account_id'] : substr($contact_id, 8));
413 413
 		}
414 414
 		else
415 415
 		{
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
 		// never allow to change the uidNumber (account_id) on update, as it could be misused by eg. xmlrpc or syncml
433 433
 		unset($ldapContact['uidnumber']);
434 434
 
435
-		unset($ldapContact['entryuuid']);	// not allowed to modify that, no need either
435
+		unset($ldapContact['entryuuid']); // not allowed to modify that, no need either
436 436
 
437 437
 		unset($ldapContact['objectClass']);
438 438
 	}
@@ -443,28 +443,28 @@  discard block
 block discarded – undo
443 443
 	 * @param array $keys if given $keys are copied to data before saveing => allows a save as
444 444
 	 * @return int 0 on success and errno != 0 else
445 445
 	 */
446
-	function save($keys=null)
446
+	function save($keys = null)
447 447
 	{
448 448
 		//error_log(__METHOD__."(".array2string($keys).") this->data=".array2string($this->data));
449
-		if(is_array($keys))
449
+		if (is_array($keys))
450 450
 		{
451
-			$this->data = is_array($this->data) ? array_merge($this->data,$keys) : $keys;
451
+			$this->data = is_array($this->data) ? array_merge($this->data, $keys) : $keys;
452 452
 		}
453 453
 
454
-		$data =& $this->data;
454
+		$data = & $this->data;
455 455
 		$isUpdate = false;
456 456
 		$ldapContact = array();
457 457
 
458 458
 		// generate addressbook dn
459
-		if((int)$data['owner'])
459
+		if ((int)$data['owner'])
460 460
 		{
461 461
 			// group address book
462
-			if(!($cn = strtolower($GLOBALS['egw']->accounts->id2name((int)$data['owner']))))
462
+			if (!($cn = strtolower($GLOBALS['egw']->accounts->id2name((int)$data['owner']))))
463 463
 			{
464 464
 				error_log('Unknown owner');
465 465
 				return true;
466 466
 			}
467
-			$baseDN = 'cn='. $cn .','.($data['owner'] < 0 ? $this->sharedContactsDN : $this->personalContactsDN);
467
+			$baseDN = 'cn='.$cn.','.($data['owner'] < 0 ? $this->sharedContactsDN : $this->personalContactsDN);
468 468
 		}
469 469
 		// only an admin or the user itself is allowed to change the data of an account
470 470
 		elseif ($data['account_id'] && ($GLOBALS['egw_info']['user']['apps']['admin'] ||
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
 		{
473 473
 			// account
474 474
 			$baseDN = $this->accountContactsDN;
475
-			$cn	= false;
475
+			$cn = false;
476 476
 			// we need an admin connection
477 477
 			$this->connect(true);
478 478
 
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
 		else
486 486
 		{
487 487
 			error_log("Permission denied, to write: data[owner]=$data[owner], data[account_id]=$data[account_id], account_id=".$GLOBALS['egw_info']['user']['account_id']);
488
-			return lang('Permission denied !!!');	// only admin or the user itself is allowd to write accounts!
488
+			return lang('Permission denied !!!'); // only admin or the user itself is allowd to write accounts!
489 489
 		}
490 490
 		// check if $baseDN exists. If not create it
491 491
 		if (($err = $this->_check_create_dn($baseDN)))
@@ -494,55 +494,54 @@  discard block
 block discarded – undo
494 494
 		}
495 495
 		// check the existing objectclasses of an entry, none = array() for new ones
496 496
 		$oldObjectclasses = array();
497
-		$attributes = array('dn','cn','objectClass',$this->dn_attribute,'mail');
497
+		$attributes = array('dn', 'cn', 'objectClass', $this->dn_attribute, 'mail');
498 498
 
499 499
 		$contactUID	= $this->data[$this->contacts_id];
500 500
 		if (!empty($contactUID) &&
501
-			($result = ldap_search($this->ds, $base=$this->allContactsDN, $this->id_filter($contactUID), $attributes)) &&
501
+			($result = ldap_search($this->ds, $base = $this->allContactsDN, $this->id_filter($contactUID), $attributes)) &&
502 502
 			($oldContactInfo = ldap_get_entries($this->ds, $result)) && $oldContactInfo['count'])
503 503
 		{
504 504
 			unset($oldContactInfo[0]['objectclass']['count']);
505
-			foreach($oldContactInfo[0]['objectclass'] as $objectclass)
505
+			foreach ($oldContactInfo[0]['objectclass'] as $objectclass)
506 506
 			{
507
-				$oldObjectclasses[]	= strtolower($objectclass);
507
+				$oldObjectclasses[] = strtolower($objectclass);
508 508
 			}
509 509
 		   	$isUpdate = true;
510 510
 		}
511 511
 
512
-		if(empty($contactUID))
512
+		if (empty($contactUID))
513 513
 		{
514 514
 			$ldapContact[$this->dn_attribute] = $this->data[$this->contacts_id] = $contactUID = md5(Api\Auth::randomstring(15));
515 515
 		}
516 516
 		//error_log(__METHOD__."() contactUID='$contactUID', isUpdate=".array2string($isUpdate).", oldContactInfo=".array2string($oldContactInfo));
517 517
 		// add for all supported objectclasses the objectclass and it's attributes
518
-		foreach($this->schema2egw as $objectclass => $mapping)
518
+		foreach ($this->schema2egw as $objectclass => $mapping)
519 519
 		{
520
-			if(!$this->ldapServerInfo->supportsObjectClass($objectclass)) continue;
520
+			if (!$this->ldapServerInfo->supportsObjectClass($objectclass)) continue;
521 521
 
522
-			if($objectclass != 'posixaccount' && !in_array($objectclass, $oldObjectclasses))
522
+			if ($objectclass != 'posixaccount' && !in_array($objectclass, $oldObjectclasses))
523 523
 			{
524 524
 				$ldapContact['objectClass'][] = $objectclass;
525 525
 			}
526 526
 			if (isset($this->required_subs[$objectclass]))
527 527
 			{
528
-				foreach($this->required_subs[$objectclass] as $sub)
528
+				foreach ($this->required_subs[$objectclass] as $sub)
529 529
 				{
530
-					if(!in_array($sub, $oldObjectclasses))
530
+					if (!in_array($sub, $oldObjectclasses))
531 531
 					{
532 532
 						$ldapContact['objectClass'][] = $sub;
533 533
 					}
534 534
 				}
535 535
 			}
536
-			foreach($mapping as $egwFieldName => $ldapFieldName)
536
+			foreach ($mapping as $egwFieldName => $ldapFieldName)
537 537
 			{
538 538
 				if (is_int($egwFieldName)) continue;
539
-				if(!empty($data[$egwFieldName]))
539
+				if (!empty($data[$egwFieldName]))
540 540
 				{
541 541
 					// dont convert the (binary) jpegPhoto!
542
-					$ldapContact[$ldapFieldName] = $ldapFieldName == 'jpegphoto' ? $data[$egwFieldName] :
543
-						Api\Translation::convert(trim($data[$egwFieldName]),$this->charset,'utf-8');
542
+					$ldapContact[$ldapFieldName] = $ldapFieldName == 'jpegphoto' ? $data[$egwFieldName] : Api\Translation::convert(trim($data[$egwFieldName]), $this->charset, 'utf-8');
544 543
 				}
545
-				elseif($isUpdate && isset($data[$egwFieldName]))
544
+				elseif ($isUpdate && isset($data[$egwFieldName]))
546 545
 				{
547 546
 					$ldapContact[$ldapFieldName] = array();
548 547
 				}
@@ -550,9 +549,9 @@  discard block
 block discarded – undo
550 549
 			}
551 550
 			// handling of special attributes, like cat_id in evolutionPerson
552 551
 			$egw2objectclass = '_egw2'.$objectclass;
553
-			if (method_exists($this,$egw2objectclass))
552
+			if (method_exists($this, $egw2objectclass))
554 553
 			{
555
-				$this->$egw2objectclass($ldapContact,$data,$isUpdate);
554
+				$this->$egw2objectclass($ldapContact, $data, $isUpdate);
556 555
 			}
557 556
 		}
558 557
 		if ($isUpdate)
@@ -570,11 +569,11 @@  discard block
 block discarded – undo
570 569
 			$needRecreation = false;
571 570
 
572 571
 			// add missing objectclasses
573
-			if($ldapContact['objectClass'] && ($missing=array_diff($ldapContact['objectClass'],$oldObjectclasses)))
572
+			if ($ldapContact['objectClass'] && ($missing = array_diff($ldapContact['objectClass'], $oldObjectclasses)))
574 573
 			{
575 574
 				if (!@ldap_mod_add($this->ds, $dn, array('objectClass' => $ldapContact['objectClass'])))
576 575
 				{
577
-					if(in_array(ldap_errno($this->ds),array(69,20)))
576
+					if (in_array(ldap_errno($this->ds), array(69, 20)))
578 577
 					{
579 578
 						// need to modify structural objectclass
580 579
 						$needRecreation = true;
@@ -583,15 +582,15 @@  discard block
 block discarded – undo
583 582
 					else
584 583
 					{
585 584
 						//echo "<p>ldap_mod_add($this->ds,'$dn',array(objectClass =>".print_r($ldapContact['objectClass'],true)."))</p>\n";
586
-						error_log(__METHOD__.'() '.__LINE__.' update of '. $dn .' failed errorcode: '. ldap_errno($this->ds) .' ('. ldap_error($this->ds) .')');
585
+						error_log(__METHOD__.'() '.__LINE__.' update of '.$dn.' failed errorcode: '.ldap_errno($this->ds).' ('.ldap_error($this->ds).')');
587 586
 						return $this->_error(__LINE__);
588 587
 					}
589 588
 				}
590 589
 			}
591 590
 
592 591
 			// check if we need to rename the DN or need to recreate the contact
593
-			$newRDN = $this->dn_attribute.'='. $ldapContact[$this->dn_attribute];
594
-			$newDN = $newRDN .','. $baseDN;
592
+			$newRDN = $this->dn_attribute.'='.$ldapContact[$this->dn_attribute];
593
+			$newDN = $newRDN.','.$baseDN;
595 594
 			if ($needRecreation)
596 595
 			{
597 596
 				$result = ldap_read($this->ds, $dn, 'objectclass=*');
@@ -602,20 +601,20 @@  discard block
 block discarded – undo
602 601
 				$newContact = $oldContact;
603 602
 				$newContact[$this->dn_attribute] = $ldapContact[$this->dn_attribute];
604 603
 
605
-				if(is_array($ldapContact['objectClass']) && count($ldapContact['objectClass']) > 0)
604
+				if (is_array($ldapContact['objectClass']) && count($ldapContact['objectClass']) > 0)
606 605
 				{
607
-					$newContact['objectclass'] = array_unique(array_map('strtolower',	// objectclasses my have different case
606
+					$newContact['objectclass'] = array_unique(array_map('strtolower', // objectclasses my have different case
608 607
 						array_merge($newContact['objectclass'], $ldapContact['objectClass'])));
609 608
 				}
610 609
 
611
-				if(!ldap_delete($this->ds, $dn))
610
+				if (!ldap_delete($this->ds, $dn))
612 611
 				{
613
-					error_log(__METHOD__.'() '.__LINE__.' delete of old '. $dn .' failed errorcode: '. ldap_errno($this->ds) .' ('. ldap_error($this->ds) .')');
612
+					error_log(__METHOD__.'() '.__LINE__.' delete of old '.$dn.' failed errorcode: '.ldap_errno($this->ds).' ('.ldap_error($this->ds).')');
614 613
 					return $this->_error(__LINE__);
615 614
 				}
616
-				if(!@ldap_add($this->ds, $newDN, $newContact))
615
+				if (!@ldap_add($this->ds, $newDN, $newContact))
617 616
 				{
618
-					error_log(__METHOD__.'() '.__LINE__.' re-create contact as '. $newDN .' failed errorcode: '. ldap_errno($this->ds) .' ('. ldap_error($this->ds) .') newContact='.array2string($newContact));
617
+					error_log(__METHOD__.'() '.__LINE__.' re-create contact as '.$newDN.' failed errorcode: '.ldap_errno($this->ds).' ('.ldap_error($this->ds).') newContact='.array2string($newContact));
619 618
 					// if adding with new objectclass or dn fails, re-add deleted contact
620 619
 					@ldap_add($this->ds, $dn, $oldContact);
621 620
 					return $this->_error(__LINE__);
@@ -644,22 +643,22 @@  discard block
 block discarded – undo
644 643
 
645 644
 			if (!@ldap_modify($this->ds, $dn, $ldapContact))
646 645
 			{
647
-				error_log(__METHOD__.'() '.__LINE__.' update of '. $dn .' failed errorcode: '. ldap_errno($this->ds) .' ('. ldap_error($this->ds) .') ldapContact='.array2string($ldapContact));
646
+				error_log(__METHOD__.'() '.__LINE__.' update of '.$dn.' failed errorcode: '.ldap_errno($this->ds).' ('.ldap_error($this->ds).') ldapContact='.array2string($ldapContact));
648 647
 				return $this->_error(__LINE__);
649 648
 			}
650 649
 		}
651 650
 		else
652 651
 		{
653
-			$dn = $this->dn_attribute.'='. $ldapContact[$this->dn_attribute] .','. $baseDN;
654
-			unset($ldapContact['entryuuid']);	// trying to write it, gives an error
652
+			$dn = $this->dn_attribute.'='.$ldapContact[$this->dn_attribute].','.$baseDN;
653
+			unset($ldapContact['entryuuid']); // trying to write it, gives an error
655 654
 
656 655
 			if (!@ldap_add($this->ds, $dn, $ldapContact))
657 656
 			{
658
-				error_log(__METHOD__.'() '.__LINE__.' add of '. $dn .' failed errorcode: '. ldap_errno($this->ds) .' ('. ldap_error($this->ds) .') ldapContact='.array2string($ldapContact));
657
+				error_log(__METHOD__.'() '.__LINE__.' add of '.$dn.' failed errorcode: '.ldap_errno($this->ds).' ('.ldap_error($this->ds).') ldapContact='.array2string($ldapContact));
659 658
 				return $this->_error(__LINE__);
660 659
 			}
661 660
 		}
662
-		return 0;	// Ok, no error
661
+		return 0; // Ok, no error
663 662
 	}
664 663
 
665 664
 	/**
@@ -668,28 +667,28 @@  discard block
 block discarded – undo
668 667
 	 * @param array $keys if given array with col => value pairs to characterise the rows to delete
669 668
 	 * @return int affected rows, should be 1 if ok, 0 if an error
670 669
 	 */
671
-	function delete($keys=null)
670
+	function delete($keys = null)
672 671
 	{
673 672
 		// single entry
674
-		if($keys[$this->contacts_id]) $keys = array( 0 => $keys);
673
+		if ($keys[$this->contacts_id]) $keys = array(0 => $keys);
675 674
 
676
-		if(!is_array($keys))
675
+		if (!is_array($keys))
677 676
 		{
678
-			$keys = array( $keys);
677
+			$keys = array($keys);
679 678
 		}
680 679
 
681 680
 		$ret = 0;
682 681
 
683 682
 		$attributes = array('dn');
684 683
 
685
-		foreach($keys as $entry)
684
+		foreach ($keys as $entry)
686 685
 		{
687 686
 			$entry = Api\Ldap::quote(is_array($entry) ? $entry['id'] : $entry);
688
-			if(($result = ldap_search($this->ds, $this->allContactsDN,
687
+			if (($result = ldap_search($this->ds, $this->allContactsDN,
689 688
 				"(|(entryUUID=$entry)(uid=$entry))", $attributes)))
690 689
 			{
691 690
 				$contactInfo = ldap_get_entries($this->ds, $result);
692
-				if(@ldap_delete($this->ds, $contactInfo[0]['dn']))
691
+				if (@ldap_delete($this->ds, $contactInfo[0]['dn']))
693 692
 				{
694 693
 					$ret++;
695 694
 				}
@@ -717,10 +716,10 @@  discard block
 block discarded – undo
717 716
 	 * @param boolean $need_full_no_count =false If true an unlimited query is run to determine the total number of rows, default false
718 717
 	 * @return array of matching rows (the row is an array of the cols) or False
719 718
 	 */
720
-	function &search($criteria,$only_keys=True,$order_by='',$extra_cols='',$wildcard='',$empty=False,$op='AND',$start=false,$filter=null,$join='',$need_full_no_count=false)
719
+	function &search($criteria, $only_keys = True, $order_by = '', $extra_cols = '', $wildcard = '', $empty = False, $op = 'AND', $start = false, $filter = null, $join = '', $need_full_no_count = false)
721 720
 	{
722 721
 		//error_log(__METHOD__."(".array2string($criteria).", ".array2string($only_keys).", '$order_by', ".array2string($extra_cols).", '$wildcard', '$empty', '$op', ".array2string($start).", ".array2string($filter).")");
723
-		unset($only_keys, $extra_cols, $empty, $join, $need_full_no_count);	// not used, but required by function signature
722
+		unset($only_keys, $extra_cols, $empty, $join, $need_full_no_count); // not used, but required by function signature
724 723
 
725 724
 		if (is_array($filter['owner']))
726 725
 		{
@@ -742,7 +741,7 @@  discard block
 block discarded – undo
742 741
 			'created' => 'createtimestamp',
743 742
 			'modified' => 'modifytimestamp',
744 743
 		);
745
-		foreach($filter as $key => $value)
744
+		foreach ($filter as $key => $value)
746 745
 		{
747 746
 			$matches = null;
748 747
 			if (is_int($key) && preg_match('/^(contact_)?(modified|created)([<=>]+)([0-9]+)$/', $value, $matches))
@@ -758,11 +757,11 @@  discard block
 block discarded – undo
758 757
 			}
759 758
 		}
760 759
 
761
-		if((int)$filter['owner'])
760
+		if ((int)$filter['owner'])
762 761
 		{
763 762
 			if (!($accountName = $GLOBALS['egw']->accounts->id2name($filter['owner']))) return false;
764 763
 
765
-			$searchDN = 'cn='. Api\Ldap::quote(strtolower($accountName)) .',';
764
+			$searchDN = 'cn='.Api\Ldap::quote(strtolower($accountName)).',';
766 765
 
767 766
 			if ($filter['owner'] < 0)
768 767
 			{
@@ -786,7 +785,7 @@  discard block
 block discarded – undo
786 785
 			$addressbookType = self::ACCOUNTS;
787 786
 		}
788 787
 		// create the search filter
789
-		switch($addressbookType)
788
+		switch ($addressbookType)
790 789
 		{
791 790
 			case self::ACCOUNTS:
792 791
 				$objectFilter = $this->accountsFilter;
@@ -801,28 +800,28 @@  discard block
 block discarded – undo
801 800
 		// shadowExpire>= does NOT work, as shadow schema only specifies integerMatch and not integerOrderingMatch :-(
802 801
 
803 802
 		$searchFilter = '';
804
-		if(is_array($criteria) && count($criteria) > 0)
803
+		if (is_array($criteria) && count($criteria) > 0)
805 804
 		{
806 805
 			$wildcard = $wildcard === '%' ? '*' : '';
807 806
 			$searchFilter = '';
808
-			foreach($criteria as $egwSearchKey => $searchValue)
807
+			foreach ($criteria as $egwSearchKey => $searchValue)
809 808
 			{
810
-				if (in_array($egwSearchKey, array('id','contact_id')))
809
+				if (in_array($egwSearchKey, array('id', 'contact_id')))
811 810
 				{
812 811
 					$searchFilter .= $this->ids_filter($searchValue);
813 812
 					continue;
814 813
 				}
815
-				foreach($this->schema2egw as $mapping)
814
+				foreach ($this->schema2egw as $mapping)
816 815
 				{
817
-					if(($ldapSearchKey = $mapping[$egwSearchKey]))
816
+					if (($ldapSearchKey = $mapping[$egwSearchKey]))
818 817
 					{
819
-						$searchString = Api\Translation::convert($searchValue,$this->charset,'utf-8');
818
+						$searchString = Api\Translation::convert($searchValue, $this->charset, 'utf-8');
820 819
 						$searchFilter .= '('.$ldapSearchKey.'='.$wildcard.Api\Ldap::quote($searchString).$wildcard.')';
821 820
 						break;
822 821
 					}
823 822
 				}
824 823
 			}
825
-			if($op == 'AND')
824
+			if ($op == 'AND')
826 825
 			{
827 826
 				$searchFilter = "(&$searchFilter)";
828 827
 			}
@@ -841,9 +840,9 @@  discard block
 block discarded – undo
841 840
 		// only return certain owners --> unset not matching ones
842 841
 		if ($owner_filter)
843 842
 		{
844
-			foreach($rows as $k => $row)
843
+			foreach ($rows as $k => $row)
845 844
 			{
846
-				if (!in_array($row['owner'],$owner_filter))
845
+				if (!in_array($row['owner'], $owner_filter))
847 846
 				{
848 847
 					unset($rows[$k]);
849 848
 					--$this->total;
@@ -854,18 +853,18 @@  discard block
 block discarded – undo
854 853
 		{
855 854
 			$order = array();
856 855
 			$sort = 'ASC';
857
-			foreach(explode(',',$order_by) as $o)
856
+			foreach (explode(',', $order_by) as $o)
858 857
 			{
859
-				if (substr($o,0,8) == 'contact_') $o = substr($o,8);
860
-				if (substr($o,-4) == ' ASC')
858
+				if (substr($o, 0, 8) == 'contact_') $o = substr($o, 8);
859
+				if (substr($o, -4) == ' ASC')
861 860
 				{
862 861
 					$sort = 'ASC';
863
-					$order[] = substr($o,0,-4);
862
+					$order[] = substr($o, 0, -4);
864 863
 				}
865
-				elseif (substr($o,-5) == ' DESC')
864
+				elseif (substr($o, -5) == ' DESC')
866 865
 				{
867 866
 					$sort = 'DESC';
868
-					$order[] = substr($o,0,-5);
867
+					$order[] = substr($o, 0, -5);
869 868
 				}
870 869
 				elseif ($o)
871 870
 				{
@@ -874,9 +873,9 @@  discard block
 block discarded – undo
874 873
 			}
875 874
 			usort($rows, function($a, $b) use ($order, $sort)
876 875
 			{
877
-				foreach($order as $f)
876
+				foreach ($order as $f)
878 877
 				{
879
-					if($sort == 'ASC')
878
+					if ($sort == 'ASC')
880 879
 					{
881 880
 						$strc = strcmp($a[$f], $b[$f]);
882 881
 					}
@@ -892,13 +891,13 @@  discard block
 block discarded – undo
892 891
 		// if requested ($start !== false) return only limited resultset
893 892
 		if (is_array($start))
894 893
 		{
895
-			list($start,$offset) = $start;
894
+			list($start, $offset) = $start;
896 895
 		}
897
-		if(is_numeric($start) && is_numeric($offset) && $offset >= 0)
896
+		if (is_numeric($start) && is_numeric($offset) && $offset >= 0)
898 897
 		{
899 898
 			return array_slice($rows, $start, $offset);
900 899
 		}
901
-		elseif(is_numeric($start))
900
+		elseif (is_numeric($start))
902 901
 		{
903 902
 			return array_slice($rows, $start, $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs']);
904 903
 		}
@@ -916,11 +915,11 @@  discard block
 block discarded – undo
916 915
 		if (!is_array($filter)) return '';
917 916
 
918 917
 		$filters = '';
919
-		foreach($filter as $key => $value)
918
+		foreach ($filter as $key => $value)
920 919
 		{
921 920
 			if ($key != 'cat_id' && $key != 'account_id' && !$value) continue;
922 921
 
923
-			switch((string) $key)
922
+			switch ((string)$key)
924 923
 			{
925 924
 				case 'owner':	// already handled
926 925
 				case 'tid':		// ignored
@@ -934,7 +933,7 @@  discard block
 block discarded – undo
934 933
 					elseif ($value)
935 934
 					{
936 935
 						if (is_array($value)) $filters .= '(|';
937
-						foreach((array)$value as $value)
936
+						foreach ((array)$value as $value)
938 937
 						{
939 938
 							$filters .= '(uidNumber='.(int)$value.')';
940 939
 						}
@@ -947,7 +946,7 @@  discard block
 block discarded – undo
947 946
 					{
948 947
 						$filters .= '(!(category=*))';
949 948
 					}
950
-					elseif((int)$value)
949
+					elseif ((int)$value)
951 950
 					{
952 951
 						if (!is_object($GLOBALS['egw']->categories))
953 952
 						{
@@ -955,10 +954,10 @@  discard block
 block discarded – undo
955 954
 						}
956 955
 						$cats = $GLOBALS['egw']->categories->return_all_children((int)$value);
957 956
 						if (count($cats) > 1) $filters .= '(|';
958
-						foreach($cats as $cat)
957
+						foreach ($cats as $cat)
959 958
 						{
960 959
 							$catName = Api\Translation::convert(
961
-								$GLOBALS['egw']->categories->id2name($cat),$this->charset,'utf-8');
960
+								$GLOBALS['egw']->categories->id2name($cat), $this->charset, 'utf-8');
962 961
 							$filters .= '(category='.Api\Ldap::quote($catName).')';
963 962
 						}
964 963
 						if (count($cats) > 1) $filters .= ')';
@@ -967,7 +966,7 @@  discard block
 block discarded – undo
967 966
 
968 967
 				case 'carddav_name':
969 968
 					if (!is_array($value)) $value = array($value);
970
-					foreach($value as &$v)
969
+					foreach ($value as &$v)
971 970
 					{
972 971
 						$v = basename($v, '.vcf');
973 972
 					}
@@ -985,28 +984,27 @@  discard block
 block discarded – undo
985 984
 					$matches = null;
986 985
 					if (!is_int($key))
987 986
 					{
988
-						foreach($this->schema2egw as $mapping)
987
+						foreach ($this->schema2egw as $mapping)
989 988
 						{
990 989
 							if (isset($mapping[$key]))
991 990
 							{
992 991
 								// todo: value = "!''"
993
-								$filters .= '('.$mapping[$key].'='.($value === "!''" ? '*' :
994
-									Api\Ldap::quote(Api\Translation::convert($value,$this->charset,'utf-8'))).')';
992
+								$filters .= '('.$mapping[$key].'='.($value === "!''" ? '*' : Api\Ldap::quote(Api\Translation::convert($value, $this->charset, 'utf-8'))).')';
995 993
 								break;
996 994
 							}
997 995
 						}
998 996
 					}
999 997
 					// filter for letter-search
1000
-					elseif (preg_match("/^([^ ]+) ".preg_quote($GLOBALS['egw']->db->capabilities[Api\Db::CAPABILITY_CASE_INSENSITIV_LIKE])." '(.*)%'$/",$value,$matches))
998
+					elseif (preg_match("/^([^ ]+) ".preg_quote($GLOBALS['egw']->db->capabilities[Api\Db::CAPABILITY_CASE_INSENSITIV_LIKE])." '(.*)%'$/", $value, $matches))
1001 999
 					{
1002
-						list(,$name,$value) = $matches;
1003
-						if (strpos($name,'.') !== false) list(,$name) = explode('.',$name);
1004
-						foreach($this->schema2egw as $mapping)
1000
+						list(,$name, $value) = $matches;
1001
+						if (strpos($name, '.') !== false) list(,$name) = explode('.', $name);
1002
+						foreach ($this->schema2egw as $mapping)
1005 1003
 						{
1006 1004
 							if (isset($mapping[$name]))
1007 1005
 							{
1008 1006
 								$filters .= '('.$mapping[$name].'='.Api\Ldap::quote(
1009
-									Api\Translation::convert($value,$this->charset,'utf-8')).'*)';
1007
+									Api\Translation::convert($value, $this->charset, 'utf-8')).'*)';
1010 1008
 								break;
1011 1009
 							}
1012 1010
 						}
@@ -1030,7 +1028,7 @@  discard block
 block discarded – undo
1030 1028
 		{
1031 1029
 			$filter .= '(|';
1032 1030
 			// unfortunately we have no group-membership attribute in LDAP, like in AD
1033
-			foreach($GLOBALS['egw']->accounts->members($gid, true) as $account_id)
1031
+			foreach ($GLOBALS['egw']->accounts->members($gid, true) as $account_id)
1034 1032
 			{
1035 1033
 				$filter .= '(uidNumber='.(int)$account_id.')';
1036 1034
 			}
@@ -1052,7 +1050,7 @@  discard block
 block discarded – undo
1052 1050
 	 * @param array $_skipPlugins =null schema-plugins to skip
1053 1051
 	 * @return array/boolean with eGW contacts or false on error
1054 1052
 	 */
1055
-	function _searchLDAP($_ldapContext, $_filter, $_attributes, $_addressbooktype, array $_skipPlugins=null)
1053
+	function _searchLDAP($_ldapContext, $_filter, $_attributes, $_addressbooktype, array $_skipPlugins = null)
1056 1054
 	{
1057 1055
 		$this->total = 0;
1058 1056
 
@@ -1065,7 +1063,7 @@  discard block
 block discarded – undo
1065 1063
 
1066 1064
 		//error_log(__METHOD__."('$_ldapContext', '$_filter', ".array2string($_attributes).", $_addressbooktype)");
1067 1065
 
1068
-		if($_addressbooktype == self::ALL || $_ldapContext == $this->allContactsDN)
1066
+		if ($_addressbooktype == self::ALL || $_ldapContext == $this->allContactsDN)
1069 1067
 		{
1070 1068
 			$result = ldap_search($this->ds, $_ldapContext, $_filter, $_attributes, 0, $this->ldapLimit);
1071 1069
 		}
@@ -1073,36 +1071,36 @@  discard block
 block discarded – undo
1073 1071
 		{
1074 1072
 			$result = @ldap_list($this->ds, $_ldapContext, $_filter, $_attributes, 0, $this->ldapLimit);
1075 1073
 		}
1076
-		if(!$result || !$entries = ldap_get_entries($this->ds, $result)) return array();
1074
+		if (!$result || !$entries = ldap_get_entries($this->ds, $result)) return array();
1077 1075
 		//error_log(__METHOD__."('$_ldapContext', '$_filter', ".array2string($_attributes).", $_addressbooktype) result of $entries[count]");
1078 1076
 
1079 1077
 		$this->total = $entries['count'];
1080
-		foreach($entries as $i => $entry)
1078
+		foreach ($entries as $i => $entry)
1081 1079
 		{
1082
-			if (!is_int($i)) continue;	// eg. count
1080
+			if (!is_int($i)) continue; // eg. count
1083 1081
 
1084 1082
 			$contact = array(
1085 1083
 				'id'  => $entry['uid'][0] ? $entry['uid'][0] : $entry['entryuuid'][0],
1086
-				'tid' => 'n',	// the type id for the addressbook
1084
+				'tid' => 'n', // the type id for the addressbook
1087 1085
 			);
1088
-			foreach($entry['objectclass'] as $ii => $objectclass)
1086
+			foreach ($entry['objectclass'] as $ii => $objectclass)
1089 1087
 			{
1090 1088
 				$objectclass = strtolower($objectclass);
1091 1089
 				if (!is_int($ii) || !isset($this->schema2egw[$objectclass]))
1092 1090
 				{
1093
-					continue;	// eg. count or unsupported objectclass
1091
+					continue; // eg. count or unsupported objectclass
1094 1092
 				}
1095
-				foreach($this->schema2egw[$objectclass] as $egwFieldName => $ldapFieldName)
1093
+				foreach ($this->schema2egw[$objectclass] as $egwFieldName => $ldapFieldName)
1096 1094
 				{
1097
-					if(!empty($entry[$ldapFieldName][0]) && !is_int($egwFieldName) && !isset($contact[$egwFieldName]))
1095
+					if (!empty($entry[$ldapFieldName][0]) && !is_int($egwFieldName) && !isset($contact[$egwFieldName]))
1098 1096
 					{
1099
-						$contact[$egwFieldName] = Api\Translation::convert($entry[$ldapFieldName][0],'utf-8');
1097
+						$contact[$egwFieldName] = Api\Translation::convert($entry[$ldapFieldName][0], 'utf-8');
1100 1098
 					}
1101 1099
 				}
1102 1100
 				$objectclass2egw = '_'.$objectclass.'2egw';
1103
-				if (!in_array($objectclass2egw, (array)$_skipPlugins) &&method_exists($this,$objectclass2egw))
1101
+				if (!in_array($objectclass2egw, (array)$_skipPlugins) && method_exists($this, $objectclass2egw))
1104 1102
 				{
1105
-					if (($ret=$this->$objectclass2egw($contact,$entry)) === false)
1103
+					if (($ret = $this->$objectclass2egw($contact, $entry)) === false)
1106 1104
 					{
1107 1105
 						--$this->total;
1108 1106
 						continue 2;
@@ -1112,20 +1110,20 @@  discard block
 block discarded – undo
1112 1110
 			// read binary jpegphoto only for one result == call by read
1113 1111
 			if ($this->total == 1 && isset($entry['jpegphoto'][0]))
1114 1112
 			{
1115
-				$bin = ldap_get_values_len($this->ds,ldap_first_entry($this->ds,$result),'jpegphoto');
1113
+				$bin = ldap_get_values_len($this->ds, ldap_first_entry($this->ds, $result), 'jpegphoto');
1116 1114
 				$contact['jpegphoto'] = $bin[0];
1117 1115
 			}
1118 1116
 			$matches = null;
1119
-			if(preg_match('/cn=([^,]+),'.preg_quote($this->personalContactsDN,'/').'$/i',$entry['dn'],$matches))
1117
+			if (preg_match('/cn=([^,]+),'.preg_quote($this->personalContactsDN, '/').'$/i', $entry['dn'], $matches))
1120 1118
 			{
1121 1119
 				// personal addressbook
1122
-				$contact['owner'] = $GLOBALS['egw']->accounts->name2id($matches[1],'account_lid','u');
1120
+				$contact['owner'] = $GLOBALS['egw']->accounts->name2id($matches[1], 'account_lid', 'u');
1123 1121
 				$contact['private'] = 0;
1124 1122
 			}
1125
-			elseif(preg_match('/cn=([^,]+),'.preg_quote($this->sharedContactsDN,'/').'$/i',$entry['dn'],$matches))
1123
+			elseif (preg_match('/cn=([^,]+),'.preg_quote($this->sharedContactsDN, '/').'$/i', $entry['dn'], $matches))
1126 1124
 			{
1127 1125
 				// group addressbook
1128
-				$contact['owner'] = $GLOBALS['egw']->accounts->name2id($matches[1],'account_lid','g');
1126
+				$contact['owner'] = $GLOBALS['egw']->accounts->name2id($matches[1], 'account_lid', 'g');
1129 1127
 				$contact['private'] = 0;
1130 1128
 			}
1131 1129
 			else
@@ -1134,12 +1132,12 @@  discard block
 block discarded – undo
1134 1132
 				$contact['owner'] = 0;
1135 1133
 				$contact['private'] = 0;
1136 1134
 			}
1137
-			foreach(array(
1135
+			foreach (array(
1138 1136
 				'createtimestamp' => 'created',
1139 1137
 				'modifytimestamp' => 'modified',
1140 1138
 			) as $ldapFieldName => $egwFieldName)
1141 1139
 			{
1142
-				if(!empty($entry[$ldapFieldName][0]))
1140
+				if (!empty($entry[$ldapFieldName][0]))
1143 1141
 				{
1144 1142
 					$contact[$egwFieldName] = $this->_ldap2ts($entry[$ldapFieldName][0]);
1145 1143
 				}
@@ -1158,8 +1156,8 @@  discard block
 block discarded – undo
1158 1156
 	 */
1159 1157
 	static function _ldap2ts($date)
1160 1158
 	{
1161
-		return gmmktime(substr($date,8,2),substr($date,10,2),substr($date,12,2),
1162
-			substr($date,4,2),substr($date,6,2),substr($date,0,4));
1159
+		return gmmktime(substr($date, 8, 2), substr($date, 10, 2), substr($date, 12, 2),
1160
+			substr($date, 4, 2), substr($date, 6, 2), substr($date, 0, 4));
1163 1161
 	}
1164 1162
 
1165 1163
 	/**
@@ -1182,20 +1180,20 @@  discard block
 block discarded – undo
1182 1180
 	function _check_create_dn($baseDN)
1183 1181
 	{
1184 1182
 		// check if $baseDN exists. If not create new one
1185
-		if(@ldap_read($this->ds, $baseDN, 'objectclass=*'))
1183
+		if (@ldap_read($this->ds, $baseDN, 'objectclass=*'))
1186 1184
 		{
1187 1185
 			return false;
1188 1186
 		}
1189 1187
 		//error_log(__METHOD__."('$baseDN') !ldap_read({$this->ds}, '$baseDN', 'objectclass=*') ldap_errno()=".ldap_errno($this->ds).', ldap_error()='.ldap_error($this->ds).get_class($this));
1190
-		if(ldap_errno($this->ds) != 32 || substr($baseDN,0,3) != 'cn=')
1188
+		if (ldap_errno($this->ds) != 32 || substr($baseDN, 0, 3) != 'cn=')
1191 1189
 		{
1192 1190
 			error_log(__METHOD__."('$baseDN') baseDN does NOT exist and we cant/wont create it! ldap_errno()=".ldap_errno($this->ds).', ldap_error()='.ldap_error($this->ds));
1193
-			return $this->_error(__LINE__);	// baseDN does NOT exist and we cant/wont create it
1191
+			return $this->_error(__LINE__); // baseDN does NOT exist and we cant/wont create it
1194 1192
 		}
1195 1193
 
1196
-		list(,$ou) = explode(',',$baseDN);
1194
+		list(,$ou) = explode(',', $baseDN);
1197 1195
 		$adminDS = null;
1198
-		foreach(array(
1196
+		foreach (array(
1199 1197
 			'ou=contacts,'.$this->allContactsDN,
1200 1198
 			$ou.',ou=contacts,'.$this->allContactsDN,
1201 1199
 			$baseDN,
@@ -1204,18 +1202,18 @@  discard block
 block discarded – undo
1204 1202
 			if (!@ldap_read($this->ds, $dn, 'objectclass=*') && ldap_errno($this->ds) == 32)
1205 1203
 			{
1206 1204
 				// entry does not exist, lets try to create it
1207
-				list($top) = explode(',',$dn);
1208
-				list($var,$val) = explode('=',$top);
1205
+				list($top) = explode(',', $dn);
1206
+				list($var, $val) = explode('=', $top);
1209 1207
 				$data = array(
1210 1208
 					'objectClass' => $var == 'cn' ? 'organizationalRole' : 'organizationalUnit',
1211 1209
 					$var => $val,
1212 1210
 				);
1213 1211
 				// create a admin connection to add the needed DN
1214 1212
 				if (!isset($adminDS)) $adminDS = Api\Ldap::factory();
1215
-				if(!@ldap_add($adminDS, $dn, $data))
1213
+				if (!@ldap_add($adminDS, $dn, $data))
1216 1214
 				{
1217 1215
 					//echo "<p>ldap_add($adminDS,'$dn',".print_r($data,true).")</p>\n";
1218
-					$err = lang("Can't create dn %1",$dn).': '.$this->_error(__LINE__,$adminDS);
1216
+					$err = lang("Can't create dn %1", $dn).': '.$this->_error(__LINE__, $adminDS);
1219 1217
 					return $err;
1220 1218
 				}
1221 1219
 			}
@@ -1230,7 +1228,7 @@  discard block
 block discarded – undo
1230 1228
 	 * @param int $line
1231 1229
 	 * @return string
1232 1230
 	 */
1233
-	function _error($line,$ds=null)
1231
+	function _error($line, $ds = null)
1234 1232
 	{
1235 1233
 		return ldap_error($ds ? $ds : $this->ds).': '.__CLASS__.': '.$line;
1236 1234
 	}
@@ -1245,27 +1243,27 @@  discard block
 block discarded – undo
1245 1243
 	 * @param array $data eGW contact data
1246 1244
 	 * @param boolean $isUpdate
1247 1245
 	 */
1248
-	function _egw2evolutionperson(&$ldapContact,$data,$isUpdate)
1246
+	function _egw2evolutionperson(&$ldapContact, $data, $isUpdate)
1249 1247
 	{
1250
-		if(!empty($data['cat_id']))
1248
+		if (!empty($data['cat_id']))
1251 1249
 		{
1252 1250
 			$ldapContact['category'] = array();
1253
-			foreach(is_array($data['cat_id']) ? $data['cat_id'] : explode(',',$data['cat_id'])  as $cat)
1251
+			foreach (is_array($data['cat_id']) ? $data['cat_id'] : explode(',', $data['cat_id'])  as $cat)
1254 1252
 			{
1255 1253
 				$ldapContact['category'][] = Api\Translation::convert(
1256
-					Api\Categories::id2name($cat),$this->charset,'utf-8');
1254
+					Api\Categories::id2name($cat), $this->charset, 'utf-8');
1257 1255
 			}
1258 1256
 		}
1259
-		foreach(array(
1260
-			'postaladdress' => $data['adr_one_street'] .'$'. $data['adr_one_locality'] .', '. $data['adr_one_region'] .'$'. $data['adr_one_postalcode'] .'$$'. $data['adr_one_countryname'],
1261
-			'homepostaladdress' => $data['adr_two_street'] .'$'. $data['adr_two_locality'] .', '. $data['adr_two_region'] .'$'. $data['adr_two_postalcode'] .'$$'. $data['adr_two_countryname'],
1257
+		foreach (array(
1258
+			'postaladdress' => $data['adr_one_street'].'$'.$data['adr_one_locality'].', '.$data['adr_one_region'].'$'.$data['adr_one_postalcode'].'$$'.$data['adr_one_countryname'],
1259
+			'homepostaladdress' => $data['adr_two_street'].'$'.$data['adr_two_locality'].', '.$data['adr_two_region'].'$'.$data['adr_two_postalcode'].'$$'.$data['adr_two_countryname'],
1262 1260
 		) as $attr => $value)
1263 1261
 		{
1264
-			if($value != '$, $$$')
1262
+			if ($value != '$, $$$')
1265 1263
 			{
1266
-				$ldapContact[$attr] = Api\Translation::convert($value,$this->charset,'utf-8');
1264
+				$ldapContact[$attr] = Api\Translation::convert($value, $this->charset, 'utf-8');
1267 1265
 			}
1268
-			elseif($isUpdate)
1266
+			elseif ($isUpdate)
1269 1267
 			{
1270 1268
 				$ldapContact[$attr] = array();
1271 1269
 			}
@@ -1275,7 +1273,7 @@  discard block
 block discarded – undo
1275 1273
 		{
1276 1274
 			$ldapContact['primaryphone'] = $data[$data['tel_prefer']];
1277 1275
 		}
1278
-		elseif($isUpdate)
1276
+		elseif ($isUpdate)
1279 1277
 		{
1280 1278
 			$ldapContact['primaryphone'] = array();
1281 1279
 		}
@@ -1290,23 +1288,23 @@  discard block
 block discarded – undo
1290 1288
 	 * @param array &$contact already copied fields according to the mapping
1291 1289
 	 * @param array $data eGW contact data
1292 1290
 	 */
1293
-	function _evolutionperson2egw(&$contact,$data)
1291
+	function _evolutionperson2egw(&$contact, $data)
1294 1292
 	{
1295 1293
 		if ($data['category'] && is_array($data['category']))
1296 1294
 		{
1297 1295
 			$contact['cat_id'] = array();
1298
-			foreach($data['category'] as $iii => $cat)
1296
+			foreach ($data['category'] as $iii => $cat)
1299 1297
 			{
1300 1298
 				if (!is_int($iii)) continue;
1301 1299
 
1302 1300
 				$contact['cat_id'][] = $GLOBALS['egw']->categories->name2id($cat);
1303 1301
 			}
1304
-			if ($contact['cat_id']) $contact['cat_id'] = implode(',',$contact['cat_id']);
1302
+			if ($contact['cat_id']) $contact['cat_id'] = implode(',', $contact['cat_id']);
1305 1303
 		}
1306 1304
 		if ($data['primaryphone'])
1307 1305
 		{
1308
-			unset($contact['tel_prefer']);	// to not find itself
1309
-			$contact['tel_prefer'] = array_search($data['primaryphone'][0],$contact);
1306
+			unset($contact['tel_prefer']); // to not find itself
1307
+			$contact['tel_prefer'] = array_search($data['primaryphone'][0], $contact);
1310 1308
 		}
1311 1309
 	}
1312 1310
 
@@ -1319,10 +1317,10 @@  discard block
 block discarded – undo
1319 1317
 	 * @param array &$contact already copied fields according to the mapping
1320 1318
 	 * @param array $data eGW contact data
1321 1319
 	 */
1322
-	function _inetorgperson2egw(&$contact, $data, $cn='cn')
1320
+	function _inetorgperson2egw(&$contact, $data, $cn = 'cn')
1323 1321
 	{
1324 1322
 		$matches = null;
1325
-		if(empty($data['givenname'][0]))
1323
+		if (empty($data['givenname'][0]))
1326 1324
 		{
1327 1325
 			$parts = explode($data['sn'][0], $data[$cn][0]);
1328 1326
 			$contact['n_prefix'] = trim($parts[0]);
@@ -1330,8 +1328,8 @@  discard block
 block discarded – undo
1330 1328
 		}
1331 1329
 		// iOS addressbook either use "givenname surname" or "surname givenname" depending on contact preference display-order
1332 1330
 		// in full name, so we need to check for both when trying to parse prefix, middle name and suffix form full name
1333
-		elseif (preg_match($preg='/^(.*) *'.preg_quote($data['givenname'][0], '/').' *(.*) *'.preg_quote($data['sn'][0], '/').' *(.*)$/', $data[$cn][0], $matches) ||
1334
-			preg_match($preg='/^(.*) *'.preg_quote($data['sn'][0], '/').'[, ]*(.*) *'.preg_quote($data['givenname'][0], '/').' *(.*)$/', $data[$cn][0], $matches))
1331
+		elseif (preg_match($preg = '/^(.*) *'.preg_quote($data['givenname'][0], '/').' *(.*) *'.preg_quote($data['sn'][0], '/').' *(.*)$/', $data[$cn][0], $matches) ||
1332
+			preg_match($preg = '/^(.*) *'.preg_quote($data['sn'][0], '/').'[, ]*(.*) *'.preg_quote($data['givenname'][0], '/').' *(.*)$/', $data[$cn][0], $matches))
1335 1333
 		{
1336 1334
 			list(,$contact['n_prefix'], $contact['n_middle'], $contact['n_suffix']) = $matches;
1337 1335
 			//error_log(__METHOD__."() preg_match('$preg', '{$data[$cn][0]}') = ".array2string($matches));
@@ -1352,11 +1350,11 @@  discard block
 block discarded – undo
1352 1350
 	 * @param array &$contact already copied fields according to the mapping
1353 1351
 	 * @param array $data eGW contact data
1354 1352
 	 */
1355
-	function _posixaccount2egw(&$contact,$data)
1353
+	function _posixaccount2egw(&$contact, $data)
1356 1354
 	{
1357
-		unset($contact);	// not used, but required by function signature
1358
-		static $shadowExpireNow=null;
1359
-		if (!isset($shadowExpireNow)) $shadowExpireNow = floor((time()-date('Z'))/86400);
1355
+		unset($contact); // not used, but required by function signature
1356
+		static $shadowExpireNow = null;
1357
+		if (!isset($shadowExpireNow)) $shadowExpireNow = floor((time() - date('Z')) / 86400);
1360 1358
 
1361 1359
 		// exclude expired or deactivated accounts
1362 1360
 		if (isset($data['shadowexpire']) && $data['shadowexpire'][0] <= $shadowExpireNow)
@@ -1374,7 +1372,7 @@  discard block
 block discarded – undo
1374 1372
 	 * @param array &$contact already copied fields according to the mapping
1375 1373
 	 * @param array $data eGW contact data
1376 1374
 	 */
1377
-	function _mozillaabpersonalpha2egw(&$contact,$data)
1375
+	function _mozillaabpersonalpha2egw(&$contact, $data)
1378 1376
 	{
1379 1377
 		if ($data['c'])
1380 1378
 		{
@@ -1392,7 +1390,7 @@  discard block
 block discarded – undo
1392 1390
 	 * @param array $data eGW contact data
1393 1391
 	 * @param boolean $isUpdate
1394 1392
 	 */
1395
-	function _egw2mozillaabpersonalpha(&$ldapContact,$data,$isUpdate)
1393
+	function _egw2mozillaabpersonalpha(&$ldapContact, $data, $isUpdate)
1396 1394
 	{
1397 1395
 		if ($data['adr_one_countrycode'])
1398 1396
 		{
@@ -1421,9 +1419,9 @@  discard block
 block discarded – undo
1421 1419
 	 * @param array &$contact already copied fields according to the mapping
1422 1420
 	 * @param array $data eGW contact data
1423 1421
 	 */
1424
-	function _mozillaorgperson2egw(&$contact,$data)
1422
+	function _mozillaorgperson2egw(&$contact, $data)
1425 1423
 	{
1426
-		unset($contact, $data);	// not used, but required by function signature
1424
+		unset($contact, $data); // not used, but required by function signature
1427 1425
 		// no special handling necessary, as it supports two distinct attributes: c, cn
1428 1426
 	}
1429 1427
 
@@ -1437,7 +1435,7 @@  discard block
 block discarded – undo
1437 1435
 	 * @param array $data eGW contact data
1438 1436
 	 * @param boolean $isUpdate
1439 1437
 	 */
1440
-	function _egw2mozillaorgperson(&$ldapContact,$data,$isUpdate)
1438
+	function _egw2mozillaorgperson(&$ldapContact, $data, $isUpdate)
1441 1439
 	{
1442 1440
 		if ($data['adr_one_countrycode'])
1443 1441
 		{
@@ -1465,7 +1463,7 @@  discard block
 block discarded – undo
1465 1463
 	 * @param int $account_id account-id of the old owner
1466 1464
 	 * @param int $new_owner account-id of the new owner
1467 1465
 	 */
1468
-	function change_owner($account_id,$new_owner)
1466
+	function change_owner($account_id, $new_owner)
1469 1467
 	{
1470 1468
 		error_log(__METHOD__."($account_id,$new_owner) not yet implemented");
1471 1469
 	}
Please login to merge, or discard this patch.
Braces   +105 added lines, -27 removed lines patch added patch discarded remove patch
@@ -327,9 +327,12 @@  discard block
 block discarded – undo
327 327
 			$this->ds = Api\Ldap::factory();
328 328
 		}
329 329
 		// if ldap is NOT the contact repository, we only do accounts and need to use the account-data
330
-		elseif (substr($GLOBALS['egw_info']['server']['contact_repository'],-4) != 'ldap')	// not (ldap or sql-ldap)
330
+		elseif (substr($GLOBALS['egw_info']['server']['contact_repository'],-4) != 'ldap')
331
+		{
332
+			// not (ldap or sql-ldap)
331 333
 		{
332 334
 			$this->ldap_config['ldap_contact_host'] = $this->ldap_config['ldap_host'];
335
+		}
333 336
 			$this->allContactsDN = $this->ldap_config['ldap_context'];
334 337
 			$this->ds = Api\Ldap::factory();
335 338
 		}
@@ -413,7 +416,10 @@  discard block
 block discarded – undo
413 416
 		}
414 417
 		else
415 418
 		{
416
-			if (is_array($contact_id)) $contact_id = isset ($contact_id['id']) ? $contact_id['id'] : $contact_id['uid'];
419
+			if (is_array($contact_id))
420
+			{
421
+				$contact_id = isset ($contact_id['id']) ? $contact_id['id'] : $contact_id['uid'];
422
+			}
417 423
 			$filter = $this->id_filter($contact_id);
418 424
 		}
419 425
 		$rows = $this->_searchLDAP($this->allContactsDN,
@@ -517,7 +523,10 @@  discard block
 block discarded – undo
517 523
 		// add for all supported objectclasses the objectclass and it's attributes
518 524
 		foreach($this->schema2egw as $objectclass => $mapping)
519 525
 		{
520
-			if(!$this->ldapServerInfo->supportsObjectClass($objectclass)) continue;
526
+			if(!$this->ldapServerInfo->supportsObjectClass($objectclass))
527
+			{
528
+				continue;
529
+			}
521 530
 
522 531
 			if($objectclass != 'posixaccount' && !in_array($objectclass, $oldObjectclasses))
523 532
 			{
@@ -535,7 +544,10 @@  discard block
 block discarded – undo
535 544
 			}
536 545
 			foreach($mapping as $egwFieldName => $ldapFieldName)
537 546
 			{
538
-				if (is_int($egwFieldName)) continue;
547
+				if (is_int($egwFieldName))
548
+				{
549
+					continue;
550
+				}
539 551
 				if(!empty($data[$egwFieldName]))
540 552
 				{
541 553
 					// dont convert the (binary) jpegPhoto!
@@ -671,7 +683,10 @@  discard block
 block discarded – undo
671 683
 	function delete($keys=null)
672 684
 	{
673 685
 		// single entry
674
-		if($keys[$this->contacts_id]) $keys = array( 0 => $keys);
686
+		if($keys[$this->contacts_id])
687
+		{
688
+			$keys = array( 0 => $keys);
689
+		}
675 690
 
676 691
 		if(!is_array($keys))
677 692
 		{
@@ -760,7 +775,10 @@  discard block
 block discarded – undo
760 775
 
761 776
 		if((int)$filter['owner'])
762 777
 		{
763
-			if (!($accountName = $GLOBALS['egw']->accounts->id2name($filter['owner']))) return false;
778
+			if (!($accountName = $GLOBALS['egw']->accounts->id2name($filter['owner'])))
779
+			{
780
+				return false;
781
+			}
764 782
 
765 783
 			$searchDN = 'cn='. Api\Ldap::quote(strtolower($accountName)) .',';
766 784
 
@@ -856,7 +874,10 @@  discard block
 block discarded – undo
856 874
 			$sort = 'ASC';
857 875
 			foreach(explode(',',$order_by) as $o)
858 876
 			{
859
-				if (substr($o,0,8) == 'contact_') $o = substr($o,8);
877
+				if (substr($o,0,8) == 'contact_')
878
+				{
879
+					$o = substr($o,8);
880
+				}
860 881
 				if (substr($o,-4) == ' ASC')
861 882
 				{
862 883
 					$sort = 'ASC';
@@ -884,7 +905,10 @@  discard block
 block discarded – undo
884 905
 					{
885 906
 						$strc = strcmp($b[$f], $a[$f]);
886 907
 					}
887
-					if ($strc) return $strc;
908
+					if ($strc)
909
+					{
910
+						return $strc;
911
+					}
888 912
 				}
889 913
 				return 0;
890 914
 			});
@@ -913,12 +937,18 @@  discard block
 block discarded – undo
913 937
 	 */
914 938
 	function _colFilter($filter)
915 939
 	{
916
-		if (!is_array($filter)) return '';
940
+		if (!is_array($filter))
941
+		{
942
+			return '';
943
+		}
917 944
 
918 945
 		$filters = '';
919 946
 		foreach($filter as $key => $value)
920 947
 		{
921
-			if ($key != 'cat_id' && $key != 'account_id' && !$value) continue;
948
+			if ($key != 'cat_id' && $key != 'account_id' && !$value)
949
+			{
950
+				continue;
951
+			}
922 952
 
923 953
 			switch((string) $key)
924 954
 			{
@@ -933,12 +963,18 @@  discard block
 block discarded – undo
933 963
 					}
934 964
 					elseif ($value)
935 965
 					{
936
-						if (is_array($value)) $filters .= '(|';
966
+						if (is_array($value))
967
+						{
968
+							$filters .= '(|';
969
+						}
937 970
 						foreach((array)$value as $value)
938 971
 						{
939 972
 							$filters .= '(uidNumber='.(int)$value.')';
940 973
 						}
941
-						if (is_array($value)) $filters .= ')';
974
+						if (is_array($value))
975
+						{
976
+							$filters .= ')';
977
+						}
942 978
 					}
943 979
 					break;
944 980
 
@@ -954,19 +990,28 @@  discard block
 block discarded – undo
954 990
 							$GLOBALS['egw']->categories = new Api\Categories();
955 991
 						}
956 992
 						$cats = $GLOBALS['egw']->categories->return_all_children((int)$value);
957
-						if (count($cats) > 1) $filters .= '(|';
993
+						if (count($cats) > 1)
994
+						{
995
+							$filters .= '(|';
996
+						}
958 997
 						foreach($cats as $cat)
959 998
 						{
960 999
 							$catName = Api\Translation::convert(
961 1000
 								$GLOBALS['egw']->categories->id2name($cat),$this->charset,'utf-8');
962 1001
 							$filters .= '(category='.Api\Ldap::quote($catName).')';
963 1002
 						}
964
-						if (count($cats) > 1) $filters .= ')';
1003
+						if (count($cats) > 1)
1004
+						{
1005
+							$filters .= ')';
1006
+						}
965 1007
 					}
966 1008
 					break;
967 1009
 
968 1010
 				case 'carddav_name':
969
-					if (!is_array($value)) $value = array($value);
1011
+					if (!is_array($value))
1012
+					{
1013
+						$value = array($value);
1014
+					}
970 1015
 					foreach($value as &$v)
971 1016
 					{
972 1017
 						$v = basename($v, '.vcf');
@@ -1000,7 +1045,10 @@  discard block
 block discarded – undo
1000 1045
 					elseif (preg_match("/^([^ ]+) ".preg_quote($GLOBALS['egw']->db->capabilities[Api\Db::CAPABILITY_CASE_INSENSITIV_LIKE])." '(.*)%'$/",$value,$matches))
1001 1046
 					{
1002 1047
 						list(,$name,$value) = $matches;
1003
-						if (strpos($name,'.') !== false) list(,$name) = explode('.',$name);
1048
+						if (strpos($name,'.') !== false)
1049
+						{
1050
+							list(,$name) = explode('.',$name);
1051
+						}
1004 1052
 						foreach($this->schema2egw as $mapping)
1005 1053
 						{
1006 1054
 							if (isset($mapping[$name]))
@@ -1073,13 +1121,20 @@  discard block
 block discarded – undo
1073 1121
 		{
1074 1122
 			$result = @ldap_list($this->ds, $_ldapContext, $_filter, $_attributes, 0, $this->ldapLimit);
1075 1123
 		}
1076
-		if(!$result || !$entries = ldap_get_entries($this->ds, $result)) return array();
1124
+		if(!$result || !$entries = ldap_get_entries($this->ds, $result))
1125
+		{
1126
+			return array();
1127
+		}
1077 1128
 		//error_log(__METHOD__."('$_ldapContext', '$_filter', ".array2string($_attributes).", $_addressbooktype) result of $entries[count]");
1078 1129
 
1079 1130
 		$this->total = $entries['count'];
1080 1131
 		foreach($entries as $i => $entry)
1081 1132
 		{
1082
-			if (!is_int($i)) continue;	// eg. count
1133
+			if (!is_int($i))
1134
+			{
1135
+				continue;
1136
+			}
1137
+			// eg. count
1083 1138
 
1084 1139
 			$contact = array(
1085 1140
 				'id'  => $entry['uid'][0] ? $entry['uid'][0] : $entry['entryuuid'][0],
@@ -1211,7 +1266,10 @@  discard block
 block discarded – undo
1211 1266
 					$var => $val,
1212 1267
 				);
1213 1268
 				// create a admin connection to add the needed DN
1214
-				if (!isset($adminDS)) $adminDS = Api\Ldap::factory();
1269
+				if (!isset($adminDS))
1270
+				{
1271
+					$adminDS = Api\Ldap::factory();
1272
+				}
1215 1273
 				if(!@ldap_add($adminDS, $dn, $data))
1216 1274
 				{
1217 1275
 					//echo "<p>ldap_add($adminDS,'$dn',".print_r($data,true).")</p>\n";
@@ -1297,11 +1355,17 @@  discard block
 block discarded – undo
1297 1355
 			$contact['cat_id'] = array();
1298 1356
 			foreach($data['category'] as $iii => $cat)
1299 1357
 			{
1300
-				if (!is_int($iii)) continue;
1358
+				if (!is_int($iii))
1359
+				{
1360
+					continue;
1361
+				}
1301 1362
 
1302 1363
 				$contact['cat_id'][] = $GLOBALS['egw']->categories->name2id($cat);
1303 1364
 			}
1304
-			if ($contact['cat_id']) $contact['cat_id'] = implode(',',$contact['cat_id']);
1365
+			if ($contact['cat_id'])
1366
+			{
1367
+				$contact['cat_id'] = implode(',',$contact['cat_id']);
1368
+			}
1305 1369
 		}
1306 1370
 		if ($data['primaryphone'])
1307 1371
 		{
@@ -1356,7 +1420,10 @@  discard block
 block discarded – undo
1356 1420
 	{
1357 1421
 		unset($contact);	// not used, but required by function signature
1358 1422
 		static $shadowExpireNow=null;
1359
-		if (!isset($shadowExpireNow)) $shadowExpireNow = floor((time()-date('Z'))/86400);
1423
+		if (!isset($shadowExpireNow))
1424
+		{
1425
+			$shadowExpireNow = floor((time()-date('Z'))/86400);
1426
+		}
1360 1427
 
1361 1428
 		// exclude expired or deactivated accounts
1362 1429
 		if (isset($data['shadowexpire']) && $data['shadowexpire'][0] <= $shadowExpireNow)
@@ -1401,9 +1468,13 @@  discard block
 block discarded – undo
1401 1468
 		elseif ($data['adr_one_countryname'])
1402 1469
 		{
1403 1470
 			$ldapContact['c'] = Api\Country::country_code($data['adr_one_countryname']);
1404
-			if ($ldapContact['c'] && strlen($ldapContact['c']) > 2)	// Bad countryname when "custom" selected!
1471
+			if ($ldapContact['c'] && strlen($ldapContact['c']) > 2)
1405 1472
 			{
1406
-				$ldapContact['c'] = array(); // should return error...
1473
+				// Bad countryname when "custom" selected!
1474
+			{
1475
+				$ldapContact['c'] = array();
1476
+			}
1477
+			// should return error...
1407 1478
 			}
1408 1479
 		}
1409 1480
 		elseif ($isUpdate)
@@ -1442,14 +1513,21 @@  discard block
 block discarded – undo
1442 1513
 		if ($data['adr_one_countrycode'])
1443 1514
 		{
1444 1515
 			$ldapContact['c'] = $data['adr_one_countrycode'];
1445
-			if ($isUpdate) $ldapContact['co'] = array();
1516
+			if ($isUpdate)
1517
+			{
1518
+				$ldapContact['co'] = array();
1519
+			}
1446 1520
 		}
1447 1521
 		elseif ($data['adr_one_countryname'])
1448 1522
 		{
1449 1523
 			$ldapContact['c'] = Api\Country::country_code($data['adr_one_countryname']);
1450
-			if ($ldapContact['c'] && strlen($ldapContact['c']) > 2)	// Bad countryname when "custom" selected!
1524
+			if ($ldapContact['c'] && strlen($ldapContact['c']) > 2)
1525
+			{
1526
+				// Bad countryname when "custom" selected!
1451 1527
 			{
1452
-				$ldapContact['c'] = array(); // should return error...
1528
+				$ldapContact['c'] = array();
1529
+			}
1530
+			// should return error...
1453 1531
 			}
1454 1532
 		}
1455 1533
 		elseif ($isUpdate)
Please login to merge, or discard this patch.
api/src/Vfs/Sqlfs/StreamWrapper.php 4 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -447,10 +447,10 @@  discard block
 block discarded – undo
447 447
  	 * Important: PHP 5.0 introduced a bug that wasn't fixed until 5.1: the return value has to be the oposite!
448 448
  	 *
449 449
  	 * if(version_compare(PHP_VERSION,'5.0','>=') && version_compare(PHP_VERSION,'5.1','<'))
450
-  	 * {
450
+ 	 * {
451 451
  	 * 		$eof = !$eof;
452 452
  	 * }
453
-  	 *
453
+ 	 *
454 454
  	 * @return boolean true if the read/write position is at the end of the stream and no more data availible, false otherwise
455 455
  	 */
456 456
 	function stream_eof ( )
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
  	 * See fseek() for more information about these parameters.
486 486
  	 *
487 487
  	 * @param integer $offset
488
-  	 * @param integer $whence	SEEK_SET - 0 - Set position equal to offset bytes
488
+ 	 * @param integer $whence	SEEK_SET - 0 - Set position equal to offset bytes
489 489
  	 * 							SEEK_CUR - 1 - Set position to current location plus offset.
490 490
  	 * 							SEEK_END - 2 - Set position to end-of-file plus offset. (To move to a position before the end-of-file, you need to pass a negative value in offset.)
491 491
  	 * @return boolean TRUE if the position was updated, FALSE otherwise.
@@ -681,8 +681,8 @@  discard block
 block discarded – undo
681 681
 		$maxdepth=10;
682 682
 		$depth2propagate = (int)$depth + 1;
683 683
 		if ($depth2propagate > $maxdepth) return is_dir($pathname);
684
-    	is_dir(Vfs::dirname($pathname)) || self::mkdir_recursive(Vfs::dirname($pathname), $mode, $depth2propagate);
685
-    	return is_dir($pathname) || @mkdir($pathname, $mode);
684
+		is_dir(Vfs::dirname($pathname)) || self::mkdir_recursive(Vfs::dirname($pathname), $mode, $depth2propagate);
685
+		return is_dir($pathname) || @mkdir($pathname, $mode);
686 686
 	}
687 687
 
688 688
 	/**
Please login to merge, or discard this patch.
Doc Comments   +7 added lines, -4 removed lines patch added patch discarded remove patch
@@ -504,7 +504,7 @@  discard block
 block discarded – undo
504 504
 	 *
505 505
 	 * If you have cached data in your stream but not yet stored it into the underlying storage, you should do so now.
506 506
 	 *
507
-	 * @return booelan TRUE if the cached data was successfully stored (or if there was no data to store), or FALSE if the data could not be stored.
507
+	 * @return boolean TRUE if the cached data was successfully stored (or if there was no data to store), or FALSE if the data could not be stored.
508 508
 	 */
509 509
 	function stream_flush ( )
510 510
 	{
@@ -673,6 +673,8 @@  discard block
 block discarded – undo
673 673
 
674 674
 	/**
675 675
 	 * due to problems with recursive directory creation, we have our own here
676
+	 * @param false|string $pathname
677
+	 * @param integer $mode
676 678
 	 */
677 679
 	protected static function mkdir_recursive($pathname, $mode, $depth=0)
678 680
 	{
@@ -1058,7 +1060,7 @@  discard block
 block discarded – undo
1058 1060
 	 *
1059 1061
 	 * @param string $url URL that was passed to opendir() and that this object is expected to explore.
1060 1062
 	 * @param int $options
1061
-	 * @return booelan
1063
+	 * @return boolean
1062 1064
 	 */
1063 1065
 	function dir_opendir ( $url, $options )
1064 1066
 	{
@@ -1458,7 +1460,7 @@  discard block
 block discarded – undo
1458 1460
 	 *
1459 1461
 	 * @param string $path string with path
1460 1462
 	 * @param int $rights =null rights to set, or null to delete the entry
1461
-	 * @param int|boolean $owner =null owner for whom to set the rights, null for the current user, or false to delete all rights for $path
1463
+	 * @param boolean $owner =null owner for whom to set the rights, null for the current user, or false to delete all rights for $path
1462 1464
 	 * @param int $fs_id =null fs_id to use, to not query it again (eg. because it's already deleted)
1463 1465
 	 * @return boolean true if acl is set/deleted, false on error
1464 1466
 	 */
@@ -1782,6 +1784,7 @@  discard block
 block discarded – undo
1782 1784
 	 * Replace the password of an url with '...' for error messages
1783 1785
 	 *
1784 1786
 	 * @param string &$url
1787
+	 * @param string $url
1785 1788
 	 */
1786 1789
 	static protected function _remove_password(&$url)
1787 1790
 	{
@@ -1797,7 +1800,7 @@  discard block
 block discarded – undo
1797 1800
 	/**
1798 1801
 	 * Get storage mode from url (get parameter 'storage', eg. ?storage=db)
1799 1802
 	 *
1800
-	 * @param string|array $url complete url or array of url-parts from parse_url
1803
+	 * @param string $url complete url or array of url-parts from parse_url
1801 1804
 	 * @return int self::STORE2FS or self::STORE2DB
1802 1805
 	 */
1803 1806
 	static function url2operation($url)
Please login to merge, or discard this patch.
Spacing   +226 added lines, -228 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 	/**
68 68
 	 * mode-bits, which have to be set for directories
69 69
 	 */
70
-	const MODE_DIR =   040000;
70
+	const MODE_DIR = 040000;
71 71
 	/**
72 72
 	 * mode-bits, which have to be set for links
73 73
 	 */
@@ -169,10 +169,10 @@  discard block
 block discarded – undo
169 169
 	 *
170 170
 	 * @param string $path ='/'
171 171
 	 */
172
-	public static function clearstatcache($path='/')
172
+	public static function clearstatcache($path = '/')
173 173
 	{
174 174
 		//error_log(__METHOD__."('$path')");
175
-		unset($path);	// not used
175
+		unset($path); // not used
176 176
 
177 177
 		self::$stat_cache = array();
178 178
 
@@ -191,32 +191,32 @@  discard block
 block discarded – undo
191 191
 	 * @param string &$opened_path full path of the file/resource, if the open was successfull and STREAM_USE_PATH was set
192 192
 	 * @return boolean true if the ressource was opened successful, otherwise false
193 193
 	 */
194
-	function stream_open ($url, $mode, $options, &$opened_path)
194
+	function stream_open($url, $mode, $options, &$opened_path)
195 195
 	{
196 196
 		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$mode,$options)");
197 197
 
198
-		$path = Vfs::parse_url($url,PHP_URL_PATH);
198
+		$path = Vfs::parse_url($url, PHP_URL_PATH);
199 199
 		$this->operation = self::url2operation($url);
200 200
 		$dir = Vfs::dirname($url);
201 201
 
202 202
 		$this->opened_path = $opened_path = $path;
203
-		$this->opened_mode = $mode = str_replace('b','',$mode);	// we are always binary, like every Linux system
203
+		$this->opened_mode = $mode = str_replace('b', '', $mode); // we are always binary, like every Linux system
204 204
 		$this->opened_stream = null;
205 205
 
206 206
 		parse_str(parse_url($url, PHP_URL_QUERY), $this->dir_url_params);
207 207
 
208
-		if (!is_null($this->overwrite_new) || !($stat = $this->url_stat($path,STREAM_URL_STAT_QUIET)) || $mode[0] == 'x')	// file not found or file should NOT exist
208
+		if (!is_null($this->overwrite_new) || !($stat = $this->url_stat($path, STREAM_URL_STAT_QUIET)) || $mode[0] == 'x')	// file not found or file should NOT exist
209 209
 		{
210
-			if (!$dir || $mode[0] == 'r' ||	// does $mode require the file to exist (r,r+)
211
-				$mode[0] == 'x' && $stat ||	// or file should not exist, but does
212
-				!($dir_stat=$this->url_stat($dir,STREAM_URL_STAT_QUIET)) ||	// or parent dir does not exist																																			create it
213
-				!Vfs::check_access($dir,Vfs::WRITABLE,$dir_stat))	// or we are not allowed to 																																			create it
210
+			if (!$dir || $mode[0] == 'r' || // does $mode require the file to exist (r,r+)
211
+				$mode[0] == 'x' && $stat || // or file should not exist, but does
212
+				!($dir_stat = $this->url_stat($dir, STREAM_URL_STAT_QUIET)) || // or parent dir does not exist																																			create it
213
+				!Vfs::check_access($dir, Vfs::WRITABLE, $dir_stat))	// or we are not allowed to 																																			create it
214 214
 			{
215 215
 				self::_remove_password($url);
216 216
 				if (self::LOG_LEVEL) error_log(__METHOD__."($url,$mode,$options) file does not exist or can not be created!");
217
-				if (($options & STREAM_REPORT_ERRORS))
217
+				if (($options&STREAM_REPORT_ERRORS))
218 218
 				{
219
-					trigger_error(__METHOD__."($url,$mode,$options) file does not exist or can not be created!",E_USER_WARNING);
219
+					trigger_error(__METHOD__."($url,$mode,$options) file does not exist or can not be created!", E_USER_WARNING);
220 220
 				}
221 221
 				$this->opened_stream = $this->opened_path = $this->opened_mode = null;
222 222
 				return false;
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 				'fs_name' => self::limit_filename(Vfs::basename($path)),
232 232
 				'fs_dir'  => $dir_stat['ino'],
233 233
 				// we use the mode of the dir, so files in group dirs stay accessible by all members
234
-				'fs_mode' => $dir_stat['mode'] & 0666,
234
+				'fs_mode' => $dir_stat['mode']&0666,
235 235
 				// for the uid we use the uid of the dir if not 0=root or the current user otherwise
236 236
 				'fs_uid'  => $dir_stat['uid'] ? $dir_stat['uid'] : Vfs::$user,
237 237
 				// we allways use the group of the dir
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 				'fs_created'  => self::_pdo_timestamp(time()),
240 240
 				'fs_modified' => self::_pdo_timestamp(time()),
241 241
 				'fs_creator'  => Vfs::$user,
242
-				'fs_mime'     => 'application/octet-stream',	// required NOT NULL!
242
+				'fs_mime'     => 'application/octet-stream', // required NOT NULL!
243 243
 				'fs_size'     => 0,
244 244
 				'fs_active'   => self::_pdo_boolean(true),
245 245
 			);
@@ -256,35 +256,35 @@  discard block
 block discarded – undo
256 256
 				$this->opened_stream = tmpfile();
257 257
 			}
258 258
 			// create the hash-dirs, if they not yet exist
259
-			elseif(!file_exists($fs_dir=Vfs::dirname(self::_fs_path($this->opened_fs_id))))
259
+			elseif (!file_exists($fs_dir = Vfs::dirname(self::_fs_path($this->opened_fs_id))))
260 260
 			{
261 261
 				$umaskbefore = umask();
262 262
 				if (self::LOG_LEVEL > 1) error_log(__METHOD__." about to call mkdir for $fs_dir # Present UMASK:".decoct($umaskbefore)." called from:".function_backtrace());
263
-				self::mkdir_recursive($fs_dir,0700,true);
263
+				self::mkdir_recursive($fs_dir, 0700, true);
264 264
 			}
265 265
 		}
266 266
 		// check if opend file is a directory
267
-		elseif($stat && ($stat['mode'] & self::MODE_DIR) == self::MODE_DIR)
267
+		elseif ($stat && ($stat['mode']&self::MODE_DIR) == self::MODE_DIR)
268 268
 		{
269 269
 				if (self::LOG_LEVEL) error_log(__METHOD__."($url,$mode,$options) Is a directory!");
270
-				if (($options & STREAM_REPORT_ERRORS))
270
+				if (($options&STREAM_REPORT_ERRORS))
271 271
 				{
272
-					trigger_error(__METHOD__."($url,$mode,$options) Is a directory!",E_USER_WARNING);
272
+					trigger_error(__METHOD__."($url,$mode,$options) Is a directory!", E_USER_WARNING);
273 273
 				}
274 274
 				$this->opened_stream = $this->opened_path = $this->opened_mode = null;
275 275
 				return false;
276 276
 		}
277 277
 		else
278 278
 		{
279
-			if ($mode == 'r' && !Vfs::check_access($url,Vfs::READABLE ,$stat) ||// we are not allowed to read
280
-				$mode != 'r' && !Vfs::check_access($url,Vfs::WRITABLE,$stat))	// or edit it
279
+			if ($mode == 'r' && !Vfs::check_access($url, Vfs::READABLE, $stat) || // we are not allowed to read
280
+				$mode != 'r' && !Vfs::check_access($url, Vfs::WRITABLE, $stat))	// or edit it
281 281
 			{
282 282
 				self::_remove_password($url);
283 283
 				$op = $mode == 'r' ? 'read' : 'edited';
284 284
 				if (self::LOG_LEVEL) error_log(__METHOD__."($url,$mode,$options) file can not be $op!");
285
-				if (($options & STREAM_REPORT_ERRORS))
285
+				if (($options&STREAM_REPORT_ERRORS))
286 286
 				{
287
-					trigger_error(__METHOD__."($url,$mode,$options) file can not be $op!",E_USER_WARNING);
287
+					trigger_error(__METHOD__."($url,$mode,$options) file can not be $op!", E_USER_WARNING);
288 288
 				}
289 289
 				$this->opened_stream = $this->opened_path = $this->opened_mode = null;
290 290
 				return false;
@@ -293,9 +293,9 @@  discard block
 block discarded – undo
293 293
 
294 294
 			if ($this->operation == self::STORE2DB)
295 295
 			{
296
-				$stmt = self::$pdo->prepare($sql='SELECT fs_content FROM '.self::TABLE.' WHERE fs_id=?');
296
+				$stmt = self::$pdo->prepare($sql = 'SELECT fs_content FROM '.self::TABLE.' WHERE fs_id=?');
297 297
 				$stmt->execute(array($stat['ino']));
298
-				$stmt->bindColumn(1,$this->opened_stream,\PDO::PARAM_LOB);
298
+				$stmt->bindColumn(1, $this->opened_stream, \PDO::PARAM_LOB);
299 299
 				$stmt->fetch(\PDO::FETCH_BOUND);
300 300
 				// hack to work around a current php bug (http://bugs.php.net/bug.php?id=40913)
301 301
 				// PDOStatement::bindColumn(,,\PDO::PARAM_LOB) is not working for MySQL, content is returned as string :-(
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 		if ($this->operation == self::STORE2FS)
315 315
 		{
316 316
 			if (self::LOG_LEVEL > 1) error_log(__METHOD__." fopen (may create a directory? mkdir) ($this->opened_fs_id,$mode,$options)");
317
-			if (!($this->opened_stream = fopen(self::_fs_path($this->opened_fs_id),$mode)) && $new_file)
317
+			if (!($this->opened_stream = fopen(self::_fs_path($this->opened_fs_id), $mode)) && $new_file)
318 318
 			{
319 319
 				// delete db entry again, if we are not able to open a new(!) file
320 320
 				unset($stmt);
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 		}
325 325
 		if ($mode[0] == 'a')	// append modes: a, a+
326 326
 		{
327
-			$this->stream_seek(0,SEEK_END);
327
+			$this->stream_seek(0, SEEK_END);
328 328
 		}
329 329
 		if (!is_resource($this->opened_stream)) error_log(__METHOD__."($url,$mode,$options) NO stream, returning false!");
330 330
 
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
 	 *
337 337
 	 * You must release any resources that were locked or allocated by the stream.
338 338
 	 */
339
-	function stream_close ( )
339
+	function stream_close( )
340 340
 	{
341 341
 		if (self::LOG_LEVEL > 1) error_log(__METHOD__."()");
342 342
 
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
 
348 348
 		if ($this->opened_mode != 'r')
349 349
 		{
350
-			$this->stream_seek(0,SEEK_END);
350
+			$this->stream_seek(0, SEEK_END);
351 351
 
352 352
 			// we need to update the mime-type, size and content (if STORE2DB)
353 353
 			$values = array(
@@ -370,10 +370,10 @@  discard block
 block discarded – undo
370 370
 			else
371 371
 			{
372 372
 				$stmt = self::$pdo->prepare('UPDATE '.self::TABLE.' SET fs_size=:fs_size,fs_mime=:fs_mime,fs_modifier=:fs_modifier,fs_modified=:fs_modified,fs_content=:fs_content WHERE fs_id=:fs_id');
373
-				$this->stream_seek(0,SEEK_SET);	// rewind to the start
374
-				foreach($values as $name => &$value)
373
+				$this->stream_seek(0, SEEK_SET); // rewind to the start
374
+				foreach ($values as $name => &$value)
375 375
 				{
376
-					$stmt->bindParam($name,$value);
376
+					$stmt->bindParam($name, $value);
377 377
 				}
378 378
 				$stmt->bindParam('fs_content', $this->opened_stream, \PDO::PARAM_LOB);
379 379
 				if (!($ret = $stmt->execute()))
@@ -406,13 +406,13 @@  discard block
 block discarded – undo
406 406
 	 * @param int $count
407 407
 	 * @return string/false up to count bytes read or false on EOF
408 408
 	 */
409
-	function stream_read ( $count )
409
+	function stream_read($count)
410 410
 	{
411 411
 		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($count) pos=$this->opened_pos");
412 412
 
413 413
 		if (is_resource($this->opened_stream))
414 414
 		{
415
-			return fread($this->opened_stream,$count);
415
+			return fread($this->opened_stream, $count);
416 416
 		}
417 417
 		return false;
418 418
 	}
@@ -428,13 +428,13 @@  discard block
 block discarded – undo
428 428
 	 * @param string $data
429 429
 	 * @return integer
430 430
 	 */
431
-	function stream_write ( $data )
431
+	function stream_write($data)
432 432
 	{
433 433
 		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($data)");
434 434
 
435 435
 		if (is_resource($this->opened_stream))
436 436
 		{
437
-			return fwrite($this->opened_stream,$data);
437
+			return fwrite($this->opened_stream, $data);
438 438
 		}
439 439
 		return false;
440 440
 	}
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
   	 *
452 452
  	 * @return boolean true if the read/write position is at the end of the stream and no more data availible, false otherwise
453 453
  	 */
454
-	function stream_eof ( )
454
+	function stream_eof( )
455 455
 	{
456 456
 		if (is_resource($this->opened_stream))
457 457
 		{
@@ -465,7 +465,7 @@  discard block
 block discarded – undo
465 465
 	 *
466 466
 	 * @return integer current read/write position of the stream
467 467
 	 */
468
- 	function stream_tell ( )
468
+ 	function stream_tell( )
469 469
  	{
470 470
 		if (self::LOG_LEVEL > 1) error_log(__METHOD__."()");
471 471
 
@@ -488,13 +488,13 @@  discard block
 block discarded – undo
488 488
  	 * 							SEEK_END - 2 - Set position to end-of-file plus offset. (To move to a position before the end-of-file, you need to pass a negative value in offset.)
489 489
  	 * @return boolean TRUE if the position was updated, FALSE otherwise.
490 490
  	 */
491
-	function stream_seek ( $offset, $whence )
491
+	function stream_seek($offset, $whence)
492 492
 	{
493 493
 		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($offset,$whence)");
494 494
 
495 495
 		if (is_resource($this->opened_stream))
496 496
 		{
497
-			return !fseek($this->opened_stream,$offset,$whence);	// fseek returns 0 on success and -1 on failure
497
+			return !fseek($this->opened_stream, $offset, $whence); // fseek returns 0 on success and -1 on failure
498 498
 		}
499 499
 		return false;
500 500
 	}
@@ -506,7 +506,7 @@  discard block
 block discarded – undo
506 506
 	 *
507 507
 	 * @return booelan TRUE if the cached data was successfully stored (or if there was no data to store), or FALSE if the data could not be stored.
508 508
 	 */
509
-	function stream_flush ( )
509
+	function stream_flush( )
510 510
 	{
511 511
 		if (self::LOG_LEVEL > 1) error_log(__METHOD__."()");
512 512
 
@@ -531,11 +531,11 @@  discard block
 block discarded – undo
531 531
 	 *
532 532
 	 * @return array containing the same values as appropriate for the stream.
533 533
 	 */
534
-	function stream_stat ( )
534
+	function stream_stat( )
535 535
 	{
536 536
 		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($this->opened_path)");
537 537
 
538
-		return $this->url_stat($this->opened_path,0);
538
+		return $this->url_stat($this->opened_path, 0);
539 539
 	}
540 540
 
541 541
 	/**
@@ -547,28 +547,28 @@  discard block
 block discarded – undo
547 547
 	 * @param string $url
548 548
 	 * @return boolean TRUE on success or FALSE on failure
549 549
 	 */
550
-	function unlink ( $url )
550
+	function unlink($url)
551 551
 	{
552 552
 		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url)");
553 553
 
554
-		$path = Vfs::parse_url($url,PHP_URL_PATH);
554
+		$path = Vfs::parse_url($url, PHP_URL_PATH);
555 555
 
556 556
 		// need to get parent stat from Sqlfs, not Vfs
557 557
 		$parent_stat = !($dir = Vfs::dirname($path)) ? false :
558 558
 			$this->url_stat($dir, STREAM_URL_STAT_LINK);
559 559
 
560
-		if (!$parent_stat || !($stat = $this->url_stat($path,STREAM_URL_STAT_LINK)) ||
560
+		if (!$parent_stat || !($stat = $this->url_stat($path, STREAM_URL_STAT_LINK)) ||
561 561
 			!$dir || !Vfs::check_access($dir, Vfs::WRITABLE, $parent_stat))
562 562
 		{
563 563
 			self::_remove_password($url);
564 564
 			if (self::LOG_LEVEL) error_log(__METHOD__."($url) permission denied!");
565
-			return false;	// no permission or file does not exist
565
+			return false; // no permission or file does not exist
566 566
 		}
567 567
 		if ($stat['mime'] == self::DIR_MIME_TYPE)
568 568
 		{
569 569
 			self::_remove_password($url);
570 570
 			if (self::LOG_LEVEL) error_log(__METHOD__."($url) is NO file!");
571
-			return false;	// no permission or file does not exist
571
+			return false; // no permission or file does not exist
572 572
 		}
573 573
 		$stmt = self::$pdo->prepare('DELETE FROM '.self::TABLE.' WHERE fs_id=:fs_id');
574 574
 		unset(self::$stat_cache[$path]);
@@ -576,7 +576,7 @@  discard block
 block discarded – undo
576 576
 		if (($ret = $stmt->execute(array('fs_id' => $stat['ino']))))
577 577
 		{
578 578
 			if (self::url2operation($url) == self::STORE2FS &&
579
-				($stat['mode'] & self::MODE_LINK) != self::MODE_LINK)
579
+				($stat['mode']&self::MODE_LINK) != self::MODE_LINK)
580 580
 			{
581 581
 				unlink(self::_fs_path($stat['ino']));
582 582
 			}
@@ -600,13 +600,13 @@  discard block
 block discarded – undo
600 600
 	 * @param string $url_to
601 601
 	 * @return boolean TRUE on success or FALSE on failure
602 602
 	 */
603
-	function rename ( $url_from, $url_to)
603
+	function rename($url_from, $url_to)
604 604
 	{
605 605
 		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url_from,$url_to)");
606 606
 
607
-		$path_from = Vfs::parse_url($url_from,PHP_URL_PATH);
607
+		$path_from = Vfs::parse_url($url_from, PHP_URL_PATH);
608 608
 		$from_dir = Vfs::dirname($path_from);
609
-		$path_to = Vfs::parse_url($url_to,PHP_URL_PATH);
609
+		$path_to = Vfs::parse_url($url_to, PHP_URL_PATH);
610 610
 		$to_dir = Vfs::dirname($path_to);
611 611
 
612 612
 		if (!($from_stat = $this->url_stat($path_from, 0)) || !$from_dir ||
@@ -615,14 +615,14 @@  discard block
 block discarded – undo
615 615
 			self::_remove_password($url_from);
616 616
 			self::_remove_password($url_to);
617 617
 			if (self::LOG_LEVEL) error_log(__METHOD__."($url_from,$url_to): $path_from permission denied!");
618
-			return false;	// no permission or file does not exist
618
+			return false; // no permission or file does not exist
619 619
 		}
620 620
 		if (!$to_dir || !Vfs::check_access($to_dir, Vfs::WRITABLE, $to_dir_stat = $this->url_stat($to_dir, 0)))
621 621
 		{
622 622
 			self::_remove_password($url_from);
623 623
 			self::_remove_password($url_to);
624 624
 			if (self::LOG_LEVEL) error_log(__METHOD__."($url_from,$url_to): $path_to permission denied!");
625
-			return false;	// no permission or parent-dir does not exist
625
+			return false; // no permission or parent-dir does not exist
626 626
 		}
627 627
 		// the filesystem stream-wrapper does NOT allow to rename files to directories, as this makes problems
628 628
 		// for our vfs too, we abort here with an error, like the filesystem one does
@@ -633,7 +633,7 @@  discard block
 block discarded – undo
633 633
 			self::_remove_password($url_to);
634 634
 			$is_dir = $to_stat['mime'] === self::DIR_MIME_TYPE ? 'a' : 'no';
635 635
 			if (self::LOG_LEVEL) error_log(__METHOD__."($url_to,$url_from) $path_to is $is_dir directory!");
636
-			return false;	// no permission or file does not exist
636
+			return false; // no permission or file does not exist
637 637
 		}
638 638
 		// if destination file already exists, delete it
639 639
 		if ($to_stat && !$this->unlink($url_to))
@@ -657,7 +657,7 @@  discard block
 block discarded – undo
657 657
 
658 658
 		// check if extension changed and update mime-type in that case (as we currently determine mime-type by it's extension!)
659 659
 		// fixes eg. problems with MsWord storing file with .tmp extension and then renaming to .doc
660
-		if ($ok && ($new_mime = Vfs::mime_content_type($url_to,true)) != Vfs::mime_content_type($url_to))
660
+		if ($ok && ($new_mime = Vfs::mime_content_type($url_to, true)) != Vfs::mime_content_type($url_to))
661 661
 		{
662 662
 			//echo "<p>Vfs::nime_content_type($url_to,true) = $new_mime</p>\n";
663 663
 			$stmt = self::$pdo->prepare('UPDATE '.self::TABLE.' SET fs_mime=:fs_mime WHERE fs_id=:fs_id');
@@ -673,9 +673,9 @@  discard block
 block discarded – undo
673 673
 	/**
674 674
 	 * due to problems with recursive directory creation, we have our own here
675 675
 	 */
676
-	protected static function mkdir_recursive($pathname, $mode, $depth=0)
676
+	protected static function mkdir_recursive($pathname, $mode, $depth = 0)
677 677
 	{
678
-		$maxdepth=10;
678
+		$maxdepth = 10;
679 679
 		$depth2propagate = (int)$depth + 1;
680 680
 		if ($depth2propagate > $maxdepth) return is_dir($pathname);
681 681
     	is_dir(Vfs::dirname($pathname)) || self::mkdir_recursive(Vfs::dirname($pathname), $mode, $depth2propagate);
@@ -693,19 +693,19 @@  discard block
 block discarded – undo
693 693
 	 * @param int $options Posible values include STREAM_REPORT_ERRORS and STREAM_MKDIR_RECURSIVE
694 694
 	 * @return boolean TRUE on success or FALSE on failure
695 695
 	 */
696
-	function mkdir ( $url, $mode, $options )
696
+	function mkdir($url, $mode, $options)
697 697
 	{
698 698
 		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$mode,$options)");
699 699
 		if (self::LOG_LEVEL > 1) error_log(__METHOD__." called from:".function_backtrace());
700
-		$path = Vfs::parse_url($url,PHP_URL_PATH);
700
+		$path = Vfs::parse_url($url, PHP_URL_PATH);
701 701
 
702
-		if ($this->url_stat($path,STREAM_URL_STAT_QUIET))
702
+		if ($this->url_stat($path, STREAM_URL_STAT_QUIET))
703 703
 		{
704 704
 			self::_remove_password($url);
705 705
 			if (self::LOG_LEVEL) error_log(__METHOD__."('$url',$mode,$options) already exist!");
706
-			if (!($options & STREAM_REPORT_ERRORS))
706
+			if (!($options&STREAM_REPORT_ERRORS))
707 707
 			{
708
-				trigger_error(__METHOD__."('$url',$mode,$options) already exist!",E_USER_WARNING);
708
+				trigger_error(__METHOD__."('$url',$mode,$options) already exist!", E_USER_WARNING);
709 709
 			}
710 710
 			return false;
711 711
 		}
@@ -713,35 +713,35 @@  discard block
 block discarded – undo
713 713
 		{
714 714
 			self::_remove_password($url);
715 715
 			if (self::LOG_LEVEL) error_log(__METHOD__."('$url',$mode,$options) dirname('$path')===false!");
716
-			if (!($options & STREAM_REPORT_ERRORS))
716
+			if (!($options&STREAM_REPORT_ERRORS))
717 717
 			{
718 718
 				trigger_error(__METHOD__."('$url',$mode,$options) dirname('$path')===false!", E_USER_WARNING);
719 719
 			}
720 720
 			return false;
721 721
 		}
722
-		if (($query = Vfs::parse_url($url,PHP_URL_QUERY))) $parent_path .= '?'.$query;
723
-		$parent = $this->url_stat($parent_path,STREAM_URL_STAT_QUIET);
722
+		if (($query = Vfs::parse_url($url, PHP_URL_QUERY))) $parent_path .= '?'.$query;
723
+		$parent = $this->url_stat($parent_path, STREAM_URL_STAT_QUIET);
724 724
 
725 725
 		// check if we should also create all non-existing path components and our parent does not exist,
726 726
 		// if yes call ourself recursive with the parent directory
727
-		if (($options & STREAM_MKDIR_RECURSIVE) && $parent_path != '/' && !$parent)
727
+		if (($options&STREAM_MKDIR_RECURSIVE) && $parent_path != '/' && !$parent)
728 728
 		{
729 729
 			if (self::LOG_LEVEL > 1) error_log(__METHOD__." creating parents: $parent_path, $mode");
730
-			if (!$this->mkdir($parent_path,$mode,$options))
730
+			if (!$this->mkdir($parent_path, $mode, $options))
731 731
 			{
732 732
 				return false;
733 733
 			}
734
-			$parent = $this->url_stat($parent_path,0);
734
+			$parent = $this->url_stat($parent_path, 0);
735 735
 		}
736
-		if (!$parent || !Vfs::check_access($parent_path,Vfs::WRITABLE,$parent))
736
+		if (!$parent || !Vfs::check_access($parent_path, Vfs::WRITABLE, $parent))
737 737
 		{
738 738
 			self::_remove_password($url);
739 739
 			if (self::LOG_LEVEL) error_log(__METHOD__."('$url',$mode,$options) permission denied!");
740
-			if (!($options & STREAM_REPORT_ERRORS))
740
+			if (!($options&STREAM_REPORT_ERRORS))
741 741
 			{
742
-				trigger_error(__METHOD__."('$url',$mode,$options) permission denied!",E_USER_WARNING);
742
+				trigger_error(__METHOD__."('$url',$mode,$options) permission denied!", E_USER_WARNING);
743 743
 			}
744
-			return false;	// no permission or file does not exist
744
+			return false; // no permission or file does not exist
745 745
 		}
746 746
 		unset(self::$stat_cache[$path]);
747 747
 		$stmt = self::$pdo->prepare('INSERT INTO '.self::TABLE.' (fs_name,fs_dir,fs_mode,fs_uid,fs_gid,fs_size,fs_mime,fs_created,fs_modified,fs_creator'.
@@ -762,9 +762,9 @@  discard block
 block discarded – undo
762 762
 			// check if some other process created the directory parallel to us (sqlfs would gives SQL errors later!)
763 763
 			$new_fs_id = self::$pdo->lastInsertId('egw_sqlfs_fs_id_seq');
764 764
 
765
-			unset($stmt);	// free statement object, on some installs a new prepare fails otherwise!
765
+			unset($stmt); // free statement object, on some installs a new prepare fails otherwise!
766 766
 
767
-			$stmt = self::$pdo->prepare($q='SELECT COUNT(*) FROM '.self::TABLE.
767
+			$stmt = self::$pdo->prepare($q = 'SELECT COUNT(*) FROM '.self::TABLE.
768 768
 				' WHERE fs_dir=:fs_dir AND fs_active=:fs_active AND fs_name'.self::$case_sensitive_equal.':fs_name');
769 769
 			if ($stmt->execute(array(
770 770
 				'fs_dir'  => $parent['ino'],
@@ -788,25 +788,24 @@  discard block
 block discarded – undo
788 788
 	 * @param int $options Possible values include STREAM_REPORT_ERRORS.
789 789
 	 * @return boolean TRUE on success or FALSE on failure.
790 790
 	 */
791
-	function rmdir ( $url, $options )
791
+	function rmdir($url, $options)
792 792
 	{
793 793
 		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url)");
794 794
 
795
-		$path = Vfs::parse_url($url,PHP_URL_PATH);
795
+		$path = Vfs::parse_url($url, PHP_URL_PATH);
796 796
 
797 797
 		if (!($parent = Vfs::dirname($path)) ||
798 798
 			!($stat = $this->url_stat($path, 0)) || $stat['mime'] != self::DIR_MIME_TYPE ||
799
-			!Vfs::check_access($parent, Vfs::WRITABLE, $this->url_stat($parent,0)))
799
+			!Vfs::check_access($parent, Vfs::WRITABLE, $this->url_stat($parent, 0)))
800 800
 		{
801 801
 			self::_remove_password($url);
802
-			$err_msg = __METHOD__."($url,$options) ".(!$stat ? 'not found!' :
803
-				($stat['mime'] != self::DIR_MIME_TYPE ? 'not a directory!' : 'permission denied!'));
802
+			$err_msg = __METHOD__."($url,$options) ".(!$stat ? 'not found!' : ($stat['mime'] != self::DIR_MIME_TYPE ? 'not a directory!' : 'permission denied!'));
804 803
 			if (self::LOG_LEVEL) error_log($err_msg);
805
-			if (!($options & STREAM_REPORT_ERRORS))
804
+			if (!($options&STREAM_REPORT_ERRORS))
806 805
 			{
807
-				trigger_error($err_msg,E_USER_WARNING);
806
+				trigger_error($err_msg, E_USER_WARNING);
808 807
 			}
809
-			return false;	// no permission or file does not exist
808
+			return false; // no permission or file does not exist
810 809
 		}
811 810
 		$stmt = self::$pdo->prepare('SELECT COUNT(*) FROM '.self::TABLE.' WHERE fs_dir=?');
812 811
 		$stmt->execute(array($stat['ino']));
@@ -814,19 +813,19 @@  discard block
 block discarded – undo
814 813
 		{
815 814
 			self::_remove_password($url);
816 815
 			if (self::LOG_LEVEL) error_log(__METHOD__."($url,$options) dir is not empty!");
817
-			if (!($options & STREAM_REPORT_ERRORS))
816
+			if (!($options&STREAM_REPORT_ERRORS))
818 817
 			{
819
-				trigger_error(__METHOD__."('$url',$options) dir is not empty!",E_USER_WARNING);
818
+				trigger_error(__METHOD__."('$url',$options) dir is not empty!", E_USER_WARNING);
820 819
 			}
821 820
 			return false;
822 821
 		}
823 822
 		unset(self::$stat_cache[$path]);
824
-		unset($stmt);	// free statement object, on some installs a new prepare fails otherwise!
823
+		unset($stmt); // free statement object, on some installs a new prepare fails otherwise!
825 824
 
826 825
 		$del_stmt = self::$pdo->prepare('DELETE FROM '.self::TABLE.' WHERE fs_id=?');
827 826
 		if (($ret = $del_stmt->execute(array($stat['ino']))))
828 827
 		{
829
-			self::eacl($path,null,false,$stat['ino']);	// remove all (=false) evtl. existing extended acl for that dir
828
+			self::eacl($path, null, false, $stat['ino']); // remove all (=false) evtl. existing extended acl for that dir
830 829
 			// delete props
831 830
 			unset($del_stmt);
832 831
 			$del_stmt = self::$pdo->prepare('DELETE FROM '.self::PROPS_TABLE.' WHERE fs_id=?');
@@ -853,10 +852,10 @@  discard block
 block discarded – undo
853 852
 	{
854 853
 		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($path, $option, ".array2string($value).")");
855 854
 
856
-		switch($option)
855
+		switch ($option)
857 856
 		{
858 857
 			case STREAM_META_TOUCH:
859
-				return $this->touch($path, $value[0]);	// atime is not supported
858
+				return $this->touch($path, $value[0]); // atime is not supported
860 859
 
861 860
 			case STREAM_META_ACCESS:
862 861
 				return $this->chmod($path, $value);
@@ -885,26 +884,26 @@  discard block
 block discarded – undo
885 884
 	 * @param int $time =null modification time (unix timestamp), default null = current time
886 885
 	 * @param int $atime =null access time (unix timestamp), default null = current time, not implemented in the vfs!
887 886
 	 */
888
-	protected function touch($url,$time=null,$atime=null)
887
+	protected function touch($url, $time = null, $atime = null)
889 888
 	{
890
-		unset($atime);	// not used
889
+		unset($atime); // not used
891 890
 		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url, $time)");
892 891
 
893
-		$path = Vfs::parse_url($url,PHP_URL_PATH);
892
+		$path = Vfs::parse_url($url, PHP_URL_PATH);
894 893
 
895 894
 		$vfs = new self();
896
-		if (!($stat = $vfs->url_stat($path,STREAM_URL_STAT_QUIET)))
895
+		if (!($stat = $vfs->url_stat($path, STREAM_URL_STAT_QUIET)))
897 896
 		{
898 897
 			// file does not exist --> create an empty one
899
-			if (!($f = fopen(self::SCHEME.'://default'.$path,'w')) || !fclose($f))
898
+			if (!($f = fopen(self::SCHEME.'://default'.$path, 'w')) || !fclose($f))
900 899
 			{
901 900
 				return false;
902 901
 			}
903 902
 			if (!$time)
904 903
 			{
905
-				return true;	// new (empty) file created with current mod time
904
+				return true; // new (empty) file created with current mod time
906 905
 			}
907
-			$stat = $vfs->url_stat($path,0);
906
+			$stat = $vfs->url_stat($path, 0);
908 907
 		}
909 908
 		unset(self::$stat_cache[$path]);
910 909
 		$stmt = self::$pdo->prepare('UPDATE '.self::TABLE.' SET fs_modified=:fs_modified,fs_modifier=:fs_modifier WHERE fs_id=:fs_id');
@@ -923,40 +922,40 @@  discard block
 block discarded – undo
923 922
 	 * @param int $owner
924 923
 	 * @return boolean
925 924
 	 */
926
-	protected function chown($url,$owner)
925
+	protected function chown($url, $owner)
927 926
 	{
928 927
 		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$owner)");
929 928
 
930
-		$path = Vfs::parse_url($url,PHP_URL_PATH);
929
+		$path = Vfs::parse_url($url, PHP_URL_PATH);
931 930
 
932 931
 		$vfs = new self();
933
-		if (!($stat = $vfs->url_stat($path,0)))
932
+		if (!($stat = $vfs->url_stat($path, 0)))
934 933
 		{
935 934
 			if (self::LOG_LEVEL) error_log(__METHOD__."($url,$owner) no such file or directory!");
936
-			trigger_error("No such file or directory $url !",E_USER_WARNING);
935
+			trigger_error("No such file or directory $url !", E_USER_WARNING);
937 936
 			return false;
938 937
 		}
939 938
 		if (!Vfs::$is_root)
940 939
 		{
941 940
 			if (self::LOG_LEVEL) error_log(__METHOD__."($url,$owner) only root can do that!");
942
-			trigger_error("Only root can do that!",E_USER_WARNING);
941
+			trigger_error("Only root can do that!", E_USER_WARNING);
943 942
 			return false;
944 943
 		}
945 944
 		if ($owner < 0 || $owner && !$GLOBALS['egw']->accounts->id2name($owner))	// not a user (0 == root)
946 945
 		{
947 946
 			if (self::LOG_LEVEL) error_log(__METHOD__."($url,$owner) unknown (numeric) user id!");
948
-			trigger_error(__METHOD__."($url,$owner) Unknown (numeric) user id!",E_USER_WARNING);
947
+			trigger_error(__METHOD__."($url,$owner) Unknown (numeric) user id!", E_USER_WARNING);
949 948
 			//throw new Exception(__METHOD__."($url,$owner) Unknown (numeric) user id!");
950 949
 			return false;
951 950
 		}
952 951
 		$stmt = self::$pdo->prepare('UPDATE '.self::TABLE.' SET fs_uid=:fs_uid WHERE fs_id=:fs_id');
953 952
 
954 953
 		// update stat-cache
955
-		if ($path != '/' && substr($path,-1) == '/') $path = substr($path, 0, -1);
954
+		if ($path != '/' && substr($path, -1) == '/') $path = substr($path, 0, -1);
956 955
 		self::$stat_cache[$path]['fs_uid'] = $owner;
957 956
 
958 957
 		return $stmt->execute(array(
959
-			'fs_uid' => (int) $owner,
958
+			'fs_uid' => (int)$owner,
960 959
 			'fs_id' => $stat['ino'],
961 960
 		));
962 961
 	}
@@ -968,37 +967,37 @@  discard block
 block discarded – undo
968 967
 	 * @param int $owner
969 968
 	 * @return boolean
970 969
 	 */
971
-	protected function chgrp($url,$owner)
970
+	protected function chgrp($url, $owner)
972 971
 	{
973 972
 		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$owner)");
974 973
 
975
-		$path = Vfs::parse_url($url,PHP_URL_PATH);
974
+		$path = Vfs::parse_url($url, PHP_URL_PATH);
976 975
 
977 976
 		$vfs = new self();
978
-		if (!($stat = $vfs->url_stat($path,0)))
977
+		if (!($stat = $vfs->url_stat($path, 0)))
979 978
 		{
980 979
 			if (self::LOG_LEVEL) error_log(__METHOD__."($url,$owner) no such file or directory!");
981
-			trigger_error("No such file or directory $url !",E_USER_WARNING);
980
+			trigger_error("No such file or directory $url !", E_USER_WARNING);
982 981
 			return false;
983 982
 		}
984
-		if (!Vfs::has_owner_rights($path,$stat))
983
+		if (!Vfs::has_owner_rights($path, $stat))
985 984
 		{
986 985
 			if (self::LOG_LEVEL) error_log(__METHOD__."($url,$owner) only owner or root can do that!");
987
-			trigger_error("Only owner or root can do that!",E_USER_WARNING);
986
+			trigger_error("Only owner or root can do that!", E_USER_WARNING);
988 987
 			return false;
989 988
 		}
990
-		if ($owner < 0) $owner = -$owner;	// sqlfs uses a positiv group id's!
989
+		if ($owner < 0) $owner = -$owner; // sqlfs uses a positiv group id's!
991 990
 
992 991
 		if ($owner && !$GLOBALS['egw']->accounts->id2name(-$owner))	// not a group
993 992
 		{
994 993
 			if (self::LOG_LEVEL) error_log(__METHOD__."($url,$owner) unknown (numeric) group id!");
995
-			trigger_error("Unknown (numeric) group id!",E_USER_WARNING);
994
+			trigger_error("Unknown (numeric) group id!", E_USER_WARNING);
996 995
 			return false;
997 996
 		}
998 997
 		$stmt = self::$pdo->prepare('UPDATE '.self::TABLE.' SET fs_gid=:fs_gid WHERE fs_id=:fs_id');
999 998
 
1000 999
 		// update stat-cache
1001
-		if ($path != '/' && substr($path,-1) == '/') $path = substr($path, 0, -1);
1000
+		if ($path != '/' && substr($path, -1) == '/') $path = substr($path, 0, -1);
1002 1001
 		self::$stat_cache[$path]['fs_gid'] = $owner;
1003 1002
 
1004 1003
 		return $stmt->execute(array(
@@ -1014,39 +1013,39 @@  discard block
 block discarded – undo
1014 1013
 	 * @param int $mode
1015 1014
 	 * @return boolean
1016 1015
 	 */
1017
-	protected function chmod($url,$mode)
1016
+	protected function chmod($url, $mode)
1018 1017
 	{
1019 1018
 		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url, $mode)");
1020 1019
 
1021
-		$path = Vfs::parse_url($url,PHP_URL_PATH);
1020
+		$path = Vfs::parse_url($url, PHP_URL_PATH);
1022 1021
 
1023 1022
 		$vfs = new self();
1024
-		if (!($stat = $vfs->url_stat($path,0)))
1023
+		if (!($stat = $vfs->url_stat($path, 0)))
1025 1024
 		{
1026 1025
 			if (self::LOG_LEVEL) error_log(__METHOD__."($url, $mode) no such file or directory!");
1027
-			trigger_error("No such file or directory $url !",E_USER_WARNING);
1026
+			trigger_error("No such file or directory $url !", E_USER_WARNING);
1028 1027
 			return false;
1029 1028
 		}
1030
-		if (!Vfs::has_owner_rights($path,$stat))
1029
+		if (!Vfs::has_owner_rights($path, $stat))
1031 1030
 		{
1032 1031
 			if (self::LOG_LEVEL) error_log(__METHOD__."($url, $mode) only owner or root can do that!");
1033
-			trigger_error("Only owner or root can do that!",E_USER_WARNING);
1032
+			trigger_error("Only owner or root can do that!", E_USER_WARNING);
1034 1033
 			return false;
1035 1034
 		}
1036 1035
 		if (!is_numeric($mode))	// not a mode
1037 1036
 		{
1038 1037
 			if (self::LOG_LEVEL) error_log(__METHOD__."($url, $mode) no (numeric) mode!");
1039
-			trigger_error("No (numeric) mode!",E_USER_WARNING);
1038
+			trigger_error("No (numeric) mode!", E_USER_WARNING);
1040 1039
 			return false;
1041 1040
 		}
1042 1041
 		$stmt = self::$pdo->prepare('UPDATE '.self::TABLE.' SET fs_mode=:fs_mode WHERE fs_id=:fs_id');
1043 1042
 
1044 1043
 		// update stat cache
1045
-		if ($path != '/' && substr($path,-1) == '/') $path = substr($path, 0, -1);
1046
-		self::$stat_cache[$path]['fs_mode'] = ((int) $mode) & 0777;
1044
+		if ($path != '/' && substr($path, -1) == '/') $path = substr($path, 0, -1);
1045
+		self::$stat_cache[$path]['fs_mode'] = ((int)$mode)&0777;
1047 1046
 
1048 1047
 		return $stmt->execute(array(
1049
-			'fs_mode' => ((int) $mode) & 0777,		// we dont store the file and dir bits, give int overflow!
1048
+			'fs_mode' => ((int)$mode)&0777, // we dont store the file and dir bits, give int overflow!
1050 1049
 			'fs_id' => $stat['ino'],
1051 1050
 		));
1052 1051
 	}
@@ -1059,18 +1058,18 @@  discard block
 block discarded – undo
1059 1058
 	 * @param int $options
1060 1059
 	 * @return booelan
1061 1060
 	 */
1062
-	function dir_opendir ( $url, $options )
1061
+	function dir_opendir($url, $options)
1063 1062
 	{
1064 1063
 		$this->opened_dir = null;
1065 1064
 
1066
-		$path = Vfs::parse_url($url,PHP_URL_PATH);
1065
+		$path = Vfs::parse_url($url, PHP_URL_PATH);
1067 1066
 
1068
-		if (!($stat = $this->url_stat($url,0)) || 		// dir not found
1069
-			!($stat['mode'] & self::MODE_DIR) && $stat['mime'] != self::DIR_MIME_TYPE ||		// no dir
1070
-			!Vfs::check_access($url,Vfs::EXECUTABLE|Vfs::READABLE,$stat))	// no access
1067
+		if (!($stat = $this->url_stat($url, 0)) || // dir not found
1068
+			!($stat['mode']&self::MODE_DIR) && $stat['mime'] != self::DIR_MIME_TYPE || // no dir
1069
+			!Vfs::check_access($url, Vfs::EXECUTABLE|Vfs::READABLE, $stat))	// no access
1071 1070
 		{
1072 1071
 			self::_remove_password($url);
1073
-			$msg = !($stat['mode'] & self::MODE_DIR) && $stat['mime'] != self::DIR_MIME_TYPE ?
1072
+			$msg = !($stat['mode']&self::MODE_DIR) && $stat['mime'] != self::DIR_MIME_TYPE ?
1074 1073
 				"$url is no directory" : 'permission denied';
1075 1074
 			if (self::LOG_LEVEL) error_log(__METHOD__."('$url',$options) $msg!");
1076 1075
 			$this->opened_dir = null;
@@ -1087,13 +1086,13 @@  discard block
 block discarded – undo
1087 1086
 		$stmt->setFetchMode(\PDO::FETCH_ASSOC);
1088 1087
 		if ($stmt->execute(array($stat['ino'])))
1089 1088
 		{
1090
-			foreach($stmt as $file)
1089
+			foreach ($stmt as $file)
1091 1090
 			{
1092 1091
 				$this->opened_dir[] = $file['fs_name'];
1093
-				self::$stat_cache[Vfs::concat($path,$file['fs_name'])] = $file;
1092
+				self::$stat_cache[Vfs::concat($path, $file['fs_name'])] = $file;
1094 1093
 			}
1095 1094
 		}
1096
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$options): ".implode(', ',$this->opened_dir));
1095
+		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$options): ".implode(', ', $this->opened_dir));
1097 1096
 		reset($this->opened_dir);
1098 1097
 
1099 1098
 		return true;
@@ -1125,26 +1124,26 @@  discard block
 block discarded – undo
1125 1124
 	 *                          stat triggers it's own warning anyway, so it makes no sense to trigger one by our stream-wrapper!
1126 1125
 	 * @return array
1127 1126
 	 */
1128
-	function url_stat ( $url, $flags )
1127
+	function url_stat($url, $flags)
1129 1128
 	{
1130
-		static $max_subquery_depth=null;
1129
+		static $max_subquery_depth = null;
1131 1130
 		if (is_null($max_subquery_depth))
1132 1131
 		{
1133 1132
 			$max_subquery_depth = $GLOBALS['egw_info']['server']['max_subquery_depth'];
1134
-			if (!$max_subquery_depth) $max_subquery_depth = 7;	// setting current default of 7, if nothing set
1133
+			if (!$max_subquery_depth) $max_subquery_depth = 7; // setting current default of 7, if nothing set
1135 1134
 		}
1136 1135
 		if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$url',$flags)");
1137 1136
 
1138
-		$path = Vfs::parse_url($url,PHP_URL_PATH);
1137
+		$path = Vfs::parse_url($url, PHP_URL_PATH);
1139 1138
 
1140 1139
 		// webdav adds a trailing slash to dirs, which causes url_stat to NOT find the file otherwise
1141
-		if ($path != '/' && substr($path,-1) == '/')
1140
+		if ($path != '/' && substr($path, -1) == '/')
1142 1141
 		{
1143
-			$path = substr($path,0,-1);
1142
+			$path = substr($path, 0, -1);
1144 1143
 		}
1145 1144
 		if (empty($path))
1146 1145
 		{
1147
-			return false;	// is invalid and gives sql error
1146
+			return false; // is invalid and gives sql error
1148 1147
 		}
1149 1148
 		// check if we already have the info from the last dir_open call, as the old vfs reads it anyway from the db
1150 1149
 		if (self::$stat_cache && isset(self::$stat_cache[$path]) && self::$stat_cache[$path] !== false)
@@ -1159,25 +1158,25 @@  discard block
 block discarded – undo
1159 1158
 		$base_query = 'SELECT fs_id,fs_name,fs_mode,fs_uid,fs_gid,fs_size,fs_mime,fs_created,fs_modified'.self::$extra_columns.
1160 1159
 			' FROM '.self::TABLE.' WHERE fs_active='.self::_pdo_boolean(true).
1161 1160
 			' AND fs_name'.self::$case_sensitive_equal.'? AND fs_dir=';
1162
-		$parts = explode('/',$path);
1161
+		$parts = explode('/', $path);
1163 1162
 
1164 1163
 		// if we have extended acl access to the url, we dont need and can NOT include the sql for the readable check
1165
-		$eacl_access = static::check_extended_acl($path,Vfs::READABLE);
1164
+		$eacl_access = static::check_extended_acl($path, Vfs::READABLE);
1166 1165
 
1167 1166
 		try {
1168
-			foreach($parts as $n => $name)
1167
+			foreach ($parts as $n => $name)
1169 1168
 			{
1170 1169
 				if ($n == 0)
1171 1170
 				{
1172
-					$query = (int) ($path != '/');	// / always has fs_id == 1, no need to query it ($path=='/' needs fs_dir=0!)
1171
+					$query = (int)($path != '/'); // / always has fs_id == 1, no need to query it ($path=='/' needs fs_dir=0!)
1173 1172
 				}
1174
-				elseif ($n < count($parts)-1)
1173
+				elseif ($n < count($parts) - 1)
1175 1174
 				{
1176 1175
 					// MySQL 5.0 has a nesting limit for subqueries
1177 1176
 					// --> we replace the so far cumulated subqueries with their result
1178 1177
 					// no idea about the other DBMS, but this does NOT hurt ...
1179 1178
 					// --> depth limit of subqueries is now dynamicly decremented in catch
1180
-					if ($n > 1 && !(($n-1) % $max_subquery_depth) && !($query = self::$pdo->query($query)->fetchColumn()))
1179
+					if ($n > 1 && !(($n - 1) % $max_subquery_depth) && !($query = self::$pdo->query($query)->fetchColumn()))
1181 1180
 					{
1182 1181
 						if (self::LOG_LEVEL > 1)
1183 1182
 						{
@@ -1204,7 +1203,7 @@  discard block
 block discarded – undo
1204 1203
 				}
1205 1204
 				else
1206 1205
 				{
1207
-					$query = str_replace('fs_name'.self::$case_sensitive_equal.'?','fs_name'.self::$case_sensitive_equal.self::$pdo->quote($name),$base_query).'('.$query.')';
1206
+					$query = str_replace('fs_name'.self::$case_sensitive_equal.'?', 'fs_name'.self::$case_sensitive_equal.self::$pdo->quote($name), $base_query).'('.$query.')';
1208 1207
 				}
1209 1208
 			}
1210 1209
 			if (self::LOG_LEVEL > 2) $query = '/* '.__METHOD__."($url,$flags) eacl_access=$eacl_access".' */ '.$query;
@@ -1230,7 +1229,7 @@  discard block
 block discarded – undo
1230 1229
 			$GLOBALS['egw_info']['server']['max_subquery_depth'] = --$max_subquery_depth;
1231 1230
 			error_log(__METHOD__."() decremented max_subquery_depth to $max_subquery_depth");
1232 1231
 			Api\Config::save_value('max_subquery_depth', $max_subquery_depth, 'phpgwapi');
1233
-			if (method_exists($GLOBALS['egw'],'invalidate_session_cache')) $GLOBALS['egw']->invalidate_session_cache();
1232
+			if (method_exists($GLOBALS['egw'], 'invalidate_session_cache')) $GLOBALS['egw']->invalidate_session_cache();
1234 1233
 			return $this->url_stat($url, $flags);
1235 1234
 		}
1236 1235
 		self::$stat_cache[$path] = $info;
@@ -1246,18 +1245,18 @@  discard block
 block discarded – undo
1246 1245
 	 */
1247 1246
 	protected static function _sql_readable()
1248 1247
 	{
1249
-		static $sql_read_acl=null;
1248
+		static $sql_read_acl = null;
1250 1249
 
1251 1250
 		if (is_null($sql_read_acl))
1252 1251
 		{
1253
-			foreach($GLOBALS['egw']->accounts->memberships(Vfs::$user,true) as $gid)
1252
+			foreach ($GLOBALS['egw']->accounts->memberships(Vfs::$user, true) as $gid)
1254 1253
 			{
1255
-				$memberships[] = abs($gid);	// sqlfs stores the gid's positiv
1254
+				$memberships[] = abs($gid); // sqlfs stores the gid's positiv
1256 1255
 			}
1257 1256
 			// using octal numbers with mysql leads to funny results (select 384 & 0400 --> 384 not 256=0400)
1258 1257
 			// 256 = 0400, 32 = 040
1259 1258
 			$sql_read_acl = '((fs_mode & 4)=4 OR (fs_mode & 256)=256 AND fs_uid='.(int)Vfs::$user.
1260
-				($memberships ? ' OR (fs_mode & 32)=32 AND fs_gid IN('.implode(',',$memberships).')' : '').')';
1259
+				($memberships ? ' OR (fs_mode & 32)=32 AND fs_gid IN('.implode(',', $memberships).')' : '').')';
1261 1260
 			//error_log(__METHOD__."() Vfs::\$user=".array2string(Vfs::$user).' --> memberships='.array2string($memberships).' --> '.$sql_read_acl.($memberships?'':': '.function_backtrace()));
1262 1261
 		}
1263 1262
 		return $sql_read_acl;
@@ -1270,7 +1269,7 @@  discard block
 block discarded – undo
1270 1269
 	 *
1271 1270
 	 * @return string
1272 1271
 	 */
1273
-	function dir_readdir ( )
1272
+	function dir_readdir( )
1274 1273
 	{
1275 1274
 		if (self::LOG_LEVEL > 1) error_log(__METHOD__."( )");
1276 1275
 
@@ -1289,7 +1288,7 @@  discard block
 block discarded – undo
1289 1288
 	 *
1290 1289
 	 * @return boolean
1291 1290
 	 */
1292
-	function dir_rewinddir ( )
1291
+	function dir_rewinddir( )
1293 1292
 	{
1294 1293
 		if (self::LOG_LEVEL > 1) error_log(__METHOD__."( )");
1295 1294
 
@@ -1307,7 +1306,7 @@  discard block
 block discarded – undo
1307 1306
 	 *
1308 1307
 	 * @return boolean
1309 1308
 	 */
1310
-	function dir_closedir ( )
1309
+	function dir_closedir( )
1311 1310
 	{
1312 1311
 		if (self::LOG_LEVEL > 1) error_log(__METHOD__."( )");
1313 1312
 
@@ -1329,7 +1328,7 @@  discard block
 block discarded – undo
1329 1328
 	static function readlink($path)
1330 1329
 	{
1331 1330
 		$vfs = new self();
1332
-		$link = !($lstat = $vfs->url_stat($path,STREAM_URL_STAT_LINK)) || is_null($lstat['readlink']) ? false : $lstat['readlink'];
1331
+		$link = !($lstat = $vfs->url_stat($path, STREAM_URL_STAT_LINK)) || is_null($lstat['readlink']) ? false : $lstat['readlink'];
1333 1332
 
1334 1333
 		if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path') = $link");
1335 1334
 
@@ -1343,32 +1342,32 @@  discard block
 block discarded – undo
1343 1342
 	 * @param string $link
1344 1343
 	 * @return boolean true on success false on error
1345 1344
 	 */
1346
-	static function symlink($target,$link)
1345
+	static function symlink($target, $link)
1347 1346
 	{
1348 1347
 		if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$target','$link')");
1349 1348
 
1350 1349
 		$inst = new static();
1351
-		if ($inst->url_stat($link,0))
1350
+		if ($inst->url_stat($link, 0))
1352 1351
 		{
1353 1352
 			if (self::LOG_LEVEL > 0) error_log(__METHOD__."('$target','$link') $link exists, returning false!");
1354
-			return false;	// $link already exists
1353
+			return false; // $link already exists
1355 1354
 		}
1356 1355
 		if (!($dir = Vfs::dirname($link)) ||
1357
-			!Vfs::check_access($dir,Vfs::WRITABLE,$dir_stat=$inst->url_stat($dir,0)))
1356
+			!Vfs::check_access($dir, Vfs::WRITABLE, $dir_stat = $inst->url_stat($dir, 0)))
1358 1357
 		{
1359 1358
 			if (self::LOG_LEVEL > 0) error_log(__METHOD__."('$target','$link') returning false! (!is_writable('$dir'), dir_stat=".array2string($dir_stat).")");
1360
-			return false;	// parent dir does not exist or is not writable
1359
+			return false; // parent dir does not exist or is not writable
1361 1360
 		}
1362 1361
 		$query = 'INSERT INTO '.self::TABLE.' (fs_name,fs_dir,fs_mode,fs_uid,fs_gid,fs_created,fs_modified,fs_creator,fs_mime,fs_size,fs_link'.
1363 1362
 			') VALUES (:fs_name,:fs_dir,:fs_mode,:fs_uid,:fs_gid,:fs_created,:fs_modified,:fs_creator,:fs_mime,:fs_size,:fs_link)';
1364 1363
 		if (self::LOG_LEVEL > 2) $query = '/* '.__METHOD__.': '.__LINE__.' */ '.$query;
1365 1364
 		$stmt = self::$pdo->prepare($query);
1366
-		unset(self::$stat_cache[Vfs::parse_url($link,PHP_URL_PATH)]);
1365
+		unset(self::$stat_cache[Vfs::parse_url($link, PHP_URL_PATH)]);
1367 1366
 
1368 1367
 		return !!$stmt->execute(array(
1369 1368
 			'fs_name' => self::limit_filename(Vfs::basename($link)),
1370 1369
 			'fs_dir'  => $dir_stat['ino'],
1371
-			'fs_mode' => ($dir_stat['mode'] & 0666),
1370
+			'fs_mode' => ($dir_stat['mode']&0666),
1372 1371
 			'fs_uid'  => $dir_stat['uid'] ? $dir_stat['uid'] : Vfs::$user,
1373 1372
 			'fs_gid'  => $dir_stat['gid'],
1374 1373
 			'fs_created'  => self::_pdo_timestamp(time()),
@@ -1392,24 +1391,24 @@  discard block
 block discarded – undo
1392 1391
 	 * @param int $check mode to check: one or more or'ed together of: 4 = read, 2 = write, 1 = executable
1393 1392
 	 * @return boolean
1394 1393
 	 */
1395
-	static function check_extended_acl($url,$check)
1394
+	static function check_extended_acl($url, $check)
1396 1395
 	{
1397
-		$url_path = Vfs::parse_url($url,PHP_URL_PATH);
1396
+		$url_path = Vfs::parse_url($url, PHP_URL_PATH);
1398 1397
 
1399 1398
 		if (is_null(self::$extended_acl))
1400 1399
 		{
1401 1400
 			self::_read_extended_acl();
1402 1401
 		}
1403 1402
 		$access = false;
1404
-		foreach(self::$extended_acl as $path => $rights)
1403
+		foreach (self::$extended_acl as $path => $rights)
1405 1404
 		{
1406
-			if ($path == $url_path || substr($url_path,0,strlen($path)+1) == $path.'/')
1405
+			if ($path == $url_path || substr($url_path, 0, strlen($path) + 1) == $path.'/')
1407 1406
 			{
1408
-				$access = ($rights & $check) == $check;
1407
+				$access = ($rights&$check) == $check;
1409 1408
 				break;
1410 1409
 			}
1411 1410
 		}
1412
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$check) ".($access?"access granted by $path=$rights":'no access!!!'));
1411
+		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$check) ".($access ? "access granted by $path=$rights" : 'no access!!!'));
1413 1412
 		return $access;
1414 1413
 	}
1415 1414
 
@@ -1421,14 +1420,14 @@  discard block
 block discarded – undo
1421 1420
 	{
1422 1421
 		if ((self::$extended_acl = Api\Cache::getSession(self::EACL_APPNAME, 'extended_acl')))
1423 1422
 		{
1424
-			return;		// ext. ACL read from session.
1423
+			return; // ext. ACL read from session.
1425 1424
 		}
1426 1425
 		self::$extended_acl = array();
1427
-		if (($rights = $GLOBALS['egw']->acl->get_all_location_rights(Vfs::$user,self::EACL_APPNAME)))
1426
+		if (($rights = $GLOBALS['egw']->acl->get_all_location_rights(Vfs::$user, self::EACL_APPNAME)))
1428 1427
 		{
1429 1428
 			$pathes = self::id2path(array_keys($rights));
1430 1429
 		}
1431
-		foreach($rights as $fs_id => $right)
1430
+		foreach ($rights as $fs_id => $right)
1432 1431
 		{
1433 1432
 			$path = $pathes[$fs_id];
1434 1433
 			if (isset($path))
@@ -1437,8 +1436,8 @@  discard block
 block discarded – undo
1437 1436
 			}
1438 1437
 		}
1439 1438
 		// sort by length descending, to allow more specific pathes to have precedence
1440
-		uksort(self::$extended_acl, function($a,$b) {
1441
-			return strlen($b)-strlen($a);
1439
+		uksort(self::$extended_acl, function($a, $b) {
1440
+			return strlen($b) - strlen($a);
1442 1441
 		});
1443 1442
 		Api\Cache::setSession(self::EACL_APPNAME, 'extended_acl', self::$extended_acl);
1444 1443
 		if (self::LOG_LEVEL > 1) error_log(__METHOD__.'() '.array2string(self::$extended_acl));
@@ -1460,24 +1459,24 @@  discard block
 block discarded – undo
1460 1459
 	 * @param int $fs_id =null fs_id to use, to not query it again (eg. because it's already deleted)
1461 1460
 	 * @return boolean true if acl is set/deleted, false on error
1462 1461
 	 */
1463
-	static function eacl($path,$rights=null,$owner=null,$fs_id=null)
1462
+	static function eacl($path, $rights = null, $owner = null, $fs_id = null)
1464 1463
 	{
1465 1464
 		if ($path[0] != '/')
1466 1465
 		{
1467
-			$path = Vfs::parse_url($path,PHP_URL_PATH);
1466
+			$path = Vfs::parse_url($path, PHP_URL_PATH);
1468 1467
 		}
1469 1468
 		if (is_null($fs_id))
1470 1469
 		{
1471 1470
 			$vfs = new self();
1472
-			if (!($stat = $vfs->url_stat($path,0)))
1471
+			if (!($stat = $vfs->url_stat($path, 0)))
1473 1472
 			{
1474 1473
 				if (self::LOG_LEVEL) error_log(__METHOD__."($path,$rights,$owner,$fs_id) no such file or directory!");
1475
-				return false;	// $path not found
1474
+				return false; // $path not found
1476 1475
 			}
1477
-			if (!Vfs::has_owner_rights($path,$stat))		// not group dir and user is eGW admin
1476
+			if (!Vfs::has_owner_rights($path, $stat))		// not group dir and user is eGW admin
1478 1477
 			{
1479 1478
 				if (self::LOG_LEVEL) error_log(__METHOD__."($path,$rights,$owner,$fs_id) permission denied!");
1480
-				return false;	// permission denied
1479
+				return false; // permission denied
1481 1480
 			}
1482 1481
 			$fs_id = $stat['ino'];
1483 1482
 		}
@@ -1489,16 +1488,16 @@  discard block
 block discarded – undo
1489 1488
 		{
1490 1489
 			// delete eacl
1491 1490
 			if (is_null($owner) || $owner == Vfs::$user ||
1492
-				$owner < 0 && Vfs::$user && in_array($owner,$GLOBALS['egw']->accounts->memberships(Vfs::$user,true)))
1491
+				$owner < 0 && Vfs::$user && in_array($owner, $GLOBALS['egw']->accounts->memberships(Vfs::$user, true)))
1493 1492
 			{
1494
-				self::$extended_acl = null;	// force new read of eACL, as there could be multiple eACL for that path
1493
+				self::$extended_acl = null; // force new read of eACL, as there could be multiple eACL for that path
1495 1494
 			}
1496 1495
 			$ret = $GLOBALS['egw']->acl->delete_repository(self::EACL_APPNAME, $fs_id, (int)$owner, false);
1497 1496
 		}
1498 1497
 		else
1499 1498
 		{
1500 1499
 			if (isset(self::$extended_acl) && ($owner == Vfs::$user ||
1501
-				$owner < 0 && Vfs::$user && in_array($owner,$GLOBALS['egw']->accounts->memberships(Vfs::$user,true))))
1500
+				$owner < 0 && Vfs::$user && in_array($owner, $GLOBALS['egw']->accounts->memberships(Vfs::$user, true))))
1502 1501
 			{
1503 1502
 				// set rights for this class, if applicable
1504 1503
 				self::$extended_acl[$path] |= $rights;
@@ -1527,10 +1526,10 @@  discard block
 block discarded – undo
1527 1526
 		if (!($stat = $inst->url_stat($path, STREAM_URL_STAT_QUIET)))
1528 1527
 		{
1529 1528
 			error_log(__METHOD__.__LINE__.' '.array2string($path).' not found!');
1530
-			return false;	// not found
1529
+			return false; // not found
1531 1530
 		}
1532 1531
 		$eacls = array();
1533
-		foreach($GLOBALS['egw']->acl->get_all_rights($stat['ino'],self::EACL_APPNAME) as $owner => $rights)
1532
+		foreach ($GLOBALS['egw']->acl->get_all_rights($stat['ino'], self::EACL_APPNAME) as $owner => $rights)
1534 1533
 		{
1535 1534
 			$eacls[] = array(
1536 1535
 				'path'   => $path,
@@ -1541,7 +1540,7 @@  discard block
 block discarded – undo
1541 1540
 		}
1542 1541
 		if (($path = Vfs::dirname($path)))
1543 1542
 		{
1544
-			$eacls = array_merge((array)self::get_eacl($path),$eacls);
1543
+			$eacls = array_merge((array)self::get_eacl($path), $eacls);
1545 1544
 		}
1546 1545
 		// sort by length descending, to show precedence
1547 1546
 		usort($eacls, function($a, $b) {
@@ -1560,7 +1559,7 @@  discard block
 block discarded – undo
1560 1559
 	static function get_minimum_file_id($path)
1561 1560
 	{
1562 1561
 		$vfs = new self();
1563
-		$stat = $vfs->url_stat($path,0);
1562
+		$stat = $vfs->url_stat($path, 0);
1564 1563
 		if ($stat['readlink'])
1565 1564
 		{
1566 1565
 			$stat = $vfs->url_stat($stat['readlink'], 0);
@@ -1600,7 +1599,7 @@  discard block
 block discarded – undo
1600 1599
 	 * @param int $recursion_count =0 internally used to break infinit recursions
1601 1600
 	 * @return false|string|array path or array or pathes indexed by fs_id, or false on error
1602 1601
 	 */
1603
-	static function id2path($fs_ids, $recursion_count=0)
1602
+	static function id2path($fs_ids, $recursion_count = 0)
1604 1603
 	{
1605 1604
 		if (self::LOG_LEVEL > 1) error_log(__METHOD__.'('.array2string($fs_ids).')');
1606 1605
 		if ($recursion_count > self::MAX_ID2PATH_RECURSION)
@@ -1611,9 +1610,9 @@  discard block
 block discarded – undo
1611 1610
 		$ids = (array)$fs_ids;
1612 1611
 		$pathes = array();
1613 1612
 		// first check our stat-cache for the ids
1614
-		foreach(self::$stat_cache as $path => $stat)
1613
+		foreach (self::$stat_cache as $path => $stat)
1615 1614
 		{
1616
-			if (($key = array_search($stat['fs_id'],$ids)) !== false)
1615
+			if (($key = array_search($stat['fs_id'], $ids)) !== false)
1617 1616
 			{
1618 1617
 				$pathes[$stat['fs_id']] = $path;
1619 1618
 				unset($ids[$key]);
@@ -1627,7 +1626,7 @@  discard block
 block discarded – undo
1627 1626
 		// now search via the database
1628 1627
 		if (count($ids) > 1) $ids = array_map(function($v) { return (int)$v; }, $ids);
1629 1628
 		$query = 'SELECT fs_id,fs_dir,fs_name FROM '.self::TABLE.' WHERE fs_id'.
1630
-			(count($ids) == 1 ? '='.(int)$ids[0] : ' IN ('.implode(',',$ids).')');
1629
+			(count($ids) == 1 ? '='.(int)$ids[0] : ' IN ('.implode(',', $ids).')');
1631 1630
 		if (self::LOG_LEVEL > 2) $query = '/* '.__METHOD__.': '.__LINE__.' */ '.$query;
1632 1631
 
1633 1632
 		if (!is_object(self::$pdo))
@@ -1638,12 +1637,12 @@  discard block
 block discarded – undo
1638 1637
 		$stmt->setFetchMode(\PDO::FETCH_ASSOC);
1639 1638
 		if (!$stmt->execute())
1640 1639
 		{
1641
-			return false;	// not found
1640
+			return false; // not found
1642 1641
 		}
1643 1642
 		$parents = array();
1644
-		foreach($stmt as $row)
1643
+		foreach ($stmt as $row)
1645 1644
 		{
1646
-			if ($row['fs_dir'] > 1 && !in_array($row['fs_dir'],$parents))
1645
+			if ($row['fs_dir'] > 1 && !in_array($row['fs_dir'], $parents))
1647 1646
 			{
1648 1647
 				$parents[] = $row['fs_dir'];
1649 1648
 			}
@@ -1651,16 +1650,16 @@  discard block
 block discarded – undo
1651 1650
 		}
1652 1651
 		unset($stmt);
1653 1652
 
1654
-		if ($parents && !($parents = self::id2path($parents, $recursion_count+1)))
1653
+		if ($parents && !($parents = self::id2path($parents, $recursion_count + 1)))
1655 1654
 		{
1656
-			return false;	// parent not found, should never happen ...
1655
+			return false; // parent not found, should never happen ...
1657 1656
 		}
1658
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__." trying foreach with:".print_r($rows,true)."#");
1659
-		foreach((array)$rows as $fs_id => $row)
1657
+		if (self::LOG_LEVEL > 1) error_log(__METHOD__." trying foreach with:".print_r($rows, true)."#");
1658
+		foreach ((array)$rows as $fs_id => $row)
1660 1659
 		{
1661 1660
 			$parent = $row['fs_dir'] > 1 ? $parents[$row['fs_dir']] : '';
1662 1661
 
1663
-			$pathes[$fs_id] = $parent . '/' . $row['fs_name'];
1662
+			$pathes[$fs_id] = $parent.'/'.$row['fs_name'];
1664 1663
 		}
1665 1664
 		if (self::LOG_LEVEL > 1) error_log(__METHOD__.'('.array2string($fs_ids).')='.array2string($pathes));
1666 1665
 		return is_array($fs_ids) ? $pathes : array_shift($pathes);
@@ -1684,7 +1683,7 @@  discard block
 block discarded – undo
1684 1683
 			$parts = explode('.', $name);
1685 1684
 			if ($parts > 1 && mb_strlen($extension = '.'.array_pop($parts)) <= $fs_name_precision)
1686 1685
 			{
1687
-				$name = mb_substr(implode('.', $parts), 0, $fs_name_precision-mb_strlen($extension)).$extension;
1686
+				$name = mb_substr(implode('.', $parts), 0, $fs_name_precision - mb_strlen($extension)).$extension;
1688 1687
 			}
1689 1688
 			else
1690 1689
 			{
@@ -1705,9 +1704,8 @@  discard block
 block discarded – undo
1705 1704
 		$stat = array(
1706 1705
 			'ino'   => $info['fs_id'],
1707 1706
 			'name'  => $info['fs_name'],
1708
-			'mode'  => $info['fs_mode'] |
1709
-				($info['fs_mime'] == self::DIR_MIME_TYPE ? self::MODE_DIR :
1710
-				($info['fs_mime'] == self::SYMLINK_MIME_TYPE ? self::MODE_LINK : self::MODE_FILE)),	// required by the stream wrapper
1707
+			'mode'  => $info['fs_mode']|
1708
+				($info['fs_mime'] == self::DIR_MIME_TYPE ? self::MODE_DIR : ($info['fs_mime'] == self::SYMLINK_MIME_TYPE ? self::MODE_LINK : self::MODE_FILE)), // required by the stream wrapper
1711 1709
 			'size'  => $info['fs_size'],
1712 1710
 			'uid'   => $info['fs_uid'],
1713 1711
 			'gid'   => $info['fs_gid'],
@@ -1752,10 +1750,10 @@  discard block
 block discarded – undo
1752 1750
 		{
1753 1751
 			if (is_object($GLOBALS['egw_setup']->db))	// if we run under setup, query the db for the files dir
1754 1752
 			{
1755
-				$GLOBALS['egw_info']['server']['files_dir'] = $GLOBALS['egw_setup']->db->select('egw_config','config_value',array(
1753
+				$GLOBALS['egw_info']['server']['files_dir'] = $GLOBALS['egw_setup']->db->select('egw_config', 'config_value', array(
1756 1754
 					'config_name' => 'files_dir',
1757 1755
 					'config_app' => 'phpgwapi',
1758
-				),__LINE__,__FILE__)->fetchColumn();
1756
+				), __LINE__, __FILE__)->fetchColumn();
1759 1757
 			}
1760 1758
 		}
1761 1759
 		if (!$GLOBALS['egw_info']['server']['files_dir'])
@@ -1764,14 +1762,14 @@  discard block
 block discarded – undo
1764 1762
 		}
1765 1763
 		$hash = array();
1766 1764
 		$n = $id;
1767
-		while(($n = (int) ($n / self::HASH_MAX)))
1765
+		while (($n = (int)($n / self::HASH_MAX)))
1768 1766
 		{
1769
-			$hash[] = sprintf('%02d',$n % self::HASH_MAX);
1767
+			$hash[] = sprintf('%02d', $n % self::HASH_MAX);
1770 1768
 		}
1771
-		if (!$hash) $hash[] = '00';		// we need at least one directory, to not conflict with the dir-names
1772
-		array_unshift($hash,$id);
1769
+		if (!$hash) $hash[] = '00'; // we need at least one directory, to not conflict with the dir-names
1770
+		array_unshift($hash, $id);
1773 1771
 
1774
-		$path = '/sqlfs/'.implode('/',array_reverse($hash));
1772
+		$path = '/sqlfs/'.implode('/', array_reverse($hash));
1775 1773
 		//error_log(__METHOD__."($id) = '$path'");
1776 1774
 		return $GLOBALS['egw_info']['server']['files_dir'].$path;
1777 1775
 	}
@@ -1787,7 +1785,7 @@  discard block
 block discarded – undo
1787 1785
 
1788 1786
 		if ($parts['pass'] || $parts['scheme'])
1789 1787
 		{
1790
-			$url = $parts['scheme'].'://'.($parts['user'] ? $parts['user'].($parts['pass']?':...':'').'@' : '').
1788
+			$url = $parts['scheme'].'://'.($parts['user'] ? $parts['user'].($parts['pass'] ? ':...' : '').'@' : '').
1791 1789
 				$parts['host'].$parts['path'];
1792 1790
 		}
1793 1791
 	}
@@ -1802,10 +1800,10 @@  discard block
 block discarded – undo
1802 1800
 	{
1803 1801
 		$operation = self::DEFAULT_OPERATION;
1804 1802
 
1805
-		if (strpos(is_array($url) ? $url['query'] : $url,'storage=') !== false)
1803
+		if (strpos(is_array($url) ? $url['query'] : $url, 'storage=') !== false)
1806 1804
 		{
1807 1805
 			$query = null;
1808
-			parse_str(is_array($url) ? $url['query'] : Vfs::parse_url($url,PHP_URL_QUERY), $query);
1806
+			parse_str(is_array($url) ? $url['query'] : Vfs::parse_url($url, PHP_URL_QUERY), $query);
1809 1807
 			switch ($query['storage'])
1810 1808
 			{
1811 1809
 				case 'db':
@@ -1828,29 +1826,29 @@  discard block
 block discarded – undo
1828 1826
 	 * @param array $props array of array with values for keys 'name', 'ns', 'val' (null to delete the prop)
1829 1827
 	 * @return boolean true if props are updated, false otherwise (eg. ressource not found)
1830 1828
 	 */
1831
-	static function proppatch($path,array $props)
1829
+	static function proppatch($path, array $props)
1832 1830
 	{
1833 1831
 		static $inst = null;
1834 1832
 		if (self::LOG_LEVEL > 1) error_log(__METHOD__."(".array2string($path).','.array2string($props));
1835 1833
 		if (!is_numeric($path))
1836 1834
 		{
1837 1835
 			if (!isset($inst)) $inst = new self();
1838
-			if (!($stat = $inst->url_stat($path,0)))
1836
+			if (!($stat = $inst->url_stat($path, 0)))
1839 1837
 			{
1840 1838
 				return false;
1841 1839
 			}
1842 1840
 			$id = $stat['ino'];
1843 1841
 		}
1844
-		elseif(!($path = self::id2path($id=$path)))
1842
+		elseif (!($path = self::id2path($id = $path)))
1845 1843
 		{
1846 1844
 			return false;
1847 1845
 		}
1848
-		if (!Vfs::check_access($path,Api\Acl::EDIT,$stat))
1846
+		if (!Vfs::check_access($path, Api\Acl::EDIT, $stat))
1849 1847
 		{
1850
-			return false;	// permission denied
1848
+			return false; // permission denied
1851 1849
 		}
1852 1850
 		$ins_stmt = $del_stmt = null;
1853
-		foreach($props as &$prop)
1851
+		foreach ($props as &$prop)
1854 1852
 		{
1855 1853
 			if (!isset($prop['ns'])) $prop['ns'] = Vfs::DEFAULT_PROP_NAMESPACE;
1856 1854
 
@@ -1895,17 +1893,17 @@  discard block
 block discarded – undo
1895 1893
 	 * @return array|boolean false on error ($path_ids does not exist), array with props (values for keys 'name', 'ns', 'value'), or
1896 1894
 	 * 	fs_id/path => array of props for $depth==1 or is_array($path_ids)
1897 1895
 	 */
1898
-	static function propfind($path_ids,$ns=Vfs::DEFAULT_PROP_NAMESPACE)
1896
+	static function propfind($path_ids, $ns = Vfs::DEFAULT_PROP_NAMESPACE)
1899 1897
 	{
1900 1898
 		static $inst = null;
1901 1899
 
1902 1900
 		$ids = is_array($path_ids) ? $path_ids : array($path_ids);
1903
-		foreach($ids as &$id)
1901
+		foreach ($ids as &$id)
1904 1902
 		{
1905 1903
 			if (!is_numeric($id))
1906 1904
 			{
1907 1905
 				if (!isset($inst)) $inst = new self();
1908
-				if (!($stat = $inst->url_stat($id,0)))
1906
+				if (!($stat = $inst->url_stat($id, 0)))
1909 1907
 				{
1910 1908
 					if (self::LOG_LEVEL) error_log(__METHOD__."(".array2string($path_ids).",$ns) path '$id' not found!");
1911 1909
 					return false;
@@ -1915,7 +1913,7 @@  discard block
 block discarded – undo
1915 1913
 		}
1916 1914
 		if (count($ids) >= 1) $ids = array_map(function($v) { return (int)$v; }, $ids);
1917 1915
 		$query = 'SELECT * FROM '.self::PROPS_TABLE.' WHERE (fs_id'.
1918
-			(count($ids) == 1 ? '='.(int)implode('',$ids) : ' IN ('.implode(',',$ids).')').')'.
1916
+			(count($ids) == 1 ? '='.(int)implode('', $ids) : ' IN ('.implode(',', $ids).')').')'.
1919 1917
 			(!is_null($ns) ? ' AND prop_namespace=?' : '');
1920 1918
 		if (self::LOG_LEVEL > 2) $query = '/* '.__METHOD__.': '.__LINE__.' */ '.$query;
1921 1919
 
@@ -1924,7 +1922,7 @@  discard block
 block discarded – undo
1924 1922
 		$stmt->execute(!is_null($ns) ? array($ns) : array());
1925 1923
 
1926 1924
 		$props = array();
1927
-		foreach($stmt as $row)
1925
+		foreach ($stmt as $row)
1928 1926
 		{
1929 1927
 			$props[$row['fs_id']][] = array(
1930 1928
 				'val'  => $row['prop_value'],
@@ -1934,19 +1932,19 @@  discard block
 block discarded – undo
1934 1932
 		}
1935 1933
 		if (!is_array($path_ids))
1936 1934
 		{
1937
-			$props = $props[$row['fs_id']] ? $props[$row['fs_id']] : array();	// return empty array for no props
1935
+			$props = $props[$row['fs_id']] ? $props[$row['fs_id']] : array(); // return empty array for no props
1938 1936
 		}
1939 1937
 		elseif ($props && isset($stat) && is_array($id2path = self::id2path(array_keys($props))))	// need to map fs_id's to pathes
1940 1938
 		{
1941
-			foreach($id2path as $id => $path)
1939
+			foreach ($id2path as $id => $path)
1942 1940
 			{
1943
-				$props[$path] =& $props[$id];
1941
+				$props[$path] = & $props[$id];
1944 1942
 				unset($props[$id]);
1945 1943
 			}
1946 1944
 		}
1947 1945
 		if (self::LOG_LEVEL > 1)
1948 1946
 		{
1949
-			foreach((array)$props as $k => $v)
1947
+			foreach ((array)$props as $k => $v)
1950 1948
 			{
1951 1949
 				error_log(__METHOD__."($path_ids,$ns) $k => ".array2string($v));
1952 1950
 			}
Please login to merge, or discard this patch.
Braces   +423 added lines, -106 removed lines patch added patch discarded remove patch
@@ -193,7 +193,10 @@  discard block
 block discarded – undo
193 193
 	 */
194 194
 	function stream_open ($url, $mode, $options, &$opened_path)
195 195
 	{
196
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$mode,$options)");
196
+		if (self::LOG_LEVEL > 1)
197
+		{
198
+			error_log(__METHOD__."($url,$mode,$options)");
199
+		}
197 200
 
198 201
 		$path = Vfs::parse_url($url,PHP_URL_PATH);
199 202
 		$this->operation = self::url2operation($url);
@@ -205,7 +208,9 @@  discard block
 block discarded – undo
205 208
 
206 209
 		parse_str(parse_url($url, PHP_URL_QUERY), $this->dir_url_params);
207 210
 
208
-		if (!is_null($this->overwrite_new) || !($stat = $this->url_stat($path,STREAM_URL_STAT_QUIET)) || $mode[0] == 'x')	// file not found or file should NOT exist
211
+		if (!is_null($this->overwrite_new) || !($stat = $this->url_stat($path,STREAM_URL_STAT_QUIET)) || $mode[0] == 'x')
212
+		{
213
+			// file not found or file should NOT exist
209 214
 		{
210 215
 			if (!$dir || $mode[0] == 'r' ||	// does $mode require the file to exist (r,r+)
211 216
 				$mode[0] == 'x' && $stat ||	// or file should not exist, but does
@@ -213,7 +218,11 @@  discard block
 block discarded – undo
213 218
 				!Vfs::check_access($dir,Vfs::WRITABLE,$dir_stat))	// or we are not allowed to 																																			create it
214 219
 			{
215 220
 				self::_remove_password($url);
216
-				if (self::LOG_LEVEL) error_log(__METHOD__."($url,$mode,$options) file does not exist or can not be created!");
221
+		}
222
+				if (self::LOG_LEVEL)
223
+				{
224
+					error_log(__METHOD__."($url,$mode,$options) file does not exist or can not be created!");
225
+				}
217 226
 				if (($options & STREAM_REPORT_ERRORS))
218 227
 				{
219 228
 					trigger_error(__METHOD__."($url,$mode,$options) file does not exist or can not be created!",E_USER_WARNING);
@@ -225,7 +234,10 @@  discard block
 block discarded – undo
225 234
 			$new_file = true;
226 235
 			$query = 'INSERT INTO '.self::TABLE.' (fs_name,fs_dir,fs_mode,fs_uid,fs_gid,fs_created,fs_modified,fs_creator,fs_mime,fs_size,fs_active'.
227 236
 				') VALUES (:fs_name,:fs_dir,:fs_mode,:fs_uid,:fs_gid,:fs_created,:fs_modified,:fs_creator,:fs_mime,:fs_size,:fs_active)';
228
-			if (self::LOG_LEVEL > 2) $query = '/* '.__METHOD__.': '.__LINE__.' */ '.$query;
237
+			if (self::LOG_LEVEL > 2)
238
+			{
239
+				$query = '/* '.__METHOD__.': '.__LINE__.' */ '.$query;
240
+			}
229 241
 			$stmt = self::$pdo->prepare($query);
230 242
 			$values = array(
231 243
 				'fs_name' => self::limit_filename(Vfs::basename($path)),
@@ -243,11 +255,17 @@  discard block
 block discarded – undo
243 255
 				'fs_size'     => 0,
244 256
 				'fs_active'   => self::_pdo_boolean(true),
245 257
 			);
246
-			if ($this->overwrite_new) $values = array_merge($values, $this->overwrite_new);
258
+			if ($this->overwrite_new)
259
+			{
260
+				$values = array_merge($values, $this->overwrite_new);
261
+			}
247 262
 			if (!$stmt->execute($values) || !($this->opened_fs_id = self::$pdo->lastInsertId('egw_sqlfs_fs_id_seq')))
248 263
 			{
249 264
 				$this->opened_stream = $this->opened_path = $this->opened_mode = null;
250
-				if (self::LOG_LEVEL) error_log(__METHOD__."($url,$mode,$options) execute() failed: ".self::$pdo->errorInfo());
265
+				if (self::LOG_LEVEL)
266
+				{
267
+					error_log(__METHOD__."($url,$mode,$options) execute() failed: ".self::$pdo->errorInfo());
268
+				}
251 269
 				return false;
252 270
 			}
253 271
 			if ($this->operation == self::STORE2DB)
@@ -259,14 +277,20 @@  discard block
 block discarded – undo
259 277
 			elseif(!file_exists($fs_dir=Vfs::dirname(self::_fs_path($this->opened_fs_id))))
260 278
 			{
261 279
 				$umaskbefore = umask();
262
-				if (self::LOG_LEVEL > 1) error_log(__METHOD__." about to call mkdir for $fs_dir # Present UMASK:".decoct($umaskbefore)." called from:".function_backtrace());
280
+				if (self::LOG_LEVEL > 1)
281
+				{
282
+					error_log(__METHOD__." about to call mkdir for $fs_dir # Present UMASK:".decoct($umaskbefore)." called from:".function_backtrace());
283
+				}
263 284
 				self::mkdir_recursive($fs_dir,0700,true);
264 285
 			}
265 286
 		}
266 287
 		// check if opend file is a directory
267 288
 		elseif($stat && ($stat['mode'] & self::MODE_DIR) == self::MODE_DIR)
268 289
 		{
269
-				if (self::LOG_LEVEL) error_log(__METHOD__."($url,$mode,$options) Is a directory!");
290
+				if (self::LOG_LEVEL)
291
+				{
292
+					error_log(__METHOD__."($url,$mode,$options) Is a directory!");
293
+				}
270 294
 				if (($options & STREAM_REPORT_ERRORS))
271 295
 				{
272 296
 					trigger_error(__METHOD__."($url,$mode,$options) Is a directory!",E_USER_WARNING);
@@ -277,11 +301,17 @@  discard block
 block discarded – undo
277 301
 		else
278 302
 		{
279 303
 			if ($mode == 'r' && !Vfs::check_access($url,Vfs::READABLE ,$stat) ||// we are not allowed to read
280
-				$mode != 'r' && !Vfs::check_access($url,Vfs::WRITABLE,$stat))	// or edit it
304
+				$mode != 'r' && !Vfs::check_access($url,Vfs::WRITABLE,$stat))
305
+			{
306
+				// or edit it
281 307
 			{
282 308
 				self::_remove_password($url);
309
+			}
283 310
 				$op = $mode == 'r' ? 'read' : 'edited';
284
-				if (self::LOG_LEVEL) error_log(__METHOD__."($url,$mode,$options) file can not be $op!");
311
+				if (self::LOG_LEVEL)
312
+				{
313
+					error_log(__METHOD__."($url,$mode,$options) file can not be $op!");
314
+				}
285 315
 				if (($options & STREAM_REPORT_ERRORS))
286 316
 				{
287 317
 					trigger_error(__METHOD__."($url,$mode,$options) file can not be $op!",E_USER_WARNING);
@@ -313,7 +343,10 @@  discard block
 block discarded – undo
313 343
 		// do we operate directly on the filesystem --> open file from there
314 344
 		if ($this->operation == self::STORE2FS)
315 345
 		{
316
-			if (self::LOG_LEVEL > 1) error_log(__METHOD__." fopen (may create a directory? mkdir) ($this->opened_fs_id,$mode,$options)");
346
+			if (self::LOG_LEVEL > 1)
347
+			{
348
+				error_log(__METHOD__." fopen (may create a directory? mkdir) ($this->opened_fs_id,$mode,$options)");
349
+			}
317 350
 			if (!($this->opened_stream = fopen(self::_fs_path($this->opened_fs_id),$mode)) && $new_file)
318 351
 			{
319 352
 				// delete db entry again, if we are not able to open a new(!) file
@@ -322,11 +355,17 @@  discard block
 block discarded – undo
322 355
 				$stmt->execute(array('fs_id' => $this->opened_fs_id));
323 356
 			}
324 357
 		}
325
-		if ($mode[0] == 'a')	// append modes: a, a+
358
+		if ($mode[0] == 'a')
359
+		{
360
+			// append modes: a, a+
326 361
 		{
327 362
 			$this->stream_seek(0,SEEK_END);
328 363
 		}
329
-		if (!is_resource($this->opened_stream)) error_log(__METHOD__."($url,$mode,$options) NO stream, returning false!");
364
+		}
365
+		if (!is_resource($this->opened_stream))
366
+		{
367
+			error_log(__METHOD__."($url,$mode,$options) NO stream, returning false!");
368
+		}
330 369
 
331 370
 		return is_resource($this->opened_stream);
332 371
 	}
@@ -338,7 +377,10 @@  discard block
 block discarded – undo
338 377
 	 */
339 378
 	function stream_close ( )
340 379
 	{
341
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."()");
380
+		if (self::LOG_LEVEL > 1)
381
+		{
382
+			error_log(__METHOD__."()");
383
+		}
342 384
 
343 385
 		if (is_null($this->opened_path) || !is_resource($this->opened_stream) || !$this->opened_fs_id)
344 386
 		{
@@ -408,7 +450,10 @@  discard block
 block discarded – undo
408 450
 	 */
409 451
 	function stream_read ( $count )
410 452
 	{
411
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($count) pos=$this->opened_pos");
453
+		if (self::LOG_LEVEL > 1)
454
+		{
455
+			error_log(__METHOD__."($count) pos=$this->opened_pos");
456
+		}
412 457
 
413 458
 		if (is_resource($this->opened_stream))
414 459
 		{
@@ -430,7 +475,10 @@  discard block
 block discarded – undo
430 475
 	 */
431 476
 	function stream_write ( $data )
432 477
 	{
433
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($data)");
478
+		if (self::LOG_LEVEL > 1)
479
+		{
480
+			error_log(__METHOD__."($data)");
481
+		}
434 482
 
435 483
 		if (is_resource($this->opened_stream))
436 484
 		{
@@ -467,7 +515,10 @@  discard block
 block discarded – undo
467 515
 	 */
468 516
  	function stream_tell ( )
469 517
  	{
470
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."()");
518
+		if (self::LOG_LEVEL > 1)
519
+		{
520
+			error_log(__METHOD__."()");
521
+		}
471 522
 
472 523
 		if (is_resource($this->opened_stream))
473 524
 		{
@@ -490,7 +541,10 @@  discard block
 block discarded – undo
490 541
  	 */
491 542
 	function stream_seek ( $offset, $whence )
492 543
 	{
493
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($offset,$whence)");
544
+		if (self::LOG_LEVEL > 1)
545
+		{
546
+			error_log(__METHOD__."($offset,$whence)");
547
+		}
494 548
 
495 549
 		if (is_resource($this->opened_stream))
496 550
 		{
@@ -508,7 +562,10 @@  discard block
 block discarded – undo
508 562
 	 */
509 563
 	function stream_flush ( )
510 564
 	{
511
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."()");
565
+		if (self::LOG_LEVEL > 1)
566
+		{
567
+			error_log(__METHOD__."()");
568
+		}
512 569
 
513 570
 		if (is_resource($this->opened_stream))
514 571
 		{
@@ -533,7 +590,10 @@  discard block
 block discarded – undo
533 590
 	 */
534 591
 	function stream_stat ( )
535 592
 	{
536
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($this->opened_path)");
593
+		if (self::LOG_LEVEL > 1)
594
+		{
595
+			error_log(__METHOD__."($this->opened_path)");
596
+		}
537 597
 
538 598
 		return $this->url_stat($this->opened_path,0);
539 599
 	}
@@ -549,7 +609,10 @@  discard block
 block discarded – undo
549 609
 	 */
550 610
 	function unlink ( $url )
551 611
 	{
552
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url)");
612
+		if (self::LOG_LEVEL > 1)
613
+		{
614
+			error_log(__METHOD__."($url)");
615
+		}
553 616
 
554 617
 		$path = Vfs::parse_url($url,PHP_URL_PATH);
555 618
 
@@ -561,13 +624,19 @@  discard block
 block discarded – undo
561 624
 			!$dir || !Vfs::check_access($dir, Vfs::WRITABLE, $parent_stat))
562 625
 		{
563 626
 			self::_remove_password($url);
564
-			if (self::LOG_LEVEL) error_log(__METHOD__."($url) permission denied!");
627
+			if (self::LOG_LEVEL)
628
+			{
629
+				error_log(__METHOD__."($url) permission denied!");
630
+			}
565 631
 			return false;	// no permission or file does not exist
566 632
 		}
567 633
 		if ($stat['mime'] == self::DIR_MIME_TYPE)
568 634
 		{
569 635
 			self::_remove_password($url);
570
-			if (self::LOG_LEVEL) error_log(__METHOD__."($url) is NO file!");
636
+			if (self::LOG_LEVEL)
637
+			{
638
+				error_log(__METHOD__."($url) is NO file!");
639
+			}
571 640
 			return false;	// no permission or file does not exist
572 641
 		}
573 642
 		$stmt = self::$pdo->prepare('DELETE FROM '.self::TABLE.' WHERE fs_id=:fs_id');
@@ -602,7 +671,10 @@  discard block
 block discarded – undo
602 671
 	 */
603 672
 	function rename ( $url_from, $url_to)
604 673
 	{
605
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url_from,$url_to)");
674
+		if (self::LOG_LEVEL > 1)
675
+		{
676
+			error_log(__METHOD__."($url_from,$url_to)");
677
+		}
606 678
 
607 679
 		$path_from = Vfs::parse_url($url_from,PHP_URL_PATH);
608 680
 		$from_dir = Vfs::dirname($path_from);
@@ -614,14 +686,20 @@  discard block
 block discarded – undo
614 686
 		{
615 687
 			self::_remove_password($url_from);
616 688
 			self::_remove_password($url_to);
617
-			if (self::LOG_LEVEL) error_log(__METHOD__."($url_from,$url_to): $path_from permission denied!");
689
+			if (self::LOG_LEVEL)
690
+			{
691
+				error_log(__METHOD__."($url_from,$url_to): $path_from permission denied!");
692
+			}
618 693
 			return false;	// no permission or file does not exist
619 694
 		}
620 695
 		if (!$to_dir || !Vfs::check_access($to_dir, Vfs::WRITABLE, $to_dir_stat = $this->url_stat($to_dir, 0)))
621 696
 		{
622 697
 			self::_remove_password($url_from);
623 698
 			self::_remove_password($url_to);
624
-			if (self::LOG_LEVEL) error_log(__METHOD__."($url_from,$url_to): $path_to permission denied!");
699
+			if (self::LOG_LEVEL)
700
+			{
701
+				error_log(__METHOD__."($url_from,$url_to): $path_to permission denied!");
702
+			}
625 703
 			return false;	// no permission or parent-dir does not exist
626 704
 		}
627 705
 		// the filesystem stream-wrapper does NOT allow to rename files to directories, as this makes problems
@@ -632,14 +710,20 @@  discard block
 block discarded – undo
632 710
 			self::_remove_password($url_from);
633 711
 			self::_remove_password($url_to);
634 712
 			$is_dir = $to_stat['mime'] === self::DIR_MIME_TYPE ? 'a' : 'no';
635
-			if (self::LOG_LEVEL) error_log(__METHOD__."($url_to,$url_from) $path_to is $is_dir directory!");
713
+			if (self::LOG_LEVEL)
714
+			{
715
+				error_log(__METHOD__."($url_to,$url_from) $path_to is $is_dir directory!");
716
+			}
636 717
 			return false;	// no permission or file does not exist
637 718
 		}
638 719
 		// if destination file already exists, delete it
639 720
 		if ($to_stat && !$this->unlink($url_to))
640 721
 		{
641 722
 			self::_remove_password($url_to);
642
-			if (self::LOG_LEVEL) error_log(__METHOD__."($url_to,$url_from) can't unlink existing $url_to!");
723
+			if (self::LOG_LEVEL)
724
+			{
725
+				error_log(__METHOD__."($url_to,$url_from) can't unlink existing $url_to!");
726
+			}
643 727
 			return false;
644 728
 		}
645 729
 		unset(self::$stat_cache[$path_from]);
@@ -677,7 +761,10 @@  discard block
 block discarded – undo
677 761
 	{
678 762
 		$maxdepth=10;
679 763
 		$depth2propagate = (int)$depth + 1;
680
-		if ($depth2propagate > $maxdepth) return is_dir($pathname);
764
+		if ($depth2propagate > $maxdepth)
765
+		{
766
+			return is_dir($pathname);
767
+		}
681 768
     	is_dir(Vfs::dirname($pathname)) || self::mkdir_recursive(Vfs::dirname($pathname), $mode, $depth2propagate);
682 769
     	return is_dir($pathname) || @mkdir($pathname, $mode);
683 770
 	}
@@ -695,14 +782,23 @@  discard block
 block discarded – undo
695 782
 	 */
696 783
 	function mkdir ( $url, $mode, $options )
697 784
 	{
698
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$mode,$options)");
699
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__." called from:".function_backtrace());
785
+		if (self::LOG_LEVEL > 1)
786
+		{
787
+			error_log(__METHOD__."($url,$mode,$options)");
788
+		}
789
+		if (self::LOG_LEVEL > 1)
790
+		{
791
+			error_log(__METHOD__." called from:".function_backtrace());
792
+		}
700 793
 		$path = Vfs::parse_url($url,PHP_URL_PATH);
701 794
 
702 795
 		if ($this->url_stat($path,STREAM_URL_STAT_QUIET))
703 796
 		{
704 797
 			self::_remove_password($url);
705
-			if (self::LOG_LEVEL) error_log(__METHOD__."('$url',$mode,$options) already exist!");
798
+			if (self::LOG_LEVEL)
799
+			{
800
+				error_log(__METHOD__."('$url',$mode,$options) already exist!");
801
+			}
706 802
 			if (!($options & STREAM_REPORT_ERRORS))
707 803
 			{
708 804
 				trigger_error(__METHOD__."('$url',$mode,$options) already exist!",E_USER_WARNING);
@@ -712,21 +808,30 @@  discard block
 block discarded – undo
712 808
 		if (!($parent_path = Vfs::dirname($path)))
713 809
 		{
714 810
 			self::_remove_password($url);
715
-			if (self::LOG_LEVEL) error_log(__METHOD__."('$url',$mode,$options) dirname('$path')===false!");
811
+			if (self::LOG_LEVEL)
812
+			{
813
+				error_log(__METHOD__."('$url',$mode,$options) dirname('$path')===false!");
814
+			}
716 815
 			if (!($options & STREAM_REPORT_ERRORS))
717 816
 			{
718 817
 				trigger_error(__METHOD__."('$url',$mode,$options) dirname('$path')===false!", E_USER_WARNING);
719 818
 			}
720 819
 			return false;
721 820
 		}
722
-		if (($query = Vfs::parse_url($url,PHP_URL_QUERY))) $parent_path .= '?'.$query;
821
+		if (($query = Vfs::parse_url($url,PHP_URL_QUERY)))
822
+		{
823
+			$parent_path .= '?'.$query;
824
+		}
723 825
 		$parent = $this->url_stat($parent_path,STREAM_URL_STAT_QUIET);
724 826
 
725 827
 		// check if we should also create all non-existing path components and our parent does not exist,
726 828
 		// if yes call ourself recursive with the parent directory
727 829
 		if (($options & STREAM_MKDIR_RECURSIVE) && $parent_path != '/' && !$parent)
728 830
 		{
729
-			if (self::LOG_LEVEL > 1) error_log(__METHOD__." creating parents: $parent_path, $mode");
831
+			if (self::LOG_LEVEL > 1)
832
+			{
833
+				error_log(__METHOD__." creating parents: $parent_path, $mode");
834
+			}
730 835
 			if (!$this->mkdir($parent_path,$mode,$options))
731 836
 			{
732 837
 				return false;
@@ -736,7 +841,10 @@  discard block
 block discarded – undo
736 841
 		if (!$parent || !Vfs::check_access($parent_path,Vfs::WRITABLE,$parent))
737 842
 		{
738 843
 			self::_remove_password($url);
739
-			if (self::LOG_LEVEL) error_log(__METHOD__."('$url',$mode,$options) permission denied!");
844
+			if (self::LOG_LEVEL)
845
+			{
846
+				error_log(__METHOD__."('$url',$mode,$options) permission denied!");
847
+			}
740 848
 			if (!($options & STREAM_REPORT_ERRORS))
741 849
 			{
742 850
 				trigger_error(__METHOD__."('$url',$mode,$options) permission denied!",E_USER_WARNING);
@@ -770,10 +878,13 @@  discard block
 block discarded – undo
770 878
 				'fs_dir'  => $parent['ino'],
771 879
 				'fs_active' => self::_pdo_boolean(true),
772 880
 				'fs_name' => self::limit_filename(Vfs::basename($path)),
773
-			)) && $stmt->fetchColumn() > 1)	// if there's more then one --> remove our new dir
881
+			)) && $stmt->fetchColumn() > 1)
882
+			{
883
+				// if there's more then one --> remove our new dir
774 884
 			{
775 885
 				self::$pdo->query('DELETE FROM '.self::TABLE.' WHERE fs_id='.$new_fs_id);
776 886
 			}
887
+			}
777 888
 		}
778 889
 		return $ok;
779 890
 	}
@@ -790,7 +901,10 @@  discard block
 block discarded – undo
790 901
 	 */
791 902
 	function rmdir ( $url, $options )
792 903
 	{
793
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url)");
904
+		if (self::LOG_LEVEL > 1)
905
+		{
906
+			error_log(__METHOD__."($url)");
907
+		}
794 908
 
795 909
 		$path = Vfs::parse_url($url,PHP_URL_PATH);
796 910
 
@@ -801,7 +915,10 @@  discard block
 block discarded – undo
801 915
 			self::_remove_password($url);
802 916
 			$err_msg = __METHOD__."($url,$options) ".(!$stat ? 'not found!' :
803 917
 				($stat['mime'] != self::DIR_MIME_TYPE ? 'not a directory!' : 'permission denied!'));
804
-			if (self::LOG_LEVEL) error_log($err_msg);
918
+			if (self::LOG_LEVEL)
919
+			{
920
+				error_log($err_msg);
921
+			}
805 922
 			if (!($options & STREAM_REPORT_ERRORS))
806 923
 			{
807 924
 				trigger_error($err_msg,E_USER_WARNING);
@@ -813,7 +930,10 @@  discard block
 block discarded – undo
813 930
 		if ($stmt->fetchColumn())
814 931
 		{
815 932
 			self::_remove_password($url);
816
-			if (self::LOG_LEVEL) error_log(__METHOD__."($url,$options) dir is not empty!");
933
+			if (self::LOG_LEVEL)
934
+			{
935
+				error_log(__METHOD__."($url,$options) dir is not empty!");
936
+			}
817 937
 			if (!($options & STREAM_REPORT_ERRORS))
818 938
 			{
819 939
 				trigger_error(__METHOD__."('$url',$options) dir is not empty!",E_USER_WARNING);
@@ -851,7 +971,10 @@  discard block
 block discarded – undo
851 971
 	 */
852 972
 	function stream_metadata($path, $option, $value)
853 973
 	{
854
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($path, $option, ".array2string($value).")");
974
+		if (self::LOG_LEVEL > 1)
975
+		{
976
+			error_log(__METHOD__."($path, $option, ".array2string($value).")");
977
+		}
855 978
 
856 979
 		switch($option)
857 980
 		{
@@ -863,14 +986,18 @@  discard block
 block discarded – undo
863 986
 
864 987
 			case STREAM_META_OWNER_NAME:
865 988
 				if (($value = $GLOBALS['egw']->accounts->name2id($value, 'account_lid', 'u')) === false)
866
-					return false;
989
+				{
990
+									return false;
991
+				}
867 992
 				// fall through
868 993
 			case STREAM_META_OWNER:
869 994
 				return $this->chown($path, $value);
870 995
 
871 996
 			case STREAM_META_GROUP_NAME:
872 997
 				if (($value = $GLOBALS['egw']->accounts->name2id($value, 'account_lid', 'g')) === false)
873
-					return false;
998
+				{
999
+									return false;
1000
+				}
874 1001
 				// fall through
875 1002
 			case STREAM_META_GROUP:
876 1003
 				return $this->chgrp($path, $value);
@@ -888,7 +1015,10 @@  discard block
 block discarded – undo
888 1015
 	protected function touch($url,$time=null,$atime=null)
889 1016
 	{
890 1017
 		unset($atime);	// not used
891
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url, $time)");
1018
+		if (self::LOG_LEVEL > 1)
1019
+		{
1020
+			error_log(__METHOD__."($url, $time)");
1021
+		}
892 1022
 
893 1023
 		$path = Vfs::parse_url($url,PHP_URL_PATH);
894 1024
 
@@ -925,26 +1055,38 @@  discard block
 block discarded – undo
925 1055
 	 */
926 1056
 	protected function chown($url,$owner)
927 1057
 	{
928
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$owner)");
1058
+		if (self::LOG_LEVEL > 1)
1059
+		{
1060
+			error_log(__METHOD__."($url,$owner)");
1061
+		}
929 1062
 
930 1063
 		$path = Vfs::parse_url($url,PHP_URL_PATH);
931 1064
 
932 1065
 		$vfs = new self();
933 1066
 		if (!($stat = $vfs->url_stat($path,0)))
934 1067
 		{
935
-			if (self::LOG_LEVEL) error_log(__METHOD__."($url,$owner) no such file or directory!");
1068
+			if (self::LOG_LEVEL)
1069
+			{
1070
+				error_log(__METHOD__."($url,$owner) no such file or directory!");
1071
+			}
936 1072
 			trigger_error("No such file or directory $url !",E_USER_WARNING);
937 1073
 			return false;
938 1074
 		}
939 1075
 		if (!Vfs::$is_root)
940 1076
 		{
941
-			if (self::LOG_LEVEL) error_log(__METHOD__."($url,$owner) only root can do that!");
1077
+			if (self::LOG_LEVEL)
1078
+			{
1079
+				error_log(__METHOD__."($url,$owner) only root can do that!");
1080
+			}
942 1081
 			trigger_error("Only root can do that!",E_USER_WARNING);
943 1082
 			return false;
944 1083
 		}
945
-		if ($owner < 0 || $owner && !$GLOBALS['egw']->accounts->id2name($owner))	// not a user (0 == root)
1084
+		if ($owner < 0 || $owner && !$GLOBALS['egw']->accounts->id2name($owner))
1085
+		{
1086
+			// not a user (0 == root)
946 1087
 		{
947 1088
 			if (self::LOG_LEVEL) error_log(__METHOD__."($url,$owner) unknown (numeric) user id!");
1089
+		}
948 1090
 			trigger_error(__METHOD__."($url,$owner) Unknown (numeric) user id!",E_USER_WARNING);
949 1091
 			//throw new Exception(__METHOD__."($url,$owner) Unknown (numeric) user id!");
950 1092
 			return false;
@@ -952,7 +1094,10 @@  discard block
 block discarded – undo
952 1094
 		$stmt = self::$pdo->prepare('UPDATE '.self::TABLE.' SET fs_uid=:fs_uid WHERE fs_id=:fs_id');
953 1095
 
954 1096
 		// update stat-cache
955
-		if ($path != '/' && substr($path,-1) == '/') $path = substr($path, 0, -1);
1097
+		if ($path != '/' && substr($path,-1) == '/')
1098
+		{
1099
+			$path = substr($path, 0, -1);
1100
+		}
956 1101
 		self::$stat_cache[$path]['fs_uid'] = $owner;
957 1102
 
958 1103
 		return $stmt->execute(array(
@@ -970,35 +1115,54 @@  discard block
 block discarded – undo
970 1115
 	 */
971 1116
 	protected function chgrp($url,$owner)
972 1117
 	{
973
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$owner)");
1118
+		if (self::LOG_LEVEL > 1)
1119
+		{
1120
+			error_log(__METHOD__."($url,$owner)");
1121
+		}
974 1122
 
975 1123
 		$path = Vfs::parse_url($url,PHP_URL_PATH);
976 1124
 
977 1125
 		$vfs = new self();
978 1126
 		if (!($stat = $vfs->url_stat($path,0)))
979 1127
 		{
980
-			if (self::LOG_LEVEL) error_log(__METHOD__."($url,$owner) no such file or directory!");
1128
+			if (self::LOG_LEVEL)
1129
+			{
1130
+				error_log(__METHOD__."($url,$owner) no such file or directory!");
1131
+			}
981 1132
 			trigger_error("No such file or directory $url !",E_USER_WARNING);
982 1133
 			return false;
983 1134
 		}
984 1135
 		if (!Vfs::has_owner_rights($path,$stat))
985 1136
 		{
986
-			if (self::LOG_LEVEL) error_log(__METHOD__."($url,$owner) only owner or root can do that!");
1137
+			if (self::LOG_LEVEL)
1138
+			{
1139
+				error_log(__METHOD__."($url,$owner) only owner or root can do that!");
1140
+			}
987 1141
 			trigger_error("Only owner or root can do that!",E_USER_WARNING);
988 1142
 			return false;
989 1143
 		}
990
-		if ($owner < 0) $owner = -$owner;	// sqlfs uses a positiv group id's!
1144
+		if ($owner < 0)
1145
+		{
1146
+			$owner = -$owner;
1147
+		}
1148
+		// sqlfs uses a positiv group id's!
991 1149
 
992
-		if ($owner && !$GLOBALS['egw']->accounts->id2name(-$owner))	// not a group
1150
+		if ($owner && !$GLOBALS['egw']->accounts->id2name(-$owner))
1151
+		{
1152
+			// not a group
993 1153
 		{
994 1154
 			if (self::LOG_LEVEL) error_log(__METHOD__."($url,$owner) unknown (numeric) group id!");
1155
+		}
995 1156
 			trigger_error("Unknown (numeric) group id!",E_USER_WARNING);
996 1157
 			return false;
997 1158
 		}
998 1159
 		$stmt = self::$pdo->prepare('UPDATE '.self::TABLE.' SET fs_gid=:fs_gid WHERE fs_id=:fs_id');
999 1160
 
1000 1161
 		// update stat-cache
1001
-		if ($path != '/' && substr($path,-1) == '/') $path = substr($path, 0, -1);
1162
+		if ($path != '/' && substr($path,-1) == '/')
1163
+		{
1164
+			$path = substr($path, 0, -1);
1165
+		}
1002 1166
 		self::$stat_cache[$path]['fs_gid'] = $owner;
1003 1167
 
1004 1168
 		return $stmt->execute(array(
@@ -1016,33 +1180,48 @@  discard block
 block discarded – undo
1016 1180
 	 */
1017 1181
 	protected function chmod($url,$mode)
1018 1182
 	{
1019
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url, $mode)");
1183
+		if (self::LOG_LEVEL > 1)
1184
+		{
1185
+			error_log(__METHOD__."($url, $mode)");
1186
+		}
1020 1187
 
1021 1188
 		$path = Vfs::parse_url($url,PHP_URL_PATH);
1022 1189
 
1023 1190
 		$vfs = new self();
1024 1191
 		if (!($stat = $vfs->url_stat($path,0)))
1025 1192
 		{
1026
-			if (self::LOG_LEVEL) error_log(__METHOD__."($url, $mode) no such file or directory!");
1193
+			if (self::LOG_LEVEL)
1194
+			{
1195
+				error_log(__METHOD__."($url, $mode) no such file or directory!");
1196
+			}
1027 1197
 			trigger_error("No such file or directory $url !",E_USER_WARNING);
1028 1198
 			return false;
1029 1199
 		}
1030 1200
 		if (!Vfs::has_owner_rights($path,$stat))
1031 1201
 		{
1032
-			if (self::LOG_LEVEL) error_log(__METHOD__."($url, $mode) only owner or root can do that!");
1202
+			if (self::LOG_LEVEL)
1203
+			{
1204
+				error_log(__METHOD__."($url, $mode) only owner or root can do that!");
1205
+			}
1033 1206
 			trigger_error("Only owner or root can do that!",E_USER_WARNING);
1034 1207
 			return false;
1035 1208
 		}
1036
-		if (!is_numeric($mode))	// not a mode
1209
+		if (!is_numeric($mode))
1210
+		{
1211
+			// not a mode
1037 1212
 		{
1038 1213
 			if (self::LOG_LEVEL) error_log(__METHOD__."($url, $mode) no (numeric) mode!");
1214
+		}
1039 1215
 			trigger_error("No (numeric) mode!",E_USER_WARNING);
1040 1216
 			return false;
1041 1217
 		}
1042 1218
 		$stmt = self::$pdo->prepare('UPDATE '.self::TABLE.' SET fs_mode=:fs_mode WHERE fs_id=:fs_id');
1043 1219
 
1044 1220
 		// update stat cache
1045
-		if ($path != '/' && substr($path,-1) == '/') $path = substr($path, 0, -1);
1221
+		if ($path != '/' && substr($path,-1) == '/')
1222
+		{
1223
+			$path = substr($path, 0, -1);
1224
+		}
1046 1225
 		self::$stat_cache[$path]['fs_mode'] = ((int) $mode) & 0777;
1047 1226
 
1048 1227
 		return $stmt->execute(array(
@@ -1067,12 +1246,18 @@  discard block
 block discarded – undo
1067 1246
 
1068 1247
 		if (!($stat = $this->url_stat($url,0)) || 		// dir not found
1069 1248
 			!($stat['mode'] & self::MODE_DIR) && $stat['mime'] != self::DIR_MIME_TYPE ||		// no dir
1070
-			!Vfs::check_access($url,Vfs::EXECUTABLE|Vfs::READABLE,$stat))	// no access
1249
+			!Vfs::check_access($url,Vfs::EXECUTABLE|Vfs::READABLE,$stat))
1250
+		{
1251
+			// no access
1071 1252
 		{
1072 1253
 			self::_remove_password($url);
1254
+		}
1073 1255
 			$msg = !($stat['mode'] & self::MODE_DIR) && $stat['mime'] != self::DIR_MIME_TYPE ?
1074 1256
 				"$url is no directory" : 'permission denied';
1075
-			if (self::LOG_LEVEL) error_log(__METHOD__."('$url',$options) $msg!");
1257
+			if (self::LOG_LEVEL)
1258
+			{
1259
+				error_log(__METHOD__."('$url',$options) $msg!");
1260
+			}
1076 1261
 			$this->opened_dir = null;
1077 1262
 			return false;
1078 1263
 		}
@@ -1081,7 +1266,10 @@  discard block
 block discarded – undo
1081 1266
 			' FROM '.self::TABLE.' WHERE fs_dir=? AND fs_active='.self::_pdo_boolean(true).
1082 1267
 			" ORDER BY fs_mime='httpd/unix-directory' DESC, fs_name ASC";
1083 1268
 		//if (self::LOG_LEVEL > 2) $query = '/* '.__METHOD__.': '.__LINE__.' */ '.$query;
1084
-		if (self::LOG_LEVEL > 2) $query = '/* '.__METHOD__."($url,$options)".' */ '.$query;
1269
+		if (self::LOG_LEVEL > 2)
1270
+		{
1271
+			$query = '/* '.__METHOD__."($url,$options)".' */ '.$query;
1272
+		}
1085 1273
 
1086 1274
 		$stmt = self::$pdo->prepare($query);
1087 1275
 		$stmt->setFetchMode(\PDO::FETCH_ASSOC);
@@ -1093,7 +1281,10 @@  discard block
 block discarded – undo
1093 1281
 				self::$stat_cache[Vfs::concat($path,$file['fs_name'])] = $file;
1094 1282
 			}
1095 1283
 		}
1096
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$options): ".implode(', ',$this->opened_dir));
1284
+		if (self::LOG_LEVEL > 1)
1285
+		{
1286
+			error_log(__METHOD__."($url,$options): ".implode(', ',$this->opened_dir));
1287
+		}
1097 1288
 		reset($this->opened_dir);
1098 1289
 
1099 1290
 		return true;
@@ -1131,9 +1322,16 @@  discard block
 block discarded – undo
1131 1322
 		if (is_null($max_subquery_depth))
1132 1323
 		{
1133 1324
 			$max_subquery_depth = $GLOBALS['egw_info']['server']['max_subquery_depth'];
1134
-			if (!$max_subquery_depth) $max_subquery_depth = 7;	// setting current default of 7, if nothing set
1325
+			if (!$max_subquery_depth)
1326
+			{
1327
+				$max_subquery_depth = 7;
1328
+			}
1329
+			// setting current default of 7, if nothing set
1330
+		}
1331
+		if (self::LOG_LEVEL > 1)
1332
+		{
1333
+			error_log(__METHOD__."('$url',$flags)");
1135 1334
 		}
1136
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$url',$flags)");
1137 1335
 
1138 1336
 		$path = Vfs::parse_url($url,PHP_URL_PATH);
1139 1337
 
@@ -1196,7 +1394,10 @@  discard block
 block discarded – undo
1196 1394
 						if (!Vfs::$user)
1197 1395
 						{
1198 1396
 							self::_remove_password($url);
1199
-							if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$url',$flags) permission denied, no user-id and not root!");
1397
+							if (self::LOG_LEVEL > 1)
1398
+							{
1399
+								error_log(__METHOD__."('$url',$flags) permission denied, no user-id and not root!");
1400
+							}
1200 1401
 							return false;
1201 1402
 						}
1202 1403
 						$query .= ' AND '.self::_sql_readable();
@@ -1207,7 +1408,10 @@  discard block
 block discarded – undo
1207 1408
 					$query = str_replace('fs_name'.self::$case_sensitive_equal.'?','fs_name'.self::$case_sensitive_equal.self::$pdo->quote($name),$base_query).'('.$query.')';
1208 1409
 				}
1209 1410
 			}
1210
-			if (self::LOG_LEVEL > 2) $query = '/* '.__METHOD__."($url,$flags) eacl_access=$eacl_access".' */ '.$query;
1411
+			if (self::LOG_LEVEL > 2)
1412
+			{
1413
+				$query = '/* '.__METHOD__."($url,$flags) eacl_access=$eacl_access".' */ '.$query;
1414
+			}
1211 1415
 			//if (self::LOG_LEVEL > 2) $query = '/* '.__METHOD__.': '.__LINE__.' */ '.$query;
1212 1416
 
1213 1417
 			if (!($result = self::$pdo->query($query)) || !($info = $result->fetch(\PDO::FETCH_ASSOC)))
@@ -1230,12 +1434,18 @@  discard block
 block discarded – undo
1230 1434
 			$GLOBALS['egw_info']['server']['max_subquery_depth'] = --$max_subquery_depth;
1231 1435
 			error_log(__METHOD__."() decremented max_subquery_depth to $max_subquery_depth");
1232 1436
 			Api\Config::save_value('max_subquery_depth', $max_subquery_depth, 'phpgwapi');
1233
-			if (method_exists($GLOBALS['egw'],'invalidate_session_cache')) $GLOBALS['egw']->invalidate_session_cache();
1437
+			if (method_exists($GLOBALS['egw'],'invalidate_session_cache'))
1438
+			{
1439
+				$GLOBALS['egw']->invalidate_session_cache();
1440
+			}
1234 1441
 			return $this->url_stat($url, $flags);
1235 1442
 		}
1236 1443
 		self::$stat_cache[$path] = $info;
1237 1444
 
1238
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$flags)=".array2string($info));
1445
+		if (self::LOG_LEVEL > 1)
1446
+		{
1447
+			error_log(__METHOD__."($url,$flags)=".array2string($info));
1448
+		}
1239 1449
 		return self::_vfsinfo2stat($info);
1240 1450
 	}
1241 1451
 
@@ -1272,9 +1482,15 @@  discard block
 block discarded – undo
1272 1482
 	 */
1273 1483
 	function dir_readdir ( )
1274 1484
 	{
1275
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."( )");
1485
+		if (self::LOG_LEVEL > 1)
1486
+		{
1487
+			error_log(__METHOD__."( )");
1488
+		}
1276 1489
 
1277
-		if (!is_array($this->opened_dir)) return false;
1490
+		if (!is_array($this->opened_dir))
1491
+		{
1492
+			return false;
1493
+		}
1278 1494
 
1279 1495
 		$file = current($this->opened_dir); next($this->opened_dir);
1280 1496
 
@@ -1291,9 +1507,15 @@  discard block
 block discarded – undo
1291 1507
 	 */
1292 1508
 	function dir_rewinddir ( )
1293 1509
 	{
1294
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."( )");
1510
+		if (self::LOG_LEVEL > 1)
1511
+		{
1512
+			error_log(__METHOD__."( )");
1513
+		}
1295 1514
 
1296
-		if (!is_array($this->opened_dir)) return false;
1515
+		if (!is_array($this->opened_dir))
1516
+		{
1517
+			return false;
1518
+		}
1297 1519
 
1298 1520
 		reset($this->opened_dir);
1299 1521
 
@@ -1309,9 +1531,15 @@  discard block
 block discarded – undo
1309 1531
 	 */
1310 1532
 	function dir_closedir ( )
1311 1533
 	{
1312
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."( )");
1534
+		if (self::LOG_LEVEL > 1)
1535
+		{
1536
+			error_log(__METHOD__."( )");
1537
+		}
1313 1538
 
1314
-		if (!is_array($this->opened_dir)) return false;
1539
+		if (!is_array($this->opened_dir))
1540
+		{
1541
+			return false;
1542
+		}
1315 1543
 
1316 1544
 		$this->opened_dir = null;
1317 1545
 
@@ -1331,7 +1559,10 @@  discard block
 block discarded – undo
1331 1559
 		$vfs = new self();
1332 1560
 		$link = !($lstat = $vfs->url_stat($path,STREAM_URL_STAT_LINK)) || is_null($lstat['readlink']) ? false : $lstat['readlink'];
1333 1561
 
1334
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path') = $link");
1562
+		if (self::LOG_LEVEL > 1)
1563
+		{
1564
+			error_log(__METHOD__."('$path') = $link");
1565
+		}
1335 1566
 
1336 1567
 		return $link;
1337 1568
 	}
@@ -1345,23 +1576,35 @@  discard block
 block discarded – undo
1345 1576
 	 */
1346 1577
 	static function symlink($target,$link)
1347 1578
 	{
1348
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$target','$link')");
1579
+		if (self::LOG_LEVEL > 1)
1580
+		{
1581
+			error_log(__METHOD__."('$target','$link')");
1582
+		}
1349 1583
 
1350 1584
 		$inst = new static();
1351 1585
 		if ($inst->url_stat($link,0))
1352 1586
 		{
1353
-			if (self::LOG_LEVEL > 0) error_log(__METHOD__."('$target','$link') $link exists, returning false!");
1587
+			if (self::LOG_LEVEL > 0)
1588
+			{
1589
+				error_log(__METHOD__."('$target','$link') $link exists, returning false!");
1590
+			}
1354 1591
 			return false;	// $link already exists
1355 1592
 		}
1356 1593
 		if (!($dir = Vfs::dirname($link)) ||
1357 1594
 			!Vfs::check_access($dir,Vfs::WRITABLE,$dir_stat=$inst->url_stat($dir,0)))
1358 1595
 		{
1359
-			if (self::LOG_LEVEL > 0) error_log(__METHOD__."('$target','$link') returning false! (!is_writable('$dir'), dir_stat=".array2string($dir_stat).")");
1596
+			if (self::LOG_LEVEL > 0)
1597
+			{
1598
+				error_log(__METHOD__."('$target','$link') returning false! (!is_writable('$dir'), dir_stat=".array2string($dir_stat).")");
1599
+			}
1360 1600
 			return false;	// parent dir does not exist or is not writable
1361 1601
 		}
1362 1602
 		$query = 'INSERT INTO '.self::TABLE.' (fs_name,fs_dir,fs_mode,fs_uid,fs_gid,fs_created,fs_modified,fs_creator,fs_mime,fs_size,fs_link'.
1363 1603
 			') VALUES (:fs_name,:fs_dir,:fs_mode,:fs_uid,:fs_gid,:fs_created,:fs_modified,:fs_creator,:fs_mime,:fs_size,:fs_link)';
1364
-		if (self::LOG_LEVEL > 2) $query = '/* '.__METHOD__.': '.__LINE__.' */ '.$query;
1604
+		if (self::LOG_LEVEL > 2)
1605
+		{
1606
+			$query = '/* '.__METHOD__.': '.__LINE__.' */ '.$query;
1607
+		}
1365 1608
 		$stmt = self::$pdo->prepare($query);
1366 1609
 		unset(self::$stat_cache[Vfs::parse_url($link,PHP_URL_PATH)]);
1367 1610
 
@@ -1409,7 +1652,10 @@  discard block
 block discarded – undo
1409 1652
 				break;
1410 1653
 			}
1411 1654
 		}
1412
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$check) ".($access?"access granted by $path=$rights":'no access!!!'));
1655
+		if (self::LOG_LEVEL > 1)
1656
+		{
1657
+			error_log(__METHOD__."($url,$check) ".($access?"access granted by $path=$rights":'no access!!!'));
1658
+		}
1413 1659
 		return $access;
1414 1660
 	}
1415 1661
 
@@ -1437,11 +1683,15 @@  discard block
 block discarded – undo
1437 1683
 			}
1438 1684
 		}
1439 1685
 		// sort by length descending, to allow more specific pathes to have precedence
1440
-		uksort(self::$extended_acl, function($a,$b) {
1686
+		uksort(self::$extended_acl, function($a,$b)
1687
+		{
1441 1688
 			return strlen($b)-strlen($a);
1442 1689
 		});
1443 1690
 		Api\Cache::setSession(self::EACL_APPNAME, 'extended_acl', self::$extended_acl);
1444
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__.'() '.array2string(self::$extended_acl));
1691
+		if (self::LOG_LEVEL > 1)
1692
+		{
1693
+			error_log(__METHOD__.'() '.array2string(self::$extended_acl));
1694
+		}
1445 1695
 	}
1446 1696
 
1447 1697
 	/**
@@ -1471,12 +1721,18 @@  discard block
 block discarded – undo
1471 1721
 			$vfs = new self();
1472 1722
 			if (!($stat = $vfs->url_stat($path,0)))
1473 1723
 			{
1474
-				if (self::LOG_LEVEL) error_log(__METHOD__."($path,$rights,$owner,$fs_id) no such file or directory!");
1724
+				if (self::LOG_LEVEL)
1725
+				{
1726
+					error_log(__METHOD__."($path,$rights,$owner,$fs_id) no such file or directory!");
1727
+				}
1475 1728
 				return false;	// $path not found
1476 1729
 			}
1477
-			if (!Vfs::has_owner_rights($path,$stat))		// not group dir and user is eGW admin
1730
+			if (!Vfs::has_owner_rights($path,$stat))
1731
+			{
1732
+				// not group dir and user is eGW admin
1478 1733
 			{
1479 1734
 				if (self::LOG_LEVEL) error_log(__METHOD__."($path,$rights,$owner,$fs_id) permission denied!");
1735
+			}
1480 1736
 				return false;	// permission denied
1481 1737
 			}
1482 1738
 			$fs_id = $stat['ino'];
@@ -1509,7 +1765,10 @@  discard block
 block discarded – undo
1509 1765
 		{
1510 1766
 			Api\Cache::setSession(self::EACL_APPNAME, 'extended_acl', self::$extended_acl);
1511 1767
 		}
1512
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($path,$rights,$owner,$fs_id)=".(int)$ret);
1768
+		if (self::LOG_LEVEL > 1)
1769
+		{
1770
+			error_log(__METHOD__."($path,$rights,$owner,$fs_id)=".(int)$ret);
1771
+		}
1513 1772
 		return $ret;
1514 1773
 	}
1515 1774
 
@@ -1544,7 +1803,8 @@  discard block
 block discarded – undo
1544 1803
 			$eacls = array_merge((array)self::get_eacl($path),$eacls);
1545 1804
 		}
1546 1805
 		// sort by length descending, to show precedence
1547
-		usort($eacls, function($a, $b) {
1806
+		usort($eacls, function($a, $b)
1807
+		{
1548 1808
 			return strlen($b['path']) - strlen($a['path']);
1549 1809
 		});
1550 1810
 		//error_log(__METHOD__."('$_path') returning ".array2string($eacls));
@@ -1602,7 +1862,10 @@  discard block
 block discarded – undo
1602 1862
 	 */
1603 1863
 	static function id2path($fs_ids, $recursion_count=0)
1604 1864
 	{
1605
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__.'('.array2string($fs_ids).')');
1865
+		if (self::LOG_LEVEL > 1)
1866
+		{
1867
+			error_log(__METHOD__.'('.array2string($fs_ids).')');
1868
+		}
1606 1869
 		if ($recursion_count > self::MAX_ID2PATH_RECURSION)
1607 1870
 		{
1608 1871
 			error_log(__METHOD__."(".array2string($fs_ids).", $recursion_count) max recursion depth reached, probably broken filesystem!");
@@ -1619,16 +1882,26 @@  discard block
 block discarded – undo
1619 1882
 				unset($ids[$key]);
1620 1883
 				if (!$ids)
1621 1884
 				{
1622
-					if (self::LOG_LEVEL > 1) error_log(__METHOD__.'('.array2string($fs_ids).')='.array2string($pathes).' *from stat_cache*');
1885
+					if (self::LOG_LEVEL > 1)
1886
+					{
1887
+						error_log(__METHOD__.'('.array2string($fs_ids).')='.array2string($pathes).' *from stat_cache*');
1888
+					}
1623 1889
 					return is_array($fs_ids) ? $pathes : array_shift($pathes);
1624 1890
 				}
1625 1891
 			}
1626 1892
 		}
1627 1893
 		// now search via the database
1628
-		if (count($ids) > 1) $ids = array_map(function($v) { return (int)$v; }, $ids);
1894
+		if (count($ids) > 1)
1895
+		{
1896
+			$ids = array_map(function($v) { return (int)$v;
1897
+		}
1898
+		}, $ids);
1629 1899
 		$query = 'SELECT fs_id,fs_dir,fs_name FROM '.self::TABLE.' WHERE fs_id'.
1630 1900
 			(count($ids) == 1 ? '='.(int)$ids[0] : ' IN ('.implode(',',$ids).')');
1631
-		if (self::LOG_LEVEL > 2) $query = '/* '.__METHOD__.': '.__LINE__.' */ '.$query;
1901
+		if (self::LOG_LEVEL > 2)
1902
+		{
1903
+			$query = '/* '.__METHOD__.': '.__LINE__.' */ '.$query;
1904
+		}
1632 1905
 
1633 1906
 		if (!is_object(self::$pdo))
1634 1907
 		{
@@ -1655,14 +1928,20 @@  discard block
 block discarded – undo
1655 1928
 		{
1656 1929
 			return false;	// parent not found, should never happen ...
1657 1930
 		}
1658
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__." trying foreach with:".print_r($rows,true)."#");
1931
+		if (self::LOG_LEVEL > 1)
1932
+		{
1933
+			error_log(__METHOD__." trying foreach with:".print_r($rows,true)."#");
1934
+		}
1659 1935
 		foreach((array)$rows as $fs_id => $row)
1660 1936
 		{
1661 1937
 			$parent = $row['fs_dir'] > 1 ? $parents[$row['fs_dir']] : '';
1662 1938
 
1663 1939
 			$pathes[$fs_id] = $parent . '/' . $row['fs_name'];
1664 1940
 		}
1665
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__.'('.array2string($fs_ids).')='.array2string($pathes));
1941
+		if (self::LOG_LEVEL > 1)
1942
+		{
1943
+			error_log(__METHOD__.'('.array2string($fs_ids).')='.array2string($pathes));
1944
+		}
1666 1945
 		return is_array($fs_ids) ? $pathes : array_shift($pathes);
1667 1946
 	}
1668 1947
 
@@ -1718,7 +1997,10 @@  discard block
 block discarded – undo
1718 1997
 			'mime'  => $info['fs_mime'],
1719 1998
 			'readlink' => $info['fs_link'],
1720 1999
 		);
1721
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($info[name]) = ".array2string($stat));
2000
+		if (self::LOG_LEVEL > 1)
2001
+		{
2002
+			error_log(__METHOD__."($info[name]) = ".array2string($stat));
2003
+		}
1722 2004
 		return $stat;
1723 2005
 	}
1724 2006
 
@@ -1750,13 +2032,16 @@  discard block
 block discarded – undo
1750 2032
 		}
1751 2033
 		if (!isset($GLOBALS['egw_info']['server']['files_dir']))
1752 2034
 		{
1753
-			if (is_object($GLOBALS['egw_setup']->db))	// if we run under setup, query the db for the files dir
2035
+			if (is_object($GLOBALS['egw_setup']->db))
2036
+			{
2037
+				// if we run under setup, query the db for the files dir
1754 2038
 			{
1755 2039
 				$GLOBALS['egw_info']['server']['files_dir'] = $GLOBALS['egw_setup']->db->select('egw_config','config_value',array(
1756 2040
 					'config_name' => 'files_dir',
1757 2041
 					'config_app' => 'phpgwapi',
1758 2042
 				),__LINE__,__FILE__)->fetchColumn();
1759 2043
 			}
2044
+			}
1760 2045
 		}
1761 2046
 		if (!$GLOBALS['egw_info']['server']['files_dir'])
1762 2047
 		{
@@ -1768,7 +2053,11 @@  discard block
 block discarded – undo
1768 2053
 		{
1769 2054
 			$hash[] = sprintf('%02d',$n % self::HASH_MAX);
1770 2055
 		}
1771
-		if (!$hash) $hash[] = '00';		// we need at least one directory, to not conflict with the dir-names
2056
+		if (!$hash)
2057
+		{
2058
+			$hash[] = '00';
2059
+		}
2060
+		// we need at least one directory, to not conflict with the dir-names
1772 2061
 		array_unshift($hash,$id);
1773 2062
 
1774 2063
 		$path = '/sqlfs/'.implode('/',array_reverse($hash));
@@ -1831,10 +2120,16 @@  discard block
 block discarded – undo
1831 2120
 	static function proppatch($path,array $props)
1832 2121
 	{
1833 2122
 		static $inst = null;
1834
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."(".array2string($path).','.array2string($props));
2123
+		if (self::LOG_LEVEL > 1)
2124
+		{
2125
+			error_log(__METHOD__."(".array2string($path).','.array2string($props));
2126
+		}
1835 2127
 		if (!is_numeric($path))
1836 2128
 		{
1837
-			if (!isset($inst)) $inst = new self();
2129
+			if (!isset($inst))
2130
+			{
2131
+				$inst = new self();
2132
+			}
1838 2133
 			if (!($stat = $inst->url_stat($path,0)))
1839 2134
 			{
1840 2135
 				return false;
@@ -1852,13 +2147,19 @@  discard block
 block discarded – undo
1852 2147
 		$ins_stmt = $del_stmt = null;
1853 2148
 		foreach($props as &$prop)
1854 2149
 		{
1855
-			if (!isset($prop['ns'])) $prop['ns'] = Vfs::DEFAULT_PROP_NAMESPACE;
2150
+			if (!isset($prop['ns']))
2151
+			{
2152
+				$prop['ns'] = Vfs::DEFAULT_PROP_NAMESPACE;
2153
+			}
1856 2154
 
1857
-			if (!isset($prop['val']) || self::$pdo_type != 'mysql')	// for non mysql, we have to delete the prop anyway, as there's no REPLACE!
2155
+			if (!isset($prop['val']) || self::$pdo_type != 'mysql')
2156
+			{
2157
+				// for non mysql, we have to delete the prop anyway, as there's no REPLACE!
1858 2158
 			{
1859 2159
 				if (!isset($del_stmt))
1860 2160
 				{
1861 2161
 					$del_stmt = self::$pdo->prepare('DELETE FROM '.self::PROPS_TABLE.' WHERE fs_id=:fs_id AND prop_namespace=:prop_namespace AND prop_name=:prop_name');
2162
+			}
1862 2163
 				}
1863 2164
 				$del_stmt->execute(array(
1864 2165
 					'fs_id'          => $id,
@@ -1904,20 +2205,33 @@  discard block
 block discarded – undo
1904 2205
 		{
1905 2206
 			if (!is_numeric($id))
1906 2207
 			{
1907
-				if (!isset($inst)) $inst = new self();
2208
+				if (!isset($inst))
2209
+				{
2210
+					$inst = new self();
2211
+				}
1908 2212
 				if (!($stat = $inst->url_stat($id,0)))
1909 2213
 				{
1910
-					if (self::LOG_LEVEL) error_log(__METHOD__."(".array2string($path_ids).",$ns) path '$id' not found!");
2214
+					if (self::LOG_LEVEL)
2215
+					{
2216
+						error_log(__METHOD__."(".array2string($path_ids).",$ns) path '$id' not found!");
2217
+					}
1911 2218
 					return false;
1912 2219
 				}
1913 2220
 				$id = $stat['ino'];
1914 2221
 			}
1915 2222
 		}
1916
-		if (count($ids) >= 1) $ids = array_map(function($v) { return (int)$v; }, $ids);
2223
+		if (count($ids) >= 1)
2224
+		{
2225
+			$ids = array_map(function($v) { return (int)$v;
2226
+		}
2227
+		}, $ids);
1917 2228
 		$query = 'SELECT * FROM '.self::PROPS_TABLE.' WHERE (fs_id'.
1918 2229
 			(count($ids) == 1 ? '='.(int)implode('',$ids) : ' IN ('.implode(',',$ids).')').')'.
1919 2230
 			(!is_null($ns) ? ' AND prop_namespace=?' : '');
1920
-		if (self::LOG_LEVEL > 2) $query = '/* '.__METHOD__.': '.__LINE__.' */ '.$query;
2231
+		if (self::LOG_LEVEL > 2)
2232
+		{
2233
+			$query = '/* '.__METHOD__.': '.__LINE__.' */ '.$query;
2234
+		}
1921 2235
 
1922 2236
 		$stmt = self::$pdo->prepare($query);
1923 2237
 		$stmt->setFetchMode(\PDO::FETCH_ASSOC);
@@ -1936,11 +2250,14 @@  discard block
 block discarded – undo
1936 2250
 		{
1937 2251
 			$props = $props[$row['fs_id']] ? $props[$row['fs_id']] : array();	// return empty array for no props
1938 2252
 		}
1939
-		elseif ($props && isset($stat) && is_array($id2path = self::id2path(array_keys($props))))	// need to map fs_id's to pathes
2253
+		elseif ($props && isset($stat) && is_array($id2path = self::id2path(array_keys($props))))
2254
+		{
2255
+			// need to map fs_id's to pathes
1940 2256
 		{
1941 2257
 			foreach($id2path as $id => $path)
1942 2258
 			{
1943 2259
 				$props[$path] =& $props[$id];
2260
+		}
1944 2261
 				unset($props[$id]);
1945 2262
 			}
1946 2263
 		}
Please login to merge, or discard this patch.
api/src/Header/UserAgent.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -76,11 +76,11 @@  discard block
 block discarded – undo
76 76
 	{
77 77
 		// should be Ok for all HTML 4 compatible browsers
78 78
 		$parts = $all_parts = null;
79
-		if(!preg_match('/compatible; ([a-z]+)[\/ ]+([0-9.]+)/i',$_SERVER['HTTP_USER_AGENT'],$parts))
79
+		if (!preg_match('/compatible; ([a-z]+)[\/ ]+([0-9.]+)/i', $_SERVER['HTTP_USER_AGENT'], $parts))
80 80
 		{
81
-			preg_match_all('/([a-z]+)\/([0-9.]+)/i',$_SERVER['HTTP_USER_AGENT'],$all_parts,PREG_SET_ORDER);
81
+			preg_match_all('/([a-z]+)\/([0-9.]+)/i', $_SERVER['HTTP_USER_AGENT'], $all_parts, PREG_SET_ORDER);
82 82
 			$parts = array_pop($all_parts);
83
-			foreach($all_parts as $p)
83
+			foreach ($all_parts as $p)
84 84
 			{
85 85
 				if ($p[1] == 'Chrome' && $parts[1] != 'Edge')
86 86
 				{
@@ -89,12 +89,12 @@  discard block
 block discarded – undo
89 89
 				}
90 90
 			}
91 91
 		}
92
-		list(,self::$user_agent,self::$ua_version) = $parts;
92
+		list(,self::$user_agent, self::$ua_version) = $parts;
93 93
 		if ((self::$user_agent = strtolower(self::$user_agent)) == 'version') self::$user_agent = 'opera';
94 94
 		// IE no longer reports MSIE, but "Trident/7.0; rv:11.0"
95
-		if (self::$user_agent=='trident')
95
+		if (self::$user_agent == 'trident')
96 96
 		{
97
-			self::$user_agent='msie';
97
+			self::$user_agent = 'msie';
98 98
 			$matches = null;
99 99
 			self::$ua_version = preg_match('|Trident/[0-9.]+; rv:([0-9.]+)|i', $_SERVER['HTTP_USER_AGENT'], $matches) ?
100 100
 				$matches[1] : 11.0;
Please login to merge, or discard this patch.
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -90,7 +90,10 @@
 block discarded – undo
90 90
 			}
91 91
 		}
92 92
 		list(,self::$user_agent,self::$ua_version) = $parts;
93
-		if ((self::$user_agent = strtolower(self::$user_agent)) == 'version') self::$user_agent = 'opera';
93
+		if ((self::$user_agent = strtolower(self::$user_agent)) == 'version')
94
+		{
95
+			self::$user_agent = 'opera';
96
+		}
94 97
 		// IE no longer reports MSIE, but "Trident/7.0; rv:11.0"
95 98
 		if (self::$user_agent=='trident')
96 99
 		{
Please login to merge, or discard this patch.
api/src/Header/Referer.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	 * @return string
27 27
 	 * @todo get "real" referer for jDots template
28 28
 	 */
29
-	static function get($default='',$referer='')
29
+	static function get($default = '', $referer = '')
30 30
 	{
31 31
 		// HTTP_REFERER seems NOT to get urldecoded
32 32
 		if (!$referer) $referer = urldecode($_SERVER['HTTP_REFERER']);
@@ -34,11 +34,11 @@  discard block
 block discarded – undo
34 34
 		$webserver_url = $GLOBALS['egw_info']['server']['webserver_url'];
35 35
 		if (empty($webserver_url) || $webserver_url{0} == '/')	// url is just a path
36 36
 		{
37
-			$referer = preg_replace('/^https?:\/\/[^\/]+/','',$referer);	// removing the domain part
37
+			$referer = preg_replace('/^https?:\/\/[^\/]+/', '', $referer); // removing the domain part
38 38
 		}
39 39
 		if (strlen($webserver_url) > 1)
40 40
 		{
41
-			list(,$referer) = explode($webserver_url,$referer,2);
41
+			list(,$referer) = explode($webserver_url, $referer, 2);
42 42
 		}
43 43
 		$ret = str_replace('/etemplate/process_exec.php', '/index.php', $referer);
44 44
 
Please login to merge, or discard this patch.
Braces   +14 added lines, -4 removed lines patch added patch discarded remove patch
@@ -29,12 +29,19 @@  discard block
 block discarded – undo
29 29
 	static function get($default='',$referer='')
30 30
 	{
31 31
 		// HTTP_REFERER seems NOT to get urldecoded
32
-		if (!$referer) $referer = urldecode($_SERVER['HTTP_REFERER']);
32
+		if (!$referer)
33
+		{
34
+			$referer = urldecode($_SERVER['HTTP_REFERER']);
35
+		}
33 36
 
34 37
 		$webserver_url = $GLOBALS['egw_info']['server']['webserver_url'];
35
-		if (empty($webserver_url) || $webserver_url{0} == '/')	// url is just a path
38
+		if (empty($webserver_url) || $webserver_url{0} == '/')
39
+		{
40
+			// url is just a path
36 41
 		{
37
-			$referer = preg_replace('/^https?:\/\/[^\/]+/','',$referer);	// removing the domain part
42
+			$referer = preg_replace('/^https?:\/\/[^\/]+/','',$referer);
43
+		}
44
+		// removing the domain part
38 45
 		}
39 46
 		if (strlen($webserver_url) > 1)
40 47
 		{
@@ -42,7 +49,10 @@  discard block
 block discarded – undo
42 49
 		}
43 50
 		$ret = str_replace('/etemplate/process_exec.php', '/index.php', $referer);
44 51
 
45
-		if (empty($ret) || strpos($ret, 'cd=yes') !== false) $ret = $default;
52
+		if (empty($ret) || strpos($ret, 'cd=yes') !== false)
53
+		{
54
+			$ret = $default;
55
+		}
46 56
 
47 57
 		return $ret;
48 58
 	}
Please login to merge, or discard this patch.
api/src/Etemplate/Widget/Transformer.php 2 patches
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 	 *
74 74
 	 * @param string $cname
75 75
 	 */
76
-	public function beforeSendToClient($cname, array $expand=array())
76
+	public function beforeSendToClient($cname, array $expand = array())
77 77
 	{
78 78
 		$attrs = $this->attrs;
79 79
 		$form_name = self::form_name($cname, $this->id);
@@ -82,14 +82,14 @@  discard block
 block discarded – undo
82 82
 			error_log(__METHOD__."() $this has no id!");
83 83
 			return;
84 84
 		}
85
-		$attrs['value'] = $value =& self::get_array(self::$request->content, $form_name, false, true);
85
+		$attrs['value'] = $value = & self::get_array(self::$request->content, $form_name, false, true);
86 86
 		$attrs['type'] = $this->type;
87 87
 		$attrs['id'] = $this->id;
88 88
 
89 89
 		$unmodified = $attrs;
90 90
 
91 91
 		// run the transformation
92
-		foreach(static::$transformation as $filter => $data)
92
+		foreach (static::$transformation as $filter => $data)
93 93
 		{
94 94
 			$this->action($filter, $data, $attrs);
95 95
 		}
@@ -97,14 +97,14 @@  discard block
 block discarded – undo
97 97
 		//echo $this; _debug_array($unmodified); _debug_array($attrs); _debug_array(array_diff_assoc($attrs, $unmodified));
98 98
 		// compute the difference and send it to the client as modifications
99 99
 		$type_changed = false;
100
-		foreach(array_diff_assoc($attrs, $unmodified) as $attr => $val)
100
+		foreach (array_diff_assoc($attrs, $unmodified) as $attr => $val)
101 101
 		{
102
-			switch($attr)
102
+			switch ($attr)
103 103
 			{
104 104
 				case 'value':
105 105
 					if ($val != $value)
106 106
 					{
107
-						$value = $val;	// $value is reference to self::$request->content
107
+						$value = $val; // $value is reference to self::$request->content
108 108
 					}
109 109
 					break;
110 110
 				case 'sel_options':
@@ -112,15 +112,15 @@  discard block
 block discarded – undo
112 112
 					break;
113 113
 				case 'type':	// not an attribute in etemplate2
114 114
 					$type_changed = true;
115
-					if($val == 'template')
115
+					if ($val == 'template')
116 116
 					{
117 117
 						// If the widget has been transformed into a template, we
118 118
 						// also need to try and instanciate & parse the template too
119 119
 						$transformed_template = Template::instance($attrs['template']);
120
-						if($transformed_template)
120
+						if ($transformed_template)
121 121
 						{
122 122
 							$this->expand_widget($transformed_template, $expand);
123
-							$transformed_template->run('beforeSendToClient',array($cname,$expand));
123
+							$transformed_template->run('beforeSendToClient', array($cname, $expand));
124 124
 						}
125 125
 						$type_changed = false;
126 126
 					}
@@ -129,14 +129,14 @@  discard block
 block discarded – undo
129 129
 					break;
130 130
 			}
131 131
 		}
132
-		if($type_changed)
132
+		if ($type_changed)
133 133
 		{
134 134
 			// Run the new widget type's beforeSendToClient
135
-			$expanded_child = self::factory($attrs['type'], false,$this->id);
135
+			$expanded_child = self::factory($attrs['type'], false, $this->id);
136 136
 			$expanded_child->id = $this->id;
137 137
 			$expanded_child->type = $attrs['type'];
138 138
 			$expanded_child->attrs = $attrs;
139
-			$expanded_child->run('beforeSendToClient',array($cname,$expand));
139
+			$expanded_child->run('beforeSendToClient', array($cname, $expand));
140 140
 		}
141 141
 	}
142 142
 
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 			if (strpos($action, '@') !== false)
159 159
 			{
160 160
 				$replace = array();
161
-				foreach($attrs as $a => $v)
161
+				foreach ($attrs as $a => $v)
162 162
 				{
163 163
 					if (is_scalar($v) || is_null($v)) $replace['@'.$a] = $v;
164 164
 				}
@@ -166,14 +166,14 @@  discard block
 block discarded – undo
166 166
 				// now replace with non-scalar value, eg. if values is an array: "@value", "@value[key] or "@value[@key]"
167 167
 				if (($a = strstr($action, '@')))
168 168
 				{
169
-					$action = self::get_array($attrs, substr($a,1));
169
+					$action = self::get_array($attrs, substr($a, 1));
170 170
 				}
171 171
 			}
172 172
 			$attrs[$attr] = $action;
173 173
 			if (self::DEBUG) error_log(__METHOD__."('$attr', ".array2string($action).") attrs['$attr'] = ".array2string($action).', attrs='.array2string($attrs));
174 174
 		}
175 175
 		// action is a serverside callback
176
-		elseif(is_array($action) && isset($action['__callback__']))
176
+		elseif (is_array($action) && isset($action['__callback__']))
177 177
 		{
178 178
 			if (!is_string(($callback = $action['__callback__'])))
179 179
 			{
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 			{
184 184
 				$attrs[$attr] = $this->$callback($attrs[$attr], $attrs);
185 185
 			}
186
-			elseif(count(explode('.', $callback)) == 3)
186
+			elseif (count(explode('.', $callback)) == 3)
187 187
 			{
188 188
 				$attrs[$attr] = ExecMethod($callback, $attrs[$attr], $attrs);
189 189
 			}
@@ -197,29 +197,29 @@  discard block
 block discarded – undo
197 197
 			}
198 198
 		}
199 199
 		// action is a clientside callback
200
-		elseif(is_array($action) && isset($action['__js__']))
200
+		elseif (is_array($action) && isset($action['__js__']))
201 201
 		{
202 202
 			// nothing to do here
203 203
 		}
204 204
 		// TODO: Might be a better way to handle when value to be set is an array
205
-		elseif(is_array($action) && $attr == 'sel_options')
205
+		elseif (is_array($action) && $attr == 'sel_options')
206 206
 		{
207 207
 			$attrs[$attr] = $action;
208 208
 		}
209 209
 		// action is a switch --> check cases
210
-		elseif(is_array($action))
210
+		elseif (is_array($action))
211 211
 		{
212 212
 			// case matches --> run all actions
213 213
 			if (isset($action[$attrs[$attr]]) || !isset($action[$attrs[$attr]]) && isset($action['__default__']))
214 214
 			{
215 215
 				$actions = isset($action[$attrs[$attr]]) ? $action[$attrs[$attr]] : $action['__default__'];
216
-				if(!is_array($actions))
216
+				if (!is_array($actions))
217 217
 				{
218 218
 					$attrs[$attr] = $actions;
219 219
 					$actions = array($attr => $actions);
220 220
 				}
221 221
 				if (self::DEBUG) error_log(__METHOD__."(attr='$attr', action=".array2string($action).") attrs['$attr']=='{$attrs[$attr]}' --> running actions");
222
-				foreach($actions as $attr => $action)
222
+				foreach ($actions as $attr => $action)
223 223
 				{
224 224
 					$this->action($attr, $action, $attrs);
225 225
 				}
Please login to merge, or discard this patch.
Braces   +16 added lines, -4 removed lines patch added patch discarded remove patch
@@ -150,7 +150,10 @@  discard block
 block discarded – undo
150 150
 	 */
151 151
 	protected function action($attr, $action, array &$attrs)
152 152
 	{
153
-		if (self::DEBUG) error_log(__METHOD__."('$attr', ".array2string($action).')');
153
+		if (self::DEBUG)
154
+		{
155
+			error_log(__METHOD__."('$attr', ".array2string($action).')');
156
+		}
154 157
 		// action is an assignment
155 158
 		if (is_scalar($action) || is_null($action))
156 159
 		{
@@ -160,7 +163,10 @@  discard block
 block discarded – undo
160 163
 				$replace = array();
161 164
 				foreach($attrs as $a => $v)
162 165
 				{
163
-					if (is_scalar($v) || is_null($v)) $replace['@'.$a] = $v;
166
+					if (is_scalar($v) || is_null($v))
167
+					{
168
+						$replace['@'.$a] = $v;
169
+					}
164 170
 				}
165 171
 				$action = strtr($action, $replace);
166 172
 				// now replace with non-scalar value, eg. if values is an array: "@value", "@value[key] or "@value[@key]"
@@ -170,7 +176,10 @@  discard block
 block discarded – undo
170 176
 				}
171 177
 			}
172 178
 			$attrs[$attr] = $action;
173
-			if (self::DEBUG) error_log(__METHOD__."('$attr', ".array2string($action).") attrs['$attr'] = ".array2string($action).', attrs='.array2string($attrs));
179
+			if (self::DEBUG)
180
+			{
181
+				error_log(__METHOD__."('$attr', ".array2string($action).") attrs['$attr'] = ".array2string($action).', attrs='.array2string($attrs));
182
+			}
174 183
 		}
175 184
 		// action is a serverside callback
176 185
 		elseif(is_array($action) && isset($action['__callback__']))
@@ -218,7 +227,10 @@  discard block
 block discarded – undo
218 227
 					$attrs[$attr] = $actions;
219 228
 					$actions = array($attr => $actions);
220 229
 				}
221
-				if (self::DEBUG) error_log(__METHOD__."(attr='$attr', action=".array2string($action).") attrs['$attr']=='{$attrs[$attr]}' --> running actions");
230
+				if (self::DEBUG)
231
+				{
232
+					error_log(__METHOD__."(attr='$attr', action=".array2string($action).") attrs['$attr']=='{$attrs[$attr]}' --> running actions");
233
+				}
222 234
 				foreach($actions as $attr => $action)
223 235
 				{
224 236
 					$this->action($attr, $action, $attrs);
Please login to merge, or discard this patch.
api/src/Etemplate/Widget/Contact.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 
129 129
 		$this->contacts->__construct();
130 130
 		$options = $this->contacts->contact_fields;
131
-		foreach($this->contacts->customfields as $name => $data)
131
+		foreach ($this->contacts->customfields as $name => $data)
132 132
 		{
133 133
 			$options['#'.$name] = $data['label'];
134 134
 		}
@@ -148,28 +148,28 @@  discard block
 block discarded – undo
148 148
 	 */
149 149
 	public function get_contact($value, array $attrs)
150 150
 	{
151
-		if (is_array($value) && !(array_key_exists('app',$value) && array_key_exists('id', $value))) return $value;
151
+		if (is_array($value) && !(array_key_exists('app', $value) && array_key_exists('id', $value))) return $value;
152 152
 
153
-		if(is_array($value) && array_key_exists('app', $value) && array_key_exists('id', $value)) $value = $value['id'];
154
-		switch($attrs['type'])
153
+		if (is_array($value) && array_key_exists('app', $value) && array_key_exists('id', $value)) $value = $value['id'];
154
+		switch ($attrs['type'])
155 155
 		{
156 156
 			case 'contact-account':
157 157
 			case 'contact-template':
158
-				if (substr($value,0,8) != 'account:')
158
+				if (substr($value, 0, 8) != 'account:')
159 159
 				{
160 160
 					$value = 'account:'.($attrs['name'] != 'account:' ? $value : $GLOBALS['egw_info']['user']['account_id']);
161 161
 				}
162 162
 				// fall-through
163 163
 			case 'contact-value':
164 164
 			default:
165
-				if (substr($value,0,12) == 'addressbook:') $value = substr($value,12);	// link-entry syntax
165
+				if (substr($value, 0, 12) == 'addressbook:') $value = substr($value, 12); // link-entry syntax
166 166
 				if (!($contact = $this->contacts->read($value)))
167 167
 				{
168 168
 					$contact = array();
169 169
 				}
170 170
 				break;
171 171
 		}
172
-		unset($contact['jpegphoto']);	// makes no sense to return binary image
172
+		unset($contact['jpegphoto']); // makes no sense to return binary image
173 173
 
174 174
 		//error_log(__METHOD__."('$value') returning ".array2string($contact));
175 175
 		return $contact;
Please login to merge, or discard this patch.
Braces   +13 added lines, -3 removed lines patch added patch discarded remove patch
@@ -148,9 +148,15 @@  discard block
 block discarded – undo
148 148
 	 */
149 149
 	public function get_contact($value, array $attrs)
150 150
 	{
151
-		if (is_array($value) && !(array_key_exists('app',$value) && array_key_exists('id', $value))) return $value;
151
+		if (is_array($value) && !(array_key_exists('app',$value) && array_key_exists('id', $value)))
152
+		{
153
+			return $value;
154
+		}
152 155
 
153
-		if(is_array($value) && array_key_exists('app', $value) && array_key_exists('id', $value)) $value = $value['id'];
156
+		if(is_array($value) && array_key_exists('app', $value) && array_key_exists('id', $value))
157
+		{
158
+			$value = $value['id'];
159
+		}
154 160
 		switch($attrs['type'])
155 161
 		{
156 162
 			case 'contact-account':
@@ -162,7 +168,11 @@  discard block
 block discarded – undo
162 168
 				// fall-through
163 169
 			case 'contact-value':
164 170
 			default:
165
-				if (substr($value,0,12) == 'addressbook:') $value = substr($value,12);	// link-entry syntax
171
+				if (substr($value,0,12) == 'addressbook:')
172
+				{
173
+					$value = substr($value,12);
174
+				}
175
+				// link-entry syntax
166 176
 				if (!($contact = $this->contacts->read($value)))
167 177
 				{
168 178
 					$contact = array();
Please login to merge, or discard this patch.