[ Index ]
 

Code source de LifeType 1.2.4

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/class/action/admin/ -> adminaddlinkcategoryaction.class.php (source)

   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/stringvalidator.class.php" );
   6      lt_include( PLOG_CLASS_PATH."class/view/admin/adminlinkcategorieslistview.class.php" );
   7      lt_include( PLOG_CLASS_PATH."class/view/admin/admintemplatedview.class.php" );    
   8  
   9      /**
  10       * \ingroup Action
  11       * @private
  12       *
  13       * Action that takes care of adding a new link category
  14       */
  15      class AdminAddLinkCategoryAction extends AdminAction 
  16      {
  17  
  18          var $_linkCategoryName;
  19          var $_properties;
  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 AdminAddLinkCategoryAction( $actionInfo, $request )
  26          {
  27              $this->AdminAction( $actionInfo, $request );
  28              
  29              // data validation
  30              $this->registerFieldValidator( "linkCategoryName", new StringValidator());
  31              $this->setValidationErrorView( new AdminTemplatedView( $this->_blogInfo, "newlinkcategory" ));
  32              
  33              $this->requirePermission( "add_link_category" );
  34          }
  35          
  36          /**
  37           * Carries out the specified action
  38           */
  39          function perform()
  40          {
  41              // add the new link category to the database
  42              $this->_linkCategoryName = Textfilter::filterAllHTML($this->_request->getValue( "linkCategoryName" ));
  43              $mylinksCategories = new MyLinksCategories();
  44              $mylinksCategory = new MyLinksCategory( $this->_linkCategoryName, 
  45                                                      $this->_blogInfo->getId(), 
  46                                                      0, 
  47                                                      $this->_properties );
  48              // the view is the same for both conditions
  49              if( $this->userHasPermission( "view_link_categories" ))
  50                     $this->_view = new AdminLinkCategoriesListView( $this->_blogInfo );                                                    
  51              else
  52                  $this->_view = new AdminTemplatedView( $this->_blogInfo, "newlinkcategory" );
  53                                                      
  54              if( !$mylinksCategories->addMyLinksCategory( $mylinksCategory, $this->_blogInfo->getId())) {
  55                  // set an error message
  56                  $this->_view->setErrorMessage( $this->_locale->tr("error_adding_link_category"));
  57              }
  58              else {
  59                  // clear the cache
  60                  CacheControl::resetBlogCache( $this->_blogInfo->getId(), false );
  61                  $this->_view->setSuccessMessage( $this->_locale->pr("link_category_added_ok", $mylinksCategory->getName()));    
  62              }
  63              
  64              $this->setCommonData();
  65  
  66              return true;
  67          }
  68      }
  69  ?>


Généré le : Mon Nov 26 21:04:15 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics