Browse Source

Implement #573

pull/676/head
Timothée Jaussoin 8 years ago
parent
commit
9e579fdaa1
  1. 28
      app/Info.php
  2. 17
      app/helpers/StringHelper.php
  3. 1
      app/widgets/Chat/Chat.php
  4. 24
      app/widgets/Chat/_chat.tpl
  5. 32
      app/widgets/CommunityData/_communitydata.tpl
  6. 9
      app/widgets/Share/Share.php
  7. 22
      database/migrations/20180529103706_add_related_to_infos.php

28
app/Info.php

@ -88,6 +88,29 @@ class Info extends Model
: $this->attributes['node'];
}
public function getRelatedAttribute()
{
if ($this->category == 'pubsub' && $this->type == 'leaf') {
return \App\Info::where('related', 'xmpp:'.$this->server.'?;node='.$this->node)
->first();
}
if (isset($this->attributes['related'])
&& $this->category == 'conference' && $this->type == 'text') {
$uri = parse_url($this->attributes['related']);
if (isset($uri['query']) && isset($uri['path'])) {
$params = explodeQueryParams($uri['query']);
if (isset($params['node'])) {
return \App\Info::where('server', $uri['path'])
->where('node', $params['node'])
->first();
}
}
}
}
public function set($query)
{
$from = (string)$query->attributes()->from;
@ -142,6 +165,11 @@ class Info extends Model
case 'pubsub#creation_date':
$this->created = toSQLDate($field->value);
break;
case 'muc#roominfo_pubsub':
if (!empty((string)$field->value)) {
$this->related = $field->value;
}
break;
case 'muc#roominfo_description':
case 'pubsub#description':
if (!empty((string)$field->value)) {

17
app/helpers/StringHelper.php

@ -162,6 +162,23 @@ function getCid($string)
}
}
/*
* Explose query parameters into an array
*/
function explodeQueryParams($query)
{
$params = [];
foreach(explode(';', $query) as $param) {
$result = explode('=', $param);
if (count($result) == 2) {
$params[$result[0]] = $result[1];
}
}
return $params;
}
/*
* Explode JID
*/

1
app/widgets/Chat/Chat.php

@ -573,6 +573,7 @@ class Chat extends \Movim\Widget\Base
$view->assign('room', $jid);
$view->assign('conference', $this->user->session->conferences()
->where('conference', $jid)
->with('info')
->first());
$mucinfo = \App\Info::where('server', explodeJid($jid)['server'])

24
app/widgets/Chat/_chat.tpl

@ -19,11 +19,15 @@
{$curl = $conference->getPhoto('s')}
{if="$curl"}
<span class="primary icon bubble color {$conference->name|stringToColor}"
style="background-image: url({$curl});">
<span class="primary icon bubble color active {$conference->name|stringToColor}
{if="!$conference->connected"}disabled{/if}"
style="background-image: url({$curl});"
onclick="Rooms_ajaxList('{$jid|echapJS}')">
</span>
{else}
<span class="primary icon bubble color {$conference->name|stringToColor}">
<span class="primary icon bubble color active {$conference->name|stringToColor}
{if="!$conference->connected"}disabled{/if}"
onclick="Rooms_ajaxList('{$jid|echapJS}')">
{$conference->name|firstLetterCapitalize}
</span>
{/if}
@ -39,11 +43,15 @@
<i class="zmdi zmdi-close"></i>
</span>
<span
class="control icon active {if="!$conference->connected"}disabled{/if}"
onclick="Rooms_ajaxList('{$jid|echapJS}')">
<i class="zmdi zmdi-accounts"></i>
</span>
{if="$conference->info && $conference->info->related"}
{$related = $conference->info->related}
<span
class="control icon active"
title="{$c->__('page.communities')}{$related->name}"
onclick="MovimUtils.redirect('{$c->route('community', [$related->server, $related->node])}')">
<i class="zmdi zmdi-group-work"></i>
</span>
{/if}
{if="$conference != null && $conference->name"}
<p class="line" title="{$room}">{$conference->name}</p>

32
app/widgets/CommunityData/_communitydata.tpl

@ -35,7 +35,37 @@
</li>
</ul>
<ul class="list block middle active">
<ul class="list middle active">
{if="$info->related"}
{$related = $info->related}
<li onclick="MovimUtils.redirect('{$c->route('chat', [$related->server,'room'])}')">
<span class="primary icon bubble color
{$related->name|stringToColor}">
{$related->name|firstLetterCapitalize}
</span>
<span class="control icon">
<i class="zmdi zmdi-chevron-right"></i>
</span>
<p class="normal line">{$related->name} <span class="second">{$related->server}</span></p>
<p class="line"
{if="$related->description"}title="{$related->description}"{/if}>
{if="$related->occupants > 0"}
<span title="{$c->__('communitydata.sub', $related->occupants)}">
{$related->occupants} <i class="zmdi zmdi-accounts"></i> –
</span>
{/if}
{if="$related->description"}
{$related->description}
{else}
{$related->server}
{/if}
</p>
</li>
{/if}
<a href="{$c->route('node', [$info->server, $info->node])}" target="_blank" class="block">
<li>
<span class="primary icon">

9
app/widgets/Share/Share.php

@ -36,14 +36,7 @@ class Share extends \Movim\Widget\Base
return;
}
$params = [];
foreach(explode(';', $uri['query']) as $param) {
$result = explode('=', $param);
if (count($result) == 2) {
$params[$result[0]] = $result[1];
}
}
$params = explodeQueryParams($uri['query']);
if (isset($params['node']) && isset($params['item'])) {
$this->rpc(

22
database/migrations/20180529103706_add_related_to_infos.php

@ -0,0 +1,22 @@
<?php
use Movim\Migration;
use Illuminate\Database\Schema\Blueprint;
class AddRelatedToInfos extends Migration
{
public function up()
{
$this->schema->table('infos', function(Blueprint $table) {
$table->string('related', 512)->nullable();
});
}
public function down()
{
$this->schema->table('infos', function(Blueprint $table) {
$table->dropColumn('related');
});
}
}
Loading…
Cancel
Save