root/releases/0.1.1b/units/users/user_info.php

Revision 2, 2.7 kB (checked in by sven, 3 years ago)

importing elgg-0.1.1a

Line 
1 <?php
2
3     // Given a title and series of user IDs as a parameter, will display a box containing the icons and names of each specified user
4     // $parameter[0] is the title of the box; $parameter[1..n] is the user ID
5
6     if (isset($parameter[0]) && sizeof($parameter) > 1 /*&& $parameter[1][0] != 0*/) {
7
8         if (sizeof($parameter[1]) > 1) {
9             $span = 2;
10         } else {
11             $span = 1;
12         }
13         
14         $name = $parameter[0];
15         
16         $i = 1;
17         if (sizeof($parameter[1]) == 0) {
18             
19             $body = "None.";
20             
21         } else {
22             $body .= <<< END
23             
24     <table align="center" border="0" class="userlist">
25         <tr>
26             
27 END;
28             foreach($parameter[1] as $key => $ident) {
29                 $ident = (int) $ident;
30                 // if (!isset($_SESSION['user_info_cache'][$ident])) {
31                     $info = db_query("select * from users where ident = $ident");
32                     $_SESSION['user_info_cache'][$ident] = $info[0];
33                     $info = $info[0];
34                 // }
35                 $info = $_SESSION['user_info_cache'][$ident];
36                 if ($info->icon != -1 && $info->icon != NULL) {
37                     // if (!isset($_SESSION['icon_cache'][$info->icon]) || (time() - $_SESSION['icon_cache'][$info->icon]->created > 60)) {
38                         $icon = db_query("select filename from icons where ident = " . $info->icon . " and owner = $ident");
39                         //$_SESSION['icon_cache'][$info->icon]->created = time();
40                         if (sizeof($icon) == 1) {
41                             //$_SESSION['icon_cache'][$info->icon]->data = $icon[0]->filename;
42                             $icon = $icon[0]->filename;
43                         } else {
44                             //$_SESSION['icon_cache'][$info->icon]->data = "default.png";
45                             $icon = "default.png";
46                         }
47                     // }
48                     // $icon = $_SESSION['icon_cache'][$info->icon]->data;
49                 } else {
50                     $icon = "default.png";
51                 }
52                 list($width, $height, $type, $attr) = getimagesize(path . "_icons/data/" . $icon);
53                 if (sizeof($parameter[1]) > 4) {
54                     $width = round($width / 2);
55                     $height = round($height / 2);
56                 }
57
58                 $username = htmlentities(stripslashes($info->name));
59                 $usermenu = run("users:infobox:menu",array($info->ident));
60                 
61                 $body .= <<< END
62         <td align="center" valign="top">
63             <a href="/{$info->username}/">
64             <img src="/_icons/data/{$icon}" width="{$width}" height="{$height}" alt="{$username}" border="0" /></a><br />
65             <span class="userdetails">{$username}{$usermenu}</span>
66         </td>
67 END;
68         
69                 if ($span == 1 || ($span == 2 && ($i % 2 == 0))) {
70                     $body .= "</tr><tr>";
71                 }
72                 $i++;
73             }
74              $body .= "</tr></table>";
75         }
76         if (isset($parameter[2]) && $parameter[2] != "") {
77             $body .= "<p align='center'>" . $parameter[2] . "</p>";
78         }
79         
80             $run_result .= run("templates:draw", array(
81                         'context' => 'infobox',
82                         'name' => $name,
83                         'contents' => $body
84                     )
85                     );
86         
87     }
88
89 ?>
Note: See TracBrowser for help on using the browser.