[ 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/admintemplatedview.class.php" ); 5 lt_include( PLOG_CLASS_PATH."class/view/admin/adminpermissionslistview.class.php" ); 6 lt_include( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" ); 7 lt_include( PLOG_CLASS_PATH."class/dao/permissions.class.php" ); 8 9 /** 10 * \ingroup Action 11 * @private 12 * 13 * Adds a new permission to the database 14 */ 15 class AdminAddPermissionAction extends AdminAction 16 { 17 function AdminAddPermissionAction( $actionInfo, $request ) 18 { 19 $this->AdminAction( $actionInfo, $request ); 20 21 // register two validators 22 $this->registerFieldValidator( "permissionName", new StringValidator()); 23 $this->registerFieldValidator( "permissionDescription", new StringValidator()); 24 $this->registerField( "corePermission" ); 25 $this->registerField( "adminOnlyPermission" ); 26 // and the view we should show in case there is a validation error 27 $errorView = new AdminTemplatedView( $this->_blogInfo, "newpermission" ); 28 $errorView->setErrorMessage( $this->_locale->tr("error_adding_permission" )); 29 $this->setValidationErrorView( $errorView ); 30 31 $this->requireAdminPermission( "add_permission" ); 32 } 33 34 function perform() 35 { 36 // add the permission and check success 37 $perm = new Permission( 38 $this->_request->getValue( "permissionName"), 39 $this->_request->getValue( "permissionDescription" ) 40 ); 41 if( $this->_request->getValue( "corePermission" ) == 1 ) 42 $perm->setCorePermission( true ); 43 if( $this->_request->getValue( "adminOnlyPermission" ) == 1 ) 44 $perm->setAdminOnlyPermission( true ); 45 46 $perms = new Permissions(); 47 $this->notifyEvent( EVENT_PRE_PERMISSION_ADD, Array( "permission" => &$perm )); 48 if( $perms->addPermission( $perm )) { 49 $this->notifyEvent( EVENT_POST_PERMISSION_ADD, Array( "permission" => &$perm )); 50 if( $this->_userInfo->hasPermissionByName( "view_permissions", 0 )) 51 $this->_view = new AdminPermissionsListView( $this->_blogInfo ); 52 else 53 $this->_view = new AdminTemplatedView( $this->_blogInfo, "newpermission" ); 54 $this->_view->setSuccessMessage( $this->_locale->tr("permission_added_ok" )); 55 $this->setCommonData(); 56 } 57 else { 58 $this->_view->setErrorMessage( $this->_locale->tr("error_adding_permission" )); 59 $this->_view->setError( true ); 60 $this->setCommonData( true ); 61 } 62 } 63 } 64 ?>
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 |
![]() |