. // Manage user settings // // Displays user settings, allows one to control special user status // and forum suspension (banishment). Put this in html/ops, // (or could be used by moderators for bans < 24 hrs). // TODO: use DB abstraction layer require_once("../inc/util.inc"); require_once("../inc/user.inc"); require_once("../inc/team.inc"); require_once("../inc/forum.inc"); require_once("../inc/util_ops.inc"); require_once("../inc/profile.inc"); require_once("../project/project.inc"); error_reporting(E_ALL); ini_set('display_errors', true); ini_set('display_startup_errors', true); // Delete a user if they have no credit, results, or posts // function possibly_delete_user($user){ if ($user->total_credit > 0.0){ admin_error_page("Cannot delete user: User has credit."); } // Don't delete user if they have any outstanding Results // if (BoincResult::count("userid=$user->id")) { admin_error_page("Cannot delete user: User has count results in the database."); } // Don't delete user if they have posted to the forums // if (BoincPost::count("user=$user->id")) { admin_error_page("Cannot delete user: User has forum posts."); } if ($user->teamid){ user_quit_team($user); } delete_user($user); } // Process special user settings // function handle_special_user($user) { global $special_user_bitfield; $Nbf = sizeof($special_user_bitfield); $bits=""; for ($i=0; $i<$Nbf; $i++) { $key = "special_user_$i"; if (array_key_exists($key, $_POST) && $_POST[$key]) { $bits .= "1"; } else { $bits .= "0"; } } $q = "UPDATE forum_preferences SET special_user=\"$bits\" WHERE userid=$user->id"; _mysql_query($q); } // Process a suspension: // function handle_suspend($user) { global $g_logged_in_user; $dt = post_int('suspend_for', true); $reason = $_POST['suspend_reason']; if ($dt > 0 && empty($reason)) { admin_error_page("You must supply a reason for a suspension.
id>Try again" ); } else { if (is_numeric($dt)) { $t = $dt>0 ? time()+$dt : 0; $q = "UPDATE forum_preferences SET banished_until=$t WHERE userid=$user->id"; _mysql_query($q); // put a timestamp in wiki to trigger re-validation of credentials if (function_exists('touch_wiki_user')){ touch_wiki_user($user); } // Send suspension e-mail to user and administrators if ($dt>0) { $subject = PROJECT." posting privileges suspended for ". $user->name; $body = " Forum posting privileges for the " .PROJECT. " user \"".$user->name."\" have been suspended for " .time_diff($dt). " by ".$g_logged_in_user->name.". The reason given was: $reason The suspension will end at " .time_str($t)."\n"; } else { $subject = PROJECT." user ". $user->name. " unsuspended"; $body = " Forum posting privileges for the " .PROJECT. " user \"".$user->name."\" have been restored by ".$g_logged_in_user->name."\n"; if ($reason) { $body.="The reason given was:\n\n $reason\n"; } } send_email($user, $subject, $body); $emails = explode(",", POST_REPORT_EMAILS); foreach ($emails as $email) { $admin->email_addr = $email; send_email($admin, $subject, $body); } } } } function show_manage_user_form($user) { global $special_user_bitfield; $Nbf = sizeof($special_user_bitfield); admin_page_head("Management $user->name"); if (!defined("POST_REPORT_EMAILS")) { echo "
There is no administrative email address defined for reporting problems or abuse in the forums. Please define POST_REPORT_EMAILS in project.inc
\n"; } echo "\n"; // Special User status: echo "\n\n
\n"; echo " | "; end_table(); echo "\n"; echo "\n\n | \n\n"; // Suspended posting privileges echo "\n"; echo " |