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

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

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

25 26 27 28 29 30 31 32 33 34
#
# 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");
}

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

#
# Verify that this uid is a member of one of the projects that the
Leigh Stoller's avatar
Leigh Stoller committed
45
# target_uid is in. Must have proper permission in that group too. 
46
#
Leigh Stoller's avatar
Leigh Stoller committed
47 48 49 50 51 52
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);
53 54 55
    }
}

56 57 58 59 60 61
#
# Tell the user how many PCs he is using.
#
$yourpcs = TBUserPCs($target_uid);

if ($yourpcs) {
62
    echo "<center><font color=Red size=+2>\n";
63 64
    
    if (strcmp($uid, $target_uid))
65
	echo "$target_uid is using $yourpcs PCs!\n";
66 67 68
    else
	echo "You are using $yourpcs PCs!\n";
    
69
    echo "</font></center>\n";
70 71
}

72
#
73
# Lets show Experiments.
74
#
75
SHOWEXPLIST("USER",$target_uid);
76 77

#
78
# Lets show project and group membership.
79 80
#
$query_result =
81
    DBQueryFatal("select distinct g.pid,g.gid,g.trust,p.name,gr.description ".
82
		 " from group_membership as g ".
83
		 "left join projects as p on p.pid=g.pid ".
84 85
		 "left join groups as gr on gr.pid=g.pid and gr.gid=g.gid ".
		 "where uid='$target_uid' and ".
86
		 "trust!='" . TBDB_TRUSTSTRING_NONE . "' ".
87
		 "order by g.pid,gr.created");
88 89 90

if (mysql_num_rows($query_result)) {
    echo "<center>
91
          <h3>Project and Group Membership</h3>
92 93 94 95
          </center>
          <table align=center border=1 cellpadding=1 cellspacing=2>\n";

    echo "<tr>
96 97 98 99 100
              <th>PID</th>
              <th>GID</th>
              <th>Name/Description</th>
              <th>Trust</th>
              <th>MailTo</th>
101 102 103
          </tr>\n";

    while ($projrow = mysql_fetch_array($query_result)) {
104
	$pid   = $projrow[pid];
105
	$gid   = $projrow[gid];
106
	$name  = $projrow[name];
107
	$desc  = $projrow[description];
108
	$trust = $projrow[trust];
109
	
110 111
	if (TBTrustConvert($trust) != $TBDB_TRUST_NONE) {
	    echo "<tr>
112 113 114 115 116 117 118 119 120 121 122 123 124 125
                     <td><A href='showproject.php3?pid=$pid'>
                            $pid</A></td>
                     <td><A href='showgroup.php3?pid=$pid&gid=$gid'>
                            $gid</A></td>\n";
	    if (strcmp($pid,$gid)) {
		echo "<td>$desc</td>\n";
		$mail  = $pid . "-" . $gid . "-users@" . $OURDOMAIN;
	    }
	    else {
		echo "<td>$name</td>\n";
		$mail  = $pid . "-users@" . $OURDOMAIN;
	    }
	    echo "<td>$trust</td>
                  <td nowrap><a href=mailto:$mail>$mail</a></td>
126 127
                 </tr>\n";
        }
128 129 130
    }
    echo "</table>\n";

131 132 133 134
    echo "<center>
          Click on the GID to view/edit group membership and trust levels.
          </center>\n";
}
135

136 137 138 139 140
#
# Widearea Accounts
# 
SHOWWIDEAREAACCOUNTS($target_uid);

141
#
142
# User Profile.
143 144 145 146 147
#
echo "<center>
      <h3>Profile</h3>
      </center>\n";

148 149
SUBPAGESTART();
SUBMENUSTART("User Options");
150
#
151 152 153 154
# 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");
155

156 157 158 159 160
if ($isadmin || !strcmp($uid, $target_uid)) {
    WRITESUBMENUBUTTON("Edit SSH Keys",
		       "showpubkeys.php3?target_uid=$target_uid");
    WRITESUBMENUBUTTON("Edit SFS Keys",
		       "showsfskeys.php3?target_uid=$target_uid");
161 162
    WRITESUBMENUBUTTON("Show History",
		       "showstats.php3?showby=user&which=$target_uid");
163
}
164 165 166 167 168 169 170 171 172 173 174 175

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");
176 177 178 179 180 181

    if (! strcmp($userstatus, TBDB_USERSTATUS_NEWUSER) ||
	! strcmp($userstatus, TBDB_USERSTATUS_UNVERIFIED)) {
	WRITESUBMENUBUTTON("Resend Verification Key",
			   "resendkey.php3?target_uid=$target_uid");
    }
182 183 184 185 186 187
}
SUBMENUEND();

SHOWUSER($target_uid);
SUBPAGEEND();

188 189 190 191 192 193 194 195
if ($isadmin) {
    echo "<center>
          <h3>User Stats</h3>
         </center>\n";

    SHOWUSERSTATS($target_uid);
}

196 197 198 199 200
#
# Standard Testbed Footer
# 
PAGEFOOTER();
?>
Chad Barb's avatar
Chad Barb committed
201 202 203