Skip to content

Commit

Permalink
MDL-21400 spamcleaner converted to YUI3
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Jan 23, 2010
1 parent 3b01539 commit 9edea33
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 96 deletions.
36 changes: 14 additions & 22 deletions admin/report/spamcleaner/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,16 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
*/

// Configuration

// List of known spammy keywords, please add more here

/////////////////////////////////////////////////////////////////////////////////

require_once('../../../config.php');
require_once($CFG->libdir.'/adminlib.php');


// Configuration

$autokeywords = array(
"<img",
"fuck",
Expand All @@ -25,12 +31,6 @@
"warcraft"
);


/////////////////////////////////////////////////////////////////////////////////

require_once('../../../config.php');
require_once($CFG->libdir.'/adminlib.php');

$keyword = optional_param('keyword', '', PARAM_RAW);
$autodetect = optional_param('autodetect', '', PARAM_RAW);
$del = optional_param('del', '', PARAM_RAW);
Expand Down Expand Up @@ -83,13 +83,13 @@
exit;
}

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

admin_externalpage_print_header();

// Print headers and things

print_spamcleaner_javascript();

echo $OUTPUT->box(get_string('spamcleanerintro', 'report_spamcleaner'));

echo $OUTPUT->box_start(); // The forms section at the top
Expand Down Expand Up @@ -244,6 +244,7 @@ function print_user_entry($user, $keywords, $count) {
$smalluserobject->auth = $user->auth;
$smalluserobject->firstname = $user->firstname;
$smalluserobject->lastname = $user->lastname;
$smalluserobject->username = $user->username;

if (empty($SESSION->users_result[$user->id])) {
$SESSION->users_result[$user->id] = $smalluserobject;
Expand Down Expand Up @@ -271,8 +272,8 @@ function print_user_entry($user, $keywords, $count) {

$html .= '<td align="left">'.format_text($user->description, $user->descriptionformat).'</td>';
$html .= '<td width="100px" align="center">';
$html .= '<button onclick="del_user(this,'.$user->id.')">'.get_string('deleteuser', 'admin').'</button><br />';
$html .= '<button onclick="ignore_user(this,'.$user->id.')">'.get_string('ignore', 'admin').'</button>';
$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 .= '</td>';
$html .= '</tr>';
return $html;
Expand All @@ -283,13 +284,4 @@ function print_user_entry($user, $keywords, $count) {

}

function print_spamcleaner_javascript() {
global $PAGE;
$PAGE->requires->js('/admin/report/spamcleaner/spamcleaner.js');
$strings = Array('spaminvalidresult','spamdeleteallconfirm','spamcannotdelete','spamdeleteconfirm');
$PAGE->requires->strings_for_js($strings, 'report_spamcleaner');
$PAGE->requires->data_for_js('spamcleaner', Array('me'=>me()));
//$sesskey = sesskey();
}

echo $OUTPUT->footer();
93 changes: 93 additions & 0 deletions admin/report/spamcleaner/module.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
M.report_spamcleaner = {
Y: null,
row: null,
me: null,

del_all: function() {
var yes = confirm(mstr.report_spamcleaner.spamdeleteallconfirm);
if (yes) {
var cfg = {
method: "POST",
on: {
success : function(id, o, args) {
try {
var resp = M.report_spamcleaner.Y.JSON.parse(o.responseText);
} catch(e) {
alert(mstr.report_spamcleaner.spaminvalidresult);
return;
}
if (resp == true) {
window.location.href=window.location.href;
}
}
}
}
M.report_spamcleaner.Y.io(M.report_spamcleaner.me+'?delall=yes&sesskey='+M.cfg.sesskey, cfg);
}
},

del_user: function(obj, id) {
var yes = confirm(mstr.report_spamcleaner.spamdeleteconfirm);
if (yes) {
M.report_spamcleaner.row = obj;
var cfg = {
method: "POST",
on: {
success : function(id, o, args) {
try {
var resp = M.report_spamcleaner.Y.JSON.parse(o.responseText);
} catch(e) {
alert(mstr.report_spamcleaner.spaminvalidresult);
return;
}
if (M.report_spamcleaner.row) {
if (resp == true) {
while(M.report_spamcleaner.row.tagName != 'TR') {
M.report_spamcleaner.row = M.report_spamcleaner.row.parentNode;
}
M.report_spamcleaner.row.parentNode.removeChild(M.report_spamcleaner.row);
M.report_spamcleaner.row = null;
} else {
alert(mstr.report_spamcleaner.spamcannotdelete);
}
}
}
}
}
M.report_spamcleaner.Y.io(M.report_spamcleaner.me+'?del=yes&sesskey='+M.cfg.sesskey+'&id='+id, cfg);
}
},

ignore_user: function(obj, id) {
M.report_spamcleaner.row = obj;
var cfg = {
method: "POST",
on: {
success : function(id, o, args) {
try {
var resp = M.report_spamcleaner.Y.JSON.parse(o.responseText);
} catch(e) {
alert(mstr.report_spamcleaner.spaminvalidresult);
return;
}
if (M.report_spamcleaner.row) {
if (resp == true){
while(M.report_spamcleaner.row.tagName != 'TR') {
M.report_spamcleaner.row = M.report_spamcleaner.row.parentNode;
}
M.report_spamcleaner.row.parentNode.removeChild(M.report_spamcleaner.row);
M.report_spamcleaner.row = null;
}
}
}
}
}
M.report_spamcleaner.Y.io(M.report_spamcleaner.me+'?ignore=yes&sesskey='+M.cfg.sesskey+'&id='+id, cfg);
},

init: function(Y, me) {
M.report_spamcleaner.Y = Y.use('json', 'io');
M.report_spamcleaner.me = me;
Y.on("click", M.report_spamcleaner.del_all, "#removeall_btn");
}
}
74 changes: 0 additions & 74 deletions admin/report/spamcleaner/spamcleaner.js

This file was deleted.

0 comments on commit 9edea33

Please sign in to comment.