Browse Source

Optimize manage action handling

SABERES_37_STABLE
Johannes Burk 9 years ago
committed by test
parent
commit
7bc73894ad
  1. 20
      manage.php
  2. 25
      renderer.php

20
manage.php

@ -46,20 +46,12 @@ $PAGE->set_title(get_string('confirmusers', 'enrol_apply'));
$PAGE->requires->css('/enrol/apply/style.css'); $PAGE->requires->css('/enrol/apply/style.css');
if ($userenrolments != null) { if ($userenrolments != null) {
$action = required_param('type', PARAM_TEXT); if (optional_param('confirm', false, PARAM_BOOL)) {
switch ($action) { confirmEnrolment($userenrolments);
case 'confirm': } else if (optional_param('wait', false, PARAM_BOOL)) {
confirmEnrolment($userenrolments); waitEnrolment ($userenrolments);
break; } else if (optional_param('cancel', false, PARAM_BOOL)) {
case 'wait': cancelEnrolment($userenrolments);
waitEnrolment ($userenrolments);
break;
case 'cancel':
cancelEnrolment($userenrolments);
break;
default:
# code...
break;
} }
redirect($manageurl); redirect($manageurl);
} }

25
renderer.php

@ -36,32 +36,17 @@ class enrol_apply_renderer extends plugin_renderer_base {
public function manage_form($table, $manageurl) { public function manage_form($table, $manageurl) {
echo html_writer::start_tag('form', array('id' => 'enrol_apply_manage_form', 'method' => 'post', 'action' => $manageurl->out())); echo html_writer::start_tag('form', array('id' => 'enrol_apply_manage_form', 'method' => 'post', 'action' => $manageurl->out()));
echo html_writer::empty_tag('input', array('type' => 'hidden', 'id' => 'type', 'name' => 'type', 'value' => 'confirm'));
$this->manage_table($table); $this->manage_table($table);
echo html_writer::start_tag('p', array('align' => 'center')); echo html_writer::start_tag('p', array('align' => 'center'));
echo html_writer::empty_tag('input', array(
'type' => 'button', echo html_writer::empty_tag('input', array('type' => 'submit', 'name' => 'confirm', 'value' => get_string('btnconfirm', 'enrol_apply')));
'onclick' => 'doSubmit("confirm");', echo html_writer::empty_tag('input', array('type' => 'submit', 'name' => 'wait', 'value' => get_string('btnwait', 'enrol_apply')));
'value' => get_string('btnconfirm', 'enrol_apply'))); echo html_writer::empty_tag('input', array('type' => 'submit', 'name' => 'cancel', 'value' => get_string('btncancel', 'enrol_apply')));
echo html_writer::empty_tag('input', array(
'type' => 'button',
'onclick' => 'doSubmit("wait");',
'value' => get_string('btnwait', 'enrol_apply')));
echo html_writer::empty_tag('input', array(
'type' => 'button',
'onclick' => 'doSubmit("cancel");',
'value' => get_string('btncancel', 'enrol_apply')));
echo html_writer::end_tag('p'); echo html_writer::end_tag('p');
echo html_writer::end_tag('form'); echo html_writer::end_tag('form');
$js = "
function doSubmit(type){
document.getElementById('type').value=type;
document.getElementById('enrol_apply_manage_form').submit();
}";
echo html_writer::tag('script', $js, array('type' => 'text/javascript'));
} }
public function manage_table($table) { public function manage_table($table) {

Loading…
Cancel
Save