示例#1
0
文件: user.php 项目: nergal/2mio
 /**
  * Insert a new object to the database
  *
  * @param  Validation $validation Validation object
  * @return ORM
  */
 public function create(Validation $validation = NULL)
 {
     /**
      * PHPBB fields
      * @var object(mixed)
      */
     $this->username_clean = NULL;
     if (!empty($this->username)) {
         $this->username_clean = mb_strtolower($this->username);
     }
     $this->user_pass_convert = 0;
     $this->group_id = 3316;
     $this->user_email_hash = Helper::phpbb_email_hash($this->email);
     // Опциональные для заполнения поля
     $this->user_style = 1;
     $this->user_lang = 'ru';
     $this->user_regdate = time();
     $this->user_passchg = time();
     $this->user_lastmark = time();
     $this->user_timezone = '2.00';
     $this->user_dateformat = 'D M d, Y H:i';
     $this->user_options = 230271;
     $this->user_form_salt = Helper::unique_id();
     // FIXIT: см. внутрь функции
     $orm = parent::create($validation);
     if ($orm->loaded()) {
         $query = 'INSERT INTO phpbb3.phpbb_user_group(user_id, group_id, user_pending) ';
         $query .= 'VALUES(:user_id, :group_id, 0)';
         $user_group = DB::query(Database::INSERT, $query);
         $user_group->parameters(array(':user_id' => $orm->user_id, ':group_id' => $orm->group_id));
         $user_group->execute();
     }
     return $orm;
 }
示例#2
0
 public function create(Validation $val = NULL)
 {
     $result = parent::create($val);
     $slug = site::slugify($this->username);
     $orgslug = $slug;
     $existing = ORM::factory('User')->where('slug', '=', $slug)->find();
     $i = 2;
     while ($existing->loaded()) {
         $slug = $orgslug . '-' . $i;
         $i++;
     }
     $this->slug = $slug;
     $this->update();
     $options = ORM::factory('User_Option');
     $options->user_id = $this->id;
     $options->save();
 }