showproject.php3 9.51 KB
Newer Older
1
<?php
Leigh Stoller's avatar
Leigh Stoller committed
2
#
Leigh Stoller's avatar
Leigh Stoller committed
3
# Copyright (c) 2000-2011 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/>.
# 
# }}}
Leigh Stoller's avatar
Leigh Stoller committed
23
#
24
include("defs.php3");
25
include_once("template_defs.php");
26
include_once("pub_defs.php");
27 28 29 30 31 32 33 34 35

#
# 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).
#

#
36
# Only known and logged in users.
37
#
38 39 40
$this_user = CheckLoginOrDie();
$uid       = $this_user->uid();
$isadmin   = ISADMIN();
41 42

#
43
# Verify page arguments.
44
#
45 46 47 48
$reqargs  = RequiredPageArguments("project", PAGEARG_PROJECT);
$project  = $reqargs["project"];
$group    = $project->Group();
$pid      = $project->pid();
49

50 51 52 53 54
#
# Standard Testbed Header
#
PAGEHEADER("Project $pid");

55
#
Leigh Stoller's avatar
Leigh Stoller committed
56
# Verify that this uid is a member of the project being displayed.
57
#
58
if (! $project->AccessCheck($this_user, $TB_PROJECT_READINFO)) {
59
    USERERROR("You are not a member of Project $pid.", 1);
60 61
}

62 63 64
SUBPAGESTART();
SUBMENUSTART("Project Options");
WRITESUBMENUBUTTON("Create Subgroup",
65
		   "newgroup.php3?pid=$pid");
66
WRITESUBMENUBUTTON("Edit User Privs",
67
		   "editgroup.php3?pid=$pid&gid=$pid");
68
WRITESUBMENUBUTTON("Remove Users",
Leigh Stoller's avatar
Leigh Stoller committed
69
		   "showgroup.php3?pid=$pid&gid=$pid");
70
WRITESUBMENUBUTTON("Show Project History",
71
		   "showstats.php3?showby=project&pid=$pid");
72 73
WRITESUBMENUBUTTON("Free Node Summary",
		   "nodecontrol_list.php3?showtype=summary&bypid=$pid");
74 75 76 77
if ($isadmin) {
    WRITESUBMENUDIVIDER();
    WRITESUBMENUBUTTON("Delete this project",
		       "deleteproject.php3?pid=$pid");
78 79
    WRITESUBMENUBUTTON("Resend Approval Message",
		       "resendapproval.php?pid=$pid");
80
}
81
SUBMENUEND();
82

83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
# Gather up the html sections.
ob_start();
$project->Show();
$profile_html = ob_get_contents();
ob_end_clean();

ob_start();
$group->ShowMembers();
$members_html = ob_get_contents();
ob_end_clean();

ob_start();
$project->ShowGroupList();
$groups_html = ob_get_contents();
ob_end_clean();

# Project wide Templates.
Leigh Stoller's avatar
Leigh Stoller committed
100
$templates_html = null;
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
if ($EXPOSETEMPLATES) {
    $templates_html = SHOWTEMPLATELIST("PROJ", 0, $uid, $pid, "", TRUE);
}

ob_start();
ShowExperimentList("PROJ", $this_user, $project);
$experiments_html = ob_get_contents();
ob_end_clean();

