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

Source for file download_file.php

Documentation is available at download_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_onceLIBERTY_PKG_PATH.'LibertyMime.php' );
  16.  
  17. // fetch the attachment details
  18. if@!BitBase::verifyId$_REQUEST['attachment_id'|| !$attachment LibertyMime::loadAttachment$_REQUEST['attachment_id']$_REQUEST ))) {
  19.     $gBitSystem->fatalErrortra"The Attachment ID given is not valid" ));
  20. }
  21.  
  22. $gBitSmarty->assign'attachment'$attachment );
  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.     $gBitSmarty->assign'gContent'$gContent );
  28.  
  29.     if$download_function $gLibertySystem->getPluginFunction$attachment['attachment_plugin_guid']'download_function''mime' )) {
  30.         if$download_function$attachment )) {
  31.             LibertyMime::addDownloadHit$attachment['attachment_id');
  32.             die;
  33.         else {
  34.             if!empty$attachment['errors')) {
  35.                 $msg '';
  36.                 foreach$attachment['errors'as $error {
  37.                     $msg .= $error.'<br />';
  38.                 }
  39.                 $gBitSystem->fatalErrortra$msg ));
  40.             else {
  41.                 $gBitSystem->fatalErrortra'There was an undetermined problem trying to prepare the file for download.' ));
  42.             }
  43.         }
  44.     else {
  45.         $gBitSystem->fatalErrortra"No suitable download function found." ));
  46.     }
  47. else {
  48.     $gBitSystem->fatalErrortra"Object not found." )NULLNULL404 );
  49. }

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