mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
webservice MDL-21351 add function page: use multiple searchable selector
This commit is contained in:
parent
c59a67ab40
commit
3a17a7a352
4 changed files with 11 additions and 15 deletions
|
@ -116,7 +116,7 @@ class external_service_functions_form extends moodleform {
|
|||
$functions[$functionid] = $function->name.':'.$function->description;
|
||||
}
|
||||
|
||||
$mform->addElement('searchableselector', 'fid', get_string('name'), $functions);
|
||||
$mform->addElement('searchableselector', 'fid', get_string('name'), $functions, array('multiple' => true));
|
||||
|
||||
$mform->addElement('hidden', 'id');
|
||||
$mform->setType('id', PARAM_INT);
|
||||
|
|
|
@ -48,7 +48,7 @@ if ($action === 'delete' and confirm_sesskey() and $service and empty($service->
|
|||
admin_externalpage_print_header();
|
||||
$optionsyes = array('id'=>$id, 'action'=>'delete', 'confirm'=>1, 'sesskey'=>sesskey(), 'fid'=>$function->id);
|
||||
$optionsno = array('id'=>$id);
|
||||
$formcontinue = new single_button(new moodle_url('service_functions.php', $optionsyes), get_string('delete'));
|
||||
$formcontinue = new single_button(new moodle_url('service_functions.php', $optionsyes), get_string('remove'));
|
||||
$formcancel = new single_button(new moodle_url('service_functions.php', $optionsno), get_string('cancel'), 'get');
|
||||
echo $OUTPUT->confirm(get_string('removefunctionconfirm', 'webservice', (object)array('service'=>$service->name, 'function'=>$function->name)), $formcontinue, $formcancel);
|
||||
echo $OUTPUT->footer();
|
||||
|
@ -64,15 +64,16 @@ if ($action === 'delete' and confirm_sesskey() and $service and empty($service->
|
|||
redirect($thisurl);
|
||||
} else if ($data = $mform->get_data()) {
|
||||
ignore_user_abort(true); // no interruption here!
|
||||
$function = $DB->get_record('external_functions', array('id'=>$data->fid), '*', MUST_EXIST);
|
||||
// make sure the function is not there yet
|
||||
if ($DB->record_exists('external_services_functions', array('externalserviceid'=>$service->id, 'functionname'=>$function->name))) {
|
||||
redirect($thisurl);
|
||||
foreach($data->fid as $fid) {
|
||||
$function = $DB->get_record('external_functions', array('id'=>$fid), '*', MUST_EXIST);
|
||||
// make sure the function is not there yet
|
||||
if (!$DB->record_exists('external_services_functions', array('externalserviceid'=>$service->id, 'functionname'=>$function->name))) {
|
||||
$new = new object();
|
||||
$new->externalserviceid = $service->id;
|
||||
$new->functionname = $function->name;
|
||||
$DB->insert_record('external_services_functions', $new);
|
||||
}
|
||||
}
|
||||
$new = new object();
|
||||
$new->externalserviceid = $service->id;
|
||||
$new->functionname = $function->name;
|
||||
$DB->insert_record('external_services_functions', $new);
|
||||
redirect($thisurl);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue