summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--edit_storage_inc.php29
-rw-r--r--liberty_lib.php3
-rw-r--r--templates/edit_storage_list.tpl24
3 files changed, 42 insertions, 14 deletions
diff --git a/edit_storage_inc.php b/edit_storage_inc.php
index 3528e42..648e80e 100644
--- a/edit_storage_inc.php
+++ b/edit_storage_inc.php
@@ -3,7 +3,7 @@
* edit_storage_inc
*
* @author spider <spider@steelsun.com>
- * @version $Revision: 1.19 $
+ * @version $Revision: 1.20 $
* @package liberty
* @subpackage functions
*
@@ -12,11 +12,21 @@
*
* Calculate a base URL for the attachment deletion/removal icons to use
*/
+include_once( '../bit_setup_inc.php' );
global $gBitSmarty, $gContent, $gBitUser, $gBitSystem, $gLibertySystem, $gBitThemes;
-$attachmentActionBaseUrl = $gBitSmarty->get_template_vars( 'attachmentActionBaseURL' );
+// we need to load gContent if this is an ajax request
+if( BitThemes::isAjaxRequest() ) {
+ include_once( LIBERTY_PKG_PATH.'lookup_content_inc.php' );
+}
+
+$attachmentActionBaseUrl = $gBitSmarty->get_template_vars( 'attachmentActionBaseUrl' );
if( empty( $attachmentActionBaseUrl )) {
- $attachmentActionBaseURL = $_SERVER['PHP_SELF'].'?';
+ if( $gBitSystem->getConfig( 'liberty_attachment_style' ) == 'ajax' ) {
+ $attachmentActionBaseUrl = LIBERTY_PKG_URL.'edit_storage_inc.php?';
+ } else {
+ $attachmentActionBaseUrl = $_SERVER['PHP_SELF'].'?';
+ }
$GETArgs = split( '&',$_SERVER['QUERY_STRING'] );
$firstArg = TRUE;
@@ -24,22 +34,21 @@ if( empty( $attachmentActionBaseUrl )) {
$parts = split( '=', $arg );
if( $parts[0] != 'deleteAttachment' ) {
if( !$firstArg ) {
- $attachmentActionBaseURL .= "&amp;";
+ $attachmentActionBaseUrl .= "&amp;";
} else {
$firstArg = FALSE;
}
- $attachmentActionBaseURL .= $arg;
+ $attachmentActionBaseUrl .= $arg;
}
}
- $gBitSmarty->assign( 'attachmentActionBaseURL', $attachmentActionBaseURL );
+ $gBitSmarty->assign( 'attachmentActionBaseUrl', $attachmentActionBaseUrl );
}
if( !empty( $_REQUEST['deleteAttachment'] )) {
$attachmentId = $_REQUEST['deleteAttachment'];
$attachmentInfo = $gContent->getAttachment( $attachmentId );
- // TODO: Should we have a permission for deleting attachments?
if( $gBitUser->isAdmin() || ( $attachmentInfo['user_id'] == $gBitUser->mUserId && $gBitUser->hasPermission( 'p_liberty_delete_attachment' ))) {
$gContent->expungeAttachment( $attachmentId );
}
@@ -51,4 +60,10 @@ $gBitSmarty->assign_by_ref( 'gLibertySystem', $gLibertySystem );
$gBitSmarty->clear_assign( 'gContent' );
$gBitSmarty->assign( 'gContent', $gContent );
$gBitThemes->loadAjax( 'prototype' );
+
+// output some stuff for ajax div
+if( BitThemes::isAjaxRequest() ) {
+ echo $gBitSmarty->fetch( 'bitpackage:liberty/edit_storage_list.tpl' );
+ die;
+}
?>
diff --git a/liberty_lib.php b/liberty_lib.php
index df81b48..09fe3e3 100644
--- a/liberty_lib.php
+++ b/liberty_lib.php
@@ -1,6 +1,6 @@
<?php
/**
- * @version $Header: /cvsroot/bitweaver/_bit_liberty/liberty_lib.php,v 1.13 2007/09/26 16:22:52 nickpalmer Exp $
+ * @version $Header: /cvsroot/bitweaver/_bit_liberty/liberty_lib.php,v 1.14 2007/10/03 09:34:44 squareing Exp $
* @package liberty
* @subpackage functions
*/
@@ -399,6 +399,7 @@ function liberty_content_display( &$pObject, &$pParamHash ) {
*/
function liberty_content_edit( &$pObject ) {
include_once( LIBERTY_PKG_PATH.'edit_help_inc.php' );
+ include_once( LIBERTY_PKG_PATH."edit_storage_inc.php" );
}
diff --git a/templates/edit_storage_list.tpl b/templates/edit_storage_list.tpl
index 9ea5b5f..12b32d4 100644
--- a/templates/edit_storage_list.tpl
+++ b/templates/edit_storage_list.tpl
@@ -1,6 +1,8 @@
-{php} include (LIBERTY_PKG_PATH."edit_storage_inc.php"); {/php}
{strip}
-<div id="edit_storage_list{if !$uploadTab}_tab{/if}">
+{* don't replicate the surrounding div when inserting ajax content *}
+{if !$gBitThemes->isAjaxRequest()}
+ <div id="edit_storage_list{if !$uploadTab}_tab{/if}">
+{/if}
{if $gContent->mStorage}
<div class="row">
<table class="data" summary="List of attached files">
@@ -38,11 +40,19 @@
{/if}
{if $gBitUser->isAdmin() || ($storage.user_id == $gBitUser->mUserId && $gBitUser->hasPermission('p_liberty_delete_attachments') ) }
{if $attachmentBrowser}
- <a href="javascript:ajax_updater('attbrowser', '{$attachmentActionBaseURL}', 'deleteAttachment={$attachmentId}');">{biticon ipackage="icons" iname="edit-delete" iexplain="delete"}</a>
+ <a href="javascript:
+ ajax_updater('edit_storage_list', '{$attachmentActionBaseUrl}', 'deleteAttachment={$attachmentId}');
+ ajax_updater('edit_storage_list_tab', '{$attachmentActionBaseUrl}', 'content_id={$gContent->mContentId}');">
+ {biticon ipackage="icons" iname="edit-delete" iexplain="delete"}
+ </a>
{elseif $libertyUploader || $gBitSystem->getConfig('liberty_attachment_style') == 'ajax'}
- <a href="javascript:ajax_updater('edit_storage_list', '{$attachmentActionBaseURL}', 'deleteAttachment={$attachmentId}{if empty($gContent->mContentId)}{foreach from=$gContent->mStorage key=key item=val}&STORAGE[existing][{$val.attachment_id}]={$val.attachment_id}{/foreach}{/if}');">{biticon ipackage="icons" iname="edit-delete" iexplain="delete"}</a>
+ <a href="javascript:
+ ajax_updater('edit_storage_list', '{$attachmentActionBaseUrl}', 'content_id={$gContent->mContentId}&amp;deleteAttachment={$attachmentId}{if empty($gContent->mContentId)}{foreach from=$gContent->mStorage key=key item=val}&amp;STORAGE[existing][{$val.attachment_id}]={$val.attachment_id}{/foreach}{/if}');
+ ajax_updater('edit_storage_list_tab', '{$attachmentActionBaseUrl}', 'content_id={$gContent->mContentId}');">
+ {biticon ipackage="icons" iname="edit-delete" iexplain="delete"}
+ </a>
{else}
- <a href="{$attachmentActionBaseURL}&amp;deleteAttachment={$attachmentId}">{biticon ipackage="icons" iname="edit-delete" iexplain="delete"}</a>
+ <a href="{$attachmentActionBaseUrl}&amp;deleteAttachment={$attachmentId}">{biticon ipackage="icons" iname="edit-delete" iexplain="delete"}</a>
{/if}
{/if}
</td>
@@ -51,5 +61,7 @@
</table>
</div>
{/if}
-</div>
+{if !$gBitThemes->isAjaxRequest()}
+ </div>
+{/if}
{/strip}