Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/mod/folder/mod_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 
00027 defined('MOODLE_INTERNAL') || die();
00028 
00029 require_once ($CFG->dirroot.'/course/moodleform_mod.php');
00030 
00031 class mod_folder_mod_form extends moodleform_mod {
00032     function definition() {
00033         global $CFG;
00034         $mform = $this->_form;
00035 
00036         $config = get_config('folder');
00037 
00038         //-------------------------------------------------------
00039         $mform->addElement('header', 'general', get_string('general', 'form'));
00040         $mform->addElement('text', 'name', get_string('name'), array('size'=>'48'));
00041         if (!empty($CFG->formatstringstriptags)) {
00042             $mform->setType('name', PARAM_TEXT);
00043         } else {
00044             $mform->setType('name', PARAM_CLEANHTML);
00045         }
00046         $mform->addRule('name', null, 'required', null, 'client');
00047         $this->add_intro_editor($config->requiremodintro);
00048 
00049         //-------------------------------------------------------
00050         $mform->addElement('header', 'content', get_string('contentheader', 'folder'));
00051         $mform->addElement('filemanager', 'files', get_string('files'), null, array('subdirs'=>1, 'accepted_types'=>'*', 'return_types'=>FILE_INTERNAL));
00052 
00053         //-------------------------------------------------------
00054         $this->standard_coursemodule_elements();
00055 
00056         //-------------------------------------------------------
00057         $this->add_action_buttons();
00058 
00059         //-------------------------------------------------------
00060         $mform->addElement('hidden', 'revision');
00061         $mform->setType('revision', PARAM_INT);
00062         $mform->setDefault('revision', 1);
00063     }
00064 
00065     function data_preprocessing(&$default_values) {
00066         if ($this->current->instance) {
00067             // editing existing instance - copy existing files into draft area
00068             $draftitemid = file_get_submitted_draft_itemid('files');
00069             file_prepare_draft_area($draftitemid, $this->context->id, 'mod_folder', 'content', 0, array('subdirs'=>true));
00070             $default_values['files'] = $draftitemid;
00071         }
00072     }
00073 }
 All Data Structures Namespaces Files Functions Variables Enumerations