notes MDL-19818 Upgrade deprecated calls and added set_url calls
[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
fc29e51b 57 $DB->insert_record('message_working', $procmessage);
3b120e46 58
59 //should only save this message for later delivery
60 return true;
61 }
62
f3d095f8 63 function config_form($preferences) {
305a014f 64 return '<table>'.
65 '<tr><td align="right">'.get_string('showmessagewindow', 'message').':</td><td><input type="checkbox" name="showmessagewindow" '.($preferences->showmessagewindow==1?" checked=\"checked\"":"").' /></td></tr>'.
66 '<tr><td align="right">'.get_string('blocknoncontacts', 'message').':</td><td><input type="checkbox" name="blocknoncontacts" '.($preferences->blocknoncontacts==1?" checked=\"checked\"":"").' /></td></tr>'.
67 '<tr><td align="right">'.get_string('beepnewmessage', 'message').':</td><td><input type="checkbox" name="beepnewmessage" '.($preferences->beepnewmessage==1?" checked=\"checked\"":"").' /></td></tr>'.
68 '<tr><td align="right">'.get_string('noframesjs', 'message').':</td><td><input type="checkbox" name="noframesjs" '.($preferences->noframesjs==1?" checked=\"checked\"":"").' /></td></tr>'.
69 '</table>';
d18b1bbd 70 }
71
f3d095f8 72 public function process_form($form, &$preferences) {
73 $preferences['message_showmessagewindow'] = $form->showmessagewindow?1:0;
74 $preferences['message_blocknoncontacts'] = $form->blocknoncontacts?1:0;
75 $preferences['message_beepnewmessage'] = $form->beepnewmessage?1:0;
76 $preferences['message_noframesjs'] = $form->noframesjs?1:0;
3b120e46 77 return true;
78 }
f3d095f8 79 public function load_data(&$preferences, $userid) {
6a0dc62e 80 $preferences->showmessagewindow = get_user_preferences( 'message_showmessagewindow', 1, $userid);
81 $preferences->blocknoncontacts = get_user_preferences( 'message_blocknoncontacts', '', $userid);
82 $preferences->beepnewmessage = get_user_preferences( 'message_beepnewmessage', '', $userid);
83 $preferences->noframesjs = get_user_preferences( 'message_noframesjs', '', $userid);
3b120e46 84 return true;
85 }
86}
87?>