Completed
Push — 16.1 ( 500e21...17a735 )
by Ralf
40:05 queued 20:51
created
calendar/inc/class.calendar_uilist.inc.php 1 patch
Spacing   +150 added lines, -150 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	 *
40 40
 	 * @var mixed
41 41
 	 */
42
-	var $debug=false;
42
+	var $debug = false;
43 43
 	/**
44 44
 	 * Filternames
45 45
 	 *
@@ -60,11 +60,11 @@  discard block
 block discarded – undo
60 60
 	 *
61 61
 	 * @param array $set_states =null to manualy set / change one of the states, default NULL = use $_REQUEST
62 62
 	 */
63
-	function __construct($set_states=null)
63
+	function __construct($set_states = null)
64 64
 	{
65
-		parent::__construct(true,$set_states);	// call the parent's constructor
65
+		parent::__construct(true, $set_states); // call the parent's constructor
66 66
 
67
-		foreach($this->date_filters as $name => $label)
67
+		foreach ($this->date_filters as $name => $label)
68 68
 		{
69 69
 			$this->date_filters[$name] = lang($label);
70 70
 		}
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 	/**
76 76
 	 * Show the listview
77 77
 	 */
78
-	function listview($_content=null,$msg='',$home=false)
78
+	function listview($_content = null, $msg = '', $home = false)
79 79
 	{
80 80
 		if ($_GET['msg']) $msg .= $_GET['msg'];
81 81
 		if ($this->group_warning) $msg .= $this->group_warning;
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 		$etpl = new Etemplate('calendar.list');
84 84
 
85 85
 		// Handle merge from sidebox
86
-		if($_GET['merge'])
86
+		if ($_GET['merge'])
87 87
 		{
88 88
 			$_content['nm']['action'] = 'document_'.$_GET['merge'];
89 89
 			$_content['nm']['select_all'] = true;
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 		if (is_array($_content))
93 93
 		{
94 94
 			// handle a single button like actions
95
-			foreach(array('delete','timesheet','document') as $button)
95
+			foreach (array('delete', 'timesheet', 'document') as $button)
96 96
 			{
97 97
 				if ($_content['nm']['rows'][$button])
98 98
 				{
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 			if ($_content['nm']['action'])
106 106
 			{
107 107
 				// Allow merge using the date range filter
108
-				if(strpos($_content['nm']['action'],'document') !== false &&
108
+				if (strpos($_content['nm']['action'], 'document') !== false &&
109 109
 					!count($_content['nm']['selected']) && !$_content['nm']['select_all']) {
110 110
 					$_content['nm']['selected'][] = $this->get_merge_range($_content['nm']);
111 111
 				}
@@ -116,14 +116,14 @@  discard block
 block discarded – undo
116 116
 				else
117 117
 				{
118 118
 					$success = $failed = $action_msg = null;
119
-					if ($this->action($_content['nm']['action'],$_content['nm']['selected'],$_content['nm']['select_all'],
120
-						$success,$failed,$action_msg,'calendar_list',$msg, $_content['nm']['checkboxes']['no_notifications']))
119
+					if ($this->action($_content['nm']['action'], $_content['nm']['selected'], $_content['nm']['select_all'],
120
+						$success, $failed, $action_msg, 'calendar_list', $msg, $_content['nm']['checkboxes']['no_notifications']))
121 121
 					{
122
-						$msg .= lang('%1 event(s) %2',$success,$action_msg);
122
+						$msg .= lang('%1 event(s) %2', $success, $action_msg);
123 123
 					}
124
-					elseif(is_null($msg))
124
+					elseif (is_null($msg))
125 125
 					{
126
-						$msg .= lang('%1 event(s) %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed);
126
+						$msg .= lang('%1 event(s) %2, %3 failed because of insufficent rights !!!', $success, $action_msg, $failed);
127 127
 					}
128 128
 				}
129 129
 			}
@@ -135,15 +135,15 @@  discard block
 block discarded – undo
135 135
 		{
136 136
 			$content['nm'] = array(
137 137
 				'get_rows'        =>	'calendar.calendar_uilist.get_rows',
138
-	 			'filter_no_lang'  => True,	// I  set no_lang for filter (=dont translate the options)
139
-				'no_filter2'      => True,	// I  disable the 2. filter (params are the same as for filter)
140
-				'no_cat'          => True,	// I  disable the cat-selectbox
138
+	 			'filter_no_lang'  => True, // I  set no_lang for filter (=dont translate the options)
139
+				'no_filter2'      => True, // I  disable the 2. filter (params are the same as for filter)
140
+				'no_cat'          => True, // I  disable the cat-selectbox
141 141
 				'filter'          => 'after',
142
-				'order'           => 'cal_start',// IO name of the column to sort after (optional for the sortheaders)
143
-				'sort'            => 'ASC',// IO direction of the sort: 'ASC' or 'DESC'
142
+				'order'           => 'cal_start', // IO name of the column to sort after (optional for the sortheaders)
143
+				'sort'            => 'ASC', // IO direction of the sort: 'ASC' or 'DESC'
144 144
 				'default_cols'    => '!week,weekday,cal_title,cal_description,recure,cal_location,cal_owner,cat_id,pm_id',
145 145
 				'filter_onchange' => "app.calendar.filter_change",
146
-				'row_id'          => 'row_id',	// set in get rows "$event[id]:$event[recur_date]"
146
+				'row_id'          => 'row_id', // set in get rows "$event[id]:$event[recur_date]"
147 147
 				'row_modified'    => 'modified',
148 148
 				'favorites'       => true,
149 149
 				'placeholder_actions' => array('add')
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 		}
152 152
 		$content['nm']['actions'] = $this->get_actions();
153 153
 
154
-		if (isset($_GET['filter']) && in_array($_GET['filter'],array_keys($this->date_filters)))
154
+		if (isset($_GET['filter']) && in_array($_GET['filter'], array_keys($this->date_filters)))
155 155
 		{
156 156
 			$content['nm']['filter'] = $_GET['filter'];
157 157
 		}
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 			!empty($json_data['request']['parameters'][0]))
165 165
 		{
166 166
 			$params = null;
167
-			parse_str(substr($json_data['request']['parameters'][0], 10), $params);	// cut off "/index.php?"
167
+			parse_str(substr($json_data['request']['parameters'][0], 10), $params); // cut off "/index.php?"
168 168
 			if (isset($params['keywords']))	// new search => set filters so every match is shown
169 169
 			{
170 170
 				$this->adjust_for_search($params['keywords'], $content['nm']);
@@ -172,22 +172,22 @@  discard block
 block discarded – undo
172 172
 		}
173 173
 		if (isset($_REQUEST['keywords']))	// new search => set filters so every match is shown
174 174
 		{
175
-			$this->adjust_for_search($_REQUEST['keywords'],$content['nm']);
175
+			$this->adjust_for_search($_REQUEST['keywords'], $content['nm']);
176 176
 		}
177 177
 		$sel_options['filter'] = &$this->date_filters;
178 178
 
179 179
 		// Send categories for row styling - calendar uses no_cat, so they don't go automatically
180 180
 		$sel_options['category'] = array('' => lang('all')) + Etemplate\Widget\Select::typeOptions('select-cat', ',,calendar');
181 181
 		// Prevent double encoding - widget does this on its own, but we're just grabbing the options
182
-		foreach($sel_options['category'] as &$label)
182
+		foreach ($sel_options['category'] as &$label)
183 183
 		{
184
-			if(!is_array($label))
184
+			if (!is_array($label))
185 185
 			{
186
-				$label = html_entity_decode($label, ENT_NOQUOTES,'utf-8');
186
+				$label = html_entity_decode($label, ENT_NOQUOTES, 'utf-8');
187 187
 			}
188
-			elseif($label['label'])
188
+			elseif ($label['label'])
189 189
 			{
190
-				$label['label'] = html_entity_decode($label['label'], ENT_NOQUOTES,'utf-8');
190
+				$label['label'] = html_entity_decode($label['label'], ENT_NOQUOTES, 'utf-8');
191 191
 			}
192 192
 		}
193 193
 
@@ -195,15 +195,15 @@  discard block
 block discarded – undo
195 195
 		if ($this->prefs['limit_des_lines'] > 0 || (string)$this->prefs['limit_des_lines'] == '')
196 196
 		{
197 197
 			$content['css'] .= '<style type="text/css">@media screen { .listDescription {  max-height: '.
198
-				(($this->prefs['limit_des_lines'] ? $this->prefs['limit_des_lines'] : 5) * 1.35).	   // dono why em is not real lines
198
+				(($this->prefs['limit_des_lines'] ? $this->prefs['limit_des_lines'] : 5) * 1.35).// dono why em is not real lines
199 199
 				'em; overflow: auto; }}</style>';
200 200
 		}
201 201
 
202
-		if($msg)
202
+		if ($msg)
203 203
 		{
204 204
 			Framework::message($msg);
205 205
 		}
206
-		$html = $etpl->exec('calendar.calendar_uilist.listview',$content,$sel_options,array(),array(),$home ? -1 : 0);
206
+		$html = $etpl->exec('calendar.calendar_uilist.listview', $content, $sel_options, array(), array(), $home ? -1 : 0);
207 207
 
208 208
 		// Not sure why this has to be echoed instead of appended, but that's what works.
209 209
 		//echo calendar_uiviews::edit_series();
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 	/**
215 215
 	 * set filter for search, so that everything is shown
216 216
 	 */
217
-	function adjust_for_search($keywords,&$params)
217
+	function adjust_for_search($keywords, &$params)
218 218
 	{
219 219
 		$params['search'] = $keywords;
220 220
 		$params['start']  = 0;
@@ -238,9 +238,9 @@  discard block
 block discarded – undo
238 238
 	 * @param array &$rows returned rows/events
239 239
 	 * @param array &$readonlys eg. to disable buttons based on Acl
240 240
 	 */
241
-	function get_rows(&$params,&$rows,&$readonlys)
241
+	function get_rows(&$params, &$rows, &$readonlys)
242 242
 	{
243
-		unset($readonlys);	// not used;
243
+		unset($readonlys); // not used;
244 244
 		//echo "uilist::get_rows() params="; _debug_array($params);
245 245
 		$this->filter = $params['filter'];
246 246
 		if ($params['filter'] == 'custom')
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 			}
271 271
 			if ($old_params['search'] != $params['search'])
272 272
 			{
273
-				$this->adjust_for_search($params['search'],$params);
273
+				$this->adjust_for_search($params['search'], $params);
274 274
 				$this->filter = $params['filter'];
275 275
 			}
276 276
 		}
@@ -278,28 +278,28 @@  discard block
 block discarded – undo
278 278
 		if (!$params['csv_export'])
279 279
 		{
280 280
 			Api\Cache::setSession('calendar', 'calendar_list',
281
-				array_diff_key ($params, array_flip(array('rows', 'actions', 'action_links', 'placeholder_actions'))));
281
+				array_diff_key($params, array_flip(array('rows', 'actions', 'action_links', 'placeholder_actions'))));
282 282
 		}
283 283
 		// do we need to query custom fields and which
284 284
 		// Check stored preference if selectcols isn't available (ie: first call)
285 285
 		$select_cols = $params['selectcols'] ? $params['selectcols'] : $GLOBALS['egw_info']['user']['preferences']['calendar']['nextmatch-calendar.list.rows'];
286
-		if(!is_array($params['selectcols']))
286
+		if (!is_array($params['selectcols']))
287 287
 		{
288
-			$select_cols = explode(',',$select_cols);
288
+			$select_cols = explode(',', $select_cols);
289 289
 		}
290
-		if (in_array('cfs',$select_cols))
290
+		if (in_array('cfs', $select_cols))
291 291
 		{
292 292
 			$cfs = array();
293
-			foreach($select_cols as $col)
293
+			foreach ($select_cols as $col)
294 294
 			{
295
-				if ($col[0] == '#') $cfs[] = substr($col,1);
295
+				if ($col[0] == '#') $cfs[] = substr($col, 1);
296 296
 			}
297 297
 		}
298 298
 		$search_params = array(
299 299
 			'cat_id'  => $params['cat_id'] ? $params['cat_id'] : 0,
300 300
 			'filter'  => $this->filter,
301 301
 			'query'   => $params['search'],
302
-			'offset'  => (int) $params['start'],
302
+			'offset'  => (int)$params['start'],
303 303
 			'num_rows'=> $params['num_rows'],
304 304
 			'order'   => $params['order'] ? $params['order'].' '.$params['sort'] : 'cal_start ASC',
305 305
 			'cfs'	 => $params['csv_export'] ? array() : $cfs,
@@ -307,24 +307,24 @@  discard block
 block discarded – undo
307 307
 		// Non-blocking events above blocking
308 308
 		$search_params['order'] .= ', cal_non_blocking DESC';
309 309
 
310
-		switch($this->filter)
310
+		switch ($this->filter)
311 311
 		{
312 312
 			case 'all':
313 313
 				break;
314 314
 			case 'before':
315
-				$search_params['end'] = $params['date'] ? Api\DateTime::to($params['date'],'ts') : $this->date;
316
-				$label = lang('Before %1',$this->bo->long_date($search_params['end']));
315
+				$search_params['end'] = $params['date'] ? Api\DateTime::to($params['date'], 'ts') : $this->date;
316
+				$label = lang('Before %1', $this->bo->long_date($search_params['end']));
317 317
 				break;
318 318
 			case 'custom':
319
-				$this->first = $search_params['start'] = Api\DateTime::to($params['startdate'],'ts');
320
-				$this->last  = $search_params['end'] = strtotime('+1 day', $this->bo->date2ts($params['enddate']))-1;
321
-				$label = $this->bo->long_date($this->first,$this->last);
319
+				$this->first = $search_params['start'] = Api\DateTime::to($params['startdate'], 'ts');
320
+				$this->last  = $search_params['end'] = strtotime('+1 day', $this->bo->date2ts($params['enddate'])) - 1;
321
+				$label = $this->bo->long_date($this->first, $this->last);
322 322
 				break;
323 323
 			case 'today':
324 324
 				$today = new Api\DateTime();
325 325
 				$today->setTime(0, 0, 0);
326 326
 				$this->first = $search_params['start'] = $today->format('ts');
327
-				$today->setTime(23,59,59);
327
+				$today->setTime(23, 59, 59);
328 328
 				$this->last  = $search_params['end'] = $today->format('ts');
329 329
 				break;
330 330
 			case 'week':
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
 				$this->last['hour'] = 23; $this->last['minute'] = $this->last['sec'] = 59;
337 337
 				unset($this->last['raw']);
338 338
 				$this->last = $this->bo->date2ts($this->last);
339
-				$this->date_filters['week'] = $label = lang('Week').' '.adodb_date('W',$this->first).': '.$this->bo->long_date($this->first,$this->last);
339
+				$this->date_filters['week'] = $label = lang('Week').' '.adodb_date('W', $this->first).': '.$this->bo->long_date($this->first, $this->last);
340 340
 				$search_params['start'] = $this->first;
341 341
 				$search_params['end'] = $this->last;
342 342
 				$params['startdate'] = Api\DateTime::to($this->first, Api\DateTime::ET2);
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
 				unset($this->first['raw']);
350 350
 				$this->last = $this->first;
351 351
 				$this->last['month'] += 1;
352
-				$this->date_filters['month'] = $label = lang(adodb_date('F',$this->bo->date2ts($params['date']))).' '.$this->first['year'];
352
+				$this->date_filters['month'] = $label = lang(adodb_date('F', $this->bo->date2ts($params['date']))).' '.$this->first['year'];
353 353
 				$this->first = $this->bo->date2ts($this->first);
354 354
 				$this->last = $this->bo->date2ts($this->last);
355 355
 				$this->last--;
@@ -362,29 +362,29 @@  discard block
 block discarded – undo
362 362
 				// fall through to after given date
363 363
 			case 'after':
364 364
 			default:
365
-				$this->date = $params['startdate'] ? Api\DateTime::to($params['startdate'],'ts') : $this->date;
366
-				$label = lang('After %1',$this->bo->long_date($this->date));
365
+				$this->date = $params['startdate'] ? Api\DateTime::to($params['startdate'], 'ts') : $this->date;
366
+				$label = lang('After %1', $this->bo->long_date($this->date));
367 367
 				$search_params['start'] = $this->date;
368 368
 				break;
369 369
 		}
370
-		if($params['status_filter'])
370
+		if ($params['status_filter'])
371 371
 		{
372 372
 			$search_params['filter'] = $params['status_filter'];
373 373
 		}
374 374
 		if ($params['col_filter']['participant'])
375 375
 		{
376
-			$search_params['users'] = is_array($params['col_filter']['participant']) ? $params['col_filter']['participant'] : array( $params['col_filter']['participant']);
376
+			$search_params['users'] = is_array($params['col_filter']['participant']) ? $params['col_filter']['participant'] : array($params['col_filter']['participant']);
377 377
 		}
378 378
 		elseif (!$params['col_filter'] || !$params['col_filter']['participant'])
379 379
 		{
380
-			$search_params['users'] = $params['owner'] ? $params['owner'] : explode(',',$this->owner);
380
+			$search_params['users'] = $params['owner'] ? $params['owner'] : explode(',', $this->owner);
381 381
 		}
382 382
 		if ($params['col_filter'])
383 383
 		{
384 384
 			$col_filter = array();
385
-			foreach($params['col_filter'] as $name => $val)
385
+			foreach ($params['col_filter'] as $name => $val)
386 386
 			{
387
-				if (!in_array($name, array('participant','row_id')) && (string)$val !== '')
387
+				if (!in_array($name, array('participant', 'row_id')) && (string)$val !== '')
388 388
 				{
389 389
 					$col_filter[$name] = $val;
390 390
 				}
@@ -394,18 +394,18 @@  discard block
 block discarded – undo
394 394
 
395 395
 		// App header is mostly taken care of on the client side, but here we update
396 396
 		// it to match changing list filters
397
-		if($params['view'] && $params['view'] == 'listview')
397
+		if ($params['view'] && $params['view'] == 'listview')
398 398
 		{
399 399
 			Api\Json\Response::get()->call('app.calendar.set_app_header',
400
-				(count($search_params['users']) == 1 ? $this->bo->participant_name($search_params['users'][0]).': ' : '') .
400
+				(count($search_params['users']) == 1 ? $this->bo->participant_name($search_params['users'][0]).': ' : '').
401 401
 				$label);
402 402
 		}
403
-		foreach((array) $this->bo->search($search_params, !empty($col_filter) ? $col_filter : null) as $event)
403
+		foreach ((array)$this->bo->search($search_params, !empty($col_filter) ? $col_filter : null) as $event)
404 404
 		{
405 405
 
406 406
 			if ($params['csv_export'])
407 407
 			{
408
-				$event['participants'] = implode(",\n",$this->bo->participants($event,true));
408
+				$event['participants'] = implode(",\n", $this->bo->participants($event, true));
409 409
 			}
410 410
 			else
411 411
 			{
@@ -413,23 +413,23 @@  discard block
 block discarded – undo
413 413
 			}
414 414
 
415 415
 			$matches = null;
416
-			if(!(int)$event['id'] && preg_match('/^([a-z_-]+)([0-9]+)$/i',$event['id'],$matches))
416
+			if (!(int)$event['id'] && preg_match('/^([a-z_-]+)([0-9]+)$/i', $event['id'], $matches))
417 417
 			{
418 418
 				$app = $matches[1];
419 419
 				$app_id = $matches[2];
420 420
 				$icons = array();
421
-				if (($is_private = calendar_bo::integration_get_private($app,$app_id,$event)))
421
+				if (($is_private = calendar_bo::integration_get_private($app, $app_id, $event)))
422 422
 				{
423
-					$icons[] = Api\Html::image('calendar','private');
423
+					$icons[] = Api\Html::image('calendar', 'private');
424 424
 				}
425 425
 				else
426 426
 				{
427
-					$icons = calendar_uiviews::integration_get_icons($app,$app_id,$event);
427
+					$icons = calendar_uiviews::integration_get_icons($app, $app_id, $event);
428 428
 				}
429 429
 			}
430 430
 			else
431 431
 			{
432
-				$is_private = !$this->bo->check_perms(Acl::READ,$event);
432
+				$is_private = !$this->bo->check_perms(Acl::READ, $event);
433 433
 			}
434 434
 			if ($is_private)
435 435
 			{
@@ -440,9 +440,9 @@  discard block
 block discarded – undo
440 440
 			$event['app_id'] = $event['id'];
441 441
 
442 442
 			// Edit link
443
-			if($app && $app_id)
443
+			if ($app && $app_id)
444 444
 			{
445
-				$popup = calendar_uiviews::integration_get_popup($app,$app_id);
445
+				$popup = calendar_uiviews::integration_get_popup($app, $app_id);
446 446
 
447 447
 				// Need to strip off 'onclick'
448 448
 				$event['edit_link'] = preg_replace('/ ?onclick="(.+)"/i', '$1', $popup);
@@ -453,18 +453,18 @@  discard block
 block discarded – undo
453 453
 				// populate js_integration_data, if not already set
454 454
 				if (!isset($js_integration_data[$app]))
455 455
 				{
456
-					$js_integration_data[$app] = calendar_bo::integration_get_data($app,'edit_link');
456
+					$js_integration_data[$app] = calendar_bo::integration_get_data($app, 'edit_link');
457 457
 				}
458 458
 			}
459 459
 			elseif ($event['recur_type'] != MCAL_RECUR_NONE)
460 460
 			{
461
-				$event['app_id'] .= ':'.Api\DateTime::to($event['recur_date'] ? $event['recur_date'] : $event['start'],'ts');
461
+				$event['app_id'] .= ':'.Api\DateTime::to($event['recur_date'] ? $event['recur_date'] : $event['start'], 'ts');
462 462
 			}
463 463
 
464 464
 			// Format start and end with timezone
465
-			foreach(array('start','end') as $time)
465
+			foreach (array('start', 'end') as $time)
466 466
 			{
467
-				$event[$time] = Api\DateTime::to($event[$time],'Y-m-d\TH:i:s\Z');
467
+				$event[$time] = Api\DateTime::to($event[$time], 'Y-m-d\TH:i:s\Z');
468 468
 			}
469 469
 
470 470
 			$rows[] = $event;
@@ -474,35 +474,35 @@  discard block
 block discarded – undo
474 474
 		// set js_calendar_integration object, to use it in app.js cal_open() function
475 475
 		$params['js_integration_data'] = json_encode($js_integration_data);
476 476
 
477
-		$wv=0;
478
-		$dv=0;
477
+		$wv = 0;
478
+		$dv = 0;
479 479
 
480 480
 		// Add in some select options
481
-		$users = is_array($search_params['users']) ? $search_params['users'] : explode(',',$search_params['users']);
481
+		$users = is_array($search_params['users']) ? $search_params['users'] : explode(',', $search_params['users']);
482 482
 
483 483
 		$this->bo->warnings['groupmembers'] = '';
484
-		if(($message = $this->check_owners_access($users)))
484
+		if (($message = $this->check_owners_access($users)))
485 485
 		{
486 486
 			Api\Json\Response::get()->error($message);
487 487
 		}
488
-		else if($this->bo->warnings['groupmembers'])
488
+		else if ($this->bo->warnings['groupmembers'])
489 489
 		{
490 490
 			Api\Json\Response::get()->error($this->bo->warnings['groupmembers']);
491 491
 		}
492 492
 		$rows['sel_options']['filter'] = $this->date_filters;
493
-		if($label)
493
+		if ($label)
494 494
 		{
495 495
 			$rows['sel_options']['filter'][$params['filter']] = $label;
496 496
 		}
497
-		foreach($users as $owner)
497
+		foreach ($users as $owner)
498 498
 		{
499
-			if(!is_int($owner) && $this->bo->resources[$owner[0]])
499
+			if (!is_int($owner) && $this->bo->resources[$owner[0]])
500 500
 			{
501 501
 				$app = $this->bo->resources[$owner[0]]['app'];
502
-				$_owner = substr($owner,1);
502
+				$_owner = substr($owner, 1);
503 503
 				// Try link first
504
-				$title = Link::title($app, $_owner );
505
-				if($title)
504
+				$title = Link::title($app, $_owner);
505
+				if ($title)
506 506
 				{
507 507
 					$rows['sel_options']['owner'][$owner] = $title;
508 508
 				}
@@ -510,15 +510,15 @@  discard block
 block discarded – undo
510 510
 		}
511 511
 		$params['options-selectcols']['week'] = lang('Week');
512 512
 		$params['options-selectcols']['weekday'] = lang('Weekday');
513
-		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,')
513
+		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,')
514 514
 		{
515
-			$rows['format'] = '32';	// prefix date with week-number
516
-			$wv=1;
515
+			$rows['format'] = '32'; // prefix date with week-number
516
+			$wv = 1;
517 517
 		}
518
-		if (!(strpos($this->cal_prefs['nextmatch-calendar.list.rows'],'weekday')===FALSE))
518
+		if (!(strpos($this->cal_prefs['nextmatch-calendar.list.rows'], 'weekday') === FALSE))
519 519
 		{
520 520
 			$rows['format'] = '16';
521
-			$dv=1;
521
+			$dv = 1;
522 522
 		}
523 523
 		if ($wv && $dv)
524 524
 		{
@@ -545,36 +545,36 @@  discard block
 block discarded – undo
545 545
 	 * @param string/array $session_name 'calendar_list'
546 546
 	 * @return boolean true if all actions succeded, false otherwise
547 547
 	 */
548
-	function action($action,$checked,$use_all,&$success,&$failed,&$action_msg,$session_name,&$msg,$skip_notification=false)
548
+	function action($action, $checked, $use_all, &$success, &$failed, &$action_msg, $session_name, &$msg, $skip_notification = false)
549 549
 	{
550 550
 		//error_log(__METHOD__."('$action', ".array2string($checked).', all='.(int)$use_all.", ...)");
551 551
 		$success = $failed = 0;
552 552
 		$msg = null;
553 553
 
554 554
 		// Split out combined values
555
-		if(strpos($action, 'status') !== false)
555
+		if (strpos($action, 'status') !== false)
556 556
 		{
557 557
 			list($action, $status) = explode('-', $action);
558 558
 		}
559 559
 		elseif (strpos($action, '_') !== false)
560 560
 		{
561
-			list($action, $settings) = explode('_', $action,2);
561
+			list($action, $settings) = explode('_', $action, 2);
562 562
 		}
563 563
 
564 564
 		if ($use_all)
565 565
 		{
566 566
 			// get the whole selection
567 567
 			$query = is_array($session_name) ? $session_name : Api\Cache::getSession('calendar', $session_name);
568
-			@set_time_limit(0);				// switch off the execution time limit, as for big selections it's too small
569
-			$query['num_rows'] = -1;		// all
568
+			@set_time_limit(0); // switch off the execution time limit, as for big selections it's too small
569
+			$query['num_rows'] = -1; // all
570 570
 			$readonlys = null;
571
-			$this->get_rows($query,$checked,$readonlys,!in_array($action,array('ical','document')));	   // true = only return the id's
571
+			$this->get_rows($query, $checked, $readonlys, !in_array($action, array('ical', 'document'))); // true = only return the id's
572 572
 			// Get rid of any extras (rows that aren't events)
573
-			if(in_array($action,array('ical','document')))
573
+			if (in_array($action, array('ical', 'document')))
574 574
 			{
575
-				foreach($checked as $key => $event)
575
+				foreach ($checked as $key => $event)
576 576
 				{
577
-					if(!is_numeric($key))
577
+					if (!is_numeric($key))
578 578
 					{
579 579
 						unset($checked[$key]);
580 580
 					}
@@ -582,27 +582,27 @@  discard block
 block discarded – undo
582 582
 			}
583 583
 		}
584 584
 		// for calendar integration we have to fetch all rows and unset the not selected ones, as we can not filter by id
585
-		elseif($action == 'document')
585
+		elseif ($action == 'document')
586 586
 		{
587 587
 			$query = is_array($session_name) ? $session_name : Api\Cache::getSession('calendar', $session_name);
588
-			@set_time_limit(0);				// switch off the execution time limit, as for big selections it's too small
588
+			@set_time_limit(0); // switch off the execution time limit, as for big selections it's too small
589 589
 			$events = null;
590
-			$this->get_rows($query,$events,$readonlys);
591
-			foreach($events as $key => $event)
590
+			$this->get_rows($query, $events, $readonlys);
591
+			foreach ($events as $key => $event)
592 592
 			{
593
-				if (!in_array($event['id'],$checked) && !in_array($event['id'].':'.$event['recur_date'], $checked)) unset($events[$key]);
593
+				if (!in_array($event['id'], $checked) && !in_array($event['id'].':'.$event['recur_date'], $checked)) unset($events[$key]);
594 594
 			}
595 595
 			$checked = array_values($events); // Clear keys
596 596
 		}
597 597
 
598 598
 		// Actions where one action is done to the group
599
-		switch($action)
599
+		switch ($action)
600 600
 		{
601 601
 			case 'ical':
602 602
 				// compile list of unique cal_id's, as iCal should contain whole series, not recurrences
603 603
 				// calendar_ical->exportVCal needs to read events again, to get them in server-time
604 604
 				$ids = array();
605
-				foreach($checked as $id)
605
+				foreach ($checked as $id)
606 606
 				{
607 607
 					if (is_array($id)) $id = $id['id'];
608 608
 					// get rid of recurrences, doublicate series and calendar-integration events
@@ -612,7 +612,7 @@  discard block
 block discarded – undo
612 612
 					}
613 613
 				}
614 614
 				$boical = new calendar_ical();
615
-				$ical =& $boical->exportVCal($ids, '2.0', 'PUBLISH');
615
+				$ical = & $boical->exportVCal($ids, '2.0', 'PUBLISH');
616 616
 				Api\Header\Content::type('event.ics', 'text/calendar', bytes($ical));
617 617
 				echo $ical;
618 618
 				exit();
@@ -627,19 +627,19 @@  discard block
 block discarded – undo
627 627
 		}
628 628
 
629 629
 		// Actions where the action is applied to each entry
630
-		if(strpos($action, 'timesheet') !== false)
630
+		if (strpos($action, 'timesheet') !== false)
631 631
 		{
632 632
 			$timesheet_bo = new timesheet_bo();
633 633
 		}
634
-		foreach($checked as &$id)
634
+		foreach ($checked as &$id)
635 635
 		{
636 636
 			$recur_date = $app = $app_id = null;
637
-			if(is_array($id) && $id['id'])
637
+			if (is_array($id) && $id['id'])
638 638
 			{
639 639
 				$id = $id['id'];
640 640
 			}
641 641
 			$matches = null;
642
-			if(!(int)$id && preg_match('/^([a-z_-]+)([0-9]+)$/i',$id,$matches))
642
+			if (!(int)$id && preg_match('/^([a-z_-]+)([0-9]+)$/i', $id, $matches))
643 643
 			{
644 644
 				$app = $matches[1];
645 645
 				$app_id = $matches[2];
@@ -647,36 +647,36 @@  discard block
 block discarded – undo
647 647
 			}
648 648
 			else
649 649
 			{
650
-				list($id,$recur_date) = explode(':',$id);
650
+				list($id, $recur_date) = explode(':', $id);
651 651
 			}
652
-			switch($action)
652
+			switch ($action)
653 653
 			{
654 654
 				case 'delete':
655 655
 					$action_msg = lang('deleted');
656
-					if($settings == 'series')
656
+					if ($settings == 'series')
657 657
 					{
658 658
 						// Delete the whole thing
659 659
 						$recur_date = 0;
660 660
 					}
661
-					if ($id && $this->bo->delete($id, $recur_date,false,$skip_notification))
661
+					if ($id && $this->bo->delete($id, $recur_date, false, $skip_notification))
662 662
 					{
663 663
 						$success++;
664
-						if(!$recur_date && $settings == 'series')
664
+						if (!$recur_date && $settings == 'series')
665 665
 						{
666 666
 							// If there are multiple events in a series selected, the next one could purge
667
-							foreach($checked as $key => $c_id)
667
+							foreach ($checked as $key => $c_id)
668 668
 							{
669
-								list($c_id,$recur_date) = explode(':',$c_id);
670
-								if($c_id == $id)
669
+								list($c_id, $recur_date) = explode(':', $c_id);
670
+								if ($c_id == $id)
671 671
 								{
672 672
 									unset($checked[$key]);
673 673
 								}
674 674
 							}
675 675
 						}
676 676
 
677
-						if(Api\Json\Response::isJSONResponse())
677
+						if (Api\Json\Response::isJSONResponse())
678 678
 						{
679
-							Api\Json\Response::get()->call('egw.refresh','','calendar',$id,'delete');
679
+							Api\Json\Response::get()->call('egw.refresh', '', 'calendar', $id, 'delete');
680 680
 						}
681 681
 					}
682 682
 					else
@@ -686,23 +686,23 @@  discard block
 block discarded – undo
686 686
 					break;
687 687
 				case 'undelete':
688 688
 					$action_msg = lang('recovered');
689
-					if($settings == 'series')
689
+					if ($settings == 'series')
690 690
 					{
691 691
 						// unDelete the whole thing
692 692
 						$recur_date = 0;
693 693
 					}
694
-					if ($id && ($event = $this->bo->read($id, $recur_date)) && $this->bo->check_perms(Acl::EDIT,$id) &&
694
+					if ($id && ($event = $this->bo->read($id, $recur_date)) && $this->bo->check_perms(Acl::EDIT, $id) &&
695 695
 						is_array($event) && $event['deleted'])
696 696
 					{
697 697
 						$event['deleted'] = null;
698
-						if($this->bo->save($event))
698
+						if ($this->bo->save($event))
699 699
 						{
700 700
 							$success++;
701 701
 
702
-							if(Api\Json\Response::isJSONResponse())
702
+							if (Api\Json\Response::isJSONResponse())
703 703
 							{
704
-								Api\Json\Response::get()->call('egw.dataStoreUID','calendar::'.$id,$this->to_client($this->bo->read($id,$recur_date)));
705
-								Api\Json\Response::get()->call('egw.refresh','','calendar',$id,'edit');
704
+								Api\Json\Response::get()->call('egw.dataStoreUID', 'calendar::'.$id, $this->to_client($this->bo->read($id, $recur_date)));
705
+								Api\Json\Response::get()->call('egw.refresh', '', 'calendar', $id, 'edit');
706 706
 							}
707 707
 							break;
708 708
 						}
@@ -711,7 +711,7 @@  discard block
 block discarded – undo
711 711
 					break;
712 712
 				case 'status':
713 713
 					$action_msg = lang('Status changed');
714
-					if($id && ($event = $this->bo->read($id, $recur_date)))
714
+					if ($id && ($event = $this->bo->read($id, $recur_date)))
715 715
 					{
716 716
 						$old_status = $event['participants'][$GLOBALS['egw_info']['user']['account_id']];
717 717
 						$quantity = $role = null;
@@ -720,12 +720,12 @@  discard block
 block discarded – undo
720 720
 						{
721 721
 							//echo "<p>$uid: status changed '$data[old_status]' --> '$status<'/p>\n";
722 722
 							$new_status = calendar_so::combine_status($status, $quantity, $role);
723
-							if ($this->bo->set_status($event,$GLOBALS['egw_info']['user']['account_id'],$new_status,$recur_date,
724
-								false,true,$skip_notification))
723
+							if ($this->bo->set_status($event, $GLOBALS['egw_info']['user']['account_id'], $new_status, $recur_date,
724
+								false, true, $skip_notification))
725 725
 							{
726
-								if(Api\Json\Response::isJSONResponse())
726
+								if (Api\Json\Response::isJSONResponse())
727 727
 								{
728
-									Api\Json\Response::get()->call('egw.dataStoreUID','calendar::'.$id,$this->to_client($this->bo->read($id,$recur_date)));
728
+									Api\Json\Response::get()->call('egw.dataStoreUID', 'calendar::'.$id, $this->to_client($this->bo->read($id, $recur_date)));
729 729
 								}
730 730
 								$success++;
731 731
 								//$msg = lang('Status changed');
@@ -742,7 +742,7 @@  discard block
 block discarded – undo
742 742
 					}
743 743
 					break;
744 744
 				case 'timesheet-add':
745
-					if($id && !$app)
745
+					if ($id && !$app)
746 746
 					{
747 747
 						$event = $this->bo->read($id, $recur_date);
748 748
 					}
@@ -754,7 +754,7 @@  discard block
 block discarded – undo
754 754
 						$result = $this->bo->search($query);
755 755
 						$event = $result[$app.$app_id];
756 756
 					}
757
-					if(!$event)
757
+					if (!$event)
758 758
 					{
759 759
 						$failed++;
760 760
 						continue;
@@ -771,16 +771,16 @@  discard block
 block discarded – undo
771 771
 					);
772 772
 
773 773
 					// Add global categories
774
-					$categories = explode(',',$event['category']);
774
+					$categories = explode(',', $event['category']);
775 775
 					$global_categories = array();
776
-					foreach($categories as $cat_id)
776
+					foreach ($categories as $cat_id)
777 777
 					{
778
-						if($GLOBALS['egw']->categories->is_global($cat_id))
778
+						if ($GLOBALS['egw']->categories->is_global($cat_id))
779 779
 						{
780 780
 							$global_categories[] = $cat_id;
781 781
 						}
782 782
 					}
783
-					if(count($global_categories))
783
+					if (count($global_categories))
784 784
 					{
785 785
 						$timesheet['cat_id'] = implode(',', $global_categories);
786 786
 					}
@@ -800,12 +800,12 @@  discard block
 block discarded – undo
800 800
 						}
801 801
 					}
802 802
 
803
-					if(!$err)
803
+					if (!$err)
804 804
 					{
805 805
 						$success++;
806 806
 
807 807
 						// Can't link to just one of a recurring series of events
808
-						if(!$recur_date || $app) {
808
+						if (!$recur_date || $app) {
809 809
 							// Create link
810 810
 							$link_id = $app ? $app_id : $id;
811 811
 							Link::link($app ? $app : 'calendar', $link_id, 'timesheet', $timesheet_bo->data['ts_id']);
@@ -833,7 +833,7 @@  discard block
 block discarded – undo
833 833
 	protected function get_merge_range($nm)
834 834
 	{
835 835
 		$checked = array();
836
-		if($nm['filter'] == 'fixed')
836
+		if ($nm['filter'] == 'fixed')
837 837
 		{
838 838
 			$checked['start'] = $nm['startdate'];
839 839
 			$last = $this->bo->date2array($nm['enddate']);
@@ -842,7 +842,7 @@  discard block
 block discarded – undo
842 842
 		}
843 843
 		else
844 844
 		{
845
-			switch($nm['filter'])
845
+			switch ($nm['filter'])
846 846
 			{
847 847
 				case 'after':
848 848
 					$checked['start'] = $nm['startdate'] ? $nm['startdate'] : strtotime('today');
@@ -855,8 +855,8 @@  discard block
 block discarded – undo
855 855
 					$checked['end'] = $nm['enddate'];
856 856
 					break;
857 857
 				default:
858
-					$date = date_create_from_format('Ymd',$this->date);
859
-					$checked['start']= $date->format('U');
858
+					$date = date_create_from_format('Ymd', $this->date);
859
+					$checked['start'] = $date->format('U');
860 860
 			}
861 861
 		}
862 862
 		return $checked;
@@ -881,7 +881,7 @@  discard block
 block discarded – undo
881 881
 				'allowOnMultiple' => false,
882 882
 				'url' => 'menuaction=calendar.calendar_uiforms.edit&cal_id=$id',
883 883
 				'popup' => Link::get_registry('calendar', 'view_popup'),
884
-				'group' => $group=1,
884
+				'group' => $group = 1,
885 885
 				'onExecute' => 'javaScript:app.calendar.cal_open',
886 886
 				'disableClass' => 'rowNoView',
887 887
 			),
@@ -914,7 +914,7 @@  discard block
 block discarded – undo
914 914
 				'group' => $group,
915 915
 			),
916 916
 		);
917
-		$status = array_map('lang',$this->bo->verbose_status);
917
+		$status = array_map('lang', $this->bo->verbose_status);
918 918
 		unset($status['G']);
919 919
 		$actions['status'] = array(
920 920
 			'caption' => 'Change your status',
@@ -923,7 +923,7 @@  discard block
 block discarded – undo
923 923
 			'children' => $status,
924 924
 			'group' => ++$group,
925 925
 		);
926
-		++$group;	// integration with other apps: infolog, calendar, filemanager
926
+		++$group; // integration with other apps: infolog, calendar, filemanager
927 927
 		if ($GLOBALS['egw_info']['user']['apps']['filemanager'])
928 928
 		{
929 929
 			$actions['filemanager'] = array(
@@ -955,7 +955,7 @@  discard block
 block discarded – undo
955 955
 				'url' => 'menuaction=timesheet.timesheet_ui.edit&link_app[]=$app&link_id[]=$id',
956 956
 				'group' => $group,
957 957
 				'allowOnMultiple' => false,
958
-				'hideOnDisabled' => true,	// show only one timesheet action in context menu
958
+				'hideOnDisabled' => true, // show only one timesheet action in context menu
959 959
 				'onExecute' => 'javaScript:app.calendar.cal_fix_app_id',
960 960
 				'popup' => Link::get_registry('timesheet', 'add_popup'),
961 961
 			);
@@ -964,7 +964,7 @@  discard block
 block discarded – undo
964 964
 				'caption' => 'Timesheet',
965 965
 				'group' => $group,
966 966
 				'allowOnMultiple' => 'only',
967
-				'hideOnDisabled' => true,	// show only one timesheet action in context menu
967
+				'hideOnDisabled' => true, // show only one timesheet action in context menu
968 968
 			);
969 969
 		}
970 970
 		$actions['ical'] = array(
@@ -973,11 +973,11 @@  discard block
 block discarded – undo
973 973
 			'group' => ++$group,
974 974
 			'hint' => 'Download this event as iCal',
975 975
 			'disableClass' => 'rowNoView',
976
-			'postSubmit' => true,	// download needs post submit (not Ajax) to work
976
+			'postSubmit' => true, // download needs post submit (not Ajax) to work
977 977
 		);
978 978
 		$actions['documents'] = calendar_merge::document_action(
979 979
 			$this->bo->cal_prefs['document_dir'], ++$group, 'Insert in document', 'document_',
980
-			$this->bo->cal_prefs['default_document'],Api\Storage\Merge::getExportLimit('calendar')
980
+			$this->bo->cal_prefs['default_document'], Api\Storage\Merge::getExportLimit('calendar')
981 981
 		);
982 982
 		++$group;
983 983
 		$actions['delete'] = array(
@@ -987,7 +987,7 @@  discard block
 block discarded – undo
987 987
 			'disableClass' => 'rowNoDelete',
988 988
 		);
989 989
 		// Add in deleted for admins
990
-		if($GLOBALS['egw_info']['server']['calendar_delete_history'])
990
+		if ($GLOBALS['egw_info']['server']['calendar_delete_history'])
991 991
 		{
992 992
 			$actions['undelete'] = array(
993 993
 				'caption' => 'Un-delete',
Please login to merge, or discard this patch.