Completed
Push — master ( cd694a...673bd3 )
by Nathan
15:56
created
admin/inc/class.admin_cmd.inc.php 1 patch
Braces   +85 added lines, -21 removed lines patch added patch discarded remove patch
@@ -172,7 +172,10 @@  discard block
 block discarded – undo
172 172
 	 */
173 173
 	public static function name()
174 174
 	{
175
-		if (self::NAME) return self::NAME;
175
+		if (self::NAME)
176
+		{
177
+			return self::NAME;
178
+		}
176 179
 
177 180
 		return ucfirst(str_replace(['_cmd_', '_', '\\'], ' ', get_called_class()));
178 181
 	}
@@ -242,7 +245,10 @@  discard block
 block discarded – undo
242 245
 				{
243 246
 					$ret = $this->remote_exec($dry_run);
244 247
 				}
245
-				if (is_null($this->status)) $this->status = admin_cmd::successful;
248
+				if (is_null($this->status))
249
+				{
250
+					$this->status = admin_cmd::successful;
251
+				}
246 252
 			}
247 253
 			catch (Exception $e) {
248 254
 				_egw_log_exception($e);
@@ -339,7 +345,10 @@  discard block
 block discarded – undo
339 345
 	function delete()
340 346
 	{
341 347
 		$this->cancel_periodic_job();
342
-		if ($this->status != admin_cmd::scheduled) return false;
348
+		if ($this->status != admin_cmd::scheduled)
349
+		{
350
+			return false;
351
+		}
343 352
 
344 353
 		$this->status = admin_cmd::deleted;
345 354
 
@@ -365,7 +374,10 @@  discard block
 block discarded – undo
365 374
 		{
366 375
 			$this->modified = time();
367 376
 			$this->modifier = $set_modifier ? $GLOBALS['egw_info']['user']['account_id'] : 0;
368
-			if ($set_modifier) $this->modifier_email = admin_cmd::user_email();
377
+			if ($set_modifier)
378
+			{
379
+				$this->modifier_email = admin_cmd::user_email();
380
+			}
369 381
 		}
370 382
 		$vars = get_object_vars($this);	// does not work in php5.1.2 due a bug
371 383
 
@@ -481,10 +493,13 @@  discard block
 block discarded – undo
481 493
 		}
482 494
 		$cmd = new $class($data);
483 495
 
484
-		if ($cmd instanceof admin_cmd)	// dont allow others classes to be executed that way!
496
+		if ($cmd instanceof admin_cmd)
497
+		{
498
+			// dont allow others classes to be executed that way!
485 499
 		{
486 500
 			return $cmd;
487 501
 		}
502
+		}
488 503
 		throw new Api\Exception\WrongParameter(lang('%1 is no command!',$class), 10);
489 504
 	}
490 505
 
@@ -521,7 +536,10 @@  discard block
 block discarded – undo
521 536
 
522 537
 		$total = admin_cmd::$sql->get_rows($query,$rows,$readonlys);
523 538
 
524
-		if (!$rows) return 0;
539
+		if (!$rows)
540
+		{
541
+			return 0;
542
+		}
525 543
 
526 544
 		$async = new Api\Asyncservice();
527 545
 		foreach($rows as &$row)
@@ -746,7 +764,10 @@  discard block
 block discarded – undo
746 764
 			}
747 765
 		}
748 766
 		unset($vars['data']);
749
-		if ($this->data) $vars = array_merge($this->data,$vars);
767
+		if ($this->data)
768
+		{
769
+			$vars = array_merge($this->data,$vars);
770
+		}
750 771
 
751 772
 		return $vars;
752 773
 	}
@@ -765,10 +786,13 @@  discard block
 block discarded – undo
765 786
 			admin_cmd::_instanciate_acl($this->creator);
766 787
 			// todo: check only if and with $this->creator
