Completed
Push — 14.2 ( c53e78...a8db63 )
by Ralf
29:08
created
addressbook/inc/class.addressbook_sql.inc.php 5 patches
Doc Comments   +8 added lines, -16 removed lines patch added patch discarded remove patch
@@ -60,7 +60,6 @@  discard block
 block discarded – undo
60 60
 	/**
61 61
 	 * Constructor
62 62
 	 *
63
-	 * @param egw_db $db=null
64 63
 	 */
65 64
 	function __construct(egw_db $db=null)
66 65
 	{
@@ -244,18 +243,15 @@  discard block
 block discarded – undo
244 243
 	 * For a union-query you call search for each query with $start=='UNION' and one more with only $order_by and $start set to run the union-query.
245 244
 	 *
246 245
 	 * @param array/string $criteria array of key and data cols, OR a SQL query (content for WHERE), fully quoted (!)
247
-	 * @param boolean/string/array $only_keys=true True returns only keys, False returns all cols. or
246
+	 * @param boolean/string/array $only_keys True returns only keys, False returns all cols. or
248 247
 	 *	comma seperated list or array of columns to return
249 248
 	 * @param string $order_by='' fieldnames + {ASC|DESC} separated by colons ',', can also contain a GROUP BY (if it contains ORDER BY)
250 249
 	 * @param string/array $extra_cols='' string or array of strings to be added to the SELECT, eg. "count(*) as num"
251 250
 	 * @param string $wildcard='' appended befor and after each criteria
252
-	 * @param boolean $empty=false False=empty criteria are ignored in query, True=empty have to be empty in row
253
-	 * @param string $op='AND' defaults to 'AND', can be set to 'OR' too, then criteria's are OR'ed together
254
-	 * @param mixed $start=false if != false, return only maxmatch rows begining with start, or array($start,$num), or 'UNION' for a part of a union query
255
-	 * @param array $filter=null if set (!=null) col-data pairs, to be and-ed (!) into the query without wildcards
251
+	 * @param array $filter if set (!=null) col-data pairs, to be and-ed (!) into the query without wildcards
256 252
 	 * @param string $join='' sql to do a join, added as is after the table-name, eg. ", table2 WHERE x=y" or
257 253
 	 *	"LEFT JOIN table2 ON (x=y)", Note: there's no quoting done on $join!
258
-	 * @param boolean $need_full_no_count=false If true an unlimited query is run to determine the total number of rows, default false
254
+	 * @param boolean $need_full_no_count If true an unlimited query is run to determine the total number of rows, default false
259 255
 	 * @return boolean/array of matching rows (the row is an array of the cols) or False
260 256
 	 */
261 257
 	function &search($criteria,$only_keys=True,$order_by='',$extra_cols='',$wildcard='',$empty=False,$op='AND',$start=false,$filter=null,$join='',$need_full_no_count=false)
@@ -496,9 +492,8 @@  discard block
 block discarded – undo
496 492
 	 *
497 493
 	 * @param array $uids array of user or group id's for $uid_column='list_owners', or values for $uid_column,
498 494
 	 * 	or whole where array: column-name => value(s) pairs
499
-	 * @param string $uid_column='list_owner' column-name or null to use $uids as where array
500
-	 * @param string $member_attr=null null: no members, 'contact_uid', 'contact_id', 'caldav_name' return members as that attribute
501
-	 * @param boolean|int|array $limit_in_ab=false if true only return members from the same owners addressbook,
495
+	 * @param string $member_attr null: no members, 'contact_uid', 'contact_id', 'caldav_name' return members as that attribute
496
+	 * @param boolean|int|array $limit_in_ab if true only return members from the same owners addressbook,
502 497
 	 * 	if int|array only return members from the given owners addressbook(s)
503 498
 	 * @return array with list_id => array(list_id,list_name,list_owner,...) pairs
504 499
 	 */
@@ -547,7 +542,6 @@  discard block
 block discarded – undo
547 542
 	 *
548 543
 	 * @param string|array $keys list-name or array with column-name => value pairs to specify the list
549 544
 	 * @param int $owner user- or group-id
550
-	 * @param array $contacts=array() contacts to add (only for not yet existing lists!)
551 545
 	 * @param array &$data=array() values for keys 'list_uid', 'list_carddav_name', 'list_name'
552 546
 	 * @return int|boolean integer list_id or false on error
553 547
 	 */
@@ -606,7 +600,7 @@  discard block
 block discarded – undo
606 600
 	 *
607 601
 	 * @param int|array $contact contact_id(s)
608 602
 	 * @param int $list list-id
609
-	 * @param array $existing=null array of existing contact-id(s) of list, to not reread it, eg. array()
603
+	 * @param array $existing array of existing contact-id(s) of list, to not reread it, eg. array()
610 604
 	 * @return false on error
611 605
 	 */
612 606
 	function add2list($contact,$list,array $existing=null)
@@ -648,7 +642,6 @@  discard block
 block discarded – undo
648 642
 	 * Removes one contact from distribution list(s)
649 643
 	 *
650 644
 	 * @param int|array $contact contact_id(s)
651
-	 * @param int $list=null list-id or null to remove from all lists
652 645
 	 * @return false on error
653 646
 	 */
654 647
 	function remove_from_list($contact,$list=null)
@@ -705,7 +698,6 @@  discard block
 block discarded – undo
705 698
 	/**
706 699
 	 * Get ctag (max list_modified as timestamp) for lists
707 700
 	 *
708
-	 * @param int|array $owner=null null for all lists user has access too
709 701
 	 * @return int
710 702
 	 */
711 703
 	function lists_ctag($owner=null)
@@ -762,7 +754,7 @@  discard block
 block discarded – undo
762 754
 	 * Saves a contact, reimplemented to check a given etag and set a uid
763 755
 	 *
764 756
 	 * @param array $keys if given $keys are copied to data before saveing => allows a save as
765
-	 * @param string|array $extra_where=null extra where clause, eg. to check the etag, returns 'nothing_affected' if not affected rows
757
+	 * @param string|array $extra_where extra where clause, eg. to check the etag, returns 'nothing_affected' if not affected rows
766 758
 	 * @return int 0 on success and errno != 0 else
767 759
 	 */
768 760
 	function save($keys = NULL, $extra_where = NULL)
@@ -823,7 +815,7 @@  discard block
 block discarded – undo
823 815
 	 * Read data of a distribution list
824 816
 	 *
825 817
 	 * @param int $list list_id
826
-	 * @return array of data or false if list does not exist
818
+	 * @return boolean of data or false if list does not exist
827 819
 	 */
828 820
 	function read_list($list)
829 821
 	{
Please login to merge, or discard this patch.
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -858,9 +858,9 @@
 block discarded – undo
858 858
 	}
859 859
 
860 860
 	/**
861
-	* Deletes custom field data
862
-	* Implemented to deal with LDAP backend, which saves CFs in SQL, but the account record is in LDAP
863
-	*/
861
+	 * Deletes custom field data
862
+	 * Implemented to deal with LDAP backend, which saves CFs in SQL, but the account record is in LDAP
863
+	 */
864 864
 	function delete_customfields($data)
865 865
 	{
866 866
 		$this->db->delete($this->extra_table,$data,__LINE__,__FILE__);
Please login to merge, or discard this patch.
Spacing   +115 added lines, -117 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	 *
40 40
 	 * @var string
41 41
 	 */
42
-	var $contacts_id='id';
42
+	var $contacts_id = 'id';
43 43
 
44 44
 	/**
45 45
 	 * Name of the table for distribution lists
@@ -62,10 +62,10 @@  discard block
 block discarded – undo
62 62
 	 *
63 63
 	 * @param egw_db $db=null
64 64
 	 */
65
-	function __construct(egw_db $db=null)
65
+	function __construct(egw_db $db = null)
66 66
 	{
67 67
 		parent::__construct('phpgwapi', 'egw_addressbook', self::EXTRA_TABLE, 'contact_',
68
-			$extra_key='_name',$extra_value='_value',$extra_id='_id',$db);
68
+			$extra_key = '_name', $extra_value = '_value', $extra_id = '_id', $db);
69 69
 
70 70
 		// Get custom fields from addressbook instead of phpgwapi
71 71
 		$this->customfields = config::get_customfields('addressbook');
@@ -109,8 +109,8 @@  discard block
 block discarded – undo
109 109
 		if (isset($param['op']) && !empty($param['op'])) $op = $param['op'];
110 110
 		$advanced_search = false;
111 111
 		if (isset($param['advanced_search']) && !empty($param['advanced_search'])) $advanced_search = true;
112
-		$wildcard ='%';
113
-		if ($advanced_search || (isset($param['wildcard']) && !empty($param['wildcard']))) $wildcard = ($param['wildcard']?$param['wildcard']:'');
112
+		$wildcard = '%';
113
+		if ($advanced_search || (isset($param['wildcard']) && !empty($param['wildcard']))) $wildcard = ($param['wildcard'] ? $param['wildcard'] : '');
114 114
 
115 115
 		// fix cat_id filter to search in comma-separated multiple cats and return subcats
116 116
 		if ((int)$filter['cat_id'])
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 			// we have no private grants in addressbook at the moment, they have then to be added here too
129 129
 			if ($param['owner'])
130 130
 			{
131
-				if (!$this->grants[(int) $filter['owner']]) return false;	// we have no access to that addressbook
131
+				if (!$this->grants[(int)$filter['owner']]) return false; // we have no access to that addressbook
132 132
 
133 133
 				$filter['owner'] = $param['owner'];
134 134
 				$filter['private'] = 0;
@@ -137,11 +137,11 @@  discard block
 block discarded – undo
137 137
 			{
138 138
 				if ($this->account_repository != 'sql' && $this->contact_repository != 'sql-ldap')
139 139
 				{
140
-					$filter[] = $this->table_name.'.contact_owner != 0';	// in case there have been accounts in sql previously
140
+					$filter[] = $this->table_name.'.contact_owner != 0'; // in case there have been accounts in sql previously
141 141
 				}
142 142
 				$filter[] = "(".$this->table_name.".contact_owner=".(int)$GLOBALS['egw_info']['user']['account_id'].
143 143
 					" OR contact_private=0 AND ".$this->table_name.".contact_owner IN (".
144
-					implode(',',array_keys($this->grants))."))";
144
+					implode(',', array_keys($this->grants))."))";
145 145
 			}
146 146
 		}
147 147
 		if ($param['searchletter'])
@@ -150,11 +150,11 @@  discard block
 block discarded – undo
150 150
 		}
151 151
 		else
152 152
 		{
153
-			$filter[] = "org_name != ''";// AND org_name IS NOT NULL";
153
+			$filter[] = "org_name != ''"; // AND org_name IS NOT NULL";
154 154
 		}
155 155
 		$sort = $param['sort'] == 'DESC' ? 'DESC' : 'ASC';
156 156
 
157
-		list(,$by) = explode(',',$param['org_view']);
157
+		list(,$by) = explode(',', $param['org_view']);
158 158
 		if (!$by)
159 159
 		{
160 160
 			$extra = array(
@@ -167,49 +167,48 @@  discard block
 block discarded – undo
167 167
 		else	// by adr_one_location or org_unit
168 168
 		{
169 169
 			// org total for more then one $by
170
-			$by_expr = $by == 'org_unit_count' ? "COUNT(DISTINCT CASE WHEN org_unit IS NULL THEN '' ELSE org_unit END)" :
171
-				"COUNT(DISTINCT CASE WHEN adr_one_locality IS NULL THEN '' ELSE adr_one_locality END)";
170
+			$by_expr = $by == 'org_unit_count' ? "COUNT(DISTINCT CASE WHEN org_unit IS NULL THEN '' ELSE org_unit END)" : "COUNT(DISTINCT CASE WHEN adr_one_locality IS NULL THEN '' ELSE adr_one_locality END)";
172 171
 			$append = "GROUP BY org_name HAVING $by_expr > 1 ORDER BY org_name $sort";
173
-			parent::search($param['search'],array('org_name'),$append,array(
172
+			parent::search($param['search'], array('org_name'), $append, array(
174 173
 				"NULL AS $by",
175 174
 				'1 AS is_main',
176 175
 				'COUNT(DISTINCT egw_addressbook.contact_id) AS org_count',
177 176
 				"COUNT(DISTINCT CASE WHEN org_unit IS NULL THEN '' ELSE org_unit END) AS org_unit_count",
178 177
 				"COUNT(DISTINCT CASE WHEN adr_one_locality IS NULL THEN '' ELSE adr_one_locality END) AS adr_one_locality_count",
179
-			),$wildcard,false,$op/*'OR'*/,'UNION',$filter);
178
+			), $wildcard, false, $op/*'OR'*/, 'UNION', $filter);
180 179
 			// org by location
181 180
 			$append = "GROUP BY org_name,$by ORDER BY org_name $sort,$by $sort";
182
-			parent::search($param['search'],array('org_name'),$append,array(
181
+			parent::search($param['search'], array('org_name'), $append, array(
183 182
 				"CASE WHEN $by IS NULL THEN '' ELSE $by END AS $by",
184 183
 				'0 AS is_main',
185 184
 				'COUNT(DISTINCT egw_addressbook.contact_id) AS org_count',
186 185
 				"COUNT(DISTINCT CASE WHEN org_unit IS NULL THEN '' ELSE org_unit END) AS org_unit_count",
187 186
 				"COUNT(DISTINCT CASE WHEN adr_one_locality IS NULL THEN '' ELSE adr_one_locality END) AS adr_one_locality_count",
188
-			),$wildcard,false,$op/*'OR'*/,'UNION',$filter);
187
+			), $wildcard, false, $op/*'OR'*/, 'UNION', $filter);
189 188
 			$append = "ORDER BY org_name $sort,is_main DESC,$by $sort";
190 189
 		}
191
-		$rows = parent::search($param['search'],array('org_name'),$append,$extra,$wildcard,false,$op/*'OR'*/,
192
-			array($param['start'],$param['num_rows']),$filter);
190
+		$rows = parent::search($param['search'], array('org_name'), $append, $extra, $wildcard, false, $op/*'OR'*/,
191
+			array($param['start'], $param['num_rows']), $filter);
193 192
 
194 193
 		if (!$rows) return false;
195 194
 
196 195
 		// query the values for *_count == 1, to display them instead
197 196
 		$filter['org_name'] = $orgs = array();
198
-		foreach($rows as $n => $row)
197
+		foreach ($rows as $n => $row)
199 198
 		{
200 199
 			if ($row['org_unit_count'] == 1 || $row['adr_one_locality_count'] == 1)
201 200
 			{
202
-				$filter['org_name'][$row['org_name']] = $row['org_name'];	// use as key too to have every org only once
201
+				$filter['org_name'][$row['org_name']] = $row['org_name']; // use as key too to have every org only once
203 202
 			}
204
-			$org_key = $row['org_name'].($by ? '|||'.($row[$by] || $row[$by.'_count']==1 ? $row[$by] : '|||') : '');
203
+			$org_key = $row['org_name'].($by ? '|||'.($row[$by] || $row[$by.'_count'] == 1 ? $row[$by] : '|||') : '');
205 204
 			$orgs[$org_key] = $row;
206 205
 		}
207 206
 		unset($rows);
208 207
 
209 208
 		if (count($filter['org_name']))
210 209
 		{
211
-			foreach((array) parent::search($criteria,array('org_name','org_unit','adr_one_locality'),'GROUP BY org_name,org_unit,adr_one_locality',
212
-				'',$wildcard,false,$op/*'AND'*/,false,$filter) as $row)
210
+			foreach ((array)parent::search($criteria, array('org_name', 'org_unit', 'adr_one_locality'), 'GROUP BY org_name,org_unit,adr_one_locality',
211
+				'', $wildcard, false, $op/*'AND'*/, false, $filter) as $row)
213 212
 			{
214 213
 				$org_key = $row['org_name'].($by ? '|||'.$row[$by] : '');
215 214
 				if ($orgs[$org_key]['org_unit_count'] == 1)
@@ -258,9 +257,9 @@  discard block
 block discarded – undo
258 257
 	 * @param boolean $need_full_no_count=false If true an unlimited query is run to determine the total number of rows, default false
259 258
 	 * @return boolean/array of matching rows (the row is an array of the cols) or False
260 259
 	 */
261
-	function &search($criteria,$only_keys=True,$order_by='',$extra_cols='',$wildcard='',$empty=False,$op='AND',$start=false,$filter=null,$join='',$need_full_no_count=false)
260
+	function &search($criteria, $only_keys = True, $order_by = '', $extra_cols = '', $wildcard = '', $empty = False, $op = 'AND', $start = false, $filter = null, $join = '', $need_full_no_count = false)
262 261
 	{
263
-		if ((int) $this->debug >= 4) echo '<p>'.__METHOD__.'('.array2string($criteria).','.array2string($only_keys).",'$order_by','$extra_cols','$wildcard','$empty','$op',$start,".array2string($filter).",'$join')</p>\n";
262
+		if ((int)$this->debug >= 4) echo '<p>'.__METHOD__.'('.array2string($criteria).','.array2string($only_keys).",'$order_by','$extra_cols','$wildcard','$empty','$op',$start,".array2string($filter).",'$join')</p>\n";
264 263
 		//error_log(__METHOD__.'('.array2string($criteria,true).','.array2string($only_keys).",'$order_by', ".array2string($extra_cols).",'$wildcard','$empty','$op',$start,".array2string($filter).",'$join')");
265 264
 
266 265
 		$owner = isset($filter['owner']) ? $filter['owner'] : (isset($criteria['owner']) ? $criteria['owner'] : null);
@@ -276,10 +275,10 @@  discard block
 block discarded – undo
276 275
 		{
277 276
 			if ($filter['cat_id'][0] == '!')
278 277
 			{
279
-				$filter['cat_id'] = substr($filter['cat_id'],1);
278
+				$filter['cat_id'] = substr($filter['cat_id'], 1);
280 279
 				$not = 'NOT';
281 280
 			}
282
-			$filter[] = $this->_cat_filter((int)$filter['cat_id'],$not);
281
+			$filter[] = $this->_cat_filter((int)$filter['cat_id'], $not);
283 282
 			unset($filter['cat_id']);
284 283
 		}
285 284
 
@@ -288,17 +287,17 @@  discard block
 block discarded – undo
288 287
 		{
289 288
 			// add read ACL for groupmembers (they have no
290 289
 			if ($GLOBALS['egw_info']['user']['preferences']['common']['account_selection'] == 'groupmembers' &&
291
-				(!isset($filter['owner']) || in_array('0',(array)$filter['owner'])))
290
+				(!isset($filter['owner']) || in_array('0', (array)$filter['owner'])))
292 291
 			{
293 292
 				$groupmembers = array();
294
-				foreach($GLOBALS['egw']->accounts->memberships($GLOBALS['egw_info']['user']['account_id'],true) as $group_id)
293
+				foreach ($GLOBALS['egw']->accounts->memberships($GLOBALS['egw_info']['user']['account_id'], true) as $group_id)
295 294
 				{
296
-					if (($members = $GLOBALS['egw']->accounts->members($group_id,true)))
295
+					if (($members = $GLOBALS['egw']->accounts->members($group_id, true)))
297 296
 					{
298
-						$groupmembers = array_merge($groupmembers,$members);
297
+						$groupmembers = array_merge($groupmembers, $members);
299 298
 					}
300 299
 				}
301
-				$groupmember_sql = $this->db->expression($this->table_name, ' OR '.$this->table_name.'.',array(
300
+				$groupmember_sql = $this->db->expression($this->table_name, ' OR '.$this->table_name.'.', array(
302 301
 					'account_id' => array_unique($groupmembers),
303 302
 				));
304 303
 			}
@@ -306,34 +305,34 @@  discard block
 block discarded – undo
306 305
 			if (isset($filter['owner']))
307 306
 			{
308 307
 				// no grants for selected owner/addressbook
309
-				if (!($filter['owner'] = array_intersect((array)$filter['owner'],array_keys($this->grants))))
308
+				if (!($filter['owner'] = array_intersect((array)$filter['owner'], array_keys($this->grants))))
310 309
 				{
311 310
 					if (!isset($groupmember_sql)) return false;
312
-					$filter[] = substr($groupmember_sql,4);
311
+					$filter[] = substr($groupmember_sql, 4);
313 312
 					unset($filter['owner']);
314 313
 				}
315 314
 				// for an owner filter, which does NOT include current user, filter out private entries
316
-				elseif (!in_array($GLOBALS['egw_info']['user']['account_id'],$filter['owner']))
315
+				elseif (!in_array($GLOBALS['egw_info']['user']['account_id'], $filter['owner']))
317 316
 				{
318 317
 					$filter['private'] = 0;
319 318
 				}
320 319
 				// if multiple addressbooks (incl. current owner) are searched, we need full acl filter
321
-				elseif(count($filter['owner']) > 1)
320
+				elseif (count($filter['owner']) > 1)
322 321
 				{
323 322
 					$filter[] = "($this->table_name.contact_owner=".(int)$GLOBALS['egw_info']['user']['account_id'].
324 323
 						" OR contact_private=0 AND $this->table_name.contact_owner IN (".
325
-						implode(',',array_keys($this->grants)).") $groupmember_sql OR $this->table_name.contact_owner IS NULL)";
324
+						implode(',', array_keys($this->grants)).") $groupmember_sql OR $this->table_name.contact_owner IS NULL)";
326 325
 				}
327 326
 			}
328 327
 			else	// search all addressbooks, incl. accounts
329 328
 			{
330 329
 				if ($this->account_repository != 'sql' && $this->contact_repository != 'sql-ldap')
331 330
 				{
332
-					$filter[] = $this->table_name.'.contact_owner != 0';	// in case there have been accounts in sql previously
331
+					$filter[] = $this->table_name.'.contact_owner != 0'; // in case there have been accounts in sql previously
333 332
 				}
334 333
 				$filter[] = "($this->table_name.contact_owner=".(int)$GLOBALS['egw_info']['user']['account_id'].
335 334
 					" OR contact_private=0 AND $this->table_name.contact_owner IN (".
336
-					implode(',',array_keys($this->grants)).") $groupmember_sql OR $this->table_name.contact_owner IS NULL)";
335
+					implode(',', array_keys($this->grants)).") $groupmember_sql OR $this->table_name.contact_owner IS NULL)";
337 336
 			}
338 337
 		}
339 338
 		if (isset($filter['list']))
@@ -342,34 +341,34 @@  discard block
 block discarded – undo
342 341
 			unset($filter['list']);
343 342
 		}
344 343
 		// add join to show only active accounts (only if accounts are shown and in sql and we not already join the accounts table, eg. used by admin)
345
-		if ((is_array($owner) ? in_array(0, $owner) : !$owner) && substr($this->account_repository,0,3) == 'sql' &&
346
-			strpos($join,$GLOBALS['egw']->accounts->backend->table) === false && !array_key_exists('account_id',$filter))
344
+		if ((is_array($owner) ? in_array(0, $owner) : !$owner) && substr($this->account_repository, 0, 3) == 'sql' &&
345
+			strpos($join, $GLOBALS['egw']->accounts->backend->table) === false && !array_key_exists('account_id', $filter))
347 346
 		{
348 347
 			$join .= self::ACCOUNT_ACTIVE_JOIN;
349
-			$filter[] = str_replace('UNIX_TIMESTAMP(NOW())',time(),self::ACOUNT_ACTIVE_FILTER);
348
+			$filter[] = str_replace('UNIX_TIMESTAMP(NOW())', time(), self::ACOUNT_ACTIVE_FILTER);
350 349
 		}
351 350
 		if ($join || ($criteria && is_string($criteria)) || ($criteria && is_array($criteria) && $order_by))	// search also adds a join for custom fields!
352 351
 		{
353
-			switch(gettype($only_keys))
352
+			switch (gettype($only_keys))
354 353
 			{
355 354
 				case 'boolean':
356 355
 					// Correctly handled by parent class
357 356
 					break;
358 357
 				case 'string':
359
-					$only_keys = explode(',',$only_keys);
358
+					$only_keys = explode(',', $only_keys);
360 359
 					// fall through
361 360
 			}
362 361
 			// postgres requires that expressions in order by appear in the columns of a distinct select
363
-			if ($this->db->Type != 'mysql' && preg_match_all("/(#?[a-zA-Z_.]+) *(<> *''|IS NULL|IS NOT NULL)? *(ASC|DESC)?(,|$)/ui",$order_by,$all_matches,PREG_SET_ORDER))
362
+			if ($this->db->Type != 'mysql' && preg_match_all("/(#?[a-zA-Z_.]+) *(<> *''|IS NULL|IS NOT NULL)? *(ASC|DESC)?(,|$)/ui", $order_by, $all_matches, PREG_SET_ORDER))
364 363
 			{
365
-				if (!is_array($extra_cols))	$extra_cols = $extra_cols ? explode(',',$extra_cols) : array();
366
-				foreach($all_matches as $matches)
364
+				if (!is_array($extra_cols))	$extra_cols = $extra_cols ? explode(',', $extra_cols) : array();
365
+				foreach ($all_matches as $matches)
367 366
 				{
368 367
 					$table = '';
369 368
 					$column = $matches[1];
370
-					if ($column[0] == '#') continue;	// order by custom field is handeled in so_sql_cf anyway
369
+					if ($column[0] == '#') continue; // order by custom field is handeled in so_sql_cf anyway
371 370
 					if (($key = array_search($column, $this->db_cols)) !== false) $column = $key;
372
-					if (strpos($column,'.') === false)
371
+					if (strpos($column, '.') === false)
373 372
 					{
374 373
 						$table = $column == $this->extra_value ? $this->extra_table : $this->table_name;
375 374
 						if (isset($this->db_cols[$column]))
@@ -385,32 +384,32 @@  discard block
 block discarded – undo
385 384
 					//_debug_array($matches);
386 385
 					if (!empty($order_by) && $table) // postgres requires explizit order by
387 386
 					{
388
-						$order_by = str_replace($matches[0],$table.$column.' '.$matches[2].' '.$matches[3].$matches[4],$order_by);
387
+						$order_by = str_replace($matches[0], $table.$column.' '.$matches[2].' '.$matches[3].$matches[4], $order_by);
389 388
 					}
390 389
 				}
391 390
 				//_debug_array($order_by); _debug_array($extra_cols);
392 391
 			}
393 392
 
394 393
 			// Understand search by date with wildcard (????.10.??) according to user date preference
395
-			if(is_string($criteria) && strpos($criteria, '?') !== false)
394
+			if (is_string($criteria) && strpos($criteria, '?') !== false)
396 395
 			{
397 396
 				$date_format = $GLOBALS['egw_info']['user']['preferences']['common']['dateformat'];
398 397
 				// First, check for a 'date', with wildcards, in the user's format
399
-				$date_regex = str_replace(array('Y','m','d','.','-'), array('(?P<Y>(?:\?|\Q){4})','(?P<m>(?:\?|\Q){2})','(?P<d>(?:\?|\Q){2})','\.','\-'),$date_format);
400
-				$date_regex = str_replace('Q','d',$date_regex);
401
-				if(preg_match_all('$'.$date_regex.'$', $criteria, $matches))
398
+				$date_regex = str_replace(array('Y', 'm', 'd', '.', '-'), array('(?P<Y>(?:\?|\Q){4})', '(?P<m>(?:\?|\Q){2})', '(?P<d>(?:\?|\Q){2})', '\.', '\-'), $date_format);
399
+				$date_regex = str_replace('Q', 'd', $date_regex);
400
+				if (preg_match_all('$'.$date_regex.'$', $criteria, $matches))
402 401
 				{
403
-					foreach($matches[0] as $m_id => $match)
402
+					foreach ($matches[0] as $m_id => $match)
404 403
 					{
405 404
 						// Birthday is Y-m-d
406
-						$criteria = str_replace($match, "*{$matches['Y'][$m_id]}-{$matches['m'][$m_id]}-{$matches['d'][$m_id]}*",$criteria);
405
+						$criteria = str_replace($match, "*{$matches['Y'][$m_id]}-{$matches['m'][$m_id]}-{$matches['d'][$m_id]}*", $criteria);
407 406
 					}
408 407
 				}
409 408
 			}
410 409
 		}
411
-		$rows =& parent::search($criteria,$only_keys,$order_by,$extra_cols,$wildcard,$empty,$op,$start,$filter,$join,$need_full_no_count);
410
+		$rows = & parent::search($criteria, $only_keys, $order_by, $extra_cols, $wildcard, $empty, $op, $start, $filter, $join, $need_full_no_count);
412 411
 
413
-		if ($start === false) $this->total = is_array($rows) ? count($rows) : 0;	// so_sql sets total only for $start !== false!
412
+		if ($start === false) $this->total = is_array($rows) ? count($rows) : 0; // so_sql sets total only for $start !== false!
414 413
 
415 414
 		return $rows;
416 415
 	}
@@ -422,18 +421,18 @@  discard block
 block discarded – undo
422 421
 	 * @param int $cat_id
423 422
 	 * @return string sql to filter by given cat
424 423
 	 */
425
-	function _cat_filter($cat_id, $not='')
424
+	function _cat_filter($cat_id, $not = '')
426 425
 	{
427 426
 		if (!is_object($GLOBALS['egw']->categories))
428 427
 		{
429 428
 			$GLOBALS['egw']->categories = CreateObject('phpgwapi.categories');
430 429
 		}
431
-		foreach($GLOBALS['egw']->categories->return_all_children((int)$cat_id) as $cat)
430
+		foreach ($GLOBALS['egw']->categories->return_all_children((int)$cat_id) as $cat)
432 431
 		{
433
-			$cat_filter[] = $this->db->concat("','",cat_id,"','")." $not LIKE '%,$cat,%'";
432
+			$cat_filter[] = $this->db->concat("','", cat_id, "','")." $not LIKE '%,$cat,%'";
434 433
 		}
435
-		$cfilter = '('.implode(' OR ',$cat_filter).')';
436
-		if(!empty($not))
434
+		$cfilter = '('.implode(' OR ', $cat_filter).')';
435
+		if (!empty($not))
437 436
 		{
438 437
 			$cfilter = "( $cfilter OR cat_id IS NULL )";
439 438
 		}
@@ -450,9 +449,9 @@  discard block
 block discarded – undo
450 449
 	function _cat_search($cats)
451 450
 	{
452 451
 		$cat_filter = array();
453
-		foreach(is_array($cats) ? $cats : (is_numeric($cats) ? array($cats) : explode(',',$cats)) as $cat)
452
+		foreach (is_array($cats) ? $cats : (is_numeric($cats) ? array($cats) : explode(',', $cats)) as $cat)
454 453
 		{
455
-			if (is_numeric($cat)) $cat_filter[] = $this->db->concat("','",cat_id,"','")." LIKE '%,$cat,%'";
454
+			if (is_numeric($cat)) $cat_filter[] = $this->db->concat("','", cat_id, "','")." LIKE '%,$cat,%'";
456 455
 		}
457 456
 		return $cat_filter;
458 457
 	}
@@ -463,32 +462,32 @@  discard block
 block discarded – undo
463 462
 	 * @param int $account_id account-id of the old owner
464 463
 	 * @param int $new_owner account-id of the new owner
465 464
 	 */
466
-	function change_owner($account_id,$new_owner)
465
+	function change_owner($account_id, $new_owner)
467 466
 	{
468 467
 		if (!$new_owner)	// otherwise we would create an account (contact_owner==0)
469 468
 		{
470 469
 			throw egw_exception_wrong_parameter(__METHOD__."($account_id, $new_owner) new owner must not be 0!");
471 470
 		}
472 471
 		// contacts
473
-		$this->db->update($this->table_name,array(
472
+		$this->db->update($this->table_name, array(
474 473
 			'contact_owner' => $new_owner,
475
-		),array(
474
+		), array(
476 475
 			'contact_owner' => $account_id,
477
-		),__LINE__,__FILE__);
476
+		), __LINE__, __FILE__);
478 477
 
479 478
 		// cfs
480 479
 		$this->db->update(self::EXTRA_TABLE, array(
481 480
 			'contact_owner' => $new_owner
482
-		),array(
481
+		), array(
483 482
 			'contact_owner' => $account_id
484 483
 		), __LINE__, __FILE__);
485 484
 
486 485
 		// lists
487 486
 		$this->db->update($this->lists_table, array(
488 487
 			'list_owner' => $new_owner,
489
-		),array(
488
+		), array(
490 489
 			'list_owner' => $account_id,
491
-		),__LINE__,__FILE__);
490
+		), __LINE__, __FILE__);
492 491
 	}
493 492
 
494 493
 	/**
@@ -502,21 +501,21 @@  discard block
 block discarded – undo
502 501
 	 * 	if int|array only return members from the given owners addressbook(s)
503 502
 	 * @return array with list_id => array(list_id,list_name,list_owner,...) pairs
504 503
 	 */
505
-	function get_lists($uids,$uid_column='list_owner',$member_attr=null,$limit_in_ab=false)
504
+	function get_lists($uids, $uid_column = 'list_owner', $member_attr = null, $limit_in_ab = false)
506 505
 	{
507 506
 		if (is_array($uids) && array_key_exists('list_id', $uids))
508 507
 		{
509
-			$uids[] = $this->db->expression($this->lists_table, $this->lists_table.'.',array('list_id' => $uids['list_id']));
508
+			$uids[] = $this->db->expression($this->lists_table, $this->lists_table.'.', array('list_id' => $uids['list_id']));
510 509
 			unset($uids['list_id']);
511 510
 		}
512 511
 		$lists = array();
513
-		foreach($this->db->select($this->lists_table,'*',$uid_column?array($uid_column=>$uids):$uids,__LINE__,__FILE__,
514
-			false,'ORDER BY list_owner<>'.(int)$GLOBALS['egw_info']['user']['account_id'].',list_name') as $row)
512
+		foreach ($this->db->select($this->lists_table, '*', $uid_column ? array($uid_column=>$uids) : $uids, __LINE__, __FILE__,
513
+			false, 'ORDER BY list_owner<>'.(int)$GLOBALS['egw_info']['user']['account_id'].',list_name') as $row)
515 514
 		{
516 515
 			if ($member_attr) $row['members'] = array();
517 516
 			$lists[$row['list_id']] = $row;
518 517
 		}
519
-		if ($lists && $member_attr && in_array($member_attr,array('contact_id','contact_uid','caldav_name')))
518
+		if ($lists && $member_attr && in_array($member_attr, array('contact_id', 'contact_uid', 'caldav_name')))
520 519
 		{
521 520
 			if ($limit_in_ab)
522 521
 			{
@@ -530,10 +529,9 @@  discard block
 block discarded – undo
530 529
 					$in_ab_join .= "list_owner=$this->table_name.contact_owner";
531 530
 				}
532 531
 			}
533
-			foreach($this->db->select($this->ab2list_table,"$this->ab2list_table.list_id,$this->table_name.$member_attr",
532
+			foreach ($this->db->select($this->ab2list_table, "$this->ab2list_table.list_id,$this->table_name.$member_attr",
534 533
 				$this->db->expression($this->ab2list_table, $this->ab2list_table.'.', array('list_id'=>array_keys($lists))),
535
-				__LINE__,__FILE__,false,$member_attr=='contact_id' ? '' :
536
-				'',false,0,"JOIN $this->table_name ON $this->ab2list_table.contact_id=$this->table_name.contact_id".$in_ab_join) as $row)
534
+				__LINE__, __FILE__, false, $member_attr == 'contact_id' ? '' : '', false, 0, "JOIN $this->table_name ON $this->ab2list_table.contact_id=$this->table_name.contact_id".$in_ab_join) as $row)
537 535
 			{
538 536
 				$lists[$row['list_id']]['members'][] = $row[$member_attr];
539 537
 			}
@@ -551,7 +549,7 @@  discard block
 block discarded – undo
551 549
 	 * @param array &$data=array() values for keys 'list_uid', 'list_carddav_name', 'list_name'
552 550
 	 * @return int|boolean integer list_id or false on error
553 551
 	 */
554
-	function add_list($keys,$owner,$contacts=array(),array &$data=array())
552
+	function add_list($keys, $owner, $contacts = array(), array &$data = array())
555 553
 	{
556 554
 		//error_log(__METHOD__.'('.array2string($keys).", $owner, ".array2string($contacts).', '.array2string($data).') '.function_backtrace());
557 555
 		if (!$keys && !$data || !(int)$owner) return false;
@@ -565,7 +563,7 @@  discard block
 block discarded – undo
565 563
 		{
566 564
 			$data['list_owner'] = $owner;
567 565
 		}
568
-		if (!$keys || !($list_id = $this->db->select($this->lists_table,'list_id',$keys,__LINE__,__FILE__)->fetchColumn()))
566
+		if (!$keys || !($list_id = $this->db->select($this->lists_table, 'list_id', $keys, __LINE__, __FILE__)->fetchColumn()))
569 567
 		{
570 568
 			$data['list_created'] = time();
571 569
 			$data['list_creator'] = $GLOBALS['egw_info']['user']['account_id'];
@@ -578,9 +576,9 @@  discard block
 block discarded – undo
578 576
 		$data['list_modifier'] = $GLOBALS['egw_info']['user']['account_id'];
579 577
 		if (!$data['list_id']) unset($data['list_id']);
580 578
 
581
-		if (!$this->db->insert($this->lists_table,$data,$keys,__LINE__,__FILE__)) return false;
579
+		if (!$this->db->insert($this->lists_table, $data, $keys, __LINE__, __FILE__)) return false;
582 580
 
583
-		if (!$list_id && ($list_id = $this->db->get_last_insert_id($this->lists_table,'list_id')) &&
581
+		if (!$list_id && ($list_id = $this->db->get_last_insert_id($this->lists_table, 'list_id')) &&
584 582
 			(!isset($data['list_uid']) || !isset($data['list_carddav_name'])))
585 583
 		{
586 584
 			$update = array();
@@ -592,9 +590,9 @@  discard block
 block discarded – undo
592 590
 			{
593 591
 				$update['list_carddav_name'] = $data['list_carddav_name'] = $data['list_uid'].'.vcf';
594 592
 			}
595
-			$this->db->update($this->lists_table,$update,array('list_id'=>$list_id),__LINE__,__FILE__);
593
+			$this->db->update($this->lists_table, $update, array('list_id'=>$list_id), __LINE__, __FILE__);
596 594
 
597
-			$this->add2list($list_id,$contacts,array());
595
+			$this->add2list($list_id, $contacts, array());
598 596
 		}
599 597
 		if ($keys) $data += $keys;
600 598
 		//error_log(__METHOD__.'('.array2string($keys).", $owner, ...) data=".array2string($data).' returning '.array2string($list_id));
@@ -609,39 +607,39 @@  discard block
 block discarded – undo
609 607
 	 * @param array $existing=null array of existing contact-id(s) of list, to not reread it, eg. array()
610 608
 	 * @return false on error
611 609
 	 */
612
-	function add2list($contact,$list,array $existing=null)
610
+	function add2list($contact, $list, array $existing = null)
613 611
 	{
614 612
 		if (!(int)$list || !is_array($contact) && !(int)$contact) return false;
615 613
 
616 614
 		if (!is_array($existing))
617 615
 		{
618 616
 			$existing = array();
619
-			foreach($this->db->select($this->ab2list_table,'contact_id',array('list_id'=>$list),__LINE__,__FILE__) as $row)
617
+			foreach ($this->db->select($this->ab2list_table, 'contact_id', array('list_id'=>$list), __LINE__, __FILE__) as $row)
620 618
 			{
621 619
 				$existing[] = $row['contact_id'];
622 620
 			}
623 621
 		}
624
-		if (!($to_add = array_diff((array)$contact,$existing)))
622
+		if (!($to_add = array_diff((array)$contact, $existing)))
625 623
 		{
626
-			return true;	// no need to insert it, would give sql error
624
+			return true; // no need to insert it, would give sql error
627 625
 		}
628
-		foreach($to_add as $contact)
626
+		foreach ($to_add as $contact)
629 627
 		{
630
-			$this->db->insert($this->ab2list_table,array(
628
+			$this->db->insert($this->ab2list_table, array(
631 629
 				'contact_id' => $contact,
632 630
 				'list_id' => $list,
633 631
 				'list_added' => time(),
634 632
 				'list_added_by' => $GLOBALS['egw_info']['user']['account_id'],
635
-			),array(),__LINE__,__FILE__);
633
+			), array(), __LINE__, __FILE__);
636 634
 		}
637 635
 		// update etag
638
-		return $this->db->update($this->lists_table,array(
636
+		return $this->db->update($this->lists_table, array(
639 637
 			'list_etag=list_etag+1',
640 638
 			'list_modified' => time(),
641 639
 			'list_modifier' => $GLOBALS['egw_info']['user']['account_id'],
642
-		),array(
640
+		), array(
643 641
 			'list_id' => $list,
644
-		),__LINE__,__FILE__);
642
+		), __LINE__, __FILE__);
645 643
 	}
646 644
 
647 645
 	/**
@@ -651,7 +649,7 @@  discard block
 block discarded – undo
651 649
 	 * @param int $list=null list-id or null to remove from all lists
652 650
 	 * @return false on error
653 651
 	 */
654
-	function remove_from_list($contact,$list=null)
652
+	function remove_from_list($contact, $list = null)
655 653
 	{
656 654
 		if (!(int)$list && !is_null($list) || !is_array($contact) && !(int)$contact) return false;
657 655
 
@@ -665,24 +663,24 @@  discard block
 block discarded – undo
665 663
 		else
666 664
 		{
667 665
 			$list = array();
668
-			foreach($this->db->select($this->ab2list_table,'list_id',$where,__LINE__,__FILE__) as $row)
666
+			foreach ($this->db->select($this->ab2list_table, 'list_id', $where, __LINE__, __FILE__) as $row)
669 667
 			{
670 668
 				$list[] = $row['list_id'];
671 669
 			}
672 670
 		}
673
-		if (!$this->db->delete($this->ab2list_table,$where,__LINE__,__FILE__))
671
+		if (!$this->db->delete($this->ab2list_table, $where, __LINE__, __FILE__))
674 672
 		{
675 673
 			return false;
676 674
 		}
677
-		foreach((array)$list as $list_id)
675
+		foreach ((array)$list as $list_id)
678 676
 		{
679
-			$this->db->update($this->lists_table,array(
677
+			$this->db->update($this->lists_table, array(
680 678
 				'list_etag=list_etag+1',
681 679
 				'list_modified' => time(),
682 680
 				'list_modifier' => $GLOBALS['egw_info']['user']['account_id'],
683
-			),array(
681
+			), array(
684 682
 				'list_id' => $list_id,
685
-			),__LINE__,__FILE__);
683
+			), __LINE__, __FILE__);
686 684
 		}
687 685
 		return true;
688 686
 	}
@@ -695,9 +693,9 @@  discard block
 block discarded – undo
695 693
 	 */
696 694
 	function delete_list($list)
697 695
 	{
698
-		if (!$this->db->delete($this->lists_table,array('list_id' => $list),__LINE__,__FILE__)) return false;
696
+		if (!$this->db->delete($this->lists_table, array('list_id' => $list), __LINE__, __FILE__)) return false;
699 697
 
700
-		$this->db->delete($this->ab2list_table,array('list_id' => $list),__LINE__,__FILE__);
698
+		$this->db->delete($this->ab2list_table, array('list_id' => $list), __LINE__, __FILE__);
701 699
 
702 700
 		return $this->db->affected_rows();
703 701
 	}
@@ -708,12 +706,12 @@  discard block
 block discarded – undo
708 706
 	 * @param int|array $owner=null null for all lists user has access too
709 707
 	 * @return int
710 708
 	 */
711
-	function lists_ctag($owner=null)
709
+	function lists_ctag($owner = null)
712 710
 	{
713 711
 		if (is_null($owner)) $owner = array_keys($this->grants);
714 712
 
715
-		if (!($modified = $this->db->select($this->lists_table,'MAX(list_modified)',array('list_owner'=>$owner),
716
-			__LINE__,__FILE__)->fetchColumn()))
713
+		if (!($modified = $this->db->select($this->lists_table, 'MAX(list_modified)', array('list_owner'=>$owner),
714
+			__LINE__, __FILE__)->fetchColumn()))
717 715
 		{
718 716
 			return 0;
719 717
 		}
@@ -728,7 +726,7 @@  discard block
 block discarded – undo
728 726
 	 * @param string $join
729 727
 	 * @return array|boolean
730 728
 	 */
731
-	function read($keys,$extra_cols='',$join='')
729
+	function read($keys, $extra_cols = '', $join = '')
732 730
 	{
733 731
 		if (isset($GLOBALS['egw_info']['user']['preferences']['syncml']['minimum_uid_length'])) {
734 732
 			$minimum_uid_length = $GLOBALS['egw_info']['user']['preferences']['syncml']['minimum_uid_length'];
@@ -741,11 +739,11 @@  discard block
 block discarded – undo
741 739
 			$keys = array('uid' => $keys);
742 740
 		}
743 741
 		try {
744
-			$contact = parent::read($keys,$extra_cols,$join);
742
+			$contact = parent::read($keys, $extra_cols, $join);
745 743
 		}
746 744
 		// catch Illegal mix of collations (ascii_general_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '=' (1267)
747 745
 		// caused by non-ascii chars compared with ascii field uid
748
-		catch(egw_exception_db $e) {
746
+		catch (egw_exception_db $e) {
749 747
 			_egw_log_exception($e);
750 748
 			return false;
751 749
 		}
@@ -753,7 +751,7 @@  discard block
 block discarded – undo
753 751
 		// enforce a minium uid strength
754 752
 		if (is_array($contact) && (!isset($contact['uid'])
755 753
 				|| strlen($contact['uid']) < $minimum_uid_length)) {
756
-			parent::update(array('uid' => common::generate_uid('addressbook',$contact['id'])));
754
+			parent::update(array('uid' => common::generate_uid('addressbook', $contact['id'])));
757 755
 		}
758 756
 		return $contact;
759 757
 	}
@@ -781,9 +779,9 @@  discard block
 block discarded – undo
781 779
 		{
782 780
 			$etag = $this->data['etag'];
783 781
 			unset($this->data['etag']);
784
-			if (!($err = parent::save(array('contact_etag=contact_etag+1'),array('contact_etag' => $etag))))
782
+			if (!($err = parent::save(array('contact_etag=contact_etag+1'), array('contact_etag' => $etag))))
785 783
 			{
786
-				$this->data['etag'] = $etag+1;
784
+				$this->data['etag'] = $etag + 1;
787 785
 			}
788 786
 			else
789 787
 			{
@@ -803,7 +801,7 @@  discard block
 block discarded – undo
803 801
 		// enforce a minium uid strength
804 802
 		if (!isset($this->data['uid']) || strlen($this->data['uid']) < $minimum_uid_length)
805 803
 		{
806
-			$update['uid'] = common::generate_uid('addressbook',$this->data['id']);
804
+			$update['uid'] = common::generate_uid('addressbook', $this->data['id']);
807 805
 			//echo "<p>set uid={$this->data['uid']}, etag={$this->data['etag']}</p>";
808 806
 		}
809 807
 		// set carddav_name, if not given by caller
@@ -829,7 +827,7 @@  discard block
 block discarded – undo
829 827
 	{
830 828
 		if (!$list) return false;
831 829
 
832
-		return $this->db->select($this->lists_table,'*',array('list_id'=>$list),__LINE__,__FILE__)->fetch();
830
+		return $this->db->select($this->lists_table, '*', array('list_id'=>$list), __LINE__, __FILE__)->fetch();
833 831
 	}
834 832
 
835 833
 	/**
@@ -850,6 +848,6 @@  discard block
 block discarded – undo
850 848
 	*/
851 849
 	function delete_customfields($data)
852 850
 	{
853
-		$this->db->delete($this->extra_table,$data,__LINE__,__FILE__);
851
+		$this->db->delete($this->extra_table, $data, __LINE__, __FILE__);
854 852
 	}
855 853
 }
Please login to merge, or discard this patch.
Braces   +127 added lines, -33 removed lines patch added patch discarded remove patch
@@ -111,11 +111,20 @@  discard block
 block discarded – undo
111 111
 	{
112 112
 		$filter = is_array($param['col_filter']) ? $param['col_filter'] : array();
113 113
 		$op = 'OR';
114
-		if (isset($param['op']) && !empty($param['op'])) $op = $param['op'];
114
+		if (isset($param['op']) && !empty($param['op']))
115
+		{
116
+			$op = $param['op'];
117
+		}
115 118
 		$advanced_search = false;
116
-		if (isset($param['advanced_search']) && !empty($param['advanced_search'])) $advanced_search = true;
119
+		if (isset($param['advanced_search']) && !empty($param['advanced_search']))
120
+		{
121
+			$advanced_search = true;
122
+		}
117 123
 		$wildcard ='%';
118
-		if ($advanced_search || (isset($param['wildcard']) && !empty($param['wildcard']))) $wildcard = ($param['wildcard']?$param['wildcard']:'');
124
+		if ($advanced_search || (isset($param['wildcard']) && !empty($param['wildcard'])))
125
+		{
126
+			$wildcard = ($param['wildcard']?$param['wildcard']:'');
127
+		}
119 128
 
120 129
 		// fix cat_id filter to search in comma-separated multiple cats and return subcats
121 130
 		if ((int)$filter['cat_id'])
@@ -133,7 +142,11 @@  discard block
 block discarded – undo
133 142
 			// we have no private grants in addressbook at the moment, they have then to be added here too
134 143
 			if ($param['owner'])
135 144
 			{
136
-				if (!$this->grants[(int) $filter['owner']]) return false;	// we have no access to that addressbook
145
+				if (!$this->grants[(int) $filter['owner']])
146
+				{
147
+					return false;
148
+				}
149
+				// we have no access to that addressbook
137 150
 
138 151
 				$filter['owner'] = $param['owner'];
139 152
 				$filter['private'] = 0;
@@ -196,7 +209,10 @@  discard block
 block discarded – undo
196 209
 		$rows = parent::search($param['search'],array('org_name'),$append,$extra,$wildcard,false,$op/*'OR'*/,
197 210
 			array($param['start'],$param['num_rows']),$filter);
198 211
 
199
-		if (!$rows) return false;
212
+		if (!$rows)
213
+		{
214
+			return false;
215
+		}
200 216
 
201 217
 		// query the values for *_count == 1, to display them instead
202 218
 		$filter['org_name'] = $orgs = array();
@@ -266,7 +282,10 @@  discard block
 block discarded – undo
266 282
 	 */
267 283
 	function &search($criteria,$only_keys=True,$order_by='',$extra_cols='',$wildcard='',$empty=False,$op='AND',$start=false,$filter=null,$join='',$need_full_no_count=false)
268 284
 	{
269
-		if ((int) $this->debug >= 4) echo '<p>'.__METHOD__.'('.array2string($criteria).','.array2string($only_keys).",'$order_by','$extra_cols','$wildcard','$empty','$op',$start,".array2string($filter).",'$join')</p>\n";
285
+		if ((int) $this->debug >= 4)
286
+		{
287
+			echo '<p>'.__METHOD__.'('.array2string($criteria).','.array2string($only_keys).",'$order_by','$extra_cols','$wildcard','$empty','$op',$start,".array2string($filter).",'$join')</p>\n";
288
+		}
270 289
 		//error_log(__METHOD__.'('.array2string($criteria,true).','.array2string($only_keys).",'$order_by', ".array2string($extra_cols).",'$wildcard','$empty','$op',$start,".array2string($filter).",'$join')");
271 290
 
272 291
 		$owner = isset($filter['owner']) ? $filter['owner'] : (isset($criteria['owner']) ? $criteria['owner'] : null);
@@ -314,7 +333,10 @@  discard block
 block discarded – undo
314 333
 				// no grants for selected owner/addressbook
315 334
 				if (!($filter['owner'] = array_intersect((array)$filter['owner'],array_keys($this->grants))))
316 335
 				{
317
-					if (!isset($groupmember_sql)) return false;
336
+					if (!isset($groupmember_sql))
337
+					{
338
+						return false;
339
+					}
318 340
 					$filter[] = substr($groupmember_sql,4);
319 341
 					unset($filter['owner']);
320 342
 				}
@@ -354,13 +376,16 @@  discard block
 block discarded – undo
354 376
 			$join .= self::ACCOUNT_ACTIVE_JOIN;
355 377
 			$filter[] = str_replace('UNIX_TIMESTAMP(NOW())',time(),self::ACOUNT_ACTIVE_FILTER);
356 378
 		}
357
-		if ($join || ($criteria && is_string($criteria)) || ($criteria && is_array($criteria) && $order_by))	// search also adds a join for custom fields!
379
+		if ($join || ($criteria && is_string($criteria)) || ($criteria && is_array($criteria) && $order_by))
380
+		{
381
+			// search also adds a join for custom fields!
358 382
 		{
359 383
 			switch(gettype($only_keys))
360 384
 			{
361 385
 				case 'boolean':
362 386
 					// Correctly handled by parent class
363 387
 					break;
388
+		}
364 389
 				case 'string':
365 390
 					$only_keys = explode(',',$only_keys);
366 391
 					// fall through
@@ -370,13 +395,23 @@  discard block
 block discarded – undo
370 395
 			if ($this->db->Type != 'mysql' && preg_match_all("/(#?[a-zA-Z_.]+) *(<> *''|IS NULL|IS NOT NULL)? *(ASC|DESC)?(,|$)/ui",
371 396
 				$order_by, $all_matches, PREG_SET_ORDER))
372 397
 			{
373
-				if (!is_array($extra_cols))	$extra_cols = $extra_cols ? explode(',',$extra_cols) : array();
398
+				if (!is_array($extra_cols))
399
+				{
400
+					$extra_cols = $extra_cols ? explode(',',$extra_cols) : array();
401
+				}
374 402
 				foreach($all_matches as $matches)
375 403
 				{
376 404
 					$table = '';
377 405
 					$column = $matches[1];
378
-					if ($column[0] == '#') continue;	// order by custom field is handeled in so_sql_cf anyway
379
-					if (($key = array_search($column, $this->db_cols)) !== false) $column = $key;
406
+					if ($column[0] == '#')
407
+					{
408
+						continue;
409
+					}
410
+					// order by custom field is handeled in so_sql_cf anyway
411
+					if (($key = array_search($column, $this->db_cols)) !== false)
412
+					{
413
+						$column = $key;
414
+					}
380 415
 					if (strpos($column,'.') === false)
381 416
 					{
382 417
 						$table = $column == $this->extra_value ? $this->extra_table : $this->table_name;
@@ -391,10 +426,13 @@  discard block
 block discarded – undo
391 426
 					}
392 427
 					$extra_cols[] = $table.$column.' '.$matches[2];
393 428
 					//_debug_array($matches);
394
-					if (!empty($order_by) && $table) // postgres requires explizit order by
429
+					if (!empty($order_by) && $table)
430
+					{
431
+						// postgres requires explizit order by
395 432
 					{
396 433
 						$order_by = str_replace($matches[0],$table.$column.' '.$matches[2].' '.$matches[3].$matches[4],$order_by);
397 434
 					}
435
+					}
398 436
 				}
399 437
 				//_debug_array($order_by); _debug_array($extra_cols);
400 438
 			}
@@ -420,7 +458,11 @@  discard block
 block discarded – undo
420 458
 		}
421 459
 		$rows =& parent::search($criteria,$only_keys,$order_by,$extra_cols,$wildcard,$empty,$op,$start,$filter,$join,$need_full_no_count);
422 460
 
423
-		if ($start === false) $this->total = is_array($rows) ? count($rows) : 0;	// so_sql sets total only for $start !== false!
461
+		if ($start === false)
462
+		{
463
+			$this->total = is_array($rows) ? count($rows) : 0;
464
+		}
465
+		// so_sql sets total only for $start !== false!
424 466
 
425 467
 		return $rows;
426 468
 	}
@@ -462,7 +504,10 @@  discard block
 block discarded – undo
462 504
 		$cat_filter = array();
463 505
 		foreach(is_array($cats) ? $cats : (is_numeric($cats) ? array($cats) : explode(',',$cats)) as $cat)
464 506
 		{
465
-			if (is_numeric($cat)) $cat_filter[] = $this->db->concat("','",cat_id,"','")." LIKE '%,$cat,%'";
507
+			if (is_numeric($cat))
508
+			{
509
+				$cat_filter[] = $this->db->concat("','",cat_id,"','")." LIKE '%,$cat,%'";
510
+			}
466 511
 		}
467 512
 		return $cat_filter;
468 513
 	}
@@ -475,10 +520,13 @@  discard block
 block discarded – undo
475 520
 	 */
476 521
 	function change_owner($account_id,$new_owner)
477 522
 	{
478
-		if (!$new_owner)	// otherwise we would create an account (contact_owner==0)
523
+		if (!$new_owner)
524
+		{
525
+			// otherwise we would create an account (contact_owner==0)
479 526
 		{
480 527
 			throw Api\Exception\WrongParameter(__METHOD__."($account_id, $new_owner) new owner must not be 0!");
481 528
 		}
529
+		}
482 530
 		// contacts
483 531
 		$this->db->update($this->table_name,array(
484 532
 			'contact_owner' => $new_owner,
@@ -523,7 +571,10 @@  discard block
 block discarded – undo
523 571
 		foreach($this->db->select($this->lists_table,'*',$uid_column?array($uid_column=>$uids):$uids,__LINE__,__FILE__,
524 572
 			false,'ORDER BY list_owner<>'.(int)$GLOBALS['egw_info']['user']['account_id'].',list_name') as $row)
525 573
 		{
526
-			if ($member_attr) $row['members'] = array();
574
+			if ($member_attr)
575
+			{
576
+				$row['members'] = array();
577
+			}
527 578
 			$lists[$row['list_id']] = $row;
528 579
 		}
529 580
 		if ($lists && $member_attr && in_array($member_attr,array('contact_id','contact_uid','caldav_name')))
@@ -564,9 +615,15 @@  discard block
 block discarded – undo
564 615
 	function add_list($keys,$owner,$contacts=array(),array &$data=array())
565 616
 	{
566 617
 		//error_log(__METHOD__.'('.array2string($keys).", $owner, ".array2string($contacts).', '.array2string($data).') '.function_backtrace());
567
-		if (!$keys && !$data || !(int)$owner) return false;
618
+		if (!$keys && !$data || !(int)$owner)
619
+		{
620
+			return false;
621
+		}
568 622
 
569
-		if ($keys && !is_array($keys)) $keys = array('list_name' => $keys);
623
+		if ($keys && !is_array($keys))
624
+		{
625
+			$keys = array('list_name' => $keys);
626
+		}
570 627
 		if ($keys)
571 628
 		{
572 629
 			$keys['list_owner'] = $owner;
@@ -586,9 +643,15 @@  discard block
 block discarded – undo
586 643
 		}
587 644
 		$data['list_modified'] = time();
588 645
 		$data['list_modifier'] = $GLOBALS['egw_info']['user']['account_id'];
589
-		if (!$data['list_id']) unset($data['list_id']);
646
+		if (!$data['list_id'])
647
+		{
648
+			unset($data['list_id']);
649
+		}
590 650
 
591
-		if (!$this->db->insert($this->lists_table,$data,$keys,__LINE__,__FILE__)) return false;
651
+		if (!$this->db->insert($this->lists_table,$data,$keys,__LINE__,__FILE__))
652
+		{
653
+			return false;
654
+		}
592 655
 
593 656
 		if (!$list_id && ($list_id = $this->db->get_last_insert_id($this->lists_table,'list_id')) &&
594 657
 			(!isset($data['list_uid']) || !isset($data['list_carddav_name'])))
@@ -606,7 +669,10 @@  discard block
 block discarded – undo
606 669
 
607 670
 			$this->add2list($list_id,$contacts,array());
608 671
 		}
609
-		if ($keys) $data += $keys;
672
+		if ($keys)
673
+		{
674
+			$data += $keys;
675
+		}
610 676
 		//error_log(__METHOD__.'('.array2string($keys).", $owner, ...) data=".array2string($data).' returning '.array2string($list_id));
611 677
 		return $list_id;
612 678
 	}
@@ -621,7 +687,10 @@  discard block
 block discarded – undo
621 687
 	 */
622 688
 	function add2list($contact,$list,array $existing=null)
623 689
 	{
624
-		if (!(int)$list || !is_array($contact) && !(int)$contact) return false;
690
+		if (!(int)$list || !is_array($contact) && !(int)$contact)
691
+		{
692
+			return false;
693
+		}
625 694
 
626 695
 		if (!is_array($existing))
627 696
 		{
@@ -663,7 +732,10 @@  discard block
 block discarded – undo
663 732
 	 */
664 733
 	function remove_from_list($contact,$list=null)
665 734
 	{
666
-		if (!(int)$list && !is_null($list) || !is_array($contact) && !(int)$contact) return false;
735
+		if (!(int)$list && !is_null($list) || !is_array($contact) && !(int)$contact)
736
+		{
737
+			return false;
738
+		}
667 739
 
668 740
 		$where = array(
669 741
 			'contact_id' => $contact,
@@ -705,7 +777,10 @@  discard block
 block discarded – undo
705 777
 	 */
706 778
 	function delete_list($list)
707 779
 	{
708
-		if (!$this->db->delete($this->lists_table,array('list_id' => $list),__LINE__,__FILE__)) return false;
780
+		if (!$this->db->delete($this->lists_table,array('list_id' => $list),__LINE__,__FILE__))
781
+		{
782
+			return false;
783
+		}
709 784
 
710 785
 		$this->db->delete($this->ab2list_table,array('list_id' => $list),__LINE__,__FILE__);
711 786
 
@@ -720,7 +795,10 @@  discard block
 block discarded – undo
720 795
 	 */
721 796
 	function lists_ctag($owner=null)
722 797
 	{
723
-		if (is_null($owner)) $owner = array_keys($this->grants);
798
+		if (is_null($owner))
799
+		{
800
+			$owner = array_keys($this->grants);
801
+		}
724 802
 
725 803
 		if (!($modified = $this->db->select($this->lists_table,'MAX(list_modified)',array('list_owner'=>$owner),
726 804
 			__LINE__,__FILE__)->fetchColumn()))
@@ -740,9 +818,12 @@  discard block
 block discarded – undo
740 818
 	 */
741 819
 	function read($keys,$extra_cols='',$join='')
742 820
 	{
743
-		if (isset($GLOBALS['egw_info']['user']['preferences']['syncml']['minimum_uid_length'])) {
821
+		if (isset($GLOBALS['egw_info']['user']['preferences']['syncml']['minimum_uid_length']))
822
+		{
744 823
 			$minimum_uid_length = $GLOBALS['egw_info']['user']['preferences']['syncml']['minimum_uid_length'];
745
-		} else {
824
+		}
825
+		else
826
+		{
746 827
 			$minimum_uid_length = 8;
747 828
 		}
748 829
 
@@ -762,7 +843,8 @@  discard block
 block discarded – undo
762 843
 
763 844
 		// enforce a minium uid strength
764 845
 		if (is_array($contact) && (!isset($contact['uid'])
765
-				|| strlen($contact['uid']) < $minimum_uid_length)) {
846
+				|| strlen($contact['uid']) < $minimum_uid_length))
847
+		{
766 848
 			parent::update(array('uid' => Api\CalDAV::generate_uid('addressbook',$contact['id'])));
767 849
 		}
768 850
 		return $contact;
@@ -779,19 +861,28 @@  discard block
 block discarded – undo
779 861
 	{
780 862
 		unset($extra_where);	// not used, but required by function signature
781 863
 
782
-		if (isset($GLOBALS['egw_info']['user']['preferences']['syncml']['minimum_uid_length'])) {
864
+		if (isset($GLOBALS['egw_info']['user']['preferences']['syncml']['minimum_uid_length']))
865
+		{
783 866
 			$minimum_uid_length = $GLOBALS['egw_info']['user']['preferences']['syncml']['minimum_uid_length'];
784
-		} else {
867
+		}
868
+		else
869
+		{
785 870
 			$minimum_uid_length = 8;
786 871
 		}
787 872
 
788
-		if (is_array($keys) && count($keys)) $this->data_merge($keys);
873
+		if (is_array($keys) && count($keys))
874
+		{
875
+			$this->data_merge($keys);
876
+		}
789 877
 
790 878
 		$new_entry = !$this->data['id'];
791 879
 
792
-		if (isset($this->data['etag']))		// do we have an etag in the data to write
880
+		if (isset($this->data['etag']))
881
+		{
882
+			// do we have an etag in the data to write
793 883
 		{
794 884
 			$etag = $this->data['etag'];
885
+		}
795 886
 			unset($this->data['etag']);
796 887
 			if (!($err = parent::save(array('contact_etag=contact_etag+1'),array('contact_etag' => $etag))))
797 888
 			{
@@ -839,7 +930,10 @@  discard block
 block discarded – undo
839 930
 	 */
840 931
 	function read_list($list)
841 932
 	{
842
-		if (!$list) return false;
933
+		if (!$list)
934
+		{
935
+			return false;
936
+		}
843 937
 
844 938
 		return $this->db->select($this->lists_table,'*',array('list_id'=>$list),__LINE__,__FILE__)->fetch();
845 939
 	}
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -543,7 +543,7 @@
 block discarded – undo
543 543
 			foreach($this->db->select($this->ab2list_table,"$this->ab2list_table.list_id,$this->table_name.$member_attr",
544 544
 				$this->db->expression($this->ab2list_table, $this->ab2list_table.'.', array('list_id'=>array_keys($lists))),
545 545
 				__LINE__,__FILE__,false,$member_attr=='contact_id' ? '' :
546
-				'',false,0,"JOIN $this->table_name ON $this->ab2list_table.contact_id=$this->table_name.contact_id".$in_ab_join) as $row)
546
+				'',false,0,"join $this->table_name ON $this->ab2list_table.contact_id=$this->table_name.contact_id".$in_ab_join) as $row)
547 547
 			{
548 548
 				$lists[$row['list_id']]['members'][] = $row[$member_attr];
549 549
 			}
Please login to merge, or discard this patch.
addressbook/inc/class.addressbook_tracking.inc.php 3 patches
Doc Comments   +3 added lines, -9 removed lines patch added patch discarded remove patch
@@ -93,12 +93,7 @@  discard block
 block discarded – undo
93 93
 	/**
94 94
 	 * Get a notification-config value
95 95
 	 *
96
-	 * @param string $what
97
-	 * 	- 'copy' array of email addresses notifications should be copied too, can depend on $data
98
-	 *  - 'lang' string lang code for copy mail
99
-	 *  - 'sender' string send email address
100 96
 	 * @param array $data current entry
101
-	 * @param array $old=null old/last state of the entry or null for a new entry
102 97
 	 * @return mixed
103 98
 	 */
104 99
 	function get_config($name,$data,$old=null)
@@ -134,9 +129,8 @@  discard block
 block discarded – undo
134 129
 	 *
135 130
 	 * @internal use only track($data,$old)
136 131
 	 * @param array $data current entry
137
-	 * @param array $old=null old/last state of the entry or null for a new entry
138
-	 * @param boolean $deleted=null can be set to true to let the tracking know the item got deleted or undelted
139
-	 * @param array $changed_fields=null changed fields from ealier call to $this->changed_fields($data,$old), to not compute it again
132
+	 * @param boolean $deleted can be set to true to let the tracking know the item got deleted or undelted
133
+	 * @param array $changed_fields changed fields from ealier call to $this->changed_fields($data,$old), to not compute it again
140 134
 	 * @return int number of log-entries made
141 135
 	 */
142 136
 	protected function save_history(array $data,array $old=null,$deleted=null,array $changed_fields=null)
@@ -196,7 +190,7 @@  discard block
 block discarded – undo
196 190
 	 *
197 191
 	 * @param array $data
198 192
 	 * @param array $old
199
-	 * @param boolean $deleted=null can be set to true to let the tracking know the item got deleted or undelted
193
+	 * @param boolean $deleted can be set to true to let the tracking know the item got deleted or undelted
200 194
 	 * @param int|string $receiver nummeric account_id or email address
201 195
 	 * @return string
202 196
 	 */
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -101,16 +101,16 @@  discard block
 block discarded – undo
101 101
 	 * @param array $old=null old/last state of the entry or null for a new entry
102 102
 	 * @return mixed
103 103
 	 */
104
-	function get_config($name,$data,$old=null)
104
+	function get_config($name, $data, $old = null)
105 105
 	{
106 106
 		//echo "<p>addressbook_tracking::get_config($name,".print_r($data,true).",...)</p>\n";
107
-		switch($name)
107
+		switch ($name)
108 108
 		{
109 109
 			case 'copy':
110 110
 				if ($data['is_contactform'])
111 111
 				{
112
-					$copy = preg_split('/, ?/',$data['email_contactform']);
113
-					if  ($data['email_copytoreceiver']) $copy[] = $data['email'];
112
+					$copy = preg_split('/, ?/', $data['email_contactform']);
113
+					if ($data['email_copytoreceiver']) $copy[] = $data['email'];
114 114
 					return $copy;
115 115
 				}
116 116
 				break;
@@ -139,27 +139,27 @@  discard block
 block discarded – undo
139 139
 	 * @param array $changed_fields=null changed fields from ealier call to $this->changed_fields($data,$old), to not compute it again
140 140
 	 * @return int number of log-entries made
141 141
 	 */
142
-	protected function save_history(array $data,array $old=null,$deleted=null,array $changed_fields=null)
142
+	protected function save_history(array $data, array $old = null, $deleted = null, array $changed_fields = null)
143 143
 	{
144 144
 		if (is_null($changed_fields))
145 145
 		{
146
-			$changed_fields = self::changed_fields($data,$old);
146
+			$changed_fields = self::changed_fields($data, $old);
147 147
 		}
148 148
 		if (!$changed_fields) return 0;
149 149
 
150
-		foreach(array('adr_one_countryname' => 'adr_one_countrycode', 'adr_two_countryname' => 'adr_two_countrycode') as $name => $code)
150
+		foreach (array('adr_one_countryname' => 'adr_one_countrycode', 'adr_two_countryname' => 'adr_two_countrycode') as $name => $code)
151 151
 		{
152 152
 			// Only codes involved, but old text name is automatically added when loaded
153
-			if($old[$code] && $data[$code] && ($key = array_search($name, $changed_fields)) !== false)
153
+			if ($old[$code] && $data[$code] && ($key = array_search($name, $changed_fields)) !== false)
154 154
 			{
155 155
 				unset($changed_fields[$key]);
156 156
 				continue;
157 157
 			}
158 158
 
159 159
 			// Code and a text name
160
-			if(in_array($name, $changed_fields) && in_array($code, $changed_fields))
160
+			if (in_array($name, $changed_fields) && in_array($code, $changed_fields))
161 161
 			{
162
-				if($data[$code])
162
+				if ($data[$code])
163 163
 				{
164 164
 					$data[$name] = $GLOBALS['egw']->country->get_full_name($data[$code], true);
165 165
 				}
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 			}
168 168
 		}
169 169
 		//error_log(__METHOD__.__LINE__.' ChangedFields:'.array2string($changed_fields));
170
-		return parent::save_history($data,$old,$deleted,$changed_fields);
170
+		return parent::save_history($data, $old, $deleted, $changed_fields);
171 171
 	}
172 172
 
173 173
 	/**
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 	 * @param int|string $receiver nummeric account_id or email address
179 179
 	 * @return string
180 180
 	 */
181
-	protected function get_message($data,$old,$receiver=null)
181
+	protected function get_message($data, $old, $receiver = null)
182 182
 	{
183 183
 		if (!$data['modified'] || !$old)
184 184
 		{
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 	 * @param int|string $receiver nummeric account_id or email address
201 201
 	 * @return string
202 202
 	 */
203
-	protected function get_subject($data,$old,$deleted=null,$receiver=null)
203
+	protected function get_subject($data, $old, $deleted = null, $receiver = null)
204 204
 	{
205 205
 		if ($data['is_contactform'])
206 206
 		{
@@ -216,13 +216,13 @@  discard block
 block discarded – undo
216 216
 	 * @param int|string $receiver nummeric account_id or email address
217 217
 	 * @return array of details as array with values for keys 'label','value','type'
218 218
 	 */
219
-	function get_details($data,$receiver=null)
219
+	function get_details($data, $receiver = null)
220 220
 	{
221
-		foreach($this->contacts->contact_fields as $name => $label)
221
+		foreach ($this->contacts->contact_fields as $name => $label)
222 222
 		{
223 223
 			if (!$data[$name] && $name != 'owner') continue;
224 224
 
225
-			switch($name)
225
+			switch ($name)
226 226
 			{
227 227
 				case 'n_prefix': case 'n_given': case 'n_middle': case 'n_family': case 'n_suffix':	// already in n_fn
228 228
 				case 'n_fileas': case 'id': case 'tid':
@@ -236,10 +236,10 @@  discard block
 block discarded – undo
236 236
 				case 'bday':
237 237
 					if ($data[$name])
238 238
 					{
239
-						list($y,$m,$d) = explode('-',$data[$name]);
239
+						list($y, $m, $d) = explode('-', $data[$name]);
240 240
 						$details[$name] = array(
241 241
 							'label' => $label,
242
-							'value' => common::dateformatorder($y,$m,$d,true),
242
+							'value' => common::dateformatorder($y, $m, $d, true),
243 243
 						);
244 244
 					}
245 245
 					break;
@@ -253,13 +253,13 @@  discard block
 block discarded – undo
253 253
 					if ($data[$name])
254 254
 					{
255 255
 						$cats = array();
256
-						foreach(is_array($data[$name]) ? $data[$name] : explode(',',$data[$name]) as $cat_id)
256
+						foreach (is_array($data[$name]) ? $data[$name] : explode(',', $data[$name]) as $cat_id)
257 257
 						{
258 258
 							$cats[] = $GLOBALS['egw']->cats->id2name($cat_id);
259 259
 						}
260 260
 						$details[$name] = array(
261 261
 							'label' => $label,
262
-							'value' => explode(', ',$cats),
262
+							'value' => explode(', ', $cats),
263 263
 						);
264 264
 					}
265 265
 				case 'note':
Please login to merge, or discard this patch.
Braces   +12 added lines, -3 removed lines patch added patch discarded remove patch
@@ -116,7 +116,10 @@  discard block
 block discarded – undo
116 116
 				if ($data['is_contactform'])
117 117
 				{
118 118
 					$copy = preg_split('/, ?/',$data['email_contactform']);
119
-					if  ($data['email_copytoreceiver']) $copy[] = $data['email'];
119
+					if  ($data['email_copytoreceiver'])
120
+					{
121
+						$copy[] = $data['email'];
122
+					}
120 123
 					return $copy;
121 124
 				}
122 125
 				break;
@@ -150,7 +153,10 @@  discard block
 block discarded – undo
150 153
 		{
151 154
 			$changed_fields = self::changed_fields($data,$old);
152 155
 		}
153
-		if (!$changed_fields) return 0;
156
+		if (!$changed_fields)
157
+		{
158
+			return 0;
159
+		}
154 160
 
155 161
 		foreach(array('adr_one_countryname' => 'adr_one_countrycode', 'adr_two_countryname' => 'adr_two_countrycode') as $name => $code)
156 162
 		{
@@ -231,7 +237,10 @@  discard block
 block discarded – undo
231 237
 
232 238
 		foreach($this->contacts->contact_fields as $name => $label)
233 239
 		{
234
-			if (!$data[$name] && $name != 'owner') continue;
240
+			if (!$data[$name] && $name != 'owner')
241
+			{
242
+				continue;
243
+			}
235 244
 
236 245
 			switch($name)
237 246
 			{
Please login to merge, or discard this patch.
admin/admin-cli.php 3 patches
Doc Comments   +5 added lines, -6 removed lines patch added patch discarded remove patch
@@ -299,8 +299,8 @@  discard block
 block discarded – undo
299 299
 /**
300 300
  * Give a usage message and exit
301 301
  *
302
- * @param string $action=null
303
- * @param int $ret=0 exit-code
302
+ * @param string $action
303
+ * @param int $ret exit-code
304 304
  */
305 305
 function usage($action=null,$ret=0)
306 306
 {
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
  * Edit or add a user to EGroupware. If you specify groups, they *replace* the exiting memberships!
405 405
  *                    1:                     2:             3:                         4:         5:        6:       7:    8:                                         9:                                 10:                            11:                                  12
406 406
  * @param array $args admin-account[@domain],admin-password,account[=new-account-name],first-name,last-name,password,email,expires{never(default)|YYYY-MM-DD|already},can-change-pw{true(default)|false},anon-user{true|false(default)},primary-group{Default(default)|...}[,groups,...][,homedirectory,loginshell]
407
- * @param boolean $run_addaccount_hook=null default run hook depending on account existence, true=allways run addaccount hook
407
+ * @param boolean $run_addaccount_hook default run hook depending on account existence, true=allways run addaccount hook
408 408
  */
409 409
 function do_edit_user($args,$run_addaccount_hook=null)
410 410
 {
@@ -453,8 +453,8 @@  discard block
 block discarded – undo
453 453
  * Delete a given acount from eGW
454 454
  *
455 455
  * @param int/string $account account-name of -id
456
- * @param int/string $new_user=0 for users only: account to move the entries too
457
- * @param boolean $is_user=true are we called for a user or group
456
+ * @param int/string $new_user for users only: account to move the entries too
457
+ * @param boolean $is_user are we called for a user or group
458 458
  * @return int 0 on success, 2-4 otherwise (see source)
459 459
  */
460 460
 function do_delete_account($account,$new_user=0,$is_user=true)
@@ -523,7 +523,6 @@  discard block
 block discarded – undo
523 523
 /**
524 524
  * Read the IMAP ACLs
525 525
  *
526
- * @param array $args admin-account[@domain],admin-password,accout_lid[,pw]
527 526
  * @return int 0 on success
528 527
  */
529 528
 function do_subscribe_other($account_lid,$pw=null)
Please login to merge, or discard this patch.
Spacing   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  * @version $Id$
12 12
  */
13 13
 
14
-chdir(dirname(__FILE__));	// to enable our relative pathes to work
14
+chdir(dirname(__FILE__)); // to enable our relative pathes to work
15 15
 
16 16
 if (php_sapi_name() !== 'cli')	// security precaution: forbit calling admin-cli as web-page
17 17
 {
@@ -29,39 +29,39 @@  discard block
 block discarded – undo
29 29
 }
30 30
 
31 31
 // allow to specify instance by using a username with appended @domain-name
32
-$arg0s = explode(',',@array_shift($arguments));
33
-@list($user,$domain) = explode('@',$arg0s[0]);
34
-load_egw($user,$arg0s[1],$domain);
32
+$arg0s = explode(',', @array_shift($arguments));
33
+@list($user, $domain) = explode('@', $arg0s[0]);
34
+load_egw($user, $arg0s[1], $domain);
35 35
 
36
-switch($action)
36
+switch ($action)
37 37
 {
38 38
 	case '--edit-user':
39 39
 		return do_edit_user($arg0s);
40 40
 
41 41
 	case '--add-user':	// like --edit-account, but always runs addaccount hook
42
-		return do_edit_user($arg0s,true);
42
+		return do_edit_user($arg0s, true);
43 43
 
44 44
 	case '--change-pw':
45 45
 		return do_change_pw($arg0s);
46 46
 
47 47
 	case '--delete-user':
48
-		return do_delete_account($arg0s[2],$arg0s[3]);
48
+		return do_delete_account($arg0s[2], $arg0s[3]);
49 49
 
50 50
 	case '--edit-group':
51 51
 		return do_edit_group($arg0s);
52 52
 
53 53
 	case '--delete-group':
54
-		return do_delete_account($arg0s[2],0,false);
54
+		return do_delete_account($arg0s[2], 0, false);
55 55
 
56 56
 	case '--allow-app':
57 57
 	case '--deny-app':
58
-		return do_account_app($arg0s,$action == '--allow-app');
58
+		return do_account_app($arg0s, $action == '--allow-app');
59 59
 
60 60
 	case '--change-account-id':
61 61
 		return do_change_account_id($arg0s);
62 62
 
63 63
 	case '--subscribe-other':
64
-		return do_subscribe_other($arg0s[2],$arg0s[3]);
64
+		return do_subscribe_other($arg0s[2], $arg0s[3]);
65 65
 
66 66
 	case '--check-acl';
67 67
 		return do_check_acl();
@@ -74,21 +74,21 @@  discard block
 block discarded – undo
74 74
 
75 75
 	default:
76 76
 		// we allow to call admin_cmd classes directly, if they define the constant SETUP_CLI_CALLABLE
77
-		if (substr($action,0,2) == '--' && class_exists($class = str_replace('-','_',substr($action,2))) &&
78
-			is_subclass_of($class,'admin_cmd') && @constant($class.'::SETUP_CLI_CALLABLE'))
77
+		if (substr($action, 0, 2) == '--' && class_exists($class = str_replace('-', '_', substr($action, 2))) &&
78
+			is_subclass_of($class, 'admin_cmd') && @constant($class.'::SETUP_CLI_CALLABLE'))
79 79
 		{
80 80
 			$args = array();
81
-			$args['domain'] = array_shift($arg0s);	// domain must be first argument, to ensure right domain get's selected in header-include
82
-			foreach($arg0s as $arg)
81
+			$args['domain'] = array_shift($arg0s); // domain must be first argument, to ensure right domain get's selected in header-include
82
+			foreach ($arg0s as $arg)
83 83
 			{
84
-				list($name,$value) = explode('=',$arg,2);
85
-				if(property_exists('admin_cmd',$name))		// dont allow to overwrite admin_cmd properties
84
+				list($name, $value) = explode('=', $arg, 2);
85
+				if (property_exists('admin_cmd', $name))		// dont allow to overwrite admin_cmd properties
86 86
 				{
87
-					throw new egw_exception_wrong_userinput(lang("Invalid argument '%1' !!!",$arg),90);
87
+					throw new egw_exception_wrong_userinput(lang("Invalid argument '%1' !!!", $arg), 90);
88 88
 				}
89
-				if (substr($name,-1) == ']')	// allow 1-dim. arrays
89
+				if (substr($name, -1) == ']')	// allow 1-dim. arrays
90 90
 				{
91
-					list($name,$sub) = explode('[',substr($name,0,-1),2);
91
+					list($name, $sub) = explode('[', substr($name, 0, -1), 2);
92 92
 					$args[$name][$sub] = $value;
93 93
 				}
94 94
 				else
@@ -112,12 +112,12 @@  discard block
 block discarded – undo
112 112
  */
113 113
 function run_command(admin_cmd $cmd)
114 114
 {
115
-	global $arguments,$user,$arg0s,$domain;
115
+	global $arguments, $user, $arg0s, $domain;
116 116
 
117 117
 	$skip_checks = false;
118 118
 	while ($arguments && ($extra = array_shift($arguments)))
119 119
 	{
120
-		switch($extra)
120
+		switch ($extra)
121 121
 		{
122 122
 			case '--schedule':	// schedule the command instead of running it directly
123 123
 				$time = admin_cmd::parse_date(array_shift($arguments));
@@ -147,15 +147,15 @@  discard block
 block discarded – undo
147 147
 			case '--header-access':
148 148
 				if ($cmd instanceof setup_cmd)
149 149
 				{
150
-					list($user,$pw) = explode(',',array_shift($arguments),2);
151
-					$cmd->set_header_secret($user,$pw);
150
+					list($user, $pw) = explode(',', array_shift($arguments), 2);
151
+					$cmd->set_header_secret($user, $pw);
152 152
 				}
153 153
 				break;
154 154
 
155 155
 			default:
156 156
 				//fail(99,lang('Unknown option %1',$extra);
157
-				echo lang('Unknown option %1',$extra)."\n\n";
158
-				usage('',99);
157
+				echo lang('Unknown option %1', $extra)."\n\n";
158
+				usage('', 99);
159 159
 				break;
160 160
 		}
161 161
 	}
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 		{
175 175
 			$url = $GLOBALS['egw_info']['server']['webserver_url'].'/json.php?menuaction=admin.admin_hooks.ajax_clear_cache';
176 176
 			if ($url[0] == '/') $url = 'http://'.(!empty($domain) && $domain != 'default' ? $domain : 'localhost').$url;
177
-			$data = file_get_contents($url, false, egw_framework::proxy_context($user,$arg0s[1]));
177
+			$data = file_get_contents($url, false, egw_framework::proxy_context($user, $arg0s[1]));
178 178
 			//error_log("file_get_contents('$url') returned ".array2string($data));
179 179
 			if ($data && strpos($data, '"success"') !== false)
180 180
 			{
@@ -213,13 +213,13 @@  discard block
 block discarded – undo
213 213
 	{
214 214
 		//fail(1,lang("Wrong admin-account or -password !!!"));
215 215
 		echo lang("Wrong admin-account or -password !!!")."\n\n";
216
-		usage('',1);
216
+		usage('', 1);
217 217
 	}
218 218
 	if (!$GLOBALS['egw_info']['user']['apps']['admin'])	// will be tested by the header too, but whould give html error-message
219 219
 	{
220 220
 		//fail(2,lang("Permission denied !!!"));
221 221
 		echo lang("Permission denied !!!")."\n\n";
222
-		usage('',2);
222
+		usage('', 2);
223 223
 	}
224 224
 	return $sessionid;
225 225
 }
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
  * @param string $passwd
232 232
  * @param string $domain
233 233
  */
234
-function load_egw($user,$passwd,$domain='default')
234
+function load_egw($user, $passwd, $domain = 'default')
235 235
 {
236 236
 	//echo "load_egw($user,$passwd,$domain)\n";
237 237
 	$_REQUEST['domain'] = $domain;
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 
244 244
 	if (ini_get('session.save_handler') == 'files' && !is_writable(ini_get('session.save_path')) && is_dir('/tmp') && is_writable('/tmp'))
245 245
 	{
246
-		ini_set('session.save_path','/tmp');	// regular users may have no rights to apache's session dir
246
+		ini_set('session.save_path', '/tmp'); // regular users may have no rights to apache's session dir
247 247
 	}
248 248
 
249 249
 	$GLOBALS['egw_info'] = array(
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
 		)
256 256
 	);
257 257
 
258
-	if (substr($user,0,5) != 'root_')
258
+	if (substr($user, 0, 5) != 'root_')
259 259
 	{
260 260
 		include('../header.inc.php');
261 261
 	}
@@ -265,9 +265,9 @@  discard block
 block discarded – undo
265 265
 		include('../header.inc.php');
266 266
 
267 267
 		if ($user == 'root_'.$GLOBALS['egw_info']['server']['header_admin_user'] &&
268
-			_check_pw($GLOBALS['egw_info']['server']['header_admin_password'],$passwd) ||
268
+			_check_pw($GLOBALS['egw_info']['server']['header_admin_password'], $passwd) ||
269 269
 			$user == 'root_'.$GLOBALS['egw_domain'][$_GET['domain']]['config_user'] &&
270
-			_check_pw($GLOBALS['egw_domain'][$_GET['domain']]['config_passwd'],$passwd))
270
+			_check_pw($GLOBALS['egw_domain'][$_GET['domain']]['config_passwd'], $passwd))
271 271
 		{
272 272
 			echo "\nRoot access granted!\n";
273 273
 			egw_vfs::$is_root = true;
@@ -286,10 +286,10 @@  discard block
 block discarded – undo
286 286
  * @param string $pw
287 287
  * @return boolean
288 288
  */
289
-function _check_pw($hash_or_cleartext,$pw)
289
+function _check_pw($hash_or_cleartext, $pw)
290 290
 {
291 291
 	//echo "_check_pw($hash_or_cleartext,$pw) md5=".md5($pw)."\n";
292
-	if (preg_match('/^[0-9a-f]{32}$/',$hash_or_cleartext))
292
+	if (preg_match('/^[0-9a-f]{32}$/', $hash_or_cleartext))
293 293
 	{
294 294
 		return $hash_or_cleartext == md5($pw);
295 295
 	}
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
  * @param string $action=null
303 303
  * @param int $ret=0 exit-code
304 304
  */
305
-function usage($action=null,$ret=0)
305
+function usage($action = null, $ret = 0)
306 306
 {
307 307
 	$cmd = basename($_SERVER['argv'][0]);
308 308
 	echo "Usage: $cmd --command admin-account[@domain],admin-password,options,... [--schedule {YYYY-mm-dd|+1 week|+5 days}] [--requested 'Name <email>'] [--comment 'comment ...'] [--remote {id|name}] [--skip-checks] [--dry-run]\n\n";
@@ -344,14 +344,14 @@  discard block
 block discarded – undo
344 344
  * @param boolean $allow true=allow, false=deny
345 345
  * @return int 0 on success
346 346
  */
347
-function do_account_app($args,$allow)
347
+function do_account_app($args, $allow)
348 348
 {
349
-	array_shift($args);	// admin-account
350
-	array_shift($args);	// admin-pw
349
+	array_shift($args); // admin-account
350
+	array_shift($args); // admin-pw
351 351
 	$account = array_shift($args);
352 352
 
353 353
 	include_once(EGW_INCLUDE_ROOT.'/admin/inc/class.admin_cmd_account_app.inc.php');
354
-	run_command(new admin_cmd_account_app($allow,$account,$args));
354
+	run_command(new admin_cmd_account_app($allow, $account, $args));
355 355
 }
356 356
 
357 357
 /**
@@ -361,9 +361,9 @@  discard block
 block discarded – undo
361 361
  */
362 362
 function do_edit_group($args)
363 363
 {
364
-	array_shift($args);	// admin-account
365
-	array_shift($args);	// admin-pw
366
-	list($account,$new_account_name) = explode('=',array_shift($args));	// account[=new-account-name]
364
+	array_shift($args); // admin-account
365
+	array_shift($args); // admin-pw
366
+	list($account, $new_account_name) = explode('=', array_shift($args)); // account[=new-account-name]
367 367
 
368 368
 	$data = array(
369 369
 		'account_lid' => $new_account_name,
@@ -371,9 +371,9 @@  discard block
 block discarded – undo
371 371
 		'account_members' => $args,
372 372
 	);
373 373
 	try {
374
-		admin_cmd::parse_account($account,false);
374
+		admin_cmd::parse_account($account, false);
375 375
 
376
-		foreach($data as $name => &$value)	// existing account --> empty values mean dont change, not set them empty!
376
+		foreach ($data as $name => &$value)	// existing account --> empty values mean dont change, not set them empty!
377 377
 		{
378 378
 			if ((string)$value === '') $value = null;
379 379
 		}
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
 		$data['account_lid'] = $account;
383 383
 		$account = false;
384 384
 	};
385
-	run_command(new admin_cmd_edit_group($account,$data));
385
+	run_command(new admin_cmd_edit_group($account, $data));
386 386
 }
387 387
 
388 388
 /**
@@ -392,12 +392,12 @@  discard block
 block discarded – undo
392 392
  */
393 393
 function do_change_pw($args)
394 394
 {
395
-	array_shift($args);     // admin-account
396
-	array_shift($args);     // admin-pw
397
-	$account = array_shift($args);	// account
398
-	$password = array_shift($args);	// pw
395
+	array_shift($args); // admin-account
396
+	array_shift($args); // admin-pw
397
+	$account = array_shift($args); // account
398
+	$password = array_shift($args); // pw
399 399
 
400
-	run_command(new admin_cmd_change_pw($account,$password));
400
+	run_command(new admin_cmd_change_pw($account, $password));
401 401
 }
402 402
 
403 403
 /**
@@ -406,18 +406,18 @@  discard block
 block discarded – undo
406 406
  * @param array $args admin-account[@domain],admin-password,account[=new-account-name],first-name,last-name,password,email,expires{never(default)|YYYY-MM-DD|already},can-change-pw{true(default)|false},anon-user{true|false(default)},primary-group{Default(default)|...}[,groups,...][,homedirectory,loginshell]
407 407
  * @param boolean $run_addaccount_hook=null default run hook depending on account existence, true=allways run addaccount hook
408 408
  */
409
-function do_edit_user($args,$run_addaccount_hook=null)
409
+function do_edit_user($args, $run_addaccount_hook = null)
410 410
 {
411
-	array_shift($args);	// admin-account
412
-	array_shift($args);	// admin-pw
413
-	list($account,$new_account_name) = explode('=',array_shift($args));	// account[=new-account-name]
411
+	array_shift($args); // admin-account
412
+	array_shift($args); // admin-pw
413
+	list($account, $new_account_name) = explode('=', array_shift($args)); // account[=new-account-name]
414 414
 
415 415
 	$data = array();
416 416
 	// do we need to support ldap only attributes: homedirectory and loginshell
417 417
 	if (($GLOBALS['egw_info']['server']['account_repository'] == 'ldap' ||
418 418
 		 empty($GLOBALS['egw_info']['server']['account_repository']) && $GLOBALS['egw_info']['server']['auth_type'] == 'ldap') &&
419
-		$GLOBALS['egw_info']['server']['ldap_extra_attributes'] && count($args) > 9 &&	// 9 = primary group
420
-		($last_arg = array_pop($dummy=$args)) && $last_arg[0] == '/')	// last argument start with a slash
419
+		$GLOBALS['egw_info']['server']['ldap_extra_attributes'] && count($args) > 9 && // 9 = primary group
420
+		($last_arg = array_pop($dummy = $args)) && $last_arg[0] == '/')	// last argument start with a slash
421 421
 	{
422 422
 		$data['loginshell'] = array_pop($args);
423 423
 		$data['homedirectory'] = array_pop($args);
@@ -435,9 +435,9 @@  discard block
 block discarded – undo
435 435
 		'account_groups' => $args,
436 436
 	);
437 437
 	try {
438
-		admin_cmd::parse_account($account,true);
438
+		admin_cmd::parse_account($account, true);
439 439
 
440
-		foreach($data as $name => &$value)	// existing account --> empty values mean dont change, not set them empty!
440
+		foreach ($data as $name => &$value)	// existing account --> empty values mean dont change, not set them empty!
441 441
 		{
442 442
 			if ((string)$value === '') $value = null;
443 443
 		}
@@ -446,7 +446,7 @@  discard block
 block discarded – undo
446 446
 		$data['account_lid'] = $account;
447 447
 		$account = false;
448 448
 	}
449
-	run_command(new admin_cmd_edit_user($account,$data,null,$run_addaccount_hook));
449
+	run_command(new admin_cmd_edit_user($account, $data, null, $run_addaccount_hook));
450 450
 }
451 451
 
452 452
 /**
@@ -457,9 +457,9 @@  discard block
 block discarded – undo
457 457
  * @param boolean $is_user=true are we called for a user or group
458 458
  * @return int 0 on success, 2-4 otherwise (see source)
459 459
  */
460
-function do_delete_account($account,$new_user=0,$is_user=true)
460
+function do_delete_account($account, $new_user = 0, $is_user = true)
461 461
 {
462
-	run_command(new admin_cmd_delete_account($account,$new_user,$is_user));
462
+	run_command(new admin_cmd_delete_account($account, $new_user, $is_user));
463 463
 }
464 464
 
465 465
 /**
@@ -480,13 +480,13 @@  discard block
 block discarded – undo
480 480
  */
481 481
 function do_change_account_id($args)
482 482
 {
483
-	if (count($args) < 4) usage();	// 4 means at least user,pw,from1,to1
483
+	if (count($args) < 4) usage(); // 4 means at least user,pw,from1,to1
484 484
 
485 485
 	$ids2change = array();
486
-	for($n = 2; $n < count($args); $n += 2)
486
+	for ($n = 2; $n < count($args); $n += 2)
487 487
 	{
488 488
 		$from = (int)$args[$n];
489
-		$to   = (int)$args[$n+1];
489
+		$to   = (int)$args[$n + 1];
490 490
 		$ids2change[$from] = $to;
491 491
 	}
492 492
 	run_command(new admin_cmd_change_account_id($ids2change));
@@ -502,21 +502,21 @@  discard block
 block discarded – undo
502 502
  */
503 503
 function list_exit_codes()
504 504
 {
505
-	error_reporting(error_reporting() & ~E_NOTICE);
505
+	error_reporting(error_reporting()&~E_NOTICE);
506 506
 
507 507
 	$codes = array('Ok');
508
-	foreach(file(__FILE__) as $n => $line)
508
+	foreach (file(__FILE__) as $n => $line)
509 509
 	{
510
-		if (preg_match('/fail\(([0-9]+),(.*)\);/',$line,$matches))
510
+		if (preg_match('/fail\(([0-9]+),(.*)\);/', $line, $matches))
511 511
 		{
512 512
 			//echo "Line $n: $matches[1]: $matches[2]\n";
513 513
 			@eval('$codes['.$matches[1].'] = '.$matches[2].';');
514 514
 		}
515 515
 	}
516
-	ksort($codes,SORT_NUMERIC);
517
-	foreach($codes as $num => $msg)
516
+	ksort($codes, SORT_NUMERIC);
517
+	foreach ($codes as $num => $msg)
518 518
 	{
519
-		echo $num."\t".str_replace("\n","\n\t",$msg)."\n";
519
+		echo $num."\t".str_replace("\n", "\n\t", $msg)."\n";
520 520
 	}
521 521
 }
522 522
 
@@ -526,11 +526,11 @@  discard block
 block discarded – undo
526 526
  * @param array $args admin-account[@domain],admin-password,accout_lid[,pw]
527 527
  * @return int 0 on success
528 528
  */
529
-function do_subscribe_other($account_lid,$pw=null)
529
+function do_subscribe_other($account_lid, $pw = null)
530 530
 {
531 531
 	if (!($account_id = $GLOBALS['egw']->accounts->name2id($account_lid)))
532 532
 	{
533
-		throw new egw_exception_wrong_userinput(lang("Unknown account: %1 !!!",$account_lid),15);
533
+		throw new egw_exception_wrong_userinput(lang("Unknown account: %1 !!!", $account_lid), 15);
534 534
 	}
535 535
 	$GLOBALS['egw_info']['user'] = array(
536 536
 		'account_id' => $account_id,
@@ -554,13 +554,13 @@  discard block
 block discarded – undo
554 554
 
555 555
 	$own_mbox = 'user'.$delimiter.$account_lid;
556 556
 
557
-	foreach($mailboxes as $n => $mailbox)
557
+	foreach ($mailboxes as $n => $mailbox)
558 558
 	{
559 559
 //		if ($n < 1) continue;
560 560
 
561
-		if (substr($mailbox,0,5) != 'user'.$delimiter || substr($mailbox,0,strlen($own_mbox)) == $own_mbox) continue;
561
+		if (substr($mailbox, 0, 5) != 'user'.$delimiter || substr($mailbox, 0, strlen($own_mbox)) == $own_mbox) continue;
562 562
 
563
-		if (!$pw) $mailbox = str_replace('INBOX','user'.$delimiter.$account_lid,$mailbox);
563
+		if (!$pw) $mailbox = str_replace('INBOX', 'user'.$delimiter.$account_lid, $mailbox);
564 564
 
565 565
 /*		$rights = $icServer->getACL($mailbox);
566 566
 		echo "getACL($mailbox)\n";
Please login to merge, or discard this patch.
Braces   +45 added lines, -11 removed lines patch added patch discarded remove patch
@@ -13,10 +13,13 @@  discard block
 block discarded – undo
13 13
 
14 14
 chdir(dirname(__FILE__));	// to enable our relative pathes to work
15 15
 
16
-if (php_sapi_name() !== 'cli')	// security precaution: forbit calling admin-cli as web-page
16
+if (php_sapi_name() !== 'cli')
17
+{
18
+	// security precaution: forbit calling admin-cli as web-page
17 19
 {
18 20
 	die('<h1>admin-cli.php must NOT be called as web-page --> exiting !!!</h1>');
19 21
 }
22
+}
20 23
 elseif ($_SERVER['argc'] > 1)
21 24
 {
22 25
 	$arguments = $_SERVER['argv'];
@@ -82,13 +85,19 @@  discard block
 block discarded – undo
82 85
 			foreach($arg0s as $arg)
83 86
 			{
84 87
 				list($name,$value) = explode('=',$arg,2);
85
-				if(property_exists('admin_cmd',$name))		// dont allow to overwrite admin_cmd properties
88
+				if(property_exists('admin_cmd',$name))
89
+				{
90
+					// dont allow to overwrite admin_cmd properties
86 91
 				{
87 92
 					throw new egw_exception_wrong_userinput(lang("Invalid argument '%1' !!!",$arg),90);
88 93
 				}
89
-				if (substr($name,-1) == ']')	// allow 1-dim. arrays
94
+				}
95
+				if (substr($name,-1) == ']')
96
+				{
97
+					// allow 1-dim. arrays
90 98
 				{
91 99
 					list($name,$sub) = explode('[',substr($name,0,-1),2);
100
+				}
92 101
 					$args[$name][$sub] = $value;
93 102
 				}
94 103
 				else
@@ -173,7 +182,10 @@  discard block
 block discarded – undo
173 182
 		if (!$dry_run)
174 183
 		{
175 184
 			$url = $GLOBALS['egw_info']['server']['webserver_url'].'/json.php?menuaction=admin.admin_hooks.ajax_clear_cache';
176
-			if ($url[0] == '/') $url = 'http://'.(!empty($domain) && $domain != 'default' ? $domain : 'localhost').$url;
185
+			if ($url[0] == '/')
186
+			{
187
+				$url = 'http://'.(!empty($domain) && $domain != 'default' ? $domain : 'localhost').$url;
188
+			}
177 189
 			$data = file_get_contents($url, false, egw_framework::proxy_context($user,$arg0s[1]));
178 190
 			//error_log("file_get_contents('$url') returned ".array2string($data));
179 191
 			if ($data && strpos($data, '"success"') !== false)
@@ -215,10 +227,13 @@  discard block
 block discarded – undo
215 227
 		echo lang("Wrong admin-account or -password !!!")."\n\n";
216 228
 		usage('',1);
217 229
 	}
218
-	if (!$GLOBALS['egw_info']['user']['apps']['admin'])	// will be tested by the header too, but whould give html error-message
230
+	if (!$GLOBALS['egw_info']['user']['apps']['admin'])
231
+	{
232
+		// will be tested by the header too, but whould give html error-message
219 233
 	{
220 234
 		//fail(2,lang("Permission denied !!!"));
221 235
 		echo lang("Permission denied !!!")."\n\n";
236
+	}
222 237
 		usage('',2);
223 238
 	}
224 239
 	return $sessionid;
@@ -373,10 +388,13 @@  discard block
 block discarded – undo
373 388
 	try {
374 389
 		admin_cmd::parse_account($account,false);
375 390
 
376
-		foreach($data as $name => &$value)	// existing account --> empty values mean dont change, not set them empty!
391
+		foreach($data as $name => &$value)
392
+		{
393
+			// existing account --> empty values mean dont change, not set them empty!
377 394
 		{
378 395
 			if ((string)$value === '') $value = null;
379 396
 		}
397
+		}
380 398
 	}
381 399
 	catch (Exception $e) {	// new group
382 400
 		$data['account_lid'] = $account;
@@ -417,9 +435,12 @@  discard block
 block discarded – undo
417 435
 	if (($GLOBALS['egw_info']['server']['account_repository'] == 'ldap' ||
418 436
 		 empty($GLOBALS['egw_info']['server']['account_repository']) && $GLOBALS['egw_info']['server']['auth_type'] == 'ldap') &&
419 437
 		$GLOBALS['egw_info']['server']['ldap_extra_attributes'] && count($args) > 9 &&	// 9 = primary group
420
-		($last_arg = array_pop($dummy=$args)) && $last_arg[0] == '/')	// last argument start with a slash
438
+		($last_arg = array_pop($dummy=$args)) && $last_arg[0] == '/')
439
+	{
440
+		// last argument start with a slash
421 441
 	{
422 442
 		$data['loginshell'] = array_pop($args);
443
+	}
423 444
 		$data['homedirectory'] = array_pop($args);
424 445
 	}
425 446
 	$data += array(
@@ -437,10 +458,13 @@  discard block
 block discarded – undo
437 458
 	try {
438 459
 		admin_cmd::parse_account($account,true);
439 460
 
440
-		foreach($data as $name => &$value)	// existing account --> empty values mean dont change, not set them empty!
461
+		foreach($data as $name => &$value)
462
+		{
463
+			// existing account --> empty values mean dont change, not set them empty!
441 464
 		{
442 465
 			if ((string)$value === '') $value = null;
443 466
 		}
467
+		}
444 468
 	}
445 469
 	catch (Exception $e) {	// new account
446 470
 		$data['account_lid'] = $account;
@@ -480,7 +504,11 @@  discard block
 block discarded – undo
480 504
  */
481 505
 function do_change_account_id($args)
482 506
 {
483
-	if (count($args) < 4) usage();	// 4 means at least user,pw,from1,to1
507
+	if (count($args) < 4)
508
+	{
509
+		usage();
510
+	}
511
+	// 4 means at least user,pw,from1,to1
484 512
 
485 513
 	$ids2change = array();
486 514
 	for($n = 2; $n < count($args); $n += 2)
@@ -558,9 +586,15 @@  discard block
 block discarded – undo
558 586
 	{
559 587
 //		if ($n < 1) continue;
560 588
 
561
-		if (substr($mailbox,0,5) != 'user'.$delimiter || substr($mailbox,0,strlen($own_mbox)) == $own_mbox) continue;
589
+		if (substr($mailbox,0,5) != 'user'.$delimiter || substr($mailbox,0,strlen($own_mbox)) == $own_mbox)
590
+		{
591
+			continue;
592
+		}
562 593
 
563
-		if (!$pw) $mailbox = str_replace('INBOX','user'.$delimiter.$account_lid,$mailbox);
594
+		if (!$pw)
595
+		{
596
+			$mailbox = str_replace('INBOX','user'.$delimiter.$account_lid,$mailbox);
597
+		}
564 598
 
565 599
 /*		$rights = $icServer->getACL($mailbox);
566 600
 		echo "getACL($mailbox)\n";
Please login to merge, or discard this patch.
admin/inc/class.admin_acl.inc.php 3 patches
Doc Comments   +2 added lines, -3 removed lines patch added patch discarded remove patch
@@ -283,8 +283,7 @@  discard block
 block discarded – undo
283 283
 	 * Check if current user has access to ACL setting of a given location
284 284
 	 *
285 285
 	 * @param int $account_id numeric account-id
286
-	 * @param int|string $location=null numeric account-id or "run"
287
-	 * @param boolean $throw=true if true, throw an exception if no access, instead of just returning false
286
+	 * @param int|string $location numeric account-id or "run"
288 287
 	 * @return boolean true if access is granted, false if notification_bo
289 288
 	 * @throws egw_exception_no_permission
290 289
 	 */
@@ -330,7 +329,7 @@  discard block
 block discarded – undo
330 329
 	 * Checks access and throws an exception, if a change is attempted without proper access
331 330
 	 *
332 331
 	 * @param string|array $ids "$app:$account:$location" string used as row-id in list
333
-	 * @param int $rights=null null to delete, or new rights
332
+	 * @param int $rights null to delete, or new rights
334 333
 	 * @throws egw_exception_no_permission
335 334
 	 */
336 335
 	public static function ajax_change_acl($ids, $rights=null)
Please login to merge, or discard this patch.
Spacing   +28 added lines, -31 removed lines patch added patch discarded remove patch
@@ -50,14 +50,14 @@  discard block
 block discarded – undo
50 50
 		$old_apps = array_keys($this->acl->get_user_applications($content['acl_account'], false, false));
51 51
 		// add new apps
52 52
 		$added_apps = array_diff($content['apps'], $old_apps);
53
-		foreach($added_apps as $app)
53
+		foreach ($added_apps as $app)
54 54
 		{
55 55
 			$this->acl->add_repository($app, 'run', $content['acl_account'], 1);
56 56
 		}
57 57
 		// remove no longer checked apps
58 58
 		$removed_apps = array_diff($old_apps, $content['apps']);
59 59
 		$deleted_ids = array();
60
-		foreach($removed_apps as $app)
60
+		foreach ($removed_apps as $app)
61 61
 		{
62 62
 			$this->acl->delete_repository($app, 'run', $content['acl_account']);
63 63
 			$deleted_ids[] = $app.':'.$content['acl_account'].':run';
@@ -91,12 +91,11 @@  discard block
 block discarded – undo
91 91
 	{
92 92
 		// assamble rights again
93 93
 		$rights = (int)$content['preserve_rights'];
94
-		foreach($content['acl'] as $right)
94
+		foreach ($content['acl'] as $right)
95 95
 		{
96 96
 			$rights |= $right;
97 97
 		}
98
-		$id = !empty($content['id']) ? $content['id'] :
99
-		$content['acl_appname'].':'.$content['acl_account'].':'.$content['acl_location'];
98
+		$id = !empty($content['id']) ? $content['id'] : $content['acl_appname'].':'.$content['acl_account'].':'.$content['acl_location'];
100 99
 		//error_log(__METHOD__."() id=$id, acl=".array2string($content['acl'])." --> rights=$rights");
101 100
 
102 101
 		if ($this->acl->get_specific_rights_for_account($content['acl_account'], $content['acl_location'], $content['acl_appname']) == $rights)
@@ -129,14 +128,14 @@  discard block
 block discarded – undo
129 128
 	 * @param array &$rows=null
130 129
 	 * @return int total number of rows available
131 130
 	 */
132
-	public static function get_rows(array $query, array &$rows=null)
131
+	public static function get_rows(array $query, array &$rows = null)
133 132
 	{
134 133
 		$so_sql = new so_sql('phpgwapi', acl::TABLE, null, '', true);
135 134
 
136 135
 		// client queries destinct rows by their row-id
137 136
 		if (isset($query['col_filter']['id']))
138 137
 		{
139
-			$query['col_filter'][] = $GLOBALS['egw']->db->concat('acl_appname',"':'",'acl_account',"':'",'acl_location').
138
+			$query['col_filter'][] = $GLOBALS['egw']->db->concat('acl_appname', "':'", 'acl_account', "':'", 'acl_location').
140 139
 				' IN ('.implode(',', array_map(array($GLOBALS['egw']->db, 'quote'), (array)$query['col_filter']['id'])).')';
141 140
 			unset($query['col_filter']['id']);
142 141
 		}
@@ -154,9 +153,9 @@  discard block
 block discarded – undo
154 153
 			if ($GLOBALS['egw_info']['user']['preferences']['admin']['acl_filter'] != $query['filter'])
155 154
 			{
156 155
 				$GLOBALS['egw']->preferences->add('admin', 'acl_filter', $query['filter']);
157
-				$GLOBALS['egw']->preferences->save_repository(false,'user',false);
156
+				$GLOBALS['egw']->preferences->save_repository(false, 'user', false);
158 157
 			}
159
-			switch($query['filter'])
158
+			switch ($query['filter'])
160 159
 			{
161 160
 				case 'run':
162 161
 					$query['col_filter']['acl_location'] = 'run';
@@ -180,7 +179,7 @@  discard block
 block discarded – undo
180 179
 					if ($not_enum_group_acls)
181 180
 					{
182 181
 						$sql = '(CASE acl_appname';
183
-						foreach($not_enum_group_acls as $app => $groups)
182
+						foreach ($not_enum_group_acls as $app => $groups)
184 183
 						{
185 184
 							if ($groups === true)
186 185
 							{
@@ -190,7 +189,7 @@  discard block
 block discarded – undo
190 189
 							{
191 190
 								$check = array_diff($memberships, $groups);
192 191
 								//error_log(__METHOD__."() app=$app, array_diff(memberships=".array2string($memberships).", groups=".array2string($groups).")=".array2string($check));
193
-								if (!$check) continue;	// would give sql error otherwise!
192
+								if (!$check) continue; // would give sql error otherwise!
194 193
 							}
195 194
 							$sql .= ' WHEN '.$GLOBALS['egw']->db->quote($app).' THEN '.$GLOBALS['egw']->db->expression(acl::TABLE, array(
196 195
 								'acl_account' => $check,
@@ -220,7 +219,7 @@  discard block
 block discarded – undo
220 219
 		$readonlys = array();
221 220
 		$total = $so_sql->get_rows($query, $rows, $readonlys);
222 221
 
223
-		foreach($rows as &$row)
222
+		foreach ($rows as &$row)
224 223
 		{
225 224
 			// generate a row-id
226 225
 			$row['id'] = $row['acl_appname'].':'.$row['acl_account'].':'.$row['acl_location'];
@@ -232,9 +231,9 @@  discard block
 block discarded – undo
232 231
 			else
233 232
 			{
234 233
 				if ($app !== $row['acl_appname']) translation::add_app($row['app_name']);
235
-				foreach($query['acl_rights'][$row['acl_appname']] as $val => $label)
234
+				foreach ($query['acl_rights'][$row['acl_appname']] as $val => $label)
236 235
 				{
237
-					if ($row['acl_rights'] & $val)
236
+					if ($row['acl_rights']&$val)
238 237
 					{
239 238
 						$row['acl'.$val] = lang($label);
240 239
 					}
@@ -249,11 +248,11 @@  discard block
 block discarded – undo
249 248
 		//error_log(__METHOD__."(".array2string($query).") returning ".$total);
250 249
 
251 250
 		// Get supporting or all apps for filter2 depending on filter
252
-		if($query['filter'] == 'run')
251
+		if ($query['filter'] == 'run')
253 252
 		{
254 253
 			$rows['sel_options']['filter2'] = array(
255 254
 				'' => lang('All applications'),
256
-			)+etemplate_widget_menupopup::app_options('enabled');
255
+			) + etemplate_widget_menupopup::app_options('enabled');
257 256
 		}
258 257
 		else
259 258
 		{
@@ -264,14 +263,14 @@  discard block
 block discarded – undo
264 263
 				'location' => 'acl_rights',
265 264
 				'owner' => $query['account_id'],
266 265
 			), array(), true);
267
-			foreach($apps as $appname => $rights)
266
+			foreach ($apps as $appname => $rights)
268 267
 			{
269 268
 				$rows['sel_options']['filter2'][] = array(
270 269
 					'value' => $appname,
271 270
 					'label' => lang($appname)
272 271
 				);
273 272
 			}
274
-			usort($rows['sel_options']['filter2'], function($a,$b) {
273
+			usort($rows['sel_options']['filter2'], function($a, $b) {
275 274
 				return strcasecmp($a['label'], $b['label']);
276 275
 			});
277 276
 		}
@@ -288,14 +287,14 @@  discard block
 block discarded – undo
288 287
 	 * @return boolean true if access is granted, false if notification_bo
289 288
 	 * @throws egw_exception_no_permission
290 289
 	 */
291
-	public static function check_access($account_id, $location=null, $throw=true)
290
+	public static function check_access($account_id, $location = null, $throw = true)
292 291
 	{
293
-		static $admin_access=null;
294
-		static $own_access=null;
292
+		static $admin_access = null;
293
+		static $own_access = null;
295 294
 		if (is_null($admin_access))
296 295
 		{
297 296
 			$admin_access = isset($GLOBALS['egw_info']['user']['apps']['admin']) &&
298
-				!$GLOBALS['egw']->acl->check('account_access', 64, 'admin');	// ! because this denies access!
297
+				!$GLOBALS['egw']->acl->check('account_access', 64, 'admin'); // ! because this denies access!
299 298
 			$own_access = $admin_access || isset($GLOBALS['egw_info']['user']['apps']['preferences']);
300 299
 		}
301 300
 		if (!(int)$account_id || !((int)$account_id == (int)$GLOBALS['egw_info']['user']['account_id'] && $location !== 'run' ?
@@ -317,9 +316,9 @@  discard block
 block discarded – undo
317 316
 	public static function ajax_get_app_list($account_id)
318 317
 	{
319 318
 		$list = array();
320
-		if(self::check_access((int)$account_id,'run',false))
319
+		if (self::check_access((int)$account_id, 'run', false))
321 320
 		{
322
-			$list = array_keys($GLOBALS['egw']->acl->get_user_applications((int)$account_id,false,false));
321
+			$list = array_keys($GLOBALS['egw']->acl->get_user_applications((int)$account_id, false, false));
323 322
 		}
324 323
 		egw_json_response::get()->data($list);
325 324
 	}
@@ -333,14 +332,14 @@  discard block
 block discarded – undo
333 332
 	 * @param int $rights=null null to delete, or new rights
334 333
 	 * @throws egw_exception_no_permission
335 334
 	 */
336
-	public static function ajax_change_acl($ids, $rights=null)
335
+	public static function ajax_change_acl($ids, $rights = null)
337 336
 	{
338 337
 		try {
339
-			foreach((array)$ids as $id)
338
+			foreach ((array)$ids as $id)
340 339
 			{
341 340
 				list($app, $account_id, $location) = explode(':', $id, 3);
342 341
 
343
-				self::check_access($account_id, $location);	// throws exception, if no rights
342
+				self::check_access($account_id, $location); // throws exception, if no rights
344 343
 
345 344
 				$acl = $GLOBALS['egw']->acl;
346 345
 
@@ -384,7 +383,7 @@  discard block
 block discarded – undo
384 383
 	 *
385 384
 	 * @param array $content
386 385
 	 */
387
-	public function index(array $content=null)
386
+	public function index(array $content = null)
388 387
 	{
389 388
 		$tpl = new etemplate_new('admin.acl');
390 389
 
@@ -394,9 +393,7 @@  discard block
 block discarded – undo
394 393
 		$content['nm'] = array(
395 394
 			'get_rows' => 'admin_acl::get_rows',
396 395
 			'no_cat' => true,
397
-			'filter' => !empty($_GET['acl_filter']) ? $_GET['acl_filter'] :
398
-				($GLOBALS['egw_info']['flags']['currentapp'] != 'admin' ? 'other' :
399
-					$GLOBALS['egw_info']['user']['preferences']['admin']['acl_filter']),
396
+			'filter' => !empty($_GET['acl_filter']) ? $_GET['acl_filter'] : ($GLOBALS['egw_info']['flags']['currentapp'] != 'admin' ? 'other' : $GLOBALS['egw_info']['user']['preferences']['admin']['acl_filter']),
400 397
 			'filter2' => !empty($_GET['acl_app']) ? $_GET['acl_app'] : '',
401 398
 			'lettersearch' => false,
402 399
 			'header_row'   => 'admin.acl.add',
Please login to merge, or discard this patch.
Braces   +31 added lines, -8 removed lines patch added patch discarded remove patch
@@ -103,9 +103,12 @@  discard block
 block discarded – undo
103 103
 		{
104 104
 			// nothing changed --> nothing to do
105 105
 		}
106
-		elseif (!$rights)	// all rights removed --> delete it
106
+		elseif (!$rights)
107
+		{
108
+			// all rights removed --> delete it
107 109
 		{
108 110
 			$this->acl->delete_repository($content['acl_appname'], $content['acl_location'], $content['acl_account']);
111
+		}
109 112
 			egw_framework::refresh_opener(lang('ACL deleted.'), 'admin', $id, 'delete');
110 113
 		}
111 114
 		else
@@ -190,7 +193,11 @@  discard block
 block discarded – undo
190 193
 							{
191 194
 								$check = array_diff($memberships, $groups);
192 195
 								//error_log(__METHOD__."() app=$app, array_diff(memberships=".array2string($memberships).", groups=".array2string($groups).")=".array2string($check));
193
-								if (!$check) continue;	// would give sql error otherwise!
196
+								if (!$check)
197
+								{
198
+									continue;
199
+								}
200
+								// would give sql error otherwise!
194 201
 							}
195 202
 							$sql .= ' WHEN '.$GLOBALS['egw']->db->quote($app).' THEN '.$GLOBALS['egw']->db->expression(acl::TABLE, array(
196 203
 								'acl_account' => $check,
@@ -201,7 +208,10 @@  discard block
 block discarded – undo
201 208
 					$sql .= $GLOBALS['egw']->db->expression(acl::TABLE, array(
202 209
 						'acl_account' => $memberships,
203 210
 					));
204
-					if ($not_enum_group_acls) $sql .= ' END)';
211
+					if ($not_enum_group_acls)
212
+					{
213
+						$sql .= ' END)';
214
+					}
205 215
 					$query['col_filter'][] = $sql;
206 216
 					break;
207 217
 
@@ -231,7 +241,10 @@  discard block
 block discarded – undo
231 241
 			}
232 242
 			else
233 243
 			{
234
-				if ($app !== $row['acl_appname']) translation::add_app($row['app_name']);
244
+				if ($app !== $row['acl_appname'])
245
+				{
246
+					translation::add_app($row['app_name']);
247
+				}
235 248
 				foreach($query['acl_rights'][$row['acl_appname']] as $val => $label)
236 249
 				{
237 250
 					if ($row['acl_rights'] & $val)
@@ -240,10 +253,13 @@  discard block
 block discarded – undo
240 253
 					}
241 254
 				}
242 255
 			}
243
-			if (!self::check_access($row['acl_account'], $row['acl_location'], false))	// false: do NOT throw an exception!
256
+			if (!self::check_access($row['acl_account'], $row['acl_location'], false))
257
+			{
258
+				// false: do NOT throw an exception!
244 259
 			{
245 260
 				$row['class'] = 'rowNoEdit';
246 261
 			}
262
+			}
247 263
 			//error_log(__METHOD__."() $n: ".array2string($row));
248 264
 		}
249 265
 		//error_log(__METHOD__."(".array2string($query).") returning ".$total);
@@ -271,7 +287,8 @@  discard block
 block discarded – undo
271 287
 					'label' => lang($appname)
272 288
 				);
273 289
 			}
274
-			usort($rows['sel_options']['filter2'], function($a,$b) {
290
+			usort($rows['sel_options']['filter2'], function($a,$b)
291
+			{
275 292
 				return strcasecmp($a['label'], $b['label']);
276 293
 			});
277 294
 		}
@@ -301,7 +318,10 @@  discard block
 block discarded – undo
301 318
 		if (!(int)$account_id || !((int)$account_id == (int)$GLOBALS['egw_info']['user']['account_id'] && $location !== 'run' ?
302 319
 				$own_access : $admin_access))
303 320
 		{
304
-			if ($throw) throw new egw_exception_no_permission(lang('Permission denied!!!'));
321
+			if ($throw)
322
+			{
323
+				throw new egw_exception_no_permission(lang('Permission denied!!!'));
324
+			}
305 325
 			return false;
306 326
 		}
307 327
 		return true;
@@ -344,10 +364,13 @@  discard block
 block discarded – undo
344 364
 
345 365
 				$acl = $GLOBALS['egw']->acl;
346 366
 
347
-				if (!(int)$rights)	// this also handles taking away all rights as delete
367
+				if (!(int)$rights)
368
+				{
369
+					// this also handles taking away all rights as delete
348 370
 				{
349 371
 					$acl->delete_repository($app, $location, $account_id);
350 372
 				}
373
+				}
351 374
 				else
352 375
 				{
353 376
 					$acl->add_repository($app, $location, $account_id, $rights);
Please login to merge, or discard this patch.
admin/inc/class.admin_applications.inc.php 3 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -185,6 +185,10 @@
 block discarded – undo
185 185
 		$order[$next_app] = $old_pos;
186 186
 	}
187 187
 
188
+	/**
189
+	 * @param integer $old_key
190
+	 * @param boolean $reverse
191
+	 */
188 192
 	function find_next_key($array,$old_key,$reverse)
189 193
 	{
190 194
 		//error_log("find_next_key($old_key ".$GLOBALS['egw']->applications->id2name($old_key)." position:".$array[$old_key].",".var_dump($reverse).")");
Please login to merge, or discard this patch.
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 	 */
39 39
 	function __construct()
40 40
 	{
41
-		$this->so = new so_sql(self::APP,self::TABLE,null,'',true);
41
+		$this->so = new so_sql(self::APP, self::TABLE, null, '', true);
42 42
 	}
43 43
 
44 44
 	/**
@@ -49,20 +49,20 @@  discard block
 block discarded – undo
49 49
 	 * @param array &$readonlys eg. to disable buttons based on acl, not use here, maybe in a derived class
50 50
 	 * @return int total number of rows
51 51
 	 */
52
-	function get_rows($query,&$rows,&$readonlys)
52
+	function get_rows($query, &$rows, &$readonlys)
53 53
 	{
54 54
 		//$query['col_filter'][] = array('app_enabled' => array(1,4));
55
-		$total = $this->so->get_rows($query,$rows,$readonlys);
55
+		$total = $this->so->get_rows($query, $rows, $readonlys);
56 56
 
57
-		foreach($rows as $i => &$row)
57
+		foreach ($rows as $i => &$row)
58 58
 		{
59 59
 			//_debug_array($GLOBALS['egw_info']['apps'][$app]);
60
-			$row['image'] = (isset($row['app_icon_app'])?$row['app_icon_app']:$row['app_name']).'/'.
61
-							(isset($row['app_icon'])?$row['app_icon']:'navbar');
60
+			$row['image'] = (isset($row['app_icon_app']) ? $row['app_icon_app'] : $row['app_name']).'/'.
61
+							(isset($row['app_icon']) ? $row['app_icon'] : 'navbar');
62 62
 			//_debug_array($row);
63
-			if($i == 0)
63
+			if ($i == 0)
64 64
 				$readonlys['up['.$row['app_id'].']'] = true;
65
-			if($i == count($rows) - 1)
65
+			if ($i == count($rows) - 1)
66 66
 				$readonlys['down['.$row['app_id'].']'] = true;
67 67
 		}
68 68
 
@@ -74,55 +74,55 @@  discard block
 block discarded – undo
74 74
 	 *
75 75
 	 * @param array $content
76 76
 	 */
77
-	function index(array $content=null)
77
+	function index(array $content = null)
78 78
 	{
79 79
 		//_debug_array($content);
80
-		if(!isset($content))
80
+		if (!isset($content))
81 81
 		{
82 82
 			$content['nm'] = array(
83
-				'get_rows'       =>	'admin.admin_applications.get_rows',	// I  method/callback to request the data for the rows eg. 'notes.bo.get_rows'
84
-				'no_filter'      => True,	// I  disable the 1. filter
85
-				'col_filter'     =>	array('app_enabled' => array(1,4),"app_name not in ('admin','manual')"),	// =All	// IO filter, if not 'no_filter' => True
86
-				'no_filter2'     => True,	// I  disable the 2. filter (params are the same as for filter)
87
-				'no_cat'         => True,	// I  disable the cat-selectbox
88
-				'header_left'    =>	false,	// I  template to show left of the range-value, left-aligned (optional)
89
-				'header_right'   =>	false,	// I  template to show right of the range-value, right-aligned (optional)
90
-				'never_hide'     => True,	// I  never hide the nextmatch-line if less then maxmatch entries
91
-				'lettersearch'   => false,	// I  show a lettersearch
92
-				'start'          =>	0,		// IO position in list
93
-				'order'          =>	'app_order',	// IO name of the column to sort after (optional for the sortheaders)
94
-				'sort'           =>	'ASC',	// IO direction of the sort: 'ASC' or 'DESC'
83
+				'get_rows'       =>	'admin.admin_applications.get_rows', // I  method/callback to request the data for the rows eg. 'notes.bo.get_rows'
84
+				'no_filter'      => True, // I  disable the 1. filter
85
+				'col_filter'     =>	array('app_enabled' => array(1, 4), "app_name not in ('admin','manual')"), // =All	// IO filter, if not 'no_filter' => True
86
+				'no_filter2'     => True, // I  disable the 2. filter (params are the same as for filter)
87
+				'no_cat'         => True, // I  disable the cat-selectbox
88
+				'header_left'    =>	false, // I  template to show left of the range-value, left-aligned (optional)
89
+				'header_right'   =>	false, // I  template to show right of the range-value, right-aligned (optional)
90
+				'never_hide'     => True, // I  never hide the nextmatch-line if less then maxmatch entries
91
+				'lettersearch'   => false, // I  show a lettersearch
92
+				'start'          =>	0, // IO position in list
93
+				'order'          =>	'app_order', // IO name of the column to sort after (optional for the sortheaders)
94
+				'sort'           =>	'ASC', // IO direction of the sort: 'ASC' or 'DESC'
95 95
 				//'default_cols'   => 	// I  columns to use if there's no user or default pref (! as first char uses all but the named columns), default all columns
96
-				'csv_fields'     =>	false,	// I  false=disable csv export, true or unset=enable it with auto-detected fieldnames,
96
+				'csv_fields'     =>	false, // I  false=disable csv export, true or unset=enable it with auto-detected fieldnames,
97 97
 								//or array with name=>label or name=>array('label'=>label,'type'=>type) pairs (type is a eT widget-type)
98 98
 			);
99 99
 		}
100
-		elseif(isset($content['nm']['rows']['up']))
100
+		elseif (isset($content['nm']['rows']['up']))
101 101
 		{
102 102
 			list($app) = each($content['nm']['rows']['up']);
103 103
 			unset($content['nm']['rows']['up']);
104 104
 			$this->move_app(-1, $app);
105 105
 			egw::invalidate_session_cache();
106
-			egw::redirect_link('/index.php',array('menuaction'=>'admin.admin_applications.index'));
106
+			egw::redirect_link('/index.php', array('menuaction'=>'admin.admin_applications.index'));
107 107
 			exit;
108 108
 		}
109
-		elseif(isset($content['nm']['rows']['down']))
109
+		elseif (isset($content['nm']['rows']['down']))
110 110
 		{
111 111
 			list($app) = each($content['nm']['rows']['down']);
112 112
 			unset($content['nm']['rows']['down']);
113 113
 			$this->move_app(1, $app);
114 114
 			egw::invalidate_session_cache();
115
-			egw::redirect_link('/index.php',array('menuaction'=>'admin.admin_applications.index'));
115
+			egw::redirect_link('/index.php', array('menuaction'=>'admin.admin_applications.index'));
116 116
 			exit;
117 117
 		}
118
-		elseif(isset($content['number']))
118
+		elseif (isset($content['number']))
119 119
 		{
120 120
 			// number apps serially
121 121
 			$order = array();
122
-			foreach($GLOBALS['egw_info']['apps'] as $app)
122
+			foreach ($GLOBALS['egw_info']['apps'] as $app)
123 123
 			{
124 124
 				//_debug_array(array($app['name'],$app['status'],$app['order']));
125
-				if(($app['status'] == 1 || $app['status'] == 4) && $app['name']!='admin' && $app['name']!='manual')
125
+				if (($app['status'] == 1 || $app['status'] == 4) && $app['name'] != 'admin' && $app['name'] != 'manual')
126 126
 				{
127 127
 					$order[$app['id']] = $app['order'];
128 128
 				}
@@ -130,25 +130,25 @@  discard block
 block discarded – undo
130 130
 			asort($order);
131 131
 			$app_ids = array_keys($order);
132 132
 			//_debug_array($app_ids);
133
-			foreach($app_ids as $pos => $app)
133
+			foreach ($app_ids as $pos => $app)
134 134
 			{
135 135
 				$app_name = $GLOBALS['egw']->applications->id2name($app);
136 136
 				//echo "set $app_name ($app) to ".($pos + 1)."<br>";
137
-				$newpos= ($pos+1)*5;
138
-				$GLOBALS['egw']->db->update(self::TABLE,array('app_order' => $newpos),array('app_id' => $app),__LINE__,__FILE__);
137
+				$newpos = ($pos + 1) * 5;
138
+				$GLOBALS['egw']->db->update(self::TABLE, array('app_order' => $newpos), array('app_id' => $app), __LINE__, __FILE__);
139 139
 				// set the egw_info->apps array as well
140
-				if(isset($GLOBALS['egw_info']['apps'][$app_name]))
140
+				if (isset($GLOBALS['egw_info']['apps'][$app_name]))
141 141
 				{
142 142
 					$GLOBALS['egw_info']['apps'][$app_name]['order'] = $newpos;
143 143
 				}
144 144
 			}
145 145
 			egw::invalidate_session_cache();
146
-			egw::redirect_link('/index.php',array('menuaction'=>'admin.admin_applications.index'));
146
+			egw::redirect_link('/index.php', array('menuaction'=>'admin.admin_applications.index'));
147 147
 			exit;
148 148
 		}
149 149
 
150 150
 		$tmpl = new etemplate('admin.applications');
151
-		$tmpl->exec('admin.admin_applications.index',$content,$sel_options,$readonlys,array(
151
+		$tmpl->exec('admin.admin_applications.index', $content, $sel_options, $readonlys, array(
152 152
 			'nm' => $content['nm'],
153 153
 		));
154 154
 	}
@@ -159,13 +159,13 @@  discard block
 block discarded – undo
159 159
 	 * @param int $dir the direction to move: -1 up, 1 down
160 160
 	 * @param int $app id of the app to move
161 161
 	 */
162
-	function move_app($dir,$app)
162
+	function move_app($dir, $app)
163 163
 	{
164 164
 		//echo "move_app($dir,$app,$order,$move_only)<br>";
165 165
 		$order = array();
166
-		foreach($GLOBALS['egw_info']['apps'] as $_app)
166
+		foreach ($GLOBALS['egw_info']['apps'] as $_app)
167 167
 		{
168
-			if(($_app['status'] == 1 || $_app['status'] == 4 ) && $app['name']!='admin' && $_app['name']!='manual')
168
+			if (($_app['status'] == 1 || $_app['status'] == 4) && $app['name'] != 'admin' && $_app['name'] != 'manual')
169 169
 			{
170 170
 				$order[$_app['id']] = $_app['order'];
171 171
 				//echo '<center>#'.$_app['id'].': '.$_app['title'].'->'.$_app['order'].'</center><br>';
@@ -176,22 +176,22 @@  discard block
 block discarded – undo
176 176
 
177 177
 		// switch positions
178 178
 		$old_pos = $order[$app];
179
-		$next_app = $this->find_next_key($order,$app,$dir == -1);
179
+		$next_app = $this->find_next_key($order, $app, $dir == -1);
180 180
 		$new_pos = $order[$next_app];
181
-		if ($new_pos == $old_pos) $new_pos= $new_pos + $dir;
182
-		$GLOBALS['egw']->db->update(self::TABLE,array('app_order' => $new_pos),array('app_id' => $app),__LINE__,__FILE__);
181
+		if ($new_pos == $old_pos) $new_pos = $new_pos + $dir;
182
+		$GLOBALS['egw']->db->update(self::TABLE, array('app_order' => $new_pos), array('app_id' => $app), __LINE__, __FILE__);
183 183
 		$order[$app] = $new_pos;
184
-		$GLOBALS['egw']->db->update(self::TABLE,array('app_order' => $old_pos),array('app_id' => $next_app),__LINE__,__FILE__);
184
+		$GLOBALS['egw']->db->update(self::TABLE, array('app_order' => $old_pos), array('app_id' => $next_app), __LINE__, __FILE__);
185 185
 		$order[$next_app] = $old_pos;
186 186
 	}
187 187
 
188
-	function find_next_key($array,$old_key,$reverse)
188
+	function find_next_key($array, $old_key, $reverse)
189 189
 	{
190 190
 		//error_log("find_next_key($old_key ".$GLOBALS['egw']->applications->id2name($old_key)." position:".$array[$old_key].",".var_dump($reverse).")");
191 191
 		$next_key = false;
192 192
 		$first = true;
193 193
 		$neworder = $array[$old_key];
194
-		foreach($array as $key => $value)
194
+		foreach ($array as $key => $value)
195 195
 		{
196 196
 			// remember the first entry
197 197
 			if ($first === true)
@@ -199,10 +199,10 @@  discard block
 block discarded – undo
199 199
 				//echo $key.' first app in order ('.$value.')<br>';
200 200
 				$first = $key;
201 201
 			}
202
-			if(!$reverse)
202
+			if (!$reverse)
203 203
 			{
204 204
 				//error_log( "down $value $value < $neworder && $value > ".$array[$old_key]);
205
-				if(((int)$value < (int)$neworder && (int)$value > (int)$array[$old_key] && $key != $old_key) || ((int)$value > (int)$array[$old_key] && $next_key === false))
205
+				if (((int)$value < (int)$neworder && (int)$value > (int)$array[$old_key] && $key != $old_key) || ((int)$value > (int)$array[$old_key] && $next_key === false))
206 206
 				{
207 207
 					//error_log( "matching down $value");
208 208
 					$next_key = $key;
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
 			else
214 214
 			{
215 215
 				//error_log( "up $value $value > $neworder && $value < ".$array[$old_key]);
216
-				if(($value > $neworder && $value < $array[$old_key] && $key != $old_key) || ($value < $array[$old_key] && $next_key === false))
216
+				if (($value > $neworder && $value < $array[$old_key] && $key != $old_key) || ($value < $array[$old_key] && $next_key === false))
217 217
 				{
218 218
 					//error_log( "matching up $value");
219 219
 					$next_key = $key;
Please login to merge, or discard this patch.
Braces   +10 added lines, -3 removed lines patch added patch discarded remove patch
@@ -61,9 +61,13 @@  discard block
 block discarded – undo
61 61
 							(isset($row['app_icon'])?$row['app_icon']:'navbar');
62 62
 			//_debug_array($row);
63 63
 			if($i == 0)
64
-				$readonlys['up['.$row['app_id'].']'] = true;
64
+			{
65
+							$readonlys['up['.$row['app_id'].']'] = true;
66
+			}
65 67
 			if($i == count($rows) - 1)
66
-				$readonlys['down['.$row['app_id'].']'] = true;
68
+			{
69
+							$readonlys['down['.$row['app_id'].']'] = true;
70
+			}
67 71
 		}
68 72
 
69 73
 		return $total;
@@ -178,7 +182,10 @@  discard block
 block discarded – undo
178 182
 		$old_pos = $order[$app];
179 183
 		$next_app = $this->find_next_key($order,$app,$dir == -1);
180 184
 		$new_pos = $order[$next_app];
181
-		if ($new_pos == $old_pos) $new_pos= $new_pos + $dir;
185
+		if ($new_pos == $old_pos)
186
+		{
187
+			$new_pos= $new_pos + $dir;
188
+		}
182 189
 		$GLOBALS['egw']->db->update(self::TABLE,array('app_order' => $new_pos),array('app_id' => $app),__LINE__,__FILE__);
183 190
 		$order[$app] = $new_pos;
184 191
 		$GLOBALS['egw']->db->update(self::TABLE,array('app_order' => $old_pos),array('app_id' => $next_app),__LINE__,__FILE__);
Please login to merge, or discard this patch.
admin/inc/class.customfields.inc.php 4 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -614,7 +614,7 @@  discard block
 block discarded – undo
614 614
 	 * Validate and create a new content type
615 615
 	 *
616 616
 	 * @param array $content
617
-	 * @return string|boolean New type ID, or false for error
617
+	 * @return false|string New type ID, or false for error
618 618
 	 */
619 619
 	function create_content_type(&$content)
620 620
 	{
@@ -671,7 +671,7 @@  discard block
 block discarded – undo
671 671
 	*
672 672
 	* @deprecated use egw_customfields::get() direct, no need to instanciate this UI class
673 673
 	* @author Cornelius Weiss
674
-	* @param boolean $all_private_too=false should all the private fields be returned too
674
+	* @param boolean $all_private_too should all the private fields be returned too
675 675
 	* @return array with customfields
676 676
 	*/
677 677
 	function get_customfields($all_private_too=false)
Please login to merge, or discard this patch.
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -28,10 +28,10 @@  discard block
 block discarded – undo
28 28
 {
29 29
 
30 30
 	/**
31
-	* appname of app which want to add / edit its customfields
32
-	*
33
-	* @var string
34
-	*/
31
+	 * appname of app which want to add / edit its customfields
32
+	 *
33
+	 * @var string
34
+	 */
35 35
 	var $appname;
36 36
 
37 37
 	/**
@@ -40,10 +40,10 @@  discard block
 block discarded – undo
40 40
 	protected $use_private = false;
41 41
 
42 42
 	/**
43
-	* userdefiened types e.g. type of infolog
44
-	*
45
-	* @var array
46
-	*/
43
+	 * userdefiened types e.g. type of infolog
44
+	 *
45
+	 * @var array
46
+	 */
47 47
 	var $types2 = array();
48 48
 	var $content_types,$fields;
49 49
 
@@ -573,8 +573,8 @@  discard block
 block discarded – undo
573 573
 	}
574 574
 
575 575
 	/**
576
-	* deletes custom field from customfield definitions
577
-	*/
576
+	 * deletes custom field from customfield definitions
577
+	 */
578 578
 	function delete_field(&$content)
579 579
 	{
580 580
 		unset($this->fields[key($content['fields']['delete'])]);
@@ -591,8 +591,8 @@  discard block
 block discarded – undo
591 591
 	}
592 592
 
593 593
 	/**
594
-	* create a new custom field
595
-	*/
594
+	 * create a new custom field
595
+	 */
596 596
 	function create_field(&$content)
597 597
 	{
598 598
 		$new_name = trim($content['fields'][count($content['fields'])-1]['name']);
@@ -653,8 +653,8 @@  discard block
 block discarded – undo
653 653
 	}
654 654
 
655 655
 	/**
656
-	* save changes to repository
657
-	*/
656
+	 * save changes to repository
657
+	 */
658 658
 	function save_repository()
659 659
 	{
660 660
 		//echo '<p>uicustomfields::save_repository() \$this->fields=<pre style="text-aling: left;">'; print_r($this->fields); echo "</pre>\n";
@@ -667,25 +667,25 @@  discard block
 block discarded – undo
667 667
 	}
668 668
 
669 669
 	/**
670
-	* get customfields of using application
671
-	*
672
-	* @deprecated use egw_customfields::get() direct, no need to instanciate this UI class
673
-	* @author Cornelius Weiss
674
-	* @param boolean $all_private_too=false should all the private fields be returned too
675
-	* @return array with customfields
676
-	*/
670
+	 * get customfields of using application
671
+	 *
672
+	 * @deprecated use egw_customfields::get() direct, no need to instanciate this UI class
673
+	 * @author Cornelius Weiss
674
+	 * @param boolean $all_private_too=false should all the private fields be returned too
675
+	 * @return array with customfields
676
+	 */
677 677
 	function get_customfields($all_private_too=false)
678 678
 	{
679 679
 		return egw_customfields::get($this->appname,$all_private_too);
680 680
 	}
681 681
 
682 682
 	/**
683
-	* get_content_types of using application
684
-	*
685
-	* @deprecated use config::get_content_types() direct, no need to instanciate this UI class
686
-	* @author Cornelius Weiss
687
-	* @return array with content-types
688
-	*/
683
+	 * get_content_types of using application
684
+	 *
685
+	 * @deprecated use config::get_content_types() direct, no need to instanciate this UI class
686
+	 * @author Cornelius Weiss
687
+	 * @return array with content-types
688
+	 */
689 689
 	function get_content_types()
690 690
 	{
691 691
 		return config::get_content_types($this->appname);
Please login to merge, or discard this patch.
Spacing   +85 added lines, -86 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 	* @var array
46 46
 	*/
47 47
 	var $types2 = array();
48
-	var $content_types,$fields;
48
+	var $content_types, $fields;
49 49
 
50 50
 	/**
51 51
 	 * Currently selected content type (if used by app)
@@ -98,14 +98,14 @@  discard block
 block discarded – undo
98 98
 	 *
99 99
 	 * @param string $appname
100 100
 	 */
101
-	function __construct($appname='')
101
+	function __construct($appname = '')
102 102
 	{
103 103
 		if (($this->appname = $appname))
104 104
 		{
105
-			$this->fields = egw_customfields::get($this->appname,true);
105
+			$this->fields = egw_customfields::get($this->appname, true);
106 106
 			$this->content_types = config::get_content_types($this->appname);
107 107
 		}
108
-		$this->so = new so_sql('phpgwapi','egw_customfields',null,'',true);
108
+		$this->so = new so_sql('phpgwapi', 'egw_customfields', null, '', true);
109 109
 	}
110 110
 
111 111
 	/**
@@ -115,43 +115,43 @@  discard block
 block discarded – undo
115 115
 	{
116 116
 		// determine appname
117 117
 		$this->appname = $this->appname ? $this->appname : ($_GET['appname'] ? $_GET['appname'] : ($content['appname'] ? $content['appname'] : false));
118
-		if(!$this->appname) die(lang('Error! No appname found'));
118
+		if (!$this->appname) die(lang('Error! No appname found'));
119 119
 
120 120
 		$this->use_private = !isset($_GET['use_private']) || (boolean)$_GET['use_private'] || $content['use_private'];
121 121
 
122 122
 		// Read fields, constructor doesn't always know appname
123
-		$this->fields = egw_customfields::get($this->appname,true);
123
+		$this->fields = egw_customfields::get($this->appname, true);
124 124
 
125 125
 		$this->tmpl = new etemplate_new();
126 126
 		$this->tmpl->read('admin.customfields');
127 127
 
128 128
 		// do we manage content-types?
129 129
 		$test = new etemplate_new();
130
-		if($test->read($this->appname.'.admin.types')) $this->manage_content_types = true;
130
+		if ($test->read($this->appname.'.admin.types')) $this->manage_content_types = true;
131 131
 
132 132
 		// Handle incoming - types, options, etc.
133
-		if($this->manage_content_types)
133
+		if ($this->manage_content_types)
134 134
 		{
135
-			if(count($this->content_types) == 0)
135
+			if (count($this->content_types) == 0)
136 136
 			{
137 137
 				$this->content_types = config::get_content_types($this->appname);
138 138
 			}
139
-			if (count($this->content_types)==0)
139
+			if (count($this->content_types) == 0)
140 140
 			{
141 141
 				// if you define your default types of your app with the search_link hook, they are available here, if no types were found
142
-				$this->content_types = (array)egw_link::get_registry($this->appname,'default_types');
142
+				$this->content_types = (array)egw_link::get_registry($this->appname, 'default_types');
143 143
 			}
144 144
 			// Set this now, we need to know it for updates
145
-			$this->content_type = $content['content_types']['types'] ? $content['content_types']['types'] : (array_key_exists(0,$this->content_types) ? $this->content_types[0] : key($this->content_types));
145
+			$this->content_type = $content['content_types']['types'] ? $content['content_types']['types'] : (array_key_exists(0, $this->content_types) ? $this->content_types[0] : key($this->content_types));
146 146
 
147 147
 			// Common type changes - add, delete
148
-			if($content['content_types']['delete'])
148
+			if ($content['content_types']['delete'])
149 149
 			{
150 150
 				$this->delete_content_type($content);
151 151
 			}
152
-			elseif($content['content_types']['create'])
152
+			elseif ($content['content_types']['create'])
153 153
 			{
154
-				if($new_type = $this->create_content_type($content))
154
+				if ($new_type = $this->create_content_type($content))
155 155
 				{
156 156
 					$content['content_types']['types'] = $this->content_type = $new_type;
157 157
 				}
@@ -159,18 +159,18 @@  discard block
 block discarded – undo
159 159
 				unset($content['content_types']['name']);
160 160
 			}
161 161
 			// No common type change and type didn't change, try an update
162
-			elseif($this->content_type && is_array($content) && $this->content_type == $content['old_content_type'])
162
+			elseif ($this->content_type && is_array($content) && $this->content_type == $content['old_content_type'])
163 163
 			{
164 164
 				$this->update($content);
165 165
 			}
166 166
 		}
167 167
 
168 168
 		// Custom field deleted from nextmatch
169
-		if($content['nm']['action'] == 'delete')
169
+		if ($content['nm']['action'] == 'delete')
170 170
 		{
171
-			foreach($this->fields as $name => $data)
171
+			foreach ($this->fields as $name => $data)
172 172
 			{
173
-				if(in_array($data['id'],$content['nm']['selected']))
173
+				if (in_array($data['id'], $content['nm']['selected']))
174 174
 				{
175 175
 					unset($this->fields[$name]);
176 176
 				}
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 			$this->save_repository();
180 180
 		}
181 181
 
182
-		$content['nm']= $GLOBALS['egw']->session->appsession('customfield-index','admin');
182
+		$content['nm'] = $GLOBALS['egw']->session->appsession('customfield-index', 'admin');
183 183
 		if (!is_array($content['nm']))
184 184
 		{
185 185
 			// Initialize nextmatch
@@ -189,8 +189,8 @@  discard block
 block discarded – undo
189 189
 				'no_filter'      => 'true',
190 190
 				'no_filter2'     => 'true',
191 191
 				'row_id'         => 'cf_id',
192
-				'order'          =>	'cf_order',// IO name of the column to sort
193
-				'sort'           =>	'ASC',// IO direction of the sort: 'ASC' or 'DESC'
192
+				'order'          =>	'cf_order', // IO name of the column to sort
193
+				'sort'           =>	'ASC', // IO direction of the sort: 'ASC' or 'DESC'
194 194
 				'actions'        => $this->get_actions()
195 195
 			);
196 196
 		}
@@ -198,11 +198,11 @@  discard block
 block discarded – undo
198 198
 		$content['nm']['use_private'] = $this->use_private;
199 199
 
200 200
 		// Set up sub-types
201
-		if($this->manage_content_types)
201
+		if ($this->manage_content_types)
202 202
 		{
203
-			foreach($this->content_types as $type => $entry)
203
+			foreach ($this->content_types as $type => $entry)
204 204
 			{
205
-				if(!is_array($entry))
205
+				if (!is_array($entry))
206 206
 				{
207 207
 					$this->content_types[$type] = array('name' => $entry);
208 208
 					$entry = $this->content_types[$type];
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
 			}
212 212
 			$sel_options['types'] = $sel_options['cf_type2'] = $this->types2;
213 213
 
214
-			$content['type_template'] = $this->appname . '.admin.types';
214
+			$content['type_template'] = $this->appname.'.admin.types';
215 215
 			$content['content_types']['appname'] = $this->appname;
216 216
 			$content_types = array_keys($this->content_types);
217 217
 
@@ -253,15 +253,15 @@  discard block
 block discarded – undo
253 253
 		static::app_index($content, $sel_options, $readonlys, $preserve);
254 254
 
255 255
 		// Make sure app css gets loaded, extending app might cause et2 to miss it
256
-		egw_framework::includeCSS('admin','app');
256
+		egw_framework::includeCSS('admin', 'app');
257 257
 
258 258
 		$GLOBALS['egw_info']['flags']['app_header'] = $GLOBALS['egw_info']['apps'][$this->appname]['title'].' - '.lang('Custom fields');
259 259
 
260 260
 		// Some logic to make sure extending class (if there is one) gets called
261 261
 		// when etemplate2 comes back instead of parent class
262
-		$exec = get_class() == get_called_class() ? 'admin.customfields.index' : $this->appname . '.' . get_called_class() . '.index';
262
+		$exec = get_class() == get_called_class() ? 'admin.customfields.index' : $this->appname.'.'.get_called_class().'.index';
263 263
 
264
-		$this->tmpl->exec($exec,$content,$sel_options,$readonlys,$preserve);
264
+		$this->tmpl->exec($exec, $content, $sel_options, $readonlys, $preserve);
265 265
 	}
266 266
 
267 267
 	/**
@@ -276,28 +276,28 @@  discard block
 block discarded – undo
276 276
 
277 277
 		// determine appname
278 278
 		$this->appname = $this->appname ? $this->appname : ($_GET['appname'] ? $_GET['appname'] : ($content['cf_app'] ? $content['cf_app'] : false));
279
-		if(!$this->appname)
279
+		if (!$this->appname)
280 280
 		{
281
-			if($cf_id && $this->so)
281
+			if ($cf_id && $this->so)
282 282
 			{
283 283
 				$content = $this->so->read($cf_id);
284 284
 				$this->appname = $content['cf_app'];
285 285
 			}
286 286
 		}
287
-		if(!$this->appname)
287
+		if (!$this->appname)
288 288
 		{
289 289
 			die(lang('Error! No appname found'));
290 290
 		}
291 291
 		$this->use_private = !isset($_GET['use_private']) || (boolean)$_GET['use_private'] || $content['use_private'];
292 292
 
293 293
 		// Read fields, constructor doesn't always know appname
294
-		$this->fields = egw_customfields::get($this->appname,true);
294
+		$this->fields = egw_customfields::get($this->appname, true);
295 295
 
296 296
 		// Update based on info returned from template
297 297
 		if (is_array($content))
298 298
 		{
299 299
 			list($action) = @each($content['button']);
300
-			switch($action)
300
+			switch ($action)
301 301
 			{
302 302
 				case 'delete':
303 303
 					$this->so->delete($cf_id);
@@ -306,46 +306,46 @@  discard block
 block discarded – undo
306 306
 					break;
307 307
 				case 'save':
308 308
 				case 'apply':
309
-					if(!$cf_id && $this->fields[$content['cf_name']])
309
+					if (!$cf_id && $this->fields[$content['cf_name']])
310 310
 					{
311
-						egw_framework::message(lang("Field '%1' already exists !!!",$content['cf_name']),'error');
311
+						egw_framework::message(lang("Field '%1' already exists !!!", $content['cf_name']), 'error');
312 312
 						$content['cf_name'] = '';
313 313
 						break;
314 314
 					}
315
-					if(empty($content['cf_label']))
315
+					if (empty($content['cf_label']))
316 316
 					{
317 317
 						$content['cf_label'] = $content['cf_name'];
318 318
 					}
319 319
 					if (!empty($content['cf_values']))
320 320
 					{
321 321
 						$values = array();
322
-						if($content['cf_values'][0] === '@')
322
+						if ($content['cf_values'][0] === '@')
323 323
 						{
324
-							$values['@'] = substr($content['cf_values'], $content['cf_values'][1] === '=' ? 2:1);
324
+							$values['@'] = substr($content['cf_values'], $content['cf_values'][1] === '=' ? 2 : 1);
325 325
 						}
326 326
 						else
327 327
 						{
328
-							foreach(explode("\n",trim($content['cf_values'])) as $line)
328
+							foreach (explode("\n", trim($content['cf_values'])) as $line)
329 329
 							{
330
-								list($var,$value) = explode('=',trim($line),2);
330
+								list($var, $value) = explode('=', trim($line), 2);
331 331
 								$var = trim($var);
332
-								$values[$var] = trim($value)==='' ? $var : $value;
332
+								$values[$var] = trim($value) === '' ? $var : $value;
333 333
 							}
334 334
 						}
335 335
 						$content['cf_values'] = $values;
336 336
 					}
337 337
 					$update_content = array();
338
-					foreach($content as $key => $value)
338
+					foreach ($content as $key => $value)
339 339
 					{
340
-						if(substr($key,0,3) == 'cf_')
340
+						if (substr($key, 0, 3) == 'cf_')
341 341
 						{
342
-							$update_content[substr($key,3)] = $value;
342
+							$update_content[substr($key, 3)] = $value;
343 343
 						}
344 344
 					}
345 345
 					egw_customfields::update($update_content);
346
-					if(!$cf_id)
346
+					if (!$cf_id)
347 347
 					{
348
-						$this->fields = egw_customfields::get($this->appname,true);
348
+						$this->fields = egw_customfields::get($this->appname, true);
349 349
 						$cf_id = (int)$this->fields[$content['cf_name']]['id'];
350 350
 					}
351 351
 					egw_framework::refresh_opener('Saved', 'admin', $cf_id, 'edit');
@@ -366,30 +366,30 @@  discard block
 block discarded – undo
366 366
 
367 367
 		// do we manage content-types?
368 368
 		$test = new etemplate_new();
369
-		if($test->read($this->appname.'.admin.types')) $this->manage_content_types = true;
369
+		if ($test->read($this->appname.'.admin.types')) $this->manage_content_types = true;
370 370
 
371 371
 		$this->tmpl = new etemplate_new();
372 372
 		$this->tmpl->read('admin.customfield_edit');
373 373
 
374
-		translation::add_app('infolog');	// til we move the translations
374
+		translation::add_app('infolog'); // til we move the translations
375 375
 
376 376
 		$GLOBALS['egw_info']['flags']['app_header'] = $GLOBALS['egw_info']['apps'][$this->appname]['title'].' - '.lang('Custom fields');
377 377
 		$sel_options = array();
378 378
 		$readonlys = array();
379 379
 
380 380
 		//echo 'customfields=<pre style="text-align: left;">'; print_r($this->fields); echo "</pre>\n";
381
-		$content['cf_order'] = (count($this->fields)+1) * 10;
381
+		$content['cf_order'] = (count($this->fields) + 1) * 10;
382 382
 		$content['use_private'] = $this->use_private;
383 383
 
384
-		if($cf_id)
384
+		if ($cf_id)
385 385
 		{
386 386
 			$content = array_merge($content, $this->so->read($cf_id));
387 387
 			$this->appname = $content['cf_app'];
388
-			if($content['cf_private'])
388
+			if ($content['cf_private'])
389 389
 			{
390
-				$content['cf_private'] = explode(',',$content['cf_private']);
390
+				$content['cf_private'] = explode(',', $content['cf_private']);
391 391
 			}
392
-			if($content['cf_name'])
392
+			if ($content['cf_name'])
393 393
 			{
394 394
 				$readonlys['cf_name'] = true;
395 395
 			}
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
 		if (is_array($content['cf_values']))
403 403
 		{
404 404
 			$values = '';
405
-			foreach($content['cf_values'] as $var => $value)
405
+			foreach ($content['cf_values'] as $var => $value)
406 406
 			{
407 407
 				$values .= (!empty($values) ? "\n" : '').$var.'='.$value;
408 408
 			}
@@ -410,18 +410,18 @@  discard block
 block discarded – undo
410 410
 		}
411 411
 
412 412
 		// Show sub-type row, and get types
413
-		if($this->manage_content_types)
413
+		if ($this->manage_content_types)
414 414
 		{
415
-			if(count($this->content_types) == 0)
415
+			if (count($this->content_types) == 0)
416 416
 			{
417 417
 				$this->content_types = config::get_content_types($this->appname);
418 418
 			}
419
-			if (count($this->content_types)==0)
419
+			if (count($this->content_types) == 0)
420 420
 			{
421 421
 				// if you define your default types of your app with the search_link hook, they are available here, if no types were found
422
-				$this->content_types = (array)egw_link::get_registry($this->appname,'default_types');
422
+				$this->content_types = (array)egw_link::get_registry($this->appname, 'default_types');
423 423
 			}
424
-			foreach($this->content_types as $type => $entry)
424
+			foreach ($this->content_types as $type => $entry)
425 425
 			{
426 426
 				$this->types2[$type] = is_array($entry) ? $entry['name'] : $entry;
427 427
 			}
@@ -433,19 +433,19 @@  discard block
 block discarded – undo
433 433
 		}
434 434
 
435 435
 		// Include type-specific value help
436
-		foreach(self::$type_option_help as $key => $value)
436
+		foreach (self::$type_option_help as $key => $value)
437 437
 		{
438 438
 			$content['options'][$key] = lang($value);
439 439
 		}
440 440
 		$content['statustext'] = $content['options'][$content['cf_type']];
441 441
 		$content['attributes'] = self::$type_attribute_flags;
442 442
 
443
-		$this->tmpl->exec('admin.customfields.edit',$content,$sel_options,$readonlys,array(
443
+		$this->tmpl->exec('admin.customfields.edit', $content, $sel_options, $readonlys, array(
444 444
 			'cf_id' => $cf_id,
445 445
 			'cf_app' => $this->appname,
446 446
 			'cf_name' => $content['cf_name'],
447 447
 			'use_private' => $this->use_private,
448
-		),2);
448
+		), 2);
449 449
 	}
450 450
 
451 451
 	/**
@@ -473,7 +473,7 @@  discard block
 block discarded – undo
473 473
 				'allowOnMultiple' => false,
474 474
 				'url' => 'menuaction=admin.customfields.edit&cf_id=$id&use_private='.$this->use_private,
475 475
 				'popup' => '500x380',
476
-				'group' => $group=1,
476
+				'group' => $group = 1,
477 477
 				'disableClass' => 'th',
478 478
 			),
479 479
 			'add' => array(
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
 
496 496
 	function update_fields(&$content)
497 497
 	{
498
-		foreach($content['fields'] as $field)
498
+		foreach ($content['fields'] as $field)
499 499
 		{
500 500
 			$name = trim($field['name']);
501 501
 			$old_name = $field['old_name'];
@@ -524,9 +524,9 @@  discard block
 block discarded – undo
524 524
 			$values = array();
525 525
 			if (!empty($field['values']))
526 526
 			{
527
-				foreach(explode("\n",$field['values']) as $line)
527
+				foreach (explode("\n", $field['values']) as $line)
528 528
 				{
529
-					list($var,$value) = explode('=',trim($line),2);
529
+					list($var, $value) = explode('=', trim($line), 2);
530 530
 					$var = trim($var);
531 531
 					$values[$var] = empty($value) ? $var : $value;
532 532
 				}
@@ -543,22 +543,22 @@  discard block
 block discarded – undo
543 543
 				'private' => $field['private'],
544 544
 				'needed' => $field['needed'],
545 545
 			);
546
-			if(!$this->fields[$name]['type2'] && $this->manage_content_types)
546
+			if (!$this->fields[$name]['type2'] && $this->manage_content_types)
547 547
 			{
548 548
 				$this->fields[$name]['type2'] = (string)0;
549 549
 			}
550 550
 		}
551 551
 		if (!function_exists('sort_by_order'))
552 552
 		{
553
-			function sort_by_order($arr1,$arr2)
553
+			function sort_by_order($arr1, $arr2)
554 554
 			{
555 555
 				return $arr1['order'] - $arr2['order'];
556 556
 			}
557 557
 		}
558
-		uasort($this->fields,sort_by_order);
558
+		uasort($this->fields, sort_by_order);
559 559
 
560 560
 		$n = 0;
561
-		foreach($this->fields as $name => $data)
561
+		foreach ($this->fields as $name => $data)
562 562
 		{
563 563
 			$this->fields[$name]['order'] = ($n += 10);
564 564
 		}
@@ -595,17 +595,16 @@  discard block
 block discarded – undo
595 595
 	*/
596 596
 	function create_field(&$content)
597 597
 	{
598
-		$new_name = trim($content['fields'][count($content['fields'])-1]['name']);
598
+		$new_name = trim($content['fields'][count($content['fields']) - 1]['name']);
599 599
 		if (empty($new_name) || isset($this->fields[$new_name]))
600 600
 		{
601 601
 			$content['error_msg'] .= empty($new_name) ?
602
-				lang('You have to enter a name, to create a new field!!!') :
603
-				lang("Field '%1' already exists !!!",$new_name);
602
+				lang('You have to enter a name, to create a new field!!!') : lang("Field '%1' already exists !!!", $new_name);
604 603
 		}
605 604
 		else
606 605
 		{
607
-			$this->fields[$new_name] = $content['fields'][count($content['fields'])-1];
608
-			if(!$this->fields[$new_name]['label']) $this->fields[$new_name]['label'] = $this->fields[$new_name]['name'];
606
+			$this->fields[$new_name] = $content['fields'][count($content['fields']) - 1];
607
+			if (!$this->fields[$new_name]['label']) $this->fields[$new_name]['label'] = $this->fields[$new_name]['name'];
609 608
 			$this->save_repository();
610 609
 		}
611 610
 	}
@@ -622,20 +621,20 @@  discard block
 block discarded – undo
622 621
 		$new_type = false;
623 622
 		if (empty($new_name))
624 623
 		{
625
-			$this->tmpl->set_validation_error('content_types[name]','You have to enter a name, to create a new type!!!');
624
+			$this->tmpl->set_validation_error('content_types[name]', 'You have to enter a name, to create a new type!!!');
626 625
 		}
627 626
 		else
628 627
 		{
629
-			foreach($this->content_types as $letter => $type)
628
+			foreach ($this->content_types as $letter => $type)
630 629
 			{
631
-				if($type['name'] == $new_name)
630
+				if ($type['name'] == $new_name)
632 631
 				{
633
-					$this->tmpl->set_validation_error('content_types[name]',lang("type '%1' already exists !!!",$new_name));
632
+					$this->tmpl->set_validation_error('content_types[name]', lang("type '%1' already exists !!!", $new_name));
634 633
 					return false;
635 634
 				}
636 635
 			}
637 636
 			// search free type character
638
-			for($i=97;$i<=122;$i++)
637
+			for ($i = 97; $i <= 122; $i++)
639 638
 			{
640 639
 				if (!$this->content_types[chr($i)] &&
641 640
 					// skip letter of deleted type for addressbook content-types, as it gives SQL error
@@ -660,7 +659,7 @@  discard block
 block discarded – undo
660 659
 		//echo '<p>uicustomfields::save_repository() \$this->fields=<pre style="text-aling: left;">'; print_r($this->fields); echo "</pre>\n";
661 660
 		$config = new config($this->appname);
662 661
 		$config->read_repository();
663
-		$config->value('types',$this->content_types);
662
+		$config->value('types', $this->content_types);
664 663
 		$config->save_repository();
665 664
 
666 665
 		egw_customfields::save($this->appname, $this->fields);
@@ -674,9 +673,9 @@  discard block
 block discarded – undo
674 673
 	* @param boolean $all_private_too=false should all the private fields be returned too
675 674
 	* @return array with customfields
676 675
 	*/
677
-	function get_customfields($all_private_too=false)
676
+	function get_customfields($all_private_too = false)
678 677
 	{
679
-		return egw_customfields::get($this->appname,$all_private_too);
678
+		return egw_customfields::get($this->appname, $all_private_too);
680 679
 	}
681 680
 
682 681
 	/**
@@ -702,13 +701,13 @@  discard block
 block discarded – undo
702 701
 		$total = $this->so->get_rows($query, $rows, $readonlys);
703 702
 		unset($query['col_filter']['cf_app']);
704 703
 
705
-		foreach($rows as &$row)
704
+		foreach ($rows as &$row)
706 705
 		{
707 706
 			$row['cf_values'] = json_decode($row['cf_values'], true);
708 707
 			if (is_array($row['cf_values']))
709 708
 			{
710 709
 				$values = '';
711
-				foreach($row['cf_values'] as $var => $value)
710
+				foreach ($row['cf_values'] as $var => $value)
712 711
 				{
713 712
 					$values .= (!empty($values) ? "\n" : '').$var.'='.$value;
714 713
 				}
Please login to merge, or discard this patch.
Braces   +28 added lines, -7 removed lines patch added patch discarded remove patch
@@ -115,7 +115,10 @@  discard block
 block discarded – undo
115 115
 	{
116 116
 		// determine appname
117 117
 		$this->appname = $this->appname ? $this->appname : ($_GET['appname'] ? $_GET['appname'] : ($content['appname'] ? $content['appname'] : false));
118
-		if(!$this->appname) die(lang('Error! No appname found'));
118
+		if(!$this->appname)
119
+		{
120
+			die(lang('Error! No appname found'));
121
+		}
119 122
 
120 123
 		$this->use_private = !isset($_GET['use_private']) || (boolean)$_GET['use_private'] || $content['use_private'];
121 124
 
@@ -127,7 +130,10 @@  discard block
 block discarded – undo
127 130
 
128 131
 		// do we manage content-types?
129 132
 		$test = new etemplate_new();
130
-		if($test->read($this->appname.'.admin.types')) $this->manage_content_types = true;
133
+		if($test->read($this->appname.'.admin.types'))
134
+		{
135
+			$this->manage_content_types = true;
136
+		}
131 137
 
132 138
 		// Handle incoming - types, options, etc.
133 139
 		if($this->manage_content_types)
@@ -366,7 +372,10 @@  discard block
 block discarded – undo
366 372
 
367 373
 		// do we manage content-types?
368 374
 		$test = new etemplate_new();
369
-		if($test->read($this->appname.'.admin.types')) $this->manage_content_types = true;
375
+		if($test->read($this->appname.'.admin.types'))
376
+		{
377
+			$this->manage_content_types = true;
378
+		}
370 379
 
371 380
 		$this->tmpl = new etemplate_new();
372 381
 		$this->tmpl->read('admin.customfield_edit');
@@ -507,20 +516,29 @@  discard block
 block discarded – undo
507 516
 			}
508 517
 			if (isset($field['old_name']))
509 518
 			{
510
-				if (empty($name))	// empty name not allowed
519
+				if (empty($name))
520
+				{
521
+					// empty name not allowed
511 522
 				{
512 523
 					$content['error_msg'] = lang('Name must not be empty !!!');
524
+				}
513 525
 					$name = $old_name;
514 526
 				}
515
-				if (!empty($name) && $old_name != $name)	// renamed
527
+				if (!empty($name) && $old_name != $name)
528
+				{
529
+					// renamed
516 530
 				{
517 531
 					unset($this->fields[$old_name]);
518 532
 				}
533
+				}
519 534
 			}
520
-			elseif (empty($name))		// new item and empty ==> ignore it
535
+			elseif (empty($name))
536
+			{
537
+				// new item and empty ==> ignore it
521 538
 			{
522 539
 				continue;
523 540
 			}
541
+			}
524 542
 			$values = array();
525 543
 			if (!empty($field['values']))
526 544
 			{
@@ -605,7 +623,10 @@  discard block
 block discarded – undo
605 623
 		else
606 624
 		{
607 625
 			$this->fields[$new_name] = $content['fields'][count($content['fields'])-1];
608
-			if(!$this->fields[$new_name]['label']) $this->fields[$new_name]['label'] = $this->fields[$new_name]['name'];
626
+			if(!$this->fields[$new_name]['label'])
627
+			{
628
+				$this->fields[$new_name]['label'] = $this->fields[$new_name]['name'];
629
+			}
609 630
 			$this->save_repository();
610 631
 		}
611 632
 	}
Please login to merge, or discard this patch.
calendar/inc/class.calendar_activesync.inc.php 4 patches
Doc Comments   +10 added lines, -11 removed lines patch added patch discarded remove patch
@@ -171,8 +171,8 @@  discard block
 block discarded – undo
171 171
 	 * will work OK apart from that.
172 172
 	 *
173 173
 	 * @param string $id folder id
174
-	 * @param int $cutoffdate=null
175
-	 * @param array $not_uids=null uids NOT to return for meeting requests
174
+	 * @param int $cutoffdate
175
+	 * @param array $not_uids uids NOT to return for meeting requests
176 176
 	 * @return array
177 177
   	 */
178 178
 	function GetMessageList($id, $cutoffdate=NULL, array $not_uids=null)
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 	 * List all meeting requests / invitations of user NOT having a UID in $not_uids (already received by email)
224 224
 	 *
225 225
 	 * @param array $not_uids
226
-	 * @param int $cutoffdate=null
226
+	 * @param int $cutoffdate
227 227
 	 * @return array
228 228
 	 */
229 229
 	function GetMeetingRequests(array $not_uids, $cutoffdate=NULL)
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
 	 * @param int $truncsize
267 267
 	 * @param int $bodypreference
268 268
 	 * @param $optionbodypreference
269
-	 * @param bool $mimesupport
269
+	 * @param integer $mimesupport
270 270
 	 * @return SyncMail
271 271
 	 */
272 272
 	function GetMeetingRequest($id, $truncsize, $bodypreference=false, $optionbodypreference=false, $mimesupport = 0)
@@ -607,7 +607,6 @@  discard block
 block discarded – undo
607 607
 	 *
608 608
 	 * @param SyncAppointment $message
609 609
 	 * @param int $account
610
-	 * @param array $event=array()
611 610
 	 * @return array
612 611
 	 */
613 612
 	private function message2event(SyncAppointment $message, $account, $event=array())
@@ -855,7 +854,7 @@  discard block
 block discarded – undo
855 854
 	 * @param string $displayname => new folder name (to be created, or to be renamed to)
856 855
 	 * @param string $type folder type, ignored in IMAP
857 856
 	 *
858
-	 * @return array|boolean stat array or false on error
857
+	 * @return boolean stat array or false on error
859 858
 	 */
860 859
 	public function ChangeFolder($id, $oldid, $displayname, $type)
861 860
 	{
@@ -870,7 +869,7 @@  discard block
 block discarded – undo
870 869
 	 * @param string $id of the folder to delete
871 870
 	 *
872 871
 	 * @return
873
-	 * @TODO check what is to be returned
872
+	 boolean @TODO check what is to be returned
874 873
 	 */
875 874
 	public function DeleteFolder($parentid, $id)
876 875
 	{
@@ -958,9 +957,9 @@  discard block
 block discarded – undo
958 957
 	 * @param string $folderid
959 958
 	 * @param string|array $id cal_id or event array (used internally)
960 959
 	 * @param int $truncsize
961
-	 * @param int|bool $bodypreference=false
960
+	 * @param int|bool $bodypreference
962 961
 	 * @param $optionbodypreference=false
963
-	 * @param int $mimesupport=0
962
+	 * @param int $mimesupport
964 963
 	 * @return SyncAppointment|boolean false on error
965 964
 	 */
966 965
 	public function GetMessage($folderid, $id, $truncsize, $bodypreference=false, $optionbodypreference=false, $mimesupport = 0)
@@ -1303,7 +1302,6 @@  discard block
 block discarded – undo
1303 1302
 	 * matching timezones for incomming timezone data. iPhone seems not to care on receiving about the above.
1304 1303
 	 *
1305 1304
 	 * @param string|DateTimeZone $tz timezone, timezone name (eg. "Europe/Berlin") or ical with VTIMEZONE
1306
-	 * @param int|string|DateTime $ts=null time for which active sync timezone data is requested, default current time
1307 1305
 	 * @return array with values for keys:
1308 1306
 	 * - "bias": timezone offset from UTC in minutes for NO DST
1309 1307
 	 * - "dstendmonth", "dstendday", "dstendweek", "dstendhour", "dstendminute", "dstendsecond", "dstendmillis"
@@ -1468,7 +1466,7 @@  discard block
 block discarded – undo
1468 1466
 	 * )
1469 1467
 	 *
1470 1468
 	 * @param string|array $ical lines of ical file
1471
-	 * @param string $component=null
1469
+	 * @param string $component
1472 1470
 	 * @return array with parsed ical components
1473 1471
 	 */
1474 1472
 	static public function ical2array(&$ical,$component=null)
@@ -1542,6 +1540,7 @@  discard block
 block discarded – undo
1542 1540
 	 * Unpack timezone info from Sync
1543 1541
 	 *
1544 1542
 	 * copied from backend/ics.php
1543
+	 * @param string $data
1545 1544
 	 */
1546 1545
 	static public function _getTZFromSyncBlob($data)
1547 1546
 	{
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -177,7 +177,7 @@
 block discarded – undo
177 177
 	 * @param int $cutoffdate =null
178 178
 	 * @param array $not_uids =null uids NOT to return for meeting requests
179 179
 	 * @return array
180
-  	 */
180
+	 */
181 181
 	function GetMessageList($id, $cutoffdate=NULL, array $not_uids=null)
182 182
 	{
183 183
 		if (!isset($this->calendar)) $this->calendar = new calendar_boupdate();
Please login to merge, or discard this patch.
Spacing   +182 added lines, -183 removed lines patch added patch discarded remove patch
@@ -81,20 +81,20 @@  discard block
 block discarded – undo
81 81
 		if (!isset($this->calendar)) $this->calendar = new calendar_boupdate();
82 82
 
83 83
 		$cals = $GLOBALS['egw_info']['user']['preferences']['activesync']['calendar-cals'];
84
-		$cals = $cals ? explode(',',$cals) : array('P');	// implicit default of 'P'
84
+		$cals = $cals ? explode(',', $cals) : array('P'); // implicit default of 'P'
85 85
 		$folderlist = array();
86 86
 
87 87
 		foreach ($this->calendar->list_cals() as $entry)
88 88
 		{
89 89
 			$account_id = $entry['grantor'];
90 90
 			$label = $entry['name'];
91
-			if (in_array('A',$cals) || in_array($account_id,$cals) ||
92
-				$account_id == $GLOBALS['egw_info']['user']['account_id'] ||	// always incl. own calendar!
93
-				$account_id == $GLOBALS['egw_info']['user']['account_primary_group'] && in_array('G',$cals))
91
+			if (in_array('A', $cals) || in_array($account_id, $cals) ||
92
+				$account_id == $GLOBALS['egw_info']['user']['account_id'] || // always incl. own calendar!
93
+				$account_id == $GLOBALS['egw_info']['user']['account_primary_group'] && in_array('G', $cals))
94 94
 			{
95 95
 				$folderlist[] = $f = array(
96
-					'id'	=>	$this->backend->createID('calendar',$account_id),
97
-					'mod'	=>	$GLOBALS['egw']->accounts->id2name($account_id,'account_fullname'),
96
+					'id'	=>	$this->backend->createID('calendar', $account_id),
97
+					'mod'	=>	$GLOBALS['egw']->accounts->id2name($account_id, 'account_fullname'),
98 98
 					'parent'=>	'0',
99 99
 				);
100 100
 			}
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 		$folderObj = new SyncFolder();
118 118
 		$folderObj->serverid = $id;
119 119
 		$folderObj->parentid = '0';
120
-		$folderObj->displayname = $GLOBALS['egw']->accounts->id2name($owner,'account_fullname');
120
+		$folderObj->displayname = $GLOBALS['egw']->accounts->id2name($owner, 'account_fullname');
121 121
 		if ($owner == $GLOBALS['egw_info']['user']['account_id'])
122 122
 		{
123 123
 			$folderObj->type = SYNC_FOLDER_TYPE_APPOINTMENT;
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 
152 152
 		$stat = array(
153 153
 			'id'	 => $id,
154
-			'mod'	=> $GLOBALS['egw']->accounts->id2name($owner,'account_fullname'),
154
+			'mod'	=> $GLOBALS['egw']->accounts->id2name($owner, 'account_fullname'),
155 155
 			'parent' => '0',
156 156
 		);
157 157
 		//error_log(__METHOD__."('$id') folderObj=".array2string($stat));
@@ -175,18 +175,18 @@  discard block
 block discarded – undo
175 175
 	 * @param array $not_uids=null uids NOT to return for meeting requests
176 176
 	 * @return array
177 177
   	 */
178
-	function GetMessageList($id, $cutoffdate=NULL, array $not_uids=null)
178
+	function GetMessageList($id, $cutoffdate = NULL, array $not_uids = null)
179 179
 	{
180 180
 		if (!isset($this->calendar)) $this->calendar = new calendar_boupdate();
181 181
 
182
-		debugLog (__METHOD__."('$id',$cutoffdate)");
183
-		$this->backend->splitID($id,$type,$user);
182
+		debugLog(__METHOD__."('$id',$cutoffdate)");
183
+		$this->backend->splitID($id, $type, $user);
184 184
 
185
-		if (!$cutoffdate) $cutoffdate = $this->bo->now - 100*24*3600;	// default three month back -30 breaks all sync recurrences
185
+		if (!$cutoffdate) $cutoffdate = $this->bo->now - 100 * 24 * 3600; // default three month back -30 breaks all sync recurrences
186 186
 
187 187
 		$filter = array(
188 188
 			'users' => $user,
189
-			'start' => $cutoffdate,	// default one month back -30 breaks all sync recurrences
189
+			'start' => $cutoffdate, // default one month back -30 breaks all sync recurrences
190 190
 			'enum_recuring' => false,
191 191
 			'daywise' => false,
192 192
 			'date_format' => 'server',
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 			'filter' => $user == $GLOBALS['egw_info']['user']['account_id'] ? (is_array($not_uids) ? 'unknown' : 'default') : 'default',
196 196
 			// @todo return only etag relevant information (seems not to work ...)
197 197
 			//'cols'		=> array('egw_cal.cal_id', 'cal_start',	'recur_type', 'cal_modified', 'cal_uid', 'cal_etag'),
198
-			'query' => array('cal_recurrence' => 0),	// do NOT return recurrence exceptions
198
+			'query' => array('cal_recurrence' => 0), // do NOT return recurrence exceptions
199 199
 		);
200 200
 
201 201
 		$messagelist = array();
@@ -226,14 +226,14 @@  discard block
 block discarded – undo
226 226
 	 * @param int $cutoffdate=null
227 227
 	 * @return array
228 228
 	 */
229
-	function GetMeetingRequests(array $not_uids, $cutoffdate=NULL)
229
+	function GetMeetingRequests(array $not_uids, $cutoffdate = NULL)
230 230
 	{
231
-return array();	// temporary disabling meeting requests from calendar
232
-		$folderid = $this->backend->createID('calendar', $GLOBALS['egw_info']['user']['account_id']);	// users personal calendar
231
+return array(); // temporary disabling meeting requests from calendar
232
+		$folderid = $this->backend->createID('calendar', $GLOBALS['egw_info']['user']['account_id']); // users personal calendar
233 233
 
234 234
 		$ret = $this->GetMessageList($folderid, $cutoffdate, $not_uids);
235 235
 		// return all id's negative to not conflict with uids from fmail
236
-		foreach($ret as &$message)
236
+		foreach ($ret as &$message)
237 237
 		{
238 238
 			$message['id'] = -$message['id'];
239 239
 		}
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 	 */
251 251
 	function StatMeetingRequest($id)
252 252
 	{
253
-		$folderid = $this->backend->createID('calendar', $GLOBALS['egw_info']['user']['account_id']);	// users personal calendar
253
+		$folderid = $this->backend->createID('calendar', $GLOBALS['egw_info']['user']['account_id']); // users personal calendar
254 254
 
255 255
 		$ret = $this->StatMessage($folderid, abs($id));
256 256
 		$ret['id'] = $id;
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 	 * @param bool $mimesupport
270 270
 	 * @return SyncMail
271 271
 	 */
272
-	function GetMeetingRequest($id, $truncsize, $bodypreference=false, $optionbodypreference=false, $mimesupport = 0)
272
+	function GetMeetingRequest($id, $truncsize, $bodypreference = false, $optionbodypreference = false, $mimesupport = 0)
273 273
 	{
274 274
 		if (!isset($this->calendar)) $this->calendar = new calendar_boupdate();
275 275
 
@@ -282,13 +282,13 @@  discard block
 block discarded – undo
282 282
 			$message = new SyncMail();
283 283
 			$message->read = false;
284 284
 			$message->subject = $event['title'];
285
-			$message->importance = 1;	// 0=Low, 1=Normal, 2=High
285
+			$message->importance = 1; // 0=Low, 1=Normal, 2=High
286 286
 			$message->datereceived = $event['created'];
287 287
 			$message->to = $message->displayto = $GLOBALS['egw_info']['user']['account_email'];
288
-			$message->from = $GLOBALS['egw']->accounts->id2name($event['owner'],'account_fullname').
289
-				' <'.$GLOBALS['egw']->accounts->id2name($event['owner'],'account_email').'>';
288
+			$message->from = $GLOBALS['egw']->accounts->id2name($event['owner'], 'account_fullname').
289
+				' <'.$GLOBALS['egw']->accounts->id2name($event['owner'], 'account_email').'>';
290 290
 			$message->internetcpid = 65001;
291
-			$message->contentclass="urn:content-classes:message";
291
+			$message->contentclass = "urn:content-classes:message";
292 292
 
293 293
 			$message->meetingrequest = self::meetingRequest($event);
294 294
 			$message->messageclass = "IPM.Schedule.Meeting.Request";
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
 			else
304 304
 			{
305 305
 				$message->airsyncbasebody = new SyncAirSyncBaseBody();
306
-				$message->airsyncbasenativebodytype=1;
306
+				$message->airsyncbasenativebodytype = 1;
307 307
 				$this->backend->note2messagenote($event['description'], $bodypreference, $message->airsyncbasebody);
308 308
 			}
309 309
 		}
@@ -338,11 +338,11 @@  discard block
 block discarded – undo
338 338
 			$as_tz = self::tz2as($event['tzid']);
339 339
 			$message->timezone = base64_encode(calendar_activesync::_getSyncBlobFromTZ($as_tz));
340 340
 		}
341
-		catch(Exception $e) {
341
+		catch (Exception $e) {
342 342
 			// ignore exception, simply set no timezone, as it is optional
343 343
 		}
344 344
 		// copying timestamps (they are already read in servertime, so non tz conversation)
345
-		foreach(array(
345
+		foreach (array(
346 346
 			'start' => 'starttime',
347 347
 			'end'   => 'endtime',
348 348
 			'created' => 'dtstamp',
@@ -352,10 +352,10 @@  discard block
 block discarded – undo
352 352
 		}
353 353
 		if (($message->alldayevent = (int)calendar_bo::isWholeDay($event)))
354 354
 		{
355
-			++$message->endtime;	// EGw all-day-events are 1 sec shorter!
355
+			++$message->endtime; // EGw all-day-events are 1 sec shorter!
356 356
 		}
357 357
 		// copying strings
358
-		foreach(array(
358
+		foreach (array(
359 359
 			'title' => 'subject',
360 360
 			'location' => 'location',
361 361
 		) as $key => $attr)
@@ -364,16 +364,16 @@  discard block
 block discarded – undo
364 364
 		}
365 365
 		$message->organizer = $event['organizer'];
366 366
 
367
-		$message->sensitivity = $event['public'] ? 0 : 2;	// 0=normal, 1=personal, 2=private, 3=confidential
367
+		$message->sensitivity = $event['public'] ? 0 : 2; // 0=normal, 1=personal, 2=private, 3=confidential
368 368
 
369 369
 		// busystatus=(0=free|1=tentative|2=busy|3=out-of-office), EGw has non_blocking=0|1
370 370
 		$message->busystatus = $event['non_blocking'] ? 0 : 2;
371 371
 
372 372
 		// ToDo: recurring events: InstanceType, RecurrenceId, Recurrences; ...
373
-		$message->instancetype = 0;	// 0=Single, 1=Master recurring, 2=Single recuring, 3=Exception
373
+		$message->instancetype = 0; // 0=Single, 1=Master recurring, 2=Single recuring, 3=Exception
374 374
 
375
-		$message->responserequested = 1;	//0=No, 1=Yes
376
-		$message->disallownewtimeproposal = 1;	//1=forbidden, 0=allowed
375
+		$message->responserequested = 1; //0=No, 1=Yes
376
+		$message->disallownewtimeproposal = 1; //1=forbidden, 0=allowed
377 377
 		//$message->messagemeetingtype;	// email2
378 378
 
379 379
 		// ToDo: alarme: Reminder
@@ -419,14 +419,14 @@  discard block
 block discarded – undo
419 419
 			// check if event already exist (invitation of or already imported by other user)
420 420
 			if (!($event = $this->calendar->read($parsed_event['uid'], 0, false, 'server')))
421 421
 			{
422
-				$event = $parsed_event;	// create new event from external invitation
422
+				$event = $parsed_event; // create new event from external invitation
423 423
 			}
424
-			elseif(!isset($event['participants'][$uid]))
424
+			elseif (!isset($event['participants'][$uid]))
425 425
 			{
426 426
 				debugLog(__METHOD__.'('.array2string($requestid).", $folderid, $response) current user ($uid) is NO participant of event ".array2string($event));
427 427
 				// maybe we should silently add him, as he might not have the rights to add him himself with calendar->update ...
428 428
 			}
429
-			elseif($event['deleted'])
429
+			elseif ($event['deleted'])
430 430
 			{
431 431
 				debugLog(__METHOD__.'('.array2string($requestid).", $folderid, $response) event ($uid) deleted on server --> return false");
432 432
 				return false;
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
 		}
440 440
 		// keep role and quantity as AS has no idea about it
441 441
 		calendar_so::split_status($event['participants'][$uid], $quantity, $role);
442
-		$status = calendar_so::combine_status($status,$quantity,$role);
442
+		$status = calendar_so::combine_status($status, $quantity, $role);
443 443
 
444 444
 		if ($event['id'] && isset($event['participants'][$uid]))
445 445
 		{
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
 		else
449 449
 		{
450 450
 			$event['participants'][$uid] = $status;
451
-			$ret = $this->calendar->update($event, true);	// true = ignore conflicts, as there seems no conflict handling in AS
451
+			$ret = $this->calendar->update($event, true); // true = ignore conflicts, as there seems no conflict handling in AS
452 452
 		}
453 453
 		debugLog(__METHOD__.'('.array2string($requestid).", '$folderid', $response) returning ".array2string($ret));
454 454
 		return $ret;
@@ -460,10 +460,10 @@  discard block
 block discarded – undo
460 460
 	 * @var array
461 461
 	 */
462 462
 	static $status2as = array(
463
-		'U' => 0,	// unknown
464
-		'T' => 2,	// tentative
465
-		'A' => 3,	// accepted
466
-		'R' => 4,	// decline
463
+		'U' => 0, // unknown
464
+		'T' => 2, // tentative
465
+		'A' => 3, // accepted
466
+		'R' => 4, // decline
467 467
 		// 5 = not responded
468 468
 	);
469 469
 	/**
@@ -472,9 +472,9 @@  discard block
 block discarded – undo
472 472
 	 * @var array
473 473
 	 */
474 474
 	static $role2as = array(
475
-		'REQ-PARTICIPANT' => 1,	// required
476
-		'CHAIR' => 1,			// required
477
-		'OPT-PARTICIPANT' => 2,	// optional
475
+		'REQ-PARTICIPANT' => 1, // required
476
+		'CHAIR' => 1, // required
477
+		'OPT-PARTICIPANT' => 2, // optional
478 478
 		'NON-PARTICIPANT' => 2,
479 479
 		// 3 = ressource
480 480
 	);
@@ -486,8 +486,8 @@  discard block
 block discarded – undo
486 486
 	static $recur_type2as = array(
487 487
 		calendar_rrule::DAILY => 0,
488 488
 		calendar_rrule::WEEKLY => 1,
489
-		calendar_rrule::MONTHLY_MDAY => 2,	// monthly
490
-		calendar_rrule::MONTHLY_WDAY => 3,	// monthly on nth day
489
+		calendar_rrule::MONTHLY_MDAY => 2, // monthly
490
+		calendar_rrule::MONTHLY_WDAY => 3, // monthly on nth day
491 491
 		calendar_rrule::YEARLY => 5,
492 492
 		// 6 = yearly on nth day (same as 5 on non-leapyears or before March on leapyears)
493 493
 	);
@@ -518,9 +518,9 @@  discard block
 block discarded – undo
518 518
 		$event = array();
519 519
 		$this->backend->splitID($folderid, $type, $account);
520 520
 
521
-		debugLog (__METHOD__."('$folderid', $id, ".array2string($message).") type='$type', account=$account");
521
+		debugLog(__METHOD__."('$folderid', $id, ".array2string($message).") type='$type', account=$account");
522 522
 
523
-		list($id,$recur_date) = explode(':',$id);
523
+		list($id, $recur_date) = explode(':', $id);
524 524
 
525 525
 		if ($type != 'calendar' || $id && !($event = $this->calendar->read($id, $recur_date, false, 'server')))
526 526
 		{
@@ -533,25 +533,25 @@  discard block
 block discarded – undo
533 533
 			debugLog(__METHOD__."('$folderid',$id:$recur_date,".array2string($message).") handling of virtual exception not yet implemented!");
534 534
 			error_log(__METHOD__."('$folderid',$id:$recur_date,".array2string($message).") handling of virtual exception not yet implemented!");
535 535
 		}
536
-		if (!$this->calendar->check_perms($id ? EGW_ACL_EDIT : EGW_ACL_ADD,$event ? $event : 0,$account))
536
+		if (!$this->calendar->check_perms($id ? EGW_ACL_EDIT : EGW_ACL_ADD, $event ? $event : 0, $account))
537 537
 		{
538 538
 			// @todo: write in users calendar and make account only a participant
539 539
 			debugLog(__METHOD__."('$folderid',$id,...) no rights to add/edit event!");
540 540
 			error_log(__METHOD__."('$folderid',$id,".array2string($message).") no rights to add/edit event!");
541 541
 			return false;
542 542
 		}
543
-		if (!$id) $event['owner'] = $account;	// we do NOT allow to change the owner of existing events
543
+		if (!$id) $event['owner'] = $account; // we do NOT allow to change the owner of existing events
544 544
 
545 545
 		$event = $this->message2event($message, $account, $event);
546 546
 
547 547
 		// store event, ignore conflicts and skip notifications, as AS clients do their own notifications
548 548
 		$skip_notification = false;
549 549
 		if (isset($GLOBALS['egw_info']['user']['preferences']['activesync']['felamimail-allowSendingInvitations']) &&
550
-			$GLOBALS['egw_info']['user']['preferences']['activesync']['felamimail-allowSendingInvitations']=='send')
550
+			$GLOBALS['egw_info']['user']['preferences']['activesync']['felamimail-allowSendingInvitations'] == 'send')
551 551
 		{
552 552
 			$skip_notification = true; // to avoid double notification from client AND Server
553 553
 		}
554
-		if (!($id = $this->calendar->update($event,$ignore_conflicts=true,$touch_modified=true,$ignore_acl=false,$updateTS=true,$messages=null, $skip_notification)))
554
+		if (!($id = $this->calendar->update($event, $ignore_conflicts = true, $touch_modified = true, $ignore_acl = false, $updateTS = true, $messages = null, $skip_notification)))
555 555
 		{
556 556
 			debugLog(__METHOD__."('$folderid',$id,...) error saving event=".array2string($event)."!");
557 557
 			return false;
@@ -559,24 +559,24 @@  discard block
 block discarded – undo
559 559
 		// store non-delete exceptions
560 560
 		if ($message->exceptions)
561 561
 		{
562
-			foreach($message->exceptions as $exception)
562
+			foreach ($message->exceptions as $exception)
563 563
 			{
564 564
 				if (!$exception->deleted)
565 565
 				{
566 566
 					$ex_event = $event;
567 567
 					unset($ex_event['id']);
568 568
 					unset($ex_event['etag']);
569
-					foreach($ex_event as $name => $value) if (substr($name,0,6) == 'recur_') unset($ex_event[$name]);
569
+					foreach ($ex_event as $name => $value) if (substr($name, 0, 6) == 'recur_') unset($ex_event[$name]);
570 570
 					$ex_event['recur_type'] = calendar_rrule::NONE;
571 571
 
572 572
 					if ($event['id'] && ($ex_events = $this->calendar->search(array(
573 573
 						'user' => $user,
574 574
 						'enum_recuring' => false,
575 575
 						'daywise' => false,
576
-						'filter' => 'owner',  // return all possible entries
576
+						'filter' => 'owner', // return all possible entries
577 577
 						'query' => array(
578 578
 							'cal_uid' => $event['uid'],
579
-							'cal_recurrence' => $exception->exceptionstarttime,	// in servertime
579
+							'cal_recurrence' => $exception->exceptionstarttime, // in servertime
580 580
 						),
581 581
 					))))
582 582
 					{
@@ -588,7 +588,7 @@  discard block
 block discarded – undo
588 588
 						$participants = $event['participants'];
589 589
 					}
590 590
 					$ex_event = $this->message2event($exception, $account, $ex_event);
591
-					$ex_event['participants'] = $participants;	// not contained in $exception
591
+					$ex_event['participants'] = $participants; // not contained in $exception
592 592
 					$ex_event['reference'] = $event['id'];
593 593
 					$ex_event['recurrence'] = egw_time::server2user($exception->exceptionstarttime);
594 594
 					$ex_ok = $this->calendar->save($ex_event);
@@ -610,10 +610,10 @@  discard block
 block discarded – undo
610 610
 	 * @param array $event=array()
611 611
 	 * @return array
612 612
 	 */
613
-	private function message2event(SyncAppointment $message, $account, $event=array())
613
+	private function message2event(SyncAppointment $message, $account, $event = array())
614 614
 	{
615 615
 		// timestamps (created & modified are updated automatically)
616
-		foreach(array(
616
+		foreach (array(
617 617
 			'start' => 'starttime',
618 618
 			'end' => 'endtime',
619 619
 		) as $key => $attr)
@@ -621,7 +621,7 @@  discard block
 block discarded – undo
621 621
 			if (isset($message->$attr)) $event[$key] = egw_time::server2user($message->$attr);
622 622
 		}
623 623
 		// copying strings
624
-		foreach(array(
624
+		foreach (array(
625 625
 			'title' => 'subject',
626 626
 			'uid'   => 'uid',
627 627
 			'location' => 'location',
@@ -636,7 +636,7 @@  discard block
 block discarded – undo
636 636
 		{
637 637
 			$event['description'] = $description;
638 638
 		}
639
-		$event['public'] = (int)($message->sensitivity < 1);	// 0=normal, 1=personal, 2=private, 3=confidential
639
+		$event['public'] = (int)($message->sensitivity < 1); // 0=normal, 1=personal, 2=private, 3=confidential
640 640
 
641 641
 		// busystatus=(0=free|1=tentative|2=busy|3=out-of-office), EGw has non_blocking=0|1
642 642
 		if (isset($message->busystatus))
@@ -646,20 +646,20 @@  discard block
 block discarded – undo
646 646
 
647 647
 		if (($event['whole_day'] = $message->alldayevent))
648 648
 		{
649
-			if ($event['end'] == $event['start']) $event['end'] += 24*3600;	// some clients send equal start&end for 1day
650
-			$event['end']--;	// otherwise our whole-day event code in save makes it one more day!
649
+			if ($event['end'] == $event['start']) $event['end'] += 24 * 3600; // some clients send equal start&end for 1day
650
+			$event['end']--; // otherwise our whole-day event code in save makes it one more day!
651 651
 		}
652 652
 
653 653
 		$participants = array();
654
-		foreach((array)$message->attendees as $attendee)
654
+		foreach ((array)$message->attendees as $attendee)
655 655
 		{
656
-			if ($attendee->type == 3) continue;	// we can not identify resources and re-add them anyway later
656
+			if ($attendee->type == 3) continue; // we can not identify resources and re-add them anyway later
657 657
 
658
-			if (preg_match('/^noreply-(.*)[email protected]$/',$attendee->email,$matches))
658
+			if (preg_match('/^noreply-(.*)[email protected]$/', $attendee->email, $matches))
659 659
 			{
660 660
 				$uid = $matches[1];
661 661
 			}
662
-			elseif (!($uid = $GLOBALS['egw']->accounts->name2id($attendee->email,'account_email')))
662
+			elseif (!($uid = $GLOBALS['egw']->accounts->name2id($attendee->email, 'account_email')))
663 663
 			{
664 664
 				$search = array(
665 665
 					'email' => $attendee->email,
@@ -669,13 +669,13 @@  discard block
 block discarded – undo
669 669
 				// search addressbook for participant
670 670
 				if (!isset($this->addressbook)) $this->addressbook = new addressbook_bo();
671 671
 				if ((list($data) = $this->addressbook->search($search,
672
-					array('id','egw_addressbook.account_id as account_id','n_fn'),
672
+					array('id', 'egw_addressbook.account_id as account_id', 'n_fn'),
673 673
 					'egw_addressbook.account_id IS NOT NULL DESC, n_fn IS NOT NULL DESC',
674
-					'','',false,'OR')))
674
+					'', '', false, 'OR')))
675 675
 				{
676 676
 					$uid = $data['account_id'] ? (int)$data['account_id'] : 'c'.$data['id'];
677 677
 				}
678
-				elseif($attendee->name === $attendee->email || empty($attendee->name))	// dont store empty or email as name
678
+				elseif ($attendee->name === $attendee->email || empty($attendee->name))	// dont store empty or email as name
679 679
 				{
680 680
 					$uid = 'e'.$attendee->email;
681 681
 				}
@@ -692,8 +692,8 @@  discard block
 block discarded – undo
692 692
 				//debugLog("old status for $uid is status=$status, quantity=$quantitiy, role=$role");
693 693
 			}
694 694
 			// check if just email is an existing attendee (iOS returns email as name too!), keep it to keep status/role if not set
695
-			elseif ($event['id'] && (isset($event['participants'][$u='e'.$attendee->email]) ||
696
-				(isset($event['participants'][$u='e'.$attendee->name.' <'.$attendee->email.'>']))))
695
+			elseif ($event['id'] && (isset($event['participants'][$u = 'e'.$attendee->email]) ||
696
+				(isset($event['participants'][$u = 'e'.$attendee->name.' <'.$attendee->email.'>']))))
697 697
 			{
698 698
 				$status = $event['participants'][$u];
699 699
 				calendar_so::split_status($status, $quantity, $role);
@@ -706,9 +706,9 @@  discard block
 block discarded – undo
706 706
 				$role = 'REQ-PARTICIPANT';
707 707
 				//debugLog("default status for $uid is status=$status, quantity=$quantitiy, role=$role");
708 708
 			}
709
-			if ($role == 'CHAIR') $chair_set = true;	// by role from existing participant
709
+			if ($role == 'CHAIR') $chair_set = true; // by role from existing participant
710 710
 
711
-			if (isset($attendee->attendeestatus) && ($s = array_search($attendee->attendeestatus,self::$status2as)))
711
+			if (isset($attendee->attendeestatus) && ($s = array_search($attendee->attendeestatus, self::$status2as)))
712 712
 			{
713 713
 				$status = $s;
714 714
 			}
@@ -718,29 +718,29 @@  discard block
 block discarded – undo
718 718
 				$chair_set = true;
719 719
 			}
720 720
 			elseif (isset($attendee->attendeetype) &&
721
-				!($role == 'CHAIR' && !is_numeric($uid)) &&	// do not override our external ORGANIZER
722
-				($r = array_search($attendee->attendeetype,self::$role2as)) &&
721
+				!($role == 'CHAIR' && !is_numeric($uid)) && // do not override our external ORGANIZER
722
+				($r = array_search($attendee->attendeetype, self::$role2as)) &&
723 723
 				(int)self::$role2as[$role] != $attendee->attendeetype)	// if old role gives same type, use old role, as we have a lot more roles then AS
724 724
 			{
725 725
 				$role = $r;
726 726
 			}
727 727
 			//debugLog("-> status for $uid is status=$status ($s), quantity=$quantitiy, role=$role ($r)");
728
-			$participants[$uid] = calendar_so::combine_status($status,$quantitiy,$role);
728
+			$participants[$uid] = calendar_so::combine_status($status, $quantitiy, $role);
729 729
 		}
730 730
 		// if organizer is not already participant, add him as chair
731
-		if (($uid = $GLOBALS['egw']->accounts->name2id($message->organizeremail,'account_email')) && !isset($participants[$uid]))
731
+		if (($uid = $GLOBALS['egw']->accounts->name2id($message->organizeremail, 'account_email')) && !isset($participants[$uid]))
732 732
 		{
733 733
 			$participants[$uid] = calendar_so::combine_status($uid == $GLOBALS['egw_info']['user']['account_id'] ?
734
-				'A' : 'U',1,'CHAIR');
734
+				'A' : 'U', 1, 'CHAIR');
735 735
 			$chair_set = true;
736 736
 		}
737 737
 		// preserve all resource types not account, contact or email (eg. resources) for existing events
738 738
 		// $account is also preserved, as AS does not add him as participant!
739
-		foreach((array)$event['participant_types'] as $type => $parts)
739
+		foreach ((array)$event['participant_types'] as $type => $parts)
740 740
 		{
741
-			if (in_array($type,array('c','e'))) continue;	// they are correctly representable in AS
741
+			if (in_array($type, array('c', 'e'))) continue; // they are correctly representable in AS
742 742
 
743
-			foreach($parts as $id => $status)
743
+			foreach ($parts as $id => $status)
744 744
 			{
745 745
 				// accounts are represented correctly, but the event owner which is no participant in AS
746 746
 				if ($type == 'u' && $id != $account) continue;
@@ -756,13 +756,13 @@  discard block
 block discarded – undo
756 756
 		if (!$event['id'] || !$participants || !isset($participants[$account]))
757 757
 		{
758 758
 			$participants[$account] = calendar_so::combine_status($account == $GLOBALS['egw_info']['user']['account_id'] ?
759
-				'A' : 'U',1,!$chair_set ? 'CHAIR' : 'REQ-PARTICIPANT');
759
+				'A' : 'U', 1, !$chair_set ? 'CHAIR' : 'REQ-PARTICIPANT');
760 760
 		}
761 761
 		$event['participants'] = $participants;
762 762
 
763 763
 		if (isset($message->categories))
764 764
 		{
765
-			$event['category'] = implode(',', array_filter($this->calendar->find_or_add_categories($message->categories, $event),'strlen'));
765
+			$event['category'] = implode(',', array_filter($this->calendar->find_or_add_categories($message->categories, $event), 'strlen'));
766 766
 		}
767 767
 
768 768
 		// check if event is recurring and import recur information (incl. timezone)
@@ -772,8 +772,7 @@  discard block
 block discarded – undo
772 772
 			{
773 773
 				$event['tzid'] = self::as2tz(self::_getTZFromSyncBlob(base64_decode($message->timezone)));
774 774
 			}
775
-			$event['recur_type'] = $message->recurrence->type == 6 ? calendar_rrule::YEARLY :
776
-				array_search($message->recurrence->type, self::$recur_type2as);
775
+			$event['recur_type'] = $message->recurrence->type == 6 ? calendar_rrule::YEARLY : array_search($message->recurrence->type, self::$recur_type2as);
777 776
 			$event['recur_interval'] = $message->recurrence->interval;
778 777
 
779 778
 			switch ($event['recur_type'])
@@ -782,7 +781,7 @@  discard block
 block discarded – undo
782 781
 					// $message->recurrence->weekofmonth is not explicitly stored in egw, just taken from start date
783 782
 					// fall throught
784 783
 				case calendar_rrule::WEEKLY:
785
-					$event['recur_data'] = $message->recurrence->dayofweek;	// 1=Su, 2=Mo, 4=Tu, .., 64=Sa
784
+					$event['recur_data'] = $message->recurrence->dayofweek; // 1=Su, 2=Mo, 4=Tu, .., 64=Sa
786 785
 					break;
787 786
 				case calendar_rrule::MONTHLY_MDAY:
788 787
 					// $message->recurrence->dayofmonth is not explicitly stored in egw, just taken from start date
@@ -798,7 +797,7 @@  discard block
 block discarded – undo
798 797
 			$event['recur_exceptions'] = array();
799 798
 			if ($message->exceptions)
800 799
 			{
801
-				foreach($message->exceptions as $exception)
800
+				foreach ($message->exceptions as $exception)
802 801
 				{
803 802
 					$event['recur_exception'][] = egw_time::server2user($exception->exceptionstarttime);
804 803
 				}
@@ -808,7 +807,7 @@  discard block
 block discarded – undo
808 807
 			{
809 808
 				// calculate enddate from occurences count, as we only support enddate
810 809
 				$count = $message->recurrence->occurrences;
811
-				foreach(calendar_rrule::event2rrule($event, true) as $rtime)	// true = timestamps are user time here, because of save!
810
+				foreach (calendar_rrule::event2rrule($event, true) as $rtime)	// true = timestamps are user time here, because of save!
812 811
 				{
813 812
 					if (--$count <= 0) break;
814 813
 				}
@@ -818,11 +817,11 @@  discard block
 block discarded – undo
818 817
 		// only import alarms in own calendar
819 818
 		if ($message->reminder && $account == $GLOBALS['egw_info']['user']['account_id'])
820 819
 		{
821
-			foreach((array)$event['alarm'] as $alarm)
820
+			foreach ((array)$event['alarm'] as $alarm)
822 821
 			{
823
-				if (($alarm['all'] || $alarm['owner'] == $account) && $alarm['offset'] == 60*$message->reminder)
822
+				if (($alarm['all'] || $alarm['owner'] == $account) && $alarm['offset'] == 60 * $message->reminder)
824 823
 				{
825
-					$alarm = true;	// alarm already exists --> do nothing
824
+					$alarm = true; // alarm already exists --> do nothing
826 825
 					break;
827 826
 				}
828 827
 			}
@@ -831,16 +830,16 @@  discard block
 block discarded – undo
831 830
 				// delete all earlier alarms of that user
832 831
 				// user get's per AS only the earliest alarm, as AS only supports one alarm
833 832
 				// --> if a later alarm is returned, user probably modifed an existing alarm
834
-				foreach((array)$event['alarm'] as $key => $alarm)
833
+				foreach ((array)$event['alarm'] as $key => $alarm)
835 834
 				{
836
-					if ($alarm['owner'] == $account && $alarm['offset'] > 60*$message->reminder)
835
+					if ($alarm['owner'] == $account && $alarm['offset'] > 60 * $message->reminder)
837 836
 					{
838 837
 						unset($event['alarm'][$key]);
839 838
 					}
840 839
 				}
841 840
 				$event['alarm'][] = $alarm = array(
842 841
 					'owner' => $account,
843
-					'offset' => 60*$message->reminder,
842
+					'offset' => 60 * $message->reminder,
844 843
 				);
845 844
 			}
846 845
 		}
@@ -963,11 +962,11 @@  discard block
 block discarded – undo
963 962
 	 * @param int $mimesupport=0
964 963
 	 * @return SyncAppointment|boolean false on error
965 964
 	 */
966
-	public function GetMessage($folderid, $id, $truncsize, $bodypreference=false, $optionbodypreference=false, $mimesupport = 0)
965
+	public function GetMessage($folderid, $id, $truncsize, $bodypreference = false, $optionbodypreference = false, $mimesupport = 0)
967 966
 	{
968 967
 		if (!isset($this->calendar)) $this->calendar = new calendar_boupdate();
969 968
 
970
-		debugLog (__METHOD__."('$folderid', ".array2string($id).", truncsize=$truncsize, bodyprefence=$bodypreference, mimesupport=$mimesupport)");
969
+		debugLog(__METHOD__."('$folderid', ".array2string($id).", truncsize=$truncsize, bodyprefence=$bodypreference, mimesupport=$mimesupport)");
971 970
 		$this->backend->splitID($folderid, $type, $account);
972 971
 		if (is_array($id))
973 972
 		{
@@ -976,15 +975,15 @@  discard block
 block discarded – undo
976 975
 		}
977 976
 		else
978 977
 		{
979
-			list($id,$recur_date) = explode(':',$id);
980
-			if ($type != 'calendar' || !($event = $this->calendar->read($id,$recur_date,false,'server',$account)))
978
+			list($id, $recur_date) = explode(':', $id);
979
+			if ($type != 'calendar' || !($event = $this->calendar->read($id, $recur_date, false, 'server', $account)))
981 980
 			{
982 981
 				error_log(__METHOD__."('$folderid', $id, ...) read($id,null,false,'server',$account) returned false");
983 982
 				return false;
984 983
 			}
985 984
 		}
986
-		debugLog(__METHOD__."($folderid,$id,...) start=$event[start]=".date('Y-m-d H:i:s',$event['start']).", recurrence=$event[recurrence]=".date('Y-m-d H:i:s',$event['recurrence']));
987
-		foreach($event['recur_exception'] as $ex) debugLog("exception=$ex=".date('Y-m-d H:i:s',$ex));
985
+		debugLog(__METHOD__."($folderid,$id,...) start=$event[start]=".date('Y-m-d H:i:s', $event['start']).", recurrence=$event[recurrence]=".date('Y-m-d H:i:s', $event['recurrence']));
986
+		foreach ($event['recur_exception'] as $ex) debugLog("exception=$ex=".date('Y-m-d H:i:s', $ex));
988 987
 
989 988
 		$message = new SyncAppointment();
990 989
 
@@ -993,11 +992,11 @@  discard block
 block discarded – undo
993 992
 			$as_tz = self::tz2as($event['tzid']);
994 993
 			$message->timezone = base64_encode(self::_getSyncBlobFromTZ($as_tz));
995 994
 		}
996
-		catch(Exception $e) {
995
+		catch (Exception $e) {
997 996
 			// ignore exception, simply set no timezone, as it is optional
998 997
 		}
999 998
 		// copying timestamps (they are already read in servertime, so non tz conversation)
1000
-		foreach(array(
999
+		foreach (array(
1001 1000
 			'start' => 'starttime',
1002 1001
 			'end'   => 'endtime',
1003 1002
 			'created' => 'dtstamp',
@@ -1008,10 +1007,10 @@  discard block
 block discarded – undo
1008 1007
 		}
1009 1008
 		if (($message->alldayevent = (int)calendar_bo::isWholeDay($event)))
1010 1009
 		{
1011
-			++$message->endtime;	// EGw all-day-events are 1 sec shorter!
1010
+			++$message->endtime; // EGw all-day-events are 1 sec shorter!
1012 1011
 		}
1013 1012
 		// copying strings
1014
-		foreach(array(
1013
+		foreach (array(
1015 1014
 			'title' => 'subject',
1016 1015
 			'uid'   => 'uid',
1017 1016
 			'location' => 'location',
@@ -1033,22 +1032,22 @@  discard block
 block discarded – undo
1033 1032
 			{
1034 1033
 				debugLog("airsyncbasebody!");
1035 1034
 				$message->airsyncbasebody = new SyncAirSyncBaseBody();
1036
-				$message->airsyncbasenativebodytype=1;
1035
+				$message->airsyncbasenativebodytype = 1;
1037 1036
 				$this->backend->note2messagenote($event['description'], $bodypreference, $message->airsyncbasebody);
1038 1037
 			}
1039 1038
 		}
1040 1039
 		$message->md5body = md5($event['description']);
1041 1040
 
1042
-		$message->organizername  = $GLOBALS['egw']->accounts->id2name($event['owner'],'account_fullname');
1043
-		$message->organizeremail = $GLOBALS['egw']->accounts->id2name($event['owner'],'account_email');
1041
+		$message->organizername  = $GLOBALS['egw']->accounts->id2name($event['owner'], 'account_fullname');
1042
+		$message->organizeremail = $GLOBALS['egw']->accounts->id2name($event['owner'], 'account_email');
1044 1043
 
1045
-		$message->sensitivity = $event['public'] ? 0 : 2;	// 0=normal, 1=personal, 2=private, 3=confidential
1044
+		$message->sensitivity = $event['public'] ? 0 : 2; // 0=normal, 1=personal, 2=private, 3=confidential
1046 1045
 
1047 1046
 		// busystatus=(0=free|1=tentative|2=busy|3=out-of-office), EGw has non_blocking=0|1
1048 1047
 		$message->busystatus = $event['non_blocking'] ? 0 : 2;
1049 1048
 
1050 1049
 		$message->attendees = array();
1051
-		foreach($event['participants'] as $uid => $status)
1050
+		foreach ($event['participants'] as $uid => $status)
1052 1051
 		{
1053 1052
 			// AS does NOT want calendar owner as participant
1054 1053
 			if ($uid == $account) continue;
@@ -1059,19 +1058,19 @@  discard block
 block discarded – undo
1059 1058
 			$attendee->attendeetype = (int)self::$role2as[$role];
1060 1059
 			if (is_numeric($uid))
1061 1060
 			{
1062
-				$attendee->name = $GLOBALS['egw']->accounts->id2name($uid,'account_fullname');
1063
-				$attendee->email = $GLOBALS['egw']->accounts->id2name($uid,'account_email');
1061
+				$attendee->name = $GLOBALS['egw']->accounts->id2name($uid, 'account_fullname');
1062
+				$attendee->email = $GLOBALS['egw']->accounts->id2name($uid, 'account_email');
1064 1063
 			}
1065 1064
 			else
1066 1065
 			{
1067 1066
 				list($info) = $i = $this->calendar->resources[$uid[0]]['info'] ?
1068
-					ExecMethod($this->calendar->resources[$uid[0]]['info'],substr($uid,1)) : array(false);
1067
+					ExecMethod($this->calendar->resources[$uid[0]]['info'], substr($uid, 1)) : array(false);
1069 1068
 
1070 1069
 				if (!$info) continue;
1071 1070
 
1072 1071
 				if (!$info['email'] && $info['responsible'])
1073 1072
 				{
1074
-					$info['email'] = $GLOBALS['egw']->accounts->id2name($info['responsible'],'account_email');
1073
+					$info['email'] = $GLOBALS['egw']->accounts->id2name($info['responsible'], 'account_email');
1075 1074
 				}
1076 1075
 				$attendee->name = empty($info['cn']) ? $info['name'] : $info['cn'];
1077 1076
 				$attendee->email = $info['email'];
@@ -1083,7 +1082,7 @@  discard block
 block discarded – undo
1083 1082
 					$message->organizeremail = $attendee->email;
1084 1083
 					debugLog(__METHOD__."($folderid, $id, ...) external organizer detected (role=$role, uid=$uid), set as AS organizer: $message->organizername <$message->organizeremail>");
1085 1084
 				}
1086
-				if ($uid[0] == 'r') $attendee->type = 3;	// 3 = resource
1085
+				if ($uid[0] == 'r') $attendee->type = 3; // 3 = resource
1087 1086
 			}
1088 1087
 			// email must NOT be empty, but MAY be an arbitrary text
1089 1088
 			if (empty($attendee->email)) $attendee->email = 'noreply-'.$uid.'[email protected]';
@@ -1091,7 +1090,7 @@  discard block
 block discarded – undo
1091 1090
 			$message->attendees[] = $attendee;
1092 1091
 		}
1093 1092
 		$message->categories = array();
1094
-		foreach($event['category'] ? explode(',',$event['category']) : array() as $cat_id)
1093
+		foreach ($event['category'] ? explode(',', $event['category']) : array() as $cat_id)
1095 1094
 		{
1096 1095
 			$message->categories[] = categories::id2name($cat_id);
1097 1096
 		}
@@ -1100,25 +1099,25 @@  discard block
 block discarded – undo
1100 1099
 		if ($event['recur_type'] != calendar_rrule::NONE && !$recur_date)
1101 1100
 		{
1102 1101
 			$message->recurrence = $recurrence = new SyncRecurrence();
1103
-			$rrule = calendar_rrule::event2rrule($event,false);	// false = timestamps in $event are servertime
1102
+			$rrule = calendar_rrule::event2rrule($event, false); // false = timestamps in $event are servertime
1104 1103
 			$recurrence->type = (int)self::$recur_type2as[$rrule->type];
1105 1104
 			$recurrence->interval = $rrule->interval;
1106 1105
 			switch ($rrule->type)
1107 1106
 			{
1108 1107
 				case calendar_rrule::MONTHLY_WDAY:
1109 1108
 					$recurrence->weekofmonth = $rrule->monthly_byday_num >= 1 ?
1110
-						$rrule->monthly_byday_num : 5;	// 1..5=last week of month, not -1
1109
+						$rrule->monthly_byday_num : 5; // 1..5=last week of month, not -1
1111 1110
 					// fall throught
1112 1111
 				case calendar_rrule::WEEKLY:
1113
-					$recurrence->dayofweek = $rrule->weekdays;	// 1=Su, 2=Mo, 4=Tu, .., 64=Sa
1112
+					$recurrence->dayofweek = $rrule->weekdays; // 1=Su, 2=Mo, 4=Tu, .., 64=Sa
1114 1113
 					break;
1115 1114
 				case calendar_rrule::MONTHLY_MDAY:
1116
-					$recurrence->dayofmonth = $rrule->monthly_bymonthday >= 1 ?	// 1..31
1117
-						$rrule->monthly_bymonthday : 31;	// not -1 for last day of month!
1115
+					$recurrence->dayofmonth = $rrule->monthly_bymonthday >= 1 ? // 1..31
1116
+						$rrule->monthly_bymonthday : 31; // not -1 for last day of month!
1118 1117
 					break;
1119 1118
 				case calendar_rrule::YEARLY:
1120
-					$recurrence->dayofmonth = (int)$rrule->time->format('d');	// 1..31
1121
-					$recurrence->monthofyear = (int)$rrule->time->format('m');	// 1..12
1119
+					$recurrence->dayofmonth = (int)$rrule->time->format('d'); // 1..31
1120
+					$recurrence->monthofyear = (int)$rrule->time->format('m'); // 1..12
1122 1121
 					break;
1123 1122
 			}
1124 1123
 			if ($rrule->enddate)	// enddate is only a date, but AS needs a time incl. correct starttime!
@@ -1134,9 +1133,9 @@  discard block
 block discarded – undo
1134 1133
 				// search real / non-virtual exceptions
1135 1134
 				if (!empty($event['uid']))
1136 1135
 				{
1137
-					$ex_events =& $this->calendar->search(array(
1136
+					$ex_events = & $this->calendar->search(array(
1138 1137
 						'query' => array('cal_uid' => $event['uid']),
1139
-						'filter' => 'owner',  // return all possible entries
1138
+						'filter' => 'owner', // return all possible entries
1140 1139
 						'daywise' => false,
1141 1140
 						'date_format' => 'server',
1142 1141
 					));
@@ -1145,36 +1144,36 @@  discard block
 block discarded – undo
1145 1144
 				{
1146 1145
 					debugLog(__METHOD__.__LINE__." Exceptions found but no UID given for Event:".$event['id'].' Exceptions:'.array2string($event['recur_exception']));
1147 1146
 				}
1148
-				if (count($ex_events)>=1) debugLog(__METHOD__.__LINE__." found ".count($ex_events)." exeptions for event with UID/ID:".$event['uid'].'/'.$event['id']);
1147
+				if (count($ex_events) >= 1) debugLog(__METHOD__.__LINE__." found ".count($ex_events)." exeptions for event with UID/ID:".$event['uid'].'/'.$event['id']);
1149 1148
 
1150 1149
 				$message->exceptions = array();
1151
-				foreach($ex_events as $ex_event)
1150
+				foreach ($ex_events as $ex_event)
1152 1151
 				{
1153
-					if ($ex_event['id'] == $event['id']) continue;	// ignore series master
1152
+					if ($ex_event['id'] == $event['id']) continue; // ignore series master
1154 1153
 					$exception = $this->GetMessage($folderid, $ex_event, $truncsize, $bodypreference, $mimesupport);
1155 1154
 					$exception->exceptionstarttime = $exception_time = $ex_event['recurrence'];
1156
-					foreach(array('attendees','recurrence','uid','timezone','organizername','organizeremail') as $not_supported)
1155
+					foreach (array('attendees', 'recurrence', 'uid', 'timezone', 'organizername', 'organizeremail') as $not_supported)
1157 1156
 					{
1158
-						$exception->$not_supported = null;	// not allowed in exceptions :-(
1157
+						$exception->$not_supported = null; // not allowed in exceptions :-(
1159 1158
 					}
1160 1159
 					$exception->deleted = 0;
1161
-					if (($key = array_search($exception_time,$event['recur_exception'])) !== false)
1160
+					if (($key = array_search($exception_time, $event['recur_exception'])) !== false)
1162 1161
 					{
1163 1162
 						unset($event['recur_exception'][$key]);
1164 1163
 					}
1165
-					debugLog(__METHOD__."() added exception ".date('Y-m-d H:i:s',$exception_time).' '.array2string($exception));
1164
+					debugLog(__METHOD__."() added exception ".date('Y-m-d H:i:s', $exception_time).' '.array2string($exception));
1166 1165
 					$message->exceptions[] = $exception;
1167 1166
 				}
1168 1167
 				// add rest of exceptions as deleted
1169
-				foreach($event['recur_exception'] as $exception_time)
1168
+				foreach ($event['recur_exception'] as $exception_time)
1170 1169
 				{
1171 1170
 					if (!empty($exception_time))
1172 1171
 					{
1173 1172
 						if (empty($event['uid'])) debugLog(__METHOD__.__LINE__." BEWARE no UID given for this event:".$event['id'].' but exception is set for '.$exception_time);
1174
-						$exception = new SyncAppointment();	// exceptions seems to be full SyncAppointments, with only starttime required
1173
+						$exception = new SyncAppointment(); // exceptions seems to be full SyncAppointments, with only starttime required
1175 1174
 						$exception->deleted = 1;
1176 1175
 						$exception->exceptionstarttime = $exception_time;
1177
-						debugLog(__METHOD__."() added deleted exception ".date('Y-m-d H:i:s',$exception_time).' '.array2string($exception));
1176
+						debugLog(__METHOD__."() added deleted exception ".date('Y-m-d H:i:s', $exception_time).' '.array2string($exception));
1178 1177
 						$message->exceptions[] = $exception;
1179 1178
 					}
1180 1179
 				}
@@ -1196,12 +1195,12 @@  discard block
 block discarded – undo
1196 1195
 		// only return alarms if in own calendar
1197 1196
 		if ($account == $GLOBALS['egw_info']['user']['account_id'] && $event['alarm'])
1198 1197
 		{
1199
-			foreach($event['alarm'] as $alarm)
1198
+			foreach ($event['alarm'] as $alarm)
1200 1199
 			{
1201 1200
 				if ($alarm['all'] || $alarm['owner'] == $account)
1202 1201
 				{
1203
-					$message->reminder = $alarm['offset']/60;	// is in minutes, not seconds as in EGw
1204
-					break;	// AS supports only one alarm! (we use the next/earliest one)
1202
+					$message->reminder = $alarm['offset'] / 60; // is in minutes, not seconds as in EGw
1203
+					break; // AS supports only one alarm! (we use the next/earliest one)
1205 1204
 				}
1206 1205
 			}
1207 1206
 		}
@@ -1232,7 +1231,7 @@  discard block
 block discarded – undo
1232 1231
 			// error_log why access is denied (should never happen for everything returned by calendar_bo::search)
1233 1232
 			$backup = $this->calendar->debug;
1234 1233
 			//$this->calendar->debug = 2;
1235
-			list($id) = explode(':',$id);
1234
+			list($id) = explode(':', $id);
1236 1235
 			$this->calendar->check_perms(EGW_ACL_FREEBUSY, $id, 0, 'server');
1237 1236
 			$this->calendar->debug = $backup;
1238 1237
 		}
@@ -1267,10 +1266,10 @@  discard block
 block discarded – undo
1267 1266
 
1268 1267
 		if (!isset($this->calendar)) $this->calendar = new calendar_boupdate();
1269 1268
 		//$ctag = $this->calendar->get_ctag($owner,'owner',true);	// true only consider recurrence master
1270
-		$ctag = $this->calendar->get_ctag($owner,false,true); // we only want to fetch the owners events, where he is a participant too
1269
+		$ctag = $this->calendar->get_ctag($owner, false, true); // we only want to fetch the owners events, where he is a participant too
1271 1270
 		// workaround for syncstate = 0 when calendar is empty causes synctate to not return 0 but array resulting in foldersync loop
1272 1271
 		if ($ctag == 0) $ctag = 1;
1273
-		$changes = array();	// no change
1272
+		$changes = array(); // no change
1274 1273
 		$syncstate_was = $syncstate;
1275 1274
 
1276 1275
 		if ($ctag !== $syncstate)
@@ -1314,7 +1313,7 @@  discard block
 block discarded – undo
1314 1313
 	 * @link http://download.microsoft.com/download/5/D/D/5DD33FDF-91F5-496D-9884-0A0B0EE698BB/%5BMS-ASDTYPE%5D.pdf
1315 1314
 	 * @throws egw_exception_assertion_failed if no vtimezone data found for given timezone
1316 1315
 	 */
1317
-	static public function tz2as($tz,$ts=null)
1316
+	static public function tz2as($tz, $ts = null)
1318 1317
 	{
1319 1318
 /*
1320 1319
 BEGIN:VTIMEZONE
@@ -1350,20 +1349,20 @@  discard block
 block discarded – undo
1350 1349
 			'dstendhour' => 0, 'dstendminute' => 0, 'dstendsecond' => 0, 'dstendmillis' => 0,
1351 1350
 		);
1352 1351
 
1353
-		$name = $component = is_a($tz,'DateTimeZone') ? $tz->getName() : $tz;
1354
-		if (strpos($component, 'VTIMEZONE') === false) $component = calendar_timezones::tz2id($name,'component');
1352
+		$name = $component = is_a($tz, 'DateTimeZone') ? $tz->getName() : $tz;
1353
+		if (strpos($component, 'VTIMEZONE') === false) $component = calendar_timezones::tz2id($name, 'component');
1355 1354
 		// parse ical timezone defintion
1356
-		$ical = self::ical2array($ical=$component);
1355
+		$ical = self::ical2array($ical = $component);
1357 1356
 		$standard = $ical['VTIMEZONE']['STANDARD'];
1358 1357
 		$daylight = $ical['VTIMEZONE']['DAYLIGHT'];
1359 1358
 
1360 1359
 		if (!isset($standard))
1361 1360
 		{
1362
-			if (preg_match('/^etc\/gmt([+-])([0-9]+)$/i',$name,$matches))
1361
+			if (preg_match('/^etc\/gmt([+-])([0-9]+)$/i', $name, $matches))
1363 1362
 			{
1364 1363
 				$standard = array(
1365
-					'TZOFFSETTO'   => sprintf('%s%02d00',$matches[1],$matches[2]),
1366
-					'TZOFFSETFROM' => sprintf('%s%02d00',$matches[1],$matches[2]),
1364
+					'TZOFFSETTO'   => sprintf('%s%02d00', $matches[1], $matches[2]),
1365
+					'TZOFFSETFROM' => sprintf('%s%02d00', $matches[1], $matches[2]),
1367 1366
 				);
1368 1367
 				unset($daylight);
1369 1368
 			}
@@ -1374,15 +1373,15 @@  discard block
 block discarded – undo
1374 1373
 		}
1375 1374
 		// get bias and dstbias from standard component, which is present in all tz's
1376 1375
 		// (dstbias is relative to bias and almost always 60 or 0)
1377
-		$data['bias'] = -(60 * substr($standard['TZOFFSETTO'],0,-2) + substr($standard['TZOFFSETTO'],-2));
1378
-		$data['dstbias'] = -(60 * substr($standard['TZOFFSETFROM'],0,-2) + substr($standard['TZOFFSETFROM'],-2) + $data['bias']);
1376
+		$data['bias'] = -(60 * substr($standard['TZOFFSETTO'], 0, -2) + substr($standard['TZOFFSETTO'], -2));
1377
+		$data['dstbias'] = -(60 * substr($standard['TZOFFSETFROM'], 0, -2) + substr($standard['TZOFFSETFROM'], -2) + $data['bias']);
1379 1378
 
1380 1379
 		// check if we have an additional DAYLIGHT component and both have a RRULE component --> tz uses daylight saving
1381 1380
 		if (isset($standard['RRULE']) && isset($daylight) && isset($daylight['RRULE']))
1382 1381
 		{
1383
-			foreach(array('dststart' => $daylight,'dstend' => $standard) as $prefix => $comp)
1382
+			foreach (array('dststart' => $daylight, 'dstend' => $standard) as $prefix => $comp)
1384 1383
 			{
1385
-				if (preg_match('/FREQ=YEARLY;BYDAY=(.*);BYMONTH=(\d+)/',$comp['RRULE'],$matches))
1384
+				if (preg_match('/FREQ=YEARLY;BYDAY=(.*);BYMONTH=(\d+)/', $comp['RRULE'], $matches))
1386 1385
 				{
1387 1386
 					$data[$prefix.'month'] = (int)$matches[2];
1388 1387
 					$data[$prefix.'week'] = (int)$matches[1];
@@ -1399,20 +1398,20 @@  discard block
 block discarded – undo
1399 1398
 						$data[$prefix.'week'] = 5;
1400 1399
 						if ($prefix == 'dstend') $data[$prefix.'month'] -= 1;
1401 1400
 					}
1402
-					static $day2int = array('SU'=>0,'MO'=>1,'TU'=>2,'WE'=>3,'TH'=>4,'FR'=>5,'SA'=>6);
1403
-					$data[$prefix.'day'] = (int)$day2int[substr($matches[1],-2)];
1401
+					static $day2int = array('SU'=>0, 'MO'=>1, 'TU'=>2, 'WE'=>3, 'TH'=>4, 'FR'=>5, 'SA'=>6);
1402
+					$data[$prefix.'day'] = (int)$day2int[substr($matches[1], -2)];
1404 1403
 				}
1405
-				if (preg_match('/^\d{8}T(\d{6})$/',$comp['DTSTART'],$matches))
1404
+				if (preg_match('/^\d{8}T(\d{6})$/', $comp['DTSTART'], $matches))
1406 1405
 				{
1407
-					$data[$prefix.'hour'] = (int)substr($matches[1],0,2)+($prefix=='dststart'?-1:1)*$data['dstbias']/60;
1408
-					$data[$prefix.'minute'] = (int)substr($matches[1],2,2)+($prefix=='dststart'?-1:1)*$data['dstbias']%60;
1409
-					$data[$prefix.'second'] = (int)substr($matches[1],4,2);
1406
+					$data[$prefix.'hour'] = (int)substr($matches[1], 0, 2) + ($prefix == 'dststart' ?-1 : 1) * $data['dstbias'] / 60;
1407
+					$data[$prefix.'minute'] = (int)substr($matches[1], 2, 2) + ($prefix == 'dststart' ?-1 : 1) * $data['dstbias'] % 60;
1408
+					$data[$prefix.'second'] = (int)substr($matches[1], 4, 2);
1410 1409
 				}
1411 1410
 			}
1412 1411
 			// for southern hermisphere, were DST is in January, we have to swap start- and end-hour/-minute
1413 1412
 			if ($data['dststartmonth'] > $data['dstendmonth'])
1414 1413
 			{
1415
-				$start = $data['dststarthour'];   $data['dststarthour'] = $data['dstendhour'];     $data['dstendhour'] = $start;
1414
+				$start = $data['dststarthour']; $data['dststarthour'] = $data['dstendhour']; $data['dstendhour'] = $start;
1416 1415
 				$start = $data['dststartminute']; $data['dststartminute'] = $data['dstendminute']; $data['dstendminute'] = $start;
1417 1416
 			}
1418 1417
 		}
@@ -1471,18 +1470,18 @@  discard block
 block discarded – undo
1471 1470
 	 * @param string $component=null
1472 1471
 	 * @return array with parsed ical components
1473 1472
 	 */
1474
-	static public function ical2array(&$ical,$component=null)
1473
+	static public function ical2array(&$ical, $component = null)
1475 1474
 	{
1476 1475
 		$arr = array();
1477 1476
 		if (!is_array($ical)) $ical = preg_split("/[\r\n]+/m", $ical);
1478 1477
 		while (($line = array_shift($ical)))
1479 1478
 		{
1480
-			list($name,$value) = explode(':',$line,2);
1479
+			list($name, $value) = explode(':', $line, 2);
1481 1480
 			if ($name == 'BEGIN')
1482 1481
 			{
1483
-				$arr[$value] = self::ical2array($ical,$value);
1482
+				$arr[$value] = self::ical2array($ical, $value);
1484 1483
 			}
1485
-			elseif($name == 'END')
1484
+			elseif ($name == 'END')
1486 1485
 			{
1487 1486
 				break;
1488 1487
 			}
@@ -1506,13 +1505,13 @@  discard block
 block discarded – undo
1506 1505
 	 */
1507 1506
 	public static function as2tz(array $data)
1508 1507
 	{
1509
-		static $cache;	// some caching withing the request
1508
+		static $cache; // some caching withing the request
1510 1509
 
1511
-		unset($data['name']);	// not used, but can stall the match
1510
+		unset($data['name']); // not used, but can stall the match
1512 1511
 
1513 1512
 		$key = serialize($data);
1514 1513
 
1515
-		for($n = 0; !isset($cache[$key]); ++$n)
1514
+		for ($n = 0; !isset($cache[$key]); ++$n)
1516 1515
 		{
1517 1516
 			if (!$n)	// check users timezone first
1518 1517
 			{
@@ -1531,7 +1530,7 @@  discard block
 block discarded – undo
1531 1530
 					break;
1532 1531
 				}
1533 1532
 			}
1534
-			catch(Exception $e) {
1533
+			catch (Exception $e) {
1535 1534
 				// simpy ignore that, as it only means $tz can NOT be converted, because it has no VTIMEZONE component
1536 1535
 			}
1537 1536
 		}
@@ -1545,8 +1544,8 @@  discard block
 block discarded – undo
1545 1544
 	 */
1546 1545
 	static public function _getTZFromSyncBlob($data)
1547 1546
 	{
1548
-		$tz = unpack(	"lbias/a64name/vdstendyear/vdstendmonth/vdstendday/vdstendweek/vdstendhour/vdstendminute/vdstendsecond/vdstendmillis/" .
1549
-						"lstdbias/a64name/vdststartyear/vdststartmonth/vdststartday/vdststartweek/vdststarthour/vdststartminute/vdststartsecond/vdststartmillis/" .
1547
+		$tz = unpack("lbias/a64name/vdstendyear/vdstendmonth/vdstendday/vdstendweek/vdstendhour/vdstendminute/vdstendsecond/vdstendmillis/".
1548
+						"lstdbias/a64name/vdststartyear/vdststartmonth/vdststartday/vdststartweek/vdststarthour/vdststartminute/vdststartsecond/vdststartmillis/".
1550 1549
 						"ldstbias", $data);
1551 1550
 
1552 1551
 		return $tz;
@@ -1559,7 +1558,7 @@  discard block
 block discarded – undo
1559 1558
 	 */
1560 1559
 	static public function _getSyncBlobFromTZ($tz)
1561 1560
 	{
1562
-		$packed = pack("la64vvvvvvvv" . "la64vvvvvvvv" . "l",
1561
+		$packed = pack("la64vvvvvvvv"."la64vvvvvvvv"."l",
1563 1562
 				$tz["bias"], "", 0, $tz["dstendmonth"], $tz["dstendday"], $tz["dstendweek"], $tz["dstendhour"], $tz["dstendminute"], $tz["dstendsecond"], $tz["dstendmillis"],
1564 1563
 				$tz["stdbias"], "", 0, $tz["dststartmonth"], $tz["dststartday"], $tz["dststartweek"], $tz["dststarthour"], $tz["dststartminute"], $tz["dststartsecond"], $tz["dststartmillis"],
1565 1564
 				$tz["dstbias"]);
@@ -1583,7 +1582,7 @@  discard block
 block discarded – undo
1583 1582
 				$account_id = $entry['grantor'];
1584 1583
 				$cals[$account_id] = $entry['name'];
1585 1584
 			}
1586
-			if ($hook_data['account_id'] > 0) unset($cals[$hook_data['account_id']]);	// skip current user
1585
+			if ($hook_data['account_id'] > 0) unset($cals[$hook_data['account_id']]); // skip current user
1587 1586
 		}
1588 1587
 		$cals['G'] = lang('Primary group');
1589 1588
 		$cals['A'] = lang('All');
@@ -1619,8 +1618,8 @@  discard block
 block discarded – undo
1619 1618
 		)
1620 1619
 	);
1621 1620
 	require_once('../../header.inc.php');
1622
-	ini_set('display_errors',1);
1623
-	error_reporting(E_ALL & ~E_NOTICE);
1621
+	ini_set('display_errors', 1);
1622
+	error_reporting(E_ALL&~E_NOTICE);
1624 1623
 
1625 1624
 	echo "<html><head><title>Conversation of ActiveSync Timezone Blobs to TZID's</title></head>\n<body>\n";
1626 1625
 	echo "<h3>Conversation of ActiveSync Timezone Blobs to TZID's</h3>\n";
@@ -1634,7 +1633,7 @@  discard block
 block discarded – undo
1634 1633
 	</script>\n";
1635 1634
 
1636 1635
 	// TZID => AS timezone blobs reported by various devices
1637
-	foreach(array(
1636
+	foreach (array(
1638 1637
 		'Europe/Berlin'    => 'xP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAoAAAAFAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAMAAAAAAAAAxP///w==',
1639 1638
 		'Europe/Helsinki'  => 'iP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAoAAAAFAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAFAAQAAAAAAAAAxP///w==',
1640 1639
 		'Asia/Tokyo'       => '5P3//wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAxP///w==',
@@ -1647,9 +1646,9 @@  discard block
 block discarded – undo
1647 1646
 	) as $tz => $sync_blob)
1648 1647
 	{
1649 1648
 		// get as timezone data for a given timezone
1650
-		$ical = calendar_timezones::tz2id($tz,'component');
1649
+		$ical = calendar_timezones::tz2id($tz, 'component');
1651 1650
 		//echo "<pre>".print_r($ical,true)."</pre>\n";
1652
-		$ical_arr = calendar_activesync::ical2array($ical_tz=$ical);
1651
+		$ical_arr = calendar_activesync::ical2array($ical_tz = $ical);
1653 1652
 		//echo "<pre>".print_r($ical_arr,true)."</pre>\n";
1654 1653
 		$as_tz = calendar_activesync::tz2as($tz);
1655 1654
 		//echo "$tz=<pre>".print_r($as_tz,true)."</pre>\n";
@@ -1663,22 +1662,22 @@  discard block
 block discarded – undo
1663 1662
 		//echo array2string($matched);
1664 1663
 
1665 1664
 		echo "<tr><td><b onclick='toggle_display(this.nextSibling);' style='cursor:pointer;'>$tz</b><pre style='margin:0; font-size: 90%; display:none;'>$ical</pre></td><td>$as_tz_org[bias]<br/>$as_tz[bias]</td><td>$as_tz_org[dstbias]<br/>$as_tz[dstbias]</td>\n";
1666
-		foreach(array('dststart','dstend') as $prefix)
1665
+		foreach (array('dststart', 'dstend') as $prefix)
1667 1666
 		{
1668 1667
 			echo "<td>\n";
1669
-			foreach(array($as_tz_org,$as_tz) as $n => $arr)
1668
+			foreach (array($as_tz_org, $as_tz) as $n => $arr)
1670 1669
 			{
1671 1670
 				$parts = array();
1672
-				foreach(array('year','month','day','week','hour','minute','second') as $postfix)
1671
+				foreach (array('year', 'month', 'day', 'week', 'hour', 'minute', 'second') as $postfix)
1673 1672
 				{
1674 1673
 					$failed = $n && $as_tz_org[$prefix.$postfix] !== $as_tz[$prefix.$postfix];
1675
-					$parts[] = ($failed?'<font color="red">':'').$arr[$prefix.$postfix].($failed?'</font>':'');
1674
+					$parts[] = ($failed ? '<font color="red">' : '').$arr[$prefix.$postfix].($failed ? '</font>' : '');
1676 1675
 				}
1677
-				echo implode(' ', $parts).(!$n?'<br/>':'');
1676
+				echo implode(' ', $parts).(!$n ? '<br/>' : '');
1678 1677
 			}
1679 1678
 			echo "</td>\n";
1680 1679
 		}
1681
-		echo "<td>&nbsp;<br/>".($matched=='UTC'?'<font color="red">':'').$matched.($matched=='UTC'?'</font>':'')."</td></tr>\n";
1680
+		echo "<td>&nbsp;<br/>".($matched == 'UTC' ? '<font color="red">' : '').$matched.($matched == 'UTC' ? '</font>' : '')."</td></tr>\n";
1682 1681
 	}
1683 1682
 	echo "</tbody></table>\n";
1684 1683
 	echo "</body></html>\n";
Please login to merge, or discard this patch.
Braces   +223 added lines, -54 removed lines patch added patch discarded remove patch
@@ -17,8 +17,12 @@  discard block
 block discarded – undo
17 17
  */
18 18
 if (isset($_SERVER['SCRIPT_FILENAME']) && $_SERVER['SCRIPT_FILENAME'] == __FILE__)
19 19
 {
20
-	interface activesync_plugin_write {}
21
-	interface activesync_plugin_meeting_requests {}
20
+	interface activesync_plugin_write
21
+	{
22
+}
23
+	interface activesync_plugin_meeting_requests
24
+	{
25
+}
22 26
 }
23 27
 
24 28
 /**
@@ -78,7 +82,10 @@  discard block
 block discarded – undo
78 82
 	 */
79 83
 	public function GetFolderList()
80 84
 	{
81
-		if (!isset($this->calendar)) $this->calendar = new calendar_boupdate();
85
+		if (!isset($this->calendar))
86
+		{
87
+			$this->calendar = new calendar_boupdate();
88
+		}
82 89
 
83 90
 		$cals = $GLOBALS['egw_info']['user']['preferences']['activesync']['calendar-cals'];
84 91
 		$cals = $cals ? explode(',',$cals) : array('P');	// implicit default of 'P'
@@ -177,12 +184,19 @@  discard block
 block discarded – undo
177 184
   	 */
178 185
 	function GetMessageList($id, $cutoffdate=NULL, array $not_uids=null)
179 186
 	{
180
-		if (!isset($this->calendar)) $this->calendar = new calendar_boupdate();
187
+		if (!isset($this->calendar))
188
+		{
189
+			$this->calendar = new calendar_boupdate();
190
+		}
181 191
 
182 192
 		debugLog (__METHOD__."('$id',$cutoffdate)");
183 193
 		$this->backend->splitID($id,$type,$user);
184 194
 
185
-		if (!$cutoffdate) $cutoffdate = $this->bo->now - 100*24*3600;	// default three month back -30 breaks all sync recurrences
195
+		if (!$cutoffdate)
196
+		{
197
+			$cutoffdate = $this->bo->now - 100*24*3600;
198
+		}
199
+		// default three month back -30 breaks all sync recurrences
186 200
 
187 201
 		$filter = array(
188 202
 			'users' => $user,
@@ -201,7 +215,10 @@  discard block
 block discarded – undo
201 215
 		$messagelist = array();
202 216
 		foreach ($this->calendar->search($filter) as $event)
203 217
 		{
204
-			if ($not_uids && in_array($event['uid'], $not_uids)) continue;
218
+			if ($not_uids && in_array($event['uid'], $not_uids))
219
+			{
220
+				continue;
221
+			}
205 222
 			$messagelist[] = $this->StatMessage($id, $event);
206 223
 
207 224
 			// add virtual exceptions for recuring events too
@@ -271,7 +288,10 @@  discard block
 block discarded – undo
271 288
 	 */
272 289
 	function GetMeetingRequest($id, $truncsize, $bodypreference=false, $optionbodypreference=false, $mimesupport = 0)
273 290
 	{
274
-		if (!isset($this->calendar)) $this->calendar = new calendar_boupdate();
291
+		if (!isset($this->calendar))
292
+		{
293
+			$this->calendar = new calendar_boupdate();
294
+		}
275 295
 
276 296
 		if (!($event = $this->calendar->read(abs($id), 0, false, 'server')))
277 297
 		{
@@ -348,7 +368,10 @@  discard block
 block discarded – undo
348 368
 			'created' => 'dtstamp',
349 369
 		) as $key => $attr)
350 370
 		{
351
-			if (!empty($event[$key])) $message->$attr = $event[$key];
371
+			if (!empty($event[$key]))
372
+			{
373
+				$message->$attr = $event[$key];
374
+			}
352 375
 		}
353 376
 		if (($message->alldayevent = (int)calendar_bo::isWholeDay($event)))
354 377
 		{
@@ -360,7 +383,10 @@  discard block
 block discarded – undo
360 383
 			'location' => 'location',
361 384
 		) as $key => $attr)
362 385
 		{
363
-			if (!empty($event[$key])) $message->$attr = $event[$key];
386
+			if (!empty($event[$key]))
387
+			{
388
+				$message->$attr = $event[$key];
389
+			}
364 390
 		}
365 391
 		$message->organizer = $event['organizer'];
366 392
 
@@ -395,7 +421,10 @@  discard block
 block discarded – undo
395 421
 	 */
396 422
 	function MeetingResponse($folderid, $requestid, $response)
397 423
 	{
398
-		if (!isset($this->calendar)) $this->calendar = new calendar_boupdate();
424
+		if (!isset($this->calendar))
425
+		{
426
+			$this->calendar = new calendar_boupdate();
427
+		}
399 428
 
400 429
 		static $as2status = array(	// different from self::$status2as!
401 430
 			1 => 'A',
@@ -405,9 +434,12 @@  discard block
 block discarded – undo
405 434
 		$status = isset($as2status[$response]) ? $as2status[$response] : 'U';
406 435
 		$uid = $GLOBALS['egw_info']['user']['account_id'];
407 436
 
408
-		if (!is_numeric($requestid))	// iCal from fmail
437
+		if (!is_numeric($requestid))
438
+		{
439
+			// iCal from fmail
409 440
 		{
410 441
 			$ical = new calendar_ical();
442
+		}
411 443
 			if (!($events = $ical->icaltoegw($requestid, '', 'utf-8')) || count($events) != 1)
412 444
 			{
413 445
 				debugLog(__METHOD__."('$event') error parsing iCal!");
@@ -513,7 +545,10 @@  discard block
 block discarded – undo
513 545
 	 */
514 546
 	public function ChangeMessage($folderid, $id, $message)
515 547
 	{
516
-		if (!isset($this->calendar)) $this->calendar = new calendar_boupdate();
548
+		if (!isset($this->calendar))
549
+		{
550
+			$this->calendar = new calendar_boupdate();
551
+		}
517 552
 
518 553
 		$event = array();
519 554
 		$this->backend->splitID($folderid, $type, $account);
@@ -527,10 +562,13 @@  discard block
 block discarded – undo
527 562
 			debugLog(__METHOD__."('$folderid',$id,...) Folder wrong or event does not existing");
528 563
 			return false;
529 564
 		}
530
-		if ($recur_date)	// virtual exception
565
+		if ($recur_date)
566
+		{
567
+			// virtual exception
531 568
 		{
532 569
 			// @todo check if virtual exception needs to be saved as real exception, or only stati need to be changed
533 570
 			debugLog(__METHOD__."('$folderid',$id:$recur_date,".array2string($message).") handling of virtual exception not yet implemented!");
571
+		}
534 572
 			error_log(__METHOD__."('$folderid',$id:$recur_date,".array2string($message).") handling of virtual exception not yet implemented!");
535 573
 		}
536 574
 		if (!$this->calendar->check_perms($id ? EGW_ACL_EDIT : EGW_ACL_ADD,$event ? $event : 0,$account))
@@ -540,7 +578,11 @@  discard block
 block discarded – undo
540 578
 			error_log(__METHOD__."('$folderid',$id,".array2string($message).") no rights to add/edit event!");
541 579
 			return false;
542 580
 		}
543
-		if (!$id) $event['owner'] = $account;	// we do NOT allow to change the owner of existing events
581
+		if (!$id)
582
+		{
583
+			$event['owner'] = $account;
584
+		}
585
+		// we do NOT allow to change the owner of existing events
544 586
 
545 587
 		$event = $this->message2event($message, $account, $event);
546 588
 
@@ -566,7 +608,10 @@  discard block
 block discarded – undo
566 608
 					$ex_event = $event;
567 609
 					unset($ex_event['id']);
568 610
 					unset($ex_event['etag']);
569
-					foreach($ex_event as $name => $value) if (substr($name,0,6) == 'recur_') unset($ex_event[$name]);
611
+					foreach($ex_event as $name => $value)
612
+					{
613
+						if (substr($name,0,6) == 'recur_') unset($ex_event[$name]);
614
+					}
570 615
 					$ex_event['recur_type'] = calendar_rrule::NONE;
571 616
 
572 617
 					if ($event['id'] && ($ex_events = $this->calendar->search(array(
@@ -618,7 +663,10 @@  discard block
 block discarded – undo
618 663
 			'end' => 'endtime',
619 664
 		) as $key => $attr)
620 665
 		{
621
-			if (isset($message->$attr)) $event[$key] = egw_time::server2user($message->$attr);
666
+			if (isset($message->$attr))
667
+			{
668
+				$event[$key] = egw_time::server2user($message->$attr);
669
+			}
622 670
 		}
623 671
 		// copying strings
624 672
 		foreach(array(
@@ -627,7 +675,10 @@  discard block
 block discarded – undo
627 675
 			'location' => 'location',
628 676
 		) as $key => $attr)
629 677
 		{
630
-			if (isset($message->$attr)) $event[$key] = $message->$attr;
678
+			if (isset($message->$attr))
679
+			{
680
+				$event[$key] = $message->$attr;
681
+			}
631 682
 		}
632 683
 
633 684
 		// only change description, if one given, as iOS5 skips description in ChangeMessage after MeetingResponse
@@ -646,14 +697,22 @@  discard block
 block discarded – undo
646 697
 
647 698
 		if (($event['whole_day'] = $message->alldayevent))
648 699
 		{
649
-			if ($event['end'] == $event['start']) $event['end'] += 24*3600;	// some clients send equal start&end for 1day
700
+			if ($event['end'] == $event['start'])
701
+			{
702
+				$event['end'] += 24*3600;
703
+			}
704
+			// some clients send equal start&end for 1day
650 705
 			$event['end']--;	// otherwise our whole-day event code in save makes it one more day!
651 706
 		}
652 707
 
653 708
 		$participants = array();
654 709
 		foreach((array)$message->attendees as $attendee)
655 710
 		{
656
-			if ($attendee->type == 3) continue;	// we can not identify resources and re-add them anyway later
711
+			if ($attendee->type == 3)
712
+			{
713
+				continue;
714
+			}
715
+			// we can not identify resources and re-add them anyway later
657 716
 
658 717
 			if (preg_match('/^noreply-(.*)[email protected]$/',$attendee->email,$matches))
659 718
 			{
@@ -667,7 +726,10 @@  discard block
 block discarded – undo
667 726
 					//'n_fn' => $attendee->name,	// not sure if we want matches without email
668 727
 				);
669 728
 				// search addressbook for participant
670
-				if (!isset($this->addressbook)) $this->addressbook = new addressbook_bo();
729
+				if (!isset($this->addressbook))
730
+				{
731
+					$this->addressbook = new addressbook_bo();
732
+				}
671 733
 				if ((list($data) = $this->addressbook->search($search,
672 734
 					array('id','egw_addressbook.account_id as account_id','n_fn'),
673 735
 					'egw_addressbook.account_id IS NOT NULL DESC, n_fn IS NOT NULL DESC',
@@ -675,10 +737,13 @@  discard block
 block discarded – undo
675 737
 				{
676 738
 					$uid = $data['account_id'] ? (int)$data['account_id'] : 'c'.$data['id'];
677 739
 				}
678
-				elseif($attendee->name === $attendee->email || empty($attendee->name))	// dont store empty or email as name
740
+				elseif($attendee->name === $attendee->email || empty($attendee->name))
741
+				{
742
+					// dont store empty or email as name
679 743
 				{
680 744
 					$uid = 'e'.$attendee->email;
681 745
 				}
746
+				}
682 747
 				else	// store just the email
683 748
 				{
684 749
 					$uid = 'e'.$attendee->name.' <'.$attendee->email.'>';
@@ -706,7 +771,11 @@  discard block
 block discarded – undo
706 771
 				$role = 'REQ-PARTICIPANT';
707 772
 				//debugLog("default status for $uid is status=$status, quantity=$quantitiy, role=$role");
708 773
 			}
709
-			if ($role == 'CHAIR') $chair_set = true;	// by role from existing participant
774
+			if ($role == 'CHAIR')
775
+			{
776
+				$chair_set = true;
777
+			}
778
+			// by role from existing participant
710 779
 
711 780
 			if (isset($attendee->attendeestatus) && ($s = array_search($attendee->attendeestatus,self::$status2as)))
712 781
 			{
@@ -720,10 +789,13 @@  discard block
 block discarded – undo
720 789
 			elseif (isset($attendee->attendeetype) &&
721 790
 				!($role == 'CHAIR' && !is_numeric($uid)) &&	// do not override our external ORGANIZER
722 791
 				($r = array_search($attendee->attendeetype,self::$role2as)) &&
723
-				(int)self::$role2as[$role] != $attendee->attendeetype)	// if old role gives same type, use old role, as we have a lot more roles then AS
792
+				(int)self::$role2as[$role] != $attendee->attendeetype)
793
+			{
794
+				// if old role gives same type, use old role, as we have a lot more roles then AS
724 795
 			{
725 796
 				$role = $r;
726 797
 			}
798
+			}
727 799
 			//debugLog("-> status for $uid is status=$status ($s), quantity=$quantitiy, role=$role ($r)");
728 800
 			$participants[$uid] = calendar_so::combine_status($status,$quantitiy,$role);
729 801
 		}
@@ -738,12 +810,19 @@  discard block
 block discarded – undo
738 810
 		// $account is also preserved, as AS does not add him as participant!
739 811
 		foreach((array)$event['participant_types'] as $type => $parts)
740 812
 		{
741
-			if (in_array($type,array('c','e'))) continue;	// they are correctly representable in AS
813
+			if (in_array($type,array('c','e')))
814
+			{
815
+				continue;
816
+			}
817
+			// they are correctly representable in AS
742 818
 
743 819
 			foreach($parts as $id => $status)
744 820
 			{
745 821
 				// accounts are represented correctly, but the event owner which is no participant in AS
746
-				if ($type == 'u' && $id != $account) continue;
822
+				if ($type == 'u' && $id != $account)
823
+				{
824
+					continue;
825
+				}
747 826
 
748 827
 				$uid = calendar_so::combine_user($type, $id);
749 828
 				if (!isset($participants[$uid]))
@@ -768,10 +847,13 @@  discard block
 block discarded – undo
768 847
 		// check if event is recurring and import recur information (incl. timezone)
769 848
 		if ($message->recurrence)
770 849
 		{
771
-			if ($message->timezone && !$event['id'])	// dont care for timezone, if no new and recurring event
850
+			if ($message->timezone && !$event['id'])
851
+			{
852
+				// dont care for timezone, if no new and recurring event
772 853
 			{
773 854
 				$event['tzid'] = self::as2tz(self::_getTZFromSyncBlob(base64_decode($message->timezone)));
774 855
 			}
856
+			}
775 857
 			$event['recur_type'] = $message->recurrence->type == 6 ? calendar_rrule::YEARLY :
776 858
 				array_search($message->recurrence->type, self::$recur_type2as);
777 859
 			$event['recur_interval'] = $message->recurrence->interval;
@@ -808,10 +890,13 @@  discard block
 block discarded – undo
808 890
 			{
809 891
 				// calculate enddate from occurences count, as we only support enddate
810 892
 				$count = $message->recurrence->occurrences;
811
-				foreach(calendar_rrule::event2rrule($event, true) as $rtime)	// true = timestamps are user time here, because of save!
893
+				foreach(calendar_rrule::event2rrule($event, true) as $rtime)
894
+				{
895
+					// true = timestamps are user time here, because of save!
812 896
 				{
813 897
 					if (--$count <= 0) break;
814 898
 				}
899
+				}
815 900
 				$event['recur_enddate'] = $rtime->format('ts');
816 901
 			}
817 902
 		}
@@ -826,7 +911,9 @@  discard block
 block discarded – undo
826 911
 					break;
827 912
 				}
828 913
 			}
829
-			if ($alarm !== true)	// new alarm
914
+			if ($alarm !== true)
915
+			{
916
+				// new alarm
830 917
 			{
831 918
 				// delete all earlier alarms of that user
832 919
 				// user get's per AS only the earliest alarm, as AS only supports one alarm
@@ -836,6 +923,7 @@  discard block
 block discarded – undo
836 923
 					if ($alarm['owner'] == $account && $alarm['offset'] > 60*$message->reminder)
837 924
 					{
838 925
 						unset($event['alarm'][$key]);
926
+			}
839 927
 					}
840 928
 				}
841 929
 				$event['alarm'][] = $alarm = array(
@@ -912,7 +1000,10 @@  discard block
 block discarded – undo
912 1000
 	 */
913 1001
 	public function DeleteMessage($folderid, $id)
914 1002
 	{
915
-		if (!isset($this->caledar)) $this->calendar = new calendar_boupdate();
1003
+		if (!isset($this->caledar))
1004
+		{
1005
+			$this->calendar = new calendar_boupdate();
1006
+		}
916 1007
 
917 1008
 		$ret = $this->calendar->delete($id);
918 1009
 		debugLog(__METHOD__."('$folderid', $id) delete($id) returned ".array2string($ret));
@@ -965,7 +1056,10 @@  discard block
 block discarded – undo
965 1056
 	 */
966 1057
 	public function GetMessage($folderid, $id, $truncsize, $bodypreference=false, $optionbodypreference=false, $mimesupport = 0)
967 1058
 	{
968
-		if (!isset($this->calendar)) $this->calendar = new calendar_boupdate();
1059
+		if (!isset($this->calendar))
1060
+		{
1061
+			$this->calendar = new calendar_boupdate();
1062
+		}
969 1063
 
970 1064
 		debugLog (__METHOD__."('$folderid', ".array2string($id).", truncsize=$truncsize, bodyprefence=$bodypreference, mimesupport=$mimesupport)");
971 1065
 		$this->backend->splitID($folderid, $type, $account);
@@ -984,7 +1078,10 @@  discard block
 block discarded – undo
984 1078
 			}
985 1079
 		}
986 1080
 		debugLog(__METHOD__."($folderid,$id,...) start=$event[start]=".date('Y-m-d H:i:s',$event['start']).", recurrence=$event[recurrence]=".date('Y-m-d H:i:s',$event['recurrence']));
987
-		foreach($event['recur_exception'] as $ex) debugLog("exception=$ex=".date('Y-m-d H:i:s',$ex));
1081
+		foreach($event['recur_exception'] as $ex)
1082
+		{
1083
+			debugLog("exception=$ex=".date('Y-m-d H:i:s',$ex));
1084
+		}
988 1085
 
989 1086
 		$message = new SyncAppointment();
990 1087
 
@@ -1004,7 +1101,10 @@  discard block
 block discarded – undo
1004 1101
 			'modified' => 'dtstamp',
1005 1102
 		) as $key => $attr)
1006 1103
 		{
1007
-			if (!empty($event[$key])) $message->$attr = $event[$key];
1104
+			if (!empty($event[$key]))
1105
+			{
1106
+				$message->$attr = $event[$key];
1107
+			}
1008 1108
 		}
1009 1109
 		if (($message->alldayevent = (int)calendar_bo::isWholeDay($event)))
1010 1110
 		{
@@ -1017,7 +1117,10 @@  discard block
 block discarded – undo
1017 1117
 			'location' => 'location',
1018 1118
 		) as $key => $attr)
1019 1119
 		{
1020
-			if (!empty($event[$key])) $message->$attr = $event[$key];
1120
+			if (!empty($event[$key]))
1121
+			{
1122
+				$message->$attr = $event[$key];
1123
+			}
1021 1124
 		}
1022 1125
 
1023 1126
 		// appoint description
@@ -1051,7 +1154,10 @@  discard block
 block discarded – undo
1051 1154
 		foreach($event['participants'] as $uid => $status)
1052 1155
 		{
1053 1156
 			// AS does NOT want calendar owner as participant
1054
-			if ($uid == $account) continue;
1157
+			if ($uid == $account)
1158
+			{
1159
+				continue;
1160
+			}
1055 1161
 			calendar_so::split_status($status, $quantity, $role);
1056 1162
 
1057 1163
 			$attendee = new SyncAttendee();
@@ -1067,7 +1173,10 @@  discard block
 block discarded – undo
1067 1173
 				list($info) = $i = $this->calendar->resources[$uid[0]]['info'] ?
1068 1174
 					ExecMethod($this->calendar->resources[$uid[0]]['info'],substr($uid,1)) : array(false);
1069 1175
 
1070
-				if (!$info) continue;
1176
+				if (!$info)
1177
+				{
1178
+					continue;
1179
+				}
1071 1180
 
1072 1181
 				if (!$info['email'] && $info['responsible'])
1073 1182
 				{
@@ -1083,10 +1192,17 @@  discard block
 block discarded – undo
1083 1192
 					$message->organizeremail = $attendee->email;
1084 1193
 					debugLog(__METHOD__."($folderid, $id, ...) external organizer detected (role=$role, uid=$uid), set as AS organizer: $message->organizername <$message->organizeremail>");
1085 1194
 				}
1086
-				if ($uid[0] == 'r') $attendee->type = 3;	// 3 = resource
1195
+				if ($uid[0] == 'r')
1196
+				{
1197
+					$attendee->type = 3;
1198
+				}
1199
+				// 3 = resource
1087 1200
 			}
1088 1201
 			// email must NOT be empty, but MAY be an arbitrary text
1089
-			if (empty($attendee->email)) $attendee->email = 'noreply-'.$uid.'[email protected]';
1202
+			if (empty($attendee->email))
1203
+			{
1204
+				$attendee->email = 'noreply-'.$uid.'[email protected]';
1205
+			}
1090 1206
 
1091 1207
 			$message->attendees[] = $attendee;
1092 1208
 		}
@@ -1121,9 +1237,12 @@  discard block
 block discarded – undo
1121 1237
 					$recurrence->monthofyear = (int)$rrule->time->format('m');	// 1..12
1122 1238
 					break;
1123 1239
 			}
1124
-			if ($rrule->enddate)	// enddate is only a date, but AS needs a time incl. correct starttime!
1240
+			if ($rrule->enddate)
1241
+			{
1242
+				// enddate is only a date, but AS needs a time incl. correct starttime!
1125 1243
 			{
1126 1244
 				$enddate = clone $rrule->time;
1245
+			}
1127 1246
 				$enddate->setDate($rrule->enddate->format('Y'), $rrule->enddate->format('m'),
1128 1247
 					$rrule->enddate->format('d'));
1129 1248
 				$recurrence->until = $enddate->format('server');
@@ -1145,12 +1264,19 @@  discard block
 block discarded – undo
1145 1264
 				{
1146 1265
 					debugLog(__METHOD__.__LINE__." Exceptions found but no UID given for Event:".$event['id'].' Exceptions:'.array2string($event['recur_exception']));
1147 1266
 				}
1148
-				if (count($ex_events)>=1) debugLog(__METHOD__.__LINE__." found ".count($ex_events)." exeptions for event with UID/ID:".$event['uid'].'/'.$event['id']);
1267
+				if (count($ex_events)>=1)
1268
+				{
1269
+					debugLog(__METHOD__.__LINE__." found ".count($ex_events)." exeptions for event with UID/ID:".$event['uid'].'/'.$event['id']);
1270
+				}
1149 1271
 
1150 1272
 				$message->exceptions = array();
1151 1273
 				foreach($ex_events as $ex_event)
1152 1274
 				{
1153
-					if ($ex_event['id'] == $event['id']) continue;	// ignore series master
1275
+					if ($ex_event['id'] == $event['id'])
1276
+					{
1277
+						continue;
1278
+					}
1279
+					// ignore series master
1154 1280
 					$exception = $this->GetMessage($folderid, $ex_event, $truncsize, $bodypreference, $mimesupport);
1155 1281
 					$exception->exceptionstarttime = $exception_time = $ex_event['recurrence'];
1156 1282
 					foreach(array('attendees','recurrence','uid','timezone','organizername','organizeremail') as $not_supported)
@@ -1170,7 +1296,10 @@  discard block
 block discarded – undo
1170 1296
 				{
1171 1297
 					if (!empty($exception_time))
1172 1298
 					{
1173
-						if (empty($event['uid'])) debugLog(__METHOD__.__LINE__." BEWARE no UID given for this event:".$event['id'].' but exception is set for '.$exception_time);
1299
+						if (empty($event['uid']))
1300
+						{
1301
+							debugLog(__METHOD__.__LINE__." BEWARE no UID given for this event:".$event['id'].' but exception is set for '.$exception_time);
1302
+						}
1174 1303
 						$exception = new SyncAppointment();	// exceptions seems to be full SyncAppointments, with only starttime required
1175 1304
 						$exception->deleted = 1;
1176 1305
 						$exception->exceptionstarttime = $exception_time;
@@ -1224,11 +1353,17 @@  discard block
 block discarded – undo
1224 1353
 	 */
1225 1354
 	public function StatMessage($folderid, $id)
1226 1355
 	{
1227
-		if (!isset($this->calendar)) $this->calendar = new calendar_boupdate();
1356
+		if (!isset($this->calendar))
1357
+		{
1358
+			$this->calendar = new calendar_boupdate();
1359
+		}
1228 1360
 
1229
-		if (!($etag = $this->calendar->get_etag($id, $nul, true, true)))	// last true: $only_master=true
1361
+		if (!($etag = $this->calendar->get_etag($id, $nul, true, true)))
1362
+		{
1363
+			// last true: $only_master=true
1230 1364
 		{
1231 1365
 			$stat = false;
1366
+		}
1232 1367
 			// error_log why access is denied (should never happen for everything returned by calendar_bo::search)
1233 1368
 			$backup = $this->calendar->debug;
1234 1369
 			//$this->calendar->debug = 2;
@@ -1263,13 +1398,22 @@  discard block
 block discarded – undo
1263 1398
 		$this->backend->splitID($folderid, $type, $owner);
1264 1399
 		debugLog(__METHOD__."('$folderid','$syncstate') type='$type', owner=$owner");
1265 1400
 
1266
-		if ($type != 'calendar') return false;
1401
+		if ($type != 'calendar')
1402
+		{
1403
+			return false;
1404
+		}
1267 1405
 
1268
-		if (!isset($this->calendar)) $this->calendar = new calendar_boupdate();
1406
+		if (!isset($this->calendar))
1407
+		{
1408
+			$this->calendar = new calendar_boupdate();
1409
+		}
1269 1410
 		//$ctag = $this->calendar->get_ctag($owner,'owner',true);	// true only consider recurrence master
1270 1411
 		$ctag = $this->calendar->get_ctag($owner,false,true); // we only want to fetch the owners events, where he is a participant too
1271 1412
 		// workaround for syncstate = 0 when calendar is empty causes synctate to not return 0 but array resulting in foldersync loop
1272
-		if ($ctag == 0) $ctag = 1;
1413
+		if ($ctag == 0)
1414
+		{
1415
+			$ctag = 1;
1416
+		}
1273 1417
 		$changes = array();	// no change
1274 1418
 		$syncstate_was = $syncstate;
1275 1419
 
@@ -1351,7 +1495,10 @@  discard block
 block discarded – undo
1351 1495
 		);
1352 1496
 
1353 1497
 		$name = $component = is_a($tz,'DateTimeZone') ? $tz->getName() : $tz;
1354
-		if (strpos($component, 'VTIMEZONE') === false) $component = calendar_timezones::tz2id($name,'component');
1498
+		if (strpos($component, 'VTIMEZONE') === false)
1499
+		{
1500
+			$component = calendar_timezones::tz2id($name,'component');
1501
+		}
1355 1502
 		// parse ical timezone defintion
1356 1503
 		$ical = self::ical2array($ical=$component);
1357 1504
 		$standard = $ical['VTIMEZONE']['STANDARD'];
@@ -1393,11 +1540,17 @@  discard block
 block discarded – undo
1393 1540
 						$data[$prefix.'week'] = 5;
1394 1541
 					}
1395 1542
 					// if both start and end use 1SU use week=5 and decrement month
1396
-					if ($prefix == 'dststart') $start_byday = $matches[1];
1543
+					if ($prefix == 'dststart')
1544
+					{
1545
+						$start_byday = $matches[1];
1546
+					}
1397 1547
 					if ($prefix == 'dstend' && $matches[1] == '1SU' && $start_byday == '1SU')
1398 1548
 					{
1399 1549
 						$data[$prefix.'week'] = 5;
1400
-						if ($prefix == 'dstend') $data[$prefix.'month'] -= 1;
1550
+						if ($prefix == 'dstend')
1551
+						{
1552
+							$data[$prefix.'month'] -= 1;
1553
+						}
1401 1554
 					}
1402 1555
 					static $day2int = array('SU'=>0,'MO'=>1,'TU'=>2,'WE'=>3,'TH'=>4,'FR'=>5,'SA'=>6);
1403 1556
 					$data[$prefix.'day'] = (int)$day2int[substr($matches[1],-2)];
@@ -1474,7 +1627,10 @@  discard block
 block discarded – undo
1474 1627
 	static public function ical2array(&$ical,$component=null)
1475 1628
 	{
1476 1629
 		$arr = array();
1477
-		if (!is_array($ical)) $ical = preg_split("/[\r\n]+/m", $ical);
1630
+		if (!is_array($ical))
1631
+		{
1632
+			$ical = preg_split("/[\r\n]+/m", $ical);
1633
+		}
1478 1634
 		while (($line = array_shift($ical)))
1479 1635
 		{
1480 1636
 			list($name,$value) = explode(':',$line,2);
@@ -1514,13 +1670,19 @@  discard block
 block discarded – undo
1514 1670
 
1515 1671
 		for($n = 0; !isset($cache[$key]); ++$n)
1516 1672
 		{
1517
-			if (!$n)	// check users timezone first
1673
+			if (!$n)
1674
+			{
1675
+				// check users timezone first
1518 1676
 			{
1519 1677
 				$tz = egw_time::$user_timezone->getName();
1520 1678
 			}
1521
-			elseif (!($tz = calendar_timezones::id2tz($n)))	// no further timezones to check
1679
+			}
1680
+			elseif (!($tz = calendar_timezones::id2tz($n)))
1681
+			{
1682
+				// no further timezones to check
1522 1683
 			{
1523 1684
 				$cache[$key] = 'UTC';
1685
+			}
1524 1686
 				error_log(__METHOD__.'('.array2string($data).') NO matching timezone found --> using UTC now!');
1525 1687
 				break;
1526 1688
 			}
@@ -1583,7 +1745,11 @@  discard block
 block discarded – undo
1583 1745
 				$account_id = $entry['grantor'];
1584 1746
 				$cals[$account_id] = $entry['name'];
1585 1747
 			}
1586
-			if ($hook_data['account_id'] > 0) unset($cals[$hook_data['account_id']]);	// skip current user
1748
+			if ($hook_data['account_id'] > 0)
1749
+			{
1750
+				unset($cals[$hook_data['account_id']]);
1751
+			}
1752
+			// skip current user
1587 1753
 		}
1588 1754
 		$cals['G'] = lang('Primary group');
1589 1755
 		$cals['A'] = lang('All');
@@ -1611,13 +1777,16 @@  discard block
 block discarded – undo
1611 1777
  *
1612 1778
  * You need to comment implements activesync_plugin_write
1613 1779
  */
1614
-if (isset($_SERVER['SCRIPT_FILENAME']) && $_SERVER['SCRIPT_FILENAME'] == __FILE__)	// some tests
1780
+if (isset($_SERVER['SCRIPT_FILENAME']) && $_SERVER['SCRIPT_FILENAME'] == __FILE__)
1781
+{
1782
+	// some tests
1615 1783
 {
1616 1784
 	$GLOBALS['egw_info'] = array(
1617 1785
 		'flags' => array(
1618 1786
 			'currentapp' => 'login'
1619 1787
 		)
1620 1788
 	);
1789
+}
1621 1790
 	require_once('../../header.inc.php');
1622 1791
 	ini_set('display_errors',1);
1623 1792
 	error_reporting(E_ALL & ~E_NOTICE);
Please login to merge, or discard this patch.
calendar/inc/class.calendar_ical.inc.php 4 patches
Doc Comments   +8 added lines, -7 removed lines patch added patch discarded remove patch
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 	 *                          default 0 => export whole series (or events, if not recurring)
192 192
 	 * @param string $principalURL ='' Used for CalDAV exports
193 193
 	 * @param string $charset ='UTF-8' encoding of the vcalendar, default UTF-8
194
-	 * @param int|string $current_user =0 uid of current user to only export that one as participant for method=REPLY
194
+	 * @param integer $current_user =0 uid of current user to only export that one as participant for method=REPLY
195 195
 	 * @return string|boolean string with iCal or false on error (e.g. no permission to read the event)
196 196
 	 */
197 197
 	function &exportVCal($events, $version='1.0', $method='PUBLISH', $recur_date=0, $principalURL='', $charset='UTF-8', $current_user=0)
@@ -1091,16 +1091,13 @@  discard block
 block discarded – undo
1091 1091
 	 * Import an iCal
1092 1092
 	 *
1093 1093
 	 * @param string|resource $_vcalData
1094
-	 * @param int $cal_id=-1 must be -1 for new entries!
1095
-	 * @param string $etag=null if an etag is given, it has to match the current etag or the import will fail
1096
-	 * @param boolean $merge=false	merge data with existing entry
1097
-	 * @param int $recur_date=0 if set, import the recurrence at this timestamp,
1094
+	 * @param int $cal_id must be -1 for new entries!
1095
+	 * @param int $recur_date if set, import the recurrence at this timestamp,
1098 1096
 	 *                          default 0 => import whole series (or events, if not recurring)
1099 1097
 	 * @param string $principalURL='' Used for CalDAV imports
1100
-	 * @param int $user=null account_id of owner, default null
1101 1098
 	 * @param string $charset  The encoding charset for $text. Defaults to
1102 1099
 	 *                         utf-8 for new format, iso-8859-1 for old format.
1103
-	 * @param string $caldav_name=null name from CalDAV client or null (to use default)
1100
+	 * @param string $caldav_name name from CalDAV client or null (to use default)
1104 1101
 	 * @return int|boolean|null cal_id > 0 on success, false on failure or 0 for a failed etag|permission denied or null for "403 Forbidden"
1105 1102
 	 */
1106 1103
 	function importVCal($_vcalData, $cal_id=-1, $etag=null, $merge=false, $recur_date=0, $principalURL='', $user=null, $charset=null, $caldav_name=null,$skip_notification=false)
@@ -3145,6 +3142,10 @@  discard block
 block discarded – undo
3145 3142
 		return $event;
3146 3143
 	}
3147 3144
 
3145
+	/**
3146
+	 * @param integer $contentID
3147
+	 * @param string $charset
3148
+	 */
3148 3149
 	function search($_vcalData, $contentID=null, $relax=false, $charset=null)
3149 3150
 	{
3150 3151
 		if (($events = $this->icaltoegw($_vcalData, $charset)))
Please login to merge, or discard this patch.
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -480,15 +480,15 @@  discard block
 block discarded – undo
480 480
 									{
481 481
 										$user = $this->resource_info($this->user);
482 482
 										$attributes['ATTENDEE'][] = 'mailto:' . $user['email'];
483
-			    						$parameters['ATTENDEE'][] = array(
484
-			    							'CN'		=>	$user['name'],
485
-			    							'ROLE'		=> 'REQ-PARTICIPANT',
483
+										$parameters['ATTENDEE'][] = array(
484
+											'CN'		=>	$user['name'],
485
+											'ROLE'		=> 'REQ-PARTICIPANT',
486 486
 											'PARTSTAT'	=> 'NEEDS-ACTION',
487 487
 											'CUTYPE'	=> 'INDIVIDUAL',
488 488
 											'RSVP'		=> 'TRUE',
489 489
 											'X-EGROUPWARE-UID'	=> (string)$this->user,
490
-			    						);
491
-			    						$event['participants'][$this->user] = true;
490
+										);
491
+										$event['participants'][$this->user] = true;
492 492
 									}
493 493
 									break;
494 494
 								case 'r':
@@ -540,24 +540,24 @@  discard block
 block discarded – undo
540 540
 						}
541 541
 						break;
542 542
 
543
-    				case 'ORGANIZER':
544
-	    				if (!$organizerURL)
545
-	    				{
546
-	    					$organizerCN = '"' . trim($GLOBALS['egw']->accounts->id2name($event['owner'],'account_firstname')
547
-			    				. ' ' . $GLOBALS['egw']->accounts->id2name($event['owner'],'account_lastname')) . '"';
548
-			    			$organizerEMail = $GLOBALS['egw']->accounts->id2name($event['owner'],'account_email');
549
-			    			if ($version == '1.0')
550
-			    			{
551
-		    					$organizerURL = trim($organizerCN . (empty($organizerURL) ? '' : ' <' . $organizerURL .'>'));
552
-			    			}
553
-			    			else
554
-			    			{
555
-		    					$organizerURL = empty($organizerEMail) ? '' : 'mailto:' . $organizerEMail;
556
-			    			}
557
-			    			$organizerUID = $event['owner'];
558
-		    				if (!isset($event['participants'][$event['owner']]))
559
-		    				{
560
-			    				$options = array(
543
+					case 'ORGANIZER':
544
+						if (!$organizerURL)
545
+						{
546
+							$organizerCN = '"' . trim($GLOBALS['egw']->accounts->id2name($event['owner'],'account_firstname')
547
+								. ' ' . $GLOBALS['egw']->accounts->id2name($event['owner'],'account_lastname')) . '"';
548
+							$organizerEMail = $GLOBALS['egw']->accounts->id2name($event['owner'],'account_email');
549
+							if ($version == '1.0')
550
+							{
551
+								$organizerURL = trim($organizerCN . (empty($organizerURL) ? '' : ' <' . $organizerURL .'>'));
552
+							}
553
+							else
554
+							{
555
+								$organizerURL = empty($organizerEMail) ? '' : 'mailto:' . $organizerEMail;
556
+							}
557
+							$organizerUID = $event['owner'];
558
+							if (!isset($event['participants'][$event['owner']]))
559
+							{
560
+								$options = array(
561 561
 									'ROLE'     => 'CHAIR',
562 562
 									'PARTSTAT' => 'DELEGATED',
563 563
 									'CUTYPE'   => 'INDIVIDUAL',
@@ -567,20 +567,20 @@  discard block
 block discarded – undo
567 567
 								if (!empty($organizerEMail)) $options['EMAIL'] = $organizerEMail;
568 568
 								if (!empty($event['owner'])) $options['X-EGROUPWARE-UID'] = $event['owner'];
569 569
 								$attributes['ATTENDEE'][] = $organizerURL;
570
-			    				$parameters['ATTENDEE'][] = $options;
571
-		    				}
572
-	    				}
573
-    					// do NOT use ORGANIZER for events without further participants or a different organizer
574
-	    				if (count($event['participants']) > 1 || !isset($event['participants'][$event['owner']]))
575
-	    				{
576
-		    				$attributes['ORGANIZER'] = $organizerURL;
577
-		    				$parameters['ORGANIZER']['CN'] = $organizerCN;
578
-		    				if (!empty($organizerUID))
579
-		    				{
580
-			    				$parameters['ORGANIZER']['X-EGROUPWARE-UID'] = $organizerUID;
581
-		    				}
582
-	    				}
583
-	    				break;
570
+								$parameters['ATTENDEE'][] = $options;
571
+							}
572
+						}
573
+						// do NOT use ORGANIZER for events without further participants or a different organizer
574
+						if (count($event['participants']) > 1 || !isset($event['participants'][$event['owner']]))
575
+						{
576
+							$attributes['ORGANIZER'] = $organizerURL;
577
+							$parameters['ORGANIZER']['CN'] = $organizerCN;
578
+							if (!empty($organizerUID))
579
+							{
580
+								$parameters['ORGANIZER']['X-EGROUPWARE-UID'] = $organizerUID;
581
+							}
582
+						}
583
+						break;
584 584
 
585 585
 					case 'DTSTART':
586 586
 						if (empty($event['whole_day']))
@@ -989,12 +989,12 @@  discard block
 block discarded – undo
989 989
 				foreach (is_array($value) && $parameters[$key]['VALUE']!='DATE' ? $value : array($value) as $valueID => $valueData)
990 990
 				{
991 991
 					$valueData = translation::convert($valueData,translation::charset(),$charset);
992
-                    $paramData = (array) translation::convert(is_array($value) ?
993
-                    		$parameters[$key][$valueID] : $parameters[$key],
994
-                            translation::charset(),$charset);
995
-                    $valuesData = (array) translation::convert($values[$key],
996
-                    		translation::charset(),$charset);
997
-                    $content = $valueData . implode(';', $valuesData);
992
+					$paramData = (array) translation::convert(is_array($value) ?
993
+							$parameters[$key][$valueID] : $parameters[$key],
994
+							translation::charset(),$charset);
995
+					$valuesData = (array) translation::convert($values[$key],
996
+							translation::charset(),$charset);
997
+					$content = $valueData . implode(';', $valuesData);
998 998
 
999 999
 					if ($version == '1.0' && (preg_match('/[^\x20-\x7F]/', $content) ||
1000 1000
 						($paramData['CN'] && preg_match('/[^\x20-\x7F]/', $paramData['CN']))))
@@ -2230,7 +2230,7 @@  discard block
 block discarded – undo
2230 2230
 	 * @param string|resource $_vcalData
2231 2231
 	 * @param string $principalURL ='' Used for CalDAV imports
2232 2232
 	 * @param string $charset  The encoding charset for $text. Defaults to
2233
-     *                         utf-8 for new format, iso-8859-1 for old format.
2233
+	 *                         utf-8 for new format, iso-8859-1 for old format.
2234 2234
 	 * @return Iterator|array|boolean Iterator if resource given or array of events on success, false on failure
2235 2235
 	 */
2236 2236
 	function icaltoegw($_vcalData, $principalURL='', $charset=null)
@@ -2747,10 +2747,10 @@  discard block
 block discarded – undo
2747 2747
 					// fall throught
2748 2748
 				case 'ATTENDEE':
2749 2749
 					if (isset($attributes['params']['PARTSTAT']))
2750
-				    {
2751
-				    	$attributes['params']['STATUS'] = $attributes['params']['PARTSTAT'];
2752
-				    }
2753
-				    if (isset($attributes['params']['STATUS']))
2750
+					{
2751
+						$attributes['params']['STATUS'] = $attributes['params']['PARTSTAT'];
2752
+					}
2753
+					if (isset($attributes['params']['STATUS']))
2754 2754
 					{
2755 2755
 						$status = $this->status_ical2egw[strtoupper($attributes['params']['STATUS'])];
2756 2756
 						if (empty($status)) $status = 'X';
@@ -3141,7 +3141,7 @@  discard block
 block discarded – undo
3141 3141
 				array2string($event)."\n",3,$this->logfile);
3142 3142
 		}
3143 3143
 		//Horde::logMessage("vevent2egw:\n" . print_r($event, true),
3144
-        //    	__FILE__, __LINE__, PEAR_LOG_DEBUG);
3144
+		//    	__FILE__, __LINE__, PEAR_LOG_DEBUG);
3145 3145
 		return $event;
3146 3146
 	}
3147 3147
 
Please login to merge, or discard this patch.
Spacing   +265 added lines, -266 removed lines patch added patch discarded remove patch
@@ -61,39 +61,39 @@  discard block
 block discarded – undo
61 61
 	 * @var array $priority_egw2ical conversion of the priority egw => ical
62 62
 	 */
63 63
 	var $priority_egw2ical = array(
64
-		0 => 0,		// undefined
65
-		1 => 9,		// low
66
-		2 => 5,		// normal
67
-		3 => 1,		// high
64
+		0 => 0, // undefined
65
+		1 => 9, // low
66
+		2 => 5, // normal
67
+		3 => 1, // high
68 68
 	);
69 69
 
70 70
 	/**
71 71
 	 * @var array $priority_ical2egw conversion of the priority ical => egw
72 72
 	 */
73 73
 	var $priority_ical2egw = array(
74
-		0 => 0,		// undefined
75
-		9 => 1,	8 => 1, 7 => 1, 6 => 1,	// low
76
-		5 => 2,		// normal
77
-		4 => 3, 3 => 3, 2 => 3, 1 => 3,	// high
74
+		0 => 0, // undefined
75
+		9 => 1, 8 => 1, 7 => 1, 6 => 1, // low
76
+		5 => 2, // normal
77
+		4 => 3, 3 => 3, 2 => 3, 1 => 3, // high
78 78
 	);
79 79
 
80 80
 	/**
81 81
 	 * @var array $priority_egw2funambol conversion of the priority egw => funambol
82 82
 	 */
83 83
 	var $priority_egw2funambol = array(
84
-		0 => 1,		// undefined (mapped to normal since undefined does not exist)
85
-		1 => 0,		// low
86
-		2 => 1,		// normal
87
-		3 => 2,		// high
84
+		0 => 1, // undefined (mapped to normal since undefined does not exist)
85
+		1 => 0, // low
86
+		2 => 1, // normal
87
+		3 => 2, // high
88 88
 	);
89 89
 
90 90
 	/**
91 91
 	 * @var array $priority_funambol2egw conversion of the priority funambol => egw
92 92
 	 */
93 93
 	var $priority_funambol2egw = array(
94
-		0 => 1,		// low
95
-		1 => 2,		// normal
96
-		2 => 3,		// high
94
+		0 => 1, // low
95
+		1 => 2, // normal
96
+		2 => 3, // high
97 97
 	);
98 98
 
99 99
 	/**
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 	 * @var boolean
164 164
 	 */
165 165
 	var $log = false;
166
-	var $logfile="/tmp/log-vcal";
166
+	var $logfile = "/tmp/log-vcal";
167 167
 
168 168
 
169 169
 	/**
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 	 * @param int|string $current_user =0 uid of current user to only export that one as participant for method=REPLY
195 195
 	 * @return string|boolean string with iCal or false on error (e.g. no permission to read the event)
196 196
 	 */
197
-	function &exportVCal($events, $version='1.0', $method='PUBLISH', $recur_date=0, $principalURL='', $charset='UTF-8', $current_user=0)
197
+	function &exportVCal($events, $version = '1.0', $method = 'PUBLISH', $recur_date = 0, $principalURL = '', $charset = 'UTF-8', $current_user = 0)
198 198
 	{
199 199
 		if ($this->log)
200 200
 		{
@@ -225,13 +225,13 @@  discard block
 block discarded – undo
225 225
 
226 226
 		if (!is_array($this->supportedFields)) $this->setSupportedFields();
227 227
 
228
-		if ($this->productManufacturer == '' )
228
+		if ($this->productManufacturer == '')
229 229
 		{	// syncevolution is broken
230 230
 			$version = '2.0';
231 231
 		}
232 232
 
233 233
 		$vcal = new Horde_Icalendar;
234
-		$vcal->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'.
234
+		$vcal->setAttribute('PRODID', '-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'.
235 235
 			strtoupper($GLOBALS['egw_info']['user']['preferences']['common']['lang']));
236 236
 		$vcal->setAttribute('VERSION', $version);
237 237
 		if ($method) $vcal->setAttribute('METHOD', $method);
@@ -261,15 +261,15 @@  discard block
 block discarded – undo
261 261
 						if ($this->log)
262 262
 						{
263 263
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
264
-								'() User does not have the permission to read event ' . $event['id']. "\n",
265
-								3,$this->logfile);
264
+								'() User does not have the permission to read event '.$event['id']."\n",
265
+								3, $this->logfile);
266 266
 						}
267 267
 						return -1; // Permission denied
268 268
 					}
269 269
 				}
270 270
 				else
271 271
 				{
272
-					$retval = false;  // Entry does not exist
272
+					$retval = false; // Entry does not exist
273 273
 					if ($this->log)
274 274
 					{
275 275
 						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
 			if ($this->log)
284 284
 			{
285 285
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
286
-					'() export event UID: ' . $event['uid'] . ".\n",
286
+					'() export event UID: '.$event['uid'].".\n",
287 287
 					3, $this->logfile);
288 288
 			}
289 289
 
@@ -308,8 +308,8 @@  discard block
 block discarded – undo
308 308
 			if ($this->log)
309 309
 			{
310 310
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
311
-					'(' . $event['id']. ',' . $recurrence . ")\n" .
312
-					array2string($event)."\n",3,$this->logfile);
311
+					'('.$event['id'].','.$recurrence.")\n".
312
+					array2string($event)."\n", 3, $this->logfile);
313 313
 			}
314 314
 
315 315
 			if ($recurrence)
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 						{
331 331
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
332 332
 								"(, $recurrence) Gratuitous pseudo exception, skipped ...\n",
333
-								3,$this->logfile);
333
+								3, $this->logfile);
334 334
 						}
335 335
 						continue; // unsupported status only exception
336 336
 					}
@@ -340,13 +340,13 @@  discard block
 block discarded – undo
340 340
 					$days = $this->so->get_recurrence_exceptions($master, $tzid, 0, 0, 'rrule');
341 341
 					if ($this->log)
342 342
 					{
343
-						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" .
344
-							array2string($days)."\n",3,$this->logfile);
343
+						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n".
344
+							array2string($days)."\n", 3, $this->logfile);
345 345
 					}
346 346
 					$recurrence = $days[$recurrence]; // use remote representation
347 347
 				}
348 348
 				// force single event
349
-				foreach (array('recur_enddate','recur_interval','recur_exception','recur_data','recur_date','id','etag') as $name)
349
+				foreach (array('recur_enddate', 'recur_interval', 'recur_exception', 'recur_data', 'recur_date', 'id', 'etag') as $name)
350 350
 				{
351 351
 					unset($event[$name]);
352 352
 				}
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
 			}
355 355
 
356 356
 			// check if tzid of event (not only recuring ones) is already added to export
357
-			if ($tzid && $tzid != 'UTC' && !in_array($tzid,$vtimezones_added))
357
+			if ($tzid && $tzid != 'UTC' && !in_array($tzid, $vtimezones_added))
358 358
 			{
359 359
 				// check if we have vtimezone component data for tzid of event, if not default to user timezone (default to server tz)
360 360
 				if (calendar_timezones::add_vtimezone($vcal, $tzid) ||
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
 			{
373 373
 				// Append UID to DESCRIPTION
374 374
 				if (!preg_match('/\[UID:.+\]/m', $event['description'])) {
375
-					$event['description'] .= "\n[UID:" . $event['uid'] . "]";
375
+					$event['description'] .= "\n[UID:".$event['uid']."]";
376 376
 				}
377 377
 			}
378 378
 
@@ -393,14 +393,14 @@  discard block
 block discarded – undo
393 393
 				$exceptions = array();
394 394
 
395 395
 				// dont use "virtual" exceptions created by participant status for GroupDAV or file export
396
-				if (!in_array($this->productManufacturer,array('file','groupdav')))
396
+				if (!in_array($this->productManufacturer, array('file', 'groupdav')))
397 397
 				{
398 398
 					$filter = isset($this->supportedFields['participants']) ? 'rrule' : 'tz_rrule';
399 399
 					$exceptions = $this->so->get_recurrence_exceptions($event, $tzid, 0, 0, $filter);
400 400
 					if ($this->log)
401 401
 					{
402
-						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."(EXCEPTIONS)\n" .
403
-							array2string($exceptions)."\n",3,$this->logfile);
402
+						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."(EXCEPTIONS)\n".
403
+							array2string($exceptions)."\n", 3, $this->logfile);
404 404
 					}
405 405
 				}
406 406
 				elseif (is_array($event['recur_exception']))
@@ -417,8 +417,8 @@  discard block
 block discarded – undo
417 417
 					if ($this->log)
418 418
 					{
419 419
 						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
420
-							'(' . $event['id'] . ") [$icalFieldName] not supported\n",
421
-							3,$this->logfile);
420
+							'('.$event['id'].") [$icalFieldName] not supported\n",
421
+							3, $this->logfile);
422 422
 					}
423 423
 					continue;
424 424
 				}
@@ -435,23 +435,23 @@  discard block
 block discarded – undo
435 435
 
436 436
 							if (!($info = $this->resource_info($uid))) continue;
437 437
 
438
-							if (in_array($status, array('X','E'))) continue;	// dont include deleted participants
438
+							if (in_array($status, array('X', 'E'))) continue; // dont include deleted participants
439 439
 
440 440
 							if ($this->log)
441 441
 							{
442
-								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
443
-									'()attendee:' . array2string($info) ."\n",3,$this->logfile);
442
+								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
443
+									'()attendee:'.array2string($info)."\n", 3, $this->logfile);
444 444
 							}
445 445
 							$participantCN = str_replace(array('\\', ',', ';', ':'),
446 446
 												array('\\\\', '\\,', '\\;', '\\:'),
447 447
 												trim(empty($info['cn']) ? $info['name'] : $info['cn']));
448 448
 							if ($version == '1.0')
449 449
 							{
450
-								$participantURL = trim('"' . $participantCN . '"' . (empty($info['email']) ? '' : ' <' . $info['email'] .'>'));
450
+								$participantURL = trim('"'.$participantCN.'"'.(empty($info['email']) ? '' : ' <'.$info['email'].'>'));
451 451
 							}
452 452
 							else
453 453
 							{
454
-								$participantURL = empty($info['email']) ? '' : 'mailto:' . $info['email'];
454
+								$participantURL = empty($info['email']) ? '' : 'mailto:'.$info['email'];
455 455
 							}
456 456
 							// RSVP={TRUE|FALSE}	// resonse expected, not set in eGW => status=U
457 457
 							$rsvp = $status == 'U' ? 'TRUE' : 'FALSE';
@@ -479,7 +479,7 @@  discard block
 block discarded – undo
479 479
 										($members = $GLOBALS['egw']->accounts->members($uid, true)) && in_array($this->user, $members))
480 480
 									{
481 481
 										$user = $this->resource_info($this->user);
482
-										$attributes['ATTENDEE'][] = 'mailto:' . $user['email'];
482
+										$attributes['ATTENDEE'][] = 'mailto:'.$user['email'];
483 483
 			    						$parameters['ATTENDEE'][] = array(
484 484
 			    							'CN'		=>	$user['name'],
485 485
 			    							'ROLE'		=> 'REQ-PARTICIPANT',
@@ -521,7 +521,7 @@  discard block
 block discarded – undo
521 521
 							if (!empty($rsvp)) $options['RSVP'] = $rsvp;
522 522
 							if (!empty($info['email']) && $participantURL != 'mailto:'.$info['email'])
523 523
 							{
524
-								$options['EMAIL'] = $info['email'];	// only add EMAIL attribute, if not already URL, as eg. Akonadi is reported to have problems with it
524
+								$options['EMAIL'] = $info['email']; // only add EMAIL attribute, if not already URL, as eg. Akonadi is reported to have problems with it
525 525
 							}
526 526
 							if ($info['type'] != 'e') $options['X-EGROUPWARE-UID'] = (string)$uid;
527 527
 							if ($quantity > 1) $options['X-EGROUPWARE-QUANTITY'] = (string)$quantity;
@@ -531,7 +531,7 @@  discard block
 block discarded – undo
531 531
 						break;
532 532
 
533 533
 					case 'CLASS':
534
-						if ($event['public']) continue;	// public is default, no need to export, fails CalDAVTester if added as default
534
+						if ($event['public']) continue; // public is default, no need to export, fails CalDAVTester if added as default
535 535
 						$attributes['CLASS'] = $event['public'] ? 'PUBLIC' : 'PRIVATE';
536 536
 						// Apple iCal on OS X uses X-CALENDARSERVER-ACCESS: CONFIDENTIAL on VCALANDAR (not VEVENT!)
537 537
 						if (!$event['public'] && $this->productManufacturer == 'groupdav')
@@ -543,16 +543,16 @@  discard block
 block discarded – undo
543 543
     				case 'ORGANIZER':
544 544
 	    				if (!$organizerURL)
545 545
 	    				{
546
-	    					$organizerCN = '"' . trim($GLOBALS['egw']->accounts->id2name($event['owner'],'account_firstname')
547
-			    				. ' ' . $GLOBALS['egw']->accounts->id2name($event['owner'],'account_lastname')) . '"';
548
-			    			$organizerEMail = $GLOBALS['egw']->accounts->id2name($event['owner'],'account_email');
546
+	    					$organizerCN = '"'.trim($GLOBALS['egw']->accounts->id2name($event['owner'], 'account_firstname')
547
+			    				. ' '.$GLOBALS['egw']->accounts->id2name($event['owner'], 'account_lastname')).'"';
548
+			    			$organizerEMail = $GLOBALS['egw']->accounts->id2name($event['owner'], 'account_email');
549 549
 			    			if ($version == '1.0')
550 550
 			    			{
551
-		    					$organizerURL = trim($organizerCN . (empty($organizerURL) ? '' : ' <' . $organizerURL .'>'));
551
+		    					$organizerURL = trim($organizerCN.(empty($organizerURL) ? '' : ' <'.$organizerURL.'>'));
552 552
 			    			}
553 553
 			    			else
554 554
 			    			{
555
-		    					$organizerURL = empty($organizerEMail) ? '' : 'mailto:' . $organizerEMail;
555
+		    					$organizerURL = empty($organizerEMail) ? '' : 'mailto:'.$organizerEMail;
556 556
 			    			}
557 557
 			    			$organizerUID = $event['owner'];
558 558
 		    				if (!isset($event['participants'][$event['owner']]))
@@ -585,7 +585,7 @@  discard block
 block discarded – undo
585 585
 					case 'DTSTART':
586 586
 						if (empty($event['whole_day']))
587 587
 						{
588
-							$attributes['DTSTART'] = self::getDateTime($event['start'],$tzid,$parameters['DTSTART']);
588
+							$attributes['DTSTART'] = self::getDateTime($event['start'], $tzid, $parameters['DTSTART']);
589 589
 						}
590 590
 						break;
591 591
 
@@ -596,27 +596,27 @@  discard block
 block discarded – undo
596 596
 							if ($tzid == 'UTC' && $event['end'] - $event['start'] <= 86400)
597 597
 								$attributes['duration'] = $event['end'] - $event['start'];
598 598
 							else
599
-							$attributes['DTEND'] = self::getDateTime($event['end'],$tzid,$parameters['DTEND']);
599
+							$attributes['DTEND'] = self::getDateTime($event['end'], $tzid, $parameters['DTEND']);
600 600
 						}
601 601
 						else
602 602
 						{
603 603
 							// write start + end of whole day events as dates
604
-							$event['end-nextday'] = $event['end'] + 12*3600;	// we need the date of the next day, as DTEND is non-inclusive (= exclusive) in rfc2445
605
-							foreach (array('start' => 'DTSTART','end-nextday' => 'DTEND') as $f => $t)
604
+							$event['end-nextday'] = $event['end'] + 12 * 3600; // we need the date of the next day, as DTEND is non-inclusive (= exclusive) in rfc2445
605
+							foreach (array('start' => 'DTSTART', 'end-nextday' => 'DTEND') as $f => $t)
606 606
 							{
607
-								$time = new egw_time($event[$f],egw_time::$server_timezone);
608
-								$arr = egw_time::to($time,'array');
609
-								$vevent->setAttribute($t, array('year' => $arr['year'],'month' => $arr['month'],'mday' => $arr['day']),
607
+								$time = new egw_time($event[$f], egw_time::$server_timezone);
608
+								$arr = egw_time::to($time, 'array');
609
+								$vevent->setAttribute($t, array('year' => $arr['year'], 'month' => $arr['month'], 'mday' => $arr['day']),
610 610
 									array('VALUE' => 'DATE'));
611 611
 							}
612 612
 							unset($attributes['DTSTART']);
613 613
 							// Outlook does NOT care about type of DTSTART/END, only setting X-MICROSOFT-CDO-ALLDAYEVENT is used to determine an event is a whole-day event
614
-							$vevent->setAttribute('X-MICROSOFT-CDO-ALLDAYEVENT','TRUE');
614
+							$vevent->setAttribute('X-MICROSOFT-CDO-ALLDAYEVENT', 'TRUE');
615 615
 						}
616 616
 						break;
617 617
 
618 618
 					case 'RRULE':
619
-						if ($event['recur_type'] == MCAL_RECUR_NONE) break;		// no recuring event
619
+						if ($event['recur_type'] == MCAL_RECUR_NONE) break; // no recuring event
620 620
 						$rriter = calendar_rrule::event2rrule($event, false, $tzid);
621 621
 						$rrule = $rriter->generate_rrule($version);
622 622
 						if ($event['recur_enddate'])
@@ -635,16 +635,16 @@  discard block
 block discarded – undo
635 635
 						{
636 636
 							if ($event['recur_enddate'] && $tzid)
637 637
 							{
638
-								$rrule['UNTIL'] = self::getDateTime($rrule['UNTIL'],$tzid);
638
+								$rrule['UNTIL'] = self::getDateTime($rrule['UNTIL'], $tzid);
639 639
 							}
640 640
 							$attributes['RRULE'] = $rrule['FREQ'].' '.$rrule['UNTIL'];
641 641
 						}
642 642
 						else // $version == '2.0'
643 643
 						{
644 644
 							$attributes['RRULE'] = '';
645
-							foreach($rrule as $n => $v)
645
+							foreach ($rrule as $n => $v)
646 646
 							{
647
-								$attributes['RRULE'] .= ($attributes['RRULE']?';':'').$n.'='.$v;
647
+								$attributes['RRULE'] .= ($attributes['RRULE'] ? ';' : '').$n.'='.$v;
648 648
 							}
649 649
 						}
650 650
 						break;
@@ -659,7 +659,7 @@  discard block
 block discarded – undo
659 659
 								{
660 660
 									// current Horde_Icalendar 2.1.4 exports EXDATE always in UTC, so we should not set a timezone here
661 661
 									// Apple calendar on OS X 10.11.4 uses a timezone, so does Horde eg. for Recurrence-ID
662
-									$event['recur_exception'][$key] = self::getDateTime($timestamp,$tzid);//,$parameters['EXDATE']);
662
+									$event['recur_exception'][$key] = self::getDateTime($timestamp, $tzid); //,$parameters['EXDATE']);
663 663
 								}
664 664
 							}
665 665
 							else
@@ -667,9 +667,9 @@  discard block
 block discarded – undo
667 667
 								// use 'DATE' instead of 'DATE-TIME' on whole day events
668 668
 								foreach ($event['recur_exception'] as $id => $timestamp)
669 669
 								{
670
-									$time = new egw_time($timestamp,egw_time::$server_timezone);
670
+									$time = new egw_time($timestamp, egw_time::$server_timezone);
671 671
 									$time->setTimezone(self::$tz_cache[$event['tzid']]);
672
-									$arr = egw_time::to($time,'array');
672
+									$arr = egw_time::to($time, 'array');
673 673
 									$days[$id] = array(
674 674
 										'year'  => $arr['year'],
675 675
 										'month' => $arr['month'],
@@ -684,21 +684,21 @@  discard block
 block discarded – undo
684 684
 						break;
685 685
 
686 686
 					case 'PRIORITY':
687
-						if (!$event['priority']) continue;	// 0=undefined is default, no need to export, fails CalDAVTester if our default is added
687
+						if (!$event['priority']) continue; // 0=undefined is default, no need to export, fails CalDAVTester if our default is added
688 688
 						if ($this->productManufacturer == 'funambol' &&
689 689
 							(strpos($this->productName, 'outlook') !== false
690 690
 								|| strpos($this->productName, 'pocket pc') !== false))
691 691
 						{
692
-							$attributes['PRIORITY'] = (int) $this->priority_egw2funambol[$event['priority']];
692
+							$attributes['PRIORITY'] = (int)$this->priority_egw2funambol[$event['priority']];
693 693
 						}
694 694
 						else
695 695
 						{
696
-							$attributes['PRIORITY'] = (int) $this->priority_egw2ical[$event['priority']];
696
+							$attributes['PRIORITY'] = (int)$this->priority_egw2ical[$event['priority']];
697 697
 						}
698 698
 						break;
699 699
 
700 700
 					case 'TRANSP':
701
-						if (!$event['non_blocking']) continue;	// OPAQUE is default, no need to export, fails CalDAVTester if added as default
701
+						if (!$event['non_blocking']) continue; // OPAQUE is default, no need to export, fails CalDAVTester if added as default
702 702
 						if ($version == '1.0')
703 703
 						{
704 704
 							$attributes['TRANSP'] = ($event['non_blocking'] ? 1 : 0);
@@ -737,13 +737,13 @@  discard block
 block discarded – undo
737 737
 							// We handle a pseudo exception
738 738
 							if (empty($event['whole_day']))
739 739
 							{
740
-								$attributes[$icalFieldName] = self::getDateTime($recur_date,$tzid,$parameters[$icalFieldName]);
740
+								$attributes[$icalFieldName] = self::getDateTime($recur_date, $tzid, $parameters[$icalFieldName]);
741 741
 							}
742 742
 							else
743 743
 							{
744
-								$time = new egw_time($recur_date,egw_time::$server_timezone);
744
+								$time = new egw_time($recur_date, egw_time::$server_timezone);
745 745
 								$time->setTimezone(self::$tz_cache[$event['tzid']]);
746
-								$arr = egw_time::to($time,'array');
746
+								$arr = egw_time::to($time, 'array');
747 747
 								$vevent->setAttribute($icalFieldName, array(
748 748
 									'year' => $arr['year'],
749 749
 									'month' => $arr['month'],
@@ -755,17 +755,17 @@  discard block
 block discarded – undo
755 755
 						elseif ($event['recurrence'] && $event['reference'])
756 756
 						{
757 757
 							// $event['reference'] is a calendar_id, not a timestamp
758
-							if (!($revent = $this->read($event['reference']))) break;	// referenced event does not exist
758
+							if (!($revent = $this->read($event['reference']))) break; // referenced event does not exist
759 759
 
760 760
 							if (empty($revent['whole_day']))
761 761
 							{
762
-								$attributes[$icalFieldName] = self::getDateTime($event['recurrence'],$tzid,$parameters[$icalFieldName]);
762
+								$attributes[$icalFieldName] = self::getDateTime($event['recurrence'], $tzid, $parameters[$icalFieldName]);
763 763
 							}
764 764
 							else
765 765
 							{
766
-								$time = new egw_time($event['recurrence'],egw_time::$server_timezone);
766
+								$time = new egw_time($event['recurrence'], egw_time::$server_timezone);
767 767
 								$time->setTimezone(self::$tz_cache[$event['tzid']]);
768
-								$arr = egw_time::to($time,'array');
768
+								$arr = egw_time::to($time, 'array');
769 769
 								$vevent->setAttribute($icalFieldName, array(
770 770
 									'year' => $arr['year'],
771 771
 									'month' => $arr['month'],
@@ -789,9 +789,9 @@  discard block
 block discarded – undo
789 789
 							$noTruncate = $this->clientProperties[$icalFieldName]['NoTruncate'];
790 790
 							if ($this->log && $size > 0)
791 791
 							{
792
-								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
793
-									"() $icalFieldName Size: $size, NoTruncate: " .
794
-									($noTruncate ? 'TRUE' : 'FALSE') . "\n",3,$this->logfile);
792
+								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
793
+									"() $icalFieldName Size: $size, NoTruncate: ".
794
+									($noTruncate ? 'TRUE' : 'FALSE')."\n", 3, $this->logfile);
795 795
 							}
796 796
 							//Horde::logMessage("vCalendar $icalFieldName Size: $size, NoTruncate: " .
797 797
 							//	($noTruncate ? 'TRUE' : 'FALSE'), __FILE__, __LINE__, PEAR_LOG_DEBUG);
@@ -809,8 +809,8 @@  discard block
 block discarded – undo
809 809
 							{
810 810
 								if ($this->log)
811 811
 								{
812
-									error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
813
-										"() $icalFieldName omitted due to maximum size $size\n",3,$this->logfile);
812
+									error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
813
+										"() $icalFieldName omitted due to maximum size $size\n", 3, $this->logfile);
814 814
 								}
815 815
 								//Horde::logMessage("vCalendar $icalFieldName omitted due to maximum size $size",
816 816
 								//	__FILE__, __LINE__, PEAR_LOG_WARNING);
@@ -820,8 +820,8 @@  discard block
 block discarded – undo
820 820
 							$value = substr($value, 0, $size - 1);
821 821
 							if ($this->log)
822 822
 							{
823
-								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
824
-									"() $icalFieldName truncated to maximum size $size\n",3,$this->logfile);
823
+								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
824
+									"() $icalFieldName truncated to maximum size $size\n", 3, $this->logfile);
825 825
 							}
826 826
 							//Horde::logMessage("vCalendar $icalFieldName truncated to maximum size $size",
827 827
 							//	__FILE__, __LINE__, PEAR_LOG_INFO);
@@ -836,7 +836,7 @@  discard block
 block discarded – undo
836 836
 			// for CalDAV add all X-Properties previously parsed
837 837
 			if ($this->productManufacturer == 'groupdav' || $this->productManufacturer == 'file')
838 838
 			{
839
-				foreach($event as $name => $value)
839
+				foreach ($event as $name => $value)
840 840
 				{
841 841
 					if (substr($name, 0, 2) == '##')
842 842
 					{
@@ -908,8 +908,8 @@  discard block
 block discarded – undo
908 908
 						$values['AALARM']['repeat count'] = '';
909 909
 						$values['AALARM']['display text'] = $description;
910 910
 					}
911
-					$attributes['DALARM'] = self::getDateTime($alarmData['time'],$tzid,$parameters['DALARM']);
912
-					$attributes['AALARM'] = self::getDateTime($alarmData['time'],$tzid,$parameters['AALARM']);
911
+					$attributes['DALARM'] = self::getDateTime($alarmData['time'], $tzid, $parameters['DALARM']);
912
+					$attributes['AALARM'] = self::getDateTime($alarmData['time'], $tzid, $parameters['AALARM']);
913 913
 					// lets take only the first alarm
914 914
 					break;
915 915
 				}
@@ -946,7 +946,7 @@  discard block
 block discarded – undo
946 946
 						$alarmData['offset'] = false;
947 947
 					}
948 948
 
949
-					$valarm = Horde_Icalendar::newComponent('VALARM',$vevent);
949
+					$valarm = Horde_Icalendar::newComponent('VALARM', $vevent);
950 950
 					if ($alarmData['offset'] !== false)
951 951
 					{
952 952
 						$valarm->setAttribute('TRIGGER', -$alarmData['offset'],
@@ -955,7 +955,7 @@  discard block
 block discarded – undo
955 955
 					else
956 956
 					{
957 957
 						$params = array('VALUE' => 'DATE-TIME');
958
-						$value = self::getDateTime($alarmData['time'],$tzid,$params);
958
+						$value = self::getDateTime($alarmData['time'], $tzid, $params);
959 959
 						$valarm->setAttribute('TRIGGER', $value, $params);
960 960
 					}
961 961
 					if (!empty($alarmData['uid']))
@@ -966,7 +966,7 @@  discard block
 block discarded – undo
966 966
 					// set evtl. existing attributes set by iCal clients not used by EGroupware
967 967
 					if (isset($alarmData['attrs']))
968 968
 					{
969
-						foreach($alarmData['attrs'] as $attr => $data)
969
+						foreach ($alarmData['attrs'] as $attr => $data)
970 970
 						{
971 971
 							$valarm->setAttribute($attr, $data['value'], $data['params']);
972 972
 						}
@@ -974,11 +974,11 @@  discard block
 block discarded – undo
974 974
 					// set default ACTION and DESCRIPTION, if not set by a client
975 975
 					if (!isset($alarmData['attrs']) || !isset($alarmData['attrs']['ACTION']))
976 976
 					{
977
-						$valarm->setAttribute('ACTION','DISPLAY');
977
+						$valarm->setAttribute('ACTION', 'DISPLAY');
978 978
 					}
979 979
 					if (!isset($alarmData['attrs']) || !isset($alarmData['attrs']['DESCRIPTION']))
980 980
 					{
981
-						$valarm->setAttribute('DESCRIPTION',$event['title'] ? $event['title'] : $description);
981
+						$valarm->setAttribute('DESCRIPTION', $event['title'] ? $event['title'] : $description);
982 982
 					}
983 983
 					$vevent->addComponent($valarm);
984 984
 				}
@@ -986,15 +986,15 @@  discard block
 block discarded – undo
986 986
 
987 987
 			foreach ($attributes as $key => $value)
988 988
 			{
989
-				foreach (is_array($value) && $parameters[$key]['VALUE']!='DATE' ? $value : array($value) as $valueID => $valueData)
989
+				foreach (is_array($value) && $parameters[$key]['VALUE'] != 'DATE' ? $value : array($value) as $valueID => $valueData)
990 990
 				{
991
-					$valueData = translation::convert($valueData,translation::charset(),$charset);
992
-                    $paramData = (array) translation::convert(is_array($value) ?
991
+					$valueData = translation::convert($valueData, translation::charset(), $charset);
992
+                    $paramData = (array)translation::convert(is_array($value) ?
993 993
                     		$parameters[$key][$valueID] : $parameters[$key],
994
-                            translation::charset(),$charset);
995
-                    $valuesData = (array) translation::convert($values[$key],
996
-                    		translation::charset(),$charset);
997
-                    $content = $valueData . implode(';', $valuesData);
994
+                            translation::charset(), $charset);
995
+                    $valuesData = (array)translation::convert($values[$key],
996
+                    		translation::charset(), $charset);
997
+                    $content = $valueData.implode(';', $valuesData);
998 998
 
999 999
 					if ($version == '1.0' && (preg_match('/[^\x20-\x7F]/', $content) ||
1000 1000
 						($paramData['CN'] && preg_match('/[^\x20-\x7F]/', $paramData['CN']))))
@@ -1044,10 +1044,10 @@  discard block
 block discarded – undo
1044 1044
 		$retval = $events_exported ? $vcal->exportvCalendar() : false;
1045 1045
  		if ($this->log)
1046 1046
  		{
1047
- 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
1048
-				"() '$this->productManufacturer','$this->productName'\n",3,$this->logfile);
1049
- 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
1050
-				"()\n".array2string($retval)."\n",3,$this->logfile);
1047
+ 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1048
+				"() '$this->productManufacturer','$this->productName'\n", 3, $this->logfile);
1049
+ 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1050
+				"()\n".array2string($retval)."\n", 3, $this->logfile);
1051 1051
  		}
1052 1052
 		return $retval;
1053 1053
 	}
@@ -1060,15 +1060,15 @@  discard block
 block discarded – undo
1060 1060
 	 * @param array &$params=null parameter array to set TZID
1061 1061
 	 * @return mixed attribute value to set: integer timestamp if $tzid == 'UTC' otherwise Ymd\THis string IN $tzid
1062 1062
 	 */
1063
-	static function getDateTime($time,$tzid,array &$params=null)
1063
+	static function getDateTime($time, $tzid, array &$params = null)
1064 1064
 	{
1065 1065
 		if (empty($tzid) || $tzid == 'UTC')
1066 1066
 		{
1067
-			return egw_time::to($time,'ts');
1067
+			return egw_time::to($time, 'ts');
1068 1068
 		}
1069
-		if (!is_a($time,'DateTime'))
1069
+		if (!is_a($time, 'DateTime'))
1070 1070
 		{
1071
-			$time = new egw_time($time,egw_time::$server_timezone);
1071
+			$time = new egw_time($time, egw_time::$server_timezone);
1072 1072
 		}
1073 1073
 		if (!isset(self::$tz_cache[$tzid]))
1074 1074
 		{
@@ -1103,11 +1103,11 @@  discard block
 block discarded – undo
1103 1103
 	 * @param string $caldav_name=null name from CalDAV client or null (to use default)
1104 1104
 	 * @return int|boolean|null cal_id > 0 on success, false on failure or 0 for a failed etag|permission denied or null for "403 Forbidden"
1105 1105
 	 */
1106
-	function importVCal($_vcalData, $cal_id=-1, $etag=null, $merge=false, $recur_date=0, $principalURL='', $user=null, $charset=null, $caldav_name=null,$skip_notification=false)
1106
+	function importVCal($_vcalData, $cal_id = -1, $etag = null, $merge = false, $recur_date = 0, $principalURL = '', $user = null, $charset = null, $caldav_name = null, $skip_notification = false)
1107 1107
 	{
1108 1108
 		//error_log(__METHOD__."(, $cal_id, $etag, $merge, $recur_date, $principalURL, $user, $charset, $caldav_name)");
1109 1109
 		$this->events_imported = 0;
1110
-		$replace = $delete_exceptions= false;
1110
+		$replace = $delete_exceptions = false;
1111 1111
 
1112 1112
 		if (!is_array($this->supportedFields)) $this->setSupportedFields();
1113 1113
 
@@ -1115,7 +1115,7 @@  discard block
 block discarded – undo
1115 1115
 		{
1116 1116
 			return false;
1117 1117
 		}
1118
-		if (!is_array($events)) $cal_id = -1;	// just to be sure, as iterator does NOT allow array access (eg. $events[0])
1118
+		if (!is_array($events)) $cal_id = -1; // just to be sure, as iterator does NOT allow array access (eg. $events[0])
1119 1119
 
1120 1120
 		if ($cal_id > 0)
1121 1121
 		{
@@ -1123,7 +1123,7 @@  discard block
 block discarded – undo
1123 1123
 			{
1124 1124
 				$replace = $recur_date == 0;
1125 1125
 				$events[0]['id'] = $cal_id;
1126
-				if (!is_null($etag)) $events[0]['etag'] = (int) $etag;
1126
+				if (!is_null($etag)) $events[0]['etag'] = (int)$etag;
1127 1127
 				if ($recur_date) $events[0]['recurrence'] = $recur_date;
1128 1128
 			}
1129 1129
 			elseif (($foundEvent = $this->find_event(array('id' => $cal_id), 'exact')) &&
@@ -1175,7 +1175,7 @@  discard block
 block discarded – undo
1175 1175
 			{
1176 1176
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
1177 1177
 					."($cal_id, $etag, $recur_date, $principalURL, $user, $charset)\n"
1178
-					. array2string($event)."\n",3,$this->logfile);
1178
+					. array2string($event)."\n", 3, $this->logfile);
1179 1179
 			}
1180 1180
 
1181 1181
 			$updated_id = false;
@@ -1198,14 +1198,14 @@  discard block
 block discarded – undo
1198 1198
 					{
1199 1199
 						if ($delete_exceptions)
1200 1200
 						{
1201
-							$this->delete($id,0,false,$skip_notification);
1201
+							$this->delete($id, 0, false, $skip_notification);
1202 1202
 						}
1203 1203
 						else
1204 1204
 						{
1205 1205
 							if (!($exception = $this->read($id))) continue;
1206 1206
 							$exception['uid'] = common::generate_uid('calendar', $id);
1207 1207
 							$exception['reference'] = $exception['recurrence'] = 0;
1208
-							$this->update($exception, true,true,false,true,$msg,$skip_notification);
1208
+							$this->update($exception, true, true, false, true, $msg, $skip_notification);
1209 1209
 						}
1210 1210
 					}
1211 1211
 				}
@@ -1222,7 +1222,7 @@  discard block
 block discarded – undo
1222 1222
 				{
1223 1223
 					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
1224 1224
 						. "(UPDATE Event)\n"
1225
-						. array2string($event_info['stored_event'])."\n",3,$this->logfile);
1225
+						. array2string($event_info['stored_event'])."\n", 3, $this->logfile);
1226 1226
 				}
1227 1227
 				if (empty($event['uid']))
1228 1228
 				{
@@ -1244,7 +1244,7 @@  discard block
 block discarded – undo
1244 1244
 								if ($this->log)
1245 1245
 								{
1246 1246
 									error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1247
-										"() Restore status for $uid\n",3,$this->logfile);
1247
+										"() Restore status for $uid\n", 3, $this->logfile);
1248 1248
 								}
1249 1249
 								$event['participants'][$uid] = $event_info['stored_event']['participants'][$uid];
1250 1250
 							}
@@ -1268,7 +1268,7 @@  discard block
 block discarded – undo
1268 1268
 					if ($this->log)
1269 1269
 					{
1270 1270
 						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1271
-							"()[MERGE]\n",3,$this->logfile);
1271
+							"()[MERGE]\n", 3, $this->logfile);
1272 1272
 					}
1273 1273
 					// overwrite with server data for merge
1274 1274
 					foreach ($event_info['stored_event'] as $key => $value)
@@ -1298,7 +1298,7 @@  discard block
 block discarded – undo
1298 1298
 				else
1299 1299
 				{
1300 1300
 					// no merge
1301
-					if(!isset($this->supportedFields['category']) || !isset($event['category']))
1301
+					if (!isset($this->supportedFields['category']) || !isset($event['category']))
1302 1302
 					{
1303 1303
 						$event['category'] = $event_info['stored_event']['category'];
1304 1304
 					}
@@ -1310,7 +1310,7 @@  discard block
 block discarded – undo
1310 1310
 						if ($this->log)
1311 1311
 						{
1312 1312
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1313
-							"() No participants\n",3,$this->logfile);
1313
+							"() No participants\n", 3, $this->logfile);
1314 1314
 						}
1315 1315
 
1316 1316
 						// If this is an updated meeting, and the client doesn't support
@@ -1329,7 +1329,7 @@  discard block
 block discarded – undo
1329 1329
 								if ($this->log)
1330 1330
 								{
1331 1331
 									error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1332
-										"() Restore resource $uid to status $status\n",3,$this->logfile);
1332
+										"() Restore resource $uid to status $status\n", 3, $this->logfile);
1333 1333
 								}
1334 1334
 								// Add it back in
1335 1335
 								$event['participants'][$uid] = $status;
@@ -1417,8 +1417,7 @@  discard block
 block discarded – undo
1417 1417
 						}
1418 1418
 						// for resources check which new-status to give (eg. with direct booking permision 'A' instead 'U')
1419 1419
 						$event['participants'][$user] = calendar_so::combine_status(
1420
-							$user < 0 || !isset($this->resources[$user[0]]['new_status']) ? 'U' :
1421
-							ExecMethod($this->resources[$user[0]]['new_status'], substr($user, 1)));
1420
+							$user < 0 || !isset($this->resources[$user[0]]['new_status']) ? 'U' : ExecMethod($this->resources[$user[0]]['new_status'], substr($user, 1)));
1422 1421
 					}
1423 1422
 				}
1424 1423
 				// check if an owner is set and the current user has add rights
@@ -1483,9 +1482,9 @@  discard block
 block discarded – undo
1483 1482
 
1484 1483
 			if ($this->log)
1485 1484
 			{
1486
-				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ . '('
1487
-					. $event_info['type'] . ")\n"
1488
-					. array2string($event)."\n",3,$this->logfile);
1485
+				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.'('
1486
+					. $event_info['type'].")\n"
1487
+					. array2string($event)."\n", 3, $this->logfile);
1489 1488
 			}
1490 1489
 
1491 1490
 			// Android (any maybe others) delete recurrences by setting STATUS: CANCELLED
@@ -1493,10 +1492,10 @@  discard block
 block discarded – undo
1493 1492
 			if (in_array($event_info['type'], array('SERIES-EXCEPTION', 'SERIES-EXCEPTION-PROPAGATE', 'SERIES-PSEUDO-EXCEPTION')) &&
1494 1493
 				$event['status'] == 'CANCELLED')
1495 1494
 			{
1496
-				if (!$this->delete($event['id'] ? $event['id'] : $cal_id, $event['recurrence'],false,$skip_notification))
1495
+				if (!$this->delete($event['id'] ? $event['id'] : $cal_id, $event['recurrence'], false, $skip_notification))
1497 1496
 				{
1498 1497
 					// delete fails (because no rights), reject recurrence
1499
-					$this->set_status($event['id'] ? $event['id'] : $cal_id, $this->user, 'R', $event['recurrence'],false,true,$skip_notification);
1498
+					$this->set_status($event['id'] ? $event['id'] : $cal_id, $this->user, 'R', $event['recurrence'], false, true, $skip_notification);
1500 1499
 				}
1501 1500
 				continue;
1502 1501
 			}
@@ -1508,7 +1507,7 @@  discard block
 block discarded – undo
1508 1507
 					if ($this->log)
1509 1508
 					{
1510 1509
 						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1511
-							"(): event SINGLE\n",3,$this->logfile);
1510
+							"(): event SINGLE\n", 3, $this->logfile);
1512 1511
 					}
1513 1512
 
1514 1513
 					// update the event
@@ -1518,7 +1517,7 @@  discard block
 block discarded – undo
1518 1517
 						$event['reference'] = 0;
1519 1518
 						$event_to_store = $event; // prevent $event from being changed by the update method
1520 1519
 						$this->server2usertime($event_to_store);
1521
-						$updated_id = $this->update($event_to_store, true,true,false,true,$msg,$skip_notification);
1520
+						$updated_id = $this->update($event_to_store, true, true, false, true, $msg, $skip_notification);
1522 1521
 						unset($event_to_store);
1523 1522
 					}
1524 1523
 					break;
@@ -1527,7 +1526,7 @@  discard block
 block discarded – undo
1527 1526
 					if ($this->log)
1528 1527
 					{
1529 1528
 						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1530
-							"(): event SERIES-MASTER\n",3,$this->logfile);
1529
+							"(): event SERIES-MASTER\n", 3, $this->logfile);
1531 1530
 					}
1532 1531
 
1533 1532
 					// remove all known pseudo exceptions and update the event
@@ -1537,8 +1536,8 @@  discard block
 block discarded – undo
1537 1536
 						$days = $this->so->get_recurrence_exceptions($event_info['stored_event'], $this->tzid, 0, 0, $filter);
1538 1537
 						if ($this->log)
1539 1538
 						{
1540
-							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."(EXCEPTIONS MAPPING):\n" .
1541
-								array2string($days)."\n",3,$this->logfile);
1539
+							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."(EXCEPTIONS MAPPING):\n".
1540
+								array2string($days)."\n", 3, $this->logfile);
1542 1541
 						}
1543 1542
 						if (is_array($days))
1544 1543
 						{
@@ -1556,7 +1555,7 @@  discard block
 block discarded – undo
1556 1555
 
1557 1556
 						$event_to_store = $event; // prevent $event from being changed by the update method
1558 1557
 						$this->server2usertime($event_to_store);
1559
-						$updated_id = $this->update($event_to_store, true,true,false,true,$msg,$skip_notification);
1558
+						$updated_id = $this->update($event_to_store, true, true, false, true, $msg, $skip_notification);
1560 1559
 						unset($event_to_store);
1561 1560
 					}
1562 1561
 					break;
@@ -1566,7 +1565,7 @@  discard block
 block discarded – undo
1566 1565
 					if ($this->log)
1567 1566
 					{
1568 1567
 						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1569
-							"(): event SERIES-EXCEPTION\n",3,$this->logfile);
1568
+							"(): event SERIES-EXCEPTION\n", 3, $this->logfile);
1570 1569
 					}
1571 1570
 
1572 1571
 					// update event
@@ -1622,13 +1621,13 @@  discard block
 block discarded – undo
1622 1621
 							$event['owner'] = $event_info['master_event']['owner'];
1623 1622
 							$event_to_store = $event_info['master_event']; // prevent the master_event from being changed by the update method
1624 1623
 							$this->server2usertime($event_to_store);
1625
-							$this->update($event_to_store, true,true,false,true,$msg,$skip_notification);
1624
+							$this->update($event_to_store, true, true, false, true, $msg, $skip_notification);
1626 1625
 							unset($event_to_store);
1627 1626
 						}
1628 1627
 
1629 1628
 						$event_to_store = $event; // prevent $event from being changed by update method
1630 1629
 						$this->server2usertime($event_to_store);
1631
-						$updated_id = $this->update($event_to_store, true,true,false,true,$msg,$skip_notification);
1630
+						$updated_id = $this->update($event_to_store, true, true, false, true, $msg, $skip_notification);
1632 1631
 						unset($event_to_store);
1633 1632
 					}
1634 1633
 					break;
@@ -1637,7 +1636,7 @@  discard block
 block discarded – undo
1637 1636
 					if ($this->log)
1638 1637
 					{
1639 1638
 						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1640
-							"(): event SERIES-PSEUDO-EXCEPTION\n",3,$this->logfile);
1639
+							"(): event SERIES-PSEUDO-EXCEPTION\n", 3, $this->logfile);
1641 1640
 					}
1642 1641
 					//Horde::logMessage('importVCAL event SERIES-PSEUDO-EXCEPTION',
1643 1642
 					//	__FILE__, __LINE__, PEAR_LOG_DEBUG);
@@ -1658,7 +1657,7 @@  discard block
 block discarded – undo
1658 1657
 						// save the series master with the adjusted exceptions
1659 1658
 						$event_to_store = $event_info['master_event']; // prevent the master_event from being changed by the update method
1660 1659
 						$this->server2usertime($event_to_store);
1661
-						$updated_id = $this->update($event_to_store, true, true, false, false,$msg,$skip_notification);
1660
+						$updated_id = $this->update($event_to_store, true, true, false, false, $msg, $skip_notification);
1662 1661
 						unset($event_to_store);
1663 1662
 					}
1664 1663
 
@@ -1685,13 +1684,13 @@  discard block
 block discarded – undo
1685 1684
 							if ($event_info['acl_edit'])
1686 1685
 							{
1687 1686
 								// update all participants if we have the right to do that
1688
-								$this->update_status($event, $event_info['stored_event'],0,$skip_notification);
1687
+								$this->update_status($event, $event_info['stored_event'], 0, $skip_notification);
1689 1688
 							}
1690 1689
 							elseif (isset($event['participants'][$this->user]) || isset($event_info['stored_event']['participants'][$this->user]))
1691 1690
 							{
1692 1691
 								// update the users status only
1693 1692
 								$this->set_status($event_info['stored_event']['id'], $this->user,
1694
-									($event['participants'][$this->user] ? $event['participants'][$this->user] : 'R'), 0, true,true,$skip_notification);
1693
+									($event['participants'][$this->user] ? $event['participants'][$this->user] : 'R'), 0, true, true, $skip_notification);
1695 1694
 							}
1696 1695
 						}
1697 1696
 						break;
@@ -1703,13 +1702,13 @@  discard block
 block discarded – undo
1703 1702
 							if ($event_info['acl_edit'])
1704 1703
 							{
1705 1704
 								// update all participants if we have the right to do that
1706
-								$this->update_status($event, $event_info['stored_event'], $recurrence,$skip_notification);
1705
+								$this->update_status($event, $event_info['stored_event'], $recurrence, $skip_notification);
1707 1706
 							}
1708 1707
 							elseif (isset($event['participants'][$this->user]) || isset($event_info['master_event']['participants'][$this->user]))
1709 1708
 							{
1710 1709
 								// update the users status only
1711 1710
 								$this->set_status($event_info['master_event']['id'], $this->user,
1712
-									($event['participants'][$this->user] ? $event['participants'][$this->user] : 'R'), $recurrence, true,true,$skip_notification);
1711
+									($event['participants'][$this->user] ? $event['participants'][$this->user] : 'R'), $recurrence, true, true, $skip_notification);
1713 1712
 							}
1714 1713
 						}
1715 1714
 						break;
@@ -1726,7 +1725,7 @@  discard block
 block discarded – undo
1726 1725
 					break;
1727 1726
 
1728 1727
 				case 'SERIES-PSEUDO-EXCEPTION':
1729
-					$return_id = is_array($event_info['master_event']) ? $event_info['master_event']['id'] . ':' . $event['recurrence'] : false;
1728
+					$return_id = is_array($event_info['master_event']) ? $event_info['master_event']['id'].':'.$event['recurrence'] : false;
1730 1729
 					break;
1731 1730
 
1732 1731
 				case 'SERIES-EXCEPTION-PROPAGATE':
@@ -1739,7 +1738,7 @@  discard block
 block discarded – undo
1739 1738
 					{
1740 1739
 						// we did not have sufficient rights to propagate the status only exception to a real one
1741 1740
 						// we have to keep the SERIES-PSEUDO-EXCEPTION id and keep the event untouched
1742
-						$return_id = $event_info['master_event']['id'] . ':' . $event['recurrence'];
1741
+						$return_id = $event_info['master_event']['id'].':'.$event['recurrence'];
1743 1742
 					}
1744 1743
 					break;
1745 1744
 			}
@@ -1753,8 +1752,8 @@  discard block
 block discarded – undo
1753 1752
 			if ($this->log)
1754 1753
 			{
1755 1754
 				$event_info['stored_event'] = $this->read($event_info['stored_event']['id']);
1756
-				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()[$updated_id]\n" .
1757
-					array2string($event_info['stored_event'])."\n",3,$this->logfile);
1755
+				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()[$updated_id]\n".
1756
+					array2string($event_info['stored_event'])."\n", 3, $this->logfile);
1758 1757
 			}
1759 1758
 		}
1760 1759
 		date_default_timezone_set($GLOBALS['egw_info']['server']['server_timezone']);
@@ -1774,10 +1773,10 @@  discard block
 block discarded – undo
1774 1773
 	{
1775 1774
 		if ($this->debug) error_log(__METHOD__."(".array2string($event).', old_alarms='.array2string($old_alarms).", $user,)");
1776 1775
 		$modified = 0;
1777
-		foreach($event['alarm'] as &$alarm)
1776
+		foreach ($event['alarm'] as &$alarm)
1778 1777
 		{
1779 1778
 			// check if alarm is already stored or from other users
1780
-			foreach($old_alarms as $id => $old_alarm)
1779
+			foreach ($old_alarms as $id => $old_alarm)
1781 1780
 			{
1782 1781
 				// not current users alarm --> ignore
1783 1782
 				if (!$old_alarm['all'] && $old_alarm['owner'] != $user)
@@ -1814,7 +1813,7 @@  discard block
 block discarded – undo
1814 1813
 			}
1815 1814
 		}
1816 1815
 		// remove all old alarms left from current user
1817
-		foreach($old_alarms as $id => $old_alarm)
1816
+		foreach ($old_alarms as $id => $old_alarm)
1818 1817
 		{
1819 1818
 			// not current users alarm --> ignore
1820 1819
 			if (!$old_alarm['all'] && $old_alarm['owner'] != $user)
@@ -1837,7 +1836,7 @@  discard block
 block discarded – undo
1837 1836
 	 * @param string $what ='value'
1838 1837
 	 * @return mixed
1839 1838
 	 */
1840
-	static function _get_attribute($components,$name,$what='value')
1839
+	static function _get_attribute($components, $name, $what = 'value')
1841 1840
 	{
1842 1841
 		foreach ($components as $attribute)
1843 1842
 		{
@@ -1872,7 +1871,7 @@  discard block
 block discarded – undo
1872 1871
 						case 'DURATION':
1873 1872
 							if (isset($vattr['params']['RELATED']) && $vattr['params']['RELATED'] == 'END')
1874 1873
 							{
1875
-								$alarm['offset'] = $duration -$vattr['value'];
1874
+								$alarm['offset'] = $duration - $vattr['value'];
1876 1875
 							}
1877 1876
 							elseif (isset($vattr['params']['RELATED']) && $vattr['params']['RELATED'] != 'START')
1878 1877
 							{
@@ -1888,7 +1887,7 @@  discard block
 block discarded – undo
1888 1887
 							$alarm['time'] = $vattr['value'];
1889 1888
 							break;
1890 1889
 						default:
1891
-							error_log('VALARM/TRIGGER: unsupported value type:' . $vtype);
1890
+							error_log('VALARM/TRIGGER: unsupported value type:'.$vtype);
1892 1891
 					}
1893 1892
 					break;
1894 1893
 
@@ -1913,9 +1912,9 @@  discard block
 block discarded – undo
1913 1912
 		return 0;
1914 1913
 	}
1915 1914
 
1916
-	function setSupportedFields($_productManufacturer='', $_productName='')
1915
+	function setSupportedFields($_productManufacturer = '', $_productName = '')
1917 1916
 	{
1918
-		$state =& $_SESSION['SyncML.state'];
1917
+		$state = & $_SESSION['SyncML.state'];
1919 1918
 		if (isset($state))
1920 1919
 		{
1921 1920
 			$deviceInfo = $state->getClientDeviceInfo();
@@ -2212,10 +2211,10 @@  discard block
 block discarded – undo
2212 2211
 		if ($this->log)
2213 2212
 		{
2214 2213
 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2215
-				'(' . $this->productManufacturer .
2216
-				', '. $this->productName .', ' .
2217
-				($this->tzid ? $this->tzid : egw_time::$user_timezone->getName()) .
2218
-				', ' . $this->calendarOwner . ")\n" , 3, $this->logfile);
2214
+				'('.$this->productManufacturer.
2215
+				', '.$this->productName.', '.
2216
+				($this->tzid ? $this->tzid : egw_time::$user_timezone->getName()).
2217
+				', '.$this->calendarOwner.")\n", 3, $this->logfile);
2219 2218
 		}
2220 2219
 
2221 2220
 		//Horde::logMessage('setSupportedFields(' . $this->productManufacturer . ', '
@@ -2233,12 +2232,12 @@  discard block
 block discarded – undo
2233 2232
      *                         utf-8 for new format, iso-8859-1 for old format.
2234 2233
 	 * @return Iterator|array|boolean Iterator if resource given or array of events on success, false on failure
2235 2234
 	 */
2236
-	function icaltoegw($_vcalData, $principalURL='', $charset=null)
2235
+	function icaltoegw($_vcalData, $principalURL = '', $charset = null)
2237 2236
 	{
2238 2237
 		if ($this->log)
2239 2238
 		{
2240
-			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."($principalURL, $charset)\n" .
2241
-				array2string($_vcalData)."\n",3,$this->logfile);
2239
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."($principalURL, $charset)\n".
2240
+				array2string($_vcalData)."\n", 3, $this->logfile);
2242 2241
 		}
2243 2242
 
2244 2243
 		if (!is_array($this->supportedFields)) $this->setSupportedFields();
@@ -2246,7 +2245,7 @@  discard block
 block discarded – undo
2246 2245
 		// we use egw_ical_iterator only on resources, as calling importVCal() accesses single events like an array (eg. $events[0])
2247 2246
 		if (is_resource($_vcalData))
2248 2247
 		{
2249
-			return new egw_ical_iterator($_vcalData,'VCALENDAR',$charset,array($this,'_ical2egw_callback'),array($this->tzid,$principalURL));
2248
+			return new egw_ical_iterator($_vcalData, 'VCALENDAR', $charset, array($this, '_ical2egw_callback'), array($this->tzid, $principalURL));
2250 2249
 		}
2251 2250
 
2252 2251
 		if ($this->tzid)
@@ -2271,14 +2270,14 @@  discard block
 block discarded – undo
2271 2270
 			if ($this->log)
2272 2271
 			{
2273 2272
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
2274
-					"(): No vCalendar Container found!\n",3,$this->logfile);
2273
+					"(): No vCalendar Container found!\n", 3, $this->logfile);
2275 2274
 			}
2276 2275
 			date_default_timezone_set($GLOBALS['egw_info']['server']['server_timezone']);
2277 2276
 			return false;
2278 2277
 		}
2279 2278
 		foreach ($vcal->getComponents() as $component)
2280 2279
 		{
2281
-			if (($event = $this->_ical2egw_callback($component,$this->tzid,$principalURL,$vcal)))
2280
+			if (($event = $this->_ical2egw_callback($component, $this->tzid, $principalURL, $vcal)))
2282 2281
 			{
2283 2282
 				$events[] = $event;
2284 2283
 			}
@@ -2297,13 +2296,13 @@  discard block
 block discarded – undo
2297 2296
 	 * @param Horde_Icalendar $container =null container to access attributes on container
2298 2297
 	 * @return array|boolean event array or false if $component is no Horde_Icalendar_Vevent
2299 2298
 	 */
2300
-	function _ical2egw_callback(Horde_Icalendar $component, $tzid, $principalURL='', Horde_Icalendar $container=null)
2299
+	function _ical2egw_callback(Horde_Icalendar $component, $tzid, $principalURL = '', Horde_Icalendar $container = null)
2301 2300
 	{
2302 2301
 		//unset($component->_container); _debug_array($component);
2303 2302
 
2304 2303
 		if ($this->log)
2305 2304
 		{
2306
-			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.'() '.get_class($component)." found\n",3,$this->logfile);
2305
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.'() '.get_class($component)." found\n", 3, $this->logfile);
2307 2306
 		}
2308 2307
 
2309 2308
 		if (!is_a($component, 'Horde_Icalendar_Vevent') ||
@@ -2352,16 +2351,16 @@  discard block
 block discarded – undo
2352 2351
 	 * @param Horde_Icalendar $container =null container to access attributes on container
2353 2352
 	 * @return array|boolean			event on success, false on failure
2354 2353
 	 */
2355
-	function vevent2egw($component, $version, $supportedFields, $principalURL='', $check_component='Horde_Icalendar_Vevent', Horde_Icalendar $container=null)
2354
+	function vevent2egw($component, $version, $supportedFields, $principalURL = '', $check_component = 'Horde_Icalendar_Vevent', Horde_Icalendar $container = null)
2356 2355
 	{
2357
-		unset($principalURL);	// not longer used, but required in function signature
2356
+		unset($principalURL); // not longer used, but required in function signature
2358 2357
 
2359 2358
 		if ($check_component && !is_a($component, $check_component))
2360 2359
 		{
2361 2360
 			if ($this->log)
2362 2361
 			{
2363
-				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.'()' .
2364
-					get_class($component)." found\n",3,$this->logfile);
2362
+				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.'()'.
2363
+					get_class($component)." found\n", 3, $this->logfile);
2365 2364
 			}
2366 2365
 			return false;
2367 2366
 		}
@@ -2377,11 +2376,11 @@  discard block
 block discarded – undo
2377 2376
 
2378 2377
 		$isDate = false;
2379 2378
 		$event		= array();
2380
-		$alarms		= array();
2381
-		$vcardData	= array(
2379
+		$alarms = array();
2380
+		$vcardData = array(
2382 2381
 			'recur_type'		=> MCAL_RECUR_NONE,
2383 2382
 			'recur_exception'	=> array(),
2384
-			'priority'          => 0,	// iCalendar default is 0=undefined, not EGroupware 5=normal
2383
+			'priority'          => 0, // iCalendar default is 0=undefined, not EGroupware 5=normal
2385 2384
 		);
2386 2385
 		// we need to parse DTSTART, DTEND or DURATION (in that order!) first
2387 2386
 		foreach (array_merge(
@@ -2398,7 +2397,7 @@  discard block
 block discarded – undo
2398 2397
 						$isDate = true;
2399 2398
 					}
2400 2399
 					$dtstart_ts = is_numeric($attributes['value']) ? $attributes['value'] : $this->date2ts($attributes['value']);
2401
-					$vcardData['start']	= $dtstart_ts;
2400
+					$vcardData['start'] = $dtstart_ts;
2402 2401
 
2403 2402
 					if ($this->tzid)
2404 2403
 					{
@@ -2421,18 +2420,18 @@  discard block
 block discarded – undo
2421 2420
 								}
2422 2421
 								else
2423 2422
 								{
2424
-									error_log(__METHOD__ . '() unknown TZID='
2425
-										. $attributes['params']['TZID'] . ', defaulting to timezone "'
2426
-										. date_default_timezone_get() . '".'.array2string($tz));
2427
-									$event['tzid'] = date_default_timezone_get();	// default to current timezone
2423
+									error_log(__METHOD__.'() unknown TZID='
2424
+										. $attributes['params']['TZID'].', defaulting to timezone "'
2425
+										. date_default_timezone_get().'".'.array2string($tz));
2426
+									$event['tzid'] = date_default_timezone_get(); // default to current timezone
2428 2427
 								}
2429 2428
 							}
2430
-							catch(Exception $e)
2429
+							catch (Exception $e)
2431 2430
 							{
2432
-								error_log(__METHOD__ . '() unknown TZID='
2433
-									. $attributes['params']['TZID'] . ', defaulting to timezone "'
2434
-									. date_default_timezone_get() . '".'.$e->getMessage());
2435
-								$event['tzid'] = date_default_timezone_get();	// default to current timezone
2431
+								error_log(__METHOD__.'() unknown TZID='
2432
+									. $attributes['params']['TZID'].', defaulting to timezone "'
2433
+									. date_default_timezone_get().'".'.$e->getMessage());
2434
+								$event['tzid'] = date_default_timezone_get(); // default to current timezone
2436 2435
 							}
2437 2436
 						}
2438 2437
 						else
@@ -2447,11 +2446,11 @@  discard block
 block discarded – undo
2447 2446
 
2448 2447
 				case 'DTEND':
2449 2448
 					$dtend_ts = is_numeric($attributes['value']) ? $attributes['value'] : $this->date2ts($attributes['value']);
2450
-					if (date('H:i:s',$dtend_ts) == '00:00:00')
2449
+					if (date('H:i:s', $dtend_ts) == '00:00:00')
2451 2450
 					{
2452 2451
 						$dtend_ts -= 1;
2453 2452
 					}
2454
-					$vcardData['end']	= $dtend_ts;
2453
+					$vcardData['end'] = $dtend_ts;
2455 2454
 					break;
2456 2455
 
2457 2456
 				case 'DURATION':	// clients can use DTSTART+DURATION, instead of DTSTART+DTEND
@@ -2471,7 +2470,7 @@  discard block
 block discarded – undo
2471 2470
 			if ($this->log)
2472 2471
 			{
2473 2472
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
2474
-					. "() DTSTART missing!\n",3,$this->logfile);
2473
+					. "() DTSTART missing!\n", 3, $this->logfile);
2475 2474
 			}
2476 2475
 			return false; // not a valid entry
2477 2476
 		}
@@ -2483,7 +2482,7 @@  discard block
 block discarded – undo
2483 2482
 				case 'X-MICROSOFT-CDO-ALLDAYEVENT':
2484 2483
 					if (isset($supportedFields['whole_day']))
2485 2484
 					{
2486
-						$event['whole_day'] = (isset($attributes['value'])?strtoupper($attributes['value'])=='TRUE':true);
2485
+						$event['whole_day'] = (isset($attributes['value']) ? strtoupper($attributes['value']) == 'TRUE' : true);
2487 2486
 					}
2488 2487
 					break;
2489 2488
 				case 'AALARM':
@@ -2513,32 +2512,32 @@  discard block
 block discarded – undo
2513 2512
 					$vcardData['recurrence'] = $attributes['value'];
2514 2513
 					break;
2515 2514
 				case 'LOCATION':
2516
-					$vcardData['location']	= str_replace("\r\n", "\n", $attributes['value']);
2515
+					$vcardData['location'] = str_replace("\r\n", "\n", $attributes['value']);
2517 2516
 					break;
2518 2517
 				case 'RRULE':
2519 2518
 					$recurence = $attributes['value'];
2520 2519
 					$vcardData['recur_interval'] = 1;
2521
-					$type = preg_match('/FREQ=([^;: ]+)/i',$recurence,$matches) ? $matches[1] : $recurence[0];
2520
+					$type = preg_match('/FREQ=([^;: ]+)/i', $recurence, $matches) ? $matches[1] : $recurence[0];
2522 2521
 					// vCard 2.0 values for all types
2523
-					if (preg_match('/UNTIL=([0-9TZ]+)/',$recurence,$matches))
2522
+					if (preg_match('/UNTIL=([0-9TZ]+)/', $recurence, $matches))
2524 2523
 					{
2525 2524
 						$vcardData['recur_enddate'] = $this->vCalendar->_parseDateTime($matches[1]);
2526 2525
 						// If it couldn't be parsed, treat it as not set
2527
-						if(is_string($vcardData['recur_enddate']))
2526
+						if (is_string($vcardData['recur_enddate']))
2528 2527
 						{
2529 2528
 							unset($vcardData['recur_enddate']);
2530 2529
 						}
2531 2530
 					}
2532
-					elseif (preg_match('/COUNT=([0-9]+)/',$recurence,$matches))
2531
+					elseif (preg_match('/COUNT=([0-9]+)/', $recurence, $matches))
2533 2532
 					{
2534 2533
 						$vcardData['recur_count'] = (int)$matches[1];
2535 2534
 					}
2536
-					if (preg_match('/INTERVAL=([0-9]+)/',$recurence,$matches))
2535
+					if (preg_match('/INTERVAL=([0-9]+)/', $recurence, $matches))
2537 2536
 					{
2538
-						$vcardData['recur_interval'] = (int) $matches[1] ? (int) $matches[1] : 1;
2537
+						$vcardData['recur_interval'] = (int)$matches[1] ? (int)$matches[1] : 1;
2539 2538
 					}
2540 2539
 					$vcardData['recur_data'] = 0;
2541
-					switch($type)
2540
+					switch ($type)
2542 2541
 					{
2543 2542
 						case 'D':	// 1.0
2544 2543
 							$recurenceMatches = null;
@@ -2562,20 +2561,20 @@  discard block
 block discarded – undo
2562 2561
 						case 'W':
2563 2562
 						case 'WEEKLY':
2564 2563
 							$days = array();
2565
-							if (preg_match('/W(\d+) *((?i: [AEFHMORSTUW]{2})+)?( +([^ ]*))$/',$recurence, $recurenceMatches))		// 1.0
2564
+							if (preg_match('/W(\d+) *((?i: [AEFHMORSTUW]{2})+)?( +([^ ]*))$/', $recurence, $recurenceMatches))		// 1.0
2566 2565
 							{
2567 2566
 								$vcardData['recur_interval'] = $recurenceMatches[1];
2568 2567
 								if (empty($recurenceMatches[2]))
2569 2568
 								{
2570
-									$days[0] = strtoupper(substr(date('D', $vcardData['start']),0,2));
2569
+									$days[0] = strtoupper(substr(date('D', $vcardData['start']), 0, 2));
2571 2570
 								}
2572 2571
 								else
2573 2572
 								{
2574
-									$days = explode(' ',trim($recurenceMatches[2]));
2573
+									$days = explode(' ', trim($recurenceMatches[2]));
2575 2574
 								}
2576 2575
 
2577 2576
 								$repeatMatches = null;
2578
-								if (preg_match('/#(\d+)/',$recurenceMatches[4],$repeatMatches))
2577
+								if (preg_match('/#(\d+)/', $recurenceMatches[4], $repeatMatches))
2579 2578
 								{
2580 2579
 									if ($repeatMatches[1]) $vcardData['recur_count'] = $repeatMatches[1];
2581 2580
 								}
@@ -2586,21 +2585,21 @@  discard block
 block discarded – undo
2586 2585
 
2587 2586
 								$recur_days = $this->recur_days_1_0;
2588 2587
 							}
2589
-							elseif (preg_match('/BYDAY=([^;: ]+)/',$recurence,$recurenceMatches))	// 2.0
2588
+							elseif (preg_match('/BYDAY=([^;: ]+)/', $recurence, $recurenceMatches))	// 2.0
2590 2589
 							{
2591
-								$days = explode(',',$recurenceMatches[1]);
2590
+								$days = explode(',', $recurenceMatches[1]);
2592 2591
 								$recur_days = $this->recur_days;
2593 2592
 							}
2594 2593
 							else	// no day given, use the day of dtstart
2595 2594
 							{
2596
-								$vcardData['recur_data'] |= 1 << (int)date('w',$vcardData['start']);
2595
+								$vcardData['recur_data'] |= 1 << (int)date('w', $vcardData['start']);
2597 2596
 								$vcardData['recur_type'] = MCAL_RECUR_WEEKLY;
2598 2597
 							}
2599 2598
 							if ($days)
2600 2599
 							{
2601 2600
 								foreach ($recur_days as $id => $day)
2602 2601
 								{
2603
-									if (in_array(strtoupper(substr($day,0,2)),$days))
2602
+									if (in_array(strtoupper(substr($day, 0, 2)), $days))
2604 2603
 									{
2605 2604
 										$vcardData['recur_data'] |= $id;
2606 2605
 									}
@@ -2616,17 +2615,17 @@  discard block
 block discarded – undo
2616 2615
 								$vcardData['recur_interval'] = $recurenceMatches[1];
2617 2616
 								$vcardData['recur_count'] = $recurenceMatches[2];
2618 2617
 							}
2619
-							elseif (preg_match('/MD(\d+)(?: [^ ]+)? ([0-9TZ]+)/',$recurence, $recurenceMatches))
2618
+							elseif (preg_match('/MD(\d+)(?: [^ ]+)? ([0-9TZ]+)/', $recurence, $recurenceMatches))
2620 2619
 							{
2621 2620
 								$vcardData['recur_type'] = MCAL_RECUR_MONTHLY_MDAY;
2622 2621
 								$vcardData['recur_interval'] = $recurenceMatches[1];
2623 2622
 								$vcardData['recur_enddate'] = $this->vCalendar->_parseDateTime($recurenceMatches[2]);
2624 2623
 							}
2625
-							elseif (preg_match('/MP(\d+) (.*) (.*) (.*)/',$recurence, $recurenceMatches))
2624
+							elseif (preg_match('/MP(\d+) (.*) (.*) (.*)/', $recurence, $recurenceMatches))
2626 2625
 							{
2627 2626
 								$vcardData['recur_type'] = MCAL_RECUR_MONTHLY_WDAY;
2628 2627
 								$vcardData['recur_interval'] = $recurenceMatches[1];
2629
-								if (preg_match('/#(\d+)/',$recurenceMatches[4],$recurenceMatches))
2628
+								if (preg_match('/#(\d+)/', $recurenceMatches[4], $recurenceMatches))
2630 2629
 								{
2631 2630
 									$vcardData['recur_count'] = $recurenceMatches[1];
2632 2631
 								}
@@ -2643,7 +2642,7 @@  discard block
 block discarded – undo
2643 2642
 								$vcardData['recur_interval'] = $recurenceMatches[1];
2644 2643
 								$vcardData['recur_count'] = $recurenceMatches[2];
2645 2644
 							}
2646
-							elseif (preg_match('/YM(\d+)(?: [^ ]+)? ([0-9TZ]+)/',$recurence, $recurenceMatches))
2645
+							elseif (preg_match('/YM(\d+)(?: [^ ]+)? ([0-9TZ]+)/', $recurence, $recurenceMatches))
2647 2646
 							{
2648 2647
 								$vcardData['recur_interval'] = $recurenceMatches[1];
2649 2648
 								$vcardData['recur_enddate'] = $this->vCalendar->_parseDateTime($recurenceMatches[2]);
@@ -2657,11 +2656,11 @@  discard block
 block discarded – undo
2657 2656
 							}
2658 2657
 							// handle FREQ=YEARLY;BYDAY= as FREQ=MONTHLY;BYDAY= with 12*INTERVAL
2659 2658
 							$vcardData['recur_interval'] = $vcardData['recur_interval'] ?
2660
-								12*$vcardData['recur_interval'] : 12;
2659
+								12 * $vcardData['recur_interval'] : 12;
2661 2660
 							// fall-through
2662 2661
 						case 'MONTHLY':
2663 2662
 							// does currently NOT parse BYDAY or BYMONTH, it has to be specified/identical to DTSTART
2664
-							$vcardData['recur_type'] = strpos($recurence,'BYDAY') !== false ?
2663
+							$vcardData['recur_type'] = strpos($recurence, 'BYDAY') !== false ?
2665 2664
 								MCAL_RECUR_MONTHLY_WDAY : MCAL_RECUR_MONTHLY_MDAY;
2666 2665
 							break;
2667 2666
 					}
@@ -2717,11 +2716,11 @@  discard block
 block discarded – undo
2717 2716
 						(strpos($this->productName, 'outlook') !== false
2718 2717
 							|| strpos($this->productName, 'pocket pc') !== false))
2719 2718
 					{
2720
-						$vcardData['priority'] = (int) $this->priority_funambol2egw[$attributes['value']];
2719
+						$vcardData['priority'] = (int)$this->priority_funambol2egw[$attributes['value']];
2721 2720
 					}
2722 2721
 					else
2723 2722
 					{
2724
-						$vcardData['priority'] = (int) $this->priority_ical2egw[$attributes['value']];
2723
+						$vcardData['priority'] = (int)$this->priority_ical2egw[$attributes['value']];
2725 2724
 					}
2726 2725
 					break;
2727 2726
 				case 'CATEGORIES':
@@ -2735,10 +2734,10 @@  discard block
 block discarded – undo
2735 2734
 					}
2736 2735
 					break;
2737 2736
 				case 'ORGANIZER':
2738
-					$event['organizer'] = $attributes['value'];	// no egw field, but needed in AS
2739
-					if (strtolower(substr($event['organizer'],0,7)) == 'mailto:')
2737
+					$event['organizer'] = $attributes['value']; // no egw field, but needed in AS
2738
+					if (strtolower(substr($event['organizer'], 0, 7)) == 'mailto:')
2740 2739
 					{
2741
-						$event['organizer'] = substr($event['organizer'],7);
2740
+						$event['organizer'] = substr($event['organizer'], 7);
2742 2741
 					}
2743 2742
 					if (!empty($attributes['params']['CN']))
2744 2743
 					{
@@ -2775,19 +2774,19 @@  discard block
 block discarded – undo
2775 2774
 					}
2776 2775
 					// try parsing email and cn from attendee
2777 2776
 					elseif (preg_match('/mailto:([@.a-z0-9_-]+)|mailto:"?([.a-z0-9_ -]*)"?[ ]*<([@.a-z0-9_-]*)>/i',
2778
-						$attributes['value'],$matches))
2777
+						$attributes['value'], $matches))
2779 2778
 					{
2780 2779
 						$email = $matches[1] ? $matches[1] : $matches[3];
2781
-						$cn = isset($matches[2]) ? $matches[2]: '';
2780
+						$cn = isset($matches[2]) ? $matches[2] : '';
2782 2781
 					}
2783 2782
 					elseif (!empty($attributes['value']) &&
2784 2783
 						preg_match('/"?([.a-z0-9_ -]*)"?[ ]*<([@.a-z0-9_-]*)>/i',
2785
-						$attributes['value'],$matches))
2784
+						$attributes['value'], $matches))
2786 2785
 					{
2787 2786
 						$cn = $matches[1];
2788 2787
 						$email = $matches[2];
2789 2788
 					}
2790
-					elseif (strpos($attributes['value'],'@') !== false)
2789
+					elseif (strpos($attributes['value'], '@') !== false)
2791 2790
 					{
2792 2791
 						$email = $attributes['value'];
2793 2792
 					}
@@ -2804,7 +2803,7 @@  discard block
 block discarded – undo
2804 2803
 						if ($this->log)
2805 2804
 						{
2806 2805
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
2807
-								. "(): Found X-EGROUPWARE-UID: '$uid'\n",3,$this->logfile);
2806
+								. "(): Found X-EGROUPWARE-UID: '$uid'\n", 3, $this->logfile);
2808 2807
 						}
2809 2808
 					}
2810 2809
 					elseif ($attributes['value'] == 'Unknown')
@@ -2822,7 +2821,7 @@  discard block
 block discarded – undo
2822 2821
 						if ($this->log)
2823 2822
 						{
2824 2823
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
2825
-								. "() Found account: '$uid', '$cn', '$email'\n",3,$this->logfile);
2824
+								. "() Found account: '$uid', '$cn', '$email'\n", 3, $this->logfile);
2826 2825
 						}
2827 2826
 					}
2828 2827
 					if (!$uid)
@@ -2839,9 +2838,9 @@  discard block
 block discarded – undo
2839 2838
 							$cn = str_replace(array('\\,', '\\;', '\\:', '\\\\'),
2840 2839
 										array(',', ';', ':', '\\'),
2841 2840
 										$attributes['params']['CN']);
2842
-							if ($cn[0] == '"' && substr($cn,-1) == '"')
2841
+							if ($cn[0] == '"' && substr($cn, -1) == '"')
2843 2842
 							{
2844
-								$cn = substr($cn,1,-1);
2843
+								$cn = substr($cn, 1, -1);
2845 2844
 							}
2846 2845
 							// not searching for $cn, as match can be not unique or without an email address
2847 2846
 							// --> notification will fail, better store just as email
@@ -2850,19 +2849,19 @@  discard block
 block discarded – undo
2850 2849
 						if ($this->log)
2851 2850
 						{
2852 2851
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
2853
-								. "() Search participant: '$cn', '$email'\n",3,$this->logfile);
2852
+								. "() Search participant: '$cn', '$email'\n", 3, $this->logfile);
2854 2853
 						}
2855 2854
 
2856 2855
 						//elseif (//$attributes['params']['CUTYPE'] == 'GROUP'
2857
-						if (preg_match('/(.*) '. lang('Group') . '/', $cn, $matches))
2856
+						if (preg_match('/(.*) '.lang('Group').'/', $cn, $matches))
2858 2857
 						{
2859 2858
 							// we found a group
2860 2859
 							if ($this->log)
2861 2860
 							{
2862 2861
 								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
2863
-									. "() Found group: '$matches[1]', '$cn', '$email'\n",3,$this->logfile);
2862
+									. "() Found group: '$matches[1]', '$cn', '$email'\n", 3, $this->logfile);
2864 2863
 							}
2865
-							if (($uid =  $GLOBALS['egw']->accounts->name2id($matches[1], 'account_lid', 'g')))
2864
+							if (($uid = $GLOBALS['egw']->accounts->name2id($matches[1], 'account_lid', 'g')))
2866 2865
 							{
2867 2866
 								//Horde::logMessage("vevent2egw: group participant $uid",
2868 2867
 								//			__FILE__, __LINE__, PEAR_LOG_DEBUG);
@@ -2876,7 +2875,7 @@  discard block
 block discarded – undo
2876 2875
 										//Horde::logMessage("vevent2egw: set status to " . $status,
2877 2876
 										//		__FILE__, __LINE__, PEAR_LOG_DEBUG);
2878 2877
 										$vcardData['participants'][$this->user] =
2879
-											calendar_so::combine_status($status,$quantity,$role);
2878
+											calendar_so::combine_status($status, $quantity, $role);
2880 2879
 									}
2881 2880
 								}
2882 2881
 								$status = 'U'; // keep the group
@@ -2885,36 +2884,36 @@  discard block
 block discarded – undo
2885 2884
 						}
2886 2885
 						elseif (empty($searcharray))
2887 2886
 						{
2888
-							continue;	// participants without email AND CN --> ignore it
2887
+							continue; // participants without email AND CN --> ignore it
2889 2888
 						}
2890 2889
 						elseif ((list($data) = $this->addressbook->search($searcharray,
2891
-							array('id','egw_addressbook.account_id as account_id','n_fn'),
2890
+							array('id', 'egw_addressbook.account_id as account_id', 'n_fn'),
2892 2891
 							'egw_addressbook.account_id IS NOT NULL DESC, n_fn IS NOT NULL DESC',
2893
-							'','',false,'OR')))
2892
+							'', '', false, 'OR')))
2894 2893
 						{
2895 2894
 							// found an addressbook entry
2896 2895
 							$uid = $data['account_id'] ? (int)$data['account_id'] : 'c'.$data['id'];
2897 2896
 							if ($this->log)
2898 2897
 							{
2899 2898
 								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
2900
-									. "() Found addressbook entry: '$uid', '$cn', '$email'\n",3,$this->logfile);
2899
+									. "() Found addressbook entry: '$uid', '$cn', '$email'\n", 3, $this->logfile);
2901 2900
 							}
2902 2901
 						}
2903 2902
 						else
2904 2903
 						{
2905 2904
 							if (!$email)
2906 2905
 							{
2907
-								$email = '[email protected]';	// set dummy email to store the CN
2906
+								$email = '[email protected]'; // set dummy email to store the CN
2908 2907
 							}
2909
-							$uid = 'e'. ($cn ? $cn . ' <' . $email . '>' : $email);
2908
+							$uid = 'e'.($cn ? $cn.' <'.$email.'>' : $email);
2910 2909
 							if ($this->log)
2911 2910
 							{
2912 2911
 								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
2913
-									. "() Not Found, create dummy: '$uid', '$cn', '$email'\n",3,$this->logfile);
2912
+									. "() Not Found, create dummy: '$uid', '$cn', '$email'\n", 3, $this->logfile);
2914 2913
 							}
2915 2914
 						}
2916 2915
 					}
2917
-					switch($attributes['name'])
2916
+					switch ($attributes['name'])
2918 2917
 					{
2919 2918
 						case 'ATTENDEE':
2920 2919
 							if (!isset($attributes['params']['ROLE']) &&
@@ -2928,7 +2927,7 @@  discard block
 block discarded – undo
2928 2927
 								// keep role 'CHAIR' from an external organizer, even if he is a regular participant with a different role
2929 2928
 								// as this is currently the only way to store an external organizer and send him iMip responses
2930 2929
 								$q = $r = null;
2931
-								if (isset($vcardData['participants'][$uid]) && ($s=$vcardData['participants'][$uid]) &&
2930
+								if (isset($vcardData['participants'][$uid]) && ($s = $vcardData['participants'][$uid]) &&
2932 2931
 									calendar_so::split_status($s, $q, $r) && $r == 'CHAIR')
2933 2932
 								{
2934 2933
 									$role = 'CHAIR';
@@ -2942,7 +2941,7 @@  discard block
 block discarded – undo
2942 2941
 									if (!$this->calendarOwner && is_numeric($uid) && $role == 'CHAIR')
2943 2942
 										$component->getAttribute('ORGANIZER');
2944 2943
 								}
2945
-								catch(Horde_Icalendar_Exception $e)
2944
+								catch (Horde_Icalendar_Exception $e)
2946 2945
 								{
2947 2946
 									// we can store the ORGANIZER as event owner
2948 2947
 									$event['owner'] = $uid;
@@ -2998,7 +2997,7 @@  discard block
 block discarded – undo
2998 2997
 					break;
2999 2998
 
3000 2999
 				case 'ATTACH':
3001
-					if ($attributes['params'] && !empty($attributes['params']['FMTTYPE'])) break;	// handeled by managed attachment code
3000
+					if ($attributes['params'] && !empty($attributes['params']['FMTTYPE'])) break; // handeled by managed attachment code
3002 3001
 					// fall throught to store external attachment url
3003 3002
 				default:	// X- attribute or other by EGroupware unsupported property
3004 3003
 					//error_log(__METHOD__."() $attributes[name] = ".array2string($attributes));
@@ -3056,7 +3055,7 @@  discard block
 block discarded – undo
3056 3055
 					if ($event['recur_type'] != MCAL_RECUR_NONE)
3057 3056
 					{
3058 3057
 						$event['reference'] = 0;
3059
-						foreach (array('recur_interval','recur_enddate','recur_data','recur_exception','recur_count') as $r)
3058
+						foreach (array('recur_interval', 'recur_enddate', 'recur_data', 'recur_exception', 'recur_count') as $r)
3060 3059
 						{
3061 3060
 							if (isset($vcardData[$r]))
3062 3061
 							{
@@ -3079,12 +3078,12 @@  discard block
 block discarded – undo
3079 3078
 			// reset recure_enddate to 00:00:00 on the last day
3080 3079
 			$rriter = calendar_rrule::event2rrule($event, false);
3081 3080
 			$last = $rriter->normalize_enddate();
3082
-			if(!is_object($last))
3081
+			if (!is_object($last))
3083 3082
 			{
3084
-				if($this->log)
3083
+				if ($this->log)
3085 3084
 				{
3086
-					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
3087
-					" Unable to determine recurrence end date.  \n".array2string($event),3, $this->logfile);
3085
+					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
3086
+					" Unable to determine recurrence end date.  \n".array2string($event), 3, $this->logfile);
3088 3087
 				}
3089 3088
 				return false;
3090 3089
 			}
@@ -3093,16 +3092,16 @@  discard block
 block discarded – undo
3093 3092
 			$event['recur_enddate'] = egw_time::to($last, 'server');
3094 3093
 		}
3095 3094
 		// translate COUNT into an enddate, as we only store enddates
3096
-		elseif($event['recur_count'])
3095
+		elseif ($event['recur_count'])
3097 3096
 		{
3098 3097
 			$rriter = calendar_rrule::event2rrule($event, false);
3099 3098
 			$last = $rriter->count2date($event['recur_count']);
3100
-			if(!is_object($last))
3099
+			if (!is_object($last))
3101 3100
 			{
3102
-				if($this->log)
3101
+				if ($this->log)
3103 3102
 				{
3104 3103
 					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__,
3105
-					" Unable to determine recurrence end date.  \n".array2string($event),3, $this->logfile);
3104
+					" Unable to determine recurrence end date.  \n".array2string($event), 3, $this->logfile);
3106 3105
 				}
3107 3106
 				return false;
3108 3107
 			}
@@ -3116,7 +3115,7 @@  discard block
 block discarded – undo
3116 3115
 			if ($this->productManufacturer == 'groupdav' && $container &&
3117 3116
 				($x_calendarserver_access = $container->getAttribute('X-CALENDARSERVER-ACCESS')))
3118 3117
 			{
3119
-				$event['public'] =  (int)(strtoupper($x_calendarserver_access) == 'PUBLIC');
3118
+				$event['public'] = (int)(strtoupper($x_calendarserver_access) == 'PUBLIC');
3120 3119
 			}
3121 3120
 			//error_log(__METHOD__."() X-CALENDARSERVER-ACCESS=".array2string($x_calendarserver_access).' --> public='.array2string($event['public']));
3122 3121
 		}
@@ -3137,15 +3136,15 @@  discard block
 block discarded – undo
3137 3136
 
3138 3137
 		if ($this->log)
3139 3138
 		{
3140
-			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" .
3141
-				array2string($event)."\n",3,$this->logfile);
3139
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n".
3140
+				array2string($event)."\n", 3, $this->logfile);
3142 3141
 		}
3143 3142
 		//Horde::logMessage("vevent2egw:\n" . print_r($event, true),
3144 3143
         //    	__FILE__, __LINE__, PEAR_LOG_DEBUG);
3145 3144
 		return $event;
3146 3145
 	}
3147 3146
 
3148
-	function search($_vcalData, $contentID=null, $relax=false, $charset=null)
3147
+	function search($_vcalData, $contentID = null, $relax = false, $charset = null)
3149 3148
 	{
3150 3149
 		if (($events = $this->icaltoegw($_vcalData, $charset)))
3151 3150
 		{
@@ -3166,8 +3165,8 @@  discard block
 block discarded – undo
3166 3165
 			}
3167 3166
 			if ($this->log)
3168 3167
 			{
3169
-				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."() found:\n" .
3170
-					array2string($events)."\n",3,$this->logfile);
3168
+				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."() found:\n".
3169
+					array2string($events)."\n", 3, $this->logfile);
3171 3170
 			}
3172 3171
 		}
3173 3172
 		return array();
@@ -3185,23 +3184,23 @@  discard block
 block discarded – undo
3185 3184
 	 * @param array $extra =null extra attributes to add
3186 3185
 	 * 	X-CALENDARSERVER-MASK-UID can be used to not include an event specified by this uid as busy
3187 3186
 	 */
3188
-	function freebusy($user,$end=null,$utc=true, $charset='UTF-8', $start=null, $method='PUBLISH', array $extra=null)
3187
+	function freebusy($user, $end = null, $utc = true, $charset = 'UTF-8', $start = null, $method = 'PUBLISH', array $extra = null)
3189 3188
 	{
3190
-		if (!$start) $start = time();	// default now
3191
-		if (!$end) $end = time() + 100*DAY_s;	// default next 100 days
3189
+		if (!$start) $start = time(); // default now
3190
+		if (!$end) $end = time() + 100 * DAY_s; // default next 100 days
3192 3191
 
3193 3192
 		$vcal = new Horde_Icalendar;
3194
-		$vcal->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'.
3193
+		$vcal->setAttribute('PRODID', '-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'.
3195 3194
 			strtoupper($GLOBALS['egw_info']['user']['preferences']['common']['lang']));
3196
-		$vcal->setAttribute('VERSION','2.0');
3197
-		$vcal->setAttribute('METHOD',$method);
3195
+		$vcal->setAttribute('VERSION', '2.0');
3196
+		$vcal->setAttribute('METHOD', $method);
3198 3197
 
3199
-		$vfreebusy = Horde_Icalendar::newComponent('VFREEBUSY',$vcal);
3198
+		$vfreebusy = Horde_Icalendar::newComponent('VFREEBUSY', $vcal);
3200 3199
 
3201 3200
 		$attributes = array(
3202 3201
 			'DTSTAMP' => time(),
3203
-			'DTSTART' => $this->date2ts($start,true),	// true = server-time
3204
-			'DTEND' => $this->date2ts($end,true),	// true = server-time
3202
+			'DTSTART' => $this->date2ts($start, true), // true = server-time
3203
+			'DTEND' => $this->date2ts($end, true), // true = server-time
3205 3204
 		);
3206 3205
 		if (!$utc)
3207 3206
 		{
@@ -3212,9 +3211,9 @@  discard block
 block discarded – undo
3212 3211
 		}
3213 3212
 		if (is_null($extra)) $extra = array(
3214 3213
 			'URL' => $this->freebusy_url($user),
3215
-			'ORGANIZER' => 'mailto:'.$GLOBALS['egw']->accounts->id2name($user,'account_email'),
3214
+			'ORGANIZER' => 'mailto:'.$GLOBALS['egw']->accounts->id2name($user, 'account_email'),
3216 3215
 		);
3217
-		foreach($attributes+$extra as $attr => $value)
3216
+		foreach ($attributes + $extra as $attr => $value)
3218 3217
 		{
3219 3218
 			$vfreebusy->setAttribute($attr, $value);
3220 3219
 		}
@@ -3237,16 +3236,16 @@  discard block
 block discarded – undo
3237 3236
 
3238 3237
 				if ($utc)
3239 3238
 				{
3240
-					$vfreebusy->setAttribute('FREEBUSY',array(array(
3239
+					$vfreebusy->setAttribute('FREEBUSY', array(array(
3241 3240
 						'start' => $event['start'],
3242 3241
 						'end' => $event['end'],
3243 3242
 					)), array('FBTYPE' => $fbtype));
3244 3243
 				}
3245 3244
 				else
3246 3245
 				{
3247
-					$vfreebusy->setAttribute('FREEBUSY',array(array(
3248
-						'start' => date('Ymd\THis',$event['start']),
3249
-						'end' => date('Ymd\THis',$event['end']),
3246
+					$vfreebusy->setAttribute('FREEBUSY', array(array(
3247
+						'start' => date('Ymd\THis', $event['start']),
3248
+						'end' => date('Ymd\THis', $event['end']),
3250 3249
 					)), array('FBTYPE' => $fbtype));
3251 3250
 				}
3252 3251
 			}
Please login to merge, or discard this patch.
Braces   +317 added lines, -81 removed lines patch added patch discarded remove patch
@@ -174,7 +174,10 @@  discard block
 block discarded – undo
174 174
 	function __construct(&$_clientProperties = array())
175 175
 	{
176 176
 		parent::__construct();
177
-		if ($this->log) $this->logfile = $GLOBALS['egw_info']['server']['temp_dir']."/log-vcal";
177
+		if ($this->log)
178
+		{
179
+			$this->logfile = $GLOBALS['egw_info']['server']['temp_dir']."/log-vcal";
180
+		}
178 181
 		$this->clientProperties = $_clientProperties;
179 182
 		$this->vCalendar = new Horde_Icalendar;
180 183
 		$this->addressbook = new addressbook_bo;
@@ -223,10 +226,14 @@  discard block
 block discarded – undo
223 226
 			'ATTACH'        => 'attachments',
224 227
 		);
225 228
 
226
-		if (!is_array($this->supportedFields)) $this->setSupportedFields();
229
+		if (!is_array($this->supportedFields))
230
+		{
231
+			$this->setSupportedFields();
232
+		}
227 233
 
228 234
 		if ($this->productManufacturer == '' )
229
-		{	// syncevolution is broken
235
+		{
236
+// syncevolution is broken
230 237
 			$version = '2.0';
231 238
 		}
232 239
 
@@ -234,10 +241,16 @@  discard block
 block discarded – undo
234 241
 		$vcal->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'.
235 242
 			strtoupper($GLOBALS['egw_info']['user']['preferences']['common']['lang']));
236 243
 		$vcal->setAttribute('VERSION', $version);
237
-		if ($method) $vcal->setAttribute('METHOD', $method);
244
+		if ($method)
245
+		{
246
+			$vcal->setAttribute('METHOD', $method);
247
+		}
238 248
 		$events_exported = false;
239 249
 
240
-		if (!is_array($events)) $events = array($events);
250
+		if (!is_array($events))
251
+		{
252
+			$events = array($events);
253
+		}
241 254
 
242 255
 		$vtimezones_added = array();
243 256
 		foreach ($events as $event)
@@ -303,7 +316,10 @@  discard block
 block discarded – undo
303 316
 				self::$tz_cache[$event['tzid']] = calendar_timezones::DateTimeZone($event['tzid']);
304 317
 			}
305 318
 
306
-			if ($this->so->isWholeDay($event)) $event['whole_day'] = true;
319
+			if ($this->so->isWholeDay($event))
320
+			{
321
+				$event['whole_day'] = true;
322
+			}
307 323
 
308 324
 			if ($this->log)
309 325
 			{
@@ -314,7 +330,10 @@  discard block
 block discarded – undo
314 330
 
315 331
 			if ($recurrence)
316 332
 			{
317
-				if (!($master = $this->read($event['id'], 0, true, 'server'))) continue;
333
+				if (!($master = $this->read($event['id'], 0, true, 'server')))
334
+				{
335
+					continue;
336
+				}
318 337
 
319 338
 				if (!isset($this->supportedFields['participants']))
320 339
 				{
@@ -371,7 +390,8 @@  discard block
 block discarded – undo
371 390
 			if ($this->productManufacturer != 'file' && $this->uidExtension)
372 391
 			{
373 392
 				// Append UID to DESCRIPTION
374
-				if (!preg_match('/\[UID:.+\]/m', $event['description'])) {
393
+				if (!preg_match('/\[UID:.+\]/m', $event['description']))
394
+				{
375 395
 					$event['description'] .= "\n[UID:" . $event['uid'] . "]";
376 396
 				}
377 397
 			}
@@ -431,11 +451,21 @@  discard block
 block discarded – undo
431 451
 							$quantity = $role = null;
432 452
 							calendar_so::split_status($status, $quantity, $role);
433 453
 							// do not include event owner/ORGANIZER as participant in his own calendar, if he is only participant
434
-							if (count($event['participants']) == 1 && $event['owner'] == $uid) continue;
454
+							if (count($event['participants']) == 1 && $event['owner'] == $uid)
455
+							{
456
+								continue;
457
+							}
435 458
 
436
-							if (!($info = $this->resource_info($uid))) continue;
459
+							if (!($info = $this->resource_info($uid)))
460
+							{
461
+								continue;
462
+							}
437 463
 
438
-							if (in_array($status, array('X','E'))) continue;	// dont include deleted participants
464
+							if (in_array($status, array('X','E')))
465
+							{
466
+								continue;
467
+							}
468
+							// dont include deleted participants
439 469
 
440 470
 							if ($this->log)
441 471
 							{
@@ -514,24 +544,49 @@  discard block
 block discarded – undo
514 544
 							}
515 545
 							// ROLE={CHAIR|REQ-PARTICIPANT|OPT-PARTICIPANT|NON-PARTICIPANT|X-*}
516 546
 							$options = array();
517
-							if (!empty($participantCN)) $options['CN'] = $participantCN;
518
-							if (!empty($role)) $options['ROLE'] = $role;
519
-							if (!empty($status)) $options['PARTSTAT'] = $status;
520
-							if (!empty($cutype)) $options['CUTYPE'] = $cutype;
521
-							if (!empty($rsvp)) $options['RSVP'] = $rsvp;
547
+							if (!empty($participantCN))
548
+							{
549
+								$options['CN'] = $participantCN;
550
+							}
551
+							if (!empty($role))
552
+							{
553
+								$options['ROLE'] = $role;
554
+							}
555
+							if (!empty($status))
556
+							{
557
+								$options['PARTSTAT'] = $status;
558
+							}
559
+							if (!empty($cutype))
560
+							{
561
+								$options['CUTYPE'] = $cutype;
562
+							}
563
+							if (!empty($rsvp))
564
+							{
565
+								$options['RSVP'] = $rsvp;
566
+							}
522 567
 							if (!empty($info['email']) && $participantURL != 'mailto:'.$info['email'])
523 568
 							{
524 569
 								$options['EMAIL'] = $info['email'];	// only add EMAIL attribute, if not already URL, as eg. Akonadi is reported to have problems with it
525 570
 							}
526
-							if ($info['type'] != 'e') $options['X-EGROUPWARE-UID'] = (string)$uid;
527
-							if ($quantity > 1) $options['X-EGROUPWARE-QUANTITY'] = (string)$quantity;
571
+							if ($info['type'] != 'e')
572
+							{
573
+								$options['X-EGROUPWARE-UID'] = (string)$uid;
574
+							}
575
+							if ($quantity > 1)
576
+							{
577
+								$options['X-EGROUPWARE-QUANTITY'] = (string)$quantity;
578
+							}
528 579
 							$attributes['ATTENDEE'][] = $participantURL;
529 580
 							$parameters['ATTENDEE'][] = $options;
530 581
 						}
531 582
 						break;
532 583
 
533 584
 					case 'CLASS':
534
-						if ($event['public']) continue;	// public is default, no need to export, fails CalDAVTester if added as default
585
+						if ($event['public'])
586
+						{
587
+							continue;
588
+						}
589
+						// public is default, no need to export, fails CalDAVTester if added as default
535 590
 						$attributes['CLASS'] = $event['public'] ? 'PUBLIC' : 'PRIVATE';
536 591
 						// Apple iCal on OS X uses X-CALENDARSERVER-ACCESS: CONFIDENTIAL on VCALANDAR (not VEVENT!)
537 592
 						if (!$event['public'] && $this->productManufacturer == 'groupdav')
@@ -563,9 +618,18 @@  discard block
 block discarded – undo
563 618
 									'CUTYPE'   => 'INDIVIDUAL',
564 619
 									//'RSVP'     => 'FALSE',
565 620
 									);
566
-								if (!empty($organizerCN)) $options['CN'] = $organizerCN;
567
-								if (!empty($organizerEMail)) $options['EMAIL'] = $organizerEMail;
568
-								if (!empty($event['owner'])) $options['X-EGROUPWARE-UID'] = $event['owner'];
621
+								if (!empty($organizerCN))
622
+								{
623
+									$options['CN'] = $organizerCN;
624
+								}
625
+								if (!empty($organizerEMail))
626
+								{
627
+									$options['EMAIL'] = $organizerEMail;
628
+								}
629
+								if (!empty($event['owner']))
630
+								{
631
+									$options['X-EGROUPWARE-UID'] = $event['owner'];
632
+								}
569 633
 								$attributes['ATTENDEE'][] = $organizerURL;
570 634
 			    				$parameters['ATTENDEE'][] = $options;
571 635
 		    				}
@@ -594,9 +658,12 @@  discard block
 block discarded – undo
594 658
 						{
595 659
 							// Hack for CalDAVTester to export duration instead of endtime
596 660
 							if ($tzid == 'UTC' && $event['end'] - $event['start'] <= 86400)
597
-								$attributes['duration'] = $event['end'] - $event['start'];
598
-							else
599
-							$attributes['DTEND'] = self::getDateTime($event['end'],$tzid,$parameters['DTEND']);
661
+							{
662
+															$attributes['duration'] = $event['end'] - $event['start'];
663
+							}
664
+							else {
665
+														$attributes['DTEND'] = self::getDateTime($event['end'],$tzid,$parameters['DTEND']);
666
+							}
600 667
 						}
601 668
 						else
602 669
 						{
@@ -616,7 +683,11 @@  discard block
 block discarded – undo
616 683
 						break;
617 684
 
618 685
 					case 'RRULE':
619
-						if ($event['recur_type'] == MCAL_RECUR_NONE) break;		// no recuring event
686
+						if ($event['recur_type'] == MCAL_RECUR_NONE)
687
+						{
688
+							break;
689
+						}
690
+						// no recuring event
620 691
 						$rriter = calendar_rrule::event2rrule($event, false, $tzid);
621 692
 						$rrule = $rriter->generate_rrule($version);
622 693
 						if ($event['recur_enddate'])
@@ -650,7 +721,10 @@  discard block
 block discarded – undo
650 721
 						break;
651 722
 
652 723
 					case 'EXDATE':
653
-						if ($event['recur_type'] == MCAL_RECUR_NONE) break;
724
+						if ($event['recur_type'] == MCAL_RECUR_NONE)
725
+						{
726
+							break;
727
+						}
654 728
 						if (!empty($event['recur_exception']))
655 729
 						{
656 730
 							if (empty($event['whole_day']))
@@ -677,14 +751,21 @@  discard block
 block discarded – undo
677 751
 									);
678 752
 								}
679 753
 								$event['recur_exception'] = $days;
680
-								if ($version != '1.0') $parameters['EXDATE']['VALUE'] = 'DATE';
754
+								if ($version != '1.0')
755
+								{
756
+									$parameters['EXDATE']['VALUE'] = 'DATE';
757
+								}
681 758
 							}
682 759
 							$vevent->setAttribute('EXDATE', $event['recur_exception'], $parameters['EXDATE']);
683 760
 						}
684 761
 						break;
685 762
 
686 763
 					case 'PRIORITY':
687
-						if (!$event['priority']) continue;	// 0=undefined is default, no need to export, fails CalDAVTester if our default is added
764
+						if (!$event['priority'])
765
+						{
766
+							continue;
767
+						}
768
+						// 0=undefined is default, no need to export, fails CalDAVTester if our default is added
688 769
 						if ($this->productManufacturer == 'funambol' &&
689 770
 							(strpos($this->productName, 'outlook') !== false
690 771
 								|| strpos($this->productName, 'pocket pc') !== false))
@@ -698,7 +779,11 @@  discard block
 block discarded – undo
698 779
 						break;
699 780
 
700 781
 					case 'TRANSP':
701
-						if (!$event['non_blocking']) continue;	// OPAQUE is default, no need to export, fails CalDAVTester if added as default
782
+						if (!$event['non_blocking'])
783
+						{
784
+							continue;
785
+						}
786
+						// OPAQUE is default, no need to export, fails CalDAVTester if added as default
702 787
 						if ($version == '1.0')
703 788
 						{
704 789
 							$attributes['TRANSP'] = ($event['non_blocking'] ? 1 : 0);
@@ -755,7 +840,11 @@  discard block
 block discarded – undo
755 840
 						elseif ($event['recurrence'] && $event['reference'])
756 841
 						{
757 842
 							// $event['reference'] is a calendar_id, not a timestamp
758
-							if (!($revent = $this->read($event['reference']))) break;	// referenced event does not exist
843
+							if (!($revent = $this->read($event['reference'])))
844
+							{
845
+								break;
846
+							}
847
+							// referenced event does not exist
759 848
 
760 849
 							if (empty($revent['whole_day']))
761 850
 							{
@@ -881,7 +970,10 @@  discard block
 block discarded – undo
881 970
 			foreach ((array)$event['alarm'] as $alarmData)
882 971
 			{
883 972
 				// skip over alarms that don't have the minimum required info
884
-				if (!isset($alarmData['offset']) && !isset($alarmData['time'])) continue;
973
+				if (!isset($alarmData['offset']) && !isset($alarmData['time']))
974
+				{
975
+					continue;
976
+				}
885 977
 
886 978
 				// skip alarms not being set for all users and alarms owned by other users
887 979
 				if ($alarmData['all'] != true && $alarmData['owner'] != $this->user)
@@ -898,7 +990,10 @@  discard block
 block discarded – undo
898 990
 
899 991
 				if ($version == '1.0')
900 992
 				{
901
-					if ($event['title']) $description = $event['title'];
993
+					if ($event['title'])
994
+					{
995
+						$description = $event['title'];
996
+					}
902 997
 					if ($description)
903 998
 					{
904 999
 						$values['DALARM']['snooze_time'] = '';
@@ -918,7 +1013,10 @@  discard block
 block discarded – undo
918 1013
 					// VCalendar 2.0 / RFC 2445
919 1014
 
920 1015
 					// RFC requires DESCRIPTION for DISPLAY
921
-					if (!$event['title'] && !$description) $description = 'Alarm';
1016
+					if (!$event['title'] && !$description)
1017
+					{
1018
+						$description = 'Alarm';
1019
+					}
922 1020
 
923 1021
 					/* Disabling for now
924 1022
 					// Lightning infinitly pops up alarms for recuring events, if the only use an offset
@@ -1109,13 +1207,20 @@  discard block
 block discarded – undo
1109 1207
 		$this->events_imported = 0;
1110 1208
 		$replace = $delete_exceptions= false;
1111 1209
 
1112
-		if (!is_array($this->supportedFields)) $this->setSupportedFields();
1210
+		if (!is_array($this->supportedFields))
1211
+		{
1212
+			$this->setSupportedFields();
1213
+		}
1113 1214
 
1114 1215
 		if (!($events = $this->icaltoegw($_vcalData, $principalURL, $charset)))
1115 1216
 		{
1116 1217
 			return false;
1117 1218
 		}
1118
-		if (!is_array($events)) $cal_id = -1;	// just to be sure, as iterator does NOT allow array access (eg. $events[0])
1219
+		if (!is_array($events))
1220
+		{
1221
+			$cal_id = -1;
1222
+		}
1223
+		// just to be sure, as iterator does NOT allow array access (eg. $events[0])
1119 1224
 
1120 1225
 		if ($cal_id > 0)
1121 1226
 		{
@@ -1123,8 +1228,14 @@  discard block
 block discarded – undo
1123 1228
 			{
1124 1229
 				$replace = $recur_date == 0;
1125 1230
 				$events[0]['id'] = $cal_id;
1126
-				if (!is_null($etag)) $events[0]['etag'] = (int) $etag;
1127
-				if ($recur_date) $events[0]['recurrence'] = $recur_date;
1231
+				if (!is_null($etag))
1232
+				{
1233
+					$events[0]['etag'] = (int) $etag;
1234
+				}
1235
+				if ($recur_date)
1236
+				{
1237
+					$events[0]['recurrence'] = $recur_date;
1238
+				}
1128 1239
 			}
1129 1240
 			elseif (($foundEvent = $this->find_event(array('id' => $cal_id), 'exact')) &&
1130 1241
 					($eventId = array_shift($foundEvent)) &&
@@ -1132,7 +1243,10 @@  discard block
 block discarded – undo
1132 1243
 			{
1133 1244
 				foreach ($events as $k => $event)
1134 1245
 				{
1135
-					if (!isset($event['uid'])) $events[$k]['uid'] = $egwEvent['uid'];
1246
+					if (!isset($event['uid']))
1247
+					{
1248
+						$events[$k]['uid'] = $egwEvent['uid'];
1249
+					}
1136 1250
 				}
1137 1251
 			}
1138 1252
 		}
@@ -1162,10 +1276,17 @@  discard block
 block discarded – undo
1162 1276
 		$msg = null;
1163 1277
 		foreach ($events as $event)
1164 1278
 		{
1165
-			if (!is_array($event)) continue; // the iterator may return false
1279
+			if (!is_array($event))
1280
+			{
1281
+				continue;
1282
+			}
1283
+			// the iterator may return false
1166 1284
 			++$this->events_imported;
1167 1285
 
1168
-			if ($this->so->isWholeDay($event)) $event['whole_day'] = true;
1286
+			if ($this->so->isWholeDay($event))
1287
+			{
1288
+				$event['whole_day'] = true;
1289
+			}
1169 1290
 			if (is_array($event['category']))
1170 1291
 			{
1171 1292
 				$event['category'] = $this->find_or_add_categories($event['category'],
@@ -1202,7 +1323,10 @@  discard block
 block discarded – undo
1202 1323
 						}
1203 1324
 						else
1204 1325
 						{
1205
-							if (!($exception = $this->read($id))) continue;
1326
+							if (!($exception = $this->read($id)))
1327
+							{
1328
+								continue;
1329
+							}
1206 1330
 							$exception['uid'] = common::generate_uid('calendar', $id);
1207 1331
 							$exception['reference'] = $exception['recurrence'] = 0;
1208 1332
 							$this->update($exception, true,true,false,true,$msg,$skip_notification);
@@ -1291,7 +1415,10 @@  discard block
 block discarded – undo
1291 1415
 								break;
1292 1416
 
1293 1417
 							default:
1294
-								if (!empty($value)) $event[$key] = $value;
1418
+								if (!empty($value))
1419
+								{
1420
+									$event[$key] = $value;
1421
+								}
1295 1422
 						}
1296 1423
 					}
1297 1424
 				}
@@ -1389,7 +1516,10 @@  discard block
 block discarded – undo
1389 1516
 			else // common adjustments for new events
1390 1517
 			{
1391 1518
 				unset($event['id']);
1392
-				if ($caldav_name) $event['caldav_name'] = $caldav_name;
1519
+				if ($caldav_name)
1520
+				{
1521
+					$event['caldav_name'] = $caldav_name;
1522
+				}
1393 1523
 				// set non blocking all day depending on the user setting
1394 1524
 				if (!empty($event['whole_day']) && $this->nonBlockingAllday)
1395 1525
 				{
@@ -1437,7 +1567,10 @@  discard block
 block discarded – undo
1437 1567
 					|| !isset($event['participants'][$event['owner']]))
1438 1568
 				{
1439 1569
 					$status = calendar_so::combine_status($event['owner'] == $this->user ? 'A' : 'U', 1, 'CHAIR');
1440
-					if (!is_array($event['participants'])) $event['participants'] = array();
1570
+					if (!is_array($event['participants']))
1571
+					{
1572
+						$event['participants'] = array();
1573
+					}
1441 1574
 					$event['participants'][$event['owner']] = $status;
1442 1575
 				}
1443 1576
 				else
@@ -1590,7 +1723,10 @@  discard block
 block discarded – undo
1590 1723
 								$occurence = $exception = false;
1591 1724
 								foreach ($event_info['master_event']['recur_exception'] as $exception)
1592 1725
 								{
1593
-									if ($exception > $event['start']) break;
1726
+									if ($exception > $event['start'])
1727
+									{
1728
+										break;
1729
+									}
1594 1730
 									$occurence = $exception;
1595 1731
 								}
1596 1732
 								if (!$occurence)
@@ -1680,12 +1816,15 @@  discard block
 block discarded – undo
1680 1816
 					case 'SERIES-MASTER':
1681 1817
 					case 'SERIES-EXCEPTION':
1682 1818
 					case 'SERIES-EXCEPTION-PROPAGATE':
1683
-						if (is_array($event_info['stored_event'])) // status update requires a stored event
1819
+						if (is_array($event_info['stored_event']))
1820
+						{
1821
+							// status update requires a stored event
1684 1822
 						{
1685 1823
 							if ($event_info['acl_edit'])
1686 1824
 							{
1687 1825
 								// update all participants if we have the right to do that
1688 1826
 								$this->update_status($event, $event_info['stored_event'],0,$skip_notification);
1827
+						}
1689 1828
 							}
1690 1829
 							elseif (isset($event['participants'][$this->user]) || isset($event_info['stored_event']['participants'][$this->user]))
1691 1830
 							{
@@ -1697,9 +1836,12 @@  discard block
 block discarded – undo
1697 1836
 						break;
1698 1837
 
1699 1838
 					case 'SERIES-PSEUDO-EXCEPTION':
1700
-						if (is_array($event_info['master_event'])) // status update requires a stored master event
1839
+						if (is_array($event_info['master_event']))
1840
+						{
1841
+							// status update requires a stored master event
1701 1842
 						{
1702 1843
 							$recurrence = $this->date2usertime($event['recurrence']);
1844
+						}
1703 1845
 							if ($event_info['acl_edit'])
1704 1846
 							{
1705 1847
 								// update all participants if we have the right to do that
@@ -1772,7 +1914,10 @@  discard block
 block discarded – undo
1772 1914
 	 */
1773 1915
 	public function sync_alarms(array &$event, array $old_alarms, $user)
1774 1916
 	{
1775
-		if ($this->debug) error_log(__METHOD__."(".array2string($event).', old_alarms='.array2string($old_alarms).", $user,)");
1917
+		if ($this->debug)
1918
+		{
1919
+			error_log(__METHOD__."(".array2string($event).', old_alarms='.array2string($old_alarms).", $user,)");
1920
+		}
1776 1921
 		$modified = 0;
1777 1922
 		foreach($event['alarm'] as &$alarm)
1778 1923
 		{
@@ -1796,19 +1941,40 @@  discard block
 block discarded – undo
1796 1941
 			if ($alarm['offset'] != $old_alarm['offset'] || $old_alarm['owner'] != $user && !$alarm['all'])
1797 1942
 			{
1798 1943
 				$alarm['owner'] = $user;
1799
-				if (!isset($alarm['time'])) $alarm['time'] = $event['start'] - $alarm['offset'];
1800
-				if ($alarm['time'] < time()) calendar_so::shift_alarm($event, $alarm);
1801
-				if ($this->debug) error_log(__METHOD__."() adding new alarm from client ".array2string($alarm));
1802
-				if ($event['id']) $alarm['id'] = $this->save_alarm($event['id'], $alarm);
1944
+				if (!isset($alarm['time']))
1945
+				{
1946
+					$alarm['time'] = $event['start'] - $alarm['offset'];
1947
+				}
1948
+				if ($alarm['time'] < time())
1949
+				{
1950
+					calendar_so::shift_alarm($event, $alarm);
1951
+				}
1952
+				if ($this->debug)
1953
+				{
1954
+					error_log(__METHOD__."() adding new alarm from client ".array2string($alarm));
1955
+				}
1956
+				if ($event['id'])
1957
+				{
1958
+					$alarm['id'] = $this->save_alarm($event['id'], $alarm);
1959
+				}
1803 1960
 				++$modified;
1804 1961
 			}
1805 1962
 			// existing alarm --> update it
1806 1963
 			elseif ($alarm['offset'] == $old_alarm['offset'] && ($old_alarm['owner'] == $user || $old_alarm['all']))
1807 1964
 			{
1808
-				if (!isset($alarm['time'])) $alarm['time'] = $event['start'] - $alarm['offset'];
1809
-				if ($alarm['time'] < time()) calendar_so::shift_alarm($event, $alarm);
1965
+				if (!isset($alarm['time']))
1966
+				{
1967
+					$alarm['time'] = $event['start'] - $alarm['offset'];
1968
+				}
1969
+				if ($alarm['time'] < time())
1970
+				{
1971
+					calendar_so::shift_alarm($event, $alarm);
1972
+				}
1810 1973
 				$alarm = array_merge($old_alarm, $alarm);
1811
-				if ($this->debug) error_log(__METHOD__."() updating existing alarm from client ".array2string($alarm));
1974
+				if ($this->debug)
1975
+				{
1976
+					error_log(__METHOD__."() updating existing alarm from client ".array2string($alarm));
1977
+				}
1812 1978
 				$alarm['id'] = $this->save_alarm($event['id'], $alarm);
1813 1979
 				++$modified;
1814 1980
 			}
@@ -1822,7 +1988,10 @@  discard block
 block discarded – undo
1822 1988
 				unset($old_alarm[$id]);
1823 1989
 				continue;
1824 1990
 			}
1825
-			if ($this->debug) error_log(__METHOD__."() deleting alarm '$id' deleted on client ".array2string($old_alarm));
1991
+			if ($this->debug)
1992
+			{
1993
+				error_log(__METHOD__."() deleting alarm '$id' deleted on client ".array2string($old_alarm));
1994
+			}
1826 1995
 			$this->delete_alarm($id);
1827 1996
 			++$modified;
1828 1997
 		}
@@ -2241,7 +2410,10 @@  discard block
 block discarded – undo
2241 2410
 				array2string($_vcalData)."\n",3,$this->logfile);
2242 2411
 		}
2243 2412
 
2244
-		if (!is_array($this->supportedFields)) $this->setSupportedFields();
2413
+		if (!is_array($this->supportedFields))
2414
+		{
2415
+			$this->setSupportedFields();
2416
+		}
2245 2417
 
2246 2418
 		// we use egw_ical_iterator only on resources, as calling importVCal() accesses single events like an array (eg. $events[0])
2247 2419
 		if (is_resource($_vcalData))
@@ -2552,19 +2724,27 @@  discard block
 block discarded – undo
2552 2724
 								$vcardData['recur_interval'] = $recurenceMatches[1];
2553 2725
 								$vcardData['recur_enddate'] = $this->vCalendar->_parseDateTime(trim($recurenceMatches[2]));
2554 2726
 							}
2555
-							else break;
2727
+							else {
2728
+								break;
2729
+							}
2556 2730
 							// fall-through
2557 2731
 						case 'DAILY':	// 2.0
2558 2732
 							$vcardData['recur_type'] = MCAL_RECUR_DAILY;
2559
-							if (stripos($recurence, 'BYDAY') === false) break;
2733
+							if (stripos($recurence, 'BYDAY') === false)
2734
+							{
2735
+								break;
2736
+							}
2560 2737
 							// hack to handle TYPE=DAILY;BYDAY= as WEEKLY, which is true as long as there's no interval
2561 2738
 							// fall-through
2562 2739
 						case 'W':
2563 2740
 						case 'WEEKLY':
2564 2741
 							$days = array();
2565
-							if (preg_match('/W(\d+) *((?i: [AEFHMORSTUW]{2})+)?( +([^ ]*))$/',$recurence, $recurenceMatches))		// 1.0
2742
+							if (preg_match('/W(\d+) *((?i: [AEFHMORSTUW]{2})+)?( +([^ ]*))$/',$recurence, $recurenceMatches))
2743
+							{
2744
+								// 1.0
2566 2745
 							{
2567 2746
 								$vcardData['recur_interval'] = $recurenceMatches[1];
2747
+							}
2568 2748
 								if (empty($recurenceMatches[2]))
2569 2749
 								{
2570 2750
 									$days[0] = strtoupper(substr(date('D', $vcardData['start']),0,2));
@@ -2577,7 +2757,10 @@  discard block
 block discarded – undo
2577 2757
 								$repeatMatches = null;
2578 2758
 								if (preg_match('/#(\d+)/',$recurenceMatches[4],$repeatMatches))
2579 2759
 								{
2580
-									if ($repeatMatches[1]) $vcardData['recur_count'] = $repeatMatches[1];
2760
+									if ($repeatMatches[1])
2761
+									{
2762
+										$vcardData['recur_count'] = $repeatMatches[1];
2763
+									}
2581 2764
 								}
2582 2765
 								else
2583 2766
 								{
@@ -2586,9 +2769,12 @@  discard block
 block discarded – undo
2586 2769
 
2587 2770
 								$recur_days = $this->recur_days_1_0;
2588 2771
 							}
2589
-							elseif (preg_match('/BYDAY=([^;: ]+)/',$recurence,$recurenceMatches))	// 2.0
2772
+							elseif (preg_match('/BYDAY=([^;: ]+)/',$recurence,$recurenceMatches))
2773
+							{
2774
+								// 2.0
2590 2775
 							{
2591 2776
 								$days = explode(',',$recurenceMatches[1]);
2777
+							}
2592 2778
 								$recur_days = $this->recur_days;
2593 2779
 							}
2594 2780
 							else	// no day given, use the day of dtstart
@@ -2647,7 +2833,10 @@  discard block
 block discarded – undo
2647 2833
 							{
2648 2834
 								$vcardData['recur_interval'] = $recurenceMatches[1];
2649 2835
 								$vcardData['recur_enddate'] = $this->vCalendar->_parseDateTime($recurenceMatches[2]);
2650
-							} else break;
2836
+							}
2837
+							else {
2838
+								break;
2839
+							}
2651 2840
 							// fall-through
2652 2841
 						case 'YEARLY':	// 2.0
2653 2842
 							if (strpos($recurence, 'BYDAY') === false)
@@ -2667,7 +2856,10 @@  discard block
 block discarded – undo
2667 2856
 					}
2668 2857
 					break;
2669 2858
 				case 'EXDATE':
2670
-					if (!$attributes['value']) break;
2859
+					if (!$attributes['value'])
2860
+					{
2861
+						break;
2862
+					}
2671 2863
 					if ((isset($attributes['params']['VALUE'])
2672 2864
 							&& $attributes['params']['VALUE'] == 'DATE') ||
2673 2865
 						(!isset($attributes['params']['VALUE']) && $isDate))
@@ -2747,13 +2939,16 @@  discard block
 block discarded – undo
2747 2939
 					// fall throught
2748 2940
 				case 'ATTENDEE':
2749 2941
 					if (isset($attributes['params']['PARTSTAT']))
2750
-				    {
2942
+					{
2751 2943
 				    	$attributes['params']['STATUS'] = $attributes['params']['PARTSTAT'];
2752 2944
 				    }
2753 2945
 				    if (isset($attributes['params']['STATUS']))
2754
-					{
2946
+				    {
2755 2947
 						$status = $this->status_ical2egw[strtoupper($attributes['params']['STATUS'])];
2756
-						if (empty($status)) $status = 'X';
2948
+						if (empty($status))
2949
+						{
2950
+							$status = 'X';
2951
+						}
2757 2952
 					}
2758 2953
 					else
2759 2954
 					{
@@ -2813,7 +3008,10 @@  discard block
 block discarded – undo
2813 3008
 							$uid = $this->user;
2814 3009
 					}
2815 3010
 					// check principal url from CalDAV here after X-EGROUPWARE-UID and to get optional X-EGROUPWARE-QUANTITY
2816
-					if (!$uid) $uid = groupdav_principals::url2uid($attributes['value'], null, $cn);
3011
+					if (!$uid)
3012
+					{
3013
+						$uid = groupdav_principals::url2uid($attributes['value'], null, $cn);
3014
+					}
2817 3015
 
2818 3016
 					// try to find an email address
2819 3017
 					if (!$uid && $email && ($uid = $GLOBALS['egw']->accounts->name2id($email, 'account_email')))
@@ -2881,7 +3079,10 @@  discard block
 block discarded – undo
2881 3079
 								}
2882 3080
 								$status = 'U'; // keep the group
2883 3081
 							}
2884
-							else continue; // can't find this group
3082
+							else {
3083
+								continue;
3084
+							}
3085
+							// can't find this group
2885 3086
 						}
2886 3087
 						elseif (empty($searcharray))
2887 3088
 						{
@@ -2940,7 +3141,9 @@  discard block
 block discarded – undo
2940 3141
 
2941 3142
 								try {
2942 3143
 									if (!$this->calendarOwner && is_numeric($uid) && $role == 'CHAIR')
2943
-										$component->getAttribute('ORGANIZER');
3144
+									{
3145
+																			$component->getAttribute('ORGANIZER');
3146
+									}
2944 3147
 								}
2945 3148
 								catch(Horde_Icalendar_Exception $e)
2946 3149
 								{
@@ -2977,7 +3180,10 @@  discard block
 block discarded – undo
2977 3180
 					}
2978 3181
 					break;
2979 3182
 				case 'CREATED':		// will be written direct to the event
2980
-					if ($event['modified']) break;
3183
+					if ($event['modified'])
3184
+					{
3185
+						break;
3186
+					}
2981 3187
 					// fall through
2982 3188
 				case 'LAST-MODIFIED':	// will be written direct to the event
2983 3189
 					$event['modified'] = $attributes['value'];
@@ -2998,7 +3204,11 @@  discard block
 block discarded – undo
2998 3204
 					break;
2999 3205
 
3000 3206
 				case 'ATTACH':
3001
-					if ($attributes['params'] && !empty($attributes['params']['FMTTYPE'])) break;	// handeled by managed attachment code
3207
+					if ($attributes['params'] && !empty($attributes['params']['FMTTYPE']))
3208
+					{
3209
+						break;
3210
+					}
3211
+					// handeled by managed attachment code
3002 3212
 					// fall throught to store external attachment url
3003 3213
 				default:	// X- attribute or other by EGroupware unsupported property
3004 3214
 					//error_log(__METHOD__."() $attributes[name] = ".array2string($attributes));
@@ -3129,7 +3339,10 @@  discard block
 block discarded – undo
3129 3339
 			$event['end'] = $event['start'] + 60 * $this->cal_prefs['defaultlength'];
3130 3340
 		}
3131 3341
 
3132
-		if ($this->calendarOwner) $event['owner'] = $this->calendarOwner;
3342
+		if ($this->calendarOwner)
3343
+		{
3344
+			$event['owner'] = $this->calendarOwner;
3345
+		}
3133 3346
 
3134 3347
 		// parsing ATTACH attributes for managed attachments
3135 3348
 		$event['attach-delete-by-put'] = $component->getAttributeDefault('X-EGROUPWARE-ATTACH-INCLUDED', null) === 'TRUE';
@@ -3155,7 +3368,10 @@  discard block
 block discarded – undo
3155 3368
 				$filter = $relax ? 'relax' : 'check';
3156 3369
 				$event = array_shift($events);
3157 3370
 				$eventId = -1;
3158
-				if ($this->so->isWholeDay($event)) $event['whole_day'] = true;
3371
+				if ($this->so->isWholeDay($event))
3372
+				{
3373
+					$event['whole_day'] = true;
3374
+				}
3159 3375
 				if ($contentID)
3160 3376
 				{
3161 3377
 					$parts = preg_split('/:/', $contentID);
@@ -3187,8 +3403,16 @@  discard block
 block discarded – undo
3187 3403
 	 */
3188 3404
 	function freebusy($user,$end=null,$utc=true, $charset='UTF-8', $start=null, $method='PUBLISH', array $extra=null)
3189 3405
 	{
3190
-		if (!$start) $start = time();	// default now
3191
-		if (!$end) $end = time() + 100*DAY_s;	// default next 100 days
3406
+		if (!$start)
3407
+		{
3408
+			$start = time();
3409
+		}
3410
+		// default now
3411
+		if (!$end)
3412
+		{
3413
+			$end = time() + 100*DAY_s;
3414
+		}
3415
+		// default next 100 days
3192 3416
 
3193 3417
 		$vcal = new Horde_Icalendar;
3194 3418
 		$vcal->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware Calendar '.$GLOBALS['egw_info']['apps']['calendar']['version'].'//'.
@@ -3210,10 +3434,13 @@  discard block
 block discarded – undo
3210 3434
 				$attributes[$attr] = date('Ymd\THis', $value);
3211 3435
 			}
3212 3436
 		}
3213
-		if (is_null($extra)) $extra = array(
3437
+		if (is_null($extra))
3438
+		{
3439
+			$extra = array(
3214 3440
 			'URL' => $this->freebusy_url($user),
3215 3441
 			'ORGANIZER' => 'mailto:'.$GLOBALS['egw']->accounts->id2name($user,'account_email'),
3216 3442
 		);
3443
+		}
3217 3444
 		foreach($attributes+$extra as $attr => $value)
3218 3445
 		{
3219 3446
 			$vfreebusy->setAttribute($attr, $value);
@@ -3229,9 +3456,18 @@  discard block
 block discarded – undo
3229 3456
 		{
3230 3457
 			foreach ($fbdata as $event)
3231 3458
 			{
3232
-				if ($event['non_blocking']) continue;
3233
-				if ($event['uid'] === $extra['X-CALENDARSERVER-MASK-UID']) continue;
3234
-				if ($event['participants'][$user] == 'R') continue;
3459
+				if ($event['non_blocking'])
3460
+				{
3461
+					continue;
3462
+				}
3463
+				if ($event['uid'] === $extra['X-CALENDARSERVER-MASK-UID'])
3464
+				{
3465
+					continue;
3466
+				}
3467
+				if ($event['participants'][$user] == 'R')
3468
+				{
3469
+					continue;
3470
+				}
3235 3471
 
3236 3472
 				$fbtype = $event['participants'][$user] == 'T' ? 'BUSY-TENTATIVE' : 'BUSY';
3237 3473
 
Please login to merge, or discard this patch.
calendar/inc/class.calendar_sif.inc.php 4 patches
Doc Comments   +2 added lines, -6 removed lines patch added patch discarded remove patch
@@ -409,11 +409,7 @@  discard block
 block discarded – undo
409 409
 	/**
410 410
 	* @return int event id
411 411
 	* @param string	$_sifdata   the SIFE data
412
-	* @param int	$_calID=-1	the internal addressbook id
413
-	* @param boolean $merge=false	merge data with existing entry
414
-	* @param int $recur_date=0 if set, import the recurrence at this timestamp,
415
-	*                          default 0 => import whole series (or events, if not recurring)
416
-	* @desc import a SIFE into the calendar
412
+	* @param int	$_calID	the internal addressbook id
417 413
 	*/
418 414
 	function addSIF($_sifdata, $_calID=-1, $merge=false, $recur_date=0)
419 415
 	{
@@ -797,7 +793,7 @@  discard block
 block discarded – undo
797 793
 	* return a sife
798 794
 	*
799 795
 	* @param int	$_id		the id of the event
800
-	* @param int $recur_date=0	if set export the next recurrence at or after the timestamp,
796
+	* @param int $recur_date	if set export the next recurrence at or after the timestamp,
801 797
 	*                          	default 0 => export whole series (or events, if not recurring)
802 798
 	* @return string containing the SIFE
803 799
 	*/
Please login to merge, or discard this patch.
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -407,14 +407,14 @@  discard block
 block discarded – undo
407 407
 	}
408 408
 
409 409
 	/**
410
-	* @return int event id
411
-	* @param string	$_sifdata   the SIFE data
412
-	* @param int	$_calID=-1	the internal addressbook id
413
-	* @param boolean $merge=false	merge data with existing entry
414
-	* @param int $recur_date=0 if set, import the recurrence at this timestamp,
415
-	*                          default 0 => import whole series (or events, if not recurring)
416
-	* @desc import a SIFE into the calendar
417
-	*/
410
+	 * @return int event id
411
+	 * @param string	$_sifdata   the SIFE data
412
+	 * @param int	$_calID=-1	the internal addressbook id
413
+	 * @param boolean $merge=false	merge data with existing entry
414
+	 * @param int $recur_date=0 if set, import the recurrence at this timestamp,
415
+	 *                          default 0 => import whole series (or events, if not recurring)
416
+	 * @desc import a SIFE into the calendar
417
+	 */
418 418
 	function addSIF($_sifdata, $_calID=-1, $merge=false, $recur_date=0)
419 419
 	{
420 420
 		if ($this->log)
@@ -794,13 +794,13 @@  discard block
 block discarded – undo
794 794
 	}
795 795
 
796 796
 	/**
797
-	* return a sife
798
-	*
799
-	* @param int	$_id		the id of the event
800
-	* @param int $recur_date=0	if set export the next recurrence at or after the timestamp,
801
-	*                          	default 0 => export whole series (or events, if not recurring)
802
-	* @return string containing the SIFE
803
-	*/
797
+	 * return a sife
798
+	 *
799
+	 * @param int	$_id		the id of the event
800
+	 * @param int $recur_date=0	if set export the next recurrence at or after the timestamp,
801
+	 *                          	default 0 => export whole series (or events, if not recurring)
802
+	 * @return string containing the SIFE
803
+	 */
804 804
 	function getSIF($_id, $recur_date=0)
805 805
 	{
806 806
 		if ($this->log)
@@ -1166,13 +1166,13 @@  discard block
 block discarded – undo
1166 1166
 	}
1167 1167
 
1168 1168
 	/**
1169
-	* Set the supported fields
1170
-	*
1171
-	* Currently we only store name and version, manucfacturer is always Funambol
1172
-	*
1173
-	* @param string $_productName
1174
-	* @param string $_productSoftwareVersion
1175
-	*/
1169
+	 * Set the supported fields
1170
+	 *
1171
+	 * Currently we only store name and version, manucfacturer is always Funambol
1172
+	 *
1173
+	 * @param string $_productName
1174
+	 * @param string $_productSoftwareVersion
1175
+	 */
1176 1176
 	function setSupportedFields($_productName='', $_productSoftwareVersion='')
1177 1177
 	{
1178 1178
 		$state =& $_SESSION['SyncML.state'];
Please login to merge, or discard this patch.
Spacing   +95 added lines, -95 removed lines patch added patch discarded remove patch
@@ -116,14 +116,14 @@  discard block
 block discarded – undo
116 116
 	 * @var boolean
117 117
 	 */
118 118
 	var $log = false;
119
-	var $logfile="/tmp/log-sifcal";
119
+	var $logfile = "/tmp/log-sifcal";
120 120
 
121 121
 
122 122
 	// constants for recurence type
123 123
 	const olRecursDaily		= 0;
124 124
 	const olRecursWeekly	= 1;
125 125
 	const olRecursMonthly	= 2;
126
-	const olRecursMonthNth	= 3;
126
+	const olRecursMonthNth = 3;
127 127
 	const olRecursYearly	= 5;
128 128
 	const olRecursYearNth	= 6;
129 129
 
@@ -131,9 +131,9 @@  discard block
 block discarded – undo
131 131
 	const olSunday		= 1;
132 132
 	const olMonday		= 2;
133 133
 	const olTuesday 	= 4;
134
-	const olWednesday	= 8;
134
+	const olWednesday = 8;
135 135
 	const olThursday	= 16;
136
-	const olFriday		= 32;
136
+	const olFriday = 32;
137 137
 	const olSaturday	= 64;
138 138
 
139 139
 	// standard headers
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 				break;
169 169
 
170 170
 			default:
171
-				if(!empty($this->sifMapping[$_tag]))
171
+				if (!empty($this->sifMapping[$_tag]))
172 172
 				{
173 173
 					$this->event[$this->sifMapping[$_tag]] = trim($this->sifData);
174 174
 				}
@@ -192,11 +192,11 @@  discard block
 block discarded – undo
192 192
 	{
193 193
 		if (empty($tzid) || $tzid == 'UTC')
194 194
 		{
195
-			return $this->vCalendar->_exportDateTime(egw_time::to($time,'ts'));
195
+			return $this->vCalendar->_exportDateTime(egw_time::to($time, 'ts'));
196 196
 		}
197
-		if (!is_a($time,'DateTime'))
197
+		if (!is_a($time, 'DateTime'))
198 198
 		{
199
-			$time = new egw_time($time,egw_time::$server_timezone);
199
+			$time = new egw_time($time, egw_time::$server_timezone);
200 200
 		}
201 201
 		if (!isset(self::$tz_cache[$tzid]))
202 202
 		{
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 		return $time->format('Ymd\THis');
208 208
 	}
209 209
 
210
-	function siftoegw($sifData, $_calID=-1)
210
+	function siftoegw($sifData, $_calID = -1)
211 211
 	{
212 212
 		$finalEvent	= array();
213 213
 		$this->event = array();
@@ -258,13 +258,13 @@  discard block
 block discarded – undo
258 258
 					if ($value == 1)
259 259
 					{
260 260
 						$finalEvent['whole_day'] = true;
261
-						$startParts = explode('-',$this->event['start']);
261
+						$startParts = explode('-', $this->event['start']);
262 262
 						$finalEvent['startdate']['hour'] = $finalEvent['startdate']['minute'] = $finalEvent['startdate']['second'] = 0;
263 263
 						$finalEvent['startdate']['year'] = $startParts[0];
264 264
 						$finalEvent['startdate']['month'] = $startParts[1];
265 265
 						$finalEvent['startdate']['day'] = $startParts[2];
266 266
 						$finalEvent['start'] = $this->date2ts($finalEvent['startdate']);
267
-						$endParts = explode('-',$this->event['end']);
267
+						$endParts = explode('-', $this->event['end']);
268 268
 						$finalEvent['enddate']['hour'] = 23; $finalEvent['enddate']['minute'] = $finalEvent['enddate']['second'] = 59;
269 269
 						$finalEvent['enddate']['year'] = $endParts[0];
270 270
 						$finalEvent['enddate']['month'] = $endParts[1];
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
 						switch ($this->event['recur_type'])
321 321
 						{
322 322
 							case self::olRecursDaily:
323
-								$finalEvent['recur_type']	= MCAL_RECUR_DAILY;
323
+								$finalEvent['recur_type'] = MCAL_RECUR_DAILY;
324 324
 								break;
325 325
 
326 326
 							case self::olRecursWeekly:
@@ -329,15 +329,15 @@  discard block
 block discarded – undo
329 329
 								break;
330 330
 
331 331
 							case self::olRecursMonthly:
332
-								$finalEvent['recur_type']	= MCAL_RECUR_MONTHLY_MDAY;
332
+								$finalEvent['recur_type'] = MCAL_RECUR_MONTHLY_MDAY;
333 333
 								break;
334 334
 
335 335
 							case self::olRecursMonthNth:
336
-								$finalEvent['recur_type']	= MCAL_RECUR_MONTHLY_WDAY;
336
+								$finalEvent['recur_type'] = MCAL_RECUR_MONTHLY_WDAY;
337 337
 								break;
338 338
 
339 339
 							case self::olRecursYearly:
340
-								$finalEvent['recur_type']	= MCAL_RECUR_YEARLY;
340
+								$finalEvent['recur_type'] = MCAL_RECUR_YEARLY;
341 341
 								$finalEvent['recur_interval'] = 1;
342 342
 								break;
343 343
 						}
@@ -384,14 +384,14 @@  discard block
 block discarded – undo
384 384
 
385 385
 		if ($this->log)
386 386
 		{
387
-			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" .
388
-				array2string($finalEvent)."\n",3,$this->logfile);
387
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n".
388
+				array2string($finalEvent)."\n", 3, $this->logfile);
389 389
 		}
390 390
 
391 391
 		return $finalEvent;
392 392
 	}
393 393
 
394
-	function search($_sifdata, $contentID=null, $relax=false)
394
+	function search($_sifdata, $contentID = null, $relax = false)
395 395
 	{
396 396
 		$result = array();
397 397
 		$filter = $relax ? 'relax' : 'exact';
@@ -415,12 +415,12 @@  discard block
 block discarded – undo
415 415
 	*                          default 0 => import whole series (or events, if not recurring)
416 416
 	* @desc import a SIFE into the calendar
417 417
 	*/
418
-	function addSIF($_sifdata, $_calID=-1, $merge=false, $recur_date=0)
418
+	function addSIF($_sifdata, $_calID = -1, $merge = false, $recur_date = 0)
419 419
 	{
420 420
 		if ($this->log)
421 421
 		{
422
-			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" .
423
-				array2string($_sifdata)."\n",3,$this->logfile);
422
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n".
423
+				array2string($_sifdata)."\n", 3, $this->logfile);
424 424
 		}
425 425
 		if (!$event = $this->siftoegw($_sifdata, $_calID))
426 426
 		{
@@ -498,17 +498,17 @@  discard block
 block discarded – undo
498 498
 							calendar_timezones::DateTimeZone($event_info['stored_event']['tzid']);
499 499
 					}
500 500
 					// Adjust dates to original TZ
501
-					$time = new egw_time($event['startdate'],self::$tz_cache[$event_info['stored_event']['tzid']]);
501
+					$time = new egw_time($event['startdate'], self::$tz_cache[$event_info['stored_event']['tzid']]);
502 502
 					$event['start'] = egw_time::to($time, 'server');
503
-					$time = new egw_time($event['enddate'],self::$tz_cache[$event_info['stored_event']['tzid']]);
503
+					$time = new egw_time($event['enddate'], self::$tz_cache[$event_info['stored_event']['tzid']]);
504 504
 					$event['end'] = egw_time::to($time, 'server');
505 505
 					if ($event['recur_type'] != MCAL_RECUR_NONE)
506 506
 					{
507 507
 						foreach ($event['recur_exception'] as $key => $day)
508 508
 						{
509
-							$time = new egw_time($day,egw_time::$server_timezone);
510
-							$time =& $this->so->startOfDay($time, $event_info['stored_event']['tzid']);
511
-							$event['recur_exception'][$key] = egw_time::to($time,'server');
509
+							$time = new egw_time($day, egw_time::$server_timezone);
510
+							$time = & $this->so->startOfDay($time, $event_info['stored_event']['tzid']);
511
+							$event['recur_exception'][$key] = egw_time::to($time, 'server');
512 512
 						}
513 513
 					}
514 514
 				}
@@ -524,7 +524,7 @@  discard block
 block discarded – undo
524 524
 		else // common adjustments for new events
525 525
 		{
526 526
 			// set non blocking all day depending on the user setting
527
-			if (!empty($event['whole_day'])	&& $this->nonBlockingAllday)
527
+			if (!empty($event['whole_day']) && $this->nonBlockingAllday)
528 528
 			{
529 529
 				$event['non_blocking'] = 1;
530 530
 			}
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
 		{
551 551
 			$alarmData['offset'] = $event['alarm'] * 60;
552 552
 			$alarmData['time'] = $event['start'] - $alarmData['offset'];
553
-			$alarmData['owner']	= $this->user;
553
+			$alarmData['owner'] = $this->user;
554 554
 			$alarmData['all'] = false;
555 555
 		}
556 556
 
@@ -578,7 +578,7 @@  discard block
 block discarded – undo
578 578
 									break;
579 579
 								}
580 580
 							}
581
-							if (isset($alarmData)&&is_array($alarmData)) $event['alarm'][] = $alarmData;
581
+							if (isset($alarmData) && is_array($alarmData)) $event['alarm'][] = $alarmData;
582 582
 						}
583 583
 					}
584 584
 					break;
@@ -608,7 +608,7 @@  discard block
 block discarded – undo
608 608
 				if ($this->log)
609 609
 				{
610 610
 					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
611
-						"(): event SINGLE\n",3,$this->logfile);
611
+						"(): event SINGLE\n", 3, $this->logfile);
612 612
 				}
613 613
 
614 614
 				// update the event
@@ -627,7 +627,7 @@  discard block
 block discarded – undo
627 627
 				if ($this->log)
628 628
 				{
629 629
 					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
630
-						"(): event SERIES-MASTER\n",3,$this->logfile);
630
+						"(): event SERIES-MASTER\n", 3, $this->logfile);
631 631
 				}
632 632
 
633 633
 				// remove all known pseudo exceptions and update the event
@@ -636,8 +636,8 @@  discard block
 block discarded – undo
636 636
 					$days = $this->so->get_recurrence_exceptions($event_info['stored_event'], $this->tzid, 0, 0, 'tz_map');
637 637
 					if ($this->log)
638 638
 					{
639
-						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."(EXCEPTIONS MAPPING):\n" .
640
-							array2string($days)."\n",3,$this->logfile);
639
+						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."(EXCEPTIONS MAPPING):\n".
640
+							array2string($days)."\n", 3, $this->logfile);
641 641
 					}
642 642
 					if (is_array($days))
643 643
 					{
@@ -663,7 +663,7 @@  discard block
 block discarded – undo
663 663
 				if ($this->log)
664 664
 				{
665 665
 					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
666
-						"(): event SERIES-EXCEPTION\n",3,$this->logfile);
666
+						"(): event SERIES-EXCEPTION\n", 3, $this->logfile);
667 667
 				}
668 668
 
669 669
 				// update event
@@ -725,7 +725,7 @@  discard block
 block discarded – undo
725 725
 				if ($this->log)
726 726
 				{
727 727
 					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
728
-						"(): event SERIES-PSEUDO-EXCEPTION\n",3,$this->logfile);
728
+						"(): event SERIES-PSEUDO-EXCEPTION\n", 3, $this->logfile);
729 729
 				}
730 730
 
731 731
 				if ($event_info['acl_edit'])
@@ -764,7 +764,7 @@  discard block
 block discarded – undo
764 764
 				break;
765 765
 
766 766
 			case 'SERIES-PSEUDO-EXCEPTION':
767
-				$return_id = is_array($event_info['master_event']) ? $event_info['master_event']['id'] . ':' . $event['recurrence'] : false;
767
+				$return_id = is_array($event_info['master_event']) ? $event_info['master_event']['id'].':'.$event['recurrence'] : false;
768 768
 				break;
769 769
 
770 770
 			case 'SERIES-EXCEPTION-PROPAGATE':
@@ -777,7 +777,7 @@  discard block
 block discarded – undo
777 777
 				{
778 778
 					// we did not have sufficient rights to propagate the status only exception to a real one
779 779
 					// we have to keep the SERIES-PSEUDO-EXCEPTION id and keep the event untouched
780
-					$return_id = $event_info['master_event']['id'] . ':' . $event['recurrence'];
780
+					$return_id = $event_info['master_event']['id'].':'.$event['recurrence'];
781 781
 				}
782 782
 				break;
783 783
 		}
@@ -786,8 +786,8 @@  discard block
 block discarded – undo
786 786
 		{
787 787
 			$recur_date = $this->date2usertime($event_info['stored_event']['start']);
788 788
 			$event_info['stored_event'] = $this->read($event_info['stored_event']['id'], $recur_date);
789
-			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" .
790
-				array2string($event_info['stored_event'])."\n",3,$this->logfile);
789
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n".
790
+				array2string($event_info['stored_event'])."\n", 3, $this->logfile);
791 791
 		}
792 792
 
793 793
 		return $return_id;
@@ -801,14 +801,14 @@  discard block
 block discarded – undo
801 801
 	*                          	default 0 => export whole series (or events, if not recurring)
802 802
 	* @return string containing the SIFE
803 803
 	*/
804
-	function getSIF($_id, $recur_date=0)
804
+	function getSIF($_id, $recur_date = 0)
805 805
 	{
806 806
 		if ($this->log)
807 807
 		{
808 808
 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
809
-			"($_id, $recur_date)\n",3,$this->logfile);
809
+			"($_id, $recur_date)\n", 3, $this->logfile);
810 810
 		}
811
-		$sysCharSet	= $GLOBALS['egw']->translation->charset();
811
+		$sysCharSet = $GLOBALS['egw']->translation->charset();
812 812
 
813 813
 		$fields = array_unique(array_values($this->sifMapping));
814 814
 		sort($fields);
@@ -819,7 +819,7 @@  discard block
 block discarded – undo
819 819
 			if ($this->read($_id, $recur_date, true, 'server'))
820 820
 			{
821 821
 				$retval = -1; // Permission denied
822
-				if($this->xmlrpc)
822
+				if ($this->xmlrpc)
823 823
 				{
824 824
 					$GLOBALS['server']->xmlrpc_error($GLOBALS['xmlrpcerr']['no_access'],
825 825
 						$GLOBALS['xmlrpcstr']['no_access']);
@@ -828,16 +828,16 @@  discard block
 block discarded – undo
828 828
 				{
829 829
 					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
830 830
 						"() User does not have the permission to read event $_id.\n",
831
-						3,$this->logfile);
831
+						3, $this->logfile);
832 832
 				}
833 833
 			}
834 834
 			else
835 835
 			{
836
-				$retval = false;  // Entry does not exist
836
+				$retval = false; // Entry does not exist
837 837
 				if ($this->log)
838 838
 				{
839 839
 					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
840
-						"() Event $_id not found.\n",3,$this->logfile);
840
+						"() Event $_id not found.\n", 3, $this->logfile);
841 841
 				}
842 842
 			}
843 843
 			return $retval;
@@ -845,8 +845,8 @@  discard block
 block discarded – undo
845 845
 
846 846
 		if ($this->log)
847 847
 		{
848
-			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" .
849
-				array2string($event)."\n",3,$this->logfile);
848
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n".
849
+				array2string($event)."\n", 3, $this->logfile);
850 850
 		}
851 851
 
852 852
 		if ($this->tzid)
@@ -910,8 +910,8 @@  discard block
 block discarded – undo
910 910
 			$exceptions = $this->so->get_recurrence_exceptions($event, $tzid, 0, 0, 'tz_rrule');
911 911
 			if ($this->log)
912 912
 			{
913
-				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."(EXCEPTIONS)\n" .
914
-					array2string($exceptions)."\n",3,$this->logfile);
913
+				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."(EXCEPTIONS)\n".
914
+					array2string($exceptions)."\n", 3, $this->logfile);
915 915
 			}
916 916
 			$event['recur_exception'] = $exceptions;
917 917
 			/*
@@ -935,11 +935,11 @@  discard block
 block discarded – undo
935 935
 		{
936 936
 			if (!preg_match('/\[UID:.+\]/m', $event['description']))
937 937
 			{
938
-				$event['description'] .= "\n[UID:" . $event['uid'] . "]";
938
+				$event['description'] .= "\n[UID:".$event['uid']."]";
939 939
 			}
940 940
 		}
941 941
 
942
-		$sifEvent = self::xml_decl . "<appointment>" . self::SIF_decl;
942
+		$sifEvent = self::xml_decl."<appointment>".self::SIF_decl;
943 943
 
944 944
 		foreach ($this->sifMapping as $sifField => $egwField)
945 945
 		{
@@ -950,7 +950,7 @@  discard block
 block discarded – undo
950 950
 			switch ($sifField)
951 951
 			{
952 952
 				case 'Importance':
953
-					$value = $value-1;
953
+					$value = $value - 1;
954 954
 					$sifEvent .= "<$sifField>$value</$sifField>";
955 955
 					break;
956 956
 
@@ -987,7 +987,7 @@  discard block
 block discarded – undo
987 987
 								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
988 988
 									"() Client Recurrence[$occurrences] $recur_date\n", 3, $this->logfile);
989 989
 							}
990
-							if (!$rriter->exceptions || !in_array($recur_date->format('Ymd'),$rriter->exceptions))
990
+							if (!$rriter->exceptions || !in_array($recur_date->format('Ymd'), $rriter->exceptions))
991 991
 							{
992 992
 								$recur_end = $recur_date;
993 993
 							}
@@ -995,7 +995,7 @@  discard block
 block discarded – undo
995 995
 						}
996 996
 						$recurEndDate = egw_time::to($recur_end, 'server');
997 997
 						$sifEvent .= '<NoEndDate>0</NoEndDate>';
998
-						$sifEvent .= '<PatternEndDate>'. self::getDateTime($recurEndDate,$tzid) .'</PatternEndDate>';
998
+						$sifEvent .= '<PatternEndDate>'.self::getDateTime($recurEndDate, $tzid).'</PatternEndDate>';
999 999
 					}
1000 1000
 
1001 1001
 					calendar_rrule::rrule2tz($event, $event['start'], $tzid);
@@ -1007,32 +1007,32 @@  discard block
 block discarded – undo
1007 1007
 
1008 1008
 						case MCAL_RECUR_DAILY:
1009 1009
 							$sifEvent .= "<$sifField>1</$sifField>";
1010
-							$sifEvent .= '<RecurrenceType>'. self::olRecursDaily .'</RecurrenceType>';
1011
-							$sifEvent .= '<Interval>'. $eventInterval .'</Interval>';
1012
-							$sifEvent .= '<PatternStartDate>'. self::getDateTime($event['start'],$tzid) .'</PatternStartDate>';
1010
+							$sifEvent .= '<RecurrenceType>'.self::olRecursDaily.'</RecurrenceType>';
1011
+							$sifEvent .= '<Interval>'.$eventInterval.'</Interval>';
1012
+							$sifEvent .= '<PatternStartDate>'.self::getDateTime($event['start'], $tzid).'</PatternStartDate>';
1013 1013
 							if ($event['recur_enddate'])
1014 1014
 							{
1015
-								$sifEvent .= '<Occurrences>'. $occurrences .'</Occurrences>';
1015
+								$sifEvent .= '<Occurrences>'.$occurrences.'</Occurrences>';
1016 1016
 							}
1017 1017
 							break;
1018 1018
 
1019 1019
 						case MCAL_RECUR_WEEKLY:
1020 1020
 							$sifEvent .= "<$sifField>1</$sifField>";
1021
-							$sifEvent .= '<RecurrenceType>'. self::olRecursWeekly .'</RecurrenceType>';
1022
-							$sifEvent .= '<Interval>'. $eventInterval .'</Interval>';
1023
-							$sifEvent .= '<PatternStartDate>'. self::getDateTime($event['start'],$tzid) .'</PatternStartDate>';
1024
-							$sifEvent .= '<DayOfWeekMask>'. $event['recur_data'] .'</DayOfWeekMask>';
1021
+							$sifEvent .= '<RecurrenceType>'.self::olRecursWeekly.'</RecurrenceType>';
1022
+							$sifEvent .= '<Interval>'.$eventInterval.'</Interval>';
1023
+							$sifEvent .= '<PatternStartDate>'.self::getDateTime($event['start'], $tzid).'</PatternStartDate>';
1024
+							$sifEvent .= '<DayOfWeekMask>'.$event['recur_data'].'</DayOfWeekMask>';
1025 1025
 							if ($event['recur_enddate'])
1026 1026
 							{
1027
-								$sifEvent .= '<Occurrences>'. $occurrences .'</Occurrences>';
1027
+								$sifEvent .= '<Occurrences>'.$occurrences.'</Occurrences>';
1028 1028
 							}
1029 1029
 							break;
1030 1030
 
1031 1031
 						case MCAL_RECUR_MONTHLY_MDAY:
1032 1032
 							$sifEvent .= "<$sifField>1</$sifField>";
1033
-							$sifEvent .= '<RecurrenceType>'. self::olRecursMonthly .'</RecurrenceType>';
1034
-							$sifEvent .= '<Interval>'. $eventInterval .'</Interval>';
1035
-							$sifEvent .= '<PatternStartDate>'. self::getDateTime($event['start'],$tzid) .'</PatternStartDate>';
1033
+							$sifEvent .= '<RecurrenceType>'.self::olRecursMonthly.'</RecurrenceType>';
1034
+							$sifEvent .= '<Interval>'.$eventInterval.'</Interval>';
1035
+							$sifEvent .= '<PatternStartDate>'.self::getDateTime($event['start'], $tzid).'</PatternStartDate>';
1036 1036
 							break;
1037 1037
 
1038 1038
 						case MCAL_RECUR_MONTHLY_WDAY:
@@ -1040,16 +1040,16 @@  discard block
 block discarded – undo
1040 1040
 								'Wed' => self::olWednesday, 'Thu' => self::olThursday, 'Fri' => self::olFriday,
1041 1041
 								'Sat' => self::olSaturday);
1042 1042
 							$sifEvent .= "<$sifField>1</$sifField>";
1043
-							$sifEvent .= '<RecurrenceType>'. self::olRecursMonthNth .'</RecurrenceType>';
1044
-							$sifEvent .= '<Interval>'. $eventInterval .'</Interval>';
1045
-							$sifEvent .= '<PatternStartDate>'. self::getDateTime($event['start'],$tzid) .'</PatternStartDate>';
1046
-							$sifEvent .= '<Instance>' . (1 + (int) ((date('d',$event['start'])-1) / 7)) . '</Instance>';
1047
-							$sifEvent .= '<DayOfWeekMask>' . $weekMaskMap[date('D',$event['start'])] . '</DayOfWeekMask>';
1043
+							$sifEvent .= '<RecurrenceType>'.self::olRecursMonthNth.'</RecurrenceType>';
1044
+							$sifEvent .= '<Interval>'.$eventInterval.'</Interval>';
1045
+							$sifEvent .= '<PatternStartDate>'.self::getDateTime($event['start'], $tzid).'</PatternStartDate>';
1046
+							$sifEvent .= '<Instance>'.(1 + (int)((date('d', $event['start']) - 1) / 7)).'</Instance>';
1047
+							$sifEvent .= '<DayOfWeekMask>'.$weekMaskMap[date('D', $event['start'])].'</DayOfWeekMask>';
1048 1048
 							break;
1049 1049
 
1050 1050
 						case MCAL_RECUR_YEARLY:
1051 1051
 							$sifEvent .= "<$sifField>1</$sifField>";
1052
-							$sifEvent .= '<RecurrenceType>'. self::olRecursYearly .'</RecurrenceType>';
1052
+							$sifEvent .= '<RecurrenceType>'.self::olRecursYearly.'</RecurrenceType>';
1053 1053
 							break;
1054 1054
 					}
1055 1055
 					if (is_array($event['recur_exception']))
@@ -1059,22 +1059,22 @@  discard block
 block discarded – undo
1059 1059
 						{
1060 1060
 							if (empty($event['whole_day']))
1061 1061
 							{
1062
-								if ($this->log && is_a($day,'DateTime'))
1062
+								if ($this->log && is_a($day, 'DateTime'))
1063 1063
 								{
1064 1064
 									error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1065
-										'() exception[' . $day->getTimezone()->getName() . ']: ' .
1066
-										$day->format('Ymd\THis') . "\n",3,$this->logfile);
1065
+										'() exception['.$day->getTimezone()->getName().']: '.
1066
+										$day->format('Ymd\THis')."\n", 3, $this->logfile);
1067 1067
 								}
1068
-								$sifEvent .= '<ExcludeDate>' . self::getDateTime($day,$tzid) . '</ExcludeDate>';
1068
+								$sifEvent .= '<ExcludeDate>'.self::getDateTime($day, $tzid).'</ExcludeDate>';
1069 1069
 							}
1070 1070
 							else
1071 1071
 							{
1072
-								if (!is_a($day,'DateTime'))
1072
+								if (!is_a($day, 'DateTime'))
1073 1073
 								{
1074
-									$day = new egw_time($day,egw_time::$server_timezone);
1074
+									$day = new egw_time($day, egw_time::$server_timezone);
1075 1075
 									$day->setTimezone(self::$tz_cache[$event['tzid']]);
1076 1076
 								}
1077
-								$sifEvent .= '<ExcludeDate>' . $day->format('Y-m-d') . '</ExcludeDate>';
1077
+								$sifEvent .= '<ExcludeDate>'.$day->format('Y-m-d').'</ExcludeDate>';
1078 1078
 							}
1079 1079
 						}
1080 1080
 						$sifEvent .= '</Exceptions>';
@@ -1099,19 +1099,19 @@  discard block
 block discarded – undo
1099 1099
 				case 'Start':
1100 1100
 					if (empty($event['whole_day']))
1101 1101
 					{
1102
-						$sifEvent .= '<Start>' . self::getDateTime($event['start'],$tzid) . '</Start>';
1103
-						$sifEvent .= '<End>' . self::getDateTime($event['end'],$tzid) . '</End>';
1102
+						$sifEvent .= '<Start>'.self::getDateTime($event['start'], $tzid).'</Start>';
1103
+						$sifEvent .= '<End>'.self::getDateTime($event['end'], $tzid).'</End>';
1104 1104
 						$sifEvent .= "<AllDayEvent>0</AllDayEvent>";
1105 1105
 					}
1106 1106
 					else
1107 1107
 					{
1108 1108
 						// for whole-day events we use the date in event timezone
1109
-						$time = new egw_time($event['start'],egw_time::$server_timezone);
1109
+						$time = new egw_time($event['start'], egw_time::$server_timezone);
1110 1110
 						$time->setTimezone(self::$tz_cache[$event['tzid']]);
1111
-						$sifEvent .= '<Start>' . $time->format('Y-m-d') . '</Start>';
1112
-						$time = new egw_time($event['end'],egw_time::$server_timezone);
1111
+						$sifEvent .= '<Start>'.$time->format('Y-m-d').'</Start>';
1112
+						$time = new egw_time($event['end'], egw_time::$server_timezone);
1113 1113
 						$time->setTimezone(self::$tz_cache[$event['tzid']]);
1114
-						$sifEvent .= '<End>' . $time->format('Y-m-d') . '</End>';
1114
+						$sifEvent .= '<End>'.$time->format('Y-m-d').'</End>';
1115 1115
 						$sifEvent .= "<AllDayEvent>1</AllDayEvent>";
1116 1116
 					}
1117 1117
 					break;
@@ -1125,7 +1125,7 @@  discard block
 block discarded – undo
1125 1125
 						$sifEvent .= "<$sifField>1</$sifField>";
1126 1126
 						foreach ($event['alarm'] as $alarmID => $alarmData)
1127 1127
 						{
1128
-							$sifEvent .= '<ReminderMinutesBeforeStart>'. $alarmData['offset']/60 .'</ReminderMinutesBeforeStart>';
1128
+							$sifEvent .= '<ReminderMinutesBeforeStart>'.$alarmData['offset'] / 60.'</ReminderMinutesBeforeStart>';
1129 1129
 							// lets take only the first alarm
1130 1130
 							break;
1131 1131
 						}
@@ -1156,10 +1156,10 @@  discard block
 block discarded – undo
1156 1156
 
1157 1157
 		if ($this->log)
1158 1158
 		{
1159
-			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
1160
-				"() '$this->productName','$this->productSoftwareVersion'\n",3,$this->logfile);
1161
-			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
1162
-				"()\n".array2string($sifEvent)."\n",3,$this->logfile);
1159
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1160
+				"() '$this->productName','$this->productSoftwareVersion'\n", 3, $this->logfile);
1161
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1162
+				"()\n".array2string($sifEvent)."\n", 3, $this->logfile);
1163 1163
 		}
1164 1164
 
1165 1165
 		return $sifEvent;
@@ -1173,9 +1173,9 @@  discard block
 block discarded – undo
1173 1173
 	* @param string $_productName
1174 1174
 	* @param string $_productSoftwareVersion
1175 1175
 	*/
1176
-	function setSupportedFields($_productName='', $_productSoftwareVersion='')
1176
+	function setSupportedFields($_productName = '', $_productSoftwareVersion = '')
1177 1177
 	{
1178
-		$state =& $_SESSION['SyncML.state'];
1178
+		$state = & $_SESSION['SyncML.state'];
1179 1179
 		if (isset($state))
1180 1180
 		{
1181 1181
 			$deviceInfo = $state->getClientDeviceInfo();
@@ -1239,8 +1239,8 @@  discard block
 block discarded – undo
1239 1239
 		if ($this->log)
1240 1240
 		{
1241 1241
 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1242
-				'(' . $this->productName .
1243
-				', '. $this->productSoftwareVersion . ")\n",3,$this->logfile);
1242
+				'('.$this->productName.
1243
+				', '.$this->productSoftwareVersion.")\n", 3, $this->logfile);
1244 1244
 		}
1245 1245
 	}
1246 1246
 }
Please login to merge, or discard this patch.
Braces   +38 added lines, -10 removed lines patch added patch discarded remove patch
@@ -149,7 +149,10 @@  discard block
 block discarded – undo
149 149
 	function __construct(&$_clientProperties = array())
150 150
 	{
151 151
 		parent::__construct();
152
-		if ($this->log) $this->logfile = $GLOBALS['egw_info']['server']['temp_dir']."/log-sifcal";
152
+		if ($this->log)
153
+		{
154
+			$this->logfile = $GLOBALS['egw_info']['server']['temp_dir']."/log-sifcal";
155
+		}
153 156
 		$this->clientProperties = $_clientProperties;
154 157
 		$this->vCalendar = new Horde_iCalendar;
155 158
 	}
@@ -376,11 +379,17 @@  discard block
 block discarded – undo
376 379
 			}
377 380
 		}
378 381
 
379
-		if ($this->calendarOwner) $finalEvent['owner'] = $this->calendarOwner;
382
+		if ($this->calendarOwner)
383
+		{
384
+			$finalEvent['owner'] = $this->calendarOwner;
385
+		}
380 386
 
381 387
 		date_default_timezone_set($GLOBALS['egw_info']['server']['server_timezone']);
382 388
 
383
-		if ($_calID > 0) $finalEvent['id'] = $_calID;
389
+		if ($_calID > 0)
390
+		{
391
+			$finalEvent['id'] = $_calID;
392
+		}
384 393
 
385 394
 		if ($this->log)
386 395
 		{
@@ -398,7 +407,8 @@  discard block
 block discarded – undo
398 407
 
399 408
 		if ($event = $this->siftoegw($_sifdata, $contentID))
400 409
 		{
401
-			if ($contentID) {
410
+			if ($contentID)
411
+			{
402 412
 				$event['id'] = $contentID;
403 413
 			}
404 414
 			$result = $this->find_event($event, $filter);
@@ -462,7 +472,10 @@  discard block
 block discarded – undo
462 472
 			$event['recur_exception'] = $exceptions;
463 473
 		} */
464 474
 
465
-		if ($recur_date) $event['recurrence'] = $recur_date;
475
+		if ($recur_date)
476
+		{
477
+			$event['recurrence'] = $recur_date;
478
+		}
466 479
 		$event_info = $this->get_event_info($event);
467 480
 
468 481
 		// common adjustments for existing events
@@ -482,7 +495,10 @@  discard block
 block discarded – undo
482 495
 						unset($event[$key]);
483 496
 						continue;
484 497
 					}
485
-					if (!empty($value))	$event[$key] = $value;
498
+					if (!empty($value))
499
+					{
500
+						$event[$key] = $value;
501
+					}
486 502
 				}
487 503
 			}
488 504
 			else
@@ -578,7 +594,10 @@  discard block
 block discarded – undo
578 594
 									break;
579 595
 								}
580 596
 							}
581
-							if (isset($alarmData)&&is_array($alarmData)) $event['alarm'][] = $alarmData;
597
+							if (isset($alarmData)&&is_array($alarmData))
598
+							{
599
+								$event['alarm'][] = $alarmData;
600
+							}
582 601
 						}
583 602
 					}
584 603
 					break;
@@ -860,7 +879,10 @@  discard block
 block discarded – undo
860 879
 			$tzid = $event['tzid'];
861 880
 		}
862 881
 
863
-		if ($this->so->isWholeDay($event)) $event['whole_day'] = true;
882
+		if ($this->so->isWholeDay($event))
883
+		{
884
+			$event['whole_day'] = true;
885
+		}
864 886
 
865 887
 		if ($tzid)
866 888
 		{
@@ -904,10 +926,13 @@  discard block
 block discarded – undo
904 926
 		}
905 927
 		elseif (!$recur_date &&
906 928
 			$event['recur_type'] != MCAL_RECUR_NONE &&
907
-			empty($event['whole_day'])) // whole-day events are not shifted
929
+			empty($event['whole_day']))
930
+		{
931
+			// whole-day events are not shifted
908 932
 		{
909 933
 			// Add the timezone transition related pseudo exceptions
910 934
 			$exceptions = $this->so->get_recurrence_exceptions($event, $tzid, 0, 0, 'tz_rrule');
935
+		}
911 936
 			if ($this->log)
912 937
 			{
913 938
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."(EXCEPTIONS)\n" .
@@ -943,7 +968,10 @@  discard block
 block discarded – undo
943 968
 
944 969
 		foreach ($this->sifMapping as $sifField => $egwField)
945 970
 		{
946
-			if (empty($egwField)) continue;
971
+			if (empty($egwField))
972
+			{
973
+				continue;
974
+			}
947 975
 
948 976
 			$value = $GLOBALS['egw']->translation->convert($event[$egwField], $sysCharSet, 'utf-8');
949 977
 
Please login to merge, or discard this patch.