Test Setup Failed
Push — 17.1 ( 8a89ce...c3d5c4 )
by Ralf
12:42
created
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)
@@ -686,24 +674,11 @@  discard block
 block discarded – undo
686 674
 	 * @param int $start startdate of the search/list (servertime)
687 675
 	 * @param int $end enddate of the search/list (servertime)
688 676
 	 * @param int|array $users user-id or array of user-id's, !$users means all entries regardless of users
689
-	 * @param int|array $cat_id =0 mixed category-id or array of cat-id's (incl. all sub-categories), default 0 = all
677
+	 * @param integer $cat_id =0 mixed category-id or array of cat-id's (incl. all sub-categories), default 0 = all
690 678
 	 * @param string $filter ='all' string filter-name: all (not rejected), accepted, unknown, tentative, rejected or everything (incl. rejected, deleted)
691 679
 	 * @param int|boolean $offset =False offset for a limited query or False (default)
692 680
 	 * @param int $num_rows =0 number of rows to return if offset set, default 0 = use default in user prefs
693 681
 	 * @param array $params =array()
694
-	 * @param string|array $params['query'] string: pattern so search for, if unset or empty all matching entries are returned (no search)
695
-	 *		Please Note: a search never returns repeating events more then once AND does not honor start+end date !!!
696
-	 *      array: everything is directly used as $where
697
-	 * @param string $params['order'] ='cal_start' column-names plus optional DESC|ASC separted by comma
698
-	 * @param string|array $params['sql_filter'] sql to be and'ed into query (fully quoted), or usual filter array
699
-	 * @param string|array $params['cols'] what to select, default "$this->repeats_table.*,$this->cal_table.*,cal_start,cal_end,cal_recur_date",
700
-	 * 						if specified and not false an iterator for the rows is returned
701
-	 * @param string $params['append'] SQL to append to the query before $order, eg. for a GROUP BY clause
702
-	 * @param array $params['cfs'] custom fields to query, null = none, array() = all, or array with cfs names
703
-	 * @param array $params['users'] raw parameter as passed to calendar_bo::search() no memberships resolved!
704
-	 * @param boolean $params['master_only'] =false, true only take into account participants/status from master (for AS)
705
-	 * @param boolean $params['enum_recuring'] =true enumerate recuring events
706
-	 * @param boolean $params['use_so_events'] =false, true return result of new $this->events()
707 682
 	 * @param int $remove_rejected_by_user =null add join to remove entry, if given user has rejected it
708 683
 	 * @return Iterator|array of events
709 684
 	 */
@@ -1168,11 +1143,11 @@  discard block
 block discarded – undo
1168 1143
 	 * Ask other apps if they want to participate in calendar search / display
1169 1144
 	 *
1170 1145
 	 * @param &$selects parts of union query
1171
-	 * @param $start see search()
1172
-	 * @param $end
1146
+	 * @param integer $start see search()
1147
+	 * @param integer $end
1173 1148
 	 * @param $users as used in calendar_so ($users_raw plus all members and memberships added by calendar_bo)
1174
-	 * @param $cat_id
1175
-	 * @param $filter
1149
+	 * @param integer $cat_id
1150
+	 * @param string $filter
1176 1151
 	 * @param $query
1177 1152
 	 * @param $users_raw as passed to calendar_bo::search (no members and memberships added)
1178 1153
 	 */
@@ -1340,6 +1315,7 @@  discard block
 block discarded – undo
1340 1315
 	 * @param int &$set_recurrences_start=0 on return: time from which on the recurrences should be rebuilt, default 0=all
1341 1316
 	 * @param int $change_since =0 time from which on the repetitions should be changed, default 0=all
1342 1317
 	 * @param int &$etag etag=null etag to check or null, on return new etag
1318
+	 * @param boolean $set_recurrences
1343 1319
 	 * @return boolean|int false on error, 0 if etag does not match, cal_id otherwise
1344 1320
 	 */
1345 1321
 	function save(&$event,&$set_recurrences,&$set_recurrences_start=0,$change_since=0,&$etag=null)
@@ -1735,7 +1711,7 @@  discard block
 block discarded – undo
1735 1711
 	 * @param int $cal_id
1736 1712
 	 * @param int $start new starttime
1737 1713
 	 * @param int $end new endtime
1738
-	 * @param int|boolean $change_since =0 false=new entry, > 0 time from which on the repetitions should be changed, default 0=all
1714
+	 * @param integer $change_since =0 false=new entry, > 0 time from which on the repetitions should be changed, default 0=all
1739 1715
 	 * @param int $old_start =0 old starttime or (default) 0, to query it from the db
1740 1716
 	 * @param int $old_end =0 old starttime or (default) 0
1741 1717
 	 * @todo Recalculate recurrences, if timezone changes
@@ -1912,7 +1888,7 @@  discard block
 block discarded – undo
1912 1888
 	 *
1913 1889
 	 * @param int $cal_id
1914 1890
 	 * @param array $participants uid => status pairs
1915
-	 * @param int|boolean $change_since =0, false=new event,
1891
+	 * @param integer $change_since =0, false=new event,
1916 1892
 	 * 		0=all, > 0 time from which on the repetitions should be changed
1917 1893
 	 * @param boolean $add_only =false
1918 1894
 	 *		false = add AND delete participants if needed (full list of participants required in $participants)
@@ -2058,7 +2034,7 @@  discard block
 block discarded – undo
2058 2034
 	 * set the status of one participant for a given recurrence or for all recurrences since now (includes recur_date=0)
2059 2035
 	 *
2060 2036
 	 * @param int $cal_id
2061
-	 * @param char $user_type 'u' regular user, 'r' resource, 'c' contact
2037
+	 * @param string $user_type 'u' regular user, 'r' resource, 'c' contact
2062 2038
 	 * @param int|string $user_id
2063 2039
 	 * @param int|char $status numeric status (defines) or 1-char code: 'R', 'U', 'T' or 'A'
2064 2040
 	 * @param int $recur_date =0 date to change, or 0 = all since now
@@ -2975,7 +2951,7 @@  discard block
 block discarded – undo
2975 2951
 	 * Updates the modification timestamp to force an etag, ctag and sync-token change
2976 2952
 	 *
2977 2953
 	 * @param int $id event id
2978
-	 * @param int|boolean $update_master =false id of series master or true, to update series master too
2954
+	 * @param boolean $update_master =false id of series master or true, to update series master too
2979 2955
 	 * @param int $time =null new timestamp, default current (server-)time
2980 2956
 	 * @param int $modifier =null uid of the modifier, default current user
2981 2957
 	 */
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
 		{
@@ -884,7 +884,7 @@  discard block
 block discarded – undo
884 884
 		$cal_table = $this->cal_range_view($start, $end, null, $filter == 'everything' ? null : $filter != 'deleted');
885 885
 		$cal_table_def = $this->db->get_table_definitions('calendar', $this->cal_table);
886 886
 
887
-		$u_join = "JOIN $this->user_table ON $this->cal_table.cal_id=$this->user_table.cal_id ".
887
+		$u_join = "join $this->user_table ON $this->cal_table.cal_id=$this->user_table.cal_id ".
888 888
 			"LEFT JOIN $this->repeats_table ON $this->cal_table.cal_id=$this->repeats_table.cal_id ".
889 889
 			$rejected_by_user_join;
890 890
 		// dates table join only needed to enum recuring events, we use a time-range limited view here too
@@ -1415,7 +1415,7 @@  discard block
 block discarded – undo
1415 1415
 			{
1416 1416
 				$old_repeats = $this->db->select($this->repeats_table, "$this->repeats_table.*,range_end AS recur_enddate",
1417 1417
 					"$this->repeats_table.cal_id=".(int)$cal_id, __LINE__, __FILE__,
1418
-					false, '', 'calendar', 0, "JOIN $this->cal_table ON $this->repeats_table.cal_id=$this->cal_table.cal_id")->fetch();
1418
+					false, '', 'calendar', 0, "join $this->cal_table ON $this->repeats_table.cal_id=$this->cal_table.cal_id")->fetch();
1419 1419
 			}
1420 1420
 			$where = array('cal_id' => $cal_id);
1421 1421
 			// read only timezone id, to check if it is changed
@@ -1782,13 +1782,13 @@  discard block
 block discarded – undo
1782 1782
 		if ($move_start)
1783 1783
 		{
1784 1784
 			// move the recur-date of the participants
1785
-			$this->db->query("UPDATE $this->user_table SET cal_recur_date=cal_recur_date+$move_start WHERE $where AND cal_recur_date ".
1785
+			$this->db->query("update $this->user_table SET cal_recur_date=cal_recur_date+$move_start WHERE $where AND cal_recur_date ".
1786 1786
 				((int)$change_since ? '>= '.(int)$change_since : '!= 0'),__LINE__,__FILE__);
1787 1787
 		}
1788 1788
 		if ($move_start || $move_end)
1789 1789
 		{
1790 1790
 			// move the event and it's recurrences
1791
-			$this->db->query("UPDATE $this->dates_table SET cal_start=cal_start+$move_start,cal_end=cal_end+$move_end WHERE $where".
1791
+			$this->db->query("update $this->dates_table SET cal_start=cal_start+$move_start,cal_end=cal_end+$move_end WHERE $where".
1792 1792
 				((int) $change_since ? ' AND cal_start >= '.(int) $change_since : ''),__LINE__,__FILE__);
1793 1793
 		}
1794 1794
 		return $this->db->affected_rows();
@@ -2488,7 +2488,7 @@  discard block
 block discarded – undo
2488 2488
 			),__LINE__,__FILE__,'calendar');
2489 2489
 
2490 2490
 			// delete calendar entries without participants (can happen if the deleted user is the only participants, but not the owner)
