profile.php 3.84 KB
Newer Older
1 2
<?php
#
3
# Copyright (c) 2000-2015 University of Utah and the Flux Group.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
# 
# {{{EMULAB-LICENSE
# 
# This file is part of the Emulab network testbed software.
# 
# This file is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
# 
# This file is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public
# License for more details.
# 
# You should have received a copy of the GNU Affero General Public License
# along with this file.  If not, see <http://www.gnu.org/licenses/>.
# 
# }}}
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
#
include("defs.php3");

#
# Only known and logged in users can do this.
#
$this_user = CheckLoginOrDie(CHECKLOGIN_USERSTATUS|
			     CHECKLOGIN_WEBONLY|CHECKLOGIN_WIKIONLY);
$uid       = $this_user->uid();
$isadmin   = ISADMIN();

#
# Verify page arguments.
#
$optargs = OptionalPageArguments("target_user", PAGEARG_USER);

if (! isset($target_user)) {
    $target_user = $this_user;
}
$userstatus = $target_user->status();
$wikionly   = $target_user->wikionly();
$target_idx = $target_user->uid_idx();
$target_uid = $target_user->uid();


#
# Verify that this uid is a member of one of the projects that the
# target_uid is in. Must have proper permission in that group too. 
#
if (!$isadmin && 
    !$target_user->AccessCheck($this_user, $TB_USERINFO_READINFO)) {
    USERERROR("You do not have permission to view this user's information!", 1);
}

#
# Standard Testbed Header.
#
PAGEHEADER("Profile for $target_uid");

#
# 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'");

#
# User Profile.
#
SUBPAGESTART();
SUBMENUSTART("Options");

#
# 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("My Emulab",
		   CreateURL("showuser", $target_user));

WRITESUBMENUBUTTON("Edit Profile",
		   CreateURL("moduserinfo", $target_user));

if (!$wikionly && ($isadmin || $target_user->SameUser($this_user))) {
    WRITESUBMENUBUTTON("Edit SSH Keys",
87
		       CreateURL("ssh-keys", $target_user));
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
    
    WRITESUBMENUBUTTON("Generate SSL Cert",
		       CreateURL("gensslcert", $target_user));


    if ($MAILMANSUPPORT && mysql_num_rows($mm_result)) {
	WRITESUBMENUBUTTON("Show Mailman Lists",
			     CreateURL("showmmlists", $target_user));
    }
}

if ($isadmin) {
   SUBMENUSECTION("Admin Options");
    
    if (!strcmp($userstatus, TBDB_USERSTATUS_FROZEN)) {
	WRITESUBMENUBUTTON("Thaw User",
			     CreateURL("freezeuser", $target_user,
				       "action", "thaw"));
    }
    else {
	WRITESUBMENUBUTTON("Freeze User",
			     CreateURL("freezeuser", $target_user,
				       "action", "freeze"));
    }
    WRITESUBMENUBUTTON("Delete User",
			 CreateURL("deleteuser", $target_user));

    WRITESUBMENUBUTTON("SU as User",
			 CreateURL("suuser", $target_user));

    if ($userstatus == TBDB_USERSTATUS_UNAPPROVED) {
	WRITESUBMENUBUTTON("Change UID",
			     CreateURL("changeuid", $target_user));
    }

    if (! strcmp($userstatus, TBDB_USERSTATUS_NEWUSER) ||
	! strcmp($userstatus, TBDB_USERSTATUS_UNVERIFIED)) {
	WRITESUBMENUBUTTON("Resend Verification Key",
			     CreateURL("resendkey", $target_user));
    }
    else {
	WRITESUBMENUBUTTON("Send Test Email Message",
			     CreateURL("sendtestmsg", $target_user));
    }
}
SUBMENUEND();
$target_user->Show();
SUBPAGEEND();

if ($isadmin) {
    echo "<center>
          <h3>User Stats</h3>
         </center>\n";

    echo $target_user->ShowStats();
}

#
# Standard Testbed Footer
# 
PAGEFOOTER();
?>