Example #1
0
 /**
  * Extract values from database and set them to object properties
  * @param integer $id ID of record to be instantiated
  * @return void DB record's fields are loaded into object properties
  */
 private function Get($id)
 {
     $query = 'SELECT * FROM ' . DB_PREFIX . self::$table . ' WHERE ' . self::$id_name . "= {$id}";
     $result = $this->db->Query($query);
     $row = $this->db->FetchAssoc($result);
     foreach ($row as $key => $value) {
         $this->{$key} = $value;
     }
     // User specific values
     View::InitView();
     $this->role = empty($this->role) ? 'user' : $this->role;
     $this->avatar_url = empty($this->avatar) ? View::GetFallbackUrl('images/avatar.gif') : HOST . "/cc-content/uploads/avatars/{$this->avatar}";
     $this->date_created = Functions::GmtToLocal($this->date_created);
     $this->last_login = Functions::GmtToLocal($this->last_login);
     $this->video_count = $this->GetVideoCount();
     Plugin::Trigger('user.get');
 }
Example #2
0
 /**
  * Extract values from database and set them to object properties
  * @param integer $id ID of record to be instantiated
  * @return void
  */
 private function Get($id)
 {
     $query = 'SELECT * FROM ' . DB_PREFIX . self::$table . ' WHERE ' . self::$id_name . "= {$id}";
     $result = $this->db->Query($query);
     $row = $this->db->FetchAssoc($result);
     foreach ($row as $key => $value) {
         $this->{$key} = $value;
     }
     // Custom Vars
     $this->date_created = Functions::GmtToLocal($this->date_created);
     $this->comments_display = nl2br($row['comments']);
     if ($this->user_id != 0) {
         $user = new User($this->user_id);
         $this->name = $user->username;
         $this->email = $user->email;
         $this->website = HOST . '/members/' . $user->username . '/';
         $this->avatar_url = $user->avatar_url;
     } else {
         View::InitView();
         $this->avatar_url = View::GetFallbackUrl('images/avatar.gif');
     }
     Plugin::Trigger('comment.get');
 }