/** * 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 */ function render() { // get all the link categories but we have to respect the order that the user asked $order = $this->getValue("showOrder"); $linkCategories = new MyLinksCategories(); $blogLinkCategories = $linkCategories->getMyLinksCategories($this->_blogInfo->getId(), $order); $this->notifyEvent(EVENT_LINK_CATEGORIES_LOADED, array("linkcategories" => &$blogLinkCategories)); // put the data in the view $this->setValue("linkcategories", $blogLinkCategories); parent::render(); }
/** * 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() { // add the new link category to the database $this->_linkCategoryName = Textfilter::filterAllHTML($this->_request->getValue("linkCategoryName")); $mylinksCategories = new MyLinksCategories(); $mylinksCategory = new MyLinksCategory($this->_linkCategoryName, $this->_blogInfo->getId(), 0, $this->_properties); // the view is the same for both conditions $this->_view = new AdminLinkCategoriesListView($this->_blogInfo); if (!$mylinksCategories->addMyLinksCategory($mylinksCategory, $this->_blogInfo->getId())) { // set an error message $this->_view->setErrorMessage($this->_locale->tr("error_adding_link_category")); } else { // clear the cache CacheControl::resetBlogCache($this->_blogInfo->getId(), false); $this->_view->setSuccessMessage($this->_locale->pr("link_category_added_ok", $mylinksCategory->getName())); } $this->setCommonData(); return true; }
function render() { // get all the link categories $blogSettings = $this->_blogInfo->getSettings(); $linkCategoriesOrder = $blogSettings->getValue("link_categories_order", MYLINKS_CATEGORIES_NO_ORDER); // get the link categories $linkCategories = new MyLinksCategories(); $blogLinkCategories = $linkCategories->getMyLinksCategories($this->_blogInfo->getId(), $linkCategoriesOrder, $this->_page, DEFAULT_ITEMS_PER_PAGE); // get the total number of link categories $numLinkCategories = $linkCategories->getNumMyLinksCategories($this->_blogInfo->getId()); // throw the event $this->notifyEvent(EVENT_LINK_CATEGORIES_LOADED, array("linkcategories" => &$blogLinkCategories)); // create the pager $pager = new Pager("?op=editLinkCategories&page=", $this->_page, $numLinkCategories, DEFAULT_ITEMS_PER_PAGE); // create the view and fill the template context $this->setValue("linkcategories", $blogLinkCategories); $this->setValue("pager", $pager); // transfer control to the parent class parent::render(); }
/** * Carries out the specified action */ function perform() { // fetch all the link categories $blogSettings = $this->_blogInfo->getSettings(); $linkCategoriesOrder = $blogSettings->getValue("link_categories_order", MYLINKS_CATEGORIES_NO_ORDER); $linkCategories = new MyLinksCategories(); $blogLinkCategories = $linkCategories->getMyLinksCategories($this->_blogInfo->getId(), $linkCategoriesOrder); // if there is none, we should not be allowed to add any link! if (empty($blogLinkCategories)) { $this->_view = new AdminTemplatedView($this->_blogInfo, "newlinkcategory"); $this->_view->setErrorMessage($this->_locale->tr("error_must_have_one_link_category")); $this->setCommonData(); return false; } $this->notifyEvent(EVENT_LINK_CATEGORIES_LOADED, array("linkcategories" => &$blogLinkCategories)); // else, put that in the template and continue $this->_view = new AdminNewLinkView($this->_blogInfo); $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; }
/** * Carries out the specified action */ function render() { // get the parameters $order = $this->getValue("showOrder"); $categoryId = $this->getValue("showCategory"); // get all the links and throw the event $links = new MyLinks(); $blogLinks = $links->getLinks($this->_blogInfo->getId(), $categoryId, $this->_page, DEFAULT_ITEMS_PER_PAGE); $this->notifyEvent(EVENT_LINKS_LOADED, array("links" => &$blogLinks)); // get the number of links $numLinks = $links->getNumLinks($this->_blogInfo->getId(), $categoryId); // get all the link categories but we have to respect the order that the user asked $linkCategories = new MyLinksCategories(); $blogLinkCategories = $linkCategories->getMyLinksCategories($this->_blogInfo->getId(), $order); $this->notifyEvent(EVENT_LINK_CATEGORIES_LOADED, array("linkcategories" => &$blogLinkCategories)); // prepare the pager $pager = new Pager("?op=editLinks&showCategory={$categoryId}&page=", $this->_page, $numLinks, DEFAULT_ITEMS_PER_PAGE); // put the data in the view $this->setValue("links", $blogLinks); $this->setValue("linkscategories", $blogLinkCategories); $this->setValue("currentcategory", $categoryId); $this->setValue("pager", $pager); parent::render(); }
/** * Updates a link in the database. * * @param myLink A MyLink object with the information we'd like to update. * @return True if successful or false otherwise. */ function updateMyLink($myLink) { $query = "UPDATE " . $this->getPrefix() . "mylinks SET\n name = '" . Db::qstr($myLink->getName()) . "',\n description = '" . Db::qstr($myLink->getDescription()) . "',\n url = '" . Db::qstr($myLink->getUrl()) . "',\n category_id = " . $myLink->getCategoryId() . ",\n date = date,\n\t\t\t\t\t properties = '" . Db::qstr(serialize($myLink->getProperties())) . "',\n\t\t\t\t\t rss_feed = '" . Db::qstr($myLink->getRssFeed()) . "'\n WHERE id = " . $myLink->getId() . " AND blog_id = " . $myLink->getBlogId() . ";"; $result = $this->Execute($query); if (!$result) { return false; } else { if ($result) { // mark the corresponding link categories as modified now $linkCategories = new MyLinksCategories(); $linkCategories->updateCategoryModificationDate($myLink->getCategoryId()); } return true; } }
/** * Removes a blog from the database. It also removes all its posts, its posts categories * its links, its links categories, its trackbacks and its comments * * @param blogId the id of the blog we'd like to delete */ function deleteBlog($blogId) { // first of all, delete the posts $articles = new Articles(); $articles->deleteBlogPosts($blogId); // next is to remove the article categories $articleCategories = new ArticleCategories(); $articleCategories->deleteBlogCategories($blogId); // next, all the links and links categories $myLinks = new MyLinks(); $myLinks->deleteBlogMyLinks($blogId); $myLinksCategories = new MyLinksCategories(); $myLinksCategories->deleteBlogMyLinksCategories($blogId); // the permissions for the blog $perms = new UserPermissions(); $perms->revokeBlogPermissions($blogId); // and finally, delete the blog $query = "DELETE FROM " . $this->getPrefix() . "blogs WHERE id = {$blogId}"; $result = $this->Execute($query); return $result; }
/** * Retrieves the links * * @private */ function _getLinkCategories() { $blogSettings = $this->_blogInfo->getSettings(); $linkCategoriesOrder = $blogSettings->getValue('link_categories_order', MYLINKS_CATEGORIES_NO_ORDER); $myLinksCategories = new MyLinksCategories(); $blogLinksCategories = $myLinksCategories->getMyLinksCategories($this->_blogInfo->getId(), $linkCategoriesOrder); $this->notifyEvent(EVENT_LINK_CATEGORIES_LOADED, array('linkcategories' => &$blogLinksCategories)); return $blogLinksCategories; }