Completed
Push — 14.2 ( c53e78...a8db63 )
by Ralf
29:08
created
addressbook/inc/class.addressbook_contactform.inc.php 2 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.
Braces   +46 added lines, -13 removed lines patch added patch discarded remove patch
@@ -57,28 +57,41 @@  discard block
 block discarded – undo
57 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())
58 58
 	{
59 59
 		#error_log( "<p>addressbook_contactform::display(".print_r($content,true).",$addressbook,".print_r($fields,true).",$msg,$tpl_name)</p>\n");
60
-		if (empty($tpl_name) && !empty($content['tpl_form_name'])) $tpl_name =$content['tpl_form_name'];
60
+		if (empty($tpl_name) && !empty($content['tpl_form_name']))
61
+		{
62
+			$tpl_name =$content['tpl_form_name'];
63
+		}
61 64
 		$tpl = new etemplate($tpl_name ? $tpl_name : 'addressbook.contactform');
62 65
 		// initializing some fields
63
-		if (!$fields) $fields = array('org_name','n_fn','email','tel_work','url','note','captcha');
66
+		if (!$fields)
67
+		{
68
+			$fields = array('org_name','n_fn','email','tel_work','url','note','captcha');
69
+		}
64 70
 		$submitted = false;
65 71
 		// check if submitted
66 72
 		if (is_array($content))
67 73
 		{
68 74
 			if ((isset($content['captcha_result']) && $content['captcha'] != $content['captcha_result']) ||	// no correct captcha OR
69 75
 				(time() - $content['start_time'] < 10 &&				// bot indicator (less then 10 sec to fill out the form and
70
-				!$GLOBALS['egw_info']['etemplate']['java_script']))	// javascript disabled)
76
+				!$GLOBALS['egw_info']['etemplate']['java_script']))
77
+			{
78
+				// javascript disabled)
71 79
 			{
72 80
 				$submitted = "truebutfalse";
81
+			}
73 82
 				$tpl->set_validation_error('captcha',lang('Wrong - try again ...'));
74 83
 			}
75 84
 			elseif ($content['submitit'])
