/**
  * Carries out the specified action
  */
 function perform()
 {
     // fetch the link
     $this->_linkId = $this->_request->getValue("linkId");
     $links = new MyLinks();
     $link = $links->getMyLink($this->_linkId, $this->_blogInfo->getId());
     // show an error if we couldn't fetch the link
     if (!$link) {
         $this->_view->setErrorMessage($this->_locale->tr("error_fetching_link"));
         $this->setCommonData();
         return false;
     }
     $this->notifyEvent(EVENT_LINK_LOADED, array("link" => &$link));
     // otherwise show the form to edit its fields
     $this->_view = new AdminEditLinkView($this->_blogInfo);
     $this->_view->setValue("linkName", $link->getName());
     $this->_view->setValue("linkDescription", $link->getDescription());
     $this->_view->setValue("linkUrl", $link->getUrl());
     $this->_view->setValue("linkRssFeed", $link->getRssFeed());
     $this->_view->setValue("linkId", $link->getId());
     $this->_view->setValue("linkCategoryId", $link->getCategoryId());
     $this->setCommonData();
     // better to return true if everything fine
     return true;
 }
 /**
  * Carries out the specified action
  */
 function perform()
 {
     // data is fine, we have already validated it
     $this->_linkName = Textfilter::filterAllHTML($this->_request->getValue("linkName"));
     $this->_linkDescription = Textfilter::filterAllHTML($this->_request->getValue("linkDescription"));
     $this->_linkUrl = Textfilter::filterAllHTML($this->_request->getValue("linkUrl"));
     $this->_linkCategoryId = $this->_request->getValue("linkCategoryId");
     $this->_linkId = $this->_request->getValue("linkId");
     $this->_linkFeed = Textfilter::filterAllHTML($this->_request->getValue("linkRssFeed"));
     // fetch the link we're trying to update
     $links = new MyLinks();
     $link = $links->getMyLink($this->_linkId, $this->_blogInfo->getId());
     if (!$link) {
         $this->_view = new AdminLinksListView($this->_blogInfo);
         $this->_view->setErrorMessage($this->_locale->tr("error_fetching_link"));
         $this->setCommonData();
         return false;
     }
     // update the fields
     $link->setName($this->_linkName);
     $link->setDescription($this->_linkDescription);
     $link->setCategoryId($this->_linkCategoryId);
     $link->setUrl($this->_linkUrl);
     $link->setProperties($this->_properties);
     $link->setRssFeed($this->_linkFeed);
     $this->notifyEvent(EVENT_PRE_LINK_UPDATE, array("link" => &$link));
     // and now update it in the database
     if (!$links->updateMyLink($link)) {
         $this->_view = new AdminLinksListView($this->_blogInfo);
         $this->_view->setErrorMessage($this->_locale->tr("error_updating_link"));
         $this->setCommonData();
         return false;
     }
     $this->notifyEvent(EVENT_POST_LINK_UPDATE, array("link" => &$link));
     // clear the cache
     CacheControl::resetBlogCache($this->_blogInfo->getId(), false);
     // and go back to the view with the list of links
     $this->_view = new AdminLinksListView($this->_blogInfo);
     $this->_view->setSuccessMessage($this->_locale->pr("link_updated_ok", $link->getName()));
     $this->setCommonData();
     // better to return true if everything fine
     return true;
 }
 /**
  * Carries out the specified action
  * @private
  */
 function _deleteLinks()
 {
     // delete the link
     $links = new MyLinks();
     $errorMessage = "";
     $successMessage = "";
     $numOk = 0;
     foreach ($this->_linkIds as $linkId) {
         // load the link
         $link = $links->getMyLink($linkId, $this->_blogInfo->getId());
         if ($link) {
             if (!$links->deleteMyLink($linkId, $this->_blogInfo->getId())) {
                 $errorMessage .= $this->_locale->pr("error_removing_link", $link->getName()) . "<br/>";
             } else {
                 $numOk++;
                 if ($numOk > 1) {
                     $successMessage = $this->_locale->pr("links_deleted_ok", $numOk);
                 } else {
                     $successMessage = $this->_locale->pr("link_deleted_ok", $link->getName());
                 }
             }
         } else {
             $errorMessage .= $this->_locale->pr("error_removing_link2", $linkId) . "<br/>";
         }
     }
     $this->_view = new AdminLinksListView($this->_blogInfo);
     if ($errorMessage != "") {
         $this->_view->setErrorMessage($errorMessage);
     }
     if ($successMessage != "") {
         $this->_view->setSuccessMessage($successMessage);
     }
     $this->setCommonData();
     // clear the cache
     CacheControl::resetBlogCache($this->_blogInfo->getId(), false);
     // better to return true if everything fine
     return true;
 }