mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 20:42:22 +02:00
MDL-10221 Simulating the HTTP DELETE method by using a URL param (action), because some web servers don't allow DELETE. AJAX Course and Block deletion now works as expected. Merged from MOODLE_19_STABLE
This commit is contained in:
parent
50569ba3ac
commit
49c4d8caa4
@ -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) {
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user