]> git.mjollnir.org Git - moodle.git/commitdiff
[MDL-15425] Search Filters are too persistant. Merged from MOODLE_19_STABLE.
authorrobertall <robertall>
Fri, 24 Oct 2008 20:17:10 +0000 (20:17 +0000)
committerrobertall <robertall>
Fri, 24 Oct 2008 20:17:10 +0000 (20:17 +0000)
mod/data/lib.php
mod/data/view.php

index 7ac3f844df3f206749dcacaef7c681128c214334..d097bc337495cf38d26c60d364b2c1bf4773b8e6 100755 (executable)
@@ -959,9 +959,8 @@ function data_get_participants($dataid) {
  *       @param string $template                                        *
  * output null                                                          *
  ************************************************************************/
-function data_print_template($template, $records, $data, $search='',$page=0, $return=false) {
+function data_print_template($template, $records, $data, $search='', $page=0, $return=false) {
     global $CFG, $DB;
-
     $cm = get_coursemodule_from_instance('data', $data->id);
     $context = get_context_instance(CONTEXT_MODULE, $cm->id);
 
@@ -1011,10 +1010,14 @@ function data_print_template($template, $records, $data, $search='',$page=0, $re
             $replacement[] = '';
             $replacement[] = '';
         }
+
+        $moreurl = $CFG->wwwroot . '/mod/data/view.php?d=' . $data->id . '&amp;rid=' . $record->id;
+        $search && $moreurl .= '&amp;filter=1';
         $patterns[]='##more##';
-        $replacement[] = '<a href="'.$CFG->wwwroot.'/mod/data/view.php?d='.$data->id.'&amp;rid='.$record->id.'"><img src="'.$CFG->pixpath.'/i/search.gif" class="iconsmall" alt="'.get_string('more', 'data').'" title="'.get_string('more', 'data').'" /></a>';
+        $replacement[] = '<a href="' . $moreurl . '"><img src="' . $CFG->pixpath . '/i/search.gif" class="iconsmall" alt="' . get_string('more', 'data') . '" title="' . get_string('more', 'data') . '" /></a>';
+
         $patterns[]='##moreurl##';
-        $replacement[] = $CFG->wwwroot.'/mod/data/view.php?d='.$data->id.'&amp;rid='.$record->id;
+        $replacement[] = $moreurl;
 
         $patterns[]='##user##';
         $replacement[] = '<a href="'.$CFG->wwwroot.'/user/view.php?id='.$record->userid.
@@ -1207,6 +1210,7 @@ function data_print_preference_form($data, $perpage, $search, $sort='', $order='
         //]]>
         </script>';
     echo '&nbsp;<input type="hidden" name="advanced" value="0" />';
+    echo '&nbsp;<input type="hidden" name="filter" value="1" />';
     echo '&nbsp;<input type="checkbox" id="advancedcheckbox" name="advanced" value="1" '.$checked.' onchange="showHideAdvSearch(this.checked);" /><label for="advancedcheckbox">'.get_string('advancedsearch', 'data').'</label>';
     echo '&nbsp;<input type="submit" value="'.get_string('savesettings','data').'" />';
 
index 63c91f0ef475e1e3cf18877f29d011ad83c0465e..dd1b690c7a6779753ed4eca559a864139b787af6 100755 (executable)
     require_once('pagelib.php');
 
 /// One of these is necessary!
-    $id    = optional_param('id', 0, PARAM_INT);  // course module id
-    $d     = optional_param('d', 0, PARAM_INT);   // database id
-    $rid   = optional_param('rid', 0, PARAM_INT);    //record id
-
-    $mode  = optional_param('mode', '', PARAM_ALPHA);    // Force the browse mode  ('single')
+    $id = optional_param('id', 0, PARAM_INT);  // course module id
+    $d = optional_param('d', 0, PARAM_INT);   // database id
+    $rid = optional_param('rid', 0, PARAM_INT);    //record id
+    $mode = optional_param('mode', '', PARAM_ALPHA);    // Force the browse mode  ('single')
+    $filter = optional_param('filter', 0, PARAM_BOOL);
+    // search filter will only be applied when $filter is true
 
     $edit = optional_param('edit', -1, PARAM_BOOL);
     $page = optional_param('page', 0, PARAM_INT);
         //(even if page 0 is revisited).
         //A false $paging flag generates advanced search results based on the fields input by the user.
         //A true $paging flag generates davanced search results from the $SESSION global.
-        //(See lines 147-158)
 
         $paging = optional_param('paging', NULL, PARAM_BOOL);
         if($page == 0 && !isset($paging)) {
         $paging = NULL;
     }
 
+    // Disable search filters if $filter is not true:
+    $filter || $search = '';
+
     $textlib = textlib_get_instance();
     if ($textlib->strlen($search) < 2) {
         $search = '';
             }
 
             if ($mode == 'single') {                  // Single template
-                $baseurl = 'view.php?d='.$data->id.'&amp;mode=single&amp;';
-
+                $baseurl = 'view.php?d=' . $data->id . '&amp;mode=single&amp;';
+                $search && $baseurl .= 'filter=1&amp;';
                 print_paging_bar($totalcount, $page, $nowperpage, $baseurl, $pagevar='page');
 
                 if (empty($data->singletemplate)){