Skip to content

Commit

Permalink
MDL-29509 move spamcleaner to admin tools
Browse files Browse the repository at this point in the history
Why? Because this tool does not support contexts, allows data modifications and is intended only for admins. It is still linked from admin reports for now, we will move it elsewhere once we know where to add general new reports.

AMOS BEGIN
 MOV [pluginname,report_spamcleaner],[pluginname,tool_spamcleaner]
 MOV [spamauto,report_spamcleaner],[spamauto,tool_spamcleaner]
 MOV [spamcannotdelete,report_spamcleaner],[spamcannotdelete,tool_spamcleaner]
 MOV [spamcannotfinduser,report_spamcleaner],[spamcannotfinduser,tool_spamcleaner]
 MOV [spamcleanerintro,report_spamcleaner],[spamcleanerintro,tool_spamcleaner]
 MOV [spamdeleteall,report_spamcleaner],[spamdeleteall,tool_spamcleaner]
 MOV [spamdeleteallconfirm,report_spamcleaner],[spamdeleteallconfirm,tool_spamcleaner]
 MOV [spamdeleteconfirm,report_spamcleaner],[spamdeleteconfirm,tool_spamcleaner]
 MOV [spamdesc,report_spamcleaner],[spamdesc,tool_spamcleaner]
 MOV [spameg,report_spamcleaner],[spameg,tool_spamcleaner]
 MOV [spamfromblog,report_spamcleaner],[spamfromblog,tool_spamcleaner]
 MOV [spaminvalidresult,report_spamcleaner],[spaminvalidresult,tool_spamcleaner]
 MOV [spamoperation,report_spamcleaner],[spamoperation,tool_spamcleaner]
 MOV [spamresult,report_spamcleaner],[spamresult,tool_spamcleaner]
 MOV [spamsearch,report_spamcleaner],[spamsearch,tool_spamcleaner]
AMOS END
  • Loading branch information
skodak committed Sep 26, 2011
1 parent cff8fc8 commit 17a14fb
Show file tree
Hide file tree
Showing 7 changed files with 97 additions and 40 deletions.
7 changes: 0 additions & 7 deletions admin/report/spamcleaner/settings.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
$id = optional_param('id', '', PARAM_INT);

require_login();
admin_externalpage_setup('reportspamcleaner');
admin_externalpage_setup('toolspamcleaner');

// Delete one user
if (!empty($del) && confirm_sesskey() && ($id != $USER->id)) {
Expand Down Expand Up @@ -79,14 +79,14 @@
exit;
}

$PAGE->requires->js_init_call('M.report_spamcleaner.init', array(me()), true);
$PAGE->requires->js_init_call('M.tool_spamcleaner.init', array(me()), true);
$strings = Array('spaminvalidresult','spamdeleteallconfirm','spamcannotdelete','spamdeleteconfirm');
$PAGE->requires->strings_for_js($strings, 'report_spamcleaner');
$PAGE->requires->strings_for_js($strings, 'tool_spamcleaner');

echo $OUTPUT->header();

// Print headers and things
echo $OUTPUT->box(get_string('spamcleanerintro', 'report_spamcleaner'));
echo $OUTPUT->box(get_string('spamcleanerintro', 'tool_spamcleaner'));

echo $OUTPUT->box_start(); // The forms section at the top

Expand All @@ -98,16 +98,16 @@
<div>
<input type="text" name="keyword" id="keyword_el" value="<?php p($keyword) ?>" />
<input type="hidden" name="sesskey" value="<?php echo sesskey();?>" />
<input type="submit" value="<?php echo get_string('spamsearch', 'report_spamcleaner')?>" />
<input type="submit" value="<?php echo get_string('spamsearch', 'tool_spamcleaner')?>" />
</div>
</form>
<p><?php echo get_string('spameg', 'report_spamcleaner');?></p>
<p><?php echo get_string('spameg', 'tool_spamcleaner');?></p>

<hr />

<form method="post" action="index.php">
<div>
<input type="submit" name="autodetect" value="<?php echo get_string('spamauto', 'report_spamcleaner');?>" />
<input type="submit" name="autodetect" value="<?php echo get_string('spamauto', 'tool_spamcleaner');?>" />
</div>
</form>

