Beispiel #1
0
 public function Register($username, $email, $firstName, $lastName, $password, $timezone, $language, $homepageId, $additionalFields = array(), $attributeValues = array(), $groups = null)
 {
     $encryptedPassword = $this->_passwordEncryption->EncryptPassword($password);
     $attributes = new UserAttribute($additionalFields);
     if ($this->CreatePending()) {
         $user = User::CreatePending($firstName, $lastName, $email, $username, $language, $timezone, $encryptedPassword->EncryptedPassword(), $encryptedPassword->Salt(), $homepageId);
     } else {
         $user = User::Create($firstName, $lastName, $email, $username, $language, $timezone, $encryptedPassword->EncryptedPassword(), $encryptedPassword->Salt(), $homepageId);
     }
     $user->ChangeAttributes($attributes->Get(UserAttribute::Phone), $attributes->Get(UserAttribute::Organization), $attributes->Get(UserAttribute::Position));
     $user->ChangeCustomAttributes($attributeValues);
     if ($groups != null) {
         $user->WithGroups($groups);
     }
     if (Configuration::Instance()->GetKey(ConfigKeys::REGISTRATION_AUTO_SUBSCRIBE_EMAIL, new BooleanConverter())) {
         foreach (ReservationEvent::AllEvents() as $event) {
             $user->ChangeEmailPreference($event, true);
         }
     }
     $userId = $this->_userRepository->Add($user);
     $this->AutoAssignPermissions($userId);
     if (Configuration::Instance()->GetKey(ConfigKeys::REGISTRATION_NOTIFY, new BooleanConverter())) {
         ServiceLocator::GetEmailService()->Send(new AccountCreationEmail($user, ServiceLocator::GetServer()->GetUserSession()));
     }
     return $user;
 }
Beispiel #2
0
 public function Register($username, $email, $firstName, $lastName, $password, $timezone, $language, $homepageId, $additionalFields = array(), $attributeValues = array())
 {
     $encryptedPassword = $this->_passwordEncryption->EncryptPassword($password);
     $attributes = new UserAttribute($additionalFields);
     if ($this->CreatePending()) {
         $user = User::CreatePending($firstName, $lastName, $email, $username, $language, $timezone, $encryptedPassword->EncryptedPassword(), $encryptedPassword->Salt(), $homepageId);
     } else {
         $user = User::Create($firstName, $lastName, $email, $username, $language, $timezone, $encryptedPassword->EncryptedPassword(), $encryptedPassword->Salt(), $homepageId);
     }
     $user->ChangeAttributes($attributes->Get(UserAttribute::Phone), $attributes->Get(UserAttribute::Organization), $attributes->Get(UserAttribute::Position));
     $user->ChangeCustomAttributes($attributeValues);
     if (Configuration::Instance()->GetKey(ConfigKeys::REGISTRATION_AUTO_SUBSCRIBE_EMAIL, new BooleanConverter())) {
         foreach (ReservationEvent::AllEvents() as $event) {
             $user->ChangeEmailPreference($event, true);
         }
     }
     $userId = $this->_userRepository->Add($user);
     $this->AutoAssignPermissions($userId);
     $addgroupname = Configuration::Instance()->GetKey(ConfigKeys::NEW_USER_GROUP);
     // Match group name to group_id
     $addgroupid_res = ServiceLocator::GetDatabase()->Query(new AdHocCommand("select group_id from groups where name = '{$addgroupname}'"));
     while ($row = $addgroupid_res->GetRow()) {
         $addgroupid = $row['group_id'];
     }
     //Add user to group
     if ($addgroupid != NULL) {
         ServiceLocator::GetDatabase()->Execute(new AdHocCommand("insert into user_groups(user_id, group_id) VALUES ({$userId}, {$addgroupid})"));
     }
     return $user;
 }
Beispiel #3
0
 public function UpdateUser($userId, $username, $email, $firstName, $lastName, $timezone, $extraAttributes)
 {
     $attributes = new UserAttribute($extraAttributes);
     $user = $this->userRepository->LoadById($userId);
     $user->ChangeName($firstName, $lastName);
     $user->ChangeEmailAddress($email);
     $user->ChangeUsername($username);
     $user->ChangeTimezone($timezone);
     $user->ChangeAttributes($attributes->Get(UserAttribute::Phone), $attributes->Get(UserAttribute::Organization), $attributes->Get(UserAttribute::Position));
     $this->userRepository->Update($user);
     return $user;
 }
 /**
  * setUp method
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     UserAttribute::$userAttributes = null;
 }
 /**
  * 会員項目のレイアウト用のデータ取得
  *
  * @param bool $force 強制的に取得するフラグ
  * @return array 会員項目データ配列
  * @SuppressWarnings(PHPMD.BooleanArgumentFlag)
  */
 public function getUserAttributesForLayout($force = false)
 {
     $this->loadModels(['DataType' => 'DataTypes.DataType', 'UserRole' => 'UserRoles.UserRole', 'UserAttributesRole' => 'UserRoles.UserAttributesRole']);
     if (isset(self::$userAttributes) && !$force) {
         return self::$userAttributes;
     }
     //UserAttributeデータ取得
     $userAttributes = $this->find('all', $this->findOptionsForLayout());
     //UserAttributeChoiceデータ取得
     $userAttributeIds = Hash::extract($userAttributes, '{n}.UserAttribute.id');
     $userAttributeChoices = $this->__getUserAttributeChoice($userAttributeIds);
     //DataTypeデータ取得
     $dataTypes = $this->DataType->getDataTypes($this->UserAttributeSetting->editDataTypes);
     //UserRoleデータの取得
     $userRoles = $this->__getUserRole();
     //戻り値の設定
     $results = array();
     foreach ($userAttributes as $userAttribute) {
         $userAttributeId = $userAttribute['UserAttribute']['id'];
         $dataTypeKey = $userAttribute['UserAttributeSetting']['data_type_key'];
         $result = $userAttribute;
         if ($userAttribute['UserAttribute']['key'] === 'role_key') {
             //権限の設定
             $result['UserAttributeChoice'] = $userRoles;
             $result['UserAttributeChoice'] = Hash::insert($result['UserAttributeChoice'], '{n}.user_attribute_id', $userAttributeId);
         } elseif (isset($dataTypes[$dataTypeKey]['DataTypeChoice'])) {
             //DataTypeChoiceにデータがある場合
             $result['UserAttributeSetting']['data_type_key'] = DataType::DATA_TYPE_SELECT;
             $result['UserAttributeChoice'] = $dataTypes[$dataTypeKey]['DataTypeChoice'];
             $result['UserAttributeChoice'] = Hash::insert($result['UserAttributeChoice'], '{n}.user_attribute_id', $userAttributeId);
         } elseif (isset($userAttributeChoices[$userAttributeId])) {
             //UserAttributeChoiceにデータがある場合
             $result['UserAttributeChoice'] = $userAttributeChoices[$userAttributeId];
         }
         $row = $userAttribute['UserAttributeSetting']['row'];
         $col = $userAttribute['UserAttributeSetting']['col'];
         $weight = $userAttribute['UserAttributeSetting']['weight'];
         $results[$row][$col][$weight] = $result;
     }
     self::$userAttributes = $results;
     return $results;
 }