MDL-16267 and MDL-10107 Fixed a typo
[moodle.git] / message / output / popup / message_output_popup.php
CommitLineData
3b120e46 1<?php
2
3///////////////////////////////////////////////////////////////////////////
4// //
5// NOTICE OF COPYRIGHT //
6// //
7// Moodle - Modular Object-Oriented Dynamic Learning Environment //
8// http://moodle.com //
9// //
10// Copyright (C) 1999 onwards Martin Dougiamas http://moodle.com //
11// //
12// This program is free software; you can redistribute it and/or modify //
13// it under the terms of the GNU General Public License as published by //
14// the Free Software Foundation; either version 2 of the License, or //
15// (at your option) any later version. //
16// //
17// This program is distributed in the hope that it will be useful, //
18// but WITHOUT ANY WARRANTY; without even the implied warranty of //
19// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
20// GNU General Public License for more details: //
21// //
22// http://www.gnu.org/copyleft/gpl.html //
23// //
24///////////////////////////////////////////////////////////////////////////
25
26/**
27 * Popup message processor - stores the message to be shown using the message popup
28 *
29 * @author Luis Rodrigues
30 * @version $Id$
31 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
32 * @package
33 */
34
9205ca2e 35require_once(dirname(dirname(dirname(dirname(__FILE__)))) . '/config.php'); //included from messagelib (how to fix?)
3b120e46 36require_once($CFG->dirroot.'/message/output/lib.php');
37
38class message_output_popup extends message_output{
39
40 /**
41 * Process the popup message.
42 * The popup doesn't send data only saves in the database for later use,
43 * the popup_interface.php takes the message from the message table into
44 * the message_read.
45 * @param object $message the message to be sent
46 * @return true if ok, false if error
47 */
f3d095f8 48 public function send_message($message) {
3b120e46 49 global $DB;
50
51 //put the process record into db
52 $processor = $DB->get_record('message_processors', array('name'=>'popup'));
53 $procmessage = new object();
54 $procmessage->unreadmessageid = $message->id;
55 $procmessage->processorid = $processor->id;
56
57 if ( !$DB->insert_record('message_working', $procmessage) ) {
58 return false;
59 }
60
61 //should only save this message for later delivery
62 return true;
63 }
64
f3d095f8 65 function config_form($preferences) {
66 echo '<fieldset id="messageprocessor_popup" class="clearfix">';
67 echo '<legend class="ftoggler">'.get_string('popup', 'messageprocessor_popup').'</legend>';
68 echo '<table>';
69 echo '<tr><td>'.get_string('showmessagewindow', 'message').'</td><td><input type="checkbox" name="showmessagewindow" '.($preferences->showmessagewindow==1?" checked=\"checked\"":"").' /></td></tr>';
70 echo '<tr><td>'.get_string('blocknoncontacts', 'message').'</td><td><input type="checkbox" name="blocknoncontacts" '.($preferences->blocknoncontacts==1?" checked=\"checked\"":"").' /></td></tr>';
71 echo '<tr><td>'.get_string('beepnewmessage', 'message').'</td><td><input type="checkbox" name="beepnewmessage" '.($preferences->beepnewmessage==1?" checked=\"checked\"":"").' /></td></tr>';
72 echo '<tr><td>'.get_string('noframesjs', 'message').'</td><td><input type="checkbox" name="noframesjs" '.($preferences->noframesjs==1?" checked=\"checked\"":"").' /></td></tr>';
73 echo '</table>';
74 echo '</fieldset>';
d18b1bbd 75 }
76
f3d095f8 77 public function process_form($form, &$preferences) {
78 $preferences['message_showmessagewindow'] = $form->showmessagewindow?1:0;
79 $preferences['message_blocknoncontacts'] = $form->blocknoncontacts?1:0;
80 $preferences['message_beepnewmessage'] = $form->beepnewmessage?1:0;
81 $preferences['message_noframesjs'] = $form->noframesjs?1:0;
3b120e46 82 return true;
83 }
f3d095f8 84 public function load_data(&$preferences, $userid) {
6a0dc62e 85 $preferences->showmessagewindow = get_user_preferences( 'message_showmessagewindow', 1, $userid);
86 $preferences->blocknoncontacts = get_user_preferences( 'message_blocknoncontacts', '', $userid);
87 $preferences->beepnewmessage = get_user_preferences( 'message_beepnewmessage', '', $userid);
88 $preferences->noframesjs = get_user_preferences( 'message_noframesjs', '', $userid);
3b120e46 89 return true;
90 }
91}
92?>