Commit 1a64d271 authored by Dan Reading's avatar Dan Reading
Browse files

Merge branch 'master' of gitlab.flux.utah.edu:emulab/emulab-devel

git commit said I have to to a pull first
parents 8822cb74 3dcc3a92
......@@ -31,24 +31,26 @@ 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";
print STDERR " -a Create a new announcement with the given announcement text.\n";
print STDERR " -p Set the portal to be the one given. Should be one of 'cloudlab', 'emulab', 'aptlab', 'phantomnet'.\n";
print STDERR " -s Set the style of the overall announcement box. Should normally be one of bootstraps alert-* classes. Defaults to 'alert-info'.\n";
print STDERR " Common styles: 'alert-success' -> green, 'alert-info' -> blue, 'alert-warning' -> yellow, 'alert-danger' -> red\n\n";
print STDERR " -b If there is an action associated with this announcement, this is the text which goes into the action button. Can include HTML. If it is unset, there is no action button.\n";
print STDERR " -u URL of action associated with this announcement. {uid_idx} and {uid} can be used as URL templates to generate a different URL on a per-user basis. If it is unset, there is no action button.\n";
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";
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;
......@@ -62,6 +64,7 @@ my $retire_idx = undef;
my $info_idx = undef;
my $text = undef;
my $list_type = "active";
my $compatibility = 0;
my $query_result;
......@@ -80,6 +83,7 @@ my $TBOPS = "@TBOPSEMAIL@";
use lib "@prefix@/lib";
use emdb;
use libtestbed;
use libdb;
use User;
#
......@@ -132,12 +136,25 @@ if (defined($options{"u"})) {
if (defined($options{"m"})) {
$max_seen = $options{"m"};
}
if (defined($options{"c"})) {
$compatibility = 1;
}
if ($add_mode + $list_mode + $retire_mode + $info_mode != 1) {
usage();
if ($add_mode)
{
if (! defined($portal)) {
print STDERR "Portal must be defined when adding an announcement\n\n";
usage();
}
elsif ($portal ne "cloudlab" && $portal ne "emulab" &&
$portal ne "aptlab" && $portal ne "phantomnet") {
print STDERR "Portal $portal is invalid. Must be cloudlab, emulab, aptlab, or phantomnet.\n\n";
usage();
}
}
if ($add_mode and ! defined($portal)) {
if ($add_mode + $list_mode + $retire_mode + $info_mode != 1) {
print STDERR "No mode selected. Must use one of -a, -r, -l, or -i\n\n";
usage();
}
......@@ -168,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
......@@ -198,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
......
......@@ -1366,7 +1366,7 @@ $(function ()
" </select>" +
" </div>" +
"<div class='col-sm-4'></div>" +
"<div class='col-sm-6 alert alert-danger' id='where-nowhere' style='display: none; margin-top: 5px; margin-bottom: 5px'>This profile <b>will not work on any clusters</b>. All clusters are unselectable.</div>" +
"<div class='col-sm-6 alert alert-danger' id='where-nowhere' style='display: none; margin-top: 5px; margin-bottom: 5px'>This profile <b>will not work on any clusters</b>. Please check your profile or parameters for errors. If you are sure they are correct, you can report the problem to support@cloudlab.us and make sure to link to the problematic profile.</div>" +
" </div>" +
"</div>";
}
......
......@@ -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