summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Kremmel <xing@synapse.plus.com>2007-07-15 19:15:25 +0000
committerMax Kremmel <xing@synapse.plus.com>2007-07-15 19:15:25 +0000
commit7568a7bca748a4b71a6d3469ce0ffc5572794bf0 (patch)
tree08e8aa6d40221b67390d2f4aefb5980baab5c187
parentdf0e2d163d91c8190acf6daf3b6a37d0d74f8f82 (diff)
downloadliberty-7568a7bca748a4b71a6d3469ce0ffc5572794bf0.tar.gz
liberty-7568a7bca748a4b71a6d3469ce0ffc5572794bf0.tar.bz2
liberty-7568a7bca748a4b71a6d3469ce0ffc5572794bf0.zip
ajaxed liberty content permissions
-rw-r--r--content_permissions.php48
-rw-r--r--templates/content_permissions.tpl46
2 files changed, 70 insertions, 24 deletions
diff --git a/content_permissions.php b/content_permissions.php
index b250f46..dad9251 100644
--- a/content_permissions.php
+++ b/content_permissions.php
@@ -1,6 +1,6 @@
<?php
/**
- * @version $Revision: 1.6 $
+ * @version $Revision: 1.7 $
* @package liberty
* @subpackage functions
*/
@@ -70,7 +70,51 @@ if( $contentPerms['assigned'] = $gContent->getContentPermissionsList() ) {
}
}
}
-
$gBitSmarty->assign( 'contentPerms', $contentPerms );
+
+// if we've called this page as part of an ajax update, we output the appropriate data
+if( $gBitThemes->isAjaxRequest() ) {
+ if( count( $contentPerms['groups'] <= 10 )) {
+ $size = 'large/';
+ } else {
+ $size = 'small/';
+ }
+
+ $gid = $_REQUEST['group_id'];
+ $perm = $_REQUEST['perm'];
+
+ // we're applying the same logic as in the template. if you fix / change anything here, please update the template as well.
+ $biticon = array(
+ 'ipackage' => 'icons',
+ 'iname' => $size.'media-playback-stop',
+ 'iexplain' => '',
+ 'iforce' => 'icon',
+ );
+ $action = 'assign';
+ if( !empty( $contentPerms['groups'][$gid]['perms'][$perm] )) {
+ $biticon['iname'] = $size.'dialog-ok';
+ if( !empty( $contentPerms['assigned'][$gid][$perm] )) {
+ $assigned = $contentPerms['assigned'][$gid][$perm];
+ $biticon['iname'] = $size.'list-add';
+ $action = 'remove';
+ }
+ if( !empty( $assigned['is_revoked'] )) {
+ $biticon['iname'] = $size.'list-remove';
+ }
+ }
+
+ require_once $gBitSmarty->_get_plugin_filepath( 'function', 'biticon' );
+ $ret = '<a title="'.$contentPerms['groups'][$gid]['group_name']." :: ".$perm.'" '.
+ 'href="javascript:ajax_updater('.
+ "'{$perm}{$gid}', ".
+ "'".LIBERTY_PKG_URL."content_permissions.php', ".
+ "'action={$action}&amp;content_id={$gContent->mContentId}&amp;perm={$perm}&amp;group_id={$gid}'".
+ ')">'.smarty_function_biticon( $biticon, $gBitSmarty ).'</a>';
+ echo $ret;
+ die;
+}
+
+// enable ajaxed permission updating
+$gBitThemes->loadAjax( 'prototype' );
$gBitSystem->display( 'bitpackage:liberty/content_permissions.tpl', tra( 'Content Permissions' ));
?>
diff --git a/templates/content_permissions.tpl b/templates/content_permissions.tpl
index 58bfa6d..5e34e5a 100644
--- a/templates/content_permissions.tpl
+++ b/templates/content_permissions.tpl
@@ -1,5 +1,4 @@
-{strip}
-
+<script type="text/javascript">/*<![CDATA[*/ show_spinner('spinner'); /*]]>*/</script>
<div class="admin liberty">
<div class="header">
<h1>{tr}Assign permissions{/tr}</h1>
@@ -10,33 +9,29 @@
{if !$contentPerms.assigned}
{formfeedback warning="No Individual permissions set. Global Permissions apply."}
- {else}
+ {/if}
+
+ {if $contentPerms.assigned || $gBitThemes->isJavascriptEnabled()}
{smartlink ititle="Clear all custom content permissions" action=expunge content_id=$gContent->mContentId}
{/if}
- {if count($contentPerms.groups) lt 10}
+ {if count($contentPerms.groups) <= 10}
{assign var=size value="large/"}
{/if}
<table class="data">
<caption>{tr}Permissions set for this content item{/tr}</caption>
- {capture assign=th}
- <tr>
- <th>{tr}Permission{/tr}</th>
- {foreach from=$contentPerms.groups item=group}
- <th onmouseover="showById('f{$group.group_id}');hideById('a{$group.group_id}')">
- <abbr id="a{$group.group_id}" title="{$group.group_name}">{if count($contentPerms.groups) gt 10}{$group.group_name|truncate:4:false}{else}{$group.group_name}{/if}</abbr>
- <span id="f{$group.group_id}" style="display:none">{$group.group_name}</span>
- </th>
- {/foreach}
- </tr>
- {/capture}
- {$th}
+ <tr>
+ <th>{tr}Permission{/tr}</th>
+ {foreach from=$contentPerms.groups item=group}
+ <th onmouseover="showById('f{$group.group_id}');hideById('a{$group.group_id}')">
+ <abbr id="a{$group.group_id}" title="{$group.group_name}">{if count($contentPerms.groups) gt 10}{$group.group_name|truncate:4:false}{else}{$group.group_name}{/if}</abbr>
+ <span id="f{$group.group_id}" style="display:none">{$group.group_name}</span>
+ </th>
+ {/foreach}
+ </tr>
{foreach from=$contentPerms.assignable key=perm item=permInfo name=perms}
- {*
- {if ($smarty.foreach.perms.iteration % 10) eq 0 and ($smarty.foreach.perms.total - $smarty.foreach.perms.iteration) gt 5}{$th}{/if}
- *}
<tr class="{cycle values="odd,even"}">
<td>{$permInfo.perm_desc}<br /><em>({$permInfo.perm_name})</em></td>
{foreach from=$contentPerms.groups key=groupId item=groupInfo}
@@ -52,8 +47,17 @@
{assign var=icon value="list-remove"} {* is_revoked icon *}
{/if}
{/if}
+
<td style="text-align:center">
- {smartlink itra=false ititle="`$contentPerms.groups.$groupId.group_name` :: $perm" ibiticon=icons/$size$icon action=$action content_id=$gContent->mContentId perm=$perm group_id=$groupId}
+ {if $gBitThemes->isJavascriptEnabled()}
+ <span id="{$perm}{$groupId}">
+ <a title="{$contentPerms.groups.$groupId.group_name} :: {$perm}" href="javascript:ajax_updater('{$perm}{$groupId}', '{$smarty.const.LIBERTY_PKG_URL}content_permissions.php', 'action={$action}&amp;content_id={$gContent->mContentId}&amp;perm={$perm}&amp;group_id={$groupId}')">
+ {biticon iname=$size$icon iexplain=""}
+ </a>
+ </span>
+ {else}
+ {smartlink itra=false ititle="`$contentPerms.groups.$groupId.group_name` :: $perm" ibiticon=icons/$size$icon action=$action content_id=$gContent->mContentId perm=$perm group_id=$groupId}
+ {/if}
</td>
{/foreach}
</tr>
@@ -71,5 +75,3 @@
{/if}
</div><!-- end .body -->
</div><!-- end .liberty -->
-
-{/strip}