Completed
Push — master ( 3281fb...fc273b )
by Hadi
55:41 queued 37:06
created
addressbook/inc/class.addressbook_contactform.inc.php 2 patches
Doc Comments   +11 added lines, -15 removed lines patch added patch discarded remove patch
@@ -30,14 +30,12 @@  discard block
 block discarded – undo
30 30
 	/**
31 31
 	 * Shows the contactform and stores the submitted data
32 32
 	 *
33
-	 * @param array $content=null submitted eTemplate content
34
-	 * @param int $addressbook=null int owner-id of addressbook to save contacts too
35
-	 * @param array $fields=null field-names to show
36
-	 * @param string $msg=null message to show after submitting the form
37
-	 * @param string $email=null comma-separated email addresses
38
-	 * @param string $tpl_name=null custom etemplate to use
39
-	 * @param string $subject=null subject for email
40
-	 * @param string $copytoreceiver=false send a copy of notification to receiver
33
+	 * @param array $content submitted eTemplate content
34
+	 * @param int $addressbook int owner-id of addressbook to save contacts too
35
+	 * @param array $fields field-names to show
36
+	 * @param string $tpl_name custom etemplate to use
37
+	 * @param string $subject subject for email
38
+	 * @param string $copytoreceiver send a copy of notification to receiver
41 39
 	 * @return string html content
42 40
 	 */
43 41
 	function display(array $content=null,$addressbook=null,$fields=null,$msg=null,$email=null,$tpl_name=null,$subject=null,$copytoreceiver=false,$sel_options=array())
@@ -49,13 +47,11 @@  discard block
 block discarded – undo
49 47
 	 * Shows the contactform and stores the submitted data ($content is a var parameter, eg. for extending classes)
50 48
 	 *
51 49
 	 * @param array &$content=null submitted eTemplate content
52
-	 * @param int $addressbook=null int owner-id of addressbook to save contacts too
53
-	 * @param array $fields=null field-names to show
54
-	 * @param string $msg=null message to show after submitting the form
55
-	 * @param string $email=null comma-separated email addresses
56
-	 * @param string $tpl_name=null custom etemplate to use
57
-	 * @param string $subject=null subject for email
58
-	 * @param string $copytoreceiver=false send a copy of notification to receiver
50
+	 * @param int $addressbook int owner-id of addressbook to save contacts too
51
+	 * @param array $fields field-names to show
52
+	 * @param string $tpl_name custom etemplate to use
53
+	 * @param string $subject subject for email
54
+	 * @param string $copytoreceiver send a copy of notification to receiver
59 55
 	 * @return string html content
60 56
 	 */
61 57
 	function display_var(array &$content=null,$addressbook=null,$fields=null,$msg=null,$email=null,$tpl_name=null,$subject=null,$copytoreceiver=false,$sel_options=array())
Please login to merge, or discard this patch.
Braces   +46 added lines, -13 removed lines patch added patch discarded remove patch
@@ -61,28 +61,41 @@  discard block
 block discarded – undo
61 61
 	function display_var(array &$content=null,$addressbook=null,$fields=null,$msg=null,$email=null,$tpl_name=null,$subject=null,$copytoreceiver=false,$sel_options=array())
62 62
 	{
63 63
 		#error_log( "<p>addressbook_contactform::display(".print_r($content,true).",$addressbook,".print_r($fields,true).",$msg,$tpl_name)</p>\n");
64
-		if (empty($tpl_name) && !empty($content['tpl_form_name'])) $tpl_name =$content['tpl_form_name'];
64
+		if (empty($tpl_name) && !empty($content['tpl_form_name']))
65
+		{
66
+			$tpl_name =$content['tpl_form_name'];
67
+		}
65 68
 		$tpl = new etemplate($tpl_name ? $tpl_name : 'addressbook.contactform');
66 69
 		// initializing some fields
67
-		if (!$fields) $fields = array('org_name','n_fn','email','tel_work','url','note','captcha');
70
+		if (!$fields)
71
+		{
72
+			$fields = array('org_name','n_fn','email','tel_work','url','note','captcha');
73
+		}
68 74
 		$submitted = false;
69 75
 		// check if submitted
70 76
 		if (is_array($content))
71 77
 		{
72 78
 			if ((isset($content['captcha_result']) && $content['captcha'] != $content['captcha_result']) ||	// no correct captcha OR
73 79
 				(time() - $content['start_time'] < 10 &&				// bot indicator (less then 10 sec to fill out the form and
74
-				!$GLOBALS['egw_info']['etemplate']['java_script']))	// javascript disabled)
80
+				!$GLOBALS['egw_info']['etemplate']['java_script']))
81
+			{
82
+				// javascript disabled)
75 83
 			{
76 84
 				$submitted = "truebutfalse";
85
+			}
77 86
 				$tpl->set_validation_error('captcha',lang('Wrong - try again ...'));
78 87
 			}
79 88
 			elseif ($content['submitit'])
80 89
 			{
81 90
 				$submitted = true;
82 91
 				$contact = new Api\Contacts();
83
-				if ($content['owner'])	// save the contact in the addressbook
92
+				if ($content['owner'])
93
+				{
94
+					// save the contact in the addressbook
84 95
 				{
85
-					$content['private'] = 0;	// in case default_private is set
96
+					$content['private'] = 0;
97
+				}
98
+				// in case default_private is set
86 99
 					if (($id = $contact->save($content)))
87 100
 					{
88 101
 						// check for fileuploads and attach the found files
@@ -139,9 +152,12 @@  discard block
 block discarded – undo
139 152
 			$custom = 1;
140 153
 			foreach($fields as $name)
141 154
 			{
142
-				if ($name[0] == '#')	// custom field
155
+				if ($name[0] == '#')
156
+				{
157
+					// custom field
143 158
 				{
144 159
 					static $contact;
160
+				}
145 161
 					if (is_null($contact))
146 162
 					{
147 163
 						$contact = new Api\Contacts();
@@ -172,12 +188,19 @@  discard block
 block discarded – undo
172 188
 			unset($content['submitit']);
173 189
 			$custom = 1;
174 190
 			// fieldnames are "defined" by the commit attempt, that way, we do not have to remember them
175
-			foreach($content as $name => $value) {
191
+			foreach($content as $name => $value)
192
+			{
176 193
 				$preserv[$name]=$value;
177
-				if ($name[0] == '#')     // custom field
194
+				if ($name[0] == '#')
195
+				{
196
+					// custom field
178 197
 				{
179 198
 					static $contact;
180
-					if (is_null($contact)) $contact = new Api\Contacts();
199
+				}
200
+					if (is_null($contact))
201
+					{
202
+						$contact = new Api\Contacts();
203
+					}
181 204
 					$content['show']['custom'.$custom] = true;
182 205
 					$content['customfield'][$custom] = $name;
183 206
 					$content['customlabel'][$custom] = $contact->customfields[substr($name,1)]['label'];
@@ -200,15 +223,25 @@  discard block
 block discarded – undo
200 223
 		}
201 224
 		$content['addr_format'] = $GLOBALS['egw_info']['user']['preferences']['addressbook']['addr_format'];
202 225
 
203
-		if ($addressbook) $preserv['owner'] = $addressbook;
204
-		if ($msg) $preserv['msg'] = $msg;
226
+		if ($addressbook)
227
+		{
228
+			$preserv['owner'] = $addressbook;
229
+		}
230
+		if ($msg)
231
+		{
232
+			$preserv['msg'] = $msg;
233
+		}
205 234
 
206 235
 		// a simple calculation captcha
207 236
 		$num1 = rand(1,99);
208 237
 		$num2 = rand(1,99);
209
-		if ($num2 > $num1)	// keep the result positive
238
+		if ($num2 > $num1)
239
+		{
240
+			// keep the result positive
210 241
 		{
211
-			$n = $num1; $num1 = $num2; $num2 = $n;
242
+			$n = $num1;
243
+		}
244
+		$num1 = $num2; $num2 = $n;
212 245
 		}
213 246
 		if (in_array('captcha',$fields))
214 247
 		{
Please login to merge, or discard this patch.
addressbook/inc/class.addressbook_groupdav.inc.php 2 patches
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 	 * @param array &$files
107 107
 	 * @param int $user account_id
108 108
 	 * @param string $id =''
109
-	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
109
+	 * @return boolean boolean true on success, false on failure or string with http status (eg. '404 Not Found')
110 110
 	 */
111 111
 	function propfind($path,&$options,&$files,$user,$id='')
112 112
 	{
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 	 *
189 189
 	 * @param string $path
190 190
 	 * @param array& $filter
191
-	 * @param array|boolean $start =false false=return all or array(start,num)
191
+	 * @param integer[] $start =false false=return all or array(start,num)
192 192
 	 * @return array with "files" array with values for keys path and props
193 193
 	 */
194 194
 	function &propfind_callback($path,array &$filter,$start=false,$report_not_found_multiget_ids=true)
@@ -539,7 +539,7 @@  discard block
 block discarded – undo
539 539
 	 * @param array &$options
540 540
 	 * @param int $id
541 541
 	 * @param int $user =null account_id
542
-	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
542
+	 * @return string|boolean boolean true on success, false on failure or string with http status (eg. '404 Not Found')
543 543
 	 */
544 544
 	function get(&$options,$id,$user=null)
545 545
 	{
@@ -566,7 +566,7 @@  discard block
 block discarded – undo
566 566
 	 * @param int $id
567 567
 	 * @param int $user =null account_id of owner, default null
568 568
 	 * @param string $prefix =null user prefix from path (eg. /ralf from /ralf/addressbook)
569
-	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
569
+	 * @return string|boolean boolean true on success, false on failure or string with http status (eg. '404 Not Found')
570 570
 	 */
571 571
 	function put(&$options,$id,$user=null,$prefix=null)
572 572
 	{
@@ -1024,7 +1024,7 @@  discard block
 block discarded – undo
1024 1024
 	 *
1025 1025
 	 * @param int $acl Acl::READ, Acl::EDIT or Acl::DELETE
1026 1026
 	 * @param array|int $contact contact-array or id
1027
-	 * @return boolean null if entry does not exist, false if no access, true if access permitted
1027
+	 * @return null|boolean null if entry does not exist, false if no access, true if access permitted
1028 1028
 	 */
1029 1029
 	function check_access($acl,$contact)
1030 1030
 	{
Please login to merge, or discard this patch.
Braces   +163 added lines, -40 removed lines patch added patch discarded remove patch
@@ -85,7 +85,10 @@  discard block
 block discarded – undo
85 85
 			self::$path_attr = 'carddav_name';
86 86
 			self::$path_extension = '';
87 87
 		}
88
-		if ($this->debug) error_log(__METHOD__."() contact_repository={$this->bo->contact_repository}, account_repository={$this->bo->account_repository}, REQUEST_URI=$_SERVER[REQUEST_URI] --> path_attr=".self::$path_attr.", path_extension=".self::$path_extension);
88
+		if ($this->debug)
89
+		{
90
+			error_log(__METHOD__."() contact_repository={$this->bo->contact_repository}, account_repository={$this->bo->account_repository}, REQUEST_URI=$_SERVER[REQUEST_URI] --> path_attr=".self::$path_attr.", path_extension=".self::$path_extension);
91
+		}
89 92
 
90 93
 		$this->home_set_pref = $GLOBALS['egw_info']['user']['preferences']['groupdav']['addressbook-home-set'];
91 94
 		$this->home_set_pref = $this->home_set_pref ? explode(',',$this->home_set_pref) : array();
@@ -123,7 +126,10 @@  discard block
 block discarded – undo
123 126
 			$filter['owner'] = $user;
124 127
 		}
125 128
 		// should we hide the accounts addressbook
126
-		if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) $filter['account_id'] = null;
129
+		if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'])
130
+		{
131
+			$filter['account_id'] = null;
132
+		}
127 133
 
128 134
 		// process REPORT filters or multiget href's
129 135
 		$nresults = null;
@@ -131,9 +137,16 @@  discard block
 block discarded – undo
131 137
 		{
132 138
 			return false;
133 139
 		}
134
-		if ($id) $path = dirname($path).'/';	// carddav_name get's added anyway in the callback
140
+		if ($id)
141
+		{
142
+			$path = dirname($path).'/';
143
+		}
144
+		// carddav_name get's added anyway in the callback
135 145
 
136
-		if ($this->debug) error_log(__METHOD__."($path,".array2string($options).",,$user,$id) filter=".array2string($filter));
146
+		if ($this->debug)
147
+		{
148
+			error_log(__METHOD__."($path,".array2string($options).",,$user,$id) filter=".array2string($filter));
149
+		}
137 150
 
138 151
 		// check if we have to return the full contact data or just the etag's
139 152
 		if (!($filter['address_data'] = $options['props'] == 'all' &&
@@ -218,16 +231,25 @@  discard block
 block discarded – undo
218 231
 
219 232
 		if (isset($filter[self::$path_attr]))
220 233
 		{
221
-			if (!is_array($filter[self::$path_attr])) $filter[self::$path_attr] = (array)$filter[self::$path_attr];
234
+			if (!is_array($filter[self::$path_attr]))
235
+			{
236
+				$filter[self::$path_attr] = (array)$filter[self::$path_attr];
237
+			}
222 238
 			$requested_multiget_ids =& $filter[self::$path_attr];
223 239
 		}
224 240
 
225 241
 		$files = array();
226 242
 		// we query etag and modified, as LDAP does not have the strong sql etag
227 243
 		$cols = array('id','uid','etag','modified','n_fn');
228
-		if (!in_array(self::$path_attr,$cols)) $cols[] = self::$path_attr;
244
+		if (!in_array(self::$path_attr,$cols))
245
+		{
246
+			$cols[] = self::$path_attr;
247
+		}
229 248
 		// we need tid for sync-collection report
230
-		if (array_key_exists('tid', $filter) && !isset($filter['tid']) && !in_array('tid', $cols)) $cols[] = 'tid';
249
+		if (array_key_exists('tid', $filter) && !isset($filter['tid']) && !in_array('tid', $cols))
250
+		{
251
+			$cols[] = 'tid';
252
+		}
231 253
 		if (($contacts =& $this->bo->search(array(),$cols,$order,'','',False,'AND',$start,$filter)))
232 254
 		{
233 255
 			foreach($contacts as &$contact)
@@ -271,7 +293,10 @@  discard block
 block discarded – undo
271 293
 			{
272 294
 				$accounts_filter = $filter_in;
273 295
 				$accounts_filter['owner'] = '0';
274
-				if ($sync_collection_report) $token_was = $this->sync_collection_token;
296
+				if ($sync_collection_report)
297
+				{
298
+					$token_was = $this->sync_collection_token;
299
+				}
275 300
 				self::$path_attr = 'id';
276 301
 				self::$path_extension = '.vcf';
277 302
 				$files = array_merge($files, $this->propfind_callback($path, $accounts_filter, false, false));
@@ -294,16 +319,22 @@  discard block
 block discarded – undo
294 319
 					list(,$sync_token) = explode('>', $filter[0]);
295 320
 					$where[] = 'list_modified>FROM_UNIXTIME('.(int)$sync_token.')';
296 321
 				}
297
-				if (isset($filter[self::$path_attr]))	// multiget report?
322
+				if (isset($filter[self::$path_attr]))
323
+				{
324
+					// multiget report?
298 325
 				{
299 326
 					$where['list_'.self::$path_attr] = $filter[self::$path_attr];
300 327
 				}
328
+				}
301 329
 				//error_log(__METHOD__."() filter=".array2string($filter).", do_groups=".in_array('D',$this->home_set_pref).", where=".array2string($where));
302
-				if (($lists = $this->bo->read_lists($where,'contact_uid',$where['list_owner'])))	// limit to contacts in same AB!
330
+				if (($lists = $this->bo->read_lists($where,'contact_uid',$where['list_owner'])))
331
+				{
332
+					// limit to contacts in same AB!
303 333
 				{
304 334
 					foreach($lists as $list)
305 335
 					{
306 336
 						$list[self::$path_attr] = $list['list_carddav_name'];
337
+				}
307 338
 						$etag = $list['list_id'].':'.$list['list_etag'];
308 339
 						// for all-in-one addressbook, add selected ABs to etag
309 340
 						if (isset($filter['owner']) && is_array($filter['owner']))
@@ -347,7 +378,10 @@  discard block
 block discarded – undo
347 378
 			}
348 379
 		}
349 380
 
350
-		if ($this->debug) error_log(__METHOD__."($path,".array2string($filter).','.array2string($start).") took ".(microtime(true) - $starttime).' to return '.count($files).' items');
381
+		if ($this->debug)
382
+		{
383
+			error_log(__METHOD__."($path,".array2string($filter).','.array2string($start).") took ".(microtime(true) - $starttime).' to return '.count($files).' items');
384
+		}
351 385
 		return $files;
352 386
 	}
353 387
 
@@ -387,7 +421,11 @@  discard block
 block discarded – undo
387 421
 			$matches = $prop_test = $column = null;
388 422
 			foreach($options['filters'] as $n => $filter)
389 423
 			{
390
-				if (!is_int($n)) continue;	// eg. attributes of filter xml element
424
+				if (!is_int($n))
425
+				{
426
+					continue;
427
+				}
428
+				// eg. attributes of filter xml element
391 429
 
392 430
 				switch((string)$filter['name'])
393 431
 				{
@@ -395,19 +433,28 @@  discard block
 block discarded – undo
395 433
 						$this->caldav->log(__METHOD__."(...) param-filter='{$filter['attrs']['name']}' not (yet) implemented!");
396 434
 						break;
397 435
 					case 'prop-filter':	// can be multiple prop-filter, see example
398
-						if ($matches) $prop_filters[] = implode($prop_test=='allof'?' AND ':' OR ',$matches);
436
+						if ($matches)
437
+						{
438
+							$prop_filters[] = implode($prop_test=='allof'?' AND ':' OR ',$matches);
439
+						}
399 440
 						$matches = array();
400 441
 						$prop_filter = strtoupper($filter['attrs']['name']);
401 442
 						$prop_test = isset($filter['attrs']['test']) ? $filter['attrs']['test'] : 'anyof';
402
-						if ($this->debug > 1) error_log(__METHOD__."(...) prop-filter='$prop_filter', test='$prop_test'");
443
+						if ($this->debug > 1)
444
+						{
445
+							error_log(__METHOD__."(...) prop-filter='$prop_filter', test='$prop_test'");
446
+						}
403 447
 						break;
404 448
 					case 'is-not-defined':
405 449
 						$matches[] = '('.$column."='' OR ".$column.' IS NULL)';
406 450
 						break;
407 451
 					case 'text-match':	// prop-filter can have multiple text-match, see example
408
-						if (!isset($this->filter_prop2cal[$prop_filter]))	// eg. not existing NICKNAME in EGroupware
452
+						if (!isset($this->filter_prop2cal[$prop_filter]))
453
+						{
454
+							// eg. not existing NICKNAME in EGroupware
409 455
 						{
410 456
 							if ($this->debug || $prop_filter != 'NICKNAME') error_log(__METHOD__."(...) text-match: $prop_filter {$filter['attrs']['match-type']} '{$filter['data']}' unknown property '$prop_filter' --> ignored");
457
+						}
411 458
 							$column = false;	// to ignore following data too
412 459
 						}
413 460
 						else
@@ -420,8 +467,14 @@  discard block
 block discarded – undo
420 467
 									break;
421 468
 							}
422 469
 							$column = $this->filter_prop2cal[strtoupper($prop_filter)];
423
-							if (strpos($column, '_') === false) $column = 'contact_'.$column;
424
-							if (!isset($filters['order'])) $filters['order'] = $column;
470
+							if (strpos($column, '_') === false)
471
+							{
472
+								$column = 'contact_'.$column;
473
+							}
474
+							if (!isset($filters['order']))
475
+							{
476
+								$filters['order'] = $column;
477
+							}
425 478
 							$match_type = $filter['attrs']['match-type'];
426 479
 							$negate_condition = isset($filter['attrs']['negate-condition']) && $filter['attrs']['negate-condition'] == 'yes';
427 480
 						}
@@ -429,9 +482,12 @@  discard block
 block discarded – undo
429 482
 					case '':	// data of text-match element
430 483
 						if (isset($filter['data']) && isset($column))
431 484
 						{
432
-							if ($column)	// false for properties not known to EGroupware
485
+							if ($column)
486
+							{
487
+								// false for properties not known to EGroupware
433 488
 							{
434 489
 								$value = str_replace(array('%', '_'), array('\\%', '\\_'), $filter['data']);
490
+							}
435 491
 								switch($match_type)
436 492
 								{
437 493
 									case 'equals':
@@ -450,7 +506,10 @@  discard block
 block discarded – undo
450 506
 								}
451 507
 								$matches[] = ($negate_condition ? 'NOT ' : '').$sql_filter;
452 508
 
453
-								if ($this->debug > 1) error_log(__METHOD__."(...) text-match: $prop_filter $match_type' '{$filter['data']}'");
509
+								if ($this->debug > 1)
510
+								{
511
+									error_log(__METHOD__."(...) text-match: $prop_filter $match_type' '{$filter['data']}'");
512
+								}
454 513
 							}
455 514
 							unset($column);
456 515
 							break;
@@ -461,11 +520,17 @@  discard block
 block discarded – undo
461 520
 						break;
462 521
 				}
463 522
 			}
464
-			if ($matches) $prop_filters[] = implode($prop_test=='allof'?' AND ':' OR ',$matches);
523
+			if ($matches)
524
+			{
525
+				$prop_filters[] = implode($prop_test=='allof'?' AND ':' OR ',$matches);
526
+			}
465 527
 			if ($prop_filters)
466 528
 			{
467 529
 				$filters[] = $filter = '(('.implode($filter_test=='allof'?') AND (':') OR (', $prop_filters).'))';
468
-				if ($this->debug) error_log(__METHOD__."(path=$options[path], ...) sql-filter: $filter");
530
+				if ($this->debug)
531
+				{
532
+					error_log(__METHOD__."(path=$options[path], ...) sql-filter: $filter");
533
+				}
469 534
 			}
470 535
 		}
471 536
 		// parse limit from $options['other']
@@ -522,8 +587,14 @@  discard block
 block discarded – undo
522 587
 					}
523 588
 				}
524 589
 			}
525
-			if ($ids) $filters[self::$path_attr] = $ids;
526
-			if ($this->debug) error_log(__METHOD__."(...) addressbook-multiget: ids=".implode(',',$ids));
590
+			if ($ids)
591
+			{
592
+				$filters[self::$path_attr] = $ids;
593
+			}
594
+			if ($this->debug)
595
+			{
596
+				error_log(__METHOD__."(...) addressbook-multiget: ids=".implode(',',$ids));
597
+			}
527 598
 		}
528 599
 		elseif ($id)
529 600
 		{
@@ -570,12 +641,18 @@  discard block
 block discarded – undo
570 641
 	 */
571 642
 	function put(&$options,$id,$user=null,$prefix=null)
572 643
 	{
573
-		if ($this->debug) error_log(__METHOD__.'('.array2string($options).",$id,$user)");
644
+		if ($this->debug)
645
+		{
646
+			error_log(__METHOD__.'('.array2string($options).",$id,$user)");
647
+		}
574 648
 
575 649
 		$oldContact = $this->_common_get_put_delete('PUT',$options,$id);
576 650
 		if (!is_null($oldContact) && !is_array($oldContact))
577 651
 		{
578
-			if ($this->debug) error_log(__METHOD__."(,'$id', $user, '$prefix') returning ".array2string($oldContact));
652
+			if ($this->debug)
653
+			{
654
+				error_log(__METHOD__."(,'$id', $user, '$prefix') returning ".array2string($oldContact));
655
+			}
579 656
 			return $oldContact;
580 657
 		}
581 658
 
@@ -666,15 +743,24 @@  discard block
 block discarded – undo
666 743
 			// done here again, as _common_get_put_delete knows nothing about default addressbooks...
667 744
 			if (!($this->bo->grants[$contact['owner']] & Acl::ADD))
668 745
 			{
669
-				if ($this->debug) error_log(__METHOD__."(,'$id', $user, '$prefix') returning '403 Forbidden'");
746
+				if ($this->debug)
747
+				{
748
+					error_log(__METHOD__."(,'$id', $user, '$prefix') returning '403 Forbidden'");
749
+				}
670 750
 				return '403 Forbidden';
671 751
 			}
672 752
 		}
673
-		if ($this->http_if_match) $contact['etag'] = self::etag2value($this->http_if_match);
753
+		if ($this->http_if_match)
754
+		{
755
+			$contact['etag'] = self::etag2value($this->http_if_match);
756
+		}
674 757
 
675 758
 		if (!($save_ok = $is_group ? $this->save_group($contact, $oldContact) : $this->bo->save($contact)))
676 759
 		{
677
-			if ($this->debug) error_log(__METHOD__."(,$id) save(".array2string($contact).") failed, Ok=$save_ok");
760
+			if ($this->debug)
761
+			{
762
+				error_log(__METHOD__."(,$id) save(".array2string($contact).") failed, Ok=$save_ok");
763
+			}
678 764
 			if ($save_ok === 0)
679 765
 			{
680 766
 				// honor Prefer: return=representation for 412 too (no need for client to explicitly reload)
@@ -703,7 +789,10 @@  discard block
 block discarded – undo
703 789
 		// send evtl. necessary respose headers: Location, etag, ...
704 790
 		$this->put_response_headers($contact, $options['path'], $retval, self::$path_attr != 'id');
705 791
 
706
-		if ($this->debug > 1) error_log(__METHOD__."(,'$id', $user, '$prefix') returning ".array2string($retval));
792
+		if ($this->debug > 1)
793
+		{
794
+			error_log(__METHOD__."(,'$id', $user, '$prefix') returning ".array2string($retval));
795
+		}
707 796
 		return $retval;
708 797
 	}
709 798
 
@@ -717,7 +806,10 @@  discard block
 block discarded – undo
717 806
 	function save_group(array &$contact, $oldContact=null)
718 807
 	{
719 808
 		$data = array('list_name' => $contact['n_fn']);
720
-		if (!isset($contact['owner'])) $contact['owner'] = $GLOBALS['egw_info']['user']['account_id'];
809
+		if (!isset($contact['owner']))
810
+		{
811
+			$contact['owner'] = $GLOBALS['egw_info']['user']['account_id'];
812
+		}
721 813
 		foreach(array('id','carddav_name','uid','owner') as $name)
722 814
 		{
723 815
 			$data['list_'.$name] = $contact[$name];
@@ -769,13 +861,22 @@  discard block
 block discarded – undo
769 861
 					}
770 862
 				}
771 863
 				//error_log('to_add_ids='.array2string($to_add_ids).', to_delete_ids='.array2string($to_delete_ids));
772
-				if ($to_add_ids) $this->bo->add2list($to_add_ids, $list_id, array());
773
-				if ($to_delete_ids) $this->bo->remove_from_list($to_delete_ids, $list_id);
864
+				if ($to_add_ids)
865
+				{
866
+					$this->bo->add2list($to_add_ids, $list_id, array());
867
+				}
868
+				if ($to_delete_ids)
869
+				{
870
+					$this->bo->remove_from_list($to_delete_ids, $list_id);
871
+				}
774 872
 			}
775 873
 			// reread as update of list-members updates etag and modified
776 874
 	 		$contact = $this->bo->read_list($list_id);
777 875
 		}
778
-		if ($this->debug > 1) error_log(__METHOD__.'('.array2string($contact).', '.array2string($oldContact).') on return contact='.array2string($data).' returning '.array2string($list_id));
876
+		if ($this->debug > 1)
877
+		{
878
+			error_log(__METHOD__.'('.array2string($contact).', '.array2string($oldContact).') on return contact='.array2string($data).' returning '.array2string($list_id));
879
+		}
779 880
  		return $list_id;
780 881
 	}
781 882
 
@@ -789,11 +890,17 @@  discard block
 block discarded – undo
789 890
 	public function getctag($path,$user)
790 891
 	{
791 892
 		static $ctags = array();	// a little per request caching, in case ctag and sync-token is both requested
792
-		if (isset($ctags[$path])) return $ctags[$path];
893
+		if (isset($ctags[$path]))
894
+		{
895
+			return $ctags[$path];
896
+		}
793 897
 
794 898
 		$user_in = $user;
795 899
 		// not showing addressbook of a single user?
796
-		if (is_null($user) || $user === '' || $path == '/addressbook/') $user = null;
900
+		if (is_null($user) || $user === '' || $path == '/addressbook/')
901
+		{
902
+			$user = null;
903
+		}
797 904
 
798 905
 		// If "Sync selected addressbooks into one" is set --> ctag need to take selected AB's into account too
799 906
 		if ($user && $user == $GLOBALS['egw_info']['user']['account_id'] && in_array('O',$this->home_set_pref))
@@ -1006,16 +1113,22 @@  discard block
 block discarded – undo
1006 1113
 				$contact['etag'] .= ':'.implode('-',$limit_in_ab);
1007 1114
 			}
1008 1115
 		}
1009
-		elseif($contact === array())	// not found from read_lists()
1116
+		elseif($contact === array())
1117
+		{
1118
+			// not found from read_lists()
1010 1119
 		{
1011 1120
 			$contact = null;
1012 1121
 		}
1122
+		}
1013 1123
 
1014 1124
 		if ($contact && $contact['tid'] == Api\Contacts::DELETED_TYPE)
1015 1125
 		{
1016 1126
 			$contact = null;	// handle deleted events, as not existing (404 Not Found)
1017 1127
 		}
1018
-		if ($this->debug > 1) error_log(__METHOD__."('$id') returning ".array2string($contact));
1128
+		if ($this->debug > 1)
1129
+		{
1130
+			error_log(__METHOD__."('$id') returning ".array2string($contact));
1131
+		}
1019 1132
 		return $contact;
1020 1133
 	}
1021 1134
 
@@ -1045,7 +1158,10 @@  discard block
 block discarded – undo
1045 1158
 		// remove add and delete grants for accounts (for admins too)
1046 1159
 		// as accounts can not be created as contacts, they eg. need further data
1047 1160
 		// and admins might not recognice they delete an account incl. its data
1048
-		if (isset($grants[0])) $grants[0] &= ~(EGW_ACL_ADD|EGW_ACL_DELETE);
1161
+		if (isset($grants[0]))
1162
+		{
1163
+			$grants[0] &= ~(EGW_ACL_ADD|EGW_ACL_DELETE);
1164
+		}
1049 1165
 
1050 1166
 		return $grants;
1051 1167
 	}
@@ -1061,7 +1177,10 @@  discard block
 block discarded – undo
1061 1177
 		$shared = array();
1062 1178
 
1063 1179
 		// if "Sync all selected addressbook into one" is set --> no (additional) shared addressbooks
1064
-		if (!$ignore_all_in_one && in_array('O',$this->home_set_pref)) return array();
1180
+		if (!$ignore_all_in_one && in_array('O',$this->home_set_pref))
1181
+		{
1182
+			return array();
1183
+		}
1065 1184
 
1066 1185
 		// replace symbolic id's with real nummeric id's
1067 1186
 		foreach(array(
@@ -1128,7 +1247,11 @@  discard block
 block discarded – undo
1128 1247
 			$user = $hook_data['account_id'];
1129 1248
 			$addressbook_bo = new Api\Contacts();
1130 1249
 			$addressbooks += $addressbook_bo->get_addressbooks(Acl::READ, null, $user);
1131
-			if ($user > 0)  unset($addressbooks[$user]);	// allways synced
1250
+			if ($user > 0)
1251
+			{
1252
+				unset($addressbooks[$user]);
1253
+			}
1254
+			// allways synced
1132 1255
 			unset($addressbooks[$user.'p']);// ignore (optional) private addressbook for now
1133 1256
 		}
1134 1257
 
Please login to merge, or discard this patch.
addressbook/inc/class.addressbook_hooks.inc.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
 	 * Register addressbook for group-acl
424 424
 	 *
425 425
 	 * @param array $args hook-params (not used)
426
-	 * @return boolean|string true=standard group acl link, of string with link
426
+	 * @return boolean true=standard group acl link, of string with link
427 427
 	 */
428 428
 	static function group_acl($args)
429 429
 	{
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
 	 * For which groups should no group acl be used: addressbook always
438 438
 	 *
439 439
 	 * @param string|array $data
440
-	 * @return boolean|array true, false or array with group-account_id's
440
+	 * @return boolean true, false or array with group-account_id's
441 441
 	 */
442 442
 	static function not_enum_group_acls($data)
443 443
 	{
Please login to merge, or discard this patch.
Braces   +8 added lines, -2 removed lines patch added patch discarded remove patch
@@ -498,11 +498,14 @@  discard block
 block discarded – undo
498 498
 			}
499 499
 		}
500 500
 		$own_account_acl['link_to'] = 'Links';
501
-		if ($config['account_repository'] != 'ldap')	// no custom-fields in ldap
501
+		if ($config['account_repository'] != 'ldap')
502
+		{
503
+			// no custom-fields in ldap
502 504
 		{
503 505
 			foreach(Api\Storage\Customfields::get('addressbook') as $name => $data)
504 506
 			{
505 507
 				$own_account_acl['#'.$name] = $data['label'];
508
+		}
506 509
 			}
507 510
 		}
508 511
 
@@ -522,11 +525,14 @@  discard block
 block discarded – undo
522 525
 				$copy_fields[$field] = $label;
523 526
 			}
524 527
 		}
525
-		if ($config['contact_repository'] != 'ldap')	// no custom-fields in ldap
528
+		if ($config['contact_repository'] != 'ldap')
529
+		{
530
+			// no custom-fields in ldap
526 531
 		{
527 532
 			foreach(Api\Storage\Customfields::get('addressbook') as $name => $data)
528 533
 			{
529 534
 				$copy_fields['#'.$name] = $data['label'];
535
+		}
530 536
 			}
531 537
 		}
532 538
 		// Remove country codes as an option, it will be added by UI constructor
Please login to merge, or discard this patch.
addressbook/inc/class.addressbook_import_contacts_csv.inc.php 2 patches
Doc Comments   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -44,9 +44,7 @@  discard block
 block discarded – undo
44 44
 
45 45
 	/**
46 46
 	 * imports entries according to given definition object.
47
-	 * @param resource $_stream
48
-	 * @param string $_charset
49
-	 * @param definition $_definition
47
+	 * @param importexport_definition $_definition
50 48
 	 */
51 49
 	public function init(importexport_definition &$_definition ) {
52 50
 
@@ -84,7 +82,7 @@  discard block
 block discarded – undo
84 82
 	 *
85 83
 	 * Updates the count of actions taken
86 84
 	 *
87
-	 * @return boolean success
85
+	 * @return null|boolean success
88 86
 	 */
89 87
 	protected function import_record(importexport_iface_egw_record &$record, &$import_csv)
90 88
 	{
Please login to merge, or discard this patch.
Braces   +126 added lines, -51 removed lines patch added patch discarded remove patch
@@ -15,7 +15,8 @@  discard block
 block discarded – undo
15 15
 /**
16 16
  * class import_csv for addressbook
17 17
  */
18
-class addressbook_import_contacts_csv extends importexport_basic_import_csv  {
18
+class addressbook_import_contacts_csv extends importexport_basic_import_csv
19
+{
19 20
 
20 21
 	/**
21 22
 	 * conditions for actions
@@ -48,7 +49,8 @@  discard block
 block discarded – undo
48 49
 	 * @param string $_charset
49 50
 	 * @param definition $_definition
50 51
 	 */
51
-	public function init(importexport_definition &$_definition ) {
52
+	public function init(importexport_definition &$_definition )
53
+	{
52 54
 
53 55
 		// fetch the addressbook bo
54 56
 		$this->bocontacts = new Api\Contacts();
@@ -90,22 +92,29 @@  discard block
 block discarded – undo
90 92
 	{
91 93
 
92 94
 		// Set owner, unless it's supposed to come from CSV file
93
-		if($this->definition->plugin_options['owner_from_csv'] && $record->owner) {
94
-			if(!is_numeric($record->owner)) {
95
+		if($this->definition->plugin_options['owner_from_csv'] && $record->owner)
96
+		{
97
+			if(!is_numeric($record->owner))
98
+			{
95 99
 				// Automatically handle text owner without explicit translation
96 100
 				$new_owner = importexport_helper_functions::account_name2id($record->owner);
97
-				if($new_owner == '') {
101
+				if($new_owner == '')
102
+				{
98 103
 					$this->errors[$import_csv->get_current_position()] = lang(
99 104
 						'Unable to convert "%1" to account ID.  Using plugin setting (%2) for owner.',
100 105
 						$record->owner,
101 106
 						Api\Accounts::username($this->user)
102 107
 					);
103 108
 					$record->owner = $this->user;
104
-				} else {
109
+				}
110
+				else
111
+				{
105 112
 					$record->owner = $new_owner;
106 113
 				}
107 114
 			}
108
-		} else {
115
+		}
116
+		else
117
+		{
109 118
 			$record->owner = $this->user;
110 119
 		}
111 120
 
@@ -141,26 +150,41 @@  discard block
 block discarded – undo
141 150
 		// Also handle categories in their own field
142 151
 		$record_array = $record->get_record_array();
143 152
 		$more_categories = array();
144
-		foreach($this->definition->plugin_options['field_mapping'] as $field_name) {
153
+		foreach($this->definition->plugin_options['field_mapping'] as $field_name)
154
+		{
145 155
 			if(!array_key_exists($field_name, $record_array) ||
146
-				substr($field_name,0,3) != 'cat' || !$record->$field_name || $field_name == 'cat_id') continue;
156
+				substr($field_name,0,3) != 'cat' || !$record->$field_name || $field_name == 'cat_id')
157
+			{
158
+				continue;
159
+			}
147 160
 			list(, $cat_id) = explode('-', $field_name);
148
-			if(is_numeric($record->$field_name) && $record->$field_name != 1) {
161
+			if(is_numeric($record->$field_name) && $record->$field_name != 1)
162
+			{
149 163
 				// Column has a single category ID
150 164
 				$more_categories[] = $record->$field_name;
151
-			} elseif($record->$field_name == '1' ||
152
-				(!is_numeric($record->$field_name) && strtolower($record->$field_name) == strtolower(lang('Yes')))) {
165
+			}
166
+			elseif($record->$field_name == '1' ||
167
+				(!is_numeric($record->$field_name) && strtolower($record->$field_name) == strtolower(lang('Yes'))))
168
+			{
153 169
 				// Each category got its own column.  '1' is the database value, lang('yes') is the human value
154 170
 				$more_categories[] = $cat_id;
155
-			} else {
171
+			}
172
+			else
173
+			{
156 174
 				// Text categories
157 175
 				$more_categories = array_merge($more_categories, importexport_helper_functions::cat_name2id(is_array($record->$field_name) ? $record->$field_name : explode(',',$record->$field_name), $cat_id));
158 176
 			}
159 177
 		}
160
-		if(count($more_categories) > 0) $record->cat_id = array_merge(is_array($record->cat_id) ? $record->cat_id : explode(',',$record->cat_id), $more_categories);
178
+		if(count($more_categories) > 0)
179
+		{
180
+			$record->cat_id = array_merge(is_array($record->cat_id) ? $record->cat_id : explode(',',$record->cat_id), $more_categories);
181
+		}
161 182
 
162 183
 		// Private set but missing causes hidden entries
163
-		if(array_key_exists('private', $record_array) && (!isset($record_array['private']) || $record_array['private'] == '')) unset($record->private);
184
+		if(array_key_exists('private', $record_array) && (!isset($record_array['private']) || $record_array['private'] == ''))
185
+		{
186
+			unset($record->private);
187
+		}
164 188
 
165 189
 		// Format birthday as backend requires - converter should give timestamp
166 190
 		if($record->bday && is_numeric($record->bday))
@@ -169,17 +193,24 @@  discard block
 block discarded – undo
169 193
 			$record->bday = $time->format('Y-m-d');
170 194
 		}
171 195
 
172
-		if ( $this->definition->plugin_options['conditions'] ) {
173
-			foreach ( $this->definition->plugin_options['conditions'] as $condition ) {
196
+		if ( $this->definition->plugin_options['conditions'] )
197
+		{
198
+			foreach ( $this->definition->plugin_options['conditions'] as $condition )
199
+			{
174 200
 				$contacts = array();
175
-				switch ( $condition['type'] ) {
201
+				switch ( $condition['type'] )
202
+				{
176 203
 					// exists
177 204
 					case 'exists' :
178
-						if($record_array[$condition['string']]) {
205
+						if($record_array[$condition['string']])
206
+						{
179 207
 							$searchcondition = array( $condition['string'] => $record_array[$condition['string']]);
180 208
 							// if we use account_id for the condition, we need to set the owner for filtering, as this
181 209
 							// enables Api\Contacts\Storage to decide what backend is to be used
182
-							if ($condition['string']=='account_id') $searchcondition['owner']=0;
210
+							if ($condition['string']=='account_id')
211
+							{
212
+								$searchcondition['owner']=0;
213
+							}
183 214
 							$contacts = $this->bocontacts->search(
184 215
 								//array( $condition['string'] => $record[$condition['string']],),
185 216
 								'',
@@ -188,19 +219,30 @@  discard block
 block discarded – undo
188 219
 								$searchcondition
189 220
 							);
190 221
 						}
191
-						if ( is_array( $contacts ) && count( array_keys( $contacts ) ) >= 1 ) {
222
+						if ( is_array( $contacts ) && count( array_keys( $contacts ) ) >= 1 )
223
+						{
192 224
 							// apply action to all contacts matching this exists condition
193 225
 							$action = $condition['true'];
194
-							foreach ( (array)$contacts as $contact ) {
226
+							foreach ( (array)$contacts as $contact )
227
+							{
195 228
 								$record->id = $contact['id'];
196
-								if ( $this->definition->plugin_options['update_cats'] == 'add' ) {
197
-									if ( !is_array( $contact['cat_id'] ) ) $contact['cat_id'] = explode( ',', $contact['cat_id'] );
198
-									if ( !is_array( $record_array['cat_id'] ) ) $record->cat_id = explode( ',', $record->cat_id );
229
+								if ( $this->definition->plugin_options['update_cats'] == 'add' )
230
+								{
231
+									if ( !is_array( $contact['cat_id'] ) )
232
+									{
233
+										$contact['cat_id'] = explode( ',', $contact['cat_id'] );
234
+									}
235
+									if ( !is_array( $record_array['cat_id'] ) )
236
+									{
237
+										$record->cat_id = explode( ',', $record->cat_id );
238
+									}
199 239
 									$record->cat_id = implode( ',', array_unique( array_merge( $record->cat_id, $contact['cat_id'] ) ) );
200 240
 								}
201 241
 								$success = $this->action(  $action['action'], $record, $import_csv->get_current_position() );
202 242
 							}
203
-						} else {
243
+						}
244
+						else
245
+						{
204 246
 							$action = $condition['false'];
205 247
 							$success = ($this->action(  $action['action'], $record, $import_csv->get_current_position() ));
206 248
 						}
@@ -227,9 +269,14 @@  discard block
 block discarded – undo
227 269
 						die('condition / action not supported!!!');
228 270
 						break;
229 271
 				}
230
-				if ($action['stop']) break;
272
+				if ($action['stop'])
273
+				{
274
+					break;
275
+				}
231 276
 			}
232
-		} else {
277
+		}
278
+		else
279
+		{
233 280
 			// unconditional insert
234 281
 			$success = $this->action( 'insert', $record, $import_csv->get_current_position() );
235 282
 		}
@@ -243,15 +290,18 @@  discard block
 block discarded – undo
243 290
 	 * @param importexport_iface_egw_record $record contact data for the action
244 291
 	 * @return bool success or not
245 292
 	 */
246
-	protected function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 ) {
293
+	protected function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 )
294
+	{
247 295
 		$_data = $record->get_record_array();
248
-		switch ($_action) {
296
+		switch ($_action)
297
+		{
249 298
 			case 'none' :
250 299
 				return true;
251 300
 			case 'delete':
252 301
 				if($_data['id'])
253 302
 				{
254
-					if ( $this->dry_run ) {
303
+					if ( $this->dry_run )
304
+					{
255 305
 						//print_r($_data);
256 306
 						$this->results[$_action]++;
257 307
 						return true;
@@ -272,14 +322,20 @@  discard block
 block discarded – undo
272 322
 				// Only update if there are changes
273 323
 				$old = $this->bocontacts->read($_data['id']);
274 324
 				// if we get countrycodes as countryname, try to translate them -> the rest should be handled by bo classes.
275
-				foreach(array('adr_one_', 'adr_two_') as $c_prefix) {
325
+				foreach(array('adr_one_', 'adr_two_') as $c_prefix)
326
+				{
276 327
 					if (strlen(trim($_data[$c_prefix.'countryname']))==2)
277
-						$_data[$c_prefix.'countryname'] = $GLOBALS['egw']->country->get_full_name(trim($_data[$c_prefix.'countryname']), true);
328
+					{
329
+											$_data[$c_prefix.'countryname'] = $GLOBALS['egw']->country->get_full_name(trim($_data[$c_prefix.'countryname']), true);
330
+					}
278 331
 				}
279 332
 				// Don't change a user account into a contact
280
-				if($old['owner'] == 0) {
333
+				if($old['owner'] == 0)
334
+				{
281 335
 					unset($_data['owner']);
282
-				} elseif(!$this->definition->plugin_options['change_owner']) {
336
+				}
337
+				elseif(!$this->definition->plugin_options['change_owner'])
338
+				{
283 339
 					// Don't change addressbook of an existing contact
284 340
 					unset($_data['owner']);
285 341
 				}
@@ -287,9 +343,12 @@  discard block
 block discarded – undo
287 343
 				// Merge to deal with fields not in import record
288 344
 				$_data = array_merge($old, $_data);
289 345
 				$changed = $this->tracking->changed_fields($_data, $old);
290
-				if(count($changed) == 0) {
346
+				if(count($changed) == 0)
347
+				{
291 348
 					return true;
292
-				} else {
349
+				}
350
+				else
351
+				{
293 352
 					//error_log(__METHOD__.__LINE__.array2string($changed).' Old:'.$old['adr_one_countryname'].' ('.$old['adr_one_countrycode'].') New:'.$_data['adr_one_countryname'].' ('.$_data['adr_one_countryname'].')');
294 353
 				}
295 354
 
@@ -298,24 +357,32 @@  discard block
 block discarded – undo
298 357
 
299 358
 				// Fall through
300 359
 			case 'insert' :
301
-				if($_action == 'insert') {
360
+				if($_action == 'insert')
361
+				{
302 362
 					// Addressbook backend doesn't like inserting with ID specified, it screws up the owner & etag
303 363
 					unset($_data['id']);
304 364
 				}
305
-				if(!isset($_data['org_name'])) {
365
+				if(!isset($_data['org_name']))
366
+				{
306 367
 					// org_name is a trigger to update n_fileas
307 368
 					$_data['org_name'] = '';
308 369
 				}
309 370
 
310
-				if ( $this->dry_run ) {
371
+				if ( $this->dry_run )
372
+				{
311 373
 					//print_r($_data);
312 374
 					$this->results[$_action]++;
313 375
 					return true;
314
-				} else {
376
+				}
377
+				else
378
+				{
315 379
 					$result = $this->bocontacts->save( $_data, $this->is_admin);
316
-					if(!$result) {
380
+					if(!$result)
381
+					{
317 382
 						$this->errors[$record_num] = $this->bocontacts->error;
318
-					} else {
383
+					}
384
+					else
385
+					{
319 386
 						$this->results[$_action]++;
320 387
 						// This does nothing (yet?) but update the identifier
321 388
 						$record->save($result);
@@ -333,7 +400,8 @@  discard block
 block discarded – undo
333 400
 	 *
334 401
 	 * @return string name
335 402
 	 */
336
-	public static function get_name() {
403
+	public static function get_name()
404
+	{
337 405
 		return lang('Addressbook CSV import');
338 406
 	}
339 407
 
@@ -342,7 +410,8 @@  discard block
 block discarded – undo
342 410
 	 *
343 411
 	 * @return string descriprion
344 412
 	 */
345
-	public static function get_description() {
413
+	public static function get_description()
414
+	{
346 415
 		return lang("Imports contacts into your Addressbook from a CSV File. CSV means 'Comma Seperated Values'. However in the options Tab you can also choose other seperators.");
347 416
 	}
348 417
 
@@ -351,7 +420,8 @@  discard block
 block discarded – undo
351 420
 	 *
352 421
 	 * @return string suffix (comma seperated)
353 422
 	 */
354
-	public static function get_filesuffix() {
423
+	public static function get_filesuffix()
424
+	{
355 425
 		return 'csv';
356 426
 	}
357 427
 
@@ -367,7 +437,8 @@  discard block
 block discarded – undo
367 437
 	 * 		preserv		=> array,
368 438
 	 * )
369 439
 	 */
370
-	public function get_options_etpl() {
440
+	public function get_options_etpl()
441
+	{
371 442
 		// lets do it!
372 443
 	}
373 444
 
@@ -376,7 +447,8 @@  discard block
 block discarded – undo
376 447
 	 *
377 448
 	 * @return string etemplate name
378 449
 	 */
379
-	public function get_selectors_etpl() {
450
+	public function get_selectors_etpl()
451
+	{
380 452
 		// lets do it!
381 453
 	}
382 454
 
@@ -388,7 +460,8 @@  discard block
 block discarded – undo
388 460
         *       record_# => warning message
389 461
         *       )
390 462
         */
391
-        public function get_warnings() {
463
+        public function get_warnings()
464
+        {
392 465
 		return $this->warnings;
393 466
 	}
394 467
 
@@ -400,7 +473,8 @@  discard block
 block discarded – undo
400 473
         *       record_# => error message
401 474
         *       )
402 475
         */
403
-        public function get_errors() {
476
+        public function get_errors()
477
+        {
404 478
 		return $this->errors;
405 479
 	}
406 480
 
@@ -412,7 +486,8 @@  discard block
 block discarded – undo
412 486
         *       action => record count
413 487
         * )
414 488
         */
415
-        public function get_results() {
489
+        public function get_results()
490
+        {
416 491
                 return $this->results;
417 492
         }
418 493
 }
Please login to merge, or discard this patch.
addressbook/inc/class.addressbook_ui.inc.php 2 patches
Doc Comments   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1027,7 +1027,7 @@  discard block
 block discarded – undo
1027 1027
 	 * @param int &$failed number of failed actions (not enought permissions)
1028 1028
 	 * @param string &$action_msg translated verb for the actions, to be used in a message like %1 contacts 'deleted'
1029 1029
 	 * @param string/array $session_name 'index' or 'email', or array with session-data depending if we are in the main list or the popup
1030
-	 * @return boolean true if all actions succeded, false otherwise
1030
+	 * @return null|boolean true if all actions succeded, false otherwise
1031 1031
 	 */
1032 1032
 	function action($action,$checked,$use_all,&$success,&$failed,&$action_msg,$session_name,&$msg, $checkboxes = NULL)
1033 1033
 	{
@@ -1887,9 +1887,7 @@  discard block
 block discarded – undo
1887 1887
 	/**
1888 1888
 	* Edit a contact
1889 1889
 	*
1890
-	* @param array $content=null submitted content
1891
-	* @param int $_GET['contact_id'] contact_id mainly for popup use
1892
-	* @param bool $_GET['makecp'] true if you want to copy the contact given by $_GET['contact_id']
1890
+	* @param array $content submitted content
1893 1891
 	*/
1894 1892
 	function edit($content=null)
1895 1893
 	{
Please login to merge, or discard this patch.
Braces   +363 added lines, -94 removed lines patch added patch discarded remove patch
@@ -92,7 +92,10 @@  discard block
 block discarded – undo
92 92
 		);
93 93
 
94 94
 		// make sure the hook for export_limit is registered
95
-		if (!Api\Hooks::exists('export_limit','addressbook')) Api\Hooks::read(true);
95
+		if (!Api\Hooks::exists('export_limit','addressbook'))
96
+		{
97
+			Api\Hooks::read(true);
98
+		}
96 99
 
97 100
 		$this->config =& $GLOBALS['egw_info']['server'];
98 101
 
@@ -131,15 +134,21 @@  discard block
 block discarded – undo
131 134
 		{
132 135
 			$do_email = $_content['do_email'];
133 136
 
134
-			if (isset($_content['nm']['rows']['delete']))	// handle a single delete like delete with the checkboxes
137
+			if (isset($_content['nm']['rows']['delete']))
138
+			{
139
+				// handle a single delete like delete with the checkboxes
135 140
 			{
136 141
 				list($id) = @each($_content['nm']['rows']['delete']);
142
+			}
137 143
 				$_content['nm']['action'] = 'delete';
138 144
 				$_content['nm']['selected'] = array($id);
139 145
 			}
140
-			if (isset($_content['nm']['rows']['document']))	// handle insert in default document button like an action
146
+			if (isset($_content['nm']['rows']['document']))
147
+			{
148
+				// handle insert in default document button like an action
141 149
 			{
142 150
 				list($id) = @each($_content['nm']['rows']['document']);
151
+			}
143 152
 				$_content['nm']['action'] = 'document';
144 153
 				$_content['nm']['selected'] = array($id);
145 154
 			}
@@ -149,10 +158,13 @@  discard block
 block discarded – undo
149 158
 				{
150 159
 					$msg = lang('You need to select some contacts first');
151 160
 				}
152
-				elseif ($_content['nm']['action'] == 'view_org')	// org-view via context menu
161
+				elseif ($_content['nm']['action'] == 'view_org')
162
+				{
163
+					// org-view via context menu
153 164
 				{
154 165
 					$_content['nm']['org_view'] = array_shift($_content['nm']['selected']);
155 166
 				}
167
+				}
156 168
 				else
157 169
 				{
158 170
 					$success = $failed = $action_msg = null;
@@ -175,10 +187,13 @@  discard block
 block discarded – undo
175 187
 				list($org) = each($_content['nm']['rows']['infolog']);
176 188
 				return $this->infolog_org_view($org);
177 189
 			}
178
-			if ($_content['nm']['rows']['view'])	// show all contacts of an organisation
190
+			if ($_content['nm']['rows']['view'])
191
+			{
192
+				// show all contacts of an organisation
179 193
 			{
180 194
 				list($org_view) = each($_content['nm']['rows']['view']);
181 195
 			}
196
+			}
182 197
 			else
183 198
 			{
184 199
 				$org_view = $_content['nm']['org_view'];
@@ -271,10 +286,14 @@  discard block
 block discarded – undo
271 286
 		}
272 287
 
273 288
 		// Search parameter passed in
274
-		if ($_GET['search']) {
289
+		if ($_GET['search'])
290
+		{
275 291
 			$content['nm']['search'] = $_GET['search'];
276 292
 		}
277
-		if (isset($typeselection)) $content['nm']['col_filter']['tid'] = $typeselection;
293
+		if (isset($typeselection))
294
+		{
295
+			$content['nm']['col_filter']['tid'] = $typeselection;
296
+		}
278 297
 		// save the tid for use in creating new addressbook entrys via UI. Current tid is to be used as type of new entrys
279 298
 		//error_log(__METHOD__.__LINE__.' '.$content['nm']['col_filter']['tid']);
280 299
 		Api\Cache::setSession('addressbook','active_tid',$content['nm']['col_filter']['tid']);
@@ -312,7 +331,10 @@  discard block
 block discarded – undo
312 331
 		$sel_options['adr_one_countrycode']['-custom-'] = lang('No country selected');
313 332
 
314 333
 		// if there is any export limit set, pass it on to the nextmatch, to be evaluated by the export
315
-		if (isset($this->config['contact_export_limit']) && (int)$this->config['contact_export_limit']) $content['nm']['export_limit']=$this->config['contact_export_limit'];
334
+		if (isset($this->config['contact_export_limit']) && (int)$this->config['contact_export_limit'])
335
+		{
336
+			$content['nm']['export_limit']=$this->config['contact_export_limit'];
337
+		}
316 338
 
317 339
 		// dont show tid-selection if we have only one content_type
318 340
 		// be a bit more sophisticated about it
@@ -322,7 +344,10 @@  discard block
 block discarded – undo
322 344
 			//_debug_array(array('Typefilter:'=> $content['nm']['col_filter']['tid'],'Available Types:'=>$availabletypes,'action:'=>'remove invalid filter'));
323 345
 			unset($content['nm']['col_filter']['tid']);
324 346
 		}
325
-		if (!isset($content['nm']['col_filter']['tid'])) $content['nm']['col_filter']['tid'] = $availabletypes[0];
347
+		if (!isset($content['nm']['col_filter']['tid']))
348
+		{
349
+			$content['nm']['col_filter']['tid'] = $availabletypes[0];
350
+		}
326 351
 		if (count($this->content_types) > 1)
327 352
 		{
328 353
 			foreach($this->content_types as $tid => $data)
@@ -421,7 +446,10 @@  discard block
 block discarded – undo
421 446
 		$crm_apps = array('infolog','tracker');
422 447
 		foreach($crm_apps as $app)
423 448
 		{
424
-			if ($GLOBALS['egw_info']['user']['apps'][$app]) $crm_count++;
449
+			if ($GLOBALS['egw_info']['user']['apps'][$app])
450
+			{
451
+				$crm_count++;
452
+			}
425 453
 		}
426 454
 		if($crm_count > 1)
427 455
 		{
@@ -477,7 +505,10 @@  discard block
 block discarded – undo
477 505
 				),
478 506
 			),
479 507
 		);
480
-		if (!$GLOBALS['egw_info']['user']['apps']['preferences']) unset($actions['cats']['children']['cat_edit']);
508
+		if (!$GLOBALS['egw_info']['user']['apps']['preferences'])
509
+		{
510
+			unset($actions['cats']['children']['cat_edit']);
511
+		}
481 512
 		// Submenu for all distributionlist stuff
482 513
 		$actions['lists'] = array(
483 514
 			'caption' => 'Distribution lists',
@@ -490,7 +521,9 @@  discard block
 block discarded – undo
490 521
 			),
491 522
 			'group' => $group,
492 523
 		);
493
-		if (($add_lists = $this->get_lists(Acl::EDIT)))	// do we have distribution lists?, and are we allowed to edit them
524
+		if (($add_lists = $this->get_lists(Acl::EDIT)))
525
+		{
526
+			// do we have distribution lists?, and are we allowed to edit them
494 527
 		{
495 528
 			$actions['lists']['children'] += array(
496 529
 				'to_list' => array(
@@ -526,6 +559,7 @@  discard block
 block discarded – undo
526 559
 					'fieldValue' => '!',	// enable if list != ''
527 560
 				),
528 561
 			);
562
+		}
529 563
 			if(is_subclass_of('etemplate', 'etemplate_new'))
530 564
 			{
531 565
 				$actions['lists']['children']['remove_from_list']['fieldId'] = 'filter2';
@@ -534,9 +568,13 @@  discard block
 block discarded – undo
534 568
 			}
535 569
 		}
536 570
 		// move to AB
537
-		if (($move2addressbooks = $this->get_addressbooks(Acl::ADD)))	// do we have addressbooks, we should
571
+		if (($move2addressbooks = $this->get_addressbooks(Acl::ADD)))
538 572
 		{
539
-			unset($move2addressbooks[0]);	// do not offer action to move contact to an account, as we dont support that currrently
573
+			// do we have addressbooks, we should
574
+		{
575
+			unset($move2addressbooks[0]);
576
+		}
577
+		// do not offer action to move contact to an account, as we dont support that currrently
540 578
 			foreach($move2addressbooks as $owner => $label)
541 579
 			{
542 580
 				$icon = $type_label = null;
@@ -667,7 +705,9 @@  discard block
 block discarded – undo
667 705
 
668 706
 			);
669 707
 		if (!$this->prefs['preferredMail'])
670
-			$actions['email']['children']['email_business']['checked'] = true;
708
+		{
709
+					$actions['email']['children']['email_business']['checked'] = true;
710
+		}
671 711
 
672 712
 		if ($GLOBALS['egw_info']['user']['apps']['filemanager'])
673 713
 		{
@@ -811,11 +851,17 @@  discard block
 block discarded – undo
811 851
 	private function _get_org_name($org)
812 852
 	{
813 853
 		$org_name = array();
814
-		if (strpos($org,'*AND*')!== false) $org = str_replace('*AND*','&',$org);
854
+		if (strpos($org,'*AND*')!== false)
855
+		{
856
+			$org = str_replace('*AND*','&',$org);
857
+		}
815 858
 		foreach(explode('|||',$org) as $part)
816 859
 		{
817 860
 			list(,$name) = explode(':',$part,2);
818
-			if ($name) $org_name[] = $name;
861
+			if ($name)
862
+			{
863
+				$org_name[] = $name;
864
+			}
819 865
 		}
820 866
 		$name = implode(': ',$org_name);
821 867
 		return $name ? array($org => $name) : array();
@@ -877,9 +923,15 @@  discard block
 block discarded – undo
877 923
 		$org_contacts = array();
878 924
 		$query = !$_query ? Api\Cache::getSession('addressbook', 'index') : $_query;
879 925
 		$query['num_rows'] = -1;	// all
880
-		if(!is_array($query['col_filter'])) $query['col_filter'] = array();
926
+		if(!is_array($query['col_filter']))
927
+		{
928
+			$query['col_filter'] = array();
929
+		}
881 930
 
882
-		if(!is_array($org)) $org = array($org);
931
+		if(!is_array($org))
932
+		{
933
+			$org = array($org);
934
+		}
883 935
 		foreach($org as $org_name)
884 936
 		{
885 937
 			$query['org_view'] = $org_name;
@@ -908,14 +960,23 @@  discard block
 block discarded – undo
908 960
 		$checked = $readonlys = null;
909 961
 		$this->get_rows($query,$checked,$readonlys,true);	// true = only return the id's
910 962
 
911
-		if (count($checked) > 1)	// use a nicely formatted org-name as title in infolog
963
+		if (count($checked) > 1)
964
+		{
965
+			// use a nicely formatted org-name as title in infolog
912 966
 		{
913 967
 			$parts = array();
914
-			if (strpos($org,'*AND*')!== false) $org = str_replace('*AND*','&',$org);
968
+		}
969
+			if (strpos($org,'*AND*')!== false)
970
+			{
971
+				$org = str_replace('*AND*','&',$org);
972
+			}
915 973
 			foreach(explode('|||',$org) as $part)
916 974
 			{
917 975
 				list(,$part) = explode(':',$part,2);
918
-				if ($part) $parts[] = $part;
976
+				if ($part)
977
+				{
978
+					$parts[] = $part;
979
+				}
919 980
 			}
920 981
 			$org = implode(', ',$parts);
921 982
 		}
@@ -940,13 +1001,19 @@  discard block
 block discarded – undo
940 1001
 
941 1002
 		$response = Api\Json\Response::get();
942 1003
 
943
-		if ($success) $response->addScript(Framework::set_onload(''));
1004
+		if ($success)
1005
+		{
1006
+			$response->addScript(Framework::set_onload(''));
1007
+		}
944 1008
 
945 1009
 		// close window only if no errors AND something added
946 1010
 		if ($failed || !$success)
947 1011
 		{
948
-			if (!$msg) $msg = $failed ? lang('%1 contact(s) %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed) :
1012
+			if (!$msg)
1013
+			{
1014
+				$msg = $failed ? lang('%1 contact(s) %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed) :
949 1015
 				lang('%1 contact(s) %2',$success,$action_msg);
1016
+			}
950 1017
 
951 1018
 			$response->addScript("alert('".addslashes($msg)."')");
952 1019
 			// reset the filter
@@ -954,7 +1021,10 @@  discard block
 block discarded – undo
954 1021
 		}
955 1022
 		else
956 1023
 		{
957
-			if (!$msg) $msg = lang('%1 contact(s) %2',$success,$action_msg);
1024
+			if (!$msg)
1025
+			{
1026
+				$msg = lang('%1 contact(s) %2',$success,$action_msg);
1027
+			}
958 1028
 			$response->addScript("alert('".addslashes($msg)."')");
959 1029
 			$response->addScript('egw(window).close();');
960 1030
 		}
@@ -1063,10 +1133,16 @@  discard block
 block discarded – undo
1063 1133
 				unset($query['filter2']);
1064 1134
 				$extra = $readonlys = null;
1065 1135
 				$this->get_rows($query,$extra,$readonlys,true);	// true = only return the id's
1066
-				if ($extra[0]) $org_contacts = array_merge($org_contacts,$extra);
1136
+				if ($extra[0])
1137
+				{
1138
+					$org_contacts = array_merge($org_contacts,$extra);
1139
+				}
1067 1140
 			}
1068 1141
 		}
1069
-		if ($org_contacts) $checked = array_unique($checked ? array_merge($checked,$org_contacts) : $org_contacts);
1142
+		if ($org_contacts)
1143
+		{
1144
+			$checked = array_unique($checked ? array_merge($checked,$org_contacts) : $org_contacts);
1145
+		}
1070 1146
 		//_debug_array($checked); exit;
1071 1147
 
1072 1148
 		if (substr($action,0,8) == 'move_to_')
@@ -1083,9 +1159,12 @@  discard block
 block discarded – undo
1083 1159
 			$document = substr($action,9);
1084 1160
 			$action = 'document';
1085 1161
 		}
1086
-		elseif(substr($action,0,4) == 'cat_')	// cat_add_123 or cat_del_456
1162
+		elseif(substr($action,0,4) == 'cat_')
1163
+		{
1164
+			// cat_add_123 or cat_del_456
1087 1165
 		{
1088 1166
 			$cat_id = (int)substr($action, 8);
1167
+		}
1089 1168
 			$action = substr($action,0,7);
1090 1169
 		}
1091 1170
 		// Security: stop non-admins to export more then the configured number of contacts
@@ -1132,7 +1211,10 @@  discard block
 block discarded – undo
1132 1211
 				return false;
1133 1212
 
1134 1213
 			case 'document':
1135
-				if (!$document) $document = $this->prefs['default_document'];
1214
+				if (!$document)
1215
+				{
1216
+					$document = $this->prefs['default_document'];
1217
+				}
1136 1218
 				$document_merge = new Api\Contacts\Merge();
1137 1219
 				$msg = $document_merge->download($document, $checked, '', $this->prefs['document_dir']);
1138 1220
 				$failed = count($checked);
@@ -1284,19 +1366,25 @@  discard block
 block discarded – undo
1284 1366
 					break;
1285 1367
 
1286 1368
 				default:	// move to an other addressbook
1287
-					if (!(int)$action || !($this->grants[(string) (int) $action] & Acl::EDIT))	// might be ADD in the future
1369
+					if (!(int)$action || !($this->grants[(string) (int) $action] & Acl::EDIT))
1370
+					{
1371
+						// might be ADD in the future
1288 1372
 					{
1289 1373
 						return false;
1290 1374
 					}
1375
+					}
1291 1376
 					if (!$checkboxes['move_to_copy'])
1292 1377
 					{
1293 1378
 						$action_msg = lang('moved');
1294 1379
 						if (($Ok = !!($contact = $this->read($id)) && $this->check_perms(Acl::DELETE,$contact)))
1295 1380
 						{
1296
-							if (!$contact['owner'])		// no (mass-)move of Api\Accounts
1381
+							if (!$contact['owner'])
1382
+							{
1383
+								// no (mass-)move of Api\Accounts
1297 1384
 							{
1298 1385
 								$Ok = false;
1299 1386
 							}
1387
+							}
1300 1388
 							elseif ($contact['owner'] != (int)$action || $contact['private'] != (int)(substr($action,-1) == 'p'))
1301 1389
 							{
1302 1390
 								$contact['owner'] = (int) $action;
@@ -1385,9 +1473,12 @@  discard block
 block discarded – undo
1385 1473
 		$do_email = $query['do_email'];
1386 1474
 		$what = $query['sitemgr_display'] ? $query['sitemgr_display'] : ($do_email ? 'email' : 'index');
1387 1475
 
1388
-		if (!$id_only && !$query['csv_export'])	// do NOT store state for csv_export or querying id's (no regular view)
1476
+		if (!$id_only && !$query['csv_export'])
1477
+		{
1478
+			// do NOT store state for csv_export or querying id's (no regular view)
1389 1479
 		{
1390 1480
 			$store_query = $query;
1481
+		}
1391 1482
 			// Do not store these
1392 1483
 			foreach(array('options-cat_id','actions') as $key)
1393 1484
 			{
@@ -1399,14 +1490,25 @@  discard block
 block discarded – undo
1399 1490
 		{
1400 1491
 			$old_state = Api\Cache::getSession('addressbook', $what);
1401 1492
 		}
1402
-		if (!isset($this->org_views[(string) $query['org_view']]) || strpos($query['org_view'],':') === false)   // we dont have an org view, unset the according col_filters
1493
+		if (!isset($this->org_views[(string) $query['org_view']]) || strpos($query['org_view'],':') === false)
1494
+		{
1495
+			// we dont have an org view, unset the according col_filters
1403 1496
 		{
1404 1497
 			if (isset($query['col_filter']['org_name'])) unset($query['col_filter']['org_name']);
1405
-			if (isset($query['col_filter']['adr_one_locality'])) unset($query['col_filter']['adr_one_locality']);
1406
-			if (isset($query['col_filter']['org_unit'])) unset($query['col_filter']['org_unit']);
1498
+		}
1499
+			if (isset($query['col_filter']['adr_one_locality']))
1500
+			{
1501
+				unset($query['col_filter']['adr_one_locality']);
1502
+			}
1503
+			if (isset($query['col_filter']['org_unit']))
1504
+			{
1505
+				unset($query['col_filter']['org_unit']);
1506
+			}
1407 1507
 		}
1408 1508
 
1409
-		if (isset($this->org_views[(string) $query['org_view']]))	// we have an org view, reset the advanced search
1509
+		if (isset($this->org_views[(string) $query['org_view']]))
1510
+		{
1511
+			// we have an org view, reset the advanced search
1410 1512
 		{
1411 1513
 			//_debug_array(array('Search'=>$query['search'],
1412 1514
 			//	'AdvancedSearch'=>$query['advanced_search']));
@@ -1414,10 +1516,14 @@  discard block
 block discarded – undo
1414 1516
 			//unset($query['advanced_search']);
1415 1517
 			if(!$query['search'] && $old_state['advanced_search']) $query['advanced_search'] = $old_state['advanced_search'];
1416 1518
 		}
1417
-		elseif(!$query['search'] && $old_state['advanced_search'])	// eg. paging in an advanced search
1519
+		}
1520
+		elseif(!$query['search'] && $old_state['advanced_search'])
1521
+		{
1522
+			// eg. paging in an advanced search
1418 1523
 		{
1419 1524
 			$query['advanced_search'] = $old_state['advanced_search'];
1420 1525
 		}
1526
+		}
1421 1527
 		/* this cant work anymore, as Framework::set_onload no longer exists
1422 1528
 		if ($do_email && etemplate::$loop)
1423 1529
 		{	// remove previous addEmail() calls, otherwise they will be run again
@@ -1427,11 +1533,13 @@  discard block
 block discarded – undo
1427 1533
 		// Make sure old lettersearch filter doesn't stay - current letter filter will be added later
1428 1534
 		foreach($query['col_filter'] as $key => $col_filter)
1429 1535
 		{
1430
-			if(!is_numeric($key)) continue;
1536
+			if(!is_numeric($key))
1537
+			{
1538
+				continue;
1539
+			}
1431 1540
 			if(preg_match('/'.$GLOBALS['egw']->db->capabilities['case_insensitive_like'].
1432 1541
 				' '.$GLOBALS['egw']->db->quote('[a-z]%').'$/',$col_filter) == 1
1433
-			)
1434
-			{
1542
+			) {
1435 1543
 				unset($query['col_filter'][$key]);
1436 1544
 			}
1437 1545
 		}
@@ -1442,9 +1550,13 @@  discard block
 block discarded – undo
1442 1550
 			// check if accounts are stored in ldap, which does NOT yet support the org-views
1443 1551
 			if ($this->so_accounts && $query['filter'] === '0' && $query['org_view'])
1444 1552
 			{
1445
-				if ($old_state['filter'] === '0')	// user changed to org_view
1553
+				if ($old_state['filter'] === '0')
1446 1554
 				{
1447
-					$query['filter'] = '';			// --> change filter to all contacts
1555
+					// user changed to org_view
1556
+				{
1557
+					$query['filter'] = '';
1558
+				}
1559
+				// --> change filter to all contacts
1448 1560
 				}
1449 1561
 				else								// user changed to accounts
1450 1562
 				{
@@ -1481,9 +1593,12 @@  discard block
 block discarded – undo
1481 1593
 		{
1482 1594
 			unset($query['col_filter']['cat_id']);
1483 1595
 		}
1484
-		if ($query['filter'] !== '')	// not all addressbooks
1596
+		if ($query['filter'] !== '')
1597
+		{
1598
+			// not all addressbooks
1485 1599
 		{
1486 1600
 			$query['col_filter']['owner'] = (string) (int) $query['filter'];
1601
+		}
1487 1602
 
1488 1603
 			if ($this->private_addressbook)
1489 1604
 			{
@@ -1495,10 +1610,13 @@  discard block
 block discarded – undo
1495 1610
 			unset($query['col_filter']['owner']);
1496 1611
 			unset($query['col_filter']['private']);
1497 1612
 		}
1498
-		if ((int)$query['filter2'])	// not no distribution list
1613
+		if ((int)$query['filter2'])
1614
+		{
1615
+			// not no distribution list
1499 1616
 		{
1500 1617
 			$query['col_filter']['list'] = (string) (int) $query['filter2'];
1501 1618
 		}
1619
+		}
1502 1620
 		else
1503 1621
 		{
1504 1622
 			unset($query['col_filter']['list']);
@@ -1510,10 +1628,13 @@  discard block
 block discarded – undo
1510 1628
 		// enable/disable distribution lists depending on backend
1511 1629
 		$query['no_filter2'] = !$this->lists_available($query['filter']);
1512 1630
 
1513
-		if (isset($this->org_views[(string) $query['org_view']]) && !$query['col_filter']['parent_id'])	// we have an org view
1631
+		if (isset($this->org_views[(string) $query['org_view']]) && !$query['col_filter']['parent_id'])
1632
+		{
1633
+			// we have an org view
1514 1634
 		{
1515 1635
 			// Query doesn't like empties
1516 1636
 			unset($query['col_filter']['parent_id']);
1637
+		}
1517 1638
 
1518 1639
 			if($query['actions'] && $query['actions']['open'])
1519 1640
 			{
@@ -1566,9 +1687,12 @@  discard block
 block discarded – undo
1566 1687
 			}
1567 1688
 			// Query doesn't like parent_id
1568 1689
 			unset($query['col_filter']['parent_id']);
1569
-			if ($query['org_view'])	// view the contacts of one organisation only
1690
+			if ($query['org_view'])
1691
+			{
1692
+				// view the contacts of one organisation only
1570 1693
 			{
1571 1694
 				if (strpos($query['org_view'],'*AND*') !== false) $query['org_view'] = str_replace('*AND*','&',$query['org_view']);
1695
+			}
1572 1696
 				foreach(explode('|||',$query['org_view']) as $part)
1573 1697
 				{
1574 1698
 					list($name,$value) = explode(':',$part,2);
@@ -1587,14 +1711,18 @@  discard block
 block discarded – undo
1587 1711
 			// translate the select order to the really used over all 3 columns
1588 1712
 			$sort = $query['sort'];
1589 1713
 			switch($query['order'])		// "xxx<>'' DESC" sorts contacts with empty order-criteria always at the end
1590
-			{							// we don't exclude them, as the total would otherwise depend on the order-criteria
1714
+			{
1715
+// we don't exclude them, as the total would otherwise depend on the order-criteria
1591 1716
 				case 'org_name':
1592 1717
 					$order = "egw_addressbook.org_name<>''DESC,egw_addressbook.org_name $sort,n_family $sort,n_given $sort";
1593 1718
 					break;
1594 1719
 				default:
1595
-					if ($query['order'][0] == '#')	// we order by a custom field
1720
+					if ($query['order'][0] == '#')
1721
+					{
1722
+						// we order by a custom field
1596 1723
 					{
1597 1724
 						$order = "{$query['order']} $sort,org_name $sort,n_family $sort,n_given $sort";
1725
+					}
1598 1726
 						break;
1599 1727
 					}
1600 1728
 					$query['order'] = 'n_family';
@@ -1618,9 +1746,12 @@  discard block
 block discarded – undo
1618 1746
 				case 'contact_id':
1619 1747
 					$order = "egw_addressbook.$query[order] $sort";
1620 1748
 			}
1621
-			if ($query['searchletter'])	// only show contacts if the order-criteria starts with the given letter
1749
+			if ($query['searchletter'])
1750
+			{
1751
+				// only show contacts if the order-criteria starts with the given letter
1622 1752
 			{
1623 1753
 				$no_letter_search = array('adr_one_postalcode', 'adr_two_postalcode', 'contact_id', 'contact_created','contact_modified');
1754
+			}
1624 1755
 				$query['col_filter'][] = (in_array($query['order'],$no_letter_search) ? 'org_name' : (substr($query['order'],0,1)=='#'?'':'egw_addressbook.').$query['order']).' '.
1625 1756
 					$GLOBALS['egw']->db->capabilities['case_insensitive_like'].' '.$GLOBALS['egw']->db->quote(strtolower($query['searchletter']).'%');
1626 1757
 			}
@@ -1658,11 +1789,17 @@  discard block
 block discarded – undo
1658 1789
 					{
1659 1790
 						foreach($columselection as $col)
1660 1791
 						{
1661
-							if ($col[0] == '#') $selected_cfs[] = substr($col,1);
1792
+							if ($col[0] == '#')
1793
+							{
1794
+								$selected_cfs[] = substr($col,1);
1795
+							}
1662 1796
 						}
1663 1797
 						$customfields = $this->read_customfields($ids,$selected_cfs);
1664 1798
 					}
1665
-					if ($show_calendar && !empty($ids)) $calendar = $this->read_calendar($ids);
1799
+					if ($show_calendar && !empty($ids))
1800
+					{
1801
+						$calendar = $this->read_calendar($ids);
1802
+					}
1666 1803
 					// distributionlist memership for the entrys
1667 1804
 					//_debug_array($this->get_lists(Acl::EDIT));
1668 1805
 					if ($show_distributionlist && $available_distib_lists)
@@ -1672,7 +1809,10 @@  discard block
 block discarded – undo
1672 1809
 				}
1673 1810
 			}
1674 1811
 		}
1675
-		if (!$rows) $rows = array();
1812
+		if (!$rows)
1813
+		{
1814
+			$rows = array();
1815
+		}
1676 1816
 
1677 1817
 		if ($id_only)
1678 1818
 		{
@@ -1705,7 +1845,10 @@  discard block
 block discarded – undo
1705 1845
 					$row['line2'] = $row['org_name'];
1706 1846
 					break;
1707 1847
 				case 'n_fileas':
1708
-					if (!$row['n_fileas']) $row['n_fileas'] = $this->fileas($row);
1848
+					if (!$row['n_fileas'])
1849
+					{
1850
+						$row['n_fileas'] = $this->fileas($row);
1851
+					}
1709 1852
 					list($row['line1'],$row['line2']) = explode(': ',$row['n_fileas']);
1710 1853
 					break;
1711 1854
 			}
@@ -1779,8 +1922,14 @@  discard block
 block discarded – undo
1779 1922
 			}
1780 1923
 
1781 1924
 			// hide region for address format 'postcode_city'
1782
-			if (($row['addr_format']  = $this->addr_format_by_country($row['adr_one_countryname']))=='postcode_city') unset($row['adr_one_region']);
1783
-			if (($row['addr_format2'] = $this->addr_format_by_country($row['adr_two_countryname']))=='postcode_city') unset($row['adr_two_region']);
1925
+			if (($row['addr_format']  = $this->addr_format_by_country($row['adr_one_countryname']))=='postcode_city')
1926
+			{
1927
+				unset($row['adr_one_region']);
1928
+			}
1929
+			if (($row['addr_format2'] = $this->addr_format_by_country($row['adr_two_countryname']))=='postcode_city')
1930
+			{
1931
+				unset($row['adr_two_region']);
1932
+			}
1784 1933
 
1785 1934
 			// respect category permissions
1786 1935
 			if(!empty($row['cat_id']))
@@ -1791,7 +1940,10 @@  discard block
 block discarded – undo
1791 1940
 		$rows['no_distribution_list'] = (bool)$query['filter2'];
1792 1941
 
1793 1942
 		// disable customfields column, if we have no customefield(s)
1794
-		if (!$this->customfields) $rows['no_customfields'] = true;
1943
+		if (!$this->customfields)
1944
+		{
1945
+			$rows['no_customfields'] = true;
1946
+		}
1795 1947
 
1796 1948
 		$rows['order'] = $order;
1797 1949
 		$rows['call_popup'] = $this->config['call_popup'];
@@ -1830,10 +1982,13 @@  discard block
 block discarded – undo
1830 1982
 			$order = $order == 'n_given' ? lang('first name') : ($order == 'n_family' ? lang('last name') : lang('Organisation'));
1831 1983
 			$header[] = lang("%1 starts with '%2'",$order,$query['searchletter']);
1832 1984
 		}
1833
-		if ($query['search'] && !$query['advanced_search']) // do not add that, if we have advanced search active
1985
+		if ($query['search'] && !$query['advanced_search'])
1986
+		{
1987
+			// do not add that, if we have advanced search active
1834 1988
 		{
1835 1989
 			$header[] = lang("Search for '%1'",$query['search']);
1836 1990
 		}
1991
+		}
1837 1992
 		$GLOBALS['egw_info']['flags']['app_header'] = implode(': ', $header);
1838 1993
 
1839 1994
 		return $this->total;
@@ -1900,7 +2055,10 @@  discard block
 block discarded – undo
1900 2055
 			$content['private'] = (int) ($content['owner'] && substr($content['owner'],-1) == 'p');
1901 2056
 			$content['owner'] = (string) (int) $content['owner'];
1902 2057
 			$content['cat_id'] = $this->config['cat_tab'] === 'Tree' ? $content['cat_id_tree'] : $content['cat_id'];
1903
-			if ($this->config['private_cf_tab']) $content = (array)$content['private_cfs'] + $content;
2058
+			if ($this->config['private_cf_tab'])
2059
+			{
2060
+				$content = (array)$content['private_cfs'] + $content;
2061
+			}
1904 2062
 			unset($content['private_cfs']);
1905 2063
 
1906 2064
 			switch($button)
@@ -2097,7 +2255,10 @@  discard block
 block discarded – undo
2097 2255
 				{
2098 2256
 					// arguments containing a comma get quoted by etemplate/js/nextmatch_action.js
2099 2257
 					// leading to error in Api\Db::column_data_implode, if not unquoted
2100
-					if ($org[0] == '"') $org = substr($org, 1, -1);
2258
+					if ($org[0] == '"')
2259
+					{
2260
+						$org = substr($org, 1, -1);
2261
+					}
2101 2262
 					$content = $this->read_org($org);
2102 2263
 				}
2103 2264
 				elseif ($state['org_view'] && !isset($this->org_views[$state['org_view']]))
@@ -2117,7 +2278,10 @@  discard block
 block discarded – undo
2117 2278
 						$content['adr_two_countryname'] =
2118 2279
 							$GLOBALS['egw']->country->get_full_name($GLOBALS['egw_info']['user']['preferences']['common']['country']);
2119 2280
 					}
2120
-					if ($this->prefs['fileas_default']) $content['fileas_type'] = $this->prefs['fileas_default'];
2281
+					if ($this->prefs['fileas_default'])
2282
+					{
2283
+						$content['fileas_type'] = $this->prefs['fileas_default'];
2284
+					}
2121 2285
 				}
2122 2286
 				if (isset($_GET['owner']) && $_GET['owner'] !== '')
2123 2287
 				{
@@ -2142,7 +2306,10 @@  discard block
 block discarded – undo
2142 2306
 				$new_type = array_keys($this->content_types);
2143 2307
 				// fetch active type to preset the type, if param typeid is not passed
2144 2308
 				$active_tid = Api\Cache::getSession('addressbook','active_tid');
2145
-				if ($active_tid && strtoupper($active_tid) === 'D') unset($active_tid);
2309
+				if ($active_tid && strtoupper($active_tid) === 'D')
2310
+				{
2311
+					unset($active_tid);
2312
+				}
2146 2313
 				$content['tid'] = $_GET['typeid'] ? $_GET['typeid'] : ($active_tid?$active_tid:$new_type[0]);
2147 2314
 				foreach($this->get_contact_columns() as $field)
2148 2315
 				{
@@ -2160,19 +2327,37 @@  discard block
 block discarded – undo
2160 2327
 									if (strpos($singleAddress[0]->personal,',')===false)
2161 2328
 									{
2162 2329
 										list($P_n_given,$P_n_family,$P_org_name)=explode(' ',$singleAddress[0]->personal,3);
2163
-										if (strlen(trim($P_n_given))>0) $content['n_given'] = trim($P_n_given);
2164
-										if (strlen(trim($P_n_family))>0) $content['n_family'] = trim($P_n_family);
2165
-										if (strlen(trim($P_org_name))>0) $content['org_name'] = trim($P_org_name);
2330
+										if (strlen(trim($P_n_given))>0)
2331
+										{
2332
+											$content['n_given'] = trim($P_n_given);
2333
+										}
2334
+										if (strlen(trim($P_n_family))>0)
2335
+										{
2336
+											$content['n_family'] = trim($P_n_family);
2337
+										}
2338
+										if (strlen(trim($P_org_name))>0)
2339
+										{
2340
+											$content['org_name'] = trim($P_org_name);
2341
+										}
2166 2342
 									}
2167 2343
 									else
2168 2344
 									{
2169 2345
 										list($P_n_family,$P_other)=explode(',',$singleAddress[0]->personal,2);
2170
-										if (strlen(trim($P_n_family))>0) $content['n_family'] = trim($P_n_family);
2346
+										if (strlen(trim($P_n_family))>0)
2347
+										{
2348
+											$content['n_family'] = trim($P_n_family);
2349
+										}
2171 2350
 										if (strlen(trim($P_other))>0)
2172 2351
 										{
2173 2352
 											list($P_n_given,$P_org_name)=explode(',',$P_other,2);
2174
-											if (strlen(trim($P_n_given))>0) $content['n_given'] = trim($P_n_given);
2175
-											if (strlen(trim($P_org_name))>0) $content['org_name'] = trim($P_org_name);
2353
+											if (strlen(trim($P_n_given))>0)
2354
+											{
2355
+												$content['n_given'] = trim($P_n_given);
2356
+											}
2357
+											if (strlen(trim($P_org_name))>0)
2358
+											{
2359
+												$content['org_name'] = trim($P_org_name);
2360
+											}
2176 2361
 										}
2177 2362
 									}
2178 2363
 								}
@@ -2200,7 +2385,10 @@  discard block
 block discarded – undo
2200 2385
 							break;
2201 2386
 						}
2202 2387
 					}
2203
-					if (empty($content['n_fn'])) $content['n_fn'] = $this->fullname($content);
2388
+					if (empty($content['n_fn']))
2389
+					{
2390
+						$content['n_fn'] = $this->fullname($content);
2391
+					}
2204 2392
 				}
2205 2393
 				$content['creator'] = $this->user;
2206 2394
 				$content['created'] = $this->now_su;
@@ -2208,17 +2396,27 @@  discard block
 block discarded – undo
2208 2396
 				//_debug_array($content);
2209 2397
 			}
2210 2398
 
2211
-			if ($_GET['msg']) $content['msg'] = strip_tags($_GET['msg']);	// dont allow HTML!
2399
+			if ($_GET['msg'])
2400
+			{
2401
+				$content['msg'] = strip_tags($_GET['msg']);
2402
+			}
2403
+			// dont allow HTML!
2212 2404
 
2213
-			if($content && $_GET['makecp'])	// copy the contact
2405
+			if($content && $_GET['makecp'])
2406
+			{
2407
+				// copy the contact
2214 2408
 			{
2215 2409
 				$this->copy_contact($content);
2410
+			}
2216 2411
 				$content['msg'] = lang('Contact copied');
2217 2412
 				$view = false;
2218 2413
 			}
2219 2414
 			else
2220 2415
 			{
2221
-				if (is_numeric($contact_id)) $content['link_to']['to_id'] = $contact_id;
2416
+				if (is_numeric($contact_id))
2417
+				{
2418
+					$content['link_to']['to_id'] = $contact_id;
2419
+				}
2222 2420
 			}
2223 2421
 			// automatic link new entries to entries specified in the url
2224 2422
 			if (!$contact_id && isset($_REQUEST['link_app']) && isset($_REQUEST['link_id']) && !is_array($content['link_to']['to_id']))
@@ -2227,10 +2425,13 @@  discard block
 block discarded – undo
2227 2425
 				foreach(is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app)
2228 2426
 				{
2229 2427
 					$link_id = $link_ids[$n];
2230
-					if (preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id))	// gard against XSS
2428
+					if (preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id))
2429
+					{
2430
+						// gard against XSS
2231 2431
 					{
2232 2432
 						Link::link('addressbook',$content['link_to']['to_id'],$link_app,$link_id);
2233 2433
 					}
2434
+					}
2234 2435
 				}
2235 2436
 			}
2236 2437
 		}
@@ -2238,7 +2439,10 @@  discard block
 block discarded – undo
2238 2439
 		{
2239 2440
 			// last and next calendar date
2240 2441
 			list(,$dates) = each($this->read_calendar(array($content['id']),false));
2241
-			if(is_array($dates)) $content += $dates;
2442
+			if(is_array($dates))
2443
+			{
2444
+				$content += $dates;
2445
+			}
2242 2446
 		}
2243 2447
 		// Avoid ID conflict with tree & selectboxes
2244 2448
 		$content['cat_id_tree'] = $content['cat_id'];
@@ -2272,7 +2476,11 @@  discard block
 block discarded – undo
2272 2476
 		$sel_options['fileas_type'] = $this->fileas_options($content);
2273 2477
 		$sel_options['adr_one_countrycode']['-custom-'] = lang('Custom');
2274 2478
 		$sel_options['owner'] = $this->get_addressbooks(Acl::ADD);
2275
-		if ($content['owner']) unset($sel_options['owner'][0]);	// do not offer to switch to accounts, as we do not support moving contacts to accounts
2479
+		if ($content['owner'])
2480
+		{
2481
+			unset($sel_options['owner'][0]);
2482
+		}
2483
+		// do not offer to switch to accounts, as we do not support moving contacts to accounts
2276 2484
 		if ((string) $content['owner'] !== '')
2277 2485
 		{
2278 2486
 			if (!isset($sel_options['owner'][(int)$content['owner']]))
@@ -2299,7 +2507,10 @@  discard block
 block discarded – undo
2299 2507
 				$readonlys[$field] = false;
2300 2508
 			}
2301 2509
 		}
2302
-		if (isset($readonlys['n_fileas'])) $readonlys['fileas_type'] = $readonlys['n_fileas'];
2510
+		if (isset($readonlys['n_fileas']))
2511
+		{
2512
+			$readonlys['fileas_type'] = $readonlys['n_fileas'];
2513
+		}
2303 2514
 		// disable not needed tabs
2304 2515
 		$readonlys['tabs']['cats'] = !($content['cat_tab'] = $this->config['cat_tab']);
2305 2516
 		$readonlys['tabs']['custom'] = !$this->customfields || $this->get_backend($content['id'],$content['owner']) == $this->so_accounts;
@@ -2307,8 +2518,14 @@  discard block
 block discarded – undo
2307 2518
 		$readonlys['tabs']['distribution_list'] = !$content['distrib_lists'];#false;
2308 2519
 		$readonlys['tabs']['history'] = $this->contact_repository != 'sql' || !$content['id'] ||
2309 2520
 			$this->account_repository != 'sql' && $content['account_id'];
2310
-		if (!$content['id']) $readonlys['button[delete]'] = !$content['id'];
2311
-		if ($this->config['private_cf_tab']) $content['no_private_cfs'] = 0;
2521
+		if (!$content['id'])
2522
+		{
2523
+			$readonlys['button[delete]'] = !$content['id'];
2524
+		}
2525
+		if ($this->config['private_cf_tab'])
2526
+		{
2527
+			$content['no_private_cfs'] = 0;
2528
+		}
2312 2529
 		$readonlys['change_org'] = empty($content['org_name']) || $view;
2313 2530
 
2314 2531
 		// for editing the own account (by a non-admin), enable only the fields allowed via the "own_account_acl"
@@ -2356,7 +2573,10 @@  discard block
 block discarded – undo
2356 2573
 
2357 2574
 		$content['photo'] = $this->photo_src($content['id'],$content['jpegphoto'],'photo',$content['etag']);
2358 2575
 
2359
-		if ($content['private']) $content['owner'] .= 'p';
2576
+		if ($content['private'])
2577
+		{
2578
+			$content['owner'] .= 'p';
2579
+		}
2360 2580
 
2361 2581
 		// for custom types, check if we have a custom edit template named "addressbook.edit.$type", $type is the name
2362 2582
 		if (in_array($content['tid'], array('n',self::DELETED_TYPE)) || !$this->tmpl->read('addressbook.edit.'.$this->content_types[$content['tid']]['name']))
@@ -2378,7 +2598,10 @@  discard block
 block discarded – undo
2378 2598
 		//error_log(__METHOD__."() hook_data=".array2string($hook_data));
2379 2599
 		foreach($hook_data as $extra_tabs)
2380 2600
 		{
2381
-			if (!$extra_tabs) continue;
2601
+			if (!$extra_tabs)
2602
+			{
2603
+				continue;
2604
+			}
2382 2605
 
2383 2606
 			foreach(isset($extra_tabs[0]) ? $extra_tabs : array($extra_tabs) as $extra_tab)
2384 2607
 			{
@@ -2395,7 +2618,10 @@  discard block
 block discarded – undo
2395 2618
 					$readonlys = array_merge($readonlys, $extra_tab['readonlys']);
2396 2619
 				}
2397 2620
 				// we must NOT add tabs and callbacks more then once!
2398
-				if (!$first_call) continue;
2621
+				if (!$first_call)
2622
+				{
2623
+					continue;
2624
+				}
2399 2625
 
2400 2626
 				if (!empty($extra_tab['pre_save_callback']))
2401 2627
 				{
@@ -2479,20 +2705,27 @@  discard block
 block discarded – undo
2479 2705
 	public function ajax_check_values($values, $name, $own_id=0)
2480 2706
 	{
2481 2707
 		$matches = null;
2482
-		if (preg_match('/^exec\[([^\]]+)\]$/', $name, $matches)) $name = $matches[1];	// remove exec[ ]
2708
+		if (preg_match('/^exec\[([^\]]+)\]$/', $name, $matches))
2709
+		{
2710
+			$name = $matches[1];
2711
+		}
2712
+		// remove exec[ ]
2483 2713
 
2484 2714
 		$ret = array('doublicates' => array(), 'msg' => null);
2485 2715
 
2486 2716
 		// if email changed, check for doublicates
2487 2717
 		if (in_array($name, array('email', 'email_home')))
2488 2718
 		{
2489
-			if (preg_match('/^'.url_widget::EMAIL_PREG.'$/i', $values[$name]))	// only search for real email addresses, to not return to many contacts
2719
+			if (preg_match('/^'.url_widget::EMAIL_PREG.'$/i', $values[$name]))
2720
+			{
2721
+				// only search for real email addresses, to not return to many contacts
2490 2722
 			{
2491 2723
 				$contacts = parent::search(array(
2492 2724
 					'email' => $values[$name],
2493 2725
 					'email_home' => $values[$name],
2494 2726
 				), false, '', '', '', false, 'OR');
2495 2727
 			}
2728
+			}
2496 2729
 		}
2497 2730
 		else
2498 2731
 		{
@@ -2506,10 +2739,13 @@  discard block
 block discarded – undo
2506 2739
 				!empty($values['n_given'])+!empty($values['n_family'])+!empty($values['org_name']) >= 2)
2507 2740
 			{
2508 2741
 				$filter = array();
2509
-				foreach(array('email', 'n_given', 'n_family', 'org_name') as $n)	// use email too, to exclude obvious false positives
2742
+				foreach(array('email', 'n_given', 'n_family', 'org_name') as $n)
2743
+				{
2744
+					// use email too, to exclude obvious false positives
2510 2745
 				{
2511 2746
 					if (!empty($values[$n])) $filter[$n] = $values[$n];
2512 2747
 				}
2748
+				}
2513 2749
 				$contacts = parent::search('', false, '', '', '', false, 'AND', false, $filter);
2514 2750
 			}
2515 2751
 		}
@@ -2517,7 +2753,10 @@  discard block
 block discarded – undo
2517 2753
 		{
2518 2754
 			foreach($contacts as $contact)
2519 2755
 			{
2520
-				if ($own_id && $contact['id'] == $own_id) continue;
2756
+				if ($own_id && $contact['id'] == $own_id)
2757
+				{
2758
+					continue;
2759
+				}
2521 2760
 
2522 2761
 				$ret['doublicates'][$contact['id']] = $this->fileas($contact).' ('.
2523 2762
 					(!$contact['owner'] ? lang('Accounts') : ($contact['owner'] == $this->user ?
@@ -2544,7 +2783,10 @@  discard block
 block discarded – undo
2544 2783
 		// CRM list comes from content, request, or preference
2545 2784
 		$crm_list = $content['crm_list'] ? $content['crm_list'] :
2546 2785
 			($_GET['crm_list'] ? $_GET['crm_list'] : $GLOBALS['egw_info']['user']['preferences']['addressbook']['crm_list']);
2547
-		if(!$crm_list || $crm_list == '~edit~') $crm_list = 'infolog';
2786
+		if(!$crm_list || $crm_list == '~edit~')
2787
+		{
2788
+			$crm_list = 'infolog';
2789
+		}
2548 2790
 
2549 2791
 		if(is_array($content))
2550 2792
 		{
@@ -2567,7 +2809,10 @@  discard block
 block discarded – undo
2567 2809
 					$inc = 1;
2568 2810
 					// fall through
2569 2811
 				case 'back':
2570
-					if (!isset($inc)) $inc = -1;
2812
+					if (!isset($inc))
2813
+					{
2814
+						$inc = -1;
2815
+					}
2571 2816
 					// get next/previous contact in selection
2572 2817
 					$query = Api\Cache::getSession('addressbook', 'index');
2573 2818
 					$query['start'] = $content['index'] + $inc;
@@ -2730,11 +2975,20 @@  discard block
 block discarded – undo
2730 2975
 		$readonlys['tabs']['distribution_list'] = !$content['distrib_lists'];#false;
2731 2976
 		$readonlys['tabs']['history'] = $this->contact_repository != 'sql' || !$content['id'] ||
2732 2977
 			$this->account_repository != 'sql' && $content['account_id'];
2733
-		if ($this->config['private_cf_tab']) $content['no_private_cfs'] = 0;
2978
+		if ($this->config['private_cf_tab'])
2979
+		{
2980
+			$content['no_private_cfs'] = 0;
2981
+		}
2734 2982
 
2735 2983
 		// last and next calendar date
2736
-		if (!empty($content['id'])) list(,$dates) = each($this->read_calendar(array($content['id']),false));
2737
-		if(is_array($dates)) $content += $dates;
2984
+		if (!empty($content['id']))
2985
+		{
2986
+			list(,$dates) = each($this->read_calendar(array($content['id']),false));
2987
+		}
2988
+		if(is_array($dates))
2989
+		{
2990
+			$content += $dates;
2991
+		}
2738 2992
 
2739 2993
 		// Disable importexport
2740 2994
 		$GLOBALS['egw_info']['flags']['disable_importexport']['export'] = true;
@@ -2813,7 +3067,10 @@  discard block
 block discarded – undo
2813 3067
 	 */
2814 3068
 	function email2link($email)
2815 3069
 	{
2816
-		if (strpos($email,'@') == false) return '';
3070
+		if (strpos($email,'@') == false)
3071
+		{
3072
+			return '';
3073
+		}
2817 3074
 
2818 3075
 		if($GLOBALS['egw_info']['user']['apps']['mail'])
2819 3076
 		{
@@ -2865,7 +3122,10 @@  discard block
 block discarded – undo
2865 3122
 				$query['advanced_search'] = array_intersect_key($_content,array_flip(array_merge($this->get_contact_columns(),array('operator','meth_select'))));
2866 3123
 				foreach ($query['advanced_search'] as $key => $value)
2867 3124
 				{
2868
-					if(!$value) unset($query['advanced_search'][$key]);
3125
+					if(!$value)
3126
+					{
3127
+						unset($query['advanced_search'][$key]);
3128
+					}
2869 3129
 				}
2870 3130
 				// Skip n_fn, it causes problems in sql
2871 3131
 				unset($query['advanced_search']['n_fn']);
@@ -2921,8 +3181,14 @@  discard block
 block discarded – undo
2921 3181
 			{
2922 3182
 				if (substr($data['type'], 0, 6) == 'select' && !($data['rows'] > 1))
2923 3183
 				{
2924
-					if (!isset($content['#'.$name])) $content['#'.$name] = '';
2925
-					if(!isset($data['values'][''])) $sel_options['#'.$name][''] = lang('Select one');
3184
+					if (!isset($content['#'.$name]))
3185
+					{
3186
+						$content['#'.$name] = '';
3187
+					}
3188
+					if(!isset($data['values']['']))
3189
+					{
3190
+						$sel_options['#'.$name][''] = lang('Select one');
3191
+					}
2926 3192
 				}
2927 3193
 			}
2928 3194
 		}
@@ -2944,7 +3210,10 @@  discard block
 block discarded – undo
2944 3210
 		$content['no_tid'] = true;
2945 3211
 		$content['showsearchbuttons'] = true; // enable search operation and search buttons| they're disabled by default
2946 3212
 
2947
-		if ($this->config['private_cf_tab']) $content['no_private_cfs'] = 0;
3213
+		if ($this->config['private_cf_tab'])
3214
+		{
3215
+			$content['no_private_cfs'] = 0;
3216
+		}
2948 3217
 
2949 3218
 		$this->tmpl->read('addressbook.edit');
2950 3219
 		$this->tmpl->set_cell_attribute('change_org','disabled',true);
Please login to merge, or discard this patch.
admin/admin-cli.php 2 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -532,7 +532,6 @@
 block discarded – undo
532 532
 /**
533 533
  * Read the IMAP ACLs
534 534
  *
535
- * @param array $args admin-account[@domain],admin-password,accout_lid[,pw]
536 535
  * @return int 0 on success
537 536
  */
538 537
 function do_subscribe_other($account_lid,$pw=null)
Please login to merge, or discard this patch.
Braces   +37 added lines, -9 removed lines patch added patch discarded remove patch
@@ -17,10 +17,13 @@  discard block
 block discarded – undo
17 17
 
18 18
 chdir(dirname(__FILE__));	// to enable our relative pathes to work
19 19
 
20
-if (php_sapi_name() !== 'cli')	// security precaution: forbit calling admin-cli as web-page
20
+if (php_sapi_name() !== 'cli')
21
+{
22
+	// security precaution: forbit calling admin-cli as web-page
21 23
 {
22 24
 	die('<h1>admin-cli.php must NOT be called as web-page --> exiting !!!</h1>');
23 25
 }
26
+}
24 27
 elseif ($_SERVER['argc'] > 1)
25 28
 {
26 29
 	$arguments = $_SERVER['argv'];
@@ -87,13 +90,19 @@  discard block
 block discarded – undo
87 90
 			foreach($arg0s as $arg)
88 91
 			{
89 92
 				list($name,$value) = explode('=',$arg,2);
90
-				if(property_exists('admin_cmd',$name))		// dont allow to overwrite admin_cmd properties
93
+				if(property_exists('admin_cmd',$name))
94
+				{
95
+					// dont allow to overwrite admin_cmd properties
91 96
 				{
92 97
 					throw new Api\Exception\WrongUserinput(lang("Invalid argument '%1' !!!",$arg),90);
93 98
 				}
94
-				if (substr($name,-1) == ']')	// allow 1-dim. arrays
99
+				}
100
+				if (substr($name,-1) == ']')
101
+				{
102
+					// allow 1-dim. arrays
95 103
 				{
96 104
 					list($name,$sub) = explode('[',substr($name,0,-1),2);
105
+				}
97 106
 					$args[$name][$sub] = $value;
98 107
 				}
99 108
 				else
@@ -178,7 +187,10 @@  discard block
 block discarded – undo
178 187
 		if (!$dry_run)
179 188
 		{
180 189
 			$url = $GLOBALS['egw_info']['server']['webserver_url'].'/json.php?menuaction=admin.admin_hooks.ajax_clear_cache';
181
-			if ($url[0] == '/') $url = 'http://'.(!empty($domain) && $domain != 'default' ? $domain : 'localhost').$url;
190
+			if ($url[0] == '/')
191
+			{
192
+				$url = 'http://'.(!empty($domain) && $domain != 'default' ? $domain : 'localhost').$url;
193
+			}
182 194
 			$data = file_get_contents($url, false, Framework::proxy_context($user,$arg0s[1]));
183 195
 			error_log("file_get_contents('$url') returned ".array2string($data));
184 196
 			if ($data && strpos($data, '"success"') !== false)
@@ -220,10 +232,13 @@  discard block
 block discarded – undo
220 232
 		echo lang("Wrong admin-account or -password !!!")."\n\n";
221 233
 		usage('',1);
222 234
 	}
223
-	if (!$GLOBALS['egw_info']['user']['apps']['admin'])	// will be tested by the header too, but whould give html error-message
235
+	if (!$GLOBALS['egw_info']['user']['apps']['admin'])
236
+	{
237
+		// will be tested by the header too, but whould give html error-message
224 238
 	{
225 239
 		//fail(2,lang("Permission denied !!!"));
226 240
 		echo lang("Permission denied !!!")."\n\n";
241
+	}
227 242
 		usage('',2);
228 243
 	}
229 244
 	return $sessionid;
@@ -379,10 +394,13 @@  discard block
 block discarded – undo
379 394
 	try {
380 395
 		admin_cmd::parse_account($account,false);
381 396
 
382
-		foreach($data as &$value)	// existing account --> empty values mean dont change, not set them empty!
397
+		foreach($data as &$value)
398
+		{
399
+			// existing account --> empty values mean dont change, not set them empty!
383 400
 		{
384 401
 			if ((string)$value === '') $value = null;
385 402
 		}
403
+		}
386 404
 	}
387 405
 	catch (Exception $e) {	// new group
388 406
 		unset($e);	// not used
@@ -424,9 +442,12 @@  discard block
 block discarded – undo
424 442
 	if (($GLOBALS['egw_info']['server']['account_repository'] == 'ldap' ||
425 443
 		 empty($GLOBALS['egw_info']['server']['account_repository']) && $GLOBALS['egw_info']['server']['auth_type'] == 'ldap') &&
426 444
 		$GLOBALS['egw_info']['server']['ldap_extra_attributes'] && count($args) > 9 &&	// 9 = primary group
427
-		($last_arg = array_pop($dummy=$args)) && $last_arg[0] == '/')	// last argument start with a slash
445
+		($last_arg = array_pop($dummy=$args)) && $last_arg[0] == '/')
446
+	{
447
+		// last argument start with a slash
428 448
 	{
429 449
 		$data['loginshell'] = array_pop($args);
450
+	}
430 451
 		$data['homedirectory'] = array_pop($args);
431 452
 	}
432 453
 	$data += array(
@@ -444,10 +465,13 @@  discard block
 block discarded – undo
444 465
 	try {
445 466
 		admin_cmd::parse_account($account,true);
446 467
 
447
-		foreach($data as &$value)	// existing account --> empty values mean dont change, not set them empty!
468
+		foreach($data as &$value)
469
+		{
470
+			// existing account --> empty values mean dont change, not set them empty!
448 471
 		{
449 472
 			if ((string)$value === '') $value = null;
450 473
 		}
474
+		}
451 475
 	}
452 476
 	catch (Exception $e) {	// new account
453 477
 		unset($e);	// not used
@@ -488,7 +512,11 @@  discard block
 block discarded – undo
488 512
  */
489 513
 function do_change_account_id($args)
490 514
 {
491
-	if (count($args) < 4) usage();	// 4 means at least user,pw,from1,to1
515
+	if (count($args) < 4)
516
+	{
517
+		usage();
518
+	}
519
+	// 4 means at least user,pw,from1,to1
492 520
 
493 521
 	$ids2change = array();
494 522
 	for($n = 2; $n < count($args); $n += 2)
Please login to merge, or discard this patch.
admin/inc/class.admin_accesslog.inc.php 2 patches
Doc Comments   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -255,11 +255,10 @@
 block discarded – undo
255 255
 	 *
256 256
 	 * @param type $action
257 257
 	 * @param type $checked
258
-	 * @param type $use_all
259 258
 	 * @param type $success
260 259
 	 * @param int $failed
261 260
 	 * @param type $action_msg
262
-	 * @return type number of failed
261
+	 * @return boolean number of failed
263 262
 	 */
264 263
 	function action($action,$checked,&$success,&$failed,&$action_msg)
265 264
 	{
Please login to merge, or discard this patch.
Braces   +22 added lines, -7 removed lines patch added patch discarded remove patch
@@ -67,9 +67,13 @@  discard block
 block discarded – undo
67 67
 	{
68 68
 		$heartbeat_limit = Api\Session::heartbeat_limit();
69 69
 
70
-		if ($query['session_list'])	// filter active sessions
70
+		if ($query['session_list'])
71
+		{
72
+			// filter active sessions
71 73
 		{
72
-			$query['col_filter']['lo'] = null;	// not logged out
74
+			$query['col_filter']['lo'] = null;
75
+		}
76
+		// not logged out
73 77
 			$query['col_filter'][0] = 'session_dla > '.(int)(time() - $GLOBALS['egw_info']['server']['sessions_timeout']);
74 78
 			switch((string)$query['session_list'])
75 79
 			{
@@ -100,12 +104,16 @@  discard block
 block discarded – undo
100 104
 			{
101 105
 				$row['sessionstatus'] = $row['session_php'];
102 106
 			}
103
-			if ($row['lo']) {
107
+			if ($row['lo'])
108
+			{
104 109
 				$row['total'] = ($row['lo'] - $row['li']) / 60;
105 110
 				$row['sessionstatus'] = 'logged out';
106 111
 			}
107 112
 			// eg. for bad login or password
108
-			if (!$row['account_id']) $row['alt_loginid'] = ($row['loginid']?$row['loginid']:lang('none'));
113
+			if (!$row['account_id'])
114
+			{
115
+				$row['alt_loginid'] = ($row['loginid']?$row['loginid']:lang('none'));
116
+			}
109 117
 
110 118
 			// do not allow to kill or select own session
111 119
 			if ($GLOBALS['egw']->session->sessionid_access_log == $row['sessionid'] && $query['session_list'])
@@ -142,7 +150,10 @@  discard block
 block discarded – undo
142 150
 	function index(array $content=null, $msg='', $sessions_list=false)
143 151
 	{
144 152
 
145
-		if (is_array($content)) $sessions_list = $content['nm']['session_list'];
153
+		if (is_array($content))
154
+		{
155
+			$sessions_list = $content['nm']['session_list'];
156
+		}
146 157
 
147 158
 		// check if user has access to requested functionality
148 159
 		if ($GLOBALS['egw']->acl->check($sessions_list ? 'current_sessions' : 'access_log_acces',1,'admin'))
@@ -215,7 +226,8 @@  discard block
 block discarded – undo
215 226
 				$success = $failed = $action = $action_msg = null;
216 227
 				if ($this->action($content['nm']['action'],$content['nm']['selected']
217 228
 					,$success,$failed,$action_msg,$msg))
218
-				{ // In case of action success
229
+				{
230
+// In case of action success
219 231
 					switch ($action_msg)
220 232
 					{
221 233
 						case'deleted':
@@ -225,12 +237,15 @@  discard block
 block discarded – undo
225 237
 							$msg = lang('%1 sessions killed',$success);
226 238
 					}
227 239
 				}
228
-				elseif($failed) // In case of action failiure
240
+				elseif($failed)
241
+				{
242
+					// In case of action failiure
229 243
 				{
230 244
 					switch ($action_msg)
231 245
 					{
232 246
 						case'deleted':
233 247
 							$msg = lang('Error deleting log entry!');
248
+				}
234 249
 							break;
235 250
 						case'killed':
236 251
 							$msg = lang('Permission denied!');
Please login to merge, or discard this patch.
admin/inc/class.admin_categories.inc.php 2 patches
Doc Comments   +2 added lines patch added patch discarded remove patch
@@ -679,6 +679,8 @@
 block discarded – undo
679 679
 	 * @param int &$failed number of failed actions (not enought permissions)
680 680
 	 * @param string &$action_msg translated verb for the actions, to be used in a message like '%1 entries deleted'
681 681
 	 * @param array $query get_rows parameter
682
+	 * @param integer $success
683
+	 * @param integer $failed
682 684
 	 * @return boolean true if all actions succeded, false otherwise
683 685
 	 */
684 686
 	function action($_action, $checked, $use_all, &$success, &$failed, &$action_msg, array $query)
Please login to merge, or discard this patch.
Braces   +64 added lines, -17 removed lines patch added patch discarded remove patch
@@ -150,8 +150,14 @@  discard block
 block discarded – undo
150 150
 			{
151 151
 				case 'save':
152 152
 				case 'apply':
153
-					if(is_array($content['owner'])) $content['owner'] = implode(',',$content['owner']);
154
-					if($content['owner'] == '') $content['owner'] = 0;
153
+					if(is_array($content['owner']))
154
+					{
155
+						$content['owner'] = implode(',',$content['owner']);
156
+					}
157
+					if($content['owner'] == '')
158
+					{
159
+						$content['owner'] = 0;
160
+					}
155 161
 					if ($content['id'] && self::$acl_edit)
156 162
 					{
157 163
 
@@ -247,7 +253,10 @@  discard block
 block discarded – undo
247 253
 			Framework::refresh_opener($msg, $refresh_app, $content['id'], $change_color ? null : 'update', $this->appname);
248 254
 		}
249 255
 		$content['msg'] = $msg;
250
-		if(!$content['appname']) $content['appname'] = $appname;
256
+		if(!$content['appname'])
257
+		{
258
+			$content['appname'] = $appname;
259
+		}
251 260
 		if($content['data']['icon'])
252 261
 		{
253 262
 			$content['icon_url'] = $content['base_url'] . $content['data']['icon'];
@@ -302,7 +311,9 @@  discard block
 block discarded – undo
302 311
 			// Allow admins access to all categories as parent
303 312
 			$content['all_cats'] = 'all_no_acl';
304 313
 			$readonlys['owner'] = false;
305
-		} else {
314
+		}
315
+		else
316
+		{
306 317
 			$readonlys['owner'] = true;
307 318
 			$readonlys['access'] = $content['owner'] != $GLOBALS['egw_info']['user']['account_id'];
308 319
 		}
@@ -313,7 +324,10 @@  discard block
 block discarded – undo
313 324
 			$appname != $content['appname'] || // Can't edit a category from a different app
314 325
 			 ($this->appname != 'admin' && $content['owner'] != $GLOBALS['egw_info']['user']['account_id']);
315 326
 		// Make sure $content['owner'] is an array otherwise it wont show up values in the multiselectbox
316
-		if (!is_array($content['owner'])) $content['owner'] = explode(',',$content['owner']);
327
+		if (!is_array($content['owner']))
328
+		{
329
+			$content['owner'] = explode(',',$content['owner']);
330
+		}
317 331
 		$tmpl = new Etemplate('admin.categories.edit');
318 332
 		$tmpl->exec($this->edit_link,$content,$sel_options,$readonlys,$content+array(
319 333
 			'old_parent' => $content['old_parent'] ? $content['old_parent'] : $content['parent'], 'appname' => $appname
@@ -373,9 +387,15 @@  discard block
 block discarded – undo
373 387
 		{
374 388
 			$globalcat = false;
375 389
 		}
376
-		if ($globalcat && $query['filter']) $filter['access'] = 'public';
390
+		if ($globalcat && $query['filter'])
391
+		{
392
+			$filter['access'] = 'public';
393
+		}
377 394
 		// new column-filter access has highest priority
378
-		if (!empty($query['col_filter']['access']))$filter['access'] = $query['col_filter']['access'];
395
+		if (!empty($query['col_filter']['access']))
396
+		{
397
+			$filter['access'] = $query['col_filter']['access'];
398
+		}
379 399
 
380 400
 		Api\Cache::setSession(__CLASS__.$query['appname'],'nm',$query);
381 401
 
@@ -404,7 +424,10 @@  discard block
 block discarded – undo
404 424
 
405 425
 			$row['level_spacer'] = str_repeat('&nbsp; &nbsp; ',$row['level']);
406 426
 
407
-			if ($row['data']['icon']) $row['icon_url'] = self::icon_url($row['data']['icon']);
427
+			if ($row['data']['icon'])
428
+			{
429
+				$row['icon_url'] = self::icon_url($row['data']['icon']);
430
+			}
408 431
 
409 432
 			$row['subs'] = count($row['children']);
410 433
 
@@ -435,13 +458,19 @@  discard block
 block discarded – undo
435 458
 			$readonlys['nm']["add[$row[id]]"]    = !self::$acl_add_sub;
436 459
 			$readonlys['nm']["delete[$row[id]]"] = !self::$acl_delete;
437 460
 		}
438
-		if (true) $rows = $count <= $query['num_rows'] ? array_values($rows) : array_slice($rows, $query['start'], $query['num_rows']);
461
+		if (true)
462
+		{
463
+			$rows = $count <= $query['num_rows'] ? array_values($rows) : array_slice($rows, $query['start'], $query['num_rows']);
464
+		}
439 465
 		// make appname available for actions
440 466
 		$rows['appname'] = $query['appname'];
441 467
 		$rows['edit_link'] = $this->edit_link;
442 468
 
443 469
 		// disable access column for global Categories
444
-		if ($GLOBALS['egw_info']['flags']['currentapp'] == 'admin') $rows['no_access'] = true;
470
+		if ($GLOBALS['egw_info']['flags']['currentapp'] == 'admin')
471
+		{
472
+			$rows['no_access'] = true;
473
+		}
445 474
 
446 475
 		$GLOBALS['egw_info']['flags']['app_header'] = lang($this->appname).' - '.lang('categories').
447 476
 			($query['appname'] != Categories::GLOBAL_APPNAME ? ': '.lang($query['appname']) : '');
@@ -458,11 +487,18 @@  discard block
 block discarded – undo
458 487
 	public function index(array $content=null,$msg='')
459 488
 	{
460 489
 		//_debug_array($_GET);
461
-		if ($this->appname != 'admin') Api\Translation::add_app('admin');	// need admin translations
490
+		if ($this->appname != 'admin')
491
+		{
492
+			Api\Translation::add_app('admin');
493
+		}
494
+		// need admin translations
462 495
 
463 496
 		if(!isset($content))
464 497
 		{
465
-			if (isset($_GET['msg'])) $msg = $_GET['msg'];
498
+			if (isset($_GET['msg']))
499
+			{
500
+				$msg = $_GET['msg'];
501
+			}
466 502
 
467 503
 			$appname = Categories::GLOBAL_APPNAME;
468 504
 			foreach(array($content['nm']['appname'], $_GET['cats_app'], $_GET['appname']) as $field)
@@ -602,7 +638,8 @@  discard block
 block discarded – undo
602 638
 			$readonlys['nm']['rows']['owner'] = true;
603 639
 			$readonlys['nm']['col_filter']['owner'] = true;
604 640
 		}
605
-		if($appname == Categories::GLOBAL_APPNAME) {
641
+		if($appname == Categories::GLOBAL_APPNAME)
642
+		{
606 643
 			$sel_options['app'] = array(''=>'');
607 644
 			$readonlys['nm']['rows']['app'] = true;
608 645
 		}
@@ -617,7 +654,8 @@  discard block
 block discarded – undo
617 654
 		));
618 655
 	}
619 656
 
620
-	protected function get_actions($appname=categories::GLOBAL_APPNAME) {
657
+	protected function get_actions($appname=categories::GLOBAL_APPNAME)
658
+	{
621 659
 
622 660
 		$actions = array(
623 661
 			'open' => array(        // does edit if allowed, otherwise view
@@ -728,11 +766,17 @@  discard block
 block discarded – undo
728 766
 				list($add_remove, $ids_csv) = explode('_', $settings, 2);
729 767
 				$ids = explode(',', $ids_csv);
730 768
 				// Adding 'All users' removes all the others
731
-				if($add_remove == 'add' && array_search(Categories::GLOBAL_ACCOUNT,$ids) !== false) $ids = array(Categories::GLOBAL_ACCOUNT);
769
+				if($add_remove == 'add' && array_search(Categories::GLOBAL_ACCOUNT,$ids) !== false)
770
+				{
771
+					$ids = array(Categories::GLOBAL_ACCOUNT);
772
+				}
732 773
 
733 774
 				foreach($checked as $id)
734 775
 				{
735
-					if (!$data = $cats->read($id)) continue;
776
+					if (!$data = $cats->read($id))
777
+					{
778
+						continue;
779
+					}
736 780
 					$data['owner'] = explode(',',$data['owner']);
737 781
 					if(array_search(Categories::GLOBAL_ACCOUNT,$data['owner']) !== false || $data['owner'][0] > 0)
738 782
 					{
@@ -772,7 +816,10 @@  discard block
 block discarded – undo
772 816
 				continue;
773 817
 			}
774 818
 			// Skip apps that don't show in the app bar, they [usually] don't have Categories
775
-			if($data['status'] > 1 || in_array($app, array('home','admin','felamimail','sitemgr','sitemgr-link'))) continue;
819
+			if($data['status'] > 1 || in_array($app, array('home','admin','felamimail','sitemgr','sitemgr-link')))
820
+			{
821
+				continue;
822
+			}
776 823
 			if ($GLOBALS['egw_info']['user']['apps'][$app])
777 824
 			{
778 825
 				$apps[$app] = $data['title'] ? $data['title'] : lang($app);
Please login to merge, or discard this patch.
admin/inc/class.admin_cmd.inc.php 2 patches
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -443,10 +443,10 @@  discard block
 block discarded – undo
443 443
 	 *
444 444
 	 * @static
445 445
 	 * @param array|string $criteria array of key and data cols, OR a SQL query (content for WHERE), fully quoted (!)
446
-	 * @param boolean|string|array $only_keys =true True returns only keys, False returns all cols. or
446
+	 * @param boolean $only_keys =true True returns only keys, False returns all cols. or
447 447
 	 *	comma seperated list or array of columns to return
448 448
 	 * @param string $order_by ='' fieldnames + {ASC|DESC} separated by colons ',', can also contain a GROUP BY (if it contains ORDER BY)
449
-	 * @param string|array $extra_cols ='' string or array of strings to be added to the SELECT, eg. "count(*) as num"
449
+	 * @param string $extra_cols ='' string or array of strings to be added to the SELECT, eg. "count(*) as num"
450 450
 	 * @param string $wildcard ='' appended befor and after each criteria
451 451
 	 * @param boolean $empty =false False=empty criteria are ignored in query, True=empty have to be empty in row
452 452
 	 * @param string $op ='AND' defaults to 'AND', can be set to 'OR' too, then criteria's are OR'ed together
@@ -696,7 +696,7 @@  discard block
 block discarded – undo
696 696
 	 *
697 697
 	 * @param string|boolean|int $value
698 698
 	 * @param boolean $default =null
699
-	 * @return boolean
699
+	 * @return boolean|null
700 700
 	 * @throws Api\Exception\WrongUserinput(lang('Invalid value "%1" use yes or no!',$value),998);
701 701
 	 */
702 702
 	static function parse_boolean($value,$default=null)
@@ -925,7 +925,7 @@  discard block
 block discarded – undo
925 925
 	 * Read data of a remote instance
926 926
 	 *
927 927
 	 * @param array|int $keys
928
-	 * @return array
928
+	 * @return string
929 929
 	 */
930 930
 	static function read_remote($keys)
931 931
 	{
@@ -1005,7 +1005,7 @@  discard block
 block discarded – undo
1005 1005
 	 * Check if string is a md5 hash (32 chars of 0-9 or a-f)
1006 1006
 	 *
1007 1007
 	 * @param string $str
1008
-	 * @return boolean
1008
+	 * @return integer
1009 1009
 	 */
1010 1010
 	static function is_md5($str)
1011 1011
 	{
Please login to merge, or discard this patch.
Braces   +53 added lines, -13 removed lines patch added patch discarded remove patch
@@ -183,7 +183,10 @@  discard block
 block discarded – undo
183 183
 				{
184 184
 					$ret = $this->remote_exec($dry_run);
185 185
 				}
186
-				if (is_null($this->status)) $this->status = admin_cmd::successful;
186
+				if (is_null($this->status))
187
+				{
188
+					$this->status = admin_cmd::successful;
189
+				}
187 190
 			}
188 191
 			catch (Exception $e) {
189 192
 				$this->error = $e->getMessage();
@@ -277,7 +280,10 @@  discard block
 block discarded – undo
277 280
 	 */
278 281
 	function delete()
279 282
 	{
280
-		if ($this->status != admin_cmd::scheduled) return false;
283
+		if ($this->status != admin_cmd::scheduled)
284
+		{
285
+			return false;
286
+		}
281 287
 
282 288
 		$this->status = admin_cmd::deleted;
283 289
 
@@ -303,7 +309,10 @@  discard block
 block discarded – undo
303 309
 		{
304 310
 			$this->modified = time();
305 311
 			$this->modifier = $set_modifier ? $GLOBALS['egw_info']['user']['account_id'] : 0;
306
-			if ($set_modifier) $this->modifier_email = admin_cmd::user_email();
312
+			if ($set_modifier)
313
+			{
314
+				$this->modifier_email = admin_cmd::user_email();
315
+			}
307 316
 		}
308 317
 		if (version_compare(PHP_VERSION,'5.1.2','>'))
309 318
 		{
@@ -411,10 +420,13 @@  discard block
 block discarded – undo
411 420
 		}
412 421
 		$cmd = new $class($data);
413 422
 
414
-		if ($cmd instanceof admin_cmd)	// dont allow others classes to be executed that way!
423
+		if ($cmd instanceof admin_cmd)
424
+		{
425
+			// dont allow others classes to be executed that way!
415 426
 		{
416 427
 			return $cmd;
417 428
 		}
429
+		}
418 430
 		throw new Api\Exception\WrongParameter(lang('%1 is no command!',$class),0);
419 431
 	}
420 432
 
@@ -564,7 +576,10 @@  discard block
 block discarded – undo
564 576
 			}
565 577
 		}
566 578
 		unset($vars['data']);
567
-		if ($this->data) $vars = array_merge($this->data,$vars);
579
+		if ($this->data)
580
+		{
581
+			$vars = array_merge($this->data,$vars);
582
+		}
568 583
 
569 584
 		return $vars;
570 585
 	}
@@ -583,10 +598,13 @@  discard block
 block discarded – undo
583 598
 			admin_cmd::_instanciate_acl($this->creator);
584 599
 			// todo: check only if and with $this->creator
585 600
 			if (!admin_cmd::$acl->check('run',1,'admin') &&		// creator is no longer admin
586
-				$extra_acl && $extra_deny && admin_cmd::$acl->check($extra_acl,$extra_deny,'admin'))	// creator is explicitly forbidden to do something
601
+				$extra_acl && $extra_deny && admin_cmd::$acl->check($extra_acl,$extra_deny,'admin'))
602
+			{
603
+				// creator is explicitly forbidden to do something
587 604
 			{
588 605
 				throw new Api\Exception\NoPermission\Admin();
589 606
 			}
607
+			}
590 608
 		}
591 609
 	}
592 610
 
@@ -603,11 +621,14 @@  discard block
 block discarded – undo
603 621
 		{
604 622
 			if (!isset($GLOBALS['egw_info']['apps'][$name]))
605 623
 			{
606
-				foreach($GLOBALS['egw_info']['apps'] as $app => $data)	// check against title and localised name
624
+				foreach($GLOBALS['egw_info']['apps'] as $app => $data)
625
+				{
626
+					// check against title and localised name
607 627
 				{
608 628
 					if (!strcasecmp($name,$data['title']) || !strcasecmp($name,lang($app)))
609 629
 					{
610 630
 						$apps[$key] = $name = $app;
631
+				}
611 632
 						break;
612 633
 					}
613 634
 				}
@@ -642,7 +663,11 @@  discard block
 block discarded – undo
642 663
 		{
643 664
 			throw new Api\Exception\WrongUserinput(lang("Wrong account type: %1 is NO %2 !!!",$account,$allow_only_user?lang('user'):lang('group')),15);
644 665
 		}
645
-		if ($type == 2 && $id > 0) $id = -$id;	// groups use negative id's internally, fix it, if user given the wrong sign
666
+		if ($type == 2 && $id > 0)
667
+		{
668
+			$id = -$id;
669
+		}
670
+		// groups use negative id's internally, fix it, if user given the wrong sign
646 671
 
647 672
 		return $id;
648 673
 	}
@@ -658,7 +683,10 @@  discard block
 block discarded – undo
658 683
 	 */
659 684
 	static function parse_accounts($accounts,$allow_only_user=null)
660 685
 	{
661
-		if (!$accounts) return null;
686
+		if (!$accounts)
687
+		{
688
+			return null;
689
+		}
662 690
 
663 691
 		$ids = array();
664 692
 		foreach(is_array($accounts) ? $accounts : explode(',',$accounts) as $account)
@@ -677,9 +705,12 @@  discard block
 block discarded – undo
677 705
 	 */
678 706
 	static function parse_date($date)
679 707
 	{
680
-		if (!is_numeric($date))	// we allow to input a timestamp
708
+		if (!is_numeric($date))
709
+		{
710
+			// we allow to input a timestamp
681 711
 		{
682 712
 			$datein = $date;
713
+		}
683 714
 			// convert german DD.MM.YYYY format into ISO YYYY-MM-DD format
684 715
 			$date = preg_replace('/^([0-9]{1,2})\.([0-9]{1,2})\.([0-9]{4})$/','\3-\2-\1',$date);
685 716
 
@@ -837,10 +868,13 @@  discard block
 block discarded – undo
837 868
 			return false;		// no schduled command, no need to setup the job
838 869
 		}
839 870
 		$next = $jobs[0];
840
-		if (($time = $next['scheduled']) < time())	// should run immediatly
871
+		if (($time = $next['scheduled']) < time())
872
+		{
873
+			// should run immediatly
841 874
 		{
842 875
 			return admin_cmd::run_queued_jobs();
843 876
 		}
877
+		}
844 878
 		$async = new Api\Asyncservice();
845 879
 
846 880
 		// we cant use this class as callback, as it's abstract and ExecMethod used by the async service instanciated the class!
@@ -944,10 +978,13 @@  discard block
 block discarded – undo
944 978
 	{
945 979
 		admin_cmd::_instanciate_remote();
946 980
 
947
-		if ($data['install_id'] && $data['config_passwd'])	// calculate hash
981
+		if ($data['install_id'] && $data['config_passwd'])
982
+		{
983
+			// calculate hash
948 984
 		{
949 985
 			$data['remote_hash'] = self::remote_hash($data['install_id'],$data['config_passwd']);
950 986
 		}
987
+		}
951 988
 		elseif (!$data['remote_hash'] && !($data['install_id'] && $data['config_passwd']))
952 989
 		{
953 990
 			throw new Api\Exception\WrongUserinput(lang('Either Install ID AND Api\Config password needed OR the remote hash!'));
@@ -981,7 +1018,10 @@  discard block
 block discarded – undo
981 1018
 		{
982 1019
 			throw new Api\Exception\WrongParameter(empty($config_passwd)?'Empty Api\Config password':'install_id no md5 hash');
983 1020
 		}
984
-		if (!self::is_md5($config_passwd)) $config_passwd = md5($config_passwd);
1021
+		if (!self::is_md5($config_passwd))
1022
+		{
1023
+			$config_passwd = md5($config_passwd);
1024
+		}
985 1025
 
986 1026
 		return md5($config_passwd.$install_id);
987 1027
 	}
Please login to merge, or discard this patch.