make it possible to add/remove administrators
This commit is contained in:
@@ -71,6 +71,7 @@ if($_REQUEST['sSubmit'])
|
||||
echo " <td>E-mail</td>\n";
|
||||
echo " <td>Creation date</td>\n";
|
||||
echo " <td>Last connected</td>\n";
|
||||
echo " <td>Roles</td>\n";
|
||||
echo " <td> </td>\n";
|
||||
echo "</tr>\n\n";
|
||||
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->created."</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>] [<a href=\"../preferences.php?userId=".$oRow->userid."&sSearch=".$sSearch."&iLimit=".$_REQUEST['iLimit']."&sOrderBy=".$_REQUEST['sOrderBy']."\">edit</a>]</td>\n";
|
||||
echo "</tr>\n\n";
|
||||
}
|
||||
|
||||
@@ -21,6 +21,18 @@
|
||||
<td> Real Name </td>
|
||||
<td> <input type="text" name="ext_realname" value="<?php echo $ext_realname; ?>"> </td>
|
||||
</tr>
|
||||
<?php
|
||||
// if we manage another user we can give him administrator rights
|
||||
if($iUserId == $_REQUEST['userId'])
|
||||
{
|
||||
?>
|
||||
<tr>
|
||||
<td> Administrator </td>
|
||||
<td> <input type="checkbox" name="ext_hasadmin" "<?php echo $ext_hasadmin; ?>" value="on"> </td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<tr>
|
||||
<td colspan=2> </td>
|
||||
</tr>
|
||||
|
||||
@@ -361,6 +361,21 @@ function UserWantsEmail($userid)
|
||||
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/**********************/
|
||||
/* preferences editor */
|
||||
/**********************/
|
||||
/*******************************/
|
||||
/* preferences and user editor */
|
||||
/*******************************/
|
||||
|
||||
/*
|
||||
* application environment
|
||||
@@ -66,7 +66,14 @@ function show_user_fields()
|
||||
$ext_realname = $user->lookup_realname($iUserId);
|
||||
$ext_email = $user->lookup_email($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");
|
||||
|
||||
echo "<tr><td> Wine version </td><td>";
|
||||
@@ -96,11 +103,15 @@ if($_POST)
|
||||
if ($user->update($iUserId, $str_passwd, $_REQUEST['ext_realname'], $_REQUEST['ext_email'], $_REQUEST['CVSrelease']))
|
||||
{
|
||||
addmsg("Preferences Updated", "green");
|
||||
|
||||
// we were managing an user, let's go back to the admin.
|
||||
if($iUserId == $_REQUEST['userId'])
|
||||
// we were managing an user, let's go back to the admin after updating tha admin status
|
||||
if($iUserId == $_REQUEST['userId'] && havepriv("admin"))
|
||||
{
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user