@@ -30,9 +30,9 @@ discard block |
||
| 30 | 30 | |
| 31 | 31 | // Copying account uses addressbook fields, but we explicitly clear these |
| 32 | 32 | protected static $copy_clear_fields = array( |
| 33 | - 'account_firstname','account_lastname','account_fullname', 'person_id', |
|
| 34 | - 'account_id','account_lid', |
|
| 35 | - 'account_lastlogin','accountlastloginfrom','account_lastpwd_change' |
|
| 33 | + 'account_firstname', 'account_lastname', 'account_fullname', 'person_id', |
|
| 34 | + 'account_id', 'account_lid', |
|
| 35 | + 'account_lastlogin', 'accountlastloginfrom', 'account_lastpwd_change' |
|
| 36 | 36 | ); |
| 37 | 37 | |
| 38 | 38 | /** |
@@ -46,11 +46,10 @@ discard block |
||
| 46 | 46 | { |
| 47 | 47 | if ((string)$content['owner'] === '0' && $GLOBALS['egw_info']['user']['apps']['admin']) |
| 48 | 48 | { |
| 49 | - $deny_edit = $content['account_id'] ? $GLOBALS['egw']->acl->check('account_access', 16, 'admin') : |
|
| 50 | - $GLOBALS['egw']->acl->check('account_access', 4, 'admin'); |
|
| 49 | + $deny_edit = $content['account_id'] ? $GLOBALS['egw']->acl->check('account_access', 16, 'admin') : $GLOBALS['egw']->acl->check('account_access', 4, 'admin'); |
|
| 51 | 50 | //error_log(__METHOD__."() contact_id=$content[contact_id], account_id=$content[account_id], deny_edit=".array2string($deny_edit)); |
| 52 | 51 | |
| 53 | - if (!$content['account_id'] && $deny_edit) return; // no right to add new accounts, should not happen by AB ACL |
|
| 52 | + if (!$content['account_id'] && $deny_edit) return; // no right to add new accounts, should not happen by AB ACL |
|
| 54 | 53 | |
| 55 | 54 | // load our translations |
| 56 | 55 | Api\Translation::add_app('admin'); |
@@ -64,7 +63,7 @@ discard block |
||
| 64 | 63 | throw new Api\Exception\NotFound('Account data NOT found!'); |
| 65 | 64 | } |
| 66 | 65 | if ($account['account_expires'] == -1) $account['account_expires'] = ''; |
| 67 | - unset($account['account_pwd']); // do NOT send to client |
|
| 66 | + unset($account['account_pwd']); // do NOT send to client |
|
| 68 | 67 | $account['account_groups'] = array_keys($account['memberships']); |
| 69 | 68 | $acl = new Acl($content['account_id']); |
| 70 | 69 | $acl->read_repository(); |
@@ -84,7 +83,7 @@ discard block |
||
| 84 | 83 | 'account_status' => 'A', |
| 85 | 84 | 'account_groups' => array(), |
| 86 | 85 | 'anonymous' => false, |
| 87 | - 'changepassword' => true, //old default: (bool)$GLOBALS['egw_info']['server']['change_pwd_every_x_days'], |
|
| 86 | + 'changepassword' => true, //old default: (bool)$GLOBALS['egw_info']['server']['change_pwd_every_x_days'], |
|
| 88 | 87 | 'mustchangepassword' => false, |
| 89 | 88 | 'account_primary_group' => $GLOBALS['egw']->accounts->name2id('Default'), |
| 90 | 89 | 'homedirectory' => $GLOBALS['egw_info']['server']['ldap_account_home'], |
@@ -105,21 +104,20 @@ discard block |
||
| 105 | 104 | |
| 106 | 105 | if ($deny_edit) |
| 107 | 106 | { |
| 108 | - foreach(array_keys($account) as $key) |
|
| 107 | + foreach (array_keys($account) as $key) |
|
| 109 | 108 | { |
| 110 | 109 | $readonlys[$key] = true; |
| 111 | 110 | } |
| 112 | 111 | $readonlys['account_passwd'] = $readonlys['account_passwd2'] = true; |
| 113 | 112 | } |
| 114 | 113 | // save old values to only trigger save, if one of the following values change (contact data get saved anyway) |
| 115 | - $preserve = empty($content['id']) ? array() : |
|
| 116 | - array('old_account' => array_intersect_key($account, array_flip(array( |
|
| 114 | + $preserve = empty($content['id']) ? array() : array('old_account' => array_intersect_key($account, array_flip(array( |
|
| 117 | 115 | 'account_lid', 'account_status', 'account_groups', 'anonymous', 'changepassword', |
| 118 | 116 | 'mustchangepassword', 'account_primary_group', 'homedirectory', 'loginshell', |
| 119 | 117 | 'account_expires', 'account_firstname', 'account_lastname', 'account_email'))), |
| 120 | 118 | 'deny_edit' => $deny_edit); |
| 121 | 119 | |
| 122 | - if($content && $_GET['copy']) |
|
| 120 | + if ($content && $_GET['copy']) |
|
| 123 | 121 | { |
| 124 | 122 | $this->copy($content, $account, $preserve); |
| 125 | 123 | } |
@@ -146,12 +144,12 @@ discard block |
||
| 146 | 144 | { |
| 147 | 145 | if (!isset($content['mustchangepassword'])) |
| 148 | 146 | { |
| 149 | - $content['mustchangepassword'] = true; // was readonly because already set |
|
| 147 | + $content['mustchangepassword'] = true; // was readonly because already set |
|
| 150 | 148 | } |
| 151 | 149 | $content['account_firstname'] = $content['n_given']; |
| 152 | 150 | $content['account_lastname'] = $content['n_family']; |
| 153 | 151 | $content['account_email'] = $content['email']; |
| 154 | - if($content['account_passwd'] && $content['account_passwd'] !== $content['account_passwd_2']) |
|
| 152 | + if ($content['account_passwd'] && $content['account_passwd'] !== $content['account_passwd_2']) |
|
| 155 | 153 | { |
| 156 | 154 | throw new Api\Exception\WrongUserinput('Passwords are not the same'); |
| 157 | 155 | } |
@@ -163,7 +161,7 @@ discard block |
||
| 163 | 161 | { |
| 164 | 162 | $old['account_groups'] = $content['old_account']['account_groups']; |
| 165 | 163 | } |
| 166 | - if($content['account_passwd']) |
|
| 164 | + if ($content['account_passwd']) |
|
| 167 | 165 | { |
| 168 | 166 | // Don't put password into history |
| 169 | 167 | $old['account_passwd'] = ''; |
@@ -171,11 +169,11 @@ discard block |
||
| 171 | 169 | } |
| 172 | 170 | if ($content['deny_edit'] || $old === array()) |
| 173 | 171 | { |
| 174 | - return ''; // no need to save account data, if nothing changed |
|
| 172 | + return ''; // no need to save account data, if nothing changed |
|
| 175 | 173 | } |
| 176 | 174 | //error_log(__METHOD__."(".array2string($content).")"); |
| 177 | 175 | $account = array(); |
| 178 | - foreach(array( |
|
| 176 | + foreach (array( |
|
| 179 | 177 | // need to copy/rename some fields named different in account and contact |
| 180 | 178 | 'n_given' => 'account_firstname', |
| 181 | 179 | 'n_family' => 'account_lastname', |
@@ -188,7 +186,7 @@ discard block |
||
| 188 | 186 | 'account_primary_group', |
| 189 | 187 | 'account_expires', 'account_status', |
| 190 | 188 | 'homedirectory', 'loginshell', |
| 191 | - 'requested', 'requested_email', 'comment', // admin_cmd documentation (EPL) |
|
| 189 | + 'requested', 'requested_email', 'comment', // admin_cmd documentation (EPL) |
|
| 192 | 190 | ) as $c_name => $a_name) |
| 193 | 191 | { |
| 194 | 192 | if (is_int($c_name)) $c_name = $a_name; |
@@ -200,15 +198,14 @@ discard block |
||
| 200 | 198 | (!isset($content[$c_name]) && $c_name !== 'account_expires' || // account_expires is not set when empty! |
| 201 | 199 | $content['old_account'][$a_name] == $content[$c_name])) |
| 202 | 200 | { |
| 203 | - continue; // no change --> no need to log setting it to identical value |
|
| 201 | + continue; // no change --> no need to log setting it to identical value |
|
| 204 | 202 | } |
| 205 | 203 | |
| 206 | - switch($a_name) |
|
| 204 | + switch ($a_name) |
|
| 207 | 205 | { |
| 208 | 206 | case 'account_expires': |
| 209 | 207 | case 'account_status': |
| 210 | - $account['account_expires'] = $content['account_expires'] ? $content['account_expires'] : |
|
| 211 | - ($content['account_status'] ? 'never' : 'already'); |
|
| 208 | + $account['account_expires'] = $content['account_expires'] ? $content['account_expires'] : ($content['account_status'] ? 'never' : 'already'); |
|
| 212 | 209 | break; |
| 213 | 210 | |
| 214 | 211 | case 'changepassword': // boolean values: admin_cmd_edit_user understands '' as NOT set |
@@ -233,7 +230,7 @@ discard block |
||
| 233 | 230 | 'account' => (int)$content['account_id'], |
| 234 | 231 | 'set' => $account, |
| 235 | 232 | 'old' => $old, |
| 236 | - )+(array)$content['admin_cmd']); |
|
| 233 | + ) + (array)$content['admin_cmd']); |
|
| 237 | 234 | $cmd->run(); |
| 238 | 235 | |
| 239 | 236 | Api\Json\Response::get()->call('egw.refresh', '', 'admin', $cmd->account, $content['account_id'] ? 'edit' : 'add'); |
@@ -267,19 +264,19 @@ discard block |
||
| 267 | 264 | |
| 268 | 265 | // Explicitly, always clear these |
| 269 | 266 | static $clear_content = Array( |
| 270 | - 'n_family','n_given','n_middle','n_suffix','n_fn','n_fileas', |
|
| 271 | - 'account_id','contact_id','id','etag','carddav_name','uid' |
|
| 267 | + 'n_family', 'n_given', 'n_middle', 'n_suffix', 'n_fn', 'n_fileas', |
|
| 268 | + 'account_id', 'contact_id', 'id', 'etag', 'carddav_name', 'uid' |
|
| 272 | 269 | ); |
| 273 | - foreach($clear_content as $field) |
|
| 270 | + foreach ($clear_content as $field) |
|
| 274 | 271 | { |
| 275 | - $account[$field] =''; |
|
| 272 | + $account[$field] = ''; |
|
| 276 | 273 | $preserve[$field] = ''; |
| 277 | 274 | } |
| 278 | 275 | $account['link_to']['to_id'] = 0; |
| 279 | 276 | unset($preserve['old_account']); |
| 280 | 277 | |
| 281 | 278 | // Never copy these on an account |
| 282 | - foreach(static::$copy_clear_fields as $field) |
|
| 279 | + foreach (static::$copy_clear_fields as $field) |
|
| 283 | 280 | { |
| 284 | 281 | unset($account[$field]); |
| 285 | 282 | } |
@@ -290,7 +287,7 @@ discard block |
||
| 290 | 287 | * |
| 291 | 288 | * @param array $content =null |
| 292 | 289 | */ |
| 293 | - public static function delete(array $content=null) |
|
| 290 | + public static function delete(array $content = null) |
|
| 294 | 291 | { |
| 295 | 292 | if (!is_array($content)) |
| 296 | 293 | { |
@@ -307,7 +304,7 @@ discard block |
||
| 307 | 304 | } |
| 308 | 305 | //error_log(__METHOD__."() \$_GET[account_id]=$_GET[account_id], \$_GET[contact_id]=$_GET[contact_id] content=".array2string($content)); |
| 309 | 306 | } |
| 310 | - if ($GLOBALS['egw']->acl->check('account_access',32,'admin') || |
|
| 307 | + if ($GLOBALS['egw']->acl->check('account_access', 32, 'admin') || |
|
| 311 | 308 | $GLOBALS['egw_info']['user']['account_id'] == $content['account_id']) |
| 312 | 309 | { |
| 313 | 310 | Framework::window_close(lang('Permission denied!!!')); |
@@ -319,7 +316,7 @@ discard block |
||
| 319 | 316 | 'new_user' => $content['new_owner'], |
| 320 | 317 | 'is_user' => $content['account_id'] > 0, |
| 321 | 318 | 'change_apps' => $content['delete_apps'] |
| 322 | - ) + (array)$content['admin_cmd']); |
|
| 319 | + ) + (array)$content['admin_cmd']); |
|
| 323 | 320 | $msg = $cmd->run(); |
| 324 | 321 | if ($content['contact_id']) |
| 325 | 322 | { |
@@ -337,19 +334,19 @@ discard block |
||
| 337 | 334 | |
| 338 | 335 | // Get a count of entries owned by the user |
| 339 | 336 | $counts = $GLOBALS['egw']->accounts->get_account_entry_counts($content['account_id']); |
| 340 | - foreach($counts as $app => $counts) |
|
| 337 | + foreach ($counts as $app => $counts) |
|
| 341 | 338 | { |
| 342 | 339 | $entry = Api\Link::get_registry($app, 'entries'); |
| 343 | - if(!$entry) |
|
| 340 | + if (!$entry) |
|
| 344 | 341 | { |
| 345 | 342 | $entry = lang('Entries'); |
| 346 | 343 | } |
| 347 | - if($counts['total'] && Api\Hooks::exists('deleteaccount', $app)) |
|
| 344 | + if ($counts['total'] && Api\Hooks::exists('deleteaccount', $app)) |
|
| 348 | 345 | { |
| 349 | 346 | $content['delete_apps'][] = $app; |
| 350 | 347 | $sel_options['delete_apps'][] = array( |
| 351 | 348 | 'value' => $app, |
| 352 | - 'label' => lang($app) . ': ' . $counts['total'] . ' '.$entry |
|
| 349 | + 'label' => lang($app).': '.$counts['total'].' '.$entry |
|
| 353 | 350 | ); |
| 354 | 351 | } |
| 355 | 352 | else if ($counts['total']) |
@@ -357,17 +354,17 @@ discard block |
||
| 357 | 354 | // These ones don't support the needed hook |
| 358 | 355 | $content['counts'][] = array( |
| 359 | 356 | 'app' => $app, |
| 360 | - 'count' => $counts['total'] . ' '.$entry |
|
| 357 | + 'count' => $counts['total'].' '.$entry |
|
| 361 | 358 | ); |
| 362 | 359 | } |
| 363 | 360 | } |
| 364 | 361 | // Add filemanager home directory in as special case, hook is in the API |
| 365 | - if(Api\Vfs::file_exists('/home/'.$GLOBALS['egw']->accounts->id2name($content['account_id']))) |
|
| 362 | + if (Api\Vfs::file_exists('/home/'.$GLOBALS['egw']->accounts->id2name($content['account_id']))) |
|
| 366 | 363 | { |
| 367 | 364 | $app = 'filemanager'; |
| 368 | 365 | $sel_options['delete_apps'][] = array( |
| 369 | 366 | 'value' => $app, |
| 370 | - 'label' => lang($app) . ': /home' |
|
| 367 | + 'label' => lang($app).': /home' |
|
| 371 | 368 | ); |
| 372 | 369 | $content['delete_apps'][] = $app; |
| 373 | 370 | } |
@@ -429,7 +426,7 @@ discard block |
||
| 429 | 426 | } |
| 430 | 427 | } |
| 431 | 428 | |
| 432 | - if (!$data['account_lid'] && !$data['account_id']) return; // makes no sense to check before |
|
| 429 | + if (!$data['account_lid'] && !$data['account_id']) return; // makes no sense to check before |
|
| 433 | 430 | |
| 434 | 431 | // set home-directory when account_lid is entered, but only for new Api\Accounts |
| 435 | 432 | if ($changed == 'account_lid' && !$data['account_id'] && |
@@ -448,7 +445,7 @@ discard block |
||
| 448 | 445 | $cmd = new admin_cmd_edit_user($data['account_id'], $data); |
| 449 | 446 | $cmd->run(null, false, false, true); |
| 450 | 447 | } |
| 451 | - catch(Exception $e) |
|
| 448 | + catch (Exception $e) |
|
| 452 | 449 | { |
| 453 | 450 | Api\Json\Response::get()->data($e->getMessage()); |
| 454 | 451 | } |
@@ -266,7 +266,7 @@ |
||
| 266 | 266 | $content['owner'] = '0'; |
| 267 | 267 | |
| 268 | 268 | // Explicitly, always clear these |
| 269 | - static $clear_content = Array( |
|
| 269 | + static $clear_content = array( |
|
| 270 | 270 | 'n_family','n_given','n_middle','n_suffix','n_fn','n_fileas', |
| 271 | 271 | 'account_id','contact_id','id','etag','carddav_name','uid' |
| 272 | 272 | ); |