. // 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 "
"; start_table(); row1("User: $user->name
" ); show_user_summary_public($user); show_profile_link_ops($user); row2("Email:", "$user->email_addr"); project_user_summary($user); end_table(); project_user_page_private($user); echo "
\n"; // Special User status: echo "\n\n

\n"; for ($i=0; $i<$Nbf; $i++) { $bit = substr($user->prefs->special_user, $i, 1); echo "\n"; } echo ""; echo " "; end_table(); echo "\n"; echo "\n\n\n"; end_table(); echo "\n"; echo "
\n"; echo "
"; start_table(); row1("Special User Status"); echo "
". $special_user_bitfield[$i] ."
\n\n"; // Suspended posting privileges echo "
"; start_table(); row1("Suspension"); if ($user->prefs->banished_until) { $dt = $user->prefs->banished_until - time(); if ($dt > 0) { $x = " Suspended until " . time_str($user->prefs->banished_until) ."
(Expires in " . time_diff($dt) .")" ; } else { $x = " last suspended " . time_str($user->prefs->banished_until); } row1($x); } else { $dt = 0; } echo "
Suspend user for:
1 hour
2 hours
6 hours
12 hours
24 hours
"; echo " 48 hours
1 week
2 weeks
"; if ($dt>0) { echo " unsuspend
"; } echo "
"; echo "

Reason (required):\n"; echo ""; echo "
The reason will be sent to both the user and to the project administrators.\n"; echo "

\n"; echo "
\n"; admin_page_tail(); } get_logged_in_user(); db_init(); $q = null; $id = get_int("userid", true); if (!$id) { $id = post_int("userid", true); } if (!$id) admin_error_page("No ID given"); $user = BoincUser::lookup_id($id); if (!$user) admin_error_page("No such user: $id"); BoincForumPrefs::lookup($user); if (isset($_POST['delete_user'])) { possibly_delete_user($user); admin_page_head("User deleted"); echo " User $user->name ($user->id) deleted.

id"); } if (isset($_POST['suspend_submit'])) { handle_suspend($user); Header("Location: manage_user.php?userid=$user->id"); } show_manage_user_form($user); $cvs_version_tracker[]= //Generated automatically - do not edit "\$Id$"; ?>