[ Index ]

PHP Cross Reference of moodle-2.8

title

Body

[close]

/admin/tool/messageinbound/classes/ -> edit_handler_form.php (source)

   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   * Form to edit handlers.
  19   *
  20   * @package    tool_messageinbound
  21   * @copyright  2014 Andrew Nicols
  22   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  defined('MOODLE_INTERNAL') || die();
  26  
  27  require_once($CFG->libdir . '/formslib.php');
  28  
  29  /**
  30   * Form to edit handlers.
  31   *
  32   * @copyright  2014 Andrew Nicols
  33   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  34   */
  35  class tool_messageinbound_edit_handler_form extends moodleform {
  36      public function definition() {
  37          $mform = $this->_form;
  38  
  39          $handler = $this->_customdata['handler'];
  40  
  41          // Set up the options for formatting text for descriptions, etc.
  42          $formatoptions = new stdClass();
  43          $formatoptions->trusted = false;
  44          $formatoptions->noclean = false;
  45          $formatoptions->smiley = false;
  46          $formatoptions->filter = false;
  47          $formatoptions->para = true;
  48          $formatoptions->newlines = false;
  49          $formatoptions->overflowdiv = true;
  50  
  51          // General information about the handler.
  52          $mform->addElement('header', 'general', get_string('general'));
  53          $mform->addElement('static', 'name', get_string('name', 'tool_messageinbound'),
  54              $handler->name);
  55          $mform->addElement('static', 'classname', get_string('classname', 'tool_messageinbound'));
  56  
  57          $description = format_text($handler->description, FORMAT_MARKDOWN, $formatoptions);
  58  
  59          $mform->addElement('static', 'description', get_string('description', 'tool_messageinbound'),
  60              $description);
  61  
  62          // Items which can be configured.
  63          $mform->addElement('header', 'configuration', get_string('configuration'));
  64  
  65          $options = array(
  66              HOURSECS => get_string('onehour', 'tool_messageinbound'),
  67              DAYSECS => get_string('oneday', 'tool_messageinbound'),
  68              WEEKSECS => get_string('oneweek', 'tool_messageinbound'),
  69              YEARSECS => get_string('oneyear', 'tool_messageinbound'),
  70              0 => get_string('noexpiry', 'tool_messageinbound'),
  71          );
  72          $mform->addElement('select', 'defaultexpiration', get_string('defaultexpiration', 'tool_messageinbound'), $options);
  73          $mform->addHelpButton('defaultexpiration', 'defaultexpiration', 'tool_messageinbound');
  74  
  75          if ($handler->can_change_validateaddress()) {
  76              $mform->addElement('checkbox', 'validateaddress', get_string('requirevalidation', 'tool_messageinbound'));
  77              $mform->addHelpButton('validateaddress', 'validateaddress', 'tool_messageinbound');
  78          } else {
  79              if ($handler->validateaddress) {
  80                  $text = get_string('yes');
  81              } else {
  82                  $text = get_string('no');
  83              }
  84              $mform->addElement('static', 'validateaddress_fake', get_string('requirevalidation', 'tool_messageinbound'), $text);
  85              $mform->addElement('hidden', 'validateaddress');
  86              $mform->addHelpButton('validateaddress_fake', 'fixedvalidateaddress', 'tool_messageinbound');
  87              $mform->setType('validateaddress', PARAM_INT);
  88          }
  89  
  90          if ($handler->can_change_enabled()) {
  91              $mform->addElement('checkbox', 'enabled', get_string('enabled', 'tool_messageinbound'));
  92          } else {
  93              if ($handler->enabled) {
  94                  $text = get_string('yes');
  95              } else {
  96                  $text = get_string('no');
  97              }
  98              $mform->addElement('static', 'enabled_fake', get_string('enabled', 'tool_messageinbound'), $text);
  99              $mform->addHelpButton('enabled', 'fixedenabled', 'tool_messageinbound');
 100              $mform->addElement('hidden', 'enabled');
 101              $mform->setType('enabled', PARAM_INT);
 102          }
 103  
 104          $this->add_action_buttons(true, get_string('savechanges'));
 105      }
 106  }


Generated: Fri Nov 28 20:29:05 2014 Cross-referenced by PHPXref 0.7.1