X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/timetracker.git/blobdiff_plain/785d404c84c153bda7d45d3aedfefa81985703b3..7ca15b5853146dd809f2ad3f5b2e1d9dab4f8dd4:/admin_options.php diff --git a/admin_options.php b/admin_options.php index ae901d6d..14cb3f54 100644 --- a/admin_options.php +++ b/admin_options.php @@ -31,7 +31,7 @@ import('form.Form'); import('ttUserHelper'); // Access check. -if (!ttAccessCheck(right_administer_site)) { +if (!ttAccessAllowed('administer_site')) { header('Location: access_denied.php'); exit(); } @@ -61,33 +61,20 @@ $form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'email','value'= $form->addInput(array('type'=>'submit','name'=>'btn_submit','value'=>$i18n->getKey('button.submit'))); if ($request->isPost()) { - // Validate user input. - if (!ttValidString($cl_name)) $err->add($i18n->getKey('error.field'), $i18n->getKey('label.person_name')); - if (!ttValidString($cl_login)) $err->add($i18n->getKey('error.field'), $i18n->getKey('label.login')); - // New login must be unique. - if ($cl_login != $user->login && ttUserHelper::getUserByLogin($cl_login)) - $err->add($i18n->getKey('error.user_exists')); - if (!$auth->isPasswordExternal() && ($cl_password1 || $cl_password2)) { - if (!ttValidString($cl_password1)) $err->add($i18n->getKey('error.field'), $i18n->getKey('label.password')); - if (!ttValidString($cl_password2)) $err->add($i18n->getKey('error.field'), $i18n->getKey('label.confirm_password')); - if ($cl_password1 !== $cl_password2) - $err->add($i18n->getKey('error.not_equal'), $i18n->getKey('label.password'), $i18n->getKey('label.confirm_password')); - } - if (!ttValidEmail($cl_email, true)) $err->add($i18n->getKey('error.field'), $i18n->getKey('label.email')); - // Finished validating user input. + // Create fields array for ttAdmin instance. + $fields = array( + 'name' => $cl_name, + 'login' => $cl_login, + 'password1' => $cl_password1, + 'password2' => $cl_password2, + 'email' => $cl_email); - if ($err->no()) { - if (ttUserHelper::update($user->id, array( - 'name' => $cl_name, - 'login' => $cl_login, - 'password' => $cl_password1, - 'email' => $cl_email, - 'status' => ACTIVE))) { - header('Location: admin_teams.php'); - exit(); - } else { - $err->add($i18n->getKey('error.db')); - } + import('ttAdmin'); + $admin = new ttAdmin($err); + $result = $admin->updateSelf($fields); + if ($result) { + header('Location: admin_teams.php'); + exit(); } } // isPost