| [ Index ] |
|
Code source de LifeType 1.2.4 |
1 <?php 2 3 lt_include( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" ); 4 lt_include( PLOG_CLASS_PATH."class/dao/mylinkscategories.class.php" ); 5 lt_include( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" ); 6 lt_include( PLOG_CLASS_PATH."class/data/validator/arrayvalidator.class.php" ); 7 lt_include( PLOG_CLASS_PATH."class/view/admin/adminlinkcategorieslistview.class.php" ); 8 9 /** 10 * \ingroup Action 11 * @private 12 * 13 * Action that deletes a link category from the database 14 */ 15 class AdminDeleteLinkCategoryAction extends AdminAction 16 { 17 18 var $_categoryIds; 19 var $_op; 20 21 /** 22 * Constructor. If nothing else, it also has to call the constructor of the parent 23 * class, BlogAction with the same parameters 24 */ 25 function AdminDeleteLinkCategoryAction( $actionInfo, $request ) 26 { 27 $this->AdminAction( $actionInfo, $request ); 28 29 $this->_op = $actionInfo->getActionParamValue(); 30 31 $view = new AdminLinkCategoriesListView( $this->_blogInfo ); 32 if( $this->_op == "deleteLinkCategory" ) 33 $this->registerFieldValidator( "categoryId", new IntegerValidator()); 34 else 35 $this->registerFieldValidator( "categoryIds", new ArrayValidator()); 36 $view->setErrorMessage( $this->_locale->tr("error_invalid_link_category_id")); 37 $this->setValidationErrorView( $view ); 38 39 // permission checks 40 $this->requirePermission( "update_link_category" ); 41 } 42 43 function perform() 44 { 45 if( $this->_op == "deleteLinkCategory" ) { 46 $this->_categoryId = $this->_request->getValue( "categoryId" ); 47 $this->_categoryIds = Array(); 48 $this->_categoryIds[] = $this->_categoryId; 49 } 50 else 51 $this->_categoryIds = $this->_request->getValue( "categoryIds" ); 52 53 $this->_deleteLinkCategories(); 54 } 55 56 /** 57 * Carries out the specified action 58 * @static 59 */ 60 function _deleteLinkCategories() 61 { 62 // delete the link category, but only if there are no links under it 63 $categories = new MyLinksCategories(); 64 $errorMessage = ""; 65 $successMessage = ""; 66 $totalOk = 0; 67 68 foreach( $this->_categoryIds as $categoryId ) { 69 // fetch the category 70 $linkCategory = $categories->getMyLinksCategory( $categoryId, $this->_blogInfo->getId()); 71 if( $linkCategory ) { 72 if( $linkCategory->getNumLinks() > 0 ) { 73 $errorMessage .= $this->_locale->pr("error_links_in_link_category",$linkCategory->getName())."<br/>"; 74 } 75 else { 76 // if all correct, now delete it and check how it went 77 if( !$categories->deleteMyLinksCategory( $categoryId, $this->_blogInfo->getId())) { 78 $errorMessage .= $this->_locale->pr("error_removing_link_category", $linkCategory->getName()); 79 } 80 else { 81 $totalOk++; 82 if( $totalOk < 2 ) 83 $successMessage = $this->_locale->pr( "link_category_deleted_ok", $linkCategory->getName()); 84 else 85 $successMessage = $this->_locale->pr( "link_categories_deleted_ok", $totalOk ); 86 } 87 } 88 } 89 else { 90 $errorMessage .= $this->_locale->pr("error_removing_link_category2", $categoryId )."<br/>"; 91 } 92 } 93 94 $this->_view = new AdminLinkCategoriesListView( $this->_blogInfo ); 95 if( $errorMessage != "" ) $this->_view->setErrorMessage( $errorMessage ); 96 if( $successMessage != "" ) { 97 $this->_view->setSuccessMessage( $successMessage ); 98 // clear the cache 99 CacheControl::resetBlogCache( $this->_blogInfo->getId(), false ); 100 } 101 102 $this->setCommonData(); 103 104 // better to return true if everything fine 105 return true; 106 } 107 } 108 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Mon Nov 26 21:04:15 2007 | par Balluche grâce à PHPXref 0.7 |
|