Commit 723661a7 authored by Leigh Stoller's avatar Leigh Stoller

Add AUP accept support.

parent 3d4f57fd
<?php
#
# Copyright (c) 2000-2018 University of Utah and the Flux Group.
#
# {{{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/>.
#
# }}}
#
chdir("..");
include("defs.php3");
chdir("apt");
include("quickvm_sup.php");
$page_title = "AUP";
#
# Only POWDER.
#
$AUPURL = "https://www.powderwireless.net/3536bfae4004e76584f504ceefe7744f53a50d32/powder/templates/powder-aup.md";
#
# Get current user.
#
RedirectSecure();
$this_user = CheckLoginOrRedirect();
$optargs = OptionalPageArguments("referrer", PAGEARG_STRING);
SPITHEADER(1);
echo "<div id='main-body'></div>\n";
echo "<script type='text/javascript'>\n";
echo " window.AUPURL = '$AUPURL';\n";
if ($referrer) {
$referrer = CleanString($referrer);
echo " window.REFERRER = '$referrer';\n";
}
echo "</script>\n";
echo "<script src='js/lib/jquery-2.0.3.min.js'></script>\n";
REQUIRE_UNDERSCORE();
REQUIRE_MARKED();
REQUIRE_SUP();
AddTemplateList(array("aup"));
SPITREQUIRE("js/aup.js");
SPITFOOTER();
?>
$(function ()
{
'use strict';
var template_list = ["aup"];
var templates = APT_OPTIONS.fetchTemplateList(template_list);
function initialize()
{
window.APT_OPTIONS.initialize(sup);
$('#main-body').html(templates["aup"]);
$('#aup-panel .scrollable-panel').css("height",
$(document).height() - 300);
$('#aup-panel .scrollable-panel').css("max-height",
$(document).height() - 300);
$('#aup-panel .scrollable-panel').scroll(function () {
//console.info($(this).scrollTop(), $(this).innerHeight(),
// $(this)[0].scrollHeight);
if ($(this).scrollTop() + $(this).innerHeight() +2 >=
$(this)[0].scrollHeight) {
$('#confirm-aup').removeClass("disabled");
}
});
$.get(window.AUPURL, function(data) {
$('#aup-panel .scrollable-panel').html(marked(data));
});
// Handler for confirm button.
$('#confirm-aup').click(function (event) {
event.preventDefault();
Accept();
});
}
function Accept()
{
var callback = function(json) {
console.log(json);
if (json.code) {
console.info("Could not accept license: " + json.value);
return;
}
if (window.REFERRER === undefined) {
window.location.replace("landing.php");
}
else {
window.location.replace(window.REFERRER);
}
};
var xmlthing = sup.CallServerMethod(null,"user-dashboard","AcceptAUP");
xmlthing.done(callback);
}
$(document).ready(initialize);
});
<?php
#
# Copyright (c) 2000-2017 University of Utah and the Flux Group.
# Copyright (c) 2000-2018 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -25,6 +25,7 @@ chdir("..");
include("defs.php3");
chdir("apt");
include("quickvm_sup.php");
$page_title = "Logout";
#
# Verify page arguments.
......
......@@ -108,6 +108,12 @@ $PAGEHEADER_FUNCTION = function($thinheader = 0, $ignore1 = NULL,
if ($login_user && !($login_status & CHECKLOGIN_WEBONLY)) {
$showmenus = 1;
}
if ($login_user && $login_user->RequireAUP() &&
$page_title != "AUP" && $page_title != "Logout") {
$referrer = urlencode($_SERVER['REQUEST_URI']);
header("Location: aup.php?referrer=$referrer");
return;
}
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Cache-Control: no-cache, must-revalidate");
......@@ -450,7 +456,7 @@ echo " <li class='divider'></li>
Extension Requests</a></li>";
echo "<li><a href='experiments.php#all'>
All Experiments</a></li>
<li><a href='myprofiles.php?all=1'>
<li><a href='list-profiles.php'>
All Profiles</a></li>
<li><a href='list-reservations.php'>
All Reservations</a></li>
......
......@@ -44,12 +44,7 @@ $session_interactive = 0;
#
# Poor man routing description.
#
$routing = array("myprofiles" =>
array("file" => "myprofiles.ajax",
"guest" => false,
"methods" => array("GetProfile" =>
"Do_GetProfile")),
"geni-login" =>
$routing = array("geni-login" =>
array("file" => "geni-login.ajax",
"guest" => true,
"methods" => array("GetSignerInfo" =>
......@@ -139,7 +134,11 @@ $routing = array("myprofiles" =>
"GetRepoHash" =>
"Do_GetRepoHash",
"GetCommitList" =>
"Do_GetCommitList")),
"Do_GetCommitList",
"SearchProfiles" =>
"Do_SearchProfiles",
"GetProfile" =>
"Do_GetProfile")),
"status" =>
array("file" => "status.ajax",
"guest" => false,
......@@ -280,7 +279,9 @@ $routing = array("myprofiles" =>
"NagPI" =>
"Do_NagPI",
"AccountDetails" =>
"Do_AccountDetails")),
"Do_AccountDetails",
"AcceptAUP" =>
"Do_AcceptAUP")),
"nag" =>
array("file" => "user-dashboard.ajax",
"unapproved" => true,
......
<style>
.scrollable-panel {
overflow-y: scroll;
}
</style>
<div>
<div class='col-lg-10 col-lg-offset-1
col-md-10 col-md-offset-1
col-sm-10 col-sm-offset-1
col-xs-12 col-xs-offset-0'>
<div class='panel panel-default' id='aup-panel'>
<div class='panel-body'>
<div class="scrollable-panel"></div>
</div>
<div class='panel-footer'>
<center>
<button class='btn btn-primary btn-sm disabled'; type='button'
id='confirm-aup'>Accept</button>
</center>
</div>
</div>
</div>
</div>
......@@ -450,6 +450,15 @@ function Do_NagPI()
SPITAJAX_RESPONSE("nagged");
}
function Do_AcceptAUP()
{
global $this_user, $PORTAL_GENESIS;
$this_user->AcceptAUP($PORTAL_GENESIS);
SPITAJAX_RESPONSE("accepted");
}
# Local Variables:
# mode:php
# End:
......
<?php
#
# Copyright (c) 2006-2017 University of Utah and the Flux Group.
# Copyright (c) 2006-2018 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -740,6 +740,31 @@ class User
return $html;
}
#
# Does the user need to accept the AUP. Always goto the DB for this
# since the user might have multiple windows/tabs.
#
function RequireAUP() {
global $PORTAL_GENESIS;
$uid_idx = $this->uid_idx();
$query_result =
DBQueryFatal("select require_aup from users ".
"where uid_idx='$uid_idx' and ".
" FIND_IN_SET(require_aup, '$PORTAL_GENESIS')");
return mysql_num_rows($query_result);
}
function AcceptAUP($portal) {
$uid_idx = $this->uid_idx();
DBQueryFatal("update users set ".
" require_aup=TRIM(BOTH ',' FROM ".
" REPLACE(CONCAT(',', require_aup, ','), ".
" CONCAT(',', '$portal', ','), ',')) ".
"where uid_idx='$uid_idx'");
}
function Show($html = FALSE) {
global $WIKISUPPORT;
......
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