SCORM MDL-22741 add missing restore code - added to HEAD to keep consistency even...
[moodle.git] / message / output / popup / message_output_popup.php
CommitLineData
3b120e46 1<?php
2
eb5334ff 3// This file is part of Moodle - http://moodle.org/
4//
5// Moodle is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation, either version 2 of the License, or
8// (at your option) any later version.
9//
10// Moodle is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
3b120e46 17
18/**
19 * Popup message processor - stores the message to be shown using the message popup
20 *
eb5334ff 21 * @copyright Luis Rodrigues
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v2 or later
23 * @package message
3b120e46 24 */
25
9205ca2e 26require_once(dirname(dirname(dirname(dirname(__FILE__)))) . '/config.php'); //included from messagelib (how to fix?)
3b120e46 27require_once($CFG->dirroot.'/message/output/lib.php');
28
29class message_output_popup extends message_output{
30
1d422980 31 /**
3b120e46 32 * Process the popup message.
1d422980
PS
33 * The popup doesn't send data only saves in the database for later use,
34 * the popup_interface.php takes the message from the message table into
3b120e46 35 * the message_read.
36 * @param object $message the message to be sent
37 * @return true if ok, false if error
38 */
f3d095f8 39 public function send_message($message) {
3b120e46 40 global $DB;
1d422980 41
3b120e46 42 //put the process record into db
43 $processor = $DB->get_record('message_processors', array('name'=>'popup'));
44 $procmessage = new object();
45 $procmessage->unreadmessageid = $message->id;
46 $procmessage->processorid = $processor->id;
47
fc29e51b 48 $DB->insert_record('message_working', $procmessage);
3b120e46 49
50 //should only save this message for later delivery
51 return true;
52 }
1d422980 53
f3d095f8 54 function config_form($preferences) {
305a014f 55 return '<table>'.
56 '<tr><td align="right">'.get_string('showmessagewindow', 'message').':</td><td><input type="checkbox" name="showmessagewindow" '.($preferences->showmessagewindow==1?" checked=\"checked\"":"").' /></td></tr>'.
57 '<tr><td align="right">'.get_string('blocknoncontacts', 'message').':</td><td><input type="checkbox" name="blocknoncontacts" '.($preferences->blocknoncontacts==1?" checked=\"checked\"":"").' /></td></tr>'.
58 '<tr><td align="right">'.get_string('beepnewmessage', 'message').':</td><td><input type="checkbox" name="beepnewmessage" '.($preferences->beepnewmessage==1?" checked=\"checked\"":"").' /></td></tr>'.
59 '<tr><td align="right">'.get_string('noframesjs', 'message').':</td><td><input type="checkbox" name="noframesjs" '.($preferences->noframesjs==1?" checked=\"checked\"":"").' /></td></tr>'.
60 '</table>';
d18b1bbd 61 }
1d422980 62
f3d095f8 63 public function process_form($form, &$preferences) {
64 $preferences['message_showmessagewindow'] = $form->showmessagewindow?1:0;
65 $preferences['message_blocknoncontacts'] = $form->blocknoncontacts?1:0;
66 $preferences['message_beepnewmessage'] = $form->beepnewmessage?1:0;
67 $preferences['message_noframesjs'] = $form->noframesjs?1:0;
3b120e46 68 return true;
69 }
f3d095f8 70 public function load_data(&$preferences, $userid) {
6a0dc62e 71 $preferences->showmessagewindow = get_user_preferences( 'message_showmessagewindow', 1, $userid);
72 $preferences->blocknoncontacts = get_user_preferences( 'message_blocknoncontacts', '', $userid);
73 $preferences->beepnewmessage = get_user_preferences( 'message_beepnewmessage', '', $userid);
74 $preferences->noframesjs = get_user_preferences( 'message_noframesjs', '', $userid);
3b120e46 75 return true;
76 }
eb5334ff 77}