76 85
 			{
77 86
 				$submitted = true;
78 87
 				$contact = new addressbook_bo();
79
-				if ($content['owner'])	// save the contact in the addressbook
88
+				if ($content['owner'])
89
+				{
90
+					// save the contact in the addressbook
80 91
 				{
81
-					$content['private'] = 0;	// in case default_private is set
92
+					$content['private'] = 0;
93
+				}
94
+				// in case default_private is set
82 95
 					if (($id = $contact->save($content)))
83 96
 					{
84 97
 						// check for fileuploads and attach the found files
@@ -136,9 +149,12 @@  discard block
 block discarded – undo
136 149
 			$custom = 1;
137 150
 			foreach($fields as $name)
138 151
 			{
139
-				if ($name[0] == '#')	// custom field
152
+				if ($name[0] == '#')
153
+				{
154
+					// custom field
140 155
 				{
141 156
 					static $contact;
157
+				}
142 158
 					if (is_null($contact))
143 159
 					{
144 160
 						$contact = new addressbook_bo();
@@ -169,12 +185,19 @@  discard block
 block discarded – undo
169 185
 			unset($content['submitit']);
170 186
 			$custom = 1;
171 187
 			// fieldnames are "defined" by the commit attempt, that way, we do not have to remember them
172
-			foreach($content as $name => $value) {
188
+			foreach($content as $name => $value)
189
+			{
173 190
 				$preserv[$name]=$value;
174
-				if ($name[0] == '#')     // custom field
191
+				if ($name[0] == '#')
192
+				{
193
+					// custom field
175 194
 				{
176 195
 					static $contact;
177
-					if (is_null($contact)) $contact = new addressbook_bo();
196
+				}
197
+					if (is_null($contact))
198
+					{
199
+						$contact = new addressbook_bo();
200
+					}
178 201
 					$content['show']['custom'.$custom] = true;
179 202
 					$content['customfield'][$custom] = $name;
180 203
 					$content['customlabel'][$custom] = $contact->customfields[substr($name,1)]['label'];
@@ -197,15 +220,25 @@  discard block
 block discarded – undo
197 220
 		}
198 221
 		$content['addr_format'] = $GLOBALS['egw_info']['user']['preferences']['addressbook']['addr_format'];
199 222
 
200
-		if ($addressbook) $preserv['owner'] = $addressbook;
201
-		if ($msg) $preserv['msg'] = $msg;
223
+		if ($addressbook)
224
+		{
225
+			$preserv['owner'] = $addressbook;
226
+		}
227
+		if ($msg)
228
+		{
229
+			$preserv['msg'] = $msg;
230
+		}
202 231
 
203 232
 		// a simple calculation captcha
204 233
 		$num1 = rand(1,99);
205 234
 		$num2 = rand(1,99);
206
-		if ($num2 > $num1)	// keep the result positive
235
+		if ($num2 > $num1)
236
+		{
237
+			// keep the result positive
207 238
 		{
208
-			$n = $num1; $num1 = $num2; $num2 = $n;
239
+			$n = $num1;
240
+		}
241
+		$num1 = $num2; $num2 = $n;
209 242
 		}
210 243
 		if (in_array('captcha',$fields))
211 244
 		{
Please login to merge, or discard this patch.
addressbook/inc/class.addressbook_hooks.inc.php 1 patch
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
 	 * Register addressbook for group-acl
424 424
 	 *
425 425
 	 * @param array $args hook-params (not used)
426
-	 * @return boolean|string true=standard group acl link, of string with link
426
+	 * @return boolean true=standard group acl link, of string with link
427 427
 	 */
428 428
 	static function group_acl($args)
429 429
 	{
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
 	 * For which groups should no group acl be used: addressbook always
438 438
 	 *
439 439
 	 * @param string|array $data
440
-	 * @return boolean|array true, false or array with group-account_id's
440
+	 * @return boolean true, false or array with group-account_id's
441 441
 	 */
442 442
 	static function not_enum_group_acls($data)
443 443
 	{
Please login to merge, or discard this patch.
addressbook/inc/class.addressbook_import_contacts_csv.inc.php 2 patches
Doc Comments   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -44,9 +44,7 @@  discard block
 block discarded – undo
44 44
 
45 45
 	/**
46 46
 	 * imports entries according to given definition object.
47
-	 * @param resource $_stream
48
-	 * @param string $_charset
49
-	 * @param definition $_definition
47
+	 * @param importexport_definition $_definition
50 48
 	 */
51 49
 	public function init(importexport_definition &$_definition ) {
52 50
 
@@ -84,7 +82,7 @@  discard block
 block discarded – undo
84 82
 	 *
85 83
 	 * Updates the count of actions taken
86 84
 	 *
87
-	 * @return boolean success
85
+	 * @return null|boolean success
88 86
 	 */
89 87
 	protected function import_record(importexport_iface_egw_record &$record, &$import_csv)
90 88
 	{
Please login to merge, or discard this patch.
Braces   +127 added lines, -51 removed lines patch added patch discarded remove patch
@@ -14,7 +14,8 @@  discard block
 block discarded – undo
14 14
 /**
15 15
  * class import_csv for addressbook
16 16
  */
17
-class addressbook_import_contacts_csv extends importexport_basic_import_csv  {
17
+class addressbook_import_contacts_csv extends importexport_basic_import_csv
18
+{
18 19
 
19 20
 	/**
20 21
 	 * conditions for actions
@@ -45,7 +46,8 @@  discard block
 block discarded – undo
45 46
 	 * @param string $_charset
46 47
 	 * @param definition $_definition
47 48
 	 */
48
-	public function init(importexport_definition &$_definition ) {
49
+	public function init(importexport_definition &$_definition )
50
+	{
49 51
 
50 52
 		// fetch the addressbook bo
51 53
 		$this->bocontacts = new addressbook_bo();
@@ -87,22 +89,29 @@  discard block
 block discarded – undo
87 89
 	{
88 90
 
89 91
 		// Set owner, unless it's supposed to come from CSV file
90
-		if($this->definition->plugin_options['owner_from_csv'] && $record->owner) {
91
-			if(!is_numeric($record->owner)) {
92
+		if($this->definition->plugin_options['owner_from_csv'] && $record->owner)
93
+		{
94
+			if(!is_numeric($record->owner))
95
+			{
92 96
 				// Automatically handle text owner without explicit translation
93 97
 				$new_owner = importexport_helper_functions::account_name2id($record->owner);
94
-				if($new_owner == '') {
98
+				if($new_owner == '')
99
+				{
95 100
 					$this->errors[$import_csv->get_current_position()] = lang(
96 101
 						'Unable to convert "%1" to account ID.  Using plugin setting (%2) for owner.',
97 102
 						$record->owner,
98 103
 						common::grab_owner_name($this->user)
99 104
 					);
100 105
 					$record->owner = $this->user;
101
-				} else {
106
+				}
107
+				else
108
+				{
102 109
 					$record->owner = $new_owner;
103 110
 				}
104 111
 			}
105
-		} else {
112
+		}
113
+		else
114
+		{
106 115
 			$record->owner = $this->user;
107 116
 		}
108 117
 
@@ -138,26 +147,41 @@  discard block
 block discarded – undo
138 147
 		// Also handle categories in their own field
139 148
 		$record_array = $record->get_record_array();
140 149
 		$more_categories = array();
141
-		foreach($this->definition->plugin_options['field_mapping'] as $number => $field_name) {
150
+		foreach($this->definition->plugin_options['field_mapping'] as $number => $field_name)
151
+		{
142 152
 			if(!array_key_exists($field_name, $record_array) ||
143
-				substr($field_name,0,3) != 'cat' || !$record->$field_name || $field_name == 'cat_id') continue;
153
+				substr($field_name,0,3) != 'cat' || !$record->$field_name || $field_name == 'cat_id')
154
+			{
155
+				continue;
156
+			}
144 157
 			list($cat, $cat_id) = explode('-', $field_name);
145
-			if(is_numeric($record->$field_name) && $record->$field_name != 1) {
158
+			if(is_numeric($record->$field_name) && $record->$field_name != 1)
159
+			{
146 160
 				// Column has a single category ID
147 161
 				$more_categories[] = $record->$field_name;
148
-			} elseif($record->$field_name == '1' ||
149
-				(!is_numeric($record->$field_name) && strtolower($record->$field_name) == strtolower(lang('Yes')))) {
162
+			}
163
+			elseif($record->$field_name == '1' ||
164
+				(!is_numeric($record->$field_name) && strtolower($record->$field_name) == strtolower(lang('Yes'))))
165
+			{
150 166
 				// Each category got its own column.  '1' is the database value, lang('yes') is the human value
151 167
 				$more_categories[] = $cat_id;
152
-			} else {
168
+			}
169
+			else
170
+			{
153 171
 				// Text categories
154 172
 				$more_categories = array_merge($more_categories, importexport_helper_functions::cat_name2id(is_array($record->$field_name) ? $record->$field_name : explode(',',$record->$field_name), $cat_id));
155 173
 			}
156 174
 		}
157
-		if(count($more_categories) > 0) $record->cat_id = array_merge(is_array($record->cat_id) ? $record->cat_id : explode(',',$record->cat_id), $more_categories);
175
+		if(count($more_categories) > 0)
176
+		{
177
+			$record->cat_id = array_merge(is_array($record->cat_id) ? $record->cat_id : explode(',',$record->cat_id), $more_categories);
178
+		}
158 179
 
159 180
 		// Private set but missing causes hidden entries
160
-		if(array_key_exists('private', $record_array) && (!isset($record_array['private']) || $record_array['private'] == '')) unset($record->private);
181
+		if(array_key_exists('private', $record_array) && (!isset($record_array['private']) || $record_array['private'] == ''))
182
+		{
183
+			unset($record->private);
184
+		}
161 185
 
162 186
 		// Format birthday as backend requires - converter should give timestamp
163 187
 		if($record->bday && is_numeric($record->bday))
@@ -166,17 +190,24 @@  discard block
 block discarded – undo
166 190
 			$record->bday = $time->format('Y-m-d');
167 191
 		}
168 192
 
169
-		if ( $this->definition->plugin_options['conditions'] ) {
170
-			foreach ( $this->definition->plugin_options['conditions'] as $condition ) {
193
+		if ( $this->definition->plugin_options['conditions'] )
194
+		{
195
+			foreach ( $this->definition->plugin_options['conditions'] as $condition )
196
+			{
171 197
 				$contacts = array();
172
-				switch ( $condition['type'] ) {
198
+				switch ( $condition['type'] )
199
+				{
173 200
 					// exists
174 201
 					case 'exists' :
175
-						if($record_array[$condition['string']]) {
202
+						if($record_array[$condition['string']])
203
+						{
176 204
 							$searchcondition = array( $condition['string'] => $record_array[$condition['string']]);
177 205
 							// if we use account_id for the condition, we need to set the owner for filtering, as this
178 206
 							// enables addressbook_so to decide what backend is to be used
179
-							if ($condition['string']=='account_id') $searchcondition['owner']=0;
207
+							if ($condition['string']=='account_id')
208
+							{
209
+								$searchcondition['owner']=0;
210
+							}
180 211
 							$contacts = $this->bocontacts->search(
181 212
 								//array( $condition['string'] => $record[$condition['string']],),
182 213
 								'',
@@ -185,19 +216,30 @@  discard block
 block discarded – undo
185 216
 								$searchcondition
186 217
 							);
187 218
 						}
188
-						if ( is_array( $contacts ) && count( array_keys( $contacts ) ) >= 1 ) {
219
+						if ( is_array( $contacts ) && count( array_keys( $contacts ) ) >= 1 )
220
+						{
189 221
 							// apply action to all contacts matching this exists condition
190 222
 							$action = $condition['true'];
191
-							foreach ( (array)$contacts as $contact ) {
223
+							foreach ( (array)$contacts as $contact )
224
+							{
192 225
 								$record->id = $contact['id'];
193
-								if ( $this->definition->plugin_options['update_cats'] == 'add' ) {
194
-									if ( !is_array( $contact['cat_id'] ) ) $contact['cat_id'] = explode( ',', $contact['cat_id'] );
195
-									if ( !is_array( $record_array['cat_id'] ) ) $record->cat_id = explode( ',', $record->cat_id );
226
+								if ( $this->definition->plugin_options['update_cats'] == 'add' )
227
+								{
228
+									if ( !is_array( $contact['cat_id'] ) )
229
+									{
230
+										$contact['cat_id'] = explode( ',', $contact['cat_id'] );
231
+									}
232
+									if ( !is_array( $record_array['cat_id'] ) )
233
+									{
234
+										$record->cat_id = explode( ',', $record->cat_id );
235
+									}
196 236
 									$record->cat_id = implode( ',', array_unique( array_merge( $record->cat_id, $contact['cat_id'] ) ) );
197 237
 								}
198 238
 								$success = $this->action(  $action['action'], $record, $import_csv->get_current_position() );
199 239
 							}
200
-						} else {
240
+						}
241
+						else
242
+						{
201 243
 							$action = $condition['false'];
202 244
 							$success = ($this->action(  $action['action'], $record, $import_csv->get_current_position() ));
203 245
 						}
@@ -224,9 +266,14 @@  discard block
 block discarded – undo
224 266
 						die('condition / action not supported!!!');
225 267
 						break;
226 268
 				}
227
-				if ($action['stop']) break;
269
+				if ($action['stop'])
270
+				{
271
+					break;
272
+				}
228 273
 			}
229
-		} else {
274
+		}
275
+		else
276
+		{
230 277
 			// unconditional insert
231 278
 			$success = $this->action( 'insert', $record, $import_csv->get_current_position() );
232 279
 		}
@@ -240,15 +287,18 @@  discard block
 block discarded – undo
240 287
 	 * @param importexport_iface_egw_record $record contact data for the action
241 288
 	 * @return bool success or not
242 289
 	 */
243
-	protected function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 ) {
290
+	protected function action ( $_action, importexport_iface_egw_record &$record, $record_num = 0 )
291
+	{
244 292
 		$_data = $record->get_record_array();
245
-		switch ($_action) {
293
+		switch ($_action)
294
+		{
246 295
 			case 'none' :
247 296
 				return true;
248 297
 			case 'delete':
249 298
 				if($_data['id'])
250 299
 				{
251
-					if ( $this->dry_run ) {
300
+					if ( $this->dry_run )
301
+					{
252 302
 						//print_r($_data);
253 303
 						$this->results[$_action]++;
254 304
 						return true;
@@ -269,13 +319,20 @@  discard block
 block discarded – undo
269 319
 				// Only update if there are changes
270 320
 				$old = $this->bocontacts->read($_data['id']);
271 321
 				// if we get countrycodes as countryname, try to translate them -> the rest should be handled by bo classes.
272
-				foreach(array('adr_one_', 'adr_two_') as $c_prefix) {
273
-					if (strlen(trim($_data[$c_prefix.'countryname']))==2) $_data[$c_prefix.'countryname'] = $GLOBALS['egw']->country->get_full_name(trim($_data[$c_prefix.'countryname']),$translated=true);
322
+				foreach(array('adr_one_', 'adr_two_') as $c_prefix)
323
+				{
324
+					if (strlen(trim($_data[$c_prefix.'countryname']))==2)
325
+					{
326
+						$_data[$c_prefix.'countryname'] = $GLOBALS['egw']->country->get_full_name(trim($_data[$c_prefix.'countryname']),$translated=true);
327
+					}
274 328
 				}
275 329
 				// Don't change a user account into a contact
276
-				if($old['owner'] == 0) {
330
+				if($old['owner'] == 0)
331
+				{
277 332
 					unset($_data['owner']);
278
-				} elseif(!$this->definition->plugin_options['change_owner']) {
333
+				}
334
+				elseif(!$this->definition->plugin_options['change_owner'])
335
+				{
279 336
 					// Don't change addressbook of an existing contact
280 337
 					unset($_data['owner']);
281 338
 				}
@@ -283,9 +340,12 @@  discard block
 block discarded – undo
283 340
 				// Merge to deal with fields not in import record
284 341
 				$_data = array_merge($old, $_data);
285 342
 				$changed = $this->tracking->changed_fields($_data, $old);
286
-				if(count($changed) == 0) {
343
+				if(count($changed) == 0)
344
+				{
287 345
 					return true;
288
-				} else {
346
+				}
347
+				else
348
+				{
289 349
 					//error_log(__METHOD__.__LINE__.array2string($changed).' Old:'.$old['adr_one_countryname'].' ('.$old['adr_one_countrycode'].') New:'.$_data['adr_one_countryname'].' ('.$_data['adr_one_countryname'].')');
290 350
 				}
291 351
 				
@@ -294,24 +354,32 @@  discard block
 block discarded – undo
294 354
 
295 355
 				// Fall through
296 356
 			case 'insert' :
297
-				if($_action == 'insert') {
357
+				if($_action == 'insert')
358
+				{
298 359
 					// Addressbook backend doesn't like inserting with ID specified, it screws up the owner & etag
299 360
 					unset($_data['id']);
300 361
 				}
301
-				if(!isset($_data['org_name'])) {
362
+				if(!isset($_data['org_name']))
363
+				{
302 364
 					// org_name is a trigger to update n_fileas
303 365
 					$_data['org_name'] = '';
304 366
 				}
305 367
 
306
-				if ( $this->dry_run ) {
368
+				if ( $this->dry_run )
369
+				{
307 370
 					//print_r($_data);
308 371
 					$this->results[$_action]++;
309 372
 					return true;
310
-				} else {
373
+				}
374
+				else
375
+				{
311 376
 					$result = $this->bocontacts->save( $_data, $this->is_admin);
312
-					if(!$result) {
377
+					if(!$result)
378
+					{
313 379
 						$this->errors[$record_num] = $this->bocontacts->error;
314
-					} else {
380
+					}
381
+					else
382
+					{
315 383
 						$this->results[$_action]++;
316 384
 						// This does nothing (yet?) but update the identifier
317 385
 						$record->save($result);
@@ -329,7 +397,8 @@  discard block
 block discarded – undo
329 397
 	 *
330 398
 	 * @return string name
331 399
 	 */
332
-	public static function get_name() {
400
+	public static function get_name()
401
+	{
333 402
 		return lang('Addressbook CSV import');
334 403
 	}
335 404
 
@@ -338,7 +407,8 @@  discard block
 block discarded – undo
338 407
 	 *
339 408
 	 * @return string descriprion
340 409
 	 */
341
-	public static function get_description() {
410
+	public static function get_description()
411
+	{
342 412
 		return lang("Imports contacts into your Addressbook from a CSV File. CSV means 'Comma Seperated Values'. However in the options Tab you can also choose other seperators.");
343 413
 	}
344 414
 
@@ -347,7 +417,8 @@  discard block
 block discarded – undo
347 417
 	 *
348 418
 	 * @return string suffix (comma seperated)
349 419
 	 */
350
-	public static function get_filesuffix() {
420
+	public static function get_filesuffix()
421
+	{
351 422
 		return 'csv';
352 423
 	}
353 424
 
@@ -363,7 +434,8 @@  discard block
 block discarded – undo
363 434
 	 * 		preserv		=> array,
364 435
 	 * )
365 436
 	 */
366
-	public function get_options_etpl() {
437
+	public function get_options_etpl()
438
+	{
367 439
 		// lets do it!
368 440
 	}
369 441
 
@@ -372,7 +444,8 @@  discard block
 block discarded – undo
372 444
 	 *
373 445
 	 * @return string etemplate name
374 446
 	 */
375
-	public function get_selectors_etpl() {
447
+	public function get_selectors_etpl()
448
+	{
376 449
 		// lets do it!
377 450
 	}
378 451
 
@@ -384,7 +457,8 @@  discard block
 block discarded – undo
384 457
         *       record_# => warning message
385 458
         *       )
386 459
         */
387
-        public function get_warnings() {
460
+        public function get_warnings()
461
+        {
388 462
 		return $this->warnings;
389 463
 	}
390 464
 
@@ -396,7 +470,8 @@  discard block
 block discarded – undo
396 470
         *       record_# => error message
397 471
         *       )
398 472
         */
399
-        public function get_errors() {
473
+        public function get_errors()
474
+        {
400 475
 		return $this->errors;
401 476
 	}
402 477
 
@@ -408,7 +483,8 @@  discard block
 block discarded – undo
408 483
         *       action => record count
409 484
         * )
410 485
         */
411
-        public function get_results() {
486
+        public function get_results()
487
+        {
412 488
                 return $this->results;
413 489
         }
414 490
 } // end of iface_export_plugin
Please login to merge, or discard this patch.
admin/inc/class.admin_accesslog.inc.php 2 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.
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 2 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
@@ -144,8 +144,14 @@  discard block
 block discarded – undo
144 144
 			{
145 145
 				case 'save':
146 146
 				case 'apply':
147
-					if(is_array($content['owner'])) $content['owner'] = implode(',',$content['owner']);
148
-					if($content['owner'] == '') $content['owner'] = 0;
147
+					if(is_array($content['owner']))
148
+					{
149
+						$content['owner'] = implode(',',$content['owner']);
150
+					}
151
+					if($content['owner'] == '')
152
+					{
153
+						$content['owner'] = 0;
154
+					}
149 155
 					if ($content['id'] && self::$acl_edit)
150 156
 					{
151 157
 
@@ -234,7 +240,10 @@  discard block
 block discarded – undo
234 240
 			egw_framework::refresh_opener($msg, $change_color ? null : $refresh_app, $content['id'], $change_color ? null : 'update', $this->appname);
235 241
 		}
236 242
 		$content['msg'] = $msg;
237
-		if(!$content['appname']) $content['appname'] = $appname;
243
+		if(!$content['appname'])
244
+		{
245
+			$content['appname'] = $appname;
246
+		}
238 247
 		if($content['data']['icon'])
239 248
 		{
240 249
 			$content['icon_url'] = $content['base_url'] . $content['data']['icon'];
@@ -290,7 +299,9 @@  discard block
 block discarded – undo
290 299
 			// Allow admins access to all categories as parent
291 300
 			$content['all_cats'] = 'all_no_acl';
292 301
 			$readonlys['owner'] = false;
293
-		} else {
302
+		}
303
+		else
304
+		{
294 305
 			$readonlys['owner'] = true;
295 306
 			$readonlys['access'] = $content['owner'] != $GLOBALS['egw_info']['user']['account_id'];
296 307
 		}
@@ -301,7 +312,10 @@  discard block
 block discarded – undo
301 312
 			$appname != $content['appname'] || // Can't edit a category from a different app
302 313
 			 ($this->appname != 'admin' && $content['owner'] != $GLOBALS['egw_info']['user']['account_id']);
303 314
 		// Make sure $content['owner'] is an array otherwise it wont show up values in the multiselectbox
304
-		if (!is_array($content['owner'])) $content['owner'] = explode(',',$content['owner']);
315
+		if (!is_array($content['owner']))
316
+		{
317
+			$content['owner'] = explode(',',$content['owner']);
318
+		}
305 319
 		$tmpl = new etemplate_new('admin.categories.edit');
306 320
 		$tmpl->exec($this->edit_link,$content,$sel_options,$readonlys,$content+array(
307 321
 			'old_parent' => $content['old_parent'] ? $content['old_parent'] : $content['parent'], 'appname' => $appname
@@ -360,9 +374,15 @@  discard block
 block discarded – undo
360 374
 		{
361 375
 			$globalcat = false;
362 376
 		}
363
-		if ($globalcat && $query['filter']) $filter['access'] = 'public';
377
+		if ($globalcat && $query['filter'])
378
+		{
379
+			$filter['access'] = 'public';
380
+		}
364 381
 		// new column-filter access has highest priority
365
-		if (!empty($query['col_filter']['access']))$filter['access'] = $query['col_filter']['access'];
382
+		if (!empty($query['col_filter']['access']))
383
+		{
384
+			$filter['access'] = $query['col_filter']['access'];
385
+		}
366 386
 
367 387
 		egw_cache::setSession(__CLASS__.$query['appname'],'nm',$query);
368 388
 
@@ -391,7 +411,10 @@  discard block
 block discarded – undo
391 411
 
392 412
 			$row['level_spacer'] = str_repeat('&nbsp; &nbsp; ',$row['level']);
393 413
 
394
-			if ($row['data']['icon']) $row['icon_url'] = self::icon_url($row['data']['icon']);
414
+			if ($row['data']['icon'])
415
+			{
416
+				$row['icon_url'] = self::icon_url($row['data']['icon']);
417
+			}
395 418
 
396 419
 			$row['subs'] = count($row['children']);
397 420
 
@@ -422,13 +445,19 @@  discard block
 block discarded – undo
422 445
 			$readonlys['nm']["add[$row[id]]"]    = !self::$acl_add_sub;
423 446
 			$readonlys['nm']["delete[$row[id]]"] = !self::$acl_delete;
424 447
 		}
425
-		if (true) $rows = $count <= $query['num_rows'] ? array_values($rows) : array_slice($rows, $query['start'], $query['num_rows']);
448
+		if (true)
449
+		{
450
+			$rows = $count <= $query['num_rows'] ? array_values($rows) : array_slice($rows, $query['start'], $query['num_rows']);
451
+		}
426 452
 		// make appname available for actions
427 453
 		$rows['appname'] = $query['appname'];
428 454
 		$rows['edit_link'] = $this->edit_link;
429 455
 
430 456
 		// disable access column for global categories
431
-		if ($GLOBALS['egw_info']['flags']['currentapp'] == 'admin') $rows['no_access'] = true;
457
+		if ($GLOBALS['egw_info']['flags']['currentapp'] == 'admin')
458
+		{
459
+			$rows['no_access'] = true;
460
+		}
432 461
 
433 462
 		$GLOBALS['egw_info']['flags']['app_header'] = lang($this->appname).' - '.lang('categories').
434 463
 			($query['appname'] != categories::GLOBAL_APPNAME ? ': '.lang($query['appname']) : '');
@@ -445,11 +474,18 @@  discard block
 block discarded – undo
445 474
 	public function index(array $content=null,$msg='')
446 475
 	{
447 476
 		//_debug_array($_GET);
448
-		if ($this->appname != 'admin') translation::add_app('admin');	// need admin translations
477
+		if ($this->appname != 'admin')
478
+		{
479
+			translation::add_app('admin');
480
+		}
481
+		// need admin translations
449 482
 
450 483
 		if(!isset($content))
451 484
 		{
452
-			if (isset($_GET['msg'])) $msg = $_GET['msg'];
485
+			if (isset($_GET['msg']))
486
+			{
487
+				$msg = $_GET['msg'];
488
+			}
453 489
 
454 490
 			$appname = categories::GLOBAL_APPNAME;
455 491
 			foreach(array($content['nm']['appname'], $_GET['cats_app'], $_GET['appname']) as $field)
@@ -590,7 +626,8 @@  discard block
 block discarded – undo
590 626
 			$readonlys['nm']['rows']['owner'] = true;
591 627
 			$readonlys['nm']['col_filter']['owner'] = true;
592 628
 		}
593
-		if($appname == categories::GLOBAL_APPNAME) {
629
+		if($appname == categories::GLOBAL_APPNAME)
630
+		{
594 631
 			$sel_options['app'] = array(''=>'');
595 632
 			$readonlys['nm']['rows']['app'] = true;
596 633
 		}
@@ -608,7 +645,8 @@  discard block
 block discarded – undo
608 645
 		));
609 646
 	}
610 647
 
611
-	protected function get_actions($appname=categories::GLOBAL_APPNAME) {
648
+	protected function get_actions($appname=categories::GLOBAL_APPNAME)
649
+	{
612 650
 
613 651
 		$actions = array(
614 652
 			'open' => array(        // does edit if allowed, otherwise view
@@ -719,11 +757,17 @@  discard block
 block discarded – undo
719 757
 				list($add_remove, $ids_csv) = explode('_', $settings, 2);
720 758
 				$ids = explode(',', $ids_csv);
721 759
 				// Adding 'All users' removes all the others
722
-				if($add_remove == 'add' && array_search(categories::GLOBAL_ACCOUNT,$ids) !== false) $ids = array(categories::GLOBAL_ACCOUNT);
760
+				if($add_remove == 'add' && array_search(categories::GLOBAL_ACCOUNT,$ids) !== false)
761
+				{
762
+					$ids = array(categories::GLOBAL_ACCOUNT);
763
+				}
723 764
 
724 765
 				foreach($checked as $id)
725 766
 				{
726
-					if (!$data = $cats->read($id)) continue;
767
+					if (!$data = $cats->read($id))
768
+					{
769
+						continue;
770
+					}
727 771
 					$data['owner'] = explode(',',$data['owner']);
728 772
 					if(array_search(categories::GLOBAL_ACCOUNT,$data['owner']) !== false || $data['owner'][0] > 0)
729 773
 					{
@@ -763,7 +807,10 @@  discard block
 block discarded – undo
763 807
 				continue;
764 808
 			}
765 809
 			// Skip apps that don't show in the app bar, they [usually] don't have categories
766
-			if($data['status'] > 1 || in_array($app, array('home','admin','felamimail','sitemgr','sitemgr-link'))) continue;
810
+			if($data['status'] > 1 || in_array($app, array('home','admin','felamimail','sitemgr','sitemgr-link')))
811
+			{
812
+				continue;
813
+			}
767 814
 			if ($GLOBALS['egw_info']['user']['apps'][$app])
768 815
 			{
769 816
 				$apps[$app] = $data['title'] ? $data['title'] : lang($app);
Please login to merge, or discard this patch.
admin/inc/class.admin_statistics.inc.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -291,7 +291,7 @@
 block discarded – undo
291 291
 	 * Check if next submission is due, in which case we call submit and NOT return to the admin hook
292 292
 	 *
293 293
 	 * @param boolean $redirect should we redirect or return true
294
-	 * @return boolean true if statistic submission is due
294
+	 * @return boolean|null true if statistic submission is due
295 295
 	 */
296 296
 	public static function check($redirect=true)
297 297
 	{
Please login to merge, or discard this patch.
Braces   +8 added lines, -2 removed lines patch added patch discarded remove patch
@@ -203,9 +203,12 @@  discard block
 block discarded – undo
203 203
 			{
204 204
 				continue;	// --> ignore to not submit too much
205 205
 			}
206
-			if (($users = self::gather_app_users($app)))	// ignore apps noone is allowed to run
206
+			if (($users = self::gather_app_users($app)))
207
+			{
208
+				// ignore apps noone is allowed to run
207 209
 			{
208 210
 				$data['apps'][$app] = $app.':'.round(100.0*$users/$data['users']).'%';
211
+			}
209 212
 				if (($entries = self::gather_app_entries($app)))
210 213
 				{
211 214
 					$data['apps'][$app] .= ':'.$entries;
@@ -302,7 +305,10 @@  discard block
 block discarded – undo
302 305
 		{
303 306
 			return false;
304 307
 		}
305
-		if (!$redirect) return true;
308
+		if (!$redirect)
309
+		{
310
+			return true;
311
+		}
306 312
 
307 313
 		//die('Due for new statistics submission: last_submit='.$config[self::CONFIG_LAST_SUBMIT ].', postpone='.$config[self::CONFIG_POSTPONE_SUBMIT].', '.function_backtrace());
308 314
 		Egw::redirect_link('/index.php',array(
Please login to merge, or discard this patch.
admin/inc/class.admin_ui.inc.php 2 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -491,6 +491,10 @@
 block discarded – undo
491 491
 	protected static function call_hook()
492 492
 	{
493 493
 		self::$hook_data = array();
494
+
495
+		/**
496
+		 * @param string $appname
497
+		 */
494 498
 		function display_section($appname,$file,$file2=False)
495 499
 		{
496 500
 			admin_ui::$hook_data[$appname] = $file2 ? $file2 : $file;
Please login to merge, or discard this patch.
Braces   +85 added lines, -21 removed lines patch added patch discarded remove patch
@@ -48,7 +48,10 @@  discard block
 block discarded – undo
48 48
 		}
49 49
 		$tpl = new Etemplate('admin.index');
50 50
 
51
-		if (!is_array($content)) $content = array();
51
+		if (!is_array($content))
52
+		{
53
+			$content = array();
54
+		}
52 55
 		$content['nm'] = array(
53 56
 			'get_rows' => 'admin_ui::get_users',
54 57
 			'no_cat' => true,
@@ -132,7 +135,9 @@  discard block
 block discarded – undo
132 135
 				'group' => 2,
133 136
 			),
134 137
 		);
135
-		if (!$GLOBALS['egw']->acl->check('account_access',64,'admin'))	// no rights to set ACL-rights
138
+		if (!$GLOBALS['egw']->acl->check('account_access',64,'admin'))
139
+		{
140
+			// no rights to set ACL-rights
136 141
 		{
137 142
 			$actions['deny'] = array(
138 143
 				'caption'   => 'Deny access',
@@ -143,6 +148,7 @@  discard block
 block discarded – undo
143 148
 				'group'     => 2,
144 149
 			);
145 150
 		}
151
+		}
146 152
 		$group = 5;	// allow to place actions in different groups by hook, this is the default
147 153
 		// supporting both old way using $GLOBALS['menuData'] and new just returning data in hook
148 154
 		$apps = array_unique(array_merge(array('admin'), Api\Hooks::implemented('edit_group')));
@@ -150,7 +156,10 @@  discard block
 block discarded – undo
150 156
 		{
151 157
 			$GLOBALS['menuData'] = $data = array();
152 158
 			$data = Api\Hooks::single('edit_group', $app);
153
-			if (!is_array($data)) $data = $GLOBALS['menuData'];
159
+			if (!is_array($data))
160
+			{
161
+				$data = $GLOBALS['menuData'];
162
+			}
154 163
 			//error_log(__METHOD__."() app $app returned ".array2string($data));
155 164
 			foreach($data as $item)
156 165
 			{
@@ -170,15 +179,33 @@  discard block
 block discarded – undo
170 179
 					{
171 180
 						$item['popup'] = $matches[2].'x'.$matches[3];
172 181
 						$item['onExecute'] = 'javaScript:nm_action';
173
-						if (isset($matches[5])) $item['tooltip'] = $matches[5];
182
+						if (isset($matches[5]))
183
+						{
184
+							$item['tooltip'] = $matches[5];
185
+						}
174 186
 						unset($item['options']);
175 187
 					}
176 188
 				}
177
-				if (empty($item['icon'])) $item['icon'] = $app.'/navbar';
178
-				if (empty($item['group'])) $item['group'] = $group;
179
-				if (empty($item['onExecute'])) $item['onExecute'] = 'javaScript:app.admin.group';
180
-				if (!isset($item['allowOnMultiple'])) $item['allowOnMultiple'] = false;
181
-				if (!isset($item['enableId'])) $item['enableId'] = '^/groups/-\\d+';
189
+				if (empty($item['icon']))
190
+				{
191
+					$item['icon'] = $app.'/navbar';
192
+				}
193
+				if (empty($item['group']))
194
+				{
195
+					$item['group'] = $group;
196
+				}
197
+				if (empty($item['onExecute']))
198
+				{
199
+					$item['onExecute'] = 'javaScript:app.admin.group';
200
+				}
201
+				if (!isset($item['allowOnMultiple']))
202
+				{
203
+					$item['allowOnMultiple'] = false;
204
+				}
205
+				if (!isset($item['enableId']))
206
+				{
207
+					$item['enableId'] = '^/groups/-\\d+';
208
+				}
182 209
 
183 210
 				$actions[$item['id']] = $item;
184 211
 			}
@@ -231,7 +258,10 @@  discard block
 block discarded – undo
231 258
 			{
232 259
 				$GLOBALS['menuData'] = $data = array();
233 260
 				$data = Api\Hooks::single('edit_user', $app);
234
-				if (!is_array($data)) $data = $GLOBALS['menuData'];
261
+				if (!is_array($data))
262
+				{
263
+					$data = $GLOBALS['menuData'];
264
+				}
235 265
 				foreach($data as $item)
236 266
 				{
237 267
 					// allow hook to return "real" actions, but still support legacy: description, url, extradata, options
@@ -249,15 +279,30 @@  discard block
 block discarded – undo
249 279
 						if ($item['options'] && preg_match('/(egw_openWindowCentered2?|window.open)\([^)]+,(\d+),(\d+).*(title="([^"]+)")?/', $item['options'], $matches))
250 280
 						{
251 281
 							$item['popup'] = $matches[2].'x'.$matches[3];
252
-							if (isset($matches[5])) $item['tooltip'] = $matches[5];
282
+							if (isset($matches[5]))
283
+							{
284
+								$item['tooltip'] = $matches[5];
285
+							}
253 286
 							unset($item['options']);
254 287
 						}
255 288
 					}
256
-					if (empty($item['icon'])) $item['icon'] = $app.'/navbar';
257
-					if (empty($item['group'])) $item['group'] = $group;
258
-					if (empty($item['onExecute'])) $item['onExecute'] = $item['popup'] ?
289
+					if (empty($item['icon']))
290
+					{
291
+						$item['icon'] = $app.'/navbar';
292
+					}
293
+					if (empty($item['group']))
294
+					{
295
+						$item['group'] = $group;
296
+					}
297
+					if (empty($item['onExecute']))
298
+					{
299
+						$item['onExecute'] = $item['popup'] ?
259 300
 						'javaScript:nm_action' : 'javaScript:app.admin.iframe_location';
260
-					if (!isset($item['allowOnMultiple'])) $item['allowOnMultiple'] = false;
301
+					}
302
+					if (!isset($item['allowOnMultiple']))
303
+					{
304
+						$item['allowOnMultiple'] = false;
305
+					}
261 306
 
262 307
 					$actions[$item['id']] = $item;
263 308
 				}
@@ -313,7 +358,10 @@  discard block
 block discarded – undo
313 358
 						($row['account_expires'] != -1 ? lang('Expires').' '.Api\DateTime::to($row['account_expires'], true) :
314 359
 							lang('Enabled')));
315 360
 
316
-			if (!self::$accounts->is_active($row)) $row['status_class'] = 'adminAccountInactive';
361
+			if (!self::$accounts->is_active($row))
362
+			{
363
+				$row['status_class'] = 'adminAccountInactive';
364
+			}
317 365
 		}
318 366
 
319 367
 		return self::$accounts->total;
@@ -367,7 +415,10 @@  discard block
 block discarded – undo
367 415
 							'link' => $data,
368 416
 						);
369 417
 					}
370
-					if (empty($data['text'])) $data['text'] = $text;
418
+					if (empty($data['text']))
419
+					{
420
+						$data['text'] = $text;
421
+					}
371 422
 					if (empty($data['id']))
372 423
 					{
373 424
 						$data['id'] = $root.($app == 'admin' ? 'admin' : 'apps/'.$app).'/';
@@ -392,7 +443,11 @@  discard block
 block discarded – undo
392 443
 					unset($data['icon']);
393 444
 					$parent =& $tree['item'];
394 445
 					$parts = explode('/', $data['id']);
395
-					if ($data['id'][0] == '/') array_shift($parts);	// remove root
446
+					if ($data['id'][0] == '/')
447
+					{
448
+						array_shift($parts);
449
+					}
450
+					// remove root
396 451
 					array_pop($parts);
397 452
 					$path = '';
398 453
 					foreach($parts as $part)
@@ -411,14 +466,23 @@  discard block
 block discarded – undo
411 466
 								'item' => array(),
412 467
 								'child' => 1,
413 468
 							);
414
-							if ($path == '/admin') $parent[$path]['open'] = true;
469
+							if ($path == '/admin')
470
+							{
471
+								$parent[$path]['open'] = true;
472
+							}
415 473
 						}
416 474
 						$parent =& $parent[$path]['item'];
417 475
 					}
418 476
 					$data['text'] = lang($data['text']);
419
-					if (!empty($data['tooltip'])) $data['tooltip'] = lang($data['tooltip']);
477
+					if (!empty($data['tooltip']))
478
+					{
479
+						$data['tooltip'] = lang($data['tooltip']);
480
+					}
420 481
 					// make sure keys are unique, as we overwrite tree entries otherwise
421
-					if (isset($parent[$data['id']])) $data['id'] .= md5($data['link']);
482
+					if (isset($parent[$data['id']]))
483
+					{
484
+						$data['id'] .= md5($data['link']);
485
+					}
422 486
 					$parent[$data['id']] = self::fix_userdata($data);
423 487
 				}
424 488
 			}
Please login to merge, or discard this patch.
api/src/Vfs/Filesystem/StreamWrapper.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 	 *
272 272
 	 * If you have cached data in your stream but not yet stored it into the underlying storage, you should do so now.
273 273
 	 *
274
-	 * @return booelan TRUE if the cached data was successfully stored (or if there was no data to store), or FALSE if the data could not be stored.
274
+	 * @return boolean TRUE if the cached data was successfully stored (or if there was no data to store), or FALSE if the data could not be stored.
275 275
 	 */
276 276
 	function stream_flush ( )
277 277
 	{
@@ -507,7 +507,7 @@  discard block
 block discarded – undo
507 507
 	 *
508 508
 	 * @param string $url URL that was passed to opendir() and that this object is expected to explore.
509 509
 	 * @param int $options
510
-	 * @return booelan
510
+	 * @return boolean
511 511
 	 */
512 512
 	function dir_opendir ( $url, $options )
513 513
 	{
@@ -616,7 +616,7 @@  discard block
 block discarded – undo
616 616
 	 * It should reset the output generated by dir_readdir(). i.e.:
617 617
 	 * The next call to dir_readdir() should return the first entry in the location returned by dir_opendir().
618 618
 	 *
619
-	 * @return boolean
619
+	 * @return boolean|null
620 620
 	 */
621 621
 	function dir_rewinddir ( )
622 622
 	{
Please login to merge, or discard this patch.
Braces   +90 added lines, -22 removed lines patch added patch discarded remove patch
@@ -131,14 +131,20 @@  discard block
 block discarded – undo
131 131
 		$read_only = str_replace('b','',$mode) == 'r';
132 132
 
133 133
 		// check access rights, based on the eGW mount perms
134
-		if (!($stat = self::url_stat($url,0)) || $mode[0] == 'x')	// file not found or file should NOT exist
134
+		if (!($stat = self::url_stat($url,0)) || $mode[0] == 'x')
135
+		{
136
+			// file not found or file should NOT exist
135 137
 		{
136 138
 			$dir = Vfs::dirname($url);
139
+		}
137 140
 			if ($mode[0] == 'r' ||	// does $mode require the file to exist (r,r+)
138 141
 				$mode[0] == 'x' ||	// or file should not exist, but does
139
-				!Vfs::check_access($dir,Vfs::WRITABLE,$dir_stat=self::url_stat($dir,0)))	// or we are not allowed to 																																			create it
142
+				!Vfs::check_access($dir,Vfs::WRITABLE,$dir_stat=self::url_stat($dir,0)))
143
+			{
144
+				// or we are not allowed to 																																			create it
140 145
 			{
141 146
 				if (self::LOG_LEVEL) error_log(__METHOD__."($url,$mode,$options) file does not exist or can not be created!");
147
+			}
142 148
 				if (!($options & STREAM_URL_STAT_QUIET))
143 149
 				{
144 150
 					trigger_error(__METHOD__."($url,$mode,$options) file does not exist or can not be created!",E_USER_WARNING);
@@ -146,9 +152,12 @@  discard block
 block discarded – undo
146 152
 				return false;
147 153
 			}
148 154
 		}
149
-		elseif (!$read_only && !Vfs::check_access($url,Vfs::WRITABLE,$stat))	// we are not allowed to edit it
155
+		elseif (!$read_only && !Vfs::check_access($url,Vfs::WRITABLE,$stat))
156
+		{
157
+			// we are not allowed to edit it
150 158
 		{
151 159
 			if (self::LOG_LEVEL) error_log(__METHOD__."($url,$mode,$options) file can not be edited!");
160
+		}
152 161
 			if (!($options & STREAM_URL_STAT_QUIET))
153 162
 			{
154 163
 				trigger_error(__METHOD__."($url,$mode,$options) file can not be edited!",E_USER_WARNING);
@@ -157,7 +166,10 @@  discard block
 block discarded – undo
157 166
 		}
158 167
 		if (!$read_only && self::deny_script($url))
159 168
 		{
160
-			if (self::LOG_LEVEL) error_log(__METHOD__."($url,$mode,$options) permission denied, file is a script!");
169
+			if (self::LOG_LEVEL)
170
+			{
171
+				error_log(__METHOD__."($url,$mode,$options) permission denied, file is a script!");
172
+			}
161 173
 			if (!($options & STREAM_URL_STAT_QUIET))
162 174
 			{
163 175
 				trigger_error(__METHOD__."($url,$mode,$options) permission denied, file is a script!",E_USER_WARNING);
@@ -168,7 +180,10 @@  discard block
 block discarded – undo
168 180
 		// open the "real" file
169 181
 		if (!($this->opened_stream = fopen($path=Vfs::decodePath(Vfs::parse_url($url,PHP_URL_PATH)),$mode,$options)))
170 182
 		{
171
-			if (self::LOG_LEVEL) error_log(__METHOD__."($url,$mode,$options) fopen('$path','$mode',$options) returned false!");
183
+			if (self::LOG_LEVEL)
184
+			{
185
+				error_log(__METHOD__."($url,$mode,$options) fopen('$path','$mode',$options) returned false!");
186
+			}
172 187
 			return false;
173 188
 		}
174 189
 		$this->opened_stream_url = $url;
@@ -313,7 +328,10 @@  discard block
 block discarded – undo
313 328
 		// check access rights (file need to exist and directory need to be writable
314 329
 		if (!file_exists($path) || is_dir($path) || !Vfs::check_access(Vfs::dirname($url),Vfs::WRITABLE))
315 330
 		{
316
-			if (self::LOG_LEVEL) error_log(__METHOD__."($url) permission denied!");
331
+			if (self::LOG_LEVEL)
332
+			{
333
+				error_log(__METHOD__."($url) permission denied!");
334
+			}
317 335
 			return false;	// no permission or file does not exist
318 336
 		}
319 337
 		return unlink($path);
@@ -339,18 +357,27 @@  discard block
 block discarded – undo
339 357
 		// check access rights
340 358
 		if (!($from_stat = self::url_stat($url_from,0)) || !Vfs::check_access(Vfs::dirname($url_from),Vfs::WRITABLE))
341 359
 		{
342
-			if (self::LOG_LEVEL) error_log(__METHOD__."($url_from,$url_to): $from[path] permission denied!");
360
+			if (self::LOG_LEVEL)
361
+			{
362
+				error_log(__METHOD__."($url_from,$url_to): $from[path] permission denied!");
363
+			}
343 364
 			return false;	// no permission or file does not exist
344 365
 		}
345 366
 		$to_dir = Vfs::dirname($url_to);
346 367
 		if (!Vfs::check_access($to_dir,Vfs::WRITABLE,$to_dir_stat = self::url_stat($to_dir,0)))
347 368
 		{
348
-			if (self::LOG_LEVEL) error_log(__METHOD__."($url_from,$url_to): $to_dir permission denied!");
369
+			if (self::LOG_LEVEL)
370
+			{
371
+				error_log(__METHOD__."($url_from,$url_to): $to_dir permission denied!");
372
+			}
349 373
 			return false;	// no permission or parent-dir does not exist
350 374
 		}
351 375
 		if (self::deny_script($url_to))
352 376
 		{
353
-			if (self::LOG_LEVEL) error_log(__METHOD__."($url_from,$url_to) permission denied, file is a script!");
377
+			if (self::LOG_LEVEL)
378
+			{
379
+				error_log(__METHOD__."($url_from,$url_to) permission denied, file is a script!");
380
+			}
354 381
 			return false;
355 382
 		}
356 383
 		// the filesystem stream-wrapper does NOT allow to rename files to directories, as this makes problems
@@ -359,13 +386,19 @@  discard block
 block discarded – undo
359 386
 			($to_stat['mime'] === self::DIR_MIME_TYPE) !== ($from_stat['mime'] === self::DIR_MIME_TYPE))
360 387
 		{
361 388
 			$is_dir = $to_stat['mime'] === self::DIR_MIME_TYPE ? 'a' : 'no';
362
-			if (self::LOG_LEVEL) error_log(__METHOD__."($url_to,$url_from) $to[path] is $is_dir directory!");
389
+			if (self::LOG_LEVEL)
390
+			{
391
+				error_log(__METHOD__."($url_to,$url_from) $to[path] is $is_dir directory!");
392
+			}
363 393
 			return false;	// no permission or file does not exist
364 394
 		}
365 395
 		// if destination file already exists, delete it
366 396
 		if ($to_stat && !self::unlink($url_to))
367 397
 		{
368
-			if (self::LOG_LEVEL) error_log(__METHOD__."($url_to,$url_from) can't unlink existing $url_to!");
398
+			if (self::LOG_LEVEL)
399
+			{
400
+				error_log(__METHOD__."($url_to,$url_from) can't unlink existing $url_to!");
401
+			}
369 402
 			return false;
370 403
 		}
371 404
 		return rename(Vfs::decodePath($from['path']),Vfs::decodePath($to['path']));
@@ -400,7 +433,10 @@  discard block
 block discarded – undo
400 433
 		// check access rights (in real filesystem AND by mount perms)
401 434
 		if (file_exists($path) || !file_exists($parent) || !is_writable($parent) || !Vfs::check_access($parent_url,Vfs::WRITABLE))
402 435
 		{
403
-			if (self::LOG_LEVEL) error_log(__METHOD__."($url) permission denied!");
436
+			if (self::LOG_LEVEL)
437
+			{
438
+				error_log(__METHOD__."($url) permission denied!");
439
+			}
404 440
 			return false;
405 441
 		}
406 442
 		return mkdir($path, 0700, $recursive);	// setting mode 0700 allows (only) apache to write into the dir
@@ -426,7 +462,10 @@  discard block
 block discarded – undo
426 462
 		// check access rights (in real filesystem AND by mount perms)
427 463
 		if (!file_exists($path) || !is_writable($parent) || !Vfs::check_access(Vfs::dirname($url),Vfs::WRITABLE))
428 464
 		{
429
-			if (self::LOG_LEVEL) error_log(__METHOD__."($url) permission denied!");
465
+			if (self::LOG_LEVEL)
466
+			{
467
+				error_log(__METHOD__."($url) permission denied!");
468
+			}
430 469
 			return false;
431 470
 		}
432 471
 		return rmdir($path);
@@ -448,7 +487,10 @@  discard block
 block discarded – undo
448 487
 		// check access rights (in real filesystem AND by mount perms)
449 488
 		if (!file_exists($path) || !is_writable($parent) || !Vfs::check_access(Vfs::dirname($url),Vfs::WRITABLE))
450 489
 		{
451
-			if (self::LOG_LEVEL) error_log(__METHOD__."($url) permission denied!");
490
+			if (self::LOG_LEVEL)
491
+			{
492
+				error_log(__METHOD__."($url) permission denied!");
493
+			}
452 494
 			return false;
453 495
 		}
454 496
 		return touch($path,$time,$atime);
@@ -511,7 +553,10 @@  discard block
 block discarded – undo
511 553
 	 */
512 554
 	function dir_opendir ( $url, $options )
513 555
 	{
514
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$options)");
556
+		if (self::LOG_LEVEL > 1)
557
+		{
558
+			error_log(__METHOD__."($url,$options)");
559
+		}
515 560
 
516 561
 		$this->opened_dir = null;
517 562
 
@@ -521,7 +566,10 @@  discard block
 block discarded – undo
521 566
 
522 567
 		if (!($this->opened_dir = opendir($path)))
523 568
 		{
524
-			if (self::LOG_LEVEL > 0) error_log(__METHOD__."($url,$options) opendir('$path') failed!");
569
+			if (self::LOG_LEVEL > 0)
570
+			{
571
+				error_log(__METHOD__."($url,$options) opendir('$path') failed!");
572
+			}
525 573
 			return false;
526 574
 		}
527 575
 		return true;
@@ -577,7 +625,10 @@  discard block
 block discarded – undo
577 625
 				$stat['mode'] = $stat[2] = $stat['mode'] & ~0222;
578 626
 			}
579 627
 		}
580
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$flags) path=$path, mount_mode=".sprintf('0%o',$mode).", mode=".sprintf('0%o',$stat['mode']).'='.Vfs::int2mode($stat['mode']));
628
+		if (self::LOG_LEVEL > 1)
629
+		{
630
+			error_log(__METHOD__."($url,$flags) path=$path, mount_mode=".sprintf('0%o',$mode).", mode=".sprintf('0%o',$stat['mode']).'='.Vfs::int2mode($stat['mode']));
631
+		}
581 632
 		return $stat;
582 633
 	}
583 634
 
@@ -598,14 +649,23 @@  discard block
 block discarded – undo
598 649
 
599 650
 			$ignore = !($file === false ||							// stop if no more dirs or
600 651
 				($file != '.' && $file != '..' ));					// file not . or ..
601
-			if (self::LOG_LEVEL > 1 && $ignore) error_log(__METHOD__.'() ignoring '.array2string($file));
652
+			if (self::LOG_LEVEL > 1 && $ignore)
653
+			{
654
+				error_log(__METHOD__.'() ignoring '.array2string($file));
655
+			}
602 656
 		}
603 657
 		while ($ignore);
604 658
 
605 659
 		// encode special chars messing up url's
606
-		if ($file !== false) $file = Vfs::encodePathComponent($file);
660
+		if ($file !== false)
661
+		{
662
+			$file = Vfs::encodePathComponent($file);
663
+		}
607 664
 
608
-		if (self::LOG_LEVEL > 1) error_log(__METHOD__.'() returning '.array2string($file));
665
+		if (self::LOG_LEVEL > 1)
666
+		{
667
+			error_log(__METHOD__.'() returning '.array2string($file));
668
+		}
609 669
 
610 670
 		return $file;
611 671
 	}
@@ -760,9 +820,17 @@  discard block
 block discarded – undo
760 820
 		list($url,$query) = explode('?',$_url,2);
761 821
 		$get = null;
762 822
 		parse_str($query,$get);
763
-		if (empty($get['url'])) return false;	// no download url given for this mount-point
823
+		if (empty($get['url']))
824
+		{
825
+			return false;
826
+		}
827
+		// no download url given for this mount-point
764 828
 
765
-		if (!($mount_url = Vfs::mount_url($_url))) return false;	// no mount url found, should not happen
829
+		if (!($mount_url = Vfs::mount_url($_url)))
830
+		{
831
+			return false;
832
+		}
833
+		// no mount url found, should not happen
766 834
 		list($mount_url) = explode('?',$mount_url);
767 835
 
768 836
 		$relpath = substr($url,strlen($mount_url));
Please login to merge, or discard this patch.
api/src/Vfs/Links/StreamWrapper.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -316,7 +316,7 @@
 block discarded – undo
316 316
 	 *
317 317
 	 * @param string $url URL that was passed to opendir() and that this object is expected to explore.
318 318
 	 * @param $options
319
-	 * @return booelan
319
+	 * @return boolean
320 320
 	 */
321 321
 	function dir_opendir ( $url, $options )
322 322
 	{
Please login to merge, or discard this patch.
Braces   +26 added lines, -7 removed lines patch added patch discarded remove patch
@@ -26,7 +26,9 @@  discard block
 block discarded – undo
26 26
  */
27 27
 if (!class_exists('EGroupware\\Api\\Vfs\\Links\\LinksParent', false))
28 28
 {
29
-	class LinksParent extends Vfs\Sqlfs\StreamWrapper {}
29
+	class LinksParent extends Vfs\Sqlfs\StreamWrapper
30
+	{
31
+}
30 32
 }
31 33
 
32 34
 /**
@@ -116,7 +118,10 @@  discard block
 block discarded – undo
116 118
 			$access = Api\Link::file_access($app,$id,$required,$rel_path,Vfs::$user);
117 119
 			$what = "from Api\Link::file_access('$app',$id,$required,'$rel_path,".Vfs::$user.")";
118 120
 		}
119
-		if (self::DEBUG) error_log(__METHOD__."($url,$check) user=".Vfs::$user." ($what) ".($access?"access granted ($app:$id:$rel_path)":'no access!!!'));
121
+		if (self::DEBUG)
122
+		{
123
+			error_log(__METHOD__."($url,$check) user=".Vfs::$user." ($what) ".($access?"access granted ($app:$id:$rel_path)":'no access!!!'));
124
+		}
120 125
 		return $access;
121 126
 	}
122 127
 
@@ -180,7 +185,10 @@  discard block
 block discarded – undo
180 185
 				);
181 186
 			}
182 187
 		}
183
-		if (self::DEBUG) error_log(__METHOD__."('$url', $flags) calling parent::url_stat(,,".array2string($eacl_check).') returning '.array2string($ret));
188
+		if (self::DEBUG)
189
+		{
190
+			error_log(__METHOD__."('$url', $flags) calling parent::url_stat(,,".array2string($eacl_check).') returning '.array2string($ret));
191
+		}
184 192
 		return $ret;
185 193
 	}
186 194
 
@@ -238,19 +246,30 @@  discard block
 block discarded – undo
238 246
 
239 247
 		if($path[0] != '/')
240 248
 		{
241
-			if (strpos($path,'?') !== false) $query = Vfs::parse_url($path,PHP_URL_QUERY);
249
+			if (strpos($path,'?') !== false)
250
+			{
251
+				$query = Vfs::parse_url($path,PHP_URL_QUERY);
252
+			}
242 253
 			$path = Vfs::parse_url($path,PHP_URL_PATH).($query ? '?'.$query : '');
243 254
 		}
244 255
 		list(,$apps,$app,$id) = explode('/',$path);
245 256
 
246 257
 		$ret = false;
247
-		if ($apps == 'apps' && $app && !$id || self::check_extended_acl($path,Vfs::WRITABLE))	// app directory itself is allways ok
258
+		if ($apps == 'apps' && $app && !$id || self::check_extended_acl($path,Vfs::WRITABLE))
259
+		{
260
+			// app directory itself is allways ok
248 261
 		{
249
-			$current_is_root = Vfs::$is_root; Vfs::$is_root = true;
262
+			$current_is_root = Vfs::$is_root;
263
+		}
264
+		Vfs::$is_root = true;
250 265
 			$current_user = Vfs::$user; Vfs::$user = 0;
251 266
 
252 267
 			$ret = parent::mkdir($path,0,$options|STREAM_MKDIR_RECURSIVE);
253
-			if ($id) parent::chmod($path,0);	// no other rights
268
+			if ($id)
269
+			{
270
+				parent::chmod($path,0);
271
+			}
272
+			// no other rights
254 273
 
255 274
 			Vfs::$user = $current_user;
256 275
 			Vfs::$is_root = $current_is_root;
Please login to merge, or discard this patch.