Browse Source

Start the reimplementation of PubsubSubscriptions in Movim

pull/305/head
Jaussoin Timothée 9 years ago
parent
commit
0360462db8
  1. 35
      app/widgets/Contact/Contact.php
  2. 4
      app/widgets/Contact/_contact.tpl
  3. 38
      app/widgets/Contact/_contact_subscriptions.tpl
  4. 4
      app/widgets/Groups/Groups.php
  5. 2
      composer.json
  6. 12
      composer.lock

35
app/widgets/Contact/Contact.php

@ -4,6 +4,7 @@ use Moxl\Xec\Action\Roster\UpdateItem;
use Moxl\Xec\Action\Vcard4\Get;
use Respect\Validation\Validator;
use Moxl\Xec\Action\Pubsub\GetItems;
use Moxl\Xec\Action\PubsubSubscription\Get as GetSubscriptions;
class Contact extends \Movim\Widget\Base
{
@ -13,6 +14,8 @@ class Contact extends \Movim\Widget\Base
{
$this->registerEvent('vcard_get_handle', 'onVcardReceived', 'contacts');
$this->registerEvent('vcard4_get_handle', 'onVcardReceived', 'contacts');
$this->registerEvent('pubsubsubscription_get_handle', 'onSubscriptions', 'contacts');
$this->addjs('contact.js');
}
@ -20,6 +23,27 @@ class Contact extends \Movim\Widget\Base
{
$contact = $packet->content;
$this->ajaxGetContact($contact->jid);
$this->ajaxRefreshSubscriptions($contact->jid);
}
public function onSubscriptions($packet)
{
$view = $this->tpl();
$items = [];
$id = new \Modl\ItemDAO;
foreach($packet->content as $subscription) {
$item = $id->getItem($subscription['server'], $subscription['node']);
if($item) {
array_push($items, $item);
}
}
$view->assign('subscriptions', $items);
RPC::call('MovimTpl.fill', '#contact_subscriptions', $view->draw('_contact_subscriptions', true));
}
function ajaxClear($page = 0)
@ -36,6 +60,8 @@ class Contact extends \Movim\Widget\Base
$html = $this->prepareContact($jid, $page);
$this->ajaxRefreshSubscriptions($jid);
RPC::call('MovimUtils.pushState', $this->route('contact', $jid));
RPC::call('MovimTpl.fill', '#contact_widget', $html);
@ -118,6 +144,15 @@ class Contact extends \Movim\Widget\Base
->request();
}
function ajaxRefreshSubscriptions($jid)
{
if(!$this->validateJid($jid)) return;
$r = new GetSubscriptions;
$r->setTo($jid)
->request();
}
function ajaxRefreshVcard($jid)
{
if(!$this->validateJid($jid)) return;

4
app/widgets/Contact/_contact.tpl

@ -382,3 +382,7 @@
</li>
</ul>
{/if}
<div id="contact_subscriptions">
</div>

38
app/widgets/Contact/_contact_subscriptions.tpl

@ -0,0 +1,38 @@
{if="count($subscriptions) > 0"}
<ul class="list active flex">
<li class="subheader block large">
<p>
<span class="info">{$subscriptions|count}</span>
{$c->__('group.subscriptions')}
</p>
</li>
{loop="$subscriptions"}
<li class="block"
title="{$value->server} - {$value->node}"
onclick="MovimUtils.redirect('{$c->route('group', [$value->server, $value->node])}')">
{if="$value->logo"}
<span class="primary icon bubble">
<img src="{$value->getLogo()}">
</span>
{else}
<span class="primary icon bubble color {$value->node|stringToColor}">{$value->node|firstLetterCapitalize}</span>
{/if}
<span class="control icon gray">
<i class="zmdi zmdi-chevron-right"></i>
</span>
<p class="line normal">
{if="$value->name"}
{$value->name}
{else}
{$value->node}
{/if}
</p>
{if="$value->description"}
<p class="line">{$value->description|strip_tags}</p>
{/if}
</li>
{/loop}
</ul>
{/if}
<br />

4
app/widgets/Groups/Groups.php

@ -174,7 +174,7 @@ class Groups extends \Movim\Widget\Base
}
function prepareSubscriptions() {
$sd = new \modl\SubscriptionDAO();
$sd = new \Modl\SubscriptionDAO;
$view = $this->tpl();
$view->assign('subscriptions', $sd->getSubscribed());
@ -184,7 +184,7 @@ class Groups extends \Movim\Widget\Base
}
private function prepareServer($server) {
$id = new \modl\ItemDAO();
$id = new \Modl\ItemDAO;
$view = $this->tpl();
$view->assign('nodes', $id->getItems($server));

2
composer.json

@ -17,7 +17,7 @@
"movim/modl": "dev-master",
"movim/sasl2": "dev-master",
"movim/moxl": "dev-master#0d0c1808014dcd08f22263e074c319f7b4134ae2",
"movim/moxl": "dev-master#612c14911dacc78b6380ee467a1cd6b5413a5036",
"embed/embed": "dev-master",
"heyupdate/emoji": "dev-master",

12
composer.lock

@ -4,8 +4,8 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "47c7950a6301a169561eab6d6942fa2b",
"content-hash": "5f6dcb8dafc7e8d4f0d96d497d1382f6",
"hash": "c3b0801f4a7eaeddd93e2bed63d05939",
"content-hash": "3dd71688c4be3c1bb72e8d9f3d13c166",
"packages": [
{
"name": "cboden/ratchet",
@ -903,12 +903,12 @@
"source": {
"type": "git",
"url": "https://github.com/movim/moxl.git",
"reference": "0d0c1808014dcd08f22263e074c319f7b4134ae2"
"reference": "612c14911dacc78b6380ee467a1cd6b5413a5036"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/movim/moxl/zipball/0d0c1808014dcd08f22263e074c319f7b4134ae2",
"reference": "0d0c1808014dcd08f22263e074c319f7b4134ae2",
"url": "https://api.github.com/repos/movim/moxl/zipball/612c14911dacc78b6380ee467a1cd6b5413a5036",
"reference": "612c14911dacc78b6380ee467a1cd6b5413a5036",
"shasum": ""
},
"require": {
@ -943,7 +943,7 @@
"php",
"xmpp"
],
"time": "2016-11-02 21:25:22"
"time": "2016-11-06 22:21:41"
},
{
"name": "movim/sasl2",

Loading…
Cancel
Save