Beispiel #1
0
 function display()
 {
     $cd = new modl\ContactDAO();
     $this->view->assign('top', $cd->getTop(6));
     $pd = new \Modl\PostnDAO();
     $this->view->assign('news', $pd->getAllPosts(false, 0, 4));
     $this->view->assign('jid', $this->user->getLogin());
     $this->view->assign('presencestxt', getPresencesTxt());
 }
Beispiel #2
0
 function prepareSearch($key)
 {
     $view = $this->tpl();
     $validate_subject = Validator::stringType()->length(1, 15);
     if (!$validate_subject->validate($key)) {
         $view->assign('empty', true);
     } else {
         $view->assign('empty', false);
         $view->assign('presencestxt', getPresencesTxt());
         $pd = new PostnDAO();
         $posts = $pd->search($key);
         $view->assign('posts', $posts);
         $cd = new ContactDAO();
         $contacts = $cd->search($key);
         $view->assign('contacts', $contacts);
         if (!$posts && !$contacts) {
             $view->assign('empty', true);
         }
     }
     return $view->draw('_search_results', true);
 }
Beispiel #3
0
 function prepareEmpty()
 {
     $view = $this->tpl();
     $cd = new \Modl\ContactDAO();
     $view->assign('presencestxt', getPresencesTxt());
     $view->assign('top', $cd->getTop(8));
     return $view->draw('_chat_empty', true);
 }
Beispiel #4
0
 function preparePresenceList()
 {
     $txt = getPresences();
     $txts = getPresencesTxt();
     $session = \Session::start();
     $pd = new \Modl\PresenceDAO();
     $p = $pd->getPresence($session->get('jid'), $session->get('resource'));
     $cd = new \Modl\ContactDAO();
     $contact = $cd->get($session->get('jid'));
     if ($contact == null) {
         $contact = new \Modl\Contact();
     }
     $presencetpl = $this->tpl();
     $presencetpl->assign('contact', $contact);
     $presencetpl->assign('p', $p);
     $presencetpl->assign('txt', $txt);
     $presencetpl->assign('txts', $txts);
     $html = $presencetpl->draw('_presence_list', true);
     return $html;
 }
Beispiel #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);
     }
 }
Beispiel #6
0
 /**
  * @brief Get data for contacts display in roster
  * @param   &$c: the contact as an array and by reference,
  *          $oc: the contact as an object,
  *          $caps: an array of capabilities
  * @returns
  */
 function prepareContact(&$c, $oc, $caps)
 {
     $arr = array();
     $jid = false;
     $presencestxt = getPresencesTxt();
     // We add some basic information
     $c['rosterview'] = array();
     $c['rosterview']['avatar'] = $oc->getPhoto('s');
     $c['rosterview']['color'] = stringToColor($oc->jid);
     $c['rosterview']['name'] = $oc->getTrueName();
     $c['rosterview']['friendpage'] = $this->route('contact', $oc->jid);
     $c['rosterview']['subscription'] = $oc->rostersubscription;
     // Some data relative to the presence
     if ($oc->last != null && $oc->last > 60) {
         $c['rosterview']['inactive'] = 'inactive';
     } else {
         $c['rosterview']['inactive'] = '';
     }
     if ($oc->value && $oc->value != 5) {
         if ($oc->value && $oc->value == 6) {
             $c['rosterview']['presencetxt'] = 'server_error';
         } else {
             $c['rosterview']['presencetxt'] = $presencestxt[$oc->value];
         }
         $c['value'] = intval($c['value']);
     } else {
         $c['rosterview']['presencetxt'] = 'offline';
         $c['value'] = 5;
     }
     $c['rosterview']['type'] = '';
     $c['rosterview']['client'] = '';
     $c['rosterview']['jingle'] = false;
     // About the entity capability
     if ($caps && isset($caps[$oc->node . '#' . $oc->ver])) {
         $cap = $caps[$oc->node . '#' . $oc->ver];
         $c['rosterview']['type'] = $cap->type;
         $client = $cap->name;
         $client = explode(' ', $client);
         $c['rosterview']['client'] = strtolower(preg_replace('/[^a-zA-Z0-9_ \\-()\\/%-&]/s', '', reset($client)));
         // Jingle support
         $features = $cap->features;
         $features = unserialize($features);
         if (array_search('urn:xmpp:jingle:1', $features) !== null && array_search('urn:xmpp:jingle:apps:rtp:audio', $features) !== null && array_search('urn:xmpp:jingle:apps:rtp:video', $features) !== null && (array_search('urn:xmpp:jingle:transports:ice-udp:0', $features) || array_search('urn:xmpp:jingle:transports:ice-udp:1', $features))) {
             $c['rosterview']['jingle'] = true;
         }
     }
     // Tune
     $c['rosterview']['tune'] = false;
     if ($oc->tuneartist != null && $oc->tuneartist != '' || $oc->tunetitle != null && $oc->tunetitle != '') {
         $c['rosterview']['tune'] = true;
     }
 }
Beispiel #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);
 }
Beispiel #8
0
 function prepareEmpty()
 {
     $view = $this->tpl();
     $nd = new \modl\PostnDAO();
     $cd = new modl\ContactDAO();
     $view = $this->tpl();
     $view->assign('presencestxt', getPresencesTxt());
     $view->assign('top', $cd->getTop(6));
     $view->assign('blogs', $nd->getLastBlogPublic(0, 6));
     $view->assign('posts', $nd->getLastPublished(0, 4));
     $view->assign('me', $cd->get($this->user->getLogin()), true);
     $view->assign('jid', $this->user->getLogin());
     return $view->draw('_post_empty', true);
 }
Beispiel #9
0
 function prepareItem($contact)
 {
     $view = $this->tpl();
     $view->assign('contact', $contact);
     $view->assign('presencestxt', getPresencesTxt());
     return $view->draw('_roster_item', true);
 }