Beispiel #1
0
 static function loadFromResult($res, $db, $bulkLoad = false)
 {
     $rows = array();
     $threads = array();
     foreach ($res as $row) {
         $rows[] = $row;
         if (!$bulkLoad) {
             $threads[$row->thread_id] = Thread::newFromRow($row);
         }
     }
     if (!$bulkLoad) {
         return $threads;
     }
     return Thread::bulkLoad($rows);
 }
 /**
  * Returns an array of structures. Each structure has the keys 'top' and 'posts'.
  * 'top' contains the top-level thread to display.
  * 'posts' contains an array of integer post IDs which should be highlighted.
  */
 function getThreads()
 {
     $rows = $this->getRows();
     if (!count($rows)) {
         return false;
     }
     $threads = Thread::bulkLoad($rows);
     $thread_ids = array_keys($threads);
     $output = array();
     foreach ($threads as $id => $thread) {
         $output[$id] = array('top' => $thread, 'posts' => array());
     }
     $dbr = wfGetDB(DB_SLAVE);
     $res = $dbr->select(array('user_message_state'), array('ums_thread', 'ums_conversation'), array('ums_user' => $this->user->getId(), 'ums_conversation' => $thread_ids), __METHOD__);
     foreach ($res as $row) {
         $top = $row->ums_conversation;
         $thread = $row->ums_thread;
         $output[$top]['posts'][] = $thread;
     }
     return $output;
 }
 function replies()
 {
     if (!$this->id()) {
         return array();
     }
     if (!is_null($this->replies)) {
         $this->checkReplies($this->replies);
         return $this->replies;
     }
     $this->dieIfHistorical();
     // Check cache
     if (isset(self::$replyCacheById[$this->id()])) {
         return $this->replies = self::$replyCacheById[$this->id()];
     }
     $this->replies = array();
     $dbr = wfGetDB(DB_SLAVE);
     $res = $dbr->select('thread', '*', array('thread_parent' => $this->id(), 'thread_type != ' . $dbr->addQuotes(Threads::TYPE_DELETED)), __METHOD__);
     $rows = array();
     foreach ($res as $row) {
         $rows[] = $row;
     }
     $this->replies = Thread::bulkLoad($rows);
     $this->checkReplies($this->replies);
     return $this->replies;
 }
Beispiel #4
0
 function getPageThreads($pager)
 {
     $rows = $pager->getRows();
     return Thread::bulkLoad($rows);
 }