Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to suspend private messaging ability #4376

Open
wants to merge 11 commits into
base: feature
Choose a base branch
from
73 changes: 71 additions & 2 deletions admin/modules/user/users.php
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@
}
}

// Moderator "Options" (suspend signature, suspend/moderate posting)
// Moderator "Options" (suspend signature, suspend/moderate posting, suspend private messaging)
$moderator_options = array(
1 => array(
"action" => "suspendsignature", // The moderator action we're performing
Expand All @@ -752,6 +752,13 @@
"time" => "suspost_time",
"update_field" => "suspendposting",
"update_length" => "suspensiontime"
),
4 => array(
"action" => "suspendprivatemessaging",
"period" => "suspm_period",
"time" => "suspm_time",
"update_field" => "suspendpm",
"update_length" => "pmsuspensiontime"
)
);

Expand Down Expand Up @@ -1679,6 +1686,45 @@ function toggleAction()
$lang->suspend_posts_info = $lang->sprintf($lang->suspend_posts_info, htmlspecialchars_uni($user['username']));
$form_container->output_row($form->generate_check_box("suspendposting", 1, $lang->suspend_posts, array("id" => "suspendposting", "onclick" => "toggleBox('suspost');", "checked" => $mybb->get_input('suspendposting'))), $lang->suspend_posts_info, $suspost_div);

// Suspend private messaging
// Generate check box
$suspm_options = $form->generate_select_box('suspm_period', $periods, $mybb->get_input('suspm_period'), array('id' => 'suspm_period'));

// Do we have any existing suspensions here?
if($user['suspendpm'] || ($mybb->get_input('suspendpm') && !empty($errors)))
{
$mybb->input['suspendpm'] = 1;

if($user['pmsuspensiontime'] == 0 || $mybb->get_input('suspm_period') == "never")
{
$existing_info = $lang->suspended_perm;
}
else
{
$remaining = $user['pmsuspensiontime']-TIME_NOW;
$suspm_date = nice_time($remaining, array('seconds' => false));

$color = 'inherit';
if($remaining < 3600)
{
$color = 'red';
}
elseif($remaining < 86400)
{
$color = 'maroon';
}
elseif($remaining < 604800)
{
$color = 'green';
}

$existing_info = $lang->sprintf($lang->suspend_length, $suspm_date, $color);
}
}

$suspm_div = '<div id="suspm">'.$existing_info.''.$lang->suspend_for.' '.$form->generate_numeric_field("suspm_time", $mybb->get_input('suspm_time'), array('style' => 'width: 3em;', 'min' => 0)).' '.$suspm_options.'</div>';
$lang->suspend_pm_info = $lang->sprintf($lang->suspend_pm_info, htmlspecialchars_uni($user['username']));
$form_container->output_row($form->generate_check_box("suspendprivatemessaging", 1, $lang->suspend_privatemessaging, array("id" => "suspendprivatemessaging", "onclick" => "toggleBox('suspm');", "checked" => $mybb->get_input('suspendpm'))), $lang->suspend_pm_info, $suspm_div);

$form_container->end();
$plugins->run_hooks("admin_user_users_edit_moderator_options");
Expand Down Expand Up @@ -1724,6 +1770,20 @@ function toggleBox(action)
$("#suspost").hide();
}
}
else if(action == "suspm")
{
$("#suspendprivatemessaging").attr("checked", false);
$("#suspm").hide();

if($("#suspendprivatemessaging").is(":checked") == true)
{
$("#suspm").show();
}
else if($("#suspendprivatemessaging").is(":checked") == false)
{
$("#suspm").hide();
}
}
}

if($("#moderateposting").is(":checked") == false)
Expand All @@ -1744,6 +1804,15 @@ function toggleBox(action)
$("#suspost").show();
}

if($("#suspendprivatemessaging").is(":checked") == false)
{
$("#suspm").hide();
}
else
{
$("#suspm").show();
}

// -->
</script>';

Expand Down Expand Up @@ -4396,4 +4465,4 @@ function merge_thread_ratings($source_uid, $destination_uid)
}
}
}
}
}
2 changes: 1 addition & 1 deletion inc/datahandlers/pm.php
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ function verify_recipient()
}

// Can the recipient actually receive private messages based on their permissions or user setting?
if(($user['receivepms'] == 0 || $recipient_permissions['canusepms'] == 0) && empty($pm['saveasdraft']))
if(($user['receivepms'] == 0 || $recipient_permissions['canusepms'] == 0 || $user['suspendpm']) && empty($pm['saveasdraft']))
{
$this->set_error("recipient_pms_disabled", array(htmlspecialchars_uni($user['username'])));
return false;
Expand Down
3 changes: 3 additions & 0 deletions inc/languages/english/admin/user_users.lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,9 @@
$l['suspended_perm'] = "<p><small>Suspended permanently.<br />Enter a new time below to change or untick this option to remove this suspension.</small></p>";
$l['suspend_length'] = "<p><small>Remaining Suspension: <span style=\"color: {2};\">{1}</span>.<br />Enter a new time below to change or untick this option to remove this suspension.</small></p>";

$l['suspend_privatemessaging'] = "Suspend Private Messaging";
$l['suspend_pm_info'] = "Suspend {1} from sending/receiving private messages.";

$l['suspendsignature_error'] = "You selected to suspend this user's signature, but didn't enter a valid time period. Please enter a valid time to continue or untick the option to cancel.";
$l['moderateposting_error'] = "You selected to moderate this user's posts, but didn't enter a valid time period. Please enter a valid time to continue or untick the option to cancel.";
$l['suspendposting_error'] = "You selected to suspend this user's posts, but didn't enter a valid time period. Please enter a valid time to continue or untick the option to cancel.";
Expand Down
5 changes: 5 additions & 0 deletions inc/languages/english/modcp.lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,18 +247,23 @@
$l['moderation'] = "Moderator Options";
$l['moderate_posts'] = "Moderate this user's posts";
$l['suspend_posts'] = "Suspend this user's posting privileges";
$l['suspend_pm'] = "Suspend this user's private messaging privileges";
$l['modpost_length'] = "Moderate for:";
$l['suspost_length'] = "Suspend for:";
$l['suspm_length'] = "Suspend for:";

$l['moderateposts_for'] = "Moderated until {1}.<br />Untick this option to remove, or extend below.";
$l['suspendposting_for'] = "Suspended until {1}.<br />Untick this option to remove, or extend below.";
$l['suspendsignature_for'] = "Suspended until {1}.<br />Untick this option to remove, or extend below.";
$l['suspendpm_for'] = "Suspended until {1}.<br />Untick this option to remove, or extend below.";
$l['suspendposting_perm'] = "Suspended permanently.<br />Untick this option to remove, or change below.";
$l['moderateposts_perm'] = "Moderated permanently.<br />Untick this option to remove, or change below.";
$l['suspendsignature_perm'] = "Suspended permanently.<br />Untick this option to remove, or change below.";
$l['suspendpm_perm'] = "Suspended permanently.<br />Untick this option to remove, or change below.";
$l['suspendsignature_error'] = "You selected to suspend this user's signature, but didn't enter a valid time period. Please enter a valid time to continue or untick the option to cancel.";
$l['moderateposting_error'] = "You selected to moderate this user's posts, but didn't enter a valid time period. Please enter a valid time to continue or untick the option to cancel.";
$l['suspendposting_error'] = "You selected to suspend this user's posts, but didn't enter a valid time period. Please enter a valid time to continue or untick the option to cancel.";
$l['suspendpm_error'] = "You selected to suspend this user's private messaging, but didn't enter a valid time period. Please enter a valid time to continue or untick the option to cancel.";
$l['suspendmoderate_error'] = "You've selected to suspend and moderate the user's posts. Please select only one type of moderation.";

$l['expire_hours'] = "hour(s)";
Expand Down
7 changes: 6 additions & 1 deletion inc/tasks/usercleanup.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function task_usercleanup($task)
$warningshandler->expire_warnings();

// Expire any post moderation or suspension limits
$query = $db->simple_select("users", "uid, moderationtime, suspensiontime", "(moderationtime!=0 AND moderationtime<".TIME_NOW.") OR (suspensiontime!=0 AND suspensiontime<".TIME_NOW.")");
$query = $db->simple_select("users", "uid, moderationtime, suspensiontime, pmsuspensiontime", "(moderationtime!=0 AND moderationtime<".TIME_NOW.") OR (suspensiontime!=0 AND suspensiontime<".TIME_NOW.") OR (pmsuspensiontime!=0 AND pmsuspensiontime<".TIME_NOW.")");
while($user = $db->fetch_array($query))
{
$updated_user = array();
Expand All @@ -33,6 +33,11 @@ function task_usercleanup($task)
$updated_user['suspendposting'] = 0;
$updated_user['suspensiontime'] = 0;
}
if($user['pmsuspensiontime'] != 0 && $user['pmsuspensiontime'] < TIME_NOW)
{
$updated_user['suspendpm'] = 0;
$updated_user['pmsuspensiontime'] = 0;
}
$db->update_query("users", $updated_user, "uid='{$user['uid']}'");
}

Expand Down
101 changes: 69 additions & 32 deletions install/resources/mybb_theme.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6779,14 +6779,15 @@ if(use_xmlhttprequest == "1")
</tr>]]></template>
<template name="modcp_banuser_lift" version="1801"><![CDATA[<div class="float_right"><a href="modcp.php?action=liftban&amp;uid={$banned['uid']}&amp;my_post_key={$mybb->post_code}">{$lang->lift_ban}</a></div>]]></template>
<template name="modcp_banuser_liftlist" version="1800"><![CDATA[<option value="{$time}"{$selected}>{$title}{$thattime}</option>]]></template>
<template name="modcp_editprofile" version="1822"><![CDATA[<html>
<template name="modcp_editprofile" version="1827"><![CDATA[<html>
<head>
<title>{$mybb->settings['bbname']} - {$lang->edit_profile}</title>
{$headerinclude}
<script type="text/javascript">
<!--
var mod_posts = '{$modpost_check}';
var susp_posts = '{$suspost_check}';
var susp_pm = '{$suspm_check}';
Xazin marked this conversation as resolved.
Show resolved Hide resolved
// -->
</script>
</head>
Expand Down Expand Up @@ -6926,34 +6927,51 @@ if(use_xmlhttprequest == "1")
<table cellspacing="0" cellpadding="{$theme['tablespace']}" width="100%">
<tr>
<td>
<dl style="margin-top: 0; margin-bottom: 0;">
<dt><label><input type="checkbox" name="moderateposting" value="1" {$modpost_checked} class="checkbox" onclick="toggleSuspend('modposts');" id="modpost" /> {$lang->moderate_posts}</label></dt>
<dd style="margin-top: 4px;" id="modposts_action">
<table cellpadding="4">
{$moderateposts_info}
<tr>
<td width="35%">{$lang->modpost_length}</td>
<td><input type="text" name="modpost_time" value="{$modpost_time}" class="textbox" style="width: 2em;" /> {$modpost_options}</td>
</tr>
</table>
</dd>
</dl>
<dl style="margin-top: 0; margin-bottom: 0;">
<dt><label><input type="checkbox" name="moderateposting" value="1" {$modpost_checked} class="checkbox" onclick="toggleSuspend('modposts');" id="modpost" /> {$lang->moderate_posts}</label></dt>
<dd style="margin-top: 4px;" id="modposts_action">
<table cellpadding="4">
{$moderateposts_info}
<tr>
<td width="35%">{$lang->modpost_length}</td>
<td><input type="text" name="modpost_time" value="{$modpost_time}" class="textbox" style="width: 2em;" /> {$modpost_options}</td>
</tr>
</table>
</dd>
</dl>
</td>
</tr>
<tr>
<td>
<dl style="margin-top: 0; margin-bottom: 0;">
<dt><label><input type="checkbox" name="suspendposting" value="1" {$suspost_checked} class="checkbox" onclick="toggleSuspend('susposts');" id="suspost" /> {$lang->suspend_posts}</label></dt>
<dd style="margin-top: 4px;" id="susposts_action">
<table cellpadding="4">
{$suspendposting_info}
<tr>
<td width="35%">{$lang->suspost_length}</td>
<td><input type="text" name="suspost_time" value="{$suspost_time}" class="textbox" style="width: 2em;" /> {$suspost_options}</td>
</tr>
</table>
</dd>
</dl></td>
<dl style="margin-top: 0; margin-bottom: 0;">
<dt><label><input type="checkbox" name="suspendposting" value="1" {$suspost_checked} class="checkbox" onclick="toggleSuspend('susposts');" id="suspost" /> {$lang->suspend_posts}</label></dt>
<dd style="margin-top: 4px;" id="susposts_action">
<table cellpadding="4">
{$suspendposting_info}
<tr>
<td width="35%">{$lang->suspost_length}</td>
<td><input type="text" name="suspost_time" value="{$suspost_time}" class="textbox" style="width: 2em;" /> {$suspost_options}</td>
</tr>
</table>
</dd>
</dl>
</td>
</tr>
<tr>
<td>
<dl style="margin-top: 0; margin-bottom: 0;">
<dt><label><input type="checkbox" name="suspendprivatemessaging" value="1" {$suspm_checked} class="checkbox" onclick="toggleSuspend('suspm');" id="suspm" /> {$lang->suspend_pm}</label></dt>
<dd style="margin-top: 4px;" id="suspm_action">
<table cellpadding="4">
{$suspendpm_info}
<tr>
<td width="35%">{$lang->suspost_length}</td>
<td><input type="text" name="suspm_time" value="{$suspost_time}" class="textbox" style="width: 2em;" /> {$suspm_options}</td>
</tr>
</table>
</dd>
</dl>
</td>
</tr>
</table>
</fieldset>
Expand All @@ -6965,13 +6983,13 @@ if(use_xmlhttprequest == "1")
<fieldset class="trow1">
<legend><strong>{$lang->signature}</strong></legend>
<table cellspacing="0" cellpadding="{$theme['tablespace']}">
<tr>
<td class="trow1" width="80%">
<textarea rows="15" cols="70" id="signature" name="signature">{$user['signature']}</textarea>
{$codebuttons}
</td>
</tr>
{$suspend_signature}
<tr>
<td class="trow1" width="80%">
<textarea rows="15" cols="70" id="signature" name="signature">{$user['signature']}</textarea>
{$codebuttons}
</td>
</tr>
{$suspend_signature}
</table>
</fieldset>
</td>
Expand Down Expand Up @@ -7008,6 +7026,11 @@ if(use_xmlhttprequest == "1")
$("#susposts_action").hide();
}

if(susp_pm == 0)
{
$("#suspm_action").hide();
}

function toggleSuspend(action)
{
if(action == "modposts")
Expand Down Expand Up @@ -7043,6 +7066,20 @@ if(use_xmlhttprequest == "1")
$("#susposts_action").show();
}
}

if(action == "suspm")
{
if($("#suspm").prop("checked") == false)
{
$("#suspm").attr("checked", false);
$("#suspm_action").hide();
}
else
{
$("#suspm").attr("checked", true);
$("#suspm_action").show();
}
}
}
// -->
</script>
Expand Down
3 changes: 2 additions & 1 deletion install/resources/mysql_db_tables.php
Original file line number Diff line number Diff line change
Expand Up @@ -1127,6 +1127,8 @@
suspensiontime int unsigned NOT NULL default '0',
suspendsignature tinyint(1) NOT NULL default '0',
suspendsigtime int unsigned NOT NULL default '0',
suspendpm tinyint(1) NOT NULL default '0',
pmsuspensiontime int unsigned NOT NULL default '0',
coppauser tinyint(1) NOT NULL default '0',
classicpostbit tinyint(1) NOT NULL default '0',
loginattempts smallint(2) unsigned NOT NULL default '0',
Expand Down Expand Up @@ -1183,4 +1185,3 @@ classicpostbit tinyint(1) NOT NULL default '0',
PRIMARY KEY (wid)
) ENGINE=MyISAM;";


2 changes: 2 additions & 0 deletions install/resources/pgsql_db_tables.php
Original file line number Diff line number Diff line change
Expand Up @@ -1090,6 +1090,8 @@
suspensiontime int NOT NULL default '0',
suspendsignature smallint NOT NULL default '0',
suspendsigtime int NOT NULL default '0',
suspendpm smallint NOT NULL default '0',
pmsuspensiontime int NOT NULL default '0',
coppauser smallint NOT NULL default '0',
classicpostbit smallint NOT NULL default '0',
loginattempts smallint NOT NULL default '0',
Expand Down
2 changes: 2 additions & 0 deletions install/resources/sqlite_db_tables.php
Original file line number Diff line number Diff line change
Expand Up @@ -1011,6 +1011,8 @@
suspensiontime int NOT NULL default '0',
suspendsignature tinyint(1) NOT NULL default '0',
suspendsigtime int NOT NULL default '0',
suspendpm tinyint(1) NOT NULL default '0',
pmsuspensiontime int NOT NULL default '0',
coppauser tinyint(1) NOT NULL default '0',
classicpostbit tinyint(1) NOT NULL default '0',
loginattempts smallint(2) NOT NULL default '0',
Expand Down