diff --git a/app/widgets/Chat/Chat.php b/app/widgets/Chat/Chat.php index f01be284a..3f348b627 100644 --- a/app/widgets/Chat/Chat.php +++ b/app/widgets/Chat/Chat.php @@ -3,6 +3,10 @@ use Moxl\Xec\Action\Message\Composing; use Moxl\Xec\Action\Message\Paused; use Moxl\Xec\Action\Message\Publish; + +use Moxl\Xec\Action\Muc\GetConfig; +use Moxl\Xec\Action\Muc\SetConfig; + use Respect\Validation\Validator; class Chat extends WidgetCommon @@ -18,6 +22,8 @@ class Chat extends WidgetCommon $this->registerEvent('paused', 'onPaused'); $this->registerEvent('gone', 'onGone'); $this->registerEvent('conference_subject', 'onConferenceSubject'); + $this->registerEvent('muc_getconfig_handle', 'onRoomConfig'); + $this->registerEvent('muc_setconfig_handle', 'onRoomConfigSaved'); //$this->registerEvent('presence', 'onPresence'); } @@ -104,6 +110,26 @@ class Chat extends WidgetCommon Header::fill($header); } + function onRoomConfig($packet) + { + list($config, $room) = array_values($packet->content); + + $view = $this->tpl(); + + $xml = new \XMPPtoForm(); + $form = $xml->getHTML($config->x->asXML()); + + $view->assign('form', $form); + $view->assign('room', $room); + + Dialog::fill($view->draw('_chat_config_room', true), true); + } + + function onRoomConfigSaved($packet) + { + Notification::append(false, $this->__('chatroom.config_saved')); + } + private function setState($array, $message) { list($from, $to) = $array; @@ -167,6 +193,8 @@ class Chat extends WidgetCommon */ function ajaxGetRoom($room) { + if(!$this->validateJid($room)) return; + $html = $this->prepareChat($room, true); $header = $this->prepareHeaderRoom($room); @@ -243,6 +271,8 @@ class Chat extends WidgetCommon * @return void */ function ajaxSendComposing($to) { + if(!$this->validateJid($to)) return; + $mc = new Composing; $mc->setTo($to)->request(); } @@ -254,10 +284,41 @@ class Chat extends WidgetCommon * @return void */ function ajaxSendPaused($to) { + if(!$this->validateJid($to)) return; + $mp = new Paused; $mp->setTo($to)->request(); } + /** + * @brief Configure a room + * + * @param string $room + */ + function ajaxGetRoomConfig($room) + { + if(!$this->validateJid($room)) return; + + $gc = new GetConfig; + $gc->setTo($room) + ->request(); + } + + /** + * @brief Save the room configuration + * + * @param string $room + */ + function ajaxSetRoomConfig($data, $room) + { + if(!$this->validateJid($room)) return; + + $sc = new SetConfig; + $sc->setTo($room) + ->setData($data) + ->request(); + } + /** * @brief Prepare the contact header * @@ -325,6 +386,8 @@ class Chat extends WidgetCommon function prepareMessages($jid) { + if(!$this->validateJid($jid)) return; + $md = new \Modl\MessageDAO(); $messages = $md->getContact(echapJid($jid), 0, 30); @@ -381,6 +444,18 @@ class Chat extends WidgetCommon return $view->draw('_chat_empty', true); } + /** + * @brief Validate the jid + * + * @param string $room + */ + private function validateJid($jid) + { + $validate_jid = Validator::email()->noWhitespace()->length(6, 60); + if(!$validate_jid->validate($jid)) return false; + else return true; + } + function display() { $validate_jid = Validator::email()->length(6, 40); diff --git a/app/widgets/Chat/_chat_config_room.tpl b/app/widgets/Chat/_chat_config_room.tpl new file mode 100644 index 000000000..ddd0d8fe4 --- /dev/null +++ b/app/widgets/Chat/_chat_config_room.tpl @@ -0,0 +1,13 @@ +
+
+ {$form} +
+
+
+ + {$c->__('button.close')} + + + {$c->__('button.save')} + +
diff --git a/app/widgets/Chat/_chat_header_room.tpl b/app/widgets/Chat/_chat_header_room.tpl index 935a511be..a4e9d0897 100644 --- a/app/widgets/Chat/_chat_header_room.tpl +++ b/app/widgets/Chat/_chat_header_room.tpl @@ -40,5 +40,8 @@
  • {$c->__('button.delete')}
  • +
  • + {$c->__('chatroom.config')} +
  • diff --git a/app/widgets/Chat/locales.ini b/app/widgets/Chat/locales.ini index bb04c933f..3f20fef5e 100644 --- a/app/widgets/Chat/locales.ini +++ b/app/widgets/Chat/locales.ini @@ -15,3 +15,5 @@ chat.empty_text = 'Discuss with your contacts' chatroom.members = 'Chatroom members' chatroom.connected = 'Connected to the chatroom' chatroom.disconnected = 'Disconnected from the chatroom' +chatroom.config = 'Get config' +chatroom.config_saved = 'Configuration saved' diff --git a/app/widgets/Chats/_chats_item.tpl b/app/widgets/Chats/_chats_item.tpl index 51f3a7cc0..163aceac1 100644 --- a/app/widgets/Chats/_chats_item.tpl +++ b/app/widgets/Chats/_chats_item.tpl @@ -23,7 +23,7 @@ {if="preg_match('#^\?OTR#', $message->body)"}

    {$c->__('message.encrypted')}

    {else} -

    {$message->body|prepareString}

    +

    {$message->body|prepareString|strip_tags}

    {/if} {/if} diff --git a/app/widgets/Contact/_contact_header.tpl b/app/widgets/Contact/_contact_header.tpl index d04ea6d7a..270d5b68f 100644 --- a/app/widgets/Contact/_contact_header.tpl +++ b/app/widgets/Contact/_contact_header.tpl @@ -29,10 +29,10 @@ -

    +
    - {$contact->getTrueName()} -

    +

    {$contact->getTrueName()}

    + {else} -

    +
    - {$jid} -

    +

    {$jid}

    + {/if} {/if} diff --git a/app/widgets/Group/_group_posts.tpl b/app/widgets/Group/_group_posts.tpl index 1e0f3f5c6..0b3255c63 100755 --- a/app/widgets/Group/_group_posts.tpl +++ b/app/widgets/Group/_group_posts.tpl @@ -58,6 +58,18 @@ {/loop} {/if} + {if="isset($value->getAttachements().pictures)"} + {loop="$value->getAttachements().pictures"} +
  • + + + +
  • + {/loop} + {/if} {if="isset($value->getAttachements().pictures)"} {if="$post->isMine()"}