From defcfd5a5e03fbb0a3a65ad77f30c62364771535 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaussoin=20Timoth=C3=A9e?= Date: Sun, 15 Mar 2015 10:20:57 +0100 Subject: [PATCH] - Fix bug #1429835 (recent chat on top of the list) - New feature, post deletion --- app/widgets/Chats/Chats.php | 3 ++- app/widgets/Post/Post.php | 31 ++++++++++++++++++++++++++++++- app/widgets/Post/_post_delete.tpl | 16 ++++++++++++++++ app/widgets/Post/_post_header.tpl | 9 +++++++++ app/widgets/Post/locales.ini | 5 +++++ linker.php | 8 ++++---- 6 files changed, 66 insertions(+), 6 deletions(-) create mode 100644 app/widgets/Post/_post_delete.tpl diff --git a/app/widgets/Chats/Chats.php b/app/widgets/Chats/Chats.php index 7e3430cb3..7f0dcfe54 100644 --- a/app/widgets/Chats/Chats.php +++ b/app/widgets/Chats/Chats.php @@ -32,7 +32,8 @@ class Chats extends WidgetCommon $this->ajaxOpen($from); } else { // TODO notification overwrite issue - RPC::call('movim_replace', $from.'_chat_item', $this->prepareChat($from)); + RPC::call('movim_delete', $from.'_chat_item'); + RPC::call('movim_prepend', 'chats_widget_list', $this->prepareChat($from)); RPC::call('Chats.refresh'); $n = new Notification; diff --git a/app/widgets/Post/Post.php b/app/widgets/Post/Post.php index ae8a59fa4..337bbb4f2 100644 --- a/app/widgets/Post/Post.php +++ b/app/widgets/Post/Post.php @@ -19,6 +19,7 @@ */ use Moxl\Xec\Action\Pubsub\PostPublish; +use Moxl\Xec\Action\Pubsub\PostDelete; use Moxl\Xec\Action\Microblog\CommentsGet; use \Michelf\Markdown; @@ -29,6 +30,7 @@ class Post extends WidgetCommon $this->addcss('post.css'); $this->registerEvent('microblog_commentsget_handle', 'onComments'); $this->registerEvent('pubsub_postpublish_handle', 'onPublish'); + $this->registerEvent('pubsub_postdelete_handle', 'onDelete'); } function onPublish() @@ -38,6 +40,14 @@ class Post extends WidgetCommon RPC::call('MovimTpl.hidePanel'); } + function onDelete() + { + Notification::append(false, $this->__('post.deleted')); + $this->ajaxClear(); + RPC::call('MovimTpl.hidePanel'); + RPC::call('Menu_ajaxGetAll'); + } + function ajaxClear() { RPC::call('movim_fill', 'post_widget', $this->prepareEmpty()); @@ -70,7 +80,7 @@ class Post extends WidgetCommon $view = $this->tpl(); $view->assign('content', Markdown::defaultTransform($form->content->value)); - Dialog::fill($view->draw('_post_preview', true)); + Dialog::fill($view->draw('_post_preview', true), true); } else { Notification::append(false, $this->__('post.no_content_preview')); } @@ -115,6 +125,25 @@ class Post extends WidgetCommon } } + function ajaxDelete($to, $node, $id) + { + $view = $this->tpl(); + + $view->assign('to', $to); + $view->assign('node', $node); + $view->assign('id', $id); + + Dialog::fill($view->draw('_post_delete', true)); + } + + function ajaxDeleteConfirm($to, $node, $id) { + $p = new PostDelete; + $p->setTo($to) + ->setNode($node) + ->setId($id) + ->request(); + } + function ajaxGetComments($jid, $id) { $c = new CommentsGet; diff --git a/app/widgets/Post/_post_delete.tpl b/app/widgets/Post/_post_delete.tpl new file mode 100644 index 000000000..143f20758 --- /dev/null +++ b/app/widgets/Post/_post_delete.tpl @@ -0,0 +1,16 @@ +
+

{$c->__('post.delete_title')}

+
+

{$c->__('post.delete_text')}

+
+
+ + {$c->__('button.cancel')} + + + {$c->__('button.delete')} + +
diff --git a/app/widgets/Post/_post_header.tpl b/app/widgets/Post/_post_header.tpl index 11c9cb324..e335de912 100644 --- a/app/widgets/Post/_post_header.tpl +++ b/app/widgets/Post/_post_header.tpl @@ -9,6 +9,15 @@
+ {if="$post->isMine()"} + + {/if}

{if="$post != null"} diff --git a/app/widgets/Post/locales.ini b/app/widgets/Post/locales.ini index 5bd801c65..02d79be78 100644 --- a/app/widgets/Post/locales.ini +++ b/app/widgets/Post/locales.ini @@ -13,6 +13,7 @@ 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' +post.deleted = 'Post deleted' post.gallery = 'This picture will be added to your gallery' post.hot = "What's Hot" @@ -20,3 +21,7 @@ post.hot = "What's Hot" post.public = 'Publish this post on your public feed?' post.blog_add = 'Post published on your blog' post.blog_remove = 'Post removed from your blog' + +[delete] +post.delete_title = 'Delete this post' +post.delete_text = 'You are going to delete this post, please confirm your action' diff --git a/linker.php b/linker.php index 98463048a..f15bf203a 100755 --- a/linker.php +++ b/linker.php @@ -45,7 +45,7 @@ $connector($config->websocketurl, array('xmpp'))->then(function($conn) use (&$st $conn->on('message', function($message) use ($conn, $loop) { if($message != '') { - #fwrite(STDERR, colorize($message, 'yellow')." : ".colorize('received', 'green')."\n"); + fwrite(STDERR, colorize($message, 'yellow')." : ".colorize('received', 'green')."\n"); if($message == '') { $conn->close(); @@ -76,7 +76,7 @@ $connector($config->websocketurl, array('xmpp'))->then(function($conn) use (&$st } if(!empty($xml)) { - #fwrite(STDERR, colorize(trim($xml), 'yellow')." : ".colorize('sent to XMPP', 'green')."\n"); + fwrite(STDERR, colorize(trim($xml), 'yellow')." : ".colorize('sent to XMPP', 'green')."\n"); $conn->send(trim($xml)); } } @@ -98,7 +98,7 @@ $connector($config->websocketurl, array('xmpp'))->then(function($conn) use (&$st $buffer = ''; foreach ($messages as $message) { - #fwrite(STDERR, colorize($message, 'yellow')." : ".colorize('received from the browser', 'green')."\n"); + fwrite(STDERR, colorize($message, 'yellow')." : ".colorize('received from the browser', 'green')."\n"); $msg = json_decode($message); @@ -118,7 +118,7 @@ $connector($config->websocketurl, array('xmpp'))->then(function($conn) use (&$st \Moxl\API::clear(); if(!empty($xml)) { - #fwrite(STDERR, colorize(trim($xml), 'yellow')." : ".colorize('sent to XMPP', 'green')."\n"); + fwrite(STDERR, colorize(trim($xml), 'yellow')." : ".colorize('sent to XMPP', 'green')."\n"); $conn->send(trim($xml)); }