OXID eShop CE  4.10.2
 All Classes Namespaces Files Functions Variables Pages
download.php
Go to the documentation of this file.
1 <?php
2 
7 class Download extends oxUBase
8 {
9 
14  public function init()
15  {
16  // empty for performance reasons
17  }
18 
25  public function render()
26  {
27  $sFileOrderId = oxRegistry::getConfig()->getRequestParameter('sorderfileid');
28 
29  if ($sFileOrderId) {
30  $oArticleFile = oxNew('oxFile');
31  try {
33  $oOrderFile = oxNew('oxOrderFile');
34  if ($oOrderFile->load($sFileOrderId)) {
35  $sFileId = $oOrderFile->getFileId();
36  $blLoadedAndExists = $oArticleFile->load($sFileId) && $oArticleFile->exist();
37  if ($sFileId && $blLoadedAndExists && $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 }