root/releases/0.1.2a/units/profile/function_search.php

Revision 7, 2.2 kB (checked in by sven, 3 years ago)

snapshot of elgg 0.1.2a

Line 
1 <?php
2
3     // Search criteria are passed in $parameter from run("search:display")
4     
5         $url = url;
6         $handle = 0;
7         foreach($data['profile:details'] as $profiletype) {
8             if ($profiletype[1] == $parameter[0] && $profiletype[2] == "keywords") {
9                 $handle = 1;
10             }
11         }
12     
13         if ($handle) {
14             
15             $searchline = "tagtype = '".addslashes($parameter[0])."' and tag = '".addslashes($parameter[1])."'";
16             $searchline = "(" . run("users:access_level_sql_where",$_SESSION['userid']) . ") and " . $searchline;
17             $result = db_query("select distinct users.* from tags left join users on users.ident = tags.owner where $searchline");
18
19             $parameter[1] = stripslashes($parameter[1]);
20             
21             if (sizeof ($result) > 0) {
22 $body = <<< END
23             
24     <h2>
25         Profiles where
26 END;
27                 $body .= "'".$parameter[0]."' includes '".$parameter[1]."':";
28                 $body .= <<< END
29     </h2>
30 END;
31                 $body .= <<< END
32     <table class="userlist">
33         <tr>
34 END;
35                 $i = 1;
36                 foreach($result as $key => $info) {
37     
38                     // $info = $info[0];
39                     if ($info->icon != -1) {
40                         $icon = db_query("select filename from icons where ident = " . $info->icon . " and owner = " . $info->ident);
41                         if (sizeof($icon) == 1) {
42                             $icon = $icon[0]->filename;
43                         } else {
44                             $icon = "default.png";
45                         }
46                     } else {
47                         $icon = "default.png";
48                     }
49                     list($width, $height, $type, $attr) = getimagesize(path . "_icons/data/" . $icon);
50                     if (sizeof($parameter[1]) > 4) {
51                         $width = round($width / 2);
52                         $height = round($height / 2);
53                     }
54                     $friends_username = stripslashes($info->username);
55                     $friends_name = htmlentities(stripslashes($info->name));
56                     $friends_menu = run("users:infobox:menu",array($info->ident));
57                     $body .= <<< END
58         <td align="center">
59             <a href="{$url}{$friends_username}/">
60             <img src="{$url}_icons/data/{$icon}" width="{$width}" height="{$height}" alt="{$friends_name}" border="0" /></a><br />
61             <span class="userdetails">
62                 {$friends_name}
63                 {$friends_menu}
64             </span>
65         </td>
66 END;
67                     if ($i % 5 == 0) {
68                         $body .= "</tr><tr>";
69                     }
70                     $i++;
71                 }
72                 $body .= <<< END
73     </tr>
74     </table>
75 END;
76                 $run_result .= $body;
77             }
78         }
79
80 ?>
Note: See TracBrowser for help on using the browser.