download.php

Go to the documentation of this file.
00001 <?php
00002 
00007 class Download extends oxUBase
00008 {
00015     public function init()
00016     {
00017         // empty for performance reasons
00018     }
00019 
00026     public function render()
00027     {
00028         $sFileOrderId = oxRegistry::getConfig()->getRequestParameter('sorderfileid');
00029 
00030         if ( $sFileOrderId ) {
00031             $oArticleFile = oxNew('oxFile');
00032             try {
00034                 $oOrderFile = oxNew('oxOrderFile');
00035                 if ( $oOrderFile->load($sFileOrderId) ) {
00036                     $sFileId = $oOrderFile->getFileId();
00037                     if ( $sFileId && $oArticleFile->load($sFileId) && $oArticleFile->exist() && $oOrderFile->processOrderFile() ) {
00038                         $oArticleFile->download();
00039                     } else {
00040                         $sError = "ERROR_MESSAGE_FILE_DOESNOT_EXIST";
00041                     }
00042                 }
00043             } catch (oxException $oEx) {
00044                 $sError = "ERROR_MESSAGE_FILE_DOWNLOAD_FAILED";
00045             }
00046         } else {
00047             $sError = "ERROR_MESSAGE_WRONG_DOWNLOAD_LINK";
00048         }
00049         if ( $sError ) {
00050             $oEx = new oxExceptionToDisplay();
00051             $oEx->setMessage( $sError );
00052             oxRegistry::get("oxUtilsView")->addErrorToDisplay( $oEx, false );
00053             oxRegistry::getUtils()->redirect( oxRegistry::getConfig()->getShopUrl() . 'index.php?cl=account_downloads');
00054         }
00055     }
00056 }