Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/filter/local_settings_form.php
Go to the documentation of this file.
00001 <?php
00002 
00003 // This file is part of Moodle - http://moodle.org/
00004 //
00005 // Moodle is free software: you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation, either version 3 of the License, or
00008 // (at your option) any later version.
00009 //
00010 // Moodle is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
00017 
00025 defined('MOODLE_INTERNAL') || die();
00026 
00027 require_once($CFG->libdir . '/formslib.php');
00028 
00029 abstract class filter_local_settings_form extends moodleform {
00030     protected $filter;
00031     protected $context;
00032 
00033     public function __construct($submiturl, $filter, $context) {
00034         $this->filter = $filter;
00035         $this->context = $context;
00036         parent::moodleform($submiturl);
00037     }
00038 
00046     public function definition() {
00047         $mform = $this->_form;
00048 
00049         $this->definition_inner($mform);
00050 
00051         $mform->addElement('hidden', 'contextid');
00052         $mform->setType('contextid', PARAM_INT);
00053         $mform->setDefault('contextid', $this->context->id);
00054 
00055         $mform->addElement('hidden', 'filter');
00056         $mform->setType('filter', PARAM_SAFEPATH);
00057         $mform->setDefault('filter', $this->filter);
00058 
00059         $this->add_action_buttons();
00060     }
00061 
00066     abstract protected function definition_inner($mform);
00067 
00073     public function save_changes($data) {
00074         $data = (array) $data;
00075         unset($data['filter']);
00076         unset($data['contextid']);
00077         foreach ($data as $name => $value) {
00078             if ($value !== '') {
00079                 filter_set_local_config($this->filter, $this->context->id, $name, $value);
00080             } else {
00081                 filter_unset_local_config($this->filter, $this->context->id, $name);
00082             }
00083         }
00084     }
00085 }
 All Data Structures Namespaces Files Functions Variables Enumerations