- if ($errors->isEmpty()) {
- if (!ttUserHelper::getUserByLogin($cl_manager_login)) {
- // Create a new team.
- $team_id = ttTeamHelper::insert(array('name'=>$cl_team_name,'currency'=>$cl_currency));
- if ($team_id) {
- // Team created, now create a team manager.
- $user_id = ttUserHelper::insert(array(
- 'team_id' => $team_id,
- 'role' => ROLE_MANAGER,
- '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
- $errors->add($i18n->getKey('error.db'));
- } else
- $errors->add($i18n->getKey('error.user_exists'));
+ // Create an instance of ttRegistrator class.
+ import('ttRegistrator');
+ $registrator = new ttRegistrator($fields, $err);
+ $registrator->register();
+
+ if ($err->no()) {
+ // 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();