]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-10221 Simulating the HTTP DELETE method by using a URL param (action), because...
authornicolasconnault <nicolasconnault>
Fri, 2 Oct 2009 07:53:01 +0000 (07:53 +0000)
committernicolasconnault <nicolasconnault>
Fri, 2 Oct 2009 07:53:01 +0000 (07:53 +0000)
course/rest.php
lib/ajax/block_classes.js
lib/ajax/section_classes.js

index a0d766bb123e5768edc5d8a0b0c7353bd277ceba..d8e5e161d068d6eeda50837fb20b8075af60bfd8 100644 (file)
@@ -39,6 +39,7 @@ $id         = optional_param('id', 0, PARAM_INT);
 $summary    = optional_param('summary', '', PARAM_RAW);
 $sequence   = optional_param('sequence', '', PARAM_SEQUENCE);
 $visible    = optional_param('visible', 0, PARAM_INT);
+$pageaction = optional_param('action', '', PARAM_ALPHA); // Used to simulate a DELETE command
 
 $PAGE->set_url(new moodle_url($CFG->wwwroot.'/course/rest.php', array('courseId'=>$courseId,'class'=>$class)));
 
@@ -53,7 +54,13 @@ require_login($course);
 require_capability('moodle/course:update', $context);
 
 // OK, now let's process the parameters and do stuff
-switch($_SERVER['REQUEST_METHOD']) {
+// MDL-10221 the DELETE method is not allowed on some web servers, so we simulate it with the action URL param
+$requestmethod = $_SERVER['REQUEST_METHOD'];
+if ($pageaction == 'DELETE') {
+    $requestmethod = 'DELETE';
+}
+
+switch($requestmethod) {
     case 'POST':
 
         switch ($class) {
index 2823f3ed148122164222c15791db0747784c8559..defcde7ef5e63b0ad52710a578ac1d96ee710045 100644 (file)
@@ -258,7 +258,7 @@ block_class.prototype.delete_button = function() {
     this.removeFromGroup('blocks');
 
     // Remove from remote model.
-    main.connect('DELETE', 'class=block&instanceId='+this.instanceId);
+    main.connect('POST', 'class=block&action=DELETE&instanceId='+this.instanceId);
         
     // Remove from view
     main.blocks.splice(main.get_block_index(this), 1);
index 3a99f67bf49e22586830cae4326bbfa7eeff7d9b..058d440cdec4777027adbb9689b845b99cd94fd8 100755 (executable)
@@ -818,7 +818,7 @@ resource_class.prototype.delete_button = function() {
         return false;
     }
     this.parentObj.remove_resource(this);
-    main.connect('DELETE', 'class=resource&id='+this.id);
+    main.connect('POST', 'class=resource&action=DELETE&id='+this.id);
 }