Completed
Push — 14.2 ( 8c75f3...7aeda4 )
by Ralf
108:06 queued 84:21
created
phpgwapi/inc/class.groupdav_handler.inc.php 3 patches
Doc Comments   +9 added lines, -18 removed lines patch added patch discarded remove patch
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 	 *
148 148
 	 * @param string $path
149 149
 	 * @param array $filter
150
-	 * @param array|boolean $start false=return all or array(start,num)
150
+	 * @param integer[] $start false=return all or array(start,num)
151 151
 	 * @param int &$total
152 152
 	 * @return array with "files" array with values for keys path and props
153 153
 	 */
@@ -158,7 +158,6 @@  discard block
 block discarded – undo
158 158
 	 *
159 159
 	 * @param array &$options
160 160
 	 * @param int $id
161
-	 * @param int $user=null account_id
162 161
 	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
163 162
 	 */
164 163
 	abstract function get(&$options,$id,$user=null);
@@ -168,7 +167,6 @@  discard block
 block discarded – undo
168 167
 	 *
169 168
 	 * @param array &$options
170 169
 	 * @param int $id
171
-	 * @param int $user=null account_id of owner, default null
172 170
 	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
173 171
 	 */
174 172
 	abstract function put(&$options,$id,$user=null);
@@ -186,7 +184,6 @@  discard block
 block discarded – undo
186 184
 	 * Read an entry
187 185
 	 *
188 186
 	 * @param string|int $id
189
-	 * @param string $path=null implementation can use it, used in call from _common_get_put_delete
190 187
 	 * @return array|boolean array with entry, false if no read rights, null if $id does not exist
191 188
 	 */
192 189
 	abstract function read($id /*,$path=null*/);
@@ -214,10 +211,8 @@  discard block
 block discarded – undo
214 211
 	/**
215 212
 	 * Add extra properties for collections
216 213
 	 *
217
-	 * @param array $props=array() regular props by the groupdav handler
218 214
 	 * @param string $displayname
219
-	 * @param string $base_uri=null base url of handler
220
-	 * @param int $user=null account_id of owner of collection
215
+	 * @param string $base_uri base url of handler
221 216
 	 * @return array
222 217
 	 */
223 218
 	public function extra_properties(array $props=array(), $displayname, $base_uri=null, $user=null)
@@ -228,8 +223,7 @@  discard block
 block discarded – undo
228 223
 	/**
229 224
 	 * Get the etag for an entry, can be reimplemented for other algorithm or field names
230 225
 	 *
231
-	 * @param array|int $event array with event or cal_id
232
-	 * @return string|boolean string with etag or false
226
+	 * @return false|string string with etag or false
233 227
 	 */
234 228
 	function get_etag($entry)
235 229
 	{
@@ -268,7 +262,7 @@  discard block
 block discarded – undo
268 262
 	 * @param array &$options
269 263
 	 * @param int|string &$id on return self::$path_extension got removed
270 264
 	 * @param boolean &$return_no_access=false if set to true on call, instead of '403 Forbidden' the entry is returned and $return_no_access===false
271
-	 * @param boolean $ignore_if_match=false if true, ignore If-Match precondition
265
+	 * @param boolean $ignore_if_match if true, ignore If-Match precondition
272 266
 	 * @return array|string entry on success, string with http-error-code on failure, null for PUT on an unknown id
273 267
 	 */
274 268
 	function _common_get_put_delete($method,&$options,&$id,&$return_no_access=false,$ignore_if_match=false)
@@ -343,7 +337,6 @@  discard block
 block discarded – undo
343 337
 	 *
344 338
 	 * @param array $options
345 339
 	 * @param int $id
346
-	 * @param int $user=null account_id
347 340
 	 * @return string|boolean http status of get or null if no representation was requested
348 341
 	 */
349 342
 	public function check_return_representation($options, $id, $user=null)
@@ -416,7 +409,7 @@  discard block
 block discarded – undo
416 409
 	/**
417 410
 	 * Identify know GroupDAV agents by HTTP_USER_AGENT header
418 411
 	 *
419
-	 * @return string|boolean agent name or false
412
+	 * @return string|false agent name or false
420 413
 	 */
421 414
 	static function get_agent()
422 415
 	{
@@ -503,7 +496,6 @@  discard block
 block discarded – undo
503 496
 	 * Priviledges are for the collection, not the resources / entries!
504 497
 	 *
505 498
 	 * @param string $path path of collection
506
-	 * @param int $user=null owner of the collection, default current user
507 499
 	 * @return array with privileges
508 500
 	 */
509 501
 	public function current_user_privileges($path, $user=null)
@@ -556,8 +548,8 @@  discard block
 block discarded – undo
556 548
 	 * @param int|array $entry id or array of new created entry
557 549
 	 * @param string $path
558 550
 	 * @param int|string $retval
559
-	 * @param boolean $path_attr_is_name=true true: path_attr is ca(l|rd)dav_name, false: id (GroupDAV needs Location header)
560
-	 * @param string $etag=null etag, to not calculate it again (if != null)
551
+	 * @param boolean $path_attr_is_name true: path_attr is ca(l|rd)dav_name, false: id (GroupDAV needs Location header)
552
+	 * @param string $etag
561 553
 	 */
562 554
 	function put_response_headers($entry, $path, $retval, $path_attr_is_name=true, $etag=null)
563 555
 	{
@@ -655,7 +647,7 @@  discard block
 block discarded – undo
655 647
 	 *
656 648
 	 * base_uri of WebDAV class can be both, depending on EGroupware config
657 649
 	 *
658
-	 * @param boolean $full_uri=true
650
+	 * @param boolean $full_uri
659 651
 	 * @return string eg. https://domain.com/egroupware/groupdav.php
660 652
 	 */
661 653
 	public function base_uri($full_uri=true)
@@ -726,7 +718,6 @@  discard block
 block discarded – undo
726 718
 	 *
727 719
 	 * @param string $path
728 720
 	 * @param int $user parameter necessary to call getctag, if no $token specified
729
-	 * @param int $token=null modification time, default call getctag($path, $user) to fetch it
730 721
 	 * @return string
731 722
 	 */
732 723
 	public function get_sync_token($path, $user, $token=null)
@@ -822,7 +813,7 @@  discard block
 block discarded – undo
822 813
 	 *
823 814
 	 * @param groupdav_handler $handler
824 815
 	 * @param array $filter filter for propfind call
825
-	 * @param array $files=array() extra files/responses to return too
816
+	 * @param string $path
826 817
 	 */
827 818
 	public function __construct(groupdav_handler $handler, $path, array $filter,array &$files=array())
828 819
 	{
Please login to merge, or discard this patch.
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 	 * @param int $user account_id
141 141
 	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
142 142
 	 */
143
-	abstract function propfind($path,&$options,&$files,$user);
143
+	abstract function propfind($path, &$options, &$files, $user);
144 144
 
145 145
 	/**
146 146
 	 * Propfind callback, if interator is used
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 	 * @param int &$total
152 152
 	 * @return array with "files" array with values for keys path and props
153 153
 	 */
154
-	function &propfind_callback($path, array $filter,$start,&$total) { }
154
+	function &propfind_callback($path, array $filter, $start, &$total) { }
155 155
 
156 156
 	/**
157 157
 	 * Handle get request for an applications entry
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 	 * @param int $user=null account_id
162 162
 	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
163 163
 	 */
164
-	abstract function get(&$options,$id,$user=null);
164
+	abstract function get(&$options, $id, $user = null);
165 165
 
166 166
 	/**
167 167
 	 * Handle get request for an applications entry
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 	 * @param int $user=null account_id of owner, default null
172 172
 	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
173 173
 	 */
174
-	abstract function put(&$options,$id,$user=null);
174
+	abstract function put(&$options, $id, $user = null);
175 175
 
176 176
 	/**
177 177
 	 * Handle get request for an applications entry
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 	 * @param int $id
181 181
 	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
182 182
 	 */
183
-	abstract function delete(&$options,$id);
183
+	abstract function delete(&$options, $id);
184 184
 
185 185
 	/**
186 186
 	 * Read an entry
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 	 * @param array|int $entry entry-array or id
210 210
 	 * @return boolean null if entry does not exist, false if no access, true if access permitted
211 211
 	 */
212
-	abstract function check_access($acl,$entry);
212
+	abstract function check_access($acl, $entry);
213 213
 
214 214
 	/**
215 215
 	 * Add extra properties for collections
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 	 * @param int $user=null account_id of owner of collection
221 221
 	 * @return array
222 222
 	 */
223
-	public function extra_properties(array $props=array(), $displayname, $base_uri=null, $user=null)
223
+	public function extra_properties(array $props = array(), $displayname, $base_uri = null, $user = null)
224 224
 	{
225 225
 		return $props;
226 226
 	}
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
 	 */
254 254
 	static function etag2value($etag)
255 255
 	{
256
-		list(,$val) = explode(':',$etag,2);
256
+		list(,$val) = explode(':', $etag, 2);
257 257
 
258 258
 		return $val;
259 259
 	}
@@ -271,18 +271,18 @@  discard block
 block discarded – undo
271 271
 	 * @param boolean $ignore_if_match=false if true, ignore If-Match precondition
272 272
 	 * @return array|string entry on success, string with http-error-code on failure, null for PUT on an unknown id
273 273
 	 */
274
-	function _common_get_put_delete($method,&$options,&$id,&$return_no_access=false,$ignore_if_match=false)
274
+	function _common_get_put_delete($method, &$options, &$id, &$return_no_access = false, $ignore_if_match = false)
275 275
 	{
276
-		if (self::$path_extension) $id = basename($id,self::$path_extension);
276
+		if (self::$path_extension) $id = basename($id, self::$path_extension);
277 277
 
278 278
 		if ($this->app != 'principals' && !$GLOBALS['egw_info']['user']['apps'][$this->app])
279 279
 		{
280 280
 			if ($this->debug) error_log(__METHOD__."($method,,$id) 403 Forbidden: no app rights for '$this->app'");
281
-			return '403 Forbidden';		// no app rights
281
+			return '403 Forbidden'; // no app rights
282 282
 		}
283 283
 		$extra_acl = $this->method2acl[$method];
284 284
 		if ($id && !($entry = $this->read($id, $options['path'])) && ($method != 'PUT' || $entry === false) ||
285
-			($extra_acl != EGW_ACL_READ && $this->check_access($extra_acl,$entry) === false))
285
+			($extra_acl != EGW_ACL_READ && $this->check_access($extra_acl, $entry) === false))
286 286
 		{
287 287
 			if ($return_no_access && !is_null($entry))
288 288
 			{
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
 			}
292 292
 			else
293 293
 			{
294
-				if ($this->debug) error_log(__METHOD__."($method,,$id) 403 Forbidden/404 Not Found: read($id)==".($entry===false?'false':'null'));
294
+				if ($this->debug) error_log(__METHOD__."($method,,$id) 403 Forbidden/404 Not Found: read($id)==".($entry === false ? 'false' : 'null'));
295 295
 				return !is_null($entry) ? '403 Forbidden' : '404 Not Found';
296 296
 			}
297 297
 		}
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
 				if ($if_none_match[0] == '"') $if_none_match = substr($if_none_match, 1, -1);
322 322
 
323 323
 				// if an IF_NONE_MATCH is given, check if we need to send a new export, or the current one is still up-to-date
324
-				if (in_array($method, array('GET','HEAD')) && $etag === $if_none_match)
324
+				if (in_array($method, array('GET', 'HEAD')) && $etag === $if_none_match)
325 325
 				{
326 326
 					if ($this->debug) error_log(__METHOD__."($method,,$id) HTTP_IF_NONE_MATCH='$_SERVER[HTTP_IF_NONE_MATCH]', etag='$etag': 304 Not Modified");
327 327
 					return '304 Not Modified';
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
 	 * @param int $user=null account_id
347 347
 	 * @return string|boolean http status of get or null if no representation was requested
348 348
 	 */
349
-	public function check_return_representation($options, $id, $user=null)
349
+	public function check_return_representation($options, $id, $user = null)
350 350
 	{
351 351
 		//error_log(__METHOD__."(, $id, $user) start ".function_backtrace());
352 352
 		if (isset($_SERVER['HTTP_PREFER']) && in_array('return=representation', preg_split('/, ?/', $_SERVER['HTTP_PREFER'])))
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
 	{
401 401
 		static $handler_cache = array();
402 402
 
403
-		if (!array_key_exists($app,$handler_cache))
403
+		if (!array_key_exists($app, $handler_cache))
404 404
 		{
405 405
 			$class = $app.'_groupdav';
406 406
 			if (!class_exists($class) && !class_exists($class = 'groupdav_'.$app)) return null;
@@ -427,29 +427,29 @@  discard block
 block discarded – undo
427 427
 			$agent = false;
428 428
 			// identify the agent (GroupDAV client) from the HTTP_USER_AGENT header
429 429
 			$user_agent = strtolower($_SERVER['HTTP_USER_AGENT']);
430
-			foreach(array(
431
-				'carddav-sync'      => 'carddav-sync',	// dmfs.org CardDAV client for Android: CardDAV-Sync (Android) (like iOS/5.0.1 (9A405) dataaccessd/1.0) gzip
432
-				'iphone'            => 'iphone',	// Apple iPhone iCal
433
-				'davkit'            => 'davkit',	// Apple iCal 10.6
434
-				'coredav'           => 'coredav',	// Apple iCal 10.7
435
-				'calendarstore'     => 'calendarstore',	// Apple iCal 5.0.1 under OS X 10.7.2
436
-				'calendaragent/'    => 'calendaragent',	// Apple iCal OS X 10.8*: Mac OS X/10.8.2 (12C54) CalendarAgent/55
437
-				'dataaccess'        => 'dataaccess',	// Apple addressbook iPhone
438
-				'cfnetwork'         => 'cfnetwork',	// Apple Addressbook 10.6/7
439
-				'addressbook/'      => 'cfnetwork',	// Apple Addressbook OS X 10.8*: Mac OS X/10.8.2 (12C54) AddressBook/1167
440
-				'bionicmessage.net' => 'funambol',	// funambol GroupDAV connector from bionicmessage.net
441
-				'zideone'           => 'zideone',	// zideone outlook plugin
442
-				'lightning'         => 'lightning',	// Lighting (incl. SOGo connector for addressbook)
443
-				'webkit'			=> 'webkit',	// Webkit Browser (also reports KHTML!)
444
-				'akonadi'			=> 'akonadi',	// new KDE PIM framework (also reports KHTML!)
445
-				'khtml'             => 'kde',		// KDE clients
430
+			foreach (array(
431
+				'carddav-sync'      => 'carddav-sync', // dmfs.org CardDAV client for Android: CardDAV-Sync (Android) (like iOS/5.0.1 (9A405) dataaccessd/1.0) gzip
432
+				'iphone'            => 'iphone', // Apple iPhone iCal
433
+				'davkit'            => 'davkit', // Apple iCal 10.6
434
+				'coredav'           => 'coredav', // Apple iCal 10.7
435
+				'calendarstore'     => 'calendarstore', // Apple iCal 5.0.1 under OS X 10.7.2
436
+				'calendaragent/'    => 'calendaragent', // Apple iCal OS X 10.8*: Mac OS X/10.8.2 (12C54) CalendarAgent/55
437
+				'dataaccess'        => 'dataaccess', // Apple addressbook iPhone
438
+				'cfnetwork'         => 'cfnetwork', // Apple Addressbook 10.6/7
439
+				'addressbook/'      => 'cfnetwork', // Apple Addressbook OS X 10.8*: Mac OS X/10.8.2 (12C54) AddressBook/1167
440
+				'bionicmessage.net' => 'funambol', // funambol GroupDAV connector from bionicmessage.net
441
+				'zideone'           => 'zideone', // zideone outlook plugin
442
+				'lightning'         => 'lightning', // Lighting (incl. SOGo connector for addressbook)
443
+				'webkit'			=> 'webkit', // Webkit Browser (also reports KHTML!)
444
+				'akonadi'			=> 'akonadi', // new KDE PIM framework (also reports KHTML!)
445
+				'khtml'             => 'kde', // KDE clients
446 446
 				'neon'              => 'neon',
447
-				'ical4ol'			=> 'ical4ol',	// iCal4OL client
448
-				'evolution'         => 'evolution',	// Evolution
449
-				'thunderbird'       => 'thunderbird',	// SOGo connector for addressbook, no Lightning installed
447
+				'ical4ol'			=> 'ical4ol', // iCal4OL client
448
+				'evolution'         => 'evolution', // Evolution
449
+				'thunderbird'       => 'thunderbird', // SOGo connector for addressbook, no Lightning installed
450 450
 			) as $pattern => $name)
451 451
 			{
452
-				if (strpos($user_agent,$pattern) !== false)
452
+				if (strpos($user_agent, $pattern) !== false)
453 453
 				{
454 454
 					$agent = $name;
455 455
 					break;
@@ -506,7 +506,7 @@  discard block
 block discarded – undo
506 506
 	 * @param int $user=null owner of the collection, default current user
507 507
 	 * @return array with privileges
508 508
 	 */
509
-	public function current_user_privileges($path, $user=null)
509
+	public function current_user_privileges($path, $user = null)
510 510
 	{
511 511
 		static $grants;
512 512
 		if (is_null($grants))
@@ -515,24 +515,24 @@  discard block
 block discarded – undo
515 515
 		}
516 516
 		$priviledes = array('read-current-user-privilege-set' => 'read-current-user-privilege-set');
517 517
 
518
-		if (is_null($user) || $grants[$user] & EGW_ACL_READ)
518
+		if (is_null($user) || $grants[$user]&EGW_ACL_READ)
519 519
 		{
520 520
 			$priviledes['read'] = 'read';
521 521
 			// allows on all calendars/addressbooks to write properties, as we store them on a per-user basis
522 522
 			// and only allow to modify explicit named properties in CalDAV, CardDAV or Calendarserver name-space
523 523
 			$priviledes['write-properties'] = 'write-properties';
524 524
 		}
525
-		if (is_null($user) || $grants[$user] & EGW_ACL_ADD)
525
+		if (is_null($user) || $grants[$user]&EGW_ACL_ADD)
526 526
 		{
527
-			$priviledes['bind'] = 'bind';	// PUT for new resources
527
+			$priviledes['bind'] = 'bind'; // PUT for new resources
528 528
 		}
529
-		if (is_null($user) || $grants[$user] & EGW_ACL_EDIT)
529
+		if (is_null($user) || $grants[$user]&EGW_ACL_EDIT)
530 530
 		{
531
-			$priviledes['write-content'] = 'write-content';	// otherwise iOS calendar does not allow to add events
531
+			$priviledes['write-content'] = 'write-content'; // otherwise iOS calendar does not allow to add events
532 532
 		}
533
-		if (is_null($user) || $grants[$user] & EGW_ACL_DELETE)
533
+		if (is_null($user) || $grants[$user]&EGW_ACL_DELETE)
534 534
 		{
535
-			$priviledes['unbind'] = 'unbind';	// DELETE
535
+			$priviledes['unbind'] = 'unbind'; // DELETE
536 536
 		}
537 537
 		// copy/move of existing resources might require write-properties, thought we do not support an explicit PROPATCH
538 538
 		//error_log(__METHOD__."('$path', ".array2string($user).') returning '.array2string($priviledes).' '.function_backtrace());
@@ -559,7 +559,7 @@  discard block
 block discarded – undo
559 559
 	 * @param boolean $path_attr_is_name=true true: path_attr is ca(l|rd)dav_name, false: id (GroupDAV needs Location header)
560 560
 	 * @param string $etag=null etag, to not calculate it again (if != null)
561 561
 	 */
562
-	function put_response_headers($entry, $path, $retval, $path_attr_is_name=true, $etag=null)
562
+	function put_response_headers($entry, $path, $retval, $path_attr_is_name = true, $etag = null)
563 563
 	{
564 564
 		//error_log(__METHOD__."(".array2string($entry).", '$path', ".array2string($retval).", path_attr_is_name=$path_attr_is_name, etag=".array2string($etag).")");
565 565
 		// we should not return an etag here, as EGroupware never stores ical/vcard byte-by-byte
@@ -620,7 +620,7 @@  discard block
 block discarded – undo
620 620
 		{
621 621
 			$props['getetag'] = $this->get_etag($entry);
622 622
 		}
623
-		foreach(array(
623
+		foreach (array(
624 624
 			'getcontenttype' => 'text/calendar',
625 625
 			'getlastmodified' => $entry['modified'],
626 626
 			'displayname' => $entry['title'],
@@ -658,7 +658,7 @@  discard block
 block discarded – undo
658 658
 	 * @param boolean $full_uri=true
659 659
 	 * @return string eg. https://domain.com/egroupware/groupdav.php
660 660
 	 */
661
-	public function base_uri($full_uri=true)
661
+	public function base_uri($full_uri = true)
662 662
 	{
663 663
 		static $uri;
664 664
 		static $path;
@@ -668,7 +668,7 @@  discard block
 block discarded – undo
668 668
 			$uri = $path = $this->groupdav->base_uri;
669 669
 			if ($uri[0] == '/')
670 670
 			{
671
-				$uri = ($_SERVER["HTTPS"] === "on" ? "https:" : "http:") .'//' . $_SERVER['HTTP_HOST'] . $uri;
671
+				$uri = ($_SERVER["HTTPS"] === "on" ? "https:" : "http:").'//'.$_SERVER['HTTP_HOST'].$uri;
672 672
 			}
673 673
 			else
674 674
 			{
@@ -692,7 +692,7 @@  discard block
 block discarded – undo
692 692
 	 * @param int $user parameter necessary to call getctag, if no $token specified
693 693
 	 * @return string
694 694
 	 */
695
-	public function get_sync_collection_token($path, $user=null, $more_results=null)
695
+	public function get_sync_collection_token($path, $user = null, $more_results = null)
696 696
 	{
697 697
 		//error_log(__METHOD__."('$path', $user, more_results=$more_results) this->sync_collection_token=".$this->sync_collection_token);
698 698
 		if ($more_results)
@@ -706,7 +706,7 @@  discard block
 block discarded – undo
706 706
 ';
707 707
 			if ($this->groupdav->crrnd)
708 708
 			{
709
-				$error = str_replace(array('<D:', '</D:'),  array('<', '</'), $error);
709
+				$error = str_replace(array('<D:', '</D:'), array('<', '</'), $error);
710 710
 			}
711 711
 			echo $error;
712 712
 		}
@@ -729,7 +729,7 @@  discard block
 block discarded – undo
729 729
 	 * @param int $token=null modification time, default call getctag($path, $user) to fetch it
730 730
 	 * @return string
731 731
 	 */
732
-	public function get_sync_token($path, $user, $token=null)
732
+	public function get_sync_token($path, $user, $token = null)
733 733
 	{
734 734
 		if (!isset($token)) $token = $this->getctag($path, $user);
735 735
 
@@ -800,7 +800,7 @@  discard block
 block discarded – undo
800 800
 	 *
801 801
 	 * @var int
802 802
 	 */
803
-	protected $start=0;
803
+	protected $start = 0;
804 804
 
805 805
 	/**
806 806
 	 * Number of entries queried from callback in one call
@@ -824,7 +824,7 @@  discard block
 block discarded – undo
824 824
 	 * @param array $filter filter for propfind call
825 825
 	 * @param array $files=array() extra files/responses to return too
826 826
 	 */
827
-	public function __construct(groupdav_handler $handler, $path, array $filter,array &$files=array())
827
+	public function __construct(groupdav_handler $handler, $path, array $filter, array &$files = array())
828 828
 	{
829 829
 		if ($this->debug) error_log(__METHOD__."('$path', ".array2string($filter).",)");
830 830
 		$this->path    = $path;
@@ -855,7 +855,7 @@  discard block
 block discarded – undo
855 855
 		$current = current($this->files);
856 856
 
857 857
 		if ($this->debug) error_log(__METHOD__."() returning ".array2string($current['path']));
858
-		return $current['path'];	// we return path as key
858
+		return $current['path']; // we return path as key
859 859
 	}
860 860
 
861 861
 	/**
@@ -875,11 +875,11 @@  discard block
 block discarded – undo
875 875
 			return false;
876 876
 		}
877 877
 		// try query further files via propfind callback of handler and store result in $this->files
878
-		$this->files = $this->handler->propfind_callback($this->path,$this->filter,array($this->start,self::CHUNK_SIZE));
878
+		$this->files = $this->handler->propfind_callback($this->path, $this->filter, array($this->start, self::CHUNK_SIZE));
879 879
 		if (!is_array($this->files) || !($entries = count($this->files)))
880 880
 		{
881 881
 			if ($this->debug) error_log(__METHOD__."() returning FALSE (no more entries)");
882
-			return false;	// no further entries
882
+			return false; // no further entries
883 883
 		}
884 884
 		$this->start += self::CHUNK_SIZE;
885 885
 		reset($this->files);
@@ -898,7 +898,7 @@  discard block
 block discarded – undo
898 898
 
899 899
 		$this->start = 0;
900 900
 		$this->files = $this->common_files;
901
-		if (!$this->files) $this->next();	// otherwise valid will return false and nothing get returned
901
+		if (!$this->files) $this->next(); // otherwise valid will return false and nothing get returned
902 902
 		reset($this->files);
903 903
 	}
904 904
 
@@ -907,7 +907,7 @@  discard block
 block discarded – undo
907 907
 	 *
908 908
 	 * @return boolean
909 909
 	 */
910
-	public function valid ()
910
+	public function valid()
911 911
 	{
912 912
 		if ($this->debug) error_log(__METHOD__."() returning ".array2string(current($this->files) !== false));
913 913
 		return current($this->files) !== false;
Please login to merge, or discard this patch.
Braces   +109 added lines, -27 removed lines patch added patch discarded remove patch
@@ -119,7 +119,10 @@  discard block
 block discarded – undo
119 119
 	function __construct($app, groupdav $groupdav)
120 120
 	{
121 121
 		$this->app = $app;
122
-		if (!is_null($parent->debug)) $this->debug = $groupdav->debug;
122
+		if (!is_null($parent->debug))
123
+		{
124
+			$this->debug = $groupdav->debug;
125
+		}
123 126
 		$this->base_uri = $groupdav->base_uri;
124 127
 		$this->groupdav = $groupdav;
125 128
 
@@ -273,11 +276,17 @@  discard block
 block discarded – undo
273 276
 	 */
274 277
 	function _common_get_put_delete($method,&$options,&$id,&$return_no_access=false,$ignore_if_match=false)
275 278
 	{
276
-		if (self::$path_extension) $id = basename($id,self::$path_extension);
279
+		if (self::$path_extension)
280
+		{
281
+			$id = basename($id,self::$path_extension);
282
+		}
277 283
 
278 284
 		if ($this->app != 'principals' && !$GLOBALS['egw_info']['user']['apps'][$this->app])
279 285
 		{
280
-			if ($this->debug) error_log(__METHOD__."($method,,$id) 403 Forbidden: no app rights for '$this->app'");
286
+			if ($this->debug)
287
+			{
288
+				error_log(__METHOD__."($method,,$id) 403 Forbidden: no app rights for '$this->app'");
289
+			}
281 290
 			return '403 Forbidden';		// no app rights
282 291
 		}
283 292
 		$extra_acl = $this->method2acl[$method];
@@ -286,12 +295,18 @@  discard block
 block discarded – undo
286 295
 		{
287 296
 			if ($return_no_access && !is_null($entry))
288 297
 			{
289
-				if ($this->debug) error_log(__METHOD__."($method,,$id,$return_no_access) \$entry=".array2string($entry).", \$return_no_access set to false");
298
+				if ($this->debug)
299
+				{
300
+					error_log(__METHOD__."($method,,$id,$return_no_access) \$entry=".array2string($entry).", \$return_no_access set to false");
301
+				}
290 302
 				$return_no_access = false;
291 303
 			}
292 304
 			else
293 305
 			{
294
-				if ($this->debug) error_log(__METHOD__."($method,,$id) 403 Forbidden/404 Not Found: read($id)==".($entry===false?'false':'null'));
306
+				if ($this->debug)
307
+				{
308
+					error_log(__METHOD__."($method,,$id) 403 Forbidden/404 Not Found: read($id)==".($entry===false?'false':'null'));
309
+				}
295 310
 				return !is_null($entry) ? '403 Forbidden' : '404 Not Found';
296 311
 			}
297 312
 		}
@@ -304,11 +319,17 @@  discard block
 block discarded – undo
304 319
 			{
305 320
 				$this->http_if_match = $_SERVER['HTTP_IF_MATCH'];
306 321
 				// strip of quotes around etag, if they exist, that way we allow etag with and without quotes
307
-				if ($this->http_if_match[0] == '"') $this->http_if_match = substr($this->http_if_match, 1, -1);
322
+				if ($this->http_if_match[0] == '"')
323
+				{
324
+					$this->http_if_match = substr($this->http_if_match, 1, -1);
325
+				}
308 326
 
309 327
 				if ($this->http_if_match !== $etag)
310 328
 				{
311
-					if ($this->debug) error_log(__METHOD__."($method,path=$options[path],$id) HTTP_IF_MATCH='$_SERVER[HTTP_IF_MATCH]', etag='$etag': 412 Precondition failed".array2string($entry));
329
+					if ($this->debug)
330
+					{
331
+						error_log(__METHOD__."($method,path=$options[path],$id) HTTP_IF_MATCH='$_SERVER[HTTP_IF_MATCH]', etag='$etag': 412 Precondition failed".array2string($entry));
332
+					}
312 333
 					// honor Prefer: return=representation for 412 too (no need for client to explicitly reload)
313 334
 					$this->check_return_representation($options, $id);
314 335
 					return '412 Precondition Failed';
@@ -318,17 +339,26 @@  discard block
 block discarded – undo
318 339
 			{
319 340
 				$if_none_match = $_SERVER['HTTP_IF_NONE_MATCH'];
320 341
 				// strip of quotes around etag, if they exist, that way we allow etag with and without quotes
321
-				if ($if_none_match[0] == '"') $if_none_match = substr($if_none_match, 1, -1);
342
+				if ($if_none_match[0] == '"')
343
+				{
344
+					$if_none_match = substr($if_none_match, 1, -1);
345
+				}
322 346
 
323 347
 				// if an IF_NONE_MATCH is given, check if we need to send a new export, or the current one is still up-to-date
324 348
 				if (in_array($method, array('GET','HEAD')) && $etag === $if_none_match)
325 349
 				{
326
-					if ($this->debug) error_log(__METHOD__."($method,,$id) HTTP_IF_NONE_MATCH='$_SERVER[HTTP_IF_NONE_MATCH]', etag='$etag': 304 Not Modified");
350
+					if ($this->debug)
351
+					{
352
+						error_log(__METHOD__."($method,,$id) HTTP_IF_NONE_MATCH='$_SERVER[HTTP_IF_NONE_MATCH]', etag='$etag': 304 Not Modified");
353
+					}
327 354
 					return '304 Not Modified';
328 355
 				}
329 356
 				if ($method == 'PUT' && ($if_none_match == '*' || $if_none_match == $etag))
330 357
 				{
331
-					if ($this->debug) error_log(__METHOD__."($method,,$id) HTTP_IF_NONE_MATCH='$_SERVER[HTTP_IF_NONE_MATCH]', etag='$etag': 412 Precondition failed");
358
+					if ($this->debug)
359
+					{
360
+						error_log(__METHOD__."($method,,$id) HTTP_IF_NONE_MATCH='$_SERVER[HTTP_IF_NONE_MATCH]', etag='$etag': 412 Precondition failed");
361
+					}
332 362
 					// honor Prefer: return=representation for 412 too (no need for client to explicitly reload)
333 363
 					$this->check_return_representation($options, $id);
334 364
 					return '412 Precondition Failed';
@@ -367,7 +397,10 @@  discard block
 block discarded – undo
367 397
 
368 398
 			if (($ret = $this->get($options, $id ? $id : $this->new_id, $user)) && !empty($options['data']))
369 399
 			{
370
-				if (!$this->groupdav->use_compression()) header('Content-Length: '.$this->groupdav->bytes($options['data']));
400
+				if (!$this->groupdav->use_compression())
401
+				{
402
+					header('Content-Length: '.$this->groupdav->bytes($options['data']));
403
+				}
371 404
 				header('Content-Type: '.$options['mimetype']);
372 405
 				echo $options['data'];
373 406
 			}
@@ -403,12 +436,18 @@  discard block
 block discarded – undo
403 436
 		if (!array_key_exists($app,$handler_cache))
404 437
 		{
405 438
 			$class = $app.'_groupdav';
406
-			if (!class_exists($class) && !class_exists($class = 'groupdav_'.$app)) return null;
439
+			if (!class_exists($class) && !class_exists($class = 'groupdav_'.$app))
440
+			{
441
+				return null;
442
+			}
407 443
 
408 444
 			$handler_cache[$app] = new $class($app, $groupdav);
409 445
 		}
410 446
 
411
-		if ($debug) error_log(__METHOD__."('$app')");
447
+		if ($debug)
448
+		{
449
+			error_log(__METHOD__."('$app')");
450
+		}
412 451
 
413 452
 		return $handler_cache[$app];
414 453
 	}
@@ -466,7 +505,10 @@  discard block
 block discarded – undo
466 505
 					case 'cfnetwork':
467 506
 						if (preg_match('/address%20book\/([0-9.]+)/', $user_agent, $matches))
468 507
 						{
469
-							if ((int)$matches[1] < 868) $agent .= '_old';
508
+							if ((int)$matches[1] < 868)
509
+							{
510
+								$agent .= '_old';
511
+							}
470 512
 						}
471 513
 						break;
472 514
 					case 'kde':
@@ -482,7 +524,10 @@  discard block
 block discarded – undo
482 524
 			}
483 525
 		}
484 526
 
485
-		if ($debug) error_log(__METHOD__."GroupDAV client: $agent");
527
+		if ($debug)
528
+		{
529
+			error_log(__METHOD__."GroupDAV client: $agent");
530
+		}
486 531
 
487 532
 		return $agent;
488 533
 	}
@@ -567,7 +612,10 @@  discard block
 block discarded – undo
567 612
 		// --> as all clients dislike not getting an ETag for a PUT, we sending it again even not storing byte-by-byte
568 613
 		//if (get_class($this) == 'addressbook_groupdav' && in_array(self::get_agent(),array('thunderbird','lightning')))
569 614
 		{
570
-			if (is_null($etag)) $etag = $this->get_etag($entry);
615
+			if (is_null($etag))
616
+			{
617
+				$etag = $this->get_etag($entry);
618
+			}
571 619
 			header('ETag: "'.$etag.'"');
572 620
 		}
573 621
 
@@ -731,7 +779,10 @@  discard block
 block discarded – undo
731 779
 	 */
732 780
 	public function get_sync_token($path, $user, $token=null)
733 781
 	{
734
-		if (!isset($token)) $token = $this->getctag($path, $user);
782
+		if (!isset($token))
783
+		{
784
+			$token = $this->getctag($path, $user);
785
+		}
735 786
 
736 787
 		// never return current time, as more modifications might happen due to second granularity --> return 1sec less
737 788
 		if ($token >= (int)$GLOBALS['egw_info']['flags']['page_start_time'])
@@ -826,7 +877,10 @@  discard block
 block discarded – undo
826 877
 	 */
827 878
 	public function __construct(groupdav_handler $handler, $path, array $filter,array &$files=array())
828 879
 	{
829
-		if ($this->debug) error_log(__METHOD__."('$path', ".array2string($filter).",)");
880
+		if ($this->debug)
881
+		{
882
+			error_log(__METHOD__."('$path', ".array2string($filter).",)");
883
+		}
830 884
 		$this->path    = $path;
831 885
 		$this->handler = $handler;
832 886
 		$this->filter  = $filter;
@@ -841,7 +895,10 @@  discard block
 block discarded – undo
841 895
 	 */
842 896
 	public function current()
843 897
 	{
844
-		if ($this->debug) error_log(__METHOD__."() returning ".array2string(current($this->files)));
898
+		if ($this->debug)
899
+		{
900
+			error_log(__METHOD__."() returning ".array2string(current($this->files)));
901
+		}
845 902
 		return current($this->files);
846 903
 	}
847 904
 
@@ -854,7 +911,10 @@  discard block
 block discarded – undo
854 911
 	{
855 912
 		$current = current($this->files);
856 913
 
857
-		if ($this->debug) error_log(__METHOD__."() returning ".array2string($current['path']));
914
+		if ($this->debug)
915
+		{
916
+			error_log(__METHOD__."() returning ".array2string($current['path']));
917
+		}
858 918
 		return $current['path'];	// we return path as key
859 919
 	}
860 920
 
@@ -865,26 +925,38 @@  discard block
 block discarded – undo
865 925
 	{
866 926
 		if (next($this->files) !== false)
867 927
 		{
868
-			if ($this->debug) error_log(__METHOD__."() returning TRUE");
928
+			if ($this->debug)
929
+			{
930
+				error_log(__METHOD__."() returning TRUE");
931
+			}
869 932
 			return true;
870 933
 		}
871 934
 		// check if previous query gave less then CHUNK_SIZE entries --> we're done
872 935
 		if ($this->start && count($this->files) < self::CHUNK_SIZE)
873 936
 		{
874
-			if ($this->debug) error_log(__METHOD__."() returning FALSE (no more entries)");
937
+			if ($this->debug)
938
+			{
939
+				error_log(__METHOD__."() returning FALSE (no more entries)");
940
+			}
875 941
 			return false;
876 942
 		}
877 943
 		// try query further files via propfind callback of handler and store result in $this->files
878 944
 		$this->files = $this->handler->propfind_callback($this->path,$this->filter,array($this->start,self::CHUNK_SIZE));
879 945
 		if (!is_array($this->files) || !($entries = count($this->files)))
880 946
 		{
881
-			if ($this->debug) error_log(__METHOD__."() returning FALSE (no more entries)");
947
+			if ($this->debug)
948
+			{
949
+				error_log(__METHOD__."() returning FALSE (no more entries)");
950
+			}
882 951
 			return false;	// no further entries
883 952
 		}
884 953
 		$this->start += self::CHUNK_SIZE;
885 954
 		reset($this->files);
886 955
 
887
-		if ($this->debug) error_log(__METHOD__."() this->start=$this->start, entries=$entries, count(this->files)=".count($this->files)." returning ".array2string(current($this->files) !== false));
956
+		if ($this->debug)
957
+		{
958
+			error_log(__METHOD__."() this->start=$this->start, entries=$entries, count(this->files)=".count($this->files)." returning ".array2string(current($this->files) !== false));
959
+		}
888 960
 
889 961
 		return current($this->files) !== false;
890 962
 	}
@@ -894,11 +966,18 @@  discard block
 block discarded – undo
894 966
 	 */
895 967
 	public function rewind()
896 968
 	{
897
-		if ($this->debug) error_log(__METHOD__."()");
969
+		if ($this->debug)
970
+		{
971
+			error_log(__METHOD__."()");
972
+		}
898 973
 
899 974
 		$this->start = 0;
900 975
 		$this->files = $this->common_files;
901
-		if (!$this->files) $this->next();	// otherwise valid will return false and nothing get returned
976
+		if (!$this->files)
977
+		{
978
+			$this->next();
979
+		}
980
+		// otherwise valid will return false and nothing get returned
902 981
 		reset($this->files);
903 982
 	}
904 983
 
@@ -909,7 +988,10 @@  discard block
 block discarded – undo
909 988
 	 */
910 989
 	public function valid ()
911 990
 	{
912
-		if ($this->debug) error_log(__METHOD__."() returning ".array2string(current($this->files) !== false));
991
+		if ($this->debug)
992
+		{
993
+			error_log(__METHOD__."() returning ".array2string(current($this->files) !== false));
994
+		}
913 995
 		return current($this->files) !== false;
914 996
 	}
915 997
 }
Please login to merge, or discard this patch.
phpgwapi/inc/class.groupdav_principals.inc.php 3 patches
Doc Comments   +14 added lines, -29 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	 * Currently we return all reports independed of path
79 79
 	 *
80 80
 	 * @param string $path eg. '/principals/'
81
-	 * @param array $reports=null
81
+	 * @param array $reports
82 82
 	 * @return array HTTP_WebDAV_Server::mkprop('supported-report-set', ...)
83 83
 	 */
84 84
 	protected function supported_report_set($path, array $reports=null)
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 	 * @param array &$options
247 247
 	 * @param array &$files
248 248
 	 * @param int $user account_id
249
-	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
249
+	 * @return boolean boolean true on success, false on failure or string with http status (eg. '404 Not Found')
250 250
 	 */
251 251
 	function expand_property_report($path,&$options,&$files,$user)
252 252
 	{
@@ -559,7 +559,6 @@  discard block
 block discarded – undo
559 559
 	 *
560 560
 	 * @param string $value value to test
561 561
 	 * @param string $match criteria/sub-string
562
-	 * @param string $match_type='contains' 'starts-with', 'ends-with' or 'equals'
563 562
 	 */
564 563
 	private static function match($value, $match, $match_type='contains')
565 564
 	{
@@ -972,8 +971,7 @@  discard block
 block discarded – undo
972 971
 	 * Convert CalDAV principal URL to a calendar uid
973 972
 	 *
974 973
 	 * @param string $url
975
-	 * @param string|array $only_type=null allowed types, return false for other (valid) types, eg. "users", "groups" or "resources", default all
976
-	 * @param string $cn=null common name to be stored in case of an "e" uid
974
+	 * @param string|array $only_type allowed types, return false for other (valid) types, eg. "users", "groups" or "resources", default all
977 975
 	 * @return int|string|boolean integer account_id, string calendar uid or false if not a supported uid
978 976
 	 */
979 977
 	static public function url2uid($url, $only_type=null, $cn=null)
@@ -1118,7 +1116,7 @@  discard block
 block discarded – undo
1118 1116
 	 * Add collection of a single resource to a collection
1119 1117
 	 *
1120 1118
 	 * @param array $resource
1121
-	 * @param boolean $is_location=null
1119
+	 * @param boolean $is_location
1122 1120
 	 * @return array with values for keys 'path' and 'props'
1123 1121
 	 */
1124 1122
 	protected function add_principal_resource(array $resource, $is_location=null)
@@ -1169,7 +1167,7 @@  discard block
 block discarded – undo
1169 1167
 	 * Check if resource is a location
1170 1168
 	 *
1171 1169
 	 * @param array|int $resource
1172
-	 * @return boolean
1170
+	 * @return null|boolean
1173 1171
 	 */
1174 1172
 	public static function resource_is_location($resource)
1175 1173
 	{
@@ -1233,7 +1231,6 @@  discard block
 block discarded – undo
1233 1231
 	/**
1234 1232
 	 * Get all resources (we cache the resources here, to only query them once per request)
1235 1233
 	 *
1236
-	 * @param int $user=null account_if of user, or null for current user
1237 1234
 	 * @return array of array with values for res_id, cat_id and name (no other values1)
1238 1235
 	 */
1239 1236
 	public static function get_resources($user=null)
@@ -1283,7 +1280,6 @@  discard block
 block discarded – undo
1283 1280
 	 * Add a collection
1284 1281
 	 *
1285 1282
 	 * @param string $path
1286
-	 * @param array $props=array() extra properties 'resourcetype' is added anyway, name => value pairs or name => HTTP_WebDAV_Server([namespace,]name,value)
1287 1283
 	 * @return array with values for keys 'path' and 'props'
1288 1284
 	 */
1289 1285
 	protected function add_collection($path, array $props = array())
@@ -1299,8 +1295,7 @@  discard block
 block discarded – undo
1299 1295
 	 * Add a principal collection
1300 1296
 	 *
1301 1297
 	 * @param string $principal relative to principal-collection-set, eg. "users/username"
1302
-	 * @param array $props=array() extra properties 'resourcetype' is added anyway
1303
-	 * @param string $principal_url=null include given principal url, relative to principal-collection-set, default $principal
1298
+	 * @param string $principal_url include given principal url, relative to principal-collection-set, default $principal
1304 1299
 	 * @return array with values for keys 'path' and 'props'
1305 1300
 	 */
1306 1301
 	protected function add_principal($principal, array $props = array(), $principal_url=null)
@@ -1327,8 +1322,7 @@  discard block
 block discarded – undo
1327 1322
 	 *
1328 1323
 	 * @param string $principal relative to principal-collection-set, eg. "users/username"
1329 1324
 	 * @param string $type eg. 'calendar-proxy-read' or 'calendar-proxy-write'
1330
-	 * @param array $proxys=array()
1331
-	 * @param array $resource=null resource to use (to not query it multiple times from the database)
1325
+	 * @param array $resource resource to use (to not query it multiple times from the database)
1332 1326
 	 * @return array with values for 'path' and 'props'
1333 1327
 	 */
1334 1328
 	protected function add_proxys($principal, $type, array $proxys=array(), array $resource=null)
@@ -1405,9 +1399,8 @@  discard block
 block discarded – undo
1405 1399
 	 * Create a named property with set or principal-urls
1406 1400
 	 *
1407 1401
 	 * @param string $prop egw. 'group-member-set' or 'membership'
1408
-	 * @param array $accounts=array() account_id => account_lid pairs
1409
-	 * @param string|array $app_proxys=null applications for which proxys should be added
1410 1402
 	 * @param int $account who is the proxy
1403
+	 * @param string[] $add_proxys
1411 1404
 	 * @return array with href props
1412 1405
 	 */
1413 1406
 	protected function principal_set($prop, array $accounts=array(), $add_proxys=null, $account=null)
@@ -1445,7 +1438,6 @@  discard block
 block discarded – undo
1445 1438
 	 * Get proxy-groups for given user $account: users or groups who GRANT proxy rights to $account
1446 1439
 	 *
1447 1440
 	 * @param int $account who is the proxy
1448
-	 * @param string|array $app_proxys=null applications for which proxys should be added
1449 1441
 	 * @return array with href props
1450 1442
 	 */
1451 1443
 	protected function get_resource_proxy_groups($account)
@@ -1489,7 +1481,6 @@  discard block
 block discarded – undo
1489 1481
 	 * Get proxy-groups for given user $account: users or groups who GRANT proxy rights to $account
1490 1482
 	 *
1491 1483
 	 * @param int $account who is the proxy
1492
-	 * @param string|array $app_proxys=null applications for which proxys should be added
1493 1484
 	 * @return array with href props
1494 1485
 	 */
1495 1486
 	protected function get_calendar_proxy_groups($account, $app='calendar')
@@ -1515,7 +1506,7 @@  discard block
 block discarded – undo
1515 1506
 	 * @param string $name name of group or empty
1516 1507
 	 * @param string $rest rest of path behind account-name
1517 1508
 	 * @param array $options
1518
-	 * @param boolean $do_locations=false false: /principal/resources, true: /principals/locations
1509
+	 * @param boolean $do_locations false: /principal/resources, true: /principals/locations
1519 1510
 	 * @return array|string array with files or HTTP error code
1520 1511
 	 */
1521 1512
 	protected function propfind_resources($name,$rest,array $options,$do_locations=false)
@@ -1583,8 +1574,6 @@  discard block
 block discarded – undo
1583 1574
 	/**
1584 1575
 	 * Do propfind of /principals/
1585 1576
 	 *
1586
-	 * @param string $name name of group or empty
1587
-	 * @param string $rest name of rest of path behind group-name
1588 1577
 	 * @param array $options
1589 1578
 	 * @return array|string array with files or HTTP error code
1590 1579
 	 */
@@ -1614,8 +1603,7 @@  discard block
 block discarded – undo
1614 1603
 	 *
1615 1604
 	 * @param array &$options
1616 1605
 	 * @param int $id
1617
-	 * @param int $user=null account_id
1618
-	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
1606
+	 * @return boolean boolean true on success, false on failure or string with http status (eg. '404 Not Found')
1619 1607
 	 */
1620 1608
 	function get(&$options,$id,$user=null)
1621 1609
 	{
@@ -1627,8 +1615,7 @@  discard block
 block discarded – undo
1627 1615
 	 *
1628 1616
 	 * @param array &$options
1629 1617
 	 * @param int $id
1630
-	 * @param int $user=null account_id of owner, default null
1631
-	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
1618
+	 * @return boolean boolean true on success, false on failure or string with http status (eg. '404 Not Found')
1632 1619
 	 */
1633 1620
 	function put(&$options,$id,$user=null)
1634 1621
 	{
@@ -1640,7 +1627,7 @@  discard block
 block discarded – undo
1640 1627
 	 *
1641 1628
 	 * @param array &$options
1642 1629
 	 * @param int $id
1643
-	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
1630
+	 * @return boolean boolean true on success, false on failure or string with http status (eg. '404 Not Found')
1644 1631
 	 */
1645 1632
 	function delete(&$options,$id)
1646 1633
 	{
@@ -1663,7 +1650,7 @@  discard block
 block discarded – undo
1663 1650
 	 *
1664 1651
 	 * @param int $acl EGW_ACL_READ, EGW_ACL_EDIT or EGW_ACL_DELETE
1665 1652
 	 * @param array/int $entry entry-array or id
1666
-	 * @return boolean null if entry does not exist, false if no access, true if access permitted
1653
+	 * @return null|boolean null if entry does not exist, false if no access, true if access permitted
1667 1654
 	 */
1668 1655
 	function check_access($acl,$entry)
1669 1656
 	{
@@ -1681,7 +1668,6 @@  discard block
 block discarded – undo
1681 1668
 	/**
1682 1669
 	 * Get the etag for an entry, can be reimplemented for other algorithm or field names
1683 1670
 	 *
1684
-	 * @param array/int $event array with event or cal_id
1685 1671
 	 * @return string/boolean string with etag or false
1686 1672
 	 */
1687 1673
 	function get_etag($account)
@@ -1705,8 +1691,7 @@  discard block
 block discarded – undo
1705 1691
 	 * Privileges are for the collection, not the resources / entries!
1706 1692
 	 *
1707 1693
 	 * @param string $path path of collection
1708
-	 * @param int $user=null owner of the collection, default current user
1709
-	 * @return array with privileges
1694
+	 * @return string[] with privileges
1710 1695
 	 */
1711 1696
 	public function current_user_privileges($path, $user=null)
1712 1697
 	{
Please login to merge, or discard this patch.
Spacing   +171 added lines, -172 removed lines patch added patch discarded remove patch
@@ -81,17 +81,16 @@  discard block
 block discarded – undo
81 81
 	 * @param array $reports=null
82 82
 	 * @return array HTTP_WebDAV_Server::mkprop('supported-report-set', ...)
83 83
 	 */
84
-	protected function supported_report_set($path, array $reports=null)
84
+	protected function supported_report_set($path, array $reports = null)
85 85
 	{
86 86
 		if (is_null($reports)) $reports = $this->supported_reports;
87 87
 
88 88
 		$supported = array();
89
-		foreach($reports as $name => $data)
89
+		foreach ($reports as $name => $data)
90 90
 		{
91
-			$supported[$name] = HTTP_WebDAV_Server::mkprop('supported-report',array(
92
-				HTTP_WebDAV_Server::mkprop('report',array(
93
-					!$data['ns'] ? HTTP_WebDAV_Server::mkprop($name, '') :
94
-						HTTP_WebDAV_Server::mkprop($data['ns'], $name, '')))));
91
+			$supported[$name] = HTTP_WebDAV_Server::mkprop('supported-report', array(
92
+				HTTP_WebDAV_Server::mkprop('report', array(
93
+					!$data['ns'] ? HTTP_WebDAV_Server::mkprop($name, '') : HTTP_WebDAV_Server::mkprop($data['ns'], $name, '')))));
95 94
 		}
96 95
 		return $supported;
97 96
 	}
@@ -105,7 +104,7 @@  discard block
 block discarded – undo
105 104
 	 * @param int $user account_id
106 105
 	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
107 106
 	 */
108
-	function propfind($path,&$options,&$files,$user)
107
+	function propfind($path, &$options, &$files, $user)
109 108
 	{
110 109
 		if (($report = isset($_GET['report']) ? $_GET['report'] : $options['root']['name']) && $report != 'propfind')
111 110
 		{
@@ -117,7 +116,7 @@  discard block
 block discarded – undo
117 116
 			$this->groupdav->log(__METHOD__."('$path', ".array2string($options).",, $user) not implemented report, returning 501 Not Implemented");
118 117
 			return '501 Not Implemented';
119 118
 		}
120
-		list(,$principals,$type,$name,$rest) = explode('/',$path,5);
119
+		list(,$principals, $type, $name, $rest) = explode('/', $path, 5);
121 120
 		// /principals/users/$name/
122 121
 		//            /users/$name/calendar-proxy-read/
123 122
 		//            /users/$name/calendar-proxy-write/
@@ -126,19 +125,19 @@  discard block
 block discarded – undo
126 125
 		//            /locations/$resource/
127 126
 		//            /__uids__/$uid/.../
128 127
 
129
-		switch($type)
128
+		switch ($type)
130 129
 		{
131 130
 			case 'users':
132
-				$files['files'] = $this->propfind_users($name,$rest,$options);
131
+				$files['files'] = $this->propfind_users($name, $rest, $options);
133 132
 				break;
134 133
 			case 'groups':
135
-				$files['files'] = $this->propfind_groups($name,$rest,$options);
134
+				$files['files'] = $this->propfind_groups($name, $rest, $options);
136 135
 				break;
137 136
 			case 'resources':
138
-				$files['files'] = $this->propfind_resources($name,$rest,$options,false);
137
+				$files['files'] = $this->propfind_resources($name, $rest, $options, false);
139 138
 				break;
140 139
 			case 'locations':
141
-				$files['files'] = $this->propfind_resources($name,$rest,$options,true);
140
+				$files['files'] = $this->propfind_resources($name, $rest, $options, true);
142 141
 				break;
143 142
 			/*case '__uids__':
144 143
 				$files['files'] = $this->propfind_uids($name,$rest,$options);
@@ -248,11 +247,11 @@  discard block
 block discarded – undo
248 247
 	 * @param int $user account_id
249 248
 	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
250 249
 	 */
251
-	function expand_property_report($path,&$options,&$files,$user)
250
+	function expand_property_report($path, &$options, &$files, $user)
252 251
 	{
253 252
 		//error_log(__METHOD__."('$path', ".array2string($options).",, $user)");
254 253
 		$requested_props = $options['other'];
255
-		while(($requested_prop = array_shift($requested_props)))
254
+		while (($requested_prop = array_shift($requested_props)))
256 255
 		{
257 256
 			if ($requested_prop['name'] != 'property' || $requested_prop['depth'] != 1) continue;
258 257
 
@@ -260,11 +259,11 @@  discard block
 block discarded – undo
260 259
 			$prop_name = $requested_prop['attrs']['name'];
261 260
 			$prop_path = $path;
262 261
 			// calendarserver has some special property-names for expansion
263
-			switch($prop_name)
262
+			switch ($prop_name)
264 263
 			{
265 264
 				case 'calendar-proxy-read-for':
266 265
 				case 'calendar-proxy-write-for':
267
-					$prop_path = $path . substr($prop_name, 0, -4).'/';
266
+					$prop_path = $path.substr($prop_name, 0, -4).'/';
268 267
 					$prop_name = 'group-member-set';
269 268
 					$prop_ns = groupdav::DAV;
270 269
 					break;
@@ -284,14 +283,14 @@  discard block
 block discarded – undo
284 283
 				'xmlns' => $prop_ns,
285 284
 			));
286 285
 			$prop_files = array();
287
-			$this->groupdav->options = $options;	// also modify global variable
286
+			$this->groupdav->options = $options; // also modify global variable
288 287
 			if (empty($prop_name) || $this->propfind($prop_path, $options, $prop_files, $user) !== true)
289 288
 			{
290 289
 				$this->groupdav->log('### NO expand-property report for '.$requested_prop['attrs']['name']);
291 290
 				continue;
292 291
 			}
293 292
 			// find prop to expand
294
-			foreach($prop_files['files'][0]['props'] as $name => $expand_prop)
293
+			foreach ($prop_files['files'][0]['props'] as $name => $expand_prop)
295 294
 			{
296 295
 				if ($expand_prop['name'] === $prop_name) break;
297 296
 			}
@@ -305,7 +304,7 @@  discard block
 block discarded – undo
305 304
 			// requested properties of each href are in depth=2 properties
306 305
 			// set them as regular propfind properties to $options['props']
307 306
 			$options2 = array('props' => 'all');
308
-			while(($prop = array_shift($requested_props)) && $prop['depth'] >= 2)
307
+			while (($prop = array_shift($requested_props)) && $prop['depth'] >= 2)
309 308
 			{
310 309
 				if ($prop['name'] == 'property' && $prop['depth'] == 2)
311 310
 				{
@@ -321,10 +320,10 @@  discard block
 block discarded – undo
321 320
 			}
322 321
 			// put back evtl. read top-level property
323 322
 			if ($prop && $prop['depth'] == 1) array_unshift($requested_props, $prop);
324
-			$this->groupdav->options = $options2;	// also modify global variable
323
+			$this->groupdav->options = $options2; // also modify global variable
325 324
 
326 325
 			// run regular profind to get requested 2.-level properties for each href
327
-			foreach($expand_prop['val'] as $key => &$prop_val)
326
+			foreach ($expand_prop['val'] as $key => &$prop_val)
328 327
 			{
329 328
 				list(,$expand_path) = explode($this->groupdav->base_uri, $prop_val['val']);
330 329
 				//error_log(__METHOD__."('$path', ..., $user) calling propfind('$expand_path', ".array2string($options2).', '.array2string($prop_val).", $user)");
@@ -419,23 +418,23 @@  discard block
 block discarded – undo
419 418
 	 * @param int $user account_id
420 419
 	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
421 420
 	 */
422
-	function principal_property_search_report($path,&$options,&$files,$user)
421
+	function principal_property_search_report($path, &$options, &$files, $user)
423 422
 	{
424 423
 		//error_log(__METHOD__."('$path', ".array2string($options).",, $user)");
425 424
 
426 425
 		// cant find the test attribute to root principal-property-search element in WebDAV rfc, but iPhones use it ...
427
-		$anyof = !empty($options['root']['attrs']['test']) && $options['root']['attrs']['test'] == 'anyof';	// "allof" (default) or "anyof"
426
+		$anyof = !empty($options['root']['attrs']['test']) && $options['root']['attrs']['test'] == 'anyof'; // "allof" (default) or "anyof"
428 427
 
429 428
 		// parse property-search prop(s) contained in $options['other']
430
-		foreach($options['other'] as $n => $prop)
429
+		foreach ($options['other'] as $n => $prop)
431 430
 		{
432
-			switch($prop['name'])
431
+			switch ($prop['name'])
433 432
 			{
434 433
 				case 'apply-to-principal-collection-set':	// optinal prop to apply search on principal-collection-set == '/principals/'
435 434
 					$path = '/principals/';
436 435
 					break;
437 436
 				case 'property-search':
438
-					$property_search = $n;	// should be 1
437
+					$property_search = $n; // should be 1
439 438
 					break;
440 439
 				case 'prop':
441 440
 					if (isset($property_search))
@@ -465,7 +464,7 @@  discard block
 block discarded – undo
465 464
 			return '400 Bad Request';
466 465
 		}
467 466
 		// make sure search property is included in toplevel props (can be missing and defaults to property-search/prop's)
468
-		foreach($search_props as $prop)
467
+		foreach ($search_props as $prop)
469 468
 		{
470 469
 			if (!$this->groupdav->prop_requested($prop['name'], $prop['xmlns']))
471 470
 			{
@@ -478,7 +477,7 @@  discard block
 block discarded – undo
478 477
 			// but interprets returning all principals (all have a matching calendar-home-set) as NOT supporting CalDAV scheduling
479 478
 			// --> search only current user's principal
480 479
 			if ($prop['name'] == 'calendar-home-set' && stripos($_SERVER['HTTP_USER_AGENT'], 'Lightning') !== false &&
481
-				substr($search_props[0]['match'],-13) == '/groupdav.php')
480
+				substr($search_props[0]['match'], -13) == '/groupdav.php')
482 481
 			{
483 482
 				$path = '/principals/users/'.$GLOBALS['egw_info']['user']['account_lid'].'/';
484 483
 				$this->groupdav->log('Enabling hack for Lightning prior 1.1.1 for searching calendar-home-set matching "/groupdav.php": limiting search to '.$path);
@@ -487,7 +486,7 @@  discard block
 block discarded – undo
487 486
 		// check type attribute to limit search on a certain tree
488 487
 		if (isset($options['root']['attrs']['type']))
489 488
 		{
490
-			switch($options['root']['attrs']['type'])
489
+			switch ($options['root']['attrs']['type'])
491 490
 			{
492 491
 				case 'INDIVIDUAL':
493 492
 					$path = '/principals/users/';
@@ -514,7 +513,7 @@  discard block
 block discarded – undo
514 513
 			return $ret;
515 514
 		}
516 515
 		// now filter out not matching "files"
517
-		foreach($files['files'] as $n => $resource)
516
+		foreach ($files['files'] as $n => $resource)
518 517
 		{
519 518
 			if (count(explode('/', $resource['path'])) < 5)	// hack to only return principals, not the collections itself
520 519
 			{
@@ -523,15 +522,15 @@  discard block
 block discarded – undo
523 522
 			}
524 523
 			// match with $search_props
525 524
 			$matches = 0;
526
-			foreach($search_props as $search_prop)
525
+			foreach ($search_props as $search_prop)
527 526
 			{
528 527
 				// search resource for $search_prop
529
-				foreach($resource['props'] as $prop) if ($prop['name'] === $search_prop['name']) break;
528
+				foreach ($resource['props'] as $prop) if ($prop['name'] === $search_prop['name']) break;
530 529
 				if ($prop['name'] === $search_prop['name'])	// search_prop NOT found
531 530
 				{
532
-					foreach((array)$prop['val'] as $value)
531
+					foreach ((array)$prop['val'] as $value)
533 532
 					{
534
-						if (is_array($value)) $value = $value['val'];	// eg. href prop
533
+						if (is_array($value)) $value = $value['val']; // eg. href prop
535 534
 						if (self::match($value, $search_prop['match'], $search_prop['match-type']) !== false)	// prop does match
536 535
 						{
537 536
 							++$matches;
@@ -543,7 +542,7 @@  discard block
 block discarded – undo
543 542
 				if ($anyof && $matches || $matches == count($search_props))
544 543
 				{
545 544
 					//error_log("$resource[path]: anyof=$anyof, $matches matches --> keep");
546
-					continue 2;	// enough matches --> keep
545
+					continue 2; // enough matches --> keep
547 546
 				}
548 547
 			}
549 548
 			//error_log("$resource[path]: anyof=$anyof, $matches matches --> skip");
@@ -561,9 +560,9 @@  discard block
 block discarded – undo
561 560
 	 * @param string $match criteria/sub-string
562 561
 	 * @param string $match_type='contains' 'starts-with', 'ends-with' or 'equals'
563 562
 	 */
564
-	private static function match($value, $match, $match_type='contains')
563
+	private static function match($value, $match, $match_type = 'contains')
565 564
 	{
566
-		switch($match_type)
565
+		switch ($match_type)
567 566
 		{
568 567
 			case 'equals':
569 568
 				return $value === $match;
@@ -633,7 +632,7 @@  discard block
 block discarded – undo
633 632
 	 * @param int $user account_id
634 633
 	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
635 634
 	 */
636
-	function principal_search_property_set_report($path,&$options,&$files,$user)
635
+	function principal_search_property_set_report($path, &$options, &$files, $user)
637 636
 	{
638 637
 		static $search_props = array(
639 638
 			// from iOS iCal
@@ -655,7 +654,7 @@  discard block
 block discarded – undo
655 654
 		$xml->startDocument('1.0', 'UTF-8');
656 655
 		$xml->startElementNs(null, 'principal-search-property-set', 'DAV:');
657 656
 
658
-		foreach($search_props as $name => $data)
657
+		foreach ($search_props as $name => $data)
659 658
 		{
660 659
 			$xml->startElement('principal-search-property');
661 660
 			$xml->startElement('prop');
@@ -667,16 +666,16 @@  discard block
 block discarded – undo
667 666
 			{
668 667
 				$xml->writeElement($name);
669 668
 			}
670
-			$xml->endElement();	// prop
669
+			$xml->endElement(); // prop
671 670
 
672 671
 			$xml->startElement('description');
673 672
 			$xml->writeAttribute('xml:lang', 'en');
674 673
 			$xml->text(is_array($data) ? $data['description'] : $data);
675
-			$xml->endElement();	// description
674
+			$xml->endElement(); // description
676 675
 
677
-			$xml->endElement();	// principal-search-property
676
+			$xml->endElement(); // principal-search-property
678 677
 		}
679
-		$xml->endElement();	// principal-search-property-set
678
+		$xml->endElement(); // principal-search-property-set
680 679
 		$xml->endDocument();
681 680
 		echo $xml->outputMemory();
682 681
 
@@ -711,7 +710,7 @@  discard block
 block discarded – undo
711 710
 	 * @param int $user account_id
712 711
 	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
713 712
 	 */
714
-	function acl_principal_prop_set_report($path,&$options,&$files,$user)
713
+	function acl_principal_prop_set_report($path, &$options, &$files, $user)
715 714
 	{
716 715
 		//error_log(__METHOD__."('$path', ".array2string($options).",, $user)");
717 716
 
@@ -730,13 +729,13 @@  discard block
 block discarded – undo
730 729
 			return $ret;
731 730
 		}
732 731
 		// now filter out not matching "files"
733
-		foreach($files['files'] as $n => $resource)
732
+		foreach ($files['files'] as $n => $resource)
734 733
 		{
735
-			foreach($resource['props']['resourcetype']['val'] as $prop)
734
+			foreach ($resource['props']['resourcetype']['val'] as $prop)
736 735
 			{
737 736
 				if ($prop['name'] == 'principal') continue 2;
738 737
 			}
739
-			unset($files['files'][$n]);	// not a principal --> do not return
738
+			unset($files['files'][$n]); // not a principal --> do not return
740 739
 		}
741 740
 		// we should not return it
742 741
 		unset($options['props']['resourcetype']);
@@ -752,7 +751,7 @@  discard block
 block discarded – undo
752 751
 	 * @param array $options
753 752
 	 * @return array|string array with files or HTTP error code
754 753
 	 */
755
-	protected function propfind_users($name,$rest,array $options)
754
+	protected function propfind_users($name, $rest, array $options)
756 755
 	{
757 756
 		//error_log(__METHOD__."($name,$rest,".array2string($options).')');
758 757
 		if (empty($name))
@@ -771,7 +770,7 @@  discard block
 block discarded – undo
771 770
 				else
772 771
 				{
773 772
 					// add all users (account_selection == groupmembers is handled by accounts->search())
774
-					foreach($this->accounts->search(array('type' => 'accounts','order' => 'account_lid')) as $account)
773
+					foreach ($this->accounts->search(array('type' => 'accounts', 'order' => 'account_lid')) as $account)
775 774
 					{
776 775
 						$files[] = $this->add_account($account);
777 776
 					}
@@ -780,15 +779,15 @@  discard block
 block discarded – undo
780 779
 		}
781 780
 		else
782 781
 		{
783
-			if (!($id = $this->accounts->name2id($name,'account_lid','u')) ||
782
+			if (!($id = $this->accounts->name2id($name, 'account_lid', 'u')) ||
784 783
 				!($account = $this->accounts->read($id)) ||
785 784
 				!$this->accounts->visible($name))
786 785
 			{
787 786
 				$this->groupdav->log(__METHOD__."('$name', ...) account '$name' NOT found OR not visible to you (check account-selection preference)!");
788 787
 				return '404 Not Found';
789 788
 			}
790
-			while (substr($rest,-1) == '/') $rest = substr($rest,0,-1);
791
-			switch((string)$rest)
789
+			while (substr($rest, -1) == '/') $rest = substr($rest, 0, -1);
790
+			switch ((string)$rest)
792 791
 			{
793 792
 				case '':
794 793
 					$files[] = $this->add_account($account);
@@ -818,7 +817,7 @@  discard block
 block discarded – undo
818 817
 	 * @param array $options
819 818
 	 * @return array|string array with files or HTTP error code
820 819
 	 */
821
-	protected function propfind_groups($name,$rest,array $options)
820
+	protected function propfind_groups($name, $rest, array $options)
822 821
 	{
823 822
 		//echo "<p>".__METHOD__."($name,$rest,".array2string($options).")</p>\n";
824 823
 		if (empty($name))
@@ -830,11 +829,11 @@  discard block
 block discarded – undo
830 829
 			if ($options['depth'])
831 830
 			{
832 831
 				// only show own groups, if account-selection is groupmembers or none
833
-				$type = in_array($GLOBALS['egw_info']['user']['preferences']['common']['account_selection'], array('groupmembers','none')) ?
832
+				$type = in_array($GLOBALS['egw_info']['user']['preferences']['common']['account_selection'], array('groupmembers', 'none')) ?
834 833
 					'owngroups' : 'groups';
835 834
 
836 835
 				// add all groups or only membergroups
837
-				foreach($this->accounts->search(array('type' => $type,'order' => 'account_lid')) as $account)
836
+				foreach ($this->accounts->search(array('type' => $type, 'order' => 'account_lid')) as $account)
838 837
 				{
839 838
 					$files[] = $this->add_group($account);
840 839
 				}
@@ -842,16 +841,16 @@  discard block
 block discarded – undo
842 841
 		}
843 842
 		else
844 843
 		{
845
-			if (!($id = $this->accounts->name2id($name,'account_lid','g')) ||
844
+			if (!($id = $this->accounts->name2id($name, 'account_lid', 'g')) ||
846 845
 				!($account = $this->accounts->read($id)) ||
847 846
 				// do NOT allow other groups, if account-selection is groupmembers or none
848
-				in_array($GLOBALS['egw_info']['user']['preferences']['common']['account_selection'], array('groupmembers','none')) &&
849
-				!in_array($account['account_id'], $this->accounts->memberships($GLOBALS['egw_info']['user']['account_id'],true)))
847
+				in_array($GLOBALS['egw_info']['user']['preferences']['common']['account_selection'], array('groupmembers', 'none')) &&
848
+				!in_array($account['account_id'], $this->accounts->memberships($GLOBALS['egw_info']['user']['account_id'], true)))
850 849
 			{
851 850
 				return '404 Not Found';
852 851
 			}
853
-			while (substr($rest,-1) == '/') $rest = substr($rest,0,-1);
854
-			switch((string)$rest)
852
+			while (substr($rest, -1) == '/') $rest = substr($rest, 0, -1);
853
+			switch ((string)$rest)
855 854
 			{
856 855
 				case '':
857 856
 					$files[] = $this->add_group($account);
@@ -882,10 +881,10 @@  discard block
 block discarded – undo
882 881
 	{
883 882
 		$addressbooks = array();
884 883
 		$addressbook_home_set = $GLOBALS['egw_info']['user']['preferences']['groupdav']['addressbook-home-set'];
885
-		if (empty($addressbook_home_set)) $addressbook_home_set = 'P';	// personal addressbook
886
-		$addressbook_home_set = explode(',',$addressbook_home_set);
884
+		if (empty($addressbook_home_set)) $addressbook_home_set = 'P'; // personal addressbook
885
+		$addressbook_home_set = explode(',', $addressbook_home_set);
887 886
 		// replace symbolic id's with real nummeric id's
888
-		foreach(array(
887
+		foreach (array(
889 888
 			'P' => $GLOBALS['egw_info']['user']['account_id'],
890 889
 			'G' => $GLOBALS['egw_info']['user']['account_primary_group'],
891 890
 			'U' => '0',
@@ -896,13 +895,13 @@  discard block
 block discarded – undo
896 895
 				$addressbook_home_set[$key] = $id;
897 896
 			}
898 897
 		}
899
-		if (in_array('O',$addressbook_home_set))	// "all in one" from groupdav.php/addressbook/
898
+		if (in_array('O', $addressbook_home_set))	// "all in one" from groupdav.php/addressbook/
900 899
 		{
901 900
 			$addressbooks[] = '/';
902 901
 		}
903
-		foreach(ExecMethod('addressbook.addressbook_bo.get_addressbooks',EGW_ACL_READ) as $id => $label)
902
+		foreach (ExecMethod('addressbook.addressbook_bo.get_addressbooks', EGW_ACL_READ) as $id => $label)
904 903
 		{
905
-			if ((in_array('A',$addressbook_home_set) || in_array((string)$id,$addressbook_home_set)) &&
904
+			if ((in_array('A', $addressbook_home_set) || in_array((string)$id, $addressbook_home_set)) &&
906 905
 				is_numeric($id) && ($owner = $this->accounts->id2name($id)))
907 906
 			{
908 907
 				$addressbooks[] = '/'.$owner.'/';
@@ -926,45 +925,45 @@  discard block
 block discarded – undo
926 925
 		$calendars[] = HTTP_WebDAV_Server::mkprop('href',
927 926
 			$this->base_uri.'/'.$account['account_lid'].'/');
928 927
 
929
-		$displayname = translation::convert($account['account_fullname'], translation::charset(),'utf-8');
928
+		$displayname = translation::convert($account['account_fullname'], translation::charset(), 'utf-8');
930 929
 
931 930
 		return $this->add_principal('users/'.$account['account_lid'], array(
932 931
 			'getetag' => $this->get_etag($account),
933 932
 			'displayname' => $displayname,
934 933
 			// CalDAV
935
-			'calendar-home-set' => HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'calendar-home-set',$calendars),
934
+			'calendar-home-set' => HTTP_WebDAV_Server::mkprop(groupdav::CALDAV, 'calendar-home-set', $calendars),
936 935
 			// CalDAV scheduling
937
-			'schedule-outbox-URL' => HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'schedule-outbox-URL',array(
938
-				HTTP_WebDAV_Server::mkprop('href',$this->base_uri.'/'.$account['account_lid'].'/outbox/'))),
939
-			'schedule-inbox-URL' => HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'schedule-inbox-URL',array(
940
-				HTTP_WebDAV_Server::mkprop('href',$this->base_uri.'/'.$account['account_lid'].'/inbox/'))),
941
-			'calendar-user-address-set' => HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'calendar-user-address-set',array(
942
-				HTTP_WebDAV_Server::mkprop('href','mailto:'.$account['account_email']),
943
-				HTTP_WebDAV_Server::mkprop('href',$this->base_uri(true).'/principals/users/'.$account['account_lid'].'/'),
944
-				HTTP_WebDAV_Server::mkprop('href',$this->base_uri(false).'/principals/users/'.$account['account_lid'].'/'),
945
-				HTTP_WebDAV_Server::mkprop('href','urn:uuid:'.common::generate_uid('accounts', $account['account_id'])),
936
+			'schedule-outbox-URL' => HTTP_WebDAV_Server::mkprop(groupdav::CALDAV, 'schedule-outbox-URL', array(
937
+				HTTP_WebDAV_Server::mkprop('href', $this->base_uri.'/'.$account['account_lid'].'/outbox/'))),
938
+			'schedule-inbox-URL' => HTTP_WebDAV_Server::mkprop(groupdav::CALDAV, 'schedule-inbox-URL', array(
939
+				HTTP_WebDAV_Server::mkprop('href', $this->base_uri.'/'.$account['account_lid'].'/inbox/'))),
940
+			'calendar-user-address-set' => HTTP_WebDAV_Server::mkprop(groupdav::CALDAV, 'calendar-user-address-set', array(
941
+				HTTP_WebDAV_Server::mkprop('href', 'mailto:'.$account['account_email']),
942
+				HTTP_WebDAV_Server::mkprop('href', $this->base_uri(true).'/principals/users/'.$account['account_lid'].'/'),
943
+				HTTP_WebDAV_Server::mkprop('href', $this->base_uri(false).'/principals/users/'.$account['account_lid'].'/'),
944
+				HTTP_WebDAV_Server::mkprop('href', 'urn:uuid:'.common::generate_uid('accounts', $account['account_id'])),
946 945
 			)),
947
-			'calendar-user-type' => HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'calendar-user-type','INDIVIDUAL'),
946
+			'calendar-user-type' => HTTP_WebDAV_Server::mkprop(groupdav::CALDAV, 'calendar-user-type', 'INDIVIDUAL'),
948 947
 			// Calendarserver
949
-			'email-address-set' => HTTP_WebDAV_Server::mkprop(groupdav::CALENDARSERVER,'email-address-set',array(
950
-				HTTP_WebDAV_Server::mkprop(groupdav::CALENDARSERVER,'email-address',$account['account_email']))),
951
-			'last-name' => HTTP_WebDAV_Server::mkprop(groupdav::CALENDARSERVER,'last-name',$account['account_lastname']),
952
-			'first-name' => HTTP_WebDAV_Server::mkprop(groupdav::CALENDARSERVER,'first-name',$account['account_firstname']),
953
-			'record-type' => HTTP_WebDAV_Server::mkprop(groupdav::CALENDARSERVER,'record-type','users'),
948
+			'email-address-set' => HTTP_WebDAV_Server::mkprop(groupdav::CALENDARSERVER, 'email-address-set', array(
949
+				HTTP_WebDAV_Server::mkprop(groupdav::CALENDARSERVER, 'email-address', $account['account_email']))),
950
+			'last-name' => HTTP_WebDAV_Server::mkprop(groupdav::CALENDARSERVER, 'last-name', $account['account_lastname']),
951
+			'first-name' => HTTP_WebDAV_Server::mkprop(groupdav::CALENDARSERVER, 'first-name', $account['account_firstname']),
952
+			'record-type' => HTTP_WebDAV_Server::mkprop(groupdav::CALENDARSERVER, 'record-type', 'users'),
954 953
 			// WebDAV ACL and CalDAV proxy
955 954
 			'group-membership' => $this->principal_set('group-membership', $this->accounts->memberships($account['account_id']),
956
-				array('calendar', 'resources'), $account['account_id']),	// add proxy-rights
955
+				array('calendar', 'resources'), $account['account_id']), // add proxy-rights
957 956
 			'alternate-URI-set' => array(
958
-				HTTP_WebDAV_Server::mkprop('href','mailto:'.$account['account_email'])),
957
+				HTTP_WebDAV_Server::mkprop('href', 'mailto:'.$account['account_email'])),
959 958
 			// CardDAV
960
-			'addressbook-home-set' => HTTP_WebDAV_Server::mkprop(groupdav::CARDDAV,'addressbook-home-set',$addressbooks),
961
-			'principal-address' => HTTP_WebDAV_Server::mkprop(groupdav::CARDDAV,'principal-address',
959
+			'addressbook-home-set' => HTTP_WebDAV_Server::mkprop(groupdav::CARDDAV, 'addressbook-home-set', $addressbooks),
960
+			'principal-address' => HTTP_WebDAV_Server::mkprop(groupdav::CARDDAV, 'principal-address',
962 961
 				$GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] ? '' : array(
963
-				HTTP_WebDAV_Server::mkprop('href',$this->base_uri.'/addressbook-accounts/'.$account['person_id'].'.vcf'))),
962
+				HTTP_WebDAV_Server::mkprop('href', $this->base_uri.'/addressbook-accounts/'.$account['person_id'].'.vcf'))),
964 963
 			// CardDAV directory
965
-			'directory-gateway' => HTTP_WebDAV_Server::mkprop(groupdav::CARDDAV, 'directory-gateway',array(
964
+			'directory-gateway' => HTTP_WebDAV_Server::mkprop(groupdav::CARDDAV, 'directory-gateway', array(
966 965
 				HTTP_WebDAV_Server::mkprop('href', $this->base_uri.'/addressbook/'))),
967
-			'resource-id' => array(HTTP_WebDAV_Server::mkprop('href','urn:uuid:'.common::generate_uid('accounts', $account['account_id']))),
966
+			'resource-id' => array(HTTP_WebDAV_Server::mkprop('href', 'urn:uuid:'.common::generate_uid('accounts', $account['account_id']))),
968 967
 		));
969 968
 	}
970 969
 
@@ -976,7 +975,7 @@  discard block
 block discarded – undo
976 975
 	 * @param string $cn=null common name to be stored in case of an "e" uid
977 976
 	 * @return int|string|boolean integer account_id, string calendar uid or false if not a supported uid
978 977
 	 */
979
-	static public function url2uid($url, $only_type=null, $cn=null)
978
+	static public function url2uid($url, $only_type = null, $cn = null)
980 979
 	{
981 980
 		if (!$only_type) $only_type = array('users', 'groups', 'resources', 'locations', 'mailto');
982 981
 
@@ -990,17 +989,17 @@  discard block
 block discarded – undo
990 989
 		}
991 990
 		if (empty($rest)) return false;
992 991
 
993
-		switch(strtolower($schema))
992
+		switch (strtolower($schema))
994 993
 		{
995 994
 			case 'http':
996 995
 			case 'https':
997 996
 				list(,$rest) = explode('/groupdav.php/principals/', $url);
998 997
 				list($type, $name) = explode('/', $rest);
999
-				switch($type)
998
+				switch ($type)
1000 999
 				{
1001 1000
 					case 'users':
1002 1001
 					case 'groups':
1003
-						$uid = $GLOBALS['egw']->accounts->name2id($name, 'account_lid', $type[0]);	// u=users, g=groups
1002
+						$uid = $GLOBALS['egw']->accounts->name2id($name, 'account_lid', $type[0]); // u=users, g=groups
1004 1003
 						break;
1005 1004
 					case 'resources':
1006 1005
 					case 'locations':
@@ -1017,9 +1016,9 @@  discard block
 block discarded – undo
1017 1016
 				}
1018 1017
 				// search contacts for email
1019 1018
 				if ((list($data) = $GLOBALS['egw']->contacts->search(array('email' => $rest, 'email_home' => $rest),
1020
-					array('id','egw_addressbook.account_id as account_id','n_fn'),
1019
+					array('id', 'egw_addressbook.account_id as account_id', 'n_fn'),
1021 1020
 					'egw_addressbook.account_id IS NOT NULL DESC, n_fn IS NOT NULL DESC',
1022
-					'','',false,'OR')))
1021
+					'', '', false, 'OR')))
1023 1022
 				{
1024 1023
 					// found an addressbook entry
1025 1024
 					$uid = $data['account_id'] ? (int)$data['account_id'] : 'c'.$data['id'];
@@ -1052,7 +1051,7 @@  discard block
 block discarded – undo
1052 1051
 					{
1053 1052
 						static $calendar_bo;
1054 1053
 						if (is_null($calendar_bo)) $calendar_bo = new calendar_bo();
1055
-						foreach($calendar_bo->resources as $letter => $info)
1054
+						foreach ($calendar_bo->resources as $letter => $info)
1056 1055
 						{
1057 1056
 							if ($info['app'] == $type || $info['app'] == 'resources' && $type == 'location')
1058 1057
 							{
@@ -1065,7 +1064,7 @@  discard block
 block discarded – undo
1065 1064
 				break;
1066 1065
 
1067 1066
 			default:
1068
-				if (isset($GLOBALS['groupdav']) && is_a($GLOBALS['groupdav'],'groupdav'))
1067
+				if (isset($GLOBALS['groupdav']) && is_a($GLOBALS['groupdav'], 'groupdav'))
1069 1068
 				{
1070 1069
 					$GLOBALS['groupdav']->log(__METHOD__."('$url') unsupported principal URL '$url'!");
1071 1070
 				}
@@ -1083,7 +1082,7 @@  discard block
 block discarded – undo
1083 1082
 	 */
1084 1083
 	protected function add_group(array $account)
1085 1084
 	{
1086
-		$displayname = translation::convert(lang('Group').' '.$account['account_lid'],	translation::charset(), 'utf-8');
1085
+		$displayname = translation::convert(lang('Group').' '.$account['account_lid'], translation::charset(), 'utf-8');
1087 1086
 
1088 1087
 		// only return current user, if account-selection == 'none'
1089 1088
 		if ($GLOBALS['egw_info']['user']['preferences']['common']['account_selection'] == 'none')
@@ -1098,19 +1097,19 @@  discard block
 block discarded – undo
1098 1097
 		return $this->add_principal('groups/'.$account['account_lid'], array(
1099 1098
 			'getetag' => $this->get_etag($account),
1100 1099
 			'displayname' => $displayname,
1101
-			'calendar-home-set' => HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'calendar-home-set',array(
1102
-				HTTP_WebDAV_Server::mkprop('href',$this->base_uri.'/'.$account['account_lid'].'/'))),
1103
-			'addressbook-home-set' => HTTP_WebDAV_Server::mkprop(groupdav::CARDDAV,'addressbook-home-set',array(
1104
-				HTTP_WebDAV_Server::mkprop('href',$this->base_uri.'/'.$account['account_lid'].'/'))),
1105
-			'calendar-user-address-set' => HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'calendar-user-address-set',array(
1106
-				HTTP_WebDAV_Server::mkprop('href',$this->base_uri(true).'/principals/groups/'.$account['account_lid'].'/'),
1107
-				HTTP_WebDAV_Server::mkprop('href',$this->base_uri(false).'/principals/groups/'.$account['account_lid'].'/'),
1108
-				HTTP_WebDAV_Server::mkprop('href','urn:uuid:'.common::generate_uid('accounts', $account['account_id'])),
1100
+			'calendar-home-set' => HTTP_WebDAV_Server::mkprop(groupdav::CALDAV, 'calendar-home-set', array(
1101
+				HTTP_WebDAV_Server::mkprop('href', $this->base_uri.'/'.$account['account_lid'].'/'))),
1102
+			'addressbook-home-set' => HTTP_WebDAV_Server::mkprop(groupdav::CARDDAV, 'addressbook-home-set', array(
1103
+				HTTP_WebDAV_Server::mkprop('href', $this->base_uri.'/'.$account['account_lid'].'/'))),
1104
+			'calendar-user-address-set' => HTTP_WebDAV_Server::mkprop(groupdav::CALDAV, 'calendar-user-address-set', array(
1105
+				HTTP_WebDAV_Server::mkprop('href', $this->base_uri(true).'/principals/groups/'.$account['account_lid'].'/'),
1106
+				HTTP_WebDAV_Server::mkprop('href', $this->base_uri(false).'/principals/groups/'.$account['account_lid'].'/'),
1107
+				HTTP_WebDAV_Server::mkprop('href', 'urn:uuid:'.common::generate_uid('accounts', $account['account_id'])),
1109 1108
 			)),
1110
-			'record-type' => HTTP_WebDAV_Server::mkprop(groupdav::CALENDARSERVER,'record-type','groups'),
1111
-			'calendar-user-type' => HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'calendar-user-type','GROUP'),
1109
+			'record-type' => HTTP_WebDAV_Server::mkprop(groupdav::CALENDARSERVER, 'record-type', 'groups'),
1110
+			'calendar-user-type' => HTTP_WebDAV_Server::mkprop(groupdav::CALDAV, 'calendar-user-type', 'GROUP'),
1112 1111
 			'group-member-set' => $this->principal_set('group-member-set', $groupmembers),
1113
-			'resource-id' => array(HTTP_WebDAV_Server::mkprop('href','urn:uuid:'.common::generate_uid('accounts', $account['account_id']))),
1112
+			'resource-id' => array(HTTP_WebDAV_Server::mkprop('href', 'urn:uuid:'.common::generate_uid('accounts', $account['account_id']))),
1114 1113
 		));
1115 1114
 	}
1116 1115
 
@@ -1121,25 +1120,25 @@  discard block
 block discarded – undo
1121 1120
 	 * @param boolean $is_location=null
1122 1121
 	 * @return array with values for keys 'path' and 'props'
1123 1122
 	 */
1124
-	protected function add_principal_resource(array $resource, $is_location=null)
1123
+	protected function add_principal_resource(array $resource, $is_location = null)
1125 1124
 	{
1126 1125
 		$name = $this->resource2name($resource, $is_location, $displayname);
1127 1126
 
1128 1127
 		return $this->add_principal($name, array(
1129 1128
 			'getetag' => $this->get_resource_etag($resource),
1130 1129
 			'displayname' => $displayname,
1131
-			'calendar-user-address-set' => HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'calendar-user-address-set',array(
1132
-				HTTP_WebDAV_Server::mkprop('href',$this->base_uri(true).'/principals/'.$name.'/'),
1133
-				HTTP_WebDAV_Server::mkprop('href',$this->base_uri(false).'/principals/'.$name.'/'),
1134
-				HTTP_WebDAV_Server::mkprop('href','urn:uuid:'.common::generate_uid('resources', $resource['res_id'])),
1130
+			'calendar-user-address-set' => HTTP_WebDAV_Server::mkprop(groupdav::CALDAV, 'calendar-user-address-set', array(
1131
+				HTTP_WebDAV_Server::mkprop('href', $this->base_uri(true).'/principals/'.$name.'/'),
1132
+				HTTP_WebDAV_Server::mkprop('href', $this->base_uri(false).'/principals/'.$name.'/'),
1133
+				HTTP_WebDAV_Server::mkprop('href', 'urn:uuid:'.common::generate_uid('resources', $resource['res_id'])),
1135 1134
 			)),
1136
-			'record-type' => HTTP_WebDAV_Server::mkprop(groupdav::CALENDARSERVER,'record-type',$is_location ? 'locations' : 'resources'),
1137
-			'calendar-user-type' => HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'calendar-user-type',$is_location ? 'ROOM' : 'RESOURCE'),
1138
-			'resource-id' => array(HTTP_WebDAV_Server::mkprop('href','urn:uuid:'.common::generate_uid('resources', $resource['res_id']))),
1135
+			'record-type' => HTTP_WebDAV_Server::mkprop(groupdav::CALENDARSERVER, 'record-type', $is_location ? 'locations' : 'resources'),
1136
+			'calendar-user-type' => HTTP_WebDAV_Server::mkprop(groupdav::CALDAV, 'calendar-user-type', $is_location ? 'ROOM' : 'RESOURCE'),
1137
+			'resource-id' => array(HTTP_WebDAV_Server::mkprop('href', 'urn:uuid:'.common::generate_uid('resources', $resource['res_id']))),
1139 1138
 			// Calendarserver also reports empty email-address-set, thought iCal still does not show resources (only locations)
1140
-			'email-address-set' => HTTP_WebDAV_Server::mkprop(groupdav::CALENDARSERVER,'email-address-set',''),
1141
-			'calendar-home-set' => HTTP_WebDAV_Server::mkprop(groupdav::CALDAV,'calendar-home-set',array(
1142
-				HTTP_WebDAV_Server::mkprop('href',$this->base_uri.'/'.$name.'/'))),
1139
+			'email-address-set' => HTTP_WebDAV_Server::mkprop(groupdav::CALENDARSERVER, 'email-address-set', ''),
1140
+			'calendar-home-set' => HTTP_WebDAV_Server::mkprop(groupdav::CALDAV, 'calendar-home-set', array(
1141
+				HTTP_WebDAV_Server::mkprop('href', $this->base_uri.'/'.$name.'/'))),
1143 1142
 		));
1144 1143
 	}
1145 1144
 
@@ -1151,7 +1150,7 @@  discard block
 block discarded – undo
1151 1150
 	 * @param string &$displayname=null on return displayname of resource
1152 1151
 	 * @return string eg. "locations/123-some-room" or "resouces/345-some-device"
1153 1152
 	 */
1154
-	public static function resource2name($resource, &$is_location=null, &$displayname=null)
1153
+	public static function resource2name($resource, &$is_location = null, &$displayname = null)
1155 1154
 	{
1156 1155
 		if (!is_array($resource) && !($resource = self::read_resource($resource)))
1157 1156
 		{
@@ -1159,10 +1158,10 @@  discard block
 block discarded – undo
1159 1158
 		}
1160 1159
 		if (is_null($is_location)) $is_location = self::resource_is_location($resource);
1161 1160
 
1162
-		$displayname = translation::convert($resource['name'],	translation::charset(), 'utf-8');
1161
+		$displayname = translation::convert($resource['name'], translation::charset(), 'utf-8');
1163 1162
 
1164 1163
 		return ($is_location ? 'locations/' : 'resources/').$resource['res_id'].'-'.
1165
-			preg_replace('/[^a-z0-9]+/i','-', translation::to_ascii($resource['name']));
1164
+			preg_replace('/[^a-z0-9]+/i', '-', translation::to_ascii($resource['name']));
1166 1165
 	}
1167 1166
 
1168 1167
 	/**
@@ -1194,7 +1193,7 @@  discard block
 block discarded – undo
1194 1193
 	 */
1195 1194
 	public static function read_resource($res_id)
1196 1195
 	{
1197
-		static $cache;	// some per-request caching
1196
+		static $cache; // some per-request caching
1198 1197
 
1199 1198
 		if (isset(self::$all_resources) && isset(self::$all_resources[$res_id]))
1200 1199
 		{
@@ -1236,7 +1235,7 @@  discard block
 block discarded – undo
1236 1235
 	 * @param int $user=null account_if of user, or null for current user
1237 1236
 	 * @return array of array with values for res_id, cat_id and name (no other values1)
1238 1237
 	 */
1239
-	public static function get_resources($user=null)
1238
+	public static function get_resources($user = null)
1240 1239
 	{
1241 1240
 		if (!isset(self::$all_resources))
1242 1241
 		{
@@ -1244,17 +1243,17 @@  discard block
 block discarded – undo
1244 1243
 
1245 1244
 			self::$all_resources = array();
1246 1245
 			$query = array(
1247
-				'show_bookable' => true,	// ignore non-bookable resources
1246
+				'show_bookable' => true, // ignore non-bookable resources
1248 1247
 				'filter2' => -3,
1249 1248
 				'start' => 0,
1250
-				'num_rows' => 10000,	// return all aka first 10000 entries
1249
+				'num_rows' => 10000, // return all aka first 10000 entries
1251 1250
 			);
1252 1251
 			if (self::$resources->get_rows($query, $rows, $readonlys))
1253 1252
 			{
1254 1253
 				//_debug_array($rows);
1255
-				foreach($rows as $resource)
1254
+				foreach ($rows as $resource)
1256 1255
 				{
1257
-					self::$all_resources[$resource['res_id']] = array_intersect_key($resource, array('res_id'=>true,'cat_id'=>true,'name'=>true));
1256
+					self::$all_resources[$resource['res_id']] = array_intersect_key($resource, array('res_id'=>true, 'cat_id'=>true, 'name'=>true));
1258 1257
 				}
1259 1258
 			}
1260 1259
 		}
@@ -1303,19 +1302,19 @@  discard block
 block discarded – undo
1303 1302
 	 * @param string $principal_url=null include given principal url, relative to principal-collection-set, default $principal
1304 1303
 	 * @return array with values for keys 'path' and 'props'
1305 1304
 	 */
1306
-	protected function add_principal($principal, array $props = array(), $principal_url=null)
1305
+	protected function add_principal($principal, array $props = array(), $principal_url = null)
1307 1306
 	{
1308 1307
 		$props['resourcetype'][] = HTTP_WebDAV_Server::mkprop('principal', '');
1309 1308
 
1310 1309
 		// required props per WebDAV ACL
1311
-		foreach(array('alternate-URI-set', 'group-membership') as $name)
1310
+		foreach (array('alternate-URI-set', 'group-membership') as $name)
1312 1311
 		{
1313
-			if (!isset($props[$name])) $props[$name] = HTTP_WebDAV_Server::mkprop($name,'');
1312
+			if (!isset($props[$name])) $props[$name] = HTTP_WebDAV_Server::mkprop($name, '');
1314 1313
 		}
1315 1314
 		if (!$principal_url) $principal_url = $principal;
1316 1315
 
1317 1316
 		$props['principal-URL'] = array(
1318
-			HTTP_WebDAV_Server::mkprop('href',$this->base_uri.'/principals/'.$principal.'/'));
1317
+			HTTP_WebDAV_Server::mkprop('href', $this->base_uri.'/principals/'.$principal.'/'));
1319 1318
 
1320 1319
 		return $this->add_collection('/principals/'.$principal.'/', $props);
1321 1320
 	}
@@ -1331,20 +1330,20 @@  discard block
 block discarded – undo
1331 1330
 	 * @param array $resource=null resource to use (to not query it multiple times from the database)
1332 1331
 	 * @return array with values for 'path' and 'props'
1333 1332
 	 */
1334
-	protected function add_proxys($principal, $type, array $proxys=array(), array $resource=null)
1333
+	protected function add_proxys($principal, $type, array $proxys = array(), array $resource = null)
1335 1334
 	{
1336 1335
 		list($app,,$what) = explode('-', $type);
1337 1336
 
1338 1337
 		$proxys = array();
1339
-		list($account_type,$account) = explode('/', $principal);
1338
+		list($account_type, $account) = explode('/', $principal);
1340 1339
 
1341
-		switch($account_type)
1340
+		switch ($account_type)
1342 1341
 		{
1343 1342
 			case 'users':
1344 1343
 			case 'groups':
1345 1344
 				$account = $location = $this->accounts->name2id($account, 'account_lid', $account_type[0]);
1346 1345
 				$right = $what == 'write' ? EGW_ACL_EDIT : EGW_ACL_READ;
1347
-				$mask = $what == 'write' ? EGW_ACL_EDIT : EGW_ACL_EDIT|EGW_ACL_READ;	// do NOT report write+read in read
1346
+				$mask = $what == 'write' ? EGW_ACL_EDIT : EGW_ACL_EDIT|EGW_ACL_READ; // do NOT report write+read in read
1348 1347
 				break;
1349 1348
 
1350 1349
 			case 'locations':
@@ -1356,18 +1355,18 @@  discard block
 block discarded – undo
1356 1355
 				}
1357 1356
 				$location = 'L'.$resource['cat_id'];
1358 1357
 				$right = $what == 'write' ? EGW_ACL_DIRECT_BOOKING : EGW_ACL_CALREAD;
1359
-				$mask = $what == 'write' ? EGW_ACL_DIRECT_BOOKING : EGW_ACL_DIRECT_BOOKING|EGW_ACL_CALREAD;	// do NOT report write+read in read
1358
+				$mask = $what == 'write' ? EGW_ACL_DIRECT_BOOKING : EGW_ACL_DIRECT_BOOKING|EGW_ACL_CALREAD; // do NOT report write+read in read
1360 1359
 				break;
1361 1360
 		}
1362 1361
 		static $principal2grants = array();
1363
-		$grants =& $principal2grants[$principal];
1362
+		$grants = & $principal2grants[$principal];
1364 1363
 		if (!isset($grants))
1365 1364
 		{
1366
-			switch($app)
1365
+			switch ($app)
1367 1366
 			{
1368 1367
 				case 'resources':
1369 1368
 					$grants = $this->get_resource_rights();
1370
-					$grants = (array)$grants[$location];	// returns array($location => $grants)
1369
+					$grants = (array)$grants[$location]; // returns array($location => $grants)
1371 1370
 					break;
1372 1371
 
1373 1372
 				case 'calendar':
@@ -1377,9 +1376,9 @@  discard block
 block discarded – undo
1377 1376
 			}
1378 1377
 			//echo "<p>type=$type --> app=$app, what=$what --> right=$right, mask=$mask, account=$account, location=$location --> grants=".array2string($grants)."</p>\n";
1379 1378
 		}
1380
-		foreach($grants as $account_id => $rights)
1379
+		foreach ($grants as $account_id => $rights)
1381 1380
 		{
1382
-			if ($account_id !== 'run' && $account_id != $account && ($rights & $mask) == $right &&
1381
+			if ($account_id !== 'run' && $account_id != $account && ($rights&$mask) == $right &&
1383 1382
 				($account_lid = $this->accounts->id2name($account_id)))
1384 1383
 			{
1385 1384
 				// ignore "broken" grants (eg. negative account_id for a user), as they lead to further errors (no members)
@@ -1410,10 +1409,10 @@  discard block
 block discarded – undo
1410 1409
 	 * @param int $account who is the proxy
1411 1410
 	 * @return array with href props
1412 1411
 	 */
1413
-	protected function principal_set($prop, array $accounts=array(), $add_proxys=null, $account=null)
1412
+	protected function principal_set($prop, array $accounts = array(), $add_proxys = null, $account = null)
1414 1413
 	{
1415 1414
 		$set = array();
1416
-		foreach($accounts as $account_id => $account_lid)
1415
+		foreach ($accounts as $account_id => $account_lid)
1417 1416
 		{
1418 1417
 			if ($this->accounts->visible($account_lid))	// only add visible accounts, gives error in iCal otherwise
1419 1418
 			{
@@ -1422,11 +1421,11 @@  discard block
 block discarded – undo
1422 1421
 		}
1423 1422
 		if ($add_proxys)
1424 1423
 		{
1425
-			foreach((array)$add_proxys as $app)
1424
+			foreach ((array)$add_proxys as $app)
1426 1425
 			{
1427 1426
 				if (!isset($GLOBALS['egw_info']['user']['apps'][$app])) continue;
1428 1427
 
1429
-				switch($app)
1428
+				switch ($app)
1430 1429
 				{
1431 1430
 					case 'resources':
1432 1431
 						$proxy_groups = $this->get_resource_proxy_groups($account);
@@ -1458,11 +1457,11 @@  discard block
 block discarded – undo
1458 1457
 			// get location grants for $account (incl. his memberships)
1459 1458
 			$memberships = $GLOBALS['egw']->accounts->memberships($account, true);
1460 1459
 			$location_grants = array();
1461
-			foreach($all_location_grants as $location => $grants)
1460
+			foreach ($all_location_grants as $location => $grants)
1462 1461
 			{
1463
-				foreach($grants as $account_id => $rights)
1462
+				foreach ($grants as $account_id => $rights)
1464 1463
 				{
1465
-					if (($rights & (EGW_ACL_CALREAD|EGW_ACL_DIRECT_BOOKING)) &&	// we only care for these rights
1464
+					if (($rights&(EGW_ACL_CALREAD|EGW_ACL_DIRECT_BOOKING)) && // we only care for these rights
1466 1465
 						($account_id == $account || in_array($account_id, $memberships)))
1467 1466
 					{
1468 1467
 						if (!isset($location_grants[$location])) $location_grants[$location] = 0;
@@ -1471,13 +1470,13 @@  discard block
 block discarded – undo
1471 1470
 				}
1472 1471
 			}
1473 1472
 			// now add proxy-groups for all resources user has rights to
1474
-			foreach($resources as $resource)
1473
+			foreach ($resources as $resource)
1475 1474
 			{
1476 1475
 				$rights = $location_grants['L'.$resource['cat_id']];
1477 1476
 				if (isset($rights))
1478 1477
 				{
1479 1478
 					$set[] = HTTP_WebDAV_Server::mkprop('href', $this->base_uri.'/principals/'.$this->resource2name($resource).
1480
-						'/calendar-proxy-'.($rights & EGW_ACL_DIRECT_BOOKING ? 'write' : 'read').'/');
1479
+						'/calendar-proxy-'.($rights&EGW_ACL_DIRECT_BOOKING ? 'write' : 'read').'/');
1481 1480
 				}
1482 1481
 			}
1483 1482
 		}
@@ -1492,18 +1491,18 @@  discard block
 block discarded – undo
1492 1491
 	 * @param string|array $app_proxys=null applications for which proxys should be added
1493 1492
 	 * @return array with href props
1494 1493
 	 */
1495
-	protected function get_calendar_proxy_groups($account, $app='calendar')
1494
+	protected function get_calendar_proxy_groups($account, $app = 'calendar')
1496 1495
 	{
1497 1496
 		$set = array();
1498
-		foreach($this->acl->get_grants($app, $app != 'addressbook', $account) as $account_id => $rights)
1497
+		foreach ($this->acl->get_grants($app, $app != 'addressbook', $account) as $account_id => $rights)
1499 1498
 		{
1500
-			if ($account_id != $account && ($rights & EGW_ACL_READ) &&
1499
+			if ($account_id != $account && ($rights&EGW_ACL_READ) &&
1501 1500
 				($account_lid = $this->accounts->id2name($account_id)) &&
1502 1501
 				$this->accounts->visible($account_lid))	// only add visible accounts, gives error in iCal otherwise
1503 1502
 			{
1504 1503
 				$set[] = HTTP_WebDAV_Server::mkprop('href', $this->base_uri.'/principals/'.
1505 1504
 					($account_id < 0 ? 'groups/' : 'users/').
1506
-					$account_lid.'/'.$app.'-proxy-'.($rights & EGW_ACL_EDIT ? 'write' : 'read').'/');
1505
+					$account_lid.'/'.$app.'-proxy-'.($rights&EGW_ACL_EDIT ? 'write' : 'read').'/');
1507 1506
 			}
1508 1507
 		}
1509 1508
 		return $set;
@@ -1518,7 +1517,7 @@  discard block
 block discarded – undo
1518 1517
 	 * @param boolean $do_locations=false false: /principal/resources, true: /principals/locations
1519 1518
 	 * @return array|string array with files or HTTP error code
1520 1519
 	 */
1521
-	protected function propfind_resources($name,$rest,array $options,$do_locations=false)
1520
+	protected function propfind_resources($name, $rest, array $options, $do_locations = false)
1522 1521
 	{
1523 1522
 		if (!isset($GLOBALS['egw_info']['user']['apps']['resources']))
1524 1523
 		{
@@ -1540,7 +1539,7 @@  discard block
 block discarded – undo
1540 1539
 				if (($resources = $this->get_resources()))
1541 1540
 				{
1542 1541
 					//_debug_array($resources);
1543
-					foreach($resources as $resource)
1542
+					foreach ($resources as $resource)
1544 1543
 					{
1545 1544
 						if (($is_location = self::resource_is_location($resource)) == $do_locations)
1546 1545
 						{
@@ -1557,8 +1556,8 @@  discard block
 block discarded – undo
1557 1556
 				return '404 Not Found';
1558 1557
 			}
1559 1558
 			$path = ($is_location ? 'locations/' : 'resources/').$name;
1560
-			while (substr($rest,-1) == '/') $rest = substr($rest,0,-1);
1561
-			switch((string)$rest)
1559
+			while (substr($rest, -1) == '/') $rest = substr($rest, 0, -1);
1560
+			switch ((string)$rest)
1562 1561
 			{
1563 1562
 				case '':
1564 1563
 					$files[] = $this->add_principal_resource($resource);
@@ -1597,12 +1596,12 @@  discard block
 block discarded – undo
1597 1596
 		if ($options['depth'])
1598 1597
 		{
1599 1598
 			if (is_numeric($options['depth'])) --$options['depth'];
1600
-			$files = array_merge($files,$this->propfind_users('','',$options));
1601
-			$files = array_merge($files,$this->propfind_groups('','',$options));
1599
+			$files = array_merge($files, $this->propfind_users('', '', $options));
1600
+			$files = array_merge($files, $this->propfind_groups('', '', $options));
1602 1601
 			if ($GLOBALS['egw_info']['user']['apps']['resources'])
1603 1602
 			{
1604
-				$files = array_merge($files,$this->propfind_resources('','',$options,false));	// resources
1605
-				$files = array_merge($files,$this->propfind_resources('','',$options,true));	// locations
1603
+				$files = array_merge($files, $this->propfind_resources('', '', $options, false)); // resources
1604
+				$files = array_merge($files, $this->propfind_resources('', '', $options, true)); // locations
1606 1605
 			}
1607 1606
 			//$files = array_merge($files,$this->propfind_uids('','',$options));
1608 1607
 		}
@@ -1617,7 +1616,7 @@  discard block
 block discarded – undo
1617 1616
 	 * @param int $user=null account_id
1618 1617
 	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
1619 1618
 	 */
1620
-	function get(&$options,$id,$user=null)
1619
+	function get(&$options, $id, $user = null)
1621 1620
 	{
1622 1621
 		return false;
1623 1622
 	}
@@ -1630,7 +1629,7 @@  discard block
 block discarded – undo
1630 1629
 	 * @param int $user=null account_id of owner, default null
1631 1630
 	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
1632 1631
 	 */
1633
-	function put(&$options,$id,$user=null)
1632
+	function put(&$options, $id, $user = null)
1634 1633
 	{
1635 1634
 		return false;
1636 1635
 	}
@@ -1642,7 +1641,7 @@  discard block
 block discarded – undo
1642 1641
 	 * @param int $id
1643 1642
 	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
1644 1643
 	 */
1645
-	function delete(&$options,$id)
1644
+	function delete(&$options, $id)
1646 1645
 	{
1647 1646
 		return false;
1648 1647
 	}
@@ -1665,13 +1664,13 @@  discard block
 block discarded – undo
1665 1664
 	 * @param array/int $entry entry-array or id
1666 1665
 	 * @return boolean null if entry does not exist, false if no access, true if access permitted
1667 1666
 	 */
1668
-	function check_access($acl,$entry)
1667
+	function check_access($acl, $entry)
1669 1668
 	{
1670 1669
 		if ($acl != EGW_ACL_READ)
1671 1670
 		{
1672 1671
 			return false;
1673 1672
 		}
1674
-		if (!is_array($entry) && !$this->accounts->name2id($entry,'account_lid','u'))
1673
+		if (!is_array($entry) && !$this->accounts->name2id($entry, 'account_lid', 'u'))
1675 1674
 		{
1676 1675
 			return null;
1677 1676
 		}
@@ -1708,7 +1707,7 @@  discard block
 block discarded – undo
1708 1707
 	 * @param int $user=null owner of the collection, default current user
1709 1708
 	 * @return array with privileges
1710 1709
 	 */
1711
-	public function current_user_privileges($path, $user=null)
1710
+	public function current_user_privileges($path, $user = null)
1712 1711
 	{
1713 1712
 		return array('read', 'read-current-user-privilege-set');
1714 1713
 	}
Please login to merge, or discard this patch.
Braces   +123 added lines, -31 removed lines patch added patch discarded remove patch
@@ -41,7 +41,10 @@  discard block
 block discarded – undo
41 41
 	{
42 42
 		parent::__construct($app, $groupdav);
43 43
 
44
-		if (!isset(self::$resources)) self::$resources = new resources_bo();
44
+		if (!isset(self::$resources))
45
+		{
46
+			self::$resources = new resources_bo();
47
+		}
45 48
 	}
46 49
 
47 50
 	/**
@@ -83,7 +86,10 @@  discard block
 block discarded – undo
83 86
 	 */
84 87
 	protected function supported_report_set($path, array $reports=null)
85 88
 	{
86
-		if (is_null($reports)) $reports = $this->supported_reports;
89
+		if (is_null($reports))
90
+		{
91
+			$reports = $this->supported_reports;
92
+		}
87 93
 
88 94
 		$supported = array();
89 95
 		foreach($reports as $name => $data)
@@ -254,7 +260,10 @@  discard block
 block discarded – undo
254 260
 		$requested_props = $options['other'];
255 261
 		while(($requested_prop = array_shift($requested_props)))
256 262
 		{
257
-			if ($requested_prop['name'] != 'property' || $requested_prop['depth'] != 1) continue;
263
+			if ($requested_prop['name'] != 'property' || $requested_prop['depth'] != 1)
264
+			{
265
+				continue;
266
+			}
258 267
 
259 268
 			$prop_ns = $requested_prop['attrs']['namespace'];
260 269
 			$prop_name = $requested_prop['attrs']['name'];
@@ -293,7 +302,10 @@  discard block
 block discarded – undo
293 302
 			// find prop to expand
294 303
 			foreach($prop_files['files'][0]['props'] as $name => $expand_prop)
295 304
 			{
296
-				if ($expand_prop['name'] === $prop_name) break;
305
+				if ($expand_prop['name'] === $prop_name)
306
+				{
307
+					break;
308
+				}
297 309
 			}
298 310
 			if ($expand_prop['name'] !== $prop_name || !is_array($expand_prop['val']) ||
299 311
 				$expand_prop['val'] && $expand_prop['val'][0]['name'] !== 'href')
@@ -309,10 +321,13 @@  discard block
 block discarded – undo
309 321
 			{
310 322
 				if ($prop['name'] == 'property' && $prop['depth'] == 2)
311 323
 				{
312
-					if (!is_array($options2['props']))	// is "all" initially
324
+					if (!is_array($options2['props']))
325
+					{
326
+						// is "all" initially
313 327
 					{
314 328
 						$options2['props'] = array();
315 329
 					}
330
+					}
316 331
 					$options2['props'][] = array(
317 332
 						'name' => $prop['attrs']['name'],
318 333
 						'xmlns' => isset($prop['attrs']['namespace']) ? $prop['attrs']['namespace'] : $prop['xmlns'],
@@ -320,7 +335,10 @@  discard block
 block discarded – undo
320 335
 				}
321 336
 			}
322 337
 			// put back evtl. read top-level property
323
-			if ($prop && $prop['depth'] == 1) array_unshift($requested_props, $prop);
338
+			if ($prop && $prop['depth'] == 1)
339
+			{
340
+				array_unshift($requested_props, $prop);
341
+			}
324 342
 			$this->groupdav->options = $options2;	// also modify global variable
325 343
 
326 344
 			// run regular profind to get requested 2.-level properties for each href
@@ -516,9 +534,12 @@  discard block
 block discarded – undo
516 534
 		// now filter out not matching "files"
517 535
 		foreach($files['files'] as $n => $resource)
518 536
 		{
519
-			if (count(explode('/', $resource['path'])) < 5)	// hack to only return principals, not the collections itself
537
+			if (count(explode('/', $resource['path'])) < 5)
538
+			{
539
+				// hack to only return principals, not the collections itself
520 540
 			{
521 541
 				unset($files['files'][$n]);
542
+			}
522 543
 				continue;
523 544
 			}
524 545
 			// match with $search_props
@@ -526,15 +547,25 @@  discard block
 block discarded – undo
526 547
 			foreach($search_props as $search_prop)
527 548
 			{
528 549
 				// search resource for $search_prop
529
-				foreach($resource['props'] as $prop) if ($prop['name'] === $search_prop['name']) break;
530
-				if ($prop['name'] === $search_prop['name'])	// search_prop NOT found
550
+				foreach($resource['props'] as $prop)
551
+				{
552
+					if ($prop['name'] === $search_prop['name']) break;
553
+				}
554
+				if ($prop['name'] === $search_prop['name'])
555
+				{
556
+					// search_prop NOT found
531 557
 				{
532 558
 					foreach((array)$prop['val'] as $value)
533 559
 					{
534
-						if (is_array($value)) $value = $value['val'];	// eg. href prop
535
-						if (self::match($value, $search_prop['match'], $search_prop['match-type']) !== false)	// prop does match
560
+						if (is_array($value)) $value = $value['val'];
561
+				}
562
+				// eg. href prop
563
+						if (self::match($value, $search_prop['match'], $search_prop['match-type']) !== false)
564
+						{
565
+							// prop does match
536 566
 						{
537 567
 							++$matches;
568
+						}
538 569
 							//error_log("$matches: $resource[path]: $search_prop[name]=".array2string($prop['name'] !== $search_prop['name'] ? null : $prop['val'])." does match '$search_prop[match]'");
539 570
 							break;
540 571
 						}
@@ -734,7 +765,10 @@  discard block
 block discarded – undo
734 765
 		{
735 766
 			foreach($resource['props']['resourcetype']['val'] as $prop)
736 767
 			{
737
-				if ($prop['name'] == 'principal') continue 2;
768
+				if ($prop['name'] == 'principal')
769
+				{
770
+					continue 2;
771
+				}
738 772
 			}
739 773
 			unset($files['files'][$n]);	// not a principal --> do not return
740 774
 		}
@@ -787,7 +821,10 @@  discard block
 block discarded – undo
787 821
 				$this->groupdav->log(__METHOD__."('$name', ...) account '$name' NOT found OR not visible to you (check account-selection preference)!");
788 822
 				return '404 Not Found';
789 823
 			}
790
-			while (substr($rest,-1) == '/') $rest = substr($rest,0,-1);
824
+			while (substr($rest,-1) == '/')
825
+			{
826
+				$rest = substr($rest,0,-1);
827
+			}
791 828
 			switch((string)$rest)
792 829
 			{
793 830
 				case '':
@@ -850,7 +887,10 @@  discard block
 block discarded – undo
850 887
 			{
851 888
 				return '404 Not Found';
852 889
 			}
853
-			while (substr($rest,-1) == '/') $rest = substr($rest,0,-1);
890
+			while (substr($rest,-1) == '/')
891
+			{
892
+				$rest = substr($rest,0,-1);
893
+			}
854 894
 			switch((string)$rest)
855 895
 			{
856 896
 				case '':
@@ -882,7 +922,11 @@  discard block
 block discarded – undo
882 922
 	{
883 923
 		$addressbooks = array();
884 924
 		$addressbook_home_set = $GLOBALS['egw_info']['user']['preferences']['groupdav']['addressbook-home-set'];
885
-		if (empty($addressbook_home_set)) $addressbook_home_set = 'P';	// personal addressbook
925
+		if (empty($addressbook_home_set))
926
+		{
927
+			$addressbook_home_set = 'P';
928
+		}
929
+		// personal addressbook
886 930
 		$addressbook_home_set = explode(',',$addressbook_home_set);
887 931
 		// replace symbolic id's with real nummeric id's
888 932
 		foreach(array(
@@ -896,10 +940,13 @@  discard block
 block discarded – undo
896 940
 				$addressbook_home_set[$key] = $id;
897 941
 			}
898 942
 		}
899
-		if (in_array('O',$addressbook_home_set))	// "all in one" from groupdav.php/addressbook/
943
+		if (in_array('O',$addressbook_home_set))
944
+		{
945
+			// "all in one" from groupdav.php/addressbook/
900 946
 		{
901 947
 			$addressbooks[] = '/';
902 948
 		}
949
+		}
903 950
 		foreach(ExecMethod('addressbook.addressbook_bo.get_addressbooks',EGW_ACL_READ) as $id => $label)
904 951
 		{
905 952
 			if ((in_array('A',$addressbook_home_set) || in_array((string)$id,$addressbook_home_set)) &&
@@ -978,7 +1025,10 @@  discard block
 block discarded – undo
978 1025
 	 */
979 1026
 	static public function url2uid($url, $only_type=null, $cn=null)
980 1027
 	{
981
-		if (!$only_type) $only_type = array('users', 'groups', 'resources', 'locations', 'mailto');
1028
+		if (!$only_type)
1029
+		{
1030
+			$only_type = array('users', 'groups', 'resources', 'locations', 'mailto');
1031
+		}
982 1032
 
983 1033
 		if ($url[0] == '/')
984 1034
 		{
@@ -988,7 +1038,10 @@  discard block
 block discarded – undo
988 1038
 		{
989 1039
 			list($schema, $rest) = explode(':', $url, 2);
990 1040
 		}
991
-		if (empty($rest)) return false;
1041
+		if (empty($rest))
1042
+		{
1043
+			return false;
1044
+		}
992 1045
 
993 1046
 		switch(strtolower($schema))
994 1047
 		{
@@ -1035,9 +1088,12 @@  discard block
 block discarded – undo
1035 1088
 			case 'urn':
1036 1089
 				list($urn_type, $uid) = explode(':', $rest, 2);
1037 1090
 				list($type, $id, $install_id) = explode('-', $uid);
1038
-				if ($type == 'accounts' && empty($id))	// groups have a negative id, eg. "urn:uuid:accounts--1-..."
1091
+				if ($type == 'accounts' && empty($id))
1092
+				{
1093
+					// groups have a negative id, eg. "urn:uuid:accounts--1-..."
1039 1094
 				{
1040 1095
 					list($type, $nul, $id, $install_id) = explode('-', $uid);
1096
+				}
1041 1097
 					$id = -$id;
1042 1098
 				}
1043 1099
 				// own urn
@@ -1051,7 +1107,10 @@  discard block
 block discarded – undo
1051 1107
 					else
1052 1108
 					{
1053 1109
 						static $calendar_bo;
1054
-						if (is_null($calendar_bo)) $calendar_bo = new calendar_bo();
1110
+						if (is_null($calendar_bo))
1111
+						{
1112
+							$calendar_bo = new calendar_bo();
1113
+						}
1055 1114
 						foreach($calendar_bo->resources as $letter => $info)
1056 1115
 						{
1057 1116
 							if ($info['app'] == $type || $info['app'] == 'resources' && $type == 'location')
@@ -1157,7 +1216,10 @@  discard block
 block discarded – undo
1157 1216
 		{
1158 1217
 			return null;
1159 1218
 		}
1160
-		if (is_null($is_location)) $is_location = self::resource_is_location($resource);
1219
+		if (is_null($is_location))
1220
+		{
1221
+			$is_location = self::resource_is_location($resource);
1222
+		}
1161 1223
 
1162 1224
 		$displayname = translation::convert($resource['name'],	translation::charset(), 'utf-8');
1163 1225
 
@@ -1203,7 +1265,10 @@  discard block
 block discarded – undo
1203 1265
 
1204 1266
 		if (!isset($cache[$res_id]))
1205 1267
 		{
1206
-			if (!isset(self::$resources)) self::$resources = new resources_bo();
1268
+			if (!isset(self::$resources))
1269
+			{
1270
+				self::$resources = new resources_bo();
1271
+			}
1207 1272
 
1208 1273
 			if (!($cache[$res_id] = self::$resources->read($res_id)))
1209 1274
 			{
@@ -1240,7 +1305,10 @@  discard block
 block discarded – undo
1240 1305
 	{
1241 1306
 		if (!isset(self::$all_resources))
1242 1307
 		{
1243
-			if (!isset(self::$resources)) self::$resources = new resources_bo($user);
1308
+			if (!isset(self::$resources))
1309
+			{
1310
+				self::$resources = new resources_bo($user);
1311
+			}
1244 1312
 
1245 1313
 			self::$all_resources = array();
1246 1314
 			$query = array(
@@ -1310,9 +1378,15 @@  discard block
 block discarded – undo
1310 1378
 		// required props per WebDAV ACL
1311 1379
 		foreach(array('alternate-URI-set', 'group-membership') as $name)
1312 1380
 		{
1313
-			if (!isset($props[$name])) $props[$name] = HTTP_WebDAV_Server::mkprop($name,'');
1381
+			if (!isset($props[$name]))
1382
+			{
1383
+				$props[$name] = HTTP_WebDAV_Server::mkprop($name,'');
1384
+			}
1385
+		}
1386
+		if (!$principal_url)
1387
+		{
1388
+			$principal_url = $principal;
1314 1389
 		}
1315
-		if (!$principal_url) $principal_url = $principal;
1316 1390
 
1317 1391
 		$props['principal-URL'] = array(
1318 1392
 			HTTP_WebDAV_Server::mkprop('href',$this->base_uri.'/principals/'.$principal.'/'));
@@ -1415,16 +1489,22 @@  discard block
 block discarded – undo
1415 1489
 		$set = array();
1416 1490
 		foreach($accounts as $account_id => $account_lid)
1417 1491
 		{
1418
-			if ($this->accounts->visible($account_lid))	// only add visible accounts, gives error in iCal otherwise
1492
+			if ($this->accounts->visible($account_lid))
1493
+			{
1494
+				// only add visible accounts, gives error in iCal otherwise
1419 1495
 			{
1420 1496
 				$set[] = HTTP_WebDAV_Server::mkprop('href', $this->base_uri.'/principals/'.($account_id < 0 ? 'groups/' : 'users/').$account_lid.'/');
1421 1497
 			}
1498
+			}
1422 1499
 		}
1423 1500
 		if ($add_proxys)
1424 1501
 		{
1425 1502
 			foreach((array)$add_proxys as $app)
1426 1503
 			{
1427
-				if (!isset($GLOBALS['egw_info']['user']['apps'][$app])) continue;
1504
+				if (!isset($GLOBALS['egw_info']['user']['apps'][$app]))
1505
+				{
1506
+					continue;
1507
+				}
1428 1508
 
1429 1509
 				switch($app)
1430 1510
 				{
@@ -1465,7 +1545,10 @@  discard block
 block discarded – undo
1465 1545
 					if (($rights & (EGW_ACL_CALREAD|EGW_ACL_DIRECT_BOOKING)) &&	// we only care for these rights
1466 1546
 						($account_id == $account || in_array($account_id, $memberships)))
1467 1547
 					{
1468
-						if (!isset($location_grants[$location])) $location_grants[$location] = 0;
1548
+						if (!isset($location_grants[$location]))
1549
+						{
1550
+							$location_grants[$location] = 0;
1551
+						}
1469 1552
 						$location_grants[$location] |= $rights;
1470 1553
 					}
1471 1554
 				}
@@ -1499,12 +1582,15 @@  discard block
 block discarded – undo
1499 1582
 		{
1500 1583
 			if ($account_id != $account && ($rights & EGW_ACL_READ) &&
1501 1584
 				($account_lid = $this->accounts->id2name($account_id)) &&
1502
-				$this->accounts->visible($account_lid))	// only add visible accounts, gives error in iCal otherwise
1585
+				$this->accounts->visible($account_lid))
1586
+			{
1587
+				// only add visible accounts, gives error in iCal otherwise
1503 1588
 			{
1504 1589
 				$set[] = HTTP_WebDAV_Server::mkprop('href', $this->base_uri.'/principals/'.
1505 1590
 					($account_id < 0 ? 'groups/' : 'users/').
1506 1591
 					$account_lid.'/'.$app.'-proxy-'.($rights & EGW_ACL_EDIT ? 'write' : 'read').'/');
1507 1592
 			}
1593
+			}
1508 1594
 		}
1509 1595
 		return $set;
1510 1596
 	}
@@ -1557,7 +1643,10 @@  discard block
 block discarded – undo
1557 1643
 				return '404 Not Found';
1558 1644
 			}
1559 1645
 			$path = ($is_location ? 'locations/' : 'resources/').$name;
1560
-			while (substr($rest,-1) == '/') $rest = substr($rest,0,-1);
1646
+			while (substr($rest,-1) == '/')
1647
+			{
1648
+				$rest = substr($rest,0,-1);
1649
+			}
1561 1650
 			switch((string)$rest)
1562 1651
 			{
1563 1652
 				case '':
@@ -1596,7 +1685,10 @@  discard block
 block discarded – undo
1596 1685
 
1597 1686
 		if ($options['depth'])
1598 1687
 		{
1599
-			if (is_numeric($options['depth'])) --$options['depth'];
1688
+			if (is_numeric($options['depth']))
1689
+			{
1690
+				--$options['depth'];
1691
+			}
1600 1692
 			$files = array_merge($files,$this->propfind_users('','',$options));
1601 1693
 			$files = array_merge($files,$this->propfind_groups('','',$options));
1602 1694
 			if ($GLOBALS['egw_info']['user']['apps']['resources'])
Please login to merge, or discard this patch.
phpgwapi/inc/class.historylog.inc.php 3 patches
Doc Comments   +2 added lines patch added patch discarded remove patch
@@ -112,6 +112,8 @@
 block discarded – undo
112 112
 
113 113
 	/**
114 114
 	 * Static function to add a history record
115
+	 * @param string $field_code
116
+	 * @param string $new_value
115 117
 	 */
116 118
 	public static function static_add($appname, $id, $user, $field_code, $new_value, $old_value = '')
117 119
 	{
Please login to merge, or discard this patch.
Spacing   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 	 * @param string $appname app name this instance operates on
58 58
 	 * @return historylog
59 59
 	 */
60
-	function historylog($appname='',$user=null)
60
+	function historylog($appname = '', $user = null)
61 61
 	{
62 62
 		$this->appname = $appname ? $appname : $GLOBALS['egw_info']['flags']['currentapp'];
63 63
 		$this->user = !is_null($user) ? $user : $GLOBALS['egw_info']['user']['account_id'];
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 		{
88 88
 			$where['history_record_id'] = $record_id;
89 89
 		}
90
-		$this->db->delete(self::TABLE,$where,__LINE__,__FILE__);
90
+		$this->db->delete(self::TABLE, $where, __LINE__, __FILE__);
91 91
 
92 92
 		return $this->db->affected_rows();
93 93
 	}
@@ -100,11 +100,11 @@  discard block
 block discarded – undo
100 100
 	 * @param string $new_value new value
101 101
 	 * @param string $old_value old value
102 102
 	 */
103
-	function add($status,$record_id,$new_value,$old_value)
103
+	function add($status, $record_id, $new_value, $old_value)
104 104
 	{
105 105
 		if ($new_value != $old_value)
106 106
 		{
107
-			$this->db->insert(self::TABLE,array(
107
+			$this->db->insert(self::TABLE, array(
108 108
 				'history_record_id' => $record_id,
109 109
 				'history_appname'   => $this->appname,
110 110
 				'history_owner'     => $this->user,
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 				'history_old_value' => $old_value,
114 114
 				'history_timestamp' => time(),
115 115
 				'sessionid' => $GLOBALS['egw']->session->sessionid_access_log,
116
-			),false,__LINE__,__FILE__);
116
+			), false, __LINE__, __FILE__);
117 117
 		}
118 118
 	}
119 119
 
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 	{
125 125
 		if ($new_value != $old_value)
126 126
 		{
127
-			$GLOBALS['egw']->db->insert(self::TABLE,array(
127
+			$GLOBALS['egw']->db->insert(self::TABLE, array(
128 128
 				'history_record_id' => $id,
129 129
 				'history_appname'   => $appname,
130 130
 				'history_owner'     => (int)$user,
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 				'history_old_value' => $old_value,
134 134
 				'history_timestamp' => time(),
135 135
 				'sessionid' => $GLOBALS['egw']->session->sessionid_access_log,
136
-			),false,__LINE__,__FILE__);
136
+			), false, __LINE__, __FILE__);
137 137
 		}
138 138
 	}
139 139
 
@@ -147,11 +147,11 @@  discard block
 block discarded – undo
147 147
 	 * @return array of arrays with keys id, record_id, appname, owner (account_id), status, new_value, old_value,
148 148
 	 * 	timestamp (Y-m-d H:i:s in servertime), user_ts (timestamp in user-time)
149 149
 	 */
150
-	function search($filter,$order='history_id',$sort='DESC',$limit=null)
150
+	function search($filter, $order = 'history_id', $sort = 'DESC', $limit = null)
151 151
 	{
152 152
 		if (!is_array($filter)) $filter = is_numeric($filter) ? array('history_record_id' => $filter) : array();
153 153
 
154
-		if (!$order || !preg_match('/^[a-z0-9_]+$/i',$order) || !preg_match('/^(asc|desc)?$/i',$sort))
154
+		if (!$order || !preg_match('/^[a-z0-9_]+$/i', $order) || !preg_match('/^(asc|desc)?$/i', $sort))
155 155
 		{
156 156
 			$orderby = 'ORDER BY history_id DESC';
157 157
 		}
@@ -159,9 +159,9 @@  discard block
 block discarded – undo
159 159
 		{
160 160
 			$orderby = "ORDER BY $order $sort";
161 161
 		}
162
-		foreach($filter as $col => $value)
162
+		foreach ($filter as $col => $value)
163 163
 		{
164
-			if (!is_numeric($col) && substr($col,0,8) != 'history_')
164
+			if (!is_numeric($col) && substr($col, 0, 8) != 'history_')
165 165
 			{
166 166
 				$filter['history_'.$col] = $value;
167 167
 				unset($filter[$col]);
@@ -173,11 +173,11 @@  discard block
 block discarded – undo
173 173
 		if (!$filter['history_record_id']) return array();
174 174
 
175 175
 		$rows = array();
176
-		foreach($this->db->select(self::TABLE, '*', $filter, __LINE__, __FILE__,
176
+		foreach ($this->db->select(self::TABLE, '*', $filter, __LINE__, __FILE__,
177 177
 			isset($limit) ? 0 : false, $orderby, 'phpgwapi', $limit) as $row)
178 178
 		{
179 179
 			$row['user_ts'] = $this->db->from_timestamp($row['history_timestamp']) + 3600 * $GLOBALS['egw_info']['user']['preferences']['common']['tz_offset'];
180
-			$rows[] = egw_db::strip_array_keys($row,'history_');
180
+			$rows[] = egw_db::strip_array_keys($row, 'history_');
181 181
 		}
182 182
 		return $rows;
183 183
 	}
@@ -192,8 +192,8 @@  discard block
 block discarded – undo
192 192
 		$rows = array();
193 193
 		$filter['history_appname'] = $query['appname'];
194 194
 		$filter['history_record_id'] = $query['record_id'];
195
-		if(is_array($query['colfilter'])) {
196
-			foreach($query['colfilter'] as $column => $value) {
195
+		if (is_array($query['colfilter'])) {
196
+			foreach ($query['colfilter'] as $column => $value) {
197 197
 				$filter[$column] = $value;
198 198
 			}
199 199
 		}
@@ -203,20 +203,20 @@  discard block
 block discarded – undo
203 203
 		}
204 204
 		else
205 205
 		{
206
-			$total = $GLOBALS['egw']->db->select(self::TABLE,'COUNT(*)',$filter,__LINE__,__FILE__,false,'','phpgwapi',0)->fetchColumn();
206
+			$total = $GLOBALS['egw']->db->select(self::TABLE, 'COUNT(*)', $filter, __LINE__, __FILE__, false, '', 'phpgwapi', 0)->fetchColumn();
207 207
 		}
208 208
 		// filter out private (or no longer defined) custom fields
209 209
 		if ($filter['history_appname'])
210 210
 		{
211 211
 			$to_or[] = "history_status NOT LIKE '#%'";
212 212
 			// explicitly allow "##" used to store iCal/vCard X-attributes
213
-			if (in_array($filter['history_appname'], array('calendar','infolog','addressbook')))
213
+			if (in_array($filter['history_appname'], array('calendar', 'infolog', 'addressbook')))
214 214
 			{
215 215
 				$to_or[] = "history_status LIKE '##%'";
216 216
 			}
217 217
 			if (($cfs = egw_customfields::get($filter['history_appname'])))
218 218
 			{
219
-				$to_or[] =  'history_status IN ('.implode(',', array_map(function($str)
219
+				$to_or[] = 'history_status IN ('.implode(',', array_map(function($str)
220 220
 				{
221 221
 					return $GLOBALS['egw']->db->quote('#'.$str);
222 222
 				}, array_keys($cfs))).')';
@@ -225,40 +225,40 @@  discard block
 block discarded – undo
225 225
 		}
226 226
 		$_query = array(array(
227 227
 			'table' => self::TABLE,
228
-			'cols' => array('history_id', 'history_record_id','history_appname','history_owner','history_status','history_new_value', 'history_timestamp','history_old_value'),
228
+			'cols' => array('history_id', 'history_record_id', 'history_appname', 'history_owner', 'history_status', 'history_new_value', 'history_timestamp', 'history_old_value'),
229 229
 			'where' => $filter,
230 230
 		));
231 231
 
232 232
 		// Add in files, if possible
233
-		if($GLOBALS['egw_info']['user']['apps']['filemanager'] &&
234
-			$file = sqlfs_stream_wrapper::url_stat("/apps/{$query['appname']}/{$query['record_id']}",STREAM_URL_STAT_LINK))
233
+		if ($GLOBALS['egw_info']['user']['apps']['filemanager'] &&
234
+			$file = sqlfs_stream_wrapper::url_stat("/apps/{$query['appname']}/{$query['record_id']}", STREAM_URL_STAT_LINK))
235 235
 		{
236 236
 			$_query[] = array(
237 237
 				'table' => sqlfs_stream_wrapper::TABLE,
238
-				'cols' =>array('fs_id', 'fs_dir', "'filemanager'",'COALESCE(fs_modifier,fs_creator)',"'~file~'",'fs_name','fs_modified', 'fs_mime'),
238
+				'cols' =>array('fs_id', 'fs_dir', "'filemanager'", 'COALESCE(fs_modifier,fs_creator)', "'~file~'", 'fs_name', 'fs_modified', 'fs_mime'),
239 239
 				'where' => array('fs_dir' => $file['ino'])
240 240
 			);
241 241
 		}
242 242
 		$new_file_id = array();
243
-		foreach($GLOBALS['egw']->db->union(
243
+		foreach ($GLOBALS['egw']->db->union(
244 244
 			$_query,
245 245
 			__LINE__, __FILE__,
246
-			' ORDER BY ' . ($query['order'] ? $query['order'] : 'history_timestamp') . ' ' . ($query['sort'] ? $query['sort'] : 'DESC'),
246
+			' ORDER BY '.($query['order'] ? $query['order'] : 'history_timestamp').' '.($query['sort'] ? $query['sort'] : 'DESC'),
247 247
 			$query['start'],
248 248
 			$query['num_rows']
249 249
 		) as $row) {
250 250
 			$row['user_ts'] = $GLOBALS['egw']->db->from_timestamp($row['history_timestamp']) + 3600 * $GLOBALS['egw_info']['user']['preferences']['common']['tz_offset'];
251 251
 
252 252
 			// Explode multi-part values
253
-			foreach(array('history_new_value','history_old_value') as $field)
253
+			foreach (array('history_new_value', 'history_old_value') as $field)
254 254
 			{
255
-				if(strpos($row[$field],bo_tracking::ONE2N_SEPERATOR) !== false)
255
+				if (strpos($row[$field], bo_tracking::ONE2N_SEPERATOR) !== false)
256 256
 				{
257
-					$row[$field] = explode(bo_tracking::ONE2N_SEPERATOR,$row[$field]);
257
+					$row[$field] = explode(bo_tracking::ONE2N_SEPERATOR, $row[$field]);
258 258
 				}
259 259
 			}
260 260
 			// Get information needed for proper display
261
-			if($row['history_appname'] == 'filemanager')
261
+			if ($row['history_appname'] == 'filemanager')
262 262
 			{
263 263
 				$new_version = $new_file_id[$row['history_new_value']];
264 264
 				$new_file_id[$row['history_new_value']] = count($rows);
@@ -274,12 +274,12 @@  discard block
 block discarded – undo
274 274
 					'mime' => $row['history_old_value']
275 275
 				);
276 276
 				$row['history_old_value'] = '';
277
-				if($new_version !== null)
277
+				if ($new_version !== null)
278 278
 				{
279 279
 					$rows[$new_version]['old_value'] = $row['history_new_value'];
280 280
 				}
281 281
 			}
282
-			$rows[] = egw_db::strip_array_keys($row,'history_');
282
+			$rows[] = egw_db::strip_array_keys($row, 'history_');
283 283
 		}
284 284
 		if ($mysql_calc_rows)
285 285
 		{
@@ -300,13 +300,13 @@  discard block
 block discarded – undo
300 300
 	 * @param int $record_id id of the record in $this->appname (set by the constructor)
301 301
 	 * @return array of arrays with keys id, record_id, owner (account_lid!), status, new_value, old_value, datetime (timestamp in servertime)
302 302
 	 */
303
-	function return_array($filter_out,$only_show,$_orderby,$sort, $record_id)
303
+	function return_array($filter_out, $only_show, $_orderby, $sort, $record_id)
304 304
 	{
305 305
 		if (!is_numeric($record_id))
306 306
 		{
307 307
 			return array();
308 308
 		}
309
-		if (!$_orderby || !preg_match('/^[a-z0-9_]+$/i',$_orderby) || !preg_match('/^(asc|desc)?$/i',$sort))
309
+		if (!$_orderby || !preg_match('/^[a-z0-9_]+$/i', $_orderby) || !preg_match('/^(asc|desc)?$/i', $sort))
310 310
 		{
311 311
 			$orderby = 'ORDER BY history_timestamp,history_id';
312 312
 		}
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
 		);
322 322
 		if (is_array($filter_out))
323 323
 		{
324
-			foreach($filter_out as $_filter)
324
+			foreach ($filter_out as $_filter)
325 325
 			{
326 326
 				$where[] = 'history_status != '.$this->db->quote($_filter);
327 327
 			}
@@ -329,20 +329,20 @@  discard block
 block discarded – undo
329 329
 		if (is_array($only_show) && count($only_show))
330 330
 		{
331 331
 			$to_or = array();
332
-			foreach($only_show as $_filter)
332
+			foreach ($only_show as $_filter)
333 333
 			{
334 334
 				$to_or[] = 'history_status = '.$this->db->quote($_filter);
335 335
 			}
336
-			$where[] = '('.implode(' OR ',$to_or).')';
336
+			$where[] = '('.implode(' OR ', $to_or).')';
337 337
 		}
338 338
 
339
-		foreach($this->db->select(self::TABLE,'*',$where,__LINE__,__FILE__,false,$orderby) as $row)
339
+		foreach ($this->db->select(self::TABLE, '*', $where, __LINE__, __FILE__, false, $orderby) as $row)
340 340
 		{
341 341
 			$return_values[] = array(
342 342
 				'id'         => $row['history_id'],
343 343
 				'record_id'  => $row['history_record_id'],
344 344
 				'owner'      => $row['history_owner'] ? $GLOBALS['egw']->accounts->id2name($row['history_owner']) : lang('eGroupWare'),
345
-				'status'     => str_replace(' ','',$row['history_status']),
345
+				'status'     => str_replace(' ', '', $row['history_status']),
346 346
 				'new_value'  => $row['history_new_value'],
347 347
 				'old_value'  => $row['history_old_value'],
348 348
 				'datetime'   => $this->db->from_timestamp($row['history_timestamp']),
@@ -361,45 +361,45 @@  discard block
 block discarded – undo
361 361
 	 * @param int $record_id id of the record in $this->appname (set by the constructor)
362 362
 	 * @return string the html
363 363
 	 */
364
-	function return_html($filter_out,$orderby,$sort, $record_id)
364
+	function return_html($filter_out, $orderby, $sort, $record_id)
365 365
 	{
366
-		$this->template   =& CreateObject('phpgwapi.Template',EGW_TEMPLATE_DIR);
367
-		$this->nextmatchs =& CreateObject('phpgwapi.nextmatchs');
366
+		$this->template   = & CreateObject('phpgwapi.Template', EGW_TEMPLATE_DIR);
367
+		$this->nextmatchs = & CreateObject('phpgwapi.nextmatchs');
368 368
 
369
-		$this->template->set_file('_history','history_list.tpl');
369
+		$this->template->set_file('_history', 'history_list.tpl');
370 370
 
371
-		$this->template->set_block('_history','row_no_history');
372
-		$this->template->set_block('_history','list');
373
-		$this->template->set_block('_history','row');
371
+		$this->template->set_block('_history', 'row_no_history');
372
+		$this->template->set_block('_history', 'list');
373
+		$this->template->set_block('_history', 'row');
374 374
 
375
-		$this->template->set_var('lang_user',lang('User'));
376
-		$this->template->set_var('lang_date',lang('Date'));
377
-		$this->template->set_var('lang_action',lang('Action'));
378
-		$this->template->set_var('lang_new_value',lang('New Value'));
375
+		$this->template->set_var('lang_user', lang('User'));
376
+		$this->template->set_var('lang_date', lang('Date'));
377
+		$this->template->set_var('lang_action', lang('Action'));
378
+		$this->template->set_var('lang_new_value', lang('New Value'));
379 379
 
380
-		$this->template->set_var('th_bg',$GLOBALS['egw_info']['theme']['th_bg']);
381
-		$this->template->set_var('sort_date',lang('Date'));
382
-		$this->template->set_var('sort_owner',lang('User'));
383
-		$this->template->set_var('sort_status',lang('Status'));
384
-		$this->template->set_var('sort_new_value',lang('New value'));
385
-		$this->template->set_var('sort_old_value',lang('Old value'));
380
+		$this->template->set_var('th_bg', $GLOBALS['egw_info']['theme']['th_bg']);
381
+		$this->template->set_var('sort_date', lang('Date'));
382
+		$this->template->set_var('sort_owner', lang('User'));
383
+		$this->template->set_var('sort_status', lang('Status'));
384
+		$this->template->set_var('sort_new_value', lang('New value'));
385
+		$this->template->set_var('sort_old_value', lang('Old value'));
386 386
 
387
-		$values = $this->return_array($filter_out,array(),$orderby,$sort,$record_id);
387
+		$values = $this->return_array($filter_out, array(), $orderby, $sort, $record_id);
388 388
 
389 389
 		if (!is_array($values))
390 390
 		{
391
-			$this->template->set_var('tr_color',$GLOBALS['egw_info']['theme']['row_off']);
392
-			$this->template->set_var('lang_no_history',lang('No history for this record'));
393
-			$this->template->fp('rows','row_no_history');
394
-			return $this->template->fp('out','list');
391
+			$this->template->set_var('tr_color', $GLOBALS['egw_info']['theme']['row_off']);
392
+			$this->template->set_var('lang_no_history', lang('No history for this record'));
393
+			$this->template->fp('rows', 'row_no_history');
394
+			return $this->template->fp('out', 'list');
395 395
 		}
396 396
 
397
-		foreach($values as $value)
397
+		foreach ($values as $value)
398 398
 		{
399 399
 			$this->nextmatchs->template_alternate_row_color($this->template);
400 400
 
401
-			$this->template->set_var('row_date',$GLOBALS['egw']->common->show_date($value['datetime']));
402
-			$this->template->set_var('row_owner',$value['owner']);
401
+			$this->template->set_var('row_date', $GLOBALS['egw']->common->show_date($value['datetime']));
402
+			$this->template->set_var('row_owner', $value['owner']);
403 403
 
404 404
 			if ($this->alternate_handlers[$value['status']])
405 405
 			{
@@ -411,14 +411,14 @@  discard block
 block discarded – undo
411 411
 			}
412 412
 			else
413 413
 			{
414
-				$this->template->set_var('row_new_value',$value['new_value']);
415
-				$this->template->set_var('row_old_value',$value['old_value']);
414
+				$this->template->set_var('row_new_value', $value['new_value']);
415
+				$this->template->set_var('row_old_value', $value['old_value']);
416 416
 			}
417 417
 
418
-			$this->template->set_var('row_status',$this->types[$value['status']]);
418
+			$this->template->set_var('row_status', $this->types[$value['status']]);
419 419
 
420
-			$this->template->fp('rows','row',True);
420
+			$this->template->fp('rows', 'row', True);
421 421
 		}
422
-		return $this->template->fp('out','list');
422
+		return $this->template->fp('out', 'list');
423 423
 	}
424 424
 }
Please login to merge, or discard this patch.
Braces   +20 added lines, -7 removed lines patch added patch discarded remove patch
@@ -149,7 +149,10 @@  discard block
 block discarded – undo
149 149
 	 */
150 150
 	function search($filter,$order='history_id',$sort='DESC',$limit=null)
151 151
 	{
152
-		if (!is_array($filter)) $filter = is_numeric($filter) ? array('history_record_id' => $filter) : array();
152
+		if (!is_array($filter))
153
+		{
154
+			$filter = is_numeric($filter) ? array('history_record_id' => $filter) : array();
155
+		}
153 156
 
154 157
 		if (!$order || !preg_match('/^[a-z0-9_]+$/i',$order) || !preg_match('/^(asc|desc)?$/i',$sort))
155 158
 		{
@@ -167,10 +170,16 @@  discard block
 block discarded – undo
167 170
 				unset($filter[$col]);
168 171
 			}
169 172
 		}
170
-		if (!isset($filter['history_appname'])) $filter['history_appname'] = $this->appname;
173
+		if (!isset($filter['history_appname']))
174
+		{
175
+			$filter['history_appname'] = $this->appname;
176
+		}
171 177
 
172 178
 		// do not try to read all history entries of an app
173
-		if (!$filter['history_record_id']) return array();
179
+		if (!$filter['history_record_id'])
180
+		{
181
+			return array();
182
+		}
174 183
 
175 184
 		$rows = array();
176 185
 		foreach($this->db->select(self::TABLE, '*', $filter, __LINE__, __FILE__,
@@ -187,13 +196,16 @@  discard block
 block discarded – undo
187 196
 	 *
188 197
 	 * Similar to search(), except this one can take a start and a number of records
189 198
 	 */
190
-	public static function get_rows(&$query, &$rows) {
199
+	public static function get_rows(&$query, &$rows)
200
+	{
191 201
 		$filter = array();
192 202
 		$rows = array();
193 203
 		$filter['history_appname'] = $query['appname'];
194 204
 		$filter['history_record_id'] = $query['record_id'];
195
-		if(is_array($query['colfilter'])) {
196
-			foreach($query['colfilter'] as $column => $value) {
205
+		if(is_array($query['colfilter']))
206
+		{
207
+			foreach($query['colfilter'] as $column => $value)
208
+			{
197 209
 				$filter[$column] = $value;
198 210
 			}
199 211
 		}
@@ -246,7 +258,8 @@  discard block
 block discarded – undo
246 258
 			' ORDER BY ' . ($query['order'] ? $query['order'] : 'history_timestamp') . ' ' . ($query['sort'] ? $query['sort'] : 'DESC'),
247 259
 			$query['start'],
248 260
 			$query['num_rows']
249
-		) as $row) {
261
+		) as $row)
262
+		{
250 263
 			$row['user_ts'] = $GLOBALS['egw']->db->from_timestamp($row['history_timestamp']) + 3600 * $GLOBALS['egw_info']['user']['preferences']['common']['tz_offset'];
251 264
 
252 265
 			// Explode multi-part values
Please login to merge, or discard this patch.
phpgwapi/inc/class.hooks.inc.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -270,7 +270,7 @@
 block discarded – undo
270 270
 	 *
271 271
 	 * @param string $appname Application 'name'
272 272
 	 * @param string $location is required, the hook itself
273
-	 * @return boolean|int false on error, true if new hooks are supplied and registed or number of removed hooks
273
+	 * @return boolean false on error, true if new hooks are supplied and registed or number of removed hooks
274 274
 	 */
275 275
 	function register_single_app_hook($appname, $location)
276 276
 	{
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -266,7 +266,7 @@
 block discarded – undo
266 266
 	/**
267 267
 	 * Add or/update a single application hook
268 268
 	 *
269
- 	 * setup file of app will be included and the hook required will be added/or updated
269
+	 * setup file of app will be included and the hook required will be added/or updated
270 270
 	 *
271 271
 	 * @param string $appname Application 'name'
272 272
 	 * @param string $location is required, the hook itself
Please login to merge, or discard this patch.
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -53,12 +53,12 @@  discard block
 block discarded – undo
53 53
 	 *
54 54
 	 * @param egw_db $db =null database class, if null we use $GLOBALS['egw']->db
55 55
 	 */
56
-	function __construct($db=null)
56
+	function __construct($db = null)
57 57
 	{
58
-		$this->db = $db ? $db : $GLOBALS['egw']->db;	// this is to allow setup to set the db
58
+		$this->db = $db ? $db : $GLOBALS['egw']->db; // this is to allow setup to set the db
59 59
 
60 60
 		// sort hooks by app-order
61
-		foreach($this->db->select($this->table,'hook_appname,hook_location,hook_filename',false,__LINE__,__FILE__,false,'ORDER BY app_order','phpgwapi',0,'JOIN egw_applications ON hook_appname=app_name') as $row)
61
+		foreach ($this->db->select($this->table, 'hook_appname,hook_location,hook_filename', false, __LINE__, __FILE__, false, 'ORDER BY app_order', 'phpgwapi', 0, 'JOIN egw_applications ON hook_appname=app_name') as $row)
62 62
 		{
63 63
 			$this->locations[$row['hook_location']][$row['hook_appname']] = $row['hook_filename'];
64 64
 		}
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	 * @param egw_db $db
72 72
 	 * @deprecated use __construct()
73 73
 	 */
74
-	function hooks($db=null)
74
+	function hooks($db = null)
75 75
 	{
76 76
 		self::__construct($db);
77 77
 	}
@@ -97,22 +97,22 @@  discard block
 block discarded – undo
97 97
 		$location = is_array($args) ? (isset($args['hook_location']) ? $args['hook_location'] : $args['location']) : $args;
98 98
 
99 99
 		$hooks = $this->locations[$location];
100
-		if (!isset($hooks) || empty($hooks)) return array();	// not a single app implements that hook
100
+		if (!isset($hooks) || empty($hooks)) return array(); // not a single app implements that hook
101 101
 
102 102
 		$apps = array_keys($hooks);
103 103
 		if (!$no_permission_check)
104 104
 		{
105 105
 			// on install of a new egroupware both hook-apps and user apps may be empty/not set
106
-			$apps = array_intersect((array)$apps,array_keys((array)$GLOBALS['egw_info']['user']['apps']));
106
+			$apps = array_intersect((array)$apps, array_keys((array)$GLOBALS['egw_info']['user']['apps']));
107 107
 		}
108 108
 		if ($order)
109 109
 		{
110
-			$apps = array_unique(array_merge((array)$order,$apps));
110
+			$apps = array_unique(array_merge((array)$order, $apps));
111 111
 		}
112 112
 		$results = array();
113
-		foreach((array)$apps as $appname)
113
+		foreach ((array)$apps as $appname)
114 114
 		{
115
-			$results[$appname] = $this->single($args,$appname,$no_permission_check);
115
+			$results[$appname] = $this->single($args, $appname, $no_permission_check);
116 116
 		}
117 117
 		return $results;
118 118
 	}
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 	 * @param boolean $try_unregistered =false If true, try to include old file-hook anyway (for setup)
129 129
 	 * @return mixed False if no hook exists, True if old hook exists and whatever the new method-hook returns (can be True or False too!).
130 130
 	 */
131
-	function single($args, $appname = '', $no_permission_check = False,$try_unregistered = False)
131
+	function single($args, $appname = '', $no_permission_check = False, $try_unregistered = False)
132 132
 	{
133 133
 		//echo "<p>hooks::single(".array2string($args).",'$appname','$no_permission_check','$try_unregistered')</p>\n";
134 134
 		if (!is_array($args)) $args = array('location' => $args);
@@ -148,20 +148,20 @@  discard block
 block discarded – undo
148 148
 		/* First include the ordered apps hook file */
149 149
 		if (isset($this->locations[$location][$appname]) || $try_unregistered)
150 150
 		{
151
-			$parts = explode('.',$method = $this->locations[$location][$appname]);
151
+			$parts = explode('.', $method = $this->locations[$location][$appname]);
152 152
 
153
-			if (strpos($method,'::') !== false || count($parts) == 3 && $parts[1] != 'inc' && $parts[2] != 'php')
153
+			if (strpos($method, '::') !== false || count($parts) == 3 && $parts[1] != 'inc' && $parts[2] != 'php')
154 154
 			{
155 155
 				// new style hook with method string or static method (eg. 'class::method')
156 156
 				try
157 157
 				{
158
-					return ExecMethod($method,$args);
158
+					return ExecMethod($method, $args);
159 159
 				}
160
-				catch(egw_exception_assertion_failed $e)
160
+				catch (egw_exception_assertion_failed $e)
161 161
 				{
162
-					if (substr($e->getMessage(),-19) == '.inc.php not found!')
162
+					if (substr($e->getMessage(), -19) == '.inc.php not found!')
163 163
 					{
164
-						return false;	// fail gracefully if hook class-file does not exists (like the old hooks do, eg. if app got removed)
164
+						return false; // fail gracefully if hook class-file does not exists (like the old hooks do, eg. if app got removed)
165 165
 					}
166 166
 					throw $e;
167 167
 				}
@@ -171,9 +171,9 @@  discard block
 block discarded – undo
171 171
 			{
172 172
 				$method = 'hook_'.$location.'.inc.php';
173 173
 			}
174
-			$f = EGW_SERVER_ROOT . $SEP . $appname . $SEP . 'inc' . $SEP . $method;
174
+			$f = EGW_SERVER_ROOT.$SEP.$appname.$SEP.'inc'.$SEP.$method;
175 175
 			if (file_exists($f) &&
176
-				( $GLOBALS['egw_info']['user']['apps'][$appname] || (($no_permission_check || $location == 'config' || $appname == 'phpgwapi') && $appname)) )
176
+				($GLOBALS['egw_info']['user']['apps'][$appname] || (($no_permission_check || $location == 'config' || $appname == 'phpgwapi') && $appname)))
177 177
 			{
178 178
 				include($f);
179 179
 				return True;
@@ -227,20 +227,20 @@  discard block
 block discarded – undo
227 227
 	 * @param array $hooks =null hooks to register, eg $setup_info[$app]['hooks'] or not used for only deregister the hooks
228 228
 	 * @return boolean|int false on error, true if new hooks are supplied and registed or number of removed hooks
229 229
 	 */
230
-	function register_hooks($appname,$hooks=null)
230
+	function register_hooks($appname, $hooks = null)
231 231
 	{
232
-		if(!$appname)
232
+		if (!$appname)
233 233
 		{
234 234
 			return False;
235 235
 		}
236
-		$this->db->delete($this->table,array('hook_appname' => $appname),__LINE__,__FILE__);
236
+		$this->db->delete($this->table, array('hook_appname' => $appname), __LINE__, __FILE__);
237 237
 
238 238
 		if (!is_array($hooks) || !count($hooks))	// only deregister
239 239
 		{
240 240
 			return $this->db->affected_rows();
241 241
 		}
242 242
 		//echo "<p>ADDING hooks for: $appname</p>";
243
-		foreach($hooks as $key => $hook)
243
+		foreach ($hooks as $key => $hook)
244 244
 		{
245 245
 			if (!is_numeric($key))	// new method-hook
246 246
 			{
@@ -252,12 +252,12 @@  discard block
 block discarded – undo
252 252
 				$location = $hook;
253 253
 				$filename = "hook_$hook.inc.php";
254 254
 			}
255
-			$this->db->insert($this->table,array(
255
+			$this->db->insert($this->table, array(
256 256
 				'hook_filename' => $filename,
257
-			),array(
257
+			), array(
258 258
 				'hook_appname'  => $appname,
259 259
 				'hook_location' => $location,
260
-			),__LINE__,__FILE__);
260
+			), __LINE__, __FILE__);
261 261
 			$this->locations[$location][$appname] = $filename;
262 262
 		}
263 263
 		return True;
@@ -274,24 +274,24 @@  discard block
 block discarded – undo
274 274
 	 */
275 275
 	function register_single_app_hook($appname, $location)
276 276
 	{
277
-		if(!$appname || empty($location))
277
+		if (!$appname || empty($location))
278 278
 		{
279 279
 			return False;
280 280
 		}
281 281
 		$SEP = filesystem_separator();
282 282
 		// now register the rest again
283
-		$f = EGW_SERVER_ROOT . $SEP . $appname . $SEP . 'setup' . $SEP . 'setup.inc.php';
283
+		$f = EGW_SERVER_ROOT.$SEP.$appname.$SEP.'setup'.$SEP.'setup.inc.php';
284 284
 		$setup_info = array($appname => array());
285
-		if(@file_exists($f)) include($f);
285
+		if (@file_exists($f)) include($f);
286 286
 		// some apps have setup_info for more then themselfs (eg. phpgwapi for groupdav)
287 287
 		$hdata = array();
288
-		foreach($setup_info as $appname => $data)
288
+		foreach ($setup_info as $appname => $data)
289 289
 		{
290 290
 			if ($data['hooks'])
291 291
 			{
292 292
 				if ($hdata[$appname])
293 293
 				{
294
-					$hdata[$appname]['hooks'] = array_merge($hdata[$appname]['hooks'],$data['hooks']);
294
+					$hdata[$appname]['hooks'] = array_merge($hdata[$appname]['hooks'], $data['hooks']);
295 295
 				}
296 296
 				else
297 297
 				{
@@ -300,21 +300,21 @@  discard block
 block discarded – undo
300 300
 			}
301 301
 		}
302 302
 		//error_log(__METHOD__.__LINE__.array2string($hdata));
303
-		foreach((array)$hdata as $appname => $data)
303
+		foreach ((array)$hdata as $appname => $data)
304 304
 		{
305
-			if (array_key_exists($location,$data['hooks'])) $method = $data['hooks'][$location];
305
+			if (array_key_exists($location, $data['hooks'])) $method = $data['hooks'][$location];
306 306
 		}
307 307
 		if (!empty($method))
308 308
 		{
309 309
 			//echo "<p>ADDING hooks for: $appname</p>";
310
-			$this->db->insert($this->table,array(
310
+			$this->db->insert($this->table, array(
311 311
 				'hook_appname'  => $appname,
312 312
 				'hook_filename' => $method,
313 313
 				'hook_location' => $location,
314
-			),array(
314
+			), array(
315 315
 				'hook_appname'  => $appname,
316 316
 				'hook_location' => $location,
317
-			),__LINE__,__FILE__);
317
+			), __LINE__, __FILE__);
318 318
 			$this->locations[$location][$appname] = $method;
319 319
 			return True;
320 320
 		}
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
 	function register_all_hooks()
328 328
 	{
329 329
 		// deleting hooks, to get ride of no longer existing apps
330
-		$this->db->delete($this->table,'1=1',__LINE__,__FILE__);
330
+		$this->db->delete($this->table, '1=1', __LINE__, __FILE__);
331 331
 
332 332
 		// if we run in setup, we need to read installed apps first
333 333
 		if (!$GLOBALS['egw_info']['apps'])
@@ -337,22 +337,22 @@  discard block
 block discarded – undo
337 337
 		}
338 338
 
339 339
 		// now register all apps using just filesystem data
340
-		foreach(array_keys($GLOBALS['egw_info']['apps']) as $appname)
340
+		foreach (array_keys($GLOBALS['egw_info']['apps']) as $appname)
341 341
 		{
342 342
 			if ($appname[0] == '.' || !is_dir(EGW_SERVER_ROOT.'/'.$appname)) continue;
343 343
 
344
-			$f = EGW_SERVER_ROOT . '/' . $appname . '/setup/setup.inc.php';
344
+			$f = EGW_SERVER_ROOT.'/'.$appname.'/setup/setup.inc.php';
345 345
 			$setup_info = array($appname => array());
346
-			if(@file_exists($f)) include($f);
346
+			if (@file_exists($f)) include($f);
347 347
 			// some apps have setup_info for more then themselfs (eg. phpgwapi for groupdav)
348 348
 			$hdata = array();
349
-			foreach($setup_info as $appname => $data)
349
+			foreach ($setup_info as $appname => $data)
350 350
 			{
351 351
 				if ($data['hooks'])
352 352
 				{
353 353
 					if ($hdata[$appname])
354 354
 					{
355
-						$hdata[$appname]['hooks'] = array_merge($hdata[$appname]['hooks'],$data['hooks']);
355
+						$hdata[$appname]['hooks'] = array_merge($hdata[$appname]['hooks'], $data['hooks']);
356 356
 					}
357 357
 					else
358 358
 					{
@@ -360,9 +360,9 @@  discard block
 block discarded – undo
360 360
 					}
361 361
 				}
362 362
 			}
363
-			foreach((array)$hdata as $appname => $data)
363
+			foreach ((array)$hdata as $appname => $data)
364 364
 			{
365
-				if ($data['hooks']) $this->register_hooks($appname,$data['hooks']);
365
+				if ($data['hooks']) $this->register_hooks($appname, $data['hooks']);
366 366
 			}
367 367
 		}
368 368
 	}
Please login to merge, or discard this patch.
Braces   +37 added lines, -9 removed lines patch added patch discarded remove patch
@@ -97,7 +97,11 @@  discard block
 block discarded – undo
97 97
 		$location = is_array($args) ? (isset($args['hook_location']) ? $args['hook_location'] : $args['location']) : $args;
98 98
 
99 99
 		$hooks = $this->locations[$location];
100
-		if (!isset($hooks) || empty($hooks)) return array();	// not a single app implements that hook
100
+		if (!isset($hooks) || empty($hooks))
101
+		{
102
+			return array();
103
+		}
104
+		// not a single app implements that hook
101 105
 
102 106
 		$apps = array_keys($hooks);
103 107
 		if (!$no_permission_check)
@@ -131,7 +135,10 @@  discard block
 block discarded – undo
131 135
 	function single($args, $appname = '', $no_permission_check = False,$try_unregistered = False)
132 136
 	{
133 137
 		//echo "<p>hooks::single(".array2string($args).",'$appname','$no_permission_check','$try_unregistered')</p>\n";
134
-		if (!is_array($args)) $args = array('location' => $args);
138
+		if (!is_array($args))
139
+		{
140
+			$args = array('location' => $args);
141
+		}
135 142
 		$location = isset($args['hook_location']) ? $args['hook_location'] : $args['location'];
136 143
 
137 144
 		if (!$appname)
@@ -235,16 +242,22 @@  discard block
 block discarded – undo
235 242
 		}
236 243
 		$this->db->delete($this->table,array('hook_appname' => $appname),__LINE__,__FILE__);
237 244
 
238
-		if (!is_array($hooks) || !count($hooks))	// only deregister
245
+		if (!is_array($hooks) || !count($hooks))
246
+		{
247
+			// only deregister
239 248
 		{
240 249
 			return $this->db->affected_rows();
241 250
 		}
251
+		}
242 252
 		//echo "<p>ADDING hooks for: $appname</p>";
243 253
 		foreach($hooks as $key => $hook)
244 254
 		{
245
-			if (!is_numeric($key))	// new method-hook
255
+			if (!is_numeric($key))
256
+			{
257
+				// new method-hook
246 258
 			{
247 259
 				$location = $key;
260
+			}
248 261
 				$filename = $hook;
249 262
 			}
250 263
 			else
@@ -282,7 +295,10 @@  discard block
 block discarded – undo
282 295
 		// now register the rest again
283 296
 		$f = EGW_SERVER_ROOT . $SEP . $appname . $SEP . 'setup' . $SEP . 'setup.inc.php';
284 297
 		$setup_info = array($appname => array());
285
-		if(@file_exists($f)) include($f);
298
+		if(@file_exists($f))
299
+		{
300
+			include($f);
301
+		}
286 302
 		// some apps have setup_info for more then themselfs (eg. phpgwapi for groupdav)
287 303
 		$hdata = array();
288 304
 		foreach($setup_info as $appname => $data)
@@ -302,7 +318,10 @@  discard block
 block discarded – undo
302 318
 		//error_log(__METHOD__.__LINE__.array2string($hdata));
303 319
 		foreach((array)$hdata as $appname => $data)
304 320
 		{
305
-			if (array_key_exists($location,$data['hooks'])) $method = $data['hooks'][$location];
321
+			if (array_key_exists($location,$data['hooks']))
322
+			{
323
+				$method = $data['hooks'][$location];
324
+			}
306 325
 		}
307 326
 		if (!empty($method))
308 327
 		{
@@ -339,11 +358,17 @@  discard block
 block discarded – undo
339 358
 		// now register all apps using just filesystem data
340 359
 		foreach(array_keys($GLOBALS['egw_info']['apps']) as $appname)
341 360
 		{
342
-			if ($appname[0] == '.' || !is_dir(EGW_SERVER_ROOT.'/'.$appname)) continue;
361
+			if ($appname[0] == '.' || !is_dir(EGW_SERVER_ROOT.'/'.$appname))
362
+			{
363
+				continue;
364
+			}
343 365
 
344 366
 			$f = EGW_SERVER_ROOT . '/' . $appname . '/setup/setup.inc.php';
345 367
 			$setup_info = array($appname => array());
346
-			if(@file_exists($f)) include($f);
368
+			if(@file_exists($f))
369
+			{
370
+				include($f);
371
+			}
347 372
 			// some apps have setup_info for more then themselfs (eg. phpgwapi for groupdav)
348 373
 			$hdata = array();
349 374
 			foreach($setup_info as $appname => $data)
@@ -362,7 +387,10 @@  discard block
 block discarded – undo
362 387
 			}
363 388
 			foreach((array)$hdata as $appname => $data)
364 389
 			{
365
-				if ($data['hooks']) $this->register_hooks($appname,$data['hooks']);
390
+				if ($data['hooks'])
391
+				{
392
+					$this->register_hooks($appname,$data['hooks']);
393
+				}
366 394
 			}
367 395
 		}
368 396
 	}
Please login to merge, or discard this patch.
phpgwapi/inc/class.html.inc.php 4 patches
Doc Comments   +5 added lines, -7 removed lines patch added patch discarded remove patch
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
 	 *
309 309
 	 * @param string $name	string with name of the submitted var which holds the key of the selected item form array
310 310
 	 * @param string|array $key key(s) of already selected item(s) from $arr, eg. '1' or '1,2' or array with keys
311
-	 * @param array $arr array with items to select, eg. $arr = array ( 'y' => 'yes','n' => 'no','m' => 'maybe');
311
+	 * @param integer $arr array with items to select, eg. $arr = array ( 'y' => 'yes','n' => 'no','m' => 'maybe');
312 312
 	 * @param boolean $no_lang NOT run the labels of the options through lang(), default false=use lang()
313 313
 	 * @param string $options additional options (e.g. 'width')
314 314
 	 * @param int $multiple number of lines for a multiselect, default 0 = no multiselect, < 0 sets size without multiple
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
 	 *
397 397
 	 * @param string $name	string with name of the submitted var which holds the key of the selected item form array
398 398
 	 * @param string|array $key key(s) of already selected item(s) from $arr, eg. '1' or '1,2' or array with keys
399
-	 * @param array $arr array with items to select, eg. $arr = array ( 'y' => 'yes','n' => 'no','m' => 'maybe');
399
+	 * @param integer $arr array with items to select, eg. $arr = array ( 'y' => 'yes','n' => 'no','m' => 'maybe');
400 400
 	 * @param boolean $no_lang NOT run the labels of the options through lang(), default false=use lang()
401 401
 	 * @param string $options additional options (e.g. 'width')
402 402
 	 * @param int $multiple number of lines for a multiselect, default 3
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
 	 * @param string $value value
483 483
 	 * @param string $label label
484 484
 	 * @param mixed $selected value or array of values of options to mark as selected
485
-	 * @param boolean $no_lang NOT running the label through lang(), default false=use lang()
485
+	 * @param integer $no_lang NOT running the label through lang(), default false=use lang()
486 486
 	 * @param string $extra extra text, e.g.: style="", default: ''
487 487
 	 * @return string html
488 488
 	 */
@@ -555,7 +555,6 @@  discard block
 block discarded – undo
555 555
 	 *
556 556
 	 * @param string $name name attr. of the tag
557 557
 	 * @param string $value default
558
-	 * @param boolean $ignore_empty if true all empty, zero (!) or unset values, plus filer=none
559 558
 	 * @param boolean $double_encoding =false do we want double encoding or not, default no
560 559
 	 * @param string html
561 560
 	 */
@@ -913,7 +912,6 @@  discard block
 block discarded – undo
913 912
 	 * @param array $hidden_vars array with name-value pairs for hidden input fields
914 913
 	 * @param string $url eGW relative URL, will be run through the link function
915 914
 	 * @param string|array $url_vars parameters for the URL, send to link static function too
916
-	 * @param string $options attributes for the tag, default ''=none
917 915
 	 * @param string $form_name name of the form, defaul ''=none
918 916
 	 * @param string $method method of the form, default 'POST'
919 917
 	 * @return string html
@@ -1209,7 +1207,7 @@  discard block
 block discarded – undo
1209 1207
 	 * Example: formatOptions('100%,,1','width,height,border') = ' width="100%" border="1"'
1210 1208
 	 *
1211 1209
 	 * @param mixed $options String (or Array) with option-values eg. '100%,,1'
1212
-	 * @param mixed $names String (or Array) with the option-names eg. 'WIDTH,HEIGHT,BORDER'
1210
+	 * @param string $names String (or Array) with the option-names eg. 'WIDTH,HEIGHT,BORDER'
1213 1211
 	 * @return string with options/attributes
1214 1212
 	 */
1215 1213
 	static function formatOptions($options,$names)
@@ -1312,7 +1310,7 @@  discard block
 block discarded – undo
1312 1310
 	 * @author Lars Kneschke <lars-AT-kneschke.de> original code in felamimail
1313 1311
 	 * @param array $_folders array of folders: pairs path => node (string label or array with keys: label, (optional) image, (optional) title, (optional) checked)
1314 1312
 	 * @param string $_selected path of selected folder
1315
-	 * @param mixed $_topFolder =false node of topFolder or false for none
1313
+	 * @param boolean $_topFolder =false node of topFolder or false for none
1316 1314
 	 * @param string $_onNodeSelect ='alert' js static function to call if node gets selected
1317 1315
 	 * @param string $tree ='foldertree' id of the div and name of the variable containing the tree object
1318 1316
 	 * @param string $_divClass ='' css class of the div
Please login to merge, or discard this patch.
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -112,16 +112,16 @@  discard block
 block discarded – undo
112 112
 	}
113 113
 
114 114
 	/**
115
-	* Created an input-field with an attached color-picker
116
-	*
117
-	* Please note: it need to be called before the call to egw_header() !!!
118
-	*
119
-	* @param string $name the name of the input-field
120
-	* @param string $value ='' the actual value for the input-field, default ''
121
-	* @param string $title ='' tooltip/title for the picker-activation-icon
122
-	* @param string $options ='' options for input
123
-	* @return string the html
124
-	*/
115
+	 * Created an input-field with an attached color-picker
116
+	 *
117
+	 * Please note: it need to be called before the call to egw_header() !!!
118
+	 *
119
+	 * @param string $name the name of the input-field
120
+	 * @param string $value ='' the actual value for the input-field, default ''
121
+	 * @param string $title ='' tooltip/title for the picker-activation-icon
122
+	 * @param string $options ='' options for input
123
+	 * @return string the html
124
+	 */
125 125
 	static function inputColor($name,$value='',$title='',$options='')
126 126
 	{
127 127
 		$options .= ' id="'.htmlspecialchars($id=str_replace(array('[',']'),array('_',''),$name).'_colorpicker').'"';
@@ -137,16 +137,16 @@  discard block
 block discarded – undo
137 137
 	}
138 138
 
139 139
 	/**
140
-	* Handles tooltips via the wz_tooltip class from Walter Zorn
141
-	*
142
-	* @param string $text text or html for the tooltip, all chars allowed, they will be quoted approperiate
143
-	* @param boolean $do_lang (default False) should the text be run though lang()
144
-	* @param array $options param/value pairs, eg. 'TITLE' => 'I am the title'. Some common parameters:
145
-	*  title (string) gives extra title-row, width (int,'auto') , padding (int), above (bool), bgcolor (color), bgimg (URL)
146
-	*  For a complete list and description see http://www.walterzorn.com/tooltip/tooltip_e.htm
147
-	* @param boolean $return_as_attributes true to return array(onmouseover, onmouseout) attributes
148
-	* @return string|array to be included in any tag, like '<p'.html::tooltip('Hello <b>Ralf</b>').'>Text with tooltip</p>'
149
-	*/
140
+	 * Handles tooltips via the wz_tooltip class from Walter Zorn
141
+	 *
142
+	 * @param string $text text or html for the tooltip, all chars allowed, they will be quoted approperiate
143
+	 * @param boolean $do_lang (default False) should the text be run though lang()
144
+	 * @param array $options param/value pairs, eg. 'TITLE' => 'I am the title'. Some common parameters:
145
+	 *  title (string) gives extra title-row, width (int,'auto') , padding (int), above (bool), bgcolor (color), bgimg (URL)
146
+	 *  For a complete list and description see http://www.walterzorn.com/tooltip/tooltip_e.htm
147
+	 * @param boolean $return_as_attributes true to return array(onmouseover, onmouseout) attributes
148
+	 * @return string|array to be included in any tag, like '<p'.html::tooltip('Hello <b>Ralf</b>').'>Text with tooltip</p>'
149
+	 */
150 150
 	static function tooltip($text,$do_lang=False,$options=False, $return_as_attributes=false)
151 151
 	{
152 152
 		// tell egw_framework to include wz_tooltip.js
@@ -594,20 +594,20 @@  discard block
 block discarded – undo
594 594
 	}
595 595
 
596 596
 	/**
597
-	* this static function is a wrapper for fckEditor to create some reuseable layouts
598
-	*
599
-	* @param string $_name name and id of the input-field
600
-	* @param string $_content of the tinymce (will be run through htmlspecialchars !!!), default ''
601
-	* @param string $_mode display mode of the tinymce editor can be: simple, extended or advanced
602
-	* @param array  $_options (toolbar_expanded true/false)
603
-	* @param string $_height ='400px'
604
-	* @param string $_width ='100%'
605
-	* @param string $_start_path ='' if passed activates the browser for image at absolute path passed
606
-	* @param boolean $_purify =true run $_content through htmlpurifier before handing it to fckEditor
607
-	* @param mixed (boolean/string) $_focusToBody=false USED only for CKEDIOR true means yes, focus on top, you may specify TOP or BOTTOM (to focus on the end of the editor area)
608
-	* @param string $_executeJSAfterInit ='' Javascript to be executed after InstanceReady of CKEditor
609
-	* @return string the necessary html for the textarea
610
-	*/
597
+	 * this static function is a wrapper for fckEditor to create some reuseable layouts
598
+	 *
599
+	 * @param string $_name name and id of the input-field
600
+	 * @param string $_content of the tinymce (will be run through htmlspecialchars !!!), default ''
601
+	 * @param string $_mode display mode of the tinymce editor can be: simple, extended or advanced
602
+	 * @param array  $_options (toolbar_expanded true/false)
603
+	 * @param string $_height ='400px'
604
+	 * @param string $_width ='100%'
605
+	 * @param string $_start_path ='' if passed activates the browser for image at absolute path passed
606
+	 * @param boolean $_purify =true run $_content through htmlpurifier before handing it to fckEditor
607
+	 * @param mixed (boolean/string) $_focusToBody=false USED only for CKEDIOR true means yes, focus on top, you may specify TOP or BOTTOM (to focus on the end of the editor area)
608
+	 * @param string $_executeJSAfterInit ='' Javascript to be executed after InstanceReady of CKEditor
609
+	 * @return string the necessary html for the textarea
610
+	 */
611 611
 	static function fckEditor($_name, $_content, $_mode, $_options=array('toolbar_expanded' =>'true'),
612 612
 		$_height='400px', $_width='100%',$_start_path='',$_purify=true, $_focusToBody=false, $_executeJSAfterInit='')
613 613
 	{
@@ -678,21 +678,21 @@  discard block
 block discarded – undo
678 678
 	}
679 679
 
680 680
 	/**
681
-	* this static function is a wrapper for tinymce to create some reuseable layouts
682
-	*
683
-	* Please note: if you did not run init_tinymce already you this static function need to be called before the call to phpgw_header() !!!
684
-	*
685
-	* @param string $_name name and id of the input-field
686
-	* @param string $_mode display mode of the tinymce editor can be: simple, extended or advanced
687
-	* @param string $_content ='' of the tinymce (will be run through htmlspecialchars !!!), default ''
688
-	* @param string $_height ='400px'
689
-	* @param string $_width ='100%'
690
-	* @param boolean $_purify =true
691
-	* @param string $_border ='0px' NOT used for CKEditor
692
-	* @param mixed (boolean/string) $_focusToBody=false USED only for CKEDIOR true means yes, focus on top, you may specify TOP or BOTTOM (to focus on the end of the editor area)
693
-	* @param string $_executeJSAfterInit ='' Javascript to be executed after InstanceReady of CKEditor
694
-	* @return string the necessary html for the textarea
695
-	*/
681
+	 * this static function is a wrapper for tinymce to create some reuseable layouts
682
+	 *
683
+	 * Please note: if you did not run init_tinymce already you this static function need to be called before the call to phpgw_header() !!!
684
+	 *
685
+	 * @param string $_name name and id of the input-field
686
+	 * @param string $_mode display mode of the tinymce editor can be: simple, extended or advanced
687
+	 * @param string $_content ='' of the tinymce (will be run through htmlspecialchars !!!), default ''
688
+	 * @param string $_height ='400px'
689
+	 * @param string $_width ='100%'
690
+	 * @param boolean $_purify =true
691
+	 * @param string $_border ='0px' NOT used for CKEditor
692
+	 * @param mixed (boolean/string) $_focusToBody=false USED only for CKEDIOR true means yes, focus on top, you may specify TOP or BOTTOM (to focus on the end of the editor area)
693
+	 * @param string $_executeJSAfterInit ='' Javascript to be executed after InstanceReady of CKEditor
694
+	 * @return string the necessary html for the textarea
695
+	 */
696 696
 	static function fckEditorQuick($_name, $_mode, $_content='', $_height='400px', $_width='100%',$_purify=true, $_border='0px',$_focusToBody=false,$_executeJSAfterInit='')
697 697
 	{
698 698
 		if (!self::htmlarea_availible() || $_mode == 'ascii')
Please login to merge, or discard this patch.
Spacing   +238 added lines, -239 removed lines patch added patch discarded remove patch
@@ -63,11 +63,11 @@  discard block
 block discarded – undo
63 63
 	{
64 64
 		// should be Ok for all HTML 4 compatible browsers
65 65
 		$parts = $all_parts = null;
66
-		if(!preg_match('/compatible; ([a-z]+)[\/ ]+([0-9.]+)/i',$_SERVER['HTTP_USER_AGENT'],$parts))
66
+		if (!preg_match('/compatible; ([a-z]+)[\/ ]+([0-9.]+)/i', $_SERVER['HTTP_USER_AGENT'], $parts))
67 67
 		{
68
-			preg_match_all('/([a-z]+)\/([0-9.]+)/i',$_SERVER['HTTP_USER_AGENT'],$all_parts,PREG_SET_ORDER);
68
+			preg_match_all('/([a-z]+)\/([0-9.]+)/i', $_SERVER['HTTP_USER_AGENT'], $all_parts, PREG_SET_ORDER);
69 69
 			$parts = array_pop($all_parts);
70
-			foreach($all_parts as $p)
70
+			foreach ($all_parts as $p)
71 71
 			{
72 72
 				if ($p[1] == 'Chrome' && $parts[1] != 'Edge')
73 73
 				{
@@ -76,12 +76,12 @@  discard block
 block discarded – undo
76 76
 				}
77 77
 			}
78 78
 		}
79
-		list(,self::$user_agent,self::$ua_version) = $parts;
79
+		list(,self::$user_agent, self::$ua_version) = $parts;
80 80
 		if ((self::$user_agent = strtolower(self::$user_agent)) == 'version') self::$user_agent = 'opera';
81 81
 		// IE no longer reports MSIE, but "Trident/7.0; rv:11.0"
82
-		if (self::$user_agent=='trident')
82
+		if (self::$user_agent == 'trident')
83 83
 		{
84
-			self::$user_agent='msie';
84
+			self::$user_agent = 'msie';
85 85
 			$matches = null;
86 86
 			self::$ua_version = preg_match('|Trident/[0-9.]+; rv:([0-9.]+)|i', $_SERVER['HTTP_USER_AGENT'], $matches) ?
87 87
 				$matches[1] : 11.0;
@@ -122,11 +122,11 @@  discard block
 block discarded – undo
122 122
 	* @param string $options ='' options for input
123 123
 	* @return string the html
124 124
 	*/
125
-	static function inputColor($name,$value='',$title='',$options='')
125
+	static function inputColor($name, $value = '', $title = '', $options = '')
126 126
 	{
127
-		$options .= ' id="'.htmlspecialchars($id=str_replace(array('[',']'),array('_',''),$name).'_colorpicker').'"';
127
+		$options .= ' id="'.htmlspecialchars($id = str_replace(array('[', ']'), array('_', ''), $name).'_colorpicker').'"';
128 128
 		$onclick = "javascript:egw_openWindowCentered2('".self::$api_js_url.'/colorpicker/select_color.html?id='.urlencode($id)."&color='+encodeURIComponent(document.getElementById('$id').value),'colorPicker',240,187);";
129
-		if (preg_match('/^#[0-9A-F]{6}$/i',$value))
129
+		if (preg_match('/^#[0-9A-F]{6}$/i', $value))
130 130
 		{
131 131
 			$options .= ' style="background-color: '.$value.'"';
132 132
 		}
@@ -147,30 +147,30 @@  discard block
 block discarded – undo
147 147
 	* @param boolean $return_as_attributes true to return array(onmouseover, onmouseout) attributes
148 148
 	* @return string|array to be included in any tag, like '<p'.html::tooltip('Hello <b>Ralf</b>').'>Text with tooltip</p>'
149 149
 	*/
150
-	static function tooltip($text,$do_lang=False,$options=False, $return_as_attributes=false)
150
+	static function tooltip($text, $do_lang = False, $options = False, $return_as_attributes = false)
151 151
 	{
152 152
 		// tell egw_framework to include wz_tooltip.js
153 153
 		$GLOBALS['egw_info']['flags']['include_wz_tooltip'] = true;
154 154
 
155 155
 		if ($do_lang) $text = lang($text);
156 156
 
157
-		$ttip = 'Tip(\''.str_replace(array("\n","\r","'",'"'),array('','',"\\'",'&quot;'),$text).'\'';
157
+		$ttip = 'Tip(\''.str_replace(array("\n", "\r", "'", '"'), array('', '', "\\'", '&quot;'), $text).'\'';
158 158
 
159 159
 		$sticky = false;
160 160
 		if (is_array($options))
161 161
 		{
162
-			foreach($options as $option => $value)
162
+			foreach ($options as $option => $value)
163 163
 			{
164 164
 				$option = strtoupper($option);
165 165
 				if ($option == 'STICKY') $sticky = (bool)$value;
166 166
 
167
-				switch(gettype($value))
167
+				switch (gettype($value))
168 168
 				{
169 169
 					case 'boolean':
170 170
 						$value = $value ? 'true' : 'false';
171 171
 						break;
172 172
 					case 'string':
173
-						if (stripos($value,"'")===false) $value = "'$value'";
173
+						if (stripos($value, "'") === false) $value = "'$value'";
174 174
 						break;
175 175
 				}
176 176
 				$ttip .= ','.$option.','.$value;
@@ -180,8 +180,7 @@  discard block
 block discarded – undo
180 180
 
181 181
 		$untip = 'UnTip()';
182 182
 
183
-		return $return_as_attributes ? array($ttip, $untip) :
184
-			' onmouseover="'.self::htmlspecialchars($ttip).'" onmouseout="'.$untip.'"';
183
+		return $return_as_attributes ? array($ttip, $untip) : ' onmouseover="'.self::htmlspecialchars($ttip).'" onmouseout="'.$untip.'"';
185 184
 	}
186 185
 
187 186
 	/**
@@ -192,7 +191,7 @@  discard block
 block discarded – undo
192 191
 	 */
193 192
 	static function activate_links($content)
194 193
 	{
195
-		if (!$content || strlen($content) < 20) return $content;	// performance
194
+		if (!$content || strlen($content) < 20) return $content; // performance
196 195
 
197 196
 		// Exclude everything which is already a link
198 197
 		$NotAnchor = '(?<!"|href=|href\s=\s|href=\s|href\s=)';
@@ -205,73 +204,73 @@  discard block
 block discarded – undo
205 204
 
206 205
 		//  First match things beginning with http:// (or other protocols)
207 206
 		$optBracket0 = '(<|&lt;)';
208
-		$Protocol = '(http:\/\/|(ftp:\/\/|https:\/\/))';	// only http:// gets removed, other protocolls are shown
207
+		$Protocol = '(http:\/\/|(ftp:\/\/|https:\/\/))'; // only http:// gets removed, other protocolls are shown
209 208
 		$Domain = '([\w-]+\.[\w-.]+)';
210 209
 		$Subdir = '([\w\-\.,@?^=%&;:\/~\+#]*[\w\-\@?^=%&\/~\+#])?';
211 210
 		$optBracket = '';
212 211
 		$optBracket = '(>|&gt;)';
213
-		$Expr = '/' .$optBracket0. $NotAnchor . $Protocol . $Domain . $Subdir . $optBracket . '/i';
212
+		$Expr = '/'.$optBracket0.$NotAnchor.$Protocol.$Domain.$Subdir.$optBracket.'/i';
214 213
 		// use preg_replace_callback as we experienced problems with https links
215
-		$result2 = preg_replace_callback( $Expr, function ($match) {
214
+		$result2 = preg_replace_callback($Expr, function($match) {
216 215
 				//error_log(__METHOD__.__LINE__.array2string($match));
217
-				return $match[1]."<a href=\"".($match[2]&&!$match[3]?$match[2]:'').($match[3]?$match[3]:'').$match[4].$match[5]."\" target=\"_blank\">".$match[4].$match[5]."</a>".$match[6];
218
-			}, $result );
216
+				return $match[1]."<a href=\"".($match[2] && !$match[3] ? $match[2] : '').($match[3] ? $match[3] : '').$match[4].$match[5]."\" target=\"_blank\">".$match[4].$match[5]."</a>".$match[6];
217
+			}, $result);
219 218
 //error_log(__METHOD__.__LINE__.array2string($Expr));
220 219
 //error_log(__METHOD__.__LINE__.array2string($result2));
221 220
 		//  First match things beginning with http:// (or other protocols)
222
-		$Protocol = '(http:\/\/|(ftp:\/\/|https:\/\/))';	// only http:// gets removed, other protocolls are shown
221
+		$Protocol = '(http:\/\/|(ftp:\/\/|https:\/\/))'; // only http:// gets removed, other protocolls are shown
223 222
 		$Domain = '([\w-]+\.[\w-.]+)';
224 223
 		$Subdir = '([\w\-\.,@?^=%&;:\/~\+#]*[\w\-\@?^=%&\/~\+#])?';
225 224
 		$optStuff = '(&quot;|&quot|;)?';
226
-		$Expr = '/' . $NotAnchor . $Protocol . $Domain . $Subdir . $optStuff . '/i';
225
+		$Expr = '/'.$NotAnchor.$Protocol.$Domain.$Subdir.$optStuff.'/i';
227 226
 		// use preg_replace_callback as we experienced problems with https links
228
-		$result3 = preg_replace_callback( $Expr, function ($match) {
229
-				$additionalQuote="";//at the end, ...
227
+		$result3 = preg_replace_callback($Expr, function($match) {
228
+				$additionalQuote = ""; //at the end, ...
230 229
 				// only one &quot at the end is found. chance is, it is not belonging to the URL
231
-				if ($match[5]==';' && (strlen($match[4])-6) >=0 && strpos($match[4],'&quot',strlen($match[4])-6)!==false && strpos(substr($match[4],0,strlen($match[4])-6),'&quot')===false)
230
+				if ($match[5] == ';' && (strlen($match[4]) - 6) >= 0 && strpos($match[4], '&quot', strlen($match[4]) - 6) !== false && strpos(substr($match[4], 0, strlen($match[4]) - 6), '&quot') === false)
232 231
 				{
233
-					$match[4] = substr($match[4],0,strpos($match[4],'&quot',strlen($match[4])-6));
232
+					$match[4] = substr($match[4], 0, strpos($match[4], '&quot', strlen($match[4]) - 6));
234 233
 					$additionalQuote = "&quot;";
235 234
 				}
236 235
 				// if there is quoted stuff within the URL then we have at least one more &quot; in match[4], so chance is the last &quot is matched by the one within
237
-				if ($match[5]==';' && (strlen($match[4])-6) >=0 && strpos($match[4],'&quot',strlen($match[4])-6)!==false && strpos(substr($match[4],0,strlen($match[4])-6),'&quot')!==false)
236
+				if ($match[5] == ';' && (strlen($match[4]) - 6) >= 0 && strpos($match[4], '&quot', strlen($match[4]) - 6) !== false && strpos(substr($match[4], 0, strlen($match[4]) - 6), '&quot') !== false)
238 237
 				{
239 238
 					$match[4] .= $match[5];
240 239
 				}
241
-				if ($match[5]==';'&&$match[4]=="&quot")
240
+				if ($match[5] == ';' && $match[4] == "&quot")
242 241
 				{
243
-					$match[4] ='';
242
+					$match[4] = '';
244 243
 					$additionalQuote = "&quot;";
245 244
 				}
246 245
 				//error_log(__METHOD__.__LINE__.array2string($match));
247
-				return "<a href=\"".($match[1]&&!$match[2]?$match[1]:'').($match[2]?$match[2]:'').$match[3].$match[4]."\" target=\"_blank\">".$match[3].$match[4]."</a>$additionalQuote";
248
-			}, $result2 );
246
+				return "<a href=\"".($match[1] && !$match[2] ? $match[1] : '').($match[2] ? $match[2] : '').$match[3].$match[4]."\" target=\"_blank\">".$match[3].$match[4]."</a>$additionalQuote";
247
+			}, $result2);
249 248
 //error_log(__METHOD__.__LINE__.array2string($Expr));
250 249
 //error_log(__METHOD__.__LINE__.array2string($result3));
251 250
 		//  Now match things beginning with www.
252 251
 		$optBracket0 = '(<|&lt;)?';
253
-		$NotHTTP = '(?<!:\/\/|" target=\"_blank\">)';	//	avoid running again on http://www links already handled above
252
+		$NotHTTP = '(?<!:\/\/|" target=\"_blank\">)'; //	avoid running again on http://www links already handled above
254 253
 		$Domain2 = 'www(\.[\w-.]+)';
255 254
 		$Subdir2 = '([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?';
256 255
 		$optBracket = '(>|&gt;|&gt|;)?';
257
-		$Expr = '/' .$optBracket0. $NotAnchor . $NotHTTP . $Domain2 . $Subdir2 .$optBracket. '/i';
256
+		$Expr = '/'.$optBracket0.$NotAnchor.$NotHTTP.$Domain2.$Subdir2.$optBracket.'/i';
258 257
 		//$Expr = '/' . $NotAnchor . $NotHTTP . $Domain . $Subdir . $optBracket . '/i';
259 258
 		// use preg_replace_callback as we experienced problems with links such as <www.example.tld/pfad/zu/einer/pdf-Datei.pdf>
260
-		$result4 = preg_replace_callback( $Expr, function ($match) {
259
+		$result4 = preg_replace_callback($Expr, function($match) {
261 260
 				//error_log(__METHOD__.__LINE__.array2string($match));
262
-				if ($match[4]==';' && (strlen($match[3])-4) >=0 && strpos($match[3],'&gt',strlen($match[3])-4)!==false)
261
+				if ($match[4] == ';' && (strlen($match[3]) - 4) >= 0 && strpos($match[3], '&gt', strlen($match[3]) - 4) !== false)
263 262
 				{
264
-					$match[3] = substr($match[3],0,strpos($match[3],'&gt',strlen($match[3])-4));
263
+					$match[3] = substr($match[3], 0, strpos($match[3], '&gt', strlen($match[3]) - 4));
265 264
 					$match[4] = "&gt;";
266 265
 				}
267
-				if ($match[4]==';'&&$match[3]=="&gt")
266
+				if ($match[4] == ';' && $match[3] == "&gt")
268 267
 				{
269
-					$match[3] ='';
268
+					$match[3] = '';
270 269
 					$match[4] = "&gt;";
271 270
 				}
272 271
 				//error_log(__METHOD__.__LINE__.array2string($match));
273 272
 				return $match[1]."<a href=\"http://www".$match[2].$match[3]."\" target=\"_blank\">"."www".$match[2].$match[3]."</a>".$match[4];
274
-			}, $result3 );
273
+			}, $result3);
275 274
 
276 275
 		//return preg_replace( $Expr, "<a href=\"http://www$1$2\" target=\"_blank\">www$1$2</a>$3 ", $result );
277 276
 //error_log(__METHOD__.__LINE__.array2string($Expr));
@@ -291,12 +290,12 @@  discard block
 block discarded – undo
291 290
 	 * @param boolean $double_encoding =false do we want double encoding or not, default no
292 291
 	 * @return string
293 292
 	 */
294
-	static function htmlspecialchars($str, $double_encoding=false)
293
+	static function htmlspecialchars($str, $double_encoding = false)
295 294
 	{
296 295
 		//if (!is_scalar($str) && !is_null($str)) error_log(__METHOD__.'('.array2string($str).') '.function_backtrace());
297 296
 		// as EGroupware supports only utf-8 we should not need to worry about wrong charsets
298 297
 		//if (is_array($str)) error_log(__METHOD__.__LINE__.' string expected -> array given:'.array2string($str).'->'.function_backtrace());
299
-		return htmlspecialchars($str,ENT_COMPAT,self::$charset,$double_encoding);
298
+		return htmlspecialchars($str, ENT_COMPAT, self::$charset, $double_encoding);
300 299
 		// we need '&#' unchanged, so we translate it back -> this is provided by 4th param = false -> do not doubleencode
301 300
 		//$str = str_replace(array('&amp;#','&amp;nbsp;','&amp;lt;','&amp;gt;'),array('&#','&nbsp;','&lt;','&gt;'),$str);
302 301
 
@@ -315,36 +314,36 @@  discard block
 block discarded – undo
315 314
 	 * @param boolean $enhanced Use enhanced selectbox with search.  Null for default yes if more than 12 options.
316 315
 	 * @return string to set for a template or to echo into html page
317 316
 	 */
318
-	static function select($name, $key, $arr=0,$no_lang=false,$options='',$multiple=0,$enhanced=null)
317
+	static function select($name, $key, $arr = 0, $no_lang = false, $options = '', $multiple = 0, $enhanced = null)
319 318
 	{
320
-		if(is_null($enhanced)) $enhanced = false;	//disabled by default (count($arr) > self::SELECT_ENHANCED_ROW_COUNT);
319
+		if (is_null($enhanced)) $enhanced = false; //disabled by default (count($arr) > self::SELECT_ENHANCED_ROW_COUNT);
321 320
 
322 321
 		if (!is_array($arr))
323 322
 		{
324
-			$arr = array('no','yes');
323
+			$arr = array('no', 'yes');
325 324
 		}
326 325
 		if ((int)$multiple > 0)
327 326
 		{
328 327
 			$options .= ' multiple="1" size="'.(int)$multiple.'"';
329
-			if (substr($name,-2) != '[]')
328
+			if (substr($name, -2) != '[]')
330 329
 			{
331 330
 				$name .= '[]';
332 331
 			}
333 332
 		}
334
-		elseif($multiple < 0)
333
+		elseif ($multiple < 0)
335 334
 		{
336 335
 			$options .= ' size="'.abs($multiple).'"';
337 336
 		}
338 337
 		// fix width for MSIE < 9 in/for selectboxes
339 338
 		if (self::$user_agent == 'msie' && self::$ua_version < 9)
340 339
 		{
341
-			if (stripos($options,'onfocus="') === false)
340
+			if (stripos($options, 'onfocus="') === false)
342 341
 			{
343 342
 				$options .= ' onfocus="window.dropdown_menu_hack(this);" ';
344 343
 			}
345 344
 			else
346 345
 			{
347
-				$options = str_ireplace('onfocus="','onfocus="window.dropdown_menu_hack(this);',$options);
346
+				$options = str_ireplace('onfocus="', 'onfocus="window.dropdown_menu_hack(this);', $options);
348 347
 			}
349 348
 		}
350 349
 		$out = "<select name=\"$name\" $options>\n";
@@ -352,14 +351,14 @@  discard block
 block discarded – undo
352 351
 		if (!is_array($key))
353 352
 		{
354 353
 			// explode on ',' only if multiple values expected and the key contains just numbers and commas
355
-			$key = $multiple > 0 && preg_match('/^[,0-9]+$/',$key) ? explode(',',$key) : array($key);
354
+			$key = $multiple > 0 && preg_match('/^[,0-9]+$/', $key) ? explode(',', $key) : array($key);
356 355
 		}
357
-		foreach($arr as $k => $data)
356
+		foreach ($arr as $k => $data)
358 357
 		{
359 358
 			if (!is_array($data) || count($data) == 2 && isset($data['label']) && isset($data['title']))
360 359
 			{
361
-				$out .= self::select_option($k,is_array($data)?$data['label']:$data,$key,$no_lang,
362
-					is_array($data)?$data['title']:'');
360
+				$out .= self::select_option($k, is_array($data) ? $data['label'] : $data, $key, $no_lang,
361
+					is_array($data) ? $data['title'] : '');
363 362
 			}
364 363
 			else
365 364
 			{
@@ -370,19 +369,19 @@  discard block
 block discarded – undo
370 369
 				}
371 370
 				$out .= '<optgroup label="'.self::htmlspecialchars($no_lang || $k == '' ? $k : lang($k))."\">\n";
372 371
 
373
-				foreach($data as $k => $label)
372
+				foreach ($data as $k => $label)
374 373
 				{
375
-					$out .= self::select_option($k,is_array($label)?$label['label']:$label,$key,$no_lang,
376
-						is_array($label)?$label['title']:'');
374
+					$out .= self::select_option($k, is_array($label) ? $label['label'] : $label, $key, $no_lang,
375
+						is_array($label) ? $label['title'] : '');
377 376
 				}
378 377
 				$out .= "</optgroup>\n";
379 378
 			}
380 379
 		}
381 380
 		$out .= "</select>\n";
382 381
 
383
-		if($enhanced) {
382
+		if ($enhanced) {
384 383
 			egw_framework::validate_file('/phpgwapi/js/jquery/chosen/chosen.jquery.js');
385
-			egw_framework::includeCSS('/phpgwapi/js/jquery/chosen/chosen.css',null,false);
384
+			egw_framework::includeCSS('/phpgwapi/js/jquery/chosen/chosen.css', null, false);
386 385
 			$out .= "<script>var lab = egw_LAB || \$LAB; lab.wait(function() {\$j(function() {if(\$j().chosen) \$j('select[name=\"$name\"]').chosen({width: '100%'});});})</script>\n";
387 386
 		}
388 387
 		return $out;
@@ -404,39 +403,39 @@  discard block
 block discarded – undo
404 403
 	 * @param string $style ='' extra style settings like "width: 100%", default '' none
405 404
 	 * @return string to set for a template or to echo into html page
406 405
 	 */
407
-	static function checkbox_multiselect($name, $key, $arr=0,$no_lang=false,$options='',$multiple=3,$selected_first=true,$style='',$enhanced = null)
406
+	static function checkbox_multiselect($name, $key, $arr = 0, $no_lang = false, $options = '', $multiple = 3, $selected_first = true, $style = '', $enhanced = null)
408 407
 	{
409 408
 		//echo "<p align=right>checkbox_multiselect('$name',".array2string($key).",".array2string($arr).",$no_lang,'$options',$multiple,$selected_first,'$style')</p>\n";
410
-		if(is_null($enhanced)) $enhanced = (count($arr) > self::SELECT_ENHANCED_ROW_COUNT);
409
+		if (is_null($enhanced)) $enhanced = (count($arr) > self::SELECT_ENHANCED_ROW_COUNT);
411 410
 
412 411
 		if (!is_array($arr))
413 412
 		{
414
-			$arr = array('no','yes');
413
+			$arr = array('no', 'yes');
415 414
 		}
416 415
 		if ((int)$multiple <= 0) $multiple = 1;
417 416
 
418
-		if (substr($name,-2) != '[]')
417
+		if (substr($name, -2) != '[]')
419 418
 		{
420 419
 			$name .= '[]';
421 420
 		}
422
-		$base_name = substr($name,0,-2);
421
+		$base_name = substr($name, 0, -2);
423 422
 
424
-		if($enhanced) return self::select($name, $key, $arr,$no_lang,$options." style=\"$style\" ",$multiple,$enhanced);
423
+		if ($enhanced) return self::select($name, $key, $arr, $no_lang, $options." style=\"$style\" ", $multiple, $enhanced);
425 424
 
426 425
 		if (!is_array($key))
427 426
 		{
428 427
 			// explode on ',' only if multiple values expected and the key contains just numbers and commas
429
-			$key = preg_match('/^[,0-9]+$/',$key) ? explode(',',$key) : array($key);
428
+			$key = preg_match('/^[,0-9]+$/', $key) ? explode(',', $key) : array($key);
430 429
 		}
431 430
 		$html = '';
432
-		$options_no_id = preg_replace('/id="[^"]+"/i','',$options);
431
+		$options_no_id = preg_replace('/id="[^"]+"/i', '', $options);
433 432
 
434 433
 		if ($selected_first)
435 434
 		{
436 435
 			$selected = $not_selected = array();
437
-			foreach($arr as $val => $label)
436
+			foreach ($arr as $val => $label)
438 437
 			{
439
-				if (in_array((string)$val,$key))
438
+				if (in_array((string)$val, $key))
440 439
 				{
441 440
 					$selected[$val] = $label;
442 441
 				}
@@ -448,7 +447,7 @@  discard block
 block discarded – undo
448 447
 			$arr = $selected + $not_selected;
449 448
 		}
450 449
 		$max_len = 0;
451
-		foreach($arr as $val => $label)
450
+		foreach ($arr as $val => $label)
452 451
 		{
453 452
 			if (is_array($label))
454 453
 			{
@@ -464,16 +463,16 @@  discard block
 block discarded – undo
464 463
 
465 464
 			if (strlen($label) > $max_len) $max_len = strlen($label);
466 465
 
467
-			$html .= self::label(self::checkbox($name,in_array((string)$val,$key),$val,$options_no_id.
466
+			$html .= self::label(self::checkbox($name, in_array((string)$val, $key), $val, $options_no_id.
468 467
 				' id="'.$base_name.'['.$val.']'.'"').self::htmlspecialchars($label),
469
-				$base_name.'['.$val.']','',($title ? 'title="'.self::htmlspecialchars($title).'" ':''))."<br />\n";
468
+				$base_name.'['.$val.']', '', ($title ? 'title="'.self::htmlspecialchars($title).'" ' : ''))."<br />\n";
470 469
 		}
471
-		if ($style && substr($style,-1) != ';') $style .= '; ';
472
-		if (strpos($style,'height')===false) $style .= 'height: '.(1.7*$multiple).'em; ';
473
-		if (strpos($style,'width')===false)  $style .= 'width: '.(4+$max_len*($max_len < 15 ? 0.65 : 0.6)).'em; ';
470
+		if ($style && substr($style, -1) != ';') $style .= '; ';
471
+		if (strpos($style, 'height') === false) $style .= 'height: '.(1.7 * $multiple).'em; ';
472
+		if (strpos($style, 'width') === false)  $style .= 'width: '.(4 + $max_len * ($max_len < 15 ? 0.65 : 0.6)).'em; ';
474 473
 		$style .= 'background-color: white; overflow: auto; border: lightgray 2px inset; text-align: left;';
475 474
 
476
-		return self::div($html,$options,'',$style);
475
+		return self::div($html, $options, '', $style);
477 476
 	}
478 477
 
479 478
 	/**
@@ -486,23 +485,23 @@  discard block
 block discarded – undo
486 485
 	 * @param string $extra extra text, e.g.: style="", default: ''
487 486
 	 * @return string html
488 487
 	 */
489
-	static function select_option($value,$label,$selected,$no_lang=0,$title='',$extra='')
488
+	static function select_option($value, $label, $selected, $no_lang = 0, $title = '', $extra = '')
490 489
 	{
491 490
 		// the following compares strict as strings, to archive: '0' == 0 != ''
492 491
 		// the first non-strict search via array_search, is for performance reasons, to not always search the whole array with php
493
-		if (($found = ($key = array_search($value,$selected)) !== false) && (string) $value !== (string) $selected[$key])
492
+		if (($found = ($key = array_search($value, $selected)) !== false) && (string)$value !== (string)$selected[$key])
494 493
 		{
495 494
 			$found = false;
496
-			foreach($selected as $sel)
495
+			foreach ($selected as $sel)
497 496
 			{
498
-				if (($found = (((string) $value) === ((string) $selected[$key])))) break;
497
+				if (($found = (((string)$value) === ((string)$selected[$key])))) break;
499 498
 			}
500 499
 			unset($sel);
501 500
 		}
502
-		return '<option value="'.self::htmlspecialchars($value).'"'.($found  ? ' selected="selected"' : '') .
503
-			($title ? ' title="'.self::htmlspecialchars($no_lang ? $title : lang($title)).'"' : '') .
504
-			($extra ? ' ' . $extra : '') . '>'.
505
-			self::htmlspecialchars($no_lang || $label == '' ? $label : lang($label)) . "</option>\n";
501
+		return '<option value="'.self::htmlspecialchars($value).'"'.($found ? ' selected="selected"' : '').
502
+			($title ? ' title="'.self::htmlspecialchars($no_lang ? $title : lang($title)).'"' : '').
503
+			($extra ? ' '.$extra : '').'>'.
504
+			self::htmlspecialchars($no_lang || $label == '' ? $label : lang($label))."</option>\n";
506 505
 	}
507 506
 
508 507
 	/**
@@ -514,7 +513,7 @@  discard block
 block discarded – undo
514 513
 	 * @param string $style css-styles attribute, default ''=none
515 514
 	 * @return string html
516 515
 	 */
517
-	static function div($content,$options='',$class='',$style='')
516
+	static function div($content, $options = '', $class = '', $style = '')
518 517
 	{
519 518
 		if ($class) $options .= ' class="'.$class.'"';
520 519
 		if ($style) $options .= ' style="'.$style.'"';
@@ -530,13 +529,13 @@  discard block
 block discarded – undo
530 529
 	 * @param boolean $ignore_empty if true all empty, zero (!) or unset values, plus filer=none
531 530
 	 * @param string html
532 531
 	 */
533
-	static function input_hidden($vars,$value='',$ignore_empty=True)
532
+	static function input_hidden($vars, $value = '', $ignore_empty = True)
534 533
 	{
535 534
 		if (!is_array($vars))
536 535
 		{
537
-			$vars = array( $vars => $value );
536
+			$vars = array($vars => $value);
538 537
 		}
539
-		foreach($vars as $name => $value)
538
+		foreach ($vars as $name => $value)
540 539
 		{
541 540
 			if (is_array($value))
542 541
 			{
@@ -559,9 +558,9 @@  discard block
 block discarded – undo
559 558
 	 * @param boolean $double_encoding =false do we want double encoding or not, default no
560 559
 	 * @param string html
561 560
 	 */
562
-	static function textarea($name,$value='',$options='',$double_encoding=false)
561
+	static function textarea($name, $value = '', $options = '', $double_encoding = false)
563 562
 	{
564
-		return "<textarea name=\"$name\" $options>".self::htmlspecialchars($value,$double_encoding)."</textarea>\n";
563
+		return "<textarea name=\"$name\" $options>".self::htmlspecialchars($value, $double_encoding)."</textarea>\n";
565 564
 	}
566 565
 
567 566
 	/**
@@ -584,7 +583,7 @@  discard block
 block discarded – undo
584 583
 	 *
585 584
 	 * creates a textarea inputfield for the htmlarea js-widget (returns the necessary html and js)
586 585
 	 */
587
-	static function htmlarea($name,$content='',$style='',$base_href=''/*,$plugins='',$custom_toolbar='',$set_width_height_in_config=false*/)
586
+	static function htmlarea($name, $content = '', $style = '', $base_href = ''/*,$plugins='',$custom_toolbar='',$set_width_height_in_config=false*/)
588 587
 	{
589 588
 		/*if (!self::htmlarea_availible())
590 589
 		{
@@ -608,16 +607,16 @@  discard block
 block discarded – undo
608 607
 	* @param string $_executeJSAfterInit ='' Javascript to be executed after InstanceReady of CKEditor
609 608
 	* @return string the necessary html for the textarea
610 609
 	*/
611
-	static function fckEditor($_name, $_content, $_mode, $_options=array('toolbar_expanded' =>'true'),
612
-		$_height='400px', $_width='100%',$_start_path='',$_purify=true, $_focusToBody=false, $_executeJSAfterInit='')
610
+	static function fckEditor($_name, $_content, $_mode, $_options = array('toolbar_expanded' =>'true'),
611
+		$_height = '400px', $_width = '100%', $_start_path = '', $_purify = true, $_focusToBody = false, $_executeJSAfterInit = '')
613 612
 	{
614 613
 		if (!self::htmlarea_availible() || $_mode == 'ascii')
615 614
 		{
616
-			return self::textarea($_name,$_content,'style="width: '.$_width.'; height: '.$_height.';" id="'.htmlspecialchars($_name).'"');
615
+			return self::textarea($_name, $_content, 'style="width: '.$_width.'; height: '.$_height.';" id="'.htmlspecialchars($_name).'"');
617 616
 		}
618 617
 
619 618
 		//include the ckeditor js file
620
-		egw_framework::validate_file('ckeditor','ckeditor','phpgwapi');
619
+		egw_framework::validate_file('ckeditor', 'ckeditor', 'phpgwapi');
621 620
 
622 621
 		// run content through htmlpurifier
623 622
 		if ($_purify && !empty($_content))
@@ -634,13 +633,13 @@  discard block
 block discarded – undo
634 633
 		// User preferences
635 634
 		$font = $GLOBALS['egw_info']['user']['preferences']['common']['rte_font'];
636 635
 		$font_size = egw_ckeditor_config::font_size_from_prefs();
637
-		$font_span = '<span '.($font||$font_size?'style=\"':'').($font?'font-family:'.$font.'; ':'').($font_size?'font-size:'.$font_size.'; ':'').'\">';
636
+		$font_span = '<span '.($font || $font_size ? 'style=\"' : '').($font ? 'font-family:'.$font.'; ' : '').($font_size ? 'font-size:'.$font_size.'; ' : '').'\">';
638 637
 		if (empty($font) && empty($font_size)) $font_span = '';
639 638
 
640 639
 		// we need to enable double encoding here, as ckEditor has to undo one level of encoding
641 640
 		// otherwise < and > chars eg. from html markup entered in regular (not source) input, will turn into html!
642 641
 		//error_log(__METHOD__.__LINE__.' '.self::$user_agent.','.self::$ua_version);
643
-		return self::textarea($_name,$_content,'id="'.htmlspecialchars($_name).'"',true).	// true = double encoding
642
+		return self::textarea($_name, $_content, 'id="'.htmlspecialchars($_name).'"', true).// true = double encoding
644 643
 '
645 644
 <script type="text/javascript">
646 645
 window.CKEDITOR_BASEPATH="'.$GLOBALS['egw_info']['server']['webserver_url'].'/phpgwapi/js/ckeditor/";
@@ -653,22 +652,22 @@  discard block
 block discarded – undo
653 652
 		function (ev)
654 653
 		{
655 654
 			//alert("CKEditorLoad:"+"'.$_focusToBody.'");
656
-'.($_focusToBody?'
655
+'.($_focusToBody ? '
657 656
 			ev.editor.focus();':'').'
658 657
 			var d = ev.editor.document;
659 658
 			var r = new CKEDITOR.dom.range(d);
660 659
 			r.collapse(true);
661 660
 			r.selectNodeContents(d.getBody());
662
-			r.collapse('.($_focusToBody==='BOTTOM'?'false':'true').');
663
-			r.select();'.($font_span?'
661
+			r.collapse('.($_focusToBody === 'BOTTOM' ? 'false' : 'true').');
662
+			r.select();'.($font_span ? '
664 663
 			//this stuff is needed, as the above places the caret just before the span tag
665 664
 			var sN = r.startContainer.getNextSourceNode();
666 665
 			//FF is selecting the span with getNextSourceNode, other browsers need to fetch it with getNext
667 666
 			r.selectNodeContents(((typeof sN.getName==="function") && sN.getName()=="span"?r.startContainer.getNextSourceNode():r.startContainer.getNextSourceNode().getNext()));
668 667
 			r.collapse(true);
669
-			r.select();'.'':'').'
668
+			r.select();'.'' : '').'
670 669
 			ev.editor.resize("100%", '.str_replace('px', '', $pxheight).');
671
-'.($_executeJSAfterInit?$_executeJSAfterInit:'').'
670
+'.($_executeJSAfterInit ? $_executeJSAfterInit : '').'
672 671
 		}
673 672
 	);'.
674 673
 	(trim($_content) == '' && $font_span ? 'CKEDITOR.instances["'.$_name.'"].setData("'.$font_span.'&#8203;</span>");' : '').
@@ -693,16 +692,16 @@  discard block
 block discarded – undo
693 692
 	* @param string $_executeJSAfterInit ='' Javascript to be executed after InstanceReady of CKEditor
694 693
 	* @return string the necessary html for the textarea
695 694
 	*/
696
-	static function fckEditorQuick($_name, $_mode, $_content='', $_height='400px', $_width='100%',$_purify=true, $_border='0px',$_focusToBody=false,$_executeJSAfterInit='')
695
+	static function fckEditorQuick($_name, $_mode, $_content = '', $_height = '400px', $_width = '100%', $_purify = true, $_border = '0px', $_focusToBody = false, $_executeJSAfterInit = '')
697 696
 	{
698 697
 		if (!self::htmlarea_availible() || $_mode == 'ascii')
699 698
 		{
700 699
 			//TODO: use self::textarea
701
-			return "<textarea name=\"$_name\" style=\"".($_width?" width:".$_width.';':" width:100%;").($_height?" height:".$_height.';':" height:400px;").($_border?" border:".$_border.';':" border:0px;")."\">$_content</textarea>";
700
+			return "<textarea name=\"$_name\" style=\"".($_width ? " width:".$_width.';' : " width:100%;").($_height ? " height:".$_height.';' : " height:400px;").($_border ? " border:".$_border.';' : " border:0px;")."\">$_content</textarea>";
702 701
 		}
703 702
 		else
704 703
 		{
705
-			return self::fckEditor($_name, $_content, $_mode, array(), $_height, $_width,'',$_purify,$_focusToBody,$_executeJSAfterInit);
704
+			return self::fckEditor($_name, $_content, $_mode, array(), $_height, $_width, '', $_purify, $_focusToBody, $_executeJSAfterInit);
706 705
 		}
707 706
 	}
708 707
 
@@ -714,7 +713,7 @@  discard block
 block discarded – undo
714 713
 	 * @param string $type type, default ''=not specified = text
715 714
 	 * @param string $options attributes for the tag, default ''=none
716 715
 	 */
717
-	static function input($name,$value='',$type='',$options='' )
716
+	static function input($name, $value = '', $type = '', $options = '')
718 717
 	{
719 718
 		switch ((string)$type)
720 719
 		{
@@ -743,12 +742,12 @@  discard block
 block discarded – undo
743 742
 		'cancelled' => '/no(&|\]|$)/',
744 743
 		'ok'     => '/ok(&|\]|$)/',
745 744
 		'close'  => '/close(&|\]|$)/',
746
-		'add'    => '/(add(&|\]|$)|create)/',	// customfields use create*
745
+		'add'    => '/(add(&|\]|$)|create)/', // customfields use create*
747 746
 	);
748 747
 
749 748
 	static protected $default_classes = array(
750
-		'et2_button_cancel'   => '/cancel(&|\]|$)/',	// yellow
751
-		'et2_button_question' => '/(yes|no)(&|\]|$)/',	// yellow
749
+		'et2_button_cancel'   => '/cancel(&|\]|$)/', // yellow
750
+		'et2_button_question' => '/(yes|no)(&|\]|$)/', // yellow
752 751
 		'et2_button_delete'   => '/delete(&|\]|$)/'		// red
753 752
 	);
754 753
 
@@ -765,7 +764,7 @@  discard block
 block discarded – undo
765 764
 	 * @param string $buttontype which type of html button (button|submit), default ='submit'
766 765
 	 * @return string html
767 766
 	 */
768
-	static function submit_button($name,$label,$onClick='',$no_lang=false,$options='',$image='',$app='phpgwapi', $buttontype='submit')
767
+	static function submit_button($name, $label, $onClick = '', $no_lang = false, $options = '', $image = '', $app = 'phpgwapi', $buttontype = 'submit')
769 768
 	{
770 769
 		// workaround for idots and IE button problem (wrong cursor-image)
771 770
 		if (self::$user_agent == 'msie')
@@ -777,11 +776,11 @@  discard block
 block discarded – undo
777 776
 
778 777
 		if ($image != '')
779 778
 		{
780
-			$image = str_replace(array('.gif','.GIF','.png','.PNG'),'',$image);
779
+			$image = str_replace(array('.gif', '.GIF', '.png', '.PNG'), '', $image);
781 780
 
782
-			if (!($path = common::image($app,$image)))
781
+			if (!($path = common::image($app, $image)))
783 782
 			{
784
-				$path = $image;		// name may already contain absolut path
783
+				$path = $image; // name may already contain absolut path
785 784
 			}
786 785
 			$image = ' src="'.$path.'"';
787 786
 			$classes[] = 'image_button';
@@ -790,11 +789,11 @@  discard block
 block discarded – undo
790 789
 		{
791 790
 			$label = lang($label);
792 791
 		}
793
-		if (($accesskey = @strstr($label,'&')) && $accesskey[1] != ' ' &&
794
-			(($pos = strpos($accesskey,';')) === false || $pos > 5))
792
+		if (($accesskey = @strstr($label, '&')) && $accesskey[1] != ' ' &&
793
+			(($pos = strpos($accesskey, ';')) === false || $pos > 5))
795 794
 		{
796
-			$label_u = str_replace('&'.$accesskey[1],'<u>'.$accesskey[1].'</u>',$label);
797
-			$label = str_replace('&','',$label);
795
+			$label_u = str_replace('&'.$accesskey[1], '<u>'.$accesskey[1].'</u>', $label);
796
+			$label = str_replace('&', '', $label);
798 797
 			$options .= ' accesskey="'.$accesskey[1].'" '.$options;
799 798
 		}
800 799
 		else
@@ -802,10 +801,10 @@  discard block
 block discarded – undo
802 801
 			$accesskey = '';
803 802
 			$label_u = $label;
804 803
 		}
805
-		if ($onClick) $options .= ' onclick="'.str_replace('"','\\"',$onClick).'"';
804
+		if ($onClick) $options .= ' onclick="'.str_replace('"', '\\"', $onClick).'"';
806 805
 
807 806
 		// add default background-image to get et2 like buttons
808
-		foreach(self::$default_background_images as $img => $reg_exp)
807
+		foreach (self::$default_background_images as $img => $reg_exp)
809 808
 		{
810 809
 			if (preg_match($reg_exp, $name) && ($url = common::image($GLOBALS['egw_info']['flags']['currentapp'], $img)))
811 810
 			{
@@ -815,7 +814,7 @@  discard block
 block discarded – undo
815 814
 			}
816 815
 		}
817 816
 		// add default class for cancel, delete or yes/no buttons
818
-		foreach(self::$default_classes as $class => $reg_exp)
817
+		foreach (self::$default_classes as $class => $reg_exp)
819 818
 		{
820 819
 			if (preg_match($reg_exp, $name))
821 820
 			{
@@ -849,20 +848,20 @@  discard block
 block discarded – undo
849 848
 	 * @param array|string $vars query or array ('name' => 'value', ...) with query
850 849
 	 * @return string absolut link already run through $phpgw->link
851 850
 	 */
852
-	static function link($_url,$vars='')
851
+	static function link($_url, $vars = '')
853 852
 	{
854 853
 		//echo "<p>html::link(url='$url',vars='"; print_r($vars); echo "')</p>\n";
855 854
 		if (!is_array($vars))
856 855
 		{
857
-			parse_str($vars,$vars);
856
+			parse_str($vars, $vars);
858 857
 		}
859
-		list($url,$v) = explode('?', $_url);	// url may contain additional vars
858
+		list($url, $v) = explode('?', $_url); // url may contain additional vars
860 859
 		if ($v)
861 860
 		{
862
-			parse_str($v,$v);
861
+			parse_str($v, $v);
863 862
 			$vars += $v;
864 863
 		}
865
-		return egw::link($url,$vars);
864
+		return egw::link($url, $vars);
866 865
 	}
867 866
 
868 867
 	/**
@@ -874,9 +873,9 @@  discard block
 block discarded – undo
874 873
 	 * @param string $options attributes for the tag, default ''=none
875 874
 	 * @return string html
876 875
 	 */
877
-	static function checkbox($name,$checked=false,$value='True',$options='')
876
+	static function checkbox($name, $checked = false, $value = 'True', $options = '')
878 877
 	{
879
-		return '<input type="checkbox" name="'.$name.'" value="'.self::htmlspecialchars($value).'"' .($checked ? ' checked="1"' : '') . "$options />\n";
878
+		return '<input type="checkbox" name="'.$name.'" value="'.self::htmlspecialchars($value).'"'.($checked ? ' checked="1"' : '')."$options />\n";
880 879
 	}
881 880
 
882 881
 	/**
@@ -891,7 +890,7 @@  discard block
 block discarded – undo
891 890
 	 * @param string $method method of the form, default 'POST'
892 891
 	 * @return string html
893 892
 	 */
894
-	static function form($content,$hidden_vars,$_url,$url_vars='',$name='',$options='',$method='POST')
893
+	static function form($content, $hidden_vars, $_url, $url_vars = '', $name = '', $options = '', $method = 'POST')
895 894
 	{
896 895
 		$url = $_url ? self::link($_url, $url_vars) : $_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'];
897 896
 		$html = "<form method=\"$method\" ".($name != '' ? "name=\"$name\" " : '')."action=\"$url\" $options>\n";
@@ -918,9 +917,9 @@  discard block
 block discarded – undo
918 917
 	 * @param string $method method of the form, default 'POST'
919 918
 	 * @return string html
920 919
 	 */
921
-	static function form_1button($name,$label,$hidden_vars,$url,$url_vars='',$form_name='',$method='POST')
920
+	static function form_1button($name, $label, $hidden_vars, $url, $url_vars = '', $form_name = '', $method = 'POST')
922 921
 	{
923
-		return self::form(self::submit_button($name,$label),$hidden_vars,$url,$url_vars,$form_name,' style="display: inline-block"',$method);
922
+		return self::form(self::submit_button($name, $label), $hidden_vars, $url, $url_vars, $form_name, ' style="display: inline-block"', $method);
924 923
 	}
925 924
 
926 925
 	const THEAD = 1;
@@ -953,34 +952,34 @@  discard block
 block discarded – undo
953 952
 	 * @param boolean $no_table_tr dont return the table- and outmost tr-tabs, default false=return table+tr
954 953
 	 * @return string with html-code of the table
955 954
 	 */
956
-	static function table($rows,$options = '',$no_table_tr=False)
955
+	static function table($rows, $options = '', $no_table_tr = False)
957 956
 	{
958 957
 		$html = $no_table_tr ? '' : "<table $options>\n";
959 958
 
960 959
 		$part = 0;
961
-		foreach($rows as $key => $row)
960
+		foreach ($rows as $key => $row)
962 961
 		{
963 962
 			if (!is_array($row))
964 963
 			{
965
-				continue;					// parameter
964
+				continue; // parameter
966 965
 			}
967 966
 			// get the current part from the optional 'h' or 'f' prefix of the key
968 967
 			$p = $key[0] == 'h' ? html::THEAD : ($key[0] == 'f' ? html::TFOOT : html::TBODY);
969 968
 			if ($part < $p && ($part || $p < self::TBODY))	// add only allowed and neccessary transitions
970 969
 			{
971 970
 				if ($part) $html .= '</'.self::$part2tag[$part].">\n";
972
-				$html .= '<'.self::$part2tag[$part=$p].">\n";
971
+				$html .= '<'.self::$part2tag[$part = $p].">\n";
973 972
 			}
974 973
 			$html .= $no_table_tr && $key == 1 ? '' : "\t<tr ".$rows['.'.$key].">\n";
975 974
 
976
-			foreach($row as $key => $cell)
975
+			foreach ($row as $key => $cell)
977 976
 			{
978 977
 				if ($key[0] == '.')
979 978
 				{
980
-					continue;				// parameter
979
+					continue; // parameter
981 980
 				}
982
-				$table_pos = strpos($cell,'<table');
983
-				$td_pos = strpos($cell,'<td');
981
+				$table_pos = strpos($cell, '<table');
982
+				$td_pos = strpos($cell, '<td');
984 983
 				if ($td_pos !== False && ($table_pos === False || $td_pos < $table_pos))
985 984
 				{
986 985
 					$html .= $cell;
@@ -1004,7 +1003,7 @@  discard block
 block discarded – undo
1004 1003
 
1005 1004
 		if ($no_table_tr)
1006 1005
 		{
1007
-			$html = substr($html,0,-16);
1006
+			$html = substr($html, 0, -16);
1008 1007
 		}
1009 1008
 		return $html;
1010 1009
 	}
@@ -1016,12 +1015,12 @@  discard block
 block discarded – undo
1016 1015
 	 * @param boolean $no_script if true generate a submit-button if javascript is off
1017 1016
 	 * @return string html
1018 1017
 	 */
1019
-	static function sbox_submit( $sbox,$no_script=false )
1018
+	static function sbox_submit($sbox, $no_script = false)
1020 1019
 	{
1021
-		$html = str_replace('<select','<select onchange="this.form.submit()" ',$sbox);
1020
+		$html = str_replace('<select', '<select onchange="this.form.submit()" ', $sbox);
1022 1021
 		if ($no_script)
1023 1022
 		{
1024
-			$html .= '<noscript>'.self::submit_button('send','>').'</noscript>';
1023
+			$html .= '<noscript>'.self::submit_button('send', '>').'</noscript>';
1025 1024
 		}
1026 1025
 		return $html;
1027 1026
 	}
@@ -1037,11 +1036,11 @@  discard block
 block discarded – undo
1037 1036
 	 * @param string $height height, default 5px
1038 1037
 	 * @return string html
1039 1038
 	 */
1040
-	static function progressbar($_percent, $_title='',$options='',$width='',$color='',$height='' )
1039
+	static function progressbar($_percent, $_title = '', $options = '', $width = '', $color = '', $height = '')
1041 1040
 	{
1042 1041
 		$percent = (int)$_percent;
1043 1042
 		if (!$width) $width = '30px';
1044
-		if (!$height)$height= '5px';
1043
+		if (!$height)$height = '5px';
1045 1044
 		if (!$color) $color = '#D00000';
1046 1045
 		$title = $_title ? self::htmlspecialchars($_title) : $percent.'%';
1047 1046
 
@@ -1051,7 +1050,7 @@  discard block
 block discarded – undo
1051 1050
 		}
1052 1051
 		return '<div class="onlyPrint">'.$title.'</div><div class="noPrint" title="'.$title.'" '.$options.
1053 1052
 			' style="height: '.$height.'; width: '.$width.'; border: 1px solid black; padding: 1px; text-align: left;'.
1054
-			(@stristr($options,'onclick="') ? ' cursor: pointer;' : '').'">'."\n\t".
1053
+			(@stristr($options, 'onclick="') ? ' cursor: pointer;' : '').'">'."\n\t".
1055 1054
 			'<div style="height: '.$height.'; width: '.$percent.'%; background: '.$color.';"></div>'."\n</div>\n";
1056 1055
 	}
1057 1056
 
@@ -1069,32 +1068,32 @@  discard block
 block discarded – undo
1069 1068
 	 * @param string $options further options for the tag, default '' = none
1070 1069
 	 * @return string the html
1071 1070
 	 */
1072
-	static function image( $app,$name,$title='',$options='' )
1071
+	static function image($app, $name, $title = '', $options = '')
1073 1072
 	{
1074 1073
 		if (is_array($name))	// menuaction and other get-vars
1075 1074
 		{
1076
-			$name = $GLOBALS['egw']->link('/index.php',$name);
1075
+			$name = $GLOBALS['egw']->link('/index.php', $name);
1077 1076
 		}
1078
-		if (substr($name,0,5) == 'vfs:/')	// vfs pseudo protocoll
1077
+		if (substr($name, 0, 5) == 'vfs:/')	// vfs pseudo protocoll
1079 1078
 		{
1080
-			$name = egw::link(egw_vfs::download_url(substr($name,4)));
1079
+			$name = egw::link(egw_vfs::download_url(substr($name, 4)));
1081 1080
 		}
1082
-		if ($name[0] == '/' || substr($name,0,7) == 'http://' || substr($name,0,8) == 'https://' || stripos($name,'etemplate/thumbnail.php') )
1081
+		if ($name[0] == '/' || substr($name, 0, 7) == 'http://' || substr($name, 0, 8) == 'https://' || stripos($name, 'etemplate/thumbnail.php'))
1083 1082
 		{
1084
-			if (!($name[0] == '/' || substr($name,0,7) == 'http://' || substr($name,0,8) == 'https://')) $name = '/'.$name;
1083
+			if (!($name[0] == '/' || substr($name, 0, 7) == 'http://' || substr($name, 0, 8) == 'https://')) $name = '/'.$name;
1085 1084
 			$url = $name;
1086 1085
 		}
1087 1086
 		else	// no URL, so try searching the image
1088 1087
 		{
1089
-			$name = str_replace(array('.gif','.GIF','.png','.PNG'),'',$name);
1088
+			$name = str_replace(array('.gif', '.GIF', '.png', '.PNG'), '', $name);
1090 1089
 
1091
-			if (!($url = $GLOBALS['egw']->common->image($app,$name)))
1090
+			if (!($url = $GLOBALS['egw']->common->image($app, $name)))
1092 1091
 			{
1093
-				$url = $name;		// name may already contain absolut path
1092
+				$url = $name; // name may already contain absolut path
1094 1093
 			}
1095
-			if($GLOBALS['egw_info']['server']['webserver_url'])
1094
+			if ($GLOBALS['egw_info']['server']['webserver_url'])
1096 1095
 			{
1097
-				list(,$path) = explode($GLOBALS['egw_info']['server']['webserver_url'],$url);
1096
+				list(,$path) = explode($GLOBALS['egw_info']['server']['webserver_url'], $url);
1098 1097
 
1099 1098
 				if (!is_null($path)) $path = EGW_SERVER_ROOT.$path;
1100 1099
 			}
@@ -1103,12 +1102,12 @@  discard block
 block discarded – undo
1103 1102
 				$path = EGW_SERVER_ROOT.$url;
1104 1103
 			}
1105 1104
 
1106
-			if (is_null($path) || (!@is_readable($path) && stripos($path,'webdav.php')===false))
1105
+			if (is_null($path) || (!@is_readable($path) && stripos($path, 'webdav.php') === false))
1107 1106
 			{
1108 1107
 				// if the image-name is a percentage, use a progressbar
1109
-				if (substr($name,-1) == '%' && is_numeric($percent = substr($name,0,-1)))
1108
+				if (substr($name, -1) == '%' && is_numeric($percent = substr($name, 0, -1)))
1110 1109
 				{
1111
-					return self::progressbar($percent,$title);
1110
+					return self::progressbar($percent, $title);
1112 1111
 				}
1113 1112
 				return $title;
1114 1113
 			}
@@ -1119,12 +1118,12 @@  discard block
 block discarded – undo
1119 1118
 		}
1120 1119
 
1121 1120
 		// This block makes pngfix.js useless, adding a check on disable_pngfix to have pngfix.js do its thing
1122
-		if (self::$user_agent == 'msie' && self::$ua_version < 7.0 && substr($url,-4) == '.png' && ($GLOBALS['egw_info']['user']['preferences']['common']['disable_pngfix'] || !isset($GLOBALS['egw_info']['user']['preferences']['common']['disable_pngfix'])))
1121
+		if (self::$user_agent == 'msie' && self::$ua_version < 7.0 && substr($url, -4) == '.png' && ($GLOBALS['egw_info']['user']['preferences']['common']['disable_pngfix'] || !isset($GLOBALS['egw_info']['user']['preferences']['common']['disable_pngfix'])))
1123 1122
 		{
1124 1123
 			$extra_styles = "display: inline-block; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='$url',sizingMethod='image'); width: 1px; height: 1px;";
1125
-			if (false!==strpos($options,'style="'))
1124
+			if (false !== strpos($options, 'style="'))
1126 1125
 			{
1127
-				$options = str_replace('style="','style="'.$extra_styles, $options);
1126
+				$options = str_replace('style="', 'style="'.$extra_styles, $options);
1128 1127
 			}
1129 1128
 			else
1130 1129
 			{
@@ -1144,24 +1143,24 @@  discard block
 block discarded – undo
1144 1143
 	 * @param string $options attributes for the tag, default ''=none
1145 1144
 	 * @return string the html
1146 1145
 	 */
1147
-	static function a_href( $content,$url,$vars='',$options='')
1146
+	static function a_href($content, $url, $vars = '', $options = '')
1148 1147
 	{
1149 1148
 		if (is_array($url))
1150 1149
 		{
1151 1150
 			$vars = $url;
1152 1151
 			$url = '/index.php';
1153 1152
 		}
1154
-		elseif (strpos($url,'/')===false &&
1155
-			count(explode('.',$url)) >= 3 &&
1156
-			!(strpos($url,'mailto:')!==false ||
1157
-			strpos($url,'://')!==false ||
1158
-			strpos($url,'javascript:')!==false))
1153
+		elseif (strpos($url, '/') === false &&
1154
+			count(explode('.', $url)) >= 3 &&
1155
+			!(strpos($url, 'mailto:') !== false ||
1156
+			strpos($url, '://') !== false ||
1157
+			strpos($url, 'javascript:') !== false))
1159 1158
 		{
1160 1159
 			$url = "/index.php?menuaction=$url";
1161 1160
 		}
1162 1161
 		if ($url[0] == '/')		// link relative to eGW
1163 1162
 		{
1164
-			$url = self::link($url,$vars);
1163
+			$url = self::link($url, $vars);
1165 1164
 		}
1166 1165
 		//echo "<p>html::a_href('".self::htmlspecialchars($content)."','$url',".print_r($vars,True).") = ".self::link($url,$vars)."</p>";
1167 1166
 		return '<a href="'.self::htmlspecialchars($url).'" '.$options.'>'.$content.'</a>';
@@ -1196,7 +1195,7 @@  discard block
 block discarded – undo
1196 1195
 	 * @param string $options attributes for the tag, default ''=none
1197 1196
 	 * @return string the html
1198 1197
 	 */
1199
-	static function hr($width='',$options='')
1198
+	static function hr($width = '', $options = '')
1200 1199
 	{
1201 1200
 		if ($width) $options .= " width=\"$width\"";
1202 1201
 
@@ -1212,12 +1211,12 @@  discard block
 block discarded – undo
1212 1211
 	 * @param mixed $names String (or Array) with the option-names eg. 'WIDTH,HEIGHT,BORDER'
1213 1212
 	 * @return string with options/attributes
1214 1213
 	 */
1215
-	static function formatOptions($options,$names)
1214
+	static function formatOptions($options, $names)
1216 1215
 	{
1217
-		if (!is_array($options)) $options = explode(',',$options);
1218
-		if (!is_array($names))   $names   = explode(',',$names);
1216
+		if (!is_array($options)) $options = explode(',', $options);
1217
+		if (!is_array($names))   $names   = explode(',', $names);
1219 1218
 
1220
-		foreach($options as $n => $val)
1219
+		foreach ($options as $n => $val)
1221 1220
 		{
1222 1221
 			if ($val != '' && $names[$n] != '')
1223 1222
 			{
@@ -1271,7 +1270,7 @@  discard block
 block discarded – undo
1271 1270
 	 * @param string $options attributes for the tag, default ''=none
1272 1271
 	 * @return string the html
1273 1272
 	 */
1274
-	static function label($content,$id='',$accesskey='',$options='')
1273
+	static function label($content, $id = '', $accesskey = '', $options = '')
1275 1274
 	{
1276 1275
 		if ($id != '')
1277 1276
 		{
@@ -1292,7 +1291,7 @@  discard block
 block discarded – undo
1292 1291
 	 * @param string $options attributes for the tag, default ''=none
1293 1292
 	 * @return string the html
1294 1293
 	 */
1295
-	static function fieldset($content,$legend='',$options='')
1294
+	static function fieldset($content, $legend = '', $options = '')
1296 1295
 	{
1297 1296
 		$html = "<fieldset $options>".($legend ? '<legend>'.self::htmlspecialchars($legend).'</legend>' : '')."\n";
1298 1297
 
@@ -1326,9 +1325,9 @@  discard block
 block discarded – undo
1326 1325
 	 *
1327 1326
 	 * @return string the html code, to be added into the template
1328 1327
 	 */
1329
-	static function tree($_folders,$_selected,$_topFolder=false,$_onNodeSelect="null",$tree='foldertree',$_divClass='',
1330
-		$_leafImage='',$_onCheckHandler=false,$delimiter='/',$folderImageDir=null,$autoLoading=null,$dataMode='JSON',
1331
-		$dragndrop=false)
1328
+	static function tree($_folders, $_selected, $_topFolder = false, $_onNodeSelect = "null", $tree = 'foldertree', $_divClass = '',
1329
+		$_leafImage = '', $_onCheckHandler = false, $delimiter = '/', $folderImageDir = null, $autoLoading = null, $dataMode = 'JSON',
1330
+		$dragndrop = false)
1332 1331
 	{
1333 1332
 		$webserver_url = $GLOBALS['egw_info']['server']['webserver_url'];
1334 1333
 		if (empty($folderImageDir))
@@ -1351,7 +1350,7 @@  discard block
 block discarded – undo
1351 1350
 			//error_log(__METHOD__."() setting templated image-path: $folderImageDir");
1352 1351
 		}
1353 1352
 
1354
-		static $tree_initialised=false;
1353
+		static $tree_initialised = false;
1355 1354
 		if (!$tree_initialised)
1356 1355
 		{
1357 1356
 			egw_framework::includeCSS('/phpgwapi/js/dhtmlxtree/codebase/dhtmlxtree.css');
@@ -1361,16 +1360,16 @@  discard block
 block discarded – undo
1361 1360
 			$tree_initialised = true;
1362 1361
 			if (!$_folders && !$autoLoading) return null;
1363 1362
 		}
1364
-		$html = self::div("\n",'id="'.$tree.'"',$_divClass).$html;
1363
+		$html = self::div("\n", 'id="'.$tree.'"', $_divClass).$html;
1365 1364
 		$html .= "<script type='text/javascript'>\n";
1366 1365
 		$html .= "var $tree;";
1367 1366
 		$html .= "egw_LAB.wait(function() {";
1368 1367
 		$html .= "$tree = new dhtmlXTreeObject('$tree','100%','100%',0);\n";
1369
-		$html .= "$tree.parentObject.style.overflow='auto';\n";	// dhtmlXTree constructor has hidden hardcoded
1368
+		$html .= "$tree.parentObject.style.overflow='auto';\n"; // dhtmlXTree constructor has hidden hardcoded
1370 1369
 		if (translation::charset() == 'utf-8') $html .= "if ($tree.setEscapingMode) $tree.setEscapingMode('utf8');\n";
1371 1370
 		$html .= "$tree.setImagePath('$folderImageDir/dhtmlxtree/');\n";
1372 1371
 
1373
-		if($_onCheckHandler)
1372
+		if ($_onCheckHandler)
1374 1373
 		{
1375 1374
 			$html .= "$tree.enableCheckBoxes(1);\n";
1376 1375
 			$html .= "$tree.setOnCheckHandler('$_onCheckHandler');\n";
@@ -1381,7 +1380,7 @@  discard block
 block discarded – undo
1381 1380
 		if ($autoLoading)
1382 1381
 		{
1383 1382
 			$autoLoading = is_array($autoLoading) ?
1384
-				egw::link('/index.php',$autoLoading) : egw::link($autoLoading);
1383
+				egw::link('/index.php', $autoLoading) : egw::link($autoLoading);
1385 1384
 			$html .= "$tree.setXMLAutoLoading('$autoLoading');\n";
1386 1385
 			if ($dataMode != 'XML') $html .= "$tree.setDataMode('$dataMode');\n";
1387 1386
 
@@ -1422,7 +1421,7 @@  discard block
 block discarded – undo
1422 1421
 		}
1423 1422
 		if (is_string($_folders))
1424 1423
 		{
1425
-			switch($dataMode)
1424
+			switch ($dataMode)
1426 1425
 			{
1427 1426
 				case 'JSON':
1428 1427
 					$html .= "$tree.loadJSONObject($_folders);\n"; break;
@@ -1433,10 +1432,10 @@  discard block
 block discarded – undo
1433 1432
 		else
1434 1433
 		{
1435 1434
 			// evtl. remove leading delimiter
1436
-			if ($_selected[0] == $delimiter) $_selected = substr($_selected,1);
1435
+			if ($_selected[0] == $delimiter) $_selected = substr($_selected, 1);
1437 1436
 
1438 1437
 			$n = 0;
1439
-			foreach($_folders as $path => $data)
1438
+			foreach ($_folders as $path => $data)
1440 1439
 			{
1441 1440
 				if (!is_array($data))
1442 1441
 				{
@@ -1448,10 +1447,10 @@  discard block
 block discarded – undo
1448 1447
 				if ($_leafImage)
1449 1448
 				{
1450 1449
 					$image1 = $image2 = $image3 = "'".$_leafImage."'";
1451
-					if (($next_item = array_slice($_folders, $n+1, 1, true)))
1450
+					if (($next_item = array_slice($_folders, $n + 1, 1, true)))
1452 1451
 					{
1453 1452
 						list($next_path) = each($next_item);
1454
-						if (substr($next_path,0,strlen($path)+1) == $path.'/')
1453
+						if (substr($next_path, 0, strlen($path) + 1) == $path.'/')
1455 1454
 						{
1456 1455
 							$image1 = $image2 = $image3 = '0';
1457 1456
 						}
@@ -1462,22 +1461,22 @@  discard block
 block discarded – undo
1462 1461
 					$image1 = $image2 = $image3 = "'".$data['image']."'";
1463 1462
 				}
1464 1463
 				// evtl. remove leading delimiter
1465
-				if ($path[0] == $delimiter) $path = substr($path,1);
1466
-				$folderParts = explode($delimiter,$path);
1464
+				if ($path[0] == $delimiter) $path = substr($path, 1);
1465
+				$folderParts = explode($delimiter, $path);
1467 1466
 
1468 1467
 				//get rightmost folderpart
1469 1468
 				$label = array_pop($folderParts);
1470 1469
 				if (isset($data['label'])) $label = $data['label'];
1471 1470
 
1472 1471
 				// the rest of the array is the name of the parent
1473
-				$parentName = implode((array)$folderParts,$delimiter);
1474
-				if(empty($parentName)) $parentName = $top;
1472
+				$parentName = implode((array)$folderParts, $delimiter);
1473
+				if (empty($parentName)) $parentName = $top;
1475 1474
 
1476 1475
 				$entryOptions = !isset($data['child']) || $data['child'] ? 'CHILD' : '';
1477 1476
 				if ($_onCheckHandler && $_selected)	// check selected items on multi selection
1478 1477
 				{
1479
-					if (!is_array($_selected)) $_selected = explode(',',$_selected);
1480
-					if (array_search("$path",$_selected)!==false) $entryOptions .= ',CHECKED';
1478
+					if (!is_array($_selected)) $_selected = explode(',', $_selected);
1479
+					if (array_search("$path", $_selected) !== false) $entryOptions .= ',CHECKED';
1481 1480
 					//echo "<p>path=$path, _selected=".print_r($_selected,true).": $entryOptions</p>\n";
1482 1481
 				}
1483 1482
 				// highlight current item
@@ -1497,7 +1496,7 @@  discard block
 block discarded – undo
1497 1496
 		$html .= "$tree.closeAllItems(0);\n";
1498 1497
 		if ($_selected)
1499 1498
 		{
1500
-			foreach(is_array($_selected)?$_selected:array($_selected) as $path)
1499
+			foreach (is_array($_selected) ? $_selected : array($_selected) as $path)
1501 1500
 			{
1502 1501
 				$html .= "$tree.openItem('".addslashes($path)."');\n";
1503 1502
 			}
@@ -1522,15 +1521,15 @@  discard block
 block discarded – undo
1522 1521
 	 *		or to restrict the attribute's values
1523 1522
 	 * @param boolean $_force =null - force the config passed to be used without merging to the default
1524 1523
 	 */
1525
-	static function purify($html,$config=null,$spec=array(),$_force=false)
1524
+	static function purify($html, $config = null, $spec = array(), $_force = false)
1526 1525
 	{
1527
-		$defaultConfig = array('valid_xhtml'=>1,'safe'=>1);
1526
+		$defaultConfig = array('valid_xhtml'=>1, 'safe'=>1);
1528 1527
 
1529
-		if (empty($html)) return $html;	// no need to process further
1528
+		if (empty($html)) return $html; // no need to process further
1530 1529
 		if (!empty($config) && is_string($config))
1531 1530
 		{
1532 1531
 			//error_log(__METHOD__.__LINE__.$config);
1533
-			$config = json_decode($config,true);
1532
+			$config = json_decode($config, true);
1534 1533
 			if (is_null($config)) error_log(__METHOD__.__LINE__." decoding of config failed; standard will be applied");
1535 1534
 		}
1536 1535
 
@@ -1540,15 +1539,15 @@  discard block
 block discarded – undo
1540 1539
 
1541 1540
 		// Check for "blank" = just user preference span - for some reason we can't match on the entity, so approximate
1542 1541
 		$regex = '#^<span style="font-family:'.$font.';font-size:'.$font_size.';">.?</span>$#us';
1543
-		if(preg_match($regex,$html))
1542
+		if (preg_match($regex, $html))
1544 1543
 		{
1545 1544
 			return '';
1546 1545
 		}
1547 1546
 		$htmLawed = new egw_htmLawed();
1548
-		if (is_array($config) && $_force===false) $config = array_merge($defaultConfig, $config);
1547
+		if (is_array($config) && $_force === false) $config = array_merge($defaultConfig, $config);
1549 1548
 		if (empty($config)) $config = $defaultConfig;
1550 1549
 		//error_log(__METHOD__.__LINE__.array2string($config));
1551
-		return $htmLawed->egw_htmLawed($html,$config,$spec);
1550
+		return $htmLawed->egw_htmLawed($html, $config, $spec);
1552 1551
 	}
1553 1552
 
1554 1553
 	/**
@@ -1569,7 +1568,7 @@  discard block
 block discarded – undo
1569 1568
 	 * @param boolean $force_download =true send content-disposition attachment header
1570 1569
 	 * @param boolean $no_content_type =false do not send actual content-type and content-length header, just content-disposition
1571 1570
 	 */
1572
-	public static function safe_content_header(&$content, $path, &$mime='', &$length=0, $nocache=true, $force_download=true, $no_content_type=false)
1571
+	public static function safe_content_header(&$content, $path, &$mime = '', &$length = 0, $nocache = true, $force_download = true, $no_content_type = false)
1573 1572
 	{
1574 1573
 		// change old/aliased mime-types to new one, eg. image/pdf to application/pdf
1575 1574
 		$mime = mime_magic::fix_mime_type($mime);
@@ -1584,7 +1583,7 @@  discard block
 block discarded – undo
1584 1583
 			if (html::$user_agent == 'chrome' || html::$user_agent == 'msie' && html::$ua_version >= 8)
1585 1584
 			{
1586 1585
 				$mime = 'text/plain';
1587
-				header('X-Content-Type-Options: nosniff');	// stop IE & Chrome from content-type sniffing
1586
+				header('X-Content-Type-Options: nosniff'); // stop IE & Chrome from content-type sniffing
1588 1587
 			}
1589 1588
 			// for the rest we change mime-type to text/html and let code below handle it safely
1590 1589
 			// this stops Safari and Firefox from using it as src attribute in a script tag
@@ -1596,7 +1595,7 @@  discard block
 block discarded – undo
1596 1595
 				{
1597 1596
 					$data = fread($content, $length);
1598 1597
 					fclose($content);
1599
-					$content =& $data;
1598
+					$content = & $data;
1600 1599
 					unset($data);
1601 1600
 				}
1602 1601
 				$content = '<pre>'.$content;
@@ -1610,12 +1609,12 @@  discard block
 block discarded – undo
1610 1609
 			if (html::$user_agent == 'chrome' && html::$ua_version >= 24 ||
1611 1610
 				// mobile FF 24 on Android does NOT honor CSP!
1612 1611
 				html::$user_agent == 'firefox' && !html::$ua_mobile && html::$ua_version >= 24 ||
1613
-				html::$user_agent == 'safari' && !html::$ua_mobile && html::$ua_version >= 536 ||	// OS X
1612
+				html::$user_agent == 'safari' && !html::$ua_mobile && html::$ua_version >= 536 || // OS X
1614 1613
 				html::$user_agent == 'safari' && html::$ua_mobile && html::$ua_version >= 9537)	// iOS 7
1615 1614
 			{
1616
-				$csp = "script-src 'none'";	// forbid to execute any javascript
1615
+				$csp = "script-src 'none'"; // forbid to execute any javascript
1617 1616
 				header("Content-Security-Policy: $csp");
1618
-				header("X-Webkit-CSP: $csp");	// Chrome: <= 24, Safari incl. iOS
1617
+				header("X-Webkit-CSP: $csp"); // Chrome: <= 24, Safari incl. iOS
1619 1618
 				//header("X-Content-Security-Policy: $csp");	// FF <= 22
1620 1619
 				//error_log(__METHOD__."('$options[path]') ".html::$user_agent.'/'.html::$ua_version.(html::$ua_mobile?'/mobile':'').": using Content-Security-Policy: $csp");
1621 1620
 			}
@@ -1648,25 +1647,25 @@  discard block
 block discarded – undo
1648 1647
 	 * @param boolean $nocache =true send headers to disallow browser/proxies to cache the download
1649 1648
 	 * @param boolean $forceDownload =true send headers to handle as attachment/download
1650 1649
 	 */
1651
-	public static function content_header($fn,$mime='',$length=0,$nocache=True,$forceDownload=true)
1650
+	public static function content_header($fn, $mime = '', $length = 0, $nocache = True, $forceDownload = true)
1652 1651
 	{
1653 1652
 		// if no mime-type is given or it's the default binary-type, guess it from the extension
1654
-		if(empty($mime) || $mime == 'application/octet-stream')
1653
+		if (empty($mime) || $mime == 'application/octet-stream')
1655 1654
 		{
1656 1655
 			$mime = mime_magic::filename2mime($fn);
1657 1656
 		}
1658
-		if($fn)
1657
+		if ($fn)
1659 1658
 		{
1660 1659
 			// Show this for all
1661
-			self::content_disposition_header($fn,$forceDownload);
1660
+			self::content_disposition_header($fn, $forceDownload);
1662 1661
 			header('Content-type: '.$mime);
1663 1662
 
1664
-			if($length)
1663
+			if ($length)
1665 1664
 			{
1666 1665
 				header('Content-length: '.$length);
1667 1666
 			}
1668 1667
 
1669
-			if($nocache)
1668
+			if ($nocache)
1670 1669
 			{
1671 1670
 				header('Pragma: no-cache');
1672 1671
 				header('Pragma: public');
@@ -1682,7 +1681,7 @@  discard block
 block discarded – undo
1682 1681
 	 * @param string $fn filename
1683 1682
 	 * @param boolean $forceDownload =true send headers to handle as attachment/download
1684 1683
 	 */
1685
-	public static function content_disposition_header($fn,$forceDownload=true)
1684
+	public static function content_disposition_header($fn, $forceDownload = true)
1686 1685
 	{
1687 1686
 		if ($forceDownload)
1688 1687
 		{
@@ -1705,30 +1704,30 @@  discard block
 block discarded – undo
1705 1704
 	static function splithtmlByPRE($html)
1706 1705
 	{
1707 1706
 		$searchFor = '<pre ';
1708
-		$pos = stripos($html,$searchFor);
1709
-		if ($pos===false)
1707
+		$pos = stripos($html, $searchFor);
1708
+		if ($pos === false)
1710 1709
 		{
1711 1710
 			$searchFor = '<pre>';
1712
-			$pos = stripos($html,$searchFor);
1711
+			$pos = stripos($html, $searchFor);
1713 1712
 		}
1714 1713
 		if ($pos === false)
1715 1714
 		{
1716 1715
 			return $html;
1717 1716
 		}
1718
-		$html2ret[] = substr($html,0,$pos);
1719
-		while ($pos!==false)
1717
+		$html2ret[] = substr($html, 0, $pos);
1718
+		while ($pos !== false)
1720 1719
 		{
1721
-			$endofpre = stripos($html,'</pre>',$pos);
1722
-			$length = $endofpre-$pos+6;
1723
-			$html2ret[] = substr($html,$pos,$length);
1720
+			$endofpre = stripos($html, '</pre>', $pos);
1721
+			$length = $endofpre - $pos + 6;
1722
+			$html2ret[] = substr($html, $pos, $length);
1724 1723
 			$searchFor = '<pre ';
1725
-			$pos = stripos($html,$searchFor, $endofpre+6);
1726
-			if ($pos===false)
1724
+			$pos = stripos($html, $searchFor, $endofpre + 6);
1725
+			if ($pos === false)
1727 1726
 			{
1728 1727
 				$searchFor = '<pre>';
1729
-				$pos = stripos($html,$searchFor, $endofpre+6);
1728
+				$pos = stripos($html, $searchFor, $endofpre + 6);
1730 1729
 			}
1731
-			$html2ret[] = ($pos ? substr($html,$endofpre+6,$pos-($endofpre+6)): substr($html,$endofpre+6));
1730
+			$html2ret[] = ($pos ? substr($html, $endofpre + 6, $pos - ($endofpre + 6)) : substr($html, $endofpre + 6));
1732 1731
 			//$pos=false;
1733 1732
 		}
1734 1733
 		//error_log(__METHOD__.__LINE__.array2string($html2ret));
@@ -1744,16 +1743,16 @@  discard block
 block discarded – undo
1744 1743
 	 */
1745 1744
 	static function getStyles(&$html)
1746 1745
 	{
1747
-		$ct=0;
1746
+		$ct = 0;
1748 1747
 		$newStyle = null;
1749
-		if (stripos($html,'<style')!==false)  $ct = preg_match_all('#<style(?:\s.*)?>(.+)</style>#isU', $html, $newStyle);
1750
-		if ($ct>0)
1748
+		if (stripos($html, '<style') !== false)  $ct = preg_match_all('#<style(?:\s.*)?>(.+)</style>#isU', $html, $newStyle);
1749
+		if ($ct > 0)
1751 1750
 		{
1752 1751
 			//error_log(__METHOD__.__LINE__.array2string($newStyle[0]));
1753
-			$style2buffer = implode('',$newStyle[0]);
1752
+			$style2buffer = implode('', $newStyle[0]);
1754 1753
 			// only replace what we have found, we use it here, as we use the same routine in translation::replaceTagsCompletley
1755 1754
 			// no need to do the extra routine
1756
-			$html = str_ireplace($newStyle[0],'',$html);
1755
+			$html = str_ireplace($newStyle[0], '', $html);
1757 1756
 		}
1758 1757
 		if ($style2buffer)
1759 1758
 		{
@@ -1761,7 +1760,7 @@  discard block
 block discarded – undo
1761 1760
 			$test = json_encode($style2buffer);
1762 1761
 			//error_log(__METHOD__.__LINE__.'#'.$test.'# ->'.strlen($style2buffer).' Error:'.json_last_error());
1763 1762
 			//if (json_last_error() != JSON_ERROR_NONE && strlen($style2buffer)>0)
1764
-			if ($test=="null" && strlen($style2buffer)>0)
1763
+			if ($test == "null" && strlen($style2buffer) > 0)
1765 1764
 			{
1766 1765
 				// this should not be needed, unless something fails with charset detection/ wrong charset passed
1767 1766
 				error_log(__METHOD__.__LINE__.' Found Invalid sequence for utf-8 in CSS:'.$style2buffer.' Carset Detected:'.translation::detect_encoding($style2buffer));
@@ -1771,19 +1770,19 @@  discard block
 block discarded – undo
1771 1770
 		$style .= $style2buffer;
1772 1771
 		// clean out comments and stuff
1773 1772
 		$search = array(
1774
-			'@url\(http:\/\/[^\)].*?\)@si',  // url calls e.g. in style definitions
1773
+			'@url\(http:\/\/[^\)].*?\)@si', // url calls e.g. in style definitions
1775 1774
 //			'@<!--[\s\S]*?[ \t\n\r]*-->@',   // Strip multi-line comments including CDATA
1776 1775
 //			'@<!--[\s\S]*?[ \t\n\r]*--@',    // Strip broken multi-line comments including CDATA
1777 1776
 		);
1778
-		$style = preg_replace($search,"",$style);
1777
+		$style = preg_replace($search, "", $style);
1779 1778
 
1780 1779
 		// CSS Security
1781 1780
 		// http://code.google.com/p/browsersec/wiki/Part1#Cascading_stylesheets
1782
-		$css = preg_replace('/(javascript|expession|-moz-binding)/i','',$style);
1783
-		if (stripos($css,'script')!==false) translation::replaceTagsCompletley($css,'script'); // Strip out script that may be included
1781
+		$css = preg_replace('/(javascript|expession|-moz-binding)/i', '', $style);
1782
+		if (stripos($css, 'script') !== false) translation::replaceTagsCompletley($css, 'script'); // Strip out script that may be included
1784 1783
 		// we need this, as styledefinitions are enclosed with curly brackets; and template stuff tries to replace everything between curly brackets that is having no horizontal whitespace
1785 1784
 		// as the comments as <!-- styledefinition --> in stylesheet are outdated, and ck-editor does not understand it, we remove it
1786
-		$css_no_comment = str_replace(array(':','<!--','-->'),array(': ','',''),$css);
1785
+		$css_no_comment = str_replace(array(':', '<!--', '-->'), array(': ', '', ''), $css);
1787 1786
 		//error_log(__METHOD__.__LINE__.$css);
1788 1787
 		// we already removed what we have found, above, as we used pretty much the same routine as in translation::replaceTagsCompletley
1789 1788
 		// no need to do the extra routine
Please login to merge, or discard this patch.
Braces   +233 added lines, -60 removed lines patch added patch discarded remove patch
@@ -77,7 +77,10 @@  discard block
 block discarded – undo
77 77
 			}
78 78
 		}
79 79
 		list(,self::$user_agent,self::$ua_version) = $parts;
80
-		if ((self::$user_agent = strtolower(self::$user_agent)) == 'version') self::$user_agent = 'opera';
80
+		if ((self::$user_agent = strtolower(self::$user_agent)) == 'version')
81
+		{
82
+			self::$user_agent = 'opera';
83
+		}
81 84
 		// IE no longer reports MSIE, but "Trident/7.0; rv:11.0"
82 85
 		if (self::$user_agent=='trident')
83 86
 		{
@@ -152,7 +155,10 @@  discard block
 block discarded – undo
152 155
 		// tell egw_framework to include wz_tooltip.js
153 156
 		$GLOBALS['egw_info']['flags']['include_wz_tooltip'] = true;
154 157
 
155
-		if ($do_lang) $text = lang($text);
158
+		if ($do_lang)
159
+		{
160
+			$text = lang($text);
161
+		}
156 162
 
157 163
 		$ttip = 'Tip(\''.str_replace(array("\n","\r","'",'"'),array('','',"\\'",'&quot;'),$text).'\'';
158 164
 
@@ -162,7 +168,10 @@  discard block
 block discarded – undo
162 168
 			foreach($options as $option => $value)
163 169
 			{
164 170
 				$option = strtoupper($option);
165
-				if ($option == 'STICKY') $sticky = (bool)$value;
171
+				if ($option == 'STICKY')
172
+				{
173
+					$sticky = (bool)$value;
174
+				}
166 175
 
167 176
 				switch(gettype($value))
168 177
 				{
@@ -170,7 +179,10 @@  discard block
 block discarded – undo
170 179
 						$value = $value ? 'true' : 'false';
171 180
 						break;
172 181
 					case 'string':
173
-						if (stripos($value,"'")===false) $value = "'$value'";
182
+						if (stripos($value,"'")===false)
183
+						{
184
+							$value = "'$value'";
185
+						}
174 186
 						break;
175 187
 				}
176 188
 				$ttip .= ','.$option.','.$value;
@@ -192,7 +204,11 @@  discard block
 block discarded – undo
192 204
 	 */
193 205
 	static function activate_links($content)
194 206
 	{
195
-		if (!$content || strlen($content) < 20) return $content;	// performance
207
+		if (!$content || strlen($content) < 20)
208
+		{
209
+			return $content;
210
+		}
211
+		// performance
196 212
 
197 213
 		// Exclude everything which is already a link
198 214
 		$NotAnchor = '(?<!"|href=|href\s=\s|href=\s|href\s=)';
@@ -212,7 +228,8 @@  discard block
 block discarded – undo
212 228
 		$optBracket = '(>|&gt;)';
213 229
 		$Expr = '/' .$optBracket0. $NotAnchor . $Protocol . $Domain . $Subdir . $optBracket . '/i';
214 230
 		// use preg_replace_callback as we experienced problems with https links
215
-		$result2 = preg_replace_callback( $Expr, function ($match) {
231
+		$result2 = preg_replace_callback( $Expr, function ($match)
232
+		{
216 233
 				//error_log(__METHOD__.__LINE__.array2string($match));
217 234
 				return $match[1]."<a href=\"".($match[2]&&!$match[3]?$match[2]:'').($match[3]?$match[3]:'').$match[4].$match[5]."\" target=\"_blank\">".$match[4].$match[5]."</a>".$match[6];
218 235
 			}, $result );
@@ -225,7 +242,8 @@  discard block
 block discarded – undo
225 242
 		$optStuff = '(&quot;|&quot|;)?';
226 243
 		$Expr = '/' . $NotAnchor . $Protocol . $Domain . $Subdir . $optStuff . '/i';
227 244
 		// use preg_replace_callback as we experienced problems with https links
228
-		$result3 = preg_replace_callback( $Expr, function ($match) {
245
+		$result3 = preg_replace_callback( $Expr, function ($match)
246
+		{
229 247
 				$additionalQuote="";//at the end, ...
230 248
 				// only one &quot at the end is found. chance is, it is not belonging to the URL
231 249
 				if ($match[5]==';' && (strlen($match[4])-6) >=0 && strpos($match[4],'&quot',strlen($match[4])-6)!==false && strpos(substr($match[4],0,strlen($match[4])-6),'&quot')===false)
@@ -257,7 +275,8 @@  discard block
 block discarded – undo
257 275
 		$Expr = '/' .$optBracket0. $NotAnchor . $NotHTTP . $Domain2 . $Subdir2 .$optBracket. '/i';
258 276
 		//$Expr = '/' . $NotAnchor . $NotHTTP . $Domain . $Subdir . $optBracket . '/i';
259 277
 		// use preg_replace_callback as we experienced problems with links such as <www.example.tld/pfad/zu/einer/pdf-Datei.pdf>
260
-		$result4 = preg_replace_callback( $Expr, function ($match) {
278
+		$result4 = preg_replace_callback( $Expr, function ($match)
279
+		{
261 280
 				//error_log(__METHOD__.__LINE__.array2string($match));
262 281
 				if ($match[4]==';' && (strlen($match[3])-4) >=0 && strpos($match[3],'&gt',strlen($match[3])-4)!==false)
263 282
 				{
@@ -317,7 +336,11 @@  discard block
 block discarded – undo
317 336
 	 */
318 337
 	static function select($name, $key, $arr=0,$no_lang=false,$options='',$multiple=0,$enhanced=null)
319 338
 	{
320
-		if(is_null($enhanced)) $enhanced = false;	//disabled by default (count($arr) > self::SELECT_ENHANCED_ROW_COUNT);
339
+		if(is_null($enhanced))
340
+		{
341
+			$enhanced = false;
342
+		}
343
+		//disabled by default (count($arr) > self::SELECT_ENHANCED_ROW_COUNT);
321 344
 
322 345
 		if (!is_array($arr))
323 346
 		{
@@ -380,7 +403,8 @@  discard block
 block discarded – undo
380 403
 		}
381 404
 		$out .= "</select>\n";
382 405
 
383
-		if($enhanced) {
406
+		if($enhanced)
407
+		{
384 408
 			egw_framework::validate_file('/phpgwapi/js/jquery/chosen/chosen.jquery.js');
385 409
 			egw_framework::includeCSS('/phpgwapi/js/jquery/chosen/chosen.css',null,false);
386 410
 			$out .= "<script>var lab = egw_LAB || \$LAB; lab.wait(function() {\$j(function() {if(\$j().chosen) \$j('select[name=\"$name\"]').chosen({width: '100%'});});})</script>\n";
@@ -407,13 +431,19 @@  discard block
 block discarded – undo
407 431
 	static function checkbox_multiselect($name, $key, $arr=0,$no_lang=false,$options='',$multiple=3,$selected_first=true,$style='',$enhanced = null)
408 432
 	{
409 433
 		//echo "<p align=right>checkbox_multiselect('$name',".array2string($key).",".array2string($arr).",$no_lang,'$options',$multiple,$selected_first,'$style')</p>\n";
410
-		if(is_null($enhanced)) $enhanced = (count($arr) > self::SELECT_ENHANCED_ROW_COUNT);
434
+		if(is_null($enhanced))
435
+		{
436
+			$enhanced = (count($arr) > self::SELECT_ENHANCED_ROW_COUNT);
437
+		}
411 438
 
412 439
 		if (!is_array($arr))
413 440
 		{
414 441
 			$arr = array('no','yes');
415 442
 		}
416
-		if ((int)$multiple <= 0) $multiple = 1;
443
+		if ((int)$multiple <= 0)
444
+		{
445
+			$multiple = 1;
446
+		}
417 447
 
418 448
 		if (substr($name,-2) != '[]')
419 449
 		{
@@ -421,7 +451,10 @@  discard block
 block discarded – undo
421 451
 		}
422 452
 		$base_name = substr($name,0,-2);
423 453
 
424
-		if($enhanced) return self::select($name, $key, $arr,$no_lang,$options." style=\"$style\" ",$multiple,$enhanced);
454
+		if($enhanced)
455
+		{
456
+			return self::select($name, $key, $arr,$no_lang,$options." style=\"$style\" ",$multiple,$enhanced);
457
+		}
425 458
 
426 459
 		if (!is_array($key))
427 460
 		{
@@ -459,18 +492,36 @@  discard block
 block discarded – undo
459 492
 			{
460 493
 				$title = '';
461 494
 			}
462
-			if ($label && !$no_lang) $label = lang($label);
463
-			if ($title && !$no_lang) $title = lang($title);
495
+			if ($label && !$no_lang)
496
+			{
497
+				$label = lang($label);
498
+			}
499
+			if ($title && !$no_lang)
500
+			{
501
+				$title = lang($title);
502
+			}
464 503
 
465
-			if (strlen($label) > $max_len) $max_len = strlen($label);
504
+			if (strlen($label) > $max_len)
505
+			{
506
+				$max_len = strlen($label);
507
+			}
466 508
 
467 509
 			$html .= self::label(self::checkbox($name,in_array((string)$val,$key),$val,$options_no_id.
468 510
 				' id="'.$base_name.'['.$val.']'.'"').self::htmlspecialchars($label),
469 511
 				$base_name.'['.$val.']','',($title ? 'title="'.self::htmlspecialchars($title).'" ':''))."<br />\n";
470 512
 		}
471
-		if ($style && substr($style,-1) != ';') $style .= '; ';
472
-		if (strpos($style,'height')===false) $style .= 'height: '.(1.7*$multiple).'em; ';
473
-		if (strpos($style,'width')===false)  $style .= 'width: '.(4+$max_len*($max_len < 15 ? 0.65 : 0.6)).'em; ';
513
+		if ($style && substr($style,-1) != ';')
514
+		{
515
+			$style .= '; ';
516
+		}
517
+		if (strpos($style,'height')===false)
518
+		{
519
+			$style .= 'height: '.(1.7*$multiple).'em; ';
520
+		}
521
+		if (strpos($style,'width')===false)
522
+		{
523
+			$style .= 'width: '.(4+$max_len*($max_len < 15 ? 0.65 : 0.6)).'em; ';
524
+		}
474 525
 		$style .= 'background-color: white; overflow: auto; border: lightgray 2px inset; text-align: left;';
475 526
 
476 527
 		return self::div($html,$options,'',$style);
@@ -495,7 +546,10 @@  discard block
 block discarded – undo
495 546
 			$found = false;
496 547
 			foreach($selected as $sel)
497 548
 			{
498
-				if (($found = (((string) $value) === ((string) $selected[$key])))) break;
549
+				if (($found = (((string) $value) === ((string) $selected[$key]))))
550
+				{
551
+					break;
552
+				}
499 553
 			}
500 554
 			unset($sel);
501 555
 		}
@@ -516,8 +570,14 @@  discard block
 block discarded – undo
516 570
 	 */
517 571
 	static function div($content,$options='',$class='',$style='')
518 572
 	{
519
-		if ($class) $options .= ' class="'.$class.'"';
520
-		if ($style) $options .= ' style="'.$style.'"';
573
+		if ($class)
574
+		{
575
+			$options .= ' class="'.$class.'"';
576
+		}
577
+		if ($style)
578
+		{
579
+			$options .= ' style="'.$style.'"';
580
+		}
521 581
 
522 582
 		return "<div $options>\n".($content ? "$content</div>\n" : '');
523 583
 	}
@@ -542,10 +602,13 @@  discard block
 block discarded – undo
542 602
 			{
543 603
 				$value = json_encode($value);
544 604
 			}
545
-			if (!$ignore_empty || $value && !($name == 'filter' && $value == 'none'))	// dont need to send all the empty vars
605
+			if (!$ignore_empty || $value && !($name == 'filter' && $value == 'none'))
606
+			{
607
+				// dont need to send all the empty vars
546 608
 			{
547 609
 				$html .= "<input type=\"hidden\" name=\"$name\" value=\"".self::htmlspecialchars($value)."\" />\n";
548 610
 			}
611
+			}
549 612
 		}
550 613
 		return $html;
551 614
 	}
@@ -621,7 +684,9 @@  discard block
 block discarded – undo
621 684
 
622 685
 		// run content through htmlpurifier
623 686
 		if ($_purify && !empty($_content))
624
-			$_content = self::purify($_content);
687
+		{
688
+					$_content = self::purify($_content);
689
+		}
625 690
 
626 691
 		// By default the editor start expanded
627 692
 		$expanded = isset($_options['toolbar_expanded']) ?
@@ -635,7 +700,10 @@  discard block
 block discarded – undo
635 700
 		$font = $GLOBALS['egw_info']['user']['preferences']['common']['rte_font'];
636 701
 		$font_size = egw_ckeditor_config::font_size_from_prefs();
637 702
 		$font_span = '<span '.($font||$font_size?'style=\"':'').($font?'font-family:'.$font.'; ':'').($font_size?'font-size:'.$font_size.'; ':'').'\">';
638
-		if (empty($font) && empty($font_size)) $font_span = '';
703
+		if (empty($font) && empty($font_size))
704
+		{
705
+			$font_span = '';
706
+		}
639 707
 
640 708
 		// we need to enable double encoding here, as ckEditor has to undo one level of encoding
641 709
 		// otherwise < and > chars eg. from html markup entered in regular (not source) input, will turn into html!
@@ -802,7 +870,10 @@  discard block
 block discarded – undo
802 870
 			$accesskey = '';
803 871
 			$label_u = $label;
804 872
 		}
805
-		if ($onClick) $options .= ' onclick="'.str_replace('"','\\"',$onClick).'"';
873
+		if ($onClick)
874
+		{
875
+			$options .= ' onclick="'.str_replace('"','\\"',$onClick).'"';
876
+		}
806 877
 
807 878
 		// add default background-image to get et2 like buttons
808 879
 		foreach(self::$default_background_images as $img => $reg_exp)
@@ -966,9 +1037,12 @@  discard block
 block discarded – undo
966 1037
 			}
967 1038
 			// get the current part from the optional 'h' or 'f' prefix of the key
968 1039
 			$p = $key[0] == 'h' ? html::THEAD : ($key[0] == 'f' ? html::TFOOT : html::TBODY);
969
-			if ($part < $p && ($part || $p < self::TBODY))	// add only allowed and neccessary transitions
1040
+			if ($part < $p && ($part || $p < self::TBODY))
1041
+			{
1042
+				// add only allowed and neccessary transitions
970 1043
 			{
971 1044
 				if ($part) $html .= '</'.self::$part2tag[$part].">\n";
1045
+			}
972 1046
 				$html .= '<'.self::$part2tag[$part=$p].">\n";
973 1047
 			}
974 1048
 			$html .= $no_table_tr && $key == 1 ? '' : "\t<tr ".$rows['.'.$key].">\n";
@@ -996,10 +1070,13 @@  discard block
 block discarded – undo
996 1070
 		{
997 1071
 			echo "<p>".function_backtrace()."</p>\n";
998 1072
 		}
999
-		if ($part)	// close current part
1073
+		if ($part)
1074
+		{
1075
+			// close current part
1000 1076
 		{
1001 1077
 			$html .= "</".self::$part2tag[$part].">\n";
1002 1078
 		}
1079
+		}
1003 1080
 		$html .= "</table>\n";
1004 1081
 
1005 1082
 		if ($no_table_tr)
@@ -1040,9 +1117,18 @@  discard block
 block discarded – undo
1040 1117
 	static function progressbar($_percent, $_title='',$options='',$width='',$color='',$height='' )
1041 1118
 	{
1042 1119
 		$percent = (int)$_percent;
1043
-		if (!$width) $width = '30px';
1044
-		if (!$height)$height= '5px';
1045
-		if (!$color) $color = '#D00000';
1120
+		if (!$width)
1121
+		{
1122
+			$width = '30px';
1123
+		}
1124
+		if (!$height)
1125
+		{
1126
+			$height= '5px';
1127
+		}
1128
+		if (!$color)
1129
+		{
1130
+			$color = '#D00000';
1131
+		}
1046 1132
 		$title = $_title ? self::htmlspecialchars($_title) : $percent.'%';
1047 1133
 
1048 1134
 		if (self::$netscape4)
@@ -1071,17 +1157,26 @@  discard block
 block discarded – undo
1071 1157
 	 */
1072 1158
 	static function image( $app,$name,$title='',$options='' )
1073 1159
 	{
1074
-		if (is_array($name))	// menuaction and other get-vars
1160
+		if (is_array($name))
1161
+		{
1162
+			// menuaction and other get-vars
1075 1163
 		{
1076 1164
 			$name = $GLOBALS['egw']->link('/index.php',$name);
1077 1165
 		}
1078
-		if (substr($name,0,5) == 'vfs:/')	// vfs pseudo protocoll
1166
+		}
1167
+		if (substr($name,0,5) == 'vfs:/')
1168
+		{
1169
+			// vfs pseudo protocoll
1079 1170
 		{
1080 1171
 			$name = egw::link(egw_vfs::download_url(substr($name,4)));
1081 1172
 		}
1173
+		}
1082 1174
 		if ($name[0] == '/' || substr($name,0,7) == 'http://' || substr($name,0,8) == 'https://' || stripos($name,'etemplate/thumbnail.php') )
1083 1175
 		{
1084
-			if (!($name[0] == '/' || substr($name,0,7) == 'http://' || substr($name,0,8) == 'https://')) $name = '/'.$name;
1176
+			if (!($name[0] == '/' || substr($name,0,7) == 'http://' || substr($name,0,8) == 'https://'))
1177
+			{
1178
+				$name = '/'.$name;
1179
+			}
1085 1180
 			$url = $name;
1086 1181
 		}
1087 1182
 		else	// no URL, so try searching the image
@@ -1096,7 +1191,10 @@  discard block
 block discarded – undo
1096 1191
 			{
1097 1192
 				list(,$path) = explode($GLOBALS['egw_info']['server']['webserver_url'],$url);
1098 1193
 
1099
-				if (!is_null($path)) $path = EGW_SERVER_ROOT.$path;
1194
+				if (!is_null($path))
1195
+				{
1196
+					$path = EGW_SERVER_ROOT.$path;
1197
+				}
1100 1198
 			}
1101 1199
 			else
1102 1200
 			{
@@ -1159,10 +1257,13 @@  discard block
 block discarded – undo
1159 1257
 		{
1160 1258
 			$url = "/index.php?menuaction=$url";
1161 1259
 		}
1162
-		if ($url[0] == '/')		// link relative to eGW
1260
+		if ($url[0] == '/')
1261
+		{
1262
+			// link relative to eGW
1163 1263
 		{
1164 1264
 			$url = self::link($url,$vars);
1165 1265
 		}
1266
+		}
1166 1267
 		//echo "<p>html::a_href('".self::htmlspecialchars($content)."','$url',".print_r($vars,True).") = ".self::link($url,$vars)."</p>";
1167 1268
 		return '<a href="'.self::htmlspecialchars($url).'" '.$options.'>'.$content.'</a>';
1168 1269
 	}
@@ -1198,7 +1299,10 @@  discard block
 block discarded – undo
1198 1299
 	 */
1199 1300
 	static function hr($width='',$options='')
1200 1301
 	{
1201
-		if ($width) $options .= " width=\"$width\"";
1302
+		if ($width)
1303
+		{
1304
+			$options .= " width=\"$width\"";
1305
+		}
1202 1306
 
1203 1307
 		return "<hr $options />\n";
1204 1308
 	}
@@ -1214,8 +1318,14 @@  discard block
 block discarded – undo
1214 1318
 	 */
1215 1319
 	static function formatOptions($options,$names)
1216 1320
 	{
1217
-		if (!is_array($options)) $options = explode(',',$options);
1218
-		if (!is_array($names))   $names   = explode(',',$names);
1321
+		if (!is_array($options))
1322
+		{
1323
+			$options = explode(',',$options);
1324
+		}
1325
+		if (!is_array($names))
1326
+		{
1327
+			$names   = explode(',',$names);
1328
+		}
1219 1329
 
1220 1330
 		foreach($options as $n => $val)
1221 1331
 		{
@@ -1357,9 +1467,15 @@  discard block
 block discarded – undo
1357 1467
 			egw_framework::includeCSS('/phpgwapi/js/dhtmlxtree/codebase/dhtmlxtree.css');
1358 1468
 			egw_framework::validate_file('/phpgwapi/js/dhtmlxtree/codebase/dhtmlxcommon.js');
1359 1469
 			egw_framework::validate_file('/phpgwapi/js/dhtmlxtree/sources/dhtmlxtree.js');
1360
-			if ($autoLoading && $dataMode != 'XML') egw_framework::validate_file('/phpgwapi/js/dhtmlxtree/sources/ext/dhtmlxtree_json.js');
1470
+			if ($autoLoading && $dataMode != 'XML')
1471
+			{
1472
+				egw_framework::validate_file('/phpgwapi/js/dhtmlxtree/sources/ext/dhtmlxtree_json.js');
1473
+			}
1361 1474
 			$tree_initialised = true;
1362
-			if (!$_folders && !$autoLoading) return null;
1475
+			if (!$_folders && !$autoLoading)
1476
+			{
1477
+				return null;
1478
+			}
1363 1479
 		}
1364 1480
 		$html = self::div("\n",'id="'.$tree.'"',$_divClass).$html;
1365 1481
 		$html .= "<script type='text/javascript'>\n";
@@ -1367,7 +1483,10 @@  discard block
 block discarded – undo
1367 1483
 		$html .= "egw_LAB.wait(function() {";
1368 1484
 		$html .= "$tree = new dhtmlXTreeObject('$tree','100%','100%',0);\n";
1369 1485
 		$html .= "$tree.parentObject.style.overflow='auto';\n";	// dhtmlXTree constructor has hidden hardcoded
1370
-		if (translation::charset() == 'utf-8') $html .= "if ($tree.setEscapingMode) $tree.setEscapingMode('utf8');\n";
1486
+		if (translation::charset() == 'utf-8')
1487
+		{
1488
+			$html .= "if ($tree.setEscapingMode) $tree.setEscapingMode('utf8');\n";
1489
+		}
1371 1490
 		$html .= "$tree.setImagePath('$folderImageDir/dhtmlxtree/');\n";
1372 1491
 
1373 1492
 		if($_onCheckHandler)
@@ -1376,19 +1495,28 @@  discard block
 block discarded – undo
1376 1495
 			$html .= "$tree.setOnCheckHandler('$_onCheckHandler');\n";
1377 1496
 		}
1378 1497
 
1379
-		if ($dragndrop) $html .= "$tree.enableDragAndDrop(true);\n";
1498
+		if ($dragndrop)
1499
+		{
1500
+			$html .= "$tree.enableDragAndDrop(true);\n";
1501
+		}
1380 1502
 
1381 1503
 		if ($autoLoading)
1382 1504
 		{
1383 1505
 			$autoLoading = is_array($autoLoading) ?
1384 1506
 				egw::link('/index.php',$autoLoading) : egw::link($autoLoading);
1385 1507
 			$html .= "$tree.setXMLAutoLoading('$autoLoading');\n";
1386
-			if ($dataMode != 'XML') $html .= "$tree.setDataMode('$dataMode');\n";
1508
+			if ($dataMode != 'XML')
1509
+			{
1510
+				$html .= "$tree.setDataMode('$dataMode');\n";
1511
+			}
1387 1512
 
1388 1513
 			// if no folders given, use xml url to load root, incl. setting of selected folder
1389 1514
 			if (!$_folders)
1390 1515
 			{
1391
-				if ($_selected) $autoLoading .= '&selected='.urlencode($_selected);
1516
+				if ($_selected)
1517
+				{
1518
+					$autoLoading .= '&selected='.urlencode($_selected);
1519
+				}
1392 1520
 				unset($_selected);
1393 1521
 				$html .= "$tree.loadXML('$autoLoading');\n";
1394 1522
 				$html .= "});";
@@ -1433,7 +1561,10 @@  discard block
 block discarded – undo
1433 1561
 		else
1434 1562
 		{
1435 1563
 			// evtl. remove leading delimiter
1436
-			if ($_selected[0] == $delimiter) $_selected = substr($_selected,1);
1564
+			if ($_selected[0] == $delimiter)
1565
+			{
1566
+				$_selected = substr($_selected,1);
1567
+			}
1437 1568
 
1438 1569
 			$n = 0;
1439 1570
 			foreach($_folders as $path => $data)
@@ -1462,22 +1593,37 @@  discard block
 block discarded – undo
1462 1593
 					$image1 = $image2 = $image3 = "'".$data['image']."'";
1463 1594
 				}
1464 1595
 				// evtl. remove leading delimiter
1465
-				if ($path[0] == $delimiter) $path = substr($path,1);
1596
+				if ($path[0] == $delimiter)
1597
+				{
1598
+					$path = substr($path,1);
1599
+				}
1466 1600
 				$folderParts = explode($delimiter,$path);
1467 1601
 
1468 1602
 				//get rightmost folderpart
1469 1603
 				$label = array_pop($folderParts);
1470
-				if (isset($data['label'])) $label = $data['label'];
1604
+				if (isset($data['label']))
1605
+				{
1606
+					$label = $data['label'];
1607
+				}
1471 1608
 
1472 1609
 				// the rest of the array is the name of the parent
1473 1610
 				$parentName = implode((array)$folderParts,$delimiter);
1474
-				if(empty($parentName)) $parentName = $top;
1611
+				if(empty($parentName))
1612
+				{
1613
+					$parentName = $top;
1614
+				}
1475 1615
 
1476 1616
 				$entryOptions = !isset($data['child']) || $data['child'] ? 'CHILD' : '';
1477
-				if ($_onCheckHandler && $_selected)	// check selected items on multi selection
1617
+				if ($_onCheckHandler && $_selected)
1618
+				{
1619
+					// check selected items on multi selection
1478 1620
 				{
1479 1621
 					if (!is_array($_selected)) $_selected = explode(',',$_selected);
1480
-					if (array_search("$path",$_selected)!==false) $entryOptions .= ',CHECKED';
1622
+				}
1623
+					if (array_search("$path",$_selected)!==false)
1624
+					{
1625
+						$entryOptions .= ',CHECKED';
1626
+					}
1481 1627
 					//echo "<p>path=$path, _selected=".print_r($_selected,true).": $entryOptions</p>\n";
1482 1628
 				}
1483 1629
 				// highlight current item
@@ -1526,12 +1672,19 @@  discard block
 block discarded – undo
1526 1672
 	{
1527 1673
 		$defaultConfig = array('valid_xhtml'=>1,'safe'=>1);
1528 1674
 
1529
-		if (empty($html)) return $html;	// no need to process further
1675
+		if (empty($html))
1676
+		{
1677
+			return $html;
1678
+		}
1679
+		// no need to process further
1530 1680
 		if (!empty($config) && is_string($config))
1531 1681
 		{
1532 1682
 			//error_log(__METHOD__.__LINE__.$config);
1533 1683
 			$config = json_decode($config,true);
1534
-			if (is_null($config)) error_log(__METHOD__.__LINE__." decoding of config failed; standard will be applied");
1684
+			if (is_null($config))
1685
+			{
1686
+				error_log(__METHOD__.__LINE__." decoding of config failed; standard will be applied");
1687
+			}
1535 1688
 		}
1536 1689
 
1537 1690
 		// User preferences
@@ -1545,8 +1698,14 @@  discard block
 block discarded – undo
1545 1698
 			return '';
1546 1699
 		}
1547 1700
 		$htmLawed = new egw_htmLawed();
1548
-		if (is_array($config) && $_force===false) $config = array_merge($defaultConfig, $config);
1549
-		if (empty($config)) $config = $defaultConfig;
1701
+		if (is_array($config) && $_force===false)
1702
+		{
1703
+			$config = array_merge($defaultConfig, $config);
1704
+		}
1705
+		if (empty($config))
1706
+		{
1707
+			$config = $defaultConfig;
1708
+		}
1550 1709
 		//error_log(__METHOD__.__LINE__.array2string($config));
1551 1710
 		return $htmLawed->egw_htmLawed($html,$config,$spec);
1552 1711
 	}
@@ -1611,9 +1770,13 @@  discard block
 block discarded – undo
1611 1770
 				// mobile FF 24 on Android does NOT honor CSP!
1612 1771
 				html::$user_agent == 'firefox' && !html::$ua_mobile && html::$ua_version >= 24 ||
1613 1772
 				html::$user_agent == 'safari' && !html::$ua_mobile && html::$ua_version >= 536 ||	// OS X
1614
-				html::$user_agent == 'safari' && html::$ua_mobile && html::$ua_version >= 9537)	// iOS 7
1773
+				html::$user_agent == 'safari' && html::$ua_mobile && html::$ua_version >= 9537)
1774
+			{
1775
+				// iOS 7
1615 1776
 			{
1616
-				$csp = "script-src 'none'";	// forbid to execute any javascript
1777
+				$csp = "script-src 'none'";
1778
+			}
1779
+			// forbid to execute any javascript
1617 1780
 				header("Content-Security-Policy: $csp");
1618 1781
 				header("X-Webkit-CSP: $csp");	// Chrome: <= 24, Safari incl. iOS
1619 1782
 				//header("X-Content-Security-Policy: $csp");	// FF <= 22
@@ -1627,7 +1790,10 @@  discard block
 block discarded – undo
1627 1790
 		}
1628 1791
 		if ($no_content_type)
1629 1792
 		{
1630
-			if ($force_download) self::content_disposition_header(egw_vfs::basename($path), $force_download);
1793
+			if ($force_download)
1794
+			{
1795
+				self::content_disposition_header(egw_vfs::basename($path), $force_download);
1796
+			}
1631 1797
 		}
1632 1798
 		else
1633 1799
 		{
@@ -1746,7 +1912,10 @@  discard block
 block discarded – undo
1746 1912
 	{
1747 1913
 		$ct=0;
1748 1914
 		$newStyle = null;
1749
-		if (stripos($html,'<style')!==false)  $ct = preg_match_all('#<style(?:\s.*)?>(.+)</style>#isU', $html, $newStyle);
1915
+		if (stripos($html,'<style')!==false)
1916
+		{
1917
+			$ct = preg_match_all('#<style(?:\s.*)?>(.+)</style>#isU', $html, $newStyle);
1918
+		}
1750 1919
 		if ($ct>0)
1751 1920
 		{
1752 1921
 			//error_log(__METHOD__.__LINE__.array2string($newStyle[0]));
@@ -1780,7 +1949,11 @@  discard block
 block discarded – undo
1780 1949
 		// CSS Security
1781 1950
 		// http://code.google.com/p/browsersec/wiki/Part1#Cascading_stylesheets
1782 1951
 		$css = preg_replace('/(javascript|expession|-moz-binding)/i','',$style);
1783
-		if (stripos($css,'script')!==false) translation::replaceTagsCompletley($css,'script'); // Strip out script that may be included
1952
+		if (stripos($css,'script')!==false)
1953
+		{
1954
+			translation::replaceTagsCompletley($css,'script');
1955
+		}
1956
+		// Strip out script that may be included
1784 1957
 		// we need this, as styledefinitions are enclosed with curly brackets; and template stuff tries to replace everything between curly brackets that is having no horizontal whitespace
1785 1958
 		// as the comments as <!-- styledefinition --> in stylesheet are outdated, and ck-editor does not understand it, we remove it
1786 1959
 		$css_no_comment = str_replace(array(':','<!--','-->'),array(': ','',''),$css);
Please login to merge, or discard this patch.
phpgwapi/inc/class.ischedule_client.inc.php 5 patches
Doc Comments   +4 added lines, -11 removed lines patch added patch discarded remove patch
@@ -68,8 +68,7 @@  discard block
 block discarded – undo
68 68
 	/**
69 69
 	 * Constructor
70 70
 	 *
71
-	 * @param string|array $recipients=null recipient email-address(es)
72
-	 * @param string $url=null ischedule url, if it should NOT be discovered
71
+	 * @param string|array $recipients recipient email-address(es)
73 72
 	 * @throws Exception in case of an error or discovery failure
74 73
 	 */
75 74
 	public function __construct($recipients, $url=null)
@@ -121,8 +120,7 @@  discard block
 block discarded – undo
121 120
 	 * @param string|array $recipients (array of) mailto urls (from same domain!)
122 121
 	 * @param int $start starttime
123 122
 	 * @param int $end endtime
124
-	 * @param string $uid=null
125
-	 * @param string $originator=null default current user's email
123
+	 * @param string $originator default current user's email
126 124
 	 * @return array with values for keys 'schedule-response' or 'error'
127 125
 	 * @throws Exception if discovery of recipient(s) fails
128 126
 	 */
@@ -190,7 +188,7 @@  discard block
 block discarded – undo
190 188
 	 * Set originator and (optional) DKIM private key
191 189
 	 *
192 190
 	 * @param string $originator
193
-	 * @param string $dkim_private_key=null
191
+	 * @param string $dkim_private_key
194 192
 	 * @throws Exception for invalid / not an email originator
195 193
 	 */
196 194
 	public function setOriginator($originator, $dkim_private_key=null)
@@ -279,8 +277,7 @@  discard block
 block discarded – undo
279 277
 	 *
280 278
 	 * @param string $content
281 279
 	 * @param string $content_type
282
-	 * @param boolean $debug=false true echo request before posting
283
-	 * @param int $max_redirect=3 maximum number of redirect before failing
280
+	 * @param int $max_redirect maximum number of redirect before failing
284 281
 	 * @return string
285 282
 	 * @throws Exception with http status code and message, if server responds other then 2xx
286 283
 	 */
@@ -366,10 +363,7 @@  discard block
 block discarded – undo
366 363
 	 *
367 364
 	 * @param array $headers name => value pairs, names as in $sign_headers
368 365
 	 * @param string $body
369
-	 * @param string $selector='calendar'
370
-	 * @param string $sign_headers='iSchedule-Version:Content-Type:Originator:Recipient'
371 366
 	 * @param int $expires seconds the signature is valid, default 300
372
-	 * @param boolean $fold=false true: return folded signature, false: return a single line
373 367
 	 * @return string DKIM-Signature: ...
374 368
 	 */
375 369
 	public function dkim_sign(array $headers, $body, $selector='calendar',$sign_headers=self::DKIM_HEADERS,$expires=300,$fold=false)
@@ -418,7 +412,6 @@  discard block
 block discarded – undo
418 412
 	/**
419 413
 	 * Query capabilities of iSchedule server
420 414
 	 *
421
-	 * @param string $name=null name of capability to return, default null to return internal array with all capabilities
422 415
 	 * @return mixed
423 416
 	 * @throws Exception in case of an error or discovery failure
424 417
 	 */
Please login to merge, or discard this patch.
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -316,15 +316,15 @@  discard block
 block discarded – undo
316 316
 		$header_string .= $this->dkim_sign($headers, $content)."\r\n";
317 317
 
318 318
 		$opts = array('http' =>
319
-		    array(
320
-		        'method'  => 'POST',
321
-		        'header'  => $header_string,
322
-		    	'user_agent' => $user_agent,
323
-		    	//'follow_location' => 1,	// default 1=follow, but only for GET, not POST!
324
-		        //'timeout' => $timeout,	// max timeout in seconds (float)
325
-		        'content' => $content,
326
-		    	'ignore_errors' => true,	// return response, even for http-status != 2xx
327
-		    )
319
+			array(
320
+				'method'  => 'POST',
321
+				'header'  => $header_string,
322
+				'user_agent' => $user_agent,
323
+				//'follow_location' => 1,	// default 1=follow, but only for GET, not POST!
324
+				//'timeout' => $timeout,	// max timeout in seconds (float)
325
+				'content' => $content,
326
+				'ignore_errors' => true,	// return response, even for http-status != 2xx
327
+			)
328 328
 		);
329 329
 
330 330
 		if ($debug) echo "POST $this->url HTTP/1.1\n$header_string\n$content\n";
@@ -388,19 +388,19 @@  discard block
 block discarded – undo
388 388
 		// generate DKIM signature according to iSchedule spec
389 389
 		$dkim = $mds->getDKIM(implode(':', $header_names), $header_values, $body, 'ischedule-relaxed/simple', 'rsa-sha256',
390 390
 			"DKIM-Signature: ".
391
-	                "v=1; ".          // DKIM Version
392
-	                "a=\$a; ".        // The algorithm used to generate the signature "rsa-sha1"
391
+					"v=1; ".          // DKIM Version
392
+					"a=\$a; ".        // The algorithm used to generate the signature "rsa-sha1"
393 393
 					"q=private-exchange:dns/txt:http/well-known; ".	// how to fetch public key: dns/txt, http/well-known or private-exchange
394 394
 					"x=".(time()+$expires)."; ".        // how long request will be valid as timestamp
395 395
 					// end iSchedule specific
396
-	                "s=\$s; ".        // The selector subdividing the namespace for the "d=" (domain) tag
397
-	                "d=\$d; ".        // The domain of the signing entity
398
-	                "l=\$l; ".        // Canonicalizated Body length count
399
-	                "t=\$t; ".        // Signature Timestamp
400
-	                "c=\$c; ".        // Message (Headers/Body) Canonicalization "relaxed/relaxed"
401
-	                "h=\$h; ".        // Signed header fields
402
-	                "bh=\$bh;\r\n\t". // The hash of the canonicalized body part of the message
403
-	                "b=");             // The signature data (Empty because we will calculate it later));
396
+					"s=\$s; ".        // The selector subdividing the namespace for the "d=" (domain) tag
397
+					"d=\$d; ".        // The domain of the signing entity
398
+					"l=\$l; ".        // Canonicalizated Body length count
399
+					"t=\$t; ".        // Signature Timestamp
400
+					"c=\$c; ".        // Message (Headers/Body) Canonicalization "relaxed/relaxed"
401
+					"h=\$h; ".        // Signed header fields
402
+					"bh=\$bh;\r\n\t". // The hash of the canonicalized body part of the message
403
+					"b=");             // The signature data (Empty because we will calculate it later));
404 404
 
405 405
 		// as we do http, no need to fold dkim, in fact recommendation is not to
406 406
 		if (!$fold) $dkim = str_replace(array(";\r\n\t", "\r\n\t"), array('; ', ''), $dkim);
Please login to merge, or discard this patch.
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 	 * @param string $url=null ischedule url, if it should NOT be discovered
73 73
 	 * @throws Exception in case of an error or discovery failure
74 74
 	 */
75
-	public function __construct($recipients, $url=null)
75
+	public function __construct($recipients, $url = null)
76 76
 	{
77 77
 		$this->recipients = (array)$recipients;
78 78
 		$this->originator = 'mailto:'.$GLOBALS['egw_info']['user']['account_email'];
@@ -126,24 +126,24 @@  discard block
 block discarded – undo
126 126
 	 * @return array with values for keys 'schedule-response' or 'error'
127 127
 	 * @throws Exception if discovery of recipient(s) fails
128 128
 	 */
129
-	public static function freebusy_request($recipients, $start, $end, $uid=null, $originator=null)
129
+	public static function freebusy_request($recipients, $start, $end, $uid = null, $originator = null)
130 130
 	{
131 131
 		$client = new ischedule_client($recipients);
132 132
 		if ($originator) $client->setOriginator($originator);
133 133
 
134 134
 		$vcal = new Horde_iCalendar;
135
-		$vcal->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'.
135
+		$vcal->setAttribute('PRODID', '-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'.
136 136
 			strtoupper($GLOBALS['egw_info']['user']['preferences']['common']['lang']));
137
-		$vcal->setAttribute('VERSION','2.0');
138
-		$vcal->setAttribute('METHOD',$method='REQUEST');
137
+		$vcal->setAttribute('VERSION', '2.0');
138
+		$vcal->setAttribute('METHOD', $method = 'REQUEST');
139 139
 
140
-		$vfreebusy = Horde_iCalendar::newComponent($component='VFREEBUSY', $vcal);
140
+		$vfreebusy = Horde_iCalendar::newComponent($component = 'VFREEBUSY', $vcal);
141 141
 		if ($uid) $vfreebusy->setAttribute('UID', $uid);
142 142
 		$vfreebusy->setAttribute('DTSTAMP', time());
143 143
 		$vfreebusy->setAttribute('DTSTART', $start);
144 144
 		$vfreebusy->setAttribute('DTEND', $end);
145 145
 		$vfreebusy->setAttribute('ORGANIZER', $client->originator);
146
-		foreach($client->recipients as $recipient)
146
+		foreach ($client->recipients as $recipient)
147 147
 		{
148 148
 			$vfreebusy->setAttribute('ATTENDEE', $recipient);
149 149
 		}
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 	 * @param string $dkim_private_key=null
194 194
 	 * @throws Exception for invalid / not an email originator
195 195
 	 */
196
-	public function setOriginator($originator, $dkim_private_key=null)
196
+	public function setOriginator($originator, $dkim_private_key = null)
197 197
 	{
198 198
 		if (!preg_match(self::EMAIL_PREG, $originator))
199 199
 		{
@@ -224,10 +224,10 @@  discard block
 block discarded – undo
224 224
 		if (isset(self::$domain2url[$domain])) return self::$domain2url[$domain];
225 225
 
226 226
 		$d = $domain;
227
-		for($n = 0; $n < 3; ++$n)
227
+		for ($n = 0; $n < 3; ++$n)
228 228
 		{
229
-			if (!($records = dns_get_record($host='_ischedules._tcp.'.$d, DNS_SRV+DNS_TXT)) &&
230
-				!($records = dns_get_record($host='_ischedule._tcp.'.$d, DNS_SRV+DNS_TXT)))
229
+			if (!($records = dns_get_record($host = '_ischedules._tcp.'.$d, DNS_SRV + DNS_TXT)) &&
230
+				!($records = dns_get_record($host = '_ischedule._tcp.'.$d, DNS_SRV + DNS_TXT)))
231 231
 			{
232 232
 				// try without subdomain(s)
233 233
 				$parts = explode('.', $d);
@@ -240,9 +240,9 @@  discard block
 block discarded – undo
240 240
 
241 241
 		$path = '/.well-known/ischedule';
242 242
 
243
-		foreach($records as $record)
243
+		foreach ($records as $record)
244 244
 		{
245
-			switch($record['type'])
245
+			switch ($record['type'])
246 246
 			{
247 247
 				case 'SRV':
248 248
 					// for multiple SRV records we use the one with smallest priority and heighest weight
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 	 * @return string
285 285
 	 * @throws Exception with http status code and message, if server responds other then 2xx
286 286
 	 */
287
-	public function post_msg($content, $content_type, $debug=false, $max_redirect=3)
287
+	public function post_msg($content, $content_type, $debug = false, $max_redirect = 3)
288 288
 	{
289 289
 		if (empty($this->dkim_private_key))
290 290
 		{
@@ -301,14 +301,14 @@  discard block
 block discarded – undo
301 301
 			'Content-Type' => $content_type,
302 302
 			'Originator' => $this->originator,
303 303
 			'Recipient' => $this->recipients,
304
-			'Cache-Control' => 'no-cache, no-transform',	// required by iSchedule spec
304
+			'Cache-Control' => 'no-cache, no-transform', // required by iSchedule spec
305 305
 			'User-Agent' => $user_agent,
306 306
 			'Content-Length' => bytes($content),
307 307
 		);
308 308
 		$header_string = '';
309
-		foreach($headers as $name => $value)
309
+		foreach ($headers as $name => $value)
310 310
 		{
311
-			foreach((array)$value as $val)
311
+			foreach ((array)$value as $val)
312 312
 			{
313 313
 				$header_string .= $name.': '.$val."\r\n";
314 314
 			}
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
 		    	//'follow_location' => 1,	// default 1=follow, but only for GET, not POST!
324 324
 		        //'timeout' => $timeout,	// max timeout in seconds (float)
325 325
 		        'content' => $content,
326
-		    	'ignore_errors' => true,	// return response, even for http-status != 2xx
326
+		    	'ignore_errors' => true, // return response, even for http-status != 2xx
327 327
 		    )
328 328
 		);
329 329
 
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
 		{
337 337
 			if ($max_redirect && $code[0] === '3')
338 338
 			{
339
-				foreach($http_response_header as $header)
339
+				foreach ($http_response_header as $header)
340 340
 				{
341 341
 					if (stripos($header, 'location:') === 0)
342 342
 					{
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
 						}
349 349
 						$this->url = $location;
350 350
 						// follow redirect
351
-						return $this->post_msg($content, $content_type, $debug, $max_redirect-1);
351
+						return $this->post_msg($content, $content_type, $debug, $max_redirect - 1);
352 352
 					}
353 353
 				}
354 354
 			}
@@ -372,12 +372,12 @@  discard block
 block discarded – undo
372 372
 	 * @param boolean $fold=false true: return folded signature, false: return a single line
373 373
 	 * @return string DKIM-Signature: ...
374 374
 	 */
375
-	public function dkim_sign(array $headers, $body, $selector='calendar',$sign_headers=self::DKIM_HEADERS,$expires=300,$fold=false)
375
+	public function dkim_sign(array $headers, $body, $selector = 'calendar', $sign_headers = self::DKIM_HEADERS, $expires = 300, $fold = false)
376 376
 	{
377 377
 		$header_values = $header_names = array();
378
-		foreach(explode(':', $sign_headers) as $header)
378
+		foreach (explode(':', $sign_headers) as $header)
379 379
 		{
380
-			foreach((array)$headers[$header] as $value)
380
+			foreach ((array)$headers[$header] as $value)
381 381
 			{
382 382
 				$header_values[] = $header.': '.$value;
383 383
 				$header_names[] = $header;
@@ -388,19 +388,19 @@  discard block
 block discarded – undo
388 388
 		// generate DKIM signature according to iSchedule spec
389 389
 		$dkim = $mds->getDKIM(implode(':', $header_names), $header_values, $body, 'ischedule-relaxed/simple', 'rsa-sha256',
390 390
 			"DKIM-Signature: ".
391
-	                "v=1; ".          // DKIM Version
392
-	                "a=\$a; ".        // The algorithm used to generate the signature "rsa-sha1"
393
-					"q=private-exchange:dns/txt:http/well-known; ".	// how to fetch public key: dns/txt, http/well-known or private-exchange
394
-					"x=".(time()+$expires)."; ".        // how long request will be valid as timestamp
391
+	                "v=1; ".// DKIM Version
392
+	                "a=\$a; ".// The algorithm used to generate the signature "rsa-sha1"
393
+					"q=private-exchange:dns/txt:http/well-known; ".// how to fetch public key: dns/txt, http/well-known or private-exchange
394
+					"x=".(time() + $expires)."; ".// how long request will be valid as timestamp
395 395
 					// end iSchedule specific
396
-	                "s=\$s; ".        // The selector subdividing the namespace for the "d=" (domain) tag
397
-	                "d=\$d; ".        // The domain of the signing entity
398
-	                "l=\$l; ".        // Canonicalizated Body length count
399
-	                "t=\$t; ".        // Signature Timestamp
400
-	                "c=\$c; ".        // Message (Headers/Body) Canonicalization "relaxed/relaxed"
401
-	                "h=\$h; ".        // Signed header fields
402
-	                "bh=\$bh;\r\n\t". // The hash of the canonicalized body part of the message
403
-	                "b=");             // The signature data (Empty because we will calculate it later));
396
+	                "s=\$s; ".// The selector subdividing the namespace for the "d=" (domain) tag
397
+	                "d=\$d; ".// The domain of the signing entity
398
+	                "l=\$l; ".// Canonicalizated Body length count
399
+	                "t=\$t; ".// Signature Timestamp
400
+	                "c=\$c; ".// Message (Headers/Body) Canonicalization "relaxed/relaxed"
401
+	                "h=\$h; ".// Signed header fields
402
+	                "bh=\$bh;\r\n\t".// The hash of the canonicalized body part of the message
403
+	                "b="); // The signature data (Empty because we will calculate it later));
404 404
 
405 405
 		// as we do http, no need to fold dkim, in fact recommendation is not to
406 406
 		if (!$fold) $dkim = str_replace(array(";\r\n\t", "\r\n\t"), array('; ', ''), $dkim);
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
 	 * @return mixed
423 423
 	 * @throws Exception in case of an error or discovery failure
424 424
 	 */
425
-	public function capabilities($name=null)
425
+	public function capabilities($name = null)
426 426
 	{
427 427
 		if (!isset($this->capabilities))
428 428
 		{
@@ -489,7 +489,7 @@  discard block
 block discarded – undo
489 489
 					}
490 490
 					if ($xml->hasAttributes)
491 491
 					{
492
-						while($xml->moveToNextAttribute())
492
+						while ($xml->moveToNextAttribute())
493 493
 						{
494 494
 							if ($xml->name != 'name')
495 495
 					   	{
Please login to merge, or discard this patch.
Braces   +51 added lines, -14 removed lines patch added patch discarded remove patch
@@ -104,7 +104,10 @@  discard block
 block discarded – undo
104 104
 		{
105 105
 			return false;
106 106
 		}
107
-		if (strpos($domain, '@') !== false) list(, $domain) = explode('@', $domain);
107
+		if (strpos($domain, '@') !== false)
108
+		{
109
+			list(, $domain) = explode('@', $domain);
110
+		}
108 111
 
109 112
 		try {
110 113
 			$url = self::discover($domain);
@@ -129,7 +132,10 @@  discard block
 block discarded – undo
129 132
 	public static function freebusy_request($recipients, $start, $end, $uid=null, $originator=null)
130 133
 	{
131 134
 		$client = new ischedule_client($recipients);
132
-		if ($originator) $client->setOriginator($originator);
135
+		if ($originator)
136
+		{
137
+			$client->setOriginator($originator);
138
+		}
133 139
 
134 140
 		$vcal = new Horde_iCalendar;
135 141
 		$vcal->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'.
@@ -138,7 +144,10 @@  discard block
 block discarded – undo
138 144
 		$vcal->setAttribute('METHOD',$method='REQUEST');
139 145
 
140 146
 		$vfreebusy = Horde_iCalendar::newComponent($component='VFREEBUSY', $vcal);
141
-		if ($uid) $vfreebusy->setAttribute('UID', $uid);
147
+		if ($uid)
148
+		{
149
+			$vfreebusy->setAttribute('UID', $uid);
150
+		}
142 151
 		$vfreebusy->setAttribute('DTSTAMP', time());
143 152
 		$vfreebusy->setAttribute('DTSTART', $start);
144 153
 		$vfreebusy->setAttribute('DTEND', $end);
@@ -221,7 +230,10 @@  discard block
 block discarded – undo
221 230
 			'http' => 80,
222 231
 		);
223 232
 
224
-		if (isset(self::$domain2url[$domain])) return self::$domain2url[$domain];
233
+		if (isset(self::$domain2url[$domain]))
234
+		{
235
+			return self::$domain2url[$domain];
236
+		}
225 237
 
226 238
 		$d = $domain;
227 239
 		for($n = 0; $n < 3; ++$n)
@@ -231,12 +243,18 @@  discard block
 block discarded – undo
231 243
 			{
232 244
 				// try without subdomain(s)
233 245
 				$parts = explode('.', $d);
234
-				if (count($parts) < 3) break;
246
+				if (count($parts) < 3)
247
+				{
248
+					break;
249
+				}
235 250
 				array_shift($parts);
236 251
 				$d = implode('.', $parts);
237 252
 			}
238 253
 		}
239
-		if (!$records) throw new Exception("Could not discover iSchedule service for domain '$domain'!");
254
+		if (!$records)
255
+		{
256
+			throw new Exception("Could not discover iSchedule service for domain '$domain'!");
257
+		}
240 258
 
241 259
 		$path = '/.well-known/ischedule';
242 260
 
@@ -254,11 +272,17 @@  discard block
 block discarded – undo
254 272
 					break;
255 273
 
256 274
 				case 'TXT':
257
-					if (strpos($record['txt'], 'path=') === 0) $path = substr($record['txt'], 5);
275
+					if (strpos($record['txt'], 'path=') === 0)
276
+					{
277
+						$path = substr($record['txt'], 5);
278
+					}
258 279
 					break;
259 280
 			}
260 281
 		}
261
-		if (!isset($srv)) throw new Exception("Could not discover iSchedule service for domain '$domain'!");
282
+		if (!isset($srv))
283
+		{
284
+			throw new Exception("Could not discover iSchedule service for domain '$domain'!");
285
+		}
262 286
 
263 287
 		$url = strpos($host, '_ischedules') === 0 ? 'https' : 'http';
264 288
 		if ($scheme2port[$url] == $srv['port'])
@@ -327,7 +351,10 @@  discard block
 block discarded – undo
327 351
 		    )
328 352
 		);
329 353
 
330
-		if ($debug) echo "POST $this->url HTTP/1.1\n$header_string\n$content\n";
354
+		if ($debug)
355
+		{
356
+			echo "POST $this->url HTTP/1.1\n$header_string\n$content\n";
357
+		}
331 358
 
332 359
 		// need to suppress warning, if http-status not 2xx
333 360
 		$response = @file_get_contents($this->url, false, stream_context_create($opts));
@@ -352,9 +379,15 @@  discard block
 block discarded – undo
352 379
 					}
353 380
 				}
354 381
 			}
355
-			if ($debug && $http_response_header) echo implode("\r\n", $http_response_header)."\r\n\r\n".$response;
382
+			if ($debug && $http_response_header)
383
+			{
384
+				echo implode("\r\n", $http_response_header)."\r\n\r\n".$response;
385
+			}
356 386
 
357
-			if (preg_match('|<response-description>(.*)</response-description>|', $response, $matches)) $message .= ': '.$matches[1];
387
+			if (preg_match('|<response-description>(.*)</response-description>|', $response, $matches))
388
+			{
389
+				$message .= ': '.$matches[1];
390
+			}
358 391
 
359 392
 			throw new Exception($message, $code);
360 393
 		}
@@ -403,7 +436,10 @@  discard block
 block discarded – undo
403 436
 	                "b=");             // The signature data (Empty because we will calculate it later));
404 437
 
405 438
 		// as we do http, no need to fold dkim, in fact recommendation is not to
406
-		if (!$fold) $dkim = str_replace(array(";\r\n\t", "\r\n\t"), array('; ', ''), $dkim);
439
+		if (!$fold)
440
+		{
441
+			$dkim = str_replace(array(";\r\n\t", "\r\n\t"), array('; ', ''), $dkim);
442
+		}
407 443
 
408 444
 		return $dkim;
409 445
 	}
@@ -456,7 +492,8 @@  discard block
 block discarded – undo
456 492
 	{
457 493
 		while ($xml->read())
458 494
 		{
459
-			switch ($xml->nodeType) {
495
+			switch ($xml->nodeType)
496
+			{
460 497
 				case XMLReader::END_ELEMENT:
461 498
 					return $target;
462 499
 				case XMLReader::ELEMENT:
@@ -492,7 +529,7 @@  discard block
 block discarded – undo
492 529
 						while($xml->moveToNextAttribute())
493 530
 						{
494 531
 							if ($xml->name != 'name')
495
-					   	{
532
+							{
496 533
 						   		$t['@'.$xml->name] = $xml->value;
497 534
 							}
498 535
 						}
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -327,7 +327,7 @@
 block discarded – undo
327 327
 		    )
328 328
 		);
329 329
 
330
-		if ($debug) echo "POST $this->url HTTP/1.1\n$header_string\n$content\n";
330
+		if ($debug) echo "post $this->url HTTP/1.1\n$header_string\n$content\n";
331 331
 
332 332
 		// need to suppress warning, if http-status not 2xx
333 333
 		$response = @file_get_contents($this->url, false, stream_context_create($opts));
Please login to merge, or discard this patch.
phpgwapi/inc/class.ischedule_server.inc.php 3 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
 	 *
321 321
 	 * @param array $event
322 322
 	 * @param calendar_ical $handler
323
-	 * @param string $component
323
+	 * @param Horde_iCalendar_vevent $component
324 324
 	 * @param XMLWriter $xml
325 325
 	 */
326 326
 	function vevent(array $event, calendar_ical $handler, Horde_iCalendar_vevent $component, XMLWriter $xml)
@@ -636,7 +636,7 @@  discard block
 block discarded – undo
636 636
 	 *
637 637
 	 * @param string $d domain
638 638
 	 * @param string $s selector
639
-	 * @return string|boolean string with (full) public key or false if not found or other error retrieving it
639
+	 * @return false|string string with (full) public key or false if not found or other error retrieving it
640 640
 	 */
641 641
 	public static function well_known_pubkey($d, $s)
642 642
 	{
@@ -653,7 +653,7 @@  discard block
 block discarded – undo
653 653
 	 *
654 654
 	 * @param string $d domain
655 655
 	 * @param string $s selector
656
-	 * @return string|boolean string with (full) public key or false if not found or other error retrieving it
656
+	 * @return false|string string with (full) public key or false if not found or other error retrieving it
657 657
 	 */
658 658
 	public function dns_txt_pubkey($d, $s)
659 659
 	{
Please login to merge, or discard this patch.
Spacing   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 		// get raw request body
72 72
 		$this->request = file_get_contents('php://input');
73 73
 
74
-		switch($_SERVER['REQUEST_METHOD'])
74
+		switch ($_SERVER['REQUEST_METHOD'])
75 75
 		{
76 76
 			case 'GET':
77 77
 				$this->get();
@@ -154,11 +154,11 @@  discard block
 block discarded – undo
154 154
 	{
155 155
 		// get and verify required headers
156 156
 		$headers = array();
157
-		foreach($_SERVER as $name => $value)
157
+		foreach ($_SERVER as $name => $value)
158 158
 		{
159 159
 			$name = strtolower(str_replace('_', '-', $name));
160 160
 			list($first, $rest) = explode('-', $name, 2);
161
-			switch($first)
161
+			switch ($first)
162 162
 			{
163 163
 				case 'content':
164 164
 					$headers[$name] = $value;
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 			{
176 176
 				$error = 'originator-missing';
177 177
 			}
178
-			elseif(in_array('recipient', $missing))
178
+			elseif (in_array('recipient', $missing))
179 179
 			{
180 180
 				$error = 'recipient-missing';
181 181
 			}
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 			{
184 184
 				$error = 'invalid-scheduling-message';
185 185
 			}
186
-			throw new Exception ("Bad Request: $error: missing required headers: ".implode(', ', $missing), 400);
186
+			throw new Exception("Bad Request: $error: missing required headers: ".implode(', ', $missing), 400);
187 187
 		}
188 188
 
189 189
 		// validate dkim signature
@@ -228,15 +228,15 @@  discard block
 block discarded – undo
228 228
 		// ToDo: no component or method in Content-Type should give an "invalid-scheduling-message" error
229 229
 		// only unsupported (not in capablities) component should give "invalid-caledar-data-type"
230 230
 		if (!preg_match('/component=([^;]+)/i', $headers['content-type'], $matches) ||
231
-			(!in_array($component=strtoupper($matches[1]), self::$supported_components)))
231
+			(!in_array($component = strtoupper($matches[1]), self::$supported_components)))
232 232
 		{
233
-			throw new Exception ('Bad Request: invalid-calendar-data-type: missing or unsupported component in Content-Type header', 400);
233
+			throw new Exception('Bad Request: invalid-calendar-data-type: missing or unsupported component in Content-Type header', 400);
234 234
 		}
235 235
 		if (!preg_match('/method=([^;]+)/i', $headers['content-type'], $matches) ||
236
-			(!isset(self::$supported_method2origin_requirement[$method=strtoupper($matches[1])])) ||
236
+			(!isset(self::$supported_method2origin_requirement[$method = strtoupper($matches[1])])) ||
237 237
 			$component == 'VFREEBUSY' && $method != 'REQUEST')
238 238
 		{
239
-			throw new Exception ('Bad Request: missing or unsupported method in Content-Type header', 400);
239
+			throw new Exception('Bad Request: missing or unsupported method in Content-Type header', 400);
240 240
 		}
241 241
 		// parse iCal
242 242
 		// code copied from calendar_groupdav::outbox_freebusy_request for now
@@ -248,11 +248,11 @@  discard block
 block discarded – undo
248 248
 		}
249 249
 		$version = $vcal->getAttribute('VERSION');
250 250
 		$handler = new calendar_ical();
251
-		$handler->setSupportedFields('GroupDAV',$this->agent);
252
-		$handler->calendarOwner = $handler->user = 0;	// to NOT default owner/organizer to something
251
+		$handler->setSupportedFields('GroupDAV', $this->agent);
252
+		$handler->calendarOwner = $handler->user = 0; // to NOT default owner/organizer to something
253 253
 		if (!($vcal_comp = $vcal->getComponent(0)) ||
254 254
 			!($event = $handler->vevent2egw($vcal_comp, $version, $handler->supportedFields,
255
-				$principalURL='', $check_component='Horde_iCalendar_'.strtolower($component))))
255
+				$principalURL = '', $check_component = 'Horde_iCalendar_'.strtolower($component))))
256 256
 		{
257 257
 			throw new Exception('Bad Request: invalid-calendar-data: Failed converting iCal', 400);
258 258
 		}
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
 		if (isset($originator_requirement))
263 263
 		{
264 264
 			$matches = false;
265
-			foreach($originator_requirement as $requirement)
265
+			foreach ($originator_requirement as $requirement)
266 266
 			{
267 267
 				$originator = $headers['originator'];
268 268
 				if (stripos($originator, 'mailto:') === 0) $originator = substr($originator, 7);
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
 					 	in_array($originator_account_id, $event['participants'])))
277 277
 			 	{
278 278
 			 		$matches = true;
279
-			 		break;	// no need to try further as we OR
279
+			 		break; // no need to try further as we OR
280 280
 			 	}
281 281
 			}
282 282
 			if (!$matches)
@@ -289,9 +289,9 @@  discard block
 block discarded – undo
289 289
 		$xml->openMemory();
290 290
 		$xml->setIndent(true);
291 291
 		$xml->startDocument('1.0', 'UTF-8');
292
-		$xml->startElementNs(null, 'schedule-response', self::ISCHEDULE);	// null = no prefix
292
+		$xml->startElementNs(null, 'schedule-response', self::ISCHEDULE); // null = no prefix
293 293
 
294
-		switch($component)
294
+		switch ($component)
295 295
 		{
296 296
 			case 'VFREEBUSY':
297 297
 				$this->vfreebusy($event, $handler, $vcal_comp, $xml);
@@ -302,10 +302,10 @@  discard block
 block discarded – undo
302 302
 				break;
303 303
 
304 304
 			default:
305
-				throw new Exception ('Bad Request: invalid-calendar-data-type: not implemented', 400);
305
+				throw new Exception('Bad Request: invalid-calendar-data-type: not implemented', 400);
306 306
 		}
307 307
 
308
-		$xml->endElement();	// schedule-response
308
+		$xml->endElement(); // schedule-response
309 309
 		$xml->endDocument();
310 310
 
311 311
 		header('Content-Type: text/xml; charset=UTF-8');
@@ -331,11 +331,11 @@  discard block
 block discarded – undo
331 331
 		$handler->importVCal($vCalendar, $eventId,
332 332
 			self::etag2value($this->http_if_match), false, 0, $this->groupdav->current_user_principal, $user, $charset, $id);
333 333
 
334
-		foreach($event['participants'] as $uid => $status)
334
+		foreach ($event['participants'] as $uid => $status)
335 335
 		{
336 336
 			$xml->startElement('response');
337 337
 
338
-			$xml->writeElement('recipient', $attendee=array_shift($attendees));	// iSchedule has not DAV:href!
338
+			$xml->writeElement('recipient', $attendee = array_shift($attendees)); // iSchedule has not DAV:href!
339 339
 
340 340
 			if (is_numeric($uid))
341 341
 			{
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
 				$xml->writeElement('request-status', '3.7;Invalid Calendar User');
348 348
 				$xml->writeElement('responsedescription', 'Recipient not a local user');
349 349
 			}
350
-			$xml->endElement();	// response
350
+			$xml->endElement(); // response
351 351
 		}
352 352
 	}
353 353
 
@@ -364,11 +364,11 @@  discard block
 block discarded – undo
364 364
 		$organizer = $component->getAttribute('ORGANIZER');
365 365
 		$attendees = (array)$component->getAttribute('ATTENDEE');
366 366
 
367
-		foreach($attendees as $attendee)
367
+		foreach ($attendees as $attendee)
368 368
 		{
369 369
 			$xml->startElement('response');
370 370
 
371
-			$xml->writeElement('recipient', $attendee);	// iSchedule has not DAV:href!
371
+			$xml->writeElement('recipient', $attendee); // iSchedule has not DAV:href!
372 372
 
373 373
 			if (stripos($attendee, 'mailto:') === 0 &&
374 374
 				($uid = $GLOBALS['egw']->accounts->name2id(substr($attendee, 7), 'account_email')))
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
 			{
386 386
 				$xml->writeElement('request-status', '3.7;Invalid Calendar User');
387 387
 			}
388
-			$xml->endElement();	// response
388
+			$xml->endElement(); // response
389 389
 		}
390 390
 	}
391 391
 	/**
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
 	 * @param string &$error=null error if false returned
409 409
 	 * @return boolean true if signature could be validated, false otherwise
410 410
 	 */
411
-	public static function dkim_validate(array $headers, $body, &$error=null)
411
+	public static function dkim_validate(array $headers, $body, &$error = null)
412 412
 	{
413 413
 		// parse dkim signature, after unfolding it
414 414
 		if (!isset($headers['dkim-signature']) ||
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
 		// create headers array, h tag can contain whitespace, which need to be removed
438 438
 		$dkim_headers = array();
439 439
 		$check = $headers;
440
-		foreach(explode(':', strtolower(preg_replace("|\s|", "", $dkim['h']))) as $header)
440
+		foreach (explode(':', strtolower(preg_replace("|\s|", "", $dkim['h']))) as $header)
441 441
 		{
442 442
 			// dkim oversigning: ommit not existing headers in signing
443 443
 			if (!isset($check[$header])) continue;
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
 		list($header_canon, $body_canon) = explode('/', isset($dkim['c']) ? $dkim['c'] : 'simple/simple');
455 455
 
456 456
 		// Canonicalization for Body
457
-		switch($body_canon)
457
+		switch ($body_canon)
458 458
 		{
459 459
 			case 'relaxed':
460 460
 				$_b = mailDomainSigner::bodyRelaxCanon($body);
@@ -489,18 +489,18 @@  discard block
 block discarded – undo
489 489
 		}
490 490
 
491 491
 		// Canonicalization Header Data
492
-		switch($header_canon)
492
+		switch ($header_canon)
493 493
 		{
494 494
 			case 'relaxed':
495
-				$_unsigned  = mailDomainSigner::headRelaxCanon(implode("\r\n", $dkim_headers). "\r\n".$dkim_unsigned);
495
+				$_unsigned = mailDomainSigner::headRelaxCanon(implode("\r\n", $dkim_headers)."\r\n".$dkim_unsigned);
496 496
 				break;
497 497
 
498 498
 			case 'ischedule-relaxed':
499
-				$_unsigned  = mailDomainSigner::headIScheduleRelaxCanon(implode("\r\n", $dkim_headers). "\r\n".$dkim_unsigned);
499
+				$_unsigned = mailDomainSigner::headIScheduleRelaxCanon(implode("\r\n", $dkim_headers)."\r\n".$dkim_unsigned);
500 500
 				break;
501 501
 
502 502
 			case 'simple':
503
-				$_unsigned  = mailDomainSigner::headSimpleCanon(implode("\r\n", $dkim_headers). "\r\n".$dkim_unsigned);
503
+				$_unsigned = mailDomainSigner::headSimpleCanon(implode("\r\n", $dkim_headers)."\r\n".$dkim_unsigned);
504 504
 				break;
505 505
 
506 506
 			default:
@@ -509,9 +509,9 @@  discard block
 block discarded – undo
509 509
 		}
510 510
 
511 511
 		// fetch public key using method in dkim q
512
-		foreach(explode(':', $dkim['q']) as $method)
512
+		foreach (explode(':', $dkim['q']) as $method)
513 513
 		{
514
-			switch($method)
514
+			switch ($method)
515 515
 			{
516 516
 				case 'dns/txt':
517 517
 					$public_key = self::dns_txt_pubkey($dkim['d'], $dkim['s']);
@@ -543,7 +543,7 @@  discard block
 block discarded – undo
543 543
 		$ok = openssl_verify($_unsigned, base64_decode(preg_replace("|\s|", "", $dkim['b'])), $public_key, $hash_algo);
544 544
 		if ($ok != 1) error_log(__METHOD__."() openssl_verify('$_unsigned', ..., '$public_key', '$hash_algo') returned ".array2string($ok));
545 545
 
546
-		switch($ok)
546
+		switch ($ok)
547 547
 		{
548 548
 			case -1:
549 549
 				$error = 'Error while verifying DKIM';
@@ -671,9 +671,9 @@  discard block
 block discarded – undo
671 671
 	 * @param string $selector
672 672
 	 * @return array with values for keys parsed from eg. "v=DKIM1\;k=rsa\;h=sha1\;s=calendar\;t=s\;p=..."
673 673
 	 */
674
-	public static function fetch_dns($domain, $selector='calendar')
674
+	public static function fetch_dns($domain, $selector = 'calendar')
675 675
 	{
676
-		if (!($records = dns_get_record($host=$selector.'._domainkey.'.$domain, DNS_TXT))) return false;
676
+		if (!($records = dns_get_record($host = $selector.'._domainkey.'.$domain, DNS_TXT))) return false;
677 677
 
678 678
 		if (!isset($records[0]['text']) &&
679 679
 			!preg_match_all('/[\t\s]*([a-z]+)=([^;]+);?/i', $records[0]['txt'], $matches))
@@ -753,57 +753,57 @@  discard block
 block discarded – undo
753 753
 		$xml->writeElement('serial-number', self::SERIAL);
754 754
 
755 755
 		$xml->startElement('versions');
756
-		foreach(self::$supported_versions as $version)
756
+		foreach (self::$supported_versions as $version)
757 757
 		{
758 758
 			$xml->writeElement('version', $version);
759 759
 		}
760
-		$xml->endElement();	// versions
760
+		$xml->endElement(); // versions
761 761
 
762 762
 		$xml->startElement('scheduling-messages');
763
-		foreach(self::$supported_components as $component => $methods)
763
+		foreach (self::$supported_components as $component => $methods)
764 764
 		{
765 765
 			$xml->startElement('component');
766 766
 			$xml->writeAttribute('name', $component);
767
-			foreach($methods as $method)
767
+			foreach ($methods as $method)
768 768
 			{
769 769
 				$xml->startElement('method');
770 770
 				$xml->writeAttribute('name', $method);
771
-				$xml->endElement();	// method
771
+				$xml->endElement(); // method
772 772
 			}
773
-			$xml->endElement();	// component
773
+			$xml->endElement(); // component
774 774
 		}
775
-		$xml->endElement();	// scheduling-messages
775
+		$xml->endElement(); // scheduling-messages
776 776
 
777 777
 		$xml->startElement('calendar-data-types');
778
-		foreach(self::$supported_calendar_data_types as $data)
778
+		foreach (self::$supported_calendar_data_types as $data)
779 779
 		{
780 780
 			$xml->startElement('calendar-data-type');
781
-			foreach($data as $name => $value)
781
+			foreach ($data as $name => $value)
782 782
 			{
783 783
 				$xml->writeAttribute($name, $value);
784 784
 			}
785
-			$xml->endElement();	// calendar-data-type
785
+			$xml->endElement(); // calendar-data-type
786 786
 		}
787
-		$xml->endElement();	// calendar-data-types
787
+		$xml->endElement(); // calendar-data-types
788 788
 
789 789
 		$xml->startElement('attachments');
790
-		foreach(self::$supported_attachments as $type)
790
+		foreach (self::$supported_attachments as $type)
791 791
 		{
792 792
 			$xml->writeElement($type, '');
793 793
 		}
794
-		$xml->endElement();	// attachments
794
+		$xml->endElement(); // attachments
795 795
 
796 796
 		if (!empty($GLOBALS['egw_info']['server']['admin_mails']))
797 797
 		{
798 798
 			self::$capablities['administrator'] = 'mailto:'.$GLOBALS['egw_info']['server']['admin_mails'];
799 799
 		}
800
-		foreach(self::$capablities as $name => $value)
800
+		foreach (self::$capablities as $name => $value)
801 801
 		{
802 802
 			$xml->writeElement($name, $value);
803 803
 		}
804 804
 
805
-		$xml->endElement();	// capabilities
806
-		$xml->endElement();	// query-result
805
+		$xml->endElement(); // capabilities
806
+		$xml->endElement(); // query-result
807 807
 		$xml->endDocument();
808 808
 		$capabilities = $xml->outputMemory();
809 809
 
@@ -828,7 +828,7 @@  discard block
 block discarded – undo
828 828
 	public static function exception_handler(Exception $e)
829 829
 	{
830 830
 		// logging exception as regular egw_execption_hander does
831
-		_egw_log_exception($e,$headline);
831
+		_egw_log_exception($e, $headline);
832 832
 
833 833
 		// exception handler sending message back to the client as http status
834 834
 		$code = $e->getCode();
Please login to merge, or discard this patch.
Braces   +33 added lines, -9 removed lines patch added patch discarded remove patch
@@ -86,7 +86,10 @@  discard block
 block discarded – undo
86 86
 				header("HTTP/1.1 400 Bad Request");
87 87
 		}
88 88
 
89
-		if (self::$request_starttime) self::log_request();
89
+		if (self::$request_starttime)
90
+		{
91
+			self::log_request();
92
+		}
90 93
 	}
91 94
 
92 95
 	/**
@@ -265,7 +268,10 @@  discard block
 block discarded – undo
265 268
 			foreach($originator_requirement as $requirement)
266 269
 			{
267 270
 				$originator = $headers['originator'];
268
-				if (stripos($originator, 'mailto:') === 0) $originator = substr($originator, 7);
271
+				if (stripos($originator, 'mailto:') === 0)
272
+				{
273
+					$originator = substr($originator, 7);
274
+				}
269 275
 
270 276
 				if ($requirement == 'ORGANIZER' &&
271 277
 					($event['organizer'] == $originator || strpos($event['organizer'], '<'.$originator.'>') !== false) ||
@@ -274,7 +280,7 @@  discard block
 block discarded – undo
274 280
 					// ToDO: Participant could have CN, need to check that too
275 281
 					 $originator_account_id = $GLOBALS['egw']->accounts->name2id($originator, 'account_email') &&
276 282
 					 	in_array($originator_account_id, $event['participants'])))
277
-			 	{
283
+				{
278 284
 			 		$matches = true;
279 285
 			 		break;	// no need to try further as we OR
280 286
 			 	}
@@ -440,7 +446,10 @@  discard block
 block discarded – undo
440 446
 		foreach(explode(':', strtolower(preg_replace("|\s|", "", $dkim['h']))) as $header)
441 447
 		{
442 448
 			// dkim oversigning: ommit not existing headers in signing
443
-			if (!isset($check[$header])) continue;
449
+			if (!isset($check[$header]))
450
+			{
451
+				continue;
452
+			}
444 453
 
445 454
 			$value = $check[$header];
446 455
 			unset($check[$header]);
@@ -529,10 +538,16 @@  discard block
 block discarded – undo
529 538
 					$public_key = false;
530 539
 					break;
531 540
 			}
532
-			if ($public_key) break;
541
+			if ($public_key)
542
+			{
543
+				break;
544
+			}
533 545
 		}
534 546
 		// for testing purpose allways try private-exchange, if none other match
535
-		if (!$public_key) $public_key = self::private_exchange_pubkey($dkim['d'], $dkim['s']);
547
+		if (!$public_key)
548
+		{
549
+			$public_key = self::private_exchange_pubkey($dkim['d'], $dkim['s']);
550
+		}
536 551
 
537 552
 		if (!$public_key)
538 553
 		{
@@ -541,7 +556,10 @@  discard block
 block discarded – undo
541 556
 		}
542 557
 		// value of b tag can contain whitespace, which need to be removed
543 558
 		$ok = openssl_verify($_unsigned, base64_decode(preg_replace("|\s|", "", $dkim['b'])), $public_key, $hash_algo);
544
-		if ($ok != 1) error_log(__METHOD__."() openssl_verify('$_unsigned', ..., '$public_key', '$hash_algo') returned ".array2string($ok));
559
+		if ($ok != 1)
560
+		{
561
+			error_log(__METHOD__."() openssl_verify('$_unsigned', ..., '$public_key', '$hash_algo') returned ".array2string($ok));
562
+		}
545 563
 
546 564
 		switch($ok)
547 565
 		{
@@ -673,7 +691,10 @@  discard block
 block discarded – undo
673 691
 	 */
674 692
 	public static function fetch_dns($domain, $selector='calendar')
675 693
 	{
676
-		if (!($records = dns_get_record($host=$selector.'._domainkey.'.$domain, DNS_TXT))) return false;
694
+		if (!($records = dns_get_record($host=$selector.'._domainkey.'.$domain, DNS_TXT)))
695
+		{
696
+			return false;
697
+		}
677 698
 
678 699
 		if (!isset($records[0]['text']) &&
679 700
 			!preg_match_all('/[\t\s]*([a-z]+)=([^;]+);?/i', $records[0]['txt'], $matches))
@@ -840,7 +861,10 @@  discard block
 block discarded – undo
840 861
 			$description = $error.($description ? ': '.$description : '');
841 862
 			$error = 'invalid-scheduling-message';
842 863
 		}
843
-		if (!in_array($code, array(400, 403, 407, 503))) $code = 500;
864
+		if (!in_array($code, array(400, 403, 407, 503)))
865
+		{
866
+			$code = 500;
867
+		}
844 868
 
845 869
 		header('HTTP/1.1 '.$code.' '.$http_status, true, $code);
846 870
 		header('Content-Type: text/xml; charset=UTF-8');
Please login to merge, or discard this patch.
phpgwapi/inc/class.jscalendar.inc.php 3 patches
Doc Comments   +7 added lines, -14 removed lines patch added patch discarded remove patch
@@ -33,8 +33,7 @@  discard block
 block discarded – undo
33 33
 	/**
34 34
 	 * Constructor
35 35
 	 *
36
-	 * @param boolean $do_header=true if true, necessary javascript and css gets loaded, only needed for input
37
-	 * @param string $path='jscalendar'
36
+	 * @param boolean $do_header if true, necessary javascript and css gets loaded, only needed for input
38 37
 	 * @return jscalendar
39 38
 	 */
40 39
 	function __construct($do_header=True,$path='jscalendar')
@@ -81,14 +80,14 @@  discard block
 block discarded – undo
81 80
 	 * Creates an inputfield for the jscalendar (returns the necessary html and js)
82 81
 	 *
83 82
 	 * @param string $name name and id of the input-field (it also names the id of the img $name.'-toggle')
84
-	 * @param int/string $date date as string or unix timestamp (in server timezone)
85
-	 * @param int $year=0 if $date is not used
86
-	 * @param int $month=0 if $date is not used
87
-	 * @param int $day=0 if $date is not used
83
+	 * @param boolean $date date as string or unix timestamp (in server timezone)
84
+	 * @param int $year if $date is not used
85
+	 * @param int $month if $date is not used
86
+	 * @param int $day if $date is not used
88 87
 	 * @param string $helpmsg='' a helpmessage for the statusline of the browser
89 88
 	 * @param string $options='' any other options to the inputfield
90
-	 * @param boolean $jsreturn=false
91
-	 * @param boolean $useicon=true true: use icon to trigger popup, false: click into input triggers popup
89
+	 * @param boolean $jsreturn
90
+	 * @param boolean $useicon true: use icon to trigger popup, false: click into input triggers popup
92 91
 	 * 		the input is made readonly via javascript to NOT trigger mobile devices to display a keyboard!
93 92
 	 * @return string html
94 93
 	 */
@@ -150,12 +149,10 @@  discard block
 block discarded – undo
150 149
 	 * Flat jscalendar with tooltips and url's for days, weeks and month
151 150
 	 *
152 151
 	 * @param string $url url to call if user clicks on a date (&date=YYYYmmdd is appended automatically)
153
-	 * @param string/int $date=null format YYYYmmdd or timestamp
154 152
 	 * @param string $weekUrl=''
155 153
 	 * @param string $weekTTip=''
156 154
 	 * @param string $monthUrl=''
157 155
 	 * @param string $monthTTip=''
158
-	 * @param string $id='calendar-container'
159 156
 	 * @return string html
160 157
 	 */
161 158
 	function flat($url,$date=null,$weekUrl='',$weekTTip='',$monthUrl='',$monthTTip='',$id='calendar-container')
@@ -212,10 +209,6 @@  discard block
 block discarded – undo
212 209
 	 * Converts the date-string back to an array with year, month, day and a timestamp
213 210
 	 *
214 211
 	 * @param string $datestr content of the inputfield generated by jscalendar::input()
215
-	 * @param boolean/string $raw='raw' key of the timestamp-field in the returned array or False of no timestamp
216
-	 * @param string $day='day' keys for the array, eg. to set mday instead of day
217
-	 * @param string $month='month' keys for the array
218
-	 * @param string $year='year' keys for the array
219 212
 	 * @return array/boolean array with the specified keys and values or false if $datestr == ''
220 213
 	 */
221 214
 	function input2date($datestr,$raw='raw',$day='day',$month='month',$year='year')
Please login to merge, or discard this patch.
Spacing   +32 added lines, -34 removed lines patch added patch discarded remove patch
@@ -37,12 +37,12 @@  discard block
 block discarded – undo
37 37
 	 * @param string $path='jscalendar'
38 38
 	 * @return jscalendar
39 39
 	 */
40
-	function __construct($do_header=True,$path='jscalendar')
40
+	function __construct($do_header = True, $path = 'jscalendar')
41 41
 	{
42 42
 		$this->jscalendar_url = $GLOBALS['egw_info']['server']['webserver_url'].'/phpgwapi/js/'.$path;
43 43
 		$this->dateformat = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat'];
44 44
 
45
-		$args = array_intersect_key($GLOBALS['egw_info']['user']['preferences']['common'],array('lang'=>1,'dateformat'=>1));
45
+		$args = array_intersect_key($GLOBALS['egw_info']['user']['preferences']['common'], array('lang'=>1, 'dateformat'=>1));
46 46
 		if (isset($GLOBALS['egw_info']['flags']['currentapp']))
47 47
 		{
48 48
 			$args['app'] = $GLOBALS['egw_info']['flags']['currentapp'];
@@ -54,9 +54,9 @@  discard block
 block discarded – undo
54 54
 		if ($do_header)
55 55
 		{
56 56
 			egw_framework::includeCSS('/phpgwapi/js/jscalendar/calendar-blue.css');
57
-			egw_framework::validate_file('jscalendar','calendar');
58
-			$args = array_intersect_key($GLOBALS['egw_info']['user']['preferences']['common'],array('lang'=>1,'dateformat'=>1));
59
-			egw_framework::validate_file('/phpgwapi/inc/jscalendar-setup.php',$args);
57
+			egw_framework::validate_file('jscalendar', 'calendar');
58
+			$args = array_intersect_key($GLOBALS['egw_info']['user']['preferences']['common'], array('lang'=>1, 'dateformat'=>1));
59
+			egw_framework::validate_file('/phpgwapi/inc/jscalendar-setup.php', $args);
60 60
 		}
61 61
 	}
62 62
 
@@ -69,11 +69,11 @@  discard block
 block discarded – undo
69 69
 	 */
70 70
 	function get_javascript()
71 71
 	{
72
-		$args = array_intersect_key($GLOBALS['egw_info']['user']['preferences']['common'],array('lang'=>1,'dateformat'=>1));
72
+		$args = array_intersect_key($GLOBALS['egw_info']['user']['preferences']['common'], array('lang'=>1, 'dateformat'=>1));
73 73
 		return
74 74
 '<link rel="stylesheet" type="text/css" media="all" href="'.$this->jscalendar_url.'/calendar-blue.css" title="blue" />
75 75
 <script type="text/javascript" src="'.$this->jscalendar_url.'/calendar.js"></script>
76
-<script type="text/javascript" src="'.egw::link('/phpgwapi/inc/jscalendar-setup.php',$args,false).'"></script>
76
+<script type="text/javascript" src="'.egw::link('/phpgwapi/inc/jscalendar-setup.php', $args, false).'"></script>
77 77
 ';
78 78
 	}
79 79
 
@@ -92,43 +92,42 @@  discard block
 block discarded – undo
92 92
 	 * 		the input is made readonly via javascript to NOT trigger mobile devices to display a keyboard!
93 93
 	 * @return string html
94 94
 	 */
95
-	function input($name,$date,$year=0,$month=0,$day=0,$helpmsg='',$options='',$jsreturn=false,$useicon=true)
95
+	function input($name, $date, $year = 0, $month = 0, $day = 0, $helpmsg = '', $options = '', $jsreturn = false, $useicon = true)
96 96
 	{
97 97
 		//echo "<p>jscalendar::input(name='$name', date='$date'='".date('Y-m-d',$date)."', year='$year', month='$month', day='$day')</p>\n";
98 98
 
99 99
 		if ($date && (is_int($date) || is_numeric($date)))
100 100
 		{
101
-			$year  = (int)adodb_date('Y',$date);
102
-			$month = (int)adodb_date('n',$date);
103
-			$day   = (int)adodb_date('d',$date);
101
+			$year  = (int)adodb_date('Y', $date);
102
+			$month = (int)adodb_date('n', $date);
103
+			$day   = (int)adodb_date('d', $date);
104 104
 		}
105 105
 		if ($year && $month && $day)
106 106
 		{
107
-			$date = adodb_date($this->dateformat,$ts = adodb_mktime(12,0,0,$month,$day,$year));
108
-			if (strpos($this->dateformat,'M') !== false)
107
+			$date = adodb_date($this->dateformat, $ts = adodb_mktime(12, 0, 0, $month, $day, $year));
108
+			if (strpos($this->dateformat, 'M') !== false)
109 109
 			{
110 110
 				static $substr;
111 111
 				if (is_null($substr)) $substr = function_exists('mb_substr') ? 'mb_substr' : 'substr';
112 112
 				static $chars_shortcut;
113
-				if (is_null($chars_shortcut)) $chars_shortcut = (int)lang('3 number of chars for month-shortcut');	// < 0 to take the chars from the end
113
+				if (is_null($chars_shortcut)) $chars_shortcut = (int)lang('3 number of chars for month-shortcut'); // < 0 to take the chars from the end
114 114
 
115
-				$short = translation::translate($m = adodb_date('M',$ts), null, '*');	// check if we have a translation of the short-cut
116
-				if ($substr($short,-1) == '*')	// if not generate one by truncating the translation of the long name
115
+				$short = translation::translate($m = adodb_date('M', $ts), null, '*'); // check if we have a translation of the short-cut
116
+				if ($substr($short, -1) == '*')	// if not generate one by truncating the translation of the long name
117 117
 				{
118
-					$short = $chars_shortcut > 0 ? $substr(lang(adodb_date('F',$ts)),0,$chars_shortcut) :
119
-						$substr(lang(adodb_date('F',$ts)),$chars_shortcut);
118
+					$short = $chars_shortcut > 0 ? $substr(lang(adodb_date('F', $ts)), 0, $chars_shortcut) : $substr(lang(adodb_date('F', $ts)), $chars_shortcut);
120 119
 				}
121
-				$date = str_replace(adodb_date('M',$ts),$short,$date);
120
+				$date = str_replace(adodb_date('M', $ts), $short, $date);
122 121
 			}
123 122
 		}
124 123
 		if ($helpmsg !== '')
125 124
 		{
126
-			$options .= " onFocus=\"self.status='".addslashes($helpmsg)."'; return true;\"" .
125
+			$options .= " onFocus=\"self.status='".addslashes($helpmsg)."'; return true;\"".
127 126
 			" onBlur=\"self.status=''; return true;\"";
128 127
 		}
129 128
 
130 129
 		$html = '<input type="text" id="'.$name.'" name="'.$name.'" size="10" value="'.htmlspecialchars($date).'"'.$options.'/>
131
-'.($useicon ? '<img id="'.$name.'-trigger" src="'.common::find_image('phpgwapi','datepopup').'" title="'.lang('Select date').'" style="cursor:pointer; cursor:hand;">' : '');
130
+'.($useicon ? '<img id="'.$name.'-trigger" src="'.common::find_image('phpgwapi', 'datepopup').'" title="'.lang('Select date').'" style="cursor:pointer; cursor:hand;">' : '');
132 131
 
133 132
 		$js = '<script type="text/javascript">
134 133
 '.(!$useicon ? '	document.getElementById("'.$name.'").readOnly=true;' : '').
@@ -158,12 +157,11 @@  discard block
 block discarded – undo
158 157
 	 * @param string $id='calendar-container'
159 158
 	 * @return string html
160 159
 	 */
161
-	function flat($url,$date=null,$weekUrl='',$weekTTip='',$monthUrl='',$monthTTip='',$id='calendar-container')
160
+	function flat($url, $date = null, $weekUrl = '', $weekTTip = '', $monthUrl = '', $monthTTip = '', $id = 'calendar-container')
162 161
 	{
163 162
 		if ($date)	// string if format YYYYmmdd or timestamp
164 163
 		{
165
-			$date = is_int($date) ? adodb_date('m/d/Y',$date) :
166
-				substr($date,4,2).'/'.substr($date,6,2).'/'.substr($date,0,4);
164
+			$date = is_int($date) ? adodb_date('m/d/Y', $date) : substr($date, 4, 2).'/'.substr($date, 6, 2).'/'.substr($date, 0, 4);
167 165
 		}
168 166
 		return '
169 167
 <div id="'.$id.'"></div>
@@ -218,28 +216,28 @@  discard block
 block discarded – undo
218 216
 	 * @param string $year='year' keys for the array
219 217
 	 * @return array/boolean array with the specified keys and values or false if $datestr == ''
220 218
 	 */
221
-	function input2date($datestr,$raw='raw',$day='day',$month='month',$year='year')
219
+	function input2date($datestr, $raw = 'raw', $day = 'day', $month = 'month', $year = 'year')
222 220
 	{
223 221
 		//echo "<p>jscalendar::input2date('$datestr') ".print_r($fields,True)."</p>\n";
224 222
 		if ($datestr === '')
225 223
 		{
226 224
 			return False;
227 225
 		}
228
-		$fields = preg_split('/[.\\/-]/',$datestr);
229
-		foreach(preg_split('/[.\\/-]/',$this->dateformat) as $n => $field)
226
+		$fields = preg_split('/[.\\/-]/', $datestr);
227
+		foreach (preg_split('/[.\\/-]/', $this->dateformat) as $n => $field)
230 228
 		{
231 229
 			if ($field == 'M')
232 230
 			{
233 231
 				if (!is_numeric($fields[$n]))
234 232
 				{
235 233
 					$partcial_match = 0;
236
-					for($i = 1; $i <= 12; $i++)
234
+					for ($i = 1; $i <= 12; $i++)
237 235
 					{
238
-						$long_name  = lang(adodb_date('F',mktime(12,0,0,$i,1,2000)));
239
-						$short_name = translation::translate(adodb_date('M',mktime(12,0,0,$i,1,2000)), null, '*');	// do we have a translation of the short-cut
240
-						if (substr($short_name,-1) == '*')	// if not generate one by truncating the translation of the long name
236
+						$long_name  = lang(adodb_date('F', mktime(12, 0, 0, $i, 1, 2000)));
237
+						$short_name = translation::translate(adodb_date('M', mktime(12, 0, 0, $i, 1, 2000)), null, '*'); // do we have a translation of the short-cut
238
+						if (substr($short_name, -1) == '*')	// if not generate one by truncating the translation of the long name
241 239
 						{
242
-							$short_name = substr($long_name,0,(int) lang('3 number of chars for month-shortcut'));
240
+							$short_name = substr($long_name, 0, (int)lang('3 number of chars for month-shortcut'));
243 241
 						}
244 242
 						//echo "<br>checking '".$fields[$n]."' against '$long_name' or '$short_name'";
245 243
 						if ($fields[$n] == $long_name || $fields[$n] == $short_name)
@@ -248,7 +246,7 @@  discard block
 block discarded – undo
248 246
 							$fields[$n] = $i;
249 247
 							break;
250 248
 						}
251
-						if (@strstr($long_name,$fields[$n]) == $long_name)	// partcial match => multibyte saver
249
+						if (@strstr($long_name, $fields[$n]) == $long_name)	// partcial match => multibyte saver
252 250
 						{
253 251
 							$partcial_match = $i;
254 252
 						}
@@ -270,7 +268,7 @@  discard block
 block discarded – undo
270 268
 		);
271 269
 		if ($raw)
272 270
 		{
273
-			$ret[$raw] = adodb_mktime(12,0,0,$date['m'],$date['d'],$date['Y']);
271
+			$ret[$raw] = adodb_mktime(12, 0, 0, $date['m'], $date['d'], $date['Y']);
274 272
 		}
275 273
 		//echo "<p>jscalendar::input2date('$datestr','$raw',$day','$month','$year') = "; print_r($ret); echo "</p>\n";
276 274
 
Please login to merge, or discard this patch.
Braces   +33 added lines, -8 removed lines patch added patch discarded remove patch
@@ -108,16 +108,26 @@  discard block
 block discarded – undo
108 108
 			if (strpos($this->dateformat,'M') !== false)
109 109
 			{
110 110
 				static $substr;
111
-				if (is_null($substr)) $substr = function_exists('mb_substr') ? 'mb_substr' : 'substr';
111
+				if (is_null($substr))
112
+				{
113
+					$substr = function_exists('mb_substr') ? 'mb_substr' : 'substr';
114
+				}
112 115
 				static $chars_shortcut;
113
-				if (is_null($chars_shortcut)) $chars_shortcut = (int)lang('3 number of chars for month-shortcut');	// < 0 to take the chars from the end
116
+				if (is_null($chars_shortcut))
117
+				{
118
+					$chars_shortcut = (int)lang('3 number of chars for month-shortcut');
119
+				}
120
+				// < 0 to take the chars from the end
114 121
 
115 122
 				$short = translation::translate($m = adodb_date('M',$ts), null, '*');	// check if we have a translation of the short-cut
116
-				if ($substr($short,-1) == '*')	// if not generate one by truncating the translation of the long name
123
+				if ($substr($short,-1) == '*')
124
+				{
125
+					// if not generate one by truncating the translation of the long name
117 126
 				{
118 127
 					$short = $chars_shortcut > 0 ? $substr(lang(adodb_date('F',$ts)),0,$chars_shortcut) :
119 128
 						$substr(lang(adodb_date('F',$ts)),$chars_shortcut);
120 129
 				}
130
+				}
121 131
 				$date = str_replace(adodb_date('M',$ts),$short,$date);
122 132
 			}
123 133
 		}
@@ -141,7 +151,10 @@  discard block
 block discarded – undo
141 151
 	});
142 152
 </script>
143 153
 ';
144
-		if ($jsreturn) return array('html' => $html, 'js' => $js);
154
+		if ($jsreturn)
155
+		{
156
+			return array('html' => $html, 'js' => $js);
157
+		}
145 158
 
146 159
 		return $html."\n".$js;
147 160
 	}
@@ -160,11 +173,14 @@  discard block
 block discarded – undo
160 173
 	 */
161 174
 	function flat($url,$date=null,$weekUrl='',$weekTTip='',$monthUrl='',$monthTTip='',$id='calendar-container')
162 175
 	{
163
-		if ($date)	// string if format YYYYmmdd or timestamp
176
+		if ($date)
177
+		{
178
+			// string if format YYYYmmdd or timestamp
164 179
 		{
165 180
 			$date = is_int($date) ? adodb_date('m/d/Y',$date) :
166 181
 				substr($date,4,2).'/'.substr($date,6,2).'/'.substr($date,0,4);
167 182
 		}
183
+		}
168 184
 		return '
169 185
 <div id="'.$id.'"></div>
170 186
 <script type="text/javascript">
@@ -237,10 +253,13 @@  discard block
 block discarded – undo
237 253
 					{
238 254
 						$long_name  = lang(adodb_date('F',mktime(12,0,0,$i,1,2000)));
239 255
 						$short_name = translation::translate(adodb_date('M',mktime(12,0,0,$i,1,2000)), null, '*');	// do we have a translation of the short-cut
240
-						if (substr($short_name,-1) == '*')	// if not generate one by truncating the translation of the long name
256
+						if (substr($short_name,-1) == '*')
257
+						{
258
+							// if not generate one by truncating the translation of the long name
241 259
 						{
242 260
 							$short_name = substr($long_name,0,(int) lang('3 number of chars for month-shortcut'));
243 261
 						}
262
+						}
244 263
 						//echo "<br>checking '".$fields[$n]."' against '$long_name' or '$short_name'";
245 264
 						if ($fields[$n] == $long_name || $fields[$n] == $short_name)
246 265
 						{
@@ -248,15 +267,21 @@  discard block
 block discarded – undo
248 267
 							$fields[$n] = $i;
249 268
 							break;
250 269
 						}
251
-						if (@strstr($long_name,$fields[$n]) == $long_name)	// partcial match => multibyte saver
270
+						if (@strstr($long_name,$fields[$n]) == $long_name)
271
+						{
272
+							// partcial match => multibyte saver
252 273
 						{
253 274
 							$partcial_match = $i;
254 275
 						}
276
+						}
255 277
 					}
256
-					if ($i > 12 && $partcial_match)	// nothing found, but a partcial match
278
+					if ($i > 12 && $partcial_match)
279
+					{
280
+						// nothing found, but a partcial match
257 281
 					{
258 282
 						$fields[$n] = $partcial_match;
259 283
 					}
284
+					}
260 285
 				}
261 286
 				$field = 'm';
262 287
 			}
Please login to merge, or discard this patch.
phpgwapi/inc/class.ldap.inc.php 4 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	/**
51 51
 	 * Constructor
52 52
 	 *
53
-	 * @param boolean $exception_on_error=false true: throw Exceptions in ldapConnect instead of echoing error and returning false
53
+	 * @param boolean $exception_on_error true: throw Exceptions in ldapConnect instead of echoing error and returning false
54 54
 	 */
55 55
 	function __construct($exception_on_error=false)
56 56
 	{
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 	/**
62 62
 	 * Returns information about connected ldap server
63 63
 	 *
64
-	 * @return ldapserverinfo|null
64
+	 * @return ldapserverinfo
65 65
 	 */
66 66
 	function getLDAPServerInfo()
67 67
 	{
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 	 * @param string $host ldap host
179 179
 	 * @param string $dn ldap dn
180 180
 	 * @param string $passwd ldap pw
181
-	 * @return resource|boolean resource from ldap_connect() or false on error
181
+	 * @return boolean resource from ldap_connect() or false on error
182 182
 	 */
183 183
 	private function _connect($host, $dn, $passwd)
184 184
 	{
Please login to merge, or discard this patch.
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -27,17 +27,17 @@
 block discarded – undo
27 27
 class ldap
28 28
 {
29 29
 	/**
30
-	* Holds the LDAP link identifier
31
-	*
32
-	* @var resource $ds
33
-	*/
30
+	 * Holds the LDAP link identifier
31
+	 *
32
+	 * @var resource $ds
33
+	 */
34 34
 	var $ds;
35 35
 
36 36
 	/**
37
-	* Holds the detected information about the connected ldap server
38
-	*
39
-	* @var ldapserverinfo $ldapserverinfo
40
-	*/
37
+	 * Holds the detected information about the connected ldap server
38
+	 *
39
+	 * @var ldapserverinfo $ldapserverinfo
40
+	 */
41 41
 	var $ldapServerInfo;
42 42
 
43 43
 	/**
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -45,14 +45,14 @@  discard block
 block discarded – undo
45 45
 	 *
46 46
 	 * @var boolean $exception_on_error
47 47
 	 */
48
-	var $exception_on_error=false;
48
+	var $exception_on_error = false;
49 49
 
50 50
 	/**
51 51
 	 * Constructor
52 52
 	 *
53 53
 	 * @param boolean $exception_on_error=false true: throw Exceptions in ldapConnect instead of echoing error and returning false
54 54
 	 */
55
-	function __construct($exception_on_error=false)
55
+	function __construct($exception_on_error = false)
56 56
 	{
57 57
 		$this->exception_on_error = $exception_on_error;
58 58
 		$this->restoreSessionData();
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 	 */
81 81
 	static function quote($string)
82 82
 	{
83
-		return str_replace(array('\\','*','(',')','\0',' '),array('\\\\','\*','\(','\)','\\0','\20'),$string);
83
+		return str_replace(array('\\', '*', '(', ')', '\0', ' '), array('\\\\', '\*', '\(', '\)', '\\0', '\20'), $string);
84 84
 	}
85 85
 
86 86
 	/**
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 		if (!is_array($ldap)) return false;
95 95
 
96 96
 		$arr = array();
97
-		foreach($ldap as $var => $val)
97
+		foreach ($ldap as $var => $val)
98 98
 		{
99 99
 			if (is_int($var) || $var == 'count') continue;
100 100
 
@@ -125,13 +125,13 @@  discard block
 block discarded – undo
125 125
 	 * @return resource|boolean resource from ldap_connect() or false on error
126 126
 	 * @throws egw_exception_assertion_failed 'LDAP support unavailable!' (no ldap extension)
127 127
 	 */
128
-	function ldapConnect($host='', $dn='', $passwd='')
128
+	function ldapConnect($host = '', $dn = '', $passwd = '')
129 129
 	{
130
-		if(!function_exists('ldap_connect'))
130
+		if (!function_exists('ldap_connect'))
131 131
 		{
132 132
 			if ($this->exception_on_error) throw new egw_exception_assertion_failed('LDAP support unavailable!');
133 133
 
134
-			printf('<b>Error: LDAP support unavailable</b><br>',$host);
134
+			printf('<b>Error: LDAP support unavailable</b><br>', $host);
135 135
 			return False;
136 136
 		}
137 137
 		if (empty($host))
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 		{
150 150
 			$host = $_SESSION['ldapConnect'][$host];
151 151
 		}
152
-		foreach($hosts=preg_split('/[ ,;]+/', $host) as $h)
152
+		foreach ($hosts = preg_split('/[ ,;]+/', $host) as $h)
153 153
 		{
154 154
 			if ($this->_connect($h, $dn, $passwd))
155 155
 			{
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 				{
158 158
 					if (isset($_SESSION))	// store working host as first choice in session
159 159
 					{
160
-						$_SESSION['ldapConnect'][$host] = implode(' ',array_unique(array_merge(array($h),$hosts)));
160
+						$_SESSION['ldapConnect'][$host] = implode(' ', array_unique(array_merge(array($h), $hosts)));
161 161
 					}
162 162
 				}
163 163
 				return $this->ds;
@@ -182,20 +182,20 @@  discard block
 block discarded – undo
182 182
 	 */
183 183
 	private function _connect($host, $dn, $passwd)
184 184
 	{
185
-		if (($use_tls = substr($host,0,6) == 'tls://'))
185
+		if (($use_tls = substr($host, 0, 6) == 'tls://'))
186 186
 		{
187
-			$port = parse_url($host,PHP_URL_PORT);
188
-			$host = parse_url($host,PHP_URL_HOST);
187
+			$port = parse_url($host, PHP_URL_PORT);
188
+			$host = parse_url($host, PHP_URL_HOST);
189 189
 		}
190 190
 		// connect to ldap server (never fails, as connection happens in bind!)
191
-		if(!($this->ds = !empty($port) ? ldap_connect($host, $port) : ldap_connect($host)))
191
+		if (!($this->ds = !empty($port) ? ldap_connect($host, $port) : ldap_connect($host)))
192 192
 		{
193 193
 			return False;
194 194
 		}
195 195
 		// set network timeout to not block for minutes
196 196
 		ldap_set_option($this->ds, LDAP_OPT_NETWORK_TIMEOUT, 5);
197 197
 
198
-		if(ldap_set_option($this->ds, LDAP_OPT_PROTOCOL_VERSION, 3))
198
+		if (ldap_set_option($this->ds, LDAP_OPT_PROTOCOL_VERSION, 3))
199 199
 		{
200 200
 			$supportedLDAPVersion = 3;
201 201
 		}
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 		if ($use_tls) ldap_start_tls($this->ds);
207 207
 
208 208
 		if (!isset($this->ldapServerInfo) ||
209
-			!is_a($this->ldapServerInfo,'ldapserverinfo') ||
209
+			!is_a($this->ldapServerInfo, 'ldapserverinfo') ||
210 210
 			$this->ldapServerInfo->host != $host)
211 211
 		{
212 212
 			//error_log("no ldap server info found");
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 			$this->saveSessionData();
217 217
 		}
218 218
 
219
-		if(!@ldap_bind($this->ds, $dn, $passwd))
219
+		if (!@ldap_bind($this->ds, $dn, $passwd))
220 220
 		{
221 221
 			return False;
222 222
 		}
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
 	 */
230 230
 	function ldapDisconnect()
231 231
 	{
232
-		if(is_resource($this->ds))
232
+		if (is_resource($this->ds))
233 233
 		{
234 234
 			ldap_unbind($this->ds);
235 235
 			unset($this->ds);
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
 	{
245 245
 		if (isset($GLOBALS['egw']->session))	// no availible in setup
246 246
 		{
247
-			$this->ldapServerInfo = (array) unserialize($GLOBALS['egw']->session->appsession('ldapServerInfo'));
247
+			$this->ldapServerInfo = (array)unserialize($GLOBALS['egw']->session->appsession('ldapServerInfo'));
248 248
 		}
249 249
 	}
250 250
 
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
 	{
256 256
 		if (isset($GLOBALS['egw']->session))	// no availible in setup
257 257
 		{
258
-			$GLOBALS['egw']->session->appsession('ldapServerInfo','',serialize($this->ldapServerInfo));
258
+			$GLOBALS['egw']->session->appsession('ldapServerInfo', '', serialize($this->ldapServerInfo));
259 259
 		}
260 260
 	}
261 261
 }
Please login to merge, or discard this patch.
Braces   +36 added lines, -9 removed lines patch added patch discarded remove patch
@@ -91,12 +91,18 @@  discard block
 block discarded – undo
91 91
 	 */
92 92
 	static function result2array($ldap)
93 93
 	{
94
-		if (!is_array($ldap)) return false;
94
+		if (!is_array($ldap))
95
+		{
96
+			return false;
97
+		}
95 98
 
96 99
 		$arr = array();
97 100
 		foreach($ldap as $var => $val)
98 101
 		{
99
-			if (is_int($var) || $var == 'count') continue;
102
+			if (is_int($var) || $var == 'count')
103
+			{
104
+				continue;
105
+			}
100 106
 
101 107
 			if (is_array($val) && $val['count'] == 1)
102 108
 			{
@@ -104,7 +110,10 @@  discard block
 block discarded – undo
104 110
 			}
105 111
 			else
106 112
 			{
107
-				if (is_array($val)) unset($val['count']);
113
+				if (is_array($val))
114
+				{
115
+					unset($val['count']);
116
+				}
108 117
 
109 118
 				$arr[$var] = $val;
110 119
 			}
@@ -129,7 +138,10 @@  discard block
 block discarded – undo
129 138
 	{
130 139
 		if(!function_exists('ldap_connect'))
131 140
 		{
132
-			if ($this->exception_on_error) throw new egw_exception_assertion_failed('LDAP support unavailable!');
141
+			if ($this->exception_on_error)
142
+			{
143
+				throw new egw_exception_assertion_failed('LDAP support unavailable!');
144
+			}
133 145
 
134 146
 			printf('<b>Error: LDAP support unavailable</b><br>',$host);
135 147
 			return False;
@@ -155,10 +167,13 @@  discard block
 block discarded – undo
155 167
 			{
156 168
 				if ($h !== $host)
157 169
 				{
158
-					if (isset($_SESSION))	// store working host as first choice in session
170
+					if (isset($_SESSION))
171
+					{
172
+						// store working host as first choice in session
159 173
 					{
160 174
 						$_SESSION['ldapConnect'][$host] = implode(' ',array_unique(array_merge(array($h),$hosts)));
161 175
 					}
176
+					}
162 177
 				}
163 178
 				return $this->ds;
164 179
 			}
@@ -167,7 +182,10 @@  discard block
 block discarded – undo
167 182
 				' '.function_backtrace());
168 183
 		}
169 184
 		// give visible error, only if we cant connect to any ldap server
170
-		if ($this->exception_on_error) throw new egw_exception_no_permission("Can't connect/bind to LDAP server '$host' and dn='$dn'!");
185
+		if ($this->exception_on_error)
186
+		{
187
+			throw new egw_exception_no_permission("Can't connect/bind to LDAP server '$host' and dn='$dn'!");
188
+		}
171 189
 
172 190
 		return false;
173 191
 	}
@@ -203,7 +221,10 @@  discard block
 block discarded – undo
203 221
 		{
204 222
 			$supportedLDAPVersion = 2;
205 223
 		}
206
-		if ($use_tls) ldap_start_tls($this->ds);
224
+		if ($use_tls)
225
+		{
226
+			ldap_start_tls($this->ds);
227
+		}
207 228
 
208 229
 		if (!isset($this->ldapServerInfo) ||
209 230
 			!is_a($this->ldapServerInfo,'ldapserverinfo') ||
@@ -242,10 +263,13 @@  discard block
 block discarded – undo
242 263
 	 */
243 264
 	function restoreSessionData()
244 265
 	{
245
-		if (isset($GLOBALS['egw']->session))	// no availible in setup
266
+		if (isset($GLOBALS['egw']->session))
267
+		{
268
+			// no availible in setup
246 269
 		{
247 270
 			$this->ldapServerInfo = (array) unserialize($GLOBALS['egw']->session->appsession('ldapServerInfo'));
248 271
 		}
272
+		}
249 273
 	}
250 274
 
251 275
 	/**
@@ -253,9 +277,12 @@  discard block
 block discarded – undo
253 277
 	 */
254 278
 	function saveSessionData()
255 279
 	{
256
-		if (isset($GLOBALS['egw']->session))	// no availible in setup
280
+		if (isset($GLOBALS['egw']->session))
281
+		{
282
+			// no availible in setup
257 283
 		{
258 284
 			$GLOBALS['egw']->session->appsession('ldapServerInfo','',serialize($this->ldapServerInfo));
259 285
 		}
286
+		}
260 287
 	}
261 288
 }
Please login to merge, or discard this patch.