[pLog-svn] r6238 - in plog/trunk: class/action/admin class/view/admin js/ui/pages templates/admin
mark at devel.lifetype.net
mark at devel.lifetype.net
Sat Mar 15 07:50:33 EDT 2008
Author: mark
Date: 2008-03-15 07:50:33 -0400 (Sat, 15 Mar 2008)
New Revision: 6238
Added:
plog/trunk/js/ui/pages/permissions.js
plog/trunk/templates/admin/newpermission_form.template
plog/trunk/templates/admin/permissions_table.template
Modified:
plog/trunk/class/action/admin/adminaddpermissionaction.class.php
plog/trunk/class/action/admin/adminnewpermissionaction.class.php
plog/trunk/class/action/admin/adminpermissionslistaction.class.php
plog/trunk/class/view/admin/adminpermissionslistview.class.php
plog/trunk/templates/admin/newpermission.template
plog/trunk/templates/admin/permissions.template
Log:
Ajaxlize permissionList admin panel.
Edit/Update & Delete still under development.
Modified: plog/trunk/class/action/admin/adminaddpermissionaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminaddpermissionaction.class.php 2008-03-15 11:07:27 UTC (rev 6237)
+++ plog/trunk/class/action/admin/adminaddpermissionaction.class.php 2008-03-15 11:50:33 UTC (rev 6238)
@@ -19,8 +19,8 @@
$this->AdminAction( $actionInfo, $request );
// register two validators
- $this->registerFieldValidator( "permissionName", new StringValidator());
- $this->registerFieldValidator( "permissionDescription", new StringValidator());
+ $this->registerFieldValidator( "permissionName", new StringValidator(), false, $this->_locale->tr("error_empty_name" ) );
+ $this->registerFieldValidator( "permissionDescription", new StringValidator(), false, $this->_locale->tr("error_empty_description" ) );
$this->registerField( "corePermission" );
$this->registerField( "adminOnlyPermission" );
// and the view we should show in case there is a validation error
@@ -30,35 +30,73 @@
$this->requireAdminPermission( "add_permission" );
}
-
- function perform()
+
+ function addPermission()
{
// add the permission and check success
- $perm = new Permission(
+ $this->_perm = new Permission(
$this->_request->getValue( "permissionName"),
$this->_request->getValue( "permissionDescription" )
);
if( $this->_request->getValue( "corePermission" ) == 1 )
- $perm->setCorePermission( true );
+ $this->_perm->setCorePermission( true );
if( $this->_request->getValue( "adminOnlyPermission" ) == 1 )
- $perm->setAdminOnlyPermission( true );
+ $this->_perm->setAdminOnlyPermission( true );
$perms = new Permissions();
- $this->notifyEvent( EVENT_PRE_ADD_PERMISSION, Array( "permission" => &$perm ));
- if( $perms->addPermission( $perm )) {
- $this->notifyEvent( EVENT_POST_ADD_PERMISSION, Array( "permission" => &$perm ));
- if( $this->_userInfo->hasPermissionByName( "view_permissions", 0 ))
- $this->_view = new AdminPermissionsListView( $this->_blogInfo );
- else
- $this->_view = new AdminTemplatedView( $this->_blogInfo, "newpermission" );
- $this->_view->setSuccessMessage( $this->_locale->tr("permission_added_ok" ));
- $this->setCommonData();
+ $this->notifyEvent( EVENT_PRE_ADD_PERMISSION, Array( "permission" => &$this->_perm ));
+ $result = $perms->addPermission( $this->_perm );
+ if( $result ) {
+ $this->notifyEvent( EVENT_POST_ADD_PERMISSION, Array( "permission" => &$this->_perm ));
+ $this->_message = $this->_locale->tr("permission_added_ok" );
}
else {
- $this->_view->setErrorMessage( $this->_locale->tr("error_adding_permission" ));
- $this->_view->setError( true );
- $this->setCommonData( true );
+ $this->_message = $this->_locale->tr("error_adding_permission" );
}
+
+ return $result;
}
+
+ /**
+ * Carries out the specified action
+ */
+ function perform()
+ {
+ if( $this->_userInfo->hasPermissionByName( "view_permissions", 0 ))
+ $this->_view = new AdminPermissionsListView( $this->_blogInfo );
+ else
+ $this->_view = new AdminTemplatedView( $this->_blogInfo, "newpermission" );
+
+ $result = $this->addPermission();
+
+ if( !$result ) {
+ // set an error message
+ $this->_view->setErrorMessage( $this->_message);
+ }
+ else {
+ // or success
+ $this->_view->setSuccessMessage( $this->_message );
+ }
+
+ $this->setCommonData();
+
+ return true;
+ }
+
+ /**
+ * Carries out the specified action
+ */
+ function performAjax()
+ {
+ $result = $this->addPermission();
+
+ $this->_view = new AdminAjaxView( $this->_blogInfo );
+
+ $this->_view->setSuccess( $result );
+ $this->_view->setMessage( $this->_message );
+ $this->_view->setResult( $this->_perm );
+
+ return( true );
+ }
}
?>
Modified: plog/trunk/class/action/admin/adminnewpermissionaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminnewpermissionaction.class.php 2008-03-15 11:07:27 UTC (rev 6237)
+++ plog/trunk/class/action/admin/adminnewpermissionaction.class.php 2008-03-15 11:50:33 UTC (rev 6238)
@@ -20,7 +20,12 @@
function perform()
{
- $this->_view = new AdminTemplatedView( $this->_blogInfo, "newpermission" );
+ // initialize the view
+ if( Request::isXHR() )
+ $this->_view = new AdminTemplatedView( $this->_blogInfo, "newpermission_form" );
+ else
+ $this->_view = new AdminTemplatedView( $this->_blogInfo, "newpermission" );
+
$this->setCommonData();
}
Modified: plog/trunk/class/action/admin/adminpermissionslistaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminpermissionslistaction.class.php 2008-03-15 11:07:27 UTC (rev 6237)
+++ plog/trunk/class/action/admin/adminpermissionslistaction.class.php 2008-03-15 11:50:33 UTC (rev 6238)
@@ -24,5 +24,10 @@
$this->_view = new AdminPermissionsListView( $this->_blogInfo );
$this->setCommonData();
}
+
+ function performAjax()
+ {
+ return( $this->perform() );
+ }
}
?>
Modified: plog/trunk/class/view/admin/adminpermissionslistview.class.php
===================================================================
--- plog/trunk/class/view/admin/adminpermissionslistview.class.php 2008-03-15 11:07:27 UTC (rev 6237)
+++ plog/trunk/class/view/admin/adminpermissionslistview.class.php 2008-03-15 11:50:33 UTC (rev 6238)
@@ -12,7 +12,12 @@
function AdminPermissionsListView( $blogInfo, $params = Array())
{
- $this->AdminTemplatedView( $blogInfo, "permissions" );
+ if( Request::isXHR())
+ $template = "permissions_table";
+ else
+ $template = "permissions";
+
+ $this->AdminTemplatedView( $blogInfo, $template );
}
/**
Added: plog/trunk/js/ui/pages/permissions.js
===================================================================
--- plog/trunk/js/ui/pages/permissions.js (rev 0)
+++ plog/trunk/js/ui/pages/permissions.js 2008-03-15 11:50:33 UTC (rev 6238)
@@ -0,0 +1,21 @@
+Lifetype.UI.Pages.Permissions = function() {}
+
+Lifetype.UI.Pages.Permissions.addSubmitHook = function( form )
+{
+ Lifetype.Forms.AjaxFormProcessor( form.id,'?output=json', {resetAfterSuccess:true} );
+}
+
+Lifetype.UI.Pages.Permissions.updateSubmitHook = function( form )
+{
+ Lifetype.Forms.AjaxFormProcessor( form.id,'?output=json' );
+}
+
+YAHOO.util.Event.addListener( window, "load", function() {
+ var t = new Lifetype.Effects.Table( "list" );
+ 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=permissionsList' ) } );
+ Lifetype.Forms.Events.formProcessorSuccessEvent.subscribe( function() { Lifetype.UI.DataTable.reload( '?op=permissionsList' ) } );
+});
\ No newline at end of file
Modified: plog/trunk/templates/admin/newpermission.template
===================================================================
--- plog/trunk/templates/admin/newpermission.template 2008-03-15 11:07:27 UTC (rev 6237)
+++ plog/trunk/templates/admin/newpermission.template 2008-03-15 11:50:33 UTC (rev 6238)
@@ -1,44 +1,7 @@
- <form name="addBlogCategory" method="post" action="admin.php">
- <fieldset class="inputField">
- <legend>{$locale->tr("newPermission")}</legend>
- {include file="$admintemplatepath/formvalidate.template"}
-
- <div class="field">
- <label for="permissionName">{$locale->tr("name")}</label>
- <span class="required">*</span>
- <div class="formHelp">{$locale->tr("permission_name_help")}</div>
- <input type="text" value="{$permissionName}" id="permissionName" name="permissionName" />
- {include file="$admintemplatepath/validate.template" field=permissionName message=$locale->tr("error_empty_name")}
- </div>
-
- <div class="field">
- <label for="permissionDescription">{$locale->tr("description")}</label>
- <span class="required">*</span>
- <div class="formHelp">{$locale->tr("permission_description_help")}</div>
- <textarea name="permissionDescription" cols="60" id="permissionDescription" rows="5">{$permissionDescription}</textarea>
- {include file="$admintemplatepath/validate.template" field=permissionDescription message=$locale->tr("error_empty_description")}
- </div>
+{include file="$admintemplatepath/header.template"}
+{include file="$admintemplatepath/navigation.template" showOpt=permissionsList title=$locale->tr("newPermission")}
- <div class="field">
- <label for="corePermission">{$locale->tr("core_perm")}</label>
- <div class="formHelp">
- <input class="checkbox" type="checkbox" id="corePermission" name="corePermission" value="1" {if $corePermission}checked="checked"{/if}/>
- {$locale->tr("core_perm_help")}
- </div>
- </div>
-
- <div class="field">
- <label for="adminOnlyPermission">{$locale->tr("admin_only")}</label>
- <div class="formHelp">
- <input class="checkbox" type="checkbox" id="adminOnlyPermission" name="adminOnlyPermission" value="1" {if $adminOnlyPermission}checked="checked"{/if} />
- {$locale->tr("admin_only_help")}
- </div>
- </div>
+{include file="$admintemplatepath/newpermission_form.template"}
- </fieldset>
- <div class="buttons">
- <input type="hidden" name="op" value="addPermission" />
- <input type="reset" name="resetButton" value="{$locale->tr("reset")}" />
- <input type="submit" name="Add" value="{$locale->tr("add")}" />
- </div>
- </form>
\ No newline at end of file
+{include file="$admintemplatepath/footernavigation.template"}
+{include file="$admintemplatepath/footer.template"}
\ No newline at end of file
Added: plog/trunk/templates/admin/newpermission_form.template
===================================================================
--- plog/trunk/templates/admin/newpermission_form.template (rev 0)
+++ plog/trunk/templates/admin/newpermission_form.template 2008-03-15 11:50:33 UTC (rev 6238)
@@ -0,0 +1,44 @@
+ <form id="addPermission" method="post" action="admin.php" onSubmit="Lifetype.UI.Pages.Permissions.addSubmitHook(this);return(false);">
+ <fieldset class="inputField">
+ <legend>{$locale->tr("newPermission")}</legend>
+ {include file="$admintemplatepath/formvalidateajax.template"}
+
+ <div class="field">
+ <label for="permissionName">{$locale->tr("name")}</label>
+ <span class="required">*</span>
+ <div class="formHelp">{$locale->tr("permission_name_help")}</div>
+ <input type="text" value="{$permissionName}" id="permissionName" name="permissionName" />
+ {include file="$admintemplatepath/validateajax.template" field=permissionName}
+ </div>
+
+ <div class="field">
+ <label for="permissionDescription">{$locale->tr("description")}</label>
+ <span class="required">*</span>
+ <div class="formHelp">{$locale->tr("permission_description_help")}</div>
+ <textarea name="permissionDescription" cols="60" id="permissionDescription" rows="5">{$permissionDescription}</textarea>
+ {include file="$admintemplatepath/validateajax.template" field=permissionDescription}
+ </div>
+
+ <div class="field">
+ <label for="corePermission">{$locale->tr("core_perm")}</label>
+ <div class="formHelp">
+ <input class="checkbox" type="checkbox" id="corePermission" name="corePermission" value="1" {if $corePermission}checked="checked"{/if}/>
+ {$locale->tr("core_perm_help")}
+ </div>
+ </div>
+
+ <div class="field">
+ <label for="adminOnlyPermission">{$locale->tr("admin_only")}</label>
+ <div class="formHelp">
+ <input class="checkbox" type="checkbox" id="adminOnlyPermission" name="adminOnlyPermission" value="1" {if $adminOnlyPermission}checked="checked"{/if} />
+ {$locale->tr("admin_only_help")}
+ </div>
+ </div>
+
+ </fieldset>
+ <div class="buttons">
+ <input type="hidden" name="op" value="addPermission" />
+ <input type="reset" name="resetButton" value="{$locale->tr("reset")}" />
+ <input type="submit" name="Add" value="{$locale->tr("add")}" />
+ </div>
+ </form>
\ No newline at end of file
Modified: plog/trunk/templates/admin/permissions.template
===================================================================
--- plog/trunk/templates/admin/permissions.template 2008-03-15 11:07:27 UTC (rev 6237)
+++ plog/trunk/templates/admin/permissions.template 2008-03-15 11:50:33 UTC (rev 6238)
@@ -1,5 +1,6 @@
{include file="$admintemplatepath/header.template"}
{include file="$admintemplatepath/navigation.template" showOpt=permissionsList title=$locale->tr("permissionsList")}
+{js src="js/ui/pages/permissions.js"}
{check_perms adminperm=add_permission}
<div class="extraFunctions">
<div class="left">
@@ -8,61 +9,10 @@
</div>
<br style="clear:both" />
{/check_perms}
-<form id="deletePermissions" action="admin.php" method="post">
+<form id="editPermissions" 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"}
- <table id="list" class="info" summary="{$locale->tr("permissionsList")}">
- <thead>
- <tr>
- <th><input class="checkbox" type="checkbox" name="all" id="all" value="1" onclick="Lifetype.Forms.toggleAllChecks('deletePermissions');" /></th>
- <th style="width:30%;">{$locale->tr("name")}</th>
- <th style="width:50%;">{$locale->tr("description")}</th>
- <th style="width:5%">{$locale->tr("core_perm")}</th>
- <th style="width:5%">{$locale->tr("admin_only")}</th>
- <th style="width:10%;">{$locale->tr("actions")}</th>
- </tr>
- </thead>
- <tbody>
- {foreach from=$perms item=perm}
- <tr class="{cycle values="odd, even"}">
- <td>
- {if !$perm->isCorePermission()}
- <input class="checkbox" type="checkbox" name="permIds[{counter}]" id="checks_{$perm->getId()}" value="{$perm->getId()}" />
- {/if}
- </td>
- <td class="col_highlighted">
- <a href="admin.php?op=editPermission&permId={$perm->getId()}">{$perm->getName()}</a>
- </td>
- <td>
- {$locale->tr($perm->getDescription())}
- </td>
- <td>
- {if $perm->isCorePermission()}{$locale->tr("yes")}{else}{$locale->tr("no")}{/if}
- </td>
- <td>
- {if $perm->isAdminOnlyPermission()}{$locale->tr("yes")}{else}{$locale->tr("no")}{/if}
- </td>
- <td>
- <div class="list_action_button">
- {check_perms adminperm=update_permission}
- {if !$perm->isCorePermission()}
- <a href="?op=editPermission&permId={$perm->getId()}" title="{$locale->tr("edit")}">
- <img src="imgs/admin/icon_edit-16.png" alt="{$locale->tr("edit")}" />
- </a>
- {/if}
- {if !$perm->isCorePermission()}
- <a href="?op=deletePermission&permId={$perm->getId()}" title="{$locale->tr("delete")}">
- <img src="imgs/admin/icon_delete-16.png" alt="{$locale->tr("delete")}" />
- </a>
- {/if}
- {/check_perms}
- </div>
- </td>
- </tr>
- {/foreach}
- </tbody>
- </table>
+ {include file="$admintemplatepath/permissions_table.template"}
</div>
<div id="list_action_bar">
{check_perms adminperm=update_permission}
Added: plog/trunk/templates/admin/permissions_table.template
===================================================================
--- plog/trunk/templates/admin/permissions_table.template (rev 0)
+++ plog/trunk/templates/admin/permissions_table.template 2008-03-15 11:50:33 UTC (rev 6238)
@@ -0,0 +1,51 @@
+ <table id="permissions" class="info" summary="{$locale->tr("permissionsList")}">
+ <thead>
+ <tr>
+ <th><input class="checkbox" type="checkbox" name="all" id="all" value="1" onclick="Lifetype.Forms.toggleAllChecks('editPermissions');" /></th>
+ <th style="width:30%;">{$locale->tr("name")}</th>
+ <th style="width:50%;">{$locale->tr("description")}</th>
+ <th style="width:5%">{$locale->tr("core_perm")}</th>
+ <th style="width:5%">{$locale->tr("admin_only")}</th>
+ <th style="width:10%;">{$locale->tr("actions")}</th>
+ </tr>
+ </thead>
+ <tbody>
+ {foreach from=$perms item=perm}
+ <tr class="{cycle values="odd, even"}">
+ <td>
+ {if !$perm->isCorePermission()}
+ <input class="checkbox" type="checkbox" name="permIds[{counter}]" id="checks_{$perm->getId()}" value="{$perm->getId()}" />
+ {/if}
+ </td>
+ <td class="col_highlighted">
+ <a href="admin.php?op=editPermission&permId={$perm->getId()}" rel="overlay">{$perm->getName()}</a>
+ </td>
+ <td>
+ {$locale->tr($perm->getDescription())}
+ </td>
+ <td>
+ {if $perm->isCorePermission()}{$locale->tr("yes")}{else}{$locale->tr("no")}{/if}
+ </td>
+ <td>
+ {if $perm->isAdminOnlyPermission()}{$locale->tr("yes")}{else}{$locale->tr("no")}{/if}
+ </td>
+ <td>
+ <div class="list_action_button">
+ {check_perms adminperm=update_permission}
+ {if !$perm->isCorePermission()}
+ <a rel="overlay" href="?op=editPermission&permId={$perm->getId()}" title="{$locale->tr("edit")}">
+ <img src="imgs/admin/icon_edit-16.png" alt="{$locale->tr("edit")}" />
+ </a>
+ {/if}
+ {if !$perm->isCorePermission()}
+ <a href="?op=deletePermission&permId={$perm->getId()}" title="{$locale->tr("delete")}" onClick="Lifetype.Forms.performRequest(this);return(false)">
+ <img src="imgs/admin/icon_delete-16.png" alt="{$locale->tr("delete")}" />
+ </a>
+ {/if}
+ {/check_perms}
+ </div>
+ </td>
+ </tr>
+ {/foreach}
+ </tbody>
+ </table>
\ No newline at end of file
More information about the pLog-svn
mailing list