function authenticateItemHash($articleId, $password)
 {
     $articles = new Articles();
     $article = $articles->getBlogArticle($articleId);
     $passwordField = $article->getFieldObject("password_field");
     return md5($passwordField->getValue()) == $password;
 }
 function perform()
 {
     $this->_view = new BlogView($this->_blogInfo, VIEW_TRACKBACKS_TEMPLATE, SMARTY_VIEW_CACHE_CHECK, array("articleId" => $this->_articleId, "articleName" => $this->_articleName, "categoryName" => $this->_categoryName, "categoryId" => $this->_categoryId, "userId" => $this->_userId, "userName" => $this->_userName, "date" => $this->_date));
     if ($this->_view->isCached()) {
         return true;
     }
     // ---
     // if we got a category name or a user name instead of a category
     // id and a user id, then we have to look up first those
     // and then proceed
     // ---
     // users...
     if ($this->_userName) {
         $users = new Users();
         $user = $users->getUserInfoFromUsername($this->_userName);
         if (!$user) {
             $this->_setErrorView();
             return false;
         }
         // if there was a user, use his/her id
         $this->_userId = $user->getId();
     }
     // ...and categories...
     if ($this->_categoryName) {
         $categories = new ArticleCategories();
         $category = $categories->getCategoryByName($this->_categoryName);
         if (!$category) {
             $this->_setErrorView();
             return false;
         }
         // if there was a user, use his/her id
         $this->_categoryId = $category->getId();
     }
     // fetch the article
     $articles = new Articles();
     if ($this->_articleId) {
         $article = $articles->getBlogArticle($this->_articleId, $this->_blogInfo->getId(), false, $this->_date, $this->_categoryId, $this->_userId);
     } else {
         $article = $articles->getBlogArticleByTitle($this->_articleName, $this->_blogInfo->getId(), false, $this->_date, $this->_categoryId, $this->_userId);
     }
     // if the article id doesn't exist, cancel the whole thing...
     if ($article == false) {
         $this->_view = new ErrorView($this->_blogInfo);
         $this->_view->setValue("message", "error_fetching_article");
         $this->setCommonData();
         return false;
     }
     $this->notifyEvent(EVENT_POST_LOADED, array("article" => &$article));
     $this->notifyEvent(EVENT_TRACKBACKS_LOADED, array("article" => &$article));
     // if everything's fine, we set up the article object for the view
     $this->_view->setValue("post", $article);
     $this->_view->setValue("trackbacks", $article->getTrackbacks());
     $this->setCommonData();
     // and return everything normal
     return true;
 }
 function perform()
 {
     // fetch the data and make some arrangements if needed
     $this->_parentId = $this->_request->getValue("parentId");
     $this->_articleId = $this->_request->getValue("articleId");
     if ($this->_parentId < 0 || $this->_parentId == "") {
         $this->_parentId = 0;
     }
     // check if comments are enabled
     $blogSettings = $this->_blogInfo->getSettings();
     if (!$blogSettings->getValue("comments_enabled")) {
         $this->_view = new ErrorView($this->_blogInfo, "error_comments_not_enabled");
         $this->setCommonData();
         return false;
     }
     // fetch the article
     $blogs = new Blogs();
     $articles = new Articles();
     $article = $articles->getBlogArticle($this->_articleId, $this->_blogInfo->getId());
     // if there was a problem fetching the article, we give an error and quit
     if ($article == false) {
         $this->_view = new ErrorView($this->_blogInfo);
         $this->_view->setValue("message", "error_fetching_article");
         $this->setCommonData();
         return false;
     }
     $this->_view = new BlogView($this->_blogInfo, "commentarticle", SMARTY_VIEW_CACHE_CHECK, array("articleId" => $this->_articleId, "parentId" => $this->_parentId));
     // do nothing if the view was already cached
     if ($this->_view->isCached()) {
         return true;
     }
     // fetch the comments so far
     $comments = new ArticleComments();
     $postComments = $comments->getPostComments($article->getId());
     if ($this->_parentId > 0) {
         // get a pre-set string for the subject field, for those users interested
         $comment = $comments->getPostComment($article->getId(), $this->_parentId);
         // create the string
         if ($comment) {
             $replyString = $this->_locale->tr("reply_string") . $comment->getTopic();
             $this->_view->setValue("comment", $comment);
         }
     }
     // if everything's fine, we set up the article object for the view
     $this->_view->setValue("post", $article);
     $this->_view->setValue("parentId", $this->_parentId);
     $this->_view->setValue("comments", $postComments);
     $this->_view->setValue("postcomments", $postComments);
     $this->_view->setValue("topic", $replyString);
     $this->setCommonData();
     // and return everything normal
     return true;
 }
 /**
  * deletes comments
  * @private
  */
 function _deleteComments()
 {
     $comments = new ArticleComments();
     $errorMessage = "";
     $successMessage = "";
     $totalOk = 0;
     // if we can't even load the article, then forget it...
     $articles = new Articles();
     $article = $articles->getBlogArticle($this->_articleId, $this->_blogInfo->getId());
     if (!$article) {
         $this->_view = new AdminPostsListView($this->_blogInfo);
         $this->_view->setErrorMessage($this->_locale->tr("error_fetching_post"));
         $this->setCommonData();
         return false;
     }
     // loop through the comments and remove them
     foreach ($this->_commentIds as $commentId) {
         // fetch the comment
         $comment = $comments->getPostComment($this->_articleId, $commentId);
         if (!$comment) {
             $errorMessage .= $this->_locale->pr("error_deleting_comment2", $commentId);
         } else {
             // fire the pre-event
             $this->notifyEvent(EVENT_PRE_COMMENT_DELETE, array("comment" => &$comment));
             if (!$comments->deletePostComment($article->getId(), $commentId)) {
                 $errorMessage .= $this->_locale->pr("error_deleting_comment", $comment->getTopic()) . "<br/>";
             } else {
                 $totalOk++;
                 if ($totalOk < 2) {
                     $successMessage .= $this->_locale->pr("comment_deleted_ok", $comment->getTopic()) . "<br/>";
                 } else {
                     $successMessage = $this->_locale->pr("comments_deleted_ok", $totalOk);
                 }
                 // fire the post-event
                 $this->notifyEvent(EVENT_POST_COMMENT_DELETE, array("comment" => &$comment));
             }
         }
     }
     // if everything fine, then display the same view again with the feedback
     $this->_view = new AdminArticleCommentsListView($this->_blogInfo, array("article" => $article));
     if ($successMessage != "") {
         $this->_view->setSuccessMessage($successMessage);
         // clear the cache
         CacheControl::resetBlogCache($this->_blogInfo->getId());
     }
     if ($errorMessage != "") {
         $this->_view->setErrorMessage($errorMessage);
     }
     $this->setCommonData();
     // better to return true if everything fine
     return true;
 }
 /**
  * Carries out the specified action
  */
 function _deletePosts()
 {
     // delete the post (it is not physically deleted but rather, we set
     // the status field to 'DELETED'
     $articles = new Articles();
     $errorMessage = "";
     $successMessage = "";
     $totalOk = 0;
     foreach ($this->_postIds as $postId) {
         // get the post
         $post = $articles->getBlogArticle($postId, $this->_blogInfo->getId());
         if ($post) {
             // fire the event
             $this->notifyEvent(EVENT_PRE_POST_DELETE, array("article" => &$post));
             //
             // the next if-else branch allows a site administrator or the blog owner to remove
             // anybody's articles. If not, then users can only remove their own articles
             //
             if ($this->_userInfo->isSiteAdmin() || $this->_blogInfo->getOwner() == $this->_userInfo->getId()) {
                 $result = $articles->deleteArticle($postId, $post->getUser(), $this->_blogInfo->getId(), false);
             } else {
                 $result = $articles->deleteArticle($postId, $this->_userInfo->getId(), $this->_blogInfo->getId(), false);
             }
             if (!$result) {
                 $errorMessage .= $this->_locale->pr("error_deleting_article", $post->getTopic()) . "<br/>";
             } else {
                 $totalOk++;
                 if ($totalOk < 2) {
                     $successMessage .= $this->_locale->pr("article_deleted_ok", $post->getTopic()) . "<br/>";
                 } else {
                     $successMessage = $this->_locale->pr("articles_deleted_ok", $totalOk);
                 }
                 // fire the post event
                 $this->notifyEvent(EVENT_POST_POST_DELETE, array("article" => &$post));
             }
         } else {
             $errorMessage .= $this->_locale->pr("error_deleting_article2", $postId) . "<br/>";
         }
     }
     // clean up the cache
     CacheControl::resetBlogCache($this->_blogInfo->getId());
     $this->_view = new AdminPostsListView($this->_blogInfo);
     if ($errorMessage != "") {
         $this->_view->setErrorMessage($errorMessage);
     }
     if ($successMessage != "") {
         $this->_view->setSuccessMessage($successMessage);
     }
     $this->setCommonData();
     return true;
 }
 /**
  * @private
  */
 function _deleteTrackbacks()
 {
     $trackbacks = new Trackbacks();
     $errorMessage = "";
     $successMessage = "";
     $totalOk = 0;
     // check if we can really load the article or not...
     $articles = new Articles();
     $article = $articles->getBlogArticle($this->_articleId, $this->_blogInfo->getId());
     if (!$article) {
         $this->_view = new AdminPostsListView($this->_blogInfo);
         $this->_view->setErrorMessage($this->_locale->tr("error_fetching_post"));
         $this->setCommonData();
         return false;
     }
     foreach ($this->_trackbackIds as $trackbackId) {
         // fetch the trackback
         $trackback = $trackbacks->getArticleTrackback($trackbackId, $this->_articleId);
         if (!$trackback) {
             $errorMessage .= $this->_locale->pr("error_deleting_trackback2", $trackbackId) . "<br/>";
         } else {
             // fire the pre-event
             $this->notifyEvent(EVENT_PRE_TRACKBACK_DELETE, array("trackback" => &$trackback));
             if (!$trackbacks->deletePostTrackback($trackbackId, $this->_articleId)) {
                 $errorMessage .= $this->_locale->pr("error_deleting_trackback", $trackback->getExcerpt()) . "<br/>";
             } else {
                 $totalOk++;
                 if ($totalOk < 2) {
                     $successMessage .= $this->_locale->pr("trackback_deleted_ok", $trackback->getExcerpt());
                 } else {
                     $successMessage = $this->_locale->pr("trackbacks_deleted_ok", $totalOk);
                 }
                 // fire the post-event
                 $this->notifyEvent(EVENT_POST_TRACKBACK_DELETE, array("trackback" => &$trackback));
             }
         }
     }
     $this->_view = new AdminArticleTrackbacksListView($this->_blogInfo, array("article" => $article));
     if ($successMessage != "") {
         $this->_view->setSuccessMessage($successMessage);
         // clear the cache
         CacheControl::resetBlogCache($this->_blogInfo->getId());
     }
     if ($errorMessage != "") {
         $this->_view->setErrorMessage($errorMessage);
     }
     $this->setCommonData();
     // better to return true if everything fine
     return true;
 }
 /**
  * Carries out the specified action
  */
 function perform()
 {
     // get the validated parameters from the request
     $articleId = $this->_request->getValue("articleId");
     $articles = new Articles();
     $article = $articles->getBlogArticle($articleId, $this->_blogInfo->getId());
     if (!$article) {
         $this->_view = new AdminPostsListView($this->_blogInfo);
         $this->_view->setErrorMessage($this->_locale->tr("error_fetching_post"));
     } else {
         $this->_view = new AdminArticleTrackbacksListView($this->_blogInfo, array("article" => $article));
     }
     $this->setCommonData();
     // better to return true if everything fine
     return true;
 }
 /**
  * @private
  * Returns true wether the comment whose status we're trying to change
  * really belongs to this blog, just in case somebody's trying to mess
  * around with that...
  */
 function _checkComment($commentId, $articleId, $blogId)
 {
     $articleComments = new ArticleComments();
     $articles = new Articles();
     // fetch the comment
     $this->_comment = $articleComments->getPostComment($articleId, $commentId);
     if (!$this->_comment) {
         return false;
     }
     // fetch the article
     $this->_article = $articles->getBlogArticle($this->_comment->getArticleId(), $blogId);
     if (!$this->_article) {
         return false;
     }
     return true;
 }
 /**
  * Carries out the specified action
  */
 function perform()
 {
     $this->_postId = $this->_request->getValue("postId");
     // fetch the post itself
     $posts = new Articles();
     $post = $posts->getBlogArticle($this->_postId, $this->_blogInfo->getId());
     if (!$post) {
         $this->_view = new AdminPostsListView($this->_blogInfo);
         $this->_view->setErrorMessage($this->_locale->tr("error_fetching_post"));
         $this->setCommonData();
         return false;
     }
     // generate the view
     $this->_view = new AdminArticleReferrersView($this->_blogInfo, array("page" => $this->_page, "article" => $post));
     $this->setCommonData();
     return true;
 }
 function perform()
 {
     // try to fetch the article
     $articles = new Articles();
     $article = $articles->getBlogArticle($this->_articleId, $this->_blogInfo->getId());
     // if there was an error, show a message and quit
     if (!$article) {
         $this->_view = new AdminErrorView($this->_blogInfo);
         $this->_view->setMessage($this->_locale->tr("error_fetching_article"));
         $this->setCommonData();
         return false;
     }
     // otherwise continue...
     $this->_view = new PluginTemplatedView($this->_blogInfo, "print", "printview", false);
     $this->_view->setValue("article", $article);
     $this->setCommonData();
     return true;
 }
 /**
  * Carries out the specified action
  */
 function perform()
 {
     // fetch the post id that has already been validated
     $this->_postId = $this->_request->getValue("postId");
     // fetch the post from the database
     $posts = new Articles();
     $post = $posts->getBlogArticle($this->_postId, $this->_blogInfo->getId(), false);
     // if the article does not exist, quit
     if (!$post) {
         $this->_view = new AdminPostsListView($this->_blogInfo);
         $this->_view->setErrorMessage($this->_locale->tr("error_fetching_article"));
         $this->setCommonData();
         return false;
     }
     // throw the event
     $this->notifyEvent(EVENT_POST_LOADED, array("article" => &$post, "from" => "editPost"));
     // and create the view where we will edit the post
     $this->_view = new AdminEditPostView($this->_blogInfo);
     $this->_view->setArticle($post);
     $this->_view->setUserInfo($this->_userInfo);
     $this->setCommonData();
     return true;
 }
