/**
  * @private
  * removes categories from the database
  */
 function _deleteArticleCategories()
 {
     $categories = new ArticleCategories();
     $errorMessage = "";
     $successMessage = "";
     $totalOk = 0;
     foreach ($this->_categoryIds as $categoryId) {
         // get the category
         $category = $categories->getCategory($categoryId, $this->_blogInfo->getId());
         if ($category) {
             // get how many articles it has
             //$numArticles = $categories->getNumArticlesCategory( $categoryId );
             $numArticles = $category->getNumArticles(POST_STATUS_ALL);
             // fire the pre-event
             $this->notifyEvent(EVENT_PRE_CATEGORY_DELETE, array("category" => &$category));
             // if it has at least one we can't delete it because then it would break the
             // integrity of our data in the database...
             if ($numArticles > 0) {
                 $errorMessage .= $this->_locale->pr("error_category_has_articles", $category->getName()) . "<br/>";
             } else {
                 // if everything correct, we can proceed and delete it
                 if (!$categories->deleteCategory($categoryId, $this->_blogInfo->getId())) {
                     $errorMessage .= $this->_locale->pr("error_deleting_category") . "<br/>";
                 } else {
                     if ($totalOk < 2) {
                         $successMessage .= $this->_locale->pr("category_deleted_ok", $category->getName()) . "<br/>";
                     } else {
                         $successMessage = $this->_locale->pr("categories_deleted_ok", $totalOk);
                     }
                     // fire the pre-event
                     $this->notifyEvent(EVENT_POST_CATEGORY_DELETE, array("category" => &$category));
                 }
             }
         } else {
             $errorMessage .= $this->_locale->pr("error_deleting_category2", $categoryId) . "<br/>";
         }
     }
     // prepare the view and all the information it needs to know
     $this->_view = new AdminArticleCategoriesListView($this->_blogInfo);
     if ($errorMessage != "") {
         $this->_view->setErrorMessage($errorMessage);
     }
     if ($successMessage != "") {
         // and clear the cache to avoid outdated information
         CacheControl::resetBlogCache($this->_blogInfo->getId(), false);
         $this->_view->setSuccessMessage($successMessage);
     }
     $this->setCommonData();
     return true;
 }