예제 #1
0
 /**
  * @desc Create a user
  * @param UserAuthentification $user_authentification
  * @param User $user
  * @return InjectQueryResult
  */
 public static function create(User $user, AuthenticationMethod $auth_method, $extended_fields = array())
 {
     $result = self::$querier->insert(DB_TABLE_MEMBER, array('display_name' => TextHelper::htmlspecialchars($user->get_display_name()), 'level' => $user->get_level(), 'groups' => implode('|', $user->get_groups()), 'email' => $user->get_email(), 'show_email' => (int) $user->get_show_email(), 'locale' => $user->get_locale(), 'timezone' => $user->get_timezone(), 'theme' => $user->get_theme(), 'editor' => $user->get_editor(), 'registration_date' => time()));
     $user_id = $result->get_last_inserted_id();
     $auth_method->associate($user_id);
     if ($extended_fields instanceof MemberExtendedFieldsService) {
         $fields_data = $extended_fields->get_data($user_id);
     } elseif (!is_array($extended_fields)) {
         $fields_data = array();
     } else {
         $fields_data = $extended_fields;
     }
     $fields_data['user_id'] = $user_id;
     self::$querier->insert(DB_TABLE_MEMBER_EXTENDED_FIELDS, $fields_data);
     self::regenerate_cache();
     return $user_id;
 }
 /**
  * @desc associate the current authentication method with the given user_id.
  * @param AuthenticationMethod $authentication the authentication method to use
  * @param int $user_id
  * @throws IllegalArgumentException if the user_id is already associate with an authentication method
  */
 public static function associate(AuthenticationMethod $authentication, $user_id)
 {
     $authentication->associate($user_id);
 }