admin reports MDL-16706 Eliminated inline scripts to use PAGE methods

This commit is contained in:
samhemelryk
2009-07-02 04:10:56 +00:00
parent 747b85cb00
commit 2a29ba7edb
3 changed files with 84 additions and 93 deletions
+4 -8
View File
@@ -33,13 +33,9 @@ define('REPORT_SECURITY_SERIOUS', 'serious');
define('REPORT_SECURITY_CRITICAL', 'critical');
function report_security_hide_timearning() {
echo '<script type="text/javascript">
//<![CDATA[
var el = document.getElementById("timewarning");
el.setAttribute("class", "timewarninghidden");
//]]>
</script>';
global $PAGE;
$PAGE->requires->yui_lib('dom');
$PAGE->requires->js_function_call('YAHOO.util.Dom.addClass', Array('timewarning', 'timewarninghidden'));
}
function report_security_get_issue_list() {
@@ -222,7 +218,7 @@ function report_security_check_mediafilterswf($detailed=false) {
$result->status = null;
$result->link = "<a href=\"$CFG->wwwroot/$CFG->admin/settings.php?section=filtersettingfiltermediaplugin\">".get_string('filtersettings', 'admin').'</a>';
$activefilters = filters_get_globally_enabled();
$activefilters = filter_get_globally_enabled();
if (array_search('filter/mediaplugin', $activefilters) !== false and !empty($CFG->filter_mediaplugin_enable_swf)) {
$result->status = REPORT_SECURITY_CRITICAL;
+6 -85
View File
@@ -281,91 +281,12 @@ function print_user_entry($user, $keywords, $count) {
}
function print_spamcleaner_javascript() {
$sesskey = sesskey();
?>
<script type="text/javascript">
//<![CDATA[
var row = null;
var delall_cb = {
success: function(o){
try {
var resp = YAHOO.lang.JSON.parse(o.responseText);
} catch(e) {
alert('<?php echo get_string('spaminvalidresult', 'report_spamcleaner');?>');
return;
}
if(resp == true){
window.location.href=window.location.href;
}
}
}
function init() {
YAHOO.util.Event.addListener("removeall_btn", "click", function(){
var yes = confirm('<?php echo get_string('spamdeleteallconfirm', 'report_spamcleaner');?>');
if(yes){
var cObj = YAHOO.util.Connect.asyncRequest('POST', '<?php echo me();?>?delall=yes&sesskey=<?php echo $sesskey;?>', delall_cb);
}
});
}
var del_cb = {
success: function(o) {
try {
var resp = YAHOO.lang.JSON.parse(o.responseText);
} catch(e) {
alert('<?php echo get_string('spaminvalidresult', 'report_spamcleaner');?>');
return;
}
if(row) {
if(resp == true){
while(row.tagName != 'TR') {
row = row.parentNode;
}
row.parentNode.removeChild(row);
row = null;
} else {
alert('<?php echo get_string('spamcannotdelete', 'report_spamcleaner');?>');
}
}
}
}
var ignore_cb = {
success: function(o){
try {
var resp = YAHOO.lang.JSON.parse(o.responseText);
} catch(e) {
alert('<?php echo get_string('spaminvalidresult', 'report_spamcleaner');?>');
return;
}
if(row) {
if(resp == true){
while(row.tagName != 'TR') {
row = row.parentNode;
}
row.parentNode.removeChild(row);
row = null;
}
}
}
}
function del_user(obj, id) {
var yes = confirm('<?php echo get_string('spamdeleteconfirm', 'report_spamcleaner');?>');
if(yes){
row = obj;
var cObj = YAHOO.util.Connect.asyncRequest('POST', '<?php echo me();?>?del=yes&sesskey=<?php echo $sesskey;?>&id='+id, del_cb);
}
}
function ignore_user(obj, id) {
row = obj;
var cObj = YAHOO.util.Connect.asyncRequest('POST', '<?php echo me();?>?ignore=yes&sesskey=<?php echo $sesskey;?>&id='+id, ignore_cb);
}
YAHOO.util.Event.onDOMReady(init);
//]]>
</script>
<?php
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();
}
admin_externalpage_print_footer();
+74
View File
@@ -0,0 +1,74 @@
var row = null;
var delall_cb = {
success: function(o){
try {
var resp = YAHOO.lang.JSON.parse(o.responseText);
} catch(e) {
alert(mstr.report_spamcleaner.spaminvalidresult);
return;
}
if(resp == true){
window.location.href=window.location.href;
}
}
}
function init() {
YAHOO.util.Event.addListener("removeall_btn", "click", function(){
var yes = confirm(mstr.report_spamcleaner.spamdeleteallconfirm);
if(yes){
var cObj = YAHOO.util.Connect.asyncRequest('POST', spamcleaner.me+'?delall=yes&sesskey='+moodle_cfg.sesskey, delall_cb);
}
});
}
var del_cb = {
success: function(o) {
try {
var resp = YAHOO.lang.JSON.parse(o.responseText);
} catch(e) {
alert(mstr.report_spamcleaner.spaminvalidresult);
return;
}
if(row) {
if(resp == true){
while(row.tagName != 'TR') {
row = row.parentNode;
}
row.parentNode.removeChild(row);
row = null;
} else {
alert(mstr.report_spamcleaner.spamcannotdelete);
}
}
}
}
var ignore_cb = {
success: function(o){
try {
var resp = YAHOO.lang.JSON.parse(o.responseText);
} catch(e) {
alert(mstr.report_spamcleaner.spaminvalidresult);
return;
}
if(row) {
if(resp == true){
while(row.tagName != 'TR') {
row = row.parentNode;
}
row.parentNode.removeChild(row);
row = null;
}
}
}
}
function del_user(obj, id) {
var yes = confirm(mstr.report_spamcleaner.spamdeleteconfirm);
if(yes){
row = obj;
var cObj = YAHOO.util.Connect.asyncRequest('POST', spamcleaner.me+'?del=yes&sesskey='+moodle_cfg.sesskey+'&id='+id, del_cb);
}
}
function ignore_user(obj, id) {
row = obj;
var cObj = YAHOO.util.Connect.asyncRequest('POST', spamcleaner.me+'?ignore=yes&sesskey='+moodle_cfg.sesskey+'&id='+id, ignore_cb);
}
YAHOO.util.Event.onDOMReady(init);