Completed
Push — master ( 9d054b...106a1b )
by Klaus
23:45 queued 04:19
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.
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.
Braces   +12 added lines, -3 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
@@ -559,7 +565,10 @@  discard block
 block discarded – undo
559 565
 			)
560 566
 		);
561 567
 
562
-		if (empty($config['geolocation_url']))	$ret ['geolocation_url'] = $geoLocation[0]['value'];
568
+		if (empty($config['geolocation_url']))
569
+		{
570
+			$ret ['geolocation_url'] = $geoLocation[0]['value'];
571
+		}
563 572
 		return $ret;
564 573
 	}
565 574
 }
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.
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']:Api\Categories::GLOBAL_APPNAME);
99
-		$session = Api\Cache::getSession(__CLASS__.$appname,'nm');
98
+		$appname = $content['appname'] ? $content['appname'] : ($_GET['appname'] ? $_GET['appname'] : Api\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, $this->appname, $content['id'], $change_color ? null : 'update', $refresh_app);
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)Api\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)Api\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'?Api\Categories::GLOBAL_ACCOUNT:$GLOBALS['egw_info']['user']['account_id'];
502
+				$content['nm']['filter'] = $this->appname == 'admin' ? Api\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
 		}
@@ -615,12 +615,12 @@  discard block
 block discarded – undo
615 615
 		// Category styles
616 616
 		Categories::css($appname);
617 617
 
