Пример #1
0
 public function handle($stanza, $parent = false)
 {
     $to = current(explode('/', (string) $stanza->attributes()->to));
     $from = $this->_to;
     $node = $this->_node;
     if ($stanza->pubsub->items->item) {
         $post = false;
         foreach ($stanza->pubsub->items->item as $item) {
             if (isset($item->entry) && (string) $item->entry->attributes()->xmlns == 'http://www.w3.org/2005/Atom') {
                 $p = new \Modl\Postn();
                 $promise = $p->set($item, $from, false, $node);
                 $promise->done(function () use($p) {
                     $pd = new \Modl\PostnDAO();
                     $pd->set($p);
                     $post = true;
                     if (is_array($this->_askreply)) {
                         $this->pack(['origin' => $this->_askreply['origin'], 'node' => $this->_askreply['node'], 'nodeid' => $this->_askreply['nodeid']]);
                         $this->deliver();
                     } else {
                         $this->pack($p);
                         $this->event('post', $this->packet);
                     }
                     $this->pack(['server' => $this->_to, 'node' => $this->_node]);
                     $this->deliver();
                 });
             }
         }
     } else {
         $pd = new PostDelete();
         $pd->setTo($this->_to)->setNode($this->_node)->setId($this->_id);
         $pd->handle($stanza);
     }
 }
Пример #2
0
 function getComments($post)
 {
     $pd = new \Modl\PostnDAO();
     return $pd->getComments($post);
     //$view = $this->tpl();
     //$view->assign('comments', $comments);
 }
Пример #3
0
 public function setPicture()
 {
     $pd = new \Modl\PostnDAO();
     $item = $pd->getGroupPicture($this->server, $this->node);
     if ($item) {
         $item->getAttachments();
         $p = new \Picture();
         if ($item->getPublicUrl()) {
             try {
                 $embed = \Embed\Embed::create($item->getPublicUrl());
                 // We get the icon
                 $url = false;
                 foreach ($embed->providerIcons as $icon) {
                     if ($icon['mime'] != 'image/x-icon') {
                         $url = $icon['value'];
                     }
                 }
                 // If not we take the main picture
                 if (!$url) {
                     $url = (string) $embed->image;
                 }
                 // If not we take the post picture
                 if (!$url) {
                     $url = (string) $item->picture;
                 }
                 $p->fromURL($url);
                 if ($p->set($this->server . $this->node)) {
                     $this->logo = true;
                 }
             } catch (\Exception $e) {
                 error_log($e->getMessage());
             }
         }
     }
 }
Пример #4
0
 function onRemoved()
 {
     $md = new Modl\MessageDAO();
     $md->clearMessage();
     $pd = new Modl\PostnDAO();
     $pd->deleteNode($this->user->getLogin(), 'urn:xmpp:microblog:0');
     RPC::call('Account.clearAccount');
 }
Пример #5
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());
 }
Пример #6
0
 public function handle($stanza, $parent = false)
 {
     $evt = new Event();
     $node = (string) $stanza->pubsub->items->attributes()->node;
     list($xmlns, $parent) = explode("/", $node);
     if ($stanza->pubsub->items->item) {
         foreach ($stanza->pubsub->items->item as $item) {
             $p = new \Modl\Postn();
             $p->set($item, $this->_to, false, $node);
             $pd = new \Modl\PostnDAO();
             $pd->set($p);
         }
     }
     $this->pack(['server' => $this->_to, 'node' => $this->_node, 'id' => $this->_id]);
     $this->deliver();
 }
Пример #7
0
 function dispatch()
 {
     $this->page->setTitle(__('page.news'));
     $user = new User();
     if (!$user->isLogged()) {
         $pd = new \Modl\PostnDAO();
         $p = $pd->get($this->fetchGet('s'), $this->fetchGet('n'), $this->fetchGet('i'));
         if ($p) {
             if ($p->isMicroblog()) {
                 $this->redirect('blog', [$p->origin, $p->nodeid]);
             } else {
                 $this->redirect('node', [$p->origin, $p->node, $p->nodeid]);
             }
         } else {
             $this->redirect('login');
         }
     }
 }
Пример #8
0
 function prepareList($type = 'all', $server = null, $node = null, $page = 0)
 {
     $view = $this->tpl();
     $pd = new \Modl\PostnDAO();
     $count = $pd->getCountSince(Cache::c('since'));
     // getting newer, not older
     if ($page == 0 || $page == "") {
         $count = 0;
         Cache::c('since', date(DATE_ISO8601, strtotime($pd->getLastDate())));
     }
     $next = $page + 1;
     switch ($type) {
         case 'all':
             $view->assign('history', $this->call('ajaxGetAll', $next));
             $items = $pd->getAllPosts(false, $page * $this->_paging + $count, $this->_paging);
             break;
         case 'news':
             $view->assign('history', $this->call('ajaxGetNews', $next));
             $items = $pd->getNews($page * $this->_paging + $count, $this->_paging);
             break;
         case 'feed':
             $view->assign('history', $this->call('ajaxGetFeed', $next));
             $items = $pd->getFeed($page * $this->_paging + $count, $this->_paging);
             break;
         case 'me':
             $view->assign('history', $this->call('ajaxGetMe', $next));
             $items = $pd->getMe($page * $this->_paging + $count, $this->_paging);
             break;
         case 'node':
             $view->assign('history', $this->call('ajaxGetNode', '"' . $server . '"', '"' . $node . '"', '"' . $next . '"'));
             $items = $pd->getNode($server, $node, $page * $this->_paging + $count, $this->_paging);
             break;
     }
     $view->assign('items', $items);
     $view->assign('page', $page);
     $view->assign('paging', $this->_paging);
     $html = $view->draw('_menu_list', true);
     if ($page == 0 || $page == "") {
         $view = $this->tpl();
         $view->assign('to', $this->user->getLogin());
         $html .= $view->draw('_menu_add', true);
     }
     return $html;
 }
Пример #9
0
 function getComments($post)
 {
     $pd = new \Modl\PostnDAO();
     return $pd->getComments($post);
 }
Пример #10
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);
     }
 }
Пример #11
0
 function ajaxTogglePrivacy($id)
 {
     $validate = Validator::string()->length(6, 128);
     if (!$validate->validate($id)) {
         return;
     }
     $pd = new \Modl\PrivacyDAO();
     $p = $pd->get($id);
     $pd = new \Modl\PostnDAO();
     $po = $pd->getItem($id);
     if ($po->isMine()) {
         if ($po->privacy == 1) {
             Notification::append(false, $this->__('post.public_no'));
             \Modl\Privacy::set($id, 0);
         }
         if ($po->privacy == 0) {
             Notification::append(false, $this->__('post.public_yes'));
             \Modl\Privacy::set($id, 1);
         }
     }
 }
Пример #12
0
 public function countComments()
 {
     $pd = new \Modl\PostnDAO();
     return $pd->countComments($this->commentorigin, $this->commentnodeid);
 }
Пример #13
0
 private function prepareGroup($server, $node, $page = 0)
 {
     $pd = new \Modl\PostnDAO();
     $posts = $pd->getNodeUnfiltered($server, $node, $page * $this->_paging, $this->_paging);
     $view = $this->tpl();
     $view->assign('server', $server);
     $view->assign('node', $node);
     $view->assign('page', $page);
     $view->assign('posts', $posts);
     $html = $view->draw('_group_posts', true);
     return $html;
 }