3 // This file is part of Moodle - http://moodle.org/
5 // Moodle is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
10 // Moodle is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
20 * The form for configuring which services are subscribed and published on a host
24 * @copyright 2010 Penny Leach
25 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
28 if (!defined('MOODLE_INTERNAL')) {
29 die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
32 require_once($CFG->libdir
. '/formslib.php');
34 class mnet_services_form
extends moodleform
{
36 function definition() {
37 $mform =& $this->_form
;
38 $mnet_peer =& $this->_customdata
['peer'];
39 $myservices = mnet_get_service_info($mnet_peer);
41 $mform->addElement('hidden', 'hostid', $mnet_peer->id
);
42 $mform->setType('hostid', PARAM_INT
);
45 foreach ($myservices as $name => $versions) {
46 $version = current($versions);
48 ($version['plugintype'] == 'mod'
50 : ($version['plugintype'] . '_'))
51 . $version['pluginname']; // TODO there should be a moodle-wide way to do this
54 $mform->addElement('html', '<hr />');
56 $mform->addElement('html', '<h3>' . get_string($name.'_name', $langmodule , $mnet_peer->name
) . '</h3>' . get_string($name.'_description', $langmodule, $mnet_peer->name
));
58 $mform->addElement('hidden', 'exists[' . $version['serviceid'] . ']', 1);
59 // Temporary fix until MDL-38885 gets integrated.
60 $mform->setType('exists', PARAM_BOOL
);
62 $pubstr = get_string('publish','mnet');
63 if (!empty($version['hostsubscribes'])) {
64 $pubstr .= ' <a class="notifysuccess" title="'.s(get_string('issubscribed','mnet', $mnet_peer->name
)).'">√</a> ';
66 $mform->addElement('advcheckbox', 'publish[' . $version['serviceid'] . ']', $pubstr);
68 $substr = get_string('subscribe','mnet');
69 if (!empty($version['hostpublishes'])) {
70 $substr .= ' <a class="notifysuccess" title="'.s(get_string('ispublished','mnet', $mnet_peer->name
)).'">√</a> ';
72 $mform->addElement('advcheckbox', 'subscribe[' . $version['serviceid']. ']', $substr);
75 $this->add_action_buttons();