]> git.mxchange.org Git - friendica.git/blobdiff - src/Module/Profile/Photos.php
Update function / rearrange tab order
[friendica.git] / src / Module / Profile / Photos.php
index caf0d1601110e13a990a89c579e887877b44450c..fcd0b78b09d8d27f14d72920a3b3dc722aa8ee8b 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2010-2022, the Friendica project
+ * @copyright Copyright (C) 2010-2023, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -78,7 +78,7 @@ class Photos extends \Friendica\Module\BaseProfile
                $this->systemMessages = $systemMessages;
                $this->aclFormatter   = $aclFormatter;
 
-               $owner = Profile::load($this->app, $this->parameters['nickname'] ?? '');
+               $owner = Profile::load($this->app, $this->parameters['nickname'] ?? '', false);
                if (!$owner || $owner['account_removed'] || $owner['account_expired']) {
                        throw new HTTPException\NotFoundException($this->t('User not found.'));
                }
@@ -93,14 +93,14 @@ class Photos extends \Friendica\Module\BaseProfile
                }
 
                $str_contact_allow = isset($request['contact_allow']) ? $this->aclFormatter->toString($request['contact_allow']) : $this->owner['allow_cid'] ?? '';
-               $str_group_allow   = isset($request['group_allow'])   ? $this->aclFormatter->toString($request['group_allow'])   : $this->owner['allow_gid'] ?? '';
+               $str_circle_allow  = isset($request['circle_allow'])  ? $this->aclFormatter->toString($request['circle_allow'])  : $this->owner['allow_gid'] ?? '';
                $str_contact_deny  = isset($request['contact_deny'])  ? $this->aclFormatter->toString($request['contact_deny'])  : $this->owner['deny_cid']  ?? '';
-               $str_group_deny    = isset($request['group_deny'])    ? $this->aclFormatter->toString($request['group_deny'])    : $this->owner['deny_gid']  ?? '';
+               $str_circle_deny   = isset($request['circle_deny'])   ? $this->aclFormatter->toString($request['circle_deny'])   : $this->owner['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 = '';
+                       $str_contact_allow = $str_circle_allow = $str_contact_deny = $str_circle_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.
@@ -229,33 +229,15 @@ class Photos extends \Friendica\Module\BaseProfile
                        $image->scaleDown($max_length);
                }
 
-               $width  = $image->getWidth();
-               $height = $image->getHeight();
-
-               $smallest = 0;
-
                $resource_id = Photo::newResource();
 
-               $r = Photo::store($image, $this->owner['uid'], 0, $resource_id, $filename, $album, 0 , Photo::DEFAULT, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny);
-
-               if (!$r) {
+               $preview = Photo::storeWithPreview($image, $this->owner['uid'], $resource_id, $filename, $filesize, $album, '', $str_contact_allow, $str_circle_allow, $str_contact_deny, $str_circle_deny);
+               if ($preview < 0) {
                        $this->logger->warning('image store failed');
                        $this->systemMessages->addNotice($this->t('Image upload failed.'));
                        return;
                }
 
-               if ($width > 640 || $height > 640) {
-                       $image->scaleDown(640);
-                       Photo::store($image, $this->owner['uid'], 0, $resource_id, $filename, $album, 1, Photo::DEFAULT, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny);
-                       $smallest = 1;
-               }
-
-               if ($width > 320 || $height > 320) {
-                       $image->scaleDown(320);
-                       Photo::store($image, $this->owner['uid'], 0, $resource_id, $filename, $album, 2, Photo::DEFAULT, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny);
-                       $smallest = 2;
-               }
-
                $uri = Item::newURI();
 
                // Create item container
@@ -285,15 +267,13 @@ class Photos extends \Friendica\Module\BaseProfile
                $arr['author-avatar'] = $this->owner['thumb'];
                $arr['title']         = '';
                $arr['allow_cid']     = $str_contact_allow;
-               $arr['allow_gid']     = $str_group_allow;
+               $arr['allow_gid']     = $str_circle_allow;
                $arr['deny_cid']      = $str_contact_deny;
-               $arr['deny_gid']      = $str_group_deny;
+               $arr['deny_gid']      = $str_circle_deny;
                $arr['visible']       = $visible;
                $arr['origin']        = 1;
 
-               $arr['body']          = '[url=' . $this->baseUrl . '/photos/' . $this->owner['nickname'] . '/image/' . $resource_id . ']'
-                       . '[img]' . $this->baseUrl . "/photo/{$resource_id}-{$smallest}.".$image->getExt() . '[/img]'
-                       . '[/url]';
+               $arr['body']          = Images::getBBCodeByResource($resource_id, $this->owner['nickname'], $preview, $image->getExt());
 
                $item_id = Item::insert($arr);
                // Update the photo albums cache
@@ -318,16 +298,8 @@ class Photos extends \Friendica\Module\BaseProfile
                $owner_uid = $this->owner['uid'];
                $is_owner  = $this->session->getLocalUserId() == $owner_uid;
 
-               $remote_contact = false;
-               if ($this->session->getRemoteContactID($owner_uid)) {
-                       $contact_id = $this->session->getRemoteContactID($owner_uid);
-
-                       $contact        = Contact::getContactForUser($contact_id, $owner_uid, ['blocked', 'pending']);
-                       $remote_contact = $contact && !$contact['blocked'] && !$contact['pending'];
-               }
-
                if ($this->owner['hidewall'] && !$this->session->isAuthenticated()) {
-                       $this->baseUrl->redirect('profile/' . $owner['nickname'] . '/restricted');
+                       $this->baseUrl->redirect('profile/' . $this->owner['nickname'] . '/restricted');
                }
 
                $this->session->set('photo_return', $this->args->getCommand());
@@ -362,7 +334,7 @@ class Photos extends \Friendica\Module\BaseProfile
                          $sql_extra
                        GROUP BY `resource-id`
                        ORDER BY `created` DESC
-                   LIMIT ? , ?",
+                       LIMIT ? , ?",
                        $this->owner['uid'],
                        Photo::DEFAULT,
                        $pager->getStart(),
@@ -412,6 +384,11 @@ class Photos extends \Friendica\Module\BaseProfile
                        ]);
                }
 
+               // Removing vCard for owner
+               if ($is_owner) {
+                       $this->page['aside'] = '';
+               }
+
                if (!empty($photo_albums_widget)) {
                        $this->page['aside'] .= $photo_albums_widget;
                }