";
echo " ";
echo $contents;
echo " ";
echo "";
echo "\n";
}
#
# SIDEBARCELL - Make a cell for the sidebar
#
function SIDEBARCELL($contents, $last = 0) {
echo "
";
if ($last) {
echo "";
echo "
";
echo "\n";
}
#
# WRITETOPBARBUTTON(text, base, link): Write a button in the topbar
#
function WRITETOPBARBUTTON($text, $base, $link ) {
$link = "$base/$link";
TOPBARCELL("$text");
}
# same as above with "new" gif next to it.
function WRITETOPBARBUTTON_NEW($text, $base, $link ) {
$link = "$base/$link";
TOPBARCELL("$text
");
}
#
# WRITESIDEBARDIVIDER(): Put a bit of whitespace in the sidebar
#
function WRITESIDEBARDIVIDER() {
global $BASEPATH;
echo "";
echo "";
echo "
";
echo "\n";
}
#
# WRITESIDEBARBUTTON(text, link): Write a button on the sidebar menu.
# We do not currently try to match the current selection so that its
# link looks different. Not sure its really necessary.
#
function WRITESIDEBARBUTTON($text, $base, $link ) {
if ($base)
$link = "$base/$link";
SIDEBARCELL("$text");
}
# same as above with "new" gif next to it.
function WRITESIDEBARBUTTON_NEW($text, $base, $link ) {
$link = "$base/$link";
SIDEBARCELL("$text
");
}
# same as above with "cool" gif next to it.
function WRITESIDEBARBUTTON_COOL($text, $base, $link ) {
$link = "$base/$link";
SIDEBARCELL("$text
");
}
function WRITESIDEBARBUTTON_ABS($text, $base, $link ) {
$link = "$link";
SIDEBARCELL("$text\n");
}
function WRITESIDEBARBUTTON_ABSCOOL($text, $base, $link ) {
$link = "$link";
SIDEBARCELL("$text
");
}
# same as above, but uses a slightly different style sheet so there
# is more padding below the last button.
# The devil is, indeed, in the details.
function WRITESIDEBARLASTBUTTON($text, $base, $link) {
$link = "$base/$link";
SIDEBARCELL("$text",1);
}
function WRITESIDEBARLASTBUTTON_COOL($text, $base, $link) {
$link = "$base/$link";
SIDEBARCELL("$text
",1);
}
# writes a message to the sidebar, without clickability.
function WRITESIDEBARNOTICE($text) {
SIDEBARCELL("$text");
}
#
# Something like the sidebar, but across the top, with only a few options.
# Think Google. For PlanetLab users, but it would be easy enough to make
# others. Still a work in progress.
#
function WRITEPLABTOPBAR() {
echo "\n";
global $login_status, $login_uid;
global $TBBASE, $TBDOCBASE, $BASEPATH;
global $THISHOMEBASE;
WRITETOPBARBUTTON("Create a Slice",
$TBBASE, "plab_ez.php3");
WRITETOPBARBUTTON("Nodes",
$TBBASE, "plabmetrics.php3");
WRITETOPBARBUTTON("My Testbed",
$TBBASE,
"showuser.php3?target_uid=$login_uid");
WRITETOPBARBUTTON("Advanced Experiment",
$TBBASE, "beginexp_html.php3");
if ($login_status & CHECKLOGIN_TRUSTED) {
# Only project/group leaders can do these options
# Show a "new" icon if there are people waiting for approval
$query_result =
DBQueryFatal("select g.* from group_membership as authed ".
"left join group_membership as g on ".
" g.pid=authed.pid and g.gid=authed.gid ".
"left join users as u on u.uid=g.uid ".
"where u.status!='".
TBDB_USERSTATUS_UNVERIFIED . "' and ".
" u.status!='" . TBDB_USERSTATUS_NEWUSER .
"' and g.uid!='$login_uid' and ".
" g.trust='". TBDB_TRUSTSTRING_NONE . "' ".
" and authed.uid='$login_uid' and ".
" (authed.trust='group_root' or ".
" authed.trust='project_root') ".
"ORDER BY g.uid,g.pid,g.gid");
if (mysql_num_rows($query_result) > 0) {
WRITETOPBARBUTTON_NEW("Approve Users",
$TBBASE, "approveuser_form.php3");
} else {
WRITETOPBARBUTTON("Approve Users",
$TBBASE, "approveuser_form.php3");
}
}
WRITETOPBARBUTTON("Log Out", $TBBASE, "logout.php3?next_page=" .
urlencode($TBBASE . "/login_plab.php3"));
echo "
\n";
echo "
\n";
}
#
# Put a few things that PlanetLab users should see, but are non-essential,
# across the bottom of the page rather than the top
#
function WRITEPLABBOTTOMBAR() {
global $login_status, $login_uid;
global $TBBASE, $TBDOCBASE, $BASEPATH;
global $THISHOMEBASE;
if ($login_uid) {
$newsBase = $TBBASE;
} else {
$newsBase = $TBDOCBASE;
}
echo "
\n";
}
#
# WRITESIDEBAR(): Write the menu. The actual menu options the user
# sees depends on the login status and the DB status.
#
function WRITESIDEBAR() {
global $login_status, $login_uid, $pid, $gid;
global $TBBASE, $TBDOCBASE, $BASEPATH, $WIKISUPPORT, $MAILMANSUPPORT;
global $BUGDBSUPPORT, $BUGDBURL;
global $CHECKLOGIN_WIKINAME;
global $THISHOMEBASE;
$firstinitstate = TBGetFirstInitState();
#
# The document base cannot be a mix of secure and nonsecure.
#
# create the main menu table, which also happens to reside in a form
# (for search.)
#
# get post time of most recent news;
# get both displayable version and age in days.
#
$query_result =
DBQueryFatal("SELECT DATE_FORMAT(date, '%M %e') AS prettydate, ".
" (TO_DAYS(NOW()) - TO_DAYS(date)) AS age ".
"FROM webnews ".
"WHERE archived=0 ".
"ORDER BY date DESC ".
"LIMIT 1");
$newsDate = "";
$newNews = 0;
#
# This is so an admin can use the editing features of news.
#
if ($login_uid) { # && ISADMIN($login_uid)) {
$newsBase = $TBBASE;
} else {
$newsBase = $TBDOCBASE;
}
if ($row = mysql_fetch_array($query_result)) {
$newsDate = "(".$row[prettydate].")";
if ($row[age] < 7) {
$newNews = 1;
}
}
echo "