mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
90 lines
2.9 KiB
PHP
90 lines
2.9 KiB
PHP
<?php
|
|
|
|
// This file is part of Moodle - http://moodle.org/
|
|
//
|
|
// Moodle is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// Moodle is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
/**
|
|
* Web services admin UI forms
|
|
*
|
|
* @package webservice
|
|
* @copyright 2009 Moodle Pty Ltd (http://moodle.com)
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
*/
|
|
|
|
require_once $CFG->libdir.'/formslib.php';
|
|
|
|
class external_service_form extends moodleform {
|
|
function definition() {
|
|
global $CFG, $USER;
|
|
|
|
$mform = $this->_form;
|
|
$service = $this->_customdata;
|
|
|
|
$mform->addElement('header', 'extservice', get_string('externalservice', 'webservice'));
|
|
|
|
$mform->addElement('text', 'name', get_string('name'));
|
|
$mform->addElement('advcheckbox', 'enabled', get_string('enabled', 'webservice'));
|
|
$mform->addElement('text', 'requiredcapability', get_string('requiredcapability', 'webservice'));
|
|
$mform->addElement('advcheckbox', 'restrictedusers', get_string('restrictedusers', 'webservice'));
|
|
|
|
$mform->addElement('hidden', 'id');
|
|
$mform->setType('id', PARAM_INT);
|
|
|
|
$this->add_action_buttons(true);
|
|
|
|
$this->set_data($service);
|
|
}
|
|
|
|
function definition_after_data() {
|
|
$mform = $this->_form;
|
|
$service = $this->_customdata;
|
|
|
|
if (!empty($service->component)) {
|
|
// custom component
|
|
$mform->hardFreeze('name,requiredcapability,restrictedusers');
|
|
}
|
|
}
|
|
}
|
|
|
|
class external_service_functions_form extends moodleform {
|
|
function definition() {
|
|
global $CFG, $USER, $DB;
|
|
|
|
$mform = $this->_form;
|
|
$data = $this->_customdata;
|
|
|
|
$mform->addElement('header', 'addfunction', get_string('addfunction', 'webservice'));
|
|
|
|
$select = "name NOT IN (SELECT s.functionname
|
|
FROM {external_services_functions} s
|
|
WHERE s.externalserviceid = :sid
|
|
)";
|
|
|
|
$functions = $DB->get_records_select_menu('external_functions', $select, array('sid'=>$data['id']), 'name', 'id, name');
|
|
|
|
$mform->addElement('select', 'fid', get_string('name'), $functions);
|
|
|
|
$mform->addElement('hidden', 'id');
|
|
$mform->setType('id', PARAM_INT);
|
|
|
|
$mform->addElement('hidden', 'action');
|
|
$mform->setType('action', PARAM_ACTION);
|
|
|
|
$this->add_action_buttons(true);
|
|
|
|
$this->set_data($data);
|
|
}
|
|
}
|