33 $this->
init(
'oxorderfiles');
41 $oArticleFile =
oxNew(
'oxFile');
42 $oArticleFile->load($this->oxorderfiles__oxfileid->value);
43 if (file_exists($oArticleFile->getStoreLocation())) {
44 $this->oxorderfiles__oxdownloadcount =
new oxField(0);
45 $this->oxorderfiles__oxfirstdownload =
new oxField(
'0000-00-00 00:00:00');
46 $this->oxorderfiles__oxlastdownload =
new oxField(
'0000-00-00 00:00:00');
47 $iExpirationTime = $this->oxorderfiles__oxlinkexpirationtime->value * 3600;
49 $sDate = date(
'Y-m-d H:i:s', $sNow + $iExpirationTime);
50 $this->oxorderfiles__oxvaliduntil =
new oxField($sDate);
51 $this->oxorderfiles__oxresetcount =
new oxField($this->oxorderfiles__oxresetcount->value + 1);
62 $this->oxorderfiles__oxorderid =
new oxField($sOrderId);
72 $this->oxorderfiles__oxorderarticleid =
new oxField($sOrderArticleId);
82 $this->oxorderfiles__oxshopid =
new oxField($sShopId);
94 public function setFile($sFileName, $sFileId, $iMaxDownloadCounts, $iExpirationTime, $iExpirationDownloadTime)
97 $sDate = date(
'Y-m-d G:i', $sNow + $iExpirationTime * 3600);
99 $this->oxorderfiles__oxfileid =
new oxField($sFileId);
100 $this->oxorderfiles__oxfilename =
new oxField($sFileName);
101 $this->oxorderfiles__oxmaxdownloadcount =
new oxField($iMaxDownloadCounts);
102 $this->oxorderfiles__oxlinkexpirationtime =
new oxField($iExpirationTime);
103 $this->oxorderfiles__oxdownloadexpirationtime =
new oxField($iExpirationDownloadTime);
104 $this->oxorderfiles__oxvaliduntil =
new oxField($sDate);
114 $oFile =
oxNew(
"oxfile");
115 $oFile->load($this->oxorderfiles__oxfileid->value);
117 return $oFile->getSize();
129 $aFieldNames = array(
130 'oxorderfiles__oxarticletitle',
131 'oxorderfiles__oxarticleartnum',
132 'oxorderfiles__oxordernr',
133 'oxorderfiles__oxorderdate',
134 'oxorderfiles__oxispaid',
135 'oxorderfiles__oxpurchasedonly'
138 if (in_array($sFieldName, $aFieldNames)) {
152 if (!$this->oxorderfiles__oxmaxdownloadcount->value || ($this->oxorderfiles__oxdownloadcount->value < $this->oxorderfiles__oxmaxdownloadcount->value)) {
154 if (!$this->oxorderfiles__oxlinkexpirationtime->value && !$this->oxorderfiles__oxdownloadxpirationtime->value) {
158 $iTimestamp = strtotime($this->oxorderfiles__oxvaliduntil->value);
159 if (!$iTimestamp || ($iTimestamp > $sNow)) {
175 return $this->oxorderfiles__oxispaid->value;
185 return substr($this->oxorderfiles__oxvaliduntil->value, 0, 16);
195 $iLeft = $this->oxorderfiles__oxmaxdownloadcount->value - $this->oxorderfiles__oxdownloadcount->value;
212 if (!$this->oxorderfiles__oxdownloadcount->value) {
213 $this->oxorderfiles__oxdownloadcount =
new oxField(1);
215 $iExpirationTime = $this->oxorderfiles__oxdownloadexpirationtime->value * 3600;
217 $this->oxorderfiles__oxvaliduntil =
new oxField(date(
'Y-m-d H:i:s', $iTime + $iExpirationTime));
219 $this->oxorderfiles__oxfirstdownload =
new oxField(date(
'Y-m-d H:i:s', $iTime));
220 $this->oxorderfiles__oxlastdownload =
new oxField(date(
'Y-m-d H:i:s', $iTime));
222 $this->oxorderfiles__oxdownloadcount =
new oxField($this->oxorderfiles__oxdownloadcount->value + 1);
225 $this->oxorderfiles__oxlastdownload =
new oxField(date(
'Y-m-d H:i:s', $iTime));
229 return $this->oxorderfiles__oxfileid->value;
242 return $this->oxorderfiles__oxfileid->value;