Esempio n. 12
0
}
if (!$config->getValue("trackback_server_enabled")) {
    trackbackLog("Trackback server disabled by administrator");
    $result = errorResponse("Trackback feature has been disabled by the administrator.");
    die($result);
}
// for security, we will strip _ANY_ html tag from the tags
$tf = new TextFilter();
$blogName = $tf->filterAllHTML($params->getValue("blog_name"));
$excerpt = $tf->filterAllHTML($params->getValue("excerpt"));
$title = $tf->filterAllHTML($params->getValue("title"));
$articleId = $params->getValue("id");
$url = $tf->filterAllHTML($params->getValue("url"));
// try to see if the article is correct
$articles = new Articles();
$article = $articles->getBlogArticle($articleId);
if (!$article) {
    trackbackLog("ERROR: Incorrect error identifier");
    $result = errorResponse("Incorrect article identifier");
    die($result);
}
// try to load the blog info too, as we are going to need it
$blogs = new Blogs();
$blogInfo = $blogs->getBlogInfo($article->getBlog());
// a bit of protection...
if (!$blogInfo) {
    trackbackLog("ERROR: Article id " . $article->getId() . " points to blog " . $article->getBlog() . " that doesn't exist!");
    $result = errorResponse("The blog does not exist");
    die($result);
}
// if the blog is disabled, then we shoulnd't take trackbacks...
 /**
  * returns the lastest $maxItems comments received in the blog
  *
  * @param blogId
  * @param maxItems
  * @return An array of ArticleComment objects
  */
 function getBlogComments($blogId, $maxItems = 0, $articleStatus = POST_STATUS_PUBLISHED)
 {
     $prefix = $this->getPrefix();
     $query = "SELECT c.id AS id, c.article_id AS article_id, c.topic AS topic, \n\t\t\t                 c.text AS text, c.date AS date, c.user_email AS user_email,\n\t\t\t\t\t\t\t c.user_url AS user_url, c.user_name AS user_name, c.parent_id AS parent_id,\n\t\t\t\t\t\t\t c.client_ip AS client_ip, c.send_notification AS send_notification,\n\t\t\t\t\t\t\t c.status AS status      \n\t\t\t\t\t  FROM {$prefix}articles_comments c, {$prefix}articles a\n\t\t\t          WHERE a.blog_id = '" . Db::qstr($blogId) . "' AND a.id = c.article_id\n\t\t\t\t\t        AND a.status = {$articleStatus} \n\t\t\t\t\t  ORDER BY date DESC";
     if ($maxItems > 0) {
         $query .= " LIMIT 0, {$maxItems}";
     }
     $result = $this->Execute($query);
     if (!$result) {
         return false;
     }
     if ($result->RowCount() == 0) {
         return array();
     }
     $comments = array();
     $articles = new Articles();
     while ($row = $result->FetchRow()) {
         // load the article to which this comment belongs
         $comment = $this->_fillCommentInformation($row);
         $article = $articles->getBlogArticle($comment->getArticleId(), $blogId);
         $comment->setArticle($article);
         // and store everything in the array
         $comments[] = $comment;
     }
     $result->Close();
     return $comments;
 }
 /**
  * returns the Article object to which this one trackback points
  *
  * @return An Article object
  */
 function getArticle()
 {
     // if we haven't loaded the article yet
     if ($this->_article == null) {
         include_once PLOG_CLASS_PATH . "class/dao/articles.class.php";
         // load the article and return it
         $articles = new Articles();
         $this->_article = $articles->getBlogArticle($this->_articleId);
     }
     return $this->_article;
 }
 /**
  * Notifies all the users of new comments in a post
  *
  * @param postId The post we want to check if there are notifications
  * @param blogId Just in case, the blog to which that post belongs.
  */
 function notifyUsers($postId, $blogInfo, $message = null)
 {
     $blogId = $blogInfo->getId();
     $artNotifs = $this->getArticleNotifications($postId, $blogId);
     // default message.
     // NOTE: Should this be translatable???
     if ($message == null) {
         $message = "There has been actitivity in the article with id " . $postId;
     }
     if (empty($artNotifs)) {
         return;
     }
     $articles = new Articles();
     $article = $articles->getBlogArticle($postId, $blogId);
     // get the correct character set
     $blogLocale =& $blogInfo->getLocale();
     $charset = $blogLocale->getCharset();
     $users = new Users();
     foreach ($artNotifs as $notif) {
         $userInfo = $users->getUserInfoFromId($notif->getUserId());
         $message = $this->renderMessageTemplate($article, $blogInfo);
         $this->notifyUser($notif, $userInfo, "pLog Notification", $message, $charset);
     }
 }
 function perform()
 {
     // we need to have the post
     $articles = new Articles();
     $post = $articles->getBlogArticle($this->_postId, $this->_blogInfo->getId());
     // now check the results and give the user the possiblity to retry again with the
     // ones that had some problem.
     $errors = false;
     // and now start sending the trackback pings
     $tbClient = new TrackbackClient();
     $postLinks = array();
     $trackbackLinks = array();
     if (count($this->_postLinks) != 0) {
         $autoDiscoverResults = $tbClient->sendTrackbacks($this->_postLinks, $post, $this->_blogInfo);
         foreach ($autoDiscoverResults as $result) {
             if ($autoDiscoverResults["status"] == TRACKBACK_FAILED) {
                 // add them again to the list of hosts
                 $errors = true;
                 array_push($postLinks, $result["url"]);
             } else {
                 if ($result["status"] == TRACKBACK_SUCCESS) {
                     if ($message == "") {
                         $message = $this->_locale->tr("trackbacks_sent_ok") . "<br/><br/>";
                     }
                     $message .= "<a href=\"" . $result["url"] . "\">" . $result["url"] . "</a><br/>";
                 } else {
                     if ($result["status"] == TRACKBACK_UNAVAILABLE) {
                         $message .= $this->_locale->tr("trackbacks_no_trackback") . "<a href=\"" . $result["url"] . "\">" . $result["url"] . "</a><br/>";
                     }
                 }
             }
         }
     }
     if (count($this->_trackbackLinks) != 0) {
         $directPingResults = $tbClient->sendDirectTrackbacks($this->_trackbackLinks, $post, $this->_blogInfo);
         foreach ($directPingResults as $result) {
             if ($result["status"] == TRACKBACK_FAILED) {
                 // add them again to the list of hosts
                 $errors = true;
                 array_push($trackbackLinks, $result["url"]);
             } else {
                 if ($result["status"] == TRACKBACK_SUCCESS) {
                     if ($message == "") {
                         $message = $this->_locale->tr("trackbacks_sent_ok") . "<br/><br/>";
                     }
                     $message .= "<a href=\"" . $result["url"] . "\">" . $result["url"] . "</a><br/>";
                 }
             }
         }
     }
     // if there were errors, we let the user try again
     if ($errors) {
         if ($message != "") {
             $message .= "<br/>";
         }
         $message .= $this->_locale->tr("error_sending_trackbacks");
         $this->_view = new AdminTemplatedView($this->_blogInfo, "sendtrackbacks");
         $this->_view->setErrorMessage($message);
         $this->_view->setValue("post", $post);
         $this->_view->setValue("postLinks", $postLinks);
         $this->_view->setValue("trackbackLinks", $trackbackLinks);
         $this->setCommonData();
     } else {
         $this->_view = new AdminPostsListView($this->_blogInfo);
         $this->_view->setSuccessMessage($message);
         $this->setCommonData();
     }
 }
 /**
  * Carries out the action
  */
 function perform()
 {
     // need to check the ip of the client
     $clientIp = Client::getIp();
     // fetch the same article again so that we can have all the comments from
     // the database, plus this last one
     $articles = new Articles();
     $article = $articles->getBlogArticle($this->_articleId, $this->_blogInfo->getId());
     // check if the user wanted to receive comments for this article
     // or not...
     if ($article->getCommentsEnabled() == false) {
         $this->_view = new ErrorView($this->_blogInfo);
         $this->_view->setValue("message", "Comments have been disabled for this article.");
         $this->setCommonData();
         return false;
     }
     $this->notifyEvent(EVENT_POST_LOADED, array("article" => &$article));
     // we have already checked all the data, so we are sure that everything's in place
     $comments = new ArticleComments();
     $comment = new UserComment($this->_articleId, $this->_parentId, $this->_commentTopic, $this->_commentText, null, $this->_userName, $this->_userEmail, $this->_userUrl, $clientIp);
     // check if there is already a comment with the same text, topic and made from the same
     // IP already in the database because if so, then we will not add the comment that
     // the user is trying to add (a reload button mistake, perhaps?)
     if (!$comments->getIdenticalComment($this->_commentTopic, $this->_commentText, $this->_articleId, $this->_parentId, $this->_userName, $this->_userEmail, $this->_userUrl, $clientIp)) {
         // fire an event
         $this->notifyEvent(EVENT_PRE_COMMENT_ADD, array("comment" => &$comment));
         if (!$comments->addComment($comment)) {
             // show an error message if problems
             $this->_view = new ErrorView($this->_blogInfo);
             $this->_view->setValue("message", "error_adding_comment");
             $this->setCommonData();
             return false;
         }
     }
     // finally, check if there was any user who wanted to be notified of new comments
     // to this post...
     $notifier = new ArticleNotifications();
     $notifier->notifyUsers($article->getId(), $this->_blogInfo);
     // fire the post event...
     $this->notifyEvent(EVENT_POST_COMMENT_ADD, array("comment" => &$comment));
     //
     // clear caches. This should be done in a more granular way, because right now
     // we're either removing *all* of them or none. I guess we should only remove the
     // cache whose identifier corresponds with the blog and article that we just removed,
     // but let's leave it as it is for the time being...
     //
     CacheControl::resetBlogCache($this->_blogInfo->getId());
     // clean up the request, there's a parameter called 'userName' also used by
     // ViewArticleAction but that doesn't have the same meaning so we better remove it
     // before it's too late! We also need to add a new request commentUserName to replace
     // original userName, in case developer need it in filter or event plugin.
     $request = HttpVars::getRequest();
     $request["commentUserName"] = $request["userName"];
     $request["userName"] = "";
     HttpVars::setRequest($request);
     // forward the action to ViewArticleAction
     return BlogController::setForwardAction("ViewArticle");
 }
 /**
  * Carries out the specified action
  */
 function perform()
 {
     // fetch the data
     $this->_fetchCommonData();
     $this->_postId = $this->_request->getValue("postId");
     // fetch the old post
     $articles = new Articles();
     $post = $articles->getBlogArticle($this->_postId, $this->_blogInfo->getId());
     // there must be something wrong if we can't fetch the post that we are trying to update...
     if (!$post) {
         $this->_view = new AdminPostsListView($this->_blogInfo);
         $this->_view->setErrorMessage($this->_locale->tr("error_fetching_post"));
         $this->setCommonData();
         return false;
     }
     // if we got it, update some fields
     $post->setTopic(stripslashes($this->_postTopic));
     $postText = $this->_postText . POST_EXTENDED_TEXT_MODIFIER . $this->_postExtendedText;
     $post->setText(stripslashes($postText));
     $post->setCategoryIds($this->_postCategories);
     $post->setStatus($this->_postStatus);
     $post->setDateObject($this->_postTimestamp);
     $post->setCommentsEnabled($this->_commentsEnabled);
     $post->setPostSlug($this->_postSlug);
     // prepare the custom fields
     $fields = array();
     if (is_array($this->_customFields)) {
         foreach ($this->_customFields as $fieldId => $fieldValue) {
             // 3 of those parameters are not really need when creating a new object... it's enough that
             // we know the field definition id.
             $customField = new CustomFieldValue($fieldId, $fieldValue, "", -1, "", $post->getId(), $this->_blogInfo->getId(), -1);
             array_push($fields, $customField);
         }
         $post->setFields($fields);
     }
     // fire the pre event
     $this->notifyEvent(EVENT_PRE_POST_UPDATE, array("article" => &$post));
     // and finally save the post to the database
     if (!$articles->updateArticle($post)) {
         $this->_view = new AdminPostsListView($this->_blogInfo);
         $this->_view->setErrorMessage($this->_locale->tr("error_updating_post"));
         $this->setCommonData();
         return false;
     }
     // clean up the cache
     CacheControl::resetBlogCache($this->_blogInfo->getId());
     // create the definitive view
     $this->_view = new AdminPostsListView($this->_blogInfo);
     // show a message saying that the post was updated
     $message = $this->_locale->pr("post_updated_ok", $post->getTopic());
     // check if there was a previous notification
     $notifications = new ArticleNotifications();
     $artNotification = $notifications->getUserArticleNotification($this->_postId, $this->_blogInfo->getId(), $this->_userInfo->getId());
     // check if we have to add or remove a notification
     if ($this->_sendNotification) {
         if (!$artNotification) {
             // if there wasn't one and now we want it, we have to add it
             $notifications->addNotification($this->_postId, $this->_blogInfo->getId(), $this->_userInfo->getId());
             $message .= " " . $this->_locale->tr("notification_added");
         }
     } else {
         // if we don't want notifications, then we have to check if there is one since we
         // should remove it
         if ($artNotification) {
             $notifications->deleteNotification($this->_postId, $this->_blogInfo->getId(), $this->_userInfo->getId());
             $message .= " " . $this->_locale->tr("notification_removed");
         }
     }
     // if the "send xmlrpc pings" checkbox was enabled, do something about it...
     if ($post->getStatus() == POST_STATUS_PUBLISHED) {
         // get the links from the text of the post
         $postLinks = StringUtils::getLinks(stripslashes($post->getText()));
         // get the real trackback links from trackbackUrls
         $trackbackLinks = array();
         foreach (explode("\r\n", $this->_trackbackUrls) as $host) {
             trim($host);
             if ($host != "" && $host != "\r\n" && $host != "\r" && $host != "\n") {
                 array_push($trackbackLinks, $host);
             }
         }
         if ($this->_sendPings) {
             $message .= "<br/><br/>" . $this->sendXmlRpcPings();
         }
         // and now check what to do with the trackbacks
         if ($this->_sendTrackbacks) {
             // if no links, there is nothing to do
             if (count($postLinks) == 0 && count($trackbackLinks) == 0) {
                 $this->_view = new AdminPostsListView($this->_blogInfo);
                 $this->_view->setErrorMessage($this->_locale->tr("error_no_trackback_links_sent"));
             } else {
                 $this->_view = new AdminTemplatedView($this->_blogInfo, "sendtrackbacks");
                 // get the links from the text of the post
                 $this->_view->setValue("post", $post);
                 $this->_view->setValue("postLinks", $postLinks);
                 $this->_view->setValue("trackbackLinks", $trackbackLinks);
             }
         }
     }
     // show the message
     $this->_view->setSuccessMessage($message);
     // and fire the post event
     $this->notifyEvent(EVENT_POST_POST_UPDATE, array("article" => &$post));
     $this->setCommonData();
     return true;
 }