showuser.php3 6.51 KB
Newer Older
1
<?php
Leigh B. Stoller's avatar
Leigh B. Stoller committed
2 3
#
# EMULAB-COPYRIGHT
4
# Copyright (c) 2000-2006 University of Utah and the Flux Group.
Leigh B. Stoller's avatar
Leigh B. Stoller committed
5 6
# All rights reserved.
#
7 8
include("defs.php3");
include("showstuff.php3");
9
include_once("template_defs.php");
10 11 12 13

#
# Only known and logged in users can do this.
#
14
$uid = GETLOGIN();
15 16
LOGGEDINORDIE($uid, CHECKLOGIN_USERSTATUS|
	      CHECKLOGIN_WEBONLY|CHECKLOGIN_WIKIONLY);
17 18 19 20 21 22 23 24 25 26
$isadmin = ISADMIN($uid);

#
# Verify form arguments.
# 
if (!isset($target_uid) ||
    strcmp($target_uid, "") == 0) {
    USERERROR("You must provide a User ID.", 1);
}

27 28 29 30 31 32 33 34 35 36
#
# Standard Testbed Header, now that we know what we want to say.
#
if (strcmp($uid, $target_uid)) {
    PAGEHEADER("Information for User: $target_uid");
}
else {
    PAGEHEADER("My Emulab.Net");
}

37
#
38 39
# Check to make sure thats this is a valid UID. Getting the status works,
# and we need that later. 
40
#
41 42
if (! ($userstatus = TBUserStatus($target_uid))) {
    USERERROR("The user $target_uid is not a valid user", 1);
43
}
44
$wikionly = TBWikiOnlyUser($target_uid);
45 46 47

#
# Verify that this uid is a member of one of the projects that the
Leigh B. Stoller's avatar
Leigh B. Stoller committed
48
# target_uid is in. Must have proper permission in that group too. 
49
#
Leigh B. Stoller's avatar
Leigh B. Stoller committed
50 51 52 53 54 55
if (!$isadmin &&
    strcmp($uid, $target_uid)) {

    if (! TBUserInfoAccessCheck($uid, $target_uid, $TB_USERINFO_READINFO)) {
	USERERROR("You do not have permission to view this user's ".
		  "information!", 1);
56 57 58
    }
}

59 60 61 62 63 64 65 66 67
#
# Special banner message.
#
$message = TBGetSiteVar("web/banner");
if ($message != "") {
    echo "<center><font color=Red size=+1>\n";
    echo "$message\n";
    echo "</font></center><br>\n";
}
68

69 70 71 72 73 74
#
# Tell the user how many PCs he is using.
#
$yourpcs = TBUserPCs($target_uid);

if ($yourpcs) {
75
    echo "<center><font color=Red size=+2>\n";
76 77
    
    if (strcmp($uid, $target_uid))
78
	echo "$target_uid is using $yourpcs PCs!\n";
79 80 81
    else
	echo "You are using $yourpcs PCs!\n";
    
82
    echo "</font></center>\n";
83 84
}

85 86 87 88 89
#
# Put a link down to the profile
#
echo "<h3><a href=\"#PROFILE\">Manage User Profile</a></h3>\n";

90 91 92 93
if ($EXPOSETEMPLATES) {
    SHOWTEMPLATELIST("USER", 0, $uid, $target_uid);
}

94
#
95
# Lets show Experiments.
96
#
97
SHOWEXPLIST("USER", $uid, $target_uid);
98 99

#
100
# Lets show project and group membership.
101 102
#
$query_result =
103 104
    DBQueryFatal("select distinct g.pid,g.gid,g.trust,p.name,gr.description, ".
    		 "       count(distinct r.node_id) as ncount ".
105
		 " from group_membership as g ".
106
		 "left join projects as p on p.pid=g.pid ".
107
		 "left join groups as gr on gr.pid=g.pid and gr.gid=g.gid ".
108 109
		 "left join experiments as e on g.pid=e.pid and g.gid=e.gid ".
		 "left join reserved as r on e.pid=r.pid and e.eid=r.eid ".
110 111
		 "left join group_membership as g2 on g2.pid=g.pid and ".
		 "     g2.gid=g.gid and g2.uid='$uid' ".
112 113
		 "where g.uid='$target_uid' and ".
		 ($isadmin ? "" : "g2.uid is not null and ") .
114
		 "g.trust!='" . TBDB_TRUSTSTRING_NONE . "' ".
115
		 "group by g.pid, g.gid ".
116
		 "order by g.pid,gr.created");
117 118 119

