]> git.mxchange.org Git - friendica.git/blobdiff - mod/photos.php
Merge pull request #10228 from MrPetovan/bug/warnings
[friendica.git] / mod / photos.php
index 94c348cc9f99ad09b9f5b31ba2e1d3988193bf33..df843846456d613522f83fa45d272402c1937a81 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2020, Friendica
+ * @copyright Copyright (C) 2010-2021, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -36,6 +36,7 @@ use Friendica\DI;
 use Friendica\Model\Contact;
 use Friendica\Model\Item;
 use Friendica\Model\Photo;
+use Friendica\Model\Post;
 use Friendica\Model\Profile;
 use Friendica\Model\Tag;
 use Friendica\Model\User;
@@ -427,7 +428,7 @@ function photos_post(App $a)
                }
 
                if ($item_id) {
-                       $item = Item::selectFirst(['tag', 'inform', 'uri-id'], ['id' => $item_id, 'uid' => $page_owner_uid]);
+                       $item = Post::selectFirst(['tag', 'inform', 'uri-id'], ['id' => $item_id, 'uid' => $page_owner_uid]);
 
                        if (DBA::isResult($item)) {
                                $old_inform = $item['inform'];
@@ -783,7 +784,7 @@ function photos_post(App $a)
        $arr['guid']          = System::createUUID();
        $arr['uid']           = $page_owner_uid;
        $arr['uri']           = $uri;
-       $arr['type']          = 'photo';
+       $arr['post-type']     = Item::PT_IMAGE;
        $arr['wall']          = 1;
        $arr['resource-id']   = $resource_id;
        $arr['contact-id']    = $owner_record['id'];
@@ -1265,23 +1266,22 @@ function photos_content(App $a)
                // as a "post" but displaying instead the photo it is linked to
 
                /// @todo Rewrite this query. To do so, $sql_extra must be changed
-               $linked_items = q("SELECT `id` FROM `item` WHERE `resource-id` = '%s' $sql_extra LIMIT 1",
+               $linked_items = q("SELECT `id` FROM `post-user-view` WHERE `resource-id` = '%s' $sql_extra LIMIT 1",
                        DBA::escape($datum)
                );
                if (DBA::isResult($linked_items)) {
                        // This is a workaround to not being forced to rewrite the while $sql_extra handling
-                       $link_item = Item::selectFirst([], ['id' => $linked_items[0]['id']]);
+                       $link_item = Post::selectFirst([], ['id' => $linked_items[0]['id']]);
                }
 
                if (!empty($link_item['parent']) && !empty($link_item['uid'])) {
                        $condition = ["`parent` = ? AND `gravity` != ?",  $link_item['parent'], GRAVITY_PARENT];
-                       $total = DBA::count('item', $condition);
+                       $total = Post::count($condition);
 
                        $pager = new Pager(DI::l10n(), DI::args()->getQueryString());
 
                        $params = ['order' => ['id'], 'limit' => [$pager->getStart(), $pager->getItemsPerPage()]];
-                       $result = Item::selectForUser($link_item['uid'], Item::ITEM_FIELDLIST, $condition, $params);
-                       $items = Item::inArray($result);
+                       $items = Post::toArray(Post::selectForUser($link_item['uid'], Item::ITEM_FIELDLIST, $condition, $params));
 
                        if (local_user() == $link_item['uid']) {
                                Item::update(['unseen' => false], ['parent' => $link_item['parent']]);
@@ -1454,7 +1454,9 @@ function photos_content(App $a)
                                                continue;
                                        }
 
-                                       $profile_url = Contact::magicLinkbyId($item['author-id']);
+                                       $author = ['uid' => 0, 'id' => $item['author-id'],
+                                               'network' => $item['author-network'], 'url' => $item['author-link']];
+                                       $profile_url = Contact::magicLinkByContact($author);
                                        if (strpos($profile_url, 'redir/') === 0) {
                                                $sparkle = ' sparkle';
                                        } else {