[ 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/view/admin/adminsiteblogslistview.class.php" ); 5 lt_include( PLOG_CLASS_PATH."class/dao/articles.class.php" ); 6 lt_include( PLOG_CLASS_PATH."class/template/cachecontrol.class.php" ); 7 lt_include( PLOG_CLASS_PATH."class/data/validator/arrayvalidator.class.php" ); 8 lt_include( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" ); 9 10 /** 11 * \ingroup Action 12 * @private 13 * 14 * Implements bulk changes of blogs 15 */ 16 class AdminChangeBlogStatusAction extends AdminAction 17 { 18 19 var $_postIds; 20 var $_postStatus; 21 22 /** 23 * Constructor. If nothing else, it also has to call the constructor of the parent 24 * class, BlogAction with the same parameters 25 */ 26 function AdminChangeBlogStatusAction( $actionInfo, $request ) 27 { 28 $this->AdminAction( $actionInfo, $request ); 29 $this->registerFieldValidator( "blogIds", new ArrayValidator()); 30 $this->registerFieldValidator( "blogStatus", new IntegerValidator() ); 31 $view = new AdminSiteBlogsListView( $this->_blogInfo ); 32 $view->setErrorMessage( $this->_locale->tr("error_incorrect_blog_id")); 33 $this->setValidationErrorView( $view ); 34 35 $this->requireAdminPermission( "update_site_blog" ); 36 } 37 38 /** 39 * Carries out the specified action 40 */ 41 function _changeBlogsStatus() 42 { 43 // Chanages the post status field by selection 44 $blogs = new Blogs(); 45 $errorMessage = ""; 46 $successMessage = ""; 47 $totalOk = 0; 48 49 foreach( $this->_blogIds as $blogId ) { 50 // get the post 51 $blog = $blogs->getBlogInfo( $blogId ); 52 53 if( $blog ) { 54 // fire the event 55 $this->notifyEvent( EVENT_PRE_BLOG_UPDATE, Array( "blog" => &$blog )); 56 57 // update the post status 58 $blog->setStatus( $this->_blogStatus ); 59 $result = $blogs->updateBlog( $blog ); 60 61 if( !$result ) { 62 $errorMessage .= $this->_locale->pr("error_updating_blog", $blog->getBlog())."<br/>"; 63 } 64 else { 65 $totalOk++; 66 if( $totalOk < 2 ) 67 $successMessage .= $this->_locale->pr("blog_updated_ok", $blog->getBlog())."<br/>"; 68 else 69 $successMessage = $this->_locale->pr("blogs_updated_ok", $totalOk ); 70 // fire the post event 71 $this->notifyEvent( EVENT_POST_BLOG_UPDATE, Array( "article" => &$blog )); 72 } 73 } 74 else { 75 $errorMessage .= $this->_locale->pr( "error_updating_blog2", $blogId )."<br/>"; 76 } 77 } 78 79 // clean up the cache 80 CacheControl::resetBlogCache( $this->_blogInfo->getId()); 81 82 $this->_view = new AdminSiteBlogsListView( $this->_blogInfo ); 83 if( $errorMessage != "" ) 84 $this->_view->setErrorMessage( $errorMessage ); 85 if( $successMessage != "" ) 86 $this->_view->setSuccessMessage( $successMessage ); 87 88 $this->setCommonData(); 89 90 return true; 91 } 92 93 function perform() 94 { 95 // prepare the parameters.. If there's only one category id, then add it to 96 // an array. 97 $this->_blogIds = $this->_request->getValue( "blogIds" ); 98 $this->_blogStatus = $this->_request->getValue( "blogStatus" ); 99 100 $this->_changeBlogsStatus(); 101 } 102 } 103 ?>
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 |
![]() |