Commit 86b9b365 authored by Jonathon Duerig's avatar Jonathon Duerig
Browse files

Announce now has a -c compatibility option to drive the web/banner sitevar for legacy Emulab.

The sitevar banner no longer shows up on the portal. Note that there is still a web/message sitevar which will show up for non-logged in users.

Fixed Issue #198
parent c75f3ba0
......@@ -31,9 +31,9 @@ use Date::Parse;
#
sub usage()
{
print STDERR "Usage: announce -a <-p portal> [-s alert_style] [-b button_label] [-u action_url] [-m max_seen_count] <announcement_text>\n";
print STDERR "Usage: announce -a <-p portal> [-c] [-s alert_style] [-b button_label] [-u action_url] [-m max_seen_count] <announcement_text>\n";
print STDERR " announce -l [active|retired|all]\n";
print STDERR " announce -r idx\n";
print STDERR " announce -r idx [-c]\n";
print STDERR " announce -i idx\n";
print STDERR " announce -h\n";
print STDERR " -h This message\n";
......@@ -46,10 +46,11 @@ sub usage()
print STDERR " -m The maximum number of times that this announcement will appear to a user. Every page view (even those in a single session) counts. A value of '0' indicates that the announcement should keep appearing indefinitely until dismissed by the user or an action is taken. Defaults to 20.\n";
print STDERR " -l List global announcements. Defaults to listing active announcements.\n";
print STDERR " -r Retire announcement with the given idx. A retired announcement will no longer be displayed to users.\n";
print STDERR " -i Info about a particular announcement.\n\n";
print STDERR " -i Info about a particular announcement.\n";
print STDERR " -c Compatibility mode. When adding in compatibility mode, the sitevar is changed, thus setting the legacy Emulab announcement. When removing in compatibility mode, the sitevar is cleared.\n";
exit(-1);
}
my $optlist = "hap:s:b:u:m:lr:i:";
my $optlist = "hacp:s:b:u:m:lr:i:";
my $add_mode = 0;
my $list_mode = 0;
my $retire_mode = 0;
......@@ -63,6 +64,7 @@ my $retire_idx = undef;
my $info_idx = undef;
my $text = undef;
my $list_type = "active";
my $compatibility = 0;
my $query_result;
......@@ -81,6 +83,7 @@ my $TBOPS = "@TBOPSEMAIL@";
use lib "@prefix@/lib";
use emdb;
use libtestbed;
use libdb;
use User;
#
......@@ -133,6 +136,9 @@ if (defined($options{"u"})) {
if (defined($options{"m"})) {
$max_seen = $options{"m"};
}
if (defined($options{"c"})) {
$compatibility = 1;
}
if ($add_mode)
{
......@@ -179,6 +185,10 @@ if ($add_mode) {
$query .= ", link_url=" . DBQuoteSpecial($url);
}
DBQueryFatal($query);
if ($compatibility)
{
TBSetSiteVar("web/banner", DBQuoteSpecial($text));
}
} elsif ($list_mode) {
#
# List announcements
......@@ -209,6 +219,10 @@ if ($add_mode) {
DBQueryFatal("update apt_announcements ".
"set retired=1 where idx=".
DBQuoteSpecial($retire_idx));
if ($compatibility)
{
TBSetSiteVar("web/banner", "");
}
} elsif ($info_mode) {
#
# Details about an announcement
......
......@@ -49,7 +49,6 @@ $WITHPUBLISHING = 0;
# Other Portal globals.
#
$PORTAL_MANUAL = "https://wiki.emulab.net/wikidocs/wiki";
$PORTAL_MOTD_SITEVAR = "web/banner";
$PORTAL_HELPFORUM = "emulab-users";
$PORTAL_PASSWORD_HELP = "Emulab Username or Email";
$PORTAL_NSFNUMBER = "CNS-58502134";
......
......@@ -54,7 +54,6 @@ if ($_SERVER["SERVER_NAME"] == "www.aptlab.net") {
$APTBASE .= "/" . $matches[1];
}
$PORTAL_MANUAL = "http://docs.aptlab.net";
$PORTAL_MOTD_SITEVAR = "aptlab/message";
$PORTAL_HELPFORUM = "apt-users";
$PORTAL_PASSWORD_HELP = "Aptlab.net or Emulab.net Username";
$PORTAL_NSFNUMBER = "CNS-1338155";
......@@ -87,7 +86,6 @@ elseif ($_SERVER["SERVER_NAME"] == "www.cloudlab.us") {
$APTBASE .= "/" . $matches[1];
}
$PORTAL_MANUAL = "http://docs.cloudlab.us";
$PORTAL_MOTD_SITEVAR = "cloudlab/message";
$PORTAL_HELPFORUM = "cloudlab-users";
$PORTAL_PASSWORD_HELP= "CloudLab.us or Emulab.net Username";
$PORTAL_NSFNUMBER = "CNS-1302688";
......@@ -119,7 +117,6 @@ elseif ($ISALTDOMAIN && $_SERVER["SERVER_NAME"] == "www.phantomnet.org") {
$APTBASE .= "/" . $matches[1];
}
$PORTAL_MANUAL = "http://docs.phantomnet.org";
$PORTAL_MOTD_SITEVAR = "phantomnet/message";
$PORTAL_HELPFORUM = "phantomnet-users";
$PORTAL_PASSWORD_HELP = "PhantomNet.org or Emulab.net Username";
$PORTAL_NSFNUMBER = "CNS-1305384";
......
......@@ -77,7 +77,7 @@ $PAGEERROR_HANDLER = function($msg, $status_code = 0) {
$PAGEHEADER_FUNCTION = function($thinheader = 0, $ignore1 = NULL,
$ignore2 = NULL, $ignore3 = NULL)
{
global $PORTAL_MANUAL, $PORTAL_MOTD_SITEVAR, $PORTAL_HELPFORUM;
global $PORTAL_MANUAL, $PORTAL_HELPFORUM;
global $TBMAINSITE, $APTTITLE, $FAVICON, $APTLOGO, $APTSTYLE, $ISAPT;
global $GOOGLEUA, $ISCLOUD, $ISPNET, $ISEMULAB, $TBBASE, $ISEMULAB;
global $login_user, $login_status, $SUPPORT;
......@@ -350,14 +350,6 @@ $PAGEHEADER_FUNCTION = function($thinheader = 0, $ignore1 = NULL,
if (NOLOGINS()) {
$message = TBGetSiteVar("web/message");
}
else {
#
# Put the special message, if any, right below the header. Note that
# the negative margin is to put it flush below the navbar without
# having to permanently remove the bottom margin on the navbar
#
$message = TBGetSiteVar($PORTAL_MOTD_SITEVAR);
}
if ($message && $message != "" && !$cleanmode) {
echo "<div class='alert alert-warning alert-dismissible'
role='alert' style='margin-top: -10px; padding: 5px;'>
......
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