diff --git a/Makefile b/Makefile index e56e84ccede201c1d3431b49b0070964e621a892..c65a84f31985bfc9984b119a81826729441a95c4 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ BASE=downloads_for_sale PLUGINTYPE=vmcustom -VERSION=1.4 +VERSION=1.5 PLUGINFILES=$(BASE).php $(BASE).script.php $(BASE).xml index.html diff --git a/downloads_for_sale.php b/downloads_for_sale.php index 362ab005358246ef154274d52ccb6290706bc72e..2f64dc453ae6aed72c1acc7a7df3877f061a4d6e 100644 --- a/downloads_for_sale.php +++ b/downloads_for_sale.php @@ -122,15 +122,20 @@ class plgVmCustomDownloads_for_Sale extends vmCustomPlugin { return ($userId>0); } // In all other cases, check that the orderitem has the correct state - if ($orderitem && in_array($orderitem->order_status, $field->paid_status)) { - return true; + if ($orderitem) { + 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; } function loadCustomfieldData ($customfield_id) { $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); $field = $db->loadObject(); if(!$field) return false; @@ -233,7 +238,7 @@ class plgVmCustomDownloads_for_Sale extends vmCustomPlugin { return true; } } else { -// JFactory::getApplication()->enqueueMessage(JText::_('VMCUSTOM_DLSALE_ERROR_NOT_AUTHORIZED_UNKNOWN'), 'error'); + JFactory::getApplication()->enqueueMessage(JText::_('VMCUSTOM_DLSALE_ERROR_NOT_AUTHORIZED_UNKNOWN'), 'error'); } } else { JFactory::getApplication()->enqueueMessage(JText::_('VMCUSTOM_DLSALE_ERROR_LOAD_FAILURE'), 'error'); @@ -287,8 +292,13 @@ class plgVmCustomDownloads_for_Sale extends vmCustomPlugin { $productinfo->downloads = array(); $customs = (array)$customModel->getproductCustomslist ($i->virtuemart_product_id); 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: - 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); } } diff --git a/downloads_for_sale.script.php b/downloads_for_sale.script.php index 2c32859934f4c25a17bdda23f1353c99d3490488..104e717782d72a6e5eaa434cfe57fb03d4507012 100644 --- a/downloads_for_sale.script.php +++ b/downloads_for_sale.script.php @@ -1,5 +1,11 @@ <?php 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 { diff --git a/downloads_for_sale.xml b/downloads_for_sale.xml index 3ad3cce704c17ff6be0bf6a3caf771a1fee2803f..2cc16f6d215dd169cab6f77024bda1da85109397 100644 --- a/downloads_for_sale.xml +++ b/downloads_for_sale.xml @@ -6,7 +6,7 @@ <authorUrl>http://www.open-tools.net/</authorUrl> <copyright>Copyright (C) 2013 Reinhold Kainhofer. All rights reserved.</copyright> <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> <files> <filename plugin="downloads_for_sale">downloads_for_sale.php</filename> diff --git a/language/de-DE/de-DE.plg_vmcustom_downloads_for_sale.ini b/language/de-DE/de-DE.plg_vmcustom_downloads_for_sale.ini index e01397ce608a6355ed3c75557c135d6d0b59f09e..9a065cb55c87ac1f5bfa7154ba4257234380416b 100644 --- a/language/de-DE/de-DE.plg_vmcustom_downloads_for_sale.ini +++ b/language/de-DE/de-DE.plg_vmcustom_downloads_for_sale.ini @@ -43,7 +43,7 @@ VMCUSTOM_DLSALE_DLPAGE_BUTTON_VIEW="Downloads anzeigen" 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_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_MIMETYPE="MIME-Typ" diff --git a/releases/plg_vmcustom_downloads_for_sale_v1.5.zip b/releases/plg_vmcustom_downloads_for_sale_v1.5.zip new file mode 100644 index 0000000000000000000000000000000000000000..e1ef7420a430a114213daa88aa5f985fe7f261e6 Binary files /dev/null and b/releases/plg_vmcustom_downloads_for_sale_v1.5.zip differ