download.php

Go to the documentation of this file.
00001 <?php
00002 
00007 class Download extends oxUBase
00008 {
00009 
00014     public function init()
00015     {
00016         // empty for performance reasons
00017     }
00018 
00025     public function render()
00026     {
00027         $sFileOrderId = oxRegistry::getConfig()->getRequestParameter('sorderfileid');
00028 
00029         if ($sFileOrderId) {
00030             $oArticleFile = oxNew('oxFile');
00031             try {
00033                 $oOrderFile = oxNew('oxOrderFile');
00034                 if ($oOrderFile->load($sFileOrderId)) {
00035                     $sFileId = $oOrderFile->getFileId();
00036                     $blLoadedAndExists = $oArticleFile->load($sFileId) && $oArticleFile->exist();
00037                     if ($sFileId && $blLoadedAndExists && $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 }