X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=register.php;h=0c0374b332b2418d779837bb57a3f143faaf1002;hb=8a671525046655e057a15c6de9507834322b466d;hp=a34a78fbc993fa1f63a5ca328131d61913a2ab4e;hpb=2ccee198591bc2ad5d80b5e1076246449d9232c1;p=timetracker.git diff --git a/register.php b/register.php index a34a78fb..0c0374b3 100644 --- a/register.php +++ b/register.php @@ -28,20 +28,22 @@ require_once('initialize.php'); import('form.Form'); -import('ttUserHelper'); -import('ttRoleHelper'); -if (!isTrue(MULTITEAM_MODE) || $auth->isPasswordExternal()) { +if (!isTrue('MULTIORG_MODE') || $auth->isPasswordExternal()) { header('Location: login.php'); exit(); } +// Use the "limit" plugin if we have one. Ignore include errors. +// The "limit" plugin is not required for normal operation of Time Tracker. +@include('plugins/limit/register.php'); + $auth->doLogout(); if (!defined('CURRENCY_DEFAULT')) define('CURRENCY_DEFAULT', '$'); if ($request->isPost()) { - $cl_team_name = trim($request->getParameter('team_name')); + $cl_group_name = trim($request->getParameter('group_name')); $cl_currency = trim($request->getParameter('currency')); if (!$cl_currency) $cl_currency = CURRENCY_DEFAULT; $cl_lang = $request->getParameter('lang'); @@ -55,8 +57,8 @@ if ($request->isPost()) { $cl_lang = $i18n->lang; // Browser setting from initialize.php. } -$form = new Form('profileForm'); -$form->addInput(array('type'=>'text','maxlength'=>'200','name'=>'team_name','value'=>$cl_team_name)); +$form = new Form('groupForm'); +$form->addInput(array('type'=>'text','maxlength'=>'200','name'=>'group_name','value'=>$cl_group_name)); $form->addInput(array('type'=>'text','maxlength'=>'7','name'=>'currency','value'=>$cl_currency)); // Prepare an array of available languages. @@ -82,7 +84,7 @@ $form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'manager_login', $form->addInput(array('type'=>'password','maxlength'=>'30','name'=>'password1','value'=>$cl_password1)); $form->addInput(array('type'=>'password','maxlength'=>'30','name'=>'password2','value'=>$cl_password2)); $form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'manager_email','value'=>$cl_manager_email)); -$form->addInput(array('type'=>'submit','name'=>'btn_submit','value'=>$i18n->getKey('button.submit'))); +$form->addInput(array('type'=>'submit','name'=>'btn_submit','value'=>$i18n->get('button.submit'))); if ($request->isPost()) { // Create fields array for ttRegistrator instance. @@ -92,51 +94,29 @@ if ($request->isPost()) { 'password1' => $cl_password1, 'password2' => $cl_password2, 'email' => $cl_manager_email, - 'group_name' => $cl_team_name, + 'group_name' => $cl_group_name, 'currency' => $cl_currency, 'lang' => $cl_lang); // Create an instance of ttRegistrator class. import('ttRegistrator'); $registrator = new ttRegistrator($fields, $err); - // Validation of user input occurs in ttRegistrator constructor above. + $registrator->register(); if ($err->no()) { - if (!ttUserHelper::getUserByLogin($cl_manager_login)) { - // Create a new team. - $team_id = ttTeamHelper::insert(array('name'=>$cl_team_name,'currency'=>$cl_currency,'lang'=>$cl_lang)); - if ($team_id) { - if (!ttRoleHelper::createPredefinedRoles($team_id, $cl_lang)) - $err->add($i18n->getKey('error.db')); - - $role_id = ttRoleHelper::getTopManagerRoleID(); - - // Team created, now create a team manager. - $user_id = ttUserHelper::insert(array( - 'team_id' => $team_id, - 'role_id' => $role_id, - 'name' => $cl_manager_name, - 'login' => $cl_manager_login, - 'password' => $cl_password1, - 'email' => $cl_manager_email)); - } - if ($team_id && $user_id) { - if ($auth->doLogin($cl_manager_login, $cl_password1)) { - setcookie('tt_login', $cl_manager_login, time() + COOKIE_EXPIRE, '/'); - header('Location: time.php'); - } else { - header('Location: login.php'); - } - exit(); - } else - $err->add($i18n->getKey('error.db')); - } else - $err->add($i18n->getKey('error.user_exists')); + // Registration successful. + if ($auth->doLogin($cl_manager_login, $cl_password1)) { + setcookie('tt_login', $cl_manager_login, time() + COOKIE_EXPIRE, '/'); + header('Location: time.php'); + } else { + header('Location: login.php'); + } + exit(); } } // isPost -$smarty->assign('title', $i18n->getKey('title.create_team')); +$smarty->assign('title', $i18n->get('title.add_group')); $smarty->assign('forms', array($form->getName()=>$form->toArray())); -$smarty->assign('onload', 'onLoad="document.profileForm.team.focus()"'); +$smarty->assign('onload', 'onLoad="document.groupForm.group_name.focus()"'); $smarty->assign('content_page_name', 'register.tpl'); $smarty->display('index.tpl');