Completed
Push — 16.1 ( 2b6741...abc73d )
by Nathan
50:22 queued 36:36
created
calendar/inc/class.calendar_egw_record.inc.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -24,8 +24,8 @@  discard block
 block discarded – undo
24 24
 
25 25
 	public static $types = array(
26 26
 		'select-cat'    => array('category'),
27
-		'select-account'=> array('owner','creator', 'modifier'),
28
-		'date-time'     => array('modified', 'created','start','end','recur_date'),
27
+		'select-account'=> array('owner', 'creator', 'modifier'),
28
+		'date-time'     => array('modified', 'created', 'start', 'end', 'recur_date'),
29 29
 		'date'			=> array('recur_enddate'),
30 30
 		'select-bool'	=> array('public', 'non_blocking'),
31 31
 		'select'	=> array('priority'),
@@ -37,12 +37,12 @@  discard block
 block discarded – undo
37 37
 	 *
38 38
 	 * @param string $_identifier
39 39
 	 */
40
-	public function __construct( $_identifier='' ){
40
+	public function __construct($_identifier = '') {
41 41
 		$this->identifier = $_identifier;
42
-		if(!is_object($this->bo)) {
42
+		if (!is_object($this->bo)) {
43 43
 			$this->bo = new calendar_bo();
44 44
 		}
45
-		if($this->identifier) {
45
+		if ($this->identifier) {
46 46
 			$this->record = $this->bo->read($this->identifier);
47 47
 		}
48 48
 	}
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 	 * @todo add some checks
97 97
 	 * @return void
98 98
 	 */
99
-	public function set_record(array $_record){
99
+	public function set_record(array $_record) {
100 100
 		$this->record = $_record;
101 101
 	}
102 102
 
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 	 *
125 125
 	 * @return string identifier
126 126
 	 */
127
-	public function save ( $_dst_identifier ) {
127
+	public function save($_dst_identifier) {
128 128
 		// Not yet implemeted
129 129
 		$this->identifier = $_dst_identifier;
130 130
 	}
@@ -135,8 +135,8 @@  discard block
 block discarded – undo
135 135
 	 * @param string $_dst_identifier
136 136
 	 * @return string dst_identifier
137 137
 	 */
138
-	public function copy ( $_dst_identifier ) {
139
-		unset($_dst_identifier);	// not used
138
+	public function copy($_dst_identifier) {
139
+		unset($_dst_identifier); // not used
140 140
 	}
141 141
 
142 142
 	/**
@@ -146,15 +146,15 @@  discard block
 block discarded – undo
146 146
 	 * @param string $_dst_identifier
147 147
 	 * @return string dst_identifier
148 148
 	 */
149
-	public function move ( $_dst_identifier ) {
150
-		unset($_dst_identifier);	// not used
149
+	public function move($_dst_identifier) {
150
+		unset($_dst_identifier); // not used
151 151
 	}
152 152
 
153 153
 	/**
154 154
 	 * delets current record from backend
155 155
 	 *
156 156
 	 */
157
-	public function delete () {
157
+	public function delete() {
158 158
 
159 159
 	}
160 160
 
Please login to merge, or discard this patch.
Braces   +34 added lines, -17 removed lines patch added patch discarded remove patch
@@ -37,12 +37,15 @@  discard block
 block discarded – undo
37 37
 	 *
38 38
 	 * @param string $_identifier
39 39
 	 */
40
-	public function __construct( $_identifier='' ){
40
+	public function __construct( $_identifier='' )
41
+	{
41 42
 		$this->identifier = $_identifier;
42
-		if(!is_object($this->bo)) {
43
+		if(!is_object($this->bo))
44
+		{
43 45
 			$this->bo = new calendar_bo();
44 46
 		}
45
-		if($this->identifier) {
47
+		if($this->identifier)
48
+		{
46 49
 			$this->record = $this->bo->read($this->identifier);
47 50
 		}
48 51
 	}
@@ -52,7 +55,8 @@  discard block
 block discarded – undo
52 55
 	 *
53 56
 	 * @param string $_attribute_name
54 57
 	 */
55
-	public function __get($_attribute_name) {
58
+	public function __get($_attribute_name)
59
+	{
56 60
 		return $this->record[$_attribute_name];
57 61
 	}
58 62
 
@@ -62,11 +66,13 @@  discard block
 block discarded – undo
62 66
 	 * @param string $_attribute_name
63 67
 	 * @param data $data
64 68
 	 */
65
-	public function __set($_attribute_name, $data) {
69
+	public function __set($_attribute_name, $data)
70
+	{
66 71
 		$this->record[$_attribute_name] = $data;
67 72
 	}
68 73
 
69
-	public function __unset($_attribute_name) {
74
+	public function __unset($_attribute_name)
75
+	{
70 76
 		unset($this->record[$_attribute_name]);
71 77
 	}
72 78
 
@@ -78,7 +84,8 @@  discard block
 block discarded – undo
78 84
 	 *
79 85
 	 * @return array complete record as associative array
80 86
 	 */
81
-	public function get_record_array() {
87
+	public function get_record_array()
88
+	{
82 89
 		return $this->record;
83 90
 	}
84 91
 
@@ -87,8 +94,10 @@  discard block
 block discarded – undo
87 94
 	 *
88 95
 	 *@return string tiltle
89 96
 	 */
90
-	public function get_title() {
91
-		if (empty($this->record)) {
97
+	public function get_title()
98
+	{
99
+		if (empty($this->record))
100
+		{
92 101
 			$this->get_record();
93 102
 		}
94 103
 		return $this->record['title'];
@@ -100,7 +109,8 @@  discard block
 block discarded – undo
100 109
 	 * @todo add some checks
101 110
 	 * @return void
102 111
 	 */
103
-	public function set_record(array $_record){
112
+	public function set_record(array $_record)
113
+	{
104 114
 		$this->record = $_record;
105 115
 	}
106 116
 
@@ -109,7 +119,8 @@  discard block
 block discarded – undo
109 119
 	 *
110 120
 	 * @return string identifier of current record
111 121
 	 */
112
-	public function get_identifier() {
122
+	public function get_identifier()
123
+	{
113 124
 		return $this->identifier;
114 125
 	}
115 126
 
@@ -119,7 +130,8 @@  discard block
 block discarded – undo
119 130
 	 *
120 131
 	 * @return string Full URL of an icon, or appname/icon_name
121 132
 	 */
122
-	public function get_icon() {
133
+	public function get_icon()
134
+	{
123 135
 		return 'calendar/navbar';
124 136
 	}
125 137
 
@@ -128,7 +140,8 @@  discard block
 block discarded – undo
128 140
 	 *
129 141
 	 * @return string identifier
130 142
 	 */
131
-	public function save ( $_dst_identifier ) {
143
+	public function save ( $_dst_identifier )
144
+	{
132 145
 		// Not yet implemeted
133 146
 		$this->identifier = $_dst_identifier;
134 147
 	}
@@ -139,7 +152,8 @@  discard block
 block discarded – undo
139 152
 	 * @param string $_dst_identifier
140 153
 	 * @return string dst_identifier
141 154
 	 */
142
-	public function copy ( $_dst_identifier ) {
155
+	public function copy ( $_dst_identifier )
156
+	{
143 157
 		unset($_dst_identifier);	// not used
144 158
 	}
145 159
 
@@ -150,7 +164,8 @@  discard block
 block discarded – undo
150 164
 	 * @param string $_dst_identifier
151 165
 	 * @return string dst_identifier
152 166
 	 */
153
-	public function move ( $_dst_identifier ) {
167
+	public function move ( $_dst_identifier )
168
+	{
154 169
 		unset($_dst_identifier);	// not used
155 170
 	}
156 171
 
@@ -158,7 +173,8 @@  discard block
 block discarded – undo
158 173
 	 * delets current record from backend
159 174
 	 *
160 175
 	 */
161
-	public function delete () {
176
+	public function delete ()
177
+	{
162 178
 
163 179
 	}
164 180
 
@@ -166,7 +182,8 @@  discard block
 block discarded – undo
166 182
 	 * destructor
167 183
 	 *
168 184
 	 */
169
-	public function __destruct() {
185
+	public function __destruct()
186
+	{
170 187
 	}
171 188
 
172 189
 }
173 190
\ No newline at end of file
Please login to merge, or discard this patch.
calendar/inc/class.calendar_ui.inc.php 4 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -387,11 +387,11 @@
 block discarded – undo
387 387
 	}
388 388
 
389 389
 	/**
390
-	* gets the icons displayed for a given event
391
-	*
392
-	* @param array $event
393
-	* @return array of 'img' / 'title' pairs
394
-	*/
390
+	 * gets the icons displayed for a given event
391
+	 *
392
+	 * @param array $event
393
+	 * @return array of 'img' / 'title' pairs
394
+	 */
395 395
 	function event_icons($event)
396 396
 	{
397 397
 		$is_private = !$event['public'] && !$this->bo->check_perms(Acl::READ,$event);
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -517,7 +517,7 @@
 block discarded – undo
517 517
 
518 518
 		if ($GLOBALS['egw_info']['user']['apps']['admin'])
519 519
 		{
520
-			$file = Array(
520
+			$file = array(
521 521
 				'Site configuration'=>Egw::link('/index.php','menuaction=admin.admin_config.index&appname=calendar&ajax=true'),
522 522
 				'Custom Fields'=>Egw::link('/index.php','menuaction=admin.admin_customfields.index&appname=calendar&ajax=true'),
523 523
 				'Global Categories' =>Egw::link('/index.php','menuaction=admin.admin_categories.index&appname=calendar&ajax=true'),
Please login to merge, or discard this patch.
Spacing   +140 added lines, -140 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 	/**
34 34
 	 * @var $debug mixed integer level or string function-name
35 35
 	 */
36
-	var $debug=false;
36
+	var $debug = false;
37 37
 	/**
38 38
 	 * instance of the bocal or bocalupdate class
39 39
 	 *
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 	/**
128 128
 	 * @var array $states_to_save all states that will be saved to the user prefs
129 129
 	 */
130
-	var $states_to_save = array('owner','status_filter','filter','cat_id','view','sortby','planner_view','weekend');
130
+	var $states_to_save = array('owner', 'status_filter', 'filter', 'cat_id', 'view', 'sortby', 'planner_view', 'weekend');
131 131
 
132 132
 	/**
133 133
 	 * Constructor
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 	 * @param boolean $use_boupdate use bocalupdate as parenent instead of bocal
136 136
 	 * @param array $set_states to manualy set / change one of the states, default NULL = use $_REQUEST
137 137
 	 */
138
-	function __construct($use_boupdate=false,$set_states=NULL)
138
+	function __construct($use_boupdate = false, $set_states = NULL)
139 139
 	{
140 140
 		if ($use_boupdate)
141 141
 		{
@@ -146,27 +146,27 @@  discard block
 block discarded – undo
146 146
 			$this->bo = new calendar_bo();
147 147
 		}
148 148
 
149
-		$this->categories = new Api\Categories($this->user,'calendar');
149
+		$this->categories = new Api\Categories($this->user, 'calendar');
150 150
 
151
-		$this->common_prefs	= &$GLOBALS['egw_info']['user']['preferences']['common'];
151
+		$this->common_prefs = &$GLOBALS['egw_info']['user']['preferences']['common'];
152 152
 		$this->cal_prefs	= &$GLOBALS['egw_info']['user']['preferences']['calendar'];
153 153
 		$this->bo->check_set_default_prefs();
154 154
 
155
-		$this->wd_start		= 60*$this->cal_prefs['workdaystarts'];
156
-		$this->wd_end		= 60*$this->cal_prefs['workdayends'];
157
-		$this->interval_m	= $this->cal_prefs['interval'];
155
+		$this->wd_start		= 60 * $this->cal_prefs['workdaystarts'];
156
+		$this->wd_end = 60 * $this->cal_prefs['workdayends'];
157
+		$this->interval_m = $this->cal_prefs['interval'];
158 158
 
159 159
 		$this->user = $GLOBALS['egw_info']['user']['account_id'];
160 160
 
161 161
 		$this->manage_states($set_states);
162 162
 
163
-		$GLOBALS['uical'] = &$this;	// make us available for ExecMethod, else it creates a new instance
163
+		$GLOBALS['uical'] = &$this; // make us available for ExecMethod, else it creates a new instance
164 164
 
165 165
 		// calendar does not work with hidden sidebox atm.
166 166
 		unset($GLOBALS['egw_info']['user']['preferences']['common']['auto_hide_sidebox']);
167 167
 
168 168
 		// make sure the hook for export_limit is registered
169
-		if (!Api\Hooks::exists('export_limit','calendar')) Api\Hooks::read(true);
169
+		if (!Api\Hooks::exists('export_limit', 'calendar')) Api\Hooks::read(true);
170 170
 	}
171 171
 
172 172
 	/**
@@ -179,21 +179,21 @@  discard block
 block discarded – undo
179 179
 	function check_owners_access($users = null, &$no_access = array())
180 180
 	{
181 181
 		$no_access = $no_access_group = array();
182
-		$owner_array = $users ? $users : explode(',',$this->owner);
183
-		foreach($owner_array as $idx => $owner)
182
+		$owner_array = $users ? $users : explode(',', $this->owner);
183
+		foreach ($owner_array as $idx => $owner)
184 184
 		{
185 185
 			$owner = trim($owner);
186 186
 			if (is_numeric($owner) && $GLOBALS['egw']->accounts->get_type($owner) == 'g')
187 187
 			{
188
-				foreach($GLOBALS['egw']->accounts->members($owner, true) as $member)
188
+				foreach ($GLOBALS['egw']->accounts->members($owner, true) as $member)
189 189
 				{
190
-					if (!$this->bo->check_perms(Acl::READ|calendar_bo::ACL_READ_FOR_PARTICIPANTS|calendar_bo::ACL_FREEBUSY,0,$member))
190
+					if (!$this->bo->check_perms(Acl::READ|calendar_bo::ACL_READ_FOR_PARTICIPANTS|calendar_bo::ACL_FREEBUSY, 0, $member))
191 191
 					{
192 192
 						$no_access_group[$member] = $this->bo->participant_name($member);
193 193
 					}
194 194
 				}
195 195
 			}
196
-			elseif (!$this->bo->check_perms(Acl::READ|calendar_bo::ACL_READ_FOR_PARTICIPANTS|calendar_bo::ACL_FREEBUSY,0,$owner))
196
+			elseif (!$this->bo->check_perms(Acl::READ|calendar_bo::ACL_READ_FOR_PARTICIPANTS|calendar_bo::ACL_FREEBUSY, 0, $owner))
197 197
 			{
198 198
 				$no_access[$owner] = $this->bo->participant_name($owner);
199 199
 				unset($owner_array[$idx]);
@@ -201,14 +201,14 @@  discard block
 block discarded – undo
201 201
 		}
202 202
 		if (count($no_access))
203 203
 		{
204
-			$message = lang('Access denied to the calendar of %1 !!!',implode(', ',$no_access));
205
-			Framework::message($message,'error');
206
-			$this->owner = implode(',',$owner_array);
204
+			$message = lang('Access denied to the calendar of %1 !!!', implode(', ', $no_access));
205
+			Framework::message($message, 'error');
206
+			$this->owner = implode(',', $owner_array);
207 207
 			return $message;
208 208
 		}
209 209
 		if (count($no_access_group))
210 210
 		{
211
-			$this->bo->warnings['groupmembers'] = lang('Groupmember(s) %1 not included, because you have no access.',implode(', ',$no_access_group));
211
+			$this->bo->warnings['groupmembers'] = lang('Groupmember(s) %1 not included, because you have no access.', implode(', ', $no_access_group));
212 212
 		}
213 213
 		return false;
214 214
 	}
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 	 *	- view: the actual view, where dialogs should return to or which they refresh
228 228
 	 * @param array $set_states array to manualy set / change one of the states, default NULL = use $_REQUEST
229 229
 	 */
230
-	function manage_states($set_states=NULL)
230
+	function manage_states($set_states = NULL)
231 231
 	{
232 232
 		// retrieve saved states from prefs
233 233
 		$states = is_array($this->bo->cal_prefs['saved_states']) ?
@@ -247,12 +247,12 @@  discard block
 block discarded – undo
247 247
 				}
248 248
 				else
249 249
 				{
250
-					parse_str(substr($json_data['request']['parameters'][0], 10), $set_states);	// cut off "/index.php?"
250
+					parse_str(substr($json_data['request']['parameters'][0], 10), $set_states); // cut off "/index.php?"
251 251
 				}
252 252
 			}
253 253
 			else
254 254
 			{
255
-				$set_states = substr($_GET['menuaction'],0,9) == 'calendar.' ? $_REQUEST : array();
255
+				$set_states = substr($_GET['menuaction'], 0, 9) == 'calendar.' ? $_REQUEST : array();
256 256
 			}
257 257
 		}
258 258
 		if (!$states['date'] && $states['year'] && $states['month'] && $states['day'])
@@ -260,16 +260,16 @@  discard block
 block discarded – undo
260 260
 			$states['date'] = $this->bo->date2string($states);
261 261
 		}
262 262
 
263
-		foreach(array(
263
+		foreach (array(
264 264
 			'date'       => $this->bo->date2string($this->bo->now_su),
265 265
 			'cat_id'     => 0,
266 266
 			'status_filter'     => 'default',
267 267
 			'owner'      => $this->user,
268 268
 			'save_owner' => 0,
269 269
 			'sortby'     => 'category',
270
-			'planner_view'=> 'month',	// full month
271
-			'view'       => ($this->bo->cal_prefs['defaultcalendar']?$this->bo->cal_prefs['defaultcalendar']:'day'), // use pref, if exists else use the dayview
272
-			'listview_days'=> '',	// no range
270
+			'planner_view'=> 'month', // full month
271
+			'view'       => ($this->bo->cal_prefs['defaultcalendar'] ? $this->bo->cal_prefs['defaultcalendar'] : 'day'), // use pref, if exists else use the dayview
272
+			'listview_days'=> '', // no range
273 273
 			'test'       => 'false',
274 274
 		) as $state => $default)
275 275
 		{
@@ -278,42 +278,42 @@  discard block
 block discarded – undo
278 278
 				if ($state == 'owner')
279 279
 				{
280 280
 					// only change the owners of the same resource-type as given in set_state[owner]
281
-					$set_owners = is_array($set_states['owner']) ? $set_states['owner'] : explode(',',$set_states['owner']);
281
+					$set_owners = is_array($set_states['owner']) ? $set_states['owner'] : explode(',', $set_states['owner']);
282 282
 					if ((string)$set_owners[0] === '0')	// set exactly the specified owners (without the 0)
283 283
 					{
284 284
 						if ($set_states['owner'] === '0,r0')	// small fix for resources
285 285
 						{
286
-							$set_states['owner'] = $default;	// --> set default, instead of none
286
+							$set_states['owner'] = $default; // --> set default, instead of none
287 287
 						}
288 288
 						else
289 289
 						{
290
-							$set_states['owner'] = substr($set_states['owner'],2);
290
+							$set_states['owner'] = substr($set_states['owner'], 2);
291 291
 						}
292 292
 					}
293 293
 					else	// change only the owners of the given type
294 294
 					{
295 295
 						$res_type = is_numeric($set_owners[0]) ? false : $set_owners[0][0];
296 296
 						$owners = $states['owner'] ? $states['owner'] : $default;
297
-						if(!is_array($owners))
297
+						if (!is_array($owners))
298 298
 						{
299
-							$owners = explode(',',$owners);
299
+							$owners = explode(',', $owners);
300 300
 						}
301
-						foreach($owners as $key => $owner)
301
+						foreach ($owners as $key => $owner)
302 302
 						{
303 303
 							if (!$res_type && is_numeric($owner) || $res_type && $owner[0] == $res_type)
304 304
 							{
305 305
 								unset($owners[$key]);
306 306
 							}
307 307
 						}
308
-						if (!$res_type || !in_array($res_type.'0',$set_owners))
308
+						if (!$res_type || !in_array($res_type.'0', $set_owners))
309 309
 						{
310
-							$owners = array_merge($owners,$set_owners);
310
+							$owners = array_merge($owners, $set_owners);
311 311
 						}
312
-						$set_states['owner'] = implode(',',$owners);
312
+						$set_states['owner'] = implode(',', $owners);
313 313
 					}
314 314
 				}
315 315
 				// for the uiforms class (eg. edit), dont store the (new) owner, as it might change the view
316
-				if (substr($_GET['menuaction'],0,25) == 'calendar.calendar_uiforms')
316
+				if (substr($_GET['menuaction'], 0, 25) == 'calendar.calendar_uiforms')
317 317
 				{
318 318
 					$this->owner = $set_states[$state];
319 319
 					continue;
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
 			if ($state == 'date')
328 328
 			{
329 329
 				$date_arr = $this->bo->date2array($states['date']);
330
-				foreach(array('year','month','day') as $name)
330
+				foreach (array('year', 'month', 'day') as $name)
331 331
 				{
332 332
 					$this->$name = $states[$name] = $date_arr[$name];
333 333
 				}
@@ -335,16 +335,16 @@  discard block
 block discarded – undo
335 335
 			$this->$state = $states[$state];
336 336
 		}
337 337
 		// remove a given calendar from the view
338
-		if (isset($_GET['close']) && ($k = array_search($_GET['close'], $owners=explode(',',$this->owner))) !== false)
338
+		if (isset($_GET['close']) && ($k = array_search($_GET['close'], $owners = explode(',', $this->owner))) !== false)
339 339
 		{
340 340
 			unset($owners[$k]);
341
-			$this->owner = $states['owner'] = implode(',',$owners);
341
+			$this->owner = $states['owner'] = implode(',', $owners);
342 342
 		}
343
-		if(is_array($this->owner))
343
+		if (is_array($this->owner))
344 344
 		{
345
-			$this->owner = implode(',',$this->owner);
345
+			$this->owner = implode(',', $this->owner);
346 346
 		}
347
-		if (substr($this->view,0,8) == 'planner_')
347
+		if (substr($this->view, 0, 8) == 'planner_')
348 348
 		{
349 349
 			$states['sortby'] = $this->sortby = $this->view == 'planner_cat' ? 'category' : 'user';
350 350
 			$states['view'] = $this->view = 'planner';
@@ -352,10 +352,10 @@  discard block
 block discarded – undo
352 352
 		// set the actual view as return_to
353 353
 		if (isset($_GET['menuaction']))
354 354
 		{
355
-			list(,$class,$func) = explode('.',$_GET['menuaction']);
355
+			list(,$class, $func) = explode('.', $_GET['menuaction']);
356 356
 			if ($func == 'index')
357 357
 			{
358
-				$func = $this->view; $this->view = 'index';	// switch to the default view
358
+				$func = $this->view; $this->view = 'index'; // switch to the default view
359 359
 			}
360 360
 		}
361 361
 		else	// eg. calendar/index.php
@@ -369,18 +369,18 @@  discard block
 block discarded – undo
369 369
 		}
370 370
 		$this->view_menuaction = $this->view == 'listview' ? 'calendar.calendar_uilist.listview' : 'calendar.calendar_uiviews.index';
371 371
 
372
-		if ($this->debug > 0 || $this->debug == 'manage_states') $this->bo->debug_message('uical::manage_states(%1), states now %3',True,$set_states,$states);
372
+		if ($this->debug > 0 || $this->debug == 'manage_states') $this->bo->debug_message('uical::manage_states(%1), states now %3', True, $set_states, $states);
373 373
 		// save the states in the session only when we are in calendar
374
-		if ($GLOBALS['egw_info']['flags']['currentapp']=='calendar')
374
+		if ($GLOBALS['egw_info']['flags']['currentapp'] == 'calendar')
375 375
 		{
376 376
 			// save defined states into the user-prefs
377
-			if(!empty($states) && is_array($states))
377
+			if (!empty($states) && is_array($states))
378 378
 			{
379
-				$saved_states = array_intersect_key($states,array_flip($this->states_to_save));
379
+				$saved_states = array_intersect_key($states, array_flip($this->states_to_save));
380 380
 				if ($saved_states != $this->cal_prefs['saved_states'])
381 381
 				{
382
-					$GLOBALS['egw']->preferences->add('calendar','saved_states',$saved_states);
383
-					$GLOBALS['egw']->preferences->save_repository(false,'user',true);
382
+					$GLOBALS['egw']->preferences->add('calendar', 'saved_states', $saved_states);
383
+					$GLOBALS['egw']->preferences->save_repository(false, 'user', true);
384 384
 				}
385 385
 			}
386 386
 		}
@@ -394,35 +394,35 @@  discard block
 block discarded – undo
394 394
 	*/
395 395
 	function event_icons($event)
396 396
 	{
397
-		$is_private = !$event['public'] && !$this->bo->check_perms(Acl::READ,$event);
397
+		$is_private = !$event['public'] && !$this->bo->check_perms(Acl::READ, $event);
398 398
 
399 399
 		$icons = array();
400 400
 		if (!$is_private)
401 401
 		{
402
-			if($event['priority'] == 3)
402
+			if ($event['priority'] == 3)
403 403
 			{
404
-				$icons[] = Api\Html::image('calendar','high',lang('high priority'));
404
+				$icons[] = Api\Html::image('calendar', 'high', lang('high priority'));
405 405
 			}
406
-			if($event['recur_type'] != MCAL_RECUR_NONE)
406
+			if ($event['recur_type'] != MCAL_RECUR_NONE)
407 407
 			{
408
-				$icons[] = Api\Html::image('calendar','recur',lang('recurring event'));
408
+				$icons[] = Api\Html::image('calendar', 'recur', lang('recurring event'));
409 409
 			}
410 410
 			// icons for single user, multiple users or group(s) and resources
411
-			foreach(array_keys($event['participants']) as  $uid)
411
+			foreach (array_keys($event['participants']) as  $uid)
412 412
 			{
413
-				if(is_numeric($uid) || !isset($this->bo->resources[$uid[0]]['icon']))
413
+				if (is_numeric($uid) || !isset($this->bo->resources[$uid[0]]['icon']))
414 414
 				{
415 415
 					if (isset($icons['single']) || $GLOBALS['egw']->accounts->get_type($uid) == 'g')
416 416
 					{
417 417
 						unset($icons['single']);
418
-						$icons['multiple'] = Api\Html::image('calendar','users');
418
+						$icons['multiple'] = Api\Html::image('calendar', 'users');
419 419
 					}
420 420
 					elseif (!isset($icons['multiple']))
421 421
 					{
422
-						$icons['single'] = Api\Html::image('calendar','single');
422
+						$icons['single'] = Api\Html::image('calendar', 'single');
423 423
 					}
424 424
 				}
425
-				elseif(!isset($icons[$uid[0]]) && isset($this->bo->resources[$uid[0]]) && isset($this->bo->resources[$uid[0]]['icon']))
425
+				elseif (!isset($icons[$uid[0]]) && isset($this->bo->resources[$uid[0]]) && isset($this->bo->resources[$uid[0]]['icon']))
426 426
 				{
427 427
 				 	$icons[$uid[0]] = Api\Html::image($this->bo->resources[$uid[0]]['app'],
428 428
 				 		($this->bo->resources[$uid[0]]['icon'] ? $this->bo->resources[$uid[0]]['icon'] : 'navbar'),
@@ -431,21 +431,21 @@  discard block
 block discarded – undo
431 431
 				}
432 432
 			}
433 433
 		}
434
-		if($event['non_blocking'])
434
+		if ($event['non_blocking'])
435 435
 		{
436
-			$icons[] = Api\Html::image('calendar','nonblocking',lang('non blocking'));
436
+			$icons[] = Api\Html::image('calendar', 'nonblocking', lang('non blocking'));
437 437
 		}
438
-		if($event['public'] == 0)
438
+		if ($event['public'] == 0)
439 439
 		{
440
-			$icons[] = Api\Html::image('calendar','private',lang('private'));
440
+			$icons[] = Api\Html::image('calendar', 'private', lang('private'));
441 441
 		}
442
-		if(isset($event['alarm']) && count($event['alarm']) >= 1 && !$is_private)
442
+		if (isset($event['alarm']) && count($event['alarm']) >= 1 && !$is_private)
443 443
 		{
444
-			$icons[] = Api\Html::image('calendar','alarm',lang('alarm'));
444
+			$icons[] = Api\Html::image('calendar', 'alarm', lang('alarm'));
445 445
 		}
446
-		if($event['participants'][$this->user][0] == 'U')
446
+		if ($event['participants'][$this->user][0] == 'U')
447 447
 		{
448
-			$icons[] = Api\Html::image('calendar','needs-action',lang('Needs action'));
448
+			$icons[] = Api\Html::image('calendar', 'needs-action', lang('Needs action'));
449 449
 		}
450 450
 		return $icons;
451 451
 	}
@@ -460,17 +460,17 @@  discard block
 block discarded – undo
460 460
 	 * @param array $vars
461 461
 	 * @return string the link incl. content
462 462
 	 */
463
-	function add_link($content,$date=null,$hour=null,$minute=0,array $vars=null)
463
+	function add_link($content, $date = null, $hour = null, $minute = 0, array $vars = null)
464 464
 	{
465 465
 		$vars['menuaction'] = 'calendar.calendar_uiforms.edit';
466
-		$vars['date'] =  $date ? $date : $this->date;
466
+		$vars['date'] = $date ? $date : $this->date;
467 467
 
468 468
 		if (!is_null($hour))
469 469
 		{
470 470
 			$vars['hour'] = $hour;
471 471
 			$vars['minute'] = $minute;
472 472
 		}
473
-		return Api\Html::a_href($content,'',$vars,' data-date="' .$vars['date'].'|'.$vars['hour'].'|'.$vars['minute']
473
+		return Api\Html::a_href($content, '', $vars, ' data-date="'.$vars['date'].'|'.$vars['hour'].'|'.$vars['minute']
474 474
 				. '" title="'.Api\Html::htmlspecialchars(lang('Add')).'"');
475 475
 	}
476 476
 
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
 		// Magic etemplate2 favorites menu (from framework)
483 483
 		display_sidebox('calendar', lang('Favorites'), Framework\Favorites::list_favorites('calendar'));
484 484
 
485
-		$file = array('menuOpened' => true);	// menu open by default
485
+		$file = array('menuOpened' => true); // menu open by default
486 486
 
487 487
 		// Target for etemplate
488 488
 		$file[] = array(
@@ -495,38 +495,38 @@  discard block
 block discarded – undo
495 495
 		// Merge print placeholders (selectbox in etemplate)
496 496
 		if ($GLOBALS['egw_info']['user']['preferences']['calendar']['document_dir'])
497 497
 		{
498
-			$file['Placeholders'] = Egw::link('/index.php','menuaction=calendar.calendar_merge.show_replacements');
498
+			$file['Placeholders'] = Egw::link('/index.php', 'menuaction=calendar.calendar_merge.show_replacements');
499 499
 		}
500 500
 		$appname = 'calendar';
501 501
 		$menu_title = lang('Calendar Menu');
502
-		display_sidebox($appname,$menu_title,$file);
502
+		display_sidebox($appname, $menu_title, $file);
503 503
 
504 504
 		$this->sidebox_etemplate();
505 505
 
506 506
 		// resources menu hooks
507 507
  		foreach ($this->bo->resources as $resource)
508 508
 		{
509
-			if(!is_array($resource['cal_sidebox'])) continue;
509
+			if (!is_array($resource['cal_sidebox'])) continue;
510 510
 			$menu_title = $resource['cal_sidebox']['menu_title'] ? $resource['cal_sidebox']['menu_title'] : lang($resource['app']);
511
-			$file = ExecMethod($resource['cal_sidebox']['file'],array(
511
+			$file = ExecMethod($resource['cal_sidebox']['file'], array(
512 512
 				'menuaction' => $this->view_menuaction,
513 513
 				'owner' => $this->owner,
514 514
 			));
515
-			display_sidebox($appname,$menu_title,$file);
515
+			display_sidebox($appname, $menu_title, $file);
516 516
 		}
517 517
 
518 518
 		if ($GLOBALS['egw_info']['user']['apps']['admin'])
519 519
 		{
520 520
 			$file = Array(
521
-				'Site configuration'=>Egw::link('/index.php','menuaction=admin.admin_config.index&appname=calendar&ajax=true'),
522
-				'Custom Fields'=>Egw::link('/index.php','menuaction=admin.admin_customfields.index&appname=calendar&ajax=true'),
523
-				'Global Categories' =>Egw::link('/index.php','menuaction=admin.admin_categories.index&appname=calendar&ajax=true'),
521
+				'Site configuration'=>Egw::link('/index.php', 'menuaction=admin.admin_config.index&appname=calendar&ajax=true'),
522
+				'Custom Fields'=>Egw::link('/index.php', 'menuaction=admin.admin_customfields.index&appname=calendar&ajax=true'),
523
+				'Global Categories' =>Egw::link('/index.php', 'menuaction=admin.admin_categories.index&appname=calendar&ajax=true'),
524 524
 			);
525
-			$GLOBALS['egw']->framework->sidebox($appname,lang('Admin'),$file,'admin');
525
+			$GLOBALS['egw']->framework->sidebox($appname, lang('Admin'), $file, 'admin');
526 526
 		}
527 527
 		display_sidebox('calendar', lang('Utilities'), array('Category report' => "javascript:egw_openWindowCentered2('".
528
-					Egw::link('/index.php',array('menuaction'=>'calendar.calendar_category_report.index','ajax'=>true),false).
529
-					"','_blank',870,500,'yes')" ));
528
+					Egw::link('/index.php', array('menuaction'=>'calendar.calendar_category_report.index', 'ajax'=>true), false).
529
+					"','_blank',870,500,'yes')"));
530 530
 	}
531 531
 
532 532
 	/**
@@ -534,15 +534,15 @@  discard block
 block discarded – undo
534 534
 	 */
535 535
 	function sidebox_etemplate($content = array())
536 536
 	{
537
-		if($content['merge'])
537
+		if ($content['merge'])
538 538
 		{
539 539
 			// View from sidebox is JSON encoded
540
-			$this->manage_states(array_merge($content,json_decode($content['view'],true)));
541
-			if($content['first'])
540
+			$this->manage_states(array_merge($content, json_decode($content['view'], true)));
541
+			if ($content['first'])
542 542
 			{
543
-				$this->first = Api\DateTime::to($content['first'],'ts');
543
+				$this->first = Api\DateTime::to($content['first'], 'ts');
544 544
 			}
545
-			if($content['last'])
545
+			if ($content['last'])
546 546
 			{
547 547
 				$this->last = new Api\DateTime($content['last']);
548 548
 				$this->last->setTime(23, 59, 59);
@@ -559,27 +559,27 @@  discard block
 block discarded – undo
559 559
 		if (!is_array($cont)) $cont = array();
560 560
 		$cont['view'] = $this->view ? $this->view : 'week';
561 561
 		$cont['date'] = $this->date ? $this->date : new Api\DateTime();
562
-		$cont['owner'] = $this->owner ? (is_array($this->owner) ? $this->owner : explode(',',$this->owner) ) : $cont['owner'];
562
+		$cont['owner'] = $this->owner ? (is_array($this->owner) ? $this->owner : explode(',', $this->owner)) : $cont['owner'];
563 563
 
564
-		$cont['year'] = (int)Api\DateTime::to($cont['date'],'Y');
564
+		$cont['year'] = (int)Api\DateTime::to($cont['date'], 'Y');
565 565
 		$cont['holidays'] = $this->bo->read_holidays($cont['year']);
566 566
 
567 567
 		$readonlys = array();
568 568
 		$sel_options['status_filter'] = array(
569
-			array('value' => 'default',     'label' => lang('Not rejected'), 'title' => lang('Show all status, but rejected')),
570
-			array('value' => 'accepted',    'label' => lang('Accepted'), 'title' => lang('Show only accepted events')),
571
-			array('value' => 'unknown',     'label' => lang('Invitations'), 'title' => lang('Show only invitations, not yet accepted or rejected')),
572
-			array('value' => 'tentative',   'label' => lang('Tentative'), 'title' => lang('Show only tentative accepted events')),
573
-			array('value' => 'delegated',   'label' => lang('Delegated'), 'title' => lang('Show only delegated events')),
574
-			array('value' => 'rejected',    'label' => lang('Rejected'),'title' => lang('Show only rejected events')),
575
-			array('value' => 'owner',       'label' => lang('Owner too'),'title' => lang('Show also events just owned by selected user')),
576
-			array('value' => 'all',         'label' => lang('All incl. rejected'),'title' => lang('Show all status incl. rejected events')),
577
-			array('value' => 'hideprivate', 'label' => lang('Hide private infos'),'title' => lang('Show all events, as if they were private')),
578
-			array('value' => 'showonlypublic',  'label' => lang('Hide private events'),'title' => lang('Show only events flagged as public, (not checked as private)')),
579
-			array('value' => 'no-enum-groups', 'label' => lang('only group-events'),'title' => lang('Do not include events of group members')),
580
-			array('value' => 'not-unknown', 'label' => lang('No meeting requests'),'title' => lang('Show all status, but unknown')),
569
+			array('value' => 'default', 'label' => lang('Not rejected'), 'title' => lang('Show all status, but rejected')),
570
+			array('value' => 'accepted', 'label' => lang('Accepted'), 'title' => lang('Show only accepted events')),
571
+			array('value' => 'unknown', 'label' => lang('Invitations'), 'title' => lang('Show only invitations, not yet accepted or rejected')),
572
+			array('value' => 'tentative', 'label' => lang('Tentative'), 'title' => lang('Show only tentative accepted events')),
573
+			array('value' => 'delegated', 'label' => lang('Delegated'), 'title' => lang('Show only delegated events')),
574
+			array('value' => 'rejected', 'label' => lang('Rejected'), 'title' => lang('Show only rejected events')),
575
+			array('value' => 'owner', 'label' => lang('Owner too'), 'title' => lang('Show also events just owned by selected user')),
576
+			array('value' => 'all', 'label' => lang('All incl. rejected'), 'title' => lang('Show all status incl. rejected events')),
577
+			array('value' => 'hideprivate', 'label' => lang('Hide private infos'), 'title' => lang('Show all events, as if they were private')),
578
+			array('value' => 'showonlypublic', 'label' => lang('Hide private events'), 'title' => lang('Show only events flagged as public, (not checked as private)')),
579
+			array('value' => 'no-enum-groups', 'label' => lang('only group-events'), 'title' => lang('Do not include events of group members')),
580
+			array('value' => 'not-unknown', 'label' => lang('No meeting requests'), 'title' => lang('Show all status, but unknown')),
581 581
 		);
582
-		if($GLOBALS['egw_info']['server']['calendar_delete_history'])
582
+		if ($GLOBALS['egw_info']['server']['calendar_delete_history'])
583 583
 		{
584 584
 			$sel_options['status_filter'][] = array('value' => 'deleted', 'label' => lang('Deleted'), 'title' => lang('Show events that have been deleted'));
585 585
 		}
@@ -587,7 +587,7 @@  discard block
 block discarded – undo
587 587
 		// Merge print
588 588
 		if ($GLOBALS['egw_info']['user']['preferences']['calendar']['document_dir'])
589 589
 		{
590
-			$sel_options['merge'] = calendar_merge::get_documents($GLOBALS['egw_info']['user']['preferences']['calendar']['document_dir'], '', null,'calendar');
590
+			$sel_options['merge'] = calendar_merge::get_documents($GLOBALS['egw_info']['user']['preferences']['calendar']['document_dir'], '', null, 'calendar');
591 591
 		}
592 592
 		else
593 593
 		{
@@ -616,10 +616,10 @@  discard block
 block discarded – undo
616 616
 	 */
617 617
 	public function update_client($event_id, Api\DateTime $recurrence_date = null)
618 618
 	{
619
-		if(!$event_id) return false;
620
-		if(is_string($event_id) && strpos($event_id,':') !== FALSE)
619
+		if (!$event_id) return false;
620
+		if (is_string($event_id) && strpos($event_id, ':') !== FALSE)
621 621
 		{
622
-			list($event_id, $date) = explode(':',$event_id);
622
+			list($event_id, $date) = explode(':', $event_id);
623 623
 			$recurrence_date = new Api\DateTime($date);
624 624
 		}
625 625
 
@@ -632,7 +632,7 @@  discard block
 block discarded – undo
632 632
 		// Check filters to see if they still match, may have to remove
633 633
 		// the event because it should no longer be displayed
634 634
 		$filter_match = true;
635
-		if($event && ($this->cal_prefs['saved_states']['status_filter'] != 'all' ||
635
+		if ($event && ($this->cal_prefs['saved_states']['status_filter'] != 'all' ||
636 636
 			$this->cal_prefs['saved_states']['cat_id']))
637 637
 		{
638 638
 			$filter_check = array(
@@ -645,20 +645,20 @@  discard block
 block discarded – undo
645 645
 			$filter_match = count($this->bo->search($filter_check, $this->bo->so->cal_table.".cal_id = {$event['id']}")) > 0;
646 646
 		}
647 647
 
648
-		if(!$event || !$filter_match)
648
+		if (!$event || !$filter_match)
649 649
 		{
650 650
 			// Sending null will trigger a removal
651 651
 			$response->generic('data', array('uid' => 'calendar::'.$event_id, 'data' => null));
652 652
 			return false;
653 653
 		}
654 654
 
655
-		if(!$event['recur_type'] || $recurrence_date)
655
+		if (!$event['recur_type'] || $recurrence_date)
656 656
 		{
657 657
 			$this->to_client($event);
658 658
 			$response->generic('data', array('uid' => 'calendar::'.$event['row_id'], 'data' => $event));
659 659
 		}
660 660
 		// If it's recurring, try to send the next month or so
661
-		else if($event['recur_type'] )
661
+		else if ($event['recur_type'])
662 662
 		{
663 663
 			$this_month = new Api\DateTime('next month');
664 664
 			$rrule = calendar_rrule::event2rrule($event, true);
@@ -671,7 +671,7 @@  discard block
 block discarded – undo
671 671
 				$response->generic('data', array('uid' => 'calendar::'.$converted['row_id'], 'data' => $converted));
672 672
 				$rrule->next();
673 673
 			}
674
-			while ($rrule->valid() && $occurrence <= $this_month );
674
+			while ($rrule->valid() && $occurrence <= $this_month);
675 675
 		}
676 676
 		return true;
677 677
 	}
@@ -687,15 +687,15 @@  discard block
 block discarded – undo
687 687
 	 */
688 688
 	public function to_client(&$event)
689 689
 	{
690
-		if(!$event || !is_array($event)) return false;
690
+		if (!$event || !is_array($event)) return false;
691 691
 
692
-		if (!$this->bo->check_perms(Acl::EDIT,$event))
692
+		if (!$this->bo->check_perms(Acl::EDIT, $event))
693 693
 		{
694 694
 			$event['class'] .= 'rowNoEdit ';
695 695
 		}
696 696
 
697 697
 		// Delete disabled for other applications
698
-		if (!$this->bo->check_perms(Acl::DELETE,$event) || !is_numeric($event['id']))
698
+		if (!$this->bo->check_perms(Acl::DELETE, $event) || !is_numeric($event['id']))
699 699
 		{
700 700
 			$event['class'] .= 'rowNoDelete ';
701 701
 		}
@@ -708,32 +708,32 @@  discard block
 block discarded – undo
708 708
 
709 709
 		$event['recure'] = $this->bo->recure2string($event);
710 710
 
711
-		if (empty($event['description'])) $event['description'] = ' ';	// no description screws the titles horz. alignment
712
-		if (empty($event['location'])) $event['location'] = ' ';	// no location screws the owner horz. alignment
711
+		if (empty($event['description'])) $event['description'] = ' '; // no description screws the titles horz. alignment
712
+		if (empty($event['location'])) $event['location'] = ' '; // no location screws the owner horz. alignment
713 713
 
714 714
 		// respect category permissions
715
-		if(!empty($event['category']))
715
+		if (!empty($event['category']))
716 716
 		{
717 717
 			$event['category'] = $this->categories->check_list(Acl::READ, $event['category']);
718 718
 		}
719 719
 		$event['non_blocking'] = (bool)$event['non_blocking'];
720 720
 
721 721
 		$matches = null;
722
-		if(!(int)$event['id'] && preg_match('/^([a-z_-]+)([0-9]+)$/i',$event['id'],$matches))
722
+		if (!(int)$event['id'] && preg_match('/^([a-z_-]+)([0-9]+)$/i', $event['id'], $matches))
723 723
 		{
724 724
 			$app = $matches[1];
725 725
 			$app_id = $matches[2];
726 726
 			$icons = array();
727
-			if(!($is_private = calendar_bo::integration_get_private($app,$app_id,$event)))
727
+			if (!($is_private = calendar_bo::integration_get_private($app, $app_id, $event)))
728 728
 			{
729
-				$icons = calendar_uiviews::integration_get_icons($app,$app_id,$event);
729
+				$icons = calendar_uiviews::integration_get_icons($app, $app_id, $event);
730 730
 			}
731 731
 			$event['app'] = $app;
732 732
 			$event['app_id'] = $app_id;
733 733
 		}
734 734
 		else
735 735
 		{
736
-			$is_private = !$this->bo->check_perms(Acl::READ,$event);
736
+			$is_private = !$this->bo->check_perms(Acl::READ, $event);
737 737
 		}
738 738
 		if ($is_private)
739 739
 		{
@@ -741,27 +741,27 @@  discard block
 block discarded – undo
741 741
 			$event['class'] .= 'rowNoView ';
742 742
 		}
743 743
 
744
-		if(!$event['app'])
744
+		if (!$event['app'])
745 745
 		{
746 746
 			$event['app'] = 'calendar';
747 747
 		}
748
-		if(!$event['app_id'])
748
+		if (!$event['app_id'])
749 749
 		{
750 750
 			$event['app_id'] = $event['id'];
751 751
 		}
752 752
 
753 753
 		if ($event['recur_type'] != MCAL_RECUR_NONE)
754 754
 		{
755
-			$event['app_id'] .= ':'.Api\DateTime::to($event['recur_date'] ? $event['recur_date'] : $event['start'],'ts');
755
+			$event['app_id'] .= ':'.Api\DateTime::to($event['recur_date'] ? $event['recur_date'] : $event['start'], 'ts');
756 756
 		}
757 757
 		// set id for grid
758
-		$event['row_id'] = $event['id'].($event['recur_type'] ? ':'.Api\DateTime::to($event['recur_date'] ? $event['recur_date'] : $event['start'],'ts') : '');
758
+		$event['row_id'] = $event['id'].($event['recur_type'] ? ':'.Api\DateTime::to($event['recur_date'] ? $event['recur_date'] : $event['start'], 'ts') : '');
759 759
 
760 760
 		// Set up participant section of tooltip
761
-		$participants = $this->bo->participants($event,false);
762
-		$event['parts'] = implode("\n",$participants);
761
+		$participants = $this->bo->participants($event, false);
762
+		$event['parts'] = implode("\n", $participants);
763 763
 		$event['participant_types'] = array();
764
-		foreach($participants as $uid => $text)
764
+		foreach ($participants as $uid => $text)
765 765
 		{
766 766
 			$user_type = $user_id = null;
767 767
 			calendar_so::split_user($uid, $user_type, $user_id);
@@ -771,9 +771,9 @@  discard block
 block discarded – undo
771 771
 		$event['date'] = $this->bo->date2string($event['start']);
772 772
 
773 773
 		// Change dates
774
-		foreach(calendar_egw_record::$types['date-time'] as $field)
774
+		foreach (calendar_egw_record::$types['date-time'] as $field)
775 775
 		{
776
-			if(is_int($event[$field]))
776
+			if (is_int($event[$field]))
777 777
 			{
778 778
 				$event[$field] = Api\DateTime::to($event[$field], Api\DateTime::ET2);
779 779
 			}
@@ -791,13 +791,13 @@  discard block
 block discarded – undo
791 791
 	public function merge($timespan = array())
792 792
 	{
793 793
 		// Merge print
794
-		if($_GET['merge'])
794
+		if ($_GET['merge'])
795 795
 		{
796
-			if(!$timespan)
796
+			if (!$timespan)
797 797
 			{
798 798
 				// Try to make time span into appropriate ranges to match
799
-				if(stripos($_GET['merge'],'month') !== false || stripos($_GET['merge'],lang('month')) !== false) $template = 'month';
800
-				if(stripos($_GET['merge'],'week') !== false || stripos($_GET['merge'],lang('week')) !== false) $template = 'week';
799
+				if (stripos($_GET['merge'], 'month') !== false || stripos($_GET['merge'], lang('month')) !== false) $template = 'month';
800
+				if (stripos($_GET['merge'], 'week') !== false || stripos($_GET['merge'], lang('week')) !== false) $template = 'week';
801 801
 				//error_log("Detected template $template");
802 802
 				switch ($template)
803 803
 				{
@@ -805,8 +805,8 @@  discard block
 block discarded – undo
805 805
 						// Trim to _only_ the month, do not pad to week start / end
806 806
 						$time = new Api\DateTime($this->date);
807 807
 						$timespan = array(array(
808
-							'start' => Api\DateTime::to($time->format('Y-m-01 00:00:00'),'ts'),
809
-							'end'	=> Api\DateTime::to($time->format('Y-m-t 23:59:59'),'ts')
808
+							'start' => Api\DateTime::to($time->format('Y-m-01 00:00:00'), 'ts'),
809
+							'end'	=> Api\DateTime::to($time->format('Y-m-t 23:59:59'), 'ts')
810 810
 						));
811 811
 						break;
812 812
 					case 'week':
@@ -814,7 +814,7 @@  discard block
 block discarded – undo
814 814
 						$start = new Api\DateTime($this->first);
815 815
 						$t = clone $start;
816 816
 						$t->modify('+1 week')->modify('-1 second');
817
-						if($t->format('ts') < Api\DateTime::to($this->last,'ts'))
817
+						if ($t->format('ts') < Api\DateTime::to($this->last, 'ts'))
818 818
 						{
819 819
 							do
820 820
 							{
@@ -824,7 +824,7 @@  discard block
 block discarded – undo
824 824
 								);
825 825
 								$start->modify('+1 week');
826 826
 								$t->modify('+1 week');
827
-							} while( $start->format('ts') < $this->last);
827
+							} while ($start->format('ts') < $this->last);
828 828
 							break;
829 829
 						}
830 830
 						// Fall through
@@ -842,7 +842,7 @@  discard block
 block discarded – undo
842 842
 			Framework::refresh_opener($error, 'calendar');
843 843
 		}
844 844
 		unset($_GET['merge']);
845
-		if($error)
845
+		if ($error)
846 846
 		{
847 847
 			// This doesn't give message either, but at least it doesn't give a blank screen
848 848
 			Framework::redirect_link('/index.php', array(
Please login to merge, or discard this patch.
Braces   +49 added lines, -13 removed lines patch added patch discarded remove patch
@@ -166,7 +166,10 @@  discard block
 block discarded – undo
166 166
 		unset($GLOBALS['egw_info']['user']['preferences']['common']['auto_hide_sidebox']);
167 167
 
168 168
 		// make sure the hook for export_limit is registered
169
-		if (!Api\Hooks::exists('export_limit','calendar')) Api\Hooks::read(true);
169
+		if (!Api\Hooks::exists('export_limit','calendar'))
170
+		{
171
+			Api\Hooks::read(true);
172
+		}
170 173
 	}
171 174
 
172 175
 	/**
@@ -279,11 +282,15 @@  discard block
 block discarded – undo
279 282
 				{
280 283
 					// only change the owners of the same resource-type as given in set_state[owner]
281 284
 					$set_owners = is_array($set_states['owner']) ? $set_states['owner'] : explode(',',$set_states['owner']);
282
-					if ((string)$set_owners[0] === '0')	// set exactly the specified owners (without the 0)
285
+					if ((string)$set_owners[0] === '0')
286
+					{
287
+						// set exactly the specified owners (without the 0)
283 288
 					{
284 289
 						if ($set_states['owner'] === '0,r0')	// small fix for resources
285 290
 						{
286
-							$set_states['owner'] = $default;	// --> set default, instead of none
291
+							$set_states['owner'] = $default;
292
+					}
293
+					// --> set default, instead of none
287 294
 						}
288 295
 						else
289 296
 						{
@@ -369,7 +376,10 @@  discard block
 block discarded – undo
369 376
 		}
370 377
 		$this->view_menuaction = $this->view == 'listview' ? 'calendar.calendar_uilist.listview' : 'calendar.calendar_uiviews.index';
371 378
 
372
-		if ($this->debug > 0 || $this->debug == 'manage_states') $this->bo->debug_message('uical::manage_states(%1), states now %3',True,$set_states,$states);
379
+		if ($this->debug > 0 || $this->debug == 'manage_states')
380
+		{
381
+			$this->bo->debug_message('uical::manage_states(%1), states now %3',True,$set_states,$states);
382
+		}
373 383
 		// save the states in the session only when we are in calendar
374 384
 		if ($GLOBALS['egw_info']['flags']['currentapp']=='calendar')
375 385
 		{
@@ -505,8 +515,11 @@  discard block
 block discarded – undo
505 515
 
506 516
 		// resources menu hooks
507 517
  		foreach ($this->bo->resources as $resource)
508
-		{
509
-			if(!is_array($resource['cal_sidebox'])) continue;
518
+ 		{
519
+			if(!is_array($resource['cal_sidebox']))
520
+			{
521
+				continue;
522
+			}
510 523
 			$menu_title = $resource['cal_sidebox']['menu_title'] ? $resource['cal_sidebox']['menu_title'] : lang($resource['app']);
511 524
 			$file = ExecMethod($resource['cal_sidebox']['file'],array(
512 525
 				'menuaction' => $this->view_menuaction,
@@ -556,7 +569,10 @@  discard block
 block discarded – undo
556 569
 		$sidebox = new Etemplate('calendar.sidebox');
557 570
 
558 571
 		$cont = $this->cal_prefs['saved_states'];
559
-		if (!is_array($cont)) $cont = array();
572
+		if (!is_array($cont))
573
+		{
574
+			$cont = array();
575
+		}
560 576
 		$cont['view'] = $this->view ? $this->view : 'week';
561 577
 		$cont['date'] = $this->date ? $this->date : new Api\DateTime();
562 578
 		$cont['owner'] = $this->owner ? (is_array($this->owner) ? $this->owner : explode(',',$this->owner) ) : $cont['owner'];
@@ -616,7 +632,10 @@  discard block
 block discarded – undo
616 632
 	 */
617 633
 	public function update_client($event_id, Api\DateTime $recurrence_date = null)
618 634
 	{
619
-		if(!$event_id) return false;
635
+		if(!$event_id)
636
+		{
637
+			return false;
638
+		}
620 639
 		if(is_string($event_id) && strpos($event_id,':') !== FALSE)
621 640
 		{
622 641
 			list($event_id, $date) = explode(':',$event_id);
@@ -687,7 +706,10 @@  discard block
 block discarded – undo
687 706
 	 */
688 707
 	public function to_client(&$event)
689 708
 	{
690
-		if(!$event || !is_array($event)) return false;
709
+		if(!$event || !is_array($event))
710
+		{
711
+			return false;
712
+		}
691 713
 
692 714
 		if (!$this->bo->check_perms(Acl::EDIT,$event))
693 715
 		{
@@ -708,8 +730,16 @@  discard block
 block discarded – undo
708 730
 
709 731
 		$event['recure'] = $this->bo->recure2string($event);
710 732
 
711
-		if (empty($event['description'])) $event['description'] = ' ';	// no description screws the titles horz. alignment
712
-		if (empty($event['location'])) $event['location'] = ' ';	// no location screws the owner horz. alignment
733
+		if (empty($event['description']))
734
+		{
735
+			$event['description'] = ' ';
736
+		}
737
+		// no description screws the titles horz. alignment
738
+		if (empty($event['location']))
739
+		{
740
+			$event['location'] = ' ';
741
+		}
742
+		// no location screws the owner horz. alignment
713 743
 
714 744
 		// respect category permissions
715 745
 		if(!empty($event['category']))
@@ -796,8 +826,14 @@  discard block
 block discarded – undo
796 826
 			if(!$timespan)
797 827
 			{
798 828
 				// Try to make time span into appropriate ranges to match
799
-				if(stripos($_GET['merge'],'month') !== false || stripos($_GET['merge'],lang('month')) !== false) $template = 'month';
800
-				if(stripos($_GET['merge'],'week') !== false || stripos($_GET['merge'],lang('week')) !== false) $template = 'week';
829
+				if(stripos($_GET['merge'],'month') !== false || stripos($_GET['merge'],lang('month')) !== false)
830
+				{
831
+					$template = 'month';
832
+				}
833
+				if(stripos($_GET['merge'],'week') !== false || stripos($_GET['merge'],lang('week')) !== false)
834
+				{
835
+					$template = 'week';
836
+				}
801 837
 				//error_log("Detected template $template");
802 838
 				switch ($template)
803 839
 				{
Please login to merge, or discard this patch.
calendar/inc/class.calendar_bo.inc.php 5 patches
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -1490,13 +1490,13 @@  discard block
 block discarded – undo
1490 1490
 	}
1491 1491
 
1492 1492
 	/**
1493
-	* Converts a participant into a (readable) user- or resource-name
1494
-	*
1495
-	* @param string|int $id id of user or resource
1496
-	* @param string|boolean $use_type =false type-letter or false
1497
-	* @param boolean $append_email =false append email (Name <email>)
1498
-	* @return string with name
1499
-	*/
1493
+	 * Converts a participant into a (readable) user- or resource-name
1494
+	 *
1495
+	 * @param string|int $id id of user or resource
1496
+	 * @param string|boolean $use_type =false type-letter or false
1497
+	 * @param boolean $append_email =false append email (Name <email>)
1498
+	 * @return string with name
1499
+	 */
1500 1500
 	function participant_name($id,$use_type=false, $append_email=false)
1501 1501
 	{
1502 1502
 		static $id2lid = array();
@@ -1525,13 +1525,13 @@  discard block
 block discarded – undo
1525 1525
 	}
1526 1526
 
1527 1527
 	/**
1528
-	* Converts participants array of an event into array of (readable) participant-names with status
1529
-	*
1530
-	* @param array $event event-data
1531
-	* @param boolean $long_status =false should the long/verbose status or an icon be use
1532
-	* @param boolean $show_group_invitation =false show group-invitations (status == 'G') or not (default)
1533
-	* @return array with id / names with status pairs
1534
-	*/
1528
+	 * Converts participants array of an event into array of (readable) participant-names with status
1529
+	 *
1530
+	 * @param array $event event-data
1531
+	 * @param boolean $long_status =false should the long/verbose status or an icon be use
1532
+	 * @param boolean $show_group_invitation =false show group-invitations (status == 'G') or not (default)
1533
+	 * @return array with id / names with status pairs
1534
+	 */
1535 1535
 	function participants($event,$long_status=false,$show_group_invitation=false)
1536 1536
 	{
1537 1537
 		//error_log(__METHOD__.__LINE__.array2string($event['participants']));
@@ -1601,12 +1601,12 @@  discard block
 block discarded – undo
1601 1601
 	}
1602 1602
 
1603 1603
 	/**
1604
-	* Converts category string of an event into array of (readable) category-names
1605
-	*
1606
-	* @param string $category cat-id (multiple id's commaseparated)
1607
-	* @param int $color color of the category, if multiple cats, the color of the last one with color is returned
1608
-	* @return array with id / names
1609
-	*/
1604
+	 * Converts category string of an event into array of (readable) category-names
1605
+	 *
1606
+	 * @param string $category cat-id (multiple id's commaseparated)
1607
+	 * @param int $color color of the category, if multiple cats, the color of the last one with color is returned
1608
+	 * @return array with id / names
1609
+	 */
1610 1610
 	function categories($category,&$color)
1611 1611
 	{
1612 1612
 		static $id2cat = array();
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 	/**
123 123
 	 * @var array recur_types translates MCAL recur-types to verbose labels
124 124
 	 */
125
-	var $recur_types = Array(
125
+	var $recur_types = array(
126 126
 		MCAL_RECUR_NONE         => 'No recurrence',
127 127
 		MCAL_RECUR_DAILY        => 'Daily',
128 128
 		MCAL_RECUR_WEEKLY       => 'Weekly',
@@ -1897,7 +1897,7 @@  discard block
 block discarded – undo
1897 1897
 	 * @param string $pattern pattern to search
1898 1898
 	 * @return array with cal_id - title pairs of the matching entries
1899 1899
 	 */
1900
-	function link_query($pattern, Array &$options = array())
1900
+	function link_query($pattern, array &$options = array())
1901 1901
 	{
1902 1902
 		$result = array();
1903 1903
 		$query = array(
Please login to merge, or discard this patch.
Doc Comments   +7 added lines, -12 removed lines patch added patch discarded remove patch
@@ -632,8 +632,8 @@  discard block
 block discarded – undo
632 632
 	 * or an ExecMethod callback with parameters $id,$event
633 633
 	 *
634 634
 	 * @param string $app
635
-	 * @param int|string $id
636
-	 * @return string
635
+	 * @param string $id
636
+	 * @return boolean
637 637
 	 */
638 638
 	static function integration_get_private($app,$id,$event)
639 639
 	{
@@ -762,7 +762,7 @@  discard block
 block discarded – undo
762 762
 	 * This methods operates in usertime, while $this->config['horizont'] is in servertime!
763 763
 	 *
764 764
 	 * @param array $event
765
-	 * @param mixed $start =0 minimum start-time for new recurrences or !$start = since the start of the event
765
+	 * @param integer $start =0 minimum start-time for new recurrences or !$start = since the start of the event
766 766
 	 */
767 767
 	function set_recurrences($event,$start=0)
768 768
 	{
@@ -982,10 +982,9 @@  discard block
 block discarded – undo
982 982
 	 * Recurrences get calculated by rrule iterator implemented in calendar_rrule class.
983 983
 	 *
984 984
 	 * @param array $event repeating event whos repetions should be inserted
985
-	 * @param mixed $start start-date
985
+	 * @param mixed $_start start-date
986 986
 	 * @param mixed $end end-date
987 987
 	 * @param array $events where the repetions get inserted
988
-	 * @param array $recur_exceptions with date (in Ymd) as key (and True as values), seems not to be used anymore
989 988
 	 */
990 989
 	function insert_all_recurrences($event,$_start,$end,&$events)
991 990
 	{
@@ -1139,7 +1138,7 @@  discard block
 block discarded – undo
1139 1138
 	 *	even if you have no general read-grant from that user.
1140 1139
 	 *
1141 1140
 	 * @param int $needed necessary ACL right: Acl::{READ|EDIT|DELETE}
1142
-	 * @param mixed $event event as array or the event-id or 0 for a general check
1141
+	 * @param integer $event event as array or the event-id or 0 for a general check
1143 1142
 	 * @param int $other uid to check (if event==0) or 0 to check against $this->user
1144 1143
 	 * @param string $date_format ='ts' date-format used for reading: 'ts'=timestamp, 'array'=array, 'string'=iso8601 string for xmlrpc
1145 1144
 	 * @param mixed $date_to_read =null date used for reading, internal param for the caching
@@ -1312,8 +1311,6 @@  discard block
 block discarded – undo
1312 1311
 	 * @param string $msg message with parameters/variables like lang(), eg. '%1'
1313 1312
 	 * @param boolean $backtrace =True include a function-backtrace, default True=On
1314 1313
 	 *	should only be set to False=Off, if your code ensures a call with backtrace=On was made before !!!
1315
-	 * @param mixed $param a variable number of parameters, to be inserted in $msg
1316
-	 *	arrays get serialized with print_r() !
1317 1314
 	 */
1318 1315
 	static function debug_message($msg,$backtrace=True)
1319 1316
 	{
@@ -1378,7 +1375,7 @@  discard block
 block discarded – undo
1378 1375
 	 * Formats one or two dates (range) as long date (full monthname), optionaly with a time
1379 1376
 	 *
1380 1377
 	 * @param mixed $_first first date
1381
-	 * @param mixed $last =0 last date if != 0 (default)
1378
+	 * @param integer $last =0 last date if != 0 (default)
1382 1379
 	 * @param boolean $display_time =false should a time be displayed too
1383 1380
 	 * @param boolean $display_day =false should a day-name prefix the date, eg. monday June 20, 2006
1384 1381
 	 * @return string with formated date
@@ -1847,7 +1844,6 @@  discard block
 block discarded – undo
1847 1844
 	 *
1848 1845
 	 * Is called as hook to participate in the linking
1849 1846
 	 *
1850
-	 * @param int|array $entry int cal_id or array with event
1851 1847
 	 * @param string|boolean string with title, null if not found or false if not read perms
1852 1848
 	 */
1853 1849
 	function link_title($event)
@@ -2036,6 +2032,7 @@  discard block
 block discarded – undo
2036 2032
 	 *
2037 2033
 	 * @param array|int|string $entry array with event or cal_id, or cal_id:recur_date for virtual exceptions
2038 2034
 	 * @param string &$schedule_tag=null on return schedule-tag (egw_cal.cal_id:egw_cal.cal_etag, no participant modifications!)
2035
+	 * @param string $schedule_tag
2039 2036
 	 * @return string|boolean string with etag or false
2040 2037
 	 */
2041 2038
 	function get_etag($entry, &$schedule_tag=null)
@@ -2076,7 +2073,6 @@  discard block
 block discarded – undo
2076 2073
 	 * Hook for infolog  to set some extra data and links
2077 2074
 	 *
2078 2075
 	 * @param array $data event-array preset by infolog plus
2079
-	 * @param int $data[id] cal_id
2080 2076
 	 * @return array with key => value pairs to set in new event and link_app/link_id arrays
2081 2077
 	 */
2082 2078
 	function infolog_set($data)
@@ -2128,7 +2124,6 @@  discard block
 block discarded – undo
2128 2124
 	 * Hook for timesheet to set some extra data and links
2129 2125
 	 *
2130 2126
 	 * @param array $data
2131
-	 * @param int $data[id] cal_id:recurrence
2132 2127
 	 * @return array with key => value pairs to set in new timesheet and link_app/link_id arrays
2133 2128
 	 */
2134 2129
 	function timesheet_set($data)
Please login to merge, or discard this patch.
Braces   +197 added lines, -49 removed lines patch added patch discarded remove patch
@@ -15,10 +15,13 @@  discard block
 block discarded – undo
15 15
 use EGroupware\Api\Link;
16 16
 use EGroupware\Api\Acl;
17 17
 
18
-if (!defined('ACL_TYPE_IDENTIFER'))	// used to mark ACL-values for the debug_message methode
18
+if (!defined('ACL_TYPE_IDENTIFER'))
19
+{
20
+	// used to mark ACL-values for the debug_message methode
19 21
 {
20 22
 	define('ACL_TYPE_IDENTIFER','***ACL***');
21 23
 }
24
+}
22 25
 
23 26
 define('HOUR_s',60*60);
24 27
 define('DAY_s',24*HOUR_s);
@@ -219,7 +222,10 @@  discard block
 block discarded – undo
219 222
 	 */
220 223
 	function __construct()
221 224
 	{
222
-		if ($this->debug > 0) $this->debug_message('calendar_bo::bocal() started',True);
225
+		if ($this->debug > 0)
226
+		{
227
+			$this->debug_message('calendar_bo::bocal() started',True);
228
+		}
223 229
 
224 230
 		$this->so = new calendar_so();
225 231
 
@@ -305,7 +311,10 @@  discard block
 block discarded – undo
305 311
 	 */
306 312
 	static function email_info($ids)
307 313
 	{
308
-		if (!$ids) return null;
314
+		if (!$ids)
315
+		{
316
+			return null;
317
+		}
309 318
 
310 319
 		$data = array();
311 320
 		foreach((array)$ids as $id)
@@ -398,10 +407,13 @@  discard block
 block discarded – undo
398 407
 				}
399 408
 				if ($ignore_acl || $this->check_perms(ACL::READ|self::ACL_READ_FOR_PARTICIPANTS|($use_freebusy?self::ACL_FREEBUSY:0),0,$contact))
400 409
 				{
401
-					if ($contact && !in_array($contact,$contact_list))	// already added?
410
+					if ($contact && !in_array($contact,$contact_list))
411
+					{
412
+						// already added?
402 413
 					{
403 414
 						$contact_list[] = $contact;
404 415
 					}
416
+					}
405 417
 				}
406 418
 			}
407 419
 		}
@@ -461,21 +473,27 @@  discard block
 block discarded – undo
461 473
 			{
462 474
 				foreach($this->enum_mailing_list($user, $ignore_acl, $use_freebusy) as $contact)
463 475
 				{
464
-					if ($contact && !in_array($contact,$users))	// already added?
476
+					if ($contact && !in_array($contact,$users))
477
+					{
478
+						// already added?
465 479
 					{
466 480
 						$users[] = $contact;
467 481
 					}
482
+					}
468 483
 				}
469 484
 				continue;
470 485
 			}
471 486
 			if ($ignore_acl || $this->check_perms(ACL::READ|self::ACL_READ_FOR_PARTICIPANTS|($use_freebusy?self::ACL_FREEBUSY:0),0,$user))
472 487
 			{
473
-				if ($user && !in_array($user,$users))	// already added?
488
+				if ($user && !in_array($user,$users))
489
+				{
490
+					// already added?
474 491
 				{
475 492
 					// General expansion check
476 493
 					if (!is_numeric($user) && $this->resources[$user[0]]['info'])
477 494
 					{
478 495
 						$info = $this->resource_info($user);
496
+				}
479 497
 						if($info && $info['resources'])
480 498
 						{
481 499
 							foreach($info['resources'] as $_user)
@@ -496,12 +514,18 @@  discard block
 block discarded – undo
496 514
 				continue;	// for non-groups (eg. users), we stop here if we have no read-rights
497 515
 			}
498 516
 			// the further code is only for real users
499
-			if (!is_numeric($user)) continue;
517
+			if (!is_numeric($user))
518
+			{
519
+				continue;
520
+			}
500 521
 
501 522
 			// for groups we have to include the members
502 523
 			if ($GLOBALS['egw']->accounts->get_type($user) == 'g')
503 524
 			{
504
-				if ($no_enum_groups) continue;
525
+				if ($no_enum_groups)
526
+				{
527
+					continue;
528
+				}
505 529
 
506 530
 				$members = $GLOBALS['egw']->accounts->members($user, true);
507 531
 				if (is_array($members))
@@ -581,11 +605,14 @@  discard block
 block discarded – undo
581 605
 		}
582 606
 
583 607
 		if (!isset($params['users']) || !$params['users'] ||
584
-			count($params['users']) == 1 && isset($params['users'][0]) && !$params['users'][0])	// null or '' casted to an array
608
+			count($params['users']) == 1 && isset($params['users'][0]) && !$params['users'][0])
609
+		{
610
+			// null or '' casted to an array
585 611
 		{
586 612
 			// for a search use all account you have read grants from
587 613
 			$params['users'] = $params['query'] ? array_keys($this->grants) : $this->user;
588 614
 		}
615
+		}
589 616
 		// resolve users to add memberships for users and members for groups
590 617
 		// for search, do NOT use freebusy rights, as it would allow to probe the content of event entries
591 618
 		$users = $this->resolve_users($params['users'], $params['filter'] == 'no-enum-groups', $params['ignore_acl'], empty($params['query']));
@@ -596,7 +623,10 @@  discard block
 block discarded – undo
596 623
 			$params['private_grants'] = array();
597 624
 			foreach($this->grants as $user => $rights)
598 625
 			{
599
-				if ($rights & Acl::PRIVAT) $params['private_grants'][] = $user;
626
+				if ($rights & Acl::PRIVAT)
627
+				{
628
+					$params['private_grants'][] = $user;
629
+				}
600 630
 			}
601 631
 		}
602 632
 
@@ -611,7 +641,10 @@  discard block
 block discarded – undo
611 641
 		{
612 642
 			return false;
613 643
 		}
614
-		if (isset($params['start'])) $start = $this->date2ts($params['start']);
644
+		if (isset($params['start']))
645
+		{
646
+			$start = $this->date2ts($params['start']);
647
+		}
615 648
 
616 649
 		if (isset($params['end']))
617 650
 		{
@@ -675,10 +708,13 @@  discard block
 block discarded – undo
675 708
 				$this->debug_message('socalendar::search daywise sorting from %1 to %2 of %3',False,$start,$end,$events);
676 709
 			}
677 710
 			// create empty entries for each day in the reported time
678
-			for($ts = $start; $ts <= $end; $ts += DAY_s) // good enough for array creation, but see while loop below.
711
+			for($ts = $start; $ts <= $end; $ts += DAY_s)
712
+			{
713
+				// good enough for array creation, but see while loop below.
679 714
 			{
680 715
 				$daysEvents[$this->date2string($ts)] = array();
681 716
 			}
717
+			}
682 718
 			foreach($events as $k => $event)
683 719
 			{
684 720
 				$e_start = max($this->date2ts($event['start']),$start);
@@ -730,7 +766,10 @@  discard block
 block discarded – undo
730 766
 			$integration_data = calendar_so::get_integration_data();
731 767
 		}
732 768
 
733
-		if (!isset($integration_data[$app])) return null;
769
+		if (!isset($integration_data[$app]))
770
+		{
771
+			return null;
772
+		}
734 773
 
735 774
 		return $part ? $integration_data[$app][$part] : $integration_data[$app];
736 775
 	}
@@ -777,8 +816,14 @@  discard block
 block discarded – undo
777 816
 	 */
778 817
 	function clear_private_infos(&$event,$allowed_participants = array())
779 818
 	{
780
-		if ($event == false) return;
781
-		if (!is_array($event['participants'])) error_log(__METHOD__.'('.array2string($event).', '.array2string($allowed_participants).') NO PARTICIPANTS '.function_backtrace());
819
+		if ($event == false)
820
+		{
821
+			return;
822
+		}
823
+		if (!is_array($event['participants']))
824
+		{
825
+			error_log(__METHOD__.'('.array2string($event).', '.array2string($allowed_participants).') NO PARTICIPANTS '.function_backtrace());
826
+		}
782 827
 
783 828
 		$event = array(
784 829
 			'id'    => $event['id'],
@@ -823,19 +868,29 @@  discard block
 block discarded – undo
823 868
 		}
824 869
 		$new_horizont = $this->date2ts($_new_horizont,true);	// now we are in server-time, where this function operates
825 870
 
826
-		if ($new_horizont <= $this->config['horizont'])	// no move necessary
871
+		if ($new_horizont <= $this->config['horizont'])
872
+		{
873
+			// no move necessary
827 874
 		{
828 875
 			if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2 is bigger ==> nothing to do',true,$new_horizont,(int)$this->config['horizont']);
876
+		}
829 877
 			return;
830 878
 		}
831 879
 		if (!empty($GLOBALS['egw_info']['server']['calendar_horizont']))
832 880
 		{
833 881
 			$maxdays = abs($GLOBALS['egw_info']['server']['calendar_horizont']);
834 882
 		}
835
-		if (empty($maxdays)) $maxdays = 1000; // old default
836
-		if ($new_horizont > time()+$maxdays*DAY_s)		// some user tries to "look" more then the maximum number of days in the future
883
+		if (empty($maxdays))
884
+		{
885
+			$maxdays = 1000;
886
+		}
887
+		// old default
888
+		if ($new_horizont > time()+$maxdays*DAY_s)
889
+		{
890
+			// some user tries to "look" more then the maximum number of days in the future
837 891
 		{
838 892
 			if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2 new horizont more then %3 days from now --> ignoring it',true,$new_horizont,(int)$this->config['horizont'],$maxdays);
893
+		}
839 894
 			$this->warnings['horizont'] = lang('Requested date %1 outside allowed range of %2 days: recurring events obmitted!', Api\DateTime::to($new_horizont,true), $maxdays);
840 895
 			return;
841 896
 		}
@@ -863,7 +918,10 @@  discard block
 block discarded – undo
863 918
 		// update the horizont
864 919
 		Api\Config::save_value('horizont',$this->config['horizont'],'calendar');
865 920
 
866
-		if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) new horizont=%2, exiting',true,$new_horizont,(int)$this->config['horizont']);
921
+		if ($this->debug == 'check_move_horizont')
922
+		{
923
+			$this->debug_message('calendar_bo::check_move_horizont(%1) new horizont=%2, exiting',true,$new_horizont,(int)$this->config['horizont']);
924
+		}
867 925
 	}
868 926
 
869 927
 	/**
@@ -894,7 +952,10 @@  discard block
 block discarded – undo
894 952
 				$event['end'] = $this->date2usertime($event_read['end']);
895 953
 			}
896 954
 		}
897
-		if (!$start) $start = $event['start'];
955
+		if (!$start)
956
+		{
957
+			$start = $event['start'];
958
+		}
898 959
 		$start_obj = new Api\DateTime($start);
899 960
 		$read_start = new Api\DateTime($event_read['start']);
900 961
 
@@ -936,7 +997,10 @@  discard block
 block discarded – undo
936 997
 	 */
937 998
 	function db2data(&$events,$date_format='ts')
938 999
 	{
939
-		if (!is_array($events)) echo "<p>calendar_bo::db2data(\$events,$date_format) \$events is no array<br />\n".function_backtrace()."</p>\n";
1000
+		if (!is_array($events))
1001
+		{
1002
+			echo "<p>calendar_bo::db2data(\$events,$date_format) \$events is no array<br />\n".function_backtrace()."</p>\n";
1003
+		}
940 1004
 		foreach ($events as &$event)
941 1005
 		{
942 1006
 			// convert timezone id of event to tzid (iCal id like 'Europe/Berlin')
@@ -1020,7 +1084,10 @@  discard block
 block discarded – undo
1020 1084
 	 */
1021 1085
 	function date2usertime($ts,$date_format='ts')
1022 1086
 	{
1023
-		if (empty($ts) || $date_format == 'server') return $ts;
1087
+		if (empty($ts) || $date_format == 'server')
1088
+		{
1089
+			return $ts;
1090
+		}
1024 1091
 
1025 1092
 		return Api\DateTime::server2user($ts,$date_format);
1026 1093
 	}
@@ -1038,9 +1105,15 @@  discard block
 block discarded – undo
1038 1105
 	 */
1039 1106
 	function read($ids,$date=null,$ignore_acl=False,$date_format='ts',$clear_private_infos_users=null)
1040 1107
 	{
1041
-		if (!$ids) return false;
1108
+		if (!$ids)
1109
+		{
1110
+			return false;
1111
+		}
1042 1112
 
1043
-		if ($date) $date = $this->date2ts($date);
1113
+		if ($date)
1114
+		{
1115
+			$date = $this->date2ts($date);
1116
+		}
1044 1117
 
1045 1118
 		$return = null;
1046 1119
 
@@ -1205,7 +1278,10 @@  discard block
 block discarded – undo
1205 1278
 	{
1206 1279
 		static $res_info_cache = array();
1207 1280
 
1208
-		if (!is_scalar($uid)) throw new Api\Exception\WrongParameter(__METHOD__.'('.array2string($uid).') parameter must be scalar');
1281
+		if (!is_scalar($uid))
1282
+		{
1283
+			throw new Api\Exception\WrongParameter(__METHOD__.'('.array2string($uid).') parameter must be scalar');
1284
+		}
1209 1285
 
1210 1286
 		if (!isset($res_info_cache[$uid]))
1211 1287
 		{
@@ -1260,7 +1336,10 @@  discard block
 block discarded – undo
1260 1336
 	 */
1261 1337
 	function check_perms($needed,$event=0,$other=0,$date_format='ts',$date_to_read=null,$user=null)
1262 1338
 	{
1263
-		if (!$user) $user = $this->user;
1339
+		if (!$user)
1340
+		{
1341
+			$user = $this->user;
1342
+		}
1264 1343
 		if ($user == $this->user)
1265 1344
 		{
1266 1345
 			$grants = $this->grants;
@@ -1299,7 +1378,10 @@  discard block
 block discarded – undo
1299 1378
 		$grant = $grants[$owner];
1300 1379
 
1301 1380
 		// now any ACL rights (but invite rights!) implicate FREEBUSY rights (at least READ has to include FREEBUSY)
1302
-		if ($grant & ~self::ACL_INVITE) $grant |= self::ACL_FREEBUSY;
1381
+		if ($grant & ~self::ACL_INVITE)
1382
+		{
1383
+			$grant |= self::ACL_FREEBUSY;
1384
+		}
1303 1385
 
1304 1386
 		if (is_array($event) && ($needed == Acl::READ || $needed == self::ACL_FREEBUSY))
1305 1387
 		{
@@ -1325,7 +1407,10 @@  discard block
 block discarded – undo
1325 1407
 					elseif (!is_numeric($uid))
1326 1408
 					{
1327 1409
 						// if the owner only grants self::ACL_FREEBUSY we are not interested in the recources explicit rights
1328
-						if ($grant == self::ACL_FREEBUSY) continue;
1410
+						if ($grant == self::ACL_FREEBUSY)
1411
+						{
1412
+							continue;
1413
+						}
1329 1414
 						// if we have a resource as participant
1330 1415
 						$resource = $this->resource_info($uid);
1331 1416
 						$grant |= $resource['rights'];
@@ -1476,14 +1561,20 @@  discard block
 block discarded – undo
1476 1561
 						$param = $param ? 'True' : 'False';
1477 1562
 						break;
1478 1563
 					case 'integer':
1479
-						if ($param >= mktime(0,0,0,1,1,2000)) $param = adodb_date('Y-m-d H:i:s',$param)." ($param)";
1564
+						if ($param >= mktime(0,0,0,1,1,2000))
1565
+						{
1566
+							$param = adodb_date('Y-m-d H:i:s',$param)." ($param)";
1567
+						}
1480 1568
 						break;
1481 1569
 				}
1482 1570
 			}
1483 1571
 			$msg = str_replace('%'.($i-1),$param,$msg);
1484 1572
 		}
1485 1573
 		error_log($msg);
1486
-		if ($backtrace) error_log(function_backtrace(1));
1574
+		if ($backtrace)
1575
+		{
1576
+			error_log(function_backtrace(1));
1577
+		}
1487 1578
 	}
1488 1579
 
1489 1580
 	/**
@@ -1591,14 +1682,20 @@  discard block
 block discarded – undo
1591 1682
 	function timespan($start_m,$end_m,$both=false)
1592 1683
 	{
1593 1684
 		$duration = $end_m - $start_m;
1594
-		if ($end_m == 24*60-1) ++$duration;
1685
+		if ($end_m == 24*60-1)
1686
+		{
1687
+			++$duration;
1688
+		}
1595 1689
 		$duration = floor($duration/60).lang('h').($duration%60 ? $duration%60 : '');
1596 1690
 
1597 1691
 		$timespan = $t = Api\DateTime::to('20000101T'.sprintf('%02d',$start_m/60).sprintf('%02d',$start_m%60).'00', false);
1598 1692
 
1599
-		if ($both)	// end-time too
1693
+		if ($both)
1694
+		{
1695
+			// end-time too
1600 1696
 		{
1601 1697
 			$timespan .= ' - '.Api\DateTime::to('20000101T'.sprintf('%02d',$end_m/60).sprintf('%02d',$end_m%60).'00', false);
1698
+		}
1602 1699
 			// dont double am/pm if they are the same in both times
1603 1700
 			if ($this->common_prefs['timeformat'] == 12 && substr($timespan,-2) == substr($t,-2))
1604 1701
 			{
@@ -1622,7 +1719,10 @@  discard block
 block discarded – undo
1622 1719
 		static $id2lid = array();
1623 1720
 		static $id2email = array();
1624 1721
 
1625
-		if ($use_type && $use_type != 'u') $id = $use_type.$id;
1722
+		if ($use_type && $use_type != 'u')
1723
+		{
1724
+			$id = $use_type.$id;
1725
+		}
1626 1726
 
1627 1727
 		if (!isset($id2lid[$id]))
1628 1728
 		{
@@ -1632,7 +1732,10 @@  discard block
 block discarded – undo
1632 1732
 				if (($info = $this->resource_info($id)))
1633 1733
 				{
1634 1734
 					$id2lid[$id] = $info['name'] ? $info['name'] : $info['email'];
1635
-					if ($info['name']) $id2email[$id] = $info['email'];
1735
+					if ($info['name'])
1736
+					{
1737
+						$id2email[$id] = $info['email'];
1738
+					}
1636 1739
 				}
1637 1740
 			}
1638 1741
 			else
@@ -1658,11 +1761,18 @@  discard block
 block discarded – undo
1658 1761
 		$names = array();
1659 1762
 		foreach((array)$event['participants'] as $id => $status)
1660 1763
 		{
1661
-			if (!is_string($status)) continue;
1764
+			if (!is_string($status))
1765
+			{
1766
+				continue;
1767
+			}
1662 1768
 			$quantity = $role = null;
1663 1769
 			calendar_so::split_status($status,$quantity,$role);
1664 1770
 
1665
-			if ($status == 'G' && !$show_group_invitation) continue;	// dont show group-invitation
1771
+			if ($status == 'G' && !$show_group_invitation)
1772
+			{
1773
+				continue;
1774
+			}
1775
+			// dont show group-invitation
1666 1776
 
1667 1777
 			$lang_status = lang($this->verbose_status[$status]);
1668 1778
 			if (!$long_status)
@@ -1735,7 +1845,10 @@  discard block
 block discarded – undo
1735 1845
 
1736 1846
 		foreach(explode(',',$category) as $cat_id)
1737 1847
 		{
1738
-			if (!$cat_id) continue;
1848
+			if (!$cat_id)
1849
+			{
1850
+				continue;
1851
+			}
1739 1852
 
1740 1853
 			if (!isset($id2cat[$cat_id]))
1741 1854
 			{
@@ -1801,7 +1914,10 @@  discard block
 block discarded – undo
1801 1914
 	 */
1802 1915
 	public static function list_calendars($user, array $grants=null)
1803 1916
 	{
1804
-		if (is_null($grants)) $grants = $GLOBALS['egw']->acl->get_grants('calendar', true, $user);
1917
+		if (is_null($grants))
1918
+		{
1919
+			$grants = $GLOBALS['egw']->acl->get_grants('calendar', true, $user);
1920
+		}
1805 1921
 
1806 1922
 		$users = $groups = array();
1807 1923
 		foreach(array_keys($grants) as $id)
@@ -1849,7 +1965,10 @@  discard block
 block discarded – undo
1849 1965
 	 */
1850 1966
 	function recure2string($event)
1851 1967
 	{
1852
-		if (!is_array($event)) return false;
1968
+		if (!is_array($event))
1969
+		{
1970
+			return false;
1971
+		}
1853 1972
 		return (string)calendar_rrule::event2rrule($event);
1854 1973
 	}
1855 1974
 
@@ -1868,7 +1987,10 @@  discard block
 block discarded – undo
1868 1987
 	 */
1869 1988
 	function read_holidays($year=0)
1870 1989
 	{
1871
-		if (!$year) $year = (int) date('Y',$this->now_su);
1990
+		if (!$year)
1991
+		{
1992
+			$year = (int) date('Y',$this->now_su);
1993
+		}
1872 1994
 
1873 1995
 		$holidays = calendar_holidays::read(
1874 1996
 				!empty($GLOBALS['egw_info']['server']['ical_holiday_url']) ?
@@ -1963,7 +2085,10 @@  discard block
 block discarded – undo
1963 2085
 				}
1964 2086
 			}
1965 2087
 			$str_fields = implode(', ',$extra_fields);
1966
-			if (is_array($extra_fields)) return $this->format_date($event['start']) . ': ' . $event['title'] . ($str_fields? ', ' . $str_fields:'');
2088
+			if (is_array($extra_fields))
2089
+			{
2090
+				return $this->format_date($event['start']) . ': ' . $event['title'] . ($str_fields? ', ' . $str_fields:'');
2091
+			}
1967 2092
 		}
1968 2093
 		return $this->format_date($event['start']) . ': ' . $event['title'];
1969 2094
 	}
@@ -1984,7 +2109,8 @@  discard block
 block discarded – undo
1984 2109
 			'offset' =>	$options['start'],
1985 2110
 			'order' => 'cal_start DESC',
1986 2111
 		);
1987
-		if($options['num_rows']) {
2112
+		if($options['num_rows'])
2113
+		{
1988 2114
 			$query['num_rows'] = $options['num_rows'];
1989 2115
 		}
1990 2116
 		foreach((array) $this->search($query) as $event)
@@ -2045,7 +2171,10 @@  discard block
 block discarded – undo
2045 2171
 			if ((!isset($default_prefs[$var]) || (string)$default_prefs[$var] === '') && (!isset($forced_prefs[$var]) || (string)$forced_prefs[$var] === ''))
2046 2172
 			{
2047 2173
 				$GLOBALS['egw']->preferences->add('calendar',$var,$default,'default');	// always store default, even if we have a forced too
2048
-				if ($type == 'forced') $GLOBALS['egw']->preferences->add('calendar',$var,$default,'forced');
2174
+				if ($type == 'forced')
2175
+				{
2176
+					$GLOBALS['egw']->preferences->add('calendar',$var,$default,'forced');
2177
+				}
2049 2178
 				$this->cal_prefs[$var] = $default;
2050 2179
 				$need_save = True;
2051 2180
 			}
@@ -2065,7 +2194,10 @@  discard block
 block discarded – undo
2065 2194
 	 */
2066 2195
 	static function freebusy_url($user='',$pw=null)
2067 2196
 	{
2068
-		if (is_numeric($user)) $user = $GLOBALS['egw']->accounts->id2name($user);
2197
+		if (is_numeric($user))
2198
+		{
2199
+			$user = $GLOBALS['egw']->accounts->id2name($user);
2200
+		}
2069 2201
 
2070 2202
 		$credentials = '';
2071 2203
 
@@ -2133,13 +2265,19 @@  discard block
 block discarded – undo
2133 2265
 	 */
2134 2266
 	public function get_ctag($user, $filter='owner', $master_only=false)
2135 2267
 	{
2136
-		if ($this->debug > 1) $startime = microtime(true);
2268
+		if ($this->debug > 1)
2269
+		{
2270
+			$startime = microtime(true);
2271
+		}
2137 2272
 
2138 2273
 		// resolve users to add memberships for users and members for groups
2139 2274
 		$users = $this->resolve_users($user);
2140 2275
 		$ctag = $users ? $this->so->get_ctag($users, $filter == 'owner', $master_only) : 0;	// no rights, return 0 as ctag (otherwise we get SQL error!)
2141 2276
 
2142
-		if ($this->debug > 1) error_log(__METHOD__. "($user, '$filter', $master_only) = $ctag = ".date('Y-m-d H:i:s',$ctag)." took ".(microtime(true)-$startime)." secs");
2277
+		if ($this->debug > 1)
2278
+		{
2279
+			error_log(__METHOD__. "($user, '$filter', $master_only) = $ctag = ".date('Y-m-d H:i:s',$ctag)." took ".(microtime(true)-$startime)." secs");
2280
+		}
2143 2281
 		return $ctag;
2144 2282
 	}
2145 2283
 
@@ -2181,15 +2319,21 @@  discard block
 block discarded – undo
2181 2319
 				$content['link_app'][] = $link['app'];
2182 2320
 				$content['link_id'][]  = $link['id'];
2183 2321
 			}
2184
-			if ($link['app'] == 'addressbook')	// prefering contact as primary contact over calendar entry set above
2322
+			if ($link['app'] == 'addressbook')
2323
+			{
2324
+				// prefering contact as primary contact over calendar entry set above
2185 2325
 			{
2186 2326
 				$content['info_contact'] = 'addressbook:'.$link['id'];
2187 2327
 			}
2328
+			}
2188 2329
 		}
2189 2330
 		// Copy same custom fields
2190 2331
 		foreach(array_keys(Api\Storage\Customfields::get('infolog')) as $name)
2191 2332
 		{
2192
-			if ($this->customfields[$name]) $content['#'.$name] = $calendar['#'.$name];
2333
+			if ($this->customfields[$name])
2334
+			{
2335
+				$content['#'.$name] = $calendar['#'.$name];
2336
+			}
2193 2337
 		}
2194 2338
 		//error_log(__METHOD__.'('.array2string($data).') calendar='.array2string($calendar).' returning '.array2string($content));
2195 2339
 		return $content;
@@ -2212,7 +2356,11 @@  discard block
 block discarded – undo
2212 2356
 			$set['ts_title'] = $this->link_title($event);
2213 2357
 			$set['start_time'] = Api\DateTime::to($event['start'],'H:i');
2214 2358
 			$set['ts_description'] = $event['description'];
2215
-			if ($this->isWholeDay($event)) $event['end']++;	// whole day events are 1sec short
2359
+			if ($this->isWholeDay($event))
2360
+			{
2361
+				$event['end']++;
2362
+			}
2363
+			// whole day events are 1sec short
2216 2364
 			$set['ts_duration']	= ($event['end'] - $event['start']) / 60;
2217 2365
 			$set['ts_quantity'] = ($event['end'] - $event['start']) / 3600;
2218 2366
 			$set['end_time'] = null;	// unset end-time
Please login to merge, or discard this patch.
Spacing   +302 added lines, -304 removed lines patch added patch discarded remove patch
@@ -17,12 +17,12 @@  discard block
 block discarded – undo
17 17
 
18 18
 if (!defined('ACL_TYPE_IDENTIFER'))	// used to mark ACL-values for the debug_message methode
19 19
 {
20
-	define('ACL_TYPE_IDENTIFER','***ACL***');
20
+	define('ACL_TYPE_IDENTIFER', '***ACL***');
21 21
 }
22 22
 
23
-define('HOUR_s',60*60);
24
-define('DAY_s',24*HOUR_s);
25
-define('WEEK_s',7*DAY_s);
23
+define('HOUR_s', 60 * 60);
24
+define('DAY_s', 24 * HOUR_s);
25
+define('WEEK_s', 7 * DAY_s);
26 26
 
27 27
 /**
28 28
  * Required (!) include, as we use the MCAL_* constants, BEFORE instanciating (and therefore autoloading) the class
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	 *	4 = function-calls to exported conversation-functions like date2ts, date2array, ...
72 72
 	 *	5 = function-calls to private functions
73 73
 	 */
74
-	var $debug=false;
74
+	var $debug = false;
75 75
 
76 76
 	/**
77 77
 	 * @var int $now timestamp in server-time
@@ -101,12 +101,12 @@  discard block
 block discarded – undo
101 101
 	/**
102 102
 	 * @var int $user nummerical id of the current user-id
103 103
 	 */
104
-	var $user=0;
104
+	var $user = 0;
105 105
 
106 106
 	/**
107 107
 	 * @var array $grants grants of the current user, array with user-id / ored-ACL-rights pairs
108 108
 	 */
109
-	var $grants=array();
109
+	var $grants = array();
110 110
 
111 111
 	/**
112 112
 	 * @var array $verbose_status translated 1-char status values to a verbose name, run through lang() by the constructor
@@ -219,15 +219,15 @@  discard block
 block discarded – undo
219 219
 	 */
220 220
 	function __construct()
221 221
 	{
222
-		if ($this->debug > 0) $this->debug_message('calendar_bo::bocal() started',True);
222
+		if ($this->debug > 0) $this->debug_message('calendar_bo::bocal() started', True);
223 223
 
224 224
 		$this->so = new calendar_so();
225 225
 
226
-		$this->common_prefs =& $GLOBALS['egw_info']['user']['preferences']['common'];
227
-		$this->cal_prefs =& $GLOBALS['egw_info']['user']['preferences']['calendar'];
226
+		$this->common_prefs = & $GLOBALS['egw_info']['user']['preferences']['common'];
227
+		$this->cal_prefs = & $GLOBALS['egw_info']['user']['preferences']['calendar'];
228 228
 
229 229
 		$this->now = time();
230
-		$this->now_su = Api\DateTime::server2user($this->now,'ts');
230
+		$this->now_su = Api\DateTime::server2user($this->now, 'ts');
231 231
 
232 232
 		$this->user = $GLOBALS['egw_info']['user']['account_id'];
233 233
 
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 		if (!is_array($this->resources = Api\Cache::getSession('calendar', 'resources')))
237 237
 		{
238 238
 			$this->resources = array();
239
-			foreach(Api\Hooks::process('calendar_resources') as $app => $data)
239
+			foreach (Api\Hooks::process('calendar_resources') as $app => $data)
240 240
 			{
241 241
 				if ($data && $data['type'])
242 242
 				{
@@ -249,8 +249,8 @@  discard block
 block discarded – undo
249 249
 				'app'  => 'email',
250 250
 			);
251 251
 			$this->resources['l'] = array(
252
-				'type' => 'l',// one char type-identifier for this resources
253
-				'info' => __CLASS__ .'::mailing_lists',// info method, returns array with id, type & name for a given id
252
+				'type' => 'l', // one char type-identifier for this resources
253
+				'info' => __CLASS__.'::mailing_lists', // info method, returns array with id, type & name for a given id
254 254
 				'app' => 'Distribution list'
255 255
 			);
256 256
 			$this->resources[''] = array(
@@ -258,22 +258,22 @@  discard block
 block discarded – undo
258 258
 				'app' => 'api-accounts',
259 259
 			);
260 260
 			$this->resources['l'] = array(
261
-				'type' => 'l',// one char type-identifier for this resources
262
-				'info' => __CLASS__ .'::mailing_lists',// info method, returns array with id, type & name for a given id
261
+				'type' => 'l', // one char type-identifier for this resources
262
+				'info' => __CLASS__.'::mailing_lists', // info method, returns array with id, type & name for a given id
263 263
 				'app' => 'Distribution list'
264 264
 			);
265 265
 			Api\Cache::setSession('calendar', 'resources', $this->resources);
266 266
 		}
267 267
 		//error_log(__METHOD__ . " registered resources=". array2string($this->resources));
268 268
 
269
-		$this->config = Api\Config::read('calendar');	// only used for horizont, regular calendar config is under phpgwapi
269
+		$this->config = Api\Config::read('calendar'); // only used for horizont, regular calendar config is under phpgwapi
270 270
 		$this->require_acl_invite = $GLOBALS['egw_info']['server']['require_acl_invite'];
271 271
 
272
-		$this->categories = new Api\Categories($this->user,'calendar');
272
+		$this->categories = new Api\Categories($this->user, 'calendar');
273 273
 
274 274
 		$this->customfields = Api\Storage\Customfields::get('calendar');
275 275
 
276
-		foreach($this->alarms as $secs => &$label)
276
+		foreach ($this->alarms as $secs => &$label)
277 277
 		{
278 278
 			$label = self::secs2label($secs);
279 279
 		}
@@ -289,15 +289,15 @@  discard block
 block discarded – undo
289 289
 	{
290 290
 		if ($secs <= 3600)
291 291
 		{
292
-			$label = lang('%1 minutes', $secs/60);
292
+			$label = lang('%1 minutes', $secs / 60);
293 293
 		}
294
-		elseif($secs <= 86400)
294
+		elseif ($secs <= 86400)
295 295
 		{
296
-			$label = lang('%1 hours', $secs/3600);
296
+			$label = lang('%1 hours', $secs / 3600);
297 297
 		}
298 298
 		else
299 299
 		{
300
-			$label = lang('%1 days', $secs/86400);
300
+			$label = lang('%1 days', $secs / 86400);
301 301
 		}
302 302
 		return $label;
303 303
 	}
@@ -313,12 +313,12 @@  discard block
 block discarded – undo
313 313
 		if (!$ids) return null;
314 314
 
315 315
 		$data = array();
316
-		foreach((array)$ids as $id)
316
+		foreach ((array)$ids as $id)
317 317
 		{
318 318
 			$email = $id;
319 319
 			$name = '';
320 320
 			$matches = null;
321
-			if (preg_match('/^(.*) *<([a-z0-9_.@-]{8,})>$/iU',$email,$matches))
321
+			if (preg_match('/^(.*) *<([a-z0-9_.@-]{8,})>$/iU', $email, $matches))
322 322
 			{
323 323
 				$name = $matches[1];
324 324
 				$email = $matches[2];
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
 	 */
343 343
 	static function mailing_lists($ids)
344 344
 	{
345
-		if(!is_array($ids))
345
+		if (!is_array($ids))
346 346
 		{
347 347
 			$ids = array($ids);
348 348
 		}
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
 		// Email list
352 352
 		$contacts_obj = new Api\Contacts();
353 353
 		$bo = new calendar_bo();
354
-		foreach($ids as $id)
354
+		foreach ($ids as $id)
355 355
 		{
356 356
 			$list = $contacts_obj->read_list((int)$id);
357 357
 
@@ -378,22 +378,22 @@  discard block
 block discarded – undo
378 378
 	 *
379 379
 	 * @return array
380 380
 	 */
381
-	public function enum_mailing_list($id, $ignore_acl= false, $use_freebusy = true)
381
+	public function enum_mailing_list($id, $ignore_acl = false, $use_freebusy = true)
382 382
 	{
383 383
 		$contact_list = array();
384 384
 		$contacts = new Api\Contacts();
385
-		if($contacts->check_list((int)substr($id,1), ACL::READ) || (int)substr($id,1) < 0)
385
+		if ($contacts->check_list((int)substr($id, 1), ACL::READ) || (int)substr($id, 1) < 0)
386 386
 		{
387
-			$options = array('list' => substr($id,1));
388
-			$lists = $contacts->search('',true,'','','',false,'AND',false,$options);
389
-			if(!$lists)
387
+			$options = array('list' => substr($id, 1));
388
+			$lists = $contacts->search('', true, '', '', '', false, 'AND', false, $options);
389
+			if (!$lists)
390 390
 			{
391 391
 				return $contact_list;
392 392
 			}
393
-			foreach($lists as &$contact)
393
+			foreach ($lists as &$contact)
394 394
 			{
395 395
 				// Check for user account
396
-				if (($account_id = $GLOBALS['egw']->accounts->name2id($contact['id'],'person_id')))
396
+				if (($account_id = $GLOBALS['egw']->accounts->name2id($contact['id'], 'person_id')))
397 397
 				{
398 398
 					$contact = ''.$account_id;
399 399
 				}
@@ -401,9 +401,9 @@  discard block
 block discarded – undo
401 401
 				{
402 402
 					$contact = 'c'.$contact['id'];
403 403
 				}
404
-				if ($ignore_acl || $this->check_perms(ACL::READ|self::ACL_READ_FOR_PARTICIPANTS|($use_freebusy?self::ACL_FREEBUSY:0),0,$contact))
404
+				if ($ignore_acl || $this->check_perms(ACL::READ|self::ACL_READ_FOR_PARTICIPANTS|($use_freebusy ? self::ACL_FREEBUSY : 0), 0, $contact))
405 405
 				{
406
-					if ($contact && !in_array($contact,$contact_list))	// already added?
406
+					if ($contact && !in_array($contact, $contact_list))	// already added?
407 407
 					{
408 408
 						$contact_list[] = $contact;
409 409
 					}
@@ -422,12 +422,12 @@  discard block
 block discarded – undo
422 422
 	function enum_groups(&$event)
423 423
 	{
424 424
 		$added = 0;
425
-		foreach(array_keys($event['participants']) as $uid)
425
+		foreach (array_keys($event['participants']) as $uid)
426 426
 		{
427 427
 			if (is_numeric($uid) && $GLOBALS['egw']->accounts->get_type($uid) == 'g' &&
428 428
 				($members = $GLOBALS['egw']->accounts->members($uid, true)))
429 429
 			{
430
-				foreach($members as $member)
430
+				foreach ($members as $member)
431 431
 				{
432 432
 					if (!isset($event['participants'][$member]))
433 433
 					{
@@ -449,7 +449,7 @@  discard block
 block discarded – undo
449 449
 	 * @param boolean $use_freebusy =true should freebusy rights are taken into account, default true, can be set to false eg. for a search
450 450
 	 * @return array of user-ids
451 451
 	 */
452
-	private function resolve_users($_users, $no_enum_groups=true, $ignore_acl=false, $use_freebusy=true)
452
+	private function resolve_users($_users, $no_enum_groups = true, $ignore_acl = false, $use_freebusy = true)
453 453
 	{
454 454
 		if (!is_array($_users))
455 455
 		{
@@ -457,35 +457,35 @@  discard block
 block discarded – undo
457 457
 		}
458 458
 		// only query calendars of users, we have READ-grants from
459 459
 		$users = array();
460
-		foreach($_users as $user)
460
+		foreach ($_users as $user)
461 461
 		{
462 462
 			$user = trim($user);
463 463
 			
464 464
 			// Handle email lists
465
-			if(!is_numeric($user) && $user[0] == 'l')
465
+			if (!is_numeric($user) && $user[0] == 'l')
466 466
 			{
467
-				foreach($this->enum_mailing_list($user, $ignore_acl, $use_freebusy) as $contact)
467
+				foreach ($this->enum_mailing_list($user, $ignore_acl, $use_freebusy) as $contact)
468 468
 				{
469
-					if ($contact && !in_array($contact,$users))	// already added?
469
+					if ($contact && !in_array($contact, $users))	// already added?
470 470
 					{
471 471
 						$users[] = $contact;
472 472
 					}
473 473
 				}
474 474
 				continue;
475 475
 			}
476
-			if ($ignore_acl || $this->check_perms(ACL::READ|self::ACL_READ_FOR_PARTICIPANTS|($use_freebusy?self::ACL_FREEBUSY:0),0,$user))
476
+			if ($ignore_acl || $this->check_perms(ACL::READ|self::ACL_READ_FOR_PARTICIPANTS|($use_freebusy ? self::ACL_FREEBUSY : 0), 0, $user))
477 477
 			{
478
-				if ($user && !in_array($user,$users))	// already added?
478
+				if ($user && !in_array($user, $users))	// already added?
479 479
 				{
480 480
 					// General expansion check
481 481
 					if (!is_numeric($user) && $this->resources[$user[0]]['info'])
482 482
 					{
483 483
 						$info = $this->resource_info($user);
484
-						if($info && $info['resources'])
484
+						if ($info && $info['resources'])
485 485
 						{
486
-							foreach($info['resources'] as $_user)
486
+							foreach ($info['resources'] as $_user)
487 487
 							{
488
-								if($_user && !in_array($_user, $users))
488
+								if ($_user && !in_array($_user, $users))
489 489
 								{
490 490
 									$users[] = $_user;
491 491
 								}
@@ -498,7 +498,7 @@  discard block
 block discarded – undo
498 498
 			}
499 499
 			elseif ($GLOBALS['egw']->accounts->get_type($user) != 'g')
500 500
 			{
501
-				continue;	// for non-groups (eg. users), we stop here if we have no read-rights
501
+				continue; // for non-groups (eg. users), we stop here if we have no read-rights
502 502
 			}
503 503
 			// the further code is only for real users
504 504
 			if (!is_numeric($user)) continue;
@@ -511,11 +511,11 @@  discard block
 block discarded – undo
511 511
 				$members = $GLOBALS['egw']->accounts->members($user, true);
512 512
 				if (is_array($members))
513 513
 				{
514
-					foreach($members as $member)
514
+					foreach ($members as $member)
515 515
 					{
516 516
 						// use only members which gave the user a read-grant
517 517
 						if (!in_array($member, $users) &&
518
-							($ignore_acl || $this->check_perms(Acl::READ|($use_freebusy?self::ACL_FREEBUSY:0),0,$member)))
518
+							($ignore_acl || $this->check_perms(Acl::READ|($use_freebusy ? self::ACL_FREEBUSY : 0), 0, $member)))
519 519
 						{
520 520
 							$users[] = $member;
521 521
 						}
@@ -527,9 +527,9 @@  discard block
 block discarded – undo
527 527
 				$memberships = $GLOBALS['egw']->accounts->memberships($user, true);
528 528
 				if (is_array($memberships))
529 529
 				{
530
-					foreach($memberships as $group)
530
+					foreach ($memberships as $group)
531 531
 					{
532
-						if (!in_array($group,$users))
532
+						if (!in_array($group, $users))
533 533
 						{
534 534
 							$users[] = $group;
535 535
 						}
@@ -570,18 +570,18 @@  discard block
 block discarded – undo
570 570
 	 * @return iterator|array|boolean array of events or array with YYYYMMDD strings / array of events pairs (depending on $daywise param)
571 571
 	 *	or false if there are no read-grants from _any_ of the requested users or iterator/recordset if cols are given
572 572
 	 */
573
-	function &search($params,$sql_filter=null)
573
+	function &search($params, $sql_filter = null)
574 574
 	{
575 575
 		$params_in = $params;
576 576
 
577
-		$params['sql_filter'] = $sql_filter;	// dont allow to set it via UI or xmlrpc
577
+		$params['sql_filter'] = $sql_filter; // dont allow to set it via UI or xmlrpc
578 578
 
579 579
 		// check if any resource wants to hook into
580
-		foreach($this->resources as $data)
580
+		foreach ($this->resources as $data)
581 581
 		{
582 582
 			if (isset($data['search_filter']))
583 583
 			{
584
-				$params = ExecMethod($data['search_filter'],$params);
584
+				$params = ExecMethod($data['search_filter'], $params);
585 585
 			}
586 586
 		}
587 587
 
@@ -599,9 +599,9 @@  discard block
 block discarded – undo
599 599
 		if (!empty($params['query']))
600 600
 		{
601 601
 			$params['private_grants'] = array();
602
-			foreach($this->grants as $user => $rights)
602
+			foreach ($this->grants as $user => $rights)
603 603
 			{
604
-				if ($rights & Acl::PRIVAT) $params['private_grants'][] = $user;
604
+				if ($rights&Acl::PRIVAT) $params['private_grants'][] = $user;
605 605
 			}
606 606
 		}
607 607
 
@@ -627,49 +627,49 @@  discard block
 block discarded – undo
627 627
 		$params['enum_recuring'] = $enum_recuring = $daywise || !isset($params['enum_recuring']) || !!$params['enum_recuring'];
628 628
 		$cat_id = isset($params['cat_id']) ? $params['cat_id'] : 0;
629 629
 		$filter = isset($params['filter']) ? $params['filter'] : 'all';
630
-		$offset = isset($params['offset']) && $params['offset'] !== false ? (int) $params['offset'] : false;
630
+		$offset = isset($params['offset']) && $params['offset'] !== false ? (int)$params['offset'] : false;
631 631
 		// socal::search() returns rejected group-invitations, as only the user not also the group is rejected
632 632
 		// as we cant remove them efficiantly in SQL, we kick them out here, but only if just one user is displayed
633 633
 		$users_in = (array)$params_in['users'];
634
-		$remove_rejected_by_user = !in_array($filter,array('all','rejected','everything')) &&
634
+		$remove_rejected_by_user = !in_array($filter, array('all', 'rejected', 'everything')) &&
635 635
 			count($users_in) == 1 && $users_in[0] > 0 ? $users_in[0] : null;
636 636
 		//error_log(__METHOD__.'('.array2string($params_in).", $sql_filter) params[users]=".array2string($params['users']).' --> remove_rejected_by_user='.array2string($remove_rejected_by_user));
637 637
 
638 638
 		if ($this->debug && ($this->debug > 1 || $this->debug == 'search'))
639 639
 		{
640 640
 			$this->debug_message('calendar_bo::search(%1) start=%2, end=%3, daywise=%4, cat_id=%5, filter=%6, query=%7, offset=%8, num_rows=%9, order=%10, sql_filter=%11)',
641
-				True,$params,$start,$end,$daywise,$cat_id,$filter,$params['query'],$offset,(int)$params['num_rows'],$params['order'],$params['sql_filter']);
641
+				True, $params, $start, $end, $daywise, $cat_id, $filter, $params['query'], $offset, (int)$params['num_rows'], $params['order'], $params['sql_filter']);
642 642
 		}
643 643
 		// date2ts(,true) converts to server time, db2data converts again to user-time
644
-		$events =& $this->so->search(isset($start) ? $this->date2ts($start,true) : null,isset($end) ? $this->date2ts($end,true) : null,
645
-			$users,$cat_id,$filter,$offset,(int)$params['num_rows'],$params,$remove_rejected_by_user);
644
+		$events = & $this->so->search(isset($start) ? $this->date2ts($start, true) : null, isset($end) ? $this->date2ts($end, true) : null,
645
+			$users, $cat_id, $filter, $offset, (int)$params['num_rows'], $params, $remove_rejected_by_user);
646 646
 
647 647
 		if (isset($params['cols']))
648 648
 		{
649 649
 			return $events;
650 650
 		}
651 651
 		$this->total = $this->so->total;
652
-		$this->db2data($events,isset($params['date_format']) ? $params['date_format'] : 'ts');
652
+		$this->db2data($events, isset($params['date_format']) ? $params['date_format'] : 'ts');
653 653
 
654 654
 		//echo "<p align=right>remove_rejected_by_user=$remove_rejected_by_user, filter=$filter, params[users]=".print_r($param['users'])."</p>\n";
655
-		foreach($events as $id => $event)
655
+		foreach ($events as $id => $event)
656 656
 		{
657 657
 			if ($params['enum_groups'] && $this->enum_groups($event))
658 658
 			{
659 659
 				$events[$id] = $event;
660 660
 			}
661 661
 			$matches = null;
662
-			if (!(int)$event['id'] && preg_match('/^([a-z_]+)([0-9]+)$/',$event['id'],$matches))
662
+			if (!(int)$event['id'] && preg_match('/^([a-z_]+)([0-9]+)$/', $event['id'], $matches))
663 663
 			{
664
-				$is_private = self::integration_get_private($matches[1],$matches[2],$event);
664
+				$is_private = self::integration_get_private($matches[1], $matches[2], $event);
665 665
 			}
666 666
 			else
667 667
 			{
668
-				$is_private = !$this->check_perms(Acl::READ,$event);
668
+				$is_private = !$this->check_perms(Acl::READ, $event);
669 669
 			}
670 670
 			if (!$params['ignore_acl'] && ($is_private || (!$event['public'] && $filter == 'hideprivate')))
671 671
 			{
672
-				$this->clear_private_infos($events[$id],$users);
672
+				$this->clear_private_infos($events[$id], $users);
673 673
 			}
674 674
 		}
675 675
 
@@ -677,18 +677,18 @@  discard block
 block discarded – undo
677 677
 		{
678 678
 			if ($this->debug && ($this->debug > 2 || $this->debug == 'search'))
679 679
 			{
680
-				$this->debug_message('socalendar::search daywise sorting from %1 to %2 of %3',False,$start,$end,$events);
680
+				$this->debug_message('socalendar::search daywise sorting from %1 to %2 of %3', False, $start, $end, $events);
681 681
 			}
682 682
 			// create empty entries for each day in the reported time
683
-			for($ts = $start; $ts <= $end; $ts += DAY_s) // good enough for array creation, but see while loop below.
683
+			for ($ts = $start; $ts <= $end; $ts += DAY_s) // good enough for array creation, but see while loop below.
684 684
 			{
685 685
 				$daysEvents[$this->date2string($ts)] = array();
686 686
 			}
687
-			foreach($events as $k => $event)
687
+			foreach ($events as $k => $event)
688 688
 			{
689
-				$e_start = max($this->date2ts($event['start']),$start);
689
+				$e_start = max($this->date2ts($event['start']), $start);
690 690
 				// $event['end']['raw']-1 to allow events to end on a full hour/day without the need to enter it as minute=59
691
-				$e_end   = min($this->date2ts($event['end'])-1,$end);
691
+				$e_end   = min($this->date2ts($event['end']) - 1, $end);
692 692
 
693 693
 				// add event to each day in the reported time
694 694
 				$ts = $e_start;
@@ -697,23 +697,23 @@  discard block
 block discarded – undo
697 697
 				$ymd = null;
698 698
 				while ($ts <= $e_end)
699 699
 				{
700
-					$daysEvents[$ymd = $this->date2string($ts)][] =& $events[$k];
701
-					$ts = strtotime("+1 day",$ts);
700
+					$daysEvents[$ymd = $this->date2string($ts)][] = & $events[$k];
701
+					$ts = strtotime("+1 day", $ts);
702 702
 				}
703 703
 				if ($ymd != ($last = $this->date2string($e_end)))
704 704
 				{
705
-					$daysEvents[$last][] =& $events[$k];
705
+					$daysEvents[$last][] = & $events[$k];
706 706
 				}
707 707
 			}
708
-			$events =& $daysEvents;
708
+			$events = & $daysEvents;
709 709
 			if ($this->debug && ($this->debug > 2 || $this->debug == 'search'))
710 710
 			{
711
-				$this->debug_message('socalendar::search daywise events=%1',False,$events);
711
+				$this->debug_message('socalendar::search daywise events=%1', False, $events);
712 712
 			}
713 713
 		}
714 714
 		if ($this->debug && ($this->debug > 0 || $this->debug == 'search'))
715 715
 		{
716
-			$this->debug_message('calendar_bo::search(%1)=%2',True,$params,$events);
716
+			$this->debug_message('calendar_bo::search(%1)=%2', True, $params, $events);
717 717
 		}
718 718
 		//error_log(__METHOD__."() returning ".count($events)." entries, total=$this->total ".function_backtrace());
719 719
 		return $events;
@@ -726,9 +726,9 @@  discard block
 block discarded – undo
726 726
 	 * @param string $part
727 727
 	 * @return array
728 728
 	 */
729
-	static function integration_get_data($app,$part=null)
729
+	static function integration_get_data($app, $part = null)
730 730
 	{
731
-		static $integration_data=null;
731
+		static $integration_data = null;
732 732
 
733 733
 		if (!isset($integration_data))
734 734
 		{
@@ -750,14 +750,14 @@  discard block
 block discarded – undo
750 750
 	 * @param int|string $id
751 751
 	 * @return string
752 752
 	 */
753
-	static function integration_get_private($app,$id,$event)
753
+	static function integration_get_private($app, $id, $event)
754 754
 	{
755
-		$app_data = self::integration_get_data($app,'is_private');
755
+		$app_data = self::integration_get_data($app, 'is_private');
756 756
 
757 757
 		// no method, fall back to link title
758 758
 		if (is_null($app_data))
759 759
 		{
760
-			$is_private = !Link::title($app,$id);
760
+			$is_private = !Link::title($app, $id);
761 761
 		}
762 762
 		// boolean value to make all events of $app public (false) or private (true)
763 763
 		elseif (is_bool($app_data))
@@ -766,7 +766,7 @@  discard block
 block discarded – undo
766 766
 		}
767 767
 		else
768 768
 		{
769
-			$is_private = (bool)ExecMethod2($app_data,$id,$event);
769
+			$is_private = (bool)ExecMethod2($app_data, $id, $event);
770 770
 		}
771 771
 		//echo '<p>'.__METHOD__."($app,$id,) app_data=".array2string($app_data).' returning '.array2string($is_private)."</p>\n";
772 772
 		return $is_private;
@@ -780,7 +780,7 @@  discard block
 block discarded – undo
780 780
 	 * @param array &$event
781 781
 	 * @param array $allowed_participants ids of the allowed participants, eg. the ones the search is over or eg. the owner of the calendar
782 782
 	 */
783
-	function clear_private_infos(&$event,$allowed_participants = array())
783
+	function clear_private_infos(&$event, $allowed_participants = array())
784 784
 	{
785 785
 		if ($event == false) return;
786 786
 		if (!is_array($event['participants'])) error_log(__METHOD__.'('.array2string($event).', '.array2string($allowed_participants).') NO PARTICIPANTS '.function_backtrace());
@@ -796,19 +796,19 @@  discard block
 block discarded – undo
796 796
 			'owner'		=> $event['owner'],
797 797
 			'uid'	=> $event['uid'],
798 798
 			'etag'	=> $event['etag'],
799
-			'participants' => array_intersect_key($event['participants'],array_flip($allowed_participants)),
799
+			'participants' => array_intersect_key($event['participants'], array_flip($allowed_participants)),
800 800
 			'public'=> 0,
801
-			'category' => $event['category'],	// category is visible anyway, eg. by using planner by cat
801
+			'category' => $event['category'], // category is visible anyway, eg. by using planner by cat
802 802
 			'non_blocking' => $event['non_blocking'],
803 803
 			'caldav_name' => $event['caldav_name'],
804 804
 		// we need full recurrence information, as they are relevant free/busy information
805
-		)+($event['recur_type'] ? array(
805
+		) + ($event['recur_type'] ? array(
806 806
 			'recur_type'     => $event['recur_type'],
807 807
 			'recur_interval' => $event['recur_interval'],
808 808
 			'recur_data'     => $event['recur_data'],
809 809
 			'recur_enddate'  => $event['recur_enddate'],
810 810
 			'recur_exception'=> $event['recur_exception'],
811
-		):array(
811
+		) : array(
812 812
 			'reference'      => $event['reference'],
813 813
 			'recurrence'     => $event['recurrence'],
814 814
 		));
@@ -822,15 +822,15 @@  discard block
 block discarded – undo
822 822
 	 */
823 823
 	function check_move_horizont($_new_horizont)
824 824
 	{
825
-		if ((int) $this->debug >= 2 || $this->debug == 'check_move_horizont')
825
+		if ((int)$this->debug >= 2 || $this->debug == 'check_move_horizont')
826 826
 		{
827
-			$this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2',true,$_new_horizont,(int)$this->config['horizont']);
827
+			$this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2', true, $_new_horizont, (int)$this->config['horizont']);
828 828
 		}
829
-		$new_horizont = $this->date2ts($_new_horizont,true);	// now we are in server-time, where this function operates
829
+		$new_horizont = $this->date2ts($_new_horizont, true); // now we are in server-time, where this function operates
830 830
 
831 831
 		if ($new_horizont <= $this->config['horizont'])	// no move necessary
832 832
 		{
833
-			if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2 is bigger ==> nothing to do',true,$new_horizont,(int)$this->config['horizont']);
833
+			if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2 is bigger ==> nothing to do', true, $new_horizont, (int)$this->config['horizont']);
834 834
 			return;
835 835
 		}
836 836
 		if (!empty($GLOBALS['egw_info']['server']['calendar_horizont']))
@@ -838,15 +838,15 @@  discard block
 block discarded – undo
838 838
 			$maxdays = abs($GLOBALS['egw_info']['server']['calendar_horizont']);
839 839
 		}
840 840
 		if (empty($maxdays)) $maxdays = 1000; // old default
841
-		if ($new_horizont > time()+$maxdays*DAY_s)		// some user tries to "look" more then the maximum number of days in the future
841
+		if ($new_horizont > time() + $maxdays * DAY_s)		// some user tries to "look" more then the maximum number of days in the future
842 842
 		{
843
-			if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2 new horizont more then %3 days from now --> ignoring it',true,$new_horizont,(int)$this->config['horizont'],$maxdays);
844
-			$this->warnings['horizont'] = lang('Requested date %1 outside allowed range of %2 days: recurring events obmitted!', Api\DateTime::to($new_horizont,true), $maxdays);
843
+			if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) horizont=%2 new horizont more then %3 days from now --> ignoring it', true, $new_horizont, (int)$this->config['horizont'], $maxdays);
844
+			$this->warnings['horizont'] = lang('Requested date %1 outside allowed range of %2 days: recurring events obmitted!', Api\DateTime::to($new_horizont, true), $maxdays);
845 845
 			return;
846 846
 		}
847
-		if ($new_horizont < time()+31*DAY_s)
847
+		if ($new_horizont < time() + 31 * DAY_s)
848 848
 		{
849
-			$new_horizont = time()+31*DAY_s;
849
+			$new_horizont = time() + 31 * DAY_s;
850 850
 		}
851 851
 		$old_horizont = $this->config['horizont'];
852 852
 		$this->config['horizont'] = $new_horizont;
@@ -854,21 +854,21 @@  discard block
 block discarded – undo
854 854
 		// create further recurrences for all recurring and not yet (at the old horizont) ended events
855 855
 		if (($recuring = $this->so->unfinished_recuring($old_horizont)))
856 856
 		{
857
-			@set_time_limit(0);	// disable time-limit, in case it takes longer to calculate the recurrences
858
-			foreach($this->read(array_keys($recuring)) as $cal_id => $event)
857
+			@set_time_limit(0); // disable time-limit, in case it takes longer to calculate the recurrences
858
+			foreach ($this->read(array_keys($recuring)) as $cal_id => $event)
859 859
 			{
860 860
 				if ($this->debug == 'check_move_horizont')
861 861
 				{
862
-					$this->debug_message('calendar_bo::check_move_horizont(%1): calling set_recurrences(%2,%3)',true,$new_horizont,$event,$old_horizont);
862
+					$this->debug_message('calendar_bo::check_move_horizont(%1): calling set_recurrences(%2,%3)', true, $new_horizont, $event, $old_horizont);
863 863
 				}
864 864
 				// insert everything behind max(cal_start), which can be less then $old_horizont because of bugs in the past
865
-				$this->set_recurrences($event,Api\DateTime::server2user($recuring[$cal_id]+1));	// set_recurences operates in user-time!
865
+				$this->set_recurrences($event, Api\DateTime::server2user($recuring[$cal_id] + 1)); // set_recurences operates in user-time!
866 866
 			}
867 867
 		}
868 868
 		// update the horizont
869
-		Api\Config::save_value('horizont',$this->config['horizont'],'calendar');
869
+		Api\Config::save_value('horizont', $this->config['horizont'], 'calendar');
870 870
 
871
-		if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) new horizont=%2, exiting',true,$new_horizont,(int)$this->config['horizont']);
871
+		if ($this->debug == 'check_move_horizont') $this->debug_message('calendar_bo::check_move_horizont(%1) new horizont=%2, exiting', true, $new_horizont, (int)$this->config['horizont']);
872 872
 	}
873 873
 
874 874
 	/**
@@ -879,11 +879,11 @@  discard block
 block discarded – undo
879 879
 	 * @param array $event
880 880
 	 * @param mixed $start =0 minimum start-time for new recurrences or !$start = since the start of the event
881 881
 	 */
882
-	function set_recurrences($event,$start=0)
882
+	function set_recurrences($event, $start = 0)
883 883
 	{
884
-		if ($this->debug && ((int) $this->debug >= 2 || $this->debug == 'set_recurrences' || $this->debug == 'check_move_horizont'))
884
+		if ($this->debug && ((int)$this->debug >= 2 || $this->debug == 'set_recurrences' || $this->debug == 'check_move_horizont'))
885 885
 		{
886
-			$this->debug_message('calendar_bo::set_recurrences(%1,%2)',true,$event,$start);
886
+			$this->debug_message('calendar_bo::set_recurrences(%1,%2)', true, $event, $start);
887 887
 		}
888 888
 		// check if the caller gave us enough information and if not read it from the DB
889 889
 		if (!isset($event['participants']) || !isset($event['start']) || !isset($event['end']))
@@ -904,29 +904,29 @@  discard block
 block discarded – undo
904 904
 		$read_start = new Api\DateTime($event_read['start']);
905 905
 
906 906
 		$events = array();
907
-		$this->insert_all_recurrences($event,$start,$this->date2usertime($this->config['horizont']),$events);
907
+		$this->insert_all_recurrences($event, $start, $this->date2usertime($this->config['horizont']), $events);
908 908
 
909 909
 		$exceptions = array();
910
-		foreach((array)$event['recur_exception'] as $exception)
910
+		foreach ((array)$event['recur_exception'] as $exception)
911 911
 		{
912
-			$exceptions[] = Api\DateTime::to($exception, true);	// true = date
912
+			$exceptions[] = Api\DateTime::to($exception, true); // true = date
913 913
 		}
914
-		foreach($events as $event)
914
+		foreach ($events as $event)
915 915
 		{
916 916
 			$is_exception = in_array(Api\DateTime::to($event['start'], true), $exceptions);
917
-			$start = $this->date2ts($event['start'],true);
917
+			$start = $this->date2ts($event['start'], true);
918 918
 			if ($event['whole_day'])
919 919
 			{
920 920
 				$start = new Api\DateTime($event['start'], Api\DateTime::$server_timezone);
921
-				$start->setTime(0,0,0);
921
+				$start->setTime(0, 0, 0);
922 922
 				$start = $start->format('ts');
923 923
 				$time = $this->so->startOfDay(new Api\DateTime($event['end'], Api\DateTime::$user_timezone));
924 924
 				$time->setTime(23, 59, 59);
925
-				$end = $this->date2ts($time,true);
925
+				$end = $this->date2ts($time, true);
926 926
 			}
927 927
 			else
928 928
 			{
929
-				$end = $this->date2ts($event['end'],true);
929
+				$end = $this->date2ts($event['end'], true);
930 930
 			}
931 931
 			//error_log(__METHOD__."() start=".Api\DateTime::to($start).", is_exception=".array2string($is_exception));
932 932
 			$this->so->recurrence($event['id'], $start, $end, $event['participants'], $is_exception);
@@ -942,7 +942,7 @@  discard block
 block discarded – undo
942 942
 	 * @param array &$events array of event-arrays (reference)
943 943
 	 * @param $date_format ='ts' date-formats: 'ts'=timestamp, 'server'=timestamp in server-time, 'array'=array or string with date-format
944 944
 	 */
945
-	function db2data(&$events,$date_format='ts')
945
+	function db2data(&$events, $date_format = 'ts')
946 946
 	{
947 947
 		if (!is_array($events)) echo "<p>calendar_bo::db2data(\$events,$date_format) \$events is no array<br />\n".function_backtrace()."</p>\n";
948 948
 		foreach ($events as &$event)
@@ -955,65 +955,65 @@  discard block
 block discarded – undo
955 955
 			// database returns timestamps as string, convert them to integer
956 956
 			// to avoid misinterpretation by Api\DateTime as Ymd string
957 957
 			// (this will fail on 32bit systems for times > 2038!)
958
-			$event['start'] = (int)$event['start'];	// this is for isWholeDay(), which also calls Api\DateTime
958
+			$event['start'] = (int)$event['start']; // this is for isWholeDay(), which also calls Api\DateTime
959 959
 			$event['end'] = (int)$event['end'];
960 960
 			$event['whole_day'] = self::isWholeDay($event);
961 961
 			if ($event['whole_day'] && $date_format != 'server')
962 962
 			{
963 963
 				// Adjust dates to user TZ
964
-				$stime =& $this->so->startOfDay(new Api\DateTime((int)$event['start'], Api\DateTime::$server_timezone), $event['tzid']);
964
+				$stime = & $this->so->startOfDay(new Api\DateTime((int)$event['start'], Api\DateTime::$server_timezone), $event['tzid']);
965 965
 				$event['start'] = Api\DateTime::to($stime, $date_format);
966
-				$time =& $this->so->startOfDay(new Api\DateTime((int)$event['end'], Api\DateTime::$server_timezone), $event['tzid']);
966
+				$time = & $this->so->startOfDay(new Api\DateTime((int)$event['end'], Api\DateTime::$server_timezone), $event['tzid']);
967 967
 				$time->setTime(23, 59, 59);
968 968
 				$event['end'] = Api\DateTime::to($time, $date_format);
969 969
 				if (!empty($event['recurrence']))
970 970
 				{
971
-					$time =& $this->so->startOfDay(new Api\DateTime((int)$event['recurrence'], Api\DateTime::$server_timezone), $event['tzid']);
971
+					$time = & $this->so->startOfDay(new Api\DateTime((int)$event['recurrence'], Api\DateTime::$server_timezone), $event['tzid']);
972 972
 					$event['recurrence'] = Api\DateTime::to($time, $date_format);
973 973
 				}
974 974
 				if (!empty($event['recur_enddate']))
975 975
 				{
976
-					$time =& $this->so->startOfDay(new Api\DateTime((int)$event['recur_enddate'], Api\DateTime::$server_timezone), $event['tzid']);
976
+					$time = & $this->so->startOfDay(new Api\DateTime((int)$event['recur_enddate'], Api\DateTime::$server_timezone), $event['tzid']);
977 977
 					$time->setTime(23, 59, 59);
978 978
 					$event['recur_enddate'] = Api\DateTime::to($time, $date_format);
979 979
 				}
980
-				$timestamps = array('modified','created','deleted');
980
+				$timestamps = array('modified', 'created', 'deleted');
981 981
 			}
982 982
 			else
983 983
 			{
984
-				$timestamps = array('start','end','modified','created','recur_enddate','recurrence','recur_date','deleted');
984
+				$timestamps = array('start', 'end', 'modified', 'created', 'recur_enddate', 'recurrence', 'recur_date', 'deleted');
985 985
 			}
986 986
 			// we convert here from the server-time timestamps to user-time and (optional) to a different date-format!
987 987
 			foreach ($timestamps as $ts)
988 988
 			{
989 989
 				if (!empty($event[$ts]))
990 990
 				{
991
-					$event[$ts] = $this->date2usertime((int)$event[$ts],$date_format);
991
+					$event[$ts] = $this->date2usertime((int)$event[$ts], $date_format);
992 992
 				}
993 993
 			}
994 994
 			// same with the recur exceptions
995 995
 			if (isset($event['recur_exception']) && is_array($event['recur_exception']))
996 996
 			{
997
-				foreach($event['recur_exception'] as &$date)
997
+				foreach ($event['recur_exception'] as &$date)
998 998
 				{
999 999
 					if ($event['whole_day'] && $date_format != 'server')
1000 1000
 					{
1001 1001
 						// Adjust dates to user TZ
1002
-						$time =& $this->so->startOfDay(new Api\DateTime((int)$date, Api\DateTime::$server_timezone), $event['tzid']);
1002
+						$time = & $this->so->startOfDay(new Api\DateTime((int)$date, Api\DateTime::$server_timezone), $event['tzid']);
1003 1003
 						$date = Api\DateTime::to($time, $date_format);
1004 1004
 					}
1005 1005
 					else
1006 1006
 					{
1007
-						$date = $this->date2usertime((int)$date,$date_format);
1007
+						$date = $this->date2usertime((int)$date, $date_format);
1008 1008
 					}
1009 1009
 				}
1010 1010
 			}
1011 1011
 			// same with the alarms
1012 1012
 			if (isset($event['alarm']) && is_array($event['alarm']))
1013 1013
 			{
1014
-				foreach($event['alarm'] as &$alarm)
1014
+				foreach ($event['alarm'] as &$alarm)
1015 1015
 				{
1016
-					$alarm['time'] = $this->date2usertime((int)$alarm['time'],$date_format);
1016
+					$alarm['time'] = $this->date2usertime((int)$alarm['time'], $date_format);
1017 1017
 				}
1018 1018
 			}
1019 1019
 		}
@@ -1026,11 +1026,11 @@  discard block
 block discarded – undo
1026 1026
 	 * @param string $date_format ='ts' date-formats: 'ts'=timestamp, 'server'=timestamp in server-time, 'array'=array or string with date-format
1027 1027
 	 * @return mixed depending of $date_format
1028 1028
 	 */
1029
-	function date2usertime($ts,$date_format='ts')
1029
+	function date2usertime($ts, $date_format = 'ts')
1030 1030
 	{
1031 1031
 		if (empty($ts) || $date_format == 'server') return $ts;
1032 1032
 
1033
-		return Api\DateTime::server2user($ts,$date_format);
1033
+		return Api\DateTime::server2user($ts, $date_format);
1034 1034
 	}
1035 1035
 
1036 1036
 	/**
@@ -1044,7 +1044,7 @@  discard block
 block discarded – undo
1044 1044
 	 * 	but call clear_private_infos() with the given users
1045 1045
 	 * @return boolean|array event or array of id => event pairs, false if the acl-check went wrong, null if $ids not found
1046 1046
 	 */
1047
-	function read($ids,$date=null,$ignore_acl=False,$date_format='ts',$clear_private_infos_users=null)
1047
+	function read($ids, $date = null, $ignore_acl = False, $date_format = 'ts', $clear_private_infos_users = null)
1048 1048
 	{
1049 1049
 		if (!$ids) return false;
1050 1050
 
@@ -1053,21 +1053,21 @@  discard block
 block discarded – undo
1053 1053
 		$return = null;
1054 1054
 
1055 1055
 		$check = $clear_private_infos_users ? self::ACL_FREEBUSY : Acl::READ;
1056
-		if ($ignore_acl || is_array($ids) || ($return = $this->check_perms($check,$ids,0,$date_format,$date)))
1056
+		if ($ignore_acl || is_array($ids) || ($return = $this->check_perms($check, $ids, 0, $date_format, $date)))
1057 1057
 		{
1058 1058
 			if (is_array($ids) || !isset(self::$cached_event['id']) || self::$cached_event['id'] != $ids ||
1059 1059
 				self::$cached_event_date_format != $date_format ||
1060 1060
 				self::$cached_event['recur_type'] != MCAL_RECUR_NONE && self::$cached_event_date != $date)
1061 1061
 			{
1062
-				$events = $this->so->read($ids,$date ? $this->date2ts($date,true) : 0);
1062
+				$events = $this->so->read($ids, $date ? $this->date2ts($date, true) : 0);
1063 1063
 
1064 1064
 				if ($events)
1065 1065
 				{
1066
-					$this->db2data($events,$date_format);
1066
+					$this->db2data($events, $date_format);
1067 1067
 
1068 1068
 					if (is_array($ids))
1069 1069
 					{
1070
-						$return =& $events;
1070
+						$return = & $events;
1071 1071
 					}
1072 1072
 					else
1073 1073
 					{
@@ -1083,13 +1083,13 @@  discard block
 block discarded – undo
1083 1083
 				$return = self::$cached_event;
1084 1084
 			}
1085 1085
 		}
1086
-		if ($clear_private_infos_users && !is_array($ids) && !$this->check_perms(Acl::READ,$return))
1086
+		if ($clear_private_infos_users && !is_array($ids) && !$this->check_perms(Acl::READ, $return))
1087 1087
 		{
1088 1088
 			$this->clear_private_infos($return, (array)$clear_private_infos_users);
1089 1089
 		}
1090 1090
 		if ($this->debug && ($this->debug > 1 || $this->debug == 'read'))
1091 1091
 		{
1092
-			$this->debug_message('calendar_bo::read(%1,%2,%3,%4,%5)=%6',True,$ids,$date,$ignore_acl,$date_format,$clear_private_infos_users,$return);
1092
+			$this->debug_message('calendar_bo::read(%1,%2,%3,%4,%5)=%6', True, $ids, $date, $ignore_acl, $date_format, $clear_private_infos_users, $return);
1093 1093
 		}
1094 1094
 		return $return;
1095 1095
 	}
@@ -1107,17 +1107,17 @@  discard block
 block discarded – undo
1107 1107
 	 * @param array $events where the repetions get inserted
1108 1108
 	 * @param array $recur_exceptions with date (in Ymd) as key (and True as values), seems not to be used anymore
1109 1109
 	 */
1110
-	function insert_all_recurrences($event,$_start,$end,&$events)
1110
+	function insert_all_recurrences($event, $_start, $end, &$events)
1111 1111
 	{
1112
-		if ((int) $this->debug >= 3 || $this->debug == 'set_recurrences' || $this->debug == 'check_move_horizont' || $this->debug == 'insert_all_recurrences')
1112
+		if ((int)$this->debug >= 3 || $this->debug == 'set_recurrences' || $this->debug == 'check_move_horizont' || $this->debug == 'insert_all_recurrences')
1113 1113
 		{
1114
-			$this->debug_message(__METHOD__.'(%1,%2,%3,&$events)',true,$event,$_start,$end);
1114
+			$this->debug_message(__METHOD__.'(%1,%2,%3,&$events)', true, $event, $_start, $end);
1115 1115
 		}
1116 1116
 		$end_in = $end;
1117 1117
 
1118 1118
 		$start = $this->date2ts($_start);
1119 1119
 		$event_start_ts = $this->date2ts($event['start']);
1120
-		$event_length = $this->date2ts($event['end']) - $event_start_ts;	// we use a constant event-length, NOT a constant end-time!
1120
+		$event_length = $this->date2ts($event['end']) - $event_start_ts; // we use a constant event-length, NOT a constant end-time!
1121 1121
 
1122 1122
 		// if $end is before recur_enddate, use it instead
1123 1123
 		if (!$event['recur_enddate'] || $this->date2ts($event['recur_enddate']) > $this->date2ts($end))
@@ -1126,39 +1126,38 @@  discard block
 block discarded – undo
1126 1126
 			// insert at least the event itself, if it's behind the horizont
1127 1127
 			$event['recur_enddate'] = $this->date2ts($end) < $this->date2ts($event['end']) ? $event['end'] : $end;
1128 1128
 		}
1129
-		$event['recur_enddate'] = is_a($event['recur_enddate'],'DateTime') ?
1130
-				$event['recur_enddate'] :
1131
-				new Api\DateTime($event['recur_enddate'], calendar_timezones::DateTimeZone($event['tzid']));
1129
+		$event['recur_enddate'] = is_a($event['recur_enddate'], 'DateTime') ?
1130
+				$event['recur_enddate'] : new Api\DateTime($event['recur_enddate'], calendar_timezones::DateTimeZone($event['tzid']));
1132 1131
 		// unset exceptions, as we need to add them as recurrence too, but marked as exception
1133 1132
 		unset($event['recur_exception']);
1134 1133
 		// loop over all recurrences and insert them, if they are after $start
1135
- 		$rrule = calendar_rrule::event2rrule($event, !$event['whole_day'], Api\DateTime::$user_timezone->getName());	// true = we operate in usertime, like the rest of calendar_bo
1136
-		foreach($rrule as $time)
1134
+ 		$rrule = calendar_rrule::event2rrule($event, !$event['whole_day'], Api\DateTime::$user_timezone->getName()); // true = we operate in usertime, like the rest of calendar_bo
1135
+		foreach ($rrule as $time)
1137 1136
 		{
1138
-			$time->setUser();	// $time is in timezone of event, convert it to usertime used here
1139
-			if($event['whole_day'])
1137
+			$time->setUser(); // $time is in timezone of event, convert it to usertime used here
1138
+			if ($event['whole_day'])
1140 1139
 			{
1141 1140
 				// All day events are processed in server timezone
1142 1141
 				$time->setServer();
1143
-				$time->setTime(0,0,0);
1142
+				$time->setTime(0, 0, 0);
1144 1143
 			}
1145
-			if (($ts = $this->date2ts($time)) < $start-$event_length)
1144
+			if (($ts = $this->date2ts($time)) < $start - $event_length)
1146 1145
 			{
1147 1146
 				//echo "<p>".$time." --> ignored as $ts < $start-$event_length</p>\n";
1148
-				continue;	// to early or original event (returned by interator too)
1147
+				continue; // to early or original event (returned by interator too)
1149 1148
 			}
1150 1149
 
1151 1150
 			$ts_end = $ts + $event_length;
1152 1151
 			// adjust ts_end for whole day events in case it does not fit due to
1153 1152
 			// spans over summer/wintertime adjusted days
1154
-			if($event['whole_day'] && ($arr_end = $this->date2array($ts_end)) &&
1153
+			if ($event['whole_day'] && ($arr_end = $this->date2array($ts_end)) &&
1155 1154
 				!($arr_end['hour'] == 23 && $arr_end['minute'] == 59 && $arr_end['second'] == 59))
1156 1155
 			{
1157 1156
 				$arr_end['hour'] = 23;
1158 1157
 				$arr_end['minute'] = 59;
1159 1158
 				$arr_end['second'] = 59;
1160 1159
 				$ts_end_guess = $this->date2ts($arr_end);
1161
-				if($ts_end_guess - $ts_end > DAY_s/2)
1160
+				if ($ts_end_guess - $ts_end > DAY_s / 2)
1162 1161
 				{
1163 1162
 					$ts_end = $ts_end_guess - DAY_s; // $ts_end_guess was one day too far in the future
1164 1163
 				}
@@ -1172,11 +1171,11 @@  discard block
 block discarded – undo
1172 1171
 			$event['end'] = $ts_end;
1173 1172
 			$events[] = $event;
1174 1173
 		}
1175
-		if ($this->debug && ((int) $this->debug > 2 || $this->debug == 'set_recurrences' || $this->debug == 'check_move_horizont' || $this->debug == 'insert_all_recurrences'))
1174
+		if ($this->debug && ((int)$this->debug > 2 || $this->debug == 'set_recurrences' || $this->debug == 'check_move_horizont' || $this->debug == 'insert_all_recurrences'))
1176 1175
 		{
1177 1176
 			$event['start'] = $event_start_ts;
1178 1177
 			$event['end'] = $event_start_ts + $event_length;
1179
-			$this->debug_message(__METHOD__.'(%1,start=%2,end=%3,events) events=%5',True,$event,$_start,$end_in,$events);
1178
+			$this->debug_message(__METHOD__.'(%1,start=%2,end=%3,events) events=%5', True, $event, $_start, $end_in, $events);
1180 1179
 		}
1181 1180
 	}
1182 1181
 
@@ -1187,18 +1186,18 @@  discard block
 block discarded – undo
1187 1186
 	 * @param array $event event to insert, it has start- and end-date of the first recurrence, not of $date_ymd
1188 1187
 	 * @param int|string $date_ymd of the date of the event
1189 1188
 	 */
1190
-	function add_adjusted_event(&$events,$event,$date_ymd)
1189
+	function add_adjusted_event(&$events, $event, $date_ymd)
1191 1190
 	{
1192 1191
 		$event_in = $event;
1193 1192
 		// calculate the new start- and end-time
1194 1193
 		$length_s = $this->date2ts($event['end']) - $this->date2ts($event['start']);
1195 1194
 		$event_start_arr = $this->date2array($event['start']);
1196 1195
 
1197
-		$date_arr = $this->date2array((string) $date_ymd);
1196
+		$date_arr = $this->date2array((string)$date_ymd);
1198 1197
 		$date_arr['hour'] = $event_start_arr['hour'];
1199 1198
 		$date_arr['minute'] = $event_start_arr['minute'];
1200 1199
 		$date_arr['second'] = $event_start_arr['second'];
1201
-		unset($date_arr['raw']);	// else date2ts would use it
1200
+		unset($date_arr['raw']); // else date2ts would use it
1202 1201
 		$event['start'] = $this->date2ts($date_arr);
1203 1202
 		$event['end'] = $event['start'] + $length_s;
1204 1203
 
@@ -1206,7 +1205,7 @@  discard block
 block discarded – undo
1206 1205
 
1207 1206
 		if ($this->debug && ($this->debug > 2 || $this->debug == 'add_adjust_event'))
1208 1207
 		{
1209
-			$this->debug_message('calendar_bo::add_adjust_event(,%1,%2) as %3',True,$event_in,$date_ymd,$event);
1208
+			$this->debug_message('calendar_bo::add_adjust_event(,%1,%2) as %3', True, $event_in, $date_ymd, $event);
1210 1209
 		}
1211 1210
 	}
1212 1211
 
@@ -1230,22 +1229,22 @@  discard block
 block discarded – undo
1230 1229
 			{
1231 1230
 				$info = array(
1232 1231
 					'res_id'    => $uid,
1233
-					'email' => $GLOBALS['egw']->accounts->id2name($uid,'account_email'),
1234
-					'name'  => trim($GLOBALS['egw']->accounts->id2name($uid,'account_firstname'). ' ' .
1235
-					$GLOBALS['egw']->accounts->id2name($uid,'account_lastname')),
1232
+					'email' => $GLOBALS['egw']->accounts->id2name($uid, 'account_email'),
1233
+					'name'  => trim($GLOBALS['egw']->accounts->id2name($uid, 'account_firstname').' '.
1234
+					$GLOBALS['egw']->accounts->id2name($uid, 'account_lastname')),
1236 1235
 					'type'  => $GLOBALS['egw']->accounts->get_type($uid),
1237 1236
 					'app'   => 'accounts',
1238 1237
 				);
1239 1238
 			}
1240 1239
 			else
1241 1240
 			{
1242
-				list($info) = $this->resources[$uid[0]]['info'] ? ExecMethod($this->resources[$uid[0]]['info'],substr($uid,1)) : false;
1241
+				list($info) = $this->resources[$uid[0]]['info'] ? ExecMethod($this->resources[$uid[0]]['info'], substr($uid, 1)) : false;
1243 1242
 				if ($info)
1244 1243
 				{
1245 1244
 					$info['type'] = $uid[0];
1246 1245
 					if (!$info['email'] && $info['responsible'])
1247 1246
 					{
1248
-						$info['email'] = $GLOBALS['egw']->accounts->id2name($info['responsible'],'account_email');
1247
+						$info['email'] = $GLOBALS['egw']->accounts->id2name($info['responsible'], 'account_email');
1249 1248
 					}
1250 1249
 					$info['app'] = $this->resources[$uid[0]]['app'];
1251 1250
 				}
@@ -1254,7 +1253,7 @@  discard block
 block discarded – undo
1254 1253
 		}
1255 1254
 		if ($this->debug && ($this->debug > 2 || $this->debug == 'resource_info'))
1256 1255
 		{
1257
-			$this->debug_message('calendar_bo::resource_info(%1) = %2',True,$uid,$res_info_cache[$uid]);
1256
+			$this->debug_message('calendar_bo::resource_info(%1) = %2', True, $uid, $res_info_cache[$uid]);
1258 1257
 		}
1259 1258
 		return $res_info_cache[$uid];
1260 1259
 	}
@@ -1275,7 +1274,7 @@  discard block
 block discarded – undo
1275 1274
 	 * @param int $user =null for which user to check, default current user
1276 1275
 	 * @return boolean true permission granted, false for permission denied or null if event not found
1277 1276
 	 */
1278
-	function check_perms($needed,$event=0,$other=0,$date_format='ts',$date_to_read=null,$user=null)
1277
+	function check_perms($needed, $event = 0, $other = 0, $date_format = 'ts', $date_to_read = null, $user = null)
1279 1278
 	{
1280 1279
 		if (!$user) $user = $this->user;
1281 1280
 		if ($user == $this->user)
@@ -1284,13 +1283,13 @@  discard block
 block discarded – undo
1284 1283
 		}
1285 1284
 		else
1286 1285
 		{
1287
-			$grants = $GLOBALS['egw']->acl->get_grants('calendar',true,$user);
1286
+			$grants = $GLOBALS['egw']->acl->get_grants('calendar', true, $user);
1288 1287
 		}
1289 1288
 
1290 1289
 		if ($other && !is_numeric($other))
1291 1290
 		{
1292 1291
 			$resource = $this->resource_info($other);
1293
-			return $needed & $resource['rights'];
1292
+			return $needed&$resource['rights'];
1294 1293
 		}
1295 1294
 		if (is_int($event) && $event == 0)
1296 1295
 		{
@@ -1300,15 +1299,15 @@  discard block
 block discarded – undo
1300 1299
 		{
1301 1300
 			if (!is_array($event))
1302 1301
 			{
1303
-				$event = $this->read($event,$date_to_read,true,$date_format);	// = no ACL check !!!
1302
+				$event = $this->read($event, $date_to_read, true, $date_format); // = no ACL check !!!
1304 1303
 			}
1305 1304
 			if (!is_array($event))
1306 1305
 			{
1307 1306
 				if ($this->xmlrpc)
1308 1307
 				{
1309
-					$GLOBALS['server']->xmlrpc_error($GLOBALS['xmlrpcerr']['not_exist'],$GLOBALS['xmlrpcstr']['not_exist']);
1308
+					$GLOBALS['server']->xmlrpc_error($GLOBALS['xmlrpcerr']['not_exist'], $GLOBALS['xmlrpcstr']['not_exist']);
1310 1309
 				}
1311
-				return null;	// event not found
1310
+				return null; // event not found
1312 1311
 			}
1313 1312
 			$owner = $event['owner'];
1314 1313
 			$private = !$event['public'];
@@ -1316,7 +1315,7 @@  discard block
 block discarded – undo
1316 1315
 		$grant = $grants[$owner];
1317 1316
 
1318 1317
 		// now any ACL rights (but invite rights!) implicate FREEBUSY rights (at least READ has to include FREEBUSY)
1319
-		if ($grant & ~self::ACL_INVITE) $grant |= self::ACL_FREEBUSY;
1318
+		if ($grant&~self::ACL_INVITE) $grant |= self::ACL_FREEBUSY;
1320 1319
 
1321 1320
 		if (is_array($event) && ($needed == Acl::READ || $needed == self::ACL_FREEBUSY))
1322 1321
 		{
@@ -1325,15 +1324,15 @@  discard block
 block discarded – undo
1325 1324
 			//
1326 1325
 			if ($event['participants'] && is_array($event['participants']))
1327 1326
 			{
1328
-				foreach(array_keys($event['participants']) as $uid)
1327
+				foreach (array_keys($event['participants']) as $uid)
1329 1328
 				{
1330
-					if ($uid == $user || $uid < 0 && in_array($user, (array)$GLOBALS['egw']->accounts->members($uid,true)))
1329
+					if ($uid == $user || $uid < 0 && in_array($user, (array)$GLOBALS['egw']->accounts->members($uid, true)))
1331 1330
 					{
1332 1331
 						// if we are a participant, we have an implicite FREEBUSY, READ and PRIVAT grant
1333
-						$grant |= self::ACL_FREEBUSY | Acl::READ | Acl::PRIVAT;
1332
+						$grant |= self::ACL_FREEBUSY|Acl::READ|Acl::PRIVAT;
1334 1333
 						break;
1335 1334
 					}
1336
-					elseif ($grants[$uid] & Acl::READ)
1335
+					elseif ($grants[$uid]&Acl::READ)
1337 1336
 					{
1338 1337
 						// if we have a READ grant from a participant, we dont give an implicit privat grant too
1339 1338
 						$grant |= Acl::READ;
@@ -1352,12 +1351,12 @@  discard block
 block discarded – undo
1352 1351
 		}
1353 1352
 		if ($GLOBALS['egw']->accounts->get_type($owner) == 'g' && $needed == Acl::ADD)
1354 1353
 		{
1355
-			$access = False;	// a group can't be the owner of an event
1354
+			$access = False; // a group can't be the owner of an event
1356 1355
 		}
1357 1356
 		else
1358 1357
 		{
1359
-			$access = $user == $owner || $grant & $needed
1360
-				&& ($needed == self::ACL_FREEBUSY || !$private || $grant & Acl::PRIVAT);
1358
+			$access = $user == $owner || $grant&$needed
1359
+				&& ($needed == self::ACL_FREEBUSY || !$private || $grant&Acl::PRIVAT);
1361 1360
 		}
1362 1361
 		// do NOT allow users to purge deleted events, if we dont have 'userpurge' enabled
1363 1362
 		if ($access && $needed == Acl::DELETE && $event['deleted'] &&
@@ -1368,7 +1367,7 @@  discard block
 block discarded – undo
1368 1367
 		}
1369 1368
 		if ($this->debug && ($this->debug > 2 || $this->debug == 'check_perms'))
1370 1369
 		{
1371
-			$this->debug_message('calendar_bo::check_perms(%1,%2,other=%3,%4,%5,user=%6)=%7',True,ACL_TYPE_IDENTIFER.$needed,$event,$other,$date_format,$date_to_read,$user,$access);
1370
+			$this->debug_message('calendar_bo::check_perms(%1,%2,other=%3,%4,%5,user=%6)=%7', True, ACL_TYPE_IDENTIFER.$needed, $event, $other, $date_format, $date_to_read, $user, $access);
1372 1371
 		}
1373 1372
 		//error_log(__METHOD__."($needed,".array2string($event).",$other,...,$user) returning ".array2string($access));
1374 1373
 		return $access;
@@ -1383,9 +1382,9 @@  discard block
 block discarded – undo
1383 1382
 	 *	array with keys 'second', 'minute', 'hour', 'day' or 'mday' (depricated !), 'month' and 'year'
1384 1383
 	 * @param boolean $user2server =False conversion between user- and server-time; default False == Off
1385 1384
 	 */
1386
-	static function date2ts($date,$user2server=False)
1385
+	static function date2ts($date, $user2server = False)
1387 1386
 	{
1388
-		return $user2server ? Api\DateTime::user2server($date,'ts') : Api\DateTime::to($date,'ts');
1387
+		return $user2server ? Api\DateTime::user2server($date, 'ts') : Api\DateTime::to($date, 'ts');
1389 1388
 	}
1390 1389
 
1391 1390
 	/**
@@ -1395,9 +1394,9 @@  discard block
 block discarded – undo
1395 1394
 	 * @param boolean $server2user conversation between user- and server-time default False == Off
1396 1395
 	 * @return array with keys 'second', 'minute', 'hour', 'day', 'month', 'year', 'raw' (timestamp) and 'full' (Ymd-string)
1397 1396
 	 */
1398
-	static function date2array($date,$server2user=False)
1397
+	static function date2array($date, $server2user = False)
1399 1398
 	{
1400
-		return $server2user ? Api\DateTime::server2user($date,'array') : Api\DateTime::to($date,'array');
1399
+		return $server2user ? Api\DateTime::server2user($date, 'array') : Api\DateTime::to($date, 'array');
1401 1400
 	}
1402 1401
 
1403 1402
 	/**
@@ -1408,9 +1407,9 @@  discard block
 block discarded – undo
1408 1407
 	 * @param string $format ='Ymd' format of the date to return, eg. 'Y-m-d\TH:i:sO' (2005-11-01T15:30:00+0100)
1409 1408
 	 * @return string date formatted according to $format
1410 1409
 	 */
1411
-	static function date2string($date,$server2user=False,$format='Ymd')
1410
+	static function date2string($date, $server2user = False, $format = 'Ymd')
1412 1411
 	{
1413
-		return $server2user ? Api\DateTime::server2user($date,$format) : Api\DateTime::to($date,$format);
1412
+		return $server2user ? Api\DateTime::server2user($date, $format) : Api\DateTime::to($date, $format);
1414 1413
 	}
1415 1414
 
1416 1415
 	/**
@@ -1420,9 +1419,9 @@  discard block
 block discarded – undo
1420 1419
 	 * @param string|boolean $format ='' default common_prefs[dateformat], common_prefs[timeformat], false=time only, true=date only
1421 1420
 	 * @return string the formated date (incl. time)
1422 1421
 	 */
1423
-	static function format_date($date,$format='')
1422
+	static function format_date($date, $format = '')
1424 1423
 	{
1425
-		return Api\DateTime::to($date,$format);
1424
+		return Api\DateTime::to($date, $format);
1426 1425
 	}
1427 1426
 
1428 1427
 	/**
@@ -1444,7 +1443,7 @@  discard block
 block discarded – undo
1444 1443
 	 * @param mixed $param a variable number of parameters, to be inserted in $msg
1445 1444
 	 *	arrays get serialized with print_r() !
1446 1445
 	 */
1447
-	static function debug_message($msg,$backtrace=True)
1446
+	static function debug_message($msg, $backtrace = True)
1448 1447
 	{
1449 1448
 		static $acl2string = array(
1450 1449
 			0               => 'ACL-UNKNOWN',
@@ -1455,22 +1454,22 @@  discard block
 block discarded – undo
1455 1454
 			Acl::PRIVAT => 'ACL_PRIVATE',
1456 1455
 			self::ACL_FREEBUSY => 'ACL_FREEBUSY',
1457 1456
 		);
1458
-		for($i = 2; $i < func_num_args(); ++$i)
1457
+		for ($i = 2; $i < func_num_args(); ++$i)
1459 1458
 		{
1460 1459
 			$param = func_get_arg($i);
1461 1460
 
1462 1461
 			if (is_null($param))
1463 1462
 			{
1464
-				$param='NULL';
1463
+				$param = 'NULL';
1465 1464
 			}
1466 1465
 			else
1467 1466
 			{
1468
-				switch(gettype($param))
1467
+				switch (gettype($param))
1469 1468
 				{
1470 1469
 					case 'string':
1471
-						if (substr($param,0,strlen(ACL_TYPE_IDENTIFER))== ACL_TYPE_IDENTIFER)
1470
+						if (substr($param, 0, strlen(ACL_TYPE_IDENTIFER)) == ACL_TYPE_IDENTIFER)
1472 1471
 						{
1473
-							$param = (int) substr($param,strlen(ACL_TYPE_IDENTIFER));
1472
+							$param = (int)substr($param, strlen(ACL_TYPE_IDENTIFER));
1474 1473
 							$param = (isset($acl2string[$param]) ? $acl2string[$param] : $acl2string[0])." ($param)";
1475 1474
 						}
1476 1475
 						else
@@ -1493,11 +1492,11 @@  discard block
 block discarded – undo
1493 1492
 						$param = $param ? 'True' : 'False';
1494 1493
 						break;
1495 1494
 					case 'integer':
1496
-						if ($param >= mktime(0,0,0,1,1,2000)) $param = adodb_date('Y-m-d H:i:s',$param)." ($param)";
1495
+						if ($param >= mktime(0, 0, 0, 1, 1, 2000)) $param = adodb_date('Y-m-d H:i:s', $param)." ($param)";
1497 1496
 						break;
1498 1497
 				}
1499 1498
 			}
1500
-			$msg = str_replace('%'.($i-1),$param,$msg);
1499
+			$msg = str_replace('%'.($i - 1), $param, $msg);
1501 1500
 		}
1502 1501
 		error_log($msg);
1503 1502
 		if ($backtrace) error_log(function_backtrace(1));
@@ -1512,7 +1511,7 @@  discard block
 block discarded – undo
1512 1511
 	 * @param boolean $display_day =false should a day-name prefix the date, eg. monday June 20, 2006
1513 1512
 	 * @return string with formated date
1514 1513
 	 */
1515
-	function long_date($_first,$last=0,$display_time=false,$display_day=false)
1514
+	function long_date($_first, $last = 0, $display_time = false, $display_day = false)
1516 1515
 	{
1517 1516
 		$first = $this->date2array($_first);
1518 1517
 		if ($last)
@@ -1527,27 +1526,27 @@  discard block
 block discarded – undo
1527 1526
 
1528 1527
 		if ($display_day)
1529 1528
 		{
1530
-			$range = lang(adodb_date('l',$first['raw'])).($this->common_prefs['dateformat'][0] != 'd' ? ' ' : ', ');
1529
+			$range = lang(adodb_date('l', $first['raw'])).($this->common_prefs['dateformat'][0] != 'd' ? ' ' : ', ');
1531 1530
 		}
1532 1531
 		for ($i = 0; $i < 5; $i += 2)
1533 1532
 		{
1534
-			switch($datefmt[$i])
1533
+			switch ($datefmt[$i])
1535 1534
 			{
1536 1535
 				case 'd':
1537
-					$range .= $first['day'] . ($datefmt[1] == '.' ? '.' : '');
1536
+					$range .= $first['day'].($datefmt[1] == '.' ? '.' : '');
1538 1537
 					if ($first['month'] != $last['month'] || $first['year'] != $last['year'])
1539 1538
 					{
1540 1539
 						if (!$month_before_day)
1541 1540
 						{
1542
-							$range .= ' '.lang(strftime('%B',$first['raw']));
1541
+							$range .= ' '.lang(strftime('%B', $first['raw']));
1543 1542
 						}
1544 1543
 						if ($first['year'] != $last['year'] && $datefmt[0] != 'Y')
1545 1544
 						{
1546
-							$range .= ($datefmt[0] != 'd' ? ', ' : ' ') . $first['year'];
1545
+							$range .= ($datefmt[0] != 'd' ? ', ' : ' ').$first['year'];
1547 1546
 						}
1548 1547
 						if ($display_time)
1549 1548
 						{
1550
-							$range .= ' '.adodb_date($timefmt,$first['raw']);
1549
+							$range .= ' '.adodb_date($timefmt, $first['raw']);
1551 1550
 						}
1552 1551
 						if (!$last)
1553 1552
 						{
@@ -1557,43 +1556,43 @@  discard block
 block discarded – undo
1557 1556
 
1558 1557
 						if ($first['year'] != $last['year'] && $datefmt[0] == 'Y')
1559 1558
 						{
1560
-							$range .= $last['year'] . ', ';
1559
+							$range .= $last['year'].', ';
1561 1560
 						}
1562 1561
 
1563 1562
 						if ($month_before_day)
1564 1563
 						{
1565
-							$range .= lang(strftime('%B',$last['raw']));
1564
+							$range .= lang(strftime('%B', $last['raw']));
1566 1565
 						}
1567 1566
 					}
1568 1567
 					else
1569 1568
 					{
1570 1569
 						if ($display_time)
1571 1570
 						{
1572
-							$range .= ' '.adodb_date($timefmt,$first['raw']);
1571
+							$range .= ' '.adodb_date($timefmt, $first['raw']);
1573 1572
 						}
1574 1573
 						$range .= ' - ';
1575 1574
 					}
1576
-					$range .= ' ' . $last['day'] . ($datefmt[1] == '.' ? '.' : '');
1575
+					$range .= ' '.$last['day'].($datefmt[1] == '.' ? '.' : '');
1577 1576
 					break;
1578 1577
 				case 'm':
1579 1578
 				case 'M':
1580
-					$range .= ' '.lang(strftime('%B',$month_before_day ? $first['raw'] : $last['raw'])) . ' ';
1579
+					$range .= ' '.lang(strftime('%B', $month_before_day ? $first['raw'] : $last['raw'])).' ';
1581 1580
 					break;
1582 1581
 				case 'Y':
1583 1582
 					if ($datefmt[0] != 'm')
1584 1583
 					{
1585
-						$range .= ' ' . ($datefmt[0] == 'Y' ? $first['year'].($datefmt[2] == 'd' ? ', ' : ' ') : $last['year'].' ');
1584
+						$range .= ' '.($datefmt[0] == 'Y' ? $first['year'].($datefmt[2] == 'd' ? ', ' : ' ') : $last['year'].' ');
1586 1585
 					}
1587 1586
 					break;
1588 1587
 			}
1589 1588
 		}
1590 1589
 		if ($display_time && $last)
1591 1590
 		{
1592
-			$range .= ' '.adodb_date($timefmt,$last['raw']);
1591
+			$range .= ' '.adodb_date($timefmt, $last['raw']);
1593 1592
 		}
1594 1593
 		if ($datefmt[4] == 'Y' && $datefmt[0] == 'm')
1595 1594
 		{
1596
-			$range .= ', ' . $last['year'];
1595
+			$range .= ', '.$last['year'];
1597 1596
 		}
1598 1597
 		return $range;
1599 1598
 	}
@@ -1605,25 +1604,25 @@  discard block
 block discarded – undo
1605 1604
 	 * @param int $end_m end time in minutes since 0h
1606 1605
 	 * @param boolean $both =false display the end-time too, duration is always displayed
1607 1606
 	 */
1608
-	function timespan($start_m,$end_m,$both=false)
1607
+	function timespan($start_m, $end_m, $both = false)
1609 1608
 	{
1610 1609
 		$duration = $end_m - $start_m;
1611
-		if ($end_m == 24*60-1) ++$duration;
1612
-		$duration = floor($duration/60).lang('h').($duration%60 ? $duration%60 : '');
1610
+		if ($end_m == 24 * 60 - 1) ++$duration;
1611
+		$duration = floor($duration / 60).lang('h').($duration % 60 ? $duration % 60 : '');
1613 1612
 
1614
-		$timespan = $t = Api\DateTime::to('20000101T'.sprintf('%02d',$start_m/60).sprintf('%02d',$start_m%60).'00', false);
1613
+		$timespan = $t = Api\DateTime::to('20000101T'.sprintf('%02d', $start_m / 60).sprintf('%02d', $start_m % 60).'00', false);
1615 1614
 
1616 1615
 		if ($both)	// end-time too
1617 1616
 		{
1618
-			$timespan .= ' - '.Api\DateTime::to('20000101T'.sprintf('%02d',$end_m/60).sprintf('%02d',$end_m%60).'00', false);
1617
+			$timespan .= ' - '.Api\DateTime::to('20000101T'.sprintf('%02d', $end_m / 60).sprintf('%02d', $end_m % 60).'00', false);
1619 1618
 			// dont double am/pm if they are the same in both times
1620
-			if ($this->common_prefs['timeformat'] == 12 && substr($timespan,-2) == substr($t,-2))
1619
+			if ($this->common_prefs['timeformat'] == 12 && substr($timespan, -2) == substr($t, -2))
1621 1620
 			{
1622
-				$timespan = str_replace($t,substr($t,0,-3),$timespan);
1621
+				$timespan = str_replace($t, substr($t, 0, -3), $timespan);
1623 1622
 			}
1624 1623
 			$timespan .= ':';
1625 1624
 		}
1626
-		return $timespan . ' ' . $duration;
1625
+		return $timespan.' '.$duration;
1627 1626
 	}
1628 1627
 
1629 1628
 	/**
@@ -1634,7 +1633,7 @@  discard block
 block discarded – undo
1634 1633
 	* @param boolean $append_email =false append email (Name <email>)
1635 1634
 	* @return string with name
1636 1635
 	*/
1637
-	function participant_name($id,$use_type=false, $append_email=false)
1636
+	function participant_name($id, $use_type = false, $append_email = false)
1638 1637
 	{
1639 1638
 		static $id2lid = array();
1640 1639
 		static $id2email = array();
@@ -1655,7 +1654,7 @@  discard block
 block discarded – undo
1655 1654
 			else
1656 1655
 			{
1657 1656
 				$id2lid[$id] = Api\Accounts::username($id);
1658
-				$id2email[$id] = $GLOBALS['egw']->accounts->id2name($id,'account_email');
1657
+				$id2email[$id] = $GLOBALS['egw']->accounts->id2name($id, 'account_email');
1659 1658
 			}
1660 1659
 		}
1661 1660
 		return $id2lid[$id].(($append_email || $id[0] == 'e') && $id2email[$id] ? ' <'.$id2email[$id].'>' : '');
@@ -1669,37 +1668,37 @@  discard block
 block discarded – undo
1669 1668
 	* @param boolean $show_group_invitation =false show group-invitations (status == 'G') or not (default)
1670 1669
 	* @return array with id / names with status pairs
1671 1670
 	*/
1672
-	function participants($event,$long_status=false,$show_group_invitation=false)
1671
+	function participants($event, $long_status = false, $show_group_invitation = false)
1673 1672
 	{
1674 1673
 		//error_log(__METHOD__.__LINE__.array2string($event['participants']));
1675 1674
 		$names = array();
1676
-		foreach((array)$event['participants'] as $id => $status)
1675
+		foreach ((array)$event['participants'] as $id => $status)
1677 1676
 		{
1678 1677
 			if (!is_string($status)) continue;
1679 1678
 			$quantity = $role = null;
1680
-			calendar_so::split_status($status,$quantity,$role);
1679
+			calendar_so::split_status($status, $quantity, $role);
1681 1680
 
1682
-			if ($status == 'G' && !$show_group_invitation) continue;	// dont show group-invitation
1681
+			if ($status == 'G' && !$show_group_invitation) continue; // dont show group-invitation
1683 1682
 
1684 1683
 			$lang_status = lang($this->verbose_status[$status]);
1685 1684
 			if (!$long_status)
1686 1685
 			{
1687
-				switch($status[0])
1686
+				switch ($status[0])
1688 1687
 				{
1689 1688
 					case 'A':	// accepted
1690
-						$status = Api\Html::image('calendar','accepted',$lang_status);
1689
+						$status = Api\Html::image('calendar', 'accepted', $lang_status);
1691 1690
 						break;
1692 1691
 					case 'R':	// rejected
1693
-						$status = Api\Html::image('calendar','rejected',$lang_status);
1692
+						$status = Api\Html::image('calendar', 'rejected', $lang_status);
1694 1693
 						break;
1695 1694
 					case 'T':	// tentative
1696
-						$status = Api\Html::image('calendar','tentative',$lang_status);
1695
+						$status = Api\Html::image('calendar', 'tentative', $lang_status);
1697 1696
 						break;
1698 1697
 					case 'U':	// no response = unknown
1699
-						$status = Api\Html::image('calendar','needs-action',$lang_status);
1698
+						$status = Api\Html::image('calendar', 'needs-action', $lang_status);
1700 1699
 						break;
1701 1700
 					case 'D':	// delegated
1702
-						$status = Api\Html::image('calendar','forward',$lang_status);
1701
+						$status = Api\Html::image('calendar', 'forward', $lang_status);
1703 1702
 						break;
1704 1703
 					case 'G':	// group invitation
1705 1704
 						// Todo: Image, seems not to be used
@@ -1721,13 +1720,13 @@  discard block
 block discarded – undo
1721 1720
 					$role = lang($this->roles[$role]);
1722 1721
 				}
1723 1722
 				// allow to use cats as roles (beside regular iCal ones)
1724
-				elseif (substr($role,0,6) == 'X-CAT-' && ($cat_id = (int)substr($role,6)) > 0)
1723
+				elseif (substr($role, 0, 6) == 'X-CAT-' && ($cat_id = (int)substr($role, 6)) > 0)
1725 1724
 				{
1726 1725
 					$role = $GLOBALS['egw']->categories->id2name($cat_id);
1727 1726
 				}
1728 1727
 				else
1729 1728
 				{
1730
-					$role = lang(str_replace('X-','',$role));
1729
+					$role = lang(str_replace('X-', '', $role));
1731 1730
 				}
1732 1731
 				$names[$id] .= ' '.$role;
1733 1732
 			}
@@ -1744,13 +1743,13 @@  discard block
 block discarded – undo
1744 1743
 	* @param int $color color of the category, if multiple cats, the color of the last one with color is returned
1745 1744
 	* @return array with id / names
1746 1745
 	*/
1747
-	function categories($category,&$color)
1746
+	function categories($category, &$color)
1748 1747
 	{
1749 1748
 		static $id2cat = array();
1750 1749
 		$cats = array();
1751 1750
 		$color = 0;
1752 1751
 
1753
-		foreach(explode(',',$category) as $cat_id)
1752
+		foreach (explode(',', $category) as $cat_id)
1754 1753
 		{
1755 1754
 			if (!$cat_id) continue;
1756 1755
 
@@ -1765,7 +1764,7 @@  discard block
 block discarded – undo
1765 1764
 			{
1766 1765
 				$color = $cat['data']['color'];
1767 1766
 			}
1768
-			elseif(preg_match('/(#[0-9A-Fa-f]{6})/', $cat['description'], $parts))
1767
+			elseif (preg_match('/(#[0-9A-Fa-f]{6})/', $cat['description'], $parts))
1769 1768
 			{
1770 1769
 				$color = $parts[1];
1771 1770
 			}
@@ -1777,12 +1776,12 @@  discard block
 block discarded – undo
1777 1776
 	/**
1778 1777
 	 *  This is called only by list_cals().  It was moved here to remove fatal error in php5 beta4
1779 1778
 	 */
1780
-	private static function _list_cals_add($id,&$users,&$groups)
1779
+	private static function _list_cals_add($id, &$users, &$groups)
1781 1780
 	{
1782 1781
 		$name = Api\Accounts::username($id);
1783 1782
 		if (!($egw_name = $GLOBALS['egw']->accounts->id2name($id)))
1784 1783
 		{
1785
-			return;	// do not return no longer existing accounts which eg. still mentioned in acl
1784
+			return; // do not return no longer existing accounts which eg. still mentioned in acl
1786 1785
 		}
1787 1786
 		if (($type = $GLOBALS['egw']->accounts->get_type($id)) == 'g')
1788 1787
 		{
@@ -1794,7 +1793,7 @@  discard block
 block discarded – undo
1794 1793
 		}
1795 1794
 		$arr[$id] = array(
1796 1795
 			'grantor' => $id,
1797
-			'value'   => ($type == 'g' ? 'g_' : '') . $id,
1796
+			'value'   => ($type == 'g' ? 'g_' : '').$id,
1798 1797
 			'name'    => $name,
1799 1798
 			'sname'	  => $egw_name
1800 1799
 		);
@@ -1816,26 +1815,26 @@  discard block
 block discarded – undo
1816 1815
 	 * @param int $user account_id of user to generate list for
1817 1816
 	 * @param array $grants =null calendar grants from user, or null to query them from acl class
1818 1817
 	 */
1819
-	public static function list_calendars($user, array $grants=null)
1818
+	public static function list_calendars($user, array $grants = null)
1820 1819
 	{
1821 1820
 		if (is_null($grants)) $grants = $GLOBALS['egw']->acl->get_grants('calendar', true, $user);
1822 1821
 
1823 1822
 		$users = $groups = array();
1824
-		foreach(array_keys($grants) as $id)
1823
+		foreach (array_keys($grants) as $id)
1825 1824
 		{
1826
-			self::_list_cals_add($id,$users,$groups);
1825
+			self::_list_cals_add($id, $users, $groups);
1827 1826
 		}
1828 1827
 		if (($memberships = $GLOBALS['egw']->accounts->memberships($user, true)))
1829 1828
 		{
1830
-			foreach($memberships as $group)
1829
+			foreach ($memberships as $group)
1831 1830
 			{
1832
-				self::_list_cals_add($group,$users,$groups);
1831
+				self::_list_cals_add($group, $users, $groups);
1833 1832
 
1834
-				if (($account_perms = $GLOBALS['egw']->acl->get_ids_for_location($group,Acl::READ,'calendar')))
1833
+				if (($account_perms = $GLOBALS['egw']->acl->get_ids_for_location($group, Acl::READ, 'calendar')))
1835 1834
 				{
1836
-					foreach($account_perms as $id)
1835
+					foreach ($account_perms as $id)
1837 1836
 					{
1838
-						self::_list_cals_add($id,$users,$groups);
1837
+						self::_list_cals_add($id, $users, $groups);
1839 1838
 					}
1840 1839
 				}
1841 1840
 			}
@@ -1843,7 +1842,7 @@  discard block
 block discarded – undo
1843 1842
 		usort($users, array(__CLASS__, 'name_cmp'));
1844 1843
 		usort($groups, array(__CLASS__, 'name_cmp'));
1845 1844
 
1846
-		return array_merge($users, $groups);	// users first and then groups, both alphabeticaly
1845
+		return array_merge($users, $groups); // users first and then groups, both alphabeticaly
1847 1846
 	}
1848 1847
 
1849 1848
 	/**
@@ -1883,28 +1882,27 @@  discard block
 block discarded – undo
1883 1882
 	 *	month: numerical month
1884 1883
 	 *	occurence: numerical year or 0 for every year
1885 1884
 	 */
1886
-	function read_holidays($year=0)
1885
+	function read_holidays($year = 0)
1887 1886
 	{
1888
-		if (!$year) $year = (int) date('Y',$this->now_su);
1887
+		if (!$year) $year = (int)date('Y', $this->now_su);
1889 1888
 
1890 1889
 		$holidays = calendar_holidays::read(
1891 1890
 				!empty($GLOBALS['egw_info']['server']['ical_holiday_url']) ?
1892
-				$GLOBALS['egw_info']['server']['ical_holiday_url'] :
1893
-				$GLOBALS['egw_info']['user']['preferences']['common']['country'], $year);
1891
+				$GLOBALS['egw_info']['server']['ical_holiday_url'] : $GLOBALS['egw_info']['user']['preferences']['common']['country'], $year);
1894 1892
 
1895 1893
 		// search for birthdays
1896 1894
 		if ($GLOBALS['egw_info']['server']['hide_birthdays'] != 'yes')
1897 1895
 		{
1898 1896
 			$contacts = new Api\Contacts();
1899
-			foreach($contacts->get_addressbooks() as $owner => $name)
1897
+			foreach ($contacts->get_addressbooks() as $owner => $name)
1900 1898
 			{
1901 1899
 				$holidays += $contacts->read_birthdays($owner, $year);
1902 1900
 			}
1903 1901
 		}
1904 1902
 
1905
-		if ((int) $this->debug >= 2 || $this->debug == 'read_holidays')
1903
+		if ((int)$this->debug >= 2 || $this->debug == 'read_holidays')
1906 1904
 		{
1907
-			$this->debug_message('calendar_bo::read_holidays(%1)=%2',true,$year,$holidays);
1905
+			$this->debug_message('calendar_bo::read_holidays(%1)=%2', true, $year, $holidays);
1908 1906
 		}
1909 1907
 		return $holidays;
1910 1908
 	}
@@ -1915,10 +1913,10 @@  discard block
 block discarded – undo
1915 1913
 	 * @param type $event
1916 1914
 	 * @return array array of selected calendar fields
1917 1915
 	 */
1918
-	public static function get_link_options ($event = array())
1916
+	public static function get_link_options($event = array())
1919 1917
 	{
1920
-		unset($event);	// not used, but required by function signature
1921
-		$options = array (
1918
+		unset($event); // not used, but required by function signature
1919
+		$options = array(
1922 1920
 			'end' => lang('End date'),
1923 1921
 			'id' => lang('ID'),
1924 1922
 			'owner' => lang('Event owner'),
@@ -1945,7 +1943,7 @@  discard block
 block discarded – undo
1945 1943
 			list($id, $recur) = explode('-', $event, 2);
1946 1944
 			$event = $this->read($id, $recur);
1947 1945
 		}
1948
-		else if (!is_array($event) && (int) $event > 0)
1946
+		else if (!is_array($event) && (int)$event > 0)
1949 1947
 		{
1950 1948
 			$event = $this->read($event);
1951 1949
 		}
@@ -1953,7 +1951,7 @@  discard block
 block discarded – undo
1953 1951
 		{
1954 1952
 			return $event;
1955 1953
 		}
1956
-		$type = explode(',',$this->cal_prefs['link_title']);
1954
+		$type = explode(',', $this->cal_prefs['link_title']);
1957 1955
 		if (is_array($type))
1958 1956
 		{
1959 1957
 			foreach ($type as &$val)
@@ -1979,10 +1977,10 @@  discard block
 block discarded – undo
1979 1977
 						$extra_fields [] = $event[$val];
1980 1978
 				}
1981 1979
 			}
1982
-			$str_fields = implode(', ',$extra_fields);
1983
-			if (is_array($extra_fields)) return $this->format_date($event['start']) . ': ' . $event['title'] . ($str_fields? ', ' . $str_fields:'');
1980
+			$str_fields = implode(', ', $extra_fields);
1981
+			if (is_array($extra_fields)) return $this->format_date($event['start']).': '.$event['title'].($str_fields ? ', '.$str_fields : '');
1984 1982
 		}
1985
-		return $this->format_date($event['start']) . ': ' . $event['title'];
1983
+		return $this->format_date($event['start']).': '.$event['title'];
1986 1984
 	}
1987 1985
 
1988 1986
 	/**
@@ -2001,10 +1999,10 @@  discard block
 block discarded – undo
2001 1999
 			'offset' =>	$options['start'],
2002 2000
 			'order' => 'cal_start DESC',
2003 2001
 		);
2004
-		if($options['num_rows']) {
2002
+		if ($options['num_rows']) {
2005 2003
 			$query['num_rows'] = $options['num_rows'];
2006 2004
 		}
2007
-		foreach((array) $this->search($query) as $event)
2005
+		foreach ((array)$this->search($query) as $event)
2008 2006
 		{
2009 2007
 			$result[$event['id']] = $this->link_title($event);
2010 2008
 		}
@@ -2021,11 +2019,11 @@  discard block
 block discarded – undo
2021 2019
 	 * @param int $user =null for which user to check, default current user
2022 2020
 	 * @return boolean true if access is granted or false otherwise
2023 2021
 	 */
2024
-	function file_access($id,$check,$rel_path,$user=null)
2022
+	function file_access($id, $check, $rel_path, $user = null)
2025 2023
 	{
2026
-		unset($rel_path);	// not used, but required by function signature
2024
+		unset($rel_path); // not used, but required by function signature
2027 2025
 
2028
-		return $this->check_perms($check,$id,0,'ts',null,$user);
2026
+		return $this->check_perms($check, $id, 0, 'ts', null, $user);
2029 2027
 	}
2030 2028
 
2031 2029
 	/**
@@ -2041,36 +2039,36 @@  discard block
 block discarded – undo
2041 2039
 		}
2042 2040
 		Api\Cache::setSession('calendar', 'default_prefs_set', 'set');
2043 2041
 
2044
-		$default_prefs =& $GLOBALS['egw']->preferences->default['calendar'];
2045
-		$forced_prefs  =& $GLOBALS['egw']->preferences->forced['calendar'];
2042
+		$default_prefs = & $GLOBALS['egw']->preferences->default['calendar'];
2043
+		$forced_prefs  = & $GLOBALS['egw']->preferences->forced['calendar'];
2046 2044
 
2047
-		$subject = lang('Calendar Event') . ' - $$action$$: $$startdate$$ $$title$$'."\n";
2045
+		$subject = lang('Calendar Event').' - $$action$$: $$startdate$$ $$title$$'."\n";
2048 2046
 		$values = array(
2049
-			'notifyAdded'     => $subject . lang ('You have a meeting scheduled for %1','$$startdate$$'),
2050
-			'notifyCanceled'  => $subject . lang ('Your meeting scheduled for %1 has been canceled','$$startdate$$'),
2051
-			'notifyModified'  => $subject . lang ('Your meeting that had been scheduled for %1 has been rescheduled to %2','$$olddate$$','$$startdate$$'),
2052
-			'notifyDisinvited'=> $subject . lang ('You have been disinvited from the meeting at %1','$$startdate$$'),
2053
-			'notifyResponse'  => $subject . lang ('On %1 %2 %3 your meeting request for %4','$$date$$','$$fullname$$','$$action$$','$$startdate$$'),
2054
-			'notifyAlarm'     => lang('Alarm for %1 at %2 in %3','$$title$$','$$startdate$$','$$location$$')."\n".lang ('Here is your requested alarm.'),
2047
+			'notifyAdded'     => $subject.lang('You have a meeting scheduled for %1', '$$startdate$$'),
2048
+			'notifyCanceled'  => $subject.lang('Your meeting scheduled for %1 has been canceled', '$$startdate$$'),
2049
+			'notifyModified'  => $subject.lang('Your meeting that had been scheduled for %1 has been rescheduled to %2', '$$olddate$$', '$$startdate$$'),
2050
+			'notifyDisinvited'=> $subject.lang('You have been disinvited from the meeting at %1', '$$startdate$$'),
2051
+			'notifyResponse'  => $subject.lang('On %1 %2 %3 your meeting request for %4', '$$date$$', '$$fullname$$', '$$action$$', '$$startdate$$'),
2052
+			'notifyAlarm'     => lang('Alarm for %1 at %2 in %3', '$$title$$', '$$startdate$$', '$$location$$')."\n".lang('Here is your requested alarm.'),
2055 2053
 			'interval'        => 30,
2056 2054
 		);
2057
-		foreach($values as $var => $default)
2055
+		foreach ($values as $var => $default)
2058 2056
 		{
2059
-			$type = substr($var,0,6) == 'notify' ? 'forced' : 'default';
2057
+			$type = substr($var, 0, 6) == 'notify' ? 'forced' : 'default';
2060 2058
 
2061 2059
 			// only set, if neither default nor forced pref exists
2062 2060
 			if ((!isset($default_prefs[$var]) || (string)$default_prefs[$var] === '') && (!isset($forced_prefs[$var]) || (string)$forced_prefs[$var] === ''))
2063 2061
 			{
2064
-				$GLOBALS['egw']->preferences->add('calendar',$var,$default,'default');	// always store default, even if we have a forced too
2065
-				if ($type == 'forced') $GLOBALS['egw']->preferences->add('calendar',$var,$default,'forced');
2062
+				$GLOBALS['egw']->preferences->add('calendar', $var, $default, 'default'); // always store default, even if we have a forced too
2063
+				if ($type == 'forced') $GLOBALS['egw']->preferences->add('calendar', $var, $default, 'forced');
2066 2064
 				$this->cal_prefs[$var] = $default;
2067 2065
 				$need_save = True;
2068 2066
 			}
2069 2067
 		}
2070 2068
 		if ($need_save)
2071 2069
 		{
2072
-			$GLOBALS['egw']->preferences->save_repository(False,'default');
2073
-			$GLOBALS['egw']->preferences->save_repository(False,'forced');
2070
+			$GLOBALS['egw']->preferences->save_repository(False, 'default');
2071
+			$GLOBALS['egw']->preferences->save_repository(False, 'forced');
2074 2072
 		}
2075 2073
 	}
2076 2074
 
@@ -2080,7 +2078,7 @@  discard block
 block discarded – undo
2080 2078
 	 * @param int|string $user account_id or account_lid
2081 2079
 	 * @param string $pw =null password
2082 2080
 	 */
2083
-	static function freebusy_url($user='',$pw=null)
2081
+	static function freebusy_url($user = '', $pw = null)
2084 2082
 	{
2085 2083
 		if (is_numeric($user)) $user = $GLOBALS['egw']->accounts->id2name($user);
2086 2084
 
@@ -2093,8 +2091,8 @@  discard block
 block discarded – undo
2093 2091
 		elseif ($GLOBALS['egw_info']['user']['preferences']['calendar']['freebusy'] == 2)
2094 2092
 		{
2095 2093
 			$credentials = $GLOBALS['egw_info']['user']['account_lid']
2096
-				. ':' . $GLOBALS['egw_info']['user']['passwd'];
2097
-			$credentials = '&cred=' . base64_encode($credentials);
2094
+				. ':'.$GLOBALS['egw_info']['user']['passwd'];
2095
+			$credentials = '&cred='.base64_encode($credentials);
2098 2096
 		}
2099 2097
 		return (!$GLOBALS['egw_info']['server']['webserver_url'] || $GLOBALS['egw_info']['server']['webserver_url'][0] == '/' ?
2100 2098
 			($_SERVER['HTTPS'] ? 'https://' : 'http://').$_SERVER['HTTP_HOST'] : '').
@@ -2126,11 +2124,11 @@  discard block
 block discarded – undo
2126 2124
 	 * @param string &$schedule_tag=null on return schedule-tag (egw_cal.cal_id:egw_cal.cal_etag, no participant modifications!)
2127 2125
 	 * @return string|boolean string with etag or false
2128 2126
 	 */
2129
-	function get_etag($entry, &$schedule_tag=null)
2127
+	function get_etag($entry, &$schedule_tag = null)
2130 2128
 	{
2131 2129
 		if (!is_array($entry))
2132 2130
 		{
2133
-			list($id,$recur_date) = explode(':',$entry);
2131
+			list($id, $recur_date) = explode(':', $entry);
2134 2132
 			$entry = $this->read($id, $recur_date, true, 'server');
2135 2133
 		}
2136 2134
 		$etag = $schedule_tag = $entry['id'].':'.$entry['etag'];
@@ -2148,15 +2146,15 @@  discard block
 block discarded – undo
2148 2146
 	 * @param boolean $master_only =false only check recurance master (egw_cal_user.recur_date=0)
2149 2147
 	 * @return integer
2150 2148
 	 */
2151
-	public function get_ctag($user, $filter='owner', $master_only=false)
2149
+	public function get_ctag($user, $filter = 'owner', $master_only = false)
2152 2150
 	{
2153 2151
 		if ($this->debug > 1) $startime = microtime(true);
2154 2152
 
2155 2153
 		// resolve users to add memberships for users and members for groups
2156 2154
 		$users = $this->resolve_users($user);
2157
-		$ctag = $users ? $this->so->get_ctag($users, $filter == 'owner', $master_only) : 0;	// no rights, return 0 as ctag (otherwise we get SQL error!)
2155
+		$ctag = $users ? $this->so->get_ctag($users, $filter == 'owner', $master_only) : 0; // no rights, return 0 as ctag (otherwise we get SQL error!)
2158 2156
 
2159
-		if ($this->debug > 1) error_log(__METHOD__. "($user, '$filter', $master_only) = $ctag = ".date('Y-m-d H:i:s',$ctag)." took ".(microtime(true)-$startime)." secs");
2157
+		if ($this->debug > 1) error_log(__METHOD__."($user, '$filter', $master_only) = $ctag = ".date('Y-m-d H:i:s', $ctag)." took ".(microtime(true) - $startime)." secs");
2160 2158
 		return $ctag;
2161 2159
 	}
2162 2160
 
@@ -2176,7 +2174,7 @@  discard block
 block discarded – undo
2176 2174
 
2177 2175
 		$content = array(
2178 2176
 			'info_cat'       => $GLOBALS['egw']->categories->check_list(Acl::READ, $calendar['category']),
2179
-			'info_priority'  => $calendar['priority'] ,
2177
+			'info_priority'  => $calendar['priority'],
2180 2178
 			'info_public'    => $calendar['public'] != 'private',
2181 2179
 			'info_subject'   => $calendar['title'],
2182 2180
 			'info_des'       => $calendar['description'],
@@ -2191,7 +2189,7 @@  discard block
 block discarded – undo
2191 2189
 		$content['link_app'][] = $calendar['info_link']['app'];
2192 2190
 		$content['link_id'][]  = $calendar['info_link']['id'];
2193 2191
 		// Copy claendar's links
2194
-		foreach(Link::get_links('calendar',$calendar['id'],'','link_lastmod DESC',true) as $link)
2192
+		foreach (Link::get_links('calendar', $calendar['id'], '', 'link_lastmod DESC', true) as $link)
2195 2193
 		{
2196 2194
 			if ($link['app'] != Link::VFS_APPNAME)
2197 2195
 			{
@@ -2204,7 +2202,7 @@  discard block
 block discarded – undo
2204 2202
 			}
2205 2203
 		}
2206 2204
 		// Copy same custom fields
2207
-		foreach(array_keys(Api\Storage\Customfields::get('infolog')) as $name)
2205
+		foreach (array_keys(Api\Storage\Customfields::get('infolog')) as $name)
2208 2206
 		{
2209 2207
 			if ($this->customfields[$name]) $content['#'.$name] = $calendar['#'.$name];
2210 2208
 		}
@@ -2222,20 +2220,20 @@  discard block
 block discarded – undo
2222 2220
 	function timesheet_set($data)
2223 2221
 	{
2224 2222
 		$set = array();
2225
-		list($id,$recurrence) = explode(':',$data['id']);
2226
-		if ((int)$id && ($event = $this->read($id,$recurrence)))
2223
+		list($id, $recurrence) = explode(':', $data['id']);
2224
+		if ((int)$id && ($event = $this->read($id, $recurrence)))
2227 2225
 		{
2228 2226
 			$set['ts_start'] = $event['start'];
2229 2227
 			$set['ts_title'] = $this->link_title($event);
2230
-			$set['start_time'] = Api\DateTime::to($event['start'],'H:i');
2228
+			$set['start_time'] = Api\DateTime::to($event['start'], 'H:i');
2231 2229
 			$set['ts_description'] = $event['description'];
2232
-			if ($this->isWholeDay($event)) $event['end']++;	// whole day events are 1sec short
2230
+			if ($this->isWholeDay($event)) $event['end']++; // whole day events are 1sec short
2233 2231
 			$set['ts_duration']	= ($event['end'] - $event['start']) / 60;
2234 2232
 			$set['ts_quantity'] = ($event['end'] - $event['start']) / 3600;
2235
-			$set['end_time'] = null;	// unset end-time
2233
+			$set['end_time'] = null; // unset end-time
2236 2234
 			$set['cat_id'] = (int)$event['category'];
2237 2235
 
2238
-			foreach(Link::get_links('calendar',$id,'','link_lastmod DESC',true) as $link)
2236
+			foreach (Link::get_links('calendar', $id, '', 'link_lastmod DESC', true) as $link)
2239 2237
 			{
2240 2238
 				if ($link['app'] != 'timesheet' && $link['app'] != Link::VFS_APPNAME)
2241 2239
 				{
Please login to merge, or discard this patch.
calendar/inc/class.calendar_timegrid_etemplate_widget.inc.php 3 patches
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -1,11 +1,11 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
-  * Egroupware
4
-  * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
5
-  * @link http://www.egroupware.org
6
-  * @author Nathan Gray
7
-  * @version $Id$
8
-  */
3
+ * Egroupware
4
+ * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
5
+ * @link http://www.egroupware.org
6
+ * @author Nathan Gray
7
+ * @version $Id$
8
+ */
9 9
 
10 10
 use EGroupware\Api;
11 11
 use EGroupware\Api\Etemplate;
@@ -22,13 +22,13 @@  discard block
 block discarded – undo
22 22
  {
23 23
 
24 24
 	 /**
25
-	 * Set up what we know on the server side.
26
-	 *
27
-	 * Sending a first chunk of rows
28
-	 *
29
-	 * @param string $cname
30
-	 * @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont'
31
-	 */
25
+	  * Set up what we know on the server side.
26
+	  *
27
+	  * Sending a first chunk of rows
28
+	  *
29
+	  * @param string $cname
30
+	  * @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont'
31
+	  */
32 32
 	public function beforeSendToClient($cname, array $expand=null)
33 33
 	{
34 34
 		$form_name = self::form_name($cname, $this->id, $expand);
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -29,24 +29,24 @@
 block discarded – undo
29 29
 	 * @param string $cname
30 30
 	 * @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont'
31 31
 	 */
32
-	public function beforeSendToClient($cname, array $expand=null)
32
+	public function beforeSendToClient($cname, array $expand = null)
33 33
 	{
34 34
 		$form_name = self::form_name($cname, $this->id, $expand);
35
-		$value =& self::get_array(self::$request->content, $form_name, true);
36
-		if(!is_array($value)) $value = array();
35
+		$value = & self::get_array(self::$request->content, $form_name, true);
36
+		if (!is_array($value)) $value = array();
37 37
 
38
-		foreach($value as &$events)
38
+		foreach ($value as &$events)
39 39
 		{
40
-			if(!is_array($events))
40
+			if (!is_array($events))
41 41
 			{
42 42
 				continue;
43 43
 			}
44
-			foreach($events as &$event)
44
+			foreach ($events as &$event)
45 45
 			{
46
-				if(!is_array($event)) continue;
47
-				foreach(array('start','end') as $date)
46
+				if (!is_array($event)) continue;
47
+				foreach (array('start', 'end') as $date)
48 48
 				{
49
-					$event[$date] = Api\DateTime::to($event[$date],'Y-m-d\TH:i:s\Z');
49
+					$event[$date] = Api\DateTime::to($event[$date], 'Y-m-d\TH:i:s\Z');
50 50
 				}
51 51
 			}
52 52
 		}
Please login to merge, or discard this patch.
Braces   +8 added lines, -2 removed lines patch added patch discarded remove patch
@@ -33,7 +33,10 @@  discard block
 block discarded – undo
33 33
 	{
34 34
 		$form_name = self::form_name($cname, $this->id, $expand);
35 35
 		$value =& self::get_array(self::$request->content, $form_name, true);
36
-		if(!is_array($value)) $value = array();
36
+		if(!is_array($value))
37
+		{
38
+			$value = array();
39
+		}
37 40
 
38 41
 		foreach($value as &$events)
39 42
 		{
@@ -43,7 +46,10 @@  discard block
 block discarded – undo
43 46
 			}
44 47
 			foreach($events as &$event)
45 48
 			{
46
-				if(!is_array($event)) continue;
49
+				if(!is_array($event))
50
+				{
51
+					continue;
52
+				}
47 53
 				foreach(array('start','end') as $date)
48 54
 				{
49 55
 					$event[$date] = Api\DateTime::to($event[$date],'Y-m-d\TH:i:s\Z');
Please login to merge, or discard this patch.
calendar/inc/class.calendar_merge.inc.php 4 patches
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -326,20 +326,20 @@  discard block
 block discarded – undo
326 326
 	}
327 327
 
328 328
 	/**
329
-	* Table plugin for event
330
-	* Lists events for a certain day of the week.  Only works for one week at a time, so for multiple weeks,
331
-	* use multiple date ranges.
332
-	*
333
-	* Use:
334
-	* $$table/Monday$$ $$starttime$$ $$title$$ $$endtable$$
335
-	* The day of the week may be language specific (date('l')).
336
-	*
337
-	* @param string $plugin (Monday-Sunday)
338
-	* @param int/array date or date range
339
-	* @param int $n Row number
340
-	* @param string $repeat Text being repeated for each entry
341
-	* @return array
342
-	*/
329
+	 * Table plugin for event
330
+	 * Lists events for a certain day of the week.  Only works for one week at a time, so for multiple weeks,
331
+	 * use multiple date ranges.
332
+	 *
333
+	 * Use:
334
+	 * $$table/Monday$$ $$starttime$$ $$title$$ $$endtable$$
335
+	 * The day of the week may be language specific (date('l')).
336
+	 *
337
+	 * @param string $plugin (Monday-Sunday)
338
+	 * @param int/array date or date range
339
+	 * @param int $n Row number
340
+	 * @param string $repeat Text being repeated for each entry
341
+	 * @return array
342
+	 */
343 343
 	public function day_plugin($plugin,$date,$n,$repeat)
344 344
 	{
345 345
 		static $days = null;
@@ -414,16 +414,16 @@  discard block
 block discarded – undo
414 414
 	}
415 415
 
416 416
 	/**
417
-	* Table plugin for a certain date
418
-	*
419
-	* Can be either a particular date (2011-02-15) or a day of the month (15)
420
-	*
421
-	* @param string $plugin
422
-	* @param int $id ID for this record
423
-	* @param int $n Repeated row number
424
-	* @param string $repeat Text being repeated for each entry
425
-	* @return array
426
-	*/
417
+	 * Table plugin for a certain date
418
+	 *
419
+	 * Can be either a particular date (2011-02-15) or a day of the month (15)
420
+	 *
421
+	 * @param string $plugin
422
+	 * @param int $id ID for this record
423
+	 * @param int $n Repeated row number
424
+	 * @param string $repeat Text being repeated for each entry
425
+	 * @return array
426
+	 */
427 427
 	public function day($plugin,$id,$n,$repeat)
428 428
 	{
429 429
 		static $days = null;
@@ -515,15 +515,15 @@  discard block
 block discarded – undo
515 515
 	}
516 516
 
517 517
 	/**
518
-	* Table plugin for participants
519
-	*
520
-	* Copied from eventmgr resources
521
-	*
522
-	* @param string $plugin
523
-	* @param int $id
524
-	* @param int $n
525
-	* @return array
526
-	*/
518
+	 * Table plugin for participants
519
+	 *
520
+	 * Copied from eventmgr resources
521
+	 *
522
+	 * @param string $plugin
523
+	 * @param int $id
524
+	 * @param int $n
525
+	 * @return array
526
+	 */
527 527
 	public function participant($plugin,$id,$n)
528 528
 	{
529 529
 		unset($plugin);	// not used, but required by function signature
@@ -582,7 +582,7 @@  discard block
 block discarded – undo
582 582
 				{
583 583
 					foreach($resource as $name => $value)
584 584
 					{
585
-					    $replacements['$$'.$name.'$$'] = $value;
585
+						$replacements['$$'.$name.'$$'] = $value;
586 586
 					}
587 587
 				}
588 588
 				break;
Please login to merge, or discard this patch.
Braces   +167 added lines, -53 removed lines patch added patch discarded remove patch
@@ -88,10 +88,12 @@  discard block
 block discarded – undo
88 88
 		{
89 89
 			$this->table_plugins[date('l', strtotime("+$i days"))] = 'day_plugin';
90 90
 		}
91
-		for($i = 1; $i <= 31; $i++) {
91
+		for($i = 1; $i <= 31; $i++)
92
+		{
92 93
 			$this->table_plugins['day_'.$i] = 'day'; // Numerically by day number (1-31)
93 94
 		}
94
-		foreach(self::$relative as $day) {
95
+		foreach(self::$relative as $day)
96
+		{
95 97
 			$this->table_plugins[$day] = 'day'; // Current day
96 98
 		}
97 99
 		$this->query = is_array($this->bo->cal_prefs['saved_states']) ?
@@ -131,9 +133,16 @@  discard block
 block discarded – undo
131 133
 				$events = $ids;
132 134
 				$ids = array('start' => PHP_INT_MAX, 'end' => 0);
133 135
 				$this->ids = array();
134
-				foreach($events as $event) {
135
-					if($event['start'] && Api\DateTime::to($event['start'],'ts') < $ids['start']) $ids['start'] = Api\DateTime::to($event['start'],'ts');
136
-					if($event['end'] && Api\DateTime::to($event['end'],'ts') > $ids['end']) $ids['end'] = Api\DateTime::to($event['end'],'ts');
136
+				foreach($events as $event)
137
+				{
138
+					if($event['start'] && Api\DateTime::to($event['start'],'ts') < $ids['start'])
139
+					{
140
+						$ids['start'] = Api\DateTime::to($event['start'],'ts');
141
+					}
142
+					if($event['end'] && Api\DateTime::to($event['end'],'ts') > $ids['end'])
143
+					{
144
+						$ids['end'] = Api\DateTime::to($event['end'],'ts');
145
+					}
137 146
 					// Keep ids for future use
138 147
 					$this->ids[] = $event['id'];
139 148
 				}
@@ -154,7 +163,8 @@  discard block
 block discarded – undo
154 163
 				'cfs' => strpos($content, '#') !== false ? array_keys(Api\Storage\Customfields::get('calendar')) : null
155 164
 			));
156 165
 			$ids = array();
157
-			foreach($events as $event) {
166
+			foreach($events as $event)
167
+			{
158 168
 				$ids[] = $event;
159 169
 			}
160 170
 		}
@@ -192,9 +202,16 @@  discard block
 block discarded – undo
192 202
 			$events = $id;
193 203
 			$id = array('start' => PHP_INT_MAX, 'end' => 0);
194 204
 			$this->ids = array();
195
-			foreach($events as $event) {
196
-				if($event['start'] && $event['start'] < $id['start']) $id['start'] = $event['start'];
197
-				if($event['end'] && $event['end'] > $id['end']) $id['end'] = $event['end'];
205
+			foreach($events as $event)
206
+			{
207
+				if($event['start'] && $event['start'] < $id['start'])
208
+				{
209
+					$id['start'] = $event['start'];
210
+				}
211
+				if($event['end'] && $event['end'] > $id['end'])
212
+				{
213
+					$id['end'] = $event['end'];
214
+				}
198 215
 				// Keep ids for future use
199 216
 				$this->ids[]  = $event['id'];
200 217
 			}
@@ -221,7 +238,10 @@  discard block
 block discarded – undo
221 238
 				foreach(self::$range_tags as $key => $format)
222 239
 				{
223 240
 					$value = date($format, $key == 'end' ? $id['end'] : $id['start']);
224
-					if($key == 'month') $value = lang($value);
241
+					if($key == 'month')
242
+					{
243
+						$value = lang($value);
244
+					}
225 245
 					$values["$\$range/$key$$"] = $value;
226 246
 				}
227 247
 			}
@@ -240,9 +260,12 @@  discard block
 block discarded – undo
240 260
 	public function calendar_replacements($id,$prefix = '', &$content = '')
241 261
 	{
242 262
 		$replacements = array();
243
-		if(!is_array($id) || !$id['start']) {
263
+		if(!is_array($id) || !$id['start'])
264
+		{
244 265
 			$event = $this->bo->read(is_array($id) ? $id['id'] : $id, is_array($id) ? $id['recur_date'] : null);
245
-		} else {
266
+		}
267
+		else
268
+		{
246 269
 			$event = $id;
247 270
 		}
248 271
 
@@ -261,7 +284,10 @@  discard block
 block discarded – undo
261 284
 		$replacements['$$' . ($prefix ? $prefix . '/' : '') . 'calendar_id'. '$$'] = $event['id'];
262 285
 		foreach($this->bo->event2array($event) as $name => $data)
263 286
 		{
264
-			if (substr($name,-4) == 'date') $name = substr($name,0,-4);
287
+			if (substr($name,-4) == 'date')
288
+			{
289
+				$name = substr($name,0,-4);
290
+			}
265 291
 			$replacements['$$' . ($prefix ? $prefix . '/' : '') . 'calendar_'.$name . '$$'] = is_array($data['data']) ? implode(', ',$data['data']) : $data['data'];
266 292
 		}
267 293
 		// Add seperate lists of participants by type
@@ -300,7 +326,10 @@  discard block
 block discarded – undo
300 326
 			) as $name => $format)
301 327
 			{
302 328
 				$value = Api\DateTime::to($event[$what],$format);
303
-				if ($format == 'l') $value = lang($value);
329
+				if ($format == 'l')
330
+				{
331
+					$value = lang($value);
332
+				}
304 333
 				$replacements['$$' .($prefix ? $prefix.'/':'').'calendar_'.$what.$name.'$$'] = $value;
305 334
 			}
306 335
 		}
@@ -343,24 +372,41 @@  discard block
 block discarded – undo
343 372
 	public function day_plugin($plugin,$date,$n,$repeat)
344 373
 	{
345 374
 		static $days = null;
346
-		if(is_array($date) && !$date['start']) {
375
+		if(is_array($date) && !$date['start'])
376
+		{
347 377
 			// List of IDs
348
-			if($date[0]['start']) {
378
+			if($date[0]['start'])
379
+			{
349 380
 				$id = array('start' => PHP_INT_MAX, 'end' => 0);
350
-				foreach($date as $event) {
351
-					if($event['start'] && $event['start'] < $id['start']) $id['start'] = $event['start'];
352
-					if($event['end'] && $event['end'] > $id['end']) $id['end'] = $event['end'];
381
+				foreach($date as $event)
382
+				{
383
+					if($event['start'] && $event['start'] < $id['start'])
384
+					{
385
+						$id['start'] = $event['start'];
386
+					}
387
+					if($event['end'] && $event['end'] > $id['end'])
388
+					{
389
+						$id['end'] = $event['end'];
390
+					}
353 391
 				}
354 392
 				$date = $id;
355
-			} else {
393
+			}
394
+			else
395
+			{
356 396
 				$event = $this->bo->read(is_array($date) ? $date['id'] : $date, is_array($date) ? $date['recur_date'] : null);
357
-				if(date('l',$event['start']) != $plugin) return array();
397
+				if(date('l',$event['start']) != $plugin)
398
+				{
399
+					return array();
400
+				}
358 401
 				$date = $event['start'];
359 402
 			}
360 403
 		}
361 404
 
362 405
 		$_date = $date['start'] ? $date['start'] : $date;
363
-		if($days[date('Ymd',$_date)][$plugin]) return $days[date('Ymd',$_date)][$plugin][$n];
406
+		if($days[date('Ymd',$_date)][$plugin])
407
+		{
408
+			return $days[date('Ymd',$_date)][$plugin][$n];
409
+		}
364 410
 
365 411
 		$events = $this->bo->search($this->query + array(
366 412
 			'start' => $date['end'] ? $date['start'] : mktime(0,0,0,date('m',$_date),date('d',$_date),date('Y',$_date)),
@@ -372,20 +418,29 @@  discard block
 block discarded – undo
372 418
 			'cfs' => array(),	// read all custom-fields
373 419
 		));
374 420
 
375
-		if (true) $days = array();
421
+		if (true)
422
+		{
423
+			$days = array();
424
+		}
376 425
 		$replacements = array();
377 426
 		$time_format = $GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == 12 ? 'h:i a' : 'H:i';
378 427
 		foreach($events as $day => $list)
379 428
 		{
380 429
 			foreach($list as $event)
381 430
 			{
382
-				if($this->ids && !in_array($event['id'], $this->ids)) continue;
431
+				if($this->ids && !in_array($event['id'], $this->ids))
432
+				{
433
+					continue;
434
+				}
383 435
 				$start = Api\DateTime::to($event['start'], 'array');
384 436
 				$end = Api\DateTime::to($event['end'], 'array');
385 437
 				$replacements = $this->calendar_replacements($event);
386
-				if($start['year'] == $end['year'] && $start['month'] == $end['month'] && $start['day'] == $end['day']) {
438
+				if($start['year'] == $end['year'] && $start['month'] == $end['month'] && $start['day'] == $end['day'])
439
+				{
387 440
 					$dow = date('l',$event['start']);
388
-				} else {
441
+				}
442
+				else
443
+				{
389 444
 					$dow = date('l', strtotime($day));
390 445
 					// Fancy date+time formatting for multi-day events
391 446
 					$replacements['$$calendar_starttime$$'] = date($time_format, $day == date('Ymd', $event['start']) ? $event['start'] : mktime(0,0,0,0,0,1));
@@ -394,12 +449,14 @@  discard block
 block discarded – undo
394 449
 
395 450
 				$days[date('Ymd',$_date)][$dow][] = $replacements;
396 451
 			}
397
-			if(strpos($repeat, 'day/date') !== false || strpos($repeat, 'day/name') !== false) {
452
+			if(strpos($repeat, 'day/date') !== false || strpos($repeat, 'day/name') !== false)
453
+			{
398 454
 				$date_marker = array(
399 455
 					'$$day/date$$' => date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'], strtotime($day)),
400 456
 					'$$day/name$$' => lang(date('l', strtotime($day)))
401 457
 				);
402
-				if(!is_array($days[date('Ymd',$_date)][date('l',strtotime($day))])) {
458
+				if(!is_array($days[date('Ymd',$_date)][date('l',strtotime($day))]))
459
+				{
403 460
 					$blank = $this->calendar_replacements(array());
404 461
 					foreach($blank as &$value)
405 462
 					{
@@ -435,16 +492,26 @@  discard block
 block discarded – undo
435 492
 			if($id[0]['start'])
436 493
 			{
437 494
 				$dates = array('start' => PHP_INT_MAX, 'end' => 0);
438
-				foreach($id as $event) {
439
-					if($event['start'] && $event['start'] < $dates['start']) $dates['start'] = $event['start'];
440
-					if($event['end'] && $event['end'] > $dates['end']) $dates['end'] = $event['end'];
495
+				foreach($id as $event)
496
+				{
497
+					if($event['start'] && $event['start'] < $dates['start'])
498
+					{
499
+						$dates['start'] = $event['start'];
500
+					}
501
+					if($event['end'] && $event['end'] > $dates['end'])
502
+					{
503
+						$dates['end'] = $event['end'];
504
+					}
441 505
 				}
442 506
 				$id = $dates;
443 507
 			}
444 508
 			$arr = $this->bo->date2array($id['start']);
445 509
 			$arr['day'] = $which;
446 510
 			$date = $this->bo->date2ts($arr);
447
-			if(is_array($id) && $id['start'] && ($date < $id['start'] || $date > $id['end'])) return array();
511
+			if(is_array($id) && $id['start'] && ($date < $id['start'] || $date > $id['end']))
512
+			{
513
+				return array();
514
+			}
448 515
 		}
449 516
 		elseif ($plugin == 'selected')
450 517
 		{
@@ -454,16 +521,26 @@  discard block
 block discarded – undo
454 521
 		{
455 522
 			$date = strtotime($plugin);
456 523
 		}
457
-		if($type == 'day' && is_array($id) && !$id['start']) {
524
+		if($type == 'day' && is_array($id) && !$id['start'])
525
+		{
458 526
 			$event = $this->bo->read(is_array($id) ? $id['id'] : $id, is_array($id) ? $id['recur_date'] : null);
459
-			if($which && date('d',$event['start']) != $which) return array();
460
-			if(date('Ymd',$date) != date('Ymd', $event['start'])) return array();
527
+			if($which && date('d',$event['start']) != $which)
528
+			{
529
+				return array();
530
+			}
531
+			if(date('Ymd',$date) != date('Ymd', $event['start']))
532
+			{
533
+				return array();
534
+			}
461 535
 			return $n == 0 ? $this->calendar_replacements($event) : array();
462 536
 		}
463 537
 
464 538
 		// Use start for cache, in case of multiple months
465 539
 		$_date = $id['start'] ? $id['start'] : $date;
466
-		if($days[date('Ymd',$_date)][$plugin]) return $days[date('Ymd',$_date)][$plugin][$n];
540
+		if($days[date('Ymd',$_date)][$plugin])
541
+		{
542
+			return $days[date('Ymd',$_date)][$plugin][$n];
543
+		}
467 544
 
468 545
 		$events = $this->bo->search($this->query + array(
469 546
 			'start' => $date,
@@ -476,31 +553,42 @@  discard block
 block discarded – undo
476 553
 		));
477 554
 
478 555
 		$replacements = array();
479
-		if (true) $days = array();
556
+		if (true)
557
+		{
558
+			$days = array();
559
+		}
480 560
 		$time_format = $GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == 12 ? 'h:i a' : 'H:i';
481 561
 		foreach($events as $day => $list)
482 562
 		{
483 563
 			foreach($list as $event)
484 564
 			{
485
-				if($this->ids && !in_array($event['id'], $this->ids)) continue;
565
+				if($this->ids && !in_array($event['id'], $this->ids))
566
+				{
567
+					continue;
568
+				}
486 569
 				$start = Api\DateTime::to($event['start'], 'array');
487 570
 				$end = Api\DateTime::to($event['end'], 'array');
488 571
 				$replacements = $this->calendar_replacements($event);
489
-				if($start['year'] == $end['year'] && $start['month'] == $end['month'] && $start['day'] == $end['day']) {
572
+				if($start['year'] == $end['year'] && $start['month'] == $end['month'] && $start['day'] == $end['day'])
573
+				{
490 574
 					//$dow = date('l',$event['start']);
491
-				} else {
575
+				}
576
+				else
577
+				{
492 578
 					// Fancy date+time formatting for multi-day events
493 579
 					$replacements['$$calendar_starttime$$'] = date($time_format, $day == date('Ymd', $event['start']) ? $event['start'] : mktime(0,0,0,0,0,1));
494 580
 					$replacements['$$calendar_endtime$$'] = date($time_format, $day == date('Ymd', $event['end']) ? $event['end'] : mktime(23,59,59,0,0,0));
495 581
 				}
496 582
 				$days[date('Ymd',$_date)][$plugin][] = $replacements;
497 583
 			}
498
-			if(strpos($repeat, 'day/date') !== false || strpos($repeat, 'day/name') !== false) {
584
+			if(strpos($repeat, 'day/date') !== false || strpos($repeat, 'day/name') !== false)
585
+			{
499 586
 				$date_marker = array(
500 587
 					'$$day/date$$' => date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'], strtotime($day)),
501 588
 					'$$day/name$$' => lang(date('l', strtotime($day)))
502 589
 				);
503
-				if(!is_array($days[date('Ymd',$_date)][$plugin])) {
590
+				if(!is_array($days[date('Ymd',$_date)][$plugin]))
591
+				{
504 592
 					$blank = $this->calendar_replacements(array());
505 593
 					foreach($blank as &$value)
506 594
 					{
@@ -528,22 +616,35 @@  discard block
 block discarded – undo
528 616
 	{
529 617
 		unset($plugin);	// not used, but required by function signature
530 618
 
531
-		if(!is_array($id) || !$id['start']) {
619
+		if(!is_array($id) || !$id['start'])
620
+		{
532 621
 			$event = $this->bo->read(is_array($id) ? $id['id'] : $id, is_array($id) ? $id['recur_date'] : null);
533
-		} else {
622
+		}
623
+		else
624
+		{
534 625
 			$event = $id;
535 626
 		}
536 627
 
537
-		if(!is_array($event['participants']) || $n >= count($event['participants'])) return array();
628
+		if(!is_array($event['participants']) || $n >= count($event['participants']))
629
+		{
630
+			return array();
631
+		}
538 632
 
539 633
 		$participant = null;
540 634
 		$status = null;
541 635
 		$i = -1;
542
-		foreach($event['participants'] as $participant => $status) {
543
-			if(++$i == $n) break;
636
+		foreach($event['participants'] as $participant => $status)
637
+		{
638
+			if(++$i == $n)
639
+			{
640
+				break;
641
+			}
544 642
 		}
545 643
 
546
-		if(!$participant) return array();
644
+		if(!$participant)
645
+		{
646
+			return array();
647
+		}
547 648
 
548 649
 		// Add some common information
549 650
 		$quantity = $role = null;
@@ -577,7 +678,10 @@  discard block
 block discarded – undo
577 678
 				$replacements = $this->contact_replacements(substr($participant,1),'');
578 679
 				break;
579 680
 			case 'r':
580
-				if (is_null(self::$resources)) self::$resources = new resources_bo();
681
+				if (is_null(self::$resources))
682
+				{
683
+					self::$resources = new resources_bo();
684
+				}
581 685
 				if (($resource = self::$resources->read(substr($participant,1))))
582 686
 				{
583 687
 					foreach($resource as $name => $value)
@@ -638,14 +742,23 @@  discard block
 block discarded – undo
638 742
 			'calendar_owner'    => lang('Owner'),
639 743
 		) as $name => $label)
640 744
 		{
641
-			if (in_array($name,array('start','end')) && $n&1)		// main values, which should be in the first column
745
+			if (in_array($name,array('start','end')) && $n&1)
746
+			{
747
+				// main values, which should be in the first column
642 748
 			{
643 749
 				echo "</tr>\n";
750
+			}
644 751
 				$n++;
645 752
 			}
646
-			if (!($n&1)) echo '<tr>';
753
+			if (!($n&1))
754
+			{
755
+				echo '<tr>';
756
+			}
647 757
 			echo '<td>{{'.$name.'}}</td><td>'.$label.'</td>';
648
-			if ($n&1) echo "</tr>\n";
758
+			if ($n&1)
759
+			{
760
+				echo "</tr>\n";
761
+			}
649 762
 			$n++;
650 763
 		}
651 764
 
@@ -696,7 +809,8 @@  discard block
 block discarded – undo
696 809
 		}
697 810
 		echo '</table></td><td colspan="2"><table >';
698 811
 		echo '<tr><td><h3>'.lang('Daily tables').":</h3></td></tr>";
699
-		foreach(self::$relative as $value) {
812
+		foreach(self::$relative as $value)
813
+		{
700 814
 			echo '<tr><td>{{table/'.$value. '}} ... {{endtable}}</td></tr>';
701 815
 		}
702 816
 		echo '<tr><td>{{table/day_n}} ... {{endtable}}</td><td>1 <= n <= 31</td></tr>';
Please login to merge, or discard this patch.
Spacing   +137 added lines, -137 removed lines patch added patch discarded remove patch
@@ -84,14 +84,14 @@  discard block
 block discarded – undo
84 84
 
85 85
 		// Register table plugins
86 86
 		$this->table_plugins['participant'] = 'participant';
87
-		for($i = 0; $i < 7; $i++)
87
+		for ($i = 0; $i < 7; $i++)
88 88
 		{
89 89
 			$this->table_plugins[date('l', strtotime("+$i days"))] = 'day_plugin';
90 90
 		}
91
-		for($i = 1; $i <= 31; $i++) {
91
+		for ($i = 1; $i <= 31; $i++) {
92 92
 			$this->table_plugins['day_'.$i] = 'day'; // Numerically by day number (1-31)
93 93
 		}
94
-		foreach(self::$relative as $day) {
94
+		foreach (self::$relative as $day) {
95 95
 			$this->table_plugins[$day] = 'day'; // Current day
96 96
 		}
97 97
 		$this->query = is_array($this->bo->cal_prefs['saved_states']) ?
@@ -117,11 +117,11 @@  discard block
 block discarded – undo
117 117
 	 * @param string $charset=null charset to override default set by mimetype or export charset
118 118
 	 * @return string|boolean merged document or false on error
119 119
 	 */
120
-	function merge_string($content,$ids,$err,$mimetype,$fix)
120
+	function merge_string($content, $ids, $err, $mimetype, $fix)
121 121
 	{
122 122
 		//error_log(__METHOD__ . ' IDs: ' . array2string($ids));
123 123
 		// Handle merging a list of events into a document with range instead of pagerepeat
124
-		if((strpos($content, '$$range') !== false || strpos($content, '{{range') !== false) && is_array($ids))
124
+		if ((strpos($content, '$$range') !== false || strpos($content, '{{range') !== false) && is_array($ids))
125 125
 		{
126 126
 			//error_log(__METHOD__ . ' Got list of events(?), no pagerepeat tag');
127 127
 			// Merging more than one something will fail without pagerepeat
@@ -131,9 +131,9 @@  discard block
 block discarded – undo
131 131
 				$events = $ids;
132 132
 				$ids = array('start' => PHP_INT_MAX, 'end' => 0);
133 133
 				$this->ids = array();
134
-				foreach($events as $event) {
135
-					if($event['start'] && Api\DateTime::to($event['start'],'ts') < $ids['start']) $ids['start'] = Api\DateTime::to($event['start'],'ts');
136
-					if($event['end'] && Api\DateTime::to($event['end'],'ts') > $ids['end']) $ids['end'] = Api\DateTime::to($event['end'],'ts');
134
+				foreach ($events as $event) {
135
+					if ($event['start'] && Api\DateTime::to($event['start'], 'ts') < $ids['start']) $ids['start'] = Api\DateTime::to($event['start'], 'ts');
136
+					if ($event['end'] && Api\DateTime::to($event['end'], 'ts') > $ids['end']) $ids['end'] = Api\DateTime::to($event['end'], 'ts');
137 137
 					// Keep ids for future use
138 138
 					$this->ids[] = $event['id'];
139 139
 				}
@@ -154,12 +154,12 @@  discard block
 block discarded – undo
154 154
 				'cfs' => strpos($content, '#') !== false ? array_keys(Api\Storage\Customfields::get('calendar')) : null
155 155
 			));
156 156
 			$ids = array();
157
-			foreach($events as $event) {
157
+			foreach ($events as $event) {
158 158
 				$ids[] = $event;
159 159
 			}
160 160
 		}
161 161
 
162
-		return parent::merge_string($content, $ids, $err, $mimetype,$fix);
162
+		return parent::merge_string($content, $ids, $err, $mimetype, $fix);
163 163
 	}
164 164
 
165 165
 	/**
@@ -169,20 +169,20 @@  discard block
 block discarded – undo
169 169
 	 * @param string &$content=null content to create some replacements only if they are used
170 170
 	 * @return array|boolean
171 171
 	 */
172
-	protected function get_replacements($id,&$content=null)
172
+	protected function get_replacements($id, &$content = null)
173 173
 	{
174 174
 		$prefix = '';
175 175
 		// List events ?
176
-		if(is_array($id) && !$id['id'] && !$id[0]['id'])
176
+		if (is_array($id) && !$id['id'] && !$id[0]['id'])
177 177
 		{
178 178
 			$events = $this->bo->search($this->query + $id + array(
179 179
 				'offset' => 0,
180 180
 				'order' => 'cal_start',
181 181
 				'cfs' => strpos($content, '#') !== false ? array_keys(Api\Storage\Customfields::get('calendar')) : null
182 182
 			));
183
-			if(strpos($content,'$$calendar/') !== false || strpos($content, '$$table/day') !== false)
183
+			if (strpos($content, '$$calendar/') !== false || strpos($content, '$$table/day') !== false)
184 184
 			{
185
-				array_unshift($events,false); unset($events[0]);	// renumber the array to start with key 1, instead of 0
185
+				array_unshift($events, false); unset($events[0]); // renumber the array to start with key 1, instead of 0
186 186
 				$prefix = 'calendar/%d';
187 187
 			}
188 188
 		}
@@ -192,11 +192,11 @@  discard block
 block discarded – undo
192 192
 			$events = $id;
193 193
 			$id = array('start' => PHP_INT_MAX, 'end' => 0);
194 194
 			$this->ids = array();
195
-			foreach($events as $event) {
196
-				if($event['start'] && $event['start'] < $id['start']) $id['start'] = $event['start'];
197
-				if($event['end'] && $event['end'] > $id['end']) $id['end'] = $event['end'];
195
+			foreach ($events as $event) {
196
+				if ($event['start'] && $event['start'] < $id['start']) $id['start'] = $event['start'];
197
+				if ($event['end'] && $event['end'] > $id['end']) $id['end'] = $event['end'];
198 198
 				// Keep ids for future use
199
-				$this->ids[]  = $event['id'];
199
+				$this->ids[] = $event['id'];
200 200
 			}
201 201
 			$id = array($id);
202 202
 		}
@@ -208,20 +208,20 @@  discard block
 block discarded – undo
208 208
 		// as this function allows to pass query- parameters, we need to check the result of the query against export_limit restrictions
209 209
 		if (Api\Storage\Merge::hasExportLimit($this->export_limit) && !Api\Storage\Merge::is_export_limit_excepted() && count($events) > (int)$this->export_limit)
210 210
 		{
211
-			$err = lang('No rights to export more than %1 entries!',(int)$this->export_limit);
211
+			$err = lang('No rights to export more than %1 entries!', (int)$this->export_limit);
212 212
 			throw new Api\Exception\WrongUserinput($err);
213 213
 		}
214 214
 		$replacements = array();
215 215
 		$n = 0;
216
-		foreach($events as $event)
216
+		foreach ($events as $event)
217 217
 		{
218
-			$values = $this->calendar_replacements($event,sprintf($prefix,++$n), $content);
219
-			if(is_array($id) && $id['start'])
218
+			$values = $this->calendar_replacements($event, sprintf($prefix, ++$n), $content);
219
+			if (is_array($id) && $id['start'])
220 220
 			{
221
-				foreach(self::$range_tags as $key => $format)
221
+				foreach (self::$range_tags as $key => $format)
222 222
 				{
223 223
 					$value = date($format, $key == 'end' ? $id['end'] : $id['start']);
224
-					if($key == 'month') $value = lang($value);
224
+					if ($key == 'month') $value = lang($value);
225 225
 					$values["$\$range/$key$$"] = $value;
226 226
 				}
227 227
 			}
@@ -237,10 +237,10 @@  discard block
 block discarded – undo
237 237
 	 * @param boolean $last_event_too=false also include information about the last event
238 238
 	 * @return array
239 239
 	 */
240
-	public function calendar_replacements($id,$prefix = '', &$content = '')
240
+	public function calendar_replacements($id, $prefix = '', &$content = '')
241 241
 	{
242 242
 		$replacements = array();
243
-		if(!is_array($id) || !$id['start']) {
243
+		if (!is_array($id) || !$id['start']) {
244 244
 			$event = $this->bo->read(is_array($id) ? $id['id'] : $id, is_array($id) ? $id['recur_date'] : null);
245 245
 		} else {
246 246
 			$event = $id;
@@ -253,68 +253,68 @@  discard block
 block discarded – undo
253 253
 		importexport_export_csv::convert($record, $types, 'calendar');
254 254
 
255 255
 		$array = $record->get_record_array();
256
-		foreach($array as $key => $value)
256
+		foreach ($array as $key => $value)
257 257
 		{
258
-			$replacements['$$'.($prefix?$prefix.'/':'').$key.'$$'] = $value;
258
+			$replacements['$$'.($prefix ? $prefix.'/' : '').$key.'$$'] = $value;
259 259
 		}
260 260
 
261
-		$replacements['$$' . ($prefix ? $prefix . '/' : '') . 'calendar_id'. '$$'] = $event['id'];
262
-		foreach($this->bo->event2array($event) as $name => $data)
261
+		$replacements['$$'.($prefix ? $prefix.'/' : '').'calendar_id'.'$$'] = $event['id'];
262
+		foreach ($this->bo->event2array($event) as $name => $data)
263 263
 		{
264
-			if (substr($name,-4) == 'date') $name = substr($name,0,-4);
265
-			$replacements['$$' . ($prefix ? $prefix . '/' : '') . 'calendar_'.$name . '$$'] = is_array($data['data']) ? implode(', ',$data['data']) : $data['data'];
264
+			if (substr($name, -4) == 'date') $name = substr($name, 0, -4);
265
+			$replacements['$$'.($prefix ? $prefix.'/' : '').'calendar_'.$name.'$$'] = is_array($data['data']) ? implode(', ', $data['data']) : $data['data'];
266 266
 		}
267 267
 		// Add seperate lists of participants by type
268
-		if(strpos($content, 'calendar_participants/')!== false)
268
+		if (strpos($content, 'calendar_participants/') !== false)
269 269
 		{
270 270
 			$types = array();
271
-			foreach($this->bo->resources as $resource)
271
+			foreach ($this->bo->resources as $resource)
272 272
 			{
273 273
 				$types[$resource['app']] = array();
274 274
 			}
275
-			foreach($event['participants'] as $uid => $status)
275
+			foreach ($event['participants'] as $uid => $status)
276 276
 			{
277 277
 				$type = $this->bo->resources[$uid[0]]['app'];
278
-				if($type == 'api-accounts')
278
+				if ($type == 'api-accounts')
279 279
 				{
280 280
 					$type = ($GLOBALS['egw']->accounts->get_type($uid) == 'g' ? 'group' : 'account');
281 281
 				}
282 282
 				$types[$type][] = $this->bo->participant_name($uid);
283 283
 			}
284
-			foreach($types as $t_id => $type)
284
+			foreach ($types as $t_id => $type)
285 285
 			{
286
-				$replacements['$$'.($prefix ? $prefix . '/' : '') . "calendar_participants/{$t_id}$$"] = implode(', ',$type);
286
+				$replacements['$$'.($prefix ? $prefix.'/' : '')."calendar_participants/{$t_id}$$"] = implode(', ', $type);
287 287
 			}
288 288
 		}
289
-		if(!$replacements['$$'.($prefix ? $prefix . '/' : '') . 'calendar_recur_type$$'])
289
+		if (!$replacements['$$'.($prefix ? $prefix.'/' : '').'calendar_recur_type$$'])
290 290
 		{
291 291
 			// Need to set it to '' if not set or previous record may be used
292
-			$replacements['$$'.($prefix ? $prefix . '/' : '') . 'calendar_recur_type$$'] = '';
292
+			$replacements['$$'.($prefix ? $prefix.'/' : '').'calendar_recur_type$$'] = '';
293 293
 		}
294
-		foreach(array('start','end') as $what)
294
+		foreach (array('start', 'end') as $what)
295 295
 		{
296
-			foreach(array(
296
+			foreach (array(
297 297
 				'date' => $GLOBALS['egw_info']['user']['preferences']['common']['dateformat'],
298 298
 				'day'  => 'l',
299
-				'time' => (date('Ymd',$event['start']) != date('Ymd',$event['end']) ? $GLOBALS['egw_info']['user']['preferences']['common']['dateformat'].' ' : '') . ($GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == 12 ? 'h:i a' : 'H:i'),
299
+				'time' => (date('Ymd', $event['start']) != date('Ymd', $event['end']) ? $GLOBALS['egw_info']['user']['preferences']['common']['dateformat'].' ' : '').($GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == 12 ? 'h:i a' : 'H:i'),
300 300
 			) as $name => $format)
301 301
 			{
302
-				$value = Api\DateTime::to($event[$what],$format);
302
+				$value = Api\DateTime::to($event[$what], $format);
303 303
 				if ($format == 'l') $value = lang($value);
304
-				$replacements['$$' .($prefix ? $prefix.'/':'').'calendar_'.$what.$name.'$$'] = $value;
304
+				$replacements['$$'.($prefix ? $prefix.'/' : '').'calendar_'.$what.$name.'$$'] = $value;
305 305
 			}
306 306
 		}
307
-		$duration = ($event['end'] - $event['start'])/60;
308
-		$replacements['$$'.($prefix?$prefix.'/':'').'calendar_duration$$'] = floor($duration/60).lang('h').($duration%60 ? $duration%60 : '');
307
+		$duration = ($event['end'] - $event['start']) / 60;
308
+		$replacements['$$'.($prefix ? $prefix.'/' : '').'calendar_duration$$'] = floor($duration / 60).lang('h').($duration % 60 ? $duration % 60 : '');
309 309
 
310 310
 		// Add in contact stuff for owner
311
-		if (strpos($content,'$$calendar_owner/') !== null && ($user = $GLOBALS['egw']->accounts->id2name($event['owner'],'person_id')))
311
+		if (strpos($content, '$$calendar_owner/') !== null && ($user = $GLOBALS['egw']->accounts->id2name($event['owner'], 'person_id')))
312 312
 		{
313
-			$replacements += $this->contact_replacements($user,($prefix ? $prefix.'/':'').'calendar_owner');
314
-			$replacements['$$'.($prefix?$prefix.'/':'').'calendar_owner/primary_group$$'] = $GLOBALS['egw']->accounts->id2name($GLOBALS['egw']->accounts->id2name($event['owner'],'account_primary_group'));
313
+			$replacements += $this->contact_replacements($user, ($prefix ? $prefix.'/' : '').'calendar_owner');
314
+			$replacements['$$'.($prefix ? $prefix.'/' : '').'calendar_owner/primary_group$$'] = $GLOBALS['egw']->accounts->id2name($GLOBALS['egw']->accounts->id2name($event['owner'], 'account_primary_group'));
315 315
 		}
316 316
 
317
-		if($content && strpos($content, '$$#') !== FALSE)
317
+		if ($content && strpos($content, '$$#') !== FALSE)
318 318
 		{
319 319
 			$this->cf_link_to_expand($event, $content, $replacements);
320 320
 		}
@@ -340,82 +340,82 @@  discard block
 block discarded – undo
340 340
 	* @param string $repeat Text being repeated for each entry
341 341
 	* @return array
342 342
 	*/
343
-	public function day_plugin($plugin,$date,$n,$repeat)
343
+	public function day_plugin($plugin, $date, $n, $repeat)
344 344
 	{
345 345
 		static $days = null;
346
-		if(is_array($date) && !$date['start']) {
346
+		if (is_array($date) && !$date['start']) {
347 347
 			// List of IDs
348
-			if($date[0]['start']) {
348
+			if ($date[0]['start']) {
349 349
 				$id = array('start' => PHP_INT_MAX, 'end' => 0);
350
-				foreach($date as $event) {
351
-					if($event['start'] && $event['start'] < $id['start']) $id['start'] = $event['start'];
352
-					if($event['end'] && $event['end'] > $id['end']) $id['end'] = $event['end'];
350
+				foreach ($date as $event) {
351
+					if ($event['start'] && $event['start'] < $id['start']) $id['start'] = $event['start'];
352
+					if ($event['end'] && $event['end'] > $id['end']) $id['end'] = $event['end'];
353 353
 				}
354 354
 				$date = $id;
355 355
 			} else {
356 356
 				$event = $this->bo->read(is_array($date) ? $date['id'] : $date, is_array($date) ? $date['recur_date'] : null);
357
-				if(date('l',$event['start']) != $plugin) return array();
357
+				if (date('l', $event['start']) != $plugin) return array();
358 358
 				$date = $event['start'];
359 359
 			}
360 360
 		}
361 361
 
362 362
 		$_date = $date['start'] ? $date['start'] : $date;
363
-		if($days[date('Ymd',$_date)][$plugin]) return $days[date('Ymd',$_date)][$plugin][$n];
363
+		if ($days[date('Ymd', $_date)][$plugin]) return $days[date('Ymd', $_date)][$plugin][$n];
364 364
 
365 365
 		$events = $this->bo->search($this->query + array(
366
-			'start' => $date['end'] ? $date['start'] : mktime(0,0,0,date('m',$_date),date('d',$_date),date('Y',$_date)),
367
-			'end' => $date['end'] ? $date['end'] : mktime(23,59,59,date('m',$_date),date('d',$_date),date('Y',$_date)),
366
+			'start' => $date['end'] ? $date['start'] : mktime(0, 0, 0, date('m', $_date), date('d', $_date), date('Y', $_date)),
367
+			'end' => $date['end'] ? $date['end'] : mktime(23, 59, 59, date('m', $_date), date('d', $_date), date('Y', $_date)),
368 368
 			'offset' => 0,
369 369
 			'num_rows' => 20,
370 370
 			'order' => 'cal_start',
371 371
 			'daywise' => true,
372
-			'cfs' => array(),	// read all custom-fields
372
+			'cfs' => array(), // read all custom-fields
373 373
 		));
374 374
 
375 375
 		if (true) $days = array();
376 376
 		$replacements = array();
377 377
 		$time_format = $GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == 12 ? 'h:i a' : 'H:i';
378
-		foreach($events as $day => $list)
378
+		foreach ($events as $day => $list)
379 379
 		{
380
-			foreach($list as $event)
380
+			foreach ($list as $event)
381 381
 			{
382
-				if($this->ids && !in_array($event['id'], $this->ids)) continue;
382
+				if ($this->ids && !in_array($event['id'], $this->ids)) continue;
383 383
 				$start = Api\DateTime::to($event['start'], 'array');
384 384
 				$end = Api\DateTime::to($event['end'], 'array');
385 385
 				$replacements = $this->calendar_replacements($event);
386
-				if($start['year'] == $end['year'] && $start['month'] == $end['month'] && $start['day'] == $end['day']) {
387
-					$dow = date('l',$event['start']);
386
+				if ($start['year'] == $end['year'] && $start['month'] == $end['month'] && $start['day'] == $end['day']) {
387
+					$dow = date('l', $event['start']);
388 388
 				} else {
389 389
 					$dow = date('l', strtotime($day));
390 390
 					// Fancy date+time formatting for multi-day events
391
-					$replacements['$$calendar_starttime$$'] = date($time_format, $day == date('Ymd', $event['start']) ? $event['start'] : mktime(0,0,0,0,0,1));
392
-					$replacements['$$calendar_endtime$$'] = date($time_format, $day == date('Ymd', $event['end']) ? $event['end'] : mktime(23,59,59,0,0,0));
391
+					$replacements['$$calendar_starttime$$'] = date($time_format, $day == date('Ymd', $event['start']) ? $event['start'] : mktime(0, 0, 0, 0, 0, 1));
392
+					$replacements['$$calendar_endtime$$'] = date($time_format, $day == date('Ymd', $event['end']) ? $event['end'] : mktime(23, 59, 59, 0, 0, 0));
393 393
 				}
394 394
 
395
-				$days[date('Ymd',$_date)][$dow][] = $replacements;
395
+				$days[date('Ymd', $_date)][$dow][] = $replacements;
396 396
 			}
397
-			if(strpos($repeat, 'day/date') !== false || strpos($repeat, 'day/name') !== false) {
397
+			if (strpos($repeat, 'day/date') !== false || strpos($repeat, 'day/name') !== false) {
398 398
 				$date_marker = array(
399 399
 					'$$day/date$$' => date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'], strtotime($day)),
400 400
 					'$$day/name$$' => lang(date('l', strtotime($day)))
401 401
 				);
402
-				if(!is_array($days[date('Ymd',$_date)][date('l',strtotime($day))])) {
402
+				if (!is_array($days[date('Ymd', $_date)][date('l', strtotime($day))])) {
403 403
 					$blank = $this->calendar_replacements(array());
404
-					foreach($blank as &$value)
404
+					foreach ($blank as &$value)
405 405
 					{
406 406
 						$value = '';
407 407
 					}
408
-					$days[date('Ymd',$_date)][date('l',strtotime($day))][] = $blank;
408
+					$days[date('Ymd', $_date)][date('l', strtotime($day))][] = $blank;
409 409
 				}
410
-				$days[date('Ymd',$_date)][date('l',strtotime($day))][0] += $date_marker;
410
+				$days[date('Ymd', $_date)][date('l', strtotime($day))][0] += $date_marker;
411 411
 			}
412 412
 			// Add in birthdays
413
-			if(strpos($repeat, 'day/birthdays') !== false)
413
+			if (strpos($repeat, 'day/birthdays') !== false)
414 414
 			{
415
-				$days[date('Ymd', $_date)][date('l',strtotime($day))][0]['$$day/birthdays$$'] = $this->get_birthdays($day);
415
+				$days[date('Ymd', $_date)][date('l', strtotime($day))][0]['$$day/birthdays$$'] = $this->get_birthdays($day);
416 416
 			}
417 417
 		}
418
-		return $days[date('Ymd',$_date)][$plugin][0];
418
+		return $days[date('Ymd', $_date)][$plugin][0];
419 419
 	}
420 420
 
421 421
 	/**
@@ -429,27 +429,27 @@  discard block
 block discarded – undo
429 429
 	* @param string $repeat Text being repeated for each entry
430 430
 	* @return array
431 431
 	*/
432
-	public function day($plugin,$id,$n,$repeat)
432
+	public function day($plugin, $id, $n, $repeat)
433 433
 	{
434 434
 		static $days = null;
435 435
 
436 436
 		// Figure out which day
437
-		list($type, $which) = explode('_',$plugin);
438
-		if($type == 'day' && $which)
437
+		list($type, $which) = explode('_', $plugin);
438
+		if ($type == 'day' && $which)
439 439
 		{
440
-			if($id[0]['start'])
440
+			if ($id[0]['start'])
441 441
 			{
442 442
 				$dates = array('start' => PHP_INT_MAX, 'end' => 0);
443
-				foreach($id as $event) {
444
-					if($event['start'] && $event['start'] < $dates['start']) $dates['start'] = $event['start'];
445
-					if($event['end'] && $event['end'] > $dates['end']) $dates['end'] = $event['end'];
443
+				foreach ($id as $event) {
444
+					if ($event['start'] && $event['start'] < $dates['start']) $dates['start'] = $event['start'];
445
+					if ($event['end'] && $event['end'] > $dates['end']) $dates['end'] = $event['end'];
446 446
 				}
447 447
 				$id = $dates;
448 448
 			}
449 449
 			$arr = $this->bo->date2array($id['start']);
450 450
 			$arr['day'] = $which;
451 451
 			$date = $this->bo->date2ts($arr);
452
-			if(is_array($id) && $id['start'] && ($date < $id['start'] || $date > $id['end'])) return array();
452
+			if (is_array($id) && $id['start'] && ($date < $id['start'] || $date > $id['end'])) return array();
453 453
 		}
454 454
 		elseif ($plugin == 'selected')
455 455
 		{
@@ -459,69 +459,69 @@  discard block
 block discarded – undo
459 459
 		{
460 460
 			$date = strtotime($plugin);
461 461
 		}
462
-		if($type == 'day' && is_array($id) && !$id['start']) {
462
+		if ($type == 'day' && is_array($id) && !$id['start']) {
463 463
 			$event = $this->bo->read(is_array($id) ? $id['id'] : $id, is_array($id) ? $id['recur_date'] : null);
464
-			if($which && date('d',$event['start']) != $which) return array();
465
-			if(date('Ymd',$date) != date('Ymd', $event['start'])) return array();
464
+			if ($which && date('d', $event['start']) != $which) return array();
465
+			if (date('Ymd', $date) != date('Ymd', $event['start'])) return array();
466 466
 			return $n == 0 ? $this->calendar_replacements($event) : array();
467 467
 		}
468 468
 
469 469
 		// Use start for cache, in case of multiple months
470 470
 		$_date = $id['start'] ? $id['start'] : $date;
471
-		if($days[date('Ymd',$_date)][$plugin]) return $days[date('Ymd',$_date)][$plugin][$n];
471
+		if ($days[date('Ymd', $_date)][$plugin]) return $days[date('Ymd', $_date)][$plugin][$n];
472 472
 
473 473
 		$events = $this->bo->search($this->query + array(
474 474
 			'start' => $date,
475
-			'end' => mktime(23,59,59,date('m',$date),date('d',$date),date('Y',$date)),
475
+			'end' => mktime(23, 59, 59, date('m', $date), date('d', $date), date('Y', $date)),
476 476
 			'offset' => 0,
477 477
 			'num_rows' => 20,
478 478
 			'order' => 'cal_start',
479 479
 			'daywise' => true,
480
-			'cfs' => array(),	// read all custom-fields
480
+			'cfs' => array(), // read all custom-fields
481 481
 		));
482 482
 
483 483
 		$replacements = array();
484 484
 		if (true) $days = array();
485 485
 		$time_format = $GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == 12 ? 'h:i a' : 'H:i';
486
-		foreach($events as $day => $list)
486
+		foreach ($events as $day => $list)
487 487
 		{
488
-			foreach($list as $event)
488
+			foreach ($list as $event)
489 489
 			{
490
-				if($this->ids && !in_array($event['id'], $this->ids)) continue;
490
+				if ($this->ids && !in_array($event['id'], $this->ids)) continue;
491 491
 				$start = Api\DateTime::to($event['start'], 'array');
492 492
 				$end = Api\DateTime::to($event['end'], 'array');
493 493
 				$replacements = $this->calendar_replacements($event);
494
-				if($start['year'] == $end['year'] && $start['month'] == $end['month'] && $start['day'] == $end['day']) {
494
+				if ($start['year'] == $end['year'] && $start['month'] == $end['month'] && $start['day'] == $end['day']) {
495 495
 					//$dow = date('l',$event['start']);
496 496
 				} else {
497 497
 					// Fancy date+time formatting for multi-day events
498
-					$replacements['$$calendar_starttime$$'] = date($time_format, $day == date('Ymd', $event['start']) ? $event['start'] : mktime(0,0,0,0,0,1));
499
-					$replacements['$$calendar_endtime$$'] = date($time_format, $day == date('Ymd', $event['end']) ? $event['end'] : mktime(23,59,59,0,0,0));
498
+					$replacements['$$calendar_starttime$$'] = date($time_format, $day == date('Ymd', $event['start']) ? $event['start'] : mktime(0, 0, 0, 0, 0, 1));
499
+					$replacements['$$calendar_endtime$$'] = date($time_format, $day == date('Ymd', $event['end']) ? $event['end'] : mktime(23, 59, 59, 0, 0, 0));
500 500
 				}
501
-				$days[date('Ymd',$_date)][$plugin][] = $replacements;
501
+				$days[date('Ymd', $_date)][$plugin][] = $replacements;
502 502
 			}
503
-			if(strpos($repeat, 'day/date') !== false || strpos($repeat, 'day/name') !== false) {
503
+			if (strpos($repeat, 'day/date') !== false || strpos($repeat, 'day/name') !== false) {
504 504
 				$date_marker = array(
505 505
 					'$$day/date$$' => date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'], strtotime($day)),
506 506
 					'$$day/name$$' => lang(date('l', strtotime($day)))
507 507
 				);
508
-				if(!is_array($days[date('Ymd',$_date)][$plugin])) {
508
+				if (!is_array($days[date('Ymd', $_date)][$plugin])) {
509 509
 					$blank = $this->calendar_replacements(array());
510
-					foreach($blank as &$value)
510
+					foreach ($blank as &$value)
511 511
 					{
512 512
 						$value = '';
513 513
 					}
514
-					$days[date('Ymd',$_date)][$plugin][] = $blank;
514
+					$days[date('Ymd', $_date)][$plugin][] = $blank;
515 515
 				}
516
-				$days[date('Ymd',$_date)][$plugin][0] += $date_marker;
516
+				$days[date('Ymd', $_date)][$plugin][0] += $date_marker;
517 517
 			}
518 518
 			// Add in birthdays
519
-			if(strpos($repeat, 'day/birthdays') !== false)
519
+			if (strpos($repeat, 'day/birthdays') !== false)
520 520
 			{
521
-				$days[date('Ymd', $_date)][date('l',strtotime($day))][0]['$$day/birthdays$$'] = $this->get_birthdays($day);
521
+				$days[date('Ymd', $_date)][date('l', strtotime($day))][0]['$$day/birthdays$$'] = $this->get_birthdays($day);
522 522
 			}
523 523
 		}
524
-		return $days[date('Ymd',$_date)][$plugin][0];
524
+		return $days[date('Ymd', $_date)][$plugin][0];
525 525
 	}
526 526
 
527 527
 	/**
@@ -534,30 +534,30 @@  discard block
 block discarded – undo
534 534
 	* @param int $n
535 535
 	* @return array
536 536
 	*/
537
-	public function participant($plugin,$id,$n)
537
+	public function participant($plugin, $id, $n)
538 538
 	{
539
-		unset($plugin);	// not used, but required by function signature
539
+		unset($plugin); // not used, but required by function signature
540 540
 
541
-		if(!is_array($id) || !$id['start']) {
541
+		if (!is_array($id) || !$id['start']) {
542 542
 			$event = $this->bo->read(is_array($id) ? $id['id'] : $id, is_array($id) ? $id['recur_date'] : null);
543 543
 		} else {
544 544
 			$event = $id;
545 545
 		}
546 546
 
547
-		if(!is_array($event['participants']) || $n >= count($event['participants'])) return array();
547
+		if (!is_array($event['participants']) || $n >= count($event['participants'])) return array();
548 548
 
549 549
 		$participant = null;
550 550
 		$status = null;
551 551
 		$i = -1;
552
-		foreach($event['participants'] as $participant => $status) {
553
-			if(++$i == $n) break;
552
+		foreach ($event['participants'] as $participant => $status) {
553
+			if (++$i == $n) break;
554 554
 		}
555 555
 
556
-		if(!$participant) return array();
556
+		if (!$participant) return array();
557 557
 
558 558
 		// Add some common information
559 559
 		$quantity = $role = null;
560
-		calendar_so::split_status($status,$quantity,$role);
560
+		calendar_so::split_status($status, $quantity, $role);
561 561
 		if ($role != 'REQ-PARTICIPANT')
562 562
 		{
563 563
 			if (isset($this->bo->roles[$role]))
@@ -565,13 +565,13 @@  discard block
 block discarded – undo
565 565
 				$role = lang($this->bo->roles[$role]);
566 566
 			}
567 567
 			// allow to use cats as roles (beside regular iCal ones)
568
-			elseif (substr($role,0,6) == 'X-CAT-' && ($cat_id = (int)substr($role,6)) > 0)
568
+			elseif (substr($role, 0, 6) == 'X-CAT-' && ($cat_id = (int)substr($role, 6)) > 0)
569 569
 			{
570 570
 				$role = $GLOBALS['egw']->categories->id2name($cat_id);
571 571
 			}
572 572
 			else
573 573
 			{
574
-				$role = lang(str_replace('X-','',$role));
574
+				$role = lang(str_replace('X-', '', $role));
575 575
 			}
576 576
 		}
577 577
 		$info = array(
@@ -584,26 +584,26 @@  discard block
 block discarded – undo
584 584
 		switch ($participant[0])
585 585
 		{
586 586
 			case 'c':
587
-				$replacements = $this->contact_replacements(substr($participant,1),'');
587
+				$replacements = $this->contact_replacements(substr($participant, 1), '');
588 588
 				break;
589 589
 			case 'r':
590 590
 				if (is_null(self::$resources)) self::$resources = new resources_bo();
591
-				if (($resource = self::$resources->read(substr($participant,1))))
591
+				if (($resource = self::$resources->read(substr($participant, 1))))
592 592
 				{
593
-					foreach($resource as $name => $value)
593
+					foreach ($resource as $name => $value)
594 594
 					{
595 595
 					    $replacements['$$'.$name.'$$'] = $value;
596 596
 					}
597 597
 				}
598 598
 				break;
599 599
 			default:
600
-				if (is_numeric($participant) && ($contact = $GLOBALS['egw']->accounts->id2name($participant,'person_id')))
600
+				if (is_numeric($participant) && ($contact = $GLOBALS['egw']->accounts->id2name($participant, 'person_id')))
601 601
 				{
602
-					$replacements = $this->contact_replacements($contact,'');
602
+					$replacements = $this->contact_replacements($contact, '');
603 603
 				}
604 604
 				break;
605 605
 		}
606
-		foreach($info as $name => $value)
606
+		foreach ($info as $name => $value)
607 607
 		{
608 608
 			$replacements['$$'.$name.'$$'] = $value;
609 609
 		}
@@ -618,7 +618,7 @@  discard block
 block discarded – undo
618 618
 	{
619 619
 		$contacts = new Api\Contacts();
620 620
 		$birthdays = Array();
621
-		foreach($contacts->get_addressbooks() as $owner => $name)
621
+		foreach ($contacts->get_addressbooks() as $owner => $name)
622 622
 		{
623 623
 			$birthdays += $contacts->read_birthdays($owner, substr($day, 0, 4));
624 624
 		}
@@ -640,7 +640,7 @@  discard block
 block discarded – undo
640 640
 		echo '<tr><td colspan="4"><h3>'.lang('Calendar fields:')."</h3></td></tr>";
641 641
 
642 642
 		$n = 0;
643
-		foreach(array(
643
+		foreach (array(
644 644
 			'calendar_id' => lang('Calendar ID'),
645 645
 			'calendar_title' => lang('Title'),
646 646
 			'calendar_description' => lang('Description'),
@@ -663,7 +663,7 @@  discard block
 block discarded – undo
663 663
 			'calendar_owner'    => lang('Owner'),
664 664
 		) as $name => $label)
665 665
 		{
666
-			if (in_array($name,array('start','end')) && $n&1)		// main values, which should be in the first column
666
+			if (in_array($name, array('start', 'end')) && $n&1)		// main values, which should be in the first column
667 667
 			{
668 668
 				echo "</tr>\n";
669 669
 				$n++;
@@ -676,13 +676,13 @@  discard block
 block discarded – undo
676 676
 
677 677
 		echo '<tr><td colspan="4"><h3>'.lang('Range fields').":</h3></td></tr>";
678 678
 		echo '<tr><td colspan="4">'.lang('If you select a range (month, week, etc) instead of a list of entries, these extra fields are available').'</td></tr>';
679
-		foreach(array_keys(self::$range_tags) as $name)
679
+		foreach (array_keys(self::$range_tags) as $name)
680 680
 		{
681 681
 			echo '<tr><td>{{range/'.$name.'}}</td><td>'.lang($name)."</td></tr>\n";
682 682
 		}
683 683
 		echo '<tr><td colspan="4"><h3>'.lang('Custom fields').":</h3></td></tr>";
684 684
 		$custom = Api\Storage\Customfields::get('calendar');
685
-		foreach($custom as $name => $field)
685
+		foreach ($custom as $name => $field)
686 686
 		{
687 687
 			echo '<tr><td>{{#'.$name.'}}</td><td colspan="3">'.$field['label']."</td></tr>\n";
688 688
 		}
@@ -691,9 +691,9 @@  discard block
 block discarded – undo
691 691
 		echo '<tr><td colspan="4"><h3>'.lang('Participants').":</h3></td></tr>";
692 692
 		echo '<tr><td>{{calendar_participants/account}}</td><td colspan="3">'.lang('Accounts')."</td></tr>\n";
693 693
 		echo '<tr><td>{{calendar_participants/group}}</td><td colspan="3">'.lang('Groups')."</td></tr>\n";
694
-		foreach($this->bo->resources as $resource)
694
+		foreach ($this->bo->resources as $resource)
695 695
 		{
696
-			if($resource['type'])
696
+			if ($resource['type'])
697 697
 			{
698 698
 				echo '<tr><td>{{calendar_participants/'.$resource['app'].'}}</td><td colspan="3">'.lang($resource['app'])."</td></tr>\n";
699 699
 			}
@@ -710,19 +710,19 @@  discard block
 block discarded – undo
710 710
 		echo '<tr style="vertical-align:top"><td colspan="2"><table >';
711 711
 		echo '<tr><td><h3>'.lang('Day of week tables').":</h3></td></tr>";
712 712
 		$days = array();
713
-		for($i = 0; $i < 7; $i++)
713
+		for ($i = 0; $i < 7; $i++)
714 714
 		{
715
-			$days[date('N',strtotime("+$i days"))] = date('l',strtotime("+$i days"));
715
+			$days[date('N', strtotime("+$i days"))] = date('l', strtotime("+$i days"));
716 716
 		}
717 717
 		ksort($days);
718
-		foreach($days as $day)
718
+		foreach ($days as $day)
719 719
 		{
720
-			echo '<tr><td>{{table/'.$day. '}} ... {{endtable}}</td></tr>';
720
+			echo '<tr><td>{{table/'.$day.'}} ... {{endtable}}</td></tr>';
721 721
 		}
722 722
 		echo '</table></td><td colspan="2"><table >';
723 723
 		echo '<tr><td><h3>'.lang('Daily tables').":</h3></td></tr>";
724
-		foreach(self::$relative as $value) {
725
-			echo '<tr><td>{{table/'.$value. '}} ... {{endtable}}</td></tr>';
724
+		foreach (self::$relative as $value) {
725
+			echo '<tr><td>{{table/'.$value.'}} ... {{endtable}}</td></tr>';
726 726
 		}
727 727
 		echo '<tr><td>{{table/day_n}} ... {{endtable}}</td><td>1 <= n <= 31</td></tr>';
728 728
 		echo '</table></td></tr>';
@@ -732,7 +732,7 @@  discard block
 block discarded – undo
732 732
 		echo '<tr><td>{{day/birthdays}}</td><td colspan="3">'.lang('Birthdays').'</td></tr>';
733 733
 
734 734
 		echo '<tr><td colspan="4"><h3>'.lang('General fields:')."</h3></td></tr>";
735
-		foreach(array(
735
+		foreach (array(
736 736
 			'link' => lang('HTML link to the current record'),
737 737
 			'links' => lang('Titles of any entries linked to the current record, excluding attached files'),
738 738
 			'attachments' => lang('List of files linked to the current record'),
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -617,7 +617,7 @@
 block discarded – undo
617 617
 	protected function get_birthdays($day)
618 618
 	{
619 619
 		$contacts = new Api\Contacts();
620
-		$birthdays = Array();
620
+		$birthdays = array();
621 621
 		foreach($contacts->get_addressbooks() as $owner => $name)
622 622
 		{
623 623
 			$birthdays += $contacts->read_birthdays($owner, substr($day, 0, 4));
Please login to merge, or discard this patch.
calendar/inc/class.calendar_favorite_portlet.inc.php 3 patches
Spacing   +41 added lines, -42 removed lines patch added patch discarded remove patch
@@ -32,19 +32,19 @@  discard block
 block discarded – undo
32 32
 		$reload = !is_null($need_reload);
33 33
 
34 34
 		// Let parent handle the basic stuff
35
-		parent::__construct($context,$need_reload);
35
+		parent::__construct($context, $need_reload);
36 36
 
37
-		if($this->favorite['state']['view'] == 'listview')
37
+		if ($this->favorite['state']['view'] == 'listview')
38 38
 		{
39 39
 			$this->context['template'] = 'calendar.list.rows';
40 40
 			$this->context['sel_options'] = array();
41 41
 			$this->nm_settings += array(
42 42
 				'csv_export'      => True,
43
-				'filter_no_lang'  => True,	// I  set no_lang for filter (=dont translate the options)
44
-				'no_filter2'      => True,	// I  disable the 2. filter (params are the same as for filter)
45
-				'no_cat'          => True,	// I  disable the cat-selectbox
43
+				'filter_no_lang'  => True, // I  set no_lang for filter (=dont translate the options)
44
+				'no_filter2'      => True, // I  disable the 2. filter (params are the same as for filter)
45
+				'no_cat'          => True, // I  disable the cat-selectbox
46 46
 				'filter'          => 'after',
47
-				'row_id'          => 'row_id',	// set in get rows "$event[id]:$event[recur_date]"
47
+				'row_id'          => 'row_id', // set in get rows "$event[id]:$event[recur_date]"
48 48
 				'row_modified'    => 'modified',
49 49
 				'get_rows'	=> 'calendar_favorite_portlet::get_rows',
50 50
 				// Use a different template so it can be accessed from client side
@@ -58,17 +58,17 @@  discard block
 block discarded – undo
58 58
 		$need_reload = $reload && $need_reload;
59 59
 	}
60 60
 
61
-	public function exec($id = null, Etemplate &$etemplate = null)
61
+	public function exec($id = null, Etemplate&$etemplate = null)
62 62
 	{
63 63
 
64 64
 		// Always load app's javascript, so most actions have a chance of working
65
-		Framework::includeJS('.','app',$this->context['appname']);
65
+		Framework::includeJS('.', 'app', $this->context['appname']);
66 66
 
67 67
 		// Always load app's css
68 68
 		Framework::includeCSS('calendar', 'app-'.$GLOBALS['egw_info']['user']['preferences']['common']['theme']) ||
69
-			Framework::includeCSS('calendar','app');
69
+			Framework::includeCSS('calendar', 'app');
70 70
 
71
-		if($this->favorite['state']['view'] == 'listview' || is_array($this->favorite) && !$this->favorite['state']['view'])
71
+		if ($this->favorite['state']['view'] == 'listview' || is_array($this->favorite) && !$this->favorite['state']['view'])
72 72
 		{
73 73
 			$ui = new calendar_uilist();
74 74
 		}
@@ -77,16 +77,16 @@  discard block
 block discarded – undo
77 77
 			$ui = new calendar_uiviews();
78 78
 			if ($this->favorite)
79 79
 			{
80
-				if($this->favorite['state']['start']) $ui->search_params['start'] = $this->favorite['state']['start'];
81
-				if($this->favorite['state']['cat_id']) $ui->search_params['cat_id'] = $this->favorite['state']['cat_id'];
80
+				if ($this->favorite['state']['start']) $ui->search_params['start'] = $this->favorite['state']['start'];
81
+				if ($this->favorite['state']['cat_id']) $ui->search_params['cat_id'] = $this->favorite['state']['cat_id'];
82 82
 				// Owner can be 0 for current user
83
-				if(array_key_exists('owner',$this->favorite['state'])) $ui->search_params['users'] = $this->favorite['state']['owner'];
84
-				if($ui->search_params['users'] && !is_array($ui->search_params['users']))
83
+				if (array_key_exists('owner', $this->favorite['state'])) $ui->search_params['users'] = $this->favorite['state']['owner'];
84
+				if ($ui->search_params['users'] && !is_array($ui->search_params['users']))
85 85
 				{
86
-					$ui->search_params['users'] = explode(',',$ui->search_params['users']);
86
+					$ui->search_params['users'] = explode(',', $ui->search_params['users']);
87 87
 				}
88
-				if($this->favorite['state']['filter']) $ui->search_params['filter'] = $this->favorite['state']['filter'];
89
-				if($this->favorite['state']['sortby']) $ui->search_params['sortby'] = $this->favorite['state']['sortby'];
88
+				if ($this->favorite['state']['filter']) $ui->search_params['filter'] = $this->favorite['state']['filter'];
89
+				if ($this->favorite['state']['sortby']) $ui->search_params['sortby'] = $this->favorite['state']['sortby'];
90 90
 				$ui->search_params['weekend'] = $this->favorite['state']['weekend'];
91 91
 			}
92 92
 			$etemplate->read('home.legacy');
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 
97 97
 		$content = array('legacy' => '');
98 98
 
99
-		switch($this->favorite['state']['view'])
99
+		switch ($this->favorite['state']['view'])
100 100
 		{
101 101
 			case 'listview':
102 102
 				$this->context['sel_options']['filter'] = &$ui->date_filters;
@@ -110,9 +110,9 @@  discard block
 block discarded – undo
110 110
 				$content = array();
111 111
 				$etemplate->read('calendar.planner');
112 112
 				$etemplate->set_dom_id($id);
113
-				$this->actions =& $etemplate->getElementAttribute('planner', 'actions');
113
+				$this->actions = & $etemplate->getElementAttribute('planner', 'actions');
114 114
 				// Don't notify the calendar app of date changes
115
-				$etemplate->setElementAttribute('planner','onchange',false);
115
+				$etemplate->setElementAttribute('planner', 'onchange', false);
116 116
 				$ui->planner_view = $this->favorite['state']['planner_view'];
117 117
 				$ui->planner(array(), $etemplate);
118 118
 				return;
@@ -120,20 +120,19 @@  discard block
 block discarded – undo
120 120
 			case 'weekN':
121 121
 				$etemplate->read('calendar.view');
122 122
 				$etemplate->set_dom_id($id);
123
-				$this->actions =& $etemplate->getElementAttribute('view', 'actions');
123
+				$this->actions = & $etemplate->getElementAttribute('view', 'actions');
124 124
 
125 125
 				$ui->month($this->favorite['state']['view'] == 'month' ?
126
-					0 :
127
-					(int)$ui->cal_prefs['multiple_weeks'],
126
+					0 : (int)$ui->cal_prefs['multiple_weeks'],
128 127
 					$etemplate
129 128
 				);
130 129
 				return;
131 130
 			case 'week':
132 131
 				$etemplate->read('calendar.view');
133 132
 				$etemplate->set_dom_id($id);
134
-				$this->actions =& $etemplate->getElementAttribute('view', 'actions');
133
+				$this->actions = & $etemplate->getElementAttribute('view', 'actions');
135 134
 				// Don't notify the calendar app of date changes
136
-				$etemplate->setElementAttribute('view[0]','onchange',false);
135
+				$etemplate->setElementAttribute('view[0]', 'onchange', false);
137 136
 				$ui->week(array(), $etemplate);
138 137
 				return;
139 138
 			case 'day':
@@ -143,7 +142,7 @@  discard block
 block discarded – undo
143 142
 				$days = $this->favorite['state']['days'] ? $this->favorite['state']['days'] : (
144 143
 					$this->favorite['state']['view'] == 'day' ? 1 : 4
145 144
 				);
146
-				$this->actions =& $etemplate->getElementAttribute('view', 'actions');
145
+				$this->actions = & $etemplate->getElementAttribute('view', 'actions');
147 146
 				$ui->week($days, $etemplate);
148 147
 				return;
149 148
 		}
@@ -156,7 +155,7 @@  discard block
 block discarded – undo
156 155
 		$old_app = $GLOBALS['egw_info']['flags']['currentapp'];
157 156
 		$GLOBALS['egw_info']['flags']['currentapp'] = 'calendar';
158 157
 
159
-		$etemplate->exec(get_called_class() .'::process',$content);
158
+		$etemplate->exec(get_called_class().'::process', $content);
160 159
 		$GLOBALS['egw_info']['flags']['currentapp'] = $old_app;
161 160
 	}
162 161
 
@@ -199,27 +198,27 @@  discard block
 block discarded – undo
199 198
 			else
200 199
 			{
201 200
 				$success = $failed = $action_msg = $msg = null;
202
-				if ($ui->action($values['nm']['action'],$values['nm']['selected'],$values['nm']['select_all'],
203
-						$success,$failed,$action_msg,'calendar_list',$msg, $values['nm']['checkboxes']['no_notifications']))
201
+				if ($ui->action($values['nm']['action'], $values['nm']['selected'], $values['nm']['select_all'],
202
+						$success, $failed, $action_msg, 'calendar_list', $msg, $values['nm']['checkboxes']['no_notifications']))
204 203
 				{
205
-					$msg .= lang('%1 event(s) %2',$success,$action_msg);
206
-					Api\Json\Response::get()->apply('egw.message',array($msg,'success'));
207
-					foreach($values['nm']['selected'] as &$id)
204
+					$msg .= lang('%1 event(s) %2', $success, $action_msg);
205
+					Api\Json\Response::get()->apply('egw.message', array($msg, 'success'));
206
+					foreach ($values['nm']['selected'] as &$id)
208 207
 					{
209 208
 						$id = 'calendar::'.$id;
210 209
 					}
211 210
 					// Directly request an update - this will get addressbook tab too
212
-					Api\Json\Response::get()->apply('egw.dataRefreshUIDs',array($values['nm']['selected']));
211
+					Api\Json\Response::get()->apply('egw.dataRefreshUIDs', array($values['nm']['selected']));
213 212
 				}
214
-				elseif(is_null($msg))
213
+				elseif (is_null($msg))
215 214
 				{
216
-					$msg .= lang('%1 entries %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed);
217
-					Api\Json\Response::get()->apply('egw.message',array($msg,'error'));
215
+					$msg .= lang('%1 entries %2, %3 failed because of insufficent rights !!!', $success, $action_msg, $failed);
216
+					Api\Json\Response::get()->apply('egw.message', array($msg, 'error'));
218 217
 				}
219
-				elseif($msg)
218
+				elseif ($msg)
220 219
 				{
221
-					$msg .= "\n".lang('%1 entries %2, %3 failed.',$success,$action_msg,$failed);
222
-					Api\Json\Response::get()->apply('egw.message',array($msg,'error'));
220
+					$msg .= "\n".lang('%1 entries %2, %3 failed.', $success, $action_msg, $failed);
221
+					Api\Json\Response::get()->apply('egw.message', array($msg, 'error'));
223 222
 				}
224 223
 				unset($values['nm']['action']);
225 224
 				unset($values['nm']['select_all']);
@@ -235,9 +234,9 @@  discard block
 block discarded – undo
235 234
 	public function get_properties()
236 235
 	{
237 236
 		$properties = parent::get_properties();
238
-		foreach($properties as &$property)
237
+		foreach ($properties as &$property)
239 238
 		{
240
-			if($property['name'] == 'favorite')
239
+			if ($property['name'] == 'favorite')
241 240
 			{
242 241
 				unset($property['select_options']['blank']);
243 242
 				break;
@@ -247,7 +246,7 @@  discard block
 block discarded – undo
247 246
 	}
248 247
 
249 248
 	public function get_actions() {
250
-		if($this->favorite['state']['view'] == 'listview' || !$this->actions)
249
+		if ($this->favorite['state']['view'] == 'listview' || !$this->actions)
251 250
 		{
252 251
 			return array();
253 252
 		}
Please login to merge, or discard this patch.
Braces   +22 added lines, -6 removed lines patch added patch discarded remove patch
@@ -77,16 +77,31 @@  discard block
 block discarded – undo
77 77
 			$ui = new calendar_uiviews();
78 78
 			if ($this->favorite)
79 79
 			{
80
-				if($this->favorite['state']['start']) $ui->search_params['start'] = $this->favorite['state']['start'];
81
-				if($this->favorite['state']['cat_id']) $ui->search_params['cat_id'] = $this->favorite['state']['cat_id'];
80
+				if($this->favorite['state']['start'])
81
+				{
82
+					$ui->search_params['start'] = $this->favorite['state']['start'];
83
+				}
84
+				if($this->favorite['state']['cat_id'])
85
+				{
86
+					$ui->search_params['cat_id'] = $this->favorite['state']['cat_id'];
87
+				}
82 88
 				// Owner can be 0 for current user
83
-				if(array_key_exists('owner',$this->favorite['state'])) $ui->search_params['users'] = $this->favorite['state']['owner'];
89
+				if(array_key_exists('owner',$this->favorite['state']))
90
+				{
91
+					$ui->search_params['users'] = $this->favorite['state']['owner'];
92
+				}
84 93
 				if($ui->search_params['users'] && !is_array($ui->search_params['users']))
85 94
 				{
86 95
 					$ui->search_params['users'] = explode(',',$ui->search_params['users']);
87 96
 				}
88
-				if($this->favorite['state']['filter']) $ui->search_params['filter'] = $this->favorite['state']['filter'];
89
-				if($this->favorite['state']['sortby']) $ui->search_params['sortby'] = $this->favorite['state']['sortby'];
97
+				if($this->favorite['state']['filter'])
98
+				{
99
+					$ui->search_params['filter'] = $this->favorite['state']['filter'];
100
+				}
101
+				if($this->favorite['state']['sortby'])
102
+				{
103
+					$ui->search_params['sortby'] = $this->favorite['state']['sortby'];
104
+				}
90 105
 				$ui->search_params['weekend'] = $this->favorite['state']['weekend'];
91 106
 			}
92 107
 			$etemplate->read('home.legacy');
@@ -246,7 +261,8 @@  discard block
 block discarded – undo
246 261
 		return $properties;
247 262
 	}
248 263
 
249
-	public function get_actions() {
264
+	public function get_actions()
265
+	{
250 266
 		if($this->favorite['state']['view'] == 'listview' || !$this->actions)
251 267
 		{
252 268
 			return array();
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@
 block discarded – undo
25 25
 	 * Construct the portlet
26 26
 	 * Calendar complicates things...
27 27
 	 */
28
-	public function __construct(Array &$context = array(), &$need_reload = false)
28
+	public function __construct(array &$context = array(), &$need_reload = false)
29 29
 	{
30 30
 		$context['appname'] = 'calendar';
31 31
 		// Reload is NULL when changing properties via AJAX
Please login to merge, or discard this patch.
calendar/inc/class.calendar_tracking.inc.php 2 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -132,10 +132,10 @@  discard block
 block discarded – undo
132 132
 		}
133 133
 
134 134
 		/**
135
-		* Do some magic with the participants and recurrance.
136
-		* If this is one of a recurring event, append the recur_date to the participant field so we can
137
-		* filter by it later.
138
-		*/
135
+		 * Do some magic with the participants and recurrance.
136
+		 * If this is one of a recurring event, append the recur_date to the participant field so we can
137
+		 * filter by it later.
138
+		 */
139 139
 		if(is_array($data['participants']))
140 140
 		{
141 141
 			$participants = $data['participants'];
@@ -195,10 +195,10 @@  discard block
 block discarded – undo
195 195
 	}
196 196
 
197 197
 	/**
198
-	* Do some magic with the participants and recurrance.
199
-	* If this is one of a recurring event, append the recur_date to the participant field so we can
200
-	* filter by it later.
201
-	*/
198
+	 * Do some magic with the participants and recurrance.
199
+	 * If this is one of a recurring event, append the recur_date to the participant field so we can
200
+	 * filter by it later.
201
+	 */
202 202
 	protected function alter_participants($participants)
203 203
 	{
204 204
 		$data = array();
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -114,18 +114,18 @@  discard block
 block discarded – undo
114 114
 	 */
115 115
 	public function __construct()
116 116
 	{
117
-		parent::__construct('calendar');	// adds custom fields
117
+		parent::__construct('calendar'); // adds custom fields
118 118
 	}
119 119
 
120 120
 	/**
121 121
 	 * Tracks the changes in one entry $data, by comparing it with the last version in $old
122 122
 	 * Overrides parent to reformat participants into a format parent can handle
123 123
 	 */
124
-	public function track(array $data,array $old=null,$user=null,$deleted=null,array $changed_fields=null)
124
+	public function track(array $data, array $old = null, $user = null, $deleted = null, array $changed_fields = null)
125 125
 	{
126 126
 		// Don't try to track dates on recurring events.
127 127
 		// It won't change for the base event, and any change to the time creates an exception
128
-		if($data['recur_type'])
128
+		if ($data['recur_type'])
129 129
 		{
130 130
 			unset($data['start']); unset($data['end']);
131 131
 			unset($old['start']); unset($old['end']);
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 		* If this is one of a recurring event, append the recur_date to the participant field so we can
137 137
 		* filter by it later.
138 138
 		*/
139
-		if(is_array($data['participants']))
139
+		if (is_array($data['participants']))
140 140
 		{
141 141
 			$participants = $data['participants'];
142 142
 			$data['participants'] = array();
@@ -144,25 +144,25 @@  discard block
 block discarded – undo
144 144
 		}
145 145
 		// if clients eg. CalDAV do NOT set participants, they are left untouched
146 146
 		// therefore we should not track them, as all updates then show up as all participants removed
147
-		elseif(!isset($data['participants']))
147
+		elseif (!isset($data['participants']))
148 148
 		{
149 149
 			unset($old['participants']);
150 150
 		}
151
-		if(is_array($old['participants']))
151
+		if (is_array($old['participants']))
152 152
 		{
153 153
 			$participants = $old['participants'];
154 154
 			$old['participants'] = array();
155 155
 			$old = array_merge($old, $this->alter_participants($participants));
156 156
 		}
157
-		parent::track($data,$old,$user,$deleted, $changed_fields);
157
+		parent::track($data, $old, $user, $deleted, $changed_fields);
158 158
 	}
159 159
 
160 160
 	/**
161 161
 	 * Overrides parent because calendar_boupdates handles the notifications
162 162
 	 */
163
-	public function do_notifications($data,$old,$deleted=null)
163
+	public function do_notifications($data, $old, $deleted = null)
164 164
 	{
165
-		unset($data, $old, $deleted);	// unused, but required by function signature
165
+		unset($data, $old, $deleted); // unused, but required by function signature
166 166
 		return true;
167 167
 	}
168 168
 
@@ -177,21 +177,21 @@  discard block
 block discarded – undo
177 177
 	 * @param array $old = null
178 178
 	 * @return array of keys with different values in $data and $old
179 179
 	 */
180
-	public function changed_fields(array $data,array $old=null)
180
+	public function changed_fields(array $data, array $old = null)
181 181
 	{
182
-		if(is_array($data['participants']))
182
+		if (is_array($data['participants']))
183 183
 		{
184 184
 			$participants = $data['participants'];
185 185
 			$data['participants'] = array();
186 186
 			$data = array_merge($data, $this->alter_participants($participants));
187 187
 		}
188
-		if(is_array($old['participants']))
188
+		if (is_array($old['participants']))
189 189
 		{
190 190
 			$participants = $old['participants'];
191 191
 			$old['participants'] = array();
192 192
 			$old = array_merge($old, $this->alter_participants($participants));
193 193
 		}
194
-		return parent::changed_fields($data,$old);
194
+		return parent::changed_fields($data, $old);
195 195
 	}
196 196
 
197 197
 	/**
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 	protected function alter_participants($participants)
203 203
 	{
204 204
 		$data = array();
205
-		foreach($participants as $uid => $status)
205
+		foreach ($participants as $uid => $status)
206 206
 		{
207 207
 			$quantity = $role = $user_type = $user_id = null;
208 208
 			calendar_so::split_status($status, $quantity, $role);
Please login to merge, or discard this patch.
calendar/inc/class.calendar_so.inc.php 5 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1528,7 +1528,7 @@
 block discarded – undo
1528 1528
 			if (!$set_recurrences)
1529 1529
 			{
1530 1530
 				$set_recurrences = (isset($event['cal_start']) && (int)$old_min != (int) $event['cal_start']) ||
1531
-				    $event['recur_type'] != $old_repeats['recur_type'] || $event['recur_data'] != $old_repeats['recur_data'] ||
1531
+					$event['recur_type'] != $old_repeats['recur_type'] || $event['recur_data'] != $old_repeats['recur_data'] ||
1532 1532
 					(int)$event['recur_interval'] != (int)$old_repeats['recur_interval'] || $event['tz_id'] != $old_tz_id;
1533 1533
 			}
1534 1534
 
Please login to merge, or discard this patch.
Doc Comments   +12 added lines, -36 removed lines patch added patch discarded remove patch
@@ -211,23 +211,11 @@  discard block
 block discarded – undo
211 211
 	 * @param int $start startdate of the search/list (servertime)
212 212
 	 * @param int $end enddate of the search/list (servertime)
213 213
 	 * @param int|array $users user-id or array of user-id's, !$users means all entries regardless of users
214
-	 * @param int|array $cat_id =0 mixed category-id or array of cat-id's (incl. all sub-categories), default 0 = all
214
+	 * @param integer $cat_id =0 mixed category-id or array of cat-id's (incl. all sub-categories), default 0 = all
215 215
 	 * @param string $filter ='default' string filter-name: all (not rejected), accepted, unknown, tentative, rejected or everything (incl. rejected, deleted)
216 216
 	 * @param int|boolean $offset =False offset for a limited query or False (default)
217 217
 	 * @param int $num_rows =0 number of rows to return if offset set, default 0 = use default in user prefs
218 218
 	 * @param array $params =array()
219
-	 * @param string|array $params['query'] string: pattern so search for, if unset or empty all matching entries are returned (no search)
220
-	 *		Please Note: a search never returns repeating events more then once AND does not honor start+end date !!!
221
-	 *      array: everything is directly used as $where
222
-	 * @param string $params['order'] ='cal_start' column-names plus optional DESC|ASC separted by comma
223
-	 * @param string $params['sql_filter'] sql to be and'ed into query (fully quoted)
224
-	 * @param string|array $params['cols'] what to select, default "$this->repeats_table.*,$this->cal_table.*,cal_start,cal_end,cal_recur_date",
225
-	 * 						if specified and not false an iterator for the rows is returned
226
-	 * @param string $params['append'] SQL to append to the query before $order, eg. for a GROUP BY clause
227
-	 * @param array $params['cfs'] custom fields to query, null = none, array() = all, or array with cfs names
228
-	 * @param array $params['users'] raw parameter as passed to calendar_bo::search() no memberships resolved!
229
-	 * @param boolean $params['master_only'] =false, true only take into account participants/status from master (for AS)
230
-	 * @param boolean $params['enum_recuring'] =true enumerate recuring events
231 219
 	 * @param int $remove_rejected_by_user =null add join to remove entry, if given user has rejected it
232 220
 	 * @return array of events
233 221
 	 */
@@ -594,7 +582,7 @@  discard block
 block discarded – undo
594 582
 	/**
595 583
 	 * generate SQL to filter after a given category (incl. subcategories)
596 584
 	 *
597
-	 * @param array|int $cat_id cat-id or array of cat-ids, or !$cat_id for none
585
+	 * @param integer $cat_id cat-id or array of cat-ids, or !$cat_id for none
598 586
 	 * @return string SQL to include in the query
599 587
 	 */
600 588
 	function cat_filter($cat_id)
@@ -682,24 +670,11 @@  discard block
 block discarded – undo
682 670
 	 * @param int $start startdate of the search/list (servertime)
683 671
 	 * @param int $end enddate of the search/list (servertime)
684 672
 	 * @param int|array $users user-id or array of user-id's, !$users means all entries regardless of users
685
-	 * @param int|array $cat_id =0 mixed category-id or array of cat-id's (incl. all sub-categories), default 0 = all
673
+	 * @param integer $cat_id =0 mixed category-id or array of cat-id's (incl. all sub-categories), default 0 = all
686 674
 	 * @param string $filter ='all' string filter-name: all (not rejected), accepted, unknown, tentative, rejected or everything (incl. rejected, deleted)
687 675
 	 * @param int|boolean $offset =False offset for a limited query or False (default)
688 676
 	 * @param int $num_rows =0 number of rows to return if offset set, default 0 = use default in user prefs
689 677
 	 * @param array $params =array()
690
-	 * @param string|array $params['query'] string: pattern so search for, if unset or empty all matching entries are returned (no search)
691
-	 *		Please Note: a search never returns repeating events more then once AND does not honor start+end date !!!
692
-	 *      array: everything is directly used as $where
693
-	 * @param string $params['order'] ='cal_start' column-names plus optional DESC|ASC separted by comma
694
-	 * @param string|array $params['sql_filter'] sql to be and'ed into query (fully quoted), or usual filter array
695
-	 * @param string|array $params['cols'] what to select, default "$this->repeats_table.*,$this->cal_table.*,cal_start,cal_end,cal_recur_date",
696
-	 * 						if specified and not false an iterator for the rows is returned
697
-	 * @param string $params['append'] SQL to append to the query before $order, eg. for a GROUP BY clause
698
-	 * @param array $params['cfs'] custom fields to query, null = none, array() = all, or array with cfs names
699
-	 * @param array $params['users'] raw parameter as passed to calendar_bo::search() no memberships resolved!
700
-	 * @param boolean $params['master_only'] =false, true only take into account participants/status from master (for AS)
701
-	 * @param boolean $params['enum_recuring'] =true enumerate recuring events
702
-	 * @param boolean $params['use_so_events'] =false, true return result of new $this->events()
703 678
 	 * @param int $remove_rejected_by_user =null add join to remove entry, if given user has rejected it
704 679
 	 * @return Iterator|array of events
705 680
 	 */
@@ -1140,11 +1115,11 @@  discard block
 block discarded – undo
1140 1115
 	 * Ask other apps if they want to participate in calendar search / display
1141 1116
 	 *
1142 1117
 	 * @param &$selects parts of union query
1143
-	 * @param $start see search()
1144
-	 * @param $end
1118
+	 * @param integer $start see search()
1119
+	 * @param integer $end
1145 1120
 	 * @param $users as used in calendar_so ($users_raw plus all members and memberships added by calendar_bo)
1146
-	 * @param $cat_id
1147
-	 * @param $filter
1121
+	 * @param integer $cat_id
1122
+	 * @param string $filter
1148 1123
 	 * @param $query
1149 1124
 	 * @param $users_raw as passed to calendar_bo::search (no members and memberships added)
1150 1125
 	 */
@@ -1312,6 +1287,7 @@  discard block
 block discarded – undo
1312 1287
 	 * @param int &$set_recurrences_start=0 on return: time from which on the recurrences should be rebuilt, default 0=all
1313 1288
 	 * @param int $change_since =0 time from which on the repetitions should be changed, default 0=all
1314 1289
 	 * @param int &$etag etag=null etag to check or null, on return new etag
1290
+	 * @param boolean $set_recurrences
1315 1291
 	 * @return boolean|int false on error, 0 if etag does not match, cal_id otherwise
1316 1292
 	 */
1317 1293
 	function save($event,&$set_recurrences,&$set_recurrences_start=0,$change_since=0,&$etag=null)
@@ -1722,7 +1698,7 @@  discard block
 block discarded – undo
1722 1698
 	 * @param int $cal_id
1723 1699
 	 * @param int $start new starttime
1724 1700
 	 * @param int $end new endtime
1725
-	 * @param int|boolean $change_since =0 false=new entry, > 0 time from which on the repetitions should be changed, default 0=all
1701
+	 * @param integer $change_since =0 false=new entry, > 0 time from which on the repetitions should be changed, default 0=all
1726 1702
 	 * @param int $old_start =0 old starttime or (default) 0, to query it from the db
1727 1703
 	 * @param int $old_end =0 old starttime or (default) 0
1728 1704
 	 * @todo Recalculate recurrences, if timezone changes
@@ -1899,7 +1875,7 @@  discard block
 block discarded – undo
1899 1875
 	 *
1900 1876
 	 * @param int $cal_id
1901 1877
 	 * @param array $participants uid => status pairs
1902
-	 * @param int|boolean $change_since =0, false=new event,
1878
+	 * @param integer $change_since =0, false=new event,
1903 1879
 	 * 		0=all, > 0 time from which on the repetitions should be changed
1904 1880
 	 * @param boolean $add_only =false
1905 1881
 	 *		false = add AND delete participants if needed (full list of participants required in $participants)
@@ -2045,7 +2021,7 @@  discard block
 block discarded – undo
2045 2021
 	 * set the status of one participant for a given recurrence or for all recurrences since now (includes recur_date=0)
2046 2022
 	 *
2047 2023
 	 * @param int $cal_id
2048
-	 * @param char $user_type 'u' regular user, 'r' resource, 'c' contact
2024
+	 * @param string $user_type 'u' regular user, 'r' resource, 'c' contact
2049 2025
 	 * @param int|string $user_id
2050 2026
 	 * @param int|char $status numeric status (defines) or 1-char code: 'R', 'U', 'T' or 'A'
2051 2027
 	 * @param int $recur_date =0 date to change, or 0 = all since now
@@ -2962,7 +2938,7 @@  discard block
 block discarded – undo
2962 2938
 	 * Updates the modification timestamp to force an etag, ctag and sync-token change
2963 2939
 	 *
2964 2940
 	 * @param int $id event id
2965
-	 * @param int|boolean $update_master =false id of series master or true, to update series master too
2941
+	 * @param boolean $update_master =false id of series master or true, to update series master too
2966 2942
 	 * @param int $time =null new timestamp, default current (server-)time
2967 2943
 	 * @param int $modifier =null uid of the modifier, default current user
2968 2944
 	 */
Please login to merge, or discard this patch.
Upper-Lower-Casing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 			"	CASE WHEN recur_type IS NULL THEN egw_cal.range_start ELSE cal_start END AS cal_start,\n".
253 253
 			"	CASE WHEN recur_type IS NULL THEN egw_cal.range_end ELSE cal_end END AS cal_end\n".
254 254
 			// using time-limited range view, instead of complete table, give a big performance plus
255
-			"FROM $egw_cal\n".
255
+			"from $egw_cal\n".
256 256
 			"JOIN egw_cal_user ON egw_cal_user.cal_id=egw_cal.cal_id\n".
257 257
 			// need to left join dates, as egw_cal_user.recur_date is null for non-recuring event
258 258
 			"LEFT JOIN egw_cal_dates ON egw_cal_user.cal_id=egw_cal_dates.cal_id AND egw_cal_dates.cal_start=egw_cal_user.cal_recur_date\n".
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
 			$where[] = 'cal_start >= '.(int)$recur_date;
346 346
 			$group_by = 'GROUP BY '.$cols;
347 347
 			$cols .= ',MIN(cal_start) AS cal_start,MIN(cal_end) AS cal_end';
348
-			$join = "JOIN $this->dates_table ON $this->cal_table.cal_id=$this->dates_table.cal_id $join";
348
+			$join = "join $this->dates_table ON $this->cal_table.cal_id=$this->dates_table.cal_id $join";
349 349
 		}
350 350
 		else
351 351
 		{
@@ -874,7 +874,7 @@  discard block
 block discarded – undo
874 874
 		$cal_table = $this->cal_range_view($start, $end, null, $filter == 'everything' ? null : $filter != 'deleted');
875 875
 		$cal_table_def = $this->db->get_table_definitions('calendar', $this->cal_table);
876 876
 
877
-		$join = "JOIN $this->user_table ON $this->cal_table.cal_id=$this->user_table.cal_id ".
877
+		$join = "join $this->user_table ON $this->cal_table.cal_id=$this->user_table.cal_id ".
878 878
 			"LEFT JOIN $this->repeats_table ON $this->cal_table.cal_id=$this->repeats_table.cal_id ".
879 879
 			$rejected_by_user_join;
880 880
 		// dates table join only needed to enum recuring events, we use a time-range limited view here too
@@ -1401,7 +1401,7 @@  discard block
 block discarded – undo
1401 1401
 			{
1402 1402
 				$old_repeats = $this->db->select($this->repeats_table, "$this->repeats_table.*,range_end AS recur_enddate",
1403 1403
 					"$this->repeats_table.cal_id=".(int)$cal_id, __LINE__, __FILE__,
1404
-					false, '', 'calendar', 0, "JOIN $this->cal_table ON $this->repeats_table.cal_id=$this->cal_table.cal_id")->fetch();
1404
+					false, '', 'calendar', 0, "join $this->cal_table ON $this->repeats_table.cal_id=$this->cal_table.cal_id")->fetch();
1405 1405
 			}
1406 1406
 			$where = array('cal_id' => $cal_id);
1407 1407
 			// read only timezone id, to check if it is changed
@@ -1766,13 +1766,13 @@  discard block
 block discarded – undo
1766 1766
 		if ($move_start)
1767 1767
 		{
1768 1768
 			// move the recur-date of the participants
1769
-			$this->db->query("UPDATE $this->user_table SET cal_recur_date=cal_recur_date+$move_start WHERE $where AND cal_recur_date ".
1769
+			$this->db->query("update $this->user_table SET cal_recur_date=cal_recur_date+$move_start WHERE $where AND cal_recur_date ".
1770 1770
 				((int)$change_since ? '>= '.(int)$change_since : '!= 0'),__LINE__,__FILE__);
1771 1771
 		}
1772 1772
 		if ($move_start || $move_end)
1773 1773
 		{
1774 1774
 			// move the event and it's recurrences
1775
-			$this->db->query("UPDATE $this->dates_table SET cal_start=cal_start+$move_start,cal_end=cal_end+$move_end WHERE $where".
1775
+			$this->db->query("update $this->dates_table SET cal_start=cal_start+$move_start,cal_end=cal_end+$move_end WHERE $where".
1776 1776
 				((int) $change_since ? ' AND cal_start >= '.(int) $change_since : ''),__LINE__,__FILE__);
1777 1777
 		}
1778 1778
 		return $this->db->affected_rows();
@@ -2472,7 +2472,7 @@  discard block
 block discarded – undo
2472 2472
 			),__LINE__,__FILE__,'calendar');
2473 2473
 
2474 2474
 			// delete calendar entries without participants (can happen if the deleted user is the only participants, but not the owner)
2475
-			foreach($this->db->select($this->cal_table,"DISTINCT $this->cal_table.cal_id",'cal_user_id IS NULL',__LINE__,__FILE__,
2475
+			foreach($this->db->select($this->cal_table,"distinct $this->cal_table.cal_id",'cal_user_id IS NULL',__LINE__,__FILE__,
2476 2476
 				False,'','calendar',0,"LEFT JOIN $this->user_table ON $this->cal_table.cal_id=$this->user_table.cal_id") as $row)
2477 2477
 			{
2478 2478
 				$this->delete($row['cal_id']);
Please login to merge, or discard this patch.
Braces   +366 added lines, -96 removed lines patch added patch discarded remove patch
@@ -154,16 +154,32 @@  discard block
 block discarded – undo
154 154
 	 */
155 155
 	protected function cal_range_view($start, $end, array $_where=null, $deleted=false)
156 156
 	{
157
-		if ($GLOBALS['egw_info']['server']['no_timerange_views'] || !$start)	// using view without start-date is slower!
157
+		if ($GLOBALS['egw_info']['server']['no_timerange_views'] || !$start)
158 158
 		{
159
-			return $this->cal_table;	// no need / use for a view
159
+			// using view without start-date is slower!
160
+		{
161
+			return $this->cal_table;
162
+		}
163
+		// no need / use for a view
160 164
 		}
161 165
 
162 166
 		$where = array();
163
-		if (isset($deleted)) $where[] = "cal_deleted IS ".($deleted ? '' : 'NOT').' NULL';
164
-		if ($end) $where[] = "range_start<".(int)$end;
165
-		if ($start) $where[] = "(range_end IS NULL OR range_end>".(int)$start.")";
166
-		if ($_where) $where = array_merge($where, $_where);
167
+		if (isset($deleted))
168
+		{
169
+			$where[] = "cal_deleted IS ".($deleted ? '' : 'NOT').' NULL';
170
+		}
171
+		if ($end)
172
+		{
173
+			$where[] = "range_start<".(int)$end;
174
+		}
175
+		if ($start)
176
+		{
177
+			$where[] = "(range_end IS NULL OR range_end>".(int)$start.")";
178
+		}
179
+		if ($_where)
180
+		{
181
+			$where = array_merge($where, $_where);
182
+		}
167 183
 
168 184
 		$sql = "(SELECT * FROM $this->cal_table WHERE ".$this->db->expression($this->cal_table, $where).") $this->cal_table";
169 185
 
@@ -184,16 +200,32 @@  discard block
 block discarded – undo
184 200
 	 */
185 201
 	protected function dates_range_view($start, $end, array $_where=null, $deleted=false)
186 202
 	{
187
-		if ($GLOBALS['egw_info']['server']['no_timerange_views'] || !$start || !$end)	// using view without start- AND end-date is slower!
203
+		if ($GLOBALS['egw_info']['server']['no_timerange_views'] || !$start || !$end)
204
+		{
205
+			// using view without start- AND end-date is slower!
188 206
 		{
189
-			return $this->dates_table;	// no need / use for a view
207
+			return $this->dates_table;
208
+		}
209
+		// no need / use for a view
190 210
 		}
191 211
 
192 212
 		$where = array();
193
-		if (isset($deleted)) $where['recur_exception'] = $deleted;
194
-		if ($end) $where[] = "cal_start<".(int)$end;
195
-		if ($start) $where[] = "cal_end>".(int)$start;
196
-		if ($_where) $where = array_merge($where, $_where);
213
+		if (isset($deleted))
214
+		{
215
+			$where['recur_exception'] = $deleted;
216
+		}
217
+		if ($end)
218
+		{
219
+			$where[] = "cal_start<".(int)$end;
220
+		}
221
+		if ($start)
222
+		{
223
+			$where[] = "cal_end>".(int)$start;
224
+		}
225
+		if ($_where)
226
+		{
227
+			$where = array_merge($where, $_where);
228
+		}
197 229
 
198 230
 		// Api\Db::union uses Api\Db::select which check if join contains "WHERE"
199 231
 		// to support old join syntax like ", other_table WHERE ...",
@@ -243,7 +275,10 @@  discard block
 block discarded – undo
243 275
 			throw new Api\Exception\AssertionFailed("Unsupported value for parameters!");
244 276
 		}
245 277
 		$where = is_array($params['query']) ? $params['query'] : array();
246
-		if ($cat_id) $where[] = $this->cat_filter($cat_id);
278
+		if ($cat_id)
279
+		{
280
+			$where[] = $this->cat_filter($cat_id);
281
+		}
247 282
 		$egw_cal = $this->cal_range_view($start, $end, $where, $filter == 'everything' ? null : $filter != 'deleted');
248 283
 
249 284
 		$status_filter = $this->status_filter($filter, $params['enum_recuring']);
@@ -264,7 +299,10 @@  discard block
 block discarded – undo
264 299
 		if ($users)
265 300
 		{
266 301
 			// fix $users to also prefix system users and groups (with 'u')
267
-			if (!is_array($users)) $users = $users ? (array)$users : array();
302
+			if (!is_array($users))
303
+			{
304
+				$users = $users ? (array)$users : array();
305
+			}
268 306
 			foreach($users as &$uid)
269 307
 			{
270 308
 				$user_type = $user_id = null;
@@ -284,15 +322,22 @@  discard block
 block discarded – undo
284 322
 			$sql .= " AND\n	".$params['sql_filter'];
285 323
 		}
286 324
 
287
-		if ($params['order'])	// only order if requested
325
+		if ($params['order'])
288 326
 		{
289
-			if (!preg_match('/^[a-z_ ,c]+$/i',$params['order'])) $params['order'] = 'cal_start';		// gard against SQL injection
327
+			// only order if requested
328
+		{
329
+			if (!preg_match('/^[a-z_ ,c]+$/i',$params['order'])) $params['order'] = 'cal_start';
330
+		}
331
+		// gard against SQL injection
290 332
 			$sql .= "\nORDER BY ".$params['order'];
291 333
 		}
292 334
 
293
-		if ($offset === false)	// return all rows --> Api\Db::query wants offset=0, num_rows=-1
335
+		if ($offset === false)
336
+		{
337
+			// return all rows --> Api\Db::query wants offset=0, num_rows=-1
294 338
 		{
295 339
 			$offset = 0;
340
+		}
296 341
 			$num_rows = -1;
297 342
 		}
298 343
 		$events =& $this->get_events($this->db->query($sql, __LINE__, __FILE__, $offset, $num_rows));
@@ -318,26 +363,35 @@  discard block
 block discarded – undo
318 363
 		$join = "LEFT JOIN $this->repeats_table ON $this->cal_table.cal_id=$this->repeats_table.cal_id";
319 364
 
320 365
 		$where = array();
321
-		if (is_scalar($ids) && !is_numeric($ids))	// a single uid
366
+		if (is_scalar($ids) && !is_numeric($ids))
367
+		{
368
+			// a single uid
322 369
 		{
323 370
 			// We want only the parents to match
324 371
 			$where['cal_uid'] = $ids;
372
+		}
325 373
 			$where['cal_reference'] = 0;
326 374
 		}
327
-		elseif(is_array($ids) && isset($ids[count($ids)-1]) || is_scalar($ids))	// one or more cal_id's
375
+		elseif(is_array($ids) && isset($ids[count($ids)-1]) || is_scalar($ids))
376
+		{
377
+			// one or more cal_id's
328 378
 		{
329 379
 			$where['cal_id'] = $ids;
330 380
 		}
381
+		}
331 382
 		else	// array with column => value pairs
332 383
 		{
333 384
 			$where = $ids;
334 385
 			unset($ids);	// otherwise users get not read!
335 386
 		}
336
-		if (isset($where['cal_id']))	// prevent non-unique column-name cal_id
387
+		if (isset($where['cal_id']))
388
+		{
389
+			// prevent non-unique column-name cal_id
337 390
 		{
338 391
 			$where[] = $this->db->expression($this->cal_table, $this->cal_table.'.',array(
339 392
 				'cal_id' => $where['cal_id'],
340 393
 			));
394
+		}
341 395
 			unset($where['cal_id']);
342 396
 		}
343 397
 		if ((int) $recur_date)
@@ -387,10 +441,16 @@  discard block
 block discarded – undo
387 441
 			$row['recur_exception'] = $row['alarm'] = array();
388 442
 			$events[$row['cal_id']] = Api\Db::strip_array_keys($row,'cal_');
389 443
 		}
390
-		if (!$events) return $events;
444
+		if (!$events)
445
+		{
446
+			return $events;
447
+		}
391 448
 
392 449
 		$ids = array_keys($events);
393
-		if (count($ids) == 1) $ids = $ids[0];
450
+		if (count($ids) == 1)
451
+		{
452
+			$ids = $ids[0];
453
+		}
394 454
 
395 455
 		foreach ($events as &$event)
396 456
 		{
@@ -464,10 +524,13 @@  discard block
 block discarded – undo
464 524
 			'cal_id'      => $ids,
465 525
 			'cal_recur_date' => $recur_date,
466 526
 			"cal_status NOT IN ('X','E')",
467
-		),__LINE__,__FILE__,false,'ORDER BY cal_user_type DESC,cal_recur_date ASC,'.self::STATUS_SORT,'calendar') as $row)	// DESC puts users before resources and contacts
527
+		),__LINE__,__FILE__,false,'ORDER BY cal_user_type DESC,cal_recur_date ASC,'.self::STATUS_SORT,'calendar') as $row)
528
+		{
529
+			// DESC puts users before resources and contacts
468 530
 		{
469 531
 			// combine all participant data in uid and status values
470 532
 			$uid    = self::combine_user($row['cal_user_type'], $row['cal_user_id'], $row['cal_user_attendee']);
533
+		}
471 534
 			$status = self::combine_status($row['cal_status'],$row['cal_quantity'],$row['cal_role']);
472 535
 
473 536
 			$events[$row['cal_id']]['participants'][$uid] = $status;
@@ -524,7 +587,10 @@  discard block
 block discarded – undo
524 587
 			$last_request = time();
525 588
 		}
526 589
 		$signature = serialize(func_get_args());
527
-		if (isset($ctags[$signature])) return $ctags[$signature];
590
+		if (isset($ctags[$signature]))
591
+		{
592
+			return $ctags[$signature];
593
+		}
528 594
 
529 595
 		$types = array();
530 596
 		foreach((array)$users as $uid)
@@ -557,7 +623,10 @@  discard block
 block discarded – undo
557 623
 			// owner can only by users, no groups or resources
558 624
 			foreach($users as $key => $user)
559 625
 			{
560
-				if (!($user > 0)) unset($users[$key]);
626
+				if (!($user > 0))
627
+				{
628
+					unset($users[$key]);
629
+				}
561 630
 			}
562 631
 			$where = $this->db->expression($this->user_table, '(', $where, ' OR ').
563 632
 				$this->db->expression($this->cal_table, array(
@@ -579,7 +648,10 @@  discard block
 block discarded – undo
579 648
 	 */
580 649
 	function get_cal_data(array $query, $cols='cal_id,cal_reference,cal_etag,cal_modified,cal_user_modified')
581 650
 	{
582
-		if (!is_array($cols)) $cols = explode(',', $cols);
651
+		if (!is_array($cols))
652
+		{
653
+			$cols = explode(',', $cols);
654
+		}
583 655
 
584 656
 		// special handling of cal_user_modified "pseudo" column
585 657
 		if (($key = array_search('cal_user_modified', $cols)) !== false)
@@ -604,7 +676,10 @@  discard block
 block discarded – undo
604 676
 		{
605 677
 			$cats = $GLOBALS['egw']->categories->return_all_children($cat_id);
606 678
 			array_walk($cats,create_function('&$val,$key','$val = (int) $val;'));
607
-			if (is_array($cat_id) && count($cat_id)==1) $cat_id = $cat_id[0];
679
+			if (is_array($cat_id) && count($cat_id)==1)
680
+			{
681
+				$cat_id = $cat_id[0];
682
+			}
608 683
 			$sql = '(cal_category'.(count($cats) > 1 ? " IN ('".implode("','",$cats)."')" : '='.$this->db->quote((int)$cat_id));
609 684
 			foreach($cats as $cat)
610 685
 			{
@@ -663,10 +738,13 @@  discard block
 block discarded – undo
663 738
 				$where[] = "$this->user_table.cal_status NOT IN ('X','E')";
664 739
 				break;
665 740
 			default:
666
-				if ($enum_recuring)	// regular UI
741
+				if ($enum_recuring)
742
+				{
743
+					// regular UI
667 744
 				{
668 745
 					$where[] = "$this->user_table.cal_status NOT IN ('R','X','E')";
669 746
 				}
747
+				}
670 748
 				else	// CalDAV / eSync / iCal need to include 'E' = exceptions
671 749
 				{
672 750
 					$where[] = "$this->user_table.cal_status NOT IN ('R','X')";
@@ -805,7 +883,10 @@  discard block
 block discarded – undo
805 883
 						$user_ids = array();
806 884
 						foreach($ids as $user_id)
807 885
 						{
808
-							if ($GLOBALS['egw']->accounts->get_type($user_id) === 'u') $user_ids[] = $user_id;
886
+							if ($GLOBALS['egw']->accounts->get_type($user_id) === 'u')
887
+							{
888
+								$user_ids[] = $user_id;
889
+							}
809 890
 						}
810 891
 						$owner_or = $this->db->expression($cal_table_def,array('cal_owner' => $user_ids));
811 892
 					}
@@ -825,7 +906,10 @@  discard block
 block discarded – undo
825 906
 				}
826 907
 			}
827 908
 			// this is only used, when we cannot use UNIONS
828
-			if (!$useUnionQuery) $where[] = '('.implode(' OR ',$to_or).')';
909
+			if (!$useUnionQuery)
910
+			{
911
+				$where[] = '('.implode(' OR ',$to_or).')';
912
+			}
829 913
 
830 914
 			$where = $this->status_filter($filter, $params['enum_recuring'], $where);
831 915
 		}
@@ -844,7 +928,11 @@  discard block
 block discarded – undo
844 928
 				$where[] = '('.((int)$start).' < range_end OR range_end IS NULL)';
845 929
 			}
846 930
 		}
847
-		if (!preg_match('/^[a-z_ ,c]+$/i',$params['order'])) $params['order'] = 'cal_start';		// gard against SQL injection
931
+		if (!preg_match('/^[a-z_ ,c]+$/i',$params['order']))
932
+		{
933
+			$params['order'] = 'cal_start';
934
+		}
935
+		// gard against SQL injection
848 936
 
849 937
 		// if not enum recuring events, we have to use minimum start- AND end-dates, otherwise we get more then one event per cal_id!
850 938
 		if (!$params['enum_recuring'])
@@ -854,9 +942,15 @@  discard block
 block discarded – undo
854 942
 			// in case cal_start is used in a query, eg. calendar_ical::find_event
855 943
 			$where = str_replace(array('cal_start','cal_end'), array('range_start','(SELECT MIN(cal_end) FROM egw_cal_dates WHERE egw_cal.cal_id=egw_cal_dates.cal_id)'), $where);
856 944
 			$params['order'] = str_replace('cal_start', 'range_start', $params['order']);
857
-			if ($end) $where[] = (int)$end.' > range_start';
945
+			if ($end)
946
+			{
947
+				$where[] = (int)$end.' > range_start';
948
+			}
858 949
   		}
859
-		elseif ($end) $where[] = (int)$end.' > cal_start';
950
+  		elseif ($end)
951
+		{
952
+			$where[] = (int)$end.' > cal_start';
953
+		}
860 954
 
861 955
 		if ($remove_rejected_by_user && $filter != 'everything')
862 956
 		{
@@ -870,7 +964,10 @@  discard block
 block discarded – undo
870 964
 				'rejected_by_user.cal_status IS NULL',
871 965
 				"rejected_by_user.cal_status NOT IN ('R','X')",
872 966
 			);
873
-			if ($filter == 'owner') $or_required[] = 'cal_owner='.(int)$remove_rejected_by_user;
967
+			if ($filter == 'owner')
968
+			{
969
+				$or_required[] = 'cal_owner='.(int)$remove_rejected_by_user;
970
+			}
874 971
 			$where[] = '('.implode(' OR ',$or_required).')';
875 972
 		}
876 973
 		// using a time-range and deleted attribute limited view instead of full table
@@ -892,7 +989,10 @@  discard block
 block discarded – undo
892 989
 		if ($useUnionQuery)
893 990
 		{
894 991
 			// allow apps to supply participants and/or icons
895
-			if (!isset($params['cols'])) $cols .= ',NULL AS participants,NULL AS icons';
992
+			if (!isset($params['cols']))
993
+			{
994
+				$cols .= ',NULL AS participants,NULL AS icons';
995
+			}
896 996
 
897 997
 			// changed the original OR in the query into a union, to speed up the query execution under MySQL 5
898 998
 			// with time-range views benefit is now at best slim for huge tables or none at all!
@@ -947,9 +1047,12 @@  discard block
 block discarded – undo
947 1047
 					$selects[count($selects)-1]['where'][] = "$this->user_table.cal_recur_date=cal_start";
948 1048
 				}
949 1049
 			}
950
-			if (is_numeric($offset) && !$params['no_total'])	// get the total too
1050
+			if (is_numeric($offset) && !$params['no_total'])
1051
+			{
1052
+				// get the total too
951 1053
 			{
952 1054
 				$save_selects = $selects;
1055
+			}
953 1056
 				// we only select cal_table.cal_id (and not cal_table.*) to be able to use DISTINCT (eg. MsSQL does not allow it for text-columns)
954 1057
 				foreach(array_keys($selects) as $key)
955 1058
 				{
@@ -960,14 +1063,20 @@  discard block
 block discarded – undo
960 1063
 							array('range_start AS cal_start','range_end AS cal_end'), $selects[$key]['cols']);
961 1064
 					}
962 1065
 				}
963
-				if (!isset($params['cols']) && !$params['no_integration']) self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']);
1066
+				if (!isset($params['cols']) && !$params['no_integration'])
1067
+				{
1068
+					self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']);
1069
+				}
964 1070
 
965 1071
 				$this->total = $this->db->union($selects,__LINE__,__FILE__)->NumRows();
966 1072
 
967 1073
 				// restore original cols / selects
968 1074
 				$selects = $save_selects; unset($save_selects);
969 1075
 			}
970
-			if (!isset($params['cols']) && !$params['no_integration']) self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']);
1076
+			if (!isset($params['cols']) && !$params['no_integration'])
1077
+			{
1078
+				self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']);
1079
+			}
971 1080
 
972 1081
 			$rs = $this->db->union($selects,__LINE__,__FILE__,$params['order'],$offset,$num_rows);
973 1082
 		}
@@ -985,9 +1094,12 @@  discard block
 block discarded – undo
985 1094
 				'table_def' => $cal_table_def,
986 1095
 			));
987 1096
 
988
-			if (is_numeric($offset) && !$params['no_total'])	// get the total too
1097
+			if (is_numeric($offset) && !$params['no_total'])
1098
+			{
1099
+				// get the total too
989 1100
 			{
990 1101
 				$save_selects = $selects;
1102
+			}
991 1103
 				// we only select cal_table.cal_id (and not cal_table.*) to be able to use DISTINCT (eg. MsSQL does not allow it for text-columns)
992 1104
 				$selects[0]['cols'] = "$this->cal_table.cal_id,cal_start";
993 1105
 				if (!isset($params['cols']) && !$params['no_integration'] && $this->db->capabilities['union'])
@@ -1015,7 +1127,10 @@  discard block
 block discarded – undo
1015 1127
 		foreach($rs as $row)
1016 1128
 		{
1017 1129
 			$id = $row['cal_id'];
1018
-			if (is_numeric($id)) $ids[] = $id;
1130
+			if (is_numeric($id))
1131
+			{
1132
+				$ids[] = $id;
1133
+			}
1019 1134
 
1020 1135
 			if ($row['cal_recur_date'])
1021 1136
 			{
@@ -1035,7 +1150,10 @@  discard block
 block discarded – undo
1035 1150
 			$row['recur_exception'] = $row['alarm'] = array();
1036 1151
 
1037 1152
 			// compile a list of recurrences per cal_id
1038
-			if (!in_array($id,(array)$recur_ids[$row['cal_id']])) $recur_ids[$row['cal_id']][] = $id;
1153
+			if (!in_array($id,(array)$recur_ids[$row['cal_id']]))
1154
+			{
1155
+				$recur_ids[$row['cal_id']][] = $id;
1156
+			}
1039 1157
 
1040 1158
 			$events[$id] = Api\Db::strip_array_keys($row,'cal_');
1041 1159
 		}
@@ -1054,10 +1172,16 @@  discard block
 block discarded – undo
1054 1172
 					//'cal_id' => array_unique($ids),
1055 1173
 					'cal_recur_date' => $recur_dates,
1056 1174
 				),__LINE__,__FILE__,false,'ORDER BY cal_id,cal_user_type DESC,'.self::STATUS_SORT,'calendar',-1,$join='',
1057
-				$this->db->get_table_definitions('calendar',$this->user_table)) as $row)	// DESC puts users before resources and contacts
1175
+				$this->db->get_table_definitions('calendar',$this->user_table)) as $row)
1176
+			{
1177
+				// DESC puts users before resources and contacts
1058 1178
 			{
1059 1179
 				$id = $row['cal_id'];
1060
-				if ($row['cal_recur_date']) $id .= '-'.$row['cal_recur_date'];
1180
+			}
1181
+				if ($row['cal_recur_date'])
1182
+				{
1183
+					$id .= '-'.$row['cal_recur_date'];
1184
+				}
1061 1185
 
1062 1186
 				// combine all participant data in uid and status values
1063 1187
 				$uid = self::combine_user($row['cal_user_type'], $row['cal_user_id'], $row['cal_user_attendee']);
@@ -1076,7 +1200,10 @@  discard block
 block discarded – undo
1076 1200
 				}
1077 1201
 
1078 1202
 				// set data, if recurrence is requested
1079
-				if (isset($events[$id])) $events[$id]['participants'][$uid] = $status;
1203
+				if (isset($events[$id]))
1204
+				{
1205
+					$events[$id]['participants'][$uid] = $status;
1206
+				}
1080 1207
 			}
1081 1208
 			// query recurrance exceptions, if needed: enum_recuring && !daywise is used in calendar_groupdav::get_series($uid,...)
1082 1209
 			if (!$params['enum_recuring'] || !$params['daywise'])
@@ -1092,7 +1219,10 @@  discard block
 block discarded – undo
1092 1219
 					{
1093 1220
 						foreach($events as $id => $event)
1094 1221
 						{
1095
-							if ($event['id'] == $row['cal_id']) break;
1222
+							if ($event['id'] == $row['cal_id'])
1223
+							{
1224
+								break;
1225
+							}
1096 1226
 						}
1097 1227
 					}
1098 1228
 					$events[$id]['recur_exception'][] = $row['cal_start'];
@@ -1102,7 +1232,10 @@  discard block
 block discarded – undo
1102 1232
 			if (!is_null($params['cfs']))
1103 1233
 			{
1104 1234
 				$where = array('cal_id' => $ids);
1105
-				if ($params['cfs']) $where['cal_extra_name'] = $params['cfs'];
1235
+				if ($params['cfs'])
1236
+				{
1237
+					$where['cal_extra_name'] = $params['cfs'];
1238
+				}
1106 1239
 				foreach($this->db->select($this->extra_table,'*',$where,
1107 1240
 					__LINE__,__FILE__,false,'','calendar') as $row)
1108 1241
 				{
@@ -1122,14 +1255,20 @@  discard block
 block discarded – undo
1122 1255
 				{
1123 1256
 					$event_start = $alarm['time'] + $alarm['offset'];
1124 1257
 
1125
-					if (isset($events[$cal_id]))	// none recuring event
1258
+					if (isset($events[$cal_id]))
1259
+					{
1260
+						// none recuring event
1126 1261
 					{
1127 1262
 						$events[$cal_id]['alarm'][$id] = $alarm;
1128 1263
 					}
1129
-					elseif (isset($events[$cal_id.'-'.$event_start]))	// recuring event
1264
+					}
1265
+					elseif (isset($events[$cal_id.'-'.$event_start]))
1266
+					{
1267
+						// recuring event
1130 1268
 					{
1131 1269
 						$events[$cal_id.'-'.$event_start]['alarm'][$id] = $alarm;
1132 1270
 					}
1271
+					}
1133 1272
 				}
1134 1273
 			}
1135 1274
 		}
@@ -1229,10 +1368,13 @@  discard block
 block discarded – undo
1229 1368
 			}
1230 1369
 			foreach((array)$cols as $col)
1231 1370
 			{
1232
-				if (substr($col,0,7) == 'egw_cal')	// remove table name
1371
+				if (substr($col,0,7) == 'egw_cal')
1372
+				{
1373
+					// remove table name
1233 1374
 				{
1234 1375
 					$col = preg_replace('/^egw_cal[a-z_]*\./','',$col);
1235 1376
 				}
1377
+				}
1236 1378
 				if (isset($app_cols[$col]))
1237 1379
 				{
1238 1380
 					$return_cols[] = $app_cols[$col];
@@ -1326,7 +1468,11 @@  discard block
 block discarded – undo
1326 1468
 		if (isset($GLOBALS['egw_info']['user']['preferences']['syncml']['minimum_uid_length']))
1327 1469
 		{
1328 1470
 			$minimum_uid_length = $GLOBALS['egw_info']['user']['preferences']['syncml']['minimum_uid_length'];
1329
-			if (empty($minimum_uid_length) || $minimum_uid_length<=1) $minimum_uid_length = 8; // we just do not accept no uid, or uid way to short!
1471
+			if (empty($minimum_uid_length) || $minimum_uid_length<=1)
1472
+			{
1473
+				$minimum_uid_length = 8;
1474
+			}
1475
+			// we just do not accept no uid, or uid way to short!
1330 1476
 		}
1331 1477
 		else
1332 1478
 		{
@@ -1374,7 +1520,10 @@  discard block
 block discarded – undo
1374 1520
 			}
1375 1521
 		}
1376 1522
 		// set range_start/_end, but only if we have cal_start/_end, as otherwise we destroy present values!
1377
-		if (isset($event['cal_start'])) $event['range_start'] = $event['cal_start'];
1523
+		if (isset($event['cal_start']))
1524
+		{
1525
+			$event['range_start'] = $event['cal_start'];
1526
+		}
1378 1527
 		if (isset($event['cal_end']))
1379 1528
 		{
1380 1529
 			$event['range_end'] = $event['recur_type'] == MCAL_RECUR_NONE ? $event['cal_end'] :
@@ -1395,7 +1544,10 @@  discard block
 block discarded – undo
1395 1544
 		$event['cal_category'] = implode(',',$categories);
1396 1545
 
1397 1546
 		// make sure recurring events never reference to an other recurrent event
1398
-		if ($event['recur_type'] != MCAL_RECUR_NONE) $event['cal_reference'] = 0;
1547
+		if ($event['recur_type'] != MCAL_RECUR_NONE)
1548
+		{
1549
+			$event['cal_reference'] = 0;
1550
+		}
1399 1551
 
1400 1552
 		if ($cal_id)
1401 1553
 		{
@@ -1412,7 +1564,10 @@  discard block
 block discarded – undo
1412 1564
 			{
1413 1565
 				$old_tz_id = $this->db->select($this->cal_table,'tz_id',$where,__LINE__,__FILE__,'calendar')->fetchColumn();
1414 1566
 			}
1415
-			if (!is_null($etag)) $where['cal_etag'] = $etag;
1567
+			if (!is_null($etag))
1568
+			{
1569
+				$where['cal_etag'] = $etag;
1570
+			}
1416 1571
 
1417 1572
 			unset($event['cal_etag']);
1418 1573
 			$event[] = 'cal_etag=cal_etag+1';	// always update the etag, even if none given to check
@@ -1423,14 +1578,24 @@  discard block
 block discarded – undo
1423 1578
 			{
1424 1579
 				return 0;	// wrong etag, someone else updated the entry
1425 1580
 			}
1426
-			if (!is_null($etag)) ++$etag;
1581
+			if (!is_null($etag))
1582
+			{
1583
+				++$etag;
1584
+			}
1427 1585
 		}
1428 1586
 		else
1429 1587
 		{
1430 1588
 			// new event
1431
-			if (!$event['cal_owner']) $event['cal_owner'] = $GLOBALS['egw_info']['user']['account_id'];
1589
+			if (!$event['cal_owner'])
1590
+			{
1591
+				$event['cal_owner'] = $GLOBALS['egw_info']['user']['account_id'];
1592
+			}
1432 1593
 
1433
-			if (!$event['cal_id'] && !isset($event['cal_uid'])) $event['cal_uid'] = '';	// uid is NOT NULL!
1594
+			if (!$event['cal_id'] && !isset($event['cal_uid']))
1595
+			{
1596
+				$event['cal_uid'] = '';
1597
+			}
1598
+			// uid is NOT NULL!
1434 1599
 
1435 1600
 			$this->db->insert($this->cal_table,$event,false,__LINE__,__FILE__,'calendar');
1436 1601
 			if (!($cal_id = $this->db->get_last_insert_id($this->cal_table,'cal_id')))
@@ -1582,8 +1747,7 @@  discard block
 block discarded – undo
1582 1747
 					// recurrences need to be truncated
1583 1748
 					if((int)$event['recur_enddate'] > 0 &&
1584 1749
 						((int)$old_repeats['recur_enddate'] == 0 || (int)$old_repeats['recur_enddate'] > (int)$event['recur_enddate'])
1585
-					)
1586
-					{
1750
+					) {
1587 1751
 						$this->db->delete($this->user_table,array('cal_id' => $cal_id,'cal_recur_date >= '.($event['recur_enddate'] + 1*DAY_s)),__LINE__,__FILE__,'calendar');
1588 1752
 						$this->db->delete($this->dates_table,array('cal_id' => $cal_id,'cal_start >= '.($event['recur_enddate'] + 1*DAY_s)),__LINE__,__FILE__,'calendar');
1589 1753
 					}
@@ -1591,8 +1755,7 @@  discard block
 block discarded – undo
1591 1755
 					// recurrences need to be expanded
1592 1756
 					if(((int)$event['recur_enddate'] == 0 && (int)$old_repeats['recur_enddate'] > 0)
1593 1757
 						|| ((int)$event['recur_enddate'] > 0 && (int)$old_repeats['recur_enddate'] > 0 && (int)$old_repeats['recur_enddate'] < (int)$event['recur_enddate'])
1594
-					)
1595
-					{
1758
+					) {
1596 1759
 						$set_recurrences = true;
1597 1760
 						$set_recurrences_start = ($old_repeats['recur_enddate'] + 1*DAY_s);
1598 1761
 					}
@@ -1739,12 +1902,18 @@  discard block
 block discarded – undo
1739 1902
 	{
1740 1903
 		//echo "<p>socal::move($cal_id,$start,$end,$change_since,$old_start,$old_end)</p>\n";
1741 1904
 
1742
-		if (!(int) $cal_id) return false;
1905
+		if (!(int) $cal_id)
1906
+		{
1907
+			return false;
1908
+		}
1743 1909
 
1744 1910
 		if (!$old_start)
1745 1911
 		{
1746
-			if ($change_since !== false) $row = $this->db->select($this->dates_table,'MIN(cal_start) AS cal_start,MIN(cal_end) AS cal_end',
1912
+			if ($change_since !== false)
1913
+			{
1914
+				$row = $this->db->select($this->dates_table,'MIN(cal_start) AS cal_start,MIN(cal_end) AS cal_end',
1747 1915
 				array('cal_id'=>$cal_id),__LINE__,__FILE__,false,'','calendar')->fetch();
1916
+			}
1748 1917
 			// if no recurrence found, create one with the new dates
1749 1918
 			if ($change_since === false || !$row || !$row['cal_start'] || !$row['cal_end'])
1750 1919
 			{
@@ -1846,7 +2015,10 @@  discard block
 block discarded – undo
1846 2015
 			$user_type = $uid[0];
1847 2016
 			$email = substr($uid, 1);
1848 2017
 			$matches = null;
1849
-			if (preg_match('/<([^<>]+)>$/', $email, $matches)) $email = $matches[1];
2018
+			if (preg_match('/<([^<>]+)>$/', $email, $matches))
2019
+			{
2020
+				$email = $matches[1];
2021
+			}
1850 2022
 			$user_id = md5(trim(strtolower($email)));
1851 2023
 		}
1852 2024
 		else
@@ -1866,8 +2038,14 @@  discard block
 block discarded – undo
1866 2038
 	 */
1867 2039
 	static function combine_status($status,$quantity=1,$role='REQ-PARTICIPANT')
1868 2040
 	{
1869
-		if ((int)$quantity > 1) $status .= (int)$quantity;
1870
-		if ($role != 'REQ-PARTICIPANT') $status .= $role;
2041
+		if ((int)$quantity > 1)
2042
+		{
2043
+			$status .= (int)$quantity;
2044
+		}
2045
+		if ($role != 'REQ-PARTICIPANT')
2046
+		{
2047
+			$status .= $role;
2048
+		}
1871 2049
 
1872 2050
 		return $status;
1873 2051
 	}
@@ -1888,8 +2066,14 @@  discard block
 block discarded – undo
1888 2066
 		$matches = null;
1889 2067
 		if (is_string($status) && strlen($status) > 1 && preg_match('/^.([0-9]*)(.*)$/',$status,$matches))
1890 2068
 		{
1891
-			if ((int)$matches[1] > 0) $quantity = (int)$matches[1];
1892
-			if ($matches[2]) $role = $matches[2];
2069
+			if ((int)$matches[1] > 0)
2070
+			{
2071
+				$quantity = (int)$matches[1];
2072
+			}
2073
+			if ($matches[2])
2074
+			{
2075
+				$role = $matches[2];
2076
+			}
1893 2077
 			$status = $status[0];
1894 2078
 		}
1895 2079
 		elseif ($status === true)
@@ -2000,9 +2184,13 @@  discard block
 block discarded – undo
2000 2184
 			}
2001 2185
 		}
2002 2186
 
2003
-		if (count($participants))	// participants which need to be added
2187
+		if (count($participants))
2188
+		{
2189
+			// participants which need to be added
2004 2190
 		{
2005
-			if (!count($recurrences)) $recurrences[] = 0;   // insert the default recurrence
2191
+			if (!count($recurrences)) $recurrences[] = 0;
2192
+		}
2193
+		// insert the default recurrence
2006 2194
 
2007 2195
 			$delete_deleted = array();
2008 2196
 
@@ -2074,7 +2262,10 @@  discard block
 block discarded – undo
2074 2262
 			return false;
2075 2263
 		}
2076 2264
 
2077
-		if (is_numeric($status)) $status = $status_code_short[$status];
2265
+		if (is_numeric($status))
2266
+		{
2267
+			$status = $status_code_short[$status];
2268
+		}
2078 2269
 
2079 2270
 		$uid = self::combine_user($user_type, $user_id);
2080 2271
 		$user_id_md5 = null;
@@ -2094,16 +2285,25 @@  discard block
 block discarded – undo
2094 2285
 			$where[] = '(cal_recur_date=0 OR cal_recur_date >= '.time().')';
2095 2286
 		}
2096 2287
 
2097
-		if ($status == 'G')		// remove group invitations, as we dont store them in the db
2288
+		if ($status == 'G')
2289
+		{
2290
+			// remove group invitations, as we dont store them in the db
2098 2291
 		{
2099 2292
 			$this->db->delete($this->user_table,$where,__LINE__,__FILE__,'calendar');
2293
+		}
2100 2294
 			$ret = $this->db->affected_rows();
2101 2295
 		}
2102 2296
 		else
2103 2297
 		{
2104 2298
 			$set = array('cal_status' => $status);
2105
-			if ($user_type == 'e' || $attendee) $set['cal_user_attendee'] = $attendee ? $attendee : $user_id;
2106
-			if (!is_null($role) && $role != 'REQ-PARTICIPANT') $set['cal_role'] = $role;
2299
+			if ($user_type == 'e' || $attendee)
2300
+			{
2301
+				$set['cal_user_attendee'] = $attendee ? $attendee : $user_id;
2302
+			}
2303
+			if (!is_null($role) && $role != 'REQ-PARTICIPANT')
2304
+			{
2305
+				$set['cal_role'] = $role;
2306
+			}
2107 2307
 			$this->db->insert($this->user_table,$set,$where,__LINE__,__FILE__,'calendar');
2108 2308
 			// for new or changed group-invitations, remove previously deleted members, so they show up again
2109 2309
 			if (($ret = $this->db->affected_rows()) && $user_type == 'u' && $user_id < 0)
@@ -2136,7 +2336,10 @@  discard block
 block discarded – undo
2136 2336
 	{
2137 2337
 		//error_log(__METHOD__."($cal_id, $start, $end, ".array2string($participants).", ".array2string($exception));
2138 2338
 		$update = array('cal_end' => $end);
2139
-		if (isset($exception)) $update['recur_exception'] = $exception;
2339
+		if (isset($exception))
2340
+		{
2341
+			$update['recur_exception'] = $exception;
2342
+		}
2140 2343
 
2141 2344
 		$this->db->insert($this->dates_table, $update, array(
2142 2345
 			'cal_id' => $cal_id,
@@ -2151,7 +2354,11 @@  discard block
 block discarded – undo
2151 2354
 		{
2152 2355
 			foreach($participants as $uid => $status)
2153 2356
 			{
2154
-				if ($status == 'G') continue;	// dont save group-invitations
2357
+				if ($status == 'G')
2358
+				{
2359
+					continue;
2360
+				}
2361
+				// dont save group-invitations
2155 2362
 
2156 2363
 				$type = '';
2157 2364
 				$id = null;
@@ -2380,7 +2587,10 @@  discard block
 block discarded – undo
2380 2587
 		}
2381 2588
 		$alarm['cal_id'] = $cal_id;		// we need the back-reference
2382 2589
 		// add an alarm uid, if none is given
2383
-		if (empty($alarm['uid']) && class_exists('Horde_Support_Uuid')) $alarm['uid'] = (string)new Horde_Support_Uuid;
2590
+		if (empty($alarm['uid']) && class_exists('Horde_Support_Uuid'))
2591
+		{
2592
+			$alarm['uid'] = (string)new Horde_Support_Uuid;
2593
+		}
2384 2594
 		//error_log(__METHOD__.__LINE__.' Save Alarm for CalID:'.$cal_id.'->'.array2string($alarm).'-->'.$id.'#'.function_backtrace());
2385 2595
 		// allways store job with the alarm owner as job-owner to get eg. the correct from address
2386 2596
 		if (!$this->async->set_timer($alarm['time'],$id,'calendar.calendar_boupdate.send_alarm',$alarm,$alarm['owner']))
@@ -2389,10 +2599,16 @@  discard block
 block discarded – undo
2389 2599
 		}
2390 2600
 
2391 2601
 		// update the modification information of the related event
2392
-		if ($update_modified) $this->updateModified($cal_id, true);
2602
+		if ($update_modified)
2603
+		{
2604
+			$this->updateModified($cal_id, true);
2605
+		}
2393 2606
 
2394 2607
 		// update cache, if used
2395
-		if (isset(self::$alarm_cache)) $this->read_alarms($cal_id, true);
2608
+		if (isset(self::$alarm_cache))
2609
+		{
2610
+			$this->read_alarms($cal_id, true);
2611
+		}
2396 2612
 
2397 2613
 		return $id;
2398 2614
 	}
@@ -2415,7 +2631,10 @@  discard block
 block discarded – undo
2415 2631
 				$this->async->cancel_timer($id);
2416 2632
 			}
2417 2633
 			// update cache, if used
2418
-			if (isset(self::$alarm_cache)) $this->read_alarms($cal_id, false);
2634
+			if (isset(self::$alarm_cache))
2635
+			{
2636
+				$this->read_alarms($cal_id, false);
2637
+			}
2419 2638
 		}
2420 2639
 		return count($alarms);
2421 2640
 	}
@@ -2438,7 +2657,10 @@  discard block
 block discarded – undo
2438 2657
 		$ret = $this->async->cancel_timer($id);
2439 2658
 
2440 2659
 		// update cache, if used
2441
-		if (isset(self::$alarm_cache)) $this->read_alarms($cal_id, true);
2660
+		if (isset(self::$alarm_cache))
2661
+		{
2662
+			$this->read_alarms($cal_id, true);
2663
+		}
2442 2664
 
2443 2665
 		return $ret;
2444 2666
 	}
@@ -2462,11 +2684,14 @@  discard block
 block discarded – undo
2462 2684
 			$user_id = null;
2463 2685
 			self::split_user($old_user,$user_type,$user_id);
2464 2686
 
2465
-			if ($user_type == 'u')	// only accounts can be owners of events
2687
+			if ($user_type == 'u')
2688
+			{
2689
+				// only accounts can be owners of events
2466 2690
 			{
2467 2691
 				foreach($this->db->select($this->cal_table,'cal_id',array('cal_owner' => $old_user),__LINE__,__FILE__,false,'','calendar') as $row)
2468 2692
 				{
2469 2693
 					$this->delete($row['cal_id']);
2694
+			}
2470 2695
 				}
2471 2696
 			}
2472 2697
 			$this->db->delete($this->user_table,array(
@@ -2494,11 +2719,14 @@  discard block
 block discarded – undo
2494 2719
 			{
2495 2720
 				$ids[] = $row['cal_id'];
2496 2721
 			}
2497
-			if ($ids) $this->db->delete($this->user_table,array(
2722
+			if ($ids)
2723
+			{
2724
+				$this->db->delete($this->user_table,array(
2498 2725
 				'cal_user_type' => 'u',
2499 2726
 				'cal_user_id' => $old_user,
2500 2727
 				'cal_id' => $ids,
2501 2728
 			),__LINE__,__FILE__,'calendar');
2729
+			}
2502 2730
 			// now change participant in the rest to contain new user instead of old user
2503 2731
 			$this->db->update($this->user_table,array(
2504 2732
 				'cal_user_id' => $new_user,
@@ -2523,8 +2751,14 @@  discard block
 block discarded – undo
2523 2751
 	{
2524 2752
 		$participant_status = array();
2525 2753
 		$where = array('cal_id' => $cal_id);
2526
-		if ($start != 0 && $end == 0) $where[] = '(cal_recur_date = 0 OR cal_recur_date >= ' . (int)$start . ')';
2527
-		if ($start == 0 && $end != 0) $where[] = '(cal_recur_date = 0 OR cal_recur_date <= ' . (int)$end . ')';
2754
+		if ($start != 0 && $end == 0)
2755
+		{
2756
+			$where[] = '(cal_recur_date = 0 OR cal_recur_date >= ' . (int)$start . ')';
2757
+		}
2758
+		if ($start == 0 && $end != 0)
2759
+		{
2760
+			$where[] = '(cal_recur_date = 0 OR cal_recur_date <= ' . (int)$end . ')';
2761
+		}
2528 2762
 		if ($start != 0 && $end != 0)
2529 2763
 		{
2530 2764
 			$where[] = '(cal_recur_date = 0 OR (cal_recur_date >= ' . (int)$start .
@@ -2535,7 +2769,10 @@  discard block
 block discarded – undo
2535 2769
 			// inititalize the array
2536 2770
 			$participant_status[$row['cal_recur_date']] = null;
2537 2771
 		}
2538
-		if (is_null($uid)) return $participant_status;
2772
+		if (is_null($uid))
2773
+		{
2774
+			return $participant_status;
2775
+		}
2539 2776
 		$user_type = $user_id = null;
2540 2777
 		self::split_user($uid, $user_type, $user_id, true);
2541 2778
 
@@ -2544,8 +2781,14 @@  discard block
 block discarded – undo
2544 2781
 			'cal_user_type'	=> $user_type ? $user_type : 'u',
2545 2782
 			'cal_user_id'   => $user_id,
2546 2783
 		);
2547
-		if ($start != 0 && $end == 0) $where2[] = '(cal_recur_date = 0 OR cal_recur_date >= ' . (int)$start . ')';
2548
-		if ($start == 0 && $end != 0) $where2[] = '(cal_recur_date = 0 OR cal_recur_date <= ' . (int)$end . ')';
2784
+		if ($start != 0 && $end == 0)
2785
+		{
2786
+			$where2[] = '(cal_recur_date = 0 OR cal_recur_date >= ' . (int)$start . ')';
2787
+		}
2788
+		if ($start == 0 && $end != 0)
2789
+		{
2790
+			$where2[] = '(cal_recur_date = 0 OR cal_recur_date <= ' . (int)$end . ')';
2791
+		}
2549 2792
 		if ($start != 0 && $end != 0)
2550 2793
 		{
2551 2794
 			$where2[] = '(cal_recur_date = 0 OR (cal_recur_date >= ' . (int)$start .
@@ -2635,17 +2878,26 @@  discard block
 block discarded – undo
2635 2878
 	 */
2636 2879
 	function get_recurrence_exceptions($event, $tz_id=null, $start=0, $end=0, $filter='all')
2637 2880
 	{
2638
-		if (!is_array($event)) return false;
2881
+		if (!is_array($event))
2882
+		{
2883
+			return false;
2884
+		}
2639 2885
 		$cal_id = (int) $event['id'];
2640 2886
 		//error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2641 2887
 		//		"($cal_id, $tz_id, $filter): " . $event['tzid']);
2642
-		if (!$cal_id || $event['recur_type'] == MCAL_RECUR_NONE) return false;
2888
+		if (!$cal_id || $event['recur_type'] == MCAL_RECUR_NONE)
2889
+		{
2890
+			return false;
2891
+		}
2643 2892
 
2644 2893
 		$days = array();
2645 2894
 
2646 2895
 		$expand_all = (!$this->isWholeDay($event) && $tz_id && $tz_id != $event['tzid']);
2647 2896
 
2648
-		if ($filter == 'tz_only' && !$expand_all) return $days;
2897
+		if ($filter == 'tz_only' && !$expand_all)
2898
+		{
2899
+			return $days;
2900
+		}
2649 2901
 
2650 2902
 		$remote = in_array($filter, array('tz_rrule', 'rrule'));
2651 2903
 
@@ -2688,7 +2940,10 @@  discard block
 block discarded – undo
2688 2940
 					$remote_rrule->next_no_exception();
2689 2941
 				}
2690 2942
 				$egw_rrule->next_no_exception();
2691
-				if (!$egw_rrule->valid()) return $days;
2943
+				if (!$egw_rrule->valid())
2944
+				{
2945
+					return $days;
2946
+				}
2692 2947
 			}
2693 2948
 			$day = $egw_rrule->current();
2694 2949
 			$locts = (int)Api\DateTime::to($day,'server');
@@ -2842,7 +3097,11 @@  discard block
 block discarded – undo
2842 3097
 			}
2843 3098
 		}
2844 3099
 
2845
-		if (empty($participants)) return false; // occurrence does not exist at all yet
3100
+		if (empty($participants))
3101
+		{
3102
+			return false;
3103
+		}
3104
+		// occurrence does not exist at all yet
2846 3105
 
2847 3106
 		foreach ($recurrence_zero as $uid => $status)
2848 3107
 		{
@@ -2899,7 +3158,9 @@  discard block
 block discarded – undo
2899 3158
 			}
2900 3159
 			if (!isset($participants[$uid])
2901 3160
 				|| $participants[$uid] != $status)
2902
-				return true;
3161
+			{
3162
+							return true;
3163
+			}
2903 3164
 			unset($participants[$uid]);
2904 3165
 		}
2905 3166
 		return (!empty($participants));
@@ -2913,7 +3174,10 @@  discard block
 block discarded – undo
2913 3174
 	 */
2914 3175
 	function isWholeDay($event)
2915 3176
 	{
2916
-		if (!isset($event['start']) || !isset($event['end'])) return false;
3177
+		if (!isset($event['start']) || !isset($event['end']))
3178
+		{
3179
+			return false;
3180
+		}
2917 3181
 
2918 3182
 		if (empty($event['tzid']))
2919 3183
 		{
@@ -2975,8 +3239,14 @@  discard block
 block discarded – undo
2975 3239
 	 */
2976 3240
 	function updateModified($id, $update_master=false, $time=null, $modifier=null)
2977 3241
 	{
2978
-		if (is_null($time) || !$time) $time = time();
2979
-		if (is_null($modifier)) $modifier = $GLOBALS['egw_info']['user']['account_id'];
3242
+		if (is_null($time) || !$time)
3243
+		{
3244
+			$time = time();
3245
+		}
3246
+		if (is_null($modifier))
3247
+		{
3248
+			$modifier = $GLOBALS['egw_info']['user']['account_id'];
3249
+		}
2980 3250
 
2981 3251
 		$this->db->update($this->cal_table,
2982 3252
 			array('cal_modified' => $time, 'cal_modifier' => $modifier),
Please login to merge, or discard this patch.
Spacing   +391 added lines, -394 removed lines patch added patch discarded remove patch
@@ -19,40 +19,40 @@  discard block
 block discarded – undo
19 19
 /**
20 20
  * some necessary defines used by the calendar
21 21
  */
22
-if(!extension_loaded('mcal'))
22
+if (!extension_loaded('mcal'))
23 23
 {
24
-	define('MCAL_RECUR_NONE',0);
25
-	define('MCAL_RECUR_DAILY',1);
26
-	define('MCAL_RECUR_WEEKLY',2);
27
-	define('MCAL_RECUR_MONTHLY_MDAY',3);
28
-	define('MCAL_RECUR_MONTHLY_WDAY',4);
29
-	define('MCAL_RECUR_YEARLY',5);
30
-	define('MCAL_RECUR_SECONDLY',6);
31
-	define('MCAL_RECUR_MINUTELY',7);
32
-	define('MCAL_RECUR_HOURLY',8);
33
-
34
-	define('MCAL_M_SUNDAY',1);
35
-	define('MCAL_M_MONDAY',2);
36
-	define('MCAL_M_TUESDAY',4);
37
-	define('MCAL_M_WEDNESDAY',8);
38
-	define('MCAL_M_THURSDAY',16);
39
-	define('MCAL_M_FRIDAY',32);
40
-	define('MCAL_M_SATURDAY',64);
41
-
42
-	define('MCAL_M_WEEKDAYS',62);
43
-	define('MCAL_M_WEEKEND',65);
44
-	define('MCAL_M_ALLDAYS',127);
24
+	define('MCAL_RECUR_NONE', 0);
25
+	define('MCAL_RECUR_DAILY', 1);
26
+	define('MCAL_RECUR_WEEKLY', 2);
27
+	define('MCAL_RECUR_MONTHLY_MDAY', 3);
28
+	define('MCAL_RECUR_MONTHLY_WDAY', 4);
29
+	define('MCAL_RECUR_YEARLY', 5);
30
+	define('MCAL_RECUR_SECONDLY', 6);
31
+	define('MCAL_RECUR_MINUTELY', 7);
32
+	define('MCAL_RECUR_HOURLY', 8);
33
+
34
+	define('MCAL_M_SUNDAY', 1);
35
+	define('MCAL_M_MONDAY', 2);
36
+	define('MCAL_M_TUESDAY', 4);
37
+	define('MCAL_M_WEDNESDAY', 8);
38
+	define('MCAL_M_THURSDAY', 16);
39
+	define('MCAL_M_FRIDAY', 32);
40
+	define('MCAL_M_SATURDAY', 64);
41
+
42
+	define('MCAL_M_WEEKDAYS', 62);
43
+	define('MCAL_M_WEEKEND', 65);
44
+	define('MCAL_M_ALLDAYS', 127);
45 45
 }
46 46
 
47
-define('REJECTED',0);
48
-define('NO_RESPONSE',1);
49
-define('TENTATIVE',2);
50
-define('ACCEPTED',3);
51
-define('DELEGATED',4);
47
+define('REJECTED', 0);
48
+define('NO_RESPONSE', 1);
49
+define('TENTATIVE', 2);
50
+define('ACCEPTED', 3);
51
+define('DELEGATED', 4);
52 52
 
53
-define('HOUR_s',60*60);
54
-define('DAY_s',24*HOUR_s);
55
-define('WEEK_s',7*DAY_s);
53
+define('HOUR_s', 60 * 60);
54
+define('DAY_s', 24 * HOUR_s);
55
+define('WEEK_s', 7 * DAY_s);
56 56
 
57 57
 /**
58 58
  * Class to store all calendar data (storage object)
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 	 * name of the main calendar table and prefix for all other calendar tables
101 101
 	 */
102 102
 	var $cal_table = 'egw_cal';
103
-	var $extra_table,$repeats_table,$user_table,$dates_table,$all_tables;
103
+	var $extra_table, $repeats_table, $user_table, $dates_table, $all_tables;
104 104
 
105 105
 	/**
106 106
 	 * reference to global db-object
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 		$this->db = $GLOBALS['egw']->db;
137 137
 
138 138
 		$this->all_tables = array($this->cal_table);
139
-		foreach(array('extra','repeats','user','dates') as $name)
139
+		foreach (array('extra', 'repeats', 'user', 'dates') as $name)
140 140
 		{
141 141
 			$vname = $name.'_table';
142 142
 			$this->all_tables[] = $this->$vname = $this->cal_table.'_'.$name;
@@ -152,11 +152,11 @@  discard block
 block discarded – undo
152 152
 	 * @param boolean $deleted =false
153 153
 	 * @return string
154 154
 	 */
155
-	protected function cal_range_view($start, $end, array $_where=null, $deleted=false)
155
+	protected function cal_range_view($start, $end, array $_where = null, $deleted = false)
156 156
 	{
157 157
 		if ($GLOBALS['egw_info']['server']['no_timerange_views'] || !$start)	// using view without start-date is slower!
158 158
 		{
159
-			return $this->cal_table;	// no need / use for a view
159
+			return $this->cal_table; // no need / use for a view
160 160
 		}
161 161
 
162 162
 		$where = array();
@@ -182,11 +182,11 @@  discard block
 block discarded – undo
182 182
 	 * @param boolean $deleted =false
183 183
 	 * @return string
184 184
 	 */
185
-	protected function dates_range_view($start, $end, array $_where=null, $deleted=false)
185
+	protected function dates_range_view($start, $end, array $_where = null, $deleted = false)
186 186
 	{
187 187
 		if ($GLOBALS['egw_info']['server']['no_timerange_views'] || !$start || !$end)	// using view without start- AND end-date is slower!
188 188
 		{
189
-			return $this->dates_table;	// no need / use for a view
189
+			return $this->dates_table; // no need / use for a view
190 190
 		}
191 191
 
192 192
 		$where = array();
@@ -231,14 +231,14 @@  discard block
 block discarded – undo
231 231
 	 * @param int $remove_rejected_by_user =null add join to remove entry, if given user has rejected it
232 232
 	 * @return array of events
233 233
 	 */
234
-	function &events($start,$end,$users,$cat_id=0,$filter='all',$offset=False,$num_rows=0,array $params=array(),$remove_rejected_by_user=null)
234
+	function &events($start, $end, $users, $cat_id = 0, $filter = 'all', $offset = False, $num_rows = 0, array $params = array(), $remove_rejected_by_user = null)
235 235
 	{
236
-		error_log(__METHOD__.'('.($start ? date('Y-m-d H:i',$start) : '').','.($end ? date('Y-m-d H:i',$end) : '').','.array2string($users).','.array2string($cat_id).",'$filter',".array2string($offset).",$num_rows,".array2string($params).') '.function_backtrace());
236
+		error_log(__METHOD__.'('.($start ? date('Y-m-d H:i', $start) : '').','.($end ? date('Y-m-d H:i', $end) : '').','.array2string($users).','.array2string($cat_id).",'$filter',".array2string($offset).",$num_rows,".array2string($params).') '.function_backtrace());
237 237
 		$start_time = microtime(true);
238 238
 		// not everything is supported by now
239 239
 		if (!$start || !$end || is_string($params['query']) ||
240 240
 			//in_array($filter,array('owner','deleted')) ||
241
-			$params['enum_recuring']===false)
241
+			$params['enum_recuring'] === false)
242 242
 		{
243 243
 			throw new Api\Exception\AssertionFailed("Unsupported value for parameters!");
244 244
 		}
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
 		{
266 266
 			// fix $users to also prefix system users and groups (with 'u')
267 267
 			if (!is_array($users)) $users = $users ? (array)$users : array();
268
-			foreach($users as &$uid)
268
+			foreach ($users as &$uid)
269 269
 			{
270 270
 				$user_type = $user_id = null;
271 271
 				self::split_user($uid, $user_type, $user_id, true);
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 
287 287
 		if ($params['order'])	// only order if requested
288 288
 		{
289
-			if (!preg_match('/^[a-z_ ,c]+$/i',$params['order'])) $params['order'] = 'cal_start';		// gard against SQL injection
289
+			if (!preg_match('/^[a-z_ ,c]+$/i', $params['order'])) $params['order'] = 'cal_start'; // gard against SQL injection
290 290
 			$sql .= "\nORDER BY ".$params['order'];
291 291
 		}
292 292
 
@@ -295,8 +295,8 @@  discard block
 block discarded – undo
295 295
 			$offset = 0;
296 296
 			$num_rows = -1;
297 297
 		}
298
-		$events =& $this->get_events($this->db->query($sql, __LINE__, __FILE__, $offset, $num_rows));
299
-		error_log(__METHOD__."(...) $sql --> ".number_format(microtime(true)-$start_time, 3));
298
+		$events = & $this->get_events($this->db->query($sql, __LINE__, __FILE__, $offset, $num_rows));
299
+		error_log(__METHOD__."(...) $sql --> ".number_format(microtime(true) - $start_time, 3));
300 300
 		return $events;
301 301
 	}
302 302
 
@@ -309,12 +309,12 @@  discard block
 block discarded – undo
309 309
 	 * @param int $recur_date =0 if set read the next recurrence at or after the timestamp, default 0 = read the initital one
310 310
 	 * @return array|boolean array with cal_id => event array pairs or false if entry not found
311 311
 	 */
312
-	function read($ids,$recur_date=0)
312
+	function read($ids, $recur_date = 0)
313 313
 	{
314 314
 		//error_log(__METHOD__.'('.array2string($ids).",$recur_date) ".function_backtrace());
315 315
 		$cols = self::get_columns('calendar', $this->cal_table);
316 316
 		$cols[0] = $this->db->to_varchar($this->cal_table.'.cal_id');
317
-		$cols = "$this->repeats_table.recur_type,$this->repeats_table.recur_interval,$this->repeats_table.recur_data,".implode(',',$cols);
317
+		$cols = "$this->repeats_table.recur_type,$this->repeats_table.recur_interval,$this->repeats_table.recur_data,".implode(',', $cols);
318 318
 		$join = "LEFT JOIN $this->repeats_table ON $this->cal_table.cal_id=$this->repeats_table.cal_id";
319 319
 
320 320
 		$where = array();
@@ -324,23 +324,23 @@  discard block
 block discarded – undo
324 324
 			$where['cal_uid'] = $ids;
325 325
 			$where['cal_reference'] = 0;
326 326
 		}
327
-		elseif(is_array($ids) && isset($ids[count($ids)-1]) || is_scalar($ids))	// one or more cal_id's
327
+		elseif (is_array($ids) && isset($ids[count($ids) - 1]) || is_scalar($ids))	// one or more cal_id's
328 328
 		{
329 329
 			$where['cal_id'] = $ids;
330 330
 		}
331 331
 		else	// array with column => value pairs
332 332
 		{
333 333
 			$where = $ids;
334
-			unset($ids);	// otherwise users get not read!
334
+			unset($ids); // otherwise users get not read!
335 335
 		}
336 336
 		if (isset($where['cal_id']))	// prevent non-unique column-name cal_id
337 337
 		{
338
-			$where[] = $this->db->expression($this->cal_table, $this->cal_table.'.',array(
338
+			$where[] = $this->db->expression($this->cal_table, $this->cal_table.'.', array(
339 339
 				'cal_id' => $where['cal_id'],
340 340
 			));
341 341
 			unset($where['cal_id']);
342 342
 		}
343
-		if ((int) $recur_date)
343
+		if ((int)$recur_date)
344 344
 		{
345 345
 			$where[] = 'cal_start >= '.(int)$recur_date;
346 346
 			$group_by = 'GROUP BY '.$cols;
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
 		}
354 354
 		$cols .= ',range_end-1 AS recur_enddate';
355 355
 
356
-		$events =& $this->get_events($this->db->select($this->cal_table, $cols, $where, __LINE__, __FILE__, false, $group_by, 'calendar', 0, $join), $recur_date);
356
+		$events = & $this->get_events($this->db->select($this->cal_table, $cols, $where, __LINE__, __FILE__, false, $group_by, 'calendar', 0, $join), $recur_date);
357 357
 
358 358
 		return $events ? $events : false;
359 359
 	}
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
 	 * @param int $recur_date =0
366 366
 	 * @return array
367 367
 	 */
368
-	protected function &get_events($rs, $recur_date=0)
368
+	protected function &get_events($rs, $recur_date = 0)
369 369
 	{
370 370
 		if (isset($GLOBALS['egw_info']['user']['preferences']['syncml']['minimum_uid_length']))
371 371
 		{
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
 		}
378 378
 
379 379
 		$events = array();
380
-		foreach($rs as $row)
380
+		foreach ($rs as $row)
381 381
 		{
382 382
 			if (!$row['recur_type'])
383 383
 			{
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
 				unset($row['recur_enddate']);
386 386
 			}
387 387
 			$row['recur_exception'] = $row['alarm'] = array();
388
-			$events[$row['cal_id']] = Api\Db::strip_array_keys($row,'cal_');
388
+			$events[$row['cal_id']] = Api\Db::strip_array_keys($row, 'cal_');
389 389
 		}
390 390
 		if (!$events) return $events;
391 391
 
@@ -397,26 +397,26 @@  discard block
 block discarded – undo
397 397
 			if (!isset($event['uid']) || strlen($event['uid']) < $minimum_uid_length)
398 398
 			{
399 399
 				// event (without uid), not strong enough uid => create new uid
400
-				$event['uid'] = Api\CalDAV::generate_uid('calendar',$event['id']);
400
+				$event['uid'] = Api\CalDAV::generate_uid('calendar', $event['id']);
401 401
 				$this->db->update($this->cal_table, array('cal_uid' => $event['uid']),
402
-					array('cal_id' => $event['id']),__LINE__,__FILE__,'calendar');
402
+					array('cal_id' => $event['id']), __LINE__, __FILE__, 'calendar');
403 403
 			}
404 404
 			if (!(int)$recur_date && $event['recur_type'] != MCAL_RECUR_NONE)
405 405
 			{
406
-				foreach($this->db->select($this->dates_table, 'cal_id,cal_start', array(
406
+				foreach ($this->db->select($this->dates_table, 'cal_id,cal_start', array(
407 407
 					'cal_id' => $ids,
408 408
 					'recur_exception' => true,
409 409
 				), __LINE__, __FILE__, false, 'ORDER BY cal_id,cal_start', 'calendar') as $row)
410 410
 				{
411 411
 					$events[$row['cal_id']]['recur_exception'][] = $row['cal_start'];
412 412
 				}
413
-				break;	// as above select read all exceptions (and I dont think too short uid problem still exists)
413
+				break; // as above select read all exceptions (and I dont think too short uid problem still exists)
414 414
 			}
415 415
 			// make sure we fetch only real exceptions (deleted occurrences of a series should not show up)
416
-			if (($recur_date &&	$event['recur_type'] != MCAL_RECUR_NONE))
416
+			if (($recur_date && $event['recur_type'] != MCAL_RECUR_NONE))
417 417
 			{
418 418
 				//_debug_array(__METHOD__.__LINE__.' recur_date:'.$recur_date.' check cal_start:'.$event['start']);
419
-				foreach($this->db->select($this->dates_table, 'cal_id,cal_start', array(
419
+				foreach ($this->db->select($this->dates_table, 'cal_id,cal_start', array(
420 420
 					'cal_id' => $event['id'],
421 421
 					'cal_start' => $event['start'],
422 422
 					'recur_exception' => true,
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
 						'cal_deleted' => NULL
433 433
 					), __LINE__, __FILE__, false, '', 'calendar')->fetchColumn())
434 434
 					{
435
-						$e = $this->read($event['id'],$event['start']+1);
435
+						$e = $this->read($event['id'], $event['start'] + 1);
436 436
 						$event = $e[$event['id']];
437 437
 						break;
438 438
 					}
@@ -454,21 +454,21 @@  discard block
 block discarded – undo
454 454
 			if ($recur_date)
455 455
 			{
456 456
 				// also remember recur_date, maybe we need it later, duno now
457
-				$recur_date = array(0,$events[$ids]['recur_date'] = $events[$ids]['start']);
457
+				$recur_date = array(0, $events[$ids]['recur_date'] = $events[$ids]['start']);
458 458
 			}
459 459
 		}
460 460
 
461 461
 		// participants, if a recur_date give, we read that recurance, plus the one users from the default entry with recur_date=0
462 462
 		// sorting by cal_recur_date ASC makes sure recurence status always overwrites series status
463
-		foreach($this->db->select($this->user_table,'*',array(
463
+		foreach ($this->db->select($this->user_table, '*', array(
464 464
 			'cal_id'      => $ids,
465 465
 			'cal_recur_date' => $recur_date,
466 466
 			"cal_status NOT IN ('X','E')",
467
-		),__LINE__,__FILE__,false,'ORDER BY cal_user_type DESC,cal_recur_date ASC,'.self::STATUS_SORT,'calendar') as $row)	// DESC puts users before resources and contacts
467
+		), __LINE__, __FILE__, false, 'ORDER BY cal_user_type DESC,cal_recur_date ASC,'.self::STATUS_SORT, 'calendar') as $row)	// DESC puts users before resources and contacts
468 468
 		{
469 469
 			// combine all participant data in uid and status values
470 470
 			$uid    = self::combine_user($row['cal_user_type'], $row['cal_user_id'], $row['cal_user_attendee']);
471
-			$status = self::combine_status($row['cal_status'],$row['cal_quantity'],$row['cal_role']);
471
+			$status = self::combine_status($row['cal_status'], $row['cal_quantity'], $row['cal_role']);
472 472
 
473 473
 			$events[$row['cal_id']]['participants'][$uid] = $status;
474 474
 			$events[$row['cal_id']]['participant_types'][$row['cal_user_type']][is_numeric($uid) ? $uid : substr($uid, 1)] = $status;
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
 		}
478 478
 
479 479
 		// custom fields
480
-		foreach($this->db->select($this->extra_table,'*',array('cal_id'=>$ids),__LINE__,__FILE__,false,'','calendar') as $row)
480
+		foreach ($this->db->select($this->extra_table, '*', array('cal_id'=>$ids), __LINE__, __FILE__, false, '', 'calendar') as $row)
481 481
 		{
482 482
 			$events[$row['cal_id']]['#'.$row['cal_extra_name']] = $row['cal_extra_value'];
483 483
 		}
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
 		// alarms
486 486
 		if (is_array($ids))
487 487
 		{
488
-			foreach($this->read_alarms((array)$ids) as $cal_id => $alarms)
488
+			foreach ($this->read_alarms((array)$ids) as $cal_id => $alarms)
489 489
 			{
490 490
 				$events[$cal_id]['alarm'] = $alarms;
491 491
 			}
@@ -514,11 +514,11 @@  discard block
 block discarded – undo
514 514
 	 * @param boolean $master_only =false only check recurance master (egw_cal_user.recur_date=0)
515 515
 	 * @return int maximum modification timestamp
516 516
 	 */
517
-	function get_ctag($users, $owner_too=false,$master_only=false)
517
+	function get_ctag($users, $owner_too = false, $master_only = false)
518 518
 	{
519
-		static $ctags = array();	// some per-request caching
519
+		static $ctags = array(); // some per-request caching
520 520
 		static $last_request = null;
521
-		if (!isset($last_request) || time()-$last_request > self::MAX_CTAG_CACHE_TIME)
521
+		if (!isset($last_request) || time() - $last_request > self::MAX_CTAG_CACHE_TIME)
522 522
 		{
523 523
 			$ctags = array();
524 524
 			$last_request = time();
@@ -527,13 +527,13 @@  discard block
 block discarded – undo
527 527
 		if (isset($ctags[$signature])) return $ctags[$signature];
528 528
 
529 529
 		$types = array();
530
-		foreach((array)$users as $uid)
530
+		foreach ((array)$users as $uid)
531 531
 		{
532 532
 			$type = $id = null;
533 533
 			self::split_user($uid, $type, $id, true);
534 534
 			$types[$type][] = $id;
535 535
 		}
536
-		foreach($types as $type => $ids)
536
+		foreach ($types as $type => $ids)
537 537
 		{
538 538
 			$where = array(
539 539
 				'cal_user_type' => $type,
@@ -555,17 +555,17 @@  discard block
 block discarded – undo
555 555
 		if ($owner_too)
556 556
 		{
557 557
 			// owner can only by users, no groups or resources
558
-			foreach($users as $key => $user)
558
+			foreach ($users as $key => $user)
559 559
 			{
560 560
 				if (!($user > 0)) unset($users[$key]);
561 561
 			}
562 562
 			$where = $this->db->expression($this->user_table, '(', $where, ' OR ').
563 563
 				$this->db->expression($this->cal_table, array(
564 564
 					'cal_owner' => $users,
565
-				),')');
565
+				), ')');
566 566
 		}
567
-		return $ctags[$signature] = $this->db->select($this->user_table,'MAX(cal_modified)',
568
-			$where,__LINE__,__FILE__,false,'','calendar',0,'JOIN egw_cal ON egw_cal.cal_id=egw_cal_user.cal_id')->fetchColumn();
567
+		return $ctags[$signature] = $this->db->select($this->user_table, 'MAX(cal_modified)',
568
+			$where, __LINE__, __FILE__, false, '', 'calendar', 0, 'JOIN egw_cal ON egw_cal.cal_id=egw_cal_user.cal_id')->fetchColumn();
569 569
 	}
570 570
 
571 571
 	/**
@@ -577,7 +577,7 @@  discard block
 block discarded – undo
577 577
 	 * @param string|array $cols ='cal_id,cal_reference,cal_etag,cal_modified,cal_user_modified' cols to query
578 578
 	 * @return Iterator as Api\Db::select
579 579
 	 */
580
-	function get_cal_data(array $query, $cols='cal_id,cal_reference,cal_etag,cal_modified,cal_user_modified')
580
+	function get_cal_data(array $query, $cols = 'cal_id,cal_reference,cal_etag,cal_modified,cal_user_modified')
581 581
 	{
582 582
 		if (!is_array($cols)) $cols = explode(',', $cols);
583 583
 
@@ -603,12 +603,12 @@  discard block
 block discarded – undo
603 603
 		if ($cat_id)
604 604
 		{
605 605
 			$cats = $GLOBALS['egw']->categories->return_all_children($cat_id);
606
-			array_walk($cats,create_function('&$val,$key','$val = (int) $val;'));
607
-			if (is_array($cat_id) && count($cat_id)==1) $cat_id = $cat_id[0];
608
-			$sql = '(cal_category'.(count($cats) > 1 ? " IN ('".implode("','",$cats)."')" : '='.$this->db->quote((int)$cat_id));
609
-			foreach($cats as $cat)
606
+			array_walk($cats, create_function('&$val,$key', '$val = (int) $val;'));
607
+			if (is_array($cat_id) && count($cat_id) == 1) $cat_id = $cat_id[0];
608
+			$sql = '(cal_category'.(count($cats) > 1 ? " IN ('".implode("','", $cats)."')" : '='.$this->db->quote((int)$cat_id));
609
+			foreach ($cats as $cat)
610 610
 			{
611
-				$sql .= ' OR '.$this->db->concat("','",'cal_category',"','").' LIKE '.$this->db->quote('%,'.$cat.',%');
611
+				$sql .= ' OR '.$this->db->concat("','", 'cal_category', "','").' LIKE '.$this->db->quote('%,'.$cat.',%');
612 612
 			}
613 613
 			$sql .= ') ';
614 614
 		}
@@ -623,13 +623,13 @@  discard block
 block discarded – undo
623 623
 	 * @param array $where =array() array to add filters too
624 624
 	 * @return array
625 625
 	 */
626
-	protected function status_filter($filter, $enum_recuring=true, array $where=array())
626
+	protected function status_filter($filter, $enum_recuring = true, array $where = array())
627 627
 	{
628
-		if($filter != 'deleted' && $filter != 'everything')
628
+		if ($filter != 'deleted' && $filter != 'everything')
629 629
 		{
630 630
 			$where[] = 'cal_deleted IS NULL';
631 631
 		}
632
-		switch($filter)
632
+		switch ($filter)
633 633
 		{
634 634
 			case 'everything':	// no filter at all
635 635
 				break;
@@ -703,7 +703,7 @@  discard block
 block discarded – undo
703 703
 	 * @param int $remove_rejected_by_user =null add join to remove entry, if given user has rejected it
704 704
 	 * @return Iterator|array of events
705 705
 	 */
706
-	function &search($start,$end,$users,$cat_id=0,$filter='all',$offset=False,$num_rows=0,array $params=array(),$remove_rejected_by_user=null)
706
+	function &search($start, $end, $users, $cat_id = 0, $filter = 'all', $offset = False, $num_rows = 0, array $params = array(), $remove_rejected_by_user = null)
707 707
 	{
708 708
 		//error_log(__METHOD__.'('.($start ? date('Y-m-d H:i',$start) : '').','.($end ? date('Y-m-d H:i',$end) : '').','.array2string($users).','.array2string($cat_id).",'$filter',".array2string($offset).",$num_rows,".array2string($params).') '.function_backtrace());
709 709
 
@@ -726,7 +726,7 @@  discard block
 block discarded – undo
726 726
 		{
727 727
 			$all_cols = self::get_columns('calendar', $this->cal_table);
728 728
 			$all_cols[0] = $this->db->to_varchar($this->cal_table.'.cal_id');
729
-			$cols = "$this->repeats_table.recur_type,$this->repeats_table.recur_interval,$this->repeats_table.recur_data,range_end - 1 AS recur_enddate,".implode(',',$all_cols).",cal_start,cal_end,$this->user_table.cal_recur_date";
729
+			$cols = "$this->repeats_table.recur_type,$this->repeats_table.recur_interval,$this->repeats_table.recur_data,range_end - 1 AS recur_enddate,".implode(',', $all_cols).",cal_start,cal_end,$this->user_table.cal_recur_date";
730 730
 		}
731 731
 		$where = array();
732 732
 		if (is_array($params['query']))
@@ -735,26 +735,26 @@  discard block
 block discarded – undo
735 735
 		}
736 736
 		elseif ($params['query'])
737 737
 		{
738
-			if(is_numeric($params['query']))
738
+			if (is_numeric($params['query']))
739 739
 			{
740
-				$where[] = $this->cal_table.'.cal_id = ' . (int)$params['query'];
740
+				$where[] = $this->cal_table.'.cal_id = '.(int)$params['query'];
741 741
 			}
742 742
 			else
743 743
 			{
744
-				foreach(array('cal_title','cal_description','cal_location') as $col)
744
+				foreach (array('cal_title', 'cal_description', 'cal_location') as $col)
745 745
 				{
746 746
 					$to_or[] = $col.' '.$this->db->capabilities[Api\Db::CAPABILITY_CASE_INSENSITIV_LIKE].' '.$this->db->quote('%'.$params['query'].'%');
747 747
 				}
748
-				$where[] = '('.implode(' OR ',$to_or).')';
748
+				$where[] = '('.implode(' OR ', $to_or).')';
749 749
 			}
750 750
 
751 751
 			// Searching - restrict private to own or private grant
752 752
 			if (!isset($params['private_grants']))
753 753
 			{
754 754
 				$params['private_grants'] = $GLOBALS['egw']->acl->get_ids_for_location($GLOBALS['egw_info']['user']['account_id'], Acl::PRIVAT, 'calendar');
755
-				$params['private_grants'][] = $GLOBALS['egw_info']['user']['account_id'];	// db query does NOT return current user
755
+				$params['private_grants'][] = $GLOBALS['egw_info']['user']['account_id']; // db query does NOT return current user
756 756
 			}
757
-			$private_filter = '(cal_public=1 OR cal_public=0 AND '.$this->db->expression($this->cal_table, array('cal_owner' => $params['private_grants'])) . ')';
757
+			$private_filter = '(cal_public=1 OR cal_public=0 AND '.$this->db->expression($this->cal_table, array('cal_owner' => $params['private_grants'])).')';
758 758
 			$where[] = $private_filter;
759 759
 		}
760 760
 		if (!empty($params['sql_filter']))
@@ -763,7 +763,7 @@  discard block
 block discarded – undo
763 763
 			{
764 764
 				$where[] = $params['sql_filter'];
765 765
 			}
766
-			elseif(is_array($params['sql_filter']))
766
+			elseif (is_array($params['sql_filter']))
767 767
 			{
768 768
 				$where = array_merge($where, $params['sql_filter']);
769 769
 			}
@@ -772,11 +772,11 @@  discard block
 block discarded – undo
772 772
 		if ($users)
773 773
 		{
774 774
 			$users_by_type = array();
775
-			foreach((array)$users as $user)
775
+			foreach ((array)$users as $user)
776 776
 			{
777 777
 				if (is_numeric($user))
778 778
 				{
779
-					$users_by_type['u'][] = (int) $user;
779
+					$users_by_type['u'][] = (int)$user;
780 780
 				}
781 781
 				else
782 782
 				{
@@ -787,45 +787,45 @@  discard block
 block discarded – undo
787 787
 			}
788 788
 			$to_or = $user_or = array();
789 789
 			$owner_or = null;
790
-			$table_def = $this->db->get_table_definitions('calendar',$this->user_table);
791
-			foreach($users_by_type as $type => $ids)
790
+			$table_def = $this->db->get_table_definitions('calendar', $this->user_table);
791
+			foreach ($users_by_type as $type => $ids)
792 792
 			{
793 793
 				// when we are able to use Union Querys, we do not OR our query, we save the needed parts for later construction of the union
794 794
 				if ($useUnionQuery)
795 795
 				{
796
-					$user_or[] = $this->db->expression($table_def,$this->user_table.'.',array(
796
+					$user_or[] = $this->db->expression($table_def, $this->user_table.'.', array(
797 797
 						'cal_user_type' => $type,
798
-					),' AND '.$this->user_table.'.',array(
798
+					), ' AND '.$this->user_table.'.', array(
799 799
 						'cal_user_id'   => $ids,
800 800
 					));
801 801
 					if ($type == 'u' && $filter == 'owner')
802 802
 					{
803
-						$cal_table_def = $this->db->get_table_definitions('calendar',$this->cal_table);
803
+						$cal_table_def = $this->db->get_table_definitions('calendar', $this->cal_table);
804 804
 						// only users can be owners, no need to add groups
805 805
 						$user_ids = array();
806
-						foreach($ids as $user_id)
806
+						foreach ($ids as $user_id)
807 807
 						{
808 808
 							if ($GLOBALS['egw']->accounts->get_type($user_id) === 'u') $user_ids[] = $user_id;
809 809
 						}
810
-						$owner_or = $this->db->expression($cal_table_def,array('cal_owner' => $user_ids));
810
+						$owner_or = $this->db->expression($cal_table_def, array('cal_owner' => $user_ids));
811 811
 					}
812 812
 				}
813 813
 				else
814 814
 				{
815
-					$to_or[] = $this->db->expression($table_def,$this->user_table.'.',array(
815
+					$to_or[] = $this->db->expression($table_def, $this->user_table.'.', array(
816 816
 						'cal_user_type' => $type,
817
-					),' AND '.$this->user_table.'.',array(
817
+					), ' AND '.$this->user_table.'.', array(
818 818
 						'cal_user_id'   => $ids,
819 819
 					));
820 820
 					if ($type == 'u' && $filter == 'owner')
821 821
 					{
822
-						$cal_table_def = $this->db->get_table_definitions('calendar',$this->cal_table);
823
-						$to_or[] = $this->db->expression($cal_table_def,array('cal_owner' => $ids));
822
+						$cal_table_def = $this->db->get_table_definitions('calendar', $this->cal_table);
823
+						$to_or[] = $this->db->expression($cal_table_def, array('cal_owner' => $ids));
824 824
 					}
825 825
 				}
826 826
 			}
827 827
 			// this is only used, when we cannot use UNIONS
828
-			if (!$useUnionQuery) $where[] = '('.implode(' OR ',$to_or).')';
828
+			if (!$useUnionQuery) $where[] = '('.implode(' OR ', $to_or).')';
829 829
 
830 830
 			$where = $this->status_filter($filter, $params['enum_recuring'], $where);
831 831
 		}
@@ -844,15 +844,15 @@  discard block
 block discarded – undo
844 844
 				$where[] = '('.((int)$start).' < range_end OR range_end IS NULL)';
845 845
 			}
846 846
 		}
847
-		if (!preg_match('/^[a-z_ ,c]+$/i',$params['order'])) $params['order'] = 'cal_start';		// gard against SQL injection
847
+		if (!preg_match('/^[a-z_ ,c]+$/i', $params['order'])) $params['order'] = 'cal_start'; // gard against SQL injection
848 848
 
849 849
 		// if not enum recuring events, we have to use minimum start- AND end-dates, otherwise we get more then one event per cal_id!
850 850
 		if (!$params['enum_recuring'])
851 851
 		{
852 852
 			$where[] = "$this->user_table.cal_recur_date=0";
853
-			$cols = str_replace(array('cal_start','cal_end'),array('range_start AS cal_start','(SELECT MIN(cal_end) FROM egw_cal_dates WHERE egw_cal.cal_id=egw_cal_dates.cal_id) AS cal_end'),$cols);
853
+			$cols = str_replace(array('cal_start', 'cal_end'), array('range_start AS cal_start', '(SELECT MIN(cal_end) FROM egw_cal_dates WHERE egw_cal.cal_id=egw_cal_dates.cal_id) AS cal_end'), $cols);
854 854
 			// in case cal_start is used in a query, eg. calendar_ical::find_event
855
-			$where = str_replace(array('cal_start','cal_end'), array('range_start','(SELECT MIN(cal_end) FROM egw_cal_dates WHERE egw_cal.cal_id=egw_cal_dates.cal_id)'), $where);
855
+			$where = str_replace(array('cal_start', 'cal_end'), array('range_start', '(SELECT MIN(cal_end) FROM egw_cal_dates WHERE egw_cal.cal_id=egw_cal_dates.cal_id)'), $where);
856 856
 			$params['order'] = str_replace('cal_start', 'range_start', $params['order']);
857 857
 			if ($end) $where[] = (int)$end.' > range_start';
858 858
   		}
@@ -864,14 +864,13 @@  discard block
 block discarded – undo
864 864
 				" ON $this->cal_table.cal_id=rejected_by_user.cal_id".
865 865
 				" AND rejected_by_user.cal_user_type='u'".
866 866
 				" AND rejected_by_user.cal_user_id=".$this->db->quote($remove_rejected_by_user).
867
-				" AND ".(!$params['enum_recuring'] ? 'rejected_by_user.cal_recur_date=0' :
868
-					'(recur_type IS NULL AND rejected_by_user.cal_recur_date=0 OR cal_start=rejected_by_user.cal_recur_date)');
867
+				" AND ".(!$params['enum_recuring'] ? 'rejected_by_user.cal_recur_date=0' : '(recur_type IS NULL AND rejected_by_user.cal_recur_date=0 OR cal_start=rejected_by_user.cal_recur_date)');
869 868
 			$or_required = array(
870 869
 				'rejected_by_user.cal_status IS NULL',
871 870
 				"rejected_by_user.cal_status NOT IN ('R','X')",
872 871
 			);
873 872
 			if ($filter == 'owner') $or_required[] = 'cal_owner='.(int)$remove_rejected_by_user;
874
-			$where[] = '('.implode(' OR ',$or_required).')';
873
+			$where[] = '('.implode(' OR ', $or_required).')';
875 874
 		}
876 875
 		// using a time-range and deleted attribute limited view instead of full table
877 876
 		$cal_table = $this->cal_range_view($start, $end, null, $filter == 'everything' ? null : $filter != 'deleted');
@@ -883,18 +882,18 @@  discard block
 block discarded – undo
883 882
 		// dates table join only needed to enum recuring events, we use a time-range limited view here too
884 883
 		if ($params['enum_recuring'])
885 884
 		{
886
-			$join = "JOIN ".$this->dates_table.	// using dates_table direct seems quicker then an other view
885
+			$join = "JOIN ".$this->dates_table.// using dates_table direct seems quicker then an other view
887 886
 				//$this->dates_range_view($start, $end, null, $filter == 'everything' ? null : $filter == 'deleted').
888 887
 				" ON $this->cal_table.cal_id=$this->dates_table.cal_id ".$join;
889 888
 		}
890 889
 
891 890
 		// Check for some special sorting, used by planner views
892
-		if($params['order'] == 'participants , cal_non_blocking DESC')
891
+		if ($params['order'] == 'participants , cal_non_blocking DESC')
893 892
 		{
894 893
 			$order = ($GLOBALS['egw_info']['user']['preferences']['common']['account_display'] == 'lastname' ? 'n_family' : 'n_fileas');
895 894
 			$cols .= ",egw_addressbook.{$order}";
896 895
 			$join .= "LEFT JOIN egw_addressbook ON ".
897
-					($this->db->Type == 'pgsql'? "egw_addressbook.account_id::varchar = ":"egw_addressbook.account_id = ").
896
+					($this->db->Type == 'pgsql' ? "egw_addressbook.account_id::varchar = " : "egw_addressbook.account_id = ").
898 897
 					"{$this->user_table}.cal_user_id";
899 898
 			$params['order'] = "$order, cal_non_blocking DESC";
900 899
 		}
@@ -927,29 +926,29 @@  discard block
 block discarded – undo
927 926
 			// as replace the OR by construction of a suitable UNION for performance reasons
928 927
 			if ($owner_or || $user_or)
929 928
 			{
930
-				foreach($user_or as $user_sql)
929
+				foreach ($user_or as $user_sql)
931 930
 				{
932 931
 					$selects[] = $select;
933
-					$selects[count($selects)-1]['where'][] = $user_sql;
932
+					$selects[count($selects) - 1]['where'][] = $user_sql;
934 933
 					if ($params['enum_recuring'])
935 934
 					{
936
-						$selects[count($selects)-1]['where'][] = "recur_type IS NULL AND $this->user_table.cal_recur_date=0";
935
+						$selects[count($selects) - 1]['where'][] = "recur_type IS NULL AND $this->user_table.cal_recur_date=0";
937 936
 						$selects[] = $select;
938
-						$selects[count($selects)-1]['where'][] = $user_sql;
939
-						$selects[count($selects)-1]['where'][] = "$this->user_table.cal_recur_date=cal_start";
937
+						$selects[count($selects) - 1]['where'][] = $user_sql;
938
+						$selects[count($selects) - 1]['where'][] = "$this->user_table.cal_recur_date=cal_start";
940 939
 					}
941 940
 				}
942 941
 				// if the query is to be filtered by owner we need to add more selects for the union
943 942
 				if ($owner_or)
944 943
 				{
945 944
 					$selects[] = $select;
946
-					$selects[count($selects)-1]['where'][] = $owner_or;
945
+					$selects[count($selects) - 1]['where'][] = $owner_or;
947 946
 					if ($params['enum_recuring'])
948 947
 					{
949
-						$selects[count($selects)-1]['where'][] = "recur_type IS NULL AND $this->user_table.cal_recur_date=0";
948
+						$selects[count($selects) - 1]['where'][] = "recur_type IS NULL AND $this->user_table.cal_recur_date=0";
950 949
 						$selects[] = $select;
951
-						$selects[count($selects)-1]['where'][] = $owner_or;
952
-						$selects[count($selects)-1]['where'][] = "$this->user_table.cal_recur_date=cal_start";
950
+						$selects[count($selects) - 1]['where'][] = $owner_or;
951
+						$selects[count($selects) - 1]['where'][] = "$this->user_table.cal_recur_date=cal_start";
953 952
 					}
954 953
 				}
955 954
 			}
@@ -959,34 +958,34 @@  discard block
 block discarded – undo
959 958
 				$selects[] = $select;
960 959
 				if ($params['enum_recuring'])
961 960
 				{
962
-					$selects[count($selects)-1]['where'][] = "recur_type IS NULL AND $this->user_table.cal_recur_date=0";
961
+					$selects[count($selects) - 1]['where'][] = "recur_type IS NULL AND $this->user_table.cal_recur_date=0";
963 962
 					$selects[] = $select;
964
-					$selects[count($selects)-1]['where'][] = "$this->user_table.cal_recur_date=cal_start";
963
+					$selects[count($selects) - 1]['where'][] = "$this->user_table.cal_recur_date=cal_start";
965 964
 				}
966 965
 			}
967 966
 			if (is_numeric($offset) && !$params['no_total'])	// get the total too
968 967
 			{
969 968
 				$save_selects = $selects;
970 969
 				// we only select cal_table.cal_id (and not cal_table.*) to be able to use DISTINCT (eg. MsSQL does not allow it for text-columns)
971
-				foreach(array_keys($selects) as $key)
970
+				foreach (array_keys($selects) as $key)
972 971
 				{
973 972
 					$selects[$key]['cols'] = "$this->repeats_table.recur_type,range_end AS recur_enddate,$this->repeats_table.recur_interval,$this->repeats_table.recur_data,".$this->db->to_varchar($this->cal_table.'.cal_id').",cal_start,cal_end,$this->user_table.cal_recur_date";
974 973
 					if (!$params['enum_recuring'])
975 974
 					{
976
-						$selects[$key]['cols'] = str_replace(array('cal_start','cal_end'),
977
-							array('range_start AS cal_start','range_end AS cal_end'), $selects[$key]['cols']);
975
+						$selects[$key]['cols'] = str_replace(array('cal_start', 'cal_end'),
976
+							array('range_start AS cal_start', 'range_end AS cal_end'), $selects[$key]['cols']);
978 977
 					}
979 978
 				}
980
-				if (!isset($params['cols']) && !$params['no_integration']) self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']);
979
+				if (!isset($params['cols']) && !$params['no_integration']) self::get_union_selects($selects, $start, $end, $users, $cat_id, $filter, $params['query'], $params['users']);
981 980
 
982
-				$this->total = $this->db->union($selects,__LINE__,__FILE__)->NumRows();
981
+				$this->total = $this->db->union($selects, __LINE__, __FILE__)->NumRows();
983 982
 
984 983
 				// restore original cols / selects
985 984
 				$selects = $save_selects; unset($save_selects);
986 985
 			}
987
-			if (!isset($params['cols']) && !$params['no_integration']) self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']);
986
+			if (!isset($params['cols']) && !$params['no_integration']) self::get_union_selects($selects, $start, $end, $users, $cat_id, $filter, $params['query'], $params['users']);
988 987
 
989
-			$rs = $this->db->union($selects,__LINE__,__FILE__,$params['order'],$offset,$num_rows);
988
+			$rs = $this->db->union($selects, __LINE__, __FILE__, $params['order'], $offset, $num_rows);
990 989
 		}
991 990
 		else	// MsSQL oder MySQL 3.23
992 991
 		{
@@ -1009,27 +1008,27 @@  discard block
 block discarded – undo
1009 1008
 				$selects[0]['cols'] = "$this->cal_table.cal_id,cal_start";
1010 1009
 				if (!isset($params['cols']) && !$params['no_integration'] && $this->db->capabilities['union'])
1011 1010
 				{
1012
-					self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']);
1011
+					self::get_union_selects($selects, $start, $end, $users, $cat_id, $filter, $params['query'], $params['users']);
1013 1012
 				}
1014 1013
 				$this->total = $this->db->union($selects, __LINE__, __FILE__)->NumRows();
1015 1014
 				$selects = $save_selects;
1016 1015
 			}
1017 1016
 			if (!isset($params['cols']) && !$params['no_integration'] && $this->db->capabilities['union'])
1018 1017
 			{
1019
-				self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']);
1018
+				self::get_union_selects($selects, $start, $end, $users, $cat_id, $filter, $params['query'], $params['users']);
1020 1019
 			}
1021
-			$rs = $this->db->union($selects,__LINE__,__FILE__,$params['order'],$offset,$num_rows);
1020
+			$rs = $this->db->union($selects, __LINE__, __FILE__, $params['order'], $offset, $num_rows);
1022 1021
 		}
1023 1022
 		//error_log(__METHOD__."() useUnionQuery=$useUnionQuery --> query took ".(microtime(true)-$starttime).'s '.$rs->sql);
1024 1023
 
1025 1024
 		if (isset($params['cols']))
1026 1025
 		{
1027
-			return $rs;	// if colums are specified we return the recordset / iterator
1026
+			return $rs; // if colums are specified we return the recordset / iterator
1028 1027
 		}
1029 1028
 		// Todo: return $this->get_events($rs);
1030 1029
 
1031 1030
 		$events = $ids = $recur_dates = $recur_ids = array();
1032
-		foreach($rs as $row)
1031
+		foreach ($rs as $row)
1033 1032
 		{
1034 1033
 			$id = $row['cal_id'];
1035 1034
 			if (is_numeric($id)) $ids[] = $id;
@@ -1041,9 +1040,9 @@  discard block
 block discarded – undo
1041 1040
 			}
1042 1041
 			if ($row['participants'])
1043 1042
 			{
1044
-				$row['participants'] = explode(',',$row['participants']);
1043
+				$row['participants'] = explode(',', $row['participants']);
1045 1044
 				$row['participants'] = array_combine($row['participants'],
1046
-					array_fill(0,count($row['participants']),''));
1045
+					array_fill(0, count($row['participants']), ''));
1047 1046
 			}
1048 1047
 			else
1049 1048
 			{
@@ -1052,9 +1051,9 @@  discard block
 block discarded – undo
1052 1051
 			$row['recur_exception'] = $row['alarm'] = array();
1053 1052
 
1054 1053
 			// compile a list of recurrences per cal_id
1055
-			if (!in_array($id,(array)$recur_ids[$row['cal_id']])) $recur_ids[$row['cal_id']][] = $id;
1054
+			if (!in_array($id, (array)$recur_ids[$row['cal_id']])) $recur_ids[$row['cal_id']][] = $id;
1056 1055
 
1057
-			$events[$id] = Api\Db::strip_array_keys($row,'cal_');
1056
+			$events[$id] = Api\Db::strip_array_keys($row, 'cal_');
1058 1057
 		}
1059 1058
 		//_debug_array($events);
1060 1059
 		if (count($ids))
@@ -1064,26 +1063,26 @@  discard block
 block discarded – undo
1064 1063
 			// now ready all users with the given cal_id AND (cal_recur_date=0 or the fitting recur-date)
1065 1064
 			// This will always read the first entry of each recuring event too, we eliminate it later
1066 1065
 			$recur_dates[] = 0;
1067
-			$utcal_id_view = " (SELECT * FROM ".$this->user_table." WHERE cal_id IN (".implode(',',$ids).")".
1066
+			$utcal_id_view = " (SELECT * FROM ".$this->user_table." WHERE cal_id IN (".implode(',', $ids).")".
1068 1067
 				($filter != 'everything' ? " AND cal_status NOT IN ('X','E')" : '').") utcalid ";
1069 1068
 			//$utrecurdate_view = " (select * from ".$this->user_table." where cal_recur_date in (".implode(',',array_unique($recur_dates)).")) utrecurdates ";
1070
-			foreach($this->db->select($utcal_id_view,'*',array(
1069
+			foreach ($this->db->select($utcal_id_view, '*', array(
1071 1070
 					//'cal_id' => array_unique($ids),
1072 1071
 					'cal_recur_date' => $recur_dates,
1073
-				),__LINE__,__FILE__,false,'ORDER BY cal_id,cal_user_type DESC,'.self::STATUS_SORT,'calendar',-1,$join='',
1074
-				$this->db->get_table_definitions('calendar',$this->user_table)) as $row)	// DESC puts users before resources and contacts
1072
+				), __LINE__, __FILE__, false, 'ORDER BY cal_id,cal_user_type DESC,'.self::STATUS_SORT, 'calendar', -1, $join = '',
1073
+				$this->db->get_table_definitions('calendar', $this->user_table)) as $row)	// DESC puts users before resources and contacts
1075 1074
 			{
1076 1075
 				$id = $row['cal_id'];
1077 1076
 				if ($row['cal_recur_date']) $id .= '-'.$row['cal_recur_date'];
1078 1077
 
1079 1078
 				// combine all participant data in uid and status values
1080 1079
 				$uid = self::combine_user($row['cal_user_type'], $row['cal_user_id'], $row['cal_user_attendee']);
1081
-				$status = self::combine_status($row['cal_status'],$row['cal_quantity'],$row['cal_role']);
1080
+				$status = self::combine_status($row['cal_status'], $row['cal_quantity'], $row['cal_role']);
1082 1081
 
1083 1082
 				// set accept/reject/tentative of series for all recurrences
1084 1083
 				if (!$row['cal_recur_date'])
1085 1084
 				{
1086
-					foreach((array)$recur_ids[$row['cal_id']] as $i)
1085
+					foreach ((array)$recur_ids[$row['cal_id']] as $i)
1087 1086
 					{
1088 1087
 						if (isset($events[$i]) && !isset($events[$i]['participants'][$uid]))
1089 1088
 						{
@@ -1098,16 +1097,16 @@  discard block
 block discarded – undo
1098 1097
 			// query recurrance exceptions, if needed: enum_recuring && !daywise is used in calendar_groupdav::get_series($uid,...)
1099 1098
 			if (!$params['enum_recuring'] || !$params['daywise'])
1100 1099
 			{
1101
-				foreach($this->db->select($this->dates_table, 'cal_id,cal_start', array(
1100
+				foreach ($this->db->select($this->dates_table, 'cal_id,cal_start', array(
1102 1101
 					'cal_id' => $ids,
1103 1102
 					'recur_exception' => true,
1104 1103
 				), __LINE__, __FILE__, false, 'ORDER BY cal_id,cal_start', 'calendar') as $row)
1105 1104
 				{
1106 1105
 					// for enum_recurring events are not indexed by cal_id, but $cal_id.'-'.$cal_start
1107 1106
 					// find master, which is first recurrence
1108
-					if (!isset($events[$id=$row['cal_id']]))
1107
+					if (!isset($events[$id = $row['cal_id']]))
1109 1108
 					{
1110
-						foreach($events as $id => $event)
1109
+						foreach ($events as $id => $event)
1111 1110
 						{
1112 1111
 							if ($event['id'] == $row['cal_id']) break;
1113 1112
 						}
@@ -1120,10 +1119,10 @@  discard block
 block discarded – undo
1120 1119
 			{
1121 1120
 				$where = array('cal_id' => $ids);
1122 1121
 				if ($params['cfs']) $where['cal_extra_name'] = $params['cfs'];
1123
-				foreach($this->db->select($this->extra_table,'*',$where,
1124
-					__LINE__,__FILE__,false,'','calendar') as $row)
1122
+				foreach ($this->db->select($this->extra_table, '*', $where,
1123
+					__LINE__, __FILE__, false, '', 'calendar') as $row)
1125 1124
 				{
1126
-					foreach((array)$recur_ids[$row['cal_id']] as $id)
1125
+					foreach ((array)$recur_ids[$row['cal_id']] as $id)
1127 1126
 					{
1128 1127
 						if (isset($events[$id]))
1129 1128
 						{
@@ -1133,9 +1132,9 @@  discard block
 block discarded – undo
1133 1132
 				}
1134 1133
 			}
1135 1134
 			// alarms
1136
-			foreach($this->read_alarms($ids) as $cal_id => $alarms)
1135
+			foreach ($this->read_alarms($ids) as $cal_id => $alarms)
1137 1136
 			{
1138
-				foreach($alarms as $id => $alarm)
1137
+				foreach ($alarms as $id => $alarm)
1139 1138
 				{
1140 1139
 					$event_start = $alarm['time'] + $alarm['offset'];
1141 1140
 
@@ -1172,16 +1171,16 @@  discard block
 block discarded – undo
1172 1171
 	 * @param $query
1173 1172
 	 * @param $users_raw as passed to calendar_bo::search (no members and memberships added)
1174 1173
 	 */
1175
-	private static function get_union_selects(array &$selects,$start,$end,$users,$cat_id,$filter,$query,$users_raw)
1174
+	private static function get_union_selects(array &$selects, $start, $end, $users, $cat_id, $filter, $query, $users_raw)
1176 1175
 	{
1177
-		if (in_array(basename($_SERVER['SCRIPT_FILENAME']),array('groupdav.php','rpc.php','xmlrpc.php','/activesync/index.php')) ||
1178
-			!in_array($GLOBALS['egw_info']['flags']['currentapp'],array('calendar','home')))
1176
+		if (in_array(basename($_SERVER['SCRIPT_FILENAME']), array('groupdav.php', 'rpc.php', 'xmlrpc.php', '/activesync/index.php')) ||
1177
+			!in_array($GLOBALS['egw_info']['flags']['currentapp'], array('calendar', 'home')))
1179 1178
 		{
1180
-			return;    // disable integration for GroupDAV, SyncML, ...
1179
+			return; // disable integration for GroupDAV, SyncML, ...
1181 1180
 		}
1182 1181
 		self::$integration_data = Api\Hooks::process(array(
1183 1182
 			'location' => 'calendar_search_union',
1184
-			'cols'  => $selects[0]['cols'],    // cols to return
1183
+			'cols'  => $selects[0]['cols'], // cols to return
1185 1184
 			'start' => $start,
1186 1185
 			'end'   => $end,
1187 1186
 			'users' => $users,
@@ -1190,12 +1189,12 @@  discard block
 block discarded – undo
1190 1189
 			'filter'=> $filter,
1191 1190
 			'query' => $query,
1192 1191
 		));
1193
-		foreach(self::$integration_data as $data)
1192
+		foreach (self::$integration_data as $data)
1194 1193
 		{
1195 1194
 			if (is_array($data['selects']))
1196 1195
 			{
1197 1196
 				//echo $app; _debug_array($data);
1198
-				$selects = array_merge($selects,$data['selects']);
1197
+				$selects = array_merge($selects, $data['selects']);
1199 1198
 			}
1200 1199
 		}
1201 1200
 	}
@@ -1220,35 +1219,35 @@  discard block
 block discarded – undo
1220 1219
 	 * @param string $required_app ='calendar'
1221 1220
 	 * @return string cols for union query to match ones supplied in $required
1222 1221
 	 */
1223
-	public static function union_cols(array $app_cols,$required,$required_app='calendar')
1222
+	public static function union_cols(array $app_cols, $required, $required_app = 'calendar')
1224 1223
 	{
1225 1224
 		// remove evtl. used DISTINCT, we currently dont need it
1226
-		if (($distinct = substr($required,0,9) == 'DISTINCT '))
1225
+		if (($distinct = substr($required, 0, 9) == 'DISTINCT '))
1227 1226
 		{
1228
-			$required = substr($required,9);
1227
+			$required = substr($required, 9);
1229 1228
 		}
1230 1229
 		$return_cols = array();
1231
-		foreach(is_array($required) ? $required : explode(',',$required) as $cols)
1230
+		foreach (is_array($required) ? $required : explode(',', $required) as $cols)
1232 1231
 		{
1233 1232
 			$matches = null;
1234
-			if (substr($cols,-2) == '.*')
1233
+			if (substr($cols, -2) == '.*')
1235 1234
 			{
1236
-				$cols = self::get_columns($required_app,substr($cols,0,-2));
1235
+				$cols = self::get_columns($required_app, substr($cols, 0, -2));
1237 1236
 			}
1238 1237
 			// remove CAST added for PostgreSQL from eg. "CAST(egw_cal.cal_id AS varchar)"
1239 1238
 			elseif (preg_match('/CAST\(([a-z0-9_.]+) AS [a-z0-9_]+\)/i', $cols, $matches))
1240 1239
 			{
1241 1240
 				$cols = $matches[1];
1242 1241
 			}
1243
-			elseif (strpos($cols,' AS ') !== false)
1242
+			elseif (strpos($cols, ' AS ') !== false)
1244 1243
 			{
1245
-				list(,$cols) = explode(' AS ',$cols);
1244
+				list(,$cols) = explode(' AS ', $cols);
1246 1245
 			}
1247
-			foreach((array)$cols as $col)
1246
+			foreach ((array)$cols as $col)
1248 1247
 			{
1249
-				if (substr($col,0,7) == 'egw_cal')	// remove table name
1248
+				if (substr($col, 0, 7) == 'egw_cal')	// remove table name
1250 1249
 				{
1251
-					$col = preg_replace('/^egw_cal[a-z_]*\./','',$col);
1250
+					$col = preg_replace('/^egw_cal[a-z_]*\./', '', $col);
1252 1251
 				}
1253 1252
 				if (isset($app_cols[$col]))
1254 1253
 				{
@@ -1261,7 +1260,7 @@  discard block
 block discarded – undo
1261 1260
 			}
1262 1261
 		}
1263 1262
 		//error_log(__METHOD__."(".array2string($app_cols).", ".array2string($required).", '$required_app') returning ".array2string(implode(',',$return_cols)));
1264
-		return implode(',',$return_cols);
1263
+		return implode(',', $return_cols);
1265 1264
 	}
1266 1265
 
1267 1266
 	/**
@@ -1271,21 +1270,21 @@  discard block
 block discarded – undo
1271 1270
 	 * @param string $table
1272 1271
 	 * @return array of column names
1273 1272
 	 */
1274
-	static private function get_columns($app,$table)
1273
+	static private function get_columns($app, $table)
1275 1274
 	{
1276 1275
 		if ($table != 'egw_cal')
1277 1276
 		{
1278
-			$table_def = $GLOBALS['egw']->db->get_table_definitions($app,$table);
1277
+			$table_def = $GLOBALS['egw']->db->get_table_definitions($app, $table);
1279 1278
 			$cols = array_keys($table_def['fd']);
1280 1279
 		}
1281 1280
 		else
1282 1281
 		{
1283 1282
 			// special handling for egw_cal, as old databases have a different column order!!!
1284
-			$cols =& Api\Cache::getSession(__CLASS__,$table);
1283
+			$cols = & Api\Cache::getSession(__CLASS__, $table);
1285 1284
 
1286 1285
 			if (is_null($cols))
1287 1286
 			{
1288
-				$meta = $GLOBALS['egw']->db->metadata($table,true);
1287
+				$meta = $GLOBALS['egw']->db->metadata($table, true);
1289 1288
 				$cols = array_keys($meta['meta']);
1290 1289
 			}
1291 1290
 		}
@@ -1338,12 +1337,12 @@  discard block
 block discarded – undo
1338 1337
 	 * @param int &$etag etag=null etag to check or null, on return new etag
1339 1338
 	 * @return boolean|int false on error, 0 if etag does not match, cal_id otherwise
1340 1339
 	 */
1341
-	function save($event,&$set_recurrences,&$set_recurrences_start=0,$change_since=0,&$etag=null)
1340
+	function save($event, &$set_recurrences, &$set_recurrences_start = 0, $change_since = 0, &$etag = null)
1342 1341
 	{
1343 1342
 		if (isset($GLOBALS['egw_info']['user']['preferences']['syncml']['minimum_uid_length']))
1344 1343
 		{
1345 1344
 			$minimum_uid_length = $GLOBALS['egw_info']['user']['preferences']['syncml']['minimum_uid_length'];
1346
-			if (empty($minimum_uid_length) || $minimum_uid_length<=1) $minimum_uid_length = 8; // we just do not accept no uid, or uid way to short!
1345
+			if (empty($minimum_uid_length) || $minimum_uid_length <= 1) $minimum_uid_length = 8; // we just do not accept no uid, or uid way to short!
1347 1346
 		}
1348 1347
 		else
1349 1348
 		{
@@ -1354,7 +1353,7 @@  discard block
 block discarded – undo
1354 1353
 
1355 1354
 		//error_log(__METHOD__.'('.array2string($event).",$set_recurrences,$change_since,$etag) ".function_backtrace());
1356 1355
 
1357
-		$cal_id = (int) $event['id'];
1356
+		$cal_id = (int)$event['id'];
1358 1357
 		unset($event['id']);
1359 1358
 		$set_recurrences = $set_recurrences || !$cal_id && $event['recur_type'] != MCAL_RECUR_NONE;
1360 1359
 
@@ -1365,9 +1364,9 @@  discard block
 block discarded – undo
1365 1364
 		}
1366 1365
 
1367 1366
 		// add colum prefix 'cal_' if there's not already a 'recur_' prefix
1368
-		foreach($event as $col => $val)
1367
+		foreach ($event as $col => $val)
1369 1368
 		{
1370
-			if ($col[0] != '#' && substr($col,0,6) != 'recur_' && substr($col,0,6) != 'range_' && $col != 'alarm' && $col != 'tz_id' && $col != 'caldav_name')
1369
+			if ($col[0] != '#' && substr($col, 0, 6) != 'recur_' && substr($col, 0, 6) != 'range_' && $col != 'alarm' && $col != 'tz_id' && $col != 'caldav_name')
1371 1370
 			{
1372 1371
 				$event['cal_'.$col] = $val;
1373 1372
 				unset($event[$col]);
@@ -1377,13 +1376,12 @@  discard block
 block discarded – undo
1377 1376
 		if (isset($event['cal_start'])) $event['range_start'] = $event['cal_start'];
1378 1377
 		if (isset($event['cal_end']))
1379 1378
 		{
1380
-			$event['range_end'] = $event['recur_type'] == MCAL_RECUR_NONE ? $event['cal_end'] :
1381
-				($event['recur_enddate'] ? $event['recur_enddate'] : null);
1379
+			$event['range_end'] = $event['recur_type'] == MCAL_RECUR_NONE ? $event['cal_end'] : ($event['recur_enddate'] ? $event['recur_enddate'] : null);
1382 1380
 		}
1383 1381
 		// ensure that we find mathing entries later on
1384 1382
 		if (!is_array($event['cal_category']))
1385 1383
 		{
1386
-			$categories = array_unique(explode(',',$event['cal_category']));
1384
+			$categories = array_unique(explode(',', $event['cal_category']));
1387 1385
 			sort($categories);
1388 1386
 		}
1389 1387
 		else
@@ -1392,7 +1390,7 @@  discard block
 block discarded – undo
1392 1390
 		}
1393 1391
 		sort($categories, SORT_NUMERIC);
1394 1392
 
1395
-		$event['cal_category'] = implode(',',$categories);
1393
+		$event['cal_category'] = implode(',', $categories);
1396 1394
 
1397 1395
 		// make sure recurring events never reference to an other recurrent event
1398 1396
 		if ($event['recur_type'] != MCAL_RECUR_NONE) $event['cal_reference'] = 0;
@@ -1410,18 +1408,18 @@  discard block
 block discarded – undo
1410 1408
 			// read only timezone id, to check if it is changed
1411 1409
 			if ($event['recur_type'] != MCAL_RECUR_NONE)
1412 1410
 			{
1413
-				$old_tz_id = $this->db->select($this->cal_table,'tz_id',$where,__LINE__,__FILE__,'calendar')->fetchColumn();
1411
+				$old_tz_id = $this->db->select($this->cal_table, 'tz_id', $where, __LINE__, __FILE__, 'calendar')->fetchColumn();
1414 1412
 			}
1415 1413
 			if (!is_null($etag)) $where['cal_etag'] = $etag;
1416 1414
 
1417 1415
 			unset($event['cal_etag']);
1418
-			$event[] = 'cal_etag=cal_etag+1';	// always update the etag, even if none given to check
1416
+			$event[] = 'cal_etag=cal_etag+1'; // always update the etag, even if none given to check
1419 1417
 
1420
-			$this->db->update($this->cal_table,$event,$where,__LINE__,__FILE__,'calendar');
1418
+			$this->db->update($this->cal_table, $event, $where, __LINE__, __FILE__, 'calendar');
1421 1419
 
1422 1420
 			if (!is_null($etag) && $this->db->affected_rows() < 1)
1423 1421
 			{
1424
-				return 0;	// wrong etag, someone else updated the entry
1422
+				return 0; // wrong etag, someone else updated the entry
1425 1423
 			}
1426 1424
 			if (!is_null($etag)) ++$etag;
1427 1425
 		}
@@ -1430,10 +1428,10 @@  discard block
 block discarded – undo
1430 1428
 			// new event
1431 1429
 			if (!$event['cal_owner']) $event['cal_owner'] = $GLOBALS['egw_info']['user']['account_id'];
1432 1430
 
1433
-			if (!$event['cal_id'] && !isset($event['cal_uid'])) $event['cal_uid'] = '';	// uid is NOT NULL!
1431
+			if (!$event['cal_id'] && !isset($event['cal_uid'])) $event['cal_uid'] = ''; // uid is NOT NULL!
1434 1432
 
1435
-			$this->db->insert($this->cal_table,$event,false,__LINE__,__FILE__,'calendar');
1436
-			if (!($cal_id = $this->db->get_last_insert_id($this->cal_table,'cal_id')))
1433
+			$this->db->insert($this->cal_table, $event, false, __LINE__, __FILE__, 'calendar');
1434
+			if (!($cal_id = $this->db->get_last_insert_id($this->cal_table, 'cal_id')))
1437 1435
 			{
1438 1436
 				return false;
1439 1437
 			}
@@ -1443,7 +1441,7 @@  discard block
 block discarded – undo
1443 1441
 		// event without uid or not strong enough uid
1444 1442
 		if (!isset($event['cal_uid']) || strlen($event['cal_uid']) < $minimum_uid_length)
1445 1443
 		{
1446
-			$update['cal_uid'] = $event['cal_uid'] = Api\CalDAV::generate_uid('calendar',$cal_id);
1444
+			$update['cal_uid'] = $event['cal_uid'] = Api\CalDAV::generate_uid('calendar', $cal_id);
1447 1445
 		}
1448 1446
 		// set caldav_name, if not given by caller
1449 1447
 		if (empty($event['caldav_name']) && version_compare($GLOBALS['egw_info']['apps']['calendar']['version'], '1.9.003', '>='))
@@ -1452,37 +1450,37 @@  discard block
 block discarded – undo
1452 1450
 		}
1453 1451
 		if ($update)
1454 1452
 		{
1455
-			$this->db->update($this->cal_table, $update, array('cal_id' => $cal_id),__LINE__,__FILE__,'calendar');
1453
+			$this->db->update($this->cal_table, $update, array('cal_id' => $cal_id), __LINE__, __FILE__, 'calendar');
1456 1454
 		}
1457 1455
 
1458 1456
 		if ($event['recur_type'] == MCAL_RECUR_NONE)
1459 1457
 		{
1460
-			$this->db->delete($this->dates_table,array(
1458
+			$this->db->delete($this->dates_table, array(
1461 1459
 				'cal_id' => $cal_id),
1462
-				__LINE__,__FILE__,'calendar');
1460
+				__LINE__, __FILE__, 'calendar');
1463 1461
 
1464 1462
 			// delete all user-records, with recur-date != 0
1465
-			$this->db->delete($this->user_table,array(
1463
+			$this->db->delete($this->user_table, array(
1466 1464
 				'cal_id' => $cal_id, 'cal_recur_date != 0'),
1467
-				__LINE__,__FILE__,'calendar');
1465
+				__LINE__, __FILE__, 'calendar');
1468 1466
 
1469
-			$this->db->delete($this->repeats_table,array(
1467
+			$this->db->delete($this->repeats_table, array(
1470 1468
 				'cal_id' => $cal_id),
1471
-				__LINE__,__FILE__,'calendar');
1469
+				__LINE__, __FILE__, 'calendar');
1472 1470
 
1473 1471
 			// add exception marker to master, so participants added to exceptions *only* get found
1474 1472
 			if ($event['cal_reference'])
1475 1473
 			{
1476 1474
 				$master_participants = array();
1477
-				foreach($this->db->select($this->user_table, 'cal_user_type,cal_user_id,cal_user_attendee', array(
1475
+				foreach ($this->db->select($this->user_table, 'cal_user_type,cal_user_id,cal_user_attendee', array(
1478 1476
 					'cal_id' => $event['cal_reference'],
1479 1477
 					'cal_recur_date' => 0,
1480
-					"cal_status != 'X'",	// deleted need to be replaced with exception marker too
1478
+					"cal_status != 'X'", // deleted need to be replaced with exception marker too
1481 1479
 				), __LINE__, __FILE__, 'calendar') as $row)
1482 1480
 				{
1483 1481
 					$master_participants[] = self::combine_user($row['cal_user_type'], $row['cal_user_id'], $row['cal_user_attendee']);
1484 1482
 				}
1485
-				foreach(array_diff(array_keys((array)$event['cal_participants']), $master_participants) as $uid)
1483
+				foreach (array_diff(array_keys((array)$event['cal_participants']), $master_participants) as $uid)
1486 1484
 				{
1487 1485
 					$user_type = $user_id = null;
1488 1486
 					self::split_user($uid, $user_type, $user_id, true);
@@ -1501,10 +1499,10 @@  discard block
 block discarded – undo
1501 1499
 		else // write information about recuring event, if recur_type is present in the array
1502 1500
 		{
1503 1501
 			// fetch information about the currently saved (old) event
1504
-			$old_min = (int) $this->db->select($this->dates_table,'MIN(cal_start)',array('cal_id'=>$cal_id),__LINE__,__FILE__,false,'','calendar')->fetchColumn();
1505
-			$old_duration = (int) $this->db->select($this->dates_table,'MIN(cal_end)',array('cal_id'=>$cal_id),__LINE__,__FILE__,false,'','calendar')->fetchColumn() - $old_min;
1502
+			$old_min = (int)$this->db->select($this->dates_table, 'MIN(cal_start)', array('cal_id'=>$cal_id), __LINE__, __FILE__, false, '', 'calendar')->fetchColumn();
1503
+			$old_duration = (int)$this->db->select($this->dates_table, 'MIN(cal_end)', array('cal_id'=>$cal_id), __LINE__, __FILE__, false, '', 'calendar')->fetchColumn() - $old_min;
1506 1504
 			$old_exceptions = array();
1507
-			foreach($this->db->select($this->dates_table, 'cal_start', array(
1505
+			foreach ($this->db->select($this->dates_table, 'cal_start', array(
1508 1506
 				'cal_id' => $cal_id,
1509 1507
 				'recur_exception' => true
1510 1508
 			), __LINE__, __FILE__, false, 'ORDER BY cal_start', 'calendar') as $row)
@@ -1523,8 +1521,8 @@  discard block
 block discarded – undo
1523 1521
 				'cal_recur_date' => 0,
1524 1522
 			);
1525 1523
 			$old_participants = array();
1526
-			foreach ($this->db->select($this->user_table,'cal_user_type,cal_user_id,cal_user_attendee,cal_status,cal_quantity,cal_role', $where,
1527
-				__LINE__,__FILE__,false,'','calendar') as $row)
1524
+			foreach ($this->db->select($this->user_table, 'cal_user_type,cal_user_id,cal_user_attendee,cal_status,cal_quantity,cal_role', $where,
1525
+				__LINE__, __FILE__, false, '', 'calendar') as $row)
1528 1526
 			{
1529 1527
 				$uid = self::combine_user($row['cal_user_type'], $row['cal_user_id'], $row['cal_user_attendee']);
1530 1528
 				$status = self::combine_status($row['cal_status'], $row['cal_quantity'], $row['cal_role']);
@@ -1534,7 +1532,7 @@  discard block
 block discarded – undo
1534 1532
 			// re-check: did so much recurrence data change that we have to rebuild it from scratch?
1535 1533
 			if (!$set_recurrences)
1536 1534
 			{
1537
-				$set_recurrences = (isset($event['cal_start']) && (int)$old_min != (int) $event['cal_start']) ||
1535
+				$set_recurrences = (isset($event['cal_start']) && (int)$old_min != (int)$event['cal_start']) ||
1538 1536
 				    $event['recur_type'] != $old_repeats['recur_type'] || $event['recur_data'] != $old_repeats['recur_data'] ||
1539 1537
 					(int)$event['recur_interval'] != (int)$old_repeats['recur_interval'] || $event['tz_id'] != $old_tz_id;
1540 1538
 			}
@@ -1543,22 +1541,22 @@  discard block
 block discarded – undo
1543 1541
 			{
1544 1542
 				// too much recurrence data has changed, we have to do a rebuild from scratch
1545 1543
 				// delete all, but the lowest dates record
1546
-				$this->db->delete($this->dates_table,array(
1544
+				$this->db->delete($this->dates_table, array(
1547 1545
 					'cal_id' => $cal_id,
1548 1546
 					'cal_start > '.(int)$old_min,
1549
-				),__LINE__,__FILE__,'calendar');
1547
+				), __LINE__, __FILE__, 'calendar');
1550 1548
 
1551 1549
 				// delete all user-records, with recur-date != 0
1552
-				$this->db->delete($this->user_table,array(
1550
+				$this->db->delete($this->user_table, array(
1553 1551
 					'cal_id' => $cal_id,
1554 1552
 					'cal_recur_date != 0',
1555
-				),__LINE__,__FILE__,'calendar');
1553
+				), __LINE__, __FILE__, 'calendar');
1556 1554
 			}
1557 1555
 			else
1558 1556
 			{
1559 1557
 				// we adjust some possibly changed recurrences manually
1560 1558
 				// deleted exceptions: re-insert recurrences into the user and dates table
1561
-				if (count($deleted_exceptions = array_diff($old_exceptions,$event['recur_exception'])))
1559
+				if (count($deleted_exceptions = array_diff($old_exceptions, $event['recur_exception'])))
1562 1560
 				{
1563 1561
 					if (isset($event['cal_participants']))
1564 1562
 					{
@@ -1569,7 +1567,7 @@  discard block
 block discarded – undo
1569 1567
 						// use old default
1570 1568
 						$participants = $old_participants;
1571 1569
 					}
1572
-					foreach($deleted_exceptions as $id => $deleted_exception)
1570
+					foreach ($deleted_exceptions as $id => $deleted_exception)
1573 1571
 					{
1574 1572
 						// rebuild participants for the re-inserted recurrence
1575 1573
 						$this->recurrence($cal_id, $deleted_exception, $deleted_exception + $old_duration, $participants);
@@ -1577,24 +1575,24 @@  discard block
 block discarded – undo
1577 1575
 				}
1578 1576
 
1579 1577
 				// check if recurrence enddate was adjusted
1580
-				if(isset($event['recur_enddate']))
1578
+				if (isset($event['recur_enddate']))
1581 1579
 				{
1582 1580
 					// recurrences need to be truncated
1583
-					if((int)$event['recur_enddate'] > 0 &&
1581
+					if ((int)$event['recur_enddate'] > 0 &&
1584 1582
 						((int)$old_repeats['recur_enddate'] == 0 || (int)$old_repeats['recur_enddate'] > (int)$event['recur_enddate'])
1585 1583
 					)
1586 1584
 					{
1587
-						$this->db->delete($this->user_table,array('cal_id' => $cal_id,'cal_recur_date >= '.($event['recur_enddate'] + 1*DAY_s)),__LINE__,__FILE__,'calendar');
1588
-						$this->db->delete($this->dates_table,array('cal_id' => $cal_id,'cal_start >= '.($event['recur_enddate'] + 1*DAY_s)),__LINE__,__FILE__,'calendar');
1585
+						$this->db->delete($this->user_table, array('cal_id' => $cal_id, 'cal_recur_date >= '.($event['recur_enddate'] + 1 * DAY_s)), __LINE__, __FILE__, 'calendar');
1586
+						$this->db->delete($this->dates_table, array('cal_id' => $cal_id, 'cal_start >= '.($event['recur_enddate'] + 1 * DAY_s)), __LINE__, __FILE__, 'calendar');
1589 1587
 					}
1590 1588
 
1591 1589
 					// recurrences need to be expanded
1592
-					if(((int)$event['recur_enddate'] == 0 && (int)$old_repeats['recur_enddate'] > 0)
1590
+					if (((int)$event['recur_enddate'] == 0 && (int)$old_repeats['recur_enddate'] > 0)
1593 1591
 						|| ((int)$event['recur_enddate'] > 0 && (int)$old_repeats['recur_enddate'] > 0 && (int)$old_repeats['recur_enddate'] < (int)$event['recur_enddate'])
1594 1592
 					)
1595 1593
 					{
1596 1594
 						$set_recurrences = true;
1597
-						$set_recurrences_start = ($old_repeats['recur_enddate'] + 1*DAY_s);
1595
+						$set_recurrences_start = ($old_repeats['recur_enddate'] + 1 * DAY_s);
1598 1596
 					}
1599 1597
 					//error_log(__METHOD__."() event[recur_enddate]=$event[recur_enddate], old_repeats[recur_enddate]=$old_repeats[recur_enddate] --> set_recurrences=".array2string($set_recurrences).", set_recurrences_start=$set_recurrences_start");
1600 1598
 				}
@@ -1603,9 +1601,9 @@  discard block
 block discarded – undo
1603 1601
 				if (count($event['recur_exception']))
1604 1602
 				{
1605 1603
 					// added and existing exceptions: delete the execeptions from the user table, it could be the first time
1606
-					$this->db->delete($this->user_table,array('cal_id' => $cal_id,'cal_recur_date' => $event['recur_exception']),__LINE__,__FILE__,'calendar');
1604
+					$this->db->delete($this->user_table, array('cal_id' => $cal_id, 'cal_recur_date' => $event['recur_exception']), __LINE__, __FILE__, 'calendar');
1607 1605
 					// update recur_exception flag based on current exceptions
1608
-					$this->db->update($this->dates_table, 'recur_exception='.$this->db->expression($this->dates_table,array(
1606
+					$this->db->update($this->dates_table, 'recur_exception='.$this->db->expression($this->dates_table, array(
1609 1607
 						'cal_start' => $event['recur_exception'],
1610 1608
 					)), array(
1611 1609
 						'cal_id' => $cal_id,
@@ -1614,27 +1612,27 @@  discard block
 block discarded – undo
1614 1612
 			}
1615 1613
 
1616 1614
 			// write the repeats table
1617
-			unset($event[0]);	// unset the 'etag=etag+1', as it's not in the repeats table
1618
-			$this->db->insert($this->repeats_table,$event,array('cal_id' => $cal_id),__LINE__,__FILE__,'calendar');
1615
+			unset($event[0]); // unset the 'etag=etag+1', as it's not in the repeats table
1616
+			$this->db->insert($this->repeats_table, $event, array('cal_id' => $cal_id), __LINE__, __FILE__, 'calendar');
1619 1617
 		}
1620 1618
 		// update start- and endtime if present in the event-array, evtl. we need to move all recurrences
1621 1619
 		if (isset($event['cal_start']) && isset($event['cal_end']))
1622 1620
 		{
1623
-			$this->move($cal_id,$event['cal_start'],$event['cal_end'],!$cal_id ? false : $change_since, $old_min, $old_min +  $old_duration);
1621
+			$this->move($cal_id, $event['cal_start'], $event['cal_end'], !$cal_id ? false : $change_since, $old_min, $old_min + $old_duration);
1624 1622
 		}
1625 1623
 		// update participants if present in the event-array
1626 1624
 		if (isset($event['cal_participants']))
1627 1625
 		{
1628
-			$this->participants($cal_id,$event['cal_participants'],!$cal_id ? false : $change_since);
1626
+			$this->participants($cal_id, $event['cal_participants'], !$cal_id ? false : $change_since);
1629 1627
 		}
1630 1628
 		// Custom fields
1631 1629
 		Api\Storage\Customfields::handle_files('calendar', $cal_id, $event);
1632 1630
 
1633
-		foreach($event as $name => $value)
1631
+		foreach ($event as $name => $value)
1634 1632
 		{
1635 1633
 			if ($name[0] == '#')
1636 1634
 			{
1637
-				if (is_array($value) && array_key_exists('id',$value))
1635
+				if (is_array($value) && array_key_exists('id', $value))
1638 1636
 				{
1639 1637
 					//error_log(__METHOD__.__LINE__."$name => ".array2string($value).function_backtrace());
1640 1638
 					$value = $value['id'];
@@ -1642,19 +1640,19 @@  discard block
 block discarded – undo
1642 1640
 				}
1643 1641
 				if ($value)
1644 1642
 				{
1645
-					$this->db->insert($this->extra_table,array(
1646
-						'cal_extra_value'	=> is_array($value) ? implode(',',$value) : $value,
1647
-					),array(
1643
+					$this->db->insert($this->extra_table, array(
1644
+						'cal_extra_value'	=> is_array($value) ? implode(',', $value) : $value,
1645
+					), array(
1648 1646
 						'cal_id'			=> $cal_id,
1649
-						'cal_extra_name'	=> substr($name,1),
1650
-					),__LINE__,__FILE__,'calendar');
1647
+						'cal_extra_name'	=> substr($name, 1),
1648
+					), __LINE__, __FILE__, 'calendar');
1651 1649
 				}
1652 1650
 				else
1653 1651
 				{
1654
-					$this->db->delete($this->extra_table,array(
1652
+					$this->db->delete($this->extra_table, array(
1655 1653
 						'cal_id'			=> $cal_id,
1656
-						'cal_extra_name'	=> substr($name,1),
1657
-					),__LINE__,__FILE__,'calendar');
1654
+						'cal_extra_name'	=> substr($name, 1),
1655
+					), __LINE__, __FILE__, 'calendar');
1658 1656
 				}
1659 1657
 			}
1660 1658
 		}
@@ -1665,9 +1663,9 @@  discard block
 block discarded – undo
1665 1663
 			{
1666 1664
 				if ($alarm['id'] && strpos($alarm['id'], 'cal:'.$cal_id.':') !== 0)
1667 1665
 				{
1668
-					unset($alarm['id']);	// unset the temporary id to add the alarm
1666
+					unset($alarm['id']); // unset the temporary id to add the alarm
1669 1667
 				}
1670
-				if(!isset($alarm['offset']))
1668
+				if (!isset($alarm['offset']))
1671 1669
 				{
1672 1670
 					$alarm['offset'] = $event['cal_start'] - $alarm['time'];
1673 1671
 				}
@@ -1678,14 +1676,14 @@  discard block
 block discarded – undo
1678 1676
 
1679 1677
 				if ($alarm['time'] < time() && !self::shift_alarm($event, $alarm))
1680 1678
 				{
1681
-					continue;	// pgoerzen: don't add alarm in the past
1679
+					continue; // pgoerzen: don't add alarm in the past
1682 1680
 				}
1683
-				$this->save_alarm($cal_id, $alarm, false);	// false: not update modified, we do it anyway
1681
+				$this->save_alarm($cal_id, $alarm, false); // false: not update modified, we do it anyway
1684 1682
 			}
1685 1683
 		}
1686 1684
 		if (is_null($etag))
1687 1685
 		{
1688
-			$etag = $this->db->select($this->cal_table,'cal_etag',array('cal_id' => $cal_id),__LINE__,__FILE__,false,'','calendar')->fetchColumn();
1686
+			$etag = $this->db->select($this->cal_table, 'cal_etag', array('cal_id' => $cal_id), __LINE__, __FILE__, false, '', 'calendar')->fetchColumn();
1689 1687
 		}
1690 1688
 
1691 1689
 		// if event is an exception: update modified of master, to force etag, ctag and sync-token change
@@ -1705,7 +1703,7 @@  discard block
 block discarded – undo
1705 1703
 	 *	are dealing with, default is now.
1706 1704
 	 * @return boolean true if alarm could be shifted, false if not
1707 1705
 	 */
1708
-	public static function shift_alarm(array $_event, array &$alarm, $timestamp=null)
1706
+	public static function shift_alarm(array $_event, array &$alarm, $timestamp = null)
1709 1707
 	{
1710 1708
 		if ($_event['recur_type'] == MCAL_RECUR_NONE)
1711 1709
 		{
@@ -1716,7 +1714,7 @@  discard block
 block discarded – undo
1716 1714
 		$rrule = calendar_rrule::event2rrule($event, false);
1717 1715
 		foreach ($rrule as $time)
1718 1716
 		{
1719
-			if ($start < ($ts = Api\DateTime::to($time,'server')))
1717
+			if ($start < ($ts = Api\DateTime::to($time, 'server')))
1720 1718
 			{
1721 1719
 				$alarm['time'] = $ts - $alarm['offset'];
1722 1720
 				return true;
@@ -1737,34 +1735,34 @@  discard block
 block discarded – undo
1737 1735
 	 * @todo Recalculate recurrences, if timezone changes
1738 1736
 	 * @return int|boolean number of moved recurrences or false on error
1739 1737
 	 */
1740
-	function move($cal_id,$start,$end,$change_since=0,$old_start=0,$old_end=0)
1738
+	function move($cal_id, $start, $end, $change_since = 0, $old_start = 0, $old_end = 0)
1741 1739
 	{
1742 1740
 		//echo "<p>socal::move($cal_id,$start,$end,$change_since,$old_start,$old_end)</p>\n";
1743 1741
 
1744
-		if (!(int) $cal_id) return false;
1742
+		if (!(int)$cal_id) return false;
1745 1743
 
1746 1744
 		if (!$old_start)
1747 1745
 		{
1748
-			if ($change_since !== false) $row = $this->db->select($this->dates_table,'MIN(cal_start) AS cal_start,MIN(cal_end) AS cal_end',
1749
-				array('cal_id'=>$cal_id),__LINE__,__FILE__,false,'','calendar')->fetch();
1746
+			if ($change_since !== false) $row = $this->db->select($this->dates_table, 'MIN(cal_start) AS cal_start,MIN(cal_end) AS cal_end',
1747
+				array('cal_id'=>$cal_id), __LINE__, __FILE__, false, '', 'calendar')->fetch();
1750 1748
 			// if no recurrence found, create one with the new dates
1751 1749
 			if ($change_since === false || !$row || !$row['cal_start'] || !$row['cal_end'])
1752 1750
 			{
1753
-				$this->db->insert($this->dates_table,array(
1751
+				$this->db->insert($this->dates_table, array(
1754 1752
 					'cal_id'    => $cal_id,
1755 1753
 					'cal_start' => $start,
1756 1754
 					'cal_end'   => $end,
1757
-				),false,__LINE__,__FILE__,'calendar');
1755
+				), false, __LINE__, __FILE__, 'calendar');
1758 1756
 
1759 1757
 				return 1;
1760 1758
 			}
1761
-			$move_start = (int) ($start-$row['cal_start']);
1762
-			$move_end   = (int) ($end-$row['cal_end']);
1759
+			$move_start = (int)($start - $row['cal_start']);
1760
+			$move_end   = (int)($end - $row['cal_end']);
1763 1761
 		}
1764 1762
 		else
1765 1763
 		{
1766
-			$move_start = (int) ($start-$old_start);
1767
-			$move_end   = (int) ($end-$old_end);
1764
+			$move_start = (int)($start - $old_start);
1765
+			$move_end   = (int)($end - $old_end);
1768 1766
 		}
1769 1767
 		$where = 'cal_id='.(int)$cal_id;
1770 1768
 
@@ -1772,13 +1770,13 @@  discard block
 block discarded – undo
1772 1770
 		{
1773 1771
 			// move the recur-date of the participants
1774 1772
 			$this->db->query("UPDATE $this->user_table SET cal_recur_date=cal_recur_date+$move_start WHERE $where AND cal_recur_date ".
1775
-				((int)$change_since ? '>= '.(int)$change_since : '!= 0'),__LINE__,__FILE__);
1773
+				((int)$change_since ? '>= '.(int)$change_since : '!= 0'), __LINE__, __FILE__);
1776 1774
 		}
1777 1775
 		if ($move_start || $move_end)
1778 1776
 		{
1779 1777
 			// move the event and it's recurrences
1780 1778
 			$this->db->query("UPDATE $this->dates_table SET cal_start=cal_start+$move_start,cal_end=cal_end+$move_end WHERE $where".
1781
-				((int) $change_since ? ' AND cal_start >= '.(int) $change_since : ''),__LINE__,__FILE__);
1779
+				((int)$change_since ? ' AND cal_start >= '.(int)$change_since : ''), __LINE__, __FILE__);
1782 1780
 		}
1783 1781
 		return $this->db->affected_rows();
1784 1782
 	}
@@ -1797,8 +1795,7 @@  discard block
 block discarded – undo
1797 1795
 		}
1798 1796
 		if (is_array($attendee))
1799 1797
 		{
1800
-			$email = !empty($attendee['email']) ? $user_attendee['email'] :
1801
-				(strtolower(substr($attendee['url'], 0, 7)) == 'mailto:' ? substr($user_attendee['url'], 7) : $attendee['url']);
1798
+			$email = !empty($attendee['email']) ? $user_attendee['email'] : (strtolower(substr($attendee['url'], 0, 7)) == 'mailto:' ? substr($user_attendee['url'], 7) : $attendee['url']);
1802 1799
 			$attendee = !empty($attendee['cn']) ? $attendee['cn'].' <'.$email.'>' : $email;
1803 1800
 		}
1804 1801
 		return $attendee;
@@ -1811,11 +1808,11 @@  discard block
 block discarded – undo
1811 1808
 	 * @param string|array $attendee attendee information: email, json or array with attr cn and url
1812 1809
 	 * @return string|int combined id
1813 1810
 	 */
1814
-	static function combine_user($user_type, $user_id, $attendee=null)
1811
+	static function combine_user($user_type, $user_id, $attendee = null)
1815 1812
 	{
1816 1813
 		if (!$user_type || $user_type == 'u')
1817 1814
 		{
1818
-			return (int) $user_id;
1815
+			return (int)$user_id;
1819 1816
 		}
1820 1817
 		if ($user_type == 'e' && $attendee)
1821 1818
 		{
@@ -1835,12 +1832,12 @@  discard block
 block discarded – undo
1835 1832
 	 * @param string|int &$user_id id
1836 1833
 	 * @param boolean $md5_email =false md5 hash user_id for email / user_type=="e"
1837 1834
 	 */
1838
-	static function split_user($uid, &$user_type, &$user_id, $md5_email=false)
1835
+	static function split_user($uid, &$user_type, &$user_id, $md5_email = false)
1839 1836
 	{
1840 1837
 		if (is_numeric($uid))
1841 1838
 		{
1842 1839
 			$user_type = 'u';
1843
-			$user_id = (int) $uid;
1840
+			$user_id = (int)$uid;
1844 1841
 		}
1845 1842
 		// create md5 hash from lowercased and trimed raw email ("[email protected]", not "Ralf Becker <[email protected]>")
1846 1843
 		elseif ($md5_email && $uid[0] == 'e')
@@ -1854,7 +1851,7 @@  discard block
 block discarded – undo
1854 1851
 		else
1855 1852
 		{
1856 1853
 			$user_type = $uid[0];
1857
-			$user_id = substr($uid,1);
1854
+			$user_id = substr($uid, 1);
1858 1855
 		}
1859 1856
 	}
1860 1857
 
@@ -1866,7 +1863,7 @@  discard block
 block discarded – undo
1866 1863
 	 * @param string $role ='REQ-PARTICIPANT'
1867 1864
 	 * @return string
1868 1865
 	 */
1869
-	static function combine_status($status,$quantity=1,$role='REQ-PARTICIPANT')
1866
+	static function combine_status($status, $quantity = 1, $role = 'REQ-PARTICIPANT')
1870 1867
 	{
1871 1868
 		if ((int)$quantity > 1) $status .= (int)$quantity;
1872 1869
 		if ($role != 'REQ-PARTICIPANT') $status .= $role;
@@ -1882,13 +1879,13 @@  discard block
 block discarded – undo
1882 1879
 	 * @param string &$role=null only O: role
1883 1880
 	 * @return string status U, T, A or R, same as $status parameter on return
1884 1881
 	 */
1885
-	static function split_status(&$status,&$quantity=null,&$role=null)
1882
+	static function split_status(&$status, &$quantity = null, &$role = null)
1886 1883
 	{
1887 1884
 		$quantity = 1;
1888 1885
 		$role = 'REQ-PARTICIPANT';
1889 1886
 		//error_log(__METHOD__.__LINE__.array2string($status));
1890 1887
 		$matches = null;
1891
-		if (is_string($status) && strlen($status) > 1 && preg_match('/^.([0-9]*)(.*)$/',$status,$matches))
1888
+		if (is_string($status) && strlen($status) > 1 && preg_match('/^.([0-9]*)(.*)$/', $status, $matches))
1892 1889
 		{
1893 1890
 			if ((int)$matches[1] > 0) $quantity = (int)$matches[1];
1894 1891
 			if ($matches[2]) $role = $matches[2];
@@ -1915,14 +1912,14 @@  discard block
 block discarded – undo
1915 1912
 	 *		true = only add participants if needed, no participant will be deleted (participants to check/add required in $participants)
1916 1913
 	 * @return int|boolean number of updated recurrences or false on error
1917 1914
 	 */
1918
-	function participants($cal_id,$participants,$change_since=0,$add_only=false)
1915
+	function participants($cal_id, $participants, $change_since = 0, $add_only = false)
1919 1916
 	{
1920 1917
 		//error_log(__METHOD__."($cal_id,".array2string($participants).",$change_since,$add_only");
1921 1918
 
1922 1919
 		$recurrences = array();
1923 1920
 
1924 1921
 		// remove group-invitations, they are NOT stored in the db
1925
-		foreach($participants as $uid => $status)
1922
+		foreach ($participants as $uid => $status)
1926 1923
 		{
1927 1924
 			if ($status[0] == 'G')
1928 1925
 			{
@@ -1931,7 +1928,7 @@  discard block
 block discarded – undo
1931 1928
 		}
1932 1929
 		$where = array('cal_id' => $cal_id);
1933 1930
 
1934
-		if ((int) $change_since)
1931
+		if ((int)$change_since)
1935 1932
 		{
1936 1933
 			$where[] = '(cal_recur_date=0 OR cal_recur_date >= '.(int)$change_since.')';
1937 1934
 		}
@@ -1939,31 +1936,31 @@  discard block
 block discarded – undo
1939 1936
 		if ($change_since !== false)
1940 1937
 		{
1941 1938
 			// find all existing recurrences
1942
-			foreach($this->db->select($this->user_table,'DISTINCT cal_recur_date',$where,__LINE__,__FILE__,false,'','calendar') as $row)
1939
+			foreach ($this->db->select($this->user_table, 'DISTINCT cal_recur_date', $where, __LINE__, __FILE__, false, '', 'calendar') as $row)
1943 1940
 			{
1944 1941
 				$recurrences[] = $row['cal_recur_date'];
1945 1942
 			}
1946 1943
 
1947 1944
 			// update existing entries
1948
-			$existing_entries = $this->db->select($this->user_table,'*',$where,__LINE__,__FILE__,false,'ORDER BY cal_recur_date DESC','calendar');
1945
+			$existing_entries = $this->db->select($this->user_table, '*', $where, __LINE__, __FILE__, false, 'ORDER BY cal_recur_date DESC', 'calendar');
1949 1946
 
1950 1947
 			// create a full list of participants which already exist in the db
1951 1948
 			// with status, quantity and role of the earliest recurence
1952 1949
 			$old_participants = array();
1953
-			foreach($existing_entries as $row)
1950
+			foreach ($existing_entries as $row)
1954 1951
 			{
1955 1952
 				$uid = self::combine_user($row['cal_user_type'], $row['cal_user_id'], $row['cal_user_attendee']);
1956 1953
 				if ($row['cal_recur_date'] || !isset($old_participants[$uid]))
1957 1954
 				{
1958
-					$old_participants[$uid] = self::combine_status($row['cal_status'],$row['cal_quantity'],$row['cal_role']);
1955
+					$old_participants[$uid] = self::combine_status($row['cal_status'], $row['cal_quantity'], $row['cal_role']);
1959 1956
 				}
1960 1957
 			}
1961 1958
 
1962 1959
 			// tag participants which should be deleted
1963
-			if($add_only === false)
1960
+			if ($add_only === false)
1964 1961
 			{
1965 1962
 				$deleted = array();
1966
-				foreach($existing_entries as $row)
1963
+				foreach ($existing_entries as $row)
1967 1964
 				{
1968 1965
 					$uid = self::combine_user($row['cal_user_type'], $row['cal_user_id'], $row['cal_user_attendee']);
1969 1966
 					// delete not longer set participants
@@ -1976,7 +1973,7 @@  discard block
 block discarded – undo
1976 1973
 
1977 1974
 			// only keep added OR status (incl. quantity!) changed participants for further steps
1978 1975
 			// we do not touch unchanged (!) existing ones
1979
-			foreach($participants as $uid => $status)
1976
+			foreach ($participants as $uid => $status)
1980 1977
 			{
1981 1978
 				if ($old_participants[$uid] === $status)
1982 1979
 				{
@@ -1988,46 +1985,46 @@  discard block
 block discarded – undo
1988 1985
 			if ($add_only === false && count($deleted))
1989 1986
 			{
1990 1987
 				$to_or = array();
1991
-				$table_def = $this->db->get_table_definitions('calendar',$this->user_table);
1992
-				foreach($deleted as $type => $ids)
1988
+				$table_def = $this->db->get_table_definitions('calendar', $this->user_table);
1989
+				foreach ($deleted as $type => $ids)
1993 1990
 				{
1994
-					$to_or[] = $this->db->expression($table_def,array(
1991
+					$to_or[] = $this->db->expression($table_def, array(
1995 1992
 						'cal_user_type' => $type,
1996 1993
 						'cal_user_id'   => $ids,
1997 1994
 					));
1998 1995
 				}
1999
-				$where[] = '('.implode(' OR ',$to_or).')';
2000
-				$where[] = "cal_status!='E'";	// do NOT delete exception marker
2001
-				$this->db->update($this->user_table,array('cal_status'=>'X'),$where,__LINE__,__FILE__,'calendar');
1996
+				$where[] = '('.implode(' OR ', $to_or).')';
1997
+				$where[] = "cal_status!='E'"; // do NOT delete exception marker
1998
+				$this->db->update($this->user_table, array('cal_status'=>'X'), $where, __LINE__, __FILE__, 'calendar');
2002 1999
 			}
2003 2000
 		}
2004 2001
 
2005 2002
 		if (count($participants))	// participants which need to be added
2006 2003
 		{
2007
-			if (!count($recurrences)) $recurrences[] = 0;   // insert the default recurrence
2004
+			if (!count($recurrences)) $recurrences[] = 0; // insert the default recurrence
2008 2005
 
2009 2006
 			$delete_deleted = array();
2010 2007
 
2011 2008
 			// update participants
2012
-			foreach($participants as $uid => $status)
2009
+			foreach ($participants as $uid => $status)
2013 2010
 			{
2014 2011
 				$type = $id = $quantity = $role = null;
2015 2012
 				self::split_user($uid, $type, $id, true);
2016
-				self::split_status($status,$quantity,$role);
2013
+				self::split_status($status, $quantity, $role);
2017 2014
 				$set = array(
2018 2015
 					'cal_status'	  => $status,
2019 2016
 					'cal_quantity'	  => $quantity,
2020 2017
 					'cal_role'        => $role,
2021 2018
 					'cal_user_attendee' => $type == 'e' ? substr($uid, 1) : null,
2022 2019
 				);
2023
-				foreach($recurrences as $recur_date)
2020
+				foreach ($recurrences as $recur_date)
2024 2021
 				{
2025
-					$this->db->insert($this->user_table,$set,array(
2022
+					$this->db->insert($this->user_table, $set, array(
2026 2023
 						'cal_id'	      => $cal_id,
2027 2024
 						'cal_recur_date'  => $recur_date,
2028 2025
 						'cal_user_type'   => $type,
2029 2026
 						'cal_user_id' 	  => $id,
2030
-					),__LINE__,__FILE__,'calendar');
2027
+					), __LINE__, __FILE__, 'calendar');
2031 2028
 				}
2032 2029
 				// for new or changed group-invitations, remove previously deleted members, so they show up again
2033 2030
 				if ($uid < 0)
@@ -2037,13 +2034,13 @@  discard block
 block discarded – undo
2037 2034
 			}
2038 2035
 			if ($delete_deleted)
2039 2036
 			{
2040
-				$this->db->delete($this->user_table, $where=array(
2037
+				$this->db->delete($this->user_table, $where = array(
2041 2038
 					'cal_id' => $cal_id,
2042 2039
 					'cal_recur_date' => $recurrences,
2043 2040
 					'cal_user_type' => 'u',
2044 2041
 					'cal_user_id' => array_unique($delete_deleted),
2045 2042
 					'cal_status' => 'X',
2046
-				),__LINE__,__FILE__,'calendar');
2043
+				), __LINE__, __FILE__, 'calendar');
2047 2044
 				//error_log(__METHOD__."($cal_id, ".array2string($participants).", since=$change_since, add_only=$add_only) db->delete('$this->user_table', ".array2string($where).") affected ".$this->db->affected_rows().' rows');
2048 2045
 			}
2049 2046
 		}
@@ -2062,7 +2059,7 @@  discard block
 block discarded – undo
2062 2059
 	 * @param string $attendee =null extra attendee information to set for all types (incl. accounts!)
2063 2060
 	 * @return int number of changed recurrences
2064 2061
 	 */
2065
-	function set_status($cal_id,$user_type,$user_id,$status,$recur_date=0,$role=null,$attendee=null)
2062
+	function set_status($cal_id, $user_type, $user_id, $status, $recur_date = 0, $role = null, $attendee = null)
2066 2063
 	{
2067 2064
 		static $status_code_short = array(
2068 2065
 			REJECTED 	=> 'R',
@@ -2087,7 +2084,7 @@  discard block
 block discarded – undo
2087 2084
 			'cal_user_type'	=> $user_type,
2088 2085
 			'cal_user_id'   => $user_id_md5,
2089 2086
 		);
2090
-		if ((int) $recur_date)
2087
+		if ((int)$recur_date)
2091 2088
 		{
2092 2089
 			$where['cal_recur_date'] = $recur_date;
2093 2090
 		}
@@ -2098,7 +2095,7 @@  discard block
 block discarded – undo
2098 2095
 
2099 2096
 		if ($status == 'G')		// remove group invitations, as we dont store them in the db
2100 2097
 		{
2101
-			$this->db->delete($this->user_table,$where,__LINE__,__FILE__,'calendar');
2098
+			$this->db->delete($this->user_table, $where, __LINE__, __FILE__, 'calendar');
2102 2099
 			$ret = $this->db->affected_rows();
2103 2100
 		}
2104 2101
 		else
@@ -2106,7 +2103,7 @@  discard block
 block discarded – undo
2106 2103
 			$set = array('cal_status' => $status);
2107 2104
 			if ($user_type == 'e' || $attendee) $set['cal_user_attendee'] = $attendee ? $attendee : $user_id;
2108 2105
 			if (!is_null($role) && $role != 'REQ-PARTICIPANT') $set['cal_role'] = $role;
2109
-			$this->db->insert($this->user_table,$set,$where,__LINE__,__FILE__,'calendar');
2106
+			$this->db->insert($this->user_table, $set, $where, __LINE__, __FILE__, 'calendar');
2110 2107
 			// for new or changed group-invitations, remove previously deleted members, so they show up again
2111 2108
 			if (($ret = $this->db->affected_rows()) && $user_type == 'u' && $user_id < 0)
2112 2109
 			{
@@ -2119,7 +2116,7 @@  discard block
 block discarded – undo
2119 2116
 		// update modified and modifier in main table
2120 2117
 		if ($ret)
2121 2118
 		{
2122
-			$this->updateModified($cal_id, true);	// true = update series master too
2119
+			$this->updateModified($cal_id, true); // true = update series master too
2123 2120
 		}
2124 2121
 		//error_log(__METHOD__."($cal_id,$user_type,$user_id,$status,$recur_date) = $ret");
2125 2122
 		return $ret;
@@ -2134,7 +2131,7 @@  discard block
 block discarded – undo
2134 2131
 	 * @param array $participants uid => status pairs
2135 2132
 	 * @param boolean $exception =null true or false to set recure_exception flag, null leave it unchanged (new are by default no exception)
2136 2133
 	 */
2137
-	function recurrence($cal_id,$start,$end,$participants,$exception=null)
2134
+	function recurrence($cal_id, $start, $end, $participants, $exception = null)
2138 2135
 	{
2139 2136
 		//error_log(__METHOD__."($cal_id, $start, $end, ".array2string($participants).", ".array2string($exception));
2140 2137
 		$update = array('cal_end' => $end);
@@ -2143,7 +2140,7 @@  discard block
 block discarded – undo
2143 2140
 		$this->db->insert($this->dates_table, $update, array(
2144 2141
 			'cal_id' => $cal_id,
2145 2142
 			'cal_start'  => $start,
2146
-		),__LINE__,__FILE__,'calendar');
2143
+		), __LINE__, __FILE__, 'calendar');
2147 2144
 
2148 2145
 		if (!is_array($participants))
2149 2146
 		{
@@ -2151,26 +2148,26 @@  discard block
 block discarded – undo
2151 2148
 		}
2152 2149
 		if ($exception !== true)
2153 2150
 		{
2154
-			foreach($participants as $uid => $status)
2151
+			foreach ($participants as $uid => $status)
2155 2152
 			{
2156
-				if ($status == 'G') continue;	// dont save group-invitations
2153
+				if ($status == 'G') continue; // dont save group-invitations
2157 2154
 
2158 2155
 				$type = '';
2159 2156
 				$id = null;
2160 2157
 				self::split_user($uid, $type, $id, true);
2161 2158
 				$quantity = $role = null;
2162
-				self::split_status($status,$quantity,$role);
2163
-				$this->db->insert($this->user_table,array(
2159
+				self::split_status($status, $quantity, $role);
2160
+				$this->db->insert($this->user_table, array(
2164 2161
 					'cal_status'	=> $status,
2165 2162
 					'cal_quantity'	=> $quantity,
2166 2163
 					'cal_role'		=> $role,
2167 2164
 					'cal_user_attendee' => $type == 'e' ? substr($uid, 1) : null,
2168
-				),array(
2165
+				), array(
2169 2166
 					'cal_id'		 => $cal_id,
2170 2167
 					'cal_recur_date' => $start,
2171 2168
 					'cal_user_type'  => $type,
2172 2169
 					'cal_user_id' 	 => $id,
2173
-				),__LINE__,__FILE__,'calendar');
2170
+				), __LINE__, __FILE__, 'calendar');
2174 2171
 			}
2175 2172
 		}
2176 2173
 	}
@@ -2184,7 +2181,7 @@  discard block
 block discarded – undo
2184 2181
 	function unfinished_recuring($time)
2185 2182
 	{
2186 2183
 		$ids = array();
2187
-		foreach($rs=$this->db->select($this->repeats_table, "$this->repeats_table.cal_id,MAX(cal_start) AS cal_start",
2184
+		foreach ($rs = $this->db->select($this->repeats_table, "$this->repeats_table.cal_id,MAX(cal_start) AS cal_start",
2188 2185
 			'(range_end IS NULL OR range_end > '.(int)$time.')',
2189 2186
 			__LINE__, __FILE__, false, "GROUP BY $this->repeats_table.cal_id,range_end", 'calendar', 0,
2190 2187
 			" JOIN $this->cal_table ON $this->repeats_table.cal_id=$this->cal_table.cal_id".
@@ -2210,9 +2207,9 @@  discard block
 block discarded – undo
2210 2207
 		// update timestamp of series master, updates own timestamp too, which does not hurt ;-)
2211 2208
 		$this->updateModified($cal_id, true);
2212 2209
 
2213
-		foreach($this->all_tables as $table)
2210
+		foreach ($this->all_tables as $table)
2214 2211
 		{
2215
-			$this->db->delete($table,array('cal_id'=>$cal_id),__LINE__,__FILE__,'calendar');
2212
+			$this->db->delete($table, array('cal_id'=>$cal_id), __LINE__, __FILE__, 'calendar');
2216 2213
 		}
2217 2214
 	}
2218 2215
 
@@ -2228,19 +2225,19 @@  discard block
 block discarded – undo
2228 2225
 	function purge($date)
2229 2226
 	{
2230 2227
 		// with new range_end we simple delete all with range_end < $date (range_end NULL is never returned)
2231
-		foreach($this->db->select($this->cal_table, 'cal_id', 'range_end < '.(int)$date, __LINE__, __FILE__, false, '', 'calendar') as $row)
2228
+		foreach ($this->db->select($this->cal_table, 'cal_id', 'range_end < '.(int)$date, __LINE__, __FILE__, false, '', 'calendar') as $row)
2232 2229
 		{
2233 2230
 			//echo __METHOD__." About to delete".$row['cal_id']."\r\n";
2234
-			foreach($this->all_tables as $table)
2231
+			foreach ($this->all_tables as $table)
2235 2232
 			{
2236 2233
 				$this->db->delete($table, array('cal_id'=>$row['cal_id']), __LINE__, __FILE__, 'calendar');
2237 2234
 			}
2238 2235
 			// handle sync
2239
-			$this->db->update('egw_api_content_history',array(
2236
+			$this->db->update('egw_api_content_history', array(
2240 2237
 				'sync_deleted' => time(),
2241
-			),array(
2238
+			), array(
2242 2239
 				'sync_appname' => 'calendar',
2243
-				'sync_contentid' => $row['cal_id'],	// sync_contentid is varchar(60)!
2240
+				'sync_contentid' => $row['cal_id'], // sync_contentid is varchar(60)!
2244 2241
 			), __LINE__, __FILE__, 'calendar');
2245 2242
 			// handle links
2246 2243
 			Link::unlink('', 'calendar', $row['cal_id']);
@@ -2263,23 +2260,23 @@  discard block
 block discarded – undo
2263 2260
 	 * @param boolean $update_cache =null true: re-read given $cal_id, false: delete given $cal_id
2264 2261
 	 * @return array of (cal_id => array of) alarms with alarm-id as key
2265 2262
 	 */
2266
-	function read_alarms($cal_id, $update_cache=null)
2263
+	function read_alarms($cal_id, $update_cache = null)
2267 2264
 	{
2268 2265
 		if (!isset(self::$alarm_cache) && is_array($cal_id))
2269 2266
 		{
2270 2267
 			self::$alarm_cache = array();
2271 2268
 			if (($jobs = $this->async->read('cal:%')))
2272 2269
 			{
2273
-				foreach($jobs as $id => $job)
2270
+				foreach ($jobs as $id => $job)
2274 2271
 				{
2275
-					$alarm         = $job['data'];	// text, enabled
2272
+					$alarm         = $job['data']; // text, enabled
2276 2273
 					$alarm['id']   = $id;
2277 2274
 					$alarm['time'] = $job['next'];
2278 2275
 
2279 2276
 					self::$alarm_cache[$alarm['cal_id']][$id] = $alarm;
2280 2277
 				}
2281 2278
 			}
2282
-			unset($update_cache);	// just done
2279
+			unset($update_cache); // just done
2283 2280
 		}
2284 2281
 		$alarms = array();
2285 2282
 
@@ -2287,13 +2284,13 @@  discard block
 block discarded – undo
2287 2284
 		{
2288 2285
 			if (isset($update_cache))
2289 2286
 			{
2290
-				foreach((array)$cal_id as $id)
2287
+				foreach ((array)$cal_id as $id)
2291 2288
 				{
2292 2289
 					if ($update_cache === false)
2293 2290
 					{
2294 2291
 						unset(self::$alarm_cache[$cal_id]);
2295 2292
 					}
2296
-					elseif($update_cache === true)
2293
+					elseif ($update_cache === true)
2297 2294
 					{
2298 2295
 						self::$alarm_cache[$cal_id] = $this->read_alarms_nocache($cal_id);
2299 2296
 					}
@@ -2305,7 +2302,7 @@  discard block
 block discarded – undo
2305 2302
 			}
2306 2303
 			else
2307 2304
 			{
2308
-				foreach($cal_id as $id)
2305
+				foreach ($cal_id as $id)
2309 2306
 				{
2310 2307
 					$alarms[$id] = (array)self::$alarm_cache[$id];
2311 2308
 				}
@@ -2320,9 +2317,9 @@  discard block
 block discarded – undo
2320 2317
 	{
2321 2318
 		if (($jobs = $this->async->read('cal:'.(int)$cal_id.':%')))
2322 2319
 		{
2323
-			foreach($jobs as $id => $job)
2320
+			foreach ($jobs as $id => $job)
2324 2321
 			{
2325
-				$alarm         = $job['data'];	// text, enabled
2322
+				$alarm         = $job['data']; // text, enabled
2326 2323
 				$alarm['id']   = $id;
2327 2324
 				$alarm['time'] = $job['next'];
2328 2325
 
@@ -2345,8 +2342,8 @@  discard block
 block discarded – undo
2345 2342
 		{
2346 2343
 			return False;
2347 2344
 		}
2348
-		list($alarm_id,$job) = each($jobs);
2349
-		$alarm         = $job['data'];	// text, enabled
2345
+		list($alarm_id, $job) = each($jobs);
2346
+		$alarm         = $job['data']; // text, enabled
2350 2347
 		$alarm['id']   = $alarm_id;
2351 2348
 		$alarm['time'] = $job['next'];
2352 2349
 
@@ -2362,12 +2359,12 @@  discard block
 block discarded – undo
2362 2359
 	 * @param boolean $update_modified =true call update modified, default true
2363 2360
 	 * @return string id of the alarm
2364 2361
 	 */
2365
-	function save_alarm($cal_id, $alarm, $update_modified=true)
2362
+	function save_alarm($cal_id, $alarm, $update_modified = true)
2366 2363
 	{
2367 2364
 		//error_log(__METHOD__."($cal_id, ".array2string($alarm).', '.array2string($update_modified).') '.function_backtrace());
2368 2365
 		if (!($id = $alarm['id']))
2369 2366
 		{
2370
-			$alarms = $this->read_alarms($cal_id);	// find a free alarm#
2367
+			$alarms = $this->read_alarms($cal_id); // find a free alarm#
2371 2368
 			$n = count($alarms);
2372 2369
 			do
2373 2370
 			{
@@ -2380,12 +2377,12 @@  discard block
 block discarded – undo
2380 2377
 		{
2381 2378
 			$this->async->cancel_timer($id);
2382 2379
 		}
2383
-		$alarm['cal_id'] = $cal_id;		// we need the back-reference
2380
+		$alarm['cal_id'] = $cal_id; // we need the back-reference
2384 2381
 		// add an alarm uid, if none is given
2385 2382
 		if (empty($alarm['uid']) && class_exists('Horde_Support_Uuid')) $alarm['uid'] = (string)new Horde_Support_Uuid;
2386 2383
 		//error_log(__METHOD__.__LINE__.' Save Alarm for CalID:'.$cal_id.'->'.array2string($alarm).'-->'.$id.'#'.function_backtrace());
2387 2384
 		// allways store job with the alarm owner as job-owner to get eg. the correct from address
2388
-		if (!$this->async->set_timer($alarm['time'],$id,'calendar.calendar_boupdate.send_alarm',$alarm,$alarm['owner']))
2385
+		if (!$this->async->set_timer($alarm['time'], $id, 'calendar.calendar_boupdate.send_alarm', $alarm, $alarm['owner']))
2389 2386
 		{
2390 2387
 			return False;
2391 2388
 		}
@@ -2412,7 +2409,7 @@  discard block
 block discarded – undo
2412 2409
 		//error_log(__METHOD__."($cal_id) ".function_backtrace());
2413 2410
 		if (($alarms = $this->read_alarms($cal_id)))
2414 2411
 		{
2415
-			foreach(array_keys($alarms) as $id)
2412
+			foreach (array_keys($alarms) as $id)
2416 2413
 			{
2417 2414
 				$this->async->cancel_timer($id);
2418 2415
 			}
@@ -2432,7 +2429,7 @@  discard block
 block discarded – undo
2432 2429
 	{
2433 2430
 		//error_log(__METHOD__."('$id') ".function_backtrace());
2434 2431
 		// update the modification information of the related event
2435
-		list(,$cal_id) = explode(':',$id);
2432
+		list(,$cal_id) = explode(':', $id);
2436 2433
 		if ($cal_id)
2437 2434
 		{
2438 2435
 			$this->updateModified($cal_id, true);
@@ -2451,7 +2448,7 @@  discard block
 block discarded – undo
2451 2448
 	 * @param array|int $old_user integer old user or array with keys 'account_id' and 'new_owner' as the deleteaccount hook uses it
2452 2449
 	 * @param int $new_user =null
2453 2450
 	 */
2454
-	function deleteaccount($old_user, $new_user=null)
2451
+	function deleteaccount($old_user, $new_user = null)
2455 2452
 	{
2456 2453
 		if (is_array($old_user))
2457 2454
 		{
@@ -2462,52 +2459,52 @@  discard block
 block discarded – undo
2462 2459
 		{
2463 2460
 			$user_type = '';
2464 2461
 			$user_id = null;
2465
-			self::split_user($old_user,$user_type,$user_id);
2462
+			self::split_user($old_user, $user_type, $user_id);
2466 2463
 
2467 2464
 			if ($user_type == 'u')	// only accounts can be owners of events
2468 2465
 			{
2469
-				foreach($this->db->select($this->cal_table,'cal_id',array('cal_owner' => $old_user),__LINE__,__FILE__,false,'','calendar') as $row)
2466
+				foreach ($this->db->select($this->cal_table, 'cal_id', array('cal_owner' => $old_user), __LINE__, __FILE__, false, '', 'calendar') as $row)
2470 2467
 				{
2471 2468
 					$this->delete($row['cal_id']);
2472 2469
 				}
2473 2470
 			}
2474
-			$this->db->delete($this->user_table,array(
2471
+			$this->db->delete($this->user_table, array(
2475 2472
 				'cal_user_type' => $user_type,
2476 2473
 				'cal_user_id'   => $user_id,
2477
-			),__LINE__,__FILE__,'calendar');
2474
+			), __LINE__, __FILE__, 'calendar');
2478 2475
 
2479 2476
 			// delete calendar entries without participants (can happen if the deleted user is the only participants, but not the owner)
2480
-			foreach($this->db->select($this->cal_table,"DISTINCT $this->cal_table.cal_id",'cal_user_id IS NULL',__LINE__,__FILE__,
2481
-				False,'','calendar',0,"LEFT JOIN $this->user_table ON $this->cal_table.cal_id=$this->user_table.cal_id") as $row)
2477
+			foreach ($this->db->select($this->cal_table, "DISTINCT $this->cal_table.cal_id", 'cal_user_id IS NULL', __LINE__, __FILE__,
2478
+				False, '', 'calendar', 0, "LEFT JOIN $this->user_table ON $this->cal_table.cal_id=$this->user_table.cal_id") as $row)
2482 2479
 			{
2483 2480
 				$this->delete($row['cal_id']);
2484 2481
 			}
2485 2482
 		}
2486 2483
 		else
2487 2484
 		{
2488
-			$this->db->update($this->cal_table,array('cal_owner' => $new_user),array('cal_owner' => $old_user),__LINE__,__FILE__,'calendar');
2485
+			$this->db->update($this->cal_table, array('cal_owner' => $new_user), array('cal_owner' => $old_user), __LINE__, __FILE__, 'calendar');
2489 2486
 			// delete participation of old user, if new user is already a participant
2490 2487
 			$ids = array();
2491
-			foreach($this->db->select($this->user_table,'cal_id',array(		// MySQL does NOT allow to run this as delete!
2488
+			foreach ($this->db->select($this->user_table, 'cal_id', array(		// MySQL does NOT allow to run this as delete!
2492 2489
 				'cal_user_type' => 'u',
2493 2490
 				'cal_user_id' => $old_user,
2494 2491
 				"cal_id IN (SELECT cal_id FROM $this->user_table other WHERE other.cal_id=cal_id AND other.cal_user_id=".$this->db->quote($new_user)." AND cal_user_type='u')",
2495
-			),__LINE__,__FILE__,false,'','calendar') as $row)
2492
+			), __LINE__, __FILE__, false, '', 'calendar') as $row)
2496 2493
 			{
2497 2494
 				$ids[] = $row['cal_id'];
2498 2495
 			}
2499
-			if ($ids) $this->db->delete($this->user_table,array(
2496
+			if ($ids) $this->db->delete($this->user_table, array(
2500 2497
 				'cal_user_type' => 'u',
2501 2498
 				'cal_user_id' => $old_user,
2502 2499
 				'cal_id' => $ids,
2503
-			),__LINE__,__FILE__,'calendar');
2500
+			), __LINE__, __FILE__, 'calendar');
2504 2501
 			// now change participant in the rest to contain new user instead of old user
2505
-			$this->db->update($this->user_table,array(
2502
+			$this->db->update($this->user_table, array(
2506 2503
 				'cal_user_id' => $new_user,
2507
-			),array(
2504
+			), array(
2508 2505
 				'cal_user_type' => 'u',
2509 2506
 				'cal_user_id' => $old_user,
2510
-			),__LINE__,__FILE__,'calendar');
2507
+			), __LINE__, __FILE__, 'calendar');
2511 2508
 		}
2512 2509
 	}
2513 2510
 
@@ -2521,18 +2518,18 @@  discard block
 block discarded – undo
2521 2518
 	 *
2522 2519
 	 * @return array recur_date => status pairs (index 0 => main status)
2523 2520
 	 */
2524
-	function get_recurrences($cal_id, $uid=null, $start=0, $end=0)
2521
+	function get_recurrences($cal_id, $uid = null, $start = 0, $end = 0)
2525 2522
 	{
2526 2523
 		$participant_status = array();
2527 2524
 		$where = array('cal_id' => $cal_id);
2528
-		if ($start != 0 && $end == 0) $where[] = '(cal_recur_date = 0 OR cal_recur_date >= ' . (int)$start . ')';
2529
-		if ($start == 0 && $end != 0) $where[] = '(cal_recur_date = 0 OR cal_recur_date <= ' . (int)$end . ')';
2525
+		if ($start != 0 && $end == 0) $where[] = '(cal_recur_date = 0 OR cal_recur_date >= '.(int)$start.')';
2526
+		if ($start == 0 && $end != 0) $where[] = '(cal_recur_date = 0 OR cal_recur_date <= '.(int)$end.')';
2530 2527
 		if ($start != 0 && $end != 0)
2531 2528
 		{
2532
-			$where[] = '(cal_recur_date = 0 OR (cal_recur_date >= ' . (int)$start .
2533
-						' AND cal_recur_date <= ' . (int)$end . '))';
2529
+			$where[] = '(cal_recur_date = 0 OR (cal_recur_date >= '.(int)$start.
2530
+						' AND cal_recur_date <= '.(int)$end.'))';
2534 2531
 		}
2535
-		foreach($this->db->select($this->user_table,'DISTINCT cal_recur_date',$where,__LINE__,__FILE__,false,'','calendar') as $row)
2532
+		foreach ($this->db->select($this->user_table, 'DISTINCT cal_recur_date', $where, __LINE__, __FILE__, false, '', 'calendar') as $row)
2536 2533
 		{
2537 2534
 			// inititalize the array
2538 2535
 			$participant_status[$row['cal_recur_date']] = null;
@@ -2546,17 +2543,17 @@  discard block
 block discarded – undo
2546 2543
 			'cal_user_type'	=> $user_type ? $user_type : 'u',
2547 2544
 			'cal_user_id'   => $user_id,
2548 2545
 		);
2549
-		if ($start != 0 && $end == 0) $where2[] = '(cal_recur_date = 0 OR cal_recur_date >= ' . (int)$start . ')';
2550
-		if ($start == 0 && $end != 0) $where2[] = '(cal_recur_date = 0 OR cal_recur_date <= ' . (int)$end . ')';
2546
+		if ($start != 0 && $end == 0) $where2[] = '(cal_recur_date = 0 OR cal_recur_date >= '.(int)$start.')';
2547
+		if ($start == 0 && $end != 0) $where2[] = '(cal_recur_date = 0 OR cal_recur_date <= '.(int)$end.')';
2551 2548
 		if ($start != 0 && $end != 0)
2552 2549
 		{
2553
-			$where2[] = '(cal_recur_date = 0 OR (cal_recur_date >= ' . (int)$start .
2554
-						' AND cal_recur_date <= ' . (int)$end . '))';
2550
+			$where2[] = '(cal_recur_date = 0 OR (cal_recur_date >= '.(int)$start.
2551
+						' AND cal_recur_date <= '.(int)$end.'))';
2555 2552
 		}
2556
-		foreach ($this->db->select($this->user_table,'cal_recur_date,cal_status,cal_quantity,cal_role',$where2,
2557
-				__LINE__,__FILE__,false,'','calendar') as $row)
2553
+		foreach ($this->db->select($this->user_table, 'cal_recur_date,cal_status,cal_quantity,cal_role', $where2,
2554
+				__LINE__, __FILE__, false, '', 'calendar') as $row)
2558 2555
 		{
2559
-			$status = self::combine_status($row['cal_status'],$row['cal_quantity'],$row['cal_role']);
2556
+			$status = self::combine_status($row['cal_status'], $row['cal_quantity'], $row['cal_role']);
2560 2557
 			$participant_status[$row['cal_recur_date']] = $status;
2561 2558
 		}
2562 2559
 		return $participant_status;
@@ -2605,8 +2602,8 @@  discard block
 block discarded – undo
2605 2602
 			'cal_uid'		=> $uid,
2606 2603
 		);
2607 2604
 		$related = array();
2608
-		foreach ($this->db->select($this->cal_table,'cal_id,cal_reference',$where,
2609
-				__LINE__,__FILE__,false,'','calendar') as $row)
2605
+		foreach ($this->db->select($this->cal_table, 'cal_id,cal_reference', $where,
2606
+				__LINE__, __FILE__, false, '', 'calendar') as $row)
2610 2607
 		{
2611 2608
 			if ($row['cal_reference'] != 0)
2612 2609
 			{
@@ -2635,10 +2632,10 @@  discard block
 block discarded – undo
2635 2632
 	 *
2636 2633
 	 * @return array		Array of exception days (false for non-recurring events).
2637 2634
 	 */
2638
-	function get_recurrence_exceptions($event, $tz_id=null, $start=0, $end=0, $filter='all')
2635
+	function get_recurrence_exceptions($event, $tz_id = null, $start = 0, $end = 0, $filter = 'all')
2639 2636
 	{
2640 2637
 		if (!is_array($event)) return false;
2641
-		$cal_id = (int) $event['id'];
2638
+		$cal_id = (int)$event['id'];
2642 2639
 		//error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2643 2640
 		//		"($cal_id, $tz_id, $filter): " . $event['tzid']);
2644 2641
 		if (!$cal_id || $event['recur_type'] == MCAL_RECUR_NONE) return false;
@@ -2662,27 +2659,27 @@  discard block
 block discarded – undo
2662 2659
 		while ($egw_rrule->valid())
2663 2660
 		{
2664 2661
 			while ($egw_rrule->exceptions &&
2665
-				in_array($egw_rrule->current->format('Ymd'),$egw_rrule->exceptions))
2662
+				in_array($egw_rrule->current->format('Ymd'), $egw_rrule->exceptions))
2666 2663
 			{
2667
-				if (in_array($filter, array('map','tz_map','rrule','tz_rrule')))
2664
+				if (in_array($filter, array('map', 'tz_map', 'rrule', 'tz_rrule')))
2668 2665
 				{
2669 2666
 					 // real exception
2670
-					$locts = (int)Api\DateTime::to($egw_rrule->current(),'server');
2667
+					$locts = (int)Api\DateTime::to($egw_rrule->current(), 'server');
2671 2668
 					if ($expand_all)
2672 2669
 					{
2673
-						$remts = (int)Api\DateTime::to($remote_rrule->current(),'server');
2670
+						$remts = (int)Api\DateTime::to($remote_rrule->current(), 'server');
2674 2671
 						if ($remote)
2675 2672
 						{
2676
-							$days[$locts]= $remts;
2673
+							$days[$locts] = $remts;
2677 2674
 						}
2678 2675
 						else
2679 2676
 						{
2680
-							$days[$remts]= $locts;
2677
+							$days[$remts] = $locts;
2681 2678
 						}
2682 2679
 					}
2683 2680
 					else
2684 2681
 					{
2685
-						$days[$locts]= $locts;
2682
+						$days[$locts] = $locts;
2686 2683
 					}
2687 2684
 				}
2688 2685
 				if ($expand_all)
@@ -2693,14 +2690,14 @@  discard block
 block discarded – undo
2693 2690
 				if (!$egw_rrule->valid()) return $days;
2694 2691
 			}
2695 2692
 			$day = $egw_rrule->current();
2696
-			$locts = (int)Api\DateTime::to($day,'server');
2693
+			$locts = (int)Api\DateTime::to($day, 'server');
2697 2694
 			$tz_exception = ($filter == 'tz_rrule');
2698 2695
 			//error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2699 2696
 			//	'()[EVENT Server]: ' . $day->format('Ymd\THis') . " ($locts)");
2700 2697
 			if ($expand_all)
2701 2698
 			{
2702 2699
 				$remote_day = $remote_rrule->current();
2703
-				$remts = (int)Api\DateTime::to($remote_day,'server');
2700
+				$remts = (int)Api\DateTime::to($remote_day, 'server');
2704 2701
 			//	error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2705 2702
 			//	'()[EVENT Device]: ' . $remote_day->format('Ymd\THis') . " ($remts)");
2706 2703
 			}
@@ -2719,11 +2716,11 @@  discard block
 block discarded – undo
2719 2716
 						//	'() tz exception: ' . $day->format('Ymd\THis'));
2720 2717
 						if ($remote)
2721 2718
 						{
2722
-							$days[$locts]= $remts;
2719
+							$days[$locts] = $remts;
2723 2720
 						}
2724 2721
 						else
2725 2722
 						{
2726
-							$days[$remts]= $locts;
2723
+							$days[$remts] = $locts;
2727 2724
 						}
2728 2725
 					}
2729 2726
 				}
@@ -2745,18 +2742,18 @@  discard block
 block discarded – undo
2745 2742
 							{
2746 2743
 								if ($remote)
2747 2744
 								{
2748
-									$days[$locts]= $remts;
2745
+									$days[$locts] = $remts;
2749 2746
 								}
2750 2747
 								else
2751 2748
 								{
2752
-									$days[$remts]= $locts;
2749
+									$days[$remts] = $locts;
2753 2750
 								}
2754 2751
 							}
2755 2752
 						}
2756 2753
 					}
2757 2754
 					elseif ($filter != 'map')
2758 2755
 					{
2759
-						$days[$locts]= $locts;
2756
+						$days[$locts] = $locts;
2760 2757
 					}
2761 2758
 				}
2762 2759
 				elseif (($filter == 'map' || filter == 'tz_map') &&
@@ -2766,11 +2763,11 @@  discard block
 block discarded – undo
2766 2763
 					if ($expand_all)
2767 2764
 					{
2768 2765
 
2769
-						$days[$remts]= $locts;
2766
+						$days[$remts] = $locts;
2770 2767
 					}
2771 2768
 					else
2772 2769
 					{
2773
-						$days[$locts]= $locts;
2770
+						$days[$locts] = $locts;
2774 2771
 					}
2775 2772
 				}
2776 2773
 			}
@@ -2794,9 +2791,9 @@  discard block
 block discarded – undo
2794 2791
 	 */
2795 2792
 	function status_pseudo_exception($cal_id, $recur_date, $filter)
2796 2793
 	{
2797
-		static $recurrence_zero=null;
2798
-		static $cached_id=null;
2799
-		static $user=null;
2794
+		static $recurrence_zero = null;
2795
+		static $cached_id = null;
2796
+		static $user = null;
2800 2797
 
2801 2798
 		if (!isset($cached_id) || $cached_id != $cal_id)
2802 2799
 		{
@@ -2807,8 +2804,8 @@  discard block
 block discarded – undo
2807 2804
 				'cal_id' => $cal_id,
2808 2805
 				'cal_recur_date' => 0,
2809 2806
 			);
2810
-			foreach ($this->db->select($this->user_table,'cal_user_type,cal_user_id,cal_user_attendee,cal_status',$where,
2811
-				__LINE__,__FILE__,false,'','calendar') as $row)
2807
+			foreach ($this->db->select($this->user_table, 'cal_user_type,cal_user_id,cal_user_attendee,cal_status', $where,
2808
+				__LINE__, __FILE__, false, '', 'calendar') as $row)
2812 2809
 			{
2813 2810
 				switch ($row['cal_user_type'])
2814 2811
 				{
@@ -2831,8 +2828,8 @@  discard block
 block discarded – undo
2831 2828
 			'cal_id' => $cal_id,
2832 2829
 			'cal_recur_date' => $recur_date,
2833 2830
 		);
2834
-		foreach ($this->db->select($this->user_table,'cal_user_type,cal_user_id,cal_user_attendee,cal_status',$where,
2835
-			__LINE__,__FILE__,false,'','calendar') as $row)
2831
+		foreach ($this->db->select($this->user_table, 'cal_user_type,cal_user_id,cal_user_attendee,cal_status', $where,
2832
+			__LINE__, __FILE__, false, '', 'calendar') as $row)
2836 2833
 		{
2837 2834
 			switch ($row['cal_user_type'])
2838 2835
 			{
@@ -2929,14 +2926,14 @@  discard block
 block discarded – undo
2929 2926
 			}
2930 2927
 			$timezone = self::$tz_cache[$event['tzid']];
2931 2928
 		}
2932
-		$start_time = new Api\DateTime($event['start'],Api\DateTime::$server_timezone);
2929
+		$start_time = new Api\DateTime($event['start'], Api\DateTime::$server_timezone);
2933 2930
 		$start_time->setTimezone($timezone);
2934
-		$end_time = new Api\DateTime($event['end'],Api\DateTime::$server_timezone);
2931
+		$end_time = new Api\DateTime($event['end'], Api\DateTime::$server_timezone);
2935 2932
 		$end_time->setTimezone($timezone);
2936 2933
 		//error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2937 2934
 		//	'(): ' . $start . '-' . $end);
2938
-		$start = Api\DateTime::to($start_time,'array');
2939
-		$end = Api\DateTime::to($end_time,'array');
2935
+		$start = Api\DateTime::to($start_time, 'array');
2936
+		$end = Api\DateTime::to($end_time, 'array');
2940 2937
 
2941 2938
 
2942 2939
 		return !$start['hour'] && !$start['minute'] && $end['hour'] == 23 && $end['minute'] == 59;
@@ -2950,7 +2947,7 @@  discard block
 block discarded – undo
2950 2947
 	 *
2951 2948
 	 * @return DateTime
2952 2949
 	 */
2953
-	function &startOfDay(Api\DateTime $time, $tz_id=null)
2950
+	function &startOfDay(Api\DateTime $time, $tz_id = null)
2954 2951
 	{
2955 2952
 		if (empty($tz_id))
2956 2953
 		{
@@ -2975,14 +2972,14 @@  discard block
 block discarded – undo
2975 2972
 	 * @param int $time =null new timestamp, default current (server-)time
2976 2973
 	 * @param int $modifier =null uid of the modifier, default current user
2977 2974
 	 */
2978
-	function updateModified($id, $update_master=false, $time=null, $modifier=null)
2975
+	function updateModified($id, $update_master = false, $time = null, $modifier = null)
2979 2976
 	{
2980 2977
 		if (is_null($time) || !$time) $time = time();
2981 2978
 		if (is_null($modifier)) $modifier = $GLOBALS['egw_info']['user']['account_id'];
2982 2979
 
2983 2980
 		$this->db->update($this->cal_table,
2984 2981
 			array('cal_modified' => $time, 'cal_modifier' => $modifier),
2985
-			array('cal_id' => $id), __LINE__,__FILE__, 'calendar');
2982
+			array('cal_id' => $id), __LINE__, __FILE__, 'calendar');
2986 2983
 
2987 2984
 		// if event is an exception: update modified of master, to force etag, ctag and sync-token change
2988 2985
 		if ($update_master)
Please login to merge, or discard this patch.
api/asyncservices.php 2 patches
Spacing   +10 added lines, -11 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 use EGroupware\Api\Asyncservice;
16 16
 
17 17
 if (!isset($_REQUEST['domain'])) $_REQUEST['domain'] = isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : 'default';
18
-$path_to_egroupware = realpath(__DIR__.'/..');	//  need to be adapted if this script is moved somewhere else
18
+$path_to_egroupware = realpath(__DIR__.'/..'); //  need to be adapted if this script is moved somewhere else
19 19
 
20 20
 // remove the comment from one of the following lines to enable loging
21 21
 // define('ASYNC_LOG','C:\\async.log');		// Windows
@@ -25,8 +25,8 @@  discard block
 block discarded – undo
25 25
 if (defined('ASYNC_LOG'))
26 26
 {
27 27
 	$msg = date('Y/m/d H:i:s ').$_REQUEST['domain'].": asyncservice started\n";
28
-	$f = fopen(ASYNC_LOG,'a+');
29
-	fwrite($f,$msg);
28
+	$f = fopen(ASYNC_LOG, 'a+');
29
+	fwrite($f, $msg);
30 30
 	fclose($f);
31 31
 }
32 32
 $GLOBALS['egw_info']['flags'] = array(
@@ -43,8 +43,8 @@  discard block
 block discarded – undo
43 43
 	}
44 44
 	if (defined('ASYNC_LOG'))
45 45
 	{
46
-		$f = fopen(ASYNC_LOG,'a+');
47
-		fwrite($f,$msg);
46
+		$f = fopen(ASYNC_LOG, 'a+');
47
+		fwrite($f, $msg);
48 48
 		fclose($f);
49 49
 	}
50 50
 	die($msg);
@@ -63,8 +63,8 @@  discard block
 block discarded – undo
63 63
 	}
64 64
 	if (defined('ASYNC_LOG'))
65 65
 	{
66
-		$f = fopen(ASYNC_LOG,'a+');
67
-		fwrite($f,$msg);
66
+		$f = fopen(ASYNC_LOG, 'a+');
67
+		fwrite($f, $msg);
68 68
 		fclose($f);
69 69
 	}
70 70
 	die($msg);
@@ -75,8 +75,7 @@  discard block
 block discarded – undo
75 75
 $async = new Asyncservice();
76 76
 $num = $async->check_run(isset($_REQUEST['run_by']) ? $_REQUEST['run_by'] : 'crontab');
77 77
 
78
-$msg = date('Y/m/d H:i:s ').$_REQUEST['domain'].': '.($num === false ? 'An error occured: can not obtain semaphore!' :
79
-	($num ? "$num job(s) executed" : 'Nothing to execute'))."\n\n";
78
+$msg = date('Y/m/d H:i:s ').$_REQUEST['domain'].': '.($num === false ? 'An error occured: can not obtain semaphore!' : ($num ? "$num job(s) executed" : 'Nothing to execute'))."\n\n";
80 79
 
81 80
 if (isset($_SERVER['HTTP_HOST']))
82 81
 {
@@ -87,7 +86,7 @@  discard block
 block discarded – undo
87 86
 
88 87
 if (defined('ASYNC_LOG'))
89 88
 {
90
-	$f = fopen(ASYNC_LOG,'a+');
91
-	fwrite($f,$msg);
89
+	$f = fopen(ASYNC_LOG, 'a+');
90
+	fwrite($f, $msg);
92 91
 	fclose($f);
93 92
 }
Please login to merge, or discard this patch.
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,10 @@
 block discarded – undo
14 14
 
15 15
 use EGroupware\Api\Asyncservice;
16 16
 
17
-if (!isset($_REQUEST['domain'])) $_REQUEST['domain'] = isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : 'default';
17
+if (!isset($_REQUEST['domain']))
18
+{
19
+	$_REQUEST['domain'] = isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : 'default';
20
+}
18 21
 $path_to_egroupware = realpath(__DIR__.'/..');	//  need to be adapted if this script is moved somewhere else
19 22
 
20 23
 // remove the comment from one of the following lines to enable loging
Please login to merge, or discard this patch.