2 // This file is part of Moodle - http://moodle.org/
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.
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.
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/>.
18 * Contains the definition of the form used to send messages
20 * @package core_message
21 * @copyright 2009 Sam Hemelryk
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24 if (!defined('MOODLE_INTERNAL')) {
25 die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
28 require_once($CFG->dirroot
.'/lib/formslib.php');
31 * The form used by users to send instant messages
33 * @package core_message
34 * @copyright 2009 Sam Hemelryk
35 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
37 class send_form
extends moodleform
{
40 * Define the mform elements required
42 function definition () {
44 $mform =& $this->_form
;
46 //$editoroptions = array('maxfiles'=>0, 'maxbytes'=>0, 'trusttext'=>false);
47 $editoroptions = array();
49 //width handled by css so cols is empty. Still present so the page validates.
50 $displayoptions = array('rows'=>'4', 'cols'=>'', 'class'=>'messagesendbox');
52 $mform->addElement('hidden', 'id');
53 $mform->setType('id', PARAM_INT
);
55 //$mform->addElement('html', '<div class="message-send-box">');
56 $mform->addElement('textarea', 'message', get_string('message', 'message'), $displayoptions, $editoroptions);
57 //$mform->addElement('editor', 'message_editor', get_string('message', 'message'), null, $editoroptions);
58 //$mform->addElement('html', '</div>');
60 $this->add_action_buttons(false, get_string('sendmessage', 'message'));
64 * Used to structure incoming data for the message editor component
68 function set_data($data) {
70 //$data->message = array('text'=>$data->message, 'format'=>$data->messageformat);
72 parent
::set_data($data);
76 * Used to reformat the data from the editor component
81 $data = parent
::get_data();
83 /*if ($data !== null) {
84 //$data->messageformat = $data->message_editor['format'];
85 //$data->message = clean_text($data->message_editor['text'], $data->messageformat);
92 * Resets the value of the message
94 * This is used because after we have acted on the submitted content we want to
95 * re-display the form but with an empty message so the user can type the next
98 //function reset_message() {
99 //$this->_form->_elements[$this->_form->_elementIndex['message']]->setValue(array('text'=>''));