Test Setup Failed
Push — master ( 8d85b5...1738c0 )
by Nathan
19:57
created
calendar/inc/class.calendar_uilist.inc.php 1 patch
Spacing   +155 added lines, -155 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 	 *
39 39
 	 * @var mixed
40 40
 	 */
41
-	var $debug=false;
41
+	var $debug = false;
42 42
 	/**
43 43
 	 * Filternames
44 44
 	 *
@@ -59,11 +59,11 @@  discard block
 block discarded – undo
59 59
 	 *
60 60
 	 * @param array $set_states =null to manualy set / change one of the states, default NULL = use $_REQUEST
61 61
 	 */
62
-	function __construct($set_states=null)
62
+	function __construct($set_states = null)
63 63
 	{
64
-		parent::__construct(true,$set_states);	// call the parent's constructor
64
+		parent::__construct(true, $set_states); // call the parent's constructor
65 65
 
66
-		foreach($this->date_filters as $name => $label)
66
+		foreach ($this->date_filters as $name => $label)
67 67
 		{
68 68
 			$this->date_filters[$name] = lang($label);
69 69
 		}
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 	/**
75 75
 	 * Show the listview
76 76
 	 */
77
-	function listview($_content=null,$msg='',$home=false)
77
+	function listview($_content = null, $msg = '', $home = false)
78 78
 	{
79 79
 		if ($_GET['msg']) $msg .= $_GET['msg'];
80 80
 		if ($this->group_warning) $msg .= $this->group_warning;
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 		$etpl = new Etemplate('calendar.list');
83 83
 
84 84
 		// Handle merge from sidebox
85
-		if($_GET['merge'])
85
+		if ($_GET['merge'])
86 86
 		{
87 87
 			$_content['nm']['action'] = 'document_'.$_GET['merge'];
88 88
 			$_content['nm']['select_all'] = true;
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 		if (is_array($_content))
92 92
 		{
93 93
 			// handle a single button like actions
94
-			foreach(array('delete','timesheet','document') as $button)
94
+			foreach (array('delete', 'timesheet', 'document') as $button)
95 95
 			{
96 96
 				if ($_content['nm']['rows'][$button])
97 97
 				{
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 			if ($_content['nm']['action'])
105 105
 			{
106 106
 				// Allow merge using the date range filter
107
-				if(strpos($_content['nm']['action'],'document') !== false &&
107
+				if (strpos($_content['nm']['action'], 'document') !== false &&
108 108
 					!count($_content['nm']['selected']) && !$_content['nm']['select_all']) {
109 109
 					$_content['nm']['selected'][] = $this->get_merge_range($_content['nm']);
110 110
 				}
@@ -115,14 +115,14 @@  discard block
 block discarded – undo
115 115
 				else
116 116
 				{
117 117
 					$success = $failed = $action_msg = null;
118
-					if ($this->action($_content['nm']['action'],$_content['nm']['selected'],$_content['nm']['select_all'],
119
-						$success,$failed,$action_msg,'calendar_list',$msg, $_content['nm']['checkboxes']['no_notifications']))
118
+					if ($this->action($_content['nm']['action'], $_content['nm']['selected'], $_content['nm']['select_all'],
119
+						$success, $failed, $action_msg, 'calendar_list', $msg, $_content['nm']['checkboxes']['no_notifications']))
120 120
 					{
121
-						$msg .= lang('%1 event(s) %2',$success,$action_msg);
121
+						$msg .= lang('%1 event(s) %2', $success, $action_msg);
122 122
 					}
123
-					elseif(is_null($msg))
123
+					elseif (is_null($msg))
124 124
 					{
125
-						$msg .= lang('%1 event(s) %2, %3 failed because of insufficient rights !!!',$success,$action_msg,$failed);
125
+						$msg .= lang('%1 event(s) %2, %3 failed because of insufficient rights !!!', $success, $action_msg, $failed);
126 126
 					}
127 127
 				}
128 128
 			}
@@ -134,15 +134,15 @@  discard block
 block discarded – undo
134 134
 		{
135 135
 			$content['nm'] = array(
136 136
 				'get_rows'        =>	'calendar.calendar_uilist.get_rows',
137
-	 			'filter_no_lang'  => True,	// I  set no_lang for filter (=dont translate the options)
138
-				'no_filter2'      => True,	// I  disable the 2. filter (params are the same as for filter)
139
-				'no_cat'          => True,	// I  disable the cat-selectbox
137
+	 			'filter_no_lang'  => True, // I  set no_lang for filter (=dont translate the options)
138
+				'no_filter2'      => True, // I  disable the 2. filter (params are the same as for filter)
139
+				'no_cat'          => True, // I  disable the cat-selectbox
140 140
 				'filter'          => 'month',
141
-				'order'           => 'cal_start',// IO name of the column to sort after (optional for the sortheaders)
142
-				'sort'            => 'ASC',// IO direction of the sort: 'ASC' or 'DESC'
141
+				'order'           => 'cal_start', // IO name of the column to sort after (optional for the sortheaders)
142
+				'sort'            => 'ASC', // IO direction of the sort: 'ASC' or 'DESC'
143 143
 				'default_cols'    => '!week,weekday,cal_title,cal_description,recure,cal_location,cal_owner,cat_id,pm_id',
144 144
 				'filter_onchange' => "app.calendar.filter_change",
145
-				'row_id'          => 'row_id',	// set in get rows "$event[id]:$event[recur_date]"
145
+				'row_id'          => 'row_id', // set in get rows "$event[id]:$event[recur_date]"
146 146
 				'row_modified'    => 'modified',
147 147
 				'favorites'       => true,
148 148
 				'placeholder_actions' => array('add')
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 		}
151 151
 		$content['nm']['actions'] = $this->get_actions();
152 152
 
153
-		if (isset($_GET['filter']) && in_array($_GET['filter'],array_keys($this->date_filters)))
153
+		if (isset($_GET['filter']) && in_array($_GET['filter'], array_keys($this->date_filters)))
154 154
 		{
155 155
 			$content['nm']['filter'] = $_GET['filter'];
156 156
 		}
@@ -158,16 +158,16 @@  discard block
 block discarded – undo
158 158
 		{
159 159
 			$content['nm']['search'] = $_GET['search'];
160 160
 		}
161
-		if($this->owner)
161
+		if ($this->owner)
162 162
 		{
163
-			$content['nm']['col_filter']['participant'] = is_array($this->owner) ? $this->owner : explode(',',$this->owner);
163
+			$content['nm']['col_filter']['participant'] = is_array($this->owner) ? $this->owner : explode(',', $this->owner);
164 164
 		}
165 165
 		// search via jdots ajax_exec uses $_REQUEST['json_data'] instead of regular GET parameters
166 166
 		if (isset($_REQUEST['json_data']) && ($json_data = json_decode($_REQUEST['json_data'], true)) &&
167 167
 			!empty($json_data['request']['parameters'][0]))
168 168
 		{
169 169
 			$params = null;
170
-			parse_str(substr($json_data['request']['parameters'][0], 10), $params);	// cut off "/index.php?"
170
+			parse_str(substr($json_data['request']['parameters'][0], 10), $params); // cut off "/index.php?"
171 171
 			if (isset($params['keywords']))	// new search => set filters so every match is shown
172 172
 			{
173 173
 				$this->adjust_for_search($params['keywords'], $content['nm']);
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 		}
177 177
 		if (isset($_REQUEST['keywords']))	// new search => set filters so every match is shown
178 178
 		{
179
-			$this->adjust_for_search($_REQUEST['keywords'],$content['nm']);
179
+			$this->adjust_for_search($_REQUEST['keywords'], $content['nm']);
180 180
 			unset($_REQUEST['keywords']);
181 181
 		}
182 182
 		$sel_options['filter'] = &$this->date_filters;
@@ -184,15 +184,15 @@  discard block
 block discarded – undo
184 184
 		// Send categories for row styling - calendar uses no_cat, so they don't go automatically
185 185
 		$sel_options['category'] = array('' => lang('all')) + Etemplate\Widget\Select::typeOptions('select-cat', ',,calendar');
186 186
 		// Prevent double encoding - widget does this on its own, but we're just grabbing the options
187
-		foreach($sel_options['category'] as &$label)
187
+		foreach ($sel_options['category'] as &$label)
188 188
 		{
189
-			if(!is_array($label))
189
+			if (!is_array($label))
190 190
 			{
191
-				$label = html_entity_decode($label, ENT_NOQUOTES,'utf-8');
191
+				$label = html_entity_decode($label, ENT_NOQUOTES, 'utf-8');
192 192
 			}
193
-			elseif($label['label'])
193
+			elseif ($label['label'])
194 194
 			{
195
-				$label['label'] = html_entity_decode($label['label'], ENT_NOQUOTES,'utf-8');
195
+				$label['label'] = html_entity_decode($label['label'], ENT_NOQUOTES, 'utf-8');
196 196
 			}
197 197
 		}
198 198
 
@@ -200,15 +200,15 @@  discard block
 block discarded – undo
200 200
 		if ($this->prefs['limit_des_lines'] > 0 || (string)$this->prefs['limit_des_lines'] == '')
201 201
 		{
202 202
 			$content['css'] .= '<style type="text/css">@media screen { .listDescription {  max-height: '.
203
-				(($this->prefs['limit_des_lines'] ? $this->prefs['limit_des_lines'] : 5) * 1.35).	   // dono why em is not real lines
203
+				(($this->prefs['limit_des_lines'] ? $this->prefs['limit_des_lines'] : 5) * 1.35).// dono why em is not real lines
204 204
 				'em; overflow: auto; }}</style>';
205 205
 		}
206 206
 
207
-		if($msg)
207
+		if ($msg)
208 208
 		{
209 209
 			Framework::message($msg);
210 210
 		}
211
-		$html = $etpl->exec('calendar.calendar_uilist.listview',$content,$sel_options,array(),array(),$home ? -1 : 0);
211
+		$html = $etpl->exec('calendar.calendar_uilist.listview', $content, $sel_options, array(), array(), $home ? -1 : 0);
212 212
 
213 213
 		// Not sure why this has to be echoed instead of appended, but that's what works.
214 214
 		//echo calendar_uiviews::edit_series();
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 	/**
220 220
 	 * set filter for search, so that everything is shown
221 221
 	 */
222
-	function adjust_for_search($keywords,&$params)
222
+	function adjust_for_search($keywords, &$params)
223 223
 	{
224 224
 		$params['search'] = $keywords;
225 225
 		$params['start']  = 0;
@@ -243,9 +243,9 @@  discard block
 block discarded – undo
243 243
 	 * @param array &$rows returned rows/events
244 244
 	 * @param array &$readonlys eg. to disable buttons based on Acl
245 245
 	 */
246
-	function get_rows(&$params,&$rows,&$readonlys)
246
+	function get_rows(&$params, &$rows, &$readonlys)
247 247
 	{
248
-		unset($readonlys);	// not used;
248
+		unset($readonlys); // not used;
249 249
 		//echo "uilist::get_rows() params="; _debug_array($params);
250 250
 		$this->filter = $params['filter'];
251 251
 		if ($params['filter'] == 'custom')
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 			}
276 276
 			if ($old_params['search'] != $params['search'])
277 277
 			{
278
-				$this->adjust_for_search($params['search'],$params);
278
+				$this->adjust_for_search($params['search'], $params);
279 279
 				$this->filter = $params['filter'];
280 280
 			}
281 281
 		}
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
 		if (!$params['csv_export'])
284 284
 		{
285 285
 			Api\Cache::setSession('calendar', 'calendar_list',
286
-				array_diff_key ($params, array_flip(array('rows', 'actions', 'action_links', 'placeholder_actions'))));
286
+				array_diff_key($params, array_flip(array('rows', 'actions', 'action_links', 'placeholder_actions'))));
287 287
 		}
288 288
 
289 289
 		// release session to allow parallel requests to run
@@ -292,23 +292,23 @@  discard block
 block discarded – undo
292 292
 		// do we need to query custom fields and which
293 293
 		// Check stored preference if selectcols isn't available (ie: first call)
294 294
 		$select_cols = $params['selectcols'] ? $params['selectcols'] : $GLOBALS['egw_info']['user']['preferences']['calendar']['nextmatch-calendar.list.rows'];
295
-		if(!is_array($params['selectcols']))
295
+		if (!is_array($params['selectcols']))
296 296
 		{
297
-			$select_cols = explode(',',$select_cols);
297
+			$select_cols = explode(',', $select_cols);
298 298
 		}
299
-		if (in_array('cfs',$select_cols))
299
+		if (in_array('cfs', $select_cols))
300 300
 		{
301 301
 			$cfs = array();
302
-			foreach($select_cols as $col)
302
+			foreach ($select_cols as $col)
303 303
 			{
304
-				if ($col[0] == '#') $cfs[] = substr($col,1);
304
+				if ($col[0] == '#') $cfs[] = substr($col, 1);
305 305
 			}
306 306
 		}
307 307
 		$search_params = array(
308 308
 			'cat_id'  => $params['cat_id'] ? $params['cat_id'] : 0,
309 309
 			'filter'  => $this->filter,
310 310
 			'query'   => $params['search'],
311
-			'offset'  => (int) $params['start'],
311
+			'offset'  => (int)$params['start'],
312 312
 			'num_rows'=> $params['num_rows'],
313 313
 			'order'   => $params['order'] ? $params['order'].' '.$params['sort'] : 'cal_start ASC',
314 314
 			'cfs'	 => $params['csv_export'] ? array() : $cfs,
@@ -316,24 +316,24 @@  discard block
 block discarded – undo
316 316
 		// Non-blocking events above blocking
317 317
 		$search_params['order'] .= ', cal_non_blocking DESC';
318 318
 
319
-		switch($this->filter)
319
+		switch ($this->filter)
320 320
 		{
321 321
 			case 'all':
322 322
 				break;
323 323
 			case 'before':
324
-				$search_params['end'] = $params['date'] ? Api\DateTime::to($params['date'],'ts') : $this->date;
325
-				$label = lang('Before %1',$this->bo->long_date($search_params['end']));
324
+				$search_params['end'] = $params['date'] ? Api\DateTime::to($params['date'], 'ts') : $this->date;
325
+				$label = lang('Before %1', $this->bo->long_date($search_params['end']));
326 326
 				break;
327 327
 			case 'custom':
328
-				$this->first = $search_params['start'] = Api\DateTime::to($params['startdate'],'ts');
329
-				$this->last  = $search_params['end'] = strtotime('+1 day', $this->bo->date2ts($params['enddate']))-1;
330
-				$label = $this->bo->long_date($this->first,$this->last);
328
+				$this->first = $search_params['start'] = Api\DateTime::to($params['startdate'], 'ts');
329
+				$this->last  = $search_params['end'] = strtotime('+1 day', $this->bo->date2ts($params['enddate'])) - 1;
330
+				$label = $this->bo->long_date($this->first, $this->last);
331 331
 				break;
332 332
 			case 'today':
333 333
 				$today = new Api\DateTime();
334 334
 				$today->setTime(0, 0, 0);
335 335
 				$this->first = $search_params['start'] = $today->format('ts');
336
-				$today->setTime(23,59,59);
336
+				$today->setTime(23, 59, 59);
337 337
 				$this->last  = $search_params['end'] = $today->format('ts');
338 338
 				break;
339 339
 			case 'week':
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
 				$this->last['hour'] = 23; $this->last['minute'] = $this->last['sec'] = 59;
346 346
 				unset($this->last['raw']);
347 347
 				$this->last = $this->bo->date2ts($this->last);
348
-				$this->date_filters['week'] = $label = lang('Week').' '.adodb_date('W',$this->first).': '.$this->bo->long_date($this->first,$this->last);
348
+				$this->date_filters['week'] = $label = lang('Week').' '.adodb_date('W', $this->first).': '.$this->bo->long_date($this->first, $this->last);
349 349
 				$search_params['start'] = $this->first;
350 350
 				$search_params['end'] = $this->last;
351 351
 				$params['startdate'] = Api\DateTime::to($this->first, Api\DateTime::ET2);
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
 				unset($this->first['raw']);
360 360
 				$this->last = $this->first;
361 361
 				$this->last['month'] += 1;
362
-				$this->date_filters['month'] = $label = lang(adodb_date('F',$this->bo->date2ts($params['date']))).' '.$this->first['year'];
362
+				$this->date_filters['month'] = $label = lang(adodb_date('F', $this->bo->date2ts($params['date']))).' '.$this->first['year'];
363 363
 				$this->first = $this->bo->date2ts($this->first);
364 364
 				$this->last = $this->bo->date2ts($this->last);
365 365
 				$this->last--;
@@ -370,22 +370,22 @@  discard block
 block discarded – undo
370 370
 				break;
371 371
 
372 372
 			case 'after':
373
-				$this->date = $params['startdate'] ? Api\DateTime::to($params['startdate'],'ts') : $this->date;
374
-				$label = lang('After %1',$this->bo->long_date($this->date));
373
+				$this->date = $params['startdate'] ? Api\DateTime::to($params['startdate'], 'ts') : $this->date;
374
+				$label = lang('After %1', $this->bo->long_date($this->date));
375 375
 				$search_params['start'] = $this->date;
376 376
 				break;
377 377
 		}
378
-		if($params['status_filter'])
378
+		if ($params['status_filter'])
379 379
 		{
380 380
 			$search_params['filter'] = $params['status_filter'];
381 381
 		}
382 382
 		if ($params['col_filter']['participant'])
383 383
 		{
384
-			$search_params['users'] = is_array($params['col_filter']['participant']) ? $params['col_filter']['participant'] : array( $params['col_filter']['participant']);
384
+			$search_params['users'] = is_array($params['col_filter']['participant']) ? $params['col_filter']['participant'] : array($params['col_filter']['participant']);
385 385
 		}
386 386
 		elseif (!$params['col_filter'] || !$params['col_filter']['participant'])
387 387
 		{
388
-			$search_params['users'] = $params['owner'] ? $params['owner'] : explode(',',$this->owner);
388
+			$search_params['users'] = $params['owner'] ? $params['owner'] : explode(',', $this->owner);
389 389
 		}
390 390
 		// Allow private to stay for all viewed owners, even if in separate calendars
391 391
 		$search_params['private_allowed'] = (array)$params['selected_owners'] + (array)$search_params['users'];
@@ -393,9 +393,9 @@  discard block
 block discarded – undo
393 393
 		if ($params['col_filter'])
394 394
 		{
395 395
 			$col_filter = array();
396
-			foreach($params['col_filter'] as $name => $val)
396
+			foreach ($params['col_filter'] as $name => $val)
397 397
 			{
398
-				if (!in_array($name, array('participant','row_id')) && (string)$val !== '')
398
+				if (!in_array($name, array('participant', 'row_id')) && (string)$val !== '')
399 399
 				{
400 400
 					$col_filter[$name] = $val;
401 401
 				}
@@ -405,18 +405,18 @@  discard block
 block discarded – undo
405 405
 
406 406
 		// App header is mostly taken care of on the client side, but here we update
407 407
 		// it to match changing list filters
408
-		if($params['view'] && $params['view'] == 'listview' && Api\Json\Response::isJSONResponse())
408
+		if ($params['view'] && $params['view'] == 'listview' && Api\Json\Response::isJSONResponse())
409 409
 		{
410 410
 			Api\Json\Response::get()->call('app.calendar.set_app_header',
411
-				(count($search_params['users']) == 1 ? $this->bo->participant_name($search_params['users'][0]).': ' : '') .
411
+				(count($search_params['users']) == 1 ? $this->bo->participant_name($search_params['users'][0]).': ' : '').
412 412
 				$label);
413 413
 		}
414
-		foreach((array) $this->bo->search($search_params, !empty($col_filter) ? $col_filter : null) as $event)
414
+		foreach ((array)$this->bo->search($search_params, !empty($col_filter) ? $col_filter : null) as $event)
415 415
 		{
416 416
 
417 417
 			if ($params['csv_export'])
418 418
 			{
419
-				$event['participants'] = implode(",\n",$this->bo->participants($event,true));
419
+				$event['participants'] = implode(",\n", $this->bo->participants($event, true));
420 420
 			}
421 421
 			else
422 422
 			{
@@ -424,23 +424,23 @@  discard block
 block discarded – undo
424 424
 			}
425 425
 
426 426
 			$matches = null;
427
-			if(!(int)$event['id'] && preg_match('/^([a-z_-]+)([0-9]+)$/i',$event['id'],$matches))
427
+			if (!(int)$event['id'] && preg_match('/^([a-z_-]+)([0-9]+)$/i', $event['id'], $matches))
428 428
 			{
429 429
 				$app = $matches[1];
430 430
 				$app_id = $matches[2];
431 431
 				$icons = array();
432
-				if (($is_private = calendar_bo::integration_get_private($app,$app_id,$event)))
432
+				if (($is_private = calendar_bo::integration_get_private($app, $app_id, $event)))
433 433
 				{
434
-					$icons[] = Api\Html::image('calendar','private');
434
+					$icons[] = Api\Html::image('calendar', 'private');
435 435
 				}
436 436
 				else
437 437
 				{
438
-					$icons = calendar_uiviews::integration_get_icons($app,$app_id,$event);
438
+					$icons = calendar_uiviews::integration_get_icons($app, $app_id, $event);
439 439
 				}
440 440
 			}
441 441
 			else
442 442
 			{
443
-				$is_private = !$this->bo->check_perms(Acl::READ,$event);
443
+				$is_private = !$this->bo->check_perms(Acl::READ, $event);
444 444
 			}
445 445
 			if ($is_private)
446 446
 			{
@@ -451,9 +451,9 @@  discard block
 block discarded – undo
451 451
 			$event['app_id'] = $event['id'];
452 452
 
453 453
 			// Edit link
454
-			if($app && $app_id)
454
+			if ($app && $app_id)
455 455
 			{
456
-				$popup = calendar_uiviews::integration_get_popup($app,$app_id);
456
+				$popup = calendar_uiviews::integration_get_popup($app, $app_id);
457 457
 
458 458
 				// Need to strip off 'onclick'
459 459
 				$event['edit_link'] = preg_replace('/ ?onclick="(.+)"/i', '$1', $popup);
@@ -464,18 +464,18 @@  discard block
 block discarded – undo
464 464
 				// populate js_integration_data, if not already set
465 465
 				if (!isset($js_integration_data[$app]))
466 466
 				{
467
-					$js_integration_data[$app] = calendar_bo::integration_get_data($app,'edit_link');
467
+					$js_integration_data[$app] = calendar_bo::integration_get_data($app, 'edit_link');
468 468
 				}
469 469
 			}
470 470
 			elseif ($event['recur_type'] != MCAL_RECUR_NONE)
471 471
 			{
472
-				$event['app_id'] .= ':'.Api\DateTime::to($event['recur_date'] ? $event['recur_date'] : $event['start'],'ts');
472
+				$event['app_id'] .= ':'.Api\DateTime::to($event['recur_date'] ? $event['recur_date'] : $event['start'], 'ts');
473 473
 			}
474 474
 
475 475
 			// Format start and end with timezone
476
-			foreach(array('start','end') as $time)
476
+			foreach (array('start', 'end') as $time)
477 477
 			{
478
-				$event[$time] = Api\DateTime::to($event[$time],'Y-m-d\TH:i:s\Z');
478
+				$event[$time] = Api\DateTime::to($event[$time], 'Y-m-d\TH:i:s\Z');
479 479
 			}
480 480
 
481 481
 			$rows[] = $event;
@@ -485,35 +485,35 @@  discard block
 block discarded – undo
485 485
 		// set js_calendar_integration object, to use it in app.js cal_open() function
486 486
 		$params['js_integration_data'] = json_encode($js_integration_data);
487 487
 
488
-		$wv=0;
489
-		$dv=0;
488
+		$wv = 0;
489
+		$dv = 0;
490 490
 
491 491
 		// Add in some select options
492
-		$users = is_array($search_params['users']) ? $search_params['users'] : explode(',',$search_params['users']);
492
+		$users = is_array($search_params['users']) ? $search_params['users'] : explode(',', $search_params['users']);
493 493
 
494 494
 		$this->bo->warnings['groupmembers'] = '';
495
-		if(($message = $this->check_owners_access($users)))
495
+		if (($message = $this->check_owners_access($users)))
496 496
 		{
497 497
 			Api\Json\Response::get()->error($message);
498 498
 		}
499
-		else if($this->bo->warnings['groupmembers'])
499
+		else if ($this->bo->warnings['groupmembers'])
500 500
 		{
501 501
 			Api\Json\Response::get()->error($this->bo->warnings['groupmembers']);
502 502
 		}
503 503
 		$rows['sel_options']['filter'] = $this->date_filters;
504
-		if($label)
504
+		if ($label)
505 505
 		{
506 506
 			$rows['sel_options']['filter'][$params['filter']] = $label;
507 507
 		}
508
-		foreach($users as $owner)
508
+		foreach ($users as $owner)
509 509
 		{
510
-			if(!is_int($owner) && $this->bo->resources[$owner[0]])
510
+			if (!is_int($owner) && $this->bo->resources[$owner[0]])
511 511
 			{
512 512
 				$app = $this->bo->resources[$owner[0]]['app'];
513
-				$_owner = substr($owner,1);
513
+				$_owner = substr($owner, 1);
514 514
 				// Try link first
515
-				$title = Link::title($app, $_owner );
516
-				if($title)
515
+				$title = Link::title($app, $_owner);
516
+				if ($title)
517 517
 				{
518 518
 					$rows['sel_options']['owner'][$owner] = $title;
519 519
 				}
@@ -521,15 +521,15 @@  discard block
 block discarded – undo
521 521
 		}
522 522
 		$params['options-selectcols']['week'] = lang('Week');
523 523
 		$params['options-selectcols']['weekday'] = lang('Weekday');
524
-		if ((substr($this->cal_prefs['nextmatch-calendar.list.rows'],0,4) == 'week' && strlen($this->cal_prefs['nextmatch-calendar.list.rows'])==4) || substr($this->cal_prefs['nextmatch-calendar.list.rows'],0,5) == 'week,')
524
+		if ((substr($this->cal_prefs['nextmatch-calendar.list.rows'], 0, 4) == 'week' && strlen($this->cal_prefs['nextmatch-calendar.list.rows']) == 4) || substr($this->cal_prefs['nextmatch-calendar.list.rows'], 0, 5) == 'week,')
525 525
 		{
526
-			$rows['format'] = '32';	// prefix date with week-number
527
-			$wv=1;
526
+			$rows['format'] = '32'; // prefix date with week-number
527
+			$wv = 1;
528 528
 		}
529
-		if (!(strpos($this->cal_prefs['nextmatch-calendar.list.rows'],'weekday')===FALSE))
529
+		if (!(strpos($this->cal_prefs['nextmatch-calendar.list.rows'], 'weekday') === FALSE))
530 530
 		{
531 531
 			$rows['format'] = '16';
532
-			$dv=1;
532
+			$dv = 1;
533 533
 		}
534 534
 		if ($wv && $dv)
535 535
 		{
@@ -556,36 +556,36 @@  discard block
 block discarded – undo
556 556
 	 * @param string/array $session_name 'calendar_list'
557 557
 	 * @return boolean true if all actions succeded, false otherwise
558 558
 	 */
559
-	function action($action,$checked,$use_all,&$success,&$failed,&$action_msg,$session_name,&$msg,$skip_notification=false)
559
+	function action($action, $checked, $use_all, &$success, &$failed, &$action_msg, $session_name, &$msg, $skip_notification = false)
560 560
 	{
561 561
 		//error_log(__METHOD__."('$action', ".array2string($checked).', all='.(int)$use_all.", ...)");
562 562
 		$success = $failed = 0;
563 563
 		$msg = null;
564 564
 
565 565
 		// Split out combined values
566
-		if(strpos($action, 'status') !== false)
566
+		if (strpos($action, 'status') !== false)
567 567
 		{
568 568
 			list($action, $status) = explode('-', $action);
569 569
 		}
570 570
 		elseif (strpos($action, '_') !== false)
571 571
 		{
572
-			list($action, $settings) = explode('_', $action,2);
572
+			list($action, $settings) = explode('_', $action, 2);
573 573
 		}
574 574
 
575 575
 		if ($use_all)
576 576
 		{
577 577
 			// get the whole selection
578 578
 			$query = is_array($session_name) ? $session_name : Api\Cache::getSession('calendar', $session_name);
579
-			@set_time_limit(0);				// switch off the execution time limit, as for big selections it's too small
580
-			$query['num_rows'] = -1;		// all
579
+			@set_time_limit(0); // switch off the execution time limit, as for big selections it's too small
580
+			$query['num_rows'] = -1; // all
581 581
 			$readonlys = null;
582
-			$this->get_rows($query,$checked,$readonlys,!in_array($action,array('ical','document')));	   // true = only return the id's
582
+			$this->get_rows($query, $checked, $readonlys, !in_array($action, array('ical', 'document'))); // true = only return the id's
583 583
 			// Get rid of any extras (rows that aren't events)
584
-			if(in_array($action,array('ical','document')))
584
+			if (in_array($action, array('ical', 'document')))
585 585
 			{
586
-				foreach($checked as $key => $event)
586
+				foreach ($checked as $key => $event)
587 587
 				{
588
-					if(!is_numeric($key))
588
+					if (!is_numeric($key))
589 589
 					{
590 590
 						unset($checked[$key]);
591 591
 					}
@@ -593,28 +593,28 @@  discard block
 block discarded – undo
593 593
 			}
594 594
 		}
595 595
 		// for calendar integration we have to fetch all rows and unset the not selected ones, as we can not filter by id
596
-		elseif($action == 'document')
596
+		elseif ($action == 'document')
597 597
 		{
598 598
 			$query = is_array($session_name) ? $session_name : Api\Cache::getSession('calendar', $session_name);
599
-			@set_time_limit(0);				// switch off the execution time limit, as for big selections it's too small
599
+			@set_time_limit(0); // switch off the execution time limit, as for big selections it's too small
600 600
 			$events = null;
601
-			$this->get_rows($query,$events,$readonlys);
602
-			foreach($events as $key => $event)
601
+			$this->get_rows($query, $events, $readonlys);
602
+			foreach ($events as $key => $event)
603 603
 			{
604
-				$recur_date = Api\DateTime::to($event['recur_date'],'ts');
605
-				if (!in_array($event['id'],$checked) && !in_array($event['id'].':'.$recur_date, $checked)) unset($events[$key]);
604
+				$recur_date = Api\DateTime::to($event['recur_date'], 'ts');
605
+				if (!in_array($event['id'], $checked) && !in_array($event['id'].':'.$recur_date, $checked)) unset($events[$key]);
606 606
 			}
607 607
 			$checked = array_values($events); // Clear keys
608 608
 		}
609 609
 
610 610
 		// Actions where one action is done to the group
611
-		switch($action)
611
+		switch ($action)
612 612
 		{
613 613
 			case 'ical':
614 614
 				// compile list of unique cal_id's, as iCal should contain whole series, not recurrences
615 615
 				// calendar_ical->exportVCal needs to read events again, to get them in server-time
616 616
 				$ids = array();
617
-				foreach($checked as $id)
617
+				foreach ($checked as $id)
618 618
 				{
619 619
 					if (is_array($id)) $id = $id['id'];
620 620
 					// get rid of recurrences, doublicate series and calendar-integration events
@@ -624,7 +624,7 @@  discard block
 block discarded – undo
624 624
 					}
625 625
 				}
626 626
 				$boical = new calendar_ical();
627
-				$ical =& $boical->exportVCal($ids, '2.0', 'PUBLISH');
627
+				$ical = & $boical->exportVCal($ids, '2.0', 'PUBLISH');
628 628
 				Api\Header\Content::type('event.ics', 'text/calendar', bytes($ical));
629 629
 				echo $ical;
630 630
 				exit();
@@ -639,19 +639,19 @@  discard block
 block discarded – undo
639 639
 		}
640 640
 
641 641
 		// Actions where the action is applied to each entry
642
-		if(strpos($action, 'timesheet') !== false)
642
+		if (strpos($action, 'timesheet') !== false)
643 643
 		{
644 644
 			$timesheet_bo = new timesheet_bo();
645 645
 		}
646
-		foreach($checked as &$id)
646
+		foreach ($checked as &$id)
647 647
 		{
648 648
 			$recur_date = $app = $app_id = null;
649
-			if(is_array($id) && $id['id'])
649
+			if (is_array($id) && $id['id'])
650 650
 			{
651 651
 				$id = $id['id'];
652 652
 			}
653 653
 			$matches = null;
654
-			if(!(int)$id && preg_match('/^([a-z_-]+)([0-9]+)$/i',$id,$matches))
654
+			if (!(int)$id && preg_match('/^([a-z_-]+)([0-9]+)$/i', $id, $matches))
655 655
 			{
656 656
 				$app = $matches[1];
657 657
 				$app_id = $matches[2];
@@ -659,36 +659,36 @@  discard block
 block discarded – undo
659 659
 			}
660 660
 			else
661 661
 			{
662
-				list($id,$recur_date) = explode(':',$id);
662
+				list($id, $recur_date) = explode(':', $id);
663 663
 			}
664
-			switch($action)
664
+			switch ($action)
665 665
 			{
666 666
 				case 'delete':
667 667
 					$action_msg = lang('deleted');
668
-					if($settings == 'series')
668
+					if ($settings == 'series')
669 669
 					{
670 670
 						// Delete the whole thing
671 671
 						$recur_date = 0;
672 672
 					}
673
-					if ($id && $this->bo->delete($id, $recur_date,false,$skip_notification))
673
+					if ($id && $this->bo->delete($id, $recur_date, false, $skip_notification))
674 674
 					{
675 675
 						$success++;
676
-						if(!$recur_date && $settings == 'series')
676
+						if (!$recur_date && $settings == 'series')
677 677
 						{
678 678
 							// If there are multiple events in a series selected, the next one could purge
679
-							foreach($checked as $key => $c_id)
679
+							foreach ($checked as $key => $c_id)
680 680
 							{
681
-								list($c_id,$recur_date) = explode(':',$c_id);
682
-								if($c_id == $id)
681
+								list($c_id, $recur_date) = explode(':', $c_id);
682
+								if ($c_id == $id)
683 683
 								{
684 684
 									unset($checked[$key]);
685 685
 								}
686 686
 							}
687 687
 						}
688 688
 
689
-						if(Api\Json\Response::isJSONResponse())
689
+						if (Api\Json\Response::isJSONResponse())
690 690
 						{
691
-							Api\Json\Response::get()->call('egw.refresh','','calendar',$id,'delete');
691
+							Api\Json\Response::get()->call('egw.refresh', '', 'calendar', $id, 'delete');
692 692
 						}
693 693
 					}
694 694
 					else
@@ -698,23 +698,23 @@  discard block
 block discarded – undo
698 698
 					break;
699 699
 				case 'undelete':
700 700
 					$action_msg = lang('recovered');
701
-					if($settings == 'series')
701
+					if ($settings == 'series')
702 702
 					{
703 703
 						// unDelete the whole thing
704 704
 						$recur_date = 0;
705 705
 					}
706
-					if ($id && ($event = $this->bo->read($id, $recur_date)) && $this->bo->check_perms(Acl::EDIT,$id) &&
706
+					if ($id && ($event = $this->bo->read($id, $recur_date)) && $this->bo->check_perms(Acl::EDIT, $id) &&
707 707
 						is_array($event) && $event['deleted'])
708 708
 					{
709 709
 						$event['deleted'] = null;
710
-						if($this->bo->save($event))
710
+						if ($this->bo->save($event))
711 711
 						{
712 712
 							$success++;
713 713
 
714
-							if(Api\Json\Response::isJSONResponse())
714
+							if (Api\Json\Response::isJSONResponse())
715 715
 							{
716
-								Api\Json\Response::get()->call('egw.dataStoreUID','calendar::'.$id,$this->to_client($this->bo->read($id,$recur_date)));
717
-								Api\Json\Response::get()->call('egw.refresh','','calendar',$id,'edit');
716
+								Api\Json\Response::get()->call('egw.dataStoreUID', 'calendar::'.$id, $this->to_client($this->bo->read($id, $recur_date)));
717
+								Api\Json\Response::get()->call('egw.refresh', '', 'calendar', $id, 'edit');
718 718
 							}
719 719
 							break;
720 720
 						}
@@ -723,7 +723,7 @@  discard block
 block discarded – undo
723 723
 					break;
724 724
 				case 'status':
725 725
 					$action_msg = lang('Status changed');
726
-					if($id && ($event = $this->bo->read($id, $recur_date)))
726
+					if ($id && ($event = $this->bo->read($id, $recur_date)))
727 727
 					{
728 728
 						$old_status = $event['participants'][$GLOBALS['egw_info']['user']['account_id']];
729 729
 						$quantity = $role = null;
@@ -732,12 +732,12 @@  discard block
 block discarded – undo
732 732
 						{
733 733
 							//echo "<p>$uid: status changed '$data[old_status]' --> '$status<'/p>\n";
734 734
 							$new_status = calendar_so::combine_status($status, $quantity, $role);
735
-							if ($this->bo->set_status($event,$GLOBALS['egw_info']['user']['account_id'],$new_status,$recur_date,
736
-								false,true,$skip_notification))
735
+							if ($this->bo->set_status($event, $GLOBALS['egw_info']['user']['account_id'], $new_status, $recur_date,
736
+								false, true, $skip_notification))
737 737
 							{
738
-								if(Api\Json\Response::isJSONResponse())
738
+								if (Api\Json\Response::isJSONResponse())
739 739
 								{
740
-									Api\Json\Response::get()->call('egw.dataStoreUID','calendar::'.$id,$this->to_client($this->bo->read($id,$recur_date)));
740
+									Api\Json\Response::get()->call('egw.dataStoreUID', 'calendar::'.$id, $this->to_client($this->bo->read($id, $recur_date)));
741 741
 								}
742 742
 								$success++;
743 743
 								//$msg = lang('Status changed');
@@ -754,7 +754,7 @@  discard block
 block discarded – undo
754 754
 					}
755 755
 					break;
756 756
 				case 'timesheet-add':
757
-					if($id && !$app)
757
+					if ($id && !$app)
758 758
 					{
759 759
 						$event = $this->bo->read($id, $recur_date);
760 760
 					}
@@ -766,10 +766,10 @@  discard block
 block discarded – undo
766 766
 						$result = $this->bo->search($query);
767 767
 						$event = $result[$app.$app_id];
768 768
 					}
769
-					if(!$event)
769
+					if (!$event)
770 770
 					{
771 771
 						$failed++;
772
-						continue 2;	// +1 for switch
772
+						continue 2; // +1 for switch
773 773
 					}
774 774
 					$timesheet = array(
775 775
 						'ts_title'		=>	$event['title'],
@@ -783,16 +783,16 @@  discard block
 block discarded – undo
783 783
 					);
784 784
 
785 785
 					// Add global categories
786
-					$categories = explode(',',$event['category']);
786
+					$categories = explode(',', $event['category']);
787 787
 					$global_categories = array();
788
-					foreach($categories as $cat_id)
788
+					foreach ($categories as $cat_id)
789 789
 					{
790
-						if($GLOBALS['egw']->categories->is_global($cat_id))
790
+						if ($GLOBALS['egw']->categories->is_global($cat_id))
791 791
 						{
792 792
 							$global_categories[] = $cat_id;
793 793
 						}
794 794
 					}
795
-					if(count($global_categories))
795
+					if (count($global_categories))
796 796
 					{
797 797
 						$timesheet['cat_id'] = implode(',', $global_categories);
798 798
 					}
@@ -812,12 +812,12 @@  discard block
 block discarded – undo
812 812
 						}
813 813
 					}
814 814
 
815
-					if(!$err)
815
+					if (!$err)
816 816
 					{
817 817
 						$success++;
818 818
 
819 819
 						// Can't link to just one of a recurring series of events
820
-						if(!$recur_date || $app) {
820
+						if (!$recur_date || $app) {
821 821
 							// Create link
822 822
 							$link_id = $app ? $app_id : $id;
823 823
 							Link::link($app ? $app : 'calendar', $link_id, 'timesheet', $timesheet_bo->data['ts_id']);
@@ -845,7 +845,7 @@  discard block
 block discarded – undo
845 845
 	protected function get_merge_range($nm)
846 846
 	{
847 847
 		$checked = array();
848
-		if($nm['filter'] == 'fixed')
848
+		if ($nm['filter'] == 'fixed')
849 849
 		{
850 850
 			$checked['start'] = $nm['startdate'];
851 851
 			$last = $this->bo->date2array($nm['enddate']);
@@ -854,7 +854,7 @@  discard block
 block discarded – undo
854 854
 		}
855 855
 		else
856 856
 		{
857
-			switch($nm['filter'])
857
+			switch ($nm['filter'])
858 858
 			{
859 859
 				case 'after':
860 860
 					$checked['start'] = $nm['startdate'] ? $nm['startdate'] : strtotime('today');
@@ -867,8 +867,8 @@  discard block
 block discarded – undo
867 867
 					$checked['end'] = $nm['enddate'];
868 868
 					break;
869 869
 				default:
870
-					$date = date_create_from_format('Ymd',$this->date);
871
-					$checked['start']= $date->format('U');
870
+					$date = date_create_from_format('Ymd', $this->date);
871
+					$checked['start'] = $date->format('U');
872 872
 			}
873 873
 		}
874 874
 		return $checked;
@@ -893,7 +893,7 @@  discard block
 block discarded – undo
893 893
 				'allowOnMultiple' => false,
894 894
 				'url' => 'menuaction=calendar.calendar_uiforms.edit&cal_id=$id',
895 895
 				'popup' => Link::get_registry('calendar', 'view_popup'),
896
-				'group' => $group=1,
896
+				'group' => $group = 1,
897 897
 				'onExecute' => 'javaScript:app.calendar.cal_open',
898 898
 				'disableClass' => 'rowNoView',
899 899
 			),
@@ -925,7 +925,7 @@  discard block
 block discarded – undo
925 925
 				'group' => $group,
926 926
 			),
927 927
 		);
928
-		$status = array_map('lang',$this->bo->verbose_status);
928
+		$status = array_map('lang', $this->bo->verbose_status);
929 929
 		unset($status['G']);
930 930
 		$actions['status'] = array(
931 931
 			'caption' => 'Change your status',
@@ -934,7 +934,7 @@  discard block
 block discarded – undo
934 934
 			'children' => $status,
935 935
 			'group' => ++$group,
936 936
 		);
937
-		++$group;	// integration with other apps: infolog, calendar, filemanager
937
+		++$group; // integration with other apps: infolog, calendar, filemanager
938 938
 		if ($GLOBALS['egw_info']['user']['apps']['filemanager'])
939 939
 		{
940 940
 			$actions['filemanager'] = array(
@@ -958,7 +958,7 @@  discard block
 block discarded – undo
958 958
 				'popup' => Link::get_registry('infolog', 'add_popup'),
959 959
 			);
960 960
 		}
961
-		if($GLOBALS['egw_info']['user']['apps']['mail'])
961
+		if ($GLOBALS['egw_info']['user']['apps']['mail'])
962 962
 		{
963 963
 			//Send to email
964 964
 			$actions['email'] = array(
@@ -988,7 +988,7 @@  discard block
 block discarded – undo
988 988
 				'caption' => 'Timesheet',
989 989
 				'group' => $group,
990 990
 				'allowOnMultiple' => false,
991
-				'hideOnDisabled' => true,	// show only one timesheet action in context menu
991
+				'hideOnDisabled' => true, // show only one timesheet action in context menu
992 992
 				'onExecute' => 'javaScript:app.calendar.action_open',
993 993
 				'open' => '{"app": "timesheet", "type": "add", "extra": "link_app[]=$app&link_id[]=$app_id"}',
994 994
 				'popup' => Link::get_registry('timesheet', 'add_popup'),
@@ -998,7 +998,7 @@  discard block
 block discarded – undo
998 998
 				'caption' => 'Timesheet',
999 999
 				'group' => $group,
1000 1000
 				'allowOnMultiple' => 'only',
1001
-				'hideOnDisabled' => true,	// show only one timesheet action in context menu
1001
+				'hideOnDisabled' => true, // show only one timesheet action in context menu
1002 1002
 			);
1003 1003
 		}
1004 1004
 		$actions['ical'] = array(
@@ -1007,11 +1007,11 @@  discard block
 block discarded – undo
1007 1007
 			'group' => ++$group,
1008 1008
 			'hint' => 'Download this event as iCal',
1009 1009
 			'disableClass' => 'rowNoView',
1010
-			'postSubmit' => true,	// download needs post submit (not Ajax) to work
1010
+			'postSubmit' => true, // download needs post submit (not Ajax) to work
1011 1011
 		);
1012 1012
 		$actions['documents'] = calendar_merge::document_action(
1013 1013
 			$this->bo->cal_prefs['document_dir'], ++$group, 'Insert in document', 'document_',
1014
-			$this->bo->cal_prefs['default_document'],Api\Storage\Merge::getExportLimit('calendar')
1014
+			$this->bo->cal_prefs['default_document'], Api\Storage\Merge::getExportLimit('calendar')
1015 1015
 		);
1016 1016
 		++$group;
1017 1017
 		$actions['delete'] = array(
@@ -1021,7 +1021,7 @@  discard block
 block discarded – undo
1021 1021
 			'disableClass' => 'rowNoDelete',
1022 1022
 		);
1023 1023
 		// Add in deleted for admins
1024
-		if($GLOBALS['egw_info']['server']['calendar_delete_history'])
1024
+		if ($GLOBALS['egw_info']['server']['calendar_delete_history'])
1025 1025
 		{
1026 1026
 			$actions['undelete'] = array(
1027 1027
 				'caption' => 'Un-delete',
Please login to merge, or discard this patch.