Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

MDL-25692 make search template to work for mssql + oracle

  • Loading branch information...
commit 5dd05d5a215c6d0aba62d7da44ed7ad10d5e4762 1 parent 3703965
Eloy Lafuente (stronk7) stronk7 authored
20 mod/data/field/latlong/field.class.php
@@ -70,17 +70,19 @@ function display_add_field($recordid=0) {
70 70
71 71 function display_search_field($value = '') {
72 72 global $CFG;
73   - $lats = get_records_sql_menu('SELECT id, content from '.$CFG->prefix.'data_content WHERE fieldid='.$this->field->id.' GROUP BY content ORDER BY content');
74   - $longs = get_records_sql_menu('SELECT id, content1 from '.$CFG->prefix.'data_content WHERE fieldid='.$this->field->id.' GROUP BY content ORDER BY content');
  73 + $varcharlat = sql_compare_text('content');
  74 + $varcharlong= sql_compare_text('content1');
  75 + $latlongsrs = get_recordset_sql(
  76 + "SELECT DISTINCT $varcharlat AS la, $varcharlong AS lo
  77 + FROM {$CFG->prefix}data_content
  78 + WHERE fieldid = {$this->field->id}
  79 + ORDER BY $varcharlat, $varcharlong");
75 80 $options = array();
76   - if(!empty($lats) && !empty($longs)) {
77   - $options[''] = '';
78   - // Make first index blank.
79   - foreach($lats as $key => $temp) {
80   - $options[$temp.','.$longs[$key]] = $temp.','.$longs[$key];
81   - }
  81 + while ($latlong = rs_fetch_next_record($latlongsrs)) {
  82 + $options[$latlong->la . ',' . $latlong->lo] = $latlong->la . ',' . $latlong->lo;
82 83 }
83   - return choose_from_menu($options, 'f_'.$this->field->id, $value, 'choose', '', 0, true);
  84 + rs_close($latlongsrs);
  85 + return choose_from_menu($options, 'f_'.$this->field->id, $value, 'choose', '', 0, true);
84 86 }
85 87
86 88 function parse_search_field() {
10 mod/data/field/menu/field.class.php
@@ -56,14 +56,16 @@ function display_add_field($recordid=0) {
56 56
57 57 return $str;
58 58 }
59   -
  59 +
60 60 function display_search_field($content = '') {
61 61 global $CFG;
62 62
63   - $usedoptions = array();
64   - $sql = "SELECT DISTINCT content
  63 + $varcharcontent = sql_compare_text('content', 255);
  64 + $sql = "SELECT DISTINCT $varcharcontent AS content
65 65 FROM {$CFG->prefix}data_content
66 66 WHERE fieldid={$this->field->id} AND content IS NOT NULL";
  67 +
  68 + $usedoptions = array();
67 69 if ($used = get_records_sql($sql)) {
68 70 foreach ($used as $data) {
69 71 $value = $data->content;
@@ -87,7 +89,7 @@ function display_search_field($content = '') {
87 89 return '';
88 90 }
89 91
90   - return choose_from_menu($options, 'f_'.$this->field->id, stripslashes($content), ' ', '', 0, true);
  92 + return choose_from_menu($options, 'f_'.$this->field->id, stripslashes($content), 'choose', '', 0, true);
91 93 }
92 94
93 95 function parse_search_field() {
6 mod/data/field/multimenu/field.class.php
@@ -78,10 +78,12 @@ function display_search_field($value = '') {
78 78 $str = '<select name="f_'.$this->field->id.'[]" multiple="multiple">';
79 79
80 80 // display only used options
81   - $usedoptions = array();
82   - $sql = "SELECT DISTINCT content
  81 + $varcharcontent = sql_compare_text('content', 255);
  82 + $sql = "SELECT DISTINCT $varcharcontent AS content
83 83 FROM {$CFG->prefix}data_content
84 84 WHERE fieldid={$this->field->id} AND content IS NOT NULL";
  85 +
  86 + $usedoptions = array();
85 87 if ($used = get_records_sql($sql)) {
86 88 foreach ($used as $data) {
87 89 $valuestr = $data->content;
22 mod/data/field/radiobutton/field.class.php
@@ -66,15 +66,21 @@ function display_add_field($recordid=0) {
66 66 $str .= '</div>';
67 67 return $str;
68 68 }
69   -
  69 +
70 70 function display_search_field($value = '') {
71 71 global $CFG;
72   - $temp = get_records_sql_menu('SELECT id, content from '.$CFG->prefix.'data_content WHERE fieldid='.$this->field->id.' GROUP BY content ORDER BY content');
  72 +
  73 + $varcharcontent = sql_compare_text('content', 255);
  74 + $used = get_records_sql(
  75 + "SELECT DISTINCT $varcharcontent AS content
  76 + FROM {$CFG->prefix}data_content
  77 + WHERE fieldid={$this->field->id}
  78 + ORDER BY $varcharcontent");
  79 +
73 80 $options = array();
74   - if(!empty($temp)) {
75   - $options[''] = ''; //Make first index blank.
76   - foreach ($temp as $key) {
77   - $options[$key] = $key; //Build following indicies from the sql.
  81 + if(!empty($used)) {
  82 + foreach ($used as $rec) {
  83 + $options[$rec->content] = $rec->content; //Build following indicies from the sql.
78 84 }
79 85 }
80 86 return choose_from_menu($options, 'f_'.$this->field->id, $value, 'choose', '', 0, true);
@@ -83,9 +89,9 @@ function display_search_field($value = '') {
83 89 function parse_search_field() {
84 90 return optional_param('f_'.$this->field->id, '', PARAM_NOTAGS);
85 91 }
86   -
  92 +
87 93 function generate_sql($tablealias, $value) {
88   - return " ({$tablealias}.fieldid = {$this->field->id} AND {$tablealias}.content = '$value') ";
  94 + return " ({$tablealias}.fieldid = {$this->field->id} AND {$tablealias}.content = '$value') ";
89 95 }
90 96
91 97 }

0 comments on commit 5dd05d5

Please sign in to comment.
Something went wrong with that request. Please try again.