From 2acbdb84d66ae1e6defdbdd5ce97bfeec3419818 Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Tue, 26 Aug 2014 13:40:15 +0000 Subject: [PATCH] Backport commit r48253, committed by Nathan Gray. - validate filters when getting rows - run method (beforeSendToClient, validate) needs to include all sub-templates (header_left, header_right, header_row, template) or those widgets get left out. --- .../class.etemplate_widget_nextmatch.inc.php | 26 ++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/etemplate/inc/class.etemplate_widget_nextmatch.inc.php b/etemplate/inc/class.etemplate_widget_nextmatch.inc.php index b833379eff..202de6b2e9 100644 --- a/etemplate/inc/class.etemplate_widget_nextmatch.inc.php +++ b/etemplate/inc/class.etemplate_widget_nextmatch.inc.php @@ -289,6 +289,22 @@ class etemplate_widget_nextmatch extends etemplate_widget { $value = ($value) ? array($value) : array(); } + + // Validate filters + if (($template = etemplate_widget_template::instance(self::$request->template['name'], self::$request->template['template_set'], + self::$request->template['version'], self::$request->template['load_via']))) + { + $template = $template->getElementById($form_name); + $expand = array( + 'cont' => array($form_name => $filters), + ); + $valid_filters = array(); + + $template->run('validate', array('', $expand, $expand['cont'], &$valid_filters), false); // $respect_disabled=false: as client may disable things, here we validate everything and leave it to the get_rows to interpret + $filters = $valid_filters[$form_name]; + //error_log($this . " Valid filters: " . array2string($filters)); + } + $value = $value_in = array_merge($value, $filters); //error_log(__METHOD__."('".substr($exec_id,0,10)."...', range=".array2string($queriedRange).', filters='.array2string($filters).", '$form_name', knownUids=".array2string($knownUids).", lastModified=$lastModified) parent_id=$value[parent_id], is_parent=$value[is_parent]"); @@ -987,10 +1003,14 @@ class etemplate_widget_nextmatch extends etemplate_widget parent::run($method_name, $params, $respect_disabled); if ($this->id) $cname = self::form_name($cname, $this->id, $params[1]); - if ($this->attrs['template']) + // Run on all the sub-templates + foreach(array('template', 'header_left', 'header_right', 'header_row') as $sub_template) { - $row_template = etemplate_widget_template::instance($this->attrs['template']); - $row_template->run($method_name, $params, $respect_disabled); + if($this->attrs[$sub_template]) + { + $row_template = etemplate_widget_template::instance($this->attrs[$sub_template]); + $row_template->run($method_name, $params, $respect_disabled); + } } } $params[0] = $old_param0;