diff --git a/include/user.php b/include/user.php
index 2c3bed7..4b340d1 100644
--- a/include/user.php
+++ b/include/user.php
@@ -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
diff --git a/preferences.php b/preferences.php
index 05a26e1..7ae1289 100644
--- a/preferences.php
+++ b/preferences.php
@@ -1,7 +1,7 @@
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 "
Wine version
";
@@ -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