Commit a7160b9c authored by Leigh Stoller's avatar Leigh Stoller

As promised, adminmode now defaults to off. See red/green dot in the

Banner bar to indicate what you are. Click the dot toggles the mode.
Might have the colors backwards though. Perhaps green dot should
indicate adminmode is off and red dot indicate on?
parent efe27f09
......@@ -259,12 +259,13 @@ function WRITESIDEBAR() {
#
function WRITEBANNER($title) {
global $BANNERCOLOR, $THISPROJECT, $THISHOMEBASE, $BASEPATH;
global $login_uid;
echo "<!-- This is the page Banner -->\n";
echo "<table cellpadding=0 cellspacing=0 border=0 width=50%>";
echo "<tr>
<td align=left valign=top width=\"0%\">
<td align=left valign=top width=0%>
<table cellpadding=5 cellspacing=0 border=0 bgcolor=\"#880000\">
<tr>
<td>
......@@ -276,7 +277,7 @@ function WRITEBANNER($title) {
</tr>
</table>
</td>
<td align=left valign=top width=100%>
<td align=left valign=top width=70%>
<table cellpadding=5 cellspacing=0 border=0
bgcolor=$BANNERCOLOR>
<tr>
......@@ -290,6 +291,33 @@ function WRITEBANNER($title) {
<tr>
</table>
</td>
<td align=left valign=center width=50%>
<table cellpadding=0 cellspacing=0 border=0>
<tr>
<td nowrap align=right>\n";
if ($login_uid && ISADMININSTRATOR()) {
if (ISADMIN($login_uid)) {
echo "<a href=adminmode.php3?target_uid=$login_uid&adminoff=1>
<img src='/autostatus-icons/greenball.gif'
alt='Admin On'></a>\n";
}
else {
echo "<a href=adminmode.php3?target_uid=$login_uid&adminoff=0>
<img src='/autostatus-icons/redball.gif'
alt='Admin Off'></a>\n";
}
}
else {
echo " <b>
<font size=5 face=helvetica color=\"#000000\">
&nbsp
</font>
</b>\n";
}
echo " </td>
<tr>
</table>
</td>
</tr>
</table>\n";
}
......@@ -310,7 +338,7 @@ function WRITETITLE($title) {
#
echo " </td>
<td align=left>
<td align=left width=\"90%\">
<b><font size=5 color=$TITLECOLOR>$title</font></b>
</td>
</tr>
......
......@@ -281,9 +281,10 @@ function LOGGEDINORDIE($uid, $modifier = 0) {
}
#
# Is this user an admin type? Its actually incorrect to look at the
# $uid. Its the currently logged in user that has to be admin. So
# ignore the uid and make sure there is a login status.
# Is this user an admin type, and is his admin bit turned on.
# Its actually incorrect to look at the $uid. Its the currently logged
# in user that has to be admin. So ignore the uid and make sure
# there is a login status.
#
function ISADMIN($uid) {
global $CHECKLOGIN_STATUS;
......@@ -296,6 +297,18 @@ function ISADMIN($uid) {
(CHECKLOGIN_LOGGEDIN|CHECKLOGIN_ISADMIN));
}
# Is this user a real administrator (ignore onoff bit).
function ISADMININSTRATOR() {
global $CHECKLOGIN_STATUS;
if ($CHECKLOGIN_STATUS == CHECKLOGIN_NOSTATUS)
TBERROR("ISADMIN: $uid is not logged in!", 1);
return (($CHECKLOGIN_STATUS &
(CHECKLOGIN_LOGGEDIN|CHECKLOGIN_ISADMIN)) ==
(CHECKLOGIN_LOGGEDIN|CHECKLOGIN_ISADMIN));
}
#
# Attempt a login.
#
......@@ -375,9 +388,9 @@ function DOLOGIN($uid, $password) {
setcookie($TBNAMECOOKIE, $uid, $timeout, "/", $TBAUTHDOMAIN, 0);
#
# Clear adminoff on new logins.
# Set adminoff on new logins.
#
DBQueryFatal("update users set adminoff=0 where uid='$uid'");
DBQueryFatal("update users set adminoff=1 where uid='$uid'");
return 0;
}
......
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