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

Version 1.1: Correctly handle VM shopper groups (fix two caching issues, one...

Version 1.1: Correctly handle VM shopper groups (fix two caching issues, one in the plugin and one with the user model)
parent c75c09b0
No related branches found
No related tags found
No related merge requests found
BASE=buyer_assign_group BASE=buyer_assign_group
PLUGINTYPE=vmcustom PLUGINTYPE=vmcustom
ZIPBASE=opentools_vm2 ZIPBASE=opentools_vm2
VERSION=1.0 VERSION=1.1
PLUGINFILES=$(BASE).php $(BASE).script.php $(BASE).xml index.html PLUGINFILES=$(BASE).php $(BASE).script.php $(BASE).xml index.html
......
...@@ -205,6 +205,10 @@ class plgVmCustomBuyer_Assign_Group extends vmCustomPlugin { ...@@ -205,6 +205,10 @@ class plgVmCustomBuyer_Assign_Group extends vmCustomPlugin {
if ($modified) { if ($modified) {
$this->setModifiedFlag ($e, $modified); $this->setModifiedFlag ($e, $modified);
} }
$userModel->_data = null;
$userModel->setId($uid);
$users[$uid] = $userModel->getUser();
$users[$uid]->shopper_groups = (array)$users[$uid]->shopper_groups;
} elseif ($unpurchased && $e['modified']) { } elseif ($unpurchased && $e['modified']) {
// Undo the addition/removal when a product purchase is cancelled // Undo the addition/removal when a product purchase is cancelled
if ($e['group_type']==0) { // Joomla User Group if ($e['group_type']==0) { // Joomla User Group
...@@ -223,6 +227,11 @@ class plgVmCustomBuyer_Assign_Group extends vmCustomPlugin { ...@@ -223,6 +227,11 @@ class plgVmCustomBuyer_Assign_Group extends vmCustomPlugin {
// Clear the modified flag in the database // Clear the modified flag in the database
$this->setModifiedFlag ($e, 0); $this->setModifiedFlag ($e, 0);
} }
// Reload the user data, because shopper groups are NOT automatically updated in the data structure in memory!
$userModel->_data = null;
$userModel->setId($uid);
$users[$uid] = $userModel->getUser();
$users[$uid]->shopper_groups = (array)$users[$uid]->shopper_groups;
} }
catch (Exception $ex) { catch (Exception $ex) {
JFactory::getApplication()->enqueueMessage("ERROR: <pre>".$ex->getMessage()."</pre>", 'info'); JFactory::getApplication()->enqueueMessage("ERROR: <pre>".$ex->getMessage()."</pre>", 'info');
......
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<install version="1.5" type="plugin" group="vmcustom" method="upgrade"> <install version="1.5" type="plugin" group="vmcustom" method="upgrade">
<name>VMCUSTOM_BUYER_GROUP</name> <name>VMCUSTOM_BUYER_GROUP</name>
<creationDate>2013-09-28</creationDate> <creationDate>2014-04-07</creationDate>
<author>Reinhold Kainhofer</author> <author>Reinhold Kainhofer</author>
<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-2014 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.0</version> <version>1.1</version>
<description>VMCUSTOM_BUYER_GROUP_DESC</description> <description>VMCUSTOM_BUYER_GROUP_DESC</description>
<files> <files>
<filename plugin="buyer_assign_group">buyer_assign_group.php</filename> <filename plugin="buyer_assign_group">buyer_assign_group.php</filename>
......
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment