treasury
[ class tree: treasury ] [ index: treasury ] [ all elements ]

Source for file view_file.php

Documentation is available at view_file.php

  1. <?php
  2. /**
  3.  * @version      $Header$
  4.  *
  5.  * @author       xing  <xing@synapse.plus.com>
  6.  * @package      treasury
  7.  * @copyright    2003-2006 bitweaver
  8.  * @license      LGPL {@link http://www.gnu.org/licenses/lgpl.html}
  9.  ***/
  10.  
  11. /**
  12.  * Setup
  13.  */
  14. require_once( '../kernel/setup_inc.php' );
  15. require_once( LIBERTY_PKG_PATH.'LibertyMime.php' );
  16.  
  17. $feedback = array();
  18.  
  19. // fetch the attachment details
  20. if( @!BitBase::verifyId( $_REQUEST['attachment_id'] ) || !( $attachment = LibertyMime::getAttachment( $_REQUEST['attachment_id'], $_REQUEST ))) {
  21.     $gBitSystem->fatalError( tra( "The Attachment ID given is not valid" ));
  22. }
  23.  
  24. // first we need to check the permissions of the content the attachment belongs to since they inherit them
  25. if( $gContent = LibertyBase::getLibertyObject( $attachment['content_id'] ) ) {
  26.     $gContent->verifyViewPermission();
  27.  
  28.     if( !empty( $_REQUEST['plugin_submit'] )) {
  29.         // now that we have data for a plugin, we'll simply feed it back to the update function of that plugin
  30.         $data = !empty( $_REQUEST['plugin'][$attachment['attachment_id']][$attachment['attachment_plugin_guid']] ) ? $_REQUEST['plugin'][$attachment['attachment_id']][$attachment['attachment_plugin_guid']] : array();
  31.         if( $gContent->updateAttachmentParams( $attachment['attachment_id'], $attachment['attachment_plugin_guid'], $data )) {
  32.             $feedback['success'] = tra( "The data was successfully updated." );
  33.         } else {
  34.             $feedback['error'] = $gContent->mErrors;
  35.         }
  36.         // reload the attachment
  37.         $attachment = LibertyMime::getAttachment( $_REQUEST['attachment_id'] );
  38.     }
  39.  
  40.     // attachment usage filter stuff is hardcoded for now - ugly as hell but we'll survive it as long as there's no demand for more of these.
  41.     if( $gLibertySystem->isPluginActive( 'filterattachment' )) {
  42.         $gBitSmarty->assign( 'usage', attachment_filter_get_usage( $attachment['attachment_id'] ));
  43.     }
  44.  
  45.     if( empty( $_REQUEST['size'] )) {
  46.         $_REQUEST['size'] = 'large';
  47.     }
  48.  
  49.     $attachment['original'] = ( $gContent->isOwner( $attachment ) || $gBitSystem->isFeatureActive( 'liberty_original_image' ));
  50.  
  51.     $gBitSmarty->assign( 'attachment', $attachment );
  52.     $gBitSmarty->assign( 'gContent', $gContent );
  53.     $gBitSmarty->assign( 'feedback', $feedback );
  54.  
  55.     // what template are we going to use to display this attachment
  56.     $gBitSmarty->assign( 'view_template', $gLibertySystem->getMimeTemplate( 'view', $attachment['attachment_plugin_guid'] ));
  57.     $gBitSmarty->assign( 'edit_template', $gLibertySystem->getMimeTemplate( 'edit', $attachment['attachment_plugin_guid'] ));
  58.  
  59.     $gBitSystem->display( 'bitpackage:liberty/mime_view.tpl', tra( "View File" ), array( 'display_mode' => 'display' ));
  60. } else {
  61.     $gBitSystem->fatalError( 'Not Found', NULL, NULL, HttpStatusCodes::HTTP_GONE );
  62. }
  63. ?>

Documentation generated on Wed, 29 Jul 2015 13:57:32 +0000 by phpDocumentor 1.5.0-lsces