showgroup.php3 2.79 KB
Newer Older
Leigh B. Stoller's avatar
Leigh B. Stoller committed
1
<?php
Leigh B. Stoller's avatar
Leigh B. Stoller committed
2
3
#
# EMULAB-COPYRIGHT
4
# Copyright (c) 2000-2003 University of Utah and the Flux Group.
Leigh B. Stoller's avatar
Leigh B. Stoller committed
5
6
# All rights reserved.
#
Leigh B. Stoller's avatar
Leigh B. Stoller committed
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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
include("defs.php3");
include("showstuff.php3");

#
# Standard Testbed Header
#
PAGEHEADER("Show Group Information");


#
# Note the difference with which this page gets it arguments!
# I invoke it using GET arguments, so uid and pid are are defined
# without having to find them in URI (like most of the other pages
# find the uid).
#

#
# Only known and logged in users can end experiments.
#
$uid = GETLOGIN();
LOGGEDINORDIE($uid);

$isadmin = ISADMIN($uid);

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

if (!isset($gid) ||
    strcmp($gid, "") == 0) {
    USERERROR("You must provide a group ID.", 1);
}

#
# Check to make sure thats this is a valid PID/GID.
#
$query_result = 
    DBQueryFatal("SELECT * FROM groups WHERE pid='$pid' and gid='$gid'");
if (mysql_num_rows($query_result) == 0) {
  USERERROR("The group $pid/$gid is not a valid group", 1);
}

#
54
55
56
57
58
59
60
61
# Verify permission to look at the group. This is a little different,
# since the standard test would look for permission in just the group,
# but we also want to allow user from the project with appropriate
# privs to look at the group.
#
if (! TBProjAccessCheck($uid, $pid, $gid, $TB_PROJECT_READINFO) &&
    ! TBMinTrust(TBGrpTrust($uid, $pid, $pid), $TBDB_TRUST_GROUPROOT)) {
    USERERROR("You are not a member of group $gid in project $pid!", 1);
Leigh B. Stoller's avatar
Leigh B. Stoller committed
62
63
}

64
65
66
67
68
69
70
71
#
# See if user is privledged for deletion.
#
$prived = 0;
if ($isadmin || TBProjAccessCheck($uid, $pid, $pid, $TB_PROJECT_DELUSER)) {
    $prived = 1;
}

72
#
73
# This menu only makes sense for people with privs to use them.
74
#
75
if (TBProjAccessCheck($uid, $pid, $gid, $TB_PROJECT_EDITGROUP) ||
Chad Barb's avatar
   
Chad Barb committed
76
77
    (strcmp($gid, $pid) && 
     TBProjAccessCheck($uid, $pid, $pid, $TB_PROJECT_DELGROUP))) {
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95

    SUBPAGESTART();
    SUBMENUSTART("Group Options");

    if (TBProjAccessCheck($uid, $pid, $gid, $TB_PROJECT_EDITGROUP)) {
	WRITESUBMENUBUTTON("Edit this Group",
			   "editgroup_form.php3?pid=$pid&gid=$gid");
    }

    #
    # A delete option, but not for the default group!
    #
    if (strcmp($gid, $pid) &&
	TBProjAccessCheck($uid, $pid, $pid, $TB_PROJECT_DELGROUP)) {
	WRITESUBMENUBUTTON("Delete this Group",
			   "deletegroup.php3?pid=$pid&gid=$gid");
    }
    SUBMENUEND();
96
97
98
}

SHOWGROUP($pid, $gid);
99
SHOWGROUPMEMBERS($pid, $gid, $prived);
100
101
102
103
104

if (TBProjAccessCheck($uid, $pid, $gid, $TB_PROJECT_EDITGROUP) ||
    TBProjAccessCheck($uid, $pid, $pid, $TB_PROJECT_DELGROUP)) {
    SUBPAGEEND();
}
Leigh B. Stoller's avatar
Leigh B. Stoller committed
105
106
107
108

#
# A list of Group experiments.
#
109
SHOWEXPLIST("GROUP",$pid,$gid);
Leigh B. Stoller's avatar
Leigh B. Stoller committed
110

111
112
113
114
115
116
117
118
if ($isadmin) {
    echo "<center>
          <h3>Group Stats</h3>
         </center>\n";

    SHOWGROUPSTATS($pid, $gid);
}

Leigh B. Stoller's avatar
Leigh B. Stoller committed
119
120
121
122
123
#
# Standard Testbed Footer
# 
PAGEFOOTER();
?>