Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
form_question_rule_type_comparison_edit_fns.inc
1 <?php
18 require_once dirname(__FILE__).'/../../form_question_rule/form_question_rule_edit_fns.inc';
19 
32 {
33 
34 
40  {
42 
43  }//end constructor
44 
45 
46  function paintRule(&$asset, &$o, $prefix, $rule_data, $write_access)
47  {
48  $operator_list = $asset->getOperators();
49 
50  if (!$write_access) {
51  $o->openField(translate('core_form_rule_details'));
52  if (($cq_id = array_get_index($rule_data, 'comparison_question_id', 0)) != 0) {
53  $value = get_asset_tag_line($cq_id);
54  } else {
55  $value = array_get_index($rule_data, 'value', '');
56  }
57 
58  echo translate('core_form_rule_comparison_edit_'.array_get_index($rule_data, 'operator', '==').($cq_id ? '_q' : ''), $value);
59  $o->closeField();
60 
61  } else {
62 
63  $o->openField(translate('operator'));
64  // list of operators
65  combo_box($prefix.'[operator]', $operator_list, false, array_get_index($rule_data, 'operator', '=='));
66  $o->closeField();
67 
68  $o->openField(translate('core_form_rule_static_value'));
69  // give a text box to write the comparison value in
70  text_box($prefix.'[value]', array_get_index($rule_data, 'value', ''), 30);
71  $o->closeField();
72 
73  $o->openField(translate('core_form_rule_or_value_of_question'));
74  // give a text box to write the comparison value in
75  asset_finder($prefix.'[asset]', array_get_index($rule_data, 'comparison_question_id', '0'), Array('form_question' => 'D'));
76  $o->closeField();
77 
78  $o->sectionNote(translate('core_form_rule_static_or_question_note'));
79  }
80 
81  return $write_access;
82 
83  }//end paintRule()
84 
85 
92  function processRule(&$asset, &$o, $prefix, &$rule_data)
93  {
94  if (!isset($_POST[$prefix])) return false;
95 
96  $operator = array_get_index($_POST[$prefix], 'operator', null);
97  $comparison = array_get_index($_POST[$prefix], 'value', null);
98  $comp_asset = array_get_index($_POST[$prefix], 'asset', null);
99 
100  $rule_data['operator'] = $operator;
101  if (is_null($comp_asset) || ($comp_asset['assetid'] == '0')) {
102  $rule_data['value'] = $comparison;
103  $rule_data['comparison_question_id'] = '0';
104  } else {
105  $rule_data['comparison_question_id'] = $comp_asset['assetid'];
106  $rule_data['value'] = null;
107  }
108 
109  return true;
110 
111  }//end processRule()
112 
113 
114 }//end class
115 ?>