Ejemplo n.º 1
0
 public function addArticleHistory($article_name, $old_content, $new_content, $user_id, $reason = null)
 {
     if (!Core::isTransactionActive()) {
         $transaction = Core::startTransaction();
     }
     $crit = $this->getCriteria();
     $crit->addInsert(self::ARTICLE_NAME, $article_name);
     $crit->addInsert(self::AUTHOR, $user_id);
     $revision_number = $this->_getNextRevisionNumberForArticle($article_name);
     $crit->addInsert(self::REVISION, $revision_number);
     if (!($revision_number == 1 && $old_content == $new_content)) {
         $crit->addInsert(self::OLD_CONTENT, $old_content);
     } else {
         $crit->addInsert(self::OLD_CONTENT, '');
     }
     $crit->addInsert(self::NEW_CONTENT, $new_content);
     if ($reason !== null) {
         $crit->addInsert(self::REASON, $reason);
     }
     $crit->addInsert(self::SCOPE, framework\Context::getScope()->getID());
     $crit->addInsert(self::DATE, NOW);
     $res = $this->doInsert($crit);
     if (isset($transaction)) {
         $transaction->commitAndEnd();
     }
     return $revision_number;
 }