Completed
Push — 14.2 ( c53e78...a8db63 )
by Ralf
29:08
created
calendar/setup/default_records.inc.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -10,17 +10,17 @@
 block discarded – undo
10 10
  */
11 11
 
12 12
 // enable auto-loading of holidays from localhost by default
13
-foreach(array(
13
+foreach (array(
14 14
 	'auto_load_holidays' => 'True',
15 15
 	'holidays_url_path'  => 'localhost',
16 16
 ) as $name => $value)
17 17
 {
18
-	$oProc->insert($GLOBALS['egw_setup']->config_table,array(
18
+	$oProc->insert($GLOBALS['egw_setup']->config_table, array(
19 19
 		'config_value' => $value,
20
-	),array(
20
+	), array(
21 21
 		'config_app' => 'phpgwapi',
22 22
 		'config_name' => $name,
23
-	),__FILE__,__LINE__);
23
+	), __FILE__, __LINE__);
24 24
 }
25 25
 
26 26
 // import timezone data
Please login to merge, or discard this patch.
calendar/inc/class.calendar_bo.inc.php 5 patches
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -1490,13 +1490,13 @@  discard block
 block discarded – undo
1490 1490
 	}
1491 1491
 
1492 1492
 	/**
1493
-	* Converts a participant into a (readable) user- or resource-name
1494
-	*
1495
-	* @param string|int $id id of user or resource
1496
-	* @param string|boolean $use_type =false type-letter or false
1497
-	* @param boolean $append_email =false append email (Name <email>)
1498
-	* @return string with name
1499
-	*/
1493
+	 * Converts a participant into a (readable) user- or resource-name
1494
+	 *
1495
+	 * @param string|int $id id of user or resource
1496
+	 * @param string|boolean $use_type =false type-letter or false
1497
+	 * @param boolean $append_email =false append email (Name <email>)
1498
+	 * @return string with name
1499
+	 */
1500 1500
 	function participant_name($id,$use_type=false, $append_email=false)
1501 1501
 	{
1502 1502
 		static $id2lid = array();
@@ -1525,13 +1525,13 @@  discard block
 block discarded – undo
1525 1525
 	}
1526 1526
 
1527 1527
 	/**
1528
-	* Converts participants array of an event into array of (readable) participant-names with status
1529
-	*
1530
-	* @param array $event event-data
1531
-	* @param boolean $long_status =false should the long/verbose status or an icon be use
1532
-	* @param boolean $show_group_invitation =false show group-invitations (status == 'G') or not (default)
1533
-	* @return array with id / names with status pairs
1534
-	*/
1528
+	 * Converts participants array of an event into array of (readable) participant-names with status
1529
+	 *
1530
+	 * @param array $event event-data
1531
+	 * @param boolean $long_status =false should the long/verbose status or an icon be use
1532
+	 * @param boolean $show_group_invitation =false show group-invitations (status == 'G') or not (default)
1533
+	 * @return array with id / names with status pairs
1534
+	 */
1535 1535
 	function participants($event,$long_status=false,$show_group_invitation=false)
1536 1536
 	{
1537 1537
 		//error_log(__METHOD__.__LINE__.array2string($event['participants']));
@@ -1601,12 +1601,12 @@  discard block
 block discarded – undo
1601 1601
 	}
1602 1602
 
1603 1603
 	/**
1604
-	* Converts category string of an event into array of (readable) category-names
1605
-	*
1606
-	* @param string $category cat-id (multiple id's commaseparated)
1607
-	* @param int $color color of the category, if multiple cats, the color of the last one with color is returned
1608
-	* @return array with id / names
1609
-	*/
1604
+	 * Converts category string of an event into array of (readable) category-names
1605
+	 *
1606
+	 * @param string $category cat-id (multiple id's commaseparated)
1607
+	 * @param int $color color of the category, if multiple cats, the color of the last one with color is returned
1608
+	 * @return array with id / names
1609
+	 */
1610 1610
 	function categories($category,&$color)
1611 1611
 	{
1612 1612
 		static $id2cat = array();
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 	/**
123 123
 	 * @var array recur_types translates MCAL recur-types to verbose labels
124 124
 	 */
125
-	var $recur_types = Array(
125
+	var $recur_types = array(
126 126
 		MCAL_RECUR_NONE         => 'No recurrence',
127 127
 		MCAL_RECUR_DAILY        => 'Daily',
128 128
 		MCAL_RECUR_WEEKLY       => 'Weekly',
@@ -1897,7 +1897,7 @@  discard block
 block discarded – undo
1897 1897
 	 * @param string $pattern pattern to search
1898 1898
 	 * @return array with cal_id - title pairs of the matching entries
1899 1899
 	 */
1900
-	function link_query($pattern, Array &$options = array())
1900
+	function link_query($pattern, array &$options = array())
1901 1901
 	{
1902 1902
 		$result = array();
1903 1903
 		$query = array(
Please login to merge, or discard this patch.
Doc Comments   +7 added lines, -13 removed lines patch added patch discarded remove patch
@@ -638,8 +638,8 @@  discard block
 block discarded – undo
638 638
 	 * or an ExecMethod callback with parameters $id,$event
639 639
 	 *
640 640
 	 * @param string $app
641
-	 * @param int|string $id
642
-	 * @return string
641
+	 * @param string $id
642
+	 * @return boolean
643 643
 	 */
644 644
 	static function integration_get_private($app,$id,$event)
645 645
 	{
@@ -768,7 +768,7 @@  discard block
 block discarded – undo
768 768
 	 * This methods operates in usertime, while $this->config['horizont'] is in servertime!
769 769
 	 *
770 770
 	 * @param array $event
771
-	 * @param mixed $start =0 minimum start-time for new recurrences or !$start = since the start of the event
771
+	 * @param integer $start =0 minimum start-time for new recurrences or !$start = since the start of the event
772 772
 	 */
773 773
 	function set_recurrences($event,$start=0)
774 774
 	{
@@ -989,10 +989,9 @@  discard block
 block discarded – undo
989 989
 	 * Recurrences get calculated by rrule iterator implemented in calendar_rrule class.
990 990
 	 *
991 991
 	 * @param array $event repeating event whos repetions should be inserted
992
-	 * @param mixed $start start-date
992
+	 * @param mixed $_start start-date
993 993
 	 * @param mixed $end end-date
994 994
 	 * @param array $events where the repetions get inserted
995
-	 * @param array $recur_exceptions with date (in Ymd) as key (and True as values), seems not to be used anymore
996 995
 	 */
997 996
 	function insert_all_recurrences($event,$_start,$end,&$events)
998 997
 	{
@@ -1146,7 +1145,7 @@  discard block
 block discarded – undo
1146 1145
 	 *	even if you have no general read-grant from that user.
1147 1146
 	 *
1148 1147
 	 * @param int $needed necessary ACL right: EGW_ACL_{READ|EDIT|DELETE}
1149
-	 * @param mixed $event event as array or the event-id or 0 for a general check
1148
+	 * @param integer $event event as array or the event-id or 0 for a general check
1150 1149
 	 * @param int $other uid to check (if event==0) or 0 to check against $this->user
1151 1150
 	 * @param string $date_format ='ts' date-format used for reading: 'ts'=timestamp, 'array'=array, 'string'=iso8601 string for xmlrpc
1152 1151
 	 * @param mixed $date_to_read =null date used for reading, internal param for the caching
@@ -1319,8 +1318,6 @@  discard block
 block discarded – undo
1319 1318
 	 * @param string $msg message with parameters/variables like lang(), eg. '%1'
1320 1319
 	 * @param boolean $backtrace =True include a function-backtrace, default True=On
1321 1320
 	 *	should only be set to False=Off, if your code ensures a call with backtrace=On was made before !!!
1322
-	 * @param mixed $param a variable number of parameters, to be inserted in $msg
1323
-	 *	arrays get serialized with print_r() !
1324 1321
 	 */
1325 1322
 	static function debug_message($msg,$backtrace=True)
1326 1323
 	{
@@ -1384,7 +1381,7 @@  discard block
 block discarded – undo
1384 1381
 	 * Formats one or two dates (range) as long date (full monthname), optionaly with a time
1385 1382
 	 *
1386 1383
 	 * @param mixed $_first first date
1387
-	 * @param mixed $last =0 last date if != 0 (default)
1384
+	 * @param integer $last =0 last date if != 0 (default)
1388 1385
 	 * @param boolean $display_time =false should a time be displayed too
1389 1386
 	 * @param boolean $display_day =false should a day-name prefix the date, eg. monday June 20, 2006
1390 1387
 	 * @return string with formated date
@@ -1859,7 +1856,6 @@  discard block
 block discarded – undo
1859 1856
 	 *
1860 1857
 	 * Is called as hook to participate in the linking
1861 1858
 	 *
1862
-	 * @param int|array $entry int cal_id or array with event
1863 1859
 	 * @param string|boolean string with title, null if not found or false if not read perms
1864 1860
 	 */
1865 1861
 	function link_title($event)
@@ -2053,7 +2049,7 @@  discard block
 block discarded – undo
2053 2049
 	 *
2054 2050
 	 * @param array|int|string $entry array with event or cal_id, or cal_id:recur_date for virtual exceptions
2055 2051
 	 * @param string &$schedule_tag=null on return schedule-tag (egw_cal.cal_id:egw_cal.cal_etag, no participant modifications!)
2056
-	 * @return string|boolean string with etag or false
2052
+	 * @return string string with etag or false
2057 2053
 	 */
2058 2054
 	function get_etag($entry, &$schedule_tag=null)
2059 2055
 	{
@@ -2093,7 +2089,6 @@  discard block
 block discarded – undo
2093 2089
 	 * Hook for infolog  to set some extra data and links
2094 2090
 	 *
2095 2091
 	 * @param array $data event-array preset by infolog plus
2096
-	 * @param int $data[id] cal_id
2097 2092
 	 * @return array with key => value pairs to set in new event and link_app/link_id arrays
2098 2093
 	 */
2099 2094
 	function infolog_set($data)
@@ -2145,7 +2140,6 @@  discard block
 block discarded – undo
2145 2140
 	 * Hook for timesheet to set some extra data and links
2146 2141
 	 *
2147 2142
 	 * @param array $data
2148
-	 * @param int $data[id] cal_id:recurrence
2149 2143
 	 * @return array with key => value pairs to set in new timesheet and link_app/link_id arrays
2150 2144
 	 */
2151 2145
 	function timesheet_set($data)
Please login to merge, or discard this patch.
Spacing   +298 added lines, -298 removed lines patch added patch discarded remove patch
@@ -13,23 +13,23 @@  discard block
 block discarded – undo
13 13
 
14 14
 if (!defined('ACL_TYPE_IDENTIFER'))	// used to mark ACL-values for the debug_message methode
15 15
 {
16
-	define('ACL_TYPE_IDENTIFER','***ACL***');
16
+	define('ACL_TYPE_IDENTIFER', '***ACL***');
17 17
 }
18 18
 
19
-define('HOUR_s',60*60);
20
-define('DAY_s',24*HOUR_s);
21
-define('WEEK_s',7*DAY_s);
19
+define('HOUR_s', 60 * 60);
20
+define('DAY_s', 24 * HOUR_s);
21
+define('WEEK_s', 7 * DAY_s);
22 22
 
23 23
 /**
24 24
  * Gives read access to the calendar, but all events the user is not participating are private!
25 25
  * Used by addressbook.
26 26
  */
27
-define('EGW_ACL_READ_FOR_PARTICIPANTS',EGW_ACL_CUSTOM_1);
28
-define('EGW_ACL_FREEBUSY',EGW_ACL_CUSTOM_2);
27
+define('EGW_ACL_READ_FOR_PARTICIPANTS', EGW_ACL_CUSTOM_1);
28
+define('EGW_ACL_FREEBUSY', EGW_ACL_CUSTOM_2);
29 29
 /**
30 30
  * Allows to invite an other user (if configured to be used!)
31 31
  */
32
-define('EGW_ACL_INVITE',EGW_ACL_CUSTOM_3);
32
+define('EGW_ACL_INVITE', EGW_ACL_CUSTOM_3);
33 33
 
34 34
 /**
35 35
  * Required (!) include, as we use the MCAL_* constants, BEFORE instanciating (and therefore autoloading) the class
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 	 *	4 = function-calls to exported conversation-functions like date2ts, date2array, ...
65 65
 	 *	5 = function-calls to private functions
66 66
 	 */
67
-	var $debug=false;
67
+	var $debug = false;
68 68
 
69 69
 	/**
70 70
 	 * @var int $now timestamp in server-time
@@ -94,12 +94,12 @@  discard block
 block discarded – undo
94 94
 	/**
95 95
 	 * @var int $user nummerical id of the current user-id
96 96
 	 */
97
-	var $user=0;
97
+	var $user = 0;
98 98
 
99 99
 	/**
100 100
 	 * @var array $grants grants of the current user, array with user-id / ored-ACL-rights pairs
101 101
 	 */
102
-	var $grants=array();
102
+	var $grants = array();
103 103
 
104 104
 	/**
105 105
 	 * @var array $verbose_status translated 1-char status values to a verbose name, run through lang() by the constructor
@@ -225,25 +225,25 @@  discard block
 block discarded – undo
225 225
 	 */
226 226
 	function __construct()
227 227
 	{
228
-		if ($this->debug > 0) $this->debug_message('calendar_bo::bocal() started',True);
228
+		if ($this->debug > 0) $this->debug_message('calendar_bo::bocal() started', True);
229 229
 
230 230
 		$this->so = new calendar_so();
231 231
 		$this->datetime = $GLOBALS['egw']->datetime;
232 232
 
233
-		$this->common_prefs =& $GLOBALS['egw_info']['user']['preferences']['common'];
234
-		$this->cal_prefs =& $GLOBALS['egw_info']['user']['preferences']['calendar'];
233
+		$this->common_prefs = & $GLOBALS['egw_info']['user']['preferences']['common'];
234
+		$this->cal_prefs = & $GLOBALS['egw_info']['user']['preferences']['calendar'];
235 235
 
236 236
 		$this->now = time();
237
-		$this->now_su = egw_time::server2user($this->now,'ts');
237
+		$this->now_su = egw_time::server2user($this->now, 'ts');
238 238
 
239 239
 		$this->user = $GLOBALS['egw_info']['user']['account_id'];
240 240
 
241 241
 		$this->grants = $GLOBALS['egw']->acl->get_grants('calendar');
242 242
 
243
-		if (!is_array($this->resources = $GLOBALS['egw']->session->appsession('resources','calendar')))
243
+		if (!is_array($this->resources = $GLOBALS['egw']->session->appsession('resources', 'calendar')))
244 244
 		{
245 245
 			$this->resources = array();
246
-			foreach($GLOBALS['egw']->hooks->process('calendar_resources') as $app => $data)
246
+			foreach ($GLOBALS['egw']->hooks->process('calendar_resources') as $app => $data)
247 247
 			{
248 248
 				if ($data && $data['type'])
249 249
 				{
@@ -259,19 +259,19 @@  discard block
 block discarded – undo
259 259
 				'type' => '',
260 260
 				'app' => 'home-accounts',
261 261
 			);
262
-			$GLOBALS['egw']->session->appsession('resources','calendar',$this->resources);
262
+			$GLOBALS['egw']->session->appsession('resources', 'calendar', $this->resources);
263 263
 		}
264 264
 		//echo "registered resources="; _debug_array($this->resources);
265 265
 
266
-		$this->config = config::read('calendar');	// only used for horizont, regular calendar config is under phpgwapi
267
-		$this->calview_no_consolidate = ($GLOBALS['egw_info']['server']['calview_no_consolidate']?$GLOBALS['egw_info']['server']['calview_no_consolidate']:5);
266
+		$this->config = config::read('calendar'); // only used for horizont, regular calendar config is under phpgwapi
267
+		$this->calview_no_consolidate = ($GLOBALS['egw_info']['server']['calview_no_consolidate'] ? $GLOBALS['egw_info']['server']['calview_no_consolidate'] : 5);
268 268
 		$this->require_acl_invite = $GLOBALS['egw_info']['server']['require_acl_invite'];
269 269
 
270
-		$this->categories = new categories($this->user,'calendar');
270
+		$this->categories = new categories($this->user, 'calendar');
271 271
 
272 272
 		$this->customfields = config::get_customfields('calendar');
273 273
 
274
-		foreach($this->alarms as $secs => &$label)
274
+		foreach ($this->alarms as $secs => &$label)
275 275
 		{
276 276
 			$label = self::secs2label($secs);
277 277
 		}
@@ -287,15 +287,15 @@  discard block
 block discarded – undo
287 287
 	{
288 288
 		if ($secs <= 3600)
289 289
 		{
290
-			$label = lang('%1 minutes', $secs/60);
290
+			$label = lang('%1 minutes', $secs / 60);
291 291
 		}
292
-		elseif($secs <= 86400)
292
+		elseif ($secs <= 86400)
293 293
 		{
294
-			$label = lang('%1 hours', $secs/3600);
294
+			$label = lang('%1 hours', $secs / 3600);
295 295
 		}
296 296
 		else
297 297
 		{
298
-			$label = lang('%1 days', $secs/86400);
298
+			$label = lang('%1 days', $secs / 86400);
299 299
 		}
300 300
 		return $label;
301 301
 	}
@@ -311,12 +311,12 @@  discard block
 block discarded – undo
311 311
 		if (!$ids) return null;
312 312
 
313 313
 		$data = array();
314
-		foreach((array)$ids as $id)
314
+		foreach ((array)$ids as $id)
315 315
 		{
316 316
 			$email = $id;
317 317
 			$name = '';
318 318
 			$matches = null;
319
-			if (preg_match('/^(.*) *<([a-z0-9_.@-]{8,})>$/iU',$email,$matches))
319
+			if (preg_match('/^(.*) *<([a-z0-9_.@-]{8,})>$/iU', $email, $matches))
320 320
 			{
321 321
 				$name = $matches[1];
322 322
 				$email = $matches[2];
@@ -341,12 +341,12 @@  discard block
 block discarded – undo
341 341
 	function enum_groups(&$event)
342 342
 	{
343 343
 		$added = 0;
344
-		foreach(array_keys($event['participants']) as $uid)
344
+		foreach (array_keys($event['participants']) as $uid)
345 345
 		{
346 346
 			if (is_numeric($uid) && $GLOBALS['egw']->accounts->get_type($uid) == 'g' &&
347 347
 				($members = $GLOBALS['egw']->accounts->member($uid)))
348 348
 			{
349
-				foreach($members as $member)
349
+				foreach ($members as $member)
350 350
 				{
351 351
 					$member = $member['account_id'];
352 352
 					if (!isset($event['participants'][$member]))
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
 	 * @param boolean $use_freebusy =true should freebusy rights are taken into account, default true, can be set to false eg. for a search
370 370
 	 * @return array of user-ids
371 371
 	 */
372
-	private function resolve_users($_users, $no_enum_groups=true, $ignore_acl=false, $use_freebusy=true)
372
+	private function resolve_users($_users, $no_enum_groups = true, $ignore_acl = false, $use_freebusy = true)
373 373
 	{
374 374
 		if (!is_array($_users))
375 375
 		{
@@ -377,19 +377,19 @@  discard block
 block discarded – undo
377 377
 		}
378 378
 		// only query calendars of users, we have READ-grants from
379 379
 		$users = array();
380
-		foreach($_users as $user)
380
+		foreach ($_users as $user)
381 381
 		{
382 382
 			$user = trim($user);
383
-			if ($ignore_acl || $this->check_perms(EGW_ACL_READ|EGW_ACL_READ_FOR_PARTICIPANTS|($use_freebusy?EGW_ACL_FREEBUSY:0),0,$user))
383
+			if ($ignore_acl || $this->check_perms(EGW_ACL_READ|EGW_ACL_READ_FOR_PARTICIPANTS|($use_freebusy ? EGW_ACL_FREEBUSY : 0), 0, $user))
384 384
 			{
385
-				if ($user && !in_array($user,$users))	// already added?
385
+				if ($user && !in_array($user, $users))	// already added?
386 386
 				{
387 387
 					$users[] = $user;
388 388
 				}
389 389
 			}
390 390
 			elseif ($GLOBALS['egw']->accounts->get_type($user) != 'g')
391 391
 			{
392
-				continue;	// for non-groups (eg. users), we stop here if we have no read-rights
392
+				continue; // for non-groups (eg. users), we stop here if we have no read-rights
393 393
 			}
394 394
 			// the further code is only for real users
395 395
 			if (!is_numeric($user)) continue;
@@ -402,11 +402,11 @@  discard block
 block discarded – undo
402 402
 				$members = $GLOBALS['egw']->accounts->member($user);
403 403
 				if (is_array($members))
404 404
 				{
405
-					foreach($members as $member)
405
+					foreach ($members as $member)
406 406
 					{
407 407
 						// use only members which gave the user a read-grant
408
-						if (!in_array($member['account_id'],$users) &&
409
-							($ignore_acl || $this->check_perms(EGW_ACL_READ|($use_freebusy?EGW_ACL_FREEBUSY:0),0,$member['account_id'])))
408
+						if (!in_array($member['account_id'], $users) &&
409
+							($ignore_acl || $this->check_perms(EGW_ACL_READ|($use_freebusy ? EGW_ACL_FREEBUSY : 0), 0, $member['account_id'])))
410 410
 						{
411 411
 							$users[] = $member['account_id'];
412 412
 						}
@@ -418,9 +418,9 @@  discard block
 block discarded – undo
418 418
 				$memberships = $GLOBALS['egw']->accounts->membership($user);
419 419
 				if (is_array($memberships))
420 420
 				{
421
-					foreach($memberships as $group)
421
+					foreach ($memberships as $group)
422 422
 					{
423
-						if (!in_array($group['account_id'],$users))
423
+						if (!in_array($group['account_id'], $users))
424 424
 						{
425 425
 							$users[] = $group['account_id'];
426 426
 						}
@@ -461,18 +461,18 @@  discard block
 block discarded – undo
461 461
 	 * @return iterator|array|boolean array of events or array with YYYYMMDD strings / array of events pairs (depending on $daywise param)
462 462
 	 *	or false if there are no read-grants from _any_ of the requested users or iterator/recordset if cols are given
463 463
 	 */
464
-	function &search($params,$sql_filter=null)
464
+	function &search($params, $sql_filter = null)
465 465
 	{
466 466
 		$params_in = $params;
467 467
 
468
-		$params['sql_filter'] = $sql_filter;	// dont allow to set it via UI or xmlrpc
468
+		$params['sql_filter'] = $sql_filter; // dont allow to set it via UI or xmlrpc
469 469
 
470 470
 		// check if any resource wants to hook into
471
-		foreach($this->resources as $data)
471
+		foreach ($this->resources as $data)
472 472
 		{
473 473
 			if (isset($data['search_filter']))
474 474
 			{
475
-				$params = ExecMethod($data['search_filter'],$params);
475
+				$params = ExecMethod($data['search_filter'], $params);
476 476
 			}
477 477
 		}
478 478
 
@@ -490,9 +490,9 @@  discard block
 block discarded – undo
490 490
 		if (!empty($params['query']))
491 491
 		{
492 492
 			$params['private_grants'] = array();
493
-			foreach($this->grants as $user => $rights)
493
+			foreach ($this->grants as $user => $rights)
494 494
 			{
495
-				if ($rights & EGW_ACL_PRIVATE) $params['private_grants'][] = $user;
495
+				if ($rights&EGW_ACL_PRIVATE) $params['private_grants'][] = $user;
496 496
 			}
497 497
 		}
498 498
 
@@ -518,49 +518,49 @@  discard block
 block discarded – undo
518 518
 		$params['enum_recuring'] = $enum_recuring = $daywise || !isset($params['enum_recuring']) || !!$params['enum_recuring'];
519 519
 		$cat_id = isset($params['cat_id']) ? $params['cat_id'] : 0;
520 520
 		$filter = isset($params['filter']) ? $params['filter'] : 'all';
521
-		$offset = isset($params['offset']) && $params['offset'] !== false ? (int) $params['offset'] : false;
521
+		$offset = isset($params['offset']) && $params['offset'] !== false ? (int)$params['offset'] : false;
522 522
 		// socal::search() returns rejected group-invitations, as only the user not also the group is rejected
523 523
 		// as we cant remove them efficiantly in SQL, we kick them out here, but only if just one user is displayed
524 524
 		$users_in = (array)$params_in['users'];
525
-		$remove_rejected_by_user = !in_array($filter,array('all','rejected','everything')) &&
525
+		$remove_rejected_by_user = !in_array($filter, array('all', 'rejected', 'everything')) &&
526 526
 			count($users_in) == 1 && $users_in[0] > 0 ? $users_in[0] : null;
527 527
 		//error_log(__METHOD__.'('.array2string($params_in).", $sql_filter) params[users]=".array2string($params['users']).' --> remove_rejected_by_user='.array2string($remove_rejected_by_user));
528 528
 
529 529
 		if ($this->debug && ($this->debug > 1 || $this->debug == 'search'))
530 530
 		{
531 531
 			$this->debug_message('calendar_bo::search(%1) start=%2, end=%3, daywise=%4, cat_id=%5, filter=%6, query=%7, offset=%8, num_rows=%9, order=%10, sql_filter=%11)',
532
-				True,$params,$start,$end,$daywise,$cat_id,$filter,$params['query'],$offset,(int)$params['num_rows'],$params['order'],$params['sql_filter']);
532
+				True, $params, $start, $end, $daywise, $cat_id, $filter, $params['query'], $offset, (int)$params['num_rows'], $params['order'], $params['sql_filter']);
533 533
 		}
534 534
 		// date2ts(,true) converts to server time, db2data converts again to user-time
535
-		$events =& $this->so->search(isset($start) ? $this->date2ts($start,true) : null,isset($end) ? $this->date2ts($end,true) : null,
536
-			$users,$cat_id,$filter,$offset,(int)$params['num_rows'],$params,$remove_rejected_by_user);
535
+		$events = & $this->so->search(isset($start) ? $this->date2ts($start, true) : null, isset($end) ? $this->date2ts($end, true) : null,
536
+			$users, $cat_id, $filter, $offset, (int)$params['num_rows'], $params, $remove_rejected_by_user);
537 537
 
538 538
 		if (isset($params['cols']))
539 539
 		{
540 540
 			return $events;
541 541
 		}
542 542
 		$this->total = $this->so->total;
543
-		$this->db2data($events,isset($params['date_format']) ? $params['date_format'] : 'ts');
543
+		$this->db2data($events, isset($params['date_format']) ? $params['date_format'] : 'ts');
544 544
 
545 545
 		//echo "<p align=right>remove_rejected_by_user=$remove_rejected_by_user, filter=$filter, params[users]=".print_r($param['users'])."</p>\n";
546
-		foreach($events as $id => $event)
546
+		foreach ($events as $id => $event)
547 547
 		{
548 548
 			if ($params['enum_groups'] && $this->enum_groups($event))
549 549
 			{
550 550
 				$events[$id] = $event;
551 551
 			}
552 552
 			$matches = null;
553
-			if (!(int)$event['id'] && preg_match('/^([a-z_]+)([0-9]+)$/',$event['id'],$matches))
553
+			if (!(int)$event['id'] && preg_match('/^([a-z_]+)([0-9]+)$/', $event['id'], $matches))
554 554
 			{
555
-				$is_private = self::integration_get_private($matches[1],$matches[2],$event);
555
+				$is_private = self::integration_get_private($matches[1], $matches[2], $event);
556 556
 			}
557 557
 			else
558 558
 			{
559
-				$is_private = !$this->check_perms(EGW_ACL_READ,$event);
559
+				$is_private = !$this->check_perms(EGW_ACL_READ, $event);
560 560
 			}
561 561
 			if ($is_private || (!$event['public'] && $filter == 'hideprivate'))
562 562
 			{
563
-				$this->clear_private_infos($events[$id],$users);
563
+				$this->clear_private_infos($events[$id], $users);
564 564
 			}
565 565
 		}
566 566
 
@@ -568,18 +568,18 @@  discard block
 block discarded – undo
568 568
 		{
569 569
 			if ($this->debug && ($this->debug > 2 || $this->debug == 'search'))
570 570
 			{
571
-				$this->debug_message('socalendar::search daywise sorting from %1 to %2 of %3',False,$start,$end,$events);
571
+				$this->debug_message('socalendar::search daywise sorting from %1 to %2 of %3', False, $start, $end, $events);
572 572
 			}
573 573
 			// create empty entries for each day in the reported time
574
-			for($ts = $start; $ts <= $end; $ts += DAY_s) // good enough for array creation, but see while loop below.
574
+			for ($ts = $start; $ts <= $end; $ts += DAY_s) // good enough for array creation, but see while loop below.
575 575
 			{
576 576
 				$daysEvents[$this->date2string($ts)] = array();
577 577
 			}
578
-			foreach($events as $k => $event)
578
+			foreach ($events as $k => $event)
579 579
 			{
580
-				$e_start = max($this->date2ts($event['start']),$start);
580
+				$e_start = max($this->date2ts($event['start']), $start);
581 581
 				// $event['end']['raw']-1 to allow events to end on a full hour/day without the need to enter it as minute=59
582
-				$e_end   = min($this->date2ts($event['end'])-1,$end);
582
+				$e_end   = min($this->date2ts($event['end']) - 1, $end);
583 583
 
584 584
 				// add event to each day in the reported time
585 585
 				$ts = $e_start;
@@ -588,23 +588,23 @@  discard block
 block discarded – undo
588 588
 				$ymd = null;
589 589
 				while ($ts <= $e_end)
590 590
 				{
591
-					$daysEvents[$ymd = $this->date2string($ts)][] =& $events[$k];
592
-					$ts = strtotime("+1 day",$ts);
591
+					$daysEvents[$ymd = $this->date2string($ts)][] = & $events[$k];
592
+					$ts = strtotime("+1 day", $ts);
593 593
 				}
594 594
 				if ($ymd != ($last = $this->date2string($e_end)))
595 595
 				{
596
-					$daysEvents[$last][] =& $events[$k];
596
+					$daysEvents[$last][] = & $events[$k];
597 597
 				}
598 598
 			}
599
-			$events =& $daysEvents;
599
+			$events = & $daysEvents;
600 600
 			if ($this->debug && ($this->debug > 2 || $this->debug == 'search'))
601 601
 			{
602
-				$this->debug_message('socalendar::search daywise events=%1',False,$events);
602
+				$this->debug_message('socalendar::search daywise events=%1', False, $events);
603 603
 			}
604 604
 		}
605 605
 		if ($this->debug && ($this->debug > 0 || $this->debug == 'search'))
606 606
 		{
607
-			$this->debug_message('calendar_bo::search(%1)=%2',True,$params,$events);
607
+			$this->debug_message('calendar_bo::search(%1)=%2', True, $params, $events);
608 608
 		}
609 609
 		//error_log(__METHOD__."() returning ".count($events)." entries, total=$this->total ".function_backtrace());
610 610
 		return $events;
@@ -617,9 +617,9 @@  discard block
 block discarded – undo
617 617
 	 * @param string $part
618 618
 	 * @return array
619 619
 	 */
620
-	static function integration_get_data($app,$part=null)
620
+	static function integration_get_data($app, $part = null)
621 621
 	{
622
-		static $integration_data=null;
622
+		static $integration_data = null;
623 623
 
624 624
 		if (!isset($integration_data))
625 625
 		{
@@ -641,14 +641,14 @@  discard block
 block discarded – undo
641 641
 	 * @param int|string $id
642 642
 	 * @return string
643 643
 	 */
644
-	static function integration_get_private($app,$id,$event)
644
+	static function integration_get_private($app, $id, $event)
645 645
 	{
646
-		$app_data = self::integration_get_data($app,'is_private');
646
+		$app_data = self::integration_get_data($app, 'is_private');
647 647
 
648 648
 		// no method, fall back to link title
649 649
 		if (is_null($app_data))
650 650
 		{
651
-			$is_private = !egw_link::title($app,$id);
651
+			$is_private = !egw_link::title($app, $id);
652 652
 		}
653 653
 		// boolean value to make all events of $app public (false) or private (true)
654 654
 		elseif (is_bool($app_data))
@@ -657,7 +657,7 @@  discard block
 block discarded – undo
657 657
 		}
658 658
 		else
659 659
 		{
660
-			$is_private = (bool)ExecMethod2($app_data,$id,$event);
660
+			$is_private = (bool)ExecMethod2($app_data, $id, $event);
661 661
 		}
662 662
 		//echo '<p>'.__METHOD__."($app,$id,) app_data=".array2string($app_data).' returning '.array2string($is_private)."</p>\n";
663 663
 		return $is_private;
@@ -671,7 +671,7 @@  discard block
 block discarded – undo
671 671
 	 * @param array &$event
672 672
 	 * @param array $allowed_participants ids of the allowed participants, eg. the ones the search is over or eg. the owner of the calendar
673 673
 	 */
674
-	function clear_private_infos(&$event,$allowed_participants = array())
674
+	function clear_private_infos(&$event, $allowed_participants = array())
675 675
 	{
676 676
 		if ($event == false) return;
677 677
 		if (!is_array($event['participants'])) error_log(__METHOD__.'('.array2string($event).', '.array2string($allowed_participants).') NO PARTICIPANTS '.function_backtrace());
@@ -687,19 +687,19 @@  discard block
 block discarded – undo
687 687
 			'owner'		=> $event['owner'],
688 688
 			'uid'	=> $event['uid'],
689 689
 			'etag'	=> $event['etag'],
690
-			'participants' => array_intersect_key($event['participants'],array_flip($allowed_participants)),
690
+			'participants' => array_intersect_key($event['participants'], array_flip($allowed_participants)),
691 691
 			'public'=> 0,
692
-			'category' => $event['category'],	// category is visible anyway, eg. by using planner by cat
692
+			'category' => $event['category'], // category is visible anyway, eg. by using planner by cat
693 693
 			'non_blocking' => $event['non_blocking'],
694 694
 			'caldav_name' => $event['caldav_name'],
695 695
 		// we need full recurrence information, as they are relevant free/busy information
696
-		)+($event['recur_type'] ? array(
696
+		) + ($event['recur_type'] ? array(
697 697
 			'recur_type'     => $event['recur_type'],
698 698
 			'recur_interval' => $event['recur_interval'],
699 699
 			'recur_data'     => $event['recur_data'],
700 700
 			'recur_enddate'  => $event['recur_enddate'],
701 701
 			'recur_exception'=> $event['recur_exception'],
702
-		):array(
702
+		) : array(
703 703
 			'reference'      => $event['reference'],
704 704
 			'recurrence'     => $event['recurrence'],
705 705
 		));
@@ -713,15 +713,15 @@  discard block
 block discarded – undo
713 713
 	 */
714 714
 	function check_move_horizont($_new_horizont)
715 715
 	{
716
-		if ((int) $this->debug >= 2 || $this->debug == 'check_move_horizont')
716
+		if ((int)$this->debug >= 2 || $this->debug == 'check_move_horizont')
717 717
 		{
718
-			$this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2',true,$_new_horizont,(int)$this->config['horizont']);
718
+			$this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2', true, $_new_horizont, (int)$this->config['horizont']);
719 719
 		}
720
-		$new_horizont = $this->date2ts($_new_horizont,true);	// now we are in server-time, where this function operates
720
+		$new_horizont = $this->date2ts($_new_horizont, true); // now we are in server-time, where this function operates
721 721
 
722 722
 		if ($new_horizont <= $this->config['horizont'])	// no move necessary
723 723
 		{
724
-			if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2 is bigger ==> nothing to do',true,$new_horizont,(int)$this->config['horizont']);
724
+			if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2 is bigger ==> nothing to do', true, $new_horizont, (int)$this->config['horizont']);
725 725
 			return;
726 726
 		}
727 727
 		if (!empty($GLOBALS['egw_info']['server']['calendar_horizont']))
@@ -729,15 +729,15 @@  discard block
 block discarded – undo
729 729
 			$maxdays = abs($GLOBALS['egw_info']['server']['calendar_horizont']);
730 730
 		}
731 731
 		if (empty($maxdays)) $maxdays = 1000; // old default
732
-		if ($new_horizont > time()+$maxdays*DAY_s)		// some user tries to "look" more then the maximum number of days in the future
732
+		if ($new_horizont > time() + $maxdays * DAY_s)		// some user tries to "look" more then the maximum number of days in the future
733 733
 		{
734
-			if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2 new horizont more then %3 days from now --> ignoring it',true,$new_horizont,(int)$this->config['horizont'],$maxdays);
735
-			$this->warnings['horizont'] = lang('Requested date %1 outside allowed range of %2 days: recurring events obmitted!', egw_time::to($new_horizont,true), $maxdays);
734
+			if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2 new horizont more then %3 days from now --> ignoring it', true, $new_horizont, (int)$this->config['horizont'], $maxdays);
735
+			$this->warnings['horizont'] = lang('Requested date %1 outside allowed range of %2 days: recurring events obmitted!', egw_time::to($new_horizont, true), $maxdays);
736 736
 			return;
737 737
 		}
738
-		if ($new_horizont < time()+31*DAY_s)
738
+		if ($new_horizont < time() + 31 * DAY_s)
739 739
 		{
740
-			$new_horizont = time()+31*DAY_s;
740
+			$new_horizont = time() + 31 * DAY_s;
741 741
 		}
742 742
 		$old_horizont = $this->config['horizont'];
743 743
 		$this->config['horizont'] = $new_horizont;
@@ -745,21 +745,21 @@  discard block
 block discarded – undo
745 745
 		// create further recurrences for all recurring and not yet (at the old horizont) ended events
746 746
 		if (($recuring = $this->so->unfinished_recuring($old_horizont)))
747 747
 		{
748
-			@set_time_limit(0);	// disable time-limit, in case it takes longer to calculate the recurrences
749
-			foreach($this->read(array_keys($recuring)) as $cal_id => $event)
748
+			@set_time_limit(0); // disable time-limit, in case it takes longer to calculate the recurrences
749
+			foreach ($this->read(array_keys($recuring)) as $cal_id => $event)
750 750
 			{
751 751
 				if ($this->debug == 'check_move_horizont')
752 752
 				{
753
-					$this->debug_message('calendar_bo::check_move_horizont(%1): calling set_recurrences(%2,%3)',true,$new_horizont,$event,$old_horizont);
753
+					$this->debug_message('calendar_bo::check_move_horizont(%1): calling set_recurrences(%2,%3)', true, $new_horizont, $event, $old_horizont);
754 754
 				}
755 755
 				// insert everything behind max(cal_start), which can be less then $old_horizont because of bugs in the past
756
-				$this->set_recurrences($event,egw_time::server2user($recuring[$cal_id]+1));	// set_recurences operates in user-time!
756
+				$this->set_recurrences($event, egw_time::server2user($recuring[$cal_id] + 1)); // set_recurences operates in user-time!
757 757
 			}
758 758
 		}
759 759
 		// update the horizont
760
-		config::save_value('horizont',$this->config['horizont'],'calendar');
760
+		config::save_value('horizont', $this->config['horizont'], 'calendar');
761 761
 
762
-		if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) new horizont=%2, exiting',true,$new_horizont,(int)$this->config['horizont']);
762
+		if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) new horizont=%2, exiting', true, $new_horizont, (int)$this->config['horizont']);
763 763
 	}
764 764
 
765 765
 	/**
@@ -770,11 +770,11 @@  discard block
 block discarded – undo
770 770
 	 * @param array $event
771 771
 	 * @param mixed $start =0 minimum start-time for new recurrences or !$start = since the start of the event
772 772
 	 */
773
-	function set_recurrences($event,$start=0)
773
+	function set_recurrences($event, $start = 0)
774 774
 	{
775
-		if ($this->debug && ((int) $this->debug >= 2 || $this->debug == 'set_recurrences' || $this->debug == 'check_move_horizont'))
775
+		if ($this->debug && ((int)$this->debug >= 2 || $this->debug == 'set_recurrences' || $this->debug == 'check_move_horizont'))
776 776
 		{
777
-			$this->debug_message('calendar_bo::set_recurrences(%1,%2)',true,$event,$start);
777
+			$this->debug_message('calendar_bo::set_recurrences(%1,%2)', true, $event, $start);
778 778
 		}
779 779
 		// check if the caller gave us enough information and if not read it from the DB
780 780
 		if (!isset($event['participants']) || !isset($event['start']) || !isset($event['end']))
@@ -793,27 +793,27 @@  discard block
 block discarded – undo
793 793
 		if (!$start) $start = $event['start'];
794 794
 
795 795
 		$events = array();
796
-		$this->insert_all_recurrences($event,$start,$this->date2usertime($this->config['horizont']),$events);
796
+		$this->insert_all_recurrences($event, $start, $this->date2usertime($this->config['horizont']), $events);
797 797
 
798 798
 		$exceptions = array();
799
-		foreach((array)$event['recur_exception'] as $exception)
799
+		foreach ((array)$event['recur_exception'] as $exception)
800 800
 		{
801
-			$exceptions[] = egw_time::to($exception, true);	// true = date
801
+			$exceptions[] = egw_time::to($exception, true); // true = date
802 802
 		}
803 803
 		//error_log(__METHOD__."(".array2string($event).", $start) exceptions=".array2string($exceptions));
804
-		foreach($events as $event)
804
+		foreach ($events as $event)
805 805
 		{
806 806
 			$is_exception = in_array(egw_time::to($event['start'], true), $exceptions);
807
-			$start = $this->date2ts($event['start'],true);
807
+			$start = $this->date2ts($event['start'], true);
808 808
 			if ($event['whole_day'])
809 809
 			{
810 810
 				$time = $this->so->startOfDay(new egw_time($event['end'], egw_time::$user_timezone));
811 811
 				$time->setTime(23, 59, 59);
812
-				$end = $this->date2ts($time,true);
812
+				$end = $this->date2ts($time, true);
813 813
 			}
814 814
 			else
815 815
 			{
816
-				$end = $this->date2ts($event['end'],true);
816
+				$end = $this->date2ts($event['end'], true);
817 817
 			}
818 818
 			//error_log(__METHOD__."() start=".egw_time::to($start).", is_exception=".array2string($is_exception));
819 819
 			$this->so->recurrence($event['id'], $start, $end, $event['participants'], $is_exception);
@@ -829,7 +829,7 @@  discard block
 block discarded – undo
829 829
 	 * @param array &$events array of event-arrays (reference)
830 830
 	 * @param $date_format ='ts' date-formats: 'ts'=timestamp, 'server'=timestamp in server-time, 'array'=array or string with date-format
831 831
 	 */
832
-	function db2data(&$events,$date_format='ts')
832
+	function db2data(&$events, $date_format = 'ts')
833 833
 	{
834 834
 		if (!is_array($events)) echo "<p>calendar_bo::db2data(\$events,$date_format) \$events is no array<br />\n".function_backtrace()."</p>\n";
835 835
 		foreach ($events as &$event)
@@ -842,65 +842,65 @@  discard block
 block discarded – undo
842 842
 			// database returns timestamps as string, convert them to integer
843 843
 			// to avoid misinterpretation by egw_time as Ymd string
844 844
 			// (this will fail on 32bit systems for times > 2038!)
845
-			$event['start'] = (int)$event['start'];	// this is for isWholeDay(), which also calls egw_time
845
+			$event['start'] = (int)$event['start']; // this is for isWholeDay(), which also calls egw_time
846 846
 			$event['end'] = (int)$event['end'];
847 847
 			$event['whole_day'] = self::isWholeDay($event);
848 848
 			if ($event['whole_day'] && $date_format != 'server')
849 849
 			{
850 850
 				// Adjust dates to user TZ
851
-				$stime =& $this->so->startOfDay(new egw_time((int)$event['start'], egw_time::$server_timezone), $event['tzid']);
851
+				$stime = & $this->so->startOfDay(new egw_time((int)$event['start'], egw_time::$server_timezone), $event['tzid']);
852 852
 				$event['start'] = egw_time::to($stime, $date_format);
853
-				$time =& $this->so->startOfDay(new egw_time((int)$event['end'], egw_time::$server_timezone), $event['tzid']);
853
+				$time = & $this->so->startOfDay(new egw_time((int)$event['end'], egw_time::$server_timezone), $event['tzid']);
854 854
 				$time->setTime(23, 59, 59);
855 855
 				$event['end'] = egw_time::to($time, $date_format);
856 856
 				if (!empty($event['recurrence']))
857 857
 				{
858
-					$time =& $this->so->startOfDay(new egw_time((int)$event['recurrence'], egw_time::$server_timezone), $event['tzid']);
858
+					$time = & $this->so->startOfDay(new egw_time((int)$event['recurrence'], egw_time::$server_timezone), $event['tzid']);
859 859
 					$event['recurrence'] = egw_time::to($time, $date_format);
860 860
 				}
861 861
 				if (!empty($event['recur_enddate']))
862 862
 				{
863
-					$time =& $this->so->startOfDay(new egw_time((int)$event['recur_enddate'], egw_time::$server_timezone), $event['tzid']);
863
+					$time = & $this->so->startOfDay(new egw_time((int)$event['recur_enddate'], egw_time::$server_timezone), $event['tzid']);
864 864
 					$time->setTime(23, 59, 59);
865 865
 					$event['recur_enddate'] = egw_time::to($time, $date_format);
866 866
 				}
867
-				$timestamps = array('modified','created');
867
+				$timestamps = array('modified', 'created');
868 868
 			}
869 869
 			else
870 870
 			{
871
-				$timestamps = array('start','end','modified','created','recur_enddate','recurrence');
871
+				$timestamps = array('start', 'end', 'modified', 'created', 'recur_enddate', 'recurrence');
872 872
 			}
873 873
 			// we convert here from the server-time timestamps to user-time and (optional) to a different date-format!
874 874
 			foreach ($timestamps as $ts)
875 875
 			{
876 876
 				if (!empty($event[$ts]))
877 877
 				{
878
-					$event[$ts] = $this->date2usertime((int)$event[$ts],$date_format);
878
+					$event[$ts] = $this->date2usertime((int)$event[$ts], $date_format);
879 879
 				}
880 880
 			}
881 881
 			// same with the recur exceptions
882 882
 			if (isset($event['recur_exception']) && is_array($event['recur_exception']))
883 883
 			{
884
-				foreach($event['recur_exception'] as &$date)
884
+				foreach ($event['recur_exception'] as &$date)
885 885
 				{
886 886
 					if ($event['whole_day'] && $date_format != 'server')
887 887
 					{
888 888
 						// Adjust dates to user TZ
889
-						$time =& $this->so->startOfDay(new egw_time((int)$date, egw_time::$server_timezone), $event['tzid']);
889
+						$time = & $this->so->startOfDay(new egw_time((int)$date, egw_time::$server_timezone), $event['tzid']);
890 890
 						$date = egw_time::to($time, $date_format);
891 891
 					}
892 892
 					else
893 893
 					{
894
-						$date = $this->date2usertime((int)$date,$date_format);
894
+						$date = $this->date2usertime((int)$date, $date_format);
895 895
 					}
896 896
 				}
897 897
 			}
898 898
 			// same with the alarms
899 899
 			if (isset($event['alarm']) && is_array($event['alarm']))
900 900
 			{
901
-				foreach($event['alarm'] as &$alarm)
901
+				foreach ($event['alarm'] as &$alarm)
902 902
 				{
903
-					$alarm['time'] = $this->date2usertime((int)$alarm['time'],$date_format);
903
+					$alarm['time'] = $this->date2usertime((int)$alarm['time'], $date_format);
904 904
 				}
905 905
 			}
906 906
 		}
@@ -913,11 +913,11 @@  discard block
 block discarded – undo
913 913
 	 * @param string $date_format ='ts' date-formats: 'ts'=timestamp, 'server'=timestamp in server-time, 'array'=array or string with date-format
914 914
 	 * @return mixed depending of $date_format
915 915
 	 */
916
-	function date2usertime($ts,$date_format='ts')
916
+	function date2usertime($ts, $date_format = 'ts')
917 917
 	{
918 918
 		if (empty($ts) || $date_format == 'server') return $ts;
919 919
 
920
-		return egw_time::server2user($ts,$date_format);
920
+		return egw_time::server2user($ts, $date_format);
921 921
 	}
922 922
 
923 923
 	/**
@@ -931,7 +931,7 @@  discard block
 block discarded – undo
931 931
 	 * 	but call clear_private_infos() with the given users
932 932
 	 * @return boolean|array event or array of id => event pairs, false if the acl-check went wrong, null if $ids not found
933 933
 	 */
934
-	function read($ids,$date=null,$ignore_acl=False,$date_format='ts',$clear_private_infos_users=null)
934
+	function read($ids, $date = null, $ignore_acl = False, $date_format = 'ts', $clear_private_infos_users = null)
935 935
 	{
936 936
 		if (!$ids) return false;
937 937
 
@@ -940,21 +940,21 @@  discard block
 block discarded – undo
940 940
 		$return = null;
941 941
 
942 942
 		$check = $clear_private_infos_users ? EGW_ACL_FREEBUSY : EGW_ACL_READ;
943
-		if ($ignore_acl || is_array($ids) || ($return = $this->check_perms($check,$ids,0,$date_format,$date)))
943
+		if ($ignore_acl || is_array($ids) || ($return = $this->check_perms($check, $ids, 0, $date_format, $date)))
944 944
 		{
945 945
 			if (is_array($ids) || !isset(self::$cached_event['id']) || self::$cached_event['id'] != $ids ||
946 946
 				self::$cached_event_date_format != $date_format ||
947 947
 				self::$cached_event['recur_type'] != MCAL_RECUR_NONE && self::$cached_event_date != $date)
948 948
 			{
949
-				$events = $this->so->read($ids,$date ? $this->date2ts($date,true) : 0);
949
+				$events = $this->so->read($ids, $date ? $this->date2ts($date, true) : 0);
950 950
 
951 951
 				if ($events)
952 952
 				{
953
-					$this->db2data($events,$date_format);
953
+					$this->db2data($events, $date_format);
954 954
 
955 955
 					if (is_array($ids))
956 956
 					{
957
-						$return =& $events;
957
+						$return = & $events;
958 958
 					}
959 959
 					else
960 960
 					{
@@ -970,13 +970,13 @@  discard block
 block discarded – undo
970 970
 				$return = self::$cached_event;
971 971
 			}
972 972
 		}
973
-		if ($clear_private_infos_users && !is_array($ids) && !$this->check_perms(EGW_ACL_READ,$return))
973
+		if ($clear_private_infos_users && !is_array($ids) && !$this->check_perms(EGW_ACL_READ, $return))
974 974
 		{
975 975
 			$this->clear_private_infos($return, (array)$clear_private_infos_users);
976 976
 		}
977 977
 		if ($this->debug && ($this->debug > 1 || $this->debug == 'read'))
978 978
 		{
979
-			$this->debug_message('calendar_bo::read(%1,%2,%3,%4,%5)=%6',True,$ids,$date,$ignore_acl,$date_format,$clear_private_infos_users,$return);
979
+			$this->debug_message('calendar_bo::read(%1,%2,%3,%4,%5)=%6', True, $ids, $date, $ignore_acl, $date_format, $clear_private_infos_users, $return);
980 980
 		}
981 981
 		return $return;
982 982
 	}
@@ -994,17 +994,17 @@  discard block
 block discarded – undo
994 994
 	 * @param array $events where the repetions get inserted
995 995
 	 * @param array $recur_exceptions with date (in Ymd) as key (and True as values), seems not to be used anymore
996 996
 	 */
997
-	function insert_all_recurrences($event,$_start,$end,&$events)
997
+	function insert_all_recurrences($event, $_start, $end, &$events)
998 998
 	{
999
-		if ((int) $this->debug >= 3 || $this->debug == 'set_recurrences' || $this->debug == 'check_move_horizont' || $this->debug == 'insert_all_recurrences')
999
+		if ((int)$this->debug >= 3 || $this->debug == 'set_recurrences' || $this->debug == 'check_move_horizont' || $this->debug == 'insert_all_recurrences')
1000 1000
 		{
1001
-			$this->debug_message(__METHOD__.'(%1,%2,%3,&$events)',true,$event,$_start,$end);
1001
+			$this->debug_message(__METHOD__.'(%1,%2,%3,&$events)', true, $event, $_start, $end);
1002 1002
 		}
1003 1003
 		$end_in = $end;
1004 1004
 
1005 1005
 		$start = $this->date2ts($_start);
1006 1006
 		$event_start_ts = $this->date2ts($event['start']);
1007
-		$event_length = $this->date2ts($event['end']) - $event_start_ts;	// we use a constant event-length, NOT a constant end-time!
1007
+		$event_length = $this->date2ts($event['end']) - $event_start_ts; // we use a constant event-length, NOT a constant end-time!
1008 1008
 
1009 1009
 		// if $end is before recur_enddate, use it instead
1010 1010
 		if (!$event['recur_enddate'] || $this->date2ts($event['recur_enddate']) > $this->date2ts($end))
@@ -1016,27 +1016,27 @@  discard block
 block discarded – undo
1016 1016
 		// unset exceptions, as we need to add them as recurrence too, but marked as exception
1017 1017
 		unset($event['recur_exception']);
1018 1018
 		// loop over all recurrences and insert them, if they are after $start
1019
-		$rrule = calendar_rrule::event2rrule($event, true);	// true = we operate in usertime, like the rest of calendar_bo
1020
-		foreach($rrule as $time)
1019
+		$rrule = calendar_rrule::event2rrule($event, true); // true = we operate in usertime, like the rest of calendar_bo
1020
+		foreach ($rrule as $time)
1021 1021
 		{
1022
-			$time->setUser();	// $time is in timezone of event, convert it to usertime used here
1023
-			if (($ts = $this->date2ts($time)) < $start-$event_length)
1022
+			$time->setUser(); // $time is in timezone of event, convert it to usertime used here
1023
+			if (($ts = $this->date2ts($time)) < $start - $event_length)
1024 1024
 			{
1025 1025
 				//echo "<p>".$time." --> ignored as $ts < $start-$event_length</p>\n";
1026
-				continue;	// to early or original event (returned by interator too)
1026
+				continue; // to early or original event (returned by interator too)
1027 1027
 			}
1028 1028
 
1029 1029
 			$ts_end = $ts + $event_length;
1030 1030
 			// adjust ts_end for whole day events in case it does not fit due to
1031 1031
 			// spans over summer/wintertime adjusted days
1032
-			if($event['whole_day'] && ($arr_end = $this->date2array($ts_end)) &&
1032
+			if ($event['whole_day'] && ($arr_end = $this->date2array($ts_end)) &&
1033 1033
 				!($arr_end['hour'] == 23 && $arr_end['minute'] == 59 && $arr_end['second'] == 59))
1034 1034
 			{
1035 1035
 				$arr_end['hour'] = 23;
1036 1036
 				$arr_end['minute'] = 59;
1037 1037
 				$arr_end['second'] = 59;
1038 1038
 				$ts_end_guess = $this->date2ts($arr_end);
1039
-				if($ts_end_guess - $ts_end > DAY_s/2)
1039
+				if ($ts_end_guess - $ts_end > DAY_s / 2)
1040 1040
 				{
1041 1041
 					$ts_end = $ts_end_guess - DAY_s; // $ts_end_guess was one day too far in the future
1042 1042
 				}
@@ -1050,11 +1050,11 @@  discard block
 block discarded – undo
1050 1050
 			$event['end'] = $ts_end;
1051 1051
 			$events[] = $event;
1052 1052
 		}
1053
-		if ($this->debug && ((int) $this->debug > 2 || $this->debug == 'set_recurrences' || $this->debug == 'check_move_horizont' || $this->debug == 'insert_all_recurrences'))
1053
+		if ($this->debug && ((int)$this->debug > 2 || $this->debug == 'set_recurrences' || $this->debug == 'check_move_horizont' || $this->debug == 'insert_all_recurrences'))
1054 1054
 		{
1055 1055
 			$event['start'] = $event_start_ts;
1056 1056
 			$event['end'] = $event_start_ts + $event_length;
1057
-			$this->debug_message(__METHOD__.'(%1,start=%2,end=%3,events) events=%5',True,$event,$_start,$end_in,$events);
1057
+			$this->debug_message(__METHOD__.'(%1,start=%2,end=%3,events) events=%5', True, $event, $_start, $end_in, $events);
1058 1058
 		}
1059 1059
 	}
1060 1060
 
@@ -1065,18 +1065,18 @@  discard block
 block discarded – undo
1065 1065
 	 * @param array $event event to insert, it has start- and end-date of the first recurrence, not of $date_ymd
1066 1066
 	 * @param int|string $date_ymd of the date of the event
1067 1067
 	 */
1068
-	function add_adjusted_event(&$events,$event,$date_ymd)
1068
+	function add_adjusted_event(&$events, $event, $date_ymd)
1069 1069
 	{
1070 1070
 		$event_in = $event;
1071 1071
 		// calculate the new start- and end-time
1072 1072
 		$length_s = $this->date2ts($event['end']) - $this->date2ts($event['start']);
1073 1073
 		$event_start_arr = $this->date2array($event['start']);
1074 1074
 
1075
-		$date_arr = $this->date2array((string) $date_ymd);
1075
+		$date_arr = $this->date2array((string)$date_ymd);
1076 1076
 		$date_arr['hour'] = $event_start_arr['hour'];
1077 1077
 		$date_arr['minute'] = $event_start_arr['minute'];
1078 1078
 		$date_arr['second'] = $event_start_arr['second'];
1079
-		unset($date_arr['raw']);	// else date2ts would use it
1079
+		unset($date_arr['raw']); // else date2ts would use it
1080 1080
 		$event['start'] = $this->date2ts($date_arr);
1081 1081
 		$event['end'] = $event['start'] + $length_s;
1082 1082
 
@@ -1084,7 +1084,7 @@  discard block
 block discarded – undo
1084 1084
 
1085 1085
 		if ($this->debug && ($this->debug > 2 || $this->debug == 'add_adjust_event'))
1086 1086
 		{
1087
-			$this->debug_message('calendar_bo::add_adjust_event(,%1,%2) as %3',True,$event_in,$date_ymd,$event);
1087
+			$this->debug_message('calendar_bo::add_adjust_event(,%1,%2) as %3', True, $event_in, $date_ymd, $event);
1088 1088
 		}
1089 1089
 	}
1090 1090
 
@@ -1108,22 +1108,22 @@  discard block
 block discarded – undo
1108 1108
 			{
1109 1109
 				$info = array(
1110 1110
 					'res_id'    => $uid,
1111
-					'email' => $GLOBALS['egw']->accounts->id2name($uid,'account_email'),
1112
-					'name'  => trim($GLOBALS['egw']->accounts->id2name($uid,'account_firstname'). ' ' .
1113
-					$GLOBALS['egw']->accounts->id2name($uid,'account_lastname')),
1111
+					'email' => $GLOBALS['egw']->accounts->id2name($uid, 'account_email'),
1112
+					'name'  => trim($GLOBALS['egw']->accounts->id2name($uid, 'account_firstname').' '.
1113
+					$GLOBALS['egw']->accounts->id2name($uid, 'account_lastname')),
1114 1114
 					'type'  => $GLOBALS['egw']->accounts->get_type($uid),
1115 1115
 					'app'   => 'accounts',
1116 1116
 				);
1117 1117
 			}
1118 1118
 			else
1119 1119
 			{
1120
-				list($info) = $this->resources[$uid[0]]['info'] ? ExecMethod($this->resources[$uid[0]]['info'],substr($uid,1)) : false;
1120
+				list($info) = $this->resources[$uid[0]]['info'] ? ExecMethod($this->resources[$uid[0]]['info'], substr($uid, 1)) : false;
1121 1121
 				if ($info)
1122 1122
 				{
1123 1123
 					$info['type'] = $uid[0];
1124 1124
 					if (!$info['email'] && $info['responsible'])
1125 1125
 					{
1126
-						$info['email'] = $GLOBALS['egw']->accounts->id2name($info['responsible'],'account_email');
1126
+						$info['email'] = $GLOBALS['egw']->accounts->id2name($info['responsible'], 'account_email');
1127 1127
 					}
1128 1128
 					$info['app'] = $this->resources[$uid[0]]['app'];
1129 1129
 				}
@@ -1132,7 +1132,7 @@  discard block
 block discarded – undo
1132 1132
 		}
1133 1133
 		if ($this->debug && ($this->debug > 2 || $this->debug == 'resource_info'))
1134 1134
 		{
1135
-			$this->debug_message('calendar_bo::resource_info(%1) = %2',True,$uid,$res_info_cache[$uid]);
1135
+			$this->debug_message('calendar_bo::resource_info(%1) = %2', True, $uid, $res_info_cache[$uid]);
1136 1136
 		}
1137 1137
 		return $res_info_cache[$uid];
1138 1138
 	}
@@ -1153,7 +1153,7 @@  discard block
 block discarded – undo
1153 1153
 	 * @param int $user =null for which user to check, default current user
1154 1154
 	 * @return boolean true permission granted, false for permission denied or null if event not found
1155 1155
 	 */
1156
-	function check_perms($needed,$event=0,$other=0,$date_format='ts',$date_to_read=null,$user=null)
1156
+	function check_perms($needed, $event = 0, $other = 0, $date_format = 'ts', $date_to_read = null, $user = null)
1157 1157
 	{
1158 1158
 		if (!$user) $user = $this->user;
1159 1159
 		if ($user == $this->user)
@@ -1162,13 +1162,13 @@  discard block
 block discarded – undo
1162 1162
 		}
1163 1163
 		else
1164 1164
 		{
1165
-			$grants = $GLOBALS['egw']->acl->get_grants('calendar',true,$user);
1165
+			$grants = $GLOBALS['egw']->acl->get_grants('calendar', true, $user);
1166 1166
 		}
1167 1167
 
1168 1168
 		if ($other && !is_numeric($other))
1169 1169
 		{
1170 1170
 			$resource = $this->resource_info($other);
1171
-			return $needed & $resource['rights'];
1171
+			return $needed&$resource['rights'];
1172 1172
 		}
1173 1173
 		if (is_int($event) && $event == 0)
1174 1174
 		{
@@ -1178,15 +1178,15 @@  discard block
 block discarded – undo
1178 1178
 		{
1179 1179
 			if (!is_array($event))
1180 1180
 			{
1181
-				$event = $this->read($event,$date_to_read,true,$date_format);	// = no ACL check !!!
1181
+				$event = $this->read($event, $date_to_read, true, $date_format); // = no ACL check !!!
1182 1182
 			}
1183 1183
 			if (!is_array($event))
1184 1184
 			{
1185 1185
 				if ($this->xmlrpc)
1186 1186
 				{
1187
-					$GLOBALS['server']->xmlrpc_error($GLOBALS['xmlrpcerr']['not_exist'],$GLOBALS['xmlrpcstr']['not_exist']);
1187
+					$GLOBALS['server']->xmlrpc_error($GLOBALS['xmlrpcerr']['not_exist'], $GLOBALS['xmlrpcstr']['not_exist']);
1188 1188
 				}
1189
-				return null;	// event not found
1189
+				return null; // event not found
1190 1190
 			}
1191 1191
 			$owner = $event['owner'];
1192 1192
 			$private = !$event['public'];
@@ -1194,7 +1194,7 @@  discard block
 block discarded – undo
1194 1194
 		$grant = $grants[$owner];
1195 1195
 
1196 1196
 		// now any ACL rights (but invite rights!) implicate FREEBUSY rights (at least READ has to include FREEBUSY)
1197
-		if ($grant & ~EGW_ACL_INVITE) $grant |= EGW_ACL_FREEBUSY;
1197
+		if ($grant&~EGW_ACL_INVITE) $grant |= EGW_ACL_FREEBUSY;
1198 1198
 
1199 1199
 		if (is_array($event) && ($needed == EGW_ACL_READ || $needed == EGW_ACL_FREEBUSY))
1200 1200
 		{
@@ -1203,15 +1203,15 @@  discard block
 block discarded – undo
1203 1203
 			//
1204 1204
 			if ($event['participants'] && is_array($event['participants']))
1205 1205
 			{
1206
-				foreach(array_keys($event['participants']) as $uid)
1206
+				foreach (array_keys($event['participants']) as $uid)
1207 1207
 				{
1208
-					if ($uid == $user || $uid < 0 && in_array($user, (array)$GLOBALS['egw']->accounts->members($uid,true)))
1208
+					if ($uid == $user || $uid < 0 && in_array($user, (array)$GLOBALS['egw']->accounts->members($uid, true)))
1209 1209
 					{
1210 1210
 						// if we are a participant, we have an implicite FREEBUSY, READ and PRIVAT grant
1211
-						$grant |= EGW_ACL_FREEBUSY | EGW_ACL_READ | EGW_ACL_PRIVATE;
1211
+						$grant |= EGW_ACL_FREEBUSY|EGW_ACL_READ|EGW_ACL_PRIVATE;
1212 1212
 						break;
1213 1213
 					}
1214
-					elseif ($grants[$uid] & EGW_ACL_READ)
1214
+					elseif ($grants[$uid]&EGW_ACL_READ)
1215 1215
 					{
1216 1216
 						// if we have a READ grant from a participant, we dont give an implicit privat grant too
1217 1217
 						$grant |= EGW_ACL_READ;
@@ -1230,12 +1230,12 @@  discard block
 block discarded – undo
1230 1230
 		}
1231 1231
 		if ($GLOBALS['egw']->accounts->get_type($owner) == 'g' && $needed == EGW_ACL_ADD)
1232 1232
 		{
1233
-			$access = False;	// a group can't be the owner of an event
1233
+			$access = False; // a group can't be the owner of an event
1234 1234
 		}
1235 1235
 		else
1236 1236
 		{
1237
-			$access = $user == $owner || $grant & $needed
1238
-				&& ($needed == EGW_ACL_FREEBUSY || !$private || $grant & EGW_ACL_PRIVATE);
1237
+			$access = $user == $owner || $grant&$needed
1238
+				&& ($needed == EGW_ACL_FREEBUSY || !$private || $grant&EGW_ACL_PRIVATE);
1239 1239
 		}
1240 1240
 		// do NOT allow users to purge deleted events, if we dont have 'userpurge' enabled
1241 1241
 		if ($access && $needed == EGW_ACL_DELETE && $event['deleted'] &&
@@ -1246,7 +1246,7 @@  discard block
 block discarded – undo
1246 1246
 		}
1247 1247
 		if ($this->debug && ($this->debug > 2 || $this->debug == 'check_perms'))
1248 1248
 		{
1249
-			$this->debug_message('calendar_bo::check_perms(%1,%2,other=%3,%4,%5,user=%6)=%7',True,ACL_TYPE_IDENTIFER.$needed,$event,$other,$date_format,$date_to_read,$user,$access);
1249
+			$this->debug_message('calendar_bo::check_perms(%1,%2,other=%3,%4,%5,user=%6)=%7', True, ACL_TYPE_IDENTIFER.$needed, $event, $other, $date_format, $date_to_read, $user, $access);
1250 1250
 		}
1251 1251
 		//error_log(__METHOD__."($needed,".array2string($event).",$other,...,$user) returning ".array2string($access));
1252 1252
 		return $access;
@@ -1261,9 +1261,9 @@  discard block
 block discarded – undo
1261 1261
 	 *	array with keys 'second', 'minute', 'hour', 'day' or 'mday' (depricated !), 'month' and 'year'
1262 1262
 	 * @param boolean $user2server =False conversion between user- and server-time; default False == Off
1263 1263
 	 */
1264
-	static function date2ts($date,$user2server=False)
1264
+	static function date2ts($date, $user2server = False)
1265 1265
 	{
1266
-		return $user2server ? egw_time::user2server($date,'ts') : egw_time::to($date,'ts');
1266
+		return $user2server ? egw_time::user2server($date, 'ts') : egw_time::to($date, 'ts');
1267 1267
 	}
1268 1268
 
1269 1269
 	/**
@@ -1273,9 +1273,9 @@  discard block
 block discarded – undo
1273 1273
 	 * @param boolean $server2user conversation between user- and server-time default False == Off
1274 1274
 	 * @return array with keys 'second', 'minute', 'hour', 'day', 'month', 'year', 'raw' (timestamp) and 'full' (Ymd-string)
1275 1275
 	 */
1276
-	static function date2array($date,$server2user=False)
1276
+	static function date2array($date, $server2user = False)
1277 1277
 	{
1278
-		return $server2user ? egw_time::server2user($date,'array') : egw_time::to($date,'array');
1278
+		return $server2user ? egw_time::server2user($date, 'array') : egw_time::to($date, 'array');
1279 1279
 	}
1280 1280
 
1281 1281
 	/**
@@ -1286,9 +1286,9 @@  discard block
 block discarded – undo
1286 1286
 	 * @param string $format ='Ymd' format of the date to return, eg. 'Y-m-d\TH:i:sO' (2005-11-01T15:30:00+0100)
1287 1287
 	 * @return string date formatted according to $format
1288 1288
 	 */
1289
-	static function date2string($date,$server2user=False,$format='Ymd')
1289
+	static function date2string($date, $server2user = False, $format = 'Ymd')
1290 1290
 	{
1291
-		return $server2user ? egw_time::server2user($date,$format) : egw_time::to($date,$format);
1291
+		return $server2user ? egw_time::server2user($date, $format) : egw_time::to($date, $format);
1292 1292
 	}
1293 1293
 
1294 1294
 	/**
@@ -1298,9 +1298,9 @@  discard block
 block discarded – undo
1298 1298
 	 * @param string|boolean $format ='' default common_prefs[dateformat], common_prefs[timeformat], false=time only, true=date only
1299 1299
 	 * @return string the formated date (incl. time)
1300 1300
 	 */
1301
-	static function format_date($date,$format='')
1301
+	static function format_date($date, $format = '')
1302 1302
 	{
1303
-		return egw_time::to($date,$format);
1303
+		return egw_time::to($date, $format);
1304 1304
 	}
1305 1305
 
1306 1306
 	/**
@@ -1322,7 +1322,7 @@  discard block
 block discarded – undo
1322 1322
 	 * @param mixed $param a variable number of parameters, to be inserted in $msg
1323 1323
 	 *	arrays get serialized with print_r() !
1324 1324
 	 */
1325
-	static function debug_message($msg,$backtrace=True)
1325
+	static function debug_message($msg, $backtrace = True)
1326 1326
 	{
1327 1327
 		static $acl2string = array(
1328 1328
 			0               => 'ACL-UNKNOWN',
@@ -1333,22 +1333,22 @@  discard block
 block discarded – undo
1333 1333
 			EGW_ACL_PRIVATE => 'ACL_PRIVATE',
1334 1334
 			EGW_ACL_FREEBUSY => 'ACL_FREEBUSY',
1335 1335
 		);
1336
-		for($i = 2; $i < func_num_args(); ++$i)
1336
+		for ($i = 2; $i < func_num_args(); ++$i)
1337 1337
 		{
1338 1338
 			$param = func_get_arg($i);
1339 1339
 
1340 1340
 			if (is_null($param))
1341 1341
 			{
1342
-				$param='NULL';
1342
+				$param = 'NULL';
1343 1343
 			}
1344 1344
 			else
1345 1345
 			{
1346
-				switch(gettype($param))
1346
+				switch (gettype($param))
1347 1347
 				{
1348 1348
 					case 'string':
1349
-						if (substr($param,0,strlen(ACL_TYPE_IDENTIFER))== ACL_TYPE_IDENTIFER)
1349
+						if (substr($param, 0, strlen(ACL_TYPE_IDENTIFER)) == ACL_TYPE_IDENTIFER)
1350 1350
 						{
1351
-							$param = (int) substr($param,strlen(ACL_TYPE_IDENTIFER));
1351
+							$param = (int)substr($param, strlen(ACL_TYPE_IDENTIFER));
1352 1352
 							$param = (isset($acl2string[$param]) ? $acl2string[$param] : $acl2string[0])." ($param)";
1353 1353
 						}
1354 1354
 						else
@@ -1370,11 +1370,11 @@  discard block
 block discarded – undo
1370 1370
 						$param = $param ? 'True' : 'False';
1371 1371
 						break;
1372 1372
 					case 'integer':
1373
-						if ($param >= mktime(0,0,0,1,1,2000)) $param = adodb_date('Y-m-d H:i:s',$param)." ($param)";
1373
+						if ($param >= mktime(0, 0, 0, 1, 1, 2000)) $param = adodb_date('Y-m-d H:i:s', $param)." ($param)";
1374 1374
 						break;
1375 1375
 				}
1376 1376
 			}
1377
-			$msg = str_replace('%'.($i-1),$param,$msg);
1377
+			$msg = str_replace('%'.($i - 1), $param, $msg);
1378 1378
 		}
1379 1379
 		error_log($msg);
1380 1380
 		if ($backtrace) error_log(function_backtrace(1));
@@ -1389,7 +1389,7 @@  discard block
 block discarded – undo
1389 1389
 	 * @param boolean $display_day =false should a day-name prefix the date, eg. monday June 20, 2006
1390 1390
 	 * @return string with formated date
1391 1391
 	 */
1392
-	function long_date($_first,$last=0,$display_time=false,$display_day=false)
1392
+	function long_date($_first, $last = 0, $display_time = false, $display_day = false)
1393 1393
 	{
1394 1394
 		$first = $this->date2array($_first);
1395 1395
 		if ($last)
@@ -1404,27 +1404,27 @@  discard block
 block discarded – undo
1404 1404
 
1405 1405
 		if ($display_day)
1406 1406
 		{
1407
-			$range = lang(adodb_date('l',$first['raw'])).($this->common_prefs['dateformat'][0] != 'd' ? ' ' : ', ');
1407
+			$range = lang(adodb_date('l', $first['raw'])).($this->common_prefs['dateformat'][0] != 'd' ? ' ' : ', ');
1408 1408
 		}
1409 1409
 		for ($i = 0; $i < 5; $i += 2)
1410 1410
 		{
1411
-			switch($datefmt[$i])
1411
+			switch ($datefmt[$i])
1412 1412
 			{
1413 1413
 				case 'd':
1414
-					$range .= $first['day'] . ($datefmt[1] == '.' ? '.' : '');
1414
+					$range .= $first['day'].($datefmt[1] == '.' ? '.' : '');
1415 1415
 					if ($first['month'] != $last['month'] || $first['year'] != $last['year'])
1416 1416
 					{
1417 1417
 						if (!$month_before_day)
1418 1418
 						{
1419
-							$range .= ' '.lang(strftime('%B',$first['raw']));
1419
+							$range .= ' '.lang(strftime('%B', $first['raw']));
1420 1420
 						}
1421 1421
 						if ($first['year'] != $last['year'] && $datefmt[0] != 'Y')
1422 1422
 						{
1423
-							$range .= ($datefmt[0] != 'd' ? ', ' : ' ') . $first['year'];
1423
+							$range .= ($datefmt[0] != 'd' ? ', ' : ' ').$first['year'];
1424 1424
 						}
1425 1425
 						if ($display_time)
1426 1426
 						{
1427
-							$range .= ' '.adodb_date($timefmt,$first['raw']);
1427
+							$range .= ' '.adodb_date($timefmt, $first['raw']);
1428 1428
 						}
1429 1429
 						if (!$last)
1430 1430
 						{
@@ -1434,43 +1434,43 @@  discard block
 block discarded – undo
1434 1434
 
1435 1435
 						if ($first['year'] != $last['year'] && $datefmt[0] == 'Y')
1436 1436
 						{
1437
-							$range .= $last['year'] . ', ';
1437
+							$range .= $last['year'].', ';
1438 1438
 						}
1439 1439
 
1440 1440
 						if ($month_before_day)
1441 1441
 						{
1442
-							$range .= lang(strftime('%B',$last['raw']));
1442
+							$range .= lang(strftime('%B', $last['raw']));
1443 1443
 						}
1444 1444
 					}
1445 1445
 					else
1446 1446
 					{
1447 1447
 						if ($display_time)
1448 1448
 						{
1449
-							$range .= ' '.adodb_date($timefmt,$first['raw']);
1449
+							$range .= ' '.adodb_date($timefmt, $first['raw']);
1450 1450
 						}
1451 1451
 						$range .= ' - ';
1452 1452
 					}
1453
-					$range .= ' ' . $last['day'] . ($datefmt[1] == '.' ? '.' : '');
1453
+					$range .= ' '.$last['day'].($datefmt[1] == '.' ? '.' : '');
1454 1454
 					break;
1455 1455
 				case 'm':
1456 1456
 				case 'M':
1457
-					$range .= ' '.lang(strftime('%B',$month_before_day ? $first['raw'] : $last['raw'])) . ' ';
1457
+					$range .= ' '.lang(strftime('%B', $month_before_day ? $first['raw'] : $last['raw'])).' ';
1458 1458
 					break;
1459 1459
 				case 'Y':
1460 1460
 					if ($datefmt[0] != 'm')
1461 1461
 					{
1462
-						$range .= ' ' . ($datefmt[0] == 'Y' ? $first['year'].($datefmt[2] == 'd' ? ', ' : ' ') : $last['year'].' ');
1462
+						$range .= ' '.($datefmt[0] == 'Y' ? $first['year'].($datefmt[2] == 'd' ? ', ' : ' ') : $last['year'].' ');
1463 1463
 					}
1464 1464
 					break;
1465 1465
 			}
1466 1466
 		}
1467 1467
 		if ($display_time && $last)
1468 1468
 		{
1469
-			$range .= ' '.adodb_date($timefmt,$last['raw']);
1469
+			$range .= ' '.adodb_date($timefmt, $last['raw']);
1470 1470
 		}
1471 1471
 		if ($datefmt[4] == 'Y' && $datefmt[0] == 'm')
1472 1472
 		{
1473
-			$range .= ', ' . $last['year'];
1473
+			$range .= ', '.$last['year'];
1474 1474
 		}
1475 1475
 		return $range;
1476 1476
 	}
@@ -1482,25 +1482,25 @@  discard block
 block discarded – undo
1482 1482
 	 * @param int $end_m end time in minutes since 0h
1483 1483
 	 * @param boolean $both =false display the end-time too, duration is always displayed
1484 1484
 	 */
1485
-	function timespan($start_m,$end_m,$both=false)
1485
+	function timespan($start_m, $end_m, $both = false)
1486 1486
 	{
1487 1487
 		$duration = $end_m - $start_m;
1488
-		if ($end_m == 24*60-1) ++$duration;
1489
-		$duration = floor($duration/60).lang('h').($duration%60 ? $duration%60 : '');
1488
+		if ($end_m == 24 * 60 - 1) ++$duration;
1489
+		$duration = floor($duration / 60).lang('h').($duration % 60 ? $duration % 60 : '');
1490 1490
 
1491
-		$timespan = $t = common::formattime(sprintf('%02d',$start_m/60),sprintf('%02d',$start_m%60));
1491
+		$timespan = $t = common::formattime(sprintf('%02d', $start_m / 60), sprintf('%02d', $start_m % 60));
1492 1492
 
1493 1493
 		if ($both)	// end-time too
1494 1494
 		{
1495
-			$timespan .= ' - '.common::formattime(sprintf('%02d',$end_m/60),sprintf('%02d',$end_m%60));
1495
+			$timespan .= ' - '.common::formattime(sprintf('%02d', $end_m / 60), sprintf('%02d', $end_m % 60));
1496 1496
 			// dont double am/pm if they are the same in both times
1497
-			if ($this->common_prefs['timeformat'] == 12 && substr($timespan,-2) == substr($t,-2))
1497
+			if ($this->common_prefs['timeformat'] == 12 && substr($timespan, -2) == substr($t, -2))
1498 1498
 			{
1499
-				$timespan = str_replace($t,substr($t,0,-3),$timespan);
1499
+				$timespan = str_replace($t, substr($t, 0, -3), $timespan);
1500 1500
 			}
1501 1501
 			$timespan .= ':';
1502 1502
 		}
1503
-		return $timespan . ' ' . $duration;
1503
+		return $timespan.' '.$duration;
1504 1504
 	}
1505 1505
 
1506 1506
 	/**
@@ -1511,13 +1511,13 @@  discard block
 block discarded – undo
1511 1511
 	* @param boolean $append_email =false append email (Name <email>)
1512 1512
 	* @return string with name
1513 1513
 	*/
1514
-	function participant_name($id,$use_type=false, $append_email=false)
1514
+	function participant_name($id, $use_type = false, $append_email = false)
1515 1515
 	{
1516 1516
 		static $id2lid = array();
1517 1517
 		static $id2email = array();
1518 1518
 
1519 1519
 		if ($use_type && $use_type != 'u') $id = $use_type.$id;
1520
-		if($id === 0 || $id === '0') $id = $this->user;
1520
+		if ($id === 0 || $id === '0') $id = $this->user;
1521 1521
 
1522 1522
 		if (!isset($id2lid[$id]))
1523 1523
 		{
@@ -1533,7 +1533,7 @@  discard block
 block discarded – undo
1533 1533
 			else
1534 1534
 			{
1535 1535
 				$id2lid[$id] = common::grab_owner_name($id);
1536
-				$id2email[$id] = $GLOBALS['egw']->accounts->id2name($id,'account_email');
1536
+				$id2email[$id] = $GLOBALS['egw']->accounts->id2name($id, 'account_email');
1537 1537
 			}
1538 1538
 		}
1539 1539
 		return $id2lid[$id].(($append_email || $id[0] == 'e') && $id2email[$id] ? ' <'.$id2email[$id].'>' : '');
@@ -1547,37 +1547,37 @@  discard block
 block discarded – undo
1547 1547
 	* @param boolean $show_group_invitation =false show group-invitations (status == 'G') or not (default)
1548 1548
 	* @return array with id / names with status pairs
1549 1549
 	*/
1550
-	function participants($event,$long_status=false,$show_group_invitation=false)
1550
+	function participants($event, $long_status = false, $show_group_invitation = false)
1551 1551
 	{
1552 1552
 		//error_log(__METHOD__.__LINE__.array2string($event['participants']));
1553 1553
 		$names = array();
1554
-		foreach((array)$event['participants'] as $id => $status)
1554
+		foreach ((array)$event['participants'] as $id => $status)
1555 1555
 		{
1556 1556
 			if (!is_string($status)) continue;
1557 1557
 			$quantity = $role = null;
1558
-			calendar_so::split_status($status,$quantity,$role);
1558
+			calendar_so::split_status($status, $quantity, $role);
1559 1559
 
1560
-			if ($status == 'G' && !$show_group_invitation) continue;	// dont show group-invitation
1560
+			if ($status == 'G' && !$show_group_invitation) continue; // dont show group-invitation
1561 1561
 
1562 1562
 			$lang_status = lang($this->verbose_status[$status]);
1563 1563
 			if (!$long_status)
1564 1564
 			{
1565
-				switch($status[0])
1565
+				switch ($status[0])
1566 1566
 				{
1567 1567
 					case 'A':	// accepted
1568
-						$status = html::image('calendar','accepted',$lang_status);
1568
+						$status = html::image('calendar', 'accepted', $lang_status);
1569 1569
 						break;
1570 1570
 					case 'R':	// rejected
1571
-						$status = html::image('calendar','rejected',$lang_status);
1571
+						$status = html::image('calendar', 'rejected', $lang_status);
1572 1572
 						break;
1573 1573
 					case 'T':	// tentative
1574
-						$status = html::image('calendar','tentative',$lang_status);
1574
+						$status = html::image('calendar', 'tentative', $lang_status);
1575 1575
 						break;
1576 1576
 					case 'U':	// no response = unknown
1577
-						$status = html::image('calendar','needs-action',$lang_status);
1577
+						$status = html::image('calendar', 'needs-action', $lang_status);
1578 1578
 						break;
1579 1579
 					case 'D':	// delegated
1580
-						$status = html::image('calendar','forward',$lang_status);
1580
+						$status = html::image('calendar', 'forward', $lang_status);
1581 1581
 						break;
1582 1582
 					case 'G':	// group invitation
1583 1583
 						// Todo: Image, seems not to be used
@@ -1599,13 +1599,13 @@  discard block
 block discarded – undo
1599 1599
 					$role = lang($this->roles[$role]);
1600 1600
 				}
1601 1601
 				// allow to use cats as roles (beside regular iCal ones)
1602
-				elseif (substr($role,0,6) == 'X-CAT-' && ($cat_id = (int)substr($role,6)) > 0)
1602
+				elseif (substr($role, 0, 6) == 'X-CAT-' && ($cat_id = (int)substr($role, 6)) > 0)
1603 1603
 				{
1604 1604
 					$role = $GLOBALS['egw']->categories->id2name($cat_id);
1605 1605
 				}
1606 1606
 				else
1607 1607
 				{
1608
-					$role = lang(str_replace('X-','',$role));
1608
+					$role = lang(str_replace('X-', '', $role));
1609 1609
 				}
1610 1610
 				$names[$id] .= ' '.$role;
1611 1611
 			}
@@ -1622,13 +1622,13 @@  discard block
 block discarded – undo
1622 1622
 	* @param int $color color of the category, if multiple cats, the color of the last one with color is returned
1623 1623
 	* @return array with id / names
1624 1624
 	*/
1625
-	function categories($category,&$color)
1625
+	function categories($category, &$color)
1626 1626
 	{
1627 1627
 		static $id2cat = array();
1628 1628
 		$cats = array();
1629 1629
 		$color = 0;
1630 1630
 
1631
-		foreach(explode(',',$category) as $cat_id)
1631
+		foreach (explode(',', $category) as $cat_id)
1632 1632
 		{
1633 1633
 			if (!$cat_id) continue;
1634 1634
 
@@ -1643,7 +1643,7 @@  discard block
 block discarded – undo
1643 1643
 			{
1644 1644
 				$color = $cat['data']['color'];
1645 1645
 			}
1646
-			elseif(preg_match('/(#[0-9A-Fa-f]{6})/', $cat['description'], $parts))
1646
+			elseif (preg_match('/(#[0-9A-Fa-f]{6})/', $cat['description'], $parts))
1647 1647
 			{
1648 1648
 				$color = $parts[1];
1649 1649
 			}
@@ -1655,12 +1655,12 @@  discard block
 block discarded – undo
1655 1655
 	/**
1656 1656
 	 *  This is called only by list_cals().  It was moved here to remove fatal error in php5 beta4
1657 1657
 	 */
1658
-	private static function _list_cals_add($id,&$users,&$groups)
1658
+	private static function _list_cals_add($id, &$users, &$groups)
1659 1659
 	{
1660 1660
 		$name = common::grab_owner_name($id);
1661 1661
 		if (!($egw_name = $GLOBALS['egw']->accounts->id2name($id)))
1662 1662
 		{
1663
-			return;	// do not return no longer existing accounts which eg. still mentioned in acl
1663
+			return; // do not return no longer existing accounts which eg. still mentioned in acl
1664 1664
 		}
1665 1665
 		if (($type = $GLOBALS['egw']->accounts->get_type($id)) == 'g')
1666 1666
 		{
@@ -1672,7 +1672,7 @@  discard block
 block discarded – undo
1672 1672
 		}
1673 1673
 		$arr[$id] = array(
1674 1674
 			'grantor' => $id,
1675
-			'value'   => ($type == 'g' ? 'g_' : '') . $id,
1675
+			'value'   => ($type == 'g' ? 'g_' : '').$id,
1676 1676
 			'name'    => $name,
1677 1677
 			'sname'	  => $egw_name
1678 1678
 		);
@@ -1694,26 +1694,26 @@  discard block
 block discarded – undo
1694 1694
 	 * @param int $user account_id of user to generate list for
1695 1695
 	 * @param array $grants =null calendar grants from user, or null to query them from acl class
1696 1696
 	 */
1697
-	public static function list_calendars($user, array $grants=null)
1697
+	public static function list_calendars($user, array $grants = null)
1698 1698
 	{
1699 1699
 		if (is_null($grants)) $grants = $GLOBALS['egw']->acl->get_grants('calendar', true, $user);
1700 1700
 
1701 1701
 		$users = $groups = array();
1702
-		foreach(array_keys($grants) as $id)
1702
+		foreach (array_keys($grants) as $id)
1703 1703
 		{
1704
-			self::_list_cals_add($id,$users,$groups);
1704
+			self::_list_cals_add($id, $users, $groups);
1705 1705
 		}
1706 1706
 		if (($memberships = $GLOBALS['egw']->accounts->membership($user)))
1707 1707
 		{
1708
-			foreach($memberships as $group_info)
1708
+			foreach ($memberships as $group_info)
1709 1709
 			{
1710
-				self::_list_cals_add($group_info['account_id'],$users,$groups);
1710
+				self::_list_cals_add($group_info['account_id'], $users, $groups);
1711 1711
 
1712
-				if (($account_perms = $GLOBALS['egw']->acl->get_ids_for_location($group_info['account_id'],EGW_ACL_READ,'calendar')))
1712
+				if (($account_perms = $GLOBALS['egw']->acl->get_ids_for_location($group_info['account_id'], EGW_ACL_READ, 'calendar')))
1713 1713
 				{
1714
-					foreach($account_perms as $id)
1714
+					foreach ($account_perms as $id)
1715 1715
 					{
1716
-						self::_list_cals_add($id,$users,$groups);
1716
+						self::_list_cals_add($id, $users, $groups);
1717 1717
 					}
1718 1718
 				}
1719 1719
 			}
@@ -1721,7 +1721,7 @@  discard block
 block discarded – undo
1721 1721
 		usort($users, array(__CLASS__, 'name_cmp'));
1722 1722
 		usort($groups, array(__CLASS__, 'name_cmp'));
1723 1723
 
1724
-		return array_merge($users, $groups);	// users first and then groups, both alphabeticaly
1724
+		return array_merge($users, $groups); // users first and then groups, both alphabeticaly
1725 1725
 	}
1726 1726
 
1727 1727
 	/**
@@ -1764,13 +1764,13 @@  discard block
 block discarded – undo
1764 1764
 	 *	dow: day of week, 0=sunday, .., 6= saturday
1765 1765
 	 *	observande_rule: boolean
1766 1766
 	 */
1767
-	function read_holidays($year=0)
1767
+	function read_holidays($year = 0)
1768 1768
 	{
1769
-		if (!$year) $year = (int) date('Y',$this->now_su);
1769
+		if (!$year) $year = (int)date('Y', $this->now_su);
1770 1770
 
1771 1771
 		if (!$this->cached_holidays)	// try reading the holidays from the session
1772 1772
 		{
1773
-			$this->cached_holidays = $GLOBALS['egw']->session->appsession('holidays','calendar');
1773
+			$this->cached_holidays = $GLOBALS['egw']->session->appsession('holidays', 'calendar');
1774 1774
 		}
1775 1775
 		if (!isset($this->cached_holidays[$year]))
1776 1776
 		{
@@ -1789,46 +1789,46 @@  discard block
 block discarded – undo
1789 1789
 					'n_family' => "!''",
1790 1790
 					'bday' => "!''",
1791 1791
 				);
1792
-				$bdays =& $contacts->search('',array('id','n_family','n_given','n_prefix','n_middle','bday'),
1793
-					'contact_bday ASC',$extra_cols='',$wildcard='',$empty=False,$op='AND',$start=false,$filter);
1792
+				$bdays = & $contacts->search('', array('id', 'n_family', 'n_given', 'n_prefix', 'n_middle', 'bday'),
1793
+					'contact_bday ASC', $extra_cols = '', $wildcard = '', $empty = False, $op = 'AND', $start = false, $filter);
1794 1794
 				// search accounts too, if not stored in contacts repository
1795 1795
 				$extra_accounts_search = $contacts->account_repository == 'ldap' && !is_null($contacts->so_accounts) &&
1796 1796
 					!$GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'];
1797
-				if ($extra_accounts_search && ($bdays2 =& $contacts->search('',array('id','n_family','n_given','n_prefix','n_middle','bday'),
1798
-					'contact_bday ASC',$extra_cols='',$wildcard='',$empty=False,$op='AND',$start=false,$filter+array('owner' => 0))))
1797
+				if ($extra_accounts_search && ($bdays2 = & $contacts->search('', array('id', 'n_family', 'n_given', 'n_prefix', 'n_middle', 'bday'),
1798
+					'contact_bday ASC', $extra_cols = '', $wildcard = '', $empty = False, $op = 'AND', $start = false, $filter + array('owner' => 0))))
1799 1799
 				{
1800
-					$bdays = !$bdays ? $bdays2 : array_merge($bdays,$bdays2);
1800
+					$bdays = !$bdays ? $bdays2 : array_merge($bdays, $bdays2);
1801 1801
 				}
1802 1802
 				if ($bdays)
1803 1803
 				{
1804 1804
 					// sort by month and day only
1805
-					usort($bdays,create_function('$a,$b','return (int) $a[\'bday\'] == (int) $b[\'bday\'] ? strcmp($a[\'bday\'],$b[\'bday\']) : (int) $a[\'bday\'] - (int) $b[\'bday\'];'));
1806
-					foreach($bdays as $pers)
1805
+					usort($bdays, create_function('$a,$b', 'return (int) $a[\'bday\'] == (int) $b[\'bday\'] ? strcmp($a[\'bday\'],$b[\'bday\']) : (int) $a[\'bday\'] - (int) $b[\'bday\'];'));
1806
+					foreach ($bdays as $pers)
1807 1807
 					{
1808
-						if (empty($pers['bday']) || $pers['bday']=='0000-00-00 0' || $pers['bday']=='0000-00-00' || $pers['bday']=='0.0.00')
1808
+						if (empty($pers['bday']) || $pers['bday'] == '0000-00-00 0' || $pers['bday'] == '0000-00-00' || $pers['bday'] == '0.0.00')
1809 1809
 						{
1810 1810
 							//error_log(__METHOD__.__LINE__.' Skipping entry for invalid birthday:'.array2string($pers));
1811 1811
 							continue;
1812 1812
 						}
1813
-						list($y,$m,$d) = explode('-',$pers['bday']);
1814
-						if ($y > $year) continue; 	// not yet born
1815
-						$this->cached_holidays[$year][sprintf('%04d%02d%02d',$year,$m,$d)][] = array(
1813
+						list($y, $m, $d) = explode('-', $pers['bday']);
1814
+						if ($y > $year) continue; // not yet born
1815
+						$this->cached_holidays[$year][sprintf('%04d%02d%02d', $year, $m, $d)][] = array(
1816 1816
 							'day'       => $d,
1817 1817
 							'month'     => $m,
1818 1818
 							'occurence' => 0,
1819 1819
 							'name'      => lang('Birthday').' '.($pers['n_given'] ? $pers['n_given'] : $pers['n_prefix']).' '.$pers['n_middle'].' '.
1820 1820
 								$pers['n_family'].($y && !$GLOBALS['egw_info']['server']['hide_birthdays'] ? ' ('.$y.')' : ''),
1821
-							'birthyear' => $y,	// this can be used to identify birthdays from holidays
1821
+							'birthyear' => $y, // this can be used to identify birthdays from holidays
1822 1822
 						);
1823 1823
 					}
1824 1824
 				}
1825 1825
 			}
1826 1826
 			// store holidays and birthdays in the session
1827
-			$this->cached_holidays = $GLOBALS['egw']->session->appsession('holidays','calendar',$this->cached_holidays);
1827
+			$this->cached_holidays = $GLOBALS['egw']->session->appsession('holidays', 'calendar', $this->cached_holidays);
1828 1828
 		}
1829
-		if ((int) $this->debug >= 2 || $this->debug == 'read_holidays')
1829
+		if ((int)$this->debug >= 2 || $this->debug == 'read_holidays')
1830 1830
 		{
1831
-			$this->debug_message('calendar_bo::read_holidays(%1)=%2',true,$year,$this->cached_holidays[$year]);
1831
+			$this->debug_message('calendar_bo::read_holidays(%1)=%2', true, $year, $this->cached_holidays[$year]);
1832 1832
 		}
1833 1833
 		return $this->cached_holidays[$year];
1834 1834
 	}
@@ -1839,10 +1839,10 @@  discard block
 block discarded – undo
1839 1839
 	 * @param type $event
1840 1840
 	 * @return array array of selected calendar fields
1841 1841
 	 */
1842
-	function get_link_options ($event = array())
1842
+	function get_link_options($event = array())
1843 1843
 	{
1844
-		unset($event);	// not used, but required by function signature
1845
-		$options = array (
1844
+		unset($event); // not used, but required by function signature
1845
+		$options = array(
1846 1846
 			'end' => lang('End date'),
1847 1847
 			'id' => lang('ID'),
1848 1848
 			'owner' => lang('Event owner'),
@@ -1869,7 +1869,7 @@  discard block
 block discarded – undo
1869 1869
 			list($id, $recur) = explode('-', $event, 2);
1870 1870
 			$event = $this->read($id, $recur);
1871 1871
 		}
1872
-		else if (!is_array($event) && (int) $event > 0)
1872
+		else if (!is_array($event) && (int)$event > 0)
1873 1873
 		{
1874 1874
 			$event = $this->read($event);
1875 1875
 		}
@@ -1877,7 +1877,7 @@  discard block
 block discarded – undo
1877 1877
 		{
1878 1878
 			return $event;
1879 1879
 		}
1880
-		$type = explode(',',$this->cal_prefs['link_title']);
1880
+		$type = explode(',', $this->cal_prefs['link_title']);
1881 1881
 		if (is_array($type))
1882 1882
 		{
1883 1883
 			foreach ($type as &$val)
@@ -1903,10 +1903,10 @@  discard block
 block discarded – undo
1903 1903
 						$extra_fields [] = $event[$val];
1904 1904
 				}
1905 1905
 			}
1906
-			$str_fields = implode(', ',$extra_fields);
1907
-			if (is_array($extra_fields)) return $this->format_date($event['start']) . ': ' . $event['title'] . ($str_fields? ', ' . $str_fields:'');
1906
+			$str_fields = implode(', ', $extra_fields);
1907
+			if (is_array($extra_fields)) return $this->format_date($event['start']).': '.$event['title'].($str_fields ? ', '.$str_fields : '');
1908 1908
 		}
1909
-		return $this->format_date($event['start']) . ': ' . $event['title'];
1909
+		return $this->format_date($event['start']).': '.$event['title'];
1910 1910
 	}
1911 1911
 
1912 1912
 	/**
@@ -1925,10 +1925,10 @@  discard block
 block discarded – undo
1925 1925
 			'offset' =>	$options['start'],
1926 1926
 			'order' => 'cal_start DESC',
1927 1927
 		);
1928
-		if($options['num_rows']) {
1928
+		if ($options['num_rows']) {
1929 1929
 			$query['num_rows'] = $options['num_rows'];
1930 1930
 		}
1931
-		foreach((array) $this->search($query) as $event)
1931
+		foreach ((array)$this->search($query) as $event)
1932 1932
 		{
1933 1933
 			$result[$event['id']] = $this->link_title($event);
1934 1934
 		}
@@ -1945,11 +1945,11 @@  discard block
 block discarded – undo
1945 1945
 	 * @param int $user =null for which user to check, default current user
1946 1946
 	 * @return boolean true if access is granted or false otherwise
1947 1947
 	 */
1948
-	function file_access($id,$check,$rel_path,$user=null)
1948
+	function file_access($id, $check, $rel_path, $user = null)
1949 1949
 	{
1950
-		unset($rel_path);	// not used, but required by function signature
1950
+		unset($rel_path); // not used, but required by function signature
1951 1951
 
1952
-		return $this->check_perms($check,$id,0,'ts',null,$user);
1952
+		return $this->check_perms($check, $id, 0, 'ts', null, $user);
1953 1953
 	}
1954 1954
 
1955 1955
 	/**
@@ -1959,47 +1959,47 @@  discard block
 block discarded – undo
1959 1959
 	 */
1960 1960
 	function check_set_default_prefs()
1961 1961
 	{
1962
-		if ($this->cal_prefs['interval'] && ($set = $GLOBALS['egw']->session->appsession('default_prefs_set','calendar')))
1962
+		if ($this->cal_prefs['interval'] && ($set = $GLOBALS['egw']->session->appsession('default_prefs_set', 'calendar')))
1963 1963
 		{
1964 1964
 			return;
1965 1965
 		}
1966
-		$GLOBALS['egw']->session->appsession('default_prefs_set','calendar','set');
1966
+		$GLOBALS['egw']->session->appsession('default_prefs_set', 'calendar', 'set');
1967 1967
 
1968
-		$default_prefs =& $GLOBALS['egw']->preferences->default['calendar'];
1969
-		$forced_prefs  =& $GLOBALS['egw']->preferences->forced['calendar'];
1968
+		$default_prefs = & $GLOBALS['egw']->preferences->default['calendar'];
1969
+		$forced_prefs  = & $GLOBALS['egw']->preferences->forced['calendar'];
1970 1970
 
1971 1971
 		if (!($planner_start_with_group = $GLOBALS['egw']->accounts->name2id('Default')))
1972 1972
 		{
1973 1973
 			$planner_start_with_group = '0';
1974 1974
 		}
1975
-		$subject = lang('Calendar Event') . ' - $$action$$: $$startdate$$ $$title$$'."\n";
1975
+		$subject = lang('Calendar Event').' - $$action$$: $$startdate$$ $$title$$'."\n";
1976 1976
 		$values = array(
1977
-			'notifyAdded'     => $subject . lang ('You have a meeting scheduled for %1','$$startdate$$'),
1978
-			'notifyCanceled'  => $subject . lang ('Your meeting scheduled for %1 has been canceled','$$startdate$$'),
1979
-			'notifyModified'  => $subject . lang ('Your meeting that had been scheduled for %1 has been rescheduled to %2','$$olddate$$','$$startdate$$'),
1980
-			'notifyDisinvited'=> $subject . lang ('You have been disinvited from the meeting at %1','$$startdate$$'),
1981
-			'notifyResponse'  => $subject . lang ('On %1 %2 %3 your meeting request for %4','$$date$$','$$fullname$$','$$action$$','$$startdate$$'),
1982
-			'notifyAlarm'     => lang('Alarm for %1 at %2 in %3','$$title$$','$$startdate$$','$$location$$')."\n".lang ('Here is your requested alarm.'),
1977
+			'notifyAdded'     => $subject.lang('You have a meeting scheduled for %1', '$$startdate$$'),
1978
+			'notifyCanceled'  => $subject.lang('Your meeting scheduled for %1 has been canceled', '$$startdate$$'),
1979
+			'notifyModified'  => $subject.lang('Your meeting that had been scheduled for %1 has been rescheduled to %2', '$$olddate$$', '$$startdate$$'),
1980
+			'notifyDisinvited'=> $subject.lang('You have been disinvited from the meeting at %1', '$$startdate$$'),
1981
+			'notifyResponse'  => $subject.lang('On %1 %2 %3 your meeting request for %4', '$$date$$', '$$fullname$$', '$$action$$', '$$startdate$$'),
1982
+			'notifyAlarm'     => lang('Alarm for %1 at %2 in %3', '$$title$$', '$$startdate$$', '$$location$$')."\n".lang('Here is your requested alarm.'),
1983 1983
 			'planner_start_with_group' => $planner_start_with_group,
1984 1984
 			'interval'        => 30,
1985 1985
 		);
1986
-		foreach($values as $var => $default)
1986
+		foreach ($values as $var => $default)
1987 1987
 		{
1988
-			$type = substr($var,0,6) == 'notify' ? 'forced' : 'default';
1988
+			$type = substr($var, 0, 6) == 'notify' ? 'forced' : 'default';
1989 1989
 
1990 1990
 			// only set, if neither default nor forced pref exists
1991 1991
 			if ((!isset($default_prefs[$var]) || (string)$default_prefs[$var] === '') && (!isset($forced_prefs[$var]) || (string)$forced_prefs[$var] === ''))
1992 1992
 			{
1993
-				$GLOBALS['egw']->preferences->add('calendar',$var,$default,'default');	// always store default, even if we have a forced too
1994
-				if ($type == 'forced') $GLOBALS['egw']->preferences->add('calendar',$var,$default,'forced');
1993
+				$GLOBALS['egw']->preferences->add('calendar', $var, $default, 'default'); // always store default, even if we have a forced too
1994
+				if ($type == 'forced') $GLOBALS['egw']->preferences->add('calendar', $var, $default, 'forced');
1995 1995
 				$this->cal_prefs[$var] = $default;
1996 1996
 				$need_save = True;
1997 1997
 			}
1998 1998
 		}
1999 1999
 		if ($need_save)
2000 2000
 		{
2001
-			$GLOBALS['egw']->preferences->save_repository(False,'default');
2002
-			$GLOBALS['egw']->preferences->save_repository(False,'forced');
2001
+			$GLOBALS['egw']->preferences->save_repository(False, 'default');
2002
+			$GLOBALS['egw']->preferences->save_repository(False, 'forced');
2003 2003
 		}
2004 2004
 	}
2005 2005
 
@@ -2009,7 +2009,7 @@  discard block
 block discarded – undo
2009 2009
 	 * @param int|string $user account_id or account_lid
2010 2010
 	 * @param string $pw =null password
2011 2011
 	 */
2012
-	static function freebusy_url($user='',$pw=null)
2012
+	static function freebusy_url($user = '', $pw = null)
2013 2013
 	{
2014 2014
 		if (is_numeric($user)) $user = $GLOBALS['egw']->accounts->id2name($user);
2015 2015
 
@@ -2022,8 +2022,8 @@  discard block
 block discarded – undo
2022 2022
 		elseif ($GLOBALS['egw_info']['user']['preferences']['calendar']['freebusy'] == 2)
2023 2023
 		{
2024 2024
 			$credentials = $GLOBALS['egw_info']['user']['account_lid']
2025
-				. ':' . $GLOBALS['egw_info']['user']['passwd'];
2026
-			$credentials = '&cred=' . base64_encode($credentials);
2025
+				. ':'.$GLOBALS['egw_info']['user']['passwd'];
2026
+			$credentials = '&cred='.base64_encode($credentials);
2027 2027
 		}
2028 2028
 		return (!$GLOBALS['egw_info']['server']['webserver_url'] || $GLOBALS['egw_info']['server']['webserver_url'][0] == '/' ?
2029 2029
 			($_SERVER['HTTPS'] ? 'https://' : 'http://').$_SERVER['HTTP_HOST'] : '').
@@ -2055,11 +2055,11 @@  discard block
 block discarded – undo
2055 2055
 	 * @param string &$schedule_tag=null on return schedule-tag (egw_cal.cal_id:egw_cal.cal_etag, no participant modifications!)
2056 2056
 	 * @return string|boolean string with etag or false
2057 2057
 	 */
2058
-	function get_etag($entry, &$schedule_tag=null)
2058
+	function get_etag($entry, &$schedule_tag = null)
2059 2059
 	{
2060 2060
 		if (!is_array($entry))
2061 2061
 		{
2062
-			list($id,$recur_date) = explode(':',$entry);
2062
+			list($id, $recur_date) = explode(':', $entry);
2063 2063
 			$entry = $this->read($id, $recur_date, true, 'server');
2064 2064
 		}
2065 2065
 		$etag = $schedule_tag = $entry['id'].':'.$entry['etag'];
@@ -2077,15 +2077,15 @@  discard block
 block discarded – undo
2077 2077
 	 * @param boolean $master_only =false only check recurance master (egw_cal_user.recur_date=0)
2078 2078
 	 * @return integer
2079 2079
 	 */
2080
-	public function get_ctag($user, $filter='owner', $master_only=false)
2080
+	public function get_ctag($user, $filter = 'owner', $master_only = false)
2081 2081
 	{
2082 2082
 		if ($this->debug > 1) $startime = microtime(true);
2083 2083
 
2084 2084
 		// resolve users to add memberships for users and members for groups
2085 2085
 		$users = $this->resolve_users($user);
2086
-		$ctag = $users ? $this->so->get_ctag($users, $filter == 'owner', $master_only) : 0;	// no rights, return 0 as ctag (otherwise we get SQL error!)
2086
+		$ctag = $users ? $this->so->get_ctag($users, $filter == 'owner', $master_only) : 0; // no rights, return 0 as ctag (otherwise we get SQL error!)
2087 2087
 
2088
-		if ($this->debug > 1) error_log(__METHOD__. "($user, '$filter') = $ctag = ".date('Y-m-d H:i:s',$ctag)." took ".(microtime(true)-$startime)." secs");
2088
+		if ($this->debug > 1) error_log(__METHOD__."($user, '$filter') = $ctag = ".date('Y-m-d H:i:s', $ctag)." took ".(microtime(true) - $startime)." secs");
2089 2089
 		return $ctag;
2090 2090
 	}
2091 2091
 
@@ -2105,7 +2105,7 @@  discard block
 block discarded – undo
2105 2105
 
2106 2106
 		$content = array(
2107 2107
 			'info_cat'       => $GLOBALS['egw']->categories->check_list(EGW_ACL_READ, $calendar['category']),
2108
-			'info_priority'  => $calendar['priority'] ,
2108
+			'info_priority'  => $calendar['priority'],
2109 2109
 			'info_public'    => $calendar['public'] != 'private',
2110 2110
 			'info_subject'   => $calendar['title'],
2111 2111
 			'info_des'       => $calendar['description'],
@@ -2120,7 +2120,7 @@  discard block
 block discarded – undo
2120 2120
 		$content['link_app'][] = $calendar['info_link']['app'];
2121 2121
 		$content['link_id'][]  = $calendar['info_link']['id'];
2122 2122
 		// Copy claendar's links
2123
-		foreach(egw_link::get_links('calendar',$calendar['id'],'','link_lastmod DESC',true) as $link)
2123
+		foreach (egw_link::get_links('calendar', $calendar['id'], '', 'link_lastmod DESC', true) as $link)
2124 2124
 		{
2125 2125
 			if ($link['app'] != egw_link::VFS_APPNAME)
2126 2126
 			{
@@ -2133,7 +2133,7 @@  discard block
 block discarded – undo
2133 2133
 			}
2134 2134
 		}
2135 2135
 		// Copy same custom fields
2136
-		foreach(array_keys(config::get_customfields('infolog')) as $name)
2136
+		foreach (array_keys(config::get_customfields('infolog')) as $name)
2137 2137
 		{
2138 2138
 			if ($this->customfields[$name]) $content['#'.$name] = $calendar['#'.$name];
2139 2139
 		}
@@ -2151,20 +2151,20 @@  discard block
 block discarded – undo
2151 2151
 	function timesheet_set($data)
2152 2152
 	{
2153 2153
 		$set = array();
2154
-		list($id,$recurrence) = explode(':',$data['id']);
2155
-		if ((int)$id && ($event = $this->read($id,$recurrence)))
2154
+		list($id, $recurrence) = explode(':', $data['id']);
2155
+		if ((int)$id && ($event = $this->read($id, $recurrence)))
2156 2156
 		{
2157 2157
 			$set['ts_start'] = $event['start'];
2158 2158
 			$set['ts_title'] = $this->link_title($event);
2159
-			$set['start_time'] = egw_time::to($event['start'],'H:i');
2159
+			$set['start_time'] = egw_time::to($event['start'], 'H:i');
2160 2160
 			$set['ts_description'] = $event['description'];
2161
-			if ($this->isWholeDay($event)) $event['end']++;	// whole day events are 1sec short
2161
+			if ($this->isWholeDay($event)) $event['end']++; // whole day events are 1sec short
2162 2162
 			$set['ts_duration']	= ($event['end'] - $event['start']) / 60;
2163 2163
 			$set['ts_quantity'] = ($event['end'] - $event['start']) / 3600;
2164
-			$set['end_time'] = null;	// unset end-time
2164
+			$set['end_time'] = null; // unset end-time
2165 2165
 			$set['cat_id'] = (int)$event['category'];
2166 2166
 
2167
-			foreach(egw_link::get_links('calendar',$id,'','link_lastmod DESC',true) as $link)
2167
+			foreach (egw_link::get_links('calendar', $id, '', 'link_lastmod DESC', true) as $link)
2168 2168
 			{
2169 2169
 				if ($link['app'] != 'timesheet' && $link['app'] != egw_link::VFS_APPNAME)
2170 2170
 				{
Please login to merge, or discard this patch.
Braces   +202 added lines, -50 removed lines patch added patch discarded remove patch
@@ -11,10 +11,13 @@  discard block
 block discarded – undo
11 11
  * @version $Id$
12 12
  */
13 13
 
14
-if (!defined('ACL_TYPE_IDENTIFER'))	// used to mark ACL-values for the debug_message methode
14
+if (!defined('ACL_TYPE_IDENTIFER'))
15
+{
16
+	// used to mark ACL-values for the debug_message methode
15 17
 {
16 18
 	define('ACL_TYPE_IDENTIFER','***ACL***');
17 19
 }
20
+}
18 21
 
19 22
 define('HOUR_s',60*60);
20 23
 define('DAY_s',24*HOUR_s);
@@ -225,7 +228,10 @@  discard block
 block discarded – undo
225 228
 	 */
226 229
 	function __construct()
227 230
 	{
228
-		if ($this->debug > 0) $this->debug_message('calendar_bo::bocal() started',True);
231
+		if ($this->debug > 0)
232
+		{
233
+			$this->debug_message('calendar_bo::bocal() started',True);
234
+		}
229 235
 
230 236
 		$this->so = new calendar_so();
231 237
 		$this->datetime = $GLOBALS['egw']->datetime;
@@ -308,7 +314,10 @@  discard block
 block discarded – undo
308 314
 	 */
309 315
 	static function email_info($ids)
310 316
 	{
311
-		if (!$ids) return null;
317
+		if (!$ids)
318
+		{
319
+			return null;
320
+		}
312 321
 
313 322
 		$data = array();
314 323
 		foreach((array)$ids as $id)
@@ -382,22 +391,31 @@  discard block
 block discarded – undo
382 391
 			$user = trim($user);
383 392
 			if ($ignore_acl || $this->check_perms(EGW_ACL_READ|EGW_ACL_READ_FOR_PARTICIPANTS|($use_freebusy?EGW_ACL_FREEBUSY:0),0,$user))
384 393
 			{
385
-				if ($user && !in_array($user,$users))	// already added?
394
+				if ($user && !in_array($user,$users))
395
+				{
396
+					// already added?
386 397
 				{
387 398
 					$users[] = $user;
388 399
 				}
400
+				}
389 401
 			}
390 402
 			elseif ($GLOBALS['egw']->accounts->get_type($user) != 'g')
391 403
 			{
392 404
 				continue;	// for non-groups (eg. users), we stop here if we have no read-rights
393 405
 			}
394 406
 			// the further code is only for real users
395
-			if (!is_numeric($user)) continue;
407
+			if (!is_numeric($user))
408
+			{
409
+				continue;
410
+			}
396 411
 
397 412
 			// for groups we have to include the members
398 413
 			if ($GLOBALS['egw']->accounts->get_type($user) == 'g')
399 414
 			{
400
-				if ($no_enum_groups) continue;
415
+				if ($no_enum_groups)
416
+				{
417
+					continue;
418
+				}
401 419
 
402 420
 				$members = $GLOBALS['egw']->accounts->member($user);
403 421
 				if (is_array($members))
@@ -477,11 +495,14 @@  discard block
 block discarded – undo
477 495
 		}
478 496
 
479 497
 		if (!isset($params['users']) || !$params['users'] ||
480
-			count($params['users']) == 1 && isset($params['users'][0]) && !$params['users'][0])	// null or '' casted to an array
498
+			count($params['users']) == 1 && isset($params['users'][0]) && !$params['users'][0])
499
+		{
500
+			// null or '' casted to an array
481 501
 		{
482 502
 			// for a search use all account you have read grants from
483 503
 			$params['users'] = $params['query'] ? array_keys($this->grants) : $this->user;
484 504
 		}
505
+		}
485 506
 		// resolve users to add memberships for users and members for groups
486 507
 		// for search, do NOT use freebusy rights, as it would allow to probe the content of event entries
487 508
 		$users = $this->resolve_users($params['users'], $params['filter'] == 'no-enum-groups', $params['ignore_acl'], empty($params['query']));
@@ -492,7 +513,10 @@  discard block
 block discarded – undo
492 513
 			$params['private_grants'] = array();
493 514
 			foreach($this->grants as $user => $rights)
494 515
 			{
495
-				if ($rights & EGW_ACL_PRIVATE) $params['private_grants'][] = $user;
516
+				if ($rights & EGW_ACL_PRIVATE)
517
+				{
518
+					$params['private_grants'][] = $user;
519
+				}
496 520
 			}
497 521
 		}
498 522
 
@@ -507,7 +531,10 @@  discard block
 block discarded – undo
507 531
 		{
508 532
 			return false;
509 533
 		}
510
-		if (isset($params['start'])) $start = $this->date2ts($params['start']);
534
+		if (isset($params['start']))
535
+		{
536
+			$start = $this->date2ts($params['start']);
537
+		}
511 538
 
512 539
 		if (isset($params['end']))
513 540
 		{
@@ -571,10 +598,13 @@  discard block
 block discarded – undo
571 598
 				$this->debug_message('socalendar::search daywise sorting from %1 to %2 of %3',False,$start,$end,$events);
572 599
 			}
573 600
 			// create empty entries for each day in the reported time
574
-			for($ts = $start; $ts <= $end; $ts += DAY_s) // good enough for array creation, but see while loop below.
601
+			for($ts = $start; $ts <= $end; $ts += DAY_s)
602
+			{
603
+				// good enough for array creation, but see while loop below.
575 604
 			{
576 605
 				$daysEvents[$this->date2string($ts)] = array();
577 606
 			}
607
+			}
578 608
 			foreach($events as $k => $event)
579 609
 			{
580 610
 				$e_start = max($this->date2ts($event['start']),$start);
@@ -626,7 +656,10 @@  discard block
 block discarded – undo
626 656
 			$integration_data = calendar_so::get_integration_data();
627 657
 		}
628 658
 
629
-		if (!isset($integration_data[$app])) return null;
659
+		if (!isset($integration_data[$app]))
660
+		{
661
+			return null;
662
+		}
630 663
 
631 664
 		return $part ? $integration_data[$app][$part] : $integration_data[$app];
632 665
 	}
@@ -673,8 +706,14 @@  discard block
 block discarded – undo
673 706
 	 */
674 707
 	function clear_private_infos(&$event,$allowed_participants = array())
675 708
 	{
676
-		if ($event == false) return;
677
-		if (!is_array($event['participants'])) error_log(__METHOD__.'('.array2string($event).', '.array2string($allowed_participants).') NO PARTICIPANTS '.function_backtrace());
709
+		if ($event == false)
710
+		{
711
+			return;
712
+		}
713
+		if (!is_array($event['participants']))
714
+		{
715
+			error_log(__METHOD__.'('.array2string($event).', '.array2string($allowed_participants).') NO PARTICIPANTS '.function_backtrace());
716
+		}
678 717
 
679 718
 		$event = array(
680 719
 			'id'    => $event['id'],
@@ -719,19 +758,29 @@  discard block
 block discarded – undo
719 758
 		}
720 759
 		$new_horizont = $this->date2ts($_new_horizont,true);	// now we are in server-time, where this function operates
721 760
 
722
-		if ($new_horizont <= $this->config['horizont'])	// no move necessary
761
+		if ($new_horizont <= $this->config['horizont'])
762
+		{
763
+			// no move necessary
723 764
 		{
724 765
 			if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2 is bigger ==> nothing to do',true,$new_horizont,(int)$this->config['horizont']);
766
+		}
725 767
 			return;
726 768
 		}
727 769
 		if (!empty($GLOBALS['egw_info']['server']['calendar_horizont']))
728 770
 		{
729 771
 			$maxdays = abs($GLOBALS['egw_info']['server']['calendar_horizont']);
730 772
 		}
731
-		if (empty($maxdays)) $maxdays = 1000; // old default
732
-		if ($new_horizont > time()+$maxdays*DAY_s)		// some user tries to "look" more then the maximum number of days in the future
773
+		if (empty($maxdays))
774
+		{
775
+			$maxdays = 1000;
776
+		}
777
+		// old default
778
+		if ($new_horizont > time()+$maxdays*DAY_s)
779
+		{
780
+			// some user tries to "look" more then the maximum number of days in the future
733 781
 		{
734 782
 			if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2 new horizont more then %3 days from now --> ignoring it',true,$new_horizont,(int)$this->config['horizont'],$maxdays);
783
+		}
735 784
 			$this->warnings['horizont'] = lang('Requested date %1 outside allowed range of %2 days: recurring events obmitted!', egw_time::to($new_horizont,true), $maxdays);
736 785
 			return;
737 786
 		}
@@ -759,7 +808,10 @@  discard block
 block discarded – undo
759 808
 		// update the horizont
760 809
 		config::save_value('horizont',$this->config['horizont'],'calendar');
761 810
 
762
-		if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) new horizont=%2, exiting',true,$new_horizont,(int)$this->config['horizont']);
811
+		if ($this->debug == 'check_move_horizont')
812
+		{
813
+			$this->debug_message('calendar_bo::check_move_horizont(%1) new horizont=%2, exiting',true,$new_horizont,(int)$this->config['horizont']);
814
+		}
763 815
 	}
764 816
 
765 817
 	/**
@@ -790,7 +842,10 @@  discard block
 block discarded – undo
790 842
 				$event['end'] = $event_read['end'];
791 843
 			}
792 844
 		}
793
-		if (!$start) $start = $event['start'];
845
+		if (!$start)
846
+		{
847
+			$start = $event['start'];
848
+		}
794 849
 
795 850
 		$events = array();
796 851
 		$this->insert_all_recurrences($event,$start,$this->date2usertime($this->config['horizont']),$events);
@@ -831,7 +886,10 @@  discard block
 block discarded – undo
831 886
 	 */
832 887
 	function db2data(&$events,$date_format='ts')
833 888
 	{
834
-		if (!is_array($events)) echo "<p>calendar_bo::db2data(\$events,$date_format) \$events is no array<br />\n".function_backtrace()."</p>\n";
889
+		if (!is_array($events))
890
+		{
891
+			echo "<p>calendar_bo::db2data(\$events,$date_format) \$events is no array<br />\n".function_backtrace()."</p>\n";
892
+		}
835 893
 		foreach ($events as &$event)
836 894
 		{
837 895
 			// convert timezone id of event to tzid (iCal id like 'Europe/Berlin')
@@ -915,7 +973,10 @@  discard block
 block discarded – undo
915 973
 	 */
916 974
 	function date2usertime($ts,$date_format='ts')
917 975
 	{
918
-		if (empty($ts) || $date_format == 'server') return $ts;
976
+		if (empty($ts) || $date_format == 'server')
977
+		{
978
+			return $ts;
979
+		}
919 980
 
920 981
 		return egw_time::server2user($ts,$date_format);
921 982
 	}
@@ -933,9 +994,15 @@  discard block
 block discarded – undo
933 994
 	 */
934 995
 	function read($ids,$date=null,$ignore_acl=False,$date_format='ts',$clear_private_infos_users=null)
935 996
 	{
936
-		if (!$ids) return false;
997
+		if (!$ids)
998
+		{
999
+			return false;
1000
+		}
937 1001
 
938
-		if ($date) $date = $this->date2ts($date);
1002
+		if ($date)
1003
+		{
1004
+			$date = $this->date2ts($date);
1005
+		}
939 1006
 
940 1007
 		$return = null;
941 1008
 
@@ -1100,7 +1167,10 @@  discard block
 block discarded – undo
1100 1167
 	{
1101 1168
 		static $res_info_cache = array();
1102 1169
 
1103
-		if (!is_scalar($uid)) throw new egw_exception_wrong_parameter(__METHOD__.'('.array2string($uid).') parameter must be scalar');
1170
+		if (!is_scalar($uid))
1171
+		{
1172
+			throw new egw_exception_wrong_parameter(__METHOD__.'('.array2string($uid).') parameter must be scalar');
1173
+		}
1104 1174
 
1105 1175
 		if (!isset($res_info_cache[$uid]))
1106 1176
 		{
@@ -1155,7 +1225,10 @@  discard block
 block discarded – undo
1155 1225
 	 */
1156 1226
 	function check_perms($needed,$event=0,$other=0,$date_format='ts',$date_to_read=null,$user=null)
1157 1227
 	{
1158
-		if (!$user) $user = $this->user;
1228
+		if (!$user)
1229
+		{
1230
+			$user = $this->user;
1231
+		}
1159 1232
 		if ($user == $this->user)
1160 1233
 		{
1161 1234
 			$grants = $this->grants;
@@ -1194,7 +1267,10 @@  discard block
 block discarded – undo
1194 1267
 		$grant = $grants[$owner];
1195 1268
 
1196 1269
 		// now any ACL rights (but invite rights!) implicate FREEBUSY rights (at least READ has to include FREEBUSY)
1197
-		if ($grant & ~EGW_ACL_INVITE) $grant |= EGW_ACL_FREEBUSY;
1270
+		if ($grant & ~EGW_ACL_INVITE)
1271
+		{
1272
+			$grant |= EGW_ACL_FREEBUSY;
1273
+		}
1198 1274
 
1199 1275
 		if (is_array($event) && ($needed == EGW_ACL_READ || $needed == EGW_ACL_FREEBUSY))
1200 1276
 		{
@@ -1220,7 +1296,10 @@  discard block
 block discarded – undo
1220 1296
 					elseif (!is_numeric($uid))
1221 1297
 					{
1222 1298
 						// if the owner only grants EGW_ACL_FREEBUSY we are not interested in the recources explicit rights
1223
-						if ($grant == EGW_ACL_FREEBUSY) continue;
1299
+						if ($grant == EGW_ACL_FREEBUSY)
1300
+						{
1301
+							continue;
1302
+						}
1224 1303
 						// if we have a resource as participant
1225 1304
 						$resource = $this->resource_info($uid);
1226 1305
 						$grant |= $resource['rights'];
@@ -1370,14 +1449,20 @@  discard block
 block discarded – undo
1370 1449
 						$param = $param ? 'True' : 'False';
1371 1450
 						break;
1372 1451
 					case 'integer':
1373
-						if ($param >= mktime(0,0,0,1,1,2000)) $param = adodb_date('Y-m-d H:i:s',$param)." ($param)";
1452
+						if ($param >= mktime(0,0,0,1,1,2000))
1453
+						{
1454
+							$param = adodb_date('Y-m-d H:i:s',$param)." ($param)";
1455
+						}
1374 1456
 						break;
1375 1457
 				}
1376 1458
 			}
1377 1459
 			$msg = str_replace('%'.($i-1),$param,$msg);
1378 1460
 		}
1379 1461
 		error_log($msg);
1380
-		if ($backtrace) error_log(function_backtrace(1));
1462
+		if ($backtrace)
1463
+		{
1464
+			error_log(function_backtrace(1));
1465
+		}
1381 1466
 	}
1382 1467
 
1383 1468
 	/**
@@ -1485,14 +1570,20 @@  discard block
 block discarded – undo
1485 1570
 	function timespan($start_m,$end_m,$both=false)
1486 1571
 	{
1487 1572
 		$duration = $end_m - $start_m;
1488
-		if ($end_m == 24*60-1) ++$duration;
1573
+		if ($end_m == 24*60-1)
1574
+		{
1575
+			++$duration;
1576
+		}
1489 1577
 		$duration = floor($duration/60).lang('h').($duration%60 ? $duration%60 : '');
1490 1578
 
1491 1579
 		$timespan = $t = common::formattime(sprintf('%02d',$start_m/60),sprintf('%02d',$start_m%60));
1492 1580
 
1493
-		if ($both)	// end-time too
1581
+		if ($both)
1582
+		{
1583
+			// end-time too
1494 1584
 		{
1495 1585
 			$timespan .= ' - '.common::formattime(sprintf('%02d',$end_m/60),sprintf('%02d',$end_m%60));
1586
+		}
1496 1587
 			// dont double am/pm if they are the same in both times
1497 1588
 			if ($this->common_prefs['timeformat'] == 12 && substr($timespan,-2) == substr($t,-2))
1498 1589
 			{
@@ -1516,8 +1607,14 @@  discard block
 block discarded – undo
1516 1607
 		static $id2lid = array();
1517 1608
 		static $id2email = array();
1518 1609
 
1519
-		if ($use_type && $use_type != 'u') $id = $use_type.$id;
1520
-		if($id === 0 || $id === '0') $id = $this->user;
1610
+		if ($use_type && $use_type != 'u')
1611
+		{
1612
+			$id = $use_type.$id;
1613
+		}
1614
+		if($id === 0 || $id === '0')
1615
+		{
1616
+			$id = $this->user;
1617
+		}
1521 1618
 
1522 1619
 		if (!isset($id2lid[$id]))
1523 1620
 		{
@@ -1527,7 +1624,10 @@  discard block
 block discarded – undo
1527 1624
 				if (($info = $this->resource_info($id)))
1528 1625
 				{
1529 1626
 					$id2lid[$id] = $info['name'] ? $info['name'] : $info['email'];
1530
-					if ($info['name']) $id2email[$id] = $info['email'];
1627
+					if ($info['name'])
1628
+					{
1629
+						$id2email[$id] = $info['email'];
1630
+					}
1531 1631
 				}
1532 1632
 			}
1533 1633
 			else
@@ -1553,11 +1653,18 @@  discard block
 block discarded – undo
1553 1653
 		$names = array();
1554 1654
 		foreach((array)$event['participants'] as $id => $status)
1555 1655
 		{
1556
-			if (!is_string($status)) continue;
1656
+			if (!is_string($status))
1657
+			{
1658
+				continue;
1659
+			}
1557 1660
 			$quantity = $role = null;
1558 1661
 			calendar_so::split_status($status,$quantity,$role);
1559 1662
 
1560
-			if ($status == 'G' && !$show_group_invitation) continue;	// dont show group-invitation
1663
+			if ($status == 'G' && !$show_group_invitation)
1664
+			{
1665
+				continue;
1666
+			}
1667
+			// dont show group-invitation
1561 1668
 
1562 1669
 			$lang_status = lang($this->verbose_status[$status]);
1563 1670
 			if (!$long_status)
@@ -1630,7 +1737,10 @@  discard block
 block discarded – undo
1630 1737
 
1631 1738
 		foreach(explode(',',$category) as $cat_id)
1632 1739
 		{
1633
-			if (!$cat_id) continue;
1740
+			if (!$cat_id)
1741
+			{
1742
+				continue;
1743
+			}
1634 1744
 
1635 1745
 			if (!isset($id2cat[$cat_id]))
1636 1746
 			{
@@ -1696,7 +1806,10 @@  discard block
 block discarded – undo
1696 1806
 	 */
1697 1807
 	public static function list_calendars($user, array $grants=null)
1698 1808
 	{
1699
-		if (is_null($grants)) $grants = $GLOBALS['egw']->acl->get_grants('calendar', true, $user);
1809
+		if (is_null($grants))
1810
+		{
1811
+			$grants = $GLOBALS['egw']->acl->get_grants('calendar', true, $user);
1812
+		}
1700 1813
 
1701 1814
 		$users = $groups = array();
1702 1815
 		foreach(array_keys($grants) as $id)
@@ -1744,7 +1857,10 @@  discard block
 block discarded – undo
1744 1857
 	 */
1745 1858
 	function recure2string($event)
1746 1859
 	{
1747
-		if (!is_array($event)) return false;
1860
+		if (!is_array($event))
1861
+		{
1862
+			return false;
1863
+		}
1748 1864
 		return (string)calendar_rrule::event2rrule($event);
1749 1865
 	}
1750 1866
 
@@ -1766,12 +1882,18 @@  discard block
 block discarded – undo
1766 1882
 	 */
1767 1883
 	function read_holidays($year=0)
1768 1884
 	{
1769
-		if (!$year) $year = (int) date('Y',$this->now_su);
1885
+		if (!$year)
1886
+		{
1887
+			$year = (int) date('Y',$this->now_su);
1888
+		}
1770 1889
 
1771
-		if (!$this->cached_holidays)	// try reading the holidays from the session
1890
+		if (!$this->cached_holidays)
1891
+		{
1892
+			// try reading the holidays from the session
1772 1893
 		{
1773 1894
 			$this->cached_holidays = $GLOBALS['egw']->session->appsession('holidays','calendar');
1774 1895
 		}
1896
+		}
1775 1897
 		if (!isset($this->cached_holidays[$year]))
1776 1898
 		{
1777 1899
 			if (!is_object($this->holidays))
@@ -1811,7 +1933,11 @@  discard block
 block discarded – undo
1811 1933
 							continue;
1812 1934
 						}
1813 1935
 						list($y,$m,$d) = explode('-',$pers['bday']);
1814
-						if ($y > $year) continue; 	// not yet born
1936
+						if ($y > $year)
1937
+						{
1938
+							continue;
1939
+						}
1940
+						// not yet born
1815 1941
 						$this->cached_holidays[$year][sprintf('%04d%02d%02d',$year,$m,$d)][] = array(
1816 1942
 							'day'       => $d,
1817 1943
 							'month'     => $m,
@@ -1904,7 +2030,10 @@  discard block
 block discarded – undo
1904 2030
 				}
1905 2031
 			}
1906 2032
 			$str_fields = implode(', ',$extra_fields);
1907
-			if (is_array($extra_fields)) return $this->format_date($event['start']) . ': ' . $event['title'] . ($str_fields? ', ' . $str_fields:'');
2033
+			if (is_array($extra_fields))
2034
+			{
2035
+				return $this->format_date($event['start']) . ': ' . $event['title'] . ($str_fields? ', ' . $str_fields:'');
2036
+			}
1908 2037
 		}
1909 2038
 		return $this->format_date($event['start']) . ': ' . $event['title'];
1910 2039
 	}
@@ -1925,7 +2054,8 @@  discard block
 block discarded – undo
1925 2054
 			'offset' =>	$options['start'],
1926 2055
 			'order' => 'cal_start DESC',
1927 2056
 		);
1928
-		if($options['num_rows']) {
2057
+		if($options['num_rows'])
2058
+		{
1929 2059
 			$query['num_rows'] = $options['num_rows'];
1930 2060
 		}
1931 2061
 		foreach((array) $this->search($query) as $event)
@@ -1991,7 +2121,10 @@  discard block
 block discarded – undo
1991 2121
 			if ((!isset($default_prefs[$var]) || (string)$default_prefs[$var] === '') && (!isset($forced_prefs[$var]) || (string)$forced_prefs[$var] === ''))
1992 2122
 			{
1993 2123
 				$GLOBALS['egw']->preferences->add('calendar',$var,$default,'default');	// always store default, even if we have a forced too
1994
-				if ($type == 'forced') $GLOBALS['egw']->preferences->add('calendar',$var,$default,'forced');
2124
+				if ($type == 'forced')
2125
+				{
2126
+					$GLOBALS['egw']->preferences->add('calendar',$var,$default,'forced');
2127
+				}
1995 2128
 				$this->cal_prefs[$var] = $default;
1996 2129
 				$need_save = True;
1997 2130
 			}
@@ -2011,7 +2144,10 @@  discard block
 block discarded – undo
2011 2144
 	 */
2012 2145
 	static function freebusy_url($user='',$pw=null)
2013 2146
 	{
2014
-		if (is_numeric($user)) $user = $GLOBALS['egw']->accounts->id2name($user);
2147
+		if (is_numeric($user))
2148
+		{
2149
+			$user = $GLOBALS['egw']->accounts->id2name($user);
2150
+		}
2015 2151
 
2016 2152
 		$credentials = '';
2017 2153
 
@@ -2079,13 +2215,19 @@  discard block
 block discarded – undo
2079 2215
 	 */
2080 2216
 	public function get_ctag($user, $filter='owner', $master_only=false)
2081 2217
 	{
2082
-		if ($this->debug > 1) $startime = microtime(true);
2218
+		if ($this->debug > 1)
2219
+		{
2220
+			$startime = microtime(true);
2221
+		}
2083 2222
 
2084 2223
 		// resolve users to add memberships for users and members for groups
2085 2224
 		$users = $this->resolve_users($user);
2086 2225
 		$ctag = $users ? $this->so->get_ctag($users, $filter == 'owner', $master_only) : 0;	// no rights, return 0 as ctag (otherwise we get SQL error!)
2087 2226
 
2088
-		if ($this->debug > 1) error_log(__METHOD__. "($user, '$filter') = $ctag = ".date('Y-m-d H:i:s',$ctag)." took ".(microtime(true)-$startime)." secs");
2227
+		if ($this->debug > 1)
2228
+		{
2229
+			error_log(__METHOD__. "($user, '$filter') = $ctag = ".date('Y-m-d H:i:s',$ctag)." took ".(microtime(true)-$startime)." secs");
2230
+		}
2089 2231
 		return $ctag;
2090 2232
 	}
2091 2233
 
@@ -2127,15 +2269,21 @@  discard block
 block discarded – undo
2127 2269
 				$content['link_app'][] = $link['app'];
2128 2270
 				$content['link_id'][]  = $link['id'];
2129 2271
 			}
2130
-			if ($link['app'] == 'addressbook')	// prefering contact as primary contact over calendar entry set above
2272
+			if ($link['app'] == 'addressbook')
2273
+			{
2274
+				// prefering contact as primary contact over calendar entry set above
2131 2275
 			{
2132 2276
 				$content['info_contact'] = 'addressbook:'.$link['id'];
2133 2277
 			}
2278
+			}
2134 2279
 		}
2135 2280
 		// Copy same custom fields
2136 2281
 		foreach(array_keys(config::get_customfields('infolog')) as $name)
2137 2282
 		{
2138
-			if ($this->customfields[$name]) $content['#'.$name] = $calendar['#'.$name];
2283
+			if ($this->customfields[$name])
2284
+			{
2285
+				$content['#'.$name] = $calendar['#'.$name];
2286
+			}
2139 2287
 		}
2140 2288
 		//error_log(__METHOD__.'('.array2string($data).') calendar='.array2string($calendar).' returning '.array2string($content));
2141 2289
 		return $content;
@@ -2158,7 +2306,11 @@  discard block
 block discarded – undo
2158 2306
 			$set['ts_title'] = $this->link_title($event);
2159 2307
 			$set['start_time'] = egw_time::to($event['start'],'H:i');
2160 2308
 			$set['ts_description'] = $event['description'];
2161
-			if ($this->isWholeDay($event)) $event['end']++;	// whole day events are 1sec short
2309
+			if ($this->isWholeDay($event))
2310
+			{
2311
+				$event['end']++;
2312
+			}
2313
+			// whole day events are 1sec short
2162 2314
 			$set['ts_duration']	= ($event['end'] - $event['start']) / 60;
2163 2315
 			$set['ts_quantity'] = ($event['end'] - $event['start']) / 3600;
2164 2316
 			$set['end_time'] = null;	// unset end-time
Please login to merge, or discard this patch.
calendar/inc/class.calendar_wizard_import_csv.inc.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 		// List each custom field
34 34
 		unset($this->mapping_fields['customfields']);
35 35
 		$custom = Api\Storage\Customfields::get('calendar');
36
-		foreach($custom as $name => $data) {
36
+		foreach ($custom as $name => $data) {
37 37
 			$this->mapping_fields['#'.$name] = $data['label'];
38 38
 		}
39 39
 
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 	function wizard_step50(&$content, &$sel_options, &$readonlys, &$preserv)
54 54
 	{
55 55
 		$result = parent::wizard_step50($content, $sel_options, $readonlys, $preserv);
56
-		$content['msg'] .= "\n*" ;
56
+		$content['msg'] .= "\n*";
57 57
 
58 58
 		return $result;
59 59
 	}
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -47,7 +47,8 @@
 block discarded – undo
47 47
                 );
48 48
 
49 49
 		$custom = Api\Storage\Customfields::get('resources', true);
50
-		foreach($custom as $name => $data) {
50
+		foreach($custom as $name => $data)
51
+		{
51 52
 			$this->mapping_fields['#'.$name] = $data['label'];
52 53
 		}
53 54
 
Please login to merge, or discard this patch.
calendar/inc/class.calendar_export_csv.inc.php 5 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -323,17 +323,17 @@
 block discarded – undo
323 323
 		$days = $states['days'];
324 324
 		$ui = new calendar_uiviews($states);
325 325
 		if (!$days)
326
-                {
327
-                        $days = isset($_GET['days']) ? $_GET['days'] : $ui->cal_prefs['days_in_weekview'];
328
-                        if ($days != 5) $days = 7;
329
-                }
326
+				{
327
+						$days = isset($_GET['days']) ? $_GET['days'] : $ui->cal_prefs['days_in_weekview'];
328
+						if ($days != 5) $days = 7;
329
+				}
330 330
 		if ($states['view'] == 'week' && $days == 4)         // next 4 days view
331
-                {
332
-                        $query['start'] = $this->bo->date2ts($states['date']);
333
-                        $query['end'] = strtotime("+$days days",$query['start']) - 1;
334
-                }
335
-                else
336
-                {
331
+				{
332
+						$query['start'] = $this->bo->date2ts($states['date']);
333
+						$query['end'] = strtotime("+$days days",$query['start']) - 1;
334
+				}
335
+				else
336
+				{
337 337
 			$query['start'] = $ui->datetime->get_weekday_start($states['year'],$states['month'],$states['day']);
338 338
 			if ($days == 5)         // no weekend-days
339 339
 			{
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@
 block discarded – undo
29 29
 	/**
30 30
 	 * Exports records as defined in $_definition
31 31
 	 *
32
-	 * @param egw_record $_definition
32
+	 * @param importexport_definition $_definition
33 33
 	 */
34 34
 	public function export( $_stream, importexport_definition $_definition) {
35 35
 		$options = $_definition->plugin_options;
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
 	 */
367 367
 	protected function get_selects()
368 368
 	{
369
-		$this->selects['priority'] = Array(
369
+		$this->selects['priority'] = array(
370 370
 			0 => lang('None'),
371 371
 			1 => lang('Low'),
372 372
 			2 => lang('Normal'),
@@ -394,7 +394,7 @@  discard block
 block discarded – undo
394 394
 	/**
395 395
 	 * Adjust automatically generated field filters
396 396
 	 */
397
-	public function get_filter_fields(Array &$filters)
397
+	public function get_filter_fields(array &$filters)
398 398
 	{
399 399
 
400 400
 		// Calendar SO doesn't support filtering by column, so we have to remove pretty much everything
Please login to merge, or discard this patch.
Braces   +97 added lines, -36 removed lines patch added patch discarded remove patch
@@ -14,9 +14,11 @@  discard block
 block discarded – undo
14 14
 /**
15 15
  * export CSV plugin of calendar
16 16
  */
17
-class calendar_export_csv implements importexport_iface_export_plugin {
17
+class calendar_export_csv implements importexport_iface_export_plugin
18
+{
18 19
 
19
-	public function __construct() {
20
+	public function __construct()
21
+	{
20 22
 		translation::add_app('calendar');
21 23
 		$this->bo = new calendar_bo();
22 24
 		$this->get_selects();
@@ -27,15 +29,23 @@  discard block
 block discarded – undo
27 29
 	 *
28 30
 	 * @param egw_record $_definition
29 31
 	 */
30
-	public function export( $_stream, importexport_definition $_definition) {
32
+	public function export( $_stream, importexport_definition $_definition)
33
+	{
31 34
 		$options = $_definition->plugin_options;
32 35
 
33 36
 		$limit_exception = bo_merge::is_export_limit_excepted();
34
-		if (!$limit_exception) $export_limit = bo_merge::getExportLimit('calendar');
37
+		if (!$limit_exception)
38
+		{
39
+			$export_limit = bo_merge::getExportLimit('calendar');
40
+		}
35 41
 		// Custom fields need to be specifically requested
36 42
 		$cfs = array();
37
-		foreach($options['mapping'] + (array)$_definition->filter as $key => $label) {
38
-			if($key[0] == '#') $cfs[] = substr($key,1);
43
+		foreach($options['mapping'] + (array)$_definition->filter as $key => $label)
44
+		{
45
+			if($key[0] == '#')
46
+			{
47
+				$cfs[] = substr($key,1);
48
+			}
39 49
 		}
40 50
 
41 51
 		$query = array(
@@ -55,7 +65,8 @@  discard block
 block discarded – undo
55 65
 					'users'         => $options['criteria']['owner'],
56 66
 					'cfs'		=> $cfs // Otherwise we shouldn't get any custom fields
57 67
 				);
58
-				if(bo_merge::hasExportLimit($export_limit) && !$limit_exception) {
68
+				if(bo_merge::hasExportLimit($export_limit) && !$limit_exception)
69
+				{
59 70
 					$query['offset'] = 0;
60 71
 					$query['num_rows'] = (int)$export_limit; // ! int of 'no' is 0
61 72
 				}
@@ -63,28 +74,34 @@  discard block
 block discarded – undo
63 74
 				break;
64 75
 			case 'search_results':
65 76
 				$states = $GLOBALS['egw']->session->appsession('session_data','calendar');
66
-				if($states['view'] == 'listview') {
77
+				if($states['view'] == 'listview')
78
+				{
67 79
 					$query = $GLOBALS['egw']->session->appsession('calendar_list','calendar');
68 80
 					$query['num_rows'] = -1;        // all
69 81
 					$query['csv_export'] = true;	// so get_rows method _can_ produce different content or not store state in the session
70 82
 					$query['start'] = 0;
71 83
 					$query['cfs'] = $cfs;
72 84
 
73
-					if(bo_merge::hasExportLimit($export_limit) && !$limit_exception) {
85
+					if(bo_merge::hasExportLimit($export_limit) && !$limit_exception)
86
+					{
74 87
 						$query['num_rows'] = (int)$export_limit; // ! int of 'no' is 0
75 88
 					}
76 89
 					$ui = new calendar_uilist();
77 90
 					$ui->get_rows($query, $events, $unused);
78
-				} else {
91
+				}
92
+				else
93
+				{
79 94
 					$query = $GLOBALS['egw']->session->appsession('session_data','calendar');
80 95
 					$query['users'] = explode(',', $query['owner']);
81 96
 					$query['num_rows'] = -1;
82
-					if(bo_merge::hasExportLimit($export_limit) && !$limit_exception) {
97
+					if(bo_merge::hasExportLimit($export_limit) && !$limit_exception)
98
+					{
83 99
 						$query['num_rows'] = (int)$export_limit;  // ! int of 'no' is 0
84 100
 					}
85 101
 
86 102
 					$events = array();
87
-					switch($states['view']) {
103
+					switch($states['view'])
104
+					{
88 105
 						case 'month':
89 106
 							$query += $this->get_query_month($states);
90 107
 							break;
@@ -136,8 +153,14 @@  discard block
 block discarded – undo
136 153
 					}
137 154
 
138 155
 					// Ranges are inclusive, so should be provided that way (from 2 to 10 includes 2 and 10)
139
-					if($value['from']) $query['sql_filter'][] = "cal_$field >= " . (int)$value['from'];
140
-					if($value['to']) $query['sql_filter'][] = "cal_$field <= " . (int)$value['to'];
156
+					if($value['from'])
157
+					{
158
+						$query['sql_filter'][] = "cal_$field >= " . (int)$value['from'];
159
+					}
160
+					if($value['to'])
161
+					{
162
+						$query['sql_filter'][] = "cal_$field <= " . (int)$value['to'];
163
+					}
141 164
 
142 165
 				}
143 166
 				if($query['sql_filter'] && is_array($query['sql_filter']))
@@ -155,36 +178,52 @@  discard block
 block discarded – undo
155 178
 		}
156 179
 
157 180
 		$export_object = new importexport_export_csv($_stream, (array)$options);
158
-		if (!$limit_exception) $export_object->export_limit = $export_limit;
181
+		if (!$limit_exception)
182
+		{
183
+			$export_object->export_limit = $export_limit;
184
+		}
159 185
 		$export_object->set_mapping($options['mapping']);
160 186
 		$convert_fields = calendar_egw_record::$types;
161 187
 
162 188
 		$recurrence = $this->bo->recur_types;
163 189
 
164 190
 		$record = new calendar_egw_record();
165
-		foreach ($events as $event) {
191
+		foreach ($events as $event)
192
+		{
166 193
 			// the condition below (2 lines) may only work on enum_recuring=false and using the iterator to test an recurring event on the given timerange
167 194
 			// Get rid of yearly recurring events that don't belong
168 195
 			//if($options['selection']['select'] == 'criteria' && ($event['start'] > $query['end'] || $event['end'] < $query['start'])) continue;
169 196
 			// Add in participants
170
-			if($options['mapping']['participants']) {
197
+			if($options['mapping']['participants'])
198
+			{
171 199
 				$event['participants'] = implode(", ",$this->bo->participants($event,true));
172 200
 			}
173 201
 			if (is_array($event))
174 202
 			{
175 203
 				$record->set_record($event);
176
-				if($options['mapping']['recurrence']) {
204
+				if($options['mapping']['recurrence'])
205
+				{
177 206
 					$record->recurrence = $recurrence[$record->recur_type];
178
-					if($record->recur_type != MCAL_RECUR_NONE) $record->recurrence .= ' / '. $record->recur_interval;
207
+					if($record->recur_type != MCAL_RECUR_NONE)
208
+					{
209
+						$record->recurrence .= ' / '. $record->recur_interval;
210
+					}
179 211
 				}
180 212
 
181 213
 				// Standard stuff
182
-				if($options['convert']) {
214
+				if($options['convert'])
215
+				{
183 216
 					importexport_export_csv::convert($record, $convert_fields, 'calendar', $this->selects);
184
-				} else {
217
+				}
218
+				else
219
+				{
185 220
 					// Implode arrays, so they don't say 'Array'
186
-					foreach($record->get_record_array() as $key => $value) {
187
-						if(is_array($value)) $record->$key = implode(',', $value);
221
+					foreach($record->get_record_array() as $key => $value)
222
+					{
223
+						if(is_array($value))
224
+						{
225
+							$record->$key = implode(',', $value);
226
+						}
188 227
 					}
189 228
 	 			}
190 229
 				$export_object->export_record($record);
@@ -199,7 +238,8 @@  discard block
 block discarded – undo
199 238
 	 *
200 239
 	 * @return string name
201 240
 	 */
202
-	public static function get_name() {
241
+	public static function get_name()
242
+	{
203 243
 		return lang('Calendar CSV export');
204 244
 	}
205 245
 
@@ -208,7 +248,8 @@  discard block
 block discarded – undo
208 248
 	 *
209 249
 	 * @return string descriprion
210 250
 	 */
211
-	public static function get_description() {
251
+	public static function get_description()
252
+	{
212 253
 		return lang("Exports events from your Calendar into a CSV File.");
213 254
 	}
214 255
 
@@ -217,11 +258,13 @@  discard block
 block discarded – undo
217 258
 	 *
218 259
 	 * @return string suffix
219 260
 	 */
220
-	public static function get_filesuffix() {
261
+	public static function get_filesuffix()
262
+	{
221 263
 		return 'csv';
222 264
 	}
223 265
 
224
-	public static function get_mimetype() {
266
+	public static function get_mimetype()
267
+	{
225 268
 		return 'text/csv';
226 269
 	}
227 270
 
@@ -229,16 +272,19 @@  discard block
 block discarded – undo
229 272
 	 * return html for options.
230 273
 	 *
231 274
 	 */
232
-	public function get_options_etpl($definition = null) {
275
+	public function get_options_etpl($definition = null)
276
+	{
233 277
 	}
234 278
 
235 279
 	/**
236 280
 	 * returns selectors of this plugin
237 281
 	 *
238 282
 	 */
239
-	public function get_selectors_etpl($definition = null) {
283
+	public function get_selectors_etpl($definition = null)
284
+	{
240 285
 		$states = $GLOBALS['egw']->session->appsession('session_data','calendar');
241
-		switch($states['view']) {
286
+		switch($states['view'])
287
+		{
242 288
 			case 'month':
243 289
 				$query = $this->get_query_month($states);
244 290
 				break;
@@ -264,7 +310,10 @@  discard block
 block discarded – undo
264 310
 			$end = $ui->last;
265 311
 
266 312
 			// Special handling
267
-			if($list['filter'] == 'all') $start = $end = null;
313
+			if($list['filter'] == 'all')
314
+			{
315
+				$start = $end = null;
316
+			}
268 317
 			if($list['filter'] == 'before')
269 318
 			{
270 319
 				$end = $start;
@@ -312,24 +361,33 @@  discard block
 block discarded – undo
312 361
 		$days = $states['days'];
313 362
 		$ui = new calendar_uiviews($states);
314 363
 		if (!$days)
315
-                {
364
+		{
316 365
                         $days = isset($_GET['days']) ? $_GET['days'] : $ui->cal_prefs['days_in_weekview'];
317
-                        if ($days != 5) $days = 7;
366
+                        if ($days != 5)
367
+                        {
368
+                        	$days = 7;
369
+                        }
318 370
                 }
319
-		if ($states['view'] == 'week' && $days == 4)         // next 4 days view
371
+		if ($states['view'] == 'week' && $days == 4)
372
+		{
373
+			// next 4 days view
320 374
                 {
321 375
                         $query['start'] = $this->bo->date2ts($states['date']);
376
+		}
322 377
                         $query['end'] = strtotime("+$days days",$query['start']) - 1;
323 378
                 }
324 379
                 else
325 380
                 {
326 381
 			$query['start'] = $ui->datetime->get_weekday_start($states['year'],$states['month'],$states['day']);
327
-			if ($days == 5)         // no weekend-days
382
+			if ($days == 5)
383
+			{
384
+				// no weekend-days
328 385
 			{
329 386
 				switch($ui->cal_prefs['weekdaystarts'])
330 387
 				{
331 388
 					case 'Saturday':
332 389
 						$query['start'] = strtotime("+2 days",$query['start']);
390
+			}
333 391
 						break;
334 392
 					case 'Sunday':
335 393
 						$query['start'] = strtotime("+1 day",$query['start']);
@@ -405,7 +463,10 @@  discard block
 block discarded – undo
405 463
 			}
406 464
 
407 465
 			// Pass on select options
408
-			if($this->selects[$field_name]) $settings['values'] = $this->selects[$field_name];
466
+			if($this->selects[$field_name])
467
+			{
468
+				$settings['values'] = $this->selects[$field_name];
469
+			}
409 470
 		}
410 471
 
411 472
 	}
Please login to merge, or discard this patch.
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -27,15 +27,15 @@  discard block
 block discarded – undo
27 27
 	 *
28 28
 	 * @param egw_record $_definition
29 29
 	 */
30
-	public function export( $_stream, importexport_definition $_definition) {
30
+	public function export($_stream, importexport_definition $_definition) {
31 31
 		$options = $_definition->plugin_options;
32 32
 
33 33
 		$limit_exception = bo_merge::is_export_limit_excepted();
34 34
 		if (!$limit_exception) $export_limit = bo_merge::getExportLimit('calendar');
35 35
 		// Custom fields need to be specifically requested
36 36
 		$cfs = array();
37
-		foreach($options['mapping'] + (array)$_definition->filter as $key => $label) {
38
-			if($key[0] == '#') $cfs[] = substr($key,1);
37
+		foreach ($options['mapping'] + (array)$_definition->filter as $key => $label) {
38
+			if ($key[0] == '#') $cfs[] = substr($key, 1);
39 39
 		}
40 40
 
41 41
 		$query = array(
@@ -43,48 +43,48 @@  discard block
 block discarded – undo
43 43
 			'num_rows'	=> -1,
44 44
 			'csv_export'	=> true
45 45
 		);
46
-		switch($options['selection'])
46
+		switch ($options['selection'])
47 47
 		{
48 48
 			case 'criteria':
49 49
 				$query = array(
50 50
 					'start' => $options['criteria']['start'],
51
-					'end'   => strtotime('+1 day',$options['criteria']['end'])-1,
51
+					'end'   => strtotime('+1 day', $options['criteria']['end']) - 1,
52 52
 					'categories'	=> $options['categories'] ? $options['categories'] : $options['criteria']['categories'],
53 53
 					//'enum_recuring' => false, // we want the recurring events enumerated for csv export
54 54
 					'daywise'       => false,
55 55
 					'users'         => $options['criteria']['owner'],
56 56
 					'cfs'		=> $cfs // Otherwise we shouldn't get any custom fields
57 57
 				);
58
-				if(bo_merge::hasExportLimit($export_limit) && !$limit_exception) {
58
+				if (bo_merge::hasExportLimit($export_limit) && !$limit_exception) {
59 59
 					$query['offset'] = 0;
60 60
 					$query['num_rows'] = (int)$export_limit; // ! int of 'no' is 0
61 61
 				}
62
-				$events =& $this->bo->search($query);
62
+				$events = & $this->bo->search($query);
63 63
 				break;
64 64
 			case 'search_results':
65
-				$states = $GLOBALS['egw']->session->appsession('session_data','calendar');
66
-				if($states['view'] == 'listview') {
67
-					$query = $GLOBALS['egw']->session->appsession('calendar_list','calendar');
68
-					$query['num_rows'] = -1;        // all
69
-					$query['csv_export'] = true;	// so get_rows method _can_ produce different content or not store state in the session
65
+				$states = $GLOBALS['egw']->session->appsession('session_data', 'calendar');
66
+				if ($states['view'] == 'listview') {
67
+					$query = $GLOBALS['egw']->session->appsession('calendar_list', 'calendar');
68
+					$query['num_rows'] = -1; // all
69
+					$query['csv_export'] = true; // so get_rows method _can_ produce different content or not store state in the session
70 70
 					$query['start'] = 0;
71 71
 					$query['cfs'] = $cfs;
72 72
 
73
-					if(bo_merge::hasExportLimit($export_limit) && !$limit_exception) {
73
+					if (bo_merge::hasExportLimit($export_limit) && !$limit_exception) {
74 74
 						$query['num_rows'] = (int)$export_limit; // ! int of 'no' is 0
75 75
 					}
76 76
 					$ui = new calendar_uilist();
77 77
 					$ui->get_rows($query, $events, $unused);
78 78
 				} else {
79
-					$query = $GLOBALS['egw']->session->appsession('session_data','calendar');
79
+					$query = $GLOBALS['egw']->session->appsession('session_data', 'calendar');
80 80
 					$query['users'] = explode(',', $query['owner']);
81 81
 					$query['num_rows'] = -1;
82
-					if(bo_merge::hasExportLimit($export_limit) && !$limit_exception) {
83
-						$query['num_rows'] = (int)$export_limit;  // ! int of 'no' is 0
82
+					if (bo_merge::hasExportLimit($export_limit) && !$limit_exception) {
83
+						$query['num_rows'] = (int)$export_limit; // ! int of 'no' is 0
84 84
 					}
85 85
 
86 86
 					$events = array();
87
-					switch($states['view']) {
87
+					switch ($states['view']) {
88 88
 						case 'month':
89 89
 							$query += $this->get_query_month($states);
90 90
 							break;
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 						default:
99 99
 							// Let UI set the date ranges
100 100
 							$ui = new calendar_uiviews($query);
101
-							if(method_exists($ui, $states['view']))
101
+							if (method_exists($ui, $states['view']))
102 102
 							{
103 103
 								ob_start();
104 104
 								$ui->$states['view']();
@@ -122,35 +122,35 @@  discard block
 block discarded – undo
122 122
 				$filter = $_definition->filter;
123 123
 
124 124
 				// Handle ranges
125
-				foreach($filter as $field => $value)
125
+				foreach ($filter as $field => $value)
126 126
 				{
127
-					if($field == 'filter' && $value)
127
+					if ($field == 'filter' && $value)
128 128
 					{
129 129
 						$query['filter'] = $value;
130 130
 						continue;
131 131
 					}
132
-					if(!is_array($value) || (!$value['from'] && !$value['to']))
132
+					if (!is_array($value) || (!$value['from'] && !$value['to']))
133 133
 					{
134 134
 						$query['query']["cal_$field"] = $value;
135 135
 						continue;
136 136
 					}
137 137
 
138 138
 					// Ranges are inclusive, so should be provided that way (from 2 to 10 includes 2 and 10)
139
-					if($value['from']) $query['sql_filter'][] = "cal_$field >= " . (int)$value['from'];
140
-					if($value['to']) $query['sql_filter'][] = "cal_$field <= " . (int)$value['to'];
139
+					if ($value['from']) $query['sql_filter'][] = "cal_$field >= ".(int)$value['from'];
140
+					if ($value['to']) $query['sql_filter'][] = "cal_$field <= ".(int)$value['to'];
141 141
 
142 142
 				}
143
-				if($query['sql_filter'] && is_array($query['sql_filter']))
143
+				if ($query['sql_filter'] && is_array($query['sql_filter']))
144 144
 				{
145 145
 					// Set as an extra parameter
146
-					$sql_filter = implode(' AND ',$query['sql_filter']);
146
+					$sql_filter = implode(' AND ', $query['sql_filter']);
147 147
 				}
148 148
 
149 149
 			case 'all':
150 150
 				$events = $this->bo->search($query + array(
151 151
 					'offset' => 0,
152 152
 					'order' => 'cal_start',
153
-				),$sql_filter);
153
+				), $sql_filter);
154 154
 				break;
155 155
 		}
156 156
 
@@ -167,24 +167,24 @@  discard block
 block discarded – undo
167 167
 			// Get rid of yearly recurring events that don't belong
168 168
 			//if($options['selection']['select'] == 'criteria' && ($event['start'] > $query['end'] || $event['end'] < $query['start'])) continue;
169 169
 			// Add in participants
170
-			if($options['mapping']['participants']) {
171
-				$event['participants'] = implode(", ",$this->bo->participants($event,true));
170
+			if ($options['mapping']['participants']) {
171
+				$event['participants'] = implode(", ", $this->bo->participants($event, true));
172 172
 			}
173 173
 			if (is_array($event))
174 174
 			{
175 175
 				$record->set_record($event);
176
-				if($options['mapping']['recurrence']) {
176
+				if ($options['mapping']['recurrence']) {
177 177
 					$record->recurrence = $recurrence[$record->recur_type];
178
-					if($record->recur_type != MCAL_RECUR_NONE) $record->recurrence .= ' / '. $record->recur_interval;
178
+					if ($record->recur_type != MCAL_RECUR_NONE) $record->recurrence .= ' / '.$record->recur_interval;
179 179
 				}
180 180
 
181 181
 				// Standard stuff
182
-				if($options['convert']) {
182
+				if ($options['convert']) {
183 183
 					importexport_export_csv::convert($record, $convert_fields, 'calendar', $this->selects);
184 184
 				} else {
185 185
 					// Implode arrays, so they don't say 'Array'
186
-					foreach($record->get_record_array() as $key => $value) {
187
-						if(is_array($value)) $record->$key = implode(',', $value);
186
+					foreach ($record->get_record_array() as $key => $value) {
187
+						if (is_array($value)) $record->$key = implode(',', $value);
188 188
 					}
189 189
 	 			}
190 190
 				$export_object->export_record($record);
@@ -237,8 +237,8 @@  discard block
 block discarded – undo
237 237
 	 *
238 238
 	 */
239 239
 	public function get_selectors_etpl($definition = null) {
240
-		$states = $GLOBALS['egw']->session->appsession('session_data','calendar');
241
-		switch($states['view']) {
240
+		$states = $GLOBALS['egw']->session->appsession('session_data', 'calendar');
241
+		switch ($states['view']) {
242 242
 			case 'month':
243 243
 				$query = $this->get_query_month($states);
244 244
 				break;
@@ -250,32 +250,32 @@  discard block
 block discarded – undo
250 250
 				$query = $this->get_query_day($states);
251 251
 				break;
252 252
 		}
253
-		$start= new egw_time($query['start']);
253
+		$start = new egw_time($query['start']);
254 254
 		$end = new egw_time($query['end']);
255 255
 		if ($states['view'] == 'listview')
256 256
 		{
257
-			$list = $GLOBALS['egw']->session->appsession('calendar_list','calendar');
257
+			$list = $GLOBALS['egw']->session->appsession('calendar_list', 'calendar');
258 258
 
259 259
 			// Use UI to get dates
260 260
 			$ui = new calendar_uilist();
261
-			$list['csv_export'] = true;	// so get_rows method _can_ produce different content or not store state in the session
262
-			$ui->get_rows($list,$rows,$readonlys);
261
+			$list['csv_export'] = true; // so get_rows method _can_ produce different content or not store state in the session
262
+			$ui->get_rows($list, $rows, $readonlys);
263 263
 			$start = $ui->first ? $ui->first : new egw_time($ui->date);
264 264
 			$end = $ui->last;
265 265
 
266 266
 			// Special handling
267
-			if($list['filter'] == 'all') $start = $end = null;
268
-			if($list['filter'] == 'before')
267
+			if ($list['filter'] == 'all') $start = $end = null;
268
+			if ($list['filter'] == 'before')
269 269
 			{
270 270
 				$end = $start;
271 271
 				$start = null;
272 272
 			}
273 273
 			$ui = null;
274 274
 		}
275
-		elseif(!$end)
275
+		elseif (!$end)
276 276
 		{
277
-			$end = '+1 ' . $states['view'];
278
-			$end = strtotime($end, $start->format('ts'))-1;
277
+			$end = '+1 '.$states['view'];
278
+			$end = strtotime($end, $start->format('ts')) - 1;
279 279
 		}
280 280
 		$prefs = unserialize($GLOBALS['egw_info']['user']['preferences']['importexport'][$definition->definition_id]);
281 281
 		$data = array(
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 				'criteria'	=> array(
287 287
 					'start'		=> is_object($start) ? $start->format('ts') : $start,
288 288
 					'end'		=> is_object($end) ? $end->format('ts') : $end,
289
-					'owner'		=> is_array($states['owner']) ? $states['owner'] : explode(',',$states['owner'])
289
+					'owner'		=> is_array($states['owner']) ? $states['owner'] : explode(',', $states['owner'])
290 290
 				)
291 291
 			),
292 292
 			'sel_options' => array(
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
 			)
295 295
 		);
296 296
 		// Pass current owner labels
297
-		foreach($data['content']['criteria']['owner'] as $owner)
297
+		foreach ($data['content']['criteria']['owner'] as $owner)
298 298
 		{
299 299
 			$data['sel_options']['owner'][] = array(
300 300
 				'id' => $owner,
@@ -312,8 +312,8 @@  discard block
 block discarded – undo
312 312
 	public static function get_query_month($states)
313 313
 	{
314 314
 		$timespan = array(
315
-			'start' => mktime(0,0,0,$states['month'],1,$states['year']),
316
-			'end' => mktime(0,0,0,$states['month']+1,1,$states['year'])-1
315
+			'start' => mktime(0, 0, 0, $states['month'], 1, $states['year']),
316
+			'end' => mktime(0, 0, 0, $states['month'] + 1, 1, $states['year']) - 1
317 317
 		);
318 318
 		return $timespan;
319 319
 	}
@@ -331,24 +331,24 @@  discard block
 block discarded – undo
331 331
 		if ($states['view'] == 'week' && $days == 4)         // next 4 days view
332 332
                 {
333 333
                         $query['start'] = $this->bo->date2ts($states['date']);
334
-                        $query['end'] = strtotime("+$days days",$query['start']) - 1;
334
+                        $query['end'] = strtotime("+$days days", $query['start']) - 1;
335 335
                 }
336 336
                 else
337 337
                 {
338
-			$query['start'] = $ui->datetime->get_weekday_start($states['year'],$states['month'],$states['day']);
338
+			$query['start'] = $ui->datetime->get_weekday_start($states['year'], $states['month'], $states['day']);
339 339
 			if ($days == 5)         // no weekend-days
340 340
 			{
341
-				switch($ui->cal_prefs['weekdaystarts'])
341
+				switch ($ui->cal_prefs['weekdaystarts'])
342 342
 				{
343 343
 					case 'Saturday':
344
-						$query['start'] = strtotime("+2 days",$query['start']);
344
+						$query['start'] = strtotime("+2 days", $query['start']);
345 345
 						break;
346 346
 					case 'Sunday':
347
-						$query['start'] = strtotime("+1 day",$query['start']);
347
+						$query['start'] = strtotime("+1 day", $query['start']);
348 348
 						break;
349 349
 				}
350 350
 			}
351
-			$query['end'] = strtotime($states['view'] == 'week' ? "+$days days" : "+{$ui->cal_prefs['multiple_weeks']} weeks",$query['start']) - 1;
351
+			$query['end'] = strtotime($states['view'] == 'week' ? "+$days days" : "+{$ui->cal_prefs['multiple_weeks']} weeks", $query['start']) - 1;
352 352
 		}
353 353
 		return $query;
354 354
 	}
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
 		$query = array();
359 359
 		$bo = new calendar_bo();
360 360
 		$query['start'] = $bo->date2ts((string)$states['date']);
361
-		$query['end'] = $query['start']+DAY_s-1;
361
+		$query['end'] = $query['start'] + DAY_s - 1;
362 362
 		return $query;
363 363
 	}
364 364
 
@@ -407,17 +407,17 @@  discard block
 block discarded – undo
407 407
 		);
408 408
 		$filters = array_reverse($filters, true);
409 409
 
410
-		foreach($filters as $field_name => &$settings)
410
+		foreach ($filters as $field_name => &$settings)
411 411
 		{
412 412
 			// Can't filter on a custom field
413
-			if(strpos($field_name, '#') === 0)
413
+			if (strpos($field_name, '#') === 0)
414 414
 			{
415 415
 				unset($filters[$field_name]);
416 416
 				continue;
417 417
 			}
418 418
 
419 419
 			// Pass on select options
420
-			if($this->selects[$field_name]) $settings['values'] = $this->selects[$field_name];
420
+			if ($this->selects[$field_name]) $settings['values'] = $this->selects[$field_name];
421 421
 		}
422 422
 
423 423
 	}
Please login to merge, or discard this patch.
calendar/inc/class.calendar_import_ical.inc.php 4 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -15,19 +15,19 @@  discard block
 block discarded – undo
15 15
 /**
16 16
  * import ical for calendar
17 17
  */
18
-class calendar_import_ical implements importexport_iface_import_plugin  {
18
+class calendar_import_ical implements importexport_iface_import_plugin {
19 19
 
20 20
 	private static $plugin_options = array(
21
-		'fieldsep', 		// char
22
-		'charset',		// string
23
-		'owner', 		// int
24
-		'update_cats', 			// string {override|add} overides record
21
+		'fieldsep', // char
22
+		'charset', // string
23
+		'owner', // int
24
+		'update_cats', // string {override|add} overides record
25 25
 								// with cat(s) from csv OR add the cat from
26 26
 								// csv file to exeisting cat(s) of record
27 27
 		'num_header_lines', // int number of header lines
28 28
 		'field_conversion', // array( $csv_col_num => conversion)
29
-		'field_mapping',	// array( $csv_col_num => adb_filed)
30
-		'conditions',		/* => array containing condition arrays:
29
+		'field_mapping', // array( $csv_col_num => adb_filed)
30
+		'conditions', /* => array containing condition arrays:
31 31
 				'type' => exists, // exists
32 32
 				'string' => '#kundennummer',
33 33
 				'true' => array(
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 	 * @param string $_charset
105 105
 	 * @param definition $_definition
106 106
 	 */
107
-	public function import( $_stream, importexport_definition $_definition ) {
107
+	public function import($_stream, importexport_definition $_definition) {
108 108
 
109 109
 		$this->definition = $_definition;
110 110
 
@@ -112,20 +112,20 @@  discard block
 block discarded – undo
112 112
 		$this->user = $GLOBALS['egw_info']['user']['account_id'];
113 113
 
114 114
 		// dry run?
115
-		$this->dry_run = isset( $_definition->plugin_options['dry_run'] ) ? $_definition->plugin_options['dry_run'] :  false;
115
+		$this->dry_run = isset($_definition->plugin_options['dry_run']) ? $_definition->plugin_options['dry_run'] : false;
116 116
 
117 117
 		// fetch the addressbook bo
118
-		$this->bo= new calendar_boupdate();
118
+		$this->bo = new calendar_boupdate();
119 119
 
120 120
 
121 121
 		// Failures
122 122
 		$this->errors = array();
123 123
 
124
-		@set_time_limit(0);     // try switching execution time limit off
124
+		@set_time_limit(0); // try switching execution time limit off
125 125
 
126 126
 		$calendar_ical = new calendar_ical;
127 127
 		$calendar_ical->setSupportedFields('file', '');
128
-		if($this->dry_run)
128
+		if ($this->dry_run)
129 129
 		{
130 130
 			// No real dry run for iCal
131 131
 			echo lang("No preview for iCal");
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 		{
137 137
 			$_definition->plugin_options['no_notification'] = true;
138 138
 		}
139
-		if (!$calendar_ical->importVCal($_stream, -1,null,false,0,'',null,null,null,$_definition->plugin_options['no_notification']))
139
+		if (!$calendar_ical->importVCal($_stream, -1, null, false, 0, '', null, null, null, $_definition->plugin_options['no_notification']))
140 140
 		{
141 141
 			$this->errors[] = lang('Error: importing the iCal');
142 142
 		}
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -104,8 +104,7 @@
 block discarded – undo
104 104
 	/**
105 105
 	 * imports entries according to given definition object.
106 106
 	 * @param resource $_stream
107
-	 * @param string $_charset
108
-	 * @param definition $_definition
107
+	 * @param importexport_definition $_definition
109 108
 	 */
110 109
 	public function import( $_stream, importexport_definition $_definition ) {
111 110
 		$import_csv = new importexport_import_csv( $_stream, array(
Please login to merge, or discard this patch.
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -64,8 +64,8 @@  discard block
 block discarded – undo
64 64
 	private $bo;
65 65
 
66 66
 	/**
67
-	* For figuring out if an entry has changed
68
-	*/
67
+	 * For figuring out if an entry has changed
68
+	 */
69 69
 	protected $tracking;
70 70
 
71 71
 	/**
@@ -94,9 +94,9 @@  discard block
 block discarded – undo
94 94
 	protected $errors = array();
95 95
 
96 96
 	/**
97
-         * List of actions, and how many times that action was taken
98
-         */
99
-        protected $results = array();
97
+	 * List of actions, and how many times that action was taken
98
+	 */
99
+		protected $results = array();
100 100
 
101 101
 	/**
102 102
 	 * imports entries according to given definition object.
@@ -202,39 +202,39 @@  discard block
 block discarded – undo
202 202
 	}
203 203
 
204 204
 	/**
205
-        * Returns warnings that were encountered during importing
206
-        * Maximum of one warning message per record, but you can append if you need to
207
-        *
208
-        * @return Array (
209
-        *       record_# => warning message
210
-        *       )
211
-        */
212
-        public function get_warnings() {
205
+	 * Returns warnings that were encountered during importing
206
+	 * Maximum of one warning message per record, but you can append if you need to
207
+	 *
208
+	 * @return Array (
209
+	 *       record_# => warning message
210
+	 *       )
211
+	 */
212
+		public function get_warnings() {
213 213
 		return $this->warnings;
214 214
 	}
215 215
 
216 216
 	/**
217
-        * Returns errors that were encountered during importing
218
-        * Maximum of one error message per record, but you can append if you need to
219
-        *
220
-        * @return Array (
221
-        *       record_# => error message
222
-        *       )
223
-        */
224
-        public function get_errors() {
217
+	 * Returns errors that were encountered during importing
218
+	 * Maximum of one error message per record, but you can append if you need to
219
+	 *
220
+	 * @return Array (
221
+	 *       record_# => error message
222
+	 *       )
223
+	 */
224
+		public function get_errors() {
225 225
 		return $this->errors;
226 226
 	}
227 227
 
228 228
 	/**
229
-        * Returns a list of actions taken, and the number of records for that action.
230
-        * Actions are things like 'insert', 'update', 'delete', and may be different for each plugin.
231
-        *
232
-        * @return Array (
233
-        *       action => record count
234
-        * )
235
-        */
236
-        public function get_results() {
237
-                return $this->results;
238
-        }
229
+	 * Returns a list of actions taken, and the number of records for that action.
230
+	 * Actions are things like 'insert', 'update', 'delete', and may be different for each plugin.
231
+	 *
232
+	 * @return Array (
233
+	 *       action => record count
234
+	 * )
235
+	 */
236
+		public function get_results() {
237
+				return $this->results;
238
+		}
239 239
 } // end of iface_export_plugin
240 240
 ?>
Please login to merge, or discard this patch.
Braces   +20 added lines, -10 removed lines patch added patch discarded remove patch
@@ -15,7 +15,8 @@  discard block
 block discarded – undo
15 15
 /**
16 16
  * import ical for calendar
17 17
  */
18
-class calendar_import_ical implements importexport_iface_import_plugin  {
18
+class calendar_import_ical implements importexport_iface_import_plugin
19
+{
19 20
 
20 21
 	private static $plugin_options = array(
21 22
 		'fieldsep', 		// char
@@ -104,7 +105,8 @@  discard block
 block discarded – undo
104 105
 	 * @param string $_charset
105 106
 	 * @param definition $_definition
106 107
 	 */
107
-	public function import( $_stream, importexport_definition $_definition ) {
108
+	public function import( $_stream, importexport_definition $_definition )
109
+	{
108 110
 
109 111
 		$this->definition = $_definition;
110 112
 
@@ -154,7 +156,8 @@  discard block
 block discarded – undo
154 156
 	 *
155 157
 	 * @return string name
156 158
 	 */
157
-	public static function get_name() {
159
+	public static function get_name()
160
+	{
158 161
 		return lang('Calendar iCal import');
159 162
 	}
160 163
 
@@ -163,7 +166,8 @@  discard block
 block discarded – undo
163 166
 	 *
164 167
 	 * @return string descriprion
165 168
 	 */
166
-	public static function get_description() {
169
+	public static function get_description()
170
+	{
167 171
 		return lang("Imports events into your Calendar from an iCal File.");
168 172
 	}
169 173
 
@@ -172,7 +176,8 @@  discard block
 block discarded – undo
172 176
 	 *
173 177
 	 * @return string suffix (comma seperated)
174 178
 	 */
175
-	public static function get_filesuffix() {
179
+	public static function get_filesuffix()
180
+	{
176 181
 		return 'ics';
177 182
 	}
178 183
 
@@ -188,7 +193,8 @@  discard block
 block discarded – undo
188 193
 	 * 		preserv		=> array,
189 194
 	 * )
190 195
 	 */
191
-	public function get_options_etpl() {
196
+	public function get_options_etpl()
197
+	{
192 198
 		// lets do it!
193 199
 	}
194 200
 
@@ -197,7 +203,8 @@  discard block
 block discarded – undo
197 203
 	 *
198 204
 	 * @return string etemplate name
199 205
 	 */
200
-	public function get_selectors_etpl() {
206
+	public function get_selectors_etpl()
207
+	{
201 208
 		// lets do it!
202 209
 	}
203 210
 
@@ -209,7 +216,8 @@  discard block
 block discarded – undo
209 216
         *       record_# => warning message
210 217
         *       )
211 218
         */
212
-        public function get_warnings() {
219
+        public function get_warnings()
220
+        {
213 221
 		return $this->warnings;
214 222
 	}
215 223
 
@@ -221,7 +229,8 @@  discard block
 block discarded – undo
221 229
         *       record_# => error message
222 230
         *       )
223 231
         */
224
-        public function get_errors() {
232
+        public function get_errors()
233
+        {
225 234
 		return $this->errors;
226 235
 	}
227 236
 
@@ -233,7 +242,8 @@  discard block
 block discarded – undo
233 242
         *       action => record count
234 243
         * )
235 244
         */
236
-        public function get_results() {
245
+        public function get_results()
246
+        {
237 247
                 return $this->results;
238 248
         }
239 249
 } // end of iface_export_plugin
Please login to merge, or discard this patch.
calendar/inc/class.calendar_tracking.inc.php 2 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -132,10 +132,10 @@  discard block
 block discarded – undo
132 132
 		}
133 133
 
134 134
 		/**
135
-		* Do some magic with the participants and recurrance.
136
-		* If this is one of a recurring event, append the recur_date to the participant field so we can
137
-		* filter by it later.
138
-		*/
135
+		 * Do some magic with the participants and recurrance.
136
+		 * If this is one of a recurring event, append the recur_date to the participant field so we can
137
+		 * filter by it later.
138
+		 */
139 139
 		if(is_array($data['participants']))
140 140
 		{
141 141
 			$participants = $data['participants'];
@@ -195,10 +195,10 @@  discard block
 block discarded – undo
195 195
 	}
196 196
 
197 197
 	/**
198
-	* Do some magic with the participants and recurrance.
199
-	* If this is one of a recurring event, append the recur_date to the participant field so we can
200
-	* filter by it later.
201
-	*/
198
+	 * Do some magic with the participants and recurrance.
199
+	 * If this is one of a recurring event, append the recur_date to the participant field so we can
200
+	 * filter by it later.
201
+	 */
202 202
 	protected function alter_participants($participants)
203 203
 	{
204 204
 		$data = array();
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -114,18 +114,18 @@  discard block
 block discarded – undo
114 114
 	 */
115 115
 	public function __construct()
116 116
 	{
117
-		parent::__construct('calendar');	// adds custom fields
117
+		parent::__construct('calendar'); // adds custom fields
118 118
 	}
119 119
 
120 120
 	/**
121 121
 	 * Tracks the changes in one entry $data, by comparing it with the last version in $old
122 122
 	 * Overrides parent to reformat participants into a format parent can handle
123 123
 	 */
124
-	public function track(array $data,array $old=null,$user=null,$deleted=null,array $changed_fields=null)
124
+	public function track(array $data, array $old = null, $user = null, $deleted = null, array $changed_fields = null)
125 125
 	{
126 126
 		// Don't try to track dates on recurring events.
127 127
 		// It won't change for the base event, and any change to the time creates an exception
128
-		if($data['recur_type'])
128
+		if ($data['recur_type'])
129 129
 		{
130 130
 			unset($data['start']); unset($data['end']);
131 131
 			unset($old['start']); unset($old['end']);
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 		* If this is one of a recurring event, append the recur_date to the participant field so we can
137 137
 		* filter by it later.
138 138
 		*/
139
-		if(is_array($data['participants']))
139
+		if (is_array($data['participants']))
140 140
 		{
141 141
 			$participants = $data['participants'];
142 142
 			$data['participants'] = array();
@@ -144,25 +144,25 @@  discard block
 block discarded – undo
144 144
 		}
145 145
 		// if clients eg. CalDAV do NOT set participants, they are left untouched
146 146
 		// therefore we should not track them, as all updates then show up as all participants removed
147
-		elseif(!isset($data['participants']))
147
+		elseif (!isset($data['participants']))
148 148
 		{
149 149
 			unset($old['participants']);
150 150
 		}
151
-		if(is_array($old['participants']))
151
+		if (is_array($old['participants']))
152 152
 		{
153 153
 			$participants = $old['participants'];
154 154
 			$old['participants'] = array();
155 155
 			$old = array_merge($old, $this->alter_participants($participants));
156 156
 		}
157
-		parent::track($data,$old,$user,$deleted, $changed_fields);
157
+		parent::track($data, $old, $user, $deleted, $changed_fields);
158 158
 	}
159 159
 
160 160
 	/**
161 161
 	 * Overrides parent because calendar_boupdates handles the notifications
162 162
 	 */
163
-	public function do_notifications($data,$old,$deleted=null)
163
+	public function do_notifications($data, $old, $deleted = null)
164 164
 	{
165
-		unset($data, $old, $deleted);	// unused, but required by function signature
165
+		unset($data, $old, $deleted); // unused, but required by function signature
166 166
 		return true;
167 167
 	}
168 168
 
@@ -177,21 +177,21 @@  discard block
 block discarded – undo
177 177
 	 * @param array $old = null
178 178
 	 * @return array of keys with different values in $data and $old
179 179
 	 */
180
-	public function changed_fields(array $data,array $old=null)
180
+	public function changed_fields(array $data, array $old = null)
181 181
 	{
182
-		if(is_array($data['participants']))
182
+		if (is_array($data['participants']))
183 183
 		{
184 184
 			$participants = $data['participants'];
185 185
 			$data['participants'] = array();
186 186
 			$data = array_merge($data, $this->alter_participants($participants));
187 187
 		}
188
-		if(is_array($old['participants']))
188
+		if (is_array($old['participants']))
189 189
 		{
190 190
 			$participants = $old['participants'];
191 191
 			$old['participants'] = array();
192 192
 			$old = array_merge($old, $this->alter_participants($participants));
193 193
 		}
194
-		return parent::changed_fields($data,$old);
194
+		return parent::changed_fields($data, $old);
195 195
 	}
196 196
 
197 197
 	/**
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 	protected function alter_participants($participants)
203 203
 	{
204 204
 		$data = array();
205
-		foreach($participants as $uid => $status)
205
+		foreach ($participants as $uid => $status)
206 206
 		{
207 207
 			$quantity = $role = $user_type = $user_id = null;
208 208
 			calendar_so::split_status($status, $quantity, $role);
Please login to merge, or discard this patch.
calendar/inc/class.calendar_so.inc.php 5 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1528,7 +1528,7 @@
 block discarded – undo
1528 1528
 			if (!$set_recurrences)
1529 1529
 			{
1530 1530
 				$set_recurrences = (isset($event['cal_start']) && (int)$old_min != (int) $event['cal_start']) ||
1531
-				    $event['recur_type'] != $old_repeats['recur_type'] || $event['recur_data'] != $old_repeats['recur_data'] ||
1531
+					$event['recur_type'] != $old_repeats['recur_type'] || $event['recur_data'] != $old_repeats['recur_data'] ||
1532 1532
 					(int)$event['recur_interval'] != (int)$old_repeats['recur_interval'] || $event['tz_id'] != $old_tz_id;
1533 1533
 			}
1534 1534
 
Please login to merge, or discard this patch.
Upper-Lower-Casing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 			"	CASE WHEN recur_type IS NULL THEN egw_cal.range_start ELSE cal_start END AS cal_start,\n".
253 253
 			"	CASE WHEN recur_type IS NULL THEN egw_cal.range_end ELSE cal_end END AS cal_end\n".
254 254
 			// using time-limited range view, instead of complete table, give a big performance plus
255
-			"FROM $egw_cal\n".
255
+			"from $egw_cal\n".
256 256
 			"JOIN egw_cal_user ON egw_cal_user.cal_id=egw_cal.cal_id\n".
257 257
 			// need to left join dates, as egw_cal_user.recur_date is null for non-recuring event
258 258
 			"LEFT JOIN egw_cal_dates ON egw_cal_user.cal_id=egw_cal_dates.cal_id AND egw_cal_dates.cal_start=egw_cal_user.cal_recur_date\n".
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
 			$where[] = 'cal_start >= '.(int)$recur_date;
346 346
 			$group_by = 'GROUP BY '.$cols;
347 347
 			$cols .= ',MIN(cal_start) AS cal_start,MIN(cal_end) AS cal_end';
348
-			$join = "JOIN $this->dates_table ON $this->cal_table.cal_id=$this->dates_table.cal_id $join";
348
+			$join = "join $this->dates_table ON $this->cal_table.cal_id=$this->dates_table.cal_id $join";
349 349
 		}
350 350
 		else
351 351
 		{
@@ -870,7 +870,7 @@  discard block
 block discarded – undo
870 870
 		$cal_table = $this->cal_range_view($start, $end, null, $filter == 'everything' ? null : $filter != 'deleted');
871 871
 		$cal_table_def = $this->db->get_table_definitions('calendar', $this->cal_table);
872 872
 
873
-		$join = "JOIN $this->user_table ON $this->cal_table.cal_id=$this->user_table.cal_id ".
873
+		$join = "join $this->user_table ON $this->cal_table.cal_id=$this->user_table.cal_id ".
874 874
 			"LEFT JOIN $this->repeats_table ON $this->cal_table.cal_id=$this->repeats_table.cal_id ".
875 875
 			$rejected_by_user_join;
876 876
 		// dates table join only needed to enum recuring events, we use a time-range limited view here too
@@ -946,7 +946,7 @@  discard block
 block discarded – undo
946 946
 				// we only select cal_table.cal_id (and not cal_table.*) to be able to use DISTINCT (eg. MsSQL does not allow it for text-columns)
947 947
 				foreach(array_keys($selects) as $key)
948 948
 				{
949
-					$selects[$key]['cols'] = "DISTINCT $this->repeats_table.recur_type,range_end AS recur_enddate,$this->repeats_table.recur_interval,$this->repeats_table.recur_data,".$this->db->to_varchar($this->cal_table.'.cal_id').",cal_start,cal_end,$this->user_table.cal_recur_date";
949
+					$selects[$key]['cols'] = "distinct $this->repeats_table.recur_type,range_end AS recur_enddate,$this->repeats_table.recur_interval,$this->repeats_table.recur_data,".$this->db->to_varchar($this->cal_table.'.cal_id').",cal_start,cal_end,$this->user_table.cal_recur_date";
950 950
 					if (!$params['enum_recuring'])
951 951
 					{
952 952
 						$selects[$key]['cols'] = str_replace(array('cal_start','cal_end'),
@@ -1397,7 +1397,7 @@  discard block
 block discarded – undo
1397 1397
 			{
1398 1398
 				$old_repeats = $this->db->select($this->repeats_table, "$this->repeats_table.*,range_end AS recur_enddate",
1399 1399
 					"$this->repeats_table.cal_id=".(int)$cal_id, __LINE__, __FILE__,
1400
-					false, '', 'calendar', 0, "JOIN $this->cal_table ON $this->repeats_table.cal_id=$this->cal_table.cal_id")->fetch();
1400
+					false, '', 'calendar', 0, "join $this->cal_table ON $this->repeats_table.cal_id=$this->cal_table.cal_id")->fetch();
1401 1401
 			}
1402 1402
 			$where = array('cal_id' => $cal_id);
1403 1403
 			// read only timezone id, to check if it is changed
@@ -1762,13 +1762,13 @@  discard block
 block discarded – undo
1762 1762
 		if ($move_start)
1763 1763
 		{
1764 1764
 			// move the recur-date of the participants
1765
-			$this->db->query("UPDATE $this->user_table SET cal_recur_date=cal_recur_date+$move_start WHERE $where AND cal_recur_date ".
1765
+			$this->db->query("update $this->user_table SET cal_recur_date=cal_recur_date+$move_start WHERE $where AND cal_recur_date ".
1766 1766
 				((int)$change_since ? '>= '.(int)$change_since : '!= 0'),__LINE__,__FILE__);
1767 1767
 		}
1768 1768
 		if ($move_start || $move_end)
1769 1769
 		{
1770 1770
 			// move the event and it's recurrences
1771
-			$this->db->query("UPDATE $this->dates_table SET cal_start=cal_start+$move_start,cal_end=cal_end+$move_end WHERE $where".
1771
+			$this->db->query("update $this->dates_table SET cal_start=cal_start+$move_start,cal_end=cal_end+$move_end WHERE $where".
1772 1772
 				((int) $change_since ? ' AND cal_start >= '.(int) $change_since : ''),__LINE__,__FILE__);
1773 1773
 		}
1774 1774
 		return $this->db->affected_rows();
@@ -2468,7 +2468,7 @@  discard block
 block discarded – undo
2468 2468
 			),__LINE__,__FILE__,'calendar');
2469 2469
 
2470 2470
 			// delete calendar entries without participants (can happen if the deleted user is the only participants, but not the owner)
2471
-			foreach($this->db->select($this->cal_table,"DISTINCT $this->cal_table.cal_id",'cal_user_id IS NULL',__LINE__,__FILE__,
2471
+			foreach($this->db->select($this->cal_table,"distinct $this->cal_table.cal_id",'cal_user_id IS NULL',__LINE__,__FILE__,
2472 2472
 				False,'','calendar',0,"LEFT JOIN $this->user_table ON $this->cal_table.cal_id=$this->user_table.cal_id") as $row)
2473 2473
 			{
2474 2474
 				$this->delete($row['cal_id']);
Please login to merge, or discard this patch.
Doc Comments   +15 added lines, -39 removed lines patch added patch discarded remove patch
@@ -207,23 +207,11 @@  discard block
 block discarded – undo
207 207
 	 * @param int $start startdate of the search/list (servertime)
208 208
 	 * @param int $end enddate of the search/list (servertime)
209 209
 	 * @param int|array $users user-id or array of user-id's, !$users means all entries regardless of users
210
-	 * @param int|array $cat_id =0 mixed category-id or array of cat-id's (incl. all sub-categories), default 0 = all
210
+	 * @param integer $cat_id =0 mixed category-id or array of cat-id's (incl. all sub-categories), default 0 = all
211 211
 	 * @param string $filter ='default' string filter-name: all (not rejected), accepted, unknown, tentative, rejected or everything (incl. rejected, deleted)
212 212
 	 * @param int|boolean $offset =False offset for a limited query or False (default)
213 213
 	 * @param int $num_rows =0 number of rows to return if offset set, default 0 = use default in user prefs
214 214
 	 * @param array $params =array()
215
-	 * @param string|array $params['query'] string: pattern so search for, if unset or empty all matching entries are returned (no search)
216
-	 *		Please Note: a search never returns repeating events more then once AND does not honor start+end date !!!
217
-	 *      array: everything is directly used as $where
218
-	 * @param string $params['order'] ='cal_start' column-names plus optional DESC|ASC separted by comma
219
-	 * @param string $params['sql_filter'] sql to be and'ed into query (fully quoted)
220
-	 * @param string|array $params['cols'] what to select, default "$this->repeats_table.*,$this->cal_table.*,cal_start,cal_end,cal_recur_date",
221
-	 * 						if specified and not false an iterator for the rows is returned
222
-	 * @param string $params['append'] SQL to append to the query before $order, eg. for a GROUP BY clause
223
-	 * @param array $params['cfs'] custom fields to query, null = none, array() = all, or array with cfs names
224
-	 * @param array $params['users'] raw parameter as passed to calendar_bo::search() no memberships resolved!
225
-	 * @param boolean $params['master_only'] =false, true only take into account participants/status from master (for AS)
226
-	 * @param boolean $params['enum_recuring'] =true enumerate recuring events
227 215
 	 * @param int $remove_rejected_by_user =null add join to remove entry, if given user has rejected it
228 216
 	 * @return array of events
229 217
 	 */
@@ -357,7 +345,7 @@  discard block
 block discarded – undo
357 345
 	/**
358 346
 	 * Get full event information from an iterator of a select on egw_cal
359 347
 	 *
360
-	 * @param array|Iterator $rs
348
+	 * @param ADORecordSet $rs
361 349
 	 * @param int $recur_date =0
362 350
 	 * @return array
363 351
 	 */
@@ -571,7 +559,7 @@  discard block
 block discarded – undo
571 559
 	 *
572 560
 	 * @param array $query filter, keys have to use 'cal_' prefix
573 561
 	 * @param string|array $cols ='cal_id,cal_reference,cal_etag,cal_modified,cal_user_modified' cols to query
574
-	 * @return Iterator as egw_db::select
562
+	 * @return ADORecordSet as egw_db::select
575 563
 	 */
576 564
 	function get_cal_data(array $query, $cols='cal_id,cal_reference,cal_etag,cal_modified,cal_user_modified')
577 565
 	{
@@ -590,7 +578,7 @@  discard block
 block discarded – undo
590 578
 	/**
591 579
 	 * generate SQL to filter after a given category (incl. subcategories)
592 580
 	 *
593
-	 * @param array|int $cat_id cat-id or array of cat-ids, or !$cat_id for none
581
+	 * @param integer $cat_id cat-id or array of cat-ids, or !$cat_id for none
594 582
 	 * @return string SQL to include in the query
595 583
 	 */
596 584
 	function cat_filter($cat_id)
@@ -678,24 +666,11 @@  discard block
 block discarded – undo
678 666
 	 * @param int $start startdate of the search/list (servertime)
679 667
 	 * @param int $end enddate of the search/list (servertime)
680 668
 	 * @param int|array $users user-id or array of user-id's, !$users means all entries regardless of users
681
-	 * @param int|array $cat_id =0 mixed category-id or array of cat-id's (incl. all sub-categories), default 0 = all
669
+	 * @param integer $cat_id =0 mixed category-id or array of cat-id's (incl. all sub-categories), default 0 = all
682 670
 	 * @param string $filter ='all' string filter-name: all (not rejected), accepted, unknown, tentative, rejected or everything (incl. rejected, deleted)
683 671
 	 * @param int|boolean $offset =False offset for a limited query or False (default)
684 672
 	 * @param int $num_rows =0 number of rows to return if offset set, default 0 = use default in user prefs
685 673
 	 * @param array $params =array()
686
-	 * @param string|array $params['query'] string: pattern so search for, if unset or empty all matching entries are returned (no search)
687
-	 *		Please Note: a search never returns repeating events more then once AND does not honor start+end date !!!
688
-	 *      array: everything is directly used as $where
689
-	 * @param string $params['order'] ='cal_start' column-names plus optional DESC|ASC separted by comma
690
-	 * @param string|array $params['sql_filter'] sql to be and'ed into query (fully quoted), or usual filter array
691
-	 * @param string|array $params['cols'] what to select, default "$this->repeats_table.*,$this->cal_table.*,cal_start,cal_end,cal_recur_date",
692
-	 * 						if specified and not false an iterator for the rows is returned
693
-	 * @param string $params['append'] SQL to append to the query before $order, eg. for a GROUP BY clause
694
-	 * @param array $params['cfs'] custom fields to query, null = none, array() = all, or array with cfs names
695
-	 * @param array $params['users'] raw parameter as passed to calendar_bo::search() no memberships resolved!
696
-	 * @param boolean $params['master_only'] =false, true only take into account participants/status from master (for AS)
697
-	 * @param boolean $params['enum_recuring'] =true enumerate recuring events
698
-	 * @param boolean $params['use_so_events'] =false, true return result of new $this->events()
699 674
 	 * @param int $remove_rejected_by_user =null add join to remove entry, if given user has rejected it
700 675
 	 * @return Iterator|array of events
701 676
 	 */
@@ -1136,11 +1111,11 @@  discard block
 block discarded – undo
1136 1111
 	 * Ask other apps if they want to participate in calendar search / display
1137 1112
 	 *
1138 1113
 	 * @param &$selects parts of union query
1139
-	 * @param $start see search()
1140
-	 * @param $end
1114
+	 * @param integer $start see search()
1115
+	 * @param integer $end
1141 1116
 	 * @param $users as used in calendar_so ($users_raw plus all members and memberships added by calendar_bo)
1142
-	 * @param $cat_id
1143
-	 * @param $filter
1117
+	 * @param integer $cat_id
1118
+	 * @param string $filter
1144 1119
 	 * @param $query
1145 1120
 	 * @param $users_raw as passed to calendar_bo::search (no members and memberships added)
1146 1121
 	 */
@@ -1308,6 +1283,7 @@  discard block
 block discarded – undo
1308 1283
 	 * @param int &$set_recurrences_start=0 on return: time from which on the recurrences should be rebuilt, default 0=all
1309 1284
 	 * @param int $change_since =0 time from which on the repetitions should be changed, default 0=all
1310 1285
 	 * @param int &$etag etag=null etag to check or null, on return new etag
1286
+	 * @param boolean $set_recurrences
1311 1287
 	 * @return boolean|int false on error, 0 if etag does not match, cal_id otherwise
1312 1288
 	 */
1313 1289
 	function save($event,&$set_recurrences,&$set_recurrences_start=0,$change_since=0,&$etag=null)
@@ -1718,7 +1694,7 @@  discard block
 block discarded – undo
1718 1694
 	 * @param int $cal_id
1719 1695
 	 * @param int $start new starttime
1720 1696
 	 * @param int $end new endtime
1721
-	 * @param int|boolean $change_since =0 false=new entry, > 0 time from which on the repetitions should be changed, default 0=all
1697
+	 * @param integer $change_since =0 false=new entry, > 0 time from which on the repetitions should be changed, default 0=all
1722 1698
 	 * @param int $old_start =0 old starttime or (default) 0, to query it from the db
1723 1699
 	 * @param int $old_end =0 old starttime or (default) 0
1724 1700
 	 * @todo Recalculate recurrences, if timezone changes
@@ -1895,12 +1871,12 @@  discard block
 block discarded – undo
1895 1871
 	 *
1896 1872
 	 * @param int $cal_id
1897 1873
 	 * @param array $participants uid => status pairs
1898
-	 * @param int|boolean $change_since =0, false=new event,
1874
+	 * @param integer $change_since =0, false=new event,
1899 1875
 	 * 		0=all, > 0 time from which on the repetitions should be changed
1900 1876
 	 * @param boolean $add_only =false
1901 1877
 	 *		false = add AND delete participants if needed (full list of participants required in $participants)
1902 1878
 	 *		true = only add participants if needed, no participant will be deleted (participants to check/add required in $participants)
1903
-	 * @return int|boolean number of updated recurrences or false on error
1879
+	 * @return boolean number of updated recurrences or false on error
1904 1880
 	 */
1905 1881
 	function participants($cal_id,$participants,$change_since=0,$add_only=false)
1906 1882
 	{
@@ -2041,7 +2017,7 @@  discard block
 block discarded – undo
2041 2017
 	 * set the status of one participant for a given recurrence or for all recurrences since now (includes recur_date=0)
2042 2018
 	 *
2043 2019
 	 * @param int $cal_id
2044
-	 * @param char $user_type 'u' regular user, 'r' resource, 'c' contact
2020
+	 * @param string $user_type 'u' regular user, 'r' resource, 'c' contact
2045 2021
 	 * @param int|string $user_id
2046 2022
 	 * @param int|char $status numeric status (defines) or 1-char code: 'R', 'U', 'T' or 'A'
2047 2023
 	 * @param int $recur_date =0 date to change, or 0 = all since now
@@ -2958,7 +2934,7 @@  discard block
 block discarded – undo
2958 2934
 	 * Updates the modification timestamp to force an etag, ctag and sync-token change
2959 2935
 	 *
2960 2936
 	 * @param int $id event id
2961
-	 * @param int|boolean $update_master =false id of series master or true, to update series master too
2937
+	 * @param boolean $update_master =false id of series master or true, to update series master too
2962 2938
 	 * @param int $time =null new timestamp, default current (server-)time
2963 2939
 	 * @param int $modifier =null uid of the modifier, default current user
2964 2940
 	 */
Please login to merge, or discard this patch.
Spacing   +387 added lines, -390 removed lines patch added patch discarded remove patch
@@ -15,40 +15,40 @@  discard block
 block discarded – undo
15 15
 /**
16 16
  * some necessary defines used by the calendar
17 17
  */
18
-if(!extension_loaded('mcal'))
18
+if (!extension_loaded('mcal'))
19 19
 {
20
-	define('MCAL_RECUR_NONE',0);
21
-	define('MCAL_RECUR_DAILY',1);
22
-	define('MCAL_RECUR_WEEKLY',2);
23
-	define('MCAL_RECUR_MONTHLY_MDAY',3);
24
-	define('MCAL_RECUR_MONTHLY_WDAY',4);
25
-	define('MCAL_RECUR_YEARLY',5);
26
-	define('MCAL_RECUR_SECONDLY',6);
27
-	define('MCAL_RECUR_MINUTELY',7);
28
-	define('MCAL_RECUR_HOURLY',8);
29
-
30
-	define('MCAL_M_SUNDAY',1);
31
-	define('MCAL_M_MONDAY',2);
32
-	define('MCAL_M_TUESDAY',4);
33
-	define('MCAL_M_WEDNESDAY',8);
34
-	define('MCAL_M_THURSDAY',16);
35
-	define('MCAL_M_FRIDAY',32);
36
-	define('MCAL_M_SATURDAY',64);
37
-
38
-	define('MCAL_M_WEEKDAYS',62);
39
-	define('MCAL_M_WEEKEND',65);
40
-	define('MCAL_M_ALLDAYS',127);
20
+	define('MCAL_RECUR_NONE', 0);
21
+	define('MCAL_RECUR_DAILY', 1);
22
+	define('MCAL_RECUR_WEEKLY', 2);
23
+	define('MCAL_RECUR_MONTHLY_MDAY', 3);
24
+	define('MCAL_RECUR_MONTHLY_WDAY', 4);
25
+	define('MCAL_RECUR_YEARLY', 5);
26
+	define('MCAL_RECUR_SECONDLY', 6);
27
+	define('MCAL_RECUR_MINUTELY', 7);
28
+	define('MCAL_RECUR_HOURLY', 8);
29
+
30
+	define('MCAL_M_SUNDAY', 1);
31
+	define('MCAL_M_MONDAY', 2);
32
+	define('MCAL_M_TUESDAY', 4);
33
+	define('MCAL_M_WEDNESDAY', 8);
34
+	define('MCAL_M_THURSDAY', 16);
35
+	define('MCAL_M_FRIDAY', 32);
36
+	define('MCAL_M_SATURDAY', 64);
37
+
38
+	define('MCAL_M_WEEKDAYS', 62);
39
+	define('MCAL_M_WEEKEND', 65);
40
+	define('MCAL_M_ALLDAYS', 127);
41 41
 }
42 42
 
43
-define('REJECTED',0);
44
-define('NO_RESPONSE',1);
45
-define('TENTATIVE',2);
46
-define('ACCEPTED',3);
47
-define('DELEGATED',4);
43
+define('REJECTED', 0);
44
+define('NO_RESPONSE', 1);
45
+define('TENTATIVE', 2);
46
+define('ACCEPTED', 3);
47
+define('DELEGATED', 4);
48 48
 
49
-define('HOUR_s',60*60);
50
-define('DAY_s',24*HOUR_s);
51
-define('WEEK_s',7*DAY_s);
49
+define('HOUR_s', 60 * 60);
50
+define('DAY_s', 24 * HOUR_s);
51
+define('WEEK_s', 7 * DAY_s);
52 52
 
53 53
 /**
54 54
  * Class to store all calendar data (storage object)
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 	 * name of the main calendar table and prefix for all other calendar tables
97 97
 	 */
98 98
 	var $cal_table = 'egw_cal';
99
-	var $extra_table,$repeats_table,$user_table,$dates_table,$all_tables;
99
+	var $extra_table, $repeats_table, $user_table, $dates_table, $all_tables;
100 100
 
101 101
 	/**
102 102
 	 * reference to global db-object
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 		$this->db = $GLOBALS['egw']->db;
133 133
 
134 134
 		$this->all_tables = array($this->cal_table);
135
-		foreach(array('extra','repeats','user','dates') as $name)
135
+		foreach (array('extra', 'repeats', 'user', 'dates') as $name)
136 136
 		{
137 137
 			$vname = $name.'_table';
138 138
 			$this->all_tables[] = $this->$vname = $this->cal_table.'_'.$name;
@@ -148,11 +148,11 @@  discard block
 block discarded – undo
148 148
 	 * @param boolean $deleted =false
149 149
 	 * @return string
150 150
 	 */
151
-	protected function cal_range_view($start, $end, array $_where=null, $deleted=false)
151
+	protected function cal_range_view($start, $end, array $_where = null, $deleted = false)
152 152
 	{
153 153
 		if ($GLOBALS['egw_info']['server']['no_timerange_views'] || !$start)	// using view without start-date is slower!
154 154
 		{
155
-			return $this->cal_table;	// no need / use for a view
155
+			return $this->cal_table; // no need / use for a view
156 156
 		}
157 157
 
158 158
 		$where = array();
@@ -178,11 +178,11 @@  discard block
 block discarded – undo
178 178
 	 * @param boolean $deleted =false
179 179
 	 * @return string
180 180
 	 */
181
-	protected function dates_range_view($start, $end, array $_where=null, $deleted=false)
181
+	protected function dates_range_view($start, $end, array $_where = null, $deleted = false)
182 182
 	{
183 183
 		if ($GLOBALS['egw_info']['server']['no_timerange_views'] || !$start || !$end)	// using view without start- AND end-date is slower!
184 184
 		{
185
-			return $this->dates_table;	// no need / use for a view
185
+			return $this->dates_table; // no need / use for a view
186 186
 		}
187 187
 
188 188
 		$where = array();
@@ -227,14 +227,14 @@  discard block
 block discarded – undo
227 227
 	 * @param int $remove_rejected_by_user =null add join to remove entry, if given user has rejected it
228 228
 	 * @return array of events
229 229
 	 */
230
-	function &events($start,$end,$users,$cat_id=0,$filter='all',$offset=False,$num_rows=0,array $params=array(),$remove_rejected_by_user=null)
230
+	function &events($start, $end, $users, $cat_id = 0, $filter = 'all', $offset = False, $num_rows = 0, array $params = array(), $remove_rejected_by_user = null)
231 231
 	{
232
-		error_log(__METHOD__.'('.($start ? date('Y-m-d H:i',$start) : '').','.($end ? date('Y-m-d H:i',$end) : '').','.array2string($users).','.array2string($cat_id).",'$filter',".array2string($offset).",$num_rows,".array2string($params).') '.function_backtrace());
232
+		error_log(__METHOD__.'('.($start ? date('Y-m-d H:i', $start) : '').','.($end ? date('Y-m-d H:i', $end) : '').','.array2string($users).','.array2string($cat_id).",'$filter',".array2string($offset).",$num_rows,".array2string($params).') '.function_backtrace());
233 233
 		$start_time = microtime(true);
234 234
 		// not everything is supported by now
235 235
 		if (!$start || !$end || is_string($params['query']) ||
236 236
 			//in_array($filter,array('owner','deleted')) ||
237
-			$params['enum_recuring']===false)
237
+			$params['enum_recuring'] === false)
238 238
 		{
239 239
 			throw new egw_exception_assertion_failed("Unsupported value for parameters!");
240 240
 		}
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 		{
262 262
 			// fix $users to also prefix system users and groups (with 'u')
263 263
 			if (!is_array($users)) $users = $users ? (array)$users : array();
264
-			foreach($users as &$uid)
264
+			foreach ($users as &$uid)
265 265
 			{
266 266
 				$user_type = $user_id = null;
267 267
 				self::split_user($uid, $user_type, $user_id, true);
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 
283 283
 		if ($params['order'])	// only order if requested
284 284
 		{
285
-			if (!preg_match('/^[a-z_ ,c]+$/i',$params['order'])) $params['order'] = 'cal_start';		// gard against SQL injection
285
+			if (!preg_match('/^[a-z_ ,c]+$/i', $params['order'])) $params['order'] = 'cal_start'; // gard against SQL injection
286 286
 			$sql .= "\nORDER BY ".$params['order'];
287 287
 		}
288 288
 
@@ -291,8 +291,8 @@  discard block
 block discarded – undo
291 291
 			$offset = 0;
292 292
 			$num_rows = -1;
293 293
 		}
294
-		$events =& $this->get_events($this->db->query($sql, __LINE__, __FILE__, $offset, $num_rows));
295
-		error_log(__METHOD__."(...) $sql --> ".number_format(microtime(true)-$start_time, 3));
294
+		$events = & $this->get_events($this->db->query($sql, __LINE__, __FILE__, $offset, $num_rows));
295
+		error_log(__METHOD__."(...) $sql --> ".number_format(microtime(true) - $start_time, 3));
296 296
 		return $events;
297 297
 	}
298 298
 
@@ -305,12 +305,12 @@  discard block
 block discarded – undo
305 305
 	 * @param int $recur_date =0 if set read the next recurrence at or after the timestamp, default 0 = read the initital one
306 306
 	 * @return array|boolean array with cal_id => event array pairs or false if entry not found
307 307
 	 */
308
-	function read($ids,$recur_date=0)
308
+	function read($ids, $recur_date = 0)
309 309
 	{
310 310
 		//error_log(__METHOD__.'('.array2string($ids).",$recur_date) ".function_backtrace());
311 311
 		$cols = self::get_columns('calendar', $this->cal_table);
312 312
 		$cols[0] = $this->db->to_varchar($this->cal_table.'.cal_id');
313
-		$cols = "$this->repeats_table.recur_type,$this->repeats_table.recur_interval,$this->repeats_table.recur_data,".implode(',',$cols);
313
+		$cols = "$this->repeats_table.recur_type,$this->repeats_table.recur_interval,$this->repeats_table.recur_data,".implode(',', $cols);
314 314
 		$join = "LEFT JOIN $this->repeats_table ON $this->cal_table.cal_id=$this->repeats_table.cal_id";
315 315
 
316 316
 		$where = array();
@@ -320,23 +320,23 @@  discard block
 block discarded – undo
320 320
 			$where['cal_uid'] = $ids;
321 321
 			$where['cal_reference'] = 0;
322 322
 		}
323
-		elseif(is_array($ids) && isset($ids[count($ids)-1]) || is_scalar($ids))	// one or more cal_id's
323
+		elseif (is_array($ids) && isset($ids[count($ids) - 1]) || is_scalar($ids))	// one or more cal_id's
324 324
 		{
325 325
 			$where['cal_id'] = $ids;
326 326
 		}
327 327
 		else	// array with column => value pairs
328 328
 		{
329 329
 			$where = $ids;
330
-			unset($ids);	// otherwise users get not read!
330
+			unset($ids); // otherwise users get not read!
331 331
 		}
332 332
 		if (isset($where['cal_id']))	// prevent non-unique column-name cal_id
333 333
 		{
334
-			$where[] = $this->db->expression($this->cal_table, $this->cal_table.'.',array(
334
+			$where[] = $this->db->expression($this->cal_table, $this->cal_table.'.', array(
335 335
 				'cal_id' => $where['cal_id'],
336 336
 			));
337 337
 			unset($where['cal_id']);
338 338
 		}
339
-		if ((int) $recur_date)
339
+		if ((int)$recur_date)
340 340
 		{
341 341
 			$where[] = 'cal_start >= '.(int)$recur_date;
342 342
 			$group_by = 'GROUP BY '.$cols;
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
 		}
350 350
 		$cols .= ',range_end AS recur_enddate';
351 351
 
352
-		$events =& $this->get_events($this->db->select($this->cal_table, $cols, $where, __LINE__, __FILE__, false, $group_by, 'calendar', 0, $join), $recur_date);
352
+		$events = & $this->get_events($this->db->select($this->cal_table, $cols, $where, __LINE__, __FILE__, false, $group_by, 'calendar', 0, $join), $recur_date);
353 353
 
354 354
 		return $events ? $events : false;
355 355
 	}
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
 	 * @param int $recur_date =0
362 362
 	 * @return array
363 363
 	 */
364
-	protected function &get_events($rs, $recur_date=0)
364
+	protected function &get_events($rs, $recur_date = 0)
365 365
 	{
366 366
 		if (isset($GLOBALS['egw_info']['user']['preferences']['syncml']['minimum_uid_length']))
367 367
 		{
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
 		}
374 374
 
375 375
 		$events = array();
376
-		foreach($rs as $row)
376
+		foreach ($rs as $row)
377 377
 		{
378 378
 			if (!$row['recur_type'])
379 379
 			{
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
 				unset($row['recur_enddate']);
382 382
 			}
383 383
 			$row['recur_exception'] = $row['alarm'] = array();
384
-			$events[$row['cal_id']] = egw_db::strip_array_keys($row,'cal_');
384
+			$events[$row['cal_id']] = egw_db::strip_array_keys($row, 'cal_');
385 385
 		}
386 386
 		if (!$events) return $events;
387 387
 
@@ -393,26 +393,26 @@  discard block
 block discarded – undo
393 393
 			if (!isset($event['uid']) || strlen($event['uid']) < $minimum_uid_length)
394 394
 			{
395 395
 				// event (without uid), not strong enough uid => create new uid
396
-				$event['uid'] = common::generate_uid('calendar',$event['id']);
396
+				$event['uid'] = common::generate_uid('calendar', $event['id']);
397 397
 				$this->db->update($this->cal_table, array('cal_uid' => $event['uid']),
398
-					array('cal_id' => $event['id']),__LINE__,__FILE__,'calendar');
398
+					array('cal_id' => $event['id']), __LINE__, __FILE__, 'calendar');
399 399
 			}
400 400
 			if (!(int)$recur_date && $event['recur_type'] != MCAL_RECUR_NONE)
401 401
 			{
402
-				foreach($this->db->select($this->dates_table, 'cal_id,cal_start', array(
402
+				foreach ($this->db->select($this->dates_table, 'cal_id,cal_start', array(
403 403
 					'cal_id' => $ids,
404 404
 					'recur_exception' => true,
405 405
 				), __LINE__, __FILE__, false, 'ORDER BY cal_id,cal_start', 'calendar') as $row)
406 406
 				{
407 407
 					$events[$row['cal_id']]['recur_exception'][] = $row['cal_start'];
408 408
 				}
409
-				break;	// as above select read all exceptions (and I dont think too short uid problem still exists)
409
+				break; // as above select read all exceptions (and I dont think too short uid problem still exists)
410 410
 			}
411 411
 			// make sure we fetch only real exceptions (deleted occurrences of a series should not show up)
412
-			if (($recur_date &&	$event['recur_type'] != MCAL_RECUR_NONE))
412
+			if (($recur_date && $event['recur_type'] != MCAL_RECUR_NONE))
413 413
 			{
414 414
 				//_debug_array(__METHOD__.__LINE__.' recur_date:'.$recur_date.' check cal_start:'.$event['start']);
415
-				foreach($this->db->select($this->dates_table, 'cal_id,cal_start', array(
415
+				foreach ($this->db->select($this->dates_table, 'cal_id,cal_start', array(
416 416
 					'cal_id' => $event['id'],
417 417
 					'cal_start' => $event['start'],
418 418
 					'recur_exception' => true,
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
 						'cal_deleted' => NULL
429 429
 					), __LINE__, __FILE__, false, '', 'calendar')->fetchColumn())
430 430
 					{
431
-						$e = $this->read($event['id'],$event['start']+1);
431
+						$e = $this->read($event['id'], $event['start'] + 1);
432 432
 						$event = $e[$event['id']];
433 433
 						break;
434 434
 					}
@@ -450,21 +450,21 @@  discard block
 block discarded – undo
450 450
 			if ($recur_date)
451 451
 			{
452 452
 				// also remember recur_date, maybe we need it later, duno now
453
-				$recur_date = array(0,$events[$ids]['recur_date'] = $events[$ids]['start']);
453
+				$recur_date = array(0, $events[$ids]['recur_date'] = $events[$ids]['start']);
454 454
 			}
455 455
 		}
456 456
 
457 457
 		// participants, if a recur_date give, we read that recurance, plus the one users from the default entry with recur_date=0
458 458
 		// sorting by cal_recur_date ASC makes sure recurence status always overwrites series status
459
-		foreach($this->db->select($this->user_table,'*',array(
459
+		foreach ($this->db->select($this->user_table, '*', array(
460 460
 			'cal_id'      => $ids,
461 461
 			'cal_recur_date' => $recur_date,
462 462
 			"cal_status NOT IN ('X','E')",
463
-		),__LINE__,__FILE__,false,'ORDER BY cal_user_type DESC,cal_recur_date ASC,'.self::STATUS_SORT,'calendar') as $row)	// DESC puts users before resources and contacts
463
+		), __LINE__, __FILE__, false, 'ORDER BY cal_user_type DESC,cal_recur_date ASC,'.self::STATUS_SORT, 'calendar') as $row)	// DESC puts users before resources and contacts
464 464
 		{
465 465
 			// combine all participant data in uid and status values
466 466
 			$uid    = self::combine_user($row['cal_user_type'], $row['cal_user_id'], $row['cal_user_attendee']);
467
-			$status = self::combine_status($row['cal_status'],$row['cal_quantity'],$row['cal_role']);
467
+			$status = self::combine_status($row['cal_status'], $row['cal_quantity'], $row['cal_role']);
468 468
 
469 469
 			$events[$row['cal_id']]['participants'][$uid] = $status;
470 470
 			$events[$row['cal_id']]['participant_types'][$row['cal_user_type']][is_numeric($uid) ? $uid : substr($uid, 1)] = $status;
@@ -473,7 +473,7 @@  discard block
 block discarded – undo
473 473
 		}
474 474
 
475 475
 		// custom fields
476
-		foreach($this->db->select($this->extra_table,'*',array('cal_id'=>$ids),__LINE__,__FILE__,false,'','calendar') as $row)
476
+		foreach ($this->db->select($this->extra_table, '*', array('cal_id'=>$ids), __LINE__, __FILE__, false, '', 'calendar') as $row)
477 477
 		{
478 478
 			$events[$row['cal_id']]['#'.$row['cal_extra_name']] = $row['cal_extra_value'];
479 479
 		}
@@ -481,7 +481,7 @@  discard block
 block discarded – undo
481 481
 		// alarms
482 482
 		if (is_array($ids))
483 483
 		{
484
-			foreach($this->read_alarms((array)$ids) as $cal_id => $alarms)
484
+			foreach ($this->read_alarms((array)$ids) as $cal_id => $alarms)
485 485
 			{
486 486
 				$events[$cal_id]['alarm'] = $alarms;
487 487
 			}
@@ -510,11 +510,11 @@  discard block
 block discarded – undo
510 510
 	 * @param boolean $master_only =false only check recurance master (egw_cal_user.recur_date=0)
511 511
 	 * @return int maximum modification timestamp
512 512
 	 */
513
-	function get_ctag($users, $owner_too=false,$master_only=false)
513
+	function get_ctag($users, $owner_too = false, $master_only = false)
514 514
 	{
515
-		static $ctags = array();	// some per-request caching
515
+		static $ctags = array(); // some per-request caching
516 516
 		static $last_request = null;
517
-		if (!isset($last_request) || time()-$last_request > self::MAX_CTAG_CACHE_TIME)
517
+		if (!isset($last_request) || time() - $last_request > self::MAX_CTAG_CACHE_TIME)
518 518
 		{
519 519
 			$ctags = array();
520 520
 			$last_request = time();
@@ -523,13 +523,13 @@  discard block
 block discarded – undo
523 523
 		if (isset($ctags[$signature])) return $ctags[$signature];
524 524
 
525 525
 		$types = array();
526
-		foreach((array)$users as $uid)
526
+		foreach ((array)$users as $uid)
527 527
 		{
528 528
 			$type = $id = null;
529 529
 			self::split_user($uid, $type, $id, true);
530 530
 			$types[$type][] = $id;
531 531
 		}
532
-		foreach($types as $type => $ids)
532
+		foreach ($types as $type => $ids)
533 533
 		{
534 534
 			$where = array(
535 535
 				'cal_user_type' => $type,
@@ -551,17 +551,17 @@  discard block
 block discarded – undo
551 551
 		if ($owner_too)
552 552
 		{
553 553
 			// owner can only by users, no groups or resources
554
-			foreach($users as $key => $user)
554
+			foreach ($users as $key => $user)
555 555
 			{
556 556
 				if (!($user > 0)) unset($users[$key]);
557 557
 			}
558 558
 			$where = $this->db->expression($this->user_table, '(', $where, ' OR ').
559 559
 				$this->db->expression($this->cal_table, array(
560 560
 					'cal_owner' => $users,
561
-				),')');
561
+				), ')');
562 562
 		}
563
-		return $ctags[$signature] = $this->db->select($this->user_table,'MAX(cal_modified)',
564
-			$where,__LINE__,__FILE__,false,'','calendar',0,'JOIN egw_cal ON egw_cal.cal_id=egw_cal_user.cal_id')->fetchColumn();
563
+		return $ctags[$signature] = $this->db->select($this->user_table, 'MAX(cal_modified)',
564
+			$where, __LINE__, __FILE__, false, '', 'calendar', 0, 'JOIN egw_cal ON egw_cal.cal_id=egw_cal_user.cal_id')->fetchColumn();
565 565
 	}
566 566
 
567 567
 	/**
@@ -573,7 +573,7 @@  discard block
 block discarded – undo
573 573
 	 * @param string|array $cols ='cal_id,cal_reference,cal_etag,cal_modified,cal_user_modified' cols to query
574 574
 	 * @return Iterator as egw_db::select
575 575
 	 */
576
-	function get_cal_data(array $query, $cols='cal_id,cal_reference,cal_etag,cal_modified,cal_user_modified')
576
+	function get_cal_data(array $query, $cols = 'cal_id,cal_reference,cal_etag,cal_modified,cal_user_modified')
577 577
 	{
578 578
 		if (!is_array($cols)) $cols = explode(',', $cols);
579 579
 
@@ -599,12 +599,12 @@  discard block
 block discarded – undo
599 599
 		if ($cat_id)
600 600
 		{
601 601
 			$cats = $GLOBALS['egw']->categories->return_all_children($cat_id);
602
-			array_walk($cats,create_function('&$val,$key','$val = (int) $val;'));
603
-			if (is_array($cat_id) && count($cat_id)==1) $cat_id = $cat_id[0];
604
-			$sql = '(cal_category'.(count($cats) > 1 ? " IN ('".implode("','",$cats)."')" : '='.$this->db->quote((int)$cat_id));
605
-			foreach($cats as $cat)
602
+			array_walk($cats, create_function('&$val,$key', '$val = (int) $val;'));
603
+			if (is_array($cat_id) && count($cat_id) == 1) $cat_id = $cat_id[0];
604
+			$sql = '(cal_category'.(count($cats) > 1 ? " IN ('".implode("','", $cats)."')" : '='.$this->db->quote((int)$cat_id));
605
+			foreach ($cats as $cat)
606 606
 			{
607
-				$sql .= ' OR '.$this->db->concat("','",'cal_category',"','").' LIKE '.$this->db->quote('%,'.$cat.',%');
607
+				$sql .= ' OR '.$this->db->concat("','", 'cal_category', "','").' LIKE '.$this->db->quote('%,'.$cat.',%');
608 608
 			}
609 609
 			$sql .= ') ';
610 610
 		}
@@ -619,13 +619,13 @@  discard block
 block discarded – undo
619 619
 	 * @param array $where =array() array to add filters too
620 620
 	 * @return array
621 621
 	 */
622
-	protected function status_filter($filter, $enum_recuring=true, array $where=array())
622
+	protected function status_filter($filter, $enum_recuring = true, array $where = array())
623 623
 	{
624
-		if($filter != 'deleted' && $filter != 'everything')
624
+		if ($filter != 'deleted' && $filter != 'everything')
625 625
 		{
626 626
 			$where[] = 'cal_deleted IS NULL';
627 627
 		}
628
-		switch($filter)
628
+		switch ($filter)
629 629
 		{
630 630
 			case 'everything':	// no filter at all
631 631
 				break;
@@ -699,7 +699,7 @@  discard block
 block discarded – undo
699 699
 	 * @param int $remove_rejected_by_user =null add join to remove entry, if given user has rejected it
700 700
 	 * @return Iterator|array of events
701 701
 	 */
702
-	function &search($start,$end,$users,$cat_id=0,$filter='all',$offset=False,$num_rows=0,array $params=array(),$remove_rejected_by_user=null)
702
+	function &search($start, $end, $users, $cat_id = 0, $filter = 'all', $offset = False, $num_rows = 0, array $params = array(), $remove_rejected_by_user = null)
703 703
 	{
704 704
 		//error_log(__METHOD__.'('.($start ? date('Y-m-d H:i',$start) : '').','.($end ? date('Y-m-d H:i',$end) : '').','.array2string($users).','.array2string($cat_id).",'$filter',".array2string($offset).",$num_rows,".array2string($params).') '.function_backtrace());
705 705
 
@@ -722,7 +722,7 @@  discard block
 block discarded – undo
722 722
 		{
723 723
 			$all_cols = self::get_columns('calendar', $this->cal_table);
724 724
 			$all_cols[0] = $this->db->to_varchar($this->cal_table.'.cal_id');
725
-			$cols = "$this->repeats_table.recur_type,$this->repeats_table.recur_interval,$this->repeats_table.recur_data,range_end AS recur_enddate,".implode(',',$all_cols).",cal_start,cal_end,$this->user_table.cal_recur_date";
725
+			$cols = "$this->repeats_table.recur_type,$this->repeats_table.recur_interval,$this->repeats_table.recur_data,range_end AS recur_enddate,".implode(',', $all_cols).",cal_start,cal_end,$this->user_table.cal_recur_date";
726 726
 		}
727 727
 		$where = array();
728 728
 		if (is_array($params['query']))
@@ -731,19 +731,19 @@  discard block
 block discarded – undo
731 731
 		}
732 732
 		elseif ($params['query'])
733 733
 		{
734
-			foreach(array('cal_title','cal_description','cal_location') as $col)
734
+			foreach (array('cal_title', 'cal_description', 'cal_location') as $col)
735 735
 			{
736 736
 				$to_or[] = $col.' '.$this->db->capabilities[egw_db::CAPABILITY_CASE_INSENSITIV_LIKE].' '.$this->db->quote('%'.$params['query'].'%');
737 737
 			}
738
-			$where[] = '('.implode(' OR ',$to_or).')';
738
+			$where[] = '('.implode(' OR ', $to_or).')';
739 739
 
740 740
 			// Searching - restrict private to own or private grant
741 741
 			if (!isset($params['private_grants']))
742 742
 			{
743 743
 				$params['private_grants'] = $GLOBALS['egw']->acl->get_ids_for_location($GLOBALS['egw_info']['user']['account_id'], EGW_ACL_PRIVATE, 'calendar');
744
-				$params['private_grants'][] = $GLOBALS['egw_info']['user']['account_id'];	// db query does NOT return current user
744
+				$params['private_grants'][] = $GLOBALS['egw_info']['user']['account_id']; // db query does NOT return current user
745 745
 			}
746
-			$private_filter = '(cal_public=1 OR cal_public=0 AND '.$this->db->expression($this->cal_table, array('cal_owner' => $params['private_grants'])) . ')';
746
+			$private_filter = '(cal_public=1 OR cal_public=0 AND '.$this->db->expression($this->cal_table, array('cal_owner' => $params['private_grants'])).')';
747 747
 			$where[] = $private_filter;
748 748
 		}
749 749
 		if (!empty($params['sql_filter']))
@@ -752,7 +752,7 @@  discard block
 block discarded – undo
752 752
 			{
753 753
 				$where[] = $params['sql_filter'];
754 754
 			}
755
-			elseif(is_array($params['sql_filter']))
755
+			elseif (is_array($params['sql_filter']))
756 756
 			{
757 757
 				$where = array_merge($where, $params['sql_filter']);
758 758
 			}
@@ -760,11 +760,11 @@  discard block
 block discarded – undo
760 760
 		if ($users)
761 761
 		{
762 762
 			$users_by_type = array();
763
-			foreach((array)$users as $user)
763
+			foreach ((array)$users as $user)
764 764
 			{
765 765
 				if (is_numeric($user))
766 766
 				{
767
-					$users_by_type['u'][] = (int) $user;
767
+					$users_by_type['u'][] = (int)$user;
768 768
 				}
769 769
 				else
770 770
 				{
@@ -776,45 +776,45 @@  discard block
 block discarded – undo
776 776
 			$to_or = $user_or = array();
777 777
 			$owner_or = null;
778 778
 			$useUnionQuery = $this->db->capabilities['distinct_on_text'] && $this->db->capabilities['union'];
779
-			$table_def = $this->db->get_table_definitions('calendar',$this->user_table);
780
-			foreach($users_by_type as $type => $ids)
779
+			$table_def = $this->db->get_table_definitions('calendar', $this->user_table);
780
+			foreach ($users_by_type as $type => $ids)
781 781
 			{
782 782
 				// when we are able to use Union Querys, we do not OR our query, we save the needed parts for later construction of the union
783 783
 				if ($useUnionQuery)
784 784
 				{
785
-					$user_or[] = $this->db->expression($table_def,$this->user_table.'.',array(
785
+					$user_or[] = $this->db->expression($table_def, $this->user_table.'.', array(
786 786
 						'cal_user_type' => $type,
787
-					),' AND '.$this->user_table.'.',array(
787
+					), ' AND '.$this->user_table.'.', array(
788 788
 						'cal_user_id'   => $ids,
789 789
 					));
790 790
 					if ($type == 'u' && $filter == 'owner')
791 791
 					{
792
-						$cal_table_def = $this->db->get_table_definitions('calendar',$this->cal_table);
792
+						$cal_table_def = $this->db->get_table_definitions('calendar', $this->cal_table);
793 793
 						// only users can be owners, no need to add groups
794 794
 						$user_ids = array();
795
-						foreach($ids as $user_id)
795
+						foreach ($ids as $user_id)
796 796
 						{
797 797
 							if ($GLOBALS['egw']->accounts->get_type($user_id) === 'u') $user_ids[] = $user_id;
798 798
 						}
799
-						$owner_or = $this->db->expression($cal_table_def,array('cal_owner' => $user_ids));
799
+						$owner_or = $this->db->expression($cal_table_def, array('cal_owner' => $user_ids));
800 800
 					}
801 801
 				}
802 802
 				else
803 803
 				{
804
-					$to_or[] = $this->db->expression($table_def,$this->user_table.'.',array(
804
+					$to_or[] = $this->db->expression($table_def, $this->user_table.'.', array(
805 805
 						'cal_user_type' => $type,
806
-					),' AND '.$this->user_table.'.',array(
806
+					), ' AND '.$this->user_table.'.', array(
807 807
 						'cal_user_id'   => $ids,
808 808
 					));
809 809
 					if ($type == 'u' && $filter == 'owner')
810 810
 					{
811
-						$cal_table_def = $this->db->get_table_definitions('calendar',$this->cal_table);
812
-						$to_or[] = $this->db->expression($cal_table_def,array('cal_owner' => $ids));
811
+						$cal_table_def = $this->db->get_table_definitions('calendar', $this->cal_table);
812
+						$to_or[] = $this->db->expression($cal_table_def, array('cal_owner' => $ids));
813 813
 					}
814 814
 				}
815 815
 			}
816 816
 			// this is only used, when we cannot use UNIONS
817
-			if (!$useUnionQuery) $where[] = '('.implode(' OR ',$to_or).')';
817
+			if (!$useUnionQuery) $where[] = '('.implode(' OR ', $to_or).')';
818 818
 
819 819
 			$where = $this->status_filter($filter, $params['enum_recuring'], $where);
820 820
 		}
@@ -833,15 +833,15 @@  discard block
 block discarded – undo
833 833
 				$where[] = '('.((int)$start).' < range_end OR range_end IS NULL)';
834 834
 			}
835 835
 		}
836
-		if (!preg_match('/^[a-z_ ,c]+$/i',$params['order'])) $params['order'] = 'cal_start';		// gard against SQL injection
836
+		if (!preg_match('/^[a-z_ ,c]+$/i', $params['order'])) $params['order'] = 'cal_start'; // gard against SQL injection
837 837
 
838 838
 		// if not enum recuring events, we have to use minimum start- AND end-dates, otherwise we get more then one event per cal_id!
839 839
 		if (!$params['enum_recuring'])
840 840
 		{
841 841
 			$where[] = "$this->user_table.cal_recur_date=0";
842
-			$cols = str_replace(array('cal_start','cal_end'),array('range_start AS cal_start','(SELECT MIN(cal_end) FROM egw_cal_dates WHERE egw_cal.cal_id=egw_cal_dates.cal_id) AS cal_end'),$cols);
842
+			$cols = str_replace(array('cal_start', 'cal_end'), array('range_start AS cal_start', '(SELECT MIN(cal_end) FROM egw_cal_dates WHERE egw_cal.cal_id=egw_cal_dates.cal_id) AS cal_end'), $cols);
843 843
 			// in case cal_start is used in a query, eg. calendar_ical::find_event
844
-			$where = str_replace(array('cal_start','cal_end'), array('range_start','(SELECT MIN(cal_end) FROM egw_cal_dates WHERE egw_cal.cal_id=egw_cal_dates.cal_id)'), $where);
844
+			$where = str_replace(array('cal_start', 'cal_end'), array('range_start', '(SELECT MIN(cal_end) FROM egw_cal_dates WHERE egw_cal.cal_id=egw_cal_dates.cal_id)'), $where);
845 845
 			$params['order'] = str_replace('cal_start', 'range_start', $params['order']);
846 846
 			if ($end) $where[] = (int)$end.' > range_start';
847 847
   		}
@@ -853,14 +853,13 @@  discard block
 block discarded – undo
853 853
 				" ON $this->cal_table.cal_id=rejected_by_user.cal_id".
854 854
 				" AND rejected_by_user.cal_user_type='u'".
855 855
 				" AND rejected_by_user.cal_user_id=".$this->db->quote($remove_rejected_by_user).
856
-				" AND ".(!$params['enum_recuring'] ? 'rejected_by_user.cal_recur_date=0' :
857
-					'(recur_type IS NULL AND rejected_by_user.cal_recur_date=0 OR cal_start=rejected_by_user.cal_recur_date)');
856
+				" AND ".(!$params['enum_recuring'] ? 'rejected_by_user.cal_recur_date=0' : '(recur_type IS NULL AND rejected_by_user.cal_recur_date=0 OR cal_start=rejected_by_user.cal_recur_date)');
858 857
 			$or_required = array(
859 858
 				'rejected_by_user.cal_status IS NULL',
860 859
 				"rejected_by_user.cal_status NOT IN ('R','X')",
861 860
 			);
862 861
 			if ($filter == 'owner') $or_required[] = 'cal_owner='.(int)$remove_rejected_by_user;
863
-			$where[] = '('.implode(' OR ',$or_required).')';
862
+			$where[] = '('.implode(' OR ', $or_required).')';
864 863
 		}
865 864
 		// using a time-range and deleted attribute limited view instead of full table
866 865
 		$cal_table = $this->cal_range_view($start, $end, null, $filter == 'everything' ? null : $filter != 'deleted');
@@ -872,7 +871,7 @@  discard block
 block discarded – undo
872 871
 		// dates table join only needed to enum recuring events, we use a time-range limited view here too
873 872
 		if ($params['enum_recuring'])
874 873
 		{
875
-			$join = "JOIN ".$this->dates_table.	// using dates_table direct seems quicker then an other view
874
+			$join = "JOIN ".$this->dates_table.// using dates_table direct seems quicker then an other view
876 875
 				//$this->dates_range_view($start, $end, null, $filter == 'everything' ? null : $filter == 'deleted').
877 876
 				" ON $this->cal_table.cal_id=$this->dates_table.cal_id ".$join;
878 877
 		}
@@ -899,29 +898,29 @@  discard block
 block discarded – undo
899 898
 			// as replace the OR by construction of a suitable UNION for performance reasons
900 899
 			if ($owner_or || $user_or)
901 900
 			{
902
-				foreach($user_or as $user_sql)
901
+				foreach ($user_or as $user_sql)
903 902
 				{
904 903
 					$selects[] = $select;
905
-					$selects[count($selects)-1]['where'][] = $user_sql;
904
+					$selects[count($selects) - 1]['where'][] = $user_sql;
906 905
 					if ($params['enum_recuring'])
907 906
 					{
908
-						$selects[count($selects)-1]['where'][] = "recur_type IS NULL AND $this->user_table.cal_recur_date=0";
907
+						$selects[count($selects) - 1]['where'][] = "recur_type IS NULL AND $this->user_table.cal_recur_date=0";
909 908
 						$selects[] = $select;
910
-						$selects[count($selects)-1]['where'][] = $user_sql;
911
-						$selects[count($selects)-1]['where'][] = "$this->user_table.cal_recur_date=cal_start";
909
+						$selects[count($selects) - 1]['where'][] = $user_sql;
910
+						$selects[count($selects) - 1]['where'][] = "$this->user_table.cal_recur_date=cal_start";
912 911
 					}
913 912
 				}
914 913
 				// if the query is to be filtered by owner we need to add more selects for the union
915 914
 				if ($owner_or)
916 915
 				{
917 916
 					$selects[] = $select;
918
-					$selects[count($selects)-1]['where'][] = $owner_or;
917
+					$selects[count($selects) - 1]['where'][] = $owner_or;
919 918
 					if ($params['enum_recuring'])
920 919
 					{
921
-						$selects[count($selects)-1]['where'][] = "recur_type IS NULL AND $this->user_table.cal_recur_date=0";
920
+						$selects[count($selects) - 1]['where'][] = "recur_type IS NULL AND $this->user_table.cal_recur_date=0";
922 921
 						$selects[] = $select;
923
-						$selects[count($selects)-1]['where'][] = $owner_or;
924
-						$selects[count($selects)-1]['where'][] = "$this->user_table.cal_recur_date=cal_start";
922
+						$selects[count($selects) - 1]['where'][] = $owner_or;
923
+						$selects[count($selects) - 1]['where'][] = "$this->user_table.cal_recur_date=cal_start";
925 924
 					}
926 925
 				}
927 926
 			}
@@ -931,34 +930,34 @@  discard block
 block discarded – undo
931 930
 				$selects[] = $select;
932 931
 				if ($params['enum_recuring'])
933 932
 				{
934
-					$selects[count($selects)-1]['where'][] = "recur_type IS NULL AND $this->user_table.cal_recur_date=0";
933
+					$selects[count($selects) - 1]['where'][] = "recur_type IS NULL AND $this->user_table.cal_recur_date=0";
935 934
 					$selects[] = $select;
936
-					$selects[count($selects)-1]['where'][] = "$this->user_table.cal_recur_date=cal_start";
935
+					$selects[count($selects) - 1]['where'][] = "$this->user_table.cal_recur_date=cal_start";
937 936
 				}
938 937
 			}
939 938
 			if (is_numeric($offset) && !$params['no_total'])	// get the total too
940 939
 			{
941 940
 				$save_selects = $selects;
942 941
 				// we only select cal_table.cal_id (and not cal_table.*) to be able to use DISTINCT (eg. MsSQL does not allow it for text-columns)
943
-				foreach(array_keys($selects) as $key)
942
+				foreach (array_keys($selects) as $key)
944 943
 				{
945 944
 					$selects[$key]['cols'] = "DISTINCT $this->repeats_table.recur_type,range_end AS recur_enddate,$this->repeats_table.recur_interval,$this->repeats_table.recur_data,".$this->db->to_varchar($this->cal_table.'.cal_id').",cal_start,cal_end,$this->user_table.cal_recur_date";
946 945
 					if (!$params['enum_recuring'])
947 946
 					{
948
-						$selects[$key]['cols'] = str_replace(array('cal_start','cal_end'),
949
-							array('range_start AS cal_start','range_end AS cal_end'), $selects[$key]['cols']);
947
+						$selects[$key]['cols'] = str_replace(array('cal_start', 'cal_end'),
948
+							array('range_start AS cal_start', 'range_end AS cal_end'), $selects[$key]['cols']);
950 949
 					}
951 950
 				}
952
-				if (!isset($params['cols']) && !$params['no_integration']) self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']);
951
+				if (!isset($params['cols']) && !$params['no_integration']) self::get_union_selects($selects, $start, $end, $users, $cat_id, $filter, $params['query'], $params['users']);
953 952
 
954
-				$this->total = $this->db->union($selects,__LINE__,__FILE__)->NumRows();
953
+				$this->total = $this->db->union($selects, __LINE__, __FILE__)->NumRows();
955 954
 
956 955
 				// restore original cols / selects
957 956
 				$selects = $save_selects; unset($save_selects);
958 957
 			}
959
-			if (!isset($params['cols']) && !$params['no_integration']) self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']);
958
+			if (!isset($params['cols']) && !$params['no_integration']) self::get_union_selects($selects, $start, $end, $users, $cat_id, $filter, $params['query'], $params['users']);
960 959
 
961
-			$rs = $this->db->union($selects,__LINE__,__FILE__,$params['order'],$offset,$num_rows);
960
+			$rs = $this->db->union($selects, __LINE__, __FILE__, $params['order'], $offset, $num_rows);
962 961
 		}
963 962
 		else	// MsSQL oder MySQL 3.23
964 963
 		{
@@ -981,27 +980,27 @@  discard block
 block discarded – undo
981 980
 				$selects[0]['cols'] = "$this->cal_table.cal_id,cal_start";
982 981
 				if (!isset($params['cols']) && !$params['no_integration'] && $this->db->capabilities['union'])
983 982
 				{
984
-					self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']);
983
+					self::get_union_selects($selects, $start, $end, $users, $cat_id, $filter, $params['query'], $params['users']);
985 984
 				}
986 985
 				$this->total = $this->db->union($selects, __LINE__, __FILE__)->NumRows();
987 986
 				$selects = $save_selects;
988 987
 			}
989 988
 			if (!isset($params['cols']) && !$params['no_integration'] && $this->db->capabilities['union'])
990 989
 			{
991
-				self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']);
990
+				self::get_union_selects($selects, $start, $end, $users, $cat_id, $filter, $params['query'], $params['users']);
992 991
 			}
993
-			$rs = $this->db->union($selects,__LINE__,__FILE__,$params['order'],$offset,$num_rows);
992
+			$rs = $this->db->union($selects, __LINE__, __FILE__, $params['order'], $offset, $num_rows);
994 993
 		}
995 994
 		//error_log(__METHOD__."() useUnionQuery=$useUnionQuery --> query took ".(microtime(true)-$starttime).'s '.$rs->sql);
996 995
 
997 996
 		if (isset($params['cols']))
998 997
 		{
999
-			return $rs;	// if colums are specified we return the recordset / iterator
998
+			return $rs; // if colums are specified we return the recordset / iterator
1000 999
 		}
1001 1000
 		// Todo: return $this->get_events($rs);
1002 1001
 
1003 1002
 		$events = $ids = $recur_dates = $recur_ids = array();
1004
-		foreach($rs as $row)
1003
+		foreach ($rs as $row)
1005 1004
 		{
1006 1005
 			$id = $row['cal_id'];
1007 1006
 			if (is_numeric($id)) $ids[] = $id;
@@ -1013,9 +1012,9 @@  discard block
 block discarded – undo
1013 1012
 			}
1014 1013
 			if ($row['participants'])
1015 1014
 			{
1016
-				$row['participants'] = explode(',',$row['participants']);
1015
+				$row['participants'] = explode(',', $row['participants']);
1017 1016
 				$row['participants'] = array_combine($row['participants'],
1018
-					array_fill(0,count($row['participants']),''));
1017
+					array_fill(0, count($row['participants']), ''));
1019 1018
 			}
1020 1019
 			else
1021 1020
 			{
@@ -1024,9 +1023,9 @@  discard block
 block discarded – undo
1024 1023
 			$row['recur_exception'] = $row['alarm'] = array();
1025 1024
 
1026 1025
 			// compile a list of recurrences per cal_id
1027
-			if (!in_array($id,(array)$recur_ids[$row['cal_id']])) $recur_ids[$row['cal_id']][] = $id;
1026
+			if (!in_array($id, (array)$recur_ids[$row['cal_id']])) $recur_ids[$row['cal_id']][] = $id;
1028 1027
 
1029
-			$events[$id] = egw_db::strip_array_keys($row,'cal_');
1028
+			$events[$id] = egw_db::strip_array_keys($row, 'cal_');
1030 1029
 		}
1031 1030
 		//_debug_array($events);
1032 1031
 		if (count($ids))
@@ -1036,26 +1035,26 @@  discard block
 block discarded – undo
1036 1035
 			// now ready all users with the given cal_id AND (cal_recur_date=0 or the fitting recur-date)
1037 1036
 			// This will always read the first entry of each recuring event too, we eliminate it later
1038 1037
 			$recur_dates[] = 0;
1039
-			$utcal_id_view = " (SELECT * FROM ".$this->user_table." WHERE cal_id IN (".implode(',',$ids).")".
1038
+			$utcal_id_view = " (SELECT * FROM ".$this->user_table." WHERE cal_id IN (".implode(',', $ids).")".
1040 1039
 				($filter != 'everything' ? " AND cal_status NOT IN ('X','E')" : '').") utcalid ";
1041 1040
 			//$utrecurdate_view = " (select * from ".$this->user_table." where cal_recur_date in (".implode(',',array_unique($recur_dates)).")) utrecurdates ";
1042
-			foreach($this->db->select($utcal_id_view,'*',array(
1041
+			foreach ($this->db->select($utcal_id_view, '*', array(
1043 1042
 					//'cal_id' => array_unique($ids),
1044 1043
 					'cal_recur_date' => $recur_dates,
1045
-				),__LINE__,__FILE__,false,'ORDER BY cal_id,cal_user_type DESC,'.self::STATUS_SORT,'calendar',$num_rows,$join='',
1046
-				$this->db->get_table_definitions('calendar',$this->user_table)) as $row)	// DESC puts users before resources and contacts
1044
+				), __LINE__, __FILE__, false, 'ORDER BY cal_id,cal_user_type DESC,'.self::STATUS_SORT, 'calendar', $num_rows, $join = '',
1045
+				$this->db->get_table_definitions('calendar', $this->user_table)) as $row)	// DESC puts users before resources and contacts
1047 1046
 			{
1048 1047
 				$id = $row['cal_id'];
1049 1048
 				if ($row['cal_recur_date']) $id .= '-'.$row['cal_recur_date'];
1050 1049
 
1051 1050
 				// combine all participant data in uid and status values
1052 1051
 				$uid = self::combine_user($row['cal_user_type'], $row['cal_user_id'], $row['cal_user_attendee']);
1053
-				$status = self::combine_status($row['cal_status'],$row['cal_quantity'],$row['cal_role']);
1052
+				$status = self::combine_status($row['cal_status'], $row['cal_quantity'], $row['cal_role']);
1054 1053
 
1055 1054
 				// set accept/reject/tentative of series for all recurrences
1056 1055
 				if (!$row['cal_recur_date'])
1057 1056
 				{
1058
-					foreach((array)$recur_ids[$row['cal_id']] as $i)
1057
+					foreach ((array)$recur_ids[$row['cal_id']] as $i)
1059 1058
 					{
1060 1059
 						if (isset($events[$i]) && !isset($events[$i]['participants'][$uid]))
1061 1060
 						{
@@ -1070,16 +1069,16 @@  discard block
 block discarded – undo
1070 1069
 			// query recurrance exceptions, if needed: enum_recuring && !daywise is used in calendar_groupdav::get_series($uid,...)
1071 1070
 			if (!$params['enum_recuring'] || !$params['daywise'])
1072 1071
 			{
1073
-				foreach($this->db->select($this->dates_table, 'cal_id,cal_start', array(
1072
+				foreach ($this->db->select($this->dates_table, 'cal_id,cal_start', array(
1074 1073
 					'cal_id' => $ids,
1075 1074
 					'recur_exception' => true,
1076 1075
 				), __LINE__, __FILE__, false, 'ORDER BY cal_id,cal_start', 'calendar') as $row)
1077 1076
 				{
1078 1077
 					// for enum_recurring events are not indexed by cal_id, but $cal_id.'-'.$cal_start
1079 1078
 					// find master, which is first recurrence
1080
-					if (!isset($events[$id=$row['cal_id']]))
1079
+					if (!isset($events[$id = $row['cal_id']]))
1081 1080
 					{
1082
-						foreach($events as $id => $event)
1081
+						foreach ($events as $id => $event)
1083 1082
 						{
1084 1083
 							if ($event['id'] == $row['cal_id']) break;
1085 1084
 						}
@@ -1092,10 +1091,10 @@  discard block
 block discarded – undo
1092 1091
 			{
1093 1092
 				$where = array('cal_id' => $ids);
1094 1093
 				if ($params['cfs']) $where['cal_extra_name'] = $params['cfs'];
1095
-				foreach($this->db->select($this->extra_table,'*',$where,
1096
-					__LINE__,__FILE__,false,'','calendar') as $row)
1094
+				foreach ($this->db->select($this->extra_table, '*', $where,
1095
+					__LINE__, __FILE__, false, '', 'calendar') as $row)
1097 1096
 				{
1098
-					foreach((array)$recur_ids[$row['cal_id']] as $id)
1097
+					foreach ((array)$recur_ids[$row['cal_id']] as $id)
1099 1098
 					{
1100 1099
 						if (isset($events[$id]))
1101 1100
 						{
@@ -1105,9 +1104,9 @@  discard block
 block discarded – undo
1105 1104
 				}
1106 1105
 			}
1107 1106
 			// alarms
1108
-			foreach($this->read_alarms($ids) as $cal_id => $alarms)
1107
+			foreach ($this->read_alarms($ids) as $cal_id => $alarms)
1109 1108
 			{
1110
-				foreach($alarms as $id => $alarm)
1109
+				foreach ($alarms as $id => $alarm)
1111 1110
 				{
1112 1111
 					$event_start = $alarm['time'] + $alarm['offset'];
1113 1112
 
@@ -1144,16 +1143,16 @@  discard block
 block discarded – undo
1144 1143
 	 * @param $query
1145 1144
 	 * @param $users_raw as passed to calendar_bo::search (no members and memberships added)
1146 1145
 	 */
1147
-	private static function get_union_selects(array &$selects,$start,$end,$users,$cat_id,$filter,$query,$users_raw)
1146
+	private static function get_union_selects(array &$selects, $start, $end, $users, $cat_id, $filter, $query, $users_raw)
1148 1147
 	{
1149
-		if (in_array(basename($_SERVER['SCRIPT_FILENAME']),array('groupdav.php','rpc.php','xmlrpc.php','/activesync/index.php')) ||
1150
-			!in_array($GLOBALS['egw_info']['flags']['currentapp'],array('calendar','home')))
1148
+		if (in_array(basename($_SERVER['SCRIPT_FILENAME']), array('groupdav.php', 'rpc.php', 'xmlrpc.php', '/activesync/index.php')) ||
1149
+			!in_array($GLOBALS['egw_info']['flags']['currentapp'], array('calendar', 'home')))
1151 1150
 		{
1152
-			return;    // disable integration for GroupDAV, SyncML, ...
1151
+			return; // disable integration for GroupDAV, SyncML, ...
1153 1152
 		}
1154 1153
 		self::$integration_data = $GLOBALS['egw']->hooks->process(array(
1155 1154
 			'location' => 'calendar_search_union',
1156
-			'cols'  => $selects[0]['cols'],    // cols to return
1155
+			'cols'  => $selects[0]['cols'], // cols to return
1157 1156
 			'start' => $start,
1158 1157
 			'end'   => $end,
1159 1158
 			'users' => $users,
@@ -1162,12 +1161,12 @@  discard block
 block discarded – undo
1162 1161
 			'filter'=> $filter,
1163 1162
 			'query' => $query,
1164 1163
 		));
1165
-		foreach(self::$integration_data as $data)
1164
+		foreach (self::$integration_data as $data)
1166 1165
 		{
1167 1166
 			if (is_array($data['selects']))
1168 1167
 			{
1169 1168
 				//echo $app; _debug_array($data);
1170
-				$selects = array_merge($selects,$data['selects']);
1169
+				$selects = array_merge($selects, $data['selects']);
1171 1170
 			}
1172 1171
 		}
1173 1172
 	}
@@ -1192,35 +1191,35 @@  discard block
 block discarded – undo
1192 1191
 	 * @param string $required_app ='calendar'
1193 1192
 	 * @return string cols for union query to match ones supplied in $required
1194 1193
 	 */
1195
-	public static function union_cols(array $app_cols,$required,$required_app='calendar')
1194
+	public static function union_cols(array $app_cols, $required, $required_app = 'calendar')
1196 1195
 	{
1197 1196
 		// remove evtl. used DISTINCT, we currently dont need it
1198
-		if (($distinct = substr($required,0,9) == 'DISTINCT '))
1197
+		if (($distinct = substr($required, 0, 9) == 'DISTINCT '))
1199 1198
 		{
1200
-			$required = substr($required,9);
1199
+			$required = substr($required, 9);
1201 1200
 		}
1202 1201
 		$return_cols = array();
1203
-		foreach(is_array($required) ? $required : explode(',',$required) as $cols)
1202
+		foreach (is_array($required) ? $required : explode(',', $required) as $cols)
1204 1203
 		{
1205 1204
 			$matches = null;
1206
-			if (substr($cols,-2) == '.*')
1205
+			if (substr($cols, -2) == '.*')
1207 1206
 			{
1208
-				$cols = self::get_columns($required_app,substr($cols,0,-2));
1207
+				$cols = self::get_columns($required_app, substr($cols, 0, -2));
1209 1208
 			}
1210 1209
 			// remove CAST added for PostgreSQL from eg. "CAST(egw_cal.cal_id AS varchar)"
1211 1210
 			elseif (preg_match('/CAST\(([a-z0-9_.]+) AS [a-z0-9_]+\)/i', $cols, $matches))
1212 1211
 			{
1213 1212
 				$cols = $matches[1];
1214 1213
 			}
1215
-			elseif (strpos($cols,' AS ') !== false)
1214
+			elseif (strpos($cols, ' AS ') !== false)
1216 1215
 			{
1217
-				list(,$cols) = explode(' AS ',$cols);
1216
+				list(,$cols) = explode(' AS ', $cols);
1218 1217
 			}
1219
-			foreach((array)$cols as $col)
1218
+			foreach ((array)$cols as $col)
1220 1219
 			{
1221
-				if (substr($col,0,7) == 'egw_cal')	// remove table name
1220
+				if (substr($col, 0, 7) == 'egw_cal')	// remove table name
1222 1221
 				{
1223
-					$col = preg_replace('/^egw_cal[a-z_]*\./','',$col);
1222
+					$col = preg_replace('/^egw_cal[a-z_]*\./', '', $col);
1224 1223
 				}
1225 1224
 				if (isset($app_cols[$col]))
1226 1225
 				{
@@ -1233,7 +1232,7 @@  discard block
 block discarded – undo
1233 1232
 			}
1234 1233
 		}
1235 1234
 		//error_log(__METHOD__."(".array2string($app_cols).", ".array2string($required).", '$required_app') returning ".array2string(implode(',',$return_cols)));
1236
-		return implode(',',$return_cols);
1235
+		return implode(',', $return_cols);
1237 1236
 	}
1238 1237
 
1239 1238
 	/**
@@ -1243,21 +1242,21 @@  discard block
 block discarded – undo
1243 1242
 	 * @param string $table
1244 1243
 	 * @return array of column names
1245 1244
 	 */
1246
-	static private function get_columns($app,$table)
1245
+	static private function get_columns($app, $table)
1247 1246
 	{
1248 1247
 		if ($table != 'egw_cal')
1249 1248
 		{
1250
-			$table_def = $GLOBALS['egw']->db->get_table_definitions($app,$table);
1249
+			$table_def = $GLOBALS['egw']->db->get_table_definitions($app, $table);
1251 1250
 			$cols = array_keys($table_def['fd']);
1252 1251
 		}
1253 1252
 		else
1254 1253
 		{
1255 1254
 			// special handling for egw_cal, as old databases have a different column order!!!
1256
-			$cols =& egw_cache::getSession(__CLASS__,$table);
1255
+			$cols = & egw_cache::getSession(__CLASS__, $table);
1257 1256
 
1258 1257
 			if (is_null($cols))
1259 1258
 			{
1260
-				$meta = $GLOBALS['egw']->db->metadata($table,true);
1259
+				$meta = $GLOBALS['egw']->db->metadata($table, true);
1261 1260
 				$cols = array_keys($meta['meta']);
1262 1261
 			}
1263 1262
 		}
@@ -1310,12 +1309,12 @@  discard block
 block discarded – undo
1310 1309
 	 * @param int &$etag etag=null etag to check or null, on return new etag
1311 1310
 	 * @return boolean|int false on error, 0 if etag does not match, cal_id otherwise
1312 1311
 	 */
1313
-	function save($event,&$set_recurrences,&$set_recurrences_start=0,$change_since=0,&$etag=null)
1312
+	function save($event, &$set_recurrences, &$set_recurrences_start = 0, $change_since = 0, &$etag = null)
1314 1313
 	{
1315 1314
 		if (isset($GLOBALS['egw_info']['user']['preferences']['syncml']['minimum_uid_length']))
1316 1315
 		{
1317 1316
 			$minimum_uid_length = $GLOBALS['egw_info']['user']['preferences']['syncml']['minimum_uid_length'];
1318
-			if (empty($minimum_uid_length) || $minimum_uid_length<=1) $minimum_uid_length = 8; // we just do not accept no uid, or uid way to short!
1317
+			if (empty($minimum_uid_length) || $minimum_uid_length <= 1) $minimum_uid_length = 8; // we just do not accept no uid, or uid way to short!
1319 1318
 		}
1320 1319
 		else
1321 1320
 		{
@@ -1326,7 +1325,7 @@  discard block
 block discarded – undo
1326 1325
 
1327 1326
 		//error_log(__METHOD__.'('.array2string($event).",$set_recurrences,$change_since,$etag) ".function_backtrace());
1328 1327
 
1329
-		$cal_id = (int) $event['id'];
1328
+		$cal_id = (int)$event['id'];
1330 1329
 		unset($event['id']);
1331 1330
 		$set_recurrences = !$cal_id && $event['recur_type'] != MCAL_RECUR_NONE;
1332 1331
 
@@ -1354,9 +1353,9 @@  discard block
 block discarded – undo
1354 1353
 		}
1355 1354
 
1356 1355
 		// add colum prefix 'cal_' if there's not already a 'recur_' prefix
1357
-		foreach($event as $col => $val)
1356
+		foreach ($event as $col => $val)
1358 1357
 		{
1359
-			if ($col[0] != '#' && substr($col,0,6) != 'recur_' && substr($col,0,6) != 'range_' && $col != 'alarm' && $col != 'tz_id' && $col != 'caldav_name')
1358
+			if ($col[0] != '#' && substr($col, 0, 6) != 'recur_' && substr($col, 0, 6) != 'range_' && $col != 'alarm' && $col != 'tz_id' && $col != 'caldav_name')
1360 1359
 			{
1361 1360
 				$event['cal_'.$col] = $val;
1362 1361
 				unset($event[$col]);
@@ -1366,13 +1365,12 @@  discard block
 block discarded – undo
1366 1365
 		if (isset($event['cal_start'])) $event['range_start'] = $event['cal_start'];
1367 1366
 		if (isset($event['cal_end']))
1368 1367
 		{
1369
-			$event['range_end'] = $event['recur_type'] == MCAL_RECUR_NONE ? $event['cal_end'] :
1370
-				($event['recur_enddate'] ? $event['recur_enddate'] : null);
1368
+			$event['range_end'] = $event['recur_type'] == MCAL_RECUR_NONE ? $event['cal_end'] : ($event['recur_enddate'] ? $event['recur_enddate'] : null);
1371 1369
 		}
1372 1370
 		// ensure that we find mathing entries later on
1373 1371
 		if (!is_array($event['cal_category']))
1374 1372
 		{
1375
-			$categories = array_unique(explode(',',$event['cal_category']));
1373
+			$categories = array_unique(explode(',', $event['cal_category']));
1376 1374
 			sort($categories);
1377 1375
 		}
1378 1376
 		else
@@ -1381,7 +1379,7 @@  discard block
 block discarded – undo
1381 1379
 		}
1382 1380
 		sort($categories, SORT_NUMERIC);
1383 1381
 
1384
-		$event['cal_category'] = implode(',',$categories);
1382
+		$event['cal_category'] = implode(',', $categories);
1385 1383
 
1386 1384
 		// make sure recurring events never reference to an other recurrent event
1387 1385
 		if ($event['recur_type'] != MCAL_RECUR_NONE) $event['cal_reference'] = 0;
@@ -1399,18 +1397,18 @@  discard block
 block discarded – undo
1399 1397
 			// read only timezone id, to check if it is changed
1400 1398
 			if ($event['recur_type'] != MCAL_RECUR_NONE)
1401 1399
 			{
1402
-				$old_tz_id = $this->db->select($this->cal_table,'tz_id',$where,__LINE__,__FILE__,'calendar')->fetchColumn();
1400
+				$old_tz_id = $this->db->select($this->cal_table, 'tz_id', $where, __LINE__, __FILE__, 'calendar')->fetchColumn();
1403 1401
 			}
1404 1402
 			if (!is_null($etag)) $where['cal_etag'] = $etag;
1405 1403
 
1406 1404
 			unset($event['cal_etag']);
1407
-			$event[] = 'cal_etag=cal_etag+1';	// always update the etag, even if none given to check
1405
+			$event[] = 'cal_etag=cal_etag+1'; // always update the etag, even if none given to check
1408 1406
 
1409
-			$this->db->update($this->cal_table,$event,$where,__LINE__,__FILE__,'calendar');
1407
+			$this->db->update($this->cal_table, $event, $where, __LINE__, __FILE__, 'calendar');
1410 1408
 
1411 1409
 			if (!is_null($etag) && $this->db->affected_rows() < 1)
1412 1410
 			{
1413
-				return 0;	// wrong etag, someone else updated the entry
1411
+				return 0; // wrong etag, someone else updated the entry
1414 1412
 			}
1415 1413
 			if (!is_null($etag)) ++$etag;
1416 1414
 		}
@@ -1419,10 +1417,10 @@  discard block
 block discarded – undo
1419 1417
 			// new event
1420 1418
 			if (!$event['cal_owner']) $event['cal_owner'] = $GLOBALS['egw_info']['user']['account_id'];
1421 1419
 
1422
-			if (!$event['cal_id'] && !isset($event['cal_uid'])) $event['cal_uid'] = '';	// uid is NOT NULL!
1420
+			if (!$event['cal_id'] && !isset($event['cal_uid'])) $event['cal_uid'] = ''; // uid is NOT NULL!
1423 1421
 
1424
-			$this->db->insert($this->cal_table,$event,false,__LINE__,__FILE__,'calendar');
1425
-			if (!($cal_id = $this->db->get_last_insert_id($this->cal_table,'cal_id')))
1422
+			$this->db->insert($this->cal_table, $event, false, __LINE__, __FILE__, 'calendar');
1423
+			if (!($cal_id = $this->db->get_last_insert_id($this->cal_table, 'cal_id')))
1426 1424
 			{
1427 1425
 				return false;
1428 1426
 			}
@@ -1432,7 +1430,7 @@  discard block
 block discarded – undo
1432 1430
 		// event without uid or not strong enough uid
1433 1431
 		if (!isset($event['cal_uid']) || strlen($event['cal_uid']) < $minimum_uid_length)
1434 1432
 		{
1435
-			$update['cal_uid'] = $event['cal_uid'] = common::generate_uid('calendar',$cal_id);
1433
+			$update['cal_uid'] = $event['cal_uid'] = common::generate_uid('calendar', $cal_id);
1436 1434
 		}
1437 1435
 		// set caldav_name, if not given by caller
1438 1436
 		if (empty($event['caldav_name']) && version_compare($GLOBALS['egw_info']['apps']['calendar']['version'], '1.9.003', '>='))
@@ -1441,37 +1439,37 @@  discard block
 block discarded – undo
1441 1439
 		}
1442 1440
 		if ($update)
1443 1441
 		{
1444
-			$this->db->update($this->cal_table, $update, array('cal_id' => $cal_id),__LINE__,__FILE__,'calendar');
1442
+			$this->db->update($this->cal_table, $update, array('cal_id' => $cal_id), __LINE__, __FILE__, 'calendar');
1445 1443
 		}
1446 1444
 
1447 1445
 		if ($event['recur_type'] == MCAL_RECUR_NONE)
1448 1446
 		{
1449
-			$this->db->delete($this->dates_table,array(
1447
+			$this->db->delete($this->dates_table, array(
1450 1448
 				'cal_id' => $cal_id),
1451
-				__LINE__,__FILE__,'calendar');
1449
+				__LINE__, __FILE__, 'calendar');
1452 1450
 
1453 1451
 			// delete all user-records, with recur-date != 0
1454
-			$this->db->delete($this->user_table,array(
1452
+			$this->db->delete($this->user_table, array(
1455 1453
 				'cal_id' => $cal_id, 'cal_recur_date != 0'),
1456
-				__LINE__,__FILE__,'calendar');
1454
+				__LINE__, __FILE__, 'calendar');
1457 1455
 
1458
-			$this->db->delete($this->repeats_table,array(
1456
+			$this->db->delete($this->repeats_table, array(
1459 1457
 				'cal_id' => $cal_id),
1460
-				__LINE__,__FILE__,'calendar');
1458
+				__LINE__, __FILE__, 'calendar');
1461 1459
 
1462 1460
 			// add exception marker to master, so participants added to exceptions *only* get found
1463 1461
 			if ($event['cal_reference'])
1464 1462
 			{
1465 1463
 				$master_participants = array();
1466
-				foreach($this->db->select($this->user_table, 'cal_user_type,cal_user_id,cal_user_attendee', array(
1464
+				foreach ($this->db->select($this->user_table, 'cal_user_type,cal_user_id,cal_user_attendee', array(
1467 1465
 					'cal_id' => $event['cal_reference'],
1468 1466
 					'cal_recur_date' => 0,
1469
-					"cal_status != 'X'",	// deleted need to be replaced with exception marker too
1467
+					"cal_status != 'X'", // deleted need to be replaced with exception marker too
1470 1468
 				), __LINE__, __FILE__, 'calendar') as $row)
1471 1469
 				{
1472 1470
 					$master_participants[] = self::combine_user($row['cal_user_type'], $row['cal_user_id'], $row['cal_user_attendee']);
1473 1471
 				}
1474
-				foreach(array_diff(array_keys((array)$event['cal_participants']), $master_participants) as $uid)
1472
+				foreach (array_diff(array_keys((array)$event['cal_participants']), $master_participants) as $uid)
1475 1473
 				{
1476 1474
 					$user_type = $user_id = null;
1477 1475
 					self::split_user($uid, $user_type, $user_id, true);
@@ -1490,10 +1488,10 @@  discard block
 block discarded – undo
1490 1488
 		else // write information about recuring event, if recur_type is present in the array
1491 1489
 		{
1492 1490
 			// fetch information about the currently saved (old) event
1493
-			$old_min = (int) $this->db->select($this->dates_table,'MIN(cal_start)',array('cal_id'=>$cal_id),__LINE__,__FILE__,false,'','calendar')->fetchColumn();
1494
-			$old_duration = (int) $this->db->select($this->dates_table,'MIN(cal_end)',array('cal_id'=>$cal_id),__LINE__,__FILE__,false,'','calendar')->fetchColumn() - $old_min;
1491
+			$old_min = (int)$this->db->select($this->dates_table, 'MIN(cal_start)', array('cal_id'=>$cal_id), __LINE__, __FILE__, false, '', 'calendar')->fetchColumn();
1492
+			$old_duration = (int)$this->db->select($this->dates_table, 'MIN(cal_end)', array('cal_id'=>$cal_id), __LINE__, __FILE__, false, '', 'calendar')->fetchColumn() - $old_min;
1495 1493
 			$old_exceptions = array();
1496
-			foreach($this->db->select($this->dates_table, 'cal_start', array(
1494
+			foreach ($this->db->select($this->dates_table, 'cal_start', array(
1497 1495
 				'cal_id' => $cal_id,
1498 1496
 				'recur_exception' => true
1499 1497
 			), __LINE__, __FILE__, false, 'ORDER BY cal_start', 'calendar') as $row)
@@ -1512,8 +1510,8 @@  discard block
 block discarded – undo
1512 1510
 				'cal_recur_date' => 0,
1513 1511
 			);
1514 1512
 			$old_participants = array();
1515
-			foreach ($this->db->select($this->user_table,'cal_user_type,cal_user_id,cal_user_attendee,cal_status,cal_quantity,cal_role', $where,
1516
-				__LINE__,__FILE__,false,'','calendar') as $row)
1513
+			foreach ($this->db->select($this->user_table, 'cal_user_type,cal_user_id,cal_user_attendee,cal_status,cal_quantity,cal_role', $where,
1514
+				__LINE__, __FILE__, false, '', 'calendar') as $row)
1517 1515
 			{
1518 1516
 				$uid = self::combine_user($row['cal_user_type'], $row['cal_user_id'], $row['cal_user_attendee']);
1519 1517
 				$status = self::combine_status($row['cal_status'], $row['cal_quantity'], $row['cal_role']);
@@ -1523,7 +1521,7 @@  discard block
 block discarded – undo
1523 1521
 			// re-check: did so much recurrence data change that we have to rebuild it from scratch?
1524 1522
 			if (!$set_recurrences)
1525 1523
 			{
1526
-				$set_recurrences = (isset($event['cal_start']) && (int)$old_min != (int) $event['cal_start']) ||
1524
+				$set_recurrences = (isset($event['cal_start']) && (int)$old_min != (int)$event['cal_start']) ||
1527 1525
 				    $event['recur_type'] != $old_repeats['recur_type'] || $event['recur_data'] != $old_repeats['recur_data'] ||
1528 1526
 					(int)$event['recur_interval'] != (int)$old_repeats['recur_interval'] || $event['tz_id'] != $old_tz_id;
1529 1527
 			}
@@ -1532,22 +1530,22 @@  discard block
 block discarded – undo
1532 1530
 			{
1533 1531
 				// too much recurrence data has changed, we have to do a rebuild from scratch
1534 1532
 				// delete all, but the lowest dates record
1535
-				$this->db->delete($this->dates_table,array(
1533
+				$this->db->delete($this->dates_table, array(
1536 1534
 					'cal_id' => $cal_id,
1537 1535
 					'cal_start > '.(int)$old_min,
1538
-				),__LINE__,__FILE__,'calendar');
1536
+				), __LINE__, __FILE__, 'calendar');
1539 1537
 
1540 1538
 				// delete all user-records, with recur-date != 0
1541
-				$this->db->delete($this->user_table,array(
1539
+				$this->db->delete($this->user_table, array(
1542 1540
 					'cal_id' => $cal_id,
1543 1541
 					'cal_recur_date != 0',
1544
-				),__LINE__,__FILE__,'calendar');
1542
+				), __LINE__, __FILE__, 'calendar');
1545 1543
 			}
1546 1544
 			else
1547 1545
 			{
1548 1546
 				// we adjust some possibly changed recurrences manually
1549 1547
 				// deleted exceptions: re-insert recurrences into the user and dates table
1550
-				if (count($deleted_exceptions = array_diff($old_exceptions,$event['recur_exception'])))
1548
+				if (count($deleted_exceptions = array_diff($old_exceptions, $event['recur_exception'])))
1551 1549
 				{
1552 1550
 					if (isset($event['cal_participants']))
1553 1551
 					{
@@ -1558,7 +1556,7 @@  discard block
 block discarded – undo
1558 1556
 						// use old default
1559 1557
 						$participants = $old_participants;
1560 1558
 					}
1561
-					foreach($deleted_exceptions as $id => $deleted_exception)
1559
+					foreach ($deleted_exceptions as $id => $deleted_exception)
1562 1560
 					{
1563 1561
 						// rebuild participants for the re-inserted recurrence
1564 1562
 						$this->recurrence($cal_id, $deleted_exception, $deleted_exception + $old_duration, $participants);
@@ -1566,24 +1564,24 @@  discard block
 block discarded – undo
1566 1564
 				}
1567 1565
 
1568 1566
 				// check if recurrence enddate was adjusted
1569
-				if(isset($event['recur_enddate']))
1567
+				if (isset($event['recur_enddate']))
1570 1568
 				{
1571 1569
 					// recurrences need to be truncated
1572
-					if((int)$event['recur_enddate'] > 0 &&
1570
+					if ((int)$event['recur_enddate'] > 0 &&
1573 1571
 						((int)$old_repeats['recur_enddate'] == 0 || (int)$old_repeats['recur_enddate'] > (int)$event['recur_enddate'])
1574 1572
 					)
1575 1573
 					{
1576
-						$this->db->delete($this->user_table,array('cal_id' => $cal_id,'cal_recur_date >= '.($event['recur_enddate'] + 1*DAY_s)),__LINE__,__FILE__,'calendar');
1577
-						$this->db->delete($this->dates_table,array('cal_id' => $cal_id,'cal_start >= '.($event['recur_enddate'] + 1*DAY_s)),__LINE__,__FILE__,'calendar');
1574
+						$this->db->delete($this->user_table, array('cal_id' => $cal_id, 'cal_recur_date >= '.($event['recur_enddate'] + 1 * DAY_s)), __LINE__, __FILE__, 'calendar');
1575
+						$this->db->delete($this->dates_table, array('cal_id' => $cal_id, 'cal_start >= '.($event['recur_enddate'] + 1 * DAY_s)), __LINE__, __FILE__, 'calendar');
1578 1576
 					}
1579 1577
 
1580 1578
 					// recurrences need to be expanded
1581
-					if(((int)$event['recur_enddate'] == 0 && (int)$old_repeats['recur_enddate'] > 0)
1579
+					if (((int)$event['recur_enddate'] == 0 && (int)$old_repeats['recur_enddate'] > 0)
1582 1580
 						|| ((int)$event['recur_enddate'] > 0 && (int)$old_repeats['recur_enddate'] > 0 && (int)$old_repeats['recur_enddate'] < (int)$event['recur_enddate'])
1583 1581
 					)
1584 1582
 					{
1585 1583
 						$set_recurrences = true;
1586
-						$set_recurrences_start = ($old_repeats['recur_enddate'] + 1*DAY_s);
1584
+						$set_recurrences_start = ($old_repeats['recur_enddate'] + 1 * DAY_s);
1587 1585
 					}
1588 1586
 					//error_log(__METHOD__."() event[recur_enddate]=$event[recur_enddate], old_repeats[recur_enddate]=$old_repeats[recur_enddate] --> set_recurrences=".array2string($set_recurrences).", set_recurrences_start=$set_recurrences_start");
1589 1587
 				}
@@ -1592,9 +1590,9 @@  discard block
 block discarded – undo
1592 1590
 				if (count($event['recur_exception']))
1593 1591
 				{
1594 1592
 					// added and existing exceptions: delete the execeptions from the user table, it could be the first time
1595
-					$this->db->delete($this->user_table,array('cal_id' => $cal_id,'cal_recur_date' => $event['recur_exception']),__LINE__,__FILE__,'calendar');
1593
+					$this->db->delete($this->user_table, array('cal_id' => $cal_id, 'cal_recur_date' => $event['recur_exception']), __LINE__, __FILE__, 'calendar');
1596 1594
 					// update recur_exception flag based on current exceptions
1597
-					$this->db->update($this->dates_table, 'recur_exception='.$this->db->expression($this->dates_table,array(
1595
+					$this->db->update($this->dates_table, 'recur_exception='.$this->db->expression($this->dates_table, array(
1598 1596
 						'cal_start' => $event['recur_exception'],
1599 1597
 					)), array(
1600 1598
 						'cal_id' => $cal_id,
@@ -1603,25 +1601,25 @@  discard block
 block discarded – undo
1603 1601
 			}
1604 1602
 
1605 1603
 			// write the repeats table
1606
-			unset($event[0]);	// unset the 'etag=etag+1', as it's not in the repeats table
1607
-			$this->db->insert($this->repeats_table,$event,array('cal_id' => $cal_id),__LINE__,__FILE__,'calendar');
1604
+			unset($event[0]); // unset the 'etag=etag+1', as it's not in the repeats table
1605
+			$this->db->insert($this->repeats_table, $event, array('cal_id' => $cal_id), __LINE__, __FILE__, 'calendar');
1608 1606
 		}
1609 1607
 		// update start- and endtime if present in the event-array, evtl. we need to move all recurrences
1610 1608
 		if (isset($event['cal_start']) && isset($event['cal_end']))
1611 1609
 		{
1612
-			$this->move($cal_id,$event['cal_start'],$event['cal_end'],!$cal_id ? false : $change_since, $old_min, $old_min +  $old_duration);
1610
+			$this->move($cal_id, $event['cal_start'], $event['cal_end'], !$cal_id ? false : $change_since, $old_min, $old_min + $old_duration);
1613 1611
 		}
1614 1612
 		// update participants if present in the event-array
1615 1613
 		if (isset($event['cal_participants']))
1616 1614
 		{
1617
-			$this->participants($cal_id,$event['cal_participants'],!$cal_id ? false : $change_since);
1615
+			$this->participants($cal_id, $event['cal_participants'], !$cal_id ? false : $change_since);
1618 1616
 		}
1619 1617
 		// Custom fields
1620
-		foreach($event as $name => $value)
1618
+		foreach ($event as $name => $value)
1621 1619
 		{
1622 1620
 			if ($name[0] == '#')
1623 1621
 			{
1624
-				if (is_array($value) && array_key_exists('id',$value))
1622
+				if (is_array($value) && array_key_exists('id', $value))
1625 1623
 				{
1626 1624
 					//error_log(__METHOD__.__LINE__."$name => ".array2string($value).function_backtrace());
1627 1625
 					$value = $value['id'];
@@ -1629,19 +1627,19 @@  discard block
 block discarded – undo
1629 1627
 				}
1630 1628
 				if ($value)
1631 1629
 				{
1632
-					$this->db->insert($this->extra_table,array(
1633
-						'cal_extra_value'	=> is_array($value) ? implode(',',$value) : $value,
1634
-					),array(
1630
+					$this->db->insert($this->extra_table, array(
1631
+						'cal_extra_value'	=> is_array($value) ? implode(',', $value) : $value,
1632
+					), array(
1635 1633
 						'cal_id'			=> $cal_id,
1636
-						'cal_extra_name'	=> substr($name,1),
1637
-					),__LINE__,__FILE__,'calendar');
1634
+						'cal_extra_name'	=> substr($name, 1),
1635
+					), __LINE__, __FILE__, 'calendar');
1638 1636
 				}
1639 1637
 				else
1640 1638
 				{
1641
-					$this->db->delete($this->extra_table,array(
1639
+					$this->db->delete($this->extra_table, array(
1642 1640
 						'cal_id'			=> $cal_id,
1643
-						'cal_extra_name'	=> substr($name,1),
1644
-					),__LINE__,__FILE__,'calendar');
1641
+						'cal_extra_name'	=> substr($name, 1),
1642
+					), __LINE__, __FILE__, 'calendar');
1645 1643
 				}
1646 1644
 			}
1647 1645
 		}
@@ -1652,9 +1650,9 @@  discard block
 block discarded – undo
1652 1650
 			{
1653 1651
 				if ($alarm['id'] && strpos($alarm['id'], 'cal:'.$cal_id.':') !== 0)
1654 1652
 				{
1655
-					unset($alarm['id']);	// unset the temporary id to add the alarm
1653
+					unset($alarm['id']); // unset the temporary id to add the alarm
1656 1654
 				}
1657
-				if(!isset($alarm['offset']))
1655
+				if (!isset($alarm['offset']))
1658 1656
 				{
1659 1657
 					$alarm['offset'] = $event['cal_start'] - $alarm['time'];
1660 1658
 				}
@@ -1665,14 +1663,14 @@  discard block
 block discarded – undo
1665 1663
 
1666 1664
 				if ($alarm['time'] < time() && !self::shift_alarm($event, $alarm))
1667 1665
 				{
1668
-					continue;	// pgoerzen: don't add alarm in the past
1666
+					continue; // pgoerzen: don't add alarm in the past
1669 1667
 				}
1670
-				$this->save_alarm($cal_id, $alarm, false);	// false: not update modified, we do it anyway
1668
+				$this->save_alarm($cal_id, $alarm, false); // false: not update modified, we do it anyway
1671 1669
 			}
1672 1670
 		}
1673 1671
 		if (is_null($etag))
1674 1672
 		{
1675
-			$etag = $this->db->select($this->cal_table,'cal_etag',array('cal_id' => $cal_id),__LINE__,__FILE__,false,'','calendar')->fetchColumn();
1673
+			$etag = $this->db->select($this->cal_table, 'cal_etag', array('cal_id' => $cal_id), __LINE__, __FILE__, false, '', 'calendar')->fetchColumn();
1676 1674
 		}
1677 1675
 
1678 1676
 		// if event is an exception: update modified of master, to force etag, ctag and sync-token change
@@ -1692,7 +1690,7 @@  discard block
 block discarded – undo
1692 1690
 	 *	are dealing with, default is now.
1693 1691
 	 * @return boolean true if alarm could be shifted, false if not
1694 1692
 	 */
1695
-	public static function shift_alarm(array $_event, array &$alarm, $timestamp=null)
1693
+	public static function shift_alarm(array $_event, array &$alarm, $timestamp = null)
1696 1694
 	{
1697 1695
 		if ($_event['recur_type'] == MCAL_RECUR_NONE)
1698 1696
 		{
@@ -1703,7 +1701,7 @@  discard block
 block discarded – undo
1703 1701
 		$rrule = calendar_rrule::event2rrule($event, false);
1704 1702
 		foreach ($rrule as $time)
1705 1703
 		{
1706
-			if ($start < ($ts = egw_time::to($time,'server')))
1704
+			if ($start < ($ts = egw_time::to($time, 'server')))
1707 1705
 			{
1708 1706
 				$alarm['time'] = $ts - $alarm['offset'];
1709 1707
 				return true;
@@ -1724,34 +1722,34 @@  discard block
 block discarded – undo
1724 1722
 	 * @todo Recalculate recurrences, if timezone changes
1725 1723
 	 * @return int|boolean number of moved recurrences or false on error
1726 1724
 	 */
1727
-	function move($cal_id,$start,$end,$change_since=0,$old_start=0,$old_end=0)
1725
+	function move($cal_id, $start, $end, $change_since = 0, $old_start = 0, $old_end = 0)
1728 1726
 	{
1729 1727
 		//echo "<p>socal::move($cal_id,$start,$end,$change_since,$old_start,$old_end)</p>\n";
1730 1728
 
1731
-		if (!(int) $cal_id) return false;
1729
+		if (!(int)$cal_id) return false;
1732 1730
 
1733 1731
 		if (!$old_start)
1734 1732
 		{
1735
-			if ($change_since !== false) $row = $this->db->select($this->dates_table,'MIN(cal_start) AS cal_start,MIN(cal_end) AS cal_end',
1736
-				array('cal_id'=>$cal_id),__LINE__,__FILE__,false,'','calendar')->fetch();
1733
+			if ($change_since !== false) $row = $this->db->select($this->dates_table, 'MIN(cal_start) AS cal_start,MIN(cal_end) AS cal_end',
1734
+				array('cal_id'=>$cal_id), __LINE__, __FILE__, false, '', 'calendar')->fetch();
1737 1735
 			// if no recurrence found, create one with the new dates
1738 1736
 			if ($change_since === false || !$row || !$row['cal_start'] || !$row['cal_end'])
1739 1737
 			{
1740
-				$this->db->insert($this->dates_table,array(
1738
+				$this->db->insert($this->dates_table, array(
1741 1739
 					'cal_id'    => $cal_id,
1742 1740
 					'cal_start' => $start,
1743 1741
 					'cal_end'   => $end,
1744
-				),false,__LINE__,__FILE__,'calendar');
1742
+				), false, __LINE__, __FILE__, 'calendar');
1745 1743
 
1746 1744
 				return 1;
1747 1745
 			}
1748
-			$move_start = (int) ($start-$row['cal_start']);
1749
-			$move_end   = (int) ($end-$row['cal_end']);
1746
+			$move_start = (int)($start - $row['cal_start']);
1747
+			$move_end   = (int)($end - $row['cal_end']);
1750 1748
 		}
1751 1749
 		else
1752 1750
 		{
1753
-			$move_start = (int) ($start-$old_start);
1754
-			$move_end   = (int) ($end-$old_end);
1751
+			$move_start = (int)($start - $old_start);
1752
+			$move_end   = (int)($end - $old_end);
1755 1753
 		}
1756 1754
 		$where = 'cal_id='.(int)$cal_id;
1757 1755
 
@@ -1759,13 +1757,13 @@  discard block
 block discarded – undo
1759 1757
 		{
1760 1758
 			// move the recur-date of the participants
1761 1759
 			$this->db->query("UPDATE $this->user_table SET cal_recur_date=cal_recur_date+$move_start WHERE $where AND cal_recur_date ".
1762
-				((int)$change_since ? '>= '.(int)$change_since : '!= 0'),__LINE__,__FILE__);
1760
+				((int)$change_since ? '>= '.(int)$change_since : '!= 0'), __LINE__, __FILE__);
1763 1761
 		}
1764 1762
 		if ($move_start || $move_end)
1765 1763
 		{
1766 1764
 			// move the event and it's recurrences
1767 1765
 			$this->db->query("UPDATE $this->dates_table SET cal_start=cal_start+$move_start,cal_end=cal_end+$move_end WHERE $where".
1768
-				((int) $change_since ? ' AND cal_start >= '.(int) $change_since : ''),__LINE__,__FILE__);
1766
+				((int)$change_since ? ' AND cal_start >= '.(int)$change_since : ''), __LINE__, __FILE__);
1769 1767
 		}
1770 1768
 		return $this->db->affected_rows();
1771 1769
 	}
@@ -1784,8 +1782,7 @@  discard block
 block discarded – undo
1784 1782
 		}
1785 1783
 		if (is_array($attendee))
1786 1784
 		{
1787
-			$email = !empty($attendee['email']) ? $user_attendee['email'] :
1788
-				(strtolower(substr($attendee['url'], 0, 7)) == 'mailto:' ? substr($user_attendee['url'], 7) : $attendee['url']);
1785
+			$email = !empty($attendee['email']) ? $user_attendee['email'] : (strtolower(substr($attendee['url'], 0, 7)) == 'mailto:' ? substr($user_attendee['url'], 7) : $attendee['url']);
1789 1786
 			$attendee = !empty($attendee['cn']) ? $attendee['cn'].' <'.$email.'>' : $email;
1790 1787
 		}
1791 1788
 		return $attendee;
@@ -1798,11 +1795,11 @@  discard block
 block discarded – undo
1798 1795
 	 * @param string|array $attendee attendee information: email, json or array with attr cn and url
1799 1796
 	 * @return string|int combined id
1800 1797
 	 */
1801
-	static function combine_user($user_type, $user_id, $attendee=null)
1798
+	static function combine_user($user_type, $user_id, $attendee = null)
1802 1799
 	{
1803 1800
 		if (!$user_type || $user_type == 'u')
1804 1801
 		{
1805
-			return (int) $user_id;
1802
+			return (int)$user_id;
1806 1803
 		}
1807 1804
 		if ($user_type == 'e' && $attendee)
1808 1805
 		{
@@ -1822,12 +1819,12 @@  discard block
 block discarded – undo
1822 1819
 	 * @param string|int &$user_id id
1823 1820
 	 * @param boolean $md5_email =false md5 hash user_id for email / user_type=="e"
1824 1821
 	 */
1825
-	static function split_user($uid, &$user_type, &$user_id, $md5_email=false)
1822
+	static function split_user($uid, &$user_type, &$user_id, $md5_email = false)
1826 1823
 	{
1827 1824
 		if (is_numeric($uid))
1828 1825
 		{
1829 1826
 			$user_type = 'u';
1830
-			$user_id = (int) $uid;
1827
+			$user_id = (int)$uid;
1831 1828
 		}
1832 1829
 		// create md5 hash from lowercased and trimed raw email ("[email protected]", not "Ralf Becker <[email protected]>")
1833 1830
 		elseif ($md5_email && $uid[0] == 'e')
@@ -1841,7 +1838,7 @@  discard block
 block discarded – undo
1841 1838
 		else
1842 1839
 		{
1843 1840
 			$user_type = $uid[0];
1844
-			$user_id = substr($uid,1);
1841
+			$user_id = substr($uid, 1);
1845 1842
 		}
1846 1843
 	}
1847 1844
 
@@ -1853,7 +1850,7 @@  discard block
 block discarded – undo
1853 1850
 	 * @param string $role ='REQ-PARTICIPANT'
1854 1851
 	 * @return string
1855 1852
 	 */
1856
-	static function combine_status($status,$quantity=1,$role='REQ-PARTICIPANT')
1853
+	static function combine_status($status, $quantity = 1, $role = 'REQ-PARTICIPANT')
1857 1854
 	{
1858 1855
 		if ((int)$quantity > 1) $status .= (int)$quantity;
1859 1856
 		if ($role != 'REQ-PARTICIPANT') $status .= $role;
@@ -1869,13 +1866,13 @@  discard block
 block discarded – undo
1869 1866
 	 * @param string &$role=null only O: role
1870 1867
 	 * @return string status U, T, A or R, same as $status parameter on return
1871 1868
 	 */
1872
-	static function split_status(&$status,&$quantity=null,&$role=null)
1869
+	static function split_status(&$status, &$quantity = null, &$role = null)
1873 1870
 	{
1874 1871
 		$quantity = 1;
1875 1872
 		$role = 'REQ-PARTICIPANT';
1876 1873
 		//error_log(__METHOD__.__LINE__.array2string($status));
1877 1874
 		$matches = null;
1878
-		if (is_string($status) && strlen($status) > 1 && preg_match('/^.([0-9]*)(.*)$/',$status,$matches))
1875
+		if (is_string($status) && strlen($status) > 1 && preg_match('/^.([0-9]*)(.*)$/', $status, $matches))
1879 1876
 		{
1880 1877
 			if ((int)$matches[1] > 0) $quantity = (int)$matches[1];
1881 1878
 			if ($matches[2]) $role = $matches[2];
@@ -1902,14 +1899,14 @@  discard block
 block discarded – undo
1902 1899
 	 *		true = only add participants if needed, no participant will be deleted (participants to check/add required in $participants)
1903 1900
 	 * @return int|boolean number of updated recurrences or false on error
1904 1901
 	 */
1905
-	function participants($cal_id,$participants,$change_since=0,$add_only=false)
1902
+	function participants($cal_id, $participants, $change_since = 0, $add_only = false)
1906 1903
 	{
1907 1904
 		//error_log(__METHOD__."($cal_id,".array2string($participants).",$change_since,$add_only");
1908 1905
 
1909 1906
 		$recurrences = array();
1910 1907
 
1911 1908
 		// remove group-invitations, they are NOT stored in the db
1912
-		foreach($participants as $uid => $status)
1909
+		foreach ($participants as $uid => $status)
1913 1910
 		{
1914 1911
 			if ($status[0] == 'G')
1915 1912
 			{
@@ -1918,7 +1915,7 @@  discard block
 block discarded – undo
1918 1915
 		}
1919 1916
 		$where = array('cal_id' => $cal_id);
1920 1917
 
1921
-		if ((int) $change_since)
1918
+		if ((int)$change_since)
1922 1919
 		{
1923 1920
 			$where[] = '(cal_recur_date=0 OR cal_recur_date >= '.(int)$change_since.')';
1924 1921
 		}
@@ -1926,31 +1923,31 @@  discard block
 block discarded – undo
1926 1923
 		if ($change_since !== false)
1927 1924
 		{
1928 1925
 			// find all existing recurrences
1929
-			foreach($this->db->select($this->user_table,'DISTINCT cal_recur_date',$where,__LINE__,__FILE__,false,'','calendar') as $row)
1926
+			foreach ($this->db->select($this->user_table, 'DISTINCT cal_recur_date', $where, __LINE__, __FILE__, false, '', 'calendar') as $row)
1930 1927
 			{
1931 1928
 				$recurrences[] = $row['cal_recur_date'];
1932 1929
 			}
1933 1930
 
1934 1931
 			// update existing entries
1935
-			$existing_entries = $this->db->select($this->user_table,'*',$where,__LINE__,__FILE__,false,'ORDER BY cal_recur_date DESC','calendar');
1932
+			$existing_entries = $this->db->select($this->user_table, '*', $where, __LINE__, __FILE__, false, 'ORDER BY cal_recur_date DESC', 'calendar');
1936 1933
 
1937 1934
 			// create a full list of participants which already exist in the db
1938 1935
 			// with status, quantity and role of the earliest recurence
1939 1936
 			$old_participants = array();
1940
-			foreach($existing_entries as $row)
1937
+			foreach ($existing_entries as $row)
1941 1938
 			{
1942 1939
 				$uid = self::combine_user($row['cal_user_type'], $row['cal_user_id'], $row['cal_user_attendee']);
1943 1940
 				if ($row['cal_recur_date'] || !isset($old_participants[$uid]))
1944 1941
 				{
1945
-					$old_participants[$uid] = self::combine_status($row['cal_status'],$row['cal_quantity'],$row['cal_role']);
1942
+					$old_participants[$uid] = self::combine_status($row['cal_status'], $row['cal_quantity'], $row['cal_role']);
1946 1943
 				}
1947 1944
 			}
1948 1945
 
1949 1946
 			// tag participants which should be deleted
1950
-			if($add_only === false)
1947
+			if ($add_only === false)
1951 1948
 			{
1952 1949
 				$deleted = array();
1953
-				foreach($existing_entries as $row)
1950
+				foreach ($existing_entries as $row)
1954 1951
 				{
1955 1952
 					$uid = self::combine_user($row['cal_user_type'], $row['cal_user_id'], $row['cal_user_attendee']);
1956 1953
 					// delete not longer set participants
@@ -1963,7 +1960,7 @@  discard block
 block discarded – undo
1963 1960
 
1964 1961
 			// only keep added OR status (incl. quantity!) changed participants for further steps
1965 1962
 			// we do not touch unchanged (!) existing ones
1966
-			foreach($participants as $uid => $status)
1963
+			foreach ($participants as $uid => $status)
1967 1964
 			{
1968 1965
 				if ($old_participants[$uid] === $status)
1969 1966
 				{
@@ -1975,46 +1972,46 @@  discard block
 block discarded – undo
1975 1972
 			if ($add_only === false && count($deleted))
1976 1973
 			{
1977 1974
 				$to_or = array();
1978
-				$table_def = $this->db->get_table_definitions('calendar',$this->user_table);
1979
-				foreach($deleted as $type => $ids)
1975
+				$table_def = $this->db->get_table_definitions('calendar', $this->user_table);
1976
+				foreach ($deleted as $type => $ids)
1980 1977
 				{
1981
-					$to_or[] = $this->db->expression($table_def,array(
1978
+					$to_or[] = $this->db->expression($table_def, array(
1982 1979
 						'cal_user_type' => $type,
1983 1980
 						'cal_user_id'   => $ids,
1984 1981
 					));
1985 1982
 				}
1986
-				$where[] = '('.implode(' OR ',$to_or).')';
1987
-				$where[] = "cal_status!='E'";	// do NOT delete exception marker
1988
-				$this->db->update($this->user_table,array('cal_status'=>'X'),$where,__LINE__,__FILE__,'calendar');
1983
+				$where[] = '('.implode(' OR ', $to_or).')';
1984
+				$where[] = "cal_status!='E'"; // do NOT delete exception marker
1985
+				$this->db->update($this->user_table, array('cal_status'=>'X'), $where, __LINE__, __FILE__, 'calendar');
1989 1986
 			}
1990 1987
 		}
1991 1988
 
1992 1989
 		if (count($participants))	// participants which need to be added
1993 1990
 		{
1994
-			if (!count($recurrences)) $recurrences[] = 0;   // insert the default recurrence
1991
+			if (!count($recurrences)) $recurrences[] = 0; // insert the default recurrence
1995 1992
 
1996 1993
 			$delete_deleted = array();
1997 1994
 
1998 1995
 			// update participants
1999
-			foreach($participants as $uid => $status)
1996
+			foreach ($participants as $uid => $status)
2000 1997
 			{
2001 1998
 				$type = $id = $quantity = $role = null;
2002 1999
 				self::split_user($uid, $type, $id, true);
2003
-				self::split_status($status,$quantity,$role);
2000
+				self::split_status($status, $quantity, $role);
2004 2001
 				$set = array(
2005 2002
 					'cal_status'	  => $status,
2006 2003
 					'cal_quantity'	  => $quantity,
2007 2004
 					'cal_role'        => $role,
2008 2005
 					'cal_user_attendee' => $type == 'e' ? substr($uid, 1) : null,
2009 2006
 				);
2010
-				foreach($recurrences as $recur_date)
2007
+				foreach ($recurrences as $recur_date)
2011 2008
 				{
2012
-					$this->db->insert($this->user_table,$set,array(
2009
+					$this->db->insert($this->user_table, $set, array(
2013 2010
 						'cal_id'	      => $cal_id,
2014 2011
 						'cal_recur_date'  => $recur_date,
2015 2012
 						'cal_user_type'   => $type,
2016 2013
 						'cal_user_id' 	  => $id,
2017
-					),__LINE__,__FILE__,'calendar');
2014
+					), __LINE__, __FILE__, 'calendar');
2018 2015
 				}
2019 2016
 				// for new or changed group-invitations, remove previously deleted members, so they show up again
2020 2017
 				if ($uid < 0)
@@ -2024,13 +2021,13 @@  discard block
 block discarded – undo
2024 2021
 			}
2025 2022
 			if ($delete_deleted)
2026 2023
 			{
2027
-				$this->db->delete($this->user_table, $where=array(
2024
+				$this->db->delete($this->user_table, $where = array(
2028 2025
 					'cal_id' => $cal_id,
2029 2026
 					'cal_recur_date' => $recurrences,
2030 2027
 					'cal_user_type' => 'u',
2031 2028
 					'cal_user_id' => array_unique($delete_deleted),
2032 2029
 					'cal_status' => 'X',
2033
-				),__LINE__,__FILE__,'calendar');
2030
+				), __LINE__, __FILE__, 'calendar');
2034 2031
 				//error_log(__METHOD__."($cal_id, ".array2string($participants).", since=$change_since, add_only=$add_only) db->delete('$this->user_table', ".array2string($where).") affected ".$this->db->affected_rows().' rows');
2035 2032
 			}
2036 2033
 		}
@@ -2049,7 +2046,7 @@  discard block
 block discarded – undo
2049 2046
 	 * @param string $attendee =null extra attendee information to set for all types (incl. accounts!)
2050 2047
 	 * @return int number of changed recurrences
2051 2048
 	 */
2052
-	function set_status($cal_id,$user_type,$user_id,$status,$recur_date=0,$role=null,$attendee=null)
2049
+	function set_status($cal_id, $user_type, $user_id, $status, $recur_date = 0, $role = null, $attendee = null)
2053 2050
 	{
2054 2051
 		static $status_code_short = array(
2055 2052
 			REJECTED 	=> 'R',
@@ -2074,7 +2071,7 @@  discard block
 block discarded – undo
2074 2071
 			'cal_user_type'	=> $user_type,
2075 2072
 			'cal_user_id'   => $user_id_md5,
2076 2073
 		);
2077
-		if ((int) $recur_date)
2074
+		if ((int)$recur_date)
2078 2075
 		{
2079 2076
 			$where['cal_recur_date'] = $recur_date;
2080 2077
 		}
@@ -2085,7 +2082,7 @@  discard block
 block discarded – undo
2085 2082
 
2086 2083
 		if ($status == 'G')		// remove group invitations, as we dont store them in the db
2087 2084
 		{
2088
-			$this->db->delete($this->user_table,$where,__LINE__,__FILE__,'calendar');
2085
+			$this->db->delete($this->user_table, $where, __LINE__, __FILE__, 'calendar');
2089 2086
 			$ret = $this->db->affected_rows();
2090 2087
 		}
2091 2088
 		else
@@ -2093,7 +2090,7 @@  discard block
 block discarded – undo
2093 2090
 			$set = array('cal_status' => $status);
2094 2091
 			if ($user_type == 'e' || $attendee) $set['cal_user_attendee'] = $attendee ? $attendee : $user_id;
2095 2092
 			if (!is_null($role) && $role != 'REQ-PARTICIPANT') $set['cal_role'] = $role;
2096
-			$this->db->insert($this->user_table,$set,$where,__LINE__,__FILE__,'calendar');
2093
+			$this->db->insert($this->user_table, $set, $where, __LINE__, __FILE__, 'calendar');
2097 2094
 			// for new or changed group-invitations, remove previously deleted members, so they show up again
2098 2095
 			if (($ret = $this->db->affected_rows()) && $user_type == 'u' && $user_id < 0)
2099 2096
 			{
@@ -2106,7 +2103,7 @@  discard block
 block discarded – undo
2106 2103
 		// update modified and modifier in main table
2107 2104
 		if ($ret)
2108 2105
 		{
2109
-			$this->updateModified($cal_id, true);	// true = update series master too
2106
+			$this->updateModified($cal_id, true); // true = update series master too
2110 2107
 		}
2111 2108
 		//error_log(__METHOD__."($cal_id,$user_type,$user_id,$status,$recur_date) = $ret");
2112 2109
 		return $ret;
@@ -2121,7 +2118,7 @@  discard block
 block discarded – undo
2121 2118
 	 * @param array $participants uid => status pairs
2122 2119
 	 * @param boolean $exception =null true or false to set recure_exception flag, null leave it unchanged (new are by default no exception)
2123 2120
 	 */
2124
-	function recurrence($cal_id,$start,$end,$participants,$exception=null)
2121
+	function recurrence($cal_id, $start, $end, $participants, $exception = null)
2125 2122
 	{
2126 2123
 		//error_log(__METHOD__."($cal_id, $start, $end, ".array2string($participants).", ".array2string($exception));
2127 2124
 		$update = array('cal_end' => $end);
@@ -2130,7 +2127,7 @@  discard block
 block discarded – undo
2130 2127
 		$this->db->insert($this->dates_table, $update, array(
2131 2128
 			'cal_id' => $cal_id,
2132 2129
 			'cal_start'  => $start,
2133
-		),__LINE__,__FILE__,'calendar');
2130
+		), __LINE__, __FILE__, 'calendar');
2134 2131
 
2135 2132
 		if (!is_array($participants))
2136 2133
 		{
@@ -2138,26 +2135,26 @@  discard block
 block discarded – undo
2138 2135
 		}
2139 2136
 		if ($exception !== true)
2140 2137
 		{
2141
-			foreach($participants as $uid => $status)
2138
+			foreach ($participants as $uid => $status)
2142 2139
 			{
2143
-				if ($status == 'G') continue;	// dont save group-invitations
2140
+				if ($status == 'G') continue; // dont save group-invitations
2144 2141
 
2145 2142
 				$type = '';
2146 2143
 				$id = null;
2147 2144
 				self::split_user($uid, $type, $id, true);
2148 2145
 				$quantity = $role = null;
2149
-				self::split_status($status,$quantity,$role);
2150
-				$this->db->insert($this->user_table,array(
2146
+				self::split_status($status, $quantity, $role);
2147
+				$this->db->insert($this->user_table, array(
2151 2148
 					'cal_status'	=> $status,
2152 2149
 					'cal_quantity'	=> $quantity,
2153 2150
 					'cal_role'		=> $role,
2154 2151
 					'cal_user_attendee' => $type == 'e' ? substr($uid, 1) : null,
2155
-				),array(
2152
+				), array(
2156 2153
 					'cal_id'		 => $cal_id,
2157 2154
 					'cal_recur_date' => $start,
2158 2155
 					'cal_user_type'  => $type,
2159 2156
 					'cal_user_id' 	 => $id,
2160
-				),__LINE__,__FILE__,'calendar');
2157
+				), __LINE__, __FILE__, 'calendar');
2161 2158
 			}
2162 2159
 		}
2163 2160
 	}
@@ -2171,7 +2168,7 @@  discard block
 block discarded – undo
2171 2168
 	function unfinished_recuring($time)
2172 2169
 	{
2173 2170
 		$ids = array();
2174
-		foreach($rs=$this->db->select($this->repeats_table, "$this->repeats_table.cal_id,MAX(cal_start) AS cal_start",
2171
+		foreach ($rs = $this->db->select($this->repeats_table, "$this->repeats_table.cal_id,MAX(cal_start) AS cal_start",
2175 2172
 			'(range_end IS NULL OR range_end > '.(int)$time.')',
2176 2173
 			__LINE__, __FILE__, false, "GROUP BY $this->repeats_table.cal_id,range_end", 'calendar', 0,
2177 2174
 			" JOIN $this->cal_table ON $this->repeats_table.cal_id=$this->cal_table.cal_id".
@@ -2197,9 +2194,9 @@  discard block
 block discarded – undo
2197 2194
 		// update timestamp of series master, updates own timestamp too, which does not hurt ;-)
2198 2195
 		$this->updateModified($cal_id, true);
2199 2196
 
2200
-		foreach($this->all_tables as $table)
2197
+		foreach ($this->all_tables as $table)
2201 2198
 		{
2202
-			$this->db->delete($table,array('cal_id'=>$cal_id),__LINE__,__FILE__,'calendar');
2199
+			$this->db->delete($table, array('cal_id'=>$cal_id), __LINE__, __FILE__, 'calendar');
2203 2200
 		}
2204 2201
 	}
2205 2202
 
@@ -2215,19 +2212,19 @@  discard block
 block discarded – undo
2215 2212
 	function purge($date)
2216 2213
 	{
2217 2214
 		// with new range_end we simple delete all with range_end < $date (range_end NULL is never returned)
2218
-		foreach($this->db->select($this->cal_table, 'cal_id', 'range_end < '.(int)$date, __LINE__, __FILE__, false, '', 'calendar') as $row)
2215
+		foreach ($this->db->select($this->cal_table, 'cal_id', 'range_end < '.(int)$date, __LINE__, __FILE__, false, '', 'calendar') as $row)
2219 2216
 		{
2220 2217
 			//echo __METHOD__." About to delete".$row['cal_id']."\r\n";
2221
-			foreach($this->all_tables as $table)
2218
+			foreach ($this->all_tables as $table)
2222 2219
 			{
2223 2220
 				$this->db->delete($table, array('cal_id'=>$row['cal_id']), __LINE__, __FILE__, 'calendar');
2224 2221
 			}
2225 2222
 			// handle sync
2226
-			$this->db->update('egw_api_content_history',array(
2223
+			$this->db->update('egw_api_content_history', array(
2227 2224
 				'sync_deleted' => time(),
2228
-			),array(
2225
+			), array(
2229 2226
 				'sync_appname' => 'calendar',
2230
-				'sync_contentid' => $row['cal_id'],	// sync_contentid is varchar(60)!
2227
+				'sync_contentid' => $row['cal_id'], // sync_contentid is varchar(60)!
2231 2228
 			), __LINE__, __FILE__);
2232 2229
 			// handle links
2233 2230
 			egw_link::unlink('', 'calendar', $row['cal_id']);
@@ -2250,23 +2247,23 @@  discard block
 block discarded – undo
2250 2247
 	 * @param boolean $update_cache =null true: re-read given $cal_id, false: delete given $cal_id
2251 2248
 	 * @return array of (cal_id => array of) alarms with alarm-id as key
2252 2249
 	 */
2253
-	function read_alarms($cal_id, $update_cache=null)
2250
+	function read_alarms($cal_id, $update_cache = null)
2254 2251
 	{
2255 2252
 		if (!isset(self::$alarm_cache) && is_array($cal_id))
2256 2253
 		{
2257 2254
 			self::$alarm_cache = array();
2258 2255
 			if (($jobs = $this->async->read('cal:%')))
2259 2256
 			{
2260
-				foreach($jobs as $id => $job)
2257
+				foreach ($jobs as $id => $job)
2261 2258
 				{
2262
-					$alarm         = $job['data'];	// text, enabled
2259
+					$alarm         = $job['data']; // text, enabled
2263 2260
 					$alarm['id']   = $id;
2264 2261
 					$alarm['time'] = $job['next'];
2265 2262
 
2266 2263
 					self::$alarm_cache[$alarm['cal_id']][$id] = $alarm;
2267 2264
 				}
2268 2265
 			}
2269
-			unset($update_cache);	// just done
2266
+			unset($update_cache); // just done
2270 2267
 		}
2271 2268
 		$alarms = array();
2272 2269
 
@@ -2274,13 +2271,13 @@  discard block
 block discarded – undo
2274 2271
 		{
2275 2272
 			if (isset($update_cache))
2276 2273
 			{
2277
-				foreach((array)$cal_id as $id)
2274
+				foreach ((array)$cal_id as $id)
2278 2275
 				{
2279 2276
 					if ($update_cache === false)
2280 2277
 					{
2281 2278
 						unset(self::$alarm_cache[$cal_id]);
2282 2279
 					}
2283
-					elseif($update_cache === true)
2280
+					elseif ($update_cache === true)
2284 2281
 					{
2285 2282
 						self::$alarm_cache[$cal_id] = $this->read_alarms_nocache($cal_id);
2286 2283
 					}
@@ -2292,7 +2289,7 @@  discard block
 block discarded – undo
2292 2289
 			}
2293 2290
 			else
2294 2291
 			{
2295
-				foreach($cal_id as $id)
2292
+				foreach ($cal_id as $id)
2296 2293
 				{
2297 2294
 					$alarms[$id] = (array)self::$alarm_cache[$id];
2298 2295
 				}
@@ -2307,9 +2304,9 @@  discard block
 block discarded – undo
2307 2304
 	{
2308 2305
 		if (($jobs = $this->async->read('cal:'.(int)$cal_id.':%')))
2309 2306
 		{
2310
-			foreach($jobs as $id => $job)
2307
+			foreach ($jobs as $id => $job)
2311 2308
 			{
2312
-				$alarm         = $job['data'];	// text, enabled
2309
+				$alarm         = $job['data']; // text, enabled
2313 2310
 				$alarm['id']   = $id;
2314 2311
 				$alarm['time'] = $job['next'];
2315 2312
 
@@ -2332,8 +2329,8 @@  discard block
 block discarded – undo
2332 2329
 		{
2333 2330
 			return False;
2334 2331
 		}
2335
-		list($alarm_id,$job) = each($jobs);
2336
-		$alarm         = $job['data'];	// text, enabled
2332
+		list($alarm_id, $job) = each($jobs);
2333
+		$alarm         = $job['data']; // text, enabled
2337 2334
 		$alarm['id']   = $alarm_id;
2338 2335
 		$alarm['time'] = $job['next'];
2339 2336
 
@@ -2349,12 +2346,12 @@  discard block
 block discarded – undo
2349 2346
 	 * @param boolean $update_modified =true call update modified, default true
2350 2347
 	 * @return string id of the alarm
2351 2348
 	 */
2352
-	function save_alarm($cal_id, $alarm, $update_modified=true)
2349
+	function save_alarm($cal_id, $alarm, $update_modified = true)
2353 2350
 	{
2354 2351
 		//error_log(__METHOD__."($cal_id, ".array2string($alarm).', '.array2string($update_modified).') '.function_backtrace());
2355 2352
 		if (!($id = $alarm['id']))
2356 2353
 		{
2357
-			$alarms = $this->read_alarms($cal_id);	// find a free alarm#
2354
+			$alarms = $this->read_alarms($cal_id); // find a free alarm#
2358 2355
 			$n = count($alarms);
2359 2356
 			do
2360 2357
 			{
@@ -2367,12 +2364,12 @@  discard block
 block discarded – undo
2367 2364
 		{
2368 2365
 			$this->async->cancel_timer($id);
2369 2366
 		}
2370
-		$alarm['cal_id'] = $cal_id;		// we need the back-reference
2367
+		$alarm['cal_id'] = $cal_id; // we need the back-reference
2371 2368
 		// add an alarm uid, if none is given
2372 2369
 		if (empty($alarm['uid']) && class_exists('Horde_Support_Uuid')) $alarm['uid'] = (string)new Horde_Support_Uuid;
2373 2370
 		//error_log(__METHOD__.__LINE__.' Save Alarm for CalID:'.$cal_id.'->'.array2string($alarm).'-->'.$id.'#'.function_backtrace());
2374 2371
 		// allways store job with the alarm owner as job-owner to get eg. the correct from address
2375
-		if (!$this->async->set_timer($alarm['time'],$id,'calendar.calendar_boupdate.send_alarm',$alarm,$alarm['owner']))
2372
+		if (!$this->async->set_timer($alarm['time'], $id, 'calendar.calendar_boupdate.send_alarm', $alarm, $alarm['owner']))
2376 2373
 		{
2377 2374
 			return False;
2378 2375
 		}
@@ -2399,7 +2396,7 @@  discard block
 block discarded – undo
2399 2396
 		//error_log(__METHOD__."($cal_id) ".function_backtrace());
2400 2397
 		if (($alarms = $this->read_alarms($cal_id)))
2401 2398
 		{
2402
-			foreach(array_keys($alarms) as $id)
2399
+			foreach (array_keys($alarms) as $id)
2403 2400
 			{
2404 2401
 				$this->async->cancel_timer($id);
2405 2402
 			}
@@ -2419,7 +2416,7 @@  discard block
 block discarded – undo
2419 2416
 	{
2420 2417
 		//error_log(__METHOD__."('$id') ".function_backtrace());
2421 2418
 		// update the modification information of the related event
2422
-		list(,$cal_id) = explode(':',$id);
2419
+		list(,$cal_id) = explode(':', $id);
2423 2420
 		if ($cal_id)
2424 2421
 		{
2425 2422
 			$this->updateModified($cal_id, true);
@@ -2438,7 +2435,7 @@  discard block
 block discarded – undo
2438 2435
 	 * @param array|int $old_user integer old user or array with keys 'account_id' and 'new_owner' as the deleteaccount hook uses it
2439 2436
 	 * @param int $new_user =null
2440 2437
 	 */
2441
-	function deleteaccount($old_user, $new_user=null)
2438
+	function deleteaccount($old_user, $new_user = null)
2442 2439
 	{
2443 2440
 		if (is_array($old_user))
2444 2441
 		{
@@ -2449,52 +2446,52 @@  discard block
 block discarded – undo
2449 2446
 		{
2450 2447
 			$user_type = '';
2451 2448
 			$user_id = null;
2452
-			self::split_user($old_user,$user_type,$user_id);
2449
+			self::split_user($old_user, $user_type, $user_id);
2453 2450
 
2454 2451
 			if ($user_type == 'u')	// only accounts can be owners of events
2455 2452
 			{
2456
-				foreach($this->db->select($this->cal_table,'cal_id',array('cal_owner' => $old_user),__LINE__,__FILE__,false,'','calendar') as $row)
2453
+				foreach ($this->db->select($this->cal_table, 'cal_id', array('cal_owner' => $old_user), __LINE__, __FILE__, false, '', 'calendar') as $row)
2457 2454
 				{
2458 2455
 					$this->delete($row['cal_id']);
2459 2456
 				}
2460 2457
 			}
2461
-			$this->db->delete($this->user_table,array(
2458
+			$this->db->delete($this->user_table, array(
2462 2459
 				'cal_user_type' => $user_type,
2463 2460
 				'cal_user_id'   => $user_id,
2464
-			),__LINE__,__FILE__,'calendar');
2461
+			), __LINE__, __FILE__, 'calendar');
2465 2462
 
2466 2463
 			// delete calendar entries without participants (can happen if the deleted user is the only participants, but not the owner)
2467
-			foreach($this->db->select($this->cal_table,"DISTINCT $this->cal_table.cal_id",'cal_user_id IS NULL',__LINE__,__FILE__,
2468
-				False,'','calendar',0,"LEFT JOIN $this->user_table ON $this->cal_table.cal_id=$this->user_table.cal_id") as $row)
2464
+			foreach ($this->db->select($this->cal_table, "DISTINCT $this->cal_table.cal_id", 'cal_user_id IS NULL', __LINE__, __FILE__,
2465
+				False, '', 'calendar', 0, "LEFT JOIN $this->user_table ON $this->cal_table.cal_id=$this->user_table.cal_id") as $row)
2469 2466
 			{
2470 2467
 				$this->delete($row['cal_id']);
2471 2468
 			}
2472 2469
 		}
2473 2470
 		else
2474 2471
 		{
2475
-			$this->db->update($this->cal_table,array('cal_owner' => $new_user),array('cal_owner' => $old_user),__LINE__,__FILE__,'calendar');
2472
+			$this->db->update($this->cal_table, array('cal_owner' => $new_user), array('cal_owner' => $old_user), __LINE__, __FILE__, 'calendar');
2476 2473
 			// delete participation of old user, if new user is already a participant
2477 2474
 			$ids = array();
2478
-			foreach($this->db->select($this->user_table,'cal_id',array(		// MySQL does NOT allow to run this as delete!
2475
+			foreach ($this->db->select($this->user_table, 'cal_id', array(		// MySQL does NOT allow to run this as delete!
2479 2476
 				'cal_user_type' => 'u',
2480 2477
 				'cal_user_id' => $old_user,
2481 2478
 				"cal_id IN (SELECT cal_id FROM $this->user_table other WHERE other.cal_id=cal_id AND other.cal_user_id=".$this->db->quote($new_user)." AND cal_user_type='u')",
2482
-			),__LINE__,__FILE__,false,'','calendar') as $row)
2479
+			), __LINE__, __FILE__, false, '', 'calendar') as $row)
2483 2480
 			{
2484 2481
 				$ids[] = $row['cal_id'];
2485 2482
 			}
2486
-			if ($ids) $this->db->delete($this->user_table,array(
2483
+			if ($ids) $this->db->delete($this->user_table, array(
2487 2484
 				'cal_user_type' => 'u',
2488 2485
 				'cal_user_id' => $old_user,
2489 2486
 				'cal_id' => $ids,
2490
-			),__LINE__,__FILE__,'calendar');
2487
+			), __LINE__, __FILE__, 'calendar');
2491 2488
 			// now change participant in the rest to contain new user instead of old user
2492
-			$this->db->update($this->user_table,array(
2489
+			$this->db->update($this->user_table, array(
2493 2490
 				'cal_user_id' => $new_user,
2494
-			),array(
2491
+			), array(
2495 2492
 				'cal_user_type' => 'u',
2496 2493
 				'cal_user_id' => $old_user,
2497
-			),__LINE__,__FILE__,'calendar');
2494
+			), __LINE__, __FILE__, 'calendar');
2498 2495
 		}
2499 2496
 	}
2500 2497
 
@@ -2508,18 +2505,18 @@  discard block
 block discarded – undo
2508 2505
 	 *
2509 2506
 	 * @return array recur_date => status pairs (index 0 => main status)
2510 2507
 	 */
2511
-	function get_recurrences($cal_id, $uid=null, $start=0, $end=0)
2508
+	function get_recurrences($cal_id, $uid = null, $start = 0, $end = 0)
2512 2509
 	{
2513 2510
 		$participant_status = array();
2514 2511
 		$where = array('cal_id' => $cal_id);
2515
-		if ($start != 0 && $end == 0) $where[] = '(cal_recur_date = 0 OR cal_recur_date >= ' . (int)$start . ')';
2516
-		if ($start == 0 && $end != 0) $where[] = '(cal_recur_date = 0 OR cal_recur_date <= ' . (int)$end . ')';
2512
+		if ($start != 0 && $end == 0) $where[] = '(cal_recur_date = 0 OR cal_recur_date >= '.(int)$start.')';
2513
+		if ($start == 0 && $end != 0) $where[] = '(cal_recur_date = 0 OR cal_recur_date <= '.(int)$end.')';
2517 2514
 		if ($start != 0 && $end != 0)
2518 2515
 		{
2519
-			$where[] = '(cal_recur_date = 0 OR (cal_recur_date >= ' . (int)$start .
2520
-						' AND cal_recur_date <= ' . (int)$end . '))';
2516
+			$where[] = '(cal_recur_date = 0 OR (cal_recur_date >= '.(int)$start.
2517
+						' AND cal_recur_date <= '.(int)$end.'))';
2521 2518
 		}
2522
-		foreach($this->db->select($this->user_table,'DISTINCT cal_recur_date',$where,__LINE__,__FILE__,false,'','calendar') as $row)
2519
+		foreach ($this->db->select($this->user_table, 'DISTINCT cal_recur_date', $where, __LINE__, __FILE__, false, '', 'calendar') as $row)
2523 2520
 		{
2524 2521
 			// inititalize the array
2525 2522
 			$participant_status[$row['cal_recur_date']] = null;
@@ -2533,17 +2530,17 @@  discard block
 block discarded – undo
2533 2530
 			'cal_user_type'	=> $user_type ? $user_type : 'u',
2534 2531
 			'cal_user_id'   => $user_id,
2535 2532
 		);
2536
-		if ($start != 0 && $end == 0) $where2[] = '(cal_recur_date = 0 OR cal_recur_date >= ' . (int)$start . ')';
2537
-		if ($start == 0 && $end != 0) $where2[] = '(cal_recur_date = 0 OR cal_recur_date <= ' . (int)$end . ')';
2533
+		if ($start != 0 && $end == 0) $where2[] = '(cal_recur_date = 0 OR cal_recur_date >= '.(int)$start.')';
2534
+		if ($start == 0 && $end != 0) $where2[] = '(cal_recur_date = 0 OR cal_recur_date <= '.(int)$end.')';
2538 2535
 		if ($start != 0 && $end != 0)
2539 2536
 		{
2540
-			$where2[] = '(cal_recur_date = 0 OR (cal_recur_date >= ' . (int)$start .
2541
-						' AND cal_recur_date <= ' . (int)$end . '))';
2537
+			$where2[] = '(cal_recur_date = 0 OR (cal_recur_date >= '.(int)$start.
2538
+						' AND cal_recur_date <= '.(int)$end.'))';
2542 2539
 		}
2543
-		foreach ($this->db->select($this->user_table,'cal_recur_date,cal_status,cal_quantity,cal_role',$where2,
2544
-				__LINE__,__FILE__,false,'','calendar') as $row)
2540
+		foreach ($this->db->select($this->user_table, 'cal_recur_date,cal_status,cal_quantity,cal_role', $where2,
2541
+				__LINE__, __FILE__, false, '', 'calendar') as $row)
2545 2542
 		{
2546
-			$status = self::combine_status($row['cal_status'],$row['cal_quantity'],$row['cal_role']);
2543
+			$status = self::combine_status($row['cal_status'], $row['cal_quantity'], $row['cal_role']);
2547 2544
 			$participant_status[$row['cal_recur_date']] = $status;
2548 2545
 		}
2549 2546
 		return $participant_status;
@@ -2592,8 +2589,8 @@  discard block
 block discarded – undo
2592 2589
 			'cal_uid'		=> $uid,
2593 2590
 		);
2594 2591
 		$related = array();
2595
-		foreach ($this->db->select($this->cal_table,'cal_id,cal_reference',$where,
2596
-				__LINE__,__FILE__,false,'','calendar') as $row)
2592
+		foreach ($this->db->select($this->cal_table, 'cal_id,cal_reference', $where,
2593
+				__LINE__, __FILE__, false, '', 'calendar') as $row)
2597 2594
 		{
2598 2595
 			if ($row['cal_reference'] != 0)
2599 2596
 			{
@@ -2622,10 +2619,10 @@  discard block
 block discarded – undo
2622 2619
 	 *
2623 2620
 	 * @return array		Array of exception days (false for non-recurring events).
2624 2621
 	 */
2625
-	function get_recurrence_exceptions($event, $tz_id=null, $start=0, $end=0, $filter='all')
2622
+	function get_recurrence_exceptions($event, $tz_id = null, $start = 0, $end = 0, $filter = 'all')
2626 2623
 	{
2627 2624
 		if (!is_array($event)) return false;
2628
-		$cal_id = (int) $event['id'];
2625
+		$cal_id = (int)$event['id'];
2629 2626
 		//error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2630 2627
 		//		"($cal_id, $tz_id, $filter): " . $event['tzid']);
2631 2628
 		if (!$cal_id || $event['recur_type'] == MCAL_RECUR_NONE) return false;
@@ -2649,27 +2646,27 @@  discard block
 block discarded – undo
2649 2646
 		while ($egw_rrule->valid())
2650 2647
 		{
2651 2648
 			while ($egw_rrule->exceptions &&
2652
-				in_array($egw_rrule->current->format('Ymd'),$egw_rrule->exceptions))
2649
+				in_array($egw_rrule->current->format('Ymd'), $egw_rrule->exceptions))
2653 2650
 			{
2654
-				if (in_array($filter, array('map','tz_map','rrule','tz_rrule')))
2651
+				if (in_array($filter, array('map', 'tz_map', 'rrule', 'tz_rrule')))
2655 2652
 				{
2656 2653
 					 // real exception
2657
-					$locts = (int)egw_time::to($egw_rrule->current(),'server');
2654
+					$locts = (int)egw_time::to($egw_rrule->current(), 'server');
2658 2655
 					if ($expand_all)
2659 2656
 					{
2660
-						$remts = (int)egw_time::to($remote_rrule->current(),'server');
2657
+						$remts = (int)egw_time::to($remote_rrule->current(), 'server');
2661 2658
 						if ($remote)
2662 2659
 						{
2663
-							$days[$locts]= $remts;
2660
+							$days[$locts] = $remts;
2664 2661
 						}
2665 2662
 						else
2666 2663
 						{
2667
-							$days[$remts]= $locts;
2664
+							$days[$remts] = $locts;
2668 2665
 						}
2669 2666
 					}
2670 2667
 					else
2671 2668
 					{
2672
-						$days[$locts]= $locts;
2669
+						$days[$locts] = $locts;
2673 2670
 					}
2674 2671
 				}
2675 2672
 				if ($expand_all)
@@ -2680,14 +2677,14 @@  discard block
 block discarded – undo
2680 2677
 				if (!$egw_rrule->valid()) return $days;
2681 2678
 			}
2682 2679
 			$day = $egw_rrule->current();
2683
-			$locts = (int)egw_time::to($day,'server');
2680
+			$locts = (int)egw_time::to($day, 'server');
2684 2681
 			$tz_exception = ($filter == 'tz_rrule');
2685 2682
 			//error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2686 2683
 			//	'()[EVENT Server]: ' . $day->format('Ymd\THis') . " ($locts)");
2687 2684
 			if ($expand_all)
2688 2685
 			{
2689 2686
 				$remote_day = $remote_rrule->current();
2690
-				$remts = (int)egw_time::to($remote_day,'server');
2687
+				$remts = (int)egw_time::to($remote_day, 'server');
2691 2688
 			//	error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2692 2689
 			//	'()[EVENT Device]: ' . $remote_day->format('Ymd\THis') . " ($remts)");
2693 2690
 			}
@@ -2706,11 +2703,11 @@  discard block
 block discarded – undo
2706 2703
 						//	'() tz exception: ' . $day->format('Ymd\THis'));
2707 2704
 						if ($remote)
2708 2705
 						{
2709
-							$days[$locts]= $remts;
2706
+							$days[$locts] = $remts;
2710 2707
 						}
2711 2708
 						else
2712 2709
 						{
2713
-							$days[$remts]= $locts;
2710
+							$days[$remts] = $locts;
2714 2711
 						}
2715 2712
 					}
2716 2713
 				}
@@ -2732,18 +2729,18 @@  discard block
 block discarded – undo
2732 2729
 							{
2733 2730
 								if ($remote)
2734 2731
 								{
2735
-									$days[$locts]= $remts;
2732
+									$days[$locts] = $remts;
2736 2733
 								}
2737 2734
 								else
2738 2735
 								{
2739
-									$days[$remts]= $locts;
2736
+									$days[$remts] = $locts;
2740 2737
 								}
2741 2738
 							}
2742 2739
 						}
2743 2740
 					}
2744 2741
 					elseif ($filter != 'map')
2745 2742
 					{
2746
-						$days[$locts]= $locts;
2743
+						$days[$locts] = $locts;
2747 2744
 					}
2748 2745
 				}
2749 2746
 				elseif (($filter == 'map' || filter == 'tz_map') &&
@@ -2753,11 +2750,11 @@  discard block
 block discarded – undo
2753 2750
 					if ($expand_all)
2754 2751
 					{
2755 2752
 
2756
-						$days[$remts]= $locts;
2753
+						$days[$remts] = $locts;
2757 2754
 					}
2758 2755
 					else
2759 2756
 					{
2760
-						$days[$locts]= $locts;
2757
+						$days[$locts] = $locts;
2761 2758
 					}
2762 2759
 				}
2763 2760
 			}
@@ -2781,9 +2778,9 @@  discard block
 block discarded – undo
2781 2778
 	 */
2782 2779
 	function status_pseudo_exception($cal_id, $recur_date, $filter)
2783 2780
 	{
2784
-		static $recurrence_zero=null;
2785
-		static $cached_id=null;
2786
-		static $user=null;
2781
+		static $recurrence_zero = null;
2782
+		static $cached_id = null;
2783
+		static $user = null;
2787 2784
 
2788 2785
 		if (!isset($cached_id) || $cached_id != $cal_id)
2789 2786
 		{
@@ -2794,8 +2791,8 @@  discard block
 block discarded – undo
2794 2791
 				'cal_id' => $cal_id,
2795 2792
 				'cal_recur_date' => 0,
2796 2793
 			);
2797
-			foreach ($this->db->select($this->user_table,'cal_user_type,cal_user_id,cal_user_attendee,cal_status',$where,
2798
-				__LINE__,__FILE__,false,'','calendar') as $row)
2794
+			foreach ($this->db->select($this->user_table, 'cal_user_type,cal_user_id,cal_user_attendee,cal_status', $where,
2795
+				__LINE__, __FILE__, false, '', 'calendar') as $row)
2799 2796
 			{
2800 2797
 				switch ($row['cal_user_type'])
2801 2798
 				{
@@ -2818,8 +2815,8 @@  discard block
 block discarded – undo
2818 2815
 			'cal_id' => $cal_id,
2819 2816
 			'cal_recur_date' => $recur_date,
2820 2817
 		);
2821
-		foreach ($this->db->select($this->user_table,'cal_user_type,cal_user_id,cal_user_attendee,cal_status',$where,
2822
-			__LINE__,__FILE__,false,'','calendar') as $row)
2818
+		foreach ($this->db->select($this->user_table, 'cal_user_type,cal_user_id,cal_user_attendee,cal_status', $where,
2819
+			__LINE__, __FILE__, false, '', 'calendar') as $row)
2823 2820
 		{
2824 2821
 			switch ($row['cal_user_type'])
2825 2822
 			{
@@ -2916,14 +2913,14 @@  discard block
 block discarded – undo
2916 2913
 			}
2917 2914
 			$timezone = self::$tz_cache[$event['tzid']];
2918 2915
 		}
2919
-		$start_time = new egw_time($event['start'],egw_time::$server_timezone);
2916
+		$start_time = new egw_time($event['start'], egw_time::$server_timezone);
2920 2917
 		$start_time->setTimezone($timezone);
2921
-		$end_time = new egw_time($event['end'],egw_time::$server_timezone);
2918
+		$end_time = new egw_time($event['end'], egw_time::$server_timezone);
2922 2919
 		$end_time->setTimezone($timezone);
2923 2920
 		//error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2924 2921
 		//	'(): ' . $start . '-' . $end);
2925
-		$start = egw_time::to($start_time,'array');
2926
-		$end = egw_time::to($end_time,'array');
2922
+		$start = egw_time::to($start_time, 'array');
2923
+		$end = egw_time::to($end_time, 'array');
2927 2924
 
2928 2925
 
2929 2926
 		return !$start['hour'] && !$start['minute'] && $end['hour'] == 23 && $end['minute'] == 59;
@@ -2937,7 +2934,7 @@  discard block
 block discarded – undo
2937 2934
 	 *
2938 2935
 	 * @return DateTime
2939 2936
 	 */
2940
-	function &startOfDay(egw_time $time, $tz_id=null)
2937
+	function &startOfDay(egw_time $time, $tz_id = null)
2941 2938
 	{
2942 2939
 		if (empty($tz_id))
2943 2940
 		{
@@ -2962,14 +2959,14 @@  discard block
 block discarded – undo
2962 2959
 	 * @param int $time =null new timestamp, default current (server-)time
2963 2960
 	 * @param int $modifier =null uid of the modifier, default current user
2964 2961
 	 */
2965
-	function updateModified($id, $update_master=false, $time=null, $modifier=null)
2962
+	function updateModified($id, $update_master = false, $time = null, $modifier = null)
2966 2963
 	{
2967 2964
 		if (is_null($time) || !$time) $time = time();
2968 2965
 		if (is_null($modifier)) $modifier = $GLOBALS['egw_info']['user']['account_id'];
2969 2966
 
2970 2967
 		$this->db->update($this->cal_table,
2971 2968
 			array('cal_modified' => $time, 'cal_modifier' => $modifier),
2972
-			array('cal_id' => $id), __LINE__,__FILE__, 'calendar');
2969
+			array('cal_id' => $id), __LINE__, __FILE__, 'calendar');
2973 2970
 
2974 2971
 		// if event is an exception: update modified of master, to force etag, ctag and sync-token change
2975 2972
 		if ($update_master)
Please login to merge, or discard this patch.
Braces   +366 added lines, -96 removed lines patch added patch discarded remove patch
@@ -150,16 +150,32 @@  discard block
 block discarded – undo
150 150
 	 */
151 151
 	protected function cal_range_view($start, $end, array $_where=null, $deleted=false)
152 152
 	{
153
-		if ($GLOBALS['egw_info']['server']['no_timerange_views'] || !$start)	// using view without start-date is slower!
153
+		if ($GLOBALS['egw_info']['server']['no_timerange_views'] || !$start)
154 154
 		{
155
-			return $this->cal_table;	// no need / use for a view
155
+			// using view without start-date is slower!
156
+		{
157
+			return $this->cal_table;
158
+		}
159
+		// no need / use for a view
156 160
 		}
157 161
 
158 162
 		$where = array();
159
-		if (isset($deleted)) $where[] = "cal_deleted IS ".($deleted ? '' : 'NOT').' NULL';
160
-		if ($end) $where[] = "range_start<".(int)$end;
161
-		if ($start) $where[] = "(range_end IS NULL OR range_end>".(int)$start.")";
162
-		if ($_where) $where = array_merge($where, $_where);
163
+		if (isset($deleted))
164
+		{
165
+			$where[] = "cal_deleted IS ".($deleted ? '' : 'NOT').' NULL';
166
+		}
167
+		if ($end)
168
+		{
169
+			$where[] = "range_start<".(int)$end;
170
+		}
171
+		if ($start)
172
+		{
173
+			$where[] = "(range_end IS NULL OR range_end>".(int)$start.")";
174
+		}
175
+		if ($_where)
176
+		{
177
+			$where = array_merge($where, $_where);
178
+		}
163 179
 
164 180
 		$sql = "(SELECT * FROM $this->cal_table WHERE ".$this->db->expression($this->cal_table, $where).") $this->cal_table";
165 181
 
@@ -180,16 +196,32 @@  discard block
 block discarded – undo
180 196
 	 */
181 197
 	protected function dates_range_view($start, $end, array $_where=null, $deleted=false)
182 198
 	{
183
-		if ($GLOBALS['egw_info']['server']['no_timerange_views'] || !$start || !$end)	// using view without start- AND end-date is slower!
199
+		if ($GLOBALS['egw_info']['server']['no_timerange_views'] || !$start || !$end)
200
+		{
201
+			// using view without start- AND end-date is slower!
184 202
 		{
185
-			return $this->dates_table;	// no need / use for a view
203
+			return $this->dates_table;
204
+		}
205
+		// no need / use for a view
186 206
 		}
187 207
 
188 208
 		$where = array();
189
-		if (isset($deleted)) $where['recur_exception'] = $deleted;
190
-		if ($end) $where[] = "cal_start<".(int)$end;
191
-		if ($start) $where[] = "cal_end>".(int)$start;
192
-		if ($_where) $where = array_merge($where, $_where);
209
+		if (isset($deleted))
210
+		{
211
+			$where['recur_exception'] = $deleted;
212
+		}
213
+		if ($end)
214
+		{
215
+			$where[] = "cal_start<".(int)$end;
216
+		}
217
+		if ($start)
218
+		{
219
+			$where[] = "cal_end>".(int)$start;
220
+		}
221
+		if ($_where)
222
+		{
223
+			$where = array_merge($where, $_where);
224
+		}
193 225
 
194 226
 		// egw_db::union uses egw_db::select which check if join contains "WHERE"
195 227
 		// to support old join syntax like ", other_table WHERE ...",
@@ -239,7 +271,10 @@  discard block
 block discarded – undo
239 271
 			throw new egw_exception_assertion_failed("Unsupported value for parameters!");
240 272
 		}
241 273
 		$where = is_array($params['query']) ? $params['query'] : array();
242
-		if ($cat_id) $where[] = $this->cat_filter($cat_id);
274
+		if ($cat_id)
275
+		{
276
+			$where[] = $this->cat_filter($cat_id);
277
+		}
243 278
 		$egw_cal = $this->cal_range_view($start, $end, $where, $filter == 'everything' ? null : $filter != 'deleted');
244 279
 
245 280
 		$status_filter = $this->status_filter($filter, $params['enum_recuring']);
@@ -260,7 +295,10 @@  discard block
 block discarded – undo
260 295
 		if ($users)
261 296
 		{
262 297
 			// fix $users to also prefix system users and groups (with 'u')
263
-			if (!is_array($users)) $users = $users ? (array)$users : array();
298
+			if (!is_array($users))
299
+			{
300
+				$users = $users ? (array)$users : array();
301
+			}
264 302
 			foreach($users as &$uid)
265 303
 			{
266 304
 				$user_type = $user_id = null;
@@ -280,15 +318,22 @@  discard block
 block discarded – undo
280 318
 			$sql .= " AND\n	".$params['sql_filter'];
281 319
 		}
282 320
 
283
-		if ($params['order'])	// only order if requested
321
+		if ($params['order'])
284 322
 		{
285
-			if (!preg_match('/^[a-z_ ,c]+$/i',$params['order'])) $params['order'] = 'cal_start';		// gard against SQL injection
323
+			// only order if requested
324
+		{
325
+			if (!preg_match('/^[a-z_ ,c]+$/i',$params['order'])) $params['order'] = 'cal_start';
326
+		}
327
+		// gard against SQL injection
286 328
 			$sql .= "\nORDER BY ".$params['order'];
287 329
 		}
288 330
 
289
-		if ($offset === false)	// return all rows --> egw_db::query wants offset=0, num_rows=-1
331
+		if ($offset === false)
332
+		{
333
+			// return all rows --> egw_db::query wants offset=0, num_rows=-1
290 334
 		{
291 335
 			$offset = 0;
336
+		}
292 337
 			$num_rows = -1;
293 338
 		}
294 339
 		$events =& $this->get_events($this->db->query($sql, __LINE__, __FILE__, $offset, $num_rows));
@@ -314,26 +359,35 @@  discard block
 block discarded – undo
314 359
 		$join = "LEFT JOIN $this->repeats_table ON $this->cal_table.cal_id=$this->repeats_table.cal_id";
315 360
 
316 361
 		$where = array();
317
-		if (is_scalar($ids) && !is_numeric($ids))	// a single uid
362
+		if (is_scalar($ids) && !is_numeric($ids))
363
+		{
364
+			// a single uid
318 365
 		{
319 366
 			// We want only the parents to match
320 367
 			$where['cal_uid'] = $ids;
368
+		}
321 369
 			$where['cal_reference'] = 0;
322 370
 		}
323
-		elseif(is_array($ids) && isset($ids[count($ids)-1]) || is_scalar($ids))	// one or more cal_id's
371
+		elseif(is_array($ids) && isset($ids[count($ids)-1]) || is_scalar($ids))
372
+		{
373
+			// one or more cal_id's
324 374
 		{
325 375
 			$where['cal_id'] = $ids;
326 376
 		}
377
+		}
327 378
 		else	// array with column => value pairs
328 379
 		{
329 380
 			$where = $ids;
330 381
 			unset($ids);	// otherwise users get not read!
331 382
 		}
332
-		if (isset($where['cal_id']))	// prevent non-unique column-name cal_id
383
+		if (isset($where['cal_id']))
384
+		{
385
+			// prevent non-unique column-name cal_id
333 386
 		{
334 387
 			$where[] = $this->db->expression($this->cal_table, $this->cal_table.'.',array(
335 388
 				'cal_id' => $where['cal_id'],
336 389
 			));
390
+		}
337 391
 			unset($where['cal_id']);
338 392
 		}
339 393
 		if ((int) $recur_date)
@@ -383,10 +437,16 @@  discard block
 block discarded – undo
383 437
 			$row['recur_exception'] = $row['alarm'] = array();
384 438
 			$events[$row['cal_id']] = egw_db::strip_array_keys($row,'cal_');
385 439
 		}
386
-		if (!$events) return $events;
440
+		if (!$events)
441
+		{
442
+			return $events;
443
+		}
387 444
 
388 445
 		$ids = array_keys($events);
389
-		if (count($ids) == 1) $ids = $ids[0];
446
+		if (count($ids) == 1)
447
+		{
448
+			$ids = $ids[0];
449
+		}
390 450
 
391 451
 		foreach ($events as &$event)
392 452
 		{
@@ -460,10 +520,13 @@  discard block
 block discarded – undo
460 520
 			'cal_id'      => $ids,
461 521
 			'cal_recur_date' => $recur_date,
462 522
 			"cal_status NOT IN ('X','E')",
463
-		),__LINE__,__FILE__,false,'ORDER BY cal_user_type DESC,cal_recur_date ASC,'.self::STATUS_SORT,'calendar') as $row)	// DESC puts users before resources and contacts
523
+		),__LINE__,__FILE__,false,'ORDER BY cal_user_type DESC,cal_recur_date ASC,'.self::STATUS_SORT,'calendar') as $row)
524
+		{
525
+			// DESC puts users before resources and contacts
464 526
 		{
465 527
 			// combine all participant data in uid and status values
466 528
 			$uid    = self::combine_user($row['cal_user_type'], $row['cal_user_id'], $row['cal_user_attendee']);
529
+		}
467 530
 			$status = self::combine_status($row['cal_status'],$row['cal_quantity'],$row['cal_role']);
468 531
 
469 532
 			$events[$row['cal_id']]['participants'][$uid] = $status;
@@ -520,7 +583,10 @@  discard block
 block discarded – undo
520 583
 			$last_request = time();
521 584
 		}
522 585
 		$signature = serialize(func_get_args());
523
-		if (isset($ctags[$signature])) return $ctags[$signature];
586
+		if (isset($ctags[$signature]))
587
+		{
588
+			return $ctags[$signature];
589
+		}
524 590
 
525 591
 		$types = array();
526 592
 		foreach((array)$users as $uid)
@@ -553,7 +619,10 @@  discard block
 block discarded – undo
553 619
 			// owner can only by users, no groups or resources
554 620
 			foreach($users as $key => $user)
555 621
 			{
556
-				if (!($user > 0)) unset($users[$key]);
622
+				if (!($user > 0))
623
+				{
624
+					unset($users[$key]);
625
+				}
557 626
 			}
558 627
 			$where = $this->db->expression($this->user_table, '(', $where, ' OR ').
559 628
 				$this->db->expression($this->cal_table, array(
@@ -575,7 +644,10 @@  discard block
 block discarded – undo
575 644
 	 */
576 645
 	function get_cal_data(array $query, $cols='cal_id,cal_reference,cal_etag,cal_modified,cal_user_modified')
577 646
 	{
578
-		if (!is_array($cols)) $cols = explode(',', $cols);
647
+		if (!is_array($cols))
648
+		{
649
+			$cols = explode(',', $cols);
650
+		}
579 651
 
580 652
 		// special handling of cal_user_modified "pseudo" column
581 653
 		if (($key = array_search('cal_user_modified', $cols)) !== false)
@@ -600,7 +672,10 @@  discard block
 block discarded – undo
600 672
 		{
601 673
 			$cats = $GLOBALS['egw']->categories->return_all_children($cat_id);
602 674
 			array_walk($cats,create_function('&$val,$key','$val = (int) $val;'));
603
-			if (is_array($cat_id) && count($cat_id)==1) $cat_id = $cat_id[0];
675
+			if (is_array($cat_id) && count($cat_id)==1)
676
+			{
677
+				$cat_id = $cat_id[0];
678
+			}
604 679
 			$sql = '(cal_category'.(count($cats) > 1 ? " IN ('".implode("','",$cats)."')" : '='.$this->db->quote((int)$cat_id));
605 680
 			foreach($cats as $cat)
606 681
 			{
@@ -659,10 +734,13 @@  discard block
 block discarded – undo
659 734
 				$where[] = "$this->user_table.cal_status NOT IN ('X','E')";
660 735
 				break;
661 736
 			default:
662
-				if ($enum_recuring)	// regular UI
737
+				if ($enum_recuring)
738
+				{
739
+					// regular UI
663 740
 				{
664 741
 					$where[] = "$this->user_table.cal_status NOT IN ('R','X','E')";
665 742
 				}
743
+				}
666 744
 				else	// CalDAV / eSync / iCal need to include 'E' = exceptions
667 745
 				{
668 746
 					$where[] = "$this->user_table.cal_status NOT IN ('R','X')";
@@ -794,7 +872,10 @@  discard block
 block discarded – undo
794 872
 						$user_ids = array();
795 873
 						foreach($ids as $user_id)
796 874
 						{
797
-							if ($GLOBALS['egw']->accounts->get_type($user_id) === 'u') $user_ids[] = $user_id;
875
+							if ($GLOBALS['egw']->accounts->get_type($user_id) === 'u')
876
+							{
877
+								$user_ids[] = $user_id;
878
+							}
798 879
 						}
799 880
 						$owner_or = $this->db->expression($cal_table_def,array('cal_owner' => $user_ids));
800 881
 					}
@@ -814,7 +895,10 @@  discard block
 block discarded – undo
814 895
 				}
815 896
 			}
816 897
 			// this is only used, when we cannot use UNIONS
817
-			if (!$useUnionQuery) $where[] = '('.implode(' OR ',$to_or).')';
898
+			if (!$useUnionQuery)
899
+			{
900
+				$where[] = '('.implode(' OR ',$to_or).')';
901
+			}
818 902
 
819 903
 			$where = $this->status_filter($filter, $params['enum_recuring'], $where);
820 904
 		}
@@ -833,7 +917,11 @@  discard block
 block discarded – undo
833 917
 				$where[] = '('.((int)$start).' < range_end OR range_end IS NULL)';
834 918
 			}
835 919
 		}
836
-		if (!preg_match('/^[a-z_ ,c]+$/i',$params['order'])) $params['order'] = 'cal_start';		// gard against SQL injection
920
+		if (!preg_match('/^[a-z_ ,c]+$/i',$params['order']))
921
+		{
922
+			$params['order'] = 'cal_start';
923
+		}
924
+		// gard against SQL injection
837 925
 
838 926
 		// if not enum recuring events, we have to use minimum start- AND end-dates, otherwise we get more then one event per cal_id!
839 927
 		if (!$params['enum_recuring'])
@@ -843,9 +931,15 @@  discard block
 block discarded – undo
843 931
 			// in case cal_start is used in a query, eg. calendar_ical::find_event
844 932
 			$where = str_replace(array('cal_start','cal_end'), array('range_start','(SELECT MIN(cal_end) FROM egw_cal_dates WHERE egw_cal.cal_id=egw_cal_dates.cal_id)'), $where);
845 933
 			$params['order'] = str_replace('cal_start', 'range_start', $params['order']);
846
-			if ($end) $where[] = (int)$end.' > range_start';
934
+			if ($end)
935
+			{
936
+				$where[] = (int)$end.' > range_start';
937
+			}
847 938
   		}
848
-		elseif ($end) $where[] = (int)$end.' > cal_start';
939
+  		elseif ($end)
940
+		{
941
+			$where[] = (int)$end.' > cal_start';
942
+		}
849 943
 
850 944
 		if ($remove_rejected_by_user && $filter != 'everything')
851 945
 		{
@@ -859,7 +953,10 @@  discard block
 block discarded – undo
859 953
 				'rejected_by_user.cal_status IS NULL',
860 954
 				"rejected_by_user.cal_status NOT IN ('R','X')",
861 955
 			);
862
-			if ($filter == 'owner') $or_required[] = 'cal_owner='.(int)$remove_rejected_by_user;
956
+			if ($filter == 'owner')
957
+			{
958
+				$or_required[] = 'cal_owner='.(int)$remove_rejected_by_user;
959
+			}
863 960
 			$where[] = '('.implode(' OR ',$or_required).')';
864 961
 		}
865 962
 		// using a time-range and deleted attribute limited view instead of full table
@@ -881,7 +978,10 @@  discard block
 block discarded – undo
881 978
 		if ($useUnionQuery)
882 979
 		{
883 980
 			// allow apps to supply participants and/or icons
884
-			if (!isset($params['cols'])) $cols .= ',NULL AS participants,NULL AS icons';
981
+			if (!isset($params['cols']))
982
+			{
983
+				$cols .= ',NULL AS participants,NULL AS icons';
984
+			}
885 985
 
886 986
 			// changed the original OR in the query into a union, to speed up the query execution under MySQL 5
887 987
 			// with time-range views benefit is now at best slim for huge tables or none at all!
@@ -936,9 +1036,12 @@  discard block
 block discarded – undo
936 1036
 					$selects[count($selects)-1]['where'][] = "$this->user_table.cal_recur_date=cal_start";
937 1037
 				}
938 1038
 			}
939
-			if (is_numeric($offset) && !$params['no_total'])	// get the total too
1039
+			if (is_numeric($offset) && !$params['no_total'])
1040
+			{
1041
+				// get the total too
940 1042
 			{
941 1043
 				$save_selects = $selects;
1044
+			}
942 1045
 				// we only select cal_table.cal_id (and not cal_table.*) to be able to use DISTINCT (eg. MsSQL does not allow it for text-columns)
943 1046
 				foreach(array_keys($selects) as $key)
944 1047
 				{
@@ -949,14 +1052,20 @@  discard block
 block discarded – undo
949 1052
 							array('range_start AS cal_start','range_end AS cal_end'), $selects[$key]['cols']);
950 1053
 					}
951 1054
 				}
952
-				if (!isset($params['cols']) && !$params['no_integration']) self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']);
1055
+				if (!isset($params['cols']) && !$params['no_integration'])
1056
+				{
1057
+					self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']);
1058
+				}
953 1059
 
954 1060
 				$this->total = $this->db->union($selects,__LINE__,__FILE__)->NumRows();
955 1061
 
956 1062
 				// restore original cols / selects
957 1063
 				$selects = $save_selects; unset($save_selects);
958 1064
 			}
959
-			if (!isset($params['cols']) && !$params['no_integration']) self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']);
1065
+			if (!isset($params['cols']) && !$params['no_integration'])
1066
+			{
1067
+				self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']);
1068
+			}
960 1069
 
961 1070
 			$rs = $this->db->union($selects,__LINE__,__FILE__,$params['order'],$offset,$num_rows);
962 1071
 		}
@@ -974,9 +1083,12 @@  discard block
 block discarded – undo
974 1083
 				'table_def' => $cal_table_def,
975 1084
 			));
976 1085
 
977
-			if (is_numeric($offset) && !$params['no_total'])	// get the total too
1086
+			if (is_numeric($offset) && !$params['no_total'])
1087
+			{
1088
+				// get the total too
978 1089
 			{
979 1090
 				$save_selects = $selects;
1091
+			}
980 1092
 				// we only select cal_table.cal_id (and not cal_table.*) to be able to use DISTINCT (eg. MsSQL does not allow it for text-columns)
981 1093
 				$selects[0]['cols'] = "$this->cal_table.cal_id,cal_start";
982 1094
 				if (!isset($params['cols']) && !$params['no_integration'] && $this->db->capabilities['union'])
@@ -1004,7 +1116,10 @@  discard block
 block discarded – undo
1004 1116
 		foreach($rs as $row)
1005 1117
 		{
1006 1118
 			$id = $row['cal_id'];
1007
-			if (is_numeric($id)) $ids[] = $id;
1119
+			if (is_numeric($id))
1120
+			{
1121
+				$ids[] = $id;
1122
+			}
1008 1123
 
1009 1124
 			if ($row['cal_recur_date'])
1010 1125
 			{
@@ -1024,7 +1139,10 @@  discard block
 block discarded – undo
1024 1139
 			$row['recur_exception'] = $row['alarm'] = array();
1025 1140
 
1026 1141
 			// compile a list of recurrences per cal_id
1027
-			if (!in_array($id,(array)$recur_ids[$row['cal_id']])) $recur_ids[$row['cal_id']][] = $id;
1142
+			if (!in_array($id,(array)$recur_ids[$row['cal_id']]))
1143
+			{
1144
+				$recur_ids[$row['cal_id']][] = $id;
1145
+			}
1028 1146
 
1029 1147
 			$events[$id] = egw_db::strip_array_keys($row,'cal_');
1030 1148
 		}
@@ -1043,10 +1161,16 @@  discard block
 block discarded – undo
1043 1161
 					//'cal_id' => array_unique($ids),
1044 1162
 					'cal_recur_date' => $recur_dates,
1045 1163
 				),__LINE__,__FILE__,false,'ORDER BY cal_id,cal_user_type DESC,'.self::STATUS_SORT,'calendar',$num_rows,$join='',
1046
-				$this->db->get_table_definitions('calendar',$this->user_table)) as $row)	// DESC puts users before resources and contacts
1164
+				$this->db->get_table_definitions('calendar',$this->user_table)) as $row)
1165
+			{
1166
+				// DESC puts users before resources and contacts
1047 1167
 			{
1048 1168
 				$id = $row['cal_id'];
1049
-				if ($row['cal_recur_date']) $id .= '-'.$row['cal_recur_date'];
1169
+			}
1170
+				if ($row['cal_recur_date'])
1171
+				{
1172
+					$id .= '-'.$row['cal_recur_date'];
1173
+				}
1050 1174
 
1051 1175
 				// combine all participant data in uid and status values
1052 1176
 				$uid = self::combine_user($row['cal_user_type'], $row['cal_user_id'], $row['cal_user_attendee']);
@@ -1065,7 +1189,10 @@  discard block
 block discarded – undo
1065 1189
 				}
1066 1190
 
1067 1191
 				// set data, if recurrence is requested
1068
-				if (isset($events[$id])) $events[$id]['participants'][$uid] = $status;
1192
+				if (isset($events[$id]))
1193
+				{
1194
+					$events[$id]['participants'][$uid] = $status;
1195
+				}
1069 1196
 			}
1070 1197
 			// query recurrance exceptions, if needed: enum_recuring && !daywise is used in calendar_groupdav::get_series($uid,...)
1071 1198
 			if (!$params['enum_recuring'] || !$params['daywise'])
@@ -1081,7 +1208,10 @@  discard block
 block discarded – undo
1081 1208
 					{
1082 1209
 						foreach($events as $id => $event)
1083 1210
 						{
1084
-							if ($event['id'] == $row['cal_id']) break;
1211
+							if ($event['id'] == $row['cal_id'])
1212
+							{
1213
+								break;
1214
+							}
1085 1215
 						}
1086 1216
 					}
1087 1217
 					$events[$id]['recur_exception'][] = $row['cal_start'];
@@ -1091,7 +1221,10 @@  discard block
 block discarded – undo
1091 1221
 			if (!is_null($params['cfs']))
1092 1222
 			{
1093 1223
 				$where = array('cal_id' => $ids);
1094
-				if ($params['cfs']) $where['cal_extra_name'] = $params['cfs'];
1224
+				if ($params['cfs'])
1225
+				{
1226
+					$where['cal_extra_name'] = $params['cfs'];
1227
+				}
1095 1228
 				foreach($this->db->select($this->extra_table,'*',$where,
1096 1229
 					__LINE__,__FILE__,false,'','calendar') as $row)
1097 1230
 				{
@@ -1111,14 +1244,20 @@  discard block
 block discarded – undo
1111 1244
 				{
1112 1245
 					$event_start = $alarm['time'] + $alarm['offset'];
1113 1246
 
1114
-					if (isset($events[$cal_id]))	// none recuring event
1247
+					if (isset($events[$cal_id]))
1248
+					{
1249
+						// none recuring event
1115 1250
 					{
1116 1251
 						$events[$cal_id]['alarm'][$id] = $alarm;
1117 1252
 					}
1118
-					elseif (isset($events[$cal_id.'-'.$event_start]))	// recuring event
1253
+					}
1254
+					elseif (isset($events[$cal_id.'-'.$event_start]))
1255
+					{
1256
+						// recuring event
1119 1257
 					{
1120 1258
 						$events[$cal_id.'-'.$event_start]['alarm'][$id] = $alarm;
1121 1259
 					}
1260
+					}
1122 1261
 				}
1123 1262
 			}
1124 1263
 		}
@@ -1218,10 +1357,13 @@  discard block
 block discarded – undo
1218 1357
 			}
1219 1358
 			foreach((array)$cols as $col)
1220 1359
 			{
1221
-				if (substr($col,0,7) == 'egw_cal')	// remove table name
1360
+				if (substr($col,0,7) == 'egw_cal')
1361
+				{
1362
+					// remove table name
1222 1363
 				{
1223 1364
 					$col = preg_replace('/^egw_cal[a-z_]*\./','',$col);
1224 1365
 				}
1366
+				}
1225 1367
 				if (isset($app_cols[$col]))
1226 1368
 				{
1227 1369
 					$return_cols[] = $app_cols[$col];
@@ -1315,7 +1457,11 @@  discard block
 block discarded – undo
1315 1457
 		if (isset($GLOBALS['egw_info']['user']['preferences']['syncml']['minimum_uid_length']))
1316 1458
 		{
1317 1459
 			$minimum_uid_length = $GLOBALS['egw_info']['user']['preferences']['syncml']['minimum_uid_length'];
1318
-			if (empty($minimum_uid_length) || $minimum_uid_length<=1) $minimum_uid_length = 8; // we just do not accept no uid, or uid way to short!
1460
+			if (empty($minimum_uid_length) || $minimum_uid_length<=1)
1461
+			{
1462
+				$minimum_uid_length = 8;
1463
+			}
1464
+			// we just do not accept no uid, or uid way to short!
1319 1465
 		}
1320 1466
 		else
1321 1467
 		{
@@ -1363,7 +1509,10 @@  discard block
 block discarded – undo
1363 1509
 			}
1364 1510
 		}
1365 1511
 		// set range_start/_end, but only if we have cal_start/_end, as otherwise we destroy present values!
1366
-		if (isset($event['cal_start'])) $event['range_start'] = $event['cal_start'];
1512
+		if (isset($event['cal_start']))
1513
+		{
1514
+			$event['range_start'] = $event['cal_start'];
1515
+		}
1367 1516
 		if (isset($event['cal_end']))
1368 1517
 		{
1369 1518
 			$event['range_end'] = $event['recur_type'] == MCAL_RECUR_NONE ? $event['cal_end'] :
@@ -1384,7 +1533,10 @@  discard block
 block discarded – undo
1384 1533
 		$event['cal_category'] = implode(',',$categories);
1385 1534
 
1386 1535
 		// make sure recurring events never reference to an other recurrent event
1387
-		if ($event['recur_type'] != MCAL_RECUR_NONE) $event['cal_reference'] = 0;
1536
+		if ($event['recur_type'] != MCAL_RECUR_NONE)
1537
+		{
1538
+			$event['cal_reference'] = 0;
1539
+		}
1388 1540
 
1389 1541
 		if ($cal_id)
1390 1542
 		{
@@ -1401,7 +1553,10 @@  discard block
 block discarded – undo
1401 1553
 			{
1402 1554
 				$old_tz_id = $this->db->select($this->cal_table,'tz_id',$where,__LINE__,__FILE__,'calendar')->fetchColumn();
1403 1555
 			}
1404
-			if (!is_null($etag)) $where['cal_etag'] = $etag;
1556
+			if (!is_null($etag))
1557
+			{
1558
+				$where['cal_etag'] = $etag;
1559
+			}
1405 1560
 
1406 1561
 			unset($event['cal_etag']);
1407 1562
 			$event[] = 'cal_etag=cal_etag+1';	// always update the etag, even if none given to check
@@ -1412,14 +1567,24 @@  discard block
 block discarded – undo
1412 1567
 			{
1413 1568
 				return 0;	// wrong etag, someone else updated the entry
1414 1569
 			}
1415
-			if (!is_null($etag)) ++$etag;
1570
+			if (!is_null($etag))
1571
+			{
1572
+				++$etag;
1573
+			}
1416 1574
 		}
1417 1575
 		else
1418 1576
 		{
1419 1577
 			// new event
1420
-			if (!$event['cal_owner']) $event['cal_owner'] = $GLOBALS['egw_info']['user']['account_id'];
1578
+			if (!$event['cal_owner'])
1579
+			{
1580
+				$event['cal_owner'] = $GLOBALS['egw_info']['user']['account_id'];
1581
+			}
1421 1582
 
1422
-			if (!$event['cal_id'] && !isset($event['cal_uid'])) $event['cal_uid'] = '';	// uid is NOT NULL!
1583
+			if (!$event['cal_id'] && !isset($event['cal_uid']))
1584
+			{
1585
+				$event['cal_uid'] = '';
1586
+			}
1587
+			// uid is NOT NULL!
1423 1588
 
1424 1589
 			$this->db->insert($this->cal_table,$event,false,__LINE__,__FILE__,'calendar');
1425 1590
 			if (!($cal_id = $this->db->get_last_insert_id($this->cal_table,'cal_id')))
@@ -1571,8 +1736,7 @@  discard block
 block discarded – undo
1571 1736
 					// recurrences need to be truncated
1572 1737
 					if((int)$event['recur_enddate'] > 0 &&
1573 1738
 						((int)$old_repeats['recur_enddate'] == 0 || (int)$old_repeats['recur_enddate'] > (int)$event['recur_enddate'])
1574
-					)
1575
-					{
1739
+					) {
1576 1740
 						$this->db->delete($this->user_table,array('cal_id' => $cal_id,'cal_recur_date >= '.($event['recur_enddate'] + 1*DAY_s)),__LINE__,__FILE__,'calendar');
1577 1741
 						$this->db->delete($this->dates_table,array('cal_id' => $cal_id,'cal_start >= '.($event['recur_enddate'] + 1*DAY_s)),__LINE__,__FILE__,'calendar');
1578 1742
 					}
@@ -1580,8 +1744,7 @@  discard block
 block discarded – undo
1580 1744
 					// recurrences need to be expanded
1581 1745
 					if(((int)$event['recur_enddate'] == 0 && (int)$old_repeats['recur_enddate'] > 0)
1582 1746
 						|| ((int)$event['recur_enddate'] > 0 && (int)$old_repeats['recur_enddate'] > 0 && (int)$old_repeats['recur_enddate'] < (int)$event['recur_enddate'])
1583
-					)
1584
-					{
1747
+					) {
1585 1748
 						$set_recurrences = true;
1586 1749
 						$set_recurrences_start = ($old_repeats['recur_enddate'] + 1*DAY_s);
1587 1750
 					}
@@ -1728,12 +1891,18 @@  discard block
 block discarded – undo
1728 1891
 	{
1729 1892
 		//echo "<p>socal::move($cal_id,$start,$end,$change_since,$old_start,$old_end)</p>\n";
1730 1893
 
1731
-		if (!(int) $cal_id) return false;
1894
+		if (!(int) $cal_id)
1895
+		{
1896
+			return false;
1897
+		}
1732 1898
 
1733 1899
 		if (!$old_start)
1734 1900
 		{
1735
-			if ($change_since !== false) $row = $this->db->select($this->dates_table,'MIN(cal_start) AS cal_start,MIN(cal_end) AS cal_end',
1901
+			if ($change_since !== false)
1902
+			{
1903
+				$row = $this->db->select($this->dates_table,'MIN(cal_start) AS cal_start,MIN(cal_end) AS cal_end',
1736 1904
 				array('cal_id'=>$cal_id),__LINE__,__FILE__,false,'','calendar')->fetch();
1905
+			}
1737 1906
 			// if no recurrence found, create one with the new dates
1738 1907
 			if ($change_since === false || !$row || !$row['cal_start'] || !$row['cal_end'])
1739 1908
 			{
@@ -1835,7 +2004,10 @@  discard block
 block discarded – undo
1835 2004
 			$user_type = $uid[0];
1836 2005
 			$email = substr($uid, 1);
1837 2006
 			$matches = null;
1838
-			if (preg_match('/<([^<>]+)>$/', $email, $matches)) $email = $matches[1];
2007
+			if (preg_match('/<([^<>]+)>$/', $email, $matches))
2008
+			{
2009
+				$email = $matches[1];
2010
+			}
1839 2011
 			$user_id = md5(trim(strtolower($email)));
1840 2012
 		}
1841 2013
 		else
@@ -1855,8 +2027,14 @@  discard block
 block discarded – undo
1855 2027
 	 */
1856 2028
 	static function combine_status($status,$quantity=1,$role='REQ-PARTICIPANT')
1857 2029
 	{
1858
-		if ((int)$quantity > 1) $status .= (int)$quantity;
1859
-		if ($role != 'REQ-PARTICIPANT') $status .= $role;
2030
+		if ((int)$quantity > 1)
2031
+		{
2032
+			$status .= (int)$quantity;
2033
+		}
2034
+		if ($role != 'REQ-PARTICIPANT')
2035
+		{
2036
+			$status .= $role;
2037
+		}
1860 2038
 
1861 2039
 		return $status;
1862 2040
 	}
@@ -1877,8 +2055,14 @@  discard block
 block discarded – undo
1877 2055
 		$matches = null;
1878 2056
 		if (is_string($status) && strlen($status) > 1 && preg_match('/^.([0-9]*)(.*)$/',$status,$matches))
1879 2057
 		{
1880
-			if ((int)$matches[1] > 0) $quantity = (int)$matches[1];
1881
-			if ($matches[2]) $role = $matches[2];
2058
+			if ((int)$matches[1] > 0)
2059
+			{
2060
+				$quantity = (int)$matches[1];
2061
+			}
2062
+			if ($matches[2])
2063
+			{
2064
+				$role = $matches[2];
2065
+			}
1882 2066
 			$status = $status[0];
1883 2067
 		}
1884 2068
 		elseif ($status === true)
@@ -1989,9 +2173,13 @@  discard block
 block discarded – undo
1989 2173
 			}
1990 2174
 		}
1991 2175
 
1992
-		if (count($participants))	// participants which need to be added
2176
+		if (count($participants))
2177
+		{
2178
+			// participants which need to be added
1993 2179
 		{
1994
-			if (!count($recurrences)) $recurrences[] = 0;   // insert the default recurrence
2180
+			if (!count($recurrences)) $recurrences[] = 0;
2181
+		}
2182
+		// insert the default recurrence
1995 2183
 
1996 2184
 			$delete_deleted = array();
1997 2185
 
@@ -2063,7 +2251,10 @@  discard block
 block discarded – undo
2063 2251
 			return false;
2064 2252
 		}
2065 2253
 
2066
-		if (is_numeric($status)) $status = $status_code_short[$status];
2254
+		if (is_numeric($status))
2255
+		{
2256
+			$status = $status_code_short[$status];
2257
+		}
2067 2258
 
2068 2259
 		$uid = self::combine_user($user_type, $user_id);
2069 2260
 		$user_id_md5 = null;
@@ -2083,16 +2274,25 @@  discard block
 block discarded – undo
2083 2274
 			$where[] = '(cal_recur_date=0 OR cal_recur_date >= '.time().')';
2084 2275
 		}
2085 2276
 
2086
-		if ($status == 'G')		// remove group invitations, as we dont store them in the db
2277
+		if ($status == 'G')
2278
+		{
2279
+			// remove group invitations, as we dont store them in the db
2087 2280
 		{
2088 2281
 			$this->db->delete($this->user_table,$where,__LINE__,__FILE__,'calendar');
2282
+		}
2089 2283
 			$ret = $this->db->affected_rows();
2090 2284
 		}
2091 2285
 		else
2092 2286
 		{
2093 2287
 			$set = array('cal_status' => $status);
2094
-			if ($user_type == 'e' || $attendee) $set['cal_user_attendee'] = $attendee ? $attendee : $user_id;
2095
-			if (!is_null($role) && $role != 'REQ-PARTICIPANT') $set['cal_role'] = $role;
2288
+			if ($user_type == 'e' || $attendee)
2289
+			{
2290
+				$set['cal_user_attendee'] = $attendee ? $attendee : $user_id;
2291
+			}
2292
+			if (!is_null($role) && $role != 'REQ-PARTICIPANT')
2293
+			{
2294
+				$set['cal_role'] = $role;
2295
+			}
2096 2296
 			$this->db->insert($this->user_table,$set,$where,__LINE__,__FILE__,'calendar');
2097 2297
 			// for new or changed group-invitations, remove previously deleted members, so they show up again
2098 2298
 			if (($ret = $this->db->affected_rows()) && $user_type == 'u' && $user_id < 0)
@@ -2125,7 +2325,10 @@  discard block
 block discarded – undo
2125 2325
 	{
2126 2326
 		//error_log(__METHOD__."($cal_id, $start, $end, ".array2string($participants).", ".array2string($exception));
2127 2327
 		$update = array('cal_end' => $end);
2128
-		if (isset($exception)) $update['recur_exception'] = $exception;
2328
+		if (isset($exception))
2329
+		{
2330
+			$update['recur_exception'] = $exception;
2331
+		}
2129 2332
 
2130 2333
 		$this->db->insert($this->dates_table, $update, array(
2131 2334
 			'cal_id' => $cal_id,
@@ -2140,7 +2343,11 @@  discard block
 block discarded – undo
2140 2343
 		{
2141 2344
 			foreach($participants as $uid => $status)
2142 2345
 			{
2143
-				if ($status == 'G') continue;	// dont save group-invitations
2346
+				if ($status == 'G')
2347
+				{
2348
+					continue;
2349
+				}
2350
+				// dont save group-invitations
2144 2351
 
2145 2352
 				$type = '';
2146 2353
 				$id = null;
@@ -2369,7 +2576,10 @@  discard block
 block discarded – undo
2369 2576
 		}
2370 2577
 		$alarm['cal_id'] = $cal_id;		// we need the back-reference
2371 2578
 		// add an alarm uid, if none is given
2372
-		if (empty($alarm['uid']) && class_exists('Horde_Support_Uuid')) $alarm['uid'] = (string)new Horde_Support_Uuid;
2579
+		if (empty($alarm['uid']) && class_exists('Horde_Support_Uuid'))
2580
+		{
2581
+			$alarm['uid'] = (string)new Horde_Support_Uuid;
2582
+		}
2373 2583
 		//error_log(__METHOD__.__LINE__.' Save Alarm for CalID:'.$cal_id.'->'.array2string($alarm).'-->'.$id.'#'.function_backtrace());
2374 2584
 		// allways store job with the alarm owner as job-owner to get eg. the correct from address
2375 2585
 		if (!$this->async->set_timer($alarm['time'],$id,'calendar.calendar_boupdate.send_alarm',$alarm,$alarm['owner']))
@@ -2378,10 +2588,16 @@  discard block
 block discarded – undo
2378 2588
 		}
2379 2589
 
2380 2590
 		// update the modification information of the related event
2381
-		if ($update_modified) $this->updateModified($cal_id, true);
2591
+		if ($update_modified)
2592
+		{
2593
+			$this->updateModified($cal_id, true);
2594
+		}
2382 2595
 
2383 2596
 		// update cache, if used
2384
-		if (isset(self::$alarm_cache)) $this->read_alarms($cal_id, true);
2597
+		if (isset(self::$alarm_cache))
2598
+		{
2599
+			$this->read_alarms($cal_id, true);
2600
+		}
2385 2601
 
2386 2602
 		return $id;
2387 2603
 	}
@@ -2404,7 +2620,10 @@  discard block
 block discarded – undo
2404 2620
 				$this->async->cancel_timer($id);
2405 2621
 			}
2406 2622
 			// update cache, if used
2407
-			if (isset(self::$alarm_cache)) $this->read_alarms($cal_id, false);
2623
+			if (isset(self::$alarm_cache))
2624
+			{
2625
+				$this->read_alarms($cal_id, false);
2626
+			}
2408 2627
 		}
2409 2628
 		return count($alarms);
2410 2629
 	}
@@ -2427,7 +2646,10 @@  discard block
 block discarded – undo
2427 2646
 		$ret = $this->async->cancel_timer($id);
2428 2647
 
2429 2648
 		// update cache, if used
2430
-		if (isset(self::$alarm_cache)) $this->read_alarms($cal_id, true);
2649
+		if (isset(self::$alarm_cache))
2650
+		{
2651
+			$this->read_alarms($cal_id, true);
2652
+		}
2431 2653
 
2432 2654
 		return $ret;
2433 2655
 	}
@@ -2451,11 +2673,14 @@  discard block
 block discarded – undo
2451 2673
 			$user_id = null;
2452 2674
 			self::split_user($old_user,$user_type,$user_id);
2453 2675
 
2454
-			if ($user_type == 'u')	// only accounts can be owners of events
2676
+			if ($user_type == 'u')
2677
+			{
2678
+				// only accounts can be owners of events
2455 2679
 			{
2456 2680
 				foreach($this->db->select($this->cal_table,'cal_id',array('cal_owner' => $old_user),__LINE__,__FILE__,false,'','calendar') as $row)
2457 2681
 				{
2458 2682
 					$this->delete($row['cal_id']);
2683
+			}
2459 2684
 				}
2460 2685
 			}
2461 2686
 			$this->db->delete($this->user_table,array(
@@ -2483,11 +2708,14 @@  discard block
 block discarded – undo
2483 2708
 			{
2484 2709
 				$ids[] = $row['cal_id'];
2485 2710
 			}
2486
-			if ($ids) $this->db->delete($this->user_table,array(
2711
+			if ($ids)
2712
+			{
2713
+				$this->db->delete($this->user_table,array(
2487 2714
 				'cal_user_type' => 'u',
2488 2715
 				'cal_user_id' => $old_user,
2489 2716
 				'cal_id' => $ids,
2490 2717
 			),__LINE__,__FILE__,'calendar');
2718
+			}
2491 2719
 			// now change participant in the rest to contain new user instead of old user
2492 2720
 			$this->db->update($this->user_table,array(
2493 2721
 				'cal_user_id' => $new_user,
@@ -2512,8 +2740,14 @@  discard block
 block discarded – undo
2512 2740
 	{
2513 2741
 		$participant_status = array();
2514 2742
 		$where = array('cal_id' => $cal_id);
2515
-		if ($start != 0 && $end == 0) $where[] = '(cal_recur_date = 0 OR cal_recur_date >= ' . (int)$start . ')';
2516
-		if ($start == 0 && $end != 0) $where[] = '(cal_recur_date = 0 OR cal_recur_date <= ' . (int)$end . ')';
2743
+		if ($start != 0 && $end == 0)
2744
+		{
2745
+			$where[] = '(cal_recur_date = 0 OR cal_recur_date >= ' . (int)$start . ')';
2746
+		}
2747
+		if ($start == 0 && $end != 0)
2748
+		{
2749
+			$where[] = '(cal_recur_date = 0 OR cal_recur_date <= ' . (int)$end . ')';
2750
+		}
2517 2751
 		if ($start != 0 && $end != 0)
2518 2752
 		{
2519 2753
 			$where[] = '(cal_recur_date = 0 OR (cal_recur_date >= ' . (int)$start .
@@ -2524,7 +2758,10 @@  discard block
 block discarded – undo
2524 2758
 			// inititalize the array
2525 2759
 			$participant_status[$row['cal_recur_date']] = null;
2526 2760
 		}
2527
-		if (is_null($uid)) return $participant_status;
2761
+		if (is_null($uid))
2762
+		{
2763
+			return $participant_status;
2764
+		}
2528 2765
 		$user_type = $user_id = null;
2529 2766
 		self::split_user($uid, $user_type, $user_id, true);
2530 2767
 
@@ -2533,8 +2770,14 @@  discard block
 block discarded – undo
2533 2770
 			'cal_user_type'	=> $user_type ? $user_type : 'u',
2534 2771
 			'cal_user_id'   => $user_id,
2535 2772
 		);
2536
-		if ($start != 0 && $end == 0) $where2[] = '(cal_recur_date = 0 OR cal_recur_date >= ' . (int)$start . ')';
2537
-		if ($start == 0 && $end != 0) $where2[] = '(cal_recur_date = 0 OR cal_recur_date <= ' . (int)$end . ')';
2773
+		if ($start != 0 && $end == 0)
2774
+		{
2775
+			$where2[] = '(cal_recur_date = 0 OR cal_recur_date >= ' . (int)$start . ')';
2776
+		}
2777
+		if ($start == 0 && $end != 0)
2778
+		{
2779
+			$where2[] = '(cal_recur_date = 0 OR cal_recur_date <= ' . (int)$end . ')';
2780
+		}
2538 2781
 		if ($start != 0 && $end != 0)
2539 2782
 		{
2540 2783
 			$where2[] = '(cal_recur_date = 0 OR (cal_recur_date >= ' . (int)$start .
@@ -2624,17 +2867,26 @@  discard block
 block discarded – undo
2624 2867
 	 */
2625 2868
 	function get_recurrence_exceptions($event, $tz_id=null, $start=0, $end=0, $filter='all')
2626 2869
 	{
2627
-		if (!is_array($event)) return false;
2870
+		if (!is_array($event))
2871
+		{
2872
+			return false;
2873
+		}
2628 2874
 		$cal_id = (int) $event['id'];
2629 2875
 		//error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2630 2876
 		//		"($cal_id, $tz_id, $filter): " . $event['tzid']);
2631
-		if (!$cal_id || $event['recur_type'] == MCAL_RECUR_NONE) return false;
2877
+		if (!$cal_id || $event['recur_type'] == MCAL_RECUR_NONE)
2878
+		{
2879
+			return false;
2880
+		}
2632 2881
 
2633 2882
 		$days = array();
2634 2883
 
2635 2884
 		$expand_all = (!$this->isWholeDay($event) && $tz_id && $tz_id != $event['tzid']);
2636 2885
 
2637
-		if ($filter == 'tz_only' && !$expand_all) return $days;
2886
+		if ($filter == 'tz_only' && !$expand_all)
2887
+		{
2888
+			return $days;
2889
+		}
2638 2890
 
2639 2891
 		$remote = in_array($filter, array('tz_rrule', 'rrule'));
2640 2892
 
@@ -2677,7 +2929,10 @@  discard block
 block discarded – undo
2677 2929
 					$remote_rrule->next_no_exception();
2678 2930
 				}
2679 2931
 				$egw_rrule->next_no_exception();
2680
-				if (!$egw_rrule->valid()) return $days;
2932
+				if (!$egw_rrule->valid())
2933
+				{
2934
+					return $days;
2935
+				}
2681 2936
 			}
2682 2937
 			$day = $egw_rrule->current();
2683 2938
 			$locts = (int)egw_time::to($day,'server');
@@ -2831,7 +3086,11 @@  discard block
 block discarded – undo
2831 3086
 			}
2832 3087
 		}
2833 3088
 
2834
-		if (empty($participants)) return false; // occurrence does not exist at all yet
3089
+		if (empty($participants))
3090
+		{
3091
+			return false;
3092
+		}
3093
+		// occurrence does not exist at all yet
2835 3094
 
2836 3095
 		foreach ($recurrence_zero as $uid => $status)
2837 3096
 		{
@@ -2888,7 +3147,9 @@  discard block
 block discarded – undo
2888 3147
 			}
2889 3148
 			if (!isset($participants[$uid])
2890 3149
 				|| $participants[$uid] != $status)
2891
-				return true;
3150
+			{
3151
+							return true;
3152
+			}
2892 3153
 			unset($participants[$uid]);
2893 3154
 		}
2894 3155
 		return (!empty($participants));
@@ -2902,7 +3163,10 @@  discard block
 block discarded – undo
2902 3163
 	 */
2903 3164
 	function isWholeDay($event)
2904 3165
 	{
2905
-		if (!isset($event['start']) || !isset($event['end'])) return false;
3166
+		if (!isset($event['start']) || !isset($event['end']))
3167
+		{
3168
+			return false;
3169
+		}
2906 3170
 
2907 3171
 		if (empty($event['tzid']))
2908 3172
 		{
@@ -2964,8 +3228,14 @@  discard block
 block discarded – undo
2964 3228
 	 */
2965 3229
 	function updateModified($id, $update_master=false, $time=null, $modifier=null)
2966 3230
 	{
2967
-		if (is_null($time) || !$time) $time = time();
2968
-		if (is_null($modifier)) $modifier = $GLOBALS['egw_info']['user']['account_id'];
3231
+		if (is_null($time) || !$time)
3232
+		{
3233
+			$time = time();
3234
+		}
3235
+		if (is_null($modifier))
3236
+		{
3237
+			$modifier = $GLOBALS['egw_info']['user']['account_id'];
3238
+		}
2969 3239
 
2970 3240
 		$this->db->update($this->cal_table,
2971 3241
 			array('cal_modified' => $time, 'cal_modifier' => $modifier),
Please login to merge, or discard this patch.
api/src/Vfs.php 5 patches
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -672,7 +672,7 @@  discard block
 block discarded – undo
672 672
 			return;	// not found, should not happen
673 673
 		}
674 674
 		if ($type && (($type == 'd') == !($stat['mode'] & Vfs\Sqlfs\StreamWrapper::MODE_DIR) ||	// != is_dir() which can be true for symlinks
675
-		    $type == 'F' && is_dir($path)))	// symlink to a directory
675
+			$type == 'F' && is_dir($path)))	// symlink to a directory
676 676
 		{
677 677
 			return;	// wrong type
678 678
 		}
@@ -1621,13 +1621,13 @@  discard block
 block discarded – undo
1621 1621
 		{
1622 1622
 			return false;
1623 1623
 		}
1624
-    	// remove the lock info evtl. set in the cache
1625
-    	unset(self::$lock_cache[$path]);
1624
+		// remove the lock info evtl. set in the cache
1625
+		unset(self::$lock_cache[$path]);
1626 1626
 
1627
-    	if ($timeout < 1000000)	// < 1000000 is a relative timestamp, so we add the current time
1628
-    	{
1629
-    		$timeout += time();
1630
-    	}
1627
+		if ($timeout < 1000000)	// < 1000000 is a relative timestamp, so we add the current time
1628
+		{
1629
+			$timeout += time();
1630
+		}
1631 1631
 
1632 1632
 		if ($update)	// Lock Update
1633 1633
 		{
@@ -1688,32 +1688,32 @@  discard block
 block discarded – undo
1688 1688
 		return $ret;
1689 1689
 	}
1690 1690
 
1691
-    /**
1692
-     * unlock a ressource/path
1693
-     *
1694
-     * @param string $path path to unlock
1695
-     * @param string $token locktoken
1691
+	/**
1692
+	 * unlock a ressource/path
1693
+	 *
1694
+	 * @param string $path path to unlock
1695
+	 * @param string $token locktoken
1696 1696
 	 * @param boolean $check_writable =true should we check if the ressource is writable, before granting locks, default yes
1697
-     * @return boolean true on success
1698
-     */
1699
-    static function unlock($path,$token,$check_writable=true)
1700
-    {
1697
+	 * @return boolean true on success
1698
+	 */
1699
+	static function unlock($path,$token,$check_writable=true)
1700
+	{
1701 1701
 		// we require write rights to lock/unlock a resource
1702 1702
 		if ($check_writable && !self::is_writable($path))
1703 1703
 		{
1704 1704
 			return false;
1705 1705
 		}
1706
-        if (($ret = self::$db->delete(self::LOCK_TABLE,array(
1707
-        	'lock_path' => $path,
1708
-        	'lock_token' => $token,
1709
-        ),__LINE__,__FILE__) && self::$db->affected_rows()))
1710
-        {
1711
-        	// remove the lock from the cache too
1712
-        	unset(self::$lock_cache[$path]);
1713
-        }
1706
+		if (($ret = self::$db->delete(self::LOCK_TABLE,array(
1707
+			'lock_path' => $path,
1708
+			'lock_token' => $token,
1709
+		),__LINE__,__FILE__) && self::$db->affected_rows()))
1710
+		{
1711
+			// remove the lock from the cache too
1712
+			unset(self::$lock_cache[$path]);
1713
+		}
1714 1714
 		if (self::LOCK_DEBUG) error_log(__METHOD__."($path,$token,$check_writable) returns ".($ret ? 'true' : 'false'));
1715 1715
 		return $ret;
1716
-    }
1716
+	}
1717 1717
 
1718 1718
 	/**
1719 1719
 	 * checkLock() helper
@@ -1741,13 +1741,13 @@  discard block
 block discarded – undo
1741 1741
 		}
1742 1742
 		if ($result && $result['expires'] < time())	// lock is expired --> remove it
1743 1743
 		{
1744
-	        self::$db->delete(self::LOCK_TABLE,array(
1745
-	        	'lock_path' => $result['path'],
1746
-	        	'lock_token' => $result['token'],
1747
-	        ),__LINE__,__FILE__);
1744
+			self::$db->delete(self::LOCK_TABLE,array(
1745
+				'lock_path' => $result['path'],
1746
+				'lock_token' => $result['token'],
1747
+			),__LINE__,__FILE__);
1748 1748
 
1749 1749
 			if (self::LOCK_DEBUG) error_log(__METHOD__."($path) lock is expired at ".date('Y-m-d H:i:s',$result['expires'])." --> removed");
1750
-	        $result = false;
1750
+			$result = false;
1751 1751
 		}
1752 1752
 		if (self::LOCK_DEBUG) error_log(__METHOD__."($path) returns ".($result?array2string($result):'false'));
1753 1753
 		return self::$lock_cache[$path] = $result;
@@ -1887,9 +1887,9 @@  discard block
 block discarded – undo
1887 1887
 			$image = Image::find($mime_sub, 'navbar');
1888 1888
 		}
1889 1889
 		else if ($file && $mime_main == 'image' && in_array($mime_sub, array('png','jpeg','jpg','gif','bmp')) &&
1890
-		         (string)$GLOBALS['egw_info']['server']['link_list_thumbnail'] != '0' &&
1891
-		         (string)$GLOBALS['egw_info']['user']['preferences']['common']['link_list_thumbnail'] != '0' &&
1892
-		         ($stat = self::stat($file)) && $stat['size'] < 1500000)
1890
+				 (string)$GLOBALS['egw_info']['server']['link_list_thumbnail'] != '0' &&
1891
+				 (string)$GLOBALS['egw_info']['user']['preferences']['common']['link_list_thumbnail'] != '0' &&
1892
+				 ($stat = self::stat($file)) && $stat['size'] < 1500000)
1893 1893
 		{
1894 1894
 			if (substr($file, 0, 6) == '/apps/')
1895 1895
 			{
Please login to merge, or discard this patch.
Braces   +237 added lines, -62 removed lines patch added patch discarded remove patch
@@ -221,7 +221,10 @@  discard block
 block discarded – undo
221 221
 		}
222 222
 		foreach($props as &$prop)
223 223
 		{
224
-			if ($prop['name'] == $name && $prop['ns'] == $ns) return $prop;
224
+			if ($prop['name'] == $name && $prop['ns'] == $ns)
225
+			{
226
+				return $prop;
227
+			}
225 228
 		}
226 229
 		return null;
227 230
 	}
@@ -314,11 +317,17 @@  discard block
 block discarded – undo
314 317
 	 */
315 318
 	static function mount($url=null,$path=null,$check_url=null,$persitent_mount=true,$clear_fstab=false)
316 319
 	{
317
-		if (is_null($check_url)) $check_url = strpos($url,'$') === false;
320
+		if (is_null($check_url))
321
+		{
322
+			$check_url = strpos($url,'$') === false;
323
+		}
318 324
 
319
-		if (!isset($GLOBALS['egw_info']['server']['vfs_fstab']))	// happens eg. in setup
325
+		if (!isset($GLOBALS['egw_info']['server']['vfs_fstab']))
326
+		{
327
+			// happens eg. in setup
320 328
 		{
321 329
 			$api_config = Config::read('phpgwapi');
330
+		}
322 331
 			if (isset($api_config['vfs_fstab']) && is_array($api_config['vfs_fstab']))
323 332
 			{
324 333
 				self::$fstab = $api_config['vfs_fstab'];
@@ -334,12 +343,18 @@  discard block
 block discarded – undo
334 343
 		}
335 344
 		if (is_null($url) || is_null($path))
336 345
 		{
337
-			if (self::LOG_LEVEL > 1) error_log(__METHOD__.'('.array2string($url).','.array2string($path).') returns '.array2string(self::$fstab));
346
+			if (self::LOG_LEVEL > 1)
347
+			{
348
+				error_log(__METHOD__.'('.array2string($url).','.array2string($path).') returns '.array2string(self::$fstab));
349
+			}
338 350
 			return self::$fstab;
339 351
 		}
340 352
 		if (!self::$is_root)
341 353
 		{
342
-			if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($url).','.array2string($path).') permission denied, you are NOT root!');
354
+			if (self::LOG_LEVEL > 0)
355
+			{
356
+				error_log(__METHOD__.'('.array2string($url).','.array2string($path).') permission denied, you are NOT root!');
357
+			}
343 358
 			return false;	// only root can mount
344 359
 		}
345 360
 		if ($clear_fstab)
@@ -348,14 +363,20 @@  discard block
 block discarded – undo
348 363
 		}
349 364
 		if (isset(self::$fstab[$path]) && self::$fstab[$path] === $url)
350 365
 		{
351
-			if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($url).','.array2string($path).') already mounted.');
366
+			if (self::LOG_LEVEL > 0)
367
+			{
368
+				error_log(__METHOD__.'('.array2string($url).','.array2string($path).') already mounted.');
369
+			}
352 370
 			return true;	// already mounted
353 371
 		}
354 372
 		self::load_wrapper(self::parse_url($url,PHP_URL_SCHEME));
355 373
 
356 374
 		if ($check_url && (!file_exists($url) || opendir($url) === false))
357 375
 		{
358
-			if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($url).','.array2string($path).') url does NOT exist!');
376
+			if (self::LOG_LEVEL > 0)
377
+			{
378
+				error_log(__METHOD__.'('.array2string($url).','.array2string($path).') url does NOT exist!');
379
+			}
359 380
 			return false;	// url does not exist
360 381
 		}
361 382
 		self::$fstab[$path] = $url;
@@ -370,12 +391,18 @@  discard block
 block discarded – undo
370 391
 			Config::save_value('vfs_fstab',self::$fstab,'phpgwapi');
371 392
 			$GLOBALS['egw_info']['server']['vfs_fstab'] = self::$fstab;
372 393
 			// invalidate session cache
373
-			if (method_exists($GLOBALS['egw'],'invalidate_session_cache'))	// egw object in setup is limited
394
+			if (method_exists($GLOBALS['egw'],'invalidate_session_cache'))
395
+			{
396
+				// egw object in setup is limited
374 397
 			{
375 398
 				$GLOBALS['egw']->invalidate_session_cache();
376 399
 			}
400
+			}
401
+		}
402
+		if (self::LOG_LEVEL > 1)
403
+		{
404
+			error_log(__METHOD__.'('.array2string($url).','.array2string($path).') returns true (successful new mount).');
377 405
 		}
378
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__.'('.array2string($url).','.array2string($path).') returns true (successful new mount).');
379 406
 		return true;
380 407
 	}
381 408
 
@@ -388,12 +415,18 @@  discard block
 block discarded – undo
388 415
 	{
389 416
 		if (!self::$is_root)
390 417
 		{
391
-			if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($path).','.array2string($path).') permission denied, you are NOT root!');
418
+			if (self::LOG_LEVEL > 0)
419
+			{
420
+				error_log(__METHOD__.'('.array2string($path).','.array2string($path).') permission denied, you are NOT root!');
421
+			}
392 422
 			return false;	// only root can mount
393 423
 		}
394 424
 		if (!isset(self::$fstab[$path]) && ($path = array_search($path,self::$fstab)) === false)
395 425
 		{
396
-			if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($path).') NOT mounted!');
426
+			if (self::LOG_LEVEL > 0)
427
+			{
428
+				error_log(__METHOD__.'('.array2string($path).') NOT mounted!');
429
+			}
397 430
 			return false;	// $path not mounted
398 431
 		}
399 432
 		unset(self::$fstab[$path]);
@@ -401,11 +434,17 @@  discard block
 block discarded – undo
401 434
 		Config::save_value('vfs_fstab',self::$fstab,'phpgwapi');
402 435
 		$GLOBALS['egw_info']['server']['vfs_fstab'] = self::$fstab;
403 436
 		// invalidate session cache
404
-		if (method_exists($GLOBALS['egw'],'invalidate_session_cache'))	// egw object in setup is limited
437
+		if (method_exists($GLOBALS['egw'],'invalidate_session_cache'))
438
+		{
439
+			// egw object in setup is limited
405 440
 		{
406 441
 			$GLOBALS['egw']->invalidate_session_cache();
407 442
 		}
408
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__.'('.array2string($path).') returns true (successful unmount).');
443
+		}
444
+		if (self::LOG_LEVEL > 1)
445
+		{
446
+			error_log(__METHOD__.'('.array2string($path).') returns true (successful unmount).');
447
+		}
409 448
 		return true;
410 449
 	}
411 450
 
@@ -460,17 +499,27 @@  discard block
 block discarded – undo
460 499
 		$dirs_last = $options['depth'];	// put content of dirs before the dir itself
461 500
 		// show dirs on top by default, if no recursive listing (allways disabled if $type specified, as unnecessary)
462 501
 		$dirsontop = !$type && (isset($options['dirsontop']) ? (boolean)$options['dirsontop'] : isset($options['maxdepth'])&&$options['maxdepth']>0);
463
-		if ($dirsontop) $options['need_mime'] = true;	// otherwise dirsontop can NOT work
502
+		if ($dirsontop)
503
+		{
504
+			$options['need_mime'] = true;
505
+		}
506
+		// otherwise dirsontop can NOT work
464 507
 
465 508
 		// process some of the options (need to be done only once)
466
-		if (isset($options['name']) && !isset($options['name_preg']))	// change from simple *,? wildcards to preg regular expression once
509
+		if (isset($options['name']) && !isset($options['name_preg']))
510
+		{
511
+			// change from simple *,? wildcards to preg regular expression once
467 512
 		{
468 513
 			$options['name_preg'] = '/^'.str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($options['name'])).'$/i';
469 514
 		}
470
-		if (isset($options['path']) && !isset($options['preg_path']))	// change from simple *,? wildcards to preg regular expression once
515
+		}
516
+		if (isset($options['path']) && !isset($options['preg_path']))
517
+		{
518
+			// change from simple *,? wildcards to preg regular expression once
471 519
 		{
472 520
 			$options['path_preg'] = '/^'.str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($options['path'])).'$/i';
473 521
 		}
522
+		}
474 523
 		if (!isset($options['uid']))
475 524
 		{
476 525
 			if (isset($options['user']))
@@ -517,7 +566,10 @@  discard block
 block discarded – undo
517 566
 		{
518 567
 			if (!$url)
519 568
 			{
520
-				if ($path[0] != '/' || !self::stat($path)) continue;
569
+				if ($path[0] != '/' || !self::stat($path))
570
+				{
571
+					continue;
572
+				}
521 573
 				$path = self::PREFIX . $path;
522 574
 			}
523 575
 			if (!isset($options['remove']))
@@ -535,9 +587,17 @@  discard block
 block discarded – undo
535 587
 			{
536 588
 				while(($fname = readdir($dir)) !== false)
537 589
 				{
538
-					if ($fname == '.' || $fname == '..') continue;	// ignore current and parent dir!
590
+					if ($fname == '.' || $fname == '..')
591
+					{
592
+						continue;
593
+					}
594
+					// ignore current and parent dir!
539 595
 
540
-					if (self::is_hidden($fname, $options['show-deleted']) && !$options['hidden']) continue;	// ignore hidden files
596
+					if (self::is_hidden($fname, $options['show-deleted']) && !$options['hidden'])
597
+					{
598
+						continue;
599
+					}
600
+					// ignore hidden files
541 601
 
542 602
 					$file = self::concat($path, $fname);
543 603
 
@@ -549,8 +609,14 @@  discard block
 block discarded – undo
549 609
 					if (is_dir($file) && ($options['follow'] || !is_link($file)) && (!isset($options['maxdepth']) || $options['maxdepth'] > 1))
550 610
 					{
551 611
 						$opts = $options;
552
-						if ($opts['mindepth']) $opts['mindepth']--;
553
-						if ($opts['maxdepth']) $opts['depth']++;
612
+						if ($opts['mindepth'])
613
+						{
614
+							$opts['mindepth']--;
615
+						}
616
+						if ($opts['maxdepth'])
617
+						{
618
+							$opts['depth']++;
619
+						}
554 620
 						unset($opts['order']);
555 621
 						unset($opts['limit']);
556 622
 						foreach(self::find($options['url']?$file:self::parse_url($file,PHP_URL_PATH),$opts,true) as $p => $s)
@@ -615,7 +681,10 @@  discard block
 block discarded – undo
615 681
 		if (isset($options['limit']))
616 682
 		{
617 683
 			list($limit,$start) = explode(',',$options['limit']);
618
-			if (!$limit && !($limit = $GLOBALS['egw_info']['user']['preferences']['comman']['maxmatches'])) $limit = 15;
684
+			if (!$limit && !($limit = $GLOBALS['egw_info']['user']['preferences']['comman']['maxmatches']))
685
+			{
686
+				$limit = 15;
687
+			}
619 688
 			//echo "total=".self::$find_total.", limit=$options[limit] --> start=$start, limit=$limit<br>\n";
620 689
 
621 690
 			if ((int)$start || self::$find_total > $limit)
@@ -672,9 +741,13 @@  discard block
 block discarded – undo
672 741
 			return;	// not found, should not happen
673 742
 		}
674 743
 		if ($type && (($type == 'd') == !($stat['mode'] & Vfs\Sqlfs\StreamWrapper::MODE_DIR) ||	// != is_dir() which can be true for symlinks
675
-		    $type == 'F' && is_dir($path)))	// symlink to a directory
744
+		    $type == 'F' && is_dir($path)))
676 745
 		{
677
-			return;	// wrong type
746
+			// symlink to a directory
747
+		{
748
+			return;
749
+		}
750
+		// wrong type
678 751
 		}
679 752
 		$stat = array_slice($stat,13);	// remove numerical indices 0-12
680 753
 		$stat['path'] = self::parse_url($path,PHP_URL_PATH);
@@ -697,11 +770,15 @@  discard block
 block discarded – undo
697 770
 		}
698 771
 		if (isset($options['mime']) && $options['mime'] != $stat['mime'])
699 772
 		{
700
-			if ($options['mime'][0] == '/')	// perl regular expression given
773
+			if ($options['mime'][0] == '/')
774
+			{
775
+				// perl regular expression given
701 776
 			{
702 777
 				if (!preg_match($options['mime'], $stat['mime']))
703 778
 				{
704
-					return;	// wrong mime-type
779
+					return;
780
+			}
781
+			// wrong mime-type
705 782
 				}
706 783
 			}
707 784
 			else
@@ -1018,7 +1095,8 @@  discard block
 block discarded – undo
1018 1095
 			}
1019 1096
 
1020 1097
 			// sort by length descending, to show precedence
1021
-			usort($eacls, function($a, $b) {
1098
+			usort($eacls, function($a, $b)
1099
+			{
1022 1100
 				return strlen($b['path']) - strlen($a['path']);
1023 1101
 			});
1024 1102
 		}
@@ -1073,14 +1151,21 @@  discard block
 block discarded – undo
1073 1151
 	 */
1074 1152
 	static function mode2int($set,$mode=0)
1075 1153
 	{
1076
-		if (is_int($set))		// already an integer
1154
+		if (is_int($set))
1155
+		{
1156
+			// already an integer
1077 1157
 		{
1078 1158
 			return $set;
1079 1159
 		}
1080
-		if (is_numeric($set))	// octal string
1160
+		}
1161
+		if (is_numeric($set))
1162
+		{
1163
+			// octal string
1081 1164
 		{
1082 1165
 			//error_log(__METHOD__."($set,$mode) returning ".(int)base_convert($set,8,10));
1083
-			return (int)base_convert($set,8,10);	// convert octal to decimal
1166
+			return (int)base_convert($set,8,10);
1167
+		}
1168
+		// convert octal to decimal
1084 1169
 		}
1085 1170
 		foreach(explode(',',$set) as $s)
1086 1171
 		{
@@ -1136,34 +1221,55 @@  discard block
 block discarded – undo
1136 1221
 	 */
1137 1222
 	static function int2mode( $mode )
1138 1223
 	{
1139
-		if(($mode & self::MODE_LINK) == self::MODE_LINK) // Symbolic Link
1224
+		if(($mode & self::MODE_LINK) == self::MODE_LINK)
1225
+		{
1226
+			// Symbolic Link
1140 1227
 		{
1141 1228
 			$sP = 'l';
1142 1229
 		}
1143
-		elseif(($mode & 0xC000) == 0xC000) // Socket
1230
+		}
1231
+		elseif(($mode & 0xC000) == 0xC000)
1232
+		{
1233
+			// Socket
1144 1234
 		{
1145 1235
 			$sP = 's';
1146 1236
 		}
1147
-		elseif($mode & 0x1000)     // FIFO pipe
1237
+		}
1238
+		elseif($mode & 0x1000)
1239
+		{
1240
+			// FIFO pipe
1148 1241
 		{
1149 1242
 			$sP = 'p';
1150 1243
 		}
1151
-		elseif($mode & 0x2000) // Character special
1244
+		}
1245
+		elseif($mode & 0x2000)
1246
+		{
1247
+			// Character special
1152 1248
 		{
1153 1249
 			$sP = 'c';
1154 1250
 		}
1155
-		elseif($mode & 0x4000) // Directory
1251
+		}
1252
+		elseif($mode & 0x4000)
1253
+		{
1254
+			// Directory
1156 1255
 		{
1157 1256
 			$sP = 'd';
1158 1257
 		}
1159
-		elseif($mode & 0x6000) // Block special
1258
+		}
1259
+		elseif($mode & 0x6000)
1260
+		{
1261
+			// Block special
1160 1262
 		{
1161 1263
 			$sP = 'b';
1162 1264
 		}
1163
-		elseif($mode & 0x8000) // Regular
1265
+		}
1266
+		elseif($mode & 0x8000)
1267
+		{
1268
+			// Regular
1164 1269
 		{
1165 1270
 			$sP = '-';
1166 1271
 		}
1272
+		}
1167 1273
 		else                         // UNKNOWN
1168 1274
 		{
1169 1275
 			$sP = 'u';
@@ -1230,9 +1336,18 @@  discard block
 block discarded – undo
1230 1336
 	 */
1231 1337
 	static function hsize($size)
1232 1338
 	{
1233
-		if ($size < 1024) return $size;
1234
-		if ($size < 1024*1024) return sprintf('%3.1lfk',(float)$size/1024);
1235
-		if ($size < 1024*1024*1024) return sprintf('%3.1lfM',(float)$size/(1024*1024));
1339
+		if ($size < 1024)
1340
+		{
1341
+			return $size;
1342
+		}
1343
+		if ($size < 1024*1024)
1344
+		{
1345
+			return sprintf('%3.1lfk',(float)$size/1024);
1346
+		}
1347
+		if ($size < 1024*1024*1024)
1348
+		{
1349
+			return sprintf('%3.1lfM',(float)$size/(1024*1024));
1350
+		}
1236 1351
 		return sprintf('%3.1lfG',(float)$size/(1024*1024*1024));
1237 1352
 	}
1238 1353
 
@@ -1243,7 +1358,10 @@  discard block
 block discarded – undo
1243 1358
 	 */
1244 1359
 	static function int_size($_val)
1245 1360
 	{
1246
-		if(empty($_val))return 0;
1361
+		if(empty($_val))
1362
+		{
1363
+			return 0;
1364
+		}
1247 1365
 
1248 1366
 		$val = trim($_val);
1249 1367
 
@@ -1251,11 +1369,13 @@  discard block
 block discarded – undo
1251 1369
 		preg_match('#([0-9]+)[\s]*([a-z]+)#i', $val, $matches);
1252 1370
 
1253 1371
 		$last = '';
1254
-		if(isset($matches[2])){
1372
+		if(isset($matches[2]))
1373
+		{
1255 1374
 			$last = $matches[2];
1256 1375
 		}
1257 1376
 
1258
-		if(isset($matches[1])){
1377
+		if(isset($matches[1]))
1378
+		{
1259 1379
 			$val = (int) $matches[1];
1260 1380
 		}
1261 1381
 
@@ -1307,7 +1427,10 @@  discard block
 block discarded – undo
1307 1427
 			return false;
1308 1428
 		}
1309 1429
 		$parts = explode('/',$url);
1310
-		if (substr($url,-1) == '/') array_pop($parts);
1430
+		if (substr($url,-1) == '/')
1431
+		{
1432
+			array_pop($parts);
1433
+		}
1311 1434
 		array_pop($parts);
1312 1435
 		if ($url[0] != '/' && count($parts) == 3 || count($parts) == 1 && $parts[0] === '')
1313 1436
 		{
@@ -1328,7 +1451,10 @@  discard block
 block discarded – undo
1328 1451
 	 */
1329 1452
 	static function has_owner_rights($path,array $stat=null)
1330 1453
 	{
1331
-		if (!$stat) $stat = self::url_stat($path,0);
1454
+		if (!$stat)
1455
+		{
1456
+			$stat = self::url_stat($path,0);
1457
+		}
1332 1458
 
1333 1459
 		return $stat['uid'] == self::$user ||	// user is the owner
1334 1460
 			self::$is_root ||					// class runs with root rights
@@ -1347,7 +1473,10 @@  discard block
 block discarded – undo
1347 1473
 	static function concat($_url,$relative)
1348 1474
 	{
1349 1475
 		list($url,$query) = explode('?',$_url,2);
1350
-		if (substr($url,-1) == '/') $url = substr($url,0,-1);
1476
+		if (substr($url,-1) == '/')
1477
+		{
1478
+			$url = substr($url,0,-1);
1479
+		}
1351 1480
 		$ret = ($relative === '' || $relative[0] == '/' ? $url.$relative : $url.'/'.$relative);
1352 1481
 
1353 1482
 		// now normalize the path (remove "/something/..")
@@ -1440,7 +1569,8 @@  discard block
 block discarded – undo
1440 1569
 		if(count($paths) > 0)
1441 1570
 		{
1442 1571
 			// Shortest to longest
1443
-			usort($paths, function($a, $b) {
1572
+			usort($paths, function($a, $b)
1573
+			{
1444 1574
 				return strlen($a) - strlen($b);
1445 1575
 			});
1446 1576
 
@@ -1513,7 +1643,10 @@  discard block
 block discarded – undo
1513 1643
 			// Don't go infinite with app entries
1514 1644
 			if(self::is_link($addfile))
1515 1645
 			{
1516
-				if(in_array($addfile, $links)) continue;
1646
+				if(in_array($addfile, $links))
1647
+				{
1648
+					continue;
1649
+				}
1517 1650
 				$links[] = $addfile;
1518 1651
 			}
1519 1652
 			// Add directory - if empty, client app might not show it though
@@ -1624,12 +1757,17 @@  discard block
 block discarded – undo
1624 1757
     	// remove the lock info evtl. set in the cache
1625 1758
     	unset(self::$lock_cache[$path]);
1626 1759
 
1627
-    	if ($timeout < 1000000)	// < 1000000 is a relative timestamp, so we add the current time
1760
+    	if ($timeout < 1000000)
1761
+    	{
1762
+    		// < 1000000 is a relative timestamp, so we add the current time
1628 1763
     	{
1629 1764
     		$timeout += time();
1630 1765
     	}
1766
+    	}
1631 1767
 
1632
-		if ($update)	// Lock Update
1768
+		if ($update)
1769
+		{
1770
+			// Lock Update
1633 1771
 		{
1634 1772
 			if (($ret = (boolean)($row = self::$db->select(self::LOCK_TABLE,array('lock_owner','lock_exclusive','lock_write'),array(
1635 1773
 				'lock_path' => $path,
@@ -1637,6 +1775,7 @@  discard block
 block discarded – undo
1637 1775
 			),__LINE__,__FILE__)->fetch())))
1638 1776
 			{
1639 1777
 				$owner = $row['lock_owner'];
1778
+		}
1640 1779
 				$scope = Db::from_bool($row['lock_exclusive']) ? 'exclusive' : 'shared';
1641 1780
 				$type  = Db::from_bool($row['lock_write']) ? 'write' : 'read';
1642 1781
 
@@ -1684,7 +1823,10 @@  discard block
 block discarded – undo
1684 1823
 				$ret = false;	// there's already a lock
1685 1824
 			}
1686 1825
 		}
1687
-		if (self::LOCK_DEBUG) error_log(__METHOD__."($path,$token,$timeout,$owner,$scope,$type,update=$update,check_writable=$check_writable) returns ".($ret ? 'true' : 'false'));
1826
+		if (self::LOCK_DEBUG)
1827
+		{
1828
+			error_log(__METHOD__."($path,$token,$timeout,$owner,$scope,$type,update=$update,check_writable=$check_writable) returns ".($ret ? 'true' : 'false'));
1829
+		}
1688 1830
 		return $ret;
1689 1831
 	}
1690 1832
 
@@ -1711,7 +1853,10 @@  discard block
 block discarded – undo
1711 1853
         	// remove the lock from the cache too
1712 1854
         	unset(self::$lock_cache[$path]);
1713 1855
         }
1714
-		if (self::LOCK_DEBUG) error_log(__METHOD__."($path,$token,$check_writable) returns ".($ret ? 'true' : 'false'));
1856
+		if (self::LOCK_DEBUG)
1857
+		{
1858
+			error_log(__METHOD__."($path,$token,$check_writable) returns ".($ret ? 'true' : 'false'));
1859
+		}
1715 1860
 		return $ret;
1716 1861
     }
1717 1862
 
@@ -1725,7 +1870,10 @@  discard block
 block discarded – undo
1725 1870
 	{
1726 1871
 		if (isset(self::$lock_cache[$path]))
1727 1872
 		{
1728
-			if (self::LOCK_DEBUG) error_log(__METHOD__."($path) returns from CACHE ".str_replace(array("\n",'    '),'',print_r(self::$lock_cache[$path],true)));
1873
+			if (self::LOCK_DEBUG)
1874
+			{
1875
+				error_log(__METHOD__."($path) returns from CACHE ".str_replace(array("\n",'    '),'',print_r(self::$lock_cache[$path],true)));
1876
+			}
1729 1877
 			return self::$lock_cache[$path];
1730 1878
 		}
1731 1879
 		$where = 'lock_path='.self::$db->quote($path);
@@ -1739,17 +1887,26 @@  discard block
 block discarded – undo
1739 1887
 			$result['scope'] = Db::from_bool($result['exclusive']) ? 'exclusive' : 'shared';
1740 1888
 			$result['depth'] = Db::from_bool($result['recursive']) ? 'infinite' : 0;
1741 1889
 		}
1742
-		if ($result && $result['expires'] < time())	// lock is expired --> remove it
1890
+		if ($result && $result['expires'] < time())
1891
+		{
1892
+			// lock is expired --> remove it
1743 1893
 		{
1744 1894
 	        self::$db->delete(self::LOCK_TABLE,array(
1745 1895
 	        	'lock_path' => $result['path'],
1746 1896
 	        	'lock_token' => $result['token'],
1747 1897
 	        ),__LINE__,__FILE__);
1898
+		}
1748 1899
 
1749
-			if (self::LOCK_DEBUG) error_log(__METHOD__."($path) lock is expired at ".date('Y-m-d H:i:s',$result['expires'])." --> removed");
1900
+			if (self::LOCK_DEBUG)
1901
+			{
1902
+				error_log(__METHOD__."($path) lock is expired at ".date('Y-m-d H:i:s',$result['expires'])." --> removed");
1903
+			}
1750 1904
 	        $result = false;
1751 1905
 		}
1752
-		if (self::LOCK_DEBUG) error_log(__METHOD__."($path) returns ".($result?array2string($result):'false'));
1906
+		if (self::LOCK_DEBUG)
1907
+		{
1908
+			error_log(__METHOD__."($path) returns ".($result?array2string($result):'false'));
1909
+		}
1753 1910
 		return self::$lock_cache[$path] = $result;
1754 1911
 	}
1755 1912
 
@@ -1763,10 +1920,13 @@  discard block
 block discarded – undo
1763 1920
 	static function getExtraInfo($path,array $content=null)
1764 1921
 	{
1765 1922
 		$extra = array();
1766
-		if (($extra_info = self::_call_on_backend('extra_info',array($path,$content),true)))	// true = fail silent if backend does NOT support it
1923
+		if (($extra_info = self::_call_on_backend('extra_info',array($path,$content),true)))
1924
+		{
1925
+			// true = fail silent if backend does NOT support it
1767 1926
 		{
1768 1927
 			$extra[] = $extra_info;
1769 1928
 		}
1929
+		}
1770 1930
 
1771 1931
 		if (($vfs_extra = Hooks::process(array(
1772 1932
 			'location' => 'vfs_extra',
@@ -2044,30 +2204,42 @@  discard block
 block discarded – undo
2044 2204
 		}
2045 2205
 		if ($check_is_uploaded_file && !is_resource($tmp_name) && !is_uploaded_file($tmp_name))
2046 2206
 		{
2047
-			if (self::LOG_LEVEL) error_log(__METHOD__."($tmp_name, $target, ".array2string($props).",$check_is_uploaded_file) returning FALSE !is_uploaded_file()");
2207
+			if (self::LOG_LEVEL)
2208
+			{
2209
+				error_log(__METHOD__."($tmp_name, $target, ".array2string($props).",$check_is_uploaded_file) returning FALSE !is_uploaded_file()");
2210
+			}
2048 2211
 			return false;
2049 2212
 		}
2050 2213
 		if (!(self::is_writable($target) || self::is_writable(self::dirname($target))))
2051 2214
 		{
2052
-			if (self::LOG_LEVEL) error_log(__METHOD__."($tmp_name, $target, ".array2string($props).",$check_is_uploaded_file) returning FALSE !writable");
2215
+			if (self::LOG_LEVEL)
2216
+			{
2217
+				error_log(__METHOD__."($tmp_name, $target, ".array2string($props).",$check_is_uploaded_file) returning FALSE !writable");
2218
+			}
2053 2219
 			return false;
2054 2220
 		}
2055 2221
 		if ($props)
2056 2222
 		{
2057
-			if (!is_array($props)) $props = array(array('name' => 'comment','val' => $props));
2223
+			if (!is_array($props))
2224
+			{
2225
+				$props = array(array('name' => 'comment','val' => $props));
2226
+			}
2058 2227
 
2059 2228
 			// if $props is name => value pairs, convert it to internal array or array with values for keys 'name', 'val' and optional 'ns'
2060 2229
 			if (!isset($props[0]))
2061 2230
 			{
2062 2231
 				foreach($props as $name => $val)
2063 2232
 				{
2064
-					if (($name == 'comment' || $name[0] == '#') && $val)	// only copy 'comment' and cfs
2233
+					if (($name == 'comment' || $name[0] == '#') && $val)
2234
+					{
2235
+						// only copy 'comment' and cfs
2065 2236
 					{
2066 2237
 						$vfs_props[] = array(
2067 2238
 							'name' => $name,
2068 2239
 							'val'  => $val,
2069 2240
 						);
2070 2241
 					}
2242
+					}
2071 2243
 				}
2072 2244
 				$props = $vfs_props;
2073 2245
 			}
@@ -2094,7 +2266,10 @@  discard block
 block discarded – undo
2094 2266
 		{
2095 2267
 			$ret = copy($tmp_name,self::PREFIX.$target) ? self::stat($target) : false;
2096 2268
 		}
2097
-		if (self::LOG_LEVEL > 1 || !$ret && self::LOG_LEVEL) error_log(__METHOD__."($tmp_name, $target, ".array2string($props).") returning ".array2string($ret));
2269
+		if (self::LOG_LEVEL > 1 || !$ret && self::LOG_LEVEL)
2270
+		{
2271
+			error_log(__METHOD__."($tmp_name, $target, ".array2string($props).") returning ".array2string($ret));
2272
+		}
2098 2273
 		return $ret;
2099 2274
 	}
2100 2275
 
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1415,7 +1415,7 @@
 block discarded – undo
1415 1415
 	 *
1416 1416
 	 * @todo use https://github.com/maennchen/ZipStream-PHP to not assamble all files in memmory
1417 1417
 	 */
1418
-	public static function download_zip(Array $_files, $name = false)
1418
+	public static function download_zip(array $_files, $name = false)
1419 1419
 	{
1420 1420
 		//error_log(__METHOD__ . ': '.implode(',',$_files));
1421 1421
 
Please login to merge, or discard this patch.
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 	 * dir working on just the eGW VFS: returns directory object
166 166
 	 *
167 167
 	 * @param string $path filename with absolute path in the eGW VFS
168
-	 * @return Directory
168
+	 * @return \Directory
169 169
 	 */
170 170
 	static function dir($path)
171 171
 	{
@@ -1313,7 +1313,7 @@  discard block
 block discarded – undo
1313 1313
 	 * Also works around PHP under Windows returning dirname('/something') === '\\', which is NOT understood by EGroupware's VFS!
1314 1314
 	 *
1315 1315
 	 * @param string $_url path or url
1316
-	 * @return string|boolean parent or false if there's none ($path == '/')
1316
+	 * @return false|string parent or false if there's none ($path == '/')
1317 1317
 	 */
1318 1318
 	static function dirname($_url)
1319 1319
 	{
@@ -1431,7 +1431,7 @@  discard block
 block discarded – undo
1431 1431
 	 * @param array $_files List of files to include in the zip
1432 1432
 	 * @param string $name optional Zip file name.  If not provided, it will be determined automatically from the files
1433 1433
 	 *
1434
-	 * @return undefined
1434
+	 * @return string|null
1435 1435
 	 */
1436 1436
 	public static function download_zip(Array $_files, $name = false)
1437 1437
 	{
@@ -1741,7 +1741,7 @@  discard block
 block discarded – undo
1741 1741
 	 * checkLock() helper
1742 1742
 	 *
1743 1743
 	 * @param  string resource path to check for locks
1744
-	 * @return array|boolean false if there's no lock, else array with lock info
1744
+	 * @return string false if there's no lock, else array with lock info
1745 1745
 	 */
1746 1746
 	static function checkLock($path)
1747 1747
 	{
@@ -1957,7 +1957,7 @@  discard block
 block discarded – undo
1957 1957
 	/**
1958 1958
 	 * Copies the files given in $src to $dst.
1959 1959
 	 *
1960
-	 * @param array $src contains the source file
1960
+	 * @param string[] $src contains the source file
1961 1961
 	 * @param string $dst is the destination directory
1962 1962
 	 * @param int& $errs =null on return number of errors happened
1963 1963
 	 * @param array& $copied =null on return files copied
Please login to merge, or discard this patch.
Spacing   +271 added lines, -275 removed lines patch added patch discarded remove patch
@@ -137,13 +137,13 @@  discard block
 block discarded – undo
137 137
 	 * @param string $mode 'r', 'w', ... like fopen
138 138
 	 * @return resource
139 139
 	 */
140
-	static function fopen($path,$mode)
140
+	static function fopen($path, $mode)
141 141
 	{
142 142
 		if ($path[0] != '/')
143 143
 		{
144 144
 			throw new egw_exception_assertion_failed("Filename '$path' is not an absolute path!");
145 145
 		}
146
-		return fopen(self::PREFIX.$path,$mode);
146
+		return fopen(self::PREFIX.$path, $mode);
147 147
 	}
148 148
 
149 149
 	/**
@@ -183,13 +183,13 @@  discard block
 block discarded – undo
183 183
 	 * @param int $sorting_order =0 !$sorting_order (default) alphabetical in ascending order, $sorting_order alphabetical in descending order.
184 184
 	 * @return array
185 185
 	 */
186
-	static function scandir($path,$sorting_order=0)
186
+	static function scandir($path, $sorting_order = 0)
187 187
 	{
188 188
 		if ($path[0] != '/')
189 189
 		{
190 190
 			throw new egw_exception_assertion_failed("Directory '$path' is not an absolute path!");
191 191
 		}
192
-		return scandir(self::PREFIX.$path,$sorting_order);
192
+		return scandir(self::PREFIX.$path, $sorting_order);
193 193
 	}
194 194
 
195 195
 	/**
@@ -199,22 +199,22 @@  discard block
 block discarded – undo
199 199
 	 * @param string $to
200 200
 	 * @return boolean
201 201
 	 */
202
-	static function copy($from,$to)
202
+	static function copy($from, $to)
203 203
 	{
204
-		$old_props = self::file_exists($to) ? self::propfind($to,null) : array();
204
+		$old_props = self::file_exists($to) ? self::propfind($to, null) : array();
205 205
 		// copy properties (eg. file comment), if there are any and evtl. existing old properties
206
-		$props = self::propfind($from,null);
206
+		$props = self::propfind($from, null);
207 207
 
208
-		foreach($old_props as $prop)
208
+		foreach ($old_props as $prop)
209 209
 		{
210
-			if (!self::find_prop($props,$prop))
210
+			if (!self::find_prop($props, $prop))
211 211
 			{
212
-				$prop['val'] = null;	// null = delete prop
212
+				$prop['val'] = null; // null = delete prop
213 213
 				$props[] = $prop;
214 214
 			}
215 215
 		}
216 216
 		// using self::copy_uploaded() to treat copying incl. properties as atomar operation in respect of notifications
217
-		return self::copy_uploaded(self::PREFIX.$from,$to,$props,false);	// false = no is_uploaded_file check!
217
+		return self::copy_uploaded(self::PREFIX.$from, $to, $props, false); // false = no is_uploaded_file check!
218 218
 	}
219 219
 
220 220
 	/**
@@ -225,14 +225,14 @@  discard block
 block discarded – undo
225 225
 	 * @param string $ns =self::DEFAULT_PROP_NAMESPACE namespace, only if $prop is no array
226 226
 	 * @return &array reference to property in $props or null if not found
227 227
 	 */
228
-	static function &find_prop(array &$props,$name,$ns=self::DEFAULT_PROP_NAMESPACE)
228
+	static function &find_prop(array &$props, $name, $ns = self::DEFAULT_PROP_NAMESPACE)
229 229
 	{
230 230
 		if (is_array($name))
231 231
 		{
232 232
 			$ns = $name['ns'];
233 233
 			$name = $name['name'];
234 234
 		}
235
-		foreach($props as &$prop)
235
+		foreach ($props as &$prop)
236 236
 		{
237 237
 			if ($prop['name'] == $name && $prop['ns'] == $ns) return $prop;
238 238
 		}
@@ -246,15 +246,15 @@  discard block
 block discarded – undo
246 246
 	 * @param boolean $try_create_home =false should a non-existing home-directory be automatically created
247 247
 	 * @return array
248 248
 	 */
249
-	static function stat($path,$try_create_home=false)
249
+	static function stat($path, $try_create_home = false)
250 250
 	{
251 251
 		if ($path[0] != '/')
252 252
 		{
253 253
 			throw new egw_exception_assertion_failed("File '$path' is not an absolute path!");
254 254
 		}
255
-		if (($stat = self::url_stat($path,0,$try_create_home)))
255
+		if (($stat = self::url_stat($path, 0, $try_create_home)))
256 256
 		{
257
-			$stat = array_slice($stat,13);	// remove numerical indices 0-12
257
+			$stat = array_slice($stat, 13); // remove numerical indices 0-12
258 258
 		}
259 259
 		return $stat;
260 260
 	}
@@ -266,15 +266,15 @@  discard block
 block discarded – undo
266 266
 	 * @param boolean $try_create_home =false should a non-existing home-directory be automatically created
267 267
 	 * @return array
268 268
 	 */
269
-	static function lstat($path,$try_create_home=false)
269
+	static function lstat($path, $try_create_home = false)
270 270
 	{
271 271
 		if ($path[0] != '/')
272 272
 		{
273 273
 			throw new egw_exception_assertion_failed("File '$path' is not an absolute path!");
274 274
 		}
275
-		if (($stat = self::url_stat($path,STREAM_URL_STAT_LINK,$try_create_home)))
275
+		if (($stat = self::url_stat($path, STREAM_URL_STAT_LINK, $try_create_home)))
276 276
 		{
277
-			$stat = array_slice($stat,13);	// remove numerical indices 0-12
277
+			$stat = array_slice($stat, 13); // remove numerical indices 0-12
278 278
 		}
279 279
 		return $stat;
280 280
 	}
@@ -325,9 +325,9 @@  discard block
 block discarded – undo
325 325
 	 * @param boolean $clear_fstab =false true clear current fstab, false (default) only add given mount
326 326
 	 * @return array|boolean array with fstab, if called without parameter or true on successful mount
327 327
 	 */
328
-	static function mount($url=null,$path=null,$check_url=null,$persitent_mount=true,$clear_fstab=false)
328
+	static function mount($url = null, $path = null, $check_url = null, $persitent_mount = true, $clear_fstab = false)
329 329
 	{
330
-		if (is_null($check_url)) $check_url = strpos($url,'$') === false;
330
+		if (is_null($check_url)) $check_url = strpos($url, '$') === false;
331 331
 
332 332
 		if (!isset($GLOBALS['egw_info']['server']['vfs_fstab']))	// happens eg. in setup
333 333
 		{
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
 		if (!self::$is_root)
354 354
 		{
355 355
 			if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($url).','.array2string($path).') permission denied, you are NOT root!');
356
-			return false;	// only root can mount
356
+			return false; // only root can mount
357 357
 		}
358 358
 		if ($clear_fstab)
359 359
 		{
@@ -362,25 +362,25 @@  discard block
 block discarded – undo
362 362
 		if (isset(self::$fstab[$path]) && self::$fstab[$path] === $url)
363 363
 		{
364 364
 			if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($url).','.array2string($path).') already mounted.');
365
-			return true;	// already mounted
365
+			return true; // already mounted
366 366
 		}
367
-		self::load_wrapper(self::parse_url($url,PHP_URL_SCHEME));
367
+		self::load_wrapper(self::parse_url($url, PHP_URL_SCHEME));
368 368
 
369 369
 		if ($check_url && (!file_exists($url) || opendir($url) === false))
370 370
 		{
371 371
 			if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($url).','.array2string($path).') url does NOT exist!');
372
-			return false;	// url does not exist
372
+			return false; // url does not exist
373 373
 		}
374 374
 		self::$fstab[$path] = $url;
375 375
 
376
-		uksort(self::$fstab,create_function('$a,$b','return strlen($a)-strlen($b);'));
376
+		uksort(self::$fstab, create_function('$a,$b', 'return strlen($a)-strlen($b);'));
377 377
 
378 378
 		if ($persitent_mount)
379 379
 		{
380
-			config::save_value('vfs_fstab',self::$fstab,'phpgwapi');
380
+			config::save_value('vfs_fstab', self::$fstab, 'phpgwapi');
381 381
 			$GLOBALS['egw_info']['server']['vfs_fstab'] = self::$fstab;
382 382
 			// invalidate session cache
383
-			if (method_exists($GLOBALS['egw'],'invalidate_session_cache'))	// egw object in setup is limited
383
+			if (method_exists($GLOBALS['egw'], 'invalidate_session_cache'))	// egw object in setup is limited
384 384
 			{
385 385
 				$GLOBALS['egw']->invalidate_session_cache();
386 386
 			}
@@ -399,19 +399,19 @@  discard block
 block discarded – undo
399 399
 		if (!self::$is_root)
400 400
 		{
401 401
 			if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($path).','.array2string($path).') permission denied, you are NOT root!');
402
-			return false;	// only root can mount
402
+			return false; // only root can mount
403 403
 		}
404
-		if (!isset(self::$fstab[$path]) && ($path = array_search($path,self::$fstab)) === false)
404
+		if (!isset(self::$fstab[$path]) && ($path = array_search($path, self::$fstab)) === false)
405 405
 		{
406 406
 			if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($path).') NOT mounted!');
407
-			return false;	// $path not mounted
407
+			return false; // $path not mounted
408 408
 		}
409 409
 		unset(self::$fstab[$path]);
410 410
 
411
-		config::save_value('vfs_fstab',self::$fstab,'phpgwapi');
411
+		config::save_value('vfs_fstab', self::$fstab, 'phpgwapi');
412 412
 		$GLOBALS['egw_info']['server']['vfs_fstab'] = self::$fstab;
413 413
 		// invalidate session cache
414
-		if (method_exists($GLOBALS['egw'],'invalidate_session_cache'))	// egw object in setup is limited
414
+		if (method_exists($GLOBALS['egw'], 'invalidate_session_cache'))	// egw object in setup is limited
415 415
 		{
416 416
 			$GLOBALS['egw']->invalidate_session_cache();
417 417
 		}
@@ -426,7 +426,7 @@  discard block
 block discarded – undo
426 426
 	 * @param boolean $allow_versions =false allow .versions or .attic
427 427
 	 * @return boolean
428 428
 	 */
429
-	public static function is_hidden($path, $allow_versions=false)
429
+	public static function is_hidden($path, $allow_versions = false)
430 430
 	{
431 431
 		$file = self::basename($path);
432 432
 
@@ -462,30 +462,30 @@  discard block
 block discarded – undo
462 462
 	 * @param array $exec_params =null further params for exec as array, path is always the first param and stat the last!
463 463
 	 * @return array of pathes if no $exec, otherwise path => stat pairs
464 464
 	 */
465
-	static function find($base,$options=null,$exec=null,$exec_params=null)
465
+	static function find($base, $options = null, $exec = null, $exec_params = null)
466 466
 	{
467 467
 		//error_log(__METHOD__."(".print_r($base,true).",".print_r($options,true).",".print_r($exec,true).",".print_r($exec_params,true).")\n");
468 468
 
469
-		$type = $options['type'];	// 'd', 'f' or 'F'
470
-		$dirs_last = $options['depth'];	// put content of dirs before the dir itself
469
+		$type = $options['type']; // 'd', 'f' or 'F'
470
+		$dirs_last = $options['depth']; // put content of dirs before the dir itself
471 471
 		// show dirs on top by default, if no recursive listing (allways disabled if $type specified, as unnecessary)
472
-		$dirsontop = !$type && (isset($options['dirsontop']) ? (boolean)$options['dirsontop'] : isset($options['maxdepth'])&&$options['maxdepth']>0);
473
-		if ($dirsontop) $options['need_mime'] = true;	// otherwise dirsontop can NOT work
472
+		$dirsontop = !$type && (isset($options['dirsontop']) ? (boolean)$options['dirsontop'] : isset($options['maxdepth']) && $options['maxdepth'] > 0);
473
+		if ($dirsontop) $options['need_mime'] = true; // otherwise dirsontop can NOT work
474 474
 
475 475
 		// process some of the options (need to be done only once)
476 476
 		if (isset($options['name']) && !isset($options['name_preg']))	// change from simple *,? wildcards to preg regular expression once
477 477
 		{
478
-			$options['name_preg'] = '/^'.str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($options['name'])).'$/i';
478
+			$options['name_preg'] = '/^'.str_replace(array('\\?', '\\*'), array('.{1}', '.*'), preg_quote($options['name'])).'$/i';
479 479
 		}
480 480
 		if (isset($options['path']) && !isset($options['preg_path']))	// change from simple *,? wildcards to preg regular expression once
481 481
 		{
482
-			$options['path_preg'] = '/^'.str_replace(array('\\?','\\*'),array('.{1}','.*'),preg_quote($options['path'])).'$/i';
482
+			$options['path_preg'] = '/^'.str_replace(array('\\?', '\\*'), array('.{1}', '.*'), preg_quote($options['path'])).'$/i';
483 483
 		}
484 484
 		if (!isset($options['uid']))
485 485
 		{
486 486
 			if (isset($options['user']))
487 487
 			{
488
-				$options['uid'] = $GLOBALS['egw']->accounts->name2id($options['user'],'account_lid','u');
488
+				$options['uid'] = $GLOBALS['egw']->accounts->name2id($options['user'], 'account_lid', 'u');
489 489
 			}
490 490
 			elseif (isset($options['nouser']))
491 491
 			{
@@ -496,7 +496,7 @@  discard block
 block discarded – undo
496 496
 		{
497 497
 			if (isset($options['group']))
498 498
 			{
499
-				$options['gid'] = abs($GLOBALS['egw']->accounts->name2id($options['group'],'account_lid','g'));
499
+				$options['gid'] = abs($GLOBALS['egw']->accounts->name2id($options['group'], 'account_lid', 'g'));
500 500
 			}
501 501
 			elseif (isset($options['nogroup']))
502 502
 			{
@@ -505,7 +505,7 @@  discard block
 block discarded – undo
505 505
 		}
506 506
 		if ($options['order'] == 'mime')
507 507
 		{
508
-			$options['need_mime'] = true;	// we need to return the mime colum
508
+			$options['need_mime'] = true; // we need to return the mime colum
509 509
 		}
510 510
 		// implicit show deleted files, if hidden is enabled (requires versioning!)
511 511
 		if (!empty($options['hidden']) && !isset($options['show-deleted']))
@@ -523,37 +523,37 @@  discard block
 block discarded – undo
523 523
 			$base = array($base);
524 524
 		}
525 525
 		$result = array();
526
-		foreach($base as $path)
526
+		foreach ($base as $path)
527 527
 		{
528 528
 			if (!$url)
529 529
 			{
530 530
 				if ($path[0] != '/' || !self::stat($path)) continue;
531
-				$path = self::PREFIX . $path;
531
+				$path = self::PREFIX.$path;
532 532
 			}
533 533
 			if (!isset($options['remove']))
534 534
 			{
535
-				$options['remove'] = count($base) == 1 ? count(explode('/',$path))-3+(int)(substr($path,-1)!='/') : 0;
535
+				$options['remove'] = count($base) == 1 ? count(explode('/', $path)) - 3 + (int)(substr($path, -1) != '/') : 0;
536 536
 			}
537 537
 			$is_dir = is_dir($path);
538 538
 			if ((int)$options['mindepth'] == 0 && (!$dirs_last || !$is_dir))
539 539
 			{
540
-				self::_check_add($options,$path,$result);
540
+				self::_check_add($options, $path, $result);
541 541
 			}
542 542
 			if ($is_dir && (!isset($options['maxdepth']) || ($options['maxdepth'] > 0 &&
543 543
 				$options['depth'] < $options['maxdepth'])) &&
544 544
 				($dir = @opendir($path, $context)))
545 545
 			{
546
-				while(($fname = readdir($dir)) !== false)
546
+				while (($fname = readdir($dir)) !== false)
547 547
 				{
548
-					if ($fname == '.' || $fname == '..') continue;	// ignore current and parent dir!
548
+					if ($fname == '.' || $fname == '..') continue; // ignore current and parent dir!
549 549
 
550
-					if (self::is_hidden($fname, $options['show-deleted']) && !$options['hidden']) continue;	// ignore hidden files
550
+					if (self::is_hidden($fname, $options['show-deleted']) && !$options['hidden']) continue; // ignore hidden files
551 551
 
552 552
 					$file = self::concat($path, $fname);
553 553
 
554 554
 					if ((int)$options['mindepth'] <= 1)
555 555
 					{
556
-						self::_check_add($options,$file,$result);
556
+						self::_check_add($options, $file, $result);
557 557
 					}
558 558
 					// only descend into subdirs, if it's a real dir (no link to a dir) or we should follow symlinks
559 559
 					if (is_dir($file) && ($options['follow'] || !is_link($file)) && (!isset($options['maxdepth']) || $options['maxdepth'] > 1))
@@ -563,7 +563,7 @@  discard block
 block discarded – undo
563 563
 						if ($opts['maxdepth']) $opts['depth']++;
564 564
 						unset($opts['order']);
565 565
 						unset($opts['limit']);
566
-						foreach(self::find($options['url']?$file:self::parse_url($file,PHP_URL_PATH),$opts,true) as $p => $s)
566
+						foreach (self::find($options['url'] ? $file : self::parse_url($file, PHP_URL_PATH), $opts, true) as $p => $s)
567 567
 						{
568 568
 							unset($result[$p]);
569 569
 							$result[$p] = $s;
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
 			}
575 575
 			if ($is_dir && (int)$options['mindepth'] == 0 && $dirs_last)
576 576
 			{
577
-				self::_check_add($options,$path,$result);
577
+				self::_check_add($options, $path, $result);
578 578
 			}
579 579
 		}
580 580
 		// sort code, to place directories before files, if $dirsontop enabled
@@ -584,7 +584,7 @@  discard block
 block discarded – undo
584 584
 		if (isset($options['order']))
585 585
 		{
586 586
 			$sort = strtolower($options['sort']) == 'desc' ? '-' : '';
587
-			switch($options['order'])
587
+			switch ($options['order'])
588 588
 			{
589 589
 				// sort numerical
590 590
 				case 'size':
@@ -596,7 +596,7 @@  discard block
 block discarded – undo
596 596
 					$code = $dirsfirst.$sort.'($a[\''.$options['order'].'\']-$b[\''.$options['order'].'\']);';
597 597
 					// always use name as second sort criteria
598 598
 					$code = '$cmp = '.$code.' return $cmp ? $cmp : strcasecmp($a[\'name\'],$b[\'name\']);';
599
-					$ok = uasort($result,create_function('$a,$b',$code));
599
+					$ok = uasort($result, create_function('$a,$b', $code));
600 600
 					break;
601 601
 
602 602
 				// sort alphanumerical
@@ -615,7 +615,7 @@  discard block
 block discarded – undo
615 615
 					{
616 616
 						$code = 'return '.$code;
617 617
 					}
618
-					$ok = uasort($result,create_function('$a,$b',$code));
618
+					$ok = uasort($result, create_function('$a,$b', $code));
619 619
 					break;
620 620
 			}
621 621
 			//echo "<p>order='$options[order]', sort='$options[sort]' --> uasort($result,create_function(,'$code'))=".array2string($ok)."</p>>\n";
@@ -624,13 +624,13 @@  discard block
 block discarded – undo
624 624
 		self::$find_total = count($result);
625 625
 		if (isset($options['limit']))
626 626
 		{
627
-			list($limit,$start) = explode(',',$options['limit']);
627
+			list($limit, $start) = explode(',', $options['limit']);
628 628
 			if (!$limit && !($limit = $GLOBALS['egw_info']['user']['preferences']['comman']['maxmatches'])) $limit = 15;
629 629
 			//echo "total=".self::$find_total.", limit=$options[limit] --> start=$start, limit=$limit<br>\n";
630 630
 
631 631
 			if ((int)$start || self::$find_total > $limit)
632 632
 			{
633
-				$result = array_slice($result,(int)$start,(int)$limit,true);
633
+				$result = array_slice($result, (int)$start, (int)$limit, true);
634 634
 			}
635 635
 		}
636 636
 		//echo $path; _debug_array($result);
@@ -640,13 +640,13 @@  discard block
 block discarded – undo
640 640
 			{
641 641
 				$exec_params = is_null($exec_params) ? array() : array($exec_params);
642 642
 			}
643
-			foreach($result as $path => &$stat)
643
+			foreach ($result as $path => &$stat)
644 644
 			{
645 645
 				$options = $exec_params;
646
-				array_unshift($options,$path);
647
-				array_push($options,$stat);
646
+				array_unshift($options, $path);
647
+				array_push($options, $stat);
648 648
 				//echo "calling ".print_r($exec,true).print_r($options,true)."\n";
649
-				$stat = call_user_func_array($exec,$options);
649
+				$stat = call_user_func_array($exec, $options);
650 650
 			}
651 651
 			return $result;
652 652
 		}
@@ -665,9 +665,9 @@  discard block
 block discarded – undo
665 665
 	 * @param string $path name of path to add
666 666
 	 * @param array &$result here we add the stat for the key $path, if the checks are successful
667 667
 	 */
668
-	private static function _check_add($options,$path,&$result)
668
+	private static function _check_add($options, $path, &$result)
669 669
 	{
670
-		$type = $options['type'];	// 'd' or 'f'
670
+		$type = $options['type']; // 'd' or 'f'
671 671
 
672 672
 		if ($options['url'])
673 673
 		{
@@ -675,35 +675,35 @@  discard block
 block discarded – undo
675 675
 		}
676 676
 		else
677 677
 		{
678
-			$stat = self::url_stat($path,STREAM_URL_STAT_LINK);
678
+			$stat = self::url_stat($path, STREAM_URL_STAT_LINK);
679 679
 		}
680 680
 		if (!$stat)
681 681
 		{
682
-			return;	// not found, should not happen
682
+			return; // not found, should not happen
683 683
 		}
684
-		if ($type && (($type == 'd') == !($stat['mode'] & Vfs\Sqlfs\StreamWrapper::MODE_DIR) ||	// != is_dir() which can be true for symlinks
684
+		if ($type && (($type == 'd') == !($stat['mode']&Vfs\Sqlfs\StreamWrapper::MODE_DIR) || // != is_dir() which can be true for symlinks
685 685
 		    $type == 'F' && is_dir($path)))	// symlink to a directory
686 686
 		{
687
-			return;	// wrong type
687
+			return; // wrong type
688 688
 		}
689
-		$stat = array_slice($stat,13);	// remove numerical indices 0-12
690
-		$stat['path'] = self::parse_url($path,PHP_URL_PATH);
691
-		$stat['name'] = $options['remove'] > 0 ? implode('/',array_slice(explode('/',$stat['path']),$options['remove'])) : self::basename($path);
689
+		$stat = array_slice($stat, 13); // remove numerical indices 0-12
690
+		$stat['path'] = self::parse_url($path, PHP_URL_PATH);
691
+		$stat['name'] = $options['remove'] > 0 ? implode('/', array_slice(explode('/', $stat['path']), $options['remove'])) : self::basename($path);
692 692
 
693 693
 		if ($options['mime'] || $options['need_mime'])
694 694
 		{
695 695
 			$stat['mime'] = self::mime_content_type($path);
696 696
 		}
697
-		if (isset($options['name_preg']) && !preg_match($options['name_preg'],$stat['name']) ||
698
-			isset($options['path_preg']) && !preg_match($options['path_preg'],$path))
697
+		if (isset($options['name_preg']) && !preg_match($options['name_preg'], $stat['name']) ||
698
+			isset($options['path_preg']) && !preg_match($options['path_preg'], $path))
699 699
 		{
700 700
 			//echo "<p>!preg_match('{$options['name_preg']}','{$stat['name']}')</p>\n";
701
-			return;	// wrong name or path
701
+			return; // wrong name or path
702 702
 		}
703 703
 		if (isset($options['gid']) && $stat['gid'] != $options['gid'] ||
704 704
 			isset($options['uid']) && $stat['uid'] != $options['uid'])
705 705
 		{
706
-			return;	// wrong user or group
706
+			return; // wrong user or group
707 707
 		}
708 708
 		if (isset($options['mime']) && $options['mime'] != $stat['mime'])
709 709
 		{
@@ -711,40 +711,40 @@  discard block
 block discarded – undo
711 711
 			{
712 712
 				if (!preg_match($options['mime'], $stat['mime']))
713 713
 				{
714
-					return;	// wrong mime-type
714
+					return; // wrong mime-type
715 715
 				}
716 716
 			}
717 717
 			else
718 718
 			{
719
-				list($type,$subtype) = explode('/',$options['mime']);
719
+				list($type, $subtype) = explode('/', $options['mime']);
720 720
 				// no subtype (eg. 'image') --> check only the main type
721
-				if ($subtype || substr($stat['mime'],0,strlen($type)+1) != $type.'/')
721
+				if ($subtype || substr($stat['mime'], 0, strlen($type) + 1) != $type.'/')
722 722
 				{
723
-					return;	// wrong mime-type
723
+					return; // wrong mime-type
724 724
 				}
725 725
 			}
726 726
 		}
727
-		if (isset($options['size']) && !self::_check_num($stat['size'],$options['size']) ||
727
+		if (isset($options['size']) && !self::_check_num($stat['size'], $options['size']) ||
728 728
 			(isset($options['empty']) && !!$options['empty'] !== !$stat['size']))
729 729
 		{
730
-			return;	// wrong size
730
+			return; // wrong size
731 731
 		}
732
-		if (isset($options['cmin']) && !self::_check_num(round((time()-$stat['ctime'])/60),$options['cmin']) ||
733
-			isset($options['mmin']) && !self::_check_num(round((time()-$stat['mtime'])/60),$options['mmin']) ||
734
-			isset($options['ctime']) && !self::_check_num(round((time()-$stat['ctime'])/86400),$options['ctime']) ||
735
-			isset($options['mtime']) && !self::_check_num(round((time()-$stat['mtime'])/86400),$options['mtime']))
732
+		if (isset($options['cmin']) && !self::_check_num(round((time() - $stat['ctime']) / 60), $options['cmin']) ||
733
+			isset($options['mmin']) && !self::_check_num(round((time() - $stat['mtime']) / 60), $options['mmin']) ||
734
+			isset($options['ctime']) && !self::_check_num(round((time() - $stat['ctime']) / 86400), $options['ctime']) ||
735
+			isset($options['mtime']) && !self::_check_num(round((time() - $stat['mtime']) / 86400), $options['mtime']))
736 736
 		{
737
-			return;	// not create/modified in the spezified time
737
+			return; // not create/modified in the spezified time
738 738
 		}
739 739
 		// do we return url or just vfs pathes
740 740
 		if (!$options['url'])
741 741
 		{
742
-			$path = self::parse_url($path,PHP_URL_PATH);
742
+			$path = self::parse_url($path, PHP_URL_PATH);
743 743
 		}
744 744
 		$result[$path] = $stat;
745 745
 	}
746 746
 
747
-	private static function _check_num($value,$argument)
747
+	private static function _check_num($value, $argument)
748 748
 	{
749 749
 		if (is_int($argument) && $argument >= 0 || $argument[0] != '-' && $argument[0] != '+')
750 750
 		{
@@ -757,7 +757,7 @@  discard block
 block discarded – undo
757 757
 			return $value < abs($argument);
758 758
 		}
759 759
 		//echo "_check_num($value,$argument) check > == ".(int)($value > (int)substr($argument,1))."\n";
760
-		return $value > (int) substr($argument,1);
760
+		return $value > (int)substr($argument, 1);
761 761
 	}
762 762
 
763 763
 	/**
@@ -768,18 +768,18 @@  discard block
 block discarded – undo
768 768
 	 * @throws egw_exception_assertion_failed when trainig to remove /, /apps or /home
769 769
 	 * @return array
770 770
 	 */
771
-	static function remove($urls,$allow_urls=false)
771
+	static function remove($urls, $allow_urls = false)
772 772
 	{
773 773
 		//error_log(__METHOD__.'('.array2string($urls).')');
774 774
 		// some precaution to never allow to (recursivly) remove /, /apps or /home
775
-		foreach((array)$urls as $url)
775
+		foreach ((array)$urls as $url)
776 776
 		{
777
-			if (preg_match('/^\/?(home|apps|)\/*$/',self::parse_url($url,PHP_URL_PATH)))
777
+			if (preg_match('/^\/?(home|apps|)\/*$/', self::parse_url($url, PHP_URL_PATH)))
778 778
 			{
779 779
 				throw new egw_exception_assertion_failed(__METHOD__.'('.array2string($urls).") Cautiously rejecting to remove folder '$url'!");
780 780
 			}
781 781
 		}
782
-		return self::find($urls,array('depth'=>true,'url'=>$allow_urls,'hidden'=>true),array(__CLASS__,'_rm_rmdir'));
782
+		return self::find($urls, array('depth'=>true, 'url'=>$allow_urls, 'hidden'=>true), array(__CLASS__, '_rm_rmdir'));
783 783
 	}
784 784
 
785 785
 	/**
@@ -792,11 +792,11 @@  discard block
 block discarded – undo
792 792
 	{
793 793
 		if ($url[0] == '/')
794 794
 		{
795
-			$url = self::PREFIX . $url;
795
+			$url = self::PREFIX.$url;
796 796
 		}
797 797
 		if (is_dir($url) && !is_link($url))
798 798
 		{
799
-			return self::rmdir($url,0);
799
+			return self::rmdir($url, 0);
800 800
 		}
801 801
 		return self::unlink($url);
802 802
 	}
@@ -810,9 +810,9 @@  discard block
 block discarded – undo
810 810
 	 * 	2 = self::WRITABLE, 1 = self::EXECUTABLE
811 811
 	 * @return boolean
812 812
 	 */
813
-	static function is_readable($path,$check = self::READABLE)
813
+	static function is_readable($path, $check = self::READABLE)
814 814
 	{
815
-		return self::check_access($path,$check);
815
+		return self::check_access($path, $check);
816 816
 	}
817 817
 
818 818
 	/**
@@ -826,7 +826,7 @@  discard block
 block discarded – undo
826 826
 	 * @param int $user =null user used for check, if not current user (self::$user)
827 827
 	 * @return boolean
828 828
 	 */
829
-	static function check_access($path, $check, $stat=null, $user=null)
829
+	static function check_access($path, $check, $stat = null, $user = null)
830 830
 	{
831 831
 		if (is_null($stat) && $user && $user != self::$user)
832 832
 		{
@@ -841,7 +841,7 @@  discard block
 block discarded – undo
841 841
 
842 842
 				$path_user_stat[$path][$user] = self::url_stat($path, 0);
843 843
 
844
-				self::clearstatcache($path);	// we need to clear the stat-cache after the call too, as the next call might be the regular user again!
844
+				self::clearstatcache($path); // we need to clear the stat-cache after the call too, as the next call might be the regular user again!
845 845
 			}
846 846
 			if (($stat = $path_user_stat[$path][$user]))
847 847
 			{
@@ -857,7 +857,7 @@  discard block
 block discarded – undo
857 857
 			}
858 858
 			else
859 859
 			{
860
-				$ret = false;	// no access, if we can not stat the file
860
+				$ret = false; // no access, if we can not stat the file
861 861
 			}
862 862
 			self::$user = $backup_user;
863 863
 
@@ -881,20 +881,20 @@  discard block
 block discarded – undo
881 881
 		// query stat array, if not given
882 882
 		if (is_null($stat))
883 883
 		{
884
-			$stat = self::url_stat($path,0);
884
+			$stat = self::url_stat($path, 0);
885 885
 		}
886 886
 		//error_log(__METHOD__."(path=$path||stat[name]={$stat['name']},stat[mode]=".sprintf('%o',$stat['mode']).",$check)");
887 887
 
888 888
 		if (!$stat)
889 889
 		{
890 890
 			//error_log(__METHOD__."(path=$path||stat[name]={$stat['name']},stat[mode]=".sprintf('%o',$stat['mode']).",$check) no stat array!");
891
-			return false;	// file not found
891
+			return false; // file not found
892 892
 		}
893 893
 		// check if we use an EGroupwre stream wrapper, or a stock php one
894 894
 		// if it's not an EGroupware one, we can NOT use uid, gid and mode!
895
-		if (($scheme = self::parse_url($stat['url'],PHP_URL_SCHEME)) && !(class_exists(self::scheme2class($scheme))))
895
+		if (($scheme = self::parse_url($stat['url'], PHP_URL_SCHEME)) && !(class_exists(self::scheme2class($scheme))))
896 896
 		{
897
-			switch($check)
897
+			switch ($check)
898 898
 			{
899 899
 				case self::READABLE:
900 900
 					return is_readable($stat['url']);
@@ -905,19 +905,19 @@  discard block
 block discarded – undo
905 905
 			}
906 906
 		}
907 907
 		// check if other rights grant access
908
-		if (($stat['mode'] & $check) == $check)
908
+		if (($stat['mode']&$check) == $check)
909 909
 		{
910 910
 			//error_log(__METHOD__."(path=$path||stat[name]={$stat['name']},stat[mode]=".sprintf('%o',$stat['mode']).",$check) access via other rights!");
911 911
 			return true;
912 912
 		}
913 913
 		// check if there's owner access and we are the owner
914
-		if (($stat['mode'] & ($check << 6)) == ($check << 6) && $stat['uid'] && $stat['uid'] == self::$user)
914
+		if (($stat['mode']&($check << 6)) == ($check << 6) && $stat['uid'] && $stat['uid'] == self::$user)
915 915
 		{
916 916
 			//error_log(__METHOD__."(path=$path||stat[name]={$stat['name']},stat[mode]=".sprintf('%o',$stat['mode']).",$check) access via owner rights!");
917 917
 			return true;
918 918
 		}
919 919
 		// check if there's a group access and we have the right membership
920
-		if (($stat['mode'] & ($check << 3)) == ($check << 3) && $stat['gid'])
920
+		if (($stat['mode']&($check << 3)) == ($check << 3) && $stat['gid'])
921 921
 		{
922 922
 			if (($memberships = $GLOBALS['egw']->accounts->memberships(self::$user, true)) && in_array(-abs($stat['gid']), $memberships))
923 923
 			{
@@ -926,7 +926,7 @@  discard block
 block discarded – undo
926 926
 			}
927 927
 		}
928 928
 		// check backend for extended acls (only if path given)
929
-		$ret = $path && self::_call_on_backend('check_extended_acl',array(isset($stat['url'])?$stat['url']:$path,$check),true);	// true = fail silent if backend does not support
929
+		$ret = $path && self::_call_on_backend('check_extended_acl', array(isset($stat['url']) ? $stat['url'] : $path, $check), true); // true = fail silent if backend does not support
930 930
 
931 931
 		//error_log(__METHOD__."(path=$path||stat[name]={$stat['name']},stat[mode]=".sprintf('%o',$stat['mode']).",$check) ".($ret ? 'backend extended acl granted access.' : 'no access!!!'));
932 932
 		return $ret;
@@ -941,7 +941,7 @@  discard block
 block discarded – undo
941 941
 	 */
942 942
 	static function is_writable($path)
943 943
 	{
944
-		return self::is_readable($path,self::WRITABLE);
944
+		return self::is_readable($path, self::WRITABLE);
945 945
 	}
946 946
 
947 947
 	/**
@@ -953,7 +953,7 @@  discard block
 block discarded – undo
953 953
 	 */
954 954
 	static function is_executable($path)
955 955
 	{
956
-		return self::is_readable($path,self::EXECUTABLE);
956
+		return self::is_readable($path, self::EXECUTABLE);
957 957
 	}
958 958
 
959 959
 	/**
@@ -964,7 +964,7 @@  discard block
 block discarded – undo
964 964
 	 */
965 965
 	static function deny_script($path)
966 966
 	{
967
-		return self::_call_on_backend('deny_script',array($path),true);
967
+		return self::_call_on_backend('deny_script', array($path), true);
968 968
 	}
969 969
 
970 970
 	/**
@@ -983,11 +983,11 @@  discard block
 block discarded – undo
983 983
 	 * @param boolean $session_only =false true: set eacl only for this session, does NO further checks currently!
984 984
 	 * @return boolean true if acl is set/deleted, false on error
985 985
 	 */
986
-	static function eacl($url,$rights=null,$owner=null,$session_only=false)
986
+	static function eacl($url, $rights = null, $owner = null, $session_only = false)
987 987
 	{
988 988
 		if ($session_only)
989 989
 		{
990
-			$session_eacls =& egw_cache::getSession(__CLASS__, self::SESSION_EACL);
990
+			$session_eacls = & egw_cache::getSession(__CLASS__, self::SESSION_EACL);
991 991
 			$session_eacls[] = array(
992 992
 				'path'   => $url[0] == '/' ? $url : self::parse_url($url, PHP_URL_PATH),
993 993
 				'owner'  => $owner ? $owner : self::$user,
@@ -995,7 +995,7 @@  discard block
 block discarded – undo
995 995
 			);
996 996
 			return true;
997 997
 		}
998
-		return self::_call_on_backend('eacl',array($url,$rights,$owner));
998
+		return self::_call_on_backend('eacl', array($url, $rights, $owner));
999 999
 	}
1000 1000
 
1001 1001
 	/**
@@ -1008,9 +1008,9 @@  discard block
 block discarded – undo
1008 1008
 	 */
1009 1009
 	static function get_eacl($path)
1010 1010
 	{
1011
-		$eacls = self::_call_on_backend('get_eacl',array($path),true);	// true = fail silent (no PHP Warning)
1011
+		$eacls = self::_call_on_backend('get_eacl', array($path), true); // true = fail silent (no PHP Warning)
1012 1012
 
1013
-		$session_eacls =& egw_cache::getSession(__CLASS__, self::SESSION_EACL);
1013
+		$session_eacls = & egw_cache::getSession(__CLASS__, self::SESSION_EACL);
1014 1014
 		if ($session_eacls)
1015 1015
 		{
1016 1016
 			// eacl is recursive, therefore we have to match all parent-dirs too
@@ -1019,7 +1019,7 @@  discard block
 block discarded – undo
1019 1019
 			{
1020 1020
 				$paths[] = $path = self::dirname($path);
1021 1021
 			}
1022
-			foreach((array)$session_eacls as $eacl)
1022
+			foreach ((array)$session_eacls as $eacl)
1023 1023
 			{
1024 1024
 				if (in_array($eacl['path'], $paths))
1025 1025
 				{
@@ -1042,9 +1042,9 @@  discard block
 block discarded – undo
1042 1042
 	 * @param array $props array of array with values for keys 'name', 'ns', 'val' (null to delete the prop)
1043 1043
 	 * @return boolean true if props are updated, false otherwise (eg. ressource not found)
1044 1044
 	 */
1045
-	static function proppatch($path,array $props)
1045
+	static function proppatch($path, array $props)
1046 1046
 	{
1047
-		return self::_call_on_backend('proppatch',array($path,$props));
1047
+		return self::_call_on_backend('proppatch', array($path, $props));
1048 1048
 	}
1049 1049
 
1050 1050
 	/**
@@ -1061,9 +1061,9 @@  discard block
 block discarded – undo
1061 1061
 	 * @return array|boolean array with props (values for keys 'name', 'ns', 'val'), or path => array of props for is_array($path)
1062 1062
 	 * 	false if $path does not exist
1063 1063
 	 */
1064
-	static function propfind($path,$ns=self::DEFAULT_PROP_NAMESPACE)
1064
+	static function propfind($path, $ns = self::DEFAULT_PROP_NAMESPACE)
1065 1065
 	{
1066
-		return self::_call_on_backend('propfind',array($path,$ns),true);	// true = fail silent (no PHP Warning)
1066
+		return self::_call_on_backend('propfind', array($path, $ns), true); // true = fail silent (no PHP Warning)
1067 1067
 	}
1068 1068
 
1069 1069
 	/**
@@ -1081,7 +1081,7 @@  discard block
 block discarded – undo
1081 1081
 	 * @param int $mode =0 current mode of the file, necessary for +/- operation
1082 1082
 	 * @return int
1083 1083
 	 */
1084
-	static function mode2int($set,$mode=0)
1084
+	static function mode2int($set, $mode = 0)
1085 1085
 	{
1086 1086
 		if (is_int($set))		// already an integer
1087 1087
 		{
@@ -1090,23 +1090,23 @@  discard block
 block discarded – undo
1090 1090
 		if (is_numeric($set))	// octal string
1091 1091
 		{
1092 1092
 			//error_log(__METHOD__."($set,$mode) returning ".(int)base_convert($set,8,10));
1093
-			return (int)base_convert($set,8,10);	// convert octal to decimal
1093
+			return (int)base_convert($set, 8, 10); // convert octal to decimal
1094 1094
 		}
1095
-		foreach(explode(',',$set) as $s)
1095
+		foreach (explode(',', $set) as $s)
1096 1096
 		{
1097 1097
 			$matches = null;
1098
-			if (!preg_match($use='/^([ugoa]*)([+=-]+)([rwx]+)$/',$s,$matches))
1098
+			if (!preg_match($use = '/^([ugoa]*)([+=-]+)([rwx]+)$/', $s, $matches))
1099 1099
 			{
1100
-				$use = str_replace(array('/','^','$','(',')'),'',$use);
1100
+				$use = str_replace(array('/', '^', '$', '(', ')'), '', $use);
1101 1101
 				throw new egw_exception_wrong_userinput("$s is not an allowed mode, use $use !");
1102 1102
 			}
1103
-			$base = (strpos($matches[3],'r') !== false ? self::READABLE : 0) |
1104
-				(strpos($matches[3],'w') !== false ? self::WRITABLE : 0) |
1105
-				(strpos($matches[3],'x') !== false ? self::EXECUTABLE : 0);
1103
+			$base = (strpos($matches[3], 'r') !== false ? self::READABLE : 0)|
1104
+				(strpos($matches[3], 'w') !== false ? self::WRITABLE : 0)|
1105
+				(strpos($matches[3], 'x') !== false ? self::EXECUTABLE : 0);
1106 1106
 
1107
-			for($n = $m = 0; $n < strlen($matches[1]); $n++)
1107
+			for ($n = $m = 0; $n < strlen($matches[1]); $n++)
1108 1108
 			{
1109
-				switch($matches[1][$n])
1109
+				switch ($matches[1][$n])
1110 1110
 				{
1111 1111
 					case 'o':
1112 1112
 						$m |= $base;
@@ -1119,10 +1119,10 @@  discard block
 block discarded – undo
1119 1119
 						break;
1120 1120
 					default:
1121 1121
 					case 'a':
1122
-						$m = $base | ($base << 3) | ($base << 6);
1122
+						$m = $base|($base << 3)|($base << 6);
1123 1123
 				}
1124 1124
 			}
1125
-			switch($matches[2])
1125
+			switch ($matches[2])
1126 1126
 			{
1127 1127
 				case '+':
1128 1128
 					$mode |= $m;
@@ -1144,33 +1144,33 @@  discard block
 block discarded – undo
1144 1144
 	 * @param int $mode
1145 1145
 	 * @return string
1146 1146
 	 */
1147
-	static function int2mode( $mode )
1147
+	static function int2mode($mode)
1148 1148
 	{
1149
-		if(($mode & self::MODE_LINK) == self::MODE_LINK) // Symbolic Link
1149
+		if (($mode&self::MODE_LINK) == self::MODE_LINK) // Symbolic Link
1150 1150
 		{
1151 1151
 			$sP = 'l';
1152 1152
 		}
1153
-		elseif(($mode & 0xC000) == 0xC000) // Socket
1153
+		elseif (($mode&0xC000) == 0xC000) // Socket
1154 1154
 		{
1155 1155
 			$sP = 's';
1156 1156
 		}
1157
-		elseif($mode & 0x1000)     // FIFO pipe
1157
+		elseif ($mode&0x1000)     // FIFO pipe
1158 1158
 		{
1159 1159
 			$sP = 'p';
1160 1160
 		}
1161
-		elseif($mode & 0x2000) // Character special
1161
+		elseif ($mode&0x2000) // Character special
1162 1162
 		{
1163 1163
 			$sP = 'c';
1164 1164
 		}
1165
-		elseif($mode & 0x4000) // Directory
1165
+		elseif ($mode&0x4000) // Directory
1166 1166
 		{
1167 1167
 			$sP = 'd';
1168 1168
 		}
1169
-		elseif($mode & 0x6000) // Block special
1169
+		elseif ($mode&0x6000) // Block special
1170 1170
 		{
1171 1171
 			$sP = 'b';
1172 1172
 		}
1173
-		elseif($mode & 0x8000) // Regular
1173
+		elseif ($mode&0x8000) // Regular
1174 1174
 		{
1175 1175
 			$sP = '-';
1176 1176
 		}
@@ -1180,22 +1180,19 @@  discard block
 block discarded – undo
1180 1180
 		}
1181 1181
 
1182 1182
 		// owner
1183
-		$sP .= (($mode & 0x0100) ? 'r' : '-') .
1184
-		(($mode & 0x0080) ? 'w' : '-') .
1185
-		(($mode & 0x0040) ? (($mode & 0x0800) ? 's' : 'x' ) :
1186
-		(($mode & 0x0800) ? 'S' : '-'));
1183
+		$sP .= (($mode&0x0100) ? 'r' : '-').
1184
+		(($mode&0x0080) ? 'w' : '-').
1185
+		(($mode&0x0040) ? (($mode&0x0800) ? 's' : 'x') : (($mode&0x0800) ? 'S' : '-'));
1187 1186
 
1188 1187
 		// group
1189
-		$sP .= (($mode & 0x0020) ? 'r' : '-') .
1190
-		(($mode & 0x0010) ? 'w' : '-') .
1191
-		(($mode & 0x0008) ? (($mode & 0x0400) ? 's' : 'x' ) :
1192
-		(($mode & 0x0400) ? 'S' : '-'));
1188
+		$sP .= (($mode&0x0020) ? 'r' : '-').
1189
+		(($mode&0x0010) ? 'w' : '-').
1190
+		(($mode&0x0008) ? (($mode&0x0400) ? 's' : 'x') : (($mode&0x0400) ? 'S' : '-'));
1193 1191
 
1194 1192
 		// world
1195
-		$sP .= (($mode & 0x0004) ? 'r' : '-') .
1196
-		(($mode & 0x0002) ? 'w' : '-') .
1197
-		(($mode & 0x0001) ? (($mode & 0x0200) ? 't' : 'x' ) :
1198
-		(($mode & 0x0200) ? 'T' : '-'));
1193
+		$sP .= (($mode&0x0004) ? 'r' : '-').
1194
+		(($mode&0x0002) ? 'w' : '-').
1195
+		(($mode&0x0001) ? (($mode&0x0200) ? 't' : 'x') : (($mode&0x0200) ? 'T' : '-'));
1199 1196
 
1200 1197
 		return $sP;
1201 1198
 	}
@@ -1208,26 +1205,26 @@  discard block
 block discarded – undo
1208 1205
 	 * @param int $size =128
1209 1206
 	 * @return string
1210 1207
 	 */
1211
-	static function mime_icon($mime_type, $et_image=true, $size=128)
1208
+	static function mime_icon($mime_type, $et_image = true, $size = 128)
1212 1209
 	{
1213 1210
 		if ($mime_type == self::DIR_MIME_TYPE)
1214 1211
 		{
1215 1212
 			$mime_type = 'Directory';
1216 1213
 		}
1217
-		if(!$mime_type)
1214
+		if (!$mime_type)
1218 1215
 		{
1219 1216
 			$mime_type = 'unknown';
1220 1217
 		}
1221
-		$mime_full = strtolower(str_replace	('/','_',$mime_type));
1222
-		list($mime_part) = explode('_',$mime_full);
1218
+		$mime_full = strtolower(str_replace('/', '_', $mime_type));
1219
+		list($mime_part) = explode('_', $mime_full);
1223 1220
 
1224
-		if (!($img=common::image('etemplate',$icon='mime'.$size.'_'.$mime_full)) &&
1221
+		if (!($img = common::image('etemplate', $icon = 'mime'.$size.'_'.$mime_full)) &&
1225 1222
 			// check mime-alias-map before falling back to more generic icons
1226 1223
 			!(isset(mime_magic::$mime_alias_map[$mime_type]) &&
1227
-				($img=common::image('etemplate',$icon='mime'.$size.'_'.str_replace('/','_',mime_magic::$mime_alias_map[$mime_full])))) &&
1228
-			!($img=common::image('etemplate',$icon='mime'.$size.'_'.$mime_part)))
1224
+				($img = common::image('etemplate', $icon = 'mime'.$size.'_'.str_replace('/', '_', mime_magic::$mime_alias_map[$mime_full])))) &&
1225
+			!($img = common::image('etemplate', $icon = 'mime'.$size.'_'.$mime_part)))
1229 1226
 		{
1230
-			$img = common::image('etemplate',$icon='mime'.$size.'_unknown');
1227
+			$img = common::image('etemplate', $icon = 'mime'.$size.'_unknown');
1231 1228
 		}
1232 1229
 		if ($et_image === 'url')
1233 1230
 		{
@@ -1237,7 +1234,7 @@  discard block
 block discarded – undo
1237 1234
 		{
1238 1235
 			return 'etemplate/'.$icon;
1239 1236
 		}
1240
-		return html::image('etemplate',$icon,mime_magic::mime2label($mime_type));
1237
+		return html::image('etemplate', $icon, mime_magic::mime2label($mime_type));
1241 1238
 	}
1242 1239
 
1243 1240
 	/**
@@ -1249,9 +1246,9 @@  discard block
 block discarded – undo
1249 1246
 	static function hsize($size)
1250 1247
 	{
1251 1248
 		if ($size < 1024) return $size;
1252
-		if ($size < 1024*1024) return sprintf('%3.1lfk',(float)$size/1024);
1253
-		if ($size < 1024*1024*1024) return sprintf('%3.1lfM',(float)$size/(1024*1024));
1254
-		return sprintf('%3.1lfG',(float)$size/(1024*1024*1024));
1249
+		if ($size < 1024 * 1024) return sprintf('%3.1lfk', (float)$size / 1024);
1250
+		if ($size < 1024 * 1024 * 1024) return sprintf('%3.1lfM', (float)$size / (1024 * 1024));
1251
+		return sprintf('%3.1lfG', (float)$size / (1024 * 1024 * 1024));
1255 1252
 	}
1256 1253
 
1257 1254
 	/**
@@ -1261,7 +1258,7 @@  discard block
 block discarded – undo
1261 1258
 	 */
1262 1259
 	static function int_size($_val)
1263 1260
 	{
1264
-		if(empty($_val))return 0;
1261
+		if (empty($_val))return 0;
1265 1262
 
1266 1263
 		$val = trim($_val);
1267 1264
 
@@ -1269,12 +1266,12 @@  discard block
 block discarded – undo
1269 1266
 		preg_match('#([0-9]+)[\s]*([a-z]+)#i', $val, $matches);
1270 1267
 
1271 1268
 		$last = '';
1272
-		if(isset($matches[2])){
1269
+		if (isset($matches[2])) {
1273 1270
 			$last = $matches[2];
1274 1271
 		}
1275 1272
 
1276
-		if(isset($matches[1])){
1277
-			$val = (int) $matches[1];
1273
+		if (isset($matches[1])) {
1274
+			$val = (int)$matches[1];
1278 1275
 		}
1279 1276
 
1280 1277
 		switch (strtolower($last))
@@ -1290,7 +1287,7 @@  discard block
 block discarded – undo
1290 1287
 			$val *= 1024;
1291 1288
 		}
1292 1289
 
1293
-		return (int) $val;
1290
+		return (int)$val;
1294 1291
 	}
1295 1292
 
1296 1293
 	/**
@@ -1301,8 +1298,8 @@  discard block
 block discarded – undo
1301 1298
 	 */
1302 1299
 	static function basename($_path)
1303 1300
 	{
1304
-		list($path) = explode('?',$_path);	// remove query
1305
-		$parts = explode('/',$path);
1301
+		list($path) = explode('?', $_path); // remove query
1302
+		$parts = explode('/', $path);
1306 1303
 
1307 1304
 		return array_pop($parts);
1308 1305
 	}
@@ -1317,22 +1314,22 @@  discard block
 block discarded – undo
1317 1314
 	 */
1318 1315
 	static function dirname($_url)
1319 1316
 	{
1320
-		list($url,$query) = explode('?',$_url,2);	// strip the query first, as it can contain slashes
1317
+		list($url, $query) = explode('?', $_url, 2); // strip the query first, as it can contain slashes
1321 1318
 
1322
-		if ($url == '/' || $url[0] != '/' && self::parse_url($url,PHP_URL_PATH) == '/')
1319
+		if ($url == '/' || $url[0] != '/' && self::parse_url($url, PHP_URL_PATH) == '/')
1323 1320
 		{
1324 1321
 			//error_log(__METHOD__."($url) returning FALSE: already in root!");
1325 1322
 			return false;
1326 1323
 		}
1327
-		$parts = explode('/',$url);
1328
-		if (substr($url,-1) == '/') array_pop($parts);
1324
+		$parts = explode('/', $url);
1325
+		if (substr($url, -1) == '/') array_pop($parts);
1329 1326
 		array_pop($parts);
1330 1327
 		if ($url[0] != '/' && count($parts) == 3 || count($parts) == 1 && $parts[0] === '')
1331 1328
 		{
1332
-			array_push($parts,'');	// scheme://host is wrong (no path), has to be scheme://host/
1329
+			array_push($parts, ''); // scheme://host is wrong (no path), has to be scheme://host/
1333 1330
 		}
1334 1331
 		//error_log(__METHOD__."($url)=".implode('/',$parts).($query ? '?'.$query : ''));
1335
-		return implode('/',$parts).($query ? '?'.$query : '');
1332
+		return implode('/', $parts).($query ? '?'.$query : '');
1336 1333
 	}
1337 1334
 
1338 1335
 	/**
@@ -1344,13 +1341,13 @@  discard block
 block discarded – undo
1344 1341
 	 * @param array $stat =null stat for path, default queried by this function
1345 1342
 	 * @return boolean
1346 1343
 	 */
1347
-	static function has_owner_rights($path,array $stat=null)
1344
+	static function has_owner_rights($path, array $stat = null)
1348 1345
 	{
1349
-		if (!$stat) $stat = self::url_stat($path,0);
1346
+		if (!$stat) $stat = self::url_stat($path, 0);
1350 1347
 
1351
-		return $stat['uid'] == self::$user ||	// user is the owner
1352
-			self::$is_root ||					// class runs with root rights
1353
-			!$stat['uid'] && $stat['gid'] && self::$is_admin;	// group directory and user is an eGW admin
1348
+		return $stat['uid'] == self::$user || // user is the owner
1349
+			self::$is_root || // class runs with root rights
1350
+			!$stat['uid'] && $stat['gid'] && self::$is_admin; // group directory and user is an eGW admin
1354 1351
 	}
1355 1352
 
1356 1353
 	/**
@@ -1362,22 +1359,22 @@  discard block
 block discarded – undo
1362 1359
 	 * @param string $relative relative path to add to $url
1363 1360
 	 * @return string
1364 1361
 	 */
1365
-	static function concat($_url,$relative)
1362
+	static function concat($_url, $relative)
1366 1363
 	{
1367
-		list($url,$query) = explode('?',$_url,2);
1368
-		if (substr($url,-1) == '/') $url = substr($url,0,-1);
1364
+		list($url, $query) = explode('?', $_url, 2);
1365
+		if (substr($url, -1) == '/') $url = substr($url, 0, -1);
1369 1366
 		$ret = ($relative === '' || $relative[0] == '/' ? $url.$relative : $url.'/'.$relative);
1370 1367
 
1371 1368
 		// now normalize the path (remove "/something/..")
1372
-		while (strpos($ret,'/../') !== false)
1369
+		while (strpos($ret, '/../') !== false)
1373 1370
 		{
1374
-			list($a_str,$b_str) = explode('/../',$ret,2);
1375
-			$a = explode('/',$a_str);
1371
+			list($a_str, $b_str) = explode('/../', $ret, 2);
1372
+			$a = explode('/', $a_str);
1376 1373
 			array_pop($a);
1377
-			$b = explode('/',$b_str);
1378
-			$ret = implode('/',array_merge($a,$b));
1374
+			$b = explode('/', $b_str);
1375
+			$ret = implode('/', array_merge($a, $b));
1379 1376
 		}
1380
-		return $ret.($query ? (strpos($url,'?')===false ? '?' : '&').$query : '');
1377
+		return $ret.($query ? (strpos($url, '?') === false ? '?' : '&').$query : '');
1381 1378
 	}
1382 1379
 
1383 1380
 	/**
@@ -1388,11 +1385,11 @@  discard block
 block discarded – undo
1388 1385
 	 */
1389 1386
 	static function build_url(array $url_parts)
1390 1387
 	{
1391
-		$url = (!isset($url_parts['scheme'])?'':$url_parts['scheme'].'://'.
1392
-			(!isset($url_parts['user'])?'':$url_parts['user'].(!isset($url_parts['pass'])?'':':'.$url_parts['pass']).'@').
1388
+		$url = (!isset($url_parts['scheme']) ? '' : $url_parts['scheme'].'://'.
1389
+			(!isset($url_parts['user']) ? '' : $url_parts['user'].(!isset($url_parts['pass']) ? '' : ':'.$url_parts['pass']).'@').
1393 1390
 			$url_parts['host']).$url_parts['path'].
1394
-			(!isset($url_parts['query'])?'':'?'.$url_parts['query']).
1395
-			(!isset($url_parts['fragment'])?'':'?'.$url_parts['fragment']);
1391
+			(!isset($url_parts['query']) ? '' : '?'.$url_parts['query']).
1392
+			(!isset($url_parts['fragment']) ? '' : '?'.$url_parts['fragment']);
1396 1393
 		//error_log(__METHOD__.'('.array2string($url_parts).") = '".$url."'");
1397 1394
 		return $url;
1398 1395
 	}
@@ -1410,19 +1407,19 @@  discard block
 block discarded – undo
1410 1407
 	 * @todo get $force_download working through webdav
1411 1408
 	 * @return string
1412 1409
 	 */
1413
-	static function download_url($path,$force_download=false)
1410
+	static function download_url($path, $force_download = false)
1414 1411
 	{
1415
-		if (($url = self::_call_on_backend('download_url',array($path,$force_download),true)))
1412
+		if (($url = self::_call_on_backend('download_url', array($path, $force_download), true)))
1416 1413
 		{
1417 1414
 			return $url;
1418 1415
 		}
1419 1416
 		if ($path[0] != '/')
1420 1417
 		{
1421
-			$path = self::parse_url($path,PHP_URL_PATH);
1418
+			$path = self::parse_url($path, PHP_URL_PATH);
1422 1419
 		}
1423 1420
 		// we do NOT need to encode % itself, as our path are already url encoded, with the exception of ' ' and '+'
1424 1421
 		// we urlencode double quotes '"', as that fixes many problems in html markup
1425
-		return '/webdav.php'.strtr($path,array('+' => '%2B',' ' => '%20','"' => '%22')).($force_download ? '?download' : '');
1422
+		return '/webdav.php'.strtr($path, array('+' => '%2B', ' ' => '%20', '"' => '%22')).($force_download ? '?download' : '');
1426 1423
 	}
1427 1424
 
1428 1425
 	/**
@@ -1450,12 +1447,12 @@  discard block
 block discarded – undo
1450 1447
 		// eg: User selected /home/nathan/picture.jpg, /home/Pictures/logo.jpg
1451 1448
 		// We want /home
1452 1449
 		$dirs = array();
1453
-		foreach($_files as $file)
1450
+		foreach ($_files as $file)
1454 1451
 		{
1455 1452
 			$dirs[] = self::dirname($file);
1456 1453
 		}
1457 1454
 		$paths = array_unique($dirs);
1458
-		if(count($paths) > 0)
1455
+		if (count($paths) > 0)
1459 1456
 		{
1460 1457
 			// Shortest to longest
1461 1458
 			usort($paths, function($a, $b) {
@@ -1463,13 +1460,13 @@  discard block
 block discarded – undo
1463 1460
 			});
1464 1461
 
1465 1462
 			// Start with shortest, pop off sub-directories that don't match
1466
-			$parts = explode('/',$paths[0]);
1467
-			foreach($paths as $path)
1463
+			$parts = explode('/', $paths[0]);
1464
+			foreach ($paths as $path)
1468 1465
 			{
1469
-				$dirs = explode('/',$path);
1470
-				foreach($dirs as $dir_index => $dir)
1466
+				$dirs = explode('/', $path);
1467
+				foreach ($dirs as $dir_index => $dir)
1471 1468
 				{
1472
-					if($parts[$dir_index] && $parts[$dir_index] != $dir)
1469
+					if ($parts[$dir_index] && $parts[$dir_index] != $dir)
1473 1470
 					{
1474 1471
 						unset($parts[$dir_index]);
1475 1472
 					}
@@ -1488,24 +1485,23 @@  discard block
 block discarded – undo
1488 1485
 			// Linux
1489 1486
 			'/',
1490 1487
 			// Windows
1491
-			'\\','?','%','*',':','|',/*'.',*/ '"','<','>'
1488
+			'\\', '?', '%', '*', ':', '|', /*'.',*/ '"', '<', '>'
1492 1489
 		);
1493 1490
 
1494 1491
 		// A nice name for the user,
1495
-		$filename = $GLOBALS['egw_info']['server']['site_title'] . '_' .
1496
-			str_replace($replace,'_',(
1492
+		$filename = $GLOBALS['egw_info']['server']['site_title'].'_'.
1493
+			str_replace($replace, '_', (
1497 1494
 			$name ? $name : (
1498 1495
 			count($_files) == 1 ?
1499 1496
 			// Just one file (hopefully a directory?) selected
1500
-			self::basename($_files[0]) :
1501
-			// Use the lowest common directory (eg: Infolog, Open, nathan)
1497
+			self::basename($_files[0]) : // Use the lowest common directory (eg: Infolog, Open, nathan)
1502 1498
 			self::basename($base_dir))
1503
-		)) . '.zip';
1499
+		)).'.zip';
1504 1500
 
1505 1501
 		// Make sure basename is a dir
1506
-		if(substr($base_dir, -1) != '/')
1502
+		if (substr($base_dir, -1) != '/')
1507 1503
 		{
1508
-			$base_dir .='/';
1504
+			$base_dir .= '/';
1509 1505
 		}
1510 1506
 
1511 1507
 		// Go into directories, find them all
@@ -1516,37 +1512,37 @@  discard block
 block discarded – undo
1516 1512
 		$tempfiles = array();
1517 1513
 
1518 1514
 		// Give 1 second per file, but try to allow more time for big files when amount of files is low
1519
-		set_time_limit((count($files)<=9?10:count($files)));
1515
+		set_time_limit((count($files) <= 9 ? 10 : count($files)));
1520 1516
 
1521 1517
 		// Add files to archive
1522
-		foreach($files as &$addfile)
1518
+		foreach ($files as &$addfile)
1523 1519
 		{
1524 1520
 			// Use relative paths inside zip
1525 1521
 			$relative = substr($addfile, strlen($base_dir));
1526 1522
 
1527 1523
 			// Use safe names - replace unsafe chars, convert to ASCII (ZIP spec says CP437, but we'll try)
1528
-			$path = explode('/',$relative);
1529
-			$_name = translation::convert(translation::to_ascii(implode('/', str_replace($replace,'_',$path))),false,'ASCII');
1524
+			$path = explode('/', $relative);
1525
+			$_name = translation::convert(translation::to_ascii(implode('/', str_replace($replace, '_', $path))), false, 'ASCII');
1530 1526
 
1531 1527
 			// Don't go infinite with app entries
1532
-			if(self::is_link($addfile))
1528
+			if (self::is_link($addfile))
1533 1529
 			{
1534
-				if(in_array($addfile, $links)) continue;
1530
+				if (in_array($addfile, $links)) continue;
1535 1531
 				$links[] = $addfile;
1536 1532
 			}
1537 1533
 			// Add directory - if empty, client app might not show it though
1538
-			if(self::is_dir($addfile))
1534
+			if (self::is_dir($addfile))
1539 1535
 			{
1540 1536
 				// Zip directories
1541 1537
 				$zip->addEmptyDir($addfile);
1542 1538
 			}
1543
-			else if(self::is_readable($addfile))
1539
+			else if (self::is_readable($addfile))
1544 1540
 			{
1545 1541
 				// Copy to temp file, as ZipArchive fails to read VFS
1546 1542
 				$temp = tempnam($GLOBALS['egw_info']['server']['temp_dir'], 'zip_');
1547
-				$from = self::fopen($addfile,'r');
1548
-		 		$to = fopen($temp,'w');
1549
-				if(!stream_copy_to_stream($from,$to) || !$zip->addFile($temp, $_name))
1543
+				$from = self::fopen($addfile, 'r');
1544
+		 		$to = fopen($temp, 'w');
1545
+				if (!stream_copy_to_stream($from, $to) || !$zip->addFile($temp, $_name))
1550 1546
 				{
1551 1547
 					unlink($temp);
1552 1548
 					trigger_error("Could not add $addfile to ZIP file", E_USER_ERROR);
@@ -1557,10 +1553,10 @@  discard block
 block discarded – undo
1557 1553
 
1558 1554
 				// Add comment in
1559 1555
 				$props = self::propfind($addfile);
1560
-				if($props)
1556
+				if ($props)
1561 1557
 				{
1562
-					$comment = self::find_prop($props,'comment');
1563
-					if($comment)
1558
+					$comment = self::find_prop($props, 'comment');
1559
+					if ($comment)
1564 1560
 					{
1565 1561
 						$zip->setCommentName($_name, $comment);
1566 1562
 					}
@@ -1570,34 +1566,34 @@  discard block
 block discarded – undo
1570 1566
 		}
1571 1567
 
1572 1568
 		// Set a comment to help tell them apart
1573
-		$zip->setArchiveComment(lang('Created by %1', $GLOBALS['egw_info']['user']['account_lid']) . ' ' .egw_time::to());
1569
+		$zip->setArchiveComment(lang('Created by %1', $GLOBALS['egw_info']['user']['account_lid']).' '.egw_time::to());
1574 1570
 
1575 1571
 		// Record total for debug, not available after close()
1576 1572
 		$total_files = $zip->numFiles;
1577 1573
 
1578 1574
 		$result = $zip->close();
1579
-		if(!$result || !filesize($zip_file))
1575
+		if (!$result || !filesize($zip_file))
1580 1576
 		{
1581 1577
 			error_log('close() result: '.array2string($result));
1582 1578
 			return 'Error creating zip file';
1583 1579
 		}
1584 1580
 
1585
-		error_log("Total files: " . $total_files . " Peak memory to zip: " . self::hsize(memory_get_peak_usage(true)));
1581
+		error_log("Total files: ".$total_files." Peak memory to zip: ".self::hsize(memory_get_peak_usage(true)));
1586 1582
 
1587 1583
 		// Stop any buffering
1588
-		while(ob_get_level() > 0)
1584
+		while (ob_get_level() > 0)
1589 1585
 		{
1590 1586
 			ob_end_clean();
1591 1587
 		}
1592 1588
 
1593 1589
 		// Stream the file to the client
1594 1590
 		header("Content-Type: application/zip");
1595
-		header("Content-Length: " . filesize($zip_file));
1591
+		header("Content-Length: ".filesize($zip_file));
1596 1592
 		header("Content-Disposition: attachment; filename=\"$filename\"");
1597 1593
 		readfile($zip_file);
1598 1594
 
1599 1595
 		unlink($zip_file);
1600
-		foreach($tempfiles as $temp_file)
1596
+		foreach ($tempfiles as $temp_file)
1601 1597
 		{
1602 1598
 			unlink($temp_file);
1603 1599
 		}
@@ -1631,7 +1627,7 @@  discard block
 block discarded – undo
1631 1627
 	 * @param boolean $check_writable =true should we check if the ressource is writable, before granting locks, default yes
1632 1628
 	 * @return boolean true on success
1633 1629
 	 */
1634
-	static function lock($path,&$token,&$timeout,&$owner,&$scope,&$type,$update=false,$check_writable=true)
1630
+	static function lock($path, &$token, &$timeout, &$owner, &$scope, &$type, $update = false, $check_writable = true)
1635 1631
 	{
1636 1632
 		// we require write rights to lock/unlock a resource
1637 1633
 		if (!$path || $update && !$token || $check_writable &&
@@ -1649,28 +1645,28 @@  discard block
 block discarded – undo
1649 1645
 
1650 1646
 		if ($update)	// Lock Update
1651 1647
 		{
1652
-			if (($ret = (boolean)($row = self::$db->select(self::LOCK_TABLE,array('lock_owner','lock_exclusive','lock_write'),array(
1648
+			if (($ret = (boolean)($row = self::$db->select(self::LOCK_TABLE, array('lock_owner', 'lock_exclusive', 'lock_write'), array(
1653 1649
 				'lock_path' => $path,
1654 1650
 				'lock_token' => $token,
1655
-			),__LINE__,__FILE__)->fetch())))
1651
+			), __LINE__, __FILE__)->fetch())))
1656 1652
 			{
1657 1653
 				$owner = $row['lock_owner'];
1658 1654
 				$scope = egw_db::from_bool($row['lock_exclusive']) ? 'exclusive' : 'shared';
1659 1655
 				$type  = egw_db::from_bool($row['lock_write']) ? 'write' : 'read';
1660 1656
 
1661
-				self::$db->update(self::LOCK_TABLE,array(
1657
+				self::$db->update(self::LOCK_TABLE, array(
1662 1658
 					'lock_expires' => $timeout,
1663 1659
 					'lock_modified' => time(),
1664
-				),array(
1660
+				), array(
1665 1661
 					'lock_path' => $path,
1666 1662
 					'lock_token' => $token,
1667
-				),__LINE__,__FILE__);
1663
+				), __LINE__, __FILE__);
1668 1664
 			}
1669 1665
 		}
1670 1666
 		// HTTP_WebDAV_Server does this check before calling LOCK, but we want to be complete and usable outside WebDAV
1671
-		elseif(($lock = self::checkLock($path)) && ($lock['scope'] == 'exclusive' || $scope == 'exclusive'))
1667
+		elseif (($lock = self::checkLock($path)) && ($lock['scope'] == 'exclusive' || $scope == 'exclusive'))
1672 1668
 		{
1673
-			$ret = false;	// there's alread a lock
1669
+			$ret = false; // there's alread a lock
1674 1670
 		}
1675 1671
 		else
1676 1672
 		{
@@ -1689,7 +1685,7 @@  discard block
 block discarded – undo
1689 1685
 				$token = HTTP_WebDAV_Server::_new_locktoken();
1690 1686
 			}
1691 1687
 			try {
1692
-				self::$db->insert(self::LOCK_TABLE,array(
1688
+				self::$db->insert(self::LOCK_TABLE, array(
1693 1689
 					'lock_token' => $token,
1694 1690
 					'lock_path'  => $path,
1695 1691
 					'lock_created' => time(),
@@ -1698,12 +1694,12 @@  discard block
 block discarded – undo
1698 1694
 					'lock_expires' => $timeout,
1699 1695
 					'lock_exclusive' => $scope == 'exclusive',
1700 1696
 					'lock_write' => $type == 'write',
1701
-				),false,__LINE__,__FILE__);
1697
+				), false, __LINE__, __FILE__);
1702 1698
 				$ret = true;
1703 1699
 			}
1704
-			catch(egw_exception_db $e) {
1700
+			catch (egw_exception_db $e) {
1705 1701
 				unset($e);
1706
-				$ret = false;	// there's already a lock
1702
+				$ret = false; // there's already a lock
1707 1703
 			}
1708 1704
 		}
1709 1705
 		if (self::LOCK_DEBUG) error_log(__METHOD__."($path,$token,$timeout,$owner,$scope,$type,update=$update,check_writable=$check_writable) returns ".($ret ? 'true' : 'false'));
@@ -1718,17 +1714,17 @@  discard block
 block discarded – undo
1718 1714
 	 * @param boolean $check_writable =true should we check if the ressource is writable, before granting locks, default yes
1719 1715
      * @return boolean true on success
1720 1716
      */
1721
-    static function unlock($path,$token,$check_writable=true)
1717
+    static function unlock($path, $token, $check_writable = true)
1722 1718
     {
1723 1719
 		// we require write rights to lock/unlock a resource
1724 1720
 		if ($check_writable && !self::is_writable($path))
1725 1721
 		{
1726 1722
 			return false;
1727 1723
 		}
1728
-        if (($ret = self::$db->delete(self::LOCK_TABLE,array(
1724
+        if (($ret = self::$db->delete(self::LOCK_TABLE, array(
1729 1725
         	'lock_path' => $path,
1730 1726
         	'lock_token' => $token,
1731
-        ),__LINE__,__FILE__) && self::$db->affected_rows()))
1727
+        ), __LINE__, __FILE__) && self::$db->affected_rows()))
1732 1728
         {
1733 1729
         	// remove the lock from the cache too
1734 1730
         	unset(self::$lock_cache[$path]);
@@ -1747,31 +1743,31 @@  discard block
 block discarded – undo
1747 1743
 	{
1748 1744
 		if (isset(self::$lock_cache[$path]))
1749 1745
 		{
1750
-			if (self::LOCK_DEBUG) error_log(__METHOD__."($path) returns from CACHE ".str_replace(array("\n",'    '),'',print_r(self::$lock_cache[$path],true)));
1746
+			if (self::LOCK_DEBUG) error_log(__METHOD__."($path) returns from CACHE ".str_replace(array("\n", '    '), '', print_r(self::$lock_cache[$path], true)));
1751 1747
 			return self::$lock_cache[$path];
1752 1748
 		}
1753 1749
 		$where = 'lock_path='.self::$db->quote($path);
1754 1750
 		// ToDo: additional check parent dirs for locks and children of the requested directory
1755 1751
 		//$where .= ' OR '.self::$db->quote($path).' LIKE '.self::$db->concat('lock_path',"'%'").' OR lock_path LIKE '.self::$db->quote($path.'%');
1756 1752
 		// ToDo: shared locks can return multiple rows
1757
-		if (($result = self::$db->select(self::LOCK_TABLE,'*',$where,__LINE__,__FILE__)->fetch()))
1753
+		if (($result = self::$db->select(self::LOCK_TABLE, '*', $where, __LINE__, __FILE__)->fetch()))
1758 1754
 		{
1759
-			$result = egw_db::strip_array_keys($result,'lock_');
1755
+			$result = egw_db::strip_array_keys($result, 'lock_');
1760 1756
 			$result['type']  = egw_db::from_bool($result['write']) ? 'write' : 'read';
1761 1757
 			$result['scope'] = egw_db::from_bool($result['exclusive']) ? 'exclusive' : 'shared';
1762 1758
 			$result['depth'] = egw_db::from_bool($result['recursive']) ? 'infinite' : 0;
1763 1759
 		}
1764 1760
 		if ($result && $result['expires'] < time())	// lock is expired --> remove it
1765 1761
 		{
1766
-	        self::$db->delete(self::LOCK_TABLE,array(
1762
+	        self::$db->delete(self::LOCK_TABLE, array(
1767 1763
 	        	'lock_path' => $result['path'],
1768 1764
 	        	'lock_token' => $result['token'],
1769
-	        ),__LINE__,__FILE__);
1765
+	        ), __LINE__, __FILE__);
1770 1766
 
1771
-			if (self::LOCK_DEBUG) error_log(__METHOD__."($path) lock is expired at ".date('Y-m-d H:i:s',$result['expires'])." --> removed");
1767
+			if (self::LOCK_DEBUG) error_log(__METHOD__."($path) lock is expired at ".date('Y-m-d H:i:s', $result['expires'])." --> removed");
1772 1768
 	        $result = false;
1773 1769
 		}
1774
-		if (self::LOCK_DEBUG) error_log(__METHOD__."($path) returns ".($result?array2string($result):'false'));
1770
+		if (self::LOCK_DEBUG) error_log(__METHOD__."($path) returns ".($result ? array2string($result) : 'false'));
1775 1771
 		return self::$lock_cache[$path] = $result;
1776 1772
 	}
1777 1773
 
@@ -1782,10 +1778,10 @@  discard block
 block discarded – undo
1782 1778
 	 * @param array $content =null
1783 1779
 	 * @return array|boolean array with values for keys 'data','etemplate','name','label','help' or false if not supported by backend
1784 1780
 	 */
1785
-	static function getExtraInfo($path,array $content=null)
1781
+	static function getExtraInfo($path, array $content = null)
1786 1782
 	{
1787 1783
 		$extra = array();
1788
-		if (($extra_info = self::_call_on_backend('extra_info',array($path,$content),true)))	// true = fail silent if backend does NOT support it
1784
+		if (($extra_info = self::_call_on_backend('extra_info', array($path, $content), true)))	// true = fail silent if backend does NOT support it
1789 1785
 		{
1790 1786
 			$extra[] = $extra_info;
1791 1787
 		}
@@ -1796,7 +1792,7 @@  discard block
 block discarded – undo
1796 1792
 			'content' => $content,
1797 1793
 		))))
1798 1794
 		{
1799
-			foreach($vfs_extra as $data)
1795
+			foreach ($vfs_extra as $data)
1800 1796
 			{
1801 1797
 				$extra = $extra ? array_merge($extra, $data) : $data;
1802 1798
 			}
@@ -1811,7 +1807,7 @@  discard block
 block discarded – undo
1811 1807
 	 * @param int|string $id
1812 1808
 	 * @return string
1813 1809
 	 */
1814
-	static function app_entry_lock_path($app,$id)
1810
+	static function app_entry_lock_path($app, $id)
1815 1811
 	{
1816 1812
 		return "/apps/$app/entry/$id";
1817 1813
 	}
@@ -1825,7 +1821,7 @@  discard block
 block discarded – undo
1825 1821
 		//'%' => '%25',	// % should be encoded, but easily leads to double encoding, therefore better NOT encodig it
1826 1822
 		'#' => '%23',
1827 1823
 		'?' => '%3F',
1828
-		'/' => '',	// better remove it completly
1824
+		'/' => '', // better remove it completly
1829 1825
 	);
1830 1826
 
1831 1827
 	/**
@@ -1840,7 +1836,7 @@  discard block
 block discarded – undo
1840 1836
 	 */
1841 1837
 	static public function encodePathComponent($component)
1842 1838
 	{
1843
-		return str_replace(array_keys(self::$encode),array_values(self::$encode),$component);
1839
+		return str_replace(array_keys(self::$encode), array_values(self::$encode), $component);
1844 1840
 	}
1845 1841
 
1846 1842
 	/**
@@ -1853,7 +1849,7 @@  discard block
 block discarded – undo
1853 1849
 	 */
1854 1850
 	static public function encodePath($path)
1855 1851
 	{
1856
-		return implode('/',self::encodePathComponent(explode('/',$path)));
1852
+		return implode('/', self::encodePathComponent(explode('/', $path)));
1857 1853
 	}
1858 1854
 
1859 1855
 	/**
@@ -1908,7 +1904,7 @@  discard block
 block discarded – undo
1908 1904
 		{
1909 1905
 			$image = common::image($mime_sub, 'navbar');
1910 1906
 		}
1911
-		else if ($file && $mime_main == 'image' && in_array($mime_sub, array('png','jpeg','jpg','gif','bmp')) &&
1907
+		else if ($file && $mime_main == 'image' && in_array($mime_sub, array('png', 'jpeg', 'jpg', 'gif', 'bmp')) &&
1912 1908
 		         (string)$GLOBALS['egw_info']['server']['link_list_thumbnail'] != '0' &&
1913 1909
 		         (string)$GLOBALS['egw_info']['user']['preferences']['common']['link_list_thumbnail'] != '0' &&
1914 1910
 		         ($stat = self::stat($file)) && $stat['size'] < 1500000)
@@ -1963,7 +1959,7 @@  discard block
 block discarded – undo
1963 1959
 	 * @param array& $copied =null on return files copied
1964 1960
 	 * @return boolean true for no errors, false otherwise
1965 1961
 	 */
1966
-	static public function copy_files(array $src, $dst, &$errs=null, array &$copied=null)
1962
+	static public function copy_files(array $src, $dst, &$errs = null, array &$copied = null)
1967 1963
 	{
1968 1964
 		if (self::is_dir($dst))
1969 1965
 		{
@@ -1981,7 +1977,7 @@  discard block
 block discarded – undo
1981 1977
 						if ($file !== $target)
1982 1978
 						{
1983 1979
 							// Create the target directory
1984
-							self::mkdir($target,null,STREAM_MKDIR_RECURSIVE);
1980
+							self::mkdir($target, null, STREAM_MKDIR_RECURSIVE);
1985 1981
 
1986 1982
 							$copied[] = $file;
1987 1983
 							$copied[] = $target; // < newly created folder must not be copied again!
@@ -2024,7 +2020,7 @@  discard block
 block discarded – undo
2024 2020
 	{
2025 2021
 		if (self::is_dir($dst))
2026 2022
 		{
2027
-			foreach($src as $file)
2023
+			foreach ($src as $file)
2028 2024
 			{
2029 2025
 				$target = self::concat($dst, self::basename($file));
2030 2026
 
@@ -2056,7 +2052,7 @@  discard block
 block discarded – undo
2056 2052
 	 * @param boolean $check_is_uploaded_file =true should method perform an is_uploaded_file check, default yes
2057 2053
 	 * @return boolean|array stat array on success, false on error
2058 2054
 	 */
2059
-	static public function copy_uploaded($src,$target,$props=null,$check_is_uploaded_file=true)
2055
+	static public function copy_uploaded($src, $target, $props = null, $check_is_uploaded_file = true)
2060 2056
 	{
2061 2057
 		$tmp_name = is_array($src) ? $src['tmp_name'] : $src;
2062 2058
 
@@ -2076,12 +2072,12 @@  discard block
 block discarded – undo
2076 2072
 		}
2077 2073
 		if ($props)
2078 2074
 		{
2079
-			if (!is_array($props)) $props = array(array('name' => 'comment','val' => $props));
2075
+			if (!is_array($props)) $props = array(array('name' => 'comment', 'val' => $props));
2080 2076
 
2081 2077
 			// if $props is name => value pairs, convert it to internal array or array with values for keys 'name', 'val' and optional 'ns'
2082 2078
 			if (!isset($props[0]))
2083 2079
 			{
2084
-				foreach($props as $name => $val)
2080
+				foreach ($props as $name => $val)
2085 2081
 				{
2086 2082
 					if (($name == 'comment' || $name[0] == '#') && $val)	// only copy 'comment' and cfs
2087 2083
 					{
@@ -2099,8 +2095,8 @@  discard block
 block discarded – undo
2099 2095
 			// set props before copying the file, so notifications already contain them
2100 2096
 			if (!self::stat($target))
2101 2097
 			{
2102
-				self::touch($target);	// create empty file, to be able to attach properties
2103
-				self::$treat_as_new = true;	// notify as new
2098
+				self::touch($target); // create empty file, to be able to attach properties
2099
+				self::$treat_as_new = true; // notify as new
2104 2100
 			}
2105 2101
 			self::proppatch($target, $props);
2106 2102
 		}
@@ -2114,7 +2110,7 @@  discard block
 block discarded – undo
2114 2110
 		}
2115 2111
 		else
2116 2112
 		{
2117
-			$ret = copy($tmp_name,self::PREFIX.$target) ? self::stat($target) : false;
2113
+			$ret = copy($tmp_name, self::PREFIX.$target) ? self::stat($target) : false;
2118 2114
 		}
2119 2115
 		if (self::LOG_LEVEL > 1 || !$ret && self::LOG_LEVEL) error_log(__METHOD__."($tmp_name, $target, ".array2string($props).") returning ".array2string($ret));
2120 2116
 		return $ret;
Please login to merge, or discard this patch.
api/src/Vfs/Sqlfs/StreamWrapper.php 4 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -447,10 +447,10 @@  discard block
 block discarded – undo
447 447
  	 * Important: PHP 5.0 introduced a bug that wasn't fixed until 5.1: the return value has to be the oposite!
448 448
  	 *
449 449
  	 * if(version_compare(PHP_VERSION,'5.0','>=') && version_compare(PHP_VERSION,'5.1','<'))
450
-  	 * {
450
+ 	 * {
451 451
  	 * 		$eof = !$eof;
452 452
  	 * }
453
-  	 *
453
+ 	 *
454 454
  	 * @return boolean true if the read/write position is at the end of the stream and no more data availible, false otherwise
455 455
  	 */
456 456
 	function stream_eof ( )
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
  	 * See fseek() for more information about these parameters.
486 486
  	 *
487 487
  	 * @param integer $offset
488
-  	 * @param integer $whence	SEEK_SET - 0 - Set position equal to offset bytes
488
+ 	 * @param integer $whence	SEEK_SET - 0 - Set position equal to offset bytes
489 489
  	 * 							SEEK_CUR - 1 - Set position to current location plus offset.
490 490
  	 * 							SEEK_END - 2 - Set position to end-of-file plus offset. (To move to a position before the end-of-file, you need to pass a negative value in offset.)
491 491
  	 * @return boolean TRUE if the position was updated, FALSE otherwise.
@@ -681,8 +681,8 @@  discard block
 block discarded – undo
681 681
 		$maxdepth=10;
682 682
 		$depth2propagate = (int)$depth + 1;
683 683
 		if ($depth2propagate > $maxdepth) return is_dir($pathname);
684
-    	is_dir(Vfs::dirname($pathname)) || self::mkdir_recursive(Vfs::dirname($pathname), $mode, $depth2propagate);
685
-    	return is_dir($pathname) || @mkdir($pathname, $mode);
684
+		is_dir(Vfs::dirname($pathname)) || self::mkdir_recursive(Vfs::dirname($pathname), $mode, $depth2propagate);
685
+		return is_dir($pathname) || @mkdir($pathname, $mode);
686 686
 	}
687 687
 
688 688
 	/**
Please login to merge, or discard this patch.
Doc Comments   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -515,7 +515,7 @@  discard block
 block discarded – undo
515 515
 	 *
516 516
 	 * If you have cached data in your stream but not yet stored it into the underlying storage, you should do so now.
517 517
 	 *
518
-	 * @return booelan TRUE if the cached data was successfully stored (or if there was no data to store), or FALSE if the data could not be stored.
518
+	 * @return boolean TRUE if the cached data was successfully stored (or if there was no data to store), or FALSE if the data could not be stored.
519 519
 	 */
520 520
 	function stream_flush ( )
521 521
 	{
@@ -556,6 +556,7 @@  discard block
 block discarded – undo
556 556
 	 * In order for the appropriate error message to be returned, do not define this method if your wrapper does not support unlinking!
557 557
 	 *
558 558
 	 * @param string $url
559
+	 * @param integer $parent_stat
559 560
 	 * @return boolean TRUE on success or FALSE on failure
560 561
 	 */
561 562
 	static function unlink ( $url, $parent_stat=null )
@@ -684,6 +685,8 @@  discard block
 block discarded – undo
684 685
 
685 686
 	/**
686 687
 	 * due to problems with recursive directory creation, we have our own here
688
+	 * @param false|string $pathname
689
+	 * @param integer $mode
687 690
 	 */
688 691
 	protected static function mkdir_recursive($pathname, $mode, $depth=0)
689 692
 	{
@@ -1014,7 +1017,7 @@  discard block
 block discarded – undo
1014 1017
 	 *
1015 1018
 	 * @param string $url URL that was passed to opendir() and that this object is expected to explore.
1016 1019
 	 * @param int $options
1017
-	 * @return booelan
1020
+	 * @return boolean
1018 1021
 	 */
1019 1022
 	function dir_opendir ( $url, $options )
1020 1023
 	{
@@ -1717,7 +1720,7 @@  discard block
 block discarded – undo
1717 1720
 	/**
1718 1721
 	 * Just a little abstration 'til I know how to organise stuff like that with PDO
1719 1722
 	 *
1720
-	 * @param mixed $time
1723
+	 * @param integer $time
1721 1724
 	 * @return string Y-m-d H:i:s
1722 1725
 	 */
1723 1726
 	static protected function _pdo_timestamp($time)
@@ -1802,6 +1805,7 @@  discard block
 block discarded – undo
1802 1805
 	 * Replace the password of an url with '...' for error messages
1803 1806
 	 *
1804 1807
 	 * @param string &$url
1808
+	 * @param string $url
1805 1809
 	 */
1806 1810
 	static protected function _remove_password(&$url)
1807 1811
 	{
@@ -1817,7 +1821,7 @@  discard block
 block discarded – undo
1817 1821
 	/**
1818 1822
 	 * Get storage mode from url (get parameter 'storage', eg. ?storage=db)
1819 1823
 	 *
1820
-	 * @param string|array $url complete url or array of url-parts from parse_url
1824
+	 * @param string $url complete url or array of url-parts from parse_url
1821 1825
 	 * @return int self::STORE2FS or self::STORE2DB
1822 1826
 	 */
1823 1827
 	static function url2operation($url)
Please login to merge, or discard this patch.
Spacing   +234 added lines, -236 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 	/**
77 77
 	 * mode-bits, which have to be set for directories
78 78
 	 */
79
-	const MODE_DIR =   040000;
79
+	const MODE_DIR = 040000;
80 80
 	/**
81 81
 	 * mode-bits, which have to be set for links
82 82
 	 */
@@ -179,10 +179,10 @@  discard block
 block discarded – undo
179 179
 	 *
180 180
 	 * @param string $path ='/'
181 181
 	 */
182
-	public static function clearstatcache($path='/')
182
+	public static function clearstatcache($path = '/')
183 183
 	{
184 184
 		//error_log(__METHOD__."('$path')");
185
-		unset($path);	// not used
185
+		unset($path); // not used
186 186
 
187 187
 		self::$stat_cache = array();
188 188
 
@@ -202,32 +202,32 @@  discard block
 block discarded – undo
202 202
 	 * @param array $overwrite_new =null if set create new file with values overwriten by the given ones
203 203
 	 * @return boolean true if the ressource was opened successful, otherwise false
204 204
 	 */
205
-	function stream_open ( $url, $mode, $options, &$opened_path, array $overwrite_new=null )
205
+	function stream_open($url, $mode, $options, &$opened_path, array $overwrite_new = null)
206 206
 	{
207 207
 		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$mode,$options)");
208 208
 
209
-		$path = Vfs::parse_url($url,PHP_URL_PATH);
209
+		$path = Vfs::parse_url($url, PHP_URL_PATH);
210 210
 		$this->operation = self::url2operation($url);
211 211
 		$dir = Vfs::dirname($url);
212 212
 
213 213
 		$this->opened_path = $opened_path = $path;
214
-		$this->opened_mode = $mode = str_replace('b','',$mode);	// we are always binary, like every Linux system
214
+		$this->opened_mode = $mode = str_replace('b', '', $mode); // we are always binary, like every Linux system
215 215
 		$this->opened_stream = null;
216 216
 
217 217
 		parse_str(parse_url($url, PHP_URL_QUERY), $this->dir_url_params);
218 218
 
219
-		if (!is_null($overwrite_new) || !($stat = static::url_stat($path,STREAM_URL_STAT_QUIET)) || $mode[0] == 'x')	// file not found or file should NOT exist
219
+		if (!is_null($overwrite_new) || !($stat = static::url_stat($path, STREAM_URL_STAT_QUIET)) || $mode[0] == 'x')	// file not found or file should NOT exist
220 220
 		{
221
-			if ($mode[0] == 'r' ||	// does $mode require the file to exist (r,r+)
222
-				$mode[0] == 'x' && $stat ||	// or file should not exist, but does
223
-				!($dir_stat=static::url_stat($dir,STREAM_URL_STAT_QUIET)) ||	// or parent dir does not exist																																			create it
224
-				!Vfs::check_access($dir,Vfs::WRITABLE,$dir_stat))	// or we are not allowed to 																																			create it
221
+			if ($mode[0] == 'r' || // does $mode require the file to exist (r,r+)
222
+				$mode[0] == 'x' && $stat || // or file should not exist, but does
223
+				!($dir_stat = static::url_stat($dir, STREAM_URL_STAT_QUIET)) || // or parent dir does not exist																																			create it
224
+				!Vfs::check_access($dir, Vfs::WRITABLE, $dir_stat))	// or we are not allowed to 																																			create it
225 225
 			{
226 226
 				self::_remove_password($url);
227 227
 				if (self::LOG_LEVEL) error_log(__METHOD__."($url,$mode,$options) file does not exist or can not be created!");
228
-				if (($options & STREAM_REPORT_ERRORS))
228
+				if (($options&STREAM_REPORT_ERRORS))
229 229
 				{
230
-					trigger_error(__METHOD__."($url,$mode,$options) file does not exist or can not be created!",E_USER_WARNING);
230
+					trigger_error(__METHOD__."($url,$mode,$options) file does not exist or can not be created!", E_USER_WARNING);
231 231
 				}
232 232
 				$this->opened_stream = $this->opened_path = $this->opened_mode = null;
233 233
 				return false;
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 				'fs_name' => self::limit_filename(Vfs::basename($path)),
243 243
 				'fs_dir'  => $dir_stat['ino'],
244 244
 				// we use the mode of the dir, so files in group dirs stay accessible by all members
245
-				'fs_mode' => $dir_stat['mode'] & 0666,
245
+				'fs_mode' => $dir_stat['mode']&0666,
246 246
 				// for the uid we use the uid of the dir if not 0=root or the current user otherwise
247 247
 				'fs_uid'  => $dir_stat['uid'] ? $dir_stat['uid'] : Vfs::$user,
248 248
 				// we allways use the group of the dir
@@ -250,11 +250,11 @@  discard block
 block discarded – undo
250 250
 				'fs_created'  => self::_pdo_timestamp(time()),
251 251
 				'fs_modified' => self::_pdo_timestamp(time()),
252 252
 				'fs_creator'  => Vfs::$user,
253
-				'fs_mime'     => 'application/octet-stream',	// required NOT NULL!
253
+				'fs_mime'     => 'application/octet-stream', // required NOT NULL!
254 254
 				'fs_size'     => 0,
255 255
 				'fs_active'   => self::_pdo_boolean(true),
256 256
 			);
257
-			if ($overwrite_new) $values = array_merge($values,$overwrite_new);
257
+			if ($overwrite_new) $values = array_merge($values, $overwrite_new);
258 258
 			if (!$stmt->execute($values) || !($this->opened_fs_id = self::$pdo->lastInsertId('egw_sqlfs_fs_id_seq')))
259 259
 			{
260 260
 				$this->opened_stream = $this->opened_path = $this->opened_mode = null;
@@ -267,35 +267,35 @@  discard block
 block discarded – undo
267 267
 				$this->opened_stream = tmpfile();
268 268
 			}
269 269
 			// create the hash-dirs, if they not yet exist
270
-			elseif(!file_exists($fs_dir=Vfs::dirname(self::_fs_path($this->opened_fs_id))))
270
+			elseif (!file_exists($fs_dir = Vfs::dirname(self::_fs_path($this->opened_fs_id))))
271 271
 			{
272 272
 				$umaskbefore = umask();
273 273
 				if (self::LOG_LEVEL > 1) error_log(__METHOD__." about to call mkdir for $fs_dir # Present UMASK:".decoct($umaskbefore)." called from:".function_backtrace());
274
-				self::mkdir_recursive($fs_dir,0700,true);
274
+				self::mkdir_recursive($fs_dir, 0700, true);
275 275
 			}
276 276
 		}
277 277
 		// check if opend file is a directory
278
-		elseif($stat && ($stat['mode'] & self::MODE_DIR) == self::MODE_DIR)
278
+		elseif ($stat && ($stat['mode']&self::MODE_DIR) == self::MODE_DIR)
279 279
 		{
280 280
 				if (self::LOG_LEVEL) error_log(__METHOD__."($url,$mode,$options) Is a directory!");
281
-				if (($options & STREAM_REPORT_ERRORS))
281
+				if (($options&STREAM_REPORT_ERRORS))
282 282
 				{
283
-					trigger_error(__METHOD__."($url,$mode,$options) Is a directory!",E_USER_WARNING);
283
+					trigger_error(__METHOD__."($url,$mode,$options) Is a directory!", E_USER_WARNING);
284 284
 				}
285 285
 				$this->opened_stream = $this->opened_path = $this->opened_mode = null;
286 286
 				return false;
287 287
 		}
288 288
 		else
289 289
 		{
290
-			if ($mode == 'r' && !Vfs::check_access($url,Vfs::READABLE ,$stat) ||// we are not allowed to read
291
-				$mode != 'r' && !Vfs::check_access($url,Vfs::WRITABLE,$stat))	// or edit it
290
+			if ($mode == 'r' && !Vfs::check_access($url, Vfs::READABLE, $stat) || // we are not allowed to read
291
+				$mode != 'r' && !Vfs::check_access($url, Vfs::WRITABLE, $stat))	// or edit it
292 292
 			{
293 293
 				self::_remove_password($url);
294 294
 				$op = $mode == 'r' ? 'read' : 'edited';
295 295
 				if (self::LOG_LEVEL) error_log(__METHOD__."($url,$mode,$options) file can not be $op!");
296
-				if (($options & STREAM_REPORT_ERRORS))
296
+				if (($options&STREAM_REPORT_ERRORS))
297 297
 				{
298
-					trigger_error(__METHOD__."($url,$mode,$options) file can not be $op!",E_USER_WARNING);
298
+					trigger_error(__METHOD__."($url,$mode,$options) file can not be $op!", E_USER_WARNING);
299 299
 				}
300 300
 				$this->opened_stream = $this->opened_path = $this->opened_mode = null;
301 301
 				return false;
@@ -304,9 +304,9 @@  discard block
 block discarded – undo
304 304
 
305 305
 			if ($this->operation == self::STORE2DB)
306 306
 			{
307
-				$stmt = self::$pdo->prepare($sql='SELECT fs_content FROM '.self::TABLE.' WHERE fs_id=?');
307
+				$stmt = self::$pdo->prepare($sql = 'SELECT fs_content FROM '.self::TABLE.' WHERE fs_id=?');
308 308
 				$stmt->execute(array($stat['ino']));
309
-				$stmt->bindColumn(1,$this->opened_stream,\PDO::PARAM_LOB);
309
+				$stmt->bindColumn(1, $this->opened_stream, \PDO::PARAM_LOB);
310 310
 				$stmt->fetch(\PDO::FETCH_BOUND);
311 311
 				// hack to work around a current php bug (http://bugs.php.net/bug.php?id=40913)
312 312
 				// PDOStatement::bindColumn(,,\PDO::PARAM_LOB) is not working for MySQL, content is returned as string :-(
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
 		if ($this->operation == self::STORE2FS)
326 326
 		{
327 327
 			if (self::LOG_LEVEL > 1) error_log(__METHOD__." fopen (may create a directory? mkdir) ($this->opened_fs_id,$mode,$options)");
328
-			if (!($this->opened_stream = fopen(self::_fs_path($this->opened_fs_id),$mode)) && $new_file)
328
+			if (!($this->opened_stream = fopen(self::_fs_path($this->opened_fs_id), $mode)) && $new_file)
329 329
 			{
330 330
 				// delete db entry again, if we are not able to open a new(!) file
331 331
 				unset($stmt);
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
 		}
336 336
 		if ($mode[0] == 'a')	// append modes: a, a+
337 337
 		{
338
-			$this->stream_seek(0,SEEK_END);
338
+			$this->stream_seek(0, SEEK_END);
339 339
 		}
340 340
 		if (!is_resource($this->opened_stream)) error_log(__METHOD__."($url,$mode,$options) NO stream, returning false!");
341 341
 
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
 	 *
348 348
 	 * You must release any resources that were locked or allocated by the stream.
349 349
 	 */
350
-	function stream_close ( )
350
+	function stream_close( )
351 351
 	{
352 352
 		if (self::LOG_LEVEL > 1) error_log(__METHOD__."()");
353 353
 
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
 
359 359
 		if ($this->opened_mode != 'r')
360 360
 		{
361
-			$this->stream_seek(0,SEEK_END);
361
+			$this->stream_seek(0, SEEK_END);
362 362
 
363 363
 			// we need to update the mime-type, size and content (if STORE2DB)
364 364
 			$values = array(
@@ -381,10 +381,10 @@  discard block
 block discarded – undo
381 381
 			else
382 382
 			{
383 383
 				$stmt = self::$pdo->prepare('UPDATE '.self::TABLE.' SET fs_size=:fs_size,fs_mime=:fs_mime,fs_modifier=:fs_modifier,fs_modified=:fs_modified,fs_content=:fs_content WHERE fs_id=:fs_id');
384
-				$this->stream_seek(0,SEEK_SET);	// rewind to the start
385
-				foreach($values as $name => &$value)
384
+				$this->stream_seek(0, SEEK_SET); // rewind to the start
385
+				foreach ($values as $name => &$value)
386 386
 				{
387
-					$stmt->bindParam($name,$value);
387
+					$stmt->bindParam($name, $value);
388 388
 				}
389 389
 				$stmt->bindParam('fs_content', $this->opened_stream, \PDO::PARAM_LOB);
390 390
 				if (!($ret = $stmt->execute()))
@@ -417,13 +417,13 @@  discard block
 block discarded – undo
417 417
 	 * @param int $count
418 418
 	 * @return string/false up to count bytes read or false on EOF
419 419
 	 */
420
-	function stream_read ( $count )
420
+	function stream_read($count)
421 421
 	{
422 422
 		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($count) pos=$this->opened_pos");
423 423
 
424 424
 		if (is_resource($this->opened_stream))
425 425
 		{
426
-			return fread($this->opened_stream,$count);
426
+			return fread($this->opened_stream, $count);
427 427
 		}
428 428
 		return false;
429 429
 	}
@@ -439,13 +439,13 @@  discard block
 block discarded – undo
439 439
 	 * @param string $data
440 440
 	 * @return integer
441 441
 	 */
442
-	function stream_write ( $data )
442
+	function stream_write($data)
443 443
 	{
444 444
 		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($data)");
445 445
 
446 446
 		if (is_resource($this->opened_stream))
447 447
 		{
448
-			return fwrite($this->opened_stream,$data);
448
+			return fwrite($this->opened_stream, $data);
449 449
 		}
450 450
 		return false;
451 451
 	}
@@ -462,7 +462,7 @@  discard block
 block discarded – undo
462 462
   	 *
463 463
  	 * @return boolean true if the read/write position is at the end of the stream and no more data availible, false otherwise
464 464
  	 */
465
-	function stream_eof ( )
465
+	function stream_eof( )
466 466
 	{
467 467
 		if (is_resource($this->opened_stream))
468 468
 		{
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
 	 *
477 477
 	 * @return integer current read/write position of the stream
478 478
 	 */
479
- 	function stream_tell ( )
479
+ 	function stream_tell( )
480 480
  	{
481 481
 		if (self::LOG_LEVEL > 1) error_log(__METHOD__."()");
482 482
 
@@ -499,13 +499,13 @@  discard block
 block discarded – undo
499 499
  	 * 							SEEK_END - 2 - Set position to end-of-file plus offset. (To move to a position before the end-of-file, you need to pass a negative value in offset.)
500 500
  	 * @return boolean TRUE if the position was updated, FALSE otherwise.
501 501
  	 */
502
-	function stream_seek ( $offset, $whence )
502
+	function stream_seek($offset, $whence)
503 503
 	{
504 504
 		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($offset,$whence)");
505 505
 
506 506
 		if (is_resource($this->opened_stream))
507 507
 		{
508
-			return !fseek($this->opened_stream,$offset,$whence);	// fseek returns 0 on success and -1 on failure
508
+			return !fseek($this->opened_stream, $offset, $whence); // fseek returns 0 on success and -1 on failure
509 509
 		}
510 510
 		return false;
511 511
 	}
@@ -517,7 +517,7 @@  discard block
 block discarded – undo
517 517
 	 *
518 518
 	 * @return booelan TRUE if the cached data was successfully stored (or if there was no data to store), or FALSE if the data could not be stored.
519 519
 	 */
520
-	function stream_flush ( )
520
+	function stream_flush( )
521 521
 	{
522 522
 		if (self::LOG_LEVEL > 1) error_log(__METHOD__."()");
523 523
 
@@ -542,11 +542,11 @@  discard block
 block discarded – undo
542 542
 	 *
543 543
 	 * @return array containing the same values as appropriate for the stream.
544 544
 	 */
545
-	function stream_stat ( )
545
+	function stream_stat( )
546 546
 	{
547 547
 		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($this->opened_path)");
548 548
 
549
-		return $this->url_stat($this->opened_path,0);
549
+		return $this->url_stat($this->opened_path, 0);
550 550
 	}
551 551
 
552 552
 	/**
@@ -558,27 +558,27 @@  discard block
 block discarded – undo
558 558
 	 * @param string $url
559 559
 	 * @return boolean TRUE on success or FALSE on failure
560 560
 	 */
561
-	static function unlink ( $url, $parent_stat=null )
561
+	static function unlink($url, $parent_stat = null)
562 562
 	{
563 563
 		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url)");
564 564
 
565
-		$path = Vfs::parse_url($url,PHP_URL_PATH);
565
+		$path = Vfs::parse_url($url, PHP_URL_PATH);
566 566
 
567 567
 		// need to get parent stat from Sqlfs, not Vfs
568 568
 		if (!isset($parent_stat)) $parent_stat = static::url_stat(Vfs::dirname($path), STREAM_URL_STAT_LINK);
569 569
 
570
-		if (!$parent_stat || !($stat = self::url_stat($path,STREAM_URL_STAT_LINK)) ||
571
-			!Vfs::check_access(Vfs::dirname($path),Vfs::WRITABLE, $parent_stat))
570
+		if (!$parent_stat || !($stat = self::url_stat($path, STREAM_URL_STAT_LINK)) ||
571
+			!Vfs::check_access(Vfs::dirname($path), Vfs::WRITABLE, $parent_stat))
572 572
 		{
573 573
 			self::_remove_password($url);
574 574
 			if (self::LOG_LEVEL) error_log(__METHOD__."($url) permission denied!");
575
-			return false;	// no permission or file does not exist
575
+			return false; // no permission or file does not exist
576 576
 		}
577 577
 		if ($stat['mime'] == self::DIR_MIME_TYPE)
578 578
 		{
579 579
 			self::_remove_password($url);
580 580
 			if (self::LOG_LEVEL) error_log(__METHOD__."($url) is NO file!");
581
-			return false;	// no permission or file does not exist
581
+			return false; // no permission or file does not exist
582 582
 		}
583 583
 		$stmt = self::$pdo->prepare('DELETE FROM '.self::TABLE.' WHERE fs_id=:fs_id');
584 584
 		unset(self::$stat_cache[$path]);
@@ -586,7 +586,7 @@  discard block
 block discarded – undo
586 586
 		if (($ret = $stmt->execute(array('fs_id' => $stat['ino']))))
587 587
 		{
588 588
 			if (self::url2operation($url) == self::STORE2FS &&
589
-				($stat['mode'] & self::MODE_LINK) != self::MODE_LINK)
589
+				($stat['mode']&self::MODE_LINK) != self::MODE_LINK)
590 590
 			{
591 591
 				unlink(self::_fs_path($stat['ino']));
592 592
 			}
@@ -610,13 +610,13 @@  discard block
 block discarded – undo
610 610
 	 * @param string $url_to
611 611
 	 * @return boolean TRUE on success or FALSE on failure
612 612
 	 */
613
-	static function rename ( $url_from, $url_to)
613
+	static function rename($url_from, $url_to)
614 614
 	{
615 615
 		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url_from,$url_to)");
616 616
 
617
-		$path_from = Vfs::parse_url($url_from,PHP_URL_PATH);
617
+		$path_from = Vfs::parse_url($url_from, PHP_URL_PATH);
618 618
 		$from_dir = Vfs::dirname($path_from);
619
-		$path_to = Vfs::parse_url($url_to,PHP_URL_PATH);
619
+		$path_to = Vfs::parse_url($url_to, PHP_URL_PATH);
620 620
 		$to_dir = Vfs::dirname($path_to);
621 621
 		$operation = self::url2operation($url_from);
622 622
 
@@ -627,14 +627,14 @@  discard block
 block discarded – undo
627 627
 			self::_remove_password($url_from);
628 628
 			self::_remove_password($url_to);
629 629
 			if (self::LOG_LEVEL) error_log(__METHOD__."($url_from,$url_to): $path_from permission denied!");
630
-			return false;	// no permission or file does not exist
630
+			return false; // no permission or file does not exist
631 631
 		}
632 632
 		if (!Vfs::check_access($to_dir, Vfs::WRITABLE, $to_dir_stat = static::url_stat($to_dir, 0)))
633 633
 		{
634 634
 			self::_remove_password($url_from);
635 635
 			self::_remove_password($url_to);
636 636
 			if (self::LOG_LEVEL) error_log(__METHOD__."($url_from,$url_to): $path_to permission denied!");
637
-			return false;	// no permission or parent-dir does not exist
637
+			return false; // no permission or parent-dir does not exist
638 638
 		}
639 639
 		// the filesystem stream-wrapper does NOT allow to rename files to directories, as this makes problems
640 640
 		// for our vfs too, we abort here with an error, like the filesystem one does
@@ -645,10 +645,10 @@  discard block
 block discarded – undo
645 645
 			self::_remove_password($url_to);
646 646
 			$is_dir = $to_stat['mime'] === self::DIR_MIME_TYPE ? 'a' : 'no';
647 647
 			if (self::LOG_LEVEL) error_log(__METHOD__."($url_to,$url_from) $path_to is $is_dir directory!");
648
-			return false;	// no permission or file does not exist
648
+			return false; // no permission or file does not exist
649 649
 		}
650 650
 		// if destination file already exists, delete it
651
-		if ($to_stat && !static::unlink($url_to,$operation))
651
+		if ($to_stat && !static::unlink($url_to, $operation))
652 652
 		{
653 653
 			self::_remove_password($url_to);
654 654
 			if (self::LOG_LEVEL) error_log(__METHOD__."($url_to,$url_from) can't unlink existing $url_to!");
@@ -669,7 +669,7 @@  discard block
 block discarded – undo
669 669
 
670 670
 		// check if extension changed and update mime-type in that case (as we currently determine mime-type by it's extension!)
671 671
 		// fixes eg. problems with MsWord storing file with .tmp extension and then renaming to .doc
672
-		if ($ok && ($new_mime = Vfs::mime_content_type($url_to,true)) != Vfs::mime_content_type($url_to))
672
+		if ($ok && ($new_mime = Vfs::mime_content_type($url_to, true)) != Vfs::mime_content_type($url_to))
673 673
 		{
674 674
 			//echo "<p>Vfs::nime_content_type($url_to,true) = $new_mime</p>\n";
675 675
 			$stmt = self::$pdo->prepare('UPDATE '.self::TABLE.' SET fs_mime=:fs_mime WHERE fs_id=:fs_id');
@@ -685,9 +685,9 @@  discard block
 block discarded – undo
685 685
 	/**
686 686
 	 * due to problems with recursive directory creation, we have our own here
687 687
 	 */
688
-	protected static function mkdir_recursive($pathname, $mode, $depth=0)
688
+	protected static function mkdir_recursive($pathname, $mode, $depth = 0)
689 689
 	{
690
-		$maxdepth=10;
690
+		$maxdepth = 10;
691 691
 		$depth2propagate = (int)$depth + 1;
692 692
 		if ($depth2propagate > $maxdepth) return is_dir($pathname);
693 693
     	is_dir(Vfs::dirname($pathname)) || self::mkdir_recursive(Vfs::dirname($pathname), $mode, $depth2propagate);
@@ -705,47 +705,47 @@  discard block
 block discarded – undo
705 705
 	 * @param int $options Posible values include STREAM_REPORT_ERRORS and STREAM_MKDIR_RECURSIVE
706 706
 	 * @return boolean TRUE on success or FALSE on failure
707 707
 	 */
708
-	static function mkdir ( $url, $mode, $options )
708
+	static function mkdir($url, $mode, $options)
709 709
 	{
710 710
 		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$mode,$options)");
711 711
 		if (self::LOG_LEVEL > 1) error_log(__METHOD__." called from:".function_backtrace());
712
-		$path = Vfs::parse_url($url,PHP_URL_PATH);
712
+		$path = Vfs::parse_url($url, PHP_URL_PATH);
713 713
 
714
-		if (self::url_stat($path,STREAM_URL_STAT_QUIET))
714
+		if (self::url_stat($path, STREAM_URL_STAT_QUIET))
715 715
 		{
716 716
 			self::_remove_password($url);
717 717
 			if (self::LOG_LEVEL) error_log(__METHOD__."('$url',$mode,$options) already exist!");
718
-			if (!($options & STREAM_REPORT_ERRORS))
718
+			if (!($options&STREAM_REPORT_ERRORS))
719 719
 			{
720 720
 				//throw new Exception(__METHOD__."('$url',$mode,$options) already exist!");
721
-				trigger_error(__METHOD__."('$url',$mode,$options) already exist!",E_USER_WARNING);
721
+				trigger_error(__METHOD__."('$url',$mode,$options) already exist!", E_USER_WARNING);
722 722
 			}
723 723
 			return false;
724 724
 		}
725 725
 		$parent_path = Vfs::dirname($path);
726
-		if (($query = Vfs::parse_url($url,PHP_URL_QUERY))) $parent_path .= '?'.$query;
727
-		$parent = self::url_stat($parent_path,STREAM_URL_STAT_QUIET);
726
+		if (($query = Vfs::parse_url($url, PHP_URL_QUERY))) $parent_path .= '?'.$query;
727
+		$parent = self::url_stat($parent_path, STREAM_URL_STAT_QUIET);
728 728
 
729 729
 		// check if we should also create all non-existing path components and our parent does not exist,
730 730
 		// if yes call ourself recursive with the parent directory
731
-		if (($options & STREAM_MKDIR_RECURSIVE) && $parent_path != '/' && !$parent)
731
+		if (($options&STREAM_MKDIR_RECURSIVE) && $parent_path != '/' && !$parent)
732 732
 		{
733 733
 			if (self::LOG_LEVEL > 1) error_log(__METHOD__." creating parents: $parent_path, $mode");
734
-			if (!self::mkdir($parent_path,$mode,$options))
734
+			if (!self::mkdir($parent_path, $mode, $options))
735 735
 			{
736 736
 				return false;
737 737
 			}
738
-			$parent = self::url_stat($parent_path,0);
738
+			$parent = self::url_stat($parent_path, 0);
739 739
 		}
740
-		if (!$parent || !Vfs::check_access($parent_path,Vfs::WRITABLE,$parent))
740
+		if (!$parent || !Vfs::check_access($parent_path, Vfs::WRITABLE, $parent))
741 741
 		{
742 742
 			self::_remove_password($url);
743 743
 			if (self::LOG_LEVEL) error_log(__METHOD__."('$url',$mode,$options) permission denied!");
744
-			if (!($options & STREAM_REPORT_ERRORS))
744
+			if (!($options&STREAM_REPORT_ERRORS))
745 745
 			{
746
-				trigger_error(__METHOD__."('$url',$mode,$options) permission denied!",E_USER_WARNING);
746
+				trigger_error(__METHOD__."('$url',$mode,$options) permission denied!", E_USER_WARNING);
747 747
 			}
748
-			return false;	// no permission or file does not exist
748
+			return false; // no permission or file does not exist
749 749
 		}
750 750
 		unset(self::$stat_cache[$path]);
751 751
 		$stmt = self::$pdo->prepare('INSERT INTO '.self::TABLE.' (fs_name,fs_dir,fs_mode,fs_uid,fs_gid,fs_size,fs_mime,fs_created,fs_modified,fs_creator'.
@@ -766,9 +766,9 @@  discard block
 block discarded – undo
766 766
 			// check if some other process created the directory parallel to us (sqlfs would gives SQL errors later!)
767 767
 			$new_fs_id = self::$pdo->lastInsertId('egw_sqlfs_fs_id_seq');
768 768
 
769
-			unset($stmt);	// free statement object, on some installs a new prepare fails otherwise!
769
+			unset($stmt); // free statement object, on some installs a new prepare fails otherwise!
770 770
 
771
-			$stmt = self::$pdo->prepare($q='SELECT COUNT(*) FROM '.self::TABLE.
771
+			$stmt = self::$pdo->prepare($q = 'SELECT COUNT(*) FROM '.self::TABLE.
772 772
 				' WHERE fs_dir=:fs_dir AND fs_active=:fs_active AND fs_name'.self::$case_sensitive_equal.':fs_name');
773 773
 			if ($stmt->execute(array(
774 774
 				'fs_dir'  => $parent['ino'],
@@ -792,25 +792,24 @@  discard block
 block discarded – undo
792 792
 	 * @param int $options Possible values include STREAM_REPORT_ERRORS.
793 793
 	 * @return boolean TRUE on success or FALSE on failure.
794 794
 	 */
795
-	static function rmdir ( $url, $options )
795
+	static function rmdir($url, $options)
796 796
 	{
797 797
 		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url)");
798 798
 
799
-		$path = Vfs::parse_url($url,PHP_URL_PATH);
799
+		$path = Vfs::parse_url($url, PHP_URL_PATH);
800 800
 		$parent = Vfs::dirname($path);
801 801
 
802
-		if (!($stat = self::url_stat($path,0)) || $stat['mime'] != self::DIR_MIME_TYPE ||
803
-			!Vfs::check_access($parent, Vfs::WRITABLE, static::url_stat($parent,0)))
802
+		if (!($stat = self::url_stat($path, 0)) || $stat['mime'] != self::DIR_MIME_TYPE ||
803
+			!Vfs::check_access($parent, Vfs::WRITABLE, static::url_stat($parent, 0)))
804 804
 		{
805 805
 			self::_remove_password($url);
806
-			$err_msg = __METHOD__."($url,$options) ".(!$stat ? 'not found!' :
807
-				($stat['mime'] != self::DIR_MIME_TYPE ? 'not a directory!' : 'permission denied!'));
806
+			$err_msg = __METHOD__."($url,$options) ".(!$stat ? 'not found!' : ($stat['mime'] != self::DIR_MIME_TYPE ? 'not a directory!' : 'permission denied!'));
808 807
 			if (self::LOG_LEVEL) error_log($err_msg);
809
-			if (!($options & STREAM_REPORT_ERRORS))
808
+			if (!($options&STREAM_REPORT_ERRORS))
810 809
 			{
811
-				trigger_error($err_msg,E_USER_WARNING);
810
+				trigger_error($err_msg, E_USER_WARNING);
812 811
 			}
813
-			return false;	// no permission or file does not exist
812
+			return false; // no permission or file does not exist
814 813
 		}
815 814
 		$stmt = self::$pdo->prepare('SELECT COUNT(*) FROM '.self::TABLE.' WHERE fs_dir=?');
816 815
 		$stmt->execute(array($stat['ino']));
@@ -818,19 +817,19 @@  discard block
 block discarded – undo
818 817
 		{
819 818
 			self::_remove_password($url);
820 819
 			if (self::LOG_LEVEL) error_log(__METHOD__."($url,$options) dir is not empty!");
821
-			if (!($options & STREAM_REPORT_ERRORS))
820
+			if (!($options&STREAM_REPORT_ERRORS))
822 821
 			{
823
-				trigger_error(__METHOD__."('$url',$options) dir is not empty!",E_USER_WARNING);
822
+				trigger_error(__METHOD__."('$url',$options) dir is not empty!", E_USER_WARNING);
824 823
 			}
825 824
 			return false;
826 825
 		}
827 826
 		unset(self::$stat_cache[$path]);
828
-		unset($stmt);	// free statement object, on some installs a new prepare fails otherwise!
827
+		unset($stmt); // free statement object, on some installs a new prepare fails otherwise!
829 828
 
830 829
 		$del_stmt = self::$pdo->prepare('DELETE FROM '.self::TABLE.' WHERE fs_id=?');
831 830
 		if (($ret = $del_stmt->execute(array($stat['ino']))))
832 831
 		{
833
-			self::eacl($path,null,false,$stat['ino']);	// remove all (=false) evtl. existing extended acl for that dir
832
+			self::eacl($path, null, false, $stat['ino']); // remove all (=false) evtl. existing extended acl for that dir
834 833
 			// delete props
835 834
 			unset($del_stmt);
836 835
 			$del_stmt = self::$pdo->prepare('DELETE FROM '.self::PROPS_TABLE.' WHERE fs_id=?');
@@ -846,25 +845,25 @@  discard block
 block discarded – undo
846 845
 	 * @param int $time =null modification time (unix timestamp), default null = current time
847 846
 	 * @param int $atime =null access time (unix timestamp), default null = current time, not implemented in the vfs!
848 847
 	 */
849
-	static function touch($url,$time=null,$atime=null)
848
+	static function touch($url, $time = null, $atime = null)
850 849
 	{
851
-		unset($atime);	// not used
850
+		unset($atime); // not used
852 851
 		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url, $time)");
853 852
 
854
-		$path = Vfs::parse_url($url,PHP_URL_PATH);
853
+		$path = Vfs::parse_url($url, PHP_URL_PATH);
855 854
 
856
-		if (!($stat = self::url_stat($path,STREAM_URL_STAT_QUIET)))
855
+		if (!($stat = self::url_stat($path, STREAM_URL_STAT_QUIET)))
857 856
 		{
858 857
 			// file does not exist --> create an empty one
859
-			if (!($f = fopen(self::SCHEME.'://default'.$path,'w')) || !fclose($f))
858
+			if (!($f = fopen(self::SCHEME.'://default'.$path, 'w')) || !fclose($f))
860 859
 			{
861 860
 				return false;
862 861
 			}
863 862
 			if (is_null($time))
864 863
 			{
865
-				return true;	// new (empty) file created with current mod time
864
+				return true; // new (empty) file created with current mod time
866 865
 			}
867
-			$stat = self::url_stat($path,0);
866
+			$stat = self::url_stat($path, 0);
868 867
 		}
869 868
 		unset(self::$stat_cache[$path]);
870 869
 		$stmt = self::$pdo->prepare('UPDATE '.self::TABLE.' SET fs_modified=:fs_modified,fs_modifier=:fs_modifier WHERE fs_id=:fs_id');
@@ -883,39 +882,39 @@  discard block
 block discarded – undo
883 882
 	 * @param int $owner
884 883
 	 * @return boolean
885 884
 	 */
886
-	static function chown($url,$owner)
885
+	static function chown($url, $owner)
887 886
 	{
888 887
 		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$owner)");
889 888
 
890
-		$path = Vfs::parse_url($url,PHP_URL_PATH);
889
+		$path = Vfs::parse_url($url, PHP_URL_PATH);
891 890
 
892
-		if (!($stat = self::url_stat($path,0)))
891
+		if (!($stat = self::url_stat($path, 0)))
893 892
 		{
894 893
 			if (self::LOG_LEVEL) error_log(__METHOD__."($url,$owner) no such file or directory!");
895
-			trigger_error("No such file or directory $url !",E_USER_WARNING);
894
+			trigger_error("No such file or directory $url !", E_USER_WARNING);
896 895
 			return false;
897 896
 		}
898 897
 		if (!Vfs::$is_root)
899 898
 		{
900 899
 			if (self::LOG_LEVEL) error_log(__METHOD__."($url,$owner) only root can do that!");
901
-			trigger_error("Only root can do that!",E_USER_WARNING);
900
+			trigger_error("Only root can do that!", E_USER_WARNING);
902 901
 			return false;
903 902
 		}
904 903
 		if ($owner < 0 || $owner && !$GLOBALS['egw']->accounts->id2name($owner))	// not a user (0 == root)
905 904
 		{
906 905
 			if (self::LOG_LEVEL) error_log(__METHOD__."($url,$owner) unknown (numeric) user id!");
907
-			trigger_error(__METHOD__."($url,$owner) Unknown (numeric) user id!",E_USER_WARNING);
906
+			trigger_error(__METHOD__."($url,$owner) Unknown (numeric) user id!", E_USER_WARNING);
908 907
 			//throw new Exception(__METHOD__."($url,$owner) Unknown (numeric) user id!");
909 908
 			return false;
910 909
 		}
911 910
 		$stmt = self::$pdo->prepare('UPDATE '.self::TABLE.' SET fs_uid=:fs_uid WHERE fs_id=:fs_id');
912 911
 
913 912
 		// update stat-cache
914
-		if ($path != '/' && substr($path,-1) == '/') $path = substr($path, 0, -1);
913
+		if ($path != '/' && substr($path, -1) == '/') $path = substr($path, 0, -1);
915 914
 		self::$stat_cache[$path]['fs_uid'] = $owner;
916 915
 
917 916
 		return $stmt->execute(array(
918
-			'fs_uid' => (int) $owner,
917
+			'fs_uid' => (int)$owner,
919 918
 			'fs_id' => $stat['ino'],
920 919
 		));
921 920
 	}
@@ -927,36 +926,36 @@  discard block
 block discarded – undo
927 926
 	 * @param int $owner
928 927
 	 * @return boolean
929 928
 	 */
930
-	static function chgrp($url,$owner)
929
+	static function chgrp($url, $owner)
931 930
 	{
932 931
 		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$owner)");
933 932
 
934
-		$path = Vfs::parse_url($url,PHP_URL_PATH);
933
+		$path = Vfs::parse_url($url, PHP_URL_PATH);
935 934
 
936
-		if (!($stat = self::url_stat($path,0)))
935
+		if (!($stat = self::url_stat($path, 0)))
937 936
 		{
938 937
 			if (self::LOG_LEVEL) error_log(__METHOD__."($url,$owner) no such file or directory!");
939
-			trigger_error("No such file or directory $url !",E_USER_WARNING);
938
+			trigger_error("No such file or directory $url !", E_USER_WARNING);
940 939
 			return false;
941 940
 		}
942
-		if (!Vfs::has_owner_rights($path,$stat))
941
+		if (!Vfs::has_owner_rights($path, $stat))
943 942
 		{
944 943
 			if (self::LOG_LEVEL) error_log(__METHOD__."($url,$owner) only owner or root can do that!");
945
-			trigger_error("Only owner or root can do that!",E_USER_WARNING);
944
+			trigger_error("Only owner or root can do that!", E_USER_WARNING);
946 945
 			return false;
947 946
 		}
948
-		if ($owner < 0) $owner = -$owner;	// sqlfs uses a positiv group id's!
947
+		if ($owner < 0) $owner = -$owner; // sqlfs uses a positiv group id's!
949 948
 
950 949
 		if ($owner && !$GLOBALS['egw']->accounts->id2name(-$owner))	// not a group
951 950
 		{
952 951
 			if (self::LOG_LEVEL) error_log(__METHOD__."($url,$owner) unknown (numeric) group id!");
953
-			trigger_error("Unknown (numeric) group id!",E_USER_WARNING);
952
+			trigger_error("Unknown (numeric) group id!", E_USER_WARNING);
954 953
 			return false;
955 954
 		}
956 955
 		$stmt = self::$pdo->prepare('UPDATE '.self::TABLE.' SET fs_gid=:fs_gid WHERE fs_id=:fs_id');
957 956
 
958 957
 		// update stat-cache
959
-		if ($path != '/' && substr($path,-1) == '/') $path = substr($path, 0, -1);
958
+		if ($path != '/' && substr($path, -1) == '/') $path = substr($path, 0, -1);
960 959
 		self::$stat_cache[$path]['fs_gid'] = $owner;
961 960
 
962 961
 		return $stmt->execute(array(
@@ -972,38 +971,38 @@  discard block
 block discarded – undo
972 971
 	 * @param int $mode
973 972
 	 * @return boolean
974 973
 	 */
975
-	static function chmod($url,$mode)
974
+	static function chmod($url, $mode)
976 975
 	{
977 976
 		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url, $mode)");
978 977
 
979
-		$path = Vfs::parse_url($url,PHP_URL_PATH);
978
+		$path = Vfs::parse_url($url, PHP_URL_PATH);
980 979
 
981
-		if (!($stat = self::url_stat($path,0)))
980
+		if (!($stat = self::url_stat($path, 0)))
982 981
 		{
983 982
 			if (self::LOG_LEVEL) error_log(__METHOD__."($url, $mode) no such file or directory!");
984
-			trigger_error("No such file or directory $url !",E_USER_WARNING);
983
+			trigger_error("No such file or directory $url !", E_USER_WARNING);
985 984
 			return false;
986 985
 		}
987
-		if (!Vfs::has_owner_rights($path,$stat))
986
+		if (!Vfs::has_owner_rights($path, $stat))
988 987
 		{
989 988
 			if (self::LOG_LEVEL) error_log(__METHOD__."($url, $mode) only owner or root can do that!");
990
-			trigger_error("Only owner or root can do that!",E_USER_WARNING);
989
+			trigger_error("Only owner or root can do that!", E_USER_WARNING);
991 990
 			return false;
992 991
 		}
993 992
 		if (!is_numeric($mode))	// not a mode
994 993
 		{
995 994
 			if (self::LOG_LEVEL) error_log(__METHOD__."($url, $mode) no (numeric) mode!");
996
-			trigger_error("No (numeric) mode!",E_USER_WARNING);
995
+			trigger_error("No (numeric) mode!", E_USER_WARNING);
997 996
 			return false;
998 997
 		}
999 998
 		$stmt = self::$pdo->prepare('UPDATE '.self::TABLE.' SET fs_mode=:fs_mode WHERE fs_id=:fs_id');
1000 999
 
1001 1000
 		// update stat cache
1002
-		if ($path != '/' && substr($path,-1) == '/') $path = substr($path, 0, -1);
1003
-		self::$stat_cache[$path]['fs_mode'] = ((int) $mode) & 0777;
1001
+		if ($path != '/' && substr($path, -1) == '/') $path = substr($path, 0, -1);
1002
+		self::$stat_cache[$path]['fs_mode'] = ((int)$mode)&0777;
1004 1003
 
1005 1004
 		return $stmt->execute(array(
1006
-			'fs_mode' => ((int) $mode) & 0777,		// we dont store the file and dir bits, give int overflow!
1005
+			'fs_mode' => ((int)$mode)&0777, // we dont store the file and dir bits, give int overflow!
1007 1006
 			'fs_id' => $stat['ino'],
1008 1007
 		));
1009 1008
 	}
@@ -1016,15 +1015,15 @@  discard block
 block discarded – undo
1016 1015
 	 * @param int $options
1017 1016
 	 * @return booelan
1018 1017
 	 */
1019
-	function dir_opendir ( $url, $options )
1018
+	function dir_opendir($url, $options)
1020 1019
 	{
1021 1020
 		$this->opened_dir = null;
1022 1021
 
1023
-		$path = Vfs::parse_url($url,PHP_URL_PATH);
1022
+		$path = Vfs::parse_url($url, PHP_URL_PATH);
1024 1023
 
1025
-		if (!($stat = self::url_stat($url,0)) || 		// dir not found
1026
-			$stat['mime'] != self::DIR_MIME_TYPE ||		// no dir
1027
-			!Vfs::check_access($url,Vfs::EXECUTABLE|Vfs::READABLE,$stat))	// no access
1024
+		if (!($stat = self::url_stat($url, 0)) || // dir not found
1025
+			$stat['mime'] != self::DIR_MIME_TYPE || // no dir
1026
+			!Vfs::check_access($url, Vfs::EXECUTABLE|Vfs::READABLE, $stat))	// no access
1028 1027
 		{
1029 1028
 			self::_remove_password($url);
1030 1029
 			$msg = $stat['mime'] != self::DIR_MIME_TYPE ? "$url is no directory" : 'permission denied';
@@ -1043,13 +1042,13 @@  discard block
 block discarded – undo
1043 1042
 		$stmt->setFetchMode(\PDO::FETCH_ASSOC);
1044 1043
 		if ($stmt->execute(array($stat['ino'])))
1045 1044
 		{
1046
-			foreach($stmt as $file)
1045
+			foreach ($stmt as $file)
1047 1046
 			{
1048 1047
 				$this->opened_dir[] = $file['fs_name'];
1049
-				self::$stat_cache[Vfs::concat($path,$file['fs_name'])] = $file;
1048
+				self::$stat_cache[Vfs::concat($path, $file['fs_name'])] = $file;
1050 1049
 			}
1051 1050
 		}
1052
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$options): ".implode(', ',$this->opened_dir));
1051
+		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$options): ".implode(', ', $this->opened_dir));
1053 1052
 		reset($this->opened_dir);
1054 1053
 
1055 1054
 		return true;
@@ -1082,26 +1081,26 @@  discard block
 block discarded – undo
1082 1081
 	 * @param boolean $eacl_access =null allows extending classes to pass the value of their check_extended_acl() method (no lsb!)
1083 1082
 	 * @return array
1084 1083
 	 */
1085
-	static function url_stat ( $url, $flags, $eacl_access=null )
1084
+	static function url_stat($url, $flags, $eacl_access = null)
1086 1085
 	{
1087
-		static $max_subquery_depth=null;
1086
+		static $max_subquery_depth = null;
1088 1087
 		if (is_null($max_subquery_depth))
1089 1088
 		{
1090 1089
 			$max_subquery_depth = $GLOBALS['egw_info']['server']['max_subquery_depth'];
1091
-			if (!$max_subquery_depth) $max_subquery_depth = 7;	// setting current default of 7, if nothing set
1090
+			if (!$max_subquery_depth) $max_subquery_depth = 7; // setting current default of 7, if nothing set
1092 1091
 		}
1093 1092
 		if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$url',$flags,$eacl_access)");
1094 1093
 
1095
-		$path = Vfs::parse_url($url,PHP_URL_PATH);
1094
+		$path = Vfs::parse_url($url, PHP_URL_PATH);
1096 1095
 
1097 1096
 		// webdav adds a trailing slash to dirs, which causes url_stat to NOT find the file otherwise
1098
-		if ($path != '/' && substr($path,-1) == '/')
1097
+		if ($path != '/' && substr($path, -1) == '/')
1099 1098
 		{
1100
-			$path = substr($path,0,-1);
1099
+			$path = substr($path, 0, -1);
1101 1100
 		}
1102 1101
 		if (empty($path))
1103 1102
 		{
1104
-			return false;	// is invalid and gives sql error
1103
+			return false; // is invalid and gives sql error
1105 1104
 		}
1106 1105
 		// check if we already have the info from the last dir_open call, as the old vfs reads it anyway from the db
1107 1106
 		if (self::$stat_cache && isset(self::$stat_cache[$path]) && (is_null($eacl_access) || self::$stat_cache[$path] !== false))
@@ -1116,28 +1115,28 @@  discard block
 block discarded – undo
1116 1115
 		$base_query = 'SELECT fs_id,fs_name,fs_mode,fs_uid,fs_gid,fs_size,fs_mime,fs_created,fs_modified'.self::$extra_columns.
1117 1116
 			' FROM '.self::TABLE.' WHERE fs_active='.self::_pdo_boolean(true).
1118 1117
 			' AND fs_name'.self::$case_sensitive_equal.'? AND fs_dir=';
1119
-		$parts = explode('/',$path);
1118
+		$parts = explode('/', $path);
1120 1119
 
1121 1120
 		// if we have extendes acl access to the url, we dont need and can NOT include the sql for the readable check
1122 1121
 		if (is_null($eacl_access))
1123 1122
 		{
1124
-			$eacl_access = self::check_extended_acl($path,Vfs::READABLE);	// should be static::check_extended_acl, but no lsb!
1123
+			$eacl_access = self::check_extended_acl($path, Vfs::READABLE); // should be static::check_extended_acl, but no lsb!
1125 1124
 		}
1126 1125
 
1127 1126
 		try {
1128
-			foreach($parts as $n => $name)
1127
+			foreach ($parts as $n => $name)
1129 1128
 			{
1130 1129
 				if ($n == 0)
1131 1130
 				{
1132
-					$query = (int) ($path != '/');	// / always has fs_id == 1, no need to query it ($path=='/' needs fs_dir=0!)
1131
+					$query = (int)($path != '/'); // / always has fs_id == 1, no need to query it ($path=='/' needs fs_dir=0!)
1133 1132
 				}
1134
-				elseif ($n < count($parts)-1)
1133
+				elseif ($n < count($parts) - 1)
1135 1134
 				{
1136 1135
 					// MySQL 5.0 has a nesting limit for subqueries
1137 1136
 					// --> we replace the so far cumulated subqueries with their result
1138 1137
 					// no idea about the other DBMS, but this does NOT hurt ...
1139 1138
 					// --> depth limit of subqueries is now dynamicly decremented in catch
1140
-					if ($n > 1 && !(($n-1) % $max_subquery_depth) && !($query = self::$pdo->query($query)->fetchColumn()))
1139
+					if ($n > 1 && !(($n - 1) % $max_subquery_depth) && !($query = self::$pdo->query($query)->fetchColumn()))
1141 1140
 					{
1142 1141
 						if (self::LOG_LEVEL > 1)
1143 1142
 						{
@@ -1164,7 +1163,7 @@  discard block
 block discarded – undo
1164 1163
 				}
1165 1164
 				else
1166 1165
 				{
1167
-					$query = str_replace('fs_name'.self::$case_sensitive_equal.'?','fs_name'.self::$case_sensitive_equal.self::$pdo->quote($name),$base_query).'('.$query.')';
1166
+					$query = str_replace('fs_name'.self::$case_sensitive_equal.'?', 'fs_name'.self::$case_sensitive_equal.self::$pdo->quote($name), $base_query).'('.$query.')';
1168 1167
 				}
1169 1168
 			}
1170 1169
 			if (self::LOG_LEVEL > 2) $query = '/* '.__METHOD__."($url,$flags,$eacl_access)".' */ '.$query;
@@ -1190,7 +1189,7 @@  discard block
 block discarded – undo
1190 1189
 			$GLOBALS['egw_info']['server']['max_subquery_depth'] = --$max_subquery_depth;
1191 1190
 			error_log(__METHOD__."() decremented max_subquery_depth to $max_subquery_depth");
1192 1191
 			config::save_value('max_subquery_depth', $max_subquery_depth, 'phpgwapi');
1193
-			if (method_exists($GLOBALS['egw'],'invalidate_session_cache')) $GLOBALS['egw']->invalidate_session_cache();
1192
+			if (method_exists($GLOBALS['egw'], 'invalidate_session_cache')) $GLOBALS['egw']->invalidate_session_cache();
1194 1193
 			return self::url_stat($url, $flags, $eacl_access);
1195 1194
 		}
1196 1195
 		self::$stat_cache[$path] = $info;
@@ -1206,18 +1205,18 @@  discard block
 block discarded – undo
1206 1205
 	 */
1207 1206
 	protected function _sql_readable()
1208 1207
 	{
1209
-		static $sql_read_acl=null;
1208
+		static $sql_read_acl = null;
1210 1209
 
1211 1210
 		if (is_null($sql_read_acl))
1212 1211
 		{
1213
-			foreach($GLOBALS['egw']->accounts->memberships(Vfs::$user,true) as $gid)
1212
+			foreach ($GLOBALS['egw']->accounts->memberships(Vfs::$user, true) as $gid)
1214 1213
 			{
1215
-				$memberships[] = abs($gid);	// sqlfs stores the gid's positiv
1214
+				$memberships[] = abs($gid); // sqlfs stores the gid's positiv
1216 1215
 			}
1217 1216
 			// using octal numbers with mysql leads to funny results (select 384 & 0400 --> 384 not 256=0400)
1218 1217
 			// 256 = 0400, 32 = 040
1219 1218
 			$sql_read_acl = '((fs_mode & 4)=4 OR (fs_mode & 256)=256 AND fs_uid='.(int)Vfs::$user.
1220
-				($memberships ? ' OR (fs_mode & 32)=32 AND fs_gid IN('.implode(',',$memberships).')' : '').')';
1219
+				($memberships ? ' OR (fs_mode & 32)=32 AND fs_gid IN('.implode(',', $memberships).')' : '').')';
1221 1220
 			//error_log(__METHOD__."() Vfs::\$user=".array2string(Vfs::$user).' --> memberships='.array2string($memberships).' --> '.$sql_read_acl.($memberships?'':': '.function_backtrace()));
1222 1221
 		}
1223 1222
 		return $sql_read_acl;
@@ -1230,7 +1229,7 @@  discard block
 block discarded – undo
1230 1229
 	 *
1231 1230
 	 * @return string
1232 1231
 	 */
1233
-	function dir_readdir ( )
1232
+	function dir_readdir( )
1234 1233
 	{
1235 1234
 		if (self::LOG_LEVEL > 1) error_log(__METHOD__."( )");
1236 1235
 
@@ -1249,7 +1248,7 @@  discard block
 block discarded – undo
1249 1248
 	 *
1250 1249
 	 * @return boolean
1251 1250
 	 */
1252
-	function dir_rewinddir ( )
1251
+	function dir_rewinddir( )
1253 1252
 	{
1254 1253
 		if (self::LOG_LEVEL > 1) error_log(__METHOD__."( )");
1255 1254
 
@@ -1267,7 +1266,7 @@  discard block
 block discarded – undo
1267 1266
 	 *
1268 1267
 	 * @return boolean
1269 1268
 	 */
1270
-	function dir_closedir ( )
1269
+	function dir_closedir( )
1271 1270
 	{
1272 1271
 		if (self::LOG_LEVEL > 1) error_log(__METHOD__."( )");
1273 1272
 
@@ -1288,7 +1287,7 @@  discard block
 block discarded – undo
1288 1287
 	 */
1289 1288
 	static function readlink($path)
1290 1289
 	{
1291
-		$link = !($lstat = self::url_stat($path,STREAM_URL_STAT_LINK)) || is_null($lstat['readlink']) ? false : $lstat['readlink'];
1290
+		$link = !($lstat = self::url_stat($path, STREAM_URL_STAT_LINK)) || is_null($lstat['readlink']) ? false : $lstat['readlink'];
1292 1291
 
1293 1292
 		if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path') = $link");
1294 1293
 
@@ -1302,31 +1301,31 @@  discard block
 block discarded – undo
1302 1301
 	 * @param string $link
1303 1302
 	 * @return boolean true on success false on error
1304 1303
 	 */
1305
-	static function symlink($target,$link)
1304
+	static function symlink($target, $link)
1306 1305
 	{
1307 1306
 		if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$target','$link')");
1308 1307
 
1309
-		if (self::url_stat($link,0))
1308
+		if (self::url_stat($link, 0))
1310 1309
 		{
1311 1310
 			if (self::LOG_LEVEL > 0) error_log(__METHOD__."('$target','$link') $link exists, returning false!");
1312
-			return false;	// $link already exists
1311
+			return false; // $link already exists
1313 1312
 		}
1314 1313
 		if (!($dir = Vfs::dirname($link)) ||
1315
-			!Vfs::check_access($dir,Vfs::WRITABLE,$dir_stat=static::url_stat($dir,0)))
1314
+			!Vfs::check_access($dir, Vfs::WRITABLE, $dir_stat = static::url_stat($dir, 0)))
1316 1315
 		{
1317 1316
 			if (self::LOG_LEVEL > 0) error_log(__METHOD__."('$target','$link') returning false! (!is_writable('$dir'), dir_stat=".array2string($dir_stat).")");
1318
-			return false;	// parent dir does not exist or is not writable
1317
+			return false; // parent dir does not exist or is not writable
1319 1318
 		}
1320 1319
 		$query = 'INSERT INTO '.self::TABLE.' (fs_name,fs_dir,fs_mode,fs_uid,fs_gid,fs_created,fs_modified,fs_creator,fs_mime,fs_size,fs_link'.
1321 1320
 			') VALUES (:fs_name,:fs_dir,:fs_mode,:fs_uid,:fs_gid,:fs_created,:fs_modified,:fs_creator,:fs_mime,:fs_size,:fs_link)';
1322 1321
 		if (self::LOG_LEVEL > 2) $query = '/* '.__METHOD__.': '.__LINE__.' */ '.$query;
1323 1322
 		$stmt = self::$pdo->prepare($query);
1324
-		unset(self::$stat_cache[Vfs::parse_url($link,PHP_URL_PATH)]);
1323
+		unset(self::$stat_cache[Vfs::parse_url($link, PHP_URL_PATH)]);
1325 1324
 
1326 1325
 		return !!$stmt->execute(array(
1327 1326
 			'fs_name' => self::limit_filename(Vfs::basename($link)),
1328 1327
 			'fs_dir'  => $dir_stat['ino'],
1329
-			'fs_mode' => ($dir_stat['mode'] & 0666),
1328
+			'fs_mode' => ($dir_stat['mode']&0666),
1330 1329
 			'fs_uid'  => $dir_stat['uid'] ? $dir_stat['uid'] : Vfs::$user,
1331 1330
 			'fs_gid'  => $dir_stat['gid'],
1332 1331
 			'fs_created'  => self::_pdo_timestamp(time()),
@@ -1350,24 +1349,24 @@  discard block
 block discarded – undo
1350 1349
 	 * @param int $check mode to check: one or more or'ed together of: 4 = read, 2 = write, 1 = executable
1351 1350
 	 * @return boolean
1352 1351
 	 */
1353
-	static function check_extended_acl($url,$check)
1352
+	static function check_extended_acl($url, $check)
1354 1353
 	{
1355
-		$url_path = Vfs::parse_url($url,PHP_URL_PATH);
1354
+		$url_path = Vfs::parse_url($url, PHP_URL_PATH);
1356 1355
 
1357 1356
 		if (is_null(self::$extended_acl))
1358 1357
 		{
1359 1358
 			self::_read_extended_acl();
1360 1359
 		}
1361 1360
 		$access = false;
1362
-		foreach(self::$extended_acl as $path => $rights)
1361
+		foreach (self::$extended_acl as $path => $rights)
1363 1362
 		{
1364
-			if ($path == $url_path || substr($url_path,0,strlen($path)+1) == $path.'/')
1363
+			if ($path == $url_path || substr($url_path, 0, strlen($path) + 1) == $path.'/')
1365 1364
 			{
1366
-				$access = ($rights & $check) == $check;
1365
+				$access = ($rights&$check) == $check;
1367 1366
 				break;
1368 1367
 			}
1369 1368
 		}
1370
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$check) ".($access?"access granted by $path=$rights":'no access!!!'));
1369
+		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$check) ".($access ? "access granted by $path=$rights" : 'no access!!!'));
1371 1370
 		return $access;
1372 1371
 	}
1373 1372
 
@@ -1379,14 +1378,14 @@  discard block
 block discarded – undo
1379 1378
 	{
1380 1379
 		if ((self::$extended_acl = egw_cache::getSession(self::EACL_APPNAME, 'extended_acl')))
1381 1380
 		{
1382
-			return;		// ext. ACL read from session.
1381
+			return; // ext. ACL read from session.
1383 1382
 		}
1384 1383
 		self::$extended_acl = array();
1385
-		if (($rights = $GLOBALS['egw']->acl->get_all_location_rights(Vfs::$user,self::EACL_APPNAME)))
1384
+		if (($rights = $GLOBALS['egw']->acl->get_all_location_rights(Vfs::$user, self::EACL_APPNAME)))
1386 1385
 		{
1387 1386
 			$pathes = self::id2path(array_keys($rights));
1388 1387
 		}
1389
-		foreach($rights as $fs_id => $right)
1388
+		foreach ($rights as $fs_id => $right)
1390 1389
 		{
1391 1390
 			$path = $pathes[$fs_id];
1392 1391
 			if (isset($path))
@@ -1395,8 +1394,8 @@  discard block
 block discarded – undo
1395 1394
 			}
1396 1395
 		}
1397 1396
 		// sort by length descending, to allow more specific pathes to have precedence
1398
-		uksort(self::$extended_acl, function($a,$b) {
1399
-			return strlen($b)-strlen($a);
1397
+		uksort(self::$extended_acl, function($a, $b) {
1398
+			return strlen($b) - strlen($a);
1400 1399
 		});
1401 1400
 		egw_cache::setSession(self::EACL_APPNAME, 'extended_acl', self::$extended_acl);
1402 1401
 		if (self::LOG_LEVEL > 1) error_log(__METHOD__.'() '.array2string(self::$extended_acl));
@@ -1418,23 +1417,23 @@  discard block
 block discarded – undo
1418 1417
 	 * @param int $fs_id =null fs_id to use, to not query it again (eg. because it's already deleted)
1419 1418
 	 * @return boolean true if acl is set/deleted, false on error
1420 1419
 	 */
1421
-	static function eacl($path,$rights=null,$owner=null,$fs_id=null)
1420
+	static function eacl($path, $rights = null, $owner = null, $fs_id = null)
1422 1421
 	{
1423 1422
 		if ($path[0] != '/')
1424 1423
 		{
1425
-			$path = Vfs::parse_url($path,PHP_URL_PATH);
1424
+			$path = Vfs::parse_url($path, PHP_URL_PATH);
1426 1425
 		}
1427 1426
 		if (is_null($fs_id))
1428 1427
 		{
1429
-			if (!($stat = self::url_stat($path,0)))
1428
+			if (!($stat = self::url_stat($path, 0)))
1430 1429
 			{
1431 1430
 				if (self::LOG_LEVEL) error_log(__METHOD__."($path,$rights,$owner,$fs_id) no such file or directory!");
1432
-				return false;	// $path not found
1431
+				return false; // $path not found
1433 1432
 			}
1434
-			if (!Vfs::has_owner_rights($path,$stat))		// not group dir and user is eGW admin
1433
+			if (!Vfs::has_owner_rights($path, $stat))		// not group dir and user is eGW admin
1435 1434
 			{
1436 1435
 				if (self::LOG_LEVEL) error_log(__METHOD__."($path,$rights,$owner,$fs_id) permission denied!");
1437
-				return false;	// permission denied
1436
+				return false; // permission denied
1438 1437
 			}
1439 1438
 			$fs_id = $stat['ino'];
1440 1439
 		}
@@ -1446,21 +1445,21 @@  discard block
 block discarded – undo
1446 1445
 		{
1447 1446
 			// delete eacl
1448 1447
 			if (is_null($owner) || $owner == Vfs::$user ||
1449
-				$owner < 0 && Vfs::$user && in_array($owner,$GLOBALS['egw']->accounts->memberships(Vfs::$user,true)))
1448
+				$owner < 0 && Vfs::$user && in_array($owner, $GLOBALS['egw']->accounts->memberships(Vfs::$user, true)))
1450 1449
 			{
1451
-				self::$extended_acl = null;	// force new read of eACL, as there could be multiple eACL for that path
1450
+				self::$extended_acl = null; // force new read of eACL, as there could be multiple eACL for that path
1452 1451
 			}
1453
-			$ret = $GLOBALS['egw']->acl->delete_repository(self::EACL_APPNAME,$fs_id,(int)$owner);
1452
+			$ret = $GLOBALS['egw']->acl->delete_repository(self::EACL_APPNAME, $fs_id, (int)$owner);
1454 1453
 		}
1455 1454
 		else
1456 1455
 		{
1457 1456
 			if (isset(self::$extended_acl) && ($owner == Vfs::$user ||
1458
-				$owner < 0 && Vfs::$user && in_array($owner,$GLOBALS['egw']->accounts->memberships(Vfs::$user,true))))
1457
+				$owner < 0 && Vfs::$user && in_array($owner, $GLOBALS['egw']->accounts->memberships(Vfs::$user, true))))
1459 1458
 			{
1460 1459
 				// set rights for this class, if applicable
1461 1460
 				self::$extended_acl[$path] |= $rights;
1462 1461
 			}
1463
-			$ret = $GLOBALS['egw']->acl->add_repository(self::EACL_APPNAME,$fs_id,$owner,$rights);
1462
+			$ret = $GLOBALS['egw']->acl->add_repository(self::EACL_APPNAME, $fs_id, $owner, $rights);
1464 1463
 		}
1465 1464
 		if ($ret)
1466 1465
 		{
@@ -1483,10 +1482,10 @@  discard block
 block discarded – undo
1483 1482
 		if (!($stat = static::url_stat($path, STREAM_URL_STAT_QUIET)))
1484 1483
 		{
1485 1484
 			error_log(__METHOD__.__LINE__.' '.array2string($path).' not found!');
1486
-			return false;	// not found
1485
+			return false; // not found
1487 1486
 		}
1488 1487
 		$eacls = array();
1489
-		foreach($GLOBALS['egw']->acl->get_all_rights($stat['ino'],self::EACL_APPNAME) as $owner => $rights)
1488
+		foreach ($GLOBALS['egw']->acl->get_all_rights($stat['ino'], self::EACL_APPNAME) as $owner => $rights)
1490 1489
 		{
1491 1490
 			$eacls[] = array(
1492 1491
 				'path'   => $path,
@@ -1497,7 +1496,7 @@  discard block
 block discarded – undo
1497 1496
 		}
1498 1497
 		if (($path = Vfs::dirname($path)))
1499 1498
 		{
1500
-			$eacls = array_merge((array)self::get_eacl($path),$eacls);
1499
+			$eacls = array_merge((array)self::get_eacl($path), $eacls);
1501 1500
 		}
1502 1501
 		// sort by length descending, to show precedence
1503 1502
 		usort($eacls, function($a, $b) {
@@ -1522,9 +1521,9 @@  discard block
 block discarded – undo
1522 1521
 		$ids = (array)$fs_ids;
1523 1522
 		$pathes = array();
1524 1523
 		// first check our stat-cache for the ids
1525
-		foreach(self::$stat_cache as $path => $stat)
1524
+		foreach (self::$stat_cache as $path => $stat)
1526 1525
 		{
1527
-			if (($key = array_search($stat['fs_id'],$ids)) !== false)
1526
+			if (($key = array_search($stat['fs_id'], $ids)) !== false)
1528 1527
 			{
1529 1528
 				$pathes[$stat['fs_id']] = $path;
1530 1529
 				unset($ids[$key]);
@@ -1538,7 +1537,7 @@  discard block
 block discarded – undo
1538 1537
 		// now search via the database
1539 1538
 		if (count($ids) > 1) array_map(function(&$v) { $v = (int)$v; },$ids);
1540 1539
 		$query = 'SELECT fs_id,fs_dir,fs_name FROM '.self::TABLE.' WHERE fs_id'.
1541
-			(count($ids) == 1 ? '='.(int)$ids[0] : ' IN ('.implode(',',$ids).')');
1540
+			(count($ids) == 1 ? '='.(int)$ids[0] : ' IN ('.implode(',', $ids).')');
1542 1541
 		if (self::LOG_LEVEL > 2) $query = '/* '.__METHOD__.': '.__LINE__.' */ '.$query;
1543 1542
 
1544 1543
 		if (!is_object(self::$pdo))
@@ -1549,12 +1548,12 @@  discard block
 block discarded – undo
1549 1548
 		$stmt->setFetchMode(\PDO::FETCH_ASSOC);
1550 1549
 		if (!$stmt->execute())
1551 1550
 		{
1552
-			return false;	// not found
1551
+			return false; // not found
1553 1552
 		}
1554 1553
 		$parents = array();
1555
-		foreach($stmt as $row)
1554
+		foreach ($stmt as $row)
1556 1555
 		{
1557
-			if ($row['fs_dir'] > 1 && !in_array($row['fs_dir'],$parents))
1556
+			if ($row['fs_dir'] > 1 && !in_array($row['fs_dir'], $parents))
1558 1557
 			{
1559 1558
 				$parents[] = $row['fs_dir'];
1560 1559
 			}
@@ -1564,14 +1563,14 @@  discard block
 block discarded – undo
1564 1563
 
1565 1564
 		if ($parents && !($parents = self::id2path($parents)))
1566 1565
 		{
1567
-			return false;	// parent not found, should never happen ...
1566
+			return false; // parent not found, should never happen ...
1568 1567
 		}
1569
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__." trying foreach with:".print_r($rows,true)."#");
1570
-		foreach((array)$rows as $fs_id => $row)
1568
+		if (self::LOG_LEVEL > 1) error_log(__METHOD__." trying foreach with:".print_r($rows, true)."#");
1569
+		foreach ((array)$rows as $fs_id => $row)
1571 1570
 		{
1572 1571
 			$parent = $row['fs_dir'] > 1 ? $parents[$row['fs_dir']] : '';
1573 1572
 
1574
-			$pathes[$fs_id] = $parent . '/' . $row['fs_name'];
1573
+			$pathes[$fs_id] = $parent.'/'.$row['fs_name'];
1575 1574
 		}
1576 1575
 		if (self::LOG_LEVEL > 1) error_log(__METHOD__.'('.array2string($fs_ids).')='.array2string($pathes));
1577 1576
 		return is_array($fs_ids) ? $pathes : array_shift($pathes);
@@ -1595,7 +1594,7 @@  discard block
 block discarded – undo
1595 1594
 			$parts = explode('.', $name);
1596 1595
 			if ($parts > 1 && mb_strlen($extension = '.'.array_pop($parts)) <= $fs_name_precision)
1597 1596
 			{
1598
-				$name = mb_substr(implode('.', $parts), 0, $fs_name_precision-mb_strlen($extension)).$extension;
1597
+				$name = mb_substr(implode('.', $parts), 0, $fs_name_precision - mb_strlen($extension)).$extension;
1599 1598
 			}
1600 1599
 			else
1601 1600
 			{
@@ -1616,9 +1615,8 @@  discard block
 block discarded – undo
1616 1615
 		$stat = array(
1617 1616
 			'ino'   => $info['fs_id'],
1618 1617
 			'name'  => $info['fs_name'],
1619
-			'mode'  => $info['fs_mode'] |
1620
-				($info['fs_mime'] == self::DIR_MIME_TYPE ? self::MODE_DIR :
1621
-				($info['fs_mime'] == self::SYMLINK_MIME_TYPE ? self::MODE_LINK : self::MODE_FILE)),	// required by the stream wrapper
1618
+			'mode'  => $info['fs_mode']|
1619
+				($info['fs_mime'] == self::DIR_MIME_TYPE ? self::MODE_DIR : ($info['fs_mime'] == self::SYMLINK_MIME_TYPE ? self::MODE_LINK : self::MODE_FILE)), // required by the stream wrapper
1622 1620
 			'size'  => $info['fs_size'],
1623 1621
 			'uid'   => $info['fs_uid'],
1624 1622
 			'gid'   => $info['fs_gid'],
@@ -1658,7 +1656,7 @@  discard block
 block discarded – undo
1658 1656
 	{
1659 1657
 		$egw_db = isset($GLOBALS['egw_setup']) ? $GLOBALS['egw_setup']->db : $GLOBALS['egw']->db;
1660 1658
 
1661
-		switch($egw_db->Type)
1659
+		switch ($egw_db->Type)
1662 1660
 		{
1663 1661
 			case 'mysqli':
1664 1662
 			case 'mysqlt':
@@ -1676,29 +1674,29 @@  discard block
 block discarded – undo
1676 1674
 
1677 1675
 		$dsn = self::$pdo_type.':dbname='.$egw_db->Database.($host ? ';host='.$host.($egw_db->Port ? ';port='.$egw_db->Port : '') : '');
1678 1676
 		// check once if pdo extension and DB specific driver is loaded or can be loaded
1679
-		static $pdo_available=null;
1677
+		static $pdo_available = null;
1680 1678
 		if (is_null($pdo_available))
1681 1679
 		{
1682
-			foreach(array('pdo','pdo_'.self::$pdo_type) as $ext)
1680
+			foreach (array('pdo', 'pdo_'.self::$pdo_type) as $ext)
1683 1681
 			{
1684
-				check_load_extension($ext,true);	// true = throw Exception
1682
+				check_load_extension($ext, true); // true = throw Exception
1685 1683
 			}
1686 1684
 			$pdo_available = true;
1687 1685
 		}
1688 1686
 		try {
1689
-			self::$pdo = new \PDO($dsn,$egw_db->User,$egw_db->Password,array(
1687
+			self::$pdo = new \PDO($dsn, $egw_db->User, $egw_db->Password, array(
1690 1688
 				\PDO::ATTR_ERRMODE=>\PDO::ERRMODE_EXCEPTION,
1691 1689
 			));
1692 1690
 		}
1693
-		catch(Exception $e)
1691
+		catch (Exception $e)
1694 1692
 		{
1695 1693
 			unset($e);
1696 1694
 			// Exception reveals password, so we ignore the exception and connect again without pw, to get the right exception without pw
1697
-			self::$pdo = new \PDO($dsn,$egw_db->User,'$egw_db->Password');
1695
+			self::$pdo = new \PDO($dsn, $egw_db->User, '$egw_db->Password');
1698 1696
 		}
1699 1697
 		// set client charset of the connection
1700 1698
 		$charset = translation::charset();
1701
-		switch(self::$pdo_type)
1699
+		switch (self::$pdo_type)
1702 1700
 		{
1703 1701
 			case 'mysql':
1704 1702
 				if (isset($egw_db->Link_ID->charset2mysql[$charset])) $charset = $egw_db->Link_ID->charset2mysql[$charset];
@@ -1724,7 +1722,7 @@  discard block
 block discarded – undo
1724 1722
 	{
1725 1723
 		if (is_numeric($time))
1726 1724
 		{
1727
-			$time = date('Y-m-d H:i:s',$time);
1725
+			$time = date('Y-m-d H:i:s', $time);
1728 1726
 		}
1729 1727
 		return $time;
1730 1728
 	}
@@ -1774,10 +1772,10 @@  discard block
 block discarded – undo
1774 1772
 		{
1775 1773
 			if (is_object($GLOBALS['egw_setup']->db))	// if we run under setup, query the db for the files dir
1776 1774
 			{
1777
-				$GLOBALS['egw_info']['server']['files_dir'] = $GLOBALS['egw_setup']->db->select('egw_config','config_value',array(
1775
+				$GLOBALS['egw_info']['server']['files_dir'] = $GLOBALS['egw_setup']->db->select('egw_config', 'config_value', array(
1778 1776
 					'config_name' => 'files_dir',
1779 1777
 					'config_app' => 'phpgwapi',
1780
-				),__LINE__,__FILE__)->fetchColumn();
1778
+				), __LINE__, __FILE__)->fetchColumn();
1781 1779
 			}
1782 1780
 		}
1783 1781
 		if (!$GLOBALS['egw_info']['server']['files_dir'])
@@ -1786,14 +1784,14 @@  discard block
 block discarded – undo
1786 1784
 		}
1787 1785
 		$hash = array();
1788 1786
 		$n = $id;
1789
-		while(($n = (int) ($n / self::HASH_MAX)))
1787
+		while (($n = (int)($n / self::HASH_MAX)))
1790 1788
 		{
1791
-			$hash[] = sprintf('%02d',$n % self::HASH_MAX);
1789
+			$hash[] = sprintf('%02d', $n % self::HASH_MAX);
1792 1790
 		}
1793
-		if (!$hash) $hash[] = '00';		// we need at least one directory, to not conflict with the dir-names
1794
-		array_unshift($hash,$id);
1791
+		if (!$hash) $hash[] = '00'; // we need at least one directory, to not conflict with the dir-names
1792
+		array_unshift($hash, $id);
1795 1793
 
1796
-		$path = '/sqlfs/'.implode('/',array_reverse($hash));
1794
+		$path = '/sqlfs/'.implode('/', array_reverse($hash));
1797 1795
 		//error_log(__METHOD__."($id) = '$path'");
1798 1796
 		return $GLOBALS['egw_info']['server']['files_dir'].$path;
1799 1797
 	}
@@ -1809,7 +1807,7 @@  discard block
 block discarded – undo
1809 1807
 
1810 1808
 		if ($parts['pass'] || $parts['scheme'])
1811 1809
 		{
1812
-			$url = $parts['scheme'].'://'.($parts['user'] ? $parts['user'].($parts['pass']?':...':'').'@' : '').
1810
+			$url = $parts['scheme'].'://'.($parts['user'] ? $parts['user'].($parts['pass'] ? ':...' : '').'@' : '').
1813 1811
 				$parts['host'].$parts['path'];
1814 1812
 		}
1815 1813
 	}
@@ -1824,10 +1822,10 @@  discard block
 block discarded – undo
1824 1822
 	{
1825 1823
 		$operation = self::DEFAULT_OPERATION;
1826 1824
 
1827
-		if (strpos(is_array($url) ? $url['query'] : $url,'storage=') !== false)
1825
+		if (strpos(is_array($url) ? $url['query'] : $url, 'storage=') !== false)
1828 1826
 		{
1829 1827
 			$query = null;
1830
-			parse_str(is_array($url) ? $url['query'] : Vfs::parse_url($url,PHP_URL_QUERY), $query);
1828
+			parse_str(is_array($url) ? $url['query'] : Vfs::parse_url($url, PHP_URL_QUERY), $query);
1831 1829
 			switch ($query['storage'])
1832 1830
 			{
1833 1831
 				case 'db':
@@ -1850,27 +1848,27 @@  discard block
 block discarded – undo
1850 1848
 	 * @param array $props array of array with values for keys 'name', 'ns', 'val' (null to delete the prop)
1851 1849
 	 * @return boolean true if props are updated, false otherwise (eg. ressource not found)
1852 1850
 	 */
1853
-	static function proppatch($path,array $props)
1851
+	static function proppatch($path, array $props)
1854 1852
 	{
1855 1853
 		if (self::LOG_LEVEL > 1) error_log(__METHOD__."(".array2string($path).','.array2string($props));
1856 1854
 		if (!is_numeric($path))
1857 1855
 		{
1858
-			if (!($stat = self::url_stat($path,0)))
1856
+			if (!($stat = self::url_stat($path, 0)))
1859 1857
 			{
1860 1858
 				return false;
1861 1859
 			}
1862 1860
 			$id = $stat['ino'];
1863 1861
 		}
1864
-		elseif(!($path = self::id2path($id=$path)))
1862
+		elseif (!($path = self::id2path($id = $path)))
1865 1863
 		{
1866 1864
 			return false;
1867 1865
 		}
1868
-		if (!Vfs::check_access($path,EGW_ACL_EDIT,$stat))
1866
+		if (!Vfs::check_access($path, EGW_ACL_EDIT, $stat))
1869 1867
 		{
1870
-			return false;	// permission denied
1868
+			return false; // permission denied
1871 1869
 		}
1872 1870
 		$ins_stmt = $del_stmt = null;
1873
-		foreach($props as &$prop)
1871
+		foreach ($props as &$prop)
1874 1872
 		{
1875 1873
 			if (!isset($prop['ns'])) $prop['ns'] = Vfs::DEFAULT_PROP_NAMESPACE;
1876 1874
 
@@ -1915,14 +1913,14 @@  discard block
 block discarded – undo
1915 1913
 	 * @return array|boolean false on error ($path_ids does not exist), array with props (values for keys 'name', 'ns', 'value'), or
1916 1914
 	 * 	fs_id/path => array of props for $depth==1 or is_array($path_ids)
1917 1915
 	 */
1918
-	static function propfind($path_ids,$ns=Vfs::DEFAULT_PROP_NAMESPACE)
1916
+	static function propfind($path_ids, $ns = Vfs::DEFAULT_PROP_NAMESPACE)
1919 1917
 	{
1920 1918
 		$ids = is_array($path_ids) ? $path_ids : array($path_ids);
1921
-		foreach($ids as &$id)
1919
+		foreach ($ids as &$id)
1922 1920
 		{
1923 1921
 			if (!is_numeric($id))
1924 1922
 			{
1925
-				if (!($stat = self::url_stat($id,0)))
1923
+				if (!($stat = self::url_stat($id, 0)))
1926 1924
 				{
1927 1925
 					if (self::LOG_LEVEL) error_log(__METHOD__."(".array2string($path_ids).",$ns) path '$id' not found!");
1928 1926
 					return false;
@@ -1932,7 +1930,7 @@  discard block
 block discarded – undo
1932 1930
 		}
1933 1931
 		if (count($ids) >= 1) array_map(function(&$v) { $v = (int)$v; },$ids);
1934 1932
 		$query = 'SELECT * FROM '.self::PROPS_TABLE.' WHERE (fs_id'.
1935
-			(count($ids) == 1 ? '='.(int)implode('',$ids) : ' IN ('.implode(',',$ids).')').')'.
1933
+			(count($ids) == 1 ? '='.(int)implode('', $ids) : ' IN ('.implode(',', $ids).')').')'.
1936 1934
 			(!is_null($ns) ? ' AND prop_namespace=?' : '');
1937 1935
 		if (self::LOG_LEVEL > 2) $query = '/* '.__METHOD__.': '.__LINE__.' */ '.$query;
1938 1936
 
@@ -1941,7 +1939,7 @@  discard block
 block discarded – undo
1941 1939
 		$stmt->execute(!is_null($ns) ? array($ns) : array());
1942 1940
 
1943 1941
 		$props = array();
1944
-		foreach($stmt as $row)
1942
+		foreach ($stmt as $row)
1945 1943
 		{
1946 1944
 			$props[$row['fs_id']][] = array(
1947 1945
 				'val'  => $row['prop_value'],
@@ -1951,19 +1949,19 @@  discard block
 block discarded – undo
1951 1949
 		}
1952 1950
 		if (!is_array($path_ids))
1953 1951
 		{
1954
-			$props = $props[$row['fs_id']] ? $props[$row['fs_id']] : array();	// return empty array for no props
1952
+			$props = $props[$row['fs_id']] ? $props[$row['fs_id']] : array(); // return empty array for no props
1955 1953
 		}
1956 1954
 		elseif ($props && isset($stat))	// need to map fs_id's to pathes
1957 1955
 		{
1958
-			foreach(self::id2path(array_keys($props)) as $id => $path)
1956
+			foreach (self::id2path(array_keys($props)) as $id => $path)
1959 1957
 			{
1960
-				$props[$path] =& $props[$id];
1958
+				$props[$path] = & $props[$id];
1961 1959
 				unset($props[$id]);
1962 1960
 			}
1963 1961
 		}
1964 1962
 		if (self::LOG_LEVEL > 1)
1965 1963
 		{
1966
-			foreach((array)$props as $k => $v)
1964
+			foreach ((array)$props as $k => $v)
1967 1965
 			{
1968 1966
 				error_log(__METHOD__."($path_ids,$ns) $k => ".array2string($v));
1969 1967
 			}
Please login to merge, or discard this patch.
Braces   +409 added lines, -102 removed lines patch added patch discarded remove patch
@@ -204,7 +204,10 @@  discard block
 block discarded – undo
204 204
 	 */
205 205
 	function stream_open ( $url, $mode, $options, &$opened_path, array $overwrite_new=null )
206 206
 	{
207
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$mode,$options)");
207
+		if (self::LOG_LEVEL > 1)
208
+		{
209
+			error_log(__METHOD__."($url,$mode,$options)");
210
+		}
208 211
 
209 212
 		$path = Vfs::parse_url($url,PHP_URL_PATH);
210 213
 		$this->operation = self::url2operation($url);
@@ -216,7 +219,9 @@  discard block
 block discarded – undo
216 219
 
217 220
 		parse_str(parse_url($url, PHP_URL_QUERY), $this->dir_url_params);
218 221
 
219
-		if (!is_null($overwrite_new) || !($stat = static::url_stat($path,STREAM_URL_STAT_QUIET)) || $mode[0] == 'x')	// file not found or file should NOT exist
222
+		if (!is_null($overwrite_new) || !($stat = static::url_stat($path,STREAM_URL_STAT_QUIET)) || $mode[0] == 'x')
223
+		{
224
+			// file not found or file should NOT exist
220 225
 		{
221 226
 			if ($mode[0] == 'r' ||	// does $mode require the file to exist (r,r+)
222 227
 				$mode[0] == 'x' && $stat ||	// or file should not exist, but does
@@ -224,7 +229,11 @@  discard block
 block discarded – undo
224 229
 				!Vfs::check_access($dir,Vfs::WRITABLE,$dir_stat))	// or we are not allowed to 																																			create it
225 230
 			{
226 231
 				self::_remove_password($url);
227
-				if (self::LOG_LEVEL) error_log(__METHOD__."($url,$mode,$options) file does not exist or can not be created!");
232
+		}
233
+				if (self::LOG_LEVEL)
234
+				{
235
+					error_log(__METHOD__."($url,$mode,$options) file does not exist or can not be created!");
236
+				}
228 237
 				if (($options & STREAM_REPORT_ERRORS))
229 238
 				{
230 239
 					trigger_error(__METHOD__."($url,$mode,$options) file does not exist or can not be created!",E_USER_WARNING);
@@ -236,7 +245,10 @@  discard block
 block discarded – undo
236 245
 			$new_file = true;
237 246
 			$query = 'INSERT INTO '.self::TABLE.' (fs_name,fs_dir,fs_mode,fs_uid,fs_gid,fs_created,fs_modified,fs_creator,fs_mime,fs_size,fs_active'.
238 247
 				') VALUES (:fs_name,:fs_dir,:fs_mode,:fs_uid,:fs_gid,:fs_created,:fs_modified,:fs_creator,:fs_mime,:fs_size,:fs_active)';
239
-			if (self::LOG_LEVEL > 2) $query = '/* '.__METHOD__.': '.__LINE__.' */ '.$query;
248
+			if (self::LOG_LEVEL > 2)
249
+			{
250
+				$query = '/* '.__METHOD__.': '.__LINE__.' */ '.$query;
251
+			}
240 252
 			$stmt = self::$pdo->prepare($query);
241 253
 			$values = array(
242 254
 				'fs_name' => self::limit_filename(Vfs::basename($path)),
@@ -254,11 +266,17 @@  discard block
 block discarded – undo
254 266
 				'fs_size'     => 0,
255 267
 				'fs_active'   => self::_pdo_boolean(true),
256 268
 			);
257
-			if ($overwrite_new) $values = array_merge($values,$overwrite_new);
269
+			if ($overwrite_new)
270
+			{
271
+				$values = array_merge($values,$overwrite_new);
272
+			}
258 273
 			if (!$stmt->execute($values) || !($this->opened_fs_id = self::$pdo->lastInsertId('egw_sqlfs_fs_id_seq')))
259 274
 			{
260 275
 				$this->opened_stream = $this->opened_path = $this->opened_mode = null;
261
-				if (self::LOG_LEVEL) error_log(__METHOD__."($url,$mode,$options) execute() failed: ".self::$pdo->errorInfo());
276
+				if (self::LOG_LEVEL)
277
+				{
278
+					error_log(__METHOD__."($url,$mode,$options) execute() failed: ".self::$pdo->errorInfo());
279
+				}
262 280
 				return false;
263 281
 			}
264 282
 			if ($this->operation == self::STORE2DB)
@@ -270,14 +288,20 @@  discard block
 block discarded – undo
270 288
 			elseif(!file_exists($fs_dir=Vfs::dirname(self::_fs_path($this->opened_fs_id))))
271 289
 			{
272 290
 				$umaskbefore = umask();
273
-				if (self::LOG_LEVEL > 1) error_log(__METHOD__." about to call mkdir for $fs_dir # Present UMASK:".decoct($umaskbefore)." called from:".function_backtrace());
291
+				if (self::LOG_LEVEL > 1)
292
+				{
293
+					error_log(__METHOD__." about to call mkdir for $fs_dir # Present UMASK:".decoct($umaskbefore)." called from:".function_backtrace());
294
+				}
274 295
 				self::mkdir_recursive($fs_dir,0700,true);
275 296
 			}
276 297
 		}
277 298
 		// check if opend file is a directory
278 299
 		elseif($stat && ($stat['mode'] & self::MODE_DIR) == self::MODE_DIR)
279 300
 		{
280
-				if (self::LOG_LEVEL) error_log(__METHOD__."($url,$mode,$options) Is a directory!");
301
+				if (self::LOG_LEVEL)
302
+				{
303
+					error_log(__METHOD__."($url,$mode,$options) Is a directory!");
304
+				}
281 305
 				if (($options & STREAM_REPORT_ERRORS))
282 306
 				{
283 307
 					trigger_error(__METHOD__."($url,$mode,$options) Is a directory!",E_USER_WARNING);
@@ -288,11 +312,17 @@  discard block
 block discarded – undo
288 312
 		else
289 313
 		{
290 314
 			if ($mode == 'r' && !Vfs::check_access($url,Vfs::READABLE ,$stat) ||// we are not allowed to read
291
-				$mode != 'r' && !Vfs::check_access($url,Vfs::WRITABLE,$stat))	// or edit it
315
+				$mode != 'r' && !Vfs::check_access($url,Vfs::WRITABLE,$stat))
316
+			{
317
+				// or edit it
292 318
 			{
293 319
 				self::_remove_password($url);
320
+			}
294 321
 				$op = $mode == 'r' ? 'read' : 'edited';
295
-				if (self::LOG_LEVEL) error_log(__METHOD__."($url,$mode,$options) file can not be $op!");
322
+				if (self::LOG_LEVEL)
323
+				{
324
+					error_log(__METHOD__."($url,$mode,$options) file can not be $op!");
325
+				}
296 326
 				if (($options & STREAM_REPORT_ERRORS))
297 327
 				{
298 328
 					trigger_error(__METHOD__."($url,$mode,$options) file can not be $op!",E_USER_WARNING);
@@ -324,7 +354,10 @@  discard block
 block discarded – undo
324 354
 		// do we operate directly on the filesystem --> open file from there
325 355
 		if ($this->operation == self::STORE2FS)
326 356
 		{
327
-			if (self::LOG_LEVEL > 1) error_log(__METHOD__." fopen (may create a directory? mkdir) ($this->opened_fs_id,$mode,$options)");
357
+			if (self::LOG_LEVEL > 1)
358
+			{
359
+				error_log(__METHOD__." fopen (may create a directory? mkdir) ($this->opened_fs_id,$mode,$options)");
360
+			}
328 361
 			if (!($this->opened_stream = fopen(self::_fs_path($this->opened_fs_id),$mode)) && $new_file)
329 362
 			{
330 363
 				// delete db entry again, if we are not able to open a new(!) file
@@ -333,11 +366,17 @@  discard block
 block discarded – undo
333 366
 				$stmt->execute(array('fs_id' => $this->opened_fs_id));
334 367
 			}
335 368
 		}
336
-		if ($mode[0] == 'a')	// append modes: a, a+
369
+		if ($mode[0] == 'a')
370
+		{
371
+			// append modes: a, a+
337 372
 		{
338 373
 			$this->stream_seek(0,SEEK_END);
339 374
 		}
340
-		if (!is_resource($this->opened_stream)) error_log(__METHOD__."($url,$mode,$options) NO stream, returning false!");
375
+		}
376
+		if (!is_resource($this->opened_stream))
377
+		{
378
+			error_log(__METHOD__."($url,$mode,$options) NO stream, returning false!");
379
+		}
341 380
 
342 381
 		return is_resource($this->opened_stream);
343 382
 	}
@@ -349,7 +388,10 @@  discard block
 block discarded – undo
349 388
 	 */
350 389
 	function stream_close ( )
351 390
 	{
352
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."()");
391
+		if (self::LOG_LEVEL > 1)
392
+		{
393
+			error_log(__METHOD__."()");
394
+		}
353 395
 
354 396
 		if (is_null($this->opened_path) || !is_resource($this->opened_stream) || !$this->opened_fs_id)
355 397
 		{
@@ -419,7 +461,10 @@  discard block
 block discarded – undo
419 461
 	 */
420 462
 	function stream_read ( $count )
421 463
 	{
422
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($count) pos=$this->opened_pos");
464
+		if (self::LOG_LEVEL > 1)
465
+		{
466
+			error_log(__METHOD__."($count) pos=$this->opened_pos");
467
+		}
423 468
 
424 469
 		if (is_resource($this->opened_stream))
425 470
 		{
@@ -441,7 +486,10 @@  discard block
 block discarded – undo
441 486
 	 */
442 487
 	function stream_write ( $data )
443 488
 	{
444
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($data)");
489
+		if (self::LOG_LEVEL > 1)
490
+		{
491
+			error_log(__METHOD__."($data)");
492
+		}
445 493
 
446 494
 		if (is_resource($this->opened_stream))
447 495
 		{
@@ -478,7 +526,10 @@  discard block
 block discarded – undo
478 526
 	 */
479 527
  	function stream_tell ( )
480 528
  	{
481
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."()");
529
+		if (self::LOG_LEVEL > 1)
530
+		{
531
+			error_log(__METHOD__."()");
532
+		}
482 533
 
483 534
 		if (is_resource($this->opened_stream))
484 535
 		{
@@ -501,7 +552,10 @@  discard block
 block discarded – undo
501 552
  	 */
502 553
 	function stream_seek ( $offset, $whence )
503 554
 	{
504
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($offset,$whence)");
555
+		if (self::LOG_LEVEL > 1)
556
+		{
557
+			error_log(__METHOD__."($offset,$whence)");
558
+		}
505 559
 
506 560
 		if (is_resource($this->opened_stream))
507 561
 		{
@@ -519,7 +573,10 @@  discard block
 block discarded – undo
519 573
 	 */
520 574
 	function stream_flush ( )
521 575
 	{
522
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."()");
576
+		if (self::LOG_LEVEL > 1)
577
+		{
578
+			error_log(__METHOD__."()");
579
+		}
523 580
 
524 581
 		if (is_resource($this->opened_stream))
525 582
 		{
@@ -544,7 +601,10 @@  discard block
 block discarded – undo
544 601
 	 */
545 602
 	function stream_stat ( )
546 603
 	{
547
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($this->opened_path)");
604
+		if (self::LOG_LEVEL > 1)
605
+		{
606
+			error_log(__METHOD__."($this->opened_path)");
607
+		}
548 608
 
549 609
 		return $this->url_stat($this->opened_path,0);
550 610
 	}
@@ -560,24 +620,36 @@  discard block
 block discarded – undo
560 620
 	 */
561 621
 	static function unlink ( $url, $parent_stat=null )
562 622
 	{
563
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url)");
623
+		if (self::LOG_LEVEL > 1)
624
+		{
625
+			error_log(__METHOD__."($url)");
626
+		}
564 627
 
565 628
 		$path = Vfs::parse_url($url,PHP_URL_PATH);
566 629
 
567 630
 		// need to get parent stat from Sqlfs, not Vfs
568
-		if (!isset($parent_stat)) $parent_stat = static::url_stat(Vfs::dirname($path), STREAM_URL_STAT_LINK);
631
+		if (!isset($parent_stat))
632
+		{
633
+			$parent_stat = static::url_stat(Vfs::dirname($path), STREAM_URL_STAT_LINK);
634
+		}
569 635
 
570 636
 		if (!$parent_stat || !($stat = self::url_stat($path,STREAM_URL_STAT_LINK)) ||
571 637
 			!Vfs::check_access(Vfs::dirname($path),Vfs::WRITABLE, $parent_stat))
572 638
 		{
573 639
 			self::_remove_password($url);
574
-			if (self::LOG_LEVEL) error_log(__METHOD__."($url) permission denied!");
640
+			if (self::LOG_LEVEL)
641
+			{
642
+				error_log(__METHOD__."($url) permission denied!");
643
+			}
575 644
 			return false;	// no permission or file does not exist
576 645
 		}
577 646
 		if ($stat['mime'] == self::DIR_MIME_TYPE)
578 647
 		{
579 648
 			self::_remove_password($url);
580
-			if (self::LOG_LEVEL) error_log(__METHOD__."($url) is NO file!");
649
+			if (self::LOG_LEVEL)
650
+			{
651
+				error_log(__METHOD__."($url) is NO file!");
652
+			}
581 653
 			return false;	// no permission or file does not exist
582 654
 		}
583 655
 		$stmt = self::$pdo->prepare('DELETE FROM '.self::TABLE.' WHERE fs_id=:fs_id');
@@ -612,7 +684,10 @@  discard block
 block discarded – undo
612 684
 	 */
613 685
 	static function rename ( $url_from, $url_to)
614 686
 	{
615
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url_from,$url_to)");
687
+		if (self::LOG_LEVEL > 1)
688
+		{
689
+			error_log(__METHOD__."($url_from,$url_to)");
690
+		}
616 691
 
617 692
 		$path_from = Vfs::parse_url($url_from,PHP_URL_PATH);
618 693
 		$from_dir = Vfs::dirname($path_from);
@@ -626,14 +701,20 @@  discard block
 block discarded – undo
626 701
 		{
627 702
 			self::_remove_password($url_from);
628 703
 			self::_remove_password($url_to);
629
-			if (self::LOG_LEVEL) error_log(__METHOD__."($url_from,$url_to): $path_from permission denied!");
704
+			if (self::LOG_LEVEL)
705
+			{
706
+				error_log(__METHOD__."($url_from,$url_to): $path_from permission denied!");
707
+			}
630 708
 			return false;	// no permission or file does not exist
631 709
 		}
632 710
 		if (!Vfs::check_access($to_dir, Vfs::WRITABLE, $to_dir_stat = static::url_stat($to_dir, 0)))
633 711
 		{
634 712
 			self::_remove_password($url_from);
635 713
 			self::_remove_password($url_to);
636
-			if (self::LOG_LEVEL) error_log(__METHOD__."($url_from,$url_to): $path_to permission denied!");
714
+			if (self::LOG_LEVEL)
715
+			{
716
+				error_log(__METHOD__."($url_from,$url_to): $path_to permission denied!");
717
+			}
637 718
 			return false;	// no permission or parent-dir does not exist
638 719
 		}
639 720
 		// the filesystem stream-wrapper does NOT allow to rename files to directories, as this makes problems
@@ -644,14 +725,20 @@  discard block
 block discarded – undo
644 725
 			self::_remove_password($url_from);
645 726
 			self::_remove_password($url_to);
646 727
 			$is_dir = $to_stat['mime'] === self::DIR_MIME_TYPE ? 'a' : 'no';
647
-			if (self::LOG_LEVEL) error_log(__METHOD__."($url_to,$url_from) $path_to is $is_dir directory!");
728
+			if (self::LOG_LEVEL)
729
+			{
730
+				error_log(__METHOD__."($url_to,$url_from) $path_to is $is_dir directory!");
731
+			}
648 732
 			return false;	// no permission or file does not exist
649 733
 		}
650 734
 		// if destination file already exists, delete it
651 735
 		if ($to_stat && !static::unlink($url_to,$operation))
652 736
 		{
653 737
 			self::_remove_password($url_to);
654
-			if (self::LOG_LEVEL) error_log(__METHOD__."($url_to,$url_from) can't unlink existing $url_to!");
738
+			if (self::LOG_LEVEL)
739
+			{
740
+				error_log(__METHOD__."($url_to,$url_from) can't unlink existing $url_to!");
741
+			}
655 742
 			return false;
656 743
 		}
657 744
 		unset(self::$stat_cache[$path_from]);
@@ -689,7 +776,10 @@  discard block
 block discarded – undo
689 776
 	{
690 777
 		$maxdepth=10;
691 778
 		$depth2propagate = (int)$depth + 1;
692
-		if ($depth2propagate > $maxdepth) return is_dir($pathname);
779
+		if ($depth2propagate > $maxdepth)
780
+		{
781
+			return is_dir($pathname);
782
+		}
693 783
     	is_dir(Vfs::dirname($pathname)) || self::mkdir_recursive(Vfs::dirname($pathname), $mode, $depth2propagate);
694 784
     	return is_dir($pathname) || @mkdir($pathname, $mode);
695 785
 	}
@@ -707,14 +797,23 @@  discard block
 block discarded – undo
707 797
 	 */
708 798
 	static function mkdir ( $url, $mode, $options )
709 799
 	{
710
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$mode,$options)");
711
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__." called from:".function_backtrace());
800
+		if (self::LOG_LEVEL > 1)
801
+		{
802
+			error_log(__METHOD__."($url,$mode,$options)");
803
+		}
804
+		if (self::LOG_LEVEL > 1)
805
+		{
806
+			error_log(__METHOD__." called from:".function_backtrace());
807
+		}
712 808
 		$path = Vfs::parse_url($url,PHP_URL_PATH);
713 809
 
714 810
 		if (self::url_stat($path,STREAM_URL_STAT_QUIET))
715 811
 		{
716 812
 			self::_remove_password($url);
717
-			if (self::LOG_LEVEL) error_log(__METHOD__."('$url',$mode,$options) already exist!");
813
+			if (self::LOG_LEVEL)
814
+			{
815
+				error_log(__METHOD__."('$url',$mode,$options) already exist!");
816
+			}
718 817
 			if (!($options & STREAM_REPORT_ERRORS))
719 818
 			{
720 819
 				//throw new Exception(__METHOD__."('$url',$mode,$options) already exist!");
@@ -723,14 +822,20 @@  discard block
 block discarded – undo
723 822
 			return false;
724 823
 		}
725 824
 		$parent_path = Vfs::dirname($path);
726
-		if (($query = Vfs::parse_url($url,PHP_URL_QUERY))) $parent_path .= '?'.$query;
825
+		if (($query = Vfs::parse_url($url,PHP_URL_QUERY)))
826
+		{
827
+			$parent_path .= '?'.$query;
828
+		}
727 829
 		$parent = self::url_stat($parent_path,STREAM_URL_STAT_QUIET);
728 830
 
729 831
 		// check if we should also create all non-existing path components and our parent does not exist,
730 832
 		// if yes call ourself recursive with the parent directory
731 833
 		if (($options & STREAM_MKDIR_RECURSIVE) && $parent_path != '/' && !$parent)
732 834
 		{
733
-			if (self::LOG_LEVEL > 1) error_log(__METHOD__." creating parents: $parent_path, $mode");
835
+			if (self::LOG_LEVEL > 1)
836
+			{
837
+				error_log(__METHOD__." creating parents: $parent_path, $mode");
838
+			}
734 839
 			if (!self::mkdir($parent_path,$mode,$options))
735 840
 			{
736 841
 				return false;
@@ -740,7 +845,10 @@  discard block
 block discarded – undo
740 845
 		if (!$parent || !Vfs::check_access($parent_path,Vfs::WRITABLE,$parent))
741 846
 		{
742 847
 			self::_remove_password($url);
743
-			if (self::LOG_LEVEL) error_log(__METHOD__."('$url',$mode,$options) permission denied!");
848
+			if (self::LOG_LEVEL)
849
+			{
850
+				error_log(__METHOD__."('$url',$mode,$options) permission denied!");
851
+			}
744 852
 			if (!($options & STREAM_REPORT_ERRORS))
745 853
 			{
746 854
 				trigger_error(__METHOD__."('$url',$mode,$options) permission denied!",E_USER_WARNING);
@@ -774,10 +882,13 @@  discard block
 block discarded – undo
774 882
 				'fs_dir'  => $parent['ino'],
775 883
 				'fs_active' => self::_pdo_boolean(true),
776 884
 				'fs_name' => self::limit_filename(Vfs::basename($path)),
777
-			)) && $stmt->fetchColumn() > 1)	// if there's more then one --> remove our new dir
885
+			)) && $stmt->fetchColumn() > 1)
886
+			{
887
+				// if there's more then one --> remove our new dir
778 888
 			{
779 889
 				self::$pdo->query('DELETE FROM '.self::TABLE.' WHERE fs_id='.$new_fs_id);
780 890
 			}
891
+			}
781 892
 		}
782 893
 		return $ok;
783 894
 	}
@@ -794,7 +905,10 @@  discard block
 block discarded – undo
794 905
 	 */
795 906
 	static function rmdir ( $url, $options )
796 907
 	{
797
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url)");
908
+		if (self::LOG_LEVEL > 1)
909
+		{
910
+			error_log(__METHOD__."($url)");
911
+		}
798 912
 
799 913
 		$path = Vfs::parse_url($url,PHP_URL_PATH);
800 914
 		$parent = Vfs::dirname($path);
@@ -805,7 +919,10 @@  discard block
 block discarded – undo
805 919
 			self::_remove_password($url);
806 920
 			$err_msg = __METHOD__."($url,$options) ".(!$stat ? 'not found!' :
807 921
 				($stat['mime'] != self::DIR_MIME_TYPE ? 'not a directory!' : 'permission denied!'));
808
-			if (self::LOG_LEVEL) error_log($err_msg);
922
+			if (self::LOG_LEVEL)
923
+			{
924
+				error_log($err_msg);
925
+			}
809 926
 			if (!($options & STREAM_REPORT_ERRORS))
810 927
 			{
811 928
 				trigger_error($err_msg,E_USER_WARNING);
@@ -817,7 +934,10 @@  discard block
 block discarded – undo
817 934
 		if ($stmt->fetchColumn())
818 935
 		{
819 936
 			self::_remove_password($url);
820
-			if (self::LOG_LEVEL) error_log(__METHOD__."($url,$options) dir is not empty!");
937
+			if (self::LOG_LEVEL)
938
+			{
939
+				error_log(__METHOD__."($url,$options) dir is not empty!");
940
+			}
821 941
 			if (!($options & STREAM_REPORT_ERRORS))
822 942
 			{
823 943
 				trigger_error(__METHOD__."('$url',$options) dir is not empty!",E_USER_WARNING);
@@ -849,7 +969,10 @@  discard block
 block discarded – undo
849 969
 	static function touch($url,$time=null,$atime=null)
850 970
 	{
851 971
 		unset($atime);	// not used
852
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url, $time)");
972
+		if (self::LOG_LEVEL > 1)
973
+		{
974
+			error_log(__METHOD__."($url, $time)");
975
+		}
853 976
 
854 977
 		$path = Vfs::parse_url($url,PHP_URL_PATH);
855 978
 
@@ -885,25 +1008,37 @@  discard block
 block discarded – undo
885 1008
 	 */
886 1009
 	static function chown($url,$owner)
887 1010
 	{
888
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$owner)");
1011
+		if (self::LOG_LEVEL > 1)
1012
+		{
1013
+			error_log(__METHOD__."($url,$owner)");
1014
+		}
889 1015
 
890 1016
 		$path = Vfs::parse_url($url,PHP_URL_PATH);
891 1017
 
892 1018
 		if (!($stat = self::url_stat($path,0)))
893 1019
 		{
894
-			if (self::LOG_LEVEL) error_log(__METHOD__."($url,$owner) no such file or directory!");
1020
+			if (self::LOG_LEVEL)
1021
+			{
1022
+				error_log(__METHOD__."($url,$owner) no such file or directory!");
1023
+			}
895 1024
 			trigger_error("No such file or directory $url !",E_USER_WARNING);
896 1025
 			return false;
897 1026
 		}
898 1027
 		if (!Vfs::$is_root)
899 1028
 		{
900
-			if (self::LOG_LEVEL) error_log(__METHOD__."($url,$owner) only root can do that!");
1029
+			if (self::LOG_LEVEL)
1030
+			{
1031
+				error_log(__METHOD__."($url,$owner) only root can do that!");
1032
+			}
901 1033
 			trigger_error("Only root can do that!",E_USER_WARNING);
902 1034
 			return false;
903 1035
 		}
904
-		if ($owner < 0 || $owner && !$GLOBALS['egw']->accounts->id2name($owner))	// not a user (0 == root)
1036
+		if ($owner < 0 || $owner && !$GLOBALS['egw']->accounts->id2name($owner))
1037
+		{
1038
+			// not a user (0 == root)
905 1039
 		{
906 1040
 			if (self::LOG_LEVEL) error_log(__METHOD__."($url,$owner) unknown (numeric) user id!");
1041
+		}
907 1042
 			trigger_error(__METHOD__."($url,$owner) Unknown (numeric) user id!",E_USER_WARNING);
908 1043
 			//throw new Exception(__METHOD__."($url,$owner) Unknown (numeric) user id!");
909 1044
 			return false;
@@ -911,7 +1046,10 @@  discard block
 block discarded – undo
911 1046
 		$stmt = self::$pdo->prepare('UPDATE '.self::TABLE.' SET fs_uid=:fs_uid WHERE fs_id=:fs_id');
912 1047
 
913 1048
 		// update stat-cache
914
-		if ($path != '/' && substr($path,-1) == '/') $path = substr($path, 0, -1);
1049
+		if ($path != '/' && substr($path,-1) == '/')
1050
+		{
1051
+			$path = substr($path, 0, -1);
1052
+		}
915 1053
 		self::$stat_cache[$path]['fs_uid'] = $owner;
916 1054
 
917 1055
 		return $stmt->execute(array(
@@ -929,34 +1067,53 @@  discard block
 block discarded – undo
929 1067
 	 */
930 1068
 	static function chgrp($url,$owner)
931 1069
 	{
932
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$owner)");
1070
+		if (self::LOG_LEVEL > 1)
1071
+		{
1072
+			error_log(__METHOD__."($url,$owner)");
1073
+		}
933 1074
 
934 1075
 		$path = Vfs::parse_url($url,PHP_URL_PATH);
935 1076
 
936 1077
 		if (!($stat = self::url_stat($path,0)))
937 1078
 		{
938
-			if (self::LOG_LEVEL) error_log(__METHOD__."($url,$owner) no such file or directory!");
1079
+			if (self::LOG_LEVEL)
1080
+			{
1081
+				error_log(__METHOD__."($url,$owner) no such file or directory!");
1082
+			}
939 1083
 			trigger_error("No such file or directory $url !",E_USER_WARNING);
940 1084
 			return false;
941 1085
 		}
942 1086
 		if (!Vfs::has_owner_rights($path,$stat))
943 1087
 		{
944
-			if (self::LOG_LEVEL) error_log(__METHOD__."($url,$owner) only owner or root can do that!");
1088
+			if (self::LOG_LEVEL)
1089
+			{
1090
+				error_log(__METHOD__."($url,$owner) only owner or root can do that!");
1091
+			}
945 1092
 			trigger_error("Only owner or root can do that!",E_USER_WARNING);
946 1093
 			return false;
947 1094
 		}
948
-		if ($owner < 0) $owner = -$owner;	// sqlfs uses a positiv group id's!
1095
+		if ($owner < 0)
1096
+		{
1097
+			$owner = -$owner;
1098
+		}
1099
+		// sqlfs uses a positiv group id's!
949 1100
 
950
-		if ($owner && !$GLOBALS['egw']->accounts->id2name(-$owner))	// not a group
1101
+		if ($owner && !$GLOBALS['egw']->accounts->id2name(-$owner))
1102
+		{
1103
+			// not a group
951 1104
 		{
952 1105
 			if (self::LOG_LEVEL) error_log(__METHOD__."($url,$owner) unknown (numeric) group id!");
1106
+		}
953 1107
 			trigger_error("Unknown (numeric) group id!",E_USER_WARNING);
954 1108
 			return false;
955 1109
 		}
956 1110
 		$stmt = self::$pdo->prepare('UPDATE '.self::TABLE.' SET fs_gid=:fs_gid WHERE fs_id=:fs_id');
957 1111
 
958 1112
 		// update stat-cache
959
-		if ($path != '/' && substr($path,-1) == '/') $path = substr($path, 0, -1);
1113
+		if ($path != '/' && substr($path,-1) == '/')
1114
+		{
1115
+			$path = substr($path, 0, -1);
1116
+		}
960 1117
 		self::$stat_cache[$path]['fs_gid'] = $owner;
961 1118
 
962 1119
 		return $stmt->execute(array(
@@ -974,32 +1131,47 @@  discard block
 block discarded – undo
974 1131
 	 */
975 1132
 	static function chmod($url,$mode)
976 1133
 	{
977
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url, $mode)");
1134
+		if (self::LOG_LEVEL > 1)
1135
+		{
1136
+			error_log(__METHOD__."($url, $mode)");
1137
+		}
978 1138
 
979 1139
 		$path = Vfs::parse_url($url,PHP_URL_PATH);
980 1140
 
981 1141
 		if (!($stat = self::url_stat($path,0)))
982 1142
 		{
983
-			if (self::LOG_LEVEL) error_log(__METHOD__."($url, $mode) no such file or directory!");
1143
+			if (self::LOG_LEVEL)
1144
+			{
1145
+				error_log(__METHOD__."($url, $mode) no such file or directory!");
1146
+			}
984 1147
 			trigger_error("No such file or directory $url !",E_USER_WARNING);
985 1148
 			return false;
986 1149
 		}
987 1150
 		if (!Vfs::has_owner_rights($path,$stat))
988 1151
 		{
989
-			if (self::LOG_LEVEL) error_log(__METHOD__."($url, $mode) only owner or root can do that!");
1152
+			if (self::LOG_LEVEL)
1153
+			{
1154
+				error_log(__METHOD__."($url, $mode) only owner or root can do that!");
1155
+			}
990 1156
 			trigger_error("Only owner or root can do that!",E_USER_WARNING);
991 1157
 			return false;
992 1158
 		}
993
-		if (!is_numeric($mode))	// not a mode
1159
+		if (!is_numeric($mode))
1160
+		{
1161
+			// not a mode
994 1162
 		{
995 1163
 			if (self::LOG_LEVEL) error_log(__METHOD__."($url, $mode) no (numeric) mode!");
1164
+		}
996 1165
 			trigger_error("No (numeric) mode!",E_USER_WARNING);
997 1166
 			return false;
998 1167
 		}
999 1168
 		$stmt = self::$pdo->prepare('UPDATE '.self::TABLE.' SET fs_mode=:fs_mode WHERE fs_id=:fs_id');
1000 1169
 
1001 1170
 		// update stat cache
1002
-		if ($path != '/' && substr($path,-1) == '/') $path = substr($path, 0, -1);
1171
+		if ($path != '/' && substr($path,-1) == '/')
1172
+		{
1173
+			$path = substr($path, 0, -1);
1174
+		}
1003 1175
 		self::$stat_cache[$path]['fs_mode'] = ((int) $mode) & 0777;
1004 1176
 
1005 1177
 		return $stmt->execute(array(
@@ -1024,11 +1196,17 @@  discard block
 block discarded – undo
1024 1196
 
1025 1197
 		if (!($stat = self::url_stat($url,0)) || 		// dir not found
1026 1198
 			$stat['mime'] != self::DIR_MIME_TYPE ||		// no dir
1027
-			!Vfs::check_access($url,Vfs::EXECUTABLE|Vfs::READABLE,$stat))	// no access
1199
+			!Vfs::check_access($url,Vfs::EXECUTABLE|Vfs::READABLE,$stat))
1200
+		{
1201
+			// no access
1028 1202
 		{
1029 1203
 			self::_remove_password($url);
1204
+		}
1030 1205
 			$msg = $stat['mime'] != self::DIR_MIME_TYPE ? "$url is no directory" : 'permission denied';
1031
-			if (self::LOG_LEVEL) error_log(__METHOD__."('$url',$options) $msg!");
1206
+			if (self::LOG_LEVEL)
1207
+			{
1208
+				error_log(__METHOD__."('$url',$options) $msg!");
1209
+			}
1032 1210
 			$this->opened_dir = null;
1033 1211
 			return false;
1034 1212
 		}
@@ -1037,7 +1215,10 @@  discard block
 block discarded – undo
1037 1215
 			' FROM '.self::TABLE.' WHERE fs_dir=? AND fs_active='.self::_pdo_boolean(true).
1038 1216
 			" ORDER BY fs_mime='httpd/unix-directory' DESC, fs_name ASC";
1039 1217
 		//if (self::LOG_LEVEL > 2) $query = '/* '.__METHOD__.': '.__LINE__.' */ '.$query;
1040
-		if (self::LOG_LEVEL > 2) $query = '/* '.__METHOD__."($url,$options)".' */ '.$query;
1218
+		if (self::LOG_LEVEL > 2)
1219
+		{
1220
+			$query = '/* '.__METHOD__."($url,$options)".' */ '.$query;
1221
+		}
1041 1222
 
1042 1223
 		$stmt = self::$pdo->prepare($query);
1043 1224
 		$stmt->setFetchMode(\PDO::FETCH_ASSOC);
@@ -1049,7 +1230,10 @@  discard block
 block discarded – undo
1049 1230
 				self::$stat_cache[Vfs::concat($path,$file['fs_name'])] = $file;
1050 1231
 			}
1051 1232
 		}
1052
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$options): ".implode(', ',$this->opened_dir));
1233
+		if (self::LOG_LEVEL > 1)
1234
+		{
1235
+			error_log(__METHOD__."($url,$options): ".implode(', ',$this->opened_dir));
1236
+		}
1053 1237
 		reset($this->opened_dir);
1054 1238
 
1055 1239
 		return true;
@@ -1088,9 +1272,16 @@  discard block
 block discarded – undo
1088 1272
 		if (is_null($max_subquery_depth))
1089 1273
 		{
1090 1274
 			$max_subquery_depth = $GLOBALS['egw_info']['server']['max_subquery_depth'];
1091
-			if (!$max_subquery_depth) $max_subquery_depth = 7;	// setting current default of 7, if nothing set
1275
+			if (!$max_subquery_depth)
1276
+			{
1277
+				$max_subquery_depth = 7;
1278
+			}
1279
+			// setting current default of 7, if nothing set
1280
+		}
1281
+		if (self::LOG_LEVEL > 1)
1282
+		{
1283
+			error_log(__METHOD__."('$url',$flags,$eacl_access)");
1092 1284
 		}
1093
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$url',$flags,$eacl_access)");
1094 1285
 
1095 1286
 		$path = Vfs::parse_url($url,PHP_URL_PATH);
1096 1287
 
@@ -1156,7 +1347,10 @@  discard block
 block discarded – undo
1156 1347
 						if (!Vfs::$user)
1157 1348
 						{
1158 1349
 							self::_remove_password($url);
1159
-							if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$url',$flags) permission denied, no user-id and not root!");
1350
+							if (self::LOG_LEVEL > 1)
1351
+							{
1352
+								error_log(__METHOD__."('$url',$flags) permission denied, no user-id and not root!");
1353
+							}
1160 1354
 							return false;
1161 1355
 						}
1162 1356
 						$query .= ' AND '.self::_sql_readable();
@@ -1167,7 +1361,10 @@  discard block
 block discarded – undo
1167 1361
 					$query = str_replace('fs_name'.self::$case_sensitive_equal.'?','fs_name'.self::$case_sensitive_equal.self::$pdo->quote($name),$base_query).'('.$query.')';
1168 1362
 				}
1169 1363
 			}
1170
-			if (self::LOG_LEVEL > 2) $query = '/* '.__METHOD__."($url,$flags,$eacl_access)".' */ '.$query;
1364
+			if (self::LOG_LEVEL > 2)
1365
+			{
1366
+				$query = '/* '.__METHOD__."($url,$flags,$eacl_access)".' */ '.$query;
1367
+			}
1171 1368
 			//if (self::LOG_LEVEL > 2) $query = '/* '.__METHOD__.': '.__LINE__.' */ '.$query;
1172 1369
 
1173 1370
 			if (!($result = self::$pdo->query($query)) || !($info = $result->fetch(\PDO::FETCH_ASSOC)))
@@ -1190,12 +1387,18 @@  discard block
 block discarded – undo
1190 1387
 			$GLOBALS['egw_info']['server']['max_subquery_depth'] = --$max_subquery_depth;
1191 1388
 			error_log(__METHOD__."() decremented max_subquery_depth to $max_subquery_depth");
1192 1389
 			config::save_value('max_subquery_depth', $max_subquery_depth, 'phpgwapi');
1193
-			if (method_exists($GLOBALS['egw'],'invalidate_session_cache')) $GLOBALS['egw']->invalidate_session_cache();
1390
+			if (method_exists($GLOBALS['egw'],'invalidate_session_cache'))
1391
+			{
1392
+				$GLOBALS['egw']->invalidate_session_cache();
1393
+			}
1194 1394
 			return self::url_stat($url, $flags, $eacl_access);
1195 1395
 		}
1196 1396
 		self::$stat_cache[$path] = $info;
1197 1397
 
1198
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$flags)=".array2string($info));
1398
+		if (self::LOG_LEVEL > 1)
1399
+		{
1400
+			error_log(__METHOD__."($url,$flags)=".array2string($info));
1401
+		}
1199 1402
 		return self::_vfsinfo2stat($info);
1200 1403
 	}
1201 1404
 
@@ -1232,9 +1435,15 @@  discard block
 block discarded – undo
1232 1435
 	 */
1233 1436
 	function dir_readdir ( )
1234 1437
 	{
1235
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."( )");
1438
+		if (self::LOG_LEVEL > 1)
1439
+		{
1440
+			error_log(__METHOD__."( )");
1441
+		}
1236 1442
 
1237
-		if (!is_array($this->opened_dir)) return false;
1443
+		if (!is_array($this->opened_dir))
1444
+		{
1445
+			return false;
1446
+		}
1238 1447
 
1239 1448
 		$file = current($this->opened_dir); next($this->opened_dir);
1240 1449
 
@@ -1251,9 +1460,15 @@  discard block
 block discarded – undo
1251 1460
 	 */
1252 1461
 	function dir_rewinddir ( )
1253 1462
 	{
1254
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."( )");
1463
+		if (self::LOG_LEVEL > 1)
1464
+		{
1465
+			error_log(__METHOD__."( )");
1466
+		}
1255 1467
 
1256
-		if (!is_array($this->opened_dir)) return false;
1468
+		if (!is_array($this->opened_dir))
1469
+		{
1470
+			return false;
1471
+		}
1257 1472
 
1258 1473
 		reset($this->opened_dir);
1259 1474
 
@@ -1269,9 +1484,15 @@  discard block
 block discarded – undo
1269 1484
 	 */
1270 1485
 	function dir_closedir ( )
1271 1486
 	{
1272
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."( )");
1487
+		if (self::LOG_LEVEL > 1)
1488
+		{
1489
+			error_log(__METHOD__."( )");
1490
+		}
1273 1491
 
1274
-		if (!is_array($this->opened_dir)) return false;
1492
+		if (!is_array($this->opened_dir))
1493
+		{
1494
+			return false;
1495
+		}
1275 1496
 
1276 1497
 		$this->opened_dir = null;
1277 1498
 
@@ -1290,7 +1511,10 @@  discard block
 block discarded – undo
1290 1511
 	{
1291 1512
 		$link = !($lstat = self::url_stat($path,STREAM_URL_STAT_LINK)) || is_null($lstat['readlink']) ? false : $lstat['readlink'];
1292 1513
 
1293
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path') = $link");
1514
+		if (self::LOG_LEVEL > 1)
1515
+		{
1516
+			error_log(__METHOD__."('$path') = $link");
1517
+		}
1294 1518
 
1295 1519
 		return $link;
1296 1520
 	}
@@ -1304,22 +1528,34 @@  discard block
 block discarded – undo
1304 1528
 	 */
1305 1529
 	static function symlink($target,$link)
1306 1530
 	{
1307
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$target','$link')");
1531
+		if (self::LOG_LEVEL > 1)
1532
+		{
1533
+			error_log(__METHOD__."('$target','$link')");
1534
+		}
1308 1535
 
1309 1536
 		if (self::url_stat($link,0))
1310 1537
 		{
1311
-			if (self::LOG_LEVEL > 0) error_log(__METHOD__."('$target','$link') $link exists, returning false!");
1538
+			if (self::LOG_LEVEL > 0)
1539
+			{
1540
+				error_log(__METHOD__."('$target','$link') $link exists, returning false!");
1541
+			}
1312 1542
 			return false;	// $link already exists
1313 1543
 		}
1314 1544
 		if (!($dir = Vfs::dirname($link)) ||
1315 1545
 			!Vfs::check_access($dir,Vfs::WRITABLE,$dir_stat=static::url_stat($dir,0)))
1316 1546
 		{
1317
-			if (self::LOG_LEVEL > 0) error_log(__METHOD__."('$target','$link') returning false! (!is_writable('$dir'), dir_stat=".array2string($dir_stat).")");
1547
+			if (self::LOG_LEVEL > 0)
1548
+			{
1549
+				error_log(__METHOD__."('$target','$link') returning false! (!is_writable('$dir'), dir_stat=".array2string($dir_stat).")");
1550
+			}
1318 1551
 			return false;	// parent dir does not exist or is not writable
1319 1552
 		}
1320 1553
 		$query = 'INSERT INTO '.self::TABLE.' (fs_name,fs_dir,fs_mode,fs_uid,fs_gid,fs_created,fs_modified,fs_creator,fs_mime,fs_size,fs_link'.
1321 1554
 			') VALUES (:fs_name,:fs_dir,:fs_mode,:fs_uid,:fs_gid,:fs_created,:fs_modified,:fs_creator,:fs_mime,:fs_size,:fs_link)';
1322
-		if (self::LOG_LEVEL > 2) $query = '/* '.__METHOD__.': '.__LINE__.' */ '.$query;
1555
+		if (self::LOG_LEVEL > 2)
1556
+		{
1557
+			$query = '/* '.__METHOD__.': '.__LINE__.' */ '.$query;
1558
+		}
1323 1559
 		$stmt = self::$pdo->prepare($query);
1324 1560
 		unset(self::$stat_cache[Vfs::parse_url($link,PHP_URL_PATH)]);
1325 1561
 
@@ -1367,7 +1603,10 @@  discard block
 block discarded – undo
1367 1603
 				break;
1368 1604
 			}
1369 1605
 		}
1370
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$check) ".($access?"access granted by $path=$rights":'no access!!!'));
1606
+		if (self::LOG_LEVEL > 1)
1607
+		{
1608
+			error_log(__METHOD__."($url,$check) ".($access?"access granted by $path=$rights":'no access!!!'));
1609
+		}
1371 1610
 		return $access;
1372 1611
 	}
1373 1612
 
@@ -1395,11 +1634,15 @@  discard block
 block discarded – undo
1395 1634
 			}
1396 1635
 		}
1397 1636
 		// sort by length descending, to allow more specific pathes to have precedence
1398
-		uksort(self::$extended_acl, function($a,$b) {
1637
+		uksort(self::$extended_acl, function($a,$b)
1638
+		{
1399 1639
 			return strlen($b)-strlen($a);
1400 1640
 		});
1401 1641
 		egw_cache::setSession(self::EACL_APPNAME, 'extended_acl', self::$extended_acl);
1402
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__.'() '.array2string(self::$extended_acl));
1642
+		if (self::LOG_LEVEL > 1)
1643
+		{
1644
+			error_log(__METHOD__.'() '.array2string(self::$extended_acl));
1645
+		}
1403 1646
 	}
1404 1647
 
1405 1648
 	/**
@@ -1428,12 +1671,18 @@  discard block
 block discarded – undo
1428 1671
 		{
1429 1672
 			if (!($stat = self::url_stat($path,0)))
1430 1673
 			{
1431
-				if (self::LOG_LEVEL) error_log(__METHOD__."($path,$rights,$owner,$fs_id) no such file or directory!");
1674
+				if (self::LOG_LEVEL)
1675
+				{
1676
+					error_log(__METHOD__."($path,$rights,$owner,$fs_id) no such file or directory!");
1677
+				}
1432 1678
 				return false;	// $path not found
1433 1679
 			}
1434
-			if (!Vfs::has_owner_rights($path,$stat))		// not group dir and user is eGW admin
1680
+			if (!Vfs::has_owner_rights($path,$stat))
1681
+			{
1682
+				// not group dir and user is eGW admin
1435 1683
 			{
1436 1684
 				if (self::LOG_LEVEL) error_log(__METHOD__."($path,$rights,$owner,$fs_id) permission denied!");
1685
+			}
1437 1686
 				return false;	// permission denied
1438 1687
 			}
1439 1688
 			$fs_id = $stat['ino'];
@@ -1466,7 +1715,10 @@  discard block
 block discarded – undo
1466 1715
 		{
1467 1716
 			egw_cache::setSession(self::EACL_APPNAME, 'extended_acl', self::$extended_acl);
1468 1717
 		}
1469
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($path,$rights,$owner,$fs_id)=".(int)$ret);
1718
+		if (self::LOG_LEVEL > 1)
1719
+		{
1720
+			error_log(__METHOD__."($path,$rights,$owner,$fs_id)=".(int)$ret);
1721
+		}
1470 1722
 		return $ret;
1471 1723
 	}
1472 1724
 
@@ -1500,7 +1752,8 @@  discard block
 block discarded – undo
1500 1752
 			$eacls = array_merge((array)self::get_eacl($path),$eacls);
1501 1753
 		}
1502 1754
 		// sort by length descending, to show precedence
1503
-		usort($eacls, function($a, $b) {
1755
+		usort($eacls, function($a, $b)
1756
+		{
1504 1757
 			return strlen($b['path']) - strlen($a['path']);
1505 1758
 		});
1506 1759
 		//error_log(__METHOD__."('$_path') returning ".array2string($eacls));
@@ -1518,7 +1771,10 @@  discard block
 block discarded – undo
1518 1771
 	 */
1519 1772
 	static function id2path($fs_ids)
1520 1773
 	{
1521
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__.'('.array2string($fs_ids).')');
1774
+		if (self::LOG_LEVEL > 1)
1775
+		{
1776
+			error_log(__METHOD__.'('.array2string($fs_ids).')');
1777
+		}
1522 1778
 		$ids = (array)$fs_ids;
1523 1779
 		$pathes = array();
1524 1780
 		// first check our stat-cache for the ids
@@ -1530,16 +1786,26 @@  discard block
 block discarded – undo
1530 1786
 				unset($ids[$key]);
1531 1787
 				if (!$ids)
1532 1788
 				{
1533
-					if (self::LOG_LEVEL > 1) error_log(__METHOD__.'('.array2string($fs_ids).')='.array2string($pathes).' *from stat_cache*');
1789
+					if (self::LOG_LEVEL > 1)
1790
+					{
1791
+						error_log(__METHOD__.'('.array2string($fs_ids).')='.array2string($pathes).' *from stat_cache*');
1792
+					}
1534 1793
 					return is_array($fs_ids) ? $pathes : array_shift($pathes);
1535 1794
 				}
1536 1795
 			}
1537 1796
 		}
1538 1797
 		// now search via the database
1539
-		if (count($ids) > 1) array_map(function(&$v) { $v = (int)$v; },$ids);
1798
+		if (count($ids) > 1)
1799
+		{
1800
+			array_map(function(&$v) { $v = (int)$v;
1801
+		}
1802
+		},$ids);
1540 1803
 		$query = 'SELECT fs_id,fs_dir,fs_name FROM '.self::TABLE.' WHERE fs_id'.
1541 1804
 			(count($ids) == 1 ? '='.(int)$ids[0] : ' IN ('.implode(',',$ids).')');
1542
-		if (self::LOG_LEVEL > 2) $query = '/* '.__METHOD__.': '.__LINE__.' */ '.$query;
1805
+		if (self::LOG_LEVEL > 2)
1806
+		{
1807
+			$query = '/* '.__METHOD__.': '.__LINE__.' */ '.$query;
1808
+		}
1543 1809
 
1544 1810
 		if (!is_object(self::$pdo))
1545 1811
 		{
@@ -1566,14 +1832,20 @@  discard block
 block discarded – undo
1566 1832
 		{
1567 1833
 			return false;	// parent not found, should never happen ...
1568 1834
 		}
1569
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__." trying foreach with:".print_r($rows,true)."#");
1835
+		if (self::LOG_LEVEL > 1)
1836
+		{
1837
+			error_log(__METHOD__." trying foreach with:".print_r($rows,true)."#");
1838
+		}
1570 1839
 		foreach((array)$rows as $fs_id => $row)
1571 1840
 		{
1572 1841
 			$parent = $row['fs_dir'] > 1 ? $parents[$row['fs_dir']] : '';
1573 1842
 
1574 1843
 			$pathes[$fs_id] = $parent . '/' . $row['fs_name'];
1575 1844
 		}
1576
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__.'('.array2string($fs_ids).')='.array2string($pathes));
1845
+		if (self::LOG_LEVEL > 1)
1846
+		{
1847
+			error_log(__METHOD__.'('.array2string($fs_ids).')='.array2string($pathes));
1848
+		}
1577 1849
 		return is_array($fs_ids) ? $pathes : array_shift($pathes);
1578 1850
 	}
1579 1851
 
@@ -1629,7 +1901,10 @@  discard block
 block discarded – undo
1629 1901
 			'mime'  => $info['fs_mime'],
1630 1902
 			'readlink' => $info['fs_link'],
1631 1903
 		);
1632
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($info[name]) = ".array2string($stat));
1904
+		if (self::LOG_LEVEL > 1)
1905
+		{
1906
+			error_log(__METHOD__."($info[name]) = ".array2string($stat));
1907
+		}
1633 1908
 		return $stat;
1634 1909
 	}
1635 1910
 
@@ -1701,7 +1976,10 @@  discard block
 block discarded – undo
1701 1976
 		switch(self::$pdo_type)
1702 1977
 		{
1703 1978
 			case 'mysql':
1704
-				if (isset($egw_db->Link_ID->charset2mysql[$charset])) $charset = $egw_db->Link_ID->charset2mysql[$charset];
1979
+				if (isset($egw_db->Link_ID->charset2mysql[$charset]))
1980
+				{
1981
+					$charset = $egw_db->Link_ID->charset2mysql[$charset];
1982
+				}
1705 1983
 				// fall throught
1706 1984
 			case 'pgsql':
1707 1985
 				$query = "SET NAMES '$charset'";
@@ -1772,13 +2050,16 @@  discard block
 block discarded – undo
1772 2050
 		}
1773 2051
 		if (!isset($GLOBALS['egw_info']['server']['files_dir']))
1774 2052
 		{
1775
-			if (is_object($GLOBALS['egw_setup']->db))	// if we run under setup, query the db for the files dir
2053
+			if (is_object($GLOBALS['egw_setup']->db))
2054
+			{
2055
+				// if we run under setup, query the db for the files dir
1776 2056
 			{
1777 2057
 				$GLOBALS['egw_info']['server']['files_dir'] = $GLOBALS['egw_setup']->db->select('egw_config','config_value',array(
1778 2058
 					'config_name' => 'files_dir',
1779 2059
 					'config_app' => 'phpgwapi',
1780 2060
 				),__LINE__,__FILE__)->fetchColumn();
1781 2061
 			}
2062
+			}
1782 2063
 		}
1783 2064
 		if (!$GLOBALS['egw_info']['server']['files_dir'])
1784 2065
 		{
@@ -1790,7 +2071,11 @@  discard block
 block discarded – undo
1790 2071
 		{
1791 2072
 			$hash[] = sprintf('%02d',$n % self::HASH_MAX);
1792 2073
 		}
1793
-		if (!$hash) $hash[] = '00';		// we need at least one directory, to not conflict with the dir-names
2074
+		if (!$hash)
2075
+		{
2076
+			$hash[] = '00';
2077
+		}
2078
+		// we need at least one directory, to not conflict with the dir-names
1794 2079
 		array_unshift($hash,$id);
1795 2080
 
1796 2081
 		$path = '/sqlfs/'.implode('/',array_reverse($hash));
@@ -1852,7 +2137,10 @@  discard block
 block discarded – undo
1852 2137
 	 */
1853 2138
 	static function proppatch($path,array $props)
1854 2139
 	{
1855
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."(".array2string($path).','.array2string($props));
2140
+		if (self::LOG_LEVEL > 1)
2141
+		{
2142
+			error_log(__METHOD__."(".array2string($path).','.array2string($props));
2143
+		}
1856 2144
 		if (!is_numeric($path))
1857 2145
 		{
1858 2146
 			if (!($stat = self::url_stat($path,0)))
@@ -1872,13 +2160,19 @@  discard block
 block discarded – undo
1872 2160
 		$ins_stmt = $del_stmt = null;
1873 2161
 		foreach($props as &$prop)
1874 2162
 		{
1875
-			if (!isset($prop['ns'])) $prop['ns'] = Vfs::DEFAULT_PROP_NAMESPACE;
2163
+			if (!isset($prop['ns']))
2164
+			{
2165
+				$prop['ns'] = Vfs::DEFAULT_PROP_NAMESPACE;
2166
+			}
1876 2167
 
1877
-			if (!isset($prop['val']) || self::$pdo_type != 'mysql')	// for non mysql, we have to delete the prop anyway, as there's no REPLACE!
2168
+			if (!isset($prop['val']) || self::$pdo_type != 'mysql')
2169
+			{
2170
+				// for non mysql, we have to delete the prop anyway, as there's no REPLACE!
1878 2171
 			{
1879 2172
 				if (!isset($del_stmt))
1880 2173
 				{
1881 2174
 					$del_stmt = self::$pdo->prepare('DELETE FROM '.self::PROPS_TABLE.' WHERE fs_id=:fs_id AND prop_namespace=:prop_namespace AND prop_name=:prop_name');
2175
+			}
1882 2176
 				}
1883 2177
 				$del_stmt->execute(array(
1884 2178
 					'fs_id'          => $id,
@@ -1924,17 +2218,27 @@  discard block
 block discarded – undo
1924 2218
 			{
1925 2219
 				if (!($stat = self::url_stat($id,0)))
1926 2220
 				{
1927
-					if (self::LOG_LEVEL) error_log(__METHOD__."(".array2string($path_ids).",$ns) path '$id' not found!");
2221
+					if (self::LOG_LEVEL)
2222
+					{
2223
+						error_log(__METHOD__."(".array2string($path_ids).",$ns) path '$id' not found!");
2224
+					}
1928 2225
 					return false;
1929 2226
 				}
1930 2227
 				$id = $stat['ino'];
1931 2228
 			}
1932 2229
 		}
1933
-		if (count($ids) >= 1) array_map(function(&$v) { $v = (int)$v; },$ids);
2230
+		if (count($ids) >= 1)
2231
+		{
2232
+			array_map(function(&$v) { $v = (int)$v;
2233
+		}
2234
+		},$ids);
1934 2235
 		$query = 'SELECT * FROM '.self::PROPS_TABLE.' WHERE (fs_id'.
1935 2236
 			(count($ids) == 1 ? '='.(int)implode('',$ids) : ' IN ('.implode(',',$ids).')').')'.
1936 2237
 			(!is_null($ns) ? ' AND prop_namespace=?' : '');
1937
-		if (self::LOG_LEVEL > 2) $query = '/* '.__METHOD__.': '.__LINE__.' */ '.$query;
2238
+		if (self::LOG_LEVEL > 2)
2239
+		{
2240
+			$query = '/* '.__METHOD__.': '.__LINE__.' */ '.$query;
2241
+		}
1938 2242
 
1939 2243
 		$stmt = self::$pdo->prepare($query);
1940 2244
 		$stmt->setFetchMode(\PDO::FETCH_ASSOC);
@@ -1953,11 +2257,14 @@  discard block
 block discarded – undo
1953 2257
 		{
1954 2258
 			$props = $props[$row['fs_id']] ? $props[$row['fs_id']] : array();	// return empty array for no props
1955 2259
 		}
1956
-		elseif ($props && isset($stat))	// need to map fs_id's to pathes
2260
+		elseif ($props && isset($stat))
2261
+		{
2262
+			// need to map fs_id's to pathes
1957 2263
 		{
1958 2264
 			foreach(self::id2path(array_keys($props)) as $id => $path)
1959 2265
 			{
1960 2266
 				$props[$path] =& $props[$id];
2267
+		}
1961 2268
 				unset($props[$id]);
1962 2269
 			}
1963 2270
 		}
Please login to merge, or discard this patch.