Removed the pop-up when editing an element to conform to Moodle standards
This commit is contained in:
parent
65adabe9d9
commit
3dd19d8390
2 changed files with 11 additions and 30 deletions
|
@ -28,7 +28,6 @@ require_once($CFG->dirroot . '/mod/customcert/element/element.class.php');
|
||||||
|
|
||||||
$cmid = required_param('cmid', PARAM_INT);
|
$cmid = required_param('cmid', PARAM_INT);
|
||||||
$action = required_param('action', PARAM_ALPHA);
|
$action = required_param('action', PARAM_ALPHA);
|
||||||
$popup = optional_param('popup', '0', PARAM_INT);
|
|
||||||
|
|
||||||
$cm = get_coursemodule_from_id('customcert', $cmid, 0, false, MUST_EXIST);
|
$cm = get_coursemodule_from_id('customcert', $cmid, 0, false, MUST_EXIST);
|
||||||
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
|
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
|
||||||
|
@ -39,7 +38,7 @@ if ($action == 'edit') {
|
||||||
// The id of the element must be supplied if we are currently editing one.
|
// The id of the element must be supplied if we are currently editing one.
|
||||||
$id = required_param('id', PARAM_INT);
|
$id = required_param('id', PARAM_INT);
|
||||||
$element = $DB->get_record('customcert_elements', array('id' => $id), '*', MUST_EXIST);
|
$element = $DB->get_record('customcert_elements', array('id' => $id), '*', MUST_EXIST);
|
||||||
$pageurl = new moodle_url('/mod/customcert/edit_element.php', array('id' => $id, 'cmid' => $cmid, 'action' => $action, 'popup' => $popup));
|
$pageurl = new moodle_url('/mod/customcert/edit_element.php', array('id' => $id, 'cmid' => $cmid, 'action' => $action));
|
||||||
} else { // Must be adding an element.
|
} else { // Must be adding an element.
|
||||||
// Page id must be supplied in order to add an element.
|
// Page id must be supplied in order to add an element.
|
||||||
$pageid = required_param('pageid', PARAM_INT);
|
$pageid = required_param('pageid', PARAM_INT);
|
||||||
|
@ -52,7 +51,6 @@ if ($action == 'edit') {
|
||||||
$params['action'] = 'add';
|
$params['action'] = 'add';
|
||||||
$params['element'] = $element->element;
|
$params['element'] = $element->element;
|
||||||
$params['pageid'] = $pageid;
|
$params['pageid'] = $pageid;
|
||||||
$params['popup'] = $popup;
|
|
||||||
$pageurl = new moodle_url('/mod/customcert/edit_element.php', $params);
|
$pageurl = new moodle_url('/mod/customcert/edit_element.php', $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,12 +58,7 @@ require_login($course, false, $cm);
|
||||||
|
|
||||||
require_capability('mod/customcert:manage', $context);
|
require_capability('mod/customcert:manage', $context);
|
||||||
|
|
||||||
if ($popup) {
|
|
||||||
$PAGE->set_pagelayout('popup');
|
|
||||||
} else {
|
|
||||||
$PAGE->set_heading($course->fullname);
|
$PAGE->set_heading($course->fullname);
|
||||||
}
|
|
||||||
|
|
||||||
$PAGE->set_title(get_string('editcustomcert', 'customcert', format_string($customcert->name)));
|
$PAGE->set_title(get_string('editcustomcert', 'customcert', format_string($customcert->name)));
|
||||||
$PAGE->set_url($pageurl);
|
$PAGE->set_url($pageurl);
|
||||||
|
|
||||||
|
@ -73,13 +66,9 @@ $mform = new mod_customcert_edit_element_form($pageurl, array('element' => $elem
|
||||||
|
|
||||||
// Check if they cancelled.
|
// Check if they cancelled.
|
||||||
if ($mform->is_cancelled()) {
|
if ($mform->is_cancelled()) {
|
||||||
if ($popup) {
|
|
||||||
close_window();
|
|
||||||
} else {
|
|
||||||
$url = new moodle_url('/mod/customcert/edit.php', array('cmid' => $cmid));
|
$url = new moodle_url('/mod/customcert/edit.php', array('cmid' => $cmid));
|
||||||
redirect($url);
|
redirect($url);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if ($data = $mform->get_data()) {
|
if ($data = $mform->get_data()) {
|
||||||
// Set the id, or page id depending on if we are editing an element, or adding a new one.
|
// Set the id, or page id depending on if we are editing an element, or adding a new one.
|
||||||
|
@ -94,13 +83,10 @@ if ($data = $mform->get_data()) {
|
||||||
if ($e = customcert_get_element_instance($data)) {
|
if ($e = customcert_get_element_instance($data)) {
|
||||||
$e->save_form_elements($data);
|
$e->save_form_elements($data);
|
||||||
}
|
}
|
||||||
if ($popup) {
|
|
||||||
close_window();
|
|
||||||
} else {
|
|
||||||
$url = new moodle_url('/mod/customcert/edit.php', array('cmid' => $cmid));
|
$url = new moodle_url('/mod/customcert/edit.php', array('cmid' => $cmid));
|
||||||
redirect($url);
|
redirect($url);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
echo $OUTPUT->header();
|
echo $OUTPUT->header();
|
||||||
echo $OUTPUT->heading(get_string('editcustomcert', 'customcert'));
|
echo $OUTPUT->heading(get_string('editcustomcert', 'customcert'));
|
||||||
|
|
|
@ -231,15 +231,10 @@ class mod_customcert_edit_form extends moodleform {
|
||||||
$deletelink = html_writer::tag('a', get_string('delete', 'customcert'), array('href' => $deletelink->out(false)));
|
$deletelink = html_writer::tag('a', get_string('delete', 'customcert'), array('href' => $deletelink->out(false)));
|
||||||
$row->cells[] = $deletelink;
|
$row->cells[] = $deletelink;
|
||||||
// Link to edit this element.
|
// Link to edit this element.
|
||||||
$params = array();
|
$editlink = new moodle_url('/mod/customcert/edit_element.php', array('id' => $element->id,
|
||||||
$params['id'] = $element->id;
|
'cmid' => $this->_customdata['cmid'],
|
||||||
$params['cmid'] = $this->_customdata['cmid'];
|
'action' => 'edit'));
|
||||||
$params['action'] = 'edit';
|
$editlink = html_writer::tag('a', get_string('edit'), array('href' => $editlink->out(false)));
|
||||||
$nopopupeditlink = new moodle_url('/mod/customcert/edit_element.php', $params);
|
|
||||||
$params['popup'] = 1;
|
|
||||||
$popupeditlink = new moodle_url('/mod/customcert/edit_element.php', $params);
|
|
||||||
$action = new popup_action('click', $popupeditlink, 'edit_element_popup', array('height' => 400, 'width' => 600));
|
|
||||||
$editlink = $OUTPUT->action_link($nopopupeditlink->out(false), get_string('edit'), $action);
|
|
||||||
$row->cells[] = $editlink;
|
$row->cells[] = $editlink;
|
||||||
// Now display any moving arrows if they are needed.
|
// Now display any moving arrows if they are needed.
|
||||||
if ($numelements > 1) {
|
if ($numelements > 1) {
|
||||||
|
|
Loading…
Reference in a new issue