3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.4 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
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-2013
40 * Smarty function for checking change in a property's value, for example
41 * when looping through an array.
44 * Smarty param: string $key unique identifier for this property (REQUIRED)
45 * Smarty param: mixed $value the current value of the property
46 * Smarty param: string $assign name of template variable to which to assign result
49 * @param array $params template call's parameters
50 * @param object $smarty the Smarty object
54 function smarty_function_isValueChange($params, &$smarty) {
55 static $values = array();
57 if (empty($params['key'])) {
58 $smarty->trigger_error("Missing required parameter, 'key', in isValueChange plugin.");
64 if (!array_key_exists($params['key'], $values) ||
$params['value'] != $values[$params['key']]) {
65 // if we have a new value
69 $values[$params['key']] = $params['value'];
71 // clear values on all properties added below/after this property
73 foreach ($values as $k => $dontcare) {
77 elseif ($params['key'] == $k) {
83 if ($params['assign']) {
84 $smarty->assign($params['assign'], $is_changed);