Added the 'delete' methods back nessicary to change $field to optional.

This commit is contained in:
cap2501 2006-08-30 19:22:34 +00:00
parent 2c50dc0b63
commit ff96b9df7e

View file

@ -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,8 +34,9 @@ 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']){
switch ($class) { case 'POST':
switch ($class) {
case 'block': case 'block':
switch ($field) { switch ($field) {
case 'visible': case 'visible':
@ -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;
@ -131,6 +143,29 @@ switch ($class) {
break; break;
} }
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;
} }