X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=user_add.php;h=403c6ca6a37b6cfc2eb82d060e05d7a546b035b1;hb=3d5bc3e13797cb7121ed8548b723a0ef85eda80c;hp=cf2fe76b511a7fac953a828d93b1ecdc0cd5bc04;hpb=098a79f0819ebb89b7d48df4a6b154af4560f68e;p=timetracker.git diff --git a/user_add.php b/user_add.php index cf2fe76b..403c6ca6 100644 --- a/user_add.php +++ b/user_add.php @@ -43,11 +43,11 @@ if (!ttAccessCheck(right_manage_team)) { // The "limit" plugin is not required for normal operation of the Time Tracker. @include('plugins/limit/user_add.php'); -if (in_array('cl', explode(',', $user->plugins))) +if ($user->isPluginEnabled('cl')) $clients = ttTeamHelper::getActiveClients($user->team_id); $assigned_projects = array(); -if ($request->getMethod() == 'POST') { +if ($request->isPost()) { $cl_name = trim($request->getParameter('name')); $cl_login = trim($request->getParameter('login')); if (!$auth->isPasswordExternal()) { @@ -68,7 +68,7 @@ if ($request->getMethod() == 'POST') { $project_with_rate['rate'] = $request->getParameter('rate_'.$p); $assigned_projects[] = $project_with_rate; } else - $errors->add($i18n->getKey('error.field'), 'rate_'.$p); + $err->add($i18n->getKey('error.field'), 'rate_'.$p); } } } @@ -84,10 +84,10 @@ $form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'email','value'= $roles[ROLE_USER] = $i18n->getKey('label.user'); $roles[ROLE_COMANAGER] = $i18n->getKey('form.users.comanager'); -if (in_array('cl', explode(',', $user->plugins))) +if ($user->isPluginEnabled('cl')) $roles[ROLE_CLIENT] = $i18n->getKey('label.client'); $form->addInput(array('type'=>'combobox','onchange'=>'handleClientControl()','name'=>'role','value'=>$cl_role,'data'=>$roles)); -if (in_array('cl', explode(',', $user->plugins))) +if ($user->isPluginEnabled('cl')) $form->addInput(array('type'=>'combobox','name'=>'client','value'=>$cl_client_id,'data'=>$clients,'datakeys'=>array('id', 'name'),'empty'=>array(''=>$i18n->getKey('dropdown.select')))); $form->addInput(array('type'=>'floatfield','maxlength'=>'10','name'=>'rate','format'=>'.2','value'=>$cl_rate)); @@ -131,20 +131,20 @@ $form->addInputElement($table); $form->addInput(array('type'=>'submit','name'=>'btn_submit','value'=>$i18n->getKey('button.submit'))); -if ($request->getMethod() == 'POST') { +if ($request->isPost()) { // Validate user input. - if (!ttValidString($cl_name)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.person_name')); - if (!ttValidString($cl_login)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.login')); + 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')); if (!$auth->isPasswordExternal()) { - if (!ttValidString($cl_password1)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.password')); - if (!ttValidString($cl_password2)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.confirm_password')); + 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) - $errors->add($i18n->getKey('error.not_equal'), $i18n->getKey('label.password'), $i18n->getKey('label.confirm_password')); - } - if (!ttValidEmail($cl_email, true)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('label.email')); - if (!ttValidFloat($cl_rate, true)) $errors->add($i18n->getKey('error.field'), $i18n->getKey('form.users.default_rate')); + $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')); + if (!ttValidFloat($cl_rate, true)) $err->add($i18n->getKey('error.field'), $i18n->getKey('form.users.default_rate')); - if ($errors->isEmpty()) { + if ($err->no()) { if (!ttUserHelper::getUserByLogin($cl_login)) { $fields = array( 'name' => $cl_name, @@ -160,11 +160,11 @@ if ($request->getMethod() == 'POST') { header('Location: users.php'); exit(); } else - $errors->add($i18n->getKey('error.db')); + $err->add($i18n->getKey('error.db')); } else - $errors->add($i18n->getKey('error.user_exists')); + $err->add($i18n->getKey('error.user_exists')); } -} // post +} // isPost $smarty->assign('auth_external', $auth->isPasswordExternal()); $smarty->assign('forms', array($form->getName()=>$form->toArray())); @@ -172,4 +172,3 @@ $smarty->assign('onload', 'onLoad="document.userForm.name.focus();handleClientCo $smarty->assign('title', $i18n->getKey('title.add_user')); $smarty->assign('content_page_name', 'user_add.tpl'); $smarty->display('index.tpl'); -?> \ No newline at end of file