function prepareChat($jid, $muc = false) { $view = $this->tpl(); $view->assign('jid', $jid); $jid = echapJS($jid); $view->assign('composing', $this->call('ajaxSendComposing', "'" . $jid . "'")); $view->assign('paused', $this->call('ajaxSendPaused', "'" . $jid . "'")); $view->assign('smiley', $this->call('ajaxSmiley')); $view->assign('emoji', prepareString('😀')); $view->assign('muc', $muc); return $view->draw('_chat', true); }
function prepareMessage(&$message, $jid = null) { if ($jid != $message->jidto && $jid != $message->jidfrom && $jid != null) { return $this->_wrapper; } $message->jidto = echapJS($message->jidto); $message->jidfrom = echapJS($message->jidfrom); if (isset($message->html)) { $message->body = $message->html; } else { // We add some smileys... $message->convertEmojis(); $message->addUrls(); // $message->body = prepareString(htmlentities($message->body , ENT_COMPAT,'UTF-8')); } if (isset($message->sticker)) { $p = new Picture(); $sticker = $p->get($message->sticker, false, false, 'png'); $stickerSize = $p->getSize(); if ($sticker == false) { $r = new Request(); $r->setTo($message->jidfrom)->setResource($message->resource)->setCid($message->sticker)->request(); } else { $message->sticker = ['url' => $sticker, 'width' => $stickerSize['width'], 'height' => $stickerSize['height']]; } } if (isset($message->picture)) { $message->sticker = ['url' => $message->picture, 'picture' => true]; } $message->publishedPrepared = prepareDate(strtotime($message->published), true); if ($message->delivered) { $message->delivered = prepareDate(strtotime($message->delivered), true); } $date = substr($message->published, 0, 10); if ($message->type == 'groupchat') { $message->color = stringToColor($message->session . $message->resource . $message->jidfrom . $message->type); //fillup $wrapper if ($message->body != "") { if (!array_key_exists($date, $this->_wrapper)) { $this->_wrapper[$date] = [$message]; } else { array_push($this->_wrapper[$date], $message); } } } else { $msgkey = $message->jidfrom . '>' . substr($message->published, 11, 5); //fillup $wrapper if (!array_key_exists($date, $this->_wrapper)) { $sticker = ""; if (isset($message->sticker)) { $sticker = "sticker"; } $this->_wrapper[$date] = ['0' . $sticker . '<' . $msgkey => [$message]]; } else { //date contains at least one speaker@time=>msg already end($this->_wrapper[$date]); $lastkey = key($this->_wrapper[$date]); if (substr($lastkey, strpos($lastkey, '<') + 1) == $msgkey && !isset($message->sticker) && strpos($lastkey, "sticker<") === false) { // the previous msg was not a sticker array_push($this->_wrapper[$date][$lastkey], $message); } else { $sticker = ""; if (isset($message->sticker)) { $sticker = "sticker"; } $this->_wrapper[$date][count($this->_wrapper[$date]) . $sticker . '<' . $msgkey] = [$message]; } } } return $this->_wrapper; }
function prepareContact($jid) { if (!$this->validateJid($jid)) { return; } $cd = new \Modl\ContactDAO(); $c = $cd->get($jid, true); if ($c == null || $c->created == null || $c->isOld()) { if ($c == null) { $c = new \Modl\Contact(); $c->jid = $jid; } $this->ajaxRefreshVcard($jid); } $cr = $cd->getRosterItem($jid); $view = $this->tpl(); $pd = new \Modl\PostnDAO(); $gallery = $pd->getGallery($jid, 0, 12); $blog = $pd->getPublic($jid, 'urn:xmpp:microblog:0', 0, 4); $presencestxt = getPresencesTxt(); $view->assign('edit', $this->call('ajaxEditContact', "'" . echapJS($jid) . "'")); $view->assign('delete', $this->call('ajaxDeleteContact', "'" . echapJS($jid) . "'")); if (isset($c)) { $view->assign('mood', getMood()); $view->assign('contact', $c); $view->assign('contactr', $cr); if ($cr->node != null && $cr->ver != null && $cr->node && $cr->ver) { $node = $cr->node . '#' . $cr->ver; $cad = new \Modl\CapsDAO(); $caps = $cad->get($node); if ($cr->value != null) { $view->assign('presence', $presencestxt[$cr->value]); } if (isset($caps) && $caps->name != '' && $caps->type != '') { $clienttype = getClientTypes(); $view->assign('caps', $caps); $view->assign('clienttype', $clienttype); } } else { $view->assign('caps', null); } $view->assign('gallery', $gallery); $view->assign('blog', $blog); $view->assign('chat', $this->call('ajaxChat', "'" . echapJS($c->jid) . "'")); return $view->draw('_contact', true); } elseif (isset($cr)) { $view->assign('contact', null); $view->assign('contactr', $cr); $view->assign('chat', $this->call('ajaxChat', "'" . echapJS($cr->jid) . "'")); return $view->draw('_contact', true); } else { return $this->prepareEmpty(0, $jid); } }
function prepareChat($jid, $muc = false) { $view = $this->tpl(); $view->assign('jid', $jid); $jid = echapJS($jid); $view->assign('composing', $this->call('ajaxSendComposing', "'" . $jid . "'")); $view->assign('paused', $this->call('ajaxSendPaused', "'" . $jid . "'")); $view->assign('smiley', $this->call('ajaxSmiley')); $view->assign('emoji', prepareString('😀')); $view->assign('muc', $muc); if ($muc) { $md = new \Modl\MessageDAO(); $s = $md->getRoomSubject($jid); $cd = new \Modl\ConferenceDAO(); $c = $cd->get($jid); $pd = new \Modl\PresenceDAO(); $p = $pd->getMyPresenceRoom($jid); $view->assign('room', $jid); $view->assign('subject', $s); $view->assign('presence', $p); $view->assign('conference', $c); } else { $cd = new \Modl\ContactDAO(); $cr = $cd->getRosterItem($jid); if (isset($cr)) { $contact = $cr; } else { $contact = $cd->get($jid); } $view->assign('contact', $contact); $view->assign('jid', $jid); } return $view->draw('_chat', true); }