Commit c7ff2750 authored by Leigh B Stoller's avatar Leigh B Stoller

Change header/footer functions to be function pointers so that we

can potentially use Emulab pages within the APT interface. Still
playing around with this, might not work out.

Add utility function to check user login and redirect to login page.
Used in pages that require a valid login.

Add JS fragments to show/hide the waitwait modal.
parent f7231615
......@@ -98,7 +98,8 @@ $PAGEERROR_HANDLER = function($msg, $status_code = 0) {
die("");
};
function SPITHEADER($thinheader = 0)
$PAGEHEADER_FUNCTION = function($thinheader = 0, $ignore1 = NULL,
$ignore2 = NULL, $ignore3 = NULL)
{
global $TBMAINSITE, $APTTITLE, $FAVICON, $APTLOGO, $APTSTYLE, $ISAPT;
global $GOOGLEUA, $ISCLOUD;
......@@ -244,10 +245,17 @@ function SPITHEADER($thinheader = 0)
}
echo " <!-- Page content -->
<div class='container-fluid'>\n";
}
};
function SPITFOOTER()
function SPITHEADER($thinheader = 0,
$ignore1 = NULL, $ignore2 = NULL, $ignore3 = NULL)
{
global $PAGEHEADER_FUNCTION;
$PAGEHEADER_FUNCTION($thinheader, $ignore1, $ignore2, $ignore3);
}
$PAGEFOOTER_FUNCTION = function($ignored = NULL) {
global $ISAPT;
$groupname = ($ISAPT ? "apt-users" : "cloudlab-users");
......@@ -278,6 +286,13 @@ function SPITFOOTER()
</div>
<!-- Placed at the end of the document so the pages load faster -->
</body></html>\n";
};
function SPITFOOTER($ignored = null)
{
global $PAGEFOOTER_FUNCTION;
$PAGEFOOTER_FUNCTION($ignored);
}
function SPITUSERERROR($msg)
......@@ -306,11 +321,16 @@ function SPITAJAX_ERROR($code, $msg)
echo json_encode($results);
}
function SPITNULLREQUIRE()
function SPITREQUIRE($main)
{
echo "<script src='js/lib/jquery-2.0.3.min.js'></script>\n";
echo "<script src='js/lib/bootstrap.js'></script>\n";
echo "<script src='js/lib/require.js' data-main='js/null'></script>\n";
echo "<script src='js/lib/require.js' data-main='js/$main'></script>\n";
}
function SPITNULLREQUIRE()
{
SPITREQUIRE("main");
}
#
......@@ -504,6 +524,12 @@ function SpitWaitModal($id)
</div>
</div>
</div>\n";
?>
<script>
function ShowWaitModal(name) { $('#' + name).modal('show'); }
function HideWaitModal(name) { $('#' + name).modal('hide'); }
</script>
<?php
}
#
......@@ -656,4 +682,19 @@ function RedirectLoginPage()
}
#
# Check the login and redirect to login page.
#
function CheckLoginOrRedirect()
{
RedirectSecure();
$check_status = 0;
$this_user = CheckLogin($check_status);
if (! ($check_status & CHECKLOGIN_LOGGEDIN)) {
RedirectLoginPage();
}
return $this_user;
}
?>
......@@ -1149,8 +1149,8 @@ function FINISHSIDEBAR($nocontent = 0)
#
# Spit out a vanilla page header.
#
function PAGEHEADER($title, $view = NULL, $extra_headers = NULL,
$notice = NULL) {
$PAGEHEADER_FUNCTION = function($title, $view = NULL, $extra_headers = NULL,
$notice = NULL) {
global $login_status, $login_user;
global $TBBASE, $TBDOCBASE, $THISHOMEBASE;
global $BASEPATH, $drewheader, $autorefresh;
......@@ -1318,12 +1318,19 @@ function PAGEHEADER($title, $view = NULL, $extra_headers = NULL,
if (VIEWSET($view, 'show_topbar', "plab")) {
WRITEPLABTOPBAR();
}
};
function PAGEHEADER($title, $view = NULL, $extra_headers = NULL,
$notice = NULL) {
global $PAGEHEADER_FUNCTION;
$PAGEHEADER_FUNCTION($title, $view, $extra_headers, $notice);
}
#
# Spit out a vanilla page footer.
#
function PAGEFOOTER($view = NULL) {
$PAGEFOOTER_FUNCTION = function($view = NULL) {
global $TBDOCBASE, $TBMAILADDR, $THISHOMEBASE, $BASEPATH, $TBBASE;
global $TBMAINSITE, $bodyclosestring, $currently_busy;
global $login_user, $javascript_debug, $sortedtables;
......@@ -1457,6 +1464,12 @@ function PAGEFOOTER($view = NULL) {
echo "</div>\n";
}
echo "</body></html>\n";
};
function PAGEFOOTER($view = NULL) {
global $PAGEFOOTER_FUNCTION;
$PAGEFOOTER_FUNCTION($view);
}
define("HTTP_400_BAD_REQUEST", 400);
......
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