@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * @param string|int|array $account account name or id (!$account to add a new account), or array with all parameters |
24 | 24 | * @param array $set =null array with all data to change |
25 | 25 | */ |
26 | - function __construct($account,$set=null) |
|
26 | + function __construct($account, $set = null) |
|
27 | 27 | { |
28 | 28 | if (!is_array($account)) |
29 | 29 | { |
@@ -43,10 +43,10 @@ discard block |
||
43 | 43 | * @throws Api\Exception\NoPermission\Admin |
44 | 44 | * @throws Api\Exception\WrongUserinput(lang("Unknown account: %1 !!!",$this->account),15); |
45 | 45 | */ |
46 | - protected function exec($check_only=false) |
|
46 | + protected function exec($check_only = false) |
|
47 | 47 | { |
48 | 48 | // check creator is still admin and not explicitly forbidden to edit accounts/groups |
49 | - if ($this->creator) $this->_check_admin('group_access',$this->account ? 16 : 4); |
|
49 | + if ($this->creator) $this->_check_admin('group_access', $this->account ? 16 : 4); |
|
50 | 50 | |
51 | 51 | admin_cmd::_instanciate_accounts(); |
52 | 52 | |
@@ -54,18 +54,18 @@ discard block |
||
54 | 54 | |
55 | 55 | if ($this->account) // existing account |
56 | 56 | { |
57 | - $data['account_id'] = admin_cmd::parse_account($this->account,false); |
|
57 | + $data['account_id'] = admin_cmd::parse_account($this->account, false); |
|
58 | 58 | } |
59 | 59 | $data += array( |
60 | 60 | 'account_type' => 'g', |
61 | - 'account_status' => 'A', // not used, but so we do the same thing as the web-interface |
|
61 | + 'account_status' => 'A', // not used, but so we do the same thing as the web-interface |
|
62 | 62 | 'account_expires' => -1, |
63 | 63 | ); |
64 | 64 | if (!$data['account_lid'] && (!$this->account || !is_null($data['account_lid']))) |
65 | 65 | { |
66 | 66 | throw new Api\Exception\WrongUserinput(lang('You must enter a group name.'), 17); |
67 | 67 | } |
68 | - if (!is_null($data['account_lid']) && ($id = admin_cmd::$accounts->name2id($data['account_lid'],'account_lid','g')) && |
|
68 | + if (!is_null($data['account_lid']) && ($id = admin_cmd::$accounts->name2id($data['account_lid'], 'account_lid', 'g')) && |
|
69 | 69 | $id !== $data['account_id']) |
70 | 70 | { |
71 | 71 | throw new Api\Exception\WrongUserinput(lang('That loginid has already been taken'), 11); |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | } |
77 | 77 | if ($data['account_members']) |
78 | 78 | { |
79 | - $data['account_members'] = admin_cmd::parse_accounts($data['account_members'],true); |
|
79 | + $data['account_members'] = admin_cmd::parse_accounts($data['account_members'], true); |
|
80 | 80 | } |
81 | 81 | if ($check_only) return true; |
82 | 82 | |
@@ -86,10 +86,10 @@ discard block |
||
86 | 86 | Api\Accounts::cache_invalidate($data['account_id']); |
87 | 87 | if (!($old = admin_cmd::$accounts->read($data['account_id']))) |
88 | 88 | { |
89 | - throw new Api\Exception\WrongUserinput(lang("Unknown account: %1 !!!",$this->account),15); |
|
89 | + throw new Api\Exception\WrongUserinput(lang("Unknown account: %1 !!!", $this->account), 15); |
|
90 | 90 | } |
91 | 91 | // as the current account class always sets all values, we have to add the not specified ones |
92 | - foreach($data as $name => &$value) |
|
92 | + foreach ($data as $name => &$value) |
|
93 | 93 | { |
94 | 94 | if (is_null($value)) $value = $old[$name]; |
95 | 95 | } |
@@ -97,22 +97,21 @@ discard block |
||
97 | 97 | if (!($data['account_id'] = admin_cmd::$accounts->save($data))) |
98 | 98 | { |
99 | 99 | //_debug_array($data); |
100 | - throw new Api\Db\Exception(lang("Error saving account!"),11); |
|
100 | + throw new Api\Db\Exception(lang("Error saving account!"), 11); |
|
101 | 101 | } |
102 | 102 | // Make sure we have lid for hook even if not changed, also set deprecated name |
103 | 103 | $data['account_name'] = $data['account_lid'] = $data['account_lid'] ? |
104 | - $data['account_lid'] : |
|
105 | - admin_cmd::$accounts->id2name($data['account_id']); |
|
104 | + $data['account_lid'] : admin_cmd::$accounts->id2name($data['account_id']); |
|
106 | 105 | |
107 | - if ($update) $data['old_name'] = $old['account_lid']; // make old name available for hooks |
|
108 | - $GLOBALS['hook_values'] =& $data; |
|
109 | - Api\Hooks::process($GLOBALS['hook_values']+array( |
|
106 | + if ($update) $data['old_name'] = $old['account_lid']; // make old name available for hooks |
|
107 | + $GLOBALS['hook_values'] = & $data; |
|
108 | + Api\Hooks::process($GLOBALS['hook_values'] + array( |
|
110 | 109 | 'location' => $update ? 'editgroup' : 'addgroup' |
111 | - ),False,True); // called for every app now, not only enabled ones) |
|
110 | + ), False, True); // called for every app now, not only enabled ones) |
|
112 | 111 | |
113 | 112 | if ($data['account_members']) |
114 | 113 | { |
115 | - admin_cmd::$accounts->set_members($data['account_members'],$data['account_id']); |
|
114 | + admin_cmd::$accounts->set_members($data['account_members'], $data['account_id']); |
|
116 | 115 | } |
117 | 116 | // make new account_id available to caller |
118 | 117 | $this->account = $data['account_id']; |
@@ -128,7 +127,7 @@ discard block |
||
128 | 127 | */ |
129 | 128 | function __tostring() |
130 | 129 | { |
131 | - return lang('%1 group %2',$this->account ? lang('Edit') : lang('Add'), |
|
130 | + return lang('%1 group %2', $this->account ? lang('Edit') : lang('Add'), |
|
132 | 131 | admin_cmd::display_account($this->account ? $this->account : $this->set['account_lid'])); |
133 | 132 | } |
134 | 133 | |
@@ -170,7 +169,7 @@ discard block |
||
170 | 169 | { |
171 | 170 | $widgets = parent::get_change_widgets(); |
172 | 171 | |
173 | - $widgets['account_id'] = 'integer'; // normaly not displayed |
|
172 | + $widgets['account_id'] = 'integer'; // normaly not displayed |
|
174 | 173 | $widgets['run'] = 'select-app'; |
175 | 174 | |
176 | 175 | return $widgets; |
@@ -217,7 +216,7 @@ discard block |
||
217 | 216 | } |
218 | 217 | |
219 | 218 | // remove values not relevant to groups |
220 | - foreach(['old', 'set'] as $name) |
|
219 | + foreach (['old', 'set'] as $name) |
|
221 | 220 | { |
222 | 221 | $data[$name] = array_diff_key($data[$name], array_flip([ |
223 | 222 | 'account_pwd', 'account_status', 'account_type', |
@@ -229,7 +228,7 @@ discard block |
||
229 | 228 | } |
230 | 229 | |
231 | 230 | // remove unchanged values (null == '' and arrays might not be sorted) |
232 | - foreach($data['set'] as $name => $value) |
|
231 | + foreach ($data['set'] as $name => $value) |
|
233 | 232 | { |
234 | 233 | if ($data['old'][$name] == $value || |
235 | 234 | is_array($value) && sort($value) && sort($data['old'][$name]) && $value == $data['old'][$name]) |