[ 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/ -> admindeletelinkaction.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/mylinks.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/adminlinkslistview.class.php" );
   8  
   9      /**
  10       * \ingroup Action
  11       * @private
  12       *
  13       * Action that shows a form to change the settings of the current blog.
  14       */
  15      class AdminDeleteLinkAction extends AdminAction 
  16      {
  17  
  18          var $_linkIds;
  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 AdminDeleteLinkAction( $actionInfo, $request )
  26          {
  27              $this->AdminAction( $actionInfo, $request );
  28              
  29              $this->_op = $actionInfo->getActionParamValue();
  30              
  31              $view = new AdminLinksListView( $this->_blogInfo );
  32              if( $this->_op == "deleteLink" ) {
  33                  $this->registerFieldValidator( "linkId", new IntegerValidator());
  34                  $view->setErrorMessage( $this->_locale->tr("error_incorrect_link_id"));    
  35              }
  36              else {
  37                  $this->registerFieldValidator( "linkIds", new ArrayValidator());
  38                  $view->setErrorMessage( $this->_locale->tr("error_no_links_selected"));
  39              }
  40              $this->setValidationErrorView( $view );
  41              
  42              // permission checks
  43              $this->requirePermission( "update_link" );
  44          }        
  45          
  46  		function perform()
  47          {
  48              if( $this->_op == "deleteLink" ) {
  49                  $this->_linkIds = Array();
  50                  $this->_linkId = $this->_request->getValue( "linkId" );
  51                  $this->_linkIds[] = $this->_linkId;
  52              }
  53              else
  54                  $this->_linkIds = $this->_request->getValue( "linkIds" );
  55                  
  56              $this->_deleteLinks();
  57          }
  58  
  59          /**
  60           * Carries out the specified action
  61           * @private
  62           */
  63          function _deleteLinks()
  64          {
  65              // delete the link
  66              $links = new MyLinks();
  67  
  68              $errorMessage = "";
  69              $successMessage = "";
  70              $numOk = 0;
  71              foreach( $this->_linkIds as $linkId ) {
  72                  // load the link
  73                  $link = $links->getMyLink( $linkId, $this->_blogInfo->getId());
  74                  if( $link ) {
  75                      if( !$links->deleteMyLink( $linkId, $this->_blogInfo->getId()))
  76                          $errorMessage .= $this->_locale->pr("error_removing_link", $link->getName())."<br/>";
  77                      else {
  78                          $numOk++;
  79                          if( $numOk > 1 )
  80                              $successMessage = $this->_locale->pr("links_deleted_ok", $numOk );
  81                          else
  82                              $successMessage = $this->_locale->pr("link_deleted_ok", $link->getName());
  83                      }
  84                  }
  85                  else {
  86                      $errorMessage .= $this->_locale->pr("error_removing_link2", $linkId)."<br/>";
  87                  }
  88              }
  89  
  90              $this->_view = new AdminLinksListView( $this->_blogInfo );
  91              if( $errorMessage != "" ) $this->_view->setErrorMessage( $errorMessage );
  92              if( $successMessage != "" ) $this->_view->setSuccessMessage( $successMessage );
  93              $this->setCommonData();
  94              
  95              // clear the cache
  96              CacheControl::resetBlogCache( $this->_blogInfo->getId(), false );
  97  
  98              // better to return true if everything fine
  99              return true;
 100          }
 101      }
 102  ?>


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