mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
Added the 'delete' methods back nessicary to change $field to optional.
This commit is contained in:
parent
2c50dc0b63
commit
ff96b9df7e
1 changed files with 126 additions and 91 deletions
|
@ -8,8 +8,8 @@ require_once($CFG->dirroot.'/course/lib.php');
|
||||||
|
|
||||||
$courseid = required_param('courseId', PARAM_INT);
|
$courseid = required_param('courseId', PARAM_INT);
|
||||||
$class = required_param('class', PARAM_ALPHA);
|
$class = required_param('class', PARAM_ALPHA);
|
||||||
$field = required_param('field', PARAM_ALPHA);
|
|
||||||
|
|
||||||
|
$field = optional_param('field', '', PARAM_ALPHA);
|
||||||
$instanceid = optional_param('instanceId', 0, PARAM_INT);
|
$instanceid = optional_param('instanceId', 0, PARAM_INT);
|
||||||
$value = optional_param('value', 0, PARAM_INT);
|
$value = optional_param('value', 0, PARAM_INT);
|
||||||
$column = optional_param('column', 0, PARAM_ALPHA);
|
$column = optional_param('column', 0, PARAM_ALPHA);
|
||||||
|
@ -34,7 +34,8 @@ require_capability('moodle/course:update', $context);
|
||||||
// OK, now let's process the parameters and do stuff
|
// OK, now let's process the parameters and do stuff
|
||||||
|
|
||||||
$dataobject = NULL;
|
$dataobject = NULL;
|
||||||
|
switch($_SERVER['REQUEST_METHOD']){
|
||||||
|
case 'POST':
|
||||||
switch ($class) {
|
switch ($class) {
|
||||||
case 'block':
|
case 'block':
|
||||||
switch ($field) {
|
switch ($field) {
|
||||||
|
@ -89,6 +90,17 @@ switch ($class) {
|
||||||
error('Failed to update section');
|
error('Failed to update section');
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'swap':
|
||||||
|
$dataobject->summary = make_dangerous($summary);
|
||||||
|
$dataobject->sequence = $sequence;
|
||||||
|
$dataobject->visible = $visible;
|
||||||
|
if (!update_record('course_sections',$dataobject)) {
|
||||||
|
error('Failed to update section');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -132,6 +144,29 @@ switch ($class) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'DELETE':
|
||||||
|
switch ($class) {
|
||||||
|
case 'block':
|
||||||
|
delete_records('block_instance','id',$instanceid);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'section':
|
||||||
|
$dataobject->id = get_field('course_sections','id','course',$course->id,'section',$id);
|
||||||
|
$dataobject->summary = '';
|
||||||
|
$dataobject->sequence = '';
|
||||||
|
$dataobject->visible = '1';
|
||||||
|
update_record('course_sections',$dataobject);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'resource':
|
||||||
|
delete_records('course_modules','id',$id);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue