Changeset 543

Show
Ignore:
Timestamp:
09/13/06 12:41:44 (2 years ago)
Author:
ben
Message:

Search now allows you to toggle between 'all', 'communities', 'people'. This is extensible: plugins can add other user_type values to filter to. See mod/community/lib.php for an example.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • devel/mod/community/lib.php

    r499 r543  
    5858         
    5959    } 
     60     
     61    $PAGE->search_menu[] = array( 'name' => gettext("Communities"), 
     62                                  'user_type' => 'community'); 
    6063 
    6164} 
  • devel/mod/profile/lib.php

    r527 r543  
    3636        } 
    3737    } 
     38     
     39    $PAGE->search_menu[] = array( 'name' => gettext("People"), 
     40                                  'user_type' => 'person'); 
     41 
    3842} 
    3943 
  • devel/search/index.php

    r526 r543  
    33    //    ELGG profile search page 
    44 
     5        global $PAGE, $db, $search_exclusions; 
     6     
    57    // Run includes 
    68        require_once(dirname(dirname(__FILE__))."/includes.php"); 
     
    1315        $title = gettext("Search"); 
    1416        templates_page_setup(); 
    15  
    16         $body = run("content:profile:search"); 
     17         
     18        $PAGE->search_type_unformatted = optional_param('user_type',''); 
     19        $PAGE->search_type = $db->qstr($PAGE->search_type_unformatted); 
     20         
     21        $querystring = ""; 
     22        if (isset($_GET) && !empty($_GET)) { 
     23            foreach($_GET as $key => $value) { 
     24                if ($key != 'user_type') { 
     25                    if (!empty($querystring)) { 
     26                        $querystring .= "&"; 
     27                    } 
     28                    $querystring .= urlencode($key); 
     29                    $querystring .= "="; 
     30                    $querystring .= urlencode(optional_param($key,'')); 
     31                } 
     32            } 
     33        } 
     34        $querystring = $CFG->wwwroot . "search/index.php?" . $querystring; 
     35         
     36        $body .= "<p>" . gettext("Searching") . " "; 
     37         
     38        if ($PAGE->search_type  == "''") { 
     39            $body .= "<b class=\"selected_search_type\">"; 
     40        } 
     41        $body .= "<a href=\"$querystring\">" . gettext("All") . "</a> "; 
     42        if ($PAGE->search_type  == "''") { 
     43            $body .= "</b>"; 
     44        } 
     45               
     46        if (isset($PAGE->search_menu) && is_array($PAGE->search_menu) && !empty($PAGE->search_menu)) { 
     47            foreach($PAGE->search_menu as $search_type) { 
     48                if ($PAGE->search_type_unformatted == $search_type['user_type']) { 
     49                    $body .= "<b class=\"selected_search_type\">"; 
     50                } 
     51                $body .= "<a href=\"$querystring&user_type=" . $search_type['user_type'] . "\">" . $search_type['name'] . "</a> "; 
     52                if ($PAGE->search_type_unformatted == $search_type['user_type']) { 
     53                    $body .= "</b>"; 
     54                } 
     55            } 
     56        } 
     57        $body .= "</p>"; 
     58         
    1759        $body .= run("search:display"); 
    1860         
  • devel/units/files/function_search.php

    r458 r543  
    11<?php 
    2 global $CFG,$USER
     2global $CFG,$USER,$PAGE
    33global $db; 
    44global $search_exclusions; 
     
    2323        } 
    2424        $searchline = " ff.ident IN (" . implode(", ", $searchlist) . ") "; 
     25        if (!empty($PAGE->search_type_unformatted)) { 
     26            $searchline .= " AND u.user_type = " . $PAGE->search_type; 
     27        } 
    2528        $folders = get_records_sql('SELECT ff.name,u.name AS userfullname,u.ident as userid,u.username,ff.ident  
    2629                                    FROM '.$CFG->prefix.'file_folders ff 
  • devel/units/profile/function_search.php

    r458 r543  
    11<?php 
    2 global $CFG; 
    3 global $db; 
     2 
     3global $CFG, $db, $PAGE; 
     4 
    45    // Search criteria are passed in $parameter from run("search:display") 
    56     
     
    1718            $searchline = "tagtype = " . $db->qstr($parameter[0]) . " AND tag = " . $db->qstr($parameter[1]) . ""; 
    1819            $searchline = "(" . run("users:access_level_sql_where",$_SESSION['userid']) . ") and " . $searchline; 
     20            if (!empty($PAGE->search_type_unformatted)) { 
     21                $searchline .= " AND u.user_type = " . $PAGE->search_type; 
     22            } 
     23             
    1924            $searchline = str_replace("owner","t.owner",$searchline); 
    2025             
     
    4853                    $friends_name = run("profile:display:name",$info->ident); 
    4954                    $info->icon = run("icons:get",$info->ident); 
    50                     $friends_menu = run("users:infobox:menu",array($info->ident)); 
    5155                    $body .= <<< END 
    5256        <td align="center"> 
     
    5559            <img src="{$CFG->wwwroot}{$friends_username}/icons/{$info->icon}/w/{$w}" alt="{$friends_name}" border="0" /></a><br /> 
    5660            <span class="userdetails"> 
    57                 {$friends_name} 
    58                 {$friends_menu} 
     61                <a href="{$CFG->wwwroot}{$friends_username}/">{$friends_name}</a> 
    5962            </span> 
    6063            </p> 
  • devel/units/search/function_display.php

    r269 r543  
    1616     
    1717            foreach($query as $field => $value) { 
    18                 if ($field != user_session_name && $field != "ref" && $field != "owner" && $field != "psaContext" && $field != "PHPSESSID") { 
     18                if ($field != user_session_name && $field != "ref" && $field != "owner" && $field != "psaContext" && $field != "PHPSESSID" && $field != "user_type") { 
    1919                    // $searchline = "tagtype = '".addslashes($field)."' and tag = '".addslashes($value)."'"; 
    2020                    $run_result .= run("search:display_results", array($field,$value)); 
  • devel/units/search/function_search_all_display.php

    r269 r543  
    1414         
    1515    } 
    16     if ($tag != "ref" && $tag != "owner" && $tag != user_session_name) { 
     16    if ($tag != "ref" && $tag != "owner" && $tag != user_session_name && $tag != "user_type") { 
    1717        $run_result .= run("search:tags:suggest",$tag); 
    1818        $run_result .= run("search:users:suggest",$tag); 
  • devel/units/weblogs/function_search.php

    r458 r543  
    11<?php 
    2 global $CFG, $USER, $db
     2global $CFG, $USER, $db, $PAGE
    33global $search_exclusions; 
    44     
     
    1717        $searchline = "(" . run("users:access_level_sql_where",$_SESSION['userid']) . ") AND " . $searchline; 
    1818        $searchline = str_replace("owner","t.owner",$searchline); 
     19        if (!empty($PAGE->search_type_unformatted)) { 
     20            $searchline .= " AND u.user_type = " . $PAGE->search_type; 
     21        } 
    1922        if ($refs = get_records_select('tags t',$searchline)) { 
    2023            $searchline = "";