MDL-25647 mnet: fixed checkbox handling at peer services form
[moodle.git] / admin / mnet / services_form.php
CommitLineData
d36fa815
PL
1<?php
2
3// This file is part of Moodle - http://moodle.org/
4//
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.
9//
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.
14//
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/>.
17
18
19/**
20 * The form for configuring which services are subscribed and published on a host
21 *
d078f6d3
PS
22 * @package core
23 * @subpackage mnet
d36fa815
PL
24 * @copyright 2010 Penny Leach
25 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26 */
27
bfebaf64
MD
28if (!defined('MOODLE_INTERNAL')) {
29 die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
30}
31
d36fa815
PL
32require_once($CFG->libdir . '/formslib.php');
33
34class mnet_services_form extends moodleform {
35
36 function definition() {
37 $mform =& $this->_form;
38 $mnet_peer =& $this->_customdata['peer'];
39 $myservices =& mnet_get_service_info($mnet_peer);
40
41 $mform->addElement('hidden', 'hostid', $mnet_peer->id);
42
43 $count = 0;
44 foreach ($myservices as $name => $versions) {
45 $version = current($versions);
46 $langmodule =
47 ($version['plugintype'] == 'mod'
48 ? ''
49 : ($version['plugintype'] . '_'))
50 . $version['pluginname']; // TODO there should be a moodle-wide way to do this
51
52 if ($count > 0) {
53 $mform->addElement('html', '<hr />');
54 }
55 $mform->addElement('html', '<h3>' . get_string($name.'_name', $langmodule , $mnet_peer->name) . '</h3>' . get_string($name.'_description', $langmodule, $mnet_peer->name));
56
57 $mform->addElement('hidden', 'exists[' . $version['serviceid'] . ']', 1);
58
59 $pubstr = get_string('publish','mnet');
60 if (!empty($version['hostsubscribes'])) {
ec2c36f8 61 $pubstr .= ' <a class="notifysuccess" title="'.s(get_string('issubscribed','mnet', $mnet_peer->name)).'">&radic;</a> ';
d36fa815 62 }
800bd785 63 $mform->addElement('advcheckbox', 'publish[' . $version['serviceid'] . ']', $pubstr);
d36fa815
PL
64
65 $substr = get_string('subscribe','mnet');
66 if (!empty($version['hostpublishes'])) {
ec2c36f8 67 $substr .= ' <a class="notifysuccess" title="'.s(get_string('ispublished','mnet', $mnet_peer->name)).'">&radic;</a> ';
d36fa815 68 }
800bd785 69 $mform->addElement('advcheckbox', 'subscribe[' . $version['serviceid']. ']', $substr);
d36fa815
PL
70 $count++;
71 }
72 $this->add_action_buttons();
73 }
74}