]> git.mjollnir.org Git - moodle.git/commitdiff
admin reports MDL-16706 Eliminated inline scripts to use PAGE methods
authorsamhemelryk <samhemelryk>
Thu, 2 Jul 2009 04:10:56 +0000 (04:10 +0000)
committersamhemelryk <samhemelryk>
Thu, 2 Jul 2009 04:10:56 +0000 (04:10 +0000)
admin/report/security/lib.php
admin/report/spamcleaner/index.php
admin/report/spamcleaner/spamcleaner.js [new file with mode: 0644]

index 94480df9bb991dce02ac2821e5359ae1561fd6b3..913dbae5eeb370d7087dcd0716309aaaf6fececb 100644 (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;
index d9eb693d7fc85c1ffbf6aaf398e3759ff75b7a39..5d3ebb0c02d88df466d47483a657cf72100921bc 100755 (executable)
@@ -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();
diff --git a/admin/report/spamcleaner/spamcleaner.js b/admin/report/spamcleaner/spamcleaner.js
new file mode 100644 (file)
index 0000000..179d455
--- /dev/null
@@ -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);
\ No newline at end of file