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

oscar at devel.lifetype.net oscar at devel.lifetype.net
Sun Nov 5 20:22:28 GMT 2006


Author: oscar
Date: 2006-11-05 20:22:28 +0000 (Sun, 05 Nov 2006)
New Revision: 4245

Modified:
   plog/trunk/class/action/admin/adminadduseraction.class.php
   plog/trunk/class/view/admin/adminadduserview.class.php
   plog/trunk/templates/admin/createuser.template
   plog/trunk/templates/admin/userprofile.template
Log:
when creating a new user, it is now possible to select which site-wide permissions he is going to have


Modified: plog/trunk/class/action/admin/adminadduseraction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminadduseraction.class.php	2006-11-05 19:59:24 UTC (rev 4244)
+++ plog/trunk/class/action/admin/adminadduseraction.class.php	2006-11-05 20:22:28 UTC (rev 4245)
@@ -8,6 +8,7 @@
 	lt_include( PLOG_CLASS_PATH."class/data/validator/usernamevalidator.class.php" );	
     lt_include( PLOG_CLASS_PATH."class/dao/users.class.php" );
 	lt_include( PLOG_CLASS_PATH."class/dao/userpermissions.class.php" );
+	lt_include( PLOG_CLASS_PATH."class/dao/permissions.class.php" );	
 	lt_include( PLOG_CLASS_PATH."class/view/admin/adminadduserview.class.php" );
 	lt_include( PLOG_CLASS_PATH."class/view/admin/adminsiteuserslistview.class.php" );	
 
@@ -27,6 +28,7 @@
 		var $_userFullName;
 		var $_properties;
 		var $_userStatus;
+		var $_permissions;
 
     	function AdminAddUserAction( $actionInfo, $request )
         {
@@ -40,7 +42,9 @@
         	$this->registerField( "userFullName" );
         	$this->registerFieldValidator( "blogId", new IntegerValidator(), true );
 			$this->registerField( "blogName" );
+			$this->registerField( "userPermissions" );
         	$view = new AdminAddUserView( $this->_blogInfo );
+			$view->setErrorMessage( $this->_locale->tr("error_adding_user" ));
         	$this->setValidationErrorView( $view );
         }
 
@@ -53,6 +57,7 @@
             $this->_userFullName = Textfilter::filterAllHTML($this->_request->getValue( "userFullName" ));
 			$this->_userStatus = $this->_request->getValue( "userStatus" );
 			$this->_userBlog = $this->_request->getValue( "blogId" );
+			$this->_permissions = $this->_request->getValue( "userPermissions" );
 	        
         	// now that we have validated the data, we can proceed to create the user, making
             // sure that it doesn't already exists
@@ -83,13 +88,24 @@
                 $this->setCommonData( true );
                 return false;
             }
+
+			// grant the site-wide permissions, if any granted
+			$userPerms = new UserPermissions();
+			if( is_array( $this->_permissions )) {
+				foreach( $this->_permissions as $val => $permId ) {
+		            $perm = new UserPermission( $user->getId(), 0, $permId );
+		            $res = $userPerms->grantPermission( $perm );
+				}
+			}			
 			
-			// if the userBlog parameter is different than 0, we have to add a relationship
-			// between that user and the blog
+			// if the userBlog parameter is different than 0, we should somehow allow the user
+			// to log into that blog although he/she won't have much to do with only the
+			// blog_access permission
 			if( $this->_userBlog > 0 ) {
-				$permissions = new UserPermissions();
-				$perm = new UserPermission( $newUserId, $this->_userBlog, PERMISSION_BLOG_USER );
-				$result = $permissions->grantPermission( $perm );
+				$perms = new Permissions();
+				$blogAccess = $perms->getPermissionByName( "blog_access" );
+				$perm = new UserPermission( $newUserId, $this->_userBlog, $blogAccess->getId() );
+				$result = $userPerms->grantPermission( $perm );
 			}
 			
 			$this->notifyEvent( EVENT_POST_USER_ADD, Array( "user" => &$user ));

Modified: plog/trunk/class/view/admin/adminadduserview.class.php
===================================================================
--- plog/trunk/class/view/admin/adminadduserview.class.php	2006-11-05 19:59:24 UTC (rev 4244)
+++ plog/trunk/class/view/admin/adminadduserview.class.php	2006-11-05 20:22:28 UTC (rev 4245)
@@ -3,6 +3,7 @@
 	lt_include( PLOG_CLASS_PATH.'class/view/admin/admintemplatedview.class.php' );
 	lt_include( PLOG_CLASS_PATH.'class/dao/blogs.class.php' );
 	lt_include( PLOG_CLASS_PATH.'class/dao/userstatus.class.php' );
+	lt_include( PLOG_CLASS_PATH.'class/dao/permissions.class.php' );	
 	
 
     /**
@@ -22,6 +23,8 @@
 		function render()
 		{
 			$this->setValue( 'userStatusList', UserStatus::getStatusList());		
+			$perms = new Permissions();
+			$this->setValue( 'permissions', $perms->getAllPermissions());
 			parent::render();
 		}
 	}

Modified: plog/trunk/templates/admin/createuser.template
===================================================================
--- plog/trunk/templates/admin/createuser.template	2006-11-05 19:59:24 UTC (rev 4244)
+++ plog/trunk/templates/admin/createuser.template	2006-11-05 20:22:28 UTC (rev 4245)
@@ -53,6 +53,18 @@
 	  </a> 
       {include file="$admintemplatepath/validate.template" field=blogId message=$locale->tr("error_incorrect_blog_id")}
     </div>
+	<div class="field">
+		<label for="userPermissions">{$locale->tr("permissions")}</label>
+		<span class="required"></span>
+		<div class="formHelp">{$locale->tr("admin_user_permissions_help")}</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}
   </fieldset>
   <div class="buttons">
     <input type="reset" name="reset" value="{$locale->tr("reset")}"/>

Modified: plog/trunk/templates/admin/userprofile.template
===================================================================
--- plog/trunk/templates/admin/userprofile.template	2006-11-05 19:59:24 UTC (rev 4244)
+++ plog/trunk/templates/admin/userprofile.template	2006-11-05 20:22:28 UTC (rev 4245)
@@ -59,7 +59,7 @@
 	<div class="field">
 		<label for="userPermissions">{$locale->tr("permissions")}</label>
 		<span class="required"></span>
-		<div class="formHelp">{$locale->tr("user_permissions")}</div>
+		<div class="formHelp">{$locale->tr("admin_user_permissions_help")}</div>
 		{foreach from=$permissions item=perm}
 			{if $perm->isAdminOnlyPermission()}
 			  {assign var=permId value=$perm->getId()}



More information about the pLog-svn mailing list