Skip to content
Browse files

MDL-25275 - mod/data - Added a check box to eliminate date searches i…

…f desired.
  • Loading branch information...
1 parent 59d9b1b commit caa0e70577066e4ad96fc58b6125246af0afc63f @abgreeve abgreeve committed with Sam Hemelryk Oct 9, 2012
Showing with 15 additions and 12 deletions.
  1. +14 −12 mod/data/field/date/field.class.php
  2. +1 −0 mod/data/lang/en/data.php
View
26 mod/data/field/date/field.class.php
@@ -55,12 +55,13 @@ function display_add_field($recordid=0) {
//Enable the following three functions once core API issues have been addressed.
function display_search_field($value=0) {
- $selectors = html_writer::select_time('days', 'f_'.$this->field->id.'_d', $value)
- . html_writer::select_time('months', 'f_'.$this->field->id.'_m', $value)
- . html_writer::select_time('years', 'f_'.$this->field->id.'_y', $value);
- return $selectors;
+ $selectors = html_writer::select_time('days', 'f_'.$this->field->id.'_d', $value['timestamp'])
+ . html_writer::select_time('months', 'f_'.$this->field->id.'_m', $value['timestamp'])
+ . html_writer::select_time('years', 'f_'.$this->field->id.'_y', $value['timestamp']);
+ $datecheck = html_writer::checkbox('f_'.$this->field->id.'_z', 1, $value['usedate']);
+ $str = $selectors . ' ' . $datecheck . ' ' . get_string('usedate', 'data');
- //return print_date_selector('f_'.$this->field->id.'_d', 'f_'.$this->field->id.'_m', 'f_'.$this->field->id.'_y', $value, true);
+ return $str;
}
function generate_sql($tablealias, $value) {
@@ -70,21 +71,22 @@ function generate_sql($tablealias, $value) {
$i++;
$name = "df_date_$i";
$varcharcontent = $DB->sql_compare_text("{$tablealias}.content");
- return array(" ({$tablealias}.fieldid = {$this->field->id} AND $varcharcontent = :$name) ", array($name=>$value));
+ return array(" ({$tablealias}.fieldid = {$this->field->id} AND $varcharcontent = :$name) ", array($name => $value['timestamp']));
}
function parse_search_field() {
-
$day = optional_param('f_'.$this->field->id.'_d', 0, PARAM_INT);
$month = optional_param('f_'.$this->field->id.'_m', 0, PARAM_INT);
$year = optional_param('f_'.$this->field->id.'_y', 0, PARAM_INT);
- if (!empty($day) && !empty($month) && !empty($year)) {
- return make_timestamp($year, $month, $day, 12, 0, 0, 0, false);
- }
- else {
+ $usedate = optional_param('f_'.$this->field->id.'_z', 0, PARAM_INT);
+ $data = array();
+ if (!empty($day) && !empty($month) && !empty($year) && $usedate == 1) {
+ $data['timestamp'] = make_timestamp($year, $month, $day, 12, 0, 0, 0, false);
+ $data['usedate'] = 1;
+ return $data;
+ } else {
return 0;
}
-
}
function update_content($recordid, $value, $name='') {
View
1 mod/data/lang/en/data.php
@@ -338,6 +338,7 @@
The field enclosure is a character that surrounds each field in each record. It can normally be left unset.';
$string['uploadrecords_link'] = 'mod/data/import';
$string['url'] = 'Url';
+$string['usedate'] = 'Include in search.';
$string['usestandard'] = 'Use a preset';
$string['usestandard_help'] = 'To use a preset available to the whole site, select it from the list. (If you have added a preset to the list using the save as preset feature then you have the option of deleting it.)';
$string['viewfromdate'] = 'Read only from';

0 comments on commit caa0e70

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