[pLog-svn] r529 - in plog/trunk: class/action/admin js/ui templates/admin

oscar at devel.plogworld.net oscar at devel.plogworld.net
Fri Dec 17 16:35:32 GMT 2004


Author: oscar
Date: 2004-12-17 16:35:31 +0000 (Fri, 17 Dec 2004)
New Revision: 529

Modified:
   plog/trunk/class/action/admin/adminupdateeditblogaction.class.php
   plog/trunk/js/ui/common.js
   plog/trunk/templates/admin/editblog.template
Log:
added support for editing the list of users that have access to the blog


Modified: plog/trunk/class/action/admin/adminupdateeditblogaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminupdateeditblogaction.class.php	2004-12-17 16:34:59 UTC (rev 528)
+++ plog/trunk/class/action/admin/adminupdateeditblogaction.class.php	2004-12-17 16:35:31 UTC (rev 529)
@@ -10,6 +10,7 @@
     include_once( PLOG_CLASS_PATH."class/view/admin/admineditsiteblogview.class.php" );
     include_once( PLOG_CLASS_PATH."class/dao/blogs.class.php" );
     include_once( PLOG_CLASS_PATH."class/dao/users.class.php" );
+    include_once( PLOG_CLASS_PATH."class/dao/userpermissions.class.php" );
     include_once( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" );
     include_once( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
 	include_once( PLOG_CLASS_PATH."class/data/validator/arrayvalidator.class.php" );
@@ -31,6 +32,7 @@
 		var $_blogName;
 		var $_blogLocale;
 		var $_blogStatus;
+		var $_blogUsers;
 
     	/**
          * Constructor. If nothing else, it also has to call the constructor of the parent
@@ -61,7 +63,7 @@
 		 */
 		function updateBlogUsers()
 		{
-		
+
 		}
 
         /**
@@ -80,6 +82,7 @@
 			$this->_blogQuota = $this->_request->getValue( "blogResourcesQuota" );
 			$this->_blogUsers = $this->_request->getValue( "blogUsers" );
 			$this->_blogStatus = $this->_request->getValue( "blogStatus" );
+			print_r($_REQUEST);
 		
         	// get the blog we're trying to update
             $blogs = new Blogs();
@@ -126,6 +129,17 @@
                	$this->setCommonData();
                 return false;
             }
+
+			// update the user permissions, even if they didn't change (but we have no way to 
+			// check that anyway!)
+			$permissions = new UserPermissions();
+			if( !$permissions->updateBlogUserPermissions( $this->_editBlogId, $this->_blogUsers )) {
+		            	$this->_view = new AdminSiteBlogsListView( $this->_blogInfo );
+                		$this->_view->setErrorMessage( $this->_locale->pr( "error_updating_blog_settings", $blogInfo->getBlog()));
+		               	$this->setCommonData();
+                		return false;
+			}
+
 			$this->notifyEvent( EVENT_POST_BLOG_UPDATE, Array( "blog" => &$blogInfo ));			
 
             // do it again, baby :)))

Modified: plog/trunk/js/ui/common.js
===================================================================
--- plog/trunk/js/ui/common.js	2004-12-17 16:34:59 UTC (rev 528)
+++ plog/trunk/js/ui/common.js	2004-12-17 16:35:31 UTC (rev 529)
@@ -335,8 +335,8 @@
 function removeUserFromBlog()
 {
 	// find the lists in the page
-	siteUsersList = document.getElementById( "availableUsers[]" );
-	blogUsersList = document.getElementById( "blogUsers[]" );
+	siteUsersList = document.getElementById( "availableUsersList" );
+	blogUsersList = document.getElementById( "blogUsersList" );
 	
 	moveElement( siteUsersList, blogUsersList );
 }
@@ -347,8 +347,21 @@
 function addUserToBlog()
 {
 	// find the lists in the page
-	siteUsersList = document.getElementById( "availableUsers[]" );
-	blogUsersList = document.getElementById( "blogUsers[]" );
+	siteUsersList = document.getElementById( "availableUsersList" );
+	blogUsersList = document.getElementById( "blogUsersList" );
 	
 	moveElement( blogUsersList, siteUsersList );
 }
+
+/**
+ * automatically selects all the elements of a list
+ */
+function listSelectAll(listId)
+{
+	list = document.getElementById( listId );
+	for( i = 0; i < list.options.length; i++ ) {
+		list.options[i].selected = true;
+	}
+
+	return true;
+}

Modified: plog/trunk/templates/admin/editblog.template
===================================================================
--- plog/trunk/templates/admin/editblog.template	2004-12-17 16:34:59 UTC (rev 528)
+++ plog/trunk/templates/admin/editblog.template	2004-12-17 16:35:31 UTC (rev 529)
@@ -2,7 +2,7 @@
 {include file="$admintemplatepath/navigation.template" showOpt=editSiteBlogs title=$locale->tr("editSiteBlogs")}
 
  {include file="$admintemplatepath/formvalidate.template" message=$locale->tr("error_updating_settings")}
- <form name="blogSettings" action="admin.php" method="post">
+ <form name="blogSettings" action="admin.php" method="post" onSubmit="listSelectAll('blogUsersList');">
    <fieldset class="inputField">
     <legend>{$locale->tr("editBlog")}</legend>
 
@@ -129,24 +129,34 @@
     </div>
 
     <div class="field">
-	<label for="blogUsers[]">{$locale->tr("users")}</label>
+	<label for="">{$locale->tr("users")}</label>
         <div class="formHelp">{$locale->tr("blog_users_help")}</div>
-	  <select id="availableUsers[]" name="availableUsers[]" size="10">
+         <table>
+          <tr>
+          <td>
+	  <select id="availableUsersList" name="availableUsers[]" size="10">
 	   <option value="-1">-- {$locale->tr("please_add_or_remove")} --</option>	  
 	   {foreach from=$availableusers item=siteuser}
 	    <option value="{$siteuser->getId()}">{$siteuser->getUsername()}</option>
 	   {/foreach}
 	  </select>
+          </td>
+          <td> 
 	  &nbsp;
-	  <input type="button" value=" << " name="removeUser" onClick="javascript:addUserToBlog()" />
+	  <input type="button" value="<<" name="removeUser" onClick="javascript:addUserToBlog()" />
 	  &nbsp;
-	  <input type="button" value=" >> " name="addUser" onClick="javascript:removeUserFromBlog()" />	  
-	  <select id="blogUsers[]" name="blogUsers[]" size="10">
+	  <input type="button" value=">>" name="addUser" onClick="javascript:removeUserFromBlog()" />	  
+          </td>
+          <td>
+	  <select id="blogUsersList" name="blogUsers[]" size="10" multiple="multiple">
 	   <option value="-1">-- {$locale->tr("please_add_or_remove")} --</option>
 	   {foreach from=$blogusers item=bloguser}
 	    <option value="{$bloguser->getId()}">{$bloguser->getUsername()}</option>
 	   {/foreach}
 	  </select>
+          </td>
+         </tr>
+        </table>
        </div>
     </fieldset>
     <div class="buttons">




More information about the pLog-svn mailing list