ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilChatMessageNotifyGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2008 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 
32 {
33  private $tpl;
34  private $lng;
35 
36  public function __construct()
37  {
38  global $tpl, $lng;
39 
40  $this->tpl = $tpl;
41  $this->lng = $lng;
42 
43  $this->lng->loadLanguageModule('chat');
44  }
45 
46  public function getHTML()
47  {
48  global $ilUser, $ilObjDataCache, $ilAccess, $ilSetting, $rbacsystem;
49 
50  include_once 'Modules/Chat/classes/class.ilChatServerCommunicator.php';
51 
52  $chatinfo = ilChatServerCommunicator::_lookupUser($ilUser->getId());
53  $last_message_info = false;
54 
55  if ($chatinfo !== false)
56  {
57  $last_msg_info = ilChatServerCommunicator::_getTailMessages($chatinfo->chatId, $chatinfo->roomId, time() - 60 * 60);
58  if ($last_msg_info == false)
59  {
60  return "";
61  }
62  else if ($_SESSION["il_notify_last_msg_checksum"] == $last_msg_info->entryId )
63  {
64  return "";
65  }
66  }
67  else
68  {
69  return "";
70  }
71  $last_msg = $last_msg_info->message;
72 
73  $_SESSION["il_notify_last_msg_checksum"] = $last_msg_info->entryId;
74 
75  $this->tpl->addJavascript('./Modules/Chat/js/ChatMessagesMainMenu.js');
76  $tpl = new ilTemplate('tpl.chat_messages_navigation.html', true, true,'Modules/Chat');
77  if((int)$ilSetting->get('chat_sound_status') && (int)$ilUser->getPref('chat_new_message_sound_status'))
78  {
79  $tpl->setCurrentBlock('beep');
80  $tpl->setVariable('BEEP_SRC', './Modules/Chat/sounds/receive.mp3');
81  $tpl->parseCurrentBlock();
82  }
83 
84  include_once 'Modules/Chat/classes/class.ilChatServerCommunicator.php';
85 
86  $tpl->setVariable("CHAT_RECENT_POSTINGS", $this->lng->txt("chat_recent_postings"));
87  $tpl->setCurrentBlock('msg_item');
88  $tpl->setVariable("TXT_MSG", $last_msg);
89  $tpl->setVariable("TXT_ROOM", $chatinfo->chatTitle);
90  $tpl->parseCurrentBlock();
91 
92  return $tpl->get();
93  }
94 }
95 ?>