$stats_html = null;
if ($isadmin) {
    ob_start();
    $project->ShowStats();
    $stats_html = ob_get_contents();
    ob_end_clean();
}

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 150 151 152 153 154 155 156 157
#
# Portal support; show exports.
#
$exports_html = null;
if ($PORTAL_ENABLE && $PORTAL_ISPRIMARY) {
    $pid_idx = $project->pid_idx();
    
    $query_result =
	DBQueryFatal("select * from group_exports ".
		     "where pid_idx='$pid_idx' and pid_idx=gid_idx");
    if (mysql_num_rows($query_result)) {
	$exports_html =
	    "<center>
               <h3>Peer Exports</h3>
             </center>
             <table align=center border=1 cellpadding=1 cellspacing=2>\n";

        $exports_html .=
	    "<tr>
                <th>Peer</th>
                <th>Exported</th>
  	        <th>Updated</th>
             </tr>\n";

	while ($exportrow = mysql_fetch_array($query_result)) {
	    $peer     = $exportrow["peer"];
	    $updated  = $exportrow["updated"];
	    $exported = $exportrow["exported"];

	    $exports_html .=
		"<tr>
                    <td>$peer</td>
                    <td>$exported</td>
                    <td>$updated</td>
                  </tr>\n";
	}
	$exports_html .= "</table>\n";
    }
}
 
158
$papers_html = null;
159
if ($PUBSUPPORT) {
160 161 162
    #
    # List papers for this project if any
    #
163
    $query_result = GetPubs("`project` = \"$pid\"");
164 165 166 167 168
    if (mysql_num_rows($query_result)) {
	$papers_html = MakeBibList($this_user, $isadmin, $query_result);
    }
}

169 170
$vis_html = null;
$whocares = null;
171
if ($EXP_VIS && CHECKURL("http://$USERNODE/proj-vis/$pid/", $whocares)) {
172
  $vis_html = "<iframe src=\"http://$USERNODE/proj-vis/$pid/\" width=\"100%\" height=600 id=\"vis-iframe\"></iframe>";
173 174
}

175 176 177
#
# Show number of PCS
#
178
$numpcs = $project->PCsInUse();
179 180 181 182

if ($numpcs) {
    echo "<center><font color=Red size=+2>\n";
    echo "Project $pid is using $numpcs PCs!\n";
183
    echo "</font></center><br>\n";
184 185
}

186
#
187 188 189 190 191 192 193
# Function to change what is being shown.
#
echo "<script type='text/javascript' language='javascript'>
        var li_current = 'li_profile';
        var div_current = 'div_profile';
        function Show(which) {
	    li = getObjbyName(li_current);
194 195 196 197 198 199
            if (li) {
                li.style.backgroundColor = '#DDE';
                li.style.borderBottom = '1px solid #778';
                div = getObjbyName(div_current);
                div.style.display = 'none';
            }
200 201 202

            li_current = 'li_' + which;
            div_current = 'div_' + which;
203 204 205 206 207 208 209
	    li = getObjbyName(li_current);
            if (li) {
                li.style.backgroundColor = 'white';
                li.style.borderBottom = '1px solid white';
                div = getObjbyName(div_current);
                div.style.display = 'block';
            }
210 211
            return false;
        }
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231
        function Setup() {
	    var urllocation = location.href; //find url parameter
	    if (urllocation && urllocation.indexOf('#') >= 0) {
                var which = urllocation.substr(urllocation.indexOf('#') + 1);

	        li = getObjbyName('li_' + which);
                if (!li) {
                    which = 'profile';
                }
                Show(which);
            }
            else {
	        li = getObjbyName(li_current);
                if (li) {
                    li.style.backgroundColor = 'white';
                    li.style.borderBottom = '1px solid white';
                    div = getObjbyName(div_current);
                    div.style.display = 'block';
                }
            }
232 233 234 235 236 237 238 239 240 241
        }
      </script>\n";

