]> git.mxchange.org Git - friendica.git/blobdiff - mod/photos.php
Set CORS header fields to support Halcyon
[friendica.git] / mod / photos.php
index b999eec3867d3fc9c33631d0c08498fcbde69664..b0bd79b8f52afd17dfdf9034363d27f31c028821 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
  *
@@ -73,7 +73,7 @@ function photos_init(App $a) {
                $a->profile_uid = $user['uid'];
                $is_owner = (local_user() && (local_user() == $a->profile_uid));
 
-               $profile = Profile::getByNickname($nick, $a->profile_uid);
+               $profile = Profile::getByNickname($nick);
 
                $account_type = Contact::getAccountType($profile);
 
@@ -784,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'];
@@ -1266,7 +1266,7 @@ 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)) {
@@ -1275,7 +1275,7 @@ function photos_content(App $a)
                }
 
                if (!empty($link_item['parent']) && !empty($link_item['uid'])) {
-                       $condition = ["`parent` = ? AND `gravity` != ?",  $link_item['parent'], GRAVITY_PARENT];
+                       $condition = ["`parent` = ? AND `gravity` = ?",  $link_item['parent'], GRAVITY_COMMENT];
                        $total = Post::count($condition);
 
                        $pager = new Pager(DI::l10n(), DI::args()->getQueryString());
@@ -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 {