Expand Down Expand Up @@ -168,7 +168,7 @@ function search_spammers($keywords) {
$spamusers_blog = $DB->get_recordset_sql($sql2, $params);

$keywordlist = implode(', ', $keywords);
echo $OUTPUT->box(get_string('spamresult', 'report_spamcleaner').s($keywordlist)).' ...';
echo $OUTPUT->box(get_string('spamresult', 'tool_spamcleaner').s($keywordlist)).' ...';

print_user_list(array($spamusers_desc, $spamusers_blog), $keywords);

Expand All @@ -186,20 +186,20 @@ function print_user_list($users_rs, $keywords) {
foreach ($users_rs as $rs){
foreach ($rs as $user) {
if (!$count) {
echo '<table border="1" width="100%" id="data-grid"><tr><th>&nbsp;</th><th>'.get_string('user','admin').'</th><th>'.get_string('spamdesc', 'report_spamcleaner').'</th><th>'.get_string('spamoperation', 'report_spamcleaner').'</th></tr>';
echo '<table border="1" width="100%" id="data-grid"><tr><th>&nbsp;</th><th>'.get_string('user','admin').'</th><th>'.get_string('spamdesc', 'tool_spamcleaner').'</th><th>'.get_string('spamoperation', 'tool_spamcleaner').'</th></tr>';
}
$count++;
filter_user($user, $keywords, $count);
}
}

if (!$count) {
echo get_string('spamcannotfinduser', 'report_spamcleaner');
echo get_string('spamcannotfinduser', 'tool_spamcleaner');

} else {
echo '</table>';
echo '<div class="mld-align">
<button id="removeall_btn">'.get_string('spamdeleteall', 'report_spamcleaner').'</button>
<button id="removeall_btn">'.get_string('spamdeleteall', 'tool_spamcleaner').'</button>
</div>';
}
}
Expand All @@ -210,7 +210,7 @@ function filter_user($user, $keywords, $count) {
$image_search = true;
}
if (isset($user->summary)) {
$user->description = '<h3>'.get_string('spamfromblog', 'report_spamcleaner').'</h3>'.$user->summary;
$user->description = '<h3>'.get_string('spamfromblog', 'tool_spamcleaner').'</h3>'.$user->summary;
unset($user->summary);
}
if (preg_match('#<img.*src=[\"\']('.$CFG->wwwroot.')#', $user->description, $matches)
Expand Down Expand Up @@ -271,8 +271,8 @@ function print_user_entry($user, $keywords, $count) {

$html .= '<td align="left">'.format_text($user->description, $user->descriptionformat, array('overflowdiv'=>true)).'</td>';
$html .= '<td width="100px" align="center">';
$html .= '<button onclick="M.report_spamcleaner.del_user(this,'.$user->id.')">'.get_string('deleteuser', 'admin').'</button><br />';
$html .= '<button onclick="M.report_spamcleaner.ignore_user(this,'.$user->id.')">'.get_string('ignore', 'admin').'</button>';
$html .= '<button onclick="M.tool_spamcleaner.del_user(this,'.$user->id.')">'.get_string('deleteuser', 'admin').'</button><br />';
$html .= '<button onclick="M.tool_spamcleaner.ignore_user(this,'.$user->id.')">'.get_string('ignore', 'admin').'</button>';
$html .= '</td>';
$html .= '</tr>';
return $html;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
Expand All @@ -16,11 +15,12 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Strings for component 'report_spamcleaner', language 'en', branch 'MOODLE_20_STABLE'
* Strings for component 'tool_spamcleaner', language 'en', branch 'MOODLE_22_STABLE'
*
* @package report_spamcleaner
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @package tool
* @subpackage spamcleaner
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

$string['pluginname'] = 'Spam cleaner';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
M.report_spamcleaner = {
M.tool_spamcleaner = {
Y: null,
row: null,
me: null,

del_all: function() {
var context = M.report_spamcleaner;
var context = M.tool_spamcleaner;

var yes = confirm(M.str.report_spamcleaner.spamdeleteallconfirm);
var yes = confirm(M.str.tool_spamcleaner.spamdeleteallconfirm);
if (yes) {
var cfg = {
method: "POST",
Expand All @@ -15,7 +15,7 @@ M.report_spamcleaner = {
try {
var resp = context.Y.JSON.parse(o.responseText);
} catch(e) {
alert(M.str.report_spamcleaner.spaminvalidresult);
alert(M.str.tool_spamcleaner.spaminvalidresult);
return;
}
if (resp == true) {
Expand All @@ -29,14 +29,14 @@ M.report_spamcleaner = {
},

del_user: function(obj, id) {
var context = M.report_spamcleaner;
var context = M.tool_spamcleaner;

if (context.Y == null) {
// not initialised yet
return;
}

var yes = confirm(M.str.report_spamcleaner.spamdeleteconfirm);
var yes = confirm(M.str.tool_spamcleaner.spamdeleteconfirm);
if (yes) {
context.row = obj;
var cfg = {
Expand All @@ -46,7 +46,7 @@ M.report_spamcleaner = {
try {
var resp = context.Y.JSON.parse(o.responseText);
} catch(e) {
alert(M.str.report_spamcleaner.spaminvalidresult);
alert(M.str.tool_spamcleaner.spaminvalidresult);
return;
}
if (context.row) {
Expand All @@ -57,7 +57,7 @@ M.report_spamcleaner = {
context.row.parentNode.removeChild(context.row);
context.row = null;
} else {
alert(M.str.report_spamcleaner.spamcannotdelete);
alert(M.str.tool_spamcleaner.spamcannotdelete);
}
}
}
Expand All @@ -68,7 +68,7 @@ M.report_spamcleaner = {
},

ignore_user: function(obj, id) {
var context = M.report_spamcleaner;
var context = M.tool_spamcleaner;

if (context.Y == null) {
// not initilised yet
Expand All @@ -83,7 +83,7 @@ M.report_spamcleaner = {
try {
var resp = context.Y.JSON.parse(o.responseText);
} catch(e) {
alert(M.str.report_spamcleaner.spaminvalidresult);
alert(M.str.tool_spamcleaner.spaminvalidresult);
return;
}
if (context.row) {
Expand All @@ -102,7 +102,7 @@ M.report_spamcleaner = {
},

init: function(Y, me) {
var context = M.report_spamcleaner;
var context = M.tool_spamcleaner;

Y.use('json', 'io-base', function (Y) {
context.Y = Y;
Expand Down
33 changes: 33 additions & 0 deletions admin/tool/spamcleaner/settings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Link to spamcleaner.
*
* For now keep in Reports folder, we should move it elsewhere once we deal with contexts in general reports and navigation
*
* @package tool
* @subpackage unsuproles
* @copyright 2011 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

defined('MOODLE_INTERNAL') || die;

if ($hassiteconfig) {
$ADMIN->add('reports', new admin_externalpage('toolspamcleaner', get_string('pluginname', 'tool_spamcleaner'), "$CFG->wwwroot/$CFG->admin/tool/spamcleaner/index.php", 'moodle/site:config'));
}

31 changes: 31 additions & 0 deletions admin/tool/spamcleaner/version.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Plugin version info
*
* @package tool
* @subpackage spamcleaner
* @copyright 2011 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

defined('MOODLE_INTERNAL') || die;

$plugin->version = 2011092500;
$plugin->requires = 2011092100;
$plugin->component = 'tool_spamcleaner'; // Full name of the plugin (used for diagnostics)

6 changes: 3 additions & 3 deletions lib/pluginlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,7 @@ public static function standard_plugins_list($type) {

'report' => array(
'backups', 'configlog', 'courseoverview',
'log', 'questioninstances',
'security', 'spamcleaner', 'stats'
'log', 'questioninstances', 'security', 'stats'
),

'repository' => array(
Expand All @@ -368,7 +367,8 @@ public static function standard_plugins_list($type) {
'tool' => array(
'bloglevelupgrade', 'capability', 'customlang', 'dbtransfer', 'generator',
'health', 'innodb', 'langimport', 'multilangupgrade', 'profiling',
'qeupgradehelper', 'unittest', 'uploaduser', 'unsuproles', 'xmldb'
'qeupgradehelper', 'spamcleaner', 'unittest', 'uploaduser', 'unsuproles',
'xmldb'
),

'webservice' => array(
Expand Down

0 comments on commit 17a14fb

Please sign in to comment.