Commit f2fa3d2a authored by Aaron Wells's avatar Aaron Wells Committed by Robert Lyon

Let admins manually edit a user's probation points

Bug 1252101

Change-Id: I47557efbbf9c303cf921ef7c7f31140471f86a5e
parent 224d6f2e
......@@ -18,6 +18,7 @@ define('SECTION_PLUGINTYPE', 'core');
define('SECTION_PLUGINNAME', 'admin');
require_once('pieforms/pieform.php');
require_once('activity.php');
require_once(get_config('docroot') . 'lib/antispam.php');
$id = param_integer('id');
$user = new User;
......@@ -121,6 +122,22 @@ else {
);
}
// Probation points
if (is_using_probation($user->id)) {
$options = array();
$options[0] = get_string('probationzeropoints', 'admin');
for ($i = 1; $i <= PROBATION_MAX_POINTS; $i++ ) {
$options[$i] = get_string('probationxpoints', 'admin', $i);
}
$elements['probationpoints'] = array(
'type' => 'select',
'title' => get_string('probationtitle', 'admin'),
'help' => true,
'options' => $options,
'defaultvalue' => min(max((int) $user->probation, 0), PROBATION_MAX_POINTS),
);
}
$authinstances = auth_get_auth_instances();
if (count($authinstances) > 1) {
$options = array();
......@@ -329,6 +346,11 @@ function edituser_site_submit(Pieform $form, $values) {
return false;
}
if (is_using_probation()) {
// Value should be between 0 and 10 inclusive
$user->probation = min(max((int) $values['probationpoints'], 0), PROBATION_MAX_POINTS);
}
if ($USER->get('admin') || get_config_plugin('artefact', 'file', 'institutionaloverride')) {
$user->quota = $values['quota'];
}
......
......@@ -745,6 +745,12 @@ $string['confirmdeleteuser'] = 'Are you sure you want to delete this user?';
$string['filequota1'] = 'File quota';
$string['quotaused'] = 'Quota used';
$string['filequotadescription'] = 'Total storage available in the user\'s files area.';
$string['probationtitle'] = 'Spammer probation status';
$string['probationzeropoints'] = 'Not on probation';
$string['probationxpoints'] = array(
0 => '%d point',
1 => '%d points',
);
$string['addusertoinstitution'] = 'Add user to institution';
$string['removeuserfrominstitution'] = 'Remove user from this institution';
$string['confirmremoveuserfrominstitution'] = 'Are you sure you want to remove the user from this institution?';
......
<!-- @license http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later -->
<!-- @copyright For copyright information on Mahara, please see the README file distributed with this software. -->
<h3>Spammer probation status</h3>
<p>This setting controls whether the user is considered to be on probation as a possible spammer. Newly self-registered users start out with a certain number of "probation points" on their account. While they have any probation points, they are considered a probationary user and cannot create public pages in their portfolio, or post links or images to potentially public content such as comments, wall posts, or forum posts.</p>
<p>Each time a probationary user makes a post in a forum, and the post is replied to by a non-probationary user, the probationary user loses one probation point. When the number of points reaches zero, they are no longer on probation.</p>
<p>Probation points have no effect on users who have been designated staff or admins.</p>
......@@ -11,6 +11,8 @@
defined('INTERNAL') || die();
define('PROBATION_MAX_POINTS', 10);
function available_spam_traps() {
$results = array();
$handle = opendir(get_config('docroot') . 'lib/antispam');
......@@ -159,4 +161,4 @@ function has_external_links_or_images($text) {
// Check to see whether the post contains any content forbidden to new users
// (We do this first, in order to avoid any unnecessary hits to the DB
return (boolean) preg_match('#(://)|(<a\b)#i', $text);
}
\ No newline at end of file
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment