OXID eShop CE  4.8.12
 All Classes Files Functions Variables Pages
download.php
Go to the documentation of this file.
1 <?php
2 
7 class Download extends oxUBase
8 {
15  public function init()
16  {
17  // empty for performance reasons
18  }
19 
26  public function render()
27  {
28  $sFileOrderId = oxRegistry::getConfig()->getRequestParameter('sorderfileid');
29 
30  if ( $sFileOrderId ) {
31  $oArticleFile = oxNew('oxFile');
32  try {
34  $oOrderFile = oxNew('oxOrderFile');
35  if ( $oOrderFile->load($sFileOrderId) ) {
36  $sFileId = $oOrderFile->getFileId();
37  if ( $sFileId && $oArticleFile->load($sFileId) && $oArticleFile->exist() && $oOrderFile->processOrderFile() ) {
38  $oArticleFile->download();
39  } else {
40  $sError = "ERROR_MESSAGE_FILE_DOESNOT_EXIST";
41  }
42  }
43  } catch (oxException $oEx) {
44  $sError = "ERROR_MESSAGE_FILE_DOWNLOAD_FAILED";
45  }
46  } else {
47  $sError = "ERROR_MESSAGE_WRONG_DOWNLOAD_LINK";
48  }
49  if ( $sError ) {
50  $oEx = new oxExceptionToDisplay();
51  $oEx->setMessage( $sError );
52  oxRegistry::get("oxUtilsView")->addErrorToDisplay( $oEx, false );
53  oxRegistry::getUtils()->redirect( oxRegistry::getConfig()->getShopUrl() . 'index.php?cl=account_downloads');
54  }
55  }
56 }