]> git.mxchange.org Git - friendica.git/blobdiff - include/items.php
Remove obsolete INI config files
[friendica.git] / include / items.php
index adc5bf0133d2570afc71bae4246e394638788841..c3113836138c1ff8c25784a109ca22dc2b0d355d 100644 (file)
@@ -97,7 +97,7 @@ function add_page_info_data(array $data, $no_photos = false)
                        /// @TODO make a positive list of allowed characters
                        $hashtag = str_replace([" ", "+", "/", ".", "#", "'", "’", "`", "(", ")", "„", "“"],
                                                ["", "", "", "", "", "", "", "", "", "", "", ""], $keyword);
-                       $hashtags .= "#[url=" . System::baseUrl() . "/search?tag=" . rawurlencode($hashtag) . "]" . $hashtag . "[/url] ";
+                       $hashtags .= "#[url=" . System::baseUrl() . "/search?tag=" . $hashtag . "]" . $hashtag . "[/url] ";
                }
        }
 
@@ -148,7 +148,7 @@ function add_page_keywords($url, $photo = "", $keywords = false, $keyword_blackl
                                $tags .= ", ";
                        }
 
-                       $tags .= "#[url=" . System::baseUrl() . "/search?tag=" . rawurlencode($hashtag) . "]" . $hashtag . "[/url]";
+                       $tags .= "#[url=" . System::baseUrl() . "/search?tag=" . $hashtag . "]" . $hashtag . "[/url]";
                }
        }
 
@@ -352,7 +352,7 @@ function drop_item($id, $return = '')
 
        // locate item to be deleted
 
-       $fields = ['id', 'uid', 'guid', 'contact-id', 'deleted'];
+       $fields = ['id', 'uid', 'guid', 'contact-id', 'deleted', 'gravity', parent];
        $item = Item::selectFirstForUser(local_user(), $fields, ['id' => $id]);
 
        if (!DBA::isResult($item)) {
@@ -407,6 +407,13 @@ function drop_item($id, $return = '')
                        $a->internalRedirect('display/' . $item['guid']);
                }
 
+               $is_comment = ($item['gravity'] == GRAVITY_COMMENT) ? true : false;
+               $parentitem = null;
+               if (!empty($item['parent'])){
+                       $fields = ['guid'];
+                       $parentitem = Item::selectFirstForUser(local_user(), $fields, ['id' => $item['parent']]);
+               }
+
                // delete the item
                Item::deleteForUser(['id' => $item['id']], local_user());
 
@@ -415,13 +422,28 @@ function drop_item($id, $return = '')
                // removes update_* from return_url to ignore Ajax refresh
                $return_url = str_replace("update_", "", $return_url);
 
-               if (empty($return_url) || strpos($return_url, 'display') !== false) {
-                       $a->internalRedirect('network');
-                       //NOTREACHED
+               // Check if delete a comment
+               if ($is_comment) {
+                       // Return to parent guid
+                       if (!empty($parentitem)) {
+                               $a->internalRedirect('display/' . $parentitem['guid']);
+                               //NOTREACHED
+                       }
+                       // In case something goes wrong
+                       else {
+                               $a->internalRedirect('network');
+                               //NOTREACHED
+                       }
                }
                else {
-                       $a->internalRedirect($return_url);
-                       //NOTREACHED
+                       // if unknown location or deleting top level post called from display
+                       if (empty($return_url) || strpos($return_url, 'display') !== false) {
+                               $a->internalRedirect('network');
+                               //NOTREACHED
+                       } else {
+                               $a->internalRedirect($return_url);
+                               //NOTREACHED
+                       }
                }
        } else {
                notice(L10n::t('Permission denied.') . EOL);