MDL-29509 move spamcleaner to admin tools
authorPetr Skoda <commits@skodak.org>
Sun, 25 Sep 2011 10:47:57 +0000 (12:47 +0200)
committerPetr Skoda <commits@skodak.org>
Mon, 26 Sep 2011 22:39:20 +0000 (00:39 +0200)
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

admin/report/spamcleaner/settings.php [deleted file]
admin/tool/spamcleaner/index.php [moved from admin/report/spamcleaner/index.php with 88% similarity]
admin/tool/spamcleaner/lang/en/tool_spamcleaner.php [moved from admin/report/spamcleaner/lang/en/report_spamcleaner.php with 87% similarity]
admin/tool/spamcleaner/module.js [moved from admin/report/spamcleaner/module.js with 82% similarity]
admin/tool/spamcleaner/settings.php [new file with mode: 0644]
admin/tool/spamcleaner/version.php [new file with mode: 0644]
lib/pluginlib.php

diff --git a/admin/report/spamcleaner/settings.php b/admin/report/spamcleaner/settings.php
deleted file mode 100644 (file)
index 7efc70a..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-<?php
-
-defined('MOODLE_INTERNAL') || die;
-
-// spam cleaner
-$ADMIN->add('reports', new admin_externalpage('reportspamcleaner', get_string('pluginname', 'report_spamcleaner'), "$CFG->wwwroot/$CFG->admin/report/spamcleaner/index.php", 'moodle/site:config'));
-
similarity index 88%
rename from admin/report/spamcleaner/index.php
rename to admin/tool/spamcleaner/index.php
index b5f1880..c2d1272 100644 (file)
@@ -40,7 +40,7 @@ $reset = optional_param('reset', '', PARAM_RAW);
 $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)) {
@@ -79,14 +79,14 @@ if (!empty($ignore)) {
     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
 
@@ -98,16 +98,16 @@ echo $OUTPUT->box_start();     // The forms section at the top
   <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>
 
@@ -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);
 
@@ -186,7 +186,7 @@ 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);
@@ -194,12 +194,12 @@ function print_user_list($users_rs, $keywords) {
     }
 
     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>';
     }
 }
@@ -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)
@@ -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;
@@ -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
 // 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';
similarity index 82%
rename from admin/report/spamcleaner/module.js
rename to admin/tool/spamcleaner/module.js
index f63ba90..d7cd018 100644 (file)
@@ -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",
@@ -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) {
@@ -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 = {
@@ -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) {
@@ -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);
                             }
                         }
                     }
@@ -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
@@ -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) {
@@ -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;
diff --git a/admin/tool/spamcleaner/settings.php b/admin/tool/spamcleaner/settings.php
new file mode 100644 (file)
index 0000000..52bace7
--- /dev/null
@@ -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'));
+}
+
diff --git a/admin/tool/spamcleaner/version.php b/admin/tool/spamcleaner/version.php
new file mode 100644 (file)
index 0000000..65541bf
--- /dev/null
@@ -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)
+
index ec5b690..ab6c9d5 100644 (file)
@@ -342,8 +342,7 @@ class plugin_manager {
 
             'report' => array(
                 'backups', 'configlog', 'courseoverview',
-                'log', 'questioninstances',
-                'security', 'spamcleaner', 'stats'
+                'log', 'questioninstances', 'security', 'stats'
             ),
 
             'repository' => array(
@@ -368,7 +367,8 @@ class plugin_manager {
             '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(