Completed
Pull Request — master (#43)
by Marcel
27:43
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,25 +58,25 @@  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($_POST['g-recaptcha-response'])) $recaptcha = sitemgr_module::verify_recaptcha ($_POST['g-recaptcha-response']);
72
+			if (isset($_POST['g-recaptcha-response'])) $recaptcha = sitemgr_module::verify_recaptcha($_POST['g-recaptcha-response']);
73 73
 			$captcha = (isset($content['captcha_result']) && $content['captcha'] != $content['captcha_result']) || ($recaptcha && $recaptcha->success == false);
74 74
 			if ($captcha || // no correct captcha OR
75
-				(time() - $content['start_time'] < 10 &&				// bot indicator (less then 10 sec to fill out the form and
75
+				(time() - $content['start_time'] < 10 && // bot indicator (less then 10 sec to fill out the form and
76 76
 				!$GLOBALS['egw_info']['etemplate']['java_script']))	// javascript disabled)
77 77
 			{
78 78
 				$submitted = "truebutfalse";
79
-				$tpl->set_validation_error('captcha',lang('Wrong - try again ...'));
79
+				$tpl->set_validation_error('captcha', lang('Wrong - try again ...'));
80 80
 			}
81 81
 			elseif ($content['submitit'])
82 82
 			{
@@ -84,11 +84,11 @@  discard block
 block discarded – undo
84 84
 				$contact = new Api\Contacts();
85 85
 				if ($content['owner'])	// save the contact in the addressbook
86 86
 				{
87
-					$content['private'] = 0;	// in case default_private is set
87
+					$content['private'] = 0; // in case default_private is set
88 88
 					if (($id = $contact->save($content)))
89 89
 					{
90 90
 						// check for fileuploads and attach the found files
91
-						foreach($content as $name => $value)
91
+						foreach ($content as $name => $value)
92 92
 						{
93 93
 							if (is_array($value) && isset($value['tmp_name']) && is_readable($value['tmp_name']))
94 94
 							{
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 								// edit rights for the addressbook used to store the new entry,
98 98
 								// which is clearly not wanted securitywise
99 99
 								Vfs::$is_root = true;
100
-								Link::link('addressbook',$id,Link::VFS_APPNAME,$value,$name);
100
+								Link::link('addressbook', $id, Link::VFS_APPNAME, $value, $name);
101 101
 								Vfs::$is_root = false;
102 102
 							}
103 103
 						}
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 					{
117 117
 						$tracking = new Api\Contacts\Tracking($contact);
118 118
 					}
119
-					if ($tracking->do_notifications($contact->data2db($content),null))
119
+					if ($tracking->do_notifications($contact->data2db($content), null))
120 120
 					{
121 121
 						return '<p align="center">'.$content['msg'].'</p>';
122 122
 					}
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 			$preserv['email_copytoreceiver'] = $copytoreceiver;
140 140
 			#if (!$fields) $fields = array('org_name','n_fn','email','tel_work','url','note','captcha');
141 141
 			$custom = 1;
142
-			foreach($fields as $name)
142
+			foreach ($fields as $name)
143 143
 			{
144 144
 				if ($name[0] == '#')	// custom field
145 145
 				{
@@ -150,10 +150,10 @@  discard block
 block discarded – undo
150 150
 					}
151 151
 					$content['show']['custom'.$custom] = true;
152 152
 					$content['customfield'][$custom] = $name;
153
-					$content['customlabel'][$custom] = $contact->customfields[substr($name,1)]['label'];
153
+					$content['customlabel'][$custom] = $contact->customfields[substr($name, 1)]['label'];
154 154
 					++$custom;
155 155
 				}
156
-				elseif($name == 'adr_one_locality')
156
+				elseif ($name == 'adr_one_locality')
157 157
 				{
158 158
 					if (!($content['show'][$name] = $GLOBALS['egw_info']['user']['preferences']['addressbook']['addr_format']))
159 159
 					{
@@ -174,18 +174,18 @@  discard block
 block discarded – undo
174 174
 			unset($content['submitit']);
175 175
 			$custom = 1;
176 176
 			// fieldnames are "defined" by the commit attempt, that way, we do not have to remember them
177
-			foreach($content as $name => $value) {
178
-				$preserv[$name]=$value;
177
+			foreach ($content as $name => $value) {
178
+				$preserv[$name] = $value;
179 179
 				if ($name[0] == '#')     // custom field
180 180
 				{
181 181
 					static $contact;
182 182
 					if (is_null($contact)) $contact = new Api\Contacts();
183 183
 					$content['show']['custom'.$custom] = true;
184 184
 					$content['customfield'][$custom] = $name;
185
-					$content['customlabel'][$custom] = $contact->customfields[substr($name,1)]['label'];
185
+					$content['customlabel'][$custom] = $contact->customfields[substr($name, 1)]['label'];
186 186
 					++$custom;
187 187
 				}
188
-				elseif($name == 'adr_one_locality')
188
+				elseif ($name == 'adr_one_locality')
189 189
 				{
190 190
 					if (!($content['show'][$name] = $GLOBALS['egw_info']['user']['preferences']['addressbook']['addr_format']))
191 191
 					{
@@ -207,16 +207,16 @@  discard block
 block discarded – undo
207 207
 		if (!sitemgr_module::get_recaptcha())
208 208
 		{
209 209
 			// a simple calculation captcha
210
-			$num1 = rand(1,99);
211
-			$num2 = rand(1,99);
210
+			$num1 = rand(1, 99);
211
+			$num2 = rand(1, 99);
212 212
 			if ($num2 > $num1)	// keep the result positive
213 213
 			{
214 214
 				$n = $num1; $num1 = $num2; $num2 = $n;
215 215
 			}
216
-			if (in_array('captcha',$fields))
216
+			if (in_array('captcha', $fields))
217 217
 			{
218
-				$content['captcha_task'] = sprintf('%d - %d =',$num1,$num2);
219
-				$preserv['captcha_result'] = $num1-$num2;
218
+				$content['captcha_task'] = sprintf('%d - %d =', $num1, $num2);
219
+				$preserv['captcha_result'] = $num1 - $num2;
220 220
 			}
221 221
 		}
222 222
 		else
@@ -232,6 +232,6 @@  discard block
 block discarded – undo
232 232
 			$content = array_merge($_GET, (array)$content);
233 233
 		}
234 234
 
235
-		return $tpl->exec($this->callback,$content,$sel_options,array(),$preserv);
235
+		return $tpl->exec($this->callback, $content, $sel_options, array(), $preserv);
236 236
 	}
237 237
 }
Please login to merge, or discard this patch.
Braces   +50 added lines, -14 removed lines patch added patch discarded remove patch
@@ -61,30 +61,46 @@  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
-			if (isset($_POST['g-recaptcha-response'])) $recaptcha = sitemgr_module::verify_recaptcha ($_POST['g-recaptcha-response']);
78
+			if (isset($_POST['g-recaptcha-response']))
79
+			{
80
+				$recaptcha = sitemgr_module::verify_recaptcha ($_POST['g-recaptcha-response']);
81
+			}
73 82
 			$captcha = (isset($content['captcha_result']) && $content['captcha'] != $content['captcha_result']) || ($recaptcha && $recaptcha->success == false);
74 83
 			if ($captcha || // no correct captcha OR
75 84
 				(time() - $content['start_time'] < 10 &&				// bot indicator (less then 10 sec to fill out the form and
76
-				!$GLOBALS['egw_info']['etemplate']['java_script']))	// javascript disabled)
85
+				!$GLOBALS['egw_info']['etemplate']['java_script']))
86
+			{
87
+				// javascript disabled)
77 88
 			{
78 89
 				$submitted = "truebutfalse";
90
+			}
79 91
 				$tpl->set_validation_error('captcha',lang('Wrong - try again ...'));
80 92
 			}
81 93
 			elseif ($content['submitit'])
82 94
 			{
83 95
 				$submitted = true;
84 96
 				$contact = new Api\Contacts();
85
-				if ($content['owner'])	// save the contact in the addressbook
97
+				if ($content['owner'])
98
+				{
99
+					// save the contact in the addressbook
86 100
 				{
87
-					$content['private'] = 0;	// in case default_private is set
101
+					$content['private'] = 0;
102
+				}
103
+				// in case default_private is set
88 104
 					if (($id = $contact->save($content)))
89 105
 					{
90 106
 						// check for fileuploads and attach the found files
@@ -141,9 +157,12 @@  discard block
 block discarded – undo
141 157
 			$custom = 1;
142 158
 			foreach($fields as $name)
143 159
 			{
144
-				if ($name[0] == '#')	// custom field
160
+				if ($name[0] == '#')
161
+				{
162
+					// custom field
145 163
 				{
146 164
 					static $contact;
165
+				}
147 166
 					if (is_null($contact))
148 167
 					{
149 168
 						$contact = new Api\Contacts();
@@ -174,12 +193,19 @@  discard block
 block discarded – undo
174 193
 			unset($content['submitit']);
175 194
 			$custom = 1;
176 195
 			// fieldnames are "defined" by the commit attempt, that way, we do not have to remember them
177
-			foreach($content as $name => $value) {
196
+			foreach($content as $name => $value)
197
+			{
178 198
 				$preserv[$name]=$value;
179
-				if ($name[0] == '#')     // custom field
199
+				if ($name[0] == '#')
200
+				{
201
+					// custom field
180 202
 				{
181 203
 					static $contact;
182
-					if (is_null($contact)) $contact = new Api\Contacts();
204
+				}
205
+					if (is_null($contact))
206
+					{
207
+						$contact = new Api\Contacts();
208
+					}
183 209
 					$content['show']['custom'.$custom] = true;
184 210
 					$content['customfield'][$custom] = $name;
185 211
 					$content['customlabel'][$custom] = $contact->customfields[substr($name,1)]['label'];
@@ -202,16 +228,26 @@  discard block
 block discarded – undo
202 228
 		}
203 229
 		$content['addr_format'] = $GLOBALS['egw_info']['user']['preferences']['addressbook']['addr_format'];
204 230
 
205
-		if ($addressbook) $preserv['owner'] = $addressbook;
206
-		if ($msg) $preserv['msg'] = $msg;
231
+		if ($addressbook)
232
+		{
233
+			$preserv['owner'] = $addressbook;
234
+		}
235
+		if ($msg)
236
+		{
237
+			$preserv['msg'] = $msg;
238
+		}
207 239
 		if (!sitemgr_module::get_recaptcha())
208 240
 		{
209 241
 			// a simple calculation captcha
210 242
 			$num1 = rand(1,99);
211 243
 			$num2 = rand(1,99);
212
-			if ($num2 > $num1)	// keep the result positive
244
+			if ($num2 > $num1)
245
+			{
246
+				// keep the result positive
213 247
 			{
214
-				$n = $num1; $num1 = $num2; $num2 = $n;
248
+				$n = $num1;
249
+			}
250
+			$num1 = $num2; $num2 = $n;
215 251
 			}
216 252
 			if (in_array('captcha',$fields))
217 253
 			{
Please login to merge, or discard this patch.
addressbook/inc/class.addressbook_export_contacts_csv.inc.php 5 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@
 block discarded – undo
36 36
 	/**
37 37
 	 * Exports records as defined in $_definition
38 38
 	 *
39
-	 * @param egw_record $_definition
39
+	 * @param importexport_definition $_definition
40 40
 	 */
41 41
 	public function export( $_stream, importexport_definition $_definition) {
42 42
 
Please login to merge, or discard this patch.
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -365,10 +365,10 @@  discard block
 block discarded – undo
365 365
 	}
366 366
 
367 367
 	/**
368
-	* Convert some internal data to something with more meaning
369
-	*
370
-	* Dates, times, user IDs, category IDs
371
-	*/
368
+	 * Convert some internal data to something with more meaning
369
+	 *
370
+	 * Dates, times, user IDs, category IDs
371
+	 */
372 372
 	public static function convert(addressbook_egw_record &$record, $options) {
373 373
 
374 374
 		if ($record->tel_prefer) {
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
 	 * Adjust automatically generated filter fields
437 437
 	 */
438 438
 	public function get_filter_fields(Array &$filters)
439
-    {
439
+	{
440 440
 		unset($filters['last_event']);
441 441
 		unset($filters['next_event']);
442 442
 		foreach($filters as $field_name => &$settings)
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -435,7 +435,7 @@
 block discarded – undo
435 435
 	/**
436 436
 	 * Adjust automatically generated filter fields
437 437
 	 */
438
-	public function get_filter_fields(Array &$filters)
438
+	public function get_filter_fields(array &$filters)
439 439
     {
440 440
 		unset($filters['last_event']);
441 441
 		unset($filters['next_event']);
Please login to merge, or discard this patch.
Braces   +164 added lines, -67 removed lines patch added patch discarded remove patch
@@ -38,7 +38,8 @@  discard block
 block discarded – undo
38 38
 	 *
39 39
 	 * @param egw_record $_definition
40 40
 	 */
41
-	public function export( $_stream, importexport_definition $_definition) {
41
+	public function export( $_stream, importexport_definition $_definition)
42
+	{
42 43
 
43 44
 		$options = $_definition->plugin_options;
44 45
 		$this->export_object = $export_object = new importexport_export_csv($_stream, (array)$options);
@@ -48,8 +49,13 @@  discard block
 block discarded – undo
48 49
 		// Addressbook defines its own export imits
49 50
 		$limit_exception = Api\Storage\Merge::is_export_limit_excepted();
50 51
 		$export_limit = Api\Storage\Merge::getExportLimit($app='addressbook');
51
-		if (!$limit_exception) $export_object->export_limit = $export_limit; // we may not need that after all
52
-		if($export_limit == 'no' && !$limit_exception) {
52
+		if (!$limit_exception)
53
+		{
54
+			$export_object->export_limit = $export_limit;
55
+		}
56
+		// we may not need that after all
57
+		if($export_limit == 'no' && !$limit_exception)
58
+		{
53 59
 			return;
54 60
 		}
55 61
 
@@ -57,18 +63,24 @@  discard block
 block discarded – undo
57 63
 		$old_app = $GLOBALS['egw_info']['flags']['currentapp'];
58 64
 		$GLOBALS['egw_info']['flags']['currentapp'] = 'addressbook';
59 65
 
60
-		if ($options['selection'] == 'search') {
66
+		if ($options['selection'] == 'search')
67
+		{
61 68
 			// uicontacts selection with checkbox 'use_all'
62 69
 			$query = Api\Cache::getSession('addressbook', 'index');
63 70
 			$query['num_rows'] = -1;	// all
64 71
 			$query['csv_export'] = true;	// so get_rows method _can_ produce different content or not store state in the session
65 72
 			$query['order'] = 'contact_id';
66
-			if(!array_key_exists('filter',$query)) $query['filter'] = $GLOBALS['egw_info']['user']['account_id'];
73
+			if(!array_key_exists('filter',$query))
74
+			{
75
+				$query['filter'] = $GLOBALS['egw_info']['user']['account_id'];
76
+			}
67 77
 			$readonlys = null;
68 78
 			$this->ui->get_rows($query,$selection,$readonlys, true);	// only return the ids
69 79
 		}
70
-		elseif ( $options['selection'] == 'all' ) {
71
-			if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] === '1') {
80
+		elseif ( $options['selection'] == 'all' )
81
+		{
82
+			if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] === '1')
83
+			{
72 84
 				$col_filter['account_id'] = null;
73 85
 			}
74 86
 			$selection = ExecMethod2('addressbook.addressbook_bo.search', array(), true, '', '','',false,'AND',false,$col_filter);
@@ -107,11 +119,20 @@  discard block
 block discarded – undo
107 119
 					$field = 'contact_'.$field;
108 120
 				}
109 121
 				$query['col_filter'][$field] = $value;
110
-				if(!is_array($value) || (!$value['from'] && !$value['to'])) continue;
122
+				if(!is_array($value) || (!$value['from'] && !$value['to']))
123
+				{
124
+					continue;
125
+				}
111 126
 
112 127
 				// Ranges are inclusive, so should be provided that way (from 2 to 10 includes 2 and 10)
113
-				if($value['from']) $query['col_filter'][] = "$field >= " . (int)$value['from'];
114
-				if($value['to']) $query['col_filter'][] = "$field <= " . (int)$value['to'];
128
+				if($value['from'])
129
+				{
130
+					$query['col_filter'][] = "$field >= " . (int)$value['from'];
131
+				}
132
+				if($value['to'])
133
+				{
134
+					$query['col_filter'][] = "$field <= " . (int)$value['to'];
135
+				}
115 136
 				unset($query['col_filter'][$field]);
116 137
 			}
117 138
 			$selection = ExecMethod2('addressbook.addressbook_bo.search', array(), true, '', '','',false,'AND',false,$query['col_filter']);
@@ -126,29 +147,36 @@  discard block
 block discarded – undo
126 147
 		}
127 148
 		$GLOBALS['egw_info']['flags']['currentapp'] = $old_app;
128 149
 
129
-		if(Api\Storage\Merge::hasExportLimit($export_limit) && !$limit_exception) {
150
+		if(Api\Storage\Merge::hasExportLimit($export_limit) && !$limit_exception)
151
+		{
130 152
 			$selection = array_slice($selection, 0, $export_limit);
131 153
 		}
132 154
 
133
-		if($options['explode_multiselects']) {
155
+		if($options['explode_multiselects'])
156
+		{
134 157
 			$customfields = Api\Storage\Customfields::get('addressbook');
135 158
 			$additional_fields = array();
136 159
 			$cat_obj = new Api\Categories('', 'addressbook');
137
-			foreach($options['explode_multiselects'] as $field => $explode) {
138
-				switch($explode['explode']) {
160
+			foreach($options['explode_multiselects'] as $field => $explode)
161
+			{
162
+				switch($explode['explode'])
163
+				{
139 164
 					case self::MAIN_CATS:
140 165
 						$cats = $cat_obj->return_array('mains', 0, false,'','ASC','',true);
141
-						foreach($cats as $settings) {
166
+						foreach($cats as $settings)
167
+						{
142 168
 							$additional_fields[$field][$settings['id']] = array(
143 169
 								'count' => 0,
144 170
 								'label' => $settings['name'],
145 171
 								'subs' => array(),
146 172
 							);
147 173
 							$subs = $cat_obj->return_sorted_array(0, False, '', 'ASC', 'cat_name', True, $settings['id']);
148
-							foreach($subs as $sub) {
174
+							foreach($subs as $sub)
175
+							{
149 176
 								$name = $sub['name'];
150 177
 								$path = $sub;
151
-								while($path['parent'] != $settings['id']) {
178
+								while($path['parent'] != $settings['id'])
179
+								{
152 180
 									$path = $cat_obj->read($path['parent']);
153 181
 									$name = $path['name'] . '/' . $name;
154 182
 								}
@@ -158,10 +186,12 @@  discard block
 block discarded – undo
158 186
 						break;
159 187
 					case self::EACH_CAT:
160 188
 						$cats = $cat_obj->return_array('all', 0, false,'','ASC','',true);
161
-						foreach($cats as $settings) {
189
+						foreach($cats as $settings)
190
+						{
162 191
 							$name = $settings['name'];
163 192
 							$path = $settings;
164
-							while($path['level'] != 0) {
193
+							while($path['level'] != 0)
194
+							{
165 195
 								$path = $cat_obj->read($path['parent']);
166 196
 								$name = $path['name'] . '/' . $name;
167 197
 							}
@@ -174,7 +204,8 @@  discard block
 block discarded – undo
174 204
 					case self::EXPLODE:
175 205
 						// Only works for custom fields
176 206
 						$index = substr($field, 1);
177
-						foreach($customfields[$index]['values'] as $key => $value) {
207
+						foreach($customfields[$index]['values'] as $key => $value)
208
+						{
178 209
 							$additional_fields[$field][$key] = array(
179 210
 								'count' => 0,
180 211
 								'label' => $customfields[$index]['label'] . ': ' . $value,
@@ -185,30 +216,47 @@  discard block
 block discarded – undo
185 216
 			}
186 217
 
187 218
 			// Check records to see if additional fields are actually used
188
-			foreach ($selection as $_contact) {
189
-				if(is_array($_contact) && array_key_exists('photo', $_contact)) {
219
+			foreach ($selection as $_contact)
220
+			{
221
+				if(is_array($_contact) && array_key_exists('photo', $_contact))
222
+				{
190 223
 					unset($_contact['photo']);
191 224
 				}
192
-				if(is_array($_contact) && count($_contact) == 1 && $_contact['id']) {
225
+				if(is_array($_contact) && count($_contact) == 1 && $_contact['id'])
226
+				{
193 227
 					$_contact = $_contact['id'];
194 228
 				}
195
-				if(is_array($_contact) && $_contact['id']) {
229
+				if(is_array($_contact) && $_contact['id'])
230
+				{
196 231
 					$contact = new addressbook_egw_record();
197 232
 					$contact->set_record($_contact);
198
-				} else {
233
+				}
234
+				else
235
+				{
199 236
 					$contact = new addressbook_egw_record($_contact);
200 237
 				}
201
-				foreach($additional_fields as $field => &$values) {
202
-					if(!$contact->$field) continue;
203
-					foreach($values as $value => &$settings) {
204
-						if(!is_array($contact->$field)) {
238
+				foreach($additional_fields as $field => &$values)
239
+				{
240
+					if(!$contact->$field)
241
+					{
242
+						continue;
243
+					}
244
+					foreach($values as $value => &$settings)
245
+					{
246
+						if(!is_array($contact->$field))
247
+						{
205 248
 							$contact->$field = explode(',', $contact->$field);
206 249
 						}
207
-						if(is_array($contact->$field) && in_array($value, $contact->$field)) {
250
+						if(is_array($contact->$field) && in_array($value, $contact->$field))
251
+						{
208 252
 							$settings['count']++;
209
-						} elseif($contact->$field == $value) {
253
+						}
254
+						elseif($contact->$field == $value)
255
+						{
210 256
 							$settings['count']++;
211
-						} elseif($options['explode_multiselects'][$field]['explode'] == self::MAIN_CATS && array_intersect($contact->$field, array_keys($settings['subs']))) {
257
+						}
258
+						elseif($options['explode_multiselects'][$field]['explode'] == self::MAIN_CATS && array_intersect($contact->$field, array_keys($settings['subs'])))
259
+						{
212 260
 							$settings['count']++;
213 261
 						}
214 262
 					}
@@ -220,21 +268,27 @@  discard block
 block discarded – undo
220 268
 			unset($settings);
221 269
 
222 270
 			// Add additional columns
223
-			foreach($additional_fields as $field => $additional_values) {
271
+			foreach($additional_fields as $field => $additional_values)
272
+			{
224 273
 				// Remove original
225 274
 				unset($options['mapping'][$field]);
226 275
 				// Add exploded
227 276
 				$field_count = 0;
228
-				foreach($additional_values as $value => $settings) {
229
-					if($settings['count'] > 0) {
277
+				foreach($additional_values as $value => $settings)
278
+				{
279
+					if($settings['count'] > 0)
280
+					{
230 281
 						$field_count += $settings['count'];
231 282
 						$options['mapping'][$field.'-'.$value] = $settings['label'];
232 283
 					}
233 284
 				}
234
-				if($field_count > 0) {
285
+				if($field_count > 0)
286
+				{
235 287
 					// Set some options for converting
236 288
 					$options['explode_multiselects'][$field]['values'] = $additional_values;
237
-				} else {
289
+				}
290
+				else
291
+				{
238 292
 					// Don't need this anymore
239 293
 					unset($options['explode_multiselects'][$field]);
240 294
 				}
@@ -263,17 +317,23 @@  discard block
 block discarded – undo
263 317
 
264 318
 		// $options['selection'] is array of identifiers as this plugin doesn't
265 319
 		// support other selectors atm.
266
-		foreach ($selection as $_contact) {
267
-			if(is_array($_contact) && array_key_exists('photo', $_contact)) {
320
+		foreach ($selection as $_contact)
321
+		{
322
+			if(is_array($_contact) && array_key_exists('photo', $_contact))
323
+			{
268 324
 				unset($_contact['photo']);
269 325
 			}
270
-			if(is_array($_contact) && count($_contact) == 1 && $_contact['id']) {
326
+			if(is_array($_contact) && count($_contact) == 1 && $_contact['id'])
327
+			{
271 328
 				$_contact = $_contact['id'];
272 329
 			}
273
-			if(is_array($_contact) && $_contact['id']) {
330
+			if(is_array($_contact) && $_contact['id'])
331
+			{
274 332
 				$contact = new addressbook_egw_record();
275 333
 				$contact->set_record($_contact);
276
-			} else {
334
+			}
335
+			else
336
+			{
277 337
 				$contact = new addressbook_egw_record($_contact);
278 338
 			}
279 339
 
@@ -286,12 +346,19 @@  discard block
 block discarded – undo
286 346
 			}
287 347
 			// Some conversion
288 348
 			$this->convert($contact, $options);
289
-			if($options['convert']) {
349
+			if($options['convert'])
350
+			{
290 351
 				importexport_export_csv::convert($contact, addressbook_egw_record::$types, 'addressbook',$this->selects);
291
-			} else {
352
+			}
353
+			else
354
+			{
292 355
 				// Implode arrays, so they don't say 'Array'
293
-				foreach($contact->get_record_array() as $key => $value) {
294
-					if(is_array($value)) $contact->$key = implode(',', $value);
356
+				foreach($contact->get_record_array() as $key => $value)
357
+				{
358
+					if(is_array($value))
359
+					{
360
+						$contact->$key = implode(',', $value);
361
+					}
295 362
 				}
296 363
 			}
297 364
 
@@ -306,7 +373,8 @@  discard block
 block discarded – undo
306 373
 	 *
307 374
 	 * @return string name
308 375
 	 */
309
-	public static function get_name() {
376
+	public static function get_name()
377
+	{
310 378
 		return lang('Addressbook CSV export');
311 379
 	}
312 380
 
@@ -315,7 +383,8 @@  discard block
 block discarded – undo
315 383
 	 *
316 384
 	 * @return string descriprion
317 385
 	 */
318
-	public static function get_description() {
386
+	public static function get_description()
387
+	{
319 388
 		return lang("Exports contacts from your Addressbook into a CSV File.");
320 389
 	}
321 390
 
@@ -324,11 +393,13 @@  discard block
 block discarded – undo
324 393
 	 *
325 394
 	 * @return string suffix
326 395
 	 */
327
-	public static function get_filesuffix() {
396
+	public static function get_filesuffix()
397
+	{
328 398
 		return 'csv';
329 399
 	}
330 400
 
331
-	public static function get_mimetype() {
401
+	public static function get_mimetype()
402
+	{
332 403
 		return 'text/csv';
333 404
 	}
334 405
 
@@ -351,14 +422,16 @@  discard block
 block discarded – undo
351 422
 	 *
352 423
 	 * @return string html
353 424
 	 */
354
-	public function get_options_etpl() {
425
+	public function get_options_etpl()
426
+	{
355 427
 	}
356 428
 
357 429
 	/**
358 430
 	 * returns slectors of this plugin via xajax
359 431
 	 *
360 432
 	 */
361
-	public function get_selectors_etpl() {
433
+	public function get_selectors_etpl()
434
+	{
362 435
 		return array(
363 436
 			'name'		=> 'importexport.export_csv_selectors',
364 437
 		);
@@ -369,9 +442,11 @@  discard block
 block discarded – undo
369 442
 	*
370 443
 	* Dates, times, user IDs, category IDs
371 444
 	*/
372
-	public static function convert(addressbook_egw_record &$record, $options) {
445
+	public static function convert(addressbook_egw_record &$record, $options)
446
+	{
373 447
 
374
-		if ($record->tel_prefer) {
448
+		if ($record->tel_prefer)
449
+		{
375 450
 			$field = $record->tel_prefer;
376 451
 			$record->tel_prefer = $record->$field;
377 452
 		}
@@ -380,33 +455,52 @@  discard block
 block discarded – undo
380 455
 		{
381 456
 			return;
382 457
 		}
383
-		foreach((array)$options['explode_multiselects'] as $field => $explode_settings) {
384
-			if(!is_array($record->$field)) $record->$field = explode(',', $record->$field);
385
-			foreach((array)$explode_settings['values'] as $value => $settings) {
458
+		foreach((array)$options['explode_multiselects'] as $field => $explode_settings)
459
+		{
460
+			if(!is_array($record->$field))
461
+			{
462
+				$record->$field = explode(',', $record->$field);
463
+			}
464
+			foreach((array)$explode_settings['values'] as $value => $settings)
465
+			{
386 466
 				$field_name = "$field-$value";
387 467
 				$record->$field_name = array();
388
-				if(is_array($record->$field) && in_array($value, $record->$field) || $record->$field == $value) {
389
-					if($explode_settings['explode'] != self::MAIN_CATS) {
468
+				if(is_array($record->$field) && in_array($value, $record->$field) || $record->$field == $value)
469
+				{
470
+					if($explode_settings['explode'] != self::MAIN_CATS)
471
+					{
390 472
 						$record->$field_name = $options['convert'] ? lang('Yes') : true;
391
-					} elseif($options['convert']) {
473
+					}
474
+					elseif($options['convert'])
475
+					{
392 476
 						// 3 part assign due to magic get method
393 477
 						$record_value = $record->$field_name;
394 478
 						$record_value[] = $settings['label'];
395 479
 						$record->$field_name = $record_value;
396
-					} else {
480
+					}
481
+					else
482
+					{
397 483
 						$record->$field_name = $value;
398 484
 					}
399 485
 				}
400
-				if($explode_settings['explode'] == self::MAIN_CATS && count(array_intersect($record->$field, array_keys($settings['subs'])))) {
486
+				if($explode_settings['explode'] == self::MAIN_CATS && count(array_intersect($record->$field, array_keys($settings['subs']))))
487
+				{
401 488
 					// 3 part assign due to magic get method
402 489
 					$record_value = $record->$field_name;
403
-					if(!is_array($record_value)) $record_value = array($record_value);
404
-					foreach(array_intersect($record->$field, array_keys($settings['subs'])) as $sub_id) {
490
+					if(!is_array($record_value))
491
+					{
492
+						$record_value = array($record_value);
493
+					}
494
+					foreach(array_intersect($record->$field, array_keys($settings['subs'])) as $sub_id)
495
+					{
405 496
 						$record_value[] = $options['convert'] ? $settings['subs'][$sub_id] : $sub_id;
406 497
 					}
407 498
 					$record->$field_name = $record_value;
408 499
 				}
409
-				if(is_array($record->$field_name)) $record->$field_name = implode(($options['convert'] ? ', ' : ','), $record->$field_name);
500
+				if(is_array($record->$field_name))
501
+				{
502
+					$record->$field_name = implode(($options['convert'] ? ', ' : ','), $record->$field_name);
503
+				}
410 504
 			}
411 505
 		}
412 506
 	}
@@ -436,12 +530,15 @@  discard block
 block discarded – undo
436 530
 	 * Adjust automatically generated filter fields
437 531
 	 */
438 532
 	public function get_filter_fields(Array &$filters)
439
-    {
533
+	{
440 534
 		unset($filters['last_event']);
441 535
 		unset($filters['next_event']);
442 536
 		foreach($filters as $field_name => &$settings)
443 537
 		{
444
-			if($this->selects[$field_name]) $settings['values'] = $this->selects[$field_name];
538
+			if($this->selects[$field_name])
539
+			{
540
+				$settings['values'] = $this->selects[$field_name];
541
+			}
445 542
 		}
446 543
 		$filters['owner'] = array(
447 544
 			'name'		=> 'owner',
Please login to merge, or discard this patch.
Spacing   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -23,13 +23,13 @@  discard block
 block discarded – undo
23 23
 	 * Constants used for exploding categories & multi-selectboxes into seperate fields
24 24
 	 */
25 25
 	const NO_EXPLODE = False;
26
-	const MAIN_CATS = 'main_cats';	// Only the top-level categories get their own field
27
-	const EACH_CAT = 'each_cat';	// Every category gets its own field
28
-	const EXPLODE = 'explode';	// For [custom] multi-selects, each option gets its own field
26
+	const MAIN_CATS = 'main_cats'; // Only the top-level categories get their own field
27
+	const EACH_CAT = 'each_cat'; // Every category gets its own field
28
+	const EXPLODE = 'explode'; // For [custom] multi-selects, each option gets its own field
29 29
 
30 30
 	public function __construct()
31 31
 	{
32
-		$this->ui= new addressbook_ui();
32
+		$this->ui = new addressbook_ui();
33 33
 		$this->get_selects();
34 34
 	}
35 35
 
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 	 *
39 39
 	 * @param egw_record $_definition
40 40
 	 */
41
-	public function export( $_stream, importexport_definition $_definition) {
41
+	public function export($_stream, importexport_definition $_definition) {
42 42
 
43 43
 		$options = $_definition->plugin_options;
44 44
 		$this->export_object = $export_object = new importexport_export_csv($_stream, (array)$options);
@@ -47,9 +47,9 @@  discard block
 block discarded – undo
47 47
 
48 48
 		// Addressbook defines its own export imits
49 49
 		$limit_exception = Api\Storage\Merge::is_export_limit_excepted();
50
-		$export_limit = Api\Storage\Merge::getExportLimit($app='addressbook');
50
+		$export_limit = Api\Storage\Merge::getExportLimit($app = 'addressbook');
51 51
 		if (!$limit_exception) $export_object->export_limit = $export_limit; // we may not need that after all
52
-		if($export_limit == 'no' && !$limit_exception) {
52
+		if ($export_limit == 'no' && !$limit_exception) {
53 53
 			return;
54 54
 		}
55 55
 
@@ -60,18 +60,18 @@  discard block
 block discarded – undo
60 60
 		if ($options['selection'] == 'search') {
61 61
 			// uicontacts selection with checkbox 'use_all'
62 62
 			$query = Api\Cache::getSession('addressbook', 'index');
63
-			$query['num_rows'] = -1;	// all
64
-			$query['csv_export'] = true;	// so get_rows method _can_ produce different content or not store state in the session
63
+			$query['num_rows'] = -1; // all
64
+			$query['csv_export'] = true; // so get_rows method _can_ produce different content or not store state in the session
65 65
 			$query['order'] = 'contact_id';
66
-			if(!array_key_exists('filter',$query)) $query['filter'] = $GLOBALS['egw_info']['user']['account_id'];
66
+			if (!array_key_exists('filter', $query)) $query['filter'] = $GLOBALS['egw_info']['user']['account_id'];
67 67
 			$readonlys = null;
68
-			$this->ui->get_rows($query,$selection,$readonlys, true);	// only return the ids
68
+			$this->ui->get_rows($query, $selection, $readonlys, true); // only return the ids
69 69
 		}
70
-		elseif ( $options['selection'] == 'all' ) {
70
+		elseif ($options['selection'] == 'all') {
71 71
 			if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] === '1') {
72 72
 				$col_filter['account_id'] = null;
73 73
 			}
74
-			$selection = ExecMethod2('addressbook.addressbook_bo.search', array(), true, '', '','',false,'AND',false,$col_filter);
74
+			$selection = ExecMethod2('addressbook.addressbook_bo.search', array(), true, '', '', '', false, 'AND', false, $col_filter);
75 75
 			//$uicontacts->get_rows($query,$selection,$readonlys,true);
76 76
 		}
77 77
 		elseif ($options['selection'] == 'filter')
@@ -80,90 +80,90 @@  discard block
 block discarded – undo
80 80
 			$query = array();
81 81
 
82 82
 			// Handle ranges
83
-			foreach($filter as $field => $value)
83
+			foreach ($filter as $field => $value)
84 84
 			{
85
-				if($field == 'cat_id')
85
+				if ($field == 'cat_id')
86 86
 				{
87
-					$query['col_filter'][$field] = implode(',',$value);
87
+					$query['col_filter'][$field] = implode(',', $value);
88 88
 					continue;
89 89
 				}
90 90
 
91 91
 				// Birthdays in addressbook are formatted Y-m-d
92
-				if($field == 'bday')
92
+				if ($field == 'bday')
93 93
 				{
94
-					if($value['from'])
94
+					if ($value['from'])
95 95
 					{
96
-						$query['col_filter'][] = "contact_bday >= " . $GLOBALS['egw']->db->quote(date('Y-m-d', (int)$value['from']));
96
+						$query['col_filter'][] = "contact_bday >= ".$GLOBALS['egw']->db->quote(date('Y-m-d', (int)$value['from']));
97 97
 					}
98
-					if($value['to'])
98
+					if ($value['to'])
99 99
 					{
100
-						$query['col_filter'][] = "contact_bday <= " . $GLOBALS['egw']->db->quote(date('Y-m-d', (int)$value['to']));
100
+						$query['col_filter'][] = "contact_bday <= ".$GLOBALS['egw']->db->quote(date('Y-m-d', (int)$value['to']));
101 101
 					}
102 102
 					continue;
103 103
 				}
104 104
 				// Custom fields & listed exceptions are not filtered with contact_ prefix
105
-				if(strpos($field, '#') !== 0 && !in_array($field, array('tid','owner')))
105
+				if (strpos($field, '#') !== 0 && !in_array($field, array('tid', 'owner')))
106 106
 				{
107 107
 					$field = 'contact_'.$field;
108 108
 				}
109 109
 				$query['col_filter'][$field] = $value;
110
-				if(!is_array($value) || (!$value['from'] && !$value['to'])) continue;
110
+				if (!is_array($value) || (!$value['from'] && !$value['to'])) continue;
111 111
 
112 112
 				// Ranges are inclusive, so should be provided that way (from 2 to 10 includes 2 and 10)
113
-				if($value['from']) $query['col_filter'][] = "$field >= " . (int)$value['from'];
114
-				if($value['to']) $query['col_filter'][] = "$field <= " . (int)$value['to'];
113
+				if ($value['from']) $query['col_filter'][] = "$field >= ".(int)$value['from'];
114
+				if ($value['to']) $query['col_filter'][] = "$field <= ".(int)$value['to'];
115 115
 				unset($query['col_filter'][$field]);
116 116
 			}
117
-			$selection = ExecMethod2('addressbook.addressbook_bo.search', array(), true, '', '','',false,'AND',false,$query['col_filter']);
117
+			$selection = ExecMethod2('addressbook.addressbook_bo.search', array(), true, '', '', '', false, 'AND', false, $query['col_filter']);
118 118
 		}
119 119
 		else
120 120
 		{
121
-			$selection = explode(',',$options['selection']);
121
+			$selection = explode(',', $options['selection']);
122 122
 		}
123
-		if(!is_array($selection))
123
+		if (!is_array($selection))
124 124
 		{
125 125
 			$selection = array();
126 126
 		}
127 127
 		$GLOBALS['egw_info']['flags']['currentapp'] = $old_app;
128 128
 
129
-		if(Api\Storage\Merge::hasExportLimit($export_limit) && !$limit_exception) {
129
+		if (Api\Storage\Merge::hasExportLimit($export_limit) && !$limit_exception) {
130 130
 			$selection = array_slice($selection, 0, $export_limit);
131 131
 		}
132 132
 
133
-		if($options['explode_multiselects']) {
133
+		if ($options['explode_multiselects']) {
134 134
 			$customfields = Api\Storage\Customfields::get('addressbook');
135 135
 			$additional_fields = array();
136 136
 			$cat_obj = new Api\Categories('', 'addressbook');
137
-			foreach($options['explode_multiselects'] as $field => $explode) {
138
-				switch($explode['explode']) {
137
+			foreach ($options['explode_multiselects'] as $field => $explode) {
138
+				switch ($explode['explode']) {
139 139
 					case self::MAIN_CATS:
140
-						$cats = $cat_obj->return_array('mains', 0, false,'','ASC','',true);
141
-						foreach($cats as $settings) {
140
+						$cats = $cat_obj->return_array('mains', 0, false, '', 'ASC', '', true);
141
+						foreach ($cats as $settings) {
142 142
 							$additional_fields[$field][$settings['id']] = array(
143 143
 								'count' => 0,
144 144
 								'label' => $settings['name'],
145 145
 								'subs' => array(),
146 146
 							);
147 147
 							$subs = $cat_obj->return_sorted_array(0, False, '', 'ASC', 'cat_name', True, $settings['id']);
148
-							foreach($subs as $sub) {
148
+							foreach ($subs as $sub) {
149 149
 								$name = $sub['name'];
150 150
 								$path = $sub;
151
-								while($path['parent'] != $settings['id']) {
151
+								while ($path['parent'] != $settings['id']) {
152 152
 									$path = $cat_obj->read($path['parent']);
153
-									$name = $path['name'] . '/' . $name;
153
+									$name = $path['name'].'/'.$name;
154 154
 								}
155 155
 								$additional_fields[$field][$settings['id']]['subs'][$sub['id']] = $name;
156 156
 							}
157 157
 						}
158 158
 						break;
159 159
 					case self::EACH_CAT:
160
-						$cats = $cat_obj->return_array('all', 0, false,'','ASC','',true);
161
-						foreach($cats as $settings) {
160
+						$cats = $cat_obj->return_array('all', 0, false, '', 'ASC', '', true);
161
+						foreach ($cats as $settings) {
162 162
 							$name = $settings['name'];
163 163
 							$path = $settings;
164
-							while($path['level'] != 0) {
164
+							while ($path['level'] != 0) {
165 165
 								$path = $cat_obj->read($path['parent']);
166
-								$name = $path['name'] . '/' . $name;
166
+								$name = $path['name'].'/'.$name;
167 167
 							}
168 168
 							$additional_fields[$field][$settings['id']] = array(
169 169
 								'count' => 0,
@@ -174,10 +174,10 @@  discard block
 block discarded – undo
174 174
 					case self::EXPLODE:
175 175
 						// Only works for custom fields
176 176
 						$index = substr($field, 1);
177
-						foreach($customfields[$index]['values'] as $key => $value) {
177
+						foreach ($customfields[$index]['values'] as $key => $value) {
178 178
 							$additional_fields[$field][$key] = array(
179 179
 								'count' => 0,
180
-								'label' => $customfields[$index]['label'] . ': ' . $value,
180
+								'label' => $customfields[$index]['label'].': '.$value,
181 181
 							);
182 182
 						}
183 183
 						break;
@@ -186,29 +186,29 @@  discard block
 block discarded – undo
186 186
 
187 187
 			// Check records to see if additional fields are actually used
188 188
 			foreach ($selection as $_contact) {
189
-				if(is_array($_contact) && array_key_exists('photo', $_contact)) {
189
+				if (is_array($_contact) && array_key_exists('photo', $_contact)) {
190 190
 					unset($_contact['photo']);
191 191
 				}
192
-				if(is_array($_contact) && count($_contact) == 1 && $_contact['id']) {
192
+				if (is_array($_contact) && count($_contact) == 1 && $_contact['id']) {
193 193
 					$_contact = $_contact['id'];
194 194
 				}
195
-				if(is_array($_contact) && $_contact['id']) {
195
+				if (is_array($_contact) && $_contact['id']) {
196 196
 					$contact = new addressbook_egw_record();
197 197
 					$contact->set_record($_contact);
198 198
 				} else {
199 199
 					$contact = new addressbook_egw_record($_contact);
200 200
 				}
201
-				foreach($additional_fields as $field => &$values) {
202
-					if(!$contact->$field) continue;
203
-					foreach($values as $value => &$settings) {
204
-						if(!is_array($contact->$field)) {
201
+				foreach ($additional_fields as $field => &$values) {
202
+					if (!$contact->$field) continue;
203
+					foreach ($values as $value => &$settings) {
204
+						if (!is_array($contact->$field)) {
205 205
 							$contact->$field = explode(',', $contact->$field);
206 206
 						}
207
-						if(is_array($contact->$field) && in_array($value, $contact->$field)) {
207
+						if (is_array($contact->$field) && in_array($value, $contact->$field)) {
208 208
 							$settings['count']++;
209
-						} elseif($contact->$field == $value) {
209
+						} elseif ($contact->$field == $value) {
210 210
 							$settings['count']++;
211
-						} elseif($options['explode_multiselects'][$field]['explode'] == self::MAIN_CATS && array_intersect($contact->$field, array_keys($settings['subs']))) {
211
+						} elseif ($options['explode_multiselects'][$field]['explode'] == self::MAIN_CATS && array_intersect($contact->$field, array_keys($settings['subs']))) {
212 212
 							$settings['count']++;
213 213
 						}
214 214
 					}
@@ -220,18 +220,18 @@  discard block
 block discarded – undo
220 220
 			unset($settings);
221 221
 
222 222
 			// Add additional columns
223
-			foreach($additional_fields as $field => $additional_values) {
223
+			foreach ($additional_fields as $field => $additional_values) {
224 224
 				// Remove original
225 225
 				unset($options['mapping'][$field]);
226 226
 				// Add exploded
227 227
 				$field_count = 0;
228
-				foreach($additional_values as $value => $settings) {
229
-					if($settings['count'] > 0) {
228
+				foreach ($additional_values as $value => $settings) {
229
+					if ($settings['count'] > 0) {
230 230
 						$field_count += $settings['count'];
231 231
 						$options['mapping'][$field.'-'.$value] = $settings['label'];
232 232
 					}
233 233
 				}
234
-				if($field_count > 0) {
234
+				if ($field_count > 0) {
235 235
 					// Set some options for converting
236 236
 					$options['explode_multiselects'][$field]['values'] = $additional_values;
237 237
 				} else {
@@ -244,12 +244,12 @@  discard block
 block discarded – undo
244 244
 		$export_object->set_mapping($options['mapping']);
245 245
 
246 246
 		// Add in last/next event, if needed
247
-		if($options['mapping']['last_date'] || $options['mapping']['next_date'])
247
+		if ($options['mapping']['last_date'] || $options['mapping']['next_date'])
248 248
 		{
249 249
 			$contact_ids = array();
250
-			foreach($selection as $_contact)
250
+			foreach ($selection as $_contact)
251 251
 			{
252
-				if(is_array($_contact) && $_contact['id'])
252
+				if (is_array($_contact) && $_contact['id'])
253 253
 				{
254 254
 					$contact_ids[] = $_contact['account_id'] ? $_contact['account_id'] : 'c'.$_contact['id'];
255 255
 				}
@@ -264,20 +264,20 @@  discard block
 block discarded – undo
264 264
 		// $options['selection'] is array of identifiers as this plugin doesn't
265 265
 		// support other selectors atm.
266 266
 		foreach ($selection as $_contact) {
267
-			if(is_array($_contact) && array_key_exists('photo', $_contact)) {
267
+			if (is_array($_contact) && array_key_exists('photo', $_contact)) {
268 268
 				unset($_contact['photo']);
269 269
 			}
270
-			if(is_array($_contact) && count($_contact) == 1 && $_contact['id']) {
270
+			if (is_array($_contact) && count($_contact) == 1 && $_contact['id']) {
271 271
 				$_contact = $_contact['id'];
272 272
 			}
273
-			if(is_array($_contact) && $_contact['id']) {
273
+			if (is_array($_contact) && $_contact['id']) {
274 274
 				$contact = new addressbook_egw_record();
275 275
 				$contact->set_record($_contact);
276 276
 			} else {
277 277
 				$contact = new addressbook_egw_record($_contact);
278 278
 			}
279 279
 
280
-			if($events && $events[$contact->id])
280
+			if ($events && $events[$contact->id])
281 281
 			{
282 282
 				// NB: last_date and next_date are used instead of last_event & next_event
283 283
 				// to avoid automatic conversion - we want to export link title, not date-time
@@ -286,12 +286,12 @@  discard block
 block discarded – undo
286 286
 			}
287 287
 			// Some conversion
288 288
 			$this->convert($contact, $options);
289
-			if($options['convert']) {
290
-				importexport_export_csv::convert($contact, addressbook_egw_record::$types, 'addressbook',$this->selects);
289
+			if ($options['convert']) {
290
+				importexport_export_csv::convert($contact, addressbook_egw_record::$types, 'addressbook', $this->selects);
291 291
 			} else {
292 292
 				// Implode arrays, so they don't say 'Array'
293
-				foreach($contact->get_record_array() as $key => $value) {
294
-					if(is_array($value)) $contact->$key = implode(',', $value);
293
+				foreach ($contact->get_record_array() as $key => $value) {
294
+					if (is_array($value)) $contact->$key = implode(',', $value);
295 295
 				}
296 296
 			}
297 297
 
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
 	 */
339 339
 	public function get_filename()
340 340
 	{
341
-		if(is_object($this->export_object) && $this->export_object->get_num_of_records() == 1)
341
+		if (is_object($this->export_object) && $this->export_object->get_num_of_records() == 1)
342 342
 		{
343 343
 			return $this->export_object->record->get_title();
344 344
 		}
@@ -376,19 +376,19 @@  discard block
 block discarded – undo
376 376
 			$record->tel_prefer = $record->$field;
377 377
 		}
378 378
 
379
-		if(!is_array($options['explode_multiselects']))
379
+		if (!is_array($options['explode_multiselects']))
380 380
 		{
381 381
 			return;
382 382
 		}
383
-		foreach((array)$options['explode_multiselects'] as $field => $explode_settings) {
384
-			if(!is_array($record->$field)) $record->$field = explode(',', $record->$field);
385
-			foreach((array)$explode_settings['values'] as $value => $settings) {
383
+		foreach ((array)$options['explode_multiselects'] as $field => $explode_settings) {
384
+			if (!is_array($record->$field)) $record->$field = explode(',', $record->$field);
385
+			foreach ((array)$explode_settings['values'] as $value => $settings) {
386 386
 				$field_name = "$field-$value";
387 387
 				$record->$field_name = array();
388
-				if(is_array($record->$field) && in_array($value, $record->$field) || $record->$field == $value) {
389
-					if($explode_settings['explode'] != self::MAIN_CATS) {
388
+				if (is_array($record->$field) && in_array($value, $record->$field) || $record->$field == $value) {
389
+					if ($explode_settings['explode'] != self::MAIN_CATS) {
390 390
 						$record->$field_name = $options['convert'] ? lang('Yes') : true;
391
-					} elseif($options['convert']) {
391
+					} elseif ($options['convert']) {
392 392
 						// 3 part assign due to magic get method
393 393
 						$record_value = $record->$field_name;
394 394
 						$record_value[] = $settings['label'];
@@ -397,16 +397,16 @@  discard block
 block discarded – undo
397 397
 						$record->$field_name = $value;
398 398
 					}
399 399
 				}
400
-				if($explode_settings['explode'] == self::MAIN_CATS && count(array_intersect($record->$field, array_keys($settings['subs'])))) {
400
+				if ($explode_settings['explode'] == self::MAIN_CATS && count(array_intersect($record->$field, array_keys($settings['subs'])))) {
401 401
 					// 3 part assign due to magic get method
402 402
 					$record_value = $record->$field_name;
403
-					if(!is_array($record_value)) $record_value = array($record_value);
404
-					foreach(array_intersect($record->$field, array_keys($settings['subs'])) as $sub_id) {
403
+					if (!is_array($record_value)) $record_value = array($record_value);
404
+					foreach (array_intersect($record->$field, array_keys($settings['subs'])) as $sub_id) {
405 405
 						$record_value[] = $options['convert'] ? $settings['subs'][$sub_id] : $sub_id;
406 406
 					}
407 407
 					$record->$field_name = $record_value;
408 408
 				}
409
-				if(is_array($record->$field_name)) $record->$field_name = implode(($options['convert'] ? ', ' : ','), $record->$field_name);
409
+				if (is_array($record->$field_name)) $record->$field_name = implode(($options['convert'] ? ', ' : ','), $record->$field_name);
410 410
 			}
411 411
 		}
412 412
 	}
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
 		$this->selects = array(
418 418
 			'tid' => array('n' => 'Contact')
419 419
 		);
420
-		foreach($this->ui->content_types as $tid => $data)
420
+		foreach ($this->ui->content_types as $tid => $data)
421 421
 		{
422 422
 			$this->selects['tid'][$tid] = $data['name'];
423 423
 		}
@@ -439,9 +439,9 @@  discard block
 block discarded – undo
439 439
     {
440 440
 		unset($filters['last_event']);
441 441
 		unset($filters['next_event']);
442
-		foreach($filters as $field_name => &$settings)
442
+		foreach ($filters as $field_name => &$settings)
443 443
 		{
444
-			if($this->selects[$field_name]) $settings['values'] = $this->selects[$field_name];
444
+			if ($this->selects[$field_name]) $settings['values'] = $this->selects[$field_name];
445 445
 		}
446 446
 		$filters['owner'] = array(
447 447
 			'name'		=> 'owner',
Please login to merge, or discard this patch.
addressbook/inc/class.addressbook_favorite_portlet.inc.php 3 patches
Doc Comments   -2 removed lines patch added patch discarded remove patch
@@ -79,8 +79,6 @@
 block discarded – undo
79 79
 	 * Here we need to handle any incoming data.  Setup is done in the constructor,
80 80
 	 * output is handled by parent.
81 81
 	 *
82
-	 * @param type $id
83
-	 * @param Etemplate $etemplate
84 82
 	 */
85 83
 	public static function process($values = array())
86 84
 	{
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@
 block discarded – undo
25 25
 	 * Construct the portlet
26 26
 	 *
27 27
 	 */
28
-	public function __construct(Array &$context = array(), &$need_reload = false)
28
+	public function __construct(array &$context = array(), &$need_reload = false)
29 29
 	{
30 30
 		$context['appname'] = 'addressbook';
31 31
 
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -30,13 +30,13 @@  discard block
 block discarded – undo
30 30
 		$context['appname'] = 'addressbook';
31 31
 
32 32
 		// Let parent handle the basic stuff
33
-		parent::__construct($context,$need_reload);
33
+		parent::__construct($context, $need_reload);
34 34
 
35 35
 		$ui = new addressbook_ui();
36 36
 
37 37
 		$this->context['template'] = 'addressbook.index.rows';
38 38
 		$this->context['sel_options'] = array();
39
-		foreach($ui->content_types as $tid => $data)
39
+		foreach ($ui->content_types as $tid => $data)
40 40
 		{
41 41
 			$this->context['sel_options']['tid'][$tid] = $data['name'];
42 42
 		}
@@ -52,8 +52,8 @@  discard block
 block discarded – undo
52 52
 	public function exec($id = null, Etemplate &$etemplate = null)
53 53
 	{
54 54
 		$ui = new addressbook_ui();
55
-		$this->context['sel_options']['filter'] = $this->context['sel_options']['owner'] = $ui->get_addressbooks(Acl::READ,lang('All'));
56
-		$this->context['sel_options']['filter2'] = $ui->get_lists(Acl::READ,array('' => lang('none')));
55
+		$this->context['sel_options']['filter'] = $this->context['sel_options']['owner'] = $ui->get_addressbooks(Acl::READ, lang('All'));
56
+		$this->context['sel_options']['filter2'] = $ui->get_lists(Acl::READ, array('' => lang('none')));
57 57
 		$this->nm_settings['actions'] = $ui->get_actions($this->nm_settings['col_filter']['tid'], $this->nm_settings['org_view']);
58 58
 
59 59
 		parent::exec($id, $etemplate);
@@ -96,27 +96,27 @@  discard block
 block discarded – undo
96 96
 			{
97 97
 				// Some processing to add values in for links and cats
98 98
 				$success = $failed = $action_msg = $msg = null;
99
-				if ($ui->action($values['nm']['action'],$values['nm']['selected'],$values['nm']['select_all'],
100
-						$success,$failed,$action_msg,$values['do_email'] ? 'email' : 'index',$msg,$values['nm']['checkboxes']))
99
+				if ($ui->action($values['nm']['action'], $values['nm']['selected'], $values['nm']['select_all'],
100
+						$success, $failed, $action_msg, $values['do_email'] ? 'email' : 'index', $msg, $values['nm']['checkboxes']))
101 101
 				{
102
-					$msg .= lang('%1 contact(s) %2',$success,$action_msg);
103
-					Api\Json\Response::get()->apply('egw.message',array($msg,'success'));
104
-					foreach($values['nm']['selected'] as &$id)
102
+					$msg .= lang('%1 contact(s) %2', $success, $action_msg);
103
+					Api\Json\Response::get()->apply('egw.message', array($msg, 'success'));
104
+					foreach ($values['nm']['selected'] as &$id)
105 105
 					{
106 106
 						$id = 'addressbook::'.$id;
107 107
 					}
108 108
 					// Directly request an update - this will get addressbook tab too
109
-					Api\Json\Response::get()->apply('egw.dataRefreshUIDs',array($values['nm']['selected']));
109
+					Api\Json\Response::get()->apply('egw.dataRefreshUIDs', array($values['nm']['selected']));
110 110
 				}
111
-				elseif(is_null($msg))
111
+				elseif (is_null($msg))
112 112
 				{
113
-					$msg .= lang('%1 entries %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed);
114
-					Api\Json\Response::get()->apply('egw.message',array($msg,'error'));
113
+					$msg .= lang('%1 entries %2, %3 failed because of insufficent rights !!!', $success, $action_msg, $failed);
114
+					Api\Json\Response::get()->apply('egw.message', array($msg, 'error'));
115 115
 				}
116
-				elseif($msg)
116
+				elseif ($msg)
117 117
 				{
118
-					$msg .= "\n".lang('%1 entries %2, %3 failed.',$success,$action_msg,$failed);
119
-					Api\Json\Response::get()->apply('egw.message',array($msg,'error'));
118
+					$msg .= "\n".lang('%1 entries %2, %3 failed.', $success, $action_msg, $failed);
119
+					Api\Json\Response::get()->apply('egw.message', array($msg, 'error'));
120 120
 				}
121 121
 				unset($values['nm']['action']);
122 122
 				unset($values['nm']['select_all']);
Please login to merge, or discard this patch.
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.
Braces   +167 added lines, -41 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'] === '1') $filter['account_id'] = null;
129
+		if ($GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] === '1')
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));
@@ -292,18 +317,27 @@  discard block
 block discarded – undo
292 317
 				if ($sync_collection_report)
293 318
 				{
294 319
 					list(,$sync_token) = explode('>', $filter[0]);
295
-					if ((int)$sync_token) $where[] = 'list_modified>'.$GLOBALS['egw']->db->from_unixtime((int)$sync_token);
320
+					if ((int)$sync_token)
321
+					{
322
+						$where[] = 'list_modified>'.$GLOBALS['egw']->db->from_unixtime((int)$sync_token);
323
+					}
296 324
 				}
297
-				if (isset($filter[self::$path_attr]))	// multiget report?
325
+				if (isset($filter[self::$path_attr]))
326
+				{
327
+					// multiget report?
298 328
 				{
299 329
 					$where['list_'.self::$path_attr] = $filter[self::$path_attr];
300 330
 				}
331
+				}
301 332
 				//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!
333
+				if (($lists = $this->bo->read_lists($where,'contact_uid',$where['list_owner'])))
334
+				{
335
+					// limit to contacts in same AB!
303 336
 				{
304 337
 					foreach($lists as $list)
305 338
 					{
306 339
 						$list[self::$path_attr] = $list['list_carddav_name'];
340
+				}
307 341
 						$etag = $list['list_id'].':'.$list['list_etag'];
308 342
 						// for all-in-one addressbook, add selected ABs to etag
309 343
 						if (isset($filter['owner']) && is_array($filter['owner']))
@@ -347,7 +381,10 @@  discard block
 block discarded – undo
347 381
 			}
348 382
 		}
349 383
 
350
-		if ($this->debug) error_log(__METHOD__."($path,".array2string($filter).','.array2string($start).") took ".(microtime(true) - $starttime).' to return '.count($files).' items');
384
+		if ($this->debug)
385
+		{
386
+			error_log(__METHOD__."($path,".array2string($filter).','.array2string($start).") took ".(microtime(true) - $starttime).' to return '.count($files).' items');
387
+		}
351 388
 		return $files;
352 389
 	}
353 390
 
@@ -387,7 +424,11 @@  discard block
 block discarded – undo
387 424
 			$matches = $prop_test = $column = null;
388 425
 			foreach($options['filters'] as $n => $filter)
389 426
 			{
390
-				if (!is_int($n)) continue;	// eg. attributes of filter xml element
427
+				if (!is_int($n))
428
+				{
429
+					continue;
430
+				}
431
+				// eg. attributes of filter xml element
391 432
 
392 433
 				switch((string)$filter['name'])
393 434
 				{
@@ -395,19 +436,28 @@  discard block
 block discarded – undo
395 436
 						$this->caldav->log(__METHOD__."(...) param-filter='{$filter['attrs']['name']}' not (yet) implemented!");
396 437
 						break;
397 438
 					case 'prop-filter':	// can be multiple prop-filter, see example
398
-						if ($matches) $prop_filters[] = implode($prop_test=='allof'?' AND ':' OR ',$matches);
439
+						if ($matches)
440
+						{
441
+							$prop_filters[] = implode($prop_test=='allof'?' AND ':' OR ',$matches);
442
+						}
399 443
 						$matches = array();
400 444
 						$prop_filter = strtoupper($filter['attrs']['name']);
401 445
 						$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'");
446
+						if ($this->debug > 1)
447
+						{
448
+							error_log(__METHOD__."(...) prop-filter='$prop_filter', test='$prop_test'");
449
+						}
403 450
 						break;
404 451
 					case 'is-not-defined':
405 452
 						$matches[] = '('.$column."='' OR ".$column.' IS NULL)';
406 453
 						break;
407 454
 					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
455
+						if (!isset($this->filter_prop2cal[$prop_filter]))
456
+						{
457
+							// eg. not existing NICKNAME in EGroupware
409 458
 						{
410 459
 							if ($this->debug || $prop_filter != 'NICKNAME') error_log(__METHOD__."(...) text-match: $prop_filter {$filter['attrs']['match-type']} '{$filter['data']}' unknown property '$prop_filter' --> ignored");
460
+						}
411 461
 							$column = false;	// to ignore following data too
412 462
 						}
413 463
 						else
@@ -420,8 +470,14 @@  discard block
 block discarded – undo
420 470
 									break;
421 471
 							}
422 472
 							$column = $this->filter_prop2cal[strtoupper($prop_filter)];
423
-							if (strpos($column, '_') === false) $column = 'contact_'.$column;
424
-							if (!isset($filters['order'])) $filters['order'] = $column;
473
+							if (strpos($column, '_') === false)
474
+							{
475
+								$column = 'contact_'.$column;
476
+							}
477
+							if (!isset($filters['order']))
478
+							{
479
+								$filters['order'] = $column;
480
+							}
425 481
 							$match_type = $filter['attrs']['match-type'];
426 482
 							$negate_condition = isset($filter['attrs']['negate-condition']) && $filter['attrs']['negate-condition'] == 'yes';
427 483
 						}
@@ -429,9 +485,12 @@  discard block
 block discarded – undo
429 485
 					case '':	// data of text-match element
430 486
 						if (isset($filter['data']) && isset($column))
431 487
 						{
432
-							if ($column)	// false for properties not known to EGroupware
488
+							if ($column)
489
+							{
490
+								// false for properties not known to EGroupware
433 491
 							{
434 492
 								$value = str_replace(array('%', '_'), array('\\%', '\\_'), $filter['data']);
493
+							}
435 494
 								switch($match_type)
436 495
 								{
437 496
 									case 'equals':
@@ -450,7 +509,10 @@  discard block
 block discarded – undo
450 509
 								}
451 510
 								$matches[] = ($negate_condition ? 'NOT ' : '').$sql_filter;
452 511
 
453
-								if ($this->debug > 1) error_log(__METHOD__."(...) text-match: $prop_filter $match_type' '{$filter['data']}'");
512
+								if ($this->debug > 1)
513
+								{
514
+									error_log(__METHOD__."(...) text-match: $prop_filter $match_type' '{$filter['data']}'");
515
+								}
454 516
 							}
455 517
 							unset($column);
456 518
 							break;
@@ -461,11 +523,17 @@  discard block
 block discarded – undo
461 523
 						break;
462 524
 				}
463 525
 			}
464
-			if ($matches) $prop_filters[] = implode($prop_test=='allof'?' AND ':' OR ',$matches);
526
+			if ($matches)
527
+			{
528
+				$prop_filters[] = implode($prop_test=='allof'?' AND ':' OR ',$matches);
529
+			}
465 530
 			if ($prop_filters)
466 531
 			{
467 532
 				$filters[] = $filter = '(('.implode($filter_test=='allof'?') AND (':') OR (', $prop_filters).'))';
468
-				if ($this->debug) error_log(__METHOD__."(path=$options[path], ...) sql-filter: $filter");
533
+				if ($this->debug)
534
+				{
535
+					error_log(__METHOD__."(path=$options[path], ...) sql-filter: $filter");
536
+				}
469 537
 			}
470 538
 		}
471 539
 		// parse limit from $options['other']
@@ -522,8 +590,14 @@  discard block
 block discarded – undo
522 590
 					}
523 591
 				}
524 592
 			}
525
-			if ($ids) $filters[self::$path_attr] = $ids;
526
-			if ($this->debug) error_log(__METHOD__."(...) addressbook-multiget: ids=".implode(',',$ids));
593
+			if ($ids)
594
+			{
595
+				$filters[self::$path_attr] = $ids;
596
+			}
597
+			if ($this->debug)
598
+			{
599
+				error_log(__METHOD__."(...) addressbook-multiget: ids=".implode(',',$ids));
600
+			}
527 601
 		}
528 602
 		elseif ($id)
529 603
 		{
@@ -570,12 +644,18 @@  discard block
 block discarded – undo
570 644
 	 */
571 645
 	function put(&$options,$id,$user=null,$prefix=null)
572 646
 	{
573
-		if ($this->debug) error_log(__METHOD__.'('.array2string($options).",$id,$user)");
647
+		if ($this->debug)
648
+		{
649
+			error_log(__METHOD__.'('.array2string($options).",$id,$user)");
650
+		}
574 651
 
575 652
 		$oldContact = $this->_common_get_put_delete('PUT',$options,$id);
576 653
 		if (!is_null($oldContact) && !is_array($oldContact))
577 654
 		{
578
-			if ($this->debug) error_log(__METHOD__."(,'$id', $user, '$prefix') returning ".array2string($oldContact));
655
+			if ($this->debug)
656
+			{
657
+				error_log(__METHOD__."(,'$id', $user, '$prefix') returning ".array2string($oldContact));
658
+			}
579 659
 			return $oldContact;
580 660
 		}
581 661
 
@@ -666,15 +746,24 @@  discard block
 block discarded – undo
666 746
 			// done here again, as _common_get_put_delete knows nothing about default addressbooks...
667 747
 			if (!($this->bo->grants[$contact['owner']] & Acl::ADD))
668 748
 			{
669
-				if ($this->debug) error_log(__METHOD__."(,'$id', $user, '$prefix') returning '403 Forbidden'");
749
+				if ($this->debug)
750
+				{
751
+					error_log(__METHOD__."(,'$id', $user, '$prefix') returning '403 Forbidden'");
752
+				}
670 753
 				return '403 Forbidden';
671 754
 			}
672 755
 		}
673
-		if ($this->http_if_match) $contact['etag'] = self::etag2value($this->http_if_match);
756
+		if ($this->http_if_match)
757
+		{
758
+			$contact['etag'] = self::etag2value($this->http_if_match);
759
+		}
674 760
 
675 761
 		if (!($save_ok = $is_group ? $this->save_group($contact, $oldContact) : $this->bo->save($contact)))
676 762
 		{
677
-			if ($this->debug) error_log(__METHOD__."(,$id) save(".array2string($contact).") failed, Ok=$save_ok");
763
+			if ($this->debug)
764
+			{
765
+				error_log(__METHOD__."(,$id) save(".array2string($contact).") failed, Ok=$save_ok");
766
+			}
678 767
 			if ($save_ok === 0)
679 768
 			{
680 769
 				// honor Prefer: return=representation for 412 too (no need for client to explicitly reload)
@@ -704,7 +793,10 @@  discard block
 block discarded – undo
704 793
 		// send evtl. necessary respose headers: Location, etag, ...
705 794
 		$this->put_response_headers($contact, $options['path'], $retval, self::$path_attr != 'id');
706 795
 
707
-		if ($this->debug > 1) error_log(__METHOD__."(,'$id', $user, '$prefix') returning ".array2string($retval));
796
+		if ($this->debug > 1)
797
+		{
798
+			error_log(__METHOD__."(,'$id', $user, '$prefix') returning ".array2string($retval));
799
+		}
708 800
 		return $retval;
709 801
 	}
710 802
 
@@ -718,7 +810,10 @@  discard block
 block discarded – undo
718 810
 	function save_group(array &$contact, $oldContact=null)
719 811
 	{
720 812
 		$data = array('list_name' => $contact['n_fn']);
721
-		if (!isset($contact['owner'])) $contact['owner'] = $GLOBALS['egw_info']['user']['account_id'];
813
+		if (!isset($contact['owner']))
814
+		{
815
+			$contact['owner'] = $GLOBALS['egw_info']['user']['account_id'];
816
+		}
722 817
 		foreach(array('id','carddav_name','uid','owner') as $name)
723 818
 		{
724 819
 			$data['list_'.$name] = $contact[$name];
@@ -770,8 +865,14 @@  discard block
 block discarded – undo
770 865
 					}
771 866
 				}
772 867
 				//error_log('to_add_ids='.array2string($to_add_ids).', to_delete_ids='.array2string($to_delete_ids));
773
-				if ($to_add_ids) $this->bo->add2list($to_add_ids, $list_id, array());
774
-				if ($to_delete_ids) $this->bo->remove_from_list($to_delete_ids, $list_id);
868
+				if ($to_add_ids)
869
+				{
870
+					$this->bo->add2list($to_add_ids, $list_id, array());
871
+				}
872
+				if ($to_delete_ids)
873
+				{
874
+					$this->bo->remove_from_list($to_delete_ids, $list_id);
875
+				}
775 876
 			}
776 877
 			// reread as update of list-members updates etag and modified
777 878
 			if (($contact = $this->bo->read_list($list_id)))
@@ -780,7 +881,10 @@  discard block
 block discarded – undo
780 881
 				$contact = $this->read($contact['list_'.self::$path_attr]);
781 882
 			}
782 883
 		}
783
-		if ($this->debug > 1) error_log(__METHOD__.'('.array2string($contact).', '.array2string($oldContact).') on return contact='.array2string($data).' returning '.array2string($list_id));
884
+		if ($this->debug > 1)
885
+		{
886
+			error_log(__METHOD__.'('.array2string($contact).', '.array2string($oldContact).') on return contact='.array2string($data).' returning '.array2string($list_id));
887
+		}
784 888
  		return $list_id;
785 889
 	}
786 890
 
@@ -794,11 +898,17 @@  discard block
 block discarded – undo
794 898
 	public function getctag($path,$user)
795 899
 	{
796 900
 		static $ctags = array();	// a little per request caching, in case ctag and sync-token is both requested
797
-		if (isset($ctags[$path])) return $ctags[$path];
901
+		if (isset($ctags[$path]))
902
+		{
903
+			return $ctags[$path];
904
+		}
798 905
 
799 906
 		$user_in = $user;
800 907
 		// not showing addressbook of a single user?
801
-		if (is_null($user) || $user === '' || $path == '/addressbook/') $user = null;
908
+		if (is_null($user) || $user === '' || $path == '/addressbook/')
909
+		{
910
+			$user = null;
911
+		}
802 912
 
803 913
 		// If "Sync selected addressbooks into one" is set --> ctag need to take selected AB's into account too
804 914
 		if ($user && $user == $GLOBALS['egw_info']['user']['account_id'] && in_array('O',$this->home_set_pref))
@@ -1011,16 +1121,22 @@  discard block
 block discarded – undo
1011 1121
 				$contact['etag'] .= ':'.implode('-',$limit_in_ab);
1012 1122
 			}
1013 1123
 		}
1014
-		elseif($contact === array())	// not found from read_lists()
1124
+		elseif($contact === array())
1125
+		{
1126
+			// not found from read_lists()
1015 1127
 		{
1016 1128
 			$contact = null;
1017 1129
 		}
1130
+		}
1018 1131
 
1019 1132
 		if ($contact && $contact['tid'] == Api\Contacts::DELETED_TYPE)
1020 1133
 		{
1021 1134
 			$contact = null;	// handle deleted events, as not existing (404 Not Found)
1022 1135
 		}
1023
-		if ($this->debug > 1) error_log(__METHOD__."('$id') returning ".array2string($contact));
1136
+		if ($this->debug > 1)
1137
+		{
1138
+			error_log(__METHOD__."('$id') returning ".array2string($contact));
1139
+		}
1024 1140
 		return $contact;
1025 1141
 	}
1026 1142
 
@@ -1050,7 +1166,10 @@  discard block
 block discarded – undo
1050 1166
 		// remove add and delete grants for accounts (for admins too)
1051 1167
 		// as accounts can not be created as contacts, they eg. need further data
1052 1168
 		// and admins might not recognice they delete an account incl. its data
1053
-		if (isset($grants[0])) $grants[0] &= ~(EGW_ACL_ADD|EGW_ACL_DELETE);
1169
+		if (isset($grants[0]))
1170
+		{
1171
+			$grants[0] &= ~(EGW_ACL_ADD|EGW_ACL_DELETE);
1172
+		}
1054 1173
 
1055 1174
 		return $grants;
1056 1175
 	}
@@ -1066,7 +1185,10 @@  discard block
 block discarded – undo
1066 1185
 		$shared = array();
1067 1186
 
1068 1187
 		// if "Sync all selected addressbook into one" is set --> no (additional) shared addressbooks
1069
-		if (!$ignore_all_in_one && in_array('O',$this->home_set_pref)) return array();
1188
+		if (!$ignore_all_in_one && in_array('O',$this->home_set_pref))
1189
+		{
1190
+			return array();
1191
+		}
1070 1192
 
1071 1193
 		// replace symbolic id's with real nummeric id's
1072 1194
 		foreach(array(
@@ -1133,7 +1255,11 @@  discard block
 block discarded – undo
1133 1255
 			$user = $hook_data['account_id'];
1134 1256
 			$addressbook_bo = new Api\Contacts();
1135 1257
 			$addressbooks += $addressbook_bo->get_addressbooks(Acl::READ, null, $user);
1136
-			if ($user > 0)  unset($addressbooks[$user]);	// allways synced
1258
+			if ($user > 0)
1259
+			{
1260
+				unset($addressbooks[$user]);
1261
+			}
1262
+			// allways synced
1137 1263
 			unset($addressbooks[$user.'p']);// ignore (optional) private addressbook for now
1138 1264
 		}
1139 1265
 
Please login to merge, or discard this patch.
Spacing   +126 added lines, -127 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']['api']['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
 			}
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
 			}
264 264
 		}
265 265
 		// last chunk or no chunking: add accounts from different repo and report missing multiget urls
266
-		if (!$start || (empty($contact)?0:count($contacts)) < $start[1])
266
+		if (!$start || (empty($contact) ? 0 : count($contacts)) < $start[1])
267 267
 		{
268 268
 			//error_log(__METHOD__."('$path', ".array2string($filter).", ".array2string($start)."; $report_not_found_multiget_ids) last chunk detected: count()=".count($contacts)." < $start[1]");
269 269
 			// add accounts after contacts, if enabled and stored in different repository
@@ -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']))
@@ -715,16 +714,16 @@  discard block
 block discarded – undo
715 714
 	 * @param array|false $oldContact
716 715
 	 * @return int|boolean $list_id or false on error
717 716
 	 */
718
-	function save_group(array &$contact, $oldContact=null)
717
+	function save_group(array &$contact, $oldContact = null)
719 718
 	{
720 719
 		$data = array('list_name' => $contact['n_fn']);
721 720
 		if (!isset($contact['owner'])) $contact['owner'] = $GLOBALS['egw_info']['user']['account_id'];
722
-		foreach(array('id','carddav_name','uid','owner') as $name)
721
+		foreach (array('id', 'carddav_name', 'uid', 'owner') as $name)
723 722
 		{
724 723
 			$data['list_'.$name] = $contact[$name];
725 724
 		}
726 725
 		//error_log(__METHOD__.'('.array2string($contact).', '.array2string($oldContact).') data='.array2string($data));
727
-		if (($list_id=$this->bo->add_list(empty($contact[self::$path_attr]) ? null : array('list_'.self::$path_attr => $contact[self::$path_attr]),
726
+		if (($list_id = $this->bo->add_list(empty($contact[self::$path_attr]) ? null : array('list_'.self::$path_attr => $contact[self::$path_attr]),
728 727
 			$contact['owner'], null, $data)))
729 728
 		{
730 729
 			// update members given in $contact['##X-ADDRESSBOOKSERVER-MEMBER']
@@ -737,14 +736,14 @@  discard block
 block discarded – undo
737 736
 			{
738 737
 				$new_members = array($new_members);
739 738
 			}
740
-			foreach($new_members as &$uid)
739
+			foreach ($new_members as &$uid)
741 740
 			{
742
-				$uid = substr($uid,9);	// cut off "urn:uuid:" prefix
741
+				$uid = substr($uid, 9); // cut off "urn:uuid:" prefix
743 742
 			}
744 743
 			if ($oldContact)
745 744
 			{
746
-				$to_add = array_diff($new_members,$oldContact['members']);
747
-				$to_delete = array_diff($oldContact['members'],$new_members);
745
+				$to_add = array_diff($new_members, $oldContact['members']);
746
+				$to_delete = array_diff($oldContact['members'], $new_members);
748 747
 			}
749 748
 			else
750 749
 			{
@@ -755,9 +754,9 @@  discard block
 block discarded – undo
755 754
 			{
756 755
 				$to_add_ids = $to_delete_ids = array();
757 756
 				$filter = array('uid' => $to_delete ? array_merge($to_add, $to_delete) : $to_add);
758
-				if (($contacts =& $this->bo->search(array(), array('id', 'uid'),'','','',False,'AND',false,$filter)))
757
+				if (($contacts = & $this->bo->search(array(), array('id', 'uid'), '', '', '', False, 'AND', false, $filter)))
759 758
 				{
760
-					foreach($contacts as $c)
759
+					foreach ($contacts as $c)
761 760
 					{
762 761
 						if ($to_delete && in_array($c['uid'], $to_delete))
763 762
 						{
@@ -791,9 +790,9 @@  discard block
 block discarded – undo
791 790
 	 * @param int $user
792 791
 	 * @return string
793 792
 	 */
794
-	public function getctag($path,$user)
793
+	public function getctag($path, $user)
795 794
 	{
796
-		static $ctags = array();	// a little per request caching, in case ctag and sync-token is both requested
795
+		static $ctags = array(); // a little per request caching, in case ctag and sync-token is both requested
797 796
 		if (isset($ctags[$path])) return $ctags[$path];
798 797
 
799 798
 		$user_in = $user;
@@ -801,9 +800,9 @@  discard block
 block discarded – undo
801 800
 		if (is_null($user) || $user === '' || $path == '/addressbook/') $user = null;
802 801
 
803 802
 		// If "Sync selected addressbooks into one" is set --> ctag need to take selected AB's into account too
804
-		if ($user && $user == $GLOBALS['egw_info']['user']['account_id'] && in_array('O',$this->home_set_pref))
803
+		if ($user && $user == $GLOBALS['egw_info']['user']['account_id'] && in_array('O', $this->home_set_pref))
805 804
 		{
806
-			$user = array_merge((array)$user,array_keys($this->get_shared(true)));	// true: ignore all-in-one pref
805
+			$user = array_merge((array)$user, array_keys($this->get_shared(true))); // true: ignore all-in-one pref
807 806
 
808 807
 			// include accounts ctag, if accounts stored different from contacts (eg.in LDAP or ADS)
809 808
 			if ($this->bo->so_accounts && in_array('0', $user))
@@ -814,7 +813,7 @@  discard block
 block discarded – undo
814 813
 		$ctag = $this->bo->get_ctag($user);
815 814
 
816 815
 		// include lists-ctag, if enabled
817
-		if (in_array('D',$this->home_set_pref))
816
+		if (in_array('D', $this->home_set_pref))
818 817
 		{
819 818
 			$lists_ctag = $this->bo->lists_ctag($user);
820 819
 		}
@@ -847,34 +846,34 @@  discard block
 block discarded – undo
847 846
 	 * @param int $user =null account_id of owner of collection
848 847
 	 * @return array
849 848
 	 */
850
-	public function extra_properties(array $props, $displayname, $base_uri=null, $user=null)
849
+	public function extra_properties(array $props, $displayname, $base_uri = null, $user = null)
851 850
 	{
852
-		unset($displayname, $base_uri, $user);	// not used, but required by function signature
851
+		unset($displayname, $base_uri, $user); // not used, but required by function signature
853 852
 
854 853
 		if (!isset($props['addressbook-description']))
855 854
 		{
856 855
 			// default addressbook description: can be overwritten via PROPPATCH, in which case it's already set
857
-			$props['addressbook-description'] = Api\CalDAV::mkprop(Api\CalDAV::CARDDAV,'addressbook-description',$props['displayname']);
856
+			$props['addressbook-description'] = Api\CalDAV::mkprop(Api\CalDAV::CARDDAV, 'addressbook-description', $props['displayname']);
858 857
 		}
859 858
 		// setting an max image size, so iOS scales the images before transmitting them
860 859
 		// we currently scale down to width of 240px, which tests shown to be ~20k
861
-		$props['max-image-size'] = Api\CalDAV::mkprop(Api\CalDAV::CARDDAV,'max-image-size',24*1024);
860
+		$props['max-image-size'] = Api\CalDAV::mkprop(Api\CalDAV::CARDDAV, 'max-image-size', 24 * 1024);
862 861
 
863 862
 		// supported reports (required property for CardDAV)
864 863
 		$props['supported-report-set'] = array(
865
-			'addressbook-query' => Api\CalDAV::mkprop('supported-report',array(
866
-				Api\CalDAV::mkprop('report',array(
867
-					Api\CalDAV::mkprop(Api\CalDAV::CARDDAV,'addressbook-query',''))))),
868
-			'addressbook-multiget' => Api\CalDAV::mkprop('supported-report',array(
869
-				Api\CalDAV::mkprop('report',array(
870
-					Api\CalDAV::mkprop(Api\CalDAV::CARDDAV,'addressbook-multiget',''))))),
864
+			'addressbook-query' => Api\CalDAV::mkprop('supported-report', array(
865
+				Api\CalDAV::mkprop('report', array(
866
+					Api\CalDAV::mkprop(Api\CalDAV::CARDDAV, 'addressbook-query', ''))))),
867
+			'addressbook-multiget' => Api\CalDAV::mkprop('supported-report', array(
868
+				Api\CalDAV::mkprop('report', array(
869
+					Api\CalDAV::mkprop(Api\CalDAV::CARDDAV, 'addressbook-multiget', ''))))),
871 870
 		);
872 871
 		// only advertice rfc 6578 sync-collection report, if "delete-prevention" is switched on (deleted entries get marked deleted but not actualy deleted
873 872
 		if ($GLOBALS['egw_info']['server']['history'])
874 873
 		{
875
-			$props['supported-report-set']['sync-collection'] = Api\CalDAV::mkprop('supported-report',array(
876
-				Api\CalDAV::mkprop('report',array(
877
-					Api\CalDAV::mkprop('sync-collection','')))));
874
+			$props['supported-report-set']['sync-collection'] = Api\CalDAV::mkprop('supported-report', array(
875
+				Api\CalDAV::mkprop('report', array(
876
+					Api\CalDAV::mkprop('sync-collection', '')))));
878 877
 		}
879 878
 		return $props;
880 879
 	}
@@ -886,7 +885,7 @@  discard block
 block discarded – undo
886 885
 	 */
887 886
 	private function _get_handler()
888 887
 	{
889
-		$handler = new addressbook_vcal('addressbook','text/vcard');
888
+		$handler = new addressbook_vcal('addressbook', 'text/vcard');
890 889
 		$supportedFields = $handler->supportedFields;
891 890
 		// Apple iOS or OS X addressbook
892 891
 		if ($this->agent == 'cfnetwork' || $this->agent == 'dataaccess')
@@ -899,11 +898,11 @@  discard block
 block discarded – undo
899 898
 			unset($supportedFields['TEL;CELL;WORK']);
900 899
 			$supportedFields['TEL;IPHONE'] = array('tel_cell_private');
901 900
 			unset($supportedFields['TEL;CELL;HOME']);
902
-			$databaseFields['X-ABSHOWAS'] = $supportedFields['X-ABSHOWAS'] = array('fileas_type');	// Horde vCard class uses uppercase prop-names!
901
+			$databaseFields['X-ABSHOWAS'] = $supportedFields['X-ABSHOWAS'] = array('fileas_type'); // Horde vCard class uses uppercase prop-names!
903 902
 
904 903
 			// Apple Addressbook pre Lion (OS X 10.7) messes up CLASS and CATEGORIES (Lion cant set them but leaves them alone)
905 904
 			$matches = null;
906
-			if (preg_match('|CFNetwork/([0-9]+)|i', $_SERVER['HTTP_USER_AGENT'],$matches) && $matches[1] < 520 ||
905
+			if (preg_match('|CFNetwork/([0-9]+)|i', $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] < 520 ||
907 906
 				// iOS 5.1.1 does not display CLASS or CATEGORY, but wrongly escapes multiple, comma-separated categories
908 907
 				// and appends CLASS: PUBLIC to an empty NOTE: field --> leaving them out for iOS
909 908
 				$this->agent == 'dataaccess')
@@ -913,7 +912,7 @@  discard block
 block discarded – undo
913 912
 				unset($supportedFields['CATEGORIES']);
914 913
 				unset($databaseFields['CATEGORIES']);
915 914
 			}
916
-			if (preg_match('|CFNetwork/([0-9]+)|i', $_SERVER['HTTP_USER_AGENT'],$matches) && $matches[1] < 520)
915
+			if (preg_match('|CFNetwork/([0-9]+)|i', $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] < 520)
917 916
 			{
918 917
 				// gd cant parse or resize images stored from snow leopard addressbook: gd-jpeg:
919 918
 				// - JPEG library reports unrecoverable error
@@ -925,7 +924,7 @@  discard block
 block discarded – undo
925 924
 			}
926 925
 			$handler->setDatabaseFields($databaseFields);
927 926
 		}
928
-		$handler->setSupportedFields('GroupDAV',$this->agent,$supportedFields);
927
+		$handler->setSupportedFields('GroupDAV', $this->agent, $supportedFields);
929 928
 		return $handler;
930 929
 	}
931 930
 
@@ -936,9 +935,9 @@  discard block
 block discarded – undo
936 935
 	 * @param int $id
937 936
 	 * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
938 937
 	 */
939
-	function delete(&$options,$id)
938
+	function delete(&$options, $id)
940 939
 	{
941
-		if (!is_array($contact = $this->_common_get_put_delete('DELETE',$options,$id)))
940
+		if (!is_array($contact = $this->_common_get_put_delete('DELETE', $options, $id)))
942 941
 		{
943 942
 			return $contact;
944 943
 		}
@@ -946,7 +945,7 @@  discard block
 block discarded – undo
946 945
 		{
947 946
 			$ok = $this->bo->delete_list($contact['list_id']) !== false;
948 947
 		}
949
-		elseif (($ok = $this->bo->delete($contact['id'],self::etag2value($this->http_if_match))) === 0)
948
+		elseif (($ok = $this->bo->delete($contact['id'], self::etag2value($this->http_if_match))) === 0)
950 949
 		{
951 950
 			return '412 Precondition Failed';
952 951
 		}
@@ -963,9 +962,9 @@  discard block
 block discarded – undo
963 962
 	 * @param string $path =null
964 963
 	 * @return array|boolean array with entry, false if no read rights, null if $id does not exist
965 964
 	 */
966
-	function read($id, $path=null)
965
+	function read($id, $path = null)
967 966
 	{
968
-		static $non_deleted_tids=null;
967
+		static $non_deleted_tids = null;
969 968
 		if (is_null($non_deleted_tids))
970 969
 		{
971 970
 			$tids = $this->bo->content_types;
@@ -975,7 +974,7 @@  discard block
 block discarded – undo
975 974
 		$contact = $this->bo->read(array(self::$path_attr => $id, 'tid' => $non_deleted_tids));
976 975
 
977 976
 		// if contact not found and accounts stored NOT like contacts, try reading it without path-extension as id
978
-		if (is_null($contact) && $this->bo->so_accounts && ($c = $this->bo->read($test=basename($id, '.vcf'))))
977
+		if (is_null($contact) && $this->bo->so_accounts && ($c = $this->bo->read($test = basename($id, '.vcf'))))
979 978
 		{
980 979
 			$contact = $c;
981 980
 		}
@@ -984,9 +983,9 @@  discard block
 block discarded – undo
984 983
 		// bo->read_list(..., true) limits returned uid to same owner's addressbook, as iOS and OS X addressbooks
985 984
 		// only understands/shows that and if return more, save_lists would delete the others ones on update!
986 985
 		$limit_in_ab = true;
987
-		list(,$account_lid,$app) = explode('/',$path);	// eg. /<username>/addressbook/<id>
986
+		list(,$account_lid, $app) = explode('/', $path); // eg. /<username>/addressbook/<id>
988 987
 		// /<username>/addressbook/ with home_set_prefs containing 'O'=all-in-one contains selected ab's
989
-		if($account_lid == $GLOBALS['egw_info']['user']['account_lid'] && $app == 'addressbook' && in_array('O',$this->home_set_pref))
988
+		if ($account_lid == $GLOBALS['egw_info']['user']['account_lid'] && $app == 'addressbook' && in_array('O', $this->home_set_pref))
990 989
 		{
991 990
 			$limit_in_ab = array_keys($this->get_shared(true));
992 991
 			$limit_in_ab[] = $GLOBALS['egw_info']['user']['account_id'];
@@ -997,28 +996,28 @@  discard block
 block discarded – undo
997 996
 		{
998 997
 			$limit_in_ab = array_keys($this->bo->grants);
999 998
 		}*/
1000
-		if (!$contact && ($contact = $this->bo->read_lists(array('list_'.self::$path_attr => $id),'contact_uid',$limit_in_ab)))
999
+		if (!$contact && ($contact = $this->bo->read_lists(array('list_'.self::$path_attr => $id), 'contact_uid', $limit_in_ab)))
1001 1000
 		{
1002 1001
 			$contact = array_shift($contact);
1003 1002
 			$contact['n_fn'] = $contact['n_family'] = $contact['list_name'];
1004
-			foreach(array('owner','id','carddav_name','modified','modifier','created','creator','etag','uid') as $name)
1003
+			foreach (array('owner', 'id', 'carddav_name', 'modified', 'modifier', 'created', 'creator', 'etag', 'uid') as $name)
1005 1004
 			{
1006 1005
 				$contact[$name] = $contact['list_'.$name];
1007 1006
 			}
1008 1007
 			// if NOT limited to containing AB ($limit_in_ab === true), add that limit to etag
1009 1008
 			if ($limit_in_ab !== true)
1010 1009
 			{
1011
-				$contact['etag'] .= ':'.implode('-',$limit_in_ab);
1010
+				$contact['etag'] .= ':'.implode('-', $limit_in_ab);
1012 1011
 			}
1013 1012
 		}
1014
-		elseif($contact === array())	// not found from read_lists()
1013
+		elseif ($contact === array())	// not found from read_lists()
1015 1014
 		{
1016 1015
 			$contact = null;
1017 1016
 		}
1018 1017
 
1019 1018
 		if ($contact && $contact['tid'] == Api\Contacts::DELETED_TYPE)
1020 1019
 		{
1021
-			$contact = null;	// handle deleted events, as not existing (404 Not Found)
1020
+			$contact = null; // handle deleted events, as not existing (404 Not Found)
1022 1021
 		}
1023 1022
 		if ($this->debug > 1) error_log(__METHOD__."('$id') returning ".array2string($contact));
1024 1023
 		return $contact;
@@ -1031,9 +1030,9 @@  discard block
 block discarded – undo
1031 1030
 	 * @param array|int $contact contact-array or id
1032 1031
 	 * @return boolean null if entry does not exist, false if no access, true if access permitted
1033 1032
 	 */
1034
-	function check_access($acl,$contact)
1033
+	function check_access($acl, $contact)
1035 1034
 	{
1036
-		return $this->bo->check_perms($acl, $contact, true);	// true = deny to delete accounts
1035
+		return $this->bo->check_perms($acl, $contact, true); // true = deny to delete accounts
1037 1036
 	}
1038 1037
 
1039 1038
 	/**
@@ -1061,15 +1060,15 @@  discard block
 block discarded – undo
1061 1060
 	 * @param boolean $ignore_all_in_one =false if true, return selected addressbooks and not array() for all-in-one
1062 1061
 	 * @return array account_id => account_lid pairs
1063 1062
 	 */
1064
-	function get_shared($ignore_all_in_one=false)
1063
+	function get_shared($ignore_all_in_one = false)
1065 1064
 	{
1066 1065
 		$shared = array();
1067 1066
 
1068 1067
 		// if "Sync all selected addressbook into one" is set --> no (additional) shared addressbooks
1069
-		if (!$ignore_all_in_one && in_array('O',$this->home_set_pref)) return array();
1068
+		if (!$ignore_all_in_one && in_array('O', $this->home_set_pref)) return array();
1070 1069
 
1071 1070
 		// replace symbolic id's with real nummeric id's
1072
-		foreach(array(
1071
+		foreach (array(
1073 1072
 			'G' => $GLOBALS['egw_info']['user']['account_primary_group'],
1074 1073
 			'U' => '0',
1075 1074
 		) as $sym => $id)
@@ -1079,11 +1078,11 @@  discard block
 block discarded – undo
1079 1078
 				$this->home_set_pref[$key] = $id;
1080 1079
 			}
1081 1080
 		}
1082
-		foreach(array_keys($this->bo->get_addressbooks(Acl::READ)) as $id)
1081
+		foreach (array_keys($this->bo->get_addressbooks(Acl::READ)) as $id)
1083 1082
 		{
1084 1083
 			if (($id || $GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] !== '1') &&
1085
-				$GLOBALS['egw_info']['user']['account_id'] != $id &&	// no current user and no accounts, if disabled in ab prefs
1086
-				(in_array('A',$this->home_set_pref) || in_array((string)$id,$this->home_set_pref)) &&
1084
+				$GLOBALS['egw_info']['user']['account_id'] != $id && // no current user and no accounts, if disabled in ab prefs
1085
+				(in_array('A', $this->home_set_pref) || in_array((string)$id, $this->home_set_pref)) &&
1087 1086
 				is_numeric($id) && ($owner = $id ? $this->accounts->id2name($id) : 'accounts'))
1088 1087
 			{
1089 1088
 				$shared[$id] = 'addressbook-'.$owner;
@@ -1103,14 +1102,14 @@  discard block
 block discarded – undo
1103 1102
 	public static function groupdav_root_props(array $data)
1104 1103
 	{
1105 1104
 		$data['props']['addressbook-home-set'] = Api\CalDAV::mkprop(Api\CalDAV::CARDDAV, 'addressbook-home-set', array(
1106
-			Api\CalDAV::mkprop('href',$data['caldav']->base_uri.'/'.$GLOBALS['egw_info']['user']['account_lid'].'/')));
1105
+			Api\CalDAV::mkprop('href', $data['caldav']->base_uri.'/'.$GLOBALS['egw_info']['user']['account_lid'].'/')));
1107 1106
 
1108 1107
 		$data['props']['principal-address'] = Api\CalDAV::mkprop(Api\CalDAV::CARDDAV, 'principal-address',
1109 1108
 				$GLOBALS['egw_info']['user']['preferences']['addressbook']['hide_accounts'] === '1' ? '' : array(
1110
-				Api\CalDAV::mkprop('href',$data['caldav']->base_uri.'/addressbook-accounts/'.$GLOBALS['egw_info']['user']['person_id'].'.vcf')));
1109
+				Api\CalDAV::mkprop('href', $data['caldav']->base_uri.'/addressbook-accounts/'.$GLOBALS['egw_info']['user']['person_id'].'.vcf')));
1111 1110
 
1112 1111
 		$data['props']['directory-gateway'] = Api\CalDAV::mkprop(Api\CalDAV::CARDDAV, 'directory-gateway', array(
1113
-			Api\CalDAV::mkprop('href',$data['caldav']->base_uri.'/addressbook/')));
1112
+			Api\CalDAV::mkprop('href', $data['caldav']->base_uri.'/addressbook/')));
1114 1113
 	}
1115 1114
 
1116 1115
 	/**
@@ -1133,8 +1132,8 @@  discard block
 block discarded – undo
1133 1132
 			$user = $hook_data['account_id'];
1134 1133
 			$addressbook_bo = new Api\Contacts();
1135 1134
 			$addressbooks += $addressbook_bo->get_addressbooks(Acl::READ, null, $user);
1136
-			if ($user > 0)  unset($addressbooks[$user]);	// allways synced
1137
-			unset($addressbooks[$user.'p']);// ignore (optional) private addressbook for now
1135
+			if ($user > 0)  unset($addressbooks[$user]); // allways synced
1136
+			unset($addressbooks[$user.'p']); // ignore (optional) private addressbook for now
1138 1137
 		}
1139 1138
 
1140 1139
 		// allow to force no other addressbooks
@@ -1161,9 +1160,9 @@  discard block
 block discarded – undo
1161 1160
 			'label'  => 'Addressbooks to sync in addition to personal addressbook',
1162 1161
 			'name'   => 'addressbook-home-set',
1163 1162
 			'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!').
1164
-				'<br/>'.lang('They will be sub-folders in users home (%1 attribute).','CardDAV "addressbook-home-set"').
1165
-				'<br/>'.lang('Select "%1", if your client does not support multiple addressbooks.',lang('Sync all selected into one')).
1166
-				'<br/>'.lang('Select "%1", if your client support groups, eg. OS X or iOS addressbook.',lang('Distribution lists as groups')),
1163
+				'<br/>'.lang('They will be sub-folders in users home (%1 attribute).', 'CardDAV "addressbook-home-set"').
1164
+				'<br/>'.lang('Select "%1", if your client does not support multiple addressbooks.', lang('Sync all selected into one')).
1165
+				'<br/>'.lang('Select "%1", if your client support groups, eg. OS X or iOS addressbook.', lang('Distribution lists as groups')),
1167 1166
 			'values' => $addressbooks,
1168 1167
 			'xmlrpc' => True,
1169 1168
 			'admin'  => False,
Please login to merge, or discard this patch.
addressbook/inc/class.addressbook_import_vcard.inc.php 4 patches
Doc Comments   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -83,8 +83,7 @@
 block discarded – undo
83 83
 	/**
84 84
 	 * imports entries according to given definition object.
85 85
 	 * @param resource $_stream
86
-	 * @param string $_charset
87
-	 * @param definition $_definition
86
+	 * @param importexport_definition $_definition
88 87
 	 */
89 88
 	public function import( $_stream, importexport_definition $_definition ) {
90 89
 		$this->definition = $_definition;
Please login to merge, or discard this patch.
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -45,8 +45,8 @@  discard block
 block discarded – undo
45 45
 	private $bocontacts;
46 46
 
47 47
 	/**
48
-	* For figuring out if a contact has changed
49
-	*/
48
+	 * For figuring out if a contact has changed
49
+	 */
50 50
 	protected $tracking;
51 51
 
52 52
 	/**
@@ -76,9 +76,9 @@  discard block
 block discarded – undo
76 76
 	protected $errors = array();
77 77
 
78 78
 	/**
79
-         * List of actions, and how many times that action was taken
80
-         */
81
-        protected $results = array();
79
+	 * List of actions, and how many times that action was taken
80
+	 */
81
+		protected $results = array();
82 82
 
83 83
 	/**
84 84
 	 * imports entries according to given definition object.
@@ -93,14 +93,14 @@  discard block
 block discarded – undo
93 93
 		$this->is_admin = isset( $GLOBALS['egw_info']['user']['apps']['admin'] ) && $GLOBALS['egw_info']['user']['apps']['admin'];
94 94
 		$this->user = $GLOBALS['egw_info']['user']['account_id'];
95 95
 
96
-                // set contact owner
97
-                $contact_owner = isset( $_definition->plugin_options['contact_owner'] ) ?
98
-                        $_definition->plugin_options['contact_owner'] : $this->user;
99
-                // Import into importer's personal addressbook
100
-                if($contact_owner == 'personal')
101
-                {
102
-                        $contact_owner = $this->user;
103
-                }
96
+				// set contact owner
97
+				$contact_owner = isset( $_definition->plugin_options['contact_owner'] ) ?
98
+						$_definition->plugin_options['contact_owner'] : $this->user;
99
+				// Import into importer's personal addressbook
100
+				if($contact_owner == 'personal')
101
+				{
102
+						$contact_owner = $this->user;
103
+				}
104 104
 
105 105
 		// dry run?
106 106
 		$this->dry_run = isset( $_definition->plugin_options['dry_run'] ) ? $_definition->plugin_options['dry_run'] :  false;
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 		$this->errors = array();
124 124
 
125 125
 		// Fix for Apple Addressbook
126
-        $vCard = preg_replace('/item\d\.(ADR|TEL|EMAIL|URL)/', '\1', stream_get_contents($_stream));
126
+		$vCard = preg_replace('/item\d\.(ADR|TEL|EMAIL|URL)/', '\1', stream_get_contents($_stream));
127 127
 
128 128
 		$contacts = new Api\CalDAV\IcalIterator($vCard, '', $charset, array($this, '_vcard'),array(
129 129
 			// Owner (addressbook)
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
 		foreach($this->preview_records as $record)
278 278
 		{
279 279
 			// Convert to human-friendly
280
-            importexport_export_csv::convert($record,$record_class::$types,$_definition->application);
280
+			importexport_export_csv::convert($record,$record_class::$types,$_definition->application);
281 281
 			$record = $record->get_record_array();
282 282
 			$row = array();
283 283
 			foreach(array_keys($labels) as $field)
@@ -350,38 +350,38 @@  discard block
 block discarded – undo
350 350
 	}
351 351
 
352 352
 	/**
353
-        * Returns warnings that were encountered during importing
354
-        * Maximum of one warning message per record, but you can append if you need to
355
-        *
356
-        * @return Array (
357
-        *       record_# => warning message
358
-        *       )
359
-        */
360
-        public function get_warnings() {
353
+	 * Returns warnings that were encountered during importing
354
+	 * Maximum of one warning message per record, but you can append if you need to
355
+	 *
356
+	 * @return Array (
357
+	 *       record_# => warning message
358
+	 *       )
359
+	 */
360
+		public function get_warnings() {
361 361
 		return $this->warnings;
362 362
 	}
363 363
 
364 364
 	/**
365
-        * Returns errors that were encountered during importing
366
-        * Maximum of one error message per record, but you can append if you need to
367
-        *
368
-        * @return Array (
369
-        *       record_# => error message
370
-        *       )
371
-        */
372
-        public function get_errors() {
365
+	 * Returns errors that were encountered during importing
366
+	 * Maximum of one error message per record, but you can append if you need to
367
+	 *
368
+	 * @return Array (
369
+	 *       record_# => error message
370
+	 *       )
371
+	 */
372
+		public function get_errors() {
373 373
 		return $this->errors;
374 374
 	}
375 375
 
376 376
 	/**
377
-        * Returns a list of actions taken, and the number of records for that action.
378
-        * Actions are things like 'insert', 'update', 'delete', and may be different for each plugin.
379
-        *
380
-        * @return Array (
381
-        *       action => record count
382
-        * )
383
-        */
384
-        public function get_results() {
385
-                return $this->results;
386
-        }
377
+	 * Returns a list of actions taken, and the number of records for that action.
378
+	 * Actions are things like 'insert', 'update', 'delete', and may be different for each plugin.
379
+	 *
380
+	 * @return Array (
381
+	 *       action => record count
382
+	 * )
383
+	 */
384
+		public function get_results() {
385
+				return $this->results;
386
+		}
387 387
 }
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 /**
16 16
  * Plugin to import vCard files
17 17
  */
18
-class addressbook_import_vcard implements importexport_iface_import_plugin  {
18
+class addressbook_import_vcard implements importexport_iface_import_plugin {
19 19
 
20 20
 	private static $plugin_options = array(
21 21
 
@@ -86,24 +86,24 @@  discard block
 block discarded – undo
86 86
 	 * @param string $_charset
87 87
 	 * @param definition $_definition
88 88
 	 */
89
-	public function import( $_stream, importexport_definition $_definition ) {
89
+	public function import($_stream, importexport_definition $_definition) {
90 90
 		$this->definition = $_definition;
91 91
 
92 92
 		// user, is admin ?
93
-		$this->is_admin = isset( $GLOBALS['egw_info']['user']['apps']['admin'] ) && $GLOBALS['egw_info']['user']['apps']['admin'];
93
+		$this->is_admin = isset($GLOBALS['egw_info']['user']['apps']['admin']) && $GLOBALS['egw_info']['user']['apps']['admin'];
94 94
 		$this->user = $GLOBALS['egw_info']['user']['account_id'];
95 95
 
96 96
                 // set contact owner
97
-                $contact_owner = isset( $_definition->plugin_options['contact_owner'] ) ?
97
+                $contact_owner = isset($_definition->plugin_options['contact_owner']) ?
98 98
                         $_definition->plugin_options['contact_owner'] : $this->user;
99 99
                 // Import into importer's personal addressbook
100
-                if($contact_owner == 'personal')
100
+                if ($contact_owner == 'personal')
101 101
                 {
102 102
                         $contact_owner = $this->user;
103 103
                 }
104 104
 
105 105
 		// dry run?
106
-		$this->dry_run = isset( $_definition->plugin_options['dry_run'] ) ? $_definition->plugin_options['dry_run'] :  false;
106
+		$this->dry_run = isset($_definition->plugin_options['dry_run']) ? $_definition->plugin_options['dry_run'] : false;
107 107
 
108 108
 		// Needed for categories to work right
109 109
 		$GLOBALS['egw_info']['flags']['currentapp'] = 'addressbook';
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 		$this->bocontacts = new addressbook_vcal();
113 113
 
114 114
 		$charset = $_definition->plugin_options['charset'];
115
-		if($charset == 'user') $charset = $GLOBALS['egw_info']['user']['preferences']['addressbook']['vcard_charset'];
115
+		if ($charset == 'user') $charset = $GLOBALS['egw_info']['user']['preferences']['addressbook']['vcard_charset'];
116 116
 
117 117
 		// Start counting successes
118 118
 		$this->current = 0;
@@ -125,24 +125,24 @@  discard block
 block discarded – undo
125 125
 		// Fix for Apple Addressbook
126 126
         $vCard = preg_replace('/item\d\.(ADR|TEL|EMAIL|URL)/', '\1', stream_get_contents($_stream));
127 127
 
128
-		$contacts = new Api\CalDAV\IcalIterator($vCard, '', $charset, array($this, '_vcard'),array(
128
+		$contacts = new Api\CalDAV\IcalIterator($vCard, '', $charset, array($this, '_vcard'), array(
129 129
 			// Owner (addressbook)
130 130
 			$contact_owner
131 131
 		));
132 132
 		$contacts->next();
133
-		while($contacts->valid()) {
133
+		while ($contacts->valid()) {
134 134
 			$this->current++;
135 135
 			$contact = $contacts->current();
136 136
 
137 137
 			$this->action('insert', $contact, $this->current);
138 138
 
139 139
 			// Stop if we have enough records for a preview
140
-			if($this->dry_run)
140
+			if ($this->dry_run)
141 141
 			{
142 142
 				$egw_record = new addressbook_egw_record();
143 143
 				$egw_record->set_record($contact);
144 144
 				$this->preview_records[] = $egw_record;
145
-				if($count >= $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs']) break;
145
+				if ($count >= $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs']) break;
146 146
 			}
147 147
 
148 148
 			$count++;
@@ -158,13 +158,13 @@  discard block
 block discarded – undo
158 158
 	public function _vcard($_vcard, $owner)
159 159
 	{
160 160
 		$charset = $this->definition->plugin_options['charset'];
161
-		if($charset == 'user') $charset = $GLOBALS['egw_info']['user']['preferences']['addressbook']['vcard_charset'];
162
-		$record = $this->bocontacts->vcardtoegw($_vcard,$charset);
161
+		if ($charset == 'user') $charset = $GLOBALS['egw_info']['user']['preferences']['addressbook']['vcard_charset'];
162
+		$record = $this->bocontacts->vcardtoegw($_vcard, $charset);
163 163
 
164 164
 		$record['owner'] = $owner;
165 165
 
166 166
 		// Check that owner (addressbook) is allowed
167
-		if(!array_key_exists($record['owner'], $this->bocontacts->get_addressbooks()))
167
+		if (!array_key_exists($record['owner'], $this->bocontacts->get_addressbooks()))
168 168
 		{
169 169
 			$this->errors[$this->current] = lang("Unable to import into %1, using %2",
170 170
 				Api\Accounts::username($record['owner']),
@@ -175,14 +175,14 @@  discard block
 block discarded – undo
175 175
 
176 176
 		// Do not allow owner == 0 (accounts) without an account_id
177 177
 		// It causes the contact to be filed as an account, and can't delete
178
-		if(!$record['owner'] && !$record['account_id'])
178
+		if (!$record['owner'] && !$record['account_id'])
179 179
 		{
180 180
 			$record['owner'] = $this->user;
181 181
 		}
182 182
 
183 183
 		if (is_array($record['cat_id']))
184 184
 		{
185
-			$record['cat_id'] = implode(',',$this->bocontacts->find_or_add_categories($record['cat_id'], -1));
185
+			$record['cat_id'] = implode(',', $this->bocontacts->find_or_add_categories($record['cat_id'], -1));
186 186
 		}
187 187
 		return $record;
188 188
 	}
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 	 * @param array $_data contact data for the action
195 195
 	 * @return bool success or not
196 196
 	 */
197
-	private function action ( $_action, $_data, $record_num = 0 ) {
197
+	private function action($_action, $_data, $record_num = 0) {
198 198
 		switch ($_action) {
199 199
 			case 'none' :
200 200
 				return true;
@@ -202,17 +202,17 @@  discard block
 block discarded – undo
202 202
 				// Only update if there are changes
203 203
 				$old = $this->bocontacts->read($_data['id']);
204 204
 				// if we get countrycodes as countryname, try to translate them -> the rest should be handled by bo classes.
205
-				foreach(array('adr_one_', 'adr_two_') as $c_prefix)
205
+				foreach (array('adr_one_', 'adr_two_') as $c_prefix)
206 206
 				{
207
-					if (strlen(trim($_data[$c_prefix.'countryname']))==2)
207
+					if (strlen(trim($_data[$c_prefix.'countryname'])) == 2)
208 208
 					{
209 209
 						$_data[$c_prefix.'countryname'] = Api\Country::get_full_name(trim($_data[$c_prefix.'countryname']), true);
210 210
 					}
211 211
 				}
212 212
 				// Don't change a user account into a contact
213
-				if($old['owner'] == 0) {
213
+				if ($old['owner'] == 0) {
214 214
 					unset($_data['owner']);
215
-				} elseif(!$this->definition->plugin_options['change_owner']) {
215
+				} elseif (!$this->definition->plugin_options['change_owner']) {
216 216
 					// Don't change addressbook of an existing contact
217 217
 					unset($_data['owner']);
218 218
 				}
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 				// Merge to deal with fields not in import record
221 221
 				$_data = array_merge($old, $_data);
222 222
 				$changed = $this->tracking->changed_fields($_data, $old);
223
-				if(count($changed) == 0) {
223
+				if (count($changed) == 0) {
224 224
 					return true;
225 225
 				} else {
226 226
 					//error_log(__METHOD__.__LINE__.array2string($changed).' Old:'.$old['adr_one_countryname'].' ('.$old['adr_one_countrycode'].') New:'.$_data['adr_one_countryname'].' ('.$_data['adr_one_countryname'].')');
@@ -231,22 +231,22 @@  discard block
 block discarded – undo
231 231
 
232 232
 				// Fall through
233 233
 			case 'insert' :
234
-				if($_action == 'insert') {
234
+				if ($_action == 'insert') {
235 235
 					// Addressbook backend doesn't like inserting with ID specified, it screws up the owner & etag
236 236
 					unset($_data['id']);
237 237
 				}
238
-				if(!isset($_data['org_name'])) {
238
+				if (!isset($_data['org_name'])) {
239 239
 					// org_name is a trigger to update n_fileas
240 240
 					$_data['org_name'] = '';
241 241
 				}
242 242
 
243
-				if ( $this->dry_run ) {
243
+				if ($this->dry_run) {
244 244
 					//print_r($_data);
245 245
 					$this->results[$_action]++;
246 246
 					return true;
247 247
 				} else {
248
-					$result = $this->bocontacts->save( $_data, $this->is_admin);
249
-					if(!$result) {
248
+					$result = $this->bocontacts->save($_data, $this->is_admin);
249
+					if (!$result) {
250 250
 						$this->errors[$record_num] = $this->bocontacts->error;
251 251
 					} else {
252 252
 						$this->results[$_action]++;
@@ -254,14 +254,14 @@  discard block
 block discarded – undo
254 254
 					return $result;
255 255
 				}
256 256
 			default:
257
-				throw new Api\Exception('Unsupported action: '. $_action);
257
+				throw new Api\Exception('Unsupported action: '.$_action);
258 258
 
259 259
 		}
260 260
 	}
261 261
 
262
-	public function preview( $_stream, importexport_definition $_definition )
262
+	public function preview($_stream, importexport_definition $_definition)
263 263
 	{
264
-		$rows = array('h1'=>array(),'f1'=>array(),'.h1'=>'class=th');
264
+		$rows = array('h1'=>array(), 'f1'=>array(), '.h1'=>'class=th');
265 265
 
266 266
 		// Set this so plugin doesn't do any data changes
267 267
 		$_definition->plugin_options = (array)$_definition->plugin_options + array('dry_run' => true);
@@ -274,18 +274,18 @@  discard block
 block discarded – undo
274 274
 
275 275
 		$record_class = get_class($this->preview_records[0]);
276 276
 
277
-		foreach($this->preview_records as $record)
277
+		foreach ($this->preview_records as $record)
278 278
 		{
279 279
 			// Convert to human-friendly
280
-            importexport_export_csv::convert($record,$record_class::$types,$_definition->application);
280
+            importexport_export_csv::convert($record, $record_class::$types, $_definition->application);
281 281
 			$record = $record->get_record_array();
282 282
 			$row = array();
283
-			foreach(array_keys($labels) as $field)
283
+			foreach (array_keys($labels) as $field)
284 284
 			{
285 285
 				$row[$field] = $record[$field];
286 286
 
287 287
 				// Don't scare users, do something with jpeg
288
-				if($field == 'jpegphoto' && $row[$field])
288
+				if ($field == 'jpegphoto' && $row[$field])
289 289
 				{
290 290
 					$row[$field] = '<img style="max-width:50px;max-height:50px;" src="data:image/jpeg;base64,'.$row[$field].'"/>';
291 291
 				}
Please login to merge, or discard this patch.
Braces   +62 added lines, -26 removed lines patch added patch discarded remove patch
@@ -15,7 +15,8 @@  discard block
 block discarded – undo
15 15
 /**
16 16
  * Plugin to import vCard files
17 17
  */
18
-class addressbook_import_vcard implements importexport_iface_import_plugin  {
18
+class addressbook_import_vcard implements importexport_iface_import_plugin
19
+{
19 20
 
20 21
 	private static $plugin_options = array(
21 22
 
@@ -86,7 +87,8 @@  discard block
 block discarded – undo
86 87
 	 * @param string $_charset
87 88
 	 * @param definition $_definition
88 89
 	 */
89
-	public function import( $_stream, importexport_definition $_definition ) {
90
+	public function import( $_stream, importexport_definition $_definition )
91
+	{
90 92
 		$this->definition = $_definition;
91 93
 
92 94
 		// user, is admin ?
@@ -112,7 +114,10 @@  discard block
 block discarded – undo
112 114
 		$this->bocontacts = new addressbook_vcal();
113 115
 
114 116
 		$charset = $_definition->plugin_options['charset'];
115
-		if($charset == 'user') $charset = $GLOBALS['egw_info']['user']['preferences']['addressbook']['vcard_charset'];
117
+		if($charset == 'user')
118
+		{
119
+			$charset = $GLOBALS['egw_info']['user']['preferences']['addressbook']['vcard_charset'];
120
+		}
116 121
 
117 122
 		// Start counting successes
118 123
 		$this->current = 0;
@@ -130,7 +135,8 @@  discard block
 block discarded – undo
130 135
 			$contact_owner
131 136
 		));
132 137
 		$contacts->next();
133
-		while($contacts->valid()) {
138
+		while($contacts->valid())
139
+		{
134 140
 			$this->current++;
135 141
 			$contact = $contacts->current();
136 142
 
@@ -142,7 +148,10 @@  discard block
 block discarded – undo
142 148
 				$egw_record = new addressbook_egw_record();
143 149
 				$egw_record->set_record($contact);
144 150
 				$this->preview_records[] = $egw_record;
145
-				if($count >= $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs']) break;
151
+				if($count >= $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs'])
152
+				{
153
+					break;
154
+				}
146 155
 			}
147 156
 
148 157
 			$count++;
@@ -158,7 +167,10 @@  discard block
 block discarded – undo
158 167
 	public function _vcard($_vcard, $owner)
159 168
 	{
160 169
 		$charset = $this->definition->plugin_options['charset'];
161
-		if($charset == 'user') $charset = $GLOBALS['egw_info']['user']['preferences']['addressbook']['vcard_charset'];
170
+		if($charset == 'user')
171
+		{
172
+			$charset = $GLOBALS['egw_info']['user']['preferences']['addressbook']['vcard_charset'];
173
+		}
162 174
 		$record = $this->bocontacts->vcardtoegw($_vcard,$charset);
163 175
 
164 176
 		$record['owner'] = $owner;
@@ -194,8 +206,10 @@  discard block
 block discarded – undo
194 206
 	 * @param array $_data contact data for the action
195 207
 	 * @return bool success or not
196 208
 	 */
197
-	private function action ( $_action, $_data, $record_num = 0 ) {
198
-		switch ($_action) {
209
+	private function action ( $_action, $_data, $record_num = 0 )
210
+	{
211
+		switch ($_action)
212
+		{
199 213
 			case 'none' :
200 214
 				return true;
201 215
 			case 'update' :
@@ -210,9 +224,12 @@  discard block
 block discarded – undo
210 224
 					}
211 225
 				}
212 226
 				// Don't change a user account into a contact
213
-				if($old['owner'] == 0) {
227
+				if($old['owner'] == 0)
228
+				{
214 229
 					unset($_data['owner']);
215
-				} elseif(!$this->definition->plugin_options['change_owner']) {
230
+				}
231
+				elseif(!$this->definition->plugin_options['change_owner'])
232
+				{
216 233
 					// Don't change addressbook of an existing contact
217 234
 					unset($_data['owner']);
218 235
 				}
@@ -220,9 +237,12 @@  discard block
 block discarded – undo
220 237
 				// Merge to deal with fields not in import record
221 238
 				$_data = array_merge($old, $_data);
222 239
 				$changed = $this->tracking->changed_fields($_data, $old);
223
-				if(count($changed) == 0) {
240
+				if(count($changed) == 0)
241
+				{
224 242
 					return true;
225
-				} else {
243
+				}
244
+				else
245
+				{
226 246
 					//error_log(__METHOD__.__LINE__.array2string($changed).' Old:'.$old['adr_one_countryname'].' ('.$old['adr_one_countrycode'].') New:'.$_data['adr_one_countryname'].' ('.$_data['adr_one_countryname'].')');
227 247
 				}
228 248
 
@@ -231,24 +251,32 @@  discard block
 block discarded – undo
231 251
 
232 252
 				// Fall through
233 253
 			case 'insert' :
234
-				if($_action == 'insert') {
254
+				if($_action == 'insert')
255
+				{
235 256
 					// Addressbook backend doesn't like inserting with ID specified, it screws up the owner & etag
236 257
 					unset($_data['id']);
237 258
 				}
238
-				if(!isset($_data['org_name'])) {
259
+				if(!isset($_data['org_name']))
260
+				{
239 261
 					// org_name is a trigger to update n_fileas
240 262
 					$_data['org_name'] = '';
241 263
 				}
242 264
 
243
-				if ( $this->dry_run ) {
265
+				if ( $this->dry_run )
266
+				{
244 267
 					//print_r($_data);
245 268
 					$this->results[$_action]++;
246 269
 					return true;
247
-				} else {
270
+				}
271
+				else
272
+				{
248 273
 					$result = $this->bocontacts->save( $_data, $this->is_admin);
249
-					if(!$result) {
274
+					if(!$result)
275
+					{
250 276
 						$this->errors[$record_num] = $this->bocontacts->error;
251
-					} else {
277
+					}
278
+					else
279
+					{
252 280
 						$this->results[$_action]++;
253 281
 					}
254 282
 					return $result;
@@ -302,7 +330,8 @@  discard block
 block discarded – undo
302 330
 	 *
303 331
 	 * @return string name
304 332
 	 */
305
-	public static function get_name() {
333
+	public static function get_name()
334
+	{
306 335
 		return lang('Addressbook vCard import');
307 336
 	}
308 337
 
@@ -311,7 +340,8 @@  discard block
 block discarded – undo
311 340
 	 *
312 341
 	 * @return string descriprion
313 342
 	 */
314
-	public static function get_description() {
343
+	public static function get_description()
344
+	{
315 345
 		return lang("Imports contacts into your Addressbook from a vCard File. ");
316 346
 	}
317 347
 
@@ -320,7 +350,8 @@  discard block
 block discarded – undo
320 350
 	 *
321 351
 	 * @return string suffix (comma seperated)
322 352
 	 */
323
-	public static function get_filesuffix() {
353
+	public static function get_filesuffix()
354
+	{
324 355
 		return 'vcf';
325 356
 	}
326 357
 
@@ -336,7 +367,8 @@  discard block
 block discarded – undo
336 367
 	 * 		preserv		=> array,
337 368
 	 * )
338 369
 	 */
339
-	public function get_options_etpl() {
370
+	public function get_options_etpl()
371
+	{
340 372
 		// lets do it!
341 373
 	}
342 374
 
@@ -345,7 +377,8 @@  discard block
 block discarded – undo
345 377
 	 *
346 378
 	 * @return string etemplate name
347 379
 	 */
348
-	public function get_selectors_etpl() {
380
+	public function get_selectors_etpl()
381
+	{
349 382
 		// lets do it!
350 383
 	}
351 384
 
@@ -357,7 +390,8 @@  discard block
 block discarded – undo
357 390
         *       record_# => warning message
358 391
         *       )
359 392
         */
360
-        public function get_warnings() {
393
+        public function get_warnings()
394
+        {
361 395
 		return $this->warnings;
362 396
 	}
363 397
 
@@ -369,7 +403,8 @@  discard block
 block discarded – undo
369 403
         *       record_# => error message
370 404
         *       )
371 405
         */
372
-        public function get_errors() {
406
+        public function get_errors()
407
+        {
373 408
 		return $this->errors;
374 409
 	}
375 410
 
@@ -381,7 +416,8 @@  discard block
 block discarded – undo
381 416
         *       action => record count
382 417
         * )
383 418
         */
384
-        public function get_results() {
419
+        public function get_results()
420
+        {
385 421
                 return $this->results;
386 422
         }
387 423
 }
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   +83 added lines, -84 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,17 +33,17 @@  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 '--edit-alias':
49 49
 	case '--edit-forward':
@@ -54,17 +54,17 @@  discard block
 block discarded – undo
54 54
 		return do_change_pw($arg0s);
55 55
 
56 56
 	case '--delete-user':
57
-		return do_delete_account($arg0s[2],$arg0s[3]);
57
+		return do_delete_account($arg0s[2], $arg0s[3]);
58 58
 
59 59
 	case '--edit-group':
60 60
 		return do_edit_group($arg0s);
61 61
 
62 62
 	case '--delete-group':
63
-		return do_delete_account($arg0s[2],0,false);
63
+		return do_delete_account($arg0s[2], 0, false);
64 64
 
65 65
 	case '--allow-app':
66 66
 	case '--deny-app':
67
-		return do_account_app($arg0s,$action == '--allow-app');
67
+		return do_account_app($arg0s, $action == '--allow-app');
68 68
 
69 69
 	case '--change-account-id':
70 70
 		return do_change_account_id($arg0s);
@@ -84,21 +84,21 @@  discard block
 block discarded – undo
84 84
 
85 85
 	default:
86 86
 		// we allow to call admin_cmd classes directly, if they define the constant SETUP_CLI_CALLABLE
87
-		if (substr($action,0,2) == '--' && class_exists($class = str_replace('-','_',substr($action,2))) &&
88
-			is_subclass_of($class,'admin_cmd') && @constant($class.'::SETUP_CLI_CALLABLE'))
87
+		if (substr($action, 0, 2) == '--' && class_exists($class = str_replace('-', '_', substr($action, 2))) &&
88
+			is_subclass_of($class, 'admin_cmd') && @constant($class.'::SETUP_CLI_CALLABLE'))
89 89
 		{
90 90
 			$args = array();
91
-			$args['domain'] = array_shift($arg0s);	// domain must be first argument, to ensure right domain get's selected in header-include
92
-			foreach($arg0s as $arg)
91
+			$args['domain'] = array_shift($arg0s); // domain must be first argument, to ensure right domain get's selected in header-include
92
+			foreach ($arg0s as $arg)
93 93
 			{
94
-				list($name,$value) = explode('=',$arg,2);
95
-				if(property_exists('admin_cmd',$name))		// dont allow to overwrite admin_cmd properties
94
+				list($name, $value) = explode('=', $arg, 2);
95
+				if (property_exists('admin_cmd', $name))		// dont allow to overwrite admin_cmd properties
96 96
 				{
97
-					throw new Api\Exception\WrongUserinput(lang("Invalid argument '%1' !!!",$arg),90);
97
+					throw new Api\Exception\WrongUserinput(lang("Invalid argument '%1' !!!", $arg), 90);
98 98
 				}
99
-				if (substr($name,-1) == ']')	// allow 1-dim. arrays
99
+				if (substr($name, -1) == ']')	// allow 1-dim. arrays
100 100
 				{
101
-					list($name,$sub) = explode('[',substr($name,0,-1),2);
101
+					list($name, $sub) = explode('[', substr($name, 0, -1), 2);
102 102
 					$args[$name][$sub] = $value;
103 103
 				}
104 104
 				else
@@ -122,12 +122,12 @@  discard block
 block discarded – undo
122 122
  */
123 123
 function run_command(admin_cmd $cmd)
124 124
 {
125
-	global $arguments,$user,$arg0s,$domain;
125
+	global $arguments, $user, $arg0s, $domain;
126 126
 
127 127
 	$skip_checks = false;
128 128
 	while ($arguments && ($extra = array_shift($arguments)))
129 129
 	{
130
-		switch($extra)
130
+		switch ($extra)
131 131
 		{
132 132
 			case '--schedule':	// schedule the command instead of running it directly
133 133
 				$time = admin_cmd::parse_date(array_shift($arguments));
@@ -157,15 +157,15 @@  discard block
 block discarded – undo
157 157
 			case '--header-access':
158 158
 				if ($cmd instanceof setup_cmd)
159 159
 				{
160
-					list($user,$pw) = explode(',',array_shift($arguments),2);
161
-					$cmd->set_header_secret($user,$pw);
160
+					list($user, $pw) = explode(',', array_shift($arguments), 2);
161
+					$cmd->set_header_secret($user, $pw);
162 162
 				}
163 163
 				break;
164 164
 
165 165
 			default:
166 166
 				//fail(99,lang('Unknown option %1',$extra);
167
-				echo lang('Unknown option %1',$extra)."\n\n";
168
-				usage('',99);
167
+				echo lang('Unknown option %1', $extra)."\n\n";
168
+				usage('', 99);
169 169
 				break;
170 170
 		}
171 171
 	}
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 		{
185 185
 			$url = $GLOBALS['egw_info']['server']['webserver_url'].'/json.php?menuaction=admin.admin_hooks.ajax_clear_cache';
186 186
 			if ($url[0] == '/') $url = 'http://'.(!empty($domain) && $domain != 'default' ? $domain : 'localhost').$url;
187
-			$data = file_get_contents($url, false, Framework::proxy_context($user,$arg0s[1]));
187
+			$data = file_get_contents($url, false, Framework::proxy_context($user, $arg0s[1]));
188 188
 			//error_log("file_get_contents('$url') returned ".array2string($data));
189 189
 			if ($data && strpos($data, '"success"') !== false)
190 190
 			{
@@ -223,13 +223,13 @@  discard block
 block discarded – undo
223 223
 	{
224 224
 		//fail(1,lang("Wrong admin-account or -password !!!"));
225 225
 		echo lang("Wrong admin-account or -password !!!")."\n\n";
226
-		usage('',1);
226
+		usage('', 1);
227 227
 	}
228 228
 	if (!$GLOBALS['egw_info']['user']['apps']['admin'])	// will be tested by the header too, but whould give html error-message
229 229
 	{
230 230
 		//fail(2,lang("Permission denied !!!"));
231 231
 		echo lang("Permission denied !!!")."\n\n";
232
-		usage('',2);
232
+		usage('', 2);
233 233
 	}
234 234
 	return $sessionid;
235 235
 }
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
  * @param string $passwd
242 242
  * @param string $domain
243 243
  */
244
-function load_egw($user,$passwd,$domain='default')
244
+function load_egw($user, $passwd, $domain = 'default')
245 245
 {
246 246
 	//echo "load_egw($user,$passwd,$domain)\n";
247 247
 	$_REQUEST['domain'] = $domain;
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
 
254 254
 	if (ini_get('session.save_handler') == 'files' && !is_writable(ini_get('session.save_path')) && is_dir('/tmp') && is_writable('/tmp'))
255 255
 	{
256
-		ini_set('session.save_path','/tmp');	// regular users may have no rights to apache's session dir
256
+		ini_set('session.save_path', '/tmp'); // regular users may have no rights to apache's session dir
257 257
 	}
258 258
 
259 259
 	$GLOBALS['egw_info'] = array(
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
 		)
266 266
 	);
267 267
 
268
-	if (substr($user,0,5) != 'root_')
268
+	if (substr($user, 0, 5) != 'root_')
269 269
 	{
270 270
 		include('../header.inc.php');
271 271
 	}
@@ -275,9 +275,9 @@  discard block
 block discarded – undo
275 275
 		include('../header.inc.php');
276 276
 
277 277
 		if ($user == 'root_'.$GLOBALS['egw_info']['server']['header_admin_user'] &&
278
-			_check_pw($GLOBALS['egw_info']['server']['header_admin_password'],$passwd) ||
278
+			_check_pw($GLOBALS['egw_info']['server']['header_admin_password'], $passwd) ||
279 279
 			$user == 'root_'.$GLOBALS['egw_domain'][$_GET['domain']]['config_user'] &&
280
-			_check_pw($GLOBALS['egw_domain'][$_GET['domain']]['config_passwd'],$passwd))
280
+			_check_pw($GLOBALS['egw_domain'][$_GET['domain']]['config_passwd'], $passwd))
281 281
 		{
282 282
 			echo "\nRoot access granted!\n";
283 283
 			Vfs::$is_root = true;
@@ -296,10 +296,10 @@  discard block
 block discarded – undo
296 296
  * @param string $pw
297 297
  * @return boolean
298 298
  */
299
-function _check_pw($hash_or_cleartext,$pw)
299
+function _check_pw($hash_or_cleartext, $pw)
300 300
 {
301 301
 	//echo "_check_pw($hash_or_cleartext,$pw) md5=".md5($pw)."\n";
302
-	if (preg_match('/^[0-9a-f]{32}$/',$hash_or_cleartext))
302
+	if (preg_match('/^[0-9a-f]{32}$/', $hash_or_cleartext))
303 303
 	{
304 304
 		return $hash_or_cleartext == md5($pw);
305 305
 	}
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
  * @param string $action =null
313 313
  * @param int $ret =0 exit-code
314 314
  */
315
-function usage($action=null,$ret=0)
315
+function usage($action = null, $ret = 0)
316 316
 {
317 317
 	unset($action);
318 318
 	$cmd = basename($_SERVER['argv'][0]);
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
 function do_edit_mail($type, array $arg0s)
366 366
 {
367 367
 	array_shift($arg0s); // admin-account
368
-	array_shift($arg0s);	// admin-pw
368
+	array_shift($arg0s); // admin-pw
369 369
 	list($account, $acc_id) = explode('=', array_shift($arg0s));
370 370
 	$account_id = is_numeric($account) ? (int)$account : $GLOBALS['egw']->accounts->name2id($account);
371 371
 	if (!$GLOBALS['egw']->accounts->exists($account_id) && !($account_id = $GLOBALS['egw']->accounts->name2id($account)))
@@ -374,18 +374,17 @@  discard block
 block discarded – undo
374 374
 		exit(1);
375 375
 	}
376 376
 	$found = 0;
377
-	foreach($acc_id ? array(Api\Mail\Account::read($acc_id, $account_id)) :
378
-		Api\Mail\Account::search($account_id, false) as $account)
377
+	foreach ($acc_id ? array(Api\Mail\Account::read($acc_id, $account_id)) : Api\Mail\Account::search($account_id, false) as $account)
379 378
 	{
380
-		if (!isset($acc_id) && !Api\Mail\Account::is_multiple($account)) continue;	// no need to waste time on personal accounts
379
+		if (!isset($acc_id) && !Api\Mail\Account::is_multiple($account)) continue; // no need to waste time on personal accounts
381 380
 
382 381
 		$args = $arg0s;
383 382
 		try {
384 383
 			if (!($data = $account->getUserData($account_id)))
385 384
 			{
386
-				continue;	// not a managed mail-server
385
+				continue; // not a managed mail-server
387 386
 			}
388
-			switch($type)
387
+			switch ($type)
389 388
 			{
390 389
 				case 'alias':
391 390
 					$create_identity = strtolower(array_shift($args)) === 'yes';
@@ -408,7 +407,7 @@  discard block
 block discarded – undo
408 407
 			if ($type == 'alias' && $create_identity && $args)
409 408
 			{
410 409
 				// check if user allready has an identity created for given aliases
411
-				foreach(Api\Mail\Account::identities($account, false, 'ident_email', $account_id) as $ident_id => $email)
410
+				foreach (Api\Mail\Account::identities($account, false, 'ident_email', $account_id) as $ident_id => $email)
412 411
 				{
413 412
 					if (($key = array_search($email, $args)) !== false)
414 413
 					{
@@ -421,19 +420,19 @@  discard block
 block discarded – undo
421 420
 					}
422 421
 				}
423 422
 				// create not existing identities by copying standard identity plus alias as email
424
-				foreach($args as $email)
423
+				foreach ($args as $email)
425 424
 				{
426 425
 					$identity = $account->params;
427 426
 					unset($identity['ident_id']);
428 427
 					unset($identity['ident_name']);
429 428
 					$identity['ident_email'] = $email;
430
-					$identity['account_id'] = $account_id;	// make this a personal identity for $account_id
429
+					$identity['account_id'] = $account_id; // make this a personal identity for $account_id
431 430
 					Api\Mail\Account::save_identity($identity);
432 431
 				}
433 432
 				if ($args) echo "Identity(s) for ".implode(', ', $args)." created.\n";
434 433
 			}
435 434
 		}
436
-		catch(\Exception $e) {
435
+		catch (\Exception $e) {
437 436
 			_egw_log_exception($e);
438 437
 			echo $e->getMessage()."\n";
439 438
 		}
@@ -458,7 +457,7 @@  discard block
 block discarded – undo
458 457
 {
459 458
 	if (!is_array($arr)) $arr = array();
460 459
 
461
-	switch($mod[0][0])
460
+	switch ($mod[0][0])
462 461
 	{
463 462
 		case '-':
464 463
 			$mod[0] = substr($mod[0], 1);
@@ -483,14 +482,14 @@  discard block
 block discarded – undo
483 482
  * @param boolean $allow true=allow, false=deny
484 483
  * @return int 0 on success
485 484
  */
486
-function do_account_app($args,$allow)
485
+function do_account_app($args, $allow)
487 486
 {
488
-	array_shift($args);	// admin-account
489
-	array_shift($args);	// admin-pw
487
+	array_shift($args); // admin-account
488
+	array_shift($args); // admin-pw
490 489
 	$account = array_shift($args);
491 490
 
492 491
 	include_once(EGW_INCLUDE_ROOT.'/admin/inc/class.admin_cmd_account_app.inc.php');
493
-	run_command(new admin_cmd_account_app($allow,$account,$args));
492
+	run_command(new admin_cmd_account_app($allow, $account, $args));
494 493
 }
495 494
 
496 495
 /**
@@ -500,9 +499,9 @@  discard block
 block discarded – undo
500 499
  */
501 500
 function do_edit_group($args)
502 501
 {
503
-	array_shift($args);	// admin-account
504
-	array_shift($args);	// admin-pw
505
-	list($account,$new_account_name) = explode('=',array_shift($args));	// account[=new-account-name]
502
+	array_shift($args); // admin-account
503
+	array_shift($args); // admin-pw
504
+	list($account, $new_account_name) = explode('=', array_shift($args)); // account[=new-account-name]
506 505
 
507 506
 	$data = array(
508 507
 		'account_lid' => $new_account_name,
@@ -510,19 +509,19 @@  discard block
 block discarded – undo
510 509
 		'account_members' => $args,
511 510
 	);
512 511
 	try {
513
-		admin_cmd::parse_account($account,false);
512
+		admin_cmd::parse_account($account, false);
514 513
 
515
-		foreach($data as &$value)	// existing account --> empty values mean dont change, not set them empty!
514
+		foreach ($data as &$value)	// existing account --> empty values mean dont change, not set them empty!
516 515
 		{
517 516
 			if ((string)$value === '') $value = null;
518 517
 		}
519 518
 	}
520 519
 	catch (Exception $e) {	// new group
521
-		unset($e);	// not used
520
+		unset($e); // not used
522 521
 		$data['account_lid'] = $account;
523 522
 		$account = false;
524 523
 	}
525
-	run_command(new admin_cmd_edit_group($account,$data));
524
+	run_command(new admin_cmd_edit_group($account, $data));
526 525
 }
527 526
 
528 527
 /**
@@ -532,12 +531,12 @@  discard block
 block discarded – undo
532 531
  */
533 532
 function do_change_pw($args)
534 533
 {
535
-	array_shift($args);     // admin-account
536
-	array_shift($args);     // admin-pw
537
-	$account = array_shift($args);	// account
538
-	$password = array_shift($args);	// pw
534
+	array_shift($args); // admin-account
535
+	array_shift($args); // admin-pw
536
+	$account = array_shift($args); // account
537
+	$password = array_shift($args); // pw
539 538
 
540
-	run_command(new admin_cmd_change_pw($account,$password));
539
+	run_command(new admin_cmd_change_pw($account, $password));
541 540
 }
542 541
 
543 542
 /**
@@ -546,18 +545,18 @@  discard block
 block discarded – undo
546 545
  * @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]
547 546
  * @param boolean $run_addaccount_hook =null default run hook depending on account existence, true=allways run addaccount hook
548 547
  */
549
-function do_edit_user($args,$run_addaccount_hook=null)
548
+function do_edit_user($args, $run_addaccount_hook = null)
550 549
 {
551
-	array_shift($args);	// admin-account
552
-	array_shift($args);	// admin-pw
553
-	list($account,$new_account_name) = explode('=',array_shift($args));	// account[=new-account-name]
550
+	array_shift($args); // admin-account
551
+	array_shift($args); // admin-pw
552
+	list($account, $new_account_name) = explode('=', array_shift($args)); // account[=new-account-name]
554 553
 
555 554
 	$data = array();
556 555
 	// do we need to support ldap only attributes: homedirectory and loginshell
557 556
 	if (($GLOBALS['egw_info']['server']['account_repository'] == 'ldap' ||
558 557
 		 empty($GLOBALS['egw_info']['server']['account_repository']) && $GLOBALS['egw_info']['server']['auth_type'] == 'ldap') &&
559
-		$GLOBALS['egw_info']['server']['ldap_extra_attributes'] && count($args) > 9 &&	// 9 = primary group
560
-		($last_arg = array_pop($dummy=$args)) && $last_arg[0] == '/')	// last argument start with a slash
558
+		$GLOBALS['egw_info']['server']['ldap_extra_attributes'] && count($args) > 9 && // 9 = primary group
559
+		($last_arg = array_pop($dummy = $args)) && $last_arg[0] == '/')	// last argument start with a slash
561 560
 	{
562 561
 		$data['loginshell'] = array_pop($args);
563 562
 		$data['homedirectory'] = array_pop($args);
@@ -575,19 +574,19 @@  discard block
 block discarded – undo
575 574
 		'account_groups' => $args,
576 575
 	);
577 576
 	try {
578
-		admin_cmd::parse_account($account,true);
577
+		admin_cmd::parse_account($account, true);
579 578
 
580
-		foreach($data as &$value)	// existing account --> empty values mean dont change, not set them empty!
579
+		foreach ($data as &$value)	// existing account --> empty values mean dont change, not set them empty!
581 580
 		{
582 581
 			if ((string)$value === '') $value = null;
583 582
 		}
584 583
 	}
585 584
 	catch (Exception $e) {	// new account
586
-		unset($e);	// not used
585
+		unset($e); // not used
587 586
 		$data['account_lid'] = $account;
588 587
 		$account = false;
589 588
 	}
590
-	run_command(new admin_cmd_edit_user($account,$data,null,$run_addaccount_hook));
589
+	run_command(new admin_cmd_edit_user($account, $data, null, $run_addaccount_hook));
591 590
 }
592 591
 
593 592
 /**
@@ -598,9 +597,9 @@  discard block
 block discarded – undo
598 597
  * @param boolean $is_user =true are we called for a user or group
599 598
  * @return int 0 on success, 2-4 otherwise (see source)
600 599
  */
601
-function do_delete_account($account,$new_user=0,$is_user=true)
600
+function do_delete_account($account, $new_user = 0, $is_user = true)
602 601
 {
603
-	run_command(new admin_cmd_delete_account($account,$new_user,$is_user));
602
+	run_command(new admin_cmd_delete_account($account, $new_user, $is_user));
604 603
 }
605 604
 
606 605
 /**
@@ -621,13 +620,13 @@  discard block
 block discarded – undo
621 620
  */
622 621
 function do_change_account_id($args)
623 622
 {
624
-	if (count($args) < 4) usage();	// 4 means at least user,pw,from1,to1
623
+	if (count($args) < 4) usage(); // 4 means at least user,pw,from1,to1
625 624
 
626 625
 	$ids2change = array();
627
-	for($n = 2; $n < count($args); $n += 2)
626
+	for ($n = 2; $n < count($args); $n += 2)
628 627
 	{
629 628
 		$from = (int)$args[$n];
630
-		$to   = (int)$args[$n+1];
629
+		$to   = (int)$args[$n + 1];
631 630
 		$ids2change[$from] = $to;
632 631
 	}
633 632
 	run_command(new admin_cmd_change_account_id($ids2change));
@@ -643,22 +642,22 @@  discard block
 block discarded – undo
643 642
  */
644 643
 function list_exit_codes()
645 644
 {
646
-	error_reporting(error_reporting() & ~E_NOTICE);
645
+	error_reporting(error_reporting()&~E_NOTICE);
647 646
 
648 647
 	$codes = array('Ok');
649
-	foreach(file(__FILE__) as $line)
648
+	foreach (file(__FILE__) as $line)
650 649
 	{
651 650
 		$matches = null;
652
-		if (preg_match('/fail\(([0-9]+),(.*)\);/',$line,$matches))
651
+		if (preg_match('/fail\(([0-9]+),(.*)\);/', $line, $matches))
653 652
 		{
654 653
 			//echo "Line $n: $matches[1]: $matches[2]\n";
655 654
 			@eval('$codes['.$matches[1].'] = '.$matches[2].';');
656 655
 		}
657 656
 	}
658
-	ksort($codes,SORT_NUMERIC);
659
-	foreach($codes as $num => $msg)
657
+	ksort($codes, SORT_NUMERIC);
658
+	foreach ($codes as $num => $msg)
660 659
 	{
661
-		echo $num."\t".str_replace("\n","\n\t",$msg)."\n";
660
+		echo $num."\t".str_replace("\n", "\n\t", $msg)."\n";
662 661
 	}
663 662
 }
664 663
 
@@ -668,7 +667,7 @@  discard block
 block discarded – undo
668 667
  * @param array $args admin-account[@domain],admin-password,accout_lid[,pw]
669 668
  * @return int 0 on success
670 669
  */
671
-function do_subscribe_other($account_lid,$pw=null)
670
+function do_subscribe_other($account_lid, $pw = null)
672 671
 {
673 672
 	unset($account_lid, $pw);
674 673
 	/* ToDo: this cant work, not even in 14.x
Please login to merge, or discard this patch.
Braces   +50 added lines, -12 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 || $_SERVER['argc'] == 2 && in_array($_SERVER['argv'][1], array('-h', '--help')))
25 28
 {
26 29
 	usage();
@@ -92,13 +95,19 @@  discard block
 block discarded – undo
92 95
 			foreach($arg0s as $arg)
93 96
 			{
94 97
 				list($name,$value) = explode('=',$arg,2);
95
-				if(property_exists('admin_cmd',$name))		// dont allow to overwrite admin_cmd properties
98
+				if(property_exists('admin_cmd',$name))
99
+				{
100
+					// dont allow to overwrite admin_cmd properties
96 101
 				{
97 102
 					throw new Api\Exception\WrongUserinput(lang("Invalid argument '%1' !!!",$arg),90);
98 103
 				}
99
-				if (substr($name,-1) == ']')	// allow 1-dim. arrays
104
+				}
105
+				if (substr($name,-1) == ']')
106
+				{
107
+					// allow 1-dim. arrays
100 108
 				{
101 109
 					list($name,$sub) = explode('[',substr($name,0,-1),2);
110
+				}
102 111
 					$args[$name][$sub] = $value;
103 112
 				}
104 113
 				else
@@ -183,7 +192,10 @@  discard block
 block discarded – undo
183 192
 		if (!$dry_run)
184 193
 		{
185 194
 			$url = $GLOBALS['egw_info']['server']['webserver_url'].'/json.php?menuaction=admin.admin_hooks.ajax_clear_cache';
186
-			if ($url[0] == '/') $url = 'http://'.(!empty($domain) && $domain != 'default' ? $domain : 'localhost').$url;
195
+			if ($url[0] == '/')
196
+			{
197
+				$url = 'http://'.(!empty($domain) && $domain != 'default' ? $domain : 'localhost').$url;
198
+			}
187 199
 			$data = file_get_contents($url, false, Framework::proxy_context($user,$arg0s[1]));
188 200
 			//error_log("file_get_contents('$url') returned ".array2string($data));
189 201
 			if ($data && strpos($data, '"success"') !== false)
@@ -225,10 +237,13 @@  discard block
 block discarded – undo
225 237
 		echo lang("Wrong admin-account or -password !!!")."\n\n";
226 238
 		usage('',1);
227 239
 	}
228
-	if (!$GLOBALS['egw_info']['user']['apps']['admin'])	// will be tested by the header too, but whould give html error-message
240
+	if (!$GLOBALS['egw_info']['user']['apps']['admin'])
241
+	{
242
+		// will be tested by the header too, but whould give html error-message
229 243
 	{
230 244
 		//fail(2,lang("Permission denied !!!"));
231 245
 		echo lang("Permission denied !!!")."\n\n";
246
+	}
232 247
 		usage('',2);
233 248
 	}
234 249
 	return $sessionid;
@@ -377,7 +392,11 @@  discard block
 block discarded – undo
377 392
 	foreach($acc_id ? array(Api\Mail\Account::read($acc_id, $account_id)) :
378 393
 		Api\Mail\Account::search($account_id, false) as $account)
379 394
 	{
380
-		if (!isset($acc_id) && !Api\Mail\Account::is_multiple($account)) continue;	// no need to waste time on personal accounts
395
+		if (!isset($acc_id) && !Api\Mail\Account::is_multiple($account))
396
+		{
397
+			continue;
398
+		}
399
+		// no need to waste time on personal accounts
381 400
 
382 401
 		$args = $arg0s;
383 402
 		try {
@@ -430,7 +449,10 @@  discard block
 block discarded – undo
430 449
 					$identity['account_id'] = $account_id;	// make this a personal identity for $account_id
431 450
 					Api\Mail\Account::save_identity($identity);
432 451
 				}
433
-				if ($args) echo "Identity(s) for ".implode(', ', $args)." created.\n";
452
+				if ($args)
453
+				{
454
+					echo "Identity(s) for ".implode(', ', $args)." created.\n";
455
+				}
434 456
 			}
435 457
 		}
436 458
 		catch(\Exception $e) {
@@ -456,7 +478,10 @@  discard block
 block discarded – undo
456 478
  */
457 479
 function array_modify(&$arr, array &$mod)
458 480
 {
459
-	if (!is_array($arr)) $arr = array();
481
+	if (!is_array($arr))
482
+	{
483
+		$arr = array();
484
+	}
460 485
 
461 486
 	switch($mod[0][0])
462 487
 	{
@@ -512,10 +537,13 @@  discard block
 block discarded – undo
512 537
 	try {
513 538
 		admin_cmd::parse_account($account,false);
514 539
 
515
-		foreach($data as &$value)	// existing account --> empty values mean dont change, not set them empty!
540
+		foreach($data as &$value)
541
+		{
542
+			// existing account --> empty values mean dont change, not set them empty!
516 543
 		{
517 544
 			if ((string)$value === '') $value = null;
518 545
 		}
546
+		}
519 547
 	}
520 548
 	catch (Exception $e) {	// new group
521 549
 		unset($e);	// not used
@@ -557,9 +585,12 @@  discard block
 block discarded – undo
557 585
 	if (($GLOBALS['egw_info']['server']['account_repository'] == 'ldap' ||
558 586
 		 empty($GLOBALS['egw_info']['server']['account_repository']) && $GLOBALS['egw_info']['server']['auth_type'] == 'ldap') &&
559 587
 		$GLOBALS['egw_info']['server']['ldap_extra_attributes'] && count($args) > 9 &&	// 9 = primary group
560
-		($last_arg = array_pop($dummy=$args)) && $last_arg[0] == '/')	// last argument start with a slash
588
+		($last_arg = array_pop($dummy=$args)) && $last_arg[0] == '/')
589
+	{
590
+		// last argument start with a slash
561 591
 	{
562 592
 		$data['loginshell'] = array_pop($args);
593
+	}
563 594
 		$data['homedirectory'] = array_pop($args);
564 595
 	}
565 596
 	$data += array(
@@ -577,10 +608,13 @@  discard block
 block discarded – undo
577 608
 	try {
578 609
 		admin_cmd::parse_account($account,true);
579 610
 
580
-		foreach($data as &$value)	// existing account --> empty values mean dont change, not set them empty!
611
+		foreach($data as &$value)
612
+		{
613
+			// existing account --> empty values mean dont change, not set them empty!
581 614
 		{
582 615
 			if ((string)$value === '') $value = null;
583 616
 		}
617
+		}
584 618
 	}
585 619
 	catch (Exception $e) {	// new account
586 620
 		unset($e);	// not used
@@ -621,7 +655,11 @@  discard block
 block discarded – undo
621 655
  */
622 656
 function do_change_account_id($args)
623 657
 {
624
-	if (count($args) < 4) usage();	// 4 means at least user,pw,from1,to1
658
+	if (count($args) < 4)
659
+	{
660
+		usage();
661
+	}
662
+	// 4 means at least user,pw,from1,to1
625 663
 
626 664
 	$ids2change = array();
627 665
 	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.
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.
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 or delete (via context menu) Categories for the selected app (backend restriction)
430
-			if($row['appname'] != $query['appname'])
430
+			if ($row['appname'] != $query['appname'])
431 431
 			{
432 432
 				$row['class'] .= ' rowNoEdit rowNoDelete ';
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.
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
@@ -22,14 +22,14 @@  discard block
 block discarded – undo
22 22
 	const successful = 2;
23 23
 	const failed     = 3;
24 24
 	const pending    = 4;
25
-	const queued     = 5;	// command waits to be fetched from remote
25
+	const queued     = 5; // command waits to be fetched from remote
26 26
 
27 27
 	/**
28 28
 	 * Status which stil need passwords available
29 29
 	 *
30 30
 	 * @var array
31 31
 	 */
32
-	static $require_pw_stati = array(self::scheduled,self::pending,self::queued);
32
+	static $require_pw_stati = array(self::scheduled, self::pending, self::queued);
33 33
 
34 34
 	/**
35 35
 	 * The status of the command, one of either scheduled, successful, failed or deleted
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 	 * @return string success message
112 112
 	 * @throws Exception()
113 113
 	 */
114
-	protected abstract function exec($check_only=false);
114
+	protected abstract function exec($check_only = false);
115 115
 
116 116
 	/**
117 117
 	 * Return a title / string representation for a given command, eg. to display it
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 
149 149
 		$this->type = get_class($this);
150 150
 
151
-		foreach($data as $name => $value)
151
+		foreach ($data as $name => $value)
152 152
 		{
153 153
 			$this->$name = $name == 'data' && !is_array($value) ? json_php_unserialize($value) : $value;
154 154
 		}
@@ -167,13 +167,13 @@  discard block
 block discarded – undo
167 167
 	 * @return mixed return value of the command
168 168
 	 * @throws Exceptions on error
169 169
 	 */
170
-	function run($time=null,$set_modifier=true,$skip_checks=false,$dry_run=false)
170
+	function run($time = null, $set_modifier = true, $skip_checks = false, $dry_run = false)
171 171
 	{
172 172
 		if (!is_null($time))
173 173
 		{
174 174
 			$this->scheduled = $time;
175 175
 			$this->status = admin_cmd::scheduled;
176
-			$ret = lang('Command scheduled to run at %1',date('Y-m-d H:i',$time));
176
+			$ret = lang('Command scheduled to run at %1', date('Y-m-d H:i', $time));
177 177
 			// running the checks of the arguments for local commands, if not explicitly requested to not run them
178 178
 			if (!$this->remote_id && !$skip_checks)
179 179
 			{
@@ -236,21 +236,21 @@  discard block
 block discarded – undo
236 236
 	{
237 237
 		if (!($remote = $this->read_remote($this->remote_id)))
238 238
 		{
239
-			throw new Api\Exception\WrongUserinput(lang('Invalid remote id or name "%1"!',$this->remote_id),997);
239
+			throw new Api\Exception\WrongUserinput(lang('Invalid remote id or name "%1"!', $this->remote_id), 997);
240 240
 		}
241 241
 		if (!$this->uid)
242 242
 		{
243
-			$this->save();	// to get the uid
243
+			$this->save(); // to get the uid
244 244
 		}
245 245
 		$secret = md5($this->uid.$remote['remote_hash']);
246 246
 
247 247
 		$postdata = $this->as_array();
248 248
 		if (is_object($GLOBALS['egw']->translation))
249 249
 		{
250
-			$postdata = Api\Translation::convert($postdata,Api\Translation::charset(),'utf-8');
250
+			$postdata = Api\Translation::convert($postdata, Api\Translation::charset(), 'utf-8');
251 251
 		}
252 252
 		// dont send the id's which have no meaning on the remote install
253
-		foreach(array('id','creator','modifier','requested','remote_id') as $name)
253
+		foreach (array('id', 'creator', 'modifier', 'requested', 'remote_id') as $name)
254 254
 		{
255 255
 			unset($postdata[$name]);
256 256
 		}
@@ -276,12 +276,12 @@  discard block
 block discarded – undo
276 276
 		}
277 277
 		if (is_object($GLOBALS['egw']->translation))
278 278
 		{
279
-			$message = Api\Translation::convert($message,'utf-8');
279
+			$message = Api\Translation::convert($message, 'utf-8');
280 280
 		}
281 281
 		$matches = null;
282
-		if (is_string($message) && preg_match('/^([0-9]+) (.*)$/',$message,$matches))
282
+		if (is_string($message) && preg_match('/^([0-9]+) (.*)$/', $message, $matches))
283 283
 		{
284
-			throw new Api\Exception($matches[2],(int)$matches[1]);
284
+			throw new Api\Exception($matches[2], (int)$matches[1]);
285 285
 		}
286 286
 		return $message;
287 287
 	}
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
 	 * @param boolean $set_modifier =true set the current user as modifier or 0 (= run by the system)
307 307
 	 * @return boolean true on success, false otherwise
308 308
 	 */
309
-	function save($set_modifier=true)
309
+	function save($set_modifier = true)
310 310
 	{
311 311
 		admin_cmd::_instanciate_sql();
312 312
 
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
 			$this->modifier = $set_modifier ? $GLOBALS['egw_info']['user']['account_id'] : 0;
322 322
 			if ($set_modifier) $this->modifier_email = admin_cmd::user_email();
323 323
 		}
324
-		$vars = get_object_vars($this);	// does not work in php5.1.2 due a bug
324
+		$vars = get_object_vars($this); // does not work in php5.1.2 due a bug
325 325
 
326 326
 		// data is stored serialized
327 327
 		// paswords are masked / removed, if we dont need them anymore
@@ -358,13 +358,13 @@  discard block
 block discarded – undo
358 358
 	 * @param boolean $return_serialized =true true: return json serialized string, false: return array
359 359
 	 * @return string|array see $return_serialized
360 360
 	 */
361
-	static function mask_passwords($data, $return_serialized=true)
361
+	static function mask_passwords($data, $return_serialized = true)
362 362
 	{
363 363
 		if (!is_array($data))
364 364
 		{
365 365
 			$data = json_php_unserialize($data);
366 366
 		}
367
-		foreach($data as $key => &$value)
367
+		foreach ($data as $key => &$value)
368 368
 		{
369 369
 			if (is_array($value))
370 370
 			{
@@ -412,10 +412,10 @@  discard block
 block discarded – undo
412 412
 		{
413 413
 			$data['data'] = json_php_unserialize($data['data']);
414 414
 		}
415
-		if (!(class_exists($class = 'EGroupware\\'.$data['type']) ||	// namespaced class
415
+		if (!(class_exists($class = 'EGroupware\\'.$data['type']) || // namespaced class
416 416
 			class_exists($class = $data['type'])) || $data['type'] == 'admin_cmd')
417 417
 		{
418
-			throw new Api\Exception\WrongParameter(lang('Unknown command %1!',$class),0);
418
+			throw new Api\Exception\WrongParameter(lang('Unknown command %1!', $class), 0);
419 419
 		}
420 420
 		$cmd = new $class($data);
421 421
 
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
 		{
424 424
 			return $cmd;
425 425
 		}
426
-		throw new Api\Exception\WrongParameter(lang('%1 is no command!',$class),0);
426
+		throw new Api\Exception\WrongParameter(lang('%1 is no command!', $class), 0);
427 427
 	}
428 428
 
429 429
 	/**
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
 	 * @param array $readonlys
436 436
 	 * @return int
437 437
 	 */
438
-	static function get_rows($query,&$rows,$readonlys)
438
+	static function get_rows($query, &$rows, $readonlys)
439 439
 	{
440 440
 		admin_cmd::_instanciate_sql();
441 441
 
@@ -443,7 +443,7 @@  discard block
 block discarded – undo
443 443
 		{
444 444
 			$query['col_filter']['remote_id'] = null;
445 445
 		}
446
-		return admin_cmd::$sql->get_rows($query,$rows,$readonlys);
446
+		return admin_cmd::$sql->get_rows($query, $rows, $readonlys);
447 447
 	}
448 448
 
449 449
 	/**
@@ -460,7 +460,7 @@  discard block
 block discarded – undo
460 460
 			$labels = admin_cmd::$sql->query_list('cmd_type');
461 461
 
462 462
 			// for admin app we also add all available cmd objects
463
-			foreach(scandir(__DIR__) as $file)
463
+			foreach (scandir(__DIR__) as $file)
464 464
 			{
465 465
 				$matches = null;
466 466
 				if (preg_match('/^class\.(admin_cmd_.*)\.inc\.php$/', $file, $matches))
@@ -471,7 +471,7 @@  discard block
 block discarded – undo
471 471
 					}
472 472
 				}
473 473
 			}
474
-			foreach($labels as $class => &$label)
474
+			foreach ($labels as $class => &$label)
475 475
 			{
476 476
 				$label = $class::name();
477 477
 			}
@@ -502,11 +502,11 @@  discard block
 block discarded – undo
502 502
 	 * @param array $filter =null if set (!=null) col-data pairs, to be and-ed (!) into the query without wildcards
503 503
 	 * @return array
504 504
 	 */
505
-	static function &search($criteria,$only_keys=True,$order_by='',$extra_cols='',$wildcard='',$empty=False,$op='AND',$start=false,$filter=null)
505
+	static function &search($criteria, $only_keys = True, $order_by = '', $extra_cols = '', $wildcard = '', $empty = False, $op = 'AND', $start = false, $filter = null)
506 506
 	{
507 507
 		admin_cmd::_instanciate_sql();
508 508
 
509
-		return admin_cmd::$sql->search($criteria,$only_keys,$order_by,$extra_cols,$wildcard,$empty,$op,$start,$filter);
509
+		return admin_cmd::$sql->search($criteria, $only_keys, $order_by, $extra_cols, $wildcard, $empty, $op, $start, $filter);
510 510
 	}
511 511
 
512 512
 	/**
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
 	{
519 519
 		if (is_null(admin_cmd::$sql))
520 520
 		{
521
-			admin_cmd::$sql = new Api\Storage\Base('admin','egw_admin_queue',null,'cmd_');
521
+			admin_cmd::$sql = new Api\Storage\Base('admin', 'egw_admin_queue', null, 'cmd_');
522 522
 		}
523 523
 	}
524 524
 
@@ -531,7 +531,7 @@  discard block
 block discarded – undo
531 531
 	{
532 532
 		if (is_null(admin_cmd::$remote))
533 533
 		{
534
-			admin_cmd::$remote = new Api\Storage\Base('admin','egw_admin_remote');
534
+			admin_cmd::$remote = new Api\Storage\Base('admin', 'egw_admin_remote');
535 535
 		}
536 536
 	}
537 537
 
@@ -543,11 +543,11 @@  discard block
 block discarded – undo
543 543
 	 */
544 544
 	function __get($property)
545 545
 	{
546
-		if (property_exists('admin_cmd',$property))
546
+		if (property_exists('admin_cmd', $property))
547 547
 		{
548
-			return $this->$property;	// making all (non static) class vars readonly available
548
+			return $this->$property; // making all (non static) class vars readonly available
549 549
 		}
550
-		switch($property)
550
+		switch ($property)
551 551
 		{
552 552
 			case 'accounts':
553 553
 				self::_instanciate_accounts();
@@ -566,9 +566,9 @@  discard block
 block discarded – undo
566 566
 	 */
567 567
 	function __isset($property)
568 568
 	{
569
-		if (property_exists('admin_cmd',$property))
569
+		if (property_exists('admin_cmd', $property))
570 570
 		{
571
-			return isset($this->$property);	// making all (non static) class vars readonly available
571
+			return isset($this->$property); // making all (non static) class vars readonly available
572 572
 		}
573 573
 		return isset($this->data[$property]);
574 574
 	}
@@ -580,7 +580,7 @@  discard block
 block discarded – undo
580 580
 	 * @param mixed $value
581 581
 	 * @return mixed
582 582
 	 */
583
-	function __set($property,$value)
583
+	function __set($property, $value)
584 584
 	{
585 585
 		$this->data[$property] = $value;
586 586
 	}
@@ -602,19 +602,19 @@  discard block
 block discarded – undo
602 602
 	 */
603 603
 	function as_array()
604 604
 	{
605
-		if (version_compare(PHP_VERSION,'5.1.2','>'))
605
+		if (version_compare(PHP_VERSION, '5.1.2', '>'))
606 606
 		{
607
-			$vars = get_object_vars($this);	// does not work in php5.1.2 due a bug
607
+			$vars = get_object_vars($this); // does not work in php5.1.2 due a bug
608 608
 		}
609 609
 		else
610 610
 		{
611
-			foreach(array_keys(get_class_vars(__CLASS__)) as $name)
611
+			foreach (array_keys(get_class_vars(__CLASS__)) as $name)
612 612
 			{
613 613
 				$vars[$name] = $this->$name;
614 614
 			}
615 615
 		}
616 616
 		unset($vars['data']);
617
-		if ($this->data) $vars = array_merge($this->data,$vars);
617
+		if ($this->data) $vars = array_merge($this->data, $vars);
618 618
 
619 619
 		return $vars;
620 620
 	}
@@ -626,14 +626,14 @@  discard block
 block discarded – undo
626 626
 	 * @param int $extra_deny =null further admin rights to check, eg. 16 = deny edit Api\Accounts
627 627
 	 * @throws Api\Exception\NoPermission\Admin
628 628
 	 */
629
-	protected function _check_admin($extra_acl=null,$extra_deny=null)
629
+	protected function _check_admin($extra_acl = null, $extra_deny = null)
630 630
 	{
631 631
 		if ($this->creator)
632 632
 		{
633 633
 			admin_cmd::_instanciate_acl($this->creator);
634 634
 			// todo: check only if and with $this->creator
635
-			if (!admin_cmd::$acl->check('run',1,'admin') &&		// creator is no longer admin
636
-				$extra_acl && $extra_deny && admin_cmd::$acl->check($extra_acl,$extra_deny,'admin'))	// creator is explicitly forbidden to do something
635
+			if (!admin_cmd::$acl->check('run', 1, 'admin') && // creator is no longer admin
636
+				$extra_acl && $extra_deny && admin_cmd::$acl->check($extra_acl, $extra_deny, 'admin'))	// creator is explicitly forbidden to do something
637 637
 			{
638 638
 				throw new Api\Exception\NoPermission\Admin();
639 639
 			}
@@ -649,13 +649,13 @@  discard block
 block discarded – undo
649 649
 	 */
650 650
 	static function parse_apps(array $apps)
651 651
 	{
652
-		foreach($apps as $key => $name)
652
+		foreach ($apps as $key => $name)
653 653
 		{
654 654
 			if (!isset($GLOBALS['egw_info']['apps'][$name]))
655 655
 			{
656
-				foreach($GLOBALS['egw_info']['apps'] as $app => $data)	// check against title and localised name
656
+				foreach ($GLOBALS['egw_info']['apps'] as $app => $data)	// check against title and localised name
657 657
 				{
658
-					if (!strcasecmp($name,$data['title']) || !strcasecmp($name,lang($app)))
658
+					if (!strcasecmp($name, $data['title']) || !strcasecmp($name, lang($app)))
659 659
 					{
660 660
 						$apps[$key] = $name = $app;
661 661
 						break;
@@ -664,7 +664,7 @@  discard block
 block discarded – undo
664 664
 			}
665 665
 			if (!isset($GLOBALS['egw_info']['apps'][$name]))
666 666
 			{
667
-				throw new Api\Exception\WrongUserinput(lang("Application '%1' not found (maybe not installed or misspelled)!",$name),8);
667
+				throw new Api\Exception\WrongUserinput(lang("Application '%1' not found (maybe not installed or misspelled)!", $name), 8);
668 668
 			}
669 669
 		}
670 670
 		return $apps;
@@ -679,20 +679,20 @@  discard block
 block discarded – undo
679 679
 	 * @throws Api\Exception\WrongUserinput(lang("Unknown account: %1 !!!",$account),15);
680 680
 	 * @throws Api\Exception\WrongUserinput(lang("Wrong account type: %1 is NO %2 !!!",$account,$allow_only_user?lang('user'):lang('group')),15);
681 681
 	 */
682
-	static function parse_account($account,$allow_only_user=null)
682
+	static function parse_account($account, $allow_only_user = null)
683 683
 	{
684 684
 		admin_cmd::_instanciate_accounts();
685 685
 
686 686
 		if (!($type = admin_cmd::$accounts->exists($account)) ||
687
-			!is_numeric($id=$account) && !($id = admin_cmd::$accounts->name2id($account)))
687
+			!is_numeric($id = $account) && !($id = admin_cmd::$accounts->name2id($account)))
688 688
 		{
689
-			throw new Api\Exception\WrongUserinput(lang("Unknown account: %1 !!!",$account),15);
689
+			throw new Api\Exception\WrongUserinput(lang("Unknown account: %1 !!!", $account), 15);
690 690
 		}
691 691
 		if (!is_null($allow_only_user) && $allow_only_user !== ($type == 1))
692 692
 		{
693
-			throw new Api\Exception\WrongUserinput(lang("Wrong account type: %1 is NO %2 !!!",$account,$allow_only_user?lang('user'):lang('group')),15);
693
+			throw new Api\Exception\WrongUserinput(lang("Wrong account type: %1 is NO %2 !!!", $account, $allow_only_user ?lang('user') : lang('group')), 15);
694 694
 		}
695
-		if ($type == 2 && $id > 0) $id = -$id;	// groups use negative id's internally, fix it, if user given the wrong sign
695
+		if ($type == 2 && $id > 0) $id = -$id; // groups use negative id's internally, fix it, if user given the wrong sign
696 696
 
697 697
 		return $id;
698 698
 	}
@@ -706,14 +706,14 @@  discard block
 block discarded – undo
706 706
 	 * @throws Api\Exception\WrongUserinput(lang("Unknown account: %1 !!!",$account),15);
707 707
 	 * @throws Api\Exception\WrongUserinput(lang("Wrong account type: %1 is NO %2 !!!",$account,$allow_only?lang('user'):lang('group')),15);
708 708
 	 */
709
-	static function parse_accounts($accounts,$allow_only_user=null)
709
+	static function parse_accounts($accounts, $allow_only_user = null)
710 710
 	{
711 711
 		if (!$accounts) return null;
712 712
 
713 713
 		$ids = array();
714
-		foreach(is_array($accounts) ? $accounts : explode(',',$accounts) as $account)
714
+		foreach (is_array($accounts) ? $accounts : explode(',', $accounts) as $account)
715 715
 		{
716
-			$ids[] = admin_cmd::parse_account($account,$allow_only_user);
716
+			$ids[] = admin_cmd::parse_account($account, $allow_only_user);
717 717
 		}
718 718
 		return $ids;
719 719
 	}
@@ -731,11 +731,11 @@  discard block
 block discarded – undo
731 731
 		{
732 732
 			$datein = $date;
733 733
 			// convert german DD.MM.YYYY format into ISO YYYY-MM-DD format
734
-			$date = preg_replace('/^([0-9]{1,2})\.([0-9]{1,2})\.([0-9]{4})$/','\3-\2-\1',$date);
734
+			$date = preg_replace('/^([0-9]{1,2})\.([0-9]{1,2})\.([0-9]{4})$/', '\3-\2-\1', $date);
735 735
 
736
-			if (($date = strtotime($date))  === false)
736
+			if (($date = strtotime($date)) === false)
737 737
 			{
738
-				throw new Api\Exception\WrongUserinput(lang('Invalid formated date "%1"!',$datein),6);
738
+				throw new Api\Exception\WrongUserinput(lang('Invalid formated date "%1"!', $datein), 6);
739 739
 			}
740 740
 		}
741 741
 		return (int)$date;
@@ -749,7 +749,7 @@  discard block
 block discarded – undo
749 749
 	 * @return boolean
750 750
 	 * @throws Api\Exception\WrongUserinput(lang('Invalid value "%1" use yes or no!',$value),998);
751 751
 	 */
752
-	static function parse_boolean($value,$default=null)
752
+	static function parse_boolean($value, $default = null)
753 753
 	{
754 754
 		if (is_bool($value) || is_int($value))
755 755
 		{
@@ -759,15 +759,15 @@  discard block
 block discarded – undo
759 759
 		{
760 760
 			return $default;
761 761
 		}
762
-		if (in_array($value,array('1','yes','true',lang('yes'),lang('true'))))
762
+		if (in_array($value, array('1', 'yes', 'true', lang('yes'), lang('true'))))
763 763
 		{
764 764
 			return true;
765 765
 		}
766
-		if (in_array($value,array('0','no','false',lang('no'),lang('false'))))
766
+		if (in_array($value, array('0', 'no', 'false', lang('no'), lang('false'))))
767 767
 		{
768 768
 			return false;
769 769
 		}
770
-		throw new Api\Exception\WrongUserinput(lang('Invalid value "%1" use yes or no!',$value),998);
770
+		throw new Api\Exception\WrongUserinput(lang('Invalid value "%1" use yes or no!', $value), 998);
771 771
 	}
772 772
 
773 773
 	/**
@@ -785,9 +785,9 @@  discard block
 block discarded – undo
785 785
 			'remote_id' => $id_or_name,
786 786
 			'remote_name' => $id_or_name,
787 787
 			'remote_domain' => $id_or_name,
788
-		),true,'','','',false,'OR')) || count($remotes) != 1)
788
+		), true, '', '', '', false, 'OR')) || count($remotes) != 1)
789 789
 		{
790
-			throw new Api\Exception\WrongUserinput(lang('Invalid remote id or name "%1"!',$id_or_name),997);
790
+			throw new Api\Exception\WrongUserinput(lang('Invalid remote id or name "%1"!', $id_or_name), 997);
791 791
 		}
792 792
 		return $remotes[0]['remote_id'];
793 793
 	}
@@ -804,7 +804,7 @@  discard block
 block discarded – undo
804 804
 		{
805 805
 			if (!is_object($GLOBALS['egw']->accounts))
806 806
 			{
807
-				throw new Api\Exception\AssertionFailed(lang('%1 class not instanciated','accounts'),999);
807
+				throw new Api\Exception\AssertionFailed(lang('%1 class not instanciated', 'accounts'), 999);
808 808
 			}
809 809
 			admin_cmd::$accounts = $GLOBALS['egw']->accounts;
810 810
 		}
@@ -817,13 +817,13 @@  discard block
 block discarded – undo
817 817
 	 * @param int $account =null account_id the class needs to be instanciated for, default need only account-independent methods
818 818
 	 * @throws Api\Exception\AssertionFailed(lang('%1 class not instanciated','acl'),999);
819 819
 	 */
820
-	protected function _instanciate_acl($account=null)
820
+	protected function _instanciate_acl($account = null)
821 821
 	{
822 822
 		if (!is_object(admin_cmd::$acl) || $account && admin_cmd::$acl->account_id != $account)
823 823
 		{
824 824
 			if (!is_object($GLOBALS['egw']->acl))
825 825
 			{
826
-				throw new Api\Exception\AssertionFailed(lang('%1 class not instanciated','acl'),999);
826
+				throw new Api\Exception\AssertionFailed(lang('%1 class not instanciated', 'acl'), 999);
827 827
 			}
828 828
 			if ($account && $GLOBALS['egw']->acl->account_id != $account)
829 829
 			{
@@ -843,20 +843,20 @@  discard block
 block discarded – undo
843 843
 	 * @param $account_id =null account_id, default current user
844 844
 	 * @return string
845 845
 	 */
846
-	static function user_email($account_id=null)
846
+	static function user_email($account_id = null)
847 847
 	{
848 848
 		if ($account_id)
849 849
 		{
850 850
 			admin_cmd::_instanciate_accounts();
851
-			$fullname = admin_cmd::$accounts->id2name($account_id,'account_fullname');
852
-			$email = admin_cmd::$accounts->id2name($account_id,'account_email');
851
+			$fullname = admin_cmd::$accounts->id2name($account_id, 'account_fullname');
852
+			$email = admin_cmd::$accounts->id2name($account_id, 'account_email');
853 853
 		}
854 854
 		else
855 855
 		{
856 856
 			$fullname = $GLOBALS['egw_info']['user']['account_fullname'];
857 857
 			$email = $GLOBALS['egw_info']['user']['account_email'];
858 858
 		}
859
-		return $fullname . ($email ? ' <'.$email.'>' : '');
859
+		return $fullname.($email ? ' <'.$email.'>' : '');
860 860
 	}
861 861
 
862 862
 	/**
@@ -880,11 +880,11 @@  discard block
 block discarded – undo
880 880
 		{
881 881
 			return false;
882 882
 		}
883
-		if (!($jobs = admin_cmd::search(array(),false,'cmd_scheduled','','',false,'AND',array(0,1),array(
883
+		if (!($jobs = admin_cmd::search(array(), false, 'cmd_scheduled', '', '', false, 'AND', array(0, 1), array(
884 884
 			'cmd_status' => admin_cmd::scheduled,
885 885
 		))))
886 886
 		{
887
-			return false;		// no schduled command, no need to setup the job
887
+			return false; // no schduled command, no need to setup the job
888 888
 		}
889 889
 		$next = $jobs[0];
890 890
 		if (($time = $next['scheduled']) < time())	// should run immediatly
@@ -894,11 +894,11 @@  discard block
 block discarded – undo
894 894
 		$async = new Api\Asyncservice();
895 895
 
896 896
 		// we cant use this class as callback, as it's abstract and ExecMethod used by the async service instanciated the class!
897
-		list($app) = explode('_',$class=$next['type']);
897
+		list($app) = explode('_', $class = $next['type']);
898 898
 		$callback = $app.'.'.$class.'.run_queued_jobs';
899 899
 
900
-		$async->cancel_timer(admin_cmd::async_job_id);	// we delete it in case a job already exists
901
-		return $async->set_timer($time,admin_cmd::async_job_id,$callback,null,$next['creator']);
900
+		$async->cancel_timer(admin_cmd::async_job_id); // we delete it in case a job already exists
901
+		return $async->set_timer($time, admin_cmd::async_job_id, $callback, null, $next['creator']);
902 902
 	}
903 903
 
904 904
 	/**
@@ -908,20 +908,20 @@  discard block
 block discarded – undo
908 908
 	 */
909 909
 	static function run_queued_jobs()
910 910
 	{
911
-		if (!($jobs = admin_cmd::search(array(),false,'cmd_scheduled','','',false,'AND',false,array(
911
+		if (!($jobs = admin_cmd::search(array(), false, 'cmd_scheduled', '', '', false, 'AND', false, array(
912 912
 			'cmd_status' => admin_cmd::scheduled,
913 913
 			'cmd_scheduled <= '.time(),
914 914
 		))))
915 915
 		{
916
-			return false;		// no schduled commands, no need to setup the job
916
+			return false; // no schduled commands, no need to setup the job
917 917
 		}
918
-		admin_cmd::$running_queued_jobs = true;	// stop admin_cmd::run() which calls admin_cmd::save() to install a new job
918
+		admin_cmd::$running_queued_jobs = true; // stop admin_cmd::run() which calls admin_cmd::save() to install a new job
919 919
 
920
-		foreach($jobs as $job)
920
+		foreach ($jobs as $job)
921 921
 		{
922 922
 			try {
923 923
 				$cmd = admin_cmd::instanciate($job);
924
-				$cmd->run(null,false);	// false = dont set current user as modifier, as job is run by the queue/system itself
924
+				$cmd->run(null, false); // false = dont set current user as modifier, as job is run by the queue/system itself
925 925
 			}
926 926
 			catch (Exception $e) {	// we need to mark that command as failed, to prevent further execution
927 927
 				admin_cmd::$sql->init($job);
@@ -948,9 +948,9 @@  discard block
 block discarded – undo
948 948
 		admin_cmd::_instanciate_remote();
949 949
 
950 950
 		$sites = array(lang('local'));
951
-		if (($remote = admin_cmd::$remote->query_list('remote_name','remote_id')))
951
+		if (($remote = admin_cmd::$remote->query_list('remote_name', 'remote_id')))
952 952
 		{
953
-			$sites = array_merge($sites,$remote);
953
+			$sites = array_merge($sites, $remote);
954 954
 		}
955 955
 		return $sites;
956 956
 	}
@@ -963,11 +963,11 @@  discard block
 block discarded – undo
963 963
 	 * @param array &$readonlys
964 964
 	 * @return int
965 965
 	 */
966
-	static function get_remotes($query,&$rows,&$readonlys)
966
+	static function get_remotes($query, &$rows, &$readonlys)
967 967
 	{
968 968
 		admin_cmd::_instanciate_remote();
969 969
 
970
-		return admin_cmd::$remote->get_rows($query,$rows,$readonlys);
970
+		return admin_cmd::$remote->get_rows($query, $rows, $readonlys);
971 971
 	}
972 972
 
973 973
 	/**
@@ -995,7 +995,7 @@  discard block
 block discarded – undo
995 995
 
996 996
 		if ($data['install_id'] && $data['config_passwd'])	// calculate hash
997 997
 		{
998
-			$data['remote_hash'] = self::remote_hash($data['install_id'],$data['config_passwd']);
998
+			$data['remote_hash'] = self::remote_hash($data['install_id'], $data['config_passwd']);
999 999
 		}
1000 1000
 		elseif (!$data['remote_hash'] && !($data['install_id'] && $data['config_passwd']))
1001 1001
 		{
@@ -1007,12 +1007,12 @@  discard block
 block discarded – undo
1007 1007
 		// check if a unique key constrain would be violated by saving the entry
1008 1008
 		if (($num = admin_cmd::$remote->not_unique()))
1009 1009
 		{
1010
-			$col = admin_cmd::$remote->table_def['uc'][$num-1];	// $num is 1 based!
1011
-			throw new egw_exception_db_not_unique(lang('Value for column %1 is not unique!',$this->table_name.'.'.$col),$num);
1010
+			$col = admin_cmd::$remote->table_def['uc'][$num - 1]; // $num is 1 based!
1011
+			throw new egw_exception_db_not_unique(lang('Value for column %1 is not unique!', $this->table_name.'.'.$col), $num);
1012 1012
 		}
1013 1013
 		if (admin_cmd::$remote->save() != 0)
1014 1014
 		{
1015
-			throw new Api\Db\Exception(lang('Error saving to db:').' '.$this->sql->db->Error.' ('.$this->sql->db->Errno.')',$this->sql->db->Errno);
1015
+			throw new Api\Db\Exception(lang('Error saving to db:').' '.$this->sql->db->Error.' ('.$this->sql->db->Errno.')', $this->sql->db->Errno);
1016 1016
 		}
1017 1017
 		return admin_cmd::$remote->data['remote_id'];
1018 1018
 	}
@@ -1024,11 +1024,11 @@  discard block
 block discarded – undo
1024 1024
 	 * @param string $config_passwd
1025 1025
 	 * @return string 32char md5 hash
1026 1026
 	 */
1027
-	static function remote_hash($install_id,$config_passwd)
1027
+	static function remote_hash($install_id, $config_passwd)
1028 1028
 	{
1029 1029
 		if (empty($config_passwd) || !self::is_md5($install_id))
1030 1030
 		{
1031
-			throw new Api\Exception\WrongParameter(empty($config_passwd)?'Empty Api\Config password':'install_id no md5 hash');
1031
+			throw new Api\Exception\WrongParameter(empty($config_passwd) ? 'Empty Api\Config password' : 'install_id no md5 hash');
1032 1032
 		}
1033 1033
 		if (!self::is_md5($config_passwd)) $config_passwd = md5($config_passwd);
1034 1034
 
@@ -1058,7 +1058,7 @@  discard block
 block discarded – undo
1058 1058
 	 */
1059 1059
 	static function is_md5($str)
1060 1060
 	{
1061
-		return preg_match('/^[0-9a-f]{32}$/',$str);
1061
+		return preg_match('/^[0-9a-f]{32}$/', $str);
1062 1062
 	}
1063 1063
 
1064 1064
 	/**
@@ -1075,26 +1075,26 @@  discard block
 block discarded – undo
1075 1075
 	 * @param string $config_passwd of the current domain
1076 1076
 	 * @throws Api\Exception\NoPermission
1077 1077
 	 */
1078
-	function check_remote_access($secret,$config_passwd)
1078
+	function check_remote_access($secret, $config_passwd)
1079 1079
 	{
1080 1080
 		// as a security measure remote administration need to be enabled under Admin > Site configuration
1081
-		list(,$remote_admin_install_id) = explode('-',$this->uid);
1082
-		$allowed_remote_admin_ids = $GLOBALS['egw_info']['server']['allow_remote_admin'] ? explode(',',$GLOBALS['egw_info']['server']['allow_remote_admin']) : array();
1081
+		list(,$remote_admin_install_id) = explode('-', $this->uid);
1082
+		$allowed_remote_admin_ids = $GLOBALS['egw_info']['server']['allow_remote_admin'] ? explode(',', $GLOBALS['egw_info']['server']['allow_remote_admin']) : array();
1083 1083
 
1084 1084
 		// to authenticate with the installation we use a secret, which is a md5 hash build from the uid
1085 1085
 		// of the command (to not allow to send new commands with an earsdroped secret) and the md5 hash
1086 1086
 		// of the md5 hash of the Api\Config password and the install_id (egw_admin_remote.remote_hash)
1087
-		if (is_null($config_passwd) || is_numeric($this->uid) || !in_array($remote_admin_install_id,$allowed_remote_admin_ids) ||
1088
-			$secret != ($md5=md5($this->uid.$this->remote_hash($GLOBALS['egw_info']['server']['install_id'],$config_passwd))))
1087
+		if (is_null($config_passwd) || is_numeric($this->uid) || !in_array($remote_admin_install_id, $allowed_remote_admin_ids) ||
1088
+			$secret != ($md5 = md5($this->uid.$this->remote_hash($GLOBALS['egw_info']['server']['install_id'], $config_passwd))))
1089 1089
 		{
1090 1090
 			//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));
1091 1091
 			unset($md5);
1092 1092
 			$msg = lang('Permission denied!');
1093
-			if (!in_array($remote_admin_install_id,$allowed_remote_admin_ids))
1093
+			if (!in_array($remote_admin_install_id, $allowed_remote_admin_ids))
1094 1094
 			{
1095 1095
 				$msg .= "\n".lang('Remote administration need to be enabled in the remote instance under Admin > Site configuration!');
1096 1096
 			}
1097
-			throw new Api\Exception\NoPermission($msg,0);
1097
+			throw new Api\Exception\NoPermission($msg, 0);
1098 1098
 		}
1099 1099
 	}
1100 1100
 
@@ -1104,7 +1104,7 @@  discard block
 block discarded – undo
1104 1104
 	 * @param int $len =16
1105 1105
 	 * @return string
1106 1106
 	 */
1107
-	static function randomstring($len=16)
1107
+	static function randomstring($len = 16)
1108 1108
 	{
1109 1109
 		return Api\Auth::randomstring($len);
1110 1110
 	}
Please login to merge, or discard this patch.
Braces   +57 added lines, -14 removed lines patch added patch discarded remove patch
@@ -130,7 +130,10 @@  discard block
 block discarded – undo
130 130
 	 */
131 131
 	public static function name()
132 132
 	{
133
-		if (self::NAME) return self::NAME;
133
+		if (self::NAME)
134
+		{
135
+			return self::NAME;
136
+		}
134 137
 
135 138
 		return ucfirst(str_replace(['_cmd_', '_', '\\'], ' ', get_called_class()));
136 139
 	}
@@ -199,7 +202,10 @@  discard block
 block discarded – undo
199 202
 				{
200 203
 					$ret = $this->remote_exec($dry_run);
201 204
 				}
202
-				if (is_null($this->status)) $this->status = admin_cmd::successful;
205
+				if (is_null($this->status))
206
+				{
207
+					$this->status = admin_cmd::successful;
208
+				}
203 209
 			}
204 210
 			catch (Exception $e) {
205 211
 				$this->error = $e->getMessage();
@@ -293,7 +299,10 @@  discard block
 block discarded – undo
293 299
 	 */
294 300
 	function delete()
295 301
 	{
296
-		if ($this->status != admin_cmd::scheduled) return false;
302
+		if ($this->status != admin_cmd::scheduled)
303
+		{
304
+			return false;
305
+		}
297 306
 
298 307
 		$this->status = admin_cmd::deleted;
299 308
 
@@ -319,7 +328,10 @@  discard block
 block discarded – undo
319 328
 		{
320 329
 			$this->modified = time();
321 330
 			$this->modifier = $set_modifier ? $GLOBALS['egw_info']['user']['account_id'] : 0;
322
-			if ($set_modifier) $this->modifier_email = admin_cmd::user_email();
331
+			if ($set_modifier)
332
+			{
333
+				$this->modifier_email = admin_cmd::user_email();
334
+			}
323 335
 		}
324 336
 		$vars = get_object_vars($this);	// does not work in php5.1.2 due a bug
325 337
 
@@ -419,10 +431,13 @@  discard block
 block discarded – undo
419 431
 		}
420 432
 		$cmd = new $class($data);
421 433
 
422
-		if ($cmd instanceof admin_cmd)	// dont allow others classes to be executed that way!
434
+		if ($cmd instanceof admin_cmd)
435
+		{
436
+			// dont allow others classes to be executed that way!
423 437
 		{
424 438
 			return $cmd;
425 439
 		}
440
+		}
426 441
 		throw new Api\Exception\WrongParameter(lang('%1 is no command!',$class),0);
427 442
 	}
428 443
 
@@ -614,7 +629,10 @@  discard block
 block discarded – undo
614 629
 			}
615 630
 		}
616 631
 		unset($vars['data']);
617
-		if ($this->data) $vars = array_merge($this->data,$vars);
632
+		if ($this->data)
633
+		{
634
+			$vars = array_merge($this->data,$vars);
635
+		}
618 636
 
619 637
 		return $vars;
620 638
 	}
@@ -633,10 +651,13 @@  discard block
 block discarded – undo
633 651
 			admin_cmd::_instanciate_acl($this->creator);
634 652
 			// todo: check only if and with $this->creator
635 653
 			if (!admin_cmd::$acl->check('run',1,'admin') &&		// creator is no longer admin
636
-				$extra_acl && $extra_deny && admin_cmd::$acl->check($extra_acl,$extra_deny,'admin'))	// creator is explicitly forbidden to do something
654
+				$extra_acl && $extra_deny && admin_cmd::$acl->check($extra_acl,$extra_deny,'admin'))
655
+			{
656
+				// creator is explicitly forbidden to do something
637 657
 			{
638 658
 				throw new Api\Exception\NoPermission\Admin();
639 659
 			}
660
+			}
640 661
 		}
641 662
 	}
642 663
 
@@ -653,11 +674,14 @@  discard block
 block discarded – undo
653 674
 		{
654 675
 			if (!isset($GLOBALS['egw_info']['apps'][$name]))
655 676
 			{
656
-				foreach($GLOBALS['egw_info']['apps'] as $app => $data)	// check against title and localised name
677
+				foreach($GLOBALS['egw_info']['apps'] as $app => $data)
678
+				{
679
+					// check against title and localised name
657 680
 				{
658 681
 					if (!strcasecmp($name,$data['title']) || !strcasecmp($name,lang($app)))
659 682
 					{
660 683
 						$apps[$key] = $name = $app;
684
+				}
661 685
 						break;
662 686
 					}
663 687
 				}
@@ -692,7 +716,11 @@  discard block
 block discarded – undo
692 716
 		{
693 717
 			throw new Api\Exception\WrongUserinput(lang("Wrong account type: %1 is NO %2 !!!",$account,$allow_only_user?lang('user'):lang('group')),15);
694 718
 		}
695
-		if ($type == 2 && $id > 0) $id = -$id;	// groups use negative id's internally, fix it, if user given the wrong sign
719
+		if ($type == 2 && $id > 0)
720
+		{
721
+			$id = -$id;
722
+		}
723
+		// groups use negative id's internally, fix it, if user given the wrong sign
696 724
 
697 725
 		return $id;
698 726
 	}
@@ -708,7 +736,10 @@  discard block
 block discarded – undo
708 736
 	 */
709 737
 	static function parse_accounts($accounts,$allow_only_user=null)
710 738
 	{
711
-		if (!$accounts) return null;
739
+		if (!$accounts)
740
+		{
741
+			return null;
742
+		}
712 743
 
713 744
 		$ids = array();
714 745
 		foreach(is_array($accounts) ? $accounts : explode(',',$accounts) as $account)
@@ -727,9 +758,12 @@  discard block
 block discarded – undo
727 758
 	 */
728 759
 	static function parse_date($date)
729 760
 	{
730
-		if (!is_numeric($date))	// we allow to input a timestamp
761
+		if (!is_numeric($date))
762
+		{
763
+			// we allow to input a timestamp
731 764
 		{
732 765
 			$datein = $date;
766
+		}
733 767
 			// convert german DD.MM.YYYY format into ISO YYYY-MM-DD format
734 768
 			$date = preg_replace('/^([0-9]{1,2})\.([0-9]{1,2})\.([0-9]{4})$/','\3-\2-\1',$date);
735 769
 
@@ -887,10 +921,13 @@  discard block
 block discarded – undo
887 921
 			return false;		// no schduled command, no need to setup the job
888 922
 		}
889 923
 		$next = $jobs[0];
890
-		if (($time = $next['scheduled']) < time())	// should run immediatly
924
+		if (($time = $next['scheduled']) < time())
925
+		{
926
+			// should run immediatly
891 927
 		{
892 928
 			return admin_cmd::run_queued_jobs();
893 929
 		}
930
+		}
894 931
 		$async = new Api\Asyncservice();
895 932
 
896 933
 		// we cant use this class as callback, as it's abstract and ExecMethod used by the async service instanciated the class!
@@ -993,10 +1030,13 @@  discard block
 block discarded – undo
993 1030
 	{
994 1031
 		admin_cmd::_instanciate_remote();
995 1032
 
996
-		if ($data['install_id'] && $data['config_passwd'])	// calculate hash
1033
+		if ($data['install_id'] && $data['config_passwd'])
1034
+		{
1035
+			// calculate hash
997 1036
 		{
998 1037
 			$data['remote_hash'] = self::remote_hash($data['install_id'],$data['config_passwd']);
999 1038
 		}
1039
+		}
1000 1040
 		elseif (!$data['remote_hash'] && !($data['install_id'] && $data['config_passwd']))
1001 1041
 		{
1002 1042
 			throw new Api\Exception\WrongUserinput(lang('Either Install ID AND Api\Config password needed OR the remote hash!'));
@@ -1030,7 +1070,10 @@  discard block
 block discarded – undo
1030 1070
 		{
1031 1071
 			throw new Api\Exception\WrongParameter(empty($config_passwd)?'Empty Api\Config password':'install_id no md5 hash');
1032 1072
 		}
1033
-		if (!self::is_md5($config_passwd)) $config_passwd = md5($config_passwd);
1073
+		if (!self::is_md5($config_passwd))
1074
+		{
1075
+			$config_passwd = md5($config_passwd);
1076
+		}
1034 1077
 
1035 1078
 		return md5($config_passwd.$install_id);
1036 1079
 	}
Please login to merge, or discard this patch.