Ignore:
Timestamp:
12/04/08 14:28:48 (3 years ago)
Author:
WanWizard
Message:

rewritten part of the search module logic. Now a session variable is used to store the search parameters, so they don't have to be exposed in the URL anymore
fixed some syntax errors in queries when using MySQL5.x
fixed some layout and locale issues in the search module output

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/search/search.members.php

    r1935 r2090  
    3333    } else { 
    3434 
    35         // get the required variables (could be POST or GET vars!) 
    36         if (isset($stext)) { 
    37             $stext = stripinput($stext); 
     35        // make sure the sub search ID is defined 
     36        if (!isset($sub_search_id)) $sub_search_id = 0; 
     37 
     38        // retrieve the search criteria 
     39        if (isset($_SESSION['search'])) { 
     40            // from the session store (used when paging through the results) 
     41            $stext = $_SESSION['search']['stext']; 
     42            $qtype = $_SESSION['search']['qtype']; 
     43            $datelimit = $_SESSION['search']['datelimit']; 
     44            $boolean = $_SESSION['search']['boolean']; 
     45            $sortby = $_SESSION['search']['sortby']; 
     46            $order = $_SESSION['search']['order']; 
     47            $limit = $_SESSION['search']['limit']; 
     48            $contentfilter_forums = $_SESSION['search']['contentfilter_forums']; 
     49            $contentfilter_users = $_SESSION['search']['contentfilter_users']; 
    3850        } else { 
     51            // from the search form 
    3952            $stext = isset($_POST['stext']) ? stripinput($_POST['stext']) : ""; 
     53            $stext = str_replace(',', ' ', $stext); 
     54            $boolean = isset($_POST['boolean']) ? 0 : 1; 
     55            $qtype = isset($_POST['qtype']) ? stripinput($_POST['qtype']) : "AND"; 
     56            if ($qtype != "OR" && $qtype != "AND") { 
     57                $qtype = "AND"; 
     58            } 
     59            $sortby = isset($_POST['sortby']) ? stripinput($_POST['sortby']) : "score"; 
     60            if (!in_array($sortby, $select_filters)) { 
     61                $sortby = $select_filters[0]; 
     62            } 
     63            $order = isset($_POST['order']) && isNum($_POST['order']) ? $_POST['order'] : 1; 
     64            $limit = isset($_POST['limit']) && isNum($_POST['limit']) ? $_POST['limit'] : 0; 
     65            $datelimit = isset($_POST['datelimit']) && isNum($_POST['datelimit']) ? $_POST['datelimit'] : 0; 
     66            // add a forum filter if requested 
     67            if (isset($_POST['contentfilter_forums']) && isNum($_POST['contentfilter_forums']) && $_POST['contentfilter_forums'] > 0 ) { 
     68                $contentfilter_forums =  stripinput($_POST['contentfilter_forums']); 
     69            } 
     70            // add an author if requested 
     71            if (isset($_POST['contentfilter_users']) && isNum($_POST['contentfilter_users']) && $_POST['contentfilter_users'] > 0 ) { 
     72                $contentfilter_users = stripinput($_POST['contentfilter_users']); 
     73            } 
    4074        } 
    41         $stext = str_replace(',', ' ', $stext); 
    4275        $variables['stext'] = $stext; 
    4376 
    44         if (!isset($qtype)) { 
    45             $qtype = isset($_POST['qtype']) ? $_POST['qtype'] : "AND"; 
    46         } 
    47         if ($qtype != "OR" && $qtype != "AND") { 
    48             $qtype = "AND"; 
    49         } 
    50         if (!isset($datelimit)) { 
    51             $datelimit = isset($_POST['datelimit']) ? $_POST['datelimit'] : 0; 
    52         } 
    53         if (!isNum($datelimit)) { 
    54             $datelimit = 0; 
    55         } 
    56         if (!isset($sortby)) { 
    57             $sortby = isset($_POST['sortby']) ? $_POST['sortby'] : "score"; 
    58         } 
    59         if (!in_array($sortby, $select_filters)) { 
    60             $sortby = $select_filters[0]; 
    61         } 
    62         if (!isset($order)) { 
    63             $order = isset($_POST['order']) ? $_POST['order'] : 1; 
    64         } 
    65         if (!isNum($order)) { 
    66             $order = 1; 
    67         } 
    68         if (!isset($limit)) { 
    69             $limit = isset($_POST['limit']) ? $_POST['limit'] : 0; 
    70         } 
    71         if (!isNum($limit)) { 
    72             $limit = 0; 
    73         } 
    74         if (!isset($boolean)) { 
    75             $boolean = isset($_POST['boolean']) ? 0 : 1; 
    76         } 
    77  
    78         if (!isset($sub_search_id)) $sub_search_id = 0; 
    79  
    80         // construct the page navigator URL to allow paging 
    81         $variables['pagenav_url'] = FUSION_SELF."?action=search&search_id=".$search_id."&"; 
    82         $variables['pagenav_url'] .= "stext=".urlencode($stext)."&"; 
    83         $variables['pagenav_url'] .= "boolean=".$boolean."&"; 
    84         $variables['pagenav_url'] .= "datelimit=".$datelimit."&"; 
    85         $variables['pagenav_url'] .= "sortby=".$sortby."&"; 
    86         $variables['pagenav_url'] .= "order=".$order."&"; 
    87         $variables['pagenav_url'] .= "limit=".$limit."&"; 
     77        // store the search parameters in the session record 
     78        $_SESSION['search'] = array('stext' => $stext, 
     79                                    'qtype' => $qtype, 
     80                                    'datelimit' => $datelimit, 
     81                                    'boolean' => $boolean, 
     82                                    'sortby' => $sortby, 
     83                                    'order' => $order, 
     84                                    'limit' => $limit, 
     85                                    'contentfilter_forums' => $contentfilter_forums, 
     86                                    'contentfilter_users' => $contentfilter_users 
     87                                ); 
    8888 
    8989        // basis of the query for this search 
Note: See TracChangeset for help on using the changeset viewer.