Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Differences Between: [Versions 400 and 402] [Versions 400 and 403]

   1  <?php
   2  // This file is part of Moodle - http://moodle.org/
   3  //
   4  // Moodle is free software: you can redistribute it and/or modify
   5  // it under the terms of the GNU General Public License as published by
   6  // the Free Software Foundation, either version 3 of the License, or
   7  // (at your option) any later version.
   8  //
   9  // Moodle is distributed in the hope that it will be useful,
  10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12  // GNU General Public License for more details.
  13  //
  14  // You should have received a copy of the GNU General Public License
  15  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  16  
  17  /**
  18   * Capability tool settings form.
  19   *
  20   * Do no include this file, it is automatically loaded by the class loader!
  21   *
  22   * @package    tool_capability
  23   * @copyright  2013 Sam Hemelryk
  24   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  25   */
  26  
  27  require_once($CFG->libdir.'/formslib.php');
  28  
  29  /**
  30   * Class tool_capability_settings_form
  31   *
  32   * The settings form for the comparison of roles/capabilities.
  33   *
  34   * @copyright  2013 Sam Hemelryk
  35   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  36   */
  37  class tool_capability_settings_form extends moodleform {
  38  
  39      /**
  40       * The form definition.
  41       */
  42      public function definition() {
  43          $form = $this->_form;
  44          $capabilities = $this->_customdata['capabilities'];
  45          $roles = $this->_customdata['roles'];
  46          // Set the form ID.
  47          $form->setAttributes(array('id' => 'capability-overview-form') + $form->getAttributes());
  48  
  49          $form->addElement('header', 'reportsettings', get_string('reportsettings', 'tool_capability'));
  50          $form->addElement('html', html_writer::tag('p', get_string('intro', 'tool_capability'), array('id' => 'intro')));
  51  
  52          $form->addElement('hidden', 'search');
  53          $form->setType('search', PARAM_TEXT);
  54  
  55          $attributes = array('multiple' => 'multiple', 'size' => 10, 'data-search' => 'capability');
  56          $form->addElement('select', 'capability', get_string('capabilitylabel', 'tool_capability'), $capabilities, $attributes);
  57          $form->setType('capability', PARAM_CAPABILITY);
  58  
  59          $attributes = array('multiple' => 'multiple', 'size' => 10);
  60          $form->addElement('select', 'roles', get_string('roleslabel', 'tool_capability'), $roles, $attributes);
  61          $form->setType('roles', PARAM_TEXT);
  62  
  63          $filters = [];
  64          $filters[] = $form->createElement('checkbox', 'onlydiff',  get_string('onlydiff', 'tool_capability'));
  65          $form->setType('onlydiff', PARAM_BOOL);
  66          $form->addGroup($filters, 'filters', get_string('filters', 'tool_capability'), array('<br>'), false);
  67  
  68          $form->addElement('submit', 'submitbutton', get_string('getreport', 'tool_capability'));
  69      }
  70  
  71  }