Esempio n. 1
0
function insert_index(&$words, $location, $pContentId)
{
    global $gBitSystem;
    if (!empty($pContentId)) {
        delete_index($pContentId);
        $now = $gBitSystem->getUTCTime();
        foreach ($words as $key => $value) {
            if (strlen($key) >= $gBitSystem->getConfig('search_min_wordlength')) {
                // todo: stopwords + common words.
                $query = "INSERT INTO `" . BIT_DB_PREFIX . "search_index`\n\t\t\t\t\t(`content_id`,`searchword`,`i_count`,`last_update`) values (?,?,?,?)";
                $gBitSystem->mDb->query($query, array($pContentId, $key, (int) $value, $now));
            }
            // What happened to location?
        }
    }
}
Esempio n. 2
0
 /**
  * set the status of an article
  * @param $pStatusId new status id of the article
  * @param $pArticleId of the article that is being changed - if not set, it will attemtp to change the currently loaded article
  * @return new status of article on success - else returns NULL
  * @access public
  **/
 public function setStatus($pStatusId, $pArticleId = NULL, $pContentId = NULL)
 {
     global $gBitSystem;
     $validStatuses = array(ARTICLE_STATUS_DENIED, ARTICLE_STATUS_DRAFT, ARTICLE_STATUS_PENDING, ARTICLE_STATUS_APPROVED, ARTICLE_STATUS_RETIRED);
     if (!in_array($pStatusId, $validStatuses)) {
         $this->mErrors[] = "Invalid article status";
         return FALSE;
     }
     if (empty($pContentId) and $this->isValid()) {
         $pContentId = $this->mContentId;
     }
     if (empty($pArticleId) and $this->isValid()) {
         $pArticleId = $this->mArticleId;
     }
     if (!empty($pContentId) and !$this->isValid()) {
         $this->mContentId = $pContentId;
     }
     if (!empty($pArticleId) and !$this->isValid()) {
         $this->mArticleId = $pArticleId;
     }
     if (empty($pArticleId) && $this->isValid()) {
         $pArticleId = $this->mArticleId;
     }
     if (@$this->verifyId($pArticleId)) {
         $sql = "UPDATE `" . BIT_DB_PREFIX . "articles` SET `status_id` = ? WHERE `article_id` = ?";
         $rs = $this->mDb->query($sql, array($pStatusId, $pArticleId));
         // Calling the index function for approved articles ...
         if ($gBitSystem->isPackageActive('search')) {
             include_once SEARCH_PKG_PATH . 'refresh_functions.php';
             if ($pStatusId == ARTICLE_STATUS_APPROVED) {
                 refresh_index($this);
             } elseif (!$pStatusId == ARTICLE_STATUS_RETIRED) {
                 delete_index($pContentId);
                 // delete it from the search index unless retired ...
             }
         }
         return $pStatusId;
     }
 }