[ 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/ -> admindeleteblogaction.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/view/admin/adminsiteblogslistview.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/dao/blogs.class.php" );
   8  
   9      /**
  10       * \ingroup Action
  11       * @private
  12       *
  13       * it does not delete blogs from the system but simply set them to disabled
  14       */
  15      class AdminDeleteBlogAction extends AdminAction
  16      {
  17          var $_op;
  18          var $_blogIds;
  19  
  20      	function AdminDeleteBlogAction( $actionInfo, $request )
  21          {
  22              $this->AdminAction( $actionInfo, $request );
  23  
  24              // set up the data validation stuff
  25              $this->_op = $actionInfo->getActionParamValue();
  26              if( $this->_op == "deleteBlogs" )
  27                  $this->registerFieldvalidator( "blogIds", new ArrayValidator());
  28              else
  29                  $this->registerFieldValidator( "blogId", new IntegerValidator());
  30              $view = new AdminSiteBlogsListView( $this->_blogInfo );
  31              $view->setErrorMessage( $this->_locale->tr("error_no_blogs_selected"));
  32              $this->setValidationErrorView( $view );
  33  
  34              $this->requireAdminPermission( "update_site_blog" );
  35          }
  36  
  37          function perform()
  38          {
  39              if( $this->_op == "deleteBlog" ) {
  40                  $this->_blogIds = Array();
  41                  $blogId = $this->_request->getValue( "blogId" );
  42                  $this->_blogIds[] = $blogId;
  43              }
  44              else
  45                  $this->_blogIds = $this->_request->getValue( "blogIds" );
  46  
  47              $this->_disableBlogs();
  48          }
  49          
  50  //        function disableBlog( $blogIn
  51  
  52          /**
  53           * @private
  54           */
  55          function _disableBlogs()
  56          {
  57              // get the default blog id
  58              $config =& Config::getConfig();
  59              $defaultBlogId = $config->getValue( "default_blog_id" );
  60  
  61              $errorMessage = "";
  62              $successMessage = "";
  63              $totalOk = 0;
  64  
  65              $blogs = new Blogs();
  66              foreach( $this->_blogIds as $blogId ) {
  67                  // get some info about the blog before deleting it
  68                  $blogInfo = $blogs->getBlogInfo( $blogId );
  69                  if( !$blogInfo ) {
  70                      $errorMessage .= $this->_locale->pr("error_deleting_blog2", $blogId)."<br/>";
  71                  }
  72                  else {
  73                      $this->notifyEvent( EVENT_PRE_BLOG_DELETE, Array( "blog" => &$blogInfo ));
  74                      // make sure we're not deleting the default one!
  75                      if( $defaultBlogId == $blogId ) {
  76                          $errorMessage .= $this->_locale->pr("error_blog_is_default_blog", $blogInfo->getBlog())."<br />";
  77                      }
  78                      else {
  79                         // disable the blog
  80                          $blogInfo->setStatus( BLOG_STATUS_DISABLED );
  81                          if( $blogs->updateBlog( $blogInfo )) {
  82                              $totalOk++;                        
  83                              if( $totalOk < 2 )
  84                                  $successMessage = $this->_locale->pr("blog_deleted_ok", $blogInfo->getBlog());
  85                              else
  86                                  $successMessage = $this->_locale->pr( "blogs_deleted_ok", $totalOk );
  87                              
  88                              $this->notifyEvent( EVENT_POST_BLOG_DELETE, Array( "blog" => &$blogInfo ));
  89                          }
  90                          else
  91                              $errorMessage .= $this->_locale->pr("error_deleting_blog", $blogInfo->getBlog())."<br/>";
  92                      }
  93                  }
  94              }
  95  
  96              $this->_view = new AdminSiteBlogsListView( $this->_blogInfo );
  97              if( $errorMessage != "" ) $this->_view->setErrorMessage( $errorMessage );
  98              if( $successMessage != "" ) $this->_view->setSuccessMessage( $successMessage );
  99              $this->setCommonData();
 100  
 101              return true;
 102          }
 103      }
 104  ?>


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