[pLog-svn] r5155 - in plog/branches/lifetype-1.2: class/action/admin class/controller js/ui locale/admin templates/admin

oscar at devel.lifetype.net oscar at devel.lifetype.net
Thu Mar 22 08:17:23 EDT 2007


Author: oscar
Date: 2007-03-22 08:17:23 -0400 (Thu, 22 Mar 2007)
New Revision: 5155

Added:
   plog/branches/lifetype-1.2/class/action/admin/adminchangeuserstatusaction.class.php
Modified:
   plog/branches/lifetype-1.2/class/controller/admincontrollermap.properties.php
   plog/branches/lifetype-1.2/js/ui/plogui.js
   plog/branches/lifetype-1.2/locale/admin/locale_ca_ES.php
   plog/branches/lifetype-1.2/locale/admin/locale_de_DE.php
   plog/branches/lifetype-1.2/locale/admin/locale_en_UK.php
   plog/branches/lifetype-1.2/locale/admin/locale_es_ES.php
   plog/branches/lifetype-1.2/locale/admin/locale_fr_FR.php
   plog/branches/lifetype-1.2/locale/admin/locale_it_IT.php
   plog/branches/lifetype-1.2/locale/admin/locale_nl_NL.php
   plog/branches/lifetype-1.2/locale/admin/locale_zh_CN.php
   plog/branches/lifetype-1.2/locale/admin/locale_zh_TW.php
   plog/branches/lifetype-1.2/templates/admin/siteblogs.template
   plog/branches/lifetype-1.2/templates/admin/siteusers.template
Log:
Support for mass edition of users, also with a few new strings.


Added: plog/branches/lifetype-1.2/class/action/admin/adminchangeuserstatusaction.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/action/admin/adminchangeuserstatusaction.class.php	                        (rev 0)
+++ plog/branches/lifetype-1.2/class/action/admin/adminchangeuserstatusaction.class.php	2007-03-22 12:17:23 UTC (rev 5155)
@@ -0,0 +1,100 @@
+<?php
+
+	lt_include( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
+    lt_include( PLOG_CLASS_PATH."class/view/admin/adminsiteuserslistview.class.php" );
+    lt_include( PLOG_CLASS_PATH."class/dao/users.class.php" );
+	lt_include( PLOG_CLASS_PATH."class/template/cachecontrol.class.php" );
+	lt_include( PLOG_CLASS_PATH."class/data/validator/arrayvalidator.class.php" );
+	lt_include( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
+
+    /**
+     * \ingroup Action
+     * @private
+     *
+     * Implements bulk changes of users
+     */
+    class AdminChangeUserStatusAction extends AdminAction 
+	{
+
+        var $_postIds;
+        var $_postStatus;
+
+    	/**
+         * Constructor. If nothing else, it also has to call the constructor of the parent
+         * class, BlogAction with the same parameters
+         */
+        function AdminChangeUserStatusAction( $actionInfo, $request )
+        {
+        	$this->AdminAction( $actionInfo, $request );
+			$this->registerFieldValidator( "userIds", new ArrayValidator());
+			$this->registerFieldValidator( "userStatus", new IntegerValidator() );
+			$view = new AdminSiteUsersListView( $this->_blogInfo );
+			$view->setErrorMessage( $this->_locale->tr("error_incorrect_user"));
+			$this->setValidationErrorView( $view );
+			
+			$this->requireAdminPermission( "update_user" );	
+        }
+
+        /**
+         * Carries out the specified action
+         */
+        function _changeUserStatus()
+        {
+        	// Chanages the post status field by selection
+            $users = new Users();
+            $errorMessage = "";
+			$successMessage = "";
+			$totalOk = 0;
+			
+            foreach( $this->_userIds as $userId ) {
+            	// get the post
+                $user = $users->getUserInfoFromId( $userId );
+				
+				if( $user ) {
+					// fire the event
+					$this->notifyEvent( EVENT_PRE_USER_UPDATE, Array( "user" => &$user ));
+					
+					// update the post status
+					$user->setStatus( $this->_userStatus );
+					$result = $users->updateUser( $user );
+					
+					if( !$result ) {
+						$errorMessage .= $this->_locale->pr("error_updating_user", $user->getUsername())."<br/>";
+					}
+					else {
+						$totalOk++;
+						if( $totalOk < 2 ) 
+							$successMessage .= $this->_locale->pr("user_updated_ok", $user->getUsername())."<br/>";
+						else
+							$successMessage = $this->_locale->pr("users_updated_ok", $totalOk );
+						// fire the post event
+						$this->notifyEvent( EVENT_POST_BLOG_UPDATE, Array( "user" => &$user ));					
+					}
+				}
+				else {
+					$errorMessage .= $this->_locale->pr( "eror_updating_user2", $userId )."<br/>";
+				}
+            }
+			
+			$this->_view = new AdminSiteUsersListView( $this->_blogInfo );
+			if( $errorMessage != "" ) 
+				$this->_view->setErrorMessage( $errorMessage );
+			if( $successMessage != "" )
+				$this->_view->setSuccessMessage( $successMessage );
+				
+			$this->setCommonData();
+			
+            return true;
+        }
+		
+		function perform()
+		{
+			// prepare the parameters.. If there's only one category id, then add it to
+			// an array.
+			$this->_userIds = $this->_request->getValue( "userIds" );
+			$this->_userStatus = $this->_request->getValue( "userStatus" );
+				
+			$this->_changeUserStatus();
+		}
+    }
+?>
\ No newline at end of file

Modified: plog/branches/lifetype-1.2/class/controller/admincontrollermap.properties.php
===================================================================
--- plog/branches/lifetype-1.2/class/controller/admincontrollermap.properties.php	2007-03-22 09:40:36 UTC (rev 5154)
+++ plog/branches/lifetype-1.2/class/controller/admincontrollermap.properties.php	2007-03-22 12:17:23 UTC (rev 5155)
@@ -318,4 +318,6 @@
 	$actions["updatePluginSettings"] = "AdminUpdatePluginSettingsAction";	
 	// bulk update of blogs
 	$actions["changeBlogStatus"] = "AdminChangeBlogStatusAction";
+	// bulk update of users
+	$actions["changeUserStatus"] = "AdminChangeUserStatusAction";	
 ?>
\ No newline at end of file

Modified: plog/branches/lifetype-1.2/js/ui/plogui.js
===================================================================
--- plog/branches/lifetype-1.2/js/ui/plogui.js	2007-03-22 09:40:36 UTC (rev 5154)
+++ plog/branches/lifetype-1.2/js/ui/plogui.js	2007-03-22 12:17:23 UTC (rev 5155)
@@ -181,6 +181,26 @@
 	document.getElementById("links").submit();
 }
 
+function submitBlogsList(op)
+{
+	if ( document.getElementById("blogStatus").value == -1 )
+		window.alert(errorStatusMsg);
+	else {
+		document.getElementById("editBlogs").op.value = op;
+		document.getElementById("editBlogs").submit();
+	}
+}
+
+function submitUsersList(op)
+{
+	if ( document.getElementById("userStatus").value == -1 )
+		window.alert(errorStatusMsg);
+	else {
+		document.getElementById("siteUsers").op.value = op;
+		document.getElementById("siteUsers").submit();
+	}
+}
+
 function switchMassiveOption()
 {
 	if ( $('massiveChangeOption').style.display == 'none' )

Modified: plog/branches/lifetype-1.2/locale/admin/locale_ca_ES.php
===================================================================
--- plog/branches/lifetype-1.2/locale/admin/locale_ca_ES.php	2007-03-22 09:40:36 UTC (rev 5154)
+++ plog/branches/lifetype-1.2/locale/admin/locale_ca_ES.php	2007-03-22 12:17:23 UTC (rev 5155)
@@ -1163,8 +1163,15 @@
 
 $messages['help_login_admin_panel'] = 'Faci clic sobre el nom del bloc per a administrar-lo';
 
-$messages['blog_updated_ok'] = 'El bloc "%s" ha estat actualitzat correctament.';
-$messages['blogs_updated_ok'] = '%s blocs han estat actualitzats correctament.';
-$messages['error_updating_blog2'] = 'S\'ha produït un error actualitzant el bloc amb identificador "%s"';
-$messages['error_updating_blog'] = 'S\'ha produït un error actualitzant el bloc "%s"';
+$messages['blog_updated_ok'] = 'El bloc "%s" ha estat modificat correctament.';
+$messages['blogs_updated_ok'] = '%s blocs han estat modificats correctament.';
+$messages['error_updating_blog2'] = 'S\'ha produït un error modificat el bloc amb identificador "%s"';
+$messages['error_updating_blog'] = 'S\'ha produït un error modificat el bloc "%s"';
+
+$messages['error_updating_user'] = 'S\'ha produït un error modificat l\'usuari "%s".';
+$messages['user_updated_ok'] = 'L\'usuari "%s" ha estat modificat correctament.';
+$messages['users_updated_ok'] = '%s usuaris han estat correctament modificats';
+$messages['eror_updating_user2'] = 'S\'ha produït un error actualitzant l\'usuari amb identificador "%s"';
+
+$messages['error_select_status'] = 'Esculli un estat vàlid';
 ?>
\ No newline at end of file

Modified: plog/branches/lifetype-1.2/locale/admin/locale_de_DE.php
===================================================================
--- plog/branches/lifetype-1.2/locale/admin/locale_de_DE.php	2007-03-22 09:40:36 UTC (rev 5154)
+++ plog/branches/lifetype-1.2/locale/admin/locale_de_DE.php	2007-03-22 12:17:23 UTC (rev 5155)
@@ -1153,4 +1153,11 @@
 $messages['blogs_updated_ok'] = '%s blogs were successfully updated';
 $messages['error_updating_blog2'] = 'There was an error updating the blog whose identifier is "%s"';
 $messages['error_updating_blog'] = 'There was an error updating blog "%s"';
+
+$messages['error_updating_user'] = 'There was an error updating user "%s".';
+$messages['user_updated_ok'] = 'User "%s" was successfully updated.';
+$messages['users_updated_ok'] = '%s users were successfully updated';
+$messages['eror_updating_user2'] = 'There was an error updating user with identifier "%s"';
+
+$messages['error_select_status'] = 'Please select a valid status';
 ?>
\ No newline at end of file

Modified: plog/branches/lifetype-1.2/locale/admin/locale_en_UK.php
===================================================================
--- plog/branches/lifetype-1.2/locale/admin/locale_en_UK.php	2007-03-22 09:40:36 UTC (rev 5154)
+++ plog/branches/lifetype-1.2/locale/admin/locale_en_UK.php	2007-03-22 12:17:23 UTC (rev 5155)
@@ -1150,4 +1150,11 @@
 $messages['blogs_updated_ok'] = '%s blogs were successfully updated';
 $messages['error_updating_blog2'] = 'There was an error updating the blog whose identifier is "%s"';
 $messages['error_updating_blog'] = 'There was an error updating blog "%s"';
+
+$messages['error_updating_user'] = 'There was an error updating user "%s".';
+$messages['user_updated_ok'] = 'User "%s" was successfully updated.';
+$messages['users_updated_ok'] = '%s users were successfully updated';
+$messages['eror_updating_user2'] = 'There was an error updating user with identifier "%s"';
+
+$messages['error_select_status'] = 'Please select a valid status';
 ?>
\ No newline at end of file

Modified: plog/branches/lifetype-1.2/locale/admin/locale_es_ES.php
===================================================================
--- plog/branches/lifetype-1.2/locale/admin/locale_es_ES.php	2007-03-22 09:40:36 UTC (rev 5154)
+++ plog/branches/lifetype-1.2/locale/admin/locale_es_ES.php	2007-03-22 12:17:23 UTC (rev 5155)
@@ -1161,4 +1161,11 @@
 $messages['blogs_updated_ok'] = '%s bitácoras fueron actualizadas correctamente';
 $messages['error_updating_blog2'] = 'Hubo un error actualizando la bitácora cuyo identificador es "%s"';
 $messages['error_updating_blog'] = 'Hubo un error actualizando la bitácora "%s"';
+
+$messages['error_updating_user'] = 'Hubo un error modificando el usuario "%s".';
+$messages['user_updated_ok'] = 'El usuario "%s" fue modificado correctamente.';
+$messages['users_updated_ok'] = '%s usuarios fueron modificados correctamente';
+$messages['eror_updating_user2'] = 'Hubo un error modificando el usuario cuyo identificador es "%s"';
+
+$messages['error_select_status'] = 'Seleccione un estado.';
 ?>
\ No newline at end of file

Modified: plog/branches/lifetype-1.2/locale/admin/locale_fr_FR.php
===================================================================
--- plog/branches/lifetype-1.2/locale/admin/locale_fr_FR.php	2007-03-22 09:40:36 UTC (rev 5154)
+++ plog/branches/lifetype-1.2/locale/admin/locale_fr_FR.php	2007-03-22 12:17:23 UTC (rev 5155)
@@ -1330,4 +1330,11 @@
 $messages['blogs_updated_ok'] = '%s blogs were successfully updated';
 $messages['error_updating_blog2'] = 'There was an error updating the blog whose identifier is "%s"';
 $messages['error_updating_blog'] = 'There was an error updating blog "%s"';
+
+$messages['error_updating_user'] = 'There was an error updating user "%s".';
+$messages['user_updated_ok'] = 'User "%s" was successfully updated.';
+$messages['users_updated_ok'] = '%s users were successfully updated';
+$messages['eror_updating_user2'] = 'There was an error updating user with identifier "%s"';
+
+$messages['error_select_status'] = 'Please select a valid status';
 ?>
\ No newline at end of file

Modified: plog/branches/lifetype-1.2/locale/admin/locale_it_IT.php
===================================================================
--- plog/branches/lifetype-1.2/locale/admin/locale_it_IT.php	2007-03-22 09:40:36 UTC (rev 5154)
+++ plog/branches/lifetype-1.2/locale/admin/locale_it_IT.php	2007-03-22 12:17:23 UTC (rev 5155)
@@ -1148,4 +1148,11 @@
 $messages['blogs_updated_ok'] = '%s blogs were successfully updated';
 $messages['error_updating_blog2'] = 'There was an error updating the blog whose identifier is "%s"';
 $messages['error_updating_blog'] = 'There was an error updating blog "%s"';
+
+$messages['error_updating_user'] = 'There was an error updating user "%s".';
+$messages['user_updated_ok'] = 'User "%s" was successfully updated.';
+$messages['users_updated_ok'] = '%s users were successfully updated';
+$messages['eror_updating_user2'] = 'There was an error updating user with identifier "%s"';
+
+$messages['error_select_status'] = 'Please select a valid status';
 ?>
\ No newline at end of file

Modified: plog/branches/lifetype-1.2/locale/admin/locale_nl_NL.php
===================================================================
--- plog/branches/lifetype-1.2/locale/admin/locale_nl_NL.php	2007-03-22 09:40:36 UTC (rev 5154)
+++ plog/branches/lifetype-1.2/locale/admin/locale_nl_NL.php	2007-03-22 12:17:23 UTC (rev 5155)
@@ -1228,4 +1228,11 @@
 $messages['blogs_updated_ok'] = '%s blogs were successfully updated';
 $messages['error_updating_blog2'] = 'There was an error updating the blog whose identifier is "%s"';
 $messages['error_updating_blog'] = 'There was an error updating blog "%s"';
+
+$messages['error_updating_user'] = 'There was an error updating user "%s".';
+$messages['user_updated_ok'] = 'User "%s" was successfully updated.';
+$messages['users_updated_ok'] = '%s users were successfully updated';
+$messages['eror_updating_user2'] = 'There was an error updating user with identifier "%s"';
+
+$messages['error_select_status'] = 'Please select a valid status';
 ?>
\ No newline at end of file

Modified: plog/branches/lifetype-1.2/locale/admin/locale_zh_CN.php
===================================================================
--- plog/branches/lifetype-1.2/locale/admin/locale_zh_CN.php	2007-03-22 09:40:36 UTC (rev 5154)
+++ plog/branches/lifetype-1.2/locale/admin/locale_zh_CN.php	2007-03-22 12:17:23 UTC (rev 5155)
@@ -1150,4 +1150,11 @@
 $messages['blogs_updated_ok'] = '%s blogs were successfully updated';
 $messages['error_updating_blog2'] = 'There was an error updating the blog whose identifier is "%s"';
 $messages['error_updating_blog'] = 'There was an error updating blog "%s"';
+
+$messages['error_updating_user'] = 'There was an error updating user "%s".';
+$messages['user_updated_ok'] = 'User "%s" was successfully updated.';
+$messages['users_updated_ok'] = '%s users were successfully updated';
+$messages['eror_updating_user2'] = 'There was an error updating user with identifier "%s"';
+
+$messages['error_select_status'] = 'Please select a valid status';
 ?>
\ No newline at end of file

Modified: plog/branches/lifetype-1.2/locale/admin/locale_zh_TW.php
===================================================================
--- plog/branches/lifetype-1.2/locale/admin/locale_zh_TW.php	2007-03-22 09:40:36 UTC (rev 5154)
+++ plog/branches/lifetype-1.2/locale/admin/locale_zh_TW.php	2007-03-22 12:17:23 UTC (rev 5155)
@@ -1150,4 +1150,11 @@
 $messages['blogs_updated_ok'] = '%s blogs were successfully updated';
 $messages['error_updating_blog2'] = 'There was an error updating the blog whose identifier is "%s"';
 $messages['error_updating_blog'] = 'There was an error updating blog "%s"';
+
+$messages['error_updating_user'] = 'There was an error updating user "%s".';
+$messages['user_updated_ok'] = 'User "%s" was successfully updated.';
+$messages['users_updated_ok'] = '%s users were successfully updated';
+$messages['eror_updating_user2'] = 'There was an error updating user with identifier "%s"';
+
+$messages['error_select_status'] = 'Please select a valid status';
 ?>
\ No newline at end of file

Modified: plog/branches/lifetype-1.2/templates/admin/siteblogs.template
===================================================================
--- plog/branches/lifetype-1.2/templates/admin/siteblogs.template	2007-03-22 09:40:36 UTC (rev 5154)
+++ plog/branches/lifetype-1.2/templates/admin/siteblogs.template	2007-03-22 12:17:23 UTC (rev 5155)
@@ -2,7 +2,7 @@
 {include file="$admintemplatepath/navigation.template" showOpt=editSiteBlogs title=$locale->tr("editSiteBlogs")}
 <script type="text/javascript" src="js/ui/plogui.js"></script>
 <script type="text/javascript">
-	var errorCommentStatusMsg = '{$locale->tr("error_comment_status")}';
+	var errorStatusMsg = '{$locale->tr("error_select_status")}';
 	var showMassiveChangeOption = '{$locale->tr("show_massive_change_option")}';
 	var hideMassiveChangeOption = '{$locale->tr("hide_massive_change_option")}';
 </script>
@@ -101,6 +101,7 @@
     </tbody> 
    </table>
   </div>
+ <a name="bulkEdit"></a>
   <div id="list_action_bar">
 	{adminpager style="list"}
 	{check_perms adminperm=update_site_blog}
@@ -125,4 +126,4 @@
   </div> 
  </form>
 {include file="$admintemplatepath/footernavigation.template"}
-{include file="$admintemplatepath/footer.template"}
+{include file="$admintemplatepath/footer.template"}
\ No newline at end of file

Modified: plog/branches/lifetype-1.2/templates/admin/siteusers.template
===================================================================
--- plog/branches/lifetype-1.2/templates/admin/siteusers.template	2007-03-22 09:40:36 UTC (rev 5154)
+++ plog/branches/lifetype-1.2/templates/admin/siteusers.template	2007-03-22 12:17:23 UTC (rev 5155)
@@ -1,6 +1,12 @@
 {include file="$admintemplatepath/header.template"}
 {include file="$admintemplatepath/navigation.template" showOpt=editSiteUsers title=$locale->tr("editSiteUsers")} 
+<script type="text/javascript" src="js/ui/plogui.js"></script>
 <script type="text/javascript">
+	var errorStatusMsg = '{$locale->tr("error_select_status")}';
+	var showMassiveChangeOption = '{$locale->tr("show_massive_change_option")}';
+	var hideMassiveChangeOption = '{$locale->tr("hide_massive_change_option")}';
+</script>
+<script type="text/javascript">
 {literal}
 YAHOO.util.Event.addListener( window, "load", function() {
 		var t = new Lifetype.UI.TableEffects( "list" );
@@ -43,6 +49,13 @@
  </div>             
  
         <form id="siteUsers" action="admin.php" method="post">
+	
+			{check_perms adminperm=update_user}	
+			     <div class="optionIcon">
+					<a id="optionIconLink" href="#bulkEdit" title="{$locale->tr("show_massive_change_option")}" onclick="switchMassiveOption()">{$locale->tr("show_massive_change_option")}</a>
+				</div>
+			{/check_perms}	
+	
         <div id="list">
   {include file="$admintemplatepath/successmessage.template"}
   {include file="$admintemplatepath/errormessage.template"}
@@ -69,14 +82,6 @@
                         </td>
                         <td class="col_highlighted">
                             <a href="?op=editSiteUser&amp;userId={$siteuser->getId()}">{$siteuser->getUsername()|truncate:20:"..."}</a>
-							{assign var=userPerms value=$siteuser->getPermissions(0)}
-							<script type="text/javascript">
-							  myTooltip = new YAHOO.widget.Tooltip("myTooltip", {literal}{{/literal}  
-							    context:"user_{$siteuser->getId()}",  
-								text:"{$locale->tr("permissions")}:<br/>{foreach from=$userPerms item=perm}{$perm->getPermissionName()}<br/>{/foreach}"
-								{literal}}{/literal} );
-							</script>
-
                         </td>
                         <td>
                             {$siteuser->getFullName()|truncate:70:"..."}
@@ -107,13 +112,29 @@
                 </tbody>
             </table>
         </div>        
+		<a name="bulkEdit"></a>
         <div id="list_action_bar">
-            {adminpager style=list}
-			{check_perms adminperm=update_user}
-              <input type="submit" name="delete" value="{$locale->tr("delete")}" class="submit" />
-              <input type="hidden" name="op" value="deleteUsers" />
-			{/check_perms}
-        </div>
+        {adminpager style=list}
+		{check_perms adminperm=update_user}
+             <input type="submit" name="delete" value="{$locale->tr("delete")}" class="submit" />
+             <input type="hidden" name="op" value="deleteUsers" />
+		{/check_perms}
+		{check_perms adminperm=update_user}
+	    <div id="massiveChangeOption" style="display: none">
+	        <fieldset>	
+	        <legend>{$locale->tr("massive_change_option")}</legend>            
+	            <label for="userStatus">{$locale->tr("status")}</label>
+	            <select name="userStatus" id="userStatus">
+	              <option value="-1">-{$locale->tr("select")}-</option>
+			    	{foreach from=$userstatus key=name item=status}
+			      		{if $status != -1}<option value="{$status}">{$locale->tr($name)}</option>{/if}
+			    	{/foreach}	
+	            </select>
+	            <input type="button" name="changeUserStatus" value="{$locale->tr("change_status")}" class="submit" onClick="javascript:submitUsersList('changeUserStatus');" /> 
+	        </fieldset>
+		</div>
+		{/check_perms}
+	  </div>	
 	</form>
 
 {include file="$admintemplatepath/footernavigation.template"}



More information about the pLog-svn mailing list