618
-		$tmpl->exec($this->list_link,$content,$sel_options,$readonlys,array(
618
+		$tmpl->exec($this->list_link, $content, $sel_options, $readonlys, array(
619 619
 			'nm' => $content['nm'],
620 620
 		));
621 621
 	}
622 622
 
623
-	protected function get_actions($appname=Api\Categories::GLOBAL_APPNAME) {
623
+	protected function get_actions($appname = Api\Categories::GLOBAL_APPNAME) {
624 624
 
625 625
 		$actions = array(
626 626
 			'open' => array(        // does edit if allowed, otherwise view
@@ -629,7 +629,7 @@  discard block
 block discarded – undo
629 629
 				'allowOnMultiple' => false,
630 630
 				'url' => 'menuaction='.$this->edit_link.'&cat_id=$id&appname='.$appname,
631 631
 				'popup' => '600x380',
632
-				'group' => $group=1,
632
+				'group' => $group = 1,
633 633
 			),
634 634
 			'add' => array(
635 635
 				'caption' => 'Add',
@@ -664,7 +664,7 @@  discard block
 block discarded – undo
664 664
 			),
665 665
 		);
666 666
 
667
-		if(!$GLOBALS['egw_info']['user']['apps']['admin'])
667
+		if (!$GLOBALS['egw_info']['user']['apps']['admin'])
668 668
 		{
669 669
 			unset($actions['owner']);
670 670
 		}
@@ -690,14 +690,14 @@  discard block
 block discarded – undo
690 690
 		$success = $failed = 0;
691 691
 		if ($use_all)
692 692
 		{
693
-			@set_time_limit(0);                     // switch off the execution time limit, as it's for big selections to small
694
-			$query['num_rows'] = -1;        // all
693
+			@set_time_limit(0); // switch off the execution time limit, as it's for big selections to small
694
+			$query['num_rows'] = -1; // all
695 695
 			$result = $readonlys = array();
696
-			$this->get_rows($query,$result,$readonlys);
696
+			$this->get_rows($query, $result, $readonlys);
697 697
 			$checked = array();
698
-			foreach($result as $key => $info)
698
+			foreach ($result as $key => $info)
699 699
 			{
700
-				if(is_numeric($key))
700
+				if (is_numeric($key))
701 701
 				{
702 702
 					$checked[] = $info['id'];
703 703
 				}
@@ -705,19 +705,19 @@  discard block
 block discarded – undo
705 705
 		}
706 706
 		$owner = $query['col_filter']['owner'] ? $query['col_filter']['owner'] : $query['filter'];
707 707
 		$app = $query['col_filter']['app'] ? $query['col_filter']['app'] : $query['appname'];
708
-		$cats = new Categories($owner,$app);
708
+		$cats = new Categories($owner, $app);
709 709
 
710 710
 		list($action, $settings) = explode('_', $_action, 2);
711 711
 
712
-		switch($action)
712
+		switch ($action)
713 713
 		{
714 714
 			case 'delete':
715 715
 				$action_msg = lang('deleted');
716
-				foreach($checked as $id)
716
+				foreach ($checked as $id)
717 717
 				{
718
-					if($cats->check_perms(Acl::DELETE, $id, (boolean)$GLOBALS['egw_info']['user']['apps']['admin']))
718
+					if ($cats->check_perms(Acl::DELETE, $id, (boolean)$GLOBALS['egw_info']['user']['apps']['admin']))
719 719
 					{
720
-						$cats->delete($id,$settings == 'sub',$settings != 'sub');
720
+						$cats->delete($id, $settings == 'sub', $settings != 'sub');
721 721
 						$success++;
722 722
 					}
723 723
 					else
@@ -731,20 +731,19 @@  discard block
 block discarded – undo
731 731
 				list($add_remove, $ids_csv) = explode('_', $settings, 2);
732 732
 				$ids = explode(',', $ids_csv);
733 733
 				// Adding 'All users' removes all the others
734
-				if($add_remove == 'add' && array_search(Categories::GLOBAL_ACCOUNT,$ids) !== false) $ids = array(Categories::GLOBAL_ACCOUNT);
734
+				if ($add_remove == 'add' && array_search(Categories::GLOBAL_ACCOUNT, $ids) !== false) $ids = array(Categories::GLOBAL_ACCOUNT);
735 735
 
736
-				foreach($checked as $id)
736
+				foreach ($checked as $id)
737 737
 				{
738 738
 					if (!$data = $cats->read($id)) continue;
739
-					$data['owner'] = explode(',',$data['owner']);
740
-					if(array_search(Categories::GLOBAL_ACCOUNT,$data['owner']) !== false || $data['owner'][0] > 0)
739
+					$data['owner'] = explode(',', $data['owner']);
740
+					if (array_search(Categories::GLOBAL_ACCOUNT, $data['owner']) !== false || $data['owner'][0] > 0)
741 741
 					{
742 742
 						$data['owner'] = array();
743 743
 					}
744 744
 					$data['owner'] = $add_remove == 'add' ?
745
-						$ids == array(Categories::GLOBAL_ACCOUNT) ? $ids : array_merge($data['owner'],$ids) :
746
-						array_diff($data['owner'],$ids);
747
-					$data['owner'] = implode(',',array_unique($data['owner']));
745
+						$ids == array(Categories::GLOBAL_ACCOUNT) ? $ids : array_merge($data['owner'], $ids) : array_diff($data['owner'], $ids);
746
+					$data['owner'] = implode(',', array_unique($data['owner']));
748 747
 
749 748
 					if ($cats->edit($data))
750 749
 					{
@@ -775,7 +774,7 @@  discard block
 block discarded – undo
775 774
 				continue;
776 775
 			}
777 776
 			// Skip apps that don't show in the app bar, they [usually] don't have Categories
778
-			if($data['status'] > 1 || in_array($app, array('home','admin','felamimail','sitemgr','sitemgr-link'))) continue;
777
+			if ($data['status'] > 1 || in_array($app, array('home', 'admin', 'felamimail', 'sitemgr', 'sitemgr-link'))) continue;
779 778
 			if ($GLOBALS['egw_info']['user']['apps'][$app])
780 779
 			{
781 780
 				$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, $this->appname, $content['id'], $change_color ? null : 'update', $refresh_app);
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
 		}
@@ -620,7 +657,8 @@  discard block
 block discarded – undo
620 657
 		));
621 658
 	}
622 659
 
623
-	protected function get_actions($appname=Api\Categories::GLOBAL_APPNAME) {
660
+	protected function get_actions($appname=Api\Categories::GLOBAL_APPNAME)
661
+	{
624 662
 
625 663
 		$actions = array(
626 664
 			'open' => array(        // does edit if allowed, otherwise view
@@ -731,11 +769,17 @@  discard block
 block discarded – undo
731 769
 				list($add_remove, $ids_csv) = explode('_', $settings, 2);
732 770
 				$ids = explode(',', $ids_csv);
733 771
 				// Adding 'All users' removes all the others
734
-				if($add_remove == 'add' && array_search(Categories::GLOBAL_ACCOUNT,$ids) !== false) $ids = array(Categories::GLOBAL_ACCOUNT);
772
+				if($add_remove == 'add' && array_search(Categories::GLOBAL_ACCOUNT,$ids) !== false)
773
+				{
774
+					$ids = array(Categories::GLOBAL_ACCOUNT);
775
+				}
735 776
 
736 777
 				foreach($checked as $id)
737 778
 				{
738
-					if (!$data = $cats->read($id)) continue;
779
+					if (!$data = $cats->read($id))
780
+					{
781
+						continue;
782
+					}
739 783
 					$data['owner'] = explode(',',$data['owner']);
740 784
 					if(array_search(Categories::GLOBAL_ACCOUNT,$data['owner']) !== false || $data['owner'][0] > 0)
741 785
 					{
@@ -775,7 +819,10 @@  discard block
 block discarded – undo
775 819
 				continue;
776 820
 			}
777 821
 			// Skip apps that don't show in the app bar, they [usually] don't have Categories
778
-			if($data['status'] > 1 || in_array($app, array('home','admin','felamimail','sitemgr','sitemgr-link'))) continue;
822
+			if($data['status'] > 1 || in_array($app, array('home','admin','felamimail','sitemgr','sitemgr-link')))
823
+			{
824
+				continue;
825
+			}
779 826
 			if ($GLOBALS['egw_info']['user']['apps'][$app])
780 827
 			{
781 828
 				$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.
admin/inc/class.admin_cmd_account_app.inc.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
 	/**
21 21
 	 * Constructor
22 22
 	 *
23
-	 * @param boolean|array $allow true=give rights, false=remove rights, or array with all 3 params
23
+	 * @param boolean $allow true=give rights, false=remove rights, or array with all 3 params
24 24
 	 * @param string|int $account =null account name or id
25 25
 	 * @param array|string $apps =null app-names
26 26
 	 */
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	 * @param string|int $account =null account name or id
25 25
 	 * @param array|string $apps =null app-names
26 26
 	 */
27
-	function __construct($allow,$account=null,$apps=null)
27
+	function __construct($allow, $account = null, $apps = null)
28 28
 	{
29 29
 		if (!is_array($allow))
30 30
 		{
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 		}
37 37
 		if (isset($allow['apps']) && !is_array($allow['apps']))
38 38
 		{
39
-			$allow['apps'] = explode(',',$allow['apps']);
39
+			$allow['apps'] = explode(',', $allow['apps']);
40 40
 		}
41 41
 		admin_cmd::__construct($allow);
42 42
 	}
@@ -50,11 +50,11 @@  discard block
 block discarded – undo
50 50
 	 * @throws Api\Exception\WrongUserinput(lang("Unknown account: %1 !!!",$this->account),15);
51 51
 	 * @throws Api\Exception\WrongUserinput(lang("Application '%1' not found (maybe not installed or misspelled)!",$name),8);
52 52
 	 */
53
-	protected function exec($check_only=false)
53
+	protected function exec($check_only = false)
54 54
 	{
55 55
 		$account_id = admin_cmd::parse_account($this->account);
56 56
 		// check creator is still admin and not explicitly forbidden to edit accounts/groups
57
-		if ($this->creator) $this->_check_admin($account_id > 0 ? 'account_access' : 'group_access',16);
57
+		if ($this->creator) $this->_check_admin($account_id > 0 ? 'account_access' : 'group_access', 16);
58 58
 
59 59
 		$apps = admin_cmd::parse_apps($this->apps);
60 60
 
@@ -62,15 +62,15 @@  discard block
 block discarded – undo
62 62
 
63 63
 		//echo "account=$this->account, account_id=$account_id, apps: ".implode(', ',$apps)."\n";
64 64
 		admin_cmd::_instanciate_acl($account_id);
65
-		foreach($apps as $app)
65
+		foreach ($apps as $app)
66 66
 		{
67 67
 			if ($this->allow)
68 68
 			{
69
-				admin_cmd::$acl->add_repository($app,'run',$account_id,1);
69
+				admin_cmd::$acl->add_repository($app, 'run', $account_id, 1);
70 70
 			}
71 71
 			else
72 72
 			{
73
-				admin_cmd::$acl->delete_repository($app,'run',$account_id);
73
+				admin_cmd::$acl->delete_repository($app, 'run', $account_id);
74 74
 			}
75 75
 		}
76 76
 		return lang('Applications run rights updated.');
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 	 */
84 84
 	function __tostring()
85 85
 	{
86
-		return lang('%1 rights for %2 and applications %3',$this->allow ? lang('Grant') : lang('Remove'),
87
-			admin_cmd::display_account($this->account),implode(', ',$this->apps));
86
+		return lang('%1 rights for %2 and applications %3', $this->allow ? lang('Grant') : lang('Remove'),
87
+			admin_cmd::display_account($this->account), implode(', ', $this->apps));
88 88
 	}
89 89
 }
Please login to merge, or discard this patch.
Braces   +8 added lines, -2 removed lines patch added patch discarded remove patch
@@ -54,11 +54,17 @@
 block discarded – undo
54 54
 	{
55 55
 		$account_id = admin_cmd::parse_account($this->account);
56 56
 		// check creator is still admin and not explicitly forbidden to edit accounts/groups
57
-		if ($this->creator) $this->_check_admin($account_id > 0 ? 'account_access' : 'group_access',16);
57
+		if ($this->creator)
58
+		{
59
+			$this->_check_admin($account_id > 0 ? 'account_access' : 'group_access',16);
60
+		}
58 61
 
59 62
 		$apps = admin_cmd::parse_apps($this->apps);
60 63
 
61
-		if ($check_only) return true;
64
+		if ($check_only)
65
+		{
66
+			return true;
67
+		}
62 68
 
63 69
 		//echo "account=$this->account, account_id=$account_id, apps: ".implode(', ',$apps)."\n";
64 70
 		admin_cmd::_instanciate_acl($account_id);
Please login to merge, or discard this patch.