[pLog-svn] r6240 - in plog/trunk: class/action/admin templates/admin
mark at devel.lifetype.net
mark at devel.lifetype.net
Sat Mar 15 13:24:27 EDT 2008
Author: mark
Date: 2008-03-15 13:24:27 -0400 (Sat, 15 Mar 2008)
New Revision: 6240
Added:
plog/trunk/templates/admin/editpermission_form.template
Modified:
plog/trunk/class/action/admin/admindeletepermissionsaction.class.php
plog/trunk/class/action/admin/admineditpermissionaction.class.php
plog/trunk/class/action/admin/adminupdateblogcategoryaction.class.php
plog/trunk/class/action/admin/adminupdatepermissionaction.class.php
plog/trunk/templates/admin/editpermission.template
Log:
Ajaxlize permissionList admin panel done.
Modified: plog/trunk/class/action/admin/admindeletepermissionsaction.class.php
===================================================================
--- plog/trunk/class/action/admin/admindeletepermissionsaction.class.php 2008-03-15 11:52:45 UTC (rev 6239)
+++ plog/trunk/class/action/admin/admindeletepermissionsaction.class.php 2008-03-15 17:24:27 UTC (rev 6240)
@@ -45,6 +45,13 @@
*/
function _deletePermissions()
{
+ if( $this->_mode == "deletePermission" ) {
+ $this->_permIds = Array();
+ $this->_permIds[] = $this->_request->getValue( "permId" );
+ }
+ else
+ $this->_permIds = $this->_request->getValue( "permIds" );
+
$perms = new Permissions();
$errorMessage = "";
@@ -85,19 +92,11 @@
}
}
- // prepare the view and all the information it needs to know
- $this->_view = new AdminPermissionsListView( $this->_blogInfo );
- if( $errorMessage != "" )
- $this->_view->setErrorMessage( $errorMessage );
- if( $successMessage != "" ) {
- // and clear the cache to avoid outdated information
- CacheControl::resetBlogCache( $this->_blogInfo->getId(), false );
- $this->_view->setSuccessMessage( $successMessage );
- }
-
- $this->setCommonData();
-
- return true;
+ // and clear the cache to avoid outdated information
+ CacheControl::resetBlogCache( $this->_blogInfo->getId(), false );
+
+ // better to return true if everything fine
+ return( Array( "errorMessage" => $errorMessage, "successMessage" => $successMessage ));
}
/**
@@ -105,14 +104,29 @@
*/
function perform()
{
- if( $this->_mode == "deletePermission" ) {
- $this->_permIds = Array();
- $this->_permIds[] = $this->_request->getValue( "permId" );
- }
- else
- $this->_permIds = $this->_request->getValue( "permIds" );
+ $results = $this->_deletePermissions();
+
+ $this->_view = new AdminPermissionsListView( $this->_blogInfo );
+ if( $results["errorMessage"] != "" ) $this->_view->setErrorMessage( $results["errorMessage"] );
+ if( $results["successMessage"] != "" ) $this->_view->setSuccessMessage( $results["successMessage"] );
+ $this->setCommonData();
- return $this->_deletePermissions();
+ return true;
}
+
+ /**
+ * Ajax-specific behaviour
+ */
+ function performAjax()
+ {
+ $results = $this->_deletePermissions();
+
+ $this->_view = new AdminAjaxView( $this->_blogInfo );
+ $this->_view->setMessage( $results );
+ $this->_view->setSuccess( true );
+
+ // better to return true if everything fine
+ return true;
+ }
}
?>
Modified: plog/trunk/class/action/admin/admineditpermissionaction.class.php
===================================================================
--- plog/trunk/class/action/admin/admineditpermissionaction.class.php 2008-03-15 11:52:45 UTC (rev 6239)
+++ plog/trunk/class/action/admin/admineditpermissionaction.class.php 2008-03-15 17:24:27 UTC (rev 6240)
@@ -34,13 +34,19 @@
$perm = $perms->getPermission( $this->_request->getValue( "permId" ));
if( !$perm ) {
- $this->_view = new AdminPermissionsListView( $this->_blogInfo );
+ if( Request::isXHR())
+ $this->_view = new AdminErrorDialogView( $this->_blogInfo );
+ else
+ $this->_view = new AdminPermissionsListView( $this->_blogInfo );
$this->_view->setErrorMessage( $this->_locale->tr("error_fetching_permission" ));
$this->setCommonData();
return( false );
}
- $this->_view = new AdminTemplatedView( $this->_blogInfo, "editpermission" );
+ if( Request::isXHR())
+ $this->_view = new AdminTemplatedView( $this->_blogInfo, "editpermission_form" );
+ else
+ $this->_view = new AdminTemplatedView( $this->_blogInfo, "editpermission" );
$this->_view->setValue( "permissionName", $perm->getName());
$this->_view->setValue( "permissionDescription", $perm->getDescription());
$this->_view->setValue( "permissionId", $perm->getId());
@@ -50,5 +56,10 @@
return( true );
}
+
+ function performAjax()
+ {
+ return( $this->perform());
+ }
}
?>
Modified: plog/trunk/class/action/admin/adminupdateblogcategoryaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminupdateblogcategoryaction.class.php 2008-03-15 11:52:45 UTC (rev 6239)
+++ plog/trunk/class/action/admin/adminupdateblogcategoryaction.class.php 2008-03-15 17:24:27 UTC (rev 6240)
@@ -33,9 +33,9 @@
$this->AdminAction( $actionInfo, $request );
// data validation settings
- $this->registerFieldValidator( "categoryName", new StringValidator());
$this->registerFieldValidator( "categoryId", new IntegerValidator());
- $this->registerFieldValidator( "categoryDescription", new StringValidator());
+ $this->registerFieldValidator( "categoryName", new StringValidator(), false, $this->_locale->tr("error_empty_name" ) );
+ $this->registerFieldValidator( "categoryDescription", new StringValidator(), false, $this->_locale->tr("error_empty_description" ));
$errorView = new AdminTemplatedView( $this->_blogInfo, "editblogcategory" );
$errorView->setErrorMessage( $this->_locale->tr("error_updating_article_category" ));
$this->setValidationErrorView( $errorView );
Modified: plog/trunk/class/action/admin/adminupdatepermissionaction.class.php
===================================================================
--- plog/trunk/class/action/admin/adminupdatepermissionaction.class.php 2008-03-15 11:52:45 UTC (rev 6239)
+++ plog/trunk/class/action/admin/adminupdatepermissionaction.class.php 2008-03-15 17:24:27 UTC (rev 6240)
@@ -20,8 +20,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->registerFieldValidator( "permissionId", new IntegerValidator());
$this->registerField( "corePermission" );
$this->registerField( "adminOnlyPermission" );
@@ -32,35 +32,69 @@
$this->requireAdminPermission( "update_permission" );
}
-
- function perform()
+
+ function updatePermission()
{
// load the permission
$perms = new Permissions();
- $perm = $perms->getPermission( $this->_request->getValue( "permissionId" ));
+ $this->_perm = $perms->getPermission( $this->_request->getValue( "permissionId" ));
- if( !$perm ) {
- $this->_view = new AdminPermissionsListView( $this->_blogInfo );
- $this->_view->setErrorMessage( $this->_locale->tr("error_fetching_permission" ));
- $this->setCommonData();
- return( false );
+ if( !$this->_perm ) {
+ $this->_message = $this->_locale->tr("error_fetching_permission" );
+ return false;
}
- $perm->setName( $this->_request->getValue( "permissionName" ));
- $perm->setDescription( $this->_request->getValue( "permissionDescription" ));
- $perm->setCorePermission(( $this->_request->getValue( "corePermission" ) == "" ? false : true ));
- $perm->setAdminOnlyPermission(( $this->_request->getValue( "adminOnlyPermission" ) == "" ? false : true ));
+ $this->_perm->setName( $this->_request->getValue( "permissionName" ));
+ $this->_perm->setDescription( $this->_request->getValue( "permissionDescription" ));
+ $this->_perm->setCorePermission(( $this->_request->getValue( "corePermission" ) == "" ? false : true ));
+ $this->_perm->setAdminOnlyPermission(( $this->_request->getValue( "adminOnlyPermission" ) == "" ? false : true ));
- if( $perms->updatePermission( $perm )) {
- $this->_view = new AdminPermissionsListView( $this->_blogInfo );
- $this->_view->setSuccessMessage( $this->_locale->tr("permission_updated_ok" ));
- $this->setCommonData();
+ $result = $perms->updatePermission( $this->_perm );
+
+ if( $result ) {
+ $this->_message = $this->_locale->tr("permission_updated_ok" );
+ return true;
+ } else {
+ $this->_message = $this->_locale->tr("error_updating_permission" );
+ return false;
}
+ }
+
+ /**
+ * Carries out the specified action
+ */
+ function perform()
+ {
+ $this->_view = new AdminPermissionsListView( $this->_blogInfo );
+ $result = $this->updatePermission();
+
+ if( !$result ) {
+ // set an error message
+ $this->_view->setErrorMessage( $this->_message);
+ }
else {
- $this->_view->setErrorMessage( $this->_locale->tr("error_updating_permission" ));
- $this->_view->setError( true );
- $this->setCommonData( true );
- }
+ // or success
+ $this->_view->setSuccessMessage( $this->_message );
+ }
+
+ $this->setCommonData();
+ return true;
}
+
+ /**
+ * Carries out the specified action
+ */
+ function performAjax()
+ {
+ $result = $this->updatePermission();
+
+ $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/templates/admin/editpermission.template
===================================================================
--- plog/trunk/templates/admin/editpermission.template 2008-03-15 11:52:45 UTC (rev 6239)
+++ plog/trunk/templates/admin/editpermission.template 2008-03-15 17:24:27 UTC (rev 6240)
@@ -1,50 +1,7 @@
{include file="$admintemplatepath/header.template"}
{include file="$admintemplatepath/navigation.template" showOpt=permissionsList title=$locale->tr("editPermission")}
- <form name="addBlogCategory" method="post" action="admin.php">
- <fieldset class="inputField">
- <legend>{$locale->tr("editPermission")}</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/editpermission_form.template"}
- <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="updatePermission" />
- <input type="hidden" name="permissionId" value="{$permissionId}" />
- <input type="reset" name="resetButton" value="{$locale->tr("reset")}" />
- <input type="submit" name="Add" value="{$locale->tr("update")}" />
- </div>
- </form>
{include file="$admintemplatepath/footernavigation.template"}
{include file="$admintemplatepath/footer.template"}
\ No newline at end of file
Added: plog/trunk/templates/admin/editpermission_form.template
===================================================================
--- plog/trunk/templates/admin/editpermission_form.template (rev 0)
+++ plog/trunk/templates/admin/editpermission_form.template 2008-03-15 17:24:27 UTC (rev 6240)
@@ -0,0 +1,45 @@
+ <form id="updatePermission" method="post" action="admin.php" onSubmit="Lifetype.UI.Pages.Permissions.updateSubmitHook(this);return(false);">
+ <fieldset class="inputField">
+ <legend>{$locale->tr("editPermission")}</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="updatePermission" />
+ <input type="hidden" name="permissionId" value="{$permissionId}" />
+ <input type="reset" name="resetButton" value="{$locale->tr("reset")}" />
+ <input type="submit" name="Add" value="{$locale->tr("update")}" />
+ </div>
+ </form>
\ No newline at end of file
More information about the pLog-svn
mailing list