Completed
Push — master ( e931fb...4d7360 )
by Klaus
19:05 queued 26s
created
calendar/inc/class.calendar_hooks.inc.php 1 patch
Braces   +25 added lines, -6 removed lines patch added patch discarded remove patch
@@ -100,9 +100,12 @@  discard block
 block discarded – undo
100 100
 	 */
101 101
 	static function settings($hook_data)
102 102
 	{
103
-		if (!$hook_data['setup'])	// does not work on setup time
103
+		if (!$hook_data['setup'])
104
+		{
105
+			// does not work on setup time
104 106
 		{
105 107
 			$bo = new calendar_bo();
108
+		}
106 109
 			$bo->check_set_default_prefs();
107 110
 		}
108 111
 		$yesno = array(
@@ -195,9 +198,12 @@  discard block
 block discarded – undo
195 198
 			1		=> lang('Yes'),
196 199
 			2		=> lang('With credentials included'),
197 200
 		);
198
-		if (!$hook_data['setup'])	// does not work at setup time
201
+		if (!$hook_data['setup'])
202
+		{
203
+			// does not work at setup time
199 204
 		{
200 205
 			$options = array('0' => lang('none'));
206
+		}
201 207
 			foreach($GLOBALS['egw']->accounts->search(array('type' => 'owngroups','app' => 'calendar')) as $group)
202 208
 			{
203 209
 				$options[$group['account_id']] = Api\Accounts::username($group['account_id']);
@@ -388,9 +394,12 @@  discard block
 block discarded – undo
388 394
 				'default' => '',
389 395
 			),
390 396
 		);
391
-		if (isset($bo))	// add custom time-spans set by CalDAV clients, not in our prefs
397
+		if (isset($bo))
398
+		{
399
+			// add custom time-spans set by CalDAV clients, not in our prefs
392 400
 		{
393 401
 			$prefs = $GLOBALS['egw_info']['user']['preferences']['calendar'];
402
+		}
394 403
 			$data = array(
395 404
 				'prefs' => &$prefs,	// use reference to get preference value back
396 405
 				'preprocess' => true,
@@ -689,7 +698,10 @@  discard block
 block discarded – undo
689 698
 	{
690 699
 		//error_log(__METHOD__."(".array2string($data).")");
691 700
 		// caldav perfs are always user specific and cant by switched off
692
-		if ($data['type'] != 'user') return;
701
+		if ($data['type'] != 'user')
702
+		{
703
+			return;
704
+		}
693 705
 
694 706
 		$account_lid = $GLOBALS['egw_info']['user']['account_lid'];
695 707
 		foreach(array(
@@ -698,16 +710,23 @@  discard block
 block discarded – undo
698 710
 		) as $name => $dav)
699 711
 		{
700 712
 			$pref =& $GLOBALS['egw_info']['user']['preferences']['groupdav'][$dav];
701
-			if (true) $pref = str_replace("\r", '', $pref);	// remove CR messing up multiline preg_match
713
+			if (true)
714
+			{
715
+				$pref = str_replace("\r", '', $pref);
716
+			}
717
+			// remove CR messing up multiline preg_match
702 718
 			$val =& $data['prefs'][$name];
703 719
 
704 720
 			//error_log(__METHOD__."() groupdav[$dav]=$pref, calendar[$name]=$val");
705 721
 
706
-			if ($data['preprocess'])	// showing preferences
722
+			if ($data['preprocess'])
723
+			{
724
+				// showing preferences
707 725
 			{
708 726
 				if (!isset($val))	// no calendar pref --> read value from caldav
709 727
 				{
710 728
 					$matches = null;
729
+			}
711 730
 					if (preg_match('/^ACTION:NONE$/mi', $pref))
712 731
 					{
713 732
 						$val = '';
Please login to merge, or discard this patch.
calendar/inc/class.calendar_timegrid_etemplate_widget.inc.php 1 patch
Braces   +8 added lines, -2 removed lines patch added patch discarded remove patch
@@ -33,7 +33,10 @@  discard block
 block discarded – undo
33 33
 	{
34 34
 		$form_name = self::form_name($cname, $this->id, $expand);
35 35
 		$value =& self::get_array(self::$request->content, $form_name, true);
36
-		if(!is_array($value)) $value = array();
36
+		if(!is_array($value))
37
+		{
38
+			$value = array();
39
+		}
37 40
 
38 41
 		foreach($value as &$events)
39 42
 		{
@@ -43,7 +46,10 @@  discard block
 block discarded – undo
43 46
 			}
44 47
 			foreach($events as &$event)
45 48
 			{
46
-				if(!is_array($event)) continue;
49
+				if(!is_array($event))
50
+				{
51
+					continue;
52
+				}
47 53
 				foreach(array('start','end') as $date)
48 54
 				{
49 55
 					$event[$date] = Api\DateTime::to($event[$date],'Y-m-d\TH:i:s\Z');
Please login to merge, or discard this patch.
calendar/inc/class.calendar_holidays.inc.php 1 patch
Braces   +32 added lines, -8 removed lines patch added patch discarded remove patch
@@ -41,7 +41,10 @@  discard block
 block discarded – undo
41 41
 	 */
42 42
 	public static function read($country, $year=null)
43 43
 	{
44
-		if (!$year) $year = (int)Api\DateTime::to('now', 'Y');
44
+		if (!$year)
45
+		{
46
+			$year = (int)Api\DateTime::to('now', 'Y');
47
+		}
45 48
 		$level = self::is_url($country) ? Api\Cache::INSTANCE : Api\Cache::TREE;
46 49
 
47 50
 		$holidays = Api\Cache::getCache($level, __CLASS__, $country.':'.$year);
@@ -68,7 +71,10 @@  discard block
 block discarded – undo
68 71
 	 */
69 72
 	public static function render($country, $year=null, $until_year=null)
70 73
 	{
71
-		if (!$year) $year = (int)Api\DateTime::to('now', 'Y');
74
+		if (!$year)
75
+		{
76
+			$year = (int)Api\DateTime::to('now', 'Y');
77
+		}
72 78
 		$end_year = $until_year && $year < $until_year ? $until_year : $year;
73 79
 
74 80
 		$starttime = microtime(true);
@@ -81,22 +87,40 @@  discard block
 block discarded – undo
81 87
 		{
82 88
 			$start = new Api\DateTime($event['start']);
83 89
 			$end = new Api\DateTime($event['end']);
84
-			if ($start->format('Y') > $end_year) continue;
85
-			if ($end->format('Y') < $year && !$event['recur_type']) continue;
90
+			if ($start->format('Y') > $end_year)
91
+			{
92
+				continue;
93
+			}
94
+			if ($end->format('Y') < $year && !$event['recur_type'])
95
+			{
96
+				continue;
97
+			}
86 98
 
87 99
 			// recuring events
88 100
 			if ($event['recur_type'])
89 101
 			{
90 102
 				// calendar_rrule limits no enddate, to 5 years
91
-				if (!$event['recur_enddate']) $event['recur_enddate'] = (1+$end_year).'0101';
103
+				if (!$event['recur_enddate'])
104
+				{
105
+					$event['recur_enddate'] = (1+$end_year).'0101';
106
+				}
92 107
 
93 108
 				$rrule = calendar_rrule::event2rrule($event);
94
-				if ($rrule->enddate && $rrule->enddate->format('Y') < $year) continue;
109
+				if ($rrule->enddate && $rrule->enddate->format('Y') < $year)
110
+				{
111
+					continue;
112
+				}
95 113
 
96 114
 				foreach($rrule as $rtime)
97 115
 				{
98
-					if (($y = (int)$rtime->format('Y')) < $year) continue;
99
-					if ($y > $end_year) break;
116
+					if (($y = (int)$rtime->format('Y')) < $year)
117
+					{
118
+						continue;
119
+					}
120
+					if ($y > $end_year)
121
+					{
122
+						break;
123
+					}
100 124
 
101 125
 					$ymd = (int)$rtime->format('Ymd');
102 126
 					$years[$y][(string)$ymd][] = array(
Please login to merge, or discard this patch.
calendar/inc/class.calendar_merge.inc.php 1 patch
Braces   +167 added lines, -53 removed lines patch added patch discarded remove patch
@@ -88,10 +88,12 @@  discard block
 block discarded – undo
88 88
 		{
89 89
 			$this->table_plugins[date('l', strtotime("+$i days"))] = 'day_plugin';
90 90
 		}
91
-		for($i = 1; $i <= 31; $i++) {
91
+		for($i = 1; $i <= 31; $i++)
92
+		{
92 93
 			$this->table_plugins['day_'.$i] = 'day'; // Numerically by day number (1-31)
93 94
 		}
94
-		foreach(self::$relative as $day) {
95
+		foreach(self::$relative as $day)
96
+		{
95 97
 			$this->table_plugins[$day] = 'day'; // Current day
96 98
 		}
97 99
 		$this->query = is_array($this->bo->cal_prefs['saved_states']) ?
@@ -131,9 +133,16 @@  discard block
 block discarded – undo
131 133
 				$events = $ids;
132 134
 				$ids = array('start' => PHP_INT_MAX, 'end' => 0);
133 135
 				$this->ids = array();
134
-				foreach($events as $event) {
135
-					if($event['start'] && Api\DateTime::to($event['start'],'ts') < $ids['start']) $ids['start'] = Api\DateTime::to($event['start'],'ts');
136
-					if($event['end'] && Api\DateTime::to($event['end'],'ts') > $ids['end']) $ids['end'] = Api\DateTime::to($event['end'],'ts');
136
+				foreach($events as $event)
137
+				{
138
+					if($event['start'] && Api\DateTime::to($event['start'],'ts') < $ids['start'])
139
+					{
140
+						$ids['start'] = Api\DateTime::to($event['start'],'ts');
141
+					}
142
+					if($event['end'] && Api\DateTime::to($event['end'],'ts') > $ids['end'])
143
+					{
144
+						$ids['end'] = Api\DateTime::to($event['end'],'ts');
145
+					}
137 146
 					// Keep ids for future use
138 147
 					$this->ids[] = $event['id'];
139 148
 				}
@@ -154,7 +163,8 @@  discard block
 block discarded – undo
154 163
 				'cfs' => strpos($content, '#') !== false ? array_keys(Api\Storage\Customfields::get('calendar')) : null
155 164
 			));
156 165
 			$ids = array();
157
-			foreach($events as $event) {
166
+			foreach($events as $event)
167
+			{
158 168
 				$ids[] = $event;
159 169
 			}
160 170
 		}
@@ -192,9 +202,16 @@  discard block
 block discarded – undo
192 202
 			$events = $id;
193 203
 			$id = array('start' => PHP_INT_MAX, 'end' => 0);
194 204
 			$this->ids = array();
195
-			foreach($events as $event) {
196
-				if($event['start'] && $event['start'] < $id['start']) $id['start'] = $event['start'];
197
-				if($event['end'] && $event['end'] > $id['end']) $id['end'] = $event['end'];
205
+			foreach($events as $event)
206
+			{
207
+				if($event['start'] && $event['start'] < $id['start'])
208
+				{
209
+					$id['start'] = $event['start'];
210
+				}
211
+				if($event['end'] && $event['end'] > $id['end'])
212
+				{
213
+					$id['end'] = $event['end'];
214
+				}
198 215
 				// Keep ids for future use
199 216
 				$this->ids[]  = $event['id'];
200 217
 			}
@@ -221,7 +238,10 @@  discard block
 block discarded – undo
221 238
 				foreach(self::$range_tags as $key => $format)
222 239
 				{
223 240
 					$value = date($format, $key == 'end' ? $id['end'] : $id['start']);
224
-					if($key == 'month') $value = lang($value);
241
+					if($key == 'month')
242
+					{
243
+						$value = lang($value);
244
+					}
225 245
 					$values["$\$range/$key$$"] = $value;
226 246
 				}
227 247
 			}
@@ -240,9 +260,12 @@  discard block
 block discarded – undo
240 260
 	public function calendar_replacements($id,$prefix = '', &$content = '')
241 261
 	{
242 262
 		$replacements = array();
243
-		if(!is_array($id) || !$id['start']) {
263
+		if(!is_array($id) || !$id['start'])
264
+		{
244 265
 			$event = $this->bo->read(is_array($id) ? $id['id'] : $id, is_array($id) ? $id['recur_date'] : null);
245
-		} else {
266
+		}
267
+		else
268
+		{
246 269
 			$event = $id;
247 270
 		}
248 271
 
@@ -261,7 +284,10 @@  discard block
 block discarded – undo
261 284
 		$replacements['$$' . ($prefix ? $prefix . '/' : '') . 'calendar_id'. '$$'] = $event['id'];
262 285
 		foreach($this->bo->event2array($event) as $name => $data)
263 286
 		{
264
-			if (substr($name,-4) == 'date') $name = substr($name,0,-4);
287
+			if (substr($name,-4) == 'date')
288
+			{
289
+				$name = substr($name,0,-4);
290
+			}
265 291
 			$replacements['$$' . ($prefix ? $prefix . '/' : '') . 'calendar_'.$name . '$$'] = is_array($data['data']) ? implode(', ',$data['data']) : $data['data'];
266 292
 		}
267 293
 		// Add seperate lists of participants by type
@@ -300,7 +326,10 @@  discard block
 block discarded – undo
300 326
 			) as $name => $format)
301 327
 			{
302 328
 				$value = Api\DateTime::to($event[$what],$format);
303
-				if ($format == 'l') $value = lang($value);
329
+				if ($format == 'l')
330
+				{
331
+					$value = lang($value);
332
+				}
304 333
 				$replacements['$$' .($prefix ? $prefix.'/':'').'calendar_'.$what.$name.'$$'] = $value;
305 334
 			}
306 335
 		}
@@ -343,24 +372,41 @@  discard block
 block discarded – undo
343 372
 	public function day_plugin($plugin,$date,$n,$repeat)
344 373
 	{
345 374
 		static $days = null;
346
-		if(is_array($date) && !$date['start']) {
375
+		if(is_array($date) && !$date['start'])
376
+		{
347 377
 			// List of IDs
348
-			if($date[0]['start']) {
378
+			if($date[0]['start'])
379
+			{
349 380
 				$id = array('start' => PHP_INT_MAX, 'end' => 0);
350
-				foreach($date as $event) {
351
-					if($event['start'] && $event['start'] < $id['start']) $id['start'] = $event['start'];
352
-					if($event['end'] && $event['end'] > $id['end']) $id['end'] = $event['end'];
381
+				foreach($date as $event)
382
+				{
383
+					if($event['start'] && $event['start'] < $id['start'])
384
+					{
385
+						$id['start'] = $event['start'];
386
+					}
387
+					if($event['end'] && $event['end'] > $id['end'])
388
+					{
389
+						$id['end'] = $event['end'];
390
+					}
353 391
 				}
354 392
 				$date = $id;
355
-			} else {
393
+			}
394
+			else
395
+			{
356 396
 				$event = $this->bo->read(is_array($date) ? $date['id'] : $date, is_array($date) ? $date['recur_date'] : null);
357
-				if(date('l',$event['start']) != $plugin) return array();
397
+				if(date('l',$event['start']) != $plugin)
398
+				{
399
+					return array();
400
+				}
358 401
 				$date = $event['start'];
359 402
 			}
360 403
 		}
361 404
 
362 405
 		$_date = $date['start'] ? $date['start'] : $date;
363
-		if($days[date('Ymd',$_date)][$plugin]) return $days[date('Ymd',$_date)][$plugin][$n];
406
+		if($days[date('Ymd',$_date)][$plugin])
407
+		{
408
+			return $days[date('Ymd',$_date)][$plugin][$n];
409
+		}
364 410
 
365 411
 		$events = $this->bo->search($this->query + array(
366 412
 			'start' => $date['end'] ? $date['start'] : mktime(0,0,0,date('m',$_date),date('d',$_date),date('Y',$_date)),
@@ -372,20 +418,29 @@  discard block
 block discarded – undo
372 418
 			'cfs' => array(),	// read all custom-fields
373 419
 		));
374 420
 
375
-		if (true) $days = array();
421
+		if (true)
422
+		{
423
+			$days = array();
424
+		}
376 425
 		$replacements = array();
377 426
 		$time_format = $GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == 12 ? 'h:i a' : 'H:i';
378 427
 		foreach($events as $day => $list)
379 428
 		{
380 429
 			foreach($list as $event)
381 430
 			{
382
-				if($this->ids && !in_array($event['id'], $this->ids)) continue;
431
+				if($this->ids && !in_array($event['id'], $this->ids))
432
+				{
433
+					continue;
434
+				}
383 435
 				$start = Api\DateTime::to($event['start'], 'array');
384 436
 				$end = Api\DateTime::to($event['end'], 'array');
385 437
 				$replacements = $this->calendar_replacements($event);
386
-				if($start['year'] == $end['year'] && $start['month'] == $end['month'] && $start['day'] == $end['day']) {
438
+				if($start['year'] == $end['year'] && $start['month'] == $end['month'] && $start['day'] == $end['day'])
439
+				{
387 440
 					$dow = date('l',$event['start']);
388
-				} else {
441
+				}
442
+				else
443
+				{
389 444
 					$dow = date('l', strtotime($day));
390 445
 					// Fancy date+time formatting for multi-day events
391 446
 					$replacements['$$calendar_starttime$$'] = date($time_format, $day == date('Ymd', $event['start']) ? $event['start'] : mktime(0,0,0,0,0,1));
@@ -394,12 +449,14 @@  discard block
 block discarded – undo
394 449
 
395 450
 				$days[date('Ymd',$_date)][$dow][] = $replacements;
396 451
 			}
397
-			if(strpos($repeat, 'day/date') !== false || strpos($repeat, 'day/name') !== false) {
452
+			if(strpos($repeat, 'day/date') !== false || strpos($repeat, 'day/name') !== false)
453
+			{
398 454
 				$date_marker = array(
399 455
 					'$$day/date$$' => date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'], strtotime($day)),
400 456
 					'$$day/name$$' => lang(date('l', strtotime($day)))
401 457
 				);
402
-				if(!is_array($days[date('Ymd',$_date)][date('l',strtotime($day))])) {
458
+				if(!is_array($days[date('Ymd',$_date)][date('l',strtotime($day))]))
459
+				{
403 460
 					$blank = $this->calendar_replacements(array());
404 461
 					foreach($blank as &$value)
405 462
 					{
@@ -435,16 +492,26 @@  discard block
 block discarded – undo
435 492
 			if($id[0]['start'])
436 493
 			{
437 494
 				$dates = array('start' => PHP_INT_MAX, 'end' => 0);
438
-				foreach($id as $event) {
439
-					if($event['start'] && $event['start'] < $dates['start']) $dates['start'] = $event['start'];
440
-					if($event['end'] && $event['end'] > $dates['end']) $dates['end'] = $event['end'];
495
+				foreach($id as $event)
496
+				{
497
+					if($event['start'] && $event['start'] < $dates['start'])
498
+					{
499
+						$dates['start'] = $event['start'];
500
+					}
501
+					if($event['end'] && $event['end'] > $dates['end'])
502
+					{
503
+						$dates['end'] = $event['end'];
504
+					}
441 505
 				}
442 506
 				$id = $dates;
443 507
 			}
444 508
 			$arr = $this->bo->date2array($id['start']);
445 509
 			$arr['day'] = $which;
446 510
 			$date = $this->bo->date2ts($arr);
447
-			if(is_array($id) && $id['start'] && ($date < $id['start'] || $date > $id['end'])) return array();
511
+			if(is_array($id) && $id['start'] && ($date < $id['start'] || $date > $id['end']))
512
+			{
513
+				return array();
514
+			}
448 515
 		}
449 516
 		elseif ($plugin == 'selected')
450 517
 		{
@@ -454,16 +521,26 @@  discard block
 block discarded – undo
454 521
 		{
455 522
 			$date = strtotime($plugin);
456 523
 		}
457
-		if($type == 'day' && is_array($id) && !$id['start']) {
524
+		if($type == 'day' && is_array($id) && !$id['start'])
525
+		{
458 526
 			$event = $this->bo->read(is_array($id) ? $id['id'] : $id, is_array($id) ? $id['recur_date'] : null);
459
-			if($which && date('d',$event['start']) != $which) return array();
460
-			if(date('Ymd',$date) != date('Ymd', $event['start'])) return array();
527
+			if($which && date('d',$event['start']) != $which)
528
+			{
529
+				return array();
530
+			}
531
+			if(date('Ymd',$date) != date('Ymd', $event['start']))
532
+			{
533
+				return array();
534
+			}
461 535
 			return $n == 0 ? $this->calendar_replacements($event) : array();
462 536
 		}
463 537
 
464 538
 		// Use start for cache, in case of multiple months
465 539
 		$_date = $id['start'] ? $id['start'] : $date;
466
-		if($days[date('Ymd',$_date)][$plugin]) return $days[date('Ymd',$_date)][$plugin][$n];
540
+		if($days[date('Ymd',$_date)][$plugin])
541
+		{
542
+			return $days[date('Ymd',$_date)][$plugin][$n];
543
+		}
467 544
 
468 545
 		$events = $this->bo->search($this->query + array(
469 546
 			'start' => $date,
@@ -476,31 +553,42 @@  discard block
 block discarded – undo
476 553
 		));
477 554
 
478 555
 		$replacements = array();
479
-		if (true) $days = array();
556
+		if (true)
557
+		{
558
+			$days = array();
559
+		}
480 560
 		$time_format = $GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == 12 ? 'h:i a' : 'H:i';
481 561
 		foreach($events as $day => $list)
482 562
 		{
483 563
 			foreach($list as $event)
484 564
 			{
485
-				if($this->ids && !in_array($event['id'], $this->ids)) continue;
565
+				if($this->ids && !in_array($event['id'], $this->ids))
566
+				{
567
+					continue;
568
+				}
486 569
 				$start = Api\DateTime::to($event['start'], 'array');
487 570
 				$end = Api\DateTime::to($event['end'], 'array');
488 571
 				$replacements = $this->calendar_replacements($event);
489
-				if($start['year'] == $end['year'] && $start['month'] == $end['month'] && $start['day'] == $end['day']) {
572
+				if($start['year'] == $end['year'] && $start['month'] == $end['month'] && $start['day'] == $end['day'])
573
+				{
490 574
 					//$dow = date('l',$event['start']);
491
-				} else {
575
+				}
576
+				else
577
+				{
492 578
 					// Fancy date+time formatting for multi-day events
493 579
 					$replacements['$$calendar_starttime$$'] = date($time_format, $day == date('Ymd', $event['start']) ? $event['start'] : mktime(0,0,0,0,0,1));
494 580
 					$replacements['$$calendar_endtime$$'] = date($time_format, $day == date('Ymd', $event['end']) ? $event['end'] : mktime(23,59,59,0,0,0));
495 581
 				}
496 582
 				$days[date('Ymd',$_date)][$plugin][] = $replacements;
497 583
 			}
498
-			if(strpos($repeat, 'day/date') !== false || strpos($repeat, 'day/name') !== false) {
584
+			if(strpos($repeat, 'day/date') !== false || strpos($repeat, 'day/name') !== false)
585
+			{
499 586
 				$date_marker = array(
500 587
 					'$$day/date$$' => date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'], strtotime($day)),
501 588
 					'$$day/name$$' => lang(date('l', strtotime($day)))
502 589
 				);
503
-				if(!is_array($days[date('Ymd',$_date)][$plugin])) {
590
+				if(!is_array($days[date('Ymd',$_date)][$plugin]))
591
+				{
504 592
 					$blank = $this->calendar_replacements(array());
505 593
 					foreach($blank as &$value)
506 594
 					{
@@ -528,22 +616,35 @@  discard block
 block discarded – undo
528 616
 	{
529 617
 		unset($plugin);	// not used, but required by function signature
530 618
 
531
-		if(!is_array($id) || !$id['start']) {
619
+		if(!is_array($id) || !$id['start'])
620
+		{
532 621
 			$event = $this->bo->read(is_array($id) ? $id['id'] : $id, is_array($id) ? $id['recur_date'] : null);
533
-		} else {
622
+		}
623
+		else
624
+		{
534 625
 			$event = $id;
535 626
 		}
536 627
 
537
-		if(!is_array($event['participants']) || $n >= count($event['participants'])) return array();
628
+		if(!is_array($event['participants']) || $n >= count($event['participants']))
629
+		{
630
+			return array();
631
+		}
538 632
 
539 633
 		$participant = null;
540 634
 		$status = null;
541 635
 		$i = -1;
542
-		foreach($event['participants'] as $participant => $status) {
543
-			if(++$i == $n) break;
636
+		foreach($event['participants'] as $participant => $status)
637
+		{
638
+			if(++$i == $n)
639
+			{
640
+				break;
641
+			}
544 642
 		}
545 643
 
546
-		if(!$participant) return array();
644
+		if(!$participant)
645
+		{
646
+			return array();
647
+		}
547 648
 
548 649
 		// Add some common information
549 650
 		$quantity = $role = null;
@@ -577,7 +678,10 @@  discard block
 block discarded – undo
577 678
 				$replacements = $this->contact_replacements(substr($participant,1),'');
578 679
 				break;
579 680
 			case 'r':
580
-				if (is_null(self::$resources)) self::$resources = CreateObject('resources.resources_bo');
681
+				if (is_null(self::$resources))
682
+				{
683
+					self::$resources = CreateObject('resources.resources_bo');
684
+				}
581 685
 				if (($resource = self::$resources->read(substr($participant,1))))
582 686
 				{
583 687
 					foreach($resource as $name => $value)
@@ -638,14 +742,23 @@  discard block
 block discarded – undo
638 742
 			'calendar_owner'    => lang('Owner'),
639 743
 		) as $name => $label)
640 744
 		{
641
-			if (in_array($name,array('start','end')) && $n&1)		// main values, which should be in the first column
745
+			if (in_array($name,array('start','end')) && $n&1)
746
+			{
747
+				// main values, which should be in the first column
642 748
 			{
643 749
 				echo "</tr>\n";
750
+			}
644 751
 				$n++;
645 752
 			}
646
-			if (!($n&1)) echo '<tr>';
753
+			if (!($n&1))
754
+			{
755
+				echo '<tr>';
756
+			}
647 757
 			echo '<td>{{'.$name.'}}</td><td>'.$label.'</td>';
648
-			if ($n&1) echo "</tr>\n";
758
+			if ($n&1)
759
+			{
760
+				echo "</tr>\n";
761
+			}
649 762
 			$n++;
650 763
 		}
651 764
 
@@ -696,7 +809,8 @@  discard block
 block discarded – undo
696 809
 		}
697 810
 		echo '</table></td><td colspan="2"><table >';
698 811
 		echo '<tr><td><h3>'.lang('Daily tables').":</h3></td></tr>";
699
-		foreach(self::$relative as $value) {
812
+		foreach(self::$relative as $value)
813
+		{
700 814
 			echo '<tr><td>{{table/'.$value. '}} ... {{endtable}}</td></tr>';
701 815
 		}
702 816
 		echo '<tr><td>{{table/day_n}} ... {{endtable}}</td><td>1 <= n <= 31</td></tr>';
Please login to merge, or discard this patch.
calendar/inc/class.calendar_export_csv.inc.php 1 patch
Braces   +97 added lines, -36 removed lines patch added patch discarded remove patch
@@ -16,9 +16,11 @@  discard block
 block discarded – undo
16 16
 /**
17 17
  * export CSV plugin of calendar
18 18
  */
19
-class calendar_export_csv implements importexport_iface_export_plugin {
19
+class calendar_export_csv implements importexport_iface_export_plugin
20
+{
20 21
 
21
-	public function __construct() {
22
+	public function __construct()
23
+	{
22 24
 		Api\Translation::add_app('calendar');
23 25
 		$this->bo = new calendar_bo();
24 26
 		$this->get_selects();
@@ -29,15 +31,23 @@  discard block
 block discarded – undo
29 31
 	 *
30 32
 	 * @param egw_record $_definition
31 33
 	 */
32
-	public function export( $_stream, importexport_definition $_definition) {
34
+	public function export( $_stream, importexport_definition $_definition)
35
+	{
33 36
 		$options = $_definition->plugin_options;
34 37
 
35 38
 		$limit_exception = Api\Storage\Merge::is_export_limit_excepted();
36
-		if (!$limit_exception) $export_limit = Api\Storage\Merge::getExportLimit('calendar');
39
+		if (!$limit_exception)
40
+		{
41
+			$export_limit = Api\Storage\Merge::getExportLimit('calendar');
42
+		}
37 43
 		// Custom fields need to be specifically requested
38 44
 		$cfs = array();
39
-		foreach($options['mapping'] + (array)$_definition->filter as $key => $label) {
40
-			if($key[0] == '#') $cfs[] = substr($key,1);
45
+		foreach($options['mapping'] + (array)$_definition->filter as $key => $label)
46
+		{
47
+			if($key[0] == '#')
48
+			{
49
+				$cfs[] = substr($key,1);
50
+			}
41 51
 		}
42 52
 
43 53
 		$query = array(
@@ -57,7 +67,8 @@  discard block
 block discarded – undo
57 67
 					'users'         => $options['criteria']['owner'],
58 68
 					'cfs'		=> $cfs // Otherwise we shouldn't get any custom fields
59 69
 				);
60
-				if(Api\Storage\Merge::hasExportLimit($export_limit) && !$limit_exception) {
70
+				if(Api\Storage\Merge::hasExportLimit($export_limit) && !$limit_exception)
71
+				{
61 72
 					$query['offset'] = 0;
62 73
 					$query['num_rows'] = (int)$export_limit; // ! int of 'no' is 0
63 74
 				}
@@ -65,28 +76,34 @@  discard block
 block discarded – undo
65 76
 				break;
66 77
 			case 'search_results':
67 78
 				$states = Api\Cache::getSession('calendar', 'session_data');
68
-				if($states['view'] == 'listview') {
79
+				if($states['view'] == 'listview')
80
+				{
69 81
 					$query = Api\Cache::getSession('calendar', 'calendar_list');
70 82
 					$query['num_rows'] = -1;        // all
71 83
 					$query['csv_export'] = true;	// so get_rows method _can_ produce different content or not store state in the session
72 84
 					$query['start'] = 0;
73 85
 					$query['cfs'] = $cfs;
74 86
 
75
-					if(Api\Storage\Merge::hasExportLimit($export_limit) && !$limit_exception) {
87
+					if(Api\Storage\Merge::hasExportLimit($export_limit) && !$limit_exception)
88
+					{
76 89
 						$query['num_rows'] = (int)$export_limit; // ! int of 'no' is 0
77 90
 					}
78 91
 					$ui = new calendar_uilist();
79 92
 					$ui->get_rows($query, $events, $unused);
80
-				} else {
93
+				}
94
+				else
95
+				{
81 96
 					$query = Api\Cache::getSession('calendar', 'session_data');
82 97
 					$query['users'] = explode(',', $query['owner']);
83 98
 					$query['num_rows'] = -1;
84
-					if(Api\Storage\Merge::hasExportLimit($export_limit) && !$limit_exception) {
99
+					if(Api\Storage\Merge::hasExportLimit($export_limit) && !$limit_exception)
100
+					{
85 101
 						$query['num_rows'] = (int)$export_limit;  // ! int of 'no' is 0
86 102
 					}
87 103
 
88 104
 					$events = array();
89
-					switch($states['view']) {
105
+					switch($states['view'])
106
+					{
90 107
 						case 'month':
91 108
 							$query += $this->get_query_month($states);
92 109
 							break;
@@ -138,8 +155,14 @@  discard block
 block discarded – undo
138 155
 					}
139 156
 
140 157
 					// Ranges are inclusive, so should be provided that way (from 2 to 10 includes 2 and 10)
141
-					if($value['from']) $query['sql_filter'][] = "cal_$field >= " . (int)$value['from'];
142
-					if($value['to']) $query['sql_filter'][] = "cal_$field <= " . (int)$value['to'];
158
+					if($value['from'])
159
+					{
160
+						$query['sql_filter'][] = "cal_$field >= " . (int)$value['from'];
161
+					}
162
+					if($value['to'])
163
+					{
164
+						$query['sql_filter'][] = "cal_$field <= " . (int)$value['to'];
165
+					}
143 166
 
144 167
 				}
145 168
 				if($query['sql_filter'] && is_array($query['sql_filter']))
@@ -157,36 +180,52 @@  discard block
 block discarded – undo
157 180
 		}
158 181
 
159 182
 		$export_object = new importexport_export_csv($_stream, (array)$options);
160
-		if (!$limit_exception) $export_object->export_limit = $export_limit;
183
+		if (!$limit_exception)
184
+		{
185
+			$export_object->export_limit = $export_limit;
186
+		}
161 187
 		$export_object->set_mapping($options['mapping']);
162 188
 		$convert_fields = calendar_egw_record::$types;
163 189
 
164 190
 		$recurrence = $this->bo->recur_types;
165 191
 
166 192
 		$record = new calendar_egw_record();
167
-		foreach ($events as $event) {
193
+		foreach ($events as $event)
194
+		{
168 195
 			// 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
169 196
 			// Get rid of yearly recurring events that don't belong
170 197
 			//if($options['selection']['select'] == 'criteria' && ($event['start'] > $query['end'] || $event['end'] < $query['start'])) continue;
171 198
 			// Add in participants
172
-			if($options['mapping']['participants']) {
199
+			if($options['mapping']['participants'])
200
+			{
173 201
 				$event['participants'] = implode(", ",$this->bo->participants($event,true));
174 202
 			}
175 203
 			if (is_array($event))
176 204
 			{
177 205
 				$record->set_record($event);
178
-				if($options['mapping']['recurrence']) {
206
+				if($options['mapping']['recurrence'])
207
+				{
179 208
 					$record->recurrence = $recurrence[$record->recur_type];
180
-					if($record->recur_type != MCAL_RECUR_NONE) $record->recurrence .= ' / '. $record->recur_interval;
209
+					if($record->recur_type != MCAL_RECUR_NONE)
210
+					{
211
+						$record->recurrence .= ' / '. $record->recur_interval;
212
+					}
181 213
 				}
182 214
 
183 215
 				// Standard stuff
184
-				if($options['convert']) {
216
+				if($options['convert'])
217
+				{
185 218
 					importexport_export_csv::convert($record, $convert_fields, 'calendar', $this->selects);
186
-				} else {
219
+				}
220
+				else
221
+				{
187 222
 					// Implode arrays, so they don't say 'Array'
188
-					foreach($record->get_record_array() as $key => $value) {
189
-						if(is_array($value)) $record->$key = implode(',', $value);
223
+					foreach($record->get_record_array() as $key => $value)
224
+					{
225
+						if(is_array($value))
226
+						{
227
+							$record->$key = implode(',', $value);
228
+						}
190 229
 					}
191 230
 	 			}
192 231
 				$export_object->export_record($record);
@@ -201,7 +240,8 @@  discard block
 block discarded – undo
201 240
 	 *
202 241
 	 * @return string name
203 242
 	 */
204
-	public static function get_name() {
243
+	public static function get_name()
244
+	{
205 245
 		return lang('Calendar CSV export');
206 246
 	}
207 247
 
@@ -210,7 +250,8 @@  discard block
 block discarded – undo
210 250
 	 *
211 251
 	 * @return string descriprion
212 252
 	 */
213
-	public static function get_description() {
253
+	public static function get_description()
254
+	{
214 255
 		return lang("Exports events from your Calendar into a CSV File.");
215 256
 	}
216 257
 
@@ -219,11 +260,13 @@  discard block
 block discarded – undo
219 260
 	 *
220 261
 	 * @return string suffix
221 262
 	 */
222
-	public static function get_filesuffix() {
263
+	public static function get_filesuffix()
264
+	{
223 265
 		return 'csv';
224 266
 	}
225 267
 
226
-	public static function get_mimetype() {
268
+	public static function get_mimetype()
269
+	{
227 270
 		return 'text/csv';
228 271
 	}
229 272
 
@@ -231,19 +274,22 @@  discard block
 block discarded – undo
231 274
 	 * return html for options.
232 275
 	 *
233 276
 	 */
234
-	public function get_options_etpl($definition = null) {
277
+	public function get_options_etpl($definition = null)
278
+	{
235 279
 	}
236 280
 
237 281
 	/**
238 282
 	 * returns selectors of this plugin
239 283
 	 *
240 284
 	 */
241
-	public function get_selectors_etpl($definition = null) {
285
+	public function get_selectors_etpl($definition = null)
286
+	{
242 287
 		$states = $this->bo->cal_prefs['saved_states'];
243 288
 		$list = Api\Cache::getSession('calendar', 'calendar_list');
244 289
 		if(!$list['startdate'])
245 290
 		{
246
-			switch($states['view']) {
291
+			switch($states['view'])
292
+			{
247 293
 				case 'month':
248 294
 					$query = $this->get_query_month($states);
249 295
 					break;
@@ -275,7 +321,10 @@  discard block
 block discarded – undo
275 321
 			$end = $ui->last;
276 322
 
277 323
 			// Special handling
278
-			if($list['filter'] == 'all') $start = $end = null;
324
+			if($list['filter'] == 'all')
325
+			{
326
+				$start = $end = null;
327
+			}
279 328
 			if($list['filter'] == 'before')
280 329
 			{
281 330
 				$end = $start;
@@ -323,24 +372,33 @@  discard block
 block discarded – undo
323 372
 		$days = $states['days'];
324 373
 		$ui = new calendar_uiviews($states);
325 374
 		if (!$days)
326
-                {
375
+		{
327 376
                         $days = isset($_GET['days']) ? $_GET['days'] : $ui->cal_prefs['days_in_weekview'];
328
-                        if ($days != 5) $days = 7;
377
+                        if ($days != 5)
378
+                        {
379
+                        	$days = 7;
380
+                        }
329 381
                 }
330
-		if ($states['view'] == 'week' && $days == 4)         // next 4 days view
382
+		if ($states['view'] == 'week' && $days == 4)
383
+		{
384
+			// next 4 days view
331 385
                 {
332 386
                         $query['start'] = $this->bo->date2ts($states['date']);
387
+		}
333 388
                         $query['end'] = strtotime("+$days days",$query['start']) - 1;
334 389
                 }
335 390
                 else
336 391
                 {
337 392
 			$query['start'] = $ui->datetime->get_weekday_start($states['year'],$states['month'],$states['day']);
338
-			if ($days == 5)         // no weekend-days
393
+			if ($days == 5)
394
+			{
395
+				// no weekend-days
339 396
 			{
340 397
 				switch($ui->cal_prefs['weekdaystarts'])
341 398
 				{
342 399
 					case 'Saturday':
343 400
 						$query['start'] = strtotime("+2 days",$query['start']);
401
+			}
344 402
 						break;
345 403
 					case 'Sunday':
346 404
 						$query['start'] = strtotime("+1 day",$query['start']);
@@ -419,7 +477,10 @@  discard block
 block discarded – undo
419 477
 			}
420 478
 
421 479
 			// Pass on select options
422
-			if($this->selects[$field_name]) $settings['values'] = $this->selects[$field_name];
480
+			if($this->selects[$field_name])
481
+			{
482
+				$settings['values'] = $this->selects[$field_name];
483
+			}
423 484
 		}
424 485
 
425 486
 	}
Please login to merge, or discard this patch.
calendar/inc/class.calendar_import_ical.inc.php 1 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
 }
240 250
\ No newline at end of file
Please login to merge, or discard this patch.
calendar/inc/class.calendar_timezones.inc.php 1 patch
Braces   +27 added lines, -6 removed lines patch added patch discarded remove patch
@@ -188,10 +188,18 @@  discard block
 block discarded – undo
188 188
 		{
189 189
 			$updated = false;
190 190
 			$msg = self::import_zones($updated);
191
-			if ($updated) error_log($msg);	// log that timezones have been updated
191
+			if ($updated)
192
+			{
193
+				error_log($msg);
194
+			}
195
+			// log that timezones have been updated
192 196
 
193 197
 			$alias_msg = self::import_tz_aliases($updated);
194
-			if ($updated) error_log($alias_msg);	// log that timezone aliases have been updated
198
+			if ($updated)
199
+			{
200
+				error_log($alias_msg);
201
+			}
202
+			// log that timezone aliases have been updated
195 203
 
196 204
 			self::$import_msg = $msg.'<br/>'.$alias_msg;
197 205
 
@@ -249,7 +257,11 @@  discard block
 block discarded – undo
249 257
 				if ($type == 'aliases')
250 258
 				{
251 259
 					$data = array('alias' => $tz2id[$data['aliasTo']]);
252
-					if (!$data['alias']) continue;	// there's no such tzid
260
+					if (!$data['alias'])
261
+					{
262
+						continue;
263
+					}
264
+					// there's no such tzid
253 265
 				}
254 266
 				// check if already in database
255 267
 				$tz2id[$tzid] = $GLOBALS['egw']->db->select('egw_cal_timezones','tz_id',array(
@@ -266,7 +278,10 @@  discard block
 block discarded – undo
266 278
 				),__LINE__,__FILE__,'calendar');
267 279
 
268 280
 				// only query last insert id, if not already in database (gives warning for PostgreSQL)
269
-				if (!$tz2id[$tzid]) $tz2id[$tzid] = $GLOBALS['egw']->db->get_last_insert_id('egw_cal_timezones','tz_id');
281
+				if (!$tz2id[$tzid])
282
+				{
283
+					$tz2id[$tzid] = $GLOBALS['egw']->db->get_last_insert_id('egw_cal_timezones','tz_id');
284
+				}
270 285
 			}
271 286
 		}
272 287
 		Api\Config::save_value('tz_version', $tz_version, 'phpgwapi');
@@ -306,13 +321,16 @@  discard block
 block discarded – undo
306 321
 		foreach($tz_aliases as $alias => $tzid)
307 322
 		{
308 323
 			if ((!($alias_id=self::tz2id($alias, 'alias')) || self::id2tz($alias_id, 'tzid') !== $tzid) &&	// not in DB or different
309
-				($tz_id = self::tz2id($tzid)))	// given tzid for alias exists in DB
324
+				($tz_id = self::tz2id($tzid)))
325
+			{
326
+				// given tzid for alias exists in DB
310 327
 			{
311 328
 				$GLOBALS['egw']->db->insert('egw_cal_timezones',array(
312 329
 					'tz_alias' => $tz_id,
313 330
 				),array(
314 331
 					'tz_tzid' => $alias,
315 332
 				),__LINE__,__FILE__,'calendar');
333
+			}
316 334
 				++$updates;
317 335
 			}
318 336
 			//error_log(__METHOD__."() alias=$alias, tzid=$tzid --> self::tz2id('$alias', 'alias') = ".array2string($alias_id).",  self::tz2id('$tzid')=".array2string($tz_id));
@@ -402,7 +420,10 @@  discard block
 block discarded – undo
402 420
 			$prefs = $prefs_obj->read();
403 421
 			$tzid = $prefs['common']['tz'];
404 422
 		}
405
-		if (!$tzid) $tzid = Api\DateTime::$server_timezone->getName();
423
+		if (!$tzid)
424
+		{
425
+			$tzid = Api\DateTime::$server_timezone->getName();
426
+		}
406 427
 
407 428
 		switch ($type)
408 429
 		{
Please login to merge, or discard this patch.
calendar/inc/class.calendar_favorite_portlet.inc.php 1 patch
Braces   +22 added lines, -6 removed lines patch added patch discarded remove patch
@@ -77,16 +77,31 @@  discard block
 block discarded – undo
77 77
 			$ui = new calendar_uiviews();
78 78
 			if ($this->favorite)
79 79
 			{
80
-				if($this->favorite['state']['start']) $ui->search_params['start'] = $this->favorite['state']['start'];
81
-				if($this->favorite['state']['cat_id']) $ui->search_params['cat_id'] = $this->favorite['state']['cat_id'];
80
+				if($this->favorite['state']['start'])
81
+				{
82
+					$ui->search_params['start'] = $this->favorite['state']['start'];
83
+				}
84
+				if($this->favorite['state']['cat_id'])
85
+				{
86
+					$ui->search_params['cat_id'] = $this->favorite['state']['cat_id'];
87
+				}
82 88
 				// Owner can be 0 for current user
83
-				if(array_key_exists('owner',$this->favorite['state'])) $ui->search_params['users'] = $this->favorite['state']['owner'];
89
+				if(array_key_exists('owner',$this->favorite['state']))
90
+				{
91
+					$ui->search_params['users'] = $this->favorite['state']['owner'];
92
+				}
84 93
 				if($ui->search_params['users'] && !is_array($ui->search_params['users']))
85 94
 				{
86 95
 					$ui->search_params['users'] = explode(',',$ui->search_params['users']);
87 96
 				}
88
-				if($this->favorite['state']['filter']) $ui->search_params['filter'] = $this->favorite['state']['filter'];
89
-				if($this->favorite['state']['sortby']) $ui->search_params['sortby'] = $this->favorite['state']['sortby'];
97
+				if($this->favorite['state']['filter'])
98
+				{
99
+					$ui->search_params['filter'] = $this->favorite['state']['filter'];
100
+				}
101
+				if($this->favorite['state']['sortby'])
102
+				{
103
+					$ui->search_params['sortby'] = $this->favorite['state']['sortby'];
104
+				}
90 105
 				$ui->search_params['weekend'] = $this->favorite['state']['weekend'];
91 106
 			}
92 107
 			$etemplate->read('home.legacy');
@@ -246,7 +261,8 @@  discard block
 block discarded – undo
246 261
 		return $properties;
247 262
 	}
248 263
 
249
-	public function get_actions() {
264
+	public function get_actions()
265
+	{
250 266
 		if($this->favorite['state']['view'] == 'listview' || !$this->actions)
251 267
 		{
252 268
 			return array();
Please login to merge, or discard this patch.
calendar/inc/class.calendar_so.inc.php 1 patch
Braces   +366 added lines, -96 removed lines patch added patch discarded remove patch
@@ -154,16 +154,32 @@  discard block
 block discarded – undo
154 154
 	 */
155 155
 	protected function cal_range_view($start, $end, array $_where=null, $deleted=false)
156 156
 	{
157
-		if ($GLOBALS['egw_info']['server']['no_timerange_views'] || !$start)	// using view without start-date is slower!
157
+		if ($GLOBALS['egw_info']['server']['no_timerange_views'] || !$start)
158 158
 		{
159
-			return $this->cal_table;	// no need / use for a view
159
+			// using view without start-date is slower!
160
+		{
161
+			return $this->cal_table;
162
+		}
163
+		// no need / use for a view
160 164
 		}
161 165
 
162 166
 		$where = array();
163
-		if (isset($deleted)) $where[] = "cal_deleted IS ".($deleted ? '' : 'NOT').' NULL';
164
-		if ($end) $where[] = "range_start<".(int)$end;
165
-		if ($start) $where[] = "(range_end IS NULL OR range_end>".(int)$start.")";
166
-		if ($_where) $where = array_merge($where, $_where);
167
+		if (isset($deleted))
168
+		{
169
+			$where[] = "cal_deleted IS ".($deleted ? '' : 'NOT').' NULL';
170
+		}
171
+		if ($end)
172
+		{
173
+			$where[] = "range_start<".(int)$end;
174
+		}
175
+		if ($start)
176
+		{
177
+			$where[] = "(range_end IS NULL OR range_end>".(int)$start.")";
178
+		}
179
+		if ($_where)
180
+		{
181
+			$where = array_merge($where, $_where);
182
+		}
167 183
 
168 184
 		$sql = "(SELECT * FROM $this->cal_table WHERE ".$this->db->expression($this->cal_table, $where).") $this->cal_table";
169 185
 
@@ -184,16 +200,32 @@  discard block
 block discarded – undo
184 200
 	 */
185 201
 	protected function dates_range_view($start, $end, array $_where=null, $deleted=false)
186 202
 	{
187
-		if ($GLOBALS['egw_info']['server']['no_timerange_views'] || !$start || !$end)	// using view without start- AND end-date is slower!
203
+		if ($GLOBALS['egw_info']['server']['no_timerange_views'] || !$start || !$end)
204
+		{
205
+			// using view without start- AND end-date is slower!
188 206
 		{
189
-			return $this->dates_table;	// no need / use for a view
207
+			return $this->dates_table;
208
+		}
209
+		// no need / use for a view
190 210
 		}
191 211
 
192 212
 		$where = array();
193
-		if (isset($deleted)) $where['recur_exception'] = $deleted;
194
-		if ($end) $where[] = "cal_start<".(int)$end;
195
-		if ($start) $where[] = "cal_end>".(int)$start;
196
-		if ($_where) $where = array_merge($where, $_where);
213
+		if (isset($deleted))
214
+		{
215
+			$where['recur_exception'] = $deleted;
216
+		}
217
+		if ($end)
218
+		{
219
+			$where[] = "cal_start<".(int)$end;
220
+		}
221
+		if ($start)
222
+		{
223
+			$where[] = "cal_end>".(int)$start;
224
+		}
225
+		if ($_where)
226
+		{
227
+			$where = array_merge($where, $_where);
228
+		}
197 229
 
198 230
 		// Api\Db::union uses Api\Db::select which check if join contains "WHERE"
199 231
 		// to support old join syntax like ", other_table WHERE ...",
@@ -243,7 +275,10 @@  discard block
 block discarded – undo
243 275
 			throw new Api\Exception\AssertionFailed("Unsupported value for parameters!");
244 276
 		}
245 277
 		$where = is_array($params['query']) ? $params['query'] : array();
246
-		if ($cat_id) $where[] = $this->cat_filter($cat_id);
278
+		if ($cat_id)
279
+		{
280
+			$where[] = $this->cat_filter($cat_id);
281
+		}
247 282
 		$egw_cal = $this->cal_range_view($start, $end, $where, $filter == 'everything' ? null : $filter != 'deleted');
248 283
 
249 284
 		$status_filter = $this->status_filter($filter, $params['enum_recuring']);
@@ -264,7 +299,10 @@  discard block
 block discarded – undo
264 299
 		if ($users)
265 300
 		{
266 301
 			// fix $users to also prefix system users and groups (with 'u')
267
-			if (!is_array($users)) $users = $users ? (array)$users : array();
302
+			if (!is_array($users))
303
+			{
304
+				$users = $users ? (array)$users : array();
305
+			}
268 306
 			foreach($users as &$uid)
269 307
 			{
270 308
 				$user_type = $user_id = null;
@@ -284,15 +322,22 @@  discard block
 block discarded – undo
284 322
 			$sql .= " AND\n	".$params['sql_filter'];
285 323
 		}
286 324
 
287
-		if ($params['order'])	// only order if requested
325
+		if ($params['order'])
288 326
 		{
289
-			if (!preg_match('/^[a-z_ ,c]+$/i',$params['order'])) $params['order'] = 'cal_start';		// gard against SQL injection
327
+			// only order if requested
328
+		{
329
+			if (!preg_match('/^[a-z_ ,c]+$/i',$params['order'])) $params['order'] = 'cal_start';
330
+		}
331
+		// gard against SQL injection
290 332
 			$sql .= "\nORDER BY ".$params['order'];
291 333
 		}
292 334
 
293
-		if ($offset === false)	// return all rows --> Api\Db::query wants offset=0, num_rows=-1
335
+		if ($offset === false)
336
+		{
337
+			// return all rows --> Api\Db::query wants offset=0, num_rows=-1
294 338
 		{
295 339
 			$offset = 0;
340
+		}
296 341
 			$num_rows = -1;
297 342
 		}
298 343
 		$events =& $this->get_events($this->db->query($sql, __LINE__, __FILE__, $offset, $num_rows));
@@ -318,26 +363,35 @@  discard block
 block discarded – undo
318 363
 		$join = "LEFT JOIN $this->repeats_table ON $this->cal_table.cal_id=$this->repeats_table.cal_id";
319 364
 
320 365
 		$where = array();
321
-		if (is_scalar($ids) && !is_numeric($ids))	// a single uid
366
+		if (is_scalar($ids) && !is_numeric($ids))
367
+		{
368
+			// a single uid
322 369
 		{
323 370
 			// We want only the parents to match
324 371
 			$where['cal_uid'] = $ids;
372
+		}
325 373
 			$where['cal_reference'] = 0;
326 374
 		}
327
-		elseif(is_array($ids) && isset($ids[count($ids)-1]) || is_scalar($ids))	// one or more cal_id's
375
+		elseif(is_array($ids) && isset($ids[count($ids)-1]) || is_scalar($ids))
376
+		{
377
+			// one or more cal_id's
328 378
 		{
329 379
 			$where['cal_id'] = $ids;
330 380
 		}
381
+		}
331 382
 		else	// array with column => value pairs
332 383
 		{
333 384
 			$where = $ids;
334 385
 			unset($ids);	// otherwise users get not read!
335 386
 		}
336
-		if (isset($where['cal_id']))	// prevent non-unique column-name cal_id
387
+		if (isset($where['cal_id']))
388
+		{
389
+			// prevent non-unique column-name cal_id
337 390
 		{
338 391
 			$where[] = $this->db->expression($this->cal_table, $this->cal_table.'.',array(
339 392
 				'cal_id' => $where['cal_id'],
340 393
 			));
394
+		}
341 395
 			unset($where['cal_id']);
342 396
 		}
343 397
 		if ((int) $recur_date)
@@ -387,10 +441,16 @@  discard block
 block discarded – undo
387 441
 			$row['recur_exception'] = $row['alarm'] = array();
388 442
 			$events[$row['cal_id']] = Api\Db::strip_array_keys($row,'cal_');
389 443
 		}
390
-		if (!$events) return $events;
444
+		if (!$events)
445
+		{
446
+			return $events;
447
+		}
391 448
 
392 449
 		$ids = array_keys($events);
393
-		if (count($ids) == 1) $ids = $ids[0];
450
+		if (count($ids) == 1)
451
+		{
452
+			$ids = $ids[0];
453
+		}
394 454
 
395 455
 		foreach ($events as &$event)
396 456
 		{
@@ -464,10 +524,13 @@  discard block
 block discarded – undo
464 524
 			'cal_id'      => $ids,
465 525
 			'cal_recur_date' => $recur_date,
466 526
 			"cal_status NOT IN ('X','E')",
467
-		),__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
527
+		),__LINE__,__FILE__,false,'ORDER BY cal_user_type DESC,cal_recur_date ASC,'.self::STATUS_SORT,'calendar') as $row)
528
+		{
529
+			// DESC puts users before resources and contacts
468 530
 		{
469 531
 			// combine all participant data in uid and status values
470 532
 			$uid    = self::combine_user($row['cal_user_type'], $row['cal_user_id'], $row['cal_user_attendee']);
533
+		}
471 534
 			$status = self::combine_status($row['cal_status'],$row['cal_quantity'],$row['cal_role']);
472 535
 
473 536
 			$events[$row['cal_id']]['participants'][$uid] = $status;
@@ -524,7 +587,10 @@  discard block
 block discarded – undo
524 587
 			$last_request = time();
525 588
 		}
526 589
 		$signature = serialize(func_get_args());
527
-		if (isset($ctags[$signature])) return $ctags[$signature];
590
+		if (isset($ctags[$signature]))
591
+		{
592
+			return $ctags[$signature];
593
+		}
528 594
 
529 595
 		$types = array();
530 596
 		foreach((array)$users as $uid)
@@ -557,7 +623,10 @@  discard block
 block discarded – undo
557 623
 			// owner can only by users, no groups or resources
558 624
 			foreach($users as $key => $user)
559 625
 			{
560
-				if (!($user > 0)) unset($users[$key]);
626
+				if (!($user > 0))
627
+				{
628
+					unset($users[$key]);
629
+				}
561 630
 			}
562 631
 			$where = $this->db->expression($this->user_table, '(', $where, ' OR ').
563 632
 				$this->db->expression($this->cal_table, array(
@@ -579,7 +648,10 @@  discard block
 block discarded – undo
579 648
 	 */
580 649
 	function get_cal_data(array $query, $cols='cal_id,cal_reference,cal_etag,cal_modified,cal_user_modified')
581 650
 	{
582
-		if (!is_array($cols)) $cols = explode(',', $cols);
651
+		if (!is_array($cols))
652
+		{
653
+			$cols = explode(',', $cols);
654
+		}
583 655
 
584 656
 		// special handling of cal_user_modified "pseudo" column
585 657
 		if (($key = array_search('cal_user_modified', $cols)) !== false)
@@ -604,7 +676,10 @@  discard block
 block discarded – undo
604 676
 		{
605 677
 			$cats = $GLOBALS['egw']->categories->return_all_children($cat_id);
606 678
 			array_walk($cats,create_function('&$val,$key','$val = (int) $val;'));
607
-			if (is_array($cat_id) && count($cat_id)==1) $cat_id = $cat_id[0];
679
+			if (is_array($cat_id) && count($cat_id)==1)
680
+			{
681
+				$cat_id = $cat_id[0];
682
+			}
608 683
 			$sql = '(cal_category'.(count($cats) > 1 ? " IN ('".implode("','",$cats)."')" : '='.$this->db->quote((int)$cat_id));
609 684
 			foreach($cats as $cat)
610 685
 			{
@@ -663,10 +738,13 @@  discard block
 block discarded – undo
663 738
 				$where[] = "$this->user_table.cal_status NOT IN ('X','E')";
664 739
 				break;
665 740
 			default:
666
-				if ($enum_recuring)	// regular UI
741
+				if ($enum_recuring)
742
+				{
743
+					// regular UI
667 744
 				{
668 745
 					$where[] = "$this->user_table.cal_status NOT IN ('R','X','E')";
669 746
 				}
747
+				}
670 748
 				else	// CalDAV / eSync / iCal need to include 'E' = exceptions
671 749
 				{
672 750
 					$where[] = "$this->user_table.cal_status NOT IN ('R','X')";
@@ -798,7 +876,10 @@  discard block
 block discarded – undo
798 876
 						$user_ids = array();
799 877
 						foreach($ids as $user_id)
800 878
 						{
801
-							if ($GLOBALS['egw']->accounts->get_type($user_id) === 'u') $user_ids[] = $user_id;
879
+							if ($GLOBALS['egw']->accounts->get_type($user_id) === 'u')
880
+							{
881
+								$user_ids[] = $user_id;
882
+							}
802 883
 						}
803 884
 						$owner_or = $this->db->expression($cal_table_def,array('cal_owner' => $user_ids));
804 885
 					}
@@ -818,7 +899,10 @@  discard block
 block discarded – undo
818 899
 				}
819 900
 			}
820 901
 			// this is only used, when we cannot use UNIONS
821
-			if (!$useUnionQuery) $where[] = '('.implode(' OR ',$to_or).')';
902
+			if (!$useUnionQuery)
903
+			{
904
+				$where[] = '('.implode(' OR ',$to_or).')';
905
+			}
822 906
 
823 907
 			$where = $this->status_filter($filter, $params['enum_recuring'], $where);
824 908
 		}
@@ -837,7 +921,11 @@  discard block
 block discarded – undo
837 921
 				$where[] = '('.((int)$start).' < range_end OR range_end IS NULL)';
838 922
 			}
839 923
 		}
840
-		if (!preg_match('/^[a-z_ ,c]+$/i',$params['order'])) $params['order'] = 'cal_start';		// gard against SQL injection
924
+		if (!preg_match('/^[a-z_ ,c]+$/i',$params['order']))
925
+		{
926
+			$params['order'] = 'cal_start';
927
+		}
928
+		// gard against SQL injection
841 929
 
842 930
 		// if not enum recuring events, we have to use minimum start- AND end-dates, otherwise we get more then one event per cal_id!
843 931
 		if (!$params['enum_recuring'])
@@ -847,9 +935,15 @@  discard block
 block discarded – undo
847 935
 			// in case cal_start is used in a query, eg. calendar_ical::find_event
848 936
 			$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);
849 937
 			$params['order'] = str_replace('cal_start', 'range_start', $params['order']);
850
-			if ($end) $where[] = (int)$end.' > range_start';
938
+			if ($end)
939
+			{
940
+				$where[] = (int)$end.' > range_start';
941
+			}
851 942
   		}
852
-		elseif ($end) $where[] = (int)$end.' > cal_start';
943
+  		elseif ($end)
944
+		{
945
+			$where[] = (int)$end.' > cal_start';
946
+		}
853 947
 
854 948
 		if ($remove_rejected_by_user && $filter != 'everything')
855 949
 		{
@@ -863,7 +957,10 @@  discard block
 block discarded – undo
863 957
 				'rejected_by_user.cal_status IS NULL',
864 958
 				"rejected_by_user.cal_status NOT IN ('R','X')",
865 959
 			);
866
-			if ($filter == 'owner') $or_required[] = 'cal_owner='.(int)$remove_rejected_by_user;
960
+			if ($filter == 'owner')
961
+			{
962
+				$or_required[] = 'cal_owner='.(int)$remove_rejected_by_user;
963
+			}
867 964
 			$where[] = '('.implode(' OR ',$or_required).')';
868 965
 		}
869 966
 		// using a time-range and deleted attribute limited view instead of full table
@@ -885,7 +982,10 @@  discard block
 block discarded – undo
885 982
 		if ($useUnionQuery)
886 983
 		{
887 984
 			// allow apps to supply participants and/or icons
888
-			if (!isset($params['cols'])) $cols .= ',NULL AS participants,NULL AS icons';
985
+			if (!isset($params['cols']))
986
+			{
987
+				$cols .= ',NULL AS participants,NULL AS icons';
988
+			}
889 989
 
890 990
 			// changed the original OR in the query into a union, to speed up the query execution under MySQL 5
891 991
 			// with time-range views benefit is now at best slim for huge tables or none at all!
@@ -940,9 +1040,12 @@  discard block
 block discarded – undo
940 1040
 					$selects[count($selects)-1]['where'][] = "$this->user_table.cal_recur_date=cal_start";
941 1041
 				}
942 1042
 			}
943
-			if (is_numeric($offset) && !$params['no_total'])	// get the total too
1043
+			if (is_numeric($offset) && !$params['no_total'])
1044
+			{
1045
+				// get the total too
944 1046
 			{
945 1047
 				$save_selects = $selects;
1048
+			}
946 1049
 				// 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 1050
 				foreach(array_keys($selects) as $key)
948 1051
 				{
@@ -953,14 +1056,20 @@  discard block
 block discarded – undo
953 1056
 							array('range_start AS cal_start','range_end AS cal_end'), $selects[$key]['cols']);
954 1057
 					}
955 1058
 				}
956
-				if (!isset($params['cols']) && !$params['no_integration']) self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']);
1059
+				if (!isset($params['cols']) && !$params['no_integration'])
1060
+				{
1061
+					self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']);
1062
+				}
957 1063
 
958 1064
 				$this->total = $this->db->union($selects,__LINE__,__FILE__)->NumRows();
959 1065
 
960 1066
 				// restore original cols / selects
961 1067
 				$selects = $save_selects; unset($save_selects);
962 1068
 			}
963
-			if (!isset($params['cols']) && !$params['no_integration']) self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']);
1069
+			if (!isset($params['cols']) && !$params['no_integration'])
1070
+			{
1071
+				self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']);
1072
+			}
964 1073
 
965 1074
 			$rs = $this->db->union($selects,__LINE__,__FILE__,$params['order'],$offset,$num_rows);
966 1075
 		}
@@ -978,9 +1087,12 @@  discard block
 block discarded – undo
978 1087
 				'table_def' => $cal_table_def,
979 1088
 			));
980 1089
 
981
-			if (is_numeric($offset) && !$params['no_total'])	// get the total too
1090
+			if (is_numeric($offset) && !$params['no_total'])
1091
+			{
1092
+				// get the total too
982 1093
 			{
983 1094
 				$save_selects = $selects;
1095
+			}
984 1096
 				// 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)
985 1097
 				$selects[0]['cols'] = "$this->cal_table.cal_id,cal_start";
986 1098
 				if (!isset($params['cols']) && !$params['no_integration'] && $this->db->capabilities['union'])
@@ -1008,7 +1120,10 @@  discard block
 block discarded – undo
1008 1120
 		foreach($rs as $row)
1009 1121
 		{
1010 1122
 			$id = $row['cal_id'];
1011
-			if (is_numeric($id)) $ids[] = $id;
1123
+			if (is_numeric($id))
1124
+			{
1125
+				$ids[] = $id;
1126
+			}
1012 1127
 
1013 1128
 			if ($row['cal_recur_date'])
1014 1129
 			{
@@ -1028,7 +1143,10 @@  discard block
 block discarded – undo
1028 1143
 			$row['recur_exception'] = $row['alarm'] = array();
1029 1144
 
1030 1145
 			// compile a list of recurrences per cal_id
1031
-			if (!in_array($id,(array)$recur_ids[$row['cal_id']])) $recur_ids[$row['cal_id']][] = $id;
1146
+			if (!in_array($id,(array)$recur_ids[$row['cal_id']]))
1147
+			{
1148
+				$recur_ids[$row['cal_id']][] = $id;
1149
+			}
1032 1150
 
1033 1151
 			$events[$id] = Api\Db::strip_array_keys($row,'cal_');
1034 1152
 		}
@@ -1047,10 +1165,16 @@  discard block
 block discarded – undo
1047 1165
 					//'cal_id' => array_unique($ids),
1048 1166
 					'cal_recur_date' => $recur_dates,
1049 1167
 				),__LINE__,__FILE__,false,'ORDER BY cal_id,cal_user_type DESC,'.self::STATUS_SORT,'calendar',$num_rows,$join='',
1050
-				$this->db->get_table_definitions('calendar',$this->user_table)) as $row)	// DESC puts users before resources and contacts
1168
+				$this->db->get_table_definitions('calendar',$this->user_table)) as $row)
1169
+			{
1170
+				// DESC puts users before resources and contacts
1051 1171
 			{
1052 1172
 				$id = $row['cal_id'];
1053
-				if ($row['cal_recur_date']) $id .= '-'.$row['cal_recur_date'];
1173
+			}
1174
+				if ($row['cal_recur_date'])
1175
+				{
1176
+					$id .= '-'.$row['cal_recur_date'];
1177
+				}
1054 1178
 
1055 1179
 				// combine all participant data in uid and status values
1056 1180
 				$uid = self::combine_user($row['cal_user_type'], $row['cal_user_id'], $row['cal_user_attendee']);
@@ -1069,7 +1193,10 @@  discard block
 block discarded – undo
1069 1193
 				}
1070 1194
 
1071 1195
 				// set data, if recurrence is requested
1072
-				if (isset($events[$id])) $events[$id]['participants'][$uid] = $status;
1196
+				if (isset($events[$id]))
1197
+				{
1198
+					$events[$id]['participants'][$uid] = $status;
1199
+				}
1073 1200
 			}
1074 1201
 			// query recurrance exceptions, if needed: enum_recuring && !daywise is used in calendar_groupdav::get_series($uid,...)
1075 1202
 			if (!$params['enum_recuring'] || !$params['daywise'])
@@ -1085,7 +1212,10 @@  discard block
 block discarded – undo
1085 1212
 					{
1086 1213
 						foreach($events as $id => $event)
1087 1214
 						{
1088
-							if ($event['id'] == $row['cal_id']) break;
1215
+							if ($event['id'] == $row['cal_id'])
1216
+							{
1217
+								break;
1218
+							}
1089 1219
 						}
1090 1220
 					}
1091 1221
 					$events[$id]['recur_exception'][] = $row['cal_start'];
@@ -1095,7 +1225,10 @@  discard block
 block discarded – undo
1095 1225
 			if (!is_null($params['cfs']))
1096 1226
 			{
1097 1227
 				$where = array('cal_id' => $ids);
1098
-				if ($params['cfs']) $where['cal_extra_name'] = $params['cfs'];
1228
+				if ($params['cfs'])
1229
+				{
1230
+					$where['cal_extra_name'] = $params['cfs'];
1231
+				}
1099 1232
 				foreach($this->db->select($this->extra_table,'*',$where,
1100 1233
 					__LINE__,__FILE__,false,'','calendar') as $row)
1101 1234
 				{
@@ -1115,14 +1248,20 @@  discard block
 block discarded – undo
1115 1248
 				{
1116 1249
 					$event_start = $alarm['time'] + $alarm['offset'];
1117 1250
 
1118
-					if (isset($events[$cal_id]))	// none recuring event
1251
+					if (isset($events[$cal_id]))
1252
+					{
1253
+						// none recuring event
1119 1254
 					{
1120 1255
 						$events[$cal_id]['alarm'][$id] = $alarm;
1121 1256
 					}
1122
-					elseif (isset($events[$cal_id.'-'.$event_start]))	// recuring event
1257
+					}
1258
+					elseif (isset($events[$cal_id.'-'.$event_start]))
1259
+					{
1260
+						// recuring event
1123 1261
 					{
1124 1262
 						$events[$cal_id.'-'.$event_start]['alarm'][$id] = $alarm;
1125 1263
 					}
1264
+					}
1126 1265
 				}
1127 1266
 			}
1128 1267
 		}
@@ -1222,10 +1361,13 @@  discard block
 block discarded – undo
1222 1361
 			}
1223 1362
 			foreach((array)$cols as $col)
1224 1363
 			{
1225
-				if (substr($col,0,7) == 'egw_cal')	// remove table name
1364
+				if (substr($col,0,7) == 'egw_cal')
1365
+				{
1366
+					// remove table name
1226 1367
 				{
1227 1368
 					$col = preg_replace('/^egw_cal[a-z_]*\./','',$col);
1228 1369
 				}
1370
+				}
1229 1371
 				if (isset($app_cols[$col]))
1230 1372
 				{
1231 1373
 					$return_cols[] = $app_cols[$col];
@@ -1319,7 +1461,11 @@  discard block
 block discarded – undo
1319 1461
 		if (isset($GLOBALS['egw_info']['user']['preferences']['syncml']['minimum_uid_length']))
1320 1462
 		{
1321 1463
 			$minimum_uid_length = $GLOBALS['egw_info']['user']['preferences']['syncml']['minimum_uid_length'];
1322
-			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!
1464
+			if (empty($minimum_uid_length) || $minimum_uid_length<=1)
1465
+			{
1466
+				$minimum_uid_length = 8;
1467
+			}
1468
+			// we just do not accept no uid, or uid way to short!
1323 1469
 		}
1324 1470
 		else
1325 1471
 		{
@@ -1367,7 +1513,10 @@  discard block
 block discarded – undo
1367 1513
 			}
1368 1514
 		}
1369 1515
 		// set range_start/_end, but only if we have cal_start/_end, as otherwise we destroy present values!
1370
-		if (isset($event['cal_start'])) $event['range_start'] = $event['cal_start'];
1516
+		if (isset($event['cal_start']))
1517
+		{
1518
+			$event['range_start'] = $event['cal_start'];
1519
+		}
1371 1520
 		if (isset($event['cal_end']))
1372 1521
 		{
1373 1522
 			$event['range_end'] = $event['recur_type'] == MCAL_RECUR_NONE ? $event['cal_end'] :
@@ -1388,7 +1537,10 @@  discard block
 block discarded – undo
1388 1537
 		$event['cal_category'] = implode(',',$categories);
1389 1538
 
1390 1539
 		// make sure recurring events never reference to an other recurrent event
1391
-		if ($event['recur_type'] != MCAL_RECUR_NONE) $event['cal_reference'] = 0;
1540
+		if ($event['recur_type'] != MCAL_RECUR_NONE)
1541
+		{
1542
+			$event['cal_reference'] = 0;
1543
+		}
1392 1544
 
1393 1545
 		if ($cal_id)
1394 1546
 		{
@@ -1405,7 +1557,10 @@  discard block
 block discarded – undo
1405 1557
 			{
1406 1558
 				$old_tz_id = $this->db->select($this->cal_table,'tz_id',$where,__LINE__,__FILE__,'calendar')->fetchColumn();
1407 1559
 			}
1408
-			if (!is_null($etag)) $where['cal_etag'] = $etag;
1560
+			if (!is_null($etag))
1561
+			{
1562
+				$where['cal_etag'] = $etag;
1563
+			}
1409 1564
 
1410 1565
 			unset($event['cal_etag']);
1411 1566
 			$event[] = 'cal_etag=cal_etag+1';	// always update the etag, even if none given to check
@@ -1416,14 +1571,24 @@  discard block
 block discarded – undo
1416 1571
 			{
1417 1572
 				return 0;	// wrong etag, someone else updated the entry
1418 1573
 			}
1419
-			if (!is_null($etag)) ++$etag;
1574
+			if (!is_null($etag))
1575
+			{
1576
+				++$etag;
1577
+			}
1420 1578
 		}
1421 1579
 		else
1422 1580
 		{
1423 1581
 			// new event
1424
-			if (!$event['cal_owner']) $event['cal_owner'] = $GLOBALS['egw_info']['user']['account_id'];
1582
+			if (!$event['cal_owner'])
1583
+			{
1584
+				$event['cal_owner'] = $GLOBALS['egw_info']['user']['account_id'];
1585
+			}
1425 1586
 
1426
-			if (!$event['cal_id'] && !isset($event['cal_uid'])) $event['cal_uid'] = '';	// uid is NOT NULL!
1587
+			if (!$event['cal_id'] && !isset($event['cal_uid']))
1588
+			{
1589
+				$event['cal_uid'] = '';
1590
+			}
1591
+			// uid is NOT NULL!
1427 1592
 
1428 1593
 			$this->db->insert($this->cal_table,$event,false,__LINE__,__FILE__,'calendar');
1429 1594
 			if (!($cal_id = $this->db->get_last_insert_id($this->cal_table,'cal_id')))
@@ -1575,8 +1740,7 @@  discard block
 block discarded – undo
1575 1740
 					// recurrences need to be truncated
1576 1741
 					if((int)$event['recur_enddate'] > 0 &&
1577 1742
 						((int)$old_repeats['recur_enddate'] == 0 || (int)$old_repeats['recur_enddate'] > (int)$event['recur_enddate'])
1578
-					)
1579
-					{
1743
+					) {
1580 1744
 						$this->db->delete($this->user_table,array('cal_id' => $cal_id,'cal_recur_date >= '.($event['recur_enddate'] + 1*DAY_s)),__LINE__,__FILE__,'calendar');
1581 1745
 						$this->db->delete($this->dates_table,array('cal_id' => $cal_id,'cal_start >= '.($event['recur_enddate'] + 1*DAY_s)),__LINE__,__FILE__,'calendar');
1582 1746
 					}
@@ -1584,8 +1748,7 @@  discard block
 block discarded – undo
1584 1748
 					// recurrences need to be expanded
1585 1749
 					if(((int)$event['recur_enddate'] == 0 && (int)$old_repeats['recur_enddate'] > 0)
1586 1750
 						|| ((int)$event['recur_enddate'] > 0 && (int)$old_repeats['recur_enddate'] > 0 && (int)$old_repeats['recur_enddate'] < (int)$event['recur_enddate'])
1587
-					)
1588
-					{
1751
+					) {
1589 1752
 						$set_recurrences = true;
1590 1753
 						$set_recurrences_start = ($old_repeats['recur_enddate'] + 1*DAY_s);
1591 1754
 					}
@@ -1732,12 +1895,18 @@  discard block
 block discarded – undo
1732 1895
 	{
1733 1896
 		//echo "<p>socal::move($cal_id,$start,$end,$change_since,$old_start,$old_end)</p>\n";
1734 1897
 
1735
-		if (!(int) $cal_id) return false;
1898
+		if (!(int) $cal_id)
1899
+		{
1900
+			return false;
1901
+		}
1736 1902
 
1737 1903
 		if (!$old_start)
1738 1904
 		{
1739
-			if ($change_since !== false) $row = $this->db->select($this->dates_table,'MIN(cal_start) AS cal_start,MIN(cal_end) AS cal_end',
1905
+			if ($change_since !== false)
1906
+			{
1907
+				$row = $this->db->select($this->dates_table,'MIN(cal_start) AS cal_start,MIN(cal_end) AS cal_end',
1740 1908
 				array('cal_id'=>$cal_id),__LINE__,__FILE__,false,'','calendar')->fetch();
1909
+			}
1741 1910
 			// if no recurrence found, create one with the new dates
1742 1911
 			if ($change_since === false || !$row || !$row['cal_start'] || !$row['cal_end'])
1743 1912
 			{
@@ -1839,7 +2008,10 @@  discard block
 block discarded – undo
1839 2008
 			$user_type = $uid[0];
1840 2009
 			$email = substr($uid, 1);
1841 2010
 			$matches = null;
1842
-			if (preg_match('/<([^<>]+)>$/', $email, $matches)) $email = $matches[1];
2011
+			if (preg_match('/<([^<>]+)>$/', $email, $matches))
2012
+			{
2013
+				$email = $matches[1];
2014
+			}
1843 2015
 			$user_id = md5(trim(strtolower($email)));
1844 2016
 		}
1845 2017
 		else
@@ -1859,8 +2031,14 @@  discard block
 block discarded – undo
1859 2031
 	 */
1860 2032
 	static function combine_status($status,$quantity=1,$role='REQ-PARTICIPANT')
1861 2033
 	{
1862
-		if ((int)$quantity > 1) $status .= (int)$quantity;
1863
-		if ($role != 'REQ-PARTICIPANT') $status .= $role;
2034
+		if ((int)$quantity > 1)
2035
+		{
2036
+			$status .= (int)$quantity;
2037
+		}
2038
+		if ($role != 'REQ-PARTICIPANT')
2039
+		{
2040
+			$status .= $role;
2041
+		}
1864 2042
 
1865 2043
 		return $status;
1866 2044
 	}
@@ -1881,8 +2059,14 @@  discard block
 block discarded – undo
1881 2059
 		$matches = null;
1882 2060
 		if (is_string($status) && strlen($status) > 1 && preg_match('/^.([0-9]*)(.*)$/',$status,$matches))
1883 2061
 		{
1884
-			if ((int)$matches[1] > 0) $quantity = (int)$matches[1];
1885
-			if ($matches[2]) $role = $matches[2];
2062
+			if ((int)$matches[1] > 0)
2063
+			{
2064
+				$quantity = (int)$matches[1];
2065
+			}
2066
+			if ($matches[2])
2067
+			{
2068
+				$role = $matches[2];
2069
+			}
1886 2070
 			$status = $status[0];
1887 2071
 		}
1888 2072
 		elseif ($status === true)
@@ -1993,9 +2177,13 @@  discard block
 block discarded – undo
1993 2177
 			}
1994 2178
 		}
1995 2179
 
1996
-		if (count($participants))	// participants which need to be added
2180
+		if (count($participants))
2181
+		{
2182
+			// participants which need to be added
1997 2183
 		{
1998
-			if (!count($recurrences)) $recurrences[] = 0;   // insert the default recurrence
2184
+			if (!count($recurrences)) $recurrences[] = 0;
2185
+		}
2186
+		// insert the default recurrence
1999 2187
 
2000 2188
 			$delete_deleted = array();
2001 2189
 
@@ -2067,7 +2255,10 @@  discard block
 block discarded – undo
2067 2255
 			return false;
2068 2256
 		}
2069 2257
 
2070
-		if (is_numeric($status)) $status = $status_code_short[$status];
2258
+		if (is_numeric($status))
2259
+		{
2260
+			$status = $status_code_short[$status];
2261
+		}
2071 2262
 
2072 2263
 		$uid = self::combine_user($user_type, $user_id);
2073 2264
 		$user_id_md5 = null;
@@ -2087,16 +2278,25 @@  discard block
 block discarded – undo
2087 2278
 			$where[] = '(cal_recur_date=0 OR cal_recur_date >= '.time().')';
2088 2279
 		}
2089 2280
 
2090
-		if ($status == 'G')		// remove group invitations, as we dont store them in the db
2281
+		if ($status == 'G')
2282
+		{
2283
+			// remove group invitations, as we dont store them in the db
2091 2284
 		{
2092 2285
 			$this->db->delete($this->user_table,$where,__LINE__,__FILE__,'calendar');
2286
+		}
2093 2287
 			$ret = $this->db->affected_rows();
2094 2288
 		}
2095 2289
 		else
2096 2290
 		{
2097 2291
 			$set = array('cal_status' => $status);
2098
-			if ($user_type == 'e' || $attendee) $set['cal_user_attendee'] = $attendee ? $attendee : $user_id;
2099
-			if (!is_null($role) && $role != 'REQ-PARTICIPANT') $set['cal_role'] = $role;
2292
+			if ($user_type == 'e' || $attendee)
2293
+			{
2294
+				$set['cal_user_attendee'] = $attendee ? $attendee : $user_id;
2295
+			}
2296
+			if (!is_null($role) && $role != 'REQ-PARTICIPANT')
2297
+			{
2298
+				$set['cal_role'] = $role;
2299
+			}
2100 2300
 			$this->db->insert($this->user_table,$set,$where,__LINE__,__FILE__,'calendar');
2101 2301
 			// for new or changed group-invitations, remove previously deleted members, so they show up again
2102 2302
 			if (($ret = $this->db->affected_rows()) && $user_type == 'u' && $user_id < 0)
@@ -2129,7 +2329,10 @@  discard block
 block discarded – undo
2129 2329
 	{
2130 2330
 		//error_log(__METHOD__."($cal_id, $start, $end, ".array2string($participants).", ".array2string($exception));
2131 2331
 		$update = array('cal_end' => $end);
2132
-		if (isset($exception)) $update['recur_exception'] = $exception;
2332
+		if (isset($exception))
2333
+		{
2334
+			$update['recur_exception'] = $exception;
2335
+		}
2133 2336
 
2134 2337
 		$this->db->insert($this->dates_table, $update, array(
2135 2338
 			'cal_id' => $cal_id,
@@ -2144,7 +2347,11 @@  discard block
 block discarded – undo
2144 2347
 		{
2145 2348
 			foreach($participants as $uid => $status)
2146 2349
 			{
2147
-				if ($status == 'G') continue;	// dont save group-invitations
2350
+				if ($status == 'G')
2351
+				{
2352
+					continue;
2353
+				}
2354
+				// dont save group-invitations
2148 2355
 
2149 2356
 				$type = '';
2150 2357
 				$id = null;
@@ -2373,7 +2580,10 @@  discard block
 block discarded – undo
2373 2580
 		}
2374 2581
 		$alarm['cal_id'] = $cal_id;		// we need the back-reference
2375 2582
 		// add an alarm uid, if none is given
2376
-		if (empty($alarm['uid']) && class_exists('Horde_Support_Uuid')) $alarm['uid'] = (string)new Horde_Support_Uuid;
2583
+		if (empty($alarm['uid']) && class_exists('Horde_Support_Uuid'))
2584
+		{
2585
+			$alarm['uid'] = (string)new Horde_Support_Uuid;
2586
+		}
2377 2587
 		//error_log(__METHOD__.__LINE__.' Save Alarm for CalID:'.$cal_id.'->'.array2string($alarm).'-->'.$id.'#'.function_backtrace());
2378 2588
 		// allways store job with the alarm owner as job-owner to get eg. the correct from address
2379 2589
 		if (!$this->async->set_timer($alarm['time'],$id,'calendar.calendar_boupdate.send_alarm',$alarm,$alarm['owner']))
@@ -2382,10 +2592,16 @@  discard block
 block discarded – undo
2382 2592
 		}
2383 2593
 
2384 2594
 		// update the modification information of the related event
2385
-		if ($update_modified) $this->updateModified($cal_id, true);
2595
+		if ($update_modified)
2596
+		{
2597
+			$this->updateModified($cal_id, true);
2598
+		}
2386 2599
 
2387 2600
 		// update cache, if used
2388
-		if (isset(self::$alarm_cache)) $this->read_alarms($cal_id, true);
2601
+		if (isset(self::$alarm_cache))
2602
+		{
2603
+			$this->read_alarms($cal_id, true);
2604
+		}
2389 2605
 
2390 2606
 		return $id;
2391 2607
 	}
@@ -2408,7 +2624,10 @@  discard block
 block discarded – undo
2408 2624
 				$this->async->cancel_timer($id);
2409 2625
 			}
2410 2626
 			// update cache, if used
2411
-			if (isset(self::$alarm_cache)) $this->read_alarms($cal_id, false);
2627
+			if (isset(self::$alarm_cache))
2628
+			{
2629
+				$this->read_alarms($cal_id, false);
2630
+			}
2412 2631
 		}
2413 2632
 		return count($alarms);
2414 2633
 	}
@@ -2431,7 +2650,10 @@  discard block
 block discarded – undo
2431 2650
 		$ret = $this->async->cancel_timer($id);
2432 2651
 
2433 2652
 		// update cache, if used
2434
-		if (isset(self::$alarm_cache)) $this->read_alarms($cal_id, true);
2653
+		if (isset(self::$alarm_cache))
2654
+		{
2655
+			$this->read_alarms($cal_id, true);
2656
+		}
2435 2657
 
2436 2658
 		return $ret;
2437 2659
 	}
@@ -2455,11 +2677,14 @@  discard block
 block discarded – undo
2455 2677
 			$user_id = null;
2456 2678
 			self::split_user($old_user,$user_type,$user_id);
2457 2679
 
2458
-			if ($user_type == 'u')	// only accounts can be owners of events
2680
+			if ($user_type == 'u')
2681
+			{
2682
+				// only accounts can be owners of events
2459 2683
 			{
2460 2684
 				foreach($this->db->select($this->cal_table,'cal_id',array('cal_owner' => $old_user),__LINE__,__FILE__,false,'','calendar') as $row)
2461 2685
 				{
2462 2686
 					$this->delete($row['cal_id']);
2687
+			}
2463 2688
 				}
2464 2689
 			}
2465 2690
 			$this->db->delete($this->user_table,array(
@@ -2487,11 +2712,14 @@  discard block
 block discarded – undo
2487 2712
 			{
2488 2713
 				$ids[] = $row['cal_id'];
2489 2714
 			}
2490
-			if ($ids) $this->db->delete($this->user_table,array(
2715
+			if ($ids)
2716
+			{
2717
+				$this->db->delete($this->user_table,array(
2491 2718
 				'cal_user_type' => 'u',
2492 2719
 				'cal_user_id' => $old_user,
2493 2720
 				'cal_id' => $ids,
2494 2721
 			),__LINE__,__FILE__,'calendar');
2722
+			}
2495 2723
 			// now change participant in the rest to contain new user instead of old user
2496 2724
 			$this->db->update($this->user_table,array(
2497 2725
 				'cal_user_id' => $new_user,
@@ -2516,8 +2744,14 @@  discard block
 block discarded – undo
2516 2744
 	{
2517 2745
 		$participant_status = array();
2518 2746
 		$where = array('cal_id' => $cal_id);
2519
-		if ($start != 0 && $end == 0) $where[] = '(cal_recur_date = 0 OR cal_recur_date >= ' . (int)$start . ')';
2520
-		if ($start == 0 && $end != 0) $where[] = '(cal_recur_date = 0 OR cal_recur_date <= ' . (int)$end . ')';
2747
+		if ($start != 0 && $end == 0)
2748
+		{
2749
+			$where[] = '(cal_recur_date = 0 OR cal_recur_date >= ' . (int)$start . ')';
2750
+		}
2751
+		if ($start == 0 && $end != 0)
2752
+		{
2753
+			$where[] = '(cal_recur_date = 0 OR cal_recur_date <= ' . (int)$end . ')';
2754
+		}
2521 2755
 		if ($start != 0 && $end != 0)
2522 2756
 		{
2523 2757
 			$where[] = '(cal_recur_date = 0 OR (cal_recur_date >= ' . (int)$start .
@@ -2528,7 +2762,10 @@  discard block
 block discarded – undo
2528 2762
 			// inititalize the array
2529 2763
 			$participant_status[$row['cal_recur_date']] = null;
2530 2764
 		}
2531
-		if (is_null($uid)) return $participant_status;
2765
+		if (is_null($uid))
2766
+		{
2767
+			return $participant_status;
2768
+		}
2532 2769
 		$user_type = $user_id = null;
2533 2770
 		self::split_user($uid, $user_type, $user_id, true);
2534 2771
 
@@ -2537,8 +2774,14 @@  discard block
 block discarded – undo
2537 2774
 			'cal_user_type'	=> $user_type ? $user_type : 'u',
2538 2775
 			'cal_user_id'   => $user_id,
2539 2776
 		);
2540
-		if ($start != 0 && $end == 0) $where2[] = '(cal_recur_date = 0 OR cal_recur_date >= ' . (int)$start . ')';
2541
-		if ($start == 0 && $end != 0) $where2[] = '(cal_recur_date = 0 OR cal_recur_date <= ' . (int)$end . ')';
2777
+		if ($start != 0 && $end == 0)
2778
+		{
2779
+			$where2[] = '(cal_recur_date = 0 OR cal_recur_date >= ' . (int)$start . ')';
2780
+		}
2781
+		if ($start == 0 && $end != 0)
2782
+		{
2783
+			$where2[] = '(cal_recur_date = 0 OR cal_recur_date <= ' . (int)$end . ')';
2784
+		}
2542 2785
 		if ($start != 0 && $end != 0)
2543 2786
 		{
2544 2787
 			$where2[] = '(cal_recur_date = 0 OR (cal_recur_date >= ' . (int)$start .
@@ -2628,17 +2871,26 @@  discard block
 block discarded – undo
2628 2871
 	 */
2629 2872
 	function get_recurrence_exceptions($event, $tz_id=null, $start=0, $end=0, $filter='all')
2630 2873
 	{
2631
-		if (!is_array($event)) return false;
2874
+		if (!is_array($event))
2875
+		{
2876
+			return false;
2877
+		}
2632 2878
 		$cal_id = (int) $event['id'];
2633 2879
 		//error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2634 2880
 		//		"($cal_id, $tz_id, $filter): " . $event['tzid']);
2635
-		if (!$cal_id || $event['recur_type'] == MCAL_RECUR_NONE) return false;
2881
+		if (!$cal_id || $event['recur_type'] == MCAL_RECUR_NONE)
2882
+		{
2883
+			return false;
2884
+		}
2636 2885
 
2637 2886
 		$days = array();
2638 2887
 
2639 2888
 		$expand_all = (!$this->isWholeDay($event) && $tz_id && $tz_id != $event['tzid']);
2640 2889
 
2641
-		if ($filter == 'tz_only' && !$expand_all) return $days;
2890
+		if ($filter == 'tz_only' && !$expand_all)
2891
+		{
2892
+			return $days;
2893
+		}
2642 2894
 
2643 2895
 		$remote = in_array($filter, array('tz_rrule', 'rrule'));
2644 2896
 
@@ -2681,7 +2933,10 @@  discard block
 block discarded – undo
2681 2933
 					$remote_rrule->next_no_exception();
2682 2934
 				}
2683 2935
 				$egw_rrule->next_no_exception();
2684
-				if (!$egw_rrule->valid()) return $days;
2936
+				if (!$egw_rrule->valid())
2937
+				{
2938
+					return $days;
2939
+				}
2685 2940
 			}
2686 2941
 			$day = $egw_rrule->current();
2687 2942
 			$locts = (int)Api\DateTime::to($day,'server');
@@ -2835,7 +3090,11 @@  discard block
 block discarded – undo
2835 3090
 			}
2836 3091
 		}
2837 3092
 
2838
-		if (empty($participants)) return false; // occurrence does not exist at all yet
3093
+		if (empty($participants))
3094
+		{
3095
+			return false;
3096
+		}
3097
+		// occurrence does not exist at all yet
2839 3098
 
2840 3099
 		foreach ($recurrence_zero as $uid => $status)
2841 3100
 		{
@@ -2892,7 +3151,9 @@  discard block
 block discarded – undo
2892 3151
 			}
2893 3152
 			if (!isset($participants[$uid])
2894 3153
 				|| $participants[$uid] != $status)
2895
-				return true;
3154
+			{
3155
+							return true;
3156
+			}
2896 3157
 			unset($participants[$uid]);
2897 3158
 		}
2898 3159
 		return (!empty($participants));
@@ -2906,7 +3167,10 @@  discard block
 block discarded – undo
2906 3167
 	 */
2907 3168
 	function isWholeDay($event)
2908 3169
 	{
2909
-		if (!isset($event['start']) || !isset($event['end'])) return false;
3170
+		if (!isset($event['start']) || !isset($event['end']))
3171
+		{
3172
+			return false;
3173
+		}
2910 3174
 
2911 3175
 		if (empty($event['tzid']))
2912 3176
 		{
@@ -2968,8 +3232,14 @@  discard block
 block discarded – undo
2968 3232
 	 */
2969 3233
 	function updateModified($id, $update_master=false, $time=null, $modifier=null)
2970 3234
 	{
2971
-		if (is_null($time) || !$time) $time = time();
2972
-		if (is_null($modifier)) $modifier = $GLOBALS['egw_info']['user']['account_id'];
3235
+		if (is_null($time) || !$time)
3236
+		{
3237
+			$time = time();
3238
+		}
3239
+		if (is_null($modifier))
3240
+		{
3241
+			$modifier = $GLOBALS['egw_info']['user']['account_id'];
3242
+		}
2973 3243
 
2974 3244
 		$this->db->update($this->cal_table,
2975 3245
 			array('cal_modified' => $time, 'cal_modifier' => $modifier),
Please login to merge, or discard this patch.