diff --git a/Makefile b/Makefile index c78d3054cd19f6132026e36f482f2fd619333e03..a6520cd009b0dee8d4c21b14fdf380091cca7572 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ BASE=downloads_for_sale PLUGINTYPE=vmcustom -VERSION=1.5.1 +VERSION=1.5.2 PLUGINFILES=$(BASE).php $(BASE).script.php $(BASE).xml index.html diff --git a/downloads_for_sale.php b/downloads_for_sale.php index 2e58b3bb6cd8c4dc113f5fd2f4effdef68376ee5..bf6589a86d933b4f3a11e65e4b711bdb4ff8f1d2 100644 --- a/downloads_for_sale.php +++ b/downloads_for_sale.php @@ -38,7 +38,7 @@ class plgVmCustomDownloads_for_Sale extends vmCustomPlugin { 'product_link_type'=>array('image','char'), 'download_type'=>array('free_download','char'), 'paid_status'=>array(array('S', 'C'), 'array'), - 'downloaded_status'=>array('S', 'char'), + 'downloaded_status'=>array('', 'char'), ); $this->setConfigParameterable('custom_params',$varsToPush); $this->onStoreInstallPluginTable($this->_psType); @@ -89,9 +89,11 @@ class plgVmCustomDownloads_for_Sale extends vmCustomPlugin { } } } - $prodid = $field->virtuemart_product_id; - if (empty($prodid)) { + if (isset($field->virtuemart_product_id) && $field->virtuemart_product_id) { + $prodid = $field->virtuemart_product_id; + } else { JFactory::getApplication()->enqueueMessage(JText::sprintf("WARNING: no product ID given in custom field. Please contact the plugin developer and copy this message: <pre>%s</pre>", print_r($field,1)), 'error'); + return array(); } $orderitems = array(); foreach ($orders as $order) { @@ -202,7 +204,7 @@ class plgVmCustomDownloads_for_Sale extends vmCustomPlugin { } function updateOrderStatus ($field, $orderitem) { - if (!$orderitem) return; + if (!$orderitem || empty($field->downloaded_status)) return; $orderModel = VmModel::getModel('orders'); # Update the whole order: @@ -223,10 +225,10 @@ class plgVmCustomDownloads_for_Sale extends vmCustomPlugin { if ($field_id) { $field = $this->loadCustomfieldData ($field_id); - $this->parseCustomParams($field); - $orderitems = $this->getCustomfieldOrderitems ($field, JFactory::getUser()->get('id'), true); - $orderitem = empty($orderitems)?null:$orderitems[0]; if ($field) { + $this->parseCustomParams($field); + $orderitems = $this->getCustomfieldOrderitems ($field, JFactory::getUser()->get('id'), true); + $orderitem = empty($orderitems)?null:$orderitems[0]; if ($this->checkDownloadable ($field, $orderitem, true)) { $handled = true; if ($this->downloadFile ($field->media_id, $render)) { diff --git a/downloads_for_sale.xml b/downloads_for_sale.xml index fb80e07751fe7cec3ef04a05425cf030126fa1a5..452b36e53f35bb5f203e6570ea9105fd5f1f6b5c 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.5.1</version> + <version>1.5.2</version> <description>VMCUSTOM_DLSALE_DESC</description> <files> <filename plugin="downloads_for_sale">downloads_for_sale.php</filename> @@ -41,7 +41,7 @@ <option value="registered_download">VMCUSTOM_DLSALE_TYPE_REGISTERED</option> <option value="paid_download">VMCUSTOM_DLSALE_TYPE_PAID</option> </param> - <param name="paid_status" type="vmorderstates" scope="com_virtuemart" default="C" label="VMCUSTOM_DLSALE_STATUS_PAID" description="VMCUSTOM_DLSALE_STATUS_PAID_EXPLAIN" /> - <param name="downloaded_status" type="vmorderstate" scope="com_virtuemart" default="S" label="VMCUSTOM_DLSALE_STATUS_DOWNLOADED" description="VMCUSTOM_DLSALE_STATUS_DOWNLOADED_EXPLAIN" /> + <param name="paid_status" type="vmorderstates" scope="com_virtuemart" default="C, S" multiple="multiple" label="VMCUSTOM_DLSALE_STATUS_PAID" description="VMCUSTOM_DLSALE_STATUS_PAID_EXPLAIN" /> + <param name="downloaded_status" type="vmdlorderstate" scope="com_virtuemart" default="" label="VMCUSTOM_DLSALE_STATUS_DOWNLOADED" description="VMCUSTOM_DLSALE_STATUS_DOWNLOADED_EXPLAIN" /> </params> </install> diff --git a/elements/vmdlorderstate.php b/elements/vmdlorderstate.php new file mode 100644 index 0000000000000000000000000000000000000000..6fea04ad9e740fdfd345e229624c75e2867791e9 --- /dev/null +++ b/elements/vmdlorderstate.php @@ -0,0 +1,56 @@ +<?php +defined ('_JEXEC') or die(); +/** + * + * @package VirtueMart + * @subpackage Plugins - Elements + * @author Valérie Isaksen + * @link http://www.virtuemart.net + * @copyright Copyright (c) 2004 - 2011 VirtueMart Team. All rights reserved. + * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php + * VirtueMart is free software. This version may have been modified pursuant + * to the GNU General Public License, and as distributed it includes or + * is derivative of works licensed under the GNU General Public License or + * other free or open source software licenses. + * @version $Id:$ + */ +/* + * This class is used by VirtueMart Payment or Shipment Plugins + * which uses JParameter + * So It should be an extension of JElement + * Those plugins cannot be configured througth the Plugin Manager anyway. + */ +class JElementVmDLOrderState extends JElement { + + /** + * Element name + * + * @access protected + * @var string + */ + var $_name = 'DownloadOrderState'; + + function fetchElement ($name, $value, &$node, $control_name) { + + $db = JFactory::getDBO (); + + $query = 'SELECT `order_status_code` AS value, `order_status_name` AS text + FROM `#__virtuemart_orderstates` + WHERE `virtuemart_vendor_id` = 1 + ORDER BY `ordering` ASC '; + + $db->setQuery ($query); + $fields = $db->loadObjectList (); + $class = ''; + foreach ($fields as $field) { + $field->text= JText::_ ($field->text); + } + $unchanged = new stdClass(); + $unchanged->text = JText::_ ('VMCUSTOM_DLSALE_STATUS_UNCHANGED'); + $unchanged->value = ''; + array_unshift($fields, $unchanged); + + return $html .JHTML::_ ('select.genericlist', $fields, $control_name . '[' . $name . ']', $class, 'value', 'text', $value, $control_name . $name); + } + +} \ No newline at end of file diff --git a/language/en-GB/en-GB.plg_vmcustom_downloads_for_sale.ini b/language/en-GB/en-GB.plg_vmcustom_downloads_for_sale.ini index 0e9210a7a8991d27184b4272938cc396dbd4d03c..74e1f5a84857ed148c81118ed42f3cd8bd3ce135 100644 --- a/language/en-GB/en-GB.plg_vmcustom_downloads_for_sale.ini +++ b/language/en-GB/en-GB.plg_vmcustom_downloads_for_sale.ini @@ -25,6 +25,7 @@ VMCUSTOM_DLSALE_STATUS_PAID="Status to enable paid download" VMCUSTOM_DLSALE_STATUS_PAID_EXPLAIN="Select the statuses for paid downloads that allow the buyer to download the file." VMCUSTOM_DLSALE_STATUS_DOWNLOADED="Status after download" VMCUSTOM_DLSALE_STATUS_DOWNLOADED_EXPLAIN="After a file was downloaded through this plugin, the order status will be set to this value, indication a download was initiated by the user." +VMCUSTOM_DLSALE_STATUS_UNCHANGED="- (No change)" VMCUSTOM_DLSALE_NO_FILES="No media files found for download or sale." VMCUSTOM_DLSALE_DOWNLOAD_FILE="Download file" diff --git a/releases/plg_vmcustom_downloads_for_sale_v1.5.2.zip b/releases/plg_vmcustom_downloads_for_sale_v1.5.2.zip new file mode 100644 index 0000000000000000000000000000000000000000..f12428d40530853988ac393c0e95dcb574d34bd8 Binary files /dev/null and b/releases/plg_vmcustom_downloads_for_sale_v1.5.2.zip differ