mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 08:26: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);
|
||||
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))) {
|
||||
redirect($thisurl);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
redirect($thisurl);
|
||||
}
|
||||
|
||||
|
|
|
@ -396,7 +396,6 @@ $string['reportnotavailable'] = 'This type of report is only available for the s
|
|||
$string['reverseproxyabused'] = 'Reverse proxy enabled, server can not be accessed directly, sorry.<br />Please contact server administrator.';
|
||||
$string['rpcerror'] = 'RPC enrol/mnet/available_courses: ($a)';
|
||||
$string['scheduledbackupsdisabled'] = 'Scheduled backups have been disabled by the server admin';
|
||||
$string['searchableselectorcannotbemultiple'] = 'A searchableselector form element cannot be multiple. Remove the \'multiple\' attribute from your call.';
|
||||
$string['sectionnotexist'] = 'This section does not exist';
|
||||
$string['secretalreadyused'] = 'Change password confirmation link was already used, password was not changed';
|
||||
$string['sendmessage'] = 'Send message';
|
||||
|
|
|
@ -36,10 +36,6 @@ class MoodleQuickForm_searchableselector extends MoodleQuickForm_select{
|
|||
|
||||
|
||||
function MoodleQuickForm_searchableselector($elementName=null, $elementLabel=null, $options=null, $attributes=null) {
|
||||
//return exception if the selector is set as multiple (TODO: implement multiple support)
|
||||
if (!empty($attributes) && key_exists('multiple', $attributes)) {
|
||||
throw new moodle_exception('searchableselectorcannotbemultiple');
|
||||
}
|
||||
//set size default to 12
|
||||
if (empty($attributes) || empty($attributes['size'])) {
|
||||
$attributes['size'] = 12;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue