diff --git a/admin/adminUsers.php b/admin/adminUsers.php
new file mode 100644
index 0000000..63c90ad
--- /dev/null
+++ b/admin/adminUsers.php
@@ -0,0 +1,101 @@
+remove($sEmail);
+ }
+}
+
+// search form
+echo html_frame_start("Users Management","400","",0)
+?>
+
+\n\n";
+ echo "\n";
+ echo " | Real name | \n";
+ echo " E-mail | \n";
+ echo " Creation date | \n";
+ echo " Last connected | \n";
+ echo " | \n";
+ echo "
\n\n";
+ if(is_numeric($_REQUEST['iLimit']) && in_array($_REQUEST['sOrderBy'],array("email","realname","created")))
+ {
+ $sSearch = addslashes($_REQUEST['sSearch']);
+ $sQuery = "SELECT * FROM user_list
+ WHERE realname LIKE '%".$sSearch."%' OR email LIKE '%".$sSearch."%'
+ ORDER BY ".$_REQUEST['sOrderBy']."
+ LIMIT ".$_REQUEST['iLimit'];
+ $hResult = query_appdb($sQuery);
+ $i=0;
+ while($hResult && $oRow = mysql_fetch_object($hResult))
+ {
+ $sAreYouSure = "Are you sure that you want to delete user ".addslashes($oRow->realname)." ?";
+ echo "\n";
+ echo " | ".$oRow->realname." | \n";
+ echo " ".$oRow->email." | \n";
+ echo " ".$oRow->created." | \n";
+ echo " ".$oRow->stamp." | \n";
+ echo " [userid."&sSearch=".$sSearch."&iLimit=".$_REQUEST['iLimit']."&sOrderBy=".$_REQUEST['sOrderBy']."&sSubmit=true\">delete] [userid."&sSearch=".$sSearch."&iLimit=".$_REQUEST['iLimit']."&sOrderBy=".$_REQUEST['sOrderBy']."\">edit] | \n";
+ echo "
\n\n";
+ }
+ }
+ echo "";
+ echo html_frame_end();
+}
+apidb_footer();
+?>
diff --git a/include/sidebar_admin.php b/include/sidebar_admin.php
index 8c3b8c3..c25d6be 100644
--- a/include/sidebar_admin.php
+++ b/include/sidebar_admin.php
@@ -12,7 +12,6 @@ function global_admin_menu() {
$g->add("Add Vendor", BASE."admin/addVendor.php");
$g->addmisc(" ");
- $g->add("List Users", BASE."admin/");
$g->add("View App Queue (".getQueuedAppCount().")", BASE."admin/adminAppQueue.php");
$g->add("View App Data Queue (".getQueuedAppDataCount().")", BASE."admin/adminAppDataQueue.php");
$g->add("View Maintainer Queue (".getQueuedMaintainerCount().")", BASE."admin/adminMaintainerQueue.php");
@@ -20,7 +19,8 @@ function global_admin_menu() {
$g->add("View Vendors (".getVendorCount().")", BASE."admin/adminVendors.php");
$g->addmisc(" ");
- $g->add("Comment manager", BASE."admin/adminCommentView.php");
+ $g->add("Users Management", BASE."admin/adminUsers.php");
+ $g->add("Comments Management", BASE."admin/adminCommentView.php");
$g->done();
}
diff --git a/include/user.php b/include/user.php
index ab200db..2c3bed7 100644
--- a/include/user.php
+++ b/include/user.php
@@ -165,17 +165,13 @@ class User {
* remove the current, or specified user from the database
* returns 0 on success and an error msg on failure
*/
- function remove($sEmail = 0)
+ function remove($sEmail = "")
{
- if($sEmail == 0)
+ if(!$sEmail)
$sEmail = $this->email;
-
- $result = query_appdb("DELETE FROM user_list WHERE email = '$sEmail'");
-
+ $result = query_appdb("DELETE FROM user_list WHERE email = '".$sEmail."'");
if(!$result)
return "A database error occured";
- if(mysql_affected_rows($result) == 0)
- return "No such user.";
return 0;
}
diff --git a/preferences.php b/preferences.php
index 525278c..05a26e1 100644
--- a/preferences.php
+++ b/preferences.php
@@ -15,6 +15,20 @@ if(!loggedin())
exit;
}
+// we come from the administration to edit an user
+if(havepriv("admin") &&
+ is_numeric($_REQUEST['userId']) &&
+ is_numeric($_REQUEST['iLimit']) &&
+ in_array($_REQUEST['sOrderBy'],array("email","realname","created"))
+)
+{
+ $iUserId = $_REQUEST['userId'];
+} else
+{
+ $iUserId = $_SESSION['current']->userid;
+}
+
+
function build_prefs_list()
{
$result = query_appdb("SELECT * FROM prefs_list ORDER BY id");
@@ -46,19 +60,18 @@ function build_prefs_list()
function show_user_fields()
{
-
- $user = new User();
-
- $ext_realname = $user->lookup_realname($_SESSION['current']->userid);
- $ext_email = $user->lookup_email($_SESSION['current']->userid);
- $CVSrelease = $user->lookup_CVSrelease($_SESSION['current']->userid);
-
- include(BASE."include/"."form_edit.php");
+ global $iUserId;
+ $user = new User();
- echo "| Wine version | ";
- make_bugzilla_version_list("CVSrelease", $CVSrelease);
- echo " |
";
+ $ext_realname = $user->lookup_realname($iUserId);
+ $ext_email = $user->lookup_email($iUserId);
+ $CVSrelease = $user->lookup_CVSrelease($iUserId);
+
+ include(BASE."include/"."form_edit.php");
+ echo "| Wine version | ";
+ make_bugzilla_version_list("CVSrelease", $CVSrelease);
+ echo " |
";
}
if($_POST)
@@ -80,10 +93,15 @@ if($_POST)
{
addmsg("The Passwords you entered did not match.", "red");
}
-
- if ($user->update($_SESSION['current']->userid, $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");
+
+ // we were managing an user, let's go back to the admin.
+ if($iUserId == $_REQUEST['userId'])
+ {
+ redirect(BASE."admin/adminUsersEdit.php?userId=".$iUserId."&sSearch=".$_REQUEST['sSearch']."&iLimit=".$_REQUEST['iLimit']."&sOrderBy=".$_REQUEST['sOrderBy']."&sSubmit=true");
+ }
}
else
{
@@ -93,16 +111,28 @@ if($_POST)
apidb_header("User Preferences");
-echo "\n";