3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
13 * CiviCRM's Smarty looped value change plugin
15 * Checks for change in value of given key
18 * @author Allen Shaw <allen@nswebsolutions.com>
19 * @copyright CiviCRM LLC https://civicrm.org/licensing
24 * Smarty function for checking change in a property's value, for example
25 * when looping through an array.
27 * Smarty param: string $key unique identifier for this property (REQUIRED)
28 * Smarty param: mixed $value the current value of the property
29 * Smarty param: string $assign name of template variable to which to assign result
32 * @param array $params
33 * Template call's parameters.
34 * @param CRM_Core_Smarty $smarty
39 function smarty_function_isValueChange($params, &$smarty) {
42 if (empty($params['key'])) {
43 $smarty->trigger_error("Missing required parameter, 'key', in isValueChange plugin.");
49 if (!array_key_exists($params['key'], $values) ||
strcasecmp($params['value'], $values[$params['key']]) !== 0) {
50 // if we have a new value
54 $values[$params['key']] = $params['value'];
56 // clear values on all properties added below/after this property
58 foreach ($values as $k => $dontcare) {
62 elseif ($params['key'] == $k) {
68 if ($params['assign']) {
69 $smarty->assign($params['assign'], $is_changed);