[pLog-svn] r5783 - in plog/trunk: class/action/admin class/view/admin js/ui/pages templates/admin
oscar at devel.lifetype.net
oscar at devel.lifetype.net
Fri Aug 3 18:09:35 EDT 2007
Author: oscar
Date: 2007-08-03 18:09:34 -0400 (Fri, 03 Aug 2007)
New Revision: 5783
Added:
plog/trunk/js/ui/pages/blogusers.js
Removed:
plog/trunk/js/ui/pages/addbloguser.js
Modified:
plog/trunk/class/action/admin/adminaddbloguseraction.class.php
plog/trunk/class/action/admin/admindeletebloguserpermissionsaction.class.php
plog/trunk/class/action/admin/adminshowblogusersaction.class.php
plog/trunk/class/view/admin/adminbloguserslistview.class.php
plog/trunk/templates/admin/addbloguser.template
plog/trunk/templates/admin/blogusers.template
plog/trunk/templates/admin/blogusers_table.template
Log:
Implemented a few fixes as well as deletion of user permissions via ajax.
Modified: plog/trunk/class/action/admin/adminaddbloguseraction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminaddbloguseraction.class.php 2007-08-03 22:07:19 UTC (rev 5782)
+++ plog/trunk/class/action/admin/adminaddbloguseraction.class.php 2007-08-03 22:09:34 UTC (rev 5783)
@@ -27,7 +27,7 @@
$this->AdminAction( $actionInfo, $request );
// data validation
- $this->registerFieldValidator( "newBlogUserName", new StringValidator(), false, $this->_locale->tr("error_invalid_user"));
+ $this->registerFieldValidator( "userName", new StringValidator(), false, $this->_locale->tr("error_invalid_user"));
$this->_sendNotification = ($this->_request->getValue( "sendNotification" ) != "" );
$this->registerField( "sendNotification" );
$this->registerField( "perm" );
@@ -59,7 +59,7 @@
function addBlogUser()
{
- $this->_newUsername = $this->_request->getFilteredValue( "newBlogUserName", new HtmlFilter());
+ $this->_newUsername = $this->_request->getFilteredValue( "userName", new HtmlFilter());
$this->_perms = $this->_request->getValue( "perm" );
// see if the user exists
@@ -67,6 +67,7 @@
$userInfo = $users->getUserInfoFromUsername( $this->_newUsername );
if( !$userInfo ) {
$this->_message = $this->_locale->pr("error_invalid_user", $this->_newUsername );
+ $this->_form->setFieldValidationStatus( "userName", false );
return false;
}
$this->notifyEvent( EVENT_USER_LOADED, Array( "user" => &$userInfo ));
Modified: plog/trunk/class/action/admin/admindeletebloguserpermissionsaction.class.php
===================================================================
--- plog/trunk/class/action/admin/admindeletebloguserpermissionsaction.class.php 2007-08-03 22:07:19 UTC (rev 5782)
+++ plog/trunk/class/action/admin/admindeletebloguserpermissionsaction.class.php 2007-08-03 22:09:34 UTC (rev 5783)
@@ -36,20 +36,27 @@
function perform()
{
+ // perform the action itself...
+ $results = $this->_revokePermissions();
+
+ $this->_view = new AdminBlogUsersListView( $this->_blogInfo );
+ if( $results["errorMessage"] != "" ) $this->_view->setErrorMessage( $results["errorMessage"] );
+ if( $results["successMessage"] != "" ) $this->_view->setSuccessMessage( $results["successMessage"] );
+ $this->setCommonData();
+
+ return true;
+ }
+
+ function _revokePermissions()
+ {
if( $this->_op == "deleteBlogUserPermissions" ) {
$this->_userId = $this->_request->getValue( "userId" );
$this->_userIds = Array();
$this->_userIds[] = $this->_userId;
}
else
- $this->_userIds = $this->_request->getValue( "userIds" );
-
- // perform the action itself...
- $this->_revokePermissions();
- }
-
- function _revokePermissions()
- {
+ $this->_userIds = $this->_request->getValue( "userIds" );
+
// now that we have the list of users we'd like to remove
// let's go through it and remove those that have been selected
$users = new Users();
@@ -78,12 +85,20 @@
}
}
- $this->_view = new AdminBlogUsersListView( $this->_blogInfo );
- if( $successMessage != "" ) $this->_view->setSuccessMessage( $successMessage );
- if( $errorMessage != "" ) $this->_view->setErrorMessage( $errorMessage );
- $this->setCommonData();
+ return( Array( "errorMessage" => $errorMessage, "successMessage" => $successMessage ));
+ }
- return true;
- }
+ function performAjax()
+ {
+ // perform the action itself...
+ $results = $this->_revokePermissions();
+
+ lt_include( PLOG_CLASS_PATH."class/view/admin/ajax/adminajaxview.class.php" );
+ $this->_view = new AdminAjaxView( $this->_blogInfo );
+ if( $results["errorMessage"] != "" ) $this->_view->setErrorMessage( $results["errorMessage"] );
+ if( $results["successMessage"] != "" ) $this->_view->setSuccessMessage( $results["successMessage"] );
+
+ return true;
+ }
}
?>
\ No newline at end of file
Modified: plog/trunk/class/action/admin/adminshowblogusersaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminshowblogusersaction.class.php 2007-08-03 22:07:19 UTC (rev 5782)
+++ plog/trunk/class/action/admin/adminshowblogusersaction.class.php 2007-08-03 22:09:34 UTC (rev 5783)
@@ -27,5 +27,17 @@
return true;
}
+
+ function performAjax()
+ {
+ lt_include( PLOG_CLASS_PATH."class/view/renderer/ajaxviewrenderer.class.php" );
+
+ $view = new AdminBlogUsersListView( $this->_blogInfo );
+ $view->loadData();
+ $this->_view = new AjaxViewRenderer( $view );
+
+ $this->_view->setSuccess( true );
+ $this->_view->setResultObject( "blogusers" );
+ }
}
?>
\ No newline at end of file
Modified: plog/trunk/class/view/admin/adminbloguserslistview.class.php
===================================================================
--- plog/trunk/class/view/admin/adminbloguserslistview.class.php 2007-08-03 22:07:19 UTC (rev 5782)
+++ plog/trunk/class/view/admin/adminbloguserslistview.class.php 2007-08-03 22:09:34 UTC (rev 5783)
@@ -14,16 +14,24 @@
function AdminBlogUsersListView( $blogInfo )
{
- $this->AdminTemplatedView( $blogInfo, "blogusers" );
+ $r =& Request::getRequest();
+ if( $r->isTableOnly())
+ $this->AdminTemplatedView( $blogInfo, "blogusers_table" );
+ else
+ $this->AdminTemplatedView( $blogInfo, "blogusers" );
}
- function render()
+ function loadData()
{
// get the users of the blog
$users = new Users();
$blogUsers = $users->getBlogUsers( $this->_blogInfo->getId(), false );
- $this->setValue( "blogusers", $blogUsers );
-
+ $this->setValue( "blogusers", $blogUsers );
+ }
+
+ function render()
+ {
+ $this->loadData();
// no need to do anything else, so... transfer control to the parent view!
parent::render();
}
Deleted: plog/trunk/js/ui/pages/addbloguser.js
===================================================================
--- plog/trunk/js/ui/pages/addbloguser.js 2007-08-03 22:07:19 UTC (rev 5782)
+++ plog/trunk/js/ui/pages/addbloguser.js 2007-08-03 22:09:34 UTC (rev 5783)
@@ -1,50 +0,0 @@
-
-// In LifeType 1.2 imeplemtation, we don't have the Role object.
-// So, I just defined two kind of permission group here, it can help user configure thier blog user permission easily.
-var permissionSets = new Array();
-permissionSets["basic_blog_permission"] = new Array( 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 22, 23, 24, 25, 26, 36, 37 );
-permissionSets["full_blog_permission"] = new Array( 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38 );
-
-Lifetype.UI.Pages.AddBlogUser = function() {}
-
-Lifetype.UI.Pages.AddBlogUser.togglePermissionSets = function(formName, permissionSet)
-{
- if(permissionSet == "")
- return;
-
- f = document.getElementById(formName);
- i = 0;
- while (e = f.elements[i])
- {
- if (e.type == "checkbox" && e.id != "sendNotification")
- {
- if( Lifetype.UI.Pages.AddBlogUser.inArray(permissionSets[permissionSet], e.value) )
- e.checked = 1;
- else
- e.checked = 0;
- }
- i++;
- }
-}
-
-/**
- * Returns true if the passed value is found in the
- * array. Returns false if it is not.
- */
-Lifetype.UI.Pages.AddBlogUser.inArray = function(a, v, c)
-{
- var i;
- for (i=0; i < a.length; i++) {
- // use === to check for Matches. ie., identical (===),
- if(c){ //performs match even the string is case sensitive
- if (a[i].toLowerCase() == v.toLowerCase()) {
- return true;
- }
- }else{
- if (a[i] == v) {
- return true;
- }
- }
- }
- return false;
-}
\ No newline at end of file
Added: plog/trunk/js/ui/pages/blogusers.js
===================================================================
--- plog/trunk/js/ui/pages/blogusers.js (rev 0)
+++ plog/trunk/js/ui/pages/blogusers.js 2007-08-03 22:09:34 UTC (rev 5783)
@@ -0,0 +1,65 @@
+
+// In LifeType 1.2 imeplemtation, we don't have the Role object.
+// So, I just defined two kind of permission group here, it can help user configure thier blog user permission easily.
+var permissionSets = new Array();
+permissionSets["basic_blog_permission"] = new Array( 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 22, 23, 24, 25, 26, 36, 37 );
+permissionSets["full_blog_permission"] = new Array( 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38 );
+
+Lifetype.UI.Pages.BlogUsers = function() {}
+
+Lifetype.UI.Pages.BlogUsers.togglePermissionSets = function(formName, permissionSet)
+{
+ if(permissionSet == "")
+ return;
+
+ f = document.getElementById(formName);
+ i = 0;
+ while (e = f.elements[i])
+ {
+ if (e.type == "checkbox" && e.id != "sendNotification")
+ {
+ if( Lifetype.UI.Pages.BlogUsers.inArray(permissionSets[permissionSet], e.value) )
+ e.checked = 1;
+ else
+ e.checked = 0;
+ }
+ i++;
+ }
+}
+
+/**
+ * Returns true if the passed value is found in the
+ * array. Returns false if it is not.
+ */
+Lifetype.UI.Pages.BlogUsers.inArray = function(a, v, c)
+{
+ var i;
+ for (i=0; i < a.length; i++) {
+ // use === to check for Matches. ie., identical (===),
+ if(c){ //performs match even the string is case sensitive
+ if (a[i].toLowerCase() == v.toLowerCase()) {
+ return true;
+ }
+ }else{
+ if (a[i] == v) {
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+Lifetype.UI.Pages.BlogUsers.addBlogUserSubmitHook = function( form )
+{
+ Lifetype.Forms.AjaxFormProcessor( form.id,'?output=json', {resetAfterSuccess:true} );
+}
+
+YAHOO.util.Event.addListener( window, "load", function() {
+ var t = new Lifetype.Effects.Table( "blogUsersTable" );
+ t.stripe();
+ t.highlightRows();
+
+ // reload the list when successfully deleting an item and processing one of the forms
+ Lifetype.Forms.Events.performRequestSuccessEvent.subscribe( function() { Lifetype.UI.DataTable.reload( '?op=showBlogUsers' )});
+ Lifetype.Forms.Events.formProcessorSuccessEvent.subscribe( function() {Lifetype.UI.DataTable.reload( '?op=showBlogUsers' )});
+});
\ No newline at end of file
Modified: plog/trunk/templates/admin/addbloguser.template
===================================================================
--- plog/trunk/templates/admin/addbloguser.template 2007-08-03 22:07:19 UTC (rev 5782)
+++ plog/trunk/templates/admin/addbloguser.template 2007-08-03 22:09:34 UTC (rev 5783)
@@ -6,12 +6,12 @@
<label for="userName">{$locale->tr("username")}</label>
<span class="required">*</span>
<div class="formHelp">{$locale->tr("new_blog_username_help")}</div>
- <input type="text" id="newBlogUserName" name="newBlogUserName" value="{$newBlogUserName}" style="width:50%" />
+ <input type="text" id="userName" name="userName" value="{$newBlogUserName}" style="width:50%" />
+ <input type="hidden" id="userId" name="userId" />
{check_perms adminperm=view_users}
<a href="#" onclick="window.open('?op=siteUsersChooser','UserChooser','scrollbars=yes,resizable=yes,toolbar=no,height=450,width=600');">
{$locale->tr("select")}
</a>
- <input type="hidden" id="userId" name="userId" value="" />
{/check_perms}
{include file="$admintemplatepath/validateajax.template" field=newBlogUserName}
</div>
Modified: plog/trunk/templates/admin/blogusers.template
===================================================================
--- plog/trunk/templates/admin/blogusers.template 2007-08-03 22:07:19 UTC (rev 5782)
+++ plog/trunk/templates/admin/blogusers.template 2007-08-03 22:09:34 UTC (rev 5783)
@@ -7,10 +7,9 @@
</div>
<br style="clear:both" />
</div>
-<form id="blogUsers" action="admin.php" method="post">
+<form id="blogUsers" action="admin.php" method="post" onSubmit="Lifetype.Forms.performRequest(this);return(false);">
+{include file="$admintemplatepath/viewvalidateajax.template"}
<div id="list">
- {include file="$admintemplatepath/successmessage.template"}
- {include file="$admintemplatepath/errormessage.template"}
{include file="$admintemplatepath/blogusers_table.template"}
</div>
<div id="list_action_bar">
Modified: plog/trunk/templates/admin/blogusers_table.template
===================================================================
--- plog/trunk/templates/admin/blogusers_table.template 2007-08-03 22:07:19 UTC (rev 5782)
+++ plog/trunk/templates/admin/blogusers_table.template 2007-08-03 22:09:34 UTC (rev 5783)
@@ -30,10 +30,10 @@
<td>
<div class="list_action_button">
{check_perms perm=update_blog_users}
- <a href="?op=editBlogUser&userId={$bloguser->getId()}" title="{$locale->tr("edit")}">
+ <a href="?op=editBlogUser&userId={$bloguser->getId()}" title="{$locale->tr("edit")}" rel="overlay" id="edit_link_{$bloguser->getId()}">
<img src="imgs/admin/icon_edit-16.png" alt="{$locale->tr("edit")}" />
</a>
- <a href="?op=deleteBlogUserPermissions&userId={$bloguser->getId()}" title="{$locale->tr("revoke_permissions")}">
+ <a href="?op=deleteBlogUserPermissions&userId={$bloguser->getId()}" title="{$locale->tr("revoke_permissions")}" onClick="Lifetype.Forms.performRequest(this);return(false);">
<img src="imgs/admin/icon_delete-16.png" alt="{$locale->tr("revoke_permissions")}" />
</a>
{/check_perms}
More information about the pLog-svn
mailing list