if (mysql_num_rows($query_result)) {
    echo "<center>
120
          <h3>Project and Group Membership</h3>
121 122 123 124
          </center>
          <table align=center border=1 cellpadding=1 cellspacing=2>\n";

    echo "<tr>
125 126
              <th>PID</th>
              <th>GID</th>
127
	      <th>Nodes</th>
128 129 130
              <th>Name/Description</th>
              <th>Trust</th>
              <th>MailTo</th>
131 132 133
          </tr>\n";

    while ($projrow = mysql_fetch_array($query_result)) {
134
	$pid   = $projrow[pid];
135
	$gid   = $projrow[gid];
136
	$name  = $projrow[name];
137
	$desc  = $projrow[description];
138
	$trust = $projrow[trust];
139
	$nodes = $projrow[ncount];
140
	
141 142
	if (TBTrustConvert($trust) != $TBDB_TRUST_NONE) {
	    echo "<tr>
143 144 145 146
                     <td><A href='showproject.php3?pid=$pid'>
                            $pid</A></td>
                     <td><A href='showgroup.php3?pid=$pid&gid=$gid'>
                            $gid</A></td>\n";
147 148 149

	    echo "<td>$nodes</td>\n";

150 151 152 153 154 155 156 157
	    if (strcmp($pid,$gid)) {
		echo "<td>$desc</td>\n";
		$mail  = $pid . "-" . $gid . "-users@" . $OURDOMAIN;
	    }
	    else {
		echo "<td>$name</td>\n";
		$mail  = $pid . "-users@" . $OURDOMAIN;
	    }
158 159 160 161 162 163 164 165 166 167
	    echo "<td>$trust</td>\n";

	    if ($MAILMANSUPPORT) {
		# Not sure what I want to do here ...
		echo "<td nowrap><a href=mailto:$mail>$mail</a></td>";
	    }
	    else {
		echo "<td nowrap><a href=mailto:$mail>$mail</a></td>";
	    }
	    echo "</tr>\n";
168
        }
169 170 171
    }
    echo "</table>\n";

172 173 174 175
    echo "<center>
          Click on the GID to view/edit group membership and trust levels.
          </center>\n";
}
176

177 178 179 180 181
#
# Widearea Accounts
# 
SHOWWIDEAREAACCOUNTS($target_uid);

182
#
183
# User Profile.
184
#
Leigh B. Stoller's avatar
Leigh B. Stoller committed
185
echo "<a NAME=PROFILE></a>\n";
186
echo "<center>
187
      <h3>User Profile</h3>
188 189
      </center>\n";

190 191 192 193 194 195 196
#
# See if any mailman lists owned by the user. If so we add a menu item.
#
$mm_result =
    DBQueryFatal("select owner_uid from mailman_listnames ".
		 "where owner_uid='$target_uid'");

197 198
SUBPAGESTART();
SUBMENUSTART("User Options");
199
#
200 201 202 203
# Permission check not needed; if the user can view this page, they can
# generally access these subpages, but if not, the subpage will still whine.
# 
WRITESUBMENUBUTTON("Edit Profile",  "moduserinfo.php3?target_uid=$target_uid");
204

205
if (!$wikionly && ($isadmin || !strcmp($uid, $target_uid))) {
206 207 208 209
    WRITESUBMENUBUTTON("Edit SSH Keys",
		       "showpubkeys.php3?target_uid=$target_uid");
    WRITESUBMENUBUTTON("Edit SFS Keys",
		       "showsfskeys.php3?target_uid=$target_uid");
210

211 212 213
    WRITESUBMENUBUTTON("Generate SSL Cert",
		       "gensslcert.php3?target_uid=$target_uid");

214 215
    WRITESUBMENUBUTTON("Show History",
		       "showstats.php3?showby=user&which=$target_uid");
216 217 218 219 220

    if ($MAILMANSUPPORT && mysql_num_rows($mm_result)) {
	WRITESUBMENUBUTTON("Show Mailman Lists",
			   "showmmlists.php3?target_uid=$target_uid");
    }
221
}
222 223 224 225 226 227 228 229 230 231 232 233

if ($isadmin) {
    if (!strcmp(TBUserStatus($target_uid), TBDB_USERSTATUS_FROZEN)) {
	WRITESUBMENUBUTTON("Thaw User",
		   "freezeuser.php3?target_uid=$target_uid&action=thaw");
    }
    else {
	WRITESUBMENUBUTTON("Freeze User",
		   "freezeuser.php3?target_uid=$target_uid&action=freeze");
    }
    WRITESUBMENUBUTTON("Delete User",
		       "deleteuser.php3?target_uid=$target_uid");
234 235 236 237 238 239

    if (! strcmp($userstatus, TBDB_USERSTATUS_NEWUSER) ||
	! strcmp($userstatus, TBDB_USERSTATUS_UNVERIFIED)) {
	WRITESUBMENUBUTTON("Resend Verification Key",
			   "resendkey.php3?target_uid=$target_uid");
    }
240 241 242 243
    else {
	WRITESUBMENUBUTTON("Send Test Email Message",
			   "sendtestmsg.php3?target_uid=$target_uid");
    }
244 245 246 247 248 249
}
SUBMENUEND();

SHOWUSER($target_uid);
SUBPAGEEND();

250 251 252 253 254 255 256 257
if ($isadmin) {
    echo "<center>
          <h3>User Stats</h3>
         </center>\n";

    SHOWUSERSTATS($target_uid);
}

258 259 260 261 262
#
# Standard Testbed Footer
# 
PAGEFOOTER();
?>
Chad Barb's avatar
 
Chad Barb committed
263 264 265