- // Validate user input.
- if (!ttValidString($cl_team_name, true)) $err->add($i18n->getKey('error.field'), $i18n->getKey('label.team_name'));
- if (!ttValidString($cl_currency, true)) $err->add($i18n->getKey('error.field'), $i18n->getKey('label.currency'));
- if (!ttValidString($cl_manager_name)) $err->add($i18n->getKey('error.field'), $i18n->getKey('label.manager_name'));
- if (!ttValidString($cl_manager_login)) $err->add($i18n->getKey('error.field'), $i18n->getKey('label.manager_login'));
- 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_manager_email, true)) $err->add($i18n->getKey('error.field'), $i18n->getKey('label.email'));
-
- 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'));
+ // Create fields array for ttRegistrator instance.
+ $fields = array(
+ 'user_name' => $cl_manager_name,
+ 'login' => $cl_manager_login,
+ 'password1' => $cl_password1,
+ 'password2' => $cl_password2,
+ 'email' => $cl_manager_email,
+ 'group_name' => $cl_group_name,
+ 'currency' => $cl_currency,
+ 'lang' => $cl_lang);