Completed
Push — master ( 9d054b...106a1b )
by Klaus
23:45 queued 04:19
created
infolog/inc/class.infolog_bo.inc.php 5 patches
Doc Comments   +2 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1226,7 +1226,7 @@  discard block
 block discarded – undo
1226 1226
 	 * Is called as hook to participate in the linking
1227 1227
 	 *
1228 1228
 	 * @param int|array $info int info_id or array with infolog entry
1229
-	 * @return string|boolean string with the title, null if $info not found, false if no perms to view
1229
+	 * @return string string with the title, null if $info not found, false if no perms to view
1230 1230
 	 */
1231 1231
 	function link_title($info)
1232 1232
 	{
@@ -1324,9 +1324,6 @@  discard block
 block discarded – undo
1324 1324
 	/**
1325 1325
 	 * hook called be calendar to include events or todos in the cal-dayview
1326 1326
 	 *
1327
-	 * @param int $args[year], $args[month], $args[day] date of the events
1328
-	 * @param int $args[owner] owner of the events
1329
-	 * @param string $args[location] calendar_include_{events|todos}
1330 1327
 	 * @return array of events (array with keys starttime, endtime, title, view, icon, content)
1331 1328
 	 */
1332 1329
 	function cal_to_include($args)
@@ -1515,7 +1512,7 @@  discard block
 block discarded – undo
1515 1512
 	 * Get names for categories specified by their id's
1516 1513
 	 *
1517 1514
 	 * @param array|string $cat_id_list array or comma-sparated list of id's
1518
-	 * @return array with names
1515
+	 * @return string|boolean with names
1519 1516
 	 */
1520 1517
 	function get_categories($cat_id_list)
1521 1518
 	{
Please login to merge, or discard this patch.
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -701,20 +701,20 @@  discard block
 block discarded – undo
701 701
 	}
702 702
 
703 703
 	/**
704
-	* writes the given $values to InfoLog, a new entry gets created if info_id is not set or 0
705
-	*
706
-	* checks and asures ACL
707
-	*
708
-	* @param array &$values values to write
709
-	* @param boolean $check_defaults = true check and set certain defaults
710
-	* @param boolean|int $touch_modified = true touch the modification date and sets the modifier's user-id, 2: only modifier
711
-	* @param boolean $user2server = true conversion between user- and server-time necessary
712
-	* @param boolean $skip_notification = false true = do NOT send notification, false (default) = send notifications
713
-	* @param boolean $throw_exception = false Throw an exception (if required fields are not set)
714
-	* @param string $purge_cfs = null null=dont, 'ical'=only iCal X-properties (cfs name starting with "#"), 'all'=all cfs
715
-	*
716
-	* @return int|boolean info_id on a successfull write or false
717
-	*/
704
+	 * writes the given $values to InfoLog, a new entry gets created if info_id is not set or 0
705
+	 *
706
+	 * checks and asures ACL
707
+	 *
708
+	 * @param array &$values values to write
709
+	 * @param boolean $check_defaults = true check and set certain defaults
710
+	 * @param boolean|int $touch_modified = true touch the modification date and sets the modifier's user-id, 2: only modifier
711
+	 * @param boolean $user2server = true conversion between user- and server-time necessary
712
+	 * @param boolean $skip_notification = false true = do NOT send notification, false (default) = send notifications
713
+	 * @param boolean $throw_exception = false Throw an exception (if required fields are not set)
714
+	 * @param string $purge_cfs = null null=dont, 'ical'=only iCal X-properties (cfs name starting with "#"), 'all'=all cfs
715
+	 *
716
+	 * @return int|boolean info_id on a successfull write or false
717
+	 */
718 718
 	function write(&$values_in, $check_defaults=true, $touch_modified=true, $user2server=true,
719 719
 		$skip_notification=false, $throw_exception=false, $purge_cfs=null)
720 720
 	{
@@ -751,7 +751,7 @@  discard block
 block discarded – undo
751 751
 			}
752 752
 		}
753 753
 		if ($values['info_id'] && !$this->check_access($values['info_id'],Acl::EDIT) && !$status_only ||
754
-		    !$values['info_id'] && $values['info_id_parent'] && !$this->check_access($values['info_id_parent'],Acl::ADD))
754
+			!$values['info_id'] && $values['info_id_parent'] && !$this->check_access($values['info_id_parent'],Acl::ADD))
755 755
 		{
756 756
 			return false;
757 757
 		}
Please login to merge, or discard this patch.
Spacing   +239 added lines, -240 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	 */
41 41
 	var $total;
42 42
 	var $vfs;
43
-	var $vfs_basedir='/infolog';
43
+	var $vfs_basedir = '/infolog';
44 44
 	/**
45 45
 	 * Set Logging
46 46
 	 *
@@ -65,13 +65,13 @@  discard block
 block discarded – undo
65 65
 	 *
66 66
 	 * @var array
67 67
 	 */
68
-	var $timestamps = array('info_startdate','info_enddate','info_datemodified','info_datecompleted','info_created');
68
+	var $timestamps = array('info_startdate', 'info_enddate', 'info_datemodified', 'info_datecompleted', 'info_created');
69 69
 	/**
70 70
 	 * fields the responsible user can change
71 71
 	 *
72 72
 	 * @var array
73 73
 	 */
74
-	var $responsible_edit=array('info_status','info_percent','info_datecompleted');
74
+	var $responsible_edit = array('info_status', 'info_percent', 'info_datecompleted');
75 75
 	/**
76 76
 	 * Fields to exclude from copy, if an entry is copied, the ones below are excluded by default.
77 77
 	 *
@@ -95,19 +95,19 @@  discard block
 block discarded – undo
95 95
 	 *
96 96
 	 * @var string
97 97
 	 */
98
-	var $implicit_rights='read';
98
+	var $implicit_rights = 'read';
99 99
 	/**
100 100
 	 * Custom fields read from the infolog config
101 101
 	 *
102 102
 	 * @var array
103 103
 	 */
104
-	var $customfields=array();
104
+	var $customfields = array();
105 105
 	/**
106 106
 	 * Group owners for certain types read from the infolog config
107 107
 	 *
108 108
 	 * @var array
109 109
 	 */
110
-	var $group_owners=array();
110
+	var $group_owners = array();
111 111
 	/**
112 112
 	 * Current user
113 113
 	 *
@@ -174,55 +174,55 @@  discard block
 block discarded – undo
174 174
 	function __construct($info_id = 0)
175 175
 	{
176 176
 		$this->enums = $this->stock_enums = array(
177
-			'priority' => array (
177
+			'priority' => array(
178 178
 				3 => 'urgent',
179 179
 				2 => 'high',
180 180
 				1 => 'normal',
181 181
 				0 => 'low'
182 182
 			),
183 183
 			'confirm'   => array(
184
-				'not' => 'not','accept' => 'accept','finish' => 'finish',
184
+				'not' => 'not', 'accept' => 'accept', 'finish' => 'finish',
185 185
 				'both' => 'both' ),
186 186
 			'type'      => array(
187
-				'task' => 'task','phone' => 'phone','note' => 'note','email' => 'email'
187
+				'task' => 'task', 'phone' => 'phone', 'note' => 'note', 'email' => 'email'
188 188
 			/*	,'confirm' => 'confirm','reject' => 'reject','fax' => 'fax' not implemented so far */ )
189 189
 		);
190 190
 		$this->status = $this->stock_status = array(
191 191
 			'defaults' => array(
192
-				'task' => 'not-started', 'phone' => 'not-started', 'note' => 'done','email' => 'done'),
192
+				'task' => 'not-started', 'phone' => 'not-started', 'note' => 'done', 'email' => 'done'),
193 193
 			'task' => array(
194
-				'offer' => 'offer',				// -->  NEEDS-ACTION
195
-				'not-started' => 'not-started',	// iCal NEEDS-ACTION
196
-				'ongoing' => 'ongoing',			// iCal IN-PROCESS
197
-				'done' => 'done',				// iCal COMPLETED
198
-				'cancelled' => 'cancelled',		// iCal CANCELLED
199
-				'billed' => 'billed',			// -->  DONE
200
-				'template' => 'template',		// -->  cancelled
201
-				'nonactive' => 'nonactive',		// -->  cancelled
202
-				'archive' => 'archive' ), 		// -->  cancelled
194
+				'offer' => 'offer', // -->  NEEDS-ACTION
195
+				'not-started' => 'not-started', // iCal NEEDS-ACTION
196
+				'ongoing' => 'ongoing', // iCal IN-PROCESS
197
+				'done' => 'done', // iCal COMPLETED
198
+				'cancelled' => 'cancelled', // iCal CANCELLED
199
+				'billed' => 'billed', // -->  DONE
200
+				'template' => 'template', // -->  cancelled
201
+				'nonactive' => 'nonactive', // -->  cancelled
202
+				'archive' => 'archive' ), // -->  cancelled
203 203
 			'phone' => array(
204
-				'not-started' => 'call',		// iCal NEEDS-ACTION
205
-				'ongoing' => 'will-call',		// iCal IN-PROCESS
206
-				'done' => 'done', 				// iCal COMPLETED
207
-				'billed' => 'billed' ),			// -->  DONE
204
+				'not-started' => 'call', // iCal NEEDS-ACTION
205
+				'ongoing' => 'will-call', // iCal IN-PROCESS
206
+				'done' => 'done', // iCal COMPLETED
207
+				'billed' => 'billed' ), // -->  DONE
208 208
 			'note' => array(
209
-				'ongoing' => 'ongoing',			// iCal has no status on notes
209
+				'ongoing' => 'ongoing', // iCal has no status on notes
210 210
 				'done' => 'done' ),
211 211
 			'email' => array(
212
-				'ongoing' => 'ongoing',			// iCal has no status on notes
212
+				'ongoing' => 'ongoing', // iCal has no status on notes
213 213
 				'done' => 'done' ),
214 214
 		);
215 215
 		if (($config_data = Api\Config::read('infolog')))
216 216
 		{
217 217
 			if (isset($config_data['status']) && is_array($config_data['status']))
218 218
 			{
219
-				foreach(array_keys($config_data['status']) as $key)
219
+				foreach (array_keys($config_data['status']) as $key)
220 220
 				{
221 221
 					if (!is_array($this->status[$key]))
222 222
 					{
223 223
 						$this->status[$key] = array();
224 224
 					}
225
-					$this->status[$key] = array_merge($this->status[$key],(array)$config_data['status'][$key]);
225
+					$this->status[$key] = array_merge($this->status[$key], (array)$config_data['status'][$key]);
226 226
 				}
227 227
 			}
228 228
 			if (isset($config_data['types']) && is_array($config_data['types']))
@@ -237,10 +237,10 @@  discard block
 block discarded – undo
237 237
 			$this->customfields = Api\Storage\Customfields::get('infolog');
238 238
 			if ($this->customfields)
239 239
 			{
240
-				foreach($this->customfields as $name => $field)
240
+				foreach ($this->customfields as $name => $field)
241 241
 				{
242 242
 					// old infolog customefield record
243
-					if(empty($field['type']))
243
+					if (empty($field['type']))
244 244
 					{
245 245
 						if (count($field['values'])) $field['type'] = 'select'; // selectbox
246 246
 						elseif ($field['rows'] > 1) $field['type'] = 'textarea'; // textarea
@@ -252,23 +252,23 @@  discard block
 block discarded – undo
252 252
 						$save_config = true;
253 253
 					}
254 254
 				}
255
-				if ($save_config) Api\Config::save_value('customfields',$this->customfields,'infolog');
255
+				if ($save_config) Api\Config::save_value('customfields', $this->customfields, 'infolog');
256 256
 			}
257 257
 			if (is_array($config_data['responsible_edit']))
258 258
 			{
259
-				$this->responsible_edit = array_merge($this->responsible_edit,$config_data['responsible_edit']);
259
+				$this->responsible_edit = array_merge($this->responsible_edit, $config_data['responsible_edit']);
260 260
 			}
261 261
 			if (is_array($config_data['copy_excludefields']))
262 262
 			{
263
-				$this->copy_excludefields = array_merge($this->copy_excludefields,$config_data['copy_excludefields']);
263
+				$this->copy_excludefields = array_merge($this->copy_excludefields, $config_data['copy_excludefields']);
264 264
 			}
265 265
 			if (is_array($config_data['sub_excludefields']) && $config_data['sub_excludefields'])
266 266
 			{
267
-				$this->sub_excludefields = array_merge($this->sub_excludefields,$config_data['sub_excludefields']);
267
+				$this->sub_excludefields = array_merge($this->sub_excludefields, $config_data['sub_excludefields']);
268 268
 			}
269 269
 			else
270 270
 			{
271
-				$this->sub_excludefields = array_merge($this->sub_excludefields,$this->default_sub_excludefields);
271
+				$this->sub_excludefields = array_merge($this->sub_excludefields, $this->default_sub_excludefields);
272 272
 			}
273 273
 			if ($config_data['implicit_rights'] == 'edit')
274 274
 			{
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
 			$this->history = $config_data['history'];
278 278
 		}
279 279
 		// sort types by there translation
280
-		foreach($this->enums['type'] as $key => $val)
280
+		foreach ($this->enums['type'] as $key => $val)
281 281
 		{
282 282
 			if (($val = lang($key)) != $key.'*') $this->enums['type'][$key] = lang($key);
283 283
 		}
@@ -286,14 +286,14 @@  discard block
 block discarded – undo
286 286
 		$this->user = $GLOBALS['egw_info']['user']['account_id'];
287 287
 
288 288
 		$this->now = time();
289
-		$this->user_time_now = Api\DateTime::server2user($this->now,'ts');
289
+		$this->user_time_now = Api\DateTime::server2user($this->now, 'ts');
290 290
 
291
-		$this->grants = $GLOBALS['egw']->acl->get_grants('infolog',$this->group_owners ? $this->group_owners : true);
291
+		$this->grants = $GLOBALS['egw']->acl->get_grants('infolog', $this->group_owners ? $this->group_owners : true);
292 292
 		$this->so = new infolog_so($this->grants);
293 293
 
294 294
 		if ($info_id)
295 295
 		{
296
-			$this->read( $info_id );
296
+			$this->read($info_id);
297 297
 		}
298 298
 		else
299 299
 		{
@@ -309,9 +309,9 @@  discard block
 block discarded – undo
309 309
 	 */
310 310
 	function has_customfields($type)
311 311
 	{
312
-		foreach($this->customfields as $field)
312
+		foreach ($this->customfields as $field)
313 313
 		{
314
-			if ((!$type || empty($field['type2']) || in_array($type,is_array($field['type2']) ? $field['type2'] : explode(',',$field['type2']))))
314
+			if ((!$type || empty($field['type2']) || in_array($type, is_array($field['type2']) ? $field['type2'] : explode(',', $field['type2']))))
315 315
 			{
316 316
 				return True;
317 317
 			}
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
 	 * @param int $user = null user whos rights to check, default current user
329 329
 	 * @return boolean
330 330
 	 */
331
-	function check_access($info,$required_rights,$other=0,$user=null)
331
+	function check_access($info, $required_rights, $other = 0, $user = null)
332 332
 	{
333 333
 		static $cache = array();
334 334
 
@@ -338,17 +338,17 @@  discard block
 block discarded – undo
338 338
 		if ($user == $this->user)
339 339
 		{
340 340
 			$grants = $this->grants;
341
-			if ($info_id) $access =& $cache[$info_id][$required_rights];	// we only cache the current user!
341
+			if ($info_id) $access = & $cache[$info_id][$required_rights]; // we only cache the current user!
342 342
 		}
343 343
 		else
344 344
 		{
345
-			$grants = $GLOBALS['egw']->acl->get_grants('infolog',$this->group_owners ? $this->group_owners : true,$user);
345
+			$grants = $GLOBALS['egw']->acl->get_grants('infolog', $this->group_owners ? $this->group_owners : true, $user);
346 346
 		}
347 347
 		if (!$info)
348 348
 		{
349 349
 			$owner = $other ? $other : $user;
350 350
 			$grant = $grants[$owner];
351
-			return $grant & $required_rights;
351
+			return $grant&$required_rights;
352 352
 		}
353 353
 
354 354
 
@@ -360,10 +360,10 @@  discard block
 block discarded – undo
360 360
 				if (!is_array($info) && !($info = $this->so->read(array('info_id' => $info_id)))) return false;
361 361
 
362 362
 				if ($info['info_status'] == 'deleted' &&
363
-					($required_rights == Acl::EDIT ||		// no edit rights for deleted entries
364
-					 $required_rights == Acl::ADD  ||		// no add rights for deleted entries
363
+					($required_rights == Acl::EDIT || // no edit rights for deleted entries
364
+					 $required_rights == Acl::ADD || // no add rights for deleted entries
365 365
 					 $required_rights == Acl::DELETE && ($this->history == 'history_no_delete' || // no delete at all!
366
-					 $this->history == 'history_admin_delete' && (!isset($GLOBALS['egw_info']['user']['apps']['admin']) || $user!=$this->user))))	// delete only for admins
366
+					 $this->history == 'history_admin_delete' && (!isset($GLOBALS['egw_info']['user']['apps']['admin']) || $user != $this->user))))	// delete only for admins
367 367
 				{
368 368
 					$access = false;
369 369
 				}
@@ -371,12 +371,12 @@  discard block
 block discarded – undo
371 371
 				{
372 372
 					if ($info['info_status'] != 'deleted')
373 373
 					{
374
-						$access = false;	// can only undelete deleted items
374
+						$access = false; // can only undelete deleted items
375 375
 					}
376 376
 					else
377 377
 					{
378 378
 						// undelete requires edit rights
379
-						$access = $this->so->check_access( $info,Acl::EDIT,$this->implicit_rights == 'edit',$grants,$user );
379
+						$access = $this->so->check_access($info, Acl::EDIT, $this->implicit_rights == 'edit', $grants, $user);
380 380
 					}
381 381
 				}
382 382
 			}
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
 			}
387 387
 			if (!isset($access))
388 388
 			{
389
-				$access = $this->so->check_access( $info,$required_rights,$this->implicit_rights == 'edit',$grants,$user );
389
+				$access = $this->so->check_access($info, $required_rights, $this->implicit_rights == 'edit', $grants, $user);
390 390
 			}
391 391
 		}
392 392
 		// else $cached = ' (from cache)';
@@ -421,12 +421,12 @@  discard block
 block discarded – undo
421 421
 	 * @param string $not_id = '' id to exclude
422 422
 	 * @return boolean True if we have a linked item, False otherwise
423 423
 	 */
424
-	function link_id2from(&$info,$not_app='',$not_id='')
424
+	function link_id2from(&$info, $not_app = '', $not_id = '')
425 425
 	{
426 426
 		//echo "<p>boinfolog::link_id2from(subject='$info[info_subject]', link_id='$info[info_link_id]', from='$info[info_from]', not_app='$not_app', not_id='$not_id')";
427 427
 
428 428
 		if ($info['info_link_id'] > 0 &&
429
-			(isset($info['links']) && ($link = $info['links'][$info['info_link_id']]) ||	// use supplied links info
429
+			(isset($info['links']) && ($link = $info['links'][$info['info_link_id']]) || // use supplied links info
430 430
 			 ($link = Link::get_link($info['info_link_id'])) !== False))	// if link not found in supplied links, we always search!
431 431
 		{
432 432
 			if (isset($info['links']) && isset($link['app']))
@@ -440,11 +440,11 @@  discard block
 block discarded – undo
440 440
 				$app = $link['link_app'.$nr];
441 441
 				$id  = $link['link_id'.$nr];
442 442
 			}
443
-			$title = Link::title($app,$id);
443
+			$title = Link::title($app, $id);
444 444
 
445 445
 			if ((string)$info['info_custom_from'] === '')	// old entry
446 446
 			{
447
-				$info['info_custom_from'] = (int) ($title != $info['info_from'] && @htmlentities($title) != $info['info_from']);
447
+				$info['info_custom_from'] = (int)($title != $info['info_from'] && @htmlentities($title) != $info['info_from']);
448 448
 			}
449 449
 			if (!$info['info_custom_from'])
450 450
 			{
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
 			return $info['blur_title'] = $title;
467 467
 		}
468 468
 		$info['info_link'] = array('title' => $info['info_from']);
469
-		$info['info_link_id'] = 0;	// link might have been deleted
469
+		$info['info_link_id'] = 0; // link might have been deleted
470 470
 		$info['info_custom_from'] = (int)!!$info['info_from'];
471 471
 
472 472
 		return False;
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
 	 */
478 478
 	static function subject_from_des($des)
479 479
 	{
480
-		return substr($des,0,60).' ...';
480
+		return substr($des, 0, 60).' ...';
481 481
 	}
482 482
 
483 483
 	/**
@@ -492,7 +492,7 @@  discard block
 block discarded – undo
492 492
 	 * 			or NULL for timestamps in user-time
493 493
 	 * 			or false for timestamps in server-time
494 494
 	 */
495
-	 function time2time(&$values, $fromTZId=false, $toTZId=null)
495
+	 function time2time(&$values, $fromTZId = false, $toTZId = null)
496 496
 	 {
497 497
 
498 498
 		if ($fromTZId === $toTZId) return;
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
 			$toTZ = Api\DateTime::$server_timezone;
534 534
 		}
535 535
 		//error_log(__METHOD__.'(values[info_enddate]='.date('Y-m-d H:i:s',$values['info_enddate']).", from=".array2string($fromTZId).", to=".array2string($toTZId).") tz=".$tz->getName().', fromTZ='.$fromTZ->getName().', toTZ='.$toTZ->getName().', userTZ='.Api\DateTime::$user_timezone->getName());
536
-	 	foreach($this->timestamps as $key)
536
+	 	foreach ($this->timestamps as $key)
537 537
 		{
538 538
 		 	if ($values[$key])
539 539
 		 	{
@@ -542,14 +542,14 @@  discard block
 block discarded – undo
542 542
 			 	if ($time->format('Hi') == '0000')
543 543
 			 	{
544 544
 				 	// we keep dates the same in new timezone
545
-				 	$arr = Api\DateTime::to($time,'array');
545
+				 	$arr = Api\DateTime::to($time, 'array');
546 546
 				 	$time = new Api\DateTime($arr, $toTZ);
547 547
 			 	}
548 548
 			 	else
549 549
 			 	{
550 550
 				 	$time->setTimezone($toTZ);
551 551
 			 	}
552
-			 	$values[$key] = Api\DateTime::to($time,'ts');
552
+			 	$values[$key] = Api\DateTime::to($time, 'ts');
553 553
 		 	}
554 554
 		}
555 555
 		//error_log(__METHOD__.'() --> values[info_enddate]='.date('Y-m-d H:i:s',$values['info_enddate']));
@@ -562,11 +562,11 @@  discard block
 block discarded – undo
562 562
 	 * @param string $date_format = 'ts' date-formats: 'ts'=timestamp, 'server'=timestamp in server-time, 'array'=array or string with date-format
563 563
 	 * @return mixed depending of $date_format
564 564
 	 */
565
-	function date2usertime($ts,$date_format='ts')
565
+	function date2usertime($ts, $date_format = 'ts')
566 566
 	{
567 567
 		if (empty($ts) || $date_format == 'server') return $ts;
568 568
 
569
-		return Api\DateTime::server2user($ts,$date_format);
569
+		return Api\DateTime::server2user($ts, $date_format);
570 570
 	}
571 571
 
572 572
 	/**
@@ -581,10 +581,10 @@  discard block
 block discarded – undo
581 581
 	 *
582 582
 	 * @return array|boolean infolog entry, null if not found or false if no permission to read it
583 583
 	 */
584
-	function &read($info_id,$run_link_id2from=true,$date_format='ts',$ignore_acl=false)
584
+	function &read($info_id, $run_link_id2from = true, $date_format = 'ts', $ignore_acl = false)
585 585
 	{
586 586
 		//error_log(__METHOD__.'('.array2string($info_id).', '.array2string($run_link_id2from).", '$date_format') ".function_backtrace());
587
-		if (is_scalar($info_id) || isset($info_id[count($info_id)-1]))
587
+		if (is_scalar($info_id) || isset($info_id[count($info_id) - 1]))
588 588
 		{
589 589
 			if (is_scalar($info_id) && !is_numeric($info_id))
590 590
 			{
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
 			return null;
602 602
 		}
603 603
 
604
-		if (!$ignore_acl && !$this->check_access($data,Acl::READ))	// check behind read, to prevent a double read
604
+		if (!$ignore_acl && !$this->check_access($data, Acl::READ))	// check behind read, to prevent a double read
605 605
 		{
606 606
 			return False;
607 607
 		}
@@ -633,7 +633,7 @@  discard block
 block discarded – undo
633 633
 	 * @param boolean $skip_notification Do not send notification of delete
634 634
 	 * @return boolean True if delete was successful, False otherwise ($info_id does not exist or no rights)
635 635
 	 */
636
-	function delete($info_id,$delete_children=False,$new_parent=False, $skip_notification=False)
636
+	function delete($info_id, $delete_children = False, $new_parent = False, $skip_notification = False)
637 637
 	{
638 638
 		if (is_array($info_id))
639 639
 		{
@@ -643,18 +643,18 @@  discard block
 block discarded – undo
643 643
 		{
644 644
 			return False;
645 645
 		}
646
-		if (!$this->check_access($info,Acl::DELETE))
646
+		if (!$this->check_access($info, Acl::DELETE))
647 647
 		{
648 648
 			return False;
649 649
 		}
650 650
 		// check if we have children and delete or re-parent them
651 651
 		if (($children = $this->so->get_children($info_id)))
652 652
 		{
653
-			foreach($children as $id => $owner)
653
+			foreach ($children as $id => $owner)
654 654
 			{
655
-				if ($delete_children && $this->so->grants[$owner] & Acl::DELETE)
655
+				if ($delete_children && $this->so->grants[$owner]&Acl::DELETE)
656 656
 				{
657
-					$this->delete($id,$delete_children,$new_parent,$skip_notification);	// call ourself recursive to delete the child
657
+					$this->delete($id, $delete_children, $new_parent, $skip_notification); // call ourself recursive to delete the child
658 658
 				}
659 659
 				else	// dont delete or no rights to delete the child --> re-parent it
660 660
 				{
@@ -673,28 +673,28 @@  discard block
 block discarded – undo
673 673
 		// if we have history switched on and not an already deleted item --> set only status deleted
674 674
 		if ($this->history && $info['info_status'] != 'deleted')
675 675
 		{
676
-			if ($info['info_status'] == 'deleted') return false;	// entry already deleted
676
+			if ($info['info_status'] == 'deleted') return false; // entry already deleted
677 677
 
678 678
 			$this->so->write($deleted);
679 679
 
680
-			Link::unlink(0,'infolog',$info_id,'','!file','',true);	// keep the file attachments, hide the rest
680
+			Link::unlink(0, 'infolog', $info_id, '', '!file', '', true); // keep the file attachments, hide the rest
681 681
 		}
682 682
 		else
683 683
 		{
684
-			$this->so->delete($info_id,false);	// we delete the children via bo to get all notifications!
684
+			$this->so->delete($info_id, false); // we delete the children via bo to get all notifications!
685 685
 
686
-			Link::unlink(0,'infolog',$info_id);
686
+			Link::unlink(0, 'infolog', $info_id);
687 687
 		}
688 688
 		if ($info['info_status'] != 'deleted')	// dont notify of final purge of already deleted items
689 689
 		{
690 690
 			// send email notifications and do the history logging
691
-			if(!$skip_notification)
691
+			if (!$skip_notification)
692 692
 			{
693 693
 				if (!is_object($this->tracking))
694 694
 				{
695 695
 					$this->tracking = new infolog_tracking($this);
696 696
 				}
697
-				$this->tracking->track($deleted,$info,$this->user,true);
697
+				$this->tracking->track($deleted, $info, $this->user, true);
698 698
 			}
699 699
 		}
700 700
 		return True;
@@ -715,13 +715,13 @@  discard block
 block discarded – undo
715 715
 	*
716 716
 	* @return int|boolean info_id on a successfull write or false
717 717
 	*/
718
-	function write(&$values_in, $check_defaults=true, $touch_modified=true, $user2server=true,
719
-		$skip_notification=false, $throw_exception=false, $purge_cfs=null)
718
+	function write(&$values_in, $check_defaults = true, $touch_modified = true, $user2server = true,
719
+		$skip_notification = false, $throw_exception = false, $purge_cfs = null)
720 720
 	{
721 721
 		$values = $values_in;
722 722
 		//echo "boinfolog::write()values="; _debug_array($values);
723
-		if (!$values['info_id'] && !$this->check_access(0,Acl::EDIT,$values['info_owner']) &&
724
-			!$this->check_access(0,Acl::ADD,$values['info_owner']))
723
+		if (!$values['info_id'] && !$this->check_access(0, Acl::EDIT, $values['info_owner']) &&
724
+			!$this->check_access(0, Acl::ADD, $values['info_owner']))
725 725
 		{
726 726
 			return false;
727 727
 		}
@@ -731,7 +731,7 @@  discard block
 block discarded – undo
731 731
 			$old = $this->read($values['info_id'], false, 'server');
732 732
 		}
733 733
 
734
-		if (($status_only = $values['info_id'] && !$this->check_access($values,Acl::EDIT)))
734
+		if (($status_only = $values['info_id'] && !$this->check_access($values, Acl::EDIT)))
735 735
 		{
736 736
 			if (!isset($values['info_responsible']))
737 737
 			{
@@ -743,31 +743,31 @@  discard block
 block discarded – undo
743 743
 			}
744 744
 			if (!($status_only = in_array($this->user, (array)$responsible)))	// responsible has implicit right to change status
745 745
 			{
746
-				$status_only = !!array_intersect((array)$responsible,array_keys($GLOBALS['egw']->accounts->memberships($this->user)));
746
+				$status_only = !!array_intersect((array)$responsible, array_keys($GLOBALS['egw']->accounts->memberships($this->user)));
747 747
 			}
748 748
 			if (!$status_only && $values['info_status'] != 'deleted')
749 749
 			{
750
-				$status_only = $undelete = $this->check_access($values['info_id'],self::ACL_UNDELETE);
750
+				$status_only = $undelete = $this->check_access($values['info_id'], self::ACL_UNDELETE);
751 751
 			}
752 752
 		}
753
-		if ($values['info_id'] && !$this->check_access($values['info_id'],Acl::EDIT) && !$status_only ||
754
-		    !$values['info_id'] && $values['info_id_parent'] && !$this->check_access($values['info_id_parent'],Acl::ADD))
753
+		if ($values['info_id'] && !$this->check_access($values['info_id'], Acl::EDIT) && !$status_only ||
754
+		    !$values['info_id'] && $values['info_id_parent'] && !$this->check_access($values['info_id_parent'], Acl::ADD))
755 755
 		{
756 756
 			return false;
757 757
 		}
758 758
 
759 759
 		// Make sure status is still valid if the type changes
760
-		if($old['info_type'] != $values['info_type'] && $values['info_status'])
760
+		if ($old['info_type'] != $values['info_type'] && $values['info_status'])
761 761
 		{
762
-			if(!in_array($values['info_status'], array_keys($this->status[$values['info_type']])))
762
+			if (!in_array($values['info_status'], array_keys($this->status[$values['info_type']])))
763 763
 			{
764 764
 				$values['info_status'] = $this->status['defaults'][$values['info_type']];
765 765
 			}
766 766
 		}
767 767
 		if ($status_only && !$undelete)	// make sure only status gets writen
768 768
 		{
769
-			$set_completed = !$values['info_datecompleted'] &&	// set date completed of finished job, only if its not already set
770
-				in_array($values['info_status'],array('done','billed','cancelled'));
769
+			$set_completed = !$values['info_datecompleted'] && // set date completed of finished job, only if its not already set
770
+				in_array($values['info_status'], array('done', 'billed', 'cancelled'));
771 771
 
772 772
 			$values = $old;
773 773
 			// only overwrite explicitly allowed fields
@@ -782,7 +782,7 @@  discard block
 block discarded – undo
782 782
 				$values['info_percent'] = 100;
783 783
 				$forcestatus = true;
784 784
 				$status = 'done';
785
-				if (isset($values['info_type']) && !in_array($values['info_status'],array('done','billed','cancelled'))) {
785
+				if (isset($values['info_type']) && !in_array($values['info_status'], array('done', 'billed', 'cancelled'))) {
786 786
 					$forcestatus = false;
787 787
 					//echo "set_completed:"; _debug_array($this->status[$values['info_type']]);
788 788
 					if (isset($this->status[$values['info_type']]['done'])) {
@@ -796,19 +796,19 @@  discard block
 block discarded – undo
796 796
 						$status = 'cancelled';
797 797
 					}
798 798
 				}
799
-				if ($forcestatus && !in_array($values['info_status'],array('done','billed','cancelled'))) $values['info_status'] = $status;
799
+				if ($forcestatus && !in_array($values['info_status'], array('done', 'billed', 'cancelled'))) $values['info_status'] = $status;
800 800
 			}
801 801
 			$check_defaults = false;
802 802
 		}
803 803
 		if ($check_defaults)
804 804
 		{
805 805
 			if (!$values['info_datecompleted'] &&
806
-				(in_array($values['info_status'],array('done','billed'))))
806
+				(in_array($values['info_status'], array('done', 'billed'))))
807 807
 			{
808
-				$values['info_datecompleted'] = $user2server ? $this->user_time_now : $this->now;	// set date completed to today if status == done
808
+				$values['info_datecompleted'] = $user2server ? $this->user_time_now : $this->now; // set date completed to today if status == done
809 809
 			}
810 810
 			// Check for valid status / percent combinations
811
-			if (in_array($values['info_status'],array('done','billed')))
811
+			if (in_array($values['info_status'], array('done', 'billed')))
812 812
 			{
813 813
 				$values['info_percent'] = 100;
814 814
 			}
@@ -823,7 +823,7 @@  discard block
 block discarded – undo
823 823
 				// We change percent to match status, not status to match percent
824 824
 				$values['info_percent'] = 10;
825 825
 			}
826
-			if ((int)$values['info_percent'] == 100 && !in_array($values['info_status'],array('done','billed','cancelled','archive')))
826
+			if ((int)$values['info_percent'] == 100 && !in_array($values['info_status'], array('done', 'billed', 'cancelled', 'archive')))
827 827
 			{
828 828
 				//echo "check_defaults:"; _debug_array($this->status[$values['info_type']]);
829 829
 				//$values['info_status'] = 'done';
@@ -844,7 +844,7 @@  discard block
 block discarded – undo
844 844
 			}
845 845
 			if ($values['info_responsible'] && $values['info_status'] == 'offer')
846 846
 			{
847
-				$values['info_status'] = 'not-started';   // have to match if not finished
847
+				$values['info_status'] = 'not-started'; // have to match if not finished
848 848
 			}
849 849
 			if (isset($values['info_subject']) && empty($values['info_subject']))
850 850
 			{
@@ -852,18 +852,18 @@  discard block
 block discarded – undo
852 852
 			}
853 853
 
854 854
 			// Check required custom fields
855
-			if($throw_exception)
855
+			if ($throw_exception)
856 856
 			{
857 857
 				$custom = Api\Storage\Customfields::get('infolog');
858
-				foreach($custom as $c_name => $c_field)
858
+				foreach ($custom as $c_name => $c_field)
859 859
 				{
860
-					if($c_field['type2']) $type2 = is_array($c_field['type2']) ? $c_field['type2'] : explode(',',$c_field['type2']);
861
-					if($c_field['needed'] && (!$c_field['type2'] || $c_field['type2'] && in_array($values['info_type'],$type2)))
860
+					if ($c_field['type2']) $type2 = is_array($c_field['type2']) ? $c_field['type2'] : explode(',', $c_field['type2']);
861
+					if ($c_field['needed'] && (!$c_field['type2'] || $c_field['type2'] && in_array($values['info_type'], $type2)))
862 862
 					{
863 863
 						// Required custom field
864
-						if(!$values['#'.$c_name])
864
+						if (!$values['#'.$c_name])
865 865
 						{
866
-							throw new Api\Exception\WrongUserinput(lang('For infolog type %1, %2 is required',lang($values['info_type']),$c_field['label']));
866
+							throw new Api\Exception\WrongUserinput(lang('For infolog type %1, %2 is required', lang($values['info_type']), $c_field['label']));
867 867
 						}
868 868
 					}
869 869
 				}
@@ -872,16 +872,16 @@  discard block
 block discarded – undo
872 872
 		if (isset($this->group_owners[$values['info_type']]))
873 873
 		{
874 874
 			$values['info_owner'] = $this->group_owners[$values['info_type']];
875
-			if (!($this->grants[$this->group_owners[$values['info_type']]] & Acl::EDIT))
875
+			if (!($this->grants[$this->group_owners[$values['info_type']]]&Acl::EDIT))
876 876
 			{
877
-				if (!$this->check_access($values['info_id'],Acl::EDIT) ||
878
-					!$values['info_id'] && !$this->check_access($values,Acl::ADD)
877
+				if (!$this->check_access($values['info_id'], Acl::EDIT) ||
878
+					!$values['info_id'] && !$this->check_access($values, Acl::ADD)
879 879
 				)
880 880
 				{
881
-					return false;	// no edit rights from the group-owner and no implicit rights (delegated and sufficient rights)
881
+					return false; // no edit rights from the group-owner and no implicit rights (delegated and sufficient rights)
882 882
 				}
883 883
 			}
884
-			$values['info_access'] = 'public';	// group-owners are allways public
884
+			$values['info_access'] = 'public'; // group-owners are allways public
885 885
 		}
886 886
 		elseif (!$values['info_id'] && !$values['info_owner'] || $GLOBALS['egw']->accounts->get_type($values['info_owner']) == 'g')
887 887
 		{
@@ -941,23 +941,23 @@  discard block
 block discarded – undo
941 941
 			$to_write['info_id'] = $info_id;
942 942
 
943 943
 			// if the info responbsible array is not passed, fetch it from old.
944
-			if (!array_key_exists('info_responsible',$values)) $values['info_responsible'] = $old['info_responsible'];
944
+			if (!array_key_exists('info_responsible', $values)) $values['info_responsible'] = $old['info_responsible'];
945 945
 			if (!is_array($values['info_responsible']))		// this should not happen, bug it does ;-)
946 946
 			{
947
-				$values['info_responsible'] = $values['info_responsible'] ? explode(',',$values['info_responsible']) : array();
947
+				$values['info_responsible'] = $values['info_responsible'] ? explode(',', $values['info_responsible']) : array();
948 948
 				$to_write['info_responsible'] = $values['info_responsible'];
949 949
 			}
950 950
 			// create (and remove) links in custom fields
951
-			Api\Storage\Customfields::update_links('infolog',$values,$old,'info_id');
951
+			Api\Storage\Customfields::update_links('infolog', $values, $old, 'info_id');
952 952
 
953 953
 			// Check for restore of deleted entry, restore held links
954
-			if($old['info_status'] == 'deleted' && $values['info_status'] != 'deleted')
954
+			if ($old['info_status'] == 'deleted' && $values['info_status'] != 'deleted')
955 955
 			{
956 956
 				Link::restore('infolog', $info_id);
957 957
 			}
958 958
 
959 959
 			// notify the link-class about the update, as other apps may be subscribt to it
960
-			Link::notify_update('infolog',$info_id,$values);
960
+			Link::notify_update('infolog', $info_id, $values);
961 961
 
962 962
 			// pre-cache the new values
963 963
 			self::set_link_cache($values);
@@ -968,42 +968,42 @@  discard block
 block discarded – undo
968 968
 				$this->tracking = new infolog_tracking($this);
969 969
 			}
970 970
 
971
-			if ($old && ($missing_fields = array_diff_key($old,$values)))
971
+			if ($old && ($missing_fields = array_diff_key($old, $values)))
972 972
 			{
973 973
 				// Some custom fields (multiselect with nothing selected) will be missing,
974 974
 				// and that's OK.  Don't put them back.
975
-				foreach(array_keys($missing_fields) as $field)
975
+				foreach (array_keys($missing_fields) as $field)
976 976
 				{
977
-					if(array_key_exists($field, $values_in))
977
+					if (array_key_exists($field, $values_in))
978 978
 					{
979 979
 						unset($missing_fields[$field]);
980 980
 					}
981 981
 				}
982
-				$values = array_merge($values,$missing_fields);
982
+				$values = array_merge($values, $missing_fields);
983 983
 			}
984 984
 			// Add keys missing in the $to_write array
985
-			if (($missing_fields = array_diff_key($values,$to_write)))
985
+			if (($missing_fields = array_diff_key($values, $to_write)))
986 986
 			{
987
-				$to_write = array_merge($to_write,$missing_fields);
987
+				$to_write = array_merge($to_write, $missing_fields);
988 988
 			}
989
-			$this->tracking->track($to_write,$old,$this->user,$values['info_status'] == 'deleted' || $old['info_status'] == 'deleted',
990
-				null,$skip_notification);
989
+			$this->tracking->track($to_write, $old, $this->user, $values['info_status'] == 'deleted' || $old['info_status'] == 'deleted',
990
+				null, $skip_notification);
991 991
 
992 992
 			if ($info_from_set) $values['info_from'] = '';
993 993
 
994 994
 			// Change new values back to user time before sending them back
995
-			if($user2server)
995
+			if ($user2server)
996 996
 			{
997 997
 				$this->time2time($values);
998 998
 			}
999 999
 			// merge changes (keeping extra values from the UI)
1000
-			$values_in = array_merge($values_in,$values);
1000
+			$values_in = array_merge($values_in, $values);
1001 1001
 
1002 1002
 			// Update modified timestamp of parent
1003
-			if($values['info_id_parent'])
1003
+			if ($values['info_id_parent'])
1004 1004
 			{
1005
-				$parent = $this->read($values['info_id_parent'], false, 'server',true);
1006
-				$this->write($parent,false, true, false, true);
1005
+				$parent = $this->read($values['info_id_parent'], false, 'server', true);
1006
+				$this->write($parent, false, true, false, true);
1007 1007
 			}
1008 1008
 		}
1009 1009
 		return $info_id;
@@ -1015,9 +1015,9 @@  discard block
 block discarded – undo
1015 1015
 	 * @param int|array $info_id id
1016 1016
 	 * @return int|array number of subs
1017 1017
 	 */
1018
-	function anzSubs( $info_id )
1018
+	function anzSubs($info_id)
1019 1019
 	{
1020
-		return $this->so->anzSubs( $info_id );
1020
+		return $this->so->anzSubs($info_id);
1021 1021
 	}
1022 1022
 
1023 1023
 	/**
@@ -1037,19 +1037,19 @@  discard block
 block discarded – undo
1037 1037
 	{
1038 1038
 		//error_log(__METHOD__.'('.array2string($query).')');
1039 1039
 
1040
-		if($query['filter'] == 'bydate')
1040
+		if ($query['filter'] == 'bydate')
1041 1041
 		{
1042 1042
 			if (is_int($query['startdate'])) $query['col_filter'][] = 'info_startdate >= '.$GLOBALS['egw']->db->quote($query['startdate']);
1043
-			if (is_int($query['enddate'])) $query['col_filter'][] = 'info_startdate <= '.$GLOBALS['egw']->db->quote($query['enddate']+(60*60*24)-1);
1043
+			if (is_int($query['enddate'])) $query['col_filter'][] = 'info_startdate <= '.$GLOBALS['egw']->db->quote($query['enddate'] + (60 * 60 * 24) - 1);
1044 1044
 		}
1045 1045
 		elseif ($query['filter'] == 'duedate')
1046 1046
 		{
1047 1047
 			if (is_int($query['startdate'])) $query['col_filter'][] = 'info_enddate >= '.$GLOBALS['egw']->db->quote($query['startdate']);
1048
-			if (is_int($query['enddate'])) $query['col_filter'][] = 'info_enddate <= '.$GLOBALS['egw']->db->quote($query['enddate']+(60*60*24)-1);
1048
+			if (is_int($query['enddate'])) $query['col_filter'][] = 'info_enddate <= '.$GLOBALS['egw']->db->quote($query['enddate'] + (60 * 60 * 24) - 1);
1049 1049
 		}
1050 1050
 		elseif ($query['filter'] == 'private')
1051 1051
 		{
1052
-			$query['col_filter'][] = 'info_access = ' . $GLOBALS['egw']->db->quote('private');
1052
+			$query['col_filter'][] = 'info_access = '.$GLOBALS['egw']->db->quote('private');
1053 1053
 		}
1054 1054
 		if (!isset($query['date_format']) || $query['date_format'] != 'server')
1055 1055
 		{
@@ -1059,7 +1059,7 @@  discard block
 block discarded – undo
1059 1059
 				{
1060 1060
 					if (!empty($query['col_filter'][$key]))
1061 1061
 					{
1062
-						$query['col_filter'][$key] = Api\DateTime::user2server($query['col_filter'][$key],'ts');
1062
+						$query['col_filter'][$key] = Api\DateTime::user2server($query['col_filter'][$key], 'ts');
1063 1063
 					}
1064 1064
 				}
1065 1065
 			}
@@ -1072,7 +1072,7 @@  discard block
 block discarded – undo
1072 1072
 		{
1073 1073
 			foreach ($ret as $id => &$data)
1074 1074
 			{
1075
-				if (!$this->check_access($data,Acl::READ))
1075
+				if (!$this->check_access($data, Acl::READ))
1076 1076
 				{
1077 1077
 					unset($ret[$id]);
1078 1078
 					continue;
@@ -1088,7 +1088,7 @@  discard block
 block discarded – undo
1088 1088
 							if ($time->format('Hi') == '0000')
1089 1089
 							{
1090 1090
 								// we keep dates the same in user-time
1091
-								$arr = Api\DateTime::to($time,'array');
1091
+								$arr = Api\DateTime::to($time, 'array');
1092 1092
 								$time = new Api\DateTime($arr, Api\DateTime::$user_timezone);
1093 1093
 							}
1094 1094
 							else
@@ -1096,7 +1096,7 @@  discard block
 block discarded – undo
1096 1096
 								$time->setTimezone(Api\DateTime::$user_timezone);
1097 1097
 							}
1098 1098
 						}
1099
-						$data[$key] = Api\DateTime::to($time,'ts');
1099
+						$data[$key] = Api\DateTime::to($time, 'ts');
1100 1100
 					}
1101 1101
 				}
1102 1102
 				// pre-cache title and file access
@@ -1113,7 +1113,7 @@  discard block
 block discarded – undo
1113 1113
 	 * @param array $filter = array('filter'=>'own','info_type'=>'task')
1114 1114
 	 * @return string
1115 1115
 	 */
1116
-	public function getctag(array $filter=array('filter'=>'own','info_type'=>'task'))
1116
+	public function getctag(array $filter = array('filter'=>'own', 'info_type'=>'task'))
1117 1117
 	{
1118 1118
 		$filter += array(
1119 1119
 			'order'			=> 'info_datemodified',
@@ -1125,7 +1125,7 @@  discard block
 block discarded – undo
1125 1125
 		// we need to query deleted entries too for a ctag!
1126 1126
 		$filter['filter'] .= '+deleted';
1127 1127
 
1128
-		$result =& $this->search($filter);
1128
+		$result = & $this->search($filter);
1129 1129
 
1130 1130
 		if (empty($result)) return 'EGw-empty-wGE';
1131 1131
 
@@ -1147,12 +1147,12 @@  discard block
 block discarded – undo
1147 1147
 	 * @param string $_date
1148 1148
 	 * @return array $content array for uiinfolog
1149 1149
 	 */
1150
-	function import_mail($_addresses,$_subject,$_message,$_attachments,$_date)
1150
+	function import_mail($_addresses, $_subject, $_message, $_attachments, $_date)
1151 1151
 	{
1152
-		foreach($_addresses as $address)
1152
+		foreach ($_addresses as $address)
1153 1153
 		{
1154 1154
 			$names[] = $address['name'];
1155
-			$emails[] =$address['email'];
1155
+			$emails[] = $address['email'];
1156 1156
 		}
1157 1157
 
1158 1158
 		$type = isset($this->enums['type']['email']) ? 'email' : 'note';
@@ -1160,8 +1160,8 @@  discard block
 block discarded – undo
1160 1160
 		$info = array(
1161 1161
 			'info_id' => 0,
1162 1162
 			'info_type' => $type,
1163
-			'info_from' => implode(', ',$names),
1164
-			'info_addr' => implode(', ',$emails),
1163
+			'info_from' => implode(', ', $names),
1164
+			'info_addr' => implode(', ', $emails),
1165 1165
 			'info_subject' => $_subject,
1166 1166
 			'info_des' => $_message,
1167 1167
 			'info_startdate' => Api\DateTime::server2user($_date),
@@ -1180,16 +1180,16 @@  discard block
 block discarded – undo
1180 1180
 		$contacts = array();
1181 1181
 		foreach ($emails as $mailadr)
1182 1182
 		{
1183
-			$contacts = array_merge($contacts,(array)$addressbook->search(
1183
+			$contacts = array_merge($contacts, (array)$addressbook->search(
1184 1184
 				array(
1185 1185
 					'email' => $mailadr,
1186 1186
 					'email_home' => $mailadr
1187
-				),True,'','','',false,'OR',false,null,'',false));
1187
+				), True, '', '', '', false, 'OR', false, null, '', false));
1188 1188
 		}
1189 1189
 		if (!$contacts || !is_array($contacts) || !is_array($contacts[0]))
1190 1190
 		{
1191
-			$info['msg'] = lang('Attention: No Contact with address %1 found.',$info['info_addr']);
1192
-			$info['info_custom_from'] = true;	// show the info_from line and NOT only the link
1191
+			$info['msg'] = lang('Attention: No Contact with address %1 found.', $info['info_addr']);
1192
+			$info['info_custom_from'] = true; // show the info_from line and NOT only the link
1193 1193
 		}
1194 1194
 		else
1195 1195
 		{
@@ -1199,21 +1199,21 @@  discard block
 block discarded – undo
1199 1199
 			// create the rest a "ordinary" links
1200 1200
 			foreach ($contacts as $contact)
1201 1201
 			{
1202
-				Link::link('infolog',$info['link_to']['to_id'],'addressbook',$contact['id']);
1202
+				Link::link('infolog', $info['link_to']['to_id'], 'addressbook', $contact['id']);
1203 1203
 			}
1204 1204
 		}
1205 1205
 		if (is_array($_attachments))
1206 1206
 		{
1207 1207
 			foreach ($_attachments as $attachment)
1208 1208
 			{
1209
-				if($attachment['egw_data'])
1209
+				if ($attachment['egw_data'])
1210 1210
 				{
1211
-					Link::link('infolog',$info['link_to']['to_id'],Link::DATA_APPNAME,  $attachment);
1211
+					Link::link('infolog', $info['link_to']['to_id'], Link::DATA_APPNAME, $attachment);
1212 1212
 				}
1213
-				else if(is_readable($attachment['tmp_name']) ||
1213
+				else if (is_readable($attachment['tmp_name']) ||
1214 1214
 					(Vfs::is_readable($attachment['tmp_name']) && parse_url($attachment['tmp_name'], PHP_URL_SCHEME) === 'vfs'))
1215 1215
 				{
1216
-					Link::link('infolog',$info['link_to']['to_id'],'file',  $attachment);
1216
+					Link::link('infolog', $info['link_to']['to_id'], 'file', $attachment);
1217 1217
 				}
1218 1218
 			}
1219 1219
 		}
@@ -1232,14 +1232,14 @@  discard block
 block discarded – undo
1232 1232
 	{
1233 1233
 		if (!is_array($info))
1234 1234
 		{
1235
-			$info = $this->read( $info,false );
1235
+			$info = $this->read($info, false);
1236 1236
 		}
1237 1237
 		if (!$info)
1238 1238
 		{
1239 1239
 			return $info;
1240 1240
 		}
1241
-		$title = !empty($info['info_subject']) ? $info['info_subject'] :self::subject_from_des($info['info_descr']);
1242
-		return $title.($GLOBALS['egw_info']['user']['preferences']['infolog']['show_id']?' (#'.$info['info_id'].')':'');
1241
+		$title = !empty($info['info_subject']) ? $info['info_subject'] : self::subject_from_des($info['info_descr']);
1242
+		return $title.($GLOBALS['egw_info']['user']['preferences']['infolog']['show_id'] ? ' (#'.$info['info_id'].')' : '');
1243 1243
 	}
1244 1244
 
1245 1245
 	/**
@@ -1250,15 +1250,15 @@  discard block
 block discarded – undo
1250 1250
 	function link_titles(array $ids)
1251 1251
 	{
1252 1252
 		$titles = array();
1253
-		foreach ($this->search($params=array(
1253
+		foreach ($this->search($params = array(
1254 1254
 			'col_filter' => array('info_id' => $ids),
1255 1255
 		)) as $info)
1256 1256
 		{
1257 1257
 			$titles[$info['info_id']] = $this->link_title($info);
1258 1258
 		}
1259
-		foreach (array_diff($ids,array_keys($titles)) as $id)
1259
+		foreach (array_diff($ids, array_keys($titles)) as $id)
1260 1260
 		{
1261
-			$titles[$id] = false;	// we assume every not returned entry to be not readable, as we notify the link class about all deletes
1261
+			$titles[$id] = false; // we assume every not returned entry to be not readable, as we notify the link class about all deletes
1262 1262
 		}
1263 1263
 		return $titles;
1264 1264
 	}
@@ -1285,7 +1285,7 @@  discard block
 block discarded – undo
1285 1285
 		$content = array();
1286 1286
 		if (is_array($ids))
1287 1287
 		{
1288
-			foreach(array_keys($ids) as $id)
1288
+			foreach (array_keys($ids) as $id)
1289 1289
 			{
1290 1290
 				$content[$id] = $this->link_title($id);
1291 1291
 			}
@@ -1302,10 +1302,10 @@  discard block
 block discarded – undo
1302 1302
 	 * @param int $user = null for which user to check, default current user
1303 1303
 	 * @return boolean true if access is granted or false otherwise
1304 1304
 	 */
1305
-	function file_access($id,$check,$rel_path=null,$user=null)
1305
+	function file_access($id, $check, $rel_path = null, $user = null)
1306 1306
 	{
1307
-		unset($rel_path);	// not used
1308
-		return $this->check_access($id,$check,0,$user);
1307
+		unset($rel_path); // not used
1308
+		return $this->check_access($id, $check, 0, $user);
1309 1309
 	}
1310 1310
 
1311 1311
 	/**
@@ -1315,10 +1315,9 @@  discard block
 block discarded – undo
1315 1315
 	 */
1316 1316
 	function set_link_cache(array $info)
1317 1317
 	{
1318
-		Link::set_cache('infolog',$info['info_id'],
1318
+		Link::set_cache('infolog', $info['info_id'],
1319 1319
 			$this->link_title($info),
1320
-			$this->file_access($info,Acl::EDIT) ? EGW_ACL_READ|EGW_ACL_EDIT :
1321
-			($this->file_access($info,Acl::READ) ? Acl::READ : 0));
1320
+			$this->file_access($info, Acl::EDIT) ? EGW_ACL_READ|EGW_ACL_EDIT : ($this->file_access($info, Acl::READ) ? Acl::READ : 0));
1322 1321
 	}
1323 1322
 
1324 1323
 	/**
@@ -1332,8 +1331,8 @@  discard block
 block discarded – undo
1332 1331
 	function cal_to_include($args)
1333 1332
 	{
1334 1333
 		//echo "<p>cal_to_include("; print_r($args); echo ")</p>\n";
1335
-		$user = (int) $args['owner'];
1336
-		if ($user <= 0 && !checkdate($args['month'],$args['day'],$args['year']))
1334
+		$user = (int)$args['owner'];
1335
+		if ($user <= 0 && !checkdate($args['month'], $args['day'], $args['year']))
1337 1336
 		{
1338 1337
 			return False;
1339 1338
 		}
@@ -1341,7 +1340,7 @@  discard block
 block discarded – undo
1341 1340
 
1342 1341
 		$do_events = $args['location'] == 'calendar_include_events';
1343 1342
 		$to_include = array();
1344
-		$date_wanted = sprintf('%04d/%02d/%02d',$args['year'],$args['month'],$args['day']);
1343
+		$date_wanted = sprintf('%04d/%02d/%02d', $args['year'], $args['month'], $args['day']);
1345 1344
 		$query = array(
1346 1345
 			'order' => 'info_startdate',
1347 1346
 			'sort'  => $do_events ? 'ASC' : 'DESC',
@@ -1350,34 +1349,34 @@  discard block
 block discarded – undo
1350 1349
 		);
1351 1350
 		if ($GLOBALS['egw_info']['user']['preferences']['infolog']['cal_show'] || $GLOBALS['egw_info']['user']['preferences']['infolog']['cal_show'] === '0')
1352 1351
 		{
1353
-			$query['col_filter']['info_type'] = explode(',',$GLOBALS['egw_info']['user']['preferences']['infolog']['cal_show']);
1352
+			$query['col_filter']['info_type'] = explode(',', $GLOBALS['egw_info']['user']['preferences']['infolog']['cal_show']);
1354 1353
 		}
1355 1354
 		elseif ($this->customfields && !$GLOBALS['egw_info']['user']['preferences']['infolog']['cal_show_custom'])
1356 1355
 		{
1357
-			$query['col_filter']['info_type'] = array('task','phone','note','email');
1356
+			$query['col_filter']['info_type'] = array('task', 'phone', 'note', 'email');
1358 1357
 		}
1359 1358
 		while ($infos = $this->search($query))
1360 1359
 		{
1361 1360
 			foreach ($infos as $info)
1362 1361
 			{
1363
-				$start = new Api\DateTime($info['info_startdate'],Api\DateTime::$user_timezone);
1362
+				$start = new Api\DateTime($info['info_startdate'], Api\DateTime::$user_timezone);
1364 1363
 				$title = ($do_events ? $start->format(false).' ' : '').
1365 1364
 					$info['info_subject'];
1366
-				$view = Link::view('infolog',$info['info_id']);
1365
+				$view = Link::view('infolog', $info['info_id']);
1367 1366
 				$size = null;
1368
-				$edit = Link::edit('infolog',$info['info_id'], $size);
1367
+				$edit = Link::edit('infolog', $info['info_id'], $size);
1369 1368
 				$edit['size'] = $size;
1370
-				$content=array();
1369
+				$content = array();
1371 1370
 				$status = $this->status[$info['info_type']][$info['info_status']];
1372 1371
 				$icons = array();
1373
-				foreach(array(
1372
+				foreach (array(
1374 1373
 					$info['info_type'] => 'navbar',
1375 1374
 					$status => 'status'
1376 1375
 				) as $icon => $default)
1377 1376
 				{
1378
-					$icons[Api\Image::find('infolog',$icon) ? $icon : $default] = $icon;
1377
+					$icons[Api\Image::find('infolog', $icon) ? $icon : $default] = $icon;
1379 1378
 				}
1380
-				$content[] = Api\Html::a_href($title,$view);
1379
+				$content[] = Api\Html::a_href($title, $view);
1381 1380
 				$html = Api\Html::table(array(1 => $content));
1382 1381
 
1383 1382
 				$to_include[] = array(
@@ -1390,9 +1389,9 @@  discard block
 block discarded – undo
1390 1389
 					'content'   => $html,
1391 1390
 				);
1392 1391
 			}
1393
-			if ($query['total'] <= ($query['start']+=count($infos)))
1392
+			if ($query['total'] <= ($query['start'] += count($infos)))
1394 1393
 			{
1395
-				break;	// no more availible
1394
+				break; // no more availible
1396 1395
 			}
1397 1396
 		}
1398 1397
 		//echo "boinfolog::cal_to_include("; print_r($args); echo ")<pre>"; print_r($to_include); echo "</pre>\n";
@@ -1415,7 +1414,7 @@  discard block
 block discarded – undo
1415 1414
 				'cols' => 'info_id,info_type,info_status,info_percent,info_id_parent',
1416 1415
 			);
1417 1416
 			$infos = array();
1418
-			foreach($this->search($query) as $row)
1417
+			foreach ($this->search($query) as $row)
1419 1418
 			{
1420 1419
 				$infos[$row['info_id']] = array(
1421 1420
 					'status' => $row['info_type'] != 'phone' && $row['info_status'] == 'ongoing' ?
@@ -1424,13 +1423,13 @@  discard block
 block discarded – undo
1424 1423
 						'ongoing' : 'infolog/'.$row['info_status'],
1425 1424
 					'class'  => $row['info_id_parent'] ? 'infolog_rowHasParent' : null,
1426 1425
 				);
1427
-				if (Api\Image::find('infolog', $icon=$row['info_type'].'_element') ||
1428
-					Api\Image::find('infolog', $icon=$row['info_type']))
1426
+				if (Api\Image::find('infolog', $icon = $row['info_type'].'_element') ||
1427
+					Api\Image::find('infolog', $icon = $row['info_type']))
1429 1428
 				{
1430 1429
 					$infos[$row['info_id']]['icon'] = 'infolog/'.$icon;
1431 1430
 				}
1432 1431
 			}
1433
-			foreach($this->anzSubs(array_keys($infos)) as $info_id => $subs)
1432
+			foreach ($this->anzSubs(array_keys($infos)) as $info_id => $subs)
1434 1433
 			{
1435 1434
 				if ($subs) $infos[$info_id]['class'] .= ' infolog_rowHasSubs';
1436 1435
 			}
@@ -1449,18 +1448,18 @@  discard block
 block discarded – undo
1449 1448
 	 *  by the ones the user normally does not see due to category permissions - used to preserve categories
1450 1449
 	 * @return array category ids (found, added and preserved categories)
1451 1450
 	 */
1452
-	function find_or_add_categories($catname_list, $info_id=-1)
1451
+	function find_or_add_categories($catname_list, $info_id = -1)
1453 1452
 	{
1454 1453
 		if (!is_object($this->categories))
1455 1454
 		{
1456
-			$this->categories = new Api\Categories($this->user,'infolog');
1455
+			$this->categories = new Api\Categories($this->user, 'infolog');
1457 1456
 		}
1458 1457
 		$old_cats_preserve = array();
1459 1458
 		if ($info_id && $info_id > 0)
1460 1459
 		{
1461 1460
 			// preserve Api\Categories without users read access
1462 1461
 			$old_infolog = $this->read($info_id);
1463
-			$old_categories = explode(',',$old_infolog['info_cat']);
1462
+			$old_categories = explode(',', $old_infolog['info_cat']);
1464 1463
 			if (is_array($old_categories) && count($old_categories) > 0)
1465 1464
 			{
1466 1465
 				foreach ($old_categories as $cat_id)
@@ -1521,15 +1520,15 @@  discard block
 block discarded – undo
1521 1520
 	{
1522 1521
 		if (!is_object($this->categories))
1523 1522
 		{
1524
-			$this->categories = new Api\Categories($this->user,'infolog');
1523
+			$this->categories = new Api\Categories($this->user, 'infolog');
1525 1524
 		}
1526 1525
 
1527 1526
 		if (!is_array($cat_id_list))
1528 1527
 		{
1529
-			$cat_id_list = explode(',',$cat_id_list);
1528
+			$cat_id_list = explode(',', $cat_id_list);
1530 1529
 		}
1531 1530
 		$cat_list = array();
1532
-		foreach($cat_id_list as $cat_id)
1531
+		foreach ($cat_id_list as $cat_id)
1533 1532
 		{
1534 1533
 			if ($cat_id && $this->categories->check_perms(Acl::READ, $cat_id) &&
1535 1534
 					($cat_name = $this->categories->id2name($cat_id)) && $cat_name != '--')
@@ -1556,20 +1555,20 @@  discard block
 block discarded – undo
1556 1555
 
1557 1556
 		$save_account_id = $GLOBALS['egw_info']['user']['account_id'];
1558 1557
 		$save_prefs      = $GLOBALS['egw_info']['user']['preferences'];
1559
-		foreach($users as $user)
1558
+		foreach ($users as $user)
1560 1559
 		{
1561
-			if (!($email = $GLOBALS['egw']->accounts->id2name($user,'account_email'))) continue;
1560
+			if (!($email = $GLOBALS['egw']->accounts->id2name($user, 'account_email'))) continue;
1562 1561
 			// create the enviroment for $user
1563 1562
 			$this->user = $GLOBALS['egw_info']['user']['account_id'] = $user;
1564 1563
 			$GLOBALS['egw']->preferences->__construct($user);
1565 1564
 			$GLOBALS['egw_info']['user']['preferences'] = $GLOBALS['egw']->preferences->read_repository();
1566 1565
 			$GLOBALS['egw']->acl->__construct($user);
1567 1566
 			$GLOBALS['egw']->acl->read_repository();
1568
-			$this->grants = $GLOBALS['egw']->acl->get_grants('infolog',$this->group_owners ? $this->group_owners : true);
1569
-			$this->so = new infolog_so($this->grants);	// so caches it's filters
1567
+			$this->grants = $GLOBALS['egw']->acl->get_grants('infolog', $this->group_owners ? $this->group_owners : true);
1568
+			$this->so = new infolog_so($this->grants); // so caches it's filters
1570 1569
 
1571 1570
 			$notified_info_ids = array();
1572
-			foreach(array(
1571
+			foreach (array(
1573 1572
 				'notify_due_responsible'   => 'open-responsible-enddate',
1574 1573
 				'notify_due_delegated'     => 'open-delegated-enddate',
1575 1574
 				'notify_start_responsible' => 'open-responsible-date',
@@ -1578,44 +1577,44 @@  discard block
 block discarded – undo
1578 1577
 			{
1579 1578
 				if (!($pref_value = $GLOBALS['egw_info']['user']['preferences']['infolog'][$pref])) continue;
1580 1579
 
1581
-				$filter .= date('Y-m-d',time()+24*60*60*(int)$pref_value);
1580
+				$filter .= date('Y-m-d', time() + 24 * 60 * 60 * (int)$pref_value);
1582 1581
 				//error_log(__METHOD__."() checking with filter '$filter' ($pref_value) for user $user ($email)");
1583 1582
 
1584 1583
 				$params = array('filter' => $filter, 'custom_fields' => true, 'subs' => true);
1585
-				foreach($this->so->search($params) as $info)
1584
+				foreach ($this->so->search($params) as $info)
1586 1585
 				{
1587 1586
 					// check if we already send a notification for that infolog entry, eg. starting and due on same day
1588
-					if (in_array($info['info_id'],$notified_info_ids)) continue;
1587
+					if (in_array($info['info_id'], $notified_info_ids)) continue;
1589 1588
 
1590 1589
 					if (is_null($this->tracking) || $this->tracking->user != $user)
1591 1590
 					{
1592 1591
 						$this->tracking = new infolog_tracking($this);
1593 1592
 					}
1594
-					switch($pref)
1593
+					switch ($pref)
1595 1594
 					{
1596 1595
 						case 'notify_due_responsible':
1597
-							$info['prefix'] = lang('Due %1',$this->enums['type'][$info['info_type']]);
1598
-							$info['message'] = lang('%1 you are responsible for is due at %2',$this->enums['type'][$info['info_type']],
1599
-								$this->tracking->datetime($info['info_enddate'],false));
1596
+							$info['prefix'] = lang('Due %1', $this->enums['type'][$info['info_type']]);
1597
+							$info['message'] = lang('%1 you are responsible for is due at %2', $this->enums['type'][$info['info_type']],
1598
+								$this->tracking->datetime($info['info_enddate'], false));
1600 1599
 							break;
1601 1600
 						case 'notify_due_delegated':
1602
-							$info['prefix'] = lang('Due %1',$this->enums['type'][$info['info_type']]);
1603
-							$info['message'] = lang('%1 you delegated is due at %2',$this->enums['type'][$info['info_type']],
1604
-								$this->tracking->datetime($info['info_enddate'],false));
1601
+							$info['prefix'] = lang('Due %1', $this->enums['type'][$info['info_type']]);
1602
+							$info['message'] = lang('%1 you delegated is due at %2', $this->enums['type'][$info['info_type']],
1603
+								$this->tracking->datetime($info['info_enddate'], false));
1605 1604
 							break;
1606 1605
 						case 'notify_start_responsible':
1607
-							$info['prefix'] = lang('Starting %1',$this->enums['type'][$info['info_type']]);
1608
-							$info['message'] = lang('%1 you are responsible for is starting at %2',$this->enums['type'][$info['info_type']],
1609
-								$this->tracking->datetime($info['info_startdate'],null));
1606
+							$info['prefix'] = lang('Starting %1', $this->enums['type'][$info['info_type']]);
1607
+							$info['message'] = lang('%1 you are responsible for is starting at %2', $this->enums['type'][$info['info_type']],
1608
+								$this->tracking->datetime($info['info_startdate'], null));
1610 1609
 							break;
1611 1610
 						case 'notify_start_delegated':
1612
-							$info['prefix'] = lang('Starting %1',$this->enums['type'][$info['info_type']]);
1613
-							$info['message'] = lang('%1 you delegated is starting at %2',$this->enums['type'][$info['info_type']],
1614
-								$this->tracking->datetime($info['info_startdate'],null));
1611
+							$info['prefix'] = lang('Starting %1', $this->enums['type'][$info['info_type']]);
1612
+							$info['message'] = lang('%1 you delegated is starting at %2', $this->enums['type'][$info['info_type']],
1613
+								$this->tracking->datetime($info['info_startdate'], null));
1615 1614
 							break;
1616 1615
 					}
1617 1616
 					//error_log("notifiying $user($email) about $info[info_subject]: $info[message]");
1618
-					$this->tracking->send_notification($info,null,$email,$user,$pref);
1617
+					$this->tracking->send_notification($info, null, $email, $user, $pref);
1619 1618
 
1620 1619
 					$notified_info_ids[] = $info['info_id'];
1621 1620
 				}
@@ -1678,7 +1677,7 @@  discard block
 block discarded – undo
1678 1677
 	 * @param string $x_infolog_status preserved original infolog status
1679 1678
 	 * @return string
1680 1679
 	 */
1681
-	function vtodo2status($_vtodo_status,$x_infolog_status=null)
1680
+	function vtodo2status($_vtodo_status, $x_infolog_status = null)
1682 1681
 	{
1683 1682
 		$vtodo_status = strtoupper($_vtodo_status);
1684 1683
 
@@ -1702,7 +1701,7 @@  discard block
 block discarded – undo
1702 1701
 	 * @param array &$icons = null on return name of icons
1703 1702
 	 * @return array value => (commaseparated) translations
1704 1703
 	 */
1705
-	function get_status($type=null, array &$icons=null)
1704
+	function get_status($type = null, array &$icons = null)
1706 1705
 	{
1707 1706
 		// if filtered by type, show only the stati of the filtered type
1708 1707
 		if ($type && isset($this->status[$type]))
@@ -1712,16 +1711,16 @@  discard block
 block discarded – undo
1712 1711
 		else	// show all stati
1713 1712
 		{
1714 1713
 			$statis = $icons = array();
1715
-			foreach($this->status as $t => $stati)
1714
+			foreach ($this->status as $t => $stati)
1716 1715
 			{
1717 1716
 				if ($t === 'defaults') continue;
1718
-				foreach($stati as $val => $label)
1717
+				foreach ($stati as $val => $label)
1719 1718
 				{
1720 1719
 					$statis[$val][$label] = lang($label);
1721 1720
 					if (!isset($icons[$val])) $icons[$val] = $label;
1722 1721
 				}
1723 1722
 			}
1724
-			foreach($statis as $val => &$labels)
1723
+			foreach ($statis as $val => &$labels)
1725 1724
 			{
1726 1725
 				$labels = implode(', ', $labels);
1727 1726
 			}
@@ -1737,7 +1736,7 @@  discard block
 block discarded – undo
1737 1736
 	 */
1738 1737
 	function activate($info)
1739 1738
 	{
1740
-		switch((int)$info['info_percent'])
1739
+		switch ((int)$info['info_percent'])
1741 1740
 		{
1742 1741
 			case 0:		return 'not-started';
1743 1742
 			case 100:	return 'done';
@@ -1756,8 +1755,8 @@  discard block
 block discarded – undo
1756 1755
 		#Horde::logMessage("getParentID($_guid)",  __FILE__, __LINE__, PEAR_LOG_DEBUG);
1757 1756
 
1758 1757
 		$parentID = False;
1759
-		$myfilter = array('col_filter' => array('info_uid'=>$_guid)) ;
1760
-		if ($_guid && ($found=$this->search($myfilter)) && ($uidmatch = array_shift($found)))
1758
+		$myfilter = array('col_filter' => array('info_uid'=>$_guid));
1759
+		if ($_guid && ($found = $this->search($myfilter)) && ($uidmatch = array_shift($found)))
1761 1760
 		{
1762 1761
 			$parentID = $uidmatch['info_id'];
1763 1762
 		}
@@ -1774,7 +1773,7 @@  discard block
 block discarded – undo
1774 1773
 	 *
1775 1774
 	 * @return array of infolog_ids of matching entries
1776 1775
 	 */
1777
-	function findInfo($infoData, $relax=false, $tzid=null)
1776
+	function findInfo($infoData, $relax = false, $tzid = null)
1778 1777
 	{
1779 1778
 		$foundInfoLogs = array();
1780 1779
 		$filter = array();
@@ -1782,7 +1781,7 @@  discard block
 block discarded – undo
1782 1781
 		if ($this->log)
1783 1782
 		{
1784 1783
 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
1785
-				. '('. ($relax ? 'RELAX, ': 'EXACT, ') . $tzid . ')[InfoData]:'
1784
+				. '('.($relax ? 'RELAX, ' : 'EXACT, ').$tzid.')[InfoData]:'
1786 1785
 				. array2string($infoData));
1787 1786
 		}
1788 1787
 
@@ -1801,9 +1800,9 @@  discard block
 block discarded – undo
1801 1800
 		if (!$relax && !empty($infoData['info_uid']))
1802 1801
 		{
1803 1802
 			$filter = array('col_filter' => array('info_uid' => $infoData['info_uid']));
1804
-			foreach($this->so->search($filter) as $egwData)
1803
+			foreach ($this->so->search($filter) as $egwData)
1805 1804
 			{
1806
-				if (!$this->check_access($egwData,Acl::READ)) continue;
1805
+				if (!$this->check_access($egwData, Acl::READ)) continue;
1807 1806
 				$foundInfoLogs[$egwData['info_id']] = $egwData['info_id'];
1808 1807
 			}
1809 1808
 			return $foundInfoLogs;
@@ -1831,7 +1830,7 @@  discard block
 block discarded – undo
1831 1830
 				$text = '';
1832 1831
 				foreach ($matches as $chunk)
1833 1832
 				{
1834
-					if (strlen($text) <  strlen($chunk[0]))
1833
+					if (strlen($text) < strlen($chunk[0]))
1835 1834
 					{
1836 1835
 						$text = $chunk[0];
1837 1836
 					}
@@ -1855,7 +1854,7 @@  discard block
 block discarded – undo
1855 1854
 
1856 1855
 		foreach ($this->so->search($filter) as $itemID => $egwData)
1857 1856
 		{
1858
-			if (!$this->check_access($egwData,Acl::READ)) continue;
1857
+			if (!$this->check_access($egwData, Acl::READ)) continue;
1859 1858
 
1860 1859
 			switch ($infoData['info_type'])
1861 1860
 			{
@@ -1872,7 +1871,7 @@  discard block
 block discarded – undo
1872 1871
 						{
1873 1872
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
1874 1873
 								. '()[location mismatch]: '
1875
-								. $infoData['info_location'] . ' <> ' . $egwData['info_location']);
1874
+								. $infoData['info_location'].' <> '.$egwData['info_location']);
1876 1875
 						}
1877 1876
 						continue;
1878 1877
 					}
@@ -1889,7 +1888,7 @@  discard block
 block discarded – undo
1889 1888
 						{
1890 1889
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
1891 1890
 								. '()[description mismatch]: '
1892
-								. $infoData['info_des'] . ' <> ' . $egwData['info_des']);
1891
+								. $infoData['info_des'].' <> '.$egwData['info_des']);
1893 1892
 						}
1894 1893
 						continue;
1895 1894
 					}
@@ -1903,7 +1902,7 @@  discard block
 block discarded – undo
1903 1902
 			if ($this->log)
1904 1903
 			{
1905 1904
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
1906
-					. '()[FOUND]:' . array2string($foundInfoLogs));
1905
+					. '()[FOUND]:'.array2string($foundInfoLogs));
1907 1906
 			}
1908 1907
 			return $foundInfoLogs;
1909 1908
 		}
@@ -1928,7 +1927,7 @@  discard block
 block discarded – undo
1928 1927
 		//	__FILE__, __LINE__, PEAR_LOG_DEBUG);
1929 1928
 		foreach ($this->so->search($filter) as $itemID => $egwData)
1930 1929
 		{
1931
-			if (!$this->check_access($egwData,Acl::READ)) continue;
1930
+			if (!$this->check_access($egwData, Acl::READ)) continue;
1932 1931
 			// Horde::logMessage("findVTODO Trying\n"
1933 1932
 			//	. print_r($egwData, true),
1934 1933
 			//	__FILE__, __LINE__, PEAR_LOG_DEBUG);
@@ -1940,7 +1939,7 @@  discard block
 block discarded – undo
1940 1939
 				{
1941 1940
 					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
1942 1941
 						. '()[category mismatch]: '
1943
-						. $infoData['info_cat'] . ' <> ' . $egwData['info_cat']);
1942
+						. $infoData['info_cat'].' <> '.$egwData['info_cat']);
1944 1943
 				}
1945 1944
 				continue;
1946 1945
 			}
@@ -1950,15 +1949,15 @@  discard block
 block discarded – undo
1950 1949
 				if (isset($egwData['info_startdate']) && $egwData['info_startdate'])
1951 1950
 				{
1952 1951
 					// We compare the date only
1953
-					$taskTime = new Api\DateTime($infoData['info_startdate'],Api\DateTime::$server_timezone);
1954
-					$egwTime = new Api\DateTime($egwData['info_startdate'],Api\DateTime::$server_timezone);
1952
+					$taskTime = new Api\DateTime($infoData['info_startdate'], Api\DateTime::$server_timezone);
1953
+					$egwTime = new Api\DateTime($egwData['info_startdate'], Api\DateTime::$server_timezone);
1955 1954
 					if ($taskTime->format('Ymd') != $egwTime->format('Ymd'))
1956 1955
 					{
1957 1956
 						if ($this->log)
1958 1957
 						{
1959 1958
 							error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
1960 1959
 								. '()[start mismatch]: '
1961
-								. $taskTime->format('Ymd') . ' <> ' . $egwTime->format('Ymd'));
1960
+								. $taskTime->format('Ymd').' <> '.$egwTime->format('Ymd'));
1962 1961
 						}
1963 1962
 						continue;
1964 1963
 					}
@@ -1985,7 +1984,7 @@  discard block
 block discarded – undo
1985 1984
 					{
1986 1985
 						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
1987 1986
 							. '()[status mismatch]: '
1988
-							. $infoData['info_status'] . ' <> ' . $egwData['info_status']);
1987
+							. $infoData['info_status'].' <> '.$egwData['info_status']);
1989 1988
 					}
1990 1989
 					continue;
1991 1990
 				}
@@ -1995,15 +1994,15 @@  discard block
 block discarded – undo
1995 1994
 					if (isset($egwData['info_enddate']) && $egwData['info_enddate'])
1996 1995
 					{
1997 1996
 						// We compare the date only
1998
-						$taskTime = new Api\DateTime($infoData['info_enddate'],Api\DateTime::$server_timezone);
1999
-						$egwTime = new Api\DateTime($egwData['info_enddate'],Api\DateTime::$server_timezone);
1997
+						$taskTime = new Api\DateTime($infoData['info_enddate'], Api\DateTime::$server_timezone);
1998
+						$egwTime = new Api\DateTime($egwData['info_enddate'], Api\DateTime::$server_timezone);
2000 1999
 						if ($taskTime->format('Ymd') != $egwTime->format('Ymd'))
2001 2000
 						{
2002 2001
 							if ($this->log)
2003 2002
 							{
2004 2003
 								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
2005 2004
 									. '()[DUE mismatch]: '
2006
-									. $taskTime->format('Ymd') . ' <> ' . $egwTime->format('Ymd'));
2005
+									. $taskTime->format('Ymd').' <> '.$egwTime->format('Ymd'));
2007 2006
 							}
2008 2007
 							continue;
2009 2008
 						}
@@ -2024,15 +2023,15 @@  discard block
 block discarded – undo
2024 2023
 					if (isset($egwData['info_datecompleted']) && $egwData['info_datecompleted'])
2025 2024
 					{
2026 2025
 						// We compare the date only
2027
-						$taskTime = new Api\DateTime($infoData['info_datecompleted'],Api\DateTime::$server_timezone);
2028
-						$egwTime = new Api\DateTime($egwData['info_datecompleted'],Api\DateTime::$server_timezone);
2026
+						$taskTime = new Api\DateTime($infoData['info_datecompleted'], Api\DateTime::$server_timezone);
2027
+						$egwTime = new Api\DateTime($egwData['info_datecompleted'], Api\DateTime::$server_timezone);
2029 2028
 						if ($taskTime->format('Ymd') != $egwTime->format('Ymd'))
2030 2029
 						{
2031 2030
 							if ($this->log)
2032 2031
 							{
2033 2032
 								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
2034 2033
 									. '()[completed mismatch]: '
2035
-									. $taskTime->format('Ymd') . ' <> ' . $egwTime->format('Ymd'));
2034
+									. $taskTime->format('Ymd').' <> '.$egwTime->format('Ymd'));
2036 2035
 							}
2037 2036
 							continue;
2038 2037
 						}
@@ -2062,7 +2061,7 @@  discard block
 block discarded – undo
2062 2061
 		if ($this->log)
2063 2062
 		{
2064 2063
 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__
2065
-				. '()[FOUND]:' . array2string($foundInfoLogs));
2064
+				. '()[FOUND]:'.array2string($foundInfoLogs));
2066 2065
 		}
2067 2066
 		return $foundInfoLogs;
2068 2067
 	}
Please login to merge, or discard this patch.
Braces   +203 added lines, -56 removed lines patch added patch discarded remove patch
@@ -232,7 +232,10 @@  discard block
 block discarded – undo
232 232
 				$this->enums['type'] += $config_data['types'];
233 233
 				//echo "types:<pre>"; print_r($this->enums['type']); echo "</pre>\n";
234 234
 			}
235
-			if ($config_data['group_owners']) $this->group_owners = $config_data['group_owners'];
235
+			if ($config_data['group_owners'])
236
+			{
237
+				$this->group_owners = $config_data['group_owners'];
238
+			}
236 239
 
237 240
 			$this->customfields = Api\Storage\Customfields::get('infolog');
238 241
 			if ($this->customfields)
@@ -242,17 +245,35 @@  discard block
 block discarded – undo
242 245
 					// old infolog customefield record
243 246
 					if(empty($field['type']))
244 247
 					{
245
-						if (count($field['values'])) $field['type'] = 'select'; // selectbox
246
-						elseif ($field['rows'] > 1) $field['type'] = 'textarea'; // textarea
247
-						elseif (intval($field['len']) > 0) $field['type'] = 'text'; // regular input field
248
-						else $field['type'] = 'label'; // header-row
248
+						if (count($field['values']))
249
+						{
250
+							$field['type'] = 'select';
251
+						}
252
+						// selectbox
253
+						elseif ($field['rows'] > 1)
254
+						{
255
+							$field['type'] = 'textarea';
256
+						}
257
+						// textarea
258
+						elseif (intval($field['len']) > 0)
259
+						{
260
+							$field['type'] = 'text';
261
+						}
262
+						// regular input field
263
+						else {
264
+							$field['type'] = 'label';
265
+						}
266
+						// header-row
249 267
 						$field['type2'] = $field['typ'];
250 268
 						unset($field['typ']);
251 269
 						$this->customfields[$name] = $field;
252 270
 						$save_config = true;
253 271
 					}
254 272
 				}
255
-				if ($save_config) Api\Config::save_value('customfields',$this->customfields,'infolog');
273
+				if ($save_config)
274
+				{
275
+					Api\Config::save_value('customfields',$this->customfields,'infolog');
276
+				}
256 277
 			}
257 278
 			if (is_array($config_data['responsible_edit']))
258 279
 			{
@@ -279,7 +300,10 @@  discard block
 block discarded – undo
279 300
 		// sort types by there translation
280 301
 		foreach($this->enums['type'] as $key => $val)
281 302
 		{
282
-			if (($val = lang($key)) != $key.'*') $this->enums['type'][$key] = lang($key);
303
+			if (($val = lang($key)) != $key.'*')
304
+			{
305
+				$this->enums['type'][$key] = lang($key);
306
+			}
283 307
 		}
284 308
 		natcasesort($this->enums['type']);
285 309
 
@@ -334,11 +358,18 @@  discard block
 block discarded – undo
334 358
 
335 359
 		$info_id = is_array($info) ? $info['info_id'] : $info;
336 360
 
337
-		if (!$user) $user = $this->user;
361
+		if (!$user)
362
+		{
363
+			$user = $this->user;
364
+		}
338 365
 		if ($user == $this->user)
339 366
 		{
340 367
 			$grants = $this->grants;
341
-			if ($info_id) $access =& $cache[$info_id][$required_rights];	// we only cache the current user!
368
+			if ($info_id)
369
+			{
370
+				$access =& $cache[$info_id][$required_rights];
371
+			}
372
+			// we only cache the current user!
342 373
 		}
343 374
 		else
344 375
 		{
@@ -357,16 +388,22 @@  discard block
 block discarded – undo
357 388
 			// handle delete for the various history modes
358 389
 			if ($this->history)
359 390
 			{
360
-				if (!is_array($info) && !($info = $this->so->read(array('info_id' => $info_id)))) return false;
391
+				if (!is_array($info) && !($info = $this->so->read(array('info_id' => $info_id))))
392
+				{
393
+					return false;
394
+				}
361 395
 
362 396
 				if ($info['info_status'] == 'deleted' &&
363 397
 					($required_rights == Acl::EDIT ||		// no edit rights for deleted entries
364 398
 					 $required_rights == Acl::ADD  ||		// no add rights for deleted entries
365 399
 					 $required_rights == Acl::DELETE && ($this->history == 'history_no_delete' || // no delete at all!
366
-					 $this->history == 'history_admin_delete' && (!isset($GLOBALS['egw_info']['user']['apps']['admin']) || $user!=$this->user))))	// delete only for admins
400
+					 $this->history == 'history_admin_delete' && (!isset($GLOBALS['egw_info']['user']['apps']['admin']) || $user!=$this->user))))
401
+				{
402
+					// delete only for admins
367 403
 				{
368 404
 					$access = false;
369 405
 				}
406
+				}
370 407
 				elseif ($required_rights == self::ACL_UNDELETE)
371 408
 				{
372 409
 					if ($info['info_status'] != 'deleted')
@@ -427,11 +464,14 @@  discard block
 block discarded – undo
427 464
 
428 465
 		if ($info['info_link_id'] > 0 &&
429 466
 			(isset($info['links']) && ($link = $info['links'][$info['info_link_id']]) ||	// use supplied links info
430
-			 ($link = Link::get_link($info['info_link_id'])) !== False))	// if link not found in supplied links, we always search!
467
+			 ($link = Link::get_link($info['info_link_id'])) !== False))
468
+		{
469
+			// if link not found in supplied links, we always search!
431 470
 		{
432 471
 			if (isset($info['links']) && isset($link['app']))
433 472
 			{
434 473
 				$app = $link['app'];
474
+		}
435 475
 				$id  = $link['id'];
436 476
 			}
437 477
 			else
@@ -442,10 +482,13 @@  discard block
 block discarded – undo
442 482
 			}
443 483
 			$title = Link::title($app,$id);
444 484
 
445
-			if ((string)$info['info_custom_from'] === '')	// old entry
485
+			if ((string)$info['info_custom_from'] === '')
486
+			{
487
+				// old entry
446 488
 			{
447 489
 				$info['info_custom_from'] = (int) ($title != $info['info_from'] && @htmlentities($title) != $info['info_from']);
448 490
 			}
491
+			}
449 492
 			if (!$info['info_custom_from'])
450 493
 			{
451 494
 				$info['info_from'] = '';
@@ -495,12 +538,15 @@  discard block
 block discarded – undo
495 538
 	 function time2time(&$values, $fromTZId=false, $toTZId=null)
496 539
 	 {
497 540
 
498
-		if ($fromTZId === $toTZId) return;
541
+		if ($fromTZId === $toTZId)
542
+		{
543
+			return;
544
+		}
499 545
 
500 546
 		$tz = Api\DateTime::$server_timezone;
501 547
 
502 548
 	 	if ($fromTZId)
503
-		{
549
+	 	{
504 550
 			if (!isset(self::$tz_cache[$fromTZId]))
505 551
 			{
506 552
 				self::$tz_cache[$fromTZId] = calendar_timezones::DateTimeZone($fromTZId);
@@ -534,7 +580,7 @@  discard block
 block discarded – undo
534 580
 		}
535 581
 		//error_log(__METHOD__.'(values[info_enddate]='.date('Y-m-d H:i:s',$values['info_enddate']).", from=".array2string($fromTZId).", to=".array2string($toTZId).") tz=".$tz->getName().', fromTZ='.$fromTZ->getName().', toTZ='.$toTZ->getName().', userTZ='.Api\DateTime::$user_timezone->getName());
536 582
 	 	foreach($this->timestamps as $key)
537
-		{
583
+	 	{
538 584
 		 	if ($values[$key])
539 585
 		 	{
540 586
 			 	$time = new Api\DateTime($values[$key], $tz);
@@ -564,7 +610,10 @@  discard block
 block discarded – undo
564 610
 	 */
565 611
 	function date2usertime($ts,$date_format='ts')
566 612
 	{
567
-		if (empty($ts) || $date_format == 'server') return $ts;
613
+		if (empty($ts) || $date_format == 'server')
614
+		{
615
+			return $ts;
616
+		}
568 617
 
569 618
 		return Api\DateTime::server2user($ts,$date_format);
570 619
 	}
@@ -601,16 +650,22 @@  discard block
 block discarded – undo
601 650
 			return null;
602 651
 		}
603 652
 
604
-		if (!$ignore_acl && !$this->check_access($data,Acl::READ))	// check behind read, to prevent a double read
653
+		if (!$ignore_acl && !$this->check_access($data,Acl::READ))
654
+		{
655
+			// check behind read, to prevent a double read
605 656
 		{
606 657
 			return False;
607 658
 		}
659
+		}
608 660
 
609 661
 		if ($data['info_subject'] == $this->subject_from_des($data['info_des']))
610 662
 		{
611 663
 			$data['info_subject'] = '';
612 664
 		}
613
-		if ($run_link_id2from) $this->link_id2from($data);
665
+		if ($run_link_id2from)
666
+		{
667
+			$this->link_id2from($data);
668
+		}
614 669
 
615 670
 		// convert server- to user-time
616 671
 		if ($date_format == 'ts')
@@ -673,7 +728,11 @@  discard block
 block discarded – undo
673 728
 		// if we have history switched on and not an already deleted item --> set only status deleted
674 729
 		if ($this->history && $info['info_status'] != 'deleted')
675 730
 		{
676
-			if ($info['info_status'] == 'deleted') return false;	// entry already deleted
731
+			if ($info['info_status'] == 'deleted')
732
+			{
733
+				return false;
734
+			}
735
+			// entry already deleted
677 736
 
678 737
 			$this->so->write($deleted);
679 738
 
@@ -685,7 +744,9 @@  discard block
 block discarded – undo
685 744
 
686 745
 			Link::unlink(0,'infolog',$info_id);
687 746
 		}
688
-		if ($info['info_status'] != 'deleted')	// dont notify of final purge of already deleted items
747
+		if ($info['info_status'] != 'deleted')
748
+		{
749
+			// dont notify of final purge of already deleted items
689 750
 		{
690 751
 			// send email notifications and do the history logging
691 752
 			if(!$skip_notification)
@@ -693,6 +754,7 @@  discard block
 block discarded – undo
693 754
 				if (!is_object($this->tracking))
694 755
 				{
695 756
 					$this->tracking = new infolog_tracking($this);
757
+		}
696 758
 				}
697 759
 				$this->tracking->track($deleted,$info,$this->user,true);
698 760
 			}
@@ -741,10 +803,13 @@  discard block
 block discarded – undo
741 803
 			{
742 804
 				$responsible = $values['info_responsible'];
743 805
 			}
744
-			if (!($status_only = in_array($this->user, (array)$responsible)))	// responsible has implicit right to change status
806
+			if (!($status_only = in_array($this->user, (array)$responsible)))
807
+			{
808
+				// responsible has implicit right to change status
745 809
 			{
746 810
 				$status_only = !!array_intersect((array)$responsible,array_keys($GLOBALS['egw']->accounts->memberships($this->user)));
747 811
 			}
812
+			}
748 813
 			if (!$status_only && $values['info_status'] != 'deleted')
749 814
 			{
750 815
 				$status_only = $undelete = $this->check_access($values['info_id'],self::ACL_UNDELETE);
@@ -764,17 +829,23 @@  discard block
 block discarded – undo
764 829
 				$values['info_status'] = $this->status['defaults'][$values['info_type']];
765 830
 			}
766 831
 		}
767
-		if ($status_only && !$undelete)	// make sure only status gets writen
832
+		if ($status_only && !$undelete)
833
+		{
834
+			// make sure only status gets writen
768 835
 		{
769 836
 			$set_completed = !$values['info_datecompleted'] &&	// set date completed of finished job, only if its not already set
770 837
 				in_array($values['info_status'],array('done','billed','cancelled'));
838
+		}
771 839
 
772 840
 			$values = $old;
773 841
 			// only overwrite explicitly allowed fields
774 842
 			$values['info_datemodified'] = $values_in['info_datemodified'];
775 843
 			foreach ($this->responsible_edit as $name)
776 844
 			{
777
-				if (isset($values_in[$name])) $values[$name] = $values_in[$name];
845
+				if (isset($values_in[$name]))
846
+				{
847
+					$values[$name] = $values_in[$name];
848
+				}
778 849
 			}
779 850
 			if ($set_completed)
780 851
 			{
@@ -782,21 +853,30 @@  discard block
 block discarded – undo
782 853
 				$values['info_percent'] = 100;
783 854
 				$forcestatus = true;
784 855
 				$status = 'done';
785
-				if (isset($values['info_type']) && !in_array($values['info_status'],array('done','billed','cancelled'))) {
856
+				if (isset($values['info_type']) && !in_array($values['info_status'],array('done','billed','cancelled')))
857
+				{
786 858
 					$forcestatus = false;
787 859
 					//echo "set_completed:"; _debug_array($this->status[$values['info_type']]);
788
-					if (isset($this->status[$values['info_type']]['done'])) {
860
+					if (isset($this->status[$values['info_type']]['done']))
861
+					{
789 862
 						$forcestatus = true;
790 863
 						$status = 'done';
791
-					} elseif (isset($this->status[$values['info_type']]['billed'])) {
864
+					}
865
+					elseif (isset($this->status[$values['info_type']]['billed']))
866
+					{
792 867
 						$forcestatus = true;
793 868
 						$status = 'billed';
794
-					} elseif (isset($this->status[$values['info_type']]['cancelled'])) {
869
+					}
870
+					elseif (isset($this->status[$values['info_type']]['cancelled']))
871
+					{
795 872
 						$forcestatus = true;
796 873
 						$status = 'cancelled';
797 874
 					}
798 875
 				}
799
-				if ($forcestatus && !in_array($values['info_status'],array('done','billed','cancelled'))) $values['info_status'] = $status;
876
+				if ($forcestatus && !in_array($values['info_status'],array('done','billed','cancelled')))
877
+				{
878
+					$values['info_status'] = $status;
879
+				}
800 880
 			}
801 881
 			$check_defaults = false;
802 882
 		}
@@ -828,14 +908,22 @@  discard block
 block discarded – undo
828 908
 				//echo "check_defaults:"; _debug_array($this->status[$values['info_type']]);
829 909
 				//$values['info_status'] = 'done';
830 910
 				$status = 'done';
831
-				if (isset($values['info_type'])) {
832
-					if (isset($this->status[$values['info_type']]['done'])) {
911
+				if (isset($values['info_type']))
912
+				{
913
+					if (isset($this->status[$values['info_type']]['done']))
914
+					{
833 915
 						$status = 'done';
834
-					} elseif (isset($this->status[$values['info_type']]['billed'])) {
916
+					}
917
+					elseif (isset($this->status[$values['info_type']]['billed']))
918
+					{
835 919
 						$status = 'billed';
836
-					} elseif (isset($this->status[$values['info_type']]['cancelled'])) {
920
+					}
921
+					elseif (isset($this->status[$values['info_type']]['cancelled']))
922
+					{
837 923
 						$status = 'cancelled';
838
-					} else {
924
+					}
925
+					else
926
+					{
839 927
 						// since the comlete stati above do not exist for that type, dont change it
840 928
 						$status = $values['info_status'];
841 929
 					}
@@ -857,7 +945,10 @@  discard block
 block discarded – undo
857 945
 				$custom = Api\Storage\Customfields::get('infolog');
858 946
 				foreach($custom as $c_name => $c_field)
859 947
 				{
860
-					if($c_field['type2']) $type2 = is_array($c_field['type2']) ? $c_field['type2'] : explode(',',$c_field['type2']);
948
+					if($c_field['type2'])
949
+					{
950
+						$type2 = is_array($c_field['type2']) ? $c_field['type2'] : explode(',',$c_field['type2']);
951
+					}
861 952
 					if($c_field['needed'] && (!$c_field['type2'] || $c_field['type2'] && in_array($values['info_type'],$type2)))
862 953
 					{
863 954
 						// Required custom field
@@ -876,8 +967,7 @@  discard block
 block discarded – undo
876 967
 			{
877 968
 				if (!$this->check_access($values['info_id'],Acl::EDIT) ||
878 969
 					!$values['info_id'] && !$this->check_access($values,Acl::ADD)
879
-				)
880
-				{
970
+				) {
881 971
 					return false;	// no edit rights from the group-owner and no implicit rights (delegated and sufficient rights)
882 972
 				}
883 973
 			}
@@ -941,10 +1031,16 @@  discard block
 block discarded – undo
941 1031
 			$to_write['info_id'] = $info_id;
942 1032
 
943 1033
 			// if the info responbsible array is not passed, fetch it from old.
944
-			if (!array_key_exists('info_responsible',$values)) $values['info_responsible'] = $old['info_responsible'];
945
-			if (!is_array($values['info_responsible']))		// this should not happen, bug it does ;-)
1034
+			if (!array_key_exists('info_responsible',$values))
1035
+			{
1036
+				$values['info_responsible'] = $old['info_responsible'];
1037
+			}
1038
+			if (!is_array($values['info_responsible']))
1039
+			{
1040
+				// this should not happen, bug it does ;-)
946 1041
 			{
947 1042
 				$values['info_responsible'] = $values['info_responsible'] ? explode(',',$values['info_responsible']) : array();
1043
+			}
948 1044
 				$to_write['info_responsible'] = $values['info_responsible'];
949 1045
 			}
950 1046
 			// create (and remove) links in custom fields
@@ -989,7 +1085,10 @@  discard block
 block discarded – undo
989 1085
 			$this->tracking->track($to_write,$old,$this->user,$values['info_status'] == 'deleted' || $old['info_status'] == 'deleted',
990 1086
 				null,$skip_notification);
991 1087
 
992
-			if ($info_from_set) $values['info_from'] = '';
1088
+			if ($info_from_set)
1089
+			{
1090
+				$values['info_from'] = '';
1091
+			}
993 1092
 
994 1093
 			// Change new values back to user time before sending them back
995 1094
 			if($user2server)
@@ -1039,13 +1138,25 @@  discard block
 block discarded – undo
1039 1138
 
1040 1139
 		if($query['filter'] == 'bydate')
1041 1140
 		{
1042
-			if (is_int($query['startdate'])) $query['col_filter'][] = 'info_startdate >= '.$GLOBALS['egw']->db->quote($query['startdate']);
1043
-			if (is_int($query['enddate'])) $query['col_filter'][] = 'info_startdate <= '.$GLOBALS['egw']->db->quote($query['enddate']+(60*60*24)-1);
1141
+			if (is_int($query['startdate']))
1142
+			{
1143
+				$query['col_filter'][] = 'info_startdate >= '.$GLOBALS['egw']->db->quote($query['startdate']);
1144
+			}
1145
+			if (is_int($query['enddate']))
1146
+			{
1147
+				$query['col_filter'][] = 'info_startdate <= '.$GLOBALS['egw']->db->quote($query['enddate']+(60*60*24)-1);
1148
+			}
1044 1149
 		}
1045 1150
 		elseif ($query['filter'] == 'duedate')
1046 1151
 		{
1047
-			if (is_int($query['startdate'])) $query['col_filter'][] = 'info_enddate >= '.$GLOBALS['egw']->db->quote($query['startdate']);
1048
-			if (is_int($query['enddate'])) $query['col_filter'][] = 'info_enddate <= '.$GLOBALS['egw']->db->quote($query['enddate']+(60*60*24)-1);
1152
+			if (is_int($query['startdate']))
1153
+			{
1154
+				$query['col_filter'][] = 'info_enddate >= '.$GLOBALS['egw']->db->quote($query['startdate']);
1155
+			}
1156
+			if (is_int($query['enddate']))
1157
+			{
1158
+				$query['col_filter'][] = 'info_enddate <= '.$GLOBALS['egw']->db->quote($query['enddate']+(60*60*24)-1);
1159
+			}
1049 1160
 		}
1050 1161
 		elseif ($query['filter'] == 'private')
1051 1162
 		{
@@ -1127,7 +1238,10 @@  discard block
 block discarded – undo
1127 1238
 
1128 1239
 		$result =& $this->search($filter);
1129 1240
 
1130
-		if (empty($result)) return 'EGw-empty-wGE';
1241
+		if (empty($result))
1242
+		{
1243
+			return 'EGw-empty-wGE';
1244
+		}
1131 1245
 
1132 1246
 		$entry = array_shift($result);
1133 1247
 
@@ -1174,7 +1288,10 @@  discard block
 block discarded – undo
1174 1288
 				'to_id' => 0,
1175 1289
 			),
1176 1290
 		);
1177
-		if ($GLOBALS['egw_info']['user']['preferences']['infolog']['cat_add_default']) $info['info_cat'] = $GLOBALS['egw_info']['user']['preferences']['infolog']['cat_add_default'];
1291
+		if ($GLOBALS['egw_info']['user']['preferences']['infolog']['cat_add_default'])
1292
+		{
1293
+			$info['info_cat'] = $GLOBALS['egw_info']['user']['preferences']['infolog']['cat_add_default'];
1294
+		}
1178 1295
 		// find the addressbookentry to link with
1179 1296
 		$addressbook = new Api\Contacts();
1180 1297
 		$contacts = array();
@@ -1432,7 +1549,10 @@  discard block
 block discarded – undo
1432 1549
 			}
1433 1550
 			foreach($this->anzSubs(array_keys($infos)) as $info_id => $subs)
1434 1551
 			{
1435
-				if ($subs) $infos[$info_id]['class'] .= ' infolog_rowHasSubs';
1552
+				if ($subs)
1553
+				{
1554
+					$infos[$info_id]['class'] .= ' infolog_rowHasSubs';
1555
+				}
1436 1556
 			}
1437 1557
 		}
1438 1558
 		return $infos;
@@ -1558,7 +1678,10 @@  discard block
 block discarded – undo
1558 1678
 		$save_prefs      = $GLOBALS['egw_info']['user']['preferences'];
1559 1679
 		foreach($users as $user)
1560 1680
 		{
1561
-			if (!($email = $GLOBALS['egw']->accounts->id2name($user,'account_email'))) continue;
1681
+			if (!($email = $GLOBALS['egw']->accounts->id2name($user,'account_email')))
1682
+			{
1683
+				continue;
1684
+			}
1562 1685
 			// create the enviroment for $user
1563 1686
 			$this->user = $GLOBALS['egw_info']['user']['account_id'] = $user;
1564 1687
 			$GLOBALS['egw']->preferences->__construct($user);
@@ -1576,7 +1699,10 @@  discard block
 block discarded – undo
1576 1699
 				'notify_start_delegated'   => 'open-delegated-date',
1577 1700
 			) as $pref => $filter)
1578 1701
 			{
1579
-				if (!($pref_value = $GLOBALS['egw_info']['user']['preferences']['infolog'][$pref])) continue;
1702
+				if (!($pref_value = $GLOBALS['egw_info']['user']['preferences']['infolog'][$pref]))
1703
+				{
1704
+					continue;
1705
+				}
1580 1706
 
1581 1707
 				$filter .= date('Y-m-d',time()+24*60*60*(int)$pref_value);
1582 1708
 				//error_log(__METHOD__."() checking with filter '$filter' ($pref_value) for user $user ($email)");
@@ -1585,7 +1711,10 @@  discard block
 block discarded – undo
1585 1711
 				foreach($this->so->search($params) as $info)
1586 1712
 				{
1587 1713
 					// check if we already send a notification for that infolog entry, eg. starting and due on same day
1588
-					if (in_array($info['info_id'],$notified_info_ids)) continue;
1714
+					if (in_array($info['info_id'],$notified_info_ids))
1715
+					{
1716
+						continue;
1717
+					}
1589 1718
 
1590 1719
 					if (is_null($this->tracking) || $this->tracking->user != $user)
1591 1720
 					{
@@ -1714,11 +1843,17 @@  discard block
 block discarded – undo
1714 1843
 			$statis = $icons = array();
1715 1844
 			foreach($this->status as $t => $stati)
1716 1845
 			{
1717
-				if ($t === 'defaults') continue;
1846
+				if ($t === 'defaults')
1847
+				{
1848
+					continue;
1849
+				}
1718 1850
 				foreach($stati as $val => $label)
1719 1851
 				{
1720 1852
 					$statis[$val][$label] = lang($label);
1721
-					if (!isset($icons[$val])) $icons[$val] = $label;
1853
+					if (!isset($icons[$val]))
1854
+					{
1855
+						$icons[$val] = $label;
1856
+					}
1722 1857
 				}
1723 1858
 			}
1724 1859
 			foreach($statis as $val => &$labels)
@@ -1794,7 +1929,10 @@  discard block
 block discarded – undo
1794 1929
 			{
1795 1930
 				return array($egwData['info_id']);
1796 1931
 			}
1797
-			if (!$relax) return array();
1932
+			if (!$relax)
1933
+			{
1934
+				return array();
1935
+			}
1798 1936
 		}
1799 1937
 		unset($infoData['info_id']);
1800 1938
 
@@ -1803,7 +1941,10 @@  discard block
 block discarded – undo
1803 1941
 			$filter = array('col_filter' => array('info_uid' => $infoData['info_uid']));
1804 1942
 			foreach($this->so->search($filter) as $egwData)
1805 1943
 			{
1806
-				if (!$this->check_access($egwData,Acl::READ)) continue;
1944
+				if (!$this->check_access($egwData,Acl::READ))
1945
+				{
1946
+					continue;
1947
+				}
1807 1948
 				$foundInfoLogs[$egwData['info_id']] = $egwData['info_id'];
1808 1949
 			}
1809 1950
 			return $foundInfoLogs;
@@ -1855,7 +1996,10 @@  discard block
 block discarded – undo
1855 1996
 
1856 1997
 		foreach ($this->so->search($filter) as $itemID => $egwData)
1857 1998
 		{
1858
-			if (!$this->check_access($egwData,Acl::READ)) continue;
1999
+			if (!$this->check_access($egwData,Acl::READ))
2000
+			{
2001
+				continue;
2002
+			}
1859 2003
 
1860 2004
 			switch ($infoData['info_type'])
1861 2005
 			{
@@ -1928,7 +2072,10 @@  discard block
 block discarded – undo
1928 2072
 		//	__FILE__, __LINE__, PEAR_LOG_DEBUG);
1929 2073
 		foreach ($this->so->search($filter) as $itemID => $egwData)
1930 2074
 		{
1931
-			if (!$this->check_access($egwData,Acl::READ)) continue;
2075
+			if (!$this->check_access($egwData,Acl::READ))
2076
+			{
2077
+				continue;
2078
+			}
1932 2079
 			// Horde::logMessage("findVTODO Trying\n"
1933 2080
 			//	. print_r($egwData, true),
1934 2081
 			//	__FILE__, __LINE__, PEAR_LOG_DEBUG);
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1272,7 +1272,7 @@
 block discarded – undo
1272 1272
 	 * @param array $options Array of options for the search
1273 1273
 	 * @return array with info_id - title pairs of the matching entries
1274 1274
 	 */
1275
-	function link_query($pattern, Array &$options = array())
1275
+	function link_query($pattern, array &$options = array())
1276 1276
 	{
1277 1277
 		$query = array(
1278 1278
 			'search' => $pattern,
Please login to merge, or discard this patch.
infolog/inc/class.infolog_groupdav.inc.php 3 patches
Doc Comments   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 	 * @param array &$options
142 142
 	 * @param array &$files
143 143
 	 * @param int $user account_id
144
-	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
144
+	 * @return boolean boolean true on success, false on failure or string with http status (eg. '404 Not Found')
145 145
 	 */
146 146
 	function propfind($path,&$options,&$files,$user,$id='')
147 147
 	{
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 	 *
222 222
 	 * @param string $path
223 223
 	 * @param array $filter
224
-	 * @param array|boolean $start =false false=return all or array(start,num)
224
+	 * @param integer[] $start =false false=return all or array(start,num)
225 225
 	 * @return array with "files" array with values for keys path and props
226 226
 	 */
227 227
 	function &propfind_callback($path,array $filter,$start=false)
@@ -521,7 +521,7 @@  discard block
 block discarded – undo
521 521
 	 * @param array &$options
522 522
 	 * @param int $id
523 523
 	 * @param int $user =null account_id
524
-	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
524
+	 * @return string|boolean boolean true on success, false on failure or string with http status (eg. '404 Not Found')
525 525
 	 */
526 526
 	function get(&$options,$id,$user=null)
527 527
 	{
@@ -546,7 +546,7 @@  discard block
 block discarded – undo
546 546
 	 * @param int $id
547 547
 	 * @param int $user =null account_id of owner, default null
548 548
 	 * @param string $prefix =null user prefix from path (eg. /ralf from /ralf/addressbook)
549
-	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
549
+	 * @return string|boolean boolean true on success, false on failure or string with http status (eg. '404 Not Found')
550 550
 	 */
551 551
 	function put(&$options,$id,$user=null,$prefix=null)
552 552
 	{
@@ -682,7 +682,7 @@  discard block
 block discarded – undo
682 682
 	 *
683 683
 	 * @param array &$options
684 684
 	 * @param int $id
685
-	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
685
+	 * @return string|boolean boolean true on success, false on failure or string with http status (eg. '404 Not Found')
686 686
 	 */
687 687
 	function delete(&$options,$id)
688 688
 	{
@@ -757,7 +757,7 @@  discard block
 block discarded – undo
757 757
 	 * etag currently uses the modifcation time (info_datemodified), 1.9.002 adds etag column, but it's not yet used!
758 758
 	 *
759 759
 	 * @param array|int $info array with infolog entry or info_id
760
-	 * @return string|boolean string with etag or false
760
+	 * @return false|string string with etag or false
761 761
 	 */
762 762
 	function get_etag($info)
763 763
 	{
Please login to merge, or discard this patch.
Spacing   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 		}
113 113
 		if ($path == '/infolog/')
114 114
 		{
115
-			$task_filter= 'own';
115
+			$task_filter = 'own';
116 116
 		}
117 117
 		else
118 118
 		{
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 			}
123 123
 			else
124 124
 			{
125
-				$task_filter = 'user' . $user;
125
+				$task_filter = 'user'.$user;
126 126
 			}
127 127
 		}
128 128
 
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 	 * @param int $user account_id
144 144
 	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
145 145
 	 */
146
-	function propfind($path,&$options,&$files,$user,$id='')
146
+	function propfind($path, &$options, &$files, $user, $id = '')
147 147
 	{
148 148
 		// todo add a filter to limit how far back entries from the past get synced
149 149
 		$filter = $this->get_infolog_filter($path, $user);
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 		// enable time-range filter for tests via propfind / autoindex
160 160
 		//$filter[] = $sql = $this->_time_range_filter(array('end' => '20001231T000000Z'));
161 161
 
162
-		if ($id) $path = dirname($path).'/';	// caldav_name get's added anyway in the callback
162
+		if ($id) $path = dirname($path).'/'; // caldav_name get's added anyway in the callback
163 163
 
164 164
 		if ($this->debug > 1)
165 165
 		{
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 		if (!($filter['calendar_data'] = $options['props'] == 'all' &&
172 172
 			$options['root']['ns'] == Api\CalDAV::CALDAV) && is_array($options['props']))
173 173
 		{
174
-			foreach($options['props'] as $prop)
174
+			foreach ($options['props'] as $prop)
175 175
 			{
176 176
 				if ($prop['name'] == 'calendar-data')
177 177
 				{
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 
192 192
 			$this->sync_collection_token = null;
193 193
 
194
-			$filter['order'] = 'info_datemodified ASC';	// return oldest modifications first
194
+			$filter['order'] = 'info_datemodified ASC'; // return oldest modifications first
195 195
 			$filter['sync-collection'] = true;
196 196
 		}
197 197
 
@@ -205,13 +205,13 @@  discard block
 block discarded – undo
205 205
 			if ($options['root']['name'] == 'sync-collection' && $this->bo->total > $nresults)
206 206
 			{
207 207
 				--$this->sync_collection_token;
208
-				$files['sync-token-params'][] = true;	// tel get_sync_collection_token that we have more entries
208
+				$files['sync-token-params'][] = true; // tel get_sync_collection_token that we have more entries
209 209
 			}
210 210
 		}
211 211
 		else
212 212
 		{
213 213
 			// return iterator, calling ourself to return result in chunks
214
-			$files['files'] = new Api\CalDAV\PropfindIterator($this,$path,$filter,$files['files']);
214
+			$files['files'] = new Api\CalDAV\PropfindIterator($this, $path, $filter, $files['files']);
215 215
 		}
216 216
 		return true;
217 217
 	}
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 	 * @param array|boolean $start =false false=return all or array(start,num)
225 225
 	 * @return array with "files" array with values for keys path and props
226 226
 	 */
227
-	function &propfind_callback($path,array $filter,$start=false)
227
+	function &propfind_callback($path, array $filter, $start = false)
228 228
 	{
229 229
 		if ($this->debug) $starttime = microtime(true);
230 230
 
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 			'filter'    	=> $task_filter,
252 252
 			'date_format'	=> 'server',
253 253
 			'col_filter'	=> $filter,
254
-			'custom_fields' => true,	// otherwise custom fields get NOT loaded!
254
+			'custom_fields' => true, // otherwise custom fields get NOT loaded!
255 255
 		);
256 256
 
257 257
 		if (!$calendar_data)
@@ -273,10 +273,10 @@  discard block
 block discarded – undo
273 273
 
274 274
 		$files = array();
275 275
 		// ToDo: add parameter to only return id & etag
276
-		$tasks =& $this->bo->search($query);
276
+		$tasks = & $this->bo->search($query);
277 277
 		if ($tasks && $offset == $query['start'])
278 278
 		{
279
-			foreach($tasks as $task)
279
+			foreach ($tasks as $task)
280 280
 			{
281 281
 				// remove task from requested multiget ids, to be able to report not found urls
282 282
 				if ($requested_multiget_ids && ($k = array_search($task[self::$path_attr], $requested_multiget_ids)) !== false)
@@ -290,15 +290,15 @@  discard block
 block discarded – undo
290 290
 					continue;
291 291
 				}
292 292
 				$props = array(
293
-					'getcontenttype' => $this->agent != 'kde' ? 'text/calendar; charset=utf-8; component=VTODO' : 'text/calendar',	// Konqueror (3.5) dont understand it otherwise
293
+					'getcontenttype' => $this->agent != 'kde' ? 'text/calendar; charset=utf-8; component=VTODO' : 'text/calendar', // Konqueror (3.5) dont understand it otherwise
294 294
 					'getlastmodified' => $task['info_datemodified'],
295 295
 					'displayname' => $task['info_subject'],
296 296
 				);
297 297
 				if ($calendar_data)
298 298
 				{
299
-					$content = $handler->exportVTODO($task, '2.0', null);	// no METHOD:PUBLISH for CalDAV
299
+					$content = $handler->exportVTODO($task, '2.0', null); // no METHOD:PUBLISH for CalDAV
300 300
 					$props['getcontentlength'] = bytes($content);
301
-					$props[] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-data',$content);
301
+					$props[] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-data', $content);
302 302
 				}
303 303
 				$files[] = $this->add_resource($path, $task, $props);
304 304
 			}
@@ -306,13 +306,13 @@  discard block
 block discarded – undo
306 306
 		// report not found multiget urls
307 307
 		if ($requested_multiget_ids)
308 308
 		{
309
-			foreach($requested_multiget_ids as $id)
309
+			foreach ($requested_multiget_ids as $id)
310 310
 			{
311 311
 				$files[] = array('path' => $path.$id.self::$path_extension);
312 312
 			}
313 313
 		}
314 314
 		// sync-collection report --> return modified of last contact as sync-token
315
-		$sync_collection_report =  $filter['sync-collection'];
315
+		$sync_collection_report = $filter['sync-collection'];
316 316
 		if ($sync_collection_report)
317 317
 		{
318 318
 			$this->sync_collection_token = $task['date_modified'];
@@ -338,18 +338,18 @@  discard block
 block discarded – undo
338 338
 	 * @param int &$nresult on return limit for number or results or unchanged/null
339 339
 	 * @return boolean true if filter could be processed
340 340
 	 */
341
-	function _report_filters($options,&$cal_filters,$id, &$nresults)
341
+	function _report_filters($options, &$cal_filters, $id, &$nresults)
342 342
 	{
343 343
 		if ($options['filters'])
344 344
 		{
345
-			foreach($options['filters'] as $filter)
345
+			foreach ($options['filters'] as $filter)
346 346
 			{
347
-				switch($filter['name'])
347
+				switch ($filter['name'])
348 348
 				{
349 349
 					case 'comp-filter':
350 350
 						if ($this->debug > 1) error_log(__METHOD__."($options[path],...) comp-filter='{$filter['attrs']['name']}'");
351 351
 
352
-						switch($filter['attrs']['name'])
352
+						switch ($filter['attrs']['name'])
353 353
 						{
354 354
 							case 'VTODO':
355 355
 							case 'VCALENDAR':
@@ -392,9 +392,9 @@  discard block
 block discarded – undo
392 392
 		    <B:nresults>10</B:nresults>
393 393
 		  </B:limit>
394 394
 		*/
395
-		foreach((array)$options['other'] as $option)
395
+		foreach ((array)$options['other'] as $option)
396 396
 		{
397
-			switch($option['name'])
397
+			switch ($option['name'])
398 398
 			{
399 399
 				case 'nresults':
400 400
 					$nresults = (int)$option['data'];
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
 				case 'limit':
404 404
 					break;
405 405
 				case 'href':
406
-					break;	// from addressbook-multiget, handled below
406
+					break; // from addressbook-multiget, handled below
407 407
 				// rfc 6578 sync-report
408 408
 				case 'sync-token':
409 409
 					if (!empty($option['data']))
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
 						$parts = explode('/', $option['data']);
412 412
 						$sync_token = array_pop($parts);
413 413
 						$cal_filters[] = 'info_datemodified>'.(int)$sync_token;
414
-						$cal_filters['filter'] .= '+deleted';	// to return deleted entries too
414
+						$cal_filters['filter'] .= '+deleted'; // to return deleted entries too
415 415
 					}
416 416
 					break;
417 417
 				case 'sync-level':
@@ -433,24 +433,24 @@  discard block
 block discarded – undo
433 433
 			if ($id)
434 434
 			{
435 435
 				$cal_filters[self::$path_attr] = self::$path_extension ?
436
-					basename($id,self::$path_extension) : $id;
436
+					basename($id, self::$path_extension) : $id;
437 437
 			}
438 438
 			else	// fetch all given url's
439 439
 			{
440
-				foreach($options['other'] as $option)
440
+				foreach ($options['other'] as $option)
441 441
 				{
442 442
 					if ($option['name'] == 'href')
443 443
 					{
444
-						$parts = explode('/',$option['data']);
444
+						$parts = explode('/', $option['data']);
445 445
 						if (($id = basename(urldecode(array_pop($parts)))))
446 446
 						{
447 447
 							$cal_filters[self::$path_attr][] = self::$path_extension ?
448
-								basename($id,self::$path_extension) : $id;
448
+								basename($id, self::$path_extension) : $id;
449 449
 						}
450 450
 					}
451 451
 				}
452 452
 			}
453
-			if ($this->debug > 1) error_log(__METHOD__ ."($options[path],...,$id) calendar-multiget: ids=".implode(',',$ids));
453
+			if ($this->debug > 1) error_log(__METHOD__."($options[path],...,$id) calendar-multiget: ids=".implode(',', $ids));
454 454
 		}
455 455
 		return true;
456 456
 	}
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
 		elseif (empty($attrs['start']))
479 479
 		{
480 480
 			$this->caldav->log(__METHOD__.'('.array2string($attrs).') minimum one of start or end is required!');
481
-			return '1';	// to not give sql error, but simply not filter out anything
481
+			return '1'; // to not give sql error, but simply not filter out anything
482 482
 		}
483 483
 		// we dont need to care for DURATION line in rfc4791#section-9.9, as we always put that in DUE/info_enddate
484 484
 
@@ -508,10 +508,10 @@  discard block
 block discarded – undo
508 508
 			"info_datecompleted > 0".(isset($start) ? " AND ($start <= info_datecompleted OR $start <= info_created)" : '').
509 509
 				(isset($end) ? " AND (info_datecompleted <= $end OR info_created <= $end)" : '').' OR '.
510 510
 			// we have no completed date, but always a created date
511
- 			"NOT info_datecompleted > 0". (isset($end) ? " AND info_created < $end" : '').
511
+ 			"NOT info_datecompleted > 0".(isset($end) ? " AND info_created < $end" : '').
512 512
 		')';
513 513
 		$sql = '('.implode(' OR ', $to_or).')';
514
-		if ($this->debug > 1) error_log(__FILE__ . __METHOD__.'('.array2string($attrs).") time-range=$attrs[start]-$attrs[end] --> $sql");
514
+		if ($this->debug > 1) error_log(__FILE__.__METHOD__.'('.array2string($attrs).") time-range=$attrs[start]-$attrs[end] --> $sql");
515 515
 		return $sql;
516 516
 	}
517 517
 
@@ -523,16 +523,16 @@  discard block
 block discarded – undo
523 523
 	 * @param int $user =null account_id
524 524
 	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
525 525
 	 */
526
-	function get(&$options,$id,$user=null)
526
+	function get(&$options, $id, $user = null)
527 527
 	{
528
-		unset($user);	// not used, but required by function signature
528
+		unset($user); // not used, but required by function signature
529 529
 
530
-		if (!is_array($task = $this->_common_get_put_delete('GET',$options,$id)))
530
+		if (!is_array($task = $this->_common_get_put_delete('GET', $options, $id)))
531 531
 		{
532 532
 			return $task;
533 533
 		}
534 534
 		$handler = $this->_get_handler();
535
-		$options['data'] = $handler->exportVTODO($task, '2.0', null);	// no METHOD:PUBLISH for CalDAV
535
+		$options['data'] = $handler->exportVTODO($task, '2.0', null); // no METHOD:PUBLISH for CalDAV
536 536
 		$options['mimetype'] = 'text/calendar; charset=utf-8';
537 537
 		header('Content-Encoding: identity');
538 538
 		header('ETag: "'.$this->get_etag($task).'"');
@@ -548,13 +548,13 @@  discard block
 block discarded – undo
548 548
 	 * @param string $prefix =null user prefix from path (eg. /ralf from /ralf/addressbook)
549 549
 	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
550 550
 	 */
551
-	function put(&$options,$id,$user=null,$prefix=null)
551
+	function put(&$options, $id, $user = null, $prefix = null)
552 552
 	{
553
-		unset($prefix);	// not used, but required by function signature
553
+		unset($prefix); // not used, but required by function signature
554 554
 
555
-		if ($this->debug) error_log(__METHOD__."($id, $user)".print_r($options,true));
555
+		if ($this->debug) error_log(__METHOD__."($id, $user)".print_r($options, true));
556 556
 
557
-		$oldTask = $this->_common_get_put_delete('PUT',$options,$id);
557
+		$oldTask = $this->_common_get_put_delete('PUT', $options, $id);
558 558
 		if (!is_null($oldTask) && !is_array($oldTask))
559 559
 		{
560 560
 			return $oldTask;
@@ -619,7 +619,7 @@  discard block
 block discarded – undo
619 619
 	 * @param array $oldTask =null
620 620
 	 * @return array modified task data
621 621
 	 */
622
-	public function cat_action(array $task, $oldTask=null)
622
+	public function cat_action(array $task, $oldTask = null)
623 623
 	{
624 624
 		$action = $GLOBALS['egw_info']['user']['preferences']['groupdav']['infolog-cat-action'];
625 625
 
@@ -650,13 +650,13 @@  discard block
 block discarded – undo
650 650
 			{
651 651
 				unset($task['info_responsible'][$key]);
652 652
 			}
653
-			switch($action)
653
+			switch ($action)
654 654
 			{
655 655
 				case 'set':
656 656
 					$task['info_responsible'] = array();
657 657
 					// fall through
658 658
 				case 'set-user':
659
-					foreach($task['info_responsible'] as $key => $account_id)
659
+					foreach ($task['info_responsible'] as $key => $account_id)
660 660
 					{
661 661
 						if ($GLOBALS['egw']->accounts->get_type($account_id) == 'u')
662 662
 						{
@@ -684,9 +684,9 @@  discard block
 block discarded – undo
684 684
 	 * @param int $id
685 685
 	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
686 686
 	 */
687
-	function delete(&$options,$id)
687
+	function delete(&$options, $id)
688 688
 	{
689
-		if (!is_array($task = $this->_common_get_put_delete('DELETE',$options,$id)))
689
+		if (!is_array($task = $this->_common_get_put_delete('DELETE', $options, $id)))
690 690
 		{
691 691
 			return $task;
692 692
 		}
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
 	 */
705 705
 	function read($id)
706 706
 	{
707
-		return $this->bo->read(array(self::$path_attr => $id, "info_status!='deleted'"),false,'server');
707
+		return $this->bo->read(array(self::$path_attr => $id, "info_status!='deleted'"), false, 'server');
708 708
 	}
709 709
 
710 710
 	/**
@@ -727,15 +727,15 @@  discard block
 block discarded – undo
727 727
 	 * @param array|int $task task-array or id
728 728
 	 * @return boolean null if entry does not exist, false if no access, true if access permitted
729 729
 	 */
730
-	function check_access($acl,$task)
730
+	function check_access($acl, $task)
731 731
 	{
732 732
 		if (is_null($task)) return true;
733 733
 
734
-		$access = $this->bo->check_access($task,$acl);
734
+		$access = $this->bo->check_access($task, $acl);
735 735
 
736 736
 		if (!$access && $acl == Acl::EDIT && $this->bo->is_responsible($task))
737 737
 		{
738
-			$access = true;	// access limited to $this->bo->responsible_edit fields (handled in infolog_bo::write())
738
+			$access = true; // access limited to $this->bo->responsible_edit fields (handled in infolog_bo::write())
739 739
 		}
740 740
 		if ($this->debug > 1) error_log(__METHOD__."($acl, ".array2string($task).') returning '.array2string($access));
741 741
 		return $access;
@@ -746,7 +746,7 @@  discard block
 block discarded – undo
746 746
 	 *
747 747
 	 * @return string
748 748
 	 */
749
-	public function getctag($path,$user)
749
+	public function getctag($path, $user)
750 750
 	{
751 751
 		return $this->bo->getctag($this->get_infolog_filter($path, $user));
752 752
 	}
@@ -763,7 +763,7 @@  discard block
 block discarded – undo
763 763
 	{
764 764
 		if (!is_array($info))
765 765
 		{
766
-			$info = $this->bo->read($info,true,'server');
766
+			$info = $this->bo->read($info, true, 'server');
767 767
 		}
768 768
 		if (!is_array($info) || !isset($info['info_id']) || !isset($info['info_datemodified']))
769 769
 		{
@@ -781,39 +781,39 @@  discard block
 block discarded – undo
781 781
 	 * @param int $user =null account_id of owner of collection
782 782
 	 * @return array
783 783
 	 */
784
-	public function extra_properties(array $props, $displayname, $base_uri=null,$user=null)
784
+	public function extra_properties(array $props, $displayname, $base_uri = null, $user = null)
785 785
 	{
786
-		unset($base_uri);	// not used, but required by function signature
786
+		unset($base_uri); // not used, but required by function signature
787 787
 
788 788
 		// calendar description
789
-		$displayname = Api\Translation::convert(lang('Tasks of'),Api\Translation::charset(),'utf-8').' '.$displayname;
790
-		$props['calendar-description'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-description',$displayname);
789
+		$displayname = Api\Translation::convert(lang('Tasks of'), Api\Translation::charset(), 'utf-8').' '.$displayname;
790
+		$props['calendar-description'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-description', $displayname);
791 791
 		// supported components, currently only VEVENT
792
-		$props['supported-calendar-component-set'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'supported-calendar-component-set',array(
793
-			Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'comp',array('name' => 'VCALENDAR')),
794
-			Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'comp',array('name' => 'VTODO')),
792
+		$props['supported-calendar-component-set'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'supported-calendar-component-set', array(
793
+			Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'comp', array('name' => 'VCALENDAR')),
794
+			Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'comp', array('name' => 'VTODO')),
795 795
 		));
796 796
 		// supported reports
797 797
 		$props['supported-report-set'] = array(
798
-			'calendar-query' => Api\CalDAV::mkprop('supported-report',array(
799
-				Api\CalDAV::mkprop('report',array(
800
-					Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-query',''))))),
801
-			'calendar-multiget' => Api\CalDAV::mkprop('supported-report',array(
802
-				Api\CalDAV::mkprop('report',array(
803
-					Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-multiget',''))))),
798
+			'calendar-query' => Api\CalDAV::mkprop('supported-report', array(
799
+				Api\CalDAV::mkprop('report', array(
800
+					Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-query', ''))))),
801
+			'calendar-multiget' => Api\CalDAV::mkprop('supported-report', array(
802
+				Api\CalDAV::mkprop('report', array(
803
+					Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-multiget', ''))))),
804 804
 		);
805 805
 		// only advertice rfc 6578 sync-collection report, if "delete-prevention" is switched on (deleted entries get marked deleted but not actualy deleted
806 806
 		$config = Api\Config::read('infolog');
807 807
 		if ($config['history'])
808 808
 		{
809
-			$props['supported-report-set']['sync-collection'] = Api\CalDAV::mkprop('supported-report',array(
810
-				Api\CalDAV::mkprop('report',array(
811
-					Api\CalDAV::mkprop('sync-collection','')))));
809
+			$props['supported-report-set']['sync-collection'] = Api\CalDAV::mkprop('supported-report', array(
810
+				Api\CalDAV::mkprop('report', array(
811
+					Api\CalDAV::mkprop('sync-collection', '')))));
812 812
 		}
813 813
 		// get timezone of calendar
814 814
 		if ($this->caldav->prop_requested('calendar-timezone'))
815 815
 		{
816
-			$props['calendar-timezone'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV,'calendar-timezone',
816
+			$props['calendar-timezone'] = Api\CalDAV::mkprop(Api\CalDAV::CALDAV, 'calendar-timezone',
817 817
 				calendar_timezones::user_timezone($user));
818 818
 		}
819 819
 		return $props;
@@ -827,8 +827,8 @@  discard block
 block discarded – undo
827 827
 	private function _get_handler()
828 828
 	{
829 829
 		$handler = new infolog_ical();
830
-		$handler->tzid = false;	//	as we read server-time timestamps (!= null=user-time), exports UTC times
831
-		$handler->setSupportedFields('GroupDAV',$this->agent);
830
+		$handler->tzid = false; //	as we read server-time timestamps (!= null=user-time), exports UTC times
831
+		$handler->setSupportedFields('GroupDAV', $this->agent);
832 832
 
833 833
 		return $handler;
834 834
 	}
Please login to merge, or discard this patch.
Braces   +76 added lines, -19 removed lines patch added patch discarded remove patch
@@ -91,7 +91,10 @@  discard block
 block discarded – undo
91 91
 		}
92 92
 		else
93 93
 		{
94
-			if (!is_array($info)) $info = $this->bo->read($info);
94
+			if (!is_array($info))
95
+			{
96
+				$info = $this->bo->read($info);
97
+			}
95 98
 			$name = $info[self::$path_attr];
96 99
 		}
97 100
 		return $name.self::$path_extension;
@@ -159,7 +162,11 @@  discard block
 block discarded – undo
159 162
 		// enable time-range filter for tests via propfind / autoindex
160 163
 		//$filter[] = $sql = $this->_time_range_filter(array('end' => '20001231T000000Z'));
161 164
 
162
-		if ($id) $path = dirname($path).'/';	// caldav_name get's added anyway in the callback
165
+		if ($id)
166
+		{
167
+			$path = dirname($path).'/';
168
+		}
169
+		// caldav_name get's added anyway in the callback
163 170
 
164 171
 		if ($this->debug > 1)
165 172
 		{
@@ -226,7 +233,10 @@  discard block
 block discarded – undo
226 233
 	 */
227 234
 	function &propfind_callback($path,array $filter,$start=false)
228 235
 	{
229
-		if ($this->debug) $starttime = microtime(true);
236
+		if ($this->debug)
237
+		{
238
+			$starttime = microtime(true);
239
+		}
230 240
 
231 241
 		if (($calendar_data = $filter['calendar_data']))
232 242
 		{
@@ -242,7 +252,10 @@  discard block
 block discarded – undo
242 252
 		if (preg_match('/^([a-z0-9_]+)( DESC| ASC)?$/i', $filter['order'], $matches))
243 253
 		{
244 254
 			$order = $matches[1];
245
-			if ($matches[2]) $sort = $matches[2];
255
+			if ($matches[2])
256
+			{
257
+				$sort = $matches[2];
258
+			}
246 259
 			unset($filter['order']);
247 260
 		}
248 261
 		$query = array(
@@ -325,7 +338,10 @@  discard block
 block discarded – undo
325 338
 				--$this->sync_collection_token;
326 339
 			}
327 340
 		}
328
-		if ($this->debug) error_log(__METHOD__."($path) took ".(microtime(true) - $starttime).' to return '.count($files).' items');
341
+		if ($this->debug)
342
+		{
343
+			error_log(__METHOD__."($path) took ".(microtime(true) - $starttime).' to return '.count($files).' items');
344
+		}
329 345
 		return $files;
330 346
 	}
331 347
 
@@ -347,7 +363,10 @@  discard block
 block discarded – undo
347 363
 				switch($filter['name'])
348 364
 				{
349 365
 					case 'comp-filter':
350
-						if ($this->debug > 1) error_log(__METHOD__."($options[path],...) comp-filter='{$filter['attrs']['name']}'");
366
+						if ($this->debug > 1)
367
+						{
368
+							error_log(__METHOD__."($options[path],...) comp-filter='{$filter['attrs']['name']}'");
369
+						}
351 370
 
352 371
 						switch($filter['attrs']['name'])
353 372
 						{
@@ -359,14 +378,23 @@  discard block
 block discarded – undo
359 378
 						}
360 379
 						break;
361 380
 					case 'prop-filter':
362
-						if ($this->debug > 1) error_log(__METHOD__."($options[path],...) prop-filter='{$filter['attrs']['name']}'");
381
+						if ($this->debug > 1)
382
+						{
383
+							error_log(__METHOD__."($options[path],...) prop-filter='{$filter['attrs']['name']}'");
384
+						}
363 385
 						$prop_filter = $filter['attrs']['name'];
364 386
 						break;
365 387
 					case 'text-match':
366
-						if ($this->debug > 1) error_log(__METHOD__."($options[path],...) text-match: $prop_filter='{$filter['data']}'");
388
+						if ($this->debug > 1)
389
+						{
390
+							error_log(__METHOD__."($options[path],...) text-match: $prop_filter='{$filter['data']}'");
391
+						}
367 392
 						if (!isset($this->filter_prop2infolog[strtoupper($prop_filter)]))
368 393
 						{
369
-							if ($this->debug) error_log(__METHOD__."($options[path],".array2string($options).",...) unknown property '$prop_filter' --> ignored");
394
+							if ($this->debug)
395
+							{
396
+								error_log(__METHOD__."($options[path],".array2string($options).",...) unknown property '$prop_filter' --> ignored");
397
+							}
370 398
 						}
371 399
 						else
372 400
 						{
@@ -375,13 +403,19 @@  discard block
 block discarded – undo
375 403
 						unset($prop_filter);
376 404
 						break;
377 405
 					case 'param-filter':
378
-						if ($this->debug) error_log(__METHOD__."($options[path],...) param-filter='{$filter['attrs']['name']}' not (yet) implemented!");
406
+						if ($this->debug)
407
+						{
408
+							error_log(__METHOD__."($options[path],...) param-filter='{$filter['attrs']['name']}' not (yet) implemented!");
409
+						}
379 410
 						break;
380 411
 					case 'time-range':
381 412
 						$cal_filters[] = $this->_time_range_filter($filter['attrs']);
382 413
 						break;
383 414
 					default:
384
-						if ($this->debug) error_log(__METHOD__."($options[path],".array2string($options).",...) unknown filter --> ignored");
415
+						if ($this->debug)
416
+						{
417
+							error_log(__METHOD__."($options[path],".array2string($options).",...) unknown filter --> ignored");
418
+						}
385 419
 						break;
386 420
 				}
387 421
 			}
@@ -450,7 +484,10 @@  discard block
 block discarded – undo
450 484
 					}
451 485
 				}
452 486
 			}
453
-			if ($this->debug > 1) error_log(__METHOD__ ."($options[path],...,$id) calendar-multiget: ids=".implode(',',$ids));
487
+			if ($this->debug > 1)
488
+			{
489
+				error_log(__METHOD__ ."($options[path],...,$id) calendar-multiget: ids=".implode(',',$ids));
490
+			}
454 491
 		}
455 492
 		return true;
456 493
 	}
@@ -511,7 +548,10 @@  discard block
 block discarded – undo
511 548
  			"NOT info_datecompleted > 0". (isset($end) ? " AND info_created < $end" : '').
512 549
 		')';
513 550
 		$sql = '('.implode(' OR ', $to_or).')';
514
-		if ($this->debug > 1) error_log(__FILE__ . __METHOD__.'('.array2string($attrs).") time-range=$attrs[start]-$attrs[end] --> $sql");
551
+		if ($this->debug > 1)
552
+		{
553
+			error_log(__FILE__ . __METHOD__.'('.array2string($attrs).") time-range=$attrs[start]-$attrs[end] --> $sql");
554
+		}
515 555
 		return $sql;
516 556
 	}
517 557
 
@@ -552,7 +592,10 @@  discard block
 block discarded – undo
552 592
 	{
553 593
 		unset($prefix);	// not used, but required by function signature
554 594
 
555
-		if ($this->debug) error_log(__METHOD__."($id, $user)".print_r($options,true));
595
+		if ($this->debug)
596
+		{
597
+			error_log(__METHOD__."($id, $user)".print_r($options,true));
598
+		}
556 599
 
557 600
 		$oldTask = $this->_common_get_put_delete('PUT',$options,$id);
558 601
 		if (!is_null($oldTask) && !is_array($oldTask))
@@ -580,7 +623,10 @@  discard block
 block discarded – undo
580 623
 		}
581 624
 		if (!($infoId = $handler->importVTODO($vTodo, $taskId, false, $user, null, $id, $callback_data)))
582 625
 		{
583
-			if ($this->debug) error_log(__METHOD__."(,$id) import_vtodo($options[content]) returned false");
626
+			if ($this->debug)
627
+			{
628
+				error_log(__METHOD__."(,$id) import_vtodo($options[content]) returned false");
629
+			}
584 630
 			return '403 Forbidden';
585 631
 		}
586 632
 
@@ -592,11 +638,13 @@  discard block
 block discarded – undo
592 638
 		// send evtl. necessary respose headers: Location, etag, ...
593 639
 		// but only for new entries, as X-INFOLOG-STATUS get's not updated on client, if we confirm with an etag
594 640
 		if ($retval !== true)
595
-			// POST with add-member query parameter
641
+		{
642
+					// POST with add-member query parameter
596 643
 			//$_SERVER['REQUEST_METHOD'] == 'POST' && isset($_GET['add-member'])))
597 644
 		{
598 645
 			$this->put_response_headers($infoId, $options['path'], $retval, self::$path_attr == 'caldav_name');
599 646
 		}
647
+		}
600 648
 		return $retval;
601 649
 	}
602 650
 
@@ -607,7 +655,10 @@  discard block
 block discarded – undo
607 655
 	 */
608 656
 	public function update_tags($entry)
609 657
 	{
610
-		if (!is_array($entry)) $entry = $this->read($entry);
658
+		if (!is_array($entry))
659
+		{
660
+			$entry = $this->read($entry);
661
+		}
611 662
 
612 663
 		$this->bo->write($entry, true);
613 664
 	}
@@ -729,7 +780,10 @@  discard block
 block discarded – undo
729 780
 	 */
730 781
 	function check_access($acl,$task)
731 782
 	{
732
-		if (is_null($task)) return true;
783
+		if (is_null($task))
784
+		{
785
+			return true;
786
+		}
733 787
 
734 788
 		$access = $this->bo->check_access($task,$acl);
735 789
 
@@ -737,7 +791,10 @@  discard block
 block discarded – undo
737 791
 		{
738 792
 			$access = true;	// access limited to $this->bo->responsible_edit fields (handled in infolog_bo::write())
739 793
 		}
740
-		if ($this->debug > 1) error_log(__METHOD__."($acl, ".array2string($task).') returning '.array2string($access));
794
+		if ($this->debug > 1)
795
+		{
796
+			error_log(__METHOD__."($acl, ".array2string($task).') returning '.array2string($access));
797
+		}
741 798
 		return $access;
742 799
 	}
743 800
 
Please login to merge, or discard this patch.
infolog/inc/class.infolog_ical.inc.php 4 patches
Doc Comments   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1042,8 +1042,7 @@
 block discarded – undo
1042 1042
 	 * Search a matching infolog entry for the VNOTE data
1043 1043
 	 *
1044 1044
 	 * @param string $_vcalData		VNOTE
1045
-	 * @param int $contentID=null 	infolog_id (or null, if unkown)
1046
-	 * @param boolean $relax=false 	if true, a weaker match algorithm is used
1045
+	 * @param int $contentID 	infolog_id (or null, if unkown)
1047 1046
 	 * @param string $charset  The encoding charset for $text. Defaults to
1048 1047
      *                         utf-8 for new format, iso-8859-1 for old format.
1049 1048
 	 *
Please login to merge, or discard this patch.
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -67,10 +67,10 @@  discard block
 block discarded – undo
67 67
 	var $productName = '';
68 68
 
69 69
 	/**
70
-	* Shall we use the UID extensions of the description field?
71
-	*
72
-	* @var boolean
73
-	*/
70
+	 * Shall we use the UID extensions of the description field?
71
+	 *
72
+	 * @var boolean
73
+	 */
74 74
 	var $uidExtension = false;
75 75
 
76 76
 	/**
@@ -509,10 +509,10 @@  discard block
 block discarded – undo
509 509
 	 * @param boolean $merge =false	merge data with existing entry (no longer used)
510 510
 	 * @param int $user =null delegate new task to this account_id, default null
511 511
 	 * @param string $charset =null The encoding charset for $text. Defaults to
512
-     *                         utf-8 for new format, iso-8859-1 for old format.
513
-     * @param string $caldav_name =null CalDAV URL name-part for new entries
514
-     * @param array $callback_data =null array with callback and further parameters, first param is task to save
515
-     * 	signature array callback($task, $param1, ...)
512
+	 *                         utf-8 for new format, iso-8859-1 for old format.
513
+	 * @param string $caldav_name =null CalDAV URL name-part for new entries
514
+	 * @param array $callback_data =null array with callback and further parameters, first param is task to save
515
+	 * 	signature array callback($task, $param1, ...)
516 516
 	 * @return int|boolean integer info_id or false on error
517 517
 	 */
518 518
 	function importVTODO(&$_vcalData, $_taskID=-1, $merge=false, $user=null, $charset=null, $caldav_name=null,
@@ -597,7 +597,7 @@  discard block
 block discarded – undo
597 597
 	 * @param int $contentID =null 	infolog_id (or null, if unkown)
598 598
 	 * @param boolean $relax =false 	if true, a weaker match algorithm is used
599 599
 	 * @param string $charset  The encoding charset for $text. Defaults to
600
-     *                         utf-8 for new format, iso-8859-1 for old format.
600
+	 *                         utf-8 for new format, iso-8859-1 for old format.
601 601
 	 *
602 602
 	 * @return array of infolog_ids of matching entries
603 603
 	 */
@@ -642,8 +642,8 @@  discard block
 block discarded – undo
642 642
 	 * @param string $_vcalData 	VTODO data
643 643
 	 * @param int $_taskID =-1		infolog_id of the entry
644 644
 	 * @param string $charset  The encoding charset for $text. Defaults to
645
-     *                         utf-8 for new format, iso-8859-1 for old format.
646
-     *
645
+	 *                         utf-8 for new format, iso-8859-1 for old format.
646
+	 *
647 647
 	 * @return array infolog entry or false on error
648 648
 	 */
649 649
 	function vtodotoegw($_vcalData, $_taskID=-1, $charset=null)
@@ -1010,8 +1010,8 @@  discard block
 block discarded – undo
1010 1010
 	 * @param int $_noteID =-1 info_id, default -1 = new entry
1011 1011
 	 * @param boolean $merge =false	merge data with existing entry (no longer used)
1012 1012
 	 * @param string $charset  The encoding charset for $text. Defaults to
1013
-     *                         utf-8 for new format, iso-8859-1 for old format.
1014
-     *
1013
+	 *                         utf-8 for new format, iso-8859-1 for old format.
1014
+	 *
1015 1015
 	 * @return int|boolean integer info_id or false on error
1016 1016
 	 */
1017 1017
 	function importVNOTE(&$_vcalData, $_type, $_noteID=-1, $merge=false, $charset=null)
@@ -1045,7 +1045,7 @@  discard block
 block discarded – undo
1045 1045
 	 * @param int $contentID=null 	infolog_id (or null, if unkown)
1046 1046
 	 * @param boolean $relax=false 	if true, a weaker match algorithm is used
1047 1047
 	 * @param string $charset  The encoding charset for $text. Defaults to
1048
-     *                         utf-8 for new format, iso-8859-1 for old format.
1048
+	 *                         utf-8 for new format, iso-8859-1 for old format.
1049 1049
 	 *
1050 1050
 	 * @return infolog_id of a matching entry or false, if nothing was found
1051 1051
 	 */
@@ -1067,8 +1067,8 @@  discard block
 block discarded – undo
1067 1067
 	 * @param string $_type		content type (eg.g text/plain)
1068 1068
 	 * @param int $_noteID =-1	infolog_id of the entry
1069 1069
 	 * @param string $charset  The encoding charset for $text. Defaults to
1070
-     *                         utf-8 for new format, iso-8859-1 for old format.
1071
-     *
1070
+	 *                         utf-8 for new format, iso-8859-1 for old format.
1071
+	 *
1072 1072
 	 * @return array infolog entry or false on error
1073 1073
 	 */
1074 1074
 	function vnotetoegw($_data, $_type, $_noteID=-1, $charset=null)
Please login to merge, or discard this patch.
Spacing   +125 added lines, -126 removed lines patch added patch discarded remove patch
@@ -23,39 +23,39 @@  discard block
 block discarded – undo
23 23
 	 * @var array $priority_egw2ical conversion of the priority egw => ical
24 24
 	 */
25 25
 	var $priority_egw2ical = array(
26
-		0 => 9,		// low
27
-		1 => 5,		// normal
28
-		2 => 3,		// high
29
-		3 => 1,		// urgent
26
+		0 => 9, // low
27
+		1 => 5, // normal
28
+		2 => 3, // high
29
+		3 => 1, // urgent
30 30
 	);
31 31
 
32 32
 	/**
33 33
 	 * @var array $priority_ical2egw conversion of the priority ical => egw
34 34
 	 */
35 35
 	var $priority_ical2egw = array(
36
-		9 => 0,	8 => 0, 7 => 0,	// low
37
-		6 => 1, 5 => 1, 4 => 1, 0 => 1,	// normal
38
-		3 => 2,	2 => 2,	// high
39
-		1 => 3,			// urgent
36
+		9 => 0, 8 => 0, 7 => 0, // low
37
+		6 => 1, 5 => 1, 4 => 1, 0 => 1, // normal
38
+		3 => 2, 2 => 2, // high
39
+		1 => 3, // urgent
40 40
 	);
41 41
 
42 42
 	/**
43 43
 	 * @var array $priority_egw2funambol conversion of the priority egw => funambol
44 44
 	 */
45 45
 	var $priority_egw2funambol = array(
46
-		0 => 0,		// low
47
-		1 => 1,		// normal
48
-		2 => 2,		// high
49
-		3 => 2,		// urgent
46
+		0 => 0, // low
47
+		1 => 1, // normal
48
+		2 => 2, // high
49
+		3 => 2, // urgent
50 50
 	);
51 51
 
52 52
 	/**
53 53
 	 * @var array $priority_funambol2egw conversion of the priority funambol => egw
54 54
 	 */
55 55
 	var $priority_funambol2egw = array(
56
-		0 => 0,		// low
57
-		1 => 1,		// normal
58
-		2 => 3,		// high
56
+		0 => 0, // low
57
+		1 => 1, // normal
58
+		2 => 3, // high
59 59
 	);
60 60
 
61 61
 	/**
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 	 * @var boolean
94 94
 	 */
95 95
 	var $log = false;
96
-	var $logfile="/tmp/log-infolog-vcal";
96
+	var $logfile = "/tmp/log-infolog-vcal";
97 97
 
98 98
 
99 99
 	/**
@@ -117,11 +117,11 @@  discard block
 block discarded – undo
117 117
 	 * @param string $charset ='UTF-8'
118 118
 	 * @return string|boolean string with vCal or false on error (eg. no permission to read the event)
119 119
 	 */
120
-	function exportVCalendar(array $tasks, $_version='2.0', $_method=null, $charset='UTF-8')
120
+	function exportVCalendar(array $tasks, $_version = '2.0', $_method = null, $charset = 'UTF-8')
121 121
 	{
122 122
 		$vcal = new Horde_Icalendar;
123 123
 
124
-		foreach($tasks as $task)
124
+		foreach ($tasks as $task)
125 125
 		{
126 126
 			if (!$this->exportVTODO($task, $_version, $_method, $charset, $vcal))
127 127
 			{
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 	 *
143 143
 	 * @return string|boolean string with vCal or false on error (eg. no permission to read the event)
144 144
 	 */
145
-	function exportVTODO($task, $_version='2.0',$_method='PUBLISH', $charset='UTF-8',Horde_Icalendar $vcal=null)
145
+	function exportVTODO($task, $_version = '2.0', $_method = 'PUBLISH', $charset = 'UTF-8', Horde_Icalendar $vcal = null)
146 146
 	{
147 147
 		if (is_array($task))
148 148
 		{
@@ -167,10 +167,10 @@  discard block
 block discarded – undo
167 167
 		{
168 168
 			if (!preg_match('/\[UID:.+\]/m', $taskData['info_des']))
169 169
 			{
170
-				$taskData['info_des'] .= "\n[UID:" . $taskData['info_uid'] . "]";
170
+				$taskData['info_des'] .= "\n[UID:".$taskData['info_uid']."]";
171 171
 				if ($taskData['info_id_parent'] != '')
172 172
 				{
173
-					$taskData['info_des'] .= "\n[PARENT_UID:" . $taskData['info_id_parent'] . "]";
173
+					$taskData['info_des'] .= "\n[PARENT_UID:".$taskData['info_id_parent']."]";
174 174
 				}
175 175
 			}
176 176
 		}
@@ -186,15 +186,15 @@  discard block
 block discarded – undo
186 186
 
187 187
 		if ($this->log)
188 188
 		{
189
-			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" .
190
-				array2string($taskData)."\n",3,$this->logfile);
189
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n".
190
+				array2string($taskData)."\n", 3, $this->logfile);
191 191
 		}
192 192
 
193 193
 		if (!isset($vcal)) $vcal = new Horde_Icalendar;
194
-		$vcal->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware InfoLog '.$GLOBALS['egw_info']['apps']['infolog']['version'].'//'.
195
-			strtoupper($GLOBALS['egw_info']['user']['preferences']['common']['lang']),array(),false);
196
-		$vcal->setAttribute('VERSION',$_version,array(),false);
197
-		if ($_method) $vcal->setAttribute('METHOD',$_method,array(),false);
194
+		$vcal->setAttribute('PRODID', '-//EGroupware//NONSGML EGroupware InfoLog '.$GLOBALS['egw_info']['apps']['infolog']['version'].'//'.
195
+			strtoupper($GLOBALS['egw_info']['user']['preferences']['common']['lang']), array(), false);
196
+		$vcal->setAttribute('VERSION', $_version, array(), false);
197
+		if ($_method) $vcal->setAttribute('METHOD', $_method, array(), false);
198 198
 
199 199
 		$tzid = $this->tzid;
200 200
 		if ($tzid && $tzid != 'UTC')
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 			}
213 213
 		}
214 214
 
215
-		$vevent = Horde_Icalendar::newComponent('VTODO',$vcal);
215
+		$vevent = Horde_Icalendar::newComponent('VTODO', $vcal);
216 216
 
217 217
 		if (!isset($this->clientProperties['SUMMARY']['Size']))
218 218
 		{
@@ -236,9 +236,9 @@  discard block
 block discarded – undo
236 236
 				$noTruncate = $this->clientProperties[$field]['NoTruncate'];
237 237
 				if ($this->log && $size > 0)
238 238
 				{
239
-					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
240
-						"() $field Size: $size, NoTruncate: " .
241
-						($noTruncate ? 'TRUE' : 'FALSE') . "\n",3,$this->logfile);
239
+					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
240
+						"() $field Size: $size, NoTruncate: ".
241
+						($noTruncate ? 'TRUE' : 'FALSE')."\n", 3, $this->logfile);
242 242
 				}
243 243
 				//Horde::logMessage("VTODO $field Size: $size, NoTruncate: " .
244 244
 				//	($noTruncate ? 'TRUE' : 'FALSE'), __FILE__, __LINE__, PEAR_LOG_DEBUG);
@@ -255,19 +255,19 @@  discard block
 block discarded – undo
255 255
 				{
256 256
 					if ($this->log)
257 257
 					{
258
-						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
259
-							"() $field omitted due to maximum size $size\n",3,$this->logfile);
258
+						error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
259
+							"() $field omitted due to maximum size $size\n", 3, $this->logfile);
260 260
 					}
261 261
 					//Horde::logMessage("VTODO $field omitted due to maximum size $size",
262 262
 					//	__FILE__, __LINE__, PEAR_LOG_WARNING);
263 263
 					continue; // skip field
264 264
 				}
265 265
 				// truncate the value to size
266
-				$value = substr($value, 0, $size -1);
266
+				$value = substr($value, 0, $size - 1);
267 267
 				if ($this->log)
268 268
 				{
269
-					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
270
-						"() $field truncated to maximum size $size\n",3,$this->logfile);
269
+					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
270
+						"() $field truncated to maximum size $size\n", 3, $this->logfile);
271 271
 				}
272 272
 				//Horde::logMessage("VTODO $field truncated to maximum size $size",
273 273
 				//	__FILE__, __LINE__, PEAR_LOG_INFO);
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 
287 287
 			if ($_version == '1.0' && preg_match('/[^\x20-\x7F]/', $value))
288 288
 			{
289
-				$options['CHARSET']	= $charset;
289
+				$options['CHARSET'] = $charset;
290 290
 				switch ($this->productManufacturer)
291 291
 				{
292 292
 					case 'groupdav':
@@ -328,23 +328,23 @@  discard block
 block discarded – undo
328 328
 			self::setDateOrTime($vevent, 'COMPLETED', $taskData['info_datecompleted'], $tzid);
329 329
 		}
330 330
 
331
-		$vevent->setAttribute('DTSTAMP',time());
331
+		$vevent->setAttribute('DTSTAMP', time());
332 332
 		$vevent->setAttribute('CREATED', $taskData['info_created']);
333 333
 		$vevent->setAttribute('LAST-MODIFIED', $taskData['info_datemodified']);
334
-		$vevent->setAttribute('CLASS',$taskData['info_access'] == 'public' ? 'PUBLIC' : 'PRIVATE');
335
-		$vevent->setAttribute('STATUS',$this->status2vtodo($taskData['info_status']));
334
+		$vevent->setAttribute('CLASS', $taskData['info_access'] == 'public' ? 'PUBLIC' : 'PRIVATE');
335
+		$vevent->setAttribute('STATUS', $this->status2vtodo($taskData['info_status']));
336 336
 		// we try to preserv the original infolog status as X-INFOLOG-STATUS, so we can restore it, if the user does not modify STATUS
337
-		$vevent->setAttribute('X-INFOLOG-STATUS',$taskData['info_status']);
338
-		$vevent->setAttribute('PERCENT-COMPLETE',$taskData['info_percent']);
337
+		$vevent->setAttribute('X-INFOLOG-STATUS', $taskData['info_status']);
338
+		$vevent->setAttribute('PERCENT-COMPLETE', $taskData['info_percent']);
339 339
 		if ($this->productManufacturer == 'funambol' &&
340 340
 			(strpos($this->productName, 'outlook') !== false
341 341
 				|| strpos($this->productName, 'pocket pc') !== false))
342 342
 		{
343
-			$priority = (int) $this->priority_egw2funambol[$taskData['info_priority']];
343
+			$priority = (int)$this->priority_egw2funambol[$taskData['info_priority']];
344 344
 		}
345 345
 		else
346 346
 		{
347
-			$priority = (int) $this->priority_egw2ical[$taskData['info_priority']];
347
+			$priority = (int)$this->priority_egw2ical[$taskData['info_priority']];
348 348
 		}
349 349
 		$vevent->setAttribute('PRIORITY', $priority);
350 350
 
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
 			(count($taskData['info_responsible']) > 1 ||
354 354
 				$taskData['info_responsible'][0] != $taskData['info_onwer']))
355 355
 		{
356
-			if (($url = $GLOBALS['egw']->accounts->id2name($taskData['info_owner'],'account_email')))
356
+			if (($url = $GLOBALS['egw']->accounts->id2name($taskData['info_owner'], 'account_email')))
357 357
 			{
358 358
 				$url = 'MAILTO:'.$url;
359 359
 			}
@@ -361,13 +361,13 @@  discard block
 block discarded – undo
361 361
 			{
362 362
 				$url = 'urn:uuid:'.Api\CalDAV::generate_uid('accounts', $taskData['info_owner']);
363 363
 			}
364
-			$vevent->setAttribute('ORGANIZER',$url,array(
365
-				'CN'		=>	$GLOBALS['egw']->accounts->id2name($taskData['info_owner'],'account_fullname'),
364
+			$vevent->setAttribute('ORGANIZER', $url, array(
365
+				'CN'		=>	$GLOBALS['egw']->accounts->id2name($taskData['info_owner'], 'account_fullname'),
366 366
 				'X-EGROUPWARE-UID'	=> $taskData['info_owner'],
367 367
 			), true);
368
-			foreach($taskData['info_responsible'] as $responsible)
368
+			foreach ($taskData['info_responsible'] as $responsible)
369 369
 			{
370
-				if (($url = $GLOBALS['egw']->accounts->id2name($responsible,'account_email')))
370
+				if (($url = $GLOBALS['egw']->accounts->id2name($responsible, 'account_email')))
371 371
 				{
372 372
 					$url = 'MAILTO:'.$url;
373 373
 				}
@@ -377,15 +377,15 @@  discard block
 block discarded – undo
377 377
 				}
378 378
 				if ($responsible > 0)
379 379
 				{
380
-					$vevent->setAttribute('ATTENDEE',$url,array(
381
-						'CN'		=>	$GLOBALS['egw']->accounts->id2name($responsible,'account_fullname'),
380
+					$vevent->setAttribute('ATTENDEE', $url, array(
381
+						'CN'		=>	$GLOBALS['egw']->accounts->id2name($responsible, 'account_fullname'),
382 382
 						'CUTYPE'	=> 'INDIVIDUAL',
383 383
 						'X-EGROUPWARE-UID'	=> $responsible,
384 384
 					), true);
385 385
 				}
386 386
 				elseif ($responsible < 0)
387 387
 				{
388
-					$vevent->setAttribute('ATTENDEE',$url,array(
388
+					$vevent->setAttribute('ATTENDEE', $url, array(
389 389
 						'CN'		=>	$GLOBALS['egw']->accounts->id2name($responsible),
390 390
 						'CUTYPE'	=> 'GROUP',
391 391
 						'X-EGROUPWARE-UID'	=> $responsible,
@@ -396,17 +396,17 @@  discard block
 block discarded – undo
396 396
 		// for CalDAV add all X-Properties previously parsed
397 397
 		if ($this->productManufacturer == 'groupdav')
398 398
 		{
399
-			foreach($taskData as $name => $value)
399
+			foreach ($taskData as $name => $value)
400 400
 			{
401 401
 				if (substr($name, 0, 2) == '##')
402 402
 				{
403 403
 					if ($name[2] == ':')
404 404
 					{
405 405
 						if (($v = json_php_unserialize($value)) && is_array($v)) $value = $v;
406
-						foreach((array)$value as $compvData)
406
+						foreach ((array)$value as $compvData)
407 407
 						{
408
-							$comp = Horde_Icalendar::newComponent(substr($name,3), $vevent);
409
-							$comp->parsevCalendar($compvData,substr($name,3));
408
+							$comp = Horde_Icalendar::newComponent(substr($name, 3), $vevent);
409
+							$comp->parsevCalendar($compvData, substr($name, 3));
410 410
 							$vevent->addComponent($comp);
411 411
 						}
412 412
 					}
@@ -426,8 +426,8 @@  discard block
 block discarded – undo
426 426
 		$retval = $vcal->exportvCalendar();
427 427
 		if ($this->log)
428 428
 		{
429
-			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" .
430
-				array2string($retval)."\n",3,$this->logfile);
429
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n".
430
+				array2string($retval)."\n", 3, $this->logfile);
431 431
 		}
432 432
 		// Horde::logMessage("exportVTODO:\n" . print_r($retval, true),
433 433
 		//	__FILE__, __LINE__, PEAR_LOG_DEBUG);
@@ -456,7 +456,7 @@  discard block
 block discarded – undo
456 456
 			}
457 457
 			$tz = self::$tz_cache[$tzid];
458 458
 		}
459
-		elseif(is_null($tzid))
459
+		elseif (is_null($tzid))
460 460
 		{
461 461
 			$tz = Api\DateTime::$user_timezone;
462 462
 		}
@@ -464,9 +464,9 @@  discard block
 block discarded – undo
464 464
 		{
465 465
 			$tz = Api\DateTime::$server_timezone;
466 466
 		}
467
-		if (!is_a($time,'DateTime'))
467
+		if (!is_a($time, 'DateTime'))
468 468
 		{
469
-			$time = new Api\DateTime($time,Api\DateTime::$server_timezone);
469
+			$time = new Api\DateTime($time, Api\DateTime::$server_timezone);
470 470
 		}
471 471
 		$time->setTimezone($tz);
472 472
 
@@ -515,16 +515,16 @@  discard block
 block discarded – undo
515 515
      * 	signature array callback($task, $param1, ...)
516 516
 	 * @return int|boolean integer info_id or false on error
517 517
 	 */
518
-	function importVTODO(&$_vcalData, $_taskID=-1, $merge=false, $user=null, $charset=null, $caldav_name=null,
519
-		array $callback_data=null)
518
+	function importVTODO(&$_vcalData, $_taskID = -1, $merge = false, $user = null, $charset = null, $caldav_name = null,
519
+		array $callback_data = null)
520 520
 	{
521
-		unset($merge);	// no longer used, but required by function signature
521
+		unset($merge); // no longer used, but required by function signature
522 522
 
523 523
 		if ($this->tzid)
524 524
 		{
525 525
 			date_default_timezone_set($this->tzid);
526 526
 		}
527
-		$taskData = $this->vtodotoegw($_vcalData,$_taskID, $charset);
527
+		$taskData = $this->vtodotoegw($_vcalData, $_taskID, $charset);
528 528
 		if ($this->tzid)
529 529
 		{
530 530
 			date_default_timezone_set($GLOBALS['egw_info']['server']['server_timezone']);
@@ -555,8 +555,8 @@  discard block
 block discarded – undo
555 555
 
556 556
 		if ($this->log)
557 557
 		{
558
-			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" .
559
-				array2string($taskData)."\n",3,$this->logfile);
558
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n".
559
+				array2string($taskData)."\n", 3, $this->logfile);
560 560
 		}
561 561
 
562 562
 		if ($caldav_name)
@@ -565,18 +565,18 @@  discard block
 block discarded – undo
565 565
 		}
566 566
 
567 567
 		// make sure not to empty fields not supported by iCal or not allowed to change by CalDAV
568
-		if ($_taskID > 0 && ($old = $this->read($_taskID,true,'server')))
568
+		if ($_taskID > 0 && ($old = $this->read($_taskID, true, 'server')))
569 569
 		{
570 570
 			// remove all values supported by iCal standard
571 571
 			$old = array_diff_key($old, array_flip(array(
572
-				'info_subject','info_des','info_location','info_cat','info_responsible',
573
-				'info_startdate','info_enddate','info_priority','info_location',
574
-				'info_access','info_status','info_percent','info_datecompleted',
572
+				'info_subject', 'info_des', 'info_location', 'info_cat', 'info_responsible',
573
+				'info_startdate', 'info_enddate', 'info_priority', 'info_location',
574
+				'info_access', 'info_status', 'info_percent', 'info_datecompleted',
575 575
 			)));
576 576
 			// remove all iCal fields not supported by EGroupware (stored like custom fields)
577
-			foreach(array_keys($old) as $name)
577
+			foreach (array_keys($old) as $name)
578 578
 			{
579
-				if (substr($name,0,2) == '##') unset($old[$name]);
579
+				if (substr($name, 0, 2) == '##') unset($old[$name]);
580 580
 			}
581 581
 			// merge in again all infolog fields not supported by iCal or not allowed to change
582 582
 			$taskData = array_merge($taskData, $old);
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
 	 *
602 602
 	 * @return array of infolog_ids of matching entries
603 603
 	 */
604
-	function searchVTODO($_vcalData, $contentID=null, $relax=false, $charset=null)
604
+	function searchVTODO($_vcalData, $contentID = null, $relax = false, $charset = null)
605 605
 	{
606 606
 		$result = array();
607 607
 
@@ -646,12 +646,12 @@  discard block
 block discarded – undo
646 646
      *
647 647
 	 * @return array infolog entry or false on error
648 648
 	 */
649
-	function vtodotoegw($_vcalData, $_taskID=-1, $charset=null)
649
+	function vtodotoegw($_vcalData, $_taskID = -1, $charset = null)
650 650
 	{
651 651
 		if ($this->log)
652 652
 		{
653
-			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."($_taskID)\n" .
654
-				array2string($_vcalData)."\n",3,$this->logfile);
653
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."($_taskID)\n".
654
+				array2string($_vcalData)."\n", 3, $this->logfile);
655 655
 		}
656 656
 
657 657
 		$vcal = new Horde_Icalendar;
@@ -664,7 +664,7 @@  discard block
 block discarded – undo
664 664
 			if ($this->log)
665 665
 			{
666 666
 				error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
667
-					"(): No vCalendar Container found!\n",3,$this->logfile);
667
+					"(): No vCalendar Container found!\n", 3, $this->logfile);
668 668
 			}
669 669
 			return false;
670 670
 		}
@@ -687,7 +687,7 @@  discard block
 block discarded – undo
687 687
 				if ($this->log)
688 688
 				{
689 689
 					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
690
-						"(): Not a vTODO container, skipping...\n",3,$this->logfile);
690
+						"(): Not a vTODO container, skipping...\n", 3, $this->logfile);
691 691
 				}
692 692
 				continue;
693 693
 			}
@@ -714,24 +714,23 @@  discard block
 block discarded – undo
714 714
 					($this->_status2vtodo[$x_infolog_status] === 'COMPLETED') != is_scalar($completed))
715 715
 				{
716 716
 					$percent_completed = $component->getAttributeDefault('PERCENT-COMPLETE', null);
717
-					$status = $completed && is_scalar($completed) ? 'COMPLETED' :
718
-						($percent_completed && is_scalar($percent_completed) && $percent_completed > 0 ? 'IN-PROCESS' : 'NEEDS-ACTION');
717
+					$status = $completed && is_scalar($completed) ? 'COMPLETED' : ($percent_completed && is_scalar($percent_completed) && $percent_completed > 0 ? 'IN-PROCESS' : 'NEEDS-ACTION');
719 718
 					$component->setAttribute('STATUS', $status);
720 719
 					if (!is_scalar($percent_completed))
721 720
 					{
722 721
 						$component->setAttribute('PERCENT-COMPLETE', $percent_completed = $status == 'COMPLETED' ?
723 722
 							100 : ($status == 'NEEDS-ACTION' ? 0 : 10));
724 723
 					}
725
-					if ($this->log) error_log(__METHOD__."() setting STATUS='$status' and PERCENT-COMPLETE=$percent_completed from COMPLETED and X-INFOLOG-STATUS='$x_infolog_status'\n",3,$this->logfile);
724
+					if ($this->log) error_log(__METHOD__."() setting STATUS='$status' and PERCENT-COMPLETE=$percent_completed from COMPLETED and X-INFOLOG-STATUS='$x_infolog_status'\n", 3, $this->logfile);
726 725
 				}
727 726
 				// new task without status --> set a default status of NEEDS-ACTION, as otherwise task is marked closed
728
-				elseif($_taskID <= 0 && !is_scalar($x_infolog_status) && !is_scalar($completed))
727
+				elseif ($_taskID <= 0 && !is_scalar($x_infolog_status) && !is_scalar($completed))
729 728
 				{
730 729
 					$component->setAttribute('STATUS', 'NEEDS-ACTION');
731 730
 				}
732 731
 				else
733 732
 				{
734
-					if ($this->log) error_log(__METHOD__."() no STATUS, X-INFOLOG-STATUS='$x_infolog_status', COMPLETED".(is_scalar($completed)?'='.$completed:' not set')." --> leaving status and percent unchanged",3,$this->logfile);
733
+					if ($this->log) error_log(__METHOD__."() no STATUS, X-INFOLOG-STATUS='$x_infolog_status', COMPLETED".(is_scalar($completed) ? '='.$completed : ' not set')." --> leaving status and percent unchanged", 3, $this->logfile);
735 734
 				}
736 735
 			}
737 736
 			foreach ($component->getAllAttributes() as $attribute)
@@ -775,7 +774,7 @@  discard block
 block discarded – undo
775 774
 					case 'DURATION':
776 775
 						if (!isset($taskData['info_startdate']))
777 776
 						{
778
-							$taskData['info_startdate']	= $component->getAttributeDefault('DTSTART', null);
777
+							$taskData['info_startdate'] = $component->getAttributeDefault('DTSTART', null);
779 778
 						}
780 779
 						$attribute['value'] += $taskData['info_startdate'];
781 780
 						$taskData['##DURATION'] = $attribute['value'];
@@ -787,11 +786,11 @@  discard block
 block discarded – undo
787 786
 						break;
788 787
 
789 788
 					case 'COMPLETED':
790
-						$taskData['info_datecompleted']	= self::date2ts($attribute['value']);
789
+						$taskData['info_datecompleted'] = self::date2ts($attribute['value']);
791 790
 						break;
792 791
 
793 792
 					case 'DTSTART':
794
-						$taskData['info_startdate']	= self::date2ts($attribute['value']);
793
+						$taskData['info_startdate'] = self::date2ts($attribute['value']);
795 794
 						break;
796 795
 
797 796
 					case 'PRIORITY':
@@ -801,16 +800,16 @@  discard block
 block discarded – undo
801 800
 								(strpos($this->productName, 'outlook') !== false
802 801
 									|| strpos($this->productName, 'pocket pc') !== false))
803 802
 							{
804
-								$taskData['info_priority'] = (int) $this->priority_funambol2egw[$attribute['value']];
803
+								$taskData['info_priority'] = (int)$this->priority_funambol2egw[$attribute['value']];
805 804
 							}
806 805
 							else
807 806
 							{
808
-								$taskData['info_priority'] = (int) $this->priority_ical2egw[$attribute['value']];
807
+								$taskData['info_priority'] = (int)$this->priority_ical2egw[$attribute['value']];
809 808
 							}
810 809
 						}
811 810
 						else
812 811
 						{
813
-							$taskData['info_priority'] = 1;	// default = normal
812
+							$taskData['info_priority'] = 1; // default = normal
814 813
 						}
815 814
 						break;
816 815
 
@@ -833,7 +832,7 @@  discard block
 block discarded – undo
833 832
 					case 'CATEGORIES':
834 833
 						if (!empty($attribute['value']))
835 834
 						{
836
-							$cats = $this->find_or_add_categories(explode(',',$attribute['value']), $_taskID);
835
+							$cats = $this->find_or_add_categories(explode(',', $attribute['value']), $_taskID);
837 836
 							$taskData['info_cat'] = $cats[0];
838 837
 						}
839 838
 						break;
@@ -846,7 +845,7 @@  discard block
 block discarded – undo
846 845
 						break;
847 846
 
848 847
 					case 'PERCENT-COMPLETE':
849
-						$taskData['info_percent'] = (int) $attribute['value'];
848
+						$taskData['info_percent'] = (int)$attribute['value'];
850 849
 						break;
851 850
 
852 851
 					case 'ATTENDEE':
@@ -888,10 +887,10 @@  discard block
 block discarded – undo
888 887
 			break;
889 888
 		}
890 889
 		// store included, but unsupported components like valarm as x-properties
891
-		foreach($component->getComponents() as $comp)
890
+		foreach ($component->getComponents() as $comp)
892 891
 		{
893 892
 			$name = '##:'.strtoupper($comp->getType());
894
-			$compvData = $comp->exportvCalendar($comp,'utf-8');
893
+			$compvData = $comp->exportvCalendar($comp, 'utf-8');
895 894
 			if (isset($taskData[$name]))
896 895
 			{
897 896
 				$taskData[$name] = array($taskData[$name]);
@@ -904,8 +903,8 @@  discard block
 block discarded – undo
904 903
 		}
905 904
 		if ($this->log)
906 905
 		{
907
-			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."($_taskID)\n" .
908
-				($taskData ? array2string($taskData) : 'FALSE') . "\n",3,$this->logfile);
906
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."($_taskID)\n".
907
+				($taskData ? array2string($taskData) : 'FALSE')."\n", 3, $this->logfile);
909 908
 		}
910 909
 		return $taskData;
911 910
 	}
@@ -919,14 +918,14 @@  discard block
 block discarded – undo
919 918
 	 *
920 919
 	 * @return string|boolean VNOTE representation of the infolog entry or false on error
921 920
 	 */
922
-	function exportVNOTE($_noteID, $_type, $charset='UTF-8')
921
+	function exportVNOTE($_noteID, $_type, $charset = 'UTF-8')
923 922
 	{
924
-		if(!($note = $this->read($_noteID, true, 'server'))) return false;
923
+		if (!($note = $this->read($_noteID, true, 'server'))) return false;
925 924
 
926 925
 		$note = Api\Translation::convert($note,
927 926
 			Api\Translation::charset(), $charset);
928 927
 
929
-		switch	($_type)
928
+		switch ($_type)
930 929
 		{
931 930
 			case 'text/plain':
932 931
 				$txt = $note['info_subject']."\n\n".$note['info_des'];
@@ -940,10 +939,10 @@  discard block
 block discarded – undo
940 939
 						Api\Translation::charset(), $charset);
941 940
 				}
942 941
 				$vnote = new Horde_Icalendar_Vnote();
943
-				$vnote->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware InfoLog '.$GLOBALS['egw_info']['apps']['infolog']['version'].'//'.
942
+				$vnote->setAttribute('PRODID', '-//EGroupware//NONSGML EGroupware InfoLog '.$GLOBALS['egw_info']['apps']['infolog']['version'].'//'.
944 943
 					strtoupper($GLOBALS['egw_info']['user']['preferences']['common']['lang']));
945 944
 				$vnote->setAttribute('VERSION', '1.1');
946
-				foreach (array(	'SUMMARY'		=> $note['info_subject'],
945
+				foreach (array('SUMMARY'		=> $note['info_subject'],
947 946
 								'BODY'			=> $note['info_des'],
948 947
 								'CATEGORIES'	=> $note['info_cat'],
949 948
 							) as $field => $value)
@@ -951,7 +950,7 @@  discard block
 block discarded – undo
951 950
 					$options = array();
952 951
 					if (preg_match('/[^\x20-\x7F]/', $value))
953 952
 					{
954
-						$options['CHARSET']	= $charset;
953
+						$options['CHARSET'] = $charset;
955 954
 						switch ($this->productManufacturer)
956 955
 						{
957 956
 							case 'groupdav':
@@ -981,21 +980,21 @@  discard block
 block discarded – undo
981 980
 				}
982 981
 				if ($note['info_startdate'])
983 982
 				{
984
-					$vnote->setAttribute('CREATED',$note['info_startdate']);
983
+					$vnote->setAttribute('CREATED', $note['info_startdate']);
985 984
 				}
986 985
 				else
987 986
 				{
988
-					$vnote->setAttribute('CREATED',$GLOBALS['egw']->contenthistory->getTSforAction('infolog_note',$_noteID,'add'));
987
+					$vnote->setAttribute('CREATED', $GLOBALS['egw']->contenthistory->getTSforAction('infolog_note', $_noteID, 'add'));
989 988
 				}
990
-				$vnote->setAttribute('LAST-MODIFIED',$GLOBALS['egw']->contenthistory->getTSforAction('infolog_note',$_noteID,'modify'));
989
+				$vnote->setAttribute('LAST-MODIFIED', $GLOBALS['egw']->contenthistory->getTSforAction('infolog_note', $_noteID, 'modify'));
991 990
 
992 991
 				#$vnote->setAttribute('CLASS',$taskData['info_access'] == 'public' ? 'PUBLIC' : 'PRIVATE');
993 992
 
994 993
 				$retval = $vnote->exportvCalendar();
995 994
 				if ($this->log)
996 995
 				{
997
-					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" .
998
-						array2string($retval)."\n",3,$this->logfile);
996
+					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n".
997
+						array2string($retval)."\n", 3, $this->logfile);
999 998
 				}
1000 999
 				return $retval;
1001 1000
 		}
@@ -1014,25 +1013,25 @@  discard block
 block discarded – undo
1014 1013
      *
1015 1014
 	 * @return int|boolean integer info_id or false on error
1016 1015
 	 */
1017
-	function importVNOTE(&$_vcalData, $_type, $_noteID=-1, $merge=false, $charset=null)
1016
+	function importVNOTE(&$_vcalData, $_type, $_noteID = -1, $merge = false, $charset = null)
1018 1017
 	{
1019
-		unset($merge);	// no longer used, but required by function signature
1018
+		unset($merge); // no longer used, but required by function signature
1020 1019
 		if ($this->log)
1021 1020
 		{
1022
-			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" .
1023
-				array2string($_vcalData)."\n",3,$this->logfile);
1021
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n".
1022
+				array2string($_vcalData)."\n", 3, $this->logfile);
1024 1023
 		}
1025 1024
 
1026 1025
 		if (!($note = $this->vnotetoegw($_vcalData, $_type, $_noteID, $charset))) return false;
1027 1026
 
1028
-		if($_noteID > 0) $note['info_id'] = $_noteID;
1027
+		if ($_noteID > 0) $note['info_id'] = $_noteID;
1029 1028
 
1030 1029
 		if (empty($note['info_status'])) $note['info_status'] = 'done';
1031 1030
 
1032 1031
 		if ($this->log)
1033 1032
 		{
1034
-			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" .
1035
-				array2string($note)."\n",3,$this->logfile);
1033
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n".
1034
+				array2string($note)."\n", 3, $this->logfile);
1036 1035
 		}
1037 1036
 
1038 1037
 		return $this->write($note, true, true, false);
@@ -1049,7 +1048,7 @@  discard block
 block discarded – undo
1049 1048
 	 *
1050 1049
 	 * @return infolog_id of a matching entry or false, if nothing was found
1051 1050
 	 */
1052
-	function searchVNOTE($_vcalData, $_type, $contentID=null, $relax=false, $charset=null)
1051
+	function searchVNOTE($_vcalData, $_type, $contentID = null, $relax = false, $charset = null)
1053 1052
 	{
1054 1053
 		if (!($note = $this->vnotetoegw($_vcalData, $_type, $contentID, $charset))) return array();
1055 1054
 
@@ -1071,12 +1070,12 @@  discard block
 block discarded – undo
1071 1070
      *
1072 1071
 	 * @return array infolog entry or false on error
1073 1072
 	 */
1074
-	function vnotetoegw($_data, $_type, $_noteID=-1, $charset=null)
1073
+	function vnotetoegw($_data, $_type, $_noteID = -1, $charset = null)
1075 1074
 	{
1076 1075
 		if ($this->log)
1077 1076
 		{
1078
-			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."($_type, $_noteID)\n" .
1079
-				array2string($_data)."\n",3,$this->logfile);
1077
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."($_type, $_noteID)\n".
1078
+				array2string($_data)."\n", 3, $this->logfile);
1080 1079
 		}
1081 1080
 		$note = false;
1082 1081
 
@@ -1130,7 +1129,7 @@  discard block
 block discarded – undo
1130 1129
 								case 'CATEGORIES':
1131 1130
 									if ($attribute['value'])
1132 1131
 									{
1133
-										$cats = $this->find_or_add_categories(explode(',',$attribute['value']), $_noteID);
1132
+										$cats = $this->find_or_add_categories(explode(',', $attribute['value']), $_noteID);
1134 1133
 										$note['info_cat'] = $cats[0];
1135 1134
 									}
1136 1135
 									break;
@@ -1141,8 +1140,8 @@  discard block
 block discarded – undo
1141 1140
 		}
1142 1141
 		if ($this->log)
1143 1142
 		{
1144
-			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."($_type, $_noteID)\n" .
1145
-				($note ? array2string($note) : 'FALSE') ."\n",3,$this->logfile);
1143
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."($_type, $_noteID)\n".
1144
+				($note ? array2string($note) : 'FALSE')."\n", 3, $this->logfile);
1146 1145
 		}
1147 1146
 		return $note;
1148 1147
 	}
@@ -1155,7 +1154,7 @@  discard block
 block discarded – undo
1155 1154
 	 * @param string $_productManufacturer
1156 1155
 	 * @param string $_productName
1157 1156
 	 */
1158
-	function setSupportedFields($_productManufacturer='', $_productName='')
1157
+	function setSupportedFields($_productManufacturer = '', $_productName = '')
1159 1158
 	{
1160 1159
 		$state = &$_SESSION['SyncML.state'];
1161 1160
 		if (isset($state))
@@ -1207,10 +1206,10 @@  discard block
 block discarded – undo
1207 1206
 		if ($this->log)
1208 1207
 		{
1209 1208
 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1210
-				'(' . $this->productManufacturer .
1211
-				', '. $this->productName .', ' .
1212
-				($this->tzid ? $this->tzid : Api\DateTime::$user_timezone->getName()) .
1213
-				")\n" , 3, $this->logfile);
1209
+				'('.$this->productManufacturer.
1210
+				', '.$this->productName.', '.
1211
+				($this->tzid ? $this->tzid : Api\DateTime::$user_timezone->getName()).
1212
+				")\n", 3, $this->logfile);
1214 1213
 		}
1215 1214
 
1216 1215
 		//Horde::logMessage('setSupportedFields(' . $this->productManufacturer . ', '
Please login to merge, or discard this patch.
Braces   +72 added lines, -18 removed lines patch added patch discarded remove patch
@@ -104,7 +104,10 @@  discard block
 block discarded – undo
104 104
 	function __construct(&$_clientProperties = array())
105 105
 	{
106 106
 		parent::__construct();
107
-		if ($this->log) $this->logfile = $GLOBALS['egw_info']['server']['temp_dir']."/log-infolog-vcal";
107
+		if ($this->log)
108
+		{
109
+			$this->logfile = $GLOBALS['egw_info']['server']['temp_dir']."/log-infolog-vcal";
110
+		}
108 111
 		$this->clientProperties = $_clientProperties;
109 112
 	}
110 113
 
@@ -150,7 +153,10 @@  discard block
 block discarded – undo
150 153
 		}
151 154
 		else
152 155
 		{
153
-			if (!($taskData = $this->read($task, true, 'server'))) return false;
156
+			if (!($taskData = $this->read($task, true, 'server')))
157
+			{
158
+				return false;
159
+			}
154 160
 		}
155 161
 
156 162
 		if ($taskData['info_id_parent'])
@@ -190,11 +196,17 @@  discard block
 block discarded – undo
190 196
 				array2string($taskData)."\n",3,$this->logfile);
191 197
 		}
192 198
 
193
-		if (!isset($vcal)) $vcal = new Horde_Icalendar;
199
+		if (!isset($vcal))
200
+		{
201
+			$vcal = new Horde_Icalendar;
202
+		}
194 203
 		$vcal->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware InfoLog '.$GLOBALS['egw_info']['apps']['infolog']['version'].'//'.
195 204
 			strtoupper($GLOBALS['egw_info']['user']['preferences']['common']['lang']),array(),false);
196 205
 		$vcal->setAttribute('VERSION',$_version,array(),false);
197
-		if ($_method) $vcal->setAttribute('METHOD',$_method,array(),false);
206
+		if ($_method)
207
+		{
208
+			$vcal->setAttribute('METHOD',$_method,array(),false);
209
+		}
198 210
 
199 211
 		$tzid = $this->tzid;
200 212
 		if ($tzid && $tzid != 'UTC')
@@ -273,7 +285,10 @@  discard block
 block discarded – undo
273 285
 				//	__FILE__, __LINE__, PEAR_LOG_INFO);
274 286
 			}
275 287
 
276
-			if (empty($value) && ($size < 0 || $noTruncate)) continue;
288
+			if (empty($value) && ($size < 0 || $noTruncate))
289
+			{
290
+				continue;
291
+			}
277 292
 
278 293
 			if ($field == 'RELATED-TO')
279 294
 			{
@@ -402,7 +417,10 @@  discard block
 block discarded – undo
402 417
 				{
403 418
 					if ($name[2] == ':')
404 419
 					{
405
-						if (($v = json_php_unserialize($value)) && is_array($v)) $value = $v;
420
+						if (($v = json_php_unserialize($value)) && is_array($v))
421
+						{
422
+							$value = $v;
423
+						}
406 424
 						foreach((array)$value as $compvData)
407 425
 						{
408 426
 							$comp = Horde_Icalendar::newComponent(substr($name,3), $vevent);
@@ -530,7 +548,10 @@  discard block
 block discarded – undo
530 548
 			date_default_timezone_set($GLOBALS['egw_info']['server']['server_timezone']);
531 549
 		}
532 550
 
533
-		if (!$taskData) return false;
551
+		if (!$taskData)
552
+		{
553
+			return false;
554
+		}
534 555
 
535 556
 		// keep the dates
536 557
 		$this->time2time($taskData, $this->tzid, false);
@@ -576,7 +597,10 @@  discard block
 block discarded – undo
576 597
 			// remove all iCal fields not supported by EGroupware (stored like custom fields)
577 598
 			foreach(array_keys($old) as $name)
578 599
 			{
579
-				if (substr($name,0,2) == '##') unset($old[$name]);
600
+				if (substr($name,0,2) == '##')
601
+				{
602
+					unset($old[$name]);
603
+				}
580 604
 			}
581 605
 			// merge in again all infolog fields not supported by iCal or not allowed to change
582 606
 			$taskData = array_merge($taskData, $old);
@@ -722,7 +746,10 @@  discard block
 block discarded – undo
722 746
 						$component->setAttribute('PERCENT-COMPLETE', $percent_completed = $status == 'COMPLETED' ?
723 747
 							100 : ($status == 'NEEDS-ACTION' ? 0 : 10));
724 748
 					}
725
-					if ($this->log) error_log(__METHOD__."() setting STATUS='$status' and PERCENT-COMPLETE=$percent_completed from COMPLETED and X-INFOLOG-STATUS='$x_infolog_status'\n",3,$this->logfile);
749
+					if ($this->log)
750
+					{
751
+						error_log(__METHOD__."() setting STATUS='$status' and PERCENT-COMPLETE=$percent_completed from COMPLETED and X-INFOLOG-STATUS='$x_infolog_status'\n",3,$this->logfile);
752
+					}
726 753
 				}
727 754
 				// new task without status --> set a default status of NEEDS-ACTION, as otherwise task is marked closed
728 755
 				elseif($_taskID <= 0 && !is_scalar($x_infolog_status) && !is_scalar($completed))
@@ -731,12 +758,18 @@  discard block
 block discarded – undo
731 758
 				}
732 759
 				else
733 760
 				{
734
-					if ($this->log) error_log(__METHOD__."() no STATUS, X-INFOLOG-STATUS='$x_infolog_status', COMPLETED".(is_scalar($completed)?'='.$completed:' not set')." --> leaving status and percent unchanged",3,$this->logfile);
761
+					if ($this->log)
762
+					{
763
+						error_log(__METHOD__."() no STATUS, X-INFOLOG-STATUS='$x_infolog_status', COMPLETED".(is_scalar($completed)?'='.$completed:' not set')." --> leaving status and percent unchanged",3,$this->logfile);
764
+					}
735 765
 				}
736 766
 			}
737 767
 			foreach ($component->getAllAttributes() as $attribute)
738 768
 			{
739
-				if (!$attribute['value'] && $attribute['value'] !== '0') continue;
769
+				if (!$attribute['value'] && $attribute['value'] !== '0')
770
+				{
771
+					continue;
772
+				}
740 773
 
741 774
 				switch ($attribute['name'])
742 775
 				{
@@ -921,7 +954,10 @@  discard block
 block discarded – undo
921 954
 	 */
922 955
 	function exportVNOTE($_noteID, $_type, $charset='UTF-8')
923 956
 	{
924
-		if(!($note = $this->read($_noteID, true, 'server'))) return false;
957
+		if(!($note = $this->read($_noteID, true, 'server')))
958
+		{
959
+			return false;
960
+		}
925 961
 
926 962
 		$note = Api\Translation::convert($note,
927 963
 			Api\Translation::charset(), $charset);
@@ -1023,11 +1059,20 @@  discard block
 block discarded – undo
1023 1059
 				array2string($_vcalData)."\n",3,$this->logfile);
1024 1060
 		}
1025 1061
 
1026
-		if (!($note = $this->vnotetoegw($_vcalData, $_type, $_noteID, $charset))) return false;
1062
+		if (!($note = $this->vnotetoegw($_vcalData, $_type, $_noteID, $charset)))
1063
+		{
1064
+			return false;
1065
+		}
1027 1066
 
1028
-		if($_noteID > 0) $note['info_id'] = $_noteID;
1067
+		if($_noteID > 0)
1068
+		{
1069
+			$note['info_id'] = $_noteID;
1070
+		}
1029 1071
 
1030
-		if (empty($note['info_status'])) $note['info_status'] = 'done';
1072
+		if (empty($note['info_status']))
1073
+		{
1074
+			$note['info_status'] = 'done';
1075
+		}
1031 1076
 
1032 1077
 		if ($this->log)
1033 1078
 		{
@@ -1051,9 +1096,15 @@  discard block
 block discarded – undo
1051 1096
 	 */
1052 1097
 	function searchVNOTE($_vcalData, $_type, $contentID=null, $relax=false, $charset=null)
1053 1098
 	{
1054
-		if (!($note = $this->vnotetoegw($_vcalData, $_type, $contentID, $charset))) return array();
1099
+		if (!($note = $this->vnotetoegw($_vcalData, $_type, $contentID, $charset)))
1100
+		{
1101
+			return array();
1102
+		}
1055 1103
 
1056
-		if ($contentID)	$note['info_id'] = $contentID;
1104
+		if ($contentID)
1105
+		{
1106
+			$note['info_id'] = $contentID;
1107
+		}
1057 1108
 
1058 1109
 		unset($note['info_startdate']);
1059 1110
 
@@ -1105,7 +1156,10 @@  discard block
 block discarded – undo
1105 1156
 				{
1106 1157
 					$_data = Api\Translation::convert($_data, $charset, 'utf-8');
1107 1158
 				}
1108
-				if (!$vnote->parsevCalendar($_data, 'VCALENDAR'))	return false;
1159
+				if (!$vnote->parsevCalendar($_data, 'VCALENDAR'))
1160
+				{
1161
+					return false;
1162
+				}
1109 1163
 
1110 1164
 				$components = $vnote->getComponent();
1111 1165
 				foreach ($components as $component)
Please login to merge, or discard this patch.
infolog/inc/class.infolog_import_infologs_csv.inc.php 4 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -108,8 +108,7 @@  discard block
 block discarded – undo
108 108
 	/**
109 109
 	 * imports entries according to given definition object.
110 110
 	 * @param resource $_stream
111
-	 * @param string $_charset
112
-	 * @param definition $_definition
111
+	 * @param importexport_definition $_definition
113 112
 	 */
114 113
 	public function import( $_stream, importexport_definition $_definition ) {
115 114
 		$import_csv = new importexport_import_csv( $_stream, array(
@@ -527,6 +526,7 @@  discard block
 block discarded – undo
527 526
 	 *
528 527
 	 * This is a copy of what's in importexport_basic_import_csv, and can go
529 528
 	 * away if this is changed to extend it
529
+	 * @param integer $record_num
530 530
 	 */
531 531
 	protected function link_by_cf($record_num, $app, $fieldname, $_value)
532 532
 	{
Please login to merge, or discard this patch.
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -74,10 +74,10 @@  discard block
 block discarded – undo
74 74
 	private $boinfolog;
75 75
 
76 76
 	/**
77
-	* For figuring out if a record has changed
78
-	*
79
-	* @var infolog_tracking::
80
-	*/
77
+	 * For figuring out if a record has changed
78
+	 *
79
+	 * @var infolog_tracking::
80
+	 */
81 81
 	protected $tracking;
82 82
 
83 83
 	/**
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 	protected $errors = array();
102 102
 
103 103
 	/**
104
- 	* List of actions, and how many times that action was taken
104
+	 * List of actions, and how many times that action was taken
105 105
 	 */
106 106
 	protected $results = array();
107 107
 
@@ -466,37 +466,37 @@  discard block
 block discarded – undo
466 466
 	}
467 467
 
468 468
 	/**
469
-	* Returns warnings that were encountered during importing
470
-	* Maximum of one warning message per record, but you can append if you need to
471
-	*
472
-	* @return Array (
473
-	*       record_# => warning message
474
-	*       )
475
-	*/
469
+	 * Returns warnings that were encountered during importing
470
+	 * Maximum of one warning message per record, but you can append if you need to
471
+	 *
472
+	 * @return Array (
473
+	 *       record_# => warning message
474
+	 *       )
475
+	 */
476 476
 	public function get_warnings() {
477 477
 		return $this->warnings;
478 478
 	}
479 479
 
480 480
 	/**
481
-	* Returns errors that were encountered during importing
482
-	* Maximum of one error message per record, but you can append if you need to
483
-	*
484
-	* @return Array (
485
-	*       record_# => error message
486
-	*       )
487
-	*/
481
+	 * Returns errors that were encountered during importing
482
+	 * Maximum of one error message per record, but you can append if you need to
483
+	 *
484
+	 * @return Array (
485
+	 *       record_# => error message
486
+	 *       )
487
+	 */
488 488
 	public function get_errors() {
489 489
 		return $this->errors;
490 490
 	}
491 491
 
492 492
 	/**
493
-	* Returns a list of actions taken, and the number of records for that action.
494
-	* Actions are things like 'insert', 'update', 'delete', and may be different for each plugin.
495
-	*
496
-	* @return Array (
497
-	*       action => record count
498
-	* )
499
-	*/
493
+	 * Returns a list of actions taken, and the number of records for that action.
494
+	 * Actions are things like 'insert', 'update', 'delete', and may be different for each plugin.
495
+	 *
496
+	 * @return Array (
497
+	 *       action => record count
498
+	 * )
499
+	 */
500 500
 	public function get_results() {
501 501
 		return $this->results;
502 502
 	}
Please login to merge, or discard this patch.
Spacing   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -16,19 +16,19 @@  discard block
 block discarded – undo
16 16
 /**
17 17
  * class import_csv for infolog
18 18
  */
19
-class infolog_import_infologs_csv implements importexport_iface_import_plugin  {
19
+class infolog_import_infologs_csv implements importexport_iface_import_plugin {
20 20
 
21 21
 	private static $plugin_options = array(
22
-		'fieldsep', 		// char
23
-		'charset', 			// string
24
-		'contact_owner', 	// int
25
-		'update_cats', 			// string {override|add} overides record
22
+		'fieldsep', // char
23
+		'charset', // string
24
+		'contact_owner', // int
25
+		'update_cats', // string {override|add} overides record
26 26
 								// with cat(s) from csv OR add the cat from
27 27
 								// csv file to exeisting cat(s) of record
28 28
 		'num_header_lines', // int number of header lines
29 29
 		'field_conversion', // array( $csv_col_num => conversion)
30
-		'field_mapping',	// array( $csv_col_num => adb_filed)
31
-		'conditions',		/* => array containing condition arrays:
30
+		'field_mapping', // array( $csv_col_num => adb_filed)
31
+		'conditions', /* => array containing condition arrays:
32 32
 				'type' => exists, // exists
33 33
 				'string' => '#kundennummer',
34 34
 				'true' => array(
@@ -54,14 +54,14 @@  discard block
 block discarded – undo
54 54
 	/**
55 55
 	 * actions wich could be done to data entries
56 56
 	 */
57
-	protected static $actions = array( 'none', 'update', 'insert', 'delete', );
57
+	protected static $actions = array('none', 'update', 'insert', 'delete',);
58 58
 
59 59
 	/**
60 60
 	 * conditions for actions
61 61
 	 *
62 62
 	 * @var array
63 63
 	 */
64
-	protected static $conditions = array( 'exists' );
64
+	protected static $conditions = array('exists');
65 65
 
66 66
 	/**
67 67
 	 * @var definition
@@ -111,8 +111,8 @@  discard block
 block discarded – undo
111 111
 	 * @param string $_charset
112 112
 	 * @param definition $_definition
113 113
 	 */
114
-	public function import( $_stream, importexport_definition $_definition ) {
115
-		$import_csv = new importexport_import_csv( $_stream, array(
114
+	public function import($_stream, importexport_definition $_definition) {
115
+		$import_csv = new importexport_import_csv($_stream, array(
116 116
 			'fieldsep' => $_definition->plugin_options['fieldsep'],
117 117
 			'charset' => $_definition->plugin_options['charset'],
118 118
 		));
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 		$this->user = $GLOBALS['egw_info']['user']['account_id'];
123 123
 
124 124
 		// dry run?
125
-		$this->dry_run = isset( $_definition->plugin_options['dry_run'] ) ? $_definition->plugin_options['dry_run'] :  false;
125
+		$this->dry_run = isset($_definition->plugin_options['dry_run']) ? $_definition->plugin_options['dry_run'] : false;
126 126
 
127 127
 		// fetch the infolog bo
128 128
 		$this->boinfolog = new infolog_bo();
@@ -143,9 +143,9 @@  discard block
 block discarded – undo
143 143
 		$import_csv->conversion_class = $this;
144 144
 
145 145
 		//check if file has a header lines
146
-		if ( isset( $_definition->plugin_options['num_header_lines'] ) && $_definition->plugin_options['num_header_lines'] > 0) {
146
+		if (isset($_definition->plugin_options['num_header_lines']) && $_definition->plugin_options['num_header_lines'] > 0) {
147 147
 			$import_csv->skip_records($_definition->plugin_options['num_header_lines']);
148
-		} elseif(isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) {
148
+		} elseif (isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) {
149 149
 			// First method is preferred
150 150
 			$import_csv->skip_records(1);
151 151
 		}
@@ -170,18 +170,18 @@  discard block
 block discarded – undo
170 170
 		$this->errors = array();
171 171
 		$this->warnings = array();
172 172
 
173
-		while ( $record = $import_csv->get_record() ) {
173
+		while ($record = $import_csv->get_record()) {
174 174
 			$success = false;
175 175
 
176 176
 			// don't import empty records
177
-			if( count( array_unique( $record ) ) < 2 ) continue;
177
+			if (count(array_unique($record)) < 2) continue;
178 178
 
179 179
 			$lookups = $_lookups;
180 180
 
181 181
 			// Early detection of type, to load appropriate statuses
182
-			foreach(array($lookups['info_type'], array_map('strtolower',array_map('lang',$lookups['info_type']))) as $types)
182
+			foreach (array($lookups['info_type'], array_map('strtolower', array_map('lang', $lookups['info_type']))) as $types)
183 183
 			{
184
-				if($record['info_type'] && $key = array_search(strtolower($record['info_type']),$types))
184
+				if ($record['info_type'] && $key = array_search(strtolower($record['info_type']), $types))
185 185
 				{
186 186
 					$lookups['info_status'] = $this->boinfolog->status[$key];
187 187
 					break;
@@ -189,34 +189,34 @@  discard block
 block discarded – undo
189 189
 			}
190 190
 
191 191
 			$result = importexport_import_csv::convert($record, infolog_egw_record::$types, 'infolog', $lookups, $_definition->plugin_options['convert']);
192
-			if($result) $this->warnings[$import_csv->get_current_position()] = $result;
192
+			if ($result) $this->warnings[$import_csv->get_current_position()] = $result;
193 193
 
194 194
 			// Make sure type is valid
195
-			if(!$record['info_type'] || $record['info_type'] && !$this->boinfolog->enums['type'][$record['info_type']])
195
+			if (!$record['info_type'] || $record['info_type'] && !$this->boinfolog->enums['type'][$record['info_type']])
196 196
 			{
197 197
 				// Check for translated type
198
-				$un_trans = Api\Translation::get_message_id($record['info_type'],'infolog');
199
-				if($record['info_type'] && $this->boinfolog->enums['type'][$un_trans])
198
+				$un_trans = Api\Translation::get_message_id($record['info_type'], 'infolog');
199
+				if ($record['info_type'] && $this->boinfolog->enums['type'][$un_trans])
200 200
 				{
201 201
 					$record['info_type'] = $un_trans;
202 202
 				}
203 203
 				else
204 204
 				{
205
-					$this->errors[$import_csv->get_current_position()] .= ($this->errors[$import_csv->get_current_position()] ? "\n":'').
205
+					$this->errors[$import_csv->get_current_position()] .= ($this->errors[$import_csv->get_current_position()] ? "\n" : '').
206 206
 						lang('Unknown type: %1', $record['info_type']);
207 207
 				}
208 208
 			}
209 209
 
210 210
 			// Set default status for type, if not specified
211
-			if(!$record['info_status'] && $record['info_type'])
211
+			if (!$record['info_status'] && $record['info_type'])
212 212
 			{
213 213
 				$record['info_status'] = $this->boinfolog->status['defaults'][$record['info_type']];
214 214
 			}
215 215
 
216 216
 			// Set owner, unless it's supposed to come from CSV file
217
-			if($_definition->plugin_options['owner_from_csv'])
217
+			if ($_definition->plugin_options['owner_from_csv'])
218 218
 			{
219
-				if(!is_numeric($record['info_owner']))
219
+				if (!is_numeric($record['info_owner']))
220 220
 				{
221 221
 					$this->errors[$import_csv->get_current_position()] = lang(
222 222
 						'Invalid owner ID: %1.  Might be a bad field translation.  Used %2 instead.',
@@ -233,51 +233,51 @@  discard block
 block discarded – undo
233 233
 			if (!isset($record['info_owner'])) $record['info_owner'] = $GLOBALS['egw_info']['user']['account_id'];
234 234
 
235 235
 			// Responsible has to be an array
236
-			$record['info_responsible'] = $record['info_responsible'] ? explode(',',$record['info_responsible']) : 0;
236
+			$record['info_responsible'] = $record['info_responsible'] ? explode(',', $record['info_responsible']) : 0;
237 237
 
238 238
 			// Special values
239 239
 			if ($record['addressbook'] && !is_numeric($record['addressbook']))
240 240
 			{
241
-				list($lastname,$firstname,$org_name) = explode(',',$record['addressbook']);
242
-				$record['addressbook'] = importexport_basic_import_csv::addr_id($lastname,$firstname,$org_name);
241
+				list($lastname, $firstname, $org_name) = explode(',', $record['addressbook']);
242
+				$record['addressbook'] = importexport_basic_import_csv::addr_id($lastname, $firstname, $org_name);
243 243
 			}
244 244
 			if ($record['projectmanager'] && !is_numeric($record['projectmanager']))
245 245
 			{
246 246
 				$record['projectmanager'] = self::project_id($record['projectmanager']);
247 247
 			}
248 248
 
249
-			if ( $_definition->plugin_options['conditions'] )
249
+			if ($_definition->plugin_options['conditions'])
250 250
 			{
251
-				foreach ( $_definition->plugin_options['conditions'] as $condition )
251
+				foreach ($_definition->plugin_options['conditions'] as $condition)
252 252
 				{
253 253
 					$results = array();
254
-					switch ( $condition['type'] )
254
+					switch ($condition['type'])
255 255
 					{
256 256
 						// exists
257 257
 						case 'exists' :
258
-							if($record[$condition['string']]) {
259
-								$query['col_filter'] = array( $condition['string'] => $record[$condition['string']],);
258
+							if ($record[$condition['string']]) {
259
+								$query['col_filter'] = array($condition['string'] => $record[$condition['string']],);
260 260
 								// Needed to query custom fields
261
-								if($condition['string'][0] == '#') $query['custom_fields'] = true;
261
+								if ($condition['string'][0] == '#') $query['custom_fields'] = true;
262 262
 								$results = $this->boinfolog->search($query);
263 263
 							}
264 264
 
265
-							if ( is_array( $results ) && count( array_keys( $results )) >= 1) {
265
+							if (is_array($results) && count(array_keys($results)) >= 1) {
266 266
 								// apply action to all records matching this exists condition
267 267
 								$action = $condition['true'];
268
-								foreach ( (array)$results as $contact ) {
268
+								foreach ((array)$results as $contact) {
269 269
 									$record['info_id'] = $contact['info_id'];
270 270
 									$record['info_owner'] = $contact['info_owner'];
271
-									if ( $_definition->plugin_options['update_cats'] == 'add' ) {
272
-										if ( !is_array( $contact['cat_id'] ) ) $contact['cat_id'] = explode( ',', $contact['cat_id'] );
273
-										if ( !is_array( $record['cat_id'] ) ) $record['cat_id'] = explode( ',', $record['cat_id'] );
274
-										$record['cat_id'] = implode( ',', array_unique( array_merge( $record['cat_id'], $contact['cat_id'] ) ) );
271
+									if ($_definition->plugin_options['update_cats'] == 'add') {
272
+										if (!is_array($contact['cat_id'])) $contact['cat_id'] = explode(',', $contact['cat_id']);
273
+										if (!is_array($record['cat_id'])) $record['cat_id'] = explode(',', $record['cat_id']);
274
+										$record['cat_id'] = implode(',', array_unique(array_merge($record['cat_id'], $contact['cat_id'])));
275 275
 									}
276
-									$success = $this->action(  $action['action'], $record, $import_csv->get_current_position() );
276
+									$success = $this->action($action['action'], $record, $import_csv->get_current_position());
277 277
 								}
278 278
 							} else {
279 279
 								$action = $condition['false'];
280
-								$success = ($this->action(  $action['action'], $record, $import_csv->get_current_position() ));
280
+								$success = ($this->action($action['action'], $record, $import_csv->get_current_position()));
281 281
 							}
282 282
 							break;
283 283
 
@@ -292,14 +292,14 @@  discard block
 block discarded – undo
292 292
 			else
293 293
 			{
294 294
 				// unconditional insert
295
-				$success = $this->action( 'insert', $record, $import_csv->get_current_position() );
295
+				$success = $this->action('insert', $record, $import_csv->get_current_position());
296 296
 			}
297
-			if($success) $count++;
298
-			if($this->warnings[$import_csv->get_current_position()]) {
299
-				$this->warnings[$import_csv->get_current_position()] .= "\nRecord:\n" .array2string($record);
297
+			if ($success) $count++;
298
+			if ($this->warnings[$import_csv->get_current_position()]) {
299
+				$this->warnings[$import_csv->get_current_position()] .= "\nRecord:\n".array2string($record);
300 300
 			}
301
-			if($this->errors[$import_csv->get_current_position()]) {
302
-				$this->errors[$import_csv->get_current_position()] .= "\nRecord:\n" .array2string($record);
301
+			if ($this->errors[$import_csv->get_current_position()]) {
302
+				$this->errors[$import_csv->get_current_position()] .= "\nRecord:\n".array2string($record);
303 303
 			}
304 304
 		}
305 305
 		return $count;
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
 	 * @param array $_data contact data for the action
313 313
 	 * @return bool success or not
314 314
 	 */
315
-	private function action ( $_action, $_data, $record_num = 0 ) {
315
+	private function action($_action, $_data, $record_num = 0) {
316 316
 		$result = true;
317 317
 		switch ($_action) {
318 318
 			case 'none' :
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
 				// Only update if there are changes
322 322
 				$old = $this->boinfolog->read($_data['info_id']);
323 323
 
324
-				if(!$this->definition->plugin_options['change_owner']) {
324
+				if (!$this->definition->plugin_options['change_owner']) {
325 325
 					// Don't change addressbook of an existing contact
326 326
 					unset($_data['owner']);
327 327
 				}
@@ -329,19 +329,19 @@  discard block
 block discarded – undo
329 329
 				// Merge to deal with fields not in import record
330 330
 				$_data = array_merge($old, $_data);
331 331
 				$changed = $this->tracking->changed_fields($_data, $old);
332
-				if(count($changed) == 0 && !$this->definition->plugin_options['update_timestamp']) {
332
+				if (count($changed) == 0 && !$this->definition->plugin_options['update_timestamp']) {
333 333
 					break;
334 334
 				}
335 335
 
336 336
 				// Fall through
337 337
 			case 'insert' :
338
-				if ( $this->dry_run ) {
338
+				if ($this->dry_run) {
339 339
 					//print_r($_data);
340 340
 
341 341
 					// Check for link during dry run
342
-					if($_data['link_custom'])
342
+					if ($_data['link_custom'])
343 343
 					{
344
-						list($app, $app_id2) = explode(':', $_data['link_custom'],2);
344
+						list($app, $app_id2) = explode(':', $_data['link_custom'], 2);
345 345
 						$app_id = $this->link_by_cf($record_num, $app, $field, $app_id2);
346 346
 					}
347 347
 
@@ -349,12 +349,12 @@  discard block
 block discarded – undo
349 349
 					break;
350 350
 				} else {
351 351
 					$result = $this->boinfolog->write(
352
-						$_data, true, 2,true, 	// 2 = dont touch modification date
352
+						$_data, true, 2, true, // 2 = dont touch modification date
353 353
 						$this->definition->plugin_options['no_notification']
354 354
 					);
355
-					if(!$result)
355
+					if (!$result)
356 356
 					{
357
-						if($result === false)
357
+						if ($result === false)
358 358
 						{
359 359
 							$this->errors[$record_num] = lang('Permissions error - %1 could not %2',
360 360
 								$GLOBALS['egw']->accounts->id2name($_data['info_owner']),
@@ -377,17 +377,17 @@  discard block
 block discarded – undo
377 377
 		}
378 378
 
379 379
 		// Process some additional fields
380
-		if(!is_numeric($result)) {
380
+		if (!is_numeric($result)) {
381 381
 			return $result;
382 382
 		}
383 383
 		$info_link_id = $_data['info_link_id'];
384
-		foreach(array_keys(self::$special_fields) as $field) {
385
-			if(!$_data[$field]) continue;
386
-			if(strpos($field, 'link') === 0) {
387
-				list($app, $app_id) = explode(':', $_data[$field],2);
384
+		foreach (array_keys(self::$special_fields) as $field) {
385
+			if (!$_data[$field]) continue;
386
+			if (strpos($field, 'link') === 0) {
387
+				list($app, $app_id) = explode(':', $_data[$field], 2);
388 388
 
389 389
 				// Linking to another entry based on matching custom fields
390
-				if($field == 'link_custom')
390
+				if ($field == 'link_custom')
391 391
 				{
392 392
 					$app_id = $this->link_by_cf($record_num, $app, $field, $app_id);
393 393
 				}
@@ -398,14 +398,14 @@  discard block
 block discarded – undo
398 398
 			if ($app && $app_id) {
399 399
 				$id = $_data['info_id'] ? $_data['info_id'] : (int)$result;
400 400
 				//echo "<p>linking infolog:$id with $app:$app_id</p>\n";
401
-				$link_id = Link::link('infolog',$id,$app,$app_id);
401
+				$link_id = Link::link('infolog', $id, $app, $app_id);
402 402
 				if ($link_id && !$info_link_id)
403 403
 				{
404 404
 					$to_write = array(
405 405
 						'info_id'      => $id,
406 406
 						'info_link_id' => $link_id,
407 407
 					);
408
-					$this->boinfolog->write($to_write,False,false,true,true);	// last true = no notifications, as no real change
408
+					$this->boinfolog->write($to_write, False, false, true, true); // last true = no notifications, as no real change
409 409
 					$info_link_id = $link_id;
410 410
 				}
411 411
 			}
@@ -505,7 +505,7 @@  discard block
 block discarded – undo
505 505
 	// Extra conversion functions - must be static
506 506
 	public static function project_id($num_or_title)
507 507
 	{
508
-		static $boprojects=null;
508
+		static $boprojects = null;
509 509
 
510 510
 		if (!$num_or_title) return false;
511 511
 
@@ -532,18 +532,18 @@  discard block
 block discarded – undo
532 532
 	{
533 533
 		$app_id = false;
534 534
 
535
-		list($custom_field, $value) = explode(':',$_value);
535
+		list($custom_field, $value) = explode(':', $_value);
536 536
 		// Find matching entry
537
-		if($app && $custom_field && $value)
537
+		if ($app && $custom_field && $value)
538 538
 		{
539 539
 			$cfs = Api\Storage\Customfields::get($app);
540 540
 			// Error if no custom fields, probably something wrong in definition
541
-			if(!$cfs[$custom_field])
541
+			if (!$cfs[$custom_field])
542 542
 			{
543 543
 				// Check for users specifing label instead of name
544
-				foreach($cfs as $name => $settings)
544
+				foreach ($cfs as $name => $settings)
545 545
 				{
546
-					if(strtolower($settings['label']) == strtolower($custom_field))
546
+					if (strtolower($settings['label']) == strtolower($custom_field))
547 547
 					{
548 548
 						$custom_field = $name;
549 549
 						break;
@@ -552,23 +552,23 @@  discard block
 block discarded – undo
552 552
 			}
553 553
 
554 554
 			// Couldn't find field, give an error - something's wrong
555
-			if(!$cfs[$custom_field] && !$cfs[substr($custom_field,1)]) {
555
+			if (!$cfs[$custom_field] && !$cfs[substr($custom_field, 1)]) {
556 556
 				$this->errors[$record_num] .= lang('No custom field "%1" for %2.',
557 557
 					$custom_field, lang($app));
558 558
 				return false;
559 559
 			}
560
-			if($custom_field[0] != '#') $custom_field = '#' . $custom_field;
560
+			if ($custom_field[0] != '#') $custom_field = '#'.$custom_field;
561 561
 
562 562
 			// Search
563
-			if(Link::get_registry($app, 'query'))
563
+			if (Link::get_registry($app, 'query'))
564 564
 			{
565
-				$options = array('filter' => array("$custom_field = " . $GLOBALS['egw']->db->quote($value)));
565
+				$options = array('filter' => array("$custom_field = ".$GLOBALS['egw']->db->quote($value)));
566 566
 				$result = Link::query($app, '', $options);
567 567
 
568 568
 				// Only one allowed
569
-				if(count($result) != 1)
569
+				if (count($result) != 1)
570 570
 				{
571
-					$this->warnings[$record_num] .= ($this->warnings[$record_num] ? "\n" : '') .
571
+					$this->warnings[$record_num] .= ($this->warnings[$record_num] ? "\n" : '').
572 572
 						lang('Unable to link to %3 by custom field "%1": "%4".  %2 matches.',
573 573
 						$custom_field, count($result), lang($app), $options['filter'][0]
574 574
 					);
Please login to merge, or discard this patch.
Braces   +112 added lines, -43 removed lines patch added patch discarded remove patch
@@ -16,7 +16,8 @@  discard block
 block discarded – undo
16 16
 /**
17 17
  * class import_csv for infolog
18 18
  */
19
-class infolog_import_infologs_csv implements importexport_iface_import_plugin  {
19
+class infolog_import_infologs_csv implements importexport_iface_import_plugin
20
+{
20 21
 
21 22
 	private static $plugin_options = array(
22 23
 		'fieldsep', 		// char
@@ -111,7 +112,8 @@  discard block
 block discarded – undo
111 112
 	 * @param string $_charset
112 113
 	 * @param definition $_definition
113 114
 	 */
114
-	public function import( $_stream, importexport_definition $_definition ) {
115
+	public function import( $_stream, importexport_definition $_definition )
116
+	{
115 117
 		$import_csv = new importexport_import_csv( $_stream, array(
116 118
 			'fieldsep' => $_definition->plugin_options['fieldsep'],
117 119
 			'charset' => $_definition->plugin_options['charset'],
@@ -143,9 +145,12 @@  discard block
 block discarded – undo
143 145
 		$import_csv->conversion_class = $this;
144 146
 
145 147
 		//check if file has a header lines
146
-		if ( isset( $_definition->plugin_options['num_header_lines'] ) && $_definition->plugin_options['num_header_lines'] > 0) {
148
+		if ( isset( $_definition->plugin_options['num_header_lines'] ) && $_definition->plugin_options['num_header_lines'] > 0)
149
+		{
147 150
 			$import_csv->skip_records($_definition->plugin_options['num_header_lines']);
148
-		} elseif(isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line']) {
151
+		}
152
+		elseif(isset($_definition->plugin_options['has_header_line']) && $_definition->plugin_options['has_header_line'])
153
+		{
149 154
 			// First method is preferred
150 155
 			$import_csv->skip_records(1);
151 156
 		}
@@ -170,11 +175,15 @@  discard block
 block discarded – undo
170 175
 		$this->errors = array();
171 176
 		$this->warnings = array();
172 177
 
173
-		while ( $record = $import_csv->get_record() ) {
178
+		while ( $record = $import_csv->get_record() )
179
+		{
174 180
 			$success = false;
175 181
 
176 182
 			// don't import empty records
177
-			if( count( array_unique( $record ) ) < 2 ) continue;
183
+			if( count( array_unique( $record ) ) < 2 )
184
+			{
185
+				continue;
186
+			}
178 187
 
179 188
 			$lookups = $_lookups;
180 189
 
@@ -189,7 +198,10 @@  discard block
 block discarded – undo
189 198
 			}
190 199
 
191 200
 			$result = importexport_import_csv::convert($record, infolog_egw_record::$types, 'infolog', $lookups, $_definition->plugin_options['convert']);
192
-			if($result) $this->warnings[$import_csv->get_current_position()] = $result;
201
+			if($result)
202
+			{
203
+				$this->warnings[$import_csv->get_current_position()] = $result;
204
+			}
193 205
 
194 206
 			// Make sure type is valid
195 207
 			if(!$record['info_type'] || $record['info_type'] && !$this->boinfolog->enums['type'][$record['info_type']])
@@ -230,7 +242,10 @@  discard block
 block discarded – undo
230 242
 			{
231 243
 				$record['info_owner'] = $_definition->plugin_options['record_owner'];
232 244
 			}
233
-			if (!isset($record['info_owner'])) $record['info_owner'] = $GLOBALS['egw_info']['user']['account_id'];
245
+			if (!isset($record['info_owner']))
246
+			{
247
+				$record['info_owner'] = $GLOBALS['egw_info']['user']['account_id'];
248
+			}
234 249
 
235 250
 			// Responsible has to be an array
236 251
 			$record['info_responsible'] = $record['info_responsible'] ? explode(',',$record['info_responsible']) : 0;
@@ -255,27 +270,42 @@  discard block
 block discarded – undo
255 270
 					{
256 271
 						// exists
257 272
 						case 'exists' :
258
-							if($record[$condition['string']]) {
273
+							if($record[$condition['string']])
274
+							{
259 275
 								$query['col_filter'] = array( $condition['string'] => $record[$condition['string']],);
260 276
 								// Needed to query custom fields
261
-								if($condition['string'][0] == '#') $query['custom_fields'] = true;
277
+								if($condition['string'][0] == '#')
278
+								{
279
+									$query['custom_fields'] = true;
280
+								}
262 281
 								$results = $this->boinfolog->search($query);
263 282
 							}
264 283
 
265
-							if ( is_array( $results ) && count( array_keys( $results )) >= 1) {
284
+							if ( is_array( $results ) && count( array_keys( $results )) >= 1)
285
+							{
266 286
 								// apply action to all records matching this exists condition
267 287
 								$action = $condition['true'];
268
-								foreach ( (array)$results as $contact ) {
288
+								foreach ( (array)$results as $contact )
289
+								{
269 290
 									$record['info_id'] = $contact['info_id'];
270 291
 									$record['info_owner'] = $contact['info_owner'];
271
-									if ( $_definition->plugin_options['update_cats'] == 'add' ) {
272
-										if ( !is_array( $contact['cat_id'] ) ) $contact['cat_id'] = explode( ',', $contact['cat_id'] );
273
-										if ( !is_array( $record['cat_id'] ) ) $record['cat_id'] = explode( ',', $record['cat_id'] );
292
+									if ( $_definition->plugin_options['update_cats'] == 'add' )
293
+									{
294
+										if ( !is_array( $contact['cat_id'] ) )
295
+										{
296
+											$contact['cat_id'] = explode( ',', $contact['cat_id'] );
297
+										}
298
+										if ( !is_array( $record['cat_id'] ) )
299
+										{
300
+											$record['cat_id'] = explode( ',', $record['cat_id'] );
301
+										}
274 302
 										$record['cat_id'] = implode( ',', array_unique( array_merge( $record['cat_id'], $contact['cat_id'] ) ) );
275 303
 									}
276 304
 									$success = $this->action(  $action['action'], $record, $import_csv->get_current_position() );
277 305
 								}
278
-							} else {
306
+							}
307
+							else
308
+							{
279 309
 								$action = $condition['false'];
280 310
 								$success = ($this->action(  $action['action'], $record, $import_csv->get_current_position() ));
281 311
 							}
@@ -286,7 +316,10 @@  discard block
 block discarded – undo
286 316
 							die('condition / action not supported!!!');
287 317
 							break;
288 318
 					}
289
-					if ($action['last']) break;
319
+					if ($action['last'])
320
+					{
321
+						break;
322
+					}
290 323
 				}
291 324
 			}
292 325
 			else
@@ -294,11 +327,16 @@  discard block
 block discarded – undo
294 327
 				// unconditional insert
295 328
 				$success = $this->action( 'insert', $record, $import_csv->get_current_position() );
296 329
 			}
297
-			if($success) $count++;
298
-			if($this->warnings[$import_csv->get_current_position()]) {
330
+			if($success)
331
+			{
332
+				$count++;
333
+			}
334
+			if($this->warnings[$import_csv->get_current_position()])
335
+			{
299 336
 				$this->warnings[$import_csv->get_current_position()] .= "\nRecord:\n" .array2string($record);
300 337
 			}
301
-			if($this->errors[$import_csv->get_current_position()]) {
338
+			if($this->errors[$import_csv->get_current_position()])
339
+			{
302 340
 				$this->errors[$import_csv->get_current_position()] .= "\nRecord:\n" .array2string($record);
303 341
 			}
304 342
 		}
@@ -312,16 +350,19 @@  discard block
 block discarded – undo
312 350
 	 * @param array $_data contact data for the action
313 351
 	 * @return bool success or not
314 352
 	 */
315
-	private function action ( $_action, $_data, $record_num = 0 ) {
353
+	private function action ( $_action, $_data, $record_num = 0 )
354
+	{
316 355
 		$result = true;
317
-		switch ($_action) {
356
+		switch ($_action)
357
+		{
318 358
 			case 'none' :
319 359
 				return true;
320 360
 			case 'update' :
321 361
 				// Only update if there are changes
322 362
 				$old = $this->boinfolog->read($_data['info_id']);
323 363
 
324
-				if(!$this->definition->plugin_options['change_owner']) {
364
+				if(!$this->definition->plugin_options['change_owner'])
365
+				{
325 366
 					// Don't change addressbook of an existing contact
326 367
 					unset($_data['owner']);
327 368
 				}
@@ -329,13 +370,15 @@  discard block
 block discarded – undo
329 370
 				// Merge to deal with fields not in import record
330 371
 				$_data = array_merge($old, $_data);
331 372
 				$changed = $this->tracking->changed_fields($_data, $old);
332
-				if(count($changed) == 0 && !$this->definition->plugin_options['update_timestamp']) {
373
+				if(count($changed) == 0 && !$this->definition->plugin_options['update_timestamp'])
374
+				{
333 375
 					break;
334 376
 				}
335 377
 
336 378
 				// Fall through
337 379
 			case 'insert' :
338
-				if ( $this->dry_run ) {
380
+				if ( $this->dry_run )
381
+				{
339 382
 					//print_r($_data);
340 383
 
341 384
 					// Check for link during dry run
@@ -347,7 +390,9 @@  discard block
 block discarded – undo
347 390
 
348 391
 					$this->results[$_action]++;
349 392
 					break;
350
-				} else {
393
+				}
394
+				else
395
+				{
351 396
 					$result = $this->boinfolog->write(
352 397
 						$_data, true, 2,true, 	// 2 = dont touch modification date
353 398
 						$this->definition->plugin_options['no_notification']
@@ -377,13 +422,19 @@  discard block
 block discarded – undo
377 422
 		}
378 423
 
379 424
 		// Process some additional fields
380
-		if(!is_numeric($result)) {
425
+		if(!is_numeric($result))
426
+		{
381 427
 			return $result;
382 428
 		}
383 429
 		$info_link_id = $_data['info_link_id'];
384
-		foreach(array_keys(self::$special_fields) as $field) {
385
-			if(!$_data[$field]) continue;
386
-			if(strpos($field, 'link') === 0) {
430
+		foreach(array_keys(self::$special_fields) as $field)
431
+		{
432
+			if(!$_data[$field])
433
+			{
434
+				continue;
435
+			}
436
+			if(strpos($field, 'link') === 0)
437
+			{
387 438
 				list($app, $app_id) = explode(':', $_data[$field],2);
388 439
 
389 440
 				// Linking to another entry based on matching custom fields
@@ -391,11 +442,14 @@  discard block
 block discarded – undo
391 442
 				{
392 443
 					$app_id = $this->link_by_cf($record_num, $app, $field, $app_id);
393 444
 				}
394
-			} else {
445
+			}
446
+			else
447
+			{
395 448
 				$app = $field;
396 449
 				$app_id = $_data[$field];
397 450
 			}
398
-			if ($app && $app_id) {
451
+			if ($app && $app_id)
452
+			{
399 453
 				$id = $_data['info_id'] ? $_data['info_id'] : (int)$result;
400 454
 				//echo "<p>linking infolog:$id with $app:$app_id</p>\n";
401 455
 				$link_id = Link::link('infolog',$id,$app,$app_id);
@@ -418,7 +472,8 @@  discard block
 block discarded – undo
418 472
 	 *
419 473
 	 * @return string name
420 474
 	 */
421
-	public static function get_name() {
475
+	public static function get_name()
476
+	{
422 477
 		return lang('Infolog CSV import');
423 478
 	}
424 479
 
@@ -427,7 +482,8 @@  discard block
 block discarded – undo
427 482
 	 *
428 483
 	 * @return string descriprion
429 484
 	 */
430
-	public static function get_description() {
485
+	public static function get_description()
486
+	{
431 487
 		return lang("Imports entries into the infolog from a CSV File. CSV means 'Comma Seperated Values'. However in the options Tab you can also choose other seperators.");
432 488
 	}
433 489
 
@@ -436,7 +492,8 @@  discard block
 block discarded – undo
436 492
 	 *
437 493
 	 * @return string suffix (comma seperated)
438 494
 	 */
439
-	public static function get_filesuffix() {
495
+	public static function get_filesuffix()
496
+	{
440 497
 		return 'csv';
441 498
 	}
442 499
 
@@ -452,7 +509,8 @@  discard block
 block discarded – undo
452 509
 	 * 		preserv		=> array,
453 510
 	 * )
454 511
 	 */
455
-	public function get_options_etpl() {
512
+	public function get_options_etpl()
513
+	{
456 514
 		// lets do it!
457 515
 	}
458 516
 
@@ -461,7 +519,8 @@  discard block
 block discarded – undo
461 519
 	 *
462 520
 	 * @return string etemplate name
463 521
 	 */
464
-	public function get_selectors_etpl() {
522
+	public function get_selectors_etpl()
523
+	{
465 524
 		// lets do it!
466 525
 	}
467 526
 
@@ -473,7 +532,8 @@  discard block
 block discarded – undo
473 532
 	*       record_# => warning message
474 533
 	*       )
475 534
 	*/
476
-	public function get_warnings() {
535
+	public function get_warnings()
536
+	{
477 537
 		return $this->warnings;
478 538
 	}
479 539
 
@@ -485,7 +545,8 @@  discard block
 block discarded – undo
485 545
 	*       record_# => error message
486 546
 	*       )
487 547
 	*/
488
-	public function get_errors() {
548
+	public function get_errors()
549
+	{
489 550
 		return $this->errors;
490 551
 	}
491 552
 
@@ -497,7 +558,8 @@  discard block
 block discarded – undo
497 558
 	*       action => record count
498 559
 	* )
499 560
 	*/
500
-	public function get_results() {
561
+	public function get_results()
562
+	{
501 563
 		return $this->results;
502 564
 	}
503 565
 	// end of iface_export_plugin
@@ -507,7 +569,10 @@  discard block
 block discarded – undo
507 569
 	{
508 570
 		static $boprojects=null;
509 571
 
510
-		if (!$num_or_title) return false;
572
+		if (!$num_or_title)
573
+		{
574
+			return false;
575
+		}
511 576
 
512 577
 		if (!is_object($boprojects))
513 578
 		{
@@ -552,12 +617,16 @@  discard block
 block discarded – undo
552 617
 			}
553 618
 
554 619
 			// Couldn't find field, give an error - something's wrong
555
-			if(!$cfs[$custom_field] && !$cfs[substr($custom_field,1)]) {
620
+			if(!$cfs[$custom_field] && !$cfs[substr($custom_field,1)])
621
+			{
556 622
 				$this->errors[$record_num] .= lang('No custom field "%1" for %2.',
557 623
 					$custom_field, lang($app));
558 624
 				return false;
559 625
 			}
560
-			if($custom_field[0] != '#') $custom_field = '#' . $custom_field;
626
+			if($custom_field[0] != '#')
627
+			{
628
+				$custom_field = '#' . $custom_field;
629
+			}
561 630
 
562 631
 			// Search
563 632
 			if(Link::get_registry($app, 'query'))
Please login to merge, or discard this patch.
infolog/inc/class.infolog_so.inc.php 5 patches
Doc Comments   +1 added lines, -14 removed lines patch added patch discarded remove patch
@@ -85,6 +85,7 @@  discard block
 block discarded – undo
85 85
 	 * Check if user is responsible for an entry: he or one of his memberships is in responsible
86 86
 	 *
87 87
 	 * @param array $info infolog entry as array
88
+	 * @param integer $user
88 89
 	 * @return boolean
89 90
 	 */
90 91
 	function is_responsible($info,$user=null)
@@ -476,8 +477,6 @@  discard block
 block discarded – undo
476 477
 	 * changes or deletes entries with a spezified owner (for hook_delete_account)
477 478
 	 *
478 479
 	 * @param array $args hook arguments
479
-	 * @param int $args['account_id'] account to delete
480
-	 * @param int $args['new_owner']=0 new owner
481 480
 	 */
482 481
 	function change_delete_owner(array $args)  // new_owner=0 means delete
483 482
 	{
@@ -659,19 +658,7 @@  discard block
 block discarded – undo
659 658
 	/**
660 659
 	 * searches InfoLog for a certain pattern in $query
661 660
 	 *
662
-	 * @param string $query[order] column-name to sort after
663
-	 * @param string $query[sort] sort-order DESC or ASC
664
-	 * @param string $query[filter] string with combination of acl-, date- and status-filters, eg. 'own-open-today' or ''
665
-	 * @param int $query[cat_id] category to use or 0 or unset
666
-	 * @param string $query[search] pattern to search, search is done in info_from, info_subject and info_des
667
-	 * @param string $query[action] / $query[action_id] if only entries linked to a specified app/entry show be used
668 661
 	 * @param int &$query[start], &$query[total] nextmatch-parameters will be used and set if query returns less entries
669
-	 * @param array $query[col_filter] array with column-name - data pairs, data == '' means no filter (!)
670
-	 * @param boolean $query[subs] return subs or not, if unset the user preference is used
671
-	 * @param int $query[num_rows] number of rows to return if $query[start] is set, default is to use the value from the general prefs
672
-	 * @param string|array $query[cols]=null what to query, if set the recordset / iterator get's returned
673
-	 * @param string $query[append]=null get's appended to sql query, eg. for GROUP BY
674
-	 * @param boolean $query['custom_fields']=false query custom-fields too, default not
675 662
 	 * @return array|iterator with id's as key of the matching log-entries or recordset/iterator if cols is set
676 663
 	 */
677 664
 	function search(&$query)
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -248,7 +248,7 @@
 block discarded – undo
248 248
 				$filtermethod .= " OR (".$this->responsible_filter($this->user).
249 249
 					($filter == 'own' && count($public_user_list) ?	// offer's should show up in own, eg. startpage, but need read-access
250 250
 						" OR info_status = 'offer' AND $public_access" : '').")".
251
-				                 " AND (info_access='public'".($has_private_access?" OR $has_private_access":'').')';
251
+								 " AND (info_access='public'".($has_private_access?" OR $has_private_access":'').')';
252 252
 			}
253 253
 			elseif ($filter != 'my' && $filter != 'responsible')	// none --> all entrys user has rights to see
254 254
 			{
Please login to merge, or discard this patch.
Spacing   +159 added lines, -160 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	 * @param array $grants =array()
72 72
 	 * @return soinfolog
73 73
 	 */
74
-	function __construct( $grants=array() )
74
+	function __construct($grants = array())
75 75
 	{
76 76
 		$this->db     = clone($GLOBALS['egw']->db);
77 77
 		$this->db->set_app('infolog');
@@ -87,18 +87,18 @@  discard block
 block discarded – undo
87 87
 	 * @param array $info infolog entry as array
88 88
 	 * @return boolean
89 89
 	 */
90
-	function is_responsible($info,$user=null)
90
+	function is_responsible($info, $user = null)
91 91
 	{
92 92
 		if (!$user) $user = $this->user;
93 93
 
94 94
 		static $um_cache = array();
95
-		if ($user == $this->user) $user_and_memberships =& $um_cache[$user];
95
+		if ($user == $this->user) $user_and_memberships = & $um_cache[$user];
96 96
 		if (!isset($user_and_memberships))
97 97
 		{
98
-			$user_and_memberships = $GLOBALS['egw']->accounts->memberships($user,true);
98
+			$user_and_memberships = $GLOBALS['egw']->accounts->memberships($user, true);
99 99
 			$user_and_memberships[] = $user;
100 100
 		}
101
-		return $info['info_responsible'] && array_intersect((array)$info['info_responsible'],$user_and_memberships);
101
+		return $info['info_responsible'] && array_intersect((array)$info['info_responsible'], $user_and_memberships);
102 102
 	}
103 103
 
104 104
 	/**
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 	 * @param int $user =null user to check, default (null) $this->user
112 112
 	 * @return boolean True if access is granted else False
113 113
 	 */
114
-	function check_access( $info,$required_rights,$implicit_edit=false,array $grants=null,$user=null )
114
+	function check_access($info, $required_rights, $implicit_edit = false, array $grants = null, $user = null)
115 115
 	{
116 116
 		if (is_null($grants)) $grants = $this->grants;
117 117
 		if (!$user) $user = $this->user;
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 		{
124 124
 
125 125
 		}
126
-		elseif ((int) $info != $this->data['info_id'])      	// already loaded?
126
+		elseif ((int)$info != $this->data['info_id'])      	// already loaded?
127 127
 		{
128 128
 			// dont change our own internal data,
129 129
 			$backup_data = $this->data;
@@ -139,12 +139,12 @@  discard block
 block discarded – undo
139 139
 			return False;
140 140
 		}
141 141
 		$owner = $info['info_owner'];
142
-		$access_ok = $owner == $user ||	// user has all rights
142
+		$access_ok = $owner == $user || // user has all rights
143 143
 			// ACL only on public entrys || $owner granted _PRIVATE
144
-			(!!($grants[$owner] & $required_rights) ||
145
-				$this->is_responsible($info,$user) &&	// implicite rights for responsible user(s) and his memberships
144
+			(!!($grants[$owner]&$required_rights) ||
145
+				$this->is_responsible($info, $user) && // implicite rights for responsible user(s) and his memberships
146 146
 				($required_rights == Acl::READ || $required_rights == Acl::ADD || $implicit_edit && $required_rights == Acl::EDIT)) &&
147
-			($info['info_access'] == 'public' || !!($this->grants[$user] & Acl::PRIVAT));
147
+			($info['info_access'] == 'public' || !!($this->grants[$user]&Acl::PRIVAT));
148 148
 
149 149
 		// error_log(__METHOD__."($info[info_id],$required_rights,$implicit_edit,".array2string($grants).",$user) returning ".array2string($access_ok));
150 150
 		return $access_ok;
@@ -163,23 +163,22 @@  discard block
 block discarded – undo
163 163
 		if (!$users) return '0';
164 164
 
165 165
 		$responsible = array();
166
-		foreach((array)$users as $user)
166
+		foreach ((array)$users as $user)
167 167
 		{
168
-			$responsible = array_merge($responsible,(array)
169
-				($user > 0 ? $GLOBALS['egw']->accounts->memberships($user,true) :
170
-					$GLOBALS['egw']->accounts->members($user,true)));
168
+			$responsible = array_merge($responsible, (array)
169
+				($user > 0 ? $GLOBALS['egw']->accounts->memberships($user, true) : $GLOBALS['egw']->accounts->members($user, true)));
171 170
 			$responsible[] = $user;
172 171
 		}
173 172
 		if (is_array($users))
174 173
 		{
175 174
 			$responsible = array_unique($responsible);
176 175
 		}
177
-		foreach($responsible as $key => $uid)
176
+		foreach ($responsible as $key => $uid)
178 177
 		{
179
-			$responsible[$key] = $this->db->concat("','",'info_responsible',"','")." LIKE '%,$uid,%'";
178
+			$responsible[$key] = $this->db->concat("','", 'info_responsible', "','")." LIKE '%,$uid,%'";
180 179
 		}
181 180
 		//echo "<p align=right>responsible_filter($user) = ".'('.implode(' OR ',$responsible).')'."</p>\n";
182
-		return '('.implode(' OR ',$responsible).')';
181
+		return '('.implode(' OR ', $responsible).')';
183 182
 	}
184 183
 
185 184
 	/**
@@ -194,17 +193,17 @@  discard block
 block discarded – undo
194 193
 	function aclFilter($_filter = False)
195 194
 	{
196 195
 		$vars = null;
197
-		preg_match('/(my|responsible|delegated|own|privat|private|all|user)([0-9,-]*)/',$_filter,$vars);
196
+		preg_match('/(my|responsible|delegated|own|privat|private|all|user)([0-9,-]*)/', $_filter, $vars);
198 197
 		$filter = $vars[1];
199 198
 		$f_user = $vars[2];
200 199
 
201 200
 		if (isset($this->acl_filter[$filter.$f_user]))
202 201
 		{
203
-			return $this->acl_filter[$filter.$f_user];  // used cached filter if found
202
+			return $this->acl_filter[$filter.$f_user]; // used cached filter if found
204 203
 		}
205
-		if ($f_user && strpos($f_user,',') !== false)
204
+		if ($f_user && strpos($f_user, ',') !== false)
206 205
 		{
207
-			$f_user = explode(',',$f_user);
206
+			$f_user = explode(',', $f_user);
208 207
 		}
209 208
 
210 209
 		$filtermethod = " (info_owner=$this->user"; // user has all rights
@@ -221,24 +220,24 @@  discard block
 block discarded – undo
221 220
 		{
222 221
 			if (is_array($this->grants))
223 222
 			{
224
-				foreach($this->grants as $user => $grant)
223
+				foreach ($this->grants as $user => $grant)
225 224
 				{
226 225
 					// echo "<p>grants: user=$user, grant=$grant</p>";
227
-					if ($grant & (EGW_ACL_READ|EGW_ACL_EDIT))
226
+					if ($grant&(EGW_ACL_READ|EGW_ACL_EDIT))
228 227
 					{
229 228
 						$public_user_list[] = $user;
230 229
 					}
231
-					if ($grant & Acl::PRIVAT)
230
+					if ($grant&Acl::PRIVAT)
232 231
 					{
233 232
 						$private_user_list[] = $user;
234 233
 					}
235 234
 				}
236 235
 				if (count($private_user_list))
237 236
 				{
238
-					$has_private_access = $this->db->expression($this->info_table,array('info_owner' => $private_user_list));
237
+					$has_private_access = $this->db->expression($this->info_table, array('info_owner' => $private_user_list));
239 238
 				}
240 239
 			}
241
-			$public_access = $this->db->expression($this->info_table,array('info_owner' => $public_user_list));
240
+			$public_access = $this->db->expression($this->info_table, array('info_owner' => $public_user_list));
242 241
 			// implicit read-rights for responsible user
243 242
 			$filtermethod .= " OR (".$this->responsible_filter($this->user).')';
244 243
 
@@ -246,9 +245,9 @@  discard block
 block discarded – undo
246 245
 			if ($filter == 'private' || $filter == 'privat' || $filter == 'own')
247 246
 			{
248 247
 				$filtermethod .= " OR (".$this->responsible_filter($this->user).
249
-					($filter == 'own' && count($public_user_list) ?	// offer's should show up in own, eg. startpage, but need read-access
248
+					($filter == 'own' && count($public_user_list) ? // offer's should show up in own, eg. startpage, but need read-access
250 249
 						" OR info_status = 'offer' AND $public_access" : '').")".
251
-				                 " AND (info_access='public'".($has_private_access?" OR $has_private_access":'').')';
250
+				                 " AND (info_access='public'".($has_private_access ? " OR $has_private_access" : '').')';
252 251
 			}
253 252
 			elseif ($filter != 'my' && $filter != 'responsible')	// none --> all entrys user has rights to see
254 253
 			{
@@ -265,13 +264,13 @@  discard block
 block discarded – undo
265 264
 
266 265
 			if ($filter == 'user' && $f_user)
267 266
 			{
268
-				$filtermethod .= $this->db->expression($this->info_table,' AND (',array(
267
+				$filtermethod .= $this->db->expression($this->info_table, ' AND (', array(
269 268
 					'info_owner' => $f_user,
270
-				)," AND info_responsible='0' OR ",$this->responsible_filter($f_user),')');
269
+				), " AND info_responsible='0' OR ", $this->responsible_filter($f_user), ')');
271 270
 			}
272 271
 		}
273 272
 		//echo "<p>aclFilter(filter='$_filter',user='$f_user') = '$filtermethod', privat_user_list=".print_r($privat_user_list,True).", public_user_list=".print_r($public_user_list,True)."</p>\n";
274
-		return $this->acl_filter[$filter.$f_user] = $filtermethod;  // cache the filter
273
+		return $this->acl_filter[$filter.$f_user] = $filtermethod; // cache the filter
275 274
 	}
276 275
 
277 276
 	/**
@@ -281,18 +280,18 @@  discard block
 block discarded – undo
281 280
 	 * @param boolean $prefix_and =true if true prefix the fileter with ' AND '
282 281
 	 * @return string the necesary sql
283 282
 	 */
284
-	function statusFilter($_filter = '',$prefix_and=true)
283
+	function statusFilter($_filter = '', $prefix_and = true)
285 284
 	{
286 285
 		$vars = null;
287
-		preg_match('/(done|open|offer|deleted|\+deleted)/',$_filter,$vars);
286
+		preg_match('/(done|open|offer|deleted|\+deleted)/', $_filter, $vars);
288 287
 		$filter = $vars[1];
289 288
 
290 289
 		switch ($filter)
291 290
 		{
292 291
 			case 'done':	$filter = "info_status IN ('done','billed','cancelled')"; break;
293 292
 			case 'open':	$filter = "NOT (info_status IN ('done','billed','cancelled','deleted','template','nonactive','archive'))"; break;
294
-			case 'offer':	$filter = "info_status = 'offer'";    break;
295
-			case 'deleted': $filter = "info_status = 'deleted'";  break;
293
+			case 'offer':	$filter = "info_status = 'offer'"; break;
294
+			case 'deleted': $filter = "info_status = 'deleted'"; break;
296 295
 			case '+deleted':$filter = "NOT (info_status IN ('template','nonactive','archive'))"; break;
297 296
 			default:        $filter = "NOT (info_status IN ('deleted','template','nonactive','archive'))"; break;
298 297
 		}
@@ -313,18 +312,18 @@  discard block
 block discarded – undo
313 312
 	function dateFilter($_filter = '')
314 313
 	{
315 314
 		$vars = null;
316
-		preg_match('/(open-upcoming|upcoming|today|overdue|date|enddate)([-\\/.0-9]*)/',$_filter,$vars);
315
+		preg_match('/(open-upcoming|upcoming|today|overdue|date|enddate)([-\\/.0-9]*)/', $_filter, $vars);
317 316
 		$filter = $vars[1];
318 317
 
319
-		if (isset($vars[2]) && !empty($vars[2]) && ($date = preg_split('/[-\\/.]/',$vars[2])))
318
+		if (isset($vars[2]) && !empty($vars[2]) && ($date = preg_split('/[-\\/.]/', $vars[2])))
320 319
 		{
321
-			$today = mktime(-$this->tz_offset,0,0,intval($date[1]),intval($date[2]),intval($date[0]));
322
-			$tomorrow = mktime(-$this->tz_offset,0,0,intval($date[1]),intval($date[2])+1,intval($date[0]));
320
+			$today = mktime(-$this->tz_offset, 0, 0, intval($date[1]), intval($date[2]), intval($date[0]));
321
+			$tomorrow = mktime(-$this->tz_offset, 0, 0, intval($date[1]), intval($date[2]) + 1, intval($date[0]));
323 322
 		}
324 323
 		else
325 324
 		{
326
-			$now = getdate(time()-60*60*$this->tz_offset);
327
-			$tomorrow = mktime(-$this->tz_offset,0,0,$now['mon'],$now['mday']+1,$now['year']);
325
+			$now = getdate(time() - 60 * 60 * $this->tz_offset);
326
+			$tomorrow = mktime(-$this->tz_offset, 0, 0, $now['mon'], $now['mday'] + 1, $now['year']);
328 327
 		}
329 328
 		switch ($filter)
330 329
 		{
@@ -388,7 +387,7 @@  discard block
 block discarded – undo
388 387
 			$minimum_uid_length = 8;
389 388
 		}
390 389
 
391
-		if (!$where || !($this->data = $this->db->select($this->info_table,'*',$where,__LINE__,__FILE__)->fetch()))
390
+		if (!$where || !($this->data = $this->db->select($this->info_table, '*', $where, __LINE__, __FILE__)->fetch()))
392 391
 		{
393 392
 			$this->init( );
394 393
 			//error_log(__METHOD__.'('.array2string($where).') returning FALSE');
@@ -400,15 +399,15 @@  discard block
 block discarded – undo
400 399
 			$this->data['info_uid'] = Api\CalDAV::generate_uid('infolog', $this->data['info_id']);
401 400
 			$this->db->update($this->info_table,
402 401
 				array('info_uid' => $this->data['info_uid']),
403
-				array('info_id' => $this->data['info_id']), __LINE__,__FILE__);
402
+				array('info_id' => $this->data['info_id']), __LINE__, __FILE__);
404 403
 		}
405 404
 		if (!is_array($this->data['info_responsible']))
406 405
 		{
407
-			$this->data['info_responsible'] = $this->data['info_responsible'] ? explode(',',$this->data['info_responsible']) : array();
406
+			$this->data['info_responsible'] = $this->data['info_responsible'] ? explode(',', $this->data['info_responsible']) : array();
408 407
 		}
409 408
 		// Cast back to integer
410 409
 		$this->data['info_id_parent'] = (int)$this->data['info_id_parent'];
411
-		foreach($this->db->select($this->extra_table,'info_extra_name,info_extra_value',array('info_id'=>$this->data['info_id']),__LINE__,__FILE__) as $row)
410
+		foreach ($this->db->select($this->extra_table, 'info_extra_name,info_extra_value', array('info_id'=>$this->data['info_id']), __LINE__, __FILE__) as $row)
412 411
 		{
413 412
 			$this->data['#'.$row['info_extra_name']] = $row['info_extra_value'];
414 413
 		}
@@ -423,16 +422,16 @@  discard block
 block discarded – undo
423 422
 	 * @param boolean $delete_children delete the children, if not set there parent-id to $new_parent
424 423
 	 * @param int $new_parent new parent-id to set for subs
425 424
 	 */
426
-	function delete($info_id,$delete_children=True,$new_parent=0)  // did _not_ ensure ACL
425
+	function delete($info_id, $delete_children = True, $new_parent = 0)  // did _not_ ensure ACL
427 426
 	{
428 427
 		//echo "<p>soinfolog::delete($info_id,'$delete_children',$new_parent)</p>\n";
429
-		if ((int) $info_id <= 0)
428
+		if ((int)$info_id <= 0)
430 429
 		{
431 430
 			return;
432 431
 		}
433
-		$this->db->delete($this->info_table,array('info_id'=>$info_id),__LINE__,__FILE__);
434
-		$this->db->delete($this->extra_table,array('info_id'=>$info_id),__LINE__,__FILE__);
435
-		Link::unlink(0,'infolog',$info_id);
432
+		$this->db->delete($this->info_table, array('info_id'=>$info_id), __LINE__, __FILE__);
433
+		$this->db->delete($this->extra_table, array('info_id'=>$info_id), __LINE__, __FILE__);
434
+		Link::unlink(0, 'infolog', $info_id);
436 435
 
437 436
 		if ($this->data['info_id'] == $info_id)
438 437
 		{
@@ -441,17 +440,17 @@  discard block
 block discarded – undo
441 440
 		// delete children, if they are owned by the user
442 441
 		if ($delete_children)
443 442
 		{
444
-			$db2 = clone($this->db);	// we need an extra result-set
445
-			foreach($db2->select($this->info_table,'info_id',array(
443
+			$db2 = clone($this->db); // we need an extra result-set
444
+			foreach ($db2->select($this->info_table, 'info_id', array(
446 445
 					'info_id_parent'	=> $info_id,
447 446
 					'info_owner'		=> $this->user,
448
-				),__LINE__,__FILE__) as $row)
447
+				), __LINE__, __FILE__) as $row)
449 448
 			{
450 449
 				$this->delete($row['info_id'], $delete_children);
451 450
 			}
452 451
 		}
453 452
 		// set parent_id to $new_parent or 0 for all not deleted children
454
-		$this->db->update($this->info_table,array('info_id_parent'=>$new_parent),array('info_id_parent'=>$info_id),__LINE__,__FILE__);
453
+		$this->db->update($this->info_table, array('info_id_parent'=>$new_parent), array('info_id_parent'=>$info_id), __LINE__, __FILE__);
455 454
 	}
456 455
 
457 456
 	/**
@@ -463,9 +462,9 @@  discard block
 block discarded – undo
463 462
 	function get_children($info_id)
464 463
 	{
465 464
 		$children = array();
466
-		foreach($this->db->select($this->info_table, 'info_id,info_owner', array(
465
+		foreach ($this->db->select($this->info_table, 'info_id,info_owner', array(
467 466
 			'info_id_parent'	=> $info_id,
468
-		),__LINE__,__FILE__) as $row)
467
+		), __LINE__, __FILE__) as $row)
469 468
 		{
470 469
 			$children[$row['info_id']] = $row['info_owner'];
471 470
 		}
@@ -481,27 +480,27 @@  discard block
 block discarded – undo
481 480
 	 */
482 481
 	function change_delete_owner(array $args)  // new_owner=0 means delete
483 482
 	{
484
-		if (!(int) $args['new_owner'])
483
+		if (!(int)$args['new_owner'])
485 484
 		{
486
-			foreach($this->db->select($this->info_table,'info_id',array('info_owner'=>$args['account_id']),__LINE__,__FILE__,false,'','infolog') as $row)
485
+			foreach ($this->db->select($this->info_table, 'info_id', array('info_owner'=>$args['account_id']), __LINE__, __FILE__, false, '', 'infolog') as $row)
487 486
 			{
488
-				$this->delete($row['info_id'],False);
487
+				$this->delete($row['info_id'], False);
489 488
 			}
490 489
 		}
491 490
 		else
492 491
 		{
493
-			$this->db->update($this->info_table,array('info_owner'=>$args['new_owner']),array('info_owner'=>$args['account_id']),__LINE__,__FILE__,'infolog');
492
+			$this->db->update($this->info_table, array('info_owner'=>$args['new_owner']), array('info_owner'=>$args['account_id']), __LINE__, __FILE__, 'infolog');
494 493
 		}
495
-		foreach($this->db->select($this->info_table,'info_id,info_responsible',
496
-			$this->db->concat("','",'info_responsible',"','").' LIKE '.$this->db->quote('%,'.(int)$args['account_id'].',%'),
497
-			__LINE__,__FILE__,false,'','infolog') as $row)
494
+		foreach ($this->db->select($this->info_table, 'info_id,info_responsible',
495
+			$this->db->concat("','", 'info_responsible', "','").' LIKE '.$this->db->quote('%,'.(int)$args['account_id'].',%'),
496
+			__LINE__, __FILE__, false, '', 'infolog') as $row)
498 497
 		{
499
-			$new_responsible = explode(',',$row['info_responsible']);
500
-			unset($new_responsible[array_search($args['account_id'],$new_responsible)]);
498
+			$new_responsible = explode(',', $row['info_responsible']);
499
+			unset($new_responsible[array_search($args['account_id'], $new_responsible)]);
501 500
 			if ((int)$args['new_owner']) $new_responsible[] = (int)$args['new_owner'];
502
-			$this->db->update($this->info_table,array(
503
-				'info_responsible' => implode(',',$new_responsible),
504
-			),array('info_id' => $row['info_id']),__LINE__,__FILE__,'infolog');
501
+			$this->db->update($this->info_table, array(
502
+				'info_responsible' => implode(',', $new_responsible),
503
+			), array('info_id' => $row['info_id']), __LINE__, __FILE__, 'infolog');
505 504
 		}
506 505
 	}
507 506
 
@@ -513,7 +512,7 @@  discard block
 block discarded – undo
513 512
 	 * @param string $purge_cfs =null null=dont, 'ical'=only iCal X-properties (cfs name starting with "#"), 'all'=all cfs
514 513
 	 * @return int|boolean info_id, false on error or 0 if the entry has been updated in the meantime
515 514
 	 */
516
-	function write($values, $check_modified=0, $purge_cfs=null)  // did _not_ ensure ACL
515
+	function write($values, $check_modified = 0, $purge_cfs = null)  // did _not_ ensure ACL
517 516
 	{
518 517
 		if (isset($GLOBALS['egw_info']['user']['preferences']['syncml']['minimum_uid_length']))
519 518
 		{
@@ -525,19 +524,19 @@  discard block
 block discarded – undo
525 524
 		}
526 525
 
527 526
 		//echo "soinfolog::write(,$check_modified) values="; _debug_array($values);
528
-		$info_id = (int) $values['info_id'];
527
+		$info_id = (int)$values['info_id'];
529 528
 
530
-		if (array_key_exists('info_responsible',$values))	// isset($values['info_responsible']) returns false for NULL!
529
+		if (array_key_exists('info_responsible', $values))	// isset($values['info_responsible']) returns false for NULL!
531 530
 		{
532
-			$values['info_responsible'] = $values['info_responsible'] ? implode(',',$values['info_responsible']) : '0';
531
+			$values['info_responsible'] = $values['info_responsible'] ? implode(',', $values['info_responsible']) : '0';
533 532
 		}
534
-		$table_def = $this->db->get_table_definitions('infolog',$this->info_table);
533
+		$table_def = $this->db->get_table_definitions('infolog', $this->info_table);
535 534
 		$to_write = array();
536
-		foreach($values as $key => $val)
535
+		foreach ($values as $key => $val)
537 536
 		{
538 537
 			if ($key != 'info_id' && isset($table_def['fd'][$key]))
539 538
 			{
540
-				$to_write[$key] = $this->data[$key] = $val;   // update internal data
539
+				$to_write[$key] = $this->data[$key] = $val; // update internal data
541 540
 			}
542 541
 		}
543 542
 		// writing no price as SQL NULL (required by postgres)
@@ -547,23 +546,23 @@  discard block
 block discarded – undo
547 546
 		{
548 547
 			$where = array('info_id' => $info_id);
549 548
 			if ($check_modified) $where['info_datemodified'] = $check_modified;
550
-			if (!$this->db->update($this->info_table,$to_write,$where,__LINE__,__FILE__))
549
+			if (!$this->db->update($this->info_table, $to_write, $where, __LINE__, __FILE__))
551 550
 			{
552 551
 				//error_log("### soinfolog::write(".print_r($to_write,true).") where=".print_r($where,true)." returning false");
553
-				return false;	// Error
552
+				return false; // Error
554 553
 			}
555 554
 			if ($check_modified && $this->db->affected_rows() < 1)
556 555
 			{
557 556
 				//error_log("### soinfolog::write(".print_r($to_write,true).") where=".print_r($where,true)." returning 0 (nothing updated, eg. condition not met)");
558
-				return 0;	// someone else updated the modtime or deleted the entry
557
+				return 0; // someone else updated the modtime or deleted the entry
559 558
 			}
560 559
 		}
561 560
 		else
562 561
 		{
563
-			if (!isset($to_write['info_id_parent'])) $to_write['info_id_parent'] = 0;	// must not be null
562
+			if (!isset($to_write['info_id_parent'])) $to_write['info_id_parent'] = 0; // must not be null
564 563
 
565
-			$this->db->insert($this->info_table,$to_write,false,__LINE__,__FILE__);
566
-			$info_id = $this->data['info_id'] = $this->db->get_last_insert_id($this->info_table,'info_id');
564
+			$this->db->insert($this->info_table, $to_write, false, __LINE__, __FILE__);
565
+			$info_id = $this->data['info_id'] = $this->db->get_last_insert_id($this->info_table, 'info_id');
567 566
 		}
568 567
 
569 568
 		$update = array();
@@ -579,8 +578,8 @@  discard block
 block discarded – undo
579 578
 		}
580 579
 		if ($update)
581 580
 		{
582
-			$this->db->update($this->info_table,$update,
583
-				array('info_id' => $info_id), __LINE__,__FILE__);
581
+			$this->db->update($this->info_table, $update,
582
+				array('info_id' => $info_id), __LINE__, __FILE__);
584 583
 		}
585 584
 
586 585
 		//echo "<p>soinfolog.write values= "; _debug_array($values);
@@ -590,38 +589,38 @@  discard block
 block discarded – undo
590 589
 		{
591 590
 			$where = array('info_id' => $info_id);
592 591
 			if ($purge_cfs == 'ical') $where[] = "info_extra_name LIKE '#%'";
593
-			$this->db->delete($this->extra_table,$where,__LINE__,__FILE__);
592
+			$this->db->delete($this->extra_table, $where, __LINE__, __FILE__);
594 593
 		}
595 594
 		$to_delete = array();
596
-		foreach($values as $key => $val)
595
+		foreach ($values as $key => $val)
597 596
 		{
598 597
 			if ($key[0] != '#')
599 598
 			{
600
-				continue;	// no customfield
599
+				continue; // no customfield
601 600
 			}
602
-			$this->data[$key] = $val;	// update internal data
601
+			$this->data[$key] = $val; // update internal data
603 602
 
604 603
 			if ($val)
605 604
 			{
606
-				$this->db->insert($this->extra_table,array(
605
+				$this->db->insert($this->extra_table, array(
607 606
 						// store multivalued CalDAV properties as serialized array, everything else get comma-separated
608
-						'info_extra_value'	=> is_array($val) ? ($key[1] == '#' ? serialize($val) : implode(',',$val)) : $val,
609
-					),array(
607
+						'info_extra_value'	=> is_array($val) ? ($key[1] == '#' ? serialize($val) : implode(',', $val)) : $val,
608
+					), array(
610 609
 						'info_id'			=> $info_id,
611
-						'info_extra_name'	=> substr($key,1),
612
-					),__LINE__,__FILE__);
610
+						'info_extra_name'	=> substr($key, 1),
611
+					), __LINE__, __FILE__);
613 612
 			}
614 613
 			else
615 614
 			{
616
-				$to_delete[] = substr($key,1);
615
+				$to_delete[] = substr($key, 1);
617 616
 			}
618 617
 		}
619 618
 		if ($to_delete && !$purge_cfs)
620 619
 		{
621
-			$this->db->delete($this->extra_table,array(
620
+			$this->db->delete($this->extra_table, array(
622 621
 					'info_id'			=> $info_id,
623 622
 					'info_extra_name'	=> $to_delete,
624
-				),__LINE__,__FILE__);
623
+				), __LINE__, __FILE__);
625 624
 		}
626 625
 		// echo "<p>soinfolog.write this->data= "; _debug_array($this->data);
627 626
 		//error_log("### soinfolog::write(".print_r($to_write,true).") where=".print_r($where,true)." returning id=".$this->data['info_id']);
@@ -637,18 +636,18 @@  discard block
 block discarded – undo
637 636
 	 * @param int|array $info_id id(s) of log-entry
638 637
 	 * @return int|array the number of sub-entries or indexed by info_id, if array as param given
639 638
 	 */
640
-	function anzSubs( $info_id )
639
+	function anzSubs($info_id)
641 640
 	{
642 641
 		if (!is_array($info_id) || !$info_id)
643 642
 		{
644 643
 			if ((int)$info_id <= 0) return 0;
645 644
 		}
646 645
 		$counts = array();
647
-		foreach($this->db->select($this->info_table,'info_id_parent,COUNT(*) AS info_anz_subs',array(
646
+		foreach ($this->db->select($this->info_table, 'info_id_parent,COUNT(*) AS info_anz_subs', array(
648 647
 			'info_id_parent' => $info_id,
649
-			"info_status != 'deleted'",	// dont count deleted subs as subs, as they are not shown by default
650
-		),__LINE__,__FILE__,
651
-			false,'GROUP BY info_id_parent','infolog') as $row)
648
+			"info_status != 'deleted'", // dont count deleted subs as subs, as they are not shown by default
649
+		), __LINE__, __FILE__,
650
+			false, 'GROUP BY info_id_parent', 'infolog') as $row)
652 651
 		{
653 652
 			$counts[$row['info_id_parent']] = (int)$row['info_anz_subs'];
654 653
 		}
@@ -688,102 +687,102 @@  discard block
 block discarded – undo
688 687
 			$action = isset($action2app[$query['action']]) ? $action2app[$query['action']] : $query['action'];
689 688
 			if ($action)
690 689
 			{
691
-				$links = Link\Storage::get_links($action=='sp'?'infolog':$action,
692
-					is_array($query['action_id']) ? $query['action_id'] : explode(',',$query['action_id']),'infolog','',$query['col_filter']['info_status'] =='deleted');
690
+				$links = Link\Storage::get_links($action == 'sp' ? 'infolog' : $action,
691
+					is_array($query['action_id']) ? $query['action_id'] : explode(',', $query['action_id']), 'infolog', '', $query['col_filter']['info_status'] == 'deleted');
693 692
 
694 693
 				if (count($links))
695 694
 				{
696
-					$links = call_user_func_array('array_merge',$links);	// flatten the array
697
-					$link_extra = ($action == 'sp' ? 'OR' : 'AND')." main.info_id IN (".implode(',',$links).')';
695
+					$links = call_user_func_array('array_merge', $links); // flatten the array
696
+					$link_extra = ($action == 'sp' ? 'OR' : 'AND')." main.info_id IN (".implode(',', $links).')';
698 697
 				}
699 698
 			}
700 699
 		}
701
-		$sortbycf='';
702
-		if (!empty($query['order']) && (preg_match('/^[a-z_0-9, ]+$/i',$query['order']) || stripos($query['order'],'#')!==FALSE ) &&
703
-			(empty($query['sort']) || preg_match('/^(DESC|ASC)$/i',$query['sort'])))
700
+		$sortbycf = '';
701
+		if (!empty($query['order']) && (preg_match('/^[a-z_0-9, ]+$/i', $query['order']) || stripos($query['order'], '#') !== FALSE) &&
702
+			(empty($query['sort']) || preg_match('/^(DESC|ASC)$/i', $query['sort'])))
704 703
 		{
705 704
 			$order = array();
706
-			foreach(explode(',',$query['order']) as $val)
705
+			foreach (explode(',', $query['order']) as $val)
707 706
 			{
708 707
 				$val = trim($val);
709 708
 				if ($val[0] == '#')
710 709
 				{
711
-					$sortbycf = substr($val,1);
710
+					$sortbycf = substr($val, 1);
712 711
 					$val = "cfsortcrit IS NULL,cfsortcrit";
713 712
 				}
714 713
 				else
715 714
 				{
716 715
 					static $table_def = null;
717
-					if (is_null($table_def)) $table_def = $this->db->get_table_definitions('infolog',$this->info_table);
718
-					if (substr($val,0,5) != 'info_' && isset($table_def['fd']['info_'.$val])) $val = 'info_'.$val;
716
+					if (is_null($table_def)) $table_def = $this->db->get_table_definitions('infolog', $this->info_table);
717
+					if (substr($val, 0, 5) != 'info_' && isset($table_def['fd']['info_'.$val])) $val = 'info_'.$val;
719 718
 					if ($val == 'info_des' && $this->db->capabilities['order_on_text'] !== true)
720 719
 					{
721 720
 						if (!$this->db->capabilities['order_on_text']) continue;
722 721
 
723
-						$val = sprintf($this->db->capabilities['order_on_text'],$val);
722
+						$val = sprintf($this->db->capabilities['order_on_text'], $val);
724 723
 					}
725 724
 				}
726 725
 				$order[] = $val;
727 726
 			}
728
-			$ordermethod = 'ORDER BY ' . implode(',',$order) . ' ' . $query['sort'];
727
+			$ordermethod = 'ORDER BY '.implode(',', $order).' '.$query['sort'];
729 728
 		}
730 729
 		else
731 730
 		{
732
-			$ordermethod = 'ORDER BY info_datemodified DESC';   // newest first
731
+			$ordermethod = 'ORDER BY info_datemodified DESC'; // newest first
733 732
 		}
734 733
 		$filtermethod = $this->aclFilter($query['filter']);
735 734
 		if (!$query['col_filter']['info_status'])  $filtermethod .= $this->statusFilter($query['filter']);
736 735
 		$filtermethod .= $this->dateFilter($query['filter']);
737
-		$cfcolfilter=0;
736
+		$cfcolfilter = 0;
738 737
 		if (is_array($query['col_filter']))
739 738
 		{
740
-			foreach($query['col_filter'] as $col => $data)
739
+			foreach ($query['col_filter'] as $col => $data)
741 740
 			{
742 741
 				if (is_int($col))
743 742
 				{
744 743
 					$filtermethod .= ' AND '.$data;
745 744
 					continue;
746 745
 				}
747
-				if ($col[0] != '#' && substr($col,0,5) != 'info_' && isset($table_def['fd']['info_'.$col])) $col = 'info_'.$col;
748
-				if ((string)$data !== '' && preg_match('/^[a-z_0-9]+$/i',$col))
746
+				if ($col[0] != '#' && substr($col, 0, 5) != 'info_' && isset($table_def['fd']['info_'.$col])) $col = 'info_'.$col;
747
+				if ((string)$data !== '' && preg_match('/^[a-z_0-9]+$/i', $col))
749 748
 				{
750 749
 					switch ($col)
751 750
 					{
752 751
 						case 'info_responsible':
753
-							$data = (int) $data;
752
+							$data = (int)$data;
754 753
 							if (!$data) continue;
755 754
 							$filtermethod .= ' AND ('.$this->responsible_filter($data)." OR info_responsible='0' AND ".
756
-								$this->db->expression($this->info_table,array(
757
-									'info_owner' => $data > 0 ? $data : $GLOBALS['egw']->accounts->members($data,true)
755
+								$this->db->expression($this->info_table, array(
756
+									'info_owner' => $data > 0 ? $data : $GLOBALS['egw']->accounts->members($data, true)
758 757
 								)).')';
759 758
 							break;
760 759
 
761 760
 						case 'info_id':	// info_id itself is ambigous
762
-							$filtermethod .= ' AND '.$this->db->expression($this->info_table,'main.',array('info_id' => $data));
761
+							$filtermethod .= ' AND '.$this->db->expression($this->info_table, 'main.', array('info_id' => $data));
763 762
 							break;
764 763
 
765 764
 						default:
766
-							$filtermethod .= ' AND '.$this->db->expression($this->info_table,array($col => $data));
765
+							$filtermethod .= ' AND '.$this->db->expression($this->info_table, array($col => $data));
767 766
 							break;
768 767
 					}
769 768
 				}
770
-				if ($col[0] == '#' &&  $query['custom_fields'] && $data)
769
+				if ($col[0] == '#' && $query['custom_fields'] && $data)
771 770
 				{
772 771
 					$filtermethod .= " AND main.info_id IN (SELECT DISTINCT info_id FROM $this->extra_table WHERE ";
773 772
 					$custom_fields = Api\Storage\Customfields::get('infolog');
774 773
 
775
-					if($custom_fields[substr($col,1)]['type'] == 'select' && $custom_fields[substr($col,1)]['rows'] > 1)
774
+					if ($custom_fields[substr($col, 1)]['type'] == 'select' && $custom_fields[substr($col, 1)]['rows'] > 1)
776 775
 					{
777 776
 						// Multi-select - any entry with the filter value selected matches
778 777
 						$filtermethod .= $this->db->expression($this->extra_table, array(
779
-							'info_extra_name' => substr($col,1),
780
-							$this->db->concat("','",'info_extra_value',"','").' '.$this->db->capabilities[Api\Db::CAPABILITY_CASE_INSENSITIV_LIKE].' '.$this->db->quote('%,'.$data.',%'),
778
+							'info_extra_name' => substr($col, 1),
779
+							$this->db->concat("','", 'info_extra_value', "','").' '.$this->db->capabilities[Api\Db::CAPABILITY_CASE_INSENSITIV_LIKE].' '.$this->db->quote('%,'.$data.',%'),
781 780
 						)).')';
782 781
 					}
783 782
 					else
784 783
 					{
785
-						$filtermethod .= $this->db->expression($this->extra_table,array(
786
-							'info_extra_name'  => substr($col,1),
784
+						$filtermethod .= $this->db->expression($this->extra_table, array(
785
+							'info_extra_name'  => substr($col, 1),
787 786
 							'info_extra_value' => $data,
788 787
 						)).')';
789 788
 					}
@@ -795,15 +794,15 @@  discard block
 block discarded – undo
795 794
 
796 795
 		if ((int)$query['cat_id'])
797 796
 		{
798
-			$categories = new Api\Categories('','infolog');
797
+			$categories = new Api\Categories('', 'infolog');
799 798
 			$cats = $categories->return_all_children((int)$query['cat_id']);
800
-			$filtermethod .= ' AND info_cat'.(count($cats)>1? ' IN ('.implode(',',$cats).') ' : '='.(int)$query['cat_id']);
799
+			$filtermethod .= ' AND info_cat'.(count($cats) > 1 ? ' IN ('.implode(',', $cats).') ' : '='.(int)$query['cat_id']);
801 800
 		}
802 801
 		$join = $distinct = '';
803
-		if ($query['query']) $query['search'] = $query['query'];	// allow both names
802
+		if ($query['query']) $query['search'] = $query['query']; // allow both names
804 803
 		if ($query['search'])			  // we search in _from, _subject, _des and _extra_value for $query
805 804
 		{
806
-			$columns = array('info_from','info_addr','info_location','info_subject','info_extra_value');
805
+			$columns = array('info_from', 'info_addr', 'info_location', 'info_subject', 'info_extra_value');
807 806
 			// at the moment MaxDB 7.5 cant cast nor search text columns, it's suppost to change in 7.6
808 807
 			if ($this->db->capabilities['like_on_text']) $columns[] = 'info_des';
809 808
 
@@ -811,13 +810,13 @@  discard block
 block discarded – undo
811 810
 			$so_sql = new Api\Storage\Base('infolog', $this->info_table, $this->db);
812 811
 			$search = $so_sql->search2criteria($query['search'], $wildcard, $op, null, $columns);
813 812
 			$sql_query = 'AND ('.(is_numeric($query['search']) ? 'main.info_id='.(int)$query['search'].' OR ' : '').
814
-				implode($op, $search) .')';
813
+				implode($op, $search).')';
815 814
 
816
-			$join = ($cfcolfilter>0 ? '':'LEFT')." JOIN $this->extra_table ON main.info_id=$this->extra_table.info_id ";
815
+			$join = ($cfcolfilter > 0 ? '' : 'LEFT')." JOIN $this->extra_table ON main.info_id=$this->extra_table.info_id ";
817 816
 			// mssql and others cant use DISTICT if text columns (info_des) are involved
818 817
 			$distinct = $this->db->capabilities['distinct_on_text'] ? 'DISTINCT' : '';
819 818
 		}
820
-		$pid = 'AND ' . $this->db->expression($this->info_table,array('info_id_parent' => ($action == 'sp' ?$query['action_id'] : 0)));
819
+		$pid = 'AND '.$this->db->expression($this->info_table, array('info_id_parent' => ($action == 'sp' ? $query['action_id'] : 0)));
821 820
 
822 821
 		if ($GLOBALS['egw_info']['user']['preferences']['infolog']['listNoSubs'] != '1' && $action != 'sp' ||
823 822
 			(string)$query['col_filter']['info_id_parent'] !== '' ||
@@ -838,14 +837,14 @@  discard block
 block discarded – undo
838 837
 			}
839 838
 			else
840 839
 			{
841
-				$query['total'] = $this->db->query($sql="SELECT $distinct main.info_id ".$sql_query,__LINE__,__FILE__)->NumRows();
840
+				$query['total'] = $this->db->query($sql = "SELECT $distinct main.info_id ".$sql_query, __LINE__, __FILE__)->NumRows();
842 841
 			}
843 842
 			$info_customfield = '';
844 843
 			if ($sortbycf != '')
845 844
 			{
846 845
 				$sort_col = "(SELECT DISTINCT info_extra_value FROM $this->extra_table sub2 WHERE sub2.info_id=main.info_id AND info_extra_name=".$this->db->quote($sortbycf).")";
847 846
 				if (!isset($custom_fields)) $custom_fields = Api\Storage\Customfields::get('infolog');
848
-				switch($custom_fields[$sortbycf]['type'])
847
+				switch ($custom_fields[$sortbycf]['type'])
849 848
 				{
850 849
 					case 'int':
851 850
 						$sort_col = $this->db->to_int($sort_col);
@@ -864,9 +863,9 @@  discard block
 block discarded – undo
864 863
 					$query['start'] = 0;
865 864
 				}
866 865
 				$cols = isset($query['cols']) ? $query['cols'] : 'main.*';
867
-				if (is_array($cols)) $cols = implode(',',$cols);
868
-				$rs = $this->db->query($sql='SELECT '.$mysql_calc_rows.' '.$distinct.' '.$cols.' '.$info_customfield.' '.$sql_query.$query['append'].' '.$ordermethod,__LINE__,__FILE__,
869
-					(int) $query['start'],isset($query['start']) ? (int) $query['num_rows'] : -1,false,Api\Db::FETCH_ASSOC);
866
+				if (is_array($cols)) $cols = implode(',', $cols);
867
+				$rs = $this->db->query($sql = 'SELECT '.$mysql_calc_rows.' '.$distinct.' '.$cols.' '.$info_customfield.' '.$sql_query.$query['append'].' '.$ordermethod, __LINE__, __FILE__,
868
+					(int)$query['start'], isset($query['start']) ? (int)$query['num_rows'] : -1, false, Api\Db::FETCH_ASSOC);
870 869
 				//echo "<p>db::query('$sql',,,".(int)$query['start'].','.(isset($query['start']) ? (int) $query['num_rows'] : -1).")</p>\n";
871 870
 
872 871
 				if ($mysql_calc_rows)
@@ -881,9 +880,9 @@  discard block
 block discarded – undo
881 880
 			{
882 881
 				return $rs;
883 882
 			}
884
-			foreach($rs as $info)
883
+			foreach ($rs as $info)
885 884
 			{
886
-				$info['info_responsible'] = $info['info_responsible'] ? explode(',',$info['info_responsible']) : array();
885
+				$info['info_responsible'] = $info['info_responsible'] ? explode(',', $info['info_responsible']) : array();
887 886
 
888 887
 				$ids[$info['info_id']] = $info;
889 888
 			}
@@ -896,19 +895,19 @@  discard block
 block discarded – undo
896 895
 			}
897 896
 			// if no specific custom field is selected, show/query all custom fields
898 897
 			if ($ids && ($query['custom_fields'] || $query['csv_export'] ||
899
-				$index_load_cfs && $query['col_filter']['info_type'] && in_array($query['col_filter']['info_type'],$index_load_cfs)))
898
+				$index_load_cfs && $query['col_filter']['info_type'] && in_array($query['col_filter']['info_type'], $index_load_cfs)))
900 899
 			{
901 900
 				$where = array('info_id' => array_keys($ids));
902
-				if (!($query['csv_export'] || strchr(is_array($query['selectcols']) ? implode(',',$query['selectcols']):$query['selectcols'],'#') === false ||
903
-					$index_load_cfs && $query['col_filter']['info_type'] && in_array($query['col_filter']['info_type'],$index_load_cfs)))
901
+				if (!($query['csv_export'] || strchr(is_array($query['selectcols']) ? implode(',', $query['selectcols']) : $query['selectcols'], '#') === false ||
902
+					$index_load_cfs && $query['col_filter']['info_type'] && in_array($query['col_filter']['info_type'], $index_load_cfs)))
904 903
 				{
905 904
 					$where['info_extra_name'] = array();
906
-					foreach(is_array($query['selectcols']) ? $query['selectcols'] : explode(',',$query['selectcols']) as $col)
905
+					foreach (is_array($query['selectcols']) ? $query['selectcols'] : explode(',', $query['selectcols']) as $col)
907 906
 					{
908
-						if ($col[0] == '#') $where['info_extra_name'][] = substr($col,1);
907
+						if ($col[0] == '#') $where['info_extra_name'][] = substr($col, 1);
909 908
 					}
910 909
 				}
911
-				foreach($this->db->select($this->extra_table,'*',$where,__LINE__,__FILE__) as $row)
910
+				foreach ($this->db->select($this->extra_table, '*', $where, __LINE__, __FILE__) as $row)
912 911
 				{
913 912
 					$ids[$row['info_id']]['#'.$row['info_extra_name']] = $row['info_extra_value'];
914 913
 				}
@@ -933,27 +932,27 @@  discard block
 block discarded – undo
933 932
 	{
934 933
 		$users = array();
935 934
 
936
-		foreach($this->db->select($this->info_table,'DISTINCT info_owner',array(
937
-			str_replace(' AND ','',$this->statusFilter('open')),
938
-			'(ABS(info_startdate-'.time().')<'.(4*24*60*60).' OR '.	// start_day within 4 days
939
-			'ABS(info_enddate-'.time().')<'.(4*24*60*60).')',		// end_day within 4 days
940
-		),__LINE__,__FILE__) as $row)
935
+		foreach ($this->db->select($this->info_table, 'DISTINCT info_owner', array(
936
+			str_replace(' AND ', '', $this->statusFilter('open')),
937
+			'(ABS(info_startdate-'.time().')<'.(4 * 24 * 60 * 60).' OR '.// start_day within 4 days
938
+			'ABS(info_enddate-'.time().')<'.(4 * 24 * 60 * 60).')', // end_day within 4 days
939
+		), __LINE__, __FILE__) as $row)
941 940
 		{
942 941
 			$users[] = $row['info_responsible'];
943 942
 		}
944
-		foreach($this->db->select($this->info_table,'DISTINCT info_responsible',$this->statusFilter('open',false),__LINE__,__FILE__) as $row)
943
+		foreach ($this->db->select($this->info_table, 'DISTINCT info_responsible', $this->statusFilter('open', false), __LINE__, __FILE__) as $row)
945 944
 		{
946
-			foreach(explode(',', $row['info_responsible']) as $responsible)
945
+			foreach (explode(',', $row['info_responsible']) as $responsible)
947 946
 			{
948 947
 				if ($GLOBALS['egw']->accounts->get_type($responsible) == 'g')
949 948
 				{
950
-					$responsible = $GLOBALS['egw']->accounts->members($responsible,true);
949
+					$responsible = $GLOBALS['egw']->accounts->members($responsible, true);
951 950
 				}
952 951
 				if ($responsible)
953 952
 				{
954
-					foreach(is_array($responsible) ? $responsible : array($responsible) as $user)
953
+					foreach (is_array($responsible) ? $responsible : array($responsible) as $user)
955 954
 					{
956
-						if ($user && !in_array($user,$users)) $users[] = $user;
955
+						if ($user && !in_array($user, $users)) $users[] = $user;
957 956
 					}
958 957
 				}
959 958
 			}
Please login to merge, or discard this patch.
Braces   +118 added lines, -29 removed lines patch added patch discarded remove patch
@@ -89,10 +89,16 @@  discard block
 block discarded – undo
89 89
 	 */
90 90
 	function is_responsible($info,$user=null)
91 91
 	{
92
-		if (!$user) $user = $this->user;
92
+		if (!$user)
93
+		{
94
+			$user = $this->user;
95
+		}
93 96
 
94 97
 		static $um_cache = array();
95
-		if ($user == $this->user) $user_and_memberships =& $um_cache[$user];
98
+		if ($user == $this->user)
99
+		{
100
+			$user_and_memberships =& $um_cache[$user];
101
+		}
96 102
 		if (!isset($user_and_memberships))
97 103
 		{
98 104
 			$user_and_memberships = $GLOBALS['egw']->accounts->memberships($user,true);
@@ -113,20 +119,32 @@  discard block
 block discarded – undo
113 119
 	 */
114 120
 	function check_access( $info,$required_rights,$implicit_edit=false,array $grants=null,$user=null )
115 121
 	{
116
-		if (is_null($grants)) $grants = $this->grants;
117
-		if (!$user) $user = $this->user;
122
+		if (is_null($grants))
123
+		{
124
+			$grants = $this->grants;
125
+		}
126
+		if (!$user)
127
+		{
128
+			$user = $this->user;
129
+		}
118 130
 
119 131
 		// if info-array, but no owner given, force reading of info from db
120
-		if (is_array($info) && !$info['info_owner']) $info = $info['info_id'];
132
+		if (is_array($info) && !$info['info_owner'])
133
+		{
134
+			$info = $info['info_id'];
135
+		}
121 136
 
122 137
 		if (is_array($info))
123 138
 		{
124 139
 
125 140
 		}
126
-		elseif ((int) $info != $this->data['info_id'])      	// already loaded?
141
+		elseif ((int) $info != $this->data['info_id'])
142
+		{
143
+			// already loaded?
127 144
 		{
128 145
 			// dont change our own internal data,
129 146
 			$backup_data = $this->data;
147
+		}
130 148
 			$info = $this->read(array('info_id'=>$info));
131 149
 			$this->data = $backup_data;
132 150
 		}
@@ -160,7 +178,10 @@  discard block
 block discarded – undo
160 178
 	 */
161 179
 	function responsible_filter($users)
162 180
 	{
163
-		if (!$users) return '0';
181
+		if (!$users)
182
+		{
183
+			return '0';
184
+		}
164 185
 
165 186
 		$responsible = array();
166 187
 		foreach((array)$users as $user)
@@ -250,11 +271,14 @@  discard block
 block discarded – undo
250 271
 						" OR info_status = 'offer' AND $public_access" : '').")".
251 272
 				                 " AND (info_access='public'".($has_private_access?" OR $has_private_access":'').')';
252 273
 			}
253
-			elseif ($filter != 'my' && $filter != 'responsible')	// none --> all entrys user has rights to see
274
+			elseif ($filter != 'my' && $filter != 'responsible')
275
+			{
276
+				// none --> all entrys user has rights to see
254 277
 			{
255 278
 				if ($has_private_access)
256 279
 				{
257 280
 					$filtermethod .= " OR $has_private_access";
281
+			}
258 282
 				}
259 283
 				if (count($public_user_list))
260 284
 				{
@@ -498,7 +522,10 @@  discard block
 block discarded – undo
498 522
 		{
499 523
 			$new_responsible = explode(',',$row['info_responsible']);
500 524
 			unset($new_responsible[array_search($args['account_id'],$new_responsible)]);
501
-			if ((int)$args['new_owner']) $new_responsible[] = (int)$args['new_owner'];
525
+			if ((int)$args['new_owner'])
526
+			{
527
+				$new_responsible[] = (int)$args['new_owner'];
528
+			}
502 529
 			$this->db->update($this->info_table,array(
503 530
 				'info_responsible' => implode(',',$new_responsible),
504 531
 			),array('info_id' => $row['info_id']),__LINE__,__FILE__,'infolog');
@@ -527,10 +554,13 @@  discard block
 block discarded – undo
527 554
 		//echo "soinfolog::write(,$check_modified) values="; _debug_array($values);
528 555
 		$info_id = (int) $values['info_id'];
529 556
 
530
-		if (array_key_exists('info_responsible',$values))	// isset($values['info_responsible']) returns false for NULL!
557
+		if (array_key_exists('info_responsible',$values))
558
+		{
559
+			// isset($values['info_responsible']) returns false for NULL!
531 560
 		{
532 561
 			$values['info_responsible'] = $values['info_responsible'] ? implode(',',$values['info_responsible']) : '0';
533 562
 		}
563
+		}
534 564
 		$table_def = $this->db->get_table_definitions('infolog',$this->info_table);
535 565
 		$to_write = array();
536 566
 		foreach($values as $key => $val)
@@ -541,12 +571,18 @@  discard block
 block discarded – undo
541 571
 			}
542 572
 		}
543 573
 		// writing no price as SQL NULL (required by postgres)
544
-		if ($to_write['info_price'] === '') $to_write['info_price'] = NULL;
574
+		if ($to_write['info_price'] === '')
575
+		{
576
+			$to_write['info_price'] = NULL;
577
+		}
545 578
 
546 579
 		if (($this->data['info_id'] = $info_id))
547 580
 		{
548 581
 			$where = array('info_id' => $info_id);
549
-			if ($check_modified) $where['info_datemodified'] = $check_modified;
582
+			if ($check_modified)
583
+			{
584
+				$where['info_datemodified'] = $check_modified;
585
+			}
550 586
 			if (!$this->db->update($this->info_table,$to_write,$where,__LINE__,__FILE__))
551 587
 			{
552 588
 				//error_log("### soinfolog::write(".print_r($to_write,true).") where=".print_r($where,true)." returning false");
@@ -560,7 +596,11 @@  discard block
 block discarded – undo
560 596
 		}
561 597
 		else
562 598
 		{
563
-			if (!isset($to_write['info_id_parent'])) $to_write['info_id_parent'] = 0;	// must not be null
599
+			if (!isset($to_write['info_id_parent']))
600
+			{
601
+				$to_write['info_id_parent'] = 0;
602
+			}
603
+			// must not be null
564 604
 
565 605
 			$this->db->insert($this->info_table,$to_write,false,__LINE__,__FILE__);
566 606
 			$info_id = $this->data['info_id'] = $this->db->get_last_insert_id($this->info_table,'info_id');
@@ -589,7 +629,10 @@  discard block
 block discarded – undo
589 629
 		if ($purge_cfs)
590 630
 		{
591 631
 			$where = array('info_id' => $info_id);
592
-			if ($purge_cfs == 'ical') $where[] = "info_extra_name LIKE '#%'";
632
+			if ($purge_cfs == 'ical')
633
+			{
634
+				$where[] = "info_extra_name LIKE '#%'";
635
+			}
593 636
 			$this->db->delete($this->extra_table,$where,__LINE__,__FILE__);
594 637
 		}
595 638
 		$to_delete = array();
@@ -641,7 +684,10 @@  discard block
 block discarded – undo
641 684
 	{
642 685
 		if (!is_array($info_id) || !$info_id)
643 686
 		{
644
-			if ((int)$info_id <= 0) return 0;
687
+			if ((int)$info_id <= 0)
688
+			{
689
+				return 0;
690
+			}
645 691
 		}
646 692
 		$counts = array();
647 693
 		foreach($this->db->select($this->info_table,'info_id_parent,COUNT(*) AS info_anz_subs',array(
@@ -714,11 +760,20 @@  discard block
 block discarded – undo
714 760
 				else
715 761
 				{
716 762
 					static $table_def = null;
717
-					if (is_null($table_def)) $table_def = $this->db->get_table_definitions('infolog',$this->info_table);
718
-					if (substr($val,0,5) != 'info_' && isset($table_def['fd']['info_'.$val])) $val = 'info_'.$val;
763
+					if (is_null($table_def))
764
+					{
765
+						$table_def = $this->db->get_table_definitions('infolog',$this->info_table);
766
+					}
767
+					if (substr($val,0,5) != 'info_' && isset($table_def['fd']['info_'.$val]))
768
+					{
769
+						$val = 'info_'.$val;
770
+					}
719 771
 					if ($val == 'info_des' && $this->db->capabilities['order_on_text'] !== true)
720 772
 					{
721
-						if (!$this->db->capabilities['order_on_text']) continue;
773
+						if (!$this->db->capabilities['order_on_text'])
774
+						{
775
+							continue;
776
+						}
722 777
 
723 778
 						$val = sprintf($this->db->capabilities['order_on_text'],$val);
724 779
 					}
@@ -732,7 +787,10 @@  discard block
 block discarded – undo
732 787
 			$ordermethod = 'ORDER BY info_datemodified DESC';   // newest first
733 788
 		}
734 789
 		$filtermethod = $this->aclFilter($query['filter']);
735
-		if (!$query['col_filter']['info_status'])  $filtermethod .= $this->statusFilter($query['filter']);
790
+		if (!$query['col_filter']['info_status'])
791
+		{
792
+			$filtermethod .= $this->statusFilter($query['filter']);
793
+		}
736 794
 		$filtermethod .= $this->dateFilter($query['filter']);
737 795
 		$cfcolfilter=0;
738 796
 		if (is_array($query['col_filter']))
@@ -744,14 +802,20 @@  discard block
 block discarded – undo
744 802
 					$filtermethod .= ' AND '.$data;
745 803
 					continue;
746 804
 				}
747
-				if ($col[0] != '#' && substr($col,0,5) != 'info_' && isset($table_def['fd']['info_'.$col])) $col = 'info_'.$col;
805
+				if ($col[0] != '#' && substr($col,0,5) != 'info_' && isset($table_def['fd']['info_'.$col]))
806
+				{
807
+					$col = 'info_'.$col;
808
+				}
748 809
 				if ((string)$data !== '' && preg_match('/^[a-z_0-9]+$/i',$col))
749 810
 				{
750 811
 					switch ($col)
751 812
 					{
752 813
 						case 'info_responsible':
753 814
 							$data = (int) $data;
754
-							if (!$data) continue;
815
+							if (!$data)
816
+							{
817
+								continue;
818
+							}
755 819
 							$filtermethod .= ' AND ('.$this->responsible_filter($data)." OR info_responsible='0' AND ".
756 820
 								$this->db->expression($this->info_table,array(
757 821
 									'info_owner' => $data > 0 ? $data : $GLOBALS['egw']->accounts->members($data,true)
@@ -800,12 +864,22 @@  discard block
 block discarded – undo
800 864
 			$filtermethod .= ' AND info_cat'.(count($cats)>1? ' IN ('.implode(',',$cats).') ' : '='.(int)$query['cat_id']);
801 865
 		}
802 866
 		$join = $distinct = '';
803
-		if ($query['query']) $query['search'] = $query['query'];	// allow both names
804
-		if ($query['search'])			  // we search in _from, _subject, _des and _extra_value for $query
867
+		if ($query['query'])
868
+		{
869
+			$query['search'] = $query['query'];
870
+		}
871
+		// allow both names
872
+		if ($query['search'])
873
+		{
874
+			// we search in _from, _subject, _des and _extra_value for $query
805 875
 		{
806 876
 			$columns = array('info_from','info_addr','info_location','info_subject','info_extra_value');
877
+		}
807 878
 			// at the moment MaxDB 7.5 cant cast nor search text columns, it's suppost to change in 7.6
808
-			if ($this->db->capabilities['like_on_text']) $columns[] = 'info_des';
879
+			if ($this->db->capabilities['like_on_text'])
880
+			{
881
+				$columns[] = 'info_des';
882
+			}
809 883
 
810 884
 			$wildcard = $op = null;
811 885
 			$so_sql = new Api\Storage\Base('infolog', $this->info_table, $this->db);
@@ -844,7 +918,10 @@  discard block
 block discarded – undo
844 918
 			if ($sortbycf != '')
845 919
 			{
846 920
 				$sort_col = "(SELECT DISTINCT info_extra_value FROM $this->extra_table sub2 WHERE sub2.info_id=main.info_id AND info_extra_name=".$this->db->quote($sortbycf).")";
847
-				if (!isset($custom_fields)) $custom_fields = Api\Storage\Customfields::get('infolog');
921
+				if (!isset($custom_fields))
922
+				{
923
+					$custom_fields = Api\Storage\Customfields::get('infolog');
924
+				}
848 925
 				switch($custom_fields[$sortbycf]['type'])
849 926
 				{
850 927
 					case 'int':
@@ -864,7 +941,10 @@  discard block
 block discarded – undo
864 941
 					$query['start'] = 0;
865 942
 				}
866 943
 				$cols = isset($query['cols']) ? $query['cols'] : 'main.*';
867
-				if (is_array($cols)) $cols = implode(',',$cols);
944
+				if (is_array($cols))
945
+				{
946
+					$cols = implode(',',$cols);
947
+				}
868 948
 				$rs = $this->db->query($sql='SELECT '.$mysql_calc_rows.' '.$distinct.' '.$cols.' '.$info_customfield.' '.$sql_query.$query['append'].' '.$ordermethod,__LINE__,__FILE__,
869 949
 					(int) $query['start'],isset($query['start']) ? (int) $query['num_rows'] : -1,false,Api\Db::FETCH_ASSOC);
870 950
 				//echo "<p>db::query('$sql',,,".(int)$query['start'].','.(isset($query['start']) ? (int) $query['num_rows'] : -1).")</p>\n";
@@ -892,7 +972,10 @@  discard block
 block discarded – undo
892 972
 			{
893 973
 				$config_data = Api\Config::read('infolog');
894 974
 				$index_load_cfs = $config_data['index_load_cfs'];
895
-				if (!is_array($index_load_cfs)) $index_load_cfs = explode(',', $index_load_cfs);
975
+				if (!is_array($index_load_cfs))
976
+				{
977
+					$index_load_cfs = explode(',', $index_load_cfs);
978
+				}
896 979
 			}
897 980
 			// if no specific custom field is selected, show/query all custom fields
898 981
 			if ($ids && ($query['custom_fields'] || $query['csv_export'] ||
@@ -905,7 +988,10 @@  discard block
 block discarded – undo
905 988
 					$where['info_extra_name'] = array();
906 989
 					foreach(is_array($query['selectcols']) ? $query['selectcols'] : explode(',',$query['selectcols']) as $col)
907 990
 					{
908
-						if ($col[0] == '#') $where['info_extra_name'][] = substr($col,1);
991
+						if ($col[0] == '#')
992
+						{
993
+							$where['info_extra_name'][] = substr($col,1);
994
+						}
909 995
 					}
910 996
 				}
911 997
 				foreach($this->db->select($this->extra_table,'*',$where,__LINE__,__FILE__) as $row)
@@ -953,7 +1039,10 @@  discard block
 block discarded – undo
953 1039
 				{
954 1040
 					foreach(is_array($responsible) ? $responsible : array($responsible) as $user)
955 1041
 					{
956
-						if ($user && !in_array($user,$users)) $users[] = $user;
1042
+						if ($user && !in_array($user,$users))
1043
+						{
1044
+							$users[] = $user;
1045
+						}
957 1046
 					}
958 1047
 				}
959 1048
 			}
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -828,7 +828,7 @@  discard block
 block discarded – undo
828 828
 		$ids = array( );
829 829
 		if ($action == '' || $action == 'sp' || count($links))
830 830
 		{
831
-			$sql_query = "FROM $this->info_table main $join WHERE ($filtermethod $pid $sql_query) $link_extra";
831
+			$sql_query = "from $this->info_table main $join WHERE ($filtermethod $pid $sql_query) $link_extra";
832 832
 			#error_log("infolog.so.search:\n" . print_r($sql_query, true));
833 833
 
834 834
 			if ($this->db->Type == 'mysql' && $this->db->ServerInfo['version'] >= 4.0)
@@ -838,7 +838,7 @@  discard block
 block discarded – undo
838 838
 			}
839 839
 			else
840 840
 			{
841
-				$query['total'] = $this->db->query($sql="SELECT $distinct main.info_id ".$sql_query,__LINE__,__FILE__)->NumRows();
841
+				$query['total'] = $this->db->query($sql="select $distinct main.info_id ".$sql_query,__LINE__,__FILE__)->NumRows();
842 842
 			}
843 843
 			$info_customfield = '';
844 844
 			if ($sortbycf != '')
Please login to merge, or discard this patch.
infolog/inc/class.infolog_tracking.inc.php 3 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -125,7 +125,6 @@
 block discarded – undo
125 125
 	/**
126 126
 	 * Constructor
127 127
 	 *
128
-	 * @param botracker $botracker
129 128
 	 * @return tracker_tracking
130 129
 	 */
131 130
 	function __construct(&$infolog_bo)
Please login to merge, or discard this patch.
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -130,9 +130,9 @@  discard block
 block discarded – undo
130 130
 	 */
131 131
 	function __construct(&$infolog_bo)
132 132
 	{
133
-		parent::__construct('infolog');	// add custom fields from infolog
133
+		parent::__construct('infolog'); // add custom fields from infolog
134 134
 
135
-		$this->infolog =& $infolog_bo;
135
+		$this->infolog = & $infolog_bo;
136 136
 	}
137 137
 
138 138
 	/**
@@ -144,23 +144,23 @@  discard block
 block discarded – undo
144 144
 	 * @param array $old
145 145
 	 * @return string
146 146
 	 */
147
-	function get_subject($data,$old)
147
+	function get_subject($data, $old)
148 148
 	{
149 149
 		if ($data['prefix'])
150 150
 		{
151
-			$prefix = $data['prefix'];	// async notification
151
+			$prefix = $data['prefix']; // async notification
152 152
 		}
153 153
 		elseif (!$old || $old['info_status'] == 'deleted')
154 154
 		{
155
-			$prefix = lang('New %1',lang($this->infolog->enums['type'][$data['info_type']]));
155
+			$prefix = lang('New %1', lang($this->infolog->enums['type'][$data['info_type']]));
156 156
 		}
157
-		elseif($data['info_status'] == 'deleted')
157
+		elseif ($data['info_status'] == 'deleted')
158 158
 		{
159
-			$prefix = lang('%1 deleted',lang($this->infolog->enums['type'][$data['info_type']]));
159
+			$prefix = lang('%1 deleted', lang($this->infolog->enums['type'][$data['info_type']]));
160 160
 		}
161 161
 		else
162 162
 		{
163
-			$prefix = lang('%1 modified',lang($this->infolog->enums['type'][$data['info_type']]));
163
+			$prefix = lang('%1 modified', lang($this->infolog->enums['type'][$data['info_type']]));
164 164
 		}
165 165
 		return $prefix.': '.$data['info_subject'];
166 166
 	}
@@ -172,22 +172,22 @@  discard block
 block discarded – undo
172 172
 	 * @param array $old
173 173
 	 * @return string
174 174
 	 */
175
-	function get_message($data,$old)
175
+	function get_message($data, $old)
176 176
 	{
177
-		if ($data['message']) return $data['message'];	// async notification
177
+		if ($data['message']) return $data['message']; // async notification
178 178
 
179 179
 		if (!$old || $old['info_status'] == 'deleted')
180 180
 		{
181
-			return lang('New %1 created by %2 at %3',lang($this->infolog->enums['type'][$data['info_type']]),
182
-				Api\Accounts::username($this->infolog->user),$this->datetime('now'));
181
+			return lang('New %1 created by %2 at %3', lang($this->infolog->enums['type'][$data['info_type']]),
182
+				Api\Accounts::username($this->infolog->user), $this->datetime('now'));
183 183
 		}
184
-		elseif($data['info_status'] == 'deleted')
184
+		elseif ($data['info_status'] == 'deleted')
185 185
 		{
186
-			return lang('%1 deleted by %2 at %3',lang($this->infolog->enums['type'][$data['info_type']]),
186
+			return lang('%1 deleted by %2 at %3', lang($this->infolog->enums['type'][$data['info_type']]),
187 187
 				Api\Accounts::username($data['info_modifier']),
188 188
 				$this->datetime($data['info_datemodified']));
189 189
 		}
190
-		return lang('%1 modified by %2 at %3',lang($this->infolog->enums['type'][$data['info_type']]),
190
+		return lang('%1 modified by %2 at %3', lang($this->infolog->enums['type'][$data['info_type']]),
191 191
 			Api\Accounts::username($data['info_modifier']),
192 192
 			$this->datetime($data['info_datemodified']));
193 193
 	}
@@ -199,14 +199,14 @@  discard block
 block discarded – undo
199 199
 	 * @param int|string $receiver nummeric account_id or email address
200 200
 	 * @return array of details as array with values for keys 'label','value','type'
201 201
 	 */
202
-	function get_details($data,$receiver=null)
202
+	function get_details($data, $receiver = null)
203 203
 	{
204
-		unset($receiver);	// not used, but required function signature
204
+		unset($receiver); // not used, but required function signature
205 205
 		//error_log(__METHOD__.__LINE__.' Data:'.array2string($data));
206 206
 		$responsible = array();
207 207
 		if ($data['info_responsible'])
208 208
 		{
209
-			foreach($data['info_responsible'] as $uid)
209
+			foreach ($data['info_responsible'] as $uid)
210 210
 			{
211 211
 				$responsible[] = Api\Accounts::username($uid);
212 212
 			}
@@ -215,31 +215,31 @@  discard block
 block discarded – undo
215 215
 		{
216 216
 			$id = ' #'.$data['info_id'];
217 217
 		}
218
-		foreach(array(
218
+		foreach (array(
219 219
 			'info_type'      => lang($this->infolog->enums['type'][$data['info_type']]).$id,
220 220
 			'info_from'      => $data['info_from'],
221 221
 			'info_addr'      => $data['info_addr'],
222 222
 			'info_cat'       => $data['info_cat'] ? $GLOBALS['egw']->categories->id2name($data['info_cat']) : '',
223 223
 			'info_priority'  => lang($this->infolog->enums['priority'][$data['info_priority']]),
224 224
 			'info_owner'     => Api\Accounts::username($data['info_owner']),
225
-			'info_status'    => lang($data['info_status']=='deleted'?'deleted':$this->infolog->status[$data['info_type']][$data['info_status']]),
225
+			'info_status'    => lang($data['info_status'] == 'deleted' ? 'deleted' : $this->infolog->status[$data['info_type']][$data['info_status']]),
226 226
 			'info_percent'   => (int)$data['info_percent'].'%',
227 227
 			'info_datecompleted' => $data['info_datecompleted'] ? $this->datetime($data['info_datecompleted']) : '',
228 228
 			'info_location'  => $data['info_location'],
229
-			'info_startdate' => $data['info_startdate'] ? $this->datetime($data['info_startdate'],null) : '',
230
-			'info_enddate'   => $data['info_enddate'] ? $this->datetime($data['info_enddate'],null) : '',
231
-			'info_responsible' => implode(', ',$responsible),
229
+			'info_startdate' => $data['info_startdate'] ? $this->datetime($data['info_startdate'], null) : '',
230
+			'info_enddate'   => $data['info_enddate'] ? $this->datetime($data['info_enddate'], null) : '',
231
+			'info_responsible' => implode(', ', $responsible),
232 232
 			'info_subject'   => $data['info_subject'],
233 233
 		) as $name => $value)
234 234
 		{
235 235
 			//error_log(__METHOD__.__LINE__.' Key:'.$name.' val:'.array2string($value));
236
-			if ($name=='info_from' && empty($value) && !empty($data['info_contact']) && is_array($data['link_to']['to_id']))
236
+			if ($name == 'info_from' && empty($value) && !empty($data['info_contact']) && is_array($data['link_to']['to_id']))
237 237
 			{
238 238
 				$lkeys = array_keys($data['link_to']['to_id']);
239
-				if (in_array($data['info_contact'],$lkeys))
239
+				if (in_array($data['info_contact'], $lkeys))
240 240
 				{
241
-					list($app,$id) = explode(':',$data['info_contact']);
242
-					if (!empty($app)&&!empty($id)) $value = Link::title($app,$id);
241
+					list($app, $id) = explode(':', $data['info_contact']);
242
+					if (!empty($app) && !empty($id)) $value = Link::title($app, $id);
243 243
 				}
244 244
 			}
245 245
 			$details[$name] = array(
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 	 * @param boolean $skip_notification = false do NOT send any notification
272 272
 	 * @return int|boolean false on error, integer number of changes logged or true for new entries ($old == null)
273 273
 	 */
274
-	public function track(array $data,array $old=null,$user=null,$deleted=null,array $changed_fields=null,$skip_notification=false)
274
+	public function track(array $data, array $old = null, $user = null, $deleted = null, array $changed_fields = null, $skip_notification = false)
275 275
 	{
276 276
 		//error_log(__METHOD__.__LINE__.' notify?'.($skip_notification?'no':'yes').function_backtrace());
277 277
 		$this->user = !is_null($user) ? $user : $GLOBALS['egw_info']['user']['account_id'];
@@ -280,23 +280,23 @@  discard block
 block discarded – undo
280 280
 
281 281
 		if ($old && $this->field2history)
282 282
 		{
283
-			$changes = $this->save_history($data,$old,$deleted,$changed_fields);
283
+			$changes = $this->save_history($data, $old, $deleted, $changed_fields);
284 284
 		}
285 285
 
286 286
 		// Don't notify if the only change was to the modified date
287
-		if(is_null($changed_fields))
287
+		if (is_null($changed_fields))
288 288
 		{
289 289
 			$changed_fields = $this->changed_fields($data, $old);
290 290
 			$changes = count($changed_fields); // we need that since TRUE evaluates to 1
291 291
 		}
292 292
 		//error_log(__METHOD__.__LINE__.array2string($changed_fields));
293
-		if(is_array($changed_fields) && $changes == 1 && in_array('info_datemodified', $changed_fields))
293
+		if (is_array($changed_fields) && $changes == 1 && in_array('info_datemodified', $changed_fields))
294 294
 		{
295 295
 			return count($changes);
296 296
 		}
297 297
 
298 298
 		// do not run do_notifications if we have no changes
299
-		if ($changes && !$skip_notification && !$this->do_notifications($data,$old,$deleted))
299
+		if ($changes && !$skip_notification && !$this->do_notifications($data, $old, $deleted))
300 300
 		{
301 301
 			$changes = false;
302 302
 		}
@@ -314,16 +314,16 @@  discard block
 block discarded – undo
314 314
 	 * @param array $old = null old/last state of the entry or null for a new entry
315 315
 	 * @return mixed
316 316
 	 */
317
-	function get_config($name,$data,$old=null)
317
+	function get_config($name, $data, $old = null)
318 318
 	{
319
-		unset($old);	// not used, but required function signature
320
-		switch($name)
319
+		unset($old); // not used, but required function signature
320
+		switch ($name)
321 321
 		{
322 322
 			case 'copy':	// include the info_cc addresses
323
-				if ($data['info_access'] == 'private') return array();	// no copies for private entries
323
+				if ($data['info_access'] == 'private') return array(); // no copies for private entries
324 324
 				if ($data['info_cc'])
325 325
 				{
326
-					$config = preg_split('/, ?/',$data['info_cc']);
326
+					$config = preg_split('/, ?/', $data['info_cc']);
327 327
 				}
328 328
 				else
329 329
 				{
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
 				break;
333 333
 			case self::CUSTOM_NOTIFICATION:
334 334
 				$info_config = Api\Config::read('infolog');
335
-				if(!$info_config[self::CUSTOM_NOTIFICATION])
335
+				if (!$info_config[self::CUSTOM_NOTIFICATION])
336 336
 				{
337 337
 					return '';
338 338
 				}
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
 				$global = $info_config[self::CUSTOM_NOTIFICATION]['~global~'];
342 342
 
343 343
 				// Disabled
344
-				if(!$type_config['use_custom'] && !$global['use_custom']) return '';
344
+				if (!$type_config['use_custom'] && !$global['use_custom']) return '';
345 345
 
346 346
 				// Type or globabl
347 347
 				$config = trim(strip_tags($type_config['message'])) != '' && $type_config['use_custom'] ? $type_config['message'] : $global['message'];
Please login to merge, or discard this patch.
Braces   +22 added lines, -5 removed lines patch added patch discarded remove patch
@@ -174,7 +174,11 @@  discard block
 block discarded – undo
174 174
 	 */
175 175
 	function get_message($data,$old)
176 176
 	{
177
-		if ($data['message']) return $data['message'];	// async notification
177
+		if ($data['message'])
178
+		{
179
+			return $data['message'];
180
+		}
181
+		// async notification
178 182
 
179 183
 		if (!$old || $old['info_status'] == 'deleted')
180 184
 		{
@@ -239,14 +243,20 @@  discard block
 block discarded – undo
239 243
 				if (in_array($data['info_contact'],$lkeys))
240 244
 				{
241 245
 					list($app,$id) = explode(':',$data['info_contact']);
242
-					if (!empty($app)&&!empty($id)) $value = Link::title($app,$id);
246
+					if (!empty($app)&&!empty($id))
247
+					{
248
+						$value = Link::title($app,$id);
249
+					}
243 250
 				}
244 251
 			}
245 252
 			$details[$name] = array(
246 253
 				'label' => lang($this->field2label[$name]),
247 254
 				'value' => $value,
248 255
 			);
249
-			if ($name == 'info_subject') $details[$name]['type'] = 'summary';
256
+			if ($name == 'info_subject')
257
+			{
258
+				$details[$name]['type'] = 'summary';
259
+			}
250 260
 		}
251 261
 		$details['info_des'] = array(
252 262
 			'value' => $data['info_des'],
@@ -320,7 +330,11 @@  discard block
 block discarded – undo
320 330
 		switch($name)
321 331
 		{
322 332
 			case 'copy':	// include the info_cc addresses
323
-				if ($data['info_access'] == 'private') return array();	// no copies for private entries
333
+				if ($data['info_access'] == 'private')
334
+				{
335
+					return array();
336
+				}
337
+				// no copies for private entries
324 338
 				if ($data['info_cc'])
325 339
 				{
326 340
 					$config = preg_split('/, ?/',$data['info_cc']);
@@ -341,7 +355,10 @@  discard block
 block discarded – undo
341 355
 				$global = $info_config[self::CUSTOM_NOTIFICATION]['~global~'];
342 356
 
343 357
 				// Disabled
344
-				if(!$type_config['use_custom'] && !$global['use_custom']) return '';
358
+				if(!$type_config['use_custom'] && !$global['use_custom'])
359
+				{
360
+					return '';
361
+				}
345 362
 
346 363
 				// Type or globabl
347 364
 				$config = trim(strip_tags($type_config['message'])) != '' && $type_config['use_custom'] ? $type_config['message'] : $global['message'];
Please login to merge, or discard this patch.
infolog/inc/class.infolog_ui.inc.php 4 patches
Doc Comments   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -295,6 +295,8 @@  discard block
 block discarded – undo
295 295
 	 * @param array &$query
296 296
 	 * @param array &$rows
297 297
 	 * @param array &$readonlys
298
+	 * @param type|null $rows
299
+	 * @param type|null $readonlys
298 300
 	 * @return int
299 301
 	 */
300 302
 	function get_rows(&$query,&$rows,&$readonlys)
@@ -574,7 +576,6 @@  discard block
 block discarded – undo
574 576
 	 * Hook for timesheet to set some extra data and links
575 577
 	 *
576 578
 	 * @param array $data
577
-	 * @param int $data[id] info_id
578 579
 	 * @return array with key => value pairs to set in new timesheet and link_app/link_id arrays
579 580
 	 */
580 581
 	function timesheet_set($data)
@@ -600,7 +601,6 @@  discard block
 block discarded – undo
600 601
 	 * Hook for calendar to set some extra data and links
601 602
 	 *
602 603
 	 * @param array $data event-array preset by calendar plus
603
-	 * @param int $data[entry_id] info_id
604 604
 	 * @return array with key => value pairs to set in new event and link_app/link_id arrays
605 605
 	 */
606 606
 	function calendar_set($data)
@@ -688,11 +688,11 @@  discard block
 block discarded – undo
688 688
 	/**
689 689
 	 * Shows the infolog list
690 690
 	 *
691
-	 * @param array/string $values etemplate content or 'reset_action_view' if called by index.php to reset an action-view
691
+	 * @param integer $values etemplate content or 'reset_action_view' if called by index.php to reset an action-view
692 692
 	 * @param string $action if set only entries liked to that $action:$action_id are shown
693 693
 	 * @param string $action_id if set only entries liked to that $action:$action_id are shown
694
-	 * @param mixed $called_as is how we got called, for a hook eg. the call-params of that page containing the hook
695
-	 * @param boolean $e$extra_app_header * @param boolean $return_html=false
694
+	 * @param integer $called_as is how we got called, for a hook eg. the call-params of that page containing the hook
695
+	 * @param boolean $extra_app_header * @param boolean $return_html
696 696
 	 * @param string $own_referer='' this is our own referer
697 697
 	 * @param string $action_title='' app_header for the action, if '' we try the link-title
698 698
 	 */
@@ -1288,7 +1288,7 @@  discard block
 block discarded – undo
1288 1288
 	 * @param array $query get_rows parameter
1289 1289
 	 * @param string &$msg on return user feedback
1290 1290
 	 * @param boolean $skip_notifications true to NOT notify users about changes
1291
-	 * @return boolean true if all actions succeded, false otherwise
1291
+	 * @return boolean|null true if all actions succeded, false otherwise
1292 1292
 	 */
1293 1293
 	function action($_action, $checked, $use_all, &$success, &$failed, &$action_msg,
1294 1294
 		array $query, &$msg, $skip_notifications = false)
@@ -1526,9 +1526,9 @@  discard block
 block discarded – undo
1526 1526
 	/**
1527 1527
 	 * Closes an infolog
1528 1528
 	 *
1529
-	 * @param int|array $values=0 info_id (default _GET[info_id])
1529
+	 * @param int|array $values info_id (default _GET[info_id])
1530 1530
 	 * @param string $_referer=''
1531
-	 * @param boolean $closesingle=false
1531
+	 * @param boolean $closesingle
1532 1532
 	 */
1533 1533
 	function close($values=0,$_referer='',$closesingle=false,$skip_notification = false)
1534 1534
 	{
@@ -1576,7 +1576,7 @@  discard block
 block discarded – undo
1576 1576
 	/**
1577 1577
 	 * Deletes an InfoLog entry
1578 1578
 	 *
1579
-	 * @param array|int $values info_id (default _GET[info_id])
1579
+	 * @param integer $values info_id (default _GET[info_id])
1580 1580
 	 * @param string $_referer
1581 1581
 	 * @param string $called_by
1582 1582
 	 * @param boolean $skip_notification Do not send notification of deletion
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -225,7 +225,7 @@
 block discarded – undo
225 225
 
226 226
 				if ($show_links != 'none' && $show_links != 'no_describtion' &&
227 227
 					$link['link_id'] != $info['info_link_id'] &&
228
-				    ($link['app'] != $action || $link['id'] != $action_id) &&
228
+					($link['app'] != $action || $link['id'] != $action_id) &&
229 229
 					($show_links == 'all' || ($show_links == 'links') === ($link['app'] != Link::VFS_APPNAME)))
230 230
 				{
231 231
 					$info['filelinks'][] = $link;
Please login to merge, or discard this patch.
Braces   +284 added lines, -71 removed lines patch added patch discarded remove patch
@@ -97,7 +97,10 @@  discard block
 block discarded – undo
97 97
 	 */
98 98
 	function __construct()
99 99
 	{
100
-		if ($GLOBALS['egw_info']['flags']['currentapp'] != 'infolog') Api\Translation::add_app('infolog');
100
+		if ($GLOBALS['egw_info']['flags']['currentapp'] != 'infolog')
101
+		{
102
+			Api\Translation::add_app('infolog');
103
+		}
101 104
 
102 105
 		// Make sure Global category is infolog - on first load, it may not be
103 106
 		if($GLOBALS['egw_info']['flags']['currentapp'] == 'infolog' && !$GLOBALS['egw']->categories->app_name)
@@ -165,13 +168,19 @@  discard block
 block discarded – undo
165 168
 		$done = $info['info_status'] == 'done' || $info['info_status'] == 'billed' || $info['info_status'] == 'cancelled'; //cancelled is regarded as a completed status as well in bo
166 169
 		// regard an infolog as done/billed/cancelled if its percentage is 100% when there is to status like the above for that type
167 170
 		if (!$done && !isset($this->bo->status[$info['info_type']]['done']) && !isset($this->bo->status[$info['info_type']]['billed']) &&
168
-			!isset($this->bo->status[$info['info_type']]['cancelled']) && (int)$info['info_percent']==100) $done = true ;
171
+			!isset($this->bo->status[$info['info_type']]['cancelled']) && (int)$info['info_percent']==100)
172
+		{
173
+			$done = true ;
174
+		}
169 175
 		$info['sub_class'] = $this->bo->enums['priority'][$info['info_priority']] . ($done ? '_done' : '');
170 176
 		if (!$done && $info['info_enddate'] < $this->bo->user_time_now)
171 177
 		{
172 178
 			$info['end_class'] = 'infolog_overdue';
173 179
 		}
174
-		if (!isset($info['info_anz_subs'])) $info['info_anz_subs'] = $this->bo->anzSubs($id);
180
+		if (!isset($info['info_anz_subs']))
181
+		{
182
+			$info['info_anz_subs'] = $this->bo->anzSubs($id);
183
+		}
175 184
 		$this->bo->link_id2from($info,$action,$action_id);	// unset from for $action:$action_id
176 185
 		$info['info_percent'] = (int) $info['info_percent'].'%';
177 186
 		$editrights = $this->bo->check_access($info,Acl::EDIT);
@@ -204,12 +213,21 @@  discard block
 block discarded – undo
204 213
 		{
205 214
 			$info['class'] .= 'rowNoSubs ';
206 215
 		}
207
-		if ($info['info_id_parent']) $info['class'] .= 'infolog_rowHasParent ';
208
-		if ($info['info_anz_subs'] > 0) $info['class'] .= 'infolog_rowHasSubs ';
216
+		if ($info['info_id_parent'])
217
+		{
218
+			$info['class'] .= 'infolog_rowHasParent ';
219
+		}
220
+		if ($info['info_anz_subs'] > 0)
221
+		{
222
+			$info['class'] .= 'infolog_rowHasSubs ';
223
+		}
209 224
 
210 225
 		$info['row_mod'] = $info['info_datemodified'];
211 226
 
212
-		if (!$show_links) $show_links = $this->prefs['show_links'];
227
+		if (!$show_links)
228
+		{
229
+			$show_links = $this->prefs['show_links'];
230
+		}
213 231
 		if (($show_links != 'none' && $show_links != 'no_describtion' ||
214 232
 			 $this->prefs['show_times'] || isset($GLOBALS['egw_info']['user']['apps']['timesheet'])) &&
215 233
 			(isset($info['links']) || ($info['links'] = Link::get_links('infolog',$info['info_id'],'','link_lastmod DESC',true,true))))
@@ -219,9 +237,16 @@  discard block
 block discarded – undo
219 237
 			{
220 238
 				// incl. link modification time into row_mod (link's lastmod is always in server-time!)
221 239
 				$link_mod = Api\DateTime::server2user($link['lastmod']);
222
-				if ($info['row_mod'] < $link_mod) $info['row_mod'] = $link_mod;
240
+				if ($info['row_mod'] < $link_mod)
241
+				{
242
+					$info['row_mod'] = $link_mod;
243
+				}
223 244
 
224
-				if ($link['deleted']) continue;	// skip deleted links, but incl. them in row_mod!
245
+				if ($link['deleted'])
246
+				{
247
+					continue;
248
+				}
249
+				// skip deleted links, but incl. them in row_mod!
225 250
 
226 251
 				if ($show_links != 'none' && $show_links != 'no_describtion' &&
227 252
 					$link['link_id'] != $info['info_link_id'] &&
@@ -234,14 +259,20 @@  discard block
 block discarded – undo
234 259
 				{
235 260
 					$info['pm_id'] = $link['id'];
236 261
 				}
237
-				if ($link['app'] == 'timesheet') $timesheets[] = $link['id'];
262
+				if ($link['app'] == 'timesheet')
263
+				{
264
+					$timesheets[] = $link['id'];
265
+				}
238 266
 			}
239 267
 			if ($this->prefs['show_times'] && isset($GLOBALS['egw_info']['user']['apps']['timesheet']) && $timesheets)
240 268
 			{
241 269
 				$sum = ExecMethod('timesheet.timesheet_bo.sum',$timesheets);
242 270
 				$info['info_sum_timesheets'] = $sum['duration'];
243 271
 				// incl. max timesheet modification in row_mod
244
-				if ($info['row_mod'] < $sum['max_modified']) $info['row_mod'] = $sum['max_modified'];
272
+				if ($info['row_mod'] < $sum['max_modified'])
273
+				{
274
+					$info['row_mod'] = $sum['max_modified'];
275
+				}
245 276
 			}
246 277
 		}
247 278
 		$info['info_type_label'] = $this->bo->enums['type'][$info['info_type']];
@@ -256,10 +287,13 @@  discard block
 block discarded – undo
256 287
 			}
257 288
 			$readonlys["edit_percent[$id]"] = true;
258 289
 		}
259
-		elseif($readonlys["edit_percent[$id]"])	// show percent, but button is switched off
290
+		elseif($readonlys["edit_percent[$id]"])
291
+		{
292
+			// show percent, but button is switched off
260 293
 		{
261 294
 			$info['info_percent2'] = $info['info_percent'];
262 295
 		}
296
+		}
263 297
 		if ($this->prefs['show_id'] == 1 || $this->prefs['show_id'] == 2 && $details)
264 298
 		{
265 299
 			$info['info_number'] = $info['info_id'];
@@ -332,10 +366,16 @@  discard block
 block discarded – undo
332 366
 			$query['col_filter'] = array('info_id_parent' => $query['col_filter']['info_id_parent']);
333 367
 		}
334 368
 		$orginal_colfilter = $query['col_filter'];
335
-		if (isset($parent_id)) $query['col_filter']['info_id_parent'] = (string)$parent_id;
369
+		if (isset($parent_id))
370
+		{
371
+			$query['col_filter']['info_id_parent'] = (string)$parent_id;
372
+		}
336 373
 
337 374
 		//echo "<p>infolog_ui.get_rows(start=$query[start],search='$query[search]',filter='$query[filter]',cat_id=$query[cat_id],action='$query[action]/$query[action_id]',col_filter=".print_r($query['col_filter'],True).",sort=$query[sort],order=$query[order])</p>\n";
338
-		if (!isset($query['start'])) $query['start'] = 0;
375
+		if (!isset($query['start']))
376
+		{
377
+			$query['start'] = 0;
378
+		}
339 379
 
340 380
 		// handle action and linked filter (show only entries linked to a certain other entry)
341 381
 		$link_filters = array();
@@ -364,7 +404,10 @@  discard block
 block discarded – undo
364 404
 				$app = $link['app'];
365 405
 				$id = $link['id'];
366 406
 			}
367
-			if(!is_array($id)) $id = explode(',',$id);
407
+			if(!is_array($id))
408
+			{
409
+				$id = explode(',',$id);
410
+			}
368 411
 			if (!($linked = Link::get_links_multiple($app,$id,true,'infolog','',$query['col_filter']['info_status'] == 'deleted')))
369 412
 			{
370 413
 				$rows = array();	// no infologs linked to selected link --> no rows to return
@@ -413,7 +456,10 @@  discard block
 block discarded – undo
413 456
 			}
414 457
 		}
415 458
 		// Framework\Template change forces the UI to do a full update first, no point in getting rows right now
416
-		if($old_template && $old_template != $query['template']) return 0;
459
+		if($old_template && $old_template != $query['template'])
460
+		{
461
+			return 0;
462
+		}
417 463
 
418 464
 		// do we need to read the custom fields, depends on the column is enabled and customfields exist, prefs are filter specific
419 465
 		// so we have to check that as well
@@ -474,12 +520,18 @@  discard block
 block discarded – undo
474 520
 		$parent_first = count($parents) == 1;
475 521
 		$parent_index = 0;
476 522
 		// et2 nextmatch listens to total, and only displays that many rows, so add parent in or we'll lose the last row
477
-		if($parent_first || $query['action'] == 'sp' && is_array($query['action_id'])) $query['total']++;
523
+		if($parent_first || $query['action'] == 'sp' && is_array($query['action_id']))
524
+		{
525
+			$query['total']++;
526
+		}
478 527
 
479 528
 		// Check to see if we need to remove description
480 529
 		foreach($infos as $id => $info)
481 530
 		{
482
-			if (!(strpos($info['info_addr'],',')===false) && strpos($info['info_addr'],', ')===false) $info['info_addr'] = str_replace(',',', ',$info['info_addr']);
531
+			if (!(strpos($info['info_addr'],',')===false) && strpos($info['info_addr'],', ')===false)
532
+			{
533
+				$info['info_addr'] = str_replace(',',', ',$info['info_addr']);
534
+			}
483 535
 			if (!$query['csv_export'] || !is_array($query['csv_export']))
484 536
 			{
485 537
 				$info['links'] =& $links[$id];
@@ -503,7 +555,10 @@  discard block
 block discarded – undo
503 555
 						{
504 556
 							foreach(array_keys($main) as $n)
505 557
 							{
506
-								if ($n[0] == '#' && !in_array($n, $columselection)) unset($main[$n]);
558
+								if ($n[0] == '#' && !in_array($n, $columselection))
559
+								{
560
+									unset($main[$n]);
561
+								}
507 562
 							}
508 563
 							break;
509 564
 						}
@@ -520,8 +575,14 @@  discard block
 block discarded – undo
520 575
 		}
521 576
 		unset($links);
522 577
 
523
-		if ($query['cat_id']) $rows['no_cat_id'] = true;
524
-		if ($query['no_actions']) $rows['no_actions'] = true;
578
+		if ($query['cat_id'])
579
+		{
580
+			$rows['no_cat_id'] = true;
581
+		}
582
+		if ($query['no_actions'])
583
+		{
584
+			$rows['no_actions'] = true;
585
+		}
525 586
 		$rows['no_timesheet'] = !isset($GLOBALS['egw_info']['user']['apps']['timesheet']);
526 587
 		if($clear_status_filter)
527 588
 		{
@@ -565,7 +626,11 @@  discard block
 block discarded – undo
565 626
 			$GLOBALS['egw_info']['flags']['app_header'] = implode(': ', $headers);
566 627
 		}
567 628
 
568
-		if (isset($linked)) $query['col_filter']['linked'] = $linked;  // add linked back to the colfilter
629
+		if (isset($linked))
630
+		{
631
+			$query['col_filter']['linked'] = $linked;
632
+		}
633
+		// add linked back to the colfilter
569 634
 
570 635
 		return $query['total'];
571 636
 	}
@@ -582,7 +647,10 @@  discard block
 block discarded – undo
582 647
 		$set = array();
583 648
 		if ((int)$data['id'] && ($info = $this->bo->read($data['id'])))
584 649
 		{
585
-			if ($info['info_cat']) $set['cat_id'] = $info['info_cat'];
650
+			if ($info['info_cat'])
651
+			{
652
+				$set['cat_id'] = $info['info_cat'];
653
+			}
586 654
 
587 655
 			foreach(Link::get_links('infolog',$info['info_id'],'','link_lastmod DESC',true) as $link)
588 656
 			{
@@ -620,7 +688,10 @@  discard block
 block discarded – undo
620 688
 			'end'		=> $infolog['info_enddate'] ? $infolog['info_enddate'] : $infolog['info_datecompleted']
621 689
 		));
622 690
 		unset($event['entry_id']);
623
-		if (!$event['end']) $event['end'] = $event['start'] + (int) $GLOBALS['egw_info']['user']['preferences']['calendar']['defaultlength']*60;
691
+		if (!$event['end'])
692
+		{
693
+			$event['end'] = $event['start'] + (int) $GLOBALS['egw_info']['user']['preferences']['calendar']['defaultlength']*60;
694
+		}
624 695
 
625 696
 		// Match Api\Categories by name
626 697
 		$event['category'] = $GLOBALS['egw']->categories->name2id(Api\Categories::id2name($infolog['info_cat']));
@@ -679,7 +750,10 @@  discard block
 block discarded – undo
679 750
 		// Copy same custom fields
680 751
 		foreach(array_keys(Api\Storage\Customfields::get('calendar')) as $name)
681 752
 		{
682
-			if ($this->bo->customfields[$name]) $event['#'.$name] = $infolog['#'.$name];
753
+			if ($this->bo->customfields[$name])
754
+			{
755
+				$event['#'.$name] = $infolog['#'.$name];
756
+			}
683 757
 		}
684 758
 		//error_log(__METHOD__.'('.array2string($data).') infolog='.array2string($infolog).' returning '.array2string($event));
685 759
 		return $event;
@@ -829,13 +903,19 @@  discard block
 block discarded – undo
829 903
 				$values['nm']['sort'] = 'DESC';
830 904
 			}
831 905
 
832
-			if (!$values['nm']['session_for'] && $this->called_by) $values['nm']['session_for'] = $this->called_by;
906
+			if (!$values['nm']['session_for'] && $this->called_by)
907
+			{
908
+				$values['nm']['session_for'] = $this->called_by;
909
+			}
833 910
 
834 911
 			$action_id = $values['action_id'] = $action ? $action_id : $nm['action_id'];
835 912
 			$action_title = $values['action_title'] = $action ? $action_title : $nm['action_title'];
836 913
 			$action = $values['action'] = $action ? $action : $nm['action'];
837 914
 		}
838
-		if($_GET['search']) $values['nm']['search'] = $_GET['search'];
915
+		if($_GET['search'])
916
+		{
917
+			$values['nm']['search'] = $_GET['search'];
918
+		}
839 919
 
840 920
 		if ($values['nm']['add'])
841 921
 		{
@@ -885,7 +965,10 @@  discard block
 block discarded – undo
885 965
 		switch ($action)
886 966
 		{
887 967
 			case 'sp':
888
-				if (!is_array($action_id) && strpos($action_id, 'infolog:') === 0) $action_id = (int)substr($action_id, 8);
968
+				if (!is_array($action_id) && strpos($action_id, 'infolog:') === 0)
969
+				{
970
+					$action_id = (int)substr($action_id, 8);
971
+				}
889 972
 				if ((is_array($action_id) && !$this->bo->read(current($action_id))) || !$this->bo->read($action_id))
890 973
 				{
891 974
 					$action = '';
@@ -932,7 +1015,10 @@  discard block
 block discarded – undo
932 1015
 		// Allow add actions even when there's no rows
933 1016
 		$values['nm']['placeholder_actions'] = array('new');
934 1017
 
935
-		if(!isset($values['nm']['filter2'])) $values['nm']['filter2'] = $this->prefs['nextmatch-'.($action ? 'infolog.'.$action : 'infolog.index.rows').'-details-pref'];
1018
+		if(!isset($values['nm']['filter2']))
1019
+		{
1020
+			$values['nm']['filter2'] = $this->prefs['nextmatch-'.($action ? 'infolog.'.$action : 'infolog.index.rows').'-details-pref'];
1021
+		}
936 1022
 
937 1023
 		// disable columns for main entry as set in the pref for details or no details
938 1024
 		$values['nm']['columnselection_pref'] = 'nextmatch-'.($action ? 'infolog.'.$action : 'infolog.index.rows')
@@ -957,7 +1043,10 @@  discard block
 block discarded – undo
957 1043
 		{
958 1044
 			foreach (array_keys($values['nm']['col_filter']) as $colfk)
959 1045
 			{
960
-				if (is_int($colfk)) unset($values['nm']['col_filter']);
1046
+				if (is_int($colfk))
1047
+				{
1048
+					unset($values['nm']['col_filter']);
1049
+				}
961 1050
 			}
962 1051
 		}
963 1052
 		$values['action'] = $persist['action'] = $values['nm']['action'] = $action;
@@ -1000,7 +1089,10 @@  discard block
 block discarded – undo
1000 1089
 		// does not take implicit rights as delegated into account, so they will not be available as filters
1001 1090
 		foreach($this->bo->group_owners as $type => $group)
1002 1091
 		{
1003
-			if (!isset($this->bo->grants[$group])) unset($sel_options['info_type'][$type]);
1092
+			if (!isset($this->bo->grants[$group]))
1093
+			{
1094
+				unset($sel_options['info_type'][$type]);
1095
+			}
1004 1096
 		}
1005 1097
 
1006 1098
 
@@ -1356,7 +1448,10 @@  discard block
 block discarded – undo
1356 1448
 				return $failed == 0;
1357 1449
 
1358 1450
 			case 'document':
1359
-				if (!$settings) $settings = $this->prefs['default_document'];
1451
+				if (!$settings)
1452
+				{
1453
+					$settings = $this->prefs['default_document'];
1454
+				}
1360 1455
 				$document_merge = new infolog_merge();
1361 1456
 				$msg = $document_merge->download($settings, $checked, '', $this->prefs['document_dir']);
1362 1457
 				$failed = count($checked);
@@ -1542,11 +1637,16 @@  discard block
 block discarded – undo
1542 1637
 			#_debug_array($info);
1543 1638
 			$status = $info['info_status'];
1544 1639
 			// closed stati assumed array('done','billed','cancelled')
1545
-			if (isset($this->bo->status[$info['info_type']]['done'])) {
1640
+			if (isset($this->bo->status[$info['info_type']]['done']))
1641
+			{
1546 1642
 				$status ='done';
1547
-			} elseif (isset($this->bo->status[$info['info_type']]['billed'])) {
1643
+			}
1644
+			elseif (isset($this->bo->status[$info['info_type']]['billed']))
1645
+			{
1548 1646
 				$status ='billed';
1549
-			} elseif (isset($this->bo->status[$info['info_type']]['cancelled'])) {
1647
+			}
1648
+			elseif (isset($this->bo->status[$info['info_type']]['cancelled']))
1649
+			{
1550 1650
 				$status ='cancelled';
1551 1651
 			}
1552 1652
 			#_debug_array($status);
@@ -1560,17 +1660,25 @@  discard block
 block discarded – undo
1560 1660
 			$this->bo->write($values, true,true,true,$skip_notification);
1561 1661
 
1562 1662
 			$query = array('action'=>'sp','action_id'=>$info_id);
1563
-			if (!$closesingle) {
1663
+			if (!$closesingle)
1664
+			{
1564 1665
 				foreach((array)$this->bo->search($query) as $info)
1565 1666
 				{
1566
-					if ($info['info_id_parent'] == $info_id)	// search also returns linked entries!
1667
+					if ($info['info_id_parent'] == $info_id)
1668
+					{
1669
+						// search also returns linked entries!
1567 1670
 					{
1568
-						$this->close($info['info_id'],$referer,$closesingle,$skip_notification);	// we call ourselfs recursive to process subs from subs too
1671
+						$this->close($info['info_id'],$referer,$closesingle,$skip_notification);
1672
+					}
1673
+					// we call ourselfs recursive to process subs from subs too
1569 1674
 					}
1570 1675
 				}
1571 1676
 			}
1572 1677
 		}
1573
-		if ($referer) $this->tmpl->location($referer);
1678
+		if ($referer)
1679
+		{
1680
+			$this->tmpl->location($referer);
1681
+		}
1574 1682
 	}
1575 1683
 
1576 1684
 	/**
@@ -1586,10 +1694,13 @@  discard block
 block discarded – undo
1586 1694
 		$info_id = (int) (is_array($values) ? $values['info_id'] : ($values ? $values : $_GET['info_id']));
1587 1695
 		$referer = is_array($values) ? $values['referer'] : $_referer;
1588 1696
 
1589
-		if (!is_array($values) && $info_id > 0 && !$this->bo->anzSubs($info_id))	// entries without subs get confirmed by javascript
1697
+		if (!is_array($values) && $info_id > 0 && !$this->bo->anzSubs($info_id))
1698
+		{
1699
+			// entries without subs get confirmed by javascript
1590 1700
 		{
1591 1701
 			$values = array('delete' => true);
1592 1702
 		}
1703
+		}
1593 1704
 		//echo "<p>infolog_ui::delete(".print_r($values,true).",'$referer','$called_by') info_id=$info_id</p>\n";
1594 1705
 
1595 1706
 		if (is_array($values) || $info_id <= 0)
@@ -1598,11 +1709,16 @@  discard block
 block discarded – undo
1598 1709
 			{
1599 1710
 				$deleted = $this->bo->delete($info_id,$values['delete_subs'],$values['info_id_parent'], $skip_notification);
1600 1711
 			}
1601
-			if ($called_by)		// direct call from the same request
1712
+			if ($called_by)
1713
+			{
1714
+				// direct call from the same request
1602 1715
 			{
1603 1716
 				return $deleted ? lang('InfoLog entry deleted') : '';
1604 1717
 			}
1605
-			if ($values['called_by'] == 'edit')	// we run in the edit popup => give control back to edit
1718
+			}
1719
+			if ($values['called_by'] == 'edit')
1720
+			{
1721
+				// we run in the edit popup => give control back to edit
1606 1722
 			{
1607 1723
 				$this->edit(array(
1608 1724
 					'info_id' => $info_id,
@@ -1611,6 +1727,7 @@  discard block
 block discarded – undo
1611 1727
 					'msg'     => $deleted ? lang('Infolog entry deleted') : '',
1612 1728
 				));
1613 1729
 			}
1730
+			}
1614 1731
 			return $referer ? $this->tmpl->location($referer) : $this->index();
1615 1732
 		}
1616 1733
 		$readonlys = $values = array();
@@ -1659,10 +1776,17 @@  discard block
 block discarded – undo
1659 1776
 			$no_popup  = $content['no_popup'];  unset($content['no_popup']);
1660 1777
 
1661 1778
 			list($button) = @each($content['button']);
1662
-			if (!$button && $action) $button = $action;	// action selectbox
1779
+			if (!$button && $action)
1780
+			{
1781
+				$button = $action;
1782
+			}
1783
+			// action selectbox
1663 1784
 			//info_cc expects an comma separated string
1664 1785
 			//error_log(__METHOD__.__LINE__.array2string($content));
1665
-			if (empty($content['info_cc'])) $content['info_cc'] = "";
1786
+			if (empty($content['info_cc']))
1787
+			{
1788
+				$content['info_cc'] = "";
1789
+			}
1666 1790
 			if (is_array($content['info_cc']))
1667 1791
 			{
1668 1792
 				foreach($content['info_cc'] as $i => $value)
@@ -1672,7 +1796,10 @@  discard block
 block discarded – undo
1672 1796
 					//error_log(__METHOD__.__LINE__.$value.'->'.array2string($addresses[0]));
1673 1797
 					$content['info_cc'][$i]=$addresses[0]->host ? $addresses[0]->mailbox.'@'.$addresses[0]->host : $addresses[0]->mailbox;
1674 1798
 				}
1675
-				if (!empty($content['info_cc'])) $content['info_cc'] = implode(',',$content['info_cc']);
1799
+				if (!empty($content['info_cc']))
1800
+				{
1801
+					$content['info_cc'] = implode(',',$content['info_cc']);
1802
+				}
1676 1803
 			}
1677 1804
 			unset($content['button']);
1678 1805
 			if ($button)
@@ -1811,9 +1938,12 @@  discard block
 block discarded – undo
1811 1938
 						Link::link('infolog',$info_id,$content['link_to']['to_id']);
1812 1939
 						$content['link_to']['to_id'] = $info_id;
1813 1940
 					}
1814
-					if ($info_link_id && strpos($info_link_id,':') !== false)	// updating info_link_id if necessary
1941
+					if ($info_link_id && strpos($info_link_id,':') !== false)
1942
+					{
1943
+						// updating info_link_id if necessary
1815 1944
 					{
1816 1945
 						list($app,$id) = explode(':',$info_link_id);
1946
+					}
1817 1947
 						$link = Link::get_link('infolog',$info_id,$app,$id);
1818 1948
 						if ((int) $content['info_link_id'] != (int) $link['link_id'])
1819 1949
 						{
@@ -1835,12 +1965,19 @@  discard block
 block discarded – undo
1835 1965
 				}
1836 1966
 				elseif ($button == 'delete' && $info_id > 0)
1837 1967
 				{
1838
-					if (!$referer && $action) $referer = array(
1968
+					if (!$referer && $action)
1969
+					{
1970
+						$referer = array(
1839 1971
 						'menuaction' => 'infolog.infolog_ui.index',
1840 1972
 						'action' => $action,
1841 1973
 						'action_id' => $action_id
1842 1974
 					);
1843
-					if (!($content['msg'] = $this->delete($info_id,$referer,'edit'))) return;	// checks ACL first
1975
+					}
1976
+					if (!($content['msg'] = $this->delete($info_id,$referer,'edit')))
1977
+					{
1978
+						return;
1979
+					}
1980
+					// checks ACL first
1844 1981
 
1845 1982
 					Framework::refresh_opener($content['msg'],'infolog',$info_id,'delete');
1846 1983
 				}
@@ -1890,13 +2027,20 @@  discard block
 block discarded – undo
1890 2027
 			$type      = $type      ? $type      : $_REQUEST['type'];
1891 2028
 			$referer   = $referer !== '' ? $referer : ($_GET['referer'] ? $_GET['referer'] :
1892 2029
 				Api\Header\Referer::get('/index.php?menuaction=infolog.infolog_ui.index'));
1893
-			if (strpos($referer, 'msg=') !== false) $referer = preg_replace('/([&?]{1})msg=[^&]+&?/','\\1',$referer);	// remove previou/old msg from referer
2030
+			if (strpos($referer, 'msg=') !== false)
2031
+			{
2032
+				$referer = preg_replace('/([&?]{1})msg=[^&]+&?/','\\1',$referer);
2033
+			}
2034
+			// remove previou/old msg from referer
1894 2035
 			$no_popup  = $_GET['no_popup'];
1895 2036
 			$print = (int) $_REQUEST['print'];
1896 2037
 			//echo "<p>infolog_ui::edit: info_id=$info_id,  action='$action', action_id='$action_id', type='$type', referer='$referer'</p>\n";
1897 2038
 
1898 2039
 			$content = $this->bo->read( $info_id || $action != 'sp' ? $info_id : $action_id );
1899
-			if (!(strpos($content['info_addr'],',')===false) && strpos($content['info_addr'],', ')===false) $content['info_addr'] = str_replace(',',', ',$content['info_addr']);
2040
+			if (!(strpos($content['info_addr'],',')===false) && strpos($content['info_addr'],', ')===false)
2041
+			{
2042
+				$content['info_addr'] = str_replace(',',', ',$content['info_addr']);
2043
+			}
1900 2044
 			foreach(array('info_subject', 'info_des') as $key)
1901 2045
 			{
1902 2046
 				if(!isset($content[$key]) || strlen($content[$key]) < 75)
@@ -1920,10 +2064,16 @@  discard block
 block discarded – undo
1920 2064
 						if (strlen($word)>75)
1921 2065
 						{
1922 2066
 							$buff = Api\Html::activate_links($word);
1923
-							if (strlen($buff) == strlen($word)) // no links -> try to break overlong words
2067
+							if (strlen($buff) == strlen($word))
2068
+							{
2069
+								// no links -> try to break overlong words
1924 2070
 							{
1925 2071
 								if (!(strpos($word,',')===false) && strpos($word,', ')===false) $word = str_replace(',',', ',$word);
1926
-								if (!(strpos($word,'.')===false) && strpos($word,'. ')===false) $word = str_replace('.','. ',$word);
2072
+							}
2073
+								if (!(strpos($word,'.')===false) && strpos($word,'. ')===false)
2074
+								{
2075
+									$word = str_replace('.','. ',$word);
2076
+								}
1927 2077
 								$word = wordwrap($word, 75, ' ', true);
1928 2078
 							}
1929 2079
 						}
@@ -1944,7 +2094,11 @@  discard block
 block discarded – undo
1944 2094
 			{
1945 2095
 				$content['info_cat'] = $this->prefs['cat_add_default'];
1946 2096
 			}
1947
-			if ($_GET['msg']) $content['msg'] = strip_tags($_GET['msg']);	// dont allow HTML!
2097
+			if ($_GET['msg'])
2098
+			{
2099
+				$content['msg'] = strip_tags($_GET['msg']);
2100
+			}
2101
+			// dont allow HTML!
1948 2102
 
1949 2103
 			switch($this->prefs['set_start'])
1950 2104
 			{
@@ -1955,13 +2109,19 @@  discard block
 block discarded – undo
1955 2109
 			if ((int)$content['info_link_id'] > 0 && !Link::get_link($content['info_link_id']))
1956 2110
 			{
1957 2111
 				$content['info_link_id'] = 0;	// link has been deleted
1958
-				if (!$content['info_custom_link']) $content['info_from'] = '';
2112
+				if (!$content['info_custom_link'])
2113
+				{
2114
+					$content['info_from'] = '';
2115
+				}
1959 2116
 			}
1960
-			if (!$info_id && $action_id && $action == 'sp')    // new SubProject
2117
+			if (!$info_id && $action_id && $action == 'sp')
2118
+			{
2119
+				// new SubProject
1961 2120
 			{
1962 2121
 				if (!$this->bo->check_access($action_id,Acl::ADD))
1963 2122
 				{
1964 2123
 					return $referer ? $this->tmpl->location($referer) : $this->index(0,$action,$action_id);
2124
+			}
1965 2125
 				}
1966 2126
 			}
1967 2127
 			else
@@ -1995,10 +2155,16 @@  discard block
 block discarded – undo
1995 2155
 				case 'copy':
1996 2156
 					$info_id = 0;
1997 2157
 					$this->create_copy($content, $action == 'sp');
1998
-					if ($action == 'sp')	// for sub-entries use type or category, like for new entries
2158
+					if ($action == 'sp')
2159
+					{
2160
+						// for sub-entries use type or category, like for new entries
1999 2161
 					{
2000 2162
 						if ($type) $content['info_type'] = $type;
2001
-						if (is_numeric($_REQUEST['cat_id'])) $content['info_cat'] = (int) $_REQUEST['cat_id'];
2163
+					}
2164
+						if (is_numeric($_REQUEST['cat_id']))
2165
+						{
2166
+							$content['info_cat'] = (int) $_REQUEST['cat_id'];
2167
+						}
2002 2168
 					}
2003 2169
 					unset($action);	// it get stored in $content and will cause an other copy after [apply]
2004 2170
 					break;
@@ -2027,7 +2193,10 @@  discard block
 block discarded – undo
2027 2193
 						{
2028 2194
 							foreach((array)$set['link_app'] as $i => $l_app)
2029 2195
 							{
2030
-								if (($l_id=$set['link_id'][$i])) Link::link('infolog',$content['link_to']['to_id'],$l_app,$l_id);
2196
+								if (($l_id=$set['link_id'][$i]))
2197
+								{
2198
+									Link::link('infolog',$content['link_to']['to_id'],$l_app,$l_id);
2199
+								}
2031 2200
 							}
2032 2201
 							unset($set['link_app']);
2033 2202
 							unset($set['link_id']);
@@ -2046,8 +2215,15 @@  discard block
 block discarded – undo
2046 2215
 						break;	// normal edit
2047 2216
 					}
2048 2217
 				case 'new':		// new entry, set some defaults, if not set by infolog_set hook
2049
-					if (empty($content['info_startdate'])) $content['info_startdate'] = (int) $_GET['startdate'] ? (int) $_GET['startdate'] : $set_startdate;
2050
-					if (empty($content['info_priority'])) $content['info_priority'] = 1; // normal
2218
+					if (empty($content['info_startdate']))
2219
+					{
2220
+						$content['info_startdate'] = (int) $_GET['startdate'] ? (int) $_GET['startdate'] : $set_startdate;
2221
+					}
2222
+					if (empty($content['info_priority']))
2223
+					{
2224
+						$content['info_priority'] = 1;
2225
+					}
2226
+					// normal
2051 2227
 					$content['info_owner'] = $this->user;
2052 2228
 					if ($type != '' && empty($content['info_type']))
2053 2229
 					{
@@ -2057,8 +2233,14 @@  discard block
 block discarded – undo
2057 2233
 					{
2058 2234
 						$content['info_type'] = $GLOBALS['egw_info']['user']['preferences']['infolog']['preferred_type'];
2059 2235
 					}
2060
-					if (empty($content['info_status'])) $content['info_status'] = $this->bo->status['defaults'][$content['info_type']];
2061
-					if (empty($content['info_percent'])) $content['info_percent'] = $content['info_status'] == 'done' ? '100%' : '0%';
2236
+					if (empty($content['info_status']))
2237
+					{
2238
+						$content['info_status'] = $this->bo->status['defaults'][$content['info_type']];
2239
+					}
2240
+					if (empty($content['info_percent']))
2241
+					{
2242
+						$content['info_percent'] = $content['info_status'] == 'done' ? '100%' : '0%';
2243
+					}
2062 2244
 					break;
2063 2245
 			}
2064 2246
 			if (!isset($this->bo->enums['type'][$content['info_type']]))
@@ -2161,12 +2343,18 @@  discard block
 block discarded – undo
2161 2343
 
2162 2344
 		$content['duration_format'] = $this->duration_format;
2163 2345
 		$content['hours_per_workday'] = $this->hours_per_workday;
2164
-		if ($this->prefs['show_id']) $content['info_number'] = $info_id;
2346
+		if ($this->prefs['show_id'])
2347
+		{
2348
+			$content['info_number'] = $info_id;
2349
+		}
2165 2350
 
2166 2351
 		$content['info_anz_subs'] = (int)$content['info_anz_subs'];	// gives javascript error if empty!
2167 2352
 
2168 2353
 		$old_pm_id = is_array($pm_links) ? array_shift($pm_links) : $content['old_pm_id'];
2169
-		if (!isset($content['pm_id']) && $old_pm_id) $content['pm_id'] = $old_pm_id;
2354
+		if (!isset($content['pm_id']) && $old_pm_id)
2355
+		{
2356
+			$content['pm_id'] = $old_pm_id;
2357
+		}
2170 2358
 
2171 2359
 		if ($info_id && $this->bo->history)
2172 2360
 		{
@@ -2239,7 +2427,10 @@  discard block
 block discarded – undo
2239 2427
 		//$content['info_des'] = substr($content['info_des'],0,1793);
2240 2428
 		//echo "<p>infolog_ui.edit(info_id='$info_id',action='$action',action_id='$action_id') readonlys="; print_r($readonlys); echo ", content = "; _debug_array($content);
2241 2429
 		//$content['info_cc'] is expected (by the widget) to be an array of emailaddresses, but is stored as comma separated string
2242
-		if (!empty($content['info_cc'])&&!is_array($content['info_cc']))$content['info_cc'] = explode(',',$content['info_cc']);
2430
+		if (!empty($content['info_cc'])&&!is_array($content['info_cc']))
2431
+		{
2432
+			$content['info_cc'] = explode(',',$content['info_cc']);
2433
+		}
2243 2434
 		$this->tmpl->exec('infolog.infolog_ui.edit',$content,$sel_options,$readonlys,$preserv+array(	// preserved values
2244 2435
 			'info_id'       => $info_id,
2245 2436
 			'action'        => $action,
@@ -2267,7 +2458,11 @@  discard block
 block discarded – undo
2267 2458
 		foreach ($exclude_fields as $field)
2268 2459
 		{
2269 2460
 			unset($content[$field]);
2270
-			if ($field == 'info_from') unset($content['info_link_id']);	// both together is called contact in UI
2461
+			if ($field == 'info_from')
2462
+			{
2463
+				unset($content['info_link_id']);
2464
+			}
2465
+			// both together is called contact in UI
2271 2466
 		}
2272 2467
 		if ($create_sub)
2273 2468
 		{
@@ -2295,13 +2490,25 @@  discard block
 block discarded – undo
2295 2490
 			$content['info_type'] = $types[0];
2296 2491
 		}
2297 2492
 		// get a consistent status, percent and date-completed
2298
-		if (!isset($content['info_status'])) $content['info_status'] = $this->bo->status['defaults'][$content['info_type']];
2299
-		if (!isset($content['info_percent'])) $content['info_percent'] = $content['info_status'] == 'done' ? '100%' : '0%';
2493
+		if (!isset($content['info_status']))
2494
+		{
2495
+			$content['info_status'] = $this->bo->status['defaults'][$content['info_type']];
2496
+		}
2497
+		if (!isset($content['info_percent']))
2498
+		{
2499
+			$content['info_percent'] = $content['info_status'] == 'done' ? '100%' : '0%';
2500
+		}
2300 2501
 		$content['info_datecompleted'] =$content['info_status'] == 'done' ? $this->bo->user_time_now : 0;
2301 2502
 
2302
-		if (!isset($content['info_cat'])) $content['info_cat'] = $this->prefs['cat_add_default'];
2503
+		if (!isset($content['info_cat']))
2504
+		{
2505
+			$content['info_cat'] = $this->prefs['cat_add_default'];
2506
+		}
2303 2507
 
2304
-		if(!is_array($content['link_to'])) $content['link_to'] = array();
2508
+		if(!is_array($content['link_to']))
2509
+		{
2510
+			$content['link_to'] = array();
2511
+		}
2305 2512
 		$content['link_to']['to_app'] = 'infolog';
2306 2513
 		$content['link_to']['to_id'] = 0;
2307 2514
 		// Get links to be copied, if not excluded
@@ -2332,7 +2539,10 @@  discard block
 block discarded – undo
2332 2539
 			{
2333 2540
 				$linkinfos = Link::get_link($info_link_id);
2334 2541
 				$content['info_contact'] = $linkinfos['link_app1']=='infolog'? $linkinfos['link_app2'].':'.$linkinfos['link_id2']:$linkinfos['link_app1'].':'.$linkinfos['link_id1'];
2335
-				if (stripos($content['info_contact'],'projectmanager')!==false) $content['pm_id'] = $linkinfos['link_app1']=='projectmanager'? $linkinfos['link_id1']:$linkinfos['link_id2'];
2542
+				if (stripos($content['info_contact'],'projectmanager')!==false)
2543
+				{
2544
+					$content['pm_id'] = $linkinfos['link_app1']=='projectmanager'? $linkinfos['link_id1']:$linkinfos['link_id2'];
2545
+				}
2336 2546
 			}
2337 2547
 			unset($content['info_link_id']);
2338 2548
 		}
@@ -2637,7 +2847,10 @@  discard block
 block discarded – undo
2637 2847
 		}
2638 2848
 		foreach($this->bo->customfields as $name => $data)
2639 2849
 		{
2640
-			if ($data['type2'] && $type && !in_array($type,explode(',',$data['type2']))) continue;
2850
+			if ($data['type2'] && $type && !in_array($type,explode(',',$data['type2'])))
2851
+			{
2852
+				continue;
2853
+			}
2641 2854
 
2642 2855
 			$fields['#'.$name] = array(
2643 2856
 				'label' => $data['label'],
Please login to merge, or discard this patch.
Spacing   +352 added lines, -356 removed lines patch added patch discarded remove patch
@@ -55,32 +55,32 @@  discard block
 block discarded – undo
55 55
 	 *
56 56
 	 * @var string
57 57
 	 */
58
-	var $duration_format = ',';	// comma is necessary!
58
+	var $duration_format = ','; // comma is necessary!
59 59
 
60 60
 	var $icons = array(
61 61
 		'type' => array(
62
-			'task'      => 'task.gif',      'task_alt'      => 'Task',
63
-			'phone'     => 'phone.gif',     'phone_alt'     => 'Phonecall',
64
-			'note'      => 'note.gif',      'note_alt'      => 'Note',
65
-			'confirm'   => 'confirm.gif',   'confirm_alt'   => 'Confirmation',
66
-			'reject'    => 'reject.gif',    'reject_alt'    => 'Reject',
67
-			'email'     => 'email.gif',     'email_alt'     => 'Email' ),
62
+			'task'      => 'task.gif', 'task_alt'      => 'Task',
63
+			'phone'     => 'phone.gif', 'phone_alt'     => 'Phonecall',
64
+			'note'      => 'note.gif', 'note_alt'      => 'Note',
65
+			'confirm'   => 'confirm.gif', 'confirm_alt'   => 'Confirmation',
66
+			'reject'    => 'reject.gif', 'reject_alt'    => 'Reject',
67
+			'email'     => 'email.gif', 'email_alt'     => 'Email' ),
68 68
 		'action' => array(
69
-			'new'       => 'new.gif',       'new_alt'       => 'Add Sub',
70
-			'view'      => 'view.gif',      'view_alt'      => 'View Subs',
71
-			'parent'    => 'parent.gif',    'parent_alt'    => 'View other Subs',
72
-			'edit'      => 'edit.gif',      'edit_alt'      => 'Edit',
73
-			'addfile'   => 'addfile.gif',   'addfile_alt'   => 'Add a file',
74
-			'delete'    => 'delete.gif',    'delete_alt'    => 'Delete',
75
-			'close'     => 'done.gif',      'close_alt'     => 'Close' ,
76
-			'close_all' => 'done_all.gif',  'close_all_alt' => 'Close' ),
69
+			'new'       => 'new.gif', 'new_alt'       => 'Add Sub',
70
+			'view'      => 'view.gif', 'view_alt'      => 'View Subs',
71
+			'parent'    => 'parent.gif', 'parent_alt'    => 'View other Subs',
72
+			'edit'      => 'edit.gif', 'edit_alt'      => 'Edit',
73
+			'addfile'   => 'addfile.gif', 'addfile_alt'   => 'Add a file',
74
+			'delete'    => 'delete.gif', 'delete_alt'    => 'Delete',
75
+			'close'     => 'done.gif', 'close_alt'     => 'Close',
76
+			'close_all' => 'done_all.gif', 'close_all_alt' => 'Close' ),
77 77
 		'status' => array(
78
-			'billed'    => 'billed.gif',    'billed_alt'    => 'billed',
79
-			'done'      => 'done.gif',      'done_alt'      => 'done',
78
+			'billed'    => 'billed.gif', 'billed_alt'    => 'billed',
79
+			'done'      => 'done.gif', 'done_alt'      => 'done',
80 80
 			'will-call' => 'will-call.gif', 'will-call_alt' => 'will-call',
81
-			'call'      => 'call.gif',      'call_alt'      => 'call',
82
-			'ongoing'   => 'ongoing.gif',   'ongoing_alt'   => 'ongoing',
83
-			'offer'     => 'offer.gif',     'offer_alt'     => 'offer' )
81
+			'call'      => 'call.gif', 'call_alt'      => 'call',
82
+			'ongoing'   => 'ongoing.gif', 'ongoing_alt'   => 'ongoing',
83
+			'offer'     => 'offer.gif', 'offer_alt'     => 'offer' )
84 84
 	);
85 85
 	var $filters;
86 86
 	var $messages = array(
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 		if ($GLOBALS['egw_info']['flags']['currentapp'] != 'infolog') Api\Translation::add_app('infolog');
101 101
 
102 102
 		// Make sure Global category is infolog - on first load, it may not be
103
-		if($GLOBALS['egw_info']['flags']['currentapp'] == 'infolog' && !$GLOBALS['egw']->categories->app_name)
103
+		if ($GLOBALS['egw_info']['flags']['currentapp'] == 'infolog' && !$GLOBALS['egw']->categories->app_name)
104 104
 		{
105 105
 			$GLOBALS['egw']->categories = new Api\Categories();
106 106
 		}
@@ -111,18 +111,18 @@  discard block
 block discarded – undo
111 111
 
112 112
 		$this->user = $GLOBALS['egw_info']['user']['account_id'];
113 113
 
114
-		$this->prefs =& $GLOBALS['egw_info']['user']['preferences']['infolog'];
114
+		$this->prefs = & $GLOBALS['egw_info']['user']['preferences']['infolog'];
115 115
 
116 116
 		// read the duration format from project-manager
117 117
 		if ($GLOBALS['egw_info']['apps']['projectmanager'])
118 118
 		{
119 119
 			$pm_config = Api\Config::read('projectmanager');
120
-			$this->duration_format = str_replace(',','',implode('', (array)$pm_config['duration_units']));
120
+			$this->duration_format = str_replace(',', '', implode('', (array)$pm_config['duration_units']));
121 121
 			//error_log(__METHOD__."() ".__LINE__." duration_format=$this->duration_format, duration_unit=".array2string($pm_config['duration_units']));
122 122
 			$this->hours_per_workday = $pm_config['hours_per_workday'];
123 123
 			unset($pm_config);
124 124
 		}
125
-		$this->filters =& $this->bo->filters;
125
+		$this->filters = & $this->bo->filters;
126 126
 		/* these are just for testing of the notifications
127 127
 		for($i = -1; $i <= 3; ++$i)
128 128
 		{
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 			$this->filters['responsible-open-date'.date('Y-m-d',time()+$i*24*60*60)] = "responsible starting in $i day(s)";
142 142
 		}
143 143
 		*/
144
-		$GLOBALS['infolog_ui'] =& $this;	// make ourself availible for ExecMethod of get_rows function
144
+		$GLOBALS['infolog_ui'] = & $this; // make ourself availible for ExecMethod of get_rows function
145 145
 	}
146 146
 
147 147
 	/**
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 	 * @param int $details
156 156
 	 * @return array
157 157
 	 */
158
-	function get_info($info,&$readonlys,$action='',$action_id='',$show_links=false,$details = 1)
158
+	function get_info($info, &$readonlys, $action = '', $action_id = '', $show_links = false, $details = 1)
159 159
 	{
160 160
 		if (!is_array($info))
161 161
 		{
@@ -165,19 +165,19 @@  discard block
 block discarded – undo
165 165
 		$done = $info['info_status'] == 'done' || $info['info_status'] == 'billed' || $info['info_status'] == 'cancelled'; //cancelled is regarded as a completed status as well in bo
166 166
 		// regard an infolog as done/billed/cancelled if its percentage is 100% when there is to status like the above for that type
167 167
 		if (!$done && !isset($this->bo->status[$info['info_type']]['done']) && !isset($this->bo->status[$info['info_type']]['billed']) &&
168
-			!isset($this->bo->status[$info['info_type']]['cancelled']) && (int)$info['info_percent']==100) $done = true ;
169
-		$info['sub_class'] = $this->bo->enums['priority'][$info['info_priority']] . ($done ? '_done' : '');
168
+			!isset($this->bo->status[$info['info_type']]['cancelled']) && (int)$info['info_percent'] == 100) $done = true;
169
+		$info['sub_class'] = $this->bo->enums['priority'][$info['info_priority']].($done ? '_done' : '');
170 170
 		if (!$done && $info['info_enddate'] < $this->bo->user_time_now)
171 171
 		{
172 172
 			$info['end_class'] = 'infolog_overdue';
173 173
 		}
174 174
 		if (!isset($info['info_anz_subs'])) $info['info_anz_subs'] = $this->bo->anzSubs($id);
175
-		$this->bo->link_id2from($info,$action,$action_id);	// unset from for $action:$action_id
176
-		$info['info_percent'] = (int) $info['info_percent'].'%';
177
-		$editrights = $this->bo->check_access($info,Acl::EDIT);
175
+		$this->bo->link_id2from($info, $action, $action_id); // unset from for $action:$action_id
176
+		$info['info_percent'] = (int)$info['info_percent'].'%';
177
+		$editrights = $this->bo->check_access($info, Acl::EDIT);
178 178
 		$isresposible = $this->bo->is_responsible($info);
179 179
 		if ((!($editrights || // edit rights or more then standard responsible rights
180
-			$isresposible && array_diff($this->bo->responsible_edit,array('info_status','info_percent','info_datecompleted')))))
180
+			$isresposible && array_diff($this->bo->responsible_edit, array('info_status', 'info_percent', 'info_datecompleted')))))
181 181
 		{
182 182
 			$info['class'] .= 'rowNoEdit ';
183 183
 		}
@@ -196,11 +196,11 @@  discard block
 block discarded – undo
196 196
 		{
197 197
 			$info['class'] .= 'rowNoCloseAll ';
198 198
 		}
199
-		if (!$this->bo->check_access($info,Acl::DELETE))
199
+		if (!$this->bo->check_access($info, Acl::DELETE))
200 200
 		{
201 201
 			$info['class'] .= 'rowNoDelete ';
202 202
 		}
203
-		if (!$this->bo->check_access($info,Acl::ADD))
203
+		if (!$this->bo->check_access($info, Acl::ADD))
204 204
 		{
205 205
 			$info['class'] .= 'rowNoSubs ';
206 206
 		}
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 		if (!$show_links) $show_links = $this->prefs['show_links'];
213 213
 		if (($show_links != 'none' && $show_links != 'no_describtion' ||
214 214
 			 $this->prefs['show_times'] || isset($GLOBALS['egw_info']['user']['apps']['timesheet'])) &&
215
-			(isset($info['links']) || ($info['links'] = Link::get_links('infolog',$info['info_id'],'','link_lastmod DESC',true,true))))
215
+			(isset($info['links']) || ($info['links'] = Link::get_links('infolog', $info['info_id'], '', 'link_lastmod DESC', true, true))))
216 216
 		{
217 217
 			$timesheets = array();
218 218
 			foreach ($info['links'] as $link)
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 				$link_mod = Api\DateTime::server2user($link['lastmod']);
222 222
 				if ($info['row_mod'] < $link_mod) $info['row_mod'] = $link_mod;
223 223
 
224
-				if ($link['deleted']) continue;	// skip deleted links, but incl. them in row_mod!
224
+				if ($link['deleted']) continue; // skip deleted links, but incl. them in row_mod!
225 225
 
226 226
 				if ($show_links != 'none' && $show_links != 'no_describtion' &&
227 227
 					$link['link_id'] != $info['info_link_id'] &&
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 			}
239 239
 			if ($this->prefs['show_times'] && isset($GLOBALS['egw_info']['user']['apps']['timesheet']) && $timesheets)
240 240
 			{
241
-				$sum = ExecMethod('timesheet.timesheet_bo.sum',$timesheets);
241
+				$sum = ExecMethod('timesheet.timesheet_bo.sum', $timesheets);
242 242
 				$info['info_sum_timesheets'] = $sum['duration'];
243 243
 				// incl. max timesheet modification in row_mod
244 244
 				if ($info['row_mod'] < $sum['max_modified']) $info['row_mod'] = $sum['max_modified'];
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 			}
257 257
 			$readonlys["edit_percent[$id]"] = true;
258 258
 		}
259
-		elseif($readonlys["edit_percent[$id]"])	// show percent, but button is switched off
259
+		elseif ($readonlys["edit_percent[$id]"])	// show percent, but button is switched off
260 260
 		{
261 261
 			$info['info_percent2'] = $info['info_percent'];
262 262
 		}
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
 	protected static function filter(array $query)
278 278
 	{
279 279
 		$filter = $query['filter'] ? 'filter' : ($query['cat_id'] ? 'cat_id' : null);
280
-		foreach((array)$query['col_filter'] as $name => $value)
280
+		foreach ((array)$query['col_filter'] as $name => $value)
281 281
 		{
282 282
 			if ((string)$value !== '')
283 283
 			{
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
 	 * @param array &$readonlys
298 298
 	 * @return int
299 299
 	 */
300
-	function get_rows(&$query,&$rows,&$readonlys)
300
+	function get_rows(&$query, &$rows, &$readonlys)
301 301
 	{
302 302
 		//error_log(__METHOD__."() query[csv_export]=".array2string($query['csv_export']).", query[filter]=".array2string($query['filter']).", query[col_filter]=".array2string(array_diff($query['col_filter'],array('',0))).' '.function_backtrace());
303 303
 		if (!$query['csv_export'])
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 			}
315 315
 			//error_log(__METHOD__."() prefs[listNoSubs]=".array2string($this->prefs['listNoSubs'])." --> parent_id=$parent_id");
316 316
 			unset($query['col_filter']['parent_id']);
317
-			if(!$query['action'])
317
+			if (!$query['action'])
318 318
 			{
319 319
 				Api\Cache::setSession('infolog', $query['session_for'].'session_data', $query);
320 320
 			}
@@ -323,10 +323,10 @@  discard block
 block discarded – undo
323 323
 			$query['row_modified'] = 'row_mod';
324 324
 			$query['parent_id'] = 'info_id_parent';
325 325
 			$query['is_parent'] = 'info_anz_subs';
326
-			$query['action_var'] = 'multi_action';	// as 'action' is already used in infolog
326
+			$query['action_var'] = 'multi_action'; // as 'action' is already used in infolog
327 327
 		}
328 328
 		// nextmatch opened an infolog containing children --> do not filter them, always show all children
329
-		elseif($query['csv_export'] === 'children')
329
+		elseif ($query['csv_export'] === 'children')
330 330
 		{
331 331
 			$query['filter'] = $query['search'] = $query['cat_id'] = '';
332 332
 			$query['col_filter'] = array('info_id_parent' => $query['col_filter']['info_id_parent']);
@@ -346,17 +346,17 @@  discard block
 block discarded – undo
346 346
 			$links['linked'] = array();
347 347
 			unset($query['col_filter']['linked']);
348 348
 		}
349
-		if($query['action'] && in_array($query['action'], array_keys($GLOBALS['egw_info']['apps'])) && $query['action_id'])
349
+		if ($query['action'] && in_array($query['action'], array_keys($GLOBALS['egw_info']['apps'])) && $query['action_id'])
350 350
 		{
351 351
 			$link_filters['action'] = array('app'=>$query['action'], 'id' => $query['action_id']);
352 352
 			$links['action'] = array();
353 353
 		}
354
-		foreach($link_filters as $key => $link)
354
+		foreach ($link_filters as $key => $link)
355 355
 		{
356
-			if(!is_array($link))
356
+			if (!is_array($link))
357 357
 			{
358 358
 				// Legacy string style
359
-				list($app,$id) = explode(':',$link);
359
+				list($app, $id) = explode(':', $link);
360 360
 			}
361 361
 			else
362 362
 			{
@@ -364,25 +364,25 @@  discard block
 block discarded – undo
364 364
 				$app = $link['app'];
365 365
 				$id = $link['id'];
366 366
 			}
367
-			if(!is_array($id)) $id = explode(',',$id);
368
-			if (!($linked = Link::get_links_multiple($app,$id,true,'infolog','',$query['col_filter']['info_status'] == 'deleted')))
367
+			if (!is_array($id)) $id = explode(',', $id);
368
+			if (!($linked = Link::get_links_multiple($app, $id, true, 'infolog', '', $query['col_filter']['info_status'] == 'deleted')))
369 369
 			{
370
-				$rows = array();	// no infologs linked to selected link --> no rows to return
370
+				$rows = array(); // no infologs linked to selected link --> no rows to return
371 371
 				return 0;
372 372
 			}
373 373
 
374 374
 
375
-			foreach($linked as $infos)
375
+			foreach ($linked as $infos)
376 376
 			{
377
-				$links[$key] = array_merge($links[$key],$infos);
377
+				$links[$key] = array_merge($links[$key], $infos);
378 378
 			}
379 379
 			$links[$key] = array_unique($links[$key]);
380
-			if($key == 'linked')
380
+			if ($key == 'linked')
381 381
 			{
382 382
 				$linked = array('app' => $app, 'id' => $id, 'title' => (count($id) == 1 ? Link::title($app, $id) : lang('multiple')));
383 383
 			}
384 384
 		}
385
-		if(count($links))
385
+		if (count($links))
386 386
 		{
387 387
 			$query['col_filter']['info_id'] = count($links) > 1 ? call_user_func_array('array_intersect', $links) : $links[$key];
388 388
 		}
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
 		$old_template = $query['template'];
392 392
 
393 393
 		// Reset custom, type-specific template if type was cleared (without changing it for home)
394
-		if(!$query['template'] || stripos($query['template'], 'infolog.index.rows') === 0)
394
+		if (!$query['template'] || stripos($query['template'], 'infolog.index.rows') === 0)
395 395
 		{
396 396
 			$query['template'] = 'infolog.index.rows';
397 397
 		}
@@ -402,10 +402,10 @@  discard block
 block discarded – undo
402 402
 			if ($tpl->read('infolog.index.rows.'.$query['col_filter']['info_type']))
403 403
 			{
404 404
 				$query['template'] = $tpl->name;
405
-				$query['custom_fields'] = true;	// read the custom fields too
405
+				$query['custom_fields'] = true; // read the custom fields too
406 406
 			}
407 407
 			// If status is not valid for selected type, clear status filter
408
-			if($query['col_filter']['info_status'] && $query['col_filter']['info_status'] != 'deleted' &&
408
+			if ($query['col_filter']['info_status'] && $query['col_filter']['info_status'] != 'deleted' &&
409 409
 				!in_array($query['col_filter']['info_status'], array_keys($this->bo->status[$query['col_filter']['info_type']])))
410 410
 			{
411 411
 				$query['col_filter']['info_status'] = '';
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
 			}
414 414
 		}
415 415
 		// Framework\Template change forces the UI to do a full update first, no point in getting rows right now
416
-		if($old_template && $old_template != $query['template']) return 0;
416
+		if ($old_template && $old_template != $query['template']) return 0;
417 417
 
418 418
 		// do we need to read the custom fields, depends on the column is enabled and customfields exist, prefs are filter specific
419 419
 		// so we have to check that as well
@@ -426,14 +426,14 @@  discard block
 block discarded – undo
426 426
 
427 427
 		if (!$query['selectcols'] && $columselection)
428 428
 		{
429
-			$columselection = is_array($columselection) ? $columselection : explode(',',$columselection);
429
+			$columselection = is_array($columselection) ? $columselection : explode(',', $columselection);
430 430
 		}
431 431
 		else
432 432
 		{
433
-			$columselection = $query['selectcols'] ? (is_array($query['selectcols']) ? $query['selectcols'] : explode(',',$query['selectcols'])) : array();
433
+			$columselection = $query['selectcols'] ? (is_array($query['selectcols']) ? $query['selectcols'] : explode(',', $query['selectcols'])) : array();
434 434
 		}
435 435
 		// do we need to query the cf's
436
-		$query['custom_fields'] = $this->bo->customfields && (!$columselection || in_array('customfields',$columselection));
436
+		$query['custom_fields'] = $this->bo->customfields && (!$columselection || in_array('customfields', $columselection));
437 437
 
438 438
 		$infos = $this->bo->search($query);
439 439
 		$query['col_filter'] = $orginal_colfilter;
@@ -451,12 +451,12 @@  discard block
 block discarded – undo
451 451
 			$query['default_cols'] = '!cat_id,info_datemodified,info_used_time_info_planned_time,info_used_time_info_planned_time_info_replanned_time,info_id';
452 452
 		}
453 453
 		// set old show_times pref, that get_info calculates the cumulated time of the timesheets (we only check used&planned to work for both time cols)
454
-		$this->prefs['show_times'] = strpos($this->prefs[$query['columnselection_pref']],'info_used_time_info_planned_time') !== false;
454
+		$this->prefs['show_times'] = strpos($this->prefs[$query['columnselection_pref']], 'info_used_time_info_planned_time') !== false;
455 455
 
456 456
 		// query all links and sub counts in one go
457 457
 		if ($infos && (!$query['csv_export'] || !is_array($query['csv_export'])))
458 458
 		{
459
-			$links = Link::get_links_multiple('infolog',array_keys($infos),true,'','link_lastmod DESC',true);	// true=incl. deleted
459
+			$links = Link::get_links_multiple('infolog', array_keys($infos), true, '', 'link_lastmod DESC', true); // true=incl. deleted
460 460
 			$anzSubs = $this->bo->anzSubs(array_keys($infos));
461 461
 		}
462 462
 		$rows = array();
@@ -467,27 +467,27 @@  discard block
 block discarded – undo
467 467
 			$parents = $query['action'] == 'sp' && $query['action_id'] ? (array)$query['action_id'] : array();
468 468
 			if (count($parents) == 1 && is_array($query['action_id']))
469 469
 			{
470
-				$query['action_id'] = array_shift($query['action_id']);	// display single parent as app_header
470
+				$query['action_id'] = array_shift($query['action_id']); // display single parent as app_header
471 471
 			}
472 472
 		}
473 473
 
474 474
 		$parent_first = count($parents) == 1;
475 475
 		$parent_index = 0;
476 476
 		// et2 nextmatch listens to total, and only displays that many rows, so add parent in or we'll lose the last row
477
-		if($parent_first || $query['action'] == 'sp' && is_array($query['action_id'])) $query['total']++;
477
+		if ($parent_first || $query['action'] == 'sp' && is_array($query['action_id'])) $query['total']++;
478 478
 
479 479
 		// Check to see if we need to remove description
480
-		foreach($infos as $id => $info)
480
+		foreach ($infos as $id => $info)
481 481
 		{
482
-			if (!(strpos($info['info_addr'],',')===false) && strpos($info['info_addr'],', ')===false) $info['info_addr'] = str_replace(',',', ',$info['info_addr']);
482
+			if (!(strpos($info['info_addr'], ',') === false) && strpos($info['info_addr'], ', ') === false) $info['info_addr'] = str_replace(',', ', ', $info['info_addr']);
483 483
 			if (!$query['csv_export'] || !is_array($query['csv_export']))
484 484
 			{
485
-				$info['links'] =& $links[$id];
485
+				$info['links'] = & $links[$id];
486 486
 				$info['info_anz_subs'] = (int)$anzSubs[$id];
487
-				$info = $this->get_info($info,$readonlys,null,null,false,$details);
487
+				$info = $this->get_info($info, $readonlys, null, null, false, $details);
488 488
 			}
489 489
 			// for subs view ('sp') add parent(s) in front of subs once(!)
490
-			if ( $parent_first && ($main = $this->bo->read($query['action_id'])) ||
490
+			if ($parent_first && ($main = $this->bo->read($query['action_id'])) ||
491 491
 				$parents && ($parent_index = array_search($info['info_id_parent'], $parents)) !== false &&
492 492
 				($main = $this->bo->read($info['info_id_parent'])))
493 493
 			{
@@ -497,11 +497,11 @@  discard block
 block discarded – undo
497 497
 				// as read() always read them all, while search() only reads the selected ones
498 498
 				if ($query['custom_fields'])
499 499
 				{
500
-					foreach($columselection as $col)
500
+					foreach ($columselection as $col)
501 501
 					{
502 502
 						if ($col[0] == '#')
503 503
 						{
504
-							foreach(array_keys($main) as $n)
504
+							foreach (array_keys($main) as $n)
505 505
 							{
506 506
 								if ($n[0] == '#' && !in_array($n, $columselection)) unset($main[$n]);
507 507
 							}
@@ -510,7 +510,7 @@  discard block
 block discarded – undo
510 510
 					}
511 511
 				}
512 512
 				$parent_first = false;
513
-				if($query['start'] == 0)
513
+				if ($query['start'] == 0)
514 514
 				{
515 515
 					array_splice($rows, $id, 0, array($main));
516 516
 					unset($parents[$parent_index]);
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
 		if ($query['cat_id']) $rows['no_cat_id'] = true;
524 524
 		if ($query['no_actions']) $rows['no_actions'] = true;
525 525
 		$rows['no_timesheet'] = !isset($GLOBALS['egw_info']['user']['apps']['timesheet']);
526
-		if($clear_status_filter)
526
+		if ($clear_status_filter)
527 527
 		{
528 528
 			$rows['info_status'] = '';
529 529
 		}
@@ -554,7 +554,7 @@  discard block
 block discarded – undo
554 554
 				$headers[] = lang($this->filters[$query['filter']]);
555 555
 			}
556 556
 			if ($query['action'] && ($title = $query['action_title'] || is_array($query['action_id']) ?
557
-				$query['action_title'] : Link::title($query['action']=='sp'?'infolog':$query['action'],$query['action_id'])))
557
+				$query['action_title'] : Link::title($query['action'] == 'sp' ? 'infolog' : $query['action'], $query['action_id'])))
558 558
 			{
559 559
 				$headers[] = $title;
560 560
 			}
@@ -565,7 +565,7 @@  discard block
 block discarded – undo
565 565
 			$GLOBALS['egw_info']['flags']['app_header'] = implode(': ', $headers);
566 566
 		}
567 567
 
568
-		if (isset($linked)) $query['col_filter']['linked'] = $linked;  // add linked back to the colfilter
568
+		if (isset($linked)) $query['col_filter']['linked'] = $linked; // add linked back to the colfilter
569 569
 
570 570
 		return $query['total'];
571 571
 	}
@@ -584,7 +584,7 @@  discard block
 block discarded – undo
584 584
 		{
585 585
 			if ($info['info_cat']) $set['cat_id'] = $info['info_cat'];
586 586
 
587
-			foreach(Link::get_links('infolog',$info['info_id'],'','link_lastmod DESC',true) as $link)
587
+			foreach (Link::get_links('infolog', $info['info_id'], '', 'link_lastmod DESC', true) as $link)
588 588
 			{
589 589
 				if ($link['app'] != 'timesheet' && $link['app'] != Link::VFS_APPNAME)
590 590
 				{
@@ -609,7 +609,7 @@  discard block
 block discarded – undo
609 609
 		{
610 610
 			return $data;
611 611
 		}
612
-		$event = array_merge($data,array(
612
+		$event = array_merge($data, array(
613 613
 			'category'	=> $GLOBALS['egw']->categories->check_list(Acl::READ, $infolog['info_cat']),
614 614
 			'priority'	=> $infolog['info_priority'] + 1,
615 615
 			'public'	=> $infolog['info_access'] != 'private',
@@ -620,7 +620,7 @@  discard block
 block discarded – undo
620 620
 			'end'		=> $infolog['info_enddate'] ? $infolog['info_enddate'] : $infolog['info_datecompleted']
621 621
 		));
622 622
 		unset($event['entry_id']);
623
-		if (!$event['end']) $event['end'] = $event['start'] + (int) $GLOBALS['egw_info']['user']['preferences']['calendar']['defaultlength']*60;
623
+		if (!$event['end']) $event['end'] = $event['start'] + (int)$GLOBALS['egw_info']['user']['preferences']['calendar']['defaultlength'] * 60;
624 624
 
625 625
 		// Match Api\Categories by name
626 626
 		$event['category'] = $GLOBALS['egw']->categories->name2id(Api\Categories::id2name($infolog['info_cat']));
@@ -629,38 +629,38 @@  discard block
 block discarded – undo
629 629
 		$event['owner'] = $user = $GLOBALS['egw_info']['user']['account_id'];
630 630
 
631 631
 		// add/modify participants according to prefs
632
-		$prefs = explode(',',$this->prefs['calendar_set'] ? $this->prefs['calendar_set'] : 'responsible,contact,user');
632
+		$prefs = explode(',', $this->prefs['calendar_set'] ? $this->prefs['calendar_set'] : 'responsible,contact,user');
633 633
 
634 634
 		// if no default participants (selected calendars) --> remove all
635
-		if (!in_array('selected',$prefs))
635
+		if (!in_array('selected', $prefs))
636 636
 		{
637 637
 			$event['participants'] = $event['participant_types'] = array();
638 638
 		}
639 639
 		// Add responsible as participant
640
-		if (in_array('responsible',$prefs))
640
+		if (in_array('responsible', $prefs))
641 641
 		{
642
-			foreach($infolog['info_responsible'] as $responsible)
642
+			foreach ($infolog['info_responsible'] as $responsible)
643 643
 			{
644 644
 				$event['participants'][$responsible] = $event['participant_types']['u'][$responsible] =
645
-					calendar_so::combine_status($user==$responsible?'A':'U');
645
+					calendar_so::combine_status($user == $responsible ? 'A' : 'U');
646 646
 			}
647 647
 		}
648 648
 		// Add linked contact as participant
649
-		if (in_array('contact',$prefs) && $infolog['info_link']['app'] == 'addressbook')
649
+		if (in_array('contact', $prefs) && $infolog['info_link']['app'] == 'addressbook')
650 650
 		{
651
-			$event['participants'][calendar_so::combine_user('c',$infolog['info_link']['id'])] =
651
+			$event['participants'][calendar_so::combine_user('c', $infolog['info_link']['id'])] =
652 652
 				$event['participant_types']['c'][$infolog['info_link']['id']] = calendar_so::combine_status('U');
653 653
 		}
654
-		if (in_array('owner',$prefs))
654
+		if (in_array('owner', $prefs))
655 655
 		{
656 656
 			$event['participants'][$infolog['info_owner']] = $event['participant_types']['u'][$infolog['info_owner']] =
657
-				calendar_so::combine_status('A',1,'CHAIR');
657
+				calendar_so::combine_status('A', 1, 'CHAIR');
658 658
 		}
659 659
 		// Add current user, if set or no other participants, which is not allowed
660
-		if (in_array('user',$prefs))
660
+		if (in_array('user', $prefs))
661 661
 		{
662 662
 			$event['participants'][$user] = $event['participant_types']['u'][$user] =
663
-				calendar_so::combine_status('A',1,'CHAIR');
663
+				calendar_so::combine_status('A', 1, 'CHAIR');
664 664
 		}
665 665
 
666 666
 		// Add infolog link to calendar entry
@@ -668,7 +668,7 @@  discard block
 block discarded – undo
668 668
 		$event['link_id'][]  = $infolog['info_link']['id'];
669 669
 
670 670
 		// Copy infolog's links
671
-		foreach(Link::get_links('infolog',$infolog['info_id'],'','link_lastmod DESC',true) as $link)
671
+		foreach (Link::get_links('infolog', $infolog['info_id'], '', 'link_lastmod DESC', true) as $link)
672 672
 		{
673 673
 			if ($link['app'] != Link::VFS_APPNAME)
674 674
 			{
@@ -677,7 +677,7 @@  discard block
 block discarded – undo
677 677
 			}
678 678
 		}
679 679
 		// Copy same custom fields
680
-		foreach(array_keys(Api\Storage\Customfields::get('calendar')) as $name)
680
+		foreach (array_keys(Api\Storage\Customfields::get('calendar')) as $name)
681 681
 		{
682 682
 			if ($this->bo->customfields[$name]) $event['#'.$name] = $infolog['#'.$name];
683 683
 		}
@@ -696,9 +696,9 @@  discard block
 block discarded – undo
696 696
 	 * @param string $own_referer='' this is our own referer
697 697
 	 * @param string $action_title='' app_header for the action, if '' we try the link-title
698 698
 	 */
699
-	function index($values = null,$action='',$action_id='',$called_as=0,$extra_app_header=False,$return_html=False,$own_referer='',$action_title='')
699
+	function index($values = null, $action = '', $action_id = '', $called_as = 0, $extra_app_header = False, $return_html = False, $own_referer = '', $action_title = '')
700 700
 	{
701
-		unset($extra_app_header);	// not used, but dont want to change signature
701
+		unset($extra_app_header); // not used, but dont want to change signature
702 702
 		if (is_array($values))
703 703
 		{
704 704
 			$called_as = $values['called_as'];
@@ -707,7 +707,7 @@  discard block
 block discarded – undo
707 707
 		elseif ($own_referer === '')
708 708
 		{
709 709
 			$own_referer = Api\Header\Referer::get();
710
-			if (strpos($own_referer,'menuaction=infolog.infolog_ui.edit') !== false)
710
+			if (strpos($own_referer, 'menuaction=infolog.infolog_ui.edit') !== false)
711 711
 			{
712 712
 				$own_referer = Api\Cache::getSession('infolog', 'own_session');
713 713
 			}
@@ -718,11 +718,11 @@  discard block
 block discarded – undo
718 718
 		}
719 719
 
720 720
 		// Handle legacy buttons like actions
721
-		if(is_array($values))
721
+		if (is_array($values))
722 722
 		{
723
-			foreach(array('document', 'view', 'delete') as $button)
723
+			foreach (array('document', 'view', 'delete') as $button)
724 724
 			{
725
-				if(isset($values['nm']['rows'][$button]))
725
+				if (isset($values['nm']['rows'][$button]))
726 726
 				{
727 727
 					list($id) = @each($values['nm']['rows'][$button]);
728 728
 					$values['nm']['multi_action'] = $button;
@@ -742,27 +742,27 @@  discard block
 block discarded – undo
742 742
 				// Some processing to add values in for links and cats
743 743
 				$multi_action = $values['nm']['multi_action'];
744 744
 				// Action has an additional action - add / delete, etc.  Buttons named <multi-action>_action[action_name]
745
-				if(in_array($multi_action, array('link', 'responsible')))
745
+				if (in_array($multi_action, array('link', 'responsible')))
746 746
 				{
747 747
 					// eTemplate ignores the _popup namespace, but et2 doesn't
748
-					if($values[$multi_action.'_popup'])
748
+					if ($values[$multi_action.'_popup'])
749 749
 					{
750
-						$popup =& $values[$multi_action.'_popup'];
750
+						$popup = & $values[$multi_action.'_popup'];
751 751
 					}
752 752
 					else
753 753
 					{
754
-						$popup =& $values;
754
+						$popup = & $values;
755 755
 					}
756
-					$values['nm']['multi_action'] .= '_' . key($popup[$multi_action . '_action']);
757
-					if($multi_action == 'link')
756
+					$values['nm']['multi_action'] .= '_'.key($popup[$multi_action.'_action']);
757
+					if ($multi_action == 'link')
758 758
 					{
759
-						$popup[$multi_action] = $popup['link']['app'] . ':'.$popup['link']['id'];
759
+						$popup[$multi_action] = $popup['link']['app'].':'.$popup['link']['id'];
760 760
 					}
761
-					else if(is_array($popup[$multi_action]))
761
+					else if (is_array($popup[$multi_action]))
762 762
 					{
763
-						$popup[$multi_action] = implode(',',$popup[$multi_action]);
763
+						$popup[$multi_action] = implode(',', $popup[$multi_action]);
764 764
 					}
765
-					$values['nm']['multi_action'] .= '_' . $popup[$multi_action];
765
+					$values['nm']['multi_action'] .= '_'.$popup[$multi_action];
766 766
 					unset($values[$multi_action.'_popup']);
767 767
 					unset($values[$multi_action]);
768 768
 				}
@@ -770,18 +770,18 @@  discard block
 block discarded – undo
770 770
 				if ($this->action($values['nm']['multi_action'], $values['nm']['selected'], $values['nm']['select_all'],
771 771
 					$success, $failed, $action_msg, $values['nm'], $msg, $values['nm']['checkboxes']['no_notifications']))
772 772
 				{
773
-					$msg .= lang('%1 entries %2',$success,$action_msg);
773
+					$msg .= lang('%1 entries %2', $success, $action_msg);
774 774
 					Framework::message($msg);
775 775
 				}
776
-				elseif(is_null($msg))
776
+				elseif (is_null($msg))
777 777
 				{
778
-					$msg .= lang('%1 entries %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed);
779
-					Framework::message($msg,'error');
778
+					$msg .= lang('%1 entries %2, %3 failed because of insufficent rights !!!', $success, $action_msg, $failed);
779
+					Framework::message($msg, 'error');
780 780
 				}
781
-				elseif($msg)
781
+				elseif ($msg)
782 782
 				{
783
-					$msg .= "\n".lang('%1 entries %2, %3 failed.',$success,$action_msg,$failed);
784
-					Framework::message($msg,'error');
783
+					$msg .= "\n".lang('%1 entries %2, %3 failed.', $success, $action_msg, $failed);
784
+					Framework::message($msg, 'error');
785 785
 				}
786 786
 				unset($values['nm']['multi_action']);
787 787
 				unset($values['nm']['select_all']);
@@ -804,7 +804,7 @@  discard block
 block discarded – undo
804 804
 				$action_id = 0;
805 805
 				$action_title = '';
806 806
 			}
807
-			if($_GET['ajax'] === 'true')
807
+			if ($_GET['ajax'] === 'true')
808 808
 			{
809 809
 				$nm['action'] = '';
810 810
 				$nm['action_id'] = 0;
@@ -820,8 +820,7 @@  discard block
 block discarded – undo
820 820
 
821 821
 			if (isset($_GET['filter']) && $_GET['filter'] != 'default' || !isset($values['nm']['filter']) && !$this->called_by)
822 822
 			{
823
-				$values['nm']['filter'] = $_GET['filter'] && $_GET['filter'] != 'default' ? $_GET['filter'] :
824
-					$this->prefs['defaultFilter'];
823
+				$values['nm']['filter'] = $_GET['filter'] && $_GET['filter'] != 'default' ? $_GET['filter'] : $this->prefs['defaultFilter'];
825 824
 			}
826 825
 			if (!isset($values['nm']['order']) || !$values['nm']['order'])
827 826
 			{
@@ -835,21 +834,21 @@  discard block
 block discarded – undo
835 834
 			$action_title = $values['action_title'] = $action ? $action_title : $nm['action_title'];
836 835
 			$action = $values['action'] = $action ? $action : $nm['action'];
837 836
 		}
838
-		if($_GET['search']) $values['nm']['search'] = $_GET['search'];
837
+		if ($_GET['search']) $values['nm']['search'] = $_GET['search'];
839 838
 
840 839
 		if ($values['nm']['add'])
841 840
 		{
842 841
 			$values['add'] = $values['nm']['add'];
843 842
 			unset($values['nm']['add']);
844 843
 		}
845
-		unset($values['nm']['rows']['checked']);	// not longer used, but hides button actions
844
+		unset($values['nm']['rows']['checked']); // not longer used, but hides button actions
846 845
 
847 846
 		if ($values['add'] || $values['cancel'] || isset($values['main']))
848 847
 		{
849 848
 			if ($values['add'])
850 849
 			{
851 850
 				list($type) = each($values['add']);
852
-				return $this->edit(0,$action,$action_id,$type,$called_as);
851
+				return $this->edit(0, $action, $action_id, $type, $called_as);
853 852
 			}
854 853
 			elseif ($values['cancel'] && $own_referer)
855 854
 			{
@@ -860,14 +859,14 @@  discard block
 block discarded – undo
860 859
 			}
861 860
 			else
862 861
 			{
863
-				list($do,$do2) = each($values['main']);
862
+				list($do, $do2) = each($values['main']);
864 863
 				list($do_id) = @each($do2);
865
-				switch((string)$do)
864
+				switch ((string)$do)
866 865
 				{
867 866
 					case 'close':
868
-						$closesingle=true;
867
+						$closesingle = true;
869 868
 					case 'close_all':
870
-						$this->close($do_id,$called_as,$closesingle);
869
+						$this->close($do_id, $called_as, $closesingle);
871 870
 						break;
872 871
 					case 'view':
873 872
 						$value = array();
@@ -905,7 +904,7 @@  discard block
 block discarded – undo
905 904
 		$this->tmpl->read('infolog.index');
906 905
 		$values['nm']['options-filter'] = $this->filters;
907 906
 		$values['nm']['get_rows'] = 'infolog.infolog_ui.get_rows';
908
-		$values['nm']['options-filter2'] = (in_array($this->prefs['show_links'],array('all','no_describtion')) ? array() : array(
907
+		$values['nm']['options-filter2'] = (in_array($this->prefs['show_links'], array('all', 'no_describtion')) ? array() : array(
909 908
 			''               => 'default',
910 909
 		)) + array(
911 910
 			'no_describtion' => 'no details',
@@ -926,34 +925,34 @@  discard block
 block discarded – undo
926 925
 		else
927 926
 		{
928 927
 			// Allow saving parent ID into favorites
929
-			$values['nm']['favorites'] = array('action','action_id');
928
+			$values['nm']['favorites'] = array('action', 'action_id');
930 929
 		}
931 930
 
932 931
 		// Allow add actions even when there's no rows
933 932
 		$values['nm']['placeholder_actions'] = array('new');
934 933
 
935
-		if(!isset($values['nm']['filter2'])) $values['nm']['filter2'] = $this->prefs['nextmatch-'.($action ? 'infolog.'.$action : 'infolog.index.rows').'-details-pref'];
934
+		if (!isset($values['nm']['filter2'])) $values['nm']['filter2'] = $this->prefs['nextmatch-'.($action ? 'infolog.'.$action : 'infolog.index.rows').'-details-pref'];
936 935
 
937 936
 		// disable columns for main entry as set in the pref for details or no details
938 937
 		$values['nm']['columnselection_pref'] = 'nextmatch-'.($action ? 'infolog.'.$action : 'infolog.index.rows')
939
-			.($values['nm']['filter2']=='all' ? '-details' : '');
938
+			.($values['nm']['filter2'] == 'all' ? '-details' : '');
940 939
 		if ($action == 'sp')
941 940
 		{
942 941
 			$pref = $values['nm']['columnselection_pref'];
943
-			foreach(array('info_used_time_info_planned_time_info_replanned_time','info_datemodified','info_owner_info_responsible','customfields') as $name)
942
+			foreach (array('info_used_time_info_planned_time_info_replanned_time', 'info_datemodified', 'info_owner_info_responsible', 'customfields') as $name)
944 943
 			{
945
-				$values['main']['no_'.$name] = strpos($this->prefs[$pref],$name) === false;
944
+				$values['main']['no_'.$name] = strpos($this->prefs[$pref], $name) === false;
946 945
 			}
947 946
 			if (!$values['main']['no_customfields'])
948 947
 			{
949 948
 				// set the column-header of the main table for the customfields.
950
-				foreach(array_keys($this->bo->customfields) as $lname)
949
+				foreach (array_keys($this->bo->customfields) as $lname)
951 950
 				{
952
-					$values['main']['customfields'].=$lname."\n";
951
+					$values['main']['customfields'] .= $lname."\n";
953 952
 				}
954 953
 			}
955 954
 		}
956
-		if ($values['nm']['filter']=='bydate')
955
+		if ($values['nm']['filter'] == 'bydate')
957 956
 		{
958 957
 			foreach (array_keys($values['nm']['col_filter']) as $colfk)
959 958
 			{
@@ -986,7 +985,7 @@  discard block
 block discarded – undo
986 985
 		{
987 986
 			$values['css'] .= '<style type="text/css">@media screen { .infoDes {  '.
988 987
 				' max-height: '.
989
-				(($this->prefs['limit_des_lines'] ? $this->prefs['limit_des_lines'] : 5) * 1.35).	// dono why em is not real lines
988
+				(($this->prefs['limit_des_lines'] ? $this->prefs['limit_des_lines'] : 5) * 1.35).// dono why em is not real lines
990 989
 				'em; overflow: auto; }}</style>';
991 990
 		}
992 991
 
@@ -998,13 +997,13 @@  discard block
 block discarded – undo
998 997
 
999 998
 		// remove group-types user has not any rights to as filter
1000 999
 		// does not take implicit rights as delegated into account, so they will not be available as filters
1001
-		foreach($this->bo->group_owners as $type => $group)
1000
+		foreach ($this->bo->group_owners as $type => $group)
1002 1001
 		{
1003 1002
 			if (!isset($this->bo->grants[$group])) unset($sel_options['info_type'][$type]);
1004 1003
 		}
1005 1004
 
1006 1005
 
1007
-		return $this->tmpl->exec('infolog.infolog_ui.index',$values,$sel_options,$readonlys,$persist,$return_html ? -1 : 0);
1006
+		return $this->tmpl->exec('infolog.infolog_ui.index', $values, $sel_options, $readonlys, $persist, $return_html ? -1 : 0);
1008 1007
 	}
1009 1008
 
1010 1009
 	/**
@@ -1019,9 +1018,9 @@  discard block
 block discarded – undo
1019 1018
 		if ($this->bo->group_owners)
1020 1019
 		{
1021 1020
 			// remove types owned by groups the user has no edit grant
1022
-			foreach($this->bo->group_owners as $type => $group)
1021
+			foreach ($this->bo->group_owners as $type => $group)
1023 1022
 			{
1024
-				if (!($this->bo->grants[$group] & Acl::EDIT))
1023
+				if (!($this->bo->grants[$group]&Acl::EDIT))
1025 1024
 				{
1026 1025
 					unset($types[$type]);
1027 1026
 				}
@@ -1038,7 +1037,7 @@  discard block
 block discarded – undo
1038 1037
 	 */
1039 1038
 	private function get_actions(array $query)
1040 1039
 	{
1041
-		for($i = 0; $i <= 100; $i += 10)
1040
+		for ($i = 0; $i <= 100; $i += 10)
1042 1041
 		{
1043 1042
 			$percent[$i] = $i.'%';
1044 1043
 		}
@@ -1047,9 +1046,9 @@  discard block
 block discarded – undo
1047 1046
 		$types_add = array();
1048 1047
 		// Do not add deleted type to add or change menus
1049 1048
 		unset($types['delete']);
1050
-		foreach($types as $type => &$data)
1049
+		foreach ($types as $type => &$data)
1051 1050
 		{
1052
-			$image_exists = Api\Image::find('infolog',$type);
1051
+			$image_exists = Api\Image::find('infolog', $type);
1053 1052
 			$data = array(
1054 1053
 				'caption' => $data,
1055 1054
 				'icon' => $image_exists ? $type : 'infolog/navbar',
@@ -1061,9 +1060,9 @@  discard block
 block discarded – undo
1061 1060
 
1062 1061
 		$icons = null;
1063 1062
 		$statis = $this->bo->get_status($query['col_filter']['info_type'], $icons);
1064
-		foreach($statis as $type => &$data)
1063
+		foreach ($statis as $type => &$data)
1065 1064
 		{
1066
-			$image_exists = Api\Image::find('infolog',$icons[$type]);
1065
+			$image_exists = Api\Image::find('infolog', $icons[$type]);
1067 1066
 			$data = array(
1068 1067
 				'caption' => $data,
1069 1068
 				'icon' => $image_exists ? $icons[$type] : 'infolog/status',
@@ -1075,10 +1074,10 @@  discard block
 block discarded – undo
1075 1074
 				'caption' => 'Open',
1076 1075
 				'default' => true,
1077 1076
 				'allowOnMultiple' => false,
1078
-				'onExecute' => Api\Header\UserAgent::mobile()?'javaScript:app.infolog.viewEntry':'',
1077
+				'onExecute' => Api\Header\UserAgent::mobile() ? 'javaScript:app.infolog.viewEntry' : '',
1079 1078
 				'url' => 'menuaction=infolog.infolog_ui.edit&info_id=$id',
1080 1079
 				'popup' => Link::get_registry('infolog', 'add_popup'),
1081
-				'group' => $group=1,
1080
+				'group' => $group = 1,
1082 1081
 				'mobileViewTemplate' => 'edit?'.filemtime(Api\Etemplate\Widget\Template::rel2path('/infolog/templates/mobile/edit.xet'))
1083 1082
 			),
1084 1083
 			'parent' => array(
@@ -1152,7 +1151,7 @@  discard block
 block discarded – undo
1152 1151
 						'icon' => 'completed',
1153 1152
 					),
1154 1153
 					'cat' =>  Etemplate\Widget\Nextmatch::category_action(
1155
-						'infolog',$group,'Change category','cat_'
1154
+						'infolog', $group, 'Change category', 'cat_'
1156 1155
 					),
1157 1156
 					'responsible' => array(
1158 1157
 						'caption' => 'Delegation',
@@ -1190,7 +1189,7 @@  discard block
 block discarded – undo
1190 1189
 				'onExecute' => 'javaScript:app.infolog.infolog_menu_print'
1191 1190
 			)
1192 1191
 		);
1193
-		++$group;	// integration with other apps
1192
+		++$group; // integration with other apps
1194 1193
 		if ($GLOBALS['egw_info']['user']['apps']['filemanager'])
1195 1194
 		{
1196 1195
 			$actions['filemanager'] = array(
@@ -1208,7 +1207,7 @@  discard block
 block discarded – undo
1208 1207
 				'caption' => 'Schedule appointment',
1209 1208
 				'group' => $group,
1210 1209
 				'url' => 'menuaction=calendar.calendar_uiforms.edit&'.
1211
-					Link::get_registry('calendar', 'add_app') . '[]=infolog&'.Link::get_registry('calendar','add_id').'[]=$id',
1210
+					Link::get_registry('calendar', 'add_app').'[]=infolog&'.Link::get_registry('calendar', 'add_id').'[]=$id',
1212 1211
 				'allowOnMultiple' => false,
1213 1212
 				'popup' => Link::get_registry('calendar', 'add_popup'),
1214 1213
 			);
@@ -1232,7 +1231,7 @@  discard block
 block discarded – undo
1232 1231
 				'hint' => 'Convert to a ticket',
1233 1232
 				'group' => $group,
1234 1233
 				'url' => 'menuaction=tracker.tracker_ui.edit&'.
1235
-					Link::get_registry('tracker', 'add_app') . '[]=infolog&'.Link::get_registry('tracker','add_id').'[]=$id',
1234
+					Link::get_registry('tracker', 'add_app').'[]=infolog&'.Link::get_registry('tracker', 'add_id').'[]=$id',
1236 1235
 				'allowOnMultiple' => false,
1237 1236
 				'popup' => Link::get_registry('tracker', 'add_popup'),
1238 1237
 			);
@@ -1245,7 +1244,7 @@  discard block
 block discarded – undo
1245 1244
 		$actions['ical'] = array(
1246 1245
 			'icon' => 'ical',
1247 1246
 			'caption' => 'Export iCal',
1248
-			'postSubmit' => true,	// download needs post submit to work
1247
+			'postSubmit' => true, // download needs post submit to work
1249 1248
 			'group' => $group,
1250 1249
 			'allowOnMultiple' => true,
1251 1250
 			'hideOnMobile' => true
@@ -1298,14 +1297,14 @@  discard block
 block discarded – undo
1298 1297
 		$success = $failed = 0;
1299 1298
 		if ($use_all)
1300 1299
 		{
1301
-			@set_time_limit(0);                     // switch off the execution time limit, as it's for big selections to small
1302
-			$query['num_rows'] = -1;        // all
1300
+			@set_time_limit(0); // switch off the execution time limit, as it's for big selections to small
1301
+			$query['num_rows'] = -1; // all
1303 1302
 			$result = $readonlys = null;
1304
-			$this->get_rows($query,$result,$readonlys);
1303
+			$this->get_rows($query, $result, $readonlys);
1305 1304
 			$checked = array();
1306
-			foreach($result as $key => $info)
1305
+			foreach ($result as $key => $info)
1307 1306
 			{
1308
-				if(is_numeric($key))
1307
+				if (is_numeric($key))
1309 1308
 				{
1310 1309
 					$checked[] = $info['info_id'];
1311 1310
 				}
@@ -1316,29 +1315,29 @@  discard block
 block discarded – undo
1316 1315
 		list($action, $settings) = explode('_', $_action, 2);
1317 1316
 
1318 1317
 		// Actions that can handle a list of IDs
1319
-		switch($action)
1318
+		switch ($action)
1320 1319
 		{
1321 1320
 			case 'link':
1322 1321
 				list($add_remove, $link) = explode('_', $settings, 2);
1323
-				list($app, $link_id) = explode(strpos($link,':') !== false ? ':' : ',', $link);
1324
-				if(!$link_id)
1322
+				list($app, $link_id) = explode(strpos($link, ':') !== false ? ':' : ',', $link);
1323
+				if (!$link_id)
1325 1324
 				{
1326 1325
 					$action_msg = 'linked';
1327 1326
 					$msg = lang('You need to select an entry for linking.');
1328 1327
 					break;
1329 1328
 				}
1330 1329
 				$title = Link::title($app, $link_id);
1331
-				foreach($checked as $id)
1330
+				foreach ($checked as $id)
1332 1331
 				{
1333
-					if(!$this->bo->check_access($id, Acl::EDIT))
1332
+					if (!$this->bo->check_access($id, Acl::EDIT))
1334 1333
 					{
1335 1334
 						$failed++;
1336 1335
 						continue;
1337 1336
 					}
1338
-					if($add_remove == 'add')
1337
+					if ($add_remove == 'add')
1339 1338
 					{
1340 1339
 						$action_msg = lang('linked to %1', $title);
1341
-						if(Link::link('infolog', $id, $app, $link_id))
1340
+						if (Link::link('infolog', $id, $app, $link_id))
1342 1341
 						{
1343 1342
 							$success++;
1344 1343
 						}
@@ -1365,20 +1364,20 @@  discard block
 block discarded – undo
1365 1364
 			case 'ical':
1366 1365
 				// infolog_ical lets horde be auto-loaded, so it must go first
1367 1366
 				$boical = new infolog_ical();
1368
-				Api\Header\Content::type('todo.ics','text/calendar');
1367
+				Api\Header\Content::type('todo.ics', 'text/calendar');
1369 1368
 				echo $boical->exportvCalendar($checked);
1370 1369
 				exit();
1371 1370
 
1372 1371
 		}
1373 1372
 
1374 1373
 		// Actions that need to loop
1375
-		foreach($checked as $id)
1374
+		foreach ($checked as $id)
1376 1375
 		{
1377
-			if(!$entry = $this->bo->read($id))
1376
+			if (!$entry = $this->bo->read($id))
1378 1377
 			{
1379 1378
 				continue;
1380 1379
 			}
1381
-			switch($action)
1380
+			switch ($action)
1382 1381
 			{
1383 1382
 				case 'close':
1384 1383
 					$action_msg = lang('closed');
@@ -1388,8 +1387,8 @@  discard block
 block discarded – undo
1388 1387
 
1389 1388
 				case 'delete':
1390 1389
 					$action_msg = $settings == 'sub' ? lang(' (and children) deleted') : lang('deleted');
1391
-					$result = $this->bo->delete($id, $settings=='sub', false, $skip_notifications);
1392
-					if($result == true)
1390
+					$result = $this->bo->delete($id, $settings == 'sub', false, $skip_notifications);
1391
+					if ($result == true)
1393 1392
 					{
1394 1393
 						$success++;
1395 1394
 					}
@@ -1402,14 +1401,14 @@  discard block
 block discarded – undo
1402 1401
 				case 'type':
1403 1402
 					$action_msg = lang('changed type');
1404 1403
 					// Dont allow to change the type, if user has no delete rights from the group-owner
1405
-					if ($id && !($this->bo->grants[$entry['info_owner']] & Acl::DELETE))
1404
+					if ($id && !($this->bo->grants[$entry['info_owner']]&Acl::DELETE))
1406 1405
 					{
1407 1406
 						$failed++;
1408 1407
 						break;
1409 1408
 					}
1410 1409
 					$entry['info_type'] = $settings;
1411 1410
 					try {
1412
-						$this->bo->write($entry, true,true,true,$skip_notifications,true); // Throw exceptions
1411
+						$this->bo->write($entry, true, true, true, $skip_notifications, true); // Throw exceptions
1413 1412
 					}
1414 1413
 					catch (Api\Exception\WrongUserinput $e)
1415 1414
 					{
@@ -1424,11 +1423,11 @@  discard block
 block discarded – undo
1424 1423
 					$action_msg = lang('changed completion to %1%', $settings);
1425 1424
 					$entry['info_percent'] = $settings;
1426 1425
 					// Done and not-started entries will get changed right back if we don't change the status too
1427
-					if(in_array($entry['info_status'],array('not-started','done','billed','cancelled','archive')))
1426
+					if (in_array($entry['info_status'], array('not-started', 'done', 'billed', 'cancelled', 'archive')))
1428 1427
 					{
1429 1428
 						$entry['info_status'] = 'ongoing';
1430 1429
 					}
1431
-					if($entry['info_percent'] == 0)
1430
+					if ($entry['info_percent'] == 0)
1432 1431
 					{
1433 1432
 						$entry['info_status'] = 'not-started';
1434 1433
 					}
@@ -1436,7 +1435,7 @@  discard block
 block discarded – undo
1436 1435
 					{
1437 1436
 						$entry['info_status'] = 'done';
1438 1437
 					}
1439
-					if($this->bo->write($entry, true,true,true,$skip_notifications))
1438
+					if ($this->bo->write($entry, true, true, true, $skip_notifications))
1440 1439
 					{
1441 1440
 						$success++;
1442 1441
 					}
@@ -1448,24 +1447,23 @@  discard block
 block discarded – undo
1448 1447
 
1449 1448
 				case 'undelete':	// set it to valid status != 'deleted' for that type
1450 1449
 					$settings = isset($this->bo->status[$entry['info_type']]['done']) ?
1451
-						$this->bo->status[$entry['info_type']]['done'] :
1452
-						$this->bo->status['defaults'][$entry['info_type']];
1450
+						$this->bo->status[$entry['info_type']]['done'] : $this->bo->status['defaults'][$entry['info_type']];
1453 1451
 					// fall-through
1454 1452
 				case 'status':
1455
-					if(isset($this->bo->status[$entry['info_type']][$settings]))
1453
+					if (isset($this->bo->status[$entry['info_type']][$settings]))
1456 1454
 					{
1457 1455
 						$action_msg = lang('changed status to %1', lang($this->bo->status[$entry['info_type']][$settings]));
1458
-						if(!in_array($settings,array('done','billed','cancelled','archive')) && $entry['info_percent'] == 100)
1456
+						if (!in_array($settings, array('done', 'billed', 'cancelled', 'archive')) && $entry['info_percent'] == 100)
1459 1457
 						{
1460 1458
 							// Done entries will get changed right back if we don't change the completion too
1461 1459
 							$entry['info_percent'] = 10;
1462 1460
 						}
1463
-						if(in_array($settings, array('not-started')) && $entry['info_percent'] > 0)
1461
+						if (in_array($settings, array('not-started')) && $entry['info_percent'] > 0)
1464 1462
 						{
1465 1463
 							$entry['info_percent'] = 0;
1466 1464
 						}
1467 1465
 						$entry['info_status'] = $settings;
1468
-						if($this->bo->write($entry, true,true,true,$skip_notifications))
1466
+						if ($this->bo->write($entry, true, true, true, $skip_notifications))
1469 1467
 						{
1470 1468
 							$success++;
1471 1469
 						}
@@ -1478,7 +1476,7 @@  discard block
 block discarded – undo
1478 1476
 					break;
1479 1477
 
1480 1478
 				case 'cat':
1481
-					if($settings)
1479
+					if ($settings)
1482 1480
 					{
1483 1481
 						$cat_name = Api\Categories::id2name($settings);
1484 1482
 						$action_msg = lang('changed category to %1', $cat_name);
@@ -1488,7 +1486,7 @@  discard block
 block discarded – undo
1488 1486
 						$action_msg = lang('removed category');
1489 1487
 					}
1490 1488
 					$entry['info_cat'] = $settings;
1491
-					if($this->bo->write($entry, true,true,true,$skip_notifications))
1489
+					if ($this->bo->write($entry, true, true, true, $skip_notifications))
1492 1490
 					{
1493 1491
 						$success++;
1494 1492
 					}
@@ -1500,15 +1498,15 @@  discard block
 block discarded – undo
1500 1498
 
1501 1499
 				case 'responsible':
1502 1500
 					list($add_remove, $user_str) = explode('_', $settings, 2);
1503
-					$action_msg = ($add_remove == 'ok' ? lang('changed') : ($add_remove == 'add' ? lang('added') : lang('removed'))) . ' ';
1501
+					$action_msg = ($add_remove == 'ok' ? lang('changed') : ($add_remove == 'add' ? lang('added') : lang('removed'))).' ';
1504 1502
 					$names = array();
1505 1503
 					$users = explode(',', $user_str);
1506
-					foreach($users as $account_id)
1504
+					foreach ($users as $account_id)
1507 1505
 					{
1508 1506
 						$names[] = Api\Accounts::username($account_id);
1509 1507
 					}
1510 1508
 					$action_msg .= implode(', ', $names);
1511
-					if($add_remove == 'ok')
1509
+					if ($add_remove == 'ok')
1512 1510
 					{
1513 1511
 						$entry['info_responsible'] = (array)$users;
1514 1512
 					}
@@ -1517,7 +1515,7 @@  discard block
 block discarded – undo
1517 1515
 						$function = $add_remove == 'add' ? 'array_merge' : 'array_diff';
1518 1516
 						$entry['info_responsible'] = array_unique($function($entry['info_responsible'], (array)$users));
1519 1517
 					}
1520
-					if($this->bo->write($entry, true,true,true,$skip_notifications))
1518
+					if ($this->bo->write($entry, true, true, true, $skip_notifications))
1521 1519
 					{
1522 1520
 						$success++;
1523 1521
 					}
@@ -1538,10 +1536,10 @@  discard block
 block discarded – undo
1538 1536
 	 * @param string $_referer=''
1539 1537
 	 * @param boolean $closesingle=false
1540 1538
 	 */
1541
-	function close($values=0,$_referer='',$closesingle=false,$skip_notification = false)
1539
+	function close($values = 0, $_referer = '', $closesingle = false, $skip_notification = false)
1542 1540
 	{
1543 1541
 		//echo "<p>".__METHOD__."($values,$referer,$closeall)</p>\n";
1544
-		$info_id = (int) (is_array($values) ? $values['info_id'] : ($values ? $values : $_GET['info_id']));
1542
+		$info_id = (int)(is_array($values) ? $values['info_id'] : ($values ? $values : $_GET['info_id']));
1545 1543
 		$referer = is_array($values) ? $values['referer'] : $_referer;
1546 1544
 
1547 1545
 		if ($info_id)
@@ -1551,11 +1549,11 @@  discard block
 block discarded – undo
1551 1549
 			$status = $info['info_status'];
1552 1550
 			// closed stati assumed array('done','billed','cancelled')
1553 1551
 			if (isset($this->bo->status[$info['info_type']]['done'])) {
1554
-				$status ='done';
1552
+				$status = 'done';
1555 1553
 			} elseif (isset($this->bo->status[$info['info_type']]['billed'])) {
1556
-				$status ='billed';
1554
+				$status = 'billed';
1557 1555
 			} elseif (isset($this->bo->status[$info['info_type']]['cancelled'])) {
1558
-				$status ='cancelled';
1556
+				$status = 'cancelled';
1559 1557
 			}
1560 1558
 			#_debug_array($status);
1561 1559
 			$values = array(
@@ -1565,15 +1563,15 @@  discard block
 block discarded – undo
1565 1563
 				'info_percent'=> 100,
1566 1564
 				'info_datecompleted' => $this->bo->now_su,
1567 1565
 			);
1568
-			$this->bo->write($values, true,true,true,$skip_notification);
1566
+			$this->bo->write($values, true, true, true, $skip_notification);
1569 1567
 
1570
-			$query = array('action'=>'sp','action_id'=>$info_id);
1568
+			$query = array('action'=>'sp', 'action_id'=>$info_id);
1571 1569
 			if (!$closesingle) {
1572
-				foreach((array)$this->bo->search($query) as $info)
1570
+				foreach ((array)$this->bo->search($query) as $info)
1573 1571
 				{
1574 1572
 					if ($info['info_id_parent'] == $info_id)	// search also returns linked entries!
1575 1573
 					{
1576
-						$this->close($info['info_id'],$referer,$closesingle,$skip_notification);	// we call ourselfs recursive to process subs from subs too
1574
+						$this->close($info['info_id'], $referer, $closesingle, $skip_notification); // we call ourselfs recursive to process subs from subs too
1577 1575
 					}
1578 1576
 				}
1579 1577
 			}
@@ -1589,9 +1587,9 @@  discard block
 block discarded – undo
1589 1587
 	 * @param string $called_by
1590 1588
 	 * @param boolean $skip_notification Do not send notification of deletion
1591 1589
 	 */
1592
-	function delete($values=0,$_referer='',$called_by='',$skip_notification=False)
1590
+	function delete($values = 0, $_referer = '', $called_by = '', $skip_notification = False)
1593 1591
 	{
1594
-		$info_id = (int) (is_array($values) ? $values['info_id'] : ($values ? $values : $_GET['info_id']));
1592
+		$info_id = (int)(is_array($values) ? $values['info_id'] : ($values ? $values : $_GET['info_id']));
1595 1593
 		$referer = is_array($values) ? $values['referer'] : $_referer;
1596 1594
 
1597 1595
 		if (!is_array($values) && $info_id > 0 && !$this->bo->anzSubs($info_id))	// entries without subs get confirmed by javascript
@@ -1602,9 +1600,9 @@  discard block
 block discarded – undo
1602 1600
 
1603 1601
 		if (is_array($values) || $info_id <= 0)
1604 1602
 		{
1605
-			if (($values['delete'] || $values['delete_subs']) && $info_id > 0 && $this->bo->check_access($info_id,Acl::DELETE))
1603
+			if (($values['delete'] || $values['delete_subs']) && $info_id > 0 && $this->bo->check_access($info_id, Acl::DELETE))
1606 1604
 			{
1607
-				$deleted = $this->bo->delete($info_id,$values['delete_subs'],$values['info_id_parent'], $skip_notification);
1605
+				$deleted = $this->bo->delete($info_id, $values['delete_subs'], $values['info_id_parent'], $skip_notification);
1608 1606
 			}
1609 1607
 			if ($called_by)		// direct call from the same request
1610 1608
 			{
@@ -1614,7 +1612,7 @@  discard block
 block discarded – undo
1614 1612
 			{
1615 1613
 				$this->edit(array(
1616 1614
 					'info_id' => $info_id,
1617
-					'button'  => array('deleted' => true),	// not delete!
1615
+					'button'  => array('deleted' => true), // not delete!
1618 1616
 					'referer' => $referer,
1619 1617
 					'msg'     => $deleted ? lang('Infolog entry deleted') : '',
1620 1618
 				));
@@ -1622,7 +1620,7 @@  discard block
 block discarded – undo
1622 1620
 			return $referer ? $this->tmpl->location($referer) : $this->index();
1623 1621
 		}
1624 1622
 		$readonlys = $values = array();
1625
-		$values['main'][1] = $this->get_info($info_id,$readonlys['main']);
1623
+		$values['main'][1] = $this->get_info($info_id, $readonlys['main']);
1626 1624
 
1627 1625
 		$this->tmpl->read('infolog.delete');
1628 1626
 
@@ -1643,7 +1641,7 @@  discard block
 block discarded – undo
1643 1641
 		$GLOBALS['egw_info']['flags']['app_header'] = lang('InfoLog').' - '.lang('Delete');
1644 1642
 		$GLOBALS['egw_info']['flags']['params']['manual'] = array('page' => 'ManualInfologDelete');
1645 1643
 
1646
-		$this->tmpl->exec('infolog.infolog_ui.delete',$values,array(),$readonlys,$persist,$called_by == 'edit' ? 2 : 0);
1644
+		$this->tmpl->exec('infolog.infolog_ui.delete', $values, array(), $readonlys, $persist, $called_by == 'edit' ? 2 : 0);
1647 1645
 	}
1648 1646
 
1649 1647
 	/**
@@ -1655,77 +1653,77 @@  discard block
 block discarded – undo
1655 1653
 	 * @param string $type Type of log-entry: note,todo,task
1656 1654
 	 * @param string $referer array with param/get-vars of the refering page
1657 1655
 	 */
1658
-	function edit($content = null,$action = '',$action_id=0,$type='',$referer='')
1656
+	function edit($content = null, $action = '', $action_id = 0, $type = '', $referer = '')
1659 1657
 	{
1660 1658
 		if (($submit = is_array($content)))
1661 1659
 		{
1662 1660
 			//echo "infolog_ui::edit: content="; _debug_array($content);
1663 1661
 			$info_id   = $content['info_id'];
1664
-			$action    = $content['action'];    unset($content['action']);
1662
+			$action    = $content['action']; unset($content['action']);
1665 1663
 			$action_id = $content['action_id']; unset($content['action_id']);
1666
-			$referer   = $content['referer'];   unset($content['referer']);
1667
-			$no_popup  = $content['no_popup'];  unset($content['no_popup']);
1664
+			$referer   = $content['referer']; unset($content['referer']);
1665
+			$no_popup  = $content['no_popup']; unset($content['no_popup']);
1668 1666
 
1669 1667
 			list($button) = @each($content['button']);
1670
-			if (!$button && $action) $button = $action;	// action selectbox
1668
+			if (!$button && $action) $button = $action; // action selectbox
1671 1669
 			//info_cc expects an comma separated string
1672 1670
 			//error_log(__METHOD__.__LINE__.array2string($content));
1673 1671
 			if (empty($content['info_cc'])) $content['info_cc'] = "";
1674 1672
 			if (is_array($content['info_cc']))
1675 1673
 			{
1676
-				foreach($content['info_cc'] as $i => $value)
1674
+				foreach ($content['info_cc'] as $i => $value)
1677 1675
 				{
1678 1676
 					//imap_rfc822 should not be used, but it works reliable here, until we have some regex solution or use horde stuff
1679 1677
 					$addresses = imap_rfc822_parse_adrlist($value, '');
1680 1678
 					//error_log(__METHOD__.__LINE__.$value.'->'.array2string($addresses[0]));
1681
-					$content['info_cc'][$i]=$addresses[0]->host ? $addresses[0]->mailbox.'@'.$addresses[0]->host : $addresses[0]->mailbox;
1679
+					$content['info_cc'][$i] = $addresses[0]->host ? $addresses[0]->mailbox.'@'.$addresses[0]->host : $addresses[0]->mailbox;
1682 1680
 				}
1683
-				if (!empty($content['info_cc'])) $content['info_cc'] = implode(',',$content['info_cc']);
1681
+				if (!empty($content['info_cc'])) $content['info_cc'] = implode(',', $content['info_cc']);
1684 1682
 			}
1685 1683
 			unset($content['button']);
1686 1684
 			if ($button)
1687 1685
 			{
1688 1686
 				// Copy or schedule Infolog
1689
-				if (in_array($button,array('copy','schedule','ical','tracker')))
1687
+				if (in_array($button, array('copy', 'schedule', 'ical', 'tracker')))
1690 1688
 				{
1691 1689
 					$action = $button;
1692
-					if (!$info_id || $this->bo->check_access($info_id,Acl::EDIT))
1690
+					if (!$info_id || $this->bo->check_access($info_id, Acl::EDIT))
1693 1691
 					{
1694
-						$button = 'apply';	// need to store infolog first
1692
+						$button = 'apply'; // need to store infolog first
1695 1693
 					}
1696 1694
 				}
1697 1695
 				//Validate the enddate must be grather than startdate
1698 1696
 				if (!empty($content['info_enddate']) && !empty($content['info_startdate']))
1699 1697
 				{
1700
-					$duration_date = $content['info_enddate']-$content['info_startdate'];
1698
+					$duration_date = $content['info_enddate'] - $content['info_startdate'];
1701 1699
 					if ($duration_date < 0)
1702 1700
 					{
1703 1701
 						$this->tmpl->set_validation_error('info_startdate', lang('Startdate must be before Enddate!!!'));
1704
-						$button = $action = '';	// stop save or apply
1702
+						$button = $action = ''; // stop save or apply
1705 1703
 					}
1706 1704
 				}
1707 1705
 				//echo "<p>infolog_ui::edit(info_id=$info_id) '$button' button pressed, content="; _debug_array($content);
1708 1706
 				if (($button == 'save' || $button == 'apply') && isset($content['info_subject']) && empty($content['info_subject']))
1709 1707
 				{
1710
-					$this->tmpl->set_validation_error('info_subject',lang('Field must not be empty !!!'));
1711
-					$button = $action = '';	// stop save or apply
1708
+					$this->tmpl->set_validation_error('info_subject', lang('Field must not be empty !!!'));
1709
+					$button = $action = ''; // stop save or apply
1712 1710
 				}
1713 1711
 				if (($button == 'save' || $button == 'apply') && $info_id)
1714 1712
 				{
1715 1713
 					$old = $this->bo->read($info_id);
1716
-					if (!($edit_acl = $this->bo->check_access($info_id,Acl::EDIT)))
1714
+					if (!($edit_acl = $this->bo->check_access($info_id, Acl::EDIT)))
1717 1715
 					{
1718 1716
 						$status_only = $this->bo->is_responsible($old);
1719
-						$undelete = $this->bo->check_access($old,infolog_bo::ACL_UNDELETE);
1717
+						$undelete = $this->bo->check_access($old, infolog_bo::ACL_UNDELETE);
1720 1718
 					}
1721 1719
 				}
1722 1720
 				if (($button == 'save' || $button == 'apply') && (!$info_id || $edit_acl || $status_only || $undelete))
1723 1721
 				{
1724
-					$operation = $info_id ?  'edit' : 'add';
1722
+					$operation = $info_id ? 'edit' : 'add';
1725 1723
 					if ($content['info_contact'])
1726 1724
 					{
1727 1725
 						$old_link_id = (int)$content['info_link_id'];
1728
-						if(is_array($content['info_contact']))
1726
+						if (is_array($content['info_contact']))
1729 1727
 						{
1730 1728
 							// eTemplate2 returns the array all ready
1731 1729
 							$app = $content['info_contact']['app'];
@@ -1738,11 +1736,11 @@  discard block
 block discarded – undo
1738 1736
 						}
1739 1737
 						elseif ($app && $id)
1740 1738
 						{
1741
-							if(!is_array($content['link_to']))
1739
+							if (!is_array($content['link_to']))
1742 1740
 							{
1743 1741
 								$content['link_to'] = array();
1744 1742
 							}
1745
-							$content['info_link_id'] = (int)($info_link_id = Link::link('infolog',$content['link_to']['to_id'],$app,$id));
1743
+							$content['info_link_id'] = (int)($info_link_id = Link::link('infolog', $content['link_to']['to_id'], $app, $id));
1746 1744
 						}
1747 1745
 						else
1748 1746
 						{
@@ -1752,7 +1750,7 @@  discard block
 block discarded – undo
1752 1750
 						{
1753 1751
 							$link = Link::get_link($old_link_id);
1754 1752
 							// remove selected project, if removed link is that project
1755
-							if($link['link_app2'] == 'projectmanager' && $link['link_id2'] == $content['old_pm_id'])
1753
+							if ($link['link_app2'] == 'projectmanager' && $link['link_id2'] == $content['old_pm_id'])
1756 1754
 							{
1757 1755
 								unset($content['pm_id'], $content['old_pm_id']);
1758 1756
 							}
@@ -1766,39 +1764,38 @@  discard block
 block discarded – undo
1766 1764
 					}
1767 1765
 					if (is_array($content['link_to']['to_id']) && count($content['link_to']['to_id']))
1768 1766
 					{
1769
-						$content['info_link_id'] = 0;	// as field has to be int
1767
+						$content['info_link_id'] = 0; // as field has to be int
1770 1768
 					}
1771 1769
 					$active_tab = $content['tabs'];
1772 1770
 					if (!($info_id = $this->bo->write($content, true, true, true, $content['no_notifications'])))
1773 1771
 					{
1774
-						$content['msg'] = $info_id !== 0 || !$content['info_id'] ? lang('Error: saving the entry') :
1775
-							lang('Error: the entry has been updated since you opened it for editing!').'<br />'.
1776
-							lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.','<a href="'.
1777
-								htmlspecialchars(Egw::link('/index.php',array(
1772
+						$content['msg'] = $info_id !== 0 || !$content['info_id'] ? lang('Error: saving the entry') : lang('Error: the entry has been updated since you opened it for editing!').'<br />'.
1773
+							lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.', '<a href="'.
1774
+								htmlspecialchars(Egw::link('/index.php', array(
1778 1775
 									'menuaction' => 'infolog.infolog_ui.edit',
1779 1776
 									'info_id'    => $content['info_id'],
1780 1777
 									'no_popup'   => $no_popup,
1781 1778
 									'referer'    => $referer,
1782
-								))).'">','</a>');
1783
-						$button = $action = '';	// not exiting edit
1779
+								))).'">', '</a>');
1780
+						$button = $action = ''; // not exiting edit
1784 1781
 						$info_id = $content['info_id'];
1785 1782
 					}
1786 1783
 					else
1787 1784
 					{
1788
-						$GLOBALS['egw']->preferences->add('infolog','preferred_type',$content['info_type']);
1789
-						$GLOBALS['egw']->preferences->save_repository(false,'user',false);
1785
+						$GLOBALS['egw']->preferences->add('infolog', 'preferred_type', $content['info_type']);
1786
+						$GLOBALS['egw']->preferences->save_repository(false, 'user', false);
1790 1787
 						$content['msg'] = lang('InfoLog entry saved');
1791
-						Framework::refresh_opener($content['msg'],'infolog',$info_id,$operation);
1788
+						Framework::refresh_opener($content['msg'], 'infolog', $info_id, $operation);
1792 1789
 					}
1793 1790
 					$content['tabs'] = $active_tab;
1794
-					if ((int) $content['pm_id'] != (int) $content['old_pm_id'])
1791
+					if ((int)$content['pm_id'] != (int)$content['old_pm_id'])
1795 1792
 					{
1796 1793
 						//echo "<p>pm_id changed: $content[old_pm_id] -> $content[pm_id]</p>\n";
1797 1794
 						// update links accordingly, if selected project changed
1798 1795
 						if ($content['pm_id'])
1799 1796
 						{
1800 1797
 							//echo "<p>this->link->link('infolog',{$content['link_to']['to_id']},'projectmanager',{$content['pm_id']});</p>";
1801
-							Link::link('infolog',$content['link_to']['to_id'],'projectmanager',$content['pm_id']);
1798
+							Link::link('infolog', $content['link_to']['to_id'], 'projectmanager', $content['pm_id']);
1802 1799
 							// making the project the selected link, if no other link selected
1803 1800
 							if (!$info_link_id || $info_link_id == 'projectmanager:'.$content['old_pm_id'])
1804 1801
 							{
@@ -1808,7 +1805,7 @@  discard block
 block discarded – undo
1808 1805
 						if ($content['old_pm_id'])
1809 1806
 						{
1810 1807
 							//echo "<p>this->link->unlink2(0,infolog,{$content['link_to']['to_id']},0,'projectmanager',{$content['old_pm_id']});</p>\n";
1811
-							Link::unlink2(0,infolog,$content['link_to']['to_id'],0,'projectmanager',$content['old_pm_id']);
1808
+							Link::unlink2(0, infolog, $content['link_to']['to_id'], 0, 'projectmanager', $content['old_pm_id']);
1812 1809
 						}
1813 1810
 						$content['old_pm_id'] = $content['pm_id'];
1814 1811
 					}
@@ -1816,14 +1813,14 @@  discard block
 block discarded – undo
1816 1813
 					if ($info_id && is_array($content['link_to']['to_id']) && count($content['link_to']['to_id']))
1817 1814
 					{
1818 1815
 						//echo "<p>writing links for new entry $info_id</p>\n"; _debug_array($content['link_to']['to_id']);
1819
-						Link::link('infolog',$info_id,$content['link_to']['to_id']);
1816
+						Link::link('infolog', $info_id, $content['link_to']['to_id']);
1820 1817
 						$content['link_to']['to_id'] = $info_id;
1821 1818
 					}
1822
-					if ($info_link_id && strpos($info_link_id,':') !== false)	// updating info_link_id if necessary
1819
+					if ($info_link_id && strpos($info_link_id, ':') !== false)	// updating info_link_id if necessary
1823 1820
 					{
1824
-						list($app,$id) = explode(':',$info_link_id);
1825
-						$link = Link::get_link('infolog',$info_id,$app,$id);
1826
-						if ((int) $content['info_link_id'] != (int) $link['link_id'])
1821
+						list($app, $id) = explode(':', $info_link_id);
1822
+						$link = Link::get_link('infolog', $info_id, $app, $id);
1823
+						if ((int)$content['info_link_id'] != (int)$link['link_id'])
1827 1824
 						{
1828 1825
 							$content['info_link_id'] = $link['link_id'];
1829 1826
 
@@ -1835,9 +1832,9 @@  discard block
 block discarded – undo
1835 1832
 								'info_owner'   => $content['info_owner'],
1836 1833
 							);
1837 1834
 							//echo "<p>updating info_link_id: ".print_r($to_write,true)."</p>\n";
1838
-							$this->bo->write($to_write,False,true,true,true);	// last true = no notifications, as no real change
1835
+							$this->bo->write($to_write, False, true, true, true); // last true = no notifications, as no real change
1839 1836
 							// we need eg. the new modification date, for further updates
1840
-							$content = array_merge($content,$to_write);
1837
+							$content = array_merge($content, $to_write);
1841 1838
 						}
1842 1839
 					}
1843 1840
 				}
@@ -1848,33 +1845,33 @@  discard block
 block discarded – undo
1848 1845
 						'action' => $action,
1849 1846
 						'action_id' => $action_id
1850 1847
 					);
1851
-					if (!($content['msg'] = $this->delete($info_id,$referer,'edit'))) return;	// checks ACL first
1848
+					if (!($content['msg'] = $this->delete($info_id, $referer, 'edit'))) return; // checks ACL first
1852 1849
 
1853
-					Framework::refresh_opener($content['msg'],'infolog',$info_id,'delete');
1850
+					Framework::refresh_opener($content['msg'], 'infolog', $info_id, 'delete');
1854 1851
 				}
1855 1852
 				// called again after delete confirmation dialog
1856
-				elseif ($button == 'deleted'  && $content['msg'])
1853
+				elseif ($button == 'deleted' && $content['msg'])
1857 1854
 				{
1858
-					Framework::refresh_opener($content['msg'],'infolog',$info_id,'delete');
1855
+					Framework::refresh_opener($content['msg'], 'infolog', $info_id, 'delete');
1859 1856
 				}
1860 1857
 				if ($button == 'save' || $button == 'cancel' || $button == 'delete' || $button == 'deleted')
1861 1858
 				{
1862 1859
 					if ($no_popup)
1863 1860
 					{
1864
-						Egw::redirect_link($referer,array('msg' => $content['msg']));
1861
+						Egw::redirect_link($referer, array('msg' => $content['msg']));
1865 1862
 					}
1866 1863
 					Framework::window_close();
1867 1864
 				}
1868 1865
 			}
1869 1866
 			// on a type-change, set the status to the default status of that type, if the actual status is not supported by the new type
1870
-			if (!array_key_exists($content['info_status'],$this->bo->status[$content['info_type']]))
1867
+			if (!array_key_exists($content['info_status'], $this->bo->status[$content['info_type']]))
1871 1868
 			{
1872 1869
 				$content['info_status'] = $this->bo->status['defaults'][$content['info_type']];
1873 1870
 				// Make sure we don't end up with invalid status / percent combinations
1874 1871
 				if ($content['info_status'] != 'done')
1875 1872
 				{
1876 1873
 					$content['info_datecompleted'] = '';
1877
-					if((int)$content['info_percent'] === 100)
1874
+					if ((int)$content['info_percent'] === 100)
1878 1875
 					{
1879 1876
 						$content['info_percent'] = 10;
1880 1877
 					}
@@ -1883,7 +1880,7 @@  discard block
 block discarded – undo
1883 1880
 				{
1884 1881
 					$content['info_percent'] = 100;
1885 1882
 				}
1886
-				if($content['info_status'] != 'not-started' && (int)$content['info_percent'] == 0)
1883
+				if ($content['info_status'] != 'not-started' && (int)$content['info_percent'] == 0)
1887 1884
 				{
1888 1885
 					$content['info_percent'] = 10;
1889 1886
 				}
@@ -1892,25 +1889,24 @@  discard block
 block discarded – undo
1892 1889
 		else	// new call via GET
1893 1890
 		{
1894 1891
 			//echo "<p>infolog_ui::edit: info_id=$info_id,  action='$action', action_id='$action_id', type='$type', referer='$referer'</p>\n";
1895
-			$action    = $action    ? $action    : $_REQUEST['action'];
1892
+			$action    = $action ? $action : $_REQUEST['action'];
1896 1893
 			$action_id = $action_id ? $action_id : $_REQUEST['action_id'];
1897
-			$info_id   = $content   ? $content   : $_REQUEST['info_id'];
1898
-			$type      = $type      ? $type      : $_REQUEST['type'];
1899
-			$referer   = $referer !== '' ? $referer : ($_GET['referer'] ? $_GET['referer'] :
1900
-				Api\Header\Referer::get('/index.php?menuaction=infolog.infolog_ui.index'));
1901
-			if (strpos($referer, 'msg=') !== false) $referer = preg_replace('/([&?]{1})msg=[^&]+&?/','\\1',$referer);	// remove previou/old msg from referer
1894
+			$info_id   = $content ? $content : $_REQUEST['info_id'];
1895
+			$type      = $type ? $type : $_REQUEST['type'];
1896
+			$referer   = $referer !== '' ? $referer : ($_GET['referer'] ? $_GET['referer'] : Api\Header\Referer::get('/index.php?menuaction=infolog.infolog_ui.index'));
1897
+			if (strpos($referer, 'msg=') !== false) $referer = preg_replace('/([&?]{1})msg=[^&]+&?/', '\\1', $referer); // remove previou/old msg from referer
1902 1898
 			$no_popup  = $_GET['no_popup'];
1903
-			$print = (int) $_REQUEST['print'];
1899
+			$print = (int)$_REQUEST['print'];
1904 1900
 			//echo "<p>infolog_ui::edit: info_id=$info_id,  action='$action', action_id='$action_id', type='$type', referer='$referer'</p>\n";
1905 1901
 
1906
-			if (($content = $this->bo->read( $info_id || $action != 'sp' ? $info_id : $action_id )) === false)
1902
+			if (($content = $this->bo->read($info_id || $action != 'sp' ? $info_id : $action_id)) === false)
1907 1903
 			{
1908 1904
 				Framework::window_close(lang('Permission denied!'));
1909 1905
 			}
1910
-			if (!(strpos($content['info_addr'],',')===false) && strpos($content['info_addr'],', ')===false) $content['info_addr'] = str_replace(',',', ',$content['info_addr']);
1911
-			foreach(array('info_subject', 'info_des') as $key)
1906
+			if (!(strpos($content['info_addr'], ',') === false) && strpos($content['info_addr'], ', ') === false) $content['info_addr'] = str_replace(',', ', ', $content['info_addr']);
1907
+			foreach (array('info_subject', 'info_des') as $key)
1912 1908
 			{
1913
-				if(!isset($content[$key]) || strlen($content[$key]) < 75)
1909
+				if (!isset($content[$key]) || strlen($content[$key]) < 75)
1914 1910
 				{
1915 1911
 					continue;
1916 1912
 				}
@@ -1918,66 +1914,66 @@  discard block
 block discarded – undo
1918 1914
 				$clarray = array();
1919 1915
 				foreach ($contlines as &$line)
1920 1916
 				{
1921
-					if(strlen($line) < 75)
1917
+					if (strlen($line) < 75)
1922 1918
 					{
1923 1919
 						$clarray[] = $line;
1924 1920
 						continue;
1925 1921
 					}
1926 1922
 					$cont = explode(' ', $line);
1927 1923
 					$ckarray = array();
1928
-					foreach($cont as &$word)
1924
+					foreach ($cont as &$word)
1929 1925
 					{
1930 1926
 						// set blank behind all , and . if words are too long, apply wordwrap afterwards to make sure we get
1931
-						if (strlen($word)>75)
1927
+						if (strlen($word) > 75)
1932 1928
 						{
1933 1929
 							$buff = Api\Html::activate_links($word);
1934 1930
 							if (strlen($buff) == strlen($word)) // no links -> try to break overlong words
1935 1931
 							{
1936
-								if (!(strpos($word,',')===false) && strpos($word,', ')===false) $word = str_replace(',',', ',$word);
1937
-								if (!(strpos($word,'.')===false) && strpos($word,'. ')===false) $word = str_replace('.','. ',$word);
1932
+								if (!(strpos($word, ',') === false) && strpos($word, ', ') === false) $word = str_replace(',', ', ', $word);
1933
+								if (!(strpos($word, '.') === false) && strpos($word, '. ') === false) $word = str_replace('.', '. ', $word);
1938 1934
 								$word = wordwrap($word, 75, ' ', true);
1939 1935
 							}
1940 1936
 						}
1941
-						$ckarray[] =$word;
1937
+						$ckarray[] = $word;
1942 1938
 					}
1943
-					$line = join(' ',$ckarray);
1939
+					$line = join(' ', $ckarray);
1944 1940
 					unset($ckarray);
1945 1941
 					$clarray[] = $line;
1946 1942
 				}
1947
-				$content[$key] = join("\n",$clarray);
1943
+				$content[$key] = join("\n", $clarray);
1948 1944
 				unset($clarray);
1949 1945
 			}
1950 1946
 			if (is_numeric($_REQUEST['cat_id']))
1951 1947
 			{
1952
-				$content['info_cat'] = (int) $_REQUEST['cat_id'];
1948
+				$content['info_cat'] = (int)$_REQUEST['cat_id'];
1953 1949
 			}
1954 1950
 			if (!$content)
1955 1951
 			{
1956 1952
 				$content['info_cat'] = $this->prefs['cat_add_default'];
1957 1953
 			}
1958
-			if ($_GET['msg']) $content['msg'] = strip_tags($_GET['msg']);	// dont allow HTML!
1954
+			if ($_GET['msg']) $content['msg'] = strip_tags($_GET['msg']); // dont allow HTML!
1959 1955
 
1960
-			switch($this->prefs['set_start'])
1956
+			switch ($this->prefs['set_start'])
1961 1957
 			{
1962
-				case 'date': default: $set_startdate = mktime(0,0,0,date('m',$this->bo->user_time_now),date('d',$this->bo->user_time_now),date('Y',$this->bo->user_time_now)); break;
1958
+				case 'date': default: $set_startdate = mktime(0, 0, 0, date('m', $this->bo->user_time_now), date('d', $this->bo->user_time_now), date('Y', $this->bo->user_time_now)); break;
1963 1959
 				case 'datetime':      $set_startdate = $this->bo->user_time_now; break;
1964 1960
 				case 'empty':         $set_startdate = 0; break;
1965 1961
 			}
1966 1962
 			if ((int)$content['info_link_id'] > 0 && !Link::get_link($content['info_link_id']))
1967 1963
 			{
1968
-				$content['info_link_id'] = 0;	// link has been deleted
1964
+				$content['info_link_id'] = 0; // link has been deleted
1969 1965
 				if (!$content['info_custom_link']) $content['info_from'] = '';
1970 1966
 			}
1971 1967
 			if (!$info_id && $action_id && $action == 'sp')    // new SubProject
1972 1968
 			{
1973
-				if (!$this->bo->check_access($action_id,Acl::ADD))
1969
+				if (!$this->bo->check_access($action_id, Acl::ADD))
1974 1970
 				{
1975
-					return $referer ? $this->tmpl->location($referer) : $this->index(0,$action,$action_id);
1971
+					return $referer ? $this->tmpl->location($referer) : $this->index(0, $action, $action_id);
1976 1972
 				}
1977 1973
 			}
1978 1974
 			else
1979 1975
 			{
1980
-				$undelete = $this->bo->check_access($info_id,infolog_bo::ACL_UNDELETE);
1976
+				$undelete = $this->bo->check_access($info_id, infolog_bo::ACL_UNDELETE);
1981 1977
 			}
1982 1978
 			$content['links'] = $content['link_to'] = array(
1983 1979
 				'to_id' => $info_id,
@@ -1985,12 +1981,12 @@  discard block
 block discarded – undo
1985 1981
 			);
1986 1982
 		}
1987 1983
 		// new call via GET or some actions handled here, as they can happen both ways ($_GET[action] or button/action in GUI)
1988
-		if (!$submit || in_array($action,array('sp','copy','schedule','ical','to_tracker')))
1984
+		if (!$submit || in_array($action, array('sp', 'copy', 'schedule', 'ical', 'to_tracker')))
1989 1985
 		{
1990 1986
 			switch ($action)
1991 1987
 			{
1992 1988
 				case 'schedule':
1993
-					Egw::redirect_link('/index.php',array(
1989
+					Egw::redirect_link('/index.php', array(
1994 1990
 						'menuaction' => 'calendar.calendar_uiforms.edit',
1995 1991
 						'link_app' => 'infolog',
1996 1992
 						'link_id' => $info_id,
@@ -1998,7 +1994,7 @@  discard block
 block discarded – undo
1998 1994
 					break;
1999 1995
 				case 'ical':
2000 1996
 					$boical = new infolog_ical();
2001
-					$result = $boical->exportVTODO($content,'2.0','PUBLISH',false);
1997
+					$result = $boical->exportVTODO($content, '2.0', 'PUBLISH', false);
2002 1998
 					Api\Header\Content::type('todo.ics', 'text/calendar');
2003 1999
 					echo $result;
2004 2000
 					exit();
@@ -2009,23 +2005,23 @@  discard block
 block discarded – undo
2009 2005
 					if ($action == 'sp')	// for sub-entries use type or category, like for new entries
2010 2006
 					{
2011 2007
 						if ($type) $content['info_type'] = $type;
2012
-						if (is_numeric($_REQUEST['cat_id'])) $content['info_cat'] = (int) $_REQUEST['cat_id'];
2008
+						if (is_numeric($_REQUEST['cat_id'])) $content['info_cat'] = (int)$_REQUEST['cat_id'];
2013 2009
 					}
2014
-					unset($action);	// it get stored in $content and will cause an other copy after [apply]
2010
+					unset($action); // it get stored in $content and will cause an other copy after [apply]
2015 2011
 					break;
2016 2012
 				case 'to_tracker':
2017
-					Egw::redirect_link('/index.php',array(
2013
+					Egw::redirect_link('/index.php', array(
2018 2014
 						'menuaction' => 'tracker.tracker_ui.edit',
2019 2015
 						Link::get_registry('tracker', 'add_app').'[]' => 'infolog',
2020
-						Link::get_registry('tracker','add_id').'[]' => $info_id,
2016
+						Link::get_registry('tracker', 'add_id').'[]' => $info_id,
2021 2017
 					));
2022 2018
 					break;
2023 2019
 				case 'projectmanager':
2024 2020
 					$pm_links = array($action_id);
2025 2021
 				default:	// to allow other apps to participate
2026 2022
 					$content['info_subject'] = Link::title($action, $id);
2027
-					$action_ids = explode(',',$action_id);
2028
-					if(count($action_ids) == 1)
2023
+					$action_ids = explode(',', $action_id);
2024
+					if (count($action_ids) == 1)
2029 2025
 					{
2030 2026
 						$content['info_contact'] = $action.':'.$action_id;
2031 2027
 					}
@@ -2034,11 +2030,11 @@  discard block
 block discarded – undo
2034 2030
 						Link::link('infolog', $content['link_to']['to_id'], $action, $id);
2035 2031
 
2036 2032
 						// calling "infolog_set" hook for first, in case app wants to set some more values
2037
-						if (!$n && ($set = Api\Hooks::single(array('location'=>'infolog_set','id'=>$action_id),$action)))
2033
+						if (!$n && ($set = Api\Hooks::single(array('location'=>'infolog_set', 'id'=>$action_id), $action)))
2038 2034
 						{
2039
-							foreach((array)$set['link_app'] as $i => $l_app)
2035
+							foreach ((array)$set['link_app'] as $i => $l_app)
2040 2036
 							{
2041
-								if (($l_id=$set['link_id'][$i])) Link::link('infolog',$content['link_to']['to_id'],$l_app,$l_id);
2037
+								if (($l_id = $set['link_id'][$i])) Link::link('infolog', $content['link_to']['to_id'], $l_app, $l_id);
2042 2038
 							}
2043 2039
 							unset($set['link_app']);
2044 2040
 							unset($set['link_id']);
@@ -2052,12 +2048,12 @@  discard block
 block discarded – undo
2052 2048
 					{
2053 2049
 						if (!isset($pm_links))
2054 2050
 						{
2055
-							$pm_links = Link::get_links('infolog',$info_id,'projectmanager');
2051
+							$pm_links = Link::get_links('infolog', $info_id, 'projectmanager');
2056 2052
 						}
2057
-						break;	// normal edit
2053
+						break; // normal edit
2058 2054
 					}
2059 2055
 				case 'new':		// new entry, set some defaults, if not set by infolog_set hook
2060
-					if (empty($content['info_startdate'])) $content['info_startdate'] = (int) $_GET['startdate'] ? (int) $_GET['startdate'] : $set_startdate;
2056
+					if (empty($content['info_startdate'])) $content['info_startdate'] = (int)$_GET['startdate'] ? (int)$_GET['startdate'] : $set_startdate;
2061 2057
 					if (empty($content['info_priority'])) $content['info_priority'] = 1; // normal
2062 2058
 					$content['info_owner'] = $this->user;
2063 2059
 					if ($type != '' && empty($content['info_type']))
@@ -2082,9 +2078,9 @@  discard block
 block discarded – undo
2082 2078
 		if ($this->bo->group_owners)
2083 2079
 		{
2084 2080
 			// remove types owned by groups the user has no edit grant (current type is made readonly)
2085
-			foreach($this->bo->group_owners as $type => $group)
2081
+			foreach ($this->bo->group_owners as $type => $group)
2086 2082
 			{
2087
-				if (!($this->bo->grants[$group] & Acl::EDIT))
2083
+				if (!($this->bo->grants[$group]&Acl::EDIT))
2088 2084
 				{
2089 2085
 					if ($type == $content['info_type'])
2090 2086
 					{
@@ -2102,7 +2098,7 @@  discard block
 block discarded – undo
2102 2098
 			{
2103 2099
 				$content['info_owner'] = $this->bo->group_owners[$content['info_type']];
2104 2100
 				// Dont allow to change the type, if user has no delete rights from the group-owner
2105
-				if ($info_id && !($this->bo->grants[$content['info_owner']] & Acl::DELETE))
2101
+				if ($info_id && !($this->bo->grants[$content['info_owner']]&Acl::DELETE))
2106 2102
 				{
2107 2103
 					//echo "<p>setting type to r/o as user has no delete rights from group #$group</p>\n";
2108 2104
 					$readonlys['info_type'] = true;
@@ -2110,7 +2106,7 @@  discard block
 block discarded – undo
2110 2106
 				// disable info_access for group-owners
2111 2107
 				$readonlys['info_access'] = true;
2112 2108
 			}
2113
-			elseif($GLOBALS['egw']->accounts->get_type($content['info_owner']) == 'g')
2109
+			elseif ($GLOBALS['egw']->accounts->get_type($content['info_owner']) == 'g')
2114 2110
 			{
2115 2111
 				$content['info_owner'] = $this->user;
2116 2112
 			}
@@ -2122,18 +2118,18 @@  discard block
 block discarded – undo
2122 2118
 		unset($preserv['links']); unset($preserv['link_to']);
2123 2119
 
2124 2120
 		// for no edit rights or implizit edit of responsible user make all fields readonly, but status and percent
2125
-		if ($info_id && !$this->bo->check_access($info_id,Acl::EDIT) && !$undelete)
2121
+		if ($info_id && !$this->bo->check_access($info_id, Acl::EDIT) && !$undelete)
2126 2122
 		{
2127
-			$readonlys['__ALL__'] = true;	// make all fields not explicitly set readonly
2123
+			$readonlys['__ALL__'] = true; // make all fields not explicitly set readonly
2128 2124
 			if ($this->bo->is_responsible($content))
2129 2125
 			{
2130
-				foreach($this->bo->responsible_edit as $name)
2126
+				foreach ($this->bo->responsible_edit as $name)
2131 2127
 				{
2132 2128
 					$readonlys[$name] = false;
2133 2129
 				}
2134 2130
 				$readonlys['button[edit]'] = $readonlys['button[save]'] = $readonlys['button[apply]'] = $readonlys['no_notifications'] = false;
2135 2131
 			}
2136
-			$readonlys['action'] = $readonlys['button[cancel]'] = false;	// always allowed
2132
+			$readonlys['action'] = $readonlys['button[cancel]'] = false; // always allowed
2137 2133
 		}
2138 2134
 		elseif (!$info_id)
2139 2135
 		{
@@ -2146,16 +2142,16 @@  discard block
 block discarded – undo
2146 2142
 			$this->tmpl->setElementAttribute('button[save]', 'label', 'Un-Delete');
2147 2143
 		}
2148 2144
 
2149
-		if (!($readonlys['button[delete]'] = !$info_id || !$this->bo->check_access($info_id,Acl::DELETE)))
2145
+		if (!($readonlys['button[delete]'] = !$info_id || !$this->bo->check_access($info_id, Acl::DELETE)))
2150 2146
 		{
2151
-			$content['info_anz_subs'] = $this->bo->anzSubs($info_id);	// to determine js confirmation of delete or not
2147
+			$content['info_anz_subs'] = $this->bo->anzSubs($info_id); // to determine js confirmation of delete or not
2152 2148
 		}
2153 2149
 		$GLOBALS['egw_info']['flags']['app_header'] = lang($this->messages[$info_id ? 'edit' : ($action == 'sp' ? 'add_sub' : 'add')]);
2154 2150
 
2155 2151
 		// use a typ-specific template (infolog.edit.xyz), if one exists, otherwise fall back to the generic one
2156 2152
 		if (!$this->tmpl->read('infolog.edit.'.$content['info_type']))
2157 2153
 		{
2158
-			$this->tmpl->read($print ? 'infolog.edit.print':'infolog.edit');
2154
+			$this->tmpl->read($print ? 'infolog.edit.print' : 'infolog.edit');
2159 2155
 		}
2160 2156
 		if ($this->bo->has_customfields($content['info_type']))
2161 2157
 		{
@@ -2167,14 +2163,14 @@  discard block
 block discarded – undo
2167 2163
 		}
2168 2164
 		if (!isset($GLOBALS['egw_info']['user']['apps']['projectmanager']))
2169 2165
 		{
2170
-			$readonlys['tabs']['project'] = true;	// disable the project tab
2166
+			$readonlys['tabs']['project'] = true; // disable the project tab
2171 2167
 		}
2172 2168
 
2173 2169
 		$content['duration_format'] = $this->duration_format;
2174 2170
 		$content['hours_per_workday'] = $this->hours_per_workday;
2175 2171
 		if ($this->prefs['show_id']) $content['info_number'] = $info_id;
2176 2172
 
2177
-		$content['info_anz_subs'] = (int)$content['info_anz_subs'];	// gives javascript error if empty!
2173
+		$content['info_anz_subs'] = (int)$content['info_anz_subs']; // gives javascript error if empty!
2178 2174
 
2179 2175
 		$old_pm_id = is_array($pm_links) ? array_shift($pm_links) : $content['old_pm_id'];
2180 2176
 		if (!isset($content['pm_id']) && $old_pm_id) $content['pm_id'] = $old_pm_id;
@@ -2192,7 +2188,7 @@  discard block
 block discarded – undo
2192 2188
 					'Pr' => $this->bo->enums['priority'],
2193 2189
 					'Ow' => 'select-account',
2194 2190
 					//'Ac',	//	info_access: private||public
2195
-					'St' => $this->bo->status[$content['info_type']]+array('deleted' => 'deleted'),
2191
+					'St' => $this->bo->status[$content['info_type']] + array('deleted' => 'deleted'),
2196 2192
 					'Pe' => 'select-percent',
2197 2193
 					'Co' => 'date-time',
2198 2194
 					'st' => 'date-time',
@@ -2209,7 +2205,7 @@  discard block
 block discarded – undo
2209 2205
 			);
2210 2206
 			$history_stati = array();
2211 2207
 			$tracking = new infolog_tracking($this);
2212
-			foreach($tracking->field2history as $field => $history)
2208
+			foreach ($tracking->field2history as $field => $history)
2213 2209
 			{
2214 2210
 				$history_stati[$history] = $tracking->field2label[$field];
2215 2211
 			}
@@ -2250,15 +2246,15 @@  discard block
 block discarded – undo
2250 2246
 		//$content['info_des'] = substr($content['info_des'],0,1793);
2251 2247
 		//echo "<p>infolog_ui.edit(info_id='$info_id',action='$action',action_id='$action_id') readonlys="; print_r($readonlys); echo ", content = "; _debug_array($content);
2252 2248
 		//$content['info_cc'] is expected (by the widget) to be an array of emailaddresses, but is stored as comma separated string
2253
-		if (!empty($content['info_cc'])&&!is_array($content['info_cc']))$content['info_cc'] = explode(',',$content['info_cc']);
2254
-		$this->tmpl->exec('infolog.infolog_ui.edit',$content,$sel_options,$readonlys,$preserv+array(	// preserved values
2249
+		if (!empty($content['info_cc']) && !is_array($content['info_cc']))$content['info_cc'] = explode(',', $content['info_cc']);
2250
+		$this->tmpl->exec('infolog.infolog_ui.edit', $content, $sel_options, $readonlys, $preserv + array(	// preserved values
2255 2251
 			'info_id'       => $info_id,
2256 2252
 			'action'        => $action,
2257 2253
 			'action_id'     => $action_id,
2258 2254
 			'referer'       => $referer,
2259 2255
 			'no_popup'      => $no_popup,
2260 2256
 			'old_pm_id'     => $old_pm_id,
2261
-		),$no_popup ? 0 : 2);
2257
+		), $no_popup ? 0 : 2);
2262 2258
 	}
2263 2259
 
2264 2260
 	/**
@@ -2269,16 +2265,16 @@  discard block
 block discarded – undo
2269 2265
 	 * @param array &$content
2270 2266
 	 * @param boolean $create_sub true: create a sub-entry instead of a copy, default false to create a copy
2271 2267
 	 */
2272
-	private function create_copy(array &$content, $create_sub=false)
2268
+	private function create_copy(array &$content, $create_sub = false)
2273 2269
 	{
2274
-		$info_id = $content['info_id'];	// it will be unset by exclude-fields
2270
+		$info_id = $content['info_id']; // it will be unset by exclude-fields
2275 2271
 
2276 2272
 		// empty fields configured to be excluded (also contains id, uid, ...)
2277 2273
 		$exclude_fields = $create_sub ? $this->bo->sub_excludefields : $this->bo->copy_excludefields;
2278 2274
 		foreach ($exclude_fields as $field)
2279 2275
 		{
2280 2276
 			unset($content[$field]);
2281
-			if ($field == 'info_from') unset($content['info_link_id']);	// both together is called contact in UI
2277
+			if ($field == 'info_from') unset($content['info_link_id']); // both together is called contact in UI
2282 2278
 		}
2283 2279
 		if ($create_sub)
2284 2280
 		{
@@ -2287,9 +2283,9 @@  discard block
 block discarded – undo
2287 2283
 		// no startdate or startdate in the past --> set startdate from pref
2288 2284
 		if (!isset($content['info_startdate']) || $content['info_startdate'] < $this->bo->user_time_now)
2289 2285
 		{
2290
-			switch($this->prefs['set_start'])
2286
+			switch ($this->prefs['set_start'])
2291 2287
 			{
2292
-				case 'date': default: $set_startdate = mktime(0,0,0,date('m',$this->bo->user_time_now),date('d',$this->bo->user_time_now),date('Y',$this->bo->user_time_now)); break;
2288
+				case 'date': default: $set_startdate = mktime(0, 0, 0, date('m', $this->bo->user_time_now), date('d', $this->bo->user_time_now), date('Y', $this->bo->user_time_now)); break;
2293 2289
 				case 'datetime':      $set_startdate = $this->bo->user_time_now; break;
2294 2290
 				case 'empty':         $set_startdate = 0; break;
2295 2291
 			}
@@ -2308,17 +2304,17 @@  discard block
 block discarded – undo
2308 2304
 		// get a consistent status, percent and date-completed
2309 2305
 		if (!isset($content['info_status'])) $content['info_status'] = $this->bo->status['defaults'][$content['info_type']];
2310 2306
 		if (!isset($content['info_percent'])) $content['info_percent'] = $content['info_status'] == 'done' ? '100%' : '0%';
2311
-		$content['info_datecompleted'] =$content['info_status'] == 'done' ? $this->bo->user_time_now : 0;
2307
+		$content['info_datecompleted'] = $content['info_status'] == 'done' ? $this->bo->user_time_now : 0;
2312 2308
 
2313 2309
 		if (!isset($content['info_cat'])) $content['info_cat'] = $this->prefs['cat_add_default'];
2314 2310
 
2315
-		if(!is_array($content['link_to'])) $content['link_to'] = array();
2311
+		if (!is_array($content['link_to'])) $content['link_to'] = array();
2316 2312
 		$content['link_to']['to_app'] = 'infolog';
2317 2313
 		$content['link_to']['to_id'] = 0;
2318 2314
 		// Get links to be copied, if not excluded
2319
-		if (!in_array('link_to',$exclude_fields) || !in_array('attachments',$exclude_fields))
2315
+		if (!in_array('link_to', $exclude_fields) || !in_array('attachments', $exclude_fields))
2320 2316
 		{
2321
-			foreach(Link::get_links($content['link_to']['to_app'], $info_id) as $link)
2317
+			foreach (Link::get_links($content['link_to']['to_app'], $info_id) as $link)
2322 2318
 			{
2323 2319
 				if ($link['app'] != Link::VFS_APPNAME && !in_array('link_to', $exclude_fields))
2324 2320
 				{
@@ -2342,19 +2338,19 @@  discard block
 block discarded – undo
2342 2338
 			if (!isset($content['info_contact']) || empty($content['info_contact']) || $content['info_contact'] === 'copy:')
2343 2339
 			{
2344 2340
 				$linkinfos = Link::get_link($info_link_id);
2345
-				$content['info_contact'] = $linkinfos['link_app1']=='infolog'? $linkinfos['link_app2'].':'.$linkinfos['link_id2']:$linkinfos['link_app1'].':'.$linkinfos['link_id1'];
2346
-				if (stripos($content['info_contact'],'projectmanager')!==false) $content['pm_id'] = $linkinfos['link_app1']=='projectmanager'? $linkinfos['link_id1']:$linkinfos['link_id2'];
2341
+				$content['info_contact'] = $linkinfos['link_app1'] == 'infolog' ? $linkinfos['link_app2'].':'.$linkinfos['link_id2'] : $linkinfos['link_app1'].':'.$linkinfos['link_id1'];
2342
+				if (stripos($content['info_contact'], 'projectmanager') !== false) $content['pm_id'] = $linkinfos['link_app1'] == 'projectmanager' ? $linkinfos['link_id1'] : $linkinfos['link_id2'];
2347 2343
 			}
2348 2344
 			unset($content['info_link_id']);
2349 2345
 		}
2350
-		$content['info_owner'] = !(int)$this->owner || !$this->bo->check_perms(Acl::ADD,0,$this->owner) ? $this->user : $this->owner;
2346
+		$content['info_owner'] = !(int)$this->owner || !$this->bo->check_perms(Acl::ADD, 0, $this->owner) ? $this->user : $this->owner;
2351 2347
 
2352 2348
 		if (!empty($content['info_subject']))
2353 2349
 		{
2354 2350
 			if ($create_sub)
2355 2351
 			{
2356 2352
 				$config = Api\Config::read('infolog');
2357
-				$prefix = lang(empty($config['sub_prefix']) ? 'Re:': $config['sub_prefix']);
2353
+				$prefix = lang(empty($config['sub_prefix']) ? 'Re:' : $config['sub_prefix']);
2358 2354
 			}
2359 2355
 			else
2360 2356
 			{
@@ -2364,11 +2360,11 @@  discard block
 block discarded – undo
2364 2360
 		}
2365 2361
 		if (!$create_sub)
2366 2362
 		{
2367
-			$content['msg'] .= ($content['msg']?"\n":'').lang('Infolog copied - the copy can now be edited');
2363
+			$content['msg'] .= ($content['msg'] ? "\n" : '').lang('Infolog copied - the copy can now be edited');
2368 2364
 		}
2369 2365
 	}
2370 2366
 
2371
-	function icon($cat,$id,$status='')
2367
+	function icon($cat, $id, $status = '')
2372 2368
 	{
2373 2369
 		if (!$status || !($icon = $this->icons[$cat][$id.'_'.$status]))
2374 2370
 		{
@@ -2385,7 +2381,7 @@  discard block
 block discarded – undo
2385 2381
 				$alt = $id;
2386 2382
 			}
2387 2383
 		}
2388
-		return $icon ? Api\Html::image('infolog',$icon,lang($alt),'border=0') : lang($alt);
2384
+		return $icon ? Api\Html::image('infolog', $icon, lang($alt), 'border=0') : lang($alt);
2389 2385
 	}
2390 2386
 
2391 2387
 	/**
@@ -2435,27 +2431,27 @@  discard block
 block discarded – undo
2435 2431
 			'info_cc' => 'CC',
2436 2432
 		);
2437 2433
 		// add customfields to field list
2438
-		foreach(Api\Storage\Customfields::get('infolog') as $name => $data)
2434
+		foreach (Api\Storage\Customfields::get('infolog') as $name => $data)
2439 2435
 		{
2440 2436
 			$excludefields['#'.$name] = $data['label'];
2441 2437
 		}
2442 2438
 		$sub_excludefields = $excludefields;
2443
-		unset($sub_excludefields['info_id_parent']);	// always set to parent!
2439
+		unset($sub_excludefields['info_id_parent']); // always set to parent!
2444 2440
 
2445 2441
 		$config = Api\Config::read('infolog');
2446 2442
 
2447
-		if($content)
2443
+		if ($content)
2448 2444
 		{
2449 2445
 			// Save
2450 2446
 			$button = key($content['button']);
2451
-			if($button == 'save' || $button == 'apply')
2447
+			if ($button == 'save' || $button == 'apply')
2452 2448
 			{
2453
-				$this->bo->responsible_edit = array('info_status','info_percent','info_datecompleted');
2449
+				$this->bo->responsible_edit = array('info_status', 'info_percent', 'info_datecompleted');
2454 2450
 
2455 2451
 				if ($content['responsible_edit'])
2456 2452
 				{
2457
-					$extra = array_intersect($content['responsible_edit'],array_keys($fields));
2458
-					$this->bo->responsible_edit = array_unique(array_merge($this->bo->responsible_edit,$extra));
2453
+					$extra = array_intersect($content['responsible_edit'], array_keys($fields));
2454
+					$this->bo->responsible_edit = array_unique(array_merge($this->bo->responsible_edit, $extra));
2459 2455
 				}
2460 2456
 				Api\Config::save_value('copy_excludefields', $content['copy_excludefields'] ? $content['copy_excludefields'] : null, 'infolog');
2461 2457
 				Api\Config::save_value('sub_excludefields', $content['sub_excludefields'] ? $content['sub_excludefields'] : array('*NONE*'), 'infolog');
@@ -2466,12 +2462,12 @@  discard block
 block discarded – undo
2466 2462
 				Api\Config::save_value('sub_prefix', $content['sub_prefix'], 'infolog');
2467 2463
 
2468 2464
 				// Notifications
2469
-				$notifications =& $config[infolog_tracking::CUSTOM_NOTIFICATION];
2465
+				$notifications = & $config[infolog_tracking::CUSTOM_NOTIFICATION];
2470 2466
 				$notifications[$content['notification_type']] = $content['notification'];
2471
-				Api\Config::save_value(infolog_tracking::CUSTOM_NOTIFICATION, $notifications,'infolog');
2467
+				Api\Config::save_value(infolog_tracking::CUSTOM_NOTIFICATION, $notifications, 'infolog');
2472 2468
 			}
2473 2469
 
2474
-			if($button == 'save' || $button == 'cancel')
2470
+			if ($button == 'save' || $button == 'cancel')
2475 2471
 			{
2476 2472
 				Egw::redirect_link('/index.php', array(
2477 2473
 					'menuaction' => 'admin.admin_ui.index',
@@ -2494,7 +2490,7 @@  discard block
 block discarded – undo
2494 2490
 		$GLOBALS['egw_info']['flags']['app_header'] = lang('InfoLog').' - '.lang('Site configuration');
2495 2491
 
2496 2492
 		// Load selected custom notification
2497
-		if(!$content['notification_type'])
2493
+		if (!$content['notification_type'])
2498 2494
 		{
2499 2495
 			$content['notification_type'] = '~global~';
2500 2496
 		}
@@ -2518,7 +2514,7 @@  discard block
 block discarded – undo
2518 2514
 		);
2519 2515
 		$preserve['notification_old_type'] = $content['notification_type'];
2520 2516
 		$this->tmpl->read('infolog.config');
2521
-		$this->tmpl->exec('infolog.infolog_ui.admin',$content,$sel_options,array(),$preserve);
2517
+		$this->tmpl->exec('infolog.infolog_ui.admin', $content, $sel_options, array(), $preserve);
2522 2518
 	}
2523 2519
 
2524 2520
 	/**
@@ -2527,13 +2523,13 @@  discard block
 block discarded – undo
2527 2523
 	 * @param array $mailContent = null content of mail
2528 2524
 	 * @return  array
2529 2525
 	 */
2530
-	function mail_import(array $mailContent=null)
2526
+	function mail_import(array $mailContent = null)
2531 2527
 	{
2532 2528
 		// It would get called from compose as a popup with egw_data
2533 2529
 		if (!is_array($mailContent) && ($_GET['egw_data']))
2534 2530
 		{
2535 2531
 			// get the mail raw data
2536
-			Link::get_data ($_GET['egw_data']);
2532
+			Link::get_data($_GET['egw_data']);
2537 2533
 			return false;
2538 2534
 		}
2539 2535
 
@@ -2564,7 +2560,7 @@  discard block
 block discarded – undo
2564 2560
 	function hook_view($args)
2565 2561
 	{
2566 2562
 		// Load JS for infolog actions
2567
-		Framework::includeJS('.','app','infolog');
2563
+		Framework::includeJS('.', 'app', 'infolog');
2568 2564
 
2569 2565
 		switch ($args['location'])
2570 2566
 		{
@@ -2592,7 +2588,7 @@  discard block
 block discarded – undo
2592 2588
 		{
2593 2589
 			return False;
2594 2590
 		}
2595
-		$this->called_by = $app;	// for read/save_sessiondata, to have different sessions for the hooks
2591
+		$this->called_by = $app; // for read/save_sessiondata, to have different sessions for the hooks
2596 2592
 
2597 2593
 		// Set to calling app, so actions wind up in the correct place client side
2598 2594
 		$GLOBALS['egw_info']['flags']['currentapp'] = $app;
@@ -2600,11 +2596,11 @@  discard block
 block discarded – undo
2600 2596
 		Api\Translation::add_app('infolog');
2601 2597
 
2602 2598
 		// Still want infolog Api\Categories though
2603
-		$GLOBALS['egw']->categories = new Api\Categories('','infolog');
2604
-		$this->index(null,$app,$args[$view_id],array(
2599
+		$GLOBALS['egw']->categories = new Api\Categories('', 'infolog');
2600
+		$this->index(null, $app, $args[$view_id], array(
2605 2601
 			'menuaction' => $view,
2606 2602
 			isset($view_id2) ? $view_id2 : $view_id => $args[$view_id]
2607
-		),True);
2603
+		), True);
2608 2604
 	}
2609 2605
 
2610 2606
 	/**
@@ -2613,26 +2609,26 @@  discard block
 block discarded – undo
2613 2609
 	 * @param string $type infolog type to include only the matching custom fields if set
2614 2610
 	 * @return array
2615 2611
 	 */
2616
-	function csv_export_fields($type=null)
2612
+	function csv_export_fields($type = null)
2617 2613
 	{
2618 2614
 		$fields = array(
2619 2615
 			'info_type'          => lang('Type'),
2620 2616
 			'info_from'          => lang('Contact'),
2621 2617
 			'info_addr'          => lang('Phone/Email'),
2622 2618
 //			'info_link_id'       => lang('primary link'),
2623
-			'info_cat'           => array('label' => lang('Category'),'type' => 'select-cat'),
2619
+			'info_cat'           => array('label' => lang('Category'), 'type' => 'select-cat'),
2624 2620
 			'info_priority'      => lang('Priority'),
2625
-			'info_owner'         => array('label' => lang('Owner'),'type' => 'select-account'),
2621
+			'info_owner'         => array('label' => lang('Owner'), 'type' => 'select-account'),
2626 2622
 			'info_access'        => lang('Access'),
2627 2623
 			'info_status'        => lang('Status'),
2628 2624
 			'info_percent'       => lang('Completed'),
2629 2625
 			'info_datecompleted' => lang('Date completed'),
2630 2626
 			'info_datemodified'  => lang('Last modified'),
2631
-			'info_modifier'      => array('label' => lang('Modifier'),'type' => 'select-account'),
2627
+			'info_modifier'      => array('label' => lang('Modifier'), 'type' => 'select-account'),
2632 2628
 			'info_location'      => lang('Location'),
2633 2629
 			'info_startdate'     => lang('Startdate'),
2634 2630
 			'info_enddate'       => lang('Enddate'),
2635
-			'info_responsible'   => array('label' => lang('Responsible'),'type' => 'select-account'),
2631
+			'info_responsible'   => array('label' => lang('Responsible'), 'type' => 'select-account'),
2636 2632
 			'info_subject'       => lang('Subject'),
2637 2633
 			'info_des'           => lang('Description'),
2638 2634
 			'info_id'            => lang('Id'),
@@ -2642,13 +2638,13 @@  discard block
 block discarded – undo
2642 2638
 			'pl_id'              => lang('pricelist'),
2643 2639
 			'info_price'         => lang('price'),
2644 2640
 		);
2645
-		foreach($this->bo->timestamps as $name)
2641
+		foreach ($this->bo->timestamps as $name)
2646 2642
 		{
2647
-			$fields[$name] = array('label' => $fields[$name],'type' => 'date-time');
2643
+			$fields[$name] = array('label' => $fields[$name], 'type' => 'date-time');
2648 2644
 		}
2649
-		foreach($this->bo->customfields as $name => $data)
2645
+		foreach ($this->bo->customfields as $name => $data)
2650 2646
 		{
2651
-			if ($data['type2'] && $type && !in_array($type,explode(',',$data['type2']))) continue;
2647
+			if ($data['type2'] && $type && !in_array($type, explode(',', $data['type2']))) continue;
2652 2648
 
2653 2649
 			$fields['#'.$name] = array(
2654 2650
 				'label' => $data['label'],
Please login to merge, or discard this patch.
json.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
  * callback if the session-check fails, redirects to login.php, if no valid basic auth credentials given
19 19
  *
20 20
  * @param array &$anon_account anon account_info with keys 'login', 'passwd' and optional 'passwd_type'
21
- * @return boolean|string true if we allow anon access and anon_account is set, a sessionid or false otherwise
21
+ * @return string|null true if we allow anon access and anon_account is set, a sessionid or false otherwise
22 22
  */
23 23
 function login_redirect(&$anon_account)
24 24
 {
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	{
29 29
 		return $session_id;
30 30
 	}
31
-	Json\Request::isJSONRequest(true);	// because Api\Json\Request::parseRequest() is not (yet) called
31
+	Json\Request::isJSONRequest(true); // because Api\Json\Request::parseRequest() is not (yet) called
32 32
 	$response = Json\Response::get();
33 33
 	$response->redirect($GLOBALS['egw_info']['server']['webserver_url'].'/login.php?cd=10', true);
34 34
 
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 	$message = null;
54 54
 	if (function_exists('_egw_log_exception'))
55 55
 	{
56
-		_egw_log_exception($e,$message);
56
+		_egw_log_exception($e, $message);
57 57
 	}
58 58
 	$response = Json\Response::get();
59 59
 	$message .= ($message ? "\n\n" : '').$e->getMessage();
@@ -73,9 +73,9 @@  discard block
 block discarded – undo
73 73
 
74 74
 if (isset($_GET['menuaction']))
75 75
 {
76
-	if (strpos($_GET['menuaction'],'::') !== false && strpos($_GET['menuaction'],'.') === false)	// static method name app_something::method
76
+	if (strpos($_GET['menuaction'], '::') !== false && strpos($_GET['menuaction'], '.') === false)	// static method name app_something::method
77 77
 	{
78
-		@list($className,$functionName,$handler) = explode('::',$_GET['menuaction']);
78
+		@list($className, $functionName, $handler) = explode('::', $_GET['menuaction']);
79 79
 
80 80
 		if (substr($className, 0, 11) == 'EGroupware\\')
81 81
 		{
@@ -83,12 +83,12 @@  discard block
 block discarded – undo
83 83
 		}
84 84
 		else
85 85
 		{
86
-			list($appName) = explode('_',$className);
86
+			list($appName) = explode('_', $className);
87 87
 		}
88 88
 	}
89 89
 	else
90 90
 	{
91
-		@list($appName, $className, $functionName, $handler) = explode('.',$_GET['menuaction']);
91
+		@list($appName, $className, $functionName, $handler) = explode('.', $_GET['menuaction']);
92 92
 	}
93 93
 	//error_log("json.php: appName=$appName, className=$className, functionName=$functionName, handler=$handler");
94 94
 
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 			'noheader'		=> True,
99 99
 			'disable_Template_class'	=> True,
100 100
 			'autocreate_session_callback' => 'login_redirect',
101
-			'no_exception_handler' => true,	// we already installed our own
101
+			'no_exception_handler' => true, // we already installed our own
102 102
 			// only log ajax requests which represent former GET requests or submits
103 103
 			// cuts down updates to egw_access_log table
104 104
 			'no_dla_update' => !preg_match('/(Etemplate::ajax_process_content|\.jdots_framework\.ajax_exec\.template)$/', $_GET['menuaction']),
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 	//Check whether the request data is set
114 114
 	if (isset($GLOBALS['egw_unset_vars']['_POST[json_data]']))
115 115
 	{
116
-		$json->isJSONRequest(true);	// otherwise exception is not send back to client, as we have not yet called parseRequest()
116
+		$json->isJSONRequest(true); // otherwise exception is not send back to client, as we have not yet called parseRequest()
117 117
 		throw new Json\Exception\ScriptTags("JSON Data contains script tags. Aborting...");
118 118
 	}
119 119
 	$json->parseRequest($_GET['menuaction'], $_REQUEST['json_data']);
@@ -121,4 +121,4 @@  discard block
 block discarded – undo
121 121
 	exit();
122 122
 }
123 123
 
124
-throw new Json\Exception($_SERVER['PHP_SELF'] . ' Invalid AJAX JSON Request');
124
+throw new Json\Exception($_SERVER['PHP_SELF'].' Invalid AJAX JSON Request');
Please login to merge, or discard this patch.
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -73,9 +73,12 @@
 block discarded – undo
73 73
 
74 74
 if (isset($_GET['menuaction']))
75 75
 {
76
-	if (strpos($_GET['menuaction'],'::') !== false && strpos($_GET['menuaction'],'.') === false)	// static method name app_something::method
76
+	if (strpos($_GET['menuaction'],'::') !== false && strpos($_GET['menuaction'],'.') === false)
77
+	{
78
+		// static method name app_something::method
77 79
 	{
78 80
 		@list($className,$functionName,$handler) = explode('::',$_GET['menuaction']);
81
+	}
79 82
 
80 83
 		if (substr($className, 0, 11) == 'EGroupware\\')
81 84
 		{
Please login to merge, or discard this patch.
mail/inc/class.mail_acl.inc.php 3 patches
Doc Comments   -2 removed lines patch added patch discarded remove patch
@@ -277,8 +277,6 @@
 block discarded – undo
277 277
 	 * Update ACL rights of a folder or including subfolders for an account(s)
278 278
 	 *
279 279
 	 * @param array $content content including the acl rights
280
-	 * @param Boolean $recursive boolean flag FALSE|TRUE. If it is FALSE, only the folder take in to account, but in case of TRUE
281
-	 *		the mailbox including all its subfolders will be considered.
282 280
 	 * @param string $msg Message
283 281
 	 *
284 282
 	 */
Please login to merge, or discard this patch.
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -33,12 +33,12 @@  discard block
 block discarded – undo
33 33
 	 *
34 34
 	 */
35 35
 	var $aclRightsAbbrvs = array(
36
-		'lrs'		=> array('label'=>'readable','title'=>'Allows a user to read the contents of the mailbox.'),
37
-		'lprs'		=> array('label'=>'post','title'=>'Allows a user to read the mailbox and post to it through the delivery system by sending mail to the submission address of the mailbox.'),
38
-		'ilprs'		=> array('label'=>'append','title'=>'Allows a user to read the mailbox and append messages to it, either via IMAP or through the delivery system.'),
39
-		'ilprsw'	=> array('label'=>'write','title'=>'Allows a user to read the maibox, post to it, append messages to it, and delete messages or the mailbox itself. The only right not given is the right to change the ACL of the mailbox.'),
40
-		'aeiklprstwx'=> array('label'=>'all','title'=>'The user has all possible rights on the mailbox. This is usually granted to users only on the mailboxes they own.'),
41
-		'custom'	=> array('label'=>'custom','title'=>'User defined combination of rights for the ACL'),
36
+		'lrs'		=> array('label'=>'readable', 'title'=>'Allows a user to read the contents of the mailbox.'),
37
+		'lprs'		=> array('label'=>'post', 'title'=>'Allows a user to read the mailbox and post to it through the delivery system by sending mail to the submission address of the mailbox.'),
38
+		'ilprs'		=> array('label'=>'append', 'title'=>'Allows a user to read the mailbox and append messages to it, either via IMAP or through the delivery system.'),
39
+		'ilprsw'	=> array('label'=>'write', 'title'=>'Allows a user to read the maibox, post to it, append messages to it, and delete messages or the mailbox itself. The only right not given is the right to change the ACL of the mailbox.'),
40
+		'aeiklprstwx'=> array('label'=>'all', 'title'=>'The user has all possible rights on the mailbox. This is usually granted to users only on the mailboxes they own.'),
41
+		'custom'	=> array('label'=>'custom', 'title'=>'User defined combination of rights for the ACL'),
42 42
 	);
43 43
 
44 44
 	/**
@@ -61,12 +61,12 @@  discard block
 block discarded – undo
61 61
 	 * @param array $msg = ''
62 62
 	 *
63 63
 	 */
64
-	function edit(array $content=null ,$msg='')
64
+	function edit(array $content = null, $msg = '')
65 65
 	{
66 66
 		$tmpl = new Etemplate('mail.acl');
67 67
 		if (!is_array($content))
68 68
 		{
69
-			$acc_id = $_GET['acc_id']?$_GET['acc_id']:$GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'];
69
+			$acc_id = $_GET['acc_id'] ? $_GET['acc_id'] : $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'];
70 70
 			if (isset($_GET['account_id']) && !isset($GLOBALS['egw_info']['user']['apps']['admin']))
71 71
 			{
72 72
 				Framework::window_close(lang('Permission denied'));
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 		$account = Mail\Account::read($acc_id, $account_id);
82 82
 		$this->imap = $account->imapServer(isset($account_id) ? (int)$account_id : false);
83 83
 
84
-		$mailbox = $_GET['mailbox']? base64_decode($_GET['mailbox']): $content['mailbox'][0];
84
+		$mailbox = $_GET['mailbox'] ? base64_decode($_GET['mailbox']) : $content['mailbox'][0];
85 85
 		if (empty($mailbox))
86 86
 		{
87 87
 			$mailbox = $this->imap->isAdminConnection ? $this->imap->getUserMailboxString($this->imap->isAdminConnection) : 'INBOX';
@@ -111,14 +111,14 @@  discard block
 block discarded – undo
111 111
 
112 112
 					foreach ($rights as $right)
113 113
 					{
114
-						$content['grid'][$n]['acl_'. $right] = true;
114
+						$content['grid'][$n]['acl_'.$right] = true;
115 115
 					}
116
-					$virtualD = array('e','t');
117
-					$content['grid'][$n]['acl_c'] = array_diff($virtuals['c'],array_intersect($rights,$virtuals['c']))? false: true; //c=kx more information rfc4314, Obsolote Rights
118
-					$content['grid'][$n]['acl_d'] = array_diff($virtualD,array_intersect($rights,$virtuals['d']))? false: true; //d=et more information rfc4314, Obsolote Rights
116
+					$virtualD = array('e', 't');
117
+					$content['grid'][$n]['acl_c'] = array_diff($virtuals['c'], array_intersect($rights, $virtuals['c'])) ? false : true; //c=kx more information rfc4314, Obsolote Rights
118
+					$content['grid'][$n]['acl_d'] = array_diff($virtualD, array_intersect($rights, $virtuals['d'])) ? false : true; //d=et more information rfc4314, Obsolote Rights
119 119
 
120 120
 					sort($rights);
121
-					$acl_abbrvs = implode('',$rights);
121
+					$acl_abbrvs = implode('', $rights);
122 122
 
123 123
 					if (array_key_exists($acl_abbrvs, $this->aclRightsAbbrvs))
124 124
 					{
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 				case 'apply':
160 160
 					if ($content)
161 161
 					{
162
-						$validation_err = $this->update_acl($content,$msg);
162
+						$validation_err = $this->update_acl($content, $msg);
163 163
 						if ($validation_err)
164 164
 						{
165 165
 							foreach ($validation_err as &$row)
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 					}
194 194
 					else
195 195
 					{
196
-						error_log(__METHOD__.__LINE__. "()" . "The remove_acl suppose to return an array back, something is wrong there");
196
+						error_log(__METHOD__.__LINE__."()"."The remove_acl suppose to return an array back, something is wrong there");
197 197
 					}
198 198
 					Framework::message($msg);
199 199
 			}
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 		$sel_options['acl'] = $this->aclRightsAbbrvs;
203 203
 
204 204
 		//Make the account owner's fields all readonly as owner has all rights and should not be able to change them
205
-		foreach($content['grid'] as $key => $fields)
205
+		foreach ($content['grid'] as $key => $fields)
206 206
 		{
207 207
 			if ($fields['acc_id'] == $this->imap->acc_imap_username ||
208 208
 					$fields['acc_id'][0] == $this->imap->acc_imap_username)
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
 			));
236 236
 		}
237 237
 
238
-		$tmpl->exec('mail.mail_acl.edit', $content, $sel_options, $readonlys, $preserv,2);
238
+		$tmpl->exec('mail.mail_acl.edit', $content, $sel_options, $readonlys, $preserv, 2);
239 239
 	}
240 240
 
241 241
 	/**
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
 		$mailbox = $imap->isAdminConnection ? $imap->getUserMailboxString($imap->isAdminConnection) : 'INBOX';
255 255
 
256 256
 		$folders = array();
257
-		foreach(self::getSubfolders($mailbox, $imap) as $folder)
257
+		foreach (self::getSubfolders($mailbox, $imap) as $folder)
258 258
 		{
259 259
 			if (stripos($folder, $_GET['query']) !== false)
260 260
 			{
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 	 * @param string $msg Message
283 283
 	 *
284 284
 	 */
285
-	function update_acl ($content, &$msg)
285
+	function update_acl($content, &$msg)
286 286
 	{
287 287
 		$validator = array();
288 288
 
@@ -298,14 +298,14 @@  discard block
 block discarded – undo
298 298
 			{
299 299
 				if ($value[$key] == true)
300 300
 				{
301
-					$right = explode("acl_" ,$key);
301
+					$right = explode("acl_", $key);
302 302
 					if ($right[1] === 'c') $right[1] = 'kx'; // c = kx , rfc 4314
303 303
 					if ($right[1] === 'd') $right[1] = 'et'; // d = et , rfc 4314
304
-					$options['rights'] .=  $right[1];
304
+					$options['rights'] .= $right[1];
305 305
 				}
306 306
 			}
307 307
 			$username = $content['grid'][$keys]['acc_id'] == $this->imap->acc_imap_username
308
-				?$content['grid'][$keys]['acc_id']:$content['grid'][$keys]['acc_id'][0];
308
+				? $content['grid'][$keys]['acc_id'] : $content['grid'][$keys]['acc_id'][0];
309 309
 			//error_log(__METHOD__."(".__LINE__.") setACL($content[mailbox], $username, ".array2string($options).", $recursive)");
310 310
 			if (is_numeric($username) && ($u = $this->imap->getMailBoxUserName($username)))
311 311
 			{
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 			if (!empty($username))
315 315
 			{
316 316
 				//error_log(__METHOD__."() setACL($content[mailbox], $username, ".array2string($options).", $recursive)");
317
-				if (($ret=$this->setACL($content['mailbox'], $username, $options, $recursive, $msg)))
317
+				if (($ret = $this->setACL($content['mailbox'], $username, $options, $recursive, $msg)))
318 318
 				{
319 319
 					$msg = lang("The Folder %1 's ACLs saved", $content['mailbox']);
320 320
 
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
 			}
327 327
 			else
328 328
 			{
329
-				if($keys !== count($content['grid']))
329
+				if ($keys !== count($content['grid']))
330 330
 				{
331 331
 					array_push($validator, $keys);
332 332
 					$msg = lang("Error:Could not save the ACL! Because some names are empty!");
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
 	 * Retrive Folder ACL rights
344 344
 	 * @todo rights 'c' and 'd' should be fixed
345 345
 	 */
346
-	function retrive_acl ($mailbox, &$msg)
346
+	function retrive_acl($mailbox, &$msg)
347 347
 	{
348 348
 		if (($acl = $this->getACL($mailbox)))
349 349
 		 {
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
 	 */
369 369
 	function remove_acl($content, &$msg)
370 370
 	{
371
-		$row_num = array_keys($content['grid']['delete'],"pressed");
371
+		$row_num = array_keys($content['grid']['delete'], "pressed");
372 372
 		if ($row_num) $row_num = $row_num[0];
373 373
 		$recursive = $content['grid'][$row_num]['acl_recursive'];
374 374
 		$identifier = $content['grid'][$row_num]['acc_id'][0];
@@ -378,24 +378,24 @@  discard block
 block discarded – undo
378 378
 			$identifier = $u;
379 379
 		}
380 380
 		//error_log(__METHOD__.__LINE__."(".$content['mailbox'].", ".$identifier.", ".$recursive.")");
381
-		if(($res = $this->deleteACL($content['mailbox'], $identifier,$recursive)))
381
+		if (($res = $this->deleteACL($content['mailbox'], $identifier, $recursive)))
382 382
 		{
383 383
 			unset($content['grid'][$row_num]);
384 384
 			unset($content['grid']['delete']);
385 385
 			if ($recursive)
386 386
 			{
387
-				$msg = lang("The %1 's acl, including its subfolders, removed from the %2",$content['mailbox'],$identifier);
387
+				$msg = lang("The %1 's acl, including its subfolders, removed from the %2", $content['mailbox'], $identifier);
388 388
 			}
389 389
 			else
390 390
 			{
391
-				$msg = lang("The %1 's acl removed from the %2",$content['mailbox'],$identifier);
391
+				$msg = lang("The %1 's acl removed from the %2", $content['mailbox'], $identifier);
392 392
 			}
393 393
 
394 394
 			return array_combine(range(1, count($content['grid'])), array_values($content['grid']));
395 395
 		}
396 396
 		else
397 397
 		{
398
-			$msg = lang("An error happend while trying to remove ACL rights from the account %1!",$identifier);
398
+			$msg = lang("An error happend while trying to remove ACL rights from the account %1!", $identifier);
399 399
 			return false;
400 400
 		}
401 401
 	}
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
 	 *
411 411
 	 * @return Boolean FALSE in case of any exceptions and TRUE in case of success
412 412
 	 */
413
-	function deleteACL ($mailbox, $identifier, $recursive)
413
+	function deleteACL($mailbox, $identifier, $recursive)
414 414
 	{
415 415
 		if ($recursive)
416 416
 		{
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
 		{
421 421
 			$folders = (array)$mailbox;
422 422
 		}
423
-		foreach($folders as $sbFolders)
423
+		foreach ($folders as $sbFolders)
424 424
 		{
425 425
 			try
426 426
 			{
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
 			}
429 429
 			catch (Exception $e)
430 430
 			{
431
-				error_log(__METHOD__. "Could not delete ACL rights of folder " . $mailbox . " for account ". $identifier ." because of " .$e->getMessage());
431
+				error_log(__METHOD__."Could not delete ACL rights of folder ".$mailbox." for account ".$identifier." because of ".$e->getMessage());
432 432
 				return false;
433 433
 			}
434 434
 		}
@@ -471,7 +471,7 @@  discard block
 block discarded – undo
471 471
 	 * @return Boolean FALSE in case of any exceptions and TRUE in case of success,
472 472
 	 *
473 473
 	 */
474
-	function setACL($mailbox, $identifier,$options, $recursive, &$msg)
474
+	function setACL($mailbox, $identifier, $options, $recursive, &$msg)
475 475
 	{
476 476
 		if ($recursive)
477 477
 		{
@@ -481,16 +481,16 @@  discard block
 block discarded – undo
481 481
 		{
482 482
 			$folders = (array)$mailbox;
483 483
 		}
484
-		foreach($folders as $sbFolders)
484
+		foreach ($folders as $sbFolders)
485 485
 		{
486 486
 			try
487 487
 			{
488
-				$this->imap->setACL($sbFolders,$identifier,$options);
488
+				$this->imap->setACL($sbFolders, $identifier, $options);
489 489
 			}
490 490
 			catch (Exception $e)
491 491
 			{
492 492
 				$msg = $e->getMessage();
493
-				error_log(__METHOD__. "Could not set ACL rights on folder " . $mailbox . " for account ". $identifier . " because of " .$e->getMessage());
493
+				error_log(__METHOD__."Could not set ACL rights on folder ".$mailbox." for account ".$identifier." because of ".$e->getMessage());
494 494
 				return false;
495 495
 			}
496 496
 		}
@@ -503,14 +503,14 @@  discard block
 block discarded – undo
503 503
 	 * @param String $mailbox folder name that needs to be read
504 504
 	 * @return Boolean FALSE in case of any exceptions and if TRUE in case of success,
505 505
 	 */
506
-	function getACL ($mailbox)
506
+	function getACL($mailbox)
507 507
 	{
508 508
 		try
509 509
 		{
510 510
 			$acl = $this->imap->getACL($mailbox);
511 511
 			return $acl;
512 512
 		} catch (Exception $e) {
513
-			error_log(__METHOD__. "Could not get ACL rights from folder " . $mailbox . " because of " .$e->getMessage());
513
+			error_log(__METHOD__."Could not get ACL rights from folder ".$mailbox." because of ".$e->getMessage());
514 514
 			return false;
515 515
 		}
516 516
 	}
Please login to merge, or discard this patch.
Braces   +32 added lines, -9 removed lines patch added patch discarded remove patch
@@ -95,7 +95,10 @@  discard block
 block discarded – undo
95 95
 			//Todo: Implement autocomplete_url function with admin stuffs consideration
96 96
 		}
97 97
 		// Unset the content if folder is changed, in order to read acl rights for new selected folder
98
-		if (!is_array($content['button']) && is_array($content['mailbox']) && !is_array($content['grid']['delete'])) unset($content);
98
+		if (!is_array($content['button']) && is_array($content['mailbox']) && !is_array($content['grid']['delete']))
99
+		{
100
+			unset($content);
101
+		}
99 102
 
100 103
 		if (!is_array($content))
101 104
 		{
@@ -170,7 +173,9 @@  discard block
 block discarded – undo
170 173
 
171 174
 						//Add new row at the end
172 175
 						if ($content['grid'][count($content['grid'])]['acc_id'])
173
-							array_push($content['grid'], array('acc_id'=>''));
176
+						{
177
+													array_push($content['grid'], array('acc_id'=>''));
178
+						}
174 179
 					}
175 180
 					else
176 181
 					{
@@ -178,7 +183,10 @@  discard block
 block discarded – undo
178 183
 					}
179 184
 					//Send message
180 185
 					Framework::message($msg);
181
-					if ($button == "apply") break;
186
+					if ($button == "apply")
187
+					{
188
+						break;
189
+					}
182 190
 
183 191
 				//Fall through
184 192
 				case 'cancel':
@@ -299,8 +307,16 @@  discard block
 block discarded – undo
299 307
 				if ($value[$key] == true)
300 308
 				{
301 309
 					$right = explode("acl_" ,$key);
302
-					if ($right[1] === 'c') $right[1] = 'kx'; // c = kx , rfc 4314
303
-					if ($right[1] === 'd') $right[1] = 'et'; // d = et , rfc 4314
310
+					if ($right[1] === 'c')
311
+					{
312
+						$right[1] = 'kx';
313
+					}
314
+					// c = kx , rfc 4314
315
+					if ($right[1] === 'd')
316
+					{
317
+						$right[1] = 'et';
318
+					}
319
+					// d = et , rfc 4314
304 320
 					$options['rights'] .=  $right[1];
305 321
 				}
306 322
 			}
@@ -346,7 +362,7 @@  discard block
 block discarded – undo
346 362
 	function retrive_acl ($mailbox, &$msg)
347 363
 	{
348 364
 		if (($acl = $this->getACL($mailbox)))
349
-		 {
365
+		{
350 366
 			$msg = lang('ACL rights retrived successfully');
351 367
 			return $acl;
352 368
 		 }
@@ -369,10 +385,16 @@  discard block
 block discarded – undo
369 385
 	function remove_acl($content, &$msg)
370 386
 	{
371 387
 		$row_num = array_keys($content['grid']['delete'],"pressed");
372
-		if ($row_num) $row_num = $row_num[0];
388
+		if ($row_num)
389
+		{
390
+			$row_num = $row_num[0];
391
+		}
373 392
 		$recursive = $content['grid'][$row_num]['acl_recursive'];
374 393
 		$identifier = $content['grid'][$row_num]['acc_id'][0];
375
-		if (is_array($content['mailbox'])) $content['mailbox'] = $content['mailbox'][0];
394
+		if (is_array($content['mailbox']))
395
+		{
396
+			$content['mailbox'] = $content['mailbox'][0];
397
+		}
376 398
 		if (is_numeric($identifier) && ($u = $this->imap->getMailBoxUserName($identifier)))
377 399
 		{
378 400
 			$identifier = $u;
@@ -509,7 +531,8 @@  discard block
 block discarded – undo
509 531
 		{
510 532
 			$acl = $this->imap->getACL($mailbox);
511 533
 			return $acl;
512
-		} catch (Exception $e) {
534
+		}
535
+		catch (Exception $e) {
513 536
 			error_log(__METHOD__. "Could not get ACL rights from folder " . $mailbox . " because of " .$e->getMessage());
514 537
 			return false;
515 538
 		}
Please login to merge, or discard this patch.