X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fphotos.php;h=8bcd9f460cd83acf750ada2e897768002d2f26e6;hb=ae76fa1174f56e3d68473cf2a4b606838b514521;hp=2d7516be932a68cb88e530c9585831ca4c05cd37;hpb=5985563149e11c5b6c91d7ed5fcf64a1c991a82e;p=friendica.git diff --git a/mod/photos.php b/mod/photos.php index 2d7516be93..8bcd9f460c 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -284,8 +284,7 @@ function photos_post(App $a) DI::baseUrl()->redirect('photos/' . DI::args()->getArgv()[1] . '/image/' . DI::args()->getArgv()[3]); } - DI::baseUrl()->redirect('photos/' . DI::args()->getArgv()[1]); - return; // NOTREACHED + DI::baseUrl()->redirect('profile/' . DI::args()->getArgv()[1] . '/photos'); } } @@ -655,7 +654,7 @@ function photos_post(App $a) Logger::info('photos: upload: received file: ' . $filename . ' as ' . $src . ' ('. $type . ') ' . $filesize . ' bytes'); - $maximagesize = DI::config()->get('system', 'maximagesize'); + $maximagesize = Strings::getBytesFromShorthand(DI::config()->get('system', 'maximagesize')); if ($maximagesize && ($filesize > $maximagesize)) { DI::sysmsg()->addNotice(DI::l10n()->t('Image exceeds size limit of %s', Strings::formatBytes($maximagesize))); @@ -778,7 +777,6 @@ function photos_post(App $a) function photos_content(App $a) { // URLs: - // photos/name // photos/name/upload // photos/name/upload/xxxxx (xxxxx is album name) // photos/name/album/xxxxx @@ -788,7 +786,7 @@ function photos_content(App $a) // photos/name/image/xxxxx/edit // photos/name/image/xxxxx/drop - $user = User::getByNickname(DI::args()->getArgv()[1]); + $user = User::getByNickname(DI::args()->getArgv()[1] ?? ''); if (!DBA::isResult($user)) { throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.')); } @@ -867,9 +865,8 @@ function photos_content(App $a) $contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => $owner_uid, 'blocked' => false, 'pending' => false]); } - if ($user['hidewall'] && (DI::userSession()->getLocalUserId() != $owner_uid) && !$remote_contact) { - DI::sysmsg()->addNotice(DI::l10n()->t('Access to this item is restricted.')); - return; + if ($user['hidewall'] && !DI::userSession()->isAuthenticated()) { + DI::baseUrl()->redirect('profile/' . $user['nickname'] . '/restricted'); } $sql_extra = Security::getPermissionsSQLByUserId($owner_uid); @@ -878,7 +875,7 @@ function photos_content(App $a) // tabs $is_owner = (DI::userSession()->getLocalUserId() && (DI::userSession()->getLocalUserId() == $owner_uid)); - $o .= BaseProfile::getTabsHTML($a, 'photos', $is_owner, $user['nickname'], $profile['hide-friends']); + $o .= BaseProfile::getTabsHTML('photos', $is_owner, $user['nickname'], $profile['hide-friends']); // Display upload form if ($datatype === 'upload') { @@ -905,7 +902,7 @@ function photos_content(App $a) $uploader = ''; - $ret = ['post_url' => 'photos/' . $user['nickname'], + $ret = ['post_url' => 'profile/' . $user['nickname'] . '/photos', 'addon_text' => $uploader, 'default_upload' => true]; @@ -916,7 +913,20 @@ function photos_content(App $a) '$submit' => DI::l10n()->t('Submit'), ]); - $usage_message = ''; + // Get the relevant size limits for uploads. Abbreviated var names: MaxImageSize -> mis; upload_max_filesize -> umf + $mis_bytes = Strings::getBytesFromShorthand(DI::config()->get('system', 'maximagesize')); + $umf_bytes = Strings::getBytesFromShorthand(ini_get('upload_max_filesize')); + + // Per Friendica definition a value of '0' means unlimited: + If ($mis_bytes == 0) { + $mis_bytes = INF; + } + + // When PHP is configured with upload_max_filesize less than maximagesize provide this lower limit. + $maximagesize_bytes = (is_numeric($mis_bytes) && ($mis_bytes < $umf_bytes) ? $mis_bytes : $umf_bytes); + + // @todo We may be want to use appropriate binary prefixed dynamicly + $usage_message = DI::l10n()->t('The maximum accepted image size is %s', Strings::formatBytes($maximagesize_bytes)); $tpl = Renderer::getMarkupTemplate('photos_upload.tpl'); @@ -1250,15 +1260,17 @@ function photos_content(App $a) if (!empty($link_item['id'])) { // parse tags and add links $tag_arr = []; - foreach (Tag::getByURIId($link_item['uri-id']) as $tag) { - $tag_arr[] = [ - 'name' => $tag['name'], - 'removeurl' => '/tagrm/' . $link_item['id'] . '/' . bin2hex($tag['name']) - ]; + foreach (explode(',', Tag::getCSVByURIId($link_item['uri-id'])) as $tag_name) { + if ($tag_name) { + $tag_arr[] = [ + 'name' => BBCode::toPlaintext($tag_name), + 'removeurl' => 'post/' . $link_item['id'] . '/tag/remove/' . bin2hex($tag_name) . '?return=' . urlencode(DI::args()->getCommand()), + ]; + } } $tags = ['title' => DI::l10n()->t('Tags: '), 'tags' => $tag_arr]; if ($cmd === 'edit') { - $tags['removeanyurl'] = 'tagrm/' . $link_item['id']; + $tags['removeanyurl'] = 'post/' . $link_item['id'] . '/tag/remove?return=' . urlencode(DI::args()->getCommand()); $tags['removetitle'] = DI::l10n()->t('[Select tags to remove]'); } } @@ -1406,7 +1418,7 @@ function photos_content(App $a) $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) { + if (strpos($profile_url, 'contact/redir/') === 0) { $sparkle = ' sparkle'; } else { $sparkle = ''; @@ -1520,68 +1532,4 @@ function photos_content(App $a) return $o; } - - // Default - show recent photos with upload link (if applicable) - //$o = ''; - $total = 0; - $r = DBA::toArray(DBA::p("SELECT `resource-id`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = ? AND `photo-type` = ? - $sql_extra GROUP BY `resource-id`", - $user['uid'], - Photo::DEFAULT, - )); - if (DBA::isResult($r)) { - $total = count($r); - } - - $pager = new Pager(DI::l10n(), DI::args()->getQueryString(), 20); - - $r = DBA::toArray(DBA::p("SELECT `resource-id`, ANY_VALUE(`id`) AS `id`, ANY_VALUE(`filename`) AS `filename`, - ANY_VALUE(`type`) AS `type`, ANY_VALUE(`album`) AS `album`, max(`scale`) AS `scale`, - ANY_VALUE(`created`) AS `created` FROM `photo` - WHERE `uid` = ? AND `photo-type` = ? - $sql_extra GROUP BY `resource-id` ORDER BY `created` DESC LIMIT ? , ?", - $user['uid'], - Photo::DEFAULT, - $pager->getStart(), - $pager->getItemsPerPage() - )); - - $photos = []; - if (DBA::isResult($r)) { - // "Twist" is only used for the duepunto theme with style "slackr" - $twist = false; - foreach ($r as $rr) { - $twist = !$twist; - $ext = $phototypes[$rr['type']]; - - $alt_e = $rr['filename']; - $name_e = $rr['album']; - - $photos[] = [ - 'id' => $rr['id'], - 'twist' => ' ' . ($twist ? 'rotleft' : 'rotright') . rand(2,4), - 'link' => 'photos/' . $user['nickname'] . '/image/' . $rr['resource-id'], - 'title' => DI::l10n()->t('View Photo'), - 'src' => 'photo/' . $rr['resource-id'] . '-' . ((($rr['scale']) == 6) ? 4 : $rr['scale']) . '.' . $ext, - 'alt' => $alt_e, - 'album' => [ - 'link' => 'photos/' . $user['nickname'] . '/album/' . bin2hex($rr['album']), - 'name' => $name_e, - 'alt' => DI::l10n()->t('View Album'), - ], - - ]; - } - } - - $tpl = Renderer::getMarkupTemplate('photos_recent.tpl'); - $o .= Renderer::replaceMacros($tpl, [ - '$title' => DI::l10n()->t('Recent Photos'), - '$can_post' => $can_post, - '$upload' => [DI::l10n()->t('Upload New Photos'), 'photos/' . $user['nickname'] . '/upload'], - '$photos' => $photos, - '$paginate' => $pager->renderFull($total), - ]); - - return $o; }