source: trunk/gm_system/users/user_existing_menubox.php@ 638

Last change on this file since 638 was 638, checked in by barny, 16 years ago
File size: 2.4 KB
Line 
1<?php
2/*
3 $Id: user_existing_menubox.php 2303 2009-08-25 09:17:44Z andrewsimpson $
4
5 (c) 2002 - 2008 Andrew Simpson <andrew.simpson at paradise.net.nz>
6
7 WebCollab
8 ---------------------------------------
9
10 This program is free software; you can redistribute it and/or modify it under the
11 terms of the GNU General Public License as published by the Free Software Foundation;
12 either version 2 of the License, or (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
16 PARTICULAR PURPOSE. See the GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License along with this
19 program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave,
20 Cambridge, MA 02139, USA.
21
22 Function:
23 ---------
24
25 The menu box that contains the user list
26
27*/
28
29//security check
30if(! defined('UID' ) ) {
31 die('Direct file access not permitted' );
32}
33
34$content = '';
35$allowed = array();
36
37//get list of common users in private usergroups that this user can view
38$q = db_query('SELECT '.PRE.'usergroups_users.usergroupid AS usergroupid,
39 '.PRE.'usergroups_users.userid AS userid
40 FROM '.PRE.'usergroups_users
41 LEFT JOIN '.PRE.'usergroups ON ('.PRE.'usergroups.id='.PRE.'usergroups_users.usergroupid)
42 WHERE '.PRE.'usergroups.private=1');
43
44for( $i=0 ; $row = @db_fetch_num($q, $i ) ; ++$i ) {
45 if(isset($GID[($row[0])] ) ) {
46 $allowed[($row[1])] = $row[1];
47 }
48}
49
50$content = "<table style=\"text-align:left\">\n";
51
52//query users
53$q = db_query('SELECT id, fullname, private FROM '.PRE.'users WHERE deleted=\'f\' ORDER by fullname' );
54
55//show them
56for($i=0 ; $row = @db_fetch_array($q, $i ) ; ++$i ) {
57
58 //user test for privacy
59 if($row['private'] && ($row['id'] != UID ) && ( ! ADMIN ) && (! isset($allowed[($row['id'])] ) ) ){
60 continue;
61 }
62
63 $content .= "<tr><td><small><a href=\"users.php?x=".X."&amp;action=show&amp;userid=".$row['id']."\">".wordwrap($row['fullname'], 30, "<br />", 1 )."</a></small></td></tr>\n";
64}
65$content .= "</table>";
66
67//check for enough users
68if($i == 0 ) {
69 $content = "<small>".$lang['no_users']."</small>";
70 new_box($lang['users'], $content );
71}
72else {
73 //show it
74 new_box($lang['existing_users'], $content, 'boxmenu' );
75}
76
77?>
Note: See TracBrowser for help on using the repository browser.