Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
form_question_rule_type_contain_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_contain_edit_'.(array_get_index($rule_data, 'operator', 1) ? 'true' : 'false').($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', 1));
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->openField(translate('core_form_case_sensitive_question'));
79  // give a text box to write the comparison value in
80  check_box($prefix.'[case]', 1, array_get_index($rule_data, 'case_sensitive', 1));
81  $o->closeField();
82 
83  $o->sectionNote(translate('core_form_rule_static_or_question_note'));
84  }
85 
86  return $write_access;
87 
88  }//end paintRule()
89 
90 
97  function processRule(&$asset, &$o, $prefix, &$rule_data)
98  {
99  if (!isset($_POST[$prefix])) return false;
100 
101  $operator = array_get_index($_POST[$prefix], 'operator', 1);
102  $comparison = array_get_index($_POST[$prefix], 'value', null);
103  $comp_asset = array_get_index($_POST[$prefix], 'asset', null);
104  $case = array_get_index($_POST[$prefix], 'case', 0);
105 
106  $rule_data['operator'] = $operator;
107  $rule_data['case_sensitive'] = $case;
108  if (is_null($comp_asset) || ($comp_asset['assetid'] == '0')) {
109  $rule_data['value'] = $comparison;
110  $rule_data['comparison_question_id'] = '0';
111  } else {
112  $rule_data['comparison_question_id'] = $comp_asset['assetid'];
113  $rule_data['value'] = null;
114  }
115 
116  return true;
117 
118  }//end processRule()
119 
120 
121 }//end class
122 ?>