767 788
 			if (!admin_cmd::$acl->check('run',1,'admin') &&		// creator is no longer admin
768
-				$extra_acl && $extra_deny && admin_cmd::$acl->check($extra_acl,$extra_deny,'admin'))	// creator is explicitly forbidden to do something
789
+				$extra_acl && $extra_deny && admin_cmd::$acl->check($extra_acl,$extra_deny,'admin'))
790
+			{
791
+				// creator is explicitly forbidden to do something
769 792
 			{
770 793
 				throw new Api\Exception\NoPermission\Admin();
771 794
 			}
795
+			}
772 796
 		}
773 797
 	}
774 798
 
@@ -785,11 +809,14 @@  discard block
 block discarded – undo
785 809
 		{
786 810
 			if (!isset($GLOBALS['egw_info']['apps'][$name]))
787 811
 			{
788
-				foreach($GLOBALS['egw_info']['apps'] as $app => $data)	// check against title and localised name
812
+				foreach($GLOBALS['egw_info']['apps'] as $app => $data)
813
+				{
814
+					// check against title and localised name
789 815
 				{
790 816
 					if (!strcasecmp($name,$data['title']) || !strcasecmp($name,lang($app)))
791 817
 					{
792 818
 						$apps[$key] = $name = $app;
819
+				}
793 820
 						break;
794 821
 					}
795 822
 				}
@@ -824,7 +851,11 @@  discard block
 block discarded – undo
824 851
 		{
825 852
 			throw new Api\Exception\WrongUserinput(lang("Wrong account type: %1 is NO %2 !!!",$account,$allow_only_user?lang('user'):lang('group')), 16);
826 853
 		}
827
-		if ($type == 2 && $id > 0) $id = -$id;	// groups use negative id's internally, fix it, if user given the wrong sign
854
+		if ($type == 2 && $id > 0)
855
+		{
856
+			$id = -$id;
857
+		}
858
+		// groups use negative id's internally, fix it, if user given the wrong sign
828 859
 
829 860
 		return $id;
830 861
 	}
@@ -840,7 +871,10 @@  discard block
 block discarded – undo
840 871
 	 */
841 872
 	static function parse_accounts($accounts,$allow_only_user=null)
842 873
 	{
843
-		if (!$accounts) return null;
874
+		if (!$accounts)
875
+		{
876
+			return null;
877
+		}
844 878
 
845 879
 		$ids = array();
846 880
 		foreach(is_array($accounts) ? $accounts : explode(',',$accounts) as $account)
@@ -859,9 +893,12 @@  discard block
 block discarded – undo
859 893
 	 */
860 894
 	static function parse_date($date)
861 895
 	{
862
-		if (!is_numeric($date))	// we allow to input a timestamp
896
+		if (!is_numeric($date))
897
+		{
898
+			// we allow to input a timestamp
863 899
 		{
864 900
 			$datein = $date;
901
+		}
865 902
 			// convert german DD.MM.YYYY format into ISO YYYY-MM-DD format
866 903
 			$date = preg_replace('/^([0-9]{1,2})\.([0-9]{1,2})\.([0-9]{4})$/','\3-\2-\1',$date);
867 904
 
@@ -1019,10 +1056,13 @@  discard block
 block discarded – undo
1019 1056
 			return false;		// no schduled command, no need to setup the job
1020 1057
 		}
1021 1058
 		$next = $jobs[0];
1022
-		if (($time = $next['scheduled']) < time())	// should run immediatly
1059
+		if (($time = $next['scheduled']) < time())
1060
+		{
1061
+			// should run immediatly
1023 1062
 		{
1024 1063
 			return admin_cmd::run_queued_jobs();
1025 1064
 		}
1065
+		}
1026 1066
 		$async = new Api\Asyncservice();
1027 1067
 
1028 1068
 		// we cant use this class as callback, as it's abstract and ExecMethod used by the async service instanciated the class!
@@ -1080,7 +1120,10 @@  discard block
 block discarded – undo
1080 1120
 	 */
1081 1121
 	public function set_periodic_job()
1082 1122
 	{
1083
-		if (empty($this->rrule)) return false;
1123
+		if (empty($this->rrule))
1124
+		{
1125
+			return false;
1126
+		}
1084 1127
 
1085 1128
 		// parse rrule and calculate next execution time
1086 1129
 		$event = calendar_rrule::parseRrule($this->rrule, true);	// true: allow HOURLY or MINUTELY
@@ -1201,10 +1244,13 @@  discard block
 block discarded – undo
1201 1244
 	{
1202 1245
 		admin_cmd::_instanciate_remote();
1203 1246
 
1204
-		if ($data['install_id'] && $data['config_passwd'])	// calculate hash
1247
+		if ($data['install_id'] && $data['config_passwd'])
1248
+		{
1249
+			// calculate hash
1205 1250
 		{
1206 1251
 			$data['remote_hash'] = self::remote_hash($data['install_id'],$data['config_passwd']);
1207 1252
 		}
1253
+		}
1208 1254
 		elseif (!$data['remote_hash'] && !($data['install_id'] && $data['config_passwd']))
1209 1255
 		{
1210 1256
 			throw new Api\Exception\WrongUserinput(lang('Either Install ID AND Api\Config password needed OR the remote hash!'));
@@ -1238,7 +1284,10 @@  discard block
 block discarded – undo
1238 1284
 		{
1239 1285
 			throw new Api\Exception\WrongParameter(empty($config_passwd)?'Empty Api\Config password':'install_id no md5 hash');
1240 1286
 		}
1241
-		if (!self::is_md5($config_passwd)) $config_passwd = md5($config_passwd);
1287
+		if (!self::is_md5($config_passwd))
1288
+		{
1289
+			$config_passwd = md5($config_passwd);
1290
+		}
1242 1291
 
1243 1292
 		return md5($config_passwd.$install_id);
1244 1293
 	}
@@ -1368,7 +1417,10 @@  discard block
 block discarded – undo
1368 1417
 				{
1369 1418
 					// remember label from last description widget
1370 1419
 					case 'description':
1371
-						if (!empty($widget->attrs['value'])) $label = $widget->attrs['value'];
1420
+						if (!empty($widget->attrs['value']))
1421
+						{
1422
+							$label = $widget->attrs['value'];
1423
+						}
1372 1424
 						break;
1373 1425
 					// ignore non input-widgets
1374 1426
 					case 'hbox': case 'vbox': case 'box': case 'groupbox':
@@ -1380,8 +1432,14 @@  discard block
 block discarded – undo
1380 1432
 					default:
1381 1433
 						if (!empty($widget->id))
1382 1434
 						{
1383
-							if (!empty($widget->attrs['label'])) $label = $widget->attrs['label'];
1384
-							if (!empty($label)) $labels[$widget->id] = $label;
1435
+							if (!empty($widget->attrs['label']))
1436
+							{
1437
+								$label = $widget->attrs['label'];
1438
+							}
1439
+							if (!empty($label))
1440
+							{
1441
+								$labels[$widget->id] = $label;
1442
+							}
1385 1443
 							$label = null;
1386 1444
 						}
1387 1445
 						break;
@@ -1419,7 +1477,10 @@  discard block
 block discarded – undo
1419 1477
 					case 'button': case 'buttononly': case 'taglist-thumbnail':
1420 1478
 						break;
1421 1479
 					case 'radio':
1422
-						if (!is_array($widgets[$widget->id])) $widgets[$widget->id] = [];
1480
+						if (!is_array($widgets[$widget->id]))
1481
+						{
1482
+							$widgets[$widget->id] = [];
1483
+						}
1423 1484
 						$label = (string)$widget->attrs['label'];
1424 1485
 						// translate "{something} {else}" type options
1425 1486
 						if (strpos($label, '{') !== false)
@@ -1433,7 +1494,10 @@  discard block
 block discarded – undo
1433 1494
 						break;
1434 1495
 					// config templates have options in the template
1435 1496
 					case 'option':
1436
-						if (!is_array($widgets[$last_select])) $widgets[$last_select] = [];
1497
+						if (!is_array($widgets[$last_select]))
1498
+						{
1499
+							$widgets[$last_select] = [];
1500
+						}
1437 1501
 						$label = (string)$widget->attrs['#text'];
1438 1502
 						// translate "{something} {else}" type options
1439 1503
 						if (strpos($label, '{') !== false)
Please login to merge, or discard this patch.