]> git.mxchange.org Git - friendica.git/blobdiff - mod/photos.php
More test data
[friendica.git] / mod / photos.php
index 6e9a96ab2d9f892935cfb13f196f788f819f6a21..71e32d4de4046cffb539328aee7e7aae8a132cc3 100644 (file)
@@ -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;
@@ -184,22 +185,21 @@ function photos_post(App $a)
                exit();
        }
 
-       $str_contact_allow = '';
-       $str_group_allow   = '';
-       $str_contact_deny  = '';
-       $str_group_deny    = '';
-
-       if (($_REQUEST['visibility'] ?? '') !== 'public') {
-               $aclFormatter = DI::aclFormatter();
-               $str_contact_allow = isset($_REQUEST['contact_allow']) ? $aclFormatter->toString($_REQUEST['contact_allow']) : $owner_record['allow_cid'] ?? '';
-               $str_group_allow   = isset($_REQUEST['group_allow'])   ? $aclFormatter->toString($_REQUEST['group_allow'])   : $owner_record['allow_gid'] ?? '';
-               $str_contact_deny  = isset($_REQUEST['contact_deny'])  ? $aclFormatter->toString($_REQUEST['contact_deny'])  : $owner_record['deny_cid']  ?? '';
-               $str_group_deny    = isset($_REQUEST['group_deny'])    ? $aclFormatter->toString($_REQUEST['group_deny'])    : $owner_record['deny_gid']  ?? '';
-
-               // Since we know from the visibility parameter it should be private, we have to prevent the empty ACL case
-               // that would make the item public. So we always append the author's contact id to the allowed contacts.
+       $aclFormatter = DI::aclFormatter();
+       $str_contact_allow = isset($_REQUEST['contact_allow']) ? $aclFormatter->toString($_REQUEST['contact_allow']) : $owner_record['allow_cid'] ?? '';
+       $str_group_allow   = isset($_REQUEST['group_allow'])   ? $aclFormatter->toString($_REQUEST['group_allow'])   : $owner_record['allow_gid'] ?? '';
+       $str_contact_deny  = isset($_REQUEST['contact_deny'])  ? $aclFormatter->toString($_REQUEST['contact_deny'])  : $owner_record['deny_cid']  ?? '';
+       $str_group_deny    = isset($_REQUEST['group_deny'])    ? $aclFormatter->toString($_REQUEST['group_deny'])    : $owner_record['deny_gid']  ?? '';
+
+       $visibility = $_REQUEST['visibility'] ?? '';
+       if ($visibility === 'public') {
+               // The ACL selector introduced in version 2019.12 sends ACL input data even when the Public visibility is selected
+               $str_contact_allow = $str_group_allow = $str_contact_deny = $str_group_deny = '';
+       } else if ($visibility === 'custom') {
+               // Since we know from the visibility parameter the item should be private, we have to prevent the empty ACL
+               // case that would make it public. So we always append the author's contact id to the allowed contacts.
                // See https://github.com/friendica/friendica/issues/9672
-               $str_contact_allow .= $aclFormatter->toString(\Friendica\Model\Contact::getPublicIdByUserId($page_owner_uid));
+               $str_contact_allow .= $aclFormatter->toString(Contact::getPublicIdByUserId($page_owner_uid));
        }
 
        if ($a->argc > 3 && $a->argv[2] === 'album') {
@@ -428,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'];
@@ -1266,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-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']]);
@@ -1455,7 +1454,7 @@ function photos_content(App $a)
                                                continue;
                                        }
 
-                                       $profile_url = Contact::magicLinkbyId($item['author-id']);
+                                       $profile_url = Contact::magicLinkById($item['author-id']);
                                        if (strpos($profile_url, 'redir/') === 0) {
                                                $sparkle = ' sparkle';
                                        } else {