Example #1
0
 private function initUser($ids)
 {
     $idl = [];
     foreach ($ids as $v) {
         if (!User::UserStack($v)) {
             $idl[$v] = $v;
         }
     }
     unset($ids);
     if (reset($idl)) {
         $list = $this->db->select("users", ['id' => 'id', 'user_name' => 'name', 'user_aliases' => 'aliases', 'user_email' => 'email', 'user_url' => 'url', 'user_status' => 'status', 'user_registered_time' => 'registered_time', 'user_last_login_time' => 'last_login_time', 'user_avatar' => 'avatar'], ['id' => $idl]);
         if ($list === false) {
             Log::write(_("Select other users error."), Log::SQL);
         } else {
             foreach ($list as &$v) {
                 //保存数据到堆栈
                 new User($v, true);
             }
         }
     }
 }
Example #2
0
 /**
  * 根据用户获取对他的项目上的对应评论
  * @param int $uid
  * @return array
  */
 public function getListOfUserOnObject($uid)
 {
     if (!$this->setCount(self::TYPE_Object_user, $uid)) {
         return [];
     }
     $list = $this->db->select($this->table, ['[><]comments' => ['comments_id' => 'id'], '[><]users' => ['users_id' => 'id']], [$this->table . "." . $this->type . "_id" => $this->type . "_id", $this->table . ".comments_id" => "comments_id", $this->table . ".object_users_id" => "object_users_id", $this->table . '.users_id' => 'users_id', 'users.id' => 'user_id', 'users.user_name' => 'user_name', 'users.user_aliases' => 'user_aliases', 'users.user_email' => 'user_email', 'users.user_url' => 'user_url', 'users.user_status' => 'user_status', 'users.user_registered_time' => 'user_registered_time', 'users.user_last_login_time' => 'user_last_login_time', 'users.user_avatar' => 'user_avatar', 'comments.comment_content' => 'comment_content', 'comments.comment_time' => 'comment_time'], [$this->table . '.object_users_id' => $uid, 'LIMIT' => [($this->count['page'] - 1) * $this->count['number'], $this->count['number']], 'ORDER' => $this->table . ".comments_id DESC"]);
     $this->getListDataParse($list);
     for ($i = 0, $l = count($list); $i < $l; $i++) {
         $user_info = [];
         foreach ($list[$i] as $k => $v) {
             if (strpos($k, "user_") === 0) {
                 $user_info[substr($k, 5)] = $v;
             }
         }
         //从堆栈获取用户
         $list[$i]['user_object'] = User::UserStack(+$user_info['id']);
         if (!is_object($list[$i]['user_object'])) {
             $list[$i]['user_object'] = new User($user_info, true);
         }
     }
     return $list;
 }
Example #3
0
 /**
  * 获取文章的内容
  * @return array|false|null
  */
 public function getInfo()
 {
     if (!is_array($this->info)) {
         if ($this->post_id > 0) {
             $where = ['posts.id' => $this->post_id];
         } else {
             if (strlen($this->post_name) > 0) {
                 $where = ['posts.post_name' => $this->post_name];
             } else {
                 return false;
             }
         }
         $info = $this->db->select("posts", ['[><]users' => ['users_id' => 'id']], ['posts.id' => 'post_id', 'posts.post_title' => 'post_title', 'posts.users_id' => 'post_users_id', 'posts.post_name' => 'post_name', 'posts.post_time' => 'post_time', 'posts.post_content' => 'post_content', 'posts.post_update_time' => 'post_update_time', 'posts.post_category' => 'post_category', 'posts.post_status' => 'post_status', 'posts.post_description' => 'post_description', 'posts.post_keyword' => 'post_keyword', 'posts.post_comment_count' => 'post_comment_count', 'posts.post_allow_comment' => 'post_allow_comment', 'users.id' => 'user_id', 'users.user_name' => 'user_name', 'users.user_aliases' => 'user_aliases', 'users.user_email' => 'user_email', 'users.user_url' => 'user_url', 'users.user_status' => 'user_status', 'users.user_registered_time' => 'user_registered_time', 'users.user_last_login_time' => 'user_last_login_time', 'users.user_avatar' => 'user_avatar'], $where);
         if (isset($info[0]['post_id'])) {
             $user_info = [];
             $this->info = [];
             foreach ($info[0] as $k => $v) {
                 if ($k[0] === 'u') {
                     $user_info[substr($k, 5)] = $v;
                 } else {
                     $this->info[$k] = $v;
                 }
             }
             //从堆栈获取用户
             $this->post_user = User::UserStack(+$user_info['id']);
             if (!is_object($this->post_user)) {
                 $this->post_user = new User($user_info, true);
             }
         }
     }
     return $this->info;
 }
Example #4
0
 /**
  * 解析的时候子返回顶级评论,回复需单独解析
  * @param array $data
  * @return Comment[]
  */
 private function parse($data)
 {
     //echo "PARSE:" . c()->getTimer()->get_second() . "<br>";
     $this->__lib('Comment');
     /**
      * @var Comment[] $rt
      */
     $rt = [];
     for ($i = 0, $l = count($data); $i < $l; $i++) {
         $user_info = [];
         $comment = [];
         foreach ($data[$i] as $k => $v) {
             $index = strpos($k, '_');
             switch ($index) {
                 case 4:
                     $user_info[substr($k, 5)] = $v;
                     break;
                 case 7:
                     $comment[$k] = $v;
                     break;
             }
         }
         //从堆栈获取用户
         $user = User::UserStack(+$user_info['id']);
         if (!is_object($user)) {
             $user = new User($user_info, true);
         }
         $rt[$comment['comment_id']] = new Comment($comment, $user->getId());
     }
     $top = [];
     foreach (array_keys($rt) as $v) {
         $parent = $rt[$v]->getCommentParent();
         if ($parent == 0) {
             $top[] =& $rt[$v];
         } else {
             $rt[$parent]->createSubNode(intval($v));
         }
     }
     //		echo "PARSE END:" . c()->getTimer()->get_second() . "<br>";
     return $top;
 }