From b66bcb20daf65b6c988db75319363ed550041510 Mon Sep 17 00:00:00 2001 From: Jonny Tischbein Date: Thu, 25 Oct 2018 23:57:26 +0200 Subject: [PATCH 1/4] Redirect to previous page after NON-AJAX Post delete via second parameter in /item/drop --- include/items.php | 14 +++++++++++--- mod/item.php | 4 ++-- src/Object/Post.php | 1 + view/theme/frio/templates/wall_thread.tpl | 2 +- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/include/items.php b/include/items.php index 887bbb5b68..6eb1345889 100644 --- a/include/items.php +++ b/include/items.php @@ -345,7 +345,7 @@ function drop_items(array $items) } } -function drop_item($id) +function drop_item($id, $return) { $a = BaseObject::getApp(); @@ -409,8 +409,16 @@ function drop_item($id) // delete the item Item::deleteForUser(['id' => $item['id']], local_user()); - $a->internalRedirect('network'); - //NOTREACHED + $return_url = hex2bin($return); + notice("RETURN: " + $return_url); + if (empty($return_url) || strpos($return_url, 'display') ) { + $a->internalRedirect('network'); + //NOTREACHED + } + else { + $a->internalRedirect($return_url); + //NOTREACHED + } } else { notice(L10n::t('Permission denied.') . EOL); $a->internalRedirect('display/' . $item['guid']); diff --git a/mod/item.php b/mod/item.php index c7dbfd21c6..2aaa3a38f0 100644 --- a/mod/item.php +++ b/mod/item.php @@ -881,11 +881,11 @@ function item_content(App $a) $o = ''; - if (($a->argc == 3) && ($a->argv[1] === 'drop') && intval($a->argv[2])) { + if (($a->argc >= 3) && ($a->argv[1] === 'drop') && intval($a->argv[2])) { if ($a->isAjax()) { $o = Item::deleteForUser(['id' => $a->argv[2]], local_user()); } else { - $o = drop_item($a->argv[2]); + $o = drop_item($a->argv[2], $a->argv[3]); } if ($a->isAjax()) { diff --git a/src/Object/Post.php b/src/Object/Post.php index 086b78960a..e2c1ea03c3 100644 --- a/src/Object/Post.php +++ b/src/Object/Post.php @@ -414,6 +414,7 @@ class Post extends BaseObject 'received' => $item['received'], 'commented' => $item['commented'], 'created_date' => $item['created'], + 'return' => ($a->cmd) ? bin2hex($a->cmd) : '', ]; $arr = ['item' => $item, 'output' => $tmp_item]; diff --git a/view/theme/frio/templates/wall_thread.tpl b/view/theme/frio/templates/wall_thread.tpl index 53efacda70..c46fc339dd 100644 --- a/view/theme/frio/templates/wall_thread.tpl +++ b/view/theme/frio/templates/wall_thread.tpl @@ -141,7 +141,7 @@ as the value of $top_child_total (this is done at the end of this file) {{if $item.drop.dropping}}
  • - +
  • {{/if}} From 6b43174a7484a46ceff8f0fabb16b3e4a969d475 Mon Sep 17 00:00:00 2001 From: Jonny Tischbein Date: Fri, 26 Oct 2018 14:05:59 +0200 Subject: [PATCH 2/4] Fix for vier theme / NonAjax Call --- mod/item.php | 7 ++++++- view/theme/vier/templates/wall_thread.tpl | 3 +-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/mod/item.php b/mod/item.php index 2aaa3a38f0..54ef53a4b8 100644 --- a/mod/item.php +++ b/mod/item.php @@ -885,7 +885,12 @@ function item_content(App $a) if ($a->isAjax()) { $o = Item::deleteForUser(['id' => $a->argv[2]], local_user()); } else { - $o = drop_item($a->argv[2], $a->argv[3]); + if (!empty($a->argv[3])) { + $o = drop_item($a->argv[2], $a->argv[3]); + } + else { + $o = drop_item($a->argv[2]); + } } if ($a->isAjax()) { diff --git a/view/theme/vier/templates/wall_thread.tpl b/view/theme/vier/templates/wall_thread.tpl index 6c636d53b6..8debce3649 100644 --- a/view/theme/vier/templates/wall_thread.tpl +++ b/view/theme/vier/templates/wall_thread.tpl @@ -1,4 +1,3 @@ - {{if $mode == display}} {{else}} {{if $item.comment_firstcollapsed}} @@ -146,7 +145,7 @@ {{/if}} {{if $item.drop.dropping}} - {{$item.drop.delete}} + {{$item.drop.delete}} {{/if}} {{if $item.edpost}} {{$item.edpost.1}} From 645f9387fa2123dac3333bb82a29a8f290d39032 Mon Sep 17 00:00:00 2001 From: Jonny Tischbein Date: Fri, 26 Oct 2018 15:00:15 +0200 Subject: [PATCH 3/4] make return url optional --- include/items.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/include/items.php b/include/items.php index 6eb1345889..961a20b240 100644 --- a/include/items.php +++ b/include/items.php @@ -345,7 +345,7 @@ function drop_items(array $items) } } -function drop_item($id, $return) +function drop_item($id, $return = '') { $a = BaseObject::getApp(); @@ -410,8 +410,7 @@ function drop_item($id, $return) Item::deleteForUser(['id' => $item['id']], local_user()); $return_url = hex2bin($return); - notice("RETURN: " + $return_url); - if (empty($return_url) || strpos($return_url, 'display') ) { + if (empty($return_url) || strpos($return_url, 'display') !== false) { $a->internalRedirect('network'); //NOTREACHED } From b73be5749b20787fd5f6601edc1ec04181ee0870 Mon Sep 17 00:00:00 2001 From: Jonny Tischbein Date: Wed, 31 Oct 2018 20:17:11 +0100 Subject: [PATCH 4/4] Add support for quattro --- view/theme/quattro/templates/wall_thread.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view/theme/quattro/templates/wall_thread.tpl b/view/theme/quattro/templates/wall_thread.tpl index 79bf1d6b6f..fda871b196 100644 --- a/view/theme/quattro/templates/wall_thread.tpl +++ b/view/theme/quattro/templates/wall_thread.tpl @@ -140,7 +140,7 @@ {{/if}} {{if $item.drop.dropping}} - {{$item.drop.delete}} + {{$item.drop.delete}} {{/if}} {{if $item.edpost}}