Esempio n. 1
0
 public function handle($stanza, $parent = false)
 {
     $r = new \modl\RosterLink();
     $r->key = $this->_from;
     $r->jid = $this->_to;
     $rd = new \modl\RosterLinkDAO();
     $rd->setNow($r);
     $cd = new \Modl\ContactDAO();
     $c = $cd->getRosterItem($this->_to, true);
     $this->deliver();
 }
Esempio n. 2
0
 public function handle($stanza, $parent = false)
 {
     $r = new \modl\RosterLink();
     $r->session = $this->_from;
     $r->jid = $this->_to;
     $r->rostername = $this->_name;
     $r->groupname = $this->_group;
     $rd = new \modl\RosterLinkDAO();
     $rd->update($r);
     $cd = new \Modl\ContactDAO();
     $c = $cd->getRosterItem($this->_to, true);
     $this->pack($c);
     $this->deliver();
 }
Esempio n. 3
0
 public function handle($stanza, $parent = false)
 {
     // Subscribe request
     if ((string) $stanza->attributes()->type == 'subscribe') {
         $session = \Session::start();
         $notifs = $session->get('activenotifs');
         $notifs[(string) $stanza->attributes()->from] = 'sub';
         $session->set('activenotifs', $notifs);
         $evt = new \Event();
         $evt->runEvent('subscribe', (string) $stanza->attributes()->from);
     } else {
         $p = new \modl\Presence();
         $p->setPresence($stanza);
         $pd = new \modl\PresenceDAO();
         $pd->set($p);
         /*if($p->photo) {
               $r = new Get;
               $r->setTo(echapJid((string)$stanza->attributes()->from))->request();
           }*/
         if ($p->muc && isset($stanza->x) && isset($stanza->x->status)) {
             $code = (string) $stanza->x->status->attributes()->code;
             if (isset($code) && $code == '110') {
                 if ($p->value != 5 && $p->value != 6) {
                     $this->method('muc_handle');
                     $this->pack($p);
                 } elseif ($p->value == 5) {
                     $pd->clearMuc($p->jid);
                     $this->method('unavailable_handle');
                     $this->pack($p);
                     $this->deliver();
                 }
             }
         } else {
             $cd = new \Modl\ContactDAO();
             $c = $cd->getRosterItem($p->jid, true);
             $this->pack($c);
             if ($p->value == 5 || $p->value == 6) {
                 $pd->delete($p);
             }
         }
         $this->deliver();
     }
 }
Esempio n. 4
0
File: Chat.php Progetto: Trim/movim
 /**
  * @brief Prepare the contact header
  *
  * @param string $jid
  */
 function prepareHeader($jid)
 {
     $view = $this->tpl();
     $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_header', true);
 }
Esempio n. 5
0
 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);
     }
 }
Esempio n. 6
0
 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);
     $view->assign('anon', false);
     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);
 }
Esempio n. 7
0
 function prepareChat($jid, $status = null)
 {
     if (!$this->validateJid($jid)) {
         return;
     }
     $view = $this->tpl();
     $cd = new \Modl\ContactDAO();
     $md = new \modl\MessageDAO();
     $cad = new \modl\CapsDAO();
     $presencestxt = getPresencesTxt();
     $cr = $cd->getRosterItem($jid);
     if (isset($cr)) {
         if ($cr->value != null) {
             $view->assign('presence', $presencestxt[$cr->value]);
         }
         $view->assign('contact', $cr);
         $view->assign('caps', $cad->get($cr->node . '#' . $cr->ver));
     } else {
         $view->assign('contact', $cd->get($jid));
         $view->assign('caps', null);
     }
     $view->assign('status', $status);
     $m = $md->getContact($jid, 0, 1);
     if (isset($m)) {
         $view->assign('message', $m[0]);
     }
     return $view->draw('_chats_item', true);
 }