Skip to content
Snippets Groups Projects
Commit bc622a5d authored by Reinhold Kainhofer's avatar Reinhold Kainhofer
Browse files

Version 1.5: Fix different paid statuses; better warnings; add GPL header;...

Version 1.5: Fix different paid statuses; better warnings; add GPL header; display free/registered downloads even if order has no proper status for paid download
parent 6ec2c348
No related branches found
No related tags found
No related merge requests found
BASE=downloads_for_sale BASE=downloads_for_sale
PLUGINTYPE=vmcustom PLUGINTYPE=vmcustom
VERSION=1.4 VERSION=1.5
PLUGINFILES=$(BASE).php $(BASE).script.php $(BASE).xml index.html PLUGINFILES=$(BASE).php $(BASE).script.php $(BASE).xml index.html
......
...@@ -122,15 +122,20 @@ class plgVmCustomDownloads_for_Sale extends vmCustomPlugin { ...@@ -122,15 +122,20 @@ class plgVmCustomDownloads_for_Sale extends vmCustomPlugin {
return ($userId>0); return ($userId>0);
} }
// In all other cases, check that the orderitem has the correct state // In all other cases, check that the orderitem has the correct state
if ($orderitem && in_array($orderitem->order_status, $field->paid_status)) { if ($orderitem) {
return true; if (in_array($orderitem->order_status, $field->paid_status)) {
return true;
} elseif ($show_warnings) {
JFactory::getApplication()->enqueueMessage(JText::sprintf("Order status %s does not allow download (allowed states are %s)", $orderitem->order_status, join($field->paid_status, ", ")), 'error');
}
} }
return false; return false;
} }
function loadCustomfieldData ($customfield_id) { function loadCustomfieldData ($customfield_id) {
$db = JFactory::getDbo(); $db = JFactory::getDbo();
$q = 'SELECT * FROM `#__virtuemart_product_customfields` WHERE `virtuemart_customfield_id` = '.(int)$customfield_id . ' AND `custom_value`=\''.$db->getEscaped($this->_name).'\''; $q = 'SELECT * FROM `#__virtuemart_customs` LEFT JOIN `#__virtuemart_product_customfields` USING (`virtuemart_custom_id`, `custom_value`) WHERE `virtuemart_customfield_id` = '.(int)$customfield_id . ' AND `custom_value`=\''.$db->getEscaped($this->_name).'\'';
$db->setQuery($q); $db->setQuery($q);
$field = $db->loadObject(); $field = $db->loadObject();
if(!$field) return false; if(!$field) return false;
...@@ -233,7 +238,7 @@ class plgVmCustomDownloads_for_Sale extends vmCustomPlugin { ...@@ -233,7 +238,7 @@ class plgVmCustomDownloads_for_Sale extends vmCustomPlugin {
return true; return true;
} }
} else { } else {
// JFactory::getApplication()->enqueueMessage(JText::_('VMCUSTOM_DLSALE_ERROR_NOT_AUTHORIZED_UNKNOWN'), 'error'); JFactory::getApplication()->enqueueMessage(JText::_('VMCUSTOM_DLSALE_ERROR_NOT_AUTHORIZED_UNKNOWN'), 'error');
} }
} else { } else {
JFactory::getApplication()->enqueueMessage(JText::_('VMCUSTOM_DLSALE_ERROR_LOAD_FAILURE'), 'error'); JFactory::getApplication()->enqueueMessage(JText::_('VMCUSTOM_DLSALE_ERROR_LOAD_FAILURE'), 'error');
...@@ -287,8 +292,13 @@ class plgVmCustomDownloads_for_Sale extends vmCustomPlugin { ...@@ -287,8 +292,13 @@ class plgVmCustomDownloads_for_Sale extends vmCustomPlugin {
$productinfo->downloads = array(); $productinfo->downloads = array();
$customs = (array)$customModel->getproductCustomslist ($i->virtuemart_product_id); $customs = (array)$customModel->getproductCustomslist ($i->virtuemart_product_id);
foreach ($customs as $field) { foreach ($customs as $field) {
$downloadable = ($field->custom_element == $this->_name);
if ($field->download_type == "paid_download") {
$downloadable = $downloadable && in_array($order['details']['BT']->order_status, $field->paid_status);
}
$downloadable = $downloadable && $this->checkDownloadable ($field, $i, false);
// Order needs to be downloadable and the individiaul field, too: // Order needs to be downloadable and the individiaul field, too:
if (($field->custom_element == $this->_name) && in_array($order['details']['BT']->order_status, $field->paid_status) && ($this->checkDownloadable ($field, $i, false))) { if ($downloadable) {
$productinfo->downloads[] = $this->createDownloadLink ($field, 'order', $field->invoice_link_type, $i); $productinfo->downloads[] = $this->createDownloadLink ($field, 'order', $field->invoice_link_type, $i);
} }
} }
......
<?php <?php
defined('_JEXEC') or die('Restricted access'); defined('_JEXEC') or die('Restricted access');
/**
* Installation script for the plugin
*
* @copyright Copyright (C) 2013 Reinhold Kainhofer, office@open-tools.net
* @license GPL v3+, http://www.gnu.org/copyleft/gpl.html
*/
class plgVmCustomDownloads_for_SaleInstallerScript class plgVmCustomDownloads_for_SaleInstallerScript
{ {
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<authorUrl>http://www.open-tools.net/</authorUrl> <authorUrl>http://www.open-tools.net/</authorUrl>
<copyright>Copyright (C) 2013 Reinhold Kainhofer. All rights reserved.</copyright> <copyright>Copyright (C) 2013 Reinhold Kainhofer. All rights reserved.</copyright>
<license>http://www.gnu.org/licenses/gpl.html GNU/GPL v3+</license> <license>http://www.gnu.org/licenses/gpl.html GNU/GPL v3+</license>
<version>1.4</version> <version>1.5</version>
<description>VMCUSTOM_DLSALE_DESC</description> <description>VMCUSTOM_DLSALE_DESC</description>
<files> <files>
<filename plugin="downloads_for_sale">downloads_for_sale.php</filename> <filename plugin="downloads_for_sale">downloads_for_sale.php</filename>
......
...@@ -43,7 +43,7 @@ VMCUSTOM_DLSALE_DLPAGE_BUTTON_VIEW="Downloads anzeigen" ...@@ -43,7 +43,7 @@ VMCUSTOM_DLSALE_DLPAGE_BUTTON_VIEW="Downloads anzeigen"
VMCUSTOM_DLSALE_DLPAGE_NO_DOWNLOADS="Keine Downloads verfügbar" VMCUSTOM_DLSALE_DLPAGE_NO_DOWNLOADS="Keine Downloads verfügbar"
VMCUSTOM_DLSALE_DLPAGE_ORDER_NO_DOWNLOADS="Keine Downloads verfügbar für Bestellung %s" VMCUSTOM_DLSALE_DLPAGE_ORDER_NO_DOWNLOADS="Keine Downloads verfügbar für Bestellung %s"
VMCUSTOM_DLSALE_DLPAGE_DOWNLOADS="Verfügbare Downloads" VMCUSTOM_DLSALE_DLPAGE_DOWNLOADS="Verfügbare Downloads"
VMCUSTOM_DLSALE_DLPAGE_ORDERPRODUCT="Auftragssnummer %s: %s (%s)" VMCUSTOM_DLSALE_DLPAGE_ORDERPRODUCT="Auftragsnummer %s: %s (%s)"
VMCUSTOM_DLSALE_FILENAME="Dateiname" VMCUSTOM_DLSALE_FILENAME="Dateiname"
VMCUSTOM_DLSALE_MIMETYPE="MIME-Typ" VMCUSTOM_DLSALE_MIMETYPE="MIME-Typ"
......
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment