public function doCreateSubmit() { $userService = new UserService(); $userVo = Request::getValue("user", "UserValue"); if ($userVo->password != '') { $userVo->password = MD5($userVo->password); } //var_dump($userVo);exit; if (!$userVo->checkOptions($userVo->getCreateOptions())) { View::set("UserCreateValue", $userVo); View::display("Create"); return; } $userVo = $userService->create($userVo); Zee::redirect(Zee::url("user", "list")); }
private function add_user() { if (PersistenceContext::get_querier()->row_exists(DB_TABLE_INTERNAL_AUTHENTICATION, 'WHERE login=:login', array('login' => $this->login))) { throw new Exception($this->login . ' login already use'); } else { if (UserService::user_exists('WHERE email=:email', array('email' => $this->email))) { throw new Exception($this->email . ' email already use'); } else { $user = new User(); $user->set_display_name($this->login); $user->set_level($this->get_real_value($this->level, $this->level_possible_values)); $user->set_email($this->email); $auth_method = new PHPBoostAuthenticationMethod($this->login, $this->password); $auth_method->set_association_parameters($this->get_real_value($this->approbation, $this->approbation_possible_values)); UserService::create($user, $auth_method); CLIOutput::writeln('User added successfull'); } } }
private function save() { $has_error = false; $registration_pass = $this->user_accounts_config->get_member_accounts_validation_method() == UserAccountsConfig::MAIL_USER_ACCOUNTS_VALIDATION ? KeyGenerator::generate_key(15) : ''; $user_aprobation = $this->user_accounts_config->get_member_accounts_validation_method() == UserAccountsConfig::AUTOMATIC_USER_ACCOUNTS_VALIDATION; $user = new User(); $user->set_display_name($this->form->get_value('display_name')); $user->set_level(User::MEMBER_LEVEL); $user->set_email($this->form->get_value('email')); $user->set_show_email(!$this->form->get_value('user_hide_mail')); $user->set_locale($this->form->get_value('lang')->get_raw_value()); $user->set_editor($this->form->get_value('text-editor')->get_raw_value()); $user->set_timezone($this->form->get_value('timezone')->get_raw_value()); if ($this->form->has_field('theme')) { $user->set_theme($this->form->get_value('theme')->get_raw_value()); } $login = $this->form->get_value('email'); if ($this->form->get_value('custom_login')) { $login = $this->form->get_value('login'); } $auth_method = new PHPBoostAuthenticationMethod($login, $this->form->get_value('password')); $auth_method->set_association_parameters($user_aprobation, $registration_pass); try { $user_id = UserService::create($user, $auth_method, $this->member_extended_fields_service); } catch (MemberExtendedFieldErrorsMessageException $e) { $has_error = true; $this->tpl->put('MSG', MessageHelper::display($e->getMessage(), MessageHelper::NOTICE)); } if (!$has_error) { UserRegistrationService::send_email_confirmation($user_id, $user->get_email(), $this->form->get_value('display_name'), $login, $this->form->get_value('password'), $registration_pass); $this->confirm_registration($user_id); } }
private function create_first_admin_account($login, $password, $email, $locale, $theme, $timezone) { $user = new User(); $user->set_display_name($login); $user->set_level(User::ADMIN_LEVEL); $user->set_email($email); $user->set_locale($locale); $user->set_theme($theme); $auth_method = new PHPBoostAuthenticationMethod($login, $password); return UserService::create($user, $auth_method); }
/** * {@inheritDoc} */ public function authenticate() { $data = $this->get_google_user_data(); $google_id = $data['id']; try { $condition = 'WHERE method=:method AND identifier=:identifier'; $parameters = array('method' => self::AUTHENTICATION_METHOD, 'identifier' => $google_id); return $this->querier->get_column_value(DB_TABLE_AUTHENTICATION_METHOD, 'user_id', $condition, $parameters); } catch (RowNotFoundException $e) { $email_exists = $this->querier->row_exists(DB_TABLE_MEMBER, 'WHERE email=:email', array('email' => $data['email'])); if ($email_exists) { $this->error_msg = LangLoader::get_message('external-auth.account-exists', 'user-common'); } else { $user = new User(); $user->set_display_name(utf8_decode($data['name'])); $user->set_level(User::MEMBER_LEVEL); $user->set_email($data['email']); $auth_method = new GoogleAuthenticationMethod(); $fields_data = array('user_avatar' => $data['picture']); return UserService::create($user, $auth_method, $fields_data); } } }
/** * @expectedException PHPUnit_Framework_AssertionFailedError */ public function testUserService() { $service = new UserService(); $service->create(['name' => 'davert']); }
private function save() { $user = new User(); $user->set_display_name($this->form->get_value('display_name')); $user->set_level($this->form->get_value('rank')->get_raw_value()); $user->set_email($this->form->get_value('email')); $login = $this->form->get_value('email'); if ($this->form->get_value('custom_login', false)) { $login = $this->form->get_value('login'); } $auth_method = new PHPBoostAuthenticationMethod($login, $this->form->get_value('password')); UserService::create($user, $auth_method); return $user->get_display_name(); }