Commit 1d184f66 authored by Leigh Stoller's avatar Leigh Stoller

Bunch of little changes to allow ISFOREIGN_ADMIN() users to see portal wide

statistics and other goodies.
parent aa5759cc
......@@ -42,7 +42,7 @@ RedirectSecure();
$this_user = CheckLoginOrRedirect();
SPITHEADER(1);
if (!ISADMIN()) {
if (!(ISADMIN() || ISFOREIGN_ADMIN())) {
if (isset($target_user)) {
if (!$target_user->SameUser($this_user)) {
SPITUSERERROR("Not enough permission to view this page!");
......
......@@ -72,7 +72,7 @@ echo "<link rel='stylesheet'
$query_result1 = null;
$query_result2 = null;
if (($all || $extend) && ISADMIN()) {
if (($all || $extend) && (ISADMIN() || ISFOREIGN_ADMIN())) {
$where = "";
if ($extend) {
$where = "where a.extension_requested=1";
......@@ -85,7 +85,7 @@ if (($all || $extend) && ISADMIN()) {
" ((UNIX_TIMESTAMP(now()) - ".
" UNIX_TIMESTAMP(a.created)) / 3600.0),2) as phours, ".
" IFNULL(aggs.count,0) as aggrows, ".
" agg.aggregate_urn as aggrow_urn".
" agg.aggregate_urn as aggrow_urn ".
" from apt_instances as a ".
"left join (".
" select uuid, COUNT(*) AS count ".
......@@ -128,7 +128,7 @@ else {
" ((UNIX_TIMESTAMP(now()) - ".
" UNIX_TIMESTAMP(a.created)) / 3600.0),2) as phours, ".
" IFNULL(aggs.count,0) as aggrows, ".
" agg.aggregate_urn as aggrow_urn".
" agg.aggregate_urn as aggrow_urn ".
" from apt_instances as a ".
"left join (".
" select uuid, COUNT(*) AS count ".
......@@ -147,9 +147,9 @@ else {
"order by a.creator");
}
function SPITROWS($all, $name, $result)
function SPITROWS($showall, $name, $result)
{
global $TBBASE, $urn_mapping;
global $TBBASE, $urn_mapping, $all, $extend;
echo "<input class='form-control search' type='search' data-column='all'
id='experiment_search_${name}' placeholder='Search'>\n";
......@@ -159,7 +159,7 @@ function SPITROWS($all, $name, $result)
<tr>
<th>Name</th>
<th>Profile</th>\n";
if ($all) {
if ($showall || $all) {
echo " <th>Creator</th>\n";
}
echo " <th>Project</th>
......@@ -231,8 +231,19 @@ function SPITROWS($all, $name, $result)
$cluster = $urn_mapping[$row["aggregate_urn"]];
}
echo " <tr>\n";
echo "<td><a href='status.php?uuid=$uuid'>$name</a></td>";
echo " <tr><td>\n";
if ($all || $extend) {
if (ISADMIN()) {
echo "<a href='status.php?uuid=$uuid'>$name</a>";
}
else {
echo $name;
}
}
else {
echo "<a href='status.php?uuid=$uuid'>$name</a>";
}
echo "</td>\n";
if ($profile) {
echo "<td><a href='show-profile.php?uuid=$profile_uuid'>
$profile_name</a></td>";
......@@ -240,7 +251,7 @@ function SPITROWS($all, $name, $result)
else {
echo "<td>$profile_name</td>\n";
}
if ($all) {
if ($showall) {
echo "<td>$creator</td>";
}
if (ISADMIN()) {
......
<?php
#
# Copyright (c) 2000-2014 University of Utah and the Flux Group.
# Copyright (c) 2000-2015 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -46,6 +46,7 @@ function Do_GetProfile()
return;
}
if (!ISADMIN() &&
!ISFOREIGN_ADMIN() &&
!$profile->CanView($this_user)) {
SPITAJAX_ERROR(1, "Not enough permission");
return;
......
......@@ -61,7 +61,7 @@ $joinclause = "";
$orderclause = "";
if (isset($all)) {
if (ISADMIN()) {
if (ISADMIN() || ISFOREIGN_ADMIN()) {
$whereclause = "";
}
else {
......@@ -88,7 +88,7 @@ if (mysql_num_rows($query_result) == 0) {
$message = "<b>No profiles to show you. Maybe you want to ".
"<a href='manage_profile.php'>create one?</a></b><br><br>";
if (ISADMIN()) {
if (ISADMIN() || ISFOREIGN_ADMIN()) {
$message .= "<img src='images/redball.gif'>".
"<a href='myprofiles.php?all=1'>Show all user Profile</a>";
}
......@@ -183,7 +183,7 @@ echo " </tbody>
</table>\n";
if (!isset($all)) {
if (ISADMIN()) {
if (ISADMIN() || ISFOREIGN_ADMIN()) {
echo "<img src='images/redball.gif'>
<a href='myprofiles.php?all=1'>Show all user profiles</a>\n";
}
......
......@@ -293,21 +293,20 @@ $PAGEHEADER_FUNCTION = function($thinheader = 0, $ignore1 = NULL,
<li><a href='list-datasets.php?all=1'>List Datasets</a></li>
<li><a href='create-dataset.php'>Create Dataset</a></li>";
echo " <li class='divider'></li>\n";
if (ISADMIN()) {
$then = time() - (90 * 3600 * 24);
echo " <li><a href='activity.php?user=$login_uid&min=$then'>
My History</a></li>\n";
if (ISADMIN() || ISFOREIGN_ADMIN()) {
echo " <li class='divider'></li>\n";
$then = time() - (30 * 3600 * 24);
echo " <li><a href='activity.php?min=$then'>
History Data</a></li>
<li><a href='sumstats.php?min=$then'>Summary Stats</a></li>
<li><a href='myexperiments.php?all=1'>
<li><a href='sumstats.php?min=$then'>Summary Stats</a></li>";
echo "<li><a href='myexperiments.php?all=1'>
All Experiments</a></li>
<li><a href='myprofiles.php?all=1'>
<li><a href='myprofiles.php?all=1'>
All Profiles</a></li>";
}
else {
$then = time() - (90 * 3600 * 24);
echo " <li><a href='activity.php?user=$login_uid&min=$then'>
My History</a></li>\n";
}
echo " </ul>
</li>\n";
}
......
......@@ -53,7 +53,7 @@ $profile = Profile::Lookup($uuid);
if (!$profile) {
SPITUSERERROR("No such profile!");
}
if (!$profile->CanView($this_user) && !ISADMIN()) {
if (!$profile->CanView($this_user) && !(ISADMIN() || ISFOREIGN_ADMIN())) {
SPITUSERERROR("Not enough permission!");
}
$profile_uuid = $profile->profile_uuid();
......
......@@ -45,7 +45,7 @@ if (!isset($showby)) {
RedirectSecure();
$this_user = CheckLoginOrRedirect();
if (!ISADMIN()) {
if (! (ISADMIN() || ISFOREIGN_ADMIN())) {
SPITUSERERROR("You do not have permission to view summary stats");
}
SPITHEADER(1);
......@@ -60,10 +60,11 @@ function ShowByCreator()
global $urn_mapping, $TBBASE, $min, $max;
$whereclause = "";
if (isset($min) && isset($max)) {
$whereclause =
"where (UNIX_TIMESTAMP(created) > $min and ".
" UNIX_TIMESTAMP(created) < $max) ";
if (isset($min)) {
$whereclause = "where UNIX_TIMESTAMP(created) > $min ";
if (isset($max)) {
$whereclause .= "and UNIX_TIMESTAMP(created) < $max ";
}
}
$query_result =
......@@ -122,7 +123,7 @@ function ShowByCreator()
echo " <table class='tablesorter' id='tablesorter_sumstats'>
<thead>
<tr>
<th rowspan=2>UID</th>
<th rowspan=1>UID</th>
<th colspan=3>Totals</th>
<th colspan=3>APT</th>
<th colspan=3>Utah</th>
......@@ -130,6 +131,8 @@ function ShowByCreator()
<th colspan=3>Clem</th>
</tr>
<tr>
<th class='filter-false sorter-false'
style='padding-left:1px; text-align:left'>Total</th>
<th>Expt</th>
<th>PCs</th>
<th>PHours</th>
......@@ -147,7 +150,7 @@ function ShowByCreator()
<th>PHours</th>
</tr>
<tr>
<th class='filter-false sorter-false'>Totals</th>
<th class='filter-false sorter-false' data-math='col-count'>0</th>
<th class='filter-false sorter-false' data-math='col-sum'>0</th>
<th class='filter-false sorter-false' data-math='col-sum'>0</th>
<th class='filter-false sorter-false'
......@@ -227,10 +230,11 @@ function ShowByProject()
global $urn_mapping, $TBBASE, $min, $max;
$whereclause = "";
if (isset($min) && isset($max)) {
$whereclause =
"where (UNIX_TIMESTAMP(created) > $min and ".
" UNIX_TIMESTAMP(created) < $max) ";
if (isset($min)) {
$whereclause = "where UNIX_TIMESTAMP(created) > $min ";
if (isset($max)) {
$whereclause .= " and UNIX_TIMESTAMP(created) < $max ";
}
}
$query_result =
......@@ -292,7 +296,7 @@ function ShowByProject()
echo " <table class='tablesorter' id='tablesorter_sumstats'>
<thead>
<tr>
<th rowspan=2>PID</th>
<th rowspan=1>PID</th>
<th colspan=3>Totals</th>
<th colspan=3>APT</th>
<th colspan=3>Utah</th>
......@@ -300,6 +304,8 @@ function ShowByProject()
<th colspan=3>Clem</th>
</tr>
<tr>
<th class='filter-false sorter-false'
style='padding-left:1px; text-align:left'>Total</th>
<th>Expt</th>
<th>PCs</th>
<th>Phours</th>
......@@ -317,7 +323,7 @@ function ShowByProject()
<th>Phours</th>
</tr>
<tr>
<th class='filter-false sorter-false'>Totals</th>
<th class='filter-false sorter-false' data-math='col-count'>0</th>
<th class='filter-false sorter-false' data-math='col-sum'>0</th>
<th class='filter-false sorter-false' data-math='col-sum'>0</th>
<th class='filter-false sorter-false'
......
......@@ -55,7 +55,7 @@
<tr>
<td><%- instance[9] %></a></td>
<td>
<a href='manage_profile.php?action=edit&uuid=<%- instance[2] %>'>
<a href='show-profile.php?action=edit&uuid=<%- instance[2] %>'>
<%- instance[0] %></a>
</td>
<td><%- instance[1] %></a></td>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment