]> git.mxchange.org Git - friendica.git/blobdiff - mod/item.php
Merge pull request #13142 from annando/collapse-author
[friendica.git] / mod / item.php
index 13ffe756833b6c391e52784a8f7af6b075535cf5..369b0888a29449bbac8239ea1c16c92d7c2c642b 100644 (file)
@@ -19,7 +19,7 @@
  *
  * This is the POST destination for most all locally posted
  * text stuff. This function handles status, wall-to-wall status,
- * local comments, and remote coments that are posted on this site
+ * local comments, and remote comments that are posted on this site
  * (as opposed to being delivered in a feed).
  * Also processed here are posts and comments coming through the
  * statusnet/twitter API.
@@ -41,10 +41,8 @@ use Friendica\DI;
 use Friendica\Model\Contact;
 use Friendica\Model\Item;
 use Friendica\Model\ItemURI;
-use Friendica\Model\Photo;
 use Friendica\Model\Post;
 use Friendica\Network\HTTPException;
-use Friendica\Protocol\Activity;
 use Friendica\Util\DateTimeFormat;
 
 function item_post(App $a) {
@@ -108,6 +106,7 @@ function item_edit(int $uid, array $request, bool $preview, string $return_path)
        $post['edit'] = $post;
        $post['file'] = Post\Category::getTextByURIId($post['uri-id'], $post['uid']);   
 
+       Post\Media::deleteByURIId($post['uri-id'], [Post\Media::AUDIO, Post\Media::VIDEO, Post\Media::IMAGE, Post\Media::HTML]);
        $post = item_process($post, $request, $preview, $return_path);
 
        $fields = [
@@ -385,6 +384,22 @@ function item_content(App $a)
 
                        Contact\User::setIgnored($item['author-id'], DI::userSession()->getLocalUserId(), true);
 
+                       if (DI::mode()->isAjax()) {
+                               // ajax return: [<item id>, 0 (no perm) | <owner id>]
+                               System::jsonExit([intval($args->get(2)), DI::userSession()->getLocalUserId()]);
+                       } else {
+                               item_redirect_after_action($item, $args->get(3));
+                       }
+                       break;
+
+               case 'collapse':
+                       $item = Post::selectFirstForUser(DI::userSession()->getLocalUserId(), ['guid', 'author-id', 'parent', 'gravity'], ['id' => $args->get(2)]);
+                       if (empty($item['author-id'])) {
+                               throw new HTTPException\NotFoundException('Item not found');
+                       }
+
+                       Contact\User::setCollapsed($item['author-id'], DI::userSession()->getLocalUserId(), true);
+
                        if (DI::mode()->isAjax()) {
                                // ajax return: [<item id>, 0 (no perm) | <owner id>]
                                System::jsonExit([intval($args->get(2)), DI::userSession()->getLocalUserId()]);