Completed
Push — master ( aa44e9...fa84e5 )
by Ralf
90:14 queued 73:21
created
addressbook/inc/class.addressbook_favorite_portlet.inc.php 3 patches
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -30,13 +30,13 @@  discard block
 block discarded – undo
30 30
 		$context['appname'] = 'addressbook';
31 31
 
32 32
 		// Let parent handle the basic stuff
33
-		parent::__construct($context,$need_reload);
33
+		parent::__construct($context, $need_reload);
34 34
 
35 35
 		$ui = new addressbook_ui();
36 36
 
37 37
 		$this->context['template'] = 'addressbook.index.rows';
38 38
 		$this->context['sel_options'] = array();
39
-		foreach($ui->content_types as $tid => $data)
39
+		foreach ($ui->content_types as $tid => $data)
40 40
 		{
41 41
 			$this->context['sel_options']['tid'][$tid] = $data['name'];
42 42
 		}
@@ -49,11 +49,11 @@  discard block
 block discarded – undo
49 49
 		);
50 50
 	}
51 51
 
52
-	public function exec($id = null, Etemplate &$etemplate = null)
52
+	public function exec($id = null, Etemplate&$etemplate = null)
53 53
 	{
54 54
 		$ui = new addressbook_ui();
55
-		$this->context['sel_options']['filter'] = $this->context['sel_options']['owner'] = $ui->get_addressbooks(Acl::READ,lang('All'));
56
-		$this->context['sel_options']['filter2'] = $ui->get_lists(Acl::READ,array('' => lang('none')));
55
+		$this->context['sel_options']['filter'] = $this->context['sel_options']['owner'] = $ui->get_addressbooks(Acl::READ, lang('All'));
56
+		$this->context['sel_options']['filter2'] = $ui->get_lists(Acl::READ, array('' => lang('none')));
57 57
 		$this->nm_settings['actions'] = $ui->get_actions($this->nm_settings['col_filter']['tid'], $this->nm_settings['org_view']);
58 58
 
59 59
 		parent::exec($id, $etemplate);
@@ -96,27 +96,27 @@  discard block
 block discarded – undo
96 96
 			{
97 97
 				// Some processing to add values in for links and cats
98 98
 				$success = $failed = $action_msg = $msg = null;
99
-				if ($ui->action($values['nm']['action'],$values['nm']['selected'],$values['nm']['select_all'],
100
-						$success,$failed,$action_msg,$values['do_email'] ? 'email' : 'index',$msg,$values['nm']['checkboxes']))
99
+				if ($ui->action($values['nm']['action'], $values['nm']['selected'], $values['nm']['select_all'],
100
+						$success, $failed, $action_msg, $values['do_email'] ? 'email' : 'index', $msg, $values['nm']['checkboxes']))
101 101
 				{
102
-					$msg .= lang('%1 contact(s) %2',$success,$action_msg);
103
-					Api\Json\Response::get()->apply('egw.message',array($msg,'success'));
104
-					foreach($values['nm']['selected'] as &$id)
102
+					$msg .= lang('%1 contact(s) %2', $success, $action_msg);
103
+					Api\Json\Response::get()->apply('egw.message', array($msg, 'success'));
104
+					foreach ($values['nm']['selected'] as &$id)
105 105
 					{
106 106
 						$id = 'addressbook::'.$id;
107 107
 					}
108 108
 					// Directly request an update - this will get addressbook tab too
109
-					Api\Json\Response::get()->apply('egw.dataRefreshUIDs',array($values['nm']['selected']));
109
+					Api\Json\Response::get()->apply('egw.dataRefreshUIDs', array($values['nm']['selected']));
110 110
 				}
111
-				elseif(is_null($msg))
111
+				elseif (is_null($msg))
112 112
 				{
113
-					$msg .= lang('%1 entries %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed);
114
-					Api\Json\Response::get()->apply('egw.message',array($msg,'error'));
113
+					$msg .= lang('%1 entries %2, %3 failed because of insufficent rights !!!', $success, $action_msg, $failed);
114
+					Api\Json\Response::get()->apply('egw.message', array($msg, 'error'));
115 115
 				}
116
-				elseif($msg)
116
+				elseif ($msg)
117 117
 				{
118
-					$msg .= "\n".lang('%1 entries %2, %3 failed.',$success,$action_msg,$failed);
119
-					Api\Json\Response::get()->apply('egw.message',array($msg,'error'));
118
+					$msg .= "\n".lang('%1 entries %2, %3 failed.', $success, $action_msg, $failed);
119
+					Api\Json\Response::get()->apply('egw.message', array($msg, 'error'));
120 120
 				}
121 121
 				unset($values['nm']['action']);
122 122
 				unset($values['nm']['select_all']);
Please login to merge, or discard this patch.
Doc Comments   -2 removed lines patch added patch discarded remove patch
@@ -86,8 +86,6 @@
 block discarded – undo
86 86
 	 * Here we need to handle any incoming data.  Setup is done in the constructor,
87 87
 	 * output is handled by parent.
88 88
 	 *
89
-	 * @param type $id
90
-	 * @param Etemplate $etemplate
91 89
 	 */
92 90
 	public static function process($content = array())
93 91
 	{
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@
 block discarded – undo
49 49
 	 *
50 50
 	 * @param boolean $need_reload Flag to indicate that the portlet needs to be reloaded (exec will be called)
51 51
 	 */
52
-	public function __construct(Array &$context = array(), &$need_reload = false)
52
+	public function __construct(array &$context = array(), &$need_reload = false)
53 53
 	{
54 54
 		if (false) parent::__construct();
55 55
 
Please login to merge, or discard this patch.
addressbook/inc/class.addressbook_wizard_import_contacts_csv.inc.php 2 patches
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -31,11 +31,11 @@  discard block
 block discarded – undo
31 31
 		$bocontacts = new Api\Contacts();
32 32
 		$this->mapping_fields = $bocontacts->contact_fields;
33 33
 
34
-		$categories = new Api\Categories('','addressbook');
34
+		$categories = new Api\Categories('', 'addressbook');
35 35
 		$cat_list = array();
36
-		foreach((array)$categories->return_sorted_array(0,False,'','','',true,0,true) as $cat)
36
+		foreach ((array)$categories->return_sorted_array(0, False, '', '', '', true, 0, true) as $cat)
37 37
 		{
38
-			$s = str_repeat(' ',$cat['level']) . stripslashes($cat['name']);
38
+			$s = str_repeat(' ', $cat['level']).stripslashes($cat['name']);
39 39
 
40 40
 			if (Api\Categories::is_global($cat))
41 41
 			{
@@ -46,14 +46,14 @@  discard block
 block discarded – undo
46 46
 				'title' => $cat['description'],
47 47
 			);
48 48
 		}
49
-		if(count($cat_list) > 0) {
49
+		if (count($cat_list) > 0) {
50 50
 			$this->mapping_fields[lang('Categories')] = $cat_list;
51 51
 		}
52 52
 
53
-		foreach($bocontacts->customfields as $name => $data) {
53
+		foreach ($bocontacts->customfields as $name => $data) {
54 54
 			$this->mapping_fields['#'.$name] = $data['label'];
55 55
 		}
56
-		unset($this->mapping_fields['jpegphoto']);        // can't cvs import that
56
+		unset($this->mapping_fields['jpegphoto']); // can't cvs import that
57 57
 
58 58
 		// Add in special handled fields
59 59
 		$this->mapping_fields[lang('Special')] = addressbook_import_contacts_csv::$special_fields;
@@ -75,18 +75,18 @@  discard block
 block discarded – undo
75 75
 
76 76
 	function wizard_step50(&$content, &$sel_options, &$readonlys, &$preserv)
77 77
 	{
78
-		if($content['field_mapping'][0] == lang('Categories')) {
78
+		if ($content['field_mapping'][0] == lang('Categories')) {
79 79
 			unset($content['field_mapping'][0]);
80 80
 		}
81 81
 		$result = parent::wizard_step50($content, $sel_options, $readonlys, $preserv);
82
-		$content['msg'] .= "\n*" . lang('Contact ID cannot be changed by import');
82
+		$content['msg'] .= "\n*".lang('Contact ID cannot be changed by import');
83 83
 
84 84
 		return $result;
85 85
 	}
86 86
 
87 87
 	function wizard_step60(&$content, &$sel_options, &$readonlys, &$preserv)
88 88
 	{
89
-		if($this->debug) error_log('addressbook.importexport.addressbook_csv_import::wizard_step60->$content '.print_r($content,true));
89
+		if ($this->debug) error_log('addressbook.importexport.addressbook_csv_import::wizard_step60->$content '.print_r($content, true));
90 90
 		unset($content['no_owner_map']);
91 91
 		// return from step60
92 92
 		if ($content['step'] == 'wizard_step60')
@@ -94,13 +94,13 @@  discard block
 block discarded – undo
94 94
 			switch (array_search('pressed', $content['button']))
95 95
 			{
96 96
 				case 'next':
97
-					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],1);
97
+					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], 1);
98 98
 				case 'previous' :
99
-					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],-1);
99
+					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], -1);
100 100
 				case 'finish':
101 101
 					return 'wizard_finish';
102 102
 				default :
103
-					return $this->wizard_step60($content,$sel_options,$readonlys,$preserv);
103
+					return $this->wizard_step60($content, $sel_options, $readonlys, $preserv);
104 104
 			}
105 105
 		}
106 106
 		// init step60
@@ -108,19 +108,19 @@  discard block
 block discarded – undo
108 108
 		{
109 109
 			$content['msg'] = $this->steps['wizard_step60'];
110 110
 			$content['step'] = 'wizard_step60';
111
-			if(!array_key_exists($content['contact_owner']) && $content['plugin_options']) {
111
+			if (!array_key_exists($content['contact_owner']) && $content['plugin_options']) {
112 112
 				$content['contact_owner'] = $content['plugin_options']['contact_owner'];
113 113
 			}
114
-			if(!array_key_exists($content['owner_from_csv']) && $content['plugin_options']) {
114
+			if (!array_key_exists($content['owner_from_csv']) && $content['plugin_options']) {
115 115
 				$content['owner_from_csv'] = $content['plugin_options']['owner_from_csv'];
116 116
 			}
117
-			if(!array_key_exists($content['change_owner']) && $content['plugin_options']) {
117
+			if (!array_key_exists($content['change_owner']) && $content['plugin_options']) {
118 118
 				$content['change_owner'] = $content['plugin_options']['change_owner'];
119 119
 			}
120 120
 
121 121
 			$bocontacts = new Api\Contacts();
122 122
 			$sel_options['contact_owner'] = array('personal' => lang("Importer's personal")) + $bocontacts->get_addressbooks(Acl::ADD);
123
-			if(!in_array('owner', $content['field_mapping'])) {
123
+			if (!in_array('owner', $content['field_mapping'])) {
124 124
 				$content['no_owner_map'] = true;
125 125
 			}
126 126
 
Please login to merge, or discard this patch.
Braces   +18 added lines, -8 removed lines patch added patch discarded remove patch
@@ -46,11 +46,13 @@  discard block
 block discarded – undo
46 46
 				'title' => $cat['description'],
47 47
 			);
48 48
 		}
49
-		if(count($cat_list) > 0) {
49
+		if(count($cat_list) > 0)
50
+		{
50 51
 			$this->mapping_fields[lang('Categories')] = $cat_list;
51 52
 		}
52 53
 
53
-		foreach($bocontacts->customfields as $name => $data) {
54
+		foreach($bocontacts->customfields as $name => $data)
55
+		{
54 56
 			$this->mapping_fields['#'.$name] = $data['label'];
55 57
 		}
56 58
 		unset($this->mapping_fields['jpegphoto']);        // can't cvs import that
@@ -75,7 +77,8 @@  discard block
 block discarded – undo
75 77
 
76 78
 	function wizard_step50(&$content, &$sel_options, &$readonlys, &$preserv)
77 79
 	{
78
-		if($content['field_mapping'][0] == lang('Categories')) {
80
+		if($content['field_mapping'][0] == lang('Categories'))
81
+		{
79 82
 			unset($content['field_mapping'][0]);
80 83
 		}
81 84
 		$result = parent::wizard_step50($content, $sel_options, $readonlys, $preserv);
@@ -86,7 +89,10 @@  discard block
 block discarded – undo
86 89
 
87 90
 	function wizard_step60(&$content, &$sel_options, &$readonlys, &$preserv)
88 91
 	{
89
-		if($this->debug) error_log('addressbook.importexport.addressbook_csv_import::wizard_step60->$content '.print_r($content,true));
92
+		if($this->debug)
93
+		{
94
+			error_log('addressbook.importexport.addressbook_csv_import::wizard_step60->$content '.print_r($content,true));
95
+		}
90 96
 		unset($content['no_owner_map']);
91 97
 		// return from step60
92 98
 		if ($content['step'] == 'wizard_step60')
@@ -108,19 +114,23 @@  discard block
 block discarded – undo
108 114
 		{
109 115
 			$content['msg'] = $this->steps['wizard_step60'];
110 116
 			$content['step'] = 'wizard_step60';
111
-			if(!array_key_exists($content['contact_owner']) && $content['plugin_options']) {
117
+			if(!array_key_exists($content['contact_owner']) && $content['plugin_options'])
118
+			{
112 119
 				$content['contact_owner'] = $content['plugin_options']['contact_owner'];
113 120
 			}
114
-			if(!array_key_exists($content['owner_from_csv']) && $content['plugin_options']) {
121
+			if(!array_key_exists($content['owner_from_csv']) && $content['plugin_options'])
122
+			{
115 123
 				$content['owner_from_csv'] = $content['plugin_options']['owner_from_csv'];
116 124
 			}
117
-			if(!array_key_exists($content['change_owner']) && $content['plugin_options']) {
125
+			if(!array_key_exists($content['change_owner']) && $content['plugin_options'])
126
+			{
118 127
 				$content['change_owner'] = $content['plugin_options']['change_owner'];
119 128
 			}
120 129
 
121 130
 			$bocontacts = new Api\Contacts();
122 131
 			$sel_options['contact_owner'] = array('personal' => lang("Importer's personal")) + $bocontacts->get_addressbooks(Acl::ADD);
123
-			if(!in_array('owner', $content['field_mapping'])) {
132
+			if(!in_array('owner', $content['field_mapping']))
133
+			{
124 134
 				$content['no_owner_map'] = true;
125 135
 			}
126 136
 
Please login to merge, or discard this patch.
addressbook/inc/class.addressbook_wizard_import_vcard.inc.php 2 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -28,20 +28,20 @@  discard block
 block discarded – undo
28 28
 
29 29
 	function wizard_step40(&$content, &$sel_options, &$readonlys, &$preserv)
30 30
 	{
31
-		if($this->debug) error_log(get_class($this) . '::wizard_step40->$content '.print_r($content,true));
31
+		if ($this->debug) error_log(get_class($this).'::wizard_step40->$content '.print_r($content, true));
32 32
 		// return from step40
33 33
 		if ($content['step'] == 'wizard_step40')
34 34
 		{
35 35
 			switch (array_search('pressed', $content['button']))
36 36
 			{
37 37
 				case 'next':
38
-					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],1);
38
+					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], 1);
39 39
 				case 'previous' :
40
-					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],-1);
40
+					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], -1);
41 41
 				case 'finish':
42 42
 					return 'wizard_finish';
43 43
 				default :
44
-					return $this->wizard_step60($content,$sel_options,$readonlys,$preserv);
44
+					return $this->wizard_step60($content, $sel_options, $readonlys, $preserv);
45 45
 			}
46 46
 		}
47 47
 		// init step40
@@ -49,20 +49,20 @@  discard block
 block discarded – undo
49 49
 		{
50 50
 			$content['msg'] = $this->steps['wizard_step40'];
51 51
 			$content['step'] = 'wizard_step40';
52
-			if(!$content['charset'] && $content['plugin_options']['charset']) {
52
+			if (!$content['charset'] && $content['plugin_options']['charset']) {
53 53
 				$content['charset'] = $content['plugin_options']['charset'];
54 54
 			}
55
-			$sel_options['charset'] = Api\Translation::get_installed_charsets()+
55
+			$sel_options['charset'] = Api\Translation::get_installed_charsets() +
56 56
 				array(
57 57
 					'user'  => lang('User preference'),
58 58
 				);
59 59
 
60 60
 			// Add in extra allowed charsets
61 61
 			$config = Api\Config::read('importexport');
62
-			$extra_charsets = array_intersect(explode(',',$config['import_charsets']), mb_list_encodings());
63
-			if($extra_charsets)
62
+			$extra_charsets = array_intersect(explode(',', $config['import_charsets']), mb_list_encodings());
63
+			if ($extra_charsets)
64 64
 			{
65
-				$sel_options['charset'] += array(lang('Extra encodings') => array_combine($extra_charsets,$extra_charsets));
65
+				$sel_options['charset'] += array(lang('Extra encodings') => array_combine($extra_charsets, $extra_charsets));
66 66
 			}
67 67
 
68 68
 			$preserv = $content;
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 
74 74
 	function wizard_step60(&$content, &$sel_options, &$readonlys, &$preserv)
75 75
 	{
76
-		if($this->debug) error_log(__METHOD__.print_r($content,true));
76
+		if ($this->debug) error_log(__METHOD__.print_r($content, true));
77 77
 
78 78
 		// return from step60
79 79
 		if ($content['step'] == 'wizard_step60')
@@ -81,13 +81,13 @@  discard block
 block discarded – undo
81 81
 			switch (array_search('pressed', $content['button']))
82 82
 			{
83 83
 				case 'next':
84
-					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],1);
84
+					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], 1);
85 85
 				case 'previous' :
86
-					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],-1);
86
+					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], -1);
87 87
 				case 'finish':
88 88
 					return 'wizard_finish';
89 89
 				default :
90
-					return $this->wizard_step60($content,$sel_options,$readonlys,$preserv);
90
+					return $this->wizard_step60($content, $sel_options, $readonlys, $preserv);
91 91
 			}
92 92
 		}
93 93
 		// init step60
@@ -95,10 +95,10 @@  discard block
 block discarded – undo