#
# This is the topbar
#
echo "<div width=\"100%\" align=center>\n";
echo "<ul id=\"topnavbar\">\n";
if ($templates_html) {
    echo "<li>
242 243
           <a href=\"#templates\" ".
	       "class=topnavbar onfocus=\"this.hideFocus=true;\" ".
244 245 246 247 248
               "id=\"li_templates\" onclick=\"Show('templates');\">".
               "Templates</a></li>\n";
}
if ($experiments_html) {
     echo "<li>
249 250
            <a href=\"#experiments\" ".
	       "class=topnavbar onfocus=\"this.hideFocus=true;\" ".
251 252 253 254 255
               "id=\"li_experiments\" onclick=\"Show('experiments');\">".
               "Experiments</a></li>\n";
}
if ($groups_html) {
    echo "<li>
256 257
          <a href=\"#groups\" ".
	      "class=topnavbar onfocus=\"this.hideFocus=true;\" ".
258 259 260 261 262
	      "id=\"li_groups\" onclick=\"Show('groups');\">".
              "Groups</a></li>\n";
}
if ($members_html) {
    echo "<li>
263 264
          <a href=\"#members\" ".
	      "class=topnavbar onfocus=\"this.hideFocus=true;\" ".
265 266 267 268
	      "id=\"li_members\" onclick=\"Show('members');\">".
              "Members</a></li>\n";
}
echo "<li>
269 270
      <a href=\"#profile\" ".
           "class=topnavbar onfocus=\"this.hideFocus=true;\" ".
271 272 273 274 275 276 277 278 279
           "id=\"li_profile\" onclick=\"Show('profile');\">".
           "Profile</a></li>\n";

if ($isadmin && $stats_html) {
    echo "<li>
          <a href=\"#F\" class=topnavbar onfocus=\"this.hideFocus=true;\" ".
	      "id=\"li_stats\" onclick=\"Show('stats');\">".
              "Project Stats</a></li>\n";
}
280 281
if ($papers_html) {
    echo "<li>
282 283
          <a href=\"#papers\" ".
	      "class=topnavbar onfocus=\"this.hideFocus=true;\" ".
284 285 286
	      "id=\"li_papers\" onclick=\"Show('papers');\">".
              "Publications</a></li>\n";
}
287 288
if ($vis_html) {
    echo "<li>
289 290
          <a href=\"#vis\" ".
	      "class=topnavbar onfocus=\"this.hideFocus=true;\" ".
291 292 293
	      "id=\"li_vis\" onclick=\"Show('vis');\">".
              "Visualization</a></li>\n";
}
294 295 296 297 298 299 300
if ($exports_html) {
    echo "<li>
          <a href=\"#exports\" ".
	      "class=topnavbar onfocus=\"this.hideFocus=true;\" ".
	      "id=\"li_exports\" onclick=\"Show('exports');\">".
              "Peers</a></li>\n";
}
301 302 303
echo "</ul>\n";
echo "</div>\n";
echo "<div align=center id=topnavbarbottom>&nbsp</div>\n";
Leigh Stoller's avatar
Leigh Stoller committed
304

305 306
if ($templates_html) {
     echo "<div class=invisible id=\"div_templates\">$templates_html</div>";
307
}
308 309 310 311 312 313 314 315 316 317 318 319 320
if ($experiments_html) {
     echo "<div class=invisible id=\"div_experiments\">$experiments_html</div>";
}
if ($groups_html) {
     echo "<div class=invisible id=\"div_groups\">$groups_html</div>";
}
if ($members_html) {
     echo "<div class=invisible id=\"div_members\">$members_html</div>";
}
echo "<div class=invisible id=\"div_profile\">$profile_html</div>";
if ($isadmin && $stats_html) {
    echo "<div class=invisible id=\"div_stats\">$stats_html</div>";
}
321 322 323
if ($papers_html) {
     echo "<div class=invisible id=\"div_papers\">$papers_html</div>";
}
324 325 326
if ($vis_html) {
     echo "<div class=invisible id=\"div_vis\">$vis_html</div>";
}
327 328 329
if ($exports_html) {
     echo "<div class=invisible id=\"div_exports\">$exports_html</div>";
}
330
SUBPAGEEND();
331

332
#
333
# Get the active tab to look right.
334
#
335
echo "<script type='text/javascript' language='javascript'>
336
      Setup();
337
      </script>\n";
338

339 340 341 342
#
# Standard Testbed Footer
# 
PAGEFOOTER();
343
?>