/**
  * Carries out the specified action
  */
 function perform()
 {
     // fetch the category we're trying to update
     $this->_categoryId = $this->_request->getValue("linkCategoryId");
     $this->_categoryName = Textfilter::filterAllHTML($this->_request->getValue("linkCategoryName"));
     $categories = new MyLinksCategories();
     $category = $categories->getMyLinksCategory($this->_categoryId, $this->_blogInfo->getId());
     if (!$category) {
         $this->_view = new AdminLinkCategoriesListView($this->_blogInfo);
         $this->_view->setErrorMessage($this->_locale->tr("error_fetching_link_category"));
         $this->setCommonData();
         return false;
     }
     // update the fields
     $category->setName($this->_categoryName);
     $this->notifyEvent(EVENT_PRE_LINK_CATEGORY_UPDATE, array("linkcategory" => &$category));
     if (!$categories->updateMyLinksCategory($category)) {
         $this->_view = new AdminLinkCategoriesListView($this->_blogInfo);
         $this->_view->setErrorMessage($this->_locale->tr("error_updating_link_category"));
         $this->setCommonData();
         return false;
     }
     $this->notifyEvent(EVENT_POST_LINK_CATEGORY_UPDATE, array("linkcategory" => &$category));
     // clear the cache
     CacheControl::resetBlogCache($this->_blogInfo->getId(), false);
     $this->_view = new AdminLinkCategoriesListView($this->_blogInfo);
     $this->_view->setSuccessMessage($this->_locale->pr("link_category_updated_ok", $category->getName()));
     $this->setCommonData();
     // better to return true if everything fine
     return true;
 }
 /**
  * Carries out the specified action
  * @static
  */
 function _deleteLinkCategories()
 {
     // delete the link category, but only if there are no links under it
     $categories = new MyLinksCategories();
     $errorMessage = "";
     $successMessage = "";
     $totalOk = 0;
     foreach ($this->_categoryIds as $categoryId) {
         // fetch the category
         $linkCategory = $categories->getMyLinksCategory($categoryId, $this->_blogInfo->getId());
         if ($linkCategory) {
             //if( $categories->getNumMyLinksCategory( $categoryId ) > 0 ) {
             if ($linkCategory->getNumLinks() > 0) {
                 $errorMessage .= $this->_locale->pr("error_links_in_link_category", $linkCategory->getName()) . "<br/>";
             } else {
                 // if all correct, now delete it and check how it went
                 if (!$categories->deleteMyLinksCategory($categoryId, $this->_blogInfo->getId())) {
                     $errorMessage .= $this->_locale->pr("error_removing_link_category", $linkCategory->getName());
                 } else {
                     $totalOk++;
                     if ($totalOk < 2) {
                         $successMessage = $this->_locale->pr("link_category_deleted_ok", $linkCategory->getName());
                     } else {
                         $successMessage = $this->_locale->pr("link_categories_deleted_ok", $totalOk);
                     }
                 }
             }
         } else {
             $errorMessage .= $this->_locale->pr("error_removing_link_category2", $categoryId) . "<br/>";
         }
     }
     $this->_view = new AdminLinkCategoriesListView($this->_blogInfo);
     if ($errorMessage != "") {
         $this->_view->setErrorMessage($errorMessage);
     }
     if ($successMessage != "") {
         $this->_view->setSuccessMessage($successMessage);
         // clear the cache
         CacheControl::resetBlogCache($this->_blogInfo->getId(), false);
     }
     $this->setCommonData();
     // better to return true if everything fine
     return true;
 }
 /**
  * Carries out the specified action
  */
 function perform()
 {
     // fetch the category
     $this->_categoryId = $this->_request->getValue("categoryId");
     $categories = new MyLinksCategories();
     $category = $categories->getMyLinksCategory($this->_categoryId, $this->_blogInfo->getId());
     // show an error if we couldn't fetch the category
     if (!$category) {
         $this->_view->setErrorMessage($this->_locale->tr("error_fetching_link_category"));
         $this->setCommonData();
         return false;
     }
     $this->notifyEvent(EVENT_LINK_CATEGORY_LOADED, array("linkcategory" => &$category));
     // otherwise show the form to edit its fields
     $this->_view = new AdminTemplatedView($this->_blogInfo, "editlinkcategory");
     $this->_view->setValue("linkCategoryName", $category->getName());
     $this->_view->setValue("linkCategoryId", $category->getId());
     $this->setCommonData();
     // better to return true if everything fine
     return true;
 }