diff --git a/.gitignore b/.gitignore index 5236e1e4621a7a79cad1c2b069faaa994d1bf73b..b25c15b81fae06e1c55946ac6270bfdb293870e8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1 @@ *~ - diff --git a/Makefile b/Makefile index 0488e956b531b09cf7e16fb6bedb4bbddcc05f3c..2ecb9f0d733a9680a5dca37e3a400b9f5efc27f9 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ BASE=vmAutoParentCategories PLUGINTYPE=system -VERSION=1.0 +VERSION=1.1 PLUGINFILES=$(BASE).php $(BASE).xml index.html # TRANSDIR=../../../administrator/language/ diff --git a/de-DE.plg_system_vmAutoParentCategories.sys.ini b/de-DE.plg_system_vmAutoParentCategories.sys.ini index 47b1033fb01598cf7fb0ad7fbcd3c8009bc80f4f..c4f937d65507424f9e65cc1a191bea0ea092d7d7 100644 --- a/de-DE.plg_system_vmAutoParentCategories.sys.ini +++ b/de-DE.plg_system_vmAutoParentCategories.sys.ini @@ -8,8 +8,9 @@ VMAUTOCATEGORIES_DESCRIPTION="<h2>Virtuemart 2 automatische Produktkategorien Pl VMAUTOCATEGORIES_RUN="Führe Plugin aus:" VMAUTOCATEGORIES_RUN_DESC="Wählen Sie aus, wann das Plugin ausgeführt wird und die Kategorien der VirtueMart Produkte modifiziert." -VMAUTOCATEGORIES_RUN_NEVER="Nie" -VMAUTOCATEGORIES_RUN_BACKEND_LOGIN="Joomla Backend Login" +VMAUTOCATEGORIES_RUN_NEVER="Nie (nur manuell)" +VMAUTOCATEGORIES_RUN_BACKEND_LOGIN="Joomla Backend Administrator Login" +VMAUTOCATEGORIES_RUN_FRONTEND_LOGIN="Joomla Frontend Administrator Login" VMAUTOCATEGORIES_RUN_VM_STARTPAGE="VirtueMart Startseite (Backend)" VMAUTOCATEGORIES_RUN_VM_PRODUCTPAGE="VirtueMart Produktliste (Backend)" diff --git a/en-GB.plg_system_vmAutoParentCategories.sys.ini b/en-GB.plg_system_vmAutoParentCategories.sys.ini index 6408a0cfad38967076a6fe76a9856da254921bb4..32bb6af5ba6ab00c6a43e551f8ca21c00faa4a81 100644 --- a/en-GB.plg_system_vmAutoParentCategories.sys.ini +++ b/en-GB.plg_system_vmAutoParentCategories.sys.ini @@ -8,8 +8,9 @@ VMAUTOCATEGORIES_DESCRIPTION="<h2>Virtuemart 2 Auto Product Categories plugin</h VMAUTOCATEGORIES_RUN="Run plugin on:" VMAUTOCATEGORIES_RUN_DESC="Select when the plugin shall be run and automatically modify the VirtueMart categories of your products." -VMAUTOCATEGORIES_RUN_NEVER="Never" -VMAUTOCATEGORIES_RUN_BACKEND_LOGIN="Joomla Backend login" +VMAUTOCATEGORIES_RUN_NEVER="Never (only manual)" +VMAUTOCATEGORIES_RUN_BACKEND_LOGIN="Joomla Backend Administrator Login" +VMAUTOCATEGORIES_RUN_FRONTEND_LOGIN="Joomla Frontend Administrator Login" VMAUTOCATEGORIES_RUN_VM_STARTPAGE="VirtueMart start page (Backend)" VMAUTOCATEGORIES_RUN_VM_PRODUCTPAGE="VirtueMart product list page (Backend)" diff --git a/releases/plg_system_vmAutoParentCategories_v1.1.zip b/releases/plg_system_vmAutoParentCategories_v1.1.zip new file mode 100644 index 0000000000000000000000000000000000000000..c6c04ac9f73d3c2c3913ecab719b8fcc7ab3f4a6 Binary files /dev/null and b/releases/plg_system_vmAutoParentCategories_v1.1.zip differ diff --git a/vmAutoParentCategories.php b/vmAutoParentCategories.php index 1e456864df982f17950392bb7db5577aa6942d93..77ff67274a45e5853ba6929d4cc0a19e3093242c 100644 --- a/vmAutoParentCategories.php +++ b/vmAutoParentCategories.php @@ -1,8 +1,8 @@ <?php /** * @plugin VMAutoParentCategories - * Version 1.0, 2012-12-18 - * @copyright Copyright (C) 2012 Reinhold Kainhofer - All rights reserved. + * Version 1.1, 2013-02-24 + * @copyright Copyright (C) 2012-2013 Reinhold Kainhofer - All rights reserved. * @Website : http://www.kainhofer.com * @license - http://www.gnu.org/licenses/gpl.html GNU/GPL **/ @@ -17,6 +17,15 @@ class plgSystemVMAutoParentCategories extends JPlugin { var $_report = TRUE; var $_debug = FALSE; + function onAfterRoute(){ + /** Alternatively you may use chaining */ + if(!JFactory::getApplication()->isAdmin()) return; + if ($this->checkForRoutingTrigger()) { + $this->initSettings(); + $this->updateCategories(); + } + } + function initSettings() { $this->_dbg = $this->params->get('debug','report_changes'); @@ -43,7 +52,7 @@ class plgSystemVMAutoParentCategories extends JPlugin { break; } } - function checkForTrigger() { + function checkForRoutingTrigger() { $trigger = $this->params->get('run_trigger', 'never'); // Explicit call will ALWAYS trigger if (JRequest::getCmd('vmAutoParentCategories') == 'run') { @@ -66,25 +75,15 @@ class plgSystemVMAutoParentCategories extends JPlugin { } return $run; } - function onAfterRoute(){ - /** Alternatively you may use chaining */ - if(!JFactory::getApplication()->isAdmin()) return; - if ($this->checkForTrigger()) { - $this->initSettings(); - $this->updateCategories(); - } - } function debugMessage ($msg) { if ($this->_debug) { - $app = JFactory::getApplication(); - $app->enqueueMessage($msg, 'message'); + JFactory::getApplication()->enqueueMessage($msg, 'message'); } } function progressMessage ($msg) { if ($this->_report) { - $app = JFactory::getApplication(); - $app->enqueueMessage($msg, 'message'); + JFactory::getApplication()->enqueueMessage($msg, 'message'); } } @@ -170,6 +169,16 @@ class plgSystemVMAutoParentCategories extends JPlugin { } } } + function getCategoryTree () { + $q = 'SELECT `c`.`virtuemart_category_id` , `l`.`category_name` , `cc`.`category_parent_id` + FROM `#__virtuemart_categories` AS `c` + LEFT JOIN `#__virtuemart_categories_'.VMLANG.'` AS `l` ON ( `c`.`virtuemart_category_id` = `l`.`virtuemart_category_id` ) + LEFT JOIN `#__virtuemart_category_categories` AS `cc` ON ( `c`.`virtuemart_category_id` = `cc`.`category_child_id` )'; + $db = JFactory::getDbo (); + $db->setQuery ($q); + $categories = $db->loadObjectList ('virtuemart_category_id'); + return $categories; + } function updateCategories() { @@ -179,10 +188,7 @@ class plgSystemVMAutoParentCategories extends JPlugin { $prodaction = $this->params->get('normal_products', 'nothing'); $childprodaction = $this->params->get('child_products', 'nothing'); - $app = JFactory::getApplication(); - $catmodel = VmModel::getModel('category'); - $cattree = $catmodel->getCategoryTree(); - + $cattree = $this->getCategoryTree(); // Store the names and parents for each category id foreach ($cattree as $cat) { $catnames[$cat->virtuemart_category_id] = $cat->category_name; diff --git a/vmAutoParentCategories.xml b/vmAutoParentCategories.xml index 59757dfef99c3824db1df1688d2020cc699744b6..9105823c17c49e65c1757eccb0763bc2d845a79a 100644 --- a/vmAutoParentCategories.xml +++ b/vmAutoParentCategories.xml @@ -7,7 +7,7 @@ <license>http://www.gnu.org/licenses/gpl.html GNU/GPL v3+</license> <authorEmail>reinhold@kainhofer.com/</authorEmail> <authorUrl>http://kainhofer.com</authorUrl> - <version>1.0.0</version> + <version>1.1.0</version> <description>VMAUTOCATEGORIES_DESCRIPTION</description> <files> @@ -26,6 +26,7 @@ <field name="run_trigger" type="list" default="never" label="VMAUTOCATEGORIES_RUN" description ="VMAUTOCATEGORIES_RUN_DESC" > <option value="never">VMAUTOCATEGORIES_RUN_NEVER</option> <!-- <option value="backend-login">VMAUTOCATEGORIES_RUN_BACKEND_LOGIN</option> --> +<!-- <option value="frontend-login">VMAUTOCATEGORIES_RUN_FRONTEND_LOGIN</option> --> <option value="virtuemart_startpage">VMAUTOCATEGORIES_RUN_VM_STARTPAGE</option> <option value="virtuemart_products">VMAUTOCATEGORIES_RUN_VM_PRODUCTPAGE</option> </field>