Browse Source

- Fix room login/logout using proper Presences

pull/16/head
Jaussoin Timothée 11 years ago
parent
commit
4936306f46
  1. 7
      app/widgets/Notifs/Notifs.php
  2. 28
      app/widgets/Rooms/Rooms.php
  3. 7
      app/widgets/Rooms/_rooms.tpl
  4. 4
      app/widgets/Rooms/_rooms_list.tpl
  5. 6
      app/widgets/Rooms/rooms.js

7
app/widgets/Notifs/Notifs.php

@ -29,17 +29,10 @@ class Notifs extends WidgetCommon
$this->addcss('notifs.css');
$this->addjs('notifs.js');
/* TODO remove Moxl Notification (inbox) actions
$this->registerEvent('notification', 'onNotification');
$this->registerEvent('notificationdelete', 'onNotificationDelete');
$this->registerEvent('notifications', 'displayNotifications');
$this->registerEvent('nonotification', 'onNoNotification');*/
$this->registerEvent('subscribe', 'onNotifs');
$this->registerEvent('roster_additem_handle', 'onNotifs');
$this->registerEvent('presence_subscribe_handle', 'onNotifs');
$this->registerEvent('presence_subscribed_handle', 'onNotifs');
//$this->registerEvent('presence_unsubscribed_handle', 'onNotifs');
}
function onNotifs($packet = false)

28
app/widgets/Rooms/Rooms.php

@ -93,12 +93,14 @@ class Rooms extends WidgetCommon
/**
* @brief Join a chatroom
*/
function ajaxJoin($jid, $nickname)
function ajaxJoin($jid, $nickname = false)
{
$p = new Muc;
$p->setTo($jid)
->setNickname($nickname)
->request();
$p->setTo($jid);
if($nickname != false) $p->setNickname($nickname);
$p->request();
}
/**
@ -176,6 +178,24 @@ class Rooms extends WidgetCommon
->request();
}
function checkConnected($room, $resource = false)
{
$pd = new \modl\PresenceDAO();
if($resource == false) {
$session = \Sessionx::start();
$resource = $session->user;
}
$presence = $pd->getPresence($room, $resource);
if($presence != null) {
return true;
} else {
return false;
}
}
function prepareRooms()
{
$view = $this->tpl();

7
app/widgets/Rooms/_rooms.tpl

@ -3,10 +3,11 @@
{$c->__('chatrooms.title')}
</li>
{loop="$conferences"}
{$connected = $c->checkConnected($value->conference, $value->nick)}
<li data-jid="{$value->conference}"
data-nick="{$value->nick}"
class="room {if="$value->status == 1"}online{/if}">
{if="$value->status == 1"}
{if="$value->nick != null"} data-nick="{$value->nick}" {/if}
class="room {if="$connected"}online{/if}">
{if="$connected"}
<span class="icon bubble color {$value->name|stringToColor}"><i class="md md-people"></i></span>
{else}
<span class="icon bubble color {$value->name|stringToColor}"><i class="md md-people-outline"></i></span>

4
app/widgets/Rooms/_rooms_list.tpl

@ -1,10 +1,10 @@
<section class="scroll">
<h3>{$c->__('chatrooms.users')}</h3>
<br />
<ul class="active">
<ul>
{$presence = getPresencesTxt()}
{loop="$list"}
<li onclick="Chats_ajaxOpen('{$value->jid}/{$value->resource}'); Dialog.clear();">
<li>
<span class="icon bubble color {$value->resource|stringToColor} status {$presence[$value->value]}">
{$value->resource|firstLetterCapitalize}
</span>

6
app/widgets/Rooms/rooms.js

@ -8,7 +8,11 @@ var Rooms = {
items[i].onclick = function(e) {
console.log(this);
if(!movim_has_class(this, 'online')) {
Rooms_ajaxJoin(this.dataset.jid, this.dataset.nick);
if(this.dataset.nick != null) {
Rooms_ajaxJoin(this.dataset.jid, this.dataset.nick);
} else {
Rooms_ajaxJoin(this.dataset.jid);
}
}
Chat_ajaxGetRoom(this.dataset.jid);

Loading…
Cancel
Save