/** * @param $params array * @param $db DatabaseBase * @return array */ function getConditions($params, $db) { $conds = array(); // Types $conds['thread_type'] = Threads::TYPE_NORMAL; // Limit $cutoff = time() - intval($params['days'] * 24 * 3600); $cutoff = $db->timestamp($cutoff); $conds[] = 'thread_created > ' . $db->addQuotes($cutoff); // Talkpage conditions $pageConds = array(); $talkpages = (array) $params['talkpage']; foreach ($talkpages as $page) { $title = Title::newFromText($page); $pageCond = array('thread_article_namespace' => $title->getNamespace(), 'thread_article_title' => $title->getDBkey()); $pageConds[] = $db->makeList($pageCond, LIST_AND); } // Thread conditions $threads = (array) $params['thread']; foreach ($threads as $thread) { $root = new Article(Title::newFromText($thread)); $thread = Threads::withRoot($root); if (!$thread) { continue; } $threadCond = array('thread_ancestor' => $thread->id(), 'thread_id' => $thread->id()); $pageConds[] = $db->makeList($threadCond, LIST_OR); } if (count($pageConds)) { $conds[] = $db->makeList($pageConds, LIST_OR); } // New thread v. Reply $types = (array) $params['type']; if (!in_array('replies', $types)) { $conds[] = Threads::topLevelClause(); } elseif (!in_array('newthreads', $types)) { $conds[] = '!' . Threads::topLevelClause(); } return $conds; }
function getQueryInfo() { $queryInfo = array('tables' => array('thread'), 'fields' => '*', 'conds' => array(Threads::articleClause($this->article), Threads::topLevelClause(), 'thread_type != ' . $this->mDb->addQuotes(Threads::TYPE_DELETED))); return $queryInfo; }