Commit 1d184f66 authored by Leigh B Stoller's avatar Leigh B Stoller
Browse files

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

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