Completed
Push — 16.1 ( bfb9cb...1e4888 )
by Ralf
12:48
created
addressbook/inc/class.addressbook_ui.inc.php 2 patches
Spacing   +411 added lines, -417 removed lines patch added patch discarded remove patch
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 	 *
80 80
 	 * @param string $contact_app
81 81
 	 */
82
-	function __construct($contact_app='addressbook')
82
+	function __construct($contact_app = 'addressbook')
83 83
 	{
84 84
 		parent::__construct($contact_app);
85 85
 
@@ -92,23 +92,23 @@  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')) Api\Hooks::read(true);
96 96
 
97
-		$this->config =& $GLOBALS['egw_info']['server'];
97
+		$this->config = & $GLOBALS['egw_info']['server'];
98 98
 
99 99
 		// check if a contact specific export limit is set, if yes use it also for etemplate's csv export
100
-		$this->config['export_limit'] = $this->config['contact_export_limit'] = Api\Storage\Merge::getExportLimit($app='addressbook');
100
+		$this->config['export_limit'] = $this->config['contact_export_limit'] = Api\Storage\Merge::getExportLimit($app = 'addressbook');
101 101
 
102 102
 		if ($this->config['copy_fields'] && ($fields = is_array($this->config['copy_fields']) ?
103 103
 			$this->config['copy_fields'] : unserialize($this->config['copy_fields'])))
104 104
 		{
105 105
 			// Set country code if country name is selected
106
-			$supported_fields = $this->get_fields('supported',null,0);
107
-			if(in_array('adr_one_countrycode', $supported_fields) && in_array('adr_one_countryname',$fields))
106
+			$supported_fields = $this->get_fields('supported', null, 0);
107
+			if (in_array('adr_one_countrycode', $supported_fields) && in_array('adr_one_countryname', $fields))
108 108
 			{
109 109
 				$fields[] = 'adr_one_countrycode';
110 110
 			}
111
-			if(in_array('adr_two_countrycode', $supported_fields) && in_array('adr_two_countryname',$fields))
111
+			if (in_array('adr_two_countrycode', $supported_fields) && in_array('adr_two_countryname', $fields))
112 112
 			{
113 113
 				$fields[] = 'adr_two_countrycode';
114 114
 			}
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 	 * @param string $msg =null	message to show
125 125
 	 * @param boolean $do_email =false do an email-selection popup or the regular index-page
126 126
 	 */
127
-	function index($_content=null,$msg=null,$do_email=false)
127
+	function index($_content = null, $msg = null, $do_email = false)
128 128
 	{
129 129
 		//echo "<p>uicontacts::index(".print_r($_content,true).",'$msg')</p>\n";
130 130
 		if (($re_submit = is_array($_content)))
@@ -156,16 +156,16 @@  discard block
 block discarded – undo
156 156
 				else
157 157
 				{
158 158
 					$success = $failed = $action_msg = null;
159
-					if ($this->action($_content['nm']['action'],$_content['nm']['selected'],$_content['nm']['select_all'],
160
-						$success,$failed,$action_msg,$_content['do_email'] ? 'email' : 'index',$msg,$_content['nm']['checkboxes']))
159
+					if ($this->action($_content['nm']['action'], $_content['nm']['selected'], $_content['nm']['select_all'],
160
+						$success, $failed, $action_msg, $_content['do_email'] ? 'email' : 'index', $msg, $_content['nm']['checkboxes']))
161 161
 					{
162
-						$msg .= lang('%1 contact(s) %2',$success,$action_msg);
162
+						$msg .= lang('%1 contact(s) %2', $success, $action_msg);
163 163
 						Framework::message($msg);
164 164
 					}
165
-					elseif(is_null($msg))
165
+					elseif (is_null($msg))
166 166
 					{
167
-						$msg .= lang('%1 contact(s) %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed);
168
-						Framework::message($msg,'error');
167
+						$msg .= lang('%1 contact(s) %2, %3 failed because of insufficent rights !!!', $success, $action_msg, $failed);
168
+						Framework::message($msg, 'error');
169 169
 					}
170 170
 					$msg = '';
171 171
 				}
@@ -185,9 +185,9 @@  discard block
 block discarded – undo
185 185
 			}
186 186
 			$typeselection = $_content['nm']['col_filter']['tid'];
187 187
 		}
188
-		elseif($_GET['add_list'])
188
+		elseif ($_GET['add_list'])
189 189
 		{
190
-			$list = $this->add_list($_GET['add_list'],$_GET['owner']?$_GET['owner']:$this->user);
190
+			$list = $this->add_list($_GET['add_list'], $_GET['owner'] ? $_GET['owner'] : $this->user);
191 191
 			if ($list === true)
192 192
 			{
193 193
 				$msg = lang('List already exists!');
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 		);
207 207
 		$to = $_content['nm']['to'];
208 208
 		$content = array();
209
-		if($msg || $_GET['msg'])
209
+		if ($msg || $_GET['msg'])
210 210
 		{
211 211
 			Framework::message($msg ? $msg : $_GET['msg']);
212 212
 		}
@@ -215,23 +215,23 @@  discard block
 block discarded – undo
215 215
 		if (!is_array($content['nm']))
216 216
 		{
217 217
 			$content['nm'] = array(
218
-				'get_rows'       =>	'addressbook.addressbook_ui.get_rows',	// I  method/callback to request the data for the rows eg. 'notes.bo.get_rows'
219
-				'bottom_too'     => false,		// I  show the nextmatch-line (arrows, filters, search, ...) again after the rows
220
-				'never_hide'     => True,		// I  never hide the nextmatch-line if less then maxmatch entrie
221
-				'start'          =>	0,			// IO position in list
222
-				'cat_id'         =>	'',			// IO category, if not 'no_cat' => True
223
-				'search'         =>	'',			// IO search pattern
224
-				'order'          =>	'n_family',	// IO name of the column to sort after (optional for the sortheaders)
225
-				'sort'           =>	'ASC',		// IO direction of the sort: 'ASC' or 'DESC'
226
-				'col_filter'     =>	array(),	// IO array of column-name value pairs (optional for the filterheaders)
218
+				'get_rows'       =>	'addressbook.addressbook_ui.get_rows', // I  method/callback to request the data for the rows eg. 'notes.bo.get_rows'
219
+				'bottom_too'     => false, // I  show the nextmatch-line (arrows, filters, search, ...) again after the rows
220
+				'never_hide'     => True, // I  never hide the nextmatch-line if less then maxmatch entrie
221
+				'start'          =>	0, // IO position in list
222
+				'cat_id'         =>	'', // IO category, if not 'no_cat' => True
223
+				'search'         =>	'', // IO search pattern
224
+				'order'          =>	'n_family', // IO name of the column to sort after (optional for the sortheaders)
225
+				'sort'           =>	'ASC', // IO direction of the sort: 'ASC' or 'DESC'
226
+				'col_filter'     =>	array(), // IO array of column-name value pairs (optional for the filterheaders)
227 227
 				//'cat_id_label' => lang('Categories'),
228 228
 				//'filter_label' => lang('Addressbook'),	// I  label for filter    (optional)
229
-				'filter'         =>	'',	// =All	// IO filter, if not 'no_filter' => True
230
-				'filter_no_lang' => True,		// I  set no_lang for filter (=dont translate the options)
231
-				'no_filter2'     => True,		// I  disable the 2. filter (params are the same as for filter)
229
+				'filter'         =>	'', // =All	// IO filter, if not 'no_filter' => True
230
+				'filter_no_lang' => True, // I  set no_lang for filter (=dont translate the options)
231
+				'no_filter2'     => True, // I  disable the 2. filter (params are the same as for filter)
232 232
 				//'filter2_label'=>	lang('Distribution lists'),			// IO filter2, if not 'no_filter2' => True
233
-				'filter2'        =>	'',			// IO filter2, if not 'no_filter2' => True
234
-				'filter2_no_lang'=> True,		// I  set no_lang for filter2 (=dont translate the options)
233
+				'filter2'        =>	'', // IO filter2, if not 'no_filter2' => True
234
+				'filter2_no_lang'=> True, // I  set no_lang for filter2 (=dont translate the options)
235 235
 				'lettersearch'   => true,
236 236
 				'do_email'       => $do_email ? 1 : 0,
237 237
 				// using a positiv list now, as we constantly adding new columns in addressbook, but not removing them from default
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 				/* old negative list
242 242
 				'default_cols'   => '!cat_id,contact_created_contact_modified,distribution_list,contact_id,owner,room',*/
243 243
 				'filter2_onchange' => "return app.addressbook.filter2_onchange();",
244
-				'manual'         => $do_email ? ' ' : false,	// space for the manual icon
244
+				'manual'         => $do_email ? ' ' : false, // space for the manual icon
245 245
 				//'actions'        => $this->get_actions(),		// set on each request, as it depends on some filters
246 246
 				'row_id'         => 'id',
247 247
 				'row_modified'   => 'modified',
@@ -258,13 +258,13 @@  discard block
 block discarded – undo
258 258
 			// use the state of the last session stored in the user prefs
259 259
 			if (($state = @unserialize($this->prefs[$do_email ? 'email_state' : 'index_state'])))
260 260
 			{
261
-				$content['nm'] = array_merge($content['nm'],$state);
261
+				$content['nm'] = array_merge($content['nm'], $state);
262 262
 			}
263 263
 		}
264 264
 		$sel_options['cat_id'] = array('' => lang('All categories'), '0' => lang('None'));
265 265
 
266 266
 		// Edit and delete list actions depends on permissions
267
-		if($this->get_lists(Acl::EDIT))
267
+		if ($this->get_lists(Acl::EDIT))
268 268
 		{
269 269
 			$content['nm']['placeholder_actions'][] = 'rename_list';
270 270
 			$content['nm']['placeholder_actions'][] = 'delete_list';
@@ -277,11 +277,11 @@  discard block
 block discarded – undo
277 277
 		if (isset($typeselection)) $content['nm']['col_filter']['tid'] = $typeselection;
278 278
 		// save the tid for use in creating new addressbook entrys via UI. Current tid is to be used as type of new entrys
279 279
 		//error_log(__METHOD__.__LINE__.' '.$content['nm']['col_filter']['tid']);
280
-		Api\Cache::setSession('addressbook','active_tid',$content['nm']['col_filter']['tid']);
280
+		Api\Cache::setSession('addressbook', 'active_tid', $content['nm']['col_filter']['tid']);
281 281
 		if ($this->lists_available())
282 282
 		{
283
-			$sel_options['filter2'] = $this->get_lists(Acl::READ,array('' => lang('No distribution list')));
284
-			$sel_options['filter2']['add'] = lang('Add a new list').'...';	// put it at the end
283
+			$sel_options['filter2'] = $this->get_lists(Acl::READ, array('' => lang('No distribution list')));
284
+			$sel_options['filter2']['add'] = lang('Add a new list').'...'; // put it at the end
285 285
 		}
286 286
 		if ($do_email)
287 287
 		{
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 			$content['nm']['header_left'] = 'addressbook.email.left';
300 300
 		}
301 301
 		// Organisation stuff is not (yet) availible with ldap
302
-		elseif($GLOBALS['egw_info']['server']['contact_repository'] != 'ldap')
302
+		elseif ($GLOBALS['egw_info']['server']['contact_repository'] != 'ldap')
303 303
 		{
304 304
 			$content['nm']['header_left'] = 'addressbook.index.left';
305 305
 		}
@@ -312,12 +312,12 @@  discard block
 block discarded – undo
312 312
 		$sel_options['adr_one_countrycode']['-custom-'] = lang('No country selected');
313 313
 
314 314
 		// 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'];
315
+		if (isset($this->config['contact_export_limit']) && (int)$this->config['contact_export_limit']) $content['nm']['export_limit'] = $this->config['contact_export_limit'];
316 316
 
317 317
 		// dont show tid-selection if we have only one content_type
318 318
 		// be a bit more sophisticated about it
319 319
 		$availabletypes = array_keys($this->content_types);
320
-		if ($content['nm']['col_filter']['tid'] && !in_array($content['nm']['col_filter']['tid'],$availabletypes))
320
+		if ($content['nm']['col_filter']['tid'] && !in_array($content['nm']['col_filter']['tid'], $availabletypes))
321 321
 		{
322 322
 			//_debug_array(array('Typefilter:'=> $content['nm']['col_filter']['tid'],'Available Types:'=>$availabletypes,'action:'=>'remove invalid filter'));
323 323
 			unset($content['nm']['col_filter']['tid']);
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
 		if (!isset($content['nm']['col_filter']['tid'])) $content['nm']['col_filter']['tid'] = $availabletypes[0];
326 326
 		if (count($this->content_types) > 1)
327 327
 		{
328
-			foreach($this->content_types as $tid => $data)
328
+			foreach ($this->content_types as $tid => $data)
329 329
 			{
330 330
 				$sel_options['tid'][$tid] = $data['name'];
331 331
 			}
@@ -343,22 +343,22 @@  discard block
 block discarded – undo
343 343
 
344 344
 		$content['nm']['actions'] = $this->get_actions($content['nm']['col_filter']['tid'], $content['nm']['org_view']);
345 345
 
346
-		if (!isset($sel_options['org_view'][(string) $content['nm']['org_view']]))
346
+		if (!isset($sel_options['org_view'][(string)$content['nm']['org_view']]))
347 347
 		{
348 348
 			$sel_options['org_view'] += $this->_get_org_name((string)$content['nm']['org_view']);
349 349
 		}
350 350
 		// unset the filters regarding organisations, when there is no organisation selected
351
-		if (empty($sel_options['org_view'][(string) $content['nm']['org_view']]) || stripos($org_view,":") === false )
351
+		if (empty($sel_options['org_view'][(string)$content['nm']['org_view']]) || stripos($org_view, ":") === false)
352 352
 		{
353 353
 			unset($content['nm']['col_filter']['org_name']);
354 354
 			unset($content['nm']['col_filter']['org_unit']);
355 355
 			unset($content['nm']['col_filter']['adr_one_locality']);
356 356
 		}
357
-		$content['nm']['org_view_label'] = $sel_options['org_view'][(string) $content['nm']['org_view']];
357
+		$content['nm']['org_view_label'] = $sel_options['org_view'][(string)$content['nm']['org_view']];
358 358
 
359 359
 		$this->tmpl->read($do_email ? 'addressbook.email' : 'addressbook.index');
360 360
 		return $this->tmpl->exec($do_email ? 'addressbook.addressbook_ui.emailpopup' : 'addressbook.addressbook_ui.index',
361
-			$content,$sel_options,array(),$preserv,$do_email ? 2 : 0);
361
+			$content, $sel_options, array(), $preserv, $do_email ? 2 : 0);
362 362
 	}
363 363
 
364 364
 	/**
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
 	 * @param string $tid_filter =null
368 368
 	 * @return array see Etemplate\Widget\Nextmatch::get_actions()
369 369
 	 */
370
-	public function get_actions($tid_filter=null)
370
+	public function get_actions($tid_filter = null)
371 371
 	{
372 372
 		// Contact view
373 373
 		$actions = array(
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
 				'caption' => 'CRM-View',
376 376
 				'default' => $GLOBALS['egw_info']['user']['preferences']['addressbook']['crm_list'] != '~edit~',
377 377
 				'allowOnMultiple' => false,
378
-				'group' => $group=1,
378
+				'group' => $group = 1,
379 379
 				'onExecute' => 'javaScript:app.addressbook.view',
380 380
 				'disableClass' => 'contact_organisation',
381 381
 				'hideOnDisabled' => true,
@@ -418,14 +418,14 @@  discard block
 block discarded – undo
418 418
 		);
419 419
 		// CRM view options
420 420
 		$crm_count = 0;
421
-		$crm_apps = array('infolog','tracker');
422
-		foreach($crm_apps as $app)
421
+		$crm_apps = array('infolog', 'tracker');
422
+		foreach ($crm_apps as $app)
423 423
 		{
424 424
 			if ($GLOBALS['egw_info']['user']['apps'][$app]) $crm_count++;
425 425
 		}
426
-		if($crm_count > 1)
426
+		if ($crm_count > 1)
427 427
 		{
428
-			foreach($crm_apps as $app)
428
+			foreach ($crm_apps as $app)
429 429
 			{
430 430
 				$actions['view']['children']["view-$app"] = array(
431 431
 					'caption' => $app,
@@ -440,7 +440,7 @@  discard block
 block discarded – undo
440 440
 				'caption' => 'View',
441 441
 				'default' => true,
442 442
 				'allowOnMultiple' => false,
443
-				'group' => $group=1,
443
+				'group' => $group = 1,
444 444
 				'disableClass' => 'contact_contact',
445 445
 				'hideOnDisabled' => true
446 446
 			),
@@ -455,23 +455,23 @@  discard block
 block discarded – undo
455 455
 			),
456 456
 		);
457 457
 
458
-		++$group;	// other AB related stuff group: lists, AB's, categories
458
+		++$group; // other AB related stuff group: lists, AB's, categories
459 459
 		// categories submenu
460 460
 		$actions['cat'] = array(
461 461
 			'caption' => 'Categories',
462 462
 			'group' => $group,
463 463
 			'children' => array(
464 464
 				'cat_add' => Etemplate\Widget\Nextmatch::category_action(
465
-					'addressbook',$group,'Add category', 'cat_add_',
466
-					true, 0,Etemplate\Widget\Nextmatch::DEFAULT_MAX_MENU_LENGTH,false
467
-				)+array(
465
+					'addressbook', $group, 'Add category', 'cat_add_',
466
+					true, 0, Etemplate\Widget\Nextmatch::DEFAULT_MAX_MENU_LENGTH, false
467
+				) + array(
468 468
 					'icon' => 'foldertree_nolines_plus',
469 469
 					'disableClass' => 'rowNoEdit',
470 470
 				),
471 471
 				'cat_del' => Etemplate\Widget\Nextmatch::category_action(
472
-					'addressbook',$group,'Delete category', 'cat_del_',
473
-					true, 0,Etemplate\Widget\Nextmatch::DEFAULT_MAX_MENU_LENGTH,false
474
-				)+array(
472
+					'addressbook', $group, 'Delete category', 'cat_del_',
473
+					true, 0, Etemplate\Widget\Nextmatch::DEFAULT_MAX_MENU_LENGTH, false
474
+				) + array(
475 475
 					'icon' => 'foldertree_nolines_minus',
476 476
 					'disableClass' => 'rowNoEdit',
477 477
 				),
@@ -498,7 +498,7 @@  discard block
 block discarded – undo
498 498
 					'children' => $add_lists,
499 499
 					'prefix' => 'to_list_',
500 500
 					'icon' => 'foldertree_nolines_plus',
501
-					'enabled' => ($add_lists?true:false), // if there are editable lists, allow to add a contact to one of them,
501
+					'enabled' => ($add_lists ? true : false), // if there are editable lists, allow to add a contact to one of them,
502 502
 					//'disableClass' => 'rowNoEdit',	  // wether you are allowed to edit the contact or not, as you alter a list, not the contact
503 503
 				),
504 504
 				'remove_from_list' => array(
@@ -507,14 +507,14 @@  discard block
 block discarded – undo
507 507
 					'icon' => 'foldertree_nolines_minus',
508 508
 					'enabled' => 'javaScript:app.addressbook.nm_compare_field',
509 509
 					'fieldId' => 'exec[nm][filter2]',
510
-					'fieldValue' => '!',	// enable if list != ''
510
+					'fieldValue' => '!', // enable if list != ''
511 511
 				),
512 512
 				'rename_list' => array(
513 513
 					'caption' => 'Rename selected distribution list',
514 514
 					'icon' => 'edit',
515 515
 					'enabled' => 'javaScript:app.addressbook.nm_compare_field',
516 516
 					'fieldId' => 'exec[nm][filter2]',
517
-					'fieldValue' => '!',	// enable if list != ''
517
+					'fieldValue' => '!', // enable if list != ''
518 518
 					'onExecute' => 'javaScript:app.addressbook.rename_list'
519 519
 				),
520 520
 				'delete_list' => array(
@@ -523,10 +523,10 @@  discard block
 block discarded – undo
523 523
 					'icon' => 'delete',
524 524
 					'enabled' => 'javaScript:app.addressbook.nm_compare_field',
525 525
 					'fieldId' => 'exec[nm][filter2]',
526
-					'fieldValue' => '!',	// enable if list != ''
526
+					'fieldValue' => '!', // enable if list != ''
527 527
 				),
528 528
 			);
529
-			if(is_subclass_of('etemplate', 'etemplate_new'))
529
+			if (is_subclass_of('etemplate', 'etemplate_new'))
530 530
 			{
531 531
 				$actions['lists']['children']['remove_from_list']['fieldId'] = 'filter2';
532 532
 				$actions['lists']['children']['rename_list']['fieldId'] = 'filter2';
@@ -536,18 +536,18 @@  discard block
 block discarded – undo
536 536
 		// move to AB
537 537
 		if (($move2addressbooks = $this->get_addressbooks(Acl::ADD)))	// do we have addressbooks, we should
538 538
 		{
539
-			unset($move2addressbooks[0]);	// do not offer action to move contact to an account, as we dont support that currrently
540
-			foreach($move2addressbooks as $owner => $label)
539
+			unset($move2addressbooks[0]); // do not offer action to move contact to an account, as we dont support that currrently
540
+			foreach ($move2addressbooks as $owner => $label)
541 541
 			{
542 542
 				$icon = $type_label = null;
543
-				$this->type_icon((int)$owner, substr($owner,-1) == 'p', 'n', $icon, $type_label);
543
+				$this->type_icon((int)$owner, substr($owner, -1) == 'p', 'n', $icon, $type_label);
544 544
 				$move2addressbooks[$owner] = array(
545 545
 					'icon' => $icon,
546 546
 					'caption' => $label,
547 547
 				);
548 548
 			}
549 549
 			// copy checkbox
550
-			$move2addressbooks= array(
550
+			$move2addressbooks = array(
551 551
 				'copy' =>array(
552 552
 					'id' => 'move_to_copy',
553 553
 					'caption' => 'Copy instead of move',
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
 			'hideOnMobile' => true
572 572
 		);
573 573
 
574
-		++$group;	// integration with other apps: infolog, calendar, filemanager
574
+		++$group; // integration with other apps: infolog, calendar, filemanager
575 575
 		if ($GLOBALS['egw_info']['user']['apps']['infolog'])
576 576
 		{
577 577
 			$actions['infolog_app'] = array(
@@ -591,7 +591,7 @@  discard block
 block discarded – undo
591 591
 						'icon' => 'new',
592 592
 						'url' => 'menuaction=infolog.infolog_ui.edit&type=task&action=addressbook&action_id=$id',
593 593
 						'popup' => Link::get_registry('infolog', 'add_popup'),
594
-						'onExecute' => 'javaScript:app.addressbook.add_task',	// call server for org-view only
594
+						'onExecute' => 'javaScript:app.addressbook.add_task', // call server for org-view only
595 595
 					),
596 596
 				),
597 597
 				'hideOnMobile' => true
@@ -608,7 +608,7 @@  discard block
 block discarded – undo
608 608
 						'caption' => 'Show',
609 609
 						'icon' => 'view',
610 610
 						'onExecute' => 'javaScript:app.addressbook.view_calendar',
611
-						'targetapp' => 'calendar',	// open in calendar tab,
611
+						'targetapp' => 'calendar', // open in calendar tab,
612 612
 						'hideOnDisabled' => true,
613 613
 					),
614 614
 					'calendar_add' => array(
@@ -687,7 +687,7 @@  discard block
 block discarded – undo
687 687
 			'caption' => 'GeoLocation',
688 688
 			'icon' => 'map',
689 689
 			'group' => ++$group,
690
-			'children' => array (
690
+			'children' => array(
691 691
 				'private' => array(
692 692
 					'caption' => 'Private Address',
693 693
 					'enabled' => 'javaScript:app.addressbook.geoLocation_enabled',
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
 		);
705 705
 		// check if user is an admin or the export is not generally turned off (contact_export_limit is non-numerical, eg. no)
706 706
 		$exception = Api\Storage\Merge::is_export_limit_excepted();
707
-		if ((isset($GLOBALS['egw_info']['user']['apps']['admin']) || $exception)  || !$this->config['contact_export_limit'] || (int)$this->config['contact_export_limit'])
707
+		if ((isset($GLOBALS['egw_info']['user']['apps']['admin']) || $exception) || !$this->config['contact_export_limit'] || (int)$this->config['contact_export_limit'])
708 708
 		{
709 709
 			$actions['export'] = array(
710 710
 				'caption' => 'Export',
@@ -719,7 +719,7 @@  discard block
 block discarded – undo
719 719
 					),
720 720
 					'vcard'  => array(
721 721
 						'caption' => 'Export as VCard',
722
-						'postSubmit' => true,	// download needs post submit (not Ajax) to work
722
+						'postSubmit' => true, // download needs post submit (not Ajax) to work
723 723
 						'icon' => Vfs::mime_icon('text/vcard'),
724 724
 					),
725 725
 				),
@@ -731,7 +731,7 @@  discard block
 block discarded – undo
731 731
 			$this->prefs['document_dir'], $group, 'Insert in document', 'document_',
732 732
 			$this->prefs['default_document'], $this->config['contact_export_limit']
733 733
 		);
734
-		if (isset($GLOBALS['egw_info']['apps']['stylite']) && ($GLOBALS['egw_info']['user']['apps']['felamimail']||$GLOBALS['egw_info']['user']['apps']['mail']))
734
+		if (isset($GLOBALS['egw_info']['apps']['stylite']) && ($GLOBALS['egw_info']['user']['apps']['felamimail'] || $GLOBALS['egw_info']['user']['apps']['mail']))
735 735
 		{
736 736
 			$actions['mail'] = array(
737 737
 				'caption' => lang('Mail VCard'),
@@ -754,7 +754,7 @@  discard block
 block discarded – undo
754 754
 				'disableClass' => 'rowNoDelete',
755 755
 			);
756 756
 		}
757
-		if ($this->grants[0] & Acl::DELETE)
757
+		if ($this->grants[0]&Acl::DELETE)
758 758
 		{
759 759
 			$actions['delete_account'] = array(
760 760
 				'caption' => 'Delete',
@@ -767,7 +767,7 @@  discard block
 block discarded – undo
767 767
 			);
768 768
 			$actions['delete']['hideOnDisabled'] = true;
769 769
 		}
770
-		if($tid_filter == 'D')
770
+		if ($tid_filter == 'D')
771 771
 		{
772 772
 			$actions['undelete'] = array(
773 773
 				'caption' => 'Un-delete',
@@ -778,7 +778,7 @@  discard block
 block discarded – undo
778 778
 		}
779 779
 		if (isset($actions['export']['children']['csv']) &&
780 780
 			(!isset($GLOBALS['egw_info']['user']['apps']['importexport']) ||
781
-			!importexport_helper_functions::has_definitions('addressbook','export')))
781
+			!importexport_helper_functions::has_definitions('addressbook', 'export')))
782 782
 		{
783 783
 			unset($actions['export']['children']['csv']);
784 784
 		}
@@ -811,13 +811,13 @@  discard block
 block discarded – undo
811 811
 	private function _get_org_name($org)
812 812
 	{
813 813
 		$org_name = array();
814
-		if (strpos($org,'*AND*')!== false) $org = str_replace('*AND*','&',$org);
815
-		foreach(explode('|||',$org) as $part)
814
+		if (strpos($org, '*AND*') !== false) $org = str_replace('*AND*', '&', $org);
815
+		foreach (explode('|||', $org) as $part)
816 816
 		{
817
-			list(,$name) = explode(':',$part,2);
817
+			list(,$name) = explode(':', $part, 2);
818 818
 			if ($name) $org_name[] = $name;
819 819
 		}
820
-		$name = implode(': ',$org_name);
820
+		$name = implode(': ', $org_name);
821 821
 		return $name ? array($org => $name) : array();
822 822
 	}
823 823
 
@@ -827,12 +827,12 @@  discard block
 block discarded – undo
827 827
 	 * @param array $content =null submitted content
828 828
 	 * @param string $msg =null	message to show
829 829
 	 */
830
-	function emailpopup($content=null,$msg=null)
830
+	function emailpopup($content = null, $msg = null)
831 831
 	{
832
-		if (strpos($GLOBALS['egw_info']['flags']['java_script'],'addEmail') === false)
832
+		if (strpos($GLOBALS['egw_info']['flags']['java_script'], 'addEmail') === false)
833 833
 		{
834 834
 			$handler = 'opener.addEmail(to,email)';
835
-			$GLOBALS['egw_info']['flags']['java_script'].= "
835
+			$GLOBALS['egw_info']['flags']['java_script'] .= "
836 836
 <script>
837 837
 window.egw_LAB.wait(function() {
838 838
 	window.focus();
@@ -862,7 +862,7 @@  discard block
 block discarded – undo
862 862
 </script>
863 863
 ";
864 864
 		}
865
-		return $this->index($content,$msg,true);
865
+		return $this->index($content, $msg, true);
866 866
 	}
867 867
 
868 868
 	/**
@@ -876,19 +876,19 @@  discard block
 block discarded – undo
876 876
 	{
877 877
 		$org_contacts = array();
878 878
 		$query = !$_query ? Api\Cache::getSession('addressbook', 'index') : $_query;
879
-		$query['num_rows'] = -1;	// all
880
-		if(!is_array($query['col_filter'])) $query['col_filter'] = array();
879
+		$query['num_rows'] = -1; // all
880
+		if (!is_array($query['col_filter'])) $query['col_filter'] = array();
881 881
 
882
-		if(!is_array($org)) $org = array($org);
883
-		foreach($org as $org_name)
882
+		if (!is_array($org)) $org = array($org);
883
+		foreach ($org as $org_name)
884 884
 		{
885 885
 			$query['org_view'] = $org_name;
886 886
 			$checked = array();
887 887
 			$readonlys = null;
888
-			$this->get_rows($query,$checked,$readonlys,true);	// true = only return the id's
889
-			if($checked[0])
888
+			$this->get_rows($query, $checked, $readonlys, true); // true = only return the id's
889
+			if ($checked[0])
890 890
 			{
891
-				$org_contacts = array_merge($org_contacts,$checked);
891
+				$org_contacts = array_merge($org_contacts, $checked);
892 892
 			}
893 893
 		}
894 894
 		Api\Json\Response::get()->data(array_unique($org_contacts));
@@ -902,33 +902,33 @@  discard block
 block discarded – undo
902 902
 	function infolog_org_view($org)
903 903
 	{
904 904
 		$query = Api\Cache::getSession('addressbook', 'index');
905
-		$query['num_rows'] = -1;	// all
905
+		$query['num_rows'] = -1; // all
906 906
 		$query['org_view'] = $org;
907 907
 		$query['searchletter'] = '';
908 908
 		$checked = $readonlys = null;
909
-		$this->get_rows($query,$checked,$readonlys,true);	// true = only return the id's
909
+		$this->get_rows($query, $checked, $readonlys, true); // true = only return the id's
910 910
 
911 911
 		if (count($checked) > 1)	// use a nicely formatted org-name as title in infolog
912 912
 		{
913 913
 			$parts = array();
914
-			if (strpos($org,'*AND*')!== false) $org = str_replace('*AND*','&',$org);
915
-			foreach(explode('|||',$org) as $part)
914
+			if (strpos($org, '*AND*') !== false) $org = str_replace('*AND*', '&', $org);
915
+			foreach (explode('|||', $org) as $part)
916 916
 			{
917
-				list(,$part) = explode(':',$part,2);
917
+				list(,$part) = explode(':', $part, 2);
918 918
 				if ($part) $parts[] = $part;
919 919
 			}
920
-			$org = implode(', ',$parts);
920
+			$org = implode(', ', $parts);
921 921
 		}
922 922
 		else
923 923
 		{
924
-			$org = '';	// use infolog default of link-title
924
+			$org = ''; // use infolog default of link-title
925 925
 		}
926
-		Egw::redirect_link('/index.php',array(
926
+		Egw::redirect_link('/index.php', array(
927 927
 			'menuaction' => 'infolog.infolog_ui.index',
928 928
 			'action' => 'addressbook',
929
-			'action_id' => implode(',',$checked),
929
+			'action_id' => implode(',', $checked),
930 930
 			'action_title' => $org,
931
-		),'infolog');
931
+		), 'infolog');
932 932
 	}
933 933
 
934 934
 	/**
@@ -953,31 +953,31 @@  discard block
 block discarded – undo
953 953
 			$owner = $this->default_addressbook;
954 954
 		}
955 955
 		// Check for valid list & permissions
956
-		if(!(int)$list_id && !$this->check_list(null,EGW_ACL_ADD|EGW_ACL_EDIT,$owner))
956
+		if (!(int)$list_id && !$this->check_list(null, EGW_ACL_ADD|EGW_ACL_EDIT, $owner))
957 957
 		{
958
-			Api\Json\Response::get()->apply('egw.message', array(  lang('List creation failed, no rights!'),'error'));
958
+			Api\Json\Response::get()->apply('egw.message', array(lang('List creation failed, no rights!'), 'error'));
959 959
 			return;
960 960
 		}
961 961
 		if ((int)$list_id && !$this->check_list((int)$list_id, Acl::EDIT, $owner))
962 962
 		{
963
-			Api\Json\Response::get()->apply('egw.message', array(  lang('Insufficent rights to edit this list!'),'error'));
963
+			Api\Json\Response::get()->apply('egw.message', array(lang('Insufficent rights to edit this list!'), 'error'));
964 964
 			return;
965 965
 		}
966 966
 
967 967
 		$list = array('list_owner' => $owner);
968 968
 
969 969
 		// Rename
970
-		if($list_id)
970
+		if ($list_id)
971 971
 		{
972 972
 			$list = $this->read_list((int)$list_id);
973 973
 		}
974 974
 		$list['list_name'] = $new_name;
975 975
 
976
-		$new_id = $this->add_list(array('list_id' => (int)$list_id), $list['list_owner'],array(),$list);
976
+		$new_id = $this->add_list(array('list_id' => (int)$list_id), $list['list_owner'], array(), $list);
977 977
 
978
-		if($contacts)
978
+		if ($contacts)
979 979
 		{
980
-			$this->add2list($contacts,$new_id);
980
+			$this->add2list($contacts, $new_id);
981 981
 		}
982 982
 		Api\Json\Response::get()->apply('egw.message', array(
983 983
 			$new_id == $list_id ? lang('Distribution list renamed') : lang('List created'),
@@ -992,7 +992,7 @@  discard block
 block discarded – undo
992 992
 	 *
993 993
 	 * @param string $account_id
994 994
 	 */
995
-	function ajax_get_contact ($account_id)
995
+	function ajax_get_contact($account_id)
996 996
 	{
997 997
 		$bo = new Api\Contacts();
998 998
 		$contact = $bo->read('account:'.$account_id);
@@ -1009,7 +1009,7 @@  discard block
 block discarded – undo
1009 1009
 	{
1010 1010
 		$query = Api\Cache::getSession('addressbook', 'index');
1011 1011
 		unset($query['advanced_search']);
1012
-		Api\Cache::setSession('addressbook','index',$query);
1012
+		Api\Cache::setSession('addressbook', 'index', $query);
1013 1013
 		Api\Cache::setSession('addressbook', 'advanced_search', false);
1014 1014
 	}
1015 1015
 
@@ -1025,78 +1025,78 @@  discard block
 block discarded – undo
1025 1025
 	 * @param string/array $session_name 'index' or 'email', or array with session-data depending if we are in the main list or the popup
1026 1026
 	 * @return boolean true if all actions succeded, false otherwise
1027 1027
 	 */
1028
-	function action($action,$checked,$use_all,&$success,&$failed,&$action_msg,$session_name,&$msg, $checkboxes = NULL)
1028
+	function action($action, $checked, $use_all, &$success, &$failed, &$action_msg, $session_name, &$msg, $checkboxes = NULL)
1029 1029
 	{
1030 1030
 		//echo "<p>uicontacts::action('$action',".print_r($checked,true).','.(int)$use_all.",...)</p>\n";
1031 1031
 		$success = $failed = 0;
1032
-		if ($use_all || in_array($action,array('remove_from_list','delete_list')))
1032
+		if ($use_all || in_array($action, array('remove_from_list', 'delete_list')))
1033 1033
 		{
1034 1034
 			// get the whole selection
1035 1035
 			$query = is_array($session_name) ? $session_name : Api\Cache::getSession('addressbook', $session_name);
1036 1036
 
1037 1037
 			if ($use_all)
1038 1038
 			{
1039
-				@set_time_limit(0);			// switch off the execution time limit, as it's for big selections to small
1040
-				$query['num_rows'] = -1;	// all
1039
+				@set_time_limit(0); // switch off the execution time limit, as it's for big selections to small
1040
+				$query['num_rows'] = -1; // all
1041 1041
 				$readonlys = null;
1042
-				$this->get_rows($query,$checked,$readonlys,true);	// true = only return the id's
1042
+				$this->get_rows($query, $checked, $readonlys, true); // true = only return the id's
1043 1043
 			}
1044 1044
 		}
1045 1045
 		// replace org_name:* id's with all id's of that org
1046 1046
 		$org_contacts = array();
1047
-		foreach((array)$checked as $n => $id)
1047
+		foreach ((array)$checked as $n => $id)
1048 1048
 		{
1049
-			if (substr($id,0,9) == 'org_name:')
1049
+			if (substr($id, 0, 9) == 'org_name:')
1050 1050
 			{
1051 1051
 				if (count($checked) == 1 && !count($org_contacts) && $action == 'infolog')
1052 1052
 				{
1053
-					return $this->infolog_org_view($id);	// uses the org-name, instead of 'selected contacts'
1053
+					return $this->infolog_org_view($id); // uses the org-name, instead of 'selected contacts'
1054 1054
 				}
1055 1055
 				unset($checked[$n]);
1056 1056
 				$query = Api\Cache::getSession('addressbook', $session_name);
1057
-				$query['num_rows'] = -1;	// all
1057
+				$query['num_rows'] = -1; // all
1058 1058
 				$query['org_view'] = $id;
1059 1059
 				unset($query['filter2']);
1060 1060
 				$extra = $readonlys = null;
1061
-				$this->get_rows($query,$extra,$readonlys,true);	// true = only return the id's
1062
-				if ($extra[0]) $org_contacts = array_merge($org_contacts,$extra);
1061
+				$this->get_rows($query, $extra, $readonlys, true); // true = only return the id's
1062
+				if ($extra[0]) $org_contacts = array_merge($org_contacts, $extra);
1063 1063
 			}
1064 1064
 		}
1065
-		if ($org_contacts) $checked = array_unique($checked ? array_merge($checked,$org_contacts) : $org_contacts);
1065
+		if ($org_contacts) $checked = array_unique($checked ? array_merge($checked, $org_contacts) : $org_contacts);
1066 1066
 		//_debug_array($checked); exit;
1067 1067
 
1068
-		if (substr($action,0,8) == 'move_to_')
1068
+		if (substr($action, 0, 8) == 'move_to_')
1069 1069
 		{
1070
-			$action = (int)substr($action,8).(substr($action,-1) == 'p' ? 'p' : '');
1070
+			$action = (int)substr($action, 8).(substr($action, -1) == 'p' ? 'p' : '');
1071 1071
 		}
1072
-		elseif (substr($action,0,8) == 'to_list_')
1072
+		elseif (substr($action, 0, 8) == 'to_list_')
1073 1073
 		{
1074
-			$to_list = (int)substr($action,8);
1074
+			$to_list = (int)substr($action, 8);
1075 1075
 			$action = 'to_list';
1076 1076
 		}
1077
-		elseif (substr($action,0,9) == 'document_')
1077
+		elseif (substr($action, 0, 9) == 'document_')
1078 1078
 		{
1079
-			$document = substr($action,9);
1079
+			$document = substr($action, 9);
1080 1080
 			$action = 'document';
1081 1081
 		}
1082
-		elseif(substr($action,0,4) == 'cat_')	// cat_add_123 or cat_del_456
1082
+		elseif (substr($action, 0, 4) == 'cat_')	// cat_add_123 or cat_del_456
1083 1083
 		{
1084 1084
 			$cat_id = (int)substr($action, 8);
1085
-			$action = substr($action,0,7);
1085
+			$action = substr($action, 0, 7);
1086 1086
 		}
1087 1087
 		// Security: stop non-admins to export more then the configured number of contacts
1088
-		if (in_array($action,array('csv','vcard')) && $this->config['contact_export_limit'] && !Api\Storage\Merge::is_export_limit_excepted() &&
1088
+		if (in_array($action, array('csv', 'vcard')) && $this->config['contact_export_limit'] && !Api\Storage\Merge::is_export_limit_excepted() &&
1089 1089
 			(!is_numeric($this->config['contact_export_limit']) || count($checked) > $this->config['contact_export_limit']))
1090 1090
 		{
1091 1091
 			$action_msg = lang('exported');
1092 1092
 			$failed = count($checked);
1093 1093
 			return false;
1094 1094
 		}
1095
-		switch($action)
1095
+		switch ($action)
1096 1096
 		{
1097 1097
 			case 'vcard':
1098 1098
 				$action_msg = lang('exported');
1099
-				$vcard = new addressbook_vcal('addressbook','text/vcard');
1099
+				$vcard = new addressbook_vcal('addressbook', 'text/vcard');
1100 1100
 				$vcard->export($checked);
1101 1101
 				// does not return!
1102 1102
 				$Ok = false;
@@ -1104,10 +1104,10 @@  discard block
 block discarded – undo
1104 1104
 
1105 1105
 			case 'merge':
1106 1106
 				$error_msg = null;
1107
-				$success = $this->merge($checked,$error_msg);
1107
+				$success = $this->merge($checked, $error_msg);
1108 1108
 				$failed = count($checked) - (int)$success;
1109 1109
 				$action_msg = lang('merged');
1110
-				$checked = array();	// to not start the single actions
1110
+				$checked = array(); // to not start the single actions
1111 1111
 				break;
1112 1112
 
1113 1113
 			case 'delete_list':
@@ -1115,7 +1115,7 @@  discard block
 block discarded – undo
1115 1115
 				{
1116 1116
 					$msg = lang('You need to select a distribution list');
1117 1117
 				}
1118
-				elseif($this->delete_list($query['filter2']) === false)
1118
+				elseif ($this->delete_list($query['filter2']) === false)
1119 1119
 				{
1120 1120
 					$msg = lang('Insufficent rights to delete this list!');
1121 1121
 				}
@@ -1135,49 +1135,49 @@  discard block
 block discarded – undo
1135 1135
 				return false;
1136 1136
 
1137 1137
 			case 'infolog_add':
1138
-				Framework::popup(Egw::link('/index.php',array(
1138
+				Framework::popup(Egw::link('/index.php', array(
1139 1139
 						'menuaction' => 'infolog.infolog_ui.edit',
1140 1140
 						'type' => 'task',
1141 1141
 						'action' => 'addressbook',
1142
-						'action_id' => implode(',',$checked),
1143
-					)),'_blank',Link::get_registry('infolog', 'add_popup'));
1144
-				$msg = '';	// no message, as we send none in javascript too and users sees opening popup
1142
+						'action_id' => implode(',', $checked),
1143
+					)), '_blank', Link::get_registry('infolog', 'add_popup'));
1144
+				$msg = ''; // no message, as we send none in javascript too and users sees opening popup
1145 1145
 				return false;
1146 1146
 
1147 1147
 			case 'calendar_add':	// add appointment for org-views, other views are handled directly in javascript
1148
-				Framework::popup(Egw::link('/index.php',array(
1148
+				Framework::popup(Egw::link('/index.php', array(
1149 1149
 						'menuaction' => 'calendar.calendar_uiforms.edit',
1150
-						'participants' => 'c'.implode(',c',$checked),
1151
-					)),'_blank',Link::get_registry('calendar', 'add_popup'));
1152
-				$msg = '';	// no message, as we send none in javascript too and users sees opening popup
1150
+						'participants' => 'c'.implode(',c', $checked),
1151
+					)), '_blank', Link::get_registry('calendar', 'add_popup'));
1152
+				$msg = ''; // no message, as we send none in javascript too and users sees opening popup
1153 1153
 				return false;
1154 1154
 
1155 1155
 			case 'calendar_view':	// show calendar for org-views, although all views are handled directly in javascript
1156
-				Egw::redirect_link('/index.php',array(
1156
+				Egw::redirect_link('/index.php', array(
1157 1157
 					'menuaction' => 'calendar.calendar_uiviews.index',
1158
-					'owner' => 'c'.implode(',c',$checked),
1158
+					'owner' => 'c'.implode(',c', $checked),
1159 1159
 				));
1160 1160
 		}
1161
-		foreach($checked as $id)
1161
+		foreach ($checked as $id)
1162 1162
 		{
1163
-			switch($action)
1163
+			switch ($action)
1164 1164
 			{
1165 1165
 				case 'cat_add':
1166 1166
 				case 'cat_del':
1167
-					if (($Ok = !!($contact = $this->read($id)) && $this->check_perms(Acl::EDIT,$contact)))
1167
+					if (($Ok = !!($contact = $this->read($id)) && $this->check_perms(Acl::EDIT, $contact)))
1168 1168
 					{
1169 1169
 						$action_msg = $action == 'cat_add' ? lang('categorie added') : lang('categorie delete');
1170
-						$cat_ids = $contact['cat_id'] ? explode(',', $contact['cat_id']) : array();   //existing Api\Categories
1170
+						$cat_ids = $contact['cat_id'] ? explode(',', $contact['cat_id']) : array(); //existing Api\Categories
1171 1171
 						if ($action == 'cat_add')
1172 1172
 						{
1173 1173
 							$cat_ids[] = $cat_id;
1174 1174
 							$cat_ids = array_unique($cat_ids);
1175 1175
 						}
1176
-						elseif ((($key = array_search($cat_id,$cat_ids))) !== false)
1176
+						elseif ((($key = array_search($cat_id, $cat_ids))) !== false)
1177 1177
 						{
1178 1178
 							unset($cat_ids[$key]);
1179 1179
 						}
1180
-						$ids = $cat_ids ? implode(',',$cat_ids) : null;
1180
+						$ids = $cat_ids ? implode(',', $cat_ids) : null;
1181 1181
 						if ($ids !== $contact['cat_id'])
1182 1182
 						{
1183 1183
 							$contact['cat_id'] = $ids;
@@ -1188,10 +1188,10 @@  discard block
 block discarded – undo
1188 1188
 
1189 1189
 				case 'delete':
1190 1190
 					$action_msg = lang('deleted');
1191
-					if (($Ok = !!($contact = $this->read($id)) && $this->check_perms(Acl::DELETE,$contact)))
1191
+					if (($Ok = !!($contact = $this->read($id)) && $this->check_perms(Acl::DELETE, $contact)))
1192 1192
 					{
1193
-						if ($contact['owner'] ||	// regular contact or
1194
-							empty($contact['account_id']) ||	// accounts without account_id
1193
+						if ($contact['owner'] || // regular contact or
1194
+							empty($contact['account_id']) || // accounts without account_id
1195 1195
 							// already deleted account (should no longer happen, but needed to allow for cleanup)
1196 1196
 							$contact['tid'] == self::DELETED_TYPE)
1197 1197
 						{
@@ -1200,7 +1200,7 @@  discard block
 block discarded – undo
1200 1200
 						// delete single account --> redirect to admin
1201 1201
 						elseif (count($checked) == 1 && $contact['account_id'])
1202 1202
 						{
1203
-							Egw::redirect_link('/index.php',array(
1203
+							Egw::redirect_link('/index.php', array(
1204 1204
 								'menuaction' => 'admin.admin_account.delete',
1205 1205
 								'account_id' => $contact['account_id'],
1206 1206
 							));
@@ -1262,7 +1262,7 @@  discard block
 block discarded – undo
1262 1262
 					}
1263 1263
 					else
1264 1264
 					{
1265
-						$Ok = $this->remove_from_list($id,$query['filter2']) !== false;
1265
+						$Ok = $this->remove_from_list($id, $query['filter2']) !== false;
1266 1266
 					}
1267 1267
 					break;
1268 1268
 
@@ -1275,28 +1275,28 @@  discard block
 block discarded – undo
1275 1275
 					}
1276 1276
 					else
1277 1277
 					{
1278
-						$Ok = $this->add2list($id,$to_list) !== false;
1278
+						$Ok = $this->add2list($id, $to_list) !== false;
1279 1279
 					}
1280 1280
 					break;
1281 1281
 
1282 1282
 				default:	// move to an other addressbook
1283
-					if (!(int)$action || !($this->grants[(string) (int) $action] & Acl::EDIT))	// might be ADD in the future
1283
+					if (!(int)$action || !($this->grants[(string)(int)$action]&Acl::EDIT))	// might be ADD in the future
1284 1284
 					{
1285 1285
 						return false;
1286 1286
 					}
1287 1287
 					if (!$checkboxes['move_to_copy'])
1288 1288
 					{
1289 1289
 						$action_msg = lang('moved');
1290
-						if (($Ok = !!($contact = $this->read($id)) && $this->check_perms(Acl::DELETE,$contact)))
1290
+						if (($Ok = !!($contact = $this->read($id)) && $this->check_perms(Acl::DELETE, $contact)))
1291 1291
 						{
1292 1292
 							if (!$contact['owner'])		// no (mass-)move of Api\Accounts
1293 1293
 							{
1294 1294
 								$Ok = false;
1295 1295
 							}
1296
-							elseif ($contact['owner'] != (int)$action || $contact['private'] != (int)(substr($action,-1) == 'p'))
1296
+							elseif ($contact['owner'] != (int)$action || $contact['private'] != (int)(substr($action, -1) == 'p'))
1297 1297
 							{
1298
-								$contact['owner'] = (int) $action;
1299
-								$contact['private'] = (int)(substr($action,-1) == 'p');
1298
+								$contact['owner'] = (int)$action;
1299
+								$contact['private'] = (int)(substr($action, -1) == 'p');
1300 1300
 								$Ok = $this->save($contact);
1301 1301
 							}
1302 1302
 						}
@@ -1304,14 +1304,14 @@  discard block
 block discarded – undo
1304 1304
 					else
1305 1305
 					{
1306 1306
 						$action_msg = lang('copied');
1307
-						if (($Ok = !!($contact = $this->read($id)) && $this->check_perms(Acl::READ,$contact)))
1307
+						if (($Ok = !!($contact = $this->read($id)) && $this->check_perms(Acl::READ, $contact)))
1308 1308
 						{
1309
-							if ($contact['owner'] != (int)$action || $contact['private'] != (int)(substr($action,-1) == 'p'))
1309
+							if ($contact['owner'] != (int)$action || $contact['private'] != (int)(substr($action, -1) == 'p'))
1310 1310
 							{
1311
-								$this->copy_contact($contact, false);	// do NOT use self::$copy_fields, copy everything but uid etc.
1311
+								$this->copy_contact($contact, false); // do NOT use self::$copy_fields, copy everything but uid etc.
1312 1312
 								$links = $contact['link_to']['to_id'];
1313
-								$contact['owner'] = (int) $action;
1314
-								$contact['private'] = (int)(substr($action,-1) == 'p');
1313
+								$contact['owner'] = (int)$action;
1314
+								$contact['private'] = (int)(substr($action, -1) == 'p');
1315 1315
 								$Ok = $this->save($contact);
1316 1316
 								if ($Ok && is_array($links))
1317 1317
 								{
@@ -1343,22 +1343,22 @@  discard block
 block discarded – undo
1343 1343
 	 * @param boolean $only_copy_fields =true true: only copy fields configured for copying (eg. no name),
1344 1344
 	 *		false: copy everything, but never to copy fields
1345 1345
 	 */
1346
-	function copy_contact(array &$content, $only_copy_fields=true)
1346
+	function copy_contact(array &$content, $only_copy_fields = true)
1347 1347
 	{
1348 1348
 		$content['link_to']['to_id'] = 0;
1349
-		Link::link('addressbook',$content['link_to']['to_id'],'addressbook',$content['id'],
1350
-			lang('Copied by %1, from record #%2.',Api\Accounts::format_username('',
1351
-			$GLOBALS['egw_info']['user']['account_firstname'],$GLOBALS['egw_info']['user']['account_lastname']),
1349
+		Link::link('addressbook', $content['link_to']['to_id'], 'addressbook', $content['id'],
1350
+			lang('Copied by %1, from record #%2.', Api\Accounts::format_username('',
1351
+			$GLOBALS['egw_info']['user']['account_firstname'], $GLOBALS['egw_info']['user']['account_lastname']),
1352 1352
 			$content['id']));
1353 1353
 		// create a new contact with the content of the old
1354
-		foreach(array_keys($content) as $key)
1354
+		foreach (array_keys($content) as $key)
1355 1355
 		{
1356
-			if($only_copy_fields && !in_array($key, self::$copy_fields) || in_array($key, array('id','etag','carddav_name','uid')))
1356
+			if ($only_copy_fields && !in_array($key, self::$copy_fields) || in_array($key, array('id', 'etag', 'carddav_name', 'uid')))
1357 1357
 			{
1358 1358
 				unset($content[$key]);
1359 1359
 			}
1360 1360
 		}
1361
-		if(!isset($content['owner']))
1361
+		if (!isset($content['owner']))
1362 1362
 		{
1363 1363
 			$content['owner'] = $this->default_private ? $this->user.'p' : $this->default_addressbook;
1364 1364
 		}
@@ -1376,7 +1376,7 @@  discard block
 block discarded – undo
1376 1376
 	 * @param boolean $id_only =false if true only return (via $rows) an array of contact-ids, dont save state to session
1377 1377
 	 * @return int total number of contacts matching the selection
1378 1378
 	 */
1379
-	function get_rows(&$query,&$rows,&$readonlys,$id_only=false)
1379
+	function get_rows(&$query, &$rows, &$readonlys, $id_only = false)
1380 1380
 	{
1381 1381
 		$do_email = $query['do_email'];
1382 1382
 		$what = $query['sitemgr_display'] ? $query['sitemgr_display'] : ($do_email ? 'email' : 'index');
@@ -1385,7 +1385,7 @@  discard block
 block discarded – undo
1385 1385
 		{
1386 1386
 			$store_query = $query;
1387 1387
 			// Do not store these
1388
-			foreach(array('options-cat_id','actions','action_links','placeholder_actions') as $key)
1388
+			foreach (array('options-cat_id', 'actions', 'action_links', 'placeholder_actions') as $key)
1389 1389
 			{
1390 1390
 				unset($store_query[$key]);
1391 1391
 			}
@@ -1396,22 +1396,22 @@  discard block
 block discarded – undo
1396 1396
 		{
1397 1397
 			$old_state = Api\Cache::getSession('addressbook', $what);
1398 1398
 		}
1399
-		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
1399
+		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
1400 1400
 		{
1401 1401
 			if (isset($query['col_filter']['org_name'])) unset($query['col_filter']['org_name']);
1402 1402
 			if (isset($query['col_filter']['adr_one_locality'])) unset($query['col_filter']['adr_one_locality']);
1403 1403
 			if (isset($query['col_filter']['org_unit'])) unset($query['col_filter']['org_unit']);
1404 1404
 		}
1405 1405
 
1406
-		if (isset($this->org_views[(string) $query['org_view']]))	// we have an org view, reset the advanced search
1406
+		if (isset($this->org_views[(string)$query['org_view']]))	// we have an org view, reset the advanced search
1407 1407
 		{
1408 1408
 			//_debug_array(array('Search'=>$query['search'],
1409 1409
 			//	'AdvancedSearch'=>$query['advanced_search']));
1410 1410
 			//if (is_array($query['search'])) unset($query['search']);
1411 1411
 			//unset($query['advanced_search']);
1412
-			if(!$query['search'] && $old_state['advanced_search']) $query['advanced_search'] = $old_state['advanced_search'];
1412
+			if (!$query['search'] && $old_state['advanced_search']) $query['advanced_search'] = $old_state['advanced_search'];
1413 1413
 		}
1414
-		elseif(!$query['search'] && array_key_exists('advanced_search',$old_state))	// eg. paging in an advanced search
1414
+		elseif (!$query['search'] && array_key_exists('advanced_search', $old_state))	// eg. paging in an advanced search
1415 1415
 		{
1416 1416
 			$query['advanced_search'] = $old_state['advanced_search'];
1417 1417
 		}
@@ -1422,11 +1422,11 @@  discard block
 block discarded – undo
1422 1422
 		}*/
1423 1423
 
1424 1424
 		// Make sure old lettersearch filter doesn't stay - current letter filter will be added later
1425
-		foreach($query['col_filter'] as $key => $col_filter)
1425
+		foreach ($query['col_filter'] as $key => $col_filter)
1426 1426
 		{
1427
-			if(!is_numeric($key)) continue;
1428
-			if(preg_match('/'.$GLOBALS['egw']->db->capabilities['case_insensitive_like'].
1429
-				' '.$GLOBALS['egw']->db->quote('[a-z]%').'$/',$col_filter) == 1
1427
+			if (!is_numeric($key)) continue;
1428
+			if (preg_match('/'.$GLOBALS['egw']->db->capabilities['case_insensitive_like'].
1429
+				' '.$GLOBALS['egw']->db->quote('[a-z]%').'$/', $col_filter) == 1
1430 1430
 			)
1431 1431
 			{
1432 1432
 				unset($query['col_filter'][$key]);
@@ -1441,16 +1441,16 @@  discard block
 block discarded – undo
1441 1441
 			{
1442 1442
 				if ($old_state['filter'] === '0')	// user changed to org_view
1443 1443
 				{
1444
-					$query['filter'] = '';			// --> change filter to all contacts
1444
+					$query['filter'] = ''; // --> change filter to all contacts
1445 1445
 				}
1446 1446
 				else								// user changed to accounts
1447 1447
 				{
1448
-					$query['org_view'] = '';		// --> change to regular contacts view
1448
+					$query['org_view'] = ''; // --> change to regular contacts view
1449 1449
 				}
1450 1450
 			}
1451 1451
 			if ($query['org_view'] && isset($this->org_views[$old_state['org_view']]) && !isset($this->org_views[$query['org_view']]))
1452 1452
 			{
1453
-				$query['searchletter'] = '';		// reset lettersearch if viewing the contacts of one organisation
1453
+				$query['searchletter'] = ''; // reset lettersearch if viewing the contacts of one organisation
1454 1454
 			}
1455 1455
 			// save the state of the index in the user prefs
1456 1456
 			$state = serialize(array(
@@ -1463,9 +1463,9 @@  discard block
 block discarded – undo
1463 1463
 			));
1464 1464
 			if ($state != $this->prefs[$what.'_state'] && !$query['csv_export'])
1465 1465
 			{
1466
-				$GLOBALS['egw']->preferences->add('addressbook',$what.'_state',$state);
1466
+				$GLOBALS['egw']->preferences->add('addressbook', $what.'_state', $state);
1467 1467
 				// save prefs, but do NOT invalid the cache (unnecessary)
1468
-				$GLOBALS['egw']->preferences->save_repository(false,'user',false);
1468
+				$GLOBALS['egw']->preferences->save_repository(false, 'user', false);
1469 1469
 			}
1470 1470
 		}
1471 1471
 		unset($old_state);
@@ -1480,11 +1480,11 @@  discard block
 block discarded – undo
1480 1480
 		}
1481 1481
 		if ($query['filter'] !== '')	// not all addressbooks
1482 1482
 		{
1483
-			$query['col_filter']['owner'] = (string) (int) $query['filter'];
1483
+			$query['col_filter']['owner'] = (string)(int)$query['filter'];
1484 1484
 
1485 1485
 			if ($this->private_addressbook)
1486 1486
 			{
1487
-				$query['col_filter']['private'] = substr($query['filter'],-1) == 'p' ? 1 : 0;
1487
+				$query['col_filter']['private'] = substr($query['filter'], -1) == 'p' ? 1 : 0;
1488 1488
 			}
1489 1489
 		}
1490 1490
 		else
@@ -1494,7 +1494,7 @@  discard block
 block discarded – undo
1494 1494
 		}
1495 1495
 		if ((int)$query['filter2'])	// not no distribution list
1496 1496
 		{
1497
-			$query['col_filter']['list'] = (string) (int) $query['filter2'];
1497
+			$query['col_filter']['list'] = (string)(int)$query['filter2'];
1498 1498
 		}
1499 1499
 		else
1500 1500
 		{
@@ -1507,18 +1507,18 @@  discard block
 block discarded – undo
1507 1507
 		// all backends allow now at least to use groups as distribution lists
1508 1508
 		$query['no_filter2'] = false;
1509 1509
 
1510
-		if (isset($this->org_views[(string) $query['org_view']]) && !$query['col_filter']['parent_id'])	// we have an org view
1510
+		if (isset($this->org_views[(string)$query['org_view']]) && !$query['col_filter']['parent_id'])	// we have an org view
1511 1511
 		{
1512 1512
 			// Query doesn't like empties
1513 1513
 			unset($query['col_filter']['parent_id']);
1514 1514
 
1515
-			if($query['actions'] && $query['actions']['open'])
1515
+			if ($query['actions'] && $query['actions']['open'])
1516 1516
 			{
1517 1517
 				// Just switched from contact view, update actions
1518 1518
 				$query['actions'] = $this->get_actions($query['col_filter']['tid'], $query['org_view']);
1519 1519
 			}
1520
-			unset($query['col_filter']['list']);	// does not work together
1521
-			$query['no_filter2'] = true;			// switch the distribution list selection off
1520
+			unset($query['col_filter']['list']); // does not work together
1521
+			$query['no_filter2'] = true; // switch the distribution list selection off
1522 1522
 
1523 1523
 			$query['template'] = 'addressbook.index.org_rows';
1524 1524
 
@@ -1556,7 +1556,7 @@  discard block
 block discarded – undo
1556 1556
 			{
1557 1557
 				$query['template'] = $do_email ? 'addressbook.email.rows' : 'addressbook.index.rows';
1558 1558
 			}
1559
-			if($query['col_filter']['parent_id'])
1559
+			if ($query['col_filter']['parent_id'])
1560 1560
 			{
1561 1561
 				$query['org_view'] = $query['col_filter']['parent_id'];
1562 1562
 				$query['template'] = 'addressbook.index.org_rows';
@@ -1565,25 +1565,25 @@  discard block
 block discarded – undo
1565 1565
 			unset($query['col_filter']['parent_id']);
1566 1566
 			if ($query['org_view'])	// view the contacts of one organisation only
1567 1567
 			{
1568
-				if (strpos($query['org_view'],'*AND*') !== false) $query['org_view'] = str_replace('*AND*','&',$query['org_view']);
1569
-				foreach(explode('|||',$query['org_view']) as $part)
1568
+				if (strpos($query['org_view'], '*AND*') !== false) $query['org_view'] = str_replace('*AND*', '&', $query['org_view']);
1569
+				foreach (explode('|||', $query['org_view']) as $part)
1570 1570
 				{
1571
-					list($name,$value) = explode(':',$part,2);
1571
+					list($name, $value) = explode(':', $part, 2);
1572 1572
 					// do NOT set invalid column, as this gives an SQL error ("AND AND" in sql)
1573
-					if (in_array($name, array('org_name','org_unit','adr_one_location')))
1573
+					if (in_array($name, array('org_name', 'org_unit', 'adr_one_location')))
1574 1574
 					{
1575 1575
 						$query['col_filter'][$name] = $value;
1576 1576
 					}
1577 1577
 				}
1578 1578
 			}
1579
-			else if($query['actions'] && !$query['actions']['edit'])
1579
+			else if ($query['actions'] && !$query['actions']['edit'])
1580 1580
 			{
1581 1581
 				// Just switched from org view, update actions
1582 1582
 				$query['actions'] = $this->get_actions($query['col_filter']['tid'], $query['org_view']);
1583 1583
 			}
1584 1584
 			// translate the select order to the really used over all 3 columns
1585 1585
 			$sort = $query['sort'];
1586
-			switch($query['order'])		// "xxx<>'' DESC" sorts contacts with empty order-criteria always at the end
1586
+			switch ($query['order'])		// "xxx<>'' DESC" sorts contacts with empty order-criteria always at the end
1587 1587
 			{							// we don't exclude them, as the total would otherwise depend on the order-criteria
1588 1588
 				case 'org_name':
1589 1589
 					$order = "egw_addressbook.org_name<>''DESC,egw_addressbook.org_name $sort,n_family $sort,n_given $sort";
@@ -1617,8 +1617,8 @@  discard block
 block discarded – undo
1617 1617
 			}
1618 1618
 			if ($query['searchletter'])	// only show contacts if the order-criteria starts with the given letter
1619 1619
 			{
1620
-				$no_letter_search = array('adr_one_postalcode', 'adr_two_postalcode', 'contact_id', 'contact_created','contact_modified');
1621
-				$query['col_filter'][] = (in_array($query['order'],$no_letter_search) ? 'org_name' : (substr($query['order'],0,1)=='#'?'':'egw_addressbook.').$query['order']).' '.
1620
+				$no_letter_search = array('adr_one_postalcode', 'adr_two_postalcode', 'contact_id', 'contact_created', 'contact_modified');
1621
+				$query['col_filter'][] = (in_array($query['order'], $no_letter_search) ? 'org_name' : (substr($query['order'], 0, 1) == '#' ? '' : 'egw_addressbook.').$query['order']).' '.
1622 1622
 					$GLOBALS['egw']->db->capabilities['case_insensitive_like'].' '.$GLOBALS['egw']->db->quote(strtolower($query['searchletter']).'%');
1623 1623
 			}
1624 1624
 			$wildcard = '%';
@@ -1632,41 +1632,41 @@  discard block
 block discarded – undo
1632 1632
 				unset($query['advanced_search']['meth_select']);
1633 1633
 			}
1634 1634
 			//if ($do_email ) $email_only = array('id','owner','tid','n_fn','n_family','n_given','org_name','email','email_home');
1635
-			$rows = parent::search($query['advanced_search'] ? $query['advanced_search'] : $query['search'],$id_only,
1636
-				$order,'',$wildcard,false,$op,array((int)$query['start'],(int) $query['num_rows']),$query['col_filter']);
1635
+			$rows = parent::search($query['advanced_search'] ? $query['advanced_search'] : $query['search'], $id_only,
1636
+				$order, '', $wildcard, false, $op, array((int)$query['start'], (int)$query['num_rows']), $query['col_filter']);
1637 1637
 
1638 1638
 			// do we need to read the custom fields, depends on the column is enabled and customfields exist
1639 1639
 			// $query['csv_export'] allways needs to read ALL cf's
1640 1640
 			$columsel = $this->prefs['nextmatch-addressbook.'.($do_email ? 'email' : 'index').'.rows'];
1641
-			$available_distib_lists=$this->get_lists(Acl::READ);
1642
-			$columselection = $columsel && !$query['csv_export'] ? explode(',',$columsel) : array();
1641
+			$available_distib_lists = $this->get_lists(Acl::READ);
1642
+			$columselection = $columsel && !$query['csv_export'] ? explode(',', $columsel) : array();
1643 1643
 			$ids = $calendar_participants = array();
1644 1644
 			if (!$id_only && $rows)
1645 1645
 			{
1646
-				$show_custom_fields = (!$columselection || in_array('customfields',$columselection) || $query['csv_export']) && $this->customfields;
1647
-				$show_calendar = !$columselection || in_array('calendar_calendar',$columselection);
1648
-				$show_distributionlist = !$columselection || in_array('distrib_lists',$columselection) || count($available_distib_lists);
1646
+				$show_custom_fields = (!$columselection || in_array('customfields', $columselection) || $query['csv_export']) && $this->customfields;
1647
+				$show_calendar = !$columselection || in_array('calendar_calendar', $columselection);
1648
+				$show_distributionlist = !$columselection || in_array('distrib_lists', $columselection) || count($available_distib_lists);
1649 1649
 				if ($show_calendar || $show_custom_fields || $show_distributionlist)
1650 1650
 				{
1651
-					foreach($rows as $val)
1651
+					foreach ($rows as $val)
1652 1652
 					{
1653 1653
 						$ids[] = $val['id'];
1654 1654
 						$calendar_participants[$val['id']] = $val['account_id'] ? $val['account_id'] : 'c'.$val['id'];
1655 1655
 					}
1656 1656
 					if ($show_custom_fields)
1657 1657
 					{
1658
-						foreach($columselection as $col)
1658
+						foreach ($columselection as $col)
1659 1659
 						{
1660
-							if ($col[0] == '#') $selected_cfs[] = substr($col,1);
1660
+							if ($col[0] == '#') $selected_cfs[] = substr($col, 1);
1661 1661
 						}
1662
-						$customfields = $this->read_customfields($ids,$selected_cfs);
1662
+						$customfields = $this->read_customfields($ids, $selected_cfs);
1663 1663
 					}
1664 1664
 					if ($show_calendar && !empty($ids)) $calendar = $this->read_calendar($calendar_participants);
1665 1665
 					// distributionlist memership for the entrys
1666 1666
 					//_debug_array($this->get_lists(Acl::EDIT));
1667 1667
 					if ($show_distributionlist && $available_distib_lists)
1668 1668
 					{
1669
-						$distributionlist = $this->read_distributionlist($ids,array_keys($available_distib_lists));
1669
+						$distributionlist = $this->read_distributionlist($ids, array_keys($available_distib_lists));
1670 1670
 					}
1671 1671
 				}
1672 1672
 			}
@@ -1675,20 +1675,20 @@  discard block
 block discarded – undo
1675 1675
 
1676 1676
 		if ($id_only)
1677 1677
 		{
1678
-			foreach($rows as $n => $row)
1678
+			foreach ($rows as $n => $row)
1679 1679
 			{
1680 1680
 				$rows[$n] = $row['id'];
1681 1681
 			}
1682
-			return $this->total;	// no need to set other fields or $readonlys
1682
+			return $this->total; // no need to set other fields or $readonlys
1683 1683
 		}
1684 1684
 		$order = $query['order'];
1685 1685
 
1686 1686
 		$readonlys = array();
1687
-		foreach($rows as $n => &$row)
1687
+		foreach ($rows as $n => &$row)
1688 1688
 		{
1689 1689
 			$given = $row['n_given'] ? $row['n_given'] : ($row['n_prefix'] ? $row['n_prefix'] : '');
1690 1690
 
1691
-			switch($order)
1691
+			switch ($order)
1692 1692
 			{
1693 1693
 				default:	// postalcode, created, modified, ...
1694 1694
 				case 'org_name':
@@ -1705,38 +1705,38 @@  discard block
 block discarded – undo
1705 1705
 					break;
1706 1706
 				case 'n_fileas':
1707 1707
 					if (!$row['n_fileas']) $row['n_fileas'] = $this->fileas($row);
1708
-					list($row['line1'],$row['line2']) = explode(': ',$row['n_fileas']);
1708
+					list($row['line1'], $row['line2']) = explode(': ', $row['n_fileas']);
1709 1709
 					break;
1710 1710
 			}
1711
-			if (isset($this->org_views[(string) $query['org_view']]))
1711
+			if (isset($this->org_views[(string)$query['org_view']]))
1712 1712
 			{
1713 1713
 				$row['type'] = 'home';
1714 1714
 				$row['type_label'] = lang('Organisation');
1715 1715
 
1716
-				if ($query['filter'] && !($this->grants[(int)$query['filter']] & Acl::DELETE))
1716
+				if ($query['filter'] && !($this->grants[(int)$query['filter']]&Acl::DELETE))
1717 1717
 				{
1718 1718
 					$row['class'] .= 'rowNoDelete ';
1719 1719
 				}
1720
-				$row['class'] .= 'rowNoEdit ';	// no edit in OrgView
1720
+				$row['class'] .= 'rowNoEdit '; // no edit in OrgView
1721 1721
 				$row['class'] .= 'contact_organisation ';
1722 1722
 			}
1723 1723
 			else
1724 1724
 			{
1725
-				$this->type_icon($row['owner'],$row['private'],$row['tid'],$row['type'],$row['type_label']);
1725
+				$this->type_icon($row['owner'], $row['private'], $row['tid'], $row['type'], $row['type_label']);
1726 1726
 
1727
-				static $tel2show = array('tel_work','tel_cell','tel_home','tel_fax');
1727
+				static $tel2show = array('tel_work', 'tel_cell', 'tel_home', 'tel_fax');
1728 1728
 				static $prefer_marker = null;
1729 1729
 				if (is_null($prefer_marker))
1730 1730
 				{
1731 1731
 					// as et2 adds options with .text(), it can't be entities, but php knows no string literals with utf-8
1732 1732
 					$prefer_marker = html_entity_decode(' &#9734;', ENT_NOQUOTES, 'utf-8');
1733 1733
 				}
1734
-				foreach($tel2show as $name)
1734
+				foreach ($tel2show as $name)
1735 1735
 				{
1736
-					$row[$name] .= ' '.($row['tel_prefer'] == $name ? $prefer_marker : '');		// .' ' to NOT remove the field
1736
+					$row[$name] .= ' '.($row['tel_prefer'] == $name ? $prefer_marker : ''); // .' ' to NOT remove the field
1737 1737
 				}
1738 1738
 				// allways show the prefered phone, if not already shown
1739
-				if (!in_array($row['tel_prefer'],$tel2show) && $row[$row['tel_prefer']])
1739
+				if (!in_array($row['tel_prefer'], $tel2show) && $row[$row['tel_prefer']])
1740 1740
 				{
1741 1741
 					$row['tel_prefered'] = $row[$row['tel_prefer']].$prefer_marker;
1742 1742
 				}
@@ -1744,33 +1744,33 @@  discard block
 block discarded – undo
1744 1744
 				{
1745 1745
 					$row['class'] .= 'rowAccount rowNoDelete ';
1746 1746
 				}
1747
-				elseif (!$this->check_perms(Acl::DELETE,$row) || (!$GLOBALS['egw_info']['user']['apps']['admin'] && $this->config['history'] != 'userpurge' && $query['col_filter']['tid'] == self::DELETED_TYPE))
1747
+				elseif (!$this->check_perms(Acl::DELETE, $row) || (!$GLOBALS['egw_info']['user']['apps']['admin'] && $this->config['history'] != 'userpurge' && $query['col_filter']['tid'] == self::DELETED_TYPE))
1748 1748
 				{
1749 1749
 					$row['class'] .= 'rowNoDelete ';
1750 1750
 				}
1751
-				if (!$this->check_perms(Acl::EDIT,$row))
1751
+				if (!$this->check_perms(Acl::EDIT, $row))
1752 1752
 				{
1753 1753
 					$row['class'] .= 'rowNoEdit ';
1754 1754
 				}
1755 1755
 				$row['class'] .= 'contact_contact ';
1756 1756
 
1757
-				unset($row['jpegphoto']);	// unused and messes up json encoding (not utf-8)
1757
+				unset($row['jpegphoto']); // unused and messes up json encoding (not utf-8)
1758 1758
 
1759 1759
 				if (isset($customfields[$row['id']]))
1760 1760
 				{
1761
-					foreach($this->customfields as $name => $data)
1761
+					foreach ($this->customfields as $name => $data)
1762 1762
 					{
1763 1763
 						$row['#'.$name] = $customfields[$row['id']]['#'.$name];
1764 1764
 					}
1765 1765
 				}
1766 1766
 				if (isset($distributionlist[$row['id']]))
1767 1767
 				{
1768
-					$row['distrib_lists'] = implode("\n",array_values($distributionlist[$row['id']]));
1768
+					$row['distrib_lists'] = implode("\n", array_values($distributionlist[$row['id']]));
1769 1769
 					//if ($show_distributionlist) $readonlys['distrib_lists'] =true;
1770 1770
 				}
1771 1771
 				if (isset($calendar[$calendar_participants[$row['id']]]))
1772 1772
 				{
1773
-					foreach($calendar[$calendar_participants[$row['id']]] as $name => $data)
1773
+					foreach ($calendar[$calendar_participants[$row['id']]] as $name => $data)
1774 1774
 					{
1775 1775
 						$row[$name] = $data;
1776 1776
 					}
@@ -1778,13 +1778,13 @@  discard block
 block discarded – undo
1778 1778
 			}
1779 1779
 
1780 1780
 			// hide region for address format 'postcode_city'
1781
-			if (($row['addr_format']  = $this->addr_format_by_country($row['adr_one_countryname']))=='postcode_city') unset($row['adr_one_region']);
1782
-			if (($row['addr_format2'] = $this->addr_format_by_country($row['adr_two_countryname']))=='postcode_city') unset($row['adr_two_region']);
1781
+			if (($row['addr_format']  = $this->addr_format_by_country($row['adr_one_countryname'])) == 'postcode_city') unset($row['adr_one_region']);
1782
+			if (($row['addr_format2'] = $this->addr_format_by_country($row['adr_two_countryname'])) == 'postcode_city') unset($row['adr_two_region']);
1783 1783
 
1784 1784
 			// respect category permissions
1785
-			if(!empty($row['cat_id']))
1785
+			if (!empty($row['cat_id']))
1786 1786
 			{
1787
-				$row['cat_id'] = $this->categories->check_list(Acl::READ,$row['cat_id']);
1787
+				$row['cat_id'] = $this->categories->check_list(Acl::READ, $row['cat_id']);
1788 1788
 			}
1789 1789
 		}
1790 1790
 		$rows['no_distribution_list'] = (bool)$query['filter2'];
@@ -1800,23 +1800,21 @@  discard block
 block discarded – undo
1800 1800
 		$header = array();
1801 1801
 		if ($query['filter'] !== '' && !isset($this->org_views[$query['org_view']]))
1802 1802
 		{
1803
-			$header[] = ($query['filter'] == '0' ? lang('accounts') :
1804
-				($GLOBALS['egw']->accounts->get_type($query['filter']) == 'g' ?
1805
-					lang('Group %1',$GLOBALS['egw']->accounts->id2name($query['filter'])) :
1806
-					Api\Accounts::username((int)$query['filter']).
1807
-						(substr($query['filter'],-1) == 'p' ? ' ('.lang('private').')' : '')));
1803
+			$header[] = ($query['filter'] == '0' ? lang('accounts') : ($GLOBALS['egw']->accounts->get_type($query['filter']) == 'g' ?
1804
+					lang('Group %1', $GLOBALS['egw']->accounts->id2name($query['filter'])) : Api\Accounts::username((int)$query['filter']).
1805
+						(substr($query['filter'], -1) == 'p' ? ' ('.lang('private').')' : '')));
1808 1806
 		}
1809 1807
 		if ($query['org_view'])
1810 1808
 		{
1811 1809
 			$header[] = $query['org_view_label'];
1812 1810
 			// Make sure option is there
1813
-			if(!array_key_exists($query['org_view'], $this->org_views))
1811
+			if (!array_key_exists($query['org_view'], $this->org_views))
1814 1812
 			{
1815 1813
 				$this->org_views += $this->_get_org_name($query['org_view']);
1816 1814
 				$rows['sel_options']['org_view'] = $this->org_views;
1817 1815
 			}
1818 1816
 		}
1819
-		if($query['advanced_search'])
1817
+		if ($query['advanced_search'])
1820 1818
 		{
1821 1819
 			$header[] = lang('Advanced search');
1822 1820
 		}
@@ -1827,11 +1825,11 @@  discard block
 block discarded – undo
1827 1825
 		if ($query['searchletter'])
1828 1826
 		{
1829 1827
 			$order = $order == 'n_given' ? lang('first name') : ($order == 'n_family' ? lang('last name') : lang('Organisation'));
1830
-			$header[] = lang("%1 starts with '%2'",$order,$query['searchletter']);
1828
+			$header[] = lang("%1 starts with '%2'", $order, $query['searchletter']);
1831 1829
 		}
1832 1830
 		if ($query['search'] && !$query['advanced_search']) // do not add that, if we have advanced search active
1833 1831
 		{
1834
-			$header[] = lang("Search for '%1'",$query['search']);
1832
+			$header[] = lang("Search for '%1'", $query['search']);
1835 1833
 		}
1836 1834
 		$GLOBALS['egw_info']['flags']['app_header'] = implode(': ', $header);
1837 1835
 
@@ -1847,7 +1845,7 @@  discard block
 block discarded – undo
1847 1845
 	 * @param string &$icon icon-name
1848 1846
 	 * @param string &$label translated label
1849 1847
 	 */
1850
-	function type_icon($owner,$private,$tid,&$icon,&$label)
1848
+	function type_icon($owner, $private, $tid, &$icon, &$label)
1851 1849
 	{
1852 1850
 		if (!$owner)
1853 1851
 		{
@@ -1862,7 +1860,7 @@  discard block
 block discarded – undo
1862 1860
 		elseif ($GLOBALS['egw']->accounts->get_type($owner) == 'g')
1863 1861
 		{
1864 1862
 			$icon = 'group';
1865
-			$label = lang('group %1',$GLOBALS['egw']->accounts->id2name($owner));
1863
+			$label = lang('group %1', $GLOBALS['egw']->accounts->id2name($owner));
1866 1864
 		}
1867 1865
 		else
1868 1866
 		{
@@ -1870,9 +1868,9 @@  discard block
 block discarded – undo
1870 1868
 			$label = $owner == $this->user ? lang('personal') : Api\Accounts::username($owner);
1871 1869
 		}
1872 1870
 		// show tid icon for tid!='n' AND only if one is defined
1873
-		if ($tid != 'n' && Api\Image::find('addressbook',$this->content_types[$tid]['name']))
1871
+		if ($tid != 'n' && Api\Image::find('addressbook', $this->content_types[$tid]['name']))
1874 1872
 		{
1875
-			$icon = Api\Image::find('addressbook',$this->content_types[$tid]['name']);
1873
+			$icon = Api\Image::find('addressbook', $this->content_types[$tid]['name']);
1876 1874
 		}
1877 1875
 
1878 1876
 		// Legacy - from when icons could be anywhere
@@ -1890,19 +1888,19 @@  discard block
 block discarded – undo
1890 1888
 	* @param int $_GET['contact_id'] contact_id mainly for popup use
1891 1889
 	* @param bool $_GET['makecp'] true if you want to copy the contact given by $_GET['contact_id']
1892 1890
 	*/
1893
-	function edit($content=null)
1891
+	function edit($content = null)
1894 1892
 	{
1895 1893
 		if (is_array($content))
1896 1894
 		{
1897 1895
 			list($button) = @each($content['button']);
1898 1896
 			unset($content['button']);
1899
-			$content['private'] = (int) ($content['owner'] && substr($content['owner'],-1) == 'p');
1900
-			$content['owner'] = (string) (int) $content['owner'];
1897
+			$content['private'] = (int)($content['owner'] && substr($content['owner'], -1) == 'p');
1898
+			$content['owner'] = (string)(int)$content['owner'];
1901 1899
 			$content['cat_id'] = $this->config['cat_tab'] === 'Tree' ? $content['cat_id_tree'] : $content['cat_id'];
1902 1900
 			if ($this->config['private_cf_tab']) $content = (array)$content['private_cfs'] + $content;
1903 1901
 			unset($content['private_cfs']);
1904 1902
 
1905
-			switch($button)
1903
+			switch ($button)
1906 1904
 			{
1907 1905
 				case 'save':
1908 1906
 				case 'apply':
@@ -1918,7 +1916,7 @@  discard block
 block discarded – undo
1918 1916
 					}
1919 1917
 					if (is_array($content['upload_photo']) && !empty($content['upload_photo']['tmp_name']) &&
1920 1918
 						$content['upload_photo']['tmp_name'] != 'none' &&
1921
-						($f = fopen($content['upload_photo']['tmp_name'],'r')))
1919
+						($f = fopen($content['upload_photo']['tmp_name'], 'r')))
1922 1920
 					{
1923 1921
 						$content['jpegphoto'] = $this->resize_photo($f);
1924 1922
 						fclose($f);
@@ -1935,12 +1933,12 @@  discard block
 block discarded – undo
1935 1933
 						$old_org_entry = $this->read($content['id']);
1936 1934
 						$old_fullname = ($old_org_entry['n_fn'] ? $old_org_entry['n_fn'] : parent::fullname($old_org_entry));
1937 1935
 					}
1938
-					if ( $content['n_fn'] != $fullname ||  $fullname != $old_fullname)
1936
+					if ($content['n_fn'] != $fullname || $fullname != $old_fullname)
1939 1937
 					{
1940 1938
 						unset($content['n_fn']);
1941 1939
 					}
1942 1940
 					// Country codes
1943
-					foreach(array('adr_one', 'adr_two') as $c_prefix)
1941
+					foreach (array('adr_one', 'adr_two') as $c_prefix)
1944 1942
 					{
1945 1943
 						if ($content[$c_prefix.'_countrycode'] == '-custom-')
1946 1944
 						{
@@ -1949,7 +1947,7 @@  discard block
 block discarded – undo
1949 1947
 					}
1950 1948
 					$content['msg'] = '';
1951 1949
 					$this->error = false;
1952
-					foreach((array)$content['pre_save_callbacks'] as $callback)
1950
+					foreach ((array)$content['pre_save_callbacks'] as $callback)
1953 1951
 					{
1954 1952
 						try {
1955 1953
 							if (($success_msg = call_user_func_array($callback, array(&$content))))
@@ -1959,7 +1957,7 @@  discard block
 block discarded – undo
1959 1957
 						}
1960 1958
 						catch (Exception $ex) {
1961 1959
 							$content['msg'] .= ($content['msg'] ? ', ' : '').$ex->getMessage();
1962
-							$button = 'apply';	// do not close dialog
1960
+							$button = 'apply'; // do not close dialog
1963 1961
 							$this->error = true;
1964 1962
 							break;
1965 1963
 						}
@@ -1972,7 +1970,7 @@  discard block
 block discarded – undo
1972 1970
 					{
1973 1971
 						$content['msg'] .= ($content['msg'] ? ', ' : '').lang('Contact saved');
1974 1972
 
1975
-						foreach((array)$content['post_save_callbacks'] as $callback)
1973
+						foreach ((array)$content['post_save_callbacks'] as $callback)
1976 1974
 						{
1977 1975
 							try {
1978 1976
 								if (($success_msg = call_user_func_array($callback, array(&$content))))
@@ -1980,58 +1978,58 @@  discard block
 block discarded – undo
1980 1978
 									$content['msg'] .= ', '.$success_msg;
1981 1979
 								}
1982 1980
 							}
1983
-							catch(Api\Exception\Redirect $r)
1981
+							catch (Api\Exception\Redirect $r)
1984 1982
 							{
1985 1983
 								// catch it to continue execution and rethrow it later
1986 1984
 							}
1987 1985
 							catch (Exception $ex) {
1988 1986
 								$content['msg'] .= ', '.$ex->getMessage();
1989
-								$button = 'apply';	// do not close dialog
1987
+								$button = 'apply'; // do not close dialog
1990 1988
 								$this->error = true;
1991 1989
 								break;
1992 1990
 							}
1993 1991
 						}
1994 1992
 
1995
-						if ($content['change_org'] && $old_org_entry && ($changed = $this->changed_fields($old_org_entry,$content,true)) &&
1996
-							($members = $this->org_similar($old_org_entry['org_name'],$changed)))
1993
+						if ($content['change_org'] && $old_org_entry && ($changed = $this->changed_fields($old_org_entry, $content, true)) &&
1994
+							($members = $this->org_similar($old_org_entry['org_name'], $changed)))
1997 1995
 						{
1998 1996
 							//foreach($changed as $name => $old_value) echo "<p>$name: '$old_value' --> '{$content[$name]}'</p>\n";
1999
-							list($changed_members,$changed_fields,$failed_members) = $this->change_org($old_org_entry['org_name'],$changed,$content,$members);
1997
+							list($changed_members, $changed_fields, $failed_members) = $this->change_org($old_org_entry['org_name'], $changed, $content, $members);
2000 1998
 							if ($changed_members)
2001 1999
 							{
2002
-								$content['msg'] .= ', '.lang('%1 fields in %2 other organisation member(s) changed',$changed_fields,$changed_members);
2000
+								$content['msg'] .= ', '.lang('%1 fields in %2 other organisation member(s) changed', $changed_fields, $changed_members);
2003 2001
 							}
2004 2002
 							if ($failed_members)
2005 2003
 							{
2006
-								$content['msg'] .= ', '.lang('failed to change %1 organisation member(s) (insufficent rights) !!!',$failed_members);
2004
+								$content['msg'] .= ', '.lang('failed to change %1 organisation member(s) (insufficent rights) !!!', $failed_members);
2007 2005
 							}
2008 2006
 						}
2009 2007
 					}
2010
-					elseif($this->error === true)
2008
+					elseif ($this->error === true)
2011 2009
 					{
2012 2010
 						$content['msg'] = lang('Error: the entry has been updated since you opened it for editing!').'<br />'.
2013
-							lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.','<a href="'.
2014
-								htmlspecialchars(Egw::link('/index.php',array(
2011
+							lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.', '<a href="'.
2012
+								htmlspecialchars(Egw::link('/index.php', array(
2015 2013
 									'menuaction' => 'addressbook.addressbook_ui.edit',
2016 2014
 									'contact_id' => $content['id'],
2017
-								))).'">','</a>');
2018
-						break;	// dont refresh the list
2015
+								))).'">', '</a>');
2016
+						break; // dont refresh the list
2019 2017
 					}
2020 2018
 					else
2021 2019
 					{
2022 2020
 						$content['msg'] = lang('Error saving the contact !!!').
2023 2021
 							($this->error ? ' '.$this->error : '');
2024
-						$button = 'apply';	// to not leave the dialog
2022
+						$button = 'apply'; // to not leave the dialog
2025 2023
 					}
2026 2024
 					// writing links for new entry, existing ones are handled by the widget itself
2027 2025
 					if ($links && $content['id'])
2028 2026
 					{
2029
-						Link::link('addressbook',$content['id'],$links);
2027
+						Link::link('addressbook', $content['id'], $links);
2030 2028
 					}
2031 2029
 					// Update client side global datastore
2032 2030
 					$response = Api\Json\Response::get();
2033 2031
 					$response->generic('data', array('uid' => 'addressbook::'.$content['id'], 'data' => $content));
2034
-					Framework::refresh_opener($content['msg'], 'addressbook', $content['id'],  $content['id'] ? 'edit' : 'add',
2032
+					Framework::refresh_opener($content['msg'], 'addressbook', $content['id'], $content['id'] ? 'edit' : 'add',
2035 2033
 						null, null, null, $this->error ? 'error' : 'success');
2036 2034
 
2037 2035
 					// re-throw redirect exception, if there's no error
@@ -2053,11 +2051,11 @@  discard block
 block discarded – undo
2053 2051
 
2054 2052
 				case 'delete':
2055 2053
 					$success = $failed = $action_msg = null;
2056
-					if($this->action('delete',array($content['id']),false,$success,$failed,$action_msg,'',$content['msg']))
2054
+					if ($this->action('delete', array($content['id']), false, $success, $failed, $action_msg, '', $content['msg']))
2057 2055
 					{
2058 2056
 						if ($GLOBALS['egw']->currentapp == 'addressbook')
2059 2057
 						{
2060
-							Framework::refresh_opener(lang('Contact deleted'), 'addressbook', $content['id'], 'delete' );
2058
+							Framework::refresh_opener(lang('Contact deleted'), 'addressbook', $content['id'], 'delete');
2061 2059
 							Framework::window_close();
2062 2060
 						}
2063 2061
 						else
@@ -2082,7 +2080,7 @@  discard block
 block discarded – undo
2082 2080
 			// new contact --> set some defaults
2083 2081
 			if ($contact_id && is_array($content = $this->read($contact_id)))
2084 2082
 			{
2085
-				$contact_id = $content['id'];	// it could have been: "account:$account_id"
2083
+				$contact_id = $content['id']; // it could have been: "account:$account_id"
2086 2084
 				if (!$this->check_perms(Acl::EDIT, $content))
2087 2085
 				{
2088 2086
 					$view = true;
@@ -2126,52 +2124,52 @@  discard block
 block discarded – undo
2126 2124
 				{
2127 2125
 					$content['owner'] = (string)$state['filter'];
2128 2126
 				}
2129
-				$content['private'] = (int) ($content['owner'] && substr($content['owner'],-1) == 'p');
2130
-				if ($content['owner'] === '' || !($this->grants[$content['owner'] = (string) (int) $content['owner']] & Acl::ADD))
2127
+				$content['private'] = (int)($content['owner'] && substr($content['owner'], -1) == 'p');
2128
+				if ($content['owner'] === '' || !($this->grants[$content['owner'] = (string)(int)$content['owner']]&Acl::ADD))
2131 2129
 				{
2132 2130
 					$content['owner'] = $this->default_addressbook;
2133 2131
 					$content['private'] = (int)$this->default_private;
2134 2132
 
2135
-					if (!($this->grants[$content['owner'] = (string) (int) $content['owner']] & Acl::ADD))
2133
+					if (!($this->grants[$content['owner'] = (string)(int)$content['owner']]&Acl::ADD))
2136 2134
 					{
2137
-						$content['owner'] = (string) $this->user;
2135
+						$content['owner'] = (string)$this->user;
2138 2136
 						$content['private'] = 0;
2139 2137
 					}
2140 2138
 				}
2141 2139
 				$new_type = array_keys($this->content_types);
2142 2140
 				// fetch active type to preset the type, if param typeid is not passed
2143
-				$active_tid = Api\Cache::getSession('addressbook','active_tid');
2141
+				$active_tid = Api\Cache::getSession('addressbook', 'active_tid');
2144 2142
 				if ($active_tid && strtoupper($active_tid) === 'D') unset($active_tid);
2145
-				$content['tid'] = $_GET['typeid'] ? $_GET['typeid'] : ($active_tid?$active_tid:$new_type[0]);
2146
-				foreach($this->get_contact_columns() as $field)
2143
+				$content['tid'] = $_GET['typeid'] ? $_GET['typeid'] : ($active_tid ? $active_tid : $new_type[0]);
2144
+				foreach ($this->get_contact_columns() as $field)
2147 2145
 				{
2148 2146
 					if ($_GET['presets'][$field])
2149 2147
 					{
2150
-						if ($field=='email'||$field=='email_home')
2148
+						if ($field == 'email' || $field == 'email_home')
2151 2149
 						{
2152
-							$singleAddress = imap_rfc822_parse_adrlist($_GET['presets'][$field],'');
2150
+							$singleAddress = imap_rfc822_parse_adrlist($_GET['presets'][$field], '');
2153 2151
 							//error_log(__METHOD__.__LINE__.' Address:'.$singleAddress[0]->mailbox."@".$singleAddress[0]->host.", ".$singleAddress[0]->personal);
2154
-							if (!(!is_array($singleAddress) || count($singleAddress)<1))
2152
+							if (!(!is_array($singleAddress) || count($singleAddress) < 1))
2155 2153
 							{
2156 2154
 								$content[$field] = $singleAddress[0]->mailbox."@".$singleAddress[0]->host;
2157 2155
 								if (!empty($singleAddress[0]->personal))
2158 2156
 								{
2159
-									if (strpos($singleAddress[0]->personal,',')===false)
2157
+									if (strpos($singleAddress[0]->personal, ',') === false)
2160 2158
 									{
2161
-										list($P_n_given,$P_n_family,$P_org_name)=explode(' ',$singleAddress[0]->personal,3);
2162
-										if (strlen(trim($P_n_given))>0) $content['n_given'] = trim($P_n_given);
2163
-										if (strlen(trim($P_n_family))>0) $content['n_family'] = trim($P_n_family);
2164
-										if (strlen(trim($P_org_name))>0) $content['org_name'] = trim($P_org_name);
2159
+										list($P_n_given, $P_n_family, $P_org_name) = explode(' ', $singleAddress[0]->personal, 3);
2160
+										if (strlen(trim($P_n_given)) > 0) $content['n_given'] = trim($P_n_given);
2161
+										if (strlen(trim($P_n_family)) > 0) $content['n_family'] = trim($P_n_family);
2162
+										if (strlen(trim($P_org_name)) > 0) $content['org_name'] = trim($P_org_name);
2165 2163
 									}
2166 2164
 									else
2167 2165
 									{
2168
-										list($P_n_family,$P_other)=explode(',',$singleAddress[0]->personal,2);
2169
-										if (strlen(trim($P_n_family))>0) $content['n_family'] = trim($P_n_family);
2170
-										if (strlen(trim($P_other))>0)
2166
+										list($P_n_family, $P_other) = explode(',', $singleAddress[0]->personal, 2);
2167
+										if (strlen(trim($P_n_family)) > 0) $content['n_family'] = trim($P_n_family);
2168
+										if (strlen(trim($P_other)) > 0)
2171 2169
 										{
2172
-											list($P_n_given,$P_org_name)=explode(',',$P_other,2);
2173
-											if (strlen(trim($P_n_given))>0) $content['n_given'] = trim($P_n_given);
2174
-											if (strlen(trim($P_org_name))>0) $content['org_name'] = trim($P_org_name);
2170
+											list($P_n_given, $P_org_name) = explode(',', $P_other, 2);
2171
+											if (strlen(trim($P_n_given)) > 0) $content['n_given'] = trim($P_n_given);
2172
+											if (strlen(trim($P_org_name)) > 0) $content['org_name'] = trim($P_org_name);
2175 2173
 										}
2176 2174
 									}
2177 2175
 								}
@@ -2189,13 +2187,13 @@  discard block
 block discarded – undo
2189 2187
 				}
2190 2188
 				if (isset($_GET['presets']))
2191 2189
 				{
2192
-					foreach(array('email','email_home','n_family','n_given','org_name') as $field)
2190
+					foreach (array('email', 'email_home', 'n_family', 'n_given', 'org_name') as $field)
2193 2191
 					{
2194 2192
 						if (!empty($content[$field]))
2195 2193
 						{
2196 2194
 							//Set the presets fields in content in order to be able to use them later in client side for checking duplication only on first time load
2197 2195
 							// after save/apply we unset them
2198
-							$content['presets_fields'][]= $field;
2196
+							$content['presets_fields'][] = $field;
2199 2197
 							break;
2200 2198
 						}
2201 2199
 					}
@@ -2207,12 +2205,12 @@  discard block
 block discarded – undo
2207 2205
 				//_debug_array($content);
2208 2206
 			}
2209 2207
 
2210
-			if ($_GET['msg']) $content['msg'] = strip_tags($_GET['msg']);	// dont allow HTML!
2208
+			if ($_GET['msg']) $content['msg'] = strip_tags($_GET['msg']); // dont allow HTML!
2211 2209
 
2212
-			if($content && $_GET['makecp'])	// copy the contact
2210
+			if ($content && $_GET['makecp'])	// copy the contact
2213 2211
 			{
2214 2212
 				$this->copy_contact($content);
2215
-				$content['msg'] = lang('%1 copied - the copy can now be edited', lang(Link::get_registry('addressbook','entry')));
2213
+				$content['msg'] = lang('%1 copied - the copy can now be edited', lang(Link::get_registry('addressbook', 'entry')));
2216 2214
 				$view = false;
2217 2215
 			}
2218 2216
 			else
@@ -2223,12 +2221,12 @@  discard block
 block discarded – undo
2223 2221
 			if (!$contact_id && isset($_REQUEST['link_app']) && isset($_REQUEST['link_id']) && !is_array($content['link_to']['to_id']))
2224 2222
 			{
2225 2223
 				$link_ids = is_array($_REQUEST['link_id']) ? $_REQUEST['link_id'] : array($_REQUEST['link_id']);
2226
-				foreach(is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app)
2224
+				foreach (is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app)
2227 2225
 				{
2228 2226
 					$link_id = $link_ids[$n];
2229
-					if (preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id))	// gard against XSS
2227
+					if (preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i', $link_app.':'.$link_id))	// gard against XSS
2230 2228
 					{
2231
-						Link::link('addressbook',$content['link_to']['to_id'],$link_app,$link_id);
2229
+						Link::link('addressbook', $content['link_to']['to_id'], $link_app, $link_id);
2232 2230
 					}
2233 2231
 				}
2234 2232
 			}
@@ -2236,8 +2234,8 @@  discard block
 block discarded – undo
2236 2234
 		if ($content['id'])
2237 2235
 		{
2238 2236
 			// last and next calendar date
2239
-			list(,$dates) = each($this->read_calendar(array($content['account_id'] ? $content['account_id'] : 'c'.$content['id']),false));
2240
-			if(is_array($dates)) $content += $dates;
2237
+			list(,$dates) = each($this->read_calendar(array($content['account_id'] ? $content['account_id'] : 'c'.$content['id']), false));
2238
+			if (is_array($dates)) $content += $dates;
2241 2239
 		}
2242 2240
 
2243 2241
 		// Registry has view_id as contact_id, so set it (custom fields uses it)
@@ -2248,7 +2246,7 @@  discard block
 block discarded – undo
2248 2246
 
2249 2247
 		// Avoid setting conflicts with private custom fields
2250 2248
 		$content['private_cfs'] = array();
2251
-		foreach(Api\Storage\Customfields::get('addressbook', true) as $name => $cf)
2249
+		foreach (Api\Storage\Customfields::get('addressbook', true) as $name => $cf)
2252 2250
 		{
2253 2251
 			if ($this->config['private_cf_tab'] && $cf['private'] && isset($content['#'.$name]))
2254 2252
 			{
@@ -2265,7 +2263,7 @@  discard block
 block discarded – undo
2265 2263
 		$content['addr_format2'] = $this->addr_format_by_country($content['adr_two_countryname']);
2266 2264
 
2267 2265
 		//_debug_array($content);
2268
-		$readonlys['button[delete]'] = !$content['owner'] || !$this->check_perms(Acl::DELETE,$content);
2266
+		$readonlys['button[delete]'] = !$content['owner'] || !$this->check_perms(Acl::DELETE, $content);
2269 2267
 		$readonlys['button[copy]'] = $readonlys['button[edit]'] = $readonlys['button[vcard]'] = true;
2270 2268
 		$readonlys['button[save]'] = $readonlys['button[apply]'] = $view;
2271 2269
 		if ($view)
@@ -2277,19 +2275,18 @@  discard block
 block discarded – undo
2277 2275
 		$sel_options['fileas_type'] = $this->fileas_options($content);
2278 2276
 		$sel_options['adr_one_countrycode']['-custom-'] = lang('Custom');
2279 2277
 		$sel_options['owner'] = $this->get_addressbooks(Acl::ADD);
2280
-		if ($content['owner']) unset($sel_options['owner'][0]);	// do not offer to switch to accounts, as we do not support moving contacts to accounts
2281
-		if ((string) $content['owner'] !== '')
2278
+		if ($content['owner']) unset($sel_options['owner'][0]); // do not offer to switch to accounts, as we do not support moving contacts to accounts
2279
+		if ((string)$content['owner'] !== '')
2282 2280
 		{
2283 2281
 			if (!isset($sel_options['owner'][(int)$content['owner']]))
2284 2282
 			{
2285
-				$sel_options['owner'][(int)$content['owner']] = !$content['owner'] ? lang('Accounts') :
2286
-					Api\Accounts::username($content['owner']);
2283
+				$sel_options['owner'][(int)$content['owner']] = !$content['owner'] ? lang('Accounts') : Api\Accounts::username($content['owner']);
2287 2284
 			}
2288
-			$readonlys['owner'] = !$content['owner'] || 		// dont allow to move accounts, as this mean deleting the user incl. all content he owns
2289
-				$content['id'] && !$this->check_perms(Acl::DELETE,$content);	// you need delete rights to move an existing contact into an other addressbook
2285
+			$readonlys['owner'] = !$content['owner'] || // dont allow to move accounts, as this mean deleting the user incl. all content he owns
2286
+				$content['id'] && !$this->check_perms(Acl::DELETE, $content); // you need delete rights to move an existing contact into an other addressbook
2290 2287
 		}
2291 2288
 		// set the unsupported fields from the backend to readonly
2292
-		foreach($this->get_fields('unsupported',$content['id'],$content['owner']) as $field)
2289
+		foreach ($this->get_fields('unsupported', $content['id'], $content['owner']) as $field)
2293 2290
 		{
2294 2291
 			$readonlys[$field] = true;
2295 2292
 		}
@@ -2299,7 +2296,7 @@  discard block
 block discarded – undo
2299 2296
 			$readonlys['__ALL__'] = true;
2300 2297
 			$readonlys['button[cancel]'] = false;
2301 2298
 
2302
-			foreach($this->own_account_acl as $field)
2299
+			foreach ($this->own_account_acl as $field)
2303 2300
 			{
2304 2301
 				$readonlys[$field] = false;
2305 2302
 			}
@@ -2315,9 +2312,9 @@  discard block
 block discarded – undo
2315 2312
 		if (isset($readonlys['n_fileas'])) $readonlys['fileas_type'] = $readonlys['n_fileas'];
2316 2313
 		// disable not needed tabs
2317 2314
 		$readonlys['tabs']['cats'] = !($content['cat_tab'] = $this->config['cat_tab']);
2318
-		$readonlys['tabs']['custom'] = !$this->customfields || $this->get_backend($content['id'],$content['owner']) == $this->so_accounts;
2315
+		$readonlys['tabs']['custom'] = !$this->customfields || $this->get_backend($content['id'], $content['owner']) == $this->so_accounts;
2319 2316
 		$readonlys['tabs']['custom_private'] = $readonlys['tabs']['custom'] || !$this->config['private_cf_tab'] ? '__ALL__' : false;
2320
-		$readonlys['tabs']['distribution_list'] = !$content['distrib_lists'];#false;
2317
+		$readonlys['tabs']['distribution_list'] = !$content['distrib_lists']; #false;
2321 2318
 		$readonlys['tabs']['history'] = $this->contact_repository != 'sql' || !$content['id'] ||
2322 2319
 			$this->account_repository != 'sql' && $content['account_id'];
2323 2320
 		if (!$content['id']) $readonlys['button[delete]'] = !$content['id'];
@@ -2329,7 +2326,7 @@  discard block
 block discarded – undo
2329 2326
 		{
2330 2327
 			$this->_set_readonlys_for_own_account_acl($readonlys, $content['id']);
2331 2328
 		}
2332
-		for($i = -23; $i<=23; $i++)
2329
+		for ($i = -23; $i <= 23; $i++)
2333 2330
 		{
2334 2331
 			$tz[$i] = ($i > 0 ? '+' : '').$i;
2335 2332
 		}
@@ -2337,11 +2334,11 @@  discard block
 block discarded – undo
2337 2334
 		$content['tz'] = $content['tz'] ? $content['tz'] : '0';
2338 2335
 		if (count($this->content_types) > 1)
2339 2336
 		{
2340
-			foreach($this->content_types as $type => $data)
2337
+			foreach ($this->content_types as $type => $data)
2341 2338
 			{
2342 2339
 				$sel_options['tid'][$type] = $data['name'];
2343 2340
 			}
2344
-			$content['typegfx'] = Api\Html::image('addressbook',$this->content_types[$content['tid']]['options']['icon'],'',' width="16px" height="16px"');
2341
+			$content['typegfx'] = Api\Html::image('addressbook', $this->content_types[$content['tid']]['options']['icon'], '', ' width="16px" height="16px"');
2345 2342
 		}
2346 2343
 		else
2347 2344
 		{
@@ -2355,10 +2352,10 @@  discard block
 block discarded – undo
2355 2352
 		);
2356 2353
 
2357 2354
 		// Links for deleted entries
2358
-		if($content['tid'] == self::DELETED_TYPE)
2355
+		if ($content['tid'] == self::DELETED_TYPE)
2359 2356
 		{
2360 2357
 			$content['link_to']['show_deleted'] = true;
2361
-			if(!$GLOBALS['egw_info']['user']['apps']['admin'] && $this->config['history'] != 'userpurge')
2358
+			if (!$GLOBALS['egw_info']['user']['apps']['admin'] && $this->config['history'] != 'userpurge')
2362 2359
 			{
2363 2360
 				$readonlys['button[delete]'] = true;
2364 2361
 			}
@@ -2367,33 +2364,33 @@  discard block
 block discarded – undo
2367 2364
 		// Enable history
2368 2365
 		$this->setup_history($content, $sel_options);
2369 2366
 
2370
-		$content['photo'] = $this->photo_src($content['id'],$content['jpegphoto'],'photo',$content['etag']);
2367
+		$content['photo'] = $this->photo_src($content['id'], $content['jpegphoto'], 'photo', $content['etag']);
2371 2368
 
2372 2369
 		if ($content['private']) $content['owner'] .= 'p';
2373 2370
 
2374 2371
 		// for custom types, check if we have a custom edit template named "addressbook.edit.$type", $type is the name
2375
-		if (in_array($content['tid'], array('n',self::DELETED_TYPE)) || !$this->tmpl->read('addressbook.edit.'.$this->content_types[$content['tid']]['name']))
2372
+		if (in_array($content['tid'], array('n', self::DELETED_TYPE)) || !$this->tmpl->read('addressbook.edit.'.$this->content_types[$content['tid']]['name']))
2376 2373
 		{
2377 2374
 			$this->tmpl->read('addressbook.edit');
2378 2375
 		}
2379 2376
 
2380 2377
 		// allow other apps to add tabs to addressbook edit
2381 2378
 		$preserve = $content;
2382
-		$content['jpegphoto'] = !empty($content['jpegphoto']);	// unused and messes up json encoding (not utf-8)
2379
+		$content['jpegphoto'] = !empty($content['jpegphoto']); // unused and messes up json encoding (not utf-8)
2383 2380
 		$this->tmpl->setElementAttribute('tabs', 'add_tabs', true);
2384
-		$tabs =& $this->tmpl->getElementAttribute('tabs', 'tabs');
2381
+		$tabs = & $this->tmpl->getElementAttribute('tabs', 'tabs');
2385 2382
 		if (($first_call = !isset($tabs)))
2386 2383
 		{
2387 2384
 			$tabs = array();
2388 2385
 		}
2389 2386
 		//error_log(__LINE__.': '.__METHOD__."() first_call=$first_call");
2390
-		$hook_data = Api\Hooks::process(array('location' => 'addressbook_edit')+$content);
2387
+		$hook_data = Api\Hooks::process(array('location' => 'addressbook_edit') + $content);
2391 2388
 		//error_log(__METHOD__."() hook_data=".array2string($hook_data));
2392
-		foreach($hook_data as $extra_tabs)
2389
+		foreach ($hook_data as $extra_tabs)
2393 2390
 		{
2394 2391
 			if (!$extra_tabs) continue;
2395 2392
 
2396
-			foreach(isset($extra_tabs[0]) ? $extra_tabs : array($extra_tabs) as $extra_tab)
2393
+			foreach (isset($extra_tabs[0]) ? $extra_tabs : array($extra_tabs) as $extra_tab)
2397 2394
 			{
2398 2395
 				if ($extra_tab['data'] && is_array($extra_tab['data']))
2399 2396
 				{
@@ -2438,15 +2435,15 @@  discard block
 block discarded – undo
2438 2435
 	 * @param array &$readonlys
2439 2436
 	 * @param int $id
2440 2437
 	 */
2441
-	function _set_readonlys_for_own_account_acl(&$readonlys,$id)
2438
+	function _set_readonlys_for_own_account_acl(&$readonlys, $id)
2442 2439
 	{
2443 2440
 		// regular fields depending on the backend
2444
-		foreach($this->get_fields('supported',$id,0) as $field)
2441
+		foreach ($this->get_fields('supported', $id, 0) as $field)
2445 2442
 		{
2446
-			if (!$this->own_account_acl || !in_array($field,$this->own_account_acl))
2443
+			if (!$this->own_account_acl || !in_array($field, $this->own_account_acl))
2447 2444
 			{
2448 2445
 				$readonlys[$field] = true;
2449
-				switch($field)
2446
+				switch ($field)
2450 2447
 				{
2451 2448
 					case 'tel_work':
2452 2449
 					case 'tel_cell':
@@ -2462,16 +2459,16 @@  discard block
 block discarded – undo
2462 2459
 		// custom fields
2463 2460
 		if ($this->customfields)
2464 2461
 		{
2465
-			foreach(array_keys($this->customfields) as $name)
2462
+			foreach (array_keys($this->customfields) as $name)
2466 2463
 			{
2467
-				if (!$this->own_account_acl || !in_array('#'.$name,$this->own_account_acl))
2464
+				if (!$this->own_account_acl || !in_array('#'.$name, $this->own_account_acl))
2468 2465
 				{
2469 2466
 					$readonlys['#'.$name] = true;
2470 2467
 				}
2471 2468
 			}
2472 2469
 		}
2473 2470
 		// links
2474
-		if (!$this->own_account_acl || !in_array('link_to',$this->own_account_acl))
2471
+		if (!$this->own_account_acl || !in_array('link_to', $this->own_account_acl))
2475 2472
 		{
2476 2473
 			$readonlys['link_to'] = true;
2477 2474
 		}
@@ -2489,10 +2486,10 @@  discard block
 block discarded – undo
2489 2486
 	 * 	'data' => array of id => "full name (addressbook)" pairs
2490 2487
 	 *  'fileas_options'
2491 2488
 	 */
2492
-	public function ajax_check_values($values, $name, $own_id=0)
2489
+	public function ajax_check_values($values, $name, $own_id = 0)
2493 2490
 	{
2494 2491
 		$matches = null;
2495
-		if (preg_match('/^exec\[([^\]]+)\]$/', $name, $matches)) $name = $matches[1];	// remove exec[ ]
2492
+		if (preg_match('/^exec\[([^\]]+)\]$/', $name, $matches)) $name = $matches[1]; // remove exec[ ]
2496 2493
 
2497 2494
 		$ret = array('doublicates' => array(), 'msg' => null);
2498 2495
 
@@ -2516,10 +2513,10 @@  discard block
 block discarded – undo
2516 2513
 
2517 2514
 			// if name, firstname or org changed and at least 2 are specified, check for doublicates
2518 2515
 			if (in_array($name, array('n_given', 'n_family', 'org_name')) &&
2519
-				!empty($values['n_given'])+!empty($values['n_family'])+!empty($values['org_name']) >= 2)
2516
+				!empty($values['n_given']) + !empty($values['n_family']) + !empty($values['org_name']) >= 2)
2520 2517
 			{
2521 2518
 				$filter = array();
2522
-				foreach(array('email', 'n_given', 'n_family', 'org_name') as $n)	// use email too, to exclude obvious false positives
2519
+				foreach (array('email', 'n_given', 'n_family', 'org_name') as $n)	// use email too, to exclude obvious false positives
2523 2520
 				{
2524 2521
 					if (!empty($values[$n])) $filter[$n] = $values[$n];
2525 2522
 				}
@@ -2528,7 +2525,7 @@  discard block
 block discarded – undo
2528 2525
 		}
2529 2526
 		if ($contacts)
2530 2527
 		{
2531
-			foreach($contacts as $contact)
2528
+			foreach ($contacts as $contact)
2532 2529
 			{
2533 2530
 				if ($own_id && $contact['id'] == $own_id) continue;
2534 2531
 
@@ -2552,26 +2549,24 @@  discard block
 block discarded – undo
2552 2549
 	 *
2553 2550
 	 * @param array $content
2554 2551
 	 */
2555
-	function view(array $content=null)
2552
+	function view(array $content = null)
2556 2553
 	{
2557 2554
 		// CRM list comes from content, request, or preference
2558
-		$crm_list = $content['crm_list'] ? $content['crm_list'] :
2559
-			($_GET['crm_list'] ? $_GET['crm_list'] : $GLOBALS['egw_info']['user']['preferences']['addressbook']['crm_list']);
2560
-		if(!$crm_list || $crm_list == '~edit~') $crm_list = 'infolog';
2555
+		$crm_list = $content['crm_list'] ? $content['crm_list'] : ($_GET['crm_list'] ? $_GET['crm_list'] : $GLOBALS['egw_info']['user']['preferences']['addressbook']['crm_list']);
2556
+		if (!$crm_list || $crm_list == '~edit~') $crm_list = 'infolog';
2561 2557
 
2562
-		if(is_array($content))
2558
+		if (is_array($content))
2563 2559
 		{
2564 2560
 			list($button) = each($content['button']);
2565 2561
 			switch ($content['toolbar'] ? $content['toolbar'] : $button)
2566 2562
 			{
2567
-				case 'vcard':
2568
-					Egw::redirect_link('/index.php','menuaction=addressbook.uivcard.out&ab_id=' .$content['id']);
2563
+				case 'vcard' : Egw::redirect_link('/index.php', 'menuaction=addressbook.uivcard.out&ab_id='.$content['id']);
2569 2564
 
2570 2565
 				case 'cancel':
2571
-					Egw::redirect_link('/index.php','menuaction=addressbook.addressbook_ui.index&ajax=true');
2566
+					Egw::redirect_link('/index.php', 'menuaction=addressbook.addressbook_ui.index&ajax=true');
2572 2567
 
2573 2568
 				case 'delete':
2574
-					Egw::redirect_link('/index.php',array(
2569
+					Egw::redirect_link('/index.php', array(
2575 2570
 						'menuaction' => 'addressbook.addressbook_ui.index',
2576 2571
 						'msg' => $this->delete($content) ? lang('Contact deleted') : lang('Error deleting the contact !!!'),
2577 2572
 					));
@@ -2589,9 +2584,9 @@  discard block
 block discarded – undo
2589 2584
 					$num_rows = $this->get_rows($query, $rows, $readonlys, true);
2590 2585
 					//error_log(__METHOD__."() get_rows()=$num_rows rows=".array2string($rows));
2591 2586
 					$contact_id = $rows[0];
2592
-					if(!$contact_id || !is_array($content = $this->read($contact_id)))
2587
+					if (!$contact_id || !is_array($content = $this->read($contact_id)))
2593 2588
 					{
2594
-						Egw::redirect_link('/index.php',array(
2589
+						Egw::redirect_link('/index.php', array(
2595 2590
 							'menuaction' => 'addressbook.addressbook_ui.index',
2596 2591
 							'msg' => $content,
2597 2592
 							'ajax' => 'true'
@@ -2600,14 +2595,14 @@  discard block
 block discarded – undo
2600 2595
 					$content['index'] = $query['start'];
2601 2596
 
2602 2597
 					// List nextmatch is already there, just update the filter
2603
-					if($contact_id && Api\Json\Request::isJSONRequest())
2598
+					if ($contact_id && Api\Json\Request::isJSONRequest())
2604 2599
 					{
2605
-						switch($crm_list)
2600
+						switch ($crm_list)
2606 2601
 						{
2607 2602
 							case 'infolog':
2608 2603
 							case 'tracker':
2609 2604
 							default:
2610
-								Api\Json\Response::get()->apply('app.addressbook.view_set_list',Array(Array('action'=>'addressbook', 'action_id' => $contact_id)));
2605
+								Api\Json\Response::get()->apply('app.addressbook.view_set_list', Array(Array('action'=>'addressbook', 'action_id' => $contact_id)));
2611 2606
 								break;
2612 2607
 						}
2613 2608
 
@@ -2638,13 +2633,13 @@  discard block
 block discarded – undo
2638 2633
 				$_GET['index'] = 0;
2639 2634
 			}
2640 2635
 			$contact_id = $_GET['contact_id'] ? $_GET['contact_id'] : ((int)$_GET['account_id'] ? 'account:'.(int)$_GET['account_id'] : 0);
2641
-			if(!$contact_id || !is_array($content = $this->read($contact_id)))
2636
+			if (!$contact_id || !is_array($content = $this->read($contact_id)))
2642 2637
 			{
2643
-				Egw::redirect_link('/index.php',array(
2638
+				Egw::redirect_link('/index.php', array(
2644 2639
 					'menuaction' => 'addressbook.addressbook_ui.index',
2645 2640
 					'msg' => $content,
2646 2641
 					'ajax' => 'true'
2647
-				)+(isset($_GET['search']) ? array('search' => $_GET['search']) : array()));
2642
+				) + (isset($_GET['search']) ? array('search' => $_GET['search']) : array()));
2648 2643
 			}
2649 2644
 			if (isset($_GET['index']))
2650 2645
 			{
@@ -2657,25 +2652,25 @@  discard block
 block discarded – undo
2657 2652
 				$num_rows = $this->get_rows($query, $rows, $readonlys, true);
2658 2653
 			}
2659 2654
 		}
2660
-		$content['jpegphoto'] = !empty($content['jpegphoto']);	// unused and messes up json encoding (not utf-8)
2655
+		$content['jpegphoto'] = !empty($content['jpegphoto']); // unused and messes up json encoding (not utf-8)
2661 2656
 
2662 2657
 		// make everything not explicit mentioned readonly
2663 2658
 		$readonlys['__ALL__'] = true;
2664 2659
 		$readonlys['photo'] = $readonlys['button[cancel]'] = $readonlys['button[copy]'] =
2665 2660
 			$readonlys['button[ok]'] = $readonlys['button[more]'] = $readonlys['toolbar'] = false;
2666 2661
 
2667
-		foreach(array_keys($this->contact_fields) as $key)
2662
+		foreach (array_keys($this->contact_fields) as $key)
2668 2663
 		{
2669
-			if (in_array($key,array('tel_home','tel_work','tel_cell','tel_fax')))
2664
+			if (in_array($key, array('tel_home', 'tel_work', 'tel_cell', 'tel_fax')))
2670 2665
 			{
2671 2666
 				$content[$key.'2'] = $content[$key];
2672 2667
 			}
2673 2668
 		}
2674 2669
 
2675 2670
 		// respect category permissions
2676
-		if(!empty($content['cat_id']))
2671
+		if (!empty($content['cat_id']))
2677 2672
 		{
2678
-			$content['cat_id'] = $this->categories->check_list(Acl::READ,$content['cat_id']);
2673
+			$content['cat_id'] = $this->categories->check_list(Acl::READ, $content['cat_id']);
2679 2674
 		}
2680 2675
 		$content['cat_id_tree'] = $content['cat_id'];
2681 2676
 
@@ -2685,12 +2680,12 @@  discard block
 block discarded – undo
2685 2680
 			'to_id'  => $content['id'],
2686 2681
 		);
2687 2682
 		// Links for deleted entries
2688
-		if($content['tid'] == self::DELETED_TYPE)
2683
+		if ($content['tid'] == self::DELETED_TYPE)
2689 2684
 		{
2690 2685
 			$content['link_to']['show_deleted'] = true;
2691 2686
 		}
2692
-		$readonlys['button[delete]'] = !$content['owner'] || !$this->check_perms(Acl::DELETE,$content);
2693
-		$readonlys['button[edit]'] = !$this->check_perms(Acl::EDIT,$content);
2687
+		$readonlys['button[delete]'] = !$content['owner'] || !$this->check_perms(Acl::DELETE, $content);
2688
+		$readonlys['button[edit]'] = !$this->check_perms(Acl::EDIT, $content);
2694 2689
 
2695 2690
 		// how to display addresses
2696 2691
 		$content['addr_format']  = $this->addr_format_by_country($content['adr_one_countryname']);
@@ -2698,7 +2693,7 @@  discard block
 block discarded – undo
2698 2693
 
2699 2694
 		$sel_options['fileas_type'][$content['fileas_type']] = $this->fileas($content);
2700 2695
 		$sel_options['owner'] = $this->get_addressbooks();
2701
-		for($i = -23; $i<=23; $i++)
2696
+		for ($i = -23; $i <= 23; $i++)
2702 2697
 		{
2703 2698
 			$tz[$i] = ($i > 0 ? '+' : '').$i;
2704 2699
 		}
@@ -2706,11 +2701,11 @@  discard block
 block discarded – undo
2706 2701
 		$content['tz'] = $content['tz'] ? $content['tz'] : 0;
2707 2702
 		if (count($this->content_types) > 1)
2708 2703
 		{
2709
-			foreach($this->content_types as $type => $data)
2704
+			foreach ($this->content_types as $type => $data)
2710 2705
 			{
2711 2706
 				$sel_options['tid'][$type] = $data['name'];
2712 2707
 			}
2713
-			$content['typegfx'] = Api\Html::image('addressbook',$this->content_types[$content['tid']]['options']['icon'],'',' width="16px" height="16px"');
2708
+			$content['typegfx'] = Api\Html::image('addressbook', $this->content_types[$content['tid']]['options']['icon'], '', ' width="16px" height="16px"');
2714 2709
 		}
2715 2710
 		else
2716 2711
 		{
@@ -2727,7 +2722,7 @@  discard block
 block discarded – undo
2727 2722
 		{
2728 2723
 			$content['owner'] .= 'p';
2729 2724
 		}
2730
-		$this->tmpl->set_cell_attribute('change_org','disabled',true);
2725
+		$this->tmpl->set_cell_attribute('change_org', 'disabled', true);
2731 2726
 
2732 2727
 		// Prevent double countries - invalid code blanks it, disabling doesn't work
2733 2728
 		$content['adr_one_countrycode'] = '-';
@@ -2740,14 +2735,14 @@  discard block
 block discarded – undo
2740 2735
 		$readonlys['tabs']['cats'] = !($content['cat_tab'] = $this->config['cat_tab']);
2741 2736
 		$readonlys['tabs']['custom'] = !$this->customfields;
2742 2737
 		$readonlys['tabs']['custom_private'] = !$this->customfields || !$this->config['private_cf_tab'];
2743
-		$readonlys['tabs']['distribution_list'] = !$content['distrib_lists'];#false;
2738
+		$readonlys['tabs']['distribution_list'] = !$content['distrib_lists']; #false;
2744 2739
 		$readonlys['tabs']['history'] = $this->contact_repository != 'sql' || !$content['id'] ||
2745 2740
 			$this->account_repository != 'sql' && $content['account_id'];
2746 2741
 		if ($this->config['private_cf_tab']) $content['no_private_cfs'] = 0;
2747 2742
 
2748 2743
 		// last and next calendar date
2749
-		if (!empty($content['id'])) list(,$dates) = each($this->read_calendar(array($content['account_id'] ? $content['account_id'] : 'c'.$content['id']),false));
2750
-		if(is_array($dates)) $content += $dates;
2744
+		if (!empty($content['id'])) list(,$dates) = each($this->read_calendar(array($content['account_id'] ? $content['account_id'] : 'c'.$content['id']), false));
2745
+		if (is_array($dates)) $content += $dates;
2751 2746
 
2752 2747
 		// Disable importexport
2753 2748
 		$GLOBALS['egw_info']['flags']['disable_importexport']['export'] = true;
@@ -2789,7 +2784,7 @@  discard block
 block discarded – undo
2789 2784
 		{
2790 2785
 			unset($actions['back']);
2791 2786
 		}
2792
-		if (!isset($content['index']) || $content['index'] >= $num_rows-1)
2787
+		if (!isset($content['index']) || $content['index'] >= $num_rows - 1)
2793 2788
 		{
2794 2789
 			unset($actions['next']);
2795 2790
 		}
@@ -2801,7 +2796,7 @@  discard block
 block discarded – undo
2801 2796
 		// need to load list's app.js now, as exec calls header before other app can include it
2802 2797
 		Framework::includeJS('/'.$crm_list.'/js/app.js');
2803 2798
 
2804
-		$this->tmpl->exec('addressbook.addressbook_ui.view',$content,$sel_options,$readonlys,array(
2799
+		$this->tmpl->exec('addressbook.addressbook_ui.view', $content, $sel_options, $readonlys, array(
2805 2800
 			'id' => $content['id'],
2806 2801
 			'index' => $content['index'],
2807 2802
 			'crm_list' => $crm_list
@@ -2809,12 +2804,12 @@  discard block
 block discarded – undo
2809 2804
 
2810 2805
 		// Only load this on first time - we're using AJAX, so it stays there through submits.
2811 2806
 		// Sending it again (via ajax) will break the addressbook.view etemplate2
2812
-		if($contact_id)
2807
+		if ($contact_id)
2813 2808
 		{
2814 2809
 			Api\Hooks::single(array(
2815 2810
 				'location' => 'addressbook_view',
2816 2811
 				'ab_id'    => $content['id']
2817
-			),$crm_list);
2812
+			), $crm_list);
2818 2813
 		}
2819 2814
 	}
2820 2815
 
@@ -2826,30 +2821,30 @@  discard block
 block discarded – undo
2826 2821
 	 */
2827 2822
 	function email2link($email)
2828 2823
 	{
2829
-		if (strpos($email,'@') == false) return '';
2824
+		if (strpos($email, '@') == false) return '';
2830 2825
 
2831
-		if($GLOBALS['egw_info']['user']['apps']['mail'])
2826
+		if ($GLOBALS['egw_info']['user']['apps']['mail'])
2832 2827
 		{
2833 2828
 			return array(
2834 2829
 				'menuaction' => 'mail.mail_compose.compose',
2835 2830
 				'send_to'    => base64_encode($email)
2836 2831
 			);
2837 2832
 		}
2838
-		if($GLOBALS['egw_info']['user']['apps']['felamimail'])
2833
+		if ($GLOBALS['egw_info']['user']['apps']['felamimail'])
2839 2834
 		{
2840 2835
 			return array(
2841 2836
 				'menuaction' => 'felamimail.uicompose.compose',
2842 2837
 				'send_to'    => base64_encode($email)
2843 2838
 			);
2844 2839
 		}
2845
-		if($GLOBALS['egw_info']['user']['apps']['email'])
2840
+		if ($GLOBALS['egw_info']['user']['apps']['email'])
2846 2841
 		{
2847 2842
 			return array(
2848 2843
 				'menuaction' => 'email.uicompose.compose',
2849 2844
 				'to' => $email,
2850 2845
 			);
2851 2846
 		}
2852
-		return 'mailto:' . $email;
2847
+		return 'mailto:'.$email;
2853 2848
 	}
2854 2849
 
2855 2850
 	/**
@@ -2858,9 +2853,9 @@  discard block
 block discarded – undo
2858 2853
 	 * @param array $_content
2859 2854
 	 * @return string
2860 2855
 	 */
2861
-	function search($_content=array())
2856
+	function search($_content = array())
2862 2857
 	{
2863
-		if(!empty($_content))
2858
+		if (!empty($_content))
2864 2859
 		{
2865 2860
 
2866 2861
 			$_content['cat_id'] = $this->config['cat_tab'] === 'Tree' ? $_content['cat_id_tree'] : $_content['cat_id'];
@@ -2875,10 +2870,10 @@  discard block
 block discarded – undo
2875 2870
 			}
2876 2871
 			else
2877 2872
 			{
2878
-				$query['advanced_search'] = array_intersect_key($_content,array_flip(array_merge($this->get_contact_columns(),array('operator','meth_select'))));
2873
+				$query['advanced_search'] = array_intersect_key($_content, array_flip(array_merge($this->get_contact_columns(), array('operator', 'meth_select'))));
2879 2874
 				foreach ($query['advanced_search'] as $key => $value)
2880 2875
 				{
2881
-					if(!$value) unset($query['advanced_search'][$key]);
2876
+					if (!$value) unset($query['advanced_search'][$key]);
2882 2877
 				}
2883 2878
 				// Skip n_fn, it causes problems in sql
2884 2879
 				unset($query['advanced_search']['n_fn']);
@@ -2894,7 +2889,7 @@  discard block
 block discarded – undo
2894 2889
 			$response->call("app.addressbook.adv_search", array('advanced_search' => $_content['button']['search'] ? $query['advanced_search'] : ''));
2895 2890
 			if ($_content['button']['cancelsearch'])
2896 2891
 			{
2897
-				Framework::window_close ();
2892
+				Framework::window_close();
2898 2893
 
2899 2894
 				// No need to reload popup
2900 2895
 				return;
@@ -2911,7 +2906,7 @@  discard block
 block discarded – undo
2911 2906
 		// Avoid ID conflict with tree & selectboxes
2912 2907
 		$content['cat_id_tree'] = $content['cat_id'];
2913 2908
 
2914
-		for($i = -23; $i<=23; $i++)
2909
+		for ($i = -23; $i <= 23; $i++)
2915 2910
 		{
2916 2911
 			$tz[$i] = ($i > 0 ? '+' : '').$i;
2917 2912
 		}
@@ -2920,8 +2915,8 @@  discard block
 block discarded – undo
2920 2915
 		//foreach($this->content_types as $type => $data) $sel_options['tid'][$type] = $data['name'];
2921 2916
 
2922 2917
 		// configure search options
2923
-		$sel_options['owner'] = $this->get_addressbooks(Acl::READ,lang('all'));
2924
-		$sel_options['operator'] =  array(
2918
+		$sel_options['owner'] = $this->get_addressbooks(Acl::READ, lang('all'));
2919
+		$sel_options['operator'] = array(
2925 2920
 			'AND' => 'AND',
2926 2921
 			'OR' => 'OR',
2927 2922
 		);
@@ -2931,12 +2926,12 @@  discard block
 block discarded – undo
2931 2926
 		);
2932 2927
 		if ($this->customfields)
2933 2928
 		{
2934
-			foreach($this->customfields as $name => $data)
2929
+			foreach ($this->customfields as $name => $data)
2935 2930
 			{
2936 2931
 				if (substr($data['type'], 0, 6) == 'select' && !($data['rows'] > 1))
2937 2932
 				{
2938 2933
 					if (!isset($content['#'.$name])) $content['#'.$name] = '';
2939
-					if(!isset($data['values'][''])) $sel_options['#'.$name][''] = lang('Select one');
2934
+					if (!isset($data['values'][''])) $sel_options['#'.$name][''] = lang('Select one');
2940 2935
 				}
2941 2936
 				// Make them not required, otherwise you can't search
2942 2937
 				$this->tmpl->setElementAttribute('#'.$name, 'needed', FALSE);
@@ -2962,8 +2957,8 @@  discard block
 block discarded – undo
2962 2957
 
2963 2958
 		if ($this->config['private_cf_tab']) $content['no_private_cfs'] = 0;
2964 2959
 
2965
-		$this->tmpl->set_cell_attribute('change_org','disabled',true);
2966
-		return $this->tmpl->exec('addressbook.addressbook_ui.search',$content,$sel_options,$readonlys,array(),2);
2960
+		$this->tmpl->set_cell_attribute('change_org', 'disabled', true);
2961
+		return $this->tmpl->exec('addressbook.addressbook_ui.search', $content, $sel_options, $readonlys, array(), 2);
2967 2962
 	}
2968 2963
 
2969 2964
 	/**
@@ -2972,16 +2967,15 @@  discard block
 block discarded – undo
2972 2967
 	function photo()
2973 2968
 	{
2974 2969
 		ob_start();
2975
-		$contact_id = isset($_GET['contact_id']) ? $_GET['contact_id'] :
2976
-			(isset($_GET['account_id']) ? 'account:'.$_GET['account_id'] : 0);
2970
+		$contact_id = isset($_GET['contact_id']) ? $_GET['contact_id'] : (isset($_GET['account_id']) ? 'account:'.$_GET['account_id'] : 0);
2977 2971
 
2978
-		if (substr($contact_id,0,8) == 'account:')
2972
+		if (substr($contact_id, 0, 8) == 'account:')
2979 2973
 		{
2980
-			$contact_id = $GLOBALS['egw']->accounts->id2name(substr($contact_id,8),'person_id');
2974
+			$contact_id = $GLOBALS['egw']->accounts->id2name(substr($contact_id, 8), 'person_id');
2981 2975
 		}
2982 2976
 		if (!($contact = $this->read($contact_id)) || !$contact['jpegphoto'])
2983 2977
 		{
2984
-			Egw::redirect(Api\Image::find('addressbook','photo'));
2978
+			Egw::redirect(Api\Image::find('addressbook', 'photo'));
2985 2979
 		}
2986 2980
 		// use an etag over the image mapp
2987 2981
 		$etag = '"'.$contact['id'].':'.$contact['etag'].'"';
@@ -2993,7 +2987,7 @@  discard block
 block discarded – undo
2993 2987
 			// different url with different etag parameter will force a reload
2994 2988
 			if (isset($_GET['etag']))
2995 2989
 			{
2996
-				Api\Session::cache_control(30*86400);	// cache for 30 days
2990
+				Api\Session::cache_control(30 * 86400); // cache for 30 days
2997 2991
 			}
2998 2992
 			// if servers send a If-None-Match header, response with 304 Not Modified, if etag matches
2999 2993
 			if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && $_SERVER['HTTP_IF_NONE_MATCH'] === $etag)
@@ -3045,15 +3039,15 @@  discard block
 block discarded – undo
3045 3039
 		echo $GLOBALS['egw']->framework->navbar();
3046 3040
 
3047 3041
 		// check if user has admin rights AND if a valid fileas type is given (Security)
3048
-		if (!$this->is_admin() || $_GET['type'] != '' && !in_array($_GET['type'],$this->fileas_types))
3042
+		if (!$this->is_admin() || $_GET['type'] != '' && !in_array($_GET['type'], $this->fileas_types))
3049 3043
 		{
3050 3044
 			echo '<h1>'.lang('Permission denied !!!')."</h1>\n";
3051 3045
 		}
3052 3046
 		else
3053 3047
 		{
3054 3048
 			$errors = null;
3055
-			$updated = parent::set_all_fileas($_GET['type'],(boolean)$_GET['all'],$errors,true);	// true = ignore Acl
3056
-			echo '<p style="margin-top: 20px;"><b>'.lang('%1 contacts updated (%2 errors).',$updated,$errors)."</b></p>\n";
3049
+			$updated = parent::set_all_fileas($_GET['type'], (boolean)$_GET['all'], $errors, true); // true = ignore Acl
3050
+			echo '<p style="margin-top: 20px;"><b>'.lang('%1 contacts updated (%2 errors).', $updated, $errors)."</b></p>\n";
3057 3051
 		}
3058 3052
 		echo $GLOBALS['egw']->framework->footer();
3059 3053
 	}
@@ -3077,8 +3071,8 @@  discard block
 block discarded – undo
3077 3071
 		else
3078 3072
 		{
3079 3073
 			$errors = null;
3080
-			$updated = parent::set_all_cleanup($errors,true);	// true = ignore Acl
3081
-			echo '<p style="margin-top: 20px;"><b>'.lang('%1 contacts updated (%2 errors).',$updated,$errors)."</b></p>\n";
3074
+			$updated = parent::set_all_cleanup($errors, true); // true = ignore Acl
3075
+			echo '<p style="margin-top: 20px;"><b>'.lang('%1 contacts updated (%2 errors).', $updated, $errors)."</b></p>\n";
3082 3076
 		}
3083 3077
 		echo $GLOBALS['egw']->framework->footer();
3084 3078
 	}
@@ -3091,7 +3085,7 @@  discard block
 block discarded – undo
3091 3085
 		if ($this->contact_repository == 'ldap' || !$content['id'] ||
3092 3086
 			$this->account_repository == 'ldap' && $content['account_id'])
3093 3087
 		{
3094
-			return;	// no history for ldap as history table only allows integer id's
3088
+			return; // no history for ldap as history table only allows integer id's
3095 3089
 		}
3096 3090
 		$content['history'] = array(
3097 3091
 			'id'	=>	$content['id'],
@@ -3106,7 +3100,7 @@  discard block
 block discarded – undo
3106 3100
 			),
3107 3101
 		);
3108 3102
 
3109
-		foreach($this->content_types as $id => $settings)
3103
+		foreach ($this->content_types as $id => $settings)
3110 3104
 		{
3111 3105
 			$content['history']['status-widgets']['tid'][$id] = $settings['name'];
3112 3106
 		}
Please login to merge, or discard this patch.
Braces   +351 added lines, -91 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)))
572
+		{
573
+			// do we have addressbooks, we should
538 574
 		{
539
-			unset($move2addressbooks[0]);	// do not offer action to move contact to an account, as we dont support that currrently
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
 		}
@@ -1059,10 +1120,16 @@  discard block
 block discarded – undo
1059 1120
 				unset($query['filter2']);
1060 1121
 				$extra = $readonlys = null;
1061 1122
 				$this->get_rows($query,$extra,$readonlys,true);	// true = only return the id's
1062
-				if ($extra[0]) $org_contacts = array_merge($org_contacts,$extra);
1123
+				if ($extra[0])
1124
+				{
1125
+					$org_contacts = array_merge($org_contacts,$extra);
1126
+				}
1063 1127
 			}
1064 1128
 		}
1065
-		if ($org_contacts) $checked = array_unique($checked ? array_merge($checked,$org_contacts) : $org_contacts);
1129
+		if ($org_contacts)
1130
+		{
1131
+			$checked = array_unique($checked ? array_merge($checked,$org_contacts) : $org_contacts);
1132
+		}
1066 1133
 		//_debug_array($checked); exit;
1067 1134
 
1068 1135
 		if (substr($action,0,8) == 'move_to_')
@@ -1079,9 +1146,12 @@  discard block
 block discarded – undo
1079 1146
 			$document = substr($action,9);
1080 1147
 			$action = 'document';
1081 1148
 		}
1082
-		elseif(substr($action,0,4) == 'cat_')	// cat_add_123 or cat_del_456
1149
+		elseif(substr($action,0,4) == 'cat_')
1150
+		{
1151
+			// cat_add_123 or cat_del_456
1083 1152
 		{
1084 1153
 			$cat_id = (int)substr($action, 8);
1154
+		}
1085 1155
 			$action = substr($action,0,7);
1086 1156
 		}
1087 1157
 		// Security: stop non-admins to export more then the configured number of contacts
@@ -1128,7 +1198,10 @@  discard block
 block discarded – undo
1128 1198
 				return false;
1129 1199
 
1130 1200
 			case 'document':
1131
-				if (!$document) $document = $this->prefs['default_document'];
1201
+				if (!$document)
1202
+				{
1203
+					$document = $this->prefs['default_document'];
1204
+				}
1132 1205
 				$document_merge = new Api\Contacts\Merge();
1133 1206
 				$msg = $document_merge->download($document, $checked, '', $this->prefs['document_dir']);
1134 1207
 				$failed = count($checked);
@@ -1280,19 +1353,25 @@  discard block
 block discarded – undo
1280 1353
 					break;
1281 1354
 
1282 1355
 				default:	// move to an other addressbook
1283
-					if (!(int)$action || !($this->grants[(string) (int) $action] & Acl::EDIT))	// might be ADD in the future
1356
+					if (!(int)$action || !($this->grants[(string) (int) $action] & Acl::EDIT))
1357
+					{
1358
+						// might be ADD in the future
1284 1359
 					{
1285 1360
 						return false;
1286 1361
 					}
1362
+					}
1287 1363
 					if (!$checkboxes['move_to_copy'])
1288 1364
 					{
1289 1365
 						$action_msg = lang('moved');
1290 1366
 						if (($Ok = !!($contact = $this->read($id)) && $this->check_perms(Acl::DELETE,$contact)))
1291 1367
 						{
1292
-							if (!$contact['owner'])		// no (mass-)move of Api\Accounts
1368
+							if (!$contact['owner'])
1369
+							{
1370
+								// no (mass-)move of Api\Accounts
1293 1371
 							{
1294 1372
 								$Ok = false;
1295 1373
 							}
1374
+							}
1296 1375
 							elseif ($contact['owner'] != (int)$action || $contact['private'] != (int)(substr($action,-1) == 'p'))
1297 1376
 							{
1298 1377
 								$contact['owner'] = (int) $action;
@@ -1381,9 +1460,12 @@  discard block
 block discarded – undo
1381 1460
 		$do_email = $query['do_email'];
1382 1461
 		$what = $query['sitemgr_display'] ? $query['sitemgr_display'] : ($do_email ? 'email' : 'index');
1383 1462
 
1384
-		if (!$id_only && !$query['csv_export'])	// do NOT store state for csv_export or querying id's (no regular view)
1463
+		if (!$id_only && !$query['csv_export'])
1464
+		{
1465
+			// do NOT store state for csv_export or querying id's (no regular view)
1385 1466
 		{
1386 1467
 			$store_query = $query;
1468
+		}
1387 1469
 			// Do not store these
1388 1470
 			foreach(array('options-cat_id','actions','action_links','placeholder_actions') as $key)
1389 1471
 			{
@@ -1396,14 +1478,25 @@  discard block
 block discarded – undo
1396 1478
 		{
1397 1479
 			$old_state = Api\Cache::getSession('addressbook', $what);
1398 1480
 		}
1399
-		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
1481
+		if (!isset($this->org_views[(string) $query['org_view']]) || strpos($query['org_view'],':') === false)
1482
+		{
1483
+			// we dont have an org view, unset the according col_filters
1400 1484
 		{
1401 1485
 			if (isset($query['col_filter']['org_name'])) unset($query['col_filter']['org_name']);
1402
-			if (isset($query['col_filter']['adr_one_locality'])) unset($query['col_filter']['adr_one_locality']);
1403
-			if (isset($query['col_filter']['org_unit'])) unset($query['col_filter']['org_unit']);
1486
+		}
1487
+			if (isset($query['col_filter']['adr_one_locality']))
1488
+			{
1489
+				unset($query['col_filter']['adr_one_locality']);
1490
+			}
1491
+			if (isset($query['col_filter']['org_unit']))
1492
+			{
1493
+				unset($query['col_filter']['org_unit']);
1494
+			}
1404 1495
 		}
1405 1496
 
1406
-		if (isset($this->org_views[(string) $query['org_view']]))	// we have an org view, reset the advanced search
1497
+		if (isset($this->org_views[(string) $query['org_view']]))
1498
+		{
1499
+			// we have an org view, reset the advanced search
1407 1500
 		{
1408 1501
 			//_debug_array(array('Search'=>$query['search'],
1409 1502
 			//	'AdvancedSearch'=>$query['advanced_search']));
@@ -1411,10 +1504,14 @@  discard block
 block discarded – undo
1411 1504
 			//unset($query['advanced_search']);
1412 1505
 			if(!$query['search'] && $old_state['advanced_search']) $query['advanced_search'] = $old_state['advanced_search'];
1413 1506
 		}
1414
-		elseif(!$query['search'] && array_key_exists('advanced_search',$old_state))	// eg. paging in an advanced search
1507
+		}
1508
+		elseif(!$query['search'] && array_key_exists('advanced_search',$old_state))
1509
+		{
1510
+			// eg. paging in an advanced search
1415 1511
 		{
1416 1512
 			$query['advanced_search'] = $old_state['advanced_search'];
1417 1513
 		}
1514
+		}
1418 1515
 		/* this cant work anymore, as Framework::set_onload no longer exists
1419 1516
 		if ($do_email && etemplate::$loop)
1420 1517
 		{	// remove previous addEmail() calls, otherwise they will be run again
@@ -1424,11 +1521,13 @@  discard block
 block discarded – undo
1424 1521
 		// Make sure old lettersearch filter doesn't stay - current letter filter will be added later
1425 1522
 		foreach($query['col_filter'] as $key => $col_filter)
1426 1523
 		{
1427
-			if(!is_numeric($key)) continue;
1524
+			if(!is_numeric($key))
1525
+			{
1526
+				continue;
1527
+			}
1428 1528
 			if(preg_match('/'.$GLOBALS['egw']->db->capabilities['case_insensitive_like'].
1429 1529
 				' '.$GLOBALS['egw']->db->quote('[a-z]%').'$/',$col_filter) == 1
1430
-			)
1431
-			{
1530
+			) {
1432 1531
 				unset($query['col_filter'][$key]);
1433 1532
 			}
1434 1533
 		}
@@ -1439,9 +1538,13 @@  discard block
 block discarded – undo
1439 1538
 			// check if accounts are stored in ldap, which does NOT yet support the org-views
1440 1539
 			if ($this->so_accounts && $query['filter'] === '0' && $query['org_view'])
1441 1540
 			{
1442
-				if ($old_state['filter'] === '0')	// user changed to org_view
1541
+				if ($old_state['filter'] === '0')
1542
+				{
1543
+					// user changed to org_view
1443 1544
 				{
1444
-					$query['filter'] = '';			// --> change filter to all contacts
1545
+					$query['filter'] = '';
1546
+				}
1547
+				// --> change filter to all contacts
1445 1548
 				}
1446 1549
 				else								// user changed to accounts
1447 1550
 				{
@@ -1478,9 +1581,12 @@  discard block
 block discarded – undo
1478 1581
 		{
1479 1582
 			unset($query['col_filter']['cat_id']);
1480 1583
 		}
1481
-		if ($query['filter'] !== '')	// not all addressbooks
1584
+		if ($query['filter'] !== '')
1585
+		{
1586
+			// not all addressbooks
1482 1587
 		{
1483 1588
 			$query['col_filter']['owner'] = (string) (int) $query['filter'];
1589
+		}
1484 1590
 
1485 1591
 			if ($this->private_addressbook)
1486 1592
 			{
@@ -1492,10 +1598,13 @@  discard block
 block discarded – undo
1492 1598
 			unset($query['col_filter']['owner']);
1493 1599
 			unset($query['col_filter']['private']);
1494 1600
 		}
1495
-		if ((int)$query['filter2'])	// not no distribution list
1601
+		if ((int)$query['filter2'])
1602
+		{
1603
+			// not no distribution list
1496 1604
 		{
1497 1605
 			$query['col_filter']['list'] = (string) (int) $query['filter2'];
1498 1606
 		}
1607
+		}
1499 1608
 		else
1500 1609
 		{
1501 1610
 			unset($query['col_filter']['list']);
@@ -1507,10 +1616,13 @@  discard block
 block discarded – undo
1507 1616
 		// all backends allow now at least to use groups as distribution lists
1508 1617
 		$query['no_filter2'] = false;
1509 1618
 
1510
-		if (isset($this->org_views[(string) $query['org_view']]) && !$query['col_filter']['parent_id'])	// we have an org view
1619
+		if (isset($this->org_views[(string) $query['org_view']]) && !$query['col_filter']['parent_id'])
1620
+		{
1621
+			// we have an org view
1511 1622
 		{
1512 1623
 			// Query doesn't like empties
1513 1624
 			unset($query['col_filter']['parent_id']);
1625
+		}
1514 1626
 
1515 1627
 			if($query['actions'] && $query['actions']['open'])
1516 1628
 			{
@@ -1563,9 +1675,12 @@  discard block
 block discarded – undo
1563 1675
 			}
1564 1676
 			// Query doesn't like parent_id
1565 1677
 			unset($query['col_filter']['parent_id']);
1566
-			if ($query['org_view'])	// view the contacts of one organisation only
1678
+			if ($query['org_view'])
1679
+			{
1680
+				// view the contacts of one organisation only
1567 1681
 			{
1568 1682
 				if (strpos($query['org_view'],'*AND*') !== false) $query['org_view'] = str_replace('*AND*','&',$query['org_view']);
1683
+			}
1569 1684
 				foreach(explode('|||',$query['org_view']) as $part)
1570 1685
 				{
1571 1686
 					list($name,$value) = explode(':',$part,2);
@@ -1584,14 +1699,18 @@  discard block
 block discarded – undo
1584 1699
 			// translate the select order to the really used over all 3 columns
1585 1700
 			$sort = $query['sort'];
1586 1701
 			switch($query['order'])		// "xxx<>'' DESC" sorts contacts with empty order-criteria always at the end
1587
-			{							// we don't exclude them, as the total would otherwise depend on the order-criteria
1702
+			{
1703
+// we don't exclude them, as the total would otherwise depend on the order-criteria
1588 1704
 				case 'org_name':
1589 1705
 					$order = "egw_addressbook.org_name<>''DESC,egw_addressbook.org_name $sort,n_family $sort,n_given $sort";
1590 1706
 					break;
1591 1707
 				default:
1592
-					if ($query['order'][0] == '#')	// we order by a custom field
1708
+					if ($query['order'][0] == '#')
1709
+					{
1710
+						// we order by a custom field
1593 1711
 					{
1594 1712
 						$order = "{$query['order']} $sort,org_name $sort,n_family $sort,n_given $sort";
1713
+					}
1595 1714
 						break;
1596 1715
 					}
1597 1716
 					$query['order'] = 'n_family';
@@ -1615,9 +1734,12 @@  discard block
 block discarded – undo
1615 1734
 				case 'contact_id':
1616 1735
 					$order = "egw_addressbook.$query[order] $sort";
1617 1736
 			}
1618
-			if ($query['searchletter'])	// only show contacts if the order-criteria starts with the given letter
1737
+			if ($query['searchletter'])
1738
+			{
1739
+				// only show contacts if the order-criteria starts with the given letter
1619 1740
 			{
1620 1741
 				$no_letter_search = array('adr_one_postalcode', 'adr_two_postalcode', 'contact_id', 'contact_created','contact_modified');
1742
+			}
1621 1743
 				$query['col_filter'][] = (in_array($query['order'],$no_letter_search) ? 'org_name' : (substr($query['order'],0,1)=='#'?'':'egw_addressbook.').$query['order']).' '.
1622 1744
 					$GLOBALS['egw']->db->capabilities['case_insensitive_like'].' '.$GLOBALS['egw']->db->quote(strtolower($query['searchletter']).'%');
1623 1745
 			}
@@ -1657,11 +1779,17 @@  discard block
 block discarded – undo
1657 1779
 					{
1658 1780
 						foreach($columselection as $col)
1659 1781
 						{
1660
-							if ($col[0] == '#') $selected_cfs[] = substr($col,1);
1782
+							if ($col[0] == '#')
1783
+							{
1784
+								$selected_cfs[] = substr($col,1);
1785
+							}
1661 1786
 						}
1662 1787
 						$customfields = $this->read_customfields($ids,$selected_cfs);
1663 1788
 					}
1664
-					if ($show_calendar && !empty($ids)) $calendar = $this->read_calendar($calendar_participants);
1789
+					if ($show_calendar && !empty($ids))
1790
+					{
1791
+						$calendar = $this->read_calendar($calendar_participants);
1792
+					}
1665 1793
 					// distributionlist memership for the entrys
1666 1794
 					//_debug_array($this->get_lists(Acl::EDIT));
1667 1795
 					if ($show_distributionlist && $available_distib_lists)
@@ -1671,7 +1799,10 @@  discard block
 block discarded – undo
1671 1799
 				}
1672 1800
 			}
1673 1801
 		}
1674
-		if (!$rows) $rows = array();
1802
+		if (!$rows)
1803
+		{
1804
+			$rows = array();
1805
+		}
1675 1806
 
1676 1807
 		if ($id_only)
1677 1808
 		{
@@ -1704,7 +1835,10 @@  discard block
 block discarded – undo
1704 1835
 					$row['line2'] = $row['org_name'];
1705 1836
 					break;
1706 1837
 				case 'n_fileas':
1707
-					if (!$row['n_fileas']) $row['n_fileas'] = $this->fileas($row);
1838
+					if (!$row['n_fileas'])
1839
+					{
1840
+						$row['n_fileas'] = $this->fileas($row);
1841
+					}
1708 1842
 					list($row['line1'],$row['line2']) = explode(': ',$row['n_fileas']);
1709 1843
 					break;
1710 1844
 			}
@@ -1778,8 +1912,14 @@  discard block
 block discarded – undo
1778 1912
 			}
1779 1913
 
1780 1914
 			// hide region for address format 'postcode_city'
1781
-			if (($row['addr_format']  = $this->addr_format_by_country($row['adr_one_countryname']))=='postcode_city') unset($row['adr_one_region']);
1782
-			if (($row['addr_format2'] = $this->addr_format_by_country($row['adr_two_countryname']))=='postcode_city') unset($row['adr_two_region']);
1915
+			if (($row['addr_format']  = $this->addr_format_by_country($row['adr_one_countryname']))=='postcode_city')
1916
+			{
1917
+				unset($row['adr_one_region']);
1918
+			}
1919
+			if (($row['addr_format2'] = $this->addr_format_by_country($row['adr_two_countryname']))=='postcode_city')
1920
+			{
1921
+				unset($row['adr_two_region']);
1922
+			}
1783 1923
 
1784 1924
 			// respect category permissions
1785 1925
 			if(!empty($row['cat_id']))
@@ -1790,7 +1930,10 @@  discard block
 block discarded – undo
1790 1930
 		$rows['no_distribution_list'] = (bool)$query['filter2'];
1791 1931
 
1792 1932
 		// disable customfields column, if we have no customefield(s)
1793
-		if (!$this->customfields) $rows['no_customfields'] = true;
1933
+		if (!$this->customfields)
1934
+		{
1935
+			$rows['no_customfields'] = true;
1936
+		}
1794 1937
 
1795 1938
 		$rows['order'] = $order;
1796 1939
 		$rows['call_popup'] = $this->config['call_popup'];
@@ -1829,10 +1972,13 @@  discard block
 block discarded – undo
1829 1972
 			$order = $order == 'n_given' ? lang('first name') : ($order == 'n_family' ? lang('last name') : lang('Organisation'));
1830 1973
 			$header[] = lang("%1 starts with '%2'",$order,$query['searchletter']);
1831 1974
 		}
1832
-		if ($query['search'] && !$query['advanced_search']) // do not add that, if we have advanced search active
1975
+		if ($query['search'] && !$query['advanced_search'])
1976
+		{
1977
+			// do not add that, if we have advanced search active
1833 1978
 		{
1834 1979
 			$header[] = lang("Search for '%1'",$query['search']);
1835 1980
 		}
1981
+		}
1836 1982
 		$GLOBALS['egw_info']['flags']['app_header'] = implode(': ', $header);
1837 1983
 
1838 1984
 		return $this->total;
@@ -1899,7 +2045,10 @@  discard block
 block discarded – undo
1899 2045
 			$content['private'] = (int) ($content['owner'] && substr($content['owner'],-1) == 'p');
1900 2046
 			$content['owner'] = (string) (int) $content['owner'];
1901 2047
 			$content['cat_id'] = $this->config['cat_tab'] === 'Tree' ? $content['cat_id_tree'] : $content['cat_id'];
1902
-			if ($this->config['private_cf_tab']) $content = (array)$content['private_cfs'] + $content;
2048
+			if ($this->config['private_cf_tab'])
2049
+			{
2050
+				$content = (array)$content['private_cfs'] + $content;
2051
+			}
1903 2052
 			unset($content['private_cfs']);
1904 2053
 
1905 2054
 			switch($button)
@@ -2096,7 +2245,10 @@  discard block
 block discarded – undo
2096 2245
 				{
2097 2246
 					// arguments containing a comma get quoted by etemplate/js/nextmatch_action.js
2098 2247
 					// leading to error in Api\Db::column_data_implode, if not unquoted
2099
-					if ($org[0] == '"') $org = substr($org, 1, -1);
2248
+					if ($org[0] == '"')
2249
+					{
2250
+						$org = substr($org, 1, -1);
2251
+					}
2100 2252
 					$content = $this->read_org($org);
2101 2253
 				}
2102 2254
 				elseif ($state['org_view'] && !isset($this->org_views[$state['org_view']]))
@@ -2116,7 +2268,10 @@  discard block
 block discarded – undo
2116 2268
 						$content['adr_two_countryname'] =
2117 2269
 							$GLOBALS['egw']->country->get_full_name($GLOBALS['egw_info']['user']['preferences']['common']['country']);
2118 2270
 					}
2119
-					if ($this->prefs['fileas_default']) $content['fileas_type'] = $this->prefs['fileas_default'];
2271
+					if ($this->prefs['fileas_default'])
2272
+					{
2273
+						$content['fileas_type'] = $this->prefs['fileas_default'];
2274
+					}
2120 2275
 				}
2121 2276
 				if (isset($_GET['owner']) && $_GET['owner'] !== '')
2122 2277
 				{
@@ -2141,7 +2296,10 @@  discard block
 block discarded – undo
2141 2296
 				$new_type = array_keys($this->content_types);
2142 2297
 				// fetch active type to preset the type, if param typeid is not passed
2143 2298
 				$active_tid = Api\Cache::getSession('addressbook','active_tid');
2144
-				if ($active_tid && strtoupper($active_tid) === 'D') unset($active_tid);
2299
+				if ($active_tid && strtoupper($active_tid) === 'D')
2300
+				{
2301
+					unset($active_tid);
2302
+				}
2145 2303
 				$content['tid'] = $_GET['typeid'] ? $_GET['typeid'] : ($active_tid?$active_tid:$new_type[0]);
2146 2304
 				foreach($this->get_contact_columns() as $field)
2147 2305
 				{
@@ -2159,19 +2317,37 @@  discard block
 block discarded – undo
2159 2317
 									if (strpos($singleAddress[0]->personal,',')===false)
2160 2318
 									{
2161 2319
 										list($P_n_given,$P_n_family,$P_org_name)=explode(' ',$singleAddress[0]->personal,3);
2162
-										if (strlen(trim($P_n_given))>0) $content['n_given'] = trim($P_n_given);
2163
-										if (strlen(trim($P_n_family))>0) $content['n_family'] = trim($P_n_family);
2164
-										if (strlen(trim($P_org_name))>0) $content['org_name'] = trim($P_org_name);
2320
+										if (strlen(trim($P_n_given))>0)
2321
+										{
2322
+											$content['n_given'] = trim($P_n_given);
2323
+										}
2324
+										if (strlen(trim($P_n_family))>0)
2325
+										{
2326
+											$content['n_family'] = trim($P_n_family);
2327
+										}
2328
+										if (strlen(trim($P_org_name))>0)
2329
+										{
2330
+											$content['org_name'] = trim($P_org_name);
2331
+										}
2165 2332
 									}
2166 2333
 									else
2167 2334
 									{
2168 2335
 										list($P_n_family,$P_other)=explode(',',$singleAddress[0]->personal,2);
2169
-										if (strlen(trim($P_n_family))>0) $content['n_family'] = trim($P_n_family);
2336
+										if (strlen(trim($P_n_family))>0)
2337
+										{
2338
+											$content['n_family'] = trim($P_n_family);
2339
+										}
2170 2340
 										if (strlen(trim($P_other))>0)
2171 2341
 										{
2172 2342
 											list($P_n_given,$P_org_name)=explode(',',$P_other,2);
2173
-											if (strlen(trim($P_n_given))>0) $content['n_given'] = trim($P_n_given);
2174
-											if (strlen(trim($P_org_name))>0) $content['org_name'] = trim($P_org_name);
2343
+											if (strlen(trim($P_n_given))>0)
2344
+											{
2345
+												$content['n_given'] = trim($P_n_given);
2346
+											}
2347
+											if (strlen(trim($P_org_name))>0)
2348
+											{
2349
+												$content['org_name'] = trim($P_org_name);
2350
+											}
2175 2351
 										}
2176 2352
 									}
2177 2353
 								}
@@ -2199,7 +2375,10 @@  discard block
 block discarded – undo
2199 2375
 							break;
2200 2376
 						}
2201 2377
 					}
2202
-					if (empty($content['n_fn'])) $content['n_fn'] = $this->fullname($content);
2378
+					if (empty($content['n_fn']))
2379
+					{
2380
+						$content['n_fn'] = $this->fullname($content);
2381
+					}
2203 2382
 				}
2204 2383
 				$content['creator'] = $this->user;
2205 2384
 				$content['created'] = $this->now_su;
@@ -2207,17 +2386,27 @@  discard block
 block discarded – undo
2207 2386
 				//_debug_array($content);
2208 2387
 			}
2209 2388
 
2210
-			if ($_GET['msg']) $content['msg'] = strip_tags($_GET['msg']);	// dont allow HTML!
2389
+			if ($_GET['msg'])
2390
+			{
2391
+				$content['msg'] = strip_tags($_GET['msg']);
2392
+			}
2393
+			// dont allow HTML!
2211 2394
 
2212
-			if($content && $_GET['makecp'])	// copy the contact
2395
+			if($content && $_GET['makecp'])
2396
+			{
2397
+				// copy the contact
2213 2398
 			{
2214 2399
 				$this->copy_contact($content);
2400
+			}
2215 2401
 				$content['msg'] = lang('%1 copied - the copy can now be edited', lang(Link::get_registry('addressbook','entry')));
2216 2402
 				$view = false;
2217 2403
 			}
2218 2404
 			else
2219 2405
 			{
2220
-				if (is_numeric($contact_id)) $content['link_to']['to_id'] = $contact_id;
2406
+				if (is_numeric($contact_id))
2407
+				{
2408
+					$content['link_to']['to_id'] = $contact_id;
2409
+				}
2221 2410
 			}
2222 2411
 			// automatic link new entries to entries specified in the url
2223 2412
 			if (!$contact_id && isset($_REQUEST['link_app']) && isset($_REQUEST['link_id']) && !is_array($content['link_to']['to_id']))
@@ -2226,10 +2415,13 @@  discard block
 block discarded – undo
2226 2415
 				foreach(is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app)
2227 2416
 				{
2228 2417
 					$link_id = $link_ids[$n];
2229
-					if (preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id))	// gard against XSS
2418
+					if (preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id))
2419
+					{
2420
+						// gard against XSS
2230 2421
 					{
2231 2422
 						Link::link('addressbook',$content['link_to']['to_id'],$link_app,$link_id);
2232 2423
 					}
2424
+					}
2233 2425
 				}
2234 2426
 			}
2235 2427
 		}
@@ -2237,7 +2429,10 @@  discard block
 block discarded – undo
2237 2429
 		{
2238 2430
 			// last and next calendar date
2239 2431
 			list(,$dates) = each($this->read_calendar(array($content['account_id'] ? $content['account_id'] : 'c'.$content['id']),false));
2240
-			if(is_array($dates)) $content += $dates;
2432
+			if(is_array($dates))
2433
+			{
2434
+				$content += $dates;
2435
+			}
2241 2436
 		}
2242 2437
 
2243 2438
 		// Registry has view_id as contact_id, so set it (custom fields uses it)
@@ -2277,7 +2472,11 @@  discard block
 block discarded – undo
2277 2472
 		$sel_options['fileas_type'] = $this->fileas_options($content);
2278 2473
 		$sel_options['adr_one_countrycode']['-custom-'] = lang('Custom');
2279 2474
 		$sel_options['owner'] = $this->get_addressbooks(Acl::ADD);
2280
-		if ($content['owner']) unset($sel_options['owner'][0]);	// do not offer to switch to accounts, as we do not support moving contacts to accounts
2475
+		if ($content['owner'])
2476
+		{
2477
+			unset($sel_options['owner'][0]);
2478
+		}
2479
+		// do not offer to switch to accounts, as we do not support moving contacts to accounts
2281 2480
 		if ((string) $content['owner'] !== '')
2282 2481
 		{
2283 2482
 			if (!isset($sel_options['owner'][(int)$content['owner']]))
@@ -2312,7 +2511,10 @@  discard block
 block discarded – undo
2312 2511
 				));
2313 2512
 			}
2314 2513
 		}
2315
-		if (isset($readonlys['n_fileas'])) $readonlys['fileas_type'] = $readonlys['n_fileas'];
2514
+		if (isset($readonlys['n_fileas']))
2515
+		{
2516
+			$readonlys['fileas_type'] = $readonlys['n_fileas'];
2517
+		}
2316 2518
 		// disable not needed tabs
2317 2519
 		$readonlys['tabs']['cats'] = !($content['cat_tab'] = $this->config['cat_tab']);
2318 2520
 		$readonlys['tabs']['custom'] = !$this->customfields || $this->get_backend($content['id'],$content['owner']) == $this->so_accounts;
@@ -2320,8 +2522,14 @@  discard block
 block discarded – undo
2320 2522
 		$readonlys['tabs']['distribution_list'] = !$content['distrib_lists'];#false;
2321 2523
 		$readonlys['tabs']['history'] = $this->contact_repository != 'sql' || !$content['id'] ||
2322 2524
 			$this->account_repository != 'sql' && $content['account_id'];
2323
-		if (!$content['id']) $readonlys['button[delete]'] = !$content['id'];
2324
-		if ($this->config['private_cf_tab']) $content['no_private_cfs'] = 0;
2525
+		if (!$content['id'])
2526
+		{
2527
+			$readonlys['button[delete]'] = !$content['id'];
2528
+		}
2529
+		if ($this->config['private_cf_tab'])
2530
+		{
2531
+			$content['no_private_cfs'] = 0;
2532
+		}
2325 2533
 		$readonlys['change_org'] = empty($content['org_name']) || $view;
2326 2534
 
2327 2535
 		// for editing the own account (by a non-admin), enable only the fields allowed via the "own_account_acl"
@@ -2369,7 +2577,10 @@  discard block
 block discarded – undo
2369 2577
 
2370 2578
 		$content['photo'] = $this->photo_src($content['id'],$content['jpegphoto'],'photo',$content['etag']);
2371 2579
 
2372
-		if ($content['private']) $content['owner'] .= 'p';
2580
+		if ($content['private'])
2581
+		{
2582
+			$content['owner'] .= 'p';
2583
+		}
2373 2584
 
2374 2585
 		// for custom types, check if we have a custom edit template named "addressbook.edit.$type", $type is the name
2375 2586
 		if (in_array($content['tid'], array('n',self::DELETED_TYPE)) || !$this->tmpl->read('addressbook.edit.'.$this->content_types[$content['tid']]['name']))
@@ -2391,7 +2602,10 @@  discard block
 block discarded – undo
2391 2602
 		//error_log(__METHOD__."() hook_data=".array2string($hook_data));
2392 2603
 		foreach($hook_data as $extra_tabs)
2393 2604
 		{
2394
-			if (!$extra_tabs) continue;
2605
+			if (!$extra_tabs)
2606
+			{
2607
+				continue;
2608
+			}
2395 2609
 
2396 2610
 			foreach(isset($extra_tabs[0]) ? $extra_tabs : array($extra_tabs) as $extra_tab)
2397 2611
 			{
@@ -2408,7 +2622,10 @@  discard block
 block discarded – undo
2408 2622
 					$readonlys = array_merge($readonlys, $extra_tab['readonlys']);
2409 2623
 				}
2410 2624
 				// we must NOT add tabs and callbacks more then once!
2411
-				if (!$first_call) continue;
2625
+				if (!$first_call)
2626
+				{
2627
+					continue;
2628
+				}
2412 2629
 
2413 2630
 				if (!empty($extra_tab['pre_save_callback']))
2414 2631
 				{
@@ -2492,20 +2709,27 @@  discard block
 block discarded – undo
2492 2709
 	public function ajax_check_values($values, $name, $own_id=0)
2493 2710
 	{
2494 2711
 		$matches = null;
2495
-		if (preg_match('/^exec\[([^\]]+)\]$/', $name, $matches)) $name = $matches[1];	// remove exec[ ]
2712
+		if (preg_match('/^exec\[([^\]]+)\]$/', $name, $matches))
2713
+		{
2714
+			$name = $matches[1];
2715
+		}
2716
+		// remove exec[ ]
2496 2717
 
2497 2718
 		$ret = array('doublicates' => array(), 'msg' => null);
2498 2719
 
2499 2720
 		// if email changed, check for doublicates
2500 2721
 		if (in_array($name, array('email', 'email_home')))
2501 2722
 		{
2502
-			if (preg_match(Etemplate\Widget\Url::EMAIL_PREG, $values[$name]))	// only search for real email addresses, to not return to many contacts
2723
+			if (preg_match(Etemplate\Widget\Url::EMAIL_PREG, $values[$name]))
2724
+			{
2725
+				// only search for real email addresses, to not return to many contacts
2503 2726
 			{
2504 2727
 				$contacts = parent::search(array(
2505 2728
 					'email' => $values[$name],
2506 2729
 					'email_home' => $values[$name],
2507 2730
 				), false, '', '', '', false, 'OR');
2508 2731
 			}
2732
+			}
2509 2733
 		}
2510 2734
 		else
2511 2735
 		{
@@ -2519,10 +2743,13 @@  discard block
 block discarded – undo
2519 2743
 				!empty($values['n_given'])+!empty($values['n_family'])+!empty($values['org_name']) >= 2)
2520 2744
 			{
2521 2745
 				$filter = array();
2522
-				foreach(array('email', 'n_given', 'n_family', 'org_name') as $n)	// use email too, to exclude obvious false positives
2746
+				foreach(array('email', 'n_given', 'n_family', 'org_name') as $n)
2747
+				{
2748
+					// use email too, to exclude obvious false positives
2523 2749
 				{
2524 2750
 					if (!empty($values[$n])) $filter[$n] = $values[$n];
2525 2751
 				}
2752
+				}
2526 2753
 				$contacts = parent::search('', false, '', '', '', false, 'AND', false, $filter);
2527 2754
 			}
2528 2755
 		}
@@ -2530,7 +2757,10 @@  discard block
 block discarded – undo
2530 2757
 		{
2531 2758
 			foreach($contacts as $contact)
2532 2759
 			{
2533
-				if ($own_id && $contact['id'] == $own_id) continue;
2760
+				if ($own_id && $contact['id'] == $own_id)
2761
+				{
2762
+					continue;
2763
+				}
2534 2764
 
2535 2765
 				$ret['doublicates'][$contact['id']] = $this->fileas($contact).' ('.
2536 2766
 					(!$contact['owner'] ? lang('Accounts') : ($contact['owner'] == $this->user ?
@@ -2557,7 +2787,10 @@  discard block
 block discarded – undo
2557 2787
 		// CRM list comes from content, request, or preference
2558 2788
 		$crm_list = $content['crm_list'] ? $content['crm_list'] :
2559 2789
 			($_GET['crm_list'] ? $_GET['crm_list'] : $GLOBALS['egw_info']['user']['preferences']['addressbook']['crm_list']);
2560
-		if(!$crm_list || $crm_list == '~edit~') $crm_list = 'infolog';
2790
+		if(!$crm_list || $crm_list == '~edit~')
2791
+		{
2792
+			$crm_list = 'infolog';
2793
+		}
2561 2794
 
2562 2795
 		if(is_array($content))
2563 2796
 		{
@@ -2580,7 +2813,10 @@  discard block
 block discarded – undo
2580 2813
 					$inc = 1;
2581 2814
 					// fall through
2582 2815
 				case 'back':
2583
-					if (!isset($inc)) $inc = -1;
2816
+					if (!isset($inc))
2817
+					{
2818
+						$inc = -1;
2819
+					}
2584 2820
 					// get next/previous contact in selection
2585 2821
 					$query = Api\Cache::getSession('addressbook', 'index');
2586 2822
 					$query['start'] = $content['index'] + $inc;
@@ -2743,11 +2979,20 @@  discard block
 block discarded – undo
2743 2979
 		$readonlys['tabs']['distribution_list'] = !$content['distrib_lists'];#false;
2744 2980
 		$readonlys['tabs']['history'] = $this->contact_repository != 'sql' || !$content['id'] ||
2745 2981
 			$this->account_repository != 'sql' && $content['account_id'];
2746
-		if ($this->config['private_cf_tab']) $content['no_private_cfs'] = 0;
2982
+		if ($this->config['private_cf_tab'])
2983
+		{
2984
+			$content['no_private_cfs'] = 0;
2985
+		}
2747 2986
 
2748 2987
 		// last and next calendar date
2749
-		if (!empty($content['id'])) list(,$dates) = each($this->read_calendar(array($content['account_id'] ? $content['account_id'] : 'c'.$content['id']),false));
2750
-		if(is_array($dates)) $content += $dates;
2988
+		if (!empty($content['id']))
2989
+		{
2990
+			list(,$dates) = each($this->read_calendar(array($content['account_id'] ? $content['account_id'] : 'c'.$content['id']),false));
2991
+		}
2992
+		if(is_array($dates))
2993
+		{
2994
+			$content += $dates;
2995
+		}
2751 2996
 
2752 2997
 		// Disable importexport
2753 2998
 		$GLOBALS['egw_info']['flags']['disable_importexport']['export'] = true;
@@ -2826,7 +3071,10 @@  discard block
 block discarded – undo
2826 3071
 	 */
2827 3072
 	function email2link($email)
2828 3073
 	{
2829
-		if (strpos($email,'@') == false) return '';
3074
+		if (strpos($email,'@') == false)
3075
+		{
3076
+			return '';
3077
+		}
2830 3078
 
2831 3079
 		if($GLOBALS['egw_info']['user']['apps']['mail'])
2832 3080
 		{
@@ -2878,7 +3126,10 @@  discard block
 block discarded – undo
2878 3126
 				$query['advanced_search'] = array_intersect_key($_content,array_flip(array_merge($this->get_contact_columns(),array('operator','meth_select'))));
2879 3127
 				foreach ($query['advanced_search'] as $key => $value)
2880 3128
 				{
2881
-					if(!$value) unset($query['advanced_search'][$key]);
3129
+					if(!$value)
3130
+					{
3131
+						unset($query['advanced_search'][$key]);
3132
+					}
2882 3133
 				}
2883 3134
 				// Skip n_fn, it causes problems in sql
2884 3135
 				unset($query['advanced_search']['n_fn']);
@@ -2935,8 +3186,14 @@  discard block
 block discarded – undo
2935 3186
 			{
2936 3187
 				if (substr($data['type'], 0, 6) == 'select' && !($data['rows'] > 1))
2937 3188
 				{
2938
-					if (!isset($content['#'.$name])) $content['#'.$name] = '';
2939
-					if(!isset($data['values'][''])) $sel_options['#'.$name][''] = lang('Select one');
3189
+					if (!isset($content['#'.$name]))
3190
+					{
3191
+						$content['#'.$name] = '';
3192
+					}
3193
+					if(!isset($data['values']['']))
3194
+					{
3195
+						$sel_options['#'.$name][''] = lang('Select one');
3196
+					}
2940 3197
 				}
2941 3198
 				// Make them not required, otherwise you can't search
2942 3199
 				$this->tmpl->setElementAttribute('#'.$name, 'needed', FALSE);
@@ -2960,7 +3217,10 @@  discard block
 block discarded – undo
2960 3217
 		$content['no_tid'] = true;
2961 3218
 		$content['showsearchbuttons'] = true; // enable search operation and search buttons| they're disabled by default
2962 3219
 
2963
-		if ($this->config['private_cf_tab']) $content['no_private_cfs'] = 0;
3220
+		if ($this->config['private_cf_tab'])
3221
+		{
3222
+			$content['no_private_cfs'] = 0;
3223
+		}
2964 3224
 
2965 3225
 		$this->tmpl->set_cell_attribute('change_org','disabled',true);
2966 3226
 		return $this->tmpl->exec('addressbook.addressbook_ui.search',$content,$sel_options,$readonlys,array(),2);
Please login to merge, or discard this patch.