| [ 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/adminsiteuserslistview.class.php" ); 5 lt_include( PLOG_CLASS_PATH."class/dao/users.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 users 15 */ 16 class AdminChangeUserStatusAction 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 AdminChangeUserStatusAction( $actionInfo, $request ) 27 { 28 $this->AdminAction( $actionInfo, $request ); 29 $this->registerFieldValidator( "userIds", new ArrayValidator()); 30 $this->registerFieldValidator( "userStatus", new IntegerValidator() ); 31 $view = new AdminSiteUsersListView( $this->_blogInfo ); 32 $view->setErrorMessage( $this->_locale->tr("error_incorrect_user")); 33 $this->setValidationErrorView( $view ); 34 35 $this->requireAdminPermission( "update_user" ); 36 } 37 38 /** 39 * Carries out the specified action 40 */ 41 function _changeUserStatus() 42 { 43 // Chanages the post status field by selection 44 $users = new Users(); 45 $errorMessage = ""; 46 $successMessage = ""; 47 $totalOk = 0; 48 49 foreach( $this->_userIds as $userId ) { 50 // get the post 51 $user = $users->getUserInfoFromId( $userId ); 52 53 if( $user ) { 54 // fire the event 55 $this->notifyEvent( EVENT_PRE_USER_UPDATE, Array( "user" => &$user )); 56 57 // update the post status 58 $user->setStatus( $this->_userStatus ); 59 $result = $users->updateUser( $user ); 60 61 if( !$result ) { 62 $errorMessage .= $this->_locale->pr("error_updating_user", $user->getUsername())."<br/>"; 63 } 64 else { 65 $totalOk++; 66 if( $totalOk < 2 ) 67 $successMessage .= $this->_locale->pr("user_updated_ok", $user->getUsername())."<br/>"; 68 else 69 $successMessage = $this->_locale->pr("users_updated_ok", $totalOk ); 70 // fire the post event 71 $this->notifyEvent( EVENT_POST_BLOG_UPDATE, Array( "user" => &$user )); 72 } 73 } 74 else { 75 $errorMessage .= $this->_locale->pr( "eror_updating_user2", $userId )."<br/>"; 76 } 77 } 78 79 $this->_view = new AdminSiteUsersListView( $this->_blogInfo ); 80 if( $errorMessage != "" ) 81 $this->_view->setErrorMessage( $errorMessage ); 82 if( $successMessage != "" ) 83 $this->_view->setSuccessMessage( $successMessage ); 84 85 $this->setCommonData(); 86 87 return true; 88 } 89 90 function perform() 91 { 92 // prepare the parameters.. If there's only one category id, then add it to 93 // an array. 94 $this->_userIds = $this->_request->getValue( "userIds" ); 95 $this->_userStatus = $this->_request->getValue( "userStatus" ); 96 97 $this->_changeUserStatus(); 98 } 99 } 100 ?>
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 |
|