function prepareProfileData() { $submit = $this->call('ajaxLocationPublish', "getMyPositionData()"); $cd = new \Modl\ContactDAO(); $c = $cd->get($this->user->getLogin()); if ($c->loctimestamp) { $data = prepareDate(strtotime($c->loctimestamp)) . '<br /><br />'; $data .= $c->getPlace(); } else { $data = ''; } $html = ''; $html .= ' <div id="location"> <div id="mapdata" style="margin: 1em 0;">' . $data . '</div> <div id="mapdiv" style="width: auto; height: 250px; display: none;"></div> <div class="clear"></div> <a class="button color green" style="margin-top: 1em;" onclick="getMyPosition(); this.style.display = \'none\';"> <i class="fa fa-compass"></i> ' . $this->__('location.update') . ' </a> <a id="mypossubmit" style="display: none; margin-top: 1em; float: right;" class="button color green merged left" onclick="' . $submit . ' hidePositionChoice();"> <i class="fa fa-check"></i> ' . $this->__('button.accept') . '</a> </div>'; return $html; }
function onPost($packet) { $pd = new \Modl\PostnDAO(); $since = Cache::c('since'); $count = $pd->getCountSince($since); $post = $packet->content; if ($count > 0 && strtotime($post->published) > strtotime($since)) { if ($post->isMicroblog()) { $cd = new \Modl\ContactDAO(); $contact = $cd->get($post->origin); if ($post->title == null) { $title = __('post.default_title'); } else { $title = $post->title; } if (!$post->isMine()) { Notification::append('news', $contact->getTrueName(), $title, $contact->getPhoto('s'), 2, $this->route('news', $post->nodeid)); } } else { $logo = $post->logo ? $post->getLogo() : null; Notification::append('news', $post->title, $post->node, $logo, 2, $this->route('news', $post->nodeid)); } $this->onStream($count); } }
/** * @brief Display the room list */ function ajaxList($room) { if (!$this->validateRoom($room)) { return; } $view = $this->tpl(); $cd = new \Modl\ContactDAO(); $view->assign('list', $cd->getPresences($room)); Dialog::fill($view->draw('_rooms_list', true), true); }
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(); }
public function handle($stanza, $parent = false) { $jid = current(explode('/', (string) $parent->attributes()->from)); $cd = new \Modl\ContactDAO(); $c = $cd->get($jid); if ($c == null) { $c = new \Modl\Contact(); } $p = new Picture(); $p->fromBase((string) $stanza->items->item->data); $p->set($jid); $this->event('vcard', $c); }
public function handle($stanza, $parent = false) { $to = current(explode('/', (string) $parent->attributes()->to)); $from = current(explode('/', (string) $parent->attributes()->from)); if (isset($stanza->items->item->geoloc) && $stanza->items->item->geoloc->count() > 0) { $cd = new \Modl\ContactDAO(); $c = $cd->get($from); if ($c != null) { $c->setLocation($stanza); $cd->set($c); } } }
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(); }
public function handle($stanza, $parent = false) { $jid = current(explode('/', (string) $parent->attributes()->from)); $cd = new \Modl\ContactDAO(); $c = $cd->get($jid); if ($c == null) { $c = new \Modl\Contact(); } $c->jid = $jid; $vcard = $stanza->items->item->vcard; $c->setVcard4($vcard); $c->createThumbnails(); $cd->set($c); $this->event('vcard', $c); }
public function handle($stanza, $parent = false) { $to = current(explode('/', (string) $parent->attributes()->to)); $from = current(explode('/', (string) $parent->attributes()->from)); if ($stanza->items->item->nick) { $cd = new \Modl\ContactDAO(); $c = $cd->get($from); if ($c == null) { $c = new \Modl\Contact(); $c->jid = $from; } $c->nickname = (string) $stanza->items->item->nick; $cd->set($c); } }
public function handle($stanza, $parent = false) { $jid = current(explode('/', (string) $parent->attributes()->from)); $cd = new \Modl\ContactDAO(); $c = $cd->get($jid); if (isset($stanza->items->item->metadata->info)) { $info = $stanza->items->item->metadata->info->attributes(); if ($info->id != $c->avatarhash) { $c->avatarhash = $info->id; $cd->set($c); $g = new Get(); $g->setTo($jid)->request(); } } }
function onSessionInitiate($jingle) { $jts = new \JingletoSDP($jingle); $sdp = $jts->generate(); $cd = new \Modl\ContactDAO(); $contact = $cd->get(cleanJid((string) $jingle->attributes()->initiator)); if (!isset($contact)) { $contact = new Modl\Contact(); } if ($sdp) { RPC::call('movim_desktop_notification', $contact->getTrueName(), $this->__('visio.calling'), $contact->getPhoto('m')); RPC::call('remoteSetJid', (string) $jingle->attributes()->initiator); RPC::call('remoteCall', 'onOffer', $sdp); RPC::commit(); } }
function prepareNotifs() { $cd = new \Modl\ContactDAO(); $contacts = $cd->getRosterFrom(); $invitations = array(); $notifs = \Cache::c('activenotifs'); if (is_array($notifs)) { foreach ($notifs as $key => $value) { array_push($invitations, $cd->get($key)); } } $nft = $this->tpl(); $nft->assign('invitations', $invitations); $nft->assign('contacts', $contacts); return $nft->draw('_notifs_from', true); }
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(); } }
public function handle($stanza, $parent = false) { $cd = new \Modl\ContactDAO(); $c = $cd->get($this->_to); if ($c == null) { $c = new \Modl\Contact(); } $c->jid = $this->_to; if ($vcard = $stanza->pubsub->items->item) { $vcard = $stanza->pubsub->items->item->vcard; $c->setVcard4($vcard); $c->createThumbnails(); $cd->set($c); $this->pack($c); $this->deliver(); } else { $this->error(false); } }
public function handle($stanza, $parent = false) { $from = current(explode('/', (string) $parent->attributes()->from)); if (isset($stanza->items->item->mood) && $stanza->items->item->mood->count() > 0) { $arrmood = array(); foreach ($stanza->items->item->mood->children() as $mood) { if ($mood->getName() != 'text') { array_push($arrmood, $mood->getName()); } } if (count($arrmood) > 0) { $cd = new \Modl\ContactDAO(); $c = $cd->get($from); if ($c != null) { $c->mood = serialize($arrmood); $cd->set($c); } } } }
public function handle($stanza, $parent = false) { if ($stanza->attributes()->from) { $jid = current(explode('/', (string) $stanza->attributes()->from)); } else { $jid = $this->_to; } if ($jid) { $evt = new Event(); $cd = new \Modl\ContactDAO(); $c = $cd->get($this->_to); if ($c == null) { $c = new \Modl\Contact(); } $c->set($stanza, $this->_to); $cd->set($c); $c->createThumbnails(); $this->pack($c); $this->deliver(); } }
function onPost($packet) { $pd = new \Modl\PostnDAO(); $count = $pd->getCountSince(Cache::c('since')); if ($count > 0) { $post = $packet->content; if ($post->isMicroblog()) { $cd = new \Modl\ContactDAO(); $contact = $cd->get($post->origin); if ($post->title == null) { $title = __('post.default_title'); } else { $title = $post->title; } if (!$post->isMine()) { Notification::append('news', $contact->getTrueName(), $title, $contact->getPhoto('s'), 2); } } else { Notification::append('news', $post->title, $post->node, null, 2); } $this->onStream($count); } }
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); }
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; }
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); } }
public function handle($stanza, $parent = false) { $cd = new \Modl\ContactDAO(); $this->pack($cd->get()); $this->deliver(); }
function preparePost($p) { $view = $this->tpl(); if (isset($p)) { if (isset($p->commentplace)) { $this->ajaxGetComments($p->commentplace, $p->nodeid); } $view->assign('recycled', false); // Is it a recycled post ? if ($p->getContact()->jid && $p->node == 'urn:xmpp:microblog:0' && $p->origin != $p->getContact()->jid) { $cd = new \Modl\ContactDAO(); $view->assign('recycled', $cd->get($p->origin)); } $view->assign('post', $p); $view->assign('attachements', $p->getAttachements()); return $view->draw('_post', true); } else { return $this->prepareEmpty(); } }
function prepareItems() { $cd = new \Modl\ContactDAO(); $this->user->reload(true); $view = $this->tpl(); $view->assign('contacts', $cd->getRoster()); $view->assign('offlineshown', $this->user->getConfig('roster')); $view->assign('presencestxt', getPresencesTxt()); return $view->draw('_roster_list', true); }
function ajaxVcardSubmit($vcard) { # Format it ISO 8601: if ($vcard->year->value != -1 && $vcard->month->value != -1 && $vcard->day->value != -1) { $vcard->date->value = $vcard->year->value . '-' . $vcard->month->value . '-' . $vcard->day->value; } unset($vcard->year->value); unset($vcard->month->value); unset($vcard->day->value); $cd = new \Modl\ContactDAO(); $c = $cd->get($this->user->getLogin()); if ($c == null) { $c = new \Modl\Contact(); } $c->jid = $this->user->getLogin(); if (isset($vcard->date->value)) { $c->date = $vcard->date->value; } if (Validator::string()->length(0, 40)->validate($vcard->name->value)) { $c->name = $vcard->name->value; } if (Validator::string()->length(0, 40)->validate($vcard->fn->value)) { $c->fn = $vcard->fn->value; } if (Validator::url()->validate($vcard->url->value)) { $c->url = $vcard->url->value; } if (Validator::in(array_keys(getGender()))->validate($vcard->gender->value)) { $c->gender = $vcard->gender->value; } if (Validator::in(array_keys(getMarital()))->validate($vcard->marital->value)) { $c->marital = $vcard->marital->value; } $c->adrlocality = $vcard->locality->value; $c->adrcountry = $vcard->country->value; if (Validator::email()->validate($vcard->email->value)) { $c->email = $vcard->email->value; } $c->twitter = $vcard->twitter->value; $c->skype = $vcard->skype->value; $c->yahoo = $vcard->yahoo->value; if (Validator::string()->validate($vcard->desc->value)) { $c->description = trim($vcard->desc->value); } $cd = new \Modl\ContactDAO(); $cd->set($c); $r = new Set(); $r->setData($c)->request(); $r = new Moxl\Xec\Action\Vcard\Set(); $r->setData($vcard)->request(); }
/** * @brief Get data from database to pass it on to angular in JSON * @param * @returns $result: a json for the contacts and one for the groups */ function prepareRoster() { //Contacts $contactdao = new \Modl\ContactDAO(); $contacts = $contactdao->getRoster(); $capsarr = $this->getCaps(); $result = array(); $farray = array(); //final array if (isset($contacts)) { /* Init */ $c = array_shift($contacts); if ($c->groupname == '') { $c->groupname = $this->__('roster.ungrouped'); } $jid = $c->jid; $groupname = $c->groupname; $ac = $c->toRoster(); $this->prepareContact($ac, $c, $capsarr); $garray = array(); //group array $garray['agroup'] = $groupname; $garray['tombstone'] = false; $garray['agroupitems'] = array(); //group array of jids $jarray = array(); //jid array $jarray['ajid'] = $jid; $jarray['atruename'] = $ac['rosterview']['name']; $jarray['aval'] = $ac['value']; $jarray['tombstone'] = false; $jarray['ajiditems'] = $ac; //jid array of resources array_push($garray['agroupitems'], $jarray); foreach ($contacts as &$c) { /*jid has changed*/ if ($jid != $c->jid) { if ($c->groupname == '') { $c->groupname = $this->__('roster.ungrouped'); } $ac = $c->toRoster(); $this->prepareContact($ac, $c, $capsarr); if ($groupname != $c->groupname && $c->groupname != "") { //close group array_push($farray, $garray); //next group $groupname = $ac['groupname']; $garray = array(); $garray['agroup'] = $groupname; $garray['tombstone'] = false; $garray['agroupitems'] = array(); } //push new jid in group $jid = $ac['jid']; $jarray['ajid'] = $jid; $jarray['atruename'] = $ac['rosterview']['name']; $jarray['aval'] = $ac['value']; $jarray['tombstone'] = false; $jarray['ajiditems'] = $ac; //jid array of resources array_push($garray['agroupitems'], $jarray); } if ($c == $contacts[count($contacts) - 1]) { array_push($farray, $garray); } } } $result['contacts'] = json_encode($farray); //Groups $rd = new \Modl\RosterLinkDAO(); $groups = $rd->getGroups(); if (is_array($groups) && !in_array("Ungrouped", $groups)) { $groups[] = "Ungrouped"; } else { $groups = array(); } $groups = array_flip($groups); $result['groups'] = json_encode($groups); return $result; }
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); }
function preparePost($p, $external = false, $public = false) { $view = $this->tpl(); if (isset($p)) { if (isset($p->commentorigin) && !$external) { $this->ajaxGetComments($p->commentorigin, $p->commentnodeid); // Broken in case of repost } $view->assign('repost', false); $view->assign('external', $external); $view->assign('public', $public); $view->assign('reply', $p->isReply() ? $p->getReply() : false); // Is it a repost ? if ($p->isRecycled()) { $cd = new \Modl\ContactDAO(); $view->assign('repost', $cd->get($p->origin)); } $view->assign('post', $p); $view->assign('attachments', $p->getAttachments()); return $view->draw('_post', true); } elseif (!$external) { return $this->prepareEmpty(); } }
function ajaxGetRememberedSession($sessions) { $sessions = json_decode($sessions); $sessions_grabbed = array(); $cd = new \Modl\ContactDAO(); foreach ($sessions as $s) { $c = $cd->get($s); if ($c != null) { array_push($sessions_grabbed, $c); } else { $c = new \Modl\Contact(); $c->jid = $s; array_push($sessions_grabbed, $c); } } $sessionshtml = $this->tpl(); $sessionshtml->assign('sessions', $sessions_grabbed); $sessionshtml->assign('empty', new \Modl\Contact()); RPC::call('movim_fill', 'sessions', $sessionshtml->draw('_login_sessions', true)); RPC::call('Login.refresh'); }
function ajaxGetContact($jid) { $cd = new \Modl\ContactDAO(); $contact = $cd->get($jid); $contactview = $this->tpl(); $contactview->assign('contact', $contact); RPC::call('movim_fill', 'avatar', $contactview->draw('_visio_contact', true)); }