Browse Source

- Implement Chatroom posts sharing in SendTo, fix #881

pull/898/head
Timothée Jaussoin 6 years ago
parent
commit
ab694cbb2f
  1. 1
      CHANGELOG.md
  2. 18
      app/widgets/SendTo/SendTo.php
  3. 13
      app/widgets/SendTo/_sendto_contacts.tpl
  4. 44
      app/widgets/SendTo/_sendto_share.tpl
  5. 4
      app/widgets/SendTo/locales.ini

1
CHANGELOG.md

@ -17,6 +17,7 @@ v0.16.1 (trunk)
* Fix Visio call (JS error)
* Implement XEP-0353: Jingle Message Initiation partially
* Refactor the Visio and VisioLink widgets to simplify them
* Allow post sharing in chatrooms (#881)
v0.16 – Cesco
---------------------------

18
app/widgets/SendTo/SendTo.php

@ -34,24 +34,34 @@ class SendTo extends Base
}
$view->assign('uri', $link);
$conferences = $this->user->session->conferences()
->with('info', 'contact')
->has('presence')
->get();
$view->assign('conferences', $conferences);
$view->assign('contacts', $this->user->session
->topContacts()
->with('presence')
->take(15)
->take($conferences->count() > 0 && $conferences->count() <= 10
? 20 - $conferences->count()
: 25 )
->get());
Drawer::fill($view->draw('_sendto_share'));
}
public function ajaxSend(string $to, $file)
public function ajaxSend(string $to, $file, $muc = false)
{
$file->type = 'xmpp';
Notification::toast($this->__('sendto.shared'));
Notification::toast($muc
? $this->__('sendto.shared_chatroom')
: $this->__('sendto.shared_contact')
);
$this->rpc('Drawer.clear');
$c = new Chat;
$c->ajaxHttpSendMessage($to, $this->__('sendto.shared_with'), false, false, false, $file);
$c->ajaxHttpSendMessage($to, $this->__('sendto.shared_with'), $muc, false, false, $file);
}
public function ajaxGetMoreContacts(string $uri)

13
app/widgets/SendTo/_sendto_contacts.tpl

@ -22,16 +22,17 @@
<i class="material-icons">person</i>
</span>
{/if}
<span class="control icon active gray" onclick="SendTo_ajaxSend('{$value->id}', {'uri': '{$uri}'})">
<span class="control icon active gray" onclick="SendTo_ajaxSend('{$value->jid}', {'uri': '{$uri}'})">
<i class="material-icons">send</i>
</span>
<p class="normal line">{$value->truename}</p>
{if="$value->group"}
<p>
<span class="tag color {$value->group|stringToColor}">
{$value->group}
</span>
{$value->jid}
{if="$value->group"}
<span class="tag color {$value->group|stringToColor}">
{$value->group}
</span>
{/if}
</p>
{/if}
</li>
{/loop}

44
app/widgets/SendTo/_sendto_share.tpl

@ -21,6 +21,50 @@
<hr />
{if="$conferences->isNotEmpty()"}
<ul class="list thin">
<li class="subheader"><p>{$c->__('sendto.chatroom')}</p></li>
{loop="$conferences"}
<li>
{$url = $value->getPhoto()}
{if="$url"}
<span class="primary icon bubble color {$value->name|stringToColor}"
style="background-image: url({$url});">
{autoescape="off"}
{$value->name|firstLetterCapitalize|addEmojis}
{/autoescape}
</span>
{else}
<span class="primary icon bubble color {$value->name|stringToColor}">
{autoescape="off"}
{$value->name|firstLetterCapitalize|addEmojis}
{/autoescape}
</span>
{/if}
<span class="control icon active gray" onclick="SendTo_ajaxSend('{$value->conference}', {'uri': '{$uri}'}, true)">
<i class="material-icons">send</i>
</span>
{$info = $value->info}
<p class="normal line">
{$value->name}
<span class="second">{$value->conference}</span>
</p>
<p class="line"
{if="isset($info) && $info->description"}title="{$info->description}"{/if}>
{if="isset($info) && $info->description"}
{$info->description}
{else}
{$value->conference}
{/if}
</p>
</li>
{/loop}
</ul>
{/if}
<ul class="list thin" id="sendto_contacts">
{autoescape="off"}
{$c->prepareContacts($contacts, $uri)}

4
app/widgets/SendTo/locales.ini

@ -1,6 +1,8 @@
[sendto]
attach = Attach to a blog publication
contact = Send it to a contact
chatroom = Share it in a chatroom
shared_with = Post shared
shared = Post shared with your contact
shared_contact = Post shared with your contact
shared_chatroom = Post shared within the chatroom
more_contacts = More contacts
Loading…
Cancel
Save