make it possible to add/remove administrators

This commit is contained in:
Jonathan Ernst
2005-01-17 04:30:39 +00:00
committed by WineHQ
parent f093a01229
commit 791bac8e09
4 changed files with 51 additions and 8 deletions

View File

@@ -71,6 +71,7 @@ if($_REQUEST['sSubmit'])
echo " <td>E-mail</td>\n"; echo " <td>E-mail</td>\n";
echo " <td>Creation date</td>\n"; echo " <td>Creation date</td>\n";
echo " <td>Last connected</td>\n"; echo " <td>Last connected</td>\n";
echo " <td>Roles</td>\n";
echo " <td>&nbsp;</td>\n"; echo " <td>&nbsp;</td>\n";
echo "</tr>\n\n"; echo "</tr>\n\n";
if(is_numeric($_REQUEST['iLimit']) && in_array($_REQUEST['sOrderBy'],array("email","realname","created"))) if(is_numeric($_REQUEST['iLimit']) && in_array($_REQUEST['sOrderBy'],array("email","realname","created")))
@@ -90,6 +91,10 @@ if($_REQUEST['sSubmit'])
echo " <td>".$oRow->email."</td>\n"; echo " <td>".$oRow->email."</td>\n";
echo " <td>".$oRow->created."</td>\n"; echo " <td>".$oRow->created."</td>\n";
echo " <td>".$oRow->stamp."</td>\n"; echo " <td>".$oRow->stamp."</td>\n";
echo " <td>";
if(isAdministrator($oRow->userid)) echo "A";
if(isMaintainer($oRow->userid)) echo "M";
echo " </td>\n";
echo " <td>[<a onclick=\"if(!confirm('".$sAreYouSure."'))return false;\" \"href=\"".$_SERVER['PHP_SELF']."?action=delete&userId=".$oRow->userid."&sSearch=".$sSearch."&iLimit=".$_REQUEST['iLimit']."&sOrderBy=".$_REQUEST['sOrderBy']."&sSubmit=true\">delete</a>]&nbsp;[<a href=\"../preferences.php?userId=".$oRow->userid."&sSearch=".$sSearch."&iLimit=".$_REQUEST['iLimit']."&sOrderBy=".$_REQUEST['sOrderBy']."\">edit</a>]</td>\n"; echo " <td>[<a onclick=\"if(!confirm('".$sAreYouSure."'))return false;\" \"href=\"".$_SERVER['PHP_SELF']."?action=delete&userId=".$oRow->userid."&sSearch=".$sSearch."&iLimit=".$_REQUEST['iLimit']."&sOrderBy=".$_REQUEST['sOrderBy']."&sSubmit=true\">delete</a>]&nbsp;[<a href=\"../preferences.php?userId=".$oRow->userid."&sSearch=".$sSearch."&iLimit=".$_REQUEST['iLimit']."&sOrderBy=".$_REQUEST['sOrderBy']."\">edit</a>]</td>\n";
echo "</tr>\n\n"; echo "</tr>\n\n";
} }

View File

@@ -21,6 +21,18 @@
<td> &nbsp; Real Name </td> <td> &nbsp; Real Name </td>
<td> <input type="text" name="ext_realname" value="<?php echo $ext_realname; ?>"> </td> <td> <input type="text" name="ext_realname" value="<?php echo $ext_realname; ?>"> </td>
</tr> </tr>
<?php
// if we manage another user we can give him administrator rights
if($iUserId == $_REQUEST['userId'])
{
?>
<tr>
<td> &nbsp; Administrator </td>
<td> <input type="checkbox" name="ext_hasadmin" "<?php echo $ext_hasadmin; ?>" value="on"> </td>
</tr>
<?php
}
?>
<tr> <tr>
<td colspan=2>&nbsp;</td> <td colspan=2>&nbsp;</td>
</tr> </tr>

View File

@@ -361,6 +361,21 @@ function UserWantsEmail($userid)
return ($ob->value == 'no' ? false : true); return ($ob->value == 'no' ? false : true);
} }
function isAdministrator($iUserId)
{
$hResult = query_appdb("SELECT * FROM user_privs WHERE userid = ".$iUserId." AND priv = 'admin'");
if(!$hResult)
return 0;
return mysql_num_rows($hResult);
}
function isMaintainer($iUserId)
{
$hResult = query_appdb("SELECT * FROM appMaintainers WHERE userId = ".$iUserId);
if(!$hResult)
return 0;
return mysql_num_rows($hResult);
}
/** /**
* get the email address of people to notify for this appId and versionId * get the email address of people to notify for this appId and versionId

View File

@@ -1,7 +1,7 @@
<?php <?php
/**********************/ /*******************************/
/* preferences editor */ /* preferences and user editor */
/**********************/ /*******************************/
/* /*
* application environment * application environment
@@ -66,7 +66,14 @@ function show_user_fields()
$ext_realname = $user->lookup_realname($iUserId); $ext_realname = $user->lookup_realname($iUserId);
$ext_email = $user->lookup_email($iUserId); $ext_email = $user->lookup_email($iUserId);
$CVSrelease = $user->lookup_CVSrelease($iUserId); $CVSrelease = $user->lookup_CVSrelease($iUserId);
// if we are managing anothe user
if($iUserId == $_REQUEST['userId'])
{
if(isAdministrator($iUserId))
$ext_hasadmin = 'checked="true"';
else
$ext_hasadmin = "";
}
include(BASE."include/"."form_edit.php"); include(BASE."include/"."form_edit.php");
echo "<tr><td>&nbsp; Wine version </td><td>"; echo "<tr><td>&nbsp; Wine version </td><td>";
@@ -96,11 +103,15 @@ if($_POST)
if ($user->update($iUserId, $str_passwd, $_REQUEST['ext_realname'], $_REQUEST['ext_email'], $_REQUEST['CVSrelease'])) if ($user->update($iUserId, $str_passwd, $_REQUEST['ext_realname'], $_REQUEST['ext_email'], $_REQUEST['CVSrelease']))
{ {
addmsg("Preferences Updated", "green"); addmsg("Preferences Updated", "green");
// we were managing an user, let's go back to the admin after updating tha admin status
// we were managing an user, let's go back to the admin. if($iUserId == $_REQUEST['userId'] && havepriv("admin"))
if($iUserId == $_REQUEST['userId'])
{ {
redirect(BASE."admin/adminUsersEdit.php?userId=".$iUserId."&sSearch=".$_REQUEST['sSearch']."&iLimit=".$_REQUEST['iLimit']."&sOrderBy=".$_REQUEST['sOrderBy']."&sSubmit=true"); $user->userid = $iUserId;
if($_POST['ext_hasadmin']=="on")
$user->addpriv("admin");
else
$user->delpriv("admin");
redirect(BASE."admin/adminUsers.php?userId=".$iUserId."&sSearch=".$_REQUEST['sSearch']."&iLimit=".$_REQUEST['iLimit']."&sOrderBy=".$_REQUEST['sOrderBy']."&sSubmit=true");
} }
} }
else else