Completed
Push — master ( aa44e9...fa84e5 )
by Ralf
90:14 queued 73:21
created
addressbook/inc/class.addressbook_contactform.inc.php 3 patches
Doc Comments   +11 added lines, -15 removed lines patch added patch discarded remove patch
@@ -30,14 +30,12 @@  discard block
 block discarded – undo
30 30
 	/**
31 31
 	 * Shows the contactform and stores the submitted data
32 32
 	 *
33
-	 * @param array $content=null submitted eTemplate content
34
-	 * @param int $addressbook=null int owner-id of addressbook to save contacts too
35
-	 * @param array $fields=null field-names to show
36
-	 * @param string $msg=null message to show after submitting the form
37
-	 * @param string $email=null comma-separated email addresses
38
-	 * @param string $tpl_name=null custom etemplate to use
39
-	 * @param string $subject=null subject for email
40
-	 * @param string $copytoreceiver=false send a copy of notification to receiver
33
+	 * @param array $content submitted eTemplate content
34
+	 * @param int $addressbook int owner-id of addressbook to save contacts too
35
+	 * @param array $fields field-names to show
36
+	 * @param string $tpl_name custom etemplate to use
37
+	 * @param string $subject subject for email
38
+	 * @param string $copytoreceiver send a copy of notification to receiver
41 39
 	 * @return string html content
42 40
 	 */
43 41
 	function display(array $content=null,$addressbook=null,$fields=null,$msg=null,$email=null,$tpl_name=null,$subject=null,$copytoreceiver=false,$sel_options=array())
@@ -49,13 +47,11 @@  discard block
 block discarded – undo
49 47
 	 * Shows the contactform and stores the submitted data ($content is a var parameter, eg. for extending classes)
50 48
 	 *
51 49
 	 * @param array &$content=null submitted eTemplate content
52
-	 * @param int $addressbook=null int owner-id of addressbook to save contacts too
53
-	 * @param array $fields=null field-names to show
54
-	 * @param string $msg=null message to show after submitting the form
55
-	 * @param string $email=null comma-separated email addresses
56
-	 * @param string $tpl_name=null custom etemplate to use
57
-	 * @param string $subject=null subject for email
58
-	 * @param string $copytoreceiver=false send a copy of notification to receiver
50
+	 * @param int $addressbook int owner-id of addressbook to save contacts too
51
+	 * @param array $fields field-names to show
52
+	 * @param string $tpl_name custom etemplate to use
53
+	 * @param string $subject subject for email
54
+	 * @param string $copytoreceiver send a copy of notification to receiver
59 55
 	 * @return string html content
60 56
 	 */
61 57
 	function display_var(array &$content=null,$addressbook=null,$fields=null,$msg=null,$email=null,$tpl_name=null,$subject=null,$copytoreceiver=false,$sel_options=array())
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -40,9 +40,9 @@  discard block
 block discarded – undo
40 40
 	 * @param string $copytoreceiver=false send a copy of notification to receiver
41 41
 	 * @return string html content
42 42
 	 */
43
-	function display(array $content=null,$addressbook=null,$fields=null,$msg=null,$email=null,$tpl_name=null,$subject=null,$copytoreceiver=false,$sel_options=array())
43
+	function display(array $content = null, $addressbook = null, $fields = null, $msg = null, $email = null, $tpl_name = null, $subject = null, $copytoreceiver = false, $sel_options = array())
44 44
 	{
45
-		return $this->display_var($content,$addressbook,$fields,$msg,$email,$tpl_name,$subject,$copytoreceiver,$sel_options);
45
+		return $this->display_var($content, $addressbook, $fields, $msg, $email, $tpl_name, $subject, $copytoreceiver, $sel_options);
46 46
 	}
47 47
 
48 48
 	/**
@@ -58,23 +58,23 @@  discard block
 block discarded – undo
58 58
 	 * @param string $copytoreceiver=false send a copy of notification to receiver
59 59
 	 * @return string html content
60 60
 	 */
61
-	function display_var(array &$content=null,$addressbook=null,$fields=null,$msg=null,$email=null,$tpl_name=null,$subject=null,$copytoreceiver=false,$sel_options=array())
61
+	function display_var(array &$content = null, $addressbook = null, $fields = null, $msg = null, $email = null, $tpl_name = null, $subject = null, $copytoreceiver = false, $sel_options = array())
62 62
 	{
63 63
 		#error_log( "<p>addressbook_contactform::display(".print_r($content,true).",$addressbook,".print_r($fields,true).",$msg,$tpl_name)</p>\n");
64
-		if (empty($tpl_name) && !empty($content['tpl_form_name'])) $tpl_name =$content['tpl_form_name'];
64
+		if (empty($tpl_name) && !empty($content['tpl_form_name'])) $tpl_name = $content['tpl_form_name'];
65 65
 		$tpl = new etemplate($tpl_name ? $tpl_name : 'addressbook.contactform');
66 66
 		// initializing some fields
67
-		if (!$fields) $fields = array('org_name','n_fn','email','tel_work','url','note','captcha');
67
+		if (!$fields) $fields = array('org_name', 'n_fn', 'email', 'tel_work', 'url', 'note', 'captcha');
68 68
 		$submitted = false;
69 69
 		// check if submitted
70 70
 		if (is_array($content))
71 71
 		{
72
-			if ((isset($content['captcha_result']) && $content['captcha'] != $content['captcha_result']) ||	// no correct captcha OR
73
-				(time() - $content['start_time'] < 10 &&				// bot indicator (less then 10 sec to fill out the form and
72
+			if ((isset($content['captcha_result']) && $content['captcha'] != $content['captcha_result']) || // no correct captcha OR
73
+				(time() - $content['start_time'] < 10 && // bot indicator (less then 10 sec to fill out the form and
74 74
 				!$GLOBALS['egw_info']['etemplate']['java_script']))	// javascript disabled)
75 75
 			{
76 76
 				$submitted = "truebutfalse";
77
-				$tpl->set_validation_error('captcha',lang('Wrong - try again ...'));
77
+				$tpl->set_validation_error('captcha', lang('Wrong - try again ...'));
78 78
 			}
79 79
 			elseif ($content['submitit'])
80 80
 			{
@@ -82,11 +82,11 @@  discard block
 block discarded – undo
82 82
 				$contact = new Api\Contacts();
83 83
 				if ($content['owner'])	// save the contact in the addressbook
84 84
 				{
85
-					$content['private'] = 0;	// in case default_private is set
85
+					$content['private'] = 0; // in case default_private is set
86 86
 					if (($id = $contact->save($content)))
87 87
 					{
88 88
 						// check for fileuploads and attach the found files
89
-						foreach($content as $name => $value)
89
+						foreach ($content as $name => $value)
90 90
 						{
91 91
 							if (is_array($value) && isset($value['tmp_name']) && is_readable($value['tmp_name']))
92 92
 							{
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 								// edit rights for the addressbook used to store the new entry,
96 96
 								// which is clearly not wanted securitywise
97 97
 								Vfs::$is_root = true;
98
-								Link::link('addressbook',$id,Link::VFS_APPNAME,$value,$name);
98
+								Link::link('addressbook', $id, Link::VFS_APPNAME, $value, $name);
99 99
 								Vfs::$is_root = false;
100 100
 							}
101 101
 						}
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 					{
115 115
 						$tracking = new Api\Contacts\Tracking($contact);
116 116
 					}
117
-					if ($tracking->do_notifications($contact->data2db($content),null))
117
+					if ($tracking->do_notifications($contact->data2db($content), null))
118 118
 					{
119 119
 						return '<p align="center">'.$content['msg'].'</p>';
120 120
 					}
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 			$preserv['email_copytoreceiver'] = $copytoreceiver;
138 138
 			#if (!$fields) $fields = array('org_name','n_fn','email','tel_work','url','note','captcha');
139 139
 			$custom = 1;
140
-			foreach($fields as $name)
140
+			foreach ($fields as $name)
141 141
 			{
142 142
 				if ($name[0] == '#')	// custom field
143 143
 				{
@@ -148,10 +148,10 @@  discard block
 block discarded – undo
148 148
 					}
149 149
 					$content['show']['custom'.$custom] = true;
150 150
 					$content['customfield'][$custom] = $name;
151
-					$content['customlabel'][$custom] = $contact->customfields[substr($name,1)]['label'];
151
+					$content['customlabel'][$custom] = $contact->customfields[substr($name, 1)]['label'];
152 152
 					++$custom;
153 153
 				}
154
-				elseif($name == 'adr_one_locality')
154
+				elseif ($name == 'adr_one_locality')
155 155
 				{
156 156
 					if (!($content['show'][$name] = $GLOBALS['egw_info']['user']['preferences']['addressbook']['addr_format']))
157 157
 					{
@@ -172,18 +172,18 @@  discard block
 block discarded – undo
172 172
 			unset($content['submitit']);
173 173
 			$custom = 1;
174 174
 			// fieldnames are "defined" by the commit attempt, that way, we do not have to remember them
175
-			foreach($content as $name => $value) {
176
-				$preserv[$name]=$value;
175
+			foreach ($content as $name => $value) {
176
+				$preserv[$name] = $value;
177 177
 				if ($name[0] == '#')     // custom field
178 178
 				{
179 179
 					static $contact;
180 180
 					if (is_null($contact)) $contact = new Api\Contacts();
181 181
 					$content['show']['custom'.$custom] = true;
182 182
 					$content['customfield'][$custom] = $name;
183
-					$content['customlabel'][$custom] = $contact->customfields[substr($name,1)]['label'];
183
+					$content['customlabel'][$custom] = $contact->customfields[substr($name, 1)]['label'];
184 184
 					++$custom;
185 185
 				}
186
-				elseif($name == 'adr_one_locality')
186
+				elseif ($name == 'adr_one_locality')
187 187
 				{
188 188
 					if (!($content['show'][$name] = $GLOBALS['egw_info']['user']['preferences']['addressbook']['addr_format']))
189 189
 					{
@@ -204,17 +204,17 @@  discard block
 block discarded – undo
204 204
 		if ($msg) $preserv['msg'] = $msg;
205 205
 
206 206
 		// a simple calculation captcha
207
-		$num1 = rand(1,99);
208
-		$num2 = rand(1,99);
207
+		$num1 = rand(1, 99);
208
+		$num2 = rand(1, 99);
209 209
 		if ($num2 > $num1)	// keep the result positive
210 210
 		{
211 211
 			$n = $num1; $num1 = $num2; $num2 = $n;
212 212
 		}
213
-		if (in_array('captcha',$fields))
213
+		if (in_array('captcha', $fields))
214 214
 		{
215
-			$content['captcha_task'] = sprintf('%d - %d =',$num1,$num2);
216
-			$preserv['captcha_result'] = $num1-$num2;
215
+			$content['captcha_task'] = sprintf('%d - %d =', $num1, $num2);
216
+			$preserv['captcha_result'] = $num1 - $num2;
217 217
 		}
218
-		return $tpl->exec($this->callback,$content,$sel_options,array(),$preserv);
218
+		return $tpl->exec($this->callback, $content, $sel_options, array(), $preserv);
219 219
 	}
220 220
 }
Please login to merge, or discard this patch.
Braces   +46 added lines, -13 removed lines patch added patch discarded remove patch
@@ -61,28 +61,41 @@  discard block
 block discarded – undo
61 61
 	function display_var(array &$content=null,$addressbook=null,$fields=null,$msg=null,$email=null,$tpl_name=null,$subject=null,$copytoreceiver=false,$sel_options=array())
62 62
 	{
63 63
 		#error_log( "<p>addressbook_contactform::display(".print_r($content,true).",$addressbook,".print_r($fields,true).",$msg,$tpl_name)</p>\n");
64
-		if (empty($tpl_name) && !empty($content['tpl_form_name'])) $tpl_name =$content['tpl_form_name'];
64
+		if (empty($tpl_name) && !empty($content['tpl_form_name']))
65
+		{
66
+			$tpl_name =$content['tpl_form_name'];
67
+		}
65 68
 		$tpl = new etemplate($tpl_name ? $tpl_name : 'addressbook.contactform');
66 69
 		// initializing some fields
67
-		if (!$fields) $fields = array('org_name','n_fn','email','tel_work','url','note','captcha');
70
+		if (!$fields)
71
+		{
72
+			$fields = array('org_name','n_fn','email','tel_work','url','note','captcha');
73
+		}
68 74
 		$submitted = false;
69 75
 		// check if submitted
70 76
 		if (is_array($content))
71 77
 		{
72 78
 			if ((isset($content['captcha_result']) && $content['captcha'] != $content['captcha_result']) ||	// no correct captcha OR
73 79
 				(time() - $content['start_time'] < 10 &&				// bot indicator (less then 10 sec to fill out the form and
74
-				!$GLOBALS['egw_info']['etemplate']['java_script']))	// javascript disabled)
80
+				!$GLOBALS['egw_info']['etemplate']['java_script']))
81
+			{
82
+				// javascript disabled)
75 83
 			{
76 84
 				$submitted = "truebutfalse";
85
+			}
77 86
 				$tpl->set_validation_error('captcha',lang('Wrong - try again ...'));
78 87
 			}
79 88
 			elseif ($content['submitit'])
80 89
 			{
81 90
 				$submitted = true;
82 91
 				$contact = new Api\Contacts();
83
-				if ($content['owner'])	// save the contact in the addressbook
92
+				if ($content['owner'])
93
+				{
94
+					// save the contact in the addressbook
84 95
 				{
85
-					$content['private'] = 0;	// in case default_private is set
96
+					$content['private'] = 0;
97
+				}
98
+				// in case default_private is set
86 99
 					if (($id = $contact->save($content)))
87 100
 					{
88 101
 						// check for fileuploads and attach the found files
@@ -139,9 +152,12 @@  discard block
 block discarded – undo
139 152
 			$custom = 1;
140 153
 			foreach($fields as $name)
141 154
 			{
142
-				if ($name[0] == '#')	// custom field
155
+				if ($name[0] == '#')
156
+				{
157
+					// custom field
143 158
 				{
144 159
 					static $contact;
160
+				}
145 161
 					if (is_null($contact))
146 162
 					{
147 163
 						$contact = new Api\Contacts();
@@ -172,12 +188,19 @@  discard block
 block discarded – undo
172 188
 			unset($content['submitit']);
173 189
 			$custom = 1;
174 190
 			// fieldnames are "defined" by the commit attempt, that way, we do not have to remember them
175
-			foreach($content as $name => $value) {
191
+			foreach($content as $name => $value)
192
+			{
176 193
 				$preserv[$name]=$value;
177
-				if ($name[0] == '#')     // custom field
194
+				if ($name[0] == '#')
195
+				{
196
+					// custom field
178 197
 				{
179 198
 					static $contact;
180
-					if (is_null($contact)) $contact = new Api\Contacts();
199
+				}
200
+					if (is_null($contact))
201
+					{
202
+						$contact = new Api\Contacts();
203
+					}
181 204
 					$content['show']['custom'.$custom] = true;
182 205
 					$content['customfield'][$custom] = $name;
183 206
 					$content['customlabel'][$custom] = $contact->customfields[substr($name,1)]['label'];
@@ -200,15 +223,25 @@  discard block
 block discarded – undo
200 223
 		}
201 224
 		$content['addr_format'] = $GLOBALS['egw_info']['user']['preferences']['addressbook']['addr_format'];
202 225
 
203
-		if ($addressbook) $preserv['owner'] = $addressbook;
204
-		if ($msg) $preserv['msg'] = $msg;
226
+		if ($addressbook)
227
+		{
228
+			$preserv['owner'] = $addressbook;
229
+		}
230
+		if ($msg)
231
+		{
232
+			$preserv['msg'] = $msg;
233
+		}
205 234
 
206 235
 		// a simple calculation captcha
207 236
 		$num1 = rand(1,99);
208 237
 		$num2 = rand(1,99);
209
-		if ($num2 > $num1)	// keep the result positive
238
+		if ($num2 > $num1)
239
+		{
240
+			// keep the result positive
210 241
 		{
211
-			$n = $num1; $num1 = $num2; $num2 = $n;
242
+			$n = $num1;
243
+		}
244
+		$num1 = $num2; $num2 = $n;
212 245
 		}
213 246
 		if (in_array('captcha',$fields))
214 247
 		{
Please login to merge, or discard this patch.
addressbook/inc/class.addressbook_groupdav.inc.php 3 patches
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 	 * @param array &$files
107 107
 	 * @param int $user account_id
108 108
 	 * @param string $id =''
109
-	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
109
+	 * @return boolean boolean true on success, false on failure or string with http status (eg. '404 Not Found')
110 110
 	 */
111 111
 	function propfind($path,&$options,&$files,$user,$id='')
112 112
 	{
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 	 *
189 189
 	 * @param string $path
190 190
 	 * @param array& $filter
191
-	 * @param array|boolean $start =false false=return all or array(start,num)
191
+	 * @param integer[] $start =false false=return all or array(start,num)
192 192
 	 * @return array with "files" array with values for keys path and props
193 193
 	 */
194 194
 	function &propfind_callback($path,array &$filter,$start=false,$report_not_found_multiget_ids=true)
@@ -539,7 +539,7 @@  discard block
 block discarded – undo
539 539
 	 * @param array &$options
540 540
 	 * @param int $id
541 541
 	 * @param int $user =null account_id
542
-	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
542
+	 * @return string|boolean boolean true on success, false on failure or string with http status (eg. '404 Not Found')
543 543
 	 */
544 544
 	function get(&$options,$id,$user=null)
545 545
 	{
@@ -566,7 +566,7 @@  discard block
 block discarded – undo
566 566
 	 * @param int $id
567 567
 	 * @param int $user =null account_id of owner, default null
568 568
 	 * @param string $prefix =null user prefix from path (eg. /ralf from /ralf/addressbook)
569
-	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
569
+	 * @return string|boolean boolean true on success, false on failure or string with http status (eg. '404 Not Found')
570 570
 	 */
571 571
 	function put(&$options,$id,$user=null,$prefix=null)
572 572
 	{
@@ -1024,7 +1024,7 @@  discard block
 block discarded – undo
1024 1024
 	 *
1025 1025
 	 * @param int $acl Acl::READ, Acl::EDIT or Acl::DELETE
1026 1026
 	 * @param array|int $contact contact-array or id
1027
-	 * @return boolean null if entry does not exist, false if no access, true if access permitted
1027
+	 * @return null|boolean null if entry does not exist, false if no access, true if access permitted
1028 1028
 	 */
1029 1029
 	function check_access($acl,$contact)
1030 1030
 	{
Please login to merge, or discard this patch.
Spacing   +125 added lines, -126 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 		// LDAP does NOT have a carddav_name attribute --> stick with id mapped to LDAP attribute uid
77 77
 		if (version_compare($GLOBALS['egw_info']['apps']['phpgwapi']['version'], '1.9.007', '<') ||
78 78
 			$this->bo->contact_repository != 'sql' ||
79
-			$this->bo->account_repository != 'sql' && strpos($_SERVER['REQUEST_URI'].'/','/addressbook-accounts/') !== false)
79
+			$this->bo->account_repository != 'sql' && strpos($_SERVER['REQUEST_URI'].'/', '/addressbook-accounts/') !== false)
80 80
 		{
81 81
 			self::$path_extension = '.vcf';
82 82
 		}
@@ -88,11 +88,11 @@  discard block
 block discarded – undo
88 88
 		if ($this->debug) error_log(__METHOD__."() contact_repository={$this->bo->contact_repository}, account_repository={$this->bo->account_repository}, REQUEST_URI=$_SERVER[REQUEST_URI] --> path_attr=".self::$path_attr.", path_extension=".self::$path_extension);
89 89
 
90 90
 		$this->home_set_pref = $GLOBALS['egw_info']['user']['preferences']['groupdav']['addressbook-home-set'];
91
-		$this->home_set_pref = $this->home_set_pref ? explode(',',$this->home_set_pref) : array();
91
+		$this->home_set_pref = $this->home_set_pref ? explode(',', $this->home_set_pref) : array();
92 92
 
93 93
 		// silently switch "Sync all into one" preference on for OS X addressbook, as it only supports one AB
94 94
 		// this restores behavior before Lion (10.7), where AB synced all ABs contained in addressbook-home-set
95
-		if (substr(self::get_agent(),0,9) == 'cfnetwork' && !in_array('O',$this->home_set_pref))
95
+		if (substr(self::get_agent(), 0, 9) == 'cfnetwork' && !in_array('O', $this->home_set_pref))
96 96
 		{
97 97
 			$this->home_set_pref[] = 'O';
98 98
 		}
@@ -108,13 +108,13 @@  discard block
 block discarded – undo
108 108
 	 * @param string $id =''
109 109
 	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
110 110
 	 */
111
-	function propfind($path,&$options,&$files,$user,$id='')
111
+	function propfind($path, &$options, &$files, $user, $id = '')
112 112
 	{
113 113
 		$filter = array();
114 114
 		// If "Sync selected addressbooks into one" is set
115
-		if ($user && $user == $GLOBALS['egw_info']['user']['account_id'] && in_array('O',$this->home_set_pref))
115
+		if ($user && $user == $GLOBALS['egw_info']['user']['account_id'] && in_array('O', $this->home_set_pref))
116 116
 		{
117
-			$filter['owner'] = array_keys($this->get_shared(true));	// true: ignore all-in-one pref
117
+			$filter['owner'] = array_keys($this->get_shared(true)); // true: ignore all-in-one pref
118 118
 			$filter['owner'][] = $user;
119 119
 		}
120 120
 		// show addressbook of a single user?
@@ -127,11 +127,11 @@  discard block
 block discarded – undo
127 127
 
128 128
 		// process REPORT filters or multiget href's
129 129
 		$nresults = null;
130
-		if (($id || $options['root']['name'] != 'propfind') && !$this->_report_filters($options,$filter,$id, $nresults))
130
+		if (($id || $options['root']['name'] != 'propfind') && !$this->_report_filters($options, $filter, $id, $nresults))
131 131
 		{
132 132
 			return false;
133 133
 		}
134
-		if ($id) $path = dirname($path).'/';	// carddav_name get's added anyway in the callback
134
+		if ($id) $path = dirname($path).'/'; // carddav_name get's added anyway in the callback
135 135
 
136 136
 		if ($this->debug) error_log(__METHOD__."($path,".array2string($options).",,$user,$id) filter=".array2string($filter));
137 137
 
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 		if (!($filter['address_data'] = $options['props'] == 'all' &&
140 140
 			$options['root']['ns'] == Api\CalDAV::CARDDAV) && is_array($options['props']))
141 141
 		{
142
-			foreach($options['props'] as $prop)
142
+			foreach ($options['props'] as $prop)
143 143
 			{
144 144
 				if ($prop['name'] == 'address-data')
145 145
 				{
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 
159 159
 			$this->sync_collection_token = null;
160 160
 
161
-			$filter['order'] = 'contact_modified ASC';	// return oldest modifications first
161
+			$filter['order'] = 'contact_modified ASC'; // return oldest modifications first
162 162
 			$filter['sync-collection'] = true;
163 163
 		}
164 164
 
@@ -172,13 +172,13 @@  discard block
 block discarded – undo
172 172
 			if ($options['root']['name'] == 'sync-collection' && $this->bo->total > $nresults)
173 173
 			{
174 174
 				--$this->sync_collection_token;
175
-				$files['sync-token-params'][] = true;	// tel get_sync_collection_token that we have more entries
175
+				$files['sync-token-params'][] = true; // tel get_sync_collection_token that we have more entries
176 176
 			}
177 177
 		}
178 178
 		else
179 179
 		{
180 180
 			// return iterator, calling ourself to return result in chunks
181
-			$files['files'] = new Api\CalDAV\PropfindIterator($this,$path,$filter,$files['files']);
181
+			$files['files'] = new Api\CalDAV\PropfindIterator($this, $path, $filter, $files['files']);
182 182
 		}
183 183
 		return true;
184 184
 	}
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 	 * @param array|boolean $start =false false=return all or array(start,num)
192 192
 	 * @return array with "files" array with values for keys path and props
193 193
 	 */
194
-	function &propfind_callback($path,array &$filter,$start=false,$report_not_found_multiget_ids=true)
194
+	function &propfind_callback($path, array &$filter, $start = false, $report_not_found_multiget_ids = true)
195 195
 	{
196 196
 		//error_log(__METHOD__."('$path', ".array2string($filter).", ".array2string($start).", $report_not_found_multiget_ids)");
197 197
 		$starttime = microtime(true);
@@ -219,18 +219,18 @@  discard block
 block discarded – undo
219 219
 		if (isset($filter[self::$path_attr]))
220 220
 		{
221 221
 			if (!is_array($filter[self::$path_attr])) $filter[self::$path_attr] = (array)$filter[self::$path_attr];
222
-			$requested_multiget_ids =& $filter[self::$path_attr];
222
+			$requested_multiget_ids = & $filter[self::$path_attr];
223 223
 		}
224 224
 
225 225
 		$files = array();
226 226
 		// we query etag and modified, as LDAP does not have the strong sql etag
227
-		$cols = array('id','uid','etag','modified','n_fn');
228
-		if (!in_array(self::$path_attr,$cols)) $cols[] = self::$path_attr;
227
+		$cols = array('id', 'uid', 'etag', 'modified', 'n_fn');
228
+		if (!in_array(self::$path_attr, $cols)) $cols[] = self::$path_attr;
229 229
 		// we need tid for sync-collection report
230 230
 		if (array_key_exists('tid', $filter) && !isset($filter['tid']) && !in_array('tid', $cols)) $cols[] = 'tid';
231
-		if (($contacts =& $this->bo->search(array(),$cols,$order,'','',False,'AND',$start,$filter)))
231
+		if (($contacts = & $this->bo->search(array(), $cols, $order, '', '', False, 'AND', $start, $filter)))
232 232
 		{
233
-			foreach($contacts as &$contact)
233
+			foreach ($contacts as &$contact)
234 234
 			{
235 235
 				// remove contact from requested multiget ids, to be able to report not found urls
236 236
 				if ($requested_multiget_ids && ($k = array_search($contact[self::$path_attr], $requested_multiget_ids)) !== false)
@@ -250,9 +250,9 @@  discard block
 block discarded – undo
250 250
 				);
251 251
 				if ($address_data)
252 252
 				{
253
-					$content = $handler->getVCard($contact['id'],$this->charset,false);
253
+					$content = $handler->getVCard($contact['id'], $this->charset, false);
254 254
 					$props['getcontentlength'] = bytes($content);
255
-					$props[] = Api\CalDAV::mkprop(Api\CalDAV::CARDDAV,'address-data',$content,true);
255
+					$props[] = Api\CalDAV::mkprop(Api\CalDAV::CARDDAV, 'address-data', $content, true);
256 256
 				}
257 257
 				$files[] = $this->add_resource($path, $contact, $props);
258 258
 			}
@@ -283,10 +283,10 @@  discard block
 block discarded – undo
283 283
 				}
284 284
 			}
285 285
 			// add groups after contacts, but only if enabled and NOT for '/addressbook/' (!isset($filter['owner'])
286
-			if (in_array('D',$this->home_set_pref) && (string)$filter['owner'] !== '0')
286
+			if (in_array('D', $this->home_set_pref) && (string)$filter['owner'] !== '0')
287 287
 			{
288 288
 				$where = array(
289
-					'list_owner' => isset($filter['owner'])?$filter['owner']:array_keys($this->bo->grants)
289
+					'list_owner' => isset($filter['owner']) ? $filter['owner'] : array_keys($this->bo->grants)
290 290
 				);
291 291
 				// add sync-token to support sync-collection report
292 292
 				if ($sync_collection_report)
@@ -299,20 +299,20 @@  discard block
 block discarded – undo
299 299
 					$where['list_'.self::$path_attr] = $filter[self::$path_attr];
300 300
 				}
301 301
 				//error_log(__METHOD__."() filter=".array2string($filter).", do_groups=".in_array('D',$this->home_set_pref).", where=".array2string($where));
302
-				if (($lists = $this->bo->read_lists($where,'contact_uid',$where['list_owner'])))	// limit to contacts in same AB!
302
+				if (($lists = $this->bo->read_lists($where, 'contact_uid', $where['list_owner'])))	// limit to contacts in same AB!
303 303
 				{
304
-					foreach($lists as $list)
304
+					foreach ($lists as $list)
305 305
 					{
306 306
 						$list[self::$path_attr] = $list['list_carddav_name'];
307 307
 						$etag = $list['list_id'].':'.$list['list_etag'];
308 308
 						// for all-in-one addressbook, add selected ABs to etag
309 309
 						if (isset($filter['owner']) && is_array($filter['owner']))
310 310
 						{
311
-							$etag .= ':'.implode('-',$filter['owner']);
311
+							$etag .= ':'.implode('-', $filter['owner']);
312 312
 						}
313 313
 						$props = array(
314 314
 							'getcontenttype' => Api\CalDAV::mkprop('getcontenttype', 'text/vcard'),
315
-							'getlastmodified' => Api\DateTime::to($list['list_modified'],'ts'),
315
+							'getlastmodified' => Api\DateTime::to($list['list_modified'], 'ts'),
316 316
 							'displayname' => $list['list_name'],
317 317
 							'getetag' => '"'.$etag.'"',
318 318
 						);
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
 						{
321 321
 							$content = $handler->getGroupVCard($list);
322 322
 							$props['getcontentlength'] = bytes($content);
323
-							$props[] = Api\CalDAV::mkprop(Api\CalDAV::CARDDAV,'address-data',$content,true);
323
+							$props[] = Api\CalDAV::mkprop(Api\CalDAV::CARDDAV, 'address-data', $content, true);
324 324
 						}
325 325
 						$files[] = $this->add_resource($path, $list, $props);
326 326
 
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 							unset($requested_multiget_ids[$k]);
331 331
 						}
332 332
 
333
-						if ($sync_collection_report && $this->sync_collection_token < ($ts=$GLOBALS['egw']->db->from_timestamp($list['list_modified'])))
333
+						if ($sync_collection_report && $this->sync_collection_token < ($ts = $GLOBALS['egw']->db->from_timestamp($list['list_modified'])))
334 334
 						{
335 335
 							$this->sync_collection_token = $ts;
336 336
 						}
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
 			// report not found multiget urls
341 341
 			if ($report_not_found_multiget_ids && $requested_multiget_ids)
342 342
 			{
343
-				foreach($requested_multiget_ids as $id)
343
+				foreach ($requested_multiget_ids as $id)
344 344
 				{
345 345
 					$files[] = array('path' => $path.$id.self::$path_extension);
346 346
 				}
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
 	 * @param int &$nresult on return limit for number or results or unchanged/null
361 361
 	 * @return boolean true if filter could be processed
362 362
 	 */
363
-	function _report_filters($options,&$filters,$id, &$nresults)
363
+	function _report_filters($options, &$filters, $id, &$nresults)
364 364
 	{
365 365
 		if ($options['filters'])
366 366
 		{
@@ -385,17 +385,17 @@  discard block
 block discarded – undo
385 385
 			$prop_filters = array();
386 386
 
387 387
 			$matches = $prop_test = $column = null;
388
-			foreach($options['filters'] as $n => $filter)
388
+			foreach ($options['filters'] as $n => $filter)
389 389
 			{
390
-				if (!is_int($n)) continue;	// eg. attributes of filter xml element
390
+				if (!is_int($n)) continue; // eg. attributes of filter xml element
391 391
 
392
-				switch((string)$filter['name'])
392
+				switch ((string)$filter['name'])
393 393
 				{
394 394
 					case 'param-filter':
395 395
 						$this->caldav->log(__METHOD__."(...) param-filter='{$filter['attrs']['name']}' not (yet) implemented!");
396 396
 						break;
397 397
 					case 'prop-filter':	// can be multiple prop-filter, see example
398
-						if ($matches) $prop_filters[] = implode($prop_test=='allof'?' AND ':' OR ',$matches);
398
+						if ($matches) $prop_filters[] = implode($prop_test == 'allof' ? ' AND ' : ' OR ', $matches);
399 399
 						$matches = array();
400 400
 						$prop_filter = strtoupper($filter['attrs']['name']);
401 401
 						$prop_test = isset($filter['attrs']['test']) ? $filter['attrs']['test'] : 'anyof';
@@ -408,11 +408,11 @@  discard block
 block discarded – undo
408 408
 						if (!isset($this->filter_prop2cal[$prop_filter]))	// eg. not existing NICKNAME in EGroupware
409 409
 						{
410 410
 							if ($this->debug || $prop_filter != 'NICKNAME') error_log(__METHOD__."(...) text-match: $prop_filter {$filter['attrs']['match-type']} '{$filter['data']}' unknown property '$prop_filter' --> ignored");
411
-							$column = false;	// to ignore following data too
411
+							$column = false; // to ignore following data too
412 412
 						}
413 413
 						else
414 414
 						{
415
-							switch($filter['attrs']['collation'])	// todo: which other collations allowed, we are allways unicode
415
+							switch ($filter['attrs']['collation'])	// todo: which other collations allowed, we are allways unicode
416 416
 							{
417 417
 								case 'i;unicode-casemap':
418 418
 								default:
@@ -432,20 +432,20 @@  discard block
 block discarded – undo
432 432
 							if ($column)	// false for properties not known to EGroupware
433 433
 							{
434 434
 								$value = str_replace(array('%', '_'), array('\\%', '\\_'), $filter['data']);
435
-								switch($match_type)
435
+								switch ($match_type)
436 436
 								{
437 437
 									case 'equals':
438
-										$sql_filter = $column . $comp . $GLOBALS['egw']->db->quote($value);
438
+										$sql_filter = $column.$comp.$GLOBALS['egw']->db->quote($value);
439 439
 										break;
440 440
 									default:
441 441
 									case 'contains':
442
-										$sql_filter = $column . $comp . $GLOBALS['egw']->db->quote('%'.$value.'%');
442
+										$sql_filter = $column.$comp.$GLOBALS['egw']->db->quote('%'.$value.'%');
443 443
 										break;
444 444
 									case 'starts-with':
445
-										$sql_filter = $column . $comp . $GLOBALS['egw']->db->quote($value.'%');
445
+										$sql_filter = $column.$comp.$GLOBALS['egw']->db->quote($value.'%');
446 446
 										break;
447 447
 									case 'ends-with':
448
-										$sql_filter = $column . $comp . $GLOBALS['egw']->db->quote('%'.$value);
448
+										$sql_filter = $column.$comp.$GLOBALS['egw']->db->quote('%'.$value);
449 449
 										break;
450 450
 								}
451 451
 								$matches[] = ($negate_condition ? 'NOT ' : '').$sql_filter;
@@ -461,10 +461,10 @@  discard block
 block discarded – undo
461 461
 						break;
462 462
 				}
463 463
 			}
464
-			if ($matches) $prop_filters[] = implode($prop_test=='allof'?' AND ':' OR ',$matches);
464
+			if ($matches) $prop_filters[] = implode($prop_test == 'allof' ? ' AND ' : ' OR ', $matches);
465 465
 			if ($prop_filters)
466 466
 			{
467
-				$filters[] = $filter = '(('.implode($filter_test=='allof'?') AND (':') OR (', $prop_filters).'))';
467
+				$filters[] = $filter = '(('.implode($filter_test == 'allof' ? ') AND (' : ') OR (', $prop_filters).'))';
468 468
 				if ($this->debug) error_log(__METHOD__."(path=$options[path], ...) sql-filter: $filter");
469 469
 			}
470 470
 		}
@@ -474,9 +474,9 @@  discard block
 block discarded – undo
474 474
 		    <B:nresults>10</B:nresults>
475 475
 		  </B:limit>
476 476
 		*/
477
-		foreach((array)$options['other'] as $option)
477
+		foreach ((array)$options['other'] as $option)
478 478
 		{
479
-			switch($option['name'])
479
+			switch ($option['name'])
480 480
 			{
481 481
 				case 'nresults':
482 482
 					$nresults = (int)$option['data'];
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
 				case 'limit':
486 486
 					break;
487 487
 				case 'href':
488
-					break;	// from addressbook-multiget, handled below
488
+					break; // from addressbook-multiget, handled below
489 489
 				// rfc 6578 sync-report
490 490
 				case 'sync-token':
491 491
 					if (!empty($option['data']))
@@ -493,7 +493,7 @@  discard block
 block discarded – undo
493 493
 						$parts = explode('/', $option['data']);
494 494
 						$sync_token = array_pop($parts);
495 495
 						$filters[] = 'contact_modified>'.(int)$sync_token;
496
-						$filters['tid'] = null;	// to return deleted entries too
496
+						$filters['tid'] = null; // to return deleted entries too
497 497
 					}
498 498
 					break;
499 499
 				case 'sync-level':
@@ -511,23 +511,23 @@  discard block
 block discarded – undo
511 511
 		if ($options['root']['name'] == 'addressbook-multiget')
512 512
 		{
513 513
 			$ids = array();
514
-			foreach($options['other'] as $option)
514
+			foreach ($options['other'] as $option)
515 515
 			{
516 516
 				if ($option['name'] == 'href')
517 517
 				{
518
-					$parts = explode('/',$option['data']);
518
+					$parts = explode('/', $option['data']);
519 519
 					if (($id = urldecode(array_pop($parts))))
520 520
 					{
521
-						$ids[] = self::$path_extension ? basename($id,self::$path_extension) : $id;
521
+						$ids[] = self::$path_extension ? basename($id, self::$path_extension) : $id;
522 522
 					}
523 523
 				}
524 524
 			}
525 525
 			if ($ids) $filters[self::$path_attr] = $ids;
526
-			if ($this->debug) error_log(__METHOD__."(...) addressbook-multiget: ids=".implode(',',$ids));
526
+			if ($this->debug) error_log(__METHOD__."(...) addressbook-multiget: ids=".implode(',', $ids));
527 527
 		}
528 528
 		elseif ($id)
529 529
 		{
530
-			$filters[self::$path_attr] = self::$path_extension ? basename($id,self::$path_extension) : $id;
530
+			$filters[self::$path_attr] = self::$path_extension ? basename($id, self::$path_extension) : $id;
531 531
 		}
532 532
 		//error_log(__METHOD__."() options[other]=".array2string($options['other'])." --> filters=".array2string($filters));
533 533
 		return true;
@@ -541,17 +541,16 @@  discard block
 block discarded – undo
541 541
 	 * @param int $user =null account_id
542 542
 	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
543 543
 	 */
544
-	function get(&$options,$id,$user=null)
544
+	function get(&$options, $id, $user = null)
545 545
 	{
546
-		unset($user);	// not used, but required by function signature
546
+		unset($user); // not used, but required by function signature
547 547
 
548
-		if (!is_array($contact = $this->_common_get_put_delete('GET',$options,$id)))
548
+		if (!is_array($contact = $this->_common_get_put_delete('GET', $options, $id)))
549 549
 		{
550 550
 			return $contact;
551 551
 		}
552 552
 		$handler = self::_get_handler();
553
-		$options['data'] = $contact['list_id'] ? $handler->getGroupVCard($contact) :
554
-			$handler->getVCard($contact['id'],$this->charset,false);
553
+		$options['data'] = $contact['list_id'] ? $handler->getGroupVCard($contact) : $handler->getVCard($contact['id'], $this->charset, false);
555 554
 		// e.g. Evolution does not understand 'text/vcard'
556 555
 		$options['mimetype'] = 'text/x-vcard; charset='.$this->charset;
557 556
 		header('Content-Encoding: identity');
@@ -568,11 +567,11 @@  discard block
 block discarded – undo
568 567
 	 * @param string $prefix =null user prefix from path (eg. /ralf from /ralf/addressbook)
569 568
 	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
570 569
 	 */
571
-	function put(&$options,$id,$user=null,$prefix=null)
570
+	function put(&$options, $id, $user = null, $prefix = null)
572 571
 	{
573 572
 		if ($this->debug) error_log(__METHOD__.'('.array2string($options).",$id,$user)");
574 573
 
575
-		$oldContact = $this->_common_get_put_delete('PUT',$options,$id);
574
+		$oldContact = $this->_common_get_put_delete('PUT', $options, $id);
576 575
 		if (!is_null($oldContact) && !is_array($oldContact))
577 576
 		{
578 577
 			if ($this->debug) error_log(__METHOD__."(,'$id', $user, '$prefix') returning ".array2string($oldContact));
@@ -597,7 +596,7 @@  discard block
 block discarded – undo
597 596
 					switch (strtolower($key))
598 597
 					{
599 598
 						case 'charset':
600
-							$charset = strtoupper(substr($value,1,-1));
599
+							$charset = strtoupper(substr($value, 1, -1));
601 600
 					}
602 601
 				}
603 602
 			}
@@ -624,7 +623,7 @@  discard block
 block discarded – undo
624 623
 
625 624
 		if (!$is_group && is_array($contact['cat_id']))
626 625
 		{
627
-			$contact['cat_id'] = implode(',',$this->bo->find_or_add_categories($contact['cat_id'], $contactId));
626
+			$contact['cat_id'] = implode(',', $this->bo->find_or_add_categories($contact['cat_id'], $contactId));
628 627
 		}
629 628
 		elseif ($contactId > 0)
630 629
 		{
@@ -648,12 +647,12 @@  discard block
 block discarded – undo
648 647
 			$contact['carddav_name'] = $id;
649 648
 
650 649
 			// only set owner, if user is explicitly specified in URL (check via prefix, NOT for /addressbook/) or sync-all-in-one!)
651
-			if ($prefix && !in_array('O',$this->home_set_pref) && $user)
650
+			if ($prefix && !in_array('O', $this->home_set_pref) && $user)
652 651
 			{
653 652
 				$contact['owner'] = $user;
654 653
 			}
655 654
 			// check if default addressbook is synced and not Api\Accounts, if not use (always synced) personal addressbook
656
-			elseif(!$this->bo->default_addressbook || !in_array($this->bo->default_addressbook,$this->home_set_pref))
655
+			elseif (!$this->bo->default_addressbook || !in_array($this->bo->default_addressbook, $this->home_set_pref))
657 656
 			{
658 657
 				$contact['owner'] = $GLOBALS['egw_info']['user']['account_id'];
659 658
 			}
@@ -664,7 +663,7 @@  discard block
 block discarded – undo
664 663
 			}
665 664
 			// check if user has add rights for addressbook
666 665
 			// done here again, as _common_get_put_delete knows nothing about default addressbooks...
667
-			if (!($this->bo->grants[$contact['owner']] & Acl::ADD))
666
+			if (!($this->bo->grants[$contact['owner']]&Acl::ADD))
668 667
 			{
669 668
 				if ($this->debug) error_log(__METHOD__."(,'$id', $user, '$prefix') returning '403 Forbidden'");
670 669
 				return '403 Forbidden';
@@ -681,7 +680,7 @@  discard block
 block discarded – undo
681 680
 				$this->check_return_representation($options, $id, $user);
682 681
 				return '412 Precondition Failed';
683 682
 			}
684
-			return '403 Forbidden';	// happens when writing new entries in AB's without ADD rights
683
+			return '403 Forbidden'; // happens when writing new entries in AB's without ADD rights
685 684
 		}
686 685
 
687 686
 		if (empty($contact['etag']) || empty($contact['cardav_name']))
@@ -714,16 +713,16 @@  discard block
 block discarded – undo
714 713
 	 * @param array|false $oldContact
715 714
 	 * @return int|boolean $list_id or false on error
716 715
 	 */
717
-	function save_group(array &$contact, $oldContact=null)
716
+	function save_group(array &$contact, $oldContact = null)
718 717
 	{
719 718
 		$data = array('list_name' => $contact['n_fn']);
720 719
 		if (!isset($contact['owner'])) $contact['owner'] = $GLOBALS['egw_info']['user']['account_id'];
721
-		foreach(array('id','carddav_name','uid','owner') as $name)
720
+		foreach (array('id', 'carddav_name', 'uid', 'owner') as $name)
722 721
 		{
723 722
 			$data['list_'.$name] = $contact[$name];
724 723
 		}
725 724
 		//error_log(__METHOD__.'('.array2string($contact).', '.array2string($oldContact).') data='.array2string($data));
726
-		if (($list_id=$this->bo->add_list(array('list_'.self::$path_attr => $contact[self::$path_attr]),
725
+		if (($list_id = $this->bo->add_list(array('list_'.self::$path_attr => $contact[self::$path_attr]),
727 726
 			$contact['owner'], null, $data)))
728 727
 		{
729 728
 			// update members given in $contact['##X-ADDRESSBOOKSERVER-MEMBER']
@@ -736,14 +735,14 @@  discard block
 block discarded – undo
736 735
 			{
737 736
 				$new_members = array($new_members);
738 737
 			}
739
-			foreach($new_members as &$uid)
738
+			foreach ($new_members as &$uid)
740 739
 			{
741
-				$uid = substr($uid,9);	// cut off "urn:uuid:" prefix
740
+				$uid = substr($uid, 9); // cut off "urn:uuid:" prefix
742 741
 			}
743 742
 			if ($oldContact)
744 743
 			{
745
-				$to_add = array_diff($new_members,$oldContact['members']);
746
-				$to_delete = array_diff($oldContact['members'],$new_members);
744
+				$to_add = array_diff($new_members, $oldContact['members']);
745
+				$to_delete = array_diff($oldContact['members'], $new_members);
747 746
 			}
748 747
 			else
749 748
 			{
@@ -754,9 +753,9 @@  discard block
 block discarded – undo
754 753
 			{
755 754
 				$to_add_ids = $to_delete_ids = array();
756 755
 				$filter = array('uid' => $to_delete ? array_merge($to_add, $to_delete) : $to_add);
757
-				if (($contacts =& $this->bo->search(array(), array('id', 'uid'),'','','',False,'AND',false,$filter)))
756
+				if (($contacts = & $this->bo->search(array(), array('id', 'uid'), '', '', '', False, 'AND', false, $filter)))
758 757
 				{
759
-					foreach($contacts as $c)
758
+					foreach ($contacts as $c)
760 759
 					{
761 760
 						if ($to_delete && in_array($c['uid'], $to_delete))
762 761
 						{
@@ -786,9 +785,9 @@  discard block
 block discarded – undo
786 785
 	 * @param int $user
787 786
 	 * @return string
788 787
 	 */
789
-	public function getctag($path,$user)
788
+	public function getctag($path, $user)
790 789
 	{
791
-		static $ctags = array();	// a little per request caching, in case ctag and sync-token is both requested
790
+		static $ctags = array(); // a little per request caching, in case ctag and sync-token is both requested
792 791
 		if (isset($ctags[$path])) return $ctags[$path];
793 792
 
794 793
 		$user_in = $user;
@@ -796,9 +795,9 @@  discard block
 block discarded – undo
796 795
 		if (is_null($user) || $user === '' || $path == '/addressbook/') $user = null;
797 796
 
798 797
 		// If "Sync selected addressbooks into one" is set --> ctag need to take selected AB's into account too
799
-		if ($user && $user == $GLOBALS['egw_info']['user']['account_id'] && in_array('O',$this->home_set_pref))
798
+		if ($user && $user == $GLOBALS['egw_info']['user']['account_id'] && in_array('O', $this->home_set_pref))
800 799
 		{
801
-			$user = array_merge((array)$user,array_keys($this->get_shared(true)));	// true: ignore all-in-one pref
800
+			$user = array_merge((array)$user, array_keys($this->get_shared(true))); // true: ignore all-in-one pref
802 801
 
803 802
 			// include accounts ctag, if accounts stored different from contacts (eg.in LDAP or ADS)
804 803
 			if ($this->bo->so_accounts && in_array('0', $user))
@@ -809,7 +808,7 @@  discard block
 block discarded – undo
809 808
 		$ctag = $this->bo->get_ctag($user);
810 809
 
811 810
 		// include lists-ctag, if enabled
812
-		if (in_array('D',$this->home_set_pref))
811
+		if (in_array('D', $this->home_set_pref))
813 812
 		{
814 813
 			$lists_ctag = $this->bo->lists_ctag($user);
815 814
 		}
@@ -842,34 +841,34 @@  discard block
 block discarded – undo
842 841
 	 * @param int $user =null account_id of owner of collection
843 842
 	 * @return array
844 843
 	 */
845
-	public function extra_properties(array $props, $displayname, $base_uri=null, $user=null)
844
+	public function extra_properties(array $props, $displayname, $base_uri = null, $user = null)
846 845
 	{
847
-		unset($displayname, $base_uri, $user);	// not used, but required by function signature
846
+		unset($displayname, $base_uri, $user); // not used, but required by function signature
848 847
 
849 848
 		if (!isset($props['addressbook-description']))
850 849
 		{
851 850
 			// default addressbook description: can be overwritten via PROPPATCH, in which case it's already set
852
-			$props['addressbook-description'] = Api\CalDAV::mkprop(Api\CalDAV::CARDDAV,'addressbook-description',$props['displayname']);
851
+			$props['addressbook-description'] = Api\CalDAV::mkprop(Api\CalDAV::CARDDAV, 'addressbook-description', $props['displayname']);
853 852
 		}
854 853
 		// setting an max image size, so iOS scales the images before transmitting them
855 854
 		// we currently scale down to width of 240px, which tests shown to be ~20k
856
-		$props['max-image-size'] = Api\CalDAV::mkprop(Api\CalDAV::CARDDAV,'max-image-size',24*1024);
855
+		$props['max-image-size'] = Api\CalDAV::mkprop(Api\CalDAV::CARDDAV, 'max-image-size', 24 * 1024);
857 856
 
858 857
 		// supported reports (required property for CardDAV)
859 858
 		$props['supported-report-set'] = array(
860
-			'addressbook-query' => Api\CalDAV::mkprop('supported-report',array(
861
-				Api\CalDAV::mkprop('report',array(
862
-					Api\CalDAV::mkprop(Api\CalDAV::CARDDAV,'addressbook-query',''))))),
863
-			'addressbook-multiget' => Api\CalDAV::mkprop('supported-report',array(
864
-				Api\CalDAV::mkprop('report',array(
865
-					Api\CalDAV::mkprop(Api\CalDAV::CARDDAV,'addressbook-multiget',''))))),
859
+			'addressbook-query' => Api\CalDAV::mkprop('supported-report', array(
860
+				Api\CalDAV::mkprop('report', array(
861
+					Api\CalDAV::mkprop(Api\CalDAV::CARDDAV, 'addressbook-query', ''))))),
862
+			'addressbook-multiget' => Api\CalDAV::mkprop('supported-report', array(
863
+				Api\CalDAV::mkprop('report', array(
864
+					Api\CalDAV::mkprop(Api\CalDAV::CARDDAV, 'addressbook-multiget', ''))))),
866 865
 		);
867 866
 		// only advertice rfc 6578 sync-collection report, if "delete-prevention" is switched on (deleted entries get marked deleted but not actualy deleted
868 867
 		if ($GLOBALS['egw_info']['server']['history'])
869 868
 		{
870
-			$props['supported-report-set']['sync-collection'] = Api\CalDAV::mkprop('supported-report',array(
871
-				Api\CalDAV::mkprop('report',array(
872
-					Api\CalDAV::mkprop('sync-collection','')))));
869
+			$props['supported-report-set']['sync-collection'] = Api\CalDAV::mkprop('supported-report', array(
870
+				Api\CalDAV::mkprop('report', array(
871
+					Api\CalDAV::mkprop('sync-collection', '')))));
873 872
 		}
874 873
 		return $props;
875 874
 	}
@@ -881,7 +880,7 @@  discard block
 block discarded – undo
881 880
 	 */
882 881
 	private function _get_handler()
883 882
 	{
884
-		$handler = new addressbook_vcal('addressbook','text/vcard');
883
+		$handler = new addressbook_vcal('addressbook', 'text/vcard');
885 884
 		$supportedFields = $handler->supportedFields;
886 885
 		// Apple iOS or OS X addressbook
887 886
 		if ($this->agent == 'cfnetwork' || $this->agent == 'dataaccess')
@@ -894,11 +893,11 @@  discard block
 block discarded – undo
894 893
 			unset($supportedFields['TEL;CELL;WORK']);
895 894
 			$supportedFields['TEL;IPHONE'] = array('tel_cell_private');
896 895
 			unset($supportedFields['TEL;CELL;HOME']);
897
-			$databaseFields['X-ABSHOWAS'] = $supportedFields['X-ABSHOWAS'] = array('fileas_type');	// Horde vCard class uses uppercase prop-names!
896
+			$databaseFields['X-ABSHOWAS'] = $supportedFields['X-ABSHOWAS'] = array('fileas_type'); // Horde vCard class uses uppercase prop-names!
898 897
 
899 898
 			// Apple Addressbook pre Lion (OS X 10.7) messes up CLASS and CATEGORIES (Lion cant set them but leaves them alone)
900 899
 			$matches = null;
901
-			if (preg_match('|CFNetwork/([0-9]+)|i', $_SERVER['HTTP_USER_AGENT'],$matches) && $matches[1] < 520 ||
900
+			if (preg_match('|CFNetwork/([0-9]+)|i', $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] < 520 ||
902 901
 				// iOS 5.1.1 does not display CLASS or CATEGORY, but wrongly escapes multiple, comma-separated categories
903 902
 				// and appends CLASS: PUBLIC to an empty NOTE: field --> leaving them out for iOS
904 903
 				$this->agent == 'dataaccess')
@@ -908,7 +907,7 @@  discard block
 block discarded – undo
908 907
 				unset($supportedFields['CATEGORIES']);
909 908
 				unset($databaseFields['CATEGORIES']);
910 909
 			}
911
-			if (preg_match('|CFNetwork/([0-9]+)|i', $_SERVER['HTTP_USER_AGENT'],$matches) && $matches[1] < 520)
910
+			if (preg_match('|CFNetwork/([0-9]+)|i', $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] < 520)
912 911
 			{
913 912
 				// gd cant parse or resize images stored from snow leopard addressbook: gd-jpeg:
914 913
 				// - JPEG library reports unrecoverable error
@@ -920,7 +919,7 @@  discard block
 block discarded – undo
920 919
 			}
921 920
 			$handler->setDatabaseFields($databaseFields);
922 921
 		}
923
-		$handler->setSupportedFields('GroupDAV',$this->agent,$supportedFields);
922
+		$handler->setSupportedFields('GroupDAV', $this->agent, $supportedFields);
924 923
 		return $handler;
925 924
 	}
926 925
 
@@ -931,9 +930,9 @@  discard block
 block discarded – undo
931 930
 	 * @param int $id
932 931
 	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
933 932
 	 */
934
-	function delete(&$options,$id)
933
+	function delete(&$options, $id)
935 934
 	{
936
-		if (!is_array($contact = $this->_common_get_put_delete('DELETE',$options,$id)))
935
+		if (!is_array($contact = $this->_common_get_put_delete('DELETE', $options, $id)))
937 936
 		{
938 937
 			return $contact;
939 938
 		}
@@ -941,7 +940,7 @@  discard block
 block discarded – undo
941 940
 		{
942 941
 			$ok = $this->bo->delete_list($contact['list_id']) !== false;
943 942
 		}
944
-		elseif (($ok = $this->bo->delete($contact['id'],self::etag2value($this->http_if_match))) === 0)
943
+		elseif (($ok = $this->bo->delete($contact['id'], self::etag2value($this->http_if_match))) === 0)
945 944
 		{
946 945
 			return '412 Precondition Failed';
947 946
 		}
@@ -958,9 +957,9 @@  discard block
 block discarded – undo
958 957
 	 * @param string $path =null
959 958
 	 * @return array|boolean array with entry, false if no read rights, null if $id does not exist
960 959
 	 */
961
-	function read($id, $path=null)
960
+	function read($id, $path = null)
962 961
 	{
963
-		static $non_deleted_tids=null;
962
+		static $non_deleted_tids = null;
964 963
 		if (is_null($non_deleted_tids))
965 964
 		{
966 965
 			$tids = $this->bo->content_types;
@@ -970,7 +969,7 @@  discard block
 block discarded – undo
970 969
 		$contact = $this->bo->read(array(self::$path_attr => $id, 'tid' => $non_deleted_tids));
971 970
 
972 971
 		// if contact not found and accounts stored NOT like contacts, try reading it without path-extension as id
973
-		if (is_null($contact) && $this->bo->so_accounts && ($c = $this->bo->read($test=basename($id, '.vcf'))))
972
+		if (is_null($contact) && $this->bo->so_accounts && ($c = $this->bo->read($test = basename($id, '.vcf'))))
974 973
 		{
975 974
 			$contact = $c;
976 975
 		}
@@ -979,9 +978,9 @@  discard block
 block discarded – undo
979 978
 		// bo->read_list(..., true) limits returned uid to same owner's addressbook, as iOS and OS X addressbooks
980 979
 		// only understands/shows that and if return more, save_lists would delete the others ones on update!
981 980
 		$limit_in_ab = true;
982
-		list(,$account_lid,$app) = explode('/',$path);	// eg. /<username>/addressbook/<id>
981
+		list(,$account_lid, $app) = explode('/', $path); // eg. /<username>/addressbook/<id>
983 982
 		// /<username>/addressbook/ with home_set_prefs containing 'O'=all-in-one contains selected ab's
984
-		if($account_lid == $GLOBALS['egw_info']['user']['account_lid'] && $app == 'addressbook' && in_array('O',$this->home_set_pref))
983
+		if ($account_lid == $GLOBALS['egw_info']['user']['account_lid'] && $app == 'addressbook' && in_array('O', $this->home_set_pref))
985 984
 		{
986 985
 			$limit_in_ab = array_keys($this->get_shared(true));
987 986
 			$limit_in_ab[] = $GLOBALS['egw_info']['user']['account_id'];
@@ -992,28 +991,28 @@  discard block
 block discarded – undo
992 991
 		{
993 992
 			$limit_in_ab = array_keys($this->bo->grants);
994 993
 		}*/
995
-		if (!$contact && ($contact = $this->bo->read_lists(array('list_'.self::$path_attr => $id),'contact_uid',$limit_in_ab)))
994
+		if (!$contact && ($contact = $this->bo->read_lists(array('list_'.self::$path_attr => $id), 'contact_uid', $limit_in_ab)))
996 995
 		{
997 996
 			$contact = array_shift($contact);
998 997
 			$contact['n_fn'] = $contact['n_family'] = $contact['list_name'];
999
-			foreach(array('owner','id','carddav_name','modified','modifier','created','creator','etag','uid') as $name)
998
+			foreach (array('owner', 'id', 'carddav_name', 'modified', 'modifier', 'created', 'creator', 'etag', 'uid') as $name)
1000 999
 			{
1001 1000
 				$contact[$name] = $contact['list_'.$name];
1002 1001
 			}
1003 1002
 			// if NOT limited to containing AB ($limit_in_ab === true), add that limit to etag
1004 1003
 			if ($limit_in_ab !== true)
1005 1004
 			{
1006
-				$contact['etag'] .= ':'.implode('-',$limit_in_ab);
1005
+				$contact['etag'] .= ':'.implode('-', $limit_in_ab);
1007 1006
 			}
1008 1007
 		}
1009
-		elseif($contact === array())	// not found from read_lists()
1008
+		elseif ($contact === array())	// not found from read_lists()
1010 1009
 		{
1011 1010
 			$contact = null;
1012 1011
 		}
1013 1012
 
1014 1013
 		if ($contact && $contact['tid'] == Api\Contacts::DELETED_TYPE)
1015 1014
 		{
1016
-			$contact = null;	// handle deleted events, as not existing (404 Not Found)
1015
+			$contact = null; // handle deleted events, as not existing (404 Not Found)
1017 1016
 		}
1018 1017
 		if ($this->debug > 1) error_log(__METHOD__."('$id') returning ".array2string($contact));
1019 1018
 		return $contact;
@@ -1026,9 +1025,9 @@  discard block
 block discarded – undo
1026 1025
 	 * @param array|int $contact contact-array or id
1027 1026
 	 * @return boolean null if entry does not exist, false if no access, true if access permitted
1028 1027
 	 */
1029
-	function check_access($acl,$contact)
1028
+	function check_access($acl, $contact)
1030 1029
 	{
1031
-		return $this->bo->check_perms($acl, $contact, true);	// true = deny to delete accounts
1030
+		return $this->bo->check_perms($acl, $contact, true); // true = deny to delete accounts
1032 1031
 	}
1033 1032
 
1034 1033
 	/**
@@ -1056,15 +1055,15 @@  discard block
 block discarded – undo
1056 1055
 	 * @param boolean $ignore_all_in_one =false if true, return selected addressbooks and not array() for all-in-one
1057 1056
 	 * @return array account_id => account_lid pairs
1058 1057
 	 */
1059
-	function get_shared($ignore_all_in_one=false)
1058
+	function get_shared($ignore_all_in_one = false)
1060 1059
 	{
1061 1060
 		$shared = array();
1062 1061
 
1063 1062
 		// if "Sync all selected addressbook into one" is set --> no (additional) shared addressbooks
1064
-		if (!$ignore_all_in_one && in_array('O',$this->home_set_pref)) return array();
1063
+		if (!$ignore_all_in_one && in_array('O', $this->home_set_pref)) return array();
1065 1064
 
1066 1065
 		// replace symbolic id's with real nummeric id's
1067
-		foreach(array(
1066
+		foreach (array(
1068 1067
 			'G' => $GLOBALS['egw_info']['user']['account_primary_group'],
1069 1068
 			'U' => '0',
1070 1069
 		) as $sym => $id)
@@ -1074,11 +1073,11 @@  discard block
 block discarded – undo
1074 1073
 				$this->home_set_pref[$key] = $id;
1075 1074
 			}
1076 1075
 		}
1077
-		foreach(array_keys($this->bo->get_addressbooks(Acl::READ)) as $id)
1076
+		foreach (array_keys($this->bo->get_addressbooks(Acl::READ)) as $id)
1078 1077
 		{
1079 1078
 			if (($id || !$GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) &&
1080
-				$GLOBALS['egw_info']['user']['account_id'] != $id &&	// no current user and no accounts, if disabled in ab prefs
1081
-				(in_array('A',$this->home_set_pref) || in_array((string)$id,$this->home_set_pref)) &&
1079
+				$GLOBALS['egw_info']['user']['account_id'] != $id && // no current user and no accounts, if disabled in ab prefs
1080
+				(in_array('A', $this->home_set_pref) || in_array((string)$id, $this->home_set_pref)) &&
1082 1081
 				is_numeric($id) && ($owner = $id ? $this->accounts->id2name($id) : 'accounts'))
1083 1082
 			{
1084 1083
 				$shared[$id] = 'addressbook-'.$owner;
@@ -1098,14 +1097,14 @@  discard block
 block discarded – undo
1098 1097
 	public static function groupdav_root_props(array $data)
1099 1098
 	{
1100 1099
 		$data['props']['addressbook-home-set'] = Api\CalDAV::mkprop(Api\CalDAV::CARDDAV, 'addressbook-home-set', array(
1101
-			Api\CalDAV::mkprop('href',$data['caldav']->base_uri.'/'.$GLOBALS['egw_info']['user']['account_lid'].'/')));
1100
+			Api\CalDAV::mkprop('href', $data['caldav']->base_uri.'/'.$GLOBALS['egw_info']['user']['account_lid'].'/')));
1102 1101
 
1103 1102
 		$data['props']['principal-address'] = Api\CalDAV::mkprop(Api\CalDAV::CARDDAV, 'principal-address',
1104 1103
 				$GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] ? '' : array(
1105
-				Api\CalDAV::mkprop('href',$data['caldav']->base_uri.'/addressbook-accounts/'.$GLOBALS['egw_info']['user']['person_id'].'.vcf')));
1104
+				Api\CalDAV::mkprop('href', $data['caldav']->base_uri.'/addressbook-accounts/'.$GLOBALS['egw_info']['user']['person_id'].'.vcf')));
1106 1105
 
1107 1106
 		$data['props']['directory-gateway'] = Api\CalDAV::mkprop(Api\CalDAV::CARDDAV, 'directory-gateway', array(
1108
-			Api\CalDAV::mkprop('href',$data['caldav']->base_uri.'/addressbook/')));
1107
+			Api\CalDAV::mkprop('href', $data['caldav']->base_uri.'/addressbook/')));
1109 1108
 	}
1110 1109
 
1111 1110
 	/**
@@ -1128,8 +1127,8 @@  discard block
 block discarded – undo
1128 1127
 			$user = $hook_data['account_id'];
1129 1128
 			$addressbook_bo = new Api\Contacts();
1130 1129
 			$addressbooks += $addressbook_bo->get_addressbooks(Acl::READ, null, $user);
1131
-			if ($user > 0)  unset($addressbooks[$user]);	// allways synced
1132
-			unset($addressbooks[$user.'p']);// ignore (optional) private addressbook for now
1130
+			if ($user > 0)  unset($addressbooks[$user]); // allways synced
1131
+			unset($addressbooks[$user.'p']); // ignore (optional) private addressbook for now
1133 1132
 		}
1134 1133
 
1135 1134
 		// allow to force no other addressbooks
@@ -1156,9 +1155,9 @@  discard block
 block discarded – undo
1156 1155
 			'label'  => 'Addressbooks to sync in addition to personal addressbook',
1157 1156
 			'name'   => 'addressbook-home-set',
1158 1157
 			'help'   => lang('Only supported by a few fully conformant clients (eg. from Apple). If you have to enter a URL, it will most likely not be supported!').
1159
-				'<br/>'.lang('They will be sub-folders in users home (%1 attribute).','CardDAV "addressbook-home-set"').
1160
-				'<br/>'.lang('Select "%1", if your client does not support multiple addressbooks.',lang('Sync all selected into one')).
1161
-				'<br/>'.lang('Select "%1", if your client support groups, eg. OS X or iOS addressbook.',lang('Distribution lists as groups')),
1158
+				'<br/>'.lang('They will be sub-folders in users home (%1 attribute).', 'CardDAV "addressbook-home-set"').
1159
+				'<br/>'.lang('Select "%1", if your client does not support multiple addressbooks.', lang('Sync all selected into one')).
1160
+				'<br/>'.lang('Select "%1", if your client support groups, eg. OS X or iOS addressbook.', lang('Distribution lists as groups')),
1162 1161
 			'values' => $addressbooks,
1163 1162
 			'xmlrpc' => True,
1164 1163
 			'admin'  => False,
Please login to merge, or discard this patch.
Braces   +163 added lines, -40 removed lines patch added patch discarded remove patch
@@ -85,7 +85,10 @@  discard block
 block discarded – undo
85 85
 			self::$path_attr = 'carddav_name';
86 86
 			self::$path_extension = '';
87 87
 		}
88
-		if ($this->debug) error_log(__METHOD__."() contact_repository={$this->bo->contact_repository}, account_repository={$this->bo->account_repository}, REQUEST_URI=$_SERVER[REQUEST_URI] --> path_attr=".self::$path_attr.", path_extension=".self::$path_extension);
88
+		if ($this->debug)
89
+		{
90
+			error_log(__METHOD__."() contact_repository={$this->bo->contact_repository}, account_repository={$this->bo->account_repository}, REQUEST_URI=$_SERVER[REQUEST_URI] --> path_attr=".self::$path_attr.", path_extension=".self::$path_extension);
91
+		}
89 92
 
90 93
 		$this->home_set_pref = $GLOBALS['egw_info']['user']['preferences']['groupdav']['addressbook-home-set'];
91 94
 		$this->home_set_pref = $this->home_set_pref ? explode(',',$this->home_set_pref) : array();
@@ -123,7 +126,10 @@  discard block
 block discarded – undo
123 126
 			$filter['owner'] = $user;
124 127
 		}
125 128
 		// should we hide the accounts addressbook
126
-		if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts']) $filter['account_id'] = null;
129
+		if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'])
130
+		{
131
+			$filter['account_id'] = null;
132
+		}
127 133
 
128 134
 		// process REPORT filters or multiget href's
129 135
 		$nresults = null;
@@ -131,9 +137,16 @@  discard block
 block discarded – undo
131 137
 		{
132 138
 			return false;
133 139
 		}
134
-		if ($id) $path = dirname($path).'/';	// carddav_name get's added anyway in the callback
140
+		if ($id)
141
+		{
142
+			$path = dirname($path).'/';
143
+		}
144
+		// carddav_name get's added anyway in the callback
135 145
 
136
-		if ($this->debug) error_log(__METHOD__."($path,".array2string($options).",,$user,$id) filter=".array2string($filter));
146
+		if ($this->debug)
147
+		{
148
+			error_log(__METHOD__."($path,".array2string($options).",,$user,$id) filter=".array2string($filter));
149
+		}
137 150
 
138 151
 		// check if we have to return the full contact data or just the etag's
139 152
 		if (!($filter['address_data'] = $options['props'] == 'all' &&
@@ -218,16 +231,25 @@  discard block
 block discarded – undo
218 231
 
219 232
 		if (isset($filter[self::$path_attr]))
220 233
 		{
221
-			if (!is_array($filter[self::$path_attr])) $filter[self::$path_attr] = (array)$filter[self::$path_attr];
234
+			if (!is_array($filter[self::$path_attr]))
235
+			{
236
+				$filter[self::$path_attr] = (array)$filter[self::$path_attr];
237
+			}
222 238
 			$requested_multiget_ids =& $filter[self::$path_attr];
223 239
 		}
224 240
 
225 241
 		$files = array();
226 242
 		// we query etag and modified, as LDAP does not have the strong sql etag
227 243
 		$cols = array('id','uid','etag','modified','n_fn');
228
-		if (!in_array(self::$path_attr,$cols)) $cols[] = self::$path_attr;
244
+		if (!in_array(self::$path_attr,$cols))
245
+		{
246
+			$cols[] = self::$path_attr;
247
+		}
229 248
 		// we need tid for sync-collection report
230
-		if (array_key_exists('tid', $filter) && !isset($filter['tid']) && !in_array('tid', $cols)) $cols[] = 'tid';
249
+		if (array_key_exists('tid', $filter) && !isset($filter['tid']) && !in_array('tid', $cols))
250
+		{
251
+			$cols[] = 'tid';
252
+		}
231 253
 		if (($contacts =& $this->bo->search(array(),$cols,$order,'','',False,'AND',$start,$filter)))
232 254
 		{
233 255
 			foreach($contacts as &$contact)
@@ -271,7 +293,10 @@  discard block
 block discarded – undo
271 293
 			{
272 294
 				$accounts_filter = $filter_in;
273 295
 				$accounts_filter['owner'] = '0';
274
-				if ($sync_collection_report) $token_was = $this->sync_collection_token;
296
+				if ($sync_collection_report)
297
+				{
298
+					$token_was = $this->sync_collection_token;
299
+				}
275 300
 				self::$path_attr = 'id';
276 301
 				self::$path_extension = '.vcf';
277 302
 				$files = array_merge($files, $this->propfind_callback($path, $accounts_filter, false, false));
@@ -294,16 +319,22 @@  discard block
 block discarded – undo
294 319
 					list(,$sync_token) = explode('>', $filter[0]);
295 320
 					$where[] = 'list_modified>FROM_UNIXTIME('.(int)$sync_token.')';
296 321
 				}
297
-				if (isset($filter[self::$path_attr]))	// multiget report?
322
+				if (isset($filter[self::$path_attr]))
323
+				{
324
+					// multiget report?
298 325
 				{
299 326
 					$where['list_'.self::$path_attr] = $filter[self::$path_attr];
300 327
 				}
328
+				}
301 329
 				//error_log(__METHOD__."() filter=".array2string($filter).", do_groups=".in_array('D',$this->home_set_pref).", where=".array2string($where));
302
-				if (($lists = $this->bo->read_lists($where,'contact_uid',$where['list_owner'])))	// limit to contacts in same AB!
330
+				if (($lists = $this->bo->read_lists($where,'contact_uid',$where['list_owner'])))
331
+				{
332
+					// limit to contacts in same AB!
303 333
 				{
304 334
 					foreach($lists as $list)
305 335
 					{
306 336
 						$list[self::$path_attr] = $list['list_carddav_name'];
337
+				}
307 338
 						$etag = $list['list_id'].':'.$list['list_etag'];
308 339
 						// for all-in-one addressbook, add selected ABs to etag
309 340
 						if (isset($filter['owner']) && is_array($filter['owner']))
@@ -347,7 +378,10 @@  discard block
 block discarded – undo
347 378
 			}
348 379
 		}
349 380
 
350
-		if ($this->debug) error_log(__METHOD__."($path,".array2string($filter).','.array2string($start).") took ".(microtime(true) - $starttime).' to return '.count($files).' items');
381
+		if ($this->debug)
382
+		{
383
+			error_log(__METHOD__."($path,".array2string($filter).','.array2string($start).") took ".(microtime(true) - $starttime).' to return '.count($files).' items');
384
+		}
351 385
 		return $files;
352 386
 	}
353 387
 
@@ -387,7 +421,11 @@  discard block
 block discarded – undo
387 421
 			$matches = $prop_test = $column = null;
388 422
 			foreach($options['filters'] as $n => $filter)
389 423
 			{
390
-				if (!is_int($n)) continue;	// eg. attributes of filter xml element
424
+				if (!is_int($n))
425
+				{
426
+					continue;
427
+				}
428
+				// eg. attributes of filter xml element
391 429
 
392 430
 				switch((string)$filter['name'])
393 431
 				{
@@ -395,19 +433,28 @@  discard block
 block discarded – undo
395 433
 						$this->caldav->log(__METHOD__."(...) param-filter='{$filter['attrs']['name']}' not (yet) implemented!");
396 434
 						break;
397 435
 					case 'prop-filter':	// can be multiple prop-filter, see example
398
-						if ($matches) $prop_filters[] = implode($prop_test=='allof'?' AND ':' OR ',$matches);
436
+						if ($matches)
437
+						{
438
+							$prop_filters[] = implode($prop_test=='allof'?' AND ':' OR ',$matches);
439
+						}
399 440
 						$matches = array();
400 441
 						$prop_filter = strtoupper($filter['attrs']['name']);
401 442
 						$prop_test = isset($filter['attrs']['test']) ? $filter['attrs']['test'] : 'anyof';
402
-						if ($this->debug > 1) error_log(__METHOD__."(...) prop-filter='$prop_filter', test='$prop_test'");
443
+						if ($this->debug > 1)
444
+						{
445
+							error_log(__METHOD__."(...) prop-filter='$prop_filter', test='$prop_test'");
446
+						}
403 447
 						break;
404 448
 					case 'is-not-defined':
405 449
 						$matches[] = '('.$column."='' OR ".$column.' IS NULL)';
406 450
 						break;
407 451
 					case 'text-match':	// prop-filter can have multiple text-match, see example
408
-						if (!isset($this->filter_prop2cal[$prop_filter]))	// eg. not existing NICKNAME in EGroupware
452
+						if (!isset($this->filter_prop2cal[$prop_filter]))
453
+						{
454
+							// eg. not existing NICKNAME in EGroupware
409 455
 						{
410 456
 							if ($this->debug || $prop_filter != 'NICKNAME') error_log(__METHOD__."(...) text-match: $prop_filter {$filter['attrs']['match-type']} '{$filter['data']}' unknown property '$prop_filter' --> ignored");
457
+						}
411 458
 							$column = false;	// to ignore following data too
412 459
 						}
413 460
 						else
@@ -420,8 +467,14 @@  discard block
 block discarded – undo
420 467
 									break;
421 468
 							}
422 469
 							$column = $this->filter_prop2cal[strtoupper($prop_filter)];
423
-							if (strpos($column, '_') === false) $column = 'contact_'.$column;
424
-							if (!isset($filters['order'])) $filters['order'] = $column;
470
+							if (strpos($column, '_') === false)
471
+							{
472
+								$column = 'contact_'.$column;
473
+							}
474
+							if (!isset($filters['order']))
475
+							{
476
+								$filters['order'] = $column;
477
+							}
425 478
 							$match_type = $filter['attrs']['match-type'];
426 479
 							$negate_condition = isset($filter['attrs']['negate-condition']) && $filter['attrs']['negate-condition'] == 'yes';
427 480
 						}
@@ -429,9 +482,12 @@  discard block
 block discarded – undo
429 482
 					case '':	// data of text-match element
430 483
 						if (isset($filter['data']) && isset($column))
431 484
 						{
432
-							if ($column)	// false for properties not known to EGroupware
485
+							if ($column)
486
+							{
487
+								// false for properties not known to EGroupware
433 488
 							{
434 489
 								$value = str_replace(array('%', '_'), array('\\%', '\\_'), $filter['data']);
490
+							}
435 491
 								switch($match_type)
436 492
 								{
437 493
 									case 'equals':
@@ -450,7 +506,10 @@  discard block
 block discarded – undo
450 506
 								}
451 507
 								$matches[] = ($negate_condition ? 'NOT ' : '').$sql_filter;
452 508
 
453
-								if ($this->debug > 1) error_log(__METHOD__."(...) text-match: $prop_filter $match_type' '{$filter['data']}'");
509
+								if ($this->debug > 1)
510
+								{
511
+									error_log(__METHOD__."(...) text-match: $prop_filter $match_type' '{$filter['data']}'");
512
+								}
454 513
 							}
455 514
 							unset($column);
456 515
 							break;
@@ -461,11 +520,17 @@  discard block
 block discarded – undo
461 520
 						break;
462 521
 				}
463 522
 			}
464
-			if ($matches) $prop_filters[] = implode($prop_test=='allof'?' AND ':' OR ',$matches);
523
+			if ($matches)
524
+			{
525
+				$prop_filters[] = implode($prop_test=='allof'?' AND ':' OR ',$matches);
526
+			}
465 527
 			if ($prop_filters)
466 528
 			{
467 529
 				$filters[] = $filter = '(('.implode($filter_test=='allof'?') AND (':') OR (', $prop_filters).'))';
468
-				if ($this->debug) error_log(__METHOD__."(path=$options[path], ...) sql-filter: $filter");
530
+				if ($this->debug)
531
+				{
532
+					error_log(__METHOD__."(path=$options[path], ...) sql-filter: $filter");
533
+				}
469 534
 			}
470 535
 		}
471 536
 		// parse limit from $options['other']
@@ -522,8 +587,14 @@  discard block
 block discarded – undo
522 587
 					}
523 588
 				}
524 589
 			}
525
-			if ($ids) $filters[self::$path_attr] = $ids;
526
-			if ($this->debug) error_log(__METHOD__."(...) addressbook-multiget: ids=".implode(',',$ids));
590
+			if ($ids)
591
+			{
592
+				$filters[self::$path_attr] = $ids;
593
+			}
594
+			if ($this->debug)
595
+			{
596
+				error_log(__METHOD__."(...) addressbook-multiget: ids=".implode(',',$ids));
597
+			}
527 598
 		}
528 599
 		elseif ($id)
529 600
 		{
@@ -570,12 +641,18 @@  discard block
 block discarded – undo
570 641
 	 */
571 642
 	function put(&$options,$id,$user=null,$prefix=null)
572 643
 	{
573
-		if ($this->debug) error_log(__METHOD__.'('.array2string($options).",$id,$user)");
644
+		if ($this->debug)
645
+		{
646
+			error_log(__METHOD__.'('.array2string($options).",$id,$user)");
647
+		}
574 648
 
575 649
 		$oldContact = $this->_common_get_put_delete('PUT',$options,$id);
576 650
 		if (!is_null($oldContact) && !is_array($oldContact))
577 651
 		{
578
-			if ($this->debug) error_log(__METHOD__."(,'$id', $user, '$prefix') returning ".array2string($oldContact));
652
+			if ($this->debug)
653
+			{
654
+				error_log(__METHOD__."(,'$id', $user, '$prefix') returning ".array2string($oldContact));
655
+			}
579 656
 			return $oldContact;
580 657
 		}
581 658
 
@@ -666,15 +743,24 @@  discard block
 block discarded – undo
666 743
 			// done here again, as _common_get_put_delete knows nothing about default addressbooks...
667 744
 			if (!($this->bo->grants[$contact['owner']] & Acl::ADD))
668 745
 			{
669
-				if ($this->debug) error_log(__METHOD__."(,'$id', $user, '$prefix') returning '403 Forbidden'");
746
+				if ($this->debug)
747
+				{
748
+					error_log(__METHOD__."(,'$id', $user, '$prefix') returning '403 Forbidden'");
749
+				}
670 750
 				return '403 Forbidden';
671 751
 			}
672 752
 		}
673
-		if ($this->http_if_match) $contact['etag'] = self::etag2value($this->http_if_match);
753
+		if ($this->http_if_match)
754
+		{
755
+			$contact['etag'] = self::etag2value($this->http_if_match);
756
+		}
674 757
 
675 758
 		if (!($save_ok = $is_group ? $this->save_group($contact, $oldContact) : $this->bo->save($contact)))
676 759
 		{
677
-			if ($this->debug) error_log(__METHOD__."(,$id) save(".array2string($contact).") failed, Ok=$save_ok");
760
+			if ($this->debug)
761
+			{
762
+				error_log(__METHOD__."(,$id) save(".array2string($contact).") failed, Ok=$save_ok");
763
+			}
678 764
 			if ($save_ok === 0)
679 765
 			{
680 766
 				// honor Prefer: return=representation for 412 too (no need for client to explicitly reload)
@@ -703,7 +789,10 @@  discard block
 block discarded – undo
703 789
 		// send evtl. necessary respose headers: Location, etag, ...
704 790
 		$this->put_response_headers($contact, $options['path'], $retval, self::$path_attr != 'id');
705 791
 
706
-		if ($this->debug > 1) error_log(__METHOD__."(,'$id', $user, '$prefix') returning ".array2string($retval));
792
+		if ($this->debug > 1)
793
+		{
794
+			error_log(__METHOD__."(,'$id', $user, '$prefix') returning ".array2string($retval));
795
+		}
707 796
 		return $retval;
708 797
 	}
709 798
 
@@ -717,7 +806,10 @@  discard block
 block discarded – undo
717 806
 	function save_group(array &$contact, $oldContact=null)
718 807
 	{
719 808
 		$data = array('list_name' => $contact['n_fn']);
720
-		if (!isset($contact['owner'])) $contact['owner'] = $GLOBALS['egw_info']['user']['account_id'];
809
+		if (!isset($contact['owner']))
810
+		{
811
+			$contact['owner'] = $GLOBALS['egw_info']['user']['account_id'];
812
+		}
721 813
 		foreach(array('id','carddav_name','uid','owner') as $name)
722 814
 		{
723 815
 			$data['list_'.$name] = $contact[$name];
@@ -769,13 +861,22 @@  discard block
 block discarded – undo
769 861
 					}
770 862
 				}
771 863
 				//error_log('to_add_ids='.array2string($to_add_ids).', to_delete_ids='.array2string($to_delete_ids));
772
-				if ($to_add_ids) $this->bo->add2list($to_add_ids, $list_id, array());
773
-				if ($to_delete_ids) $this->bo->remove_from_list($to_delete_ids, $list_id);
864
+				if ($to_add_ids)
865
+				{
866
+					$this->bo->add2list($to_add_ids, $list_id, array());
867
+				}
868
+				if ($to_delete_ids)
869
+				{
870
+					$this->bo->remove_from_list($to_delete_ids, $list_id);
871
+				}
774 872
 			}
775 873
 			// reread as update of list-members updates etag and modified
776 874
 	 		$contact = $this->bo->read_list($list_id);
777 875
 		}
778
-		if ($this->debug > 1) error_log(__METHOD__.'('.array2string($contact).', '.array2string($oldContact).') on return contact='.array2string($data).' returning '.array2string($list_id));
876
+		if ($this->debug > 1)
877
+		{
878
+			error_log(__METHOD__.'('.array2string($contact).', '.array2string($oldContact).') on return contact='.array2string($data).' returning '.array2string($list_id));
879
+		}
779 880
  		return $list_id;
780 881
 	}
781 882
 
@@ -789,11 +890,17 @@  discard block
 block discarded – undo
789 890
 	public function getctag($path,$user)
790 891
 	{
791 892
 		static $ctags = array();	// a little per request caching, in case ctag and sync-token is both requested
792
-		if (isset($ctags[$path])) return $ctags[$path];
893
+		if (isset($ctags[$path]))
894
+		{
895
+			return $ctags[$path];
896
+		}
793 897
 
794 898
 		$user_in = $user;
795 899
 		// not showing addressbook of a single user?
796
-		if (is_null($user) || $user === '' || $path == '/addressbook/') $user = null;
900
+		if (is_null($user) || $user === '' || $path == '/addressbook/')
901
+		{
902
+			$user = null;
903
+		}
797 904
 
798 905
 		// If "Sync selected addressbooks into one" is set --> ctag need to take selected AB's into account too
799 906
 		if ($user && $user == $GLOBALS['egw_info']['user']['account_id'] && in_array('O',$this->home_set_pref))
@@ -1006,16 +1113,22 @@  discard block
 block discarded – undo
1006 1113
 				$contact['etag'] .= ':'.implode('-',$limit_in_ab);
1007 1114
 			}
1008 1115
 		}
1009
-		elseif($contact === array())	// not found from read_lists()
1116
+		elseif($contact === array())
1117
+		{
1118
+			// not found from read_lists()
1010 1119
 		{
1011 1120
 			$contact = null;
1012 1121
 		}
1122
+		}
1013 1123
 
1014 1124
 		if ($contact && $contact['tid'] == Api\Contacts::DELETED_TYPE)
1015 1125
 		{
1016 1126
 			$contact = null;	// handle deleted events, as not existing (404 Not Found)
1017 1127
 		}
1018
-		if ($this->debug > 1) error_log(__METHOD__."('$id') returning ".array2string($contact));
1128
+		if ($this->debug > 1)
1129
+		{
1130
+			error_log(__METHOD__."('$id') returning ".array2string($contact));
1131
+		}
1019 1132
 		return $contact;
1020 1133
 	}
1021 1134
 
@@ -1045,7 +1158,10 @@  discard block
 block discarded – undo
1045 1158
 		// remove add and delete grants for accounts (for admins too)
1046 1159
 		// as accounts can not be created as contacts, they eg. need further data
1047 1160
 		// and admins might not recognice they delete an account incl. its data
1048
-		if (isset($grants[0])) $grants[0] &= ~(EGW_ACL_ADD|EGW_ACL_DELETE);
1161
+		if (isset($grants[0]))
1162
+		{
1163
+			$grants[0] &= ~(EGW_ACL_ADD|EGW_ACL_DELETE);
1164
+		}
1049 1165
 
1050 1166
 		return $grants;
1051 1167
 	}
@@ -1061,7 +1177,10 @@  discard block
 block discarded – undo
1061 1177
 		$shared = array();
1062 1178
 
1063 1179
 		// if "Sync all selected addressbook into one" is set --> no (additional) shared addressbooks
1064
-		if (!$ignore_all_in_one && in_array('O',$this->home_set_pref)) return array();
1180
+		if (!$ignore_all_in_one && in_array('O',$this->home_set_pref))
1181
+		{
1182
+			return array();
1183
+		}
1065 1184
 
1066 1185
 		// replace symbolic id's with real nummeric id's
1067 1186
 		foreach(array(
@@ -1128,7 +1247,11 @@  discard block
 block discarded – undo
1128 1247
 			$user = $hook_data['account_id'];
1129 1248
 			$addressbook_bo = new Api\Contacts();
1130 1249
 			$addressbooks += $addressbook_bo->get_addressbooks(Acl::READ, null, $user);
1131
-			if ($user > 0)  unset($addressbooks[$user]);	// allways synced
1250
+			if ($user > 0)
1251
+			{
1252
+				unset($addressbooks[$user]);
1253
+			}
1254
+			// allways synced
1132 1255
 			unset($addressbooks[$user.'p']);// ignore (optional) private addressbook for now
1133 1256
 		}
1134 1257
 
Please login to merge, or discard this patch.
addressbook/inc/class.addressbook_hooks.inc.php 4 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
 	 * Register addressbook for group-acl
424 424
 	 *
425 425
 	 * @param array $args hook-params (not used)
426
-	 * @return boolean|string true=standard group acl link, of string with link
426
+	 * @return boolean true=standard group acl link, of string with link
427 427
 	 */
428 428
 	static function group_acl($args)
429 429
 	{
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
 	 * For which groups should no group acl be used: addressbook always
438 438
 	 *
439 439
 	 * @param string|array $data
440
-	 * @return boolean|array true, false or array with group-account_id's
440
+	 * @return boolean true, false or array with group-account_id's
441 441
 	 */
442 442
 	static function not_enum_group_acls($data)
443 443
 	{
Please login to merge, or discard this patch.
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -43,37 +43,37 @@  discard block
 block discarded – undo
43 43
 						'link'    => false,
44 44
 						'icon'    => false,
45 45
 					),
46
-					'menuOpened'  => true,	// display it open by default
46
+					'menuOpened'  => true, // display it open by default
47 47
 				));
48 48
 			}
49 49
 			// Magic etemplate2 favorites menu (from nextmatch widget)
50 50
 			display_sidebox($appname, lang('Favorites'), Framework\Favorites::list_favorites('addressbook'));
51 51
 
52 52
 			$file = array(
53
-				'Addressbook list' => Egw::link('/index.php',array(
53
+				'Addressbook list' => Egw::link('/index.php', array(
54 54
 					'menuaction' => 'addressbook.addressbook_ui.index',
55 55
 					'ajax' => 'true')),
56 56
 				array(
57
-					'text' => lang('Add %1',lang(Link::get_registry($appname, 'entry'))),
57
+					'text' => lang('Add %1', lang(Link::get_registry($appname, 'entry'))),
58 58
 					'no_lang' => true,
59 59
 					'link' => "javascript:egw.open('','$appname','add')"
60 60
 				),
61 61
 				'Advanced search' => "javascript:egw_openWindowCentered2('".
62
-					Egw::link('/index.php',array('menuaction' => 'addressbook.addressbook_ui.search'),false).
62
+					Egw::link('/index.php', array('menuaction' => 'addressbook.addressbook_ui.search'), false).
63 63
 					"','_blank',870,610,'yes')",
64
-				'Placeholders'    => Egw::link('/index.php','menuaction=api.EGroupware\\Api\\Contacts\\Merge.show_replacements')
64
+				'Placeholders'    => Egw::link('/index.php', 'menuaction=api.EGroupware\\Api\\Contacts\\Merge.show_replacements')
65 65
 			);
66
-			display_sidebox($appname,lang('Addressbook menu'),$file);
66
+			display_sidebox($appname, lang('Addressbook menu'), $file);
67 67
 		}
68 68
 
69 69
 		if ($GLOBALS['egw_info']['user']['apps']['admin'] && $location != 'preferences')
70 70
 		{
71 71
 			$file = Array(
72
-				'Site configuration' => Egw::link('/index.php',array(
72
+				'Site configuration' => Egw::link('/index.php', array(
73 73
 					'menuaction' => 'admin.uiconfig.index',
74 74
 					'appname'    => $appname,
75 75
 				)),
76
-				'Global Categories'  => Egw::link('/index.php',array(
76
+				'Global Categories'  => Egw::link('/index.php', array(
77 77
 					'menuaction' => 'admin.admin_categories.index',
78 78
 					'appname'    => $appname,
79 79
 					'global_cats'=> True,
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 			// custom fields are not availible in LDAP
83 83
 			if ($GLOBALS['egw_info']['server']['contact_repository'] != 'ldap')
84 84
 			{
85
-				$file['Custom fields'] = Egw::link('/index.php',array(
85
+				$file['Custom fields'] = Egw::link('/index.php', array(
86 86
 					'menuaction' => 'admin.customfields.index',
87 87
 					'appname'    => $appname,
88 88
 					'use_private'=> 1,
@@ -91,11 +91,11 @@  discard block
 block discarded – undo
91 91
 			}
92 92
 			if ($location == 'admin')
93 93
 			{
94
-				display_section($appname,$file);
94
+				display_section($appname, $file);
95 95
 			}
96 96
 			else
97 97
 			{
98
-				display_sidebox($appname,lang('Admin'),$file);
98
+				display_sidebox($appname, lang('Admin'), $file);
99 99
 			}
100 100
 		}
101 101
 	}
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 			'label'  => 'Default addressbook for adding contacts',
123 123
 			'name'   => 'add_default',
124 124
 			'help'   => 'Which addressbook should be selected when adding a contact AND you have no add rights to the current addressbook.',
125
-			'values' => !$hook_data['setup'] ? ExecMethod('addressbook.addressbook_ui.get_addressbooks',Acl::ADD) : array(),
125
+			'values' => !$hook_data['setup'] ? ExecMethod('addressbook.addressbook_ui.get_addressbooks', Acl::ADD) : array(),
126 126
 			'xmlrpc' => True,
127 127
 			'admin'  => False,
128 128
 		);
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 			'name'   => 'link_title',
155 155
 			'values' => array(
156 156
 				'n_fileas' => lang('own sorting').' ('.lang('default').': '.lang('Company').': '.lang('lastname').', '.lang('firstname').')',
157
-			)+$fileas_options,	// plus all fileas types
157
+			) + $fileas_options, // plus all fileas types
158 158
 			'help'   => 'What should links to the addressbook display in other applications. Empty values will be left out. You need to log in anew, if you change this setting!',
159 159
 			'xmlrpc' => True,
160 160
 			'admin'  => false,
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 			'~edit~'    => lang('Edit contact'),
200 200
 			'infolog' => lang('Open %1 CRM view', lang('infolog')),
201 201
 		);
202
-		if($GLOBALS['egw_info']['user']['apps']['tracker'])
202
+		if ($GLOBALS['egw_info']['user']['apps']['tracker'])
203 203
 		{
204 204
 			$crm_list_options['tracker'] = lang('Open %1 CRM view', lang('tracker'));
205 205
 		}
@@ -246,8 +246,8 @@  discard block
 block discarded – undo
246 246
 				'label'  => 'Default document to insert contacts',
247 247
 				'name'   => 'default_document',
248 248
 				'help'   => lang('If you specify a document (full vfs path) here, %1 displays an extra document icon for each entry. That icon allows to download the specified document with the data inserted.', lang('addressbook')).' '.
249
-					lang('The document can contain placeholder like {{%1}}, to be replaced with the data.','n_fn').' '.
250
-					lang('The following document-types are supported:'). implode(',',Api\Storage\Merge::get_file_extensions()),
249
+					lang('The document can contain placeholder like {{%1}}, to be replaced with the data.', 'n_fn').' '.
250
+					lang('The following document-types are supported:').implode(',', Api\Storage\Merge::get_file_extensions()),
251 251
 				'run_lang' => false,
252 252
 				'xmlrpc' => True,
253 253
 				'admin'  => False,
@@ -257,9 +257,9 @@  discard block
 block discarded – undo
257 257
 				'size'   => 60,
258 258
 				'label'  => 'Directory with documents to insert contacts',
259 259
 				'name'   => 'document_dir',
260
-				'help'   => lang('If you specify a directory (full vfs path) here, %1 displays an action for each document. That action allows to download the specified document with the data inserted.',lang('addressbook')).' '.
261
-					lang('The document can contain placeholder like {{%1}}, to be replaced with the data.','n_fn').' '.
262
-					lang('The following document-types are supported:'). implode(',',Api\Storage\Merge::get_file_extensions()),
260
+				'help'   => lang('If you specify a directory (full vfs path) here, %1 displays an action for each document. That action allows to download the specified document with the data inserted.', lang('addressbook')).' '.
261
+					lang('The document can contain placeholder like {{%1}}, to be replaced with the data.', 'n_fn').' '.
262
+					lang('The following document-types are supported:').implode(',', Api\Storage\Merge::get_file_extensions()),
263 263
 				'run_lang' => false,
264 264
 				'xmlrpc' => True,
265 265
 				'admin'  => False,
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
 	 */
344 344
 	static function search_link($location)
345 345
 	{
346
-		unset($location);	// not used, but required by function signature
346
+		unset($location); // not used, but required by function signature
347 347
 
348 348
 		$links = array(
349 349
 			'query' => 'api.EGroupware\\Api\\Contacts.link_query',
@@ -369,9 +369,9 @@  discard block
 block discarded – undo
369 369
 			'add_app'    => 'link_app',
370 370
 			'add_id'     => 'link_id',
371 371
 			'add_popup'  => '870x610',
372
-			'file_access_user' => true,	// file_access supports 4th parameter $user
372
+			'file_access_user' => true, // file_access supports 4th parameter $user
373 373
 			'file_access'=> 'api.EGroupware\\Api\\Contacts.file_access',
374
-			'default_types' => array('n' => array('name' => 'contact', 'options' => array('icon' => 'navbar.png','template' => 'addressbook.edit'))),
374
+			'default_types' => array('n' => array('name' => 'contact', 'options' => array('icon' => 'navbar.png', 'template' => 'addressbook.edit'))),
375 375
 			// registers an addtional type 'addressbook-email', returning only contacts with email, title has email appended
376 376
 			'additional' => array(
377 377
 				'addressbook-email' => array(
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
 	 */
399 399
 	static function getAppExportLimit($location)
400 400
 	{
401
-		unset($location);	// not used, but required by function signature
401
+		unset($location); // not used, but required by function signature
402 402
 
403 403
 		return $GLOBALS['egw_info']['server']['contact_export_limit'];
404 404
 	}
@@ -411,11 +411,11 @@  discard block
 block discarded – undo
411 411
 	 */
412 412
 	static function calendar_resources($args)
413 413
 	{
414
-		unset($args);	// not used, but required by function signature
414
+		unset($args); // not used, but required by function signature
415 415
 
416 416
 		return array(
417
-			'type' => 'c',// one char type-identifiy for this resources
418
-			'info' => 'api.EGroupware\\Api\\Contacts.calendar_info',// info method, returns array with id, type & name for a given id
417
+			'type' => 'c', // one char type-identifiy for this resources
418
+			'info' => 'api.EGroupware\\Api\\Contacts.calendar_info', // info method, returns array with id, type & name for a given id
419 419
 		);
420 420
 	}
421 421
 
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
 	 */
428 428
 	static function group_acl($args)
429 429
 	{
430
-		unset($args);	// not used, but required by function signature
430
+		unset($args); // not used, but required by function signature
431 431
 
432 432
 		// addressbook uses group-acl, only if contacts-backend is NOT LDAP, as the ACL can not be modified there
433 433
 		return $GLOBALS['egw_info']['server']['contact_repository'] != 'ldap';
@@ -441,7 +441,7 @@  discard block
 block discarded – undo
441 441
 	 */
442 442
 	static function not_enum_group_acls($data)
443 443
 	{
444
-		unset($data);	// not used, but required by function signature
444
+		unset($data); // not used, but required by function signature
445 445
 
446 446
 		return true;
447 447
 	}
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
 	 */
455 455
 	public static function acl_rights($params)
456 456
 	{
457
-		unset($params);	// not used, but required by function signature
457
+		unset($params); // not used, but required by function signature
458 458
 
459 459
 		return array(
460 460
 			Acl::READ    => 'read',
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
 	 */
473 473
 	public static function categories($data)
474 474
 	{
475
-		unset($data);	// not used, but required by function signature
475
+		unset($data); // not used, but required by function signature
476 476
 
477 477
 		return true;
478 478
 	}
@@ -489,10 +489,10 @@  discard block
 block discarded – undo
489 489
 
490 490
 		// get the list of account fields
491 491
 		$own_account_acl = array();
492
-		foreach($bocontacts->contact_fields as $field => $label)
492
+		foreach ($bocontacts->contact_fields as $field => $label)
493 493
 		{
494 494
 			// some fields the user should never be allowed to edit or are covert by an other attribute (n_fn for all n_*)
495
-			if (!in_array($field,array('id','tid','owner','created','creator','modified','modifier','private','n_prefix','n_given','n_middle','n_family','n_suffix')))
495
+			if (!in_array($field, array('id', 'tid', 'owner', 'created', 'creator', 'modified', 'modifier', 'private', 'n_prefix', 'n_given', 'n_middle', 'n_family', 'n_suffix')))
496 496
 			{
497 497
 				$own_account_acl[$field] = $label;
498 498
 			}
@@ -500,7 +500,7 @@  discard block
 block discarded – undo
500 500
 		$own_account_acl['link_to'] = 'Links';
501 501
 		if ($config['account_repository'] != 'ldap')	// no custom-fields in ldap
502 502
 		{
503
-			foreach(Api\Storage\Customfields::get('addressbook') as $name => $data)
503
+			foreach (Api\Storage\Customfields::get('addressbook') as $name => $data)
504 504
 			{
505 505
 				$own_account_acl['#'.$name] = $data['label'];
506 506
 			}
@@ -511,26 +511,26 @@  discard block
 block discarded – undo
511 511
 		// Remove country codes as an option, it will be added by BO constructor
512 512
 		unset($org_fields['adr_one_countrycode'], $org_fields['adr_two_countrycode']);
513 513
 
514
-		$supported_fields = $bocontacts->get_fields('supported',null,0);	// fields supported by the backend (ldap schemas!)
514
+		$supported_fields = $bocontacts->get_fields('supported', null, 0); // fields supported by the backend (ldap schemas!)
515 515
 		// get the list of account fields
516 516
 		$copy_fields = array();
517
-		foreach($bocontacts->contact_fields as $field => $label)
517
+		foreach ($bocontacts->contact_fields as $field => $label)
518 518
 		{
519 519
 			// some fields the user should never be allowed to copy or are coverted by an other attribute (n_fn for all n_*)
520
-			if (!in_array($field,array('id','tid','created','creator','modified','modifier','account_id','uid','etag','n_fn')))
520
+			if (!in_array($field, array('id', 'tid', 'created', 'creator', 'modified', 'modifier', 'account_id', 'uid', 'etag', 'n_fn')))
521 521
 			{
522 522
 				$copy_fields[$field] = $label;
523 523
 			}
524 524
 		}
525 525
 		if ($config['contact_repository'] != 'ldap')	// no custom-fields in ldap
526 526
 		{
527
-			foreach(Api\Storage\Customfields::get('addressbook') as $name => $data)
527
+			foreach (Api\Storage\Customfields::get('addressbook') as $name => $data)
528 528
 			{
529 529
 				$copy_fields['#'.$name] = $data['label'];
530 530
 			}
531 531
 		}
532 532
 		// Remove country codes as an option, it will be added by UI constructor
533
-		if(in_array('adr_one_countrycode', $supported_fields))
533
+		if (in_array('adr_one_countrycode', $supported_fields))
534 534
 		{
535 535
 			unset($copy_fields['adr_one_countrycode'], $copy_fields['adr_two_countrycode']);
536 536
 		}
@@ -551,7 +551,7 @@  discard block
 block discarded – undo
551 551
 		$ret = array(
552 552
 			'sel_options' => array(
553 553
 				'own_account_acl' => $own_account_acl,
554
-				'org_fileds_to_update' => $org_fields,	// typo has to stay, as it was there allways and we would loose existing config :(
554
+				'org_fileds_to_update' => $org_fields, // typo has to stay, as it was there allways and we would loose existing config :(
555 555
 				'copy_fields' => $copy_fields,
556 556
 				'fileas' => $bocontacts->fileas_options(),
557 557
 				'contact_repository' => $repositories,
Please login to merge, or discard this patch.
Braces   +8 added lines, -2 removed lines patch added patch discarded remove patch
@@ -498,11 +498,14 @@  discard block
 block discarded – undo
498 498
 			}
499 499
 		}
500 500
 		$own_account_acl['link_to'] = 'Links';
501
-		if ($config['account_repository'] != 'ldap')	// no custom-fields in ldap
501
+		if ($config['account_repository'] != 'ldap')
502
+		{
503
+			// no custom-fields in ldap
502 504
 		{
503 505
 			foreach(Api\Storage\Customfields::get('addressbook') as $name => $data)
504 506
 			{
505 507
 				$own_account_acl['#'.$name] = $data['label'];
508
+		}
506 509
 			}
507 510
 		}
508 511
 
@@ -522,11 +525,14 @@  discard block
 block discarded – undo
522 525
 				$copy_fields[$field] = $label;
523 526
 			}
524 527
 		}
525
-		if ($config['contact_repository'] != 'ldap')	// no custom-fields in ldap
528
+		if ($config['contact_repository'] != 'ldap')
529
+		{
530
+			// no custom-fields in ldap
526 531
 		{
527 532
 			foreach(Api\Storage\Customfields::get('addressbook') as $name => $data)
528 533
 			{
529 534
 				$copy_fields['#'.$name] = $data['label'];
535
+		}
530 536
 			}
531 537
 		}
532 538
 		// Remove country codes as an option, it will be added by UI constructor
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -108,7 +108,7 @@
 block discarded – undo
108 108
 
109 109
 		if ($GLOBALS['egw_info']['user']['apps']['admin'] && !Api\Header\UserAgent::mobile())
110 110
 		{
111
-			$file = Array(
111
+			$file = array(
112 112
 				'Site configuration' => Egw::link('/index.php',array(
113 113
 					'menuaction' => 'infolog.infolog_ui.admin' )),
114 114
 				'Global Categories'  => Egw::link('/index.php',array(
Please login to merge, or discard this patch.
addressbook/inc/class.addressbook_import_contacts_csv.inc.php 4 patches
Doc Comments   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -44,9 +44,7 @@  discard block
 block discarded – undo
44 44
 
45 45
 	/**
46 46
 	 * imports entries according to given definition object.
47
-	 * @param resource $_stream
48
-	 * @param string $_charset
49
-	 * @param definition $_definition
47
+	 * @param importexport_definition $_definition
50 48
 	 */
51 49
 	public function init(importexport_definition &$_definition ) {
52 50
 
@@ -84,7 +82,7 @@  discard block
 block discarded – undo
84 82
 	 *
85 83
 	 * Updates the count of actions taken
86 84
 	 *
87
-	 * @return boolean success
85
+	 * @return null|boolean success
88 86
 	 */
89 87
 	protected function import_record(importexport_iface_egw_record &$record, &$import_csv)
90 88
 	{
Please login to merge, or discard this patch.
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -381,38 +381,38 @@
 block discarded – undo
381 381
 	}
382 382
 
383 383
 	/**
384
-        * Returns warnings that were encountered during importing
385
-        * Maximum of one warning message per record, but you can append if you need to
386
-        *
387
-        * @return Array (
388
-        *       record_# => warning message
389
-        *       )
390
-        */
391
-        public function get_warnings() {
384
+	 * Returns warnings that were encountered during importing
385
+	 * Maximum of one warning message per record, but you can append if you need to
386
+	 *
387
+	 * @return Array (
388
+	 *       record_# => warning message
389
+	 *       )
390
+	 */
391
+		public function get_warnings() {
392 392
 		return $this->warnings;
393 393
 	}
394 394
 
395 395
 	/**
396
-        * Returns errors that were encountered during importing
397
-        * Maximum of one error message per record, but you can append if you need to
398
-        *
399
-        * @return Array (
400
-        *       record_# => error message
401
-        *       )
402
-        */
403
-        public function get_errors() {
396
+	 * Returns errors that were encountered during importing
397
+	 * Maximum of one error message per record, but you can append if you need to
398
+	 *
399
+	 * @return Array (
400
+	 *       record_# => error message
401
+	 *       )
402
+	 */
403
+		public function get_errors() {
404 404
 		return $this->errors;
405 405
 	}
406 406
 
407 407
 	/**
408
-        * Returns a list of actions taken, and the number of records for that action.
409
-        * Actions are things like 'insert', 'update', 'delete', and may be different for each plugin.
410
-        *
411
-        * @return Array (
412
-        *       action => record count
413
-        * )
414
-        */
415
-        public function get_results() {
416
-                return $this->results;
417
-        }
408
+	 * Returns a list of actions taken, and the number of records for that action.
409
+	 * Actions are things like 'insert', 'update', 'delete', and may be different for each plugin.
410
+	 *
411
+	 * @return Array (
412
+	 *       action => record count
413
+	 * )
414
+	 */
415
+		public function get_results() {
416
+				return $this->results;
417
+		}
418 418
 }
Please login to merge, or discard this patch.
Spacing   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -15,14 +15,14 @@  discard block
 block discarded – undo
15 15
 /**
16 16
  * class import_csv for addressbook
17 17
  */
18
-class addressbook_import_contacts_csv extends importexport_basic_import_csv  {
18
+class addressbook_import_contacts_csv extends importexport_basic_import_csv {
19 19
 
20 20
 	/**
21 21
 	 * conditions for actions
22 22
 	 *
23 23
 	 * @var array
24 24
 	 */
25
-	protected static $conditions = array( 'exists', 'equal' );
25
+	protected static $conditions = array('exists', 'equal');
26 26
 
27 27
 	/**
28 28
 	 * @var bocontacts
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 	 * @param string $_charset
49 49
 	 * @param definition $_definition
50 50
 	 */
51
-	public function init(importexport_definition &$_definition ) {
51
+	public function init(importexport_definition&$_definition) {
52 52
 
53 53
 		// fetch the addressbook bo
54 54
 		$this->bocontacts = new Api\Contacts();
@@ -59,17 +59,17 @@  discard block
 block discarded – undo
59 59
 		$this->lookups = array(
60 60
 			'tid' => array('n'=>'contact')
61 61
 		);
62
-		foreach($this->bocontacts->content_types as $tid => $data)
62
+		foreach ($this->bocontacts->content_types as $tid => $data)
63 63
 		{
64 64
 			$this->lookups['tid'][$tid] = $data['name'];
65 65
 		}
66 66
 
67 67
 		// set contact owner
68
-		$contact_owner = isset( $_definition->plugin_options['contact_owner'] ) ?
68
+		$contact_owner = isset($_definition->plugin_options['contact_owner']) ?
69 69
 			$_definition->plugin_options['contact_owner'] : $this->user;
70 70
 
71 71
 		// Import into importer's personal addressbook
72
-		if($contact_owner == 'personal')
72
+		if ($contact_owner == 'personal')
73 73
 		{
74 74
 			$contact_owner = $this->user;
75 75
 		}
@@ -86,15 +86,15 @@  discard block
 block discarded – undo
86 86
 	 *
87 87
 	 * @return boolean success
88 88
 	 */
89
-	protected function import_record(importexport_iface_egw_record &$record, &$import_csv)
89
+	protected function import_record(importexport_iface_egw_record&$record, &$import_csv)
90 90
 	{
91 91
 
92 92
 		// Set owner, unless it's supposed to come from CSV file
93
-		if($this->definition->plugin_options['owner_from_csv'] && $record->owner) {
94
-			if(!is_numeric($record->owner)) {
93
+		if ($this->definition->plugin_options['owner_from_csv'] && $record->owner) {
94
+			if (!is_numeric($record->owner)) {
95 95
 				// Automatically handle text owner without explicit translation
96 96
 				$new_owner = importexport_helper_functions::account_name2id($record->owner);
97
-				if($new_owner == '') {
97
+				if ($new_owner == '') {
98 98
 					$this->errors[$import_csv->get_current_position()] = lang(
99 99
 						'Unable to convert "%1" to account ID.  Using plugin setting (%2) for owner.',
100 100
 						$record->owner,
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 		}
111 111
 
112 112
 		// Check that owner (addressbook) is allowed
113
-		if(!array_key_exists($record->owner, $this->bocontacts->get_addressbooks()))
113
+		if (!array_key_exists($record->owner, $this->bocontacts->get_addressbooks()))
114 114
 		{
115 115
 			$this->errors[$import_csv->get_current_position()] = lang("Unable to import into %1, using %2",
116 116
 				Api\Accounts::username($record->owner),
@@ -121,18 +121,18 @@  discard block
 block discarded – undo
121 121
 
122 122
 		// Do not allow owner == 0 (accounts) without an account_id
123 123
 		// It causes the contact to be filed as an account, and can't delete
124
-		if(!$record->owner && !$record->account_id)
124
+		if (!$record->owner && !$record->account_id)
125 125
 		{
126 126
 			$record->owner = $GLOBALS['egw_info']['user']['account_id'];
127 127
 		}
128 128
 
129 129
 		// Do not import into non-existing type, warn and change
130
-		if(!$record->tid || !$this->lookups['tid'][$record->tid])
130
+		if (!$record->tid || !$this->lookups['tid'][$record->tid])
131 131
 		{
132 132
 			// Avoid lots of warnings about type (2 types are contact and deleted)
133
-			if(!$this->type_warned || count($this->lookups['tid']) == 2 )
133
+			if (!$this->type_warned || count($this->lookups['tid']) == 2)
134 134
 			{
135
-				$this->warnings[$import_csv->get_current_position()] = lang('Unknown type %1, imported as %2',$record->tid,lang($this->lookups['tid']['n']));
135
+				$this->warnings[$import_csv->get_current_position()] = lang('Unknown type %1, imported as %2', $record->tid, lang($this->lookups['tid']['n']));
136 136
 				$this->type_warned = true;
137 137
 			}
138 138
 			$record->tid = 'n';
@@ -141,45 +141,45 @@  discard block
 block discarded – undo
141 141
 		// Also handle categories in their own field
142 142
 		$record_array = $record->get_record_array();
143 143
 		$more_categories = array();
144
-		foreach($this->definition->plugin_options['field_mapping'] as $field_name) {
145
-			if(!array_key_exists($field_name, $record_array) ||
146
-				substr($field_name,0,3) != 'cat' || !$record->$field_name || $field_name == 'cat_id') continue;
144
+		foreach ($this->definition->plugin_options['field_mapping'] as $field_name) {
145
+			if (!array_key_exists($field_name, $record_array) ||
146
+				substr($field_name, 0, 3) != 'cat' || !$record->$field_name || $field_name == 'cat_id') continue;
147 147
 			list(, $cat_id) = explode('-', $field_name);
148
-			if(is_numeric($record->$field_name) && $record->$field_name != 1) {
148
+			if (is_numeric($record->$field_name) && $record->$field_name != 1) {
149 149
 				// Column has a single category ID
150 150
 				$more_categories[] = $record->$field_name;
151
-			} elseif($record->$field_name == '1' ||
151
+			} elseif ($record->$field_name == '1' ||
152 152
 				(!is_numeric($record->$field_name) && strtolower($record->$field_name) == strtolower(lang('Yes')))) {
153 153
 				// Each category got its own column.  '1' is the database value, lang('yes') is the human value
154 154
 				$more_categories[] = $cat_id;
155 155
 			} else {
156 156
 				// Text categories
157
-				$more_categories = array_merge($more_categories, importexport_helper_functions::cat_name2id(is_array($record->$field_name) ? $record->$field_name : explode(',',$record->$field_name), $cat_id));
157
+				$more_categories = array_merge($more_categories, importexport_helper_functions::cat_name2id(is_array($record->$field_name) ? $record->$field_name : explode(',', $record->$field_name), $cat_id));
158 158
 			}
159 159
 		}
160
-		if(count($more_categories) > 0) $record->cat_id = array_merge(is_array($record->cat_id) ? $record->cat_id : explode(',',$record->cat_id), $more_categories);
160
+		if (count($more_categories) > 0) $record->cat_id = array_merge(is_array($record->cat_id) ? $record->cat_id : explode(',', $record->cat_id), $more_categories);
161 161
 
162 162
 		// Private set but missing causes hidden entries
163
-		if(array_key_exists('private', $record_array) && (!isset($record_array['private']) || $record_array['private'] == '')) unset($record->private);
163
+		if (array_key_exists('private', $record_array) && (!isset($record_array['private']) || $record_array['private'] == '')) unset($record->private);
164 164
 
165 165
 		// Format birthday as backend requires - converter should give timestamp
166
-		if($record->bday && is_numeric($record->bday))
166
+		if ($record->bday && is_numeric($record->bday))
167 167
 		{
168 168
 			$time = new Api\DateTime($record->bday);
169 169
 			$record->bday = $time->format('Y-m-d');
170 170
 		}
171 171
 
172
-		if ( $this->definition->plugin_options['conditions'] ) {
173
-			foreach ( $this->definition->plugin_options['conditions'] as $condition ) {
172
+		if ($this->definition->plugin_options['conditions']) {
173
+			foreach ($this->definition->plugin_options['conditions'] as $condition) {
174 174
 				$contacts = array();
175
-				switch ( $condition['type'] ) {
175
+				switch ($condition['type']) {
176 176
 					// exists
177 177
 					case 'exists' :
178
-						if($record_array[$condition['string']]) {
179
-							$searchcondition = array( $condition['string'] => $record_array[$condition['string']]);
178
+						if ($record_array[$condition['string']]) {
179
+							$searchcondition = array($condition['string'] => $record_array[$condition['string']]);
180 180
 							// if we use account_id for the condition, we need to set the owner for filtering, as this
181 181
 							// enables Api\Contacts\Storage to decide what backend is to be used
182
-							if ($condition['string']=='account_id') $searchcondition['owner']=0;
182
+							if ($condition['string'] == 'account_id') $searchcondition['owner'] = 0;
183 183
 							$contacts = $this->bocontacts->search(
184 184
 								//array( $condition['string'] => $record[$condition['string']],),
185 185
 								'',
@@ -188,37 +188,37 @@  discard block
 block discarded – undo
188 188
 								$searchcondition
189 189
 							);
190 190
 						}
191
-						if ( is_array( $contacts ) && count( array_keys( $contacts ) ) >= 1 ) {
191
+						if (is_array($contacts) && count(array_keys($contacts)) >= 1) {
192 192
 							// apply action to all contacts matching this exists condition
193 193
 							$action = $condition['true'];
194
-							foreach ( (array)$contacts as $contact ) {
194
+							foreach ((array)$contacts as $contact) {
195 195
 								$record->id = $contact['id'];
196
-								if ( $this->definition->plugin_options['update_cats'] == 'add' ) {
197
-									if ( !is_array( $contact['cat_id'] ) ) $contact['cat_id'] = explode( ',', $contact['cat_id'] );
198
-									if ( !is_array( $record_array['cat_id'] ) ) $record->cat_id = explode( ',', $record->cat_id );
199
-									$record->cat_id = implode( ',', array_unique( array_merge( $record->cat_id, $contact['cat_id'] ) ) );
196
+								if ($this->definition->plugin_options['update_cats'] == 'add') {
197
+									if (!is_array($contact['cat_id'])) $contact['cat_id'] = explode(',', $contact['cat_id']);
198
+									if (!is_array($record_array['cat_id'])) $record->cat_id = explode(',', $record->cat_id);
199
+									$record->cat_id = implode(',', array_unique(array_merge($record->cat_id, $contact['cat_id'])));
200 200
 								}
201
-								$success = $this->action(  $action['action'], $record, $import_csv->get_current_position() );
201
+								$success = $this->action($action['action'], $record, $import_csv->get_current_position());
202 202
 							}
203 203
 						} else {
204 204
 							$action = $condition['false'];
205
-							$success = ($this->action(  $action['action'], $record, $import_csv->get_current_position() ));
205
+							$success = ($this->action($action['action'], $record, $import_csv->get_current_position()));
206 206
 						}
207 207
 						break;
208 208
 					case 'equal':
209 209
 						// Match on field
210 210
 						$result = $this->equal($record, $condition);
211
-						if($result)
211
+						if ($result)
212 212
 						{
213 213
 							// Apply true action to any matching records found
214 214
 							$action = $condition['true'];
215
-							$success = ($this->action(  $action['action'], $record, $import_csv->get_current_position() ));
215
+							$success = ($this->action($action['action'], $record, $import_csv->get_current_position()));
216 216
 						}
217 217
 						else
218 218
 						{
219 219
 							// Apply false action if no matching records found
220 220
 							$action = $condition['false'];
221
-							$success = ($this->action(  $action['action'], $record, $import_csv->get_current_position() ));
221
+							$success = ($this->action($action['action'], $record, $import_csv->get_current_position()));
222 222
 						}
223 223
 						break;
224 224
 
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 			}
232 232
 		} else {
233 233
 			// unconditional insert
234
-			$success = $this->action( 'insert', $record, $import_csv->get_current_position() );
234
+			$success = $this->action('insert', $record, $import_csv->get_current_position());
235 235
 		}
236 236
 		return $success;
237 237
 	}
@@ -243,21 +243,21 @@  discard block
 block discarded – undo
243 243
 	 * @param importexport_iface_egw_record $record contact data for the action
244 244
 	 * @return bool success or not
245 245
 	 */
246
-	protected function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 ) {
246
+	protected function action($_action, importexport_iface_egw_record&$record, $record_num = 0) {
247 247
 		$_data = $record->get_record_array();
248 248
 		switch ($_action) {
249 249
 			case 'none' :
250 250
 				return true;
251 251
 			case 'delete':
252
-				if($_data['id'])
252
+				if ($_data['id'])
253 253
 				{
254
-					if ( $this->dry_run ) {
254
+					if ($this->dry_run) {
255 255
 						//print_r($_data);
256 256
 						$this->results[$_action]++;
257 257
 						return true;
258 258
 					}
259 259
 					$result = $this->bocontacts->delete($_data);
260
-					if($result && $result === true)
260
+					if ($result && $result === true)
261 261
 					{
262 262
 						$this->results[$_action]++;
263 263
 					}
@@ -272,14 +272,14 @@  discard block
 block discarded – undo
272 272
 				// Only update if there are changes
273 273
 				$old = $this->bocontacts->read($_data['id']);
274 274
 				// if we get countrycodes as countryname, try to translate them -> the rest should be handled by bo classes.
275
-				foreach(array('adr_one_', 'adr_two_') as $c_prefix) {
276
-					if (strlen(trim($_data[$c_prefix.'countryname']))==2)
275
+				foreach (array('adr_one_', 'adr_two_') as $c_prefix) {
276
+					if (strlen(trim($_data[$c_prefix.'countryname'])) == 2)
277 277
 						$_data[$c_prefix.'countryname'] = $GLOBALS['egw']->country->get_full_name(trim($_data[$c_prefix.'countryname']), true);
278 278
 				}
279 279
 				// Don't change a user account into a contact
280
-				if($old['owner'] == 0) {
280
+				if ($old['owner'] == 0) {
281 281
 					unset($_data['owner']);
282
-				} elseif(!$this->definition->plugin_options['change_owner']) {
282
+				} elseif (!$this->definition->plugin_options['change_owner']) {
283 283
 					// Don't change addressbook of an existing contact
284 284
 					unset($_data['owner']);
285 285
 				}
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
 				// Merge to deal with fields not in import record
288 288
 				$_data = array_merge($old, $_data);
289 289
 				$changed = $this->tracking->changed_fields($_data, $old);
290
-				if(count($changed) == 0) {
290
+				if (count($changed) == 0) {
291 291
 					return true;
292 292
 				} else {
293 293
 					//error_log(__METHOD__.__LINE__.array2string($changed).' Old:'.$old['adr_one_countryname'].' ('.$old['adr_one_countrycode'].') New:'.$_data['adr_one_countryname'].' ('.$_data['adr_one_countryname'].')');
@@ -298,22 +298,22 @@  discard block
 block discarded – undo
298 298
 
299 299
 				// Fall through
300 300
 			case 'insert' :
301
-				if($_action == 'insert') {
301
+				if ($_action == 'insert') {
302 302
 					// Addressbook backend doesn't like inserting with ID specified, it screws up the owner & etag
303 303
 					unset($_data['id']);
304 304
 				}
305
-				if(!isset($_data['org_name'])) {
305
+				if (!isset($_data['org_name'])) {
306 306
 					// org_name is a trigger to update n_fileas
307 307
 					$_data['org_name'] = '';
308 308
 				}
309 309
 
310
-				if ( $this->dry_run ) {
310
+				if ($this->dry_run) {
311 311
 					//print_r($_data);
312 312
 					$this->results[$_action]++;
313 313
 					return true;
314 314
 				} else {
315
-					$result = $this->bocontacts->save( $_data, $this->is_admin);
316
-					if(!$result) {
315
+					$result = $this->bocontacts->save($_data, $this->is_admin);
316
+					if (!$result) {
317 317
 						$this->errors[$record_num] = $this->bocontacts->error;
318 318
 					} else {
319 319
 						$this->results[$_action]++;
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
 					return $result;
324 324
 				}
325 325
 			default:
326
-				throw new Api\Exception('Unsupported action: '. $_action);
326
+				throw new Api\Exception('Unsupported action: '.$_action);
327 327
 
328 328
 		}
329 329
 	}
Please login to merge, or discard this patch.
Braces   +126 added lines, -51 removed lines patch added patch discarded remove patch
@@ -15,7 +15,8 @@  discard block
 block discarded – undo
15 15
 /**
16 16
  * class import_csv for addressbook
17 17
  */
18
-class addressbook_import_contacts_csv extends importexport_basic_import_csv  {
18
+class addressbook_import_contacts_csv extends importexport_basic_import_csv
19
+{
19 20
 
20 21
 	/**
21 22
 	 * conditions for actions
@@ -48,7 +49,8 @@  discard block
 block discarded – undo
48 49
 	 * @param string $_charset
49 50
 	 * @param definition $_definition
50 51
 	 */
51
-	public function init(importexport_definition &$_definition ) {
52
+	public function init(importexport_definition &$_definition )
53
+	{
52 54
 
53 55
 		// fetch the addressbook bo
54 56
 		$this->bocontacts = new Api\Contacts();
@@ -90,22 +92,29 @@  discard block
 block discarded – undo
90 92
 	{
91 93
 
92 94
 		// Set owner, unless it's supposed to come from CSV file
93
-		if($this->definition->plugin_options['owner_from_csv'] && $record->owner) {
94
-			if(!is_numeric($record->owner)) {
95
+		if($this->definition->plugin_options['owner_from_csv'] && $record->owner)
96
+		{
97
+			if(!is_numeric($record->owner))
98
+			{
95 99
 				// Automatically handle text owner without explicit translation
96 100
 				$new_owner = importexport_helper_functions::account_name2id($record->owner);
97
-				if($new_owner == '') {
101
+				if($new_owner == '')
102
+				{
98 103
 					$this->errors[$import_csv->get_current_position()] = lang(
99 104
 						'Unable to convert "%1" to account ID.  Using plugin setting (%2) for owner.',
100 105
 						$record->owner,
101 106
 						Api\Accounts::username($this->user)
102 107
 					);
103 108
 					$record->owner = $this->user;
104
-				} else {
109
+				}
110
+				else
111
+				{
105 112
 					$record->owner = $new_owner;
106 113
 				}
107 114
 			}
108
-		} else {
115
+		}
116
+		else
117
+		{
109 118
 			$record->owner = $this->user;
110 119
 		}
111 120
 
@@ -141,26 +150,41 @@  discard block
 block discarded – undo
141 150
 		// Also handle categories in their own field
142 151
 		$record_array = $record->get_record_array();
143 152
 		$more_categories = array();
144
-		foreach($this->definition->plugin_options['field_mapping'] as $field_name) {
153
+		foreach($this->definition->plugin_options['field_mapping'] as $field_name)
154
+		{
145 155
 			if(!array_key_exists($field_name, $record_array) ||
146
-				substr($field_name,0,3) != 'cat' || !$record->$field_name || $field_name == 'cat_id') continue;
156
+				substr($field_name,0,3) != 'cat' || !$record->$field_name || $field_name == 'cat_id')
157
+			{
158
+				continue;
159
+			}
147 160
 			list(, $cat_id) = explode('-', $field_name);
148
-			if(is_numeric($record->$field_name) && $record->$field_name != 1) {
161
+			if(is_numeric($record->$field_name) && $record->$field_name != 1)
162
+			{
149 163
 				// Column has a single category ID
150 164
 				$more_categories[] = $record->$field_name;
151
-			} elseif($record->$field_name == '1' ||
152
-				(!is_numeric($record->$field_name) && strtolower($record->$field_name) == strtolower(lang('Yes')))) {
165
+			}
166
+			elseif($record->$field_name == '1' ||
167
+				(!is_numeric($record->$field_name) && strtolower($record->$field_name) == strtolower(lang('Yes'))))
168
+			{
153 169
 				// Each category got its own column.  '1' is the database value, lang('yes') is the human value
154 170
 				$more_categories[] = $cat_id;
155
-			} else {
171
+			}
172
+			else
173
+			{
156 174
 				// Text categories
157 175
 				$more_categories = array_merge($more_categories, importexport_helper_functions::cat_name2id(is_array($record->$field_name) ? $record->$field_name : explode(',',$record->$field_name), $cat_id));
158 176
 			}
159 177
 		}
160
-		if(count($more_categories) > 0) $record->cat_id = array_merge(is_array($record->cat_id) ? $record->cat_id : explode(',',$record->cat_id), $more_categories);
178
+		if(count($more_categories) > 0)
179
+		{
180
+			$record->cat_id = array_merge(is_array($record->cat_id) ? $record->cat_id : explode(',',$record->cat_id), $more_categories);
181
+		}
161 182
 
162 183
 		// Private set but missing causes hidden entries
163
-		if(array_key_exists('private', $record_array) && (!isset($record_array['private']) || $record_array['private'] == '')) unset($record->private);
184
+		if(array_key_exists('private', $record_array) && (!isset($record_array['private']) || $record_array['private'] == ''))
185
+		{
186
+			unset($record->private);
187
+		}
164 188
 
165 189
 		// Format birthday as backend requires - converter should give timestamp
166 190
 		if($record->bday && is_numeric($record->bday))
@@ -169,17 +193,24 @@  discard block
 block discarded – undo
169 193
 			$record->bday = $time->format('Y-m-d');
170 194
 		}
171 195
 
172
-		if ( $this->definition->plugin_options['conditions'] ) {
173
-			foreach ( $this->definition->plugin_options['conditions'] as $condition ) {
196
+		if ( $this->definition->plugin_options['conditions'] )
197
+		{
198
+			foreach ( $this->definition->plugin_options['conditions'] as $condition )
199
+			{
174 200
 				$contacts = array();
175
-				switch ( $condition['type'] ) {
201
+				switch ( $condition['type'] )
202
+				{
176 203
 					// exists
177 204
 					case 'exists' :
178
-						if($record_array[$condition['string']]) {
205
+						if($record_array[$condition['string']])
206
+						{
179 207
 							$searchcondition = array( $condition['string'] => $record_array[$condition['string']]);
180 208
 							// if we use account_id for the condition, we need to set the owner for filtering, as this
181 209
 							// enables Api\Contacts\Storage to decide what backend is to be used
182
-							if ($condition['string']=='account_id') $searchcondition['owner']=0;
210
+							if ($condition['string']=='account_id')
211
+							{
212
+								$searchcondition['owner']=0;
213
+							}
183 214
 							$contacts = $this->bocontacts->search(
184 215
 								//array( $condition['string'] => $record[$condition['string']],),
185 216
 								'',
@@ -188,19 +219,30 @@  discard block
 block discarded – undo
188 219
 								$searchcondition
189 220
 							);
190 221
 						}
191
-						if ( is_array( $contacts ) && count( array_keys( $contacts ) ) >= 1 ) {
222
+						if ( is_array( $contacts ) && count( array_keys( $contacts ) ) >= 1 )
223
+						{
192 224
 							// apply action to all contacts matching this exists condition
193 225
 							$action = $condition['true'];
194
-							foreach ( (array)$contacts as $contact ) {
226
+							foreach ( (array)$contacts as $contact )
227
+							{
195 228
 								$record->id = $contact['id'];
196
-								if ( $this->definition->plugin_options['update_cats'] == 'add' ) {
197
-									if ( !is_array( $contact['cat_id'] ) ) $contact['cat_id'] = explode( ',', $contact['cat_id'] );
198
-									if ( !is_array( $record_array['cat_id'] ) ) $record->cat_id = explode( ',', $record->cat_id );
229
+								if ( $this->definition->plugin_options['update_cats'] == 'add' )
230
+								{
231
+									if ( !is_array( $contact['cat_id'] ) )
232
+									{
233
+										$contact['cat_id'] = explode( ',', $contact['cat_id'] );
234
+									}
235
+									if ( !is_array( $record_array['cat_id'] ) )
236
+									{
237
+										$record->cat_id = explode( ',', $record->cat_id );
238
+									}
199 239
 									$record->cat_id = implode( ',', array_unique( array_merge( $record->cat_id, $contact['cat_id'] ) ) );
200 240
 								}
201 241
 								$success = $this->action(  $action['action'], $record, $import_csv->get_current_position() );
202 242
 							}
203
-						} else {
243
+						}
244
+						else
245
+						{
204 246
 							$action = $condition['false'];
205 247
 							$success = ($this->action(  $action['action'], $record, $import_csv->get_current_position() ));
206 248
 						}
@@ -227,9 +269,14 @@  discard block
 block discarded – undo
227 269
 						die('condition / action not supported!!!');
228 270
 						break;
229 271
 				}
230
-				if ($action['stop']) break;
272
+				if ($action['stop'])
273
+				{
274
+					break;
275
+				}
231 276
 			}
232
-		} else {
277
+		}
278
+		else
279
+		{
233 280
 			// unconditional insert
234 281
 			$success = $this->action( 'insert', $record, $import_csv->get_current_position() );
235 282
 		}
@@ -243,15 +290,18 @@  discard block
 block discarded – undo
243 290
 	 * @param importexport_iface_egw_record $record contact data for the action
244 291
 	 * @return bool success or not
245 292
 	 */
246
-	protected function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 ) {
293
+	protected function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 )
294
+	{
247 295
 		$_data = $record->get_record_array();
248
-		switch ($_action) {
296
+		switch ($_action)
297
+		{
249 298
 			case 'none' :
250 299
 				return true;
251 300
 			case 'delete':
252 301
 				if($_data['id'])
253 302
 				{
254
-					if ( $this->dry_run ) {
303
+					if ( $this->dry_run )
304
+					{
255 305
 						//print_r($_data);
256 306
 						$this->results[$_action]++;
257 307
 						return true;
@@ -272,14 +322,20 @@  discard block
 block discarded – undo
272 322
 				// Only update if there are changes
273 323
 				$old = $this->bocontacts->read($_data['id']);
274 324
 				// if we get countrycodes as countryname, try to translate them -> the rest should be handled by bo classes.
275
-				foreach(array('adr_one_', 'adr_two_') as $c_prefix) {
325
+				foreach(array('adr_one_', 'adr_two_') as $c_prefix)
326
+				{
276 327
 					if (strlen(trim($_data[$c_prefix.'countryname']))==2)
277
-						$_data[$c_prefix.'countryname'] = $GLOBALS['egw']->country->get_full_name(trim($_data[$c_prefix.'countryname']), true);
328
+					{
329
+											$_data[$c_prefix.'countryname'] = $GLOBALS['egw']->country->get_full_name(trim($_data[$c_prefix.'countryname']), true);
330
+					}
278 331
 				}
279 332
 				// Don't change a user account into a contact
280
-				if($old['owner'] == 0) {
333
+				if($old['owner'] == 0)
334
+				{
281 335
 					unset($_data['owner']);
282
-				} elseif(!$this->definition->plugin_options['change_owner']) {
336
+				}
337
+				elseif(!$this->definition->plugin_options['change_owner'])
338
+				{
283 339
 					// Don't change addressbook of an existing contact
284 340
 					unset($_data['owner']);
285 341
 				}
@@ -287,9 +343,12 @@  discard block
 block discarded – undo
287 343
 				// Merge to deal with fields not in import record
288 344
 				$_data = array_merge($old, $_data);
289 345
 				$changed = $this->tracking->changed_fields($_data, $old);
290
-				if(count($changed) == 0) {
346
+				if(count($changed) == 0)
347
+				{
291 348
 					return true;
292
-				} else {
349
+				}
350
+				else
351
+				{
293 352
 					//error_log(__METHOD__.__LINE__.array2string($changed).' Old:'.$old['adr_one_countryname'].' ('.$old['adr_one_countrycode'].') New:'.$_data['adr_one_countryname'].' ('.$_data['adr_one_countryname'].')');
294 353
 				}
295 354
 
@@ -298,24 +357,32 @@  discard block
 block discarded – undo
298 357
 
299 358
 				// Fall through
300 359
 			case 'insert' :
301
-				if($_action == 'insert') {
360
+				if($_action == 'insert')
361
+				{
302 362
 					// Addressbook backend doesn't like inserting with ID specified, it screws up the owner & etag
303 363
 					unset($_data['id']);
304 364
 				}
305
-				if(!isset($_data['org_name'])) {
365
+				if(!isset($_data['org_name']))
366
+				{
306 367
 					// org_name is a trigger to update n_fileas
307 368
 					$_data['org_name'] = '';
308 369
 				}
309 370
 
310
-				if ( $this->dry_run ) {
371
+				if ( $this->dry_run )
372
+				{
311 373
 					//print_r($_data);
312 374
 					$this->results[$_action]++;
313 375
 					return true;
314
-				} else {
376
+				}
377
+				else
378
+				{
315 379
 					$result = $this->bocontacts->save( $_data, $this->is_admin);
316
-					if(!$result) {
380
+					if(!$result)
381
+					{
317 382
 						$this->errors[$record_num] = $this->bocontacts->error;
318
-					} else {
383
+					}
384
+					else
385
+					{
319 386
 						$this->results[$_action]++;
320 387
 						// This does nothing (yet?) but update the identifier
321 388
 						$record->save($result);
@@ -333,7 +400,8 @@  discard block
 block discarded – undo
333 400
 	 *
334 401
 	 * @return string name
335 402
 	 */
336
-	public static function get_name() {
403
+	public static function get_name()
404
+	{
337 405
 		return lang('Addressbook CSV import');
338 406
 	}
339 407
 
@@ -342,7 +410,8 @@  discard block
 block discarded – undo
342 410
 	 *
343 411
 	 * @return string descriprion
344 412
 	 */
345
-	public static function get_description() {
413
+	public static function get_description()
414
+	{
346 415
 		return lang("Imports contacts into your Addressbook from a CSV File. CSV means 'Comma Seperated Values'. However in the options Tab you can also choose other seperators.");
347 416
 	}
348 417
 
@@ -351,7 +420,8 @@  discard block
 block discarded – undo
351 420
 	 *
352 421
 	 * @return string suffix (comma seperated)
353 422
 	 */
354
-	public static function get_filesuffix() {
423
+	public static function get_filesuffix()
424
+	{
355 425
 		return 'csv';
356 426
 	}
357 427
 
@@ -367,7 +437,8 @@  discard block
 block discarded – undo
367 437
 	 * 		preserv		=> array,
368 438
 	 * )
369 439
 	 */
370
-	public function get_options_etpl() {
440
+	public function get_options_etpl()
441
+	{
371 442
 		// lets do it!
372 443
 	}
373 444
 
@@ -376,7 +447,8 @@  discard block
 block discarded – undo
376 447
 	 *
377 448
 	 * @return string etemplate name
378 449
 	 */
379
-	public function get_selectors_etpl() {
450
+	public function get_selectors_etpl()
451
+	{
380 452
 		// lets do it!
381 453
 	}
382 454
 
@@ -388,7 +460,8 @@  discard block
 block discarded – undo
388 460
         *       record_# => warning message
389 461
         *       )
390 462
         */
391
-        public function get_warnings() {
463
+        public function get_warnings()
464
+        {
392 465
 		return $this->warnings;
393 466
 	}
394 467
 
@@ -400,7 +473,8 @@  discard block
 block discarded – undo
400 473
         *       record_# => error message
401 474
         *       )
402 475
         */
403
-        public function get_errors() {
476
+        public function get_errors()
477
+        {
404 478
 		return $this->errors;
405 479
 	}
406 480
 
@@ -412,7 +486,8 @@  discard block
 block discarded – undo
412 486
         *       action => record count
413 487
         * )
414 488
         */
415
-        public function get_results() {
489
+        public function get_results()
490
+        {
416 491
                 return $this->results;
417 492
         }
418 493
 }
Please login to merge, or discard this patch.
addressbook/inc/class.addressbook_ui.inc.php 5 patches
Doc Comments   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1027,7 +1027,7 @@  discard block
 block discarded – undo
1027 1027
 	 * @param int &$failed number of failed actions (not enought permissions)
1028 1028
 	 * @param string &$action_msg translated verb for the actions, to be used in a message like %1 contacts 'deleted'
1029 1029
 	 * @param string/array $session_name 'index' or 'email', or array with session-data depending if we are in the main list or the popup
1030
-	 * @return boolean true if all actions succeded, false otherwise
1030
+	 * @return null|boolean true if all actions succeded, false otherwise
1031 1031
 	 */
1032 1032
 	function action($action,$checked,$use_all,&$success,&$failed,&$action_msg,$session_name,&$msg, $checkboxes = NULL)
1033 1033
 	{
@@ -1887,9 +1887,7 @@  discard block
 block discarded – undo
1887 1887
 	/**
1888 1888
 	* Edit a contact
1889 1889
 	*
1890
-	* @param array $content=null submitted content
1891
-	* @param int $_GET['contact_id'] contact_id mainly for popup use
1892
-	* @param bool $_GET['makecp'] true if you want to copy the contact given by $_GET['contact_id']
1890
+	* @param array $content submitted content
1893 1891
 	*/
1894 1892
 	function edit($content=null)
1895 1893
 	{
Please login to merge, or discard this patch.
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1885,12 +1885,12 @@  discard block
 block discarded – undo
1885 1885
 	}
1886 1886
 
1887 1887
 	/**
1888
-	* Edit a contact
1889
-	*
1890
-	* @param array $content=null submitted content
1891
-	* @param int $_GET['contact_id'] contact_id mainly for popup use
1892
-	* @param bool $_GET['makecp'] true if you want to copy the contact given by $_GET['contact_id']
1893
-	*/
1888
+	 * Edit a contact
1889
+	 *
1890
+	 * @param array $content=null submitted content
1891
+	 * @param int $_GET['contact_id'] contact_id mainly for popup use
1892
+	 * @param bool $_GET['makecp'] true if you want to copy the contact given by $_GET['contact_id']
1893
+	 */
1894 1894
 	function edit($content=null)
1895 1895
 	{
1896 1896
 		if (is_array($content))
@@ -3069,8 +3069,8 @@  discard block
 block discarded – undo
3069 3069
 	}
3070 3070
 
3071 3071
 	/**
3072
-	* Set up history log widget
3073
-	*/
3072
+	 * Set up history log widget
3073
+	 */
3074 3074
 	protected function setup_history(&$content, &$sel_options)
3075 3075
 	{
3076 3076
 		if ($this->contact_repository == 'ldap' || !$content['id'] ||
Please login to merge, or discard this patch.
Spacing   +410 added lines, -417 removed lines patch added patch discarded remove patch
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 	 *
80 80
 	 * @param string $contact_app
81 81
 	 */
82
-	function __construct($contact_app='addressbook')
82
+	function __construct($contact_app = 'addressbook')
83 83
 	{
84 84
 		parent::__construct($contact_app);
85 85
 
@@ -92,23 +92,23 @@  discard block
 block discarded – undo
92 92
 		);
93 93
 
94 94
 		// make sure the hook for export_limit is registered
95
-		if (!Api\Hooks::exists('export_limit','addressbook')) Api\Hooks::read(true);
95
+		if (!Api\Hooks::exists('export_limit', 'addressbook')) Api\Hooks::read(true);
96 96
 
97
-		$this->config =& $GLOBALS['egw_info']['server'];
97
+		$this->config = & $GLOBALS['egw_info']['server'];
98 98
 
99 99
 		// check if a contact specific export limit is set, if yes use it also for etemplate's csv export
100
-		$this->config['export_limit'] = $this->config['contact_export_limit'] = Api\Storage\Merge::getExportLimit($app='addressbook');
100
+		$this->config['export_limit'] = $this->config['contact_export_limit'] = Api\Storage\Merge::getExportLimit($app = 'addressbook');
101 101
 
102 102
 		if ($this->config['copy_fields'] && ($fields = is_array($this->config['copy_fields']) ?
103 103
 			$this->config['copy_fields'] : unserialize($this->config['copy_fields'])))
104 104
 		{
105 105
 			// Set country code if country name is selected
106
-			$supported_fields = $this->get_fields('supported',null,0);
107
-			if(in_array('adr_one_countrycode', $supported_fields) && in_array('adr_one_countryname',$fields))
106
+			$supported_fields = $this->get_fields('supported', null, 0);
107
+			if (in_array('adr_one_countrycode', $supported_fields) && in_array('adr_one_countryname', $fields))
108 108
 			{
109 109
 				$fields[] = 'adr_one_countrycode';
110 110
 			}
111
-			if(in_array('adr_two_countrycode', $supported_fields) && in_array('adr_two_countryname',$fields))
111
+			if (in_array('adr_two_countrycode', $supported_fields) && in_array('adr_two_countryname', $fields))
112 112
 			{
113 113
 				$fields[] = 'adr_two_countrycode';
114 114
 			}
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 	 * @param string $msg =null	message to show
125 125
 	 * @param boolean $do_email =false do an email-selection popup or the regular index-page
126 126
 	 */
127
-	function index($_content=null,$msg=null,$do_email=false)
127
+	function index($_content = null, $msg = null, $do_email = false)
128 128
 	{
129 129
 		//echo "<p>uicontacts::index(".print_r($_content,true).",'$msg')</p>\n";
130 130
 		if (($re_submit = is_array($_content)))
@@ -156,16 +156,16 @@  discard block
 block discarded – undo
156 156
 				else
157 157
 				{
158 158
 					$success = $failed = $action_msg = null;
159
-					if ($this->action($_content['nm']['action'],$_content['nm']['selected'],$_content['nm']['select_all'],
160
-						$success,$failed,$action_msg,$_content['do_email'] ? 'email' : 'index',$msg,$_content['nm']['checkboxes']))
159
+					if ($this->action($_content['nm']['action'], $_content['nm']['selected'], $_content['nm']['select_all'],
160
+						$success, $failed, $action_msg, $_content['do_email'] ? 'email' : 'index', $msg, $_content['nm']['checkboxes']))
161 161
 					{
162
-						$msg .= lang('%1 contact(s) %2',$success,$action_msg);
162
+						$msg .= lang('%1 contact(s) %2', $success, $action_msg);
163 163
 						Framework::message($msg);
164 164
 					}
165
-					elseif(is_null($msg))
165
+					elseif (is_null($msg))
166 166
 					{
167
-						$msg .= lang('%1 contact(s) %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed);
168
-						Framework::message($msg,'error');
167
+						$msg .= lang('%1 contact(s) %2, %3 failed because of insufficent rights !!!', $success, $action_msg, $failed);
168
+						Framework::message($msg, 'error');
169 169
 					}
170 170
 					$msg = '';
171 171
 				}
@@ -185,9 +185,9 @@  discard block
 block discarded – undo
185 185
 			}
186 186
 			$typeselection = $_content['nm']['col_filter']['tid'];
187 187
 		}
188
-		elseif($_GET['add_list'])
188
+		elseif ($_GET['add_list'])
189 189
 		{
190
-			$list = $this->add_list($_GET['add_list'],$_GET['owner']?$_GET['owner']:$this->user);
190
+			$list = $this->add_list($_GET['add_list'], $_GET['owner'] ? $_GET['owner'] : $this->user);
191 191
 			if ($list === true)
192 192
 			{
193 193
 				$msg = lang('List already exists!');
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 		);
207 207
 		$to = $_content['nm']['to'];
208 208
 		$content = array();
209
-		if($msg || $_GET['msg'])
209
+		if ($msg || $_GET['msg'])
210 210
 		{
211 211
 			Framework::message($msg ? $msg : $_GET['msg']);
212 212
 		}
@@ -215,23 +215,23 @@  discard block
 block discarded – undo
215 215
 		if (!is_array($content['nm']))
216 216
 		{
217 217
 			$content['nm'] = array(
218
-				'get_rows'       =>	'addressbook.addressbook_ui.get_rows',	// I  method/callback to request the data for the rows eg. 'notes.bo.get_rows'
219
-				'bottom_too'     => false,		// I  show the nextmatch-line (arrows, filters, search, ...) again after the rows
220
-				'never_hide'     => True,		// I  never hide the nextmatch-line if less then maxmatch entrie
221
-				'start'          =>	0,			// IO position in list
222
-				'cat_id'         =>	'',			// IO category, if not 'no_cat' => True
223
-				'search'         =>	'',			// IO search pattern
224
-				'order'          =>	'n_family',	// IO name of the column to sort after (optional for the sortheaders)
225
-				'sort'           =>	'ASC',		// IO direction of the sort: 'ASC' or 'DESC'
226
-				'col_filter'     =>	array(),	// IO array of column-name value pairs (optional for the filterheaders)
218
+				'get_rows'       =>	'addressbook.addressbook_ui.get_rows', // I  method/callback to request the data for the rows eg. 'notes.bo.get_rows'
219
+				'bottom_too'     => false, // I  show the nextmatch-line (arrows, filters, search, ...) again after the rows
220
+				'never_hide'     => True, // I  never hide the nextmatch-line if less then maxmatch entrie
221
+				'start'          =>	0, // IO position in list
222
+				'cat_id'         =>	'', // IO category, if not 'no_cat' => True
223
+				'search'         =>	'', // IO search pattern
224
+				'order'          =>	'n_family', // IO name of the column to sort after (optional for the sortheaders)
225
+				'sort'           =>	'ASC', // IO direction of the sort: 'ASC' or 'DESC'
226
+				'col_filter'     =>	array(), // IO array of column-name value pairs (optional for the filterheaders)
227 227
 				//'cat_id_label' => lang('Categories'),
228 228
 				//'filter_label' => lang('Addressbook'),	// I  label for filter    (optional)
229
-				'filter'         =>	'',	// =All	// IO filter, if not 'no_filter' => True
230
-				'filter_no_lang' => True,		// I  set no_lang for filter (=dont translate the options)
231
-				'no_filter2'     => True,		// I  disable the 2. filter (params are the same as for filter)
229
+				'filter'         =>	'', // =All	// IO filter, if not 'no_filter' => True
230
+				'filter_no_lang' => True, // I  set no_lang for filter (=dont translate the options)
231
+				'no_filter2'     => True, // I  disable the 2. filter (params are the same as for filter)
232 232
 				//'filter2_label'=>	lang('Distribution lists'),			// IO filter2, if not 'no_filter2' => True
233
-				'filter2'        =>	'',			// IO filter2, if not 'no_filter2' => True
234
-				'filter2_no_lang'=> True,		// I  set no_lang for filter2 (=dont translate the options)
233
+				'filter2'        =>	'', // IO filter2, if not 'no_filter2' => True
234
+				'filter2_no_lang'=> True, // I  set no_lang for filter2 (=dont translate the options)
235 235
 				'lettersearch'   => true,
236 236
 				'do_email'       => $do_email ? 1 : 0,
237 237
 				// using a positiv list now, as we constantly adding new columns in addressbook, but not removing them from default
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 				/* old negative list
242 242
 				'default_cols'   => '!cat_id,contact_created_contact_modified,distribution_list,contact_id,owner,room',*/
243 243
 				'filter2_onchange' => "app.addressbook.filter2_onchange();",
244
-				'manual'         => $do_email ? ' ' : false,	// space for the manual icon
244
+				'manual'         => $do_email ? ' ' : false, // space for the manual icon
245 245
 				//'actions'        => $this->get_actions(),		// set on each request, as it depends on some filters
246 246
 				'row_id'         => 'id',
247 247
 				'row_modified'   => 'modified',
@@ -258,13 +258,13 @@  discard block
 block discarded – undo
258 258
 			// use the state of the last session stored in the user prefs
259 259
 			if (($state = @unserialize($this->prefs[$do_email ? 'email_state' : 'index_state'])))
260 260
 			{
261
-				$content['nm'] = array_merge($content['nm'],$state);
261
+				$content['nm'] = array_merge($content['nm'], $state);
262 262
 			}
263 263
 		}
264 264
 		$sel_options['cat_id'] = array('' => lang('All categories'), '0' => lang('None'));
265 265
 
266 266
 		// Edit and delete list actions depends on permissions
267
-		if($this->get_lists(Acl::EDIT))
267
+		if ($this->get_lists(Acl::EDIT))
268 268
 		{
269 269
 			$content['nm']['placeholder_actions'][] = 'rename_list';
270 270
 			$content['nm']['placeholder_actions'][] = 'delete_list';
@@ -277,11 +277,11 @@  discard block
 block discarded – undo
277 277
 		if (isset($typeselection)) $content['nm']['col_filter']['tid'] = $typeselection;
278 278
 		// save the tid for use in creating new addressbook entrys via UI. Current tid is to be used as type of new entrys
279 279
 		//error_log(__METHOD__.__LINE__.' '.$content['nm']['col_filter']['tid']);
280
-		Api\Cache::setSession('addressbook','active_tid',$content['nm']['col_filter']['tid']);
280
+		Api\Cache::setSession('addressbook', 'active_tid', $content['nm']['col_filter']['tid']);
281 281
 		if ($this->lists_available())
282 282
 		{
283
-			$sel_options['filter2'] = $this->get_lists(Acl::READ,array('' => lang('No distribution list')));
284
-			$sel_options['filter2']['add'] = lang('Add a new list').'...';	// put it at the end
283
+			$sel_options['filter2'] = $this->get_lists(Acl::READ, array('' => lang('No distribution list')));
284
+			$sel_options['filter2']['add'] = lang('Add a new list').'...'; // put it at the end
285 285
 		}
286 286
 		if ($do_email)
287 287
 		{
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 			$content['nm']['header_left'] = 'addressbook.email.left';
300 300
 		}
301 301
 		// Organisation stuff is not (yet) availible with ldap
302
-		elseif($GLOBALS['egw_info']['server']['contact_repository'] != 'ldap')
302
+		elseif ($GLOBALS['egw_info']['server']['contact_repository'] != 'ldap')
303 303
 		{
304 304
 			$content['nm']['header_left'] = 'addressbook.index.left';
305 305
 		}
@@ -312,12 +312,12 @@  discard block
 block discarded – undo
312 312
 		$sel_options['adr_one_countrycode']['-custom-'] = lang('No country selected');
313 313
 
314 314
 		// if there is any export limit set, pass it on to the nextmatch, to be evaluated by the export
315
-		if (isset($this->config['contact_export_limit']) && (int)$this->config['contact_export_limit']) $content['nm']['export_limit']=$this->config['contact_export_limit'];
315
+		if (isset($this->config['contact_export_limit']) && (int)$this->config['contact_export_limit']) $content['nm']['export_limit'] = $this->config['contact_export_limit'];
316 316
 
317 317
 		// dont show tid-selection if we have only one content_type
318 318
 		// be a bit more sophisticated about it
319 319
 		$availabletypes = array_keys($this->content_types);
320
-		if ($content['nm']['col_filter']['tid'] && !in_array($content['nm']['col_filter']['tid'],$availabletypes))
320
+		if ($content['nm']['col_filter']['tid'] && !in_array($content['nm']['col_filter']['tid'], $availabletypes))
321 321
 		{
322 322
 			//_debug_array(array('Typefilter:'=> $content['nm']['col_filter']['tid'],'Available Types:'=>$availabletypes,'action:'=>'remove invalid filter'));
323 323
 			unset($content['nm']['col_filter']['tid']);
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
 		if (!isset($content['nm']['col_filter']['tid'])) $content['nm']['col_filter']['tid'] = $availabletypes[0];
326 326
 		if (count($this->content_types) > 1)
327 327
 		{
328
-			foreach($this->content_types as $tid => $data)
328
+			foreach ($this->content_types as $tid => $data)
329 329
 			{
330 330
 				$sel_options['tid'][$tid] = $data['name'];
331 331
 			}
@@ -343,22 +343,22 @@  discard block
 block discarded – undo
343 343
 
344 344
 		$content['nm']['actions'] = $this->get_actions($content['nm']['col_filter']['tid'], $content['nm']['org_view']);
345 345
 
346
-		if (!isset($sel_options['org_view'][(string) $content['nm']['org_view']]))
346
+		if (!isset($sel_options['org_view'][(string)$content['nm']['org_view']]))
347 347
 		{
348 348
 			$sel_options['org_view'] += $this->_get_org_name((string)$content['nm']['org_view']);
349 349
 		}
350 350
 		// unset the filters regarding organisations, when there is no organisation selected
351
-		if (empty($sel_options['org_view'][(string) $content['nm']['org_view']]) || stripos($org_view,":") === false )
351
+		if (empty($sel_options['org_view'][(string)$content['nm']['org_view']]) || stripos($org_view, ":") === false)
352 352
 		{
353 353
 			unset($content['nm']['col_filter']['org_name']);
354 354
 			unset($content['nm']['col_filter']['org_unit']);
355 355
 			unset($content['nm']['col_filter']['adr_one_locality']);
356 356
 		}
357
-		$content['nm']['org_view_label'] = $sel_options['org_view'][(string) $content['nm']['org_view']];
357
+		$content['nm']['org_view_label'] = $sel_options['org_view'][(string)$content['nm']['org_view']];
358 358
 
359 359
 		$this->tmpl->read($do_email ? 'addressbook.email' : 'addressbook.index');
360 360
 		return $this->tmpl->exec($do_email ? 'addressbook.addressbook_ui.emailpopup' : 'addressbook.addressbook_ui.index',
361
-			$content,$sel_options,array(),$preserv,$do_email ? 2 : 0);
361
+			$content, $sel_options, array(), $preserv, $do_email ? 2 : 0);
362 362
 	}
363 363
 
364 364
 	/**
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
 	 * @param string $tid_filter =null
368 368
 	 * @return array see Etemplate\Widget\Nextmatch::get_actions()
369 369
 	 */
370
-	public function get_actions($tid_filter=null)
370
+	public function get_actions($tid_filter = null)
371 371
 	{
372 372
 		// Contact view
373 373
 		$actions = array(
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
 				'caption' => 'CRM-View',
376 376
 				'default' => $GLOBALS['egw_info']['user']['preferences']['addressbook']['crm_list'] != '~edit~',
377 377
 				'allowOnMultiple' => false,
378
-				'group' => $group=1,
378
+				'group' => $group = 1,
379 379
 				'onExecute' => 'javaScript:app.addressbook.view',
380 380
 				'disableClass' => 'contact_organisation',
381 381
 				'hideOnDisabled' => true,
@@ -418,14 +418,14 @@  discard block
 block discarded – undo
418 418
 		);
419 419
 		// CRM view options
420 420
 		$crm_count = 0;
421
-		$crm_apps = array('infolog','tracker');
422
-		foreach($crm_apps as $app)
421
+		$crm_apps = array('infolog', 'tracker');
422
+		foreach ($crm_apps as $app)
423 423
 		{
424 424
 			if ($GLOBALS['egw_info']['user']['apps'][$app]) $crm_count++;
425 425
 		}
426
-		if($crm_count > 1)
426
+		if ($crm_count > 1)
427 427
 		{
428
-			foreach($crm_apps as $app)
428
+			foreach ($crm_apps as $app)
429 429
 			{
430 430
 				$actions['view']['children']["view-$app"] = array(
431 431
 					'caption' => $app,
@@ -440,7 +440,7 @@  discard block
 block discarded – undo
440 440
 				'caption' => 'View',
441 441
 				'default' => true,
442 442
 				'allowOnMultiple' => false,
443
-				'group' => $group=1,
443
+				'group' => $group = 1,
444 444
 				'disableClass' => 'contact_contact',
445 445
 				'hideOnDisabled' => true
446 446
 			),
@@ -455,23 +455,23 @@  discard block
 block discarded – undo
455 455
 			),
456 456
 		);
457 457
 
458
-		++$group;	// other AB related stuff group: lists, AB's, categories
458
+		++$group; // other AB related stuff group: lists, AB's, categories
459 459
 		// categories submenu
460 460
 		$actions['cat'] = array(
461 461
 			'caption' => 'Categories',
462 462
 			'group' => $group,
463 463
 			'children' => array(
464 464
 				'cat_add' => Etemplate\Widget\Nextmatch::category_action(
465
-					'addressbook',$group,'Add category', 'cat_add_',
466
-					true, 0,Etemplate\Widget\Nextmatch::DEFAULT_MAX_MENU_LENGTH,false
467
-				)+array(
465
+					'addressbook', $group, 'Add category', 'cat_add_',
466
+					true, 0, Etemplate\Widget\Nextmatch::DEFAULT_MAX_MENU_LENGTH, false
467
+				) + array(
468 468
 					'icon' => 'foldertree_nolines_plus',
469 469
 					'disableClass' => 'rowNoEdit',
470 470
 				),
471 471
 				'cat_del' => Etemplate\Widget\Nextmatch::category_action(
472
-					'addressbook',$group,'Delete category', 'cat_del_',
473
-					true, 0,Etemplate\Widget\Nextmatch::DEFAULT_MAX_MENU_LENGTH,false
474
-				)+array(
472
+					'addressbook', $group, 'Delete category', 'cat_del_',
473
+					true, 0, Etemplate\Widget\Nextmatch::DEFAULT_MAX_MENU_LENGTH, false
474
+				) + array(
475 475
 					'icon' => 'foldertree_nolines_minus',
476 476
 					'disableClass' => 'rowNoEdit',
477 477
 				),
@@ -498,7 +498,7 @@  discard block
 block discarded – undo
498 498
 					'children' => $add_lists,
499 499
 					'prefix' => 'to_list_',
500 500
 					'icon' => 'foldertree_nolines_plus',
501
-					'enabled' => ($add_lists?true:false), // if there are editable lists, allow to add a contact to one of them,
501
+					'enabled' => ($add_lists ? true : false), // if there are editable lists, allow to add a contact to one of them,
502 502
 					//'disableClass' => 'rowNoEdit',	  // wether you are allowed to edit the contact or not, as you alter a list, not the contact
503 503
 				),
504 504
 				'remove_from_list' => array(
@@ -507,14 +507,14 @@  discard block
 block discarded – undo
507 507
 					'icon' => 'foldertree_nolines_minus',
508 508
 					'enabled' => 'javaScript:app.addressbook.nm_compare_field',
509 509
 					'fieldId' => 'exec[nm][filter2]',
510
-					'fieldValue' => '!',	// enable if list != ''
510
+					'fieldValue' => '!', // enable if list != ''
511 511
 				),
512 512
 				'rename_list' => array(
513 513
 					'caption' => 'Rename selected distribution list',
514 514
 					'icon' => 'edit',
515 515
 					'enabled' => 'javaScript:app.addressbook.nm_compare_field',
516 516
 					'fieldId' => 'exec[nm][filter2]',
517
-					'fieldValue' => '!',	// enable if list != ''
517
+					'fieldValue' => '!', // enable if list != ''
518 518
 					'onExecute' => 'javaScript:app.addressbook.rename_list'
519 519
 				),
520 520
 				'delete_list' => array(
@@ -523,10 +523,10 @@  discard block
 block discarded – undo
523 523
 					'icon' => 'delete',
524 524
 					'enabled' => 'javaScript:app.addressbook.nm_compare_field',
525 525
 					'fieldId' => 'exec[nm][filter2]',
526
-					'fieldValue' => '!',	// enable if list != ''
526
+					'fieldValue' => '!', // enable if list != ''
527 527
 				),
528 528
 			);
529
-			if(is_subclass_of('etemplate', 'etemplate_new'))
529
+			if (is_subclass_of('etemplate', 'etemplate_new'))
530 530
 			{
531 531
 				$actions['lists']['children']['remove_from_list']['fieldId'] = 'filter2';
532 532
 				$actions['lists']['children']['rename_list']['fieldId'] = 'filter2';
@@ -536,18 +536,18 @@  discard block
 block discarded – undo
536 536
 		// move to AB
537 537
 		if (($move2addressbooks = $this->get_addressbooks(Acl::ADD)))	// do we have addressbooks, we should
538 538
 		{
539
-			unset($move2addressbooks[0]);	// do not offer action to move contact to an account, as we dont support that currrently
540
-			foreach($move2addressbooks as $owner => $label)
539
+			unset($move2addressbooks[0]); // do not offer action to move contact to an account, as we dont support that currrently
540
+			foreach ($move2addressbooks as $owner => $label)
541 541
 			{
542 542
 				$icon = $type_label = null;
543
-				$this->type_icon((int)$owner, substr($owner,-1) == 'p', 'n', $icon, $type_label);
543
+				$this->type_icon((int)$owner, substr($owner, -1) == 'p', 'n', $icon, $type_label);
544 544
 				$move2addressbooks[$owner] = array(
545 545
 					'icon' => $icon,
546 546
 					'caption' => $label,
547 547
 				);
548 548
 			}
549 549
 			// copy checkbox
550
-			$move2addressbooks= array(
550
+			$move2addressbooks = array(
551 551
 				'copy' =>array(
552 552
 					'id' => 'move_to_copy',
553 553
 					'caption' => 'Copy instead of move',
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
 			'hideOnMobile' => true
572 572
 		);
573 573
 
574
-		++$group;	// integration with other apps: infolog, calendar, filemanager
574
+		++$group; // integration with other apps: infolog, calendar, filemanager
575 575
 		if ($GLOBALS['egw_info']['user']['apps']['infolog'])
576 576
 		{
577 577
 			$actions['infolog_app'] = array(
@@ -591,7 +591,7 @@  discard block
 block discarded – undo
591 591
 						'icon' => 'new',
592 592
 						'url' => 'menuaction=infolog.infolog_ui.edit&type=task&action=addressbook&action_id=$id',
593 593
 						'popup' => Link::get_registry('infolog', 'add_popup'),
594
-						'onExecute' => 'javaScript:app.addressbook.add_task',	// call server for org-view only
594
+						'onExecute' => 'javaScript:app.addressbook.add_task', // call server for org-view only
595 595
 					),
596 596
 				),
597 597
 				'hideOnMobile' => true
@@ -608,7 +608,7 @@  discard block
 block discarded – undo
608 608
 						'caption' => 'Show',
609 609
 						'icon' => 'view',
610 610
 						'onExecute' => 'javaScript:app.addressbook.view_calendar',
611
-						'targetapp' => 'calendar',	// open in calendar tab,
611
+						'targetapp' => 'calendar', // open in calendar tab,
612 612
 						'hideOnDisabled' => true,
613 613
 					),
614 614
 					'calendar_add' => array(
@@ -687,7 +687,7 @@  discard block
 block discarded – undo
687 687
 			'caption' => 'GeoLocation',
688 688
 			'icon' => 'map',
689 689
 			'group' => ++$group,
690
-			'children' => array (
690
+			'children' => array(
691 691
 				'private' => array(
692 692
 					'caption' => 'Private Address',
693 693
 					'enabled' => 'javaScript:app.addressbook.geoLocation_enabled',
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
 		);
705 705
 		// check if user is an admin or the export is not generally turned off (contact_export_limit is non-numerical, eg. no)
706 706
 		$exception = Api\Storage\Merge::is_export_limit_excepted();
707
-		if ((isset($GLOBALS['egw_info']['user']['apps']['admin']) || $exception)  || !$this->config['contact_export_limit'] || (int)$this->config['contact_export_limit'])
707
+		if ((isset($GLOBALS['egw_info']['user']['apps']['admin']) || $exception) || !$this->config['contact_export_limit'] || (int)$this->config['contact_export_limit'])
708 708
 		{
709 709
 			$actions['export'] = array(
710 710
 				'caption' => 'Export',
@@ -719,7 +719,7 @@  discard block
 block discarded – undo
719 719
 					),
720 720
 					'vcard'  => array(
721 721
 						'caption' => 'Export as VCard',
722
-						'postSubmit' => true,	// download needs post submit (not Ajax) to work
722
+						'postSubmit' => true, // download needs post submit (not Ajax) to work
723 723
 						'icon' => Vfs::mime_icon('text/vcard'),
724 724
 					),
725 725
 				),
@@ -731,7 +731,7 @@  discard block
 block discarded – undo
731 731
 			$this->prefs['document_dir'], $group, 'Insert in document', 'document_',
732 732
 			$this->prefs['default_document'], $this->config['contact_export_limit']
733 733
 		);
734
-		if (isset($GLOBALS['egw_info']['apps']['stylite']) && ($GLOBALS['egw_info']['user']['apps']['felamimail']||$GLOBALS['egw_info']['user']['apps']['mail']))
734
+		if (isset($GLOBALS['egw_info']['apps']['stylite']) && ($GLOBALS['egw_info']['user']['apps']['felamimail'] || $GLOBALS['egw_info']['user']['apps']['mail']))
735 735
 		{
736 736
 			$actions['mail'] = array(
737 737
 				'caption' => lang('Mail VCard'),
@@ -754,7 +754,7 @@  discard block
 block discarded – undo
754 754
 				'disableClass' => 'rowNoDelete',
755 755
 			);
756 756
 		}
757
-		if ($this->grants[0] & Acl::DELETE)
757
+		if ($this->grants[0]&Acl::DELETE)
758 758
 		{
759 759
 			$actions['delete_account'] = array(
760 760
 				'caption' => 'Delete',
@@ -767,7 +767,7 @@  discard block
 block discarded – undo
767 767
 			);
768 768
 			$actions['delete']['hideOnDisabled'] = true;
769 769
 		}
770
-		if($tid_filter == 'D')
770
+		if ($tid_filter == 'D')
771 771
 		{
772 772
 			$actions['undelete'] = array(
773 773
 				'caption' => 'Un-delete',
@@ -778,7 +778,7 @@  discard block
 block discarded – undo
778 778
 		}
779 779
 		if (isset($actions['export']['children']['csv']) &&
780 780
 			(!isset($GLOBALS['egw_info']['user']['apps']['importexport']) ||
781
-			!importexport_helper_functions::has_definitions('addressbook','export')))
781
+			!importexport_helper_functions::has_definitions('addressbook', 'export')))
782 782
 		{
783 783
 			unset($actions['export']['children']['csv']);
784 784
 		}
@@ -811,13 +811,13 @@  discard block
 block discarded – undo
811 811
 	private function _get_org_name($org)
812 812
 	{
813 813
 		$org_name = array();
814
-		if (strpos($org,'*AND*')!== false) $org = str_replace('*AND*','&',$org);
815
-		foreach(explode('|||',$org) as $part)
814
+		if (strpos($org, '*AND*') !== false) $org = str_replace('*AND*', '&', $org);
815
+		foreach (explode('|||', $org) as $part)
816 816
 		{
817
-			list(,$name) = explode(':',$part,2);
817
+			list(,$name) = explode(':', $part, 2);
818 818
 			if ($name) $org_name[] = $name;
819 819
 		}
820
-		$name = implode(': ',$org_name);
820
+		$name = implode(': ', $org_name);
821 821
 		return $name ? array($org => $name) : array();
822 822
 	}
823 823
 
@@ -827,12 +827,12 @@  discard block
 block discarded – undo
827 827
 	 * @param array $content =null submitted content
828 828
 	 * @param string $msg =null	message to show
829 829
 	 */
830
-	function emailpopup($content=null,$msg=null)
830
+	function emailpopup($content = null, $msg = null)
831 831
 	{
832
-		if (strpos($GLOBALS['egw_info']['flags']['java_script'],'addEmail') === false)
832
+		if (strpos($GLOBALS['egw_info']['flags']['java_script'], 'addEmail') === false)
833 833
 		{
834 834
 			$handler = 'opener.addEmail(to,email)';
835
-			$GLOBALS['egw_info']['flags']['java_script'].= "
835
+			$GLOBALS['egw_info']['flags']['java_script'] .= "
836 836
 <script>
837 837
 window.egw_LAB.wait(function() {
838 838
 	window.focus();
@@ -862,7 +862,7 @@  discard block
 block discarded – undo
862 862
 </script>
863 863
 ";
864 864
 		}
865
-		return $this->index($content,$msg,true);
865
+		return $this->index($content, $msg, true);
866 866
 	}
867 867
 
868 868
 	/**
@@ -876,19 +876,19 @@  discard block
 block discarded – undo
876 876
 	{
877 877
 		$org_contacts = array();
878 878
 		$query = !$_query ? Api\Cache::getSession('addressbook', 'index') : $_query;
879
-		$query['num_rows'] = -1;	// all
880
-		if(!is_array($query['col_filter'])) $query['col_filter'] = array();
879
+		$query['num_rows'] = -1; // all
880
+		if (!is_array($query['col_filter'])) $query['col_filter'] = array();
881 881
 
882
-		if(!is_array($org)) $org = array($org);
883
-		foreach($org as $org_name)
882
+		if (!is_array($org)) $org = array($org);
883
+		foreach ($org as $org_name)
884 884
 		{
885 885
 			$query['org_view'] = $org_name;
886 886
 			$checked = array();
887 887
 			$readonlys = null;
888
-			$this->get_rows($query,$checked,$readonlys,true);	// true = only return the id's
889
-			if($checked[0])
888
+			$this->get_rows($query, $checked, $readonlys, true); // true = only return the id's
889
+			if ($checked[0])
890 890
 			{
891
-				$org_contacts = array_merge($org_contacts,$checked);
891
+				$org_contacts = array_merge($org_contacts, $checked);
892 892
 			}
893 893
 		}
894 894
 		Api\Json\Response::get()->data(array_unique($org_contacts));
@@ -902,33 +902,33 @@  discard block
 block discarded – undo
902 902
 	function infolog_org_view($org)
903 903
 	{
904 904
 		$query = Api\Cache::getSession('addressbook', 'index');
905
-		$query['num_rows'] = -1;	// all
905
+		$query['num_rows'] = -1; // all
906 906
 		$query['org_view'] = $org;
907 907
 		$query['searchletter'] = '';
908 908
 		$checked = $readonlys = null;
909
-		$this->get_rows($query,$checked,$readonlys,true);	// true = only return the id's
909
+		$this->get_rows($query, $checked, $readonlys, true); // true = only return the id's
910 910
 
911 911
 		if (count($checked) > 1)	// use a nicely formatted org-name as title in infolog
912 912
 		{
913 913
 			$parts = array();
914
-			if (strpos($org,'*AND*')!== false) $org = str_replace('*AND*','&',$org);
915
-			foreach(explode('|||',$org) as $part)
914
+			if (strpos($org, '*AND*') !== false) $org = str_replace('*AND*', '&', $org);
915
+			foreach (explode('|||', $org) as $part)
916 916
 			{
917
-				list(,$part) = explode(':',$part,2);
917
+				list(,$part) = explode(':', $part, 2);
918 918
 				if ($part) $parts[] = $part;
919 919
 			}
920
-			$org = implode(', ',$parts);
920
+			$org = implode(', ', $parts);
921 921
 		}
922 922
 		else
923 923
 		{
924
-			$org = '';	// use infolog default of link-title
924
+			$org = ''; // use infolog default of link-title
925 925
 		}
926
-		Egw::redirect_link('/index.php',array(
926
+		Egw::redirect_link('/index.php', array(
927 927
 			'menuaction' => 'infolog.infolog_ui.index',
928 928
 			'action' => 'addressbook',
929
-			'action_id' => implode(',',$checked),
929
+			'action_id' => implode(',', $checked),
930 930
 			'action_title' => $org,
931
-		),'infolog');
931
+		), 'infolog');
932 932
 	}
933 933
 
934 934
 	function ajax_add_whole_list($list, $email_type = 'email')
@@ -936,7 +936,7 @@  discard block
 block discarded – undo
936 936
 		$query = Api\Cache::getSession('addressbook', 'email');
937 937
 		$query['filter2'] = (int)$list;
938 938
 		$success = $failed = $action_msg = $msg = null;
939
-		$this->action($email_type,array(),true,$success,$failed,$action_msg,$query,$msg);
939
+		$this->action($email_type, array(), true, $success, $failed, $action_msg, $query, $msg);
940 940
 
941 941
 		$response = Api\Json\Response::get();
942 942
 
@@ -945,8 +945,7 @@  discard block
 block discarded – undo
945 945
 		// close window only if no errors AND something added
946 946
 		if ($failed || !$success)
947 947
 		{
948
-			if (!$msg) $msg = $failed ? lang('%1 contact(s) %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed) :
949
-				lang('%1 contact(s) %2',$success,$action_msg);
948
+			if (!$msg) $msg = $failed ? lang('%1 contact(s) %2, %3 failed because of insufficent rights !!!', $success, $action_msg, $failed) : lang('%1 contact(s) %2', $success, $action_msg);
950 949
 
951 950
 			$response->addScript("alert('".addslashes($msg)."')");
952 951
 			// reset the filter
@@ -954,7 +953,7 @@  discard block
 block discarded – undo
954 953
 		}
955 954
 		else
956 955
 		{
957
-			if (!$msg) $msg = lang('%1 contact(s) %2',$success,$action_msg);
956
+			if (!$msg) $msg = lang('%1 contact(s) %2', $success, $action_msg);
958 957
 			$response->addScript("alert('".addslashes($msg)."')");
959 958
 			$response->addScript('egw(window).close();');
960 959
 		}
@@ -975,27 +974,27 @@  discard block
 block discarded – undo
975 974
 		$owner = $_owner ? $_owner : $GLOBALS['egw_info']['user']['account_id'];
976 975
 
977 976
 		// Check for valid list & permissions
978
-		if(!(int)$list_id && !$this->check_list(null,EGW_ACL_ADD|EGW_ACL_EDIT,$owner))
977
+		if (!(int)$list_id && !$this->check_list(null, EGW_ACL_ADD|EGW_ACL_EDIT, $owner))
979 978
 		{
980
-			Api\Json\Response::get()->apply('egw.message', array(  lang('List creation failed, no rights!'),'error'));
979
+			Api\Json\Response::get()->apply('egw.message', array(lang('List creation failed, no rights!'), 'error'));
981 980
 			return;
982 981
 		}
983 982
 		if ((int)$list_id && !$this->check_list((int)$list_id, Acl::EDIT, $owner))
984 983
 		{
985
-			Api\Json\Response::get()->apply('egw.message', array(  lang('Insufficent rights to edit this list!'),'error'));
984
+			Api\Json\Response::get()->apply('egw.message', array(lang('Insufficent rights to edit this list!'), 'error'));
986 985
 			return;
987 986
 		}
988 987
 
989 988
 		$list = array('list_owner' => $owner);
990 989
 
991 990
 		// Rename
992
-		if($list_id)
991
+		if ($list_id)
993 992
 		{
994 993
 			$list = $this->read_list((int)$list_id);
995 994
 		}
996 995
 		$list['list_name'] = $new_name;
997 996
 
998
-		$new_id = $this->add_list(array('list_id' => (int)$list_id), $list['list_owner'],array(),$list);
997
+		$new_id = $this->add_list(array('list_id' => (int)$list_id), $list['list_owner'], array(), $list);
999 998
 
1000 999
 		Api\Json\Response::get()->apply('egw.message', array(
1001 1000
 			$new_id == $list_id ? lang('Distribution list renamed') : lang('List created'),
@@ -1010,7 +1009,7 @@  discard block
 block discarded – undo
1010 1009
 	 *
1011 1010
 	 * @param type $account_id
1012 1011
 	 */
1013
-	function ajax_get_contact ($account_id)
1012
+	function ajax_get_contact($account_id)
1014 1013
 	{
1015 1014
 		$bo = new Api\Contacts();
1016 1015
 		$contact = $bo->read('account:'.$account_id[0]);
@@ -1029,78 +1028,78 @@  discard block
 block discarded – undo
1029 1028
 	 * @param string/array $session_name 'index' or 'email', or array with session-data depending if we are in the main list or the popup
1030 1029
 	 * @return boolean true if all actions succeded, false otherwise
1031 1030
 	 */
1032
-	function action($action,$checked,$use_all,&$success,&$failed,&$action_msg,$session_name,&$msg, $checkboxes = NULL)
1031
+	function action($action, $checked, $use_all, &$success, &$failed, &$action_msg, $session_name, &$msg, $checkboxes = NULL)
1033 1032
 	{
1034 1033
 		//echo "<p>uicontacts::action('$action',".print_r($checked,true).','.(int)$use_all.",...)</p>\n";
1035 1034
 		$success = $failed = 0;
1036
-		if ($use_all || in_array($action,array('remove_from_list','delete_list')))
1035
+		if ($use_all || in_array($action, array('remove_from_list', 'delete_list')))
1037 1036
 		{
1038 1037
 			// get the whole selection
1039 1038
 			$query = is_array($session_name) ? $session_name : Api\Cache::getSession('addressbook', $session_name);
1040 1039
 
1041 1040
 			if ($use_all)
1042 1041
 			{
1043
-				@set_time_limit(0);			// switch off the execution time limit, as it's for big selections to small
1044
-				$query['num_rows'] = -1;	// all
1042
+				@set_time_limit(0); // switch off the execution time limit, as it's for big selections to small
1043
+				$query['num_rows'] = -1; // all
1045 1044
 				$readonlys = null;
1046
-				$this->get_rows($query,$checked,$readonlys,true);	// true = only return the id's
1045
+				$this->get_rows($query, $checked, $readonlys, true); // true = only return the id's
1047 1046
 			}
1048 1047
 		}
1049 1048
 		// replace org_name:* id's with all id's of that org
1050 1049
 		$org_contacts = array();
1051
-		foreach((array)$checked as $n => $id)
1050
+		foreach ((array)$checked as $n => $id)
1052 1051
 		{
1053
-			if (substr($id,0,9) == 'org_name:')
1052
+			if (substr($id, 0, 9) == 'org_name:')
1054 1053
 			{
1055 1054
 				if (count($checked) == 1 && !count($org_contacts) && $action == 'infolog')
1056 1055
 				{
1057
-					return $this->infolog_org_view($id);	// uses the org-name, instead of 'selected contacts'
1056
+					return $this->infolog_org_view($id); // uses the org-name, instead of 'selected contacts'
1058 1057
 				}
1059 1058
 				unset($checked[$n]);
1060 1059
 				$query = Api\Cache::getSession('addressbook', $session_name);
1061
-				$query['num_rows'] = -1;	// all
1060
+				$query['num_rows'] = -1; // all
1062 1061
 				$query['org_view'] = $id;
1063 1062
 				unset($query['filter2']);
1064 1063
 				$extra = $readonlys = null;
1065
-				$this->get_rows($query,$extra,$readonlys,true);	// true = only return the id's
1066
-				if ($extra[0]) $org_contacts = array_merge($org_contacts,$extra);
1064
+				$this->get_rows($query, $extra, $readonlys, true); // true = only return the id's
1065
+				if ($extra[0]) $org_contacts = array_merge($org_contacts, $extra);
1067 1066
 			}
1068 1067
 		}
1069
-		if ($org_contacts) $checked = array_unique($checked ? array_merge($checked,$org_contacts) : $org_contacts);
1068
+		if ($org_contacts) $checked = array_unique($checked ? array_merge($checked, $org_contacts) : $org_contacts);
1070 1069
 		//_debug_array($checked); exit;
1071 1070
 
1072
-		if (substr($action,0,8) == 'move_to_')
1071
+		if (substr($action, 0, 8) == 'move_to_')
1073 1072
 		{
1074
-			$action = (int)substr($action,8).(substr($action,-1) == 'p' ? 'p' : '');
1073
+			$action = (int)substr($action, 8).(substr($action, -1) == 'p' ? 'p' : '');
1075 1074
 		}
1076
-		elseif (substr($action,0,8) == 'to_list_')
1075
+		elseif (substr($action, 0, 8) == 'to_list_')
1077 1076
 		{
1078
-			$to_list = (int)substr($action,8);
1077
+			$to_list = (int)substr($action, 8);
1079 1078
 			$action = 'to_list';
1080 1079
 		}
1081
-		elseif (substr($action,0,9) == 'document_')
1080
+		elseif (substr($action, 0, 9) == 'document_')
1082 1081
 		{
1083
-			$document = substr($action,9);
1082
+			$document = substr($action, 9);
1084 1083
 			$action = 'document';
1085 1084
 		}
1086
-		elseif(substr($action,0,4) == 'cat_')	// cat_add_123 or cat_del_456
1085
+		elseif (substr($action, 0, 4) == 'cat_')	// cat_add_123 or cat_del_456
1087 1086
 		{
1088 1087
 			$cat_id = (int)substr($action, 8);
1089
-			$action = substr($action,0,7);
1088
+			$action = substr($action, 0, 7);
1090 1089
 		}
1091 1090
 		// Security: stop non-admins to export more then the configured number of contacts
1092
-		if (in_array($action,array('csv','vcard')) && $this->config['contact_export_limit'] && !Api\Storage\Merge::is_export_limit_excepted() &&
1091
+		if (in_array($action, array('csv', 'vcard')) && $this->config['contact_export_limit'] && !Api\Storage\Merge::is_export_limit_excepted() &&
1093 1092
 			(!is_numeric($this->config['contact_export_limit']) || count($checked) > $this->config['contact_export_limit']))
1094 1093
 		{
1095 1094
 			$action_msg = lang('exported');
1096 1095
 			$failed = count($checked);
1097 1096
 			return false;
1098 1097
 		}
1099
-		switch($action)
1098
+		switch ($action)
1100 1099
 		{
1101 1100
 			case 'vcard':
1102 1101
 				$action_msg = lang('exported');
1103
-				$vcard = new addressbook_vcal('addressbook','text/vcard');
1102
+				$vcard = new addressbook_vcal('addressbook', 'text/vcard');
1104 1103
 				$vcard->export($checked);
1105 1104
 				// does not return!
1106 1105
 				$Ok = false;
@@ -1108,10 +1107,10 @@  discard block
 block discarded – undo
1108 1107
 
1109 1108
 			case 'merge':
1110 1109
 				$error_msg = null;
1111
-				$success = $this->merge($checked,$error_msg);
1110
+				$success = $this->merge($checked, $error_msg);
1112 1111
 				$failed = count($checked) - (int)$success;
1113 1112
 				$action_msg = lang('merged');
1114
-				$checked = array();	// to not start the single actions
1113
+				$checked = array(); // to not start the single actions
1115 1114
 				break;
1116 1115
 
1117 1116
 			case 'delete_list':
@@ -1119,7 +1118,7 @@  discard block
 block discarded – undo
1119 1118
 				{
1120 1119
 					$msg = lang('You need to select a distribution list');
1121 1120
 				}
1122
-				elseif($this->delete_list($query['filter2']) === false)
1121
+				elseif ($this->delete_list($query['filter2']) === false)
1123 1122
 				{
1124 1123
 					$msg = lang('Insufficent rights to delete this list!');
1125 1124
 				}
@@ -1139,49 +1138,49 @@  discard block
 block discarded – undo
1139 1138
 				return false;
1140 1139
 
1141 1140
 			case 'infolog_add':
1142
-				Framework::popup(Egw::link('/index.php',array(
1141
+				Framework::popup(Egw::link('/index.php', array(
1143 1142
 						'menuaction' => 'infolog.infolog_ui.edit',
1144 1143
 						'type' => 'task',
1145 1144
 						'action' => 'addressbook',
1146
-						'action_id' => implode(',',$checked),
1147
-					)),'_blank',Link::get_registry('infolog', 'add_popup'));
1148
-				$msg = '';	// no message, as we send none in javascript too and users sees opening popup
1145
+						'action_id' => implode(',', $checked),
1146
+					)), '_blank', Link::get_registry('infolog', 'add_popup'));
1147
+				$msg = ''; // no message, as we send none in javascript too and users sees opening popup
1149 1148
 				return false;
1150 1149
 
1151 1150
 			case 'calendar_add':	// add appointment for org-views, other views are handled directly in javascript
1152
-				Framework::popup(Egw::link('/index.php',array(
1151
+				Framework::popup(Egw::link('/index.php', array(
1153 1152
 						'menuaction' => 'calendar.calendar_uiforms.edit',
1154
-						'participants' => 'c'.implode(',c',$checked),
1155
-					)),'_blank',Link::get_registry('calendar', 'add_popup'));
1156
-				$msg = '';	// no message, as we send none in javascript too and users sees opening popup
1153
+						'participants' => 'c'.implode(',c', $checked),
1154
+					)), '_blank', Link::get_registry('calendar', 'add_popup'));
1155
+				$msg = ''; // no message, as we send none in javascript too and users sees opening popup
1157 1156
 				return false;
1158 1157
 
1159 1158
 			case 'calendar_view':	// show calendar for org-views, although all views are handled directly in javascript
1160
-				Egw::redirect_link('/index.php',array(
1159
+				Egw::redirect_link('/index.php', array(
1161 1160
 					'menuaction' => 'calendar.calendar_uiviews.index',
1162
-					'owner' => 'c'.implode(',c',$checked),
1161
+					'owner' => 'c'.implode(',c', $checked),
1163 1162
 				));
1164 1163
 		}
1165
-		foreach($checked as $id)
1164
+		foreach ($checked as $id)
1166 1165
 		{
1167
-			switch($action)
1166
+			switch ($action)
1168 1167
 			{
1169 1168
 				case 'cat_add':
1170 1169
 				case 'cat_del':
1171
-					if (($Ok = !!($contact = $this->read($id)) && $this->check_perms(Acl::EDIT,$contact)))
1170
+					if (($Ok = !!($contact = $this->read($id)) && $this->check_perms(Acl::EDIT, $contact)))
1172 1171
 					{
1173 1172
 						$action_msg = $action == 'cat_add' ? lang('categorie added') : lang('categorie delete');
1174
-						$cat_ids = $contact['cat_id'] ? explode(',', $contact['cat_id']) : array();   //existing Api\Categories
1173
+						$cat_ids = $contact['cat_id'] ? explode(',', $contact['cat_id']) : array(); //existing Api\Categories
1175 1174
 						if ($action == 'cat_add')
1176 1175
 						{
1177 1176
 							$cat_ids[] = $cat_id;
1178 1177
 							$cat_ids = array_unique($cat_ids);
1179 1178
 						}
1180
-						elseif ((($key = array_search($cat_id,$cat_ids))) !== false)
1179
+						elseif ((($key = array_search($cat_id, $cat_ids))) !== false)
1181 1180
 						{
1182 1181
 							unset($cat_ids[$key]);
1183 1182
 						}
1184
-						$ids = $cat_ids ? implode(',',$cat_ids) : null;
1183
+						$ids = $cat_ids ? implode(',', $cat_ids) : null;
1185 1184
 						if ($ids !== $contact['cat_id'])
1186 1185
 						{
1187 1186
 							$contact['cat_id'] = $ids;
@@ -1192,10 +1191,10 @@  discard block
 block discarded – undo
1192 1191
 
1193 1192
 				case 'delete':
1194 1193
 					$action_msg = lang('deleted');
1195
-					if (($Ok = !!($contact = $this->read($id)) && $this->check_perms(Acl::DELETE,$contact)))
1194
+					if (($Ok = !!($contact = $this->read($id)) && $this->check_perms(Acl::DELETE, $contact)))
1196 1195
 					{
1197
-						if ($contact['owner'] ||	// regular contact or
1198
-							empty($contact['account_id']) ||	// accounts without account_id
1196
+						if ($contact['owner'] || // regular contact or
1197
+							empty($contact['account_id']) || // accounts without account_id
1199 1198
 							// already deleted account (should no longer happen, but needed to allow for cleanup)
1200 1199
 							$contact['tid'] == self::DELETED_TYPE)
1201 1200
 						{
@@ -1204,7 +1203,7 @@  discard block
 block discarded – undo
1204 1203
 						// delete single account --> redirect to admin
1205 1204
 						elseif (count($checked) == 1 && $contact['account_id'])
1206 1205
 						{
1207
-							Egw::redirect_link('/index.php',array(
1206
+							Egw::redirect_link('/index.php', array(
1208 1207
 								'menuaction' => 'admin.admin_account.delete',
1209 1208
 								'account_id' => $contact['account_id'],
1210 1209
 							));
@@ -1266,7 +1265,7 @@  discard block
 block discarded – undo
1266 1265
 					}
1267 1266
 					else
1268 1267
 					{
1269
-						$Ok = $this->remove_from_list($id,$query['filter2']) !== false;
1268
+						$Ok = $this->remove_from_list($id, $query['filter2']) !== false;
1270 1269
 					}
1271 1270
 					break;
1272 1271
 
@@ -1279,28 +1278,28 @@  discard block
 block discarded – undo
1279 1278
 					}
1280 1279
 					else
1281 1280
 					{
1282
-						$Ok = $this->add2list($id,$to_list) !== false;
1281
+						$Ok = $this->add2list($id, $to_list) !== false;
1283 1282
 					}
1284 1283
 					break;
1285 1284
 
1286 1285
 				default:	// move to an other addressbook
1287
-					if (!(int)$action || !($this->grants[(string) (int) $action] & Acl::EDIT))	// might be ADD in the future
1286
+					if (!(int)$action || !($this->grants[(string)(int)$action]&Acl::EDIT))	// might be ADD in the future
1288 1287
 					{
1289 1288
 						return false;
1290 1289
 					}
1291 1290
 					if (!$checkboxes['move_to_copy'])
1292 1291
 					{
1293 1292
 						$action_msg = lang('moved');
1294
-						if (($Ok = !!($contact = $this->read($id)) && $this->check_perms(Acl::DELETE,$contact)))
1293
+						if (($Ok = !!($contact = $this->read($id)) && $this->check_perms(Acl::DELETE, $contact)))
1295 1294
 						{
1296 1295
 							if (!$contact['owner'])		// no (mass-)move of Api\Accounts
1297 1296
 							{
1298 1297
 								$Ok = false;
1299 1298
 							}
1300
-							elseif ($contact['owner'] != (int)$action || $contact['private'] != (int)(substr($action,-1) == 'p'))
1299
+							elseif ($contact['owner'] != (int)$action || $contact['private'] != (int)(substr($action, -1) == 'p'))
1301 1300
 							{
1302
-								$contact['owner'] = (int) $action;
1303
-								$contact['private'] = (int)(substr($action,-1) == 'p');
1301
+								$contact['owner'] = (int)$action;
1302
+								$contact['private'] = (int)(substr($action, -1) == 'p');
1304 1303
 								$Ok = $this->save($contact);
1305 1304
 							}
1306 1305
 						}
@@ -1308,14 +1307,14 @@  discard block
 block discarded – undo
1308 1307
 					else
1309 1308
 					{
1310 1309
 						$action_msg = lang('copied');
1311
-						if (($Ok = !!($contact = $this->read($id)) && $this->check_perms(Acl::READ,$contact)))
1310
+						if (($Ok = !!($contact = $this->read($id)) && $this->check_perms(Acl::READ, $contact)))
1312 1311
 						{
1313
-							if ($contact['owner'] != (int)$action || $contact['private'] != (int)(substr($action,-1) == 'p'))
1312
+							if ($contact['owner'] != (int)$action || $contact['private'] != (int)(substr($action, -1) == 'p'))
1314 1313
 							{
1315
-								$this->copy_contact($contact, false);	// do NOT use self::$copy_fields, copy everything but uid etc.
1314
+								$this->copy_contact($contact, false); // do NOT use self::$copy_fields, copy everything but uid etc.
1316 1315
 								$links = $contact['link_to']['to_id'];
1317
-								$contact['owner'] = (int) $action;
1318
-								$contact['private'] = (int)(substr($action,-1) == 'p');
1316
+								$contact['owner'] = (int)$action;
1317
+								$contact['private'] = (int)(substr($action, -1) == 'p');
1319 1318
 								$Ok = $this->save($contact);
1320 1319
 								if ($Ok && is_array($links))
1321 1320
 								{
@@ -1347,22 +1346,22 @@  discard block
 block discarded – undo
1347 1346
 	 * @param boolean $only_copy_fields =true true: only copy fields configured for copying (eg. no name),
1348 1347
 	 *		false: copy everything, but never to copy fields
1349 1348
 	 */
1350
-	function copy_contact(array &$content, $only_copy_fields=true)
1349
+	function copy_contact(array &$content, $only_copy_fields = true)
1351 1350
 	{
1352 1351
 		$content['link_to']['to_id'] = 0;
1353
-		Link::link('addressbook',$content['link_to']['to_id'],'addressbook',$content['id'],
1354
-			lang('Copied by %1, from record #%2.',Api\Accounts::format_username('',
1355
-			$GLOBALS['egw_info']['user']['account_firstname'],$GLOBALS['egw_info']['user']['account_lastname']),
1352
+		Link::link('addressbook', $content['link_to']['to_id'], 'addressbook', $content['id'],
1353
+			lang('Copied by %1, from record #%2.', Api\Accounts::format_username('',
1354
+			$GLOBALS['egw_info']['user']['account_firstname'], $GLOBALS['egw_info']['user']['account_lastname']),
1356 1355
 			$content['id']));
1357 1356
 		// create a new contact with the content of the old
1358
-		foreach(array_keys($content) as $key)
1357
+		foreach (array_keys($content) as $key)
1359 1358
 		{
1360
-			if($only_copy_fields && !in_array($key, self::$copy_fields) || in_array($key, array('id','etag','carddav_name','uid')))
1359
+			if ($only_copy_fields && !in_array($key, self::$copy_fields) || in_array($key, array('id', 'etag', 'carddav_name', 'uid')))
1361 1360
 			{
1362 1361
 				unset($content[$key]);
1363 1362
 			}
1364 1363
 		}
1365
-		if(!isset($content['owner']))
1364
+		if (!isset($content['owner']))
1366 1365
 		{
1367 1366
 			$content['owner'] = $this->default_private ? $this->user.'p' : $this->default_addressbook;
1368 1367
 		}
@@ -1380,7 +1379,7 @@  discard block
 block discarded – undo
1380 1379
 	 * @param boolean $id_only =false if true only return (via $rows) an array of contact-ids, dont save state to session
1381 1380
 	 * @return int total number of contacts matching the selection
1382 1381
 	 */
1383
-	function get_rows(&$query,&$rows,&$readonlys,$id_only=false)
1382
+	function get_rows(&$query, &$rows, &$readonlys, $id_only = false)
1384 1383
 	{
1385 1384
 		$do_email = $query['do_email'];
1386 1385
 		$what = $query['sitemgr_display'] ? $query['sitemgr_display'] : ($do_email ? 'email' : 'index');
@@ -1389,7 +1388,7 @@  discard block
 block discarded – undo
1389 1388
 		{
1390 1389
 			$store_query = $query;
1391 1390
 			// Do not store these
1392
-			foreach(array('options-cat_id','actions') as $key)
1391
+			foreach (array('options-cat_id', 'actions') as $key)
1393 1392
 			{
1394 1393
 				unset($store_query[$key]);
1395 1394
 			}
@@ -1399,22 +1398,22 @@  discard block
 block discarded – undo
1399 1398
 		{
1400 1399
 			$old_state = Api\Cache::getSession('addressbook', $what);
1401 1400
 		}
1402
-		if (!isset($this->org_views[(string) $query['org_view']]) || strpos($query['org_view'],':') === false)   // we dont have an org view, unset the according col_filters
1401
+		if (!isset($this->org_views[(string)$query['org_view']]) || strpos($query['org_view'], ':') === false)   // we dont have an org view, unset the according col_filters
1403 1402
 		{
1404 1403
 			if (isset($query['col_filter']['org_name'])) unset($query['col_filter']['org_name']);
1405 1404
 			if (isset($query['col_filter']['adr_one_locality'])) unset($query['col_filter']['adr_one_locality']);
1406 1405
 			if (isset($query['col_filter']['org_unit'])) unset($query['col_filter']['org_unit']);
1407 1406
 		}
1408 1407
 
1409
-		if (isset($this->org_views[(string) $query['org_view']]))	// we have an org view, reset the advanced search
1408
+		if (isset($this->org_views[(string)$query['org_view']]))	// we have an org view, reset the advanced search
1410 1409
 		{
1411 1410
 			//_debug_array(array('Search'=>$query['search'],
1412 1411
 			//	'AdvancedSearch'=>$query['advanced_search']));
1413 1412
 			//if (is_array($query['search'])) unset($query['search']);
1414 1413
 			//unset($query['advanced_search']);
1415
-			if(!$query['search'] && $old_state['advanced_search']) $query['advanced_search'] = $old_state['advanced_search'];
1414
+			if (!$query['search'] && $old_state['advanced_search']) $query['advanced_search'] = $old_state['advanced_search'];
1416 1415
 		}
1417
-		elseif(!$query['search'] && $old_state['advanced_search'])	// eg. paging in an advanced search
1416
+		elseif (!$query['search'] && $old_state['advanced_search'])	// eg. paging in an advanced search
1418 1417
 		{
1419 1418
 			$query['advanced_search'] = $old_state['advanced_search'];
1420 1419
 		}
@@ -1425,11 +1424,11 @@  discard block
 block discarded – undo
1425 1424
 		}*/
1426 1425
 
1427 1426
 		// Make sure old lettersearch filter doesn't stay - current letter filter will be added later
1428
-		foreach($query['col_filter'] as $key => $col_filter)
1427
+		foreach ($query['col_filter'] as $key => $col_filter)
1429 1428
 		{
1430
-			if(!is_numeric($key)) continue;
1431
-			if(preg_match('/'.$GLOBALS['egw']->db->capabilities['case_insensitive_like'].
1432
-				' '.$GLOBALS['egw']->db->quote('[a-z]%').'$/',$col_filter) == 1
1429
+			if (!is_numeric($key)) continue;
1430
+			if (preg_match('/'.$GLOBALS['egw']->db->capabilities['case_insensitive_like'].
1431
+				' '.$GLOBALS['egw']->db->quote('[a-z]%').'$/', $col_filter) == 1
1433 1432
 			)
1434 1433
 			{
1435 1434
 				unset($query['col_filter'][$key]);
@@ -1444,16 +1443,16 @@  discard block
 block discarded – undo
1444 1443
 			{
1445 1444
 				if ($old_state['filter'] === '0')	// user changed to org_view
1446 1445
 				{
1447
-					$query['filter'] = '';			// --> change filter to all contacts
1446
+					$query['filter'] = ''; // --> change filter to all contacts
1448 1447
 				}
1449 1448
 				else								// user changed to accounts
1450 1449
 				{
1451
-					$query['org_view'] = '';		// --> change to regular contacts view
1450
+					$query['org_view'] = ''; // --> change to regular contacts view
1452 1451
 				}
1453 1452
 			}
1454 1453
 			if ($query['org_view'] && isset($this->org_views[$old_state['org_view']]) && !isset($this->org_views[$query['org_view']]))
1455 1454
 			{
1456
-				$query['searchletter'] = '';		// reset lettersearch if viewing the contacts of one organisation
1455
+				$query['searchletter'] = ''; // reset lettersearch if viewing the contacts of one organisation
1457 1456
 			}
1458 1457
 			// save the state of the index in the user prefs
1459 1458
 			$state = serialize(array(
@@ -1466,9 +1465,9 @@  discard block
 block discarded – undo
1466 1465
 			));
1467 1466
 			if ($state != $this->prefs[$what.'_state'] && !$query['csv_export'])
1468 1467
 			{
1469
-				$GLOBALS['egw']->preferences->add('addressbook',$what.'_state',$state);
1468
+				$GLOBALS['egw']->preferences->add('addressbook', $what.'_state', $state);
1470 1469
 				// save prefs, but do NOT invalid the cache (unnecessary)
1471
-				$GLOBALS['egw']->preferences->save_repository(false,'user',false);
1470
+				$GLOBALS['egw']->preferences->save_repository(false, 'user', false);
1472 1471
 			}
1473 1472
 		}
1474 1473
 		unset($old_state);
@@ -1483,11 +1482,11 @@  discard block
 block discarded – undo
1483 1482
 		}
1484 1483
 		if ($query['filter'] !== '')	// not all addressbooks
1485 1484
 		{
1486
-			$query['col_filter']['owner'] = (string) (int) $query['filter'];
1485
+			$query['col_filter']['owner'] = (string)(int)$query['filter'];
1487 1486
 
1488 1487
 			if ($this->private_addressbook)
1489 1488
 			{
1490
-				$query['col_filter']['private'] = substr($query['filter'],-1) == 'p' ? 1 : 0;
1489
+				$query['col_filter']['private'] = substr($query['filter'], -1) == 'p' ? 1 : 0;
1491 1490
 			}
1492 1491
 		}
1493 1492
 		else
@@ -1497,7 +1496,7 @@  discard block
 block discarded – undo
1497 1496
 		}
1498 1497
 		if ((int)$query['filter2'])	// not no distribution list
1499 1498
 		{
1500
-			$query['col_filter']['list'] = (string) (int) $query['filter2'];
1499
+			$query['col_filter']['list'] = (string)(int)$query['filter2'];
1501 1500
 		}
1502 1501
 		else
1503 1502
 		{
@@ -1510,18 +1509,18 @@  discard block
 block discarded – undo
1510 1509
 		// enable/disable distribution lists depending on backend
1511 1510
 		$query['no_filter2'] = !$this->lists_available($query['filter']);
1512 1511
 
1513
-		if (isset($this->org_views[(string) $query['org_view']]) && !$query['col_filter']['parent_id'])	// we have an org view
1512
+		if (isset($this->org_views[(string)$query['org_view']]) && !$query['col_filter']['parent_id'])	// we have an org view
1514 1513
 		{
1515 1514
 			// Query doesn't like empties
1516 1515
 			unset($query['col_filter']['parent_id']);
1517 1516
 
1518
-			if($query['actions'] && $query['actions']['open'])
1517
+			if ($query['actions'] && $query['actions']['open'])
1519 1518
 			{
1520 1519
 				// Just switched from contact view, update actions
1521 1520
 				$query['actions'] = $this->get_actions($query['col_filter']['tid'], $query['org_view']);
1522 1521
 			}
1523
-			unset($query['col_filter']['list']);	// does not work together
1524
-			$query['no_filter2'] = true;			// switch the distribution list selection off
1522
+			unset($query['col_filter']['list']); // does not work together
1523
+			$query['no_filter2'] = true; // switch the distribution list selection off
1525 1524
 
1526 1525
 			$query['template'] = 'addressbook.index.org_rows';
1527 1526
 
@@ -1559,7 +1558,7 @@  discard block
 block discarded – undo
1559 1558
 			{
1560 1559
 				$query['template'] = $do_email ? 'addressbook.email.rows' : 'addressbook.index.rows';
1561 1560
 			}
1562
-			if($query['col_filter']['parent_id'])
1561
+			if ($query['col_filter']['parent_id'])
1563 1562
 			{
1564 1563
 				$query['org_view'] = $query['col_filter']['parent_id'];
1565 1564
 				$query['template'] = 'addressbook.index.org_rows';
@@ -1568,25 +1567,25 @@  discard block
 block discarded – undo
1568 1567
 			unset($query['col_filter']['parent_id']);
1569 1568
 			if ($query['org_view'])	// view the contacts of one organisation only
1570 1569
 			{
1571
-				if (strpos($query['org_view'],'*AND*') !== false) $query['org_view'] = str_replace('*AND*','&',$query['org_view']);
1572
-				foreach(explode('|||',$query['org_view']) as $part)
1570
+				if (strpos($query['org_view'], '*AND*') !== false) $query['org_view'] = str_replace('*AND*', '&', $query['org_view']);
1571
+				foreach (explode('|||', $query['org_view']) as $part)
1573 1572
 				{
1574
-					list($name,$value) = explode(':',$part,2);
1573
+					list($name, $value) = explode(':', $part, 2);
1575 1574
 					// do NOT set invalid column, as this gives an SQL error ("AND AND" in sql)
1576
-					if (in_array($name, array('org_name','org_unit','adr_one_location')))
1575
+					if (in_array($name, array('org_name', 'org_unit', 'adr_one_location')))
1577 1576
 					{
1578 1577
 						$query['col_filter'][$name] = $value;
1579 1578
 					}
1580 1579
 				}
1581 1580
 			}
1582
-			else if($query['actions'] && !$query['actions']['edit'])
1581
+			else if ($query['actions'] && !$query['actions']['edit'])
1583 1582
 			{
1584 1583
 				// Just switched from org view, update actions
1585 1584
 				$query['actions'] = $this->get_actions($query['col_filter']['tid'], $query['org_view']);
1586 1585
 			}
1587 1586
 			// translate the select order to the really used over all 3 columns
1588 1587
 			$sort = $query['sort'];
1589
-			switch($query['order'])		// "xxx<>'' DESC" sorts contacts with empty order-criteria always at the end
1588
+			switch ($query['order'])		// "xxx<>'' DESC" sorts contacts with empty order-criteria always at the end
1590 1589
 			{							// we don't exclude them, as the total would otherwise depend on the order-criteria
1591 1590
 				case 'org_name':
1592 1591
 					$order = "egw_addressbook.org_name<>''DESC,egw_addressbook.org_name $sort,n_family $sort,n_given $sort";
@@ -1620,8 +1619,8 @@  discard block
 block discarded – undo
1620 1619
 			}
1621 1620
 			if ($query['searchletter'])	// only show contacts if the order-criteria starts with the given letter
1622 1621
 			{
1623
-				$no_letter_search = array('adr_one_postalcode', 'adr_two_postalcode', 'contact_id', 'contact_created','contact_modified');
1624
-				$query['col_filter'][] = (in_array($query['order'],$no_letter_search) ? 'org_name' : (substr($query['order'],0,1)=='#'?'':'egw_addressbook.').$query['order']).' '.
1622
+				$no_letter_search = array('adr_one_postalcode', 'adr_two_postalcode', 'contact_id', 'contact_created', 'contact_modified');
1623
+				$query['col_filter'][] = (in_array($query['order'], $no_letter_search) ? 'org_name' : (substr($query['order'], 0, 1) == '#' ? '' : 'egw_addressbook.').$query['order']).' '.
1625 1624
 					$GLOBALS['egw']->db->capabilities['case_insensitive_like'].' '.$GLOBALS['egw']->db->quote(strtolower($query['searchletter']).'%');
1626 1625
 			}
1627 1626
 			$wildcard = '%';
@@ -1635,39 +1634,39 @@  discard block
 block discarded – undo
1635 1634
 				unset($query['advanced_search']['meth_select']);
1636 1635
 			}
1637 1636
 			//if ($do_email ) $email_only = array('id','owner','tid','n_fn','n_family','n_given','org_name','email','email_home');
1638
-			$rows = parent::search($query['advanced_search'] ? $query['advanced_search'] : $query['search'],$id_only,
1639
-				$order,'',$wildcard,false,$op,array((int)$query['start'],(int) $query['num_rows']),$query['col_filter']);
1637
+			$rows = parent::search($query['advanced_search'] ? $query['advanced_search'] : $query['search'], $id_only,
1638
+				$order, '', $wildcard, false, $op, array((int)$query['start'], (int)$query['num_rows']), $query['col_filter']);
1640 1639
 
1641 1640
 			// do we need to read the custom fields, depends on the column is enabled and customfields exist
1642 1641
 			// $query['csv_export'] allways needs to read ALL cf's
1643 1642
 			$columsel = $this->prefs['nextmatch-addressbook.'.($do_email ? 'email' : 'index').'.rows'];
1644
-			$available_distib_lists=$this->get_lists(Acl::READ);
1645
-			$columselection = $columsel && !$query['csv_export'] ? explode(',',$columsel) : array();
1643
+			$available_distib_lists = $this->get_lists(Acl::READ);
1644
+			$columselection = $columsel && !$query['csv_export'] ? explode(',', $columsel) : array();
1646 1645
 			if (!$id_only && $rows)
1647 1646
 			{
1648
-				$show_custom_fields = (!$columselection || in_array('customfields',$columselection) || $query['csv_export']) && $this->customfields;
1649
-				$show_calendar = !$columselection || in_array('calendar_calendar',$columselection);
1650
-				$show_distributionlist = !$columselection || in_array('distrib_lists',$columselection) || count($available_distib_lists);
1647
+				$show_custom_fields = (!$columselection || in_array('customfields', $columselection) || $query['csv_export']) && $this->customfields;
1648
+				$show_calendar = !$columselection || in_array('calendar_calendar', $columselection);
1649
+				$show_distributionlist = !$columselection || in_array('distrib_lists', $columselection) || count($available_distib_lists);
1651 1650
 				if ($show_calendar || $show_custom_fields || $show_distributionlist)
1652 1651
 				{
1653
-					foreach($rows as $val)
1652
+					foreach ($rows as $val)
1654 1653
 					{
1655 1654
 						$ids[] = $val['id'];
1656 1655
 					}
1657 1656
 					if ($show_custom_fields)
1658 1657
 					{
1659
-						foreach($columselection as $col)
1658
+						foreach ($columselection as $col)
1660 1659
 						{
1661
-							if ($col[0] == '#') $selected_cfs[] = substr($col,1);
1660
+							if ($col[0] == '#') $selected_cfs[] = substr($col, 1);
1662 1661
 						}
1663
-						$customfields = $this->read_customfields($ids,$selected_cfs);
1662
+						$customfields = $this->read_customfields($ids, $selected_cfs);
1664 1663
 					}
1665 1664
 					if ($show_calendar && !empty($ids)) $calendar = $this->read_calendar($ids);
1666 1665
 					// distributionlist memership for the entrys
1667 1666
 					//_debug_array($this->get_lists(Acl::EDIT));
1668 1667
 					if ($show_distributionlist && $available_distib_lists)
1669 1668
 					{
1670
-						$distributionlist = $this->read_distributionlist($ids,array_keys($available_distib_lists));
1669
+						$distributionlist = $this->read_distributionlist($ids, array_keys($available_distib_lists));
1671 1670
 					}
1672 1671
 				}
1673 1672
 			}
@@ -1676,20 +1675,20 @@  discard block
 block discarded – undo
1676 1675
 
1677 1676
 		if ($id_only)
1678 1677
 		{
1679
-			foreach($rows as $n => $row)
1678
+			foreach ($rows as $n => $row)
1680 1679
 			{
1681 1680
 				$rows[$n] = $row['id'];
1682 1681
 			}
1683
-			return $this->total;	// no need to set other fields or $readonlys
1682
+			return $this->total; // no need to set other fields or $readonlys
1684 1683
 		}
1685 1684
 		$order = $query['order'];
1686 1685
 
1687 1686
 		$readonlys = array();
1688
-		foreach($rows as $n => &$row)
1687
+		foreach ($rows as $n => &$row)
1689 1688
 		{
1690 1689
 			$given = $row['n_given'] ? $row['n_given'] : ($row['n_prefix'] ? $row['n_prefix'] : '');
1691 1690
 
1692
-			switch($order)
1691
+			switch ($order)
1693 1692
 			{
1694 1693
 				default:	// postalcode, created, modified, ...
1695 1694
 				case 'org_name':
@@ -1706,38 +1705,38 @@  discard block
 block discarded – undo
1706 1705
 					break;
1707 1706
 				case 'n_fileas':
1708 1707
 					if (!$row['n_fileas']) $row['n_fileas'] = $this->fileas($row);
1709
-					list($row['line1'],$row['line2']) = explode(': ',$row['n_fileas']);
1708
+					list($row['line1'], $row['line2']) = explode(': ', $row['n_fileas']);
1710 1709
 					break;
1711 1710
 			}
1712
-			if (isset($this->org_views[(string) $query['org_view']]))
1711
+			if (isset($this->org_views[(string)$query['org_view']]))
1713 1712
 			{
1714 1713
 				$row['type'] = 'home';
1715 1714
 				$row['type_label'] = lang('Organisation');
1716 1715
 
1717
-				if ($query['filter'] && !($this->grants[(int)$query['filter']] & Acl::DELETE))
1716
+				if ($query['filter'] && !($this->grants[(int)$query['filter']]&Acl::DELETE))
1718 1717
 				{
1719 1718
 					$row['class'] .= 'rowNoDelete ';
1720 1719
 				}
1721
-				$row['class'] .= 'rowNoEdit ';	// no edit in OrgView
1720
+				$row['class'] .= 'rowNoEdit '; // no edit in OrgView
1722 1721
 				$row['class'] .= 'contact_organisation ';
1723 1722
 			}
1724 1723
 			else
1725 1724
 			{
1726
-				$this->type_icon($row['owner'],$row['private'],$row['tid'],$row['type'],$row['type_label']);
1725
+				$this->type_icon($row['owner'], $row['private'], $row['tid'], $row['type'], $row['type_label']);
1727 1726
 
1728
-				static $tel2show = array('tel_work','tel_cell','tel_home','tel_fax');
1727
+				static $tel2show = array('tel_work', 'tel_cell', 'tel_home', 'tel_fax');
1729 1728
 				static $prefer_marker = null;
1730 1729
 				if (is_null($prefer_marker))
1731 1730
 				{
1732 1731
 					// as et2 adds options with .text(), it can't be entities, but php knows no string literals with utf-8
1733 1732
 					$prefer_marker = html_entity_decode(' &#9734;', ENT_NOQUOTES, 'utf-8');
1734 1733
 				}
1735
-				foreach($tel2show as $name)
1734
+				foreach ($tel2show as $name)
1736 1735
 				{
1737
-					$row[$name] .= ' '.($row['tel_prefer'] == $name ? $prefer_marker : '');		// .' ' to NOT remove the field
1736
+					$row[$name] .= ' '.($row['tel_prefer'] == $name ? $prefer_marker : ''); // .' ' to NOT remove the field
1738 1737
 				}
1739 1738
 				// allways show the prefered phone, if not already shown
1740
-				if (!in_array($row['tel_prefer'],$tel2show) && $row[$row['tel_prefer']])
1739
+				if (!in_array($row['tel_prefer'], $tel2show) && $row[$row['tel_prefer']])
1741 1740
 				{
1742 1741
 					$row['tel_prefered'] = $row[$row['tel_prefer']].$prefer_marker;
1743 1742
 				}
@@ -1745,33 +1744,33 @@  discard block
 block discarded – undo
1745 1744
 				{
1746 1745
 					$row['class'] .= 'rowAccount rowNoDelete ';
1747 1746
 				}
1748
-				elseif (!$this->check_perms(Acl::DELETE,$row) || (!$GLOBALS['egw_info']['user']['apps']['admin'] && $this->config['history'] != 'userpurge' && $query['col_filter']['tid'] == self::DELETED_TYPE))
1747
+				elseif (!$this->check_perms(Acl::DELETE, $row) || (!$GLOBALS['egw_info']['user']['apps']['admin'] && $this->config['history'] != 'userpurge' && $query['col_filter']['tid'] == self::DELETED_TYPE))
1749 1748
 				{
1750 1749
 					$row['class'] .= 'rowNoDelete ';
1751 1750
 				}
1752
-				if (!$this->check_perms(Acl::EDIT,$row))
1751
+				if (!$this->check_perms(Acl::EDIT, $row))
1753 1752
 				{
1754 1753
 					$row['class'] .= 'rowNoEdit ';
1755 1754
 				}
1756 1755
 				$row['class'] .= 'contact_contact ';
1757 1756
 
1758
-				unset($row['jpegphoto']);	// unused and messes up json encoding (not utf-8)
1757
+				unset($row['jpegphoto']); // unused and messes up json encoding (not utf-8)
1759 1758
 
1760 1759
 				if (isset($customfields[$row['id']]))
1761 1760
 				{
1762
-					foreach($this->customfields as $name => $data)
1761
+					foreach ($this->customfields as $name => $data)
1763 1762
 					{
1764 1763
 						$row['#'.$name] = $customfields[$row['id']]['#'.$name];
1765 1764
 					}
1766 1765
 				}
1767 1766
 				if (isset($distributionlist[$row['id']]))
1768 1767
 				{
1769
-					$row['distrib_lists'] = implode("\n",array_values($distributionlist[$row['id']]));
1768
+					$row['distrib_lists'] = implode("\n", array_values($distributionlist[$row['id']]));
1770 1769
 					//if ($show_distributionlist) $readonlys['distrib_lists'] =true;
1771 1770
 				}
1772 1771
 				if (isset($calendar[$row['id']]))
1773 1772
 				{
1774
-					foreach($calendar[$row['id']] as $name => $data)
1773
+					foreach ($calendar[$row['id']] as $name => $data)
1775 1774
 					{
1776 1775
 						$row[$name] = $data;
1777 1776
 					}
@@ -1779,13 +1778,13 @@  discard block
 block discarded – undo
1779 1778
 			}
1780 1779
 
1781 1780
 			// hide region for address format 'postcode_city'
1782
-			if (($row['addr_format']  = $this->addr_format_by_country($row['adr_one_countryname']))=='postcode_city') unset($row['adr_one_region']);
1783
-			if (($row['addr_format2'] = $this->addr_format_by_country($row['adr_two_countryname']))=='postcode_city') unset($row['adr_two_region']);
1781
+			if (($row['addr_format']  = $this->addr_format_by_country($row['adr_one_countryname'])) == 'postcode_city') unset($row['adr_one_region']);
1782
+			if (($row['addr_format2'] = $this->addr_format_by_country($row['adr_two_countryname'])) == 'postcode_city') unset($row['adr_two_region']);
1784 1783
 
1785 1784
 			// respect category permissions
1786
-			if(!empty($row['cat_id']))
1785
+			if (!empty($row['cat_id']))
1787 1786
 			{
1788
-				$row['cat_id'] = $this->categories->check_list(Acl::READ,$row['cat_id']);
1787
+				$row['cat_id'] = $this->categories->check_list(Acl::READ, $row['cat_id']);
1789 1788
 			}
1790 1789
 		}
1791 1790
 		$rows['no_distribution_list'] = (bool)$query['filter2'];
@@ -1801,23 +1800,21 @@  discard block
 block discarded – undo
1801 1800
 		$header = array();
1802 1801
 		if ($query['filter'] !== '' && !isset($this->org_views[$query['org_view']]))
1803 1802
 		{
1804
-			$header[] = ($query['filter'] == '0' ? lang('accounts') :
1805
-				($GLOBALS['egw']->accounts->get_type($query['filter']) == 'g' ?
1806
-					lang('Group %1',$GLOBALS['egw']->accounts->id2name($query['filter'])) :
1807
-					Api\Accounts::username((int)$query['filter']).
1808
-						(substr($query['filter'],-1) == 'p' ? ' ('.lang('private').')' : '')));
1803
+			$header[] = ($query['filter'] == '0' ? lang('accounts') : ($GLOBALS['egw']->accounts->get_type($query['filter']) == 'g' ?
1804
+					lang('Group %1', $GLOBALS['egw']->accounts->id2name($query['filter'])) : Api\Accounts::username((int)$query['filter']).
1805
+						(substr($query['filter'], -1) == 'p' ? ' ('.lang('private').')' : '')));
1809 1806
 		}
1810 1807
 		if ($query['org_view'])
1811 1808
 		{
1812 1809
 			$header[] = $query['org_view_label'];
1813 1810
 			// Make sure option is there
1814
-			if(!array_key_exists($query['org_view'], $this->org_views))
1811
+			if (!array_key_exists($query['org_view'], $this->org_views))
1815 1812
 			{
1816 1813
 				$this->org_views += $this->_get_org_name($query['org_view']);
1817 1814
 				$rows['sel_options']['org_view'] = $this->org_views;
1818 1815
 			}
1819 1816
 		}
1820
-		if($query['advanced_search'])
1817
+		if ($query['advanced_search'])
1821 1818
 		{
1822 1819
 			$header[] = lang('Advanced search');
1823 1820
 		}
@@ -1828,11 +1825,11 @@  discard block
 block discarded – undo
1828 1825
 		if ($query['searchletter'])
1829 1826
 		{
1830 1827
 			$order = $order == 'n_given' ? lang('first name') : ($order == 'n_family' ? lang('last name') : lang('Organisation'));
1831
-			$header[] = lang("%1 starts with '%2'",$order,$query['searchletter']);
1828
+			$header[] = lang("%1 starts with '%2'", $order, $query['searchletter']);
1832 1829
 		}
1833 1830
 		if ($query['search'] && !$query['advanced_search']) // do not add that, if we have advanced search active
1834 1831
 		{
1835
-			$header[] = lang("Search for '%1'",$query['search']);
1832
+			$header[] = lang("Search for '%1'", $query['search']);
1836 1833
 		}
1837 1834
 		$GLOBALS['egw_info']['flags']['app_header'] = implode(': ', $header);
1838 1835
 
@@ -1848,7 +1845,7 @@  discard block
 block discarded – undo
1848 1845
 	 * @param string &$icon icon-name
1849 1846
 	 * @param string &$label translated label
1850 1847
 	 */
1851
-	function type_icon($owner,$private,$tid,&$icon,&$label)
1848
+	function type_icon($owner, $private, $tid, &$icon, &$label)
1852 1849
 	{
1853 1850
 		if (!$owner)
1854 1851
 		{
@@ -1863,7 +1860,7 @@  discard block
 block discarded – undo
1863 1860
 		elseif ($GLOBALS['egw']->accounts->get_type($owner) == 'g')
1864 1861
 		{
1865 1862
 			$icon = 'group';
1866
-			$label = lang('group %1',$GLOBALS['egw']->accounts->id2name($owner));
1863
+			$label = lang('group %1', $GLOBALS['egw']->accounts->id2name($owner));
1867 1864
 		}
1868 1865
 		else
1869 1866
 		{
@@ -1871,9 +1868,9 @@  discard block
 block discarded – undo
1871 1868
 			$label = $owner == $this->user ? lang('personal') : Api\Accounts::username($owner);
1872 1869
 		}
1873 1870
 		// show tid icon for tid!='n' AND only if one is defined
1874
-		if ($tid != 'n' && Api\Image::find('addressbook',$this->content_types[$tid]['name']))
1871
+		if ($tid != 'n' && Api\Image::find('addressbook', $this->content_types[$tid]['name']))
1875 1872
 		{
1876
-			$icon = Api\Image::find('addressbook',$this->content_types[$tid]['name']);
1873
+			$icon = Api\Image::find('addressbook', $this->content_types[$tid]['name']);
1877 1874
 		}
1878 1875
 
1879 1876
 		// Legacy - from when icons could be anywhere
@@ -1891,19 +1888,19 @@  discard block
 block discarded – undo
1891 1888
 	* @param int $_GET['contact_id'] contact_id mainly for popup use
1892 1889
 	* @param bool $_GET['makecp'] true if you want to copy the contact given by $_GET['contact_id']
1893 1890
 	*/
1894
-	function edit($content=null)
1891
+	function edit($content = null)
1895 1892
 	{
1896 1893
 		if (is_array($content))
1897 1894
 		{
1898 1895
 			list($button) = @each($content['button']);
1899 1896
 			unset($content['button']);
1900
-			$content['private'] = (int) ($content['owner'] && substr($content['owner'],-1) == 'p');
1901
-			$content['owner'] = (string) (int) $content['owner'];
1897
+			$content['private'] = (int)($content['owner'] && substr($content['owner'], -1) == 'p');
1898
+			$content['owner'] = (string)(int)$content['owner'];
1902 1899
 			$content['cat_id'] = $this->config['cat_tab'] === 'Tree' ? $content['cat_id_tree'] : $content['cat_id'];
1903 1900
 			if ($this->config['private_cf_tab']) $content = (array)$content['private_cfs'] + $content;
1904 1901
 			unset($content['private_cfs']);
1905 1902
 
1906
-			switch($button)
1903
+			switch ($button)
1907 1904
 			{
1908 1905
 				case 'save':
1909 1906
 				case 'apply':
@@ -1919,7 +1916,7 @@  discard block
 block discarded – undo
1919 1916
 					}
1920 1917
 					if (is_array($content['upload_photo']) && !empty($content['upload_photo']['tmp_name']) &&
1921 1918
 						$content['upload_photo']['tmp_name'] != 'none' &&
1922
-						($f = fopen($content['upload_photo']['tmp_name'],'r')))
1919
+						($f = fopen($content['upload_photo']['tmp_name'], 'r')))
1923 1920
 					{
1924 1921
 						$content['jpegphoto'] = $this->resize_photo($f);
1925 1922
 						fclose($f);
@@ -1936,12 +1933,12 @@  discard block
 block discarded – undo
1936 1933
 						$old_org_entry = $this->read($content['id']);
1937 1934
 						$old_fullname = ($old_org_entry['n_fn'] ? $old_org_entry['n_fn'] : parent::fullname($old_org_entry));
1938 1935
 					}
1939
-					if ( $content['n_fn'] != $fullname ||  $fullname != $old_fullname)
1936
+					if ($content['n_fn'] != $fullname || $fullname != $old_fullname)
1940 1937
 					{
1941 1938
 						unset($content['n_fn']);
1942 1939
 					}
1943 1940
 					// Country codes
1944
-					foreach(array('adr_one', 'adr_two') as $c_prefix)
1941
+					foreach (array('adr_one', 'adr_two') as $c_prefix)
1945 1942
 					{
1946 1943
 						if ($content[$c_prefix.'_countrycode'] == '-custom-')
1947 1944
 						{
@@ -1950,7 +1947,7 @@  discard block
 block discarded – undo
1950 1947
 					}
1951 1948
 					$content['msg'] = '';
1952 1949
 					$this->error = false;
1953
-					foreach((array)$content['pre_save_callbacks'] as $callback)
1950
+					foreach ((array)$content['pre_save_callbacks'] as $callback)
1954 1951
 					{
1955 1952
 						try {
1956 1953
 							if (($success_msg = call_user_func_array($callback, array(&$content))))
@@ -1960,7 +1957,7 @@  discard block
 block discarded – undo
1960 1957
 						}
1961 1958
 						catch (Exception $ex) {
1962 1959
 							$content['msg'] .= ($content['msg'] ? ', ' : '').$ex->getMessage();
1963
-							$button = 'apply';	// do not close dialog
1960
+							$button = 'apply'; // do not close dialog
1964 1961
 							$this->error = true;
1965 1962
 							break;
1966 1963
 						}
@@ -1973,7 +1970,7 @@  discard block
 block discarded – undo
1973 1970
 					{
1974 1971
 						$content['msg'] .= ($content['msg'] ? ', ' : '').lang('Contact saved');
1975 1972
 
1976
-						foreach((array)$content['post_save_callbacks'] as $callback)
1973
+						foreach ((array)$content['post_save_callbacks'] as $callback)
1977 1974
 						{
1978 1975
 							try {
1979 1976
 								if (($success_msg = call_user_func_array($callback, array(&$content))))
@@ -1981,58 +1978,58 @@  discard block
 block discarded – undo
1981 1978
 									$content['msg'] .= ', '.$success_msg;
1982 1979
 								}
1983 1980
 							}
1984
-							catch(Api\Exception\Redirect $r)
1981
+							catch (Api\Exception\Redirect $r)
1985 1982
 							{
1986 1983
 								// catch it to continue execution and rethrow it later
1987 1984
 							}
1988 1985
 							catch (Exception $ex) {
1989 1986
 								$content['msg'] .= ', '.$ex->getMessage();
1990
-								$button = 'apply';	// do not close dialog
1987
+								$button = 'apply'; // do not close dialog
1991 1988
 								$this->error = true;
1992 1989
 								break;
1993 1990
 							}
1994 1991
 						}
1995 1992
 
1996
-						if ($content['change_org'] && $old_org_entry && ($changed = $this->changed_fields($old_org_entry,$content,true)) &&
1997
-							($members = $this->org_similar($old_org_entry['org_name'],$changed)))
1993
+						if ($content['change_org'] && $old_org_entry && ($changed = $this->changed_fields($old_org_entry, $content, true)) &&
1994
+							($members = $this->org_similar($old_org_entry['org_name'], $changed)))
1998 1995
 						{
1999 1996
 							//foreach($changed as $name => $old_value) echo "<p>$name: '$old_value' --> '{$content[$name]}'</p>\n";
2000
-							list($changed_members,$changed_fields,$failed_members) = $this->change_org($old_org_entry['org_name'],$changed,$content,$members);
1997
+							list($changed_members, $changed_fields, $failed_members) = $this->change_org($old_org_entry['org_name'], $changed, $content, $members);
2001 1998
 							if ($changed_members)
2002 1999
 							{
2003
-								$content['msg'] .= ', '.lang('%1 fields in %2 other organisation member(s) changed',$changed_fields,$changed_members);
2000
+								$content['msg'] .= ', '.lang('%1 fields in %2 other organisation member(s) changed', $changed_fields, $changed_members);
2004 2001
 							}
2005 2002
 							if ($failed_members)
2006 2003
 							{
2007
-								$content['msg'] .= ', '.lang('failed to change %1 organisation member(s) (insufficent rights) !!!',$failed_members);
2004
+								$content['msg'] .= ', '.lang('failed to change %1 organisation member(s) (insufficent rights) !!!', $failed_members);
2008 2005
 							}
2009 2006
 						}
2010 2007
 					}
2011
-					elseif($this->error === true)
2008
+					elseif ($this->error === true)
2012 2009
 					{
2013 2010
 						$content['msg'] = lang('Error: the entry has been updated since you opened it for editing!').'<br />'.
2014
-							lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.','<a href="'.
2015
-								htmlspecialchars(Egw::link('/index.php',array(
2011
+							lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.', '<a href="'.
2012
+								htmlspecialchars(Egw::link('/index.php', array(
2016 2013
 									'menuaction' => 'addressbook.addressbook_ui.edit',
2017 2014
 									'contact_id' => $content['id'],
2018
-								))).'">','</a>');
2019
-						break;	// dont refresh the list
2015
+								))).'">', '</a>');
2016
+						break; // dont refresh the list
2020 2017
 					}
2021 2018
 					else
2022 2019
 					{
2023 2020
 						$content['msg'] = lang('Error saving the contact !!!').
2024 2021
 							($this->error ? ' '.$this->error : '');
2025
-						$button = 'apply';	// to not leave the dialog
2022
+						$button = 'apply'; // to not leave the dialog
2026 2023
 					}
2027 2024
 					// writing links for new entry, existing ones are handled by the widget itself
2028 2025
 					if ($links && $content['id'])
2029 2026
 					{
2030
-						Link::link('addressbook',$content['id'],$links);
2027
+						Link::link('addressbook', $content['id'], $links);
2031 2028
 					}
2032 2029
 					// Update client side global datastore
2033 2030
 					$response = Api\Json\Response::get();
2034 2031
 					$response->generic('data', array('uid' => 'addressbook::'.$content['id'], 'data' => $content));
2035
-					Framework::refresh_opener($content['msg'], 'addressbook', $content['id'],  $content['id'] ? 'edit' : 'add',
2032
+					Framework::refresh_opener($content['msg'], 'addressbook', $content['id'], $content['id'] ? 'edit' : 'add',
2036 2033
 						null, null, null, $this->error ? 'error' : 'success');
2037 2034
 
2038 2035
 					// re-throw redirect exception, if there's no error
@@ -2054,11 +2051,11 @@  discard block
 block discarded – undo
2054 2051
 
2055 2052
 				case 'delete':
2056 2053
 					$success = $failed = $action_msg = null;
2057
-					if($this->action('delete',array($content['id']),false,$success,$failed,$action_msg,'',$content['msg']))
2054
+					if ($this->action('delete', array($content['id']), false, $success, $failed, $action_msg, '', $content['msg']))
2058 2055
 					{
2059 2056
 						if ($GLOBALS['egw']->currentapp == 'addressbook')
2060 2057
 						{
2061
-							Framework::refresh_opener(lang('Contact deleted'), 'addressbook', $content['id'], 'delete' );
2058
+							Framework::refresh_opener(lang('Contact deleted'), 'addressbook', $content['id'], 'delete');
2062 2059
 							Framework::window_close();
2063 2060
 						}
2064 2061
 						else
@@ -2083,7 +2080,7 @@  discard block
 block discarded – undo
2083 2080
 			// new contact --> set some defaults
2084 2081
 			if ($contact_id && is_array($content = $this->read($contact_id)))
2085 2082
 			{
2086
-				$contact_id = $content['id'];	// it could have been: "account:$account_id"
2083
+				$contact_id = $content['id']; // it could have been: "account:$account_id"
2087 2084
 				if (!$this->check_perms(Acl::EDIT, $content))
2088 2085
 				{
2089 2086
 					$view = true;
@@ -2127,52 +2124,52 @@  discard block
 block discarded – undo
2127 2124
 				{
2128 2125
 					$content['owner'] = (string)$state['filter'];
2129 2126
 				}
2130
-				$content['private'] = (int) ($content['owner'] && substr($content['owner'],-1) == 'p');
2131
-				if ($content['owner'] === '' || !($this->grants[$content['owner'] = (string) (int) $content['owner']] & Acl::ADD))
2127
+				$content['private'] = (int)($content['owner'] && substr($content['owner'], -1) == 'p');
2128
+				if ($content['owner'] === '' || !($this->grants[$content['owner'] = (string)(int)$content['owner']]&Acl::ADD))
2132 2129
 				{
2133 2130
 					$content['owner'] = $this->default_addressbook;
2134 2131
 					$content['private'] = (int)$this->default_private;
2135 2132
 
2136
-					if (!($this->grants[$content['owner'] = (string) (int) $content['owner']] & Acl::ADD))
2133
+					if (!($this->grants[$content['owner'] = (string)(int)$content['owner']]&Acl::ADD))
2137 2134
 					{
2138
-						$content['owner'] = (string) $this->user;
2135
+						$content['owner'] = (string)$this->user;
2139 2136
 						$content['private'] = 0;
2140 2137
 					}
2141 2138
 				}
2142 2139
 				$new_type = array_keys($this->content_types);
2143 2140
 				// fetch active type to preset the type, if param typeid is not passed
2144
-				$active_tid = Api\Cache::getSession('addressbook','active_tid');
2141
+				$active_tid = Api\Cache::getSession('addressbook', 'active_tid');
2145 2142
 				if ($active_tid && strtoupper($active_tid) === 'D') unset($active_tid);
2146
-				$content['tid'] = $_GET['typeid'] ? $_GET['typeid'] : ($active_tid?$active_tid:$new_type[0]);
2147
-				foreach($this->get_contact_columns() as $field)
2143
+				$content['tid'] = $_GET['typeid'] ? $_GET['typeid'] : ($active_tid ? $active_tid : $new_type[0]);
2144
+				foreach ($this->get_contact_columns() as $field)
2148 2145
 				{
2149 2146
 					if ($_GET['presets'][$field])
2150 2147
 					{
2151
-						if ($field=='email'||$field=='email_home')
2148
+						if ($field == 'email' || $field == 'email_home')
2152 2149
 						{
2153
-							$singleAddress = imap_rfc822_parse_adrlist($_GET['presets'][$field],'');
2150
+							$singleAddress = imap_rfc822_parse_adrlist($_GET['presets'][$field], '');
2154 2151
 							//error_log(__METHOD__.__LINE__.' Address:'.$singleAddress[0]->mailbox."@".$singleAddress[0]->host.", ".$singleAddress[0]->personal);
2155
-							if (!(!is_array($singleAddress) || count($singleAddress)<1))
2152
+							if (!(!is_array($singleAddress) || count($singleAddress) < 1))
2156 2153
 							{
2157 2154
 								$content[$field] = $singleAddress[0]->mailbox."@".$singleAddress[0]->host;
2158 2155
 								if (!empty($singleAddress[0]->personal))
2159 2156
 								{
2160
-									if (strpos($singleAddress[0]->personal,',')===false)
2157
+									if (strpos($singleAddress[0]->personal, ',') === false)
2161 2158
 									{
2162
-										list($P_n_given,$P_n_family,$P_org_name)=explode(' ',$singleAddress[0]->personal,3);
2163
-										if (strlen(trim($P_n_given))>0) $content['n_given'] = trim($P_n_given);
2164
-										if (strlen(trim($P_n_family))>0) $content['n_family'] = trim($P_n_family);
2165
-										if (strlen(trim($P_org_name))>0) $content['org_name'] = trim($P_org_name);
2159
+										list($P_n_given, $P_n_family, $P_org_name) = explode(' ', $singleAddress[0]->personal, 3);
2160
+										if (strlen(trim($P_n_given)) > 0) $content['n_given'] = trim($P_n_given);
2161
+										if (strlen(trim($P_n_family)) > 0) $content['n_family'] = trim($P_n_family);
2162
+										if (strlen(trim($P_org_name)) > 0) $content['org_name'] = trim($P_org_name);
2166 2163
 									}
2167 2164
 									else
2168 2165
 									{
2169
-										list($P_n_family,$P_other)=explode(',',$singleAddress[0]->personal,2);
2170
-										if (strlen(trim($P_n_family))>0) $content['n_family'] = trim($P_n_family);
2171
-										if (strlen(trim($P_other))>0)
2166
+										list($P_n_family, $P_other) = explode(',', $singleAddress[0]->personal, 2);
2167
+										if (strlen(trim($P_n_family)) > 0) $content['n_family'] = trim($P_n_family);
2168
+										if (strlen(trim($P_other)) > 0)
2172 2169
 										{
2173
-											list($P_n_given,$P_org_name)=explode(',',$P_other,2);
2174
-											if (strlen(trim($P_n_given))>0) $content['n_given'] = trim($P_n_given);
2175
-											if (strlen(trim($P_org_name))>0) $content['org_name'] = trim($P_org_name);
2170
+											list($P_n_given, $P_org_name) = explode(',', $P_other, 2);
2171
+											if (strlen(trim($P_n_given)) > 0) $content['n_given'] = trim($P_n_given);
2172
+											if (strlen(trim($P_org_name)) > 0) $content['org_name'] = trim($P_org_name);
2176 2173
 										}
2177 2174
 									}
2178 2175
 								}
@@ -2190,13 +2187,13 @@  discard block
 block discarded – undo
2190 2187
 				}
2191 2188
 				if (isset($_GET['presets']))
2192 2189
 				{
2193
-					foreach(array('email','email_home','n_family','n_given','org_name') as $field)
2190
+					foreach (array('email', 'email_home', 'n_family', 'n_given', 'org_name') as $field)
2194 2191
 					{
2195 2192
 						if (!empty($content[$field]))
2196 2193
 						{
2197 2194
 							//Set the presets fields in content in order to be able to use them later in client side for checking duplication only on first time load
2198 2195
 							// after save/apply we unset them
2199
-							$content['presets_fields'][]= $field;
2196
+							$content['presets_fields'][] = $field;
2200 2197
 							break;
2201 2198
 						}
2202 2199
 					}
@@ -2208,9 +2205,9 @@  discard block
 block discarded – undo
2208 2205
 				//_debug_array($content);
2209 2206
 			}
2210 2207
 
2211
-			if ($_GET['msg']) $content['msg'] = strip_tags($_GET['msg']);	// dont allow HTML!
2208
+			if ($_GET['msg']) $content['msg'] = strip_tags($_GET['msg']); // dont allow HTML!
2212 2209
 
2213
-			if($content && $_GET['makecp'])	// copy the contact
2210
+			if ($content && $_GET['makecp'])	// copy the contact
2214 2211
 			{
2215 2212
 				$this->copy_contact($content);
2216 2213
 				$content['msg'] = lang('Contact copied');
@@ -2224,12 +2221,12 @@  discard block
 block discarded – undo
2224 2221
 			if (!$contact_id && isset($_REQUEST['link_app']) && isset($_REQUEST['link_id']) && !is_array($content['link_to']['to_id']))
2225 2222
 			{
2226 2223
 				$link_ids = is_array($_REQUEST['link_id']) ? $_REQUEST['link_id'] : array($_REQUEST['link_id']);
2227
-				foreach(is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app)
2224
+				foreach (is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app)
2228 2225
 				{
2229 2226
 					$link_id = $link_ids[$n];
2230
-					if (preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id))	// gard against XSS
2227
+					if (preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i', $link_app.':'.$link_id))	// gard against XSS
2231 2228
 					{
2232
-						Link::link('addressbook',$content['link_to']['to_id'],$link_app,$link_id);
2229
+						Link::link('addressbook', $content['link_to']['to_id'], $link_app, $link_id);
2233 2230
 					}
2234 2231
 				}
2235 2232
 			}
@@ -2237,8 +2234,8 @@  discard block
 block discarded – undo
2237 2234
 		if ($content['id'])
2238 2235
 		{
2239 2236
 			// last and next calendar date
2240
-			list(,$dates) = each($this->read_calendar(array($content['id']),false));
2241
-			if(is_array($dates)) $content += $dates;
2237
+			list(,$dates) = each($this->read_calendar(array($content['id']), false));
2238
+			if (is_array($dates)) $content += $dates;
2242 2239
 		}
2243 2240
 		// Avoid ID conflict with tree & selectboxes
2244 2241
 		$content['cat_id_tree'] = $content['cat_id'];
@@ -2247,7 +2244,7 @@  discard block
 block discarded – undo
2247 2244
 		if ($this->config['private_cf_tab'])
2248 2245
 		{
2249 2246
 			$content['private_cfs'] = array();
2250
-			foreach(Api\Storage\Customfields::get('addressbook', true) as $name => $cf)
2247
+			foreach (Api\Storage\Customfields::get('addressbook', true) as $name => $cf)
2251 2248
 			{
2252 2249
 				if ($cf['private'] && isset($content['#'.$name]))
2253 2250
 				{
@@ -2260,7 +2257,7 @@  discard block
 block discarded – undo
2260 2257
 		$content['addr_format2'] = $this->addr_format_by_country($content['adr_two_countryname']);
2261 2258
 
2262 2259
 		//_debug_array($content);
2263
-		$readonlys['button[delete]'] = !$content['owner'] || !$this->check_perms(Acl::DELETE,$content);
2260
+		$readonlys['button[delete]'] = !$content['owner'] || !$this->check_perms(Acl::DELETE, $content);
2264 2261
 		$readonlys['button[copy]'] = $readonlys['button[edit]'] = $readonlys['button[vcard]'] = true;
2265 2262
 		$readonlys['button[save]'] = $readonlys['button[apply]'] = $view;
2266 2263
 		if ($view)
@@ -2272,19 +2269,18 @@  discard block
 block discarded – undo
2272 2269
 		$sel_options['fileas_type'] = $this->fileas_options($content);
2273 2270
 		$sel_options['adr_one_countrycode']['-custom-'] = lang('Custom');
2274 2271
 		$sel_options['owner'] = $this->get_addressbooks(Acl::ADD);
2275
-		if ($content['owner']) unset($sel_options['owner'][0]);	// do not offer to switch to accounts, as we do not support moving contacts to accounts
2276
-		if ((string) $content['owner'] !== '')
2272
+		if ($content['owner']) unset($sel_options['owner'][0]); // do not offer to switch to accounts, as we do not support moving contacts to accounts
2273
+		if ((string)$content['owner'] !== '')
2277 2274
 		{
2278 2275
 			if (!isset($sel_options['owner'][(int)$content['owner']]))
2279 2276
 			{
2280
-				$sel_options['owner'][(int)$content['owner']] = !$content['owner'] ? lang('Accounts') :
2281
-					Api\Accounts::username($content['owner']);
2277
+				$sel_options['owner'][(int)$content['owner']] = !$content['owner'] ? lang('Accounts') : Api\Accounts::username($content['owner']);
2282 2278
 			}
2283
-			$readonlys['owner'] = !$content['owner'] || 		// dont allow to move accounts, as this mean deleting the user incl. all content he owns
2284
-				$content['id'] && !$this->check_perms(Acl::DELETE,$content);	// you need delete rights to move an existing contact into an other addressbook
2279
+			$readonlys['owner'] = !$content['owner'] || // dont allow to move accounts, as this mean deleting the user incl. all content he owns
2280
+				$content['id'] && !$this->check_perms(Acl::DELETE, $content); // you need delete rights to move an existing contact into an other addressbook
2285 2281
 		}
2286 2282
 		// set the unsupported fields from the backend to readonly
2287
-		foreach($this->get_fields('unsupported',$content['id'],$content['owner']) as $field)
2283
+		foreach ($this->get_fields('unsupported', $content['id'], $content['owner']) as $field)
2288 2284
 		{
2289 2285
 			$readonlys[$field] = true;
2290 2286
 		}
@@ -2294,7 +2290,7 @@  discard block
 block discarded – undo
2294 2290
 			$readonlys['__ALL__'] = true;
2295 2291
 			$readonlys['button[cancel]'] = false;
2296 2292
 
2297
-			foreach($this->own_account_acl as $field)
2293
+			foreach ($this->own_account_acl as $field)
2298 2294
 			{
2299 2295
 				$readonlys[$field] = false;
2300 2296
 			}
@@ -2302,9 +2298,9 @@  discard block
 block discarded – undo
2302 2298
 		if (isset($readonlys['n_fileas'])) $readonlys['fileas_type'] = $readonlys['n_fileas'];
2303 2299
 		// disable not needed tabs
2304 2300
 		$readonlys['tabs']['cats'] = !($content['cat_tab'] = $this->config['cat_tab']);
2305
-		$readonlys['tabs']['custom'] = !$this->customfields || $this->get_backend($content['id'],$content['owner']) == $this->so_accounts;
2301
+		$readonlys['tabs']['custom'] = !$this->customfields || $this->get_backend($content['id'], $content['owner']) == $this->so_accounts;
2306 2302
 		$readonlys['tabs']['custom_private'] = $readonlys['tabs']['custom'] || !$this->config['private_cf_tab'];
2307
-		$readonlys['tabs']['distribution_list'] = !$content['distrib_lists'];#false;
2303
+		$readonlys['tabs']['distribution_list'] = !$content['distrib_lists']; #false;
2308 2304
 		$readonlys['tabs']['history'] = $this->contact_repository != 'sql' || !$content['id'] ||
2309 2305
 			$this->account_repository != 'sql' && $content['account_id'];
2310 2306
 		if (!$content['id']) $readonlys['button[delete]'] = !$content['id'];
@@ -2316,7 +2312,7 @@  discard block
 block discarded – undo
2316 2312
 		{
2317 2313
 			$this->_set_readonlys_for_own_account_acl($readonlys, $content['id']);
2318 2314
 		}
2319
-		for($i = -23; $i<=23; $i++)
2315
+		for ($i = -23; $i <= 23; $i++)
2320 2316
 		{
2321 2317
 			$tz[$i] = ($i > 0 ? '+' : '').$i;
2322 2318
 		}
@@ -2324,11 +2320,11 @@  discard block
 block discarded – undo
2324 2320
 		$content['tz'] = $content['tz'] ? $content['tz'] : '0';
2325 2321
 		if (count($this->content_types) > 1)
2326 2322
 		{
2327
-			foreach($this->content_types as $type => $data)
2323
+			foreach ($this->content_types as $type => $data)
2328 2324
 			{
2329 2325
 				$sel_options['tid'][$type] = $data['name'];
2330 2326
 			}
2331
-			$content['typegfx'] = Api\Html::image('addressbook',$this->content_types[$content['tid']]['options']['icon'],'',' width="16px" height="16px"');
2327
+			$content['typegfx'] = Api\Html::image('addressbook', $this->content_types[$content['tid']]['options']['icon'], '', ' width="16px" height="16px"');
2332 2328
 		}
2333 2329
 		else
2334 2330
 		{
@@ -2342,10 +2338,10 @@  discard block
 block discarded – undo
2342 2338
 		);
2343 2339
 
2344 2340
 		// Links for deleted entries
2345
-		if($content['tid'] == self::DELETED_TYPE)
2341
+		if ($content['tid'] == self::DELETED_TYPE)
2346 2342
 		{
2347 2343
 			$content['link_to']['show_deleted'] = true;
2348
-			if(!$GLOBALS['egw_info']['user']['apps']['admin'] && $this->config['history'] != 'userpurge')
2344
+			if (!$GLOBALS['egw_info']['user']['apps']['admin'] && $this->config['history'] != 'userpurge')
2349 2345
 			{
2350 2346
 				$readonlys['button[delete]'] = true;
2351 2347
 			}
@@ -2354,33 +2350,33 @@  discard block
 block discarded – undo
2354 2350
 		// Enable history
2355 2351
 		$this->setup_history($content, $sel_options);
2356 2352
 
2357
-		$content['photo'] = $this->photo_src($content['id'],$content['jpegphoto'],'photo',$content['etag']);
2353
+		$content['photo'] = $this->photo_src($content['id'], $content['jpegphoto'], 'photo', $content['etag']);
2358 2354
 
2359 2355
 		if ($content['private']) $content['owner'] .= 'p';
2360 2356
 
2361 2357
 		// for custom types, check if we have a custom edit template named "addressbook.edit.$type", $type is the name
2362
-		if (in_array($content['tid'], array('n',self::DELETED_TYPE)) || !$this->tmpl->read('addressbook.edit.'.$this->content_types[$content['tid']]['name']))
2358
+		if (in_array($content['tid'], array('n', self::DELETED_TYPE)) || !$this->tmpl->read('addressbook.edit.'.$this->content_types[$content['tid']]['name']))
2363 2359
 		{
2364 2360
 			$this->tmpl->read('addressbook.edit');
2365 2361
 		}
2366 2362
 
2367 2363
 		// allow other apps to add tabs to addressbook edit
2368 2364
 		$preserve = $content;
2369
-		$content['jpegphoto'] = !empty($content['jpegphoto']);	// unused and messes up json encoding (not utf-8)
2365
+		$content['jpegphoto'] = !empty($content['jpegphoto']); // unused and messes up json encoding (not utf-8)
2370 2366
 		$this->tmpl->setElementAttribute('tabs', 'add_tabs', true);
2371
-		$tabs =& $this->tmpl->getElementAttribute('tabs', 'tabs');
2367
+		$tabs = & $this->tmpl->getElementAttribute('tabs', 'tabs');
2372 2368
 		if (($first_call = !isset($tabs)))
2373 2369
 		{
2374 2370
 			$tabs = array();
2375 2371
 		}
2376 2372
 		//error_log(__LINE__.': '.__METHOD__."() first_call=$first_call");
2377
-		$hook_data = Api\Hooks::process(array('location' => 'addressbook_edit')+$content);
2373
+		$hook_data = Api\Hooks::process(array('location' => 'addressbook_edit') + $content);
2378 2374
 		//error_log(__METHOD__."() hook_data=".array2string($hook_data));
2379
-		foreach($hook_data as $extra_tabs)
2375
+		foreach ($hook_data as $extra_tabs)
2380 2376
 		{
2381 2377
 			if (!$extra_tabs) continue;
2382 2378
 
2383
-			foreach(isset($extra_tabs[0]) ? $extra_tabs : array($extra_tabs) as $extra_tab)
2379
+			foreach (isset($extra_tabs[0]) ? $extra_tabs : array($extra_tabs) as $extra_tab)
2384 2380
 			{
2385 2381
 				if ($extra_tab['data'] && is_array($extra_tab['data']))
2386 2382
 				{
@@ -2425,15 +2421,15 @@  discard block
 block discarded – undo
2425 2421
 	 * @param array &$readonlys
2426 2422
 	 * @param int $id
2427 2423
 	 */
2428
-	function _set_readonlys_for_own_account_acl(&$readonlys,$id)
2424
+	function _set_readonlys_for_own_account_acl(&$readonlys, $id)
2429 2425
 	{
2430 2426
 		// regular fields depending on the backend
2431
-		foreach($this->get_fields('supported',$id,0) as $field)
2427
+		foreach ($this->get_fields('supported', $id, 0) as $field)
2432 2428
 		{
2433
-			if (!$this->own_account_acl || !in_array($field,$this->own_account_acl))
2429
+			if (!$this->own_account_acl || !in_array($field, $this->own_account_acl))
2434 2430
 			{
2435 2431
 				$readonlys[$field] = true;
2436
-				switch($field)
2432
+				switch ($field)
2437 2433
 				{
2438 2434
 					case 'tel_work':
2439 2435
 					case 'tel_cell':
@@ -2449,16 +2445,16 @@  discard block
 block discarded – undo
2449 2445
 		// custom fields
2450 2446
 		if ($this->customfields)
2451 2447
 		{
2452
-			foreach(array_keys($this->customfields) as $name)
2448
+			foreach (array_keys($this->customfields) as $name)
2453 2449
 			{
2454
-				if (!$this->own_account_acl || !in_array('#'.$name,$this->own_account_acl))
2450
+				if (!$this->own_account_acl || !in_array('#'.$name, $this->own_account_acl))
2455 2451
 				{
2456 2452
 					$readonlys['#'.$name] = true;
2457 2453
 				}
2458 2454
 			}
2459 2455
 		}
2460 2456
 		// links
2461
-		if (!$this->own_account_acl || !in_array('link_to',$this->own_account_acl))
2457
+		if (!$this->own_account_acl || !in_array('link_to', $this->own_account_acl))
2462 2458
 		{
2463 2459
 			$readonlys['link_to'] = true;
2464 2460
 		}
@@ -2476,10 +2472,10 @@  discard block
 block discarded – undo
2476 2472
 	 * 	'data' => array of id => "full name (addressbook)" pairs
2477 2473
 	 *  'fileas_options'
2478 2474
 	 */
2479
-	public function ajax_check_values($values, $name, $own_id=0)
2475
+	public function ajax_check_values($values, $name, $own_id = 0)
2480 2476
 	{
2481 2477
 		$matches = null;
2482
-		if (preg_match('/^exec\[([^\]]+)\]$/', $name, $matches)) $name = $matches[1];	// remove exec[ ]
2478
+		if (preg_match('/^exec\[([^\]]+)\]$/', $name, $matches)) $name = $matches[1]; // remove exec[ ]
2483 2479
 
2484 2480
 		$ret = array('doublicates' => array(), 'msg' => null);
2485 2481
 
@@ -2503,10 +2499,10 @@  discard block
 block discarded – undo
2503 2499
 
2504 2500
 			// if name, firstname or org changed and at least 2 are specified, check for doublicates
2505 2501
 			if (in_array($name, array('n_given', 'n_family', 'org_name')) &&
2506
-				!empty($values['n_given'])+!empty($values['n_family'])+!empty($values['org_name']) >= 2)
2502
+				!empty($values['n_given']) + !empty($values['n_family']) + !empty($values['org_name']) >= 2)
2507 2503
 			{
2508 2504
 				$filter = array();
2509
-				foreach(array('email', 'n_given', 'n_family', 'org_name') as $n)	// use email too, to exclude obvious false positives
2505
+				foreach (array('email', 'n_given', 'n_family', 'org_name') as $n)	// use email too, to exclude obvious false positives
2510 2506
 				{
2511 2507
 					if (!empty($values[$n])) $filter[$n] = $values[$n];
2512 2508
 				}
@@ -2515,7 +2511,7 @@  discard block
 block discarded – undo
2515 2511
 		}
2516 2512
 		if ($contacts)
2517 2513
 		{
2518
-			foreach($contacts as $contact)
2514
+			foreach ($contacts as $contact)
2519 2515
 			{
2520 2516
 				if ($own_id && $contact['id'] == $own_id) continue;
2521 2517
 
@@ -2539,26 +2535,24 @@  discard block
 block discarded – undo
2539 2535
 	 *
2540 2536
 	 * @param array $content
2541 2537
 	 */
2542
-	function view(array $content=null)
2538
+	function view(array $content = null)
2543 2539
 	{
2544 2540
 		// CRM list comes from content, request, or preference
2545
-		$crm_list = $content['crm_list'] ? $content['crm_list'] :
2546
-			($_GET['crm_list'] ? $_GET['crm_list'] : $GLOBALS['egw_info']['user']['preferences']['addressbook']['crm_list']);
2547
-		if(!$crm_list || $crm_list == '~edit~') $crm_list = 'infolog';
2541
+		$crm_list = $content['crm_list'] ? $content['crm_list'] : ($_GET['crm_list'] ? $_GET['crm_list'] : $GLOBALS['egw_info']['user']['preferences']['addressbook']['crm_list']);
2542
+		if (!$crm_list || $crm_list == '~edit~') $crm_list = 'infolog';
2548 2543
 
2549
-		if(is_array($content))
2544
+		if (is_array($content))
2550 2545
 		{
2551 2546
 			list($button) = each($content['button']);
2552 2547
 			switch ($content['toolbar'] ? $content['toolbar'] : $button)
2553 2548
 			{
2554
-				case 'vcard':
2555
-					Egw::redirect_link('/index.php','menuaction=addressbook.uivcard.out&ab_id=' .$content['id']);
2549
+				case 'vcard' : Egw::redirect_link('/index.php', 'menuaction=addressbook.uivcard.out&ab_id='.$content['id']);
2556 2550
 
2557 2551
 				case 'cancel':
2558
-					Egw::redirect_link('/index.php','menuaction=addressbook.addressbook_ui.index&ajax=true');
2552
+					Egw::redirect_link('/index.php', 'menuaction=addressbook.addressbook_ui.index&ajax=true');
2559 2553
 
2560 2554
 				case 'delete':
2561
-					Egw::redirect_link('/index.php',array(
2555
+					Egw::redirect_link('/index.php', array(
2562 2556
 						'menuaction' => 'addressbook.addressbook_ui.index',
2563 2557
 						'msg' => $this->delete($content) ? lang('Contact deleted') : lang('Error deleting the contact !!!'),
2564 2558
 					));
@@ -2576,9 +2570,9 @@  discard block
 block discarded – undo
2576 2570
 					$num_rows = $this->get_rows($query, $rows, $readonlys, true);
2577 2571
 					//error_log(__METHOD__."() get_rows()=$num_rows rows=".array2string($rows));
2578 2572
 					$contact_id = $rows[0];
2579
-					if(!$contact_id || !is_array($content = $this->read($contact_id)))
2573
+					if (!$contact_id || !is_array($content = $this->read($contact_id)))
2580 2574
 					{
2581
-						Egw::redirect_link('/index.php',array(
2575
+						Egw::redirect_link('/index.php', array(
2582 2576
 							'menuaction' => 'addressbook.addressbook_ui.index',
2583 2577
 							'msg' => $content,
2584 2578
 							'ajax' => 'true'
@@ -2587,14 +2581,14 @@  discard block
 block discarded – undo
2587 2581
 					$content['index'] = $query['start'];
2588 2582
 
2589 2583
 					// List nextmatch is already there, just update the filter
2590
-					if($contact_id && Api\Json\Request::isJSONRequest())
2584
+					if ($contact_id && Api\Json\Request::isJSONRequest())
2591 2585
 					{
2592
-						switch($crm_list)
2586
+						switch ($crm_list)
2593 2587
 						{
2594 2588
 							case 'infolog':
2595 2589
 							case 'tracker':
2596 2590
 							default:
2597
-								Api\Json\Response::get()->apply('app.addressbook.view_set_list',Array(Array('action'=>'addressbook', 'action_id' => $contact_id)));
2591
+								Api\Json\Response::get()->apply('app.addressbook.view_set_list', Array(Array('action'=>'addressbook', 'action_id' => $contact_id)));
2598 2592
 								break;
2599 2593
 						}
2600 2594
 
@@ -2625,13 +2619,13 @@  discard block
 block discarded – undo
2625 2619
 				$_GET['index'] = 0;
2626 2620
 			}
2627 2621
 			$contact_id = $_GET['contact_id'] ? $_GET['contact_id'] : ((int)$_GET['account_id'] ? 'account:'.(int)$_GET['account_id'] : 0);
2628
-			if(!$contact_id || !is_array($content = $this->read($contact_id)))
2622
+			if (!$contact_id || !is_array($content = $this->read($contact_id)))
2629 2623
 			{
2630
-				Egw::redirect_link('/index.php',array(
2624
+				Egw::redirect_link('/index.php', array(
2631 2625
 					'menuaction' => 'addressbook.addressbook_ui.index',
2632 2626
 					'msg' => $content,
2633 2627
 					'ajax' => 'true'
2634
-				)+(isset($_GET['search']) ? array('search' => $_GET['search']) : array()));
2628
+				) + (isset($_GET['search']) ? array('search' => $_GET['search']) : array()));
2635 2629
 			}
2636 2630
 			if (isset($_GET['index']))
2637 2631
 			{
@@ -2644,25 +2638,25 @@  discard block
 block discarded – undo
2644 2638
 				$num_rows = $this->get_rows($query, $rows, $readonlys, true);
2645 2639
 			}
2646 2640
 		}
2647
-		$content['jpegphoto'] = !empty($content['jpegphoto']);	// unused and messes up json encoding (not utf-8)
2641
+		$content['jpegphoto'] = !empty($content['jpegphoto']); // unused and messes up json encoding (not utf-8)
2648 2642
 
2649 2643
 		// make everything not explicit mentioned readonly
2650 2644
 		$readonlys['__ALL__'] = true;
2651 2645
 		$readonlys['photo'] = $readonlys['button[cancel]'] = $readonlys['button[copy]'] =
2652 2646
 			$readonlys['button[ok]'] = $readonlys['button[more]'] = $readonlys['toolbar'] = false;
2653 2647
 
2654
-		foreach(array_keys($this->contact_fields) as $key)
2648
+		foreach (array_keys($this->contact_fields) as $key)
2655 2649
 		{
2656
-			if (in_array($key,array('tel_home','tel_work','tel_cell','tel_fax')))
2650
+			if (in_array($key, array('tel_home', 'tel_work', 'tel_cell', 'tel_fax')))
2657 2651
 			{
2658 2652
 				$content[$key.'2'] = $content[$key];
2659 2653
 			}
2660 2654
 		}
2661 2655
 
2662 2656
 		// respect category permissions
2663
-		if(!empty($content['cat_id']))
2657
+		if (!empty($content['cat_id']))
2664 2658
 		{
2665
-			$content['cat_id'] = $this->categories->check_list(Acl::READ,$content['cat_id']);
2659
+			$content['cat_id'] = $this->categories->check_list(Acl::READ, $content['cat_id']);
2666 2660
 		}
2667 2661
 		$content['cat_id_tree'] = $content['cat_id'];
2668 2662
 
@@ -2672,12 +2666,12 @@  discard block
 block discarded – undo
2672 2666
 			'to_id'  => $content['id'],
2673 2667
 		);
2674 2668
 		// Links for deleted entries
2675
-		if($content['tid'] == self::DELETED_TYPE)
2669
+		if ($content['tid'] == self::DELETED_TYPE)
2676 2670
 		{
2677 2671
 			$content['link_to']['show_deleted'] = true;
2678 2672
 		}
2679
-		$readonlys['button[delete]'] = !$content['owner'] || !$this->check_perms(Acl::DELETE,$content);
2680
-		$readonlys['button[edit]'] = !$this->check_perms(Acl::EDIT,$content);
2673
+		$readonlys['button[delete]'] = !$content['owner'] || !$this->check_perms(Acl::DELETE, $content);
2674
+		$readonlys['button[edit]'] = !$this->check_perms(Acl::EDIT, $content);
2681 2675
 
2682 2676
 		// how to display addresses
2683 2677
 		$content['addr_format']  = $this->addr_format_by_country($content['adr_one_countryname']);
@@ -2685,7 +2679,7 @@  discard block
 block discarded – undo
2685 2679
 
2686 2680
 		$sel_options['fileas_type'][$content['fileas_type']] = $this->fileas($content);
2687 2681
 		$sel_options['owner'] = $this->get_addressbooks();
2688
-		for($i = -23; $i<=23; $i++)
2682
+		for ($i = -23; $i <= 23; $i++)
2689 2683
 		{
2690 2684
 			$tz[$i] = ($i > 0 ? '+' : '').$i;
2691 2685
 		}
@@ -2693,11 +2687,11 @@  discard block
 block discarded – undo
2693 2687
 		$content['tz'] = $content['tz'] ? $content['tz'] : 0;
2694 2688
 		if (count($this->content_types) > 1)
2695 2689
 		{
2696
-			foreach($this->content_types as $type => $data)
2690
+			foreach ($this->content_types as $type => $data)
2697 2691
 			{
2698 2692
 				$sel_options['tid'][$type] = $data['name'];
2699 2693
 			}
2700
-			$content['typegfx'] = Api\Html::image('addressbook',$this->content_types[$content['tid']]['options']['icon'],'',' width="16px" height="16px"');
2694
+			$content['typegfx'] = Api\Html::image('addressbook', $this->content_types[$content['tid']]['options']['icon'], '', ' width="16px" height="16px"');
2701 2695
 		}
2702 2696
 		else
2703 2697
 		{
@@ -2714,7 +2708,7 @@  discard block
 block discarded – undo
2714 2708
 		{
2715 2709
 			$content['owner'] .= 'p';
2716 2710
 		}
2717
-		$this->tmpl->set_cell_attribute('change_org','disabled',true);
2711
+		$this->tmpl->set_cell_attribute('change_org', 'disabled', true);
2718 2712
 
2719 2713
 		// Prevent double countries - invalid code blanks it, disabling doesn't work
2720 2714
 		$content['adr_one_countrycode'] = '-';
@@ -2727,14 +2721,14 @@  discard block
 block discarded – undo
2727 2721
 		$readonlys['tabs']['cats'] = !($content['cat_tab'] = $this->config['cat_tab']);
2728 2722
 		$readonlys['tabs']['custom'] = !$this->customfields;
2729 2723
 		$readonlys['tabs']['custom_private'] = !$this->customfields || !$this->config['private_cf_tab'];
2730
-		$readonlys['tabs']['distribution_list'] = !$content['distrib_lists'];#false;
2724
+		$readonlys['tabs']['distribution_list'] = !$content['distrib_lists']; #false;
2731 2725
 		$readonlys['tabs']['history'] = $this->contact_repository != 'sql' || !$content['id'] ||
2732 2726
 			$this->account_repository != 'sql' && $content['account_id'];
2733 2727
 		if ($this->config['private_cf_tab']) $content['no_private_cfs'] = 0;
2734 2728
 
2735 2729
 		// last and next calendar date
2736
-		if (!empty($content['id'])) list(,$dates) = each($this->read_calendar(array($content['id']),false));
2737
-		if(is_array($dates)) $content += $dates;
2730
+		if (!empty($content['id'])) list(,$dates) = each($this->read_calendar(array($content['id']), false));
2731
+		if (is_array($dates)) $content += $dates;
2738 2732
 
2739 2733
 		// Disable importexport
2740 2734
 		$GLOBALS['egw_info']['flags']['disable_importexport']['export'] = true;
@@ -2776,7 +2770,7 @@  discard block
 block discarded – undo
2776 2770
 		{
2777 2771
 			unset($actions['back']);
2778 2772
 		}
2779
-		if (!isset($content['index']) || $content['index'] >= $num_rows-1)
2773
+		if (!isset($content['index']) || $content['index'] >= $num_rows - 1)
2780 2774
 		{
2781 2775
 			unset($actions['next']);
2782 2776
 		}
@@ -2788,7 +2782,7 @@  discard block
 block discarded – undo
2788 2782
 		// need to load list's app.js now, as exec calls header before other app can include it
2789 2783
 		Framework::includeJS('/'.$crm_list.'/js/app.js');
2790 2784
 
2791
-		$this->tmpl->exec('addressbook.addressbook_ui.view',$content,$sel_options,$readonlys,array(
2785
+		$this->tmpl->exec('addressbook.addressbook_ui.view', $content, $sel_options, $readonlys, array(
2792 2786
 			'id' => $content['id'],
2793 2787
 			'index' => $content['index'],
2794 2788
 			'crm_list' => $crm_list
@@ -2796,12 +2790,12 @@  discard block
 block discarded – undo
2796 2790
 
2797 2791
 		// Only load this on first time - we're using AJAX, so it stays there through submits.
2798 2792
 		// Sending it again (via ajax) will break the addressbook.view etemplate2
2799
-		if($contact_id)
2793
+		if ($contact_id)
2800 2794
 		{
2801 2795
 			Api\Hooks::single(array(
2802 2796
 				'location' => 'addressbook_view',
2803 2797
 				'ab_id'    => $content['id']
2804
-			),$crm_list);
2798
+			), $crm_list);
2805 2799
 		}
2806 2800
 	}
2807 2801
 
@@ -2813,30 +2807,30 @@  discard block
 block discarded – undo
2813 2807
 	 */
2814 2808
 	function email2link($email)
2815 2809
 	{
2816
-		if (strpos($email,'@') == false) return '';
2810
+		if (strpos($email, '@') == false) return '';
2817 2811
 
2818
-		if($GLOBALS['egw_info']['user']['apps']['mail'])
2812
+		if ($GLOBALS['egw_info']['user']['apps']['mail'])
2819 2813
 		{
2820 2814
 			return array(
2821 2815
 				'menuaction' => 'mail.mail_compose.compose',
2822 2816
 				'send_to'    => base64_encode($email)
2823 2817
 			);
2824 2818
 		}
2825
-		if($GLOBALS['egw_info']['user']['apps']['felamimail'])
2819
+		if ($GLOBALS['egw_info']['user']['apps']['felamimail'])
2826 2820
 		{
2827 2821
 			return array(
2828 2822
 				'menuaction' => 'felamimail.uicompose.compose',
2829 2823
 				'send_to'    => base64_encode($email)
2830 2824
 			);
2831 2825
 		}
2832
-		if($GLOBALS['egw_info']['user']['apps']['email'])
2826
+		if ($GLOBALS['egw_info']['user']['apps']['email'])
2833 2827
 		{
2834 2828
 			return array(
2835 2829
 				'menuaction' => 'email.uicompose.compose',
2836 2830
 				'to' => $email,
2837 2831
 			);
2838 2832
 		}
2839
-		return 'mailto:' . $email;
2833
+		return 'mailto:'.$email;
2840 2834
 	}
2841 2835
 
2842 2836
 	/**
@@ -2845,9 +2839,9 @@  discard block
 block discarded – undo
2845 2839
 	 * @param array $_content
2846 2840
 	 * @return string
2847 2841
 	 */
2848
-	function search($_content=array())
2842
+	function search($_content = array())
2849 2843
 	{
2850
-		if(!empty($_content))
2844
+		if (!empty($_content))
2851 2845
 		{
2852 2846
 
2853 2847
 			$_content['cat_id'] = $this->config['cat_tab'] === 'Tree' ? $_content['cat_id_tree'] : $_content['cat_id'];
@@ -2862,10 +2856,10 @@  discard block
 block discarded – undo
2862 2856
 			}
2863 2857
 			else
2864 2858
 			{
2865
-				$query['advanced_search'] = array_intersect_key($_content,array_flip(array_merge($this->get_contact_columns(),array('operator','meth_select'))));
2859
+				$query['advanced_search'] = array_intersect_key($_content, array_flip(array_merge($this->get_contact_columns(), array('operator', 'meth_select'))));
2866 2860
 				foreach ($query['advanced_search'] as $key => $value)
2867 2861
 				{
2868
-					if(!$value) unset($query['advanced_search'][$key]);
2862
+					if (!$value) unset($query['advanced_search'][$key]);
2869 2863
 				}
2870 2864
 				// Skip n_fn, it causes problems in sql
2871 2865
 				unset($query['advanced_search']['n_fn']);
@@ -2881,7 +2875,7 @@  discard block
 block discarded – undo
2881 2875
 			$response->call("app.addressbook.adv_search", array('advanced_search' => $_content['button']['search'] ? $query['advanced_search'] : ''));
2882 2876
 			if ($_content['button']['cancelsearch'])
2883 2877
 			{
2884
-				Framework::window_close ();
2878
+				Framework::window_close();
2885 2879
 
2886 2880
 				// No need to reload popup
2887 2881
 				return;
@@ -2897,7 +2891,7 @@  discard block
 block discarded – undo
2897 2891
 		// Avoid ID conflict with tree & selectboxes
2898 2892
 		$content['cat_id_tree'] = $content['cat_id'];
2899 2893
 
2900
-		for($i = -23; $i<=23; $i++)
2894
+		for ($i = -23; $i <= 23; $i++)
2901 2895
 		{
2902 2896
 			$tz[$i] = ($i > 0 ? '+' : '').$i;
2903 2897
 		}
@@ -2906,8 +2900,8 @@  discard block
 block discarded – undo
2906 2900
 		//foreach($this->content_types as $type => $data) $sel_options['tid'][$type] = $data['name'];
2907 2901
 
2908 2902
 		// configure search options
2909
-		$sel_options['owner'] = $this->get_addressbooks(Acl::READ,lang('all'));
2910
-		$sel_options['operator'] =  array(
2903
+		$sel_options['owner'] = $this->get_addressbooks(Acl::READ, lang('all'));
2904
+		$sel_options['operator'] = array(
2911 2905
 			'AND' => 'AND',
2912 2906
 			'OR' => 'OR',
2913 2907
 		);
@@ -2917,12 +2911,12 @@  discard block
 block discarded – undo
2917 2911
 		);
2918 2912
 		if ($this->customfields)
2919 2913
 		{
2920
-			foreach($this->customfields as $name => $data)
2914
+			foreach ($this->customfields as $name => $data)
2921 2915
 			{
2922 2916
 				if (substr($data['type'], 0, 6) == 'select' && !($data['rows'] > 1))
2923 2917
 				{
2924 2918
 					if (!isset($content['#'.$name])) $content['#'.$name] = '';
2925
-					if(!isset($data['values'][''])) $sel_options['#'.$name][''] = lang('Select one');
2919
+					if (!isset($data['values'][''])) $sel_options['#'.$name][''] = lang('Select one');
2926 2920
 				}
2927 2921
 			}
2928 2922
 		}
@@ -2947,8 +2941,8 @@  discard block
 block discarded – undo
2947 2941
 		if ($this->config['private_cf_tab']) $content['no_private_cfs'] = 0;
2948 2942
 
2949 2943
 		$this->tmpl->read('addressbook.edit');
2950
-		$this->tmpl->set_cell_attribute('change_org','disabled',true);
2951
-		return $this->tmpl->exec('addressbook.addressbook_ui.search',$content,$sel_options,$readonlys,array(),2);
2944
+		$this->tmpl->set_cell_attribute('change_org', 'disabled', true);
2945
+		return $this->tmpl->exec('addressbook.addressbook_ui.search', $content, $sel_options, $readonlys, array(), 2);
2952 2946
 	}
2953 2947
 
2954 2948
 	/**
@@ -2957,16 +2951,15 @@  discard block
 block discarded – undo
2957 2951
 	function photo()
2958 2952
 	{
2959 2953
 		ob_start();
2960
-		$contact_id = isset($_GET['contact_id']) ? $_GET['contact_id'] :
2961
-			(isset($_GET['account_id']) ? 'account:'.$_GET['account_id'] : 0);
2954
+		$contact_id = isset($_GET['contact_id']) ? $_GET['contact_id'] : (isset($_GET['account_id']) ? 'account:'.$_GET['account_id'] : 0);
2962 2955
 
2963
-		if (substr($contact_id,0,8) == 'account:')
2956
+		if (substr($contact_id, 0, 8) == 'account:')
2964 2957
 		{
2965
-			$contact_id = $GLOBALS['egw']->accounts->id2name(substr($contact_id,8),'person_id');
2958
+			$contact_id = $GLOBALS['egw']->accounts->id2name(substr($contact_id, 8), 'person_id');
2966 2959
 		}
2967 2960
 		if (!($contact = $this->read($contact_id)) || !$contact['jpegphoto'])
2968 2961
 		{
2969
-			Egw::redirect(Api\Image::find('addressbook','photo'));
2962
+			Egw::redirect(Api\Image::find('addressbook', 'photo'));
2970 2963
 		}
2971 2964
 		// use an etag over the image mapp
2972 2965
 		$etag = '"'.$contact['id'].':'.$contact['etag'].'"';
@@ -2978,7 +2971,7 @@  discard block
 block discarded – undo
2978 2971
 			// different url with different etag parameter will force a reload
2979 2972
 			if (isset($_GET['etag']))
2980 2973
 			{
2981
-				Api\Session::cache_control(30*86400);	// cache for 30 days
2974
+				Api\Session::cache_control(30 * 86400); // cache for 30 days
2982 2975
 			}
2983 2976
 			// if servers send a If-None-Match header, response with 304 Not Modified, if etag matches
2984 2977
 			if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && $_SERVER['HTTP_IF_NONE_MATCH'] === $etag)
@@ -3030,15 +3023,15 @@  discard block
 block discarded – undo
3030 3023
 		echo $GLOBALS['egw']->framework->navbar();
3031 3024
 
3032 3025
 		// check if user has admin rights AND if a valid fileas type is given (Security)
3033
-		if (!$this->is_admin() || $_GET['type'] != '' && !in_array($_GET['type'],$this->fileas_types))
3026
+		if (!$this->is_admin() || $_GET['type'] != '' && !in_array($_GET['type'], $this->fileas_types))
3034 3027
 		{
3035 3028
 			echo '<h1>'.lang('Permission denied !!!')."</h1>\n";
3036 3029
 		}
3037 3030
 		else
3038 3031
 		{
3039 3032
 			$errors = null;
3040
-			$updated = parent::set_all_fileas($_GET['type'],(boolean)$_GET['all'],$errors,true);	// true = ignore Acl
3041
-			echo '<p style="margin-top: 20px;"><b>'.lang('%1 contacts updated (%2 errors).',$updated,$errors)."</b></p>\n";
3033
+			$updated = parent::set_all_fileas($_GET['type'], (boolean)$_GET['all'], $errors, true); // true = ignore Acl
3034
+			echo '<p style="margin-top: 20px;"><b>'.lang('%1 contacts updated (%2 errors).', $updated, $errors)."</b></p>\n";
3042 3035
 		}
3043 3036
 		echo $GLOBALS['egw']->framework->footer();
3044 3037
 	}
@@ -3062,8 +3055,8 @@  discard block
 block discarded – undo
3062 3055
 		else
3063 3056
 		{
3064 3057
 			$errors = null;
3065
-			$updated = parent::set_all_cleanup($errors,true);	// true = ignore Acl
3066
-			echo '<p style="margin-top: 20px;"><b>'.lang('%1 contacts updated (%2 errors).',$updated,$errors)."</b></p>\n";
3058
+			$updated = parent::set_all_cleanup($errors, true); // true = ignore Acl
3059
+			echo '<p style="margin-top: 20px;"><b>'.lang('%1 contacts updated (%2 errors).', $updated, $errors)."</b></p>\n";
3067 3060
 		}
3068 3061
 		echo $GLOBALS['egw']->framework->footer();
3069 3062
 	}
@@ -3076,7 +3069,7 @@  discard block
 block discarded – undo
3076 3069
 		if ($this->contact_repository == 'ldap' || !$content['id'] ||
3077 3070
 			$this->account_repository == 'ldap' && $content['account_id'])
3078 3071
 		{
3079
-			return;	// no history for ldap as history table only allows integer id's
3072
+			return; // no history for ldap as history table only allows integer id's
3080 3073
 		}
3081 3074
 		$content['history'] = array(
3082 3075
 			'id'	=>	$content['id'],
@@ -3091,7 +3084,7 @@  discard block
 block discarded – undo
3091 3084
 			),
3092 3085
 		);
3093 3086
 
3094
-		foreach($this->content_types as $id => $settings)
3087
+		foreach ($this->content_types as $id => $settings)
3095 3088
 		{
3096 3089
 			$content['history']['status-widgets']['tid'][$id] = $settings['name'];
3097 3090
 		}
Please login to merge, or discard this patch.
Braces   +363 added lines, -94 removed lines patch added patch discarded remove patch
@@ -92,7 +92,10 @@  discard block
 block discarded – undo
92 92
 		);
93 93
 
94 94
 		// make sure the hook for export_limit is registered
95
-		if (!Api\Hooks::exists('export_limit','addressbook')) Api\Hooks::read(true);
95
+		if (!Api\Hooks::exists('export_limit','addressbook'))
96
+		{
97
+			Api\Hooks::read(true);
98
+		}
96 99
 
97 100
 		$this->config =& $GLOBALS['egw_info']['server'];
98 101
 
@@ -131,15 +134,21 @@  discard block
 block discarded – undo
131 134
 		{
132 135
 			$do_email = $_content['do_email'];
133 136
 
134
-			if (isset($_content['nm']['rows']['delete']))	// handle a single delete like delete with the checkboxes
137
+			if (isset($_content['nm']['rows']['delete']))
138
+			{
139
+				// handle a single delete like delete with the checkboxes
135 140
 			{
136 141
 				list($id) = @each($_content['nm']['rows']['delete']);
142
+			}
137 143
 				$_content['nm']['action'] = 'delete';
138 144
 				$_content['nm']['selected'] = array($id);
139 145
 			}
140
-			if (isset($_content['nm']['rows']['document']))	// handle insert in default document button like an action
146
+			if (isset($_content['nm']['rows']['document']))
147
+			{
148
+				// handle insert in default document button like an action
141 149
 			{
142 150
 				list($id) = @each($_content['nm']['rows']['document']);
151
+			}
143 152
 				$_content['nm']['action'] = 'document';
144 153
 				$_content['nm']['selected'] = array($id);
145 154
 			}
@@ -149,10 +158,13 @@  discard block
 block discarded – undo
149 158
 				{
150 159
 					$msg = lang('You need to select some contacts first');
151 160
 				}
152
-				elseif ($_content['nm']['action'] == 'view_org')	// org-view via context menu
161
+				elseif ($_content['nm']['action'] == 'view_org')
162
+				{
163
+					// org-view via context menu
153 164
 				{
154 165
 					$_content['nm']['org_view'] = array_shift($_content['nm']['selected']);
155 166
 				}
167
+				}
156 168
 				else
157 169
 				{
158 170
 					$success = $failed = $action_msg = null;
@@ -175,10 +187,13 @@  discard block
 block discarded – undo
175 187
 				list($org) = each($_content['nm']['rows']['infolog']);
176 188
 				return $this->infolog_org_view($org);
177 189
 			}
178
-			if ($_content['nm']['rows']['view'])	// show all contacts of an organisation
190
+			if ($_content['nm']['rows']['view'])
191
+			{
192
+				// show all contacts of an organisation
179 193
 			{
180 194
 				list($org_view) = each($_content['nm']['rows']['view']);
181 195
 			}
196
+			}
182 197
 			else
183 198
 			{
184 199
 				$org_view = $_content['nm']['org_view'];
@@ -271,10 +286,14 @@  discard block
 block discarded – undo
271 286
 		}
272 287
 
273 288
 		// Search parameter passed in
274
-		if ($_GET['search']) {
289
+		if ($_GET['search'])
290
+		{
275 291
 			$content['nm']['search'] = $_GET['search'];
276 292
 		}
277
-		if (isset($typeselection)) $content['nm']['col_filter']['tid'] = $typeselection;
293
+		if (isset($typeselection))
294
+		{
295
+			$content['nm']['col_filter']['tid'] = $typeselection;
296
+		}
278 297
 		// save the tid for use in creating new addressbook entrys via UI. Current tid is to be used as type of new entrys
279 298
 		//error_log(__METHOD__.__LINE__.' '.$content['nm']['col_filter']['tid']);
280 299
 		Api\Cache::setSession('addressbook','active_tid',$content['nm']['col_filter']['tid']);
@@ -312,7 +331,10 @@  discard block
 block discarded – undo
312 331
 		$sel_options['adr_one_countrycode']['-custom-'] = lang('No country selected');
313 332
 
314 333
 		// if there is any export limit set, pass it on to the nextmatch, to be evaluated by the export
315
-		if (isset($this->config['contact_export_limit']) && (int)$this->config['contact_export_limit']) $content['nm']['export_limit']=$this->config['contact_export_limit'];
334
+		if (isset($this->config['contact_export_limit']) && (int)$this->config['contact_export_limit'])
335
+		{
336
+			$content['nm']['export_limit']=$this->config['contact_export_limit'];
337
+		}
316 338
 
317 339
 		// dont show tid-selection if we have only one content_type
318 340
 		// be a bit more sophisticated about it
@@ -322,7 +344,10 @@  discard block
 block discarded – undo
322 344
 			//_debug_array(array('Typefilter:'=> $content['nm']['col_filter']['tid'],'Available Types:'=>$availabletypes,'action:'=>'remove invalid filter'));
323 345
 			unset($content['nm']['col_filter']['tid']);
324 346
 		}
325
-		if (!isset($content['nm']['col_filter']['tid'])) $content['nm']['col_filter']['tid'] = $availabletypes[0];
347
+		if (!isset($content['nm']['col_filter']['tid']))
348
+		{
349
+			$content['nm']['col_filter']['tid'] = $availabletypes[0];
350
+		}
326 351
 		if (count($this->content_types) > 1)
327 352
 		{
328 353
 			foreach($this->content_types as $tid => $data)
@@ -421,7 +446,10 @@  discard block
 block discarded – undo
421 446
 		$crm_apps = array('infolog','tracker');
422 447
 		foreach($crm_apps as $app)
423 448
 		{
424
-			if ($GLOBALS['egw_info']['user']['apps'][$app]) $crm_count++;
449
+			if ($GLOBALS['egw_info']['user']['apps'][$app])
450
+			{
451
+				$crm_count++;
452
+			}
425 453
 		}
426 454
 		if($crm_count > 1)
427 455
 		{
@@ -477,7 +505,10 @@  discard block
 block discarded – undo
477 505
 				),
478 506
 			),
479 507
 		);
480
-		if (!$GLOBALS['egw_info']['user']['apps']['preferences']) unset($actions['cats']['children']['cat_edit']);
508
+		if (!$GLOBALS['egw_info']['user']['apps']['preferences'])
509
+		{
510
+			unset($actions['cats']['children']['cat_edit']);
511
+		}
481 512
 		// Submenu for all distributionlist stuff
482 513
 		$actions['lists'] = array(
483 514
 			'caption' => 'Distribution lists',
@@ -490,7 +521,9 @@  discard block
 block discarded – undo
490 521
 			),
491 522
 			'group' => $group,
492 523
 		);
493
-		if (($add_lists = $this->get_lists(Acl::EDIT)))	// do we have distribution lists?, and are we allowed to edit them
524
+		if (($add_lists = $this->get_lists(Acl::EDIT)))
525
+		{
526
+			// do we have distribution lists?, and are we allowed to edit them
494 527
 		{
495 528
 			$actions['lists']['children'] += array(
496 529
 				'to_list' => array(
@@ -526,6 +559,7 @@  discard block
 block discarded – undo
526 559
 					'fieldValue' => '!',	// enable if list != ''
527 560
 				),
528 561
 			);
562
+		}
529 563
 			if(is_subclass_of('etemplate', 'etemplate_new'))
530 564
 			{
531 565
 				$actions['lists']['children']['remove_from_list']['fieldId'] = 'filter2';
@@ -534,9 +568,13 @@  discard block
 block discarded – undo
534 568
 			}
535 569
 		}
536 570
 		// move to AB
537
-		if (($move2addressbooks = $this->get_addressbooks(Acl::ADD)))	// do we have addressbooks, we should
571
+		if (($move2addressbooks = $this->get_addressbooks(Acl::ADD)))
538 572
 		{
539
-			unset($move2addressbooks[0]);	// do not offer action to move contact to an account, as we dont support that currrently
573
+			// do we have addressbooks, we should
574
+		{
575
+			unset($move2addressbooks[0]);
576
+		}
577
+		// do not offer action to move contact to an account, as we dont support that currrently
540 578
 			foreach($move2addressbooks as $owner => $label)
541 579
 			{
542 580
 				$icon = $type_label = null;
@@ -667,7 +705,9 @@  discard block
 block discarded – undo
667 705
 
668 706
 			);
669 707
 		if (!$this->prefs['preferredMail'])
670
-			$actions['email']['children']['email_business']['checked'] = true;
708
+		{
709
+					$actions['email']['children']['email_business']['checked'] = true;
710
+		}
671 711
 
672 712
 		if ($GLOBALS['egw_info']['user']['apps']['filemanager'])
673 713
 		{
@@ -811,11 +851,17 @@  discard block
 block discarded – undo
811 851
 	private function _get_org_name($org)
812 852
 	{
813 853
 		$org_name = array();
814
-		if (strpos($org,'*AND*')!== false) $org = str_replace('*AND*','&',$org);
854
+		if (strpos($org,'*AND*')!== false)
855
+		{
856
+			$org = str_replace('*AND*','&',$org);
857
+		}
815 858
 		foreach(explode('|||',$org) as $part)
816 859
 		{
817 860
 			list(,$name) = explode(':',$part,2);
818
-			if ($name) $org_name[] = $name;
861
+			if ($name)
862
+			{
863
+				$org_name[] = $name;
864
+			}
819 865
 		}
820 866
 		$name = implode(': ',$org_name);
821 867
 		return $name ? array($org => $name) : array();
@@ -877,9 +923,15 @@  discard block
 block discarded – undo
877 923
 		$org_contacts = array();
878 924
 		$query = !$_query ? Api\Cache::getSession('addressbook', 'index') : $_query;
879 925
 		$query['num_rows'] = -1;	// all
880
-		if(!is_array($query['col_filter'])) $query['col_filter'] = array();
926
+		if(!is_array($query['col_filter']))
927
+		{
928
+			$query['col_filter'] = array();
929
+		}
881 930
 
882
-		if(!is_array($org)) $org = array($org);
931
+		if(!is_array($org))
932
+		{
933
+			$org = array($org);
934
+		}
883 935
 		foreach($org as $org_name)
884 936
 		{
885 937
 			$query['org_view'] = $org_name;
@@ -908,14 +960,23 @@  discard block
 block discarded – undo
908 960
 		$checked = $readonlys = null;
909 961
 		$this->get_rows($query,$checked,$readonlys,true);	// true = only return the id's
910 962
 
911
-		if (count($checked) > 1)	// use a nicely formatted org-name as title in infolog
963
+		if (count($checked) > 1)
964
+		{
965
+			// use a nicely formatted org-name as title in infolog
912 966
 		{
913 967
 			$parts = array();
914
-			if (strpos($org,'*AND*')!== false) $org = str_replace('*AND*','&',$org);
968
+		}
969
+			if (strpos($org,'*AND*')!== false)
970
+			{
971
+				$org = str_replace('*AND*','&',$org);
972
+			}
915 973
 			foreach(explode('|||',$org) as $part)
916 974
 			{
917 975
 				list(,$part) = explode(':',$part,2);
918
-				if ($part) $parts[] = $part;
976
+				if ($part)
977
+				{
978
+					$parts[] = $part;
979
+				}
919 980
 			}
920 981
 			$org = implode(', ',$parts);
921 982
 		}
@@ -940,13 +1001,19 @@  discard block
 block discarded – undo
940 1001
 
941 1002
 		$response = Api\Json\Response::get();
942 1003
 
943
-		if ($success) $response->addScript(Framework::set_onload(''));
1004
+		if ($success)
1005
+		{
1006
+			$response->addScript(Framework::set_onload(''));
1007
+		}
944 1008
 
945 1009
 		// close window only if no errors AND something added
946 1010
 		if ($failed || !$success)
947 1011
 		{
948
-			if (!$msg) $msg = $failed ? lang('%1 contact(s) %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed) :
1012
+			if (!$msg)
1013
+			{
1014
+				$msg = $failed ? lang('%1 contact(s) %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed) :
949 1015
 				lang('%1 contact(s) %2',$success,$action_msg);
1016
+			}
950 1017
 
951 1018
 			$response->addScript("alert('".addslashes($msg)."')");
952 1019
 			// reset the filter
@@ -954,7 +1021,10 @@  discard block
 block discarded – undo
954 1021
 		}
955 1022
 		else
956 1023
 		{
957
-			if (!$msg) $msg = lang('%1 contact(s) %2',$success,$action_msg);
1024
+			if (!$msg)
1025
+			{
1026
+				$msg = lang('%1 contact(s) %2',$success,$action_msg);
1027
+			}
958 1028
 			$response->addScript("alert('".addslashes($msg)."')");
959 1029
 			$response->addScript('egw(window).close();');
960 1030
 		}
@@ -1063,10 +1133,16 @@  discard block
 block discarded – undo
1063 1133
 				unset($query['filter2']);
1064 1134
 				$extra = $readonlys = null;
1065 1135
 				$this->get_rows($query,$extra,$readonlys,true);	// true = only return the id's
1066
-				if ($extra[0]) $org_contacts = array_merge($org_contacts,$extra);
1136
+				if ($extra[0])
1137
+				{
1138
+					$org_contacts = array_merge($org_contacts,$extra);
1139
+				}
1067 1140
 			}
1068 1141
 		}
1069
-		if ($org_contacts) $checked = array_unique($checked ? array_merge($checked,$org_contacts) : $org_contacts);
1142
+		if ($org_contacts)
1143
+		{
1144
+			$checked = array_unique($checked ? array_merge($checked,$org_contacts) : $org_contacts);
1145
+		}
1070 1146
 		//_debug_array($checked); exit;
1071 1147
 
1072 1148
 		if (substr($action,0,8) == 'move_to_')
@@ -1083,9 +1159,12 @@  discard block
 block discarded – undo
1083 1159
 			$document = substr($action,9);
1084 1160
 			$action = 'document';
1085 1161
 		}
1086
-		elseif(substr($action,0,4) == 'cat_')	// cat_add_123 or cat_del_456
1162
+		elseif(substr($action,0,4) == 'cat_')
1163
+		{
1164
+			// cat_add_123 or cat_del_456
1087 1165
 		{
1088 1166
 			$cat_id = (int)substr($action, 8);
1167
+		}
1089 1168
 			$action = substr($action,0,7);
1090 1169
 		}
1091 1170
 		// Security: stop non-admins to export more then the configured number of contacts
@@ -1132,7 +1211,10 @@  discard block
 block discarded – undo
1132 1211
 				return false;
1133 1212
 
1134 1213
 			case 'document':
1135
-				if (!$document) $document = $this->prefs['default_document'];
1214
+				if (!$document)
1215
+				{
1216
+					$document = $this->prefs['default_document'];
1217
+				}
1136 1218
 				$document_merge = new Api\Contacts\Merge();
1137 1219
 				$msg = $document_merge->download($document, $checked, '', $this->prefs['document_dir']);
1138 1220
 				$failed = count($checked);
@@ -1284,19 +1366,25 @@  discard block
 block discarded – undo
1284 1366
 					break;
1285 1367
 
1286 1368
 				default:	// move to an other addressbook
1287
-					if (!(int)$action || !($this->grants[(string) (int) $action] & Acl::EDIT))	// might be ADD in the future
1369
+					if (!(int)$action || !($this->grants[(string) (int) $action] & Acl::EDIT))
1370
+					{
1371
+						// might be ADD in the future
1288 1372
 					{
1289 1373
 						return false;
1290 1374
 					}
1375
+					}
1291 1376
 					if (!$checkboxes['move_to_copy'])
1292 1377
 					{
1293 1378
 						$action_msg = lang('moved');
1294 1379
 						if (($Ok = !!($contact = $this->read($id)) && $this->check_perms(Acl::DELETE,$contact)))
1295 1380
 						{
1296
-							if (!$contact['owner'])		// no (mass-)move of Api\Accounts
1381
+							if (!$contact['owner'])
1382
+							{
1383
+								// no (mass-)move of Api\Accounts
1297 1384
 							{
1298 1385
 								$Ok = false;
1299 1386
 							}
1387
+							}
1300 1388
 							elseif ($contact['owner'] != (int)$action || $contact['private'] != (int)(substr($action,-1) == 'p'))
1301 1389
 							{
1302 1390
 								$contact['owner'] = (int) $action;
@@ -1385,9 +1473,12 @@  discard block
 block discarded – undo
1385 1473
 		$do_email = $query['do_email'];
1386 1474
 		$what = $query['sitemgr_display'] ? $query['sitemgr_display'] : ($do_email ? 'email' : 'index');
1387 1475
 
1388
-		if (!$id_only && !$query['csv_export'])	// do NOT store state for csv_export or querying id's (no regular view)
1476
+		if (!$id_only && !$query['csv_export'])
1477
+		{
1478
+			// do NOT store state for csv_export or querying id's (no regular view)
1389 1479
 		{
1390 1480
 			$store_query = $query;
1481
+		}
1391 1482
 			// Do not store these
1392 1483
 			foreach(array('options-cat_id','actions') as $key)
1393 1484
 			{
@@ -1399,14 +1490,25 @@  discard block
 block discarded – undo
1399 1490
 		{
1400 1491
 			$old_state = Api\Cache::getSession('addressbook', $what);
1401 1492
 		}
1402
-		if (!isset($this->org_views[(string) $query['org_view']]) || strpos($query['org_view'],':') === false)   // we dont have an org view, unset the according col_filters
1493
+		if (!isset($this->org_views[(string) $query['org_view']]) || strpos($query['org_view'],':') === false)
1494
+		{
1495
+			// we dont have an org view, unset the according col_filters
1403 1496
 		{
1404 1497
 			if (isset($query['col_filter']['org_name'])) unset($query['col_filter']['org_name']);
1405
-			if (isset($query['col_filter']['adr_one_locality'])) unset($query['col_filter']['adr_one_locality']);
1406
-			if (isset($query['col_filter']['org_unit'])) unset($query['col_filter']['org_unit']);
1498
+		}
1499
+			if (isset($query['col_filter']['adr_one_locality']))
1500
+			{
1501
+				unset($query['col_filter']['adr_one_locality']);
1502
+			}
1503
+			if (isset($query['col_filter']['org_unit']))
1504
+			{
1505
+				unset($query['col_filter']['org_unit']);
1506
+			}
1407 1507
 		}
1408 1508
 
1409
-		if (isset($this->org_views[(string) $query['org_view']]))	// we have an org view, reset the advanced search
1509
+		if (isset($this->org_views[(string) $query['org_view']]))
1510
+		{
1511
+			// we have an org view, reset the advanced search
1410 1512
 		{
1411 1513
 			//_debug_array(array('Search'=>$query['search'],
1412 1514
 			//	'AdvancedSearch'=>$query['advanced_search']));
@@ -1414,10 +1516,14 @@  discard block
 block discarded – undo
1414 1516
 			//unset($query['advanced_search']);
1415 1517
 			if(!$query['search'] && $old_state['advanced_search']) $query['advanced_search'] = $old_state['advanced_search'];
1416 1518
 		}
1417
-		elseif(!$query['search'] && $old_state['advanced_search'])	// eg. paging in an advanced search
1519
+		}
1520
+		elseif(!$query['search'] && $old_state['advanced_search'])
1521
+		{
1522
+			// eg. paging in an advanced search
1418 1523
 		{
1419 1524
 			$query['advanced_search'] = $old_state['advanced_search'];
1420 1525
 		}
1526
+		}
1421 1527
 		/* this cant work anymore, as Framework::set_onload no longer exists
1422 1528
 		if ($do_email && etemplate::$loop)
1423 1529
 		{	// remove previous addEmail() calls, otherwise they will be run again
@@ -1427,11 +1533,13 @@  discard block
 block discarded – undo
1427 1533
 		// Make sure old lettersearch filter doesn't stay - current letter filter will be added later
1428 1534
 		foreach($query['col_filter'] as $key => $col_filter)
1429 1535
 		{
1430
-			if(!is_numeric($key)) continue;
1536
+			if(!is_numeric($key))
1537
+			{
1538
+				continue;
1539
+			}
1431 1540
 			if(preg_match('/'.$GLOBALS['egw']->db->capabilities['case_insensitive_like'].
1432 1541
 				' '.$GLOBALS['egw']->db->quote('[a-z]%').'$/',$col_filter) == 1
1433
-			)
1434
-			{
1542
+			) {
1435 1543
 				unset($query['col_filter'][$key]);
1436 1544
 			}
1437 1545
 		}
@@ -1442,9 +1550,13 @@  discard block
 block discarded – undo
1442 1550
 			// check if accounts are stored in ldap, which does NOT yet support the org-views
1443 1551
 			if ($this->so_accounts && $query['filter'] === '0' && $query['org_view'])
1444 1552
 			{
1445
-				if ($old_state['filter'] === '0')	// user changed to org_view
1553
+				if ($old_state['filter'] === '0')
1446 1554
 				{
1447
-					$query['filter'] = '';			// --> change filter to all contacts
1555
+					// user changed to org_view
1556
+				{
1557
+					$query['filter'] = '';
1558
+				}
1559
+				// --> change filter to all contacts
1448 1560
 				}
1449 1561
 				else								// user changed to accounts
1450 1562
 				{
@@ -1481,9 +1593,12 @@  discard block
 block discarded – undo
1481 1593
 		{
1482 1594
 			unset($query['col_filter']['cat_id']);
1483 1595
 		}
1484
-		if ($query['filter'] !== '')	// not all addressbooks
1596
+		if ($query['filter'] !== '')
1597
+		{
1598
+			// not all addressbooks
1485 1599
 		{
1486 1600
 			$query['col_filter']['owner'] = (string) (int) $query['filter'];
1601
+		}
1487 1602
 
1488 1603
 			if ($this->private_addressbook)
1489 1604
 			{
@@ -1495,10 +1610,13 @@  discard block
 block discarded – undo
1495 1610
 			unset($query['col_filter']['owner']);
1496 1611
 			unset($query['col_filter']['private']);
1497 1612
 		}
1498
-		if ((int)$query['filter2'])	// not no distribution list
1613
+		if ((int)$query['filter2'])
1614
+		{
1615
+			// not no distribution list
1499 1616
 		{
1500 1617
 			$query['col_filter']['list'] = (string) (int) $query['filter2'];
1501 1618
 		}
1619
+		}
1502 1620
 		else
1503 1621
 		{
1504 1622
 			unset($query['col_filter']['list']);
@@ -1510,10 +1628,13 @@  discard block
 block discarded – undo
1510 1628
 		// enable/disable distribution lists depending on backend
1511 1629
 		$query['no_filter2'] = !$this->lists_available($query['filter']);
1512 1630
 
1513
-		if (isset($this->org_views[(string) $query['org_view']]) && !$query['col_filter']['parent_id'])	// we have an org view
1631
+		if (isset($this->org_views[(string) $query['org_view']]) && !$query['col_filter']['parent_id'])
1632
+		{
1633
+			// we have an org view
1514 1634
 		{
1515 1635
 			// Query doesn't like empties
1516 1636
 			unset($query['col_filter']['parent_id']);
1637
+		}
1517 1638
 
1518 1639
 			if($query['actions'] && $query['actions']['open'])
1519 1640
 			{
@@ -1566,9 +1687,12 @@  discard block
 block discarded – undo
1566 1687
 			}
1567 1688
 			// Query doesn't like parent_id
1568 1689
 			unset($query['col_filter']['parent_id']);
1569
-			if ($query['org_view'])	// view the contacts of one organisation only
1690
+			if ($query['org_view'])
1691
+			{
1692
+				// view the contacts of one organisation only
1570 1693
 			{
1571 1694
 				if (strpos($query['org_view'],'*AND*') !== false) $query['org_view'] = str_replace('*AND*','&',$query['org_view']);
1695
+			}
1572 1696
 				foreach(explode('|||',$query['org_view']) as $part)
1573 1697
 				{
1574 1698
 					list($name,$value) = explode(':',$part,2);
@@ -1587,14 +1711,18 @@  discard block
 block discarded – undo
1587 1711
 			// translate the select order to the really used over all 3 columns
1588 1712
 			$sort = $query['sort'];
1589 1713
 			switch($query['order'])		// "xxx<>'' DESC" sorts contacts with empty order-criteria always at the end
1590
-			{							// we don't exclude them, as the total would otherwise depend on the order-criteria
1714
+			{
1715
+// we don't exclude them, as the total would otherwise depend on the order-criteria
1591 1716
 				case 'org_name':
1592 1717
 					$order = "egw_addressbook.org_name<>''DESC,egw_addressbook.org_name $sort,n_family $sort,n_given $sort";
1593 1718
 					break;
1594 1719
 				default:
1595
-					if ($query['order'][0] == '#')	// we order by a custom field
1720
+					if ($query['order'][0] == '#')
1721
+					{
1722
+						// we order by a custom field
1596 1723
 					{
1597 1724
 						$order = "{$query['order']} $sort,org_name $sort,n_family $sort,n_given $sort";
1725
+					}
1598 1726
 						break;
1599 1727
 					}
1600 1728
 					$query['order'] = 'n_family';
@@ -1618,9 +1746,12 @@  discard block
 block discarded – undo
1618 1746
 				case 'contact_id':
1619 1747
 					$order = "egw_addressbook.$query[order] $sort";
1620 1748
 			}
1621
-			if ($query['searchletter'])	// only show contacts if the order-criteria starts with the given letter
1749
+			if ($query['searchletter'])
1750
+			{
1751
+				// only show contacts if the order-criteria starts with the given letter
1622 1752
 			{
1623 1753
 				$no_letter_search = array('adr_one_postalcode', 'adr_two_postalcode', 'contact_id', 'contact_created','contact_modified');
1754
+			}
1624 1755
 				$query['col_filter'][] = (in_array($query['order'],$no_letter_search) ? 'org_name' : (substr($query['order'],0,1)=='#'?'':'egw_addressbook.').$query['order']).' '.
1625 1756
 					$GLOBALS['egw']->db->capabilities['case_insensitive_like'].' '.$GLOBALS['egw']->db->quote(strtolower($query['searchletter']).'%');
1626 1757
 			}
@@ -1658,11 +1789,17 @@  discard block
 block discarded – undo
1658 1789
 					{
1659 1790
 						foreach($columselection as $col)
1660 1791
 						{
1661
-							if ($col[0] == '#') $selected_cfs[] = substr($col,1);
1792
+							if ($col[0] == '#')
1793
+							{
1794
+								$selected_cfs[] = substr($col,1);
1795
+							}
1662 1796
 						}
1663 1797
 						$customfields = $this->read_customfields($ids,$selected_cfs);
1664 1798
 					}
1665
-					if ($show_calendar && !empty($ids)) $calendar = $this->read_calendar($ids);
1799
+					if ($show_calendar && !empty($ids))
1800
+					{
1801
+						$calendar = $this->read_calendar($ids);
1802
+					}
1666 1803
 					// distributionlist memership for the entrys
1667 1804
 					//_debug_array($this->get_lists(Acl::EDIT));
1668 1805
 					if ($show_distributionlist && $available_distib_lists)
@@ -1672,7 +1809,10 @@  discard block
 block discarded – undo
1672 1809
 				}
1673 1810
 			}
1674 1811
 		}
1675
-		if (!$rows) $rows = array();
1812
+		if (!$rows)
1813
+		{
1814
+			$rows = array();
1815
+		}
1676 1816
 
1677 1817
 		if ($id_only)
1678 1818
 		{
@@ -1705,7 +1845,10 @@  discard block
 block discarded – undo
1705 1845
 					$row['line2'] = $row['org_name'];
1706 1846
 					break;
1707 1847
 				case 'n_fileas':
1708
-					if (!$row['n_fileas']) $row['n_fileas'] = $this->fileas($row);
1848
+					if (!$row['n_fileas'])
1849
+					{
1850
+						$row['n_fileas'] = $this->fileas($row);
1851
+					}
1709 1852
 					list($row['line1'],$row['line2']) = explode(': ',$row['n_fileas']);
1710 1853
 					break;
1711 1854
 			}
@@ -1779,8 +1922,14 @@  discard block
 block discarded – undo
1779 1922
 			}
1780 1923
 
1781 1924
 			// hide region for address format 'postcode_city'
1782
-			if (($row['addr_format']  = $this->addr_format_by_country($row['adr_one_countryname']))=='postcode_city') unset($row['adr_one_region']);
1783
-			if (($row['addr_format2'] = $this->addr_format_by_country($row['adr_two_countryname']))=='postcode_city') unset($row['adr_two_region']);
1925
+			if (($row['addr_format']  = $this->addr_format_by_country($row['adr_one_countryname']))=='postcode_city')
1926
+			{
1927
+				unset($row['adr_one_region']);
1928
+			}
1929
+			if (($row['addr_format2'] = $this->addr_format_by_country($row['adr_two_countryname']))=='postcode_city')
1930
+			{
1931
+				unset($row['adr_two_region']);
1932
+			}
1784 1933
 
1785 1934
 			// respect category permissions
1786 1935
 			if(!empty($row['cat_id']))
@@ -1791,7 +1940,10 @@  discard block
 block discarded – undo
1791 1940
 		$rows['no_distribution_list'] = (bool)$query['filter2'];
1792 1941
 
1793 1942
 		// disable customfields column, if we have no customefield(s)
1794
-		if (!$this->customfields) $rows['no_customfields'] = true;
1943
+		if (!$this->customfields)
1944
+		{
1945
+			$rows['no_customfields'] = true;
1946
+		}
1795 1947
 
1796 1948
 		$rows['order'] = $order;
1797 1949
 		$rows['call_popup'] = $this->config['call_popup'];
@@ -1830,10 +1982,13 @@  discard block
 block discarded – undo
1830 1982
 			$order = $order == 'n_given' ? lang('first name') : ($order == 'n_family' ? lang('last name') : lang('Organisation'));
1831 1983
 			$header[] = lang("%1 starts with '%2'",$order,$query['searchletter']);
1832 1984
 		}
1833
-		if ($query['search'] && !$query['advanced_search']) // do not add that, if we have advanced search active
1985
+		if ($query['search'] && !$query['advanced_search'])
1986
+		{
1987
+			// do not add that, if we have advanced search active
1834 1988
 		{
1835 1989
 			$header[] = lang("Search for '%1'",$query['search']);
1836 1990
 		}
1991
+		}
1837 1992
 		$GLOBALS['egw_info']['flags']['app_header'] = implode(': ', $header);
1838 1993
 
1839 1994
 		return $this->total;
@@ -1900,7 +2055,10 @@  discard block
 block discarded – undo
1900 2055
 			$content['private'] = (int) ($content['owner'] && substr($content['owner'],-1) == 'p');
1901 2056
 			$content['owner'] = (string) (int) $content['owner'];
1902 2057
 			$content['cat_id'] = $this->config['cat_tab'] === 'Tree' ? $content['cat_id_tree'] : $content['cat_id'];
1903
-			if ($this->config['private_cf_tab']) $content = (array)$content['private_cfs'] + $content;
2058
+			if ($this->config['private_cf_tab'])
2059
+			{
2060
+				$content = (array)$content['private_cfs'] + $content;
2061
+			}
1904 2062
 			unset($content['private_cfs']);
1905 2063
 
1906 2064
 			switch($button)
@@ -2097,7 +2255,10 @@  discard block
 block discarded – undo
2097 2255
 				{
2098 2256
 					// arguments containing a comma get quoted by etemplate/js/nextmatch_action.js
2099 2257
 					// leading to error in Api\Db::column_data_implode, if not unquoted
2100
-					if ($org[0] == '"') $org = substr($org, 1, -1);
2258
+					if ($org[0] == '"')
2259
+					{
2260
+						$org = substr($org, 1, -1);
2261
+					}
2101 2262
 					$content = $this->read_org($org);
2102 2263
 				}
2103 2264
 				elseif ($state['org_view'] && !isset($this->org_views[$state['org_view']]))
@@ -2117,7 +2278,10 @@  discard block
 block discarded – undo
2117 2278
 						$content['adr_two_countryname'] =
2118 2279
 							$GLOBALS['egw']->country->get_full_name($GLOBALS['egw_info']['user']['preferences']['common']['country']);
2119 2280
 					}
2120
-					if ($this->prefs['fileas_default']) $content['fileas_type'] = $this->prefs['fileas_default'];
2281
+					if ($this->prefs['fileas_default'])
2282
+					{
2283
+						$content['fileas_type'] = $this->prefs['fileas_default'];
2284
+					}
2121 2285
 				}
2122 2286
 				if (isset($_GET['owner']) && $_GET['owner'] !== '')
2123 2287
 				{
@@ -2142,7 +2306,10 @@  discard block
 block discarded – undo
2142 2306
 				$new_type = array_keys($this->content_types);
2143 2307
 				// fetch active type to preset the type, if param typeid is not passed
2144 2308
 				$active_tid = Api\Cache::getSession('addressbook','active_tid');
2145
-				if ($active_tid && strtoupper($active_tid) === 'D') unset($active_tid);
2309
+				if ($active_tid && strtoupper($active_tid) === 'D')
2310
+				{
2311
+					unset($active_tid);
2312
+				}
2146 2313
 				$content['tid'] = $_GET['typeid'] ? $_GET['typeid'] : ($active_tid?$active_tid:$new_type[0]);
2147 2314
 				foreach($this->get_contact_columns() as $field)
2148 2315
 				{
@@ -2160,19 +2327,37 @@  discard block
 block discarded – undo
2160 2327
 									if (strpos($singleAddress[0]->personal,',')===false)
2161 2328
 									{
2162 2329
 										list($P_n_given,$P_n_family,$P_org_name)=explode(' ',$singleAddress[0]->personal,3);
2163
-										if (strlen(trim($P_n_given))>0) $content['n_given'] = trim($P_n_given);
2164
-										if (strlen(trim($P_n_family))>0) $content['n_family'] = trim($P_n_family);
2165
-										if (strlen(trim($P_org_name))>0) $content['org_name'] = trim($P_org_name);
2330
+										if (strlen(trim($P_n_given))>0)
2331
+										{
2332
+											$content['n_given'] = trim($P_n_given);
2333
+										}
2334
+										if (strlen(trim($P_n_family))>0)
2335
+										{
2336
+											$content['n_family'] = trim($P_n_family);
2337
+										}
2338
+										if (strlen(trim($P_org_name))>0)
2339
+										{
2340
+											$content['org_name'] = trim($P_org_name);
2341
+										}
2166 2342
 									}
2167 2343
 									else
2168 2344
 									{
2169 2345
 										list($P_n_family,$P_other)=explode(',',$singleAddress[0]->personal,2);
2170
-										if (strlen(trim($P_n_family))>0) $content['n_family'] = trim($P_n_family);
2346
+										if (strlen(trim($P_n_family))>0)
2347
+										{
2348
+											$content['n_family'] = trim($P_n_family);
2349
+										}
2171 2350
 										if (strlen(trim($P_other))>0)
2172 2351
 										{
2173 2352
 											list($P_n_given,$P_org_name)=explode(',',$P_other,2);
2174
-											if (strlen(trim($P_n_given))>0) $content['n_given'] = trim($P_n_given);
2175
-											if (strlen(trim($P_org_name))>0) $content['org_name'] = trim($P_org_name);
2353
+											if (strlen(trim($P_n_given))>0)
2354
+											{
2355
+												$content['n_given'] = trim($P_n_given);
2356
+											}
2357
+											if (strlen(trim($P_org_name))>0)
2358
+											{
2359
+												$content['org_name'] = trim($P_org_name);
2360
+											}
2176 2361
 										}
2177 2362
 									}
2178 2363
 								}
@@ -2200,7 +2385,10 @@  discard block
 block discarded – undo
2200 2385
 							break;
2201 2386
 						}
2202 2387
 					}
2203
-					if (empty($content['n_fn'])) $content['n_fn'] = $this->fullname($content);
2388
+					if (empty($content['n_fn']))
2389
+					{
2390
+						$content['n_fn'] = $this->fullname($content);
2391
+					}
2204 2392
 				}
2205 2393
 				$content['creator'] = $this->user;
2206 2394
 				$content['created'] = $this->now_su;
@@ -2208,17 +2396,27 @@  discard block
 block discarded – undo
2208 2396
 				//_debug_array($content);
2209 2397
 			}
2210 2398
 
2211
-			if ($_GET['msg']) $content['msg'] = strip_tags($_GET['msg']);	// dont allow HTML!
2399
+			if ($_GET['msg'])
2400
+			{
2401
+				$content['msg'] = strip_tags($_GET['msg']);
2402
+			}
2403
+			// dont allow HTML!
2212 2404
 
2213
-			if($content && $_GET['makecp'])	// copy the contact
2405
+			if($content && $_GET['makecp'])
2406
+			{
2407
+				// copy the contact
2214 2408
 			{
2215 2409
 				$this->copy_contact($content);
2410
+			}
2216 2411
 				$content['msg'] = lang('Contact copied');
2217 2412
 				$view = false;
2218 2413
 			}
2219 2414
 			else
2220 2415
 			{
2221
-				if (is_numeric($contact_id)) $content['link_to']['to_id'] = $contact_id;
2416
+				if (is_numeric($contact_id))
2417
+				{
2418
+					$content['link_to']['to_id'] = $contact_id;
2419
+				}
2222 2420
 			}
2223 2421
 			// automatic link new entries to entries specified in the url
2224 2422
 			if (!$contact_id && isset($_REQUEST['link_app']) && isset($_REQUEST['link_id']) && !is_array($content['link_to']['to_id']))
@@ -2227,10 +2425,13 @@  discard block
 block discarded – undo
2227 2425
 				foreach(is_array($_REQUEST['link_app']) ? $_REQUEST['link_app'] : array($_REQUEST['link_app']) as $n => $link_app)
2228 2426
 				{
2229 2427
 					$link_id = $link_ids[$n];
2230
-					if (preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id))	// gard against XSS
2428
+					if (preg_match('/^[a-z_0-9-]+:[:a-z_0-9-]+$/i',$link_app.':'.$link_id))
2429
+					{
2430
+						// gard against XSS
2231 2431
 					{
2232 2432
 						Link::link('addressbook',$content['link_to']['to_id'],$link_app,$link_id);
2233 2433
 					}
2434
+					}
2234 2435
 				}
2235 2436
 			}
2236 2437
 		}
@@ -2238,7 +2439,10 @@  discard block
 block discarded – undo
2238 2439
 		{
2239 2440
 			// last and next calendar date
2240 2441
 			list(,$dates) = each($this->read_calendar(array($content['id']),false));
2241
-			if(is_array($dates)) $content += $dates;
2442
+			if(is_array($dates))
2443
+			{
2444
+				$content += $dates;
2445
+			}
2242 2446
 		}
2243 2447
 		// Avoid ID conflict with tree & selectboxes
2244 2448
 		$content['cat_id_tree'] = $content['cat_id'];
@@ -2272,7 +2476,11 @@  discard block
 block discarded – undo
2272 2476
 		$sel_options['fileas_type'] = $this->fileas_options($content);
2273 2477
 		$sel_options['adr_one_countrycode']['-custom-'] = lang('Custom');
2274 2478
 		$sel_options['owner'] = $this->get_addressbooks(Acl::ADD);
2275
-		if ($content['owner']) unset($sel_options['owner'][0]);	// do not offer to switch to accounts, as we do not support moving contacts to accounts
2479
+		if ($content['owner'])
2480
+		{
2481
+			unset($sel_options['owner'][0]);
2482
+		}
2483
+		// do not offer to switch to accounts, as we do not support moving contacts to accounts
2276 2484
 		if ((string) $content['owner'] !== '')
2277 2485
 		{
2278 2486
 			if (!isset($sel_options['owner'][(int)$content['owner']]))
@@ -2299,7 +2507,10 @@  discard block
 block discarded – undo
2299 2507
 				$readonlys[$field] = false;
2300 2508
 			}
2301 2509
 		}
2302
-		if (isset($readonlys['n_fileas'])) $readonlys['fileas_type'] = $readonlys['n_fileas'];
2510
+		if (isset($readonlys['n_fileas']))
2511
+		{
2512
+			$readonlys['fileas_type'] = $readonlys['n_fileas'];
2513
+		}
2303 2514
 		// disable not needed tabs
2304 2515
 		$readonlys['tabs']['cats'] = !($content['cat_tab'] = $this->config['cat_tab']);
2305 2516
 		$readonlys['tabs']['custom'] = !$this->customfields || $this->get_backend($content['id'],$content['owner']) == $this->so_accounts;
@@ -2307,8 +2518,14 @@  discard block
 block discarded – undo
2307 2518
 		$readonlys['tabs']['distribution_list'] = !$content['distrib_lists'];#false;
2308 2519
 		$readonlys['tabs']['history'] = $this->contact_repository != 'sql' || !$content['id'] ||
2309 2520
 			$this->account_repository != 'sql' && $content['account_id'];
2310
-		if (!$content['id']) $readonlys['button[delete]'] = !$content['id'];
2311
-		if ($this->config['private_cf_tab']) $content['no_private_cfs'] = 0;
2521
+		if (!$content['id'])
2522
+		{
2523
+			$readonlys['button[delete]'] = !$content['id'];
2524
+		}
2525
+		if ($this->config['private_cf_tab'])
2526
+		{
2527
+			$content['no_private_cfs'] = 0;
2528
+		}
2312 2529
 		$readonlys['change_org'] = empty($content['org_name']) || $view;
2313 2530
 
2314 2531
 		// for editing the own account (by a non-admin), enable only the fields allowed via the "own_account_acl"
@@ -2356,7 +2573,10 @@  discard block
 block discarded – undo
2356 2573
 
2357 2574
 		$content['photo'] = $this->photo_src($content['id'],$content['jpegphoto'],'photo',$content['etag']);
2358 2575
 
2359
-		if ($content['private']) $content['owner'] .= 'p';
2576
+		if ($content['private'])
2577
+		{
2578
+			$content['owner'] .= 'p';
2579
+		}
2360 2580
 
2361 2581
 		// for custom types, check if we have a custom edit template named "addressbook.edit.$type", $type is the name
2362 2582
 		if (in_array($content['tid'], array('n',self::DELETED_TYPE)) || !$this->tmpl->read('addressbook.edit.'.$this->content_types[$content['tid']]['name']))
@@ -2378,7 +2598,10 @@  discard block
 block discarded – undo
2378 2598
 		//error_log(__METHOD__."() hook_data=".array2string($hook_data));
2379 2599
 		foreach($hook_data as $extra_tabs)
2380 2600
 		{
2381
-			if (!$extra_tabs) continue;
2601
+			if (!$extra_tabs)
2602
+			{
2603
+				continue;
2604
+			}
2382 2605
 
2383 2606
 			foreach(isset($extra_tabs[0]) ? $extra_tabs : array($extra_tabs) as $extra_tab)
2384 2607
 			{
@@ -2395,7 +2618,10 @@  discard block
 block discarded – undo
2395 2618
 					$readonlys = array_merge($readonlys, $extra_tab['readonlys']);
2396 2619
 				}
2397 2620
 				// we must NOT add tabs and callbacks more then once!
2398
-				if (!$first_call) continue;
2621
+				if (!$first_call)
2622
+				{
2623
+					continue;
2624
+				}
2399 2625
 
2400 2626
 				if (!empty($extra_tab['pre_save_callback']))
2401 2627
 				{
@@ -2479,20 +2705,27 @@  discard block
 block discarded – undo
2479 2705
 	public function ajax_check_values($values, $name, $own_id=0)
2480 2706
 	{
2481 2707
 		$matches = null;
2482
-		if (preg_match('/^exec\[([^\]]+)\]$/', $name, $matches)) $name = $matches[1];	// remove exec[ ]
2708
+		if (preg_match('/^exec\[([^\]]+)\]$/', $name, $matches))
2709
+		{
2710
+			$name = $matches[1];
2711
+		}
2712
+		// remove exec[ ]
2483 2713
 
2484 2714
 		$ret = array('doublicates' => array(), 'msg' => null);
2485 2715
 
2486 2716
 		// if email changed, check for doublicates
2487 2717
 		if (in_array($name, array('email', 'email_home')))
2488 2718
 		{
2489
-			if (preg_match('/^'.url_widget::EMAIL_PREG.'$/i', $values[$name]))	// only search for real email addresses, to not return to many contacts
2719
+			if (preg_match('/^'.url_widget::EMAIL_PREG.'$/i', $values[$name]))
2720
+			{
2721
+				// only search for real email addresses, to not return to many contacts
2490 2722
 			{
2491 2723
 				$contacts = parent::search(array(
2492 2724
 					'email' => $values[$name],
2493 2725
 					'email_home' => $values[$name],
2494 2726
 				), false, '', '', '', false, 'OR');
2495 2727
 			}
2728
+			}
2496 2729
 		}
2497 2730
 		else
2498 2731
 		{
@@ -2506,10 +2739,13 @@  discard block
 block discarded – undo
2506 2739
 				!empty($values['n_given'])+!empty($values['n_family'])+!empty($values['org_name']) >= 2)
2507 2740
 			{
2508 2741
 				$filter = array();
2509
-				foreach(array('email', 'n_given', 'n_family', 'org_name') as $n)	// use email too, to exclude obvious false positives
2742
+				foreach(array('email', 'n_given', 'n_family', 'org_name') as $n)
2743
+				{
2744
+					// use email too, to exclude obvious false positives
2510 2745
 				{
2511 2746
 					if (!empty($values[$n])) $filter[$n] = $values[$n];
2512 2747
 				}
2748
+				}
2513 2749
 				$contacts = parent::search('', false, '', '', '', false, 'AND', false, $filter);
2514 2750
 			}
2515 2751
 		}
@@ -2517,7 +2753,10 @@  discard block
 block discarded – undo
2517 2753
 		{
2518 2754
 			foreach($contacts as $contact)
2519 2755
 			{
2520
-				if ($own_id && $contact['id'] == $own_id) continue;
2756
+				if ($own_id && $contact['id'] == $own_id)
2757
+				{
2758
+					continue;
2759
+				}
2521 2760
 
2522 2761
 				$ret['doublicates'][$contact['id']] = $this->fileas($contact).' ('.
2523 2762
 					(!$contact['owner'] ? lang('Accounts') : ($contact['owner'] == $this->user ?
@@ -2544,7 +2783,10 @@  discard block
 block discarded – undo
2544 2783
 		// CRM list comes from content, request, or preference
2545 2784
 		$crm_list = $content['crm_list'] ? $content['crm_list'] :
2546 2785
 			($_GET['crm_list'] ? $_GET['crm_list'] : $GLOBALS['egw_info']['user']['preferences']['addressbook']['crm_list']);
2547
-		if(!$crm_list || $crm_list == '~edit~') $crm_list = 'infolog';
2786
+		if(!$crm_list || $crm_list == '~edit~')
2787
+		{
2788
+			$crm_list = 'infolog';
2789
+		}
2548 2790
 
2549 2791
 		if(is_array($content))
2550 2792
 		{
@@ -2567,7 +2809,10 @@  discard block
 block discarded – undo
2567 2809
 					$inc = 1;
2568 2810
 					// fall through
2569 2811
 				case 'back':
2570
-					if (!isset($inc)) $inc = -1;
2812
+					if (!isset($inc))
2813
+					{
2814
+						$inc = -1;
2815
+					}
2571 2816
 					// get next/previous contact in selection
2572 2817
 					$query = Api\Cache::getSession('addressbook', 'index');
2573 2818
 					$query['start'] = $content['index'] + $inc;
@@ -2730,11 +2975,20 @@  discard block
 block discarded – undo
2730 2975
 		$readonlys['tabs']['distribution_list'] = !$content['distrib_lists'];#false;
2731 2976
 		$readonlys['tabs']['history'] = $this->contact_repository != 'sql' || !$content['id'] ||
2732 2977
 			$this->account_repository != 'sql' && $content['account_id'];
2733
-		if ($this->config['private_cf_tab']) $content['no_private_cfs'] = 0;
2978
+		if ($this->config['private_cf_tab'])
2979
+		{
2980
+			$content['no_private_cfs'] = 0;
2981
+		}
2734 2982
 
2735 2983
 		// last and next calendar date
2736
-		if (!empty($content['id'])) list(,$dates) = each($this->read_calendar(array($content['id']),false));
2737
-		if(is_array($dates)) $content += $dates;
2984
+		if (!empty($content['id']))
2985
+		{
2986
+			list(,$dates) = each($this->read_calendar(array($content['id']),false));
2987
+		}
2988
+		if(is_array($dates))
2989
+		{
2990
+			$content += $dates;
2991
+		}
2738 2992
 
2739 2993
 		// Disable importexport
2740 2994
 		$GLOBALS['egw_info']['flags']['disable_importexport']['export'] = true;
@@ -2813,7 +3067,10 @@  discard block
 block discarded – undo
2813 3067
 	 */
2814 3068
 	function email2link($email)
2815 3069
 	{
2816
-		if (strpos($email,'@') == false) return '';
3070
+		if (strpos($email,'@') == false)
3071
+		{
3072
+			return '';
3073
+		}
2817 3074
 
2818 3075
 		if($GLOBALS['egw_info']['user']['apps']['mail'])
2819 3076
 		{
@@ -2865,7 +3122,10 @@  discard block
 block discarded – undo
2865 3122
 				$query['advanced_search'] = array_intersect_key($_content,array_flip(array_merge($this->get_contact_columns(),array('operator','meth_select'))));
2866 3123
 				foreach ($query['advanced_search'] as $key => $value)
2867 3124
 				{
2868
-					if(!$value) unset($query['advanced_search'][$key]);
3125
+					if(!$value)
3126
+					{
3127
+						unset($query['advanced_search'][$key]);
3128
+					}
2869 3129
 				}
2870 3130
 				// Skip n_fn, it causes problems in sql
2871 3131
 				unset($query['advanced_search']['n_fn']);
@@ -2921,8 +3181,14 @@  discard block
 block discarded – undo
2921 3181
 			{
2922 3182
 				if (substr($data['type'], 0, 6) == 'select' && !($data['rows'] > 1))
2923 3183
 				{
2924
-					if (!isset($content['#'.$name])) $content['#'.$name] = '';
2925
-					if(!isset($data['values'][''])) $sel_options['#'.$name][''] = lang('Select one');
3184
+					if (!isset($content['#'.$name]))
3185
+					{
3186
+						$content['#'.$name] = '';
3187
+					}
3188
+					if(!isset($data['values']['']))
3189
+					{
3190
+						$sel_options['#'.$name][''] = lang('Select one');
3191
+					}
2926 3192
 				}
2927 3193
 			}
2928 3194
 		}
@@ -2944,7 +3210,10 @@  discard block
 block discarded – undo
2944 3210
 		$content['no_tid'] = true;
2945 3211
 		$content['showsearchbuttons'] = true; // enable search operation and search buttons| they're disabled by default
2946 3212
 
2947
-		if ($this->config['private_cf_tab']) $content['no_private_cfs'] = 0;
3213
+		if ($this->config['private_cf_tab'])
3214
+		{
3215
+			$content['no_private_cfs'] = 0;
3216
+		}
2948 3217
 
2949 3218
 		$this->tmpl->read('addressbook.edit');
2950 3219
 		$this->tmpl->set_cell_attribute('change_org','disabled',true);
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2594,7 +2594,7 @@
 block discarded – undo
2594 2594
 							case 'infolog':
2595 2595
 							case 'tracker':
2596 2596
 							default:
2597
-								Api\Json\Response::get()->apply('app.addressbook.view_set_list',Array(Array('action'=>'addressbook', 'action_id' => $contact_id)));
2597
+								Api\Json\Response::get()->apply('app.addressbook.view_set_list',array(array('action'=>'addressbook', 'action_id' => $contact_id)));
2598 2598
 								break;
2599 2599
 						}
2600 2600
 
Please login to merge, or discard this patch.
admin/admin-cli.php 3 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -532,7 +532,6 @@
 block discarded – undo
532 532
 /**
533 533
  * Read the IMAP ACLs
534 534
  *
535
- * @param array $args admin-account[@domain],admin-password,accout_lid[,pw]
536 535
  * @return int 0 on success
537 536
  */
538 537
 function do_subscribe_other($account_lid,$pw=null)
Please login to merge, or discard this patch.
Spacing   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 use EGroupware\Api\Framework;
16 16
 use EGroupware\Api\Vfs;
17 17
 
18
-chdir(dirname(__FILE__));	// to enable our relative pathes to work
18
+chdir(dirname(__FILE__)); // to enable our relative pathes to work
19 19
 
20 20
 if (php_sapi_name() !== 'cli')	// security precaution: forbit calling admin-cli as web-page
21 21
 {
@@ -33,33 +33,33 @@  discard block
 block discarded – undo
33 33
 }
34 34
 
35 35
 // allow to specify instance by using a username with appended @domain-name
36
-$arg0s = explode(',',@array_shift($arguments));
37
-@list($user,$domain) = explode('@',$arg0s[0]);
38
-load_egw($user,$arg0s[1],$domain);
36
+$arg0s = explode(',', @array_shift($arguments));
37
+@list($user, $domain) = explode('@', $arg0s[0]);
38
+load_egw($user, $arg0s[1], $domain);
39 39
 
40
-switch($action)
40
+switch ($action)
41 41
 {
42 42
 	case '--edit-user':
43 43
 		return do_edit_user($arg0s);
44 44
 
45 45
 	case '--add-user':	// like --edit-account, but always runs addaccount hook
46
-		return do_edit_user($arg0s,true);
46
+		return do_edit_user($arg0s, true);
47 47
 
48 48
 	case '--change-pw':
49 49
 		return do_change_pw($arg0s);
50 50
 
51 51
 	case '--delete-user':
52
-		return do_delete_account($arg0s[2],$arg0s[3]);
52
+		return do_delete_account($arg0s[2], $arg0s[3]);
53 53
 
54 54
 	case '--edit-group':
55 55
 		return do_edit_group($arg0s);
56 56
 
57 57
 	case '--delete-group':
58
-		return do_delete_account($arg0s[2],0,false);
58
+		return do_delete_account($arg0s[2], 0, false);
59 59
 
60 60
 	case '--allow-app':
61 61
 	case '--deny-app':
62
-		return do_account_app($arg0s,$action == '--allow-app');
62
+		return do_account_app($arg0s, $action == '--allow-app');
63 63
 
64 64
 	case '--change-account-id':
65 65
 		return do_change_account_id($arg0s);
@@ -79,21 +79,21 @@  discard block
 block discarded – undo
79 79
 
80 80
 	default:
81 81
 		// we allow to call admin_cmd classes directly, if they define the constant SETUP_CLI_CALLABLE
82
-		if (substr($action,0,2) == '--' && class_exists($class = str_replace('-','_',substr($action,2))) &&
83
-			is_subclass_of($class,'admin_cmd') && @constant($class.'::SETUP_CLI_CALLABLE'))
82
+		if (substr($action, 0, 2) == '--' && class_exists($class = str_replace('-', '_', substr($action, 2))) &&
83
+			is_subclass_of($class, 'admin_cmd') && @constant($class.'::SETUP_CLI_CALLABLE'))
84 84
 		{
85 85
 			$args = array();
86
-			$args['domain'] = array_shift($arg0s);	// domain must be first argument, to ensure right domain get's selected in header-include
87
-			foreach($arg0s as $arg)
86
+			$args['domain'] = array_shift($arg0s); // domain must be first argument, to ensure right domain get's selected in header-include
87
+			foreach ($arg0s as $arg)
88 88
 			{
89
-				list($name,$value) = explode('=',$arg,2);
90
-				if(property_exists('admin_cmd',$name))		// dont allow to overwrite admin_cmd properties
89
+				list($name, $value) = explode('=', $arg, 2);
90
+				if (property_exists('admin_cmd', $name))		// dont allow to overwrite admin_cmd properties
91 91
 				{
92
-					throw new Api\Exception\WrongUserinput(lang("Invalid argument '%1' !!!",$arg),90);
92
+					throw new Api\Exception\WrongUserinput(lang("Invalid argument '%1' !!!", $arg), 90);
93 93
 				}
94
-				if (substr($name,-1) == ']')	// allow 1-dim. arrays
94
+				if (substr($name, -1) == ']')	// allow 1-dim. arrays
95 95
 				{
96
-					list($name,$sub) = explode('[',substr($name,0,-1),2);
96
+					list($name, $sub) = explode('[', substr($name, 0, -1), 2);
97 97
 					$args[$name][$sub] = $value;
98 98
 				}
99 99
 				else
@@ -117,12 +117,12 @@  discard block
 block discarded – undo
117 117
  */
118 118
 function run_command(admin_cmd $cmd)
119 119
 {
120
-	global $arguments,$user,$arg0s,$domain;
120
+	global $arguments, $user, $arg0s, $domain;
121 121
 
122 122
 	$skip_checks = false;
123 123
 	while ($arguments && ($extra = array_shift($arguments)))
124 124
 	{
125
-		switch($extra)
125
+		switch ($extra)
126 126
 		{
127 127
 			case '--schedule':	// schedule the command instead of running it directly
128 128
 				$time = admin_cmd::parse_date(array_shift($arguments));
@@ -152,15 +152,15 @@  discard block
 block discarded – undo
152 152
 			case '--header-access':
153 153
 				if ($cmd instanceof setup_cmd)
154 154
 				{
155
-					list($user,$pw) = explode(',',array_shift($arguments),2);
156
-					$cmd->set_header_secret($user,$pw);
155
+					list($user, $pw) = explode(',', array_shift($arguments), 2);
156
+					$cmd->set_header_secret($user, $pw);
157 157
 				}
158 158
 				break;
159 159
 
160 160
 			default:
161 161
 				//fail(99,lang('Unknown option %1',$extra);
162
-				echo lang('Unknown option %1',$extra)."\n\n";
163
-				usage('',99);
162
+				echo lang('Unknown option %1', $extra)."\n\n";
163
+				usage('', 99);
164 164
 				break;
165 165
 		}
166 166
 	}
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 		{
180 180
 			$url = $GLOBALS['egw_info']['server']['webserver_url'].'/json.php?menuaction=admin.admin_hooks.ajax_clear_cache';
181 181
 			if ($url[0] == '/') $url = 'http://'.(!empty($domain) && $domain != 'default' ? $domain : 'localhost').$url;
182
-			$data = file_get_contents($url, false, Framework::proxy_context($user,$arg0s[1]));
182
+			$data = file_get_contents($url, false, Framework::proxy_context($user, $arg0s[1]));
183 183
 			error_log("file_get_contents('$url') returned ".array2string($data));
184 184
 			if ($data && strpos($data, '"success"') !== false)
185 185
 			{
@@ -218,13 +218,13 @@  discard block
 block discarded – undo
218 218
 	{
219 219
 		//fail(1,lang("Wrong admin-account or -password !!!"));
220 220
 		echo lang("Wrong admin-account or -password !!!")."\n\n";
221
-		usage('',1);
221
+		usage('', 1);
222 222
 	}
223 223
 	if (!$GLOBALS['egw_info']['user']['apps']['admin'])	// will be tested by the header too, but whould give html error-message
224 224
 	{
225 225
 		//fail(2,lang("Permission denied !!!"));
226 226
 		echo lang("Permission denied !!!")."\n\n";
227
-		usage('',2);
227
+		usage('', 2);
228 228
 	}
229 229
 	return $sessionid;
230 230
 }
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
  * @param string $passwd
237 237
  * @param string $domain
238 238
  */
239
-function load_egw($user,$passwd,$domain='default')
239
+function load_egw($user, $passwd, $domain = 'default')
240 240
 {
241 241
 	//echo "load_egw($user,$passwd,$domain)\n";
242 242
 	$_REQUEST['domain'] = $domain;
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 
249 249
 	if (ini_get('session.save_handler') == 'files' && !is_writable(ini_get('session.save_path')) && is_dir('/tmp') && is_writable('/tmp'))
250 250
 	{
251
-		ini_set('session.save_path','/tmp');	// regular users may have no rights to apache's session dir
251
+		ini_set('session.save_path', '/tmp'); // regular users may have no rights to apache's session dir
252 252
 	}
253 253
 
254 254
 	$GLOBALS['egw_info'] = array(
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
 		)
261 261
 	);
262 262
 
263
-	if (substr($user,0,5) != 'root_')
263
+	if (substr($user, 0, 5) != 'root_')
264 264
 	{
265 265
 		include('../header.inc.php');
266 266
 	}
@@ -270,9 +270,9 @@  discard block
 block discarded – undo
270 270
 		include('../header.inc.php');
271 271
 
272 272
 		if ($user == 'root_'.$GLOBALS['egw_info']['server']['header_admin_user'] &&
273
-			_check_pw($GLOBALS['egw_info']['server']['header_admin_password'],$passwd) ||
273
+			_check_pw($GLOBALS['egw_info']['server']['header_admin_password'], $passwd) ||
274 274
 			$user == 'root_'.$GLOBALS['egw_domain'][$_GET['domain']]['config_user'] &&
275
-			_check_pw($GLOBALS['egw_domain'][$_GET['domain']]['config_passwd'],$passwd))
275
+			_check_pw($GLOBALS['egw_domain'][$_GET['domain']]['config_passwd'], $passwd))
276 276
 		{
277 277
 			echo "\nRoot access granted!\n";
278 278
 			Vfs::$is_root = true;
@@ -291,10 +291,10 @@  discard block
 block discarded – undo
291 291
  * @param string $pw
292 292
  * @return boolean
293 293
  */
294
-function _check_pw($hash_or_cleartext,$pw)
294
+function _check_pw($hash_or_cleartext, $pw)
295 295
 {
296 296
 	//echo "_check_pw($hash_or_cleartext,$pw) md5=".md5($pw)."\n";
297
-	if (preg_match('/^[0-9a-f]{32}$/',$hash_or_cleartext))
297
+	if (preg_match('/^[0-9a-f]{32}$/', $hash_or_cleartext))
298 298
 	{
299 299
 		return $hash_or_cleartext == md5($pw);
300 300
 	}
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
  * @param string $action =null
308 308
  * @param int $ret =0 exit-code
309 309
  */
310
-function usage($action=null,$ret=0)
310
+function usage($action = null, $ret = 0)
311 311
 {
312 312
 	unset($action);
313 313
 	$cmd = basename($_SERVER['argv'][0]);
@@ -350,14 +350,14 @@  discard block
 block discarded – undo
350 350
  * @param boolean $allow true=allow, false=deny
351 351
  * @return int 0 on success
352 352
  */
353
-function do_account_app($args,$allow)
353
+function do_account_app($args, $allow)
354 354
 {
355
-	array_shift($args);	// admin-account
356
-	array_shift($args);	// admin-pw
355
+	array_shift($args); // admin-account
356
+	array_shift($args); // admin-pw
357 357
 	$account = array_shift($args);
358 358
 
359 359
 	include_once(EGW_INCLUDE_ROOT.'/admin/inc/class.admin_cmd_account_app.inc.php');
360
-	run_command(new admin_cmd_account_app($allow,$account,$args));
360
+	run_command(new admin_cmd_account_app($allow, $account, $args));
361 361
 }
362 362
 
363 363
 /**
@@ -367,9 +367,9 @@  discard block
 block discarded – undo
367 367
  */
368 368
 function do_edit_group($args)
369 369
 {
370
-	array_shift($args);	// admin-account
371
-	array_shift($args);	// admin-pw
372
-	list($account,$new_account_name) = explode('=',array_shift($args));	// account[=new-account-name]
370
+	array_shift($args); // admin-account
371
+	array_shift($args); // admin-pw
372
+	list($account, $new_account_name) = explode('=', array_shift($args)); // account[=new-account-name]
373 373
 
374 374
 	$data = array(
375 375
 		'account_lid' => $new_account_name,
@@ -377,19 +377,19 @@  discard block
 block discarded – undo
377 377
 		'account_members' => $args,
378 378
 	);
379 379
 	try {
380
-		admin_cmd::parse_account($account,false);
380
+		admin_cmd::parse_account($account, false);
381 381
 
382
-		foreach($data as &$value)	// existing account --> empty values mean dont change, not set them empty!
382
+		foreach ($data as &$value)	// existing account --> empty values mean dont change, not set them empty!
383 383
 		{
384 384
 			if ((string)$value === '') $value = null;
385 385
 		}
386 386
 	}
387 387
 	catch (Exception $e) {	// new group
388
-		unset($e);	// not used
388
+		unset($e); // not used
389 389
 		$data['account_lid'] = $account;
390 390
 		$account = false;
391 391
 	}
392
-	run_command(new admin_cmd_edit_group($account,$data));
392
+	run_command(new admin_cmd_edit_group($account, $data));
393 393
 }
394 394
 
395 395
 /**
@@ -399,12 +399,12 @@  discard block
 block discarded – undo
399 399
  */
400 400
 function do_change_pw($args)
401 401
 {
402
-	array_shift($args);     // admin-account
403
-	array_shift($args);     // admin-pw
404
-	$account = array_shift($args);	// account
405
-	$password = array_shift($args);	// pw
402
+	array_shift($args); // admin-account
403
+	array_shift($args); // admin-pw
404
+	$account = array_shift($args); // account
405
+	$password = array_shift($args); // pw
406 406
 
407
-	run_command(new admin_cmd_change_pw($account,$password));
407
+	run_command(new admin_cmd_change_pw($account, $password));
408 408
 }
409 409
 
410 410
 /**
@@ -413,18 +413,18 @@  discard block
 block discarded – undo
413 413
  * @param array $args admin-account[@domain],admin-password,account[=new-account-name],first-name,last-name,password,email,expires{never(default)|YYYY-MM-DD|already},can-change-pw{true(default)|false},anon-user{true|false(default)},primary-group{Default(default)|...}[,groups,...][,homedirectory,loginshell]
414 414
  * @param boolean $run_addaccount_hook =null default run hook depending on account existence, true=allways run addaccount hook
415 415
  */
416
-function do_edit_user($args,$run_addaccount_hook=null)
416
+function do_edit_user($args, $run_addaccount_hook = null)
417 417
 {
418
-	array_shift($args);	// admin-account
419
-	array_shift($args);	// admin-pw
420
-	list($account,$new_account_name) = explode('=',array_shift($args));	// account[=new-account-name]
418
+	array_shift($args); // admin-account
419
+	array_shift($args); // admin-pw
420
+	list($account, $new_account_name) = explode('=', array_shift($args)); // account[=new-account-name]
421 421
 
422 422
 	$data = array();
423 423
 	// do we need to support ldap only attributes: homedirectory and loginshell
424 424
 	if (($GLOBALS['egw_info']['server']['account_repository'] == 'ldap' ||
425 425
 		 empty($GLOBALS['egw_info']['server']['account_repository']) && $GLOBALS['egw_info']['server']['auth_type'] == 'ldap') &&
426
-		$GLOBALS['egw_info']['server']['ldap_extra_attributes'] && count($args) > 9 &&	// 9 = primary group
427
-		($last_arg = array_pop($dummy=$args)) && $last_arg[0] == '/')	// last argument start with a slash
426
+		$GLOBALS['egw_info']['server']['ldap_extra_attributes'] && count($args) > 9 && // 9 = primary group
427
+		($last_arg = array_pop($dummy = $args)) && $last_arg[0] == '/')	// last argument start with a slash
428 428
 	{
429 429
 		$data['loginshell'] = array_pop($args);
430 430
 		$data['homedirectory'] = array_pop($args);
@@ -442,19 +442,19 @@  discard block
 block discarded – undo
442 442
 		'account_groups' => $args,
443 443
 	);
444 444
 	try {
445
-		admin_cmd::parse_account($account,true);
445
+		admin_cmd::parse_account($account, true);
446 446
 
447
-		foreach($data as &$value)	// existing account --> empty values mean dont change, not set them empty!
447
+		foreach ($data as &$value)	// existing account --> empty values mean dont change, not set them empty!
448 448
 		{
449 449
 			if ((string)$value === '') $value = null;
450 450
 		}
451 451
 	}
452 452
 	catch (Exception $e) {	// new account
453
-		unset($e);	// not used
453
+		unset($e); // not used
454 454
 		$data['account_lid'] = $account;
455 455
 		$account = false;
456 456
 	}
457
-	run_command(new admin_cmd_edit_user($account,$data,null,$run_addaccount_hook));
457
+	run_command(new admin_cmd_edit_user($account, $data, null, $run_addaccount_hook));
458 458
 }
459 459
 
460 460
 /**
@@ -465,9 +465,9 @@  discard block
 block discarded – undo
465 465
  * @param boolean $is_user =true are we called for a user or group
466 466
  * @return int 0 on success, 2-4 otherwise (see source)
467 467
  */
468
-function do_delete_account($account,$new_user=0,$is_user=true)
468
+function do_delete_account($account, $new_user = 0, $is_user = true)
469 469
 {
470
-	run_command(new admin_cmd_delete_account($account,$new_user,$is_user));
470
+	run_command(new admin_cmd_delete_account($account, $new_user, $is_user));
471 471
 }
472 472
 
473 473
 /**
@@ -488,13 +488,13 @@  discard block
 block discarded – undo
488 488
  */
489 489
 function do_change_account_id($args)
490 490
 {
491
-	if (count($args) < 4) usage();	// 4 means at least user,pw,from1,to1
491
+	if (count($args) < 4) usage(); // 4 means at least user,pw,from1,to1
492 492
 
493 493
 	$ids2change = array();
494
-	for($n = 2; $n < count($args); $n += 2)
494
+	for ($n = 2; $n < count($args); $n += 2)
495 495
 	{
496 496
 		$from = (int)$args[$n];
497
-		$to   = (int)$args[$n+1];
497
+		$to   = (int)$args[$n + 1];
498 498
 		$ids2change[$from] = $to;
499 499
 	}
500 500
 	run_command(new admin_cmd_change_account_id($ids2change));
@@ -510,22 +510,22 @@  discard block
 block discarded – undo
510 510
  */
511 511
 function list_exit_codes()
512 512
 {
513
-	error_reporting(error_reporting() & ~E_NOTICE);
513
+	error_reporting(error_reporting()&~E_NOTICE);
514 514
 
515 515
 	$codes = array('Ok');
516
-	foreach(file(__FILE__) as $line)
516
+	foreach (file(__FILE__) as $line)
517 517
 	{
518 518
 		$matches = null;
519
-		if (preg_match('/fail\(([0-9]+),(.*)\);/',$line,$matches))
519
+		if (preg_match('/fail\(([0-9]+),(.*)\);/', $line, $matches))
520 520
 		{
521 521
 			//echo "Line $n: $matches[1]: $matches[2]\n";
522 522
 			@eval('$codes['.$matches[1].'] = '.$matches[2].';');
523 523
 		}
524 524
 	}
525
-	ksort($codes,SORT_NUMERIC);
526
-	foreach($codes as $num => $msg)
525
+	ksort($codes, SORT_NUMERIC);
526
+	foreach ($codes as $num => $msg)
527 527
 	{
528
-		echo $num."\t".str_replace("\n","\n\t",$msg)."\n";
528
+		echo $num."\t".str_replace("\n", "\n\t", $msg)."\n";
529 529
 	}
530 530
 }
531 531
 
@@ -535,7 +535,7 @@  discard block
 block discarded – undo
535 535
  * @param array $args admin-account[@domain],admin-password,accout_lid[,pw]
536 536
  * @return int 0 on success
537 537
  */
538
-function do_subscribe_other($account_lid,$pw=null)
538
+function do_subscribe_other($account_lid, $pw = null)
539 539
 {
540 540
 	unset($account_lid, $pw);
541 541
 	/* ToDo: this cant work, not even in 14.x
Please login to merge, or discard this patch.
Braces   +37 added lines, -9 removed lines patch added patch discarded remove patch
@@ -17,10 +17,13 @@  discard block
 block discarded – undo
17 17
 
18 18
 chdir(dirname(__FILE__));	// to enable our relative pathes to work
19 19
 
20
-if (php_sapi_name() !== 'cli')	// security precaution: forbit calling admin-cli as web-page
20
+if (php_sapi_name() !== 'cli')
21
+{
22
+	// security precaution: forbit calling admin-cli as web-page
21 23
 {
22 24
 	die('<h1>admin-cli.php must NOT be called as web-page --> exiting !!!</h1>');
23 25
 }
26
+}
24 27
 elseif ($_SERVER['argc'] > 1)
25 28
 {
26 29
 	$arguments = $_SERVER['argv'];
@@ -87,13 +90,19 @@  discard block
 block discarded – undo
87 90
 			foreach($arg0s as $arg)
88 91
 			{
89 92
 				list($name,$value) = explode('=',$arg,2);
90
-				if(property_exists('admin_cmd',$name))		// dont allow to overwrite admin_cmd properties
93
+				if(property_exists('admin_cmd',$name))
94
+				{
95
+					// dont allow to overwrite admin_cmd properties
91 96
 				{
92 97
 					throw new Api\Exception\WrongUserinput(lang("Invalid argument '%1' !!!",$arg),90);
93 98
 				}
94
-				if (substr($name,-1) == ']')	// allow 1-dim. arrays
99
+				}
100
+				if (substr($name,-1) == ']')
101
+				{
102
+					// allow 1-dim. arrays
95 103
 				{
96 104
 					list($name,$sub) = explode('[',substr($name,0,-1),2);
105
+				}
97 106
 					$args[$name][$sub] = $value;
98 107
 				}
99 108
 				else
@@ -178,7 +187,10 @@  discard block
 block discarded – undo
178 187
 		if (!$dry_run)
179 188
 		{
180 189
 			$url = $GLOBALS['egw_info']['server']['webserver_url'].'/json.php?menuaction=admin.admin_hooks.ajax_clear_cache';
181
-			if ($url[0] == '/') $url = 'http://'.(!empty($domain) && $domain != 'default' ? $domain : 'localhost').$url;
190
+			if ($url[0] == '/')
191
+			{
192
+				$url = 'http://'.(!empty($domain) && $domain != 'default' ? $domain : 'localhost').$url;
193
+			}
182 194
 			$data = file_get_contents($url, false, Framework::proxy_context($user,$arg0s[1]));
183 195
 			error_log("file_get_contents('$url') returned ".array2string($data));
184 196
 			if ($data && strpos($data, '"success"') !== false)
@@ -220,10 +232,13 @@  discard block
 block discarded – undo
220 232
 		echo lang("Wrong admin-account or -password !!!")."\n\n";
221 233
 		usage('',1);
222 234
 	}
223
-	if (!$GLOBALS['egw_info']['user']['apps']['admin'])	// will be tested by the header too, but whould give html error-message
235
+	if (!$GLOBALS['egw_info']['user']['apps']['admin'])
236
+	{
237
+		// will be tested by the header too, but whould give html error-message
224 238
 	{
225 239
 		//fail(2,lang("Permission denied !!!"));
226 240
 		echo lang("Permission denied !!!")."\n\n";
241
+	}
227 242
 		usage('',2);
228 243
 	}
229 244
 	return $sessionid;
@@ -379,10 +394,13 @@  discard block
 block discarded – undo
379 394
 	try {
380 395
 		admin_cmd::parse_account($account,false);
381 396
 
382
-		foreach($data as &$value)	// existing account --> empty values mean dont change, not set them empty!
397
+		foreach($data as &$value)
398
+		{
399
+			// existing account --> empty values mean dont change, not set them empty!
383 400
 		{
384 401
 			if ((string)$value === '') $value = null;
385 402
 		}
403
+		}
386 404
 	}
387 405
 	catch (Exception $e) {	// new group
388 406
 		unset($e);	// not used
@@ -424,9 +442,12 @@  discard block
 block discarded – undo
424 442
 	if (($GLOBALS['egw_info']['server']['account_repository'] == 'ldap' ||
425 443
 		 empty($GLOBALS['egw_info']['server']['account_repository']) && $GLOBALS['egw_info']['server']['auth_type'] == 'ldap') &&
426 444
 		$GLOBALS['egw_info']['server']['ldap_extra_attributes'] && count($args) > 9 &&	// 9 = primary group
427
-		($last_arg = array_pop($dummy=$args)) && $last_arg[0] == '/')	// last argument start with a slash
445
+		($last_arg = array_pop($dummy=$args)) && $last_arg[0] == '/')
446
+	{
447
+		// last argument start with a slash
428 448
 	{
429 449
 		$data['loginshell'] = array_pop($args);
450
+	}
430 451
 		$data['homedirectory'] = array_pop($args);
431 452
 	}
432 453
 	$data += array(
@@ -444,10 +465,13 @@  discard block
 block discarded – undo
444 465
 	try {
445 466
 		admin_cmd::parse_account($account,true);
446 467
 
447
-		foreach($data as &$value)	// existing account --> empty values mean dont change, not set them empty!
468
+		foreach($data as &$value)
469
+		{
470
+			// existing account --> empty values mean dont change, not set them empty!
448 471
 		{
449 472
 			if ((string)$value === '') $value = null;
450 473
 		}
474
+		}
451 475
 	}
452 476
 	catch (Exception $e) {	// new account
453 477
 		unset($e);	// not used
@@ -488,7 +512,11 @@  discard block
 block discarded – undo
488 512
  */
489 513
 function do_change_account_id($args)
490 514
 {
491
-	if (count($args) < 4) usage();	// 4 means at least user,pw,from1,to1
515
+	if (count($args) < 4)
516
+	{
517
+		usage();
518
+	}
519
+	// 4 means at least user,pw,from1,to1
492 520
 
493 521
 	$ids2change = array();
494 522
 	for($n = 2; $n < count($args); $n += 2)
Please login to merge, or discard this patch.
admin/inc/class.admin_accesslog.inc.php 3 patches
Doc Comments   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -255,11 +255,10 @@
 block discarded – undo
255 255
 	 *
256 256
 	 * @param type $action
257 257
 	 * @param type $checked
258
-	 * @param type $use_all
259 258
 	 * @param type $success
260 259
 	 * @param int $failed
261 260
 	 * @param type $action_msg
262
-	 * @return type number of failed
261
+	 * @return boolean number of failed
263 262
 	 */
264 263
 	function action($action,$checked,&$success,&$failed,&$action_msg)
265 264
 	{
Please login to merge, or discard this patch.
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	 */
51 51
 	function __construct()
52 52
 	{
53
-		$this->so = new Api\Storage\Base(self::APP,self::TABLE,null,'',true);
53
+		$this->so = new Api\Storage\Base(self::APP, self::TABLE, null, '', true);
54 54
 		$this->so->timestamps = array('li', 'lo', 'session_dla', 'notification_heartbeat');
55 55
 	}
56 56
 
@@ -63,19 +63,19 @@  discard block
 block discarded – undo
63 63
 	 * @param array &$readonlys eg. to disable buttons based on acl, not use here, maybe in a derived class
64 64
 	 * @return int total number of rows
65 65
 	 */
66
-	function get_rows($query,&$rows,&$readonlys)
66
+	function get_rows($query, &$rows, &$readonlys)
67 67
 	{
68 68
 		$heartbeat_limit = Api\Session::heartbeat_limit();
69 69
 
70 70
 		if ($query['session_list'])	// filter active sessions
71 71
 		{
72
-			$query['col_filter']['lo'] = null;	// not logged out
72
+			$query['col_filter']['lo'] = null; // not logged out
73 73
 			$query['col_filter'][0] = 'session_dla > '.(int)(time() - $GLOBALS['egw_info']['server']['sessions_timeout']);
74
-			switch((string)$query['session_list'])
74
+			switch ((string)$query['session_list'])
75 75
 			{
76 76
 				case 'active':	// remove status != 'active', eg. CalDAV/eSync
77 77
 					$query['col_filter'][1] = "notification_heartbeat > $heartbeat_limit";
78
-					$query['col_filter'][3] = "session_php NOT LIKE '% %'";	// remove blocked, bad login, etc
78
+					$query['col_filter'][3] = "session_php NOT LIKE '% %'"; // remove blocked, bad login, etc
79 79
 					break;
80 80
 				default:
81 81
 					$query['col_filter'][1] = "(notification_heartbeat IS NULL OR notification_heartbeat > $heartbeat_limit)";
@@ -83,20 +83,20 @@  discard block
 block discarded – undo
83 83
 			}
84 84
 			$query['col_filter'][2] = 'account_id>0';
85 85
 		}
86
-		$total = $this->so->get_rows($query,$rows,$readonlys);
86
+		$total = $this->so->get_rows($query, $rows, $readonlys);
87 87
 
88 88
 		$heartbeat_limit_user = Api\DateTime::server2user($heartbeat_limit, 'ts');
89 89
 
90
-		foreach($rows as &$row)
90
+		foreach ($rows as &$row)
91 91
 		{
92 92
 			$row['sessionstatus'] = 'success';
93 93
 			if ($row['notification_heartbeat'] > $heartbeat_limit_user)
94 94
 			{
95 95
 				$row['sessionstatus'] = 'active';
96 96
 			}
97
-			if (stripos($row['session_php'],'blocked') !== false ||
98
-				stripos($row['session_php'],'bad login') !== false ||
99
-				strpos($row['session_php'],' ') !== false)
97
+			if (stripos($row['session_php'], 'blocked') !== false ||
98
+				stripos($row['session_php'], 'bad login') !== false ||
99
+				strpos($row['session_php'], ' ') !== false)
100 100
 			{
101 101
 				$row['sessionstatus'] = $row['session_php'];
102 102
 			}
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 				$row['sessionstatus'] = 'logged out';
106 106
 			}
107 107
 			// eg. for bad login or password
108
-			if (!$row['account_id']) $row['alt_loginid'] = ($row['loginid']?$row['loginid']:lang('none'));
108
+			if (!$row['account_id']) $row['alt_loginid'] = ($row['loginid'] ? $row['loginid'] : lang('none'));
109 109
 
110 110
 			// do not allow to kill or select own session
111 111
 			if ($GLOBALS['egw']->session->sessionid_access_log == $row['sessionid'] && $query['session_list'])
@@ -113,13 +113,13 @@  discard block
 block discarded – undo
113 113
 				$row['class'] .= ' rowNoDelete ';
114 114
 			}
115 115
 			// do not allow to delete access log off active sessions
116
-			if (!$row['lo'] && $row['session_dla'] > time()-$GLOBALS['egw_info']['server']['sessions_timeout'] &&
116
+			if (!$row['lo'] && $row['session_dla'] > time() - $GLOBALS['egw_info']['server']['sessions_timeout'] &&
117 117
 				in_array($row['sessionstatus'], array('active', 'success')) && !$query['session_list'])
118 118
 			{
119 119
 				$row['class'] .= ' rowNoDelete ';
120 120
 			}
121 121
 			$row['sessionstatus'] = lang($row['sessionstatus']);
122
-			unset($row['session_php']);	// for security reasons, do NOT give real PHP sessionid to UI
122
+			unset($row['session_php']); // for security reasons, do NOT give real PHP sessionid to UI
123 123
 		}
124 124
 		if ($query['session_list'])
125 125
 		{
@@ -139,33 +139,33 @@  discard block
 block discarded – undo
139 139
 	 * @param string $msg =''
140 140
 	 * @param boolean $sessions_list =false
141 141
 	 */
142
-	function index(array $content=null, $msg='', $sessions_list=false)
142
+	function index(array $content = null, $msg = '', $sessions_list = false)
143 143
 	{
144 144
 
145 145
 		if (is_array($content)) $sessions_list = $content['nm']['session_list'];
146 146
 
147 147
 		// check if user has access to requested functionality
148
-		if ($GLOBALS['egw']->acl->check($sessions_list ? 'current_sessions' : 'access_log_acces',1,'admin'))
148
+		if ($GLOBALS['egw']->acl->check($sessions_list ? 'current_sessions' : 'access_log_acces', 1, 'admin'))
149 149
 		{
150 150
 			$GLOBALS['egw']->redirect_link('/index.php');
151 151
 		}
152 152
 
153
-		if(!isset($content))
153
+		if (!isset($content))
154 154
 		{
155 155
 			$content['nm'] = array(
156
-				'get_rows'       =>	'admin.admin_accesslog.get_rows',	// I  method/callback to request the data for the rows eg. 'notes.bo.get_rows'
157
-				'no_filter'      => True,	// I  disable the 1. filter
158
-				'no_filter2'     => True,	// I  disable the 2. filter (params are the same as for filter)
159
-				'no_cat'         => True,	// I  disable the cat-selectbox
160
-				'header_left'    =>	false,	// I  template to show left of the range-value, left-aligned (optional)
161
-				'header_right'   =>	false,	// I  template to show right of the range-value, right-aligned (optional)
162
-				'never_hide'     => True,	// I  never hide the nextmatch-line if less then maxmatch entries
163
-				'lettersearch'   => false,	// I  show a lettersearch
164
-				'start'          =>	0,		// IO position in list
165
-				'order'          =>	'li',	// IO name of the column to sort after (optional for the sortheaders)
166
-				'sort'           =>	'DESC',	// IO direction of the sort: 'ASC' or 'DESC'
156
+				'get_rows'       =>	'admin.admin_accesslog.get_rows', // I  method/callback to request the data for the rows eg. 'notes.bo.get_rows'
157
+				'no_filter'      => True, // I  disable the 1. filter
158
+				'no_filter2'     => True, // I  disable the 2. filter (params are the same as for filter)
159
+				'no_cat'         => True, // I  disable the cat-selectbox
160
+				'header_left'    =>	false, // I  template to show left of the range-value, left-aligned (optional)
161
+				'header_right'   =>	false, // I  template to show right of the range-value, right-aligned (optional)
162
+				'never_hide'     => True, // I  never hide the nextmatch-line if less then maxmatch entries
163
+				'lettersearch'   => false, // I  show a lettersearch
164
+				'start'          =>	0, // IO position in list
165
+				'order'          =>	'li', // IO name of the column to sort after (optional for the sortheaders)
166
+				'sort'           =>	'DESC', // IO direction of the sort: 'ASC' or 'DESC'
167 167
 				//'default_cols'   => 	// I  columns to use if there's no user or default pref (! as first char uses all but the named columns), default all columns
168
-				'csv_fields'     =>	false,	// I  false=disable csv export, true or unset=enable it with auto-detected fieldnames,
168
+				'csv_fields'     =>	false, // I  false=disable csv export, true or unset=enable it with auto-detected fieldnames,
169 169
 								//or array with name=>label or name=>array('label'=>label,'type'=>type) pairs (type is a eT widget-type)
170 170
 				'actions'		=> $this->get_actions($sessions_list),
171 171
 				'placeholder_actions' => false,
@@ -196,12 +196,12 @@  discard block
 block discarded – undo
196 196
 					'col_filter' => $content['nm']['col_filter']
197 197
 				);
198 198
 
199
-				@set_time_limit(0);			// switch off the execution time limit, as it's for big selections to small
200
-				$query['num_rows'] = -1;	// all
199
+				@set_time_limit(0); // switch off the execution time limit, as it's for big selections to small
200
+				$query['num_rows'] = -1; // all
201 201
 				$all = $readonlys = array();
202
-				$this->get_rows($query,$all,$readonlys);
202
+				$this->get_rows($query, $all, $readonlys);
203 203
 				$content['nm']['selected'] = array();
204
-				foreach($all as $session)
204
+				foreach ($all as $session)
205 205
 				{
206 206
 					$content['nm']['selected'][] = $session[$content['nm']['row_id']];
207 207
 				}
@@ -213,19 +213,19 @@  discard block
 block discarded – undo
213 213
 			else
214 214
 			{
215 215
 				$success = $failed = $action = $action_msg = null;
216
-				if ($this->action($content['nm']['action'],$content['nm']['selected']
217
-					,$success,$failed,$action_msg,$msg))
216
+				if ($this->action($content['nm']['action'], $content['nm']['selected']
217
+					,$success, $failed, $action_msg, $msg))
218 218
 				{ // In case of action success
219 219
 					switch ($action_msg)
220 220
 					{
221 221
 						case'deleted':
222
-							$msg = lang('%1 log entries deleted.',$success);
222
+							$msg = lang('%1 log entries deleted.', $success);
223 223
 							break;
224 224
 						case'killed':
225
-							$msg = lang('%1 sessions killed',$success);
225
+							$msg = lang('%1 sessions killed', $success);
226 226
 					}
227 227
 				}
228
-				elseif($failed) // In case of action failiure
228
+				elseif ($failed) // In case of action failiure
229 229
 				{
230 230
 					switch ($action_msg)
231 231
 					{
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 		$content['msg'] = $msg;
243 243
 		$content['percent'] = 100.0 * $GLOBALS['egw']->db->query(
244 244
 			'SELECT ((SELECT COUNT(*) FROM '.self::TABLE.' WHERE lo != 0) / COUNT(*)) FROM '.self::TABLE,
245
-			__LINE__,__FILE__)->fetchColumn();
245
+			__LINE__, __FILE__)->fetchColumn();
246 246
 
247 247
 		$tmpl = new Etemplate('admin.accesslog');
248 248
 		$tmpl->exec('admin.admin_accesslog.index', $content, array(), $readonlys, array(
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 	 * @param type $action_msg
262 262
 	 * @return type number of failed
263 263
 	 */
264
-	function action($action,$checked,&$success,&$failed,&$action_msg)
264
+	function action($action, $checked, &$success, &$failed, &$action_msg)
265 265
 	{
266 266
 		$success = $failed = 0;
267 267
 		//error_log(__METHOD__.'selected:' . array2string($checked). 'action:' . $action);
@@ -269,14 +269,14 @@  discard block
 block discarded – undo
269 269
 		{
270 270
 			case "delete":
271 271
 				$action_msg = "deleted";
272
-				$del_msg= $this->so->delete(array('sessionid' => $checked));
272
+				$del_msg = $this->so->delete(array('sessionid' => $checked));
273 273
 				if ($checked && $del_msg)
274 274
 				{
275 275
 					$success = $del_msg;
276 276
 				}
277 277
 				else
278 278
 				{
279
-					$failed ++;
279
+					$failed++;
280 280
 				}
281 281
 				break;
282 282
 			case "kill":
@@ -284,19 +284,19 @@  discard block
 block discarded – undo
284 284
 				$sessionid = $checked;
285 285
 				if (($key = array_search($GLOBALS['egw']->session->sessionid_access_log, $sessionid)))
286 286
 				{
287
-						unset($sessionid[$key]);	// dont allow to kill own sessions
287
+						unset($sessionid[$key]); // dont allow to kill own sessions
288 288
 				}
289
-				if ($GLOBALS['egw']->acl->check('current_sessions',8,'admin'))
289
+				if ($GLOBALS['egw']->acl->check('current_sessions', 8, 'admin'))
290 290
 				{
291
-					$failed ++;
291
+					$failed++;
292 292
 				}
293 293
 				else
294 294
 				{
295
-					foreach((array)$sessionid as $id)
295
+					foreach ((array)$sessionid as $id)
296 296
 					{
297 297
 						$GLOBALS['egw']->session->destroy($id);
298 298
 					}
299
-					$success= count($sessionid);
299
+					$success = count($sessionid);
300 300
 				}
301 301
 				break;
302 302
 		}
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
 		if ($sessions_list)
317 317
 		{
318 318
 		//	error_log(__METHOD__. $sessions_list);
319
-			$actions= array(
319
+			$actions = array(
320 320
 				'kill' => array(
321 321
 					'caption' => 'Kill',
322 322
 					'confirm' => 'Kill this session',
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
 		}
330 330
 		else
331 331
 		{
332
-			$actions= array(
332
+			$actions = array(
333 333
 				'delete' => array(
334 334
 					'caption' => 'Delete',
335 335
 					'confirm' => 'Delete this entry',
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
 	 * @param array $content =null
362 362
 	 * @param string $msg =''
363 363
 	 */
364
-	function sessions(array $content=null, $msg='')
364
+	function sessions(array $content = null, $msg = '')
365 365
 	{
366 366
 		return $this->index($content, $msg, true);
367 367
 	}
Please login to merge, or discard this patch.
Braces   +22 added lines, -7 removed lines patch added patch discarded remove patch
@@ -67,9 +67,13 @@  discard block
 block discarded – undo
67 67
 	{
68 68
 		$heartbeat_limit = Api\Session::heartbeat_limit();
69 69
 
70
-		if ($query['session_list'])	// filter active sessions
70
+		if ($query['session_list'])
71
+		{
72
+			// filter active sessions
71 73
 		{
72
-			$query['col_filter']['lo'] = null;	// not logged out
74
+			$query['col_filter']['lo'] = null;
75
+		}
76
+		// not logged out
73 77
 			$query['col_filter'][0] = 'session_dla > '.(int)(time() - $GLOBALS['egw_info']['server']['sessions_timeout']);
74 78
 			switch((string)$query['session_list'])
75 79
 			{
@@ -100,12 +104,16 @@  discard block
 block discarded – undo
100 104
 			{
101 105
 				$row['sessionstatus'] = $row['session_php'];
102 106
 			}
103
-			if ($row['lo']) {
107
+			if ($row['lo'])
108
+			{
104 109
 				$row['total'] = ($row['lo'] - $row['li']) / 60;
105 110
 				$row['sessionstatus'] = 'logged out';
106 111
 			}
107 112
 			// eg. for bad login or password
108
-			if (!$row['account_id']) $row['alt_loginid'] = ($row['loginid']?$row['loginid']:lang('none'));
113
+			if (!$row['account_id'])
114
+			{
115
+				$row['alt_loginid'] = ($row['loginid']?$row['loginid']:lang('none'));
116
+			}
109 117
 
110 118
 			// do not allow to kill or select own session
111 119
 			if ($GLOBALS['egw']->session->sessionid_access_log == $row['sessionid'] && $query['session_list'])
@@ -142,7 +150,10 @@  discard block
 block discarded – undo
142 150
 	function index(array $content=null, $msg='', $sessions_list=false)
143 151
 	{
144 152
 
145
-		if (is_array($content)) $sessions_list = $content['nm']['session_list'];
153
+		if (is_array($content))
154
+		{
155
+			$sessions_list = $content['nm']['session_list'];
156
+		}
146 157
 
147 158
 		// check if user has access to requested functionality
148 159
 		if ($GLOBALS['egw']->acl->check($sessions_list ? 'current_sessions' : 'access_log_acces',1,'admin'))
@@ -215,7 +226,8 @@  discard block
 block discarded – undo
215 226
 				$success = $failed = $action = $action_msg = null;
216 227
 				if ($this->action($content['nm']['action'],$content['nm']['selected']
217 228
 					,$success,$failed,$action_msg,$msg))
218
-				{ // In case of action success
229
+				{
230
+// In case of action success
219 231
 					switch ($action_msg)
220 232
 					{
221 233
 						case'deleted':
@@ -225,12 +237,15 @@  discard block
 block discarded – undo
225 237
 							$msg = lang('%1 sessions killed',$success);
226 238
 					}
227 239
 				}
228
-				elseif($failed) // In case of action failiure
240
+				elseif($failed)
241
+				{
242
+					// In case of action failiure
229 243
 				{
230 244
 					switch ($action_msg)
231 245
 					{
232 246
 						case'deleted':
233 247
 							$msg = lang('Error deleting log entry!');
248
+				}
234 249
 							break;
235 250
 						case'killed':
236 251
 							$msg = lang('Permission denied!');
Please login to merge, or discard this patch.
admin/inc/class.admin_categories.inc.php 3 patches
Doc Comments   +2 added lines patch added patch discarded remove patch
@@ -679,6 +679,8 @@
 block discarded – undo
679 679
 	 * @param int &$failed number of failed actions (not enought permissions)
680 680
 	 * @param string &$action_msg translated verb for the actions, to be used in a message like '%1 entries deleted'
681 681
 	 * @param array $query get_rows parameter
682
+	 * @param integer $success
683
+	 * @param integer $failed
682 684
 	 * @return boolean true if all actions succeded, false otherwise
683 685
 	 */
684 686
 	function action($_action, $checked, $use_all, &$success, &$failed, &$action_msg, array $query)
Please login to merge, or discard this patch.
Spacing   +125 added lines, -126 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 		{
64 64
 			throw new Api\Exception\NoPermission\Admin();
65 65
 		}
66
-		if ($GLOBALS['egw']->acl->check('global_categorie',1,'admin'))
66
+		if ($GLOBALS['egw']->acl->check('global_categorie', 1, 'admin'))
67 67
 		{
68 68
 			$GLOBALS['egw']->redirect_link('/index.php');
69 69
 		}
@@ -77,12 +77,12 @@  discard block
 block discarded – undo
77 77
 	{
78 78
 		if (is_null(self::$acl_search))
79 79
 		{
80
-			self::$acl_search = !$GLOBALS['egw']->acl->check('global_categorie',2,'admin');
81
-			self::$acl_add    = !$GLOBALS['egw']->acl->check('global_categorie',4,'admin');
82
-			self::$acl_view   = !$GLOBALS['egw']->acl->check('global_categorie',8,'admin');
83
-			self::$acl_edit   = !$GLOBALS['egw']->acl->check('global_categorie',16,'admin');
84
-			self::$acl_delete = !$GLOBALS['egw']->acl->check('global_categorie',32,'admin');
85
-			self::$acl_add_sub= !$GLOBALS['egw']->acl->check('global_categorie',64,'admin');
80
+			self::$acl_search = !$GLOBALS['egw']->acl->check('global_categorie', 2, 'admin');
81
+			self::$acl_add    = !$GLOBALS['egw']->acl->check('global_categorie', 4, 'admin');
82
+			self::$acl_view   = !$GLOBALS['egw']->acl->check('global_categorie', 8, 'admin');
83
+			self::$acl_edit   = !$GLOBALS['egw']->acl->check('global_categorie', 16, 'admin');
84
+			self::$acl_delete = !$GLOBALS['egw']->acl->check('global_categorie', 32, 'admin');
85
+			self::$acl_add_sub = !$GLOBALS['egw']->acl->check('global_categorie', 64, 'admin');
86 86
 		}
87 87
 	}
88 88
 
@@ -92,11 +92,11 @@  discard block
 block discarded – undo
92 92
 	 * @param array $content = null
93 93
 	 * @param string $msg = ''
94 94
 	 */
95
-	public function edit(array $content=null,$msg='')
95
+	public function edit(array $content = null, $msg = '')
96 96
 	{
97 97
 		// read the session, as the global_cats param is stored with it.
98
-		$appname = $content['appname'] ? $content['appname'] : ($_GET['appname']?$_GET['appname']:categories::GLOBAL_APPNAME);
99
-		$session = Api\Cache::getSession(__CLASS__.$appname,'nm');
98
+		$appname = $content['appname'] ? $content['appname'] : ($_GET['appname'] ? $_GET['appname'] : categories::GLOBAL_APPNAME);
99
+		$session = Api\Cache::getSession(__CLASS__.$appname, 'nm');
100 100
 		unset($session);
101 101
 		if (!isset($content))
102 102
 		{
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 				($content = Categories::read($_GET['cat_id']))))
105 105
 			{
106 106
 				$content = array('data' => array());
107
-				if(isset($_GET['parent']) && $_GET['parent'] > 0)
107
+				if (isset($_GET['parent']) && $_GET['parent'] > 0)
108 108
 				{
109 109
 					// Sub-category - set some defaults from parent
110 110
 					$content['parent'] = (int)$_GET['parent'];
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 					$appname = Categories::GLOBAL_APPNAME;
121 121
 				}
122 122
 			}
123
-			elseif ($content['appname'] != $appname || !self::$acl_edit || ( $content['owner'] != $GLOBALS['egw_info']['user']['account_id'] && $this->appname != 'admin'))
123
+			elseif ($content['appname'] != $appname || !self::$acl_edit || ($content['owner'] != $GLOBALS['egw_info']['user']['account_id'] && $this->appname != 'admin'))
124 124
 			{
125 125
 				// only allow to view category
126 126
 				$readonlys['__ALL__'] = true;
@@ -130,12 +130,12 @@  discard block
 block discarded – undo
130 130
 		}
131 131
 		elseif ($content['button'] || $content['delete'])
132 132
 		{
133
-			$cats = new Categories($content['owner'] ? $content['owner'] : Categories::GLOBAL_ACCOUNT,$content['appname']);
133
+			$cats = new Categories($content['owner'] ? $content['owner'] : Categories::GLOBAL_ACCOUNT, $content['appname']);
134 134
 
135 135
 			if ($content['delete']['delete'] || $content['delete']['subs'])
136 136
 			{
137 137
 				$button = 'delete';
138
-				$delete_subs = $content['delete']['subs']?true:false;
138
+				$delete_subs = $content['delete']['subs'] ? true : false;
139 139
 			}
140 140
 			else
141 141
 			{
@@ -146,23 +146,23 @@  discard block
 block discarded – undo
146 146
 
147 147
 			$refresh_app = $this->appname == 'preferences' ? $content['appname'] : $this->appname;
148 148
 
149
-			switch($button)
149
+			switch ($button)
150 150
 			{
151 151
 				case 'save':
152 152
 				case 'apply':
153
-					if(is_array($content['owner'])) $content['owner'] = implode(',',$content['owner']);
154
-					if($content['owner'] == '') $content['owner'] = 0;
153
+					if (is_array($content['owner'])) $content['owner'] = implode(',', $content['owner']);
154
+					if ($content['owner'] == '') $content['owner'] = 0;
155 155
 					if ($content['id'] && self::$acl_edit)
156 156
 					{
157 157
 
158
-						$data = $cats->id2name($content['id'],'data');
158
+						$data = $cats->id2name($content['id'], 'data');
159 159
 						try {
160 160
 							$cats->edit($content);
161 161
 							$msg = lang('Category saved.');
162 162
 						}
163 163
 						catch (Api\Exception\WrongUserinput $e)
164 164
 						{
165
-							$msg = lang('Unwilling to save category with current settings. Check for inconsistency:').$e->getMessage();	// display conflicts etc.
165
+							$msg = lang('Unwilling to save category with current settings. Check for inconsistency:').$e->getMessage(); // display conflicts etc.
166 166
 						}
167 167
 					}
168 168
 					elseif (!$content['id'] && (
@@ -181,15 +181,15 @@  discard block
 block discarded – undo
181 181
 					// to reload the whole nextmatch instead of just the row
182 182
 					$change_color = ($data['color'] != $content['data']['color']);
183 183
 					// Nicely reload just the category window / iframe
184
-					if($change_color)
184
+					if ($change_color)
185 185
 					{
186
-						if(Api\Json\Response::isJSONResponse())
186
+						if (Api\Json\Response::isJSONResponse())
187 187
 						{
188 188
 							// Update category styles
189
-							Api\Json\Response::get()->apply('opener.egw.includeCSS',array(Categories::css($refresh_app == 'admin' ? Categories::GLOBAL_APPNAME : $refresh_app)));
190
-							if($this->appname != 'admin')
189
+							Api\Json\Response::get()->apply('opener.egw.includeCSS', array(Categories::css($refresh_app == 'admin' ? Categories::GLOBAL_APPNAME : $refresh_app)));
190
+							if ($this->appname != 'admin')
191 191
 							{
192
-								Api\Json\Response::get()->apply('opener.egw.show_preferences',array(
192
+								Api\Json\Response::get()->apply('opener.egw.show_preferences', array(
193 193
 									'cats',
194 194
 									$this->appname == 'admin' ? Categories::GLOBAL_APPNAME : array($refresh_app)
195 195
 								));
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 							{
200 200
 								Categories::css($refresh_app == 'admin' ? Categories::GLOBAL_APPNAME : $refresh_app);
201 201
 								// Need to forcably re-load the iframe to avoid smart etemplate refresh
202
-								Api\Json\Response::get()->apply('opener.app.admin.load',array(
202
+								Api\Json\Response::get()->apply('opener.app.admin.load', array(
203 203
 									Framework::link('/index.php', array(
204 204
 										'menuaction' => $this->list_link,
205 205
 										'appname' => $appname
@@ -229,10 +229,10 @@  discard block
 block discarded – undo
229 229
 				case 'delete':
230 230
 					if (self::$acl_delete)
231 231
 					{
232
-						$cats->delete($content['id'],$delete_subs,!$delete_subs);
232
+						$cats->delete($content['id'], $delete_subs, !$delete_subs);
233 233
 						$msg = lang('Category deleted.');
234 234
 
235
-						Framework::refresh_opener($msg, $refresh_app, $content['id'],'delete', $this->appname);
235
+						Framework::refresh_opener($msg, $refresh_app, $content['id'], 'delete', $this->appname);
236 236
 						Framework::window_close();
237 237
 						return;
238 238
 					}
@@ -247,19 +247,19 @@  discard block
 block discarded – undo
247 247
 			Framework::refresh_opener($msg, $refresh_app, $content['id'], $change_color ? null : 'update', $this->appname);
248 248
 		}
249 249
 		$content['msg'] = $msg;
250
-		if(!$content['appname']) $content['appname'] = $appname;
251
-		if($content['data']['icon'])
250
+		if (!$content['appname']) $content['appname'] = $appname;
251
+		if ($content['data']['icon'])
252 252
 		{
253
-			$content['icon_url'] = $content['base_url'] . $content['data']['icon'];
253
+			$content['icon_url'] = $content['base_url'].$content['data']['icon'];
254 254
 		}
255 255
 
256 256
 		$sel_options['icon'] = self::get_icons();
257 257
 		$sel_options['owner'] = array();
258 258
 
259 259
 		// User's category - add current value to be able to preserve owner
260
-		if(!$content['id'])
260
+		if (!$content['id'])
261 261
 		{
262
-			if($this->appname != 'admin')
262
+			if ($this->appname != 'admin')
263 263
 			{
264 264
 				$content['owner'] = $GLOBALS['egw_info']['user']['account_id'];
265 265
 			}
@@ -269,24 +269,24 @@  discard block
 block discarded – undo
269 269
 			}
270 270
 		}
271 271
 
272
-		if($this->appname != 'admin' && $content['owner'] > 0 )
272
+		if ($this->appname != 'admin' && $content['owner'] > 0)
273 273
 		{
274 274
 			$sel_options['owner'][$content['owner']] = Api\Accounts::username($content['owner']);
275 275
 		}
276 276
 		// Add 'All users', in case owner is readonlys
277
-		if($content['id'] && $content['owner'] == 0)
277
+		if ($content['id'] && $content['owner'] == 0)
278 278
 		{
279 279
 			$sel_options['owner'][0] = lang('All users');
280 280
 		}
281
-		if($this->appname == 'admin' || ($content['id'] && !((int)$content['owner'] > 0)))
281
+		if ($this->appname == 'admin' || ($content['id'] && !((int)$content['owner'] > 0)))
282 282
 		{
283
-			if($content['owner'] > 0)
283
+			if ($content['owner'] > 0)
284 284
 			{
285 285
 				$content['msg'] .= "\n".lang('owner "%1" removed, please select group-owner', Api\Accounts::username($content['owner']));
286 286
 				$content['owner'] = 0;
287 287
 			}
288 288
 			$sel_options['owner'][0] = lang('All users');
289
-			foreach($GLOBALS['egw']->accounts->search(array('type' => 'groups')) as $acc)
289
+			foreach ($GLOBALS['egw']->accounts->search(array('type' => 'groups')) as $acc)
290 290
 			{
291 291
 				if ($acc['account_type'] == 'g')
292 292
 				{
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
 			$content['no_private'] = true;
297 297
 		}
298 298
 
299
-		if($this->appname == 'admin')
299
+		if ($this->appname == 'admin')
300 300
 		{
301 301
 			$content['access'] = 'public';
302 302
 			// Allow admins access to all categories as parent
@@ -307,17 +307,17 @@  discard block
 block discarded – undo
307 307
 			$readonlys['access'] = $content['owner'] != $GLOBALS['egw_info']['user']['account_id'];
308 308
 		}
309 309
 
310
-		Framework::includeJS('.','global_categories','admin');
310
+		Framework::includeJS('.', 'global_categories', 'admin');
311 311
 
312
-		$readonlys['button[delete]'] = !$content['id'] || !self::$acl_delete ||		// cant delete not yet saved category
312
+		$readonlys['button[delete]'] = !$content['id'] || !self::$acl_delete || // cant delete not yet saved category
313 313
 			$appname != $content['appname'] || // Can't edit a category from a different app
314 314
 			 ($this->appname != 'admin' && $content['owner'] != $GLOBALS['egw_info']['user']['account_id']);
315 315
 		// Make sure $content['owner'] is an array otherwise it wont show up values in the multiselectbox
316
-		if (!is_array($content['owner'])) $content['owner'] = explode(',',$content['owner']);
316
+		if (!is_array($content['owner'])) $content['owner'] = explode(',', $content['owner']);
317 317
 		$tmpl = new Etemplate('admin.categories.edit');
318
-		$tmpl->exec($this->edit_link,$content,$sel_options,$readonlys,$content+array(
318
+		$tmpl->exec($this->edit_link, $content, $sel_options, $readonlys, $content + array(
319 319
 			'old_parent' => $content['old_parent'] ? $content['old_parent'] : $content['parent'], 'appname' => $appname
320
-		),2);
320
+		), 2);
321 321
 	}
322 322
 
323 323
 	/**
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
 	 * @param string $icon = '' filename
327 327
 	 * @return string url
328 328
 	 */
329
-	static function icon_url($icon='')
329
+	static function icon_url($icon = '')
330 330
 	{
331 331
 		return $GLOBALS['egw_info']['server']['webserver_url'].self::ICON_PATH.'/'.$icon;
332 332
 	}
@@ -339,12 +339,12 @@  discard block
 block discarded – undo
339 339
 	static function get_icons()
340 340
 	{
341 341
 		$icons = array();
342
-		if (file_exists($image_dir=EGW_SERVER_ROOT.self::ICON_PATH) && ($dir = dir($image_dir)))
342
+		if (file_exists($image_dir = EGW_SERVER_ROOT.self::ICON_PATH) && ($dir = dir($image_dir)))
343 343
 		{
344 344
 			$matches = null;
345
-			while(($file = $dir->read()))
345
+			while (($file = $dir->read()))
346 346
 			{
347
-				if (preg_match('/^(.*)\\.(png|gif|jpe?g)$/i',$file,$matches))
347
+				if (preg_match('/^(.*)\\.(png|gif|jpe?g)$/i', $file, $matches))
348 348
 				{
349 349
 					$icons[$file] = ucfirst($matches[1]);
350 350
 				}
@@ -363,13 +363,13 @@  discard block
 block discarded – undo
363 363
 	 * @param array &$readonlys eg. to disable buttons based on Acl, not use here, maybe in a derived class
364 364
 	 * @return int total number of rows
365 365
 	 */
366
-	public function get_rows(&$query,&$rows,&$readonlys)
366
+	public function get_rows(&$query, &$rows, &$readonlys)
367 367
 	{
368 368
 		self::init_static();
369 369
 
370 370
 		$filter = array();
371 371
 		$globalcat = ($query['filter'] === Categories::GLOBAL_ACCOUNT || !$query['filter']);
372
-		if (isset($query['global_cats']) && $query['global_cats']===false)
372
+		if (isset($query['global_cats']) && $query['global_cats'] === false)
373 373
 		{
374 374
 			$globalcat = false;
375 375
 		}
@@ -377,49 +377,49 @@  discard block
 block discarded – undo
377 377
 		// new column-filter access has highest priority
378 378
 		if (!empty($query['col_filter']['access']))$filter['access'] = $query['col_filter']['access'];
379 379
 
380
-		Api\Cache::setSession(__CLASS__.$query['appname'],'nm',$query);
380
+		Api\Cache::setSession(__CLASS__.$query['appname'], 'nm', $query);
381 381
 
382
-		if($query['filter'] > 0 || $query['col_filter']['owner'])
382
+		if ($query['filter'] > 0 || $query['col_filter']['owner'])
383 383
 		{
384 384
 			$owner = $query['col_filter']['owner'] ? $query['col_filter']['owner'] : $query['filter'];
385 385
 		}
386
-		if($query['col_filter']['app'])
386
+		if ($query['col_filter']['app'])
387 387
 		{
388 388
 			$filter['appname'] = $query['col_filter']['app'];
389 389
 		}
390
-		$GLOBALS['egw']->categories = $cats = new Categories($filter['owner'],$query['appname']);
391
-		$globals = isset($GLOBALS['egw_info']['user']['apps']['admin']) ? 'all_no_acl' : $globalcat;	// ignore Acl only for admins
390
+		$GLOBALS['egw']->categories = $cats = new Categories($filter['owner'], $query['appname']);
391
+		$globals = isset($GLOBALS['egw_info']['user']['apps']['admin']) ? 'all_no_acl' : $globalcat; // ignore Acl only for admins
392 392
 		$parent = $query['search'] ? false : 0;
393
-		$rows = $cats->return_sorted_array($query['start'],false,$query['search'],$query['sort'],$query['order'],$globals,$parent,true,$filter);
393
+		$rows = $cats->return_sorted_array($query['start'], false, $query['search'], $query['sort'], $query['order'], $globals, $parent, true, $filter);
394 394
 		$count = $cats->total_records;
395
-		foreach($rows as $key => &$row)
395
+		foreach ($rows as $key => &$row)
396 396
 		{
397
-			$row['owner'] = explode(',',$row['owner']);
398
-			if(($owner && !in_array($owner, $row['owner'])) || ((string)$query['filter'] === (string)categories::GLOBAL_ACCOUNT && $row['owner'][0] > 0))
397
+			$row['owner'] = explode(',', $row['owner']);
398
+			if (($owner && !in_array($owner, $row['owner'])) || ((string)$query['filter'] === (string)categories::GLOBAL_ACCOUNT && $row['owner'][0] > 0))
399 399
 			{
400 400
 				unset($rows[$key]);
401 401
 				$count--;
402 402
 				continue;
403 403
 			}
404 404
 
405
-			$row['level_spacer'] = str_repeat('&nbsp; &nbsp; ',$row['level']);
405
+			$row['level_spacer'] = str_repeat('&nbsp; &nbsp; ', $row['level']);
406 406
 
407 407
 			if ($row['data']['icon']) $row['icon_url'] = self::icon_url($row['data']['icon']);
408 408
 
409 409
 			$row['subs'] = count($row['children']);
410 410
 
411 411
 			$row['class'] = 'level'.$row['level'];
412
-			if($row['owner'][0] > 0 && !$GLOBALS['egw_info']['user']['apps']['admin'] && $row['owner'][0] != $GLOBALS['egw_info']['user']['account_id'])
412
+			if ($row['owner'][0] > 0 && !$GLOBALS['egw_info']['user']['apps']['admin'] && $row['owner'][0] != $GLOBALS['egw_info']['user']['account_id'])
413 413
 			{
414 414
 				$row['class'] .= ' rowNoEdit rowNoDelete ';
415 415
 			}
416 416
 			else if (!$GLOBALS['egw_info']['user']['apps']['admin'])
417 417
 			{
418
-				if(!$cats->check_perms(Acl::EDIT, $row['id']) || !self::$acl_edit)
418
+				if (!$cats->check_perms(Acl::EDIT, $row['id']) || !self::$acl_edit)
419 419
 				{
420 420
 					$row['class'] .= ' rowNoEdit';
421 421
 				}
422
-				if(!$cats->check_perms(Acl::DELETE, $row['id']) || !self::$acl_delete ||
422
+				if (!$cats->check_perms(Acl::DELETE, $row['id']) || !self::$acl_delete ||
423 423
 					// Only admins can delete globals
424 424
 					$cats->is_global($row['id']) && !$GLOBALS['egw_info']['user']['apps']['admin'])
425 425
 				{
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
 				}
428 428
 			}
429 429
 			// Can only edit (via context menu) Categories for the selected app (backend restriction)
430
-			if($row['appname'] != $query['appname'] || (array_sum($row['owner']) > 0))
430
+			if ($row['appname'] != $query['appname'] || (array_sum($row['owner']) > 0))
431 431
 			{
432 432
 				$row['class'] .= ' rowNoEdit ';
433 433
 			}
@@ -455,60 +455,60 @@  discard block
 block discarded – undo
455 455
 	 * @param array $content = null
456 456
 	 * @param string $msg = ''
457 457
 	 */
458
-	public function index(array $content=null,$msg='')
458
+	public function index(array $content = null, $msg = '')
459 459
 	{
460 460
 		//_debug_array($_GET);
461
-		if ($this->appname != 'admin') Api\Translation::add_app('admin');	// need admin translations
461
+		if ($this->appname != 'admin') Api\Translation::add_app('admin'); // need admin translations
462 462
 
463
-		if(!isset($content))
463
+		if (!isset($content))
464 464
 		{
465 465
 			if (isset($_GET['msg'])) $msg = $_GET['msg'];
466 466
 
467 467
 			$appname = Categories::GLOBAL_APPNAME;
468
-			foreach(array($content['nm']['appname'], $_GET['cats_app'], $_GET['appname']) as $field)
468
+			foreach (array($content['nm']['appname'], $_GET['cats_app'], $_GET['appname']) as $field)
469 469
 			{
470
-				if($field)
470
+				if ($field)
471 471
 				{
472 472
 					$appname = $field;
473 473
 					break;
474 474
 				}
475 475
 			}
476
-			$content['nm'] = Api\Cache::getSession(__CLASS__.$appname,'nm');
476
+			$content['nm'] = Api\Cache::getSession(__CLASS__.$appname, 'nm');
477 477
 			if (!is_array($content['nm']))
478 478
 			{
479 479
 				$content['nm'] = array(
480
-					'get_rows'       =>	$this->get_rows,	// I  method/callback to request the data for the rows eg. 'notes.bo.get_rows'
480
+					'get_rows'       =>	$this->get_rows, // I  method/callback to request the data for the rows eg. 'notes.bo.get_rows'
481 481
 					'options-filter' => array(
482 482
 						'' => lang('All categories'),
483 483
 						Categories::GLOBAL_ACCOUNT => lang('Global categories'),
484 484
 						$GLOBALS['egw_info']['user']['account_id'] => lang('Own categories'),
485 485
 					),
486
-					'no_filter2'     => True,	// I  disable the 2. filter (params are the same as for filter)
487
-					'no_cat'         => True,	// I  disable the cat-selectbox
488
-					'header_left'    =>	false,	// I  template to show left of the range-value, left-aligned (optional)
489
-					'header_right'   =>	false,	// I  template to show right of the range-value, right-aligned (optional)
490
-					'never_hide'     => True,	// I  never hide the nextmatch-line if less then maxmatch entries
491
-					'lettersearch'   => false,	// I  show a lettersearch
492
-					'start'          =>	0,		// IO position in list
493
-					'order'          =>	'name',	// IO name of the column to sort after (optional for the sortheaders)
494
-					'sort'           =>	'ASC',	// IO direction of the sort: 'ASC' or 'DESC'
495
-					'default_cols'   => '!color,last_mod,subs,legacy_actions',	// I  columns to use if there's no user or default pref (! as first char uses all but the named columns), default all columns
496
-					'csv_fields'     =>	false,	// I  false=disable csv export, true or unset=enable it with auto-detected fieldnames,
486
+					'no_filter2'     => True, // I  disable the 2. filter (params are the same as for filter)
487
+					'no_cat'         => True, // I  disable the cat-selectbox
488
+					'header_left'    =>	false, // I  template to show left of the range-value, left-aligned (optional)
489
+					'header_right'   =>	false, // I  template to show right of the range-value, right-aligned (optional)
490
+					'never_hide'     => True, // I  never hide the nextmatch-line if less then maxmatch entries
491
+					'lettersearch'   => false, // I  show a lettersearch
492
+					'start'          =>	0, // IO position in list
493
+					'order'          =>	'name', // IO name of the column to sort after (optional for the sortheaders)
494
+					'sort'           =>	'ASC', // IO direction of the sort: 'ASC' or 'DESC'
495
+					'default_cols'   => '!color,last_mod,subs,legacy_actions', // I  columns to use if there's no user or default pref (! as first char uses all but the named columns), default all columns
496
+					'csv_fields'     =>	false, // I  false=disable csv export, true or unset=enable it with auto-detected fieldnames,
497 497
 									//or array with name=>label or name=>array('label'=>label,'type'=>type) pairs (type is a eT widget-type)
498 498
 					'no_search'      => !self::$acl_search,
499 499
 					'row_id'         => 'id',
500 500
 					'dataStorePrefix' => 'categories' // Avoid conflict with user list when in admin
501 501
 				);
502
-				$content['nm']['filter'] = $this->appname == 'admin'?categories::GLOBAL_ACCOUNT:$GLOBALS['egw_info']['user']['account_id'];
502
+				$content['nm']['filter'] = $this->appname == 'admin' ? categories::GLOBAL_ACCOUNT : $GLOBALS['egw_info']['user']['account_id'];
503 503
 			}
504 504
 			else
505 505
 			{
506
-				$content['nm']['start']=0;
506
+				$content['nm']['start'] = 0;
507 507
 			}
508 508
 			$content['nm']['appname'] = $appname = $_GET['appname'] ? $_GET['appname'] : $appname;
509 509
 			$content['nm']['actions'] = $this->get_actions($appname);
510 510
 			// switch filter off for super-global categories
511
-			if($appname == 'phpgw')
511
+			if ($appname == 'phpgw')
512 512
 			{
513 513
 				$content['nm']['no_filter'] = true;
514 514
 				// Make sure filter is set properly, could be different if user was looking at something else
@@ -516,18 +516,18 @@  discard block
 block discarded – undo
516 516
 			}
517 517
 
518 518
 			$content['nm']['global_cats'] = true;
519
-			if (isset($_GET['global_cats']) && empty($_GET['global_cats'] ))
519
+			if (isset($_GET['global_cats']) && empty($_GET['global_cats']))
520 520
 			{
521 521
 				$content['nm']['global_cats'] = false;
522 522
 			}
523 523
 		}
524
-		elseif($content['nm']['action'])
524
+		elseif ($content['nm']['action'])
525 525
 		{
526 526
 			$appname = $content['nm']['appname'];
527 527
 			// Old buttons
528
-			foreach(array('delete') as $button)
528
+			foreach (array('delete') as $button)
529 529
 			{
530
-				if(isset($content['nm']['rows'][$button]))
530
+				if (isset($content['nm']['rows'][$button]))
531 531
 				{
532 532
 					list($id) = @each($content['nm']['rows'][$button]);
533 533
 					$content['nm']['action'] = $button;
@@ -542,39 +542,39 @@  discard block
 block discarded – undo
542 542
 			else
543 543
 			{
544 544
 				// Action has an additional action - add / delete, etc.  Buttons named <multi-action>_action[action_name]
545
-				if(in_array($content['nm']['action'], array('owner')))
545
+				if (in_array($content['nm']['action'], array('owner')))
546 546
 				{
547 547
 					$action = $content['nm']['action'];
548 548
 					if ($content[$action.'_popup'])
549 549
 					{
550
-						$content = array_merge($content,$content[$action.'_popup']);
550
+						$content = array_merge($content, $content[$action.'_popup']);
551 551
 					}
552
-					$content['nm']['action'] .= '_' . key($content[$action . '_action']);
552
+					$content['nm']['action'] .= '_'.key($content[$action.'_action']);
553 553
 
554
-					if(is_array($content[$action]))
554
+					if (is_array($content[$action]))
555 555
 					{
556
-						$content[$action] = implode(',',$content[$action]);
556
+						$content[$action] = implode(',', $content[$action]);
557 557
 					}
558
-					$content['nm']['action'] .= '_' . $content[$action];
558
+					$content['nm']['action'] .= '_'.$content[$action];
559 559
 				}
560 560
 				$success = $failed = 0;
561 561
 				$action_msg = null;
562
-				if ($this->action($content['nm']['action'],$content['nm']['selected'],$content['nm']['select_all'],
563
-					$success,$failed,$action_msg,$content['nm']))
562
+				if ($this->action($content['nm']['action'], $content['nm']['selected'], $content['nm']['select_all'],
563
+					$success, $failed, $action_msg, $content['nm']))
564 564
 				{
565
-					$msg .= lang('%1 category(s) %2',$success,$action_msg);
565
+					$msg .= lang('%1 category(s) %2', $success, $action_msg);
566 566
 				}
567
-				elseif(empty($msg))
567
+				elseif (empty($msg))
568 568
 				{
569
-					$msg .= lang('%1 category(s) %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed);
569
+					$msg .= lang('%1 category(s) %2, %3 failed because of insufficent rights !!!', $success, $action_msg, $failed);
570 570
 				}
571 571
 				Framework::refresh_opener($msg, $this->appname);
572 572
 				$msg = '';
573 573
 			}
574 574
 		}
575 575
 		$content['msg'] = $msg;
576
-		$content['nm']['add_link']= Framework::link('/index.php','menuaction='.$this->add_link . '&cat_id=&appname='.$appname);
577
-		$content['edit_link']= $this->edit_link.'&appname='.$appname;
576
+		$content['nm']['add_link'] = Framework::link('/index.php', 'menuaction='.$this->add_link.'&cat_id=&appname='.$appname);
577
+		$content['edit_link'] = $this->edit_link.'&appname='.$appname;
578 578
 		$content['owner'] = '';
579 579
 
580 580
 		$sel_options['appname'] = $this->get_app_list();
@@ -588,7 +588,7 @@  discard block
 block discarded – undo
588 588
 		);
589 589
 
590 590
 		$sel_options['owner'][0] = lang('All users');
591
-		foreach($GLOBALS['egw']->accounts->search(array('type' => 'groups')) as $acc)
591
+		foreach ($GLOBALS['egw']->accounts->search(array('type' => 'groups')) as $acc)
592 592
 		{
593 593
 			if ($acc['account_type'] == 'g')
594 594
 			{
@@ -597,12 +597,12 @@  discard block
 block discarded – undo
597 597
 		}
598 598
 
599 599
 		$readonlys['add'] = !self::$acl_add;
600
-		if(!$GLOBALS['egw_info']['user']['apps']['admin'])
600
+		if (!$GLOBALS['egw_info']['user']['apps']['admin'])
601 601
 		{
602 602
 			$readonlys['nm']['rows']['owner'] = true;
603 603
 			$readonlys['nm']['col_filter']['owner'] = true;
604 604
 		}
605
-		if($appname == Categories::GLOBAL_APPNAME) {
605
+		if ($appname == Categories::GLOBAL_APPNAME) {
606 606
 			$sel_options['app'] = array(''=>'');
607 607
 			$readonlys['nm']['rows']['app'] = true;
608 608
 		}
@@ -612,12 +612,12 @@  discard block
 block discarded – undo
612 612
 		// Category styles
613 613
 		Categories::css($appname);
614 614
 
615
-		$tmpl->exec($this->list_link,$content,$sel_options,$readonlys,array(
615
+		$tmpl->exec($this->list_link, $content, $sel_options, $readonlys, array(
616 616
 			'nm' => $content['nm'],
617 617
 		));
618 618
 	}
619 619
 
620
-	protected function get_actions($appname=categories::GLOBAL_APPNAME) {
620
+	protected function get_actions($appname = categories::GLOBAL_APPNAME) {
621 621
 
622 622
 		$actions = array(
623 623
 			'open' => array(        // does edit if allowed, otherwise view
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
 				'allowOnMultiple' => false,
627 627
 				'url' => 'menuaction='.$this->edit_link.'&cat_id=$id&appname='.$appname,
628 628
 				'popup' => '600x380',
629
-				'group' => $group=1,
629
+				'group' => $group = 1,
630 630
 			),
631 631
 			'add' => array(
632 632
 				'caption' => 'Add',
@@ -661,7 +661,7 @@  discard block
 block discarded – undo
661 661
 			),
662 662
 		);
663 663
 
664
-		if(!$GLOBALS['egw_info']['user']['apps']['admin'])
664
+		if (!$GLOBALS['egw_info']['user']['apps']['admin'])
665 665
 		{
666 666
 			unset($actions['owner']);
667 667
 		}
@@ -687,14 +687,14 @@  discard block
 block discarded – undo
687 687
 		$success = $failed = 0;
688 688
 		if ($use_all)
689 689
 		{
690
-			@set_time_limit(0);                     // switch off the execution time limit, as it's for big selections to small
691
-			$query['num_rows'] = -1;        // all
690
+			@set_time_limit(0); // switch off the execution time limit, as it's for big selections to small
691
+			$query['num_rows'] = -1; // all
692 692
 			$result = $readonlys = array();
693
-			$this->get_rows($query,$result,$readonlys);
693
+			$this->get_rows($query, $result, $readonlys);
694 694
 			$checked = array();
695
-			foreach($result as $key => $info)
695
+			foreach ($result as $key => $info)
696 696
 			{
697
-				if(is_numeric($key))
697
+				if (is_numeric($key))
698 698
 				{
699 699
 					$checked[] = $info['id'];
700 700
 				}
@@ -702,19 +702,19 @@  discard block
 block discarded – undo
702 702
 		}
703 703
 		$owner = $query['col_filter']['owner'] ? $query['col_filter']['owner'] : $query['filter'];
704 704
 		$app = $query['col_filter']['app'] ? $query['col_filter']['app'] : $query['appname'];
705
-		$cats = new Categories($owner,$app);
705
+		$cats = new Categories($owner, $app);
706 706
 
707 707
 		list($action, $settings) = explode('_', $_action, 2);
708 708
 
709
-		switch($action)
709
+		switch ($action)
710 710
 		{
711 711
 			case 'delete':
712 712
 				$action_msg = lang('deleted');
713
-				foreach($checked as $id)
713
+				foreach ($checked as $id)
714 714
 				{
715
-					if($cats->check_perms(Acl::DELETE, $id, (boolean)$GLOBALS['egw_info']['user']['apps']['admin']))
715
+					if ($cats->check_perms(Acl::DELETE, $id, (boolean)$GLOBALS['egw_info']['user']['apps']['admin']))
716 716
 					{
717
-						$cats->delete($id,$settings == 'sub',$settings != 'sub');
717
+						$cats->delete($id, $settings == 'sub', $settings != 'sub');
718 718
 						$success++;
719 719
 					}
720 720
 					else
@@ -728,20 +728,19 @@  discard block
 block discarded – undo
728 728
 				list($add_remove, $ids_csv) = explode('_', $settings, 2);
729 729
 				$ids = explode(',', $ids_csv);
730 730
 				// Adding 'All users' removes all the others
731
-				if($add_remove == 'add' && array_search(Categories::GLOBAL_ACCOUNT,$ids) !== false) $ids = array(Categories::GLOBAL_ACCOUNT);
731
+				if ($add_remove == 'add' && array_search(Categories::GLOBAL_ACCOUNT, $ids) !== false) $ids = array(Categories::GLOBAL_ACCOUNT);
732 732
 
733
-				foreach($checked as $id)
733
+				foreach ($checked as $id)
734 734
 				{
735 735
 					if (!$data = $cats->read($id)) continue;
736
-					$data['owner'] = explode(',',$data['owner']);
737
-					if(array_search(Categories::GLOBAL_ACCOUNT,$data['owner']) !== false || $data['owner'][0] > 0)
736
+					$data['owner'] = explode(',', $data['owner']);
737
+					if (array_search(Categories::GLOBAL_ACCOUNT, $data['owner']) !== false || $data['owner'][0] > 0)
738 738
 					{
739 739
 						$data['owner'] = array();
740 740
 					}
741 741
 					$data['owner'] = $add_remove == 'add' ?
742
-						$ids == array(Categories::GLOBAL_ACCOUNT) ? $ids : array_merge($data['owner'],$ids) :
743
-						array_diff($data['owner'],$ids);
744
-					$data['owner'] = implode(',',array_unique($data['owner']));
742
+						$ids == array(Categories::GLOBAL_ACCOUNT) ? $ids : array_merge($data['owner'], $ids) : array_diff($data['owner'], $ids);
743
+					$data['owner'] = implode(',', array_unique($data['owner']));
745 744
 
746 745
 					if ($cats->edit($data))
747 746
 					{
@@ -772,7 +771,7 @@  discard block
 block discarded – undo
772 771
 				continue;
773 772
 			}
774 773
 			// Skip apps that don't show in the app bar, they [usually] don't have Categories
775
-			if($data['status'] > 1 || in_array($app, array('home','admin','felamimail','sitemgr','sitemgr-link'))) continue;
774
+			if ($data['status'] > 1 || in_array($app, array('home', 'admin', 'felamimail', 'sitemgr', 'sitemgr-link'))) continue;
776 775
 			if ($GLOBALS['egw_info']['user']['apps'][$app])
777 776
 			{
778 777
 				$apps[$app] = $data['title'] ? $data['title'] : lang($app);
Please login to merge, or discard this patch.
Braces   +64 added lines, -17 removed lines patch added patch discarded remove patch
@@ -150,8 +150,14 @@  discard block
 block discarded – undo
150 150
 			{
151 151
 				case 'save':
152 152
 				case 'apply':
153
-					if(is_array($content['owner'])) $content['owner'] = implode(',',$content['owner']);
154
-					if($content['owner'] == '') $content['owner'] = 0;
153
+					if(is_array($content['owner']))
154
+					{
155
+						$content['owner'] = implode(',',$content['owner']);
156
+					}
157
+					if($content['owner'] == '')
158
+					{
159
+						$content['owner'] = 0;
160
+					}
155 161
 					if ($content['id'] && self::$acl_edit)
156 162
 					{
157 163
 
@@ -247,7 +253,10 @@  discard block
 block discarded – undo
247 253
 			Framework::refresh_opener($msg, $refresh_app, $content['id'], $change_color ? null : 'update', $this->appname);
248 254
 		}
249 255
 		$content['msg'] = $msg;
250
-		if(!$content['appname']) $content['appname'] = $appname;
256
+		if(!$content['appname'])
257
+		{
258
+			$content['appname'] = $appname;
259
+		}
251 260
 		if($content['data']['icon'])
252 261
 		{
253 262
 			$content['icon_url'] = $content['base_url'] . $content['data']['icon'];
@@ -302,7 +311,9 @@  discard block
 block discarded – undo
302 311
 			// Allow admins access to all categories as parent
303 312
 			$content['all_cats'] = 'all_no_acl';
304 313
 			$readonlys['owner'] = false;
305
-		} else {
314
+		}
315
+		else
316
+		{
306 317
 			$readonlys['owner'] = true;
307 318
 			$readonlys['access'] = $content['owner'] != $GLOBALS['egw_info']['user']['account_id'];
308 319
 		}
@@ -313,7 +324,10 @@  discard block
 block discarded – undo
313 324
 			$appname != $content['appname'] || // Can't edit a category from a different app
314 325
 			 ($this->appname != 'admin' && $content['owner'] != $GLOBALS['egw_info']['user']['account_id']);
315 326
 		// Make sure $content['owner'] is an array otherwise it wont show up values in the multiselectbox
316
-		if (!is_array($content['owner'])) $content['owner'] = explode(',',$content['owner']);
327
+		if (!is_array($content['owner']))
328
+		{
329
+			$content['owner'] = explode(',',$content['owner']);
330
+		}
317 331
 		$tmpl = new Etemplate('admin.categories.edit');
318 332
 		$tmpl->exec($this->edit_link,$content,$sel_options,$readonlys,$content+array(
319 333
 			'old_parent' => $content['old_parent'] ? $content['old_parent'] : $content['parent'], 'appname' => $appname
@@ -373,9 +387,15 @@  discard block
 block discarded – undo
373 387
 		{
374 388
 			$globalcat = false;
375 389
 		}
376
-		if ($globalcat && $query['filter']) $filter['access'] = 'public';
390
+		if ($globalcat && $query['filter'])
391
+		{
392
+			$filter['access'] = 'public';
393
+		}
377 394
 		// new column-filter access has highest priority
378
-		if (!empty($query['col_filter']['access']))$filter['access'] = $query['col_filter']['access'];
395
+		if (!empty($query['col_filter']['access']))
396
+		{
397
+			$filter['access'] = $query['col_filter']['access'];
398
+		}
379 399
 
380 400
 		Api\Cache::setSession(__CLASS__.$query['appname'],'nm',$query);
381 401
 
@@ -404,7 +424,10 @@  discard block
 block discarded – undo
404 424
 
405 425
 			$row['level_spacer'] = str_repeat('&nbsp; &nbsp; ',$row['level']);
406 426
 
407
-			if ($row['data']['icon']) $row['icon_url'] = self::icon_url($row['data']['icon']);
427
+			if ($row['data']['icon'])
428
+			{
429
+				$row['icon_url'] = self::icon_url($row['data']['icon']);
430
+			}
408 431
 
409 432
 			$row['subs'] = count($row['children']);
410 433
 
@@ -435,13 +458,19 @@  discard block
 block discarded – undo
435 458
 			$readonlys['nm']["add[$row[id]]"]    = !self::$acl_add_sub;
436 459
 			$readonlys['nm']["delete[$row[id]]"] = !self::$acl_delete;
437 460
 		}
438
-		if (true) $rows = $count <= $query['num_rows'] ? array_values($rows) : array_slice($rows, $query['start'], $query['num_rows']);
461
+		if (true)
462
+		{
463
+			$rows = $count <= $query['num_rows'] ? array_values($rows) : array_slice($rows, $query['start'], $query['num_rows']);
464
+		}
439 465
 		// make appname available for actions
440 466
 		$rows['appname'] = $query['appname'];
441 467
 		$rows['edit_link'] = $this->edit_link;
442 468
 
443 469
 		// disable access column for global Categories
444
-		if ($GLOBALS['egw_info']['flags']['currentapp'] == 'admin') $rows['no_access'] = true;
470
+		if ($GLOBALS['egw_info']['flags']['currentapp'] == 'admin')
471
+		{
472
+			$rows['no_access'] = true;
473
+		}
445 474
 
446 475
 		$GLOBALS['egw_info']['flags']['app_header'] = lang($this->appname).' - '.lang('categories').
447 476
 			($query['appname'] != Categories::GLOBAL_APPNAME ? ': '.lang($query['appname']) : '');
@@ -458,11 +487,18 @@  discard block
 block discarded – undo
458 487
 	public function index(array $content=null,$msg='')
459 488
 	{
460 489
 		//_debug_array($_GET);
461
-		if ($this->appname != 'admin') Api\Translation::add_app('admin');	// need admin translations
490
+		if ($this->appname != 'admin')
491
+		{
492
+			Api\Translation::add_app('admin');
493
+		}
494
+		// need admin translations
462 495
 
463 496
 		if(!isset($content))
464 497
 		{
465
-			if (isset($_GET['msg'])) $msg = $_GET['msg'];
498
+			if (isset($_GET['msg']))
499
+			{
500
+				$msg = $_GET['msg'];
501
+			}
466 502
 
467 503
 			$appname = Categories::GLOBAL_APPNAME;
468 504
 			foreach(array($content['nm']['appname'], $_GET['cats_app'], $_GET['appname']) as $field)
@@ -602,7 +638,8 @@  discard block
 block discarded – undo
602 638
 			$readonlys['nm']['rows']['owner'] = true;
603 639
 			$readonlys['nm']['col_filter']['owner'] = true;
604 640
 		}
605
-		if($appname == Categories::GLOBAL_APPNAME) {
641
+		if($appname == Categories::GLOBAL_APPNAME)
642
+		{
606 643
 			$sel_options['app'] = array(''=>'');
607 644
 			$readonlys['nm']['rows']['app'] = true;
608 645
 		}
@@ -617,7 +654,8 @@  discard block
 block discarded – undo
617 654
 		));
618 655
 	}
619 656
 
620
-	protected function get_actions($appname=categories::GLOBAL_APPNAME) {
657
+	protected function get_actions($appname=categories::GLOBAL_APPNAME)
658
+	{
621 659
 
622 660
 		$actions = array(
623 661
 			'open' => array(        // does edit if allowed, otherwise view
@@ -728,11 +766,17 @@  discard block
 block discarded – undo
728 766
 				list($add_remove, $ids_csv) = explode('_', $settings, 2);
729 767
 				$ids = explode(',', $ids_csv);
730 768
 				// Adding 'All users' removes all the others
731
-				if($add_remove == 'add' && array_search(Categories::GLOBAL_ACCOUNT,$ids) !== false) $ids = array(Categories::GLOBAL_ACCOUNT);
769
+				if($add_remove == 'add' && array_search(Categories::GLOBAL_ACCOUNT,$ids) !== false)
770
+				{
771
+					$ids = array(Categories::GLOBAL_ACCOUNT);
772
+				}
732 773
 
733 774
 				foreach($checked as $id)
734 775
 				{
735
-					if (!$data = $cats->read($id)) continue;
776
+					if (!$data = $cats->read($id))
777
+					{
778
+						continue;
779
+					}
736 780
 					$data['owner'] = explode(',',$data['owner']);
737 781
 					if(array_search(Categories::GLOBAL_ACCOUNT,$data['owner']) !== false || $data['owner'][0] > 0)
738 782
 					{
@@ -772,7 +816,10 @@  discard block
 block discarded – undo
772 816
 				continue;
773 817
 			}
774 818
 			// Skip apps that don't show in the app bar, they [usually] don't have Categories
775
-			if($data['status'] > 1 || in_array($app, array('home','admin','felamimail','sitemgr','sitemgr-link'))) continue;
819
+			if($data['status'] > 1 || in_array($app, array('home','admin','felamimail','sitemgr','sitemgr-link')))
820
+			{
821
+				continue;
822
+			}
776 823
 			if ($GLOBALS['egw_info']['user']['apps'][$app])
777 824
 			{
778 825
 				$apps[$app] = $data['title'] ? $data['title'] : lang($app);
Please login to merge, or discard this patch.
admin/inc/class.admin_cmd.inc.php 4 patches
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -443,10 +443,10 @@  discard block
 block discarded – undo
443 443
 	 *
444 444
 	 * @static
445 445
 	 * @param array|string $criteria array of key and data cols, OR a SQL query (content for WHERE), fully quoted (!)
446
-	 * @param boolean|string|array $only_keys =true True returns only keys, False returns all cols. or
446
+	 * @param boolean $only_keys =true True returns only keys, False returns all cols. or
447 447
 	 *	comma seperated list or array of columns to return
448 448
 	 * @param string $order_by ='' fieldnames + {ASC|DESC} separated by colons ',', can also contain a GROUP BY (if it contains ORDER BY)
449
-	 * @param string|array $extra_cols ='' string or array of strings to be added to the SELECT, eg. "count(*) as num"
449
+	 * @param string $extra_cols ='' string or array of strings to be added to the SELECT, eg. "count(*) as num"
450 450
 	 * @param string $wildcard ='' appended befor and after each criteria
451 451
 	 * @param boolean $empty =false False=empty criteria are ignored in query, True=empty have to be empty in row
452 452
 	 * @param string $op ='AND' defaults to 'AND', can be set to 'OR' too, then criteria's are OR'ed together
@@ -696,7 +696,7 @@  discard block
 block discarded – undo
696 696
 	 *
697 697
 	 * @param string|boolean|int $value
698 698
 	 * @param boolean $default =null
699
-	 * @return boolean
699
+	 * @return boolean|null
700 700
 	 * @throws Api\Exception\WrongUserinput(lang('Invalid value "%1" use yes or no!',$value),998);
701 701
 	 */
702 702
 	static function parse_boolean($value,$default=null)
@@ -925,7 +925,7 @@  discard block
 block discarded – undo
925 925
 	 * Read data of a remote instance
926 926
 	 *
927 927
 	 * @param array|int $keys
928
-	 * @return array
928
+	 * @return string
929 929
 	 */
930 930
 	static function read_remote($keys)
931 931
 	{
@@ -1005,7 +1005,7 @@  discard block
 block discarded – undo
1005 1005
 	 * Check if string is a md5 hash (32 chars of 0-9 or a-f)
1006 1006
 	 *
1007 1007
 	 * @param string $str
1008
-	 * @return boolean
1008
+	 * @return integer
1009 1009
 	 */
1010 1010
 	static function is_md5($str)
1011 1011
 	{
Please login to merge, or discard this patch.
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -239,11 +239,11 @@
 block discarded – undo
239 239
 			unset($postdata[$name]);
240 240
 		}
241 241
 		$opts = array('http' =>
242
-		    array(
243
-		        'method'  => 'POST',
244
-		        'header'  => 'Content-type: application/x-www-form-urlencoded',
245
-		        'content' => http_build_query($postdata),
246
-		    )
242
+			array(
243
+				'method'  => 'POST',
244
+				'header'  => 'Content-type: application/x-www-form-urlencoded',
245
+				'content' => http_build_query($postdata),
246
+			)
247 247
 		);
248 248
 		$url = $remote['remote_url'].'/admin/remote.php?domain='.urlencode($remote['remote_domain']).'&secret='.urlencode($secret);
249 249
 		//echo "sending command to $url\n"; _debug_array($opts);
Please login to merge, or discard this patch.
Spacing   +98 added lines, -98 removed lines patch added patch discarded remove patch
@@ -23,14 +23,14 @@  discard block
 block discarded – undo
23 23
 	const successful = 2;
24 24
 	const failed     = 3;
25 25
 	const pending    = 4;
26
-	const queued     = 5;	// command waits to be fetched from remote
26
+	const queued     = 5; // command waits to be fetched from remote
27 27
 
28 28
 	/**
29 29
 	 * Status which stil need passwords available
30 30
 	 *
31 31
 	 * @var array
32 32
 	 */
33
-	static $require_pw_stati = array(self::scheduled,self::pending,self::queued);
33
+	static $require_pw_stati = array(self::scheduled, self::pending, self::queued);
34 34
 
35 35
 	/**
36 36
 	 * The status of the command, one of either scheduled, successful, failed or deleted
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 	 * @return string success message
108 108
 	 * @throws Exception()
109 109
 	 */
110
-	protected abstract function exec($check_only=false);
110
+	protected abstract function exec($check_only = false);
111 111
 
112 112
 	/**
113 113
 	 * Return a title / string representation for a given command, eg. to display it
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 
133 133
 		$this->type = get_class($this);
134 134
 
135
-		foreach($data as $name => $value)
135
+		foreach ($data as $name => $value)
136 136
 		{
137 137
 			$this->$name = $name == 'data' && !is_array($value) ? json_php_unserialize($value) : $value;
138 138
 		}
@@ -151,13 +151,13 @@  discard block
 block discarded – undo
151 151
 	 * @return mixed return value of the command
152 152
 	 * @throws Exceptions on error
153 153
 	 */
154
-	function run($time=null,$set_modifier=true,$skip_checks=false,$dry_run=false)
154
+	function run($time = null, $set_modifier = true, $skip_checks = false, $dry_run = false)
155 155
 	{
156 156
 		if (!is_null($time))
157 157
 		{
158 158
 			$this->scheduled = $time;
159 159
 			$this->status = admin_cmd::scheduled;
160
-			$ret = lang('Command scheduled to run at %1',date('Y-m-d H:i',$time));
160
+			$ret = lang('Command scheduled to run at %1', date('Y-m-d H:i', $time));
161 161
 			// running the checks of the arguments for local commands, if not explicitly requested to not run them
162 162
 			if (!$this->remote_id && !$skip_checks)
163 163
 			{
@@ -220,21 +220,21 @@  discard block
 block discarded – undo
220 220
 	{
221 221
 		if (!($remote = $this->read_remote($this->remote_id)))
222 222
 		{
223
-			throw new Api\Exception\WrongUserinput(lang('Invalid remote id or name "%1"!',$this->remote_id),997);
223
+			throw new Api\Exception\WrongUserinput(lang('Invalid remote id or name "%1"!', $this->remote_id), 997);
224 224
 		}
225 225
 		if (!$this->uid)
226 226
 		{
227
-			$this->save();	// to get the uid
227
+			$this->save(); // to get the uid
228 228
 		}
229 229
 		$secret = md5($this->uid.$remote['remote_hash']);
230 230
 
231 231
 		$postdata = $this->as_array();
232 232
 		if (is_object($GLOBALS['egw']->translation))
233 233
 		{
234
-			$postdata = Api\Translation::convert($postdata,Api\Translation::charset(),'utf-8');
234
+			$postdata = Api\Translation::convert($postdata, Api\Translation::charset(), 'utf-8');
235 235
 		}
236 236
 		// dont send the id's which have no meaning on the remote install
237
-		foreach(array('id','creator','modifier','requested','remote_id') as $name)
237
+		foreach (array('id', 'creator', 'modifier', 'requested', 'remote_id') as $name)
238 238
 		{
239 239
 			unset($postdata[$name]);
240 240
 		}
@@ -260,12 +260,12 @@  discard block
 block discarded – undo
260 260
 		}
261 261
 		if (is_object($GLOBALS['egw']->translation))
262 262
 		{
263
-			$message = Api\Translation::convert($message,'utf-8');
263
+			$message = Api\Translation::convert($message, 'utf-8');
264 264
 		}
265 265
 		$matches = null;
266
-		if (is_string($message) && preg_match('/^([0-9]+) (.*)$/',$message,$matches))
266
+		if (is_string($message) && preg_match('/^([0-9]+) (.*)$/', $message, $matches))
267 267
 		{
268
-			throw new Api\Exception($matches[2],(int)$matches[1]);
268
+			throw new Api\Exception($matches[2], (int)$matches[1]);
269 269
 		}
270 270
 		return $message;
271 271
 	}
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 	 * @param boolean $set_modifier =true set the current user as modifier or 0 (= run by the system)
291 291
 	 * @return boolean true on success, false otherwise
292 292
 	 */
293
-	function save($set_modifier=true)
293
+	function save($set_modifier = true)
294 294
 	{
295 295
 		admin_cmd::_instanciate_sql();
296 296
 
@@ -305,13 +305,13 @@  discard block
 block discarded – undo
305 305
 			$this->modifier = $set_modifier ? $GLOBALS['egw_info']['user']['account_id'] : 0;
306 306
 			if ($set_modifier) $this->modifier_email = admin_cmd::user_email();
307 307
 		}
308
-		if (version_compare(PHP_VERSION,'5.1.2','>'))
308
+		if (version_compare(PHP_VERSION, '5.1.2', '>'))
309 309
 		{
310
-			$vars = get_object_vars($this);	// does not work in php5.1.2 due a bug
310
+			$vars = get_object_vars($this); // does not work in php5.1.2 due a bug
311 311
 		}
312 312
 		else
313 313
 		{
314
-			foreach(array_keys(get_class_vars(__CLASS__)) as $name)
314
+			foreach (array_keys(get_class_vars(__CLASS__)) as $name)
315 315
 			{
316 316
 				$vars[$name] = $this->$name;
317 317
 			}
@@ -351,13 +351,13 @@  discard block
 block discarded – undo
351 351
 	 * @param boolean $return_serialized =true true: return json serialized string, false: return array
352 352
 	 * @return string|array see $return_serialized
353 353
 	 */
354
-	static function mask_passwords($data, $return_serialized=true)
354
+	static function mask_passwords($data, $return_serialized = true)
355 355
 	{
356 356
 		if (!is_array($data))
357 357
 		{
358 358
 			$data = json_php_unserialize($data);
359 359
 		}
360
-		foreach($data as $key => &$value)
360
+		foreach ($data as $key => &$value)
361 361
 		{
362 362
 			if (is_array($value))
363 363
 			{
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
 		}
408 408
 		if (!class_exists($class = $data['type']) || $class == 'admin_cmd')
409 409
 		{
410
-			throw new Api\Exception\WrongParameter(lang('Unknown command %1!',$class),0);
410
+			throw new Api\Exception\WrongParameter(lang('Unknown command %1!', $class), 0);
411 411
 		}
412 412
 		$cmd = new $class($data);
413 413
 
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
 		{
416 416
 			return $cmd;
417 417
 		}
418
-		throw new Api\Exception\WrongParameter(lang('%1 is no command!',$class),0);
418
+		throw new Api\Exception\WrongParameter(lang('%1 is no command!', $class), 0);
419 419
 	}
420 420
 
421 421
 	/**
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
 	 * @param array $readonlys
428 428
 	 * @return int
429 429
 	 */
430
-	static function get_rows($query,&$rows,$readonlys)
430
+	static function get_rows($query, &$rows, $readonlys)
431 431
 	{
432 432
 		admin_cmd::_instanciate_sql();
433 433
 
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
 		{
436 436
 			$query['col_filter']['remote_id'] = null;
437 437
 		}
438
-		return admin_cmd::$sql->get_rows($query,$rows,$readonlys);
438
+		return admin_cmd::$sql->get_rows($query, $rows, $readonlys);
439 439
 	}
440 440
 
441 441
 	/**
@@ -454,11 +454,11 @@  discard block
 block discarded – undo
454 454
 	 * @param array $filter =null if set (!=null) col-data pairs, to be and-ed (!) into the query without wildcards
455 455
 	 * @return array
456 456
 	 */
457
-	static function &search($criteria,$only_keys=True,$order_by='',$extra_cols='',$wildcard='',$empty=False,$op='AND',$start=false,$filter=null)
457
+	static function &search($criteria, $only_keys = True, $order_by = '', $extra_cols = '', $wildcard = '', $empty = False, $op = 'AND', $start = false, $filter = null)
458 458
 	{
459 459
 		admin_cmd::_instanciate_sql();
460 460
 
461
-		return admin_cmd::$sql->search($criteria,$only_keys,$order_by,$extra_cols,$wildcard,$empty,$op,$start,$filter);
461
+		return admin_cmd::$sql->search($criteria, $only_keys, $order_by, $extra_cols, $wildcard, $empty, $op, $start, $filter);
462 462
 	}
463 463
 
464 464
 	/**
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
 	{
471 471
 		if (is_null(admin_cmd::$sql))
472 472
 		{
473
-			admin_cmd::$sql = new Api\Storage\Base('admin','egw_admin_queue',null,'cmd_');
473
+			admin_cmd::$sql = new Api\Storage\Base('admin', 'egw_admin_queue', null, 'cmd_');
474 474
 		}
475 475
 	}
476 476
 
@@ -483,7 +483,7 @@  discard block
 block discarded – undo
483 483
 	{
484 484
 		if (is_null(admin_cmd::$remote))
485 485
 		{
486
-			admin_cmd::$remote = new Api\Storage\Base('admin','egw_admin_remote');
486
+			admin_cmd::$remote = new Api\Storage\Base('admin', 'egw_admin_remote');
487 487
 		}
488 488
 	}
489 489
 
@@ -495,11 +495,11 @@  discard block
 block discarded – undo
495 495
 	 */
496 496
 	function __get($property)
497 497
 	{
498
-		if (property_exists('admin_cmd',$property))
498
+		if (property_exists('admin_cmd', $property))
499 499
 		{
500
-			return $this->$property;	// making all (non static) class vars readonly available
500
+			return $this->$property; // making all (non static) class vars readonly available
501 501
 		}
502
-		switch($property)
502
+		switch ($property)
503 503
 		{
504 504
 			case 'accounts':
505 505
 				self::_instanciate_accounts();
@@ -516,9 +516,9 @@  discard block
 block discarded – undo
516 516
 	 */
517 517
 	function __isset($property)
518 518
 	{
519
-		if (property_exists('admin_cmd',$property))
519
+		if (property_exists('admin_cmd', $property))
520 520
 		{
521
-			return isset($this->$property);	// making all (non static) class vars readonly available
521
+			return isset($this->$property); // making all (non static) class vars readonly available
522 522
 		}
523 523
 		return isset($this->data[$property]);
524 524
 	}
@@ -530,7 +530,7 @@  discard block
 block discarded – undo
530 530
 	 * @param mixed $value
531 531
 	 * @return mixed
532 532
 	 */
533
-	function __set($property,$value)
533
+	function __set($property, $value)
534 534
 	{
535 535
 		$this->data[$property] = $value;
536 536
 	}
@@ -552,19 +552,19 @@  discard block
 block discarded – undo
552 552
 	 */
553 553
 	function as_array()
554 554
 	{
555
-		if (version_compare(PHP_VERSION,'5.1.2','>'))
555
+		if (version_compare(PHP_VERSION, '5.1.2', '>'))
556 556
 		{
557
-			$vars = get_object_vars($this);	// does not work in php5.1.2 due a bug
557
+			$vars = get_object_vars($this); // does not work in php5.1.2 due a bug
558 558
 		}
559 559
 		else
560 560
 		{
561
-			foreach(array_keys(get_class_vars(__CLASS__)) as $name)
561
+			foreach (array_keys(get_class_vars(__CLASS__)) as $name)
562 562
 			{
563 563
 				$vars[$name] = $this->$name;
564 564
 			}
565 565
 		}
566 566
 		unset($vars['data']);
567
-		if ($this->data) $vars = array_merge($this->data,$vars);
567
+		if ($this->data) $vars = array_merge($this->data, $vars);
568 568
 
569 569
 		return $vars;
570 570
 	}
@@ -576,14 +576,14 @@  discard block
 block discarded – undo
576 576
 	 * @param int $extra_deny =null further admin rights to check, eg. 16 = deny edit Api\Accounts
577 577
 	 * @throws Api\Exception\NoPermission\Admin
578 578
 	 */
579
-	protected function _check_admin($extra_acl=null,$extra_deny=null)
579
+	protected function _check_admin($extra_acl = null, $extra_deny = null)
580 580
 	{
581 581
 		if ($this->creator)
582 582
 		{
583 583
 			admin_cmd::_instanciate_acl($this->creator);
584 584
 			// todo: check only if and with $this->creator
585
-			if (!admin_cmd::$acl->check('run',1,'admin') &&		// creator is no longer admin
586
-				$extra_acl && $extra_deny && admin_cmd::$acl->check($extra_acl,$extra_deny,'admin'))	// creator is explicitly forbidden to do something
585
+			if (!admin_cmd::$acl->check('run', 1, 'admin') && // creator is no longer admin
586
+				$extra_acl && $extra_deny && admin_cmd::$acl->check($extra_acl, $extra_deny, 'admin'))	// creator is explicitly forbidden to do something
587 587
 			{
588 588
 				throw new Api\Exception\NoPermission\Admin();
589 589
 			}
@@ -599,13 +599,13 @@  discard block
 block discarded – undo
599 599
 	 */
600 600
 	static function parse_apps(array $apps)
601 601
 	{
602
-		foreach($apps as $key => $name)
602
+		foreach ($apps as $key => $name)
603 603
 		{
604 604
 			if (!isset($GLOBALS['egw_info']['apps'][$name]))
605 605
 			{
606
-				foreach($GLOBALS['egw_info']['apps'] as $app => $data)	// check against title and localised name
606
+				foreach ($GLOBALS['egw_info']['apps'] as $app => $data)	// check against title and localised name
607 607
 				{
608
-					if (!strcasecmp($name,$data['title']) || !strcasecmp($name,lang($app)))
608
+					if (!strcasecmp($name, $data['title']) || !strcasecmp($name, lang($app)))
609 609
 					{
610 610
 						$apps[$key] = $name = $app;
611 611
 						break;
@@ -614,7 +614,7 @@  discard block
 block discarded – undo
614 614
 			}
615 615
 			if (!isset($GLOBALS['egw_info']['apps'][$name]))
616 616
 			{
617
-				throw new Api\Exception\WrongUserinput(lang("Application '%1' not found (maybe not installed or misspelled)!",$name),8);
617
+				throw new Api\Exception\WrongUserinput(lang("Application '%1' not found (maybe not installed or misspelled)!", $name), 8);
618 618
 			}
619 619
 		}
620 620
 		return $apps;
@@ -629,20 +629,20 @@  discard block
 block discarded – undo
629 629
 	 * @throws Api\Exception\WrongUserinput(lang("Unknown account: %1 !!!",$account),15);
630 630
 	 * @throws Api\Exception\WrongUserinput(lang("Wrong account type: %1 is NO %2 !!!",$account,$allow_only_user?lang('user'):lang('group')),15);
631 631
 	 */
632
-	static function parse_account($account,$allow_only_user=null)
632
+	static function parse_account($account, $allow_only_user = null)
633 633
 	{
634 634
 		admin_cmd::_instanciate_accounts();
635 635
 
636 636
 		if (!($type = admin_cmd::$accounts->exists($account)) ||
637
-			!is_numeric($id=$account) && !($id = admin_cmd::$accounts->name2id($account)))
637
+			!is_numeric($id = $account) && !($id = admin_cmd::$accounts->name2id($account)))
638 638
 		{
639
-			throw new Api\Exception\WrongUserinput(lang("Unknown account: %1 !!!",$account),15);
639
+			throw new Api\Exception\WrongUserinput(lang("Unknown account: %1 !!!", $account), 15);
640 640
 		}
641 641
 		if (!is_null($allow_only_user) && $allow_only_user !== ($type == 1))
642 642
 		{
643
-			throw new Api\Exception\WrongUserinput(lang("Wrong account type: %1 is NO %2 !!!",$account,$allow_only_user?lang('user'):lang('group')),15);
643
+			throw new Api\Exception\WrongUserinput(lang("Wrong account type: %1 is NO %2 !!!", $account, $allow_only_user ? lang('user') : lang('group')), 15);
644 644
 		}
645
-		if ($type == 2 && $id > 0) $id = -$id;	// groups use negative id's internally, fix it, if user given the wrong sign
645
+		if ($type == 2 && $id > 0) $id = -$id; // groups use negative id's internally, fix it, if user given the wrong sign
646 646
 
647 647
 		return $id;
648 648
 	}
@@ -656,14 +656,14 @@  discard block
 block discarded – undo
656 656
 	 * @throws Api\Exception\WrongUserinput(lang("Unknown account: %1 !!!",$account),15);
657 657
 	 * @throws Api\Exception\WrongUserinput(lang("Wrong account type: %1 is NO %2 !!!",$account,$allow_only?lang('user'):lang('group')),15);
658 658
 	 */
659
-	static function parse_accounts($accounts,$allow_only_user=null)
659
+	static function parse_accounts($accounts, $allow_only_user = null)
660 660
 	{
661 661
 		if (!$accounts) return null;
662 662
 
663 663
 		$ids = array();
664
-		foreach(is_array($accounts) ? $accounts : explode(',',$accounts) as $account)
664
+		foreach (is_array($accounts) ? $accounts : explode(',', $accounts) as $account)
665 665
 		{
666
-			$ids[] = admin_cmd::parse_account($account,$allow_only_user);
666
+			$ids[] = admin_cmd::parse_account($account, $allow_only_user);
667 667
 		}
668 668
 		return $ids;
669 669
 	}
@@ -681,11 +681,11 @@  discard block
 block discarded – undo
681 681
 		{
682 682
 			$datein = $date;
683 683
 			// convert german DD.MM.YYYY format into ISO YYYY-MM-DD format
684
-			$date = preg_replace('/^([0-9]{1,2})\.([0-9]{1,2})\.([0-9]{4})$/','\3-\2-\1',$date);
684
+			$date = preg_replace('/^([0-9]{1,2})\.([0-9]{1,2})\.([0-9]{4})$/', '\3-\2-\1', $date);
685 685
 
686
-			if (($date = strtotime($date))  === false)
686
+			if (($date = strtotime($date)) === false)
687 687
 			{
688
-				throw new Api\Exception\WrongUserinput(lang('Invalid formated date "%1"!',$datein),6);
688
+				throw new Api\Exception\WrongUserinput(lang('Invalid formated date "%1"!', $datein), 6);
689 689
 			}
690 690
 		}
691 691
 		return (int)$date;
@@ -699,7 +699,7 @@  discard block
 block discarded – undo
699 699
 	 * @return boolean
700 700
 	 * @throws Api\Exception\WrongUserinput(lang('Invalid value "%1" use yes or no!',$value),998);
701 701
 	 */
702
-	static function parse_boolean($value,$default=null)
702
+	static function parse_boolean($value, $default = null)
703 703
 	{
704 704
 		if (is_bool($value) || is_int($value))
705 705
 		{
@@ -709,15 +709,15 @@  discard block
 block discarded – undo
709 709
 		{
710 710
 			return $default;
711 711
 		}
712
-		if (in_array($value,array('1','yes','true',lang('yes'),lang('true'))))
712
+		if (in_array($value, array('1', 'yes', 'true', lang('yes'), lang('true'))))
713 713
 		{
714 714
 			return true;
715 715
 		}
716
-		if (in_array($value,array('0','no','false',lang('no'),lang('false'))))
716
+		if (in_array($value, array('0', 'no', 'false', lang('no'), lang('false'))))
717 717
 		{
718 718
 			return false;
719 719
 		}
720
-		throw new Api\Exception\WrongUserinput(lang('Invalid value "%1" use yes or no!',$value),998);
720
+		throw new Api\Exception\WrongUserinput(lang('Invalid value "%1" use yes or no!', $value), 998);
721 721
 	}
722 722
 
723 723
 	/**
@@ -735,9 +735,9 @@  discard block
 block discarded – undo
735 735
 			'remote_id' => $id_or_name,
736 736
 			'remote_name' => $id_or_name,
737 737
 			'remote_domain' => $id_or_name,
738
-		),true,'','','',false,'OR')) || count($remotes) != 1)
738
+		), true, '', '', '', false, 'OR')) || count($remotes) != 1)
739 739
 		{
740
-			throw new Api\Exception\WrongUserinput(lang('Invalid remote id or name "%1"!',$id_or_name),997);
740
+			throw new Api\Exception\WrongUserinput(lang('Invalid remote id or name "%1"!', $id_or_name), 997);
741 741
 		}
742 742
 		return $remotes[0]['remote_id'];
743 743
 	}
@@ -754,7 +754,7 @@  discard block
 block discarded – undo
754 754
 		{
755 755
 			if (!is_object($GLOBALS['egw']->accounts))
756 756
 			{
757
-				throw new Api\Exception\AssertionFailed(lang('%1 class not instanciated','accounts'),999);
757
+				throw new Api\Exception\AssertionFailed(lang('%1 class not instanciated', 'accounts'), 999);
758 758
 			}
759 759
 			admin_cmd::$accounts = $GLOBALS['egw']->accounts;
760 760
 		}
@@ -767,13 +767,13 @@  discard block
 block discarded – undo
767 767
 	 * @param int $account =null account_id the class needs to be instanciated for, default need only account-independent methods
768 768
 	 * @throws Api\Exception\AssertionFailed(lang('%1 class not instanciated','acl'),999);
769 769
 	 */
770
-	protected function _instanciate_acl($account=null)
770
+	protected function _instanciate_acl($account = null)
771 771
 	{
772 772
 		if (!is_object(admin_cmd::$acl) || $account && admin_cmd::$acl->account_id != $account)
773 773
 		{
774 774
 			if (!is_object($GLOBALS['egw']->acl))
775 775
 			{
776
-				throw new Api\Exception\AssertionFailed(lang('%1 class not instanciated','acl'),999);
776
+				throw new Api\Exception\AssertionFailed(lang('%1 class not instanciated', 'acl'), 999);
777 777
 			}
778 778
 			if ($account && $GLOBALS['egw']->acl->account_id != $account)
779 779
 			{
@@ -793,20 +793,20 @@  discard block
 block discarded – undo
793 793
 	 * @param $account_id =null account_id, default current user
794 794
 	 * @return string
795 795
 	 */
796
-	static function user_email($account_id=null)
796
+	static function user_email($account_id = null)
797 797
 	{
798 798
 		if ($account_id)
799 799
 		{
800 800
 			admin_cmd::_instanciate_accounts();
801
-			$fullname = admin_cmd::$accounts->id2name($account_id,'account_fullname');
802
-			$email = admin_cmd::$accounts->id2name($account_id,'account_email');
801
+			$fullname = admin_cmd::$accounts->id2name($account_id, 'account_fullname');
802
+			$email = admin_cmd::$accounts->id2name($account_id, 'account_email');
803 803
 		}
804 804
 		else
805 805
 		{
806 806
 			$fullname = $GLOBALS['egw_info']['user']['account_fullname'];
807 807
 			$email = $GLOBALS['egw_info']['user']['account_email'];
808 808
 		}
809
-		return $fullname . ($email ? ' <'.$email.'>' : '');
809
+		return $fullname.($email ? ' <'.$email.'>' : '');
810 810
 	}
811 811
 
812 812
 	/**
@@ -830,11 +830,11 @@  discard block
 block discarded – undo
830 830
 		{
831 831
 			return false;
832 832
 		}
833
-		if (!($jobs = admin_cmd::search(array(),false,'cmd_scheduled','','',false,'AND',array(0,1),array(
833
+		if (!($jobs = admin_cmd::search(array(), false, 'cmd_scheduled', '', '', false, 'AND', array(0, 1), array(
834 834
 			'cmd_status' => admin_cmd::scheduled,
835 835
 		))))
836 836
 		{
837
-			return false;		// no schduled command, no need to setup the job
837
+			return false; // no schduled command, no need to setup the job
838 838
 		}
839 839
 		$next = $jobs[0];
840 840
 		if (($time = $next['scheduled']) < time())	// should run immediatly
@@ -844,11 +844,11 @@  discard block
 block discarded – undo
844 844
 		$async = new Api\Asyncservice();
845 845
 
846 846
 		// we cant use this class as callback, as it's abstract and ExecMethod used by the async service instanciated the class!
847
-		list($app) = explode('_',$class=$next['type']);
847
+		list($app) = explode('_', $class = $next['type']);
848 848
 		$callback = $app.'.'.$class.'.run_queued_jobs';
849 849
 
850
-		$async->cancel_timer(admin_cmd::async_job_id);	// we delete it in case a job already exists
851
-		return $async->set_timer($time,admin_cmd::async_job_id,$callback,null,$next['creator']);
850
+		$async->cancel_timer(admin_cmd::async_job_id); // we delete it in case a job already exists
851
+		return $async->set_timer($time, admin_cmd::async_job_id, $callback, null, $next['creator']);
852 852
 	}
853 853
 
854 854
 	/**
@@ -858,27 +858,27 @@  discard block
 block discarded – undo
858 858
 	 */
859 859
 	static function run_queued_jobs()
860 860
 	{
861
-		if (!($jobs = admin_cmd::search(array(),false,'cmd_scheduled','','',false,'AND',false,array(
861
+		if (!($jobs = admin_cmd::search(array(), false, 'cmd_scheduled', '', '', false, 'AND', false, array(
862 862
 			'cmd_status' => admin_cmd::scheduled,
863 863
 			'cmd_scheduled <= '.time(),
864 864
 		))))
865 865
 		{
866
-			return false;		// no schduled commands, no need to setup the job
866
+			return false; // no schduled commands, no need to setup the job
867 867
 		}
868
-		admin_cmd::$running_queued_jobs = true;	// stop admin_cmd::run() which calls admin_cmd::save() to install a new job
868
+		admin_cmd::$running_queued_jobs = true; // stop admin_cmd::run() which calls admin_cmd::save() to install a new job
869 869
 
870
-		foreach($jobs as $job)
870
+		foreach ($jobs as $job)
871 871
 		{
872 872
 			try {
873 873
 				$cmd = admin_cmd::instanciate($job);
874
-				$cmd->run(null,false);	// false = dont set current user as modifier, as job is run by the queue/system itself
874
+				$cmd->run(null, false); // false = dont set current user as modifier, as job is run by the queue/system itself
875 875
 			}
876 876
 			catch (Exception $e) {	// we need to mark that command as failed, to prevent further execution
877 877
 				unset($e);
878 878
 				admin_cmd::$sql->init($job);
879 879
 				admin_cmd::$sql->save(array(
880 880
 					'status' => admin_cmd::failed,
881
-					'error'  => lang('Unknown command %1!',$job['type']),
881
+					'error'  => lang('Unknown command %1!', $job['type']),
882 882
 					'errno'  => 0,
883 883
 					'data'   => self::mask_passwords($job['data']),
884 884
 				));
@@ -899,9 +899,9 @@  discard block
 block discarded – undo
899 899
 		admin_cmd::_instanciate_remote();
900 900
 
901 901
 		$sites = array(lang('local'));
902
-		if (($remote = admin_cmd::$remote->query_list('remote_name','remote_id')))
902
+		if (($remote = admin_cmd::$remote->query_list('remote_name', 'remote_id')))
903 903
 		{
904
-			$sites = array_merge($sites,$remote);
904
+			$sites = array_merge($sites, $remote);
905 905
 		}
906 906
 		return $sites;
907 907
 	}
@@ -914,11 +914,11 @@  discard block
 block discarded – undo
914 914
 	 * @param array &$readonlys
915 915
 	 * @return int
916 916
 	 */
917
-	static function get_remotes($query,&$rows,&$readonlys)
917
+	static function get_remotes($query, &$rows, &$readonlys)
918 918
 	{
919 919
 		admin_cmd::_instanciate_remote();
920 920
 
921
-		return admin_cmd::$remote->get_rows($query,$rows,$readonlys);
921
+		return admin_cmd::$remote->get_rows($query, $rows, $readonlys);
922 922
 	}
923 923
 
924 924
 	/**
@@ -946,7 +946,7 @@  discard block
 block discarded – undo
946 946
 
947 947
 		if ($data['install_id'] && $data['config_passwd'])	// calculate hash
948 948
 		{
949
-			$data['remote_hash'] = self::remote_hash($data['install_id'],$data['config_passwd']);
949
+			$data['remote_hash'] = self::remote_hash($data['install_id'], $data['config_passwd']);
950 950
 		}
951 951
 		elseif (!$data['remote_hash'] && !($data['install_id'] && $data['config_passwd']))
952 952
 		{
@@ -958,12 +958,12 @@  discard block
 block discarded – undo
958 958
 		// check if a unique key constrain would be violated by saving the entry
959 959
 		if (($num = admin_cmd::$remote->not_unique()))
960 960
 		{
961
-			$col = admin_cmd::$remote->table_def['uc'][$num-1];	// $num is 1 based!
962
-			throw new egw_exception_db_not_unique(lang('Value for column %1 is not unique!',$this->table_name.'.'.$col),$num);
961
+			$col = admin_cmd::$remote->table_def['uc'][$num - 1]; // $num is 1 based!
962
+			throw new egw_exception_db_not_unique(lang('Value for column %1 is not unique!', $this->table_name.'.'.$col), $num);
963 963
 		}
964 964
 		if (admin_cmd::$remote->save() != 0)
965 965
 		{
966
-			throw new Api\Db\Exception(lang('Error saving to db:').' '.$this->sql->db->Error.' ('.$this->sql->db->Errno.')',$this->sql->db->Errno);
966
+			throw new Api\Db\Exception(lang('Error saving to db:').' '.$this->sql->db->Error.' ('.$this->sql->db->Errno.')', $this->sql->db->Errno);
967 967
 		}
968 968
 		return admin_cmd::$remote->data['remote_id'];
969 969
 	}
@@ -975,11 +975,11 @@  discard block
 block discarded – undo
975 975
 	 * @param string $config_passwd
976 976
 	 * @return string 32char md5 hash
977 977
 	 */
978
-	static function remote_hash($install_id,$config_passwd)
978
+	static function remote_hash($install_id, $config_passwd)
979 979
 	{
980 980
 		if (empty($config_passwd) || !self::is_md5($install_id))
981 981
 		{
982
-			throw new Api\Exception\WrongParameter(empty($config_passwd)?'Empty Api\Config password':'install_id no md5 hash');
982
+			throw new Api\Exception\WrongParameter(empty($config_passwd) ? 'Empty Api\Config password' : 'install_id no md5 hash');
983 983
 		}
984 984
 		if (!self::is_md5($config_passwd)) $config_passwd = md5($config_passwd);
985 985
 
@@ -1009,7 +1009,7 @@  discard block
 block discarded – undo
1009 1009
 	 */
1010 1010
 	static function is_md5($str)
1011 1011
 	{
1012
-		return preg_match('/^[0-9a-f]{32}$/',$str);
1012
+		return preg_match('/^[0-9a-f]{32}$/', $str);
1013 1013
 	}
1014 1014
 
1015 1015
 	/**
@@ -1026,26 +1026,26 @@  discard block
 block discarded – undo
1026 1026
 	 * @param string $config_passwd of the current domain
1027 1027
 	 * @throws Api\Exception\NoPermission
1028 1028
 	 */
1029
-	function check_remote_access($secret,$config_passwd)
1029
+	function check_remote_access($secret, $config_passwd)
1030 1030
 	{
1031 1031
 		// as a security measure remote administration need to be enabled under Admin > Site configuration
1032
-		list(,$remote_admin_install_id) = explode('-',$this->uid);
1033
-		$allowed_remote_admin_ids = $GLOBALS['egw_info']['server']['allow_remote_admin'] ? explode(',',$GLOBALS['egw_info']['server']['allow_remote_admin']) : array();
1032
+		list(,$remote_admin_install_id) = explode('-', $this->uid);
1033
+		$allowed_remote_admin_ids = $GLOBALS['egw_info']['server']['allow_remote_admin'] ? explode(',', $GLOBALS['egw_info']['server']['allow_remote_admin']) : array();
1034 1034
 
1035 1035
 		// to authenticate with the installation we use a secret, which is a md5 hash build from the uid
1036 1036
 		// of the command (to not allow to send new commands with an earsdroped secret) and the md5 hash
1037 1037
 		// of the md5 hash of the Api\Config password and the install_id (egw_admin_remote.remote_hash)
1038
-		if (is_null($config_passwd) || is_numeric($this->uid) || !in_array($remote_admin_install_id,$allowed_remote_admin_ids) ||
1039
-			$secret != ($md5=md5($this->uid.$this->remote_hash($GLOBALS['egw_info']['server']['install_id'],$config_passwd))))
1038
+		if (is_null($config_passwd) || is_numeric($this->uid) || !in_array($remote_admin_install_id, $allowed_remote_admin_ids) ||
1039
+			$secret != ($md5 = md5($this->uid.$this->remote_hash($GLOBALS['egw_info']['server']['install_id'], $config_passwd))))
1040 1040
 		{
1041 1041
 			//die("secret='$secret' != '$md5', is_null($config_passwd)=".is_null($config_passwd).", uid=$this->uid, remote_install_id=$remote_admin_install_id, allowed: ".implode(', ',$allowed_remote_admin_ids));
1042 1042
 			unset($md5);
1043 1043
 			$msg = lang('Permission denied!');
1044
-			if (!in_array($remote_admin_install_id,$allowed_remote_admin_ids))
1044
+			if (!in_array($remote_admin_install_id, $allowed_remote_admin_ids))
1045 1045
 			{
1046 1046
 				$msg .= "\n".lang('Remote administration need to be enabled in the remote instance under Admin > Site configuration!');
1047 1047
 			}
1048
-			throw new Api\Exception\NoPermission($msg,0);
1048
+			throw new Api\Exception\NoPermission($msg, 0);
1049 1049
 		}
1050 1050
 	}
1051 1051
 
@@ -1055,7 +1055,7 @@  discard block
 block discarded – undo
1055 1055
 	 * @param int $len =16
1056 1056
 	 * @return string
1057 1057
 	 */
1058
-	static function randomstring($len=16)
1058
+	static function randomstring($len = 16)
1059 1059
 	{
1060 1060
 		return Api\Auth::randomstring($len);
1061 1061
 	}
Please login to merge, or discard this patch.
Braces   +53 added lines, -13 removed lines patch added patch discarded remove patch
@@ -183,7 +183,10 @@  discard block
 block discarded – undo
183 183
 				{
184 184
 					$ret = $this->remote_exec($dry_run);
185 185
 				}
186
-				if (is_null($this->status)) $this->status = admin_cmd::successful;
186
+				if (is_null($this->status))
187
+				{
188
+					$this->status = admin_cmd::successful;
189
+				}
187 190
 			}
188 191
 			catch (Exception $e) {
189 192
 				$this->error = $e->getMessage();
@@ -277,7 +280,10 @@  discard block
 block discarded – undo
277 280
 	 */
278 281
 	function delete()
279 282
 	{
280
-		if ($this->status != admin_cmd::scheduled) return false;
283
+		if ($this->status != admin_cmd::scheduled)
284
+		{
285
+			return false;
286
+		}
281 287
 
282 288
 		$this->status = admin_cmd::deleted;
283 289
 
@@ -303,7 +309,10 @@  discard block
 block discarded – undo
303 309
 		{
304 310
 			$this->modified = time();
305 311
 			$this->modifier = $set_modifier ? $GLOBALS['egw_info']['user']['account_id'] : 0;
306
-			if ($set_modifier) $this->modifier_email = admin_cmd::user_email();
312
+			if ($set_modifier)
313
+			{
314
+				$this->modifier_email = admin_cmd::user_email();
315
+			}
307 316
 		}
308 317
 		if (version_compare(PHP_VERSION,'5.1.2','>'))
309 318
 		{
@@ -411,10 +420,13 @@  discard block
 block discarded – undo
411 420
 		}
412 421
 		$cmd = new $class($data);
413 422
 
414
-		if ($cmd instanceof admin_cmd)	// dont allow others classes to be executed that way!
423
+		if ($cmd instanceof admin_cmd)
424
+		{
425
+			// dont allow others classes to be executed that way!
415 426
 		{
416 427
 			return $cmd;
417 428
 		}
429
+		}
418 430
 		throw new Api\Exception\WrongParameter(lang('%1 is no command!',$class),0);
419 431
 	}
420 432
 
@@ -564,7 +576,10 @@  discard block
 block discarded – undo
564 576
 			}
565 577
 		}
566 578
 		unset($vars['data']);
567
-		if ($this->data) $vars = array_merge($this->data,$vars);
579
+		if ($this->data)
580
+		{
581
+			$vars = array_merge($this->data,$vars);
582
+		}
568 583
 
569 584
 		return $vars;
570 585
 	}
@@ -583,10 +598,13 @@  discard block
 block discarded – undo
583 598
 			admin_cmd::_instanciate_acl($this->creator);
584 599
 			// todo: check only if and with $this->creator
585 600
 			if (!admin_cmd::$acl->check('run',1,'admin') &&		// creator is no longer admin
586
-				$extra_acl && $extra_deny && admin_cmd::$acl->check($extra_acl,$extra_deny,'admin'))	// creator is explicitly forbidden to do something
601
+				$extra_acl && $extra_deny && admin_cmd::$acl->check($extra_acl,$extra_deny,'admin'))
602
+			{
603
+				// creator is explicitly forbidden to do something
587 604
 			{
588 605
 				throw new Api\Exception\NoPermission\Admin();
589 606
 			}
607
+			}
590 608
 		}
591 609
 	}
592 610
 
@@ -603,11 +621,14 @@  discard block
 block discarded – undo
603 621
 		{
604 622
 			if (!isset($GLOBALS['egw_info']['apps'][$name]))
605 623
 			{
606
-				foreach($GLOBALS['egw_info']['apps'] as $app => $data)	// check against title and localised name
624
+				foreach($GLOBALS['egw_info']['apps'] as $app => $data)
625
+				{
626
+					// check against title and localised name
607 627
 				{
608 628
 					if (!strcasecmp($name,$data['title']) || !strcasecmp($name,lang($app)))
609 629
 					{
610 630
 						$apps[$key] = $name = $app;
631
+				}
611 632
 						break;
612 633
 					}
613 634
 				}
@@ -642,7 +663,11 @@  discard block
 block discarded – undo
642 663
 		{
643 664
 			throw new Api\Exception\WrongUserinput(lang("Wrong account type: %1 is NO %2 !!!",$account,$allow_only_user?lang('user'):lang('group')),15);
644 665
 		}
645
-		if ($type == 2 && $id > 0) $id = -$id;	// groups use negative id's internally, fix it, if user given the wrong sign
666
+		if ($type == 2 && $id > 0)
667
+		{
668
+			$id = -$id;
669
+		}
670
+		// groups use negative id's internally, fix it, if user given the wrong sign
646 671
 
647 672
 		return $id;
648 673
 	}
@@ -658,7 +683,10 @@  discard block
 block discarded – undo
658 683
 	 */
659 684
 	static function parse_accounts($accounts,$allow_only_user=null)
660 685
 	{
661
-		if (!$accounts) return null;
686
+		if (!$accounts)
687
+		{
688
+			return null;
689
+		}
662 690
 
663 691
 		$ids = array();
664 692
 		foreach(is_array($accounts) ? $accounts : explode(',',$accounts) as $account)
@@ -677,9 +705,12 @@  discard block
 block discarded – undo
677 705
 	 */
678 706
 	static function parse_date($date)
679 707
 	{
680
-		if (!is_numeric($date))	// we allow to input a timestamp
708
+		if (!is_numeric($date))
709
+		{
710
+			// we allow to input a timestamp
681 711
 		{
682 712
 			$datein = $date;
713
+		}
683 714
 			// convert german DD.MM.YYYY format into ISO YYYY-MM-DD format
684 715
 			$date = preg_replace('/^([0-9]{1,2})\.([0-9]{1,2})\.([0-9]{4})$/','\3-\2-\1',$date);
685 716
 
@@ -837,10 +868,13 @@  discard block
 block discarded – undo
837 868
 			return false;		// no schduled command, no need to setup the job
838 869
 		}
839 870
 		$next = $jobs[0];
840
-		if (($time = $next['scheduled']) < time())	// should run immediatly
871
+		if (($time = $next['scheduled']) < time())
872
+		{
873
+			// should run immediatly
841 874
 		{
842 875
 			return admin_cmd::run_queued_jobs();
843 876
 		}
877
+		}
844 878
 		$async = new Api\Asyncservice();
845 879
 
846 880
 		// we cant use this class as callback, as it's abstract and ExecMethod used by the async service instanciated the class!
@@ -944,10 +978,13 @@  discard block
 block discarded – undo
944 978
 	{
945 979
 		admin_cmd::_instanciate_remote();
946 980
 
947
-		if ($data['install_id'] && $data['config_passwd'])	// calculate hash
981
+		if ($data['install_id'] && $data['config_passwd'])
982
+		{
983
+			// calculate hash
948 984
 		{
949 985
 			$data['remote_hash'] = self::remote_hash($data['install_id'],$data['config_passwd']);
950 986
 		}
987
+		}
951 988
 		elseif (!$data['remote_hash'] && !($data['install_id'] && $data['config_passwd']))
952 989
 		{
953 990
 			throw new Api\Exception\WrongUserinput(lang('Either Install ID AND Api\Config password needed OR the remote hash!'));
@@ -981,7 +1018,10 @@  discard block
 block discarded – undo
981 1018
 		{
982 1019
 			throw new Api\Exception\WrongParameter(empty($config_passwd)?'Empty Api\Config password':'install_id no md5 hash');
983 1020
 		}
984
-		if (!self::is_md5($config_passwd)) $config_passwd = md5($config_passwd);
1021
+		if (!self::is_md5($config_passwd))
1022
+		{
1023
+			$config_passwd = md5($config_passwd);
1024
+		}
985 1025
 
986 1026
 		return md5($config_passwd.$install_id);
987 1027
 	}
Please login to merge, or discard this patch.