Commit b1d12e13 authored by Reinhold Kainhofer's avatar Reinhold Kainhofer
Browse files

V1.2: Make the plugin work properly with VM3

parent 4ac82bc3
......@@ -106,7 +106,7 @@ class plgVmCustomBuyer_Assign_Group extends vmCustomPlugin {
'group_id' => 'int(11) UNSIGNED NULL DEFAULT 0',
'group_type' => 'int(1) UNSIGNED NULL DEFAULT 0',
'group_add' => 'bool DEFAULT 1',
'modified' => 'bool DEFAULT 1',
'modified' => 'bool DEFAULT 0',
);
return $SQLfields;
}
......@@ -189,7 +189,7 @@ class plgVmCustomBuyer_Assign_Group extends vmCustomPlugin {
if (!isset($customs[$cid])) {
$customsModel->setId($cid);
$c = $customsModel->getData();
$this->parseCustomParams($c);
$this->parseCustomParams($c, 'custom_params');
$pstates[$cid] = $c->purchased_status;
}
}
......@@ -221,7 +221,9 @@ class plgVmCustomBuyer_Assign_Group extends vmCustomPlugin {
if ($modified) {
$this->setModifiedFlag ($e, $modified);
}
// Update the $users array so the next step in the loop has the correct groups if the user is added to another group
$userModel->_data = null;
$userModel->setId(0); // <- This makes sure to invalidate the cache
$userModel->setId($uid);
$users[$uid] = $userModel->getUser();
$users[$uid]->shopper_groups = (array)$users[$uid]->shopper_groups;
......@@ -245,6 +247,7 @@ class plgVmCustomBuyer_Assign_Group extends vmCustomPlugin {
}
// Reload the user data, because shopper groups are NOT automatically updated in the data structure in memory!
$userModel->_data = null;
$userModel->setId(0); // <- This makes sure to invalidate the cache
$userModel->setId($uid);
$users[$uid] = $userModel->getUser();
$users[$uid]->shopper_groups = (array)$users[$uid]->shopper_groups;
......@@ -256,16 +259,17 @@ class plgVmCustomBuyer_Assign_Group extends vmCustomPlugin {
}
}
function plgVmCouponUpdateOrderStatus($data, $old_order_status) {
return $this->plgVmOnUpdateOrder($data, $old_order_status);
}
// VM2.x compat:
function plgVmOnUpdateOrder($data, $old_order_status) {
return $this->plgVmOnUpdateOrderShipment($data, $old_order_status);
}
// VM3.x
function plgVmOnUpdateOrderShipment($data, $old_order_status) {
return $this->updateOrderStatus($data->virtuemart_order_id, $data->order_status, $old_order_status);
}
function plgVmConfirmedOrder($cart, $order) {
// Each custom field will have its own value for auto-subscribe, so we need to handle all purchased products!
// Each custom field will have its own values, so we need to handle all purchased products!
$vuid = $order['details']['BT']->virtuemart_user_id;
$userModel = VmModel::getModel('user');
$user = $userModel->getCurrentUser();
......@@ -279,7 +283,11 @@ class plgVmCustomBuyer_Assign_Group extends vmCustomPlugin {
$customModel = VmModel::getModel('customfields');
// Collect all group additions/removals that need to be stored in the database; Will be used on order change
foreach ($order['items'] as $item) {
$customs = $customModel->getproductCustomslist ($item->virtuemart_product_id);
if (method_exists($customModel, 'getCustomEmbeddedProductCustomFields')) { // V3.x
$customs = $customModel->getCustomEmbeddedProductCustomFields (array ($item->virtuemart_product_id));
} else {
$customs = $customModel->getproductCustomslist ($item->virtuemart_product_id); // V2.x
}
foreach ($customs as $field) {
if ($field->custom_element != $this->_name) continue;
......
<?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:$
*/
// if (!class_exists('VmConfig')) require(JPATH_VM_ADMINISTRATOR.DS.'components'.DS.'com_virtuemart'.DS.'helpers'.DS.'config.php');
// if(!class_exists('VmModel')) require(JPATH_VM_ADMINISTRATOR.DS.'helpers'.DS.'vmmodel.php');
/*
* 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 JElementVmOrderStates extends JElement {
//
// /**
// * Element name
// *
// * @access protected
// * @var string
// */
// var $_name = 'OrderStates';
//
// function fetchElement ($name, $value, &$node, $control_name) {
// $statusModel = VmModel::getModel('OrderStatus');
// $fields = $statusModel->getOrderStatusNames();
// $class = 'class="inputbox" multiple="multiple" size="6" ';
//
// return JHTML::_ ('select.genericlist', $fields, $control_name . '[' . $name . '][]', $class, 'order_status_code', 'order_status_name', $value, $control_name . $name, true);
// }
// }
// <?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:$
*/
class JFormFieldVmOrderStates extends JFormField {
var $type = 'VmOrderStates';
function getInput () {
defined('DS') or define('DS', DIRECTORY_SEPARATOR);
if (!class_exists( 'VmConfig' )) require(JPATH_ROOT.DS.'administrator'.DS.'components'.DS.'com_virtuemart'.DS.'helpers'.DS.'config.php');
if (!class_exists ('VmModel')) {
require(VMPATH_ADMIN . DS . 'helpers' . DS . 'vmmodel.php');
}
VmConfig::loadConfig ();
VmConfig::loadJLang('com_virtuemart');
$key = ($this->element['key_field'] ? $this->element['key_field'] : 'value');
$val = ($this->element['value_field'] ? $this->element['value_field'] : $this->name);
$model = VmModel::getModel ('Orderstatus');
$orderStatus = $model->getOrderStatusList ();
foreach ($orderStatus as $orderState) {
$orderState->order_status_name = vmText::_ ($orderState->order_status_name);
}
return JHtml::_ ('select.genericlist', $orderStatus, $this->name, 'class="inputbox" multiple="true" size="6"', 'order_status_code', 'order_status_name', $this->value, $this
->id);
}
}
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="380"
height="290"
id="svg3813"
sodipodi:version="0.32"
inkscape:version="0.46"
version="1.0"
sodipodi:docname="shopping_cart.svg"
inkscape:output_extension="org.inkscape.output.svg.inkscape">
<defs
id="defs3815">
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient3216"
id="radialGradient3402"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1,0,0,1.0265279,53.571429,-12.46395)"
cx="300.63495"
cy="462.18982"
fx="300.63495"
fy="462.18982"
r="10.97111" />
<linearGradient
inkscape:collect="always"
id="linearGradient3206">
<stop
style="stop-color:#b3b3b3;stop-opacity:1;"
offset="0"
id="stop3208" />
<stop
style="stop-color:#b3b3b3;stop-opacity:0;"
offset="1"
id="stop3210" />
</linearGradient>
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient3206"
id="radialGradient3405"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1,0,0,1.423301,0,-161.97783)"
cx="408.53793"
cy="375.87903"
fx="408.53793"
fy="375.87903"
r="8.046875" />
<linearGradient
inkscape:collect="always"
id="linearGradient3216">
<stop
style="stop-color:#b3b3b3;stop-opacity:1;"
offset="0"
id="stop3218" />
<stop
style="stop-color:#b3b3b3;stop-opacity:0;"
offset="1"
id="stop3220" />
</linearGradient>
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient3216"
id="radialGradient3408"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1,0,0,1.0265279,0,-12.46395)"
cx="300.63495"
cy="462.18982"
fx="300.63495"
fy="462.18982"
r="10.97111" />
<linearGradient
inkscape:collect="always"
id="linearGradient3186">
<stop
style="stop-color:#cccccc;stop-opacity:1;"
offset="0"
id="stop3188" />
<stop
style="stop-color:#cccccc;stop-opacity:0;"
offset="1"
id="stop3190" />
</linearGradient>
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient3186"
id="radialGradient3412"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1,0,0,0.5693009,0,177.43456)"
cx="270.58206"
cy="378.09262"
fx="270.58206"
fy="378.09262"
r="72.84153" />
<linearGradient
inkscape:collect="always"
id="linearGradient3244">
<stop
style="stop-color:#ffffff;stop-opacity:1;"
offset="0"
id="stop3246" />
<stop
style="stop-color:#ffffff;stop-opacity:0;"
offset="1"
id="stop3248" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient3244"
id="linearGradient3415"
gradientUnits="userSpaceOnUse"
x1="277.7323"
y1="425.51294"
x2="427.34067"
y2="425.51294" />
<inkscape:perspective
sodipodi:type="inkscape:persp3d"
inkscape:vp_x="0 : 526.18109 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_z="744.09448 : 526.18109 : 1"
inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
id="perspective3821" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
gridtolerance="10000"
guidetolerance="10"
objecttolerance="10"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.35"
inkscape:cx="500.71429"
inkscape:cy="-360"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:window-width="641"
inkscape:window-height="710"
inkscape:window-x="208"
inkscape:window-y="147" />
<metadata
id="metadata3818">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<g
id="g3488"
transform="matrix(2.224774,0,0,2.224774,-587.53503,-802.87942)"
inkscape:export-filename="/home/brandon/Desktop/list.png"
inkscape:export-xdpi="89.997635"
inkscape:export-ydpi="89.997635">
<path
style="fill:#4d4d4d;fill-opacity:1;fill-rule:nonzero;stroke:url(#linearGradient3415);stroke-width:2;stroke-linecap:round;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
d="M 413.01639,368.49129 C 411.75829,368.48998 410.46298,369.17585 409.36115,371.24677 L 401.40399,390.87257 C 401.30871,390.86656 401.21966,390.84446 401.12282,390.84446 L 283.14307,390.84446 C 282.08274,390.89154 281.02676,390.83811 279.96583,390.90069 C 278.6876,391.28367 277.9485,392.63205 278.33503,393.90923 C 278.69637,395.33894 278.82077,396.67603 279.57219,397.98622 L 296.18945,452.8991 C 296.0874,454.81012 295.94267,456.21692 298.01707,456.21693 L 298.49506,456.21693 C 298.83061,456.29065 299.18112,456.26847 299.5354,456.18881 L 381.18773,455.3453 C 382.13888,455.3453 382.2275,455.17977 381.97501,454.83919 C 382.60855,454.63915 383.17089,454.20146 383.46522,453.5458 L 409.41739,395.73685 C 409.52183,395.50418 409.55825,395.24557 409.58609,395.0058 L 415.6594,381.48143 L 421.14226,387.27357 C 421.68872,388.4909 423.10065,389.02568 424.3195,388.48261 C 425.53835,387.93951 427.28404,381.88338 426.73758,380.66603 C 422.80088,377.57775 420.68318,372.11562 416.3061,369.72844 C 415.38363,369.13624 414.2302,368.49254 413.01639,368.49129 z M 290.22861,399.78572 L 396.96147,399.78572 L 392.01284,412.0167 C 391.43925,411.74953 390.80566,411.59494 390.12899,411.59494 L 293.3215,411.59494 L 290.22861,399.78572 z M 295.68334,420.50809 L 388.55443,420.50809 L 384.92731,429.44936 L 298.04518,429.44936 L 295.68334,420.50809 z M 300.37891,438.36251 L 381.18773,438.36251 C 381.22523,438.36251 381.28861,438.36342 381.32831,438.36251 L 377.84178,446.91014 C 377.79792,447.00785 377.80137,447.14887 377.78555,447.30378 L 302.74076,447.30378 L 300.37891,438.36251 z M 311.76638,457.51032 C 305.03318,457.51032 299.56351,463.11325 299.56351,470.02247 C 299.56351,476.93168 305.03319,482.53463 311.76638,482.53462 C 318.49955,482.53462 323.94112,476.93168 323.94112,470.02247 C 323.94112,463.11326 318.49956,457.51033 311.76638,457.51032 z M 365.32963,457.51032 C 358.59646,457.51032 353.12676,463.11325 353.12677,470.02247 C 353.12677,476.93168 358.59645,482.53463 365.32963,482.53462 C 372.06282,482.53462 377.5325,476.93168 377.53249,470.02247 C 377.53249,463.11326 372.06281,457.51033 365.32963,457.51032 z"
id="rect3280"
sodipodi:nodetypes="cccccccccccccccccccsccccccccccccccccccccccsssccsssc" />
<path
style="fill:url(#radialGradient3412);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:1, 3;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
d="M 413.03125,370.5 C 411.77315,370.49868 410.47683,373.17908 409.375,375.25 L 408.3125,378.1875 C 410.61719,378.70158 412.86029,379.34607 415.03125,380.125 L 415.15625,379.875 L 415.5625,380.34375 C 418.92891,381.59244 422.12069,383.14437 425.09375,385.03125 C 425.71232,383.46486 426.13509,381.56238 425.8125,380.84375 L 419.21875,374.40625 C 419.08864,373.79201 418.71166,373.22898 418.15625,372.875 C 417.55733,372.22031 416.9452,371.87131 416.3125,371.71875 C 415.39004,371.12654 414.24506,370.50125 413.03125,370.5 z M 344.96875,392.71875 L 283.15625,392.84375 C 282.96996,392.84376 282.77392,392.8843 282.59375,392.90625 C 280.62231,392.53124 281.02854,393.08588 280.34375,393.90625 C 280.70446,395.33832 280.89151,396.6539 281.5625,398 L 298.1875,450.90625 C 298.13112,451.96201 298.07605,452.84172 298.375,453.4375 C 299.35403,450.22872 300.49819,447.02444 301.84375,443.84375 L 300.375,438.375 L 304.34375,438.375 C 305.82634,435.36561 307.45324,432.3644 309.25,429.4375 L 298.03125,429.4375 L 295.6875,420.5 L 315.375,420.5 C 317.67378,417.44544 320.14181,414.4639 322.78125,411.59375 L 293.3125,411.59375 L 290.21875,399.78125 L 335.34375,399.78125 C 337.28188,398.20835 339.28782,396.67991 341.34375,395.21875 C 342.55557,394.3575 343.74613,393.51919 344.96875,392.71875 z"
id="path2409"
sodipodi:nodetypes="ccccccccccccccccccccccccccccccsc" />
<path
style="opacity:0.5;fill:#333333;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:1, 3;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
d="M 416.16323,378.67089 C 413.56836,378.8104 411.89271,381.84582 409.94765,384.53431 C 406.5873,389.17902 393.07528,426.66072 385.93242,430.94643 C 379.7842,434.63536 385.16665,433.33082 374.74492,438.35268 L 380.68242,438.35268 C 380.71992,438.35268 380.79897,438.35359 380.83867,438.35268 L 377.33867,446.91518 C 377.29481,447.01292 377.29199,447.13527 377.27617,447.29018 L 352.74492,447.29018 C 339.85069,451.40684 328.7717,453.07143 324.15117,453.07143 C 322.59828,453.07142 320.17321,453.44999 317.40117,454.00893 L 378.68242,453.35268 C 379.63357,453.35269 379.71616,453.19326 379.46367,452.85268 C 380.09721,452.65264 380.66934,452.19584 380.96367,451.54018 L 406.90117,395.72768 C 407.00561,395.49502 407.37333,395.15495 407.40117,394.91518 L 415.59819,380.26274 L 421.2519,386.25893 C 421.79835,387.47626 422.6268,388.40146 423.84565,387.85839 C 424.7011,387.47722 425.4913,384.9974 425.8125,383.17026 C 425.76735,383.01328 425.79578,382.90192 425.875,382.79526 C 425.91901,382.45857 426.3008,382.21175 426.28505,381.95214 C 425.81324,381.58177 423.78867,380.46607 421.27617,379.50893 C 418.46367,378.4375 417.72015,378.58718 416.16323,378.67089 z"
id="path2411"
sodipodi:nodetypes="cssccccccsccccccccscccsc" />
<path
style="fill:url(#radialGradient3408);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:1, 3;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
d="M 311.625,458.59375 C 305.56446,458.59374 300.625,463.62478 300.625,469.84375 C 300.62499,474.73825 303.68408,478.88494 307.9375,480.4375 C 306.06909,478.41848 304.90625,475.68938 304.90625,472.6875 C 304.90625,466.46853 309.84571,461.43749 315.90625,461.4375 C 317.19282,461.4375 318.41645,461.6762 319.5625,462.09375 C 317.56694,459.93281 314.75779,458.59376 311.625,458.59375 z"
id="path3196" />
<path
style="fill:url(#radialGradient3405);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:1, 3;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
d="M 413.00446,371.20089 C 411.74636,371.19959 410.45004,373.87997 409.34821,375.95089 L 403.34821,392.45089 C 403.84132,392.93115 404.27373,393.49259 404.59821,394.10714 C 406.00381,384.07022 412.01611,376.3216 419.44196,375.32589 L 419.22321,375.10714 C 419.0931,374.4929 418.71612,373.96112 418.16071,373.60714 C 417.56178,372.95245 416.94966,372.60345 416.31696,372.45089 C 415.39449,371.8587 414.21827,371.20214 413.00446,371.20089 z"
id="path3198" />
<path
id="path3229"
d="M 365.19643,458.59375 C 359.13589,458.59374 354.19643,463.62478 354.19643,469.84375 C 354.19642,474.73825 357.25551,478.88494 361.50893,480.4375 C 359.64052,478.41848 358.47768,475.68938 358.47768,472.6875 C 358.47768,466.46853 363.41714,461.43749 369.47768,461.4375 C 370.76425,461.4375 371.98788,461.6762 373.13393,462.09375 C 371.13837,459.93281 368.32922,458.59376 365.19643,458.59375 z"
style="fill:url(#radialGradient3402);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;marker:none;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:4;stroke-dasharray:1, 3;stroke-dashoffset:0;stroke-opacity:1;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
</g>
</g>
</svg>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment