3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
29 * CiviCRM's Smarty looped value change plugin
31 * Checks for change in value of given key
34 * @author Allen Shaw <allen@nswebsolutions.com>
35 * @copyright CiviCRM LLC (c) 2004-2015
40 * Smarty function for checking change in a property's value, for example
41 * when looping through an array.
43 * Smarty param: string $key unique identifier for this property (REQUIRED)
44 * Smarty param: mixed $value the current value of the property
45 * Smarty param: string $assign name of template variable to which to assign result
48 * @param array $params
49 * Template call's parameters.
50 * @param CRM_Core_Smarty $smarty
55 function smarty_function_isValueChange($params, &$smarty) {
56 static $values = array();
58 if (empty($params['key'])) {
59 $smarty->trigger_error("Missing required parameter, 'key', in isValueChange plugin.");
65 if (!array_key_exists($params['key'], $values) ||
strcasecmp($params['value'], $values[$params['key']]) !== 0) {
66 // if we have a new value
70 $values[$params['key']] = $params['value'];
72 // clear values on all properties added below/after this property
74 foreach ($values as $k => $dontcare) {
78 elseif ($params['key'] == $k) {
84 if ($params['assign']) {
85 $smarty->assign($params['assign'], $is_changed);