Test Setup Failed
Push — master ( 1738c0...e99c33 )
by Nathan
18:51
created
calendar/inc/class.calendar_uilist.inc.php 1 patch
Spacing   +156 added lines, -156 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')
@@ -151,12 +151,12 @@  discard block
 block discarded – undo
151 151
 		$content['nm']['actions'] = $this->get_actions();
152 152
 
153 153
 		// Skip first load if view is not listview
154
-		if($this->view && $this->view !== 'listview')
154
+		if ($this->view && $this->view !== 'listview')
155 155
 		{
156 156
 			$content['nm']['num_rows'] = 0;
157 157
 		}
158 158
 
159
-		if (isset($_GET['filter']) && in_array($_GET['filter'],array_keys($this->date_filters)))
159
+		if (isset($_GET['filter']) && in_array($_GET['filter'], array_keys($this->date_filters)))
160 160
 		{
161 161
 			$content['nm']['filter'] = $_GET['filter'];
162 162
 		}
@@ -164,16 +164,16 @@  discard block
 block discarded – undo
164 164
 		{
165 165
 			$content['nm']['search'] = $_GET['search'];
166 166
 		}
167
-		if($this->owner)
167
+		if ($this->owner)
168 168
 		{
169
-			$content['nm']['col_filter']['participant'] = is_array($this->owner) ? $this->owner : explode(',',$this->owner);
169
+			$content['nm']['col_filter']['participant'] = is_array($this->owner) ? $this->owner : explode(',', $this->owner);
170 170
 		}
171 171
 		// search via jdots ajax_exec uses $_REQUEST['json_data'] instead of regular GET parameters
172 172
 		if (isset($_REQUEST['json_data']) && ($json_data = json_decode($_REQUEST['json_data'], true)) &&
173 173
 			!empty($json_data['request']['parameters'][0]))
174 174
 		{
175 175
 			$params = null;
176
-			parse_str(substr($json_data['request']['parameters'][0], 10), $params);	// cut off "/index.php?"
176
+			parse_str(substr($json_data['request']['parameters'][0], 10), $params); // cut off "/index.php?"
177 177
 			if (isset($params['keywords']))	// new search => set filters so every match is shown
178 178
 			{
179 179
 				$this->adjust_for_search($params['keywords'], $content['nm']);
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 		}
183 183
 		if (isset($_REQUEST['keywords']))	// new search => set filters so every match is shown
184 184
 		{
185
-			$this->adjust_for_search($_REQUEST['keywords'],$content['nm']);
185
+			$this->adjust_for_search($_REQUEST['keywords'], $content['nm']);
186 186
 			unset($_REQUEST['keywords']);
187 187
 		}
188 188
 		$sel_options['filter'] = &$this->date_filters;
@@ -190,15 +190,15 @@  discard block
 block discarded – undo
190 190
 		// Send categories for row styling - calendar uses no_cat, so they don't go automatically
191 191
 		$sel_options['category'] = array('' => lang('all')) + Etemplate\Widget\Select::typeOptions('select-cat', ',,calendar');
192 192
 		// Prevent double encoding - widget does this on its own, but we're just grabbing the options
193
-		foreach($sel_options['category'] as &$label)
193
+		foreach ($sel_options['category'] as &$label)
194 194
 		{
195
-			if(!is_array($label))
195
+			if (!is_array($label))
196 196
 			{
197
-				$label = html_entity_decode($label, ENT_NOQUOTES,'utf-8');
197
+				$label = html_entity_decode($label, ENT_NOQUOTES, 'utf-8');
198 198
 			}
199
-			elseif($label['label'])
199
+			elseif ($label['label'])
200 200
 			{
201
-				$label['label'] = html_entity_decode($label['label'], ENT_NOQUOTES,'utf-8');
201
+				$label['label'] = html_entity_decode($label['label'], ENT_NOQUOTES, 'utf-8');
202 202
 			}
203 203
 		}
204 204
 
@@ -206,15 +206,15 @@  discard block
 block discarded – undo
206 206
 		if ($this->prefs['limit_des_lines'] > 0 || (string)$this->prefs['limit_des_lines'] == '')
207 207
 		{
208 208
 			$content['css'] .= '<style type="text/css">@media screen { .listDescription {  max-height: '.
209
-				(($this->prefs['limit_des_lines'] ? $this->prefs['limit_des_lines'] : 5) * 1.35).	   // dono why em is not real lines
209
+				(($this->prefs['limit_des_lines'] ? $this->prefs['limit_des_lines'] : 5) * 1.35).// dono why em is not real lines
210 210
 				'em; overflow: auto; }}</style>';
211 211
 		}
212 212
 
213
-		if($msg)
213
+		if ($msg)
214 214
 		{
215 215
 			Framework::message($msg);
216 216
 		}
217
-		$html = $etpl->exec('calendar.calendar_uilist.listview',$content,$sel_options,array(),array(),$home ? -1 : 0);
217
+		$html = $etpl->exec('calendar.calendar_uilist.listview', $content, $sel_options, array(), array(), $home ? -1 : 0);
218 218
 
219 219
 		// Not sure why this has to be echoed instead of appended, but that's what works.
220 220
 		//echo calendar_uiviews::edit_series();
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 	/**
226 226
 	 * set filter for search, so that everything is shown
227 227
 	 */
228
-	function adjust_for_search($keywords,&$params)
228
+	function adjust_for_search($keywords, &$params)
229 229
 	{
230 230
 		$params['search'] = $keywords;
231 231
 		$params['start']  = 0;
@@ -249,9 +249,9 @@  discard block
 block discarded – undo
249 249
 	 * @param array &$rows returned rows/events
250 250
 	 * @param array &$readonlys eg. to disable buttons based on Acl
251 251
 	 */
252
-	function get_rows(&$params,&$rows,&$readonlys)
252
+	function get_rows(&$params, &$rows, &$readonlys)
253 253
 	{
254
-		unset($readonlys);	// not used;
254
+		unset($readonlys); // not used;
255 255
 		//echo "uilist::get_rows() params="; _debug_array($params);
256 256
 		$this->filter = $params['filter'];
257 257
 		if ($params['filter'] == 'custom')
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
 			}
282 282
 			if ($old_params['search'] != $params['search'])
283 283
 			{
284
-				$this->adjust_for_search($params['search'],$params);
284
+				$this->adjust_for_search($params['search'], $params);
285 285
 				$this->filter = $params['filter'];
286 286
 			}
287 287
 		}
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 		if (!$params['csv_export'])
290 290
 		{
291 291
 			Api\Cache::setSession('calendar', 'calendar_list',
292
-				array_diff_key ($params, array_flip(array('rows', 'actions', 'action_links', 'placeholder_actions'))));
292
+				array_diff_key($params, array_flip(array('rows', 'actions', 'action_links', 'placeholder_actions'))));
293 293
 		}
294 294
 
295 295
 		// release session to allow parallel requests to run
@@ -298,23 +298,23 @@  discard block
 block discarded – undo
298 298
 		// do we need to query custom fields and which
299 299
 		// Check stored preference if selectcols isn't available (ie: first call)
300 300
 		$select_cols = $params['selectcols'] ? $params['selectcols'] : $GLOBALS['egw_info']['user']['preferences']['calendar']['nextmatch-calendar.list.rows'];
301
-		if(!is_array($params['selectcols']))
301
+		if (!is_array($params['selectcols']))
302 302
 		{
303
-			$select_cols = explode(',',$select_cols);
303
+			$select_cols = explode(',', $select_cols);
304 304
 		}
305
-		if (in_array('cfs',$select_cols))
305
+		if (in_array('cfs', $select_cols))
306 306
 		{
307 307
 			$cfs = array();
308
-			foreach($select_cols as $col)
308
+			foreach ($select_cols as $col)
309 309
 			{
310
-				if ($col[0] == '#') $cfs[] = substr($col,1);
310
+				if ($col[0] == '#') $cfs[] = substr($col, 1);
311 311
 			}
312 312
 		}
313 313
 		$search_params = array(
314 314
 			'cat_id'  => $params['cat_id'] ? $params['cat_id'] : 0,
315 315
 			'filter'  => $this->filter,
316 316
 			'query'   => $params['search'],
317
-			'offset'  => (int) $params['start'],
317
+			'offset'  => (int)$params['start'],
318 318
 			'num_rows'=> $params['num_rows'],
319 319
 			'order'   => $params['order'] ? $params['order'].' '.$params['sort'] : 'cal_start ASC',
320 320
 			'cfs'	 => $params['csv_export'] ? array() : $cfs,
@@ -322,24 +322,24 @@  discard block
 block discarded – undo
322 322
 		// Non-blocking events above blocking
323 323
 		$search_params['order'] .= ', cal_non_blocking DESC';
324 324
 
325
-		switch($this->filter)
325
+		switch ($this->filter)
326 326
 		{
327 327
 			case 'all':
328 328
 				break;
329 329
 			case 'before':
330
-				$search_params['end'] = $params['date'] ? Api\DateTime::to($params['date'],'ts') : $this->date;
331
-				$label = lang('Before %1',$this->bo->long_date($search_params['end']));
330
+				$search_params['end'] = $params['date'] ? Api\DateTime::to($params['date'], 'ts') : $this->date;
331
+				$label = lang('Before %1', $this->bo->long_date($search_params['end']));
332 332
 				break;
333 333
 			case 'custom':
334
-				$this->first = $search_params['start'] = Api\DateTime::to($params['startdate'],'ts');
335
-				$this->last  = $search_params['end'] = strtotime('+1 day', $this->bo->date2ts($params['enddate']))-1;
336
-				$label = $this->bo->long_date($this->first,$this->last);
334
+				$this->first = $search_params['start'] = Api\DateTime::to($params['startdate'], 'ts');
335
+				$this->last  = $search_params['end'] = strtotime('+1 day', $this->bo->date2ts($params['enddate'])) - 1;
336
+				$label = $this->bo->long_date($this->first, $this->last);
337 337
 				break;
338 338
 			case 'today':
339 339
 				$today = new Api\DateTime();
340 340
 				$today->setTime(0, 0, 0);
341 341
 				$this->first = $search_params['start'] = $today->format('ts');
342
-				$today->setTime(23,59,59);
342
+				$today->setTime(23, 59, 59);
343 343
 				$this->last  = $search_params['end'] = $today->format('ts');
344 344
 				break;
345 345
 			case 'week':
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
 				$this->last['hour'] = 23; $this->last['minute'] = $this->last['sec'] = 59;
352 352
 				unset($this->last['raw']);
353 353
 				$this->last = $this->bo->date2ts($this->last);
354
-				$this->date_filters['week'] = $label = lang('Week').' '.adodb_date('W',$this->first).': '.$this->bo->long_date($this->first,$this->last);
354
+				$this->date_filters['week'] = $label = lang('Week').' '.adodb_date('W', $this->first).': '.$this->bo->long_date($this->first, $this->last);
355 355
 				$search_params['start'] = $this->first;
356 356
 				$search_params['end'] = $this->last;
357 357
 				$params['startdate'] = Api\DateTime::to($this->first, Api\DateTime::ET2);
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
 				unset($this->first['raw']);
366 366
 				$this->last = $this->first;
367 367
 				$this->last['month'] += 1;
368
-				$this->date_filters['month'] = $label = lang(adodb_date('F',$this->bo->date2ts($params['date']))).' '.$this->first['year'];
368
+				$this->date_filters['month'] = $label = lang(adodb_date('F', $this->bo->date2ts($params['date']))).' '.$this->first['year'];
369 369
 				$this->first = $this->bo->date2ts($this->first);
370 370
 				$this->last = $this->bo->date2ts($this->last);
371 371
 				$this->last--;
@@ -376,22 +376,22 @@  discard block
 block discarded – undo
376 376
 				break;
377 377
 
378 378
 			case 'after':
379
-				$this->date = $params['startdate'] ? Api\DateTime::to($params['startdate'],'ts') : $this->date;
380
-				$label = lang('After %1',$this->bo->long_date($this->date));
379
+				$this->date = $params['startdate'] ? Api\DateTime::to($params['startdate'], 'ts') : $this->date;
380
+				$label = lang('After %1', $this->bo->long_date($this->date));
381 381
 				$search_params['start'] = $this->date;
382 382
 				break;
383 383
 		}
384
-		if($params['status_filter'])
384
+		if ($params['status_filter'])
385 385
 		{
386 386
 			$search_params['filter'] = $params['status_filter'];
387 387
 		}
388 388
 		if ($params['col_filter']['participant'])
389 389
 		{
390
-			$search_params['users'] = is_array($params['col_filter']['participant']) ? $params['col_filter']['participant'] : array( $params['col_filter']['participant']);
390
+			$search_params['users'] = is_array($params['col_filter']['participant']) ? $params['col_filter']['participant'] : array($params['col_filter']['participant']);
391 391
 		}
392 392
 		elseif (!$params['col_filter'] || !$params['col_filter']['participant'])
393 393
 		{
394
-			$search_params['users'] = $params['owner'] ? $params['owner'] : explode(',',$this->owner);
394
+			$search_params['users'] = $params['owner'] ? $params['owner'] : explode(',', $this->owner);
395 395
 		}
396 396
 		// Allow private to stay for all viewed owners, even if in separate calendars
397 397
 		$search_params['private_allowed'] = (array)$params['selected_owners'] + (array)$search_params['users'];
@@ -399,9 +399,9 @@  discard block
 block discarded – undo
399 399
 		if ($params['col_filter'])
400 400
 		{
401 401
 			$col_filter = array();
402
-			foreach($params['col_filter'] as $name => $val)
402
+			foreach ($params['col_filter'] as $name => $val)
403 403
 			{
404
-				if (!in_array($name, array('participant','row_id')) && (string)$val !== '')
404
+				if (!in_array($name, array('participant', 'row_id')) && (string)$val !== '')
405 405
 				{
406 406
 					$col_filter[$name] = $val;
407 407
 				}
@@ -411,18 +411,18 @@  discard block
 block discarded – undo
411 411
 
412 412
 		// App header is mostly taken care of on the client side, but here we update
413 413
 		// it to match changing list filters
414
-		if($params['view'] && $params['view'] == 'listview' && Api\Json\Response::isJSONResponse())
414
+		if ($params['view'] && $params['view'] == 'listview' && Api\Json\Response::isJSONResponse())
415 415
 		{
416 416
 			Api\Json\Response::get()->call('app.calendar.set_app_header',
417
-				(count($search_params['users']) == 1 ? $this->bo->participant_name($search_params['users'][0]).': ' : '') .
417
+				(count($search_params['users']) == 1 ? $this->bo->participant_name($search_params['users'][0]).': ' : '').
418 418
 				$label);
419 419
 		}
420
-		foreach((array) $this->bo->search($search_params, !empty($col_filter) ? $col_filter : null) as $event)
420
+		foreach ((array)$this->bo->search($search_params, !empty($col_filter) ? $col_filter : null) as $event)
421 421
 		{
422 422
 
423 423
 			if ($params['csv_export'])
424 424
 			{
425
-				$event['participants'] = implode(",\n",$this->bo->participants($event,true));
425
+				$event['participants'] = implode(",\n", $this->bo->participants($event, true));
426 426
 			}
427 427
 			else
428 428
 			{
@@ -430,23 +430,23 @@  discard block
 block discarded – undo
430 430
 			}
431 431
 
432 432
 			$matches = null;
433
-			if(!(int)$event['id'] && preg_match('/^([a-z_-]+)([0-9]+)$/i',$event['id'],$matches))
433
+			if (!(int)$event['id'] && preg_match('/^([a-z_-]+)([0-9]+)$/i', $event['id'], $matches))
434 434
 			{
435 435
 				$app = $matches[1];
436 436
 				$app_id = $matches[2];
437 437
 				$icons = array();
438
-				if (($is_private = calendar_bo::integration_get_private($app,$app_id,$event)))
438
+				if (($is_private = calendar_bo::integration_get_private($app, $app_id, $event)))
439 439
 				{
440
-					$icons[] = Api\Html::image('calendar','private');
440
+					$icons[] = Api\Html::image('calendar', 'private');
441 441
 				}
442 442
 				else
443 443
 				{
444
-					$icons = calendar_uiviews::integration_get_icons($app,$app_id,$event);
444
+					$icons = calendar_uiviews::integration_get_icons($app, $app_id, $event);
445 445
 				}
446 446
 			}
447 447
 			else
448 448
 			{
449
-				$is_private = !$this->bo->check_perms(Acl::READ,$event);
449
+				$is_private = !$this->bo->check_perms(Acl::READ, $event);
450 450
 			}
451 451
 			if ($is_private)
452 452
 			{
@@ -457,9 +457,9 @@  discard block
 block discarded – undo
457 457
 			$event['app_id'] = $event['id'];
458 458
 
459 459
 			// Edit link
460
-			if($app && $app_id)
460
+			if ($app && $app_id)
461 461
 			{
462
-				$popup = calendar_uiviews::integration_get_popup($app,$app_id);
462
+				$popup = calendar_uiviews::integration_get_popup($app, $app_id);
463 463
 
464 464
 				// Need to strip off 'onclick'
465 465
 				$event['edit_link'] = preg_replace('/ ?onclick="(.+)"/i', '$1', $popup);
@@ -470,18 +470,18 @@  discard block
 block discarded – undo
470 470
 				// populate js_integration_data, if not already set
471 471
 				if (!isset($js_integration_data[$app]))
472 472
 				{
473
-					$js_integration_data[$app] = calendar_bo::integration_get_data($app,'edit_link');
473
+					$js_integration_data[$app] = calendar_bo::integration_get_data($app, 'edit_link');
474 474
 				}
475 475
 			}
476 476
 			elseif ($event['recur_type'] != MCAL_RECUR_NONE)
477 477
 			{
478
-				$event['app_id'] .= ':'.Api\DateTime::to($event['recur_date'] ? $event['recur_date'] : $event['start'],'ts');
478
+				$event['app_id'] .= ':'.Api\DateTime::to($event['recur_date'] ? $event['recur_date'] : $event['start'], 'ts');
479 479
 			}
480 480
 
481 481
 			// Format start and end with timezone
482
-			foreach(array('start','end') as $time)
482
+			foreach (array('start', 'end') as $time)
483 483
 			{
484
-				$event[$time] = Api\DateTime::to($event[$time],'Y-m-d\TH:i:s\Z');
484
+				$event[$time] = Api\DateTime::to($event[$time], 'Y-m-d\TH:i:s\Z');
485 485
 			}
486 486
 
487 487
 			$rows[] = $event;
@@ -491,35 +491,35 @@  discard block
 block discarded – undo
491 491
 		// set js_calendar_integration object, to use it in app.js cal_open() function
492 492
 		$params['js_integration_data'] = json_encode($js_integration_data);
493 493
 
494
-		$wv=0;
495
-		$dv=0;
494
+		$wv = 0;
495
+		$dv = 0;
496 496
 
497 497
 		// Add in some select options
498
-		$users = is_array($search_params['users']) ? $search_params['users'] : explode(',',$search_params['users']);
498
+		$users = is_array($search_params['users']) ? $search_params['users'] : explode(',', $search_params['users']);
499 499
 
500 500
 		$this->bo->warnings['groupmembers'] = '';
501
-		if(($message = $this->check_owners_access($users)))
501
+		if (($message = $this->check_owners_access($users)))
502 502
 		{
503 503
 			Api\Json\Response::get()->error($message);
504 504
 		}
505
-		else if($this->bo->warnings['groupmembers'])
505
+		else if ($this->bo->warnings['groupmembers'])
506 506
 		{
507 507
 			Api\Json\Response::get()->error($this->bo->warnings['groupmembers']);
508 508
 		}
509 509
 		$rows['sel_options']['filter'] = $this->date_filters;
510
-		if($label)
510
+		if ($label)
511 511
 		{
512 512
 			$rows['sel_options']['filter'][$params['filter']] = $label;
513 513
 		}
514
-		foreach($users as $owner)
514
+		foreach ($users as $owner)
515 515
 		{
516
-			if(!is_int($owner) && $this->bo->resources[$owner[0]])
516
+			if (!is_int($owner) && $this->bo->resources[$owner[0]])
517 517
 			{
518 518
 				$app = $this->bo->resources[$owner[0]]['app'];
519
-				$_owner = substr($owner,1);
519
+				$_owner = substr($owner, 1);
520 520
 				// Try link first
521
-				$title = Link::title($app, $_owner );
522
-				if($title)
521
+				$title = Link::title($app, $_owner);
522
+				if ($title)
523 523
 				{
524 524
 					$rows['sel_options']['owner'][$owner] = $title;
525 525
 				}
@@ -527,15 +527,15 @@  discard block
 block discarded – undo
527 527
 		}
528 528
 		$params['options-selectcols']['week'] = lang('Week');
529 529
 		$params['options-selectcols']['weekday'] = lang('Weekday');
530
-		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,')
530
+		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,')
531 531
 		{
532
-			$rows['format'] = '32';	// prefix date with week-number
533
-			$wv=1;
532
+			$rows['format'] = '32'; // prefix date with week-number
533
+			$wv = 1;
534 534
 		}
535
-		if (!(strpos($this->cal_prefs['nextmatch-calendar.list.rows'],'weekday')===FALSE))
535
+		if (!(strpos($this->cal_prefs['nextmatch-calendar.list.rows'], 'weekday') === FALSE))
536 536
 		{
537 537
 			$rows['format'] = '16';
538
-			$dv=1;
538
+			$dv = 1;
539 539
 		}
540 540
 		if ($wv && $dv)
541 541
 		{
@@ -562,36 +562,36 @@  discard block
 block discarded – undo
562 562
 	 * @param string/array $session_name 'calendar_list'
563 563
 	 * @return boolean true if all actions succeded, false otherwise
564 564
 	 */
565
-	function action($action,$checked,$use_all,&$success,&$failed,&$action_msg,$session_name,&$msg,$skip_notification=false)
565
+	function action($action, $checked, $use_all, &$success, &$failed, &$action_msg, $session_name, &$msg, $skip_notification = false)
566 566
 	{
567 567
 		//error_log(__METHOD__."('$action', ".array2string($checked).', all='.(int)$use_all.", ...)");
568 568
 		$success = $failed = 0;
569 569
 		$msg = null;
570 570
 
571 571
 		// Split out combined values
572
-		if(strpos($action, 'status') !== false)
572
+		if (strpos($action, 'status') !== false)
573 573
 		{
574 574
 			list($action, $status) = explode('-', $action);
575 575
 		}
576 576
 		elseif (strpos($action, '_') !== false)
577 577
 		{
578
-			list($action, $settings) = explode('_', $action,2);
578
+			list($action, $settings) = explode('_', $action, 2);
579 579
 		}
580 580
 
581 581
 		if ($use_all)
582 582
 		{
583 583
 			// get the whole selection
584 584
 			$query = is_array($session_name) ? $session_name : Api\Cache::getSession('calendar', $session_name);
585
-			@set_time_limit(0);				// switch off the execution time limit, as for big selections it's too small
586
-			$query['num_rows'] = -1;		// all
585
+			@set_time_limit(0); // switch off the execution time limit, as for big selections it's too small
586
+			$query['num_rows'] = -1; // all
587 587
 			$readonlys = null;
588
-			$this->get_rows($query,$checked,$readonlys,!in_array($action,array('ical','document')));	   // true = only return the id's
588
+			$this->get_rows($query, $checked, $readonlys, !in_array($action, array('ical', 'document'))); // true = only return the id's
589 589
 			// Get rid of any extras (rows that aren't events)
590
-			if(in_array($action,array('ical','document')))
590
+			if (in_array($action, array('ical', 'document')))
591 591
 			{
592
-				foreach($checked as $key => $event)
592
+				foreach ($checked as $key => $event)
593 593
 				{
594
-					if(!is_numeric($key))
594
+					if (!is_numeric($key))
595 595
 					{
596 596
 						unset($checked[$key]);
597 597
 					}
@@ -599,28 +599,28 @@  discard block
 block discarded – undo
599 599
 			}
600 600
 		}
601 601
 		// for calendar integration we have to fetch all rows and unset the not selected ones, as we can not filter by id
602
-		elseif($action == 'document')
602
+		elseif ($action == 'document')
603 603
 		{
604 604
 			$query = is_array($session_name) ? $session_name : Api\Cache::getSession('calendar', $session_name);
605
-			@set_time_limit(0);				// switch off the execution time limit, as for big selections it's too small
605
+			@set_time_limit(0); // switch off the execution time limit, as for big selections it's too small
606 606
 			$events = null;
607
-			$this->get_rows($query,$events,$readonlys);
608
-			foreach($events as $key => $event)
607
+			$this->get_rows($query, $events, $readonlys);
608
+			foreach ($events as $key => $event)
609 609
 			{
610
-				$recur_date = Api\DateTime::to($event['recur_date'],'ts');
611
-				if (!in_array($event['id'],$checked) && !in_array($event['id'].':'.$recur_date, $checked)) unset($events[$key]);
610
+				$recur_date = Api\DateTime::to($event['recur_date'], 'ts');
611
+				if (!in_array($event['id'], $checked) && !in_array($event['id'].':'.$recur_date, $checked)) unset($events[$key]);
612 612
 			}
613 613
 			$checked = array_values($events); // Clear keys
614 614
 		}
615 615
 
616 616
 		// Actions where one action is done to the group
617
-		switch($action)
617
+		switch ($action)
618 618
 		{
619 619
 			case 'ical':
620 620
 				// compile list of unique cal_id's, as iCal should contain whole series, not recurrences
621 621
 				// calendar_ical->exportVCal needs to read events again, to get them in server-time
622 622
 				$ids = array();
623
-				foreach($checked as $id)
623
+				foreach ($checked as $id)
624 624
 				{
625 625
 					if (is_array($id)) $id = $id['id'];
626 626
 					// get rid of recurrences, doublicate series and calendar-integration events
@@ -630,7 +630,7 @@  discard block
 block discarded – undo
630 630
 					}
631 631
 				}
632 632
 				$boical = new calendar_ical();
633
-				$ical =& $boical->exportVCal($ids, '2.0', 'PUBLISH');
633
+				$ical = & $boical->exportVCal($ids, '2.0', 'PUBLISH');
634 634
 				Api\Header\Content::type('event.ics', 'text/calendar', bytes($ical));
635 635
 				echo $ical;
636 636
 				exit();
@@ -645,19 +645,19 @@  discard block
 block discarded – undo
645 645
 		}
646 646
 
647 647
 		// Actions where the action is applied to each entry
648
-		if(strpos($action, 'timesheet') !== false)
648
+		if (strpos($action, 'timesheet') !== false)
649 649
 		{
650 650
 			$timesheet_bo = new timesheet_bo();
651 651
 		}
652
-		foreach($checked as &$id)
652
+		foreach ($checked as &$id)
653 653
 		{
654 654
 			$recur_date = $app = $app_id = null;
655
-			if(is_array($id) && $id['id'])
655
+			if (is_array($id) && $id['id'])
656 656
 			{
657 657
 				$id = $id['id'];
658 658
 			}
659 659
 			$matches = null;
660
-			if(!(int)$id && preg_match('/^([a-z_-]+)([0-9]+)$/i',$id,$matches))
660
+			if (!(int)$id && preg_match('/^([a-z_-]+)([0-9]+)$/i', $id, $matches))
661 661
 			{
662 662
 				$app = $matches[1];
663 663
 				$app_id = $matches[2];
@@ -665,36 +665,36 @@  discard block
 block discarded – undo
665 665
 			}
666 666
 			else
667 667
 			{
668
-				list($id,$recur_date) = explode(':',$id);
668
+				list($id, $recur_date) = explode(':', $id);
669 669
 			}
670
-			switch($action)
670
+			switch ($action)
671 671
 			{
672 672
 				case 'delete':
673 673
 					$action_msg = lang('deleted');
674
-					if($settings == 'series')
674
+					if ($settings == 'series')
675 675
 					{
676 676
 						// Delete the whole thing
677 677
 						$recur_date = 0;
678 678
 					}
679
-					if ($id && $this->bo->delete($id, $recur_date,false,$skip_notification))
679
+					if ($id && $this->bo->delete($id, $recur_date, false, $skip_notification))
680 680
 					{
681 681
 						$success++;
682
-						if(!$recur_date && $settings == 'series')
682
+						if (!$recur_date && $settings == 'series')
683 683
 						{
684 684
 							// If there are multiple events in a series selected, the next one could purge
685
-							foreach($checked as $key => $c_id)
685
+							foreach ($checked as $key => $c_id)
686 686
 							{
687
-								list($c_id,$recur_date) = explode(':',$c_id);
688
-								if($c_id == $id)
687
+								list($c_id, $recur_date) = explode(':', $c_id);
688
+								if ($c_id == $id)
689 689
 								{
690 690
 									unset($checked[$key]);
691 691
 								}
692 692
 							}
693 693
 						}
694 694
 
695
-						if(Api\Json\Response::isJSONResponse())
695
+						if (Api\Json\Response::isJSONResponse())
696 696
 						{
697
-							Api\Json\Response::get()->call('egw.refresh','','calendar',$id,'delete');
697
+							Api\Json\Response::get()->call('egw.refresh', '', 'calendar', $id, 'delete');
698 698
 						}
699 699
 					}
700 700
 					else
@@ -704,23 +704,23 @@  discard block
 block discarded – undo
704 704
 					break;
705 705
 				case 'undelete':
706 706
 					$action_msg = lang('recovered');
707
-					if($settings == 'series')
707
+					if ($settings == 'series')
708 708
 					{
709 709
 						// unDelete the whole thing
710 710
 						$recur_date = 0;
711 711
 					}
712
-					if ($id && ($event = $this->bo->read($id, $recur_date)) && $this->bo->check_perms(Acl::EDIT,$id) &&
712
+					if ($id && ($event = $this->bo->read($id, $recur_date)) && $this->bo->check_perms(Acl::EDIT, $id) &&
713 713
 						is_array($event) && $event['deleted'])
714 714
 					{
715 715
 						$event['deleted'] = null;
716
-						if($this->bo->save($event))
716
+						if ($this->bo->save($event))
717 717
 						{
718 718
 							$success++;
719 719
 
720
-							if(Api\Json\Response::isJSONResponse())
720
+							if (Api\Json\Response::isJSONResponse())
721 721
 							{
722
-								Api\Json\Response::get()->call('egw.dataStoreUID','calendar::'.$id,$this->to_client($this->bo->read($id,$recur_date)));
723
-								Api\Json\Response::get()->call('egw.refresh','','calendar',$id,'edit');
722
+								Api\Json\Response::get()->call('egw.dataStoreUID', 'calendar::'.$id, $this->to_client($this->bo->read($id, $recur_date)));
723
+								Api\Json\Response::get()->call('egw.refresh', '', 'calendar', $id, 'edit');
724 724
 							}
725 725
 							break;
726 726
 						}
@@ -729,7 +729,7 @@  discard block
 block discarded – undo
729 729
 					break;
730 730
 				case 'status':
731 731
 					$action_msg = lang('Status changed');
732
-					if($id && ($event = $this->bo->read($id, $recur_date)))
732
+					if ($id && ($event = $this->bo->read($id, $recur_date)))
733 733
 					{
734 734
 						$old_status = $event['participants'][$GLOBALS['egw_info']['user']['account_id']];
735 735
 						$quantity = $role = null;
@@ -738,12 +738,12 @@  discard block
 block discarded – undo
738 738
 						{
739 739
 							//echo "<p>$uid: status changed '$data[old_status]' --> '$status<'/p>\n";
740 740
 							$new_status = calendar_so::combine_status($status, $quantity, $role);
741
-							if ($this->bo->set_status($event,$GLOBALS['egw_info']['user']['account_id'],$new_status,$recur_date,
742
-								false,true,$skip_notification))
741
+							if ($this->bo->set_status($event, $GLOBALS['egw_info']['user']['account_id'], $new_status, $recur_date,
742
+								false, true, $skip_notification))
743 743
 							{
744
-								if(Api\Json\Response::isJSONResponse())
744
+								if (Api\Json\Response::isJSONResponse())
745 745
 								{
746
-									Api\Json\Response::get()->call('egw.dataStoreUID','calendar::'.$id,$this->to_client($this->bo->read($id,$recur_date)));
746
+									Api\Json\Response::get()->call('egw.dataStoreUID', 'calendar::'.$id, $this->to_client($this->bo->read($id, $recur_date)));
747 747
 								}
748 748
 								$success++;
749 749
 								//$msg = lang('Status changed');
@@ -760,7 +760,7 @@  discard block
 block discarded – undo
760 760
 					}
761 761
 					break;
762 762
 				case 'timesheet-add':
763
-					if($id && !$app)
763
+					if ($id && !$app)
764 764
 					{
765 765
 						$event = $this->bo->read($id, $recur_date);
766 766
 					}
@@ -772,10 +772,10 @@  discard block
 block discarded – undo
772 772
 						$result = $this->bo->search($query);
773 773
 						$event = $result[$app.$app_id];
774 774
 					}
775
-					if(!$event)
775
+					if (!$event)
776 776
 					{
777 777
 						$failed++;
778
-						continue 2;	// +1 for switch
778
+						continue 2; // +1 for switch
779 779
 					}
780 780
 					$timesheet = array(
781 781
 						'ts_title'		=>	$event['title'],
@@ -789,16 +789,16 @@  discard block
 block discarded – undo
789 789
 					);
790 790
 
791 791
 					// Add global categories
792
-					$categories = explode(',',$event['category']);
792
+					$categories = explode(',', $event['category']);
793 793
 					$global_categories = array();
794
-					foreach($categories as $cat_id)
794
+					foreach ($categories as $cat_id)
795 795
 					{
796
-						if($GLOBALS['egw']->categories->is_global($cat_id))
796
+						if ($GLOBALS['egw']->categories->is_global($cat_id))
797 797
 						{
798 798
 							$global_categories[] = $cat_id;
799 799
 						}
800 800
 					}
801
-					if(count($global_categories))
801
+					if (count($global_categories))
802 802
 					{
803 803
 						$timesheet['cat_id'] = implode(',', $global_categories);
804 804
 					}
@@ -818,12 +818,12 @@  discard block
 block discarded – undo
818 818
 						}
819 819
 					}
820 820
 
821
-					if(!$err)
821
+					if (!$err)
822 822
 					{
823 823
 						$success++;
824 824
 
825 825
 						// Can't link to just one of a recurring series of events
826
-						if(!$recur_date || $app) {
826
+						if (!$recur_date || $app) {
827 827
 							// Create link
828 828
 							$link_id = $app ? $app_id : $id;
829 829
 							Link::link($app ? $app : 'calendar', $link_id, 'timesheet', $timesheet_bo->data['ts_id']);
@@ -851,7 +851,7 @@  discard block
 block discarded – undo
851 851
 	protected function get_merge_range($nm)
852 852
 	{
853 853
 		$checked = array();
854
-		if($nm['filter'] == 'fixed')
854
+		if ($nm['filter'] == 'fixed')
855 855
 		{
856 856
 			$checked['start'] = $nm['startdate'];
857 857
 			$last = $this->bo->date2array($nm['enddate']);
@@ -860,7 +860,7 @@  discard block
 block discarded – undo
860 860
 		}
861 861
 		else
862 862
 		{
863
-			switch($nm['filter'])
863
+			switch ($nm['filter'])
864 864
 			{
865 865
 				case 'after':
866 866
 					$checked['start'] = $nm['startdate'] ? $nm['startdate'] : strtotime('today');
@@ -873,8 +873,8 @@  discard block
 block discarded – undo
873 873
 					$checked['end'] = $nm['enddate'];
874 874
 					break;
875 875
 				default:
876
-					$date = date_create_from_format('Ymd',$this->date);
877
-					$checked['start']= $date->format('U');
876
+					$date = date_create_from_format('Ymd', $this->date);
877
+					$checked['start'] = $date->format('U');
878 878
 			}
879 879
 		}
880 880
 		return $checked;
@@ -899,7 +899,7 @@  discard block
 block discarded – undo
899 899
 				'allowOnMultiple' => false,
900 900
 				'url' => 'menuaction=calendar.calendar_uiforms.edit&cal_id=$id',
901 901
 				'popup' => Link::get_registry('calendar', 'view_popup'),
902
-				'group' => $group=1,
902
+				'group' => $group = 1,
903 903
 				'onExecute' => 'javaScript:app.calendar.cal_open',
904 904
 				'disableClass' => 'rowNoView',
905 905
 			),
@@ -931,7 +931,7 @@  discard block
 block discarded – undo
931 931
 				'group' => $group,
932 932
 			),
933 933
 		);
934
-		$status = array_map('lang',$this->bo->verbose_status);
934
+		$status = array_map('lang', $this->bo->verbose_status);
935 935
 		unset($status['G']);
936 936
 		$actions['status'] = array(
937 937
 			'caption' => 'Change your status',
@@ -940,7 +940,7 @@  discard block
 block discarded – undo
940 940
 			'children' => $status,
941 941
 			'group' => ++$group,
942 942
 		);
943
-		++$group;	// integration with other apps: infolog, calendar, filemanager
943
+		++$group; // integration with other apps: infolog, calendar, filemanager
944 944
 		if ($GLOBALS['egw_info']['user']['apps']['filemanager'])
945 945
 		{
946 946
 			$actions['filemanager'] = array(
@@ -964,7 +964,7 @@  discard block
 block discarded – undo
964 964
 				'popup' => Link::get_registry('infolog', 'add_popup'),
965 965
 			);
966 966
 		}
967
-		if($GLOBALS['egw_info']['user']['apps']['mail'])
967
+		if ($GLOBALS['egw_info']['user']['apps']['mail'])
968 968
 		{
969 969
 			//Send to email
970 970
 			$actions['email'] = array(
@@ -994,7 +994,7 @@  discard block
 block discarded – undo
994 994
 				'caption' => 'Timesheet',
995 995
 				'group' => $group,
996 996
 				'allowOnMultiple' => false,
997
-				'hideOnDisabled' => true,	// show only one timesheet action in context menu
997
+				'hideOnDisabled' => true, // show only one timesheet action in context menu
998 998
 				'onExecute' => 'javaScript:app.calendar.action_open',
999 999
 				'open' => '{"app": "timesheet", "type": "add", "extra": "link_app[]=$app&link_id[]=$app_id"}',
1000 1000
 				'popup' => Link::get_registry('timesheet', 'add_popup'),
@@ -1004,7 +1004,7 @@  discard block
 block discarded – undo
1004 1004
 				'caption' => 'Timesheet',
1005 1005
 				'group' => $group,
1006 1006
 				'allowOnMultiple' => 'only',
1007
-				'hideOnDisabled' => true,	// show only one timesheet action in context menu
1007
+				'hideOnDisabled' => true, // show only one timesheet action in context menu
1008 1008
 			);
1009 1009
 		}
1010 1010
 		$actions['ical'] = array(
@@ -1013,11 +1013,11 @@  discard block
 block discarded – undo
1013 1013
 			'group' => ++$group,
1014 1014
 			'hint' => 'Download this event as iCal',
1015 1015
 			'disableClass' => 'rowNoView',
1016
-			'postSubmit' => true,	// download needs post submit (not Ajax) to work
1016
+			'postSubmit' => true, // download needs post submit (not Ajax) to work
1017 1017
 		);
1018 1018
 		$actions['documents'] = calendar_merge::document_action(
1019 1019
 			$this->bo->cal_prefs['document_dir'], ++$group, 'Insert in document', 'document_',
1020
-			$this->bo->cal_prefs['default_document'],Api\Storage\Merge::getExportLimit('calendar')
1020
+			$this->bo->cal_prefs['default_document'], Api\Storage\Merge::getExportLimit('calendar')
1021 1021
 		);
1022 1022
 		++$group;
1023 1023
 		$actions['delete'] = array(
@@ -1027,7 +1027,7 @@  discard block
 block discarded – undo
1027 1027
 			'disableClass' => 'rowNoDelete',
1028 1028
 		);
1029 1029
 		// Add in deleted for admins
1030
-		if($GLOBALS['egw_info']['server']['calendar_delete_history'])
1030
+		if ($GLOBALS['egw_info']['server']['calendar_delete_history'])
1031 1031
 		{
1032 1032
 			$actions['undelete'] = array(
1033 1033
 				'caption' => 'Un-delete',
Please login to merge, or discard this patch.