2491
-			foreach($this->db->select($this->cal_table,"DISTINCT $this->cal_table.cal_id",'cal_user_id IS NULL',__LINE__,__FILE__,
2491
+			foreach($this->db->select($this->cal_table,"distinct $this->cal_table.cal_id",'cal_user_id IS NULL',__LINE__,__FILE__,
2492 2492
 				False,'','calendar',0,"LEFT JOIN $this->user_table ON $this->cal_table.cal_id=$this->user_table.cal_id") as $row)
2493 2493
 			{
2494 2494
 				$this->delete($row['cal_id']);
Please login to merge, or discard this patch.
Spacing   +394 added lines, -397 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
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 		$this->db = $GLOBALS['egw']->db;
142 142
 
143 143
 		$this->all_tables = array($this->cal_table);
144
-		foreach(array('extra','repeats','user','dates') as $name)
144
+		foreach (array('extra', 'repeats', 'user', 'dates') as $name)
145 145
 		{
146 146
 			$vname = $name.'_table';
147 147
 			$this->all_tables[] = $this->$vname = $this->cal_table.'_'.$name;
@@ -157,11 +157,11 @@  discard block
 block discarded – undo
157 157
 	 * @param boolean $deleted =false
158 158
 	 * @return string
159 159
 	 */
160
-	protected function cal_range_view($start, $end, array $_where=null, $deleted=false)
160
+	protected function cal_range_view($start, $end, array $_where = null, $deleted = false)
161 161
 	{
162 162
 		if ($GLOBALS['egw_info']['server']['no_timerange_views'] || !$start)	// using view without start-date is slower!
163 163
 		{
164
-			return $this->cal_table;	// no need / use for a view
164
+			return $this->cal_table; // no need / use for a view
165 165
 		}
166 166
 
167 167
 		$where = array();
@@ -187,11 +187,11 @@  discard block
 block discarded – undo
187 187
 	 * @param boolean $deleted =false
188 188
 	 * @return string
189 189
 	 */
190
-	protected function dates_range_view($start, $end, array $_where=null, $deleted=false)
190
+	protected function dates_range_view($start, $end, array $_where = null, $deleted = false)
191 191
 	{
192 192
 		if ($GLOBALS['egw_info']['server']['no_timerange_views'] || !$start || !$end)	// using view without start- AND end-date is slower!
193 193
 		{
194
-			return $this->dates_table;	// no need / use for a view
194
+			return $this->dates_table; // no need / use for a view
195 195
 		}
196 196
 
197 197
 		$where = array();
@@ -236,14 +236,14 @@  discard block
 block discarded – undo
236 236
 	 * @param int $remove_rejected_by_user =null add join to remove entry, if given user has rejected it
237 237
 	 * @return array of events
238 238
 	 */
239
-	function &events($start,$end,$users,$cat_id=0,$filter='all',$offset=False,$num_rows=0,array $params=array(),$remove_rejected_by_user=null)
239
+	function &events($start, $end, $users, $cat_id = 0, $filter = 'all', $offset = False, $num_rows = 0, array $params = array(), $remove_rejected_by_user = null)
240 240
 	{
241
-		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());
241
+		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());
242 242
 		$start_time = microtime(true);
243 243
 		// not everything is supported by now
244 244
 		if (!$start || !$end || is_string($params['query']) ||
245 245
 			//in_array($filter,array('owner','deleted')) ||
246
-			$params['enum_recuring']===false)
246
+			$params['enum_recuring'] === false)
247 247
 		{
248 248
 			throw new Api\Exception\AssertionFailed("Unsupported value for parameters!");
249 249
 		}
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 		{
271 271
 			// fix $users to also prefix system users and groups (with 'u')
272 272
 			if (!is_array($users)) $users = $users ? (array)$users : array();
273
-			foreach($users as &$uid)
273
+			foreach ($users as &$uid)
274 274
 			{
275 275
 				$user_type = $user_id = null;
276 276
 				self::split_user($uid, $user_type, $user_id, true);
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
 
292 292
 		if ($params['order'])	// only order if requested
293 293
 		{
294
-			if (!preg_match('/^[a-z_ ,c]+$/i',$params['order'])) $params['order'] = 'cal_start';		// gard against SQL injection
294
+			if (!preg_match('/^[a-z_ ,c]+$/i', $params['order'])) $params['order'] = 'cal_start'; // gard against SQL injection
295 295
 			$sql .= "\nORDER BY ".$params['order'];
296 296
 		}
297 297
 
@@ -300,8 +300,8 @@  discard block
 block discarded – undo
300 300
 			$offset = 0;
301 301
 			$num_rows = -1;
302 302
 		}
303
-		$events =& $this->get_events($this->db->query($sql, __LINE__, __FILE__, $offset, $num_rows));
304
-		error_log(__METHOD__."(...) $sql --> ".number_format(microtime(true)-$start_time, 3));
303
+		$events = & $this->get_events($this->db->query($sql, __LINE__, __FILE__, $offset, $num_rows));
304
+		error_log(__METHOD__."(...) $sql --> ".number_format(microtime(true) - $start_time, 3));
305 305
 		return $events;
306 306
 	}
307 307
 
@@ -315,12 +315,12 @@  discard block
 block discarded – undo
315 315
 	 * @param boolean $read_recurrence =false true: read the exception, not the series master (only for recur_date && $ids='<uid>'!)
316 316
 	 * @return array|boolean array with cal_id => event array pairs or false if entry not found
317 317
 	 */
318
-	function read($ids, $recur_date=0, $read_recurrence=false)
318
+	function read($ids, $recur_date = 0, $read_recurrence = false)
319 319
 	{
320 320
 		//error_log(__METHOD__.'('.array2string($ids).",$recur_date) ".function_backtrace());
321 321
 		$cols = self::get_columns('calendar', $this->cal_table);
322 322
 		$cols[0] = $this->db->to_varchar($this->cal_table.'.cal_id');
323
-		$cols = "$this->repeats_table.recur_type,$this->repeats_table.recur_interval,$this->repeats_table.recur_data,".implode(',',$cols);
323
+		$cols = "$this->repeats_table.recur_type,$this->repeats_table.recur_interval,$this->repeats_table.recur_data,".implode(',', $cols);
324 324
 		$join = "LEFT JOIN $this->repeats_table ON $this->cal_table.cal_id=$this->repeats_table.cal_id";
325 325
 
326 326
 		$where = array();
@@ -338,23 +338,23 @@  discard block
 block discarded – undo
338 338
 				$where['cal_reference'] = 0;
339 339
 			}
340 340
 		}
341
-		elseif(is_array($ids) && isset($ids[count($ids)-1]) || is_scalar($ids))	// one or more cal_id's
341
+		elseif (is_array($ids) && isset($ids[count($ids) - 1]) || is_scalar($ids))	// one or more cal_id's
342 342
 		{
343 343
 			$where['cal_id'] = $ids;
344 344
 		}
345 345
 		else	// array with column => value pairs
346 346
 		{
347 347
 			$where = $ids;
348
-			unset($ids);	// otherwise users get not read!
348
+			unset($ids); // otherwise users get not read!
349 349
 		}
350 350
 		if (isset($where['cal_id']))	// prevent non-unique column-name cal_id
351 351
 		{
352
-			$where[] = $this->db->expression($this->cal_table, $this->cal_table.'.',array(
352
+			$where[] = $this->db->expression($this->cal_table, $this->cal_table.'.', array(
353 353
 				'cal_id' => $where['cal_id'],
354 354
 			));
355 355
 			unset($where['cal_id']);
356 356
 		}
357
-		if ((int) $recur_date && !$read_recurrence)
357
+		if ((int)$recur_date && !$read_recurrence)
358 358
 		{
359 359
 			$where[] = 'cal_start >= '.(int)$recur_date;
360 360
 			$group_by = 'GROUP BY '.$cols;
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
 		}
368 368
 		$cols .= ',range_end-1 AS recur_enddate';
369 369
 
370
-		$events =& $this->get_events($this->db->select($this->cal_table, $cols, $where, __LINE__, __FILE__, false, $group_by, 'calendar', 0, $join), $recur_date);
370
+		$events = & $this->get_events($this->db->select($this->cal_table, $cols, $where, __LINE__, __FILE__, false, $group_by, 'calendar', 0, $join), $recur_date);
371 371
 
372 372
 		// if we wanted to read the real recurrence, but we have eg. only a virtual one, we need to try again without $read_recurrence
373 373
 		if ((!$events || ($e = current($events)) && $e['deleted']) && $recur_date && $read_recurrence)
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
 	 * @param int $recur_date =0
386 386
 	 * @return array
387 387
 	 */
388
-	protected function &get_events($rs, $recur_date=0)
388
+	protected function &get_events($rs, $recur_date = 0)
389 389
 	{
390 390
 		if (isset($GLOBALS['egw_info']['user']['preferences']['syncml']['minimum_uid_length']))
391 391
 		{
@@ -397,7 +397,7 @@  discard block
 block discarded – undo
397 397
 		}
398 398
 
399 399
 		$events = array();
400
-		foreach($rs as $row)
400
+		foreach ($rs as $row)
401 401
 		{
402 402
 			if (!$row['recur_type'])
403 403
 			{
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
 				unset($row['recur_enddate']);
406 406
 			}
407 407
 			$row['recur_exception'] = $row['alarm'] = array();
408
-			$events[$row['cal_id']] = Api\Db::strip_array_keys($row,'cal_');
408
+			$events[$row['cal_id']] = Api\Db::strip_array_keys($row, 'cal_');
409 409
 		}
410 410
 		if (!$events) return $events;
411 411
 
@@ -417,26 +417,26 @@  discard block
 block discarded – undo
417 417
 			if (!isset($event['uid']) || strlen($event['uid']) < $minimum_uid_length)
418 418
 			{
419 419
 				// event (without uid), not strong enough uid => create new uid
420
-				$event['uid'] = Api\CalDAV::generate_uid('calendar',$event['id']);
420
+				$event['uid'] = Api\CalDAV::generate_uid('calendar', $event['id']);
421 421
 				$this->db->update($this->cal_table, array('cal_uid' => $event['uid']),
422
-					array('cal_id' => $event['id']),__LINE__,__FILE__,'calendar');
422
+					array('cal_id' => $event['id']), __LINE__, __FILE__, 'calendar');
423 423
 			}
424 424
 			if (!(int)$recur_date && $event['recur_type'] != MCAL_RECUR_NONE)
425 425
 			{
426
-				foreach($this->db->select($this->dates_table, 'cal_id,cal_start', array(
426
+				foreach ($this->db->select($this->dates_table, 'cal_id,cal_start', array(
427 427
 					'cal_id' => $ids,
428 428
 					'recur_exception' => true,
429 429
 				), __LINE__, __FILE__, false, 'ORDER BY cal_id,cal_start', 'calendar') as $row)
430 430
 				{
431 431
 					$events[$row['cal_id']]['recur_exception'][] = $row['cal_start'];
432 432
 				}
433
-				break;	// as above select read all exceptions (and I dont think too short uid problem still exists)
433
+				break; // as above select read all exceptions (and I dont think too short uid problem still exists)
434 434
 			}
435 435
 			// make sure we fetch only real exceptions (deleted occurrences of a series should not show up)
436
-			if (($recur_date &&	$event['recur_type'] != MCAL_RECUR_NONE))
436
+			if (($recur_date && $event['recur_type'] != MCAL_RECUR_NONE))
437 437
 			{
438 438
 				//_debug_array(__METHOD__.__LINE__.' recur_date:'.$recur_date.' check cal_start:'.$event['start']);
439
-				foreach($this->db->select($this->dates_table, 'cal_id,cal_start', array(
439
+				foreach ($this->db->select($this->dates_table, 'cal_id,cal_start', array(
440 440
 					'cal_id' => $event['id'],
441 441
 					'cal_start' => $event['start'],
442 442
 					'recur_exception' => true,
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
 						'cal_deleted' => NULL
453 453
 					), __LINE__, __FILE__, false, '', 'calendar')->fetchColumn())
454 454
 					{
455
-						$e = $this->read($event['id'],$event['start']+1);
455
+						$e = $this->read($event['id'], $event['start'] + 1);
456 456
 						$event = $e[$event['id']];
457 457
 						break;
458 458
 					}
@@ -474,21 +474,21 @@  discard block
 block discarded – undo
474 474
 			if ($recur_date)
475 475
 			{
476 476
 				// also remember recur_date, maybe we need it later, duno now
477
-				$recur_date = array(0,$events[$ids]['recur_date'] = $events[$ids]['start']);
477
+				$recur_date = array(0, $events[$ids]['recur_date'] = $events[$ids]['start']);
478 478
 			}
479 479
 		}
480 480
 
481 481
 		// participants, if a recur_date give, we read that recurance, plus the one users from the default entry with recur_date=0
482 482
 		// sorting by cal_recur_date ASC makes sure recurence status always overwrites series status
483
-		foreach($this->db->select($this->user_table,'*',array(
483
+		foreach ($this->db->select($this->user_table, '*', array(
484 484
 			'cal_id'      => $ids,
485 485
 			'cal_recur_date' => $recur_date,
486 486
 			"cal_status NOT IN ('X','E')",
487
-		),__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
487
+		), __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
488 488
 		{
489 489
 			// combine all participant data in uid and status values
490 490
 			$uid    = self::combine_user($row['cal_user_type'], $row['cal_user_id'], $row['cal_user_attendee']);
491
-			$status = self::combine_status($row['cal_status'],$row['cal_quantity'],$row['cal_role']);
491
+			$status = self::combine_status($row['cal_status'], $row['cal_quantity'], $row['cal_role']);
492 492
 
493 493
 			$events[$row['cal_id']]['participants'][$uid] = $status;
494 494
 			$events[$row['cal_id']]['participant_types'][$row['cal_user_type']][is_numeric($uid) ? $uid : substr($uid, 1)] = $status;
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
 		}
498 498
 
499 499
 		// custom fields
500
-		foreach($this->db->select($this->extra_table,'*',array('cal_id'=>$ids),__LINE__,__FILE__,false,'','calendar') as $row)
500
+		foreach ($this->db->select($this->extra_table, '*', array('cal_id'=>$ids), __LINE__, __FILE__, false, '', 'calendar') as $row)
501 501
 		{
502 502
 			$events[$row['cal_id']]['#'.$row['cal_extra_name']] = $row['cal_extra_value'];
503 503
 		}
@@ -505,7 +505,7 @@  discard block
 block discarded – undo
505 505
 		// alarms
506 506
 		if (is_array($ids))
507 507
 		{
508
-			foreach($this->read_alarms((array)$ids) as $cal_id => $alarms)
508
+			foreach ($this->read_alarms((array)$ids) as $cal_id => $alarms)
509 509
 			{
510 510
 				$events[$cal_id]['alarm'] = $alarms;
511 511
 			}
@@ -534,11 +534,11 @@  discard block
 block discarded – undo
534 534
 	 * @param boolean $master_only =false only check recurance master (egw_cal_user.recur_date=0)
535 535
 	 * @return int maximum modification timestamp
536 536
 	 */
537
-	function get_ctag($users, $owner_too=false,$master_only=false)
537
+	function get_ctag($users, $owner_too = false, $master_only = false)
538 538
 	{
539
-		static $ctags = array();	// some per-request caching
539
+		static $ctags = array(); // some per-request caching
540 540
 		static $last_request = null;
541
-		if (!isset($last_request) || time()-$last_request > self::MAX_CTAG_CACHE_TIME)
541
+		if (!isset($last_request) || time() - $last_request > self::MAX_CTAG_CACHE_TIME)
542 542
 		{
543 543
 			$ctags = array();
544 544
 			$last_request = time();
@@ -547,13 +547,13 @@  discard block
 block discarded – undo
547 547
 		if (isset($ctags[$signature])) return $ctags[$signature];
548 548
 
549 549
 		$types = array();
550
-		foreach((array)$users as $uid)
550
+		foreach ((array)$users as $uid)
551 551
 		{
552 552
 			$type = $id = null;
553 553
 			self::split_user($uid, $type, $id, true);
554 554
 			$types[$type][] = $id;
555 555
 		}
556
-		foreach($types as $type => $ids)
556
+		foreach ($types as $type => $ids)
557 557
 		{
558 558
 			$where = array(
559 559
 				'cal_user_type' => $type,
@@ -575,17 +575,17 @@  discard block
 block discarded – undo
575 575
 		if ($owner_too)
576 576
 		{
577 577
 			// owner can only by users, no groups or resources
578
-			foreach($users as $key => $user)
578
+			foreach ($users as $key => $user)
579 579
 			{
580 580
 				if (!($user > 0)) unset($users[$key]);
581 581
 			}
582 582
 			$where = $this->db->expression($this->user_table, '(', $where, ' OR ').
583 583
 				$this->db->expression($this->cal_table, array(
584 584
 					'cal_owner' => $users,
585
-				),')');
585
+				), ')');
586 586
 		}
587
-		return $ctags[$signature] = $this->db->select($this->user_table,'MAX(cal_modified)',
588
-			$where,__LINE__,__FILE__,false,'','calendar',0,'JOIN egw_cal ON egw_cal.cal_id=egw_cal_user.cal_id')->fetchColumn();
587
+		return $ctags[$signature] = $this->db->select($this->user_table, 'MAX(cal_modified)',
588
+			$where, __LINE__, __FILE__, false, '', 'calendar', 0, 'JOIN egw_cal ON egw_cal.cal_id=egw_cal_user.cal_id')->fetchColumn();
589 589
 	}
590 590
 
591 591
 	/**
@@ -597,7 +597,7 @@  discard block
 block discarded – undo
597 597
 	 * @param string|array $cols ='cal_id,cal_reference,cal_etag,cal_modified,cal_user_modified' cols to query
598 598
 	 * @return Iterator as Api\Db::select
599 599
 	 */
600
-	function get_cal_data(array $query, $cols='cal_id,cal_reference,cal_etag,cal_modified,cal_user_modified')
600
+	function get_cal_data(array $query, $cols = 'cal_id,cal_reference,cal_etag,cal_modified,cal_user_modified')
601 601
 	{
602 602
 		if (!is_array($cols)) $cols = explode(',', $cols);
603 603
 
@@ -625,14 +625,14 @@  discard block
 block discarded – undo
625 625
 			$cats = $GLOBALS['egw']->categories->return_all_children($cat_id);
626 626
 			array_walk($cats, function(&$val, $key)
627 627
 			{
628
-				unset($key);	// not used, but required by function signature
629
-				$val = (int) $val;
628
+				unset($key); // not used, but required by function signature
629
+				$val = (int)$val;
630 630
 			});
631
-			if (is_array($cat_id) && count($cat_id)==1) $cat_id = $cat_id[0];
632
-			$sql = '(cal_category'.(count($cats) > 1 ? " IN ('".implode("','",$cats)."')" : '='.$this->db->quote((int)$cat_id));
633
-			foreach($cats as $cat)
631
+			if (is_array($cat_id) && count($cat_id) == 1) $cat_id = $cat_id[0];
632
+			$sql = '(cal_category'.(count($cats) > 1 ? " IN ('".implode("','", $cats)."')" : '='.$this->db->quote((int)$cat_id));
633
+			foreach ($cats as $cat)
634 634
 			{
635
-				$sql .= ' OR '.$this->db->concat("','",'cal_category',"','").' LIKE '.$this->db->quote('%,'.$cat.',%');
635
+				$sql .= ' OR '.$this->db->concat("','", 'cal_category', "','").' LIKE '.$this->db->quote('%,'.$cat.',%');
636 636
 			}
637 637
 			$sql .= ') ';
638 638
 		}
@@ -647,13 +647,13 @@  discard block
 block discarded – undo
647 647
 	 * @param array $where =array() array to add filters too
648 648
 	 * @return array
649 649
 	 */
650
-	protected function status_filter($filter, $enum_recuring=true, array $where=array())
650
+	protected function status_filter($filter, $enum_recuring = true, array $where = array())
651 651
 	{
652
-		if($filter != 'deleted' && $filter != 'everything')
652
+		if ($filter != 'deleted' && $filter != 'everything')
653 653
 		{
654 654
 			$where[] = 'cal_deleted IS NULL';
655 655
 		}
656
-		switch($filter)
656
+		switch ($filter)
657 657
 		{
658 658
 			case 'everything':	// no filter at all
659 659
 				break;
@@ -727,7 +727,7 @@  discard block
 block discarded – undo
727 727
 	 * @param int $remove_rejected_by_user =null add join to remove entry, if given user has rejected it
728 728
 	 * @return Iterator|array of events
729 729
 	 */
730
-	function &search($start,$end,$users,$cat_id=0,$filter='all',$offset=False,$num_rows=0,array $params=array(),$remove_rejected_by_user=null)
730
+	function &search($start, $end, $users, $cat_id = 0, $filter = 'all', $offset = False, $num_rows = 0, array $params = array(), $remove_rejected_by_user = null)
731 731
 	{
732 732
 		//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());
733 733
 
@@ -750,7 +750,7 @@  discard block
 block discarded – undo
750 750
 		{
751 751
 			$all_cols = self::get_columns('calendar', $this->cal_table);
752 752
 			$all_cols[0] = $this->db->to_varchar($this->cal_table.'.cal_id');
753
-			$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";
753
+			$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";
754 754
 		}
755 755
 		$where = array();
756 756
 		$join = '';
@@ -760,13 +760,13 @@  discard block
 block discarded – undo
760 760
 		}
761 761
 		elseif ($params['query'])
762 762
 		{
763
-			$columns = array('cal_title','cal_description','cal_location');
763
+			$columns = array('cal_title', 'cal_description', 'cal_location');
764 764
 
765 765
 			$wildcard = $op = null;
766
-			if(!is_null($params['cfs']))
766
+			if (!is_null($params['cfs']))
767 767
 			{
768 768
 				$custom = Api\Storage\Customfields::get('calendar');
769
-				if($custom)
769
+				if ($custom)
770 770
 				{
771 771
 					$columns[] = 'cal_extra_value';
772 772
 					$join .= " LEFT JOIN {$this->extra_table} ON {$this->extra_table}.cal_id = {$this->cal_table}.cal_id ";
@@ -779,9 +779,9 @@  discard block
 block discarded – undo
779 779
 			if (!isset($params['private_grants']))
780 780
 			{
781 781
 				$params['private_grants'] = $GLOBALS['egw']->acl->get_ids_for_location($GLOBALS['egw_info']['user']['account_id'], Acl::PRIVAT, 'calendar');
782
-				$params['private_grants'][] = $GLOBALS['egw_info']['user']['account_id'];	// db query does NOT return current user
782
+				$params['private_grants'][] = $GLOBALS['egw_info']['user']['account_id']; // db query does NOT return current user
783 783
 			}
784
-			$private_filter = '(cal_public=1 OR cal_public=0 AND '.$this->db->expression($this->cal_table, array('cal_owner' => $params['private_grants'])) . ')';
784
+			$private_filter = '(cal_public=1 OR cal_public=0 AND '.$this->db->expression($this->cal_table, array('cal_owner' => $params['private_grants'])).')';
785 785
 			$where[] = $private_filter;
786 786
 		}
787 787
 		if (!empty($params['sql_filter']))
@@ -790,7 +790,7 @@  discard block
 block discarded – undo
790 790
 			{
791 791
 				$where[] = $params['sql_filter'];
792 792
 			}
793
-			elseif(is_array($params['sql_filter']))
793
+			elseif (is_array($params['sql_filter']))
794 794
 			{
795 795
 				$where = array_merge($where, $params['sql_filter']);
796 796
 			}
@@ -799,11 +799,11 @@  discard block
 block discarded – undo
799 799
 		if ($users)
800 800
 		{
801 801
 			$users_by_type = array();
802
-			foreach((array)$users as $user)
802
+			foreach ((array)$users as $user)
803 803
 			{
804 804
 				if (is_numeric($user))
805 805
 				{
806
-					$users_by_type['u'][] = (int) $user;
806
+					$users_by_type['u'][] = (int)$user;
807 807
 				}
808 808
 				else
809 809
 				{
@@ -814,45 +814,45 @@  discard block
 block discarded – undo
814 814
 			}
815 815
 			$to_or = $user_or = array();
816 816
 			$owner_or = null;
817
-			$table_def = $this->db->get_table_definitions('calendar',$this->user_table);
818
-			foreach($users_by_type as $type => $ids)
817
+			$table_def = $this->db->get_table_definitions('calendar', $this->user_table);
818
+			foreach ($users_by_type as $type => $ids)
819 819
 			{
820 820
 				// 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
821 821
 				if ($useUnionQuery)
822 822
 				{
823
-					$user_or[] = $this->db->expression($table_def,$this->user_table.'.',array(
823
+					$user_or[] = $this->db->expression($table_def, $this->user_table.'.', array(
824 824
 						'cal_user_type' => $type,
825
-					),' AND '.$this->user_table.'.',array(
825
+					), ' AND '.$this->user_table.'.', array(
826 826
 						'cal_user_id'   => $ids,
827 827
 					));
828 828
 					if ($type == 'u' && $filter == 'owner')
829 829
 					{
830
-						$cal_table_def = $this->db->get_table_definitions('calendar',$this->cal_table);
830
+						$cal_table_def = $this->db->get_table_definitions('calendar', $this->cal_table);
831 831
 						// only users can be owners, no need to add groups
832 832
 						$user_ids = array();
833
-						foreach($ids as $user_id)
833
+						foreach ($ids as $user_id)
834 834
 						{
835 835
 							if ($GLOBALS['egw']->accounts->get_type($user_id) === 'u') $user_ids[] = $user_id;
836 836
 						}
837
-						$owner_or = $this->db->expression($cal_table_def,array('cal_owner' => $user_ids));
837
+						$owner_or = $this->db->expression($cal_table_def, array('cal_owner' => $user_ids));
838 838
 					}
839 839
 				}
840 840
 				else
841 841
 				{
842
-					$to_or[] = $this->db->expression($table_def,$this->user_table.'.',array(
842
+					$to_or[] = $this->db->expression($table_def, $this->user_table.'.', array(
843 843
 						'cal_user_type' => $type,
844
-					),' AND '.$this->user_table.'.',array(
844
+					), ' AND '.$this->user_table.'.', array(
845 845
 						'cal_user_id'   => $ids,
846 846
 					));
847 847
 					if ($type == 'u' && $filter == 'owner')
848 848
 					{
849
-						$cal_table_def = $this->db->get_table_definitions('calendar',$this->cal_table);
850
-						$to_or[] = $this->db->expression($cal_table_def,array('cal_owner' => $ids));
849
+						$cal_table_def = $this->db->get_table_definitions('calendar', $this->cal_table);
850
+						$to_or[] = $this->db->expression($cal_table_def, array('cal_owner' => $ids));
851 851
 					}
852 852
 				}
853 853
 			}
854 854
 			// this is only used, when we cannot use UNIONS
855
-			if (!$useUnionQuery) $where[] = '('.implode(' OR ',$to_or).')';
855
+			if (!$useUnionQuery) $where[] = '('.implode(' OR ', $to_or).')';
856 856
 
857 857
 			$where = $this->status_filter($filter, $params['enum_recuring'], $where);
858 858
 		}
@@ -871,15 +871,15 @@  discard block
 block discarded – undo
871 871
 				$where[] = '('.((int)$start).' < range_end OR range_end IS NULL)';
872 872
 			}
873 873
 		}
874
-		if (!preg_match('/^[a-z_ ,c]+$/i',$params['order'])) $params['order'] = 'cal_start';		// gard against SQL injection
874
+		if (!preg_match('/^[a-z_ ,c]+$/i', $params['order'])) $params['order'] = 'cal_start'; // gard against SQL injection
875 875
 
876 876
 		// if not enum recuring events, we have to use minimum start- AND end-dates, otherwise we get more then one event per cal_id!
877 877
 		if (!$params['enum_recuring'])
878 878
 		{
879 879
 			$where[] = "$this->user_table.cal_recur_date=0";
880
-			$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);
880
+			$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);
881 881
 			// in case cal_start is used in a query, eg. calendar_ical::find_event
882
-			$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);
882
+			$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);
883 883
 			$params['order'] = str_replace('cal_start', 'range_start', $params['order']);
884 884
 			if ($end) $where[] = (int)$end.' > range_start';
885 885
   		}
@@ -891,14 +891,13 @@  discard block
 block discarded – undo
891 891
 				" ON $this->cal_table.cal_id=rejected_by_user.cal_id".
892 892
 				" AND rejected_by_user.cal_user_type='u'".
893 893
 				" AND rejected_by_user.cal_user_id=".$this->db->quote($remove_rejected_by_user).
894
-				" AND ".(!$params['enum_recuring'] ? 'rejected_by_user.cal_recur_date=0' :
895
-					'(recur_type IS NULL AND rejected_by_user.cal_recur_date=0 OR cal_start=rejected_by_user.cal_recur_date)');
894
+				" 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)');
896 895
 			$or_required = array(
897 896
 				'rejected_by_user.cal_status IS NULL',
898 897
 				"rejected_by_user.cal_status NOT IN ('R','X')",
899 898
 			);
900 899
 			if ($filter == 'owner') $or_required[] = 'cal_owner='.(int)$remove_rejected_by_user;
901
-			$where[] = '('.implode(' OR ',$or_required).')';
900
+			$where[] = '('.implode(' OR ', $or_required).')';
902 901
 		}
903 902
 		// using a time-range and deleted attribute limited view instead of full table
904 903
 		$cal_table = $this->cal_range_view($start, $end, null, $filter == 'everything' ? null : $filter != 'deleted');
@@ -910,7 +909,7 @@  discard block
 block discarded – undo
910 909
 		// dates table join only needed to enum recuring events, we use a time-range limited view here too
911 910
 		if ($params['enum_recuring'])
912 911
 		{
913
-			$join .= "JOIN ".$this->dates_table.	// using dates_table direct seems quicker then an other view
912
+			$join .= "JOIN ".$this->dates_table.// using dates_table direct seems quicker then an other view
914 913
 				//$this->dates_range_view($start, $end, null, $filter == 'everything' ? null : $filter == 'deleted').
915 914
 				" ON $this->cal_table.cal_id=$this->dates_table.cal_id ".$u_join;
916 915
 		}
@@ -920,12 +919,12 @@  discard block
 block discarded – undo
920 919
 		}
921 920
 
922 921
 		// Check for some special sorting, used by planner views
923
-		if($params['order'] == 'participants , cal_non_blocking DESC')
922
+		if ($params['order'] == 'participants , cal_non_blocking DESC')
924 923
 		{
925 924
 			$order = ($GLOBALS['egw_info']['user']['preferences']['common']['account_display'] == 'lastname' ? 'n_family' : 'n_fileas');
926 925
 			$cols .= ",egw_addressbook.{$order}";
927 926
 			$join .= "LEFT JOIN egw_addressbook ON ".
928
-					($this->db->Type == 'pgsql'? "egw_addressbook.account_id::varchar = ":"egw_addressbook.account_id = ").
927
+					($this->db->Type == 'pgsql' ? "egw_addressbook.account_id::varchar = " : "egw_addressbook.account_id = ").
929 928
 					"{$this->user_table}.cal_user_id";
930 929
 			$params['order'] = "$order, cal_non_blocking DESC";
931 930
 		}
@@ -958,29 +957,29 @@  discard block
 block discarded – undo
958 957
 			// as replace the OR by construction of a suitable UNION for performance reasons
959 958
 			if ($owner_or || $user_or)
960 959
 			{
961
-				foreach($user_or as $user_sql)
960
+				foreach ($user_or as $user_sql)
962 961
 				{
963 962
 					$selects[] = $select;
964
-					$selects[count($selects)-1]['where'][] = $user_sql;
963
+					$selects[count($selects) - 1]['where'][] = $user_sql;
965 964
 					if ($params['enum_recuring'])
966 965
 					{
967
-						$selects[count($selects)-1]['where'][] = "recur_type IS NULL AND $this->user_table.cal_recur_date=0";
966
+						$selects[count($selects) - 1]['where'][] = "recur_type IS NULL AND $this->user_table.cal_recur_date=0";
968 967
 						$selects[] = $select;
969
-						$selects[count($selects)-1]['where'][] = $user_sql;
970
-						$selects[count($selects)-1]['where'][] = "$this->user_table.cal_recur_date=cal_start";
968
+						$selects[count($selects) - 1]['where'][] = $user_sql;
969
+						$selects[count($selects) - 1]['where'][] = "$this->user_table.cal_recur_date=cal_start";
971 970
 					}
972 971
 				}
973 972
 				// if the query is to be filtered by owner we need to add more selects for the union
974 973
 				if ($owner_or)
975 974
 				{
976 975
 					$selects[] = $select;
977
-					$selects[count($selects)-1]['where'][] = $owner_or;
976
+					$selects[count($selects) - 1]['where'][] = $owner_or;
978 977
 					if ($params['enum_recuring'])
979 978
 					{
980
-						$selects[count($selects)-1]['where'][] = "recur_type IS NULL AND $this->user_table.cal_recur_date=0";
979
+						$selects[count($selects) - 1]['where'][] = "recur_type IS NULL AND $this->user_table.cal_recur_date=0";
981 980
 						$selects[] = $select;
982
-						$selects[count($selects)-1]['where'][] = $owner_or;
983
-						$selects[count($selects)-1]['where'][] = "$this->user_table.cal_recur_date=cal_start";
981
+						$selects[count($selects) - 1]['where'][] = $owner_or;
982
+						$selects[count($selects) - 1]['where'][] = "$this->user_table.cal_recur_date=cal_start";
984 983
 					}
985 984
 				}
986 985
 			}
@@ -990,34 +989,34 @@  discard block
 block discarded – undo
990 989
 				$selects[] = $select;
991 990
 				if ($params['enum_recuring'])
992 991
 				{
993
-					$selects[count($selects)-1]['where'][] = "recur_type IS NULL AND $this->user_table.cal_recur_date=0";
992
+					$selects[count($selects) - 1]['where'][] = "recur_type IS NULL AND $this->user_table.cal_recur_date=0";
994 993
 					$selects[] = $select;
995
-					$selects[count($selects)-1]['where'][] = "$this->user_table.cal_recur_date=cal_start";
994
+					$selects[count($selects) - 1]['where'][] = "$this->user_table.cal_recur_date=cal_start";
996 995
 				}
997 996
 			}
998 997
 			if (is_numeric($offset) && !$params['no_total'])	// get the total too
999 998
 			{
1000 999
 				$save_selects = $selects;
1001 1000
 				// 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)
1002
-				foreach(array_keys($selects) as $key)
1001
+				foreach (array_keys($selects) as $key)
1003 1002
 				{
1004 1003
 					$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";
1005 1004
 					if (!$params['enum_recuring'])
1006 1005
 					{
1007
-						$selects[$key]['cols'] = str_replace(array('cal_start','cal_end'),
1008
-							array('range_start AS cal_start','range_end AS cal_end'), $selects[$key]['cols']);
1006
+						$selects[$key]['cols'] = str_replace(array('cal_start', 'cal_end'),
1007
+							array('range_start AS cal_start', 'range_end AS cal_end'), $selects[$key]['cols']);
1009 1008
 					}
1010 1009
 				}
1011
-				if (!isset($params['cols']) && !$params['no_integration']) self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']);
1010
+				if (!isset($params['cols']) && !$params['no_integration']) self::get_union_selects($selects, $start, $end, $users, $cat_id, $filter, $params['query'], $params['users']);
1012 1011
 
1013
-				$this->total = $this->db->union($selects,__LINE__,__FILE__)->NumRows();
1012
+				$this->total = $this->db->union($selects, __LINE__, __FILE__)->NumRows();
1014 1013
 
1015 1014
 				// restore original cols / selects
1016 1015
 				$selects = $save_selects; unset($save_selects);
1017 1016
 			}
1018
-			if (!isset($params['cols']) && !$params['no_integration']) self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']);
1017
+			if (!isset($params['cols']) && !$params['no_integration']) self::get_union_selects($selects, $start, $end, $users, $cat_id, $filter, $params['query'], $params['users']);
1019 1018
 
1020
-			$rs = $this->db->union($selects,__LINE__,__FILE__,$params['order'],$offset,$num_rows);
1019
+			$rs = $this->db->union($selects, __LINE__, __FILE__, $params['order'], $offset, $num_rows);
1021 1020
 		}
1022 1021
 		else	// MsSQL oder MySQL 3.23
1023 1022
 		{
@@ -1040,27 +1039,27 @@  discard block
 block discarded – undo
1040 1039
 				$selects[0]['cols'] = "$this->cal_table.cal_id,cal_start";
1041 1040
 				if (!isset($params['cols']) && !$params['no_integration'] && $this->db->capabilities['union'])
1042 1041
 				{
1043
-					self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']);
1042
+					self::get_union_selects($selects, $start, $end, $users, $cat_id, $filter, $params['query'], $params['users']);
1044 1043
 				}
1045 1044
 				$this->total = $this->db->union($selects, __LINE__, __FILE__)->NumRows();
1046 1045
 				$selects = $save_selects;
1047 1046
 			}
1048 1047
 			if (!isset($params['cols']) && !$params['no_integration'] && $this->db->capabilities['union'])
1049 1048
 			{
1050
-				self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']);
1049
+				self::get_union_selects($selects, $start, $end, $users, $cat_id, $filter, $params['query'], $params['users']);
1051 1050
 			}
1052
-			$rs = $this->db->union($selects,__LINE__,__FILE__,$params['order'],$offset,$num_rows);
1051
+			$rs = $this->db->union($selects, __LINE__, __FILE__, $params['order'], $offset, $num_rows);
1053 1052
 		}
1054 1053
 		//error_log(__METHOD__."() useUnionQuery=$useUnionQuery --> query took ".(microtime(true)-$starttime).'s '.$rs->sql);
1055 1054
 
1056 1055
 		if (isset($params['cols']))
1057 1056
 		{
1058
-			return $rs;	// if colums are specified we return the recordset / iterator
1057
+			return $rs; // if colums are specified we return the recordset / iterator
1059 1058
 		}
1060 1059
 		// Todo: return $this->get_events($rs);
1061 1060
 
1062 1061
 		$events = $ids = $recur_dates = $recur_ids = array();
1063
-		foreach($rs as $row)
1062
+		foreach ($rs as $row)
1064 1063
 		{
1065 1064
 			$id = $row['cal_id'];
1066 1065
 			if (is_numeric($id)) $ids[] = $id;
@@ -1072,9 +1071,9 @@  discard block
 block discarded – undo
1072 1071
 			}
1073 1072
 			if ($row['participants'])
1074 1073
 			{
1075
-				$row['participants'] = explode(',',$row['participants']);
1074
+				$row['participants'] = explode(',', $row['participants']);
1076 1075
 				$row['participants'] = array_combine($row['participants'],
1077
-					array_fill(0,count($row['participants']),''));
1076
+					array_fill(0, count($row['participants']), ''));
1078 1077
 			}
1079 1078
 			else
1080 1079
 			{
@@ -1083,9 +1082,9 @@  discard block
 block discarded – undo
1083 1082
 			$row['recur_exception'] = $row['alarm'] = array();
1084 1083
 
1085 1084
 			// compile a list of recurrences per cal_id
1086
-			if (!in_array($id,(array)$recur_ids[$row['cal_id']])) $recur_ids[$row['cal_id']][] = $id;
1085
+			if (!in_array($id, (array)$recur_ids[$row['cal_id']])) $recur_ids[$row['cal_id']][] = $id;
1087 1086
 
1088
-			$events[$id] = Api\Db::strip_array_keys($row,'cal_');
1087
+			$events[$id] = Api\Db::strip_array_keys($row, 'cal_');
1089 1088
 		}
1090 1089
 		//_debug_array($events);
1091 1090
 		if (count($ids))
@@ -1095,26 +1094,26 @@  discard block
 block discarded – undo
1095 1094
 			// now ready all users with the given cal_id AND (cal_recur_date=0 or the fitting recur-date)
1096 1095
 			// This will always read the first entry of each recuring event too, we eliminate it later
1097 1096
 			$recur_dates[] = 0;
1098
-			$utcal_id_view = " (SELECT * FROM ".$this->user_table." WHERE cal_id IN (".implode(',',$ids).")".
1097
+			$utcal_id_view = " (SELECT * FROM ".$this->user_table." WHERE cal_id IN (".implode(',', $ids).")".
1099 1098
 				($filter != 'everything' ? " AND cal_status NOT IN ('X','E')" : '').") utcalid ";
1100 1099
 			//$utrecurdate_view = " (select * from ".$this->user_table." where cal_recur_date in (".implode(',',array_unique($recur_dates)).")) utrecurdates ";
1101
-			foreach($this->db->select($utcal_id_view,'*',array(
1100
+			foreach ($this->db->select($utcal_id_view, '*', array(
1102 1101
 					//'cal_id' => array_unique($ids),
1103 1102
 					'cal_recur_date' => $recur_dates,
1104
-				),__LINE__,__FILE__,false,'ORDER BY cal_id,cal_user_type DESC,'.self::STATUS_SORT,'calendar',-1,$join='',
1105
-				$this->db->get_table_definitions('calendar',$this->user_table)) as $row)	// DESC puts users before resources and contacts
1103
+				), __LINE__, __FILE__, false, 'ORDER BY cal_id,cal_user_type DESC,'.self::STATUS_SORT, 'calendar', -1, $join = '',
1104
+				$this->db->get_table_definitions('calendar', $this->user_table)) as $row)	// DESC puts users before resources and contacts
1106 1105
 			{
1107 1106
 				$id = $row['cal_id'];
1108 1107
 				if ($row['cal_recur_date']) $id .= '-'.$row['cal_recur_date'];
1109 1108
 
1110 1109
 				// combine all participant data in uid and status values
1111 1110
 				$uid = self::combine_user($row['cal_user_type'], $row['cal_user_id'], $row['cal_user_attendee']);
1112
-				$status = self::combine_status($row['cal_status'],$row['cal_quantity'],$row['cal_role']);
1111
+				$status = self::combine_status($row['cal_status'], $row['cal_quantity'], $row['cal_role']);
1113 1112
 
1114 1113
 				// set accept/reject/tentative of series for all recurrences
1115 1114
 				if (!$row['cal_recur_date'])
1116 1115
 				{
1117
-					foreach((array)$recur_ids[$row['cal_id']] as $i)
1116
+					foreach ((array)$recur_ids[$row['cal_id']] as $i)
1118 1117
 					{
1119 1118
 						if (isset($events[$i]) && !isset($events[$i]['participants'][$uid]))
1120 1119
 						{
@@ -1129,16 +1128,16 @@  discard block
 block discarded – undo
1129 1128
 			// query recurrance exceptions, if needed: enum_recuring && !daywise is used in calendar_groupdav::get_series($uid,...)
1130 1129
 			if (!$params['enum_recuring'] || !$params['daywise'])
1131 1130
 			{
1132
-				foreach($this->db->select($this->dates_table, 'cal_id,cal_start', array(
1131
+				foreach ($this->db->select($this->dates_table, 'cal_id,cal_start', array(
1133 1132
 					'cal_id' => $ids,
1134 1133
 					'recur_exception' => true,
1135 1134
 				), __LINE__, __FILE__, false, 'ORDER BY cal_id,cal_start', 'calendar') as $row)
1136 1135
 				{
1137 1136
 					// for enum_recurring events are not indexed by cal_id, but $cal_id.'-'.$cal_start
1138 1137
 					// find master, which is first recurrence
1139
-					if (!isset($events[$id=$row['cal_id']]))
1138
+					if (!isset($events[$id = $row['cal_id']]))
1140 1139
 					{
1141
-						foreach($events as $id => $event)
1140
+						foreach ($events as $id => $event)
1142 1141
 						{
1143 1142
 							if ($event['id'] == $row['cal_id']) break;
1144 1143
 						}
@@ -1151,10 +1150,10 @@  discard block
 block discarded – undo
1151 1150
 			{
1152 1151
 				$where = array('cal_id' => $ids);
1153 1152
 				if ($params['cfs']) $where['cal_extra_name'] = $params['cfs'];
1154
-				foreach($this->db->select($this->extra_table,'*',$where,
1155
-					__LINE__,__FILE__,false,'','calendar') as $row)
1153
+				foreach ($this->db->select($this->extra_table, '*', $where,
1154
+					__LINE__, __FILE__, false, '', 'calendar') as $row)
1156 1155
 				{
1157
-					foreach((array)$recur_ids[$row['cal_id']] as $id)
1156
+					foreach ((array)$recur_ids[$row['cal_id']] as $id)
1158 1157
 					{
1159 1158
 						if (isset($events[$id]))
1160 1159
 						{
@@ -1164,9 +1163,9 @@  discard block
 block discarded – undo
1164 1163
 				}
1165 1164
 			}
1166 1165
 			// alarms
1167
-			foreach($this->read_alarms($ids) as $cal_id => $alarms)
1166
+			foreach ($this->read_alarms($ids) as $cal_id => $alarms)
1168 1167
 			{
1169
-				foreach($alarms as $id => $alarm)
1168
+				foreach ($alarms as $id => $alarm)
1170 1169
 				{
1171 1170
 					$event_start = $alarm['time'] + $alarm['offset'];
1172 1171
 
@@ -1203,16 +1202,16 @@  discard block
 block discarded – undo
1203 1202
 	 * @param $query
1204 1203
 	 * @param $users_raw as passed to calendar_bo::search (no members and memberships added)
1205 1204
 	 */
1206
-	private static function get_union_selects(array &$selects,$start,$end,$users,$cat_id,$filter,$query,$users_raw)
1205
+	private static function get_union_selects(array &$selects, $start, $end, $users, $cat_id, $filter, $query, $users_raw)
1207 1206
 	{
1208
-		if (in_array(basename($_SERVER['SCRIPT_FILENAME']),array('groupdav.php','rpc.php','xmlrpc.php','/activesync/index.php')) ||
1209
-			!in_array($GLOBALS['egw_info']['flags']['currentapp'],array('calendar','home')))
1207
+		if (in_array(basename($_SERVER['SCRIPT_FILENAME']), array('groupdav.php', 'rpc.php', 'xmlrpc.php', '/activesync/index.php')) ||
1208
+			!in_array($GLOBALS['egw_info']['flags']['currentapp'], array('calendar', 'home')))
1210 1209
 		{
1211
-			return;    // disable integration for GroupDAV, SyncML, ...
1210
+			return; // disable integration for GroupDAV, SyncML, ...
1212 1211
 		}
1213 1212
 		self::$integration_data = Api\Hooks::process(array(
1214 1213
 			'location' => 'calendar_search_union',
1215
-			'cols'  => $selects[0]['cols'],    // cols to return
1214
+			'cols'  => $selects[0]['cols'], // cols to return
1216 1215
 			'start' => $start,
1217 1216
 			'end'   => $end,
1218 1217
 			'users' => $users,
@@ -1221,12 +1220,12 @@  discard block
 block discarded – undo
1221 1220
 			'filter'=> $filter,
1222 1221
 			'query' => $query,
1223 1222
 		));
1224
-		foreach(self::$integration_data as $data)
1223
+		foreach (self::$integration_data as $data)
1225 1224
 		{
1226 1225
 			if (is_array($data['selects']))
1227 1226
 			{
1228 1227
 				//echo $app; _debug_array($data);
1229
-				$selects = array_merge($selects,$data['selects']);
1228
+				$selects = array_merge($selects, $data['selects']);
1230 1229
 			}
1231 1230
 		}
1232 1231
 	}
@@ -1251,35 +1250,35 @@  discard block
 block discarded – undo
1251 1250
 	 * @param string $required_app ='calendar'
1252 1251
 	 * @return string cols for union query to match ones supplied in $required
1253 1252
 	 */
1254
-	public static function union_cols(array $app_cols,$required,$required_app='calendar')
1253
+	public static function union_cols(array $app_cols, $required, $required_app = 'calendar')
1255 1254
 	{
1256 1255
 		// remove evtl. used DISTINCT, we currently dont need it
1257
-		if (($distinct = substr($required,0,9) == 'DISTINCT '))
1256
+		if (($distinct = substr($required, 0, 9) == 'DISTINCT '))
1258 1257
 		{
1259
-			$required = substr($required,9);
1258
+			$required = substr($required, 9);
1260 1259
 		}
1261 1260
 		$return_cols = array();
1262
-		foreach(is_array($required) ? $required : explode(',',$required) as $cols)
1261
+		foreach (is_array($required) ? $required : explode(',', $required) as $cols)
1263 1262
 		{
1264 1263
 			$matches = null;
1265
-			if (substr($cols,-2) == '.*')
1264
+			if (substr($cols, -2) == '.*')
1266 1265
 			{
1267
-				$cols = self::get_columns($required_app,substr($cols,0,-2));
1266
+				$cols = self::get_columns($required_app, substr($cols, 0, -2));
1268 1267
 			}
1269 1268
 			// remove CAST added for PostgreSQL from eg. "CAST(egw_cal.cal_id AS varchar)"
1270 1269
 			elseif (preg_match('/CAST\(([a-z0-9_.]+) AS [a-z0-9_]+\)/i', $cols, $matches))
1271 1270
 			{
1272 1271
 				$cols = $matches[1];
1273 1272
 			}
1274
-			elseif (strpos($cols,' AS ') !== false)
1273
+			elseif (strpos($cols, ' AS ') !== false)
1275 1274
 			{
1276
-				list(,$cols) = explode(' AS ',$cols);
1275
+				list(,$cols) = explode(' AS ', $cols);
1277 1276
 			}
1278
-			foreach((array)$cols as $col)
1277
+			foreach ((array)$cols as $col)
1279 1278
 			{
1280
-				if (substr($col,0,7) == 'egw_cal')	// remove table name
1279
+				if (substr($col, 0, 7) == 'egw_cal')	// remove table name
1281 1280
 				{
1282
-					$col = preg_replace('/^egw_cal[a-z_]*\./','',$col);
1281
+					$col = preg_replace('/^egw_cal[a-z_]*\./', '', $col);
1283 1282
 				}
1284 1283
 				if (isset($app_cols[$col]))
1285 1284
 				{
@@ -1292,7 +1291,7 @@  discard block
 block discarded – undo
1292 1291
 			}
1293 1292
 		}
1294 1293
 		//error_log(__METHOD__."(".array2string($app_cols).", ".array2string($required).", '$required_app') returning ".array2string(implode(',',$return_cols)));
1295
-		return implode(',',$return_cols);
1294
+		return implode(',', $return_cols);
1296 1295
 	}
1297 1296
 
1298 1297
 	/**
@@ -1302,21 +1301,21 @@  discard block
 block discarded – undo
1302 1301
 	 * @param string $table
1303 1302
 	 * @return array of column names
1304 1303
 	 */
1305
-	static private function get_columns($app,$table)
1304
+	static private function get_columns($app, $table)
1306 1305
 	{
1307 1306
 		if ($table != 'egw_cal')
1308 1307
 		{
1309
-			$table_def = $GLOBALS['egw']->db->get_table_definitions($app,$table);
1308
+			$table_def = $GLOBALS['egw']->db->get_table_definitions($app, $table);
1310 1309
 			$cols = array_keys($table_def['fd']);
1311 1310
 		}
1312 1311
 		else
1313 1312
 		{
1314 1313
 			// special handling for egw_cal, as old databases have a different column order!!!
1315
-			$cols =& Api\Cache::getSession(__CLASS__,$table);
1314
+			$cols = & Api\Cache::getSession(__CLASS__, $table);
1316 1315
 
1317 1316
 			if (is_null($cols))
1318 1317
 			{
1319
-				$meta = $GLOBALS['egw']->db->metadata($table,true);
1318
+				$meta = $GLOBALS['egw']->db->metadata($table, true);
1320 1319
 				$cols = array_keys($meta['meta']);
1321 1320
 			}
1322 1321
 		}
@@ -1369,12 +1368,12 @@  discard block
 block discarded – undo
1369 1368
 	 * @param int &$etag etag=null etag to check or null, on return new etag
1370 1369
 	 * @return boolean|int false on error, 0 if etag does not match, cal_id otherwise
1371 1370
 	 */
1372
-	function save(&$event,&$set_recurrences,&$set_recurrences_start=0,$change_since=0,&$etag=null)
1371
+	function save(&$event, &$set_recurrences, &$set_recurrences_start = 0, $change_since = 0, &$etag = null)
1373 1372
 	{
1374 1373
 		if (isset($GLOBALS['egw_info']['user']['preferences']['syncml']['minimum_uid_length']))
1375 1374
 		{
1376 1375
 			$minimum_uid_length = $GLOBALS['egw_info']['user']['preferences']['syncml']['minimum_uid_length'];
1377
-			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!
1376
+			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!
1378 1377
 		}
1379 1378
 		else
1380 1379
 		{
@@ -1385,7 +1384,7 @@  discard block
 block discarded – undo
1385 1384
 
1386 1385
 		//error_log(__METHOD__.'('.array2string($event).",$set_recurrences,$change_since,$etag) ".function_backtrace());
1387 1386
 
1388
-		$cal_id = (int) $event['id'];
1387
+		$cal_id = (int)$event['id'];
1389 1388
 		unset($event['id']);
1390 1389
 		$set_recurrences = $set_recurrences || !$cal_id && $event['recur_type'] != MCAL_RECUR_NONE;
1391 1390
 
@@ -1396,9 +1395,9 @@  discard block
 block discarded – undo
1396 1395
 		}
1397 1396
 
1398 1397
 		// add colum prefix 'cal_' if there's not already a 'recur_' prefix
1399
-		foreach(array_keys($event) as $col)
1398
+		foreach (array_keys($event) as $col)
1400 1399
 		{
1401
-			if ($col[0] != '#' && substr($col,0,6) != 'recur_' && substr($col,0,6) != 'range_' && $col != 'alarm' && $col != 'tz_id' && $col != 'caldav_name')
1400
+			if ($col[0] != '#' && substr($col, 0, 6) != 'recur_' && substr($col, 0, 6) != 'range_' && $col != 'alarm' && $col != 'tz_id' && $col != 'caldav_name')
1402 1401
 			{
1403 1402
 				$event['cal_'.$col] = $event[$col];
1404 1403
 				unset($event[$col]);
@@ -1408,13 +1407,12 @@  discard block
 block discarded – undo
1408 1407
 		if (isset($event['cal_start'])) $event['range_start'] = $event['cal_start'];
1409 1408
 		if (isset($event['cal_end']))
1410 1409
 		{
1411
-			$event['range_end'] = $event['recur_type'] == MCAL_RECUR_NONE ? $event['cal_end'] :
1412
-				($event['recur_enddate'] ? $event['recur_enddate'] : null);
1410
+			$event['range_end'] = $event['recur_type'] == MCAL_RECUR_NONE ? $event['cal_end'] : ($event['recur_enddate'] ? $event['recur_enddate'] : null);
1413 1411
 		}
1414 1412
 		// ensure that we find mathing entries later on
1415 1413
 		if (!is_array($event['cal_category']))
1416 1414
 		{
1417
-			$categories = array_unique(explode(',',$event['cal_category']));
1415
+			$categories = array_unique(explode(',', $event['cal_category']));
1418 1416
 			sort($categories);
1419 1417
 		}
1420 1418
 		else
@@ -1423,7 +1421,7 @@  discard block
 block discarded – undo
1423 1421
 		}
1424 1422
 		sort($categories, SORT_NUMERIC);
1425 1423
 
1426
-		$event['cal_category'] = implode(',',$categories);
1424
+		$event['cal_category'] = implode(',', $categories);
1427 1425
 
1428 1426
 		// make sure recurring events never reference to an other recurrent event
1429 1427
 		if ($event['recur_type'] != MCAL_RECUR_NONE) $event['cal_reference'] = 0;
@@ -1441,18 +1439,18 @@  discard block
 block discarded – undo
1441 1439
 			// read only timezone id, to check if it is changed
1442 1440
 			if ($event['recur_type'] != MCAL_RECUR_NONE)
1443 1441
 			{
1444
-				$old_tz_id = $this->db->select($this->cal_table,'tz_id',$where,__LINE__,__FILE__,'calendar')->fetchColumn();
1442
+				$old_tz_id = $this->db->select($this->cal_table, 'tz_id', $where, __LINE__, __FILE__, 'calendar')->fetchColumn();
1445 1443
 			}
1446 1444
 			if (!is_null($etag)) $where['cal_etag'] = $etag;
1447 1445
 
1448 1446
 			unset($event['cal_etag']);
1449
-			$event[] = 'cal_etag=COALESCE(cal_etag,0)+1';	// always update the etag, even if none given to check
1447
+			$event[] = 'cal_etag=COALESCE(cal_etag,0)+1'; // always update the etag, even if none given to check
1450 1448
 
1451
-			$this->db->update($this->cal_table,$event,$where,__LINE__,__FILE__,'calendar');
1449
+			$this->db->update($this->cal_table, $event, $where, __LINE__, __FILE__, 'calendar');
1452 1450
 
1453 1451
 			if (!is_null($etag) && $this->db->affected_rows() < 1)
1454 1452
 			{
1455
-				return 0;	// wrong etag, someone else updated the entry
1453
+				return 0; // wrong etag, someone else updated the entry
1456 1454
 			}
1457 1455
 			if (!is_null($etag)) ++$etag;
1458 1456
 		}
@@ -1461,11 +1459,11 @@  discard block
 block discarded – undo
1461 1459
 			// new event
1462 1460
 			if (!$event['cal_owner']) $event['cal_owner'] = $GLOBALS['egw_info']['user']['account_id'];
1463 1461
 
1464
-			if (!$event['cal_id'] && !isset($event['cal_uid'])) $event['cal_uid'] = '';	// uid is NOT NULL!
1462
+			if (!$event['cal_id'] && !isset($event['cal_uid'])) $event['cal_uid'] = ''; // uid is NOT NULL!
1465 1463
 
1466 1464
 			$event['cal_etag'] = $etag = 0;
1467
-			$this->db->insert($this->cal_table,$event,false,__LINE__,__FILE__,'calendar');
1468
-			if (!($cal_id = $this->db->get_last_insert_id($this->cal_table,'cal_id')))
1465
+			$this->db->insert($this->cal_table, $event, false, __LINE__, __FILE__, 'calendar');
1466
+			if (!($cal_id = $this->db->get_last_insert_id($this->cal_table, 'cal_id')))
1469 1467
 			{
1470 1468
 				return false;
1471 1469
 			}
@@ -1474,7 +1472,7 @@  discard block
 block discarded – undo
1474 1472
 		// event without uid or not strong enough uid
1475 1473
 		if (!isset($event['cal_uid']) || strlen($event['cal_uid']) < $minimum_uid_length)
1476 1474
 		{
1477
-			$update['cal_uid'] = $event['cal_uid'] = Api\CalDAV::generate_uid('calendar',$cal_id);
1475
+			$update['cal_uid'] = $event['cal_uid'] = Api\CalDAV::generate_uid('calendar', $cal_id);
1478 1476
 		}
1479 1477
 		// set caldav_name, if not given by caller
1480 1478
 		if (empty($event['caldav_name']) && version_compare($GLOBALS['egw_info']['apps']['calendar']['version'], '1.9.003', '>='))
@@ -1483,37 +1481,37 @@  discard block
 block discarded – undo
1483 1481
 		}
1484 1482
 		if ($update)
1485 1483
 		{
1486
-			$this->db->update($this->cal_table, $update, array('cal_id' => $cal_id),__LINE__,__FILE__,'calendar');
1484
+			$this->db->update($this->cal_table, $update, array('cal_id' => $cal_id), __LINE__, __FILE__, 'calendar');
1487 1485
 		}
1488 1486
 
1489 1487
 		if ($event['recur_type'] == MCAL_RECUR_NONE)
1490 1488
 		{
1491
-			$this->db->delete($this->dates_table,array(
1489
+			$this->db->delete($this->dates_table, array(
1492 1490
 				'cal_id' => $cal_id),
1493
-				__LINE__,__FILE__,'calendar');
1491
+				__LINE__, __FILE__, 'calendar');
1494 1492
 
1495 1493
 			// delete all user-records, with recur-date != 0
1496
-			$this->db->delete($this->user_table,array(
1494
+			$this->db->delete($this->user_table, array(
1497 1495
 				'cal_id' => $cal_id, 'cal_recur_date != 0'),
1498
-				__LINE__,__FILE__,'calendar');
1496
+				__LINE__, __FILE__, 'calendar');
1499 1497
 
1500
-			$this->db->delete($this->repeats_table,array(
1498
+			$this->db->delete($this->repeats_table, array(
1501 1499
 				'cal_id' => $cal_id),
1502
-				__LINE__,__FILE__,'calendar');
1500
+				__LINE__, __FILE__, 'calendar');
1503 1501
 
1504 1502
 			// add exception marker to master, so participants added to exceptions *only* get found
1505 1503
 			if ($event['cal_reference'])
1506 1504
 			{
1507 1505
 				$master_participants = array();
1508
-				foreach($this->db->select($this->user_table, 'cal_user_type,cal_user_id,cal_user_attendee', array(
1506
+				foreach ($this->db->select($this->user_table, 'cal_user_type,cal_user_id,cal_user_attendee', array(
1509 1507
 					'cal_id' => $event['cal_reference'],
1510 1508
 					'cal_recur_date' => 0,
1511
-					"cal_status != 'X'",	// deleted need to be replaced with exception marker too
1509
+					"cal_status != 'X'", // deleted need to be replaced with exception marker too
1512 1510
 				), __LINE__, __FILE__, 'calendar') as $row)
1513 1511
 				{
1514 1512
 					$master_participants[] = self::combine_user($row['cal_user_type'], $row['cal_user_id'], $row['cal_user_attendee']);
1515 1513
 				}
1516
-				foreach(array_diff(array_keys((array)$event['cal_participants']), $master_participants) as $uid)
1514
+				foreach (array_diff(array_keys((array)$event['cal_participants']), $master_participants) as $uid)
1517 1515
 				{
1518 1516
 					$user_type = $user_id = null;
1519 1517
 					self::split_user($uid, $user_type, $user_id, true);
@@ -1532,10 +1530,10 @@  discard block
 block discarded – undo
1532 1530
 		else // write information about recuring event, if recur_type is present in the array
1533 1531
 		{
1534 1532
 			// fetch information about the currently saved (old) event
1535
-			$old_min = (int) $this->db->select($this->dates_table,'MIN(cal_start)',array('cal_id'=>$cal_id),__LINE__,__FILE__,false,'','calendar')->fetchColumn();
1536
-			$old_duration = (int) $this->db->select($this->dates_table,'MIN(cal_end)',array('cal_id'=>$cal_id),__LINE__,__FILE__,false,'','calendar')->fetchColumn() - $old_min;
1533
+			$old_min = (int)$this->db->select($this->dates_table, 'MIN(cal_start)', array('cal_id'=>$cal_id), __LINE__, __FILE__, false, '', 'calendar')->fetchColumn();
1534
+			$old_duration = (int)$this->db->select($this->dates_table, 'MIN(cal_end)', array('cal_id'=>$cal_id), __LINE__, __FILE__, false, '', 'calendar')->fetchColumn() - $old_min;
1537 1535
 			$old_exceptions = array();
1538
-			foreach($this->db->select($this->dates_table, 'cal_start', array(
1536
+			foreach ($this->db->select($this->dates_table, 'cal_start', array(
1539 1537
 				'cal_id' => $cal_id,
1540 1538
 				'recur_exception' => true
1541 1539
 			), __LINE__, __FILE__, false, 'ORDER BY cal_start', 'calendar') as $row)
@@ -1554,8 +1552,8 @@  discard block
 block discarded – undo
1554 1552
 				'cal_recur_date' => 0,
1555 1553
 			);
1556 1554
 			$old_participants = array();
1557
-			foreach ($this->db->select($this->user_table,'cal_user_type,cal_user_id,cal_user_attendee,cal_status,cal_quantity,cal_role', $where,
1558
-				__LINE__,__FILE__,false,'','calendar') as $row)
1555
+			foreach ($this->db->select($this->user_table, 'cal_user_type,cal_user_id,cal_user_attendee,cal_status,cal_quantity,cal_role', $where,
1556
+				__LINE__, __FILE__, false, '', 'calendar') as $row)
1559 1557
 			{
1560 1558
 				$uid = self::combine_user($row['cal_user_type'], $row['cal_user_id'], $row['cal_user_attendee']);
1561 1559
 				$status = self::combine_status($row['cal_status'], $row['cal_quantity'], $row['cal_role']);
@@ -1565,7 +1563,7 @@  discard block
 block discarded – undo
1565 1563
 			// re-check: did so much recurrence data change that we have to rebuild it from scratch?
1566 1564
 			if (!$set_recurrences)
1567 1565
 			{
1568
-				$set_recurrences = (isset($event['cal_start']) && (int)$old_min != (int) $event['cal_start']) ||
1566
+				$set_recurrences = (isset($event['cal_start']) && (int)$old_min != (int)$event['cal_start']) ||
1569 1567
 				    $event['recur_type'] != $old_repeats['recur_type'] || $event['recur_data'] != $old_repeats['recur_data'] ||
1570 1568
 					(int)$event['recur_interval'] != (int)$old_repeats['recur_interval'] || $event['tz_id'] != $old_tz_id;
1571 1569
 			}
@@ -1574,22 +1572,22 @@  discard block
 block discarded – undo
1574 1572
 			{
1575 1573
 				// too much recurrence data has changed, we have to do a rebuild from scratch
1576 1574
 				// delete all, but the lowest dates record
1577
-				$this->db->delete($this->dates_table,array(
1575
+				$this->db->delete($this->dates_table, array(
1578 1576
 					'cal_id' => $cal_id,
1579 1577
 					'cal_start > '.(int)$old_min,
1580
-				),__LINE__,__FILE__,'calendar');
1578
+				), __LINE__, __FILE__, 'calendar');
1581 1579
 
1582 1580
 				// delete all user-records, with recur-date != 0
1583
-				$this->db->delete($this->user_table,array(
1581
+				$this->db->delete($this->user_table, array(
1584 1582
 					'cal_id' => $cal_id,
1585 1583
 					'cal_recur_date != 0',
1586
-				),__LINE__,__FILE__,'calendar');
1584
+				), __LINE__, __FILE__, 'calendar');
1587 1585
 			}
1588 1586
 			else
1589 1587
 			{
1590 1588
 				// we adjust some possibly changed recurrences manually
1591 1589
 				// deleted exceptions: re-insert recurrences into the user and dates table
1592
-				if (count($deleted_exceptions = array_diff($old_exceptions,$event['recur_exception'])))
1590
+				if (count($deleted_exceptions = array_diff($old_exceptions, $event['recur_exception'])))
1593 1591
 				{
1594 1592
 					if (isset($event['cal_participants']))
1595 1593
 					{
@@ -1600,7 +1598,7 @@  discard block
 block discarded – undo
1600 1598
 						// use old default
1601 1599
 						$participants = $old_participants;
1602 1600
 					}
1603
-					foreach($deleted_exceptions as $id => $deleted_exception)
1601
+					foreach ($deleted_exceptions as $id => $deleted_exception)
1604 1602
 					{
1605 1603
 						// rebuild participants for the re-inserted recurrence
1606 1604
 						$this->recurrence($cal_id, $deleted_exception, $deleted_exception + $old_duration, $participants);
@@ -1608,24 +1606,24 @@  discard block
 block discarded – undo
1608 1606
 				}
1609 1607
 
1610 1608
 				// check if recurrence enddate was adjusted
1611
-				if(isset($event['recur_enddate']))
1609
+				if (isset($event['recur_enddate']))
1612 1610
 				{
1613 1611
 					// recurrences need to be truncated
1614
-					if((int)$event['recur_enddate'] > 0 &&
1612
+					if ((int)$event['recur_enddate'] > 0 &&
1615 1613
 						((int)$old_repeats['recur_enddate'] == 0 || (int)$old_repeats['recur_enddate'] > (int)$event['recur_enddate'])
1616 1614
 					)
1617 1615
 					{
1618
-						$this->db->delete($this->user_table,array('cal_id' => $cal_id,'cal_recur_date >= '.($event['recur_enddate'] + 1*DAY_s)),__LINE__,__FILE__,'calendar');
1619
-						$this->db->delete($this->dates_table,array('cal_id' => $cal_id,'cal_start >= '.($event['recur_enddate'] + 1*DAY_s)),__LINE__,__FILE__,'calendar');
1616
+						$this->db->delete($this->user_table, array('cal_id' => $cal_id, 'cal_recur_date >= '.($event['recur_enddate'] + 1 * DAY_s)), __LINE__, __FILE__, 'calendar');
1617
+						$this->db->delete($this->dates_table, array('cal_id' => $cal_id, 'cal_start >= '.($event['recur_enddate'] + 1 * DAY_s)), __LINE__, __FILE__, 'calendar');
1620 1618
 					}
1621 1619
 
1622 1620
 					// recurrences need to be expanded
1623
-					if(((int)$event['recur_enddate'] == 0 && (int)$old_repeats['recur_enddate'] > 0)
1621
+					if (((int)$event['recur_enddate'] == 0 && (int)$old_repeats['recur_enddate'] > 0)
1624 1622
 						|| ((int)$event['recur_enddate'] > 0 && (int)$old_repeats['recur_enddate'] > 0 && (int)$old_repeats['recur_enddate'] < (int)$event['recur_enddate'])
1625 1623
 					)
1626 1624
 					{
1627 1625
 						$set_recurrences = true;
1628
-						$set_recurrences_start = ($old_repeats['recur_enddate'] + 1*DAY_s);
1626
+						$set_recurrences_start = ($old_repeats['recur_enddate'] + 1 * DAY_s);
1629 1627
 					}
1630 1628
 					//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");
1631 1629
 				}
@@ -1634,9 +1632,9 @@  discard block
 block discarded – undo
1634 1632
 				if (count($event['recur_exception']))
1635 1633
 				{
1636 1634
 					// added and existing exceptions: delete the execeptions from the user table, it could be the first time
1637
-					$this->db->delete($this->user_table,array('cal_id' => $cal_id,'cal_recur_date' => $event['recur_exception']),__LINE__,__FILE__,'calendar');
1635
+					$this->db->delete($this->user_table, array('cal_id' => $cal_id, 'cal_recur_date' => $event['recur_exception']), __LINE__, __FILE__, 'calendar');
1638 1636
 					// update recur_exception flag based on current exceptions
1639
-					$this->db->update($this->dates_table, 'recur_exception='.$this->db->expression($this->dates_table,array(
1637
+					$this->db->update($this->dates_table, 'recur_exception='.$this->db->expression($this->dates_table, array(
1640 1638
 						'cal_start' => $event['recur_exception'],
1641 1639
 					)), array(
1642 1640
 						'cal_id' => $cal_id,
@@ -1645,27 +1643,27 @@  discard block
 block discarded – undo
1645 1643
 			}
1646 1644
 
1647 1645
 			// write the repeats table
1648
-			unset($event[0]);	// unset the 'etag=etag+1', as it's not in the repeats table
1649
-			$this->db->insert($this->repeats_table,$event,array('cal_id' => $cal_id),__LINE__,__FILE__,'calendar');
1646
+			unset($event[0]); // unset the 'etag=etag+1', as it's not in the repeats table
1647
+			$this->db->insert($this->repeats_table, $event, array('cal_id' => $cal_id), __LINE__, __FILE__, 'calendar');
1650 1648
 		}
1651 1649
 		// update start- and endtime if present in the event-array, evtl. we need to move all recurrences
1652 1650
 		if (isset($event['cal_start']) && isset($event['cal_end']))
1653 1651
 		{
1654
-			$this->move($cal_id,$event['cal_start'],$event['cal_end'],!$cal_id ? false : $change_since, $old_min, $old_min +  $old_duration);
1652
+			$this->move($cal_id, $event['cal_start'], $event['cal_end'], !$cal_id ? false : $change_since, $old_min, $old_min + $old_duration);
1655 1653
 		}
1656 1654
 		// update participants if present in the event-array
1657 1655
 		if (isset($event['cal_participants']))
1658 1656
 		{
1659
-			$this->participants($cal_id,$event['cal_participants'],!$cal_id ? false : $change_since);
1657
+			$this->participants($cal_id, $event['cal_participants'], !$cal_id ? false : $change_since);
1660 1658
 		}
1661 1659
 		// Custom fields
1662 1660
 		Api\Storage\Customfields::handle_files('calendar', $cal_id, $event);
1663 1661
 
1664
-		foreach($event as $name => $value)
1662
+		foreach ($event as $name => $value)
1665 1663
 		{
1666 1664
 			if ($name[0] == '#')
1667 1665
 			{
1668
-				if (is_array($value) && array_key_exists('id',$value))
1666
+				if (is_array($value) && array_key_exists('id', $value))
1669 1667
 				{
1670 1668
 					//error_log(__METHOD__.__LINE__."$name => ".array2string($value).function_backtrace());
1671 1669
 					$value = $value['id'];
@@ -1673,19 +1671,19 @@  discard block
 block discarded – undo
1673 1671
 				}
1674 1672
 				if ($value)
1675 1673
 				{
1676
-					$this->db->insert($this->extra_table,array(
1677
-						'cal_extra_value'	=> is_array($value) ? implode(',',$value) : $value,
1678
-					),array(
1674
+					$this->db->insert($this->extra_table, array(
1675
+						'cal_extra_value'	=> is_array($value) ? implode(',', $value) : $value,
1676
+					), array(
1679 1677
 						'cal_id'			=> $cal_id,
1680
-						'cal_extra_name'	=> substr($name,1),
1681
-					),__LINE__,__FILE__,'calendar');
1678
+						'cal_extra_name'	=> substr($name, 1),
1679
+					), __LINE__, __FILE__, 'calendar');
1682 1680
 				}
1683 1681
 				else
1684 1682
 				{
1685
-					$this->db->delete($this->extra_table,array(
1683
+					$this->db->delete($this->extra_table, array(
1686 1684
 						'cal_id'			=> $cal_id,
1687
-						'cal_extra_name'	=> substr($name,1),
1688
-					),__LINE__,__FILE__,'calendar');
1685
+						'cal_extra_name'	=> substr($name, 1),
1686
+					), __LINE__, __FILE__, 'calendar');
1689 1687
 				}
1690 1688
 			}
1691 1689
 		}
@@ -1696,9 +1694,9 @@  discard block
 block discarded – undo
1696 1694
 			{
1697 1695
 				if ($alarm['id'] && strpos($alarm['id'], 'cal:'.$cal_id.':') !== 0)
1698 1696
 				{
1699
-					unset($alarm['id']);	// unset the temporary id to add the alarm
1697
+					unset($alarm['id']); // unset the temporary id to add the alarm
1700 1698
 				}
1701
-				if(!isset($alarm['offset']))
1699
+				if (!isset($alarm['offset']))
1702 1700
 				{
1703 1701
 					$alarm['offset'] = $event['cal_start'] - $alarm['time'];
1704 1702
 				}
@@ -1709,14 +1707,14 @@  discard block
 block discarded – undo
1709 1707
 
1710 1708
 				if ($alarm['time'] < time() && !self::shift_alarm($event, $alarm))
1711 1709
 				{
1712
-					continue;	// pgoerzen: don't add alarm in the past
1710
+					continue; // pgoerzen: don't add alarm in the past
1713 1711
 				}
1714
-				$this->save_alarm($cal_id, $alarm, false);	// false: not update modified, we do it anyway
1712
+				$this->save_alarm($cal_id, $alarm, false); // false: not update modified, we do it anyway
1715 1713
 			}
1716 1714
 		}
1717 1715
 		if (is_null($etag))
1718 1716
 		{
1719
-			$etag = $this->db->select($this->cal_table,'cal_etag',array('cal_id' => $cal_id),__LINE__,__FILE__,false,'','calendar')->fetchColumn();
1717
+			$etag = $this->db->select($this->cal_table, 'cal_etag', array('cal_id' => $cal_id), __LINE__, __FILE__, false, '', 'calendar')->fetchColumn();
1720 1718
 		}
1721 1719
 
1722 1720
 		// if event is an exception: update modified of master, to force etag, ctag and sync-token change
@@ -1736,7 +1734,7 @@  discard block
 block discarded – undo
1736 1734
 	 *	are dealing with, default is now.
1737 1735
 	 * @return boolean true if alarm could be shifted, false if not
1738 1736
 	 */
1739
-	public static function shift_alarm(array $_event, array &$alarm, $timestamp=null)
1737
+	public static function shift_alarm(array $_event, array &$alarm, $timestamp = null)
1740 1738
 	{
1741 1739
 		if ($_event['recur_type'] == MCAL_RECUR_NONE)
1742 1740
 		{
@@ -1747,7 +1745,7 @@  discard block
 block discarded – undo
1747 1745
 		$rrule = calendar_rrule::event2rrule($event, false);
1748 1746
 		foreach ($rrule as $time)
1749 1747
 		{
1750
-			if ($start < ($ts = Api\DateTime::to($time,'server')))
1748
+			if ($start < ($ts = Api\DateTime::to($time, 'server')))
1751 1749
 			{
1752 1750
 				$alarm['time'] = $ts - $alarm['offset'];
1753 1751
 				return true;
@@ -1768,34 +1766,34 @@  discard block
 block discarded – undo
1768 1766
 	 * @todo Recalculate recurrences, if timezone changes
1769 1767
 	 * @return int|boolean number of moved recurrences or false on error
1770 1768
 	 */
1771
-	function move($cal_id,$start,$end,$change_since=0,$old_start=0,$old_end=0)
1769
+	function move($cal_id, $start, $end, $change_since = 0, $old_start = 0, $old_end = 0)
1772 1770
 	{
1773 1771
 		//echo "<p>socal::move($cal_id,$start,$end,$change_since,$old_start,$old_end)</p>\n";
1774 1772
 
1775
-		if (!(int) $cal_id) return false;
1773
+		if (!(int)$cal_id) return false;
1776 1774
 
1777 1775
 		if (!$old_start)
1778 1776
 		{
1779
-			if ($change_since !== false) $row = $this->db->select($this->dates_table,'MIN(cal_start) AS cal_start,MIN(cal_end) AS cal_end',
1780
-				array('cal_id'=>$cal_id),__LINE__,__FILE__,false,'','calendar')->fetch();
1777
+			if ($change_since !== false) $row = $this->db->select($this->dates_table, 'MIN(cal_start) AS cal_start,MIN(cal_end) AS cal_end',
1778
+				array('cal_id'=>$cal_id), __LINE__, __FILE__, false, '', 'calendar')->fetch();
1781 1779
 			// if no recurrence found, create one with the new dates
1782 1780
 			if ($change_since === false || !$row || !$row['cal_start'] || !$row['cal_end'])
1783 1781
 			{
1784
-				$this->db->insert($this->dates_table,array(
1782
+				$this->db->insert($this->dates_table, array(
1785 1783
 					'cal_id'    => $cal_id,
1786 1784
 					'cal_start' => $start,
1787 1785
 					'cal_end'   => $end,
1788
-				),false,__LINE__,__FILE__,'calendar');
1786
+				), false, __LINE__, __FILE__, 'calendar');
1789 1787
 
1790 1788
 				return 1;
1791 1789
 			}
1792
-			$move_start = (int) ($start-$row['cal_start']);
1793
-			$move_end   = (int) ($end-$row['cal_end']);
1790
+			$move_start = (int)($start - $row['cal_start']);
1791
+			$move_end   = (int)($end - $row['cal_end']);
1794 1792
 		}
1795 1793
 		else
1796 1794
 		{
1797
-			$move_start = (int) ($start-$old_start);
1798
-			$move_end   = (int) ($end-$old_end);
1795
+			$move_start = (int)($start - $old_start);
1796
+			$move_end   = (int)($end - $old_end);
1799 1797
 		}
1800 1798
 		$where = 'cal_id='.(int)$cal_id;
1801 1799
 
@@ -1803,13 +1801,13 @@  discard block
 block discarded – undo
1803 1801
 		{
1804 1802
 			// move the recur-date of the participants
1805 1803
 			$this->db->query("UPDATE $this->user_table SET cal_recur_date=cal_recur_date+$move_start WHERE $where AND cal_recur_date ".
1806
-				((int)$change_since ? '>= '.(int)$change_since : '!= 0'),__LINE__,__FILE__);
1804
+				((int)$change_since ? '>= '.(int)$change_since : '!= 0'), __LINE__, __FILE__);
1807 1805
 		}
1808 1806
 		if ($move_start || $move_end)
1809 1807
 		{
1810 1808
 			// move the event and it's recurrences
1811 1809
 			$this->db->query("UPDATE $this->dates_table SET cal_start=cal_start+$move_start,cal_end=cal_end+$move_end WHERE $where".
1812
-				((int) $change_since ? ' AND cal_start >= '.(int) $change_since : ''),__LINE__,__FILE__);
1810
+				((int)$change_since ? ' AND cal_start >= '.(int)$change_since : ''), __LINE__, __FILE__);
1813 1811
 		}
1814 1812
 		return $this->db->affected_rows();
1815 1813
 	}
@@ -1828,8 +1826,7 @@  discard block
 block discarded – undo
1828 1826
 		}
1829 1827
 		if (is_array($attendee))
1830 1828
 		{
1831
-			$email = !empty($attendee['email']) ? $user_attendee['email'] :
1832
-				(strtolower(substr($attendee['url'], 0, 7)) == 'mailto:' ? substr($user_attendee['url'], 7) : $attendee['url']);
1829
+			$email = !empty($attendee['email']) ? $user_attendee['email'] : (strtolower(substr($attendee['url'], 0, 7)) == 'mailto:' ? substr($user_attendee['url'], 7) : $attendee['url']);
1833 1830
 			$attendee = !empty($attendee['cn']) ? $attendee['cn'].' <'.$email.'>' : $email;
1834 1831
 		}
1835 1832
 		return $attendee;
@@ -1842,11 +1839,11 @@  discard block
 block discarded – undo
1842 1839
 	 * @param string|array $attendee attendee information: email, json or array with attr cn and url
1843 1840
 	 * @return string|int combined id
1844 1841
 	 */
1845
-	static function combine_user($user_type, $user_id, $attendee=null)
1842
+	static function combine_user($user_type, $user_id, $attendee = null)
1846 1843
 	{
1847 1844
 		if (!$user_type || $user_type == 'u')
1848 1845
 		{
1849
-			return (int) $user_id;
1846
+			return (int)$user_id;
1850 1847
 		}
1851 1848
 		if ($user_type == 'e' && $attendee)
1852 1849
 		{
@@ -1866,12 +1863,12 @@  discard block
 block discarded – undo
1866 1863
 	 * @param string|int &$user_id id
1867 1864
 	 * @param boolean $md5_email =false md5 hash user_id for email / user_type=="e"
1868 1865
 	 */
1869
-	static function split_user($uid, &$user_type, &$user_id, $md5_email=false)
1866
+	static function split_user($uid, &$user_type, &$user_id, $md5_email = false)
1870 1867
 	{
1871 1868
 		if (is_numeric($uid))
1872 1869
 		{
1873 1870
 			$user_type = 'u';
1874
-			$user_id = (int) $uid;
1871
+			$user_id = (int)$uid;
1875 1872
 		}
1876 1873
 		// create md5 hash from lowercased and trimed raw email ("[email protected]", not "Ralf Becker <[email protected]>")
1877 1874
 		elseif ($md5_email && $uid[0] == 'e')
@@ -1885,7 +1882,7 @@  discard block
 block discarded – undo
1885 1882
 		else
1886 1883
 		{
1887 1884
 			$user_type = $uid[0];
1888
-			$user_id = substr($uid,1);
1885
+			$user_id = substr($uid, 1);
1889 1886
 		}
1890 1887
 	}
1891 1888
 
@@ -1897,7 +1894,7 @@  discard block
 block discarded – undo
1897 1894
 	 * @param string $role ='REQ-PARTICIPANT'
1898 1895
 	 * @return string
1899 1896
 	 */
1900
-	static function combine_status($status,$quantity=1,$role='REQ-PARTICIPANT')
1897
+	static function combine_status($status, $quantity = 1, $role = 'REQ-PARTICIPANT')
1901 1898
 	{
1902 1899
 		if ((int)$quantity > 1) $status .= (int)$quantity;
1903 1900
 		if ($role != 'REQ-PARTICIPANT') $status .= $role;
@@ -1913,13 +1910,13 @@  discard block
 block discarded – undo
1913 1910
 	 * @param string &$role=null only O: role
1914 1911
 	 * @return string status U, T, A or R, same as $status parameter on return
1915 1912
 	 */
1916
-	static function split_status(&$status,&$quantity=null,&$role=null)
1913
+	static function split_status(&$status, &$quantity = null, &$role = null)
1917 1914
 	{
1918 1915
 		$quantity = 1;
1919 1916
 		$role = 'REQ-PARTICIPANT';
1920 1917
 		//error_log(__METHOD__.__LINE__.array2string($status));
1921 1918
 		$matches = null;
1922
-		if (is_string($status) && strlen($status) > 1 && preg_match('/^.([0-9]*)(.*)$/',$status,$matches))
1919
+		if (is_string($status) && strlen($status) > 1 && preg_match('/^.([0-9]*)(.*)$/', $status, $matches))
1923 1920
 		{
1924 1921
 			if ((int)$matches[1] > 0) $quantity = (int)$matches[1];
1925 1922
 			if ($matches[2]) $role = $matches[2];
@@ -1946,14 +1943,14 @@  discard block
 block discarded – undo
1946 1943
 	 *		true = only add participants if needed, no participant will be deleted (participants to check/add required in $participants)
1947 1944
 	 * @return int|boolean number of updated recurrences or false on error
1948 1945
 	 */
1949
-	function participants($cal_id,$participants,$change_since=0,$add_only=false)
1946
+	function participants($cal_id, $participants, $change_since = 0, $add_only = false)
1950 1947
 	{
1951 1948
 		//error_log(__METHOD__."($cal_id,".array2string($participants).",$change_since,$add_only");
1952 1949
 
1953 1950
 		$recurrences = array();
1954 1951
 
1955 1952
 		// remove group-invitations, they are NOT stored in the db
1956
-		foreach($participants as $uid => $status)
1953
+		foreach ($participants as $uid => $status)
1957 1954
 		{
1958 1955
 			if ($status[0] == 'G')
1959 1956
 			{
@@ -1962,7 +1959,7 @@  discard block
 block discarded – undo
1962 1959
 		}
1963 1960
 		$where = array('cal_id' => $cal_id);
1964 1961
 
1965
-		if ((int) $change_since)
1962
+		if ((int)$change_since)
1966 1963
 		{
1967 1964
 			$where[] = '(cal_recur_date=0 OR cal_recur_date >= '.(int)$change_since.')';
1968 1965
 		}
@@ -1970,31 +1967,31 @@  discard block
 block discarded – undo
1970 1967
 		if ($change_since !== false)
1971 1968
 		{
1972 1969
 			// find all existing recurrences
1973
-			foreach($this->db->select($this->user_table,'DISTINCT cal_recur_date',$where,__LINE__,__FILE__,false,'','calendar') as $row)
1970
+			foreach ($this->db->select($this->user_table, 'DISTINCT cal_recur_date', $where, __LINE__, __FILE__, false, '', 'calendar') as $row)
1974 1971
 			{
1975 1972
 				$recurrences[] = $row['cal_recur_date'];
1976 1973
 			}
1977 1974
 
1978 1975
 			// update existing entries
1979
-			$existing_entries = $this->db->select($this->user_table,'*',$where,__LINE__,__FILE__,false,'ORDER BY cal_recur_date DESC','calendar');
1976
+			$existing_entries = $this->db->select($this->user_table, '*', $where, __LINE__, __FILE__, false, 'ORDER BY cal_recur_date DESC', 'calendar');
1980 1977
 
1981 1978
 			// create a full list of participants which already exist in the db
1982 1979
 			// with status, quantity and role of the earliest recurence
1983 1980
 			$old_participants = array();
1984
-			foreach($existing_entries as $row)
1981
+			foreach ($existing_entries as $row)
1985 1982
 			{
1986 1983
 				$uid = self::combine_user($row['cal_user_type'], $row['cal_user_id'], $row['cal_user_attendee']);
1987 1984
 				if ($row['cal_recur_date'] || !isset($old_participants[$uid]))
1988 1985
 				{
1989
-					$old_participants[$uid] = self::combine_status($row['cal_status'],$row['cal_quantity'],$row['cal_role']);
1986
+					$old_participants[$uid] = self::combine_status($row['cal_status'], $row['cal_quantity'], $row['cal_role']);
1990 1987
 				}
1991 1988
 			}
1992 1989
 
1993 1990
 			// tag participants which should be deleted
1994
-			if($add_only === false)
1991
+			if ($add_only === false)
1995 1992
 			{
1996 1993
 				$deleted = array();
1997
-				foreach($existing_entries as $row)
1994
+				foreach ($existing_entries as $row)
1998 1995
 				{
1999 1996
 					$uid = self::combine_user($row['cal_user_type'], $row['cal_user_id'], $row['cal_user_attendee']);
2000 1997
 					// delete not longer set participants
@@ -2007,7 +2004,7 @@  discard block
 block discarded – undo
2007 2004
 
2008 2005
 			// only keep added OR status (incl. quantity!) changed participants for further steps
2009 2006
 			// we do not touch unchanged (!) existing ones
2010
-			foreach($participants as $uid => $status)
2007
+			foreach ($participants as $uid => $status)
2011 2008
 			{
2012 2009
 				if ($old_participants[$uid] === $status)
2013 2010
 				{
@@ -2019,46 +2016,46 @@  discard block
 block discarded – undo
2019 2016
 			if ($add_only === false && count($deleted))
2020 2017
 			{
2021 2018
 				$to_or = array();
2022
-				$table_def = $this->db->get_table_definitions('calendar',$this->user_table);
2023
-				foreach($deleted as $type => $ids)
2019
+				$table_def = $this->db->get_table_definitions('calendar', $this->user_table);
2020
+				foreach ($deleted as $type => $ids)
2024 2021
 				{
2025
-					$to_or[] = $this->db->expression($table_def,array(
2022
+					$to_or[] = $this->db->expression($table_def, array(
2026 2023
 						'cal_user_type' => $type,
2027 2024
 						'cal_user_id'   => $ids,
2028 2025
 					));
2029 2026
 				}
2030
-				$where[] = '('.implode(' OR ',$to_or).')';
2031
-				$where[] = "cal_status!='E'";	// do NOT delete exception marker
2032
-				$this->db->update($this->user_table,array('cal_status'=>'X'),$where,__LINE__,__FILE__,'calendar');
2027
+				$where[] = '('.implode(' OR ', $to_or).')';
2028
+				$where[] = "cal_status!='E'"; // do NOT delete exception marker
2029
+				$this->db->update($this->user_table, array('cal_status'=>'X'), $where, __LINE__, __FILE__, 'calendar');
2033 2030
 			}
2034 2031
 		}
2035 2032
 
2036 2033
 		if (count($participants))	// participants which need to be added
2037 2034
 		{
2038
-			if (!count($recurrences)) $recurrences[] = 0;   // insert the default recurrence
2035
+			if (!count($recurrences)) $recurrences[] = 0; // insert the default recurrence
2039 2036
 
2040 2037
 			$delete_deleted = array();
2041 2038
 
2042 2039
 			// update participants
2043
-			foreach($participants as $uid => $status)
2040
+			foreach ($participants as $uid => $status)
2044 2041
 			{
2045 2042
 				$type = $id = $quantity = $role = null;
2046 2043
 				self::split_user($uid, $type, $id, true);
2047
-				self::split_status($status,$quantity,$role);
2044
+				self::split_status($status, $quantity, $role);
2048 2045
 				$set = array(
2049 2046
 					'cal_status'	  => $status,
2050 2047
 					'cal_quantity'	  => $quantity,
2051 2048
 					'cal_role'        => $role,
2052 2049
 					'cal_user_attendee' => $type == 'e' ? substr($uid, 1) : null,
2053 2050
 				);
2054
-				foreach($recurrences as $recur_date)
2051
+				foreach ($recurrences as $recur_date)
2055 2052
 				{
2056
-					$this->db->insert($this->user_table,$set,array(
2053
+					$this->db->insert($this->user_table, $set, array(
2057 2054
 						'cal_id'	      => $cal_id,
2058 2055
 						'cal_recur_date'  => $recur_date,
2059 2056
 						'cal_user_type'   => $type,
2060 2057
 						'cal_user_id' 	  => $id,
2061
-					),__LINE__,__FILE__,'calendar');
2058
+					), __LINE__, __FILE__, 'calendar');
2062 2059
 				}
2063 2060
 				// for new or changed group-invitations, remove previously deleted members, so they show up again
2064 2061
 				if ($uid < 0)
@@ -2068,13 +2065,13 @@  discard block
 block discarded – undo
2068 2065
 			}
2069 2066
 			if ($delete_deleted)
2070 2067
 			{
2071
-				$this->db->delete($this->user_table, $where=array(
2068
+				$this->db->delete($this->user_table, $where = array(
2072 2069
 					'cal_id' => $cal_id,
2073 2070
 					'cal_recur_date' => $recurrences,
2074 2071
 					'cal_user_type' => 'u',
2075 2072
 					'cal_user_id' => array_unique($delete_deleted),
2076 2073
 					'cal_status' => 'X',
2077
-				),__LINE__,__FILE__,'calendar');
2074
+				), __LINE__, __FILE__, 'calendar');
2078 2075
 				//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');
2079 2076
 			}
2080 2077
 		}
@@ -2093,7 +2090,7 @@  discard block
 block discarded – undo
2093 2090
 	 * @param string $attendee =null extra attendee information to set for all types (incl. accounts!)
2094 2091
 	 * @return int number of changed recurrences
2095 2092
 	 */
2096
-	function set_status($cal_id,$user_type,$user_id,$status,$recur_date=0,$role=null,$attendee=null)
2093
+	function set_status($cal_id, $user_type, $user_id, $status, $recur_date = 0, $role = null, $attendee = null)
2097 2094
 	{
2098 2095
 		static $status_code_short = array(
2099 2096
 			REJECTED 	=> 'R',
@@ -2118,7 +2115,7 @@  discard block
 block discarded – undo
2118 2115
 			'cal_user_type'	=> $user_type,
2119 2116
 			'cal_user_id'   => $user_id_md5,
2120 2117
 		);
2121
-		if ((int) $recur_date)
2118
+		if ((int)$recur_date)
2122 2119
 		{
2123 2120
 			$where['cal_recur_date'] = $recur_date;
2124 2121
 		}
@@ -2129,7 +2126,7 @@  discard block
 block discarded – undo
2129 2126
 
2130 2127
 		if ($status == 'G')		// remove group invitations, as we dont store them in the db
2131 2128
 		{
2132
-			$this->db->delete($this->user_table,$where,__LINE__,__FILE__,'calendar');
2129
+			$this->db->delete($this->user_table, $where, __LINE__, __FILE__, 'calendar');
2133 2130
 			$ret = $this->db->affected_rows();
2134 2131
 		}
2135 2132
 		else
@@ -2137,7 +2134,7 @@  discard block
 block discarded – undo
2137 2134
 			$set = array('cal_status' => $status);
2138 2135
 			if ($user_type == 'e' || $attendee) $set['cal_user_attendee'] = $attendee ? $attendee : $user_id;
2139 2136
 			if (!is_null($role) && $role != 'REQ-PARTICIPANT') $set['cal_role'] = $role;
2140
-			$this->db->insert($this->user_table,$set,$where,__LINE__,__FILE__,'calendar');
2137
+			$this->db->insert($this->user_table, $set, $where, __LINE__, __FILE__, 'calendar');
2141 2138
 			// for new or changed group-invitations, remove previously deleted members, so they show up again
2142 2139
 			if (($ret = $this->db->affected_rows()) && $user_type == 'u' && $user_id < 0)
2143 2140
 			{
@@ -2150,7 +2147,7 @@  discard block
 block discarded – undo
2150 2147
 		// update modified and modifier in main table
2151 2148
 		if ($ret)
2152 2149
 		{
2153
-			$this->updateModified($cal_id, true);	// true = update series master too
2150
+			$this->updateModified($cal_id, true); // true = update series master too
2154 2151
 		}
2155 2152
 		//error_log(__METHOD__."($cal_id,$user_type,$user_id,$status,$recur_date) = $ret");
2156 2153
 		return $ret;
@@ -2165,7 +2162,7 @@  discard block
 block discarded – undo
2165 2162
 	 * @param array $participants uid => status pairs
2166 2163
 	 * @param boolean $exception =null true or false to set recure_exception flag, null leave it unchanged (new are by default no exception)
2167 2164
 	 */
2168
-	function recurrence($cal_id,$start,$end,$participants,$exception=null)
2165
+	function recurrence($cal_id, $start, $end, $participants, $exception = null)
2169 2166
 	{
2170 2167
 		//error_log(__METHOD__."($cal_id, $start, $end, ".array2string($participants).", ".array2string($exception));
2171 2168
 		$update = array('cal_end' => $end);
@@ -2174,7 +2171,7 @@  discard block
 block discarded – undo
2174 2171
 		$this->db->insert($this->dates_table, $update, array(
2175 2172
 			'cal_id' => $cal_id,
2176 2173
 			'cal_start'  => $start,
2177
-		),__LINE__,__FILE__,'calendar');
2174
+		), __LINE__, __FILE__, 'calendar');
2178 2175
 
2179 2176
 		if (!is_array($participants))
2180 2177
 		{
@@ -2182,26 +2179,26 @@  discard block
 block discarded – undo
2182 2179
 		}
2183 2180
 		if ($exception !== true)
2184 2181
 		{
2185
-			foreach($participants as $uid => $status)
2182
+			foreach ($participants as $uid => $status)
2186 2183
 			{
2187
-				if ($status == 'G') continue;	// dont save group-invitations
2184
+				if ($status == 'G') continue; // dont save group-invitations
2188 2185
 
2189 2186
 				$type = '';
2190 2187
 				$id = null;
2191 2188
 				self::split_user($uid, $type, $id, true);
2192 2189
 				$quantity = $role = null;
2193
-				self::split_status($status,$quantity,$role);
2194
-				$this->db->insert($this->user_table,array(
2190
+				self::split_status($status, $quantity, $role);
2191
+				$this->db->insert($this->user_table, array(
2195 2192
 					'cal_status'	=> $status,
2196 2193
 					'cal_quantity'	=> $quantity,
2197 2194
 					'cal_role'		=> $role,
2198 2195
 					'cal_user_attendee' => $type == 'e' ? substr($uid, 1) : null,
2199
-				),array(
2196
+				), array(
2200 2197
 					'cal_id'		 => $cal_id,
2201 2198
 					'cal_recur_date' => $start,
2202 2199
 					'cal_user_type'  => $type,
2203 2200
 					'cal_user_id' 	 => $id,
2204
-				),__LINE__,__FILE__,'calendar');
2201
+				), __LINE__, __FILE__, 'calendar');
2205 2202
 			}
2206 2203
 		}
2207 2204
 	}
@@ -2215,7 +2212,7 @@  discard block
 block discarded – undo
2215 2212
 	function unfinished_recuring($time)
2216 2213
 	{
2217 2214
 		$ids = array();
2218
-		foreach($rs=$this->db->select($this->repeats_table, "$this->repeats_table.cal_id,MAX(cal_start) AS cal_start",
2215
+		foreach ($rs = $this->db->select($this->repeats_table, "$this->repeats_table.cal_id,MAX(cal_start) AS cal_start",
2219 2216
 			'(range_end IS NULL OR range_end > '.(int)$time.')',
2220 2217
 			__LINE__, __FILE__, false, "GROUP BY $this->repeats_table.cal_id,range_end", 'calendar', 0,
2221 2218
 			" JOIN $this->cal_table ON $this->repeats_table.cal_id=$this->cal_table.cal_id".
@@ -2241,9 +2238,9 @@  discard block
 block discarded – undo
2241 2238
 		// update timestamp of series master, updates own timestamp too, which does not hurt ;-)
2242 2239
 		$this->updateModified($cal_id, true);
2243 2240
 
2244
-		foreach($this->all_tables as $table)
2241
+		foreach ($this->all_tables as $table)
2245 2242
 		{
2246
-			$this->db->delete($table,array('cal_id'=>$cal_id),__LINE__,__FILE__,'calendar');
2243
+			$this->db->delete($table, array('cal_id'=>$cal_id), __LINE__, __FILE__, 'calendar');
2247 2244
 		}
2248 2245
 	}
2249 2246
 
@@ -2259,10 +2256,10 @@  discard block
 block discarded – undo
2259 2256
 	function purge($date)
2260 2257
 	{
2261 2258
 		// with new range_end we simple delete all with range_end < $date (range_end NULL is never returned)
2262
-		foreach($this->db->select($this->cal_table, 'cal_id', 'range_end < '.(int)$date, __LINE__, __FILE__, false, '', 'calendar') as $row)
2259
+		foreach ($this->db->select($this->cal_table, 'cal_id', 'range_end < '.(int)$date, __LINE__, __FILE__, false, '', 'calendar') as $row)
2263 2260
 		{
2264 2261
 			//echo __METHOD__." About to delete".$row['cal_id']."\r\n";
2265
-			foreach($this->all_tables as $table)
2262
+			foreach ($this->all_tables as $table)
2266 2263
 			{
2267 2264
 				$this->db->delete($table, array('cal_id'=>$row['cal_id']), __LINE__, __FILE__, 'calendar');
2268 2265
 			}
@@ -2287,23 +2284,23 @@  discard block
 block discarded – undo
2287 2284
 	 * @param boolean $update_cache =null true: re-read given $cal_id, false: delete given $cal_id
2288 2285
 	 * @return array of (cal_id => array of) alarms with alarm-id as key
2289 2286
 	 */
2290
-	function read_alarms($cal_id, $update_cache=null)
2287
+	function read_alarms($cal_id, $update_cache = null)
2291 2288
 	{
2292 2289
 		if (!isset(self::$alarm_cache) && is_array($cal_id))
2293 2290
 		{
2294 2291
 			self::$alarm_cache = array();
2295 2292
 			if (($jobs = $this->async->read('cal:%')))
2296 2293
 			{
2297
-				foreach($jobs as $id => $job)
2294
+				foreach ($jobs as $id => $job)
2298 2295
 				{
2299
-					$alarm         = $job['data'];	// text, enabled
2296
+					$alarm         = $job['data']; // text, enabled
2300 2297
 					$alarm['id']   = $id;
2301 2298
 					$alarm['time'] = $job['next'];
2302 2299
 
2303 2300
 					self::$alarm_cache[$alarm['cal_id']][$id] = $alarm;
2304 2301
 				}
2305 2302
 			}
2306
-			unset($update_cache);	// just done
2303
+			unset($update_cache); // just done
2307 2304
 		}
2308 2305
 		$alarms = array();
2309 2306
 
@@ -2311,13 +2308,13 @@  discard block
 block discarded – undo
2311 2308
 		{
2312 2309
 			if (isset($update_cache))
2313 2310
 			{
2314
-				foreach((array)$cal_id as $id)
2311
+				foreach ((array)$cal_id as $id)
2315 2312
 				{
2316 2313
 					if ($update_cache === false)
2317 2314
 					{
2318 2315
 						unset(self::$alarm_cache[$cal_id]);
2319 2316
 					}
2320
-					elseif($update_cache === true)
2317
+					elseif ($update_cache === true)
2321 2318
 					{
2322 2319
 						self::$alarm_cache[$cal_id] = $this->read_alarms_nocache($cal_id);
2323 2320
 					}
@@ -2329,7 +2326,7 @@  discard block
 block discarded – undo
2329 2326
 			}
2330 2327
 			else
2331 2328
 			{
2332
-				foreach($cal_id as $id)
2329
+				foreach ($cal_id as $id)
2333 2330
 				{
2334 2331
 					$alarms[$id] = (array)self::$alarm_cache[$id];
2335 2332
 				}
@@ -2344,9 +2341,9 @@  discard block
 block discarded – undo
2344 2341
 	{
2345 2342
 		if (($jobs = $this->async->read('cal:'.(int)$cal_id.':%')))
2346 2343
 		{
2347
-			foreach($jobs as $id => $job)
2344
+			foreach ($jobs as $id => $job)
2348 2345
 			{
2349
-				$alarm         = $job['data'];	// text, enabled
2346
+				$alarm         = $job['data']; // text, enabled
2350 2347
 				$alarm['id']   = $id;
2351 2348
 				$alarm['time'] = $job['next'];
2352 2349
 
@@ -2369,8 +2366,8 @@  discard block
 block discarded – undo
2369 2366
 		{
2370 2367
 			return False;
2371 2368
 		}
2372
-		list($alarm_id,$job) = each($jobs);
2373
-		$alarm         = $job['data'];	// text, enabled
2369
+		list($alarm_id, $job) = each($jobs);
2370
+		$alarm         = $job['data']; // text, enabled
2374 2371
 		$alarm['id']   = $alarm_id;
2375 2372
 		$alarm['time'] = $job['next'];
2376 2373
 
@@ -2386,12 +2383,12 @@  discard block
 block discarded – undo
2386 2383
 	 * @param boolean $update_modified =true call update modified, default true
2387 2384
 	 * @return string id of the alarm
2388 2385
 	 */
2389
-	function save_alarm($cal_id, $alarm, $update_modified=true)
2386
+	function save_alarm($cal_id, $alarm, $update_modified = true)
2390 2387
 	{
2391 2388
 		//error_log(__METHOD__."($cal_id, ".array2string($alarm).', '.array2string($update_modified).') '.function_backtrace());
2392 2389
 		if (!($id = $alarm['id']))
2393 2390
 		{
2394
-			$alarms = $this->read_alarms($cal_id);	// find a free alarm#
2391
+			$alarms = $this->read_alarms($cal_id); // find a free alarm#
2395 2392
 			$n = count($alarms);
2396 2393
 			do
2397 2394
 			{
@@ -2404,13 +2401,13 @@  discard block
 block discarded – undo
2404 2401
 		{
2405 2402
 			$this->async->cancel_timer($id);
2406 2403
 		}
2407
-		$alarm['cal_id'] = $cal_id;		// we need the back-reference
2404
+		$alarm['cal_id'] = $cal_id; // we need the back-reference
2408 2405
 		// do not deleted async-job, as we need it for alarm snozzing
2409 2406
 		$alarm['keep'] = self::ALARM_KEEP_TIME;
2410 2407
 		// past alarms need NOT to be triggered, but kept around for a while to allow alarm snozzing
2411 2408
 		if ($alarm['time'] < time())
2412 2409
 		{
2413
-			$alarm['time'] = $alarm['keep_time'] = time()+self::ALARM_KEEP_TIME;
2410
+			$alarm['time'] = $alarm['keep_time'] = time() + self::ALARM_KEEP_TIME;
2414 2411
 		}
2415 2412
 		// add an alarm uid, if none is given
2416 2413
 		if (empty($alarm['uid']) && class_exists('Horde_Support_Uuid')) $alarm['uid'] = (string)new Horde_Support_Uuid;
@@ -2443,7 +2440,7 @@  discard block
 block discarded – undo
2443 2440
 		//error_log(__METHOD__."($cal_id) ".function_backtrace());
2444 2441
 		if (($alarms = $this->read_alarms($cal_id)))
2445 2442
 		{
2446
-			foreach(array_keys($alarms) as $id)
2443
+			foreach (array_keys($alarms) as $id)
2447 2444
 			{
2448 2445
 				$this->async->cancel_timer($id);
2449 2446
 			}
@@ -2463,7 +2460,7 @@  discard block
 block discarded – undo
2463 2460
 	{
2464 2461
 		//error_log(__METHOD__."('$id') ".function_backtrace());
2465 2462
 		// update the modification information of the related event
2466
-		list(,$cal_id) = explode(':',$id);
2463
+		list(,$cal_id) = explode(':', $id);
2467 2464
 		if ($cal_id)
2468 2465
 		{
2469 2466
 			$this->updateModified($cal_id, true);
@@ -2482,7 +2479,7 @@  discard block
 block discarded – undo
2482 2479
 	 * @param array|int $old_user integer old user or array with keys 'account_id' and 'new_owner' as the deleteaccount hook uses it
2483 2480
 	 * @param int $new_user =null
2484 2481
 	 */
2485
-	function deleteaccount($old_user, $new_user=null)
2482
+	function deleteaccount($old_user, $new_user = null)
2486 2483
 	{
2487 2484
 		if (is_array($old_user))
2488 2485
 		{
@@ -2493,52 +2490,52 @@  discard block
 block discarded – undo
2493 2490
 		{
2494 2491
 			$user_type = '';
2495 2492
 			$user_id = null;
2496
-			self::split_user($old_user,$user_type,$user_id);
2493
+			self::split_user($old_user, $user_type, $user_id);
2497 2494
 
2498 2495
 			if ($user_type == 'u')	// only accounts can be owners of events
2499 2496
 			{
2500
-				foreach($this->db->select($this->cal_table,'cal_id',array('cal_owner' => $old_user),__LINE__,__FILE__,false,'','calendar') as $row)
2497
+				foreach ($this->db->select($this->cal_table, 'cal_id', array('cal_owner' => $old_user), __LINE__, __FILE__, false, '', 'calendar') as $row)
2501 2498
 				{
2502 2499
 					$this->delete($row['cal_id']);
2503 2500
 				}
2504 2501
 			}
2505
-			$this->db->delete($this->user_table,array(
2502
+			$this->db->delete($this->user_table, array(
2506 2503
 				'cal_user_type' => $user_type,
2507 2504
 				'cal_user_id'   => $user_id,
2508
-			),__LINE__,__FILE__,'calendar');
2505
+			), __LINE__, __FILE__, 'calendar');
2509 2506
 
2510 2507
 			// delete calendar entries without participants (can happen if the deleted user is the only participants, but not the owner)
2511
-			foreach($this->db->select($this->cal_table,"DISTINCT $this->cal_table.cal_id",'cal_user_id IS NULL',__LINE__,__FILE__,
2512
-				False,'','calendar',0,"LEFT JOIN $this->user_table ON $this->cal_table.cal_id=$this->user_table.cal_id") as $row)
2508
+			foreach ($this->db->select($this->cal_table, "DISTINCT $this->cal_table.cal_id", 'cal_user_id IS NULL', __LINE__, __FILE__,
2509
+				False, '', 'calendar', 0, "LEFT JOIN $this->user_table ON $this->cal_table.cal_id=$this->user_table.cal_id") as $row)
2513 2510
 			{
2514 2511
 				$this->delete($row['cal_id']);
2515 2512
 			}
2516 2513
 		}
2517 2514
 		else
2518 2515
 		{
2519
-			$this->db->update($this->cal_table,array('cal_owner' => $new_user),array('cal_owner' => $old_user),__LINE__,__FILE__,'calendar');
2516
+			$this->db->update($this->cal_table, array('cal_owner' => $new_user), array('cal_owner' => $old_user), __LINE__, __FILE__, 'calendar');
2520 2517
 			// delete participation of old user, if new user is already a participant
2521 2518
 			$ids = array();
2522
-			foreach($this->db->select($this->user_table,'cal_id',array(		// MySQL does NOT allow to run this as delete!
2519
+			foreach ($this->db->select($this->user_table, 'cal_id', array(		// MySQL does NOT allow to run this as delete!
2523 2520
 				'cal_user_type' => 'u',
2524 2521
 				'cal_user_id' => $old_user,
2525 2522
 				"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')",
2526
-			),__LINE__,__FILE__,false,'','calendar') as $row)
2523
+			), __LINE__, __FILE__, false, '', 'calendar') as $row)
2527 2524
 			{
2528 2525
 				$ids[] = $row['cal_id'];
2529 2526
 			}
2530
-			if ($ids) $this->db->delete($this->user_table,array(
2527
+			if ($ids) $this->db->delete($this->user_table, array(
2531 2528
 				'cal_user_type' => 'u',
2532 2529
 				'cal_user_id' => $old_user,
2533 2530
 				'cal_id' => $ids,
2534
-			),__LINE__,__FILE__,'calendar');
2531
+			), __LINE__, __FILE__, 'calendar');
2535 2532
 			// now change participant in the rest to contain new user instead of old user
2536
-			$this->db->update($this->user_table,array(
2533
+			$this->db->update($this->user_table, array(
2537 2534
 				'cal_user_id' => $new_user,
2538
-			),array(
2535
+			), array(
2539 2536
 				'cal_user_type' => 'u',
2540 2537
 				'cal_user_id' => $old_user,
2541
-			),__LINE__,__FILE__,'calendar');
2538
+			), __LINE__, __FILE__, 'calendar');
2542 2539
 		}
2543 2540
 	}
2544 2541
 
@@ -2552,18 +2549,18 @@  discard block
 block discarded – undo
2552 2549
 	 *
2553 2550
 	 * @return array recur_date => status pairs (index 0 => main status)
2554 2551
 	 */
2555
-	function get_recurrences($cal_id, $uid=null, $start=0, $end=0)
2552
+	function get_recurrences($cal_id, $uid = null, $start = 0, $end = 0)
2556 2553
 	{
2557 2554
 		$participant_status = array();
2558 2555
 		$where = array('cal_id' => $cal_id);
2559
-		if ($start != 0 && $end == 0) $where[] = '(cal_recur_date = 0 OR cal_recur_date >= ' . (int)$start . ')';
2560
-		if ($start == 0 && $end != 0) $where[] = '(cal_recur_date = 0 OR cal_recur_date <= ' . (int)$end . ')';
2556
+		if ($start != 0 && $end == 0) $where[] = '(cal_recur_date = 0 OR cal_recur_date >= '.(int)$start.')';
2557
+		if ($start == 0 && $end != 0) $where[] = '(cal_recur_date = 0 OR cal_recur_date <= '.(int)$end.')';
2561 2558
 		if ($start != 0 && $end != 0)
2562 2559
 		{
2563
-			$where[] = '(cal_recur_date = 0 OR (cal_recur_date >= ' . (int)$start .
2564
-						' AND cal_recur_date <= ' . (int)$end . '))';
2560
+			$where[] = '(cal_recur_date = 0 OR (cal_recur_date >= '.(int)$start.
2561
+						' AND cal_recur_date <= '.(int)$end.'))';
2565 2562
 		}
2566
-		foreach($this->db->select($this->user_table,'DISTINCT cal_recur_date',$where,__LINE__,__FILE__,false,'','calendar') as $row)
2563
+		foreach ($this->db->select($this->user_table, 'DISTINCT cal_recur_date', $where, __LINE__, __FILE__, false, '', 'calendar') as $row)
2567 2564
 		{
2568 2565
 			// inititalize the array
2569 2566
 			$participant_status[$row['cal_recur_date']] = null;
@@ -2577,17 +2574,17 @@  discard block
 block discarded – undo
2577 2574
 			'cal_user_type'	=> $user_type ? $user_type : 'u',
2578 2575
 			'cal_user_id'   => $user_id,
2579 2576
 		);
2580
-		if ($start != 0 && $end == 0) $where2[] = '(cal_recur_date = 0 OR cal_recur_date >= ' . (int)$start . ')';
2581
-		if ($start == 0 && $end != 0) $where2[] = '(cal_recur_date = 0 OR cal_recur_date <= ' . (int)$end . ')';
2577
+		if ($start != 0 && $end == 0) $where2[] = '(cal_recur_date = 0 OR cal_recur_date >= '.(int)$start.')';
2578
+		if ($start == 0 && $end != 0) $where2[] = '(cal_recur_date = 0 OR cal_recur_date <= '.(int)$end.')';
2582 2579
 		if ($start != 0 && $end != 0)
2583 2580
 		{
2584
-			$where2[] = '(cal_recur_date = 0 OR (cal_recur_date >= ' . (int)$start .
2585
-						' AND cal_recur_date <= ' . (int)$end . '))';
2581
+			$where2[] = '(cal_recur_date = 0 OR (cal_recur_date >= '.(int)$start.
2582
+						' AND cal_recur_date <= '.(int)$end.'))';
2586 2583
 		}
2587
-		foreach ($this->db->select($this->user_table,'cal_recur_date,cal_status,cal_quantity,cal_role',$where2,
2588
-				__LINE__,__FILE__,false,'','calendar') as $row)
2584
+		foreach ($this->db->select($this->user_table, 'cal_recur_date,cal_status,cal_quantity,cal_role', $where2,
2585
+				__LINE__, __FILE__, false, '', 'calendar') as $row)
2589 2586
 		{
2590
-			$status = self::combine_status($row['cal_status'],$row['cal_quantity'],$row['cal_role']);
2587
+			$status = self::combine_status($row['cal_status'], $row['cal_quantity'], $row['cal_role']);
2591 2588
 			$participant_status[$row['cal_recur_date']] = $status;
2592 2589
 		}
2593 2590
 		return $participant_status;
@@ -2636,8 +2633,8 @@  discard block
 block discarded – undo
2636 2633
 			'cal_uid'		=> $uid,
2637 2634
 		);
2638 2635
 		$related = array();
2639
-		foreach ($this->db->select($this->cal_table,'cal_id,cal_reference',$where,
2640
-				__LINE__,__FILE__,false,'','calendar') as $row)
2636
+		foreach ($this->db->select($this->cal_table, 'cal_id,cal_reference', $where,
2637
+				__LINE__, __FILE__, false, '', 'calendar') as $row)
2641 2638
 		{
2642 2639
 			if ($row['cal_reference'] != 0)
2643 2640
 			{
@@ -2666,10 +2663,10 @@  discard block
 block discarded – undo
2666 2663
 	 *
2667 2664
 	 * @return array		Array of exception days (false for non-recurring events).
2668 2665
 	 */
2669
-	function get_recurrence_exceptions($event, $tz_id=null, $start=0, $end=0, $filter='all')
2666
+	function get_recurrence_exceptions($event, $tz_id = null, $start = 0, $end = 0, $filter = 'all')
2670 2667
 	{
2671 2668
 		if (!is_array($event)) return false;
2672
-		$cal_id = (int) $event['id'];
2669
+		$cal_id = (int)$event['id'];
2673 2670
 		//error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2674 2671
 		//		"($cal_id, $tz_id, $filter): " . $event['tzid']);
2675 2672
 		if (!$cal_id || $event['recur_type'] == MCAL_RECUR_NONE) return false;
@@ -2693,27 +2690,27 @@  discard block
 block discarded – undo
2693 2690
 		while ($egw_rrule->valid())
2694 2691
 		{
2695 2692
 			while ($egw_rrule->exceptions &&
2696
-				in_array($egw_rrule->current->format('Ymd'),$egw_rrule->exceptions))
2693
+				in_array($egw_rrule->current->format('Ymd'), $egw_rrule->exceptions))
2697 2694
 			{
2698
-				if (in_array($filter, array('map','tz_map','rrule','tz_rrule')))
2695
+				if (in_array($filter, array('map', 'tz_map', 'rrule', 'tz_rrule')))
2699 2696
 				{
2700 2697
 					 // real exception
2701
-					$locts = (int)Api\DateTime::to($egw_rrule->current(),'server');
2698
+					$locts = (int)Api\DateTime::to($egw_rrule->current(), 'server');
2702 2699
 					if ($expand_all)
2703 2700
 					{
2704
-						$remts = (int)Api\DateTime::to($remote_rrule->current(),'server');
2701
+						$remts = (int)Api\DateTime::to($remote_rrule->current(), 'server');
2705 2702
 						if ($remote)
2706 2703
 						{
2707
-							$days[$locts]= $remts;
2704
+							$days[$locts] = $remts;
2708 2705
 						}
2709 2706
 						else
2710 2707
 						{
2711
-							$days[$remts]= $locts;
2708
+							$days[$remts] = $locts;
2712 2709
 						}
2713 2710
 					}
2714 2711
 					else
2715 2712
 					{
2716
-						$days[$locts]= $locts;
2713
+						$days[$locts] = $locts;
2717 2714
 					}
2718 2715
 				}
2719 2716
 				if ($expand_all)
@@ -2724,14 +2721,14 @@  discard block
 block discarded – undo
2724 2721
 				if (!$egw_rrule->valid()) return $days;
2725 2722
 			}
2726 2723
 			$day = $egw_rrule->current();
2727
-			$locts = (int)Api\DateTime::to($day,'server');
2724
+			$locts = (int)Api\DateTime::to($day, 'server');
2728 2725
 			$tz_exception = ($filter == 'tz_rrule');
2729 2726
 			//error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2730 2727
 			//	'()[EVENT Server]: ' . $day->format('Ymd\THis') . " ($locts)");
2731 2728
 			if ($expand_all)
2732 2729
 			{
2733 2730
 				$remote_day = $remote_rrule->current();
2734
-				$remts = (int)Api\DateTime::to($remote_day,'server');
2731
+				$remts = (int)Api\DateTime::to($remote_day, 'server');
2735 2732
 			//	error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2736 2733
 			//	'()[EVENT Device]: ' . $remote_day->format('Ymd\THis') . " ($remts)");
2737 2734
 			}
@@ -2750,11 +2747,11 @@  discard block
 block discarded – undo
2750 2747
 						//	'() tz exception: ' . $day->format('Ymd\THis'));
2751 2748
 						if ($remote)
2752 2749
 						{
2753
-							$days[$locts]= $remts;
2750
+							$days[$locts] = $remts;
2754 2751
 						}
2755 2752
 						else
2756 2753
 						{
2757
-							$days[$remts]= $locts;
2754
+							$days[$remts] = $locts;
2758 2755
 						}
2759 2756
 					}
2760 2757
 				}
@@ -2776,18 +2773,18 @@  discard block
 block discarded – undo
2776 2773
 							{
2777 2774
 								if ($remote)
2778 2775
 								{
2779
-									$days[$locts]= $remts;
2776
+									$days[$locts] = $remts;
2780 2777
 								}
2781 2778
 								else
2782 2779
 								{
2783
-									$days[$remts]= $locts;
2780
+									$days[$remts] = $locts;
2784 2781
 								}
2785 2782
 							}
2786 2783
 						}
2787 2784
 					}
2788 2785
 					elseif ($filter != 'map')
2789 2786
 					{
2790
-						$days[$locts]= $locts;
2787
+						$days[$locts] = $locts;
2791 2788
 					}
2792 2789
 				}
2793 2790
 				elseif (($filter == 'map' || filter == 'tz_map') &&
@@ -2797,11 +2794,11 @@  discard block
 block discarded – undo
2797 2794
 					if ($expand_all)
2798 2795
 					{
2799 2796
 
2800
-						$days[$remts]= $locts;
2797
+						$days[$remts] = $locts;
2801 2798
 					}
2802 2799
 					else
2803 2800
 					{
2804
-						$days[$locts]= $locts;
2801
+						$days[$locts] = $locts;
2805 2802
 					}
2806 2803
 				}
2807 2804
 			}
@@ -2825,9 +2822,9 @@  discard block
 block discarded – undo
2825 2822
 	 */
2826 2823
 	function status_pseudo_exception($cal_id, $recur_date, $filter)
2827 2824
 	{
2828
-		static $recurrence_zero=null;
2829
-		static $cached_id=null;
2830
-		static $user=null;
2825
+		static $recurrence_zero = null;
2826
+		static $cached_id = null;
2827
+		static $user = null;
2831 2828
 
2832 2829
 		if (!isset($cached_id) || $cached_id != $cal_id)
2833 2830
 		{
@@ -2838,8 +2835,8 @@  discard block
 block discarded – undo
2838 2835
 				'cal_id' => $cal_id,
2839 2836
 				'cal_recur_date' => 0,
2840 2837
 			);
2841
-			foreach ($this->db->select($this->user_table,'cal_user_type,cal_user_id,cal_user_attendee,cal_status',$where,
2842
-				__LINE__,__FILE__,false,'','calendar') as $row)
2838
+			foreach ($this->db->select($this->user_table, 'cal_user_type,cal_user_id,cal_user_attendee,cal_status', $where,
2839
+				__LINE__, __FILE__, false, '', 'calendar') as $row)
2843 2840
 			{
2844 2841
 				switch ($row['cal_user_type'])
2845 2842
 				{
@@ -2862,8 +2859,8 @@  discard block
 block discarded – undo
2862 2859
 			'cal_id' => $cal_id,
2863 2860
 			'cal_recur_date' => $recur_date,
2864 2861
 		);
2865
-		foreach ($this->db->select($this->user_table,'cal_user_type,cal_user_id,cal_user_attendee,cal_status',$where,
2866
-			__LINE__,__FILE__,false,'','calendar') as $row)
2862
+		foreach ($this->db->select($this->user_table, 'cal_user_type,cal_user_id,cal_user_attendee,cal_status', $where,
2863
+			__LINE__, __FILE__, false, '', 'calendar') as $row)
2867 2864
 		{
2868 2865
 			switch ($row['cal_user_type'])
2869 2866
 			{
@@ -2888,42 +2885,42 @@  discard block
 block discarded – undo
2888 2885
 						if ($status != 'U')
2889 2886
 						{
2890 2887
 							unset($participants[$uid]);
2891
-							continue 2;	// +1 for switch
2888
+							continue 2; // +1 for switch
2892 2889
 						}
2893 2890
 						break;
2894 2891
 					case 'accepted':
2895 2892
 						if ($status != 'A')
2896 2893
 						{
2897 2894
 							unset($participants[$uid]);
2898
-							continue 2;	// +1 for switch
2895
+							continue 2; // +1 for switch
2899 2896
 						}
2900 2897
 						break;
2901 2898
 					case 'tentative':
2902 2899
 						if ($status != 'T')
2903 2900
 						{
2904 2901
 							unset($participants[$uid]);
2905
-							continue 2;	// +1 for switch
2902
+							continue 2; // +1 for switch
2906 2903
 						}
2907 2904
 						break;
2908 2905
 					case 'rejected':
2909 2906
 						if ($status != 'R')
2910 2907
 						{
2911 2908
 							unset($participants[$uid]);
2912
-							continue 2;	// +1 for switch
2909
+							continue 2; // +1 for switch
2913 2910
 						}
2914 2911
 						break;
2915 2912
 					case 'delegated':
2916 2913
 						if ($status != 'D')
2917 2914
 						{
2918 2915
 							unset($participants[$uid]);
2919
-							continue 2;	// +1 for switch
2916
+							continue 2; // +1 for switch
2920 2917
 						}
2921 2918
 						break;
2922 2919
 					case 'default':
2923 2920
 						if ($status == 'R')
2924 2921
 						{
2925 2922
 							unset($participants[$uid]);
2926
-							continue 2;	// +1 for switch
2923
+							continue 2; // +1 for switch
2927 2924
 						}
2928 2925
 						break;
2929 2926
 					default:
@@ -2960,14 +2957,14 @@  discard block
 block discarded – undo
2960 2957
 			}
2961 2958
 			$timezone = self::$tz_cache[$event['tzid']];
2962 2959
 		}
2963
-		$start_time = new Api\DateTime($event['start'],Api\DateTime::$server_timezone);
2960
+		$start_time = new Api\DateTime($event['start'], Api\DateTime::$server_timezone);
2964 2961
 		$start_time->setTimezone($timezone);
2965
-		$end_time = new Api\DateTime($event['end'],Api\DateTime::$server_timezone);
2962
+		$end_time = new Api\DateTime($event['end'], Api\DateTime::$server_timezone);
2966 2963
 		$end_time->setTimezone($timezone);
2967 2964
 		//error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2968 2965
 		//	'(): ' . $start . '-' . $end);
2969
-		$start = Api\DateTime::to($start_time,'array');
2970
-		$end = Api\DateTime::to($end_time,'array');
2966
+		$start = Api\DateTime::to($start_time, 'array');
2967
+		$end = Api\DateTime::to($end_time, 'array');
2971 2968
 
2972 2969
 
2973 2970
 		return !$start['hour'] && !$start['minute'] && $end['hour'] == 23 && $end['minute'] == 59;
@@ -2981,7 +2978,7 @@  discard block
 block discarded – undo
2981 2978
 	 *
2982 2979
 	 * @return DateTime
2983 2980
 	 */
2984
-	function &startOfDay(Api\DateTime $time, $tz_id=null)
2981
+	function &startOfDay(Api\DateTime $time, $tz_id = null)
2985 2982
 	{
2986 2983
 		if (empty($tz_id))
2987 2984
 		{
@@ -3006,14 +3003,14 @@  discard block
 block discarded – undo
3006 3003
 	 * @param int $time =null new timestamp, default current (server-)time
3007 3004
 	 * @param int $modifier =null uid of the modifier, default current user
3008 3005
 	 */
3009
-	function updateModified($id, $update_master=false, $time=null, $modifier=null)
3006
+	function updateModified($id, $update_master = false, $time = null, $modifier = null)
3010 3007
 	{
3011 3008
 		if (is_null($time) || !$time) $time = time();
3012 3009
 		if (is_null($modifier)) $modifier = $GLOBALS['egw_info']['user']['account_id'];
3013 3010
 
3014 3011
 		$this->db->update($this->cal_table,
3015 3012
 			array('cal_modified' => $time, 'cal_modifier' => $modifier),
3016
-			array('cal_id' => $id), __LINE__,__FILE__, 'calendar');
3013
+			array('cal_id' => $id), __LINE__, __FILE__, 'calendar');
3017 3014
 
3018 3015
 		// if event is an exception: update modified of master, to force etag, ctag and sync-token change
3019 3016
 		if ($update_master)
Please login to merge, or discard this patch.
Braces   +366 added lines, -96 removed lines patch added patch discarded remove patch
@@ -159,16 +159,32 @@  discard block
 block discarded – undo
159 159
 	 */
160 160
 	protected function cal_range_view($start, $end, array $_where=null, $deleted=false)
161 161
 	{
162
-		if ($GLOBALS['egw_info']['server']['no_timerange_views'] || !$start)	// using view without start-date is slower!
162
+		if ($GLOBALS['egw_info']['server']['no_timerange_views'] || !$start)
163 163
 		{
164
-			return $this->cal_table;	// no need / use for a view
164
+			// using view without start-date is slower!
165
+		{
166
+			return $this->cal_table;
167
+		}
168
+		// no need / use for a view
165 169
 		}
166 170
 
167 171
 		$where = array();
168
-		if (isset($deleted)) $where[] = "cal_deleted IS ".($deleted ? '' : 'NOT').' NULL';
169
-		if ($end) $where[] = "range_start<".(int)$end;
170
-		if ($start) $where[] = "(range_end IS NULL OR range_end>".(int)$start.")";
171
-		if ($_where) $where = array_merge($where, $_where);
172
+		if (isset($deleted))
173
+		{
174
+			$where[] = "cal_deleted IS ".($deleted ? '' : 'NOT').' NULL';
175
+		}
176
+		if ($end)
177
+		{
178
+			$where[] = "range_start<".(int)$end;
179
+		}
180
+		if ($start)
181
+		{
182
+			$where[] = "(range_end IS NULL OR range_end>".(int)$start.")";
183
+		}
184
+		if ($_where)
185
+		{
186
+			$where = array_merge($where, $_where);
187
+		}
172 188
 
173 189
 		$sql = "(SELECT * FROM $this->cal_table WHERE ".$this->db->expression($this->cal_table, $where).") $this->cal_table";
174 190
 
@@ -189,16 +205,32 @@  discard block
 block discarded – undo
189 205
 	 */
190 206
 	protected function dates_range_view($start, $end, array $_where=null, $deleted=false)
191 207
 	{
192
-		if ($GLOBALS['egw_info']['server']['no_timerange_views'] || !$start || !$end)	// using view without start- AND end-date is slower!
208
+		if ($GLOBALS['egw_info']['server']['no_timerange_views'] || !$start || !$end)
209
+		{
210
+			// using view without start- AND end-date is slower!
193 211
 		{
194
-			return $this->dates_table;	// no need / use for a view
212
+			return $this->dates_table;
213
+		}
214
+		// no need / use for a view
195 215
 		}
196 216
 
197 217
 		$where = array();
198
-		if (isset($deleted)) $where['recur_exception'] = $deleted;
199
-		if ($end) $where[] = "cal_start<".(int)$end;
200
-		if ($start) $where[] = "cal_end>".(int)$start;
201
-		if ($_where) $where = array_merge($where, $_where);
218
+		if (isset($deleted))
219
+		{
220
+			$where['recur_exception'] = $deleted;
221
+		}
222
+		if ($end)
223
+		{
224
+			$where[] = "cal_start<".(int)$end;
225
+		}
226
+		if ($start)
227
+		{
228
+			$where[] = "cal_end>".(int)$start;
229
+		}
230
+		if ($_where)
231
+		{
232
+			$where = array_merge($where, $_where);
233
+		}
202 234
 
203 235
 		// Api\Db::union uses Api\Db::select which check if join contains "WHERE"
204 236
 		// to support old join syntax like ", other_table WHERE ...",
@@ -248,7 +280,10 @@  discard block
 block discarded – undo
248 280
 			throw new Api\Exception\AssertionFailed("Unsupported value for parameters!");
249 281
 		}
250 282
 		$where = is_array($params['query']) ? $params['query'] : array();
251
-		if ($cat_id) $where[] = $this->cat_filter($cat_id);
283
+		if ($cat_id)
284
+		{
285
+			$where[] = $this->cat_filter($cat_id);
286
+		}
252 287
 		$egw_cal = $this->cal_range_view($start, $end, $where, $filter == 'everything' ? null : $filter != 'deleted');
253 288
 
254 289
 		$status_filter = $this->status_filter($filter, $params['enum_recuring']);
@@ -269,7 +304,10 @@  discard block
 block discarded – undo
269 304
 		if ($users)
270 305
 		{
271 306
 			// fix $users to also prefix system users and groups (with 'u')
272
-			if (!is_array($users)) $users = $users ? (array)$users : array();
307
+			if (!is_array($users))
308
+			{
309
+				$users = $users ? (array)$users : array();
310
+			}
273 311
 			foreach($users as &$uid)
274 312
 			{
275 313
 				$user_type = $user_id = null;
@@ -289,15 +327,22 @@  discard block
 block discarded – undo
289 327
 			$sql .= " AND\n	".$params['sql_filter'];
290 328
 		}
291 329
 
292
-		if ($params['order'])	// only order if requested
330
+		if ($params['order'])
293 331
 		{
294
-			if (!preg_match('/^[a-z_ ,c]+$/i',$params['order'])) $params['order'] = 'cal_start';		// gard against SQL injection
332
+			// only order if requested
333
+		{
334
+			if (!preg_match('/^[a-z_ ,c]+$/i',$params['order'])) $params['order'] = 'cal_start';
335
+		}
336
+		// gard against SQL injection
295 337
 			$sql .= "\nORDER BY ".$params['order'];
296 338
 		}
297 339
 
298
-		if ($offset === false)	// return all rows --> Api\Db::query wants offset=0, num_rows=-1
340
+		if ($offset === false)
341
+		{
342
+			// return all rows --> Api\Db::query wants offset=0, num_rows=-1
299 343
 		{
300 344
 			$offset = 0;
345
+		}
301 346
 			$num_rows = -1;
302 347
 		}
303 348
 		$events =& $this->get_events($this->db->query($sql, __LINE__, __FILE__, $offset, $num_rows));
@@ -324,10 +369,13 @@  discard block
 block discarded – undo
324 369
 		$join = "LEFT JOIN $this->repeats_table ON $this->cal_table.cal_id=$this->repeats_table.cal_id";
325 370
 
326 371
 		$where = array();
327
-		if (is_scalar($ids) && !is_numeric($ids))	// a single uid
372
+		if (is_scalar($ids) && !is_numeric($ids))
373
+		{
374
+			// a single uid
328 375
 		{
329 376
 			// We want only the parents to match
330 377
 			$where['cal_uid'] = $ids;
378
+		}
331 379
 			if ($read_recurrence)
332 380
 			{
333 381
 				$where['cal_recurrence'] = $recur_date;
@@ -337,20 +385,26 @@  discard block
 block discarded – undo
337 385
 				$where['cal_reference'] = 0;
338 386
 			}
339 387
 		}
340
-		elseif(is_array($ids) && isset($ids[count($ids)-1]) || is_scalar($ids))	// one or more cal_id's
388
+		elseif(is_array($ids) && isset($ids[count($ids)-1]) || is_scalar($ids))
389
+		{
390
+			// one or more cal_id's
341 391
 		{
342 392
 			$where['cal_id'] = $ids;
343 393
 		}
394
+		}
344 395
 		else	// array with column => value pairs
345 396
 		{
346 397
 			$where = $ids;
347 398
 			unset($ids);	// otherwise users get not read!
348 399
 		}
349
-		if (isset($where['cal_id']))	// prevent non-unique column-name cal_id
400
+		if (isset($where['cal_id']))
401
+		{
402
+			// prevent non-unique column-name cal_id
350 403
 		{
351 404
 			$where[] = $this->db->expression($this->cal_table, $this->cal_table.'.',array(
352 405
 				'cal_id' => $where['cal_id'],
353 406
 			));
407
+		}
354 408
 			unset($where['cal_id']);
355 409
 		}
356 410
 		if ((int) $recur_date && !$read_recurrence)
@@ -406,10 +460,16 @@  discard block
 block discarded – undo
406 460
 			$row['recur_exception'] = $row['alarm'] = array();
407 461
 			$events[$row['cal_id']] = Api\Db::strip_array_keys($row,'cal_');
408 462
 		}
409
-		if (!$events) return $events;
463
+		if (!$events)
464
+		{
465
+			return $events;
466
+		}
410 467
 
411 468
 		$ids = array_keys($events);
412
-		if (count($ids) == 1) $ids = $ids[0];
469
+		if (count($ids) == 1)
470
+		{
471
+			$ids = $ids[0];
472
+		}
413 473
 
414 474
 		foreach ($events as &$event)
415 475
 		{
@@ -483,10 +543,13 @@  discard block
 block discarded – undo
483 543
 			'cal_id'      => $ids,
484 544
 			'cal_recur_date' => $recur_date,
485 545
 			"cal_status NOT IN ('X','E')",
486
-		),__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
546
+		),__LINE__,__FILE__,false,'ORDER BY cal_user_type DESC,cal_recur_date ASC,'.self::STATUS_SORT,'calendar') as $row)
547
+		{
548
+			// DESC puts users before resources and contacts
487 549
 		{
488 550
 			// combine all participant data in uid and status values
489 551
 			$uid    = self::combine_user($row['cal_user_type'], $row['cal_user_id'], $row['cal_user_attendee']);
552
+		}
490 553
 			$status = self::combine_status($row['cal_status'],$row['cal_quantity'],$row['cal_role']);
491 554
 
492 555
 			$events[$row['cal_id']]['participants'][$uid] = $status;
@@ -543,7 +606,10 @@  discard block
 block discarded – undo
543 606
 			$last_request = time();
544 607
 		}
545 608
 		$signature = serialize(func_get_args());
546
-		if (isset($ctags[$signature])) return $ctags[$signature];
609
+		if (isset($ctags[$signature]))
610
+		{
611
+			return $ctags[$signature];
612
+		}
547 613
 
548 614
 		$types = array();
549 615
 		foreach((array)$users as $uid)
@@ -576,7 +642,10 @@  discard block
 block discarded – undo
576 642
 			// owner can only by users, no groups or resources
577 643
 			foreach($users as $key => $user)
578 644
 			{
579
-				if (!($user > 0)) unset($users[$key]);
645
+				if (!($user > 0))
646
+				{
647
+					unset($users[$key]);
648
+				}
580 649
 			}
581 650
 			$where = $this->db->expression($this->user_table, '(', $where, ' OR ').
582 651
 				$this->db->expression($this->cal_table, array(
@@ -598,7 +667,10 @@  discard block
 block discarded – undo
598 667
 	 */
599 668
 	function get_cal_data(array $query, $cols='cal_id,cal_reference,cal_etag,cal_modified,cal_user_modified')
600 669
 	{
601
-		if (!is_array($cols)) $cols = explode(',', $cols);
670
+		if (!is_array($cols))
671
+		{
672
+			$cols = explode(',', $cols);
673
+		}
602 674
 
603 675
 		// special handling of cal_user_modified "pseudo" column
604 676
 		if (($key = array_search('cal_user_modified', $cols)) !== false)
@@ -627,7 +699,10 @@  discard block
 block discarded – undo
627 699
 				unset($key);	// not used, but required by function signature
628 700
 				$val = (int) $val;
629 701
 			});
630
-			if (is_array($cat_id) && count($cat_id)==1) $cat_id = $cat_id[0];
702
+			if (is_array($cat_id) && count($cat_id)==1)
703
+			{
704
+				$cat_id = $cat_id[0];
705
+			}
631 706
 			$sql = '(cal_category'.(count($cats) > 1 ? " IN ('".implode("','",$cats)."')" : '='.$this->db->quote((int)$cat_id));
632 707
 			foreach($cats as $cat)
633 708
 			{
@@ -686,10 +761,13 @@  discard block
 block discarded – undo
686 761
 				$where[] = "$this->user_table.cal_status NOT IN ('X','E')";
687 762
 				break;
688 763
 			default:
689
-				if ($enum_recuring)	// regular UI
764
+				if ($enum_recuring)
765
+				{
766
+					// regular UI
690 767
 				{
691 768
 					$where[] = "$this->user_table.cal_status NOT IN ('R','X','E')";
692 769
 				}
770
+				}
693 771
 				else	// CalDAV / eSync / iCal need to include 'E' = exceptions
694 772
 				{
695 773
 					$where[] = "$this->user_table.cal_status NOT IN ('R','X')";
@@ -831,7 +909,10 @@  discard block
 block discarded – undo
831 909
 						$user_ids = array();
832 910
 						foreach($ids as $user_id)
833 911
 						{
834
-							if ($GLOBALS['egw']->accounts->get_type($user_id) === 'u') $user_ids[] = $user_id;
912
+							if ($GLOBALS['egw']->accounts->get_type($user_id) === 'u')
913
+							{
914
+								$user_ids[] = $user_id;
915
+							}
835 916
 						}
836 917
 						$owner_or = $this->db->expression($cal_table_def,array('cal_owner' => $user_ids));
837 918
 					}
@@ -851,7 +932,10 @@  discard block
 block discarded – undo
851 932
 				}
852 933
 			}
853 934
 			// this is only used, when we cannot use UNIONS
854
-			if (!$useUnionQuery) $where[] = '('.implode(' OR ',$to_or).')';
935
+			if (!$useUnionQuery)
936
+			{
937
+				$where[] = '('.implode(' OR ',$to_or).')';
938
+			}
855 939
 
856 940
 			$where = $this->status_filter($filter, $params['enum_recuring'], $where);
857 941
 		}
@@ -870,7 +954,11 @@  discard block
 block discarded – undo
870 954
 				$where[] = '('.((int)$start).' < range_end OR range_end IS NULL)';
871 955
 			}
872 956
 		}
873
-		if (!preg_match('/^[a-z_ ,c]+$/i',$params['order'])) $params['order'] = 'cal_start';		// gard against SQL injection
957
+		if (!preg_match('/^[a-z_ ,c]+$/i',$params['order']))
958
+		{
959
+			$params['order'] = 'cal_start';
960
+		}
961
+		// gard against SQL injection
874 962
 
875 963
 		// if not enum recuring events, we have to use minimum start- AND end-dates, otherwise we get more then one event per cal_id!
876 964
 		if (!$params['enum_recuring'])
@@ -880,9 +968,15 @@  discard block
 block discarded – undo
880 968
 			// in case cal_start is used in a query, eg. calendar_ical::find_event
881 969
 			$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);
882 970
 			$params['order'] = str_replace('cal_start', 'range_start', $params['order']);
883
-			if ($end) $where[] = (int)$end.' > range_start';
971
+			if ($end)
972
+			{
973
+				$where[] = (int)$end.' > range_start';
974
+			}
884 975
   		}
885
-		elseif ($end) $where[] = (int)$end.' > cal_start';
976
+  		elseif ($end)
977
+		{
978
+			$where[] = (int)$end.' > cal_start';
979
+		}
886 980
 
887 981
 		if ($remove_rejected_by_user && $filter != 'everything')
888 982
 		{
@@ -896,7 +990,10 @@  discard block
 block discarded – undo
896 990
 				'rejected_by_user.cal_status IS NULL',
897 991
 				"rejected_by_user.cal_status NOT IN ('R','X')",
898 992
 			);
899
-			if ($filter == 'owner') $or_required[] = 'cal_owner='.(int)$remove_rejected_by_user;
993
+			if ($filter == 'owner')
994
+			{
995
+				$or_required[] = 'cal_owner='.(int)$remove_rejected_by_user;
996
+			}
900 997
 			$where[] = '('.implode(' OR ',$or_required).')';
901 998
 		}
902 999
 		// using a time-range and deleted attribute limited view instead of full table
@@ -939,7 +1036,10 @@  discard block
 block discarded – undo
939 1036
 		if ($useUnionQuery)
940 1037
 		{
941 1038
 			// allow apps to supply participants and/or icons
942
-			if (!isset($params['cols'])) $cols .= ',NULL AS participants,NULL AS icons';
1039
+			if (!isset($params['cols']))
1040
+			{
1041
+				$cols .= ',NULL AS participants,NULL AS icons';
1042
+			}
943 1043
 
944 1044
 			// changed the original OR in the query into a union, to speed up the query execution under MySQL 5
945 1045
 			// with time-range views benefit is now at best slim for huge tables or none at all!
@@ -994,9 +1094,12 @@  discard block
 block discarded – undo
994 1094
 					$selects[count($selects)-1]['where'][] = "$this->user_table.cal_recur_date=cal_start";
995 1095
 				}
996 1096
 			}
997
-			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
998 1100
 			{
999 1101
 				$save_selects = $selects;
1102
+			}
1000 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)
1001 1104
 				foreach(array_keys($selects) as $key)
1002 1105
 				{
@@ -1007,14 +1110,20 @@  discard block
 block discarded – undo
1007 1110
 							array('range_start AS cal_start','range_end AS cal_end'), $selects[$key]['cols']);
1008 1111
 					}
1009 1112
 				}
1010
-				if (!isset($params['cols']) && !$params['no_integration']) self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']);
1113
+				if (!isset($params['cols']) && !$params['no_integration'])
1114
+				{
1115
+					self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']);
1116
+				}
1011 1117
 
1012 1118
 				$this->total = $this->db->union($selects,__LINE__,__FILE__)->NumRows();
1013 1119
 
1014 1120
 				// restore original cols / selects
1015 1121
 				$selects = $save_selects; unset($save_selects);
1016 1122
 			}
1017
-			if (!isset($params['cols']) && !$params['no_integration']) self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']);
1123
+			if (!isset($params['cols']) && !$params['no_integration'])
1124
+			{
1125
+				self::get_union_selects($selects,$start,$end,$users,$cat_id,$filter,$params['query'],$params['users']);
1126
+			}
1018 1127
 
1019 1128
 			$rs = $this->db->union($selects,__LINE__,__FILE__,$params['order'],$offset,$num_rows);
1020 1129
 		}
@@ -1032,9 +1141,12 @@  discard block
 block discarded – undo
1032 1141
 				'table_def' => $cal_table_def,
1033 1142
 			));
1034 1143
 
1035
-			if (is_numeric($offset) && !$params['no_total'])	// get the total too
1144
+			if (is_numeric($offset) && !$params['no_total'])
1145
+			{
1146
+				// get the total too
1036 1147
 			{
1037 1148
 				$save_selects = $selects;
1149
+			}
1038 1150
 				// 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)
1039 1151
 				$selects[0]['cols'] = "$this->cal_table.cal_id,cal_start";
1040 1152
 				if (!isset($params['cols']) && !$params['no_integration'] && $this->db->capabilities['union'])
@@ -1062,7 +1174,10 @@  discard block
 block discarded – undo
1062 1174
 		foreach($rs as $row)
1063 1175
 		{
1064 1176
 			$id = $row['cal_id'];
1065
-			if (is_numeric($id)) $ids[] = $id;
1177
+			if (is_numeric($id))
1178
+			{
1179
+				$ids[] = $id;
1180
+			}
1066 1181
 
1067 1182
 			if ($row['cal_recur_date'])
1068 1183
 			{
@@ -1082,7 +1197,10 @@  discard block
 block discarded – undo
1082 1197
 			$row['recur_exception'] = $row['alarm'] = array();
1083 1198
 
1084 1199
 			// compile a list of recurrences per cal_id
1085
-			if (!in_array($id,(array)$recur_ids[$row['cal_id']])) $recur_ids[$row['cal_id']][] = $id;
1200
+			if (!in_array($id,(array)$recur_ids[$row['cal_id']]))
1201
+			{
1202
+				$recur_ids[$row['cal_id']][] = $id;
1203
+			}
1086 1204
 
1087 1205
 			$events[$id] = Api\Db::strip_array_keys($row,'cal_');
1088 1206
 		}
@@ -1101,10 +1219,16 @@  discard block
 block discarded – undo
1101 1219
 					//'cal_id' => array_unique($ids),
1102 1220
 					'cal_recur_date' => $recur_dates,
1103 1221
 				),__LINE__,__FILE__,false,'ORDER BY cal_id,cal_user_type DESC,'.self::STATUS_SORT,'calendar',-1,$join='',
1104
-				$this->db->get_table_definitions('calendar',$this->user_table)) as $row)	// DESC puts users before resources and contacts
1222
+				$this->db->get_table_definitions('calendar',$this->user_table)) as $row)
1223
+			{
1224
+				// DESC puts users before resources and contacts
1105 1225
 			{
1106 1226
 				$id = $row['cal_id'];
1107
-				if ($row['cal_recur_date']) $id .= '-'.$row['cal_recur_date'];
1227
+			}
1228
+				if ($row['cal_recur_date'])
1229
+				{
1230
+					$id .= '-'.$row['cal_recur_date'];
1231
+				}
1108 1232
 
1109 1233
 				// combine all participant data in uid and status values
1110 1234
 				$uid = self::combine_user($row['cal_user_type'], $row['cal_user_id'], $row['cal_user_attendee']);
@@ -1123,7 +1247,10 @@  discard block
 block discarded – undo
1123 1247
 				}
1124 1248
 
1125 1249
 				// set data, if recurrence is requested
1126
-				if (isset($events[$id])) $events[$id]['participants'][$uid] = $status;
1250
+				if (isset($events[$id]))
1251
+				{
1252
+					$events[$id]['participants'][$uid] = $status;
1253
+				}
1127 1254
 			}
1128 1255
 			// query recurrance exceptions, if needed: enum_recuring && !daywise is used in calendar_groupdav::get_series($uid,...)
1129 1256
 			if (!$params['enum_recuring'] || !$params['daywise'])
@@ -1139,7 +1266,10 @@  discard block
 block discarded – undo
1139 1266
 					{
1140 1267
 						foreach($events as $id => $event)
1141 1268
 						{
1142
-							if ($event['id'] == $row['cal_id']) break;
1269
+							if ($event['id'] == $row['cal_id'])
1270
+							{
1271
+								break;
1272
+							}
1143 1273
 						}
1144 1274
 					}
1145 1275
 					$events[$id]['recur_exception'][] = $row['cal_start'];
@@ -1149,7 +1279,10 @@  discard block
 block discarded – undo
1149 1279
 			if (!is_null($params['cfs']))
1150 1280
 			{
1151 1281
 				$where = array('cal_id' => $ids);
1152
-				if ($params['cfs']) $where['cal_extra_name'] = $params['cfs'];
1282
+				if ($params['cfs'])
1283
+				{
1284
+					$where['cal_extra_name'] = $params['cfs'];
1285
+				}
1153 1286
 				foreach($this->db->select($this->extra_table,'*',$where,
1154 1287
 					__LINE__,__FILE__,false,'','calendar') as $row)
1155 1288
 				{
@@ -1169,14 +1302,20 @@  discard block
 block discarded – undo
1169 1302
 				{
1170 1303
 					$event_start = $alarm['time'] + $alarm['offset'];
1171 1304
 
1172
-					if (isset($events[$cal_id]))	// none recuring event
1305
+					if (isset($events[$cal_id]))
1306
+					{
1307
+						// none recuring event
1173 1308
 					{
1174 1309
 						$events[$cal_id]['alarm'][$id] = $alarm;
1175 1310
 					}
1176
-					elseif (isset($events[$cal_id.'-'.$event_start]))	// recuring event
1311
+					}
1312
+					elseif (isset($events[$cal_id.'-'.$event_start]))
1313
+					{
1314
+						// recuring event
1177 1315
 					{
1178 1316
 						$events[$cal_id.'-'.$event_start]['alarm'][$id] = $alarm;
1179 1317
 					}
1318
+					}
1180 1319
 				}
1181 1320
 			}
1182 1321
 		}
@@ -1276,10 +1415,13 @@  discard block
 block discarded – undo
1276 1415
 			}
1277 1416
 			foreach((array)$cols as $col)
1278 1417
 			{
1279
-				if (substr($col,0,7) == 'egw_cal')	// remove table name
1418
+				if (substr($col,0,7) == 'egw_cal')
1419
+				{
1420
+					// remove table name
1280 1421
 				{
1281 1422
 					$col = preg_replace('/^egw_cal[a-z_]*\./','',$col);
1282 1423
 				}
1424
+				}
1283 1425
 				if (isset($app_cols[$col]))
1284 1426
 				{
1285 1427
 					$return_cols[] = $app_cols[$col];
@@ -1373,7 +1515,11 @@  discard block
 block discarded – undo
1373 1515
 		if (isset($GLOBALS['egw_info']['user']['preferences']['syncml']['minimum_uid_length']))
1374 1516
 		{
1375 1517
 			$minimum_uid_length = $GLOBALS['egw_info']['user']['preferences']['syncml']['minimum_uid_length'];
1376
-			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!
1518
+			if (empty($minimum_uid_length) || $minimum_uid_length<=1)
1519
+			{
1520
+				$minimum_uid_length = 8;
1521
+			}
1522
+			// we just do not accept no uid, or uid way to short!
1377 1523
 		}
1378 1524
 		else
1379 1525
 		{
@@ -1404,7 +1550,10 @@  discard block
 block discarded – undo
1404 1550
 			}
1405 1551
 		}
1406 1552
 		// set range_start/_end, but only if we have cal_start/_end, as otherwise we destroy present values!
1407
-		if (isset($event['cal_start'])) $event['range_start'] = $event['cal_start'];
1553
+		if (isset($event['cal_start']))
1554
+		{
1555
+			$event['range_start'] = $event['cal_start'];
1556
+		}
1408 1557
 		if (isset($event['cal_end']))
1409 1558
 		{
1410 1559
 			$event['range_end'] = $event['recur_type'] == MCAL_RECUR_NONE ? $event['cal_end'] :
@@ -1425,7 +1574,10 @@  discard block
 block discarded – undo
1425 1574
 		$event['cal_category'] = implode(',',$categories);
1426 1575
 
1427 1576
 		// make sure recurring events never reference to an other recurrent event
1428
-		if ($event['recur_type'] != MCAL_RECUR_NONE) $event['cal_reference'] = 0;
1577
+		if ($event['recur_type'] != MCAL_RECUR_NONE)
1578
+		{
1579
+			$event['cal_reference'] = 0;
1580
+		}
1429 1581
 
1430 1582
 		if ($cal_id)
1431 1583
 		{
@@ -1442,7 +1594,10 @@  discard block
 block discarded – undo
1442 1594
 			{
1443 1595
 				$old_tz_id = $this->db->select($this->cal_table,'tz_id',$where,__LINE__,__FILE__,'calendar')->fetchColumn();
1444 1596
 			}
1445
-			if (!is_null($etag)) $where['cal_etag'] = $etag;
1597
+			if (!is_null($etag))
1598
+			{
1599
+				$where['cal_etag'] = $etag;
1600
+			}
1446 1601
 
1447 1602
 			unset($event['cal_etag']);
1448 1603
 			$event[] = 'cal_etag=COALESCE(cal_etag,0)+1';	// always update the etag, even if none given to check
@@ -1453,14 +1608,24 @@  discard block
 block discarded – undo
1453 1608
 			{
1454 1609
 				return 0;	// wrong etag, someone else updated the entry
1455 1610
 			}
1456
-			if (!is_null($etag)) ++$etag;
1611
+			if (!is_null($etag))
1612
+			{
1613
+				++$etag;
1614
+			}
1457 1615
 		}
1458 1616
 		else
1459 1617
 		{
1460 1618
 			// new event
1461
-			if (!$event['cal_owner']) $event['cal_owner'] = $GLOBALS['egw_info']['user']['account_id'];
1619
+			if (!$event['cal_owner'])
1620
+			{
1621
+				$event['cal_owner'] = $GLOBALS['egw_info']['user']['account_id'];
1622
+			}
1462 1623
 
1463
-			if (!$event['cal_id'] && !isset($event['cal_uid'])) $event['cal_uid'] = '';	// uid is NOT NULL!
1624
+			if (!$event['cal_id'] && !isset($event['cal_uid']))
1625
+			{
1626
+				$event['cal_uid'] = '';
1627
+			}
1628
+			// uid is NOT NULL!
1464 1629
 
1465 1630
 			$event['cal_etag'] = $etag = 0;
1466 1631
 			$this->db->insert($this->cal_table,$event,false,__LINE__,__FILE__,'calendar');
@@ -1612,8 +1777,7 @@  discard block
 block discarded – undo
1612 1777
 					// recurrences need to be truncated
1613 1778
 					if((int)$event['recur_enddate'] > 0 &&
1614 1779
 						((int)$old_repeats['recur_enddate'] == 0 || (int)$old_repeats['recur_enddate'] > (int)$event['recur_enddate'])
1615
-					)
1616
-					{
1780
+					) {
1617 1781
 						$this->db->delete($this->user_table,array('cal_id' => $cal_id,'cal_recur_date >= '.($event['recur_enddate'] + 1*DAY_s)),__LINE__,__FILE__,'calendar');
1618 1782
 						$this->db->delete($this->dates_table,array('cal_id' => $cal_id,'cal_start >= '.($event['recur_enddate'] + 1*DAY_s)),__LINE__,__FILE__,'calendar');
1619 1783
 					}
@@ -1621,8 +1785,7 @@  discard block
 block discarded – undo
1621 1785
 					// recurrences need to be expanded
1622 1786
 					if(((int)$event['recur_enddate'] == 0 && (int)$old_repeats['recur_enddate'] > 0)
1623 1787
 						|| ((int)$event['recur_enddate'] > 0 && (int)$old_repeats['recur_enddate'] > 0 && (int)$old_repeats['recur_enddate'] < (int)$event['recur_enddate'])
1624
-					)
1625
-					{
1788
+					) {
1626 1789
 						$set_recurrences = true;
1627 1790
 						$set_recurrences_start = ($old_repeats['recur_enddate'] + 1*DAY_s);
1628 1791
 					}
@@ -1771,12 +1934,18 @@  discard block
 block discarded – undo
1771 1934
 	{
1772 1935
 		//echo "<p>socal::move($cal_id,$start,$end,$change_since,$old_start,$old_end)</p>\n";
1773 1936
 
1774
-		if (!(int) $cal_id) return false;
1937
+		if (!(int) $cal_id)
1938
+		{
1939
+			return false;
1940
+		}
1775 1941
 
1776 1942
 		if (!$old_start)
1777 1943
 		{
1778
-			if ($change_since !== false) $row = $this->db->select($this->dates_table,'MIN(cal_start) AS cal_start,MIN(cal_end) AS cal_end',
1944
+			if ($change_since !== false)
1945
+			{
1946
+				$row = $this->db->select($this->dates_table,'MIN(cal_start) AS cal_start,MIN(cal_end) AS cal_end',
1779 1947
 				array('cal_id'=>$cal_id),__LINE__,__FILE__,false,'','calendar')->fetch();
1948
+			}
1780 1949
 			// if no recurrence found, create one with the new dates
1781 1950
 			if ($change_since === false || !$row || !$row['cal_start'] || !$row['cal_end'])
1782 1951
 			{
@@ -1878,7 +2047,10 @@  discard block
 block discarded – undo
1878 2047
 			$user_type = $uid[0];
1879 2048
 			$email = substr($uid, 1);
1880 2049
 			$matches = null;
1881
-			if (preg_match('/<([^<>]+)>$/', $email, $matches)) $email = $matches[1];
2050
+			if (preg_match('/<([^<>]+)>$/', $email, $matches))
2051
+			{
2052
+				$email = $matches[1];
2053
+			}
1882 2054
 			$user_id = md5(trim(strtolower($email)));
1883 2055
 		}
1884 2056
 		else
@@ -1898,8 +2070,14 @@  discard block
 block discarded – undo
1898 2070
 	 */
1899 2071
 	static function combine_status($status,$quantity=1,$role='REQ-PARTICIPANT')
1900 2072
 	{
1901
-		if ((int)$quantity > 1) $status .= (int)$quantity;
1902
-		if ($role != 'REQ-PARTICIPANT') $status .= $role;
2073
+		if ((int)$quantity > 1)
2074
+		{
2075
+			$status .= (int)$quantity;
2076
+		}
2077
+		if ($role != 'REQ-PARTICIPANT')
2078
+		{
2079
+			$status .= $role;
2080
+		}
1903 2081
 
1904 2082
 		return $status;
1905 2083
 	}
@@ -1920,8 +2098,14 @@  discard block
 block discarded – undo
1920 2098
 		$matches = null;
1921 2099
 		if (is_string($status) && strlen($status) > 1 && preg_match('/^.([0-9]*)(.*)$/',$status,$matches))
1922 2100
 		{
1923
-			if ((int)$matches[1] > 0) $quantity = (int)$matches[1];
1924
-			if ($matches[2]) $role = $matches[2];
2101
+			if ((int)$matches[1] > 0)
2102
+			{
2103
+				$quantity = (int)$matches[1];
2104
+			}
2105
+			if ($matches[2])
2106
+			{
2107
+				$role = $matches[2];
2108
+			}
1925 2109
 			$status = $status[0];
1926 2110
 		}
1927 2111
 		elseif ($status === true)
@@ -2032,9 +2216,13 @@  discard block
 block discarded – undo
2032 2216
 			}
2033 2217
 		}
2034 2218
 
2035
-		if (count($participants))	// participants which need to be added
2219
+		if (count($participants))
2220
+		{
2221
+			// participants which need to be added
2036 2222
 		{
2037
-			if (!count($recurrences)) $recurrences[] = 0;   // insert the default recurrence
2223
+			if (!count($recurrences)) $recurrences[] = 0;
2224
+		}
2225
+		// insert the default recurrence
2038 2226
 
2039 2227
 			$delete_deleted = array();
2040 2228
 
@@ -2106,7 +2294,10 @@  discard block
 block discarded – undo
2106 2294
 			return false;
2107 2295
 		}
2108 2296
 
2109
-		if (is_numeric($status)) $status = $status_code_short[$status];
2297
+		if (is_numeric($status))
2298
+		{
2299
+			$status = $status_code_short[$status];
2300
+		}
2110 2301
 
2111 2302
 		$uid = self::combine_user($user_type, $user_id);
2112 2303
 		$user_id_md5 = null;
@@ -2126,16 +2317,25 @@  discard block
 block discarded – undo
2126 2317
 			$where[] = '(cal_recur_date=0 OR cal_recur_date >= '.time().')';
2127 2318
 		}
2128 2319
 
2129
-		if ($status == 'G')		// remove group invitations, as we dont store them in the db
2320
+		if ($status == 'G')
2321
+		{
2322
+			// remove group invitations, as we dont store them in the db
2130 2323
 		{
2131 2324
 			$this->db->delete($this->user_table,$where,__LINE__,__FILE__,'calendar');
2325
+		}
2132 2326
 			$ret = $this->db->affected_rows();
2133 2327
 		}
2134 2328
 		else
2135 2329
 		{
2136 2330
 			$set = array('cal_status' => $status);
2137
-			if ($user_type == 'e' || $attendee) $set['cal_user_attendee'] = $attendee ? $attendee : $user_id;
2138
-			if (!is_null($role) && $role != 'REQ-PARTICIPANT') $set['cal_role'] = $role;
2331
+			if ($user_type == 'e' || $attendee)
2332
+			{
2333
+				$set['cal_user_attendee'] = $attendee ? $attendee : $user_id;
2334
+			}
2335
+			if (!is_null($role) && $role != 'REQ-PARTICIPANT')
2336
+			{
2337
+				$set['cal_role'] = $role;
2338
+			}
2139 2339
 			$this->db->insert($this->user_table,$set,$where,__LINE__,__FILE__,'calendar');
2140 2340
 			// for new or changed group-invitations, remove previously deleted members, so they show up again
2141 2341
 			if (($ret = $this->db->affected_rows()) && $user_type == 'u' && $user_id < 0)
@@ -2168,7 +2368,10 @@  discard block
 block discarded – undo
2168 2368
 	{
2169 2369
 		//error_log(__METHOD__."($cal_id, $start, $end, ".array2string($participants).", ".array2string($exception));
2170 2370
 		$update = array('cal_end' => $end);
2171
-		if (isset($exception)) $update['recur_exception'] = $exception;
2371
+		if (isset($exception))
2372
+		{
2373
+			$update['recur_exception'] = $exception;
2374
+		}
2172 2375
 
2173 2376
 		$this->db->insert($this->dates_table, $update, array(
2174 2377
 			'cal_id' => $cal_id,
@@ -2183,7 +2386,11 @@  discard block
 block discarded – undo
2183 2386
 		{
2184 2387
 			foreach($participants as $uid => $status)
2185 2388
 			{
2186
-				if ($status == 'G') continue;	// dont save group-invitations
2389
+				if ($status == 'G')
2390
+				{
2391
+					continue;
2392
+				}
2393
+				// dont save group-invitations
2187 2394
 
2188 2395
 				$type = '';
2189 2396
 				$id = null;
@@ -2412,7 +2619,10 @@  discard block
 block discarded – undo
2412 2619
 			$alarm['time'] = $alarm['keep_time'] = time()+self::ALARM_KEEP_TIME;
2413 2620
 		}
2414 2621
 		// add an alarm uid, if none is given
2415
-		if (empty($alarm['uid']) && class_exists('Horde_Support_Uuid')) $alarm['uid'] = (string)new Horde_Support_Uuid;
2622
+		if (empty($alarm['uid']) && class_exists('Horde_Support_Uuid'))
2623
+		{
2624
+			$alarm['uid'] = (string)new Horde_Support_Uuid;
2625
+		}
2416 2626
 		//error_log(__METHOD__.__LINE__.' Save Alarm for CalID:'.$cal_id.'->'.array2string($alarm).'-->'.$id.'#'.function_backtrace());
2417 2627
 		// allways store job with the alarm owner as job-owner to get eg. the correct from address
2418 2628
 		if (!$this->async->set_timer($alarm['time'], $id, 'calendar.calendar_boupdate.send_alarm', $alarm, $alarm['owner'], false, true))
@@ -2421,10 +2631,16 @@  discard block
 block discarded – undo
2421 2631
 		}
2422 2632
 
2423 2633
 		// update the modification information of the related event
2424
-		if ($update_modified) $this->updateModified($cal_id, true);
2634
+		if ($update_modified)
2635
+		{
2636
+			$this->updateModified($cal_id, true);
2637
+		}
2425 2638
 
2426 2639
 		// update cache, if used
2427
-		if (isset(self::$alarm_cache)) $this->read_alarms($cal_id, true);
2640
+		if (isset(self::$alarm_cache))
2641
+		{
2642
+			$this->read_alarms($cal_id, true);
2643
+		}
2428 2644
 
2429 2645
 		return $id;
2430 2646
 	}
@@ -2447,7 +2663,10 @@  discard block
 block discarded – undo
2447 2663
 				$this->async->cancel_timer($id);
2448 2664
 			}
2449 2665
 			// update cache, if used
2450
-			if (isset(self::$alarm_cache)) $this->read_alarms($cal_id, false);
2666
+			if (isset(self::$alarm_cache))
2667
+			{
2668
+				$this->read_alarms($cal_id, false);
2669
+			}
2451 2670
 		}
2452 2671
 		return count($alarms);
2453 2672
 	}
@@ -2470,7 +2689,10 @@  discard block
 block discarded – undo
2470 2689
 		$ret = $this->async->cancel_timer($id);
2471 2690
 
2472 2691
 		// update cache, if used
2473
-		if (isset(self::$alarm_cache)) $this->read_alarms($cal_id, true);
2692
+		if (isset(self::$alarm_cache))
2693
+		{
2694
+			$this->read_alarms($cal_id, true);
2695
+		}
2474 2696
 
2475 2697
 		return $ret;
2476 2698
 	}
@@ -2494,11 +2716,14 @@  discard block
 block discarded – undo
2494 2716
 			$user_id = null;
2495 2717
 			self::split_user($old_user,$user_type,$user_id);
2496 2718
 
2497
-			if ($user_type == 'u')	// only accounts can be owners of events
2719
+			if ($user_type == 'u')
2720
+			{
2721
+				// only accounts can be owners of events
2498 2722
 			{
2499 2723
 				foreach($this->db->select($this->cal_table,'cal_id',array('cal_owner' => $old_user),__LINE__,__FILE__,false,'','calendar') as $row)
2500 2724
 				{
2501 2725
 					$this->delete($row['cal_id']);
2726
+			}
2502 2727
 				}
2503 2728
 			}
2504 2729
 			$this->db->delete($this->user_table,array(
@@ -2526,11 +2751,14 @@  discard block
 block discarded – undo
2526 2751
 			{
2527 2752
 				$ids[] = $row['cal_id'];
2528 2753
 			}
2529
-			if ($ids) $this->db->delete($this->user_table,array(
2754
+			if ($ids)
2755
+			{
2756
+				$this->db->delete($this->user_table,array(
2530 2757
 				'cal_user_type' => 'u',
2531 2758
 				'cal_user_id' => $old_user,
2532 2759
 				'cal_id' => $ids,
2533 2760
 			),__LINE__,__FILE__,'calendar');
2761
+			}
2534 2762
 			// now change participant in the rest to contain new user instead of old user
2535 2763
 			$this->db->update($this->user_table,array(
2536 2764
 				'cal_user_id' => $new_user,
@@ -2555,8 +2783,14 @@  discard block
 block discarded – undo
2555 2783
 	{
2556 2784
 		$participant_status = array();
2557 2785
 		$where = array('cal_id' => $cal_id);
2558
-		if ($start != 0 && $end == 0) $where[] = '(cal_recur_date = 0 OR cal_recur_date >= ' . (int)$start . ')';
2559
-		if ($start == 0 && $end != 0) $where[] = '(cal_recur_date = 0 OR cal_recur_date <= ' . (int)$end . ')';
2786
+		if ($start != 0 && $end == 0)
2787
+		{
2788
+			$where[] = '(cal_recur_date = 0 OR cal_recur_date >= ' . (int)$start . ')';
2789
+		}
2790
+		if ($start == 0 && $end != 0)
2791
+		{
2792
+			$where[] = '(cal_recur_date = 0 OR cal_recur_date <= ' . (int)$end . ')';
2793
+		}
2560 2794
 		if ($start != 0 && $end != 0)
2561 2795
 		{
2562 2796
 			$where[] = '(cal_recur_date = 0 OR (cal_recur_date >= ' . (int)$start .
@@ -2567,7 +2801,10 @@  discard block
 block discarded – undo
2567 2801
 			// inititalize the array
2568 2802
 			$participant_status[$row['cal_recur_date']] = null;
2569 2803
 		}
2570
-		if (is_null($uid)) return $participant_status;
2804
+		if (is_null($uid))
2805
+		{
2806
+			return $participant_status;
2807
+		}
2571 2808
 		$user_type = $user_id = null;
2572 2809
 		self::split_user($uid, $user_type, $user_id, true);
2573 2810
 
@@ -2576,8 +2813,14 @@  discard block
 block discarded – undo
2576 2813
 			'cal_user_type'	=> $user_type ? $user_type : 'u',
2577 2814
 			'cal_user_id'   => $user_id,
2578 2815
 		);
2579
-		if ($start != 0 && $end == 0) $where2[] = '(cal_recur_date = 0 OR cal_recur_date >= ' . (int)$start . ')';
2580
-		if ($start == 0 && $end != 0) $where2[] = '(cal_recur_date = 0 OR cal_recur_date <= ' . (int)$end . ')';
2816
+		if ($start != 0 && $end == 0)
2817
+		{
2818
+			$where2[] = '(cal_recur_date = 0 OR cal_recur_date >= ' . (int)$start . ')';
2819
+		}
2820
+		if ($start == 0 && $end != 0)
2821
+		{
2822
+			$where2[] = '(cal_recur_date = 0 OR cal_recur_date <= ' . (int)$end . ')';
2823
+		}
2581 2824
 		if ($start != 0 && $end != 0)
2582 2825
 		{
2583 2826
 			$where2[] = '(cal_recur_date = 0 OR (cal_recur_date >= ' . (int)$start .
@@ -2667,17 +2910,26 @@  discard block
 block discarded – undo
2667 2910
 	 */
2668 2911
 	function get_recurrence_exceptions($event, $tz_id=null, $start=0, $end=0, $filter='all')
2669 2912
 	{
2670
-		if (!is_array($event)) return false;
2913
+		if (!is_array($event))
2914
+		{
2915
+			return false;
2916
+		}
2671 2917
 		$cal_id = (int) $event['id'];
2672 2918
 		//error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2673 2919
 		//		"($cal_id, $tz_id, $filter): " . $event['tzid']);
2674
-		if (!$cal_id || $event['recur_type'] == MCAL_RECUR_NONE) return false;
2920
+		if (!$cal_id || $event['recur_type'] == MCAL_RECUR_NONE)
2921
+		{
2922
+			return false;
2923
+		}
2675 2924
 
2676 2925
 		$days = array();
2677 2926
 
2678 2927
 		$expand_all = (!$this->isWholeDay($event) && $tz_id && $tz_id != $event['tzid']);
2679 2928
 
2680
-		if ($filter == 'tz_only' && !$expand_all) return $days;
2929
+		if ($filter == 'tz_only' && !$expand_all)
2930
+		{
2931
+			return $days;
2932
+		}
2681 2933
 
2682 2934
 		$remote = in_array($filter, array('tz_rrule', 'rrule'));
2683 2935
 
@@ -2720,7 +2972,10 @@  discard block
 block discarded – undo
2720 2972
 					$remote_rrule->next_no_exception();
2721 2973
 				}
2722 2974
 				$egw_rrule->next_no_exception();
2723
-				if (!$egw_rrule->valid()) return $days;
2975
+				if (!$egw_rrule->valid())
2976
+				{
2977
+					return $days;
2978
+				}
2724 2979
 			}
2725 2980
 			$day = $egw_rrule->current();
2726 2981
 			$locts = (int)Api\DateTime::to($day,'server');
@@ -2874,7 +3129,11 @@  discard block
 block discarded – undo
2874 3129
 			}
2875 3130
 		}
2876 3131
 
2877
-		if (empty($participants)) return false; // occurrence does not exist at all yet
3132
+		if (empty($participants))
3133
+		{
3134
+			return false;
3135
+		}
3136
+		// occurrence does not exist at all yet
2878 3137
 
2879 3138
 		foreach ($recurrence_zero as $uid => $status)
2880 3139
 		{
@@ -2931,7 +3190,9 @@  discard block
 block discarded – undo
2931 3190
 			}
2932 3191
 			if (!isset($participants[$uid])
2933 3192
 				|| $participants[$uid] != $status)
2934
-				return true;
3193
+			{
3194
+							return true;
3195
+			}
2935 3196
 			unset($participants[$uid]);
2936 3197
 		}
2937 3198
 		return (!empty($participants));
@@ -2945,7 +3206,10 @@  discard block
 block discarded – undo
2945 3206
 	 */
2946 3207
 	function isWholeDay($event)
2947 3208
 	{
2948
-		if (!isset($event['start']) || !isset($event['end'])) return false;
3209
+		if (!isset($event['start']) || !isset($event['end']))
3210
+		{
3211
+			return false;
3212
+		}
2949 3213
 
2950 3214
 		if (empty($event['tzid']))
2951 3215
 		{
@@ -3007,8 +3271,14 @@  discard block
 block discarded – undo
3007 3271
 	 */
3008 3272
 	function updateModified($id, $update_master=false, $time=null, $modifier=null)
3009 3273
 	{
3010
-		if (is_null($time) || !$time) $time = time();
3011
-		if (is_null($modifier)) $modifier = $GLOBALS['egw_info']['user']['account_id'];
3274
+		if (is_null($time) || !$time)
3275
+		{
3276
+			$time = time();
3277
+		}
3278
+		if (is_null($modifier))
3279
+		{
3280
+			$modifier = $GLOBALS['egw_info']['user']['account_id'];
3281
+		}
3012 3282
 
3013 3283
 		$this->db->update($this->cal_table,
3014 3284
 			array('cal_modified' => $time, 'cal_modifier' => $modifier),
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.
api/images.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -28,17 +28,17 @@  discard block
 block discarded – undo
28 28
 
29 29
 include '../header.inc.php';
30 30
 
31
-$content = json_encode(Api\Image::map(preg_match('/^[a-z0-9_-]+$/i',$_GET['template']) ? $_GET['template'] : null, $_GET['svg']),
32
-	JSON_FORCE_OBJECT |	// export empty php-arrays as empty objects, not empty arrays
33
-	JSON_UNESCAPED_SLASHES | // do not escape slashes, smaller and better readable
31
+$content = json_encode(Api\Image::map(preg_match('/^[a-z0-9_-]+$/i', $_GET['template']) ? $_GET['template'] : null, $_GET['svg']),
32
+	JSON_FORCE_OBJECT|// export empty php-arrays as empty objects, not empty arrays
33
+	JSON_UNESCAPED_SLASHES|// do not escape slashes, smaller and better readable
34 34
 	(!empty($_GET['debug']) ? JSON_PRETTY_PRINT : 0));
35 35
 
36 36
 // use an etag over the image mapp
37 37
 $etag = '"'.md5($content).'"';
38 38
 
39 39
 // headers to allow caching, egw_framework specifies etag on url to force reload, even with Expires header
40
-Api\Session::cache_control(86400);	// cache for one day
41
-Header('Content-Type: '.(empty($_GET['debug'])?'text/javascript':'application/json').'; charset=utf-8');
40
+Api\Session::cache_control(86400); // cache for one day
41
+Header('Content-Type: '.(empty($_GET['debug']) ? 'text/javascript' : 'application/json').'; charset=utf-8');
42 42
 Header('ETag: '.$etag);
43 43
 
44 44
 // if servers send a If-None-Match header, response with 304 Not Modified, if etag matches
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 if (empty($_GET['debug'])) $content = 'egw.set_images('.$content.", egw && egw.window !== window);\n";
52 52
 
53 53
 // we run our own gzip compression, to set a correct Content-Length of the encoded content
54
-if (in_array('gzip', explode(',',$_SERVER['HTTP_ACCEPT_ENCODING'])) && function_exists('gzencode'))
54
+if (in_array('gzip', explode(',', $_SERVER['HTTP_ACCEPT_ENCODING'])) && function_exists('gzencode'))
55 55
 {
56 56
 	$content = gzencode($content);
57 57
 	header('Content-Encoding: gzip');
Please login to merge, or discard this patch.
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -48,7 +48,10 @@
 block discarded – undo
48 48
 	exit;
49 49
 }
50 50
 
51
-if (empty($_GET['debug'])) $content = 'egw.set_images('.$content.", egw && egw.window !== window);\n";
51
+if (empty($_GET['debug']))
52
+{
53
+	$content = 'egw.set_images('.$content.", egw && egw.window !== window);\n";
54
+}
52 55
 
53 56
 // we run our own gzip compression, to set a correct Content-Length of the encoded content
54 57
 if (in_array('gzip', explode(',',$_SERVER['HTTP_ACCEPT_ENCODING'])) && function_exists('gzencode'))
Please login to merge, or discard this patch.
api/src/Framework/Template.php 3 patches
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	 *	- function-name like set_var to get eg. all assignments or
33 33
 	 *	- handle- / variable-names - if you are only interested in some variables ;-)
34 34
 	 */
35
-	var $debug = False;	// array('cat_list','cat_list_t');
35
+	var $debug = False; // array('cat_list','cat_list_t');
36 36
 
37 37
 	/**
38 38
 	 * $file[handle] = 'filename';
@@ -128,9 +128,9 @@  discard block
 block discarded – undo
128 128
 	 */
129 129
 	function set_file($handle, $filename = '')
130 130
 	{
131
-		if ($this->debug && $this->check_debug('set_file',$handle,$filename))
131
+		if ($this->debug && $this->check_debug('set_file', $handle, $filename))
132 132
 		{
133
-			echo "<p>Template::set_file('".print_r($handle,true)."','$filename')</p>\n";
133
+			echo "<p>Template::set_file('".print_r($handle, true)."','$filename')</p>\n";
134 134
 		}
135 135
 		if (!is_array($handle))
136 136
 		{
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 		}
144 144
 		else
145 145
 		{
146
-			foreach($handle as $h => $f)
146
+			foreach ($handle as $h => $f)
147 147
 			{
148 148
 				$this->file[$h] = $this->filename($f);
149 149
 			}
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 	 */
161 161
 	function set_block($parent, $handle, $name = '')
162 162
 	{
163
-		if ($this->debug && $this->check_debug('set_block',$parent,$handle,$name))
163
+		if ($this->debug && $this->check_debug('set_block', $parent, $handle, $name))
164 164
 		{
165 165
 			echo "<p>Template::set_block('$parent','$handle','$name')</p>\n";
166 166
 		}
@@ -177,14 +177,14 @@  discard block
 block discarded – undo
177 177
 		$qhandle = preg_quote($handle);
178 178
 		$reg = "/<!--\\s+BEGIN $qhandle\\s+-->(.*)\n\\s*<!--\\s+END $qhandle\\s+-->/s";
179 179
 		$match = null;
180
-		if (!preg_match($reg,$str,$match))
180
+		if (!preg_match($reg, $str, $match))
181 181
 		{
182 182
 			// unfortunaly some apps set non-existing blocks, therefor I have to disable this diagnostics again for now
183 183
 			$this->halt("set_block: unable to find block '$handle' in '$parent'=<pre>".htmlspecialchars($str)."</pre> this->root=$this->root");
184 184
 			// return False;
185 185
 		}
186
-		$this->set_var($handle,$match[1]);
187
-		$this->set_var($parent,preg_replace($reg, '{' . "$name}",$str));
186
+		$this->set_var($handle, $match[1]);
187
+		$this->set_var($parent, preg_replace($reg, '{'."$name}", $str));
188 188
 	}
189 189
 
190 190
 	/* public: set_var(array $values)
@@ -205,18 +205,18 @@  discard block
 block discarded – undo
205 205
 				$varname => $value
206 206
 			);
207 207
 		}
208
-		foreach($varname as $k => $v)
208
+		foreach ($varname as $k => $v)
209 209
 		{
210 210
 			if (!empty($k))
211 211
 			{
212
-				if ($this->debug && $this->check_debug('set_var',$k))
212
+				if ($this->debug && $this->check_debug('set_var', $k))
213 213
 				{
214 214
 					echo "<p>Template::set_var('$k','$v')</p>\n";
215 215
 				}
216 216
 				$this->varkeys[$k] = $this->varname($k);
217 217
 				$this->varvals[$k] = $this->egroupware_hack ? str_replace(
218
-					array('phpGroupWare','www.phpgroupware.org'),
219
-					array('eGroupWare','www.eGroupWare.org'),$v
218
+					array('phpGroupWare', 'www.phpgroupware.org'),
219
+					array('eGroupWare', 'www.eGroupWare.org'), $v
220 220
 				) : $v;
221 221
 			}
222 222
 		}
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 	 */
231 231
 	function subst($handle)
232 232
 	{
233
-		if ($this->debug && $this->check_debug('subst',$handle))
233
+		if ($this->debug && $this->check_debug('subst', $handle))
234 234
 		{
235 235
 			echo "<p>Template::subst('$handle')</p>\n";
236 236
 		}
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 		}
242 242
 
243 243
 		$str = $this->get_var($handle);
244
-		foreach($this->varkeys as $k => $v)
244
+		foreach ($this->varkeys as $k => $v)
245 245
 		{
246 246
 			$str = str_replace($v, $this->varvals[$k], $str);
247 247
 		}
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
 			$str = $this->subst($handle);
277 277
 			if ($append)
278 278
 			{
279
-				$this->set_var($target, $this->get_var($target) . $str);
279
+				$this->set_var($target, $this->get_var($target).$str);
280 280
 			}
281 281
 			else
282 282
 			{
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 		}
286 286
 		else
287 287
 		{
288
-			foreach($handle as $h)
288
+			foreach ($handle as $h)
289 289
 			{
290 290
 				$str = $this->subst($h);
291 291
 				$this->set_var($target, $str);
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
 	 */
333 333
 	function get_vars()
334 334
 	{
335
-		foreach(array_keys($this->varkeys) as $k)
335
+		foreach (array_keys($this->varkeys) as $k)
336 336
 		{
337 337
 			$result[$k] = $this->varvals[$k];
338 338
 		}
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
 		}
354 354
 		else
355 355
 		{
356
-			foreach(array_keys($varname) as $k)
356
+			foreach (array_keys($varname) as $k)
357 357
 			{
358 358
 				$result[$k] = $this->varvals[$k];
359 359
 			}
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
 		{
383 383
 			return false;
384 384
 		}
385
-		foreach($m as $v)
385
+		foreach ($m as $v)
386 386
 		{
387 387
 			if (!isset($this->varkeys[$v]))
388 388
 			{
@@ -448,15 +448,15 @@  discard block
 block discarded – undo
448 448
 	 * @param string $root ='' default $this->root
449 449
 	 * @param int $time =1
450 450
 	 */
451
-	protected function filename($filename,$root='',$time=1)
451
+	protected function filename($filename, $root = '', $time = 1)
452 452
 	{
453
-		if($root == '')
453
+		if ($root == '')
454 454
 		{
455 455
 			$root = $this->root;
456 456
 		}
457
-		if(substr($filename, 0, 1) != '/')
457
+		if (substr($filename, 0, 1) != '/')
458 458
 		{
459
-			$new_filename = $root . '/' . $filename;
459
+			$new_filename = $root.'/'.$filename;
460 460
 		}
461 461
 		else
462 462
 		{
@@ -465,14 +465,14 @@  discard block
 block discarded – undo
465 465
 
466 466
 		if (!file_exists($new_filename))
467 467
 		{
468
-			if($time==2)
468
+			if ($time == 2)
469 469
 			{
470 470
 				$this->halt("filename: file $new_filename does not exist.");
471 471
 			}
472 472
 			else
473 473
 			{
474
-				$new_root = dirname($root) . DIRECTORY_SEPARATOR . 'default';
475
-				$new_filename = $this->filename(str_replace($root.'/','',$new_filename),$new_root,2);
474
+				$new_root = dirname($root).DIRECTORY_SEPARATOR.'default';
475
+				$new_filename = $this->filename(str_replace($root.'/', '', $new_filename), $new_root, 2);
476 476
 			}
477 477
 		}
478 478
 		return $new_filename;
@@ -491,9 +491,9 @@  discard block
 block discarded – undo
491 491
 	 */
492 492
 	function loadfile($handle)
493 493
 	{
494
-		if ($this->debug && $this->check_debug('loadfile',$handle))
494
+		if ($this->debug && $this->check_debug('loadfile', $handle))
495 495
 		{
496
-			echo "<p>Template::loadfile('$handle') file=<pre>\n".print_r($this->file,True)."</pre>\n";
496
+			echo "<p>Template::loadfile('$handle') file=<pre>\n".print_r($this->file, True)."</pre>\n";
497 497
 			echo "<p>backtrace: ".function_backtrace()."</p>\n";
498 498
 		}
499 499
 		if (isset($this->varkeys[$handle]) && !empty($this->varvals[$handle]))
@@ -502,9 +502,9 @@  discard block
 block discarded – undo
502 502
 		}
503 503
 		if (!isset($this->file[$handle]))
504 504
 		{
505
-			if ($this->debug && $this->check_debug('loadfile',$handle))
505
+			if ($this->debug && $this->check_debug('loadfile', $handle))
506 506
 			{
507
-				echo "varkeys =<pre>".print_r($this->varkeys,True)."</pre>varvals =<pre>".print_r($this->varvals,True)."</pre>\n";
507
+				echo "varkeys =<pre>".print_r($this->varkeys, True)."</pre>varvals =<pre>".print_r($this->varvals, True)."</pre>\n";
508 508
 			}
509 509
 			$this->halt("loadfile: $handle is not a valid handle.");
510 510
 			return false;
@@ -549,10 +549,10 @@  discard block
 block discarded – undo
549 549
 	{
550 550
 		if (!$this->debug) return False;
551 551
 
552
-		foreach(func_get_args() as $arg)
552
+		foreach (func_get_args() as $arg)
553 553
 		{
554 554
 			if (!is_array($this->debug) && $this->debug === $arg ||
555
-				(is_array($this->debug) && (@$this->debug[$arg] || in_array($arg,$this->debug,True))))
555
+				(is_array($this->debug) && (@$this->debug[$arg] || in_array($arg, $this->debug, True))))
556 556
 			{
557 557
 				return True;
558 558
 			}
@@ -601,8 +601,8 @@  discard block
 block discarded – undo
601 601
 		{
602 602
 			$GLOBALS['egw_info']['server']['template_set'] = 'idots';
603 603
 		}
604
-		$tpldir         = EGW_SERVER_ROOT . '/' . $appname . '/templates/' . $GLOBALS['egw_info']['server']['template_set'];
605
-		$tpldir_default = EGW_SERVER_ROOT . '/' . $appname . '/templates/default';
604
+		$tpldir         = EGW_SERVER_ROOT.'/'.$appname.'/templates/'.$GLOBALS['egw_info']['server']['template_set'];
605
+		$tpldir_default = EGW_SERVER_ROOT.'/'.$appname.'/templates/default';
606 606
 
607 607
 		if (@is_dir($tpldir))
608 608
 		{
Please login to merge, or discard this patch.
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -547,7 +547,10 @@
 block discarded – undo
547 547
 
548 548
 	function check_debug()
549 549
 	{
550
-		if (!$this->debug) return False;
550
+		if (!$this->debug)
551
+		{
552
+			return False;
553
+		}
551 554
 
552 555
 		foreach(func_get_args() as $arg)
553 556
 		{
Please login to merge, or discard this patch.
Doc Comments   +6 added lines, -1 removed lines patch added patch discarded remove patch
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 	 * @param string $parent name of tempalte containing $handle
157 157
 	 * @param string $handle name of part
158 158
 	 * @param string $name name of variable/placeholder
159
-	 * @return boolean
159
+	 * @return false|null
160 160
 	 */
161 161
 	function set_block($parent, $handle, $name = '')
162 162
 	{
@@ -311,6 +311,8 @@  discard block
 block discarded – undo
311 311
 
312 312
 	/**
313 313
 	 * This is short for finish parse
314
+	 * @param string $target
315
+	 * @param string $handle
314 316
 	 */
315 317
 	function fp($target, $handle, $append = False)
316 318
 	{
@@ -319,6 +321,8 @@  discard block
 block discarded – undo
319 321
 
320 322
 	/**
321 323
 	 * This is a short cut for print finish parse
324
+	 * @param string $target
325
+	 * @param string $handle
322 326
 	 */
323 327
 	function pfp($target, $handle, $append = False)
324 328
 	{
@@ -365,6 +369,7 @@  discard block
 block discarded – undo
365 369
 	 * Return undefined variables/placeholders of a handle
366 370
 	 *
367 371
 	 * @param string handle handle of a template
372
+	 * @param string $handle
368 373
 	 * @return array|boolean array with undefined variables as key and value, or false if none
369 374
 	 */
370 375
 	function get_undefined($handle)
Please login to merge, or discard this patch.
api/src/Framework/Tutorial.php 3 patches
Spacing   +7 added lines, -8 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	 *
33 33
 	 * @param array $content
34 34
 	 */
35
-	function popup ($content=null)
35
+	function popup($content = null)
36 36
 	{
37 37
 		// check and if not done register tutorial_menu hook
38 38
 		if (!Api\Hooks::exists('sidebox_all', 'api') ||
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 		if (!is_array($content))
49 49
 		{
50 50
 			// Get tutorial object id
51
-			$tuid_indx = explode('-',$_GET['tuid']);
51
+			$tuid_indx = explode('-', $_GET['tuid']);
52 52
 			$appName = $tuid_indx[0];
53 53
 			$lang = $tuid_indx[1];
54 54
 			$id = $tuid_indx[2];
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 		{
58 58
 			$appName = $content['list']['apps'];
59 59
 			$lang = $GLOBALS['egw_info']['user']['preferences']['common']['lang'];
60
-			$id ="0";
60
+			$id = "0";
61 61
 		}
62 62
 		// read tutorials json file to fetch data
63 63
 		$tutorials = json_decode(self::getJsonData(), true);
@@ -74,8 +74,7 @@  discard block
 block discarded – undo
74 74
 		if (in_array($appName, array_keys($GLOBALS['egw_info']['user']['apps'])) || $appName === "introduction")
75 75
 		{
76 76
 			// fallback to english video
77
-			$tutorial = $tutorials[$appName][$lang][$id]? $tutorials[$appName][$lang][$id]:
78
-				$tutorials[$appName]['en'][$id];
77
+			$tutorial = $tutorials[$appName][$lang][$id] ? $tutorials[$appName][$lang][$id] : $tutorials[$appName]['en'][$id];
79 78
 
80 79
 			$list = array(
81 80
 				'apps' => $appName,
@@ -86,7 +85,7 @@  discard block
 block discarded – undo
86 85
 				$v ['onclick'] = 'app[egw.app_name()].tutorial_videoOnClick("'.$v['src'].'")';
87 86
 				array_push($list, $v);
88 87
 			}
89
-			$content = array (
88
+			$content = array(
90 89
 				'src' => $tutorial['src'],
91 90
 				'title' => $tutorial['title'],
92 91
 				'desc' => $tutorial['desc'],
@@ -137,13 +136,13 @@  discard block
 block discarded – undo
137 136
 	public static function tutorial_menu()
138 137
 	{
139 138
 		if (Api\Header\UserAgent::mobile()) return;
140
-		$tutorials = json_decode(self::getJsonData(),true);
139
+		$tutorials = json_decode(self::getJsonData(), true);
141 140
 		$appname = $GLOBALS['egw_info']['flags']['currentapp'];
142 141
 		if (!is_array($tutorials[$appname])) return false;
143 142
 		if (!$GLOBALS['egw_info']['server']['egw_tutorial_disable']
144 143
 			|| $GLOBALS['egw_info']['server']['egw_tutorial_disable'] == 'intro')
145 144
 		{
146
-			$file = Array (
145
+			$file = Array(
147 146
 				array(
148 147
 					'text'    => '<div id="egw_tutorial_'.$appname.'_sidebox" class="egwTutorial"/>',
149 148
 					'no_lang' => true,
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -143,7 +143,7 @@
 block discarded – undo
143 143
 		if (!$GLOBALS['egw_info']['server']['egw_tutorial_disable']
144 144
 			|| $GLOBALS['egw_info']['server']['egw_tutorial_disable'] == 'intro')
145 145
 		{
146
-			$file = Array (
146
+			$file = array (
147 147
 				array(
148 148
 					'text'    => '<div id="egw_tutorial_'.$appname.'_sidebox" class="egwTutorial"/>',
149 149
 					'no_lang' => true,
Please login to merge, or discard this patch.
Braces   +16 added lines, -4 removed lines patch added patch discarded remove patch
@@ -65,7 +65,10 @@  discard block
 block discarded – undo
65 65
 		foreach (array_keys($tutorials) as $app)
66 66
 		{
67 67
 			// show only apps user has access to them
68
-			if (in_array($app, array_keys($GLOBALS['egw_info']['user']['apps']))) $apps [$app] = $app;
68
+			if (in_array($app, array_keys($GLOBALS['egw_info']['user']['apps'])))
69
+			{
70
+				$apps [$app] = $app;
71
+			}
69 72
 		}
70 73
 		$sel_options = array(
71 74
 			'apps' => $apps,
@@ -123,7 +126,10 @@  discard block
 block discarded – undo
123 126
 			$json = file_get_contents('https://www.egroupware.org/videos/tutorials.json',
124 127
 				false, Api\Framework::proxy_context());
125 128
 			// Fallback tutorials.json
126
-			if (!$json) $json = file_get_contents('api/setup/tutorials.json');
129
+			if (!$json)
130
+			{
131
+				$json = file_get_contents('api/setup/tutorials.json');
132
+			}
127 133
 			// Cache the json object for two hours
128 134
 			Api\Cache::setCache(Api\Cache::TREE, __CLASS__, 'egw_tutorial_json', $json, 7200);
129 135
 		}
@@ -137,10 +143,16 @@  discard block
 block discarded – undo
137 143
 	 */
138 144
 	public static function tutorial_menu()
139 145
 	{
140
-		if (Api\Header\UserAgent::mobile()) return;
146
+		if (Api\Header\UserAgent::mobile())
147
+		{
148
+			return;
149
+		}
141 150
 		$tutorials = json_decode(self::getJsonData(),true);
142 151
 		$appname = $GLOBALS['egw_info']['flags']['currentapp'];
143
-		if (!is_array($tutorials[$appname])) return false;
152
+		if (!is_array($tutorials[$appname]))
153
+		{
154
+			return false;
155
+		}
144 156
 		if (!$GLOBALS['egw_info']['server']['egw_tutorial_disable']
145 157
 			|| $GLOBALS['egw_info']['server']['egw_tutorial_disable'] == 'intro')
146 158
 		{
Please login to merge, or discard this patch.
api/src/Framework/Bundle.php 2 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 			$bundles = Cache::getTree(__CLASS__, 'bundles', array(__CLASS__, 'all'), array(), 7200);
52 52
 			$bundles_ts = $bundles['.ts'];
53 53
 			unset($bundles['.ts']);
54
-			foreach($bundles as $name => $files)
54
+			foreach ($bundles as $name => $files)
55 55
 			{
56 56
 				// to facilitate move to new api/et2 location, can be removed after 16.1 release
57 57
 				if ($name == 'et21' && !in_array('/api/js/etemplate/etemplate2.js', $files) ||
@@ -72,9 +72,9 @@  discard block
 block discarded – undo
72 72
 		}
73 73
 		$to_include = $included_bundles = array();
74 74
 		$query = null;
75
-		foreach($js_includes as $file)
75
+		foreach ($js_includes as $file)
76 76
 		{
77
-			if ($file == '/api/js/jsapi/egw.js') continue;	// loaded via own tag, and we must not load it twice!
77
+			if ($file == '/api/js/jsapi/egw.js') continue; // loaded via own tag, and we must not load it twice!
78 78
 
79 79
 			if (!isset($to_include[$file]))
80 80
 			{
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 	 * @param string $minurl =null url of minified bundle, to be used, if existing and recent
130 130
 	 * @return array js-files (can be more then one, if one of given files can not be bundeled)
131 131
 	 */
132
-	protected static function urls(array $js_includes, &$max_modified=null, $minurl=null)
132
+	protected static function urls(array $js_includes, &$max_modified = null, $minurl = null)
133 133
 	{
134 134
 		$debug_minify = $GLOBALS['egw_info']['server']['debug_minify'] === 'True';
135 135
 		// ignore not existing minurl
@@ -137,28 +137,28 @@  discard block
 block discarded – undo
137 137
 		$to_include_first = $to_include = $to_minify = array();
138 138
 		$max_modified = 0;
139 139
 		$query = null;
140
-		foreach($js_includes as $path)
140
+		foreach ($js_includes as $path)
141 141
 		{
142 142
 			if ($path == '/api/js/jsapi/egw.js') continue; // Leave egw.js out of bundle
143 143
 			unset($query);
144
-			list($path,$query) = explode('?',$path,2);
144
+			list($path, $query) = explode('?', $path, 2);
145 145
 			$mod = filemtime(EGW_SERVER_ROOT.$path);
146 146
 			if ($mod > $max_modified) $max_modified = $mod;
147 147
 
148 148
 			// ckeditor must be included before bundled files, as they depend on it!
149
-			if (strpos($path,'/ckeditor/ckeditor.js') !== false)
149
+			if (strpos($path, '/ckeditor/ckeditor.js') !== false)
150 150
 			{
151
-				$to_include_first[] = $path . '?' . $mod;
151
+				$to_include_first[] = $path.'?'.$mod;
152 152
 			}
153 153
 			// for now minify does NOT support query parameters, nor php files generating javascript
154 154
 			elseif ($debug_minify || $query || substr($path, -3) != '.js' || empty($minurl))
155 155
 			{
156
-				$path .= '?'. $mod.($query ? '&'.$query : '');
156
+				$path .= '?'.$mod.($query ? '&'.$query : '');
157 157
 				$to_include[] = $path;
158 158
 			}
159 159
 			else
160 160
 			{
161
-				$to_minify[] = substr($path,1);
161
+				$to_minify[] = substr($path, 1);
162 162
 			}
163 163
 		}
164 164
 		if (!$debug_minify && $to_minify)
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 		$stock_files = call_user_func_array('array_merge', $bundles);
247 247
 
248 248
 		// generate template and app bundles, if installed
249
-		foreach(array(
249
+		foreach (array(
250 250
 			'jdots' => '/jdots/js/fw_jdots.js',
251 251
 			'mobile' => '/pixelegg/js/fw_mobile.js',
252 252
 			'pixelegg' => '/pixelegg/js/fw_pixelegg.js',
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 		{
258 258
 			if (@file_exists(EGW_SERVER_ROOT.$file))
259 259
 			{
260
-				$inc_mgr = new IncludeMgr($stock_files);	// reset loaded files to stock files
260
+				$inc_mgr = new IncludeMgr($stock_files); // reset loaded files to stock files
261 261
 				$inc_mgr->include_js_file($file);
262 262
 				$bundles[$bundle] = array_diff($inc_mgr->get_included_files(), $stock_files);
263 263
 				self::urls($bundles[$bundle], $max_mod[$bundle]);
@@ -265,12 +265,12 @@  discard block
 block discarded – undo
265 265
 		}
266 266
 
267 267
 		// automatic split bundles with more then MAX_BUNDLE_FILES (=50) files
268
-		foreach($bundles as $name => $files)
268
+		foreach ($bundles as $name => $files)
269 269
 		{
270 270
 			$n = '';
271
-			while (count($files) > self::MAX_BUNDLE_FILES*(int)$n)
271
+			while (count($files) > self::MAX_BUNDLE_FILES * (int)$n)
272 272
 			{
273
-				$files80 = array_slice($files, self::MAX_BUNDLE_FILES*(int)$n, self::MAX_BUNDLE_FILES, true);
273
+				$files80 = array_slice($files, self::MAX_BUNDLE_FILES * (int)$n, self::MAX_BUNDLE_FILES, true);
274 274
 				$bundles[$name.$n++] = $files80;
275 275
 			}
276 276
 		}
Please login to merge, or discard this patch.
Braces   +22 added lines, -5 removed lines patch added patch discarded remove patch
@@ -74,7 +74,11 @@  discard block
 block discarded – undo
74 74
 		$query = null;
75 75
 		foreach($js_includes as $file)
76 76
 		{
77
-			if ($file == '/api/js/jsapi/egw.js') continue;	// loaded via own tag, and we must not load it twice!
77
+			if ($file == '/api/js/jsapi/egw.js')
78
+			{
79
+				continue;
80
+			}
81
+			// loaded via own tag, and we must not load it twice!
78 82
 
79 83
 			if (!isset($to_include[$file]))
80 84
 			{
@@ -133,17 +137,27 @@  discard block
 block discarded – undo
133 137
 	{
134 138
 		$debug_minify = $GLOBALS['egw_info']['server']['debug_minify'] === 'True';
135 139
 		// ignore not existing minurl
136
-		if (!empty($minurl) && !file_exists(EGW_SERVER_ROOT.$minurl)) $minurl = null;
140
+		if (!empty($minurl) && !file_exists(EGW_SERVER_ROOT.$minurl))
141
+		{
142
+			$minurl = null;
143
+		}
137 144
 		$to_include_first = $to_include = $to_minify = array();
138 145
 		$max_modified = 0;
139 146
 		$query = null;
140 147
 		foreach($js_includes as $path)
141 148
 		{
142
-			if ($path == '/api/js/jsapi/egw.js') continue; // Leave egw.js out of bundle
149
+			if ($path == '/api/js/jsapi/egw.js')
150
+			{
151
+				continue;
152
+			}
153
+			// Leave egw.js out of bundle
143 154
 			unset($query);
144 155
 			list($path,$query) = explode('?',$path,2);
145 156
 			$mod = filemtime(EGW_SERVER_ROOT.$path);
146
-			if ($mod > $max_modified) $max_modified = $mod;
157
+			if ($mod > $max_modified)
158
+			{
159
+				$max_modified = $mod;
160
+			}
147 161
 
148 162
 			// ckeditor must be included before bundled files, as they depend on it!
149 163
 			if (strpos($path,'/ckeditor/ckeditor.js') !== false)
@@ -182,7 +196,10 @@  discard block
 block discarded – undo
182 196
 			// need to include minified javascript before not minified stuff like jscalendar-setup, as it might depend on it
183 197
 			array_unshift($to_include, $path);
184 198
 		}
185
-		if ($to_include_first) $to_include = array_merge($to_include_first, $to_include);
199
+		if ($to_include_first)
200
+		{
201
+			$to_include = array_merge($to_include_first, $to_include);
202
+		}
186 203
 		//error_log(__METHOD__."("./*array2string($js_includes).*/", $max_modified, $minurl) returning ".array2string($to_include));
187 204
 		return $to_include;
188 205
 	}
Please login to merge, or discard this patch.
api/src/Framework/Extra.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -54,12 +54,12 @@  discard block
 block discarded – undo
54 54
 	 * @param string $with =null
55 55
 	 * @param string $msg_type =null 'error', 'warning' or 'success' (default)
56 56
 	 */
57
-	public static function refresh_opener($msg, $app, $id=null, $type=null, $targetapp=null, $replace=null, $with=null, $msg_type=null)
57
+	public static function refresh_opener($msg, $app, $id = null, $type = null, $targetapp = null, $replace = null, $with = null, $msg_type = null)
58 58
 	{
59 59
 		//error_log(__METHOD__.'('.array2string(func_get_args()).')');
60 60
 		self::$extra['refresh-opener'] = func_get_args();
61 61
 
62
-		unset($msg, $app, $id, $type, $targetapp, $replace, $with, $msg_type);	// used only via func_get_args();
62
+		unset($msg, $app, $id, $type, $targetapp, $replace, $with, $msg_type); // used only via func_get_args();
63 63
 	}
64 64
 
65 65
 	/**
@@ -70,11 +70,11 @@  discard block
 block discarded – undo
70 70
 	 * @param string $msg message to show
71 71
 	 * @param string $type ='success' 'error', 'warning' or 'success' (default)
72 72
 	 */
73
-	public static function message($msg, $type='success')
73
+	public static function message($msg, $type = 'success')
74 74
 	{
75 75
 		self::$extra['message'] = func_get_args();
76 76
 
77
-		unset($msg, $type);	// used only via func_get_args();
77
+		unset($msg, $type); // used only via func_get_args();
78 78
 	}
79 79
 
80 80
 	/**
@@ -84,12 +84,12 @@  discard block
 block discarded – undo
84 84
 	 * @param string $target
85 85
 	 * @param string $popup
86 86
 	 */
87
-	public static function popup($link, $target='_blank', $popup='640x480')
87
+	public static function popup($link, $target = '_blank', $popup = '640x480')
88 88
 	{
89 89
 		// default params are not returned by func_get_args!
90
-		$args = func_get_args()+array(null, '_blank', '640x480');
90
+		$args = func_get_args() + array(null, '_blank', '640x480');
91 91
 
92
-		unset($link, $target, $popup);	// used only via func_get_args()
92
+		unset($link, $target, $popup); // used only via func_get_args()
93 93
 
94 94
 		if (Json\Request::isJSONRequest())
95 95
 		{
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 	 *
107 107
 	 * @param string $alert_msg ='' optional message to display as alert, before closing the window
108 108
 	 */
109
-	public static function window_close($alert_msg='')
109
+	public static function window_close($alert_msg = '')
110 110
 	{
111 111
 		//error_log(__METHOD__."()");
112 112
 		self::$extra['window-close'] = $alert_msg ? $alert_msg : true;
@@ -163,12 +163,12 @@  discard block
 block discarded – undo
163 163
 	public static function get_extra()
164 164
 	{
165 165
 		// adding links of refreshed entry, to give others apps more information about necessity to refresh
166
-		if (isset(self::$extra['refresh-opener']) && count(self::$extra['refresh-opener']) <= 8 &&	// do not run twice
166
+		if (isset(self::$extra['refresh-opener']) && count(self::$extra['refresh-opener']) <= 8 && // do not run twice
167 167
 			!empty(self::$extra['refresh-opener'][1]) && !empty(self::$extra['refresh-opener'][2]))	// app/id given
168 168
 		{
169 169
 			$links = Link::get_links(self::$extra['refresh-opener'][1], self::$extra['refresh-opener'][2]);
170 170
 			$apps = array();
171
-			foreach($links as $link)
171
+			foreach ($links as $link)
172 172
 			{
173 173
 				$apps[$link['app']][] = $link['id'];
174 174
 			}
Please login to merge, or discard this patch.
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -164,9 +164,12 @@
 block discarded – undo
164 164
 	{
165 165
 		// adding links of refreshed entry, to give others apps more information about necessity to refresh
166 166
 		if (isset(self::$extra['refresh-opener']) && count(self::$extra['refresh-opener']) <= 8 &&	// do not run twice
167
-			!empty(self::$extra['refresh-opener'][1]) && !empty(self::$extra['refresh-opener'][2]))	// app/id given
167
+			!empty(self::$extra['refresh-opener'][1]) && !empty(self::$extra['refresh-opener'][2]))
168
+		{
169
+			// app/id given
168 170
 		{
169 171
 			$links = Link::get_links(self::$extra['refresh-opener'][1], self::$extra['refresh-opener'][2]);
172
+		}
170 173
 			$apps = array();
171 174
 			foreach($links as $link)
172 175
 			{
Please login to merge, or discard this patch.
api/src/Framework/Login.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 	 *
44 44
 	 * @param string $extra_vars for login url
45 45
 	 * @param string $change_passwd =null string with message to render input fields for password change
46
-	*/
46
+	 */
47 47
 	function screen($extra_vars, $change_passwd=null)
48 48
 	{
49 49
 		Api\Header\ContentSecurityPolicy::add('frame-src', array());	// array() no external frame-sources
@@ -226,8 +226,8 @@  discard block
 block discarded – undo
226 226
 	}
227 227
 
228 228
 	/**
229
-	* displays a login denied message
230
-	*/
229
+	 * displays a login denied message
230
+	 */
231 231
 	function denylogin_screen()
232 232
 	{
233 233
 		try {
Please login to merge, or discard this patch.
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -44,29 +44,29 @@  discard block
 block discarded – undo
44 44
 	 * @param string $extra_vars for login url
45 45
 	 * @param string $change_passwd =null string with message to render input fields for password change
46 46
 	*/
47
-	function screen($extra_vars, $change_passwd=null)
47
+	function screen($extra_vars, $change_passwd = null)
48 48
 	{
49
-		Api\Header\ContentSecurityPolicy::add('frame-src', array());	// array() no external frame-sources
49
+		Api\Header\ContentSecurityPolicy::add('frame-src', array()); // array() no external frame-sources
50 50
 
51 51
 		//error_log(__METHOD__."() this->template=$this->framework->template, this->template_dir=$this->framework->template_dir, get_class(this)=".get_class($this));
52 52
 		try {
53 53
 			$tmpl = new Template(EGW_SERVER_ROOT.$this->framework->template_dir);
54
-			$tmpl->set_file(array('login_form' => Api\Header\UserAgent::mobile()?'login_mobile.tpl':'login.tpl'));
54
+			$tmpl->set_file(array('login_form' => Api\Header\UserAgent::mobile() ? 'login_mobile.tpl' : 'login.tpl'));
55 55
 		}
56
-		catch(Api\Exception\WrongParameter $e) {
56
+		catch (Api\Exception\WrongParameter $e) {
57 57
 			unset($e);
58 58
 			$tmpl = new Template(EGW_SERVER_ROOT.'/api/templates/default');
59
-			$tmpl->set_file(array('login_form' => Api\Header\UserAgent::mobile()?'login_mobile.tpl':'login.tpl'));
59
+			$tmpl->set_file(array('login_form' => Api\Header\UserAgent::mobile() ? 'login_mobile.tpl' : 'login.tpl'));
60 60
 		}
61 61
 
62
-		$tmpl->set_var('lang_message',$GLOBALS['loginscreenmessage']);
62
+		$tmpl->set_var('lang_message', $GLOBALS['loginscreenmessage']);
63 63
 
64 64
 		// hide change-password fields, if not requested
65 65
 		if (!$change_passwd)
66 66
 		{
67
-			$tmpl->set_block('login_form','change_password');
67
+			$tmpl->set_block('login_form', 'change_password');
68 68
 			$tmpl->set_var('change_password', '');
69
-			$tmpl->set_var('lang_password',lang('password'));
69
+			$tmpl->set_var('lang_password', lang('password'));
70 70
 
71 71
 			// display login-message depending on $_GET[cd] and what's in database/header for "login_message"
72 72
 			$cd_msg = self::check_logoutcode($_GET['cd']);
@@ -87,9 +87,9 @@  discard block
 block discarded – undo
87 87
 		}
88 88
 		else
89 89
 		{
90
-			$tmpl->set_var('lang_password',lang('Old password'));
91
-			$tmpl->set_var('lang_new_password',lang('New password'));
92
-			$tmpl->set_var('lang_repeat_password',lang('Repeat password'));
90
+			$tmpl->set_var('lang_password', lang('Old password'));
91
+			$tmpl->set_var('lang_new_password', lang('New password'));
92
+			$tmpl->set_var('lang_repeat_password', lang('Repeat password'));
93 93
 			$tmpl->set_var('cd', $change_passwd);
94 94
 			$tmpl->set_var('cd_class', 'error');
95 95
 			$last_loginid = $_POST['login'];
@@ -98,56 +98,56 @@  discard block
 block discarded – undo
98 98
 			$tmpl->set_var('autofocus_login', '');
99 99
 			$tmpl->set_var('autofocus_new_passwd', 'autofocus');
100 100
 		}
101
-		if($GLOBALS['egw_info']['server']['show_domain_selectbox'])
101
+		if ($GLOBALS['egw_info']['server']['show_domain_selectbox'])
102 102
 		{
103
-			foreach(array_keys($GLOBALS['egw_domain']) as $domain)
103
+			foreach (array_keys($GLOBALS['egw_domain']) as $domain)
104 104
 			{
105 105
 				$domains[$domain] = $domain;
106 106
 			}
107 107
 			$tmpl->set_var(array(
108 108
 				'lang_domain'   => lang('domain'),
109
-				'select_domain' => Api\Html::select('logindomain',$last_domain,$domains,true,'tabindex="2"',0,false),
109
+				'select_domain' => Api\Html::select('logindomain', $last_domain, $domains, true, 'tabindex="2"', 0, false),
110 110
 			));
111 111
 		}
112 112
 		else
113 113
 		{
114 114
 			/* trick to make domain section disapear */
115
-			$tmpl->set_block('login_form','domain_selection');
116
-			$tmpl->set_var('domain_selection',$GLOBALS['egw_info']['user']['domain'] ?
117
-			Api\Html::input_hidden('logindomain',$GLOBALS['egw_info']['user']['domain']) : '');
115
+			$tmpl->set_block('login_form', 'domain_selection');
116
+			$tmpl->set_var('domain_selection', $GLOBALS['egw_info']['user']['domain'] ?
117
+			Api\Html::input_hidden('logindomain', $GLOBALS['egw_info']['user']['domain']) : '');
118 118
 
119
-			if($last_loginid !== '')
119
+			if ($last_loginid !== '')
120 120
 			{
121 121
 				reset($GLOBALS['egw_domain']);
122 122
 				list($default_domain) = each($GLOBALS['egw_domain']);
123 123
 
124
-				if(!empty ($last_domain) && $last_domain != $default_domain)
124
+				if (!empty ($last_domain) && $last_domain != $default_domain)
125 125
 				{
126
-					$last_loginid .= '@' . $last_domain;
126
+					$last_loginid .= '@'.$last_domain;
127 127
 				}
128 128
 			}
129 129
 		}
130 130
 
131 131
 		$config_reg = Api\Config::read('registration');
132 132
 
133
-		if($config_reg['enable_registration'])
133
+		if ($config_reg['enable_registration'])
134 134
 		{
135 135
 			$lang = $_GET['lang'] ? $_GET['lang'] : $GLOBALS['egw_info']['user']['preferences']['common']['lang'];
136 136
 			if ($config_reg['register_link'])
137 137
 			{
138
-				$reg_link='&nbsp;<a href="'. $this->framework->link('/registration/index.php','lang_code='.$lang). '">'.lang('Sigup').'</a>';
138
+				$reg_link = '&nbsp;<a href="'.$this->framework->link('/registration/index.php', 'lang_code='.$lang).'">'.lang('Sigup').'</a>';
139 139
 			}
140 140
 			if ($config_reg['lostpassword_link'])
141 141
 			{
142
-				$lostpw_link='&nbsp;<a href="'. $this->framework->link('/registration/index.php','menuaction=registration.registration_ui.lost_password&lang_code='.$lang). '">'.lang('Lost password').'</a>';
142
+				$lostpw_link = '&nbsp;<a href="'.$this->framework->link('/registration/index.php', 'menuaction=registration.registration_ui.lost_password&lang_code='.$lang).'">'.lang('Lost password').'</a>';
143 143
 			}
144 144
 			if ($config_reg['lostid_link'])
145 145
 			{
146
-				$lostid_link='&nbsp;<a href="'. $this->framework->link('/registration/index.php','menuaction=registration.registration_ui.lost_username&lang_code='.$lang). '">'.lang('Lost Login Id').'</a>';
146
+				$lostid_link = '&nbsp;<a href="'.$this->framework->link('/registration/index.php', 'menuaction=registration.registration_ui.lost_username&lang_code='.$lang).'">'.lang('Lost Login Id').'</a>';
147 147
 			}
148 148
 
149 149
 			/* if at least one option of "registration" is activated display the registration section */
150
-			if($config_reg['register_link'] || $config_reg['lostpassword_link'] || $config_reg['lostid_link'] )
150
+			if ($config_reg['register_link'] || $config_reg['lostpassword_link'] || $config_reg['lostid_link'])
151 151
 			{
152 152
 				$tmpl->set_var(array(
153 153
 				'register_link'     => $reg_link,
@@ -158,31 +158,31 @@  discard block
 block discarded – undo
158 158
 			else
159 159
 			{
160 160
 				/* trick to make registration section disapear */
161
-				$tmpl->set_block('login_form','registration');
162
-				$tmpl->set_var('registration','');
161
+				$tmpl->set_block('login_form', 'registration');
162
+				$tmpl->set_var('registration', '');
163 163
 			}
164 164
 		}
165 165
 
166
-		$tmpl->set_var('login_url', $GLOBALS['egw_info']['server']['webserver_url'] . '/login.php' . $extra_vars);
166
+		$tmpl->set_var('login_url', $GLOBALS['egw_info']['server']['webserver_url'].'/login.php'.$extra_vars);
167 167
 		$tmpl->set_var('version', $GLOBALS['egw_info']['server']['versions']['phpgwapi']);
168 168
 		$tmpl->set_var('login', htmlspecialchars($last_loginid));
169 169
 
170
-		$tmpl->set_var('lang_username',lang('username'));
171
-		$tmpl->set_var('lang_login',lang('login'));
170
+		$tmpl->set_var('lang_username', lang('username'));
171
+		$tmpl->set_var('lang_login', lang('login'));
172 172
 
173 173
 		$tmpl->set_var('website_title', $GLOBALS['egw_info']['server']['site_title']);
174
-		$tmpl->set_var('template_set',$this->framework->template);
174
+		$tmpl->set_var('template_set', $this->framework->template);
175 175
 
176 176
 		$var['background_file'] = self::pick_login_background($GLOBALS['egw_info']['server']['login_background_file']);
177 177
 
178 178
 		$var['logo_file'] = \EGroupware\Api\Framework::get_login_logo_or_bg_url('login_logo_file', 'login_logo');
179 179
 
180
-		$var['logo_url'] = $GLOBALS['egw_info']['server']['login_logo_url']?$GLOBALS['egw_info']['server']['login_logo_url']:'http://www.egroupware.org';
181
-		if (substr($var['logo_url'],0,4) != 'http')
180
+		$var['logo_url'] = $GLOBALS['egw_info']['server']['login_logo_url'] ? $GLOBALS['egw_info']['server']['login_logo_url'] : 'http://www.egroupware.org';
181
+		if (substr($var['logo_url'], 0, 4) != 'http')
182 182
 		{
183 183
 			$var['logo_url'] = 'http://'.$var['logo_url'];
184 184
 		}
185
-		$var['logo_title'] = $GLOBALS['egw_info']['server']['login_logo_title']?$GLOBALS['egw_info']['server']['login_logo_title']:'www.eGroupWare.org';
185
+		$var['logo_title'] = $GLOBALS['egw_info']['server']['login_logo_title'] ? $GLOBALS['egw_info']['server']['login_logo_title'] : 'www.eGroupWare.org';
186 186
 		$tmpl->set_var($var);
187 187
 
188 188
 		/* language section if activated in site Config */
@@ -190,14 +190,14 @@  discard block
 block discarded – undo
190 190
 		{
191 191
 			$tmpl->set_var(array(
192 192
 				'lang_language' => lang('Language'),
193
-				'select_language' => Api\Html::select('lang',$GLOBALS['egw_info']['user']['preferences']['common']['lang'],
194
-				Api\Translation::get_installed_langs(),true,'tabindex="1"',0,false),
193
+				'select_language' => Api\Html::select('lang', $GLOBALS['egw_info']['user']['preferences']['common']['lang'],
194
+				Api\Translation::get_installed_langs(), true, 'tabindex="1"', 0, false),
195 195
 			));
196 196
 		}
197 197
 		else
198 198
 		{
199
-			$tmpl->set_block('login_form','language_select');
200
-			$tmpl->set_var('language_select','');
199
+			$tmpl->set_block('login_form', 'language_select');
200
+			$tmpl->set_var('language_select', '');
201 201
 		}
202 202
 
203 203
 		/********************************************************\
@@ -205,36 +205,36 @@  discard block
 block discarded – undo
205 205
 		* and place a time selectbox, how long cookie is valid   *
206 206
 		\********************************************************/
207 207
 
208
-		if($GLOBALS['egw_info']['server']['allow_cookie_auth'])
208
+		if ($GLOBALS['egw_info']['server']['allow_cookie_auth'])
209 209
 		{
210
-			$tmpl->set_block('login_form','remember_me_selection');
211
-			$tmpl->set_var('lang_remember_me',lang('Remember me'));
212
-			$tmpl->set_var('select_remember_me',Api\Html::select('remember_me', '', array(
210
+			$tmpl->set_block('login_form', 'remember_me_selection');
211
+			$tmpl->set_var('lang_remember_me', lang('Remember me'));
212
+			$tmpl->set_var('select_remember_me', Api\Html::select('remember_me', '', array(
213 213
 				'' => lang('not'),
214 214
 				'1hour' => lang('1 Hour'),
215 215
 				'1day' => lang('1 Day'),
216 216
 				'1week'=> lang('1 Week'),
217 217
 				'1month' => lang('1 Month'),
218 218
 				'forever' => lang('Forever'),
219
-			),true,'tabindex="3"',0,false));
219
+			), true, 'tabindex="3"', 0, false));
220 220
 		}
221 221
 		else
222 222
 		{
223 223
 			/* trick to make remember_me section disapear */
224
-			$tmpl->set_block('login_form','remember_me_selection');
225
-			$tmpl->set_var('remember_me_selection','');
224
+			$tmpl->set_block('login_form', 'remember_me_selection');
225
+			$tmpl->set_var('remember_me_selection', '');
226 226
 		}
227 227
 		$tmpl->set_var('autocomplete', ($GLOBALS['egw_info']['server']['autocomplete_login'] ? 'autocomplete="off"' : ''));
228 228
 
229 229
 		if (Api\Header\UserAgent::type() == 'msie' && Api\Header\UserAgent::version() < 12)
230 230
 		{
231
-			$tmpl->set_var('cd', lang('Browser %1 %2 is not recommended. You may experience issues and not working features. Please use the latest version of Chrome, Firefox or Edge. Thank You!',Api\Header\UserAgent::type(), Api\Header\UserAgent::version()));
231
+			$tmpl->set_var('cd', lang('Browser %1 %2 is not recommended. You may experience issues and not working features. Please use the latest version of Chrome, Firefox or Edge. Thank You!', Api\Header\UserAgent::type(), Api\Header\UserAgent::version()));
232 232
 			$tmpl->set_var('cd_class', 'error');
233 233
 		}
234 234
 		// load jquery for login screen too
235 235
 		Api\Framework::includeJS('jquery', 'jquery');
236 236
 
237
-		$this->framework->render($tmpl->fp('loginout','login_form'),false,false);
237
+		$this->framework->render($tmpl->fp('loginout', 'login_form'), false, false);
238 238
 	}
239 239
 
240 240
 	/**
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 	{
250 250
 		if (is_array($backgrounds))
251 251
 		{
252
-			$chosen = $backgrounds[rand(0, count($backgrounds)-1)];
252
+			$chosen = $backgrounds[rand(0, count($backgrounds) - 1)];
253 253
 		}
254 254
 		else
255 255
 		{
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
 		}
264 264
 		else
265 265
 		{
266
-			return Api\Image::find('api',$chosen ? $chosen : 'login_background', '', null);
266
+			return Api\Image::find('api', $chosen ? $chosen : 'login_background', '', null);
267 267
 		}
268 268
 	}
269 269
 
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
 			$tmpl = new Template(EGW_SERVER_ROOT.$this->framework->template_dir);
277 277
 			$tmpl->set_file(array('login_form' => 'login_denylogin.tpl'));
278 278
 		}
279
-		catch(Api\Exception\WrongParameter $e) {
279
+		catch (Api\Exception\WrongParameter $e) {
280 280
 			unset($e);
281 281
 			$tmpl = new Template(EGW_SERVER_ROOT.'/api/templates/default');
282 282
 			$tmpl->set_file(array('login_form' => 'login_denylogin.tpl'));
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
 		// load jquery for deny-login screen too
292 292
 		Api\Framework::includeJS('jquery', 'jquery');
293 293
 
294
-		$this->framework->render($tmpl->fp('loginout','login_form'),false,false);
294
+		$this->framework->render($tmpl->fp('loginout', 'login_form'), false, false);
295 295
 	}
296 296
 
297 297
 	/**
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 	 */
303 303
 	static function check_logoutcode($code)
304 304
 	{
305
-		switch($code)
305
+		switch ($code)
306 306
 		{
307 307
 			case 1:
308 308
 				return lang('You have been successfully logged out');
Please login to merge, or discard this patch.
api/src/Framework/Minimal.php 4 patches
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -21,29 +21,29 @@  discard block
 block discarded – undo
21 21
 class Minimal extends Api\Framework
22 22
 {
23 23
 	/**
24
-	* Instance of the phplib Template class for the API's template dir (EGW_TEMPLATE_DIR)
25
-	*
26
-	* @var Template
27
-	*/
24
+	 * Instance of the phplib Template class for the API's template dir (EGW_TEMPLATE_DIR)
25
+	 *
26
+	 * @var Template
27
+	 */
28 28
 	var $tpl;
29 29
 
30 30
 	/**
31
-	* Constructor
32
-	*
33
-	* @param string $template ='default' name of the template
34
-	* @return idots_framework
35
-	*/
31
+	 * Constructor
32
+	 *
33
+	 * @param string $template ='default' name of the template
34
+	 * @return idots_framework
35
+	 */
36 36
 	function __construct($template='default')
37 37
 	{
38 38
 		parent::__construct($template);		// call the constructor of the extended class
39 39
 	}
40 40
 
41 41
 	/**
42
-	* Returns the html-header incl. the opening body tag
43
-	*
44
-	* @param array $extra =array() extra attributes passed as data-attribute to egw.js
45
-	* @return string with html
46
-	*/
42
+	 * Returns the html-header incl. the opening body tag
43
+	 *
44
+	 * @param array $extra =array() extra attributes passed as data-attribute to egw.js
45
+	 * @return string with html
46
+	 */
47 47
 	function header(array $extra=array())
48 48
 	{
49 49
 		// make sure header is output only once
@@ -76,10 +76,10 @@  discard block
 block discarded – undo
76 76
 	}
77 77
 
78 78
 	/**
79
-	* Returns the html from the body-tag til the main application area (incl. opening div tag)
80
-	*
81
-	* @return string with html
82
-	*/
79
+	 * Returns the html from the body-tag til the main application area (incl. opening div tag)
80
+	 *
81
+	 * @return string with html
82
+	 */
83 83
 	function navbar()
84 84
 	{
85 85
 		return '';
@@ -101,37 +101,37 @@  discard block
 block discarded – undo
101 101
 	}
102 102
 
103 103
 	/**
104
-	* Add menu items to the topmenu template class to be displayed
105
-	*
106
-	* @param array $app application data
107
-	* @param mixed $alt_label string with alternative menu item label default value = null
108
-	* @param string $urlextra string with alternate additional code inside <a>-tag
109
-	* @access protected
110
-	* @return void
111
-	*/
104
+	 * Add menu items to the topmenu template class to be displayed
105
+	 *
106
+	 * @param array $app application data
107
+	 * @param mixed $alt_label string with alternative menu item label default value = null
108
+	 * @param string $urlextra string with alternate additional code inside <a>-tag
109
+	 * @access protected
110
+	 * @return void
111
+	 */
112 112
 	function _add_topmenu_item(array $app_data,$alt_label=null)
113 113
 	{
114 114
 		unset($app_data, $alt_label);
115 115
 	}
116 116
 
117 117
 	/**
118
-	* Add info items to the topmenu template class to be displayed
119
-	*
120
-	* @param string $content html of item
121
-	* @param string $id =null
122
-	* @access protected
123
-	* @return void
124
-	*/
118
+	 * Add info items to the topmenu template class to be displayed
119
+	 *
120
+	 * @param string $content html of item
121
+	 * @param string $id =null
122
+	 * @access protected
123
+	 * @return void
124
+	 */
125 125
 	function _add_topmenu_info_item($content, $id=null)
126 126
 	{
127 127
 		unset($content, $id);
128 128
 	}
129 129
 
130 130
 	/**
131
-	* Returns the html from the closing div of the main application area to the closing html-tag
132
-	*
133
-	* @return string html or null if no footer needed/wanted
134
-	*/
131
+	 * Returns the html from the closing div of the main application area to the closing html-tag
132
+	 *
133
+	 * @return string html or null if no footer needed/wanted
134
+	 */
135 135
 	function footer()
136 136
 	{
137 137
 		static $footer_done=0;
@@ -141,29 +141,29 @@  discard block
 block discarded – undo
141 141
 	}
142 142
 
143 143
 	/**
144
-	* Parses one sidebox menu and add's the html to $this->sidebox_content for later use by $this->navbar
145
-	*
146
-	* @param string $appname
147
-	* @param string $menu_title
148
-	* @param array $file
149
-	* @param string $type =null 'admin', 'preferences', 'favorites', ...
150
-	*/
144
+	 * Parses one sidebox menu and add's the html to $this->sidebox_content for later use by $this->navbar
145
+	 *
146
+	 * @param string $appname
147
+	 * @param string $menu_title
148
+	 * @param array $file
149
+	 * @param string $type =null 'admin', 'preferences', 'favorites', ...
150
+	 */
151 151
 	function sidebox($appname,$menu_title,$file,$type=null)
152 152
 	{
153 153
 		unset($appname, $menu_title, $file, $type);
154 154
 	}
155 155
 
156 156
 	/**
157
-	* called by hooks to add an icon in the topmenu info location
158
-	*
159
-	* @param string $id unique element id
160
-	* @param string $icon_src src of the icon image. Make sure this nog height then 18pixels
161
-	* @param string $iconlink where the icon links to
162
-	* @param booleon $blink set true to make the icon blink
163
-	* @param mixed $tooltip string containing the tooltip html, or null of no tooltip
164
-	* @access public
165
-	* @return void
166
-	*/
157
+	 * called by hooks to add an icon in the topmenu info location
158
+	 *
159
+	 * @param string $id unique element id
160
+	 * @param string $icon_src src of the icon image. Make sure this nog height then 18pixels
161
+	 * @param string $iconlink where the icon links to
162
+	 * @param booleon $blink set true to make the icon blink
163
+	 * @param mixed $tooltip string containing the tooltip html, or null of no tooltip
164
+	 * @access public
165
+	 * @return void
166
+	 */
167 167
 	function topmenu_info_icon($id,$icon_src,$iconlink,$blink=false,$tooltip=null)
168 168
 	{
169 169
 		unset($id, $icon_src, $iconlink, $blink, $tooltip);
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -33,9 +33,9 @@  discard block
 block discarded – undo
33 33
 	* @param string $template ='default' name of the template
34 34
 	* @return idots_framework
35 35
 	*/
36
-	function __construct($template='default')
36
+	function __construct($template = 'default')
37 37
 	{
38
-		parent::__construct($template);		// call the constructor of the extended class
38
+		parent::__construct($template); // call the constructor of the extended class
39 39
 	}
40 40
 
41 41
 	/**
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 	* @param array $extra =array() extra attributes passed as data-attribute to egw.js
45 45
 	* @return string with html
46 46
 	*/
47
-	function header(array $extra=array())
47
+	function header(array $extra = array())
48 48
 	{
49 49
 		// make sure header is output only once
50 50
 		if (self::$header_done) return '';
@@ -66,11 +66,11 @@  discard block
 block discarded – undo
66 66
 		// as the old Template class has problems if restored from the session (php-restore)
67 67
 		$this->tpl = new Template(EGW_SERVER_ROOT.$this->template_dir, 'keep');
68 68
 		$this->tpl->set_file(array('_head' => 'head.tpl'));
69
-		$this->tpl->set_block('_head','head');
69
+		$this->tpl->set_block('_head', 'head');
70 70
 
71 71
 		$this->tpl->set_var($this->_get_header($extra));
72 72
 
73
-		$content .= $this->tpl->fp('out','head');
73
+		$content .= $this->tpl->fp('out', 'head');
74 74
 
75 75
 		return $content;
76 76
 	}
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 	 * @return boolean $consider_navbar_not_yet_called_as_true=true
94 94
 	 * @return boolean
95 95
 	 */
96
-	public function isTop($consider_navbar_not_yet_called_as_true=true)
96
+	public function isTop($consider_navbar_not_yet_called_as_true = true)
97 97
 	{
98 98
 		unset($consider_navbar_not_yet_called_as_true);
99 99
 
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 	* @access protected
110 110
 	* @return void
111 111
 	*/
112
-	function _add_topmenu_item(array $app_data,$alt_label=null)
112
+	function _add_topmenu_item(array $app_data, $alt_label = null)
113 113
 	{
114 114
 		unset($app_data, $alt_label);
115 115
 	}
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 	* @access protected
123 123
 	* @return void
124 124
 	*/
125
-	function _add_topmenu_info_item($content, $id=null)
125
+	function _add_topmenu_info_item($content, $id = null)
126 126
 	{
127 127
 		unset($content, $id);
128 128
 	}
@@ -134,10 +134,10 @@  discard block
 block discarded – undo
134 134
 	*/
135 135
 	function footer()
136 136
 	{
137
-		static $footer_done=0;
138
-		if ($footer_done++) return;	// prevent multiple footers, not sure we still need this (RalfBecker)
137
+		static $footer_done = 0;
138
+		if ($footer_done++) return; // prevent multiple footers, not sure we still need this (RalfBecker)
139 139
 
140
-		return "</body>\n</html>\n";	// close body and html tag, eg. for popups
140
+		return "</body>\n</html>\n"; // close body and html tag, eg. for popups
141 141
 	}
142 142
 
143 143
 	/**
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 	* @param array $file
149 149
 	* @param string $type =null 'admin', 'preferences', 'favorites', ...
150 150
 	*/
151
-	function sidebox($appname,$menu_title,$file,$type=null)
151
+	function sidebox($appname, $menu_title, $file, $type = null)
152 152
 	{
153 153
 		unset($appname, $menu_title, $file, $type);
154 154
 	}
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 	* @access public
165 165
 	* @return void
166 166
 	*/
167
-	function topmenu_info_icon($id,$icon_src,$iconlink,$blink=false,$tooltip=null)
167
+	function topmenu_info_icon($id, $icon_src, $iconlink, $blink = false, $tooltip = null)
168 168
 	{
169 169
 		unset($id, $icon_src, $iconlink, $blink, $tooltip);
170 170
 	}
Please login to merge, or discard this patch.
Braces   +9 added lines, -2 removed lines patch added patch discarded remove patch
@@ -47,7 +47,10 @@  discard block
 block discarded – undo
47 47
 	function header(array $extra=array())
48 48
 	{
49 49
 		// make sure header is output only once
50
-		if (self::$header_done) return '';
50
+		if (self::$header_done)
51
+		{
52
+			return '';
53
+		}
51 54
 		self::$header_done = true;
52 55
 
53 56
 		// js stuff is not needed by login page or in popups
@@ -135,7 +138,11 @@  discard block
 block discarded – undo
135 138
 	function footer()
136 139
 	{
137 140
 		static $footer_done=0;
138
-		if ($footer_done++) return;	// prevent multiple footers, not sure we still need this (RalfBecker)
141
+		if ($footer_done++)
142
+		{
143
+			return;
144
+		}
145
+		// prevent multiple footers, not sure we still need this (RalfBecker)
139 146
 
140 147
 		return "</body>\n</html>\n";	// close body and html tag, eg. for popups
141 148
 	}
Please login to merge, or discard this patch.
Doc Comments   -5 removed lines patch added patch discarded remove patch
@@ -356,11 +356,6 @@
 block discarded – undo
356 356
 	/**
357 357
 	* Add menu items to the topmenu template class to be displayed
358 358
 	*
359
-	* @param array $app application data
360
-	* @param mixed $alt_label string with alternative menu item label default value = null
361
-	* @param string $urlextra string with alternate additional code inside <a>-tag
362
-	* @access protected
363
-	* @return void
364 359
 	*/
365 360
 	function _add_topmenu_item(array $app_data,$alt_label=null)
366 361
 	{
Please login to merge, or discard this patch.