Completed
Push — 16.1 ( b5bda6...d590ad )
by Nathan
30:38 queued 15:41
created
admin/inc/class.admin_ui.inc.php 2 patches
Spacing   +38 added lines, -42 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	 *
41 41
 	 * @param array $content
42 42
 	 */
43
-	public function index(array $content=null)
43
+	public function index(array $content = null)
44 44
 	{
45 45
 		if (admin_statistics::check(false))
46 46
 		{
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 		//$content['msg'] = 'Hi Ralf ;-)';
76 76
 		$sel_options['tree'] = $this->tree_data();
77 77
 		$sel_options['filter'] = array('' => lang('All groups'));
78
-		foreach(self::$accounts->search(array(
78
+		foreach (self::$accounts->search(array(
79 79
 			'type' => 'groups',
80 80
 			'start' => false,
81 81
 			'order' => 'account_lid',
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 		}
106 106
 		else
107 107
 		{
108
-			$content['iframe'] = 'about:blank';	// we show accounts-list be default now
108
+			$content['iframe'] = 'about:blank'; // we show accounts-list be default now
109 109
 		}
110 110
 
111 111
 		$tpl->exec('admin.admin_ui.index', $content, $sel_options);
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 	{
121 121
 		$actions = static::group_actions();
122 122
 
123
-		foreach($actions as $action_id =>  &$action)
123
+		foreach ($actions as $action_id =>  &$action)
124 124
 		{
125 125
 			if (!isset($action['enableId']) && !in_array($action_id, array('add')))
126 126
 			{
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 					'default' => true,
149 149
 					'allowOnMultiple' => false,
150 150
 					'onExecute' => 'javaScript:app.admin.account',
151
-					'group' => $group=0,
151
+					'group' => $group = 0,
152 152
 				),
153 153
 				'add' => array(
154 154
 					'caption' => 'Add user',
@@ -159,25 +159,25 @@  discard block
 block discarded – undo
159 159
 			// generate urls for add/edit accounts via addressbook
160 160
 			$edit = Link::get_registry('addressbook', 'edit');
161 161
 			$edit['account_id'] = '$id';
162
-			foreach($edit as $name => $val)
162
+			foreach ($edit as $name => $val)
163 163
 			{
164 164
 				$actions['edit']['url'] .= ($actions['edit']['url'] ? '&' : '').$name.'='.$val;
165 165
 			}
166 166
 			unset($edit['account_id']);
167 167
 			$edit['owner'] = 0;
168
-			foreach($edit as $name => $val)
168
+			foreach ($edit as $name => $val)
169 169
 			{
170 170
 				$actions['add']['url'] .= ($actions['edit']['url'] ? '&' : '').$name.'='.$val;
171 171
 			}
172 172
 			++$group;
173 173
 			// supporting both old way using $GLOBALS['menuData'] and new just returning data in hook
174 174
 			$apps = array_unique(array_merge(array('admin'), Api\Hooks::implemented('edit_user')));
175
-			foreach($apps as $app)
175
+			foreach ($apps as $app)
176 176
 			{
177 177
 				$GLOBALS['menuData'] = $data = array();
178 178
 				$data = Api\Hooks::single('edit_user', $app);
179 179
 				if (!is_array($data)) $data = $GLOBALS['menuData'];
180
-				foreach($data as $item)
180
+				foreach ($data as $item)
181 181
 				{
182 182
 					// allow hook to return "real" actions, but still support legacy: description, url, extradata, options
183 183
 					if (empty($item['caption']))
@@ -232,12 +232,12 @@  discard block
 block discarded – undo
232 232
 				'onExecute' => 'javaScript:app.admin.group',
233 233
 				'caption' => 'Show members',
234 234
 				'default' => true,
235
-				'group' => $group=1,
235
+				'group' => $group = 1,
236 236
 				'allowOnMultiple' => false
237 237
 			),
238 238
 			'add' => array(
239 239
 				'group' => $group,
240
-			)+$user_actions['add'],
240
+			) + $user_actions['add'],
241 241
 			'acl' => array(
242 242
 				'onExecute' => 'javaScript:app.admin.group',
243 243
 				'caption' => 'Access control',
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 				'allowOnMultiple' => false
249 249
 			),
250 250
 		);
251
-		if (!$GLOBALS['egw']->acl->check('account_access',64,'admin'))	// no rights to set ACL-rights
251
+		if (!$GLOBALS['egw']->acl->check('account_access', 64, 'admin'))	// no rights to set ACL-rights
252 252
 		{
253 253
 			$actions['deny'] = array(
254 254
 				'caption'   => 'Deny access',
@@ -260,17 +260,17 @@  discard block
 block discarded – undo
260 260
 			);
261 261
 		}
262 262
 
263
-		$group = 5;	// allow to place actions in different groups by hook, this is the default
263
+		$group = 5; // allow to place actions in different groups by hook, this is the default
264 264
 
265 265
 		// supporting both old way using $GLOBALS['menuData'] and new just returning data in hook
266 266
 		$apps = array_unique(array_merge(array('admin'), Api\Hooks::implemented('edit_group')));
267
-		foreach($apps as $app)
267
+		foreach ($apps as $app)
268 268
 		{
269 269
 			$GLOBALS['menuData'] = $data = array();
270 270
 			$data = Api\Hooks::single('edit_group', $app);
271 271
 			if (!is_array($data)) $data = $GLOBALS['menuData'];
272 272
 
273
-			foreach($data as $item)
273
+			foreach ($data as $item)
274 274
 			{
275 275
 				// allow hook to return "real" actions, but still support legacy: description, url, extradata, options
276 276
 				if (empty($item['caption']))
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 	 * @param array &$rows=null
311 311
 	 * @return int total number of rows available
312 312
 	 */
313
-	public static function get_users(array $query, array &$rows=null)
313
+	public static function get_users(array $query, array &$rows = null)
314 314
 	{
315 315
 		$params = array(
316 316
 			'type' => (int)$query['filter'] ? (int)$query['filter'] : 'accounts',
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
 			$params['query'] = $query['searchletter'];
326 326
 			$params['query_type'] = 'start';
327 327
 		}
328
-		elseif($query['search'])
328
+		elseif ($query['search'])
329 329
 		{
330 330
 			$params['query'] = $query['search'];
331 331
 			$params['query_type'] = 'all';
@@ -334,13 +334,10 @@  discard block
 block discarded – undo
334 334
 		$rows = array_values(self::$accounts->search($params));
335 335
 		//error_log(__METHOD__."() accounts->search(".array2string($params).") total=".self::$accounts->total);
336 336
 
337
-		foreach($rows as &$row)
337
+		foreach ($rows as &$row)
338 338
 		{
339 339
 			$row['status'] = self::$accounts->is_expired($row) ?
340
-				lang('Expired').' '.Api\DateTime::to($row['account_expires'], true) :
341
-					(!self::$accounts->is_active($row) ? lang('Disabled') :
342
-						($row['account_expires'] != -1 ? lang('Expires').' '.Api\DateTime::to($row['account_expires'], true) :
343
-							lang('Enabled')));
340
+				lang('Expired').' '.Api\DateTime::to($row['account_expires'], true) : (!self::$accounts->is_active($row) ? lang('Disabled') : ($row['account_expires'] != -1 ? lang('Expires').' '.Api\DateTime::to($row['account_expires'], true) : lang('Enabled')));
344 341
 
345 342
 			if (!self::$accounts->is_active($row)) $row['status_class'] = 'adminAccountInactive';
346 343
 		}
@@ -362,29 +359,29 @@  discard block
 block discarded – undo
362 359
 			));
363 360
 
364 361
 		$apps = array();
365
-		foreach($GLOBALS['egw_info']['apps'] as $app => $data)
362
+		foreach ($GLOBALS['egw_info']['apps'] as $app => $data)
366 363
 		{
367 364
 			if (!$data['enabled'] || !$data['status'] || $data['status'] == 3)
368 365
 			{
369
-				continue;	// do NOT show disabled apps, or our API (status = 3)
366
+				continue; // do NOT show disabled apps, or our API (status = 3)
370 367
 			}
371 368
 
372 369
 			$apps[] = $app;
373 370
 		}
374 371
 
375 372
 		$rows = array();
376
-		foreach($groups as &$group)
373
+		foreach ($groups as &$group)
377 374
 		{
378 375
 			$run_rights = $GLOBALS['egw']->acl->get_user_applications($group['account_id'], false, false);
379
-			foreach($apps as $app)
376
+			foreach ($apps as $app)
380 377
 			{
381
-				if((boolean)$run_rights[$app])
378
+				if ((boolean)$run_rights[$app])
382 379
 				{
383 380
 					$group['apps'][] = $app;
384 381
 				}
385 382
 			}
386 383
 
387
-			$group['members'] = $GLOBALS['egw']->accounts->members($group['account_id'],true);
384
+			$group['members'] = $GLOBALS['egw']->accounts->members($group['account_id'], true);
388 385
 			$rows[] = $group;
389 386
 		}
390 387
 
@@ -424,14 +421,14 @@  discard block
 block discarded – undo
424 421
 		if ($root == '/')
425 422
 		{
426 423
 			$hook_data = self::call_hook();
427
-			foreach($hook_data as $app => $app_data)
424
+			foreach ($hook_data as $app => $app_data)
428 425
 			{
429
-				if(!is_array($app_data))
426
+				if (!is_array($app_data))
430 427
 				{
431 428
 					// Application has no data
432 429
 					continue;
433 430
 				}
434
-				foreach($app_data as $text => $data)
431
+				foreach ($app_data as $text => $data)
435 432
 				{
436 433
 					if (!is_array($data))
437 434
 					{
@@ -462,18 +459,17 @@  discard block
 block discarded – undo
462 459
 						}
463 460
 					}
464 461
 					unset($data['icon']);
465
-					$parent =& $tree['item'];
462
+					$parent = & $tree['item'];
466 463
 					$parts = explode('/', $data['id']);
467
-					if ($data['id'][0] == '/') array_shift($parts);	// remove root
464
+					if ($data['id'][0] == '/') array_shift($parts); // remove root
468 465
 					array_pop($parts);
469 466
 					$path = '';
470
-					foreach($parts as $part)
467
+					foreach ($parts as $part)
471 468
 					{
472 469
 						$path .= ($path == '/' ? '' : '/').$part;
473 470
 						if (!isset($parent[$path]))
474 471
 						{
475
-							$icon = Etemplate\Widget\Tree::imagePath($part == 'apps' ? Api\Image::find('api', 'home') :
476
-								(($i=Api\Image::find($part, 'navbar')) ? $i : Api\Image::find('api', 'nonav')));
472
+							$icon = Etemplate\Widget\Tree::imagePath($part == 'apps' ? Api\Image::find('api', 'home') : (($i = Api\Image::find($part, 'navbar')) ? $i : Api\Image::find('api', 'nonav')));
477 473
 							$parent[$path] = array(
478 474
 								'id' => $path,
479 475
 								'text' => $part == 'apps' ? lang('Applications') : lang($part),
@@ -485,7 +481,7 @@  discard block
 block discarded – undo
485 481
 							);
486 482
 							if ($path == '/admin') $parent[$path]['open'] = true;
487 483
 						}
488
-						$parent =& $parent[$path]['item'];
484
+						$parent = & $parent[$path]['item'];
489 485
 					}
490 486
 					$data['text'] = lang($data['text']);
491 487
 					if (!empty($data['tooltip'])) $data['tooltip'] = lang($data['tooltip']);
@@ -497,7 +493,7 @@  discard block
 block discarded – undo
497 493
 		}
498 494
 		elseif ($root == '/groups')
499 495
 		{
500
-			foreach($GLOBALS['egw']->accounts->search(array(
496
+			foreach ($GLOBALS['egw']->accounts->search(array(
501 497
 				'type' => 'groups',
502 498
 				'order' => 'account_lid',
503 499
 				'sort' => 'ASC',
@@ -524,8 +520,8 @@  discard block
 block discarded – undo
524 520
 	private static function fix_userdata(array $data)
525 521
 	{
526 522
 		// store link as userdata, maybe we should store everything not directly understood by tree this way ...
527
-		foreach(array_diff_key($data, array_flip(array(
528
-			'id','text','tooltip','im0','im1','im2','item','child','select','open','call',
523
+		foreach (array_diff_key($data, array_flip(array(
524
+			'id', 'text', 'tooltip', 'im0', 'im1', 'im2', 'item', 'child', 'select', 'open', 'call',
529 525
 		))) as $name => $content)
530 526
 		{
531 527
 			$data['userdata'][] = array(
@@ -545,7 +541,7 @@  discard block
 block discarded – undo
545 541
 	private static function strip_item_keys(array &$items)
546 542
 	{
547 543
 		$items = array_values($items);
548
-		foreach($items as &$item)
544
+		foreach ($items as &$item)
549 545
 		{
550 546
 			if (is_array($item) && isset($item['item']))
551 547
 			{
@@ -563,7 +559,7 @@  discard block
 block discarded – undo
563 559
 	protected static function call_hook()
564 560
 	{
565 561
 		self::$hook_data = array();
566
-		function display_section($appname,$file,$file2=False)
562
+		function display_section($appname, $file, $file2 = False)
567 563
 		{
568 564
 			admin_ui::$hook_data[$appname] = $file2 ? $file2 : $file;
569 565
 			//error_log(__METHOD__."(".array2string(func_get_args()).")");
Please login to merge, or discard this patch.
Braces   +81 added lines, -20 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,
@@ -176,7 +179,10 @@  discard block
 block discarded – undo
176 179
 			{
177 180
 				$GLOBALS['menuData'] = $data = array();
178 181
 				$data = Api\Hooks::single('edit_user', $app);
179
-				if (!is_array($data)) $data = $GLOBALS['menuData'];
182
+				if (!is_array($data))
183
+				{
184
+					$data = $GLOBALS['menuData'];
185
+				}
180 186
 				foreach($data as $item)
181 187
 				{
182 188
 					// allow hook to return "real" actions, but still support legacy: description, url, extradata, options
@@ -194,15 +200,30 @@  discard block
 block discarded – undo
194 200
 						if ($item['options'] && preg_match('/(egw_openWindowCentered2?|window.open)\([^)]+,(\d+),(\d+).*(title="([^"]+)")?/', $item['options'], $matches))
195 201
 						{
196 202
 							$item['popup'] = $matches[2].'x'.$matches[3];
197
-							if (isset($matches[5])) $item['tooltip'] = $matches[5];
203
+							if (isset($matches[5]))
204
+							{
205
+								$item['tooltip'] = $matches[5];
206
+							}
198 207
 							unset($item['options']);
199 208
 						}
200 209
 					}
201
-					if (empty($item['icon'])) $item['icon'] = $app.'/navbar';
202
-					if (empty($item['group'])) $item['group'] = $group;
203
-					if (empty($item['onExecute'])) $item['onExecute'] = $item['popup'] ?
210
+					if (empty($item['icon']))
211
+					{
212
+						$item['icon'] = $app.'/navbar';
213
+					}
214
+					if (empty($item['group']))
215
+					{
216
+						$item['group'] = $group;
217
+					}
218
+					if (empty($item['onExecute']))
219
+					{
220
+						$item['onExecute'] = $item['popup'] ?
204 221
 						'javaScript:nm_action' : 'javaScript:app.admin.iframe_location';
205
-					if (!isset($item['allowOnMultiple'])) $item['allowOnMultiple'] = false;
222
+					}
223
+					if (!isset($item['allowOnMultiple']))
224
+					{
225
+						$item['allowOnMultiple'] = false;
226
+					}
206 227
 
207 228
 					$actions[$item['id']] = $item;
208 229
 				}
@@ -248,7 +269,9 @@  discard block
 block discarded – undo
248 269
 				'allowOnMultiple' => false
249 270
 			),
250 271
 		);
251
-		if (!$GLOBALS['egw']->acl->check('account_access',64,'admin'))	// no rights to set ACL-rights
272
+		if (!$GLOBALS['egw']->acl->check('account_access',64,'admin'))
273
+		{
274
+			// no rights to set ACL-rights
252 275
 		{
253 276
 			$actions['deny'] = array(
254 277
 				'caption'   => 'Deny access',
@@ -259,6 +282,7 @@  discard block
 block discarded – undo
259 282
 				'allowOnMultiple' => false
260 283
 			);
261 284
 		}
285
+		}
262 286
 
263 287
 		$group = 5;	// allow to place actions in different groups by hook, this is the default
264 288
 
@@ -268,7 +292,10 @@  discard block
 block discarded – undo
268 292
 		{
269 293
 			$GLOBALS['menuData'] = $data = array();
270 294
 			$data = Api\Hooks::single('edit_group', $app);
271
-			if (!is_array($data)) $data = $GLOBALS['menuData'];
295
+			if (!is_array($data))
296
+			{
297
+				$data = $GLOBALS['menuData'];
298
+			}
272 299
 
273 300
 			foreach($data as $item)
274 301
 			{
@@ -288,14 +315,29 @@  discard block
 block discarded – undo
288 315
 					{
289 316
 						$item['popup'] = $matches[2].'x'.$matches[3];
290 317
 						$item['onExecute'] = 'javaScript:nm_action';
291
-						if (isset($matches[5])) $item['tooltip'] = $matches[5];
318
+						if (isset($matches[5]))
319
+						{
320
+							$item['tooltip'] = $matches[5];
321
+						}
292 322
 						unset($item['options']);
293 323
 					}
294 324
 				}
295
-				if (empty($item['icon'])) $item['icon'] = $app.'/navbar';
296
-				if (empty($item['group'])) $item['group'] = $group;
297
-				if (empty($item['onExecute'])) $item['onExecute'] = 'javaScript:app.admin.group';
298
-				if (!isset($item['allowOnMultiple'])) $item['allowOnMultiple'] = false;
325
+				if (empty($item['icon']))
326
+				{
327
+					$item['icon'] = $app.'/navbar';
328
+				}
329
+				if (empty($item['group']))
330
+				{
331
+					$item['group'] = $group;
332
+				}
333
+				if (empty($item['onExecute']))
334
+				{
335
+					$item['onExecute'] = 'javaScript:app.admin.group';
336
+				}
337
+				if (!isset($item['allowOnMultiple']))
338
+				{
339
+					$item['allowOnMultiple'] = false;
340
+				}
299 341
 
300 342
 				$actions[$item['id']] = $item;
301 343
 			}
@@ -342,7 +384,10 @@  discard block
 block discarded – undo
342 384
 						($row['account_expires'] != -1 ? lang('Expires').' '.Api\DateTime::to($row['account_expires'], true) :
343 385
 							lang('Enabled')));
344 386
 
345
-			if (!self::$accounts->is_active($row)) $row['status_class'] = 'adminAccountInactive';
387
+			if (!self::$accounts->is_active($row))
388
+			{
389
+				$row['status_class'] = 'adminAccountInactive';
390
+			}
346 391
 		}
347 392
 
348 393
 		return self::$accounts->total;
@@ -439,7 +484,10 @@  discard block
 block discarded – undo
439 484
 							'link' => $data,
440 485
 						);
441 486
 					}
442
-					if (empty($data['text'])) $data['text'] = $text;
487
+					if (empty($data['text']))
488
+					{
489
+						$data['text'] = $text;
490
+					}
443 491
 					if (empty($data['id']))
444 492
 					{
445 493
 						$data['id'] = $root.($app == 'admin' ? 'admin' : 'apps/'.$app).'/';
@@ -464,7 +512,11 @@  discard block
 block discarded – undo
464 512
 					unset($data['icon']);
465 513
 					$parent =& $tree['item'];
466 514
 					$parts = explode('/', $data['id']);
467
-					if ($data['id'][0] == '/') array_shift($parts);	// remove root
515
+					if ($data['id'][0] == '/')
516
+					{
517
+						array_shift($parts);
518
+					}
519
+					// remove root
468 520
 					array_pop($parts);
469 521
 					$path = '';
470 522
 					foreach($parts as $part)
@@ -483,14 +535,23 @@  discard block
 block discarded – undo
483 535
 								'item' => array(),
484 536
 								'child' => 1,
485 537
 							);
486
-							if ($path == '/admin') $parent[$path]['open'] = true;
538
+							if ($path == '/admin')
539
+							{
540
+								$parent[$path]['open'] = true;
541
+							}
487 542
 						}
488 543
 						$parent =& $parent[$path]['item'];
489 544
 					}
490 545
 					$data['text'] = lang($data['text']);
491
-					if (!empty($data['tooltip'])) $data['tooltip'] = lang($data['tooltip']);
546
+					if (!empty($data['tooltip']))
547
+					{
548
+						$data['tooltip'] = lang($data['tooltip']);
549
+					}
492 550
 					// make sure keys are unique, as we overwrite tree entries otherwise
493
-					if (isset($parent[$data['id']])) $data['id'] .= md5($data['link']);
551
+					if (isset($parent[$data['id']]))
552
+					{
553
+						$data['id'] .= md5($data['link']);
554
+					}
494 555
 					$parent[$data['id']] = self::fix_userdata($data);
495 556
 				}
496 557
 			}
Please login to merge, or discard this patch.