[pLog-svn] r4210 - in plog/trunk: class/action/admin class/view/admin locale templates/admin

oscar at devel.lifetype.net oscar at devel.lifetype.net
Sun Oct 29 18:12:27 GMT 2006


Author: oscar
Date: 2006-10-29 18:12:26 +0000 (Sun, 29 Oct 2006)
New Revision: 4210

Modified:
   plog/trunk/class/action/admin/adminupdateuserprofileaction.class.php
   plog/trunk/class/view/admin/admineditsiteuserview.class.php
   plog/trunk/locale/locale_en_UK.php
   plog/trunk/templates/admin/userprofile.template
Log:
added support for editing a user's admin-only permissions (such as login_perm)


Modified: plog/trunk/class/action/admin/adminupdateuserprofileaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminupdateuserprofileaction.class.php	2006-10-29 18:09:27 UTC (rev 4209)
+++ plog/trunk/class/action/admin/adminupdateuserprofileaction.class.php	2006-10-29 18:12:26 UTC (rev 4210)
@@ -8,6 +8,7 @@
     lt_include( PLOG_CLASS_PATH."class/data/validator/passwordvalidator.class.php" );
     lt_include( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" );	
     lt_include( PLOG_CLASS_PATH."class/dao/users.class.php" );
+    lt_include( PLOG_CLASS_PATH."class/dao/userpermissions.class.php" );
 
     /**
      * \ingroup Action
@@ -38,6 +39,7 @@
 			$this->registerField( "properties" );
 			$this->registerField( "userIsSiteAdmin" );
 			$this->registerField( "userName" );
+			$this->registerField( "userPermissions" );
 			$this->registerFieldValidator( "userProfilePassword", new PasswordValidator(), true );
 			$this->registerFieldValidator( "userStatus", new IntegerValidator());
 			$view = new AdminEditSiteUserView( $this->_blogInfo );
@@ -56,6 +58,7 @@
             $this->_adminPrivs = $this->_request->getValue( "userIsSiteAdmin" );
 			$this->_userProperties = $this->_request->getValue( "properties" );
 			$this->_userStatus = $this->_request->getValue( "userStatus" );
+			$this->_perms = $this->_request->getValue( "userPermissions" );
 
         	// load the user settings
             $users = new Users();
@@ -78,6 +81,19 @@
 			$user->setStatus( $this->_userStatus );
             if( $this->_userPassword != "" )
             	$user->setPassword( $this->_userPassword );
+
+			// and finally update the global permissions
+			// first revoke all permissions
+			$userPerms = new UserPermissions();
+			$userPerms->revokePermissions( $user->getId(), 0 );
+			
+			// and then assign the new ones
+			if( is_array( $this->_perms )) {
+				foreach( $this->_perms as $val => $permId ) {
+		            $perm = new UserPermission( $user->getId(), 0, $permId );
+		            $res = $userPerms->grantPermission( $perm );
+				}
+			}
 				
 			$this->notifyEvent( EVENT_PRE_USER_UPDATE, Array( "user" => &$user ));
 

Modified: plog/trunk/class/view/admin/admineditsiteuserview.class.php
===================================================================
--- plog/trunk/class/view/admin/admineditsiteuserview.class.php	2006-10-29 18:09:27 UTC (rev 4209)
+++ plog/trunk/class/view/admin/admineditsiteuserview.class.php	2006-10-29 18:12:26 UTC (rev 4210)
@@ -4,6 +4,7 @@
 	lt_include( PLOG_CLASS_PATH.'class/view/admin/adminerrorview.class.php' );
 	lt_include( PLOG_CLASS_PATH.'class/dao/users.class.php' );
 	lt_include( PLOG_CLASS_PATH.'class/dao/userstatus.class.php' );
+	lt_include( PLOG_CLASS_PATH.'class/dao/permissions.class.php' );
 	
     /**
      * \ingroup View
@@ -12,8 +13,7 @@
 	 * shows the view to edit a user
 	 */
 	class AdminEditSiteUserView extends AdminTemplatedView
-	{
-		
+	{		
 		var $_user;
 		
 		function AdminEditSiteUserView( $blogInfo, $userInfo = null )
@@ -38,6 +38,8 @@
 				$this->setValue( 'userIsSiteAdmin', $this->_user->isSiteAdmin());
 				$this->setValue( 'userAbout', $this->_user->getAboutMyself());
 				$this->setValue( 'userFullName', $this->_user->getFullName());
+				// list of global permissions that the user has
+				$this->setValue( 'userPermissions', $this->_user->getPermissions());
 			}
 			else {
 				// or else an error
@@ -59,8 +61,11 @@
             $this->setValue( 'edituserblogs', $userBlogs );
 			// list of available status
 			$this->setValue( 'userStatusList', UserStatus::getStatusList());
+			// list of global permisisons
+			$perms = new Permissions();
+			$this->setValue( 'permissions', $perms->getAllPermissions());
 			
 			parent::render();
 		}
 	}
-?>
+?>
\ No newline at end of file

Modified: plog/trunk/locale/locale_en_UK.php
===================================================================
--- plog/trunk/locale/locale_en_UK.php	2006-10-29 18:09:27 UTC (rev 4209)
+++ plog/trunk/locale/locale_en_UK.php	2006-10-29 18:12:26 UTC (rev 4210)
@@ -1142,6 +1142,7 @@
 $messages['view_posts_desc'] = 'View the blog posts';
 $messages['view_resources_desc'] = 'View the blog resources';
 $messages['view_trackbacks_desc'] = 'View the blog trackbacks';
+$messages['login_perm_desc'] = 'User is allowed to log in';
 
 $messages['summary_welcome_msg'] = 'Welcome, %s!';
 $messages['summary_go_to_admin'] = 'Go to admin interface';
@@ -1155,4 +1156,6 @@
 $messages['error_updating_permission'] = 'There was an error updating the permission';
 $messages['permission_updated_ok'] = 'Permission updated succesfully';
 $messages['error_adding_permission'] = 'There was an error adding the permission';
+
+$messages['error_cannot_login'] = 'Sorry, you are not allowed to log in';
 ?>
\ No newline at end of file

Modified: plog/trunk/templates/admin/userprofile.template
===================================================================
--- plog/trunk/templates/admin/userprofile.template	2006-10-29 18:09:27 UTC (rev 4209)
+++ plog/trunk/templates/admin/userprofile.template	2006-10-29 18:12:26 UTC (rev 4210)
@@ -56,6 +56,18 @@
 		{$locale->tr("site_admin_help")}
       </div>
     </div>
+	<div class="field">
+		<label for="userPermissions">{$locale->tr("permissions")}</label>
+		<span class="required"></span>
+		<div class="formHelp">{$locale->tr("user_permissions")}</div>
+		{foreach from=$permissions item=perm}
+			{if $perm->isAdminOnlyPermission()}
+			  {assign var=permId value=$perm->getId()}
+			  <input type="checkbox" class="checkbox" name="userPermissions[{$perm->getId()}]" value="{$perm->getId()}" {if $userPermissions[$permId]}checked="checked"{/if} />
+			  {assign var=permDesc value=$perm->getDescription()}
+			  {$locale->tr($permDesc)}<br/>
+			{/if}
+		{/foreach}
     <input type="hidden" name="userPictureId" value="{$edituser->getPictureId()}" />
   </fieldset>
   <div class="buttons">



More information about the pLog-svn mailing list