diff options
| -rw-r--r-- | edit_storage_inc.php | 77 | ||||
| -rw-r--r-- | templates/edit_storage_list.tpl | 12 |
2 files changed, 45 insertions, 44 deletions
diff --git a/edit_storage_inc.php b/edit_storage_inc.php index fac3166..bf7d359 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.24 $ + * @version $Revision: 1.25 $ * @package liberty * @subpackage functions * @@ -20,39 +20,33 @@ if( BitThemes::isAjaxRequest() ) { include_once( LIBERTY_PKG_PATH.'lookup_content_inc.php' ); } -$attachmentActionBaseUrl = $gBitSmarty->get_template_vars( 'attachmentActionBaseUrl' ); - -if( empty( $attachmentActionBaseUrl )) { - 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; - - foreach( $GETArgs as $arg ) { - $parts = split( '=', $arg ); - if( $parts[0] != 'deleteAttachment' ) { - if( !$firstArg ) { - $attachmentActionBaseUrl .= "&"; - } else { - $firstArg = FALSE; - } +// set up base URL +if( $gBitSystem->getConfig( 'liberty_attachment_style' ) == 'ajax' ) { + $attachmentBaseUrl = LIBERTY_PKG_URL.'edit_storage_inc.php'; +} else { + $attachmentBaseUrl = $_SERVER['PHP_SELF']; +} +$gBitSmarty->assign( 'attachmentBaseUrl', $attachmentBaseUrl ); - $attachmentActionBaseUrl .= $arg; - } +// set up base arguments +$getArgs = split( '&', $_SERVER['QUERY_STRING'] ); +$attachmentBaseArgs = ''; +foreach( $getArgs as $arg ) { + $parts = split( '=', $arg ); + if( $parts[0] != 'deleteAttachment' ) { + $attachmentBaseArgs .= $arg."&"; } - $gBitSmarty->assign( 'attachmentActionBaseUrl', $attachmentActionBaseUrl ); } +$gBitSmarty->assign( 'attachmentBaseArgs', $attachmentBaseArgs ); +// delete attachment if requested if( !empty( $_REQUEST['deleteAttachment'] )) { $attachmentId = $_REQUEST['deleteAttachment']; $attachmentInfo = $gContent->getAttachment( $attachmentId ); // the second part of this check seems odd (never used?) to me, but I'll leave it in for now - spiderr 10/17/2007 - if( $gContent->hasAdminPermission() || ( $attachmentInfo['user_id'] == $gBitUser->mUserId && $gBitUser->hasPermission( 'p_liberty_delete_attachment' ))) { - $gContent->expungeAttachment( $attachmentId ); + if( $gContent->hasAdminPermission() || ( $gContent->isOwner( $attachmentInfo ) && $gBitUser->hasPermission( 'p_liberty_delete_attachment' ))) { + //$gContent->expungeAttachment( $attachmentId ); } // in case we have deleted attachments @@ -66,22 +60,29 @@ if( $gBitSystem->getConfig('liberty_attachment_style') == 'ajax' ) { $gBitSmarty->assign( 'attachments_ajax', TRUE ); } -// output some stuff for ajax div +// output some stuff for ajax div if requested /* This in general is no good here. * it creates problems for packages loading up entire editing forms using ajax. * If there is some need to display the list tpl, then it should probably - * happen in an another tpl or via another php file - presumably the one - * which is including this file. This is a bad shortcut. - * I'm commenting it out for now, as I've not been able to find a part of bw - * that needs it. If this causes something of yours to break come get me so we - * can sort it out. -wjames5 + * happen in an another tpl or via another php file - presumably the one which + * is including this file. This is a bad shortcut. I'm commenting it out for + * now, as I've not been able to find a part of bw that needs it. If this + * causes something of yours to break come get me so we can sort it out. + * -wjames5 + * + * + * Since this is called as a service, it has to happen automagically - this is + * the reason why we check for isAjaxRequest and don't really have an option to + * check for anything else. + * + * If you are calling this page via an XMLHttpRequest and don't want to display + * the content, are you using a specific format header like 'xml' or + * 'center_only'? any other distinguishing features? perhaps we could use a + * $_REQUEST parameter like $_REQUEST['no_attachment_content'] + * - xing - Wednesday Oct 31, 2007 10:43:17 CET */ -/* -if( BitThemes::isAjaxRequest() ) { - echo $gBitSmarty->fetch( 'bitpackage:liberty/edit_storage_list.tpl' ); - // this die is no good here for ajax requests which this file is just a part of - // really should consider using display with a center_only header format instead of fetch - // die; +if( BitThemes::isAjaxRequest() && $gBitSystem->mFormatHeader != 'xml' ) { + $gBitSystem->setFormatHeader( 'center_only' ); + $gBitSystem->display( 'bitpackage:liberty/edit_storage_list.tpl' ); } -*/ ?> diff --git a/templates/edit_storage_list.tpl b/templates/edit_storage_list.tpl index bbf8a6b..bf50b61 100644 --- a/templates/edit_storage_list.tpl +++ b/templates/edit_storage_list.tpl @@ -35,24 +35,24 @@ <td class="actionicon"> {if $uploadTab} {* these radio buttons can not be displayed twice in the same form due to interference in $_REQUEST *} - {tr}{$primary_label|default:"Primary"}{/tr}: <input type="radio" name="liberty_attachments[primary]" value="{$attachmentId}"{if $storage.is_primary eq 'y'} checked="checked"{/if}/> + <label>{tr}{$primary_label|default:"Primary"}{/tr}: <input type="radio" name="liberty_attachments[primary]" value="{$attachmentId}"{if $storage.is_primary eq 'y'} checked="checked"{/if} /></label> <br /> {/if} {if $gBitUser->isAdmin() || ($storage.user_id == $gBitUser->mUserId && $gBitUser->hasPermission('p_liberty_delete_attachments') ) } {if $attachmentBrowser} <a href="javascript: - BitAjax.updater('edit_storage_list', '{$attachmentActionBaseUrl}', 'deleteAttachment={$attachmentId}'); - BitAjax.updater('edit_storage_list_tab', '{$attachmentActionBaseUrl}', 'content_id={$gContent->mContentId}');"> + BitAjax.updater('edit_storage_list', '{$attachmentBaseUrl}', 'deleteAttachment={$attachmentId}'); + BitAjax.updater('edit_storage_list_tab', '{$attachmentBaseUrl}', 'content_id={$gContent->mContentId}');"> {biticon ipackage="icons" iname="edit-delete" iexplain="delete"} </a> {elseif $libertyUploader || $gBitSystem->getConfig('liberty_attachment_style') == 'ajax'} <a href="javascript: - BitAjax.updater('edit_storage_list', '{$attachmentActionBaseUrl}', 'content_id={$gContent->mContentId}&deleteAttachment={$attachmentId}{if empty($gContent->mContentId)}{foreach from=$gContent->mStorage key=key item=val}&STORAGE[existing][{$val.attachment_id}]={$val.attachment_id}{/foreach}{/if}'); - BitAjax.updater('edit_storage_list_tab', '{$attachmentActionBaseUrl}', 'content_id={$gContent->mContentId}{if empty($gContent->mContentId)}{foreach from=$gContent->mStorage key=key item=val}&STORAGE[existing][{$val.attachment_id}]={$val.attachment_id}{/foreach}{/if}');"> + BitAjax.updater('edit_storage_list', '{$attachmentBaseUrl}', '{$attachmentBaseArgs}content_id={$gContent->mContentId}&deleteAttachment={$attachmentId}{if empty($gContent->mContentId)}{foreach from=$gContent->mStorage key=key item=val}&STORAGE[existing][{$val.attachment_id}]={$val.attachment_id}{/foreach}{/if}'); + BitAjax.updater('edit_storage_list_tab', '{$attachmentBaseUrl}', '{$attachmentBaseArgs}content_id={$gContent->mContentId}{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> {else} - <a href="{$attachmentActionBaseUrl}&deleteAttachment={$attachmentId}">{biticon ipackage="icons" iname="edit-delete" iexplain="delete"}</a> + <a href="{$attachmentBaseUrl}&deleteAttachment={$attachmentId}">{biticon ipackage="icons" iname="edit-delete" iexplain="delete"}</a> {/if} {/if} </td> |
