Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.
   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   *
  22   * @package    core
  23   * @subpackage mnet
  24   * @copyright  2010 Penny Leach
  25   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  26   */
  27  
  28  if (!defined('MOODLE_INTERNAL')) {
  29      die('Direct access to this script is forbidden.');    ///  It must be included from a Moodle page
  30  }
  31  
  32  require_once($CFG->libdir . '/formslib.php');
  33  
  34  class 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          $mform->setType('hostid', PARAM_INT);
  43  
  44          $count = 0;
  45          foreach ($myservices as $name => $versions) {
  46              $version = current($versions);
  47              $langmodule =
  48                  ($version['plugintype'] == 'mod'
  49                      ? ''
  50                      : ($version['plugintype'] . '_'))
  51                  . $version['pluginname']; // TODO there should be a moodle-wide way to do this
  52  
  53              if ($count > 0) {
  54                  $mform->addElement('html', '<hr />');
  55              }
  56              $mform->addElement('html', '<h3>' .  get_string($name.'_name', $langmodule , $mnet_peer->name) . '</h3>' . get_string($name.'_description', $langmodule, $mnet_peer->name));
  57  
  58              $mform->addElement('hidden', 'exists[' . $version['serviceid'] . ']', 1);
  59              // Temporary fix until MDL-38885 gets integrated.
  60              $mform->setType('exists', PARAM_BOOL);
  61  
  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)).'">&radic;</a> ';
  65              }
  66              $mform->addElement('advcheckbox', 'publish[' . $version['serviceid'] . ']', $pubstr);
  67  
  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)).'">&radic;</a> ';
  71              }
  72              $mform->addElement('advcheckbox', 'subscribe[' . $version['serviceid']. ']', $substr);
  73              $count++;
  74          }
  75          $this->add_action_buttons();
  76      }
  77  }