diff --git a/html/ops/manage_user.php b/html/ops/manage_user.php index 6eac082cd8..9d461306fe 100644 --- a/html/ops/manage_user.php +++ b/html/ops/manage_user.php @@ -3,8 +3,10 @@ * Manage user settings * * Displays user settings, allows one to control special user status - * and forum suspension (banishment). Put this in html/ops + * and forum suspension (banishment). Put this in html/ops, + * (or could be used by moderators for bans < 24 hrs). * + * @(#) $Id$ \***********************************************************************/ require_once("../inc/util.inc"); @@ -14,49 +16,70 @@ require_once("../inc/util_ops.inc"); require_once("../inc/profile.inc"); require_once("../project/project.inc"); -// Stuff for user roles and wiki interface. -// (Should work even if you comment these out) -/** -require_once("../include/roles.php"); -require_once("../include/mediawiki.php"); -**/ - - db_init(); -$logged_in_user = get_logged_in_user(true); -$logged_in_user= getForumPreferences($logged_in_user); +$is_admin = true; +$Nbf = sizeof($special_user_bitfield); -if( function_exists('is_Administrator') ){ // only (now) on Pirates@Home - if( !is_Administrator($logged_in_user) ){ - error_page("You must be a project administrator to use this page."); - } - } +/** + * Process user search form + */ + +$matches=""; + +if( isset($_POST['search_submit']) ){ + $search_name = post_str('search_text'); + $search_name = process_user_text(strip_tags($search_name)); + + if( !empty($search_name) ){ + $result = mysql_query("SELECT * FROM user WHERE name='$search_name'"); + + if( mysql_num_rows($result)==1 ) { + $user = mysql_fetch_object($result); + mysql_free_result($result); + } + else { + $q = "SELECT * FROM user WHERE name LIKE '%".$search_name."%'"; + $result = mysql_query($q); + if( mysql_num_rows($result)==1 ) { + $user = mysql_fetch_object($result); + mysql_free_result($result); + } + if( mysql_num_rows($result)>1 ) { + while( $row = mysql_fetch_object($result) ){ + if( !empty($matches) ) $matches .= ", "; + $matches .= $row->name; + } + mysql_free_result($result); + } + } + } +} + + +/** + * Look up the user + */ $id = get_int("userid", true); -if(!isset($id) ) $id = post_int("userid", true); - -if( !$id || !is_numeric($id) || $id <= 0 ) { - error_page("Must specify a userid"); +if( empty($id) ) $id = post_int("userid", true); +if( !empty($id) ){ + $user = lookup_user_id($id); } +// but clear if page was reset (forcing search form) -// Look up the user - -$user=lookup_user_id($id); -if( !$user ) { - error_page("Cannot find user $id"); +if( isset($_POST['reset_page']) ){ + unset($user); } -$self = $_SERVER['PHP_SELF']; -$Nbf = sizeof($special_user_bitfield); /** * Process special user settings */ -if( isset($_POST['special_user']) ){ +if( isset($_POST['special_user']) && $user && $is_admin ){ $bits=""; for($i=0;$i<$Nbf;$i++) { $bits .= $_POST['special_user_'.$i] ? "1" : "0" ; @@ -70,14 +93,16 @@ if( isset($_POST['special_user']) ){ * Process a suspension: */ -if( isset($_POST['suspend_submit']) ){ +if( isset($_POST['suspend_submit']) && !empty($user) && $is_admin ){ $dt = post_int('suspend_for',true); - if( user_has_permission('moderator') ){ + + if( $is_admin || ($is_mod && $dt < 86400) ){ $reason = $_POST['suspend_reason']; if( $dt > 0 && empty($reason) ) { error_page("You must supply a reason for a suspension.
Try again"); - } else { + } + else { if( is_numeric($dt) ) { $t = time()+$dt; $q = "UPDATE forum_preferences SET banished_until=$t WHERE userid=$id"; @@ -91,7 +116,7 @@ if( isset($_POST['suspend_submit']) ){ /* Send suspension e-mail to user and administrators */ - if($dt>0){ + if( $dt>0 ){ $subject = PROJECT." posting privileges suspended for ". $user->name; $body = " Forum posting privileges for the " .PROJECT. " user \"".$user->name."\" @@ -117,18 +142,18 @@ have been restored by ".$logged_in_user->name."\n"; $admin->email_addr = $email; send_email($admin, $subject, $body); } - - }// + }//numerical($dt) } } }// suspend_submit -// Now update from whatever was set - -$user=getForumPreferences($user); +// Now update from whatever might have been set above +if( !empty($user) ) { + $user=getForumPreferences($user); +} /******************************** * Output: @@ -138,24 +163,49 @@ admin_page_head("User Management: $user->name"); echo "\n\n"; echo "\n\n"; +echo "
+ echo "
There is no addministrative e-mail address defined for reporting problems
or abuse in the forums. Please define POST_REPORT_EMAILS in project.inc
+ Id# ". $user->id
. "