95 95
 		{
96 96
 			$content['msg'] = $this->steps['wizard_step60'];
97 97
 			$content['step'] = 'wizard_step60';
98
-			if(!array_key_exists($content['contact_owner']) && $content['plugin_options']) {
98
+			if (!array_key_exists($content['contact_owner']) && $content['plugin_options']) {
99 99
 				$content['contact_owner'] = $content['plugin_options']['contact_owner'];
100 100
 			}
101
-			if(!array_key_exists($content['change_owner']) && $content['plugin_options']) {
101
+			if (!array_key_exists($content['change_owner']) && $content['plugin_options']) {
102 102
 				$content['change_owner'] = $content['plugin_options']['change_owner'];
103 103
 			}
104 104
 
Please login to merge, or discard this patch.
Braces   +14 added lines, -5 removed lines patch added patch discarded remove patch
@@ -28,7 +28,10 @@  discard block
 block discarded – undo
28 28
 
29 29
 	function wizard_step40(&$content, &$sel_options, &$readonlys, &$preserv)
30 30
 	{
31
-		if($this->debug) error_log(get_class($this) . '::wizard_step40->$content '.print_r($content,true));
31
+		if($this->debug)
32
+		{
33
+			error_log(get_class($this) . '::wizard_step40->$content '.print_r($content,true));
34
+		}
32 35
 		// return from step40
33 36
 		if ($content['step'] == 'wizard_step40')
34 37
 		{
@@ -49,7 +52,8 @@  discard block
 block discarded – undo
49 52
 		{
50 53
 			$content['msg'] = $this->steps['wizard_step40'];
51 54
 			$content['step'] = 'wizard_step40';
52
-			if(!$content['charset'] && $content['plugin_options']['charset']) {
55
+			if(!$content['charset'] && $content['plugin_options']['charset'])
56
+			{
53 57
 				$content['charset'] = $content['plugin_options']['charset'];
54 58
 			}
55 59
 			$sel_options['charset'] = Api\Translation::get_installed_charsets()+
@@ -73,7 +77,10 @@  discard block
 block discarded – undo
73 77
 
74 78
 	function wizard_step60(&$content, &$sel_options, &$readonlys, &$preserv)
75 79
 	{
76
-		if($this->debug) error_log(__METHOD__.print_r($content,true));
80
+		if($this->debug)
81
+		{
82
+			error_log(__METHOD__.print_r($content,true));
83
+		}
77 84
 
78 85
 		// return from step60
79 86
 		if ($content['step'] == 'wizard_step60')
@@ -95,10 +102,12 @@  discard block
 block discarded – undo
95 102
 		{
96 103
 			$content['msg'] = $this->steps['wizard_step60'];
97 104
 			$content['step'] = 'wizard_step60';
98
-			if(!array_key_exists($content['contact_owner']) && $content['plugin_options']) {
105
+			if(!array_key_exists($content['contact_owner']) && $content['plugin_options'])
106
+			{
99 107
 				$content['contact_owner'] = $content['plugin_options']['contact_owner'];
100 108
 			}
101
-			if(!array_key_exists($content['change_owner']) && $content['plugin_options']) {
109
+			if(!array_key_exists($content['change_owner']) && $content['plugin_options'])
110
+			{
102 111
 				$content['change_owner'] = $content['plugin_options']['change_owner'];
103 112
 			}
104 113
 
Please login to merge, or discard this patch.
addressbook/inc/class.addressbook_export_contacts_csv.inc.php 5 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -365,10 +365,10 @@  discard block
 block discarded – undo
365 365
 	}
366 366
 
367 367
 	/**
368
-	* Convert some internal data to something with more meaning
369
-	*
370
-	* Dates, times, user IDs, category IDs
371
-	*/
368
+	 * Convert some internal data to something with more meaning
369
+	 *
370
+	 * Dates, times, user IDs, category IDs
371
+	 */
372 372
 	public static function convert(addressbook_egw_record &$record, $options) {
373 373
 
374 374
 		if ($record->tel_prefer) {
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
 	 * Adjust automatically generated filter fields
437 437
 	 */
438 438
 	public function get_filter_fields(Array &$filters)
439
-    {
439
+	{
440 440
 		unset($filters['last_event']);
441 441
 		unset($filters['next_event']);
442 442
 		foreach($filters as $field_name => &$settings)
Please login to merge, or discard this patch.
Spacing   +84 added lines, -84 removed lines patch added patch discarded remove patch
@@ -23,13 +23,13 @@  discard block
 block discarded – undo
23 23
 	 * Constants used for exploding categories & multi-selectboxes into seperate fields
24 24
 	 */
25 25
 	const NO_EXPLODE = False;
26
-	const MAIN_CATS = 'main_cats';	// Only the top-level categories get their own field
27
-	const EACH_CAT = 'each_cat';	// Every category gets its own field
28
-	const EXPLODE = 'explode';	// For [custom] multi-selects, each option gets its own field
26
+	const MAIN_CATS = 'main_cats'; // Only the top-level categories get their own field
27
+	const EACH_CAT = 'each_cat'; // Every category gets its own field
28
+	const EXPLODE = 'explode'; // For [custom] multi-selects, each option gets its own field
29 29
 
30 30
 	public function __construct()
31 31
 	{
32
-		$this->ui= new addressbook_ui();
32
+		$this->ui = new addressbook_ui();
33 33
 		$this->get_selects();
34 34
 	}
35 35
 
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 	 *
39 39
 	 * @param egw_record $_definition
40 40
 	 */
41
-	public function export( $_stream, importexport_definition $_definition) {
41
+	public function export($_stream, importexport_definition $_definition) {
42 42
 
43 43
 		$options = $_definition->plugin_options;
44 44
 		$this->export_object = $export_object = new importexport_export_csv($_stream, (array)$options);
@@ -47,9 +47,9 @@  discard block
 block discarded – undo
47 47
 
48 48
 		// Addressbook defines its own export imits
49 49
 		$limit_exception = Api\Storage\Merge::is_export_limit_excepted();
50
-		$export_limit = Api\Storage\Merge::getExportLimit($app='addressbook');
50
+		$export_limit = Api\Storage\Merge::getExportLimit($app = 'addressbook');
51 51
 		if (!$limit_exception) $export_object->export_limit = $export_limit; // we may not need that after all
52
-		if($export_limit == 'no' && !$limit_exception) {
52
+		if ($export_limit == 'no' && !$limit_exception) {
53 53
 			return;
54 54
 		}
55 55
 
@@ -60,18 +60,18 @@  discard block
 block discarded – undo
60 60
 		if ($options['selection'] == 'search') {
61 61
 			// uicontacts selection with checkbox 'use_all'
62 62
 			$query = Api\Cache::getSession('addressbook', 'index');
63
-			$query['num_rows'] = -1;	// all
64
-			$query['csv_export'] = true;	// so get_rows method _can_ produce different content or not store state in the session
63
+			$query['num_rows'] = -1; // all
64
+			$query['csv_export'] = true; // so get_rows method _can_ produce different content or not store state in the session
65 65
 			$query['order'] = 'contact_id';
66
-			if(!array_key_exists('filter',$query)) $query['filter'] = $GLOBALS['egw_info']['user']['account_id'];
66
+			if (!array_key_exists('filter', $query)) $query['filter'] = $GLOBALS['egw_info']['user']['account_id'];
67 67
 			$readonlys = null;
68
-			$this->ui->get_rows($query,$selection,$readonlys, true);	// only return the ids
68
+			$this->ui->get_rows($query, $selection, $readonlys, true); // only return the ids
69 69
 		}
70
-		elseif ( $options['selection'] == 'all' ) {
70
+		elseif ($options['selection'] == 'all') {
71 71
 			if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) {
72 72
 				$col_filter['account_id'] = null;
73 73
 			}
74
-			$selection = ExecMethod2('addressbook.addressbook_bo.search', array(), true, '', '','',false,'AND',false,$col_filter);
74
+			$selection = ExecMethod2('addressbook.addressbook_bo.search', array(), true, '', '', '', false, 'AND', false, $col_filter);
75 75
 			//$uicontacts->get_rows($query,$selection,$readonlys,true);
76 76
 		}
77 77
 		elseif ($options['selection'] == 'filter')
@@ -80,90 +80,90 @@  discard block
 block discarded – undo
80 80
 			$query = array();
81 81
 
82 82
 			// Handle ranges
83
-			foreach($filter as $field => $value)
83
+			foreach ($filter as $field => $value)
84 84
 			{
85
-				if($field == 'cat_id')
85
+				if ($field == 'cat_id')
86 86
 				{
87
-					$query['col_filter'][$field] = implode(',',$value);
87
+					$query['col_filter'][$field] = implode(',', $value);
88 88
 					continue;
89 89
 				}
90 90
 
91 91
 				// Birthdays in addressbook are formatted Y-m-d
92
-				if($field == 'bday')
92
+				if ($field == 'bday')
93 93
 				{
94
-					if($value['from'])
94
+					if ($value['from'])
95 95
 					{
96
-						$query['col_filter'][] = "contact_bday >= " . $GLOBALS['egw']->db->quote(date('Y-m-d', (int)$value['from']));
96
+						$query['col_filter'][] = "contact_bday >= ".$GLOBALS['egw']->db->quote(date('Y-m-d', (int)$value['from']));
97 97
 					}
98
-					if($value['to'])
98
+					if ($value['to'])
99 99
 					{
100
-						$query['col_filter'][] = "contact_bday <= " . $GLOBALS['egw']->db->quote(date('Y-m-d', (int)$value['to']));
100
+						$query['col_filter'][] = "contact_bday <= ".$GLOBALS['egw']->db->quote(date('Y-m-d', (int)$value['to']));
101 101
 					}
102 102
 					continue;
103 103
 				}
104 104
 				// Custom fields & listed exceptions are not filtered with contact_ prefix
105
-				if(strpos($field, '#') !== 0 && !in_array($field, array('tid','owner')))
105
+				if (strpos($field, '#') !== 0 && !in_array($field, array('tid', 'owner')))
106 106
 				{
107 107
 					$field = 'contact_'.$field;
108 108
 				}
109 109
 				$query['col_filter'][$field] = $value;
110
-				if(!is_array($value) || (!$value['from'] && !$value['to'])) continue;
110
+				if (!is_array($value) || (!$value['from'] && !$value['to'])) continue;
111 111
 
112 112
 				// Ranges are inclusive, so should be provided that way (from 2 to 10 includes 2 and 10)
113
-				if($value['from']) $query['col_filter'][] = "$field >= " . (int)$value['from'];
114
-				if($value['to']) $query['col_filter'][] = "$field <= " . (int)$value['to'];
113
+				if ($value['from']) $query['col_filter'][] = "$field >= ".(int)$value['from'];
114
+				if ($value['to']) $query['col_filter'][] = "$field <= ".(int)$value['to'];
115 115
 				unset($query['col_filter'][$field]);
116 116
 			}
117
-			$selection = ExecMethod2('addressbook.addressbook_bo.search', array(), true, '', '','',false,'AND',false,$query['col_filter']);
117
+			$selection = ExecMethod2('addressbook.addressbook_bo.search', array(), true, '', '', '', false, 'AND', false, $query['col_filter']);
118 118
 		}
119 119
 		else
120 120
 		{
121
-			$selection = explode(',',$options['selection']);
121
+			$selection = explode(',', $options['selection']);
122 122
 		}
123
-		if(!is_array($selection))
123
+		if (!is_array($selection))
124 124
 		{
125 125
 			$selection = array();
126 126
 		}
127 127
 		$GLOBALS['egw_info']['flags']['currentapp'] = $old_app;
128 128
 
129
-		if(Api\Storage\Merge::hasExportLimit($export_limit) && !$limit_exception) {
129
+		if (Api\Storage\Merge::hasExportLimit($export_limit) && !$limit_exception) {
130 130
 			$selection = array_slice($selection, 0, $export_limit);
131 131
 		}
132 132
 
133
-		if($options['explode_multiselects']) {
133
+		if ($options['explode_multiselects']) {
134 134
 			$customfields = Api\Storage\Customfields::get('addressbook');
135 135
 			$additional_fields = array();
136 136
 			$cat_obj = new Api\Categories('', 'addressbook');
137
-			foreach($options['explode_multiselects'] as $field => $explode) {
138
-				switch($explode['explode']) {
137
+			foreach ($options['explode_multiselects'] as $field => $explode) {
138
+				switch ($explode['explode']) {
139 139
 					case self::MAIN_CATS:
140
-						$cats = $cat_obj->return_array('mains', 0, false,'','ASC','',true);
141
-						foreach($cats as $settings) {
140
+						$cats = $cat_obj->return_array('mains', 0, false, '', 'ASC', '', true);
141
+						foreach ($cats as $settings) {
142 142
 							$additional_fields[$field][$settings['id']] = array(
143 143
 								'count' => 0,
144 144
 								'label' => $settings['name'],
145 145
 								'subs' => array(),
146 146
 							);
147 147
 							$subs = $cat_obj->return_sorted_array(0, False, '', 'ASC', 'cat_name', True, $settings['id']);
148
-							foreach($subs as $sub) {
148
+							foreach ($subs as $sub) {
149 149
 								$name = $sub['name'];
150 150
 								$path = $sub;
151
-								while($path['parent'] != $settings['id']) {
151
+								while ($path['parent'] != $settings['id']) {
152 152
 									$path = $cat_obj->read($path['parent']);
153
-									$name = $path['name'] . '/' . $name;
153
+									$name = $path['name'].'/'.$name;
154 154
 								}
155 155
 								$additional_fields[$field][$settings['id']]['subs'][$sub['id']] = $name;
156 156
 							}
157 157
 						}
158 158
 						break;
159 159
 					case self::EACH_CAT:
160
-						$cats = $cat_obj->return_array('all', 0, false,'','ASC','',true);
161
-						foreach($cats as $settings) {
160
+						$cats = $cat_obj->return_array('all', 0, false, '', 'ASC', '', true);
161
+						foreach ($cats as $settings) {
162 162
 							$name = $settings['name'];
163 163
 							$path = $settings;
164
-							while($path['level'] != 0) {
164
+							while ($path['level'] != 0) {
165 165
 								$path = $cat_obj->read($path['parent']);
166
-								$name = $path['name'] . '/' . $name;
166
+								$name = $path['name'].'/'.$name;
167 167
 							}
168 168
 							$additional_fields[$field][$settings['id']] = array(
169 169
 								'count' => 0,
@@ -174,10 +174,10 @@  discard block
 block discarded – undo
174 174
 					case self::EXPLODE:
175 175
 						// Only works for custom fields
176 176
 						$index = substr($field, 1);
177
-						foreach($customfields[$index]['values'] as $key => $value) {
177
+						foreach ($customfields[$index]['values'] as $key => $value) {
178 178
 							$additional_fields[$field][$key] = array(
179 179
 								'count' => 0,
180
-								'label' => $customfields[$index]['label'] . ': ' . $value,
180
+								'label' => $customfields[$index]['label'].': '.$value,
181 181
 							);
182 182
 						}
183 183
 						break;
@@ -186,29 +186,29 @@  discard block
 block discarded – undo
186 186
 
187 187
 			// Check records to see if additional fields are actually used
188 188
 			foreach ($selection as $_contact) {
189
-				if(is_array($_contact) && array_key_exists('photo', $_contact)) {
189
+				if (is_array($_contact) && array_key_exists('photo', $_contact)) {
190 190
 					unset($_contact['photo']);
191 191
 				}
192
-				if(is_array($_contact) && count($_contact) == 1 && $_contact['id']) {
192
+				if (is_array($_contact) && count($_contact) == 1 && $_contact['id']) {
193 193
 					$_contact = $_contact['id'];
194 194
 				}
195
-				if(is_array($_contact) && $_contact['id']) {
195
+				if (is_array($_contact) && $_contact['id']) {
196 196
 					$contact = new addressbook_egw_record();
197 197
 					$contact->set_record($_contact);
198 198
 				} else {
199 199
 					$contact = new addressbook_egw_record($_contact);
200 200
 				}
201
-				foreach($additional_fields as $field => &$values) {
202
-					if(!$contact->$field) continue;
203
-					foreach($values as $value => &$settings) {
204
-						if(!is_array($contact->$field)) {
201
+				foreach ($additional_fields as $field => &$values) {
202
+					if (!$contact->$field) continue;
203
+					foreach ($values as $value => &$settings) {
204
+						if (!is_array($contact->$field)) {
205 205
 							$contact->$field = explode(',', $contact->$field);
206 206
 						}
207
-						if(is_array($contact->$field) && in_array($value, $contact->$field)) {
207
+						if (is_array($contact->$field) && in_array($value, $contact->$field)) {
208 208
 							$settings['count']++;
209
-						} elseif($contact->$field == $value) {
209
+						} elseif ($contact->$field == $value) {
210 210
 							$settings['count']++;
211
-						} elseif($options['explode_multiselects'][$field]['explode'] == self::MAIN_CATS && array_intersect($contact->$field, array_keys($settings['subs']))) {
211
+						} elseif ($options['explode_multiselects'][$field]['explode'] == self::MAIN_CATS && array_intersect($contact->$field, array_keys($settings['subs']))) {
212 212
 							$settings['count']++;
213 213
 						}
214 214
 					}
@@ -220,18 +220,18 @@  discard block
 block discarded – undo
220 220
 			unset($settings);
221 221
 
222 222
 			// Add additional columns
223
-			foreach($additional_fields as $field => $additional_values) {
223
+			foreach ($additional_fields as $field => $additional_values) {
224 224
 				// Remove original
225 225
 				unset($options['mapping'][$field]);
226 226
 				// Add exploded
227 227
 				$field_count = 0;
228
-				foreach($additional_values as $value => $settings) {
229
-					if($settings['count'] > 0) {
228
+				foreach ($additional_values as $value => $settings) {
229
+					if ($settings['count'] > 0) {
230 230
 						$field_count += $settings['count'];
231 231
 						$options['mapping'][$field.'-'.$value] = $settings['label'];
232 232
 					}
233 233
 				}
234
-				if($field_count > 0) {
234
+				if ($field_count > 0) {
235 235
 					// Set some options for converting
236 236
 					$options['explode_multiselects'][$field]['values'] = $additional_values;
237 237
 				} else {
@@ -244,12 +244,12 @@  discard block
 block discarded – undo
244 244
 		$export_object->set_mapping($options['mapping']);
245 245
 
246 246
 		// Add in last/next event, if needed
247
-		if($options['mapping']['last_date'] || $options['mapping']['next_date'])
247
+		if ($options['mapping']['last_date'] || $options['mapping']['next_date'])
248 248
 		{
249 249
 			$contact_ids = array();
250
-			foreach($selection as $_contact)
250
+			foreach ($selection as $_contact)
251 251
 			{
252
-				if(is_array($_contact) && $_contact['id'])
252
+				if (is_array($_contact) && $_contact['id'])
253 253
 				{
254 254
 					$contact_ids[] = $_contact['id'];
255 255
 				}
@@ -264,20 +264,20 @@  discard block
 block discarded – undo
264 264
 		// $options['selection'] is array of identifiers as this plugin doesn't
265 265
 		// support other selectors atm.
266 266
 		foreach ($selection as $_contact) {
267
-			if(is_array($_contact) && array_key_exists('photo', $_contact)) {
267
+			if (is_array($_contact) && array_key_exists('photo', $_contact)) {
268 268
 				unset($_contact['photo']);
269 269
 			}
270
-			if(is_array($_contact) && count($_contact) == 1 && $_contact['id']) {
270
+			if (is_array($_contact) && count($_contact) == 1 && $_contact['id']) {
271 271
 				$_contact = $_contact['id'];
272 272
 			}
273
-			if(is_array($_contact) && $_contact['id']) {
273
+			if (is_array($_contact) && $_contact['id']) {
274 274
 				$contact = new addressbook_egw_record();
275 275
 				$contact->set_record($_contact);
276 276
 			} else {
277 277
 				$contact = new addressbook_egw_record($_contact);
278 278
 			}
279 279
 
280
-			if($events && $events[$contact->id])
280
+			if ($events && $events[$contact->id])
281 281
 			{
282 282
 				// NB: last_date and next_date are used instead of last_event & next_event
283 283
 				// to avoid automatic conversion - we want to export link title, not date-time
@@ -286,12 +286,12 @@  discard block
 block discarded – undo
286 286
 			}
287 287
 			// Some conversion
288 288
 			$this->convert($contact, $options);
289
-			if($options['convert']) {
290
-				importexport_export_csv::convert($contact, addressbook_egw_record::$types, 'addressbook',$this->selects);
289
+			if ($options['convert']) {
290
+				importexport_export_csv::convert($contact, addressbook_egw_record::$types, 'addressbook', $this->selects);
291 291
 			} else {
292 292
 				// Implode arrays, so they don't say 'Array'
293
-				foreach($contact->get_record_array() as $key => $value) {
294
-					if(is_array($value)) $contact->$key = implode(',', $value);
293
+				foreach ($contact->get_record_array() as $key => $value) {
294
+					if (is_array($value)) $contact->$key = implode(',', $value);
295 295
 				}
296 296
 			}
297 297
 
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
 	 */
339 339
 	public function get_filename()
340 340
 	{
341
-		if(is_object($this->export_object) && $this->export_object->get_num_of_records() == 1)
341
+		if (is_object($this->export_object) && $this->export_object->get_num_of_records() == 1)
342 342
 		{
343 343
 			return $this->export_object->record->get_title();
344 344
 		}
@@ -369,26 +369,26 @@  discard block
 block discarded – undo
369 369
 	*
370 370
 	* Dates, times, user IDs, category IDs
371 371
 	*/
372
-	public static function convert(addressbook_egw_record &$record, $options) {
372
+	public static function convert(addressbook_egw_record&$record, $options) {
373 373
 
374 374
 		if ($record->tel_prefer) {
375 375
 			$field = $record->tel_prefer;
376 376
 			$record->tel_prefer = $record->$field;
377 377
 		}
378 378
 
379
-		if(!is_array($options['explode_multiselects']))
379
+		if (!is_array($options['explode_multiselects']))
380 380
 		{
381 381
 			return;
382 382
 		}
383
-		foreach((array)$options['explode_multiselects'] as $field => $explode_settings) {
384
-			if(!is_array($record->$field)) $record->$field = explode(',', $record->$field);
385
-			foreach((array)$explode_settings['values'] as $value => $settings) {
383
+		foreach ((array)$options['explode_multiselects'] as $field => $explode_settings) {
384
+			if (!is_array($record->$field)) $record->$field = explode(',', $record->$field);
385
+			foreach ((array)$explode_settings['values'] as $value => $settings) {
386 386
 				$field_name = "$field-$value";
387 387
 				$record->$field_name = array();
388
-				if(is_array($record->$field) && in_array($value, $record->$field) || $record->$field == $value) {
389
-					if($explode_settings['explode'] != self::MAIN_CATS) {
388
+				if (is_array($record->$field) && in_array($value, $record->$field) || $record->$field == $value) {
389
+					if ($explode_settings['explode'] != self::MAIN_CATS) {
390 390
 						$record->$field_name = $options['convert'] ? lang('Yes') : true;
391
-					} elseif($options['convert']) {
391
+					} elseif ($options['convert']) {
392 392
 						// 3 part assign due to magic get method
393 393
 						$record_value = $record->$field_name;
394 394
 						$record_value[] = $settings['label'];
@@ -397,16 +397,16 @@  discard block
 block discarded – undo
397 397
 						$record->$field_name = $value;
398 398
 					}
399 399
 				}
400
-				if($explode_settings['explode'] == self::MAIN_CATS && count(array_intersect($record->$field, array_keys($settings['subs'])))) {
400
+				if ($explode_settings['explode'] == self::MAIN_CATS && count(array_intersect($record->$field, array_keys($settings['subs'])))) {
401 401
 					// 3 part assign due to magic get method
402 402
 					$record_value = $record->$field_name;
403
-					if(!is_array($record_value)) $record_value = array($record_value);
404
-					foreach(array_intersect($record->$field, array_keys($settings['subs'])) as $sub_id) {
403
+					if (!is_array($record_value)) $record_value = array($record_value);
404
+					foreach (array_intersect($record->$field, array_keys($settings['subs'])) as $sub_id) {
405 405
 						$record_value[] = $options['convert'] ? $settings['subs'][$sub_id] : $sub_id;
406 406
 					}
407 407
 					$record->$field_name = $record_value;
408 408
 				}
409
-				if(is_array($record->$field_name)) $record->$field_name = implode(($options['convert'] ? ', ' : ','), $record->$field_name);
409
+				if (is_array($record->$field_name)) $record->$field_name = implode(($options['convert'] ? ', ' : ','), $record->$field_name);
410 410
 			}
411 411
 		}
412 412
 	}
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
 		$this->selects = array(
418 418
 			'tid' => array('n' => 'Contact')
419 419
 		);
420
-		foreach($this->ui->content_types as $tid => $data)
420
+		foreach ($this->ui->content_types as $tid => $data)
421 421
 		{
422 422
 			$this->selects['tid'][$tid] = $data['name'];
423 423
 		}
@@ -439,9 +439,9 @@  discard block
 block discarded – undo
439 439
     {
440 440
 		unset($filters['last_event']);
441 441
 		unset($filters['next_event']);
442
-		foreach($filters as $field_name => &$settings)
442
+		foreach ($filters as $field_name => &$settings)
443 443
 		{
444
-			if($this->selects[$field_name]) $settings['values'] = $this->selects[$field_name];
444
+			if ($this->selects[$field_name]) $settings['values'] = $this->selects[$field_name];
445 445
 		}
446 446
 		$filters['owner'] = array(
447 447
 			'name'		=> 'owner',
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@
 block discarded – undo
29 29
 	/**
30 30
 	 * Exports records as defined in $_definition
31 31
 	 *
32
-	 * @param egw_record $_definition
32
+	 * @param importexport_definition $_definition
33 33
 	 */
34 34
 	public function export( $_stream, importexport_definition $_definition) {
35 35
 		$options = $_definition->plugin_options;
Please login to merge, or discard this patch.
Braces   +164 added lines, -67 removed lines patch added patch discarded remove patch
@@ -38,7 +38,8 @@  discard block
 block discarded – undo
38 38
 	 *
39 39
 	 * @param egw_record $_definition
40 40
 	 */
41
-	public function export( $_stream, importexport_definition $_definition) {
41
+	public function export( $_stream, importexport_definition $_definition)
42
+	{
42 43
 
43 44
 		$options = $_definition->plugin_options;
44 45
 		$this->export_object = $export_object = new importexport_export_csv($_stream, (array)$options);
@@ -48,8 +49,13 @@  discard block
 block discarded – undo
48 49
 		// Addressbook defines its own export imits
49 50
 		$limit_exception = Api\Storage\Merge::is_export_limit_excepted();
50 51
 		$export_limit = Api\Storage\Merge::getExportLimit($app='addressbook');
51
-		if (!$limit_exception) $export_object->export_limit = $export_limit; // we may not need that after all
52
-		if($export_limit == 'no' && !$limit_exception) {
52
+		if (!$limit_exception)
53
+		{
54
+			$export_object->export_limit = $export_limit;
55
+		}
56
+		// we may not need that after all
57
+		if($export_limit == 'no' && !$limit_exception)
58
+		{
53 59
 			return;
54 60
 		}
55 61
 
@@ -57,18 +63,24 @@  discard block
 block discarded – undo
57 63
 		$old_app = $GLOBALS['egw_info']['flags']['currentapp'];
58 64
 		$GLOBALS['egw_info']['flags']['currentapp'] = 'addressbook';
59 65
 
60
-		if ($options['selection'] == 'search') {
66
+		if ($options['selection'] == 'search')
67
+		{
61 68
 			// uicontacts selection with checkbox 'use_all'
62 69
 			$query = Api\Cache::getSession('addressbook', 'index');
63 70
 			$query['num_rows'] = -1;	// all
64 71
 			$query['csv_export'] = true;	// so get_rows method _can_ produce different content or not store state in the session
65 72
 			$query['order'] = 'contact_id';
66
-			if(!array_key_exists('filter',$query)) $query['filter'] = $GLOBALS['egw_info']['user']['account_id'];
73
+			if(!array_key_exists('filter',$query))
74
+			{
75
+				$query['filter'] = $GLOBALS['egw_info']['user']['account_id'];
76
+			}
67 77
 			$readonlys = null;
68 78
 			$this->ui->get_rows($query,$selection,$readonlys, true);	// only return the ids
69 79
 		}
70
-		elseif ( $options['selection'] == 'all' ) {
71
-			if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) {
80
+		elseif ( $options['selection'] == 'all' )
81
+		{
82
+			if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'])
83
+			{
72 84
 				$col_filter['account_id'] = null;
73 85
 			}
74 86
 			$selection = ExecMethod2('addressbook.addressbook_bo.search', array(), true, '', '','',false,'AND',false,$col_filter);
@@ -107,11 +119,20 @@  discard block
 block discarded – undo
107 119
 					$field = 'contact_'.$field;
108 120
 				}
109 121
 				$query['col_filter'][$field] = $value;
110
-				if(!is_array($value) || (!$value['from'] && !$value['to'])) continue;
122
+				if(!is_array($value) || (!$value['from'] && !$value['to']))
123
+				{
124
+					continue;
125
+				}
111 126
 
112 127
 				// Ranges are inclusive, so should be provided that way (from 2 to 10 includes 2 and 10)
113
-				if($value['from']) $query['col_filter'][] = "$field >= " . (int)$value['from'];
114
-				if($value['to']) $query['col_filter'][] = "$field <= " . (int)$value['to'];
128
+				if($value['from'])
129
+				{
130
+					$query['col_filter'][] = "$field >= " . (int)$value['from'];
131
+				}
132
+				if($value['to'])
133
+				{
134
+					$query['col_filter'][] = "$field <= " . (int)$value['to'];
135
+				}
115 136
 				unset($query['col_filter'][$field]);
116 137
 			}
117 138
 			$selection = ExecMethod2('addressbook.addressbook_bo.search', array(), true, '', '','',false,'AND',false,$query['col_filter']);
@@ -126,29 +147,36 @@  discard block
 block discarded – undo
126 147
 		}
127 148
 		$GLOBALS['egw_info']['flags']['currentapp'] = $old_app;
128 149
 
129
-		if(Api\Storage\Merge::hasExportLimit($export_limit) && !$limit_exception) {
150
+		if(Api\Storage\Merge::hasExportLimit($export_limit) && !$limit_exception)
151
+		{
130 152
 			$selection = array_slice($selection, 0, $export_limit);
131 153
 		}
132 154
 
133
-		if($options['explode_multiselects']) {
155
+		if($options['explode_multiselects'])
156
+		{
134 157
 			$customfields = Api\Storage\Customfields::get('addressbook');
135 158
 			$additional_fields = array();
136 159
 			$cat_obj = new Api\Categories('', 'addressbook');
137
-			foreach($options['explode_multiselects'] as $field => $explode) {
138
-				switch($explode['explode']) {
160
+			foreach($options['explode_multiselects'] as $field => $explode)
161
+			{
162
+				switch($explode['explode'])
163
+				{
139 164
 					case self::MAIN_CATS:
140 165
 						$cats = $cat_obj->return_array('mains', 0, false,'','ASC','',true);
141
-						foreach($cats as $settings) {
166
+						foreach($cats as $settings)
167
+						{
142 168
 							$additional_fields[$field][$settings['id']] = array(
143 169
 								'count' => 0,
144 170
 								'label' => $settings['name'],
145 171
 								'subs' => array(),
146 172
 							);
147 173
 							$subs = $cat_obj->return_sorted_array(0, False, '', 'ASC', 'cat_name', True, $settings['id']);
148
-							foreach($subs as $sub) {
174
+							foreach($subs as $sub)
175
+							{
149 176
 								$name = $sub['name'];
150 177
 								$path = $sub;
151
-								while($path['parent'] != $settings['id']) {
178
+								while($path['parent'] != $settings['id'])
179
+								{
152 180
 									$path = $cat_obj->read($path['parent']);
153 181
 									$name = $path['name'] . '/' . $name;
154 182
 								}
@@ -158,10 +186,12 @@  discard block
 block discarded – undo
158 186
 						break;
159 187
 					case self::EACH_CAT:
160 188
 						$cats = $cat_obj->return_array('all', 0, false,'','ASC','',true);
161
-						foreach($cats as $settings) {
189
+						foreach($cats as $settings)
190
+						{
162 191
 							$name = $settings['name'];
163 192
 							$path = $settings;
164
-							while($path['level'] != 0) {
193
+							while($path['level'] != 0)
194
+							{
165 195
 								$path = $cat_obj->read($path['parent']);
166 196
 								$name = $path['name'] . '/' . $name;
167 197
 							}
@@ -174,7 +204,8 @@  discard block
 block discarded – undo
174 204
 					case self::EXPLODE:
175 205
 						// Only works for custom fields
176 206
 						$index = substr($field, 1);
177
-						foreach($customfields[$index]['values'] as $key => $value) {
207
+						foreach($customfields[$index]['values'] as $key => $value)
208
+						{
178 209
 							$additional_fields[$field][$key] = array(
179 210
 								'count' => 0,
180 211
 								'label' => $customfields[$index]['label'] . ': ' . $value,
@@ -185,30 +216,47 @@  discard block
 block discarded – undo
185 216
 			}
186 217
 
187 218
 			// Check records to see if additional fields are actually used
188
-			foreach ($selection as $_contact) {
189
-				if(is_array($_contact) && array_key_exists('photo', $_contact)) {
219
+			foreach ($selection as $_contact)
220
+			{
221
+				if(is_array($_contact) && array_key_exists('photo', $_contact))
222
+				{
190 223
 					unset($_contact['photo']);
191 224
 				}
192
-				if(is_array($_contact) && count($_contact) == 1 && $_contact['id']) {
225
+				if(is_array($_contact) && count($_contact) == 1 && $_contact['id'])
226
+				{
193 227
 					$_contact = $_contact['id'];
194 228
 				}
195
-				if(is_array($_contact) && $_contact['id']) {
229
+				if(is_array($_contact) && $_contact['id'])
230
+				{
196 231
 					$contact = new addressbook_egw_record();
197 232
 					$contact->set_record($_contact);
198
-				} else {
233
+				}
234
+				else
235
+				{
199 236
 					$contact = new addressbook_egw_record($_contact);
200 237
 				}
201
-				foreach($additional_fields as $field => &$values) {
202
-					if(!$contact->$field) continue;
203
-					foreach($values as $value => &$settings) {
204
-						if(!is_array($contact->$field)) {
238
+				foreach($additional_fields as $field => &$values)
239
+				{
240
+					if(!$contact->$field)
241
+					{
242
+						continue;
243
+					}
244
+					foreach($values as $value => &$settings)
245
+					{
246
+						if(!is_array($contact->$field))
247
+						{
205 248
 							$contact->$field = explode(',', $contact->$field);
206 249
 						}
207
-						if(is_array($contact->$field) && in_array($value, $contact->$field)) {
250
+						if(is_array($contact->$field) && in_array($value, $contact->$field))
251
+						{
208 252
 							$settings['count']++;
209
-						} elseif($contact->$field == $value) {
253
+						}
254
+						elseif($contact->$field == $value)
255
+						{
210 256
 							$settings['count']++;
211
-						} elseif($options['explode_multiselects'][$field]['explode'] == self::MAIN_CATS && array_intersect($contact->$field, array_keys($settings['subs']))) {
257
+						}
258
+						elseif($options['explode_multiselects'][$field]['explode'] == self::MAIN_CATS && array_intersect($contact->$field, array_keys($settings['subs'])))
259
+						{
212 260
 							$settings['count']++;
213 261
 						}
214 262
 					}
@@ -220,21 +268,27 @@  discard block
 block discarded – undo
220 268
 			unset($settings);
221 269
 
222 270
 			// Add additional columns
223
-			foreach($additional_fields as $field => $additional_values) {
271
+			foreach($additional_fields as $field => $additional_values)
272
+			{
224 273
 				// Remove original
225 274
 				unset($options['mapping'][$field]);
226 275
 				// Add exploded
227 276
 				$field_count = 0;
228
-				foreach($additional_values as $value => $settings) {
229
-					if($settings['count'] > 0) {
277
+				foreach($additional_values as $value => $settings)
278
+				{
279
+					if($settings['count'] > 0)
280
+					{
230 281
 						$field_count += $settings['count'];
231 282
 						$options['mapping'][$field.'-'.$value] = $settings['label'];
232 283
 					}
233 284
 				}
234
-				if($field_count > 0) {
285
+				if($field_count > 0)
286
+				{
235 287
 					// Set some options for converting
236 288
 					$options['explode_multiselects'][$field]['values'] = $additional_values;
237
-				} else {
289
+				}
290
+				else
291
+				{
238 292
 					// Don't need this anymore
239 293
 					unset($options['explode_multiselects'][$field]);
240 294
 				}
@@ -263,17 +317,23 @@  discard block
 block discarded – undo
263 317
 
264 318
 		// $options['selection'] is array of identifiers as this plugin doesn't
265 319
 		// support other selectors atm.
266
-		foreach ($selection as $_contact) {
267
-			if(is_array($_contact) && array_key_exists('photo', $_contact)) {
320
+		foreach ($selection as $_contact)
321
+		{
322
+			if(is_array($_contact) && array_key_exists('photo', $_contact))
323
+			{
268 324
 				unset($_contact['photo']);
269 325
 			}
270
-			if(is_array($_contact) && count($_contact) == 1 && $_contact['id']) {
326
+			if(is_array($_contact) && count($_contact) == 1 && $_contact['id'])
327
+			{
271 328
 				$_contact = $_contact['id'];
272 329
 			}
273
-			if(is_array($_contact) && $_contact['id']) {
330
+			if(is_array($_contact) && $_contact['id'])
331
+			{
274 332
 				$contact = new addressbook_egw_record();
275 333
 				$contact->set_record($_contact);
276
-			} else {
334
+			}
335
+			else
336
+			{
277 337
 				$contact = new addressbook_egw_record($_contact);
278 338
 			}
279 339
 
@@ -286,12 +346,19 @@  discard block
 block discarded – undo
286 346
 			}
287 347
 			// Some conversion
288 348
 			$this->convert($contact, $options);
289
-			if($options['convert']) {
349
+			if($options['convert'])
350
+			{
290 351
 				importexport_export_csv::convert($contact, addressbook_egw_record::$types, 'addressbook',$this->selects);
291
-			} else {
352
+			}
353
+			else
354
+			{
292 355
 				// Implode arrays, so they don't say 'Array'
293
-				foreach($contact->get_record_array() as $key => $value) {
294
-					if(is_array($value)) $contact->$key = implode(',', $value);
356
+				foreach($contact->get_record_array() as $key => $value)
357
+				{
358
+					if(is_array($value))
359
+					{
360
+						$contact->$key = implode(',', $value);
361
+					}
295 362
 				}
296 363
 			}
297 364
 
@@ -306,7 +373,8 @@  discard block
 block discarded – undo
306 373
 	 *
307 374
 	 * @return string name
308 375
 	 */
309
-	public static function get_name() {
376
+	public static function get_name()
377
+	{
310 378
 		return lang('Addressbook CSV export');
311 379
 	}
312 380
 
@@ -315,7 +383,8 @@  discard block
 block discarded – undo
315 383
 	 *
316 384
 	 * @return string descriprion
317 385
 	 */
318
-	public static function get_description() {
386
+	public static function get_description()
387
+	{
319 388
 		return lang("Exports contacts from your Addressbook into a CSV File.");
320 389
 	}
321 390
 
@@ -324,11 +393,13 @@  discard block
 block discarded – undo
324 393
 	 *
325 394
 	 * @return string suffix
326 395
 	 */
327
-	public static function get_filesuffix() {
396
+	public static function get_filesuffix()
397
+	{
328 398
 		return 'csv';
329 399
 	}
330 400
 
331
-	public static function get_mimetype() {
401
+	public static function get_mimetype()
402
+	{
332 403
 		return 'text/csv';
333 404
 	}
334 405
 
@@ -351,14 +422,16 @@  discard block
 block discarded – undo
351 422
 	 *
352 423
 	 * @return string html
353 424
 	 */
354
-	public function get_options_etpl() {
425
+	public function get_options_etpl()
426
+	{
355 427
 	}
356 428
 
357 429
 	/**
358 430
 	 * returns slectors of this plugin via xajax
359 431
 	 *
360 432
 	 */
361
-	public function get_selectors_etpl() {
433
+	public function get_selectors_etpl()
434
+	{
362 435
 		return array(
363 436
 			'name'		=> 'importexport.export_csv_selectors',
364 437
 		);
@@ -369,9 +442,11 @@  discard block
 block discarded – undo
369 442
 	*
370 443
 	* Dates, times, user IDs, category IDs
371 444
 	*/
372
-	public static function convert(addressbook_egw_record &$record, $options) {
445
+	public static function convert(addressbook_egw_record &$record, $options)
446
+	{
373 447
 
374
-		if ($record->tel_prefer) {
448
+		if ($record->tel_prefer)
449
+		{
375 450
 			$field = $record->tel_prefer;
376 451
 			$record->tel_prefer = $record->$field;
377 452
 		}
@@ -380,33 +455,52 @@  discard block
 block discarded – undo
380 455
 		{
381 456
 			return;
382 457
 		}
383
-		foreach((array)$options['explode_multiselects'] as $field => $explode_settings) {
384
-			if(!is_array($record->$field)) $record->$field = explode(',', $record->$field);
385
-			foreach((array)$explode_settings['values'] as $value => $settings) {
458
+		foreach((array)$options['explode_multiselects'] as $field => $explode_settings)
459
+		{
460
+			if(!is_array($record->$field))
461
+			{
462
+				$record->$field = explode(',', $record->$field);
463
+			}
464
+			foreach((array)$explode_settings['values'] as $value => $settings)
465
+			{
386 466
 				$field_name = "$field-$value";
387 467
 				$record->$field_name = array();
388
-				if(is_array($record->$field) && in_array($value, $record->$field) || $record->$field == $value) {
389
-					if($explode_settings['explode'] != self::MAIN_CATS) {
468
+				if(is_array($record->$field) && in_array($value, $record->$field) || $record->$field == $value)
469
+				{
470
+					if($explode_settings['explode'] != self::MAIN_CATS)
471
+					{
390 472
 						$record->$field_name = $options['convert'] ? lang('Yes') : true;
391
-					} elseif($options['convert']) {
473
+					}
474
+					elseif($options['convert'])
475
+					{
392 476
 						// 3 part assign due to magic get method
393 477
 						$record_value = $record->$field_name;
394 478
 						$record_value[] = $settings['label'];
395 479
 						$record->$field_name = $record_value;
396
-					} else {
480
+					}
481
+					else
482
+					{
397 483
 						$record->$field_name = $value;
398 484
 					}
399 485
 				}
400
-				if($explode_settings['explode'] == self::MAIN_CATS && count(array_intersect($record->$field, array_keys($settings['subs'])))) {
486
+				if($explode_settings['explode'] == self::MAIN_CATS && count(array_intersect($record->$field, array_keys($settings['subs']))))
487
+				{
401 488
 					// 3 part assign due to magic get method
402 489
 					$record_value = $record->$field_name;
403
-					if(!is_array($record_value)) $record_value = array($record_value);
404
-					foreach(array_intersect($record->$field, array_keys($settings['subs'])) as $sub_id) {
490
+					if(!is_array($record_value))
491
+					{
492
+						$record_value = array($record_value);
493
+					}
494
+					foreach(array_intersect($record->$field, array_keys($settings['subs'])) as $sub_id)
495
+					{
405 496
 						$record_value[] = $options['convert'] ? $settings['subs'][$sub_id] : $sub_id;
406 497
 					}
407 498
 					$record->$field_name = $record_value;
408 499
 				}
409
-				if(is_array($record->$field_name)) $record->$field_name = implode(($options['convert'] ? ', ' : ','), $record->$field_name);
500
+				if(is_array($record->$field_name))
501
+				{
502
+					$record->$field_name = implode(($options['convert'] ? ', ' : ','), $record->$field_name);
503
+				}
410 504
 			}
411 505
 		}
412 506
 	}
@@ -436,12 +530,15 @@  discard block
 block discarded – undo
436 530
 	 * Adjust automatically generated filter fields
437 531
 	 */
438 532
 	public function get_filter_fields(Array &$filters)
439
-    {
533
+	{
440 534
 		unset($filters['last_event']);
441 535
 		unset($filters['next_event']);
442 536
 		foreach($filters as $field_name => &$settings)
443 537
 		{
444
-			if($this->selects[$field_name]) $settings['values'] = $this->selects[$field_name];
538
+			if($this->selects[$field_name])
539
+			{
540
+				$settings['values'] = $this->selects[$field_name];
541
+			}
445 542
 		}
446 543
 		$filters['owner'] = array(
447 544
 			'name'		=> 'owner',
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -247,7 +247,7 @@
 block discarded – undo
247 247
 		$this->selects['info_status'] = $this->bo->get_status();
248 248
 	}
249 249
 
250
-	public function get_filter_fields(Array &$filters)
250
+	public function get_filter_fields(array &$filters)
251 251
 	{
252 252
 		foreach($filters as $field_name => &$settings)
253 253
 		{
Please login to merge, or discard this patch.
addressbook/inc/class.addressbook_bo.inc.php 2 patches
Spacing   +9 added lines, -10 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 		if (!is_array($recipients)) $recipients = array($recipients);
41 41
 
42 42
 		$criteria = $result = array();
43
-		foreach($recipients as &$recipient)
43
+		foreach ($recipients as &$recipient)
44 44
 		{
45 45
 			if (is_numeric($recipient))
46 46
 			{
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 				$criteria['contact_email'][] = $recipient = strtolower($recipient);
52 52
 			}
53 53
 		}
54
-		foreach($this->search($criteria, array('account_id', 'contact_email', 'contact_pubkey'), '', '', '', false, 'OR', false,
54
+		foreach ($this->search($criteria, array('account_id', 'contact_email', 'contact_pubkey'), '', '', '', false, 'OR', false,
55 55
 			"contact_pubkey LIKE '%-----BEGIN PGP PUBLIC KEY BLOCK-----%'") as $contact)
56 56
 		{
57 57
 			$matches = null;
@@ -83,9 +83,9 @@  discard block
 block discarded – undo
83 83
 	 * @param int|string|array $recipients (array of) email addresses or numeric account-ids
84 84
 	 * @param array $result =array()
85 85
 	 */
86
-	public static function get_pgp_keyserver($recipients, array $result=array())
86
+	public static function get_pgp_keyserver($recipients, array $result = array())
87 87
 	{
88
-		foreach($recipients as $recipient)
88
+		foreach ($recipients as $recipient)
89 89
 		{
90 90
 			$id = $recipient;
91 91
 			if (is_numeric($recipient))
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 	 * @param boolean $allow_user_updates =null for admins, set config to allow regular users to store their pgp key
138 138
 	 * @return int number of pgp keys stored
139 139
 	 */
140
-	public function ajax_set_pgp_keys($keys, $allow_user_updates=null)
140
+	public function ajax_set_pgp_keys($keys, $allow_user_updates = null)
141 141
 	{
142 142
 		if (isset($allow_user_updates) && isset($GLOBALS['egw_info']['user']['apps']['admin']))
143 143
 		{
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 			}
159 159
 		}
160 160
 		$criteria = array();
161
-		foreach($keys as $recipient => $key)
161
+		foreach ($keys as $recipient => $key)
162 162
 		{
163 163
 			if (!preg_match(self::$pgp_key_regexp, $key)) continue;
164 164
 
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 		if (!$criteria) return 0;
175 175
 
176 176
 		$updated = 0;
177
-		foreach($this->search($criteria, false, '', '', '', false, 'OR') as $contact)
177
+		foreach ($this->search($criteria, false, '', '', '', false, 'OR') as $contact)
178 178
 		{
179 179
 			if ($contact['account_id'] && isset($keys[$contact['account_id']]))
180 180
 			{
@@ -199,8 +199,7 @@  discard block
 block discarded – undo
199 199
 		}
200 200
 		if ($criteria == array('egw.addressbook.account_id' => array((int)$GLOBALS['egw_info']['user']['account_id'])))
201 201
 		{
202
-			$message = !$updated ? lang('Permissiong denied! Ask your administrator to allow regular uses to update their public keys.') :
203
-				lang('Your new public key has been stored in accounts addressbook.');
202
+			$message = !$updated ? lang('Permissiong denied! Ask your administrator to allow regular uses to update their public keys.') : lang('Your new public key has been stored in accounts addressbook.');
204 203
 		}
205 204
 		else
206 205
 		{
@@ -227,7 +226,7 @@  discard block
 block discarded – undo
227 226
 	public static function set_pgp_keyserver($keys)
228 227
 	{
229 228
 		$added = 0;
230
-		foreach($keys as $email => $cert)
229
+		foreach ($keys as $email => $cert)
231 230
 		{
232 231
 			if (is_numeric($email))
233 232
 			{
Please login to merge, or discard this patch.
Braces   +24 added lines, -6 removed lines patch added patch discarded remove patch
@@ -35,9 +35,15 @@  discard block
 block discarded – undo
35 35
 	 */
36 36
 	public function get_pgp_keys($recipients)
37 37
 	{
38
-		if (!$recipients) return array();
38
+		if (!$recipients)
39
+		{
40
+			return array();
41
+		}
39 42
 
40
-		if (!is_array($recipients)) $recipients = array($recipients);
43
+		if (!is_array($recipients))
44
+		{
45
+			$recipients = array($recipients);
46
+		}
41 47
 
42 48
 		$criteria = $result = array();
43 49
 		foreach($recipients as &$recipient)
@@ -116,9 +122,15 @@  discard block
 block discarded – undo
116 122
 	 */
117 123
 	public function ajax_get_pgp_keys($recipients)
118 124
 	{
119
-		if (!$recipients) return array();
125
+		if (!$recipients)
126
+		{
127
+			return array();
128
+		}
120 129
 
121
-		if (!is_array($recipients)) $recipients = array($recipients);
130
+		if (!is_array($recipients))
131
+		{
132
+			$recipients = array($recipients);
133
+		}
122 134
 
123 135
 		$result = $this->get_pgp_keys($recipients);
124 136
 
@@ -160,7 +172,10 @@  discard block
 block discarded – undo
160 172
 		$criteria = array();
161 173
 		foreach($keys as $recipient => $key)
162 174
 		{
163
-			if (!preg_match(self::$pgp_key_regexp, $key)) continue;
175
+			if (!preg_match(self::$pgp_key_regexp, $key))
176
+			{
177
+				continue;
178
+			}
164 179
 
165 180
 			if (is_numeric($recipient))
166 181
 			{
@@ -171,7 +186,10 @@  discard block
 block discarded – undo
171 186
 				$criteria['contact_email'][] = $recipient;
172 187
 			}
173 188
 		}
174
-		if (!$criteria) return 0;
189
+		if (!$criteria)
190
+		{
191
+			return 0;
192
+		}
175 193
 
176 194
 		$updated = 0;
177 195
 		foreach($this->search($criteria, false, '', '', '', false, 'OR') as $contact)
Please login to merge, or discard this patch.
addressbook/inc/class.addressbook_vcal.inc.php 3 patches
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -90,20 +90,20 @@  discard block
 block discarded – undo
90 90
 	 */
91 91
 	var $clientProperties;
92 92
 	/**
93
-	* Set Logging
94
-	*
95
-	* @var string
96
-	* off = false;
97
-	*/
93
+	 * Set Logging
94
+	 *
95
+	 * @var string
96
+	 * off = false;
97
+	 */
98 98
 	var $log = false;
99 99
 	var $logfile="/tmp/log-vcard";
100 100
 	/**
101
-	* Constructor
102
-	*
103
-	* @param string $contact_app			the current application
104
-	* @param string	$_contentType			the content type (version)
105
-	* @param array $_clientProperties		client properties
106
-	*/
101
+	 * Constructor
102
+	 *
103
+	 * @param string $contact_app			the current application
104
+	 * @param string	$_contentType			the content type (version)
105
+	 * @param array $_clientProperties		client properties
106
+	 */
107 107
 	function __construct($contact_app='addressbook', $_contentType='text/x-vcard', &$_clientProperties = array())
108 108
 	{
109 109
 		parent::__construct($contact_app);
@@ -126,15 +126,15 @@  discard block
 block discarded – undo
126 126
 		$this->supportedFields = $this->databaseFields;
127 127
 	}
128 128
 	/**
129
-	* import a vard into addressbook
130
-	*
131
-	* @param string	$_vcard		the vcard
132
-	* @param int/string	$_abID =null		the internal addressbook id or !$_abID for a new enty
133
-	* @param boolean $merge =false	merge data with existing entry
134
-	* @param string $charset  The encoding charset for $text. Defaults to
135
-    *                         utf-8 for new format, iso-8859-1 for old format.
136
-	* @return int contact id
137
-	*/
129
+	 * import a vard into addressbook
130
+	 *
131
+	 * @param string	$_vcard		the vcard
132
+	 * @param int/string	$_abID =null		the internal addressbook id or !$_abID for a new enty
133
+	 * @param boolean $merge =false	merge data with existing entry
134
+	 * @param string $charset  The encoding charset for $text. Defaults to
135
+	 *                         utf-8 for new format, iso-8859-1 for old format.
136
+	 * @return int contact id
137
+	 */
138 138
 	function addVCard($_vcard, $_abID=null, $merge=false, $charset=null)
139 139
 	{
140 140
 		if (!($contact = $this->vcardtoegw($_vcard, $charset))) return false;
@@ -174,17 +174,17 @@  discard block
 block discarded – undo
174 174
 			$contact['id'] = $_abID;
175 175
 		}
176 176
 		else
177
-    	{
178
-    		if (is_array($contact['cat_id']))
177
+		{
178
+			if (is_array($contact['cat_id']))
179 179
 			{
180 180
 				$contact['cat_id'] = implode(',',$this->find_or_add_categories($contact['cat_id'], -1));
181 181
 			}
182
-    	}
183
-    	if (isset($contact['owner']) && $contact['owner'] != $this->user)
184
-    	{
185
-    		$contact['private'] = 0;	// foreign contacts are never private!
186
-    	}
187
-    	if ($this->log)
182
+		}
183
+		if (isset($contact['owner']) && $contact['owner'] != $this->user)
184
+		{
185
+			$contact['private'] = 0;	// foreign contacts are never private!
186
+		}
187
+		if ($this->log)
188 188
 		{
189 189
 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" .
190 190
 				array2string($contact)."\n",3,$this->logfile);
@@ -193,13 +193,13 @@  discard block
 block discarded – undo
193 193
 	}
194 194
 
195 195
 	/**
196
-	* return a vcard
197
-	*
198
-	* @param int/string	$_id the id of the contact
199
-	* @param string $_charset ='UTF-8' encoding of the vcard, default UTF-8
200
-	* @param boolean $extra_charset_attribute =true GroupDAV/CalDAV dont need the charset attribute and some clients have problems with it
201
-	* @return string containing the vcard
202
-	*/
196
+	 * return a vcard
197
+	 *
198
+	 * @param int/string	$_id the id of the contact
199
+	 * @param string $_charset ='UTF-8' encoding of the vcard, default UTF-8
200
+	 * @param boolean $extra_charset_attribute =true GroupDAV/CalDAV dont need the charset attribute and some clients have problems with it
201
+	 * @return string containing the vcard
202
+	 */
203 203
 	function getVCard($_id,$_charset='UTF-8',$extra_charset_attribute=true)
204 204
 	{
205 205
 		$vCard = new Horde_Icalendar_Vcard($this->version);
@@ -533,14 +533,14 @@  discard block
 block discarded – undo
533 533
 	}
534 534
 
535 535
 	/**
536
-     * Parses a string containing vCard data.
537
-     *
538
-     * @param string $_vcard   The data to parse.
539
-     * @param string $charset  The encoding charset for $text. Defaults to
540
-     *                         utf-8 for new format, iso-8859-1 for old format.
541
-     *
542
-     * @return array|boolean   The contact data or false on errors.
543
-     */
536
+	 * Parses a string containing vCard data.
537
+	 *
538
+	 * @param string $_vcard   The data to parse.
539
+	 * @param string $charset  The encoding charset for $text. Defaults to
540
+	 *                         utf-8 for new format, iso-8859-1 for old format.
541
+	 *
542
+	 * @return array|boolean   The contact data or false on errors.
543
+	 */
544 544
 	function vcardtoegw($_vcard, $charset=null)
545 545
 	{
546 546
 		// the horde class does the charset conversion. DO NOT CONVERT HERE.
@@ -799,7 +799,7 @@  discard block
 block discarded – undo
799 799
 					}
800 800
 					break;
801 801
 				case 'TEL;OTHER;VOICE':
802
-				    if (!in_array('TEL;OTHER', $rowNames)
802
+					if (!in_array('TEL;OTHER', $rowNames)
803 803
 							&& !isset($finalRowNames['TEL;OTHER']))
804 804
 					{
805 805
 						$finalRowNames['TEL;OTHER'] = $vcardKey;
Please login to merge, or discard this patch.
Spacing   +89 added lines, -89 removed lines patch added patch discarded remove patch
@@ -38,20 +38,20 @@  discard block
 block discarded – undo
38 38
 	 * @var array
39 39
 	 */
40 40
 	var $databaseFields = array( // all entries e.g. for CardDAV
41
-			'ADR;WORK'			=> array('','adr_one_street2','adr_one_street','adr_one_locality','adr_one_region',
42
-									'adr_one_postalcode','adr_one_countryname'),
43
-			'ADR;HOME'			=> array('','adr_two_street2','adr_two_street','adr_two_locality','adr_two_region',
44
-									'adr_two_postalcode','adr_two_countryname'),
41
+			'ADR;WORK'			=> array('', 'adr_one_street2', 'adr_one_street', 'adr_one_locality', 'adr_one_region',
42
+									'adr_one_postalcode', 'adr_one_countryname'),
43
+			'ADR;HOME'			=> array('', 'adr_two_street2', 'adr_two_street', 'adr_two_locality', 'adr_two_region',
44
+									'adr_two_postalcode', 'adr_two_countryname'),
45 45
 			'BDAY'				=> array('bday'),
46 46
 			'CLASS'				=> array('private'),
47 47
 			'CATEGORIES'			=> array('cat_id'),
48 48
 			'EMAIL;WORK'			=> array('email'),
49 49
 			'EMAIL;HOME'			=> array('email_home'),
50
-			'N'				=> array('n_family','n_given','n_middle',
51
-									'n_prefix','n_suffix'),
50
+			'N'				=> array('n_family', 'n_given', 'n_middle',
51
+									'n_prefix', 'n_suffix'),
52 52
 			'FN'				=> array('n_fn'),
53 53
 			'NOTE'				=> array('note'),
54
-			'ORG'				=> array('org_name','org_unit','room'),
54
+			'ORG'				=> array('org_name', 'org_unit', 'room'),
55 55
 			'TEL;CELL;WORK'			=> array('tel_cell'),
56 56
 			'TEL;CELL;HOME'			=> array('tel_cell_private'),
57 57
 			'TEL;CAR'			=> array('tel_car'),
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 	* off = false;
97 97
 	*/
98 98
 	var $log = false;
99
-	var $logfile="/tmp/log-vcard";
99
+	var $logfile = "/tmp/log-vcard";
100 100
 	/**
101 101
 	* Constructor
102 102
 	*
@@ -104,16 +104,16 @@  discard block
 block discarded – undo
104 104
 	* @param string	$_contentType			the content type (version)
105 105
 	* @param array $_clientProperties		client properties
106 106
 	*/
107
-	function __construct($contact_app='addressbook', $_contentType='text/x-vcard', &$_clientProperties = array())
107
+	function __construct($contact_app = 'addressbook', $_contentType = 'text/x-vcard', &$_clientProperties = array())
108 108
 	{
109 109
 		parent::__construct($contact_app);
110 110
 		if ($this->log)
111 111
 		{
112 112
 			$this->logfile = $GLOBALS['egw_info']['server']['temp_dir']."/log-vcard";
113
-			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" .
114
-				array2string($_contentType)."\n",3,$this->logfile);
113
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n".
114
+				array2string($_contentType)."\n", 3, $this->logfile);
115 115
 		}
116
-		switch($_contentType)
116
+		switch ($_contentType)
117 117
 		{
118 118
 			case 'text/vcard':
119 119
 				$this->version = '3.0';
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
     *                         utf-8 for new format, iso-8859-1 for old format.
136 136
 	* @return int contact id
137 137
 	*/
138
-	function addVCard($_vcard, $_abID=null, $merge=false, $charset=null)
138
+	function addVCard($_vcard, $_abID = null, $merge = false, $charset = null)
139 139
 	{
140 140
 		if (!($contact = $this->vcardtoegw($_vcard, $charset))) return false;
141 141
 
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 					}
162 162
 					if (is_array($contact['cat_id']))
163 163
 					{
164
-						$contact['cat_id'] = implode(',',$this->find_or_add_categories($contact['cat_id'], $_abID));
164
+						$contact['cat_id'] = implode(',', $this->find_or_add_categories($contact['cat_id'], $_abID));
165 165
 					}
166 166
 					else
167 167
 					{
@@ -177,17 +177,17 @@  discard block
 block discarded – undo
177 177
     	{
178 178
     		if (is_array($contact['cat_id']))
179 179
 			{
180
-				$contact['cat_id'] = implode(',',$this->find_or_add_categories($contact['cat_id'], -1));
180
+				$contact['cat_id'] = implode(',', $this->find_or_add_categories($contact['cat_id'], -1));
181 181
 			}
182 182
     	}
183 183
     	if (isset($contact['owner']) && $contact['owner'] != $this->user)
184 184
     	{
185
-    		$contact['private'] = 0;	// foreign contacts are never private!
185
+    		$contact['private'] = 0; // foreign contacts are never private!
186 186
     	}
187 187
     	if ($this->log)
188 188
 		{
189
-			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" .
190
-				array2string($contact)."\n",3,$this->logfile);
189
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n".
190
+				array2string($contact)."\n", 3, $this->logfile);
191 191
 		}
192 192
 		return $this->save($contact);
193 193
 	}
@@ -200,10 +200,10 @@  discard block
 block discarded – undo
200 200
 	* @param boolean $extra_charset_attribute =true GroupDAV/CalDAV dont need the charset attribute and some clients have problems with it
201 201
 	* @return string containing the vcard
202 202
 	*/
203
-	function getVCard($_id,$_charset='UTF-8',$extra_charset_attribute=true)
203
+	function getVCard($_id, $_charset = 'UTF-8', $extra_charset_attribute = true)
204 204
 	{
205 205
 		$vCard = new Horde_Icalendar_Vcard($this->version);
206
-		$vCard->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware Addressbook '.$GLOBALS['egw_info']['apps']['phpgwapi']['version'].'//'.
206
+		$vCard->setAttribute('PRODID', '-//EGroupware//NONSGML EGroupware Addressbook '.$GLOBALS['egw_info']['apps']['phpgwapi']['version'].'//'.
207 207
 			strtoupper($GLOBALS['egw_info']['user']['preferences']['common']['lang']));
208 208
 
209 209
 		$sysCharSet = Api\Translation::charset();
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 				if (!$oval && ($this->version == '3.0'))
238 238
 				{
239 239
 					// declare OPTION as TYPE=OPTION
240
-					$options['TYPE'][] = $oname ;
240
+					$options['TYPE'][] = $oname;
241 241
 				}
242 242
 				else
243 243
 				{
@@ -257,9 +257,9 @@  discard block
 block discarded – undo
257 257
 				$noTruncate = $this->clientProperties[$vcardField]['NoTruncate'];
258 258
 				if ($this->log && $size > 0)
259 259
 				{
260
-					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
261
-						"() $vcardField Size: $size, NoTruncate: " .
262
-						($noTruncate ? 'TRUE' : 'FALSE') . "\n",3,$this->logfile);
260
+					error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
261
+						"() $vcardField Size: $size, NoTruncate: ".
262
+						($noTruncate ? 'TRUE' : 'FALSE')."\n", 3, $this->logfile);
263 263
 				}
264 264
 				//Horde::logMessage("vCalAddressbook $vcardField Size: $size, NoTruncate: " .
265 265
 				//	($noTruncate ? 'TRUE' : 'FALSE'), __FILE__, __LINE__, PEAR_LOG_DEBUG);
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
 				switch ($databaseField)
282 282
 				{
283 283
 					case 'modified':
284
-						$value = gmdate("Y-m-d\TH:i:s\Z",Api\DateTime::user2server($value));
284
+						$value = gmdate("Y-m-d\TH:i:s\Z", Api\DateTime::user2server($value));
285 285
 						$hasdata++;
286 286
 						break;
287 287
 
@@ -295,14 +295,14 @@  discard block
 block discarded – undo
295 295
 						{
296 296
 							if ($size == 8)
297 297
 							{
298
-								$value = str_replace('-','',$value);
298
+								$value = str_replace('-', '', $value);
299 299
 							}
300 300
 							elseif (isset($options['TYPE']) && (
301 301
 								$options['TYPE'] == 'BASIC'))
302 302
 							{
303 303
 								unset($options['TYPE']);
304 304
 								// used by old SyncML implementations
305
-								$value = str_replace('-','',$value).'T000000Z';
305
+								$value = str_replace('-', '', $value).'T000000Z';
306 306
 							}
307 307
 							$hasdata++;
308 308
 						}
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
 					case 'cat_id':
334 334
 						if (!empty($value) && ($values = /*str_replace(',','\\,',*/$this->get_categories($value)))//)
335 335
 						{
336
-							$values = (array) Api\Translation::convert($values, $sysCharSet, $_charset);
336
+							$values = (array)Api\Translation::convert($values, $sysCharSet, $_charset);
337 337
 							$value = implode(',', $values); // just for the CHARSET recognition
338 338
 							if (($size > 0) && strlen($value) > $size)
339 339
 							{
@@ -343,8 +343,8 @@  discard block
 block discarded – undo
343 343
 								{
344 344
 									if ($this->log)
345 345
 									{
346
-										error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
347
-										"() $vcardField omitted due to maximum size $size\n",3,$this->logfile);
346
+										error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
347
+										"() $vcardField omitted due to maximum size $size\n", 3, $this->logfile);
348 348
 									}
349 349
 									// Horde::logMessage("vCalAddressbook $vcardField omitted due to maximum size $size",
350 350
 									//		__FILE__, __LINE__, PEAR_LOG_WARNING);
@@ -393,14 +393,14 @@  discard block
 block discarded – undo
393 393
 						// fall-through
394 394
 
395 395
 					default:
396
-						if (($size > 0) && strlen(implode(',', $values) . $value) > $size)
396
+						if (($size > 0) && strlen(implode(',', $values).$value) > $size)
397 397
 						{
398 398
 							if ($noTruncate)
399 399
 							{
400 400
 								if ($this->log)
401 401
 								{
402
-									error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
403
-										"() $vcardField omitted due to maximum size $size\n",3,$this->logfile);
402
+									error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
403
+										"() $vcardField omitted due to maximum size $size\n", 3, $this->logfile);
404 404
 								}
405 405
 								// Horde::logMessage("vCalAddressbook $vcardField omitted due to maximum size $size",
406 406
 								//		__FILE__, __LINE__, PEAR_LOG_WARNING);
@@ -419,14 +419,14 @@  discard block
 block discarded – undo
419 419
 							}
420 420
 							if ($this->log)
421 421
 							{
422
-								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
423
-									"() $vcardField truncated to maximum size $size\n",3,$this->logfile);
422
+								error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
423
+									"() $vcardField truncated to maximum size $size\n", 3, $this->logfile);
424 424
 							}
425 425
 							//Horde::logMessage("vCalAddressbook $vcardField truncated to maximum size $size",
426 426
 							//		__FILE__, __LINE__, PEAR_LOG_INFO);
427 427
 						}
428 428
 						if (!empty($value) // required field
429
-							|| in_array($vcardField,array('FN','ORG','N'))
429
+							|| in_array($vcardField, array('FN', 'ORG', 'N'))
430 430
 							|| ($size >= 0 && !$noTruncate))
431 431
 						{
432 432
 							$value = Api\Translation::convert(trim($value), $sysCharSet, $_charset);
@@ -491,15 +491,15 @@  discard block
 block discarded – undo
491 491
 
492 492
 		if ($this->log)
493 493
 		{
494
-			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__ .
495
-				"() '$this->productManufacturer','$this->productName'\n",3,$this->logfile);
496
-			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" .
497
-				array2string($result)."\n",3,$this->logfile);
494
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
495
+				"() '$this->productManufacturer','$this->productName'\n", 3, $this->logfile);
496
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n".
497
+				array2string($result)."\n", 3, $this->logfile);
498 498
 		}
499 499
 		return $result;
500 500
 	}
501 501
 
502
-	function search($_vcard, $contentID=null, $relax=false, $charset=null)
502
+	function search($_vcard, $contentID = null, $relax = false, $charset = null)
503 503
 	{
504 504
 		$result = array();
505 505
 
@@ -507,7 +507,7 @@  discard block
 block discarded – undo
507 507
 		{
508 508
 			if (is_array($contact['category']))
509 509
 			{
510
-					$contact['category'] = implode(',',$this->find_or_add_categories($contact['category'],
510
+					$contact['category'] = implode(',', $this->find_or_add_categories($contact['category'],
511 511
 						$contentID ? $contentID : -1));
512 512
 			}
513 513
 			if ($contentID)
@@ -519,7 +519,7 @@  discard block
 block discarded – undo
519 519
 		return $result;
520 520
 	}
521 521
 
522
-	function setSupportedFields($_productManufacturer='file', $_productName='', $_supportedFields = null)
522
+	function setSupportedFields($_productManufacturer = 'file', $_productName = '', $_supportedFields = null)
523 523
 	{
524 524
 		$this->productManufacturer = strtolower($_productManufacturer);
525 525
 		$this->productName = strtolower($_productName);
@@ -541,18 +541,18 @@  discard block
 block discarded – undo
541 541
      *
542 542
      * @return array|boolean   The contact data or false on errors.
543 543
      */
544
-	function vcardtoegw($_vcard, $charset=null)
544
+	function vcardtoegw($_vcard, $charset = null)
545 545
 	{
546 546
 		// the horde class does the charset conversion. DO NOT CONVERT HERE.
547 547
 		// be as flexible as possible
548 548
 
549 549
 		if ($this->log)
550 550
 		{
551
-			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" .
552
-				array2string($_vcard)."\n",3,$this->logfile);
551
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n".
552
+				array2string($_vcard)."\n", 3, $this->logfile);
553 553
 		}
554 554
 
555
-		if(!($_vcard instanceof Horde_Icalendar))
555
+		if (!($_vcard instanceof Horde_Icalendar))
556 556
 		{
557 557
 			$container = false;
558 558
 			$vCard = Horde_Icalendar::newComponent('vcard', $container);
@@ -593,10 +593,10 @@  discard block
 block discarded – undo
593 593
 		$pref_tel = false;
594 594
 
595 595
 		$rowNames = array();
596
-		foreach($vcardValues as $key => $vcardRow)
596
+		foreach ($vcardValues as $key => $vcardRow)
597 597
 		{
598
-			$rowName  = strtoupper($vcardRow['name']);
599
-			if ($vcardRow['value'] == ''  && implode('', $vcardRow['values']) == '')
598
+			$rowName = strtoupper($vcardRow['name']);
599
+			if ($vcardRow['value'] == '' && implode('', $vcardRow['values']) == '')
600 600
 			{
601 601
 				unset($vcardRow);
602 602
 				continue;
@@ -671,7 +671,7 @@  discard block
 block discarded – undo
671 671
 				switch ($pname)
672 672
 				{
673 673
 					case 'PREF':
674
-						if (substr($rowName,0,3) == 'TEL' && !$pref_tel)
674
+						if (substr($rowName, 0, 3) == 'TEL' && !$pref_tel)
675 675
 						{
676 676
 							$pref_tel = $key;
677 677
 						}
@@ -684,7 +684,7 @@  discard block
 block discarded – undo
684 684
 						if ($rowName != 'TEL') break;
685 685
 					case 'WORK':
686 686
 					case 'HOME':
687
-						$rowName .= ';' . $pname;
687
+						$rowName .= ';'.$pname;
688 688
 						break;
689 689
 					case 'CAR':
690 690
 					case 'X-CUSTOMLABEL-CAR':
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
 						if (strpos($pname, 'X-FUNAMBOL-') === 0)
705 705
 						{
706 706
 							// Propriatary Funambol extension will be ignored
707
-							$rowName .= ';' . $pname;
707
+							$rowName .= ';'.$pname;
708 708
 						}
709 709
 						break;
710 710
 				}
@@ -712,39 +712,39 @@  discard block
 block discarded – undo
712 712
 
713 713
 			if ($rowName == 'EMAIL')
714 714
 			{
715
-				$rowName .= ';X-egw-Ref' . $email++;
715
+				$rowName .= ';X-egw-Ref'.$email++;
716 716
 			}
717 717
 
718 718
 			if (($rowName == 'TEL;CELL') ||
719 719
 					($rowName == 'TEL;CELL;VOICE'))
720 720
 			{
721
-				$rowName = 'TEL;CELL;X-egw-Ref' . $cell++;
721
+				$rowName = 'TEL;CELL;X-egw-Ref'.$cell++;
722 722
 			}
723 723
 
724 724
 			if (($rowName == 'TEL') ||
725 725
 					($rowName == 'TEL;VOICE'))
726 726
 			{
727
-				$rowName = 'TEL;X-egw-Ref' . $tel++;
727
+				$rowName = 'TEL;X-egw-Ref'.$tel++;
728 728
 			}
729 729
 
730 730
 			if ($rowName == 'URL')
731 731
 			{
732
-				$rowName = 'URL;X-egw-Ref' . $url++;
732
+				$rowName = 'URL;X-egw-Ref'.$url++;
733 733
 			}
734 734
 
735 735
 			// current algorithm cant cope with multiple attributes of same name
736 736
 			// --> cumulate them in values, so they can be used later (works only for values, not for parameters!)
737 737
 			if (($k = array_search($rowName, $rowNames)) != false)
738 738
 			{
739
-				$vcardValues[$k]['values'] = array_merge($vcardValues[$k]['values'],$vcardValues[$key]['values']);
739
+				$vcardValues[$k]['values'] = array_merge($vcardValues[$k]['values'], $vcardValues[$key]['values']);
740 740
 			}
741 741
 			$rowNames[$key] = $rowName;
742 742
 		}
743 743
 
744 744
 		if ($this->log)
745 745
 		{
746
-			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" .
747
-				array2string($rowNames)."\n",3,$this->logfile);
746
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n".
747
+				array2string($rowNames)."\n", 3, $this->logfile);
748 748
 		}
749 749
 
750 750
 		// All rowNames of the vCard are now concatenated with their qualifiers.
@@ -914,15 +914,15 @@  discard block
 block discarded – undo
914 914
 
915 915
 		if ($this->log)
916 916
 		{
917
-			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" .
918
-				array2string($finalRowNames)."\n",3,$this->logfile);
917
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n".
918
+				array2string($finalRowNames)."\n", 3, $this->logfile);
919 919
 		}
920 920
 
921 921
 		$contact = array();
922 922
 		// to be able to delete fields, we have to set all supported fields to at least null
923
-		foreach($this->supportedFields as $fields)
923
+		foreach ($this->supportedFields as $fields)
924 924
 		{
925
-			foreach($fields as $field)
925
+			foreach ($fields as $field)
926 926
 			{
927 927
 				if ($field != 'fileas_type') $contact[$field] = null;
928 928
 			}
@@ -945,16 +945,16 @@  discard block
 block discarded – undo
945 945
 						{
946 946
 							$contact['tel_prefer'] = $fieldName;
947 947
 						}
948
-						switch($fieldName)
948
+						switch ($fieldName)
949 949
 						{
950 950
 							case 'bday':
951
-								$contact[$fieldName] = $vcardValues[$vcardKey]['value']['year'] .
952
-									'-' . $vcardValues[$vcardKey]['value']['month'] .
953
-									'-' . $vcardValues[$vcardKey]['value']['mday'];
951
+								$contact[$fieldName] = $vcardValues[$vcardKey]['value']['year'].
952
+									'-'.$vcardValues[$vcardKey]['value']['month'].
953
+									'-'.$vcardValues[$vcardKey]['value']['mday'];
954 954
 								break;
955 955
 
956 956
 							case 'private':
957
-								$contact[$fieldName] = (int) ( strtoupper($value) == 'PRIVATE');
957
+								$contact[$fieldName] = (int)(strtoupper($value) == 'PRIVATE');
958 958
 								break;
959 959
 
960 960
 							case 'cat_id':
@@ -963,7 +963,7 @@  discard block
 block discarded – undo
963 963
 
964 964
 							case 'jpegphoto':
965 965
 								$contact[$fieldName] = $vcardValues[$vcardKey]['value'];
966
-								if(in_array($vcardValues[$vcardKey]['params']['ENCODING'],array('b','B','BASE64')))
966
+								if (in_array($vcardValues[$vcardKey]['params']['ENCODING'], array('b', 'B', 'BASE64')))
967 967
 								{
968 968
 									$contact[$fieldName] = base64_decode($contact[$fieldName]);
969 969
 								}
@@ -994,7 +994,7 @@  discard block
 block discarded – undo
994 994
 				}
995 995
 			}
996 996
 			// add unsupported attributes as with '##' prefix
997
-			elseif(($attribute = $vcardValues[$vcardKey]) && !in_array($attribute['name'],array('PRODID','REV')))
997
+			elseif (($attribute = $vcardValues[$vcardKey]) && !in_array($attribute['name'], array('PRODID', 'REV')))
998 998
 			{
999 999
 				// for attributes with multiple values in multiple lines, merge the values
1000 1000
 				if (isset($contact['##'.$attribute['name']]))
@@ -1013,10 +1013,10 @@  discard block
 block discarded – undo
1013 1013
 
1014 1014
 		if ($this->log)
1015 1015
 		{
1016
-			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__	.
1017
-				"() '$this->productManufacturer','$this->productName'\n",3,$this->logfile);
1018
-			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" .
1019
-				array2string($contact)."\n",3,$this->logfile);
1016
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__.
1017
+				"() '$this->productManufacturer','$this->productName'\n", 3, $this->logfile);
1018
+			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n".
1019
+				array2string($contact)."\n", 3, $this->logfile);
1020 1020
 		}
1021 1021
 		return $contact;
1022 1022
 	}
@@ -1027,14 +1027,14 @@  discard block
 block discarded – undo
1027 1027
 	 * @param array $ids contact-ids
1028 1028
 	 * @param string $file filename or null for download
1029 1029
 	 */
1030
-	function export($ids, $file=null)
1030
+	function export($ids, $file = null)
1031 1031
 	{
1032 1032
 		if (!$file)
1033 1033
 		{
1034
-			$filename = count($ids) == 1 ? Link::title('addressbook',$ids[0]): 'egw_addressbook_'.date('Y-m-d');
1035
-			Api\Header\Content::type(($filename ? $filename : 'addressbook').'.vcf','text/x-vcard');
1034
+			$filename = count($ids) == 1 ? Link::title('addressbook', $ids[0]) : 'egw_addressbook_'.date('Y-m-d');
1035
+			Api\Header\Content::type(($filename ? $filename : 'addressbook').'.vcf', 'text/x-vcard');
1036 1036
 		}
1037
-		if (!($fp = fopen($file ? $file : 'php://output','w')))
1037
+		if (!($fp = fopen($file ? $file : 'php://output', 'w')))
1038 1038
 		{
1039 1039
 			return false;
1040 1040
 		}
@@ -1048,7 +1048,7 @@  discard block
 block discarded – undo
1048 1048
 		}
1049 1049
 		foreach ($ids as $id)
1050 1050
 		{
1051
-			fwrite($fp,$this->getVCard($id, $charset));
1051
+			fwrite($fp, $this->getVCard($id, $charset));
1052 1052
 		}
1053 1053
 		fclose($fp);
1054 1054
 
@@ -1066,22 +1066,22 @@  discard block
 block discarded – undo
1066 1066
 	 * @param string $version ='3.0' vcard version
1067 1067
 	 * @return string containing the vcard
1068 1068
 	 */
1069
-	function getGroupVCard(array $list,$version='3.0')
1069
+	function getGroupVCard(array $list, $version = '3.0')
1070 1070
 	{
1071 1071
 		$vCard = new Horde_Icalendar_Vcard($version);
1072
-		$vCard->setAttribute('PRODID','-//EGroupware//NONSGML EGroupware Addressbook '.$GLOBALS['egw_info']['apps']['phpgwapi']['version'].'//'.
1072
+		$vCard->setAttribute('PRODID', '-//EGroupware//NONSGML EGroupware Addressbook '.$GLOBALS['egw_info']['apps']['phpgwapi']['version'].'//'.
1073 1073
 			strtoupper($GLOBALS['egw_info']['user']['preferences']['common']['lang']));
1074 1074
 
1075
-		$vCard->setAttribute('N',$list['list_name'],array(),true,array($list['list_name'],'','','',''));
1076
-		$vCard->setAttribute('FN',$list['list_name']);
1075
+		$vCard->setAttribute('N', $list['list_name'], array(), true, array($list['list_name'], '', '', '', ''));
1076
+		$vCard->setAttribute('FN', $list['list_name']);
1077 1077
 
1078
-		$vCard->setAttribute('X-ADDRESSBOOKSERVER-KIND','group');
1079
-		foreach($list['members'] as $uid)
1078
+		$vCard->setAttribute('X-ADDRESSBOOKSERVER-KIND', 'group');
1079
+		foreach ($list['members'] as $uid)
1080 1080
 		{
1081
-			$vCard->setAttribute('X-ADDRESSBOOKSERVER-MEMBER','urn:uuid:'.$uid);
1081
+			$vCard->setAttribute('X-ADDRESSBOOKSERVER-MEMBER', 'urn:uuid:'.$uid);
1082 1082
 		}
1083
-		$vCard->setAttribute('REV',Api\DateTime::to($list['list_modified'],'Y-m-d\TH:i:s\Z'));
1084
-		$vCard->setAttribute('UID',$list['list_uid']);
1083
+		$vCard->setAttribute('REV', Api\DateTime::to($list['list_modified'], 'Y-m-d\TH:i:s\Z'));
1084
+		$vCard->setAttribute('UID', $list['list_uid']);
1085 1085
 
1086 1086
 		return $vCard->exportvCalendar();
1087 1087
 	}
Please login to merge, or discard this patch.
Braces   +38 added lines, -13 removed lines patch added patch discarded remove patch
@@ -137,7 +137,10 @@  discard block
 block discarded – undo
137 137
 	*/
138 138
 	function addVCard($_vcard, $_abID=null, $merge=false, $charset=null)
139 139
 	{
140
-		if (!($contact = $this->vcardtoegw($_vcard, $charset))) return false;
140
+		if (!($contact = $this->vcardtoegw($_vcard, $charset)))
141
+		{
142
+			return false;
143
+		}
141 144
 
142 145
 		if ($_abID)
143 146
 		{
@@ -174,9 +177,9 @@  discard block
 block discarded – undo
174 177
 			$contact['id'] = $_abID;
175 178
 		}
176 179
 		else
177
-    	{
180
+		{
178 181
     		if (is_array($contact['cat_id']))
179
-			{
182
+    		{
180 183
 				$contact['cat_id'] = implode(',',$this->find_or_add_categories($contact['cat_id'], -1));
181 184
 			}
182 185
     	}
@@ -185,7 +188,7 @@  discard block
 block discarded – undo
185 188
     		$contact['private'] = 0;	// foreign contacts are never private!
186 189
     	}
187 190
     	if ($this->log)
188
-		{
191
+    	{
189 192
 			error_log(__FILE__.'['.__LINE__.'] '.__METHOD__."()\n" .
190 193
 				array2string($contact)."\n",3,$this->logfile);
191 194
 		}
@@ -331,9 +334,12 @@  discard block
 block discarded – undo
331 334
 						break;
332 335
 
333 336
 					case 'cat_id':
334
-						if (!empty($value) && ($values = /*str_replace(',','\\,',*/$this->get_categories($value)))//)
337
+						if (!empty($value) && ($values = /*str_replace(',','\\,',*/$this->get_categories($value)))
338
+						{
339
+							//)
335 340
 						{
336 341
 							$values = (array) Api\Translation::convert($values, $sysCharSet, $_charset);
342
+						}
337 343
 							$value = implode(',', $values); // just for the CHARSET recognition
338 344
 							if (($size > 0) && strlen($value) > $size)
339 345
 							{
@@ -386,8 +392,14 @@  discard block
 block discarded – undo
386 392
 						if (isset($this->supportedFields['X-ABSHOWAS']) &&
387 393
 							$entry['org_name'] == $entry['n_fileas'] && $entry['fileas_type'] == 'org_name')
388 394
 						{
389
-							if ($vcardField == 'X-ABSHOWAS') $value = 'COMPANY';
390
-							if ($databaseField == 'n_fn') $value = $entry['org_name'];
395
+							if ($vcardField == 'X-ABSHOWAS')
396
+							{
397
+								$value = 'COMPANY';
398
+							}
399
+							if ($databaseField == 'n_fn')
400
+							{
401
+								$value = $entry['org_name'];
402
+							}
391 403
 						}
392 404
 						//error_log("vcardField='$vcardField', databaseField='$databaseField', this->supportedFields['X-ABSHOWAS']=".array2string($this->supportedFields['X-ABSHOWAS'])." --> value='$value'");
393 405
 						// fall-through
@@ -524,12 +536,18 @@  discard block
 block discarded – undo
524 536
 		$this->productManufacturer = strtolower($_productManufacturer);
525 537
 		$this->productName = strtolower($_productName);
526 538
 
527
-		if (is_array($_supportedFields)) $this->supportedFields = $_supportedFields;
539
+		if (is_array($_supportedFields))
540
+		{
541
+			$this->supportedFields = $_supportedFields;
542
+		}
528 543
 	}
529 544
 
530 545
 	function setDatabaseFields($_databaseFields)
531 546
 	{
532
-		if (is_array($_databaseFields)) $this->databaseFields = $_databaseFields;
547
+		if (is_array($_databaseFields))
548
+		{
549
+			$this->databaseFields = $_databaseFields;
550
+		}
533 551
 	}
534 552
 
535 553
 	/**
@@ -681,7 +699,10 @@  discard block
 block discarded – undo
681 699
 					case 'VOICE':
682 700
 					case 'OTHER':
683 701
 					case 'CELL':
684
-						if ($rowName != 'TEL') break;
702
+						if ($rowName != 'TEL')
703
+						{
704
+							break;
705
+						}
685 706
 					case 'WORK':
686 707
 					case 'HOME':
687 708
 						$rowName .= ';' . $pname;
@@ -801,7 +822,7 @@  discard block
 block discarded – undo
801 822
 				case 'TEL;OTHER;VOICE':
802 823
 				    if (!in_array('TEL;OTHER', $rowNames)
803 824
 							&& !isset($finalRowNames['TEL;OTHER']))
804
-					{
825
+				    {
805 826
 						$finalRowNames['TEL;OTHER'] = $vcardKey;
806 827
 					}
807 828
 					break;
@@ -924,7 +945,10 @@  discard block
 block discarded – undo
924 945
 		{
925 946
 			foreach($fields as $field)
926 947
 			{
927
-				if ($field != 'fileas_type') $contact[$field] = null;
948
+				if ($field != 'fileas_type')
949
+				{
950
+					$contact[$field] = null;
951
+				}
928 952
 			}
929 953
 		}
930 954
 
@@ -982,7 +1006,8 @@  discard block
 block discarded – undo
982 1006
 								break;
983 1007
 
984 1008
 							case 'uid':
985
-								if (strlen($value) < $minimum_uid_length) {
1009
+								if (strlen($value) < $minimum_uid_length)
1010
+								{
986 1011
 									// we don't use it
987 1012
 									break;
988 1013
 								}
Please login to merge, or discard this patch.
addressbook/inc/class.addressbook_zpush.inc.php 3 patches
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
 	 * @param string $id folder id
278 278
 	 * @param int $cutoffdate =null
279 279
 	 * @return array
280
-  	 */
280
+	 */
281 281
 	function GetMessageList($id, $cutoffdate=NULL)
282 282
 	{
283 283
 		unset($cutoffdate);	// not used, but required by function signature
@@ -378,10 +378,10 @@  discard block
 block discarded – undo
378 378
 				case 'bday':	// zpush seems to use a timestamp in utc (at least vcard backend does)
379 379
 					if (!empty($contact[$attr]))
380 380
 					{
381
-            			$tz = date_default_timezone_get();
382
-            			date_default_timezone_set('UTC');
383
-            			$message->birthday = strtotime($contact[$attr]);
384
-            			date_default_timezone_set($tz);
381
+						$tz = date_default_timezone_get();
382
+						date_default_timezone_set('UTC');
383
+						$message->birthday = strtotime($contact[$attr]);
384
+						date_default_timezone_set($tz);
385 385
 					}
386 386
 					break;
387 387
 
@@ -634,7 +634,7 @@  discard block
 block discarded – undo
634 634
 	 * @param $folderid of the current folder
635 635
 	 * @param $id of the message
636 636
 	 * @param $newfolderid
637
-     * @param ContentParameters   $contentParameters
637
+	 * @param ContentParameters   $contentParameters
638 638
 	 *
639 639
 	 * @return $newid as a string | boolean false on error
640 640
 	 *
@@ -662,7 +662,7 @@  discard block
 block discarded – undo
662 662
 	 *
663 663
 	 * @param $folderid
664 664
 	 * @param $id
665
-     * @param ContentParameters   $contentParameters
665
+	 * @param ContentParameters   $contentParameters
666 666
 	 *
667 667
 	 * @return boolean true on success, false on error, diffbackend does NOT use the returnvalue
668 668
 	 *
@@ -681,23 +681,23 @@  discard block
 block discarded – undo
681 681
 		return $ret;
682 682
 	}
683 683
 
684
-    /**
685
-     * Changes the 'read' flag of a message on disk. The $flags
686
-     * parameter can only be '1' (read) or '0' (unread). After a call to
687
-     * SetReadFlag(), GetMessageList() should return the message with the
688
-     * new 'flags' but should not modify the 'mod' parameter. If you do
689
-     * change 'mod', simply setting the message to 'read' on the mobile will trigger
690
-     * a full resync of the item from the server.
691
-     *
692
-     * @param string              $folderid            id of the folder
693
-     * @param string              $id                  id of the message
694
-     * @param int                 $flags               read flag of the message
695
-     * @param ContentParameters   $contentParameters
696
-     *
697
-     * @access public
698
-     * @return boolean                      status of the operation
699
-     * @throws StatusException              could throw specific SYNC_STATUS_* exceptions
700
-     */
684
+	/**
685
+	 * Changes the 'read' flag of a message on disk. The $flags
686
+	 * parameter can only be '1' (read) or '0' (unread). After a call to
687
+	 * SetReadFlag(), GetMessageList() should return the message with the
688
+	 * new 'flags' but should not modify the 'mod' parameter. If you do
689
+	 * change 'mod', simply setting the message to 'read' on the mobile will trigger
690
+	 * a full resync of the item from the server.
691
+	 *
692
+	 * @param string              $folderid            id of the folder
693
+	 * @param string              $id                  id of the message
694
+	 * @param int                 $flags               read flag of the message
695
+	 * @param ContentParameters   $contentParameters
696
+	 *
697
+	 * @access public
698
+	 * @return boolean                      status of the operation
699
+	 * @throws StatusException              could throw specific SYNC_STATUS_* exceptions
700
+	 */
701 701
 	function SetReadFlag($folderid, $id, $flags, $contentParameters)
702 702
 	{
703 703
 		unset($folderid, $id, $flags, $contentParameters);
@@ -713,7 +713,7 @@  discard block
 block discarded – undo
713 713
 	 *
714 714
 	 *
715 715
 	 * @DESC The $flags parameter must contains the poommailflag Object
716
- 	 */
716
+	 */
717 717
 	function ChangeMessageFlag($folderid, $id, $flags)
718 718
 	{
719 719
 		unset($folderid, $id, $flags);
Please login to merge, or discard this patch.
Spacing   +58 added lines, -59 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 		'homestreet'	=>	'adr_two_street',
72 72
 		'homefaxnumber'	=> 'tel_fax_home',
73 73
 		'homephonenumber'	=>	'tel_home',
74
-		'jobtitle'	=>	'title',	// unfortunatly outlook only has title & jobtitle, while EGw has 'n_prefix', 'title' & 'role',
74
+		'jobtitle'	=>	'title', // unfortunatly outlook only has title & jobtitle, while EGw has 'n_prefix', 'title' & 'role',
75 75
 		'lastname'	=> 'n_family',
76 76
 		'middlename'	=> 'n_middle',
77 77
 		'mobilephonenumber'	=> 'tel_cell',
@@ -123,9 +123,9 @@  discard block
 block discarded – undo
123 123
 	 * @param booelan $ab_prefix =false prefix personal, private and accounts addressbook with lang('Addressbook').' '
124 124
 	 * @return string|array addressbook name of array with int account_id => label pairs
125 125
 	 */
126
-	private function get_addressbooks($account=null,$return_all_in_one=true, $ab_prefix=false)
126
+	private function get_addressbooks($account = null, $return_all_in_one = true, $ab_prefix = false)
127 127
 	{
128
-		static $abs=null;
128
+		static $abs = null;
129 129
 
130 130
 		if (!isset($abs) || !$return_all_in_one)
131 131
 		{
@@ -137,13 +137,13 @@  discard block
 block discarded – undo
137 137
 			}
138 138
 			else
139 139
 			{
140
-				Api\Translation::add_app('addressbook');	// we need the addressbook translations
140
+				Api\Translation::add_app('addressbook'); // we need the addressbook translations
141 141
 
142 142
 				if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts();
143 143
 
144 144
 				// error_log(print_r($this->addressbook->get_addressbooks(Acl::READ),true));
145 145
 				$pref = $GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-abs'];
146
-				$pref_abs = (string)$pref !== '' ? explode(',',$pref) : array();
146
+				$pref_abs = (string)$pref !== '' ? explode(',', $pref) : array();
147 147
 
148 148
 				foreach ($this->addressbook->get_addressbooks() as $account_id => $label)
149 149
 				{
@@ -151,18 +151,17 @@  discard block
 block discarded – undo
151 151
 					{
152 152
 						$account_id = self::PRIVATE_AB;
153 153
 					}
154
-					if ($account_id && in_array($account_id,$pref_abs) || in_array('A',$pref_abs) ||
155
-						$account_id == 0 && in_array('U',$pref_abs) ||
156
-						$account_id == $GLOBALS['egw_info']['user']['account_id'] ||	// allways sync pers. AB
157
-						$account_id == $GLOBALS['egw_info']['user']['account_primary_group'] && in_array('G',$pref_abs))
154
+					if ($account_id && in_array($account_id, $pref_abs) || in_array('A', $pref_abs) ||
155
+						$account_id == 0 && in_array('U', $pref_abs) ||
156
+						$account_id == $GLOBALS['egw_info']['user']['account_id'] || // allways sync pers. AB
157
+						$account_id == $GLOBALS['egw_info']['user']['account_primary_group'] && in_array('G', $pref_abs))
158 158
 					{
159 159
 						$abs[$account_id] = $label;
160 160
 					}
161 161
 				}
162 162
 			}
163 163
 		}
164
-		$ret = is_null($account) ? $abs :
165
-			($ab_prefix && (!$account || (int)$account == (int)$GLOBALS['egw_info']['user']['account_id']) ?
164
+		$ret = is_null($account) ? $abs : ($ab_prefix && (!$account || (int)$account == (int)$GLOBALS['egw_info']['user']['account_id']) ?
166 165
 				lang('Addressbook').' ' : '').$abs[$account];
167 166
 		//error_log(__METHOD__."($account, $return_all_in_one, $ab_prefix) returning ".array2string($ret));
168 167
 		return $ret;
@@ -180,7 +179,7 @@  discard block
 block discarded – undo
180 179
 		foreach ($this->get_addressbooks() as $account => $label)
181 180
 		{
182 181
 			$folderlist[] = array(
183
-				'id'	=>	$this->backend->createID('addressbook',$account),
182
+				'id'	=>	$this->backend->createID('addressbook', $account),
184 183
 				'mod'	=>	$label,
185 184
 				'parent'=>	'0',
186 185
 			);
@@ -278,20 +277,20 @@  discard block
 block discarded – undo
278 277
 	 * @param int $cutoffdate =null
279 278
 	 * @return array
280 279
   	 */
281
-	function GetMessageList($id, $cutoffdate=NULL)
280
+	function GetMessageList($id, $cutoffdate = NULL)
282 281
 	{
283
-		unset($cutoffdate);	// not used, but required by function signature
282
+		unset($cutoffdate); // not used, but required by function signature
284 283
 		if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts();
285 284
 
286 285
 		$type = $user = null;
287
-		$this->backend->splitID($id,$type,$user);
286
+		$this->backend->splitID($id, $type, $user);
288 287
 		$filter = array('owner' => $user);
289 288
 
290 289
 		// handle all-in-one addressbook
291 290
 		if ($GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-all-in-one'] &&
292 291
 			$user == $GLOBALS['egw_info']['user']['account_id'])
293 292
 		{
294
-			$filter['owner'] = array_keys($this->get_addressbooks(null,false));	// false = return all selected abs
293
+			$filter['owner'] = array_keys($this->get_addressbooks(null, false)); // false = return all selected abs
295 294
 			// translate AS private AB ID to EGroupware one
296 295
 			if (($key = array_search(self::PRIVATE_AB, $filter['owner'])) !== false)
297 296
 			{
@@ -308,10 +307,10 @@  discard block
 block discarded – undo
308 307
 
309 308
 		$messagelist = array();
310 309
 		$criteria = null;
311
-		if (($contacts =& $this->addressbook->search($criteria, 'contact_id,contact_etag', '', '', '',
312
-			false, 'AND', false,$filter)))
310
+		if (($contacts = & $this->addressbook->search($criteria, 'contact_id,contact_etag', '', '', '',
311
+			false, 'AND', false, $filter)))
313 312
 		{
314
-			foreach($contacts as $contact)
313
+			foreach ($contacts as $contact)
315 314
 			{
316 315
 				$messagelist[] = $this->StatMessage($id, $contact);
317 316
 			}
@@ -348,9 +347,9 @@  discard block
 block discarded – undo
348 347
 		}
349 348
 		$emailname = isset($contact['n_given']) ? $contact['n_given'].' ' : '';
350 349
 		$emailname .= isset($contact['n_middle']) ? $contact['n_middle'].' ' : '';
351
-		$emailname .= isset($contact['n_family']) ? $contact['n_family']: '';
350
+		$emailname .= isset($contact['n_family']) ? $contact['n_family'] : '';
352 351
 		$message = new SyncContact();
353
-		foreach(self::$mapping as $key => $attr)
352
+		foreach (self::$mapping as $key => $attr)
354 353
 		{
355 354
 			switch ($attr)
356 355
 			{
@@ -363,7 +362,7 @@  discard block
 block discarded – undo
363 362
 					}
364 363
 					else
365 364
 					{
366
-						if (strlen ($contact[$attr]) > 0)
365
+						if (strlen($contact[$attr]) > 0)
367 366
 						{
368 367
 							$message->asbody = new SyncBaseBody();
369 368
 							$this->backend->note2messagenote($contact[$attr], $bodypreference, $message->asbody);
@@ -387,14 +386,14 @@  discard block
 block discarded – undo
387 386
 
388 387
 				case 'cat_id':
389 388
 					$message->$key = array();
390
-					foreach($contact[$attr] ? explode(',',$contact[$attr]) : array() as $cat_id)
389
+					foreach ($contact[$attr] ? explode(',', $contact[$attr]) : array() as $cat_id)
391 390
 					{
392 391
 						$message->categories[] = Api\Categories::id2name($cat_id);
393 392
 					}
394 393
 					// for all addressbooks in one, add addressbook name itself as category
395 394
 					if ($GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-all-in-one'])
396 395
 					{
397
-						$message->categories[] = $this->get_addressbooks($contact['owner'].($contact['private']?'p':''), false, true);
396
+						$message->categories[] = $this->get_addressbooks($contact['owner'].($contact['private'] ? 'p' : ''), false, true);
398 397
 					}
399 398
 					break;
400 399
 				case 'email':
@@ -413,7 +412,7 @@  discard block
 block discarded – undo
413 412
 				case 'n_fileas':
414 413
 					if ($GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-force-fileas'])
415 414
 					{
416
-						$message->$key = $this->addressbook->fileas($contact,$GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-force-fileas']);
415
+						$message->$key = $this->addressbook->fileas($contact, $GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-force-fileas']);
417 416
 						break;
418 417
 					}
419 418
 					// fall through
@@ -439,7 +438,7 @@  discard block
 block discarded – undo
439 438
 	 */
440 439
 	public function StatMessage($folderid, $contact)
441 440
 	{
442
-		unset($folderid);	// not used (contact_id is global), but required by function signaure
441
+		unset($folderid); // not used (contact_id is global), but required by function signaure
443 442
 		if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts();
444 443
 
445 444
 		if (!is_array($contact)) $contact = $this->addressbook->read($contact);
@@ -474,7 +473,7 @@  discard block
 block discarded – undo
474 473
 	 */
475 474
 	public function ChangeFolder($id, $oldid, $displayname, $type)
476 475
 	{
477
-		unset($id, $oldid, $displayname, $type);	// not used, but required by function signature
476
+		unset($id, $oldid, $displayname, $type); // not used, but required by function signature
478 477
 		debugLog(__METHOD__." not implemented");
479 478
 	}
480 479
 
@@ -513,7 +512,7 @@  discard block
 block discarded – undo
513 512
 	 */
514 513
 	public function ChangeMessage($folderid, $id, $message, $contentParameters)
515 514
 	{
516
-		unset($contentParameters);	// not used, but required by function signature
515
+		unset($contentParameters); // not used, but required by function signature
517 516
 		if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts();
518 517
 
519 518
 		$type = $account = null;
@@ -534,10 +533,10 @@  discard block
 block discarded – undo
534 533
 		if ($account == 0)	// as a precausion, we currently do NOT allow to change Api\Accounts
535 534
 		{
536 535
 			debugLog(__METHOD__." Changing of Api\Accounts denied!");
537
-			return false;			//no changing of Api\Accounts
536
+			return false; //no changing of Api\Accounts
538 537
 		}
539 538
 		$contact = array();
540
-		if (empty($id) && ($this->addressbook->grants[$account] & Acl::EDIT) || ($contact = $this->addressbook->read($id)) && $this->addressbook->check_perms(Acl::EDIT, $contact))
539
+		if (empty($id) && ($this->addressbook->grants[$account]&Acl::EDIT) || ($contact = $this->addressbook->read($id)) && $this->addressbook->check_perms(Acl::EDIT, $contact))
541 540
 		{
542 541
 			// remove all fields supported by AS, leaving all unsupported fields unchanged
543 542
 			$contact = array_diff_key($contact, array_flip(self::$mapping));
@@ -550,7 +549,7 @@  discard block
 block discarded – undo
550 549
 						break;
551 550
 
552 551
 					case 'bday':	// zpush uses timestamp in servertime
553
-						$contact[$attr] = $message->$key ? date('Y-m-d',$message->$key) : null;
552
+						$contact[$attr] = $message->$key ? date('Y-m-d', $message->$key) : null;
554 553
 						break;
555 554
 
556 555
 					case 'jpegphoto':
@@ -560,20 +559,20 @@  discard block
 block discarded – undo
560 559
 					case 'cat_id':
561 560
 						// for existing entries in all-in-one addressbook, remove addressbook name as category
562 561
 						if ($contact && $GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-all-in-one'] &&
563
-							($k=array_search($this->get_addressbooks($contact['owner'].($contact['private']?'p':''), false, true),$message->$key)))
562
+							($k = array_search($this->get_addressbooks($contact['owner'].($contact['private'] ? 'p' : ''), false, true), $message->$key)))
564 563
 						{
565 564
 							unset($message->categories[$k]);
566 565
 						}
567 566
 						if (is_array($message->$key))
568 567
 						{
569
-							$contact[$attr] = implode(',', array_filter($this->addressbook->find_or_add_categories($message->$key, $id),'strlen'));
568
+							$contact[$attr] = implode(',', array_filter($this->addressbook->find_or_add_categories($message->$key, $id), 'strlen'));
570 569
 						}
571 570
 						break;
572 571
 					case 'email':
573 572
 					case 'email_home':
574
-						if (function_exists ('imap_rfc822_parse_adrlist'))
573
+						if (function_exists('imap_rfc822_parse_adrlist'))
575 574
 						{
576
-							$email_array = array_shift(imap_rfc822_parse_adrlist($message->$key,""));
575
+							$email_array = array_shift(imap_rfc822_parse_adrlist($message->$key, ""));
577 576
 							if (!empty($email_array->mailbox) && $email_array->mailbox != 'INVALID_ADDRESS' && !empty($email_array->host))
578 577
 							{
579 578
 								$contact[$attr] = $email_array->mailbox.'@'.$email_array->host;
@@ -585,7 +584,7 @@  discard block
 block discarded – undo
585 584
 						}
586 585
 						else
587 586
 						{
588
-							debugLog(__METHOD__. " Warning : php-imap not available");
587
+							debugLog(__METHOD__." Warning : php-imap not available");
589 588
 							$contact[$attr] = $message->$key;
590 589
 						}
591 590
 						break;
@@ -612,9 +611,9 @@  discard block
 block discarded – undo
612 611
 				$contact['private'] = (int)$is_private;
613 612
 			}
614 613
 			// if default addressbook for new contacts is NOT synced --> use personal addressbook
615
-			elseif($GLOBALS['egw_info']['user']['preferences']['addressbook']['add_default'] &&
614
+			elseif ($GLOBALS['egw_info']['user']['preferences']['addressbook']['add_default'] &&
616 615
 				!in_array($GLOBALS['egw_info']['user']['preferences']['addressbook']['add_default'],
617
-					array_keys($this->get_addressbooks(null,false))))
616
+					array_keys($this->get_addressbooks(null, false))))
618 617
 			{
619 618
 				$contact['owner'] = $GLOBALS['egw_info']['user']['account_id'];
620 619
 			}
@@ -646,7 +645,7 @@  discard block
 block discarded – undo
646 645
 	 */
647 646
 	public function MoveMessage($folderid, $id, $newfolderid, $contentParameters)
648 647
 	{
649
-		unset($contentParameters);	// not used, but required by function signature
648
+		unset($contentParameters); // not used, but required by function signature
650 649
 		if ($GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-all-in-one'])
651 650
 		{
652 651
 			debugLog(__METHOD__."('$folderid', $id, $newfolderid) NOT allowed for an all-in-one addressbook --> returning false");
@@ -673,7 +672,7 @@  discard block
 block discarded – undo
673 672
 	 */
674 673
 	public function DeleteMessage($folderid, $id, $contentParameters)
675 674
 	{
676
-		unset($contentParameters);	// not used, but required by function signature
675
+		unset($contentParameters); // not used, but required by function signature
677 676
 		if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts();
678 677
 
679 678
 		$ret = $this->addressbook->delete($id);
@@ -742,18 +741,18 @@  discard block
 block discarded – undo
742 741
 		if ($GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-all-in-one'] &&
743 742
 			$owner == $GLOBALS['egw_info']['user']['account_id'])
744 743
 		{
745
-			if (strpos($GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-abs'],'A') !== false)
744
+			if (strpos($GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-abs'], 'A') !== false)
746 745
 			{
747
-				$owner = null;	// all AB's
746
+				$owner = null; // all AB's
748 747
 			}
749 748
 			else
750 749
 			{
751
-				$owner = array_keys($this->get_addressbooks(null,false));	// false = return all selected abs
750
+				$owner = array_keys($this->get_addressbooks(null, false)); // false = return all selected abs
752 751
 				// translate AS private AB ID to current user
753 752
 				if (($key = array_search(self::PRIVATE_AB, $owner)) !== false)
754 753
 				{
755 754
 					unset($owner[$key]);
756
-					if (!in_array($GLOBALS['egw_info']['user']['account_id'],$owner))
755
+					if (!in_array($GLOBALS['egw_info']['user']['account_id'], $owner))
757 756
 					{
758 757
 						$owner[] = $GLOBALS['egw_info']['user']['account_id'];
759 758
 					}
@@ -766,7 +765,7 @@  discard block
 block discarded – undo
766 765
 		}
767 766
 		$ctag = $this->addressbook->get_ctag($owner);
768 767
 
769
-		$changes = array();	// no change
768
+		$changes = array(); // no change
770 769
 		//$syncstate_was = $syncstate;
771 770
 
772 771
 		if ($ctag !== $syncstate)
@@ -794,32 +793,32 @@  discard block
 block discarded – undo
794 793
 		$range = false;
795 794
 		if (isset($searchquery['range']) && preg_match('/^\d+-\d+$/', $searchquery['range']))
796 795
 		{
797
-			list($start,$end) = explode('-', $searchquery['range']);
798
-			$range = array($start, $end-$start+1);	// array(start, num_entries)
796
+			list($start, $end) = explode('-', $searchquery['range']);
797
+			$range = array($start, $end - $start + 1); // array(start, num_entries)
799 798
 		}
800 799
 		//error_log(__METHOD__.'('.array2string($searchquery).') range='.array2string($range));
801 800
 
802 801
 		$items = $filter = array();
803 802
 		$filter['cols_to_search'] = array('n_fn', 'n_family', 'n_given',
804
-						'room','org_name', 'title', 'role', 'tel_work', 'tel_home', 'tel_cell',
803
+						'room', 'org_name', 'title', 'role', 'tel_work', 'tel_home', 'tel_cell',
805 804
 						'email', 'email_home');
806
-		if (($contacts =& $this->addressbook->search($searchquery['query'], false, false, '', '%', false, 'OR', $range, $filter)))
805
+		if (($contacts = & $this->addressbook->search($searchquery['query'], false, false, '', '%', false, 'OR', $range, $filter)))
807 806
 		{
808
-			foreach($contacts as $contact)
807
+			foreach ($contacts as $contact)
809 808
 			{
810 809
 				//$item[SYNC_GAL_ALIAS] = $contact['contact_id'];
811
-			  	$item[SYNC_GAL_LASTNAME] = $contact['n_family']?$contact['n_family']:$contact['org_name'];
810
+			  	$item[SYNC_GAL_LASTNAME] = $contact['n_family'] ? $contact['n_family'] : $contact['org_name'];
812 811
 			  	$item[SYNC_GAL_FIRSTNAME] = $contact['n_given'];
813 812
 				$item[SYNC_GAL_DISPLAYNAME] = $contact['n_fn'];
814
-				if (!trim($item[SYNC_GAL_DISPLAYNAME])) $item[SYNC_GAL_DISPLAYNAME] = $contact['n_family']?$contact['n_family']:$contact['org_name'];
815
-				$item[SYNC_GAL_EMAILADDRESS] = $contact['email'] ? $contact['email'] : (string)$contact['email_private'] ;
813
+				if (!trim($item[SYNC_GAL_DISPLAYNAME])) $item[SYNC_GAL_DISPLAYNAME] = $contact['n_family'] ? $contact['n_family'] : $contact['org_name'];
814
+				$item[SYNC_GAL_EMAILADDRESS] = $contact['email'] ? $contact['email'] : (string)$contact['email_private'];
816 815
 				//$item['nameid'] = $searchquery;
817 816
 				$item[SYNC_GAL_PHONE] = (string)$contact['tel_work'];
818 817
 				$item[SYNC_GAL_HOMEPHONE] = (string)$contact['tel_home'];
819 818
 				$item[SYNC_GAL_MOBILEPHONE] = (string)$contact['tel_cell'];
820 819
 				$item[SYNC_GAL_COMPANY] = (string)$contact['org_name'];
821 820
 				$item[SYNC_GAL_OFFICE] = $contact['room'];
822
-				$item[SYNC_GAL_TITLE ] = $contact['title'];
821
+				$item[SYNC_GAL_TITLE] = $contact['title'];
823 822
 
824 823
 			  	//do not return users without email
825 824
 				if (!trim($item[SYNC_GAL_EMAILADDRESS])) continue;
@@ -827,8 +826,8 @@  discard block
 block discarded – undo
827 826
 				$items[] = $item;
828 827
 			}
829 828
 		}
830
-		$items['searchtotal']=count($items);
831
-		$items['range']=$searchquery['range'];
829
+		$items['searchtotal'] = count($items);
830
+		$items['range'] = $searchquery['range'];
832 831
 		return $items;
833 832
 	}
834 833
 
@@ -849,14 +848,14 @@  discard block
 block discarded – undo
849 848
 			$addressbooks = $addressbook_bo->get_addressbooks(Acl::READ, null, $user);
850 849
 			if ($user > 0)
851 850
 			{
852
-				unset($addressbooks[$user]);	// personal addressbook is allways synced
851
+				unset($addressbooks[$user]); // personal addressbook is allways synced
853 852
 				if (isset($addressbooks[$user.'p']))
854 853
 				{
855 854
 					$addressbooks[self::PRIVATE_AB] = lang('Private');
856 855
 				}
857 856
 			}
858
-			unset($addressbooks[$user.'p']);// private addressbook uses ID self::PRIVATE_AB
859
-			$fileas_options = array('0' => lang('use addressbooks "own sorting" attribute'))+$addressbook_bo->fileas_options();
857
+			unset($addressbooks[$user.'p']); // private addressbook uses ID self::PRIVATE_AB
858
+			$fileas_options = array('0' => lang('use addressbooks "own sorting" attribute')) + $addressbook_bo->fileas_options();
860 859
 		}
861 860
 		$addressbooks += array(
862 861
 			'G'	=> lang('Primary Group'),
Please login to merge, or discard this patch.
Braces   +76 added lines, -19 removed lines patch added patch discarded remove patch
@@ -139,7 +139,10 @@  discard block
 block discarded – undo
139 139
 			{
140 140
 				Api\Translation::add_app('addressbook');	// we need the addressbook translations
141 141
 
142
-				if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts();
142
+				if (!isset($this->addressbook))
143
+				{
144
+					$this->addressbook = new Api\Contacts();
145
+				}
143 146
 
144 147
 				// error_log(print_r($this->addressbook->get_addressbooks(Acl::READ),true));
145 148
 				$pref = $GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-abs'];
@@ -281,7 +284,10 @@  discard block
 block discarded – undo
281 284
 	function GetMessageList($id, $cutoffdate=NULL)
282 285
 	{
283 286
 		unset($cutoffdate);	// not used, but required by function signature
284
-		if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts();
287
+		if (!isset($this->addressbook))
288
+		{
289
+			$this->addressbook = new Api\Contacts();
290
+		}
285 291
 
286 292
 		$type = $user = null;
287 293
 		$this->backend->splitID($id,$type,$user);
@@ -332,7 +338,10 @@  discard block
 block discarded – undo
332 338
 	 */
333 339
 	public function GetMessage($folderid, $id, $contentparameters)
334 340
 	{
335
-		if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts();
341
+		if (!isset($this->addressbook))
342
+		{
343
+			$this->addressbook = new Api\Contacts();
344
+		}
336 345
 
337 346
 		//$truncsize = Utils::GetTruncSize($contentparameters->GetTruncation());
338 347
 		//$mimesupport = $contentparameters->GetMimeSupport();
@@ -372,7 +381,10 @@  discard block
 block discarded – undo
372 381
 					break;
373 382
 
374 383
 				case 'jpegphoto':
375
-					if (!empty($contact[$attr])) $message->$key = base64_encode($contact[$attr]);
384
+					if (!empty($contact[$attr]))
385
+					{
386
+						$message->$key = base64_encode($contact[$attr]);
387
+					}
376 388
 					break;
377 389
 
378 390
 				case 'bday':	// zpush seems to use a timestamp in utc (at least vcard backend does)
@@ -418,7 +430,10 @@  discard block
 block discarded – undo
418 430
 					}
419 431
 					// fall through
420 432
 				default:
421
-					if (!empty($contact[$attr])) $message->$key = $contact[$attr];
433
+					if (!empty($contact[$attr]))
434
+					{
435
+						$message->$key = $contact[$attr];
436
+					}
422 437
 			}
423 438
 		}
424 439
 		//error_log(__METHOD__."(folder='$folderid',$id,...) returning ".array2string($message));
@@ -440,9 +455,15 @@  discard block
 block discarded – undo
440 455
 	public function StatMessage($folderid, $contact)
441 456
 	{
442 457
 		unset($folderid);	// not used (contact_id is global), but required by function signaure
443
-		if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts();
458
+		if (!isset($this->addressbook))
459
+		{
460
+			$this->addressbook = new Api\Contacts();
461
+		}
444 462
 
445
-		if (!is_array($contact)) $contact = $this->addressbook->read($contact);
463
+		if (!is_array($contact))
464
+		{
465
+			$contact = $this->addressbook->read($contact);
466
+		}
446 467
 
447 468
 		if (!$contact)
448 469
 		{
@@ -514,7 +535,10 @@  discard block
 block discarded – undo
514 535
 	public function ChangeMessage($folderid, $id, $message, $contentParameters)
515 536
 	{
516 537
 		unset($contentParameters);	// not used, but required by function signature
517
-		if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts();
538
+		if (!isset($this->addressbook))
539
+		{
540
+			$this->addressbook = new Api\Contacts();
541
+		}
518 542
 
519 543
 		$type = $account = null;
520 544
 		$this->backend->splitID($folderid, $type, $account);
@@ -526,14 +550,20 @@  discard block
 block discarded – undo
526 550
 
527 551
 		}
528 552
 		// error_log(__METHOD__. " Id " .$id. " Account ". $account . " FolderID " . $folderid);
529
-		if ($type != 'addressbook') // || !($contact = $this->addressbook->read($id)))
553
+		if ($type != 'addressbook')
554
+		{
555
+			// || !($contact = $this->addressbook->read($id)))
530 556
 		{
531 557
 			debugLog(__METHOD__." Folder wrong or contact not existing");
558
+		}
532 559
 			return false;
533 560
 		}
534
-		if ($account == 0)	// as a precausion, we currently do NOT allow to change Api\Accounts
561
+		if ($account == 0)
562
+		{
563
+			// as a precausion, we currently do NOT allow to change Api\Accounts
535 564
 		{
536 565
 			debugLog(__METHOD__." Changing of Api\Accounts denied!");
566
+		}
537 567
 			return false;			//no changing of Api\Accounts
538 568
 		}
539 569
 		$contact = array();
@@ -596,7 +626,10 @@  discard block
 block discarded – undo
596 626
 						}
597 627
 						break;
598 628
 					case 'title':	// as ol jobtitle mapping changed in egw from role to title, do NOT overwrite title with value of role
599
-						if ($id && $message->$key == $contact['role']) break;
629
+						if ($id && $message->$key == $contact['role'])
630
+						{
631
+							break;
632
+						}
600 633
 						// fall throught
601 634
 					default:
602 635
 						$contact[$attr] = $message->$key;
@@ -605,7 +638,10 @@  discard block
 block discarded – undo
605 638
 			}
606 639
 			// for all-in-one addressbook, account is meaningless and wrong!
607 640
 			// Api\Contacts::save() keeps the owner or sets an appropriate one if none given
608
-			if (!isset($contact['private'])) $contact['private'] = (int)$is_private;
641
+			if (!isset($contact['private']))
642
+			{
643
+				$contact['private'] = (int)$is_private;
644
+			}
609 645
 			if (!$GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-all-in-one'])
610 646
 			{
611 647
 				$contact['owner'] = $account;
@@ -618,7 +654,10 @@  discard block
 block discarded – undo
618 654
 			{
619 655
 				$contact['owner'] = $GLOBALS['egw_info']['user']['account_id'];
620 656
 			}
621
-			if (!empty($id)) $contact['id'] = $id;
657
+			if (!empty($id))
658
+			{
659
+				$contact['id'] = $id;
660
+			}
622 661
 			$this->addressbook->fixup_contact($contact);
623 662
 			$newid = $this->addressbook->save($contact);
624 663
 			//error_log(__METHOD__."($folderid,$id) contact=".array2string($contact)." returning ".array2string($newid));
@@ -674,7 +713,10 @@  discard block
 block discarded – undo
674 713
 	public function DeleteMessage($folderid, $id, $contentParameters)
675 714
 	{
676 715
 		unset($contentParameters);	// not used, but required by function signature
677
-		if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts();
716
+		if (!isset($this->addressbook))
717
+		{
718
+			$this->addressbook = new Api\Contacts();
719
+		}
678 720
 
679 721
 		$ret = $this->addressbook->delete($id);
680 722
 		debugLog(__METHOD__."('$folderid', $id) delete($id) returned ".array2string($ret));
@@ -734,9 +776,15 @@  discard block
 block discarded – undo
734 776
 		$type = $owner = null;
735 777
 		$this->backend->splitID($folderid, $type, $owner);
736 778
 
737
-		if ($type != 'addressbook') return false;
779
+		if ($type != 'addressbook')
780
+		{
781
+			return false;
782
+		}
738 783
 
739
-		if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts();
784
+		if (!isset($this->addressbook))
785
+		{
786
+			$this->addressbook = new Api\Contacts();
787
+		}
740 788
 
741 789
 		// handle all-in-one addressbook
742 790
 		if ($GLOBALS['egw_info']['user']['preferences']['activesync']['addressbook-all-in-one'] &&
@@ -787,7 +835,10 @@  discard block
 block discarded – undo
787 835
 	 */
788 836
 	function getSearchResultsGAL($searchquery)
789 837
 	{
790
-		if (!isset($this->addressbook)) $this->addressbook = new Api\Contacts();
838
+		if (!isset($this->addressbook))
839
+		{
840
+			$this->addressbook = new Api\Contacts();
841
+		}
791 842
 		//error_log(__METHOD__.'('.array2string($searchquery).')');
792 843
 
793 844
 		// only return items in given range, eg. "0-50"
@@ -811,7 +862,10 @@  discard block
 block discarded – undo
811 862
 			  	$item[SYNC_GAL_LASTNAME] = $contact['n_family']?$contact['n_family']:$contact['org_name'];
812 863
 			  	$item[SYNC_GAL_FIRSTNAME] = $contact['n_given'];
813 864
 				$item[SYNC_GAL_DISPLAYNAME] = $contact['n_fn'];
814
-				if (!trim($item[SYNC_GAL_DISPLAYNAME])) $item[SYNC_GAL_DISPLAYNAME] = $contact['n_family']?$contact['n_family']:$contact['org_name'];
865
+				if (!trim($item[SYNC_GAL_DISPLAYNAME]))
866
+				{
867
+					$item[SYNC_GAL_DISPLAYNAME] = $contact['n_family']?$contact['n_family']:$contact['org_name'];
868
+				}
815 869
 				$item[SYNC_GAL_EMAILADDRESS] = $contact['email'] ? $contact['email'] : (string)$contact['email_private'] ;
816 870
 				//$item['nameid'] = $searchquery;
817 871
 				$item[SYNC_GAL_PHONE] = (string)$contact['tel_work'];
@@ -822,7 +876,10 @@  discard block
 block discarded – undo
822 876
 				$item[SYNC_GAL_TITLE ] = $contact['title'];
823 877
 
824 878
 			  	//do not return users without email
825
-				if (!trim($item[SYNC_GAL_EMAILADDRESS])) continue;
879
+				if (!trim($item[SYNC_GAL_EMAILADDRESS]))
880
+				{
881
+					continue;
882
+				}
826 883
 
827 884
 				$items[] = $item;
828 885
 			}
Please login to merge, or discard this patch.
addressbook/inc/class.addressbook_wizard_export_contacts_csv.inc.php 3 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -35,8 +35,8 @@  discard block
 block discarded – undo
35 35
 	}
36 36
 
37 37
 	/**
38
-	* Overridden to be able to skip the next step
39
-	*/
38
+	 * Overridden to be able to skip the next step
39
+	 */
40 40
 	function wizard_step40(&$content, &$sel_options, &$readonlys, &$preserv) {
41 41
 
42 42
 		if ($content['step'] == 'wizard_step40' && array_search('pressed', $content['button']) == 'next') {
@@ -52,10 +52,10 @@  discard block
 block discarded – undo
52 52
 		}
53 53
 	}
54 54
 
55
-        /**
56
-        * Choose how to export multi-selects (includes Api\Categories)
57
-        */
58
-        function wizard_step50(&$content, &$sel_options, &$readonlys, &$preserv)
55
+		/**
56
+		 * Choose how to export multi-selects (includes Api\Categories)
57
+		 */
58
+		function wizard_step50(&$content, &$sel_options, &$readonlys, &$preserv)
59 59
 	{
60 60
 		if($this->debug) error_log(get_class($this) . '::wizard_step50->$content '.print_r($content,true));
61 61
 		// return from step50
@@ -130,8 +130,8 @@  discard block
 block discarded – undo
130 130
 	}
131 131
 
132 132
 	/**
133
-	* Get a list of multi-select fields
134
-	*/
133
+	 * Get a list of multi-select fields
134
+	 */
135 135
 	protected function get_field_list($content) {
136 136
 		$field_list = array();
137 137
 
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -22,10 +22,10 @@  discard block
 block discarded – undo
22 22
 		// Field mapping
23 23
 		$bocontacts = new Api\Contacts();
24 24
 		$this->export_fields = $bocontacts->contact_fields;
25
-		foreach($bocontacts->customfields as $name => $data) {
25
+		foreach ($bocontacts->customfields as $name => $data) {
26 26
 			$this->export_fields['#'.$name] = $data['label'];
27 27
 		}
28
-		unset($this->export_fields['jpegphoto']);        // can't cvs export that
28
+		unset($this->export_fields['jpegphoto']); // can't cvs export that
29 29
 
30 30
 		// Add in last/next appointments
31 31
 		// NB: last_date and next_date are used instead of last_event & next_event
@@ -42,10 +42,10 @@  discard block
 block discarded – undo
42 42
 		if ($content['step'] == 'wizard_step40' && array_search('pressed', $content['button']) == 'next') {
43 43
 			$result = parent::wizard_step40($content, $sel_options, $readonlys, $preserv);
44 44
 			$field_list = $this->get_field_list($content);
45
-			if(count($field_list)) {
45
+			if (count($field_list)) {
46 46
 				return $result;
47 47
 			} else {
48
-				return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],2);
48
+				return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], 2);
49 49
 			}
50 50
 		} else {
51 51
 			return parent::wizard_step40($content, $sel_options, $readonlys, $preserv);
@@ -57,15 +57,15 @@  discard block
 block discarded – undo
57 57
         */
58 58
         function wizard_step50(&$content, &$sel_options, &$readonlys, &$preserv)
59 59
 	{
60
-		if($this->debug) error_log(get_class($this) . '::wizard_step50->$content '.print_r($content,true));
60
+		if ($this->debug) error_log(get_class($this).'::wizard_step50->$content '.print_r($content, true));
61 61
 		// return from step50
62 62
 		if ($content['step'] == 'wizard_step50')
63 63
 		{
64
-			if($content['explode_multiselects']) {
64
+			if ($content['explode_multiselects']) {
65 65
 				$explodes = $content['explode_multiselects'];
66 66
 				$content['explode_multiselects'] = array();
67
-				foreach($explodes as $row => $settings) {
68
-					if($settings['explode'] != addressbook_export_contacts_csv::NO_EXPLODE) {
67
+				foreach ($explodes as $row => $settings) {
68
+					if ($settings['explode'] != addressbook_export_contacts_csv::NO_EXPLODE) {
69 69
 						$content['explode_multiselects'][$settings['field']] = $settings;
70 70
 					}
71 71
 				}
@@ -73,13 +73,13 @@  discard block
 block discarded – undo
73 73
 			switch (array_search('pressed', $content['button']))
74 74
 			{
75 75
 				case 'next':
76
-					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],1);
76
+					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], 1);
77 77
 				case 'previous' :
78
-					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],-1);
78
+					return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'], -1);
79 79
 				case 'finish':
80 80
 					return 'wizard_finish';
81 81
 				default :
82
-					return $this->wizard_step50($content,$sel_options,$readonlys,$preserv);
82
+					return $this->wizard_step50($content, $sel_options, $readonlys, $preserv);
83 83
 			}
84 84
 		}
85 85
 		// init step50
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 			$settings = $content['explode_multiselects'] ? $content['explode_multiselects'] : $content['plugin_options']['explode_multiselects'];
94 94
 
95 95
 			// Skip this step if no fields applicable
96
-			if(count($field_list) == 0) {
96
+			if (count($field_list) == 0) {
97 97
 				$content['explode_multiselects'] = array();
98 98
 			}
99 99
 
@@ -108,13 +108,13 @@  discard block
 block discarded – undo
108 108
 			);
109 109
 
110 110
 			$row = 1;
111
-			foreach($field_list as $field => $name) {
111
+			foreach ($field_list as $field => $name) {
112 112
 				$content['explode_multiselects'][$row] = array(
113 113
 					'field' =>      $field,
114 114
 					'name'  =>      $name,
115 115
 					'explode'=>	$settings[$field]
116 116
 				);
117
-				if($field == 'cat_id') {
117
+				if ($field == 'cat_id') {
118 118
 					$sel_options['explode_multiselects'][$row]['explode'] = $cat_options;
119 119
 				} else {
120 120
 					$sel_options['explode_multiselects'][$row]['explode'] = $multi_options;
@@ -136,14 +136,14 @@  discard block
 block discarded – undo
136 136
 		$field_list = array();
137 137
 
138 138
 		// Category gets special handling
139
-		if(in_array('cat_id', array_keys($content['mapping']))) {
139
+		if (in_array('cat_id', array_keys($content['mapping']))) {
140 140
 			$field_list['cat_id'] = $this->export_fields['cat_id'];
141 141
 		}
142 142
 
143 143
 		// Add any multi-select custom fields
144 144
 		$custom = Api\Storage\Customfields::get('addressbook');
145
-		foreach($custom as $name => $c_field) {
146
-			if($c_field['type'] == 'select' && $c_field['rows'] > 1 && in_array('#'.$name, array_keys($content['mapping']))) {
145
+		foreach ($custom as $name => $c_field) {
146
+			if ($c_field['type'] == 'select' && $c_field['rows'] > 1 && in_array('#'.$name, array_keys($content['mapping']))) {
147 147
 				$field_list['#'.$name] = $c_field['label'];
148 148
 			}
149 149
 		}
Please login to merge, or discard this patch.
Braces   +44 added lines, -20 removed lines patch added patch discarded remove patch
@@ -13,7 +13,8 @@  discard block
 block discarded – undo
13 13
 
14 14
 class addressbook_wizard_export_contacts_csv extends importexport_wizard_basic_export_csv
15 15
 {
16
-	public function __construct() {
16
+	public function __construct()
17
+	{
17 18
 		parent::__construct();
18 19
 
19 20
 		$this->steps['wizard_step50'] = lang('Choose export options');
@@ -22,7 +23,8 @@  discard block
 block discarded – undo
22 23
 		// Field mapping
23 24
 		$bocontacts = new Api\Contacts();
24 25
 		$this->export_fields = $bocontacts->contact_fields;
25
-		foreach($bocontacts->customfields as $name => $data) {
26
+		foreach($bocontacts->customfields as $name => $data)
27
+		{
26 28
 			$this->export_fields['#'.$name] = $data['label'];
27 29
 		}
28 30
 		unset($this->export_fields['jpegphoto']);        // can't cvs export that
@@ -37,17 +39,24 @@  discard block
 block discarded – undo
37 39
 	/**
38 40
 	* Overridden to be able to skip the next step
39 41
 	*/
40
-	function wizard_step40(&$content, &$sel_options, &$readonlys, &$preserv) {
42
+	function wizard_step40(&$content, &$sel_options, &$readonlys, &$preserv)
43
+	{
41 44
 
42
-		if ($content['step'] == 'wizard_step40' && array_search('pressed', $content['button']) == 'next') {
45
+		if ($content['step'] == 'wizard_step40' && array_search('pressed', $content['button']) == 'next')
46
+		{
43 47
 			$result = parent::wizard_step40($content, $sel_options, $readonlys, $preserv);
44 48
 			$field_list = $this->get_field_list($content);
45
-			if(count($field_list)) {
49
+			if(count($field_list))
50
+			{
46 51
 				return $result;
47
-			} else {
52
+			}
53
+			else
54
+			{
48 55
 				return $GLOBALS['egw']->importexport_definitions_ui->get_step($content['step'],2);
49 56
 			}
50
-		} else {
57
+		}
58
+		else
59
+		{
51 60
 			return parent::wizard_step40($content, $sel_options, $readonlys, $preserv);
52 61
 		}
53 62
 	}
@@ -56,16 +65,22 @@  discard block
 block discarded – undo
56 65
         * Choose how to export multi-selects (includes Api\Categories)
57 66
         */
58 67
         function wizard_step50(&$content, &$sel_options, &$readonlys, &$preserv)
59
-	{
60
-		if($this->debug) error_log(get_class($this) . '::wizard_step50->$content '.print_r($content,true));
68
+        {
69
+		if($this->debug)
70
+		{
71
+			error_log(get_class($this) . '::wizard_step50->$content '.print_r($content,true));
72
+		}
61 73
 		// return from step50
62 74
 		if ($content['step'] == 'wizard_step50')
63 75
 		{
64
-			if($content['explode_multiselects']) {
76
+			if($content['explode_multiselects'])
77
+			{
65 78
 				$explodes = $content['explode_multiselects'];
66 79
 				$content['explode_multiselects'] = array();
67
-				foreach($explodes as $row => $settings) {
68
-					if($settings['explode'] != addressbook_export_contacts_csv::NO_EXPLODE) {
80
+				foreach($explodes as $row => $settings)
81
+				{
82
+					if($settings['explode'] != addressbook_export_contacts_csv::NO_EXPLODE)
83
+					{
69 84
 						$content['explode_multiselects'][$settings['field']] = $settings;
70 85
 					}
71 86
 				}
@@ -93,7 +108,8 @@  discard block
 block discarded – undo
93 108
 			$settings = $content['explode_multiselects'] ? $content['explode_multiselects'] : $content['plugin_options']['explode_multiselects'];
94 109
 
95 110
 			// Skip this step if no fields applicable
96
-			if(count($field_list) == 0) {
111
+			if(count($field_list) == 0)
112
+			{
97 113
 				$content['explode_multiselects'] = array();
98 114
 			}
99 115
 
@@ -108,15 +124,19 @@  discard block
 block discarded – undo
108 124
 			);
109 125
 
110 126
 			$row = 1;
111
-			foreach($field_list as $field => $name) {
127
+			foreach($field_list as $field => $name)
128
+			{
112 129
 				$content['explode_multiselects'][$row] = array(
113 130
 					'field' =>      $field,
114 131
 					'name'  =>      $name,
115 132
 					'explode'=>	$settings[$field]
116 133
 				);
117
-				if($field == 'cat_id') {
134
+				if($field == 'cat_id')
135
+				{
118 136
 					$sel_options['explode_multiselects'][$row]['explode'] = $cat_options;
119
-				} else {
137
+				}
138
+				else
139
+				{
120 140
 					$sel_options['explode_multiselects'][$row]['explode'] = $multi_options;
121 141
 				}
122 142
 				$row++;
@@ -132,18 +152,22 @@  discard block
 block discarded – undo
132 152
 	/**
133 153
 	* Get a list of multi-select fields
134 154
 	*/
135
-	protected function get_field_list($content) {
155
+	protected function get_field_list($content)
156
+	{
136 157
 		$field_list = array();
137 158
 
138 159
 		// Category gets special handling
139
-		if(in_array('cat_id', array_keys($content['mapping']))) {
160
+		if(in_array('cat_id', array_keys($content['mapping'])))
161
+		{
140 162
 			$field_list['cat_id'] = $this->export_fields['cat_id'];
141 163
 		}
142 164
 
143 165
 		// Add any multi-select custom fields
144 166
 		$custom = Api\Storage\Customfields::get('addressbook');
145
-		foreach($custom as $name => $c_field) {
146
-			if($c_field['type'] == 'select' && $c_field['rows'] > 1 && in_array('#'.$name, array_keys($content['mapping']))) {
167
+		foreach($custom as $name => $c_field)
168
+		{
169
+			if($c_field['type'] == 'select' && $c_field['rows'] > 1 && in_array('#'.$name, array_keys($content['mapping'])))
170
+			{
147 171
 				$field_list['#'.$name] = $c_field['label'];
148 172
 			}
149 173
 		}
Please login to merge, or discard this patch.
addressbook/index.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,4 +25,4 @@
 block discarded – undo
25 25
 	unset($old_state['advanced_search']);
26 26
 	Api\Cache::setSession('addressbook', 'index', $old_state);
27 27
 }
28
-Api\Egw::redirect_link('/index.php','menuaction=addressbook.addressbook_ui.index');
28
+Api\Egw::redirect_link('/index.php', 'menuaction=addressbook.addressbook_ui.index');
Please login to merge, or discard this patch.