Browse Source

- Fix the Notification x2 incrementation

- Add a ACK when a post is published
- Add some locales
pull/16/head
Jaussoin Timothée 11 years ago
parent
commit
483455c857
  1. 20
      app/models/postn/PostnDAO.php
  2. 34
      app/widgets/Menu/Menu.php
  3. 14
      app/widgets/Notification/Notification.php
  4. 8
      app/widgets/Post/Post.php
  5. 1
      app/widgets/Post/locales.ini

20
app/models/postn/PostnDAO.php

@ -408,7 +408,7 @@ class PostnDAO extends SQL {
}
function getCountSince($date) {
$this->_sql = '
/*$this->_sql = '
select count(*) from postn
left outer join subscription on
postn.session = subscription.jid and
@ -418,7 +418,14 @@ class PostnDAO extends SQL {
and postn.node not like \'urn:xmpp:microblog:0:comments/%\'
and postn.node not like \'urn:xmpp:inbox\'
and subscription is not null
and published > :published';
and published > :published';*/
$this->_sql = '
select count(*) from postn
where postn.session = :session
and postn.node not like \'urn:xmpp:microblog:0:comments/%\'
and postn.node not like \'urn:xmpp:inbox\'
and published > :published
';
$this->prepare(
'Postn',
@ -436,6 +443,7 @@ class PostnDAO extends SQL {
}
function getLastDate() {
/*
$this->_sql = '
select published from postn
left outer join subscription on
@ -447,6 +455,14 @@ class PostnDAO extends SQL {
and postn.node not like \'urn:xmpp:inbox\'
and subscription is not null
order by postn.published desc
limit 1 offset 0';*/
$this->_sql = '
select published from postn
where postn.session = :session
and postn.node not like \'urn:xmpp:microblog:0:comments/%\'
and postn.node not like \'urn:xmpp:inbox\'
order by postn.published desc
limit 1 offset 0';
$this->prepare(

34
app/widgets/Menu/Menu.php

@ -9,6 +9,7 @@ class Menu extends WidgetCommon
function load()
{
$this->registerEvent('post', 'onPost');
$this->registerEvent('pubsub_postpublish_handle', 'onPublish');
$this->addjs('menu.js');
}
@ -22,7 +23,12 @@ class Menu extends WidgetCommon
RPC::call('movim_fill', 'menu_refresh', $view->draw('_menu_refresh', true));
}
function onPost($packet)
function onPublish($packet)
{
$this->onPost($packet, false);
}
function onPost($packet, $notify = true)
{
$pd = new \Modl\PostnDAO;
$count = $pd->getCountSince(Cache::c('since'));
@ -39,9 +45,9 @@ class Menu extends WidgetCommon
$title = $post->title;
}
Notification::append('news', $contact->getTrueName(), $title, $contact->getPhoto('s'), 2);
if($notify) Notification::append('news', $contact->getTrueName(), $title, $contact->getPhoto('s'), 2);
} else {
Notification::append('news', $post->title, $post->node, null, 2);
if($notify) Notification::append('news', $post->title, $post->node, null, 2);
}
$this->onStream($count);
@ -97,14 +103,14 @@ class Menu extends WidgetCommon
}
function prepareList($type = 'all', $server = null, $node = null, $page = 0) {
movim_log(__METHOD__);
//movim_log(__METHOD__);
$view = $this->tpl();
$pd = new \Modl\PostnDAO;
$count = $pd->getCountSince(Cache::c('since'));
// getting newer, not older
movim_log($page);
movim_log($page == "");
//movim_log($page);
//movim_log($page == "");
if($page == 0 || $page == ""){
$count = 0;
Cache::c('since', date(DATE_ISO8601, strtotime($pd->getLastDate())));
@ -116,30 +122,30 @@ class Menu extends WidgetCommon
case 'all' :
$view->assign('history', $this->call('ajaxGetAll', $next));
$items = $pd->getAllPosts(false, $page * $this->_paging + $count, $this->_paging);
movim_log(__LINE__);
/*movim_log(__LINE__);
movim_log(" ALL ");
movim_log($page * $this->_paging + $count);
movim_log($page * $this->_paging + $count);*/
break;
case 'news' :
$view->assign('history', $this->call('ajaxGetNews', $next));
$items = $pd->getNews($page * $this->_paging + $count, $this->_paging);
movim_log(__LINE__);
/*movim_log(__LINE__);
movim_log(" NEWS ");
movim_log($page * $this->_paging + $count);
movim_log($page * $this->_paging + $count);*/
break;
case 'feed' :
$view->assign('history', $this->call('ajaxGetFeed', $next));
$items = $pd->getFeed($page * $this->_paging + $count, $this->_paging);
movim_log(__LINE__);
/*movim_log(__LINE__);
movim_log(" FEED ");
movim_log($page * $this->_paging + $count);
movim_log($page * $this->_paging + $count);*/
break;
case 'node' :
$view->assign('history', $this->call('ajaxGetNode', '"'.$server.'"', '"'.$node.'"', $next));
$items = $pd->getNode($server, $node, $page * $this->_paging + $count, $this->_paging);
movim_log(__LINE__);
/*movim_log(__LINE__);
movim_log(" NODE ");
movim_log($page * $this->_paging + $count);
movim_log($page * $this->_paging + $count);*/
break;
}

14
app/widgets/Notification/Notification.php

@ -47,13 +47,15 @@ class Notification extends WidgetCommon
RPC::call('Notification.counter', $first, $notifs[$first]);
if(array_key_exists($key, $notifs)) {
$notifs[$key]++;
} else {
$notifs[$key] = 1;
}
if($first != $key) {
if(array_key_exists($key, $notifs)) {
$notifs[$key]++;
} else {
$notifs[$key] = 1;
}
RPC::call('Notification.counter', $key, $notifs[$key]);
RPC::call('Notification.counter', $key, $notifs[$key]);
}
$n = new Notification;
RPC::call('Notification.snackbar', $n->prepareSnackbar($title, $body, $picture), $time);

8
app/widgets/Post/Post.php

@ -28,6 +28,14 @@ class Post extends WidgetCommon
{
$this->addcss('post.css');
$this->registerEvent('microblog_commentsget_handle', 'onComments');
$this->registerEvent('pubsub_postpublish_handle', 'onPublish');
}
function onPublish($packet)
{
Notification::append(false, $this->__('post.published'));
$this->ajaxClear();
RPC::call('MovimTpl.hidePanel');
}
function ajaxClear()

1
app/widgets/Post/locales.ini

@ -12,3 +12,4 @@ post.tags = 'Tags'
post.valid_url = 'Please enter a valid url'
post.no_content_preview = 'No content to preview'
post.no_content = 'No content'
post.published = 'Post published'
Loading…
Cancel
Save