]> git.mxchange.org Git - friendica.git/blobdiff - mod/photos.php
Merge pull request #8472 from annando/prevent-loop
[friendica.git] / mod / photos.php
index c2fb8256968193ea9ecd95ad20523578043ae5a7..ef957ad5b05517110fd365b5d39a5ecb9e3ff9f4 100644 (file)
@@ -1,6 +1,22 @@
 <?php
 /**
- * @file mod/photos.php
+ * @copyright Copyright (C) 2020, Friendica
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ *
  */
 
 use Friendica\App;
@@ -21,6 +37,7 @@ use Friendica\Model\Item;
 use Friendica\Model\Photo;
 use Friendica\Model\Profile;
 use Friendica\Model\User;
+use Friendica\Module\BaseProfile;
 use Friendica\Network\Probe;
 use Friendica\Object\Image;
 use Friendica\Protocol\Activity;
@@ -57,14 +74,14 @@ function photos_init(App $a) {
 
                $account_type = Contact::getAccountType($profile);
 
-               $tpl = Renderer::getMarkupTemplate("widget/vcard.tpl");
+               $tpl = Renderer::getMarkupTemplate('widget/vcard.tpl');
 
                $vcard_widget = Renderer::replaceMacros($tpl, [
                        '$name' => $profile['name'],
                        '$photo' => $profile['photo'],
                        '$addr' => $profile['addr'] ?? '',
                        '$account_type' => $account_type,
-                       '$pdesc' => $profile['pdesc'] ?? '',
+                       '$about' => BBCode::convert($profile['about'] ?? ''),
                ]);
 
                $albums = Photo::getAlbums($a->data['user']['uid']);
@@ -187,13 +204,13 @@ function photos_post(App $a)
 
                if (!DBA::isResult($r)) {
                        notice(DI::l10n()->t('Album not found.') . EOL);
-                       DI::baseUrl()->redirect($_SESSION['photo_return']);
+                       DI::baseUrl()->redirect('photos/' . $a->data['user']['nickname'] . '/album');
                        return; // NOTREACHED
                }
 
                // Check if the user has responded to a delete confirmation query
                if (!empty($_REQUEST['canceled'])) {
-                       DI::baseUrl()->redirect($_SESSION['photo_return']);
+                       DI::baseUrl()->redirect('photos/' . $a->data['user']['nickname'] . '/album/' . $a->argv[3]);
                }
 
                // RENAME photo album
@@ -250,7 +267,7 @@ function photos_post(App $a)
                        }
                }
 
-               DI::baseUrl()->redirect('photos/' . $a->argv[1]);
+               DI::baseUrl()->redirect('photos/' . $a->data['user']['nickname'] . '/album');
        }
 
        if ($a->argc > 3 && $a->argv[2] === 'image') {
@@ -914,7 +931,7 @@ function photos_content(App $a)
 
        // tabs
        $is_owner = (local_user() && (local_user() == $owner_uid));
-       $o .= Profile::getTabs($a, 'photos', $is_owner, $a->data['user']['nickname']);
+       $o .= BaseProfile::getTabsHTML($a, 'photos', $is_owner, $a->data['user']['nickname']);
 
        // Display upload form
        if ($datatype === 'upload') {
@@ -1006,7 +1023,7 @@ function photos_content(App $a)
                        $total = count($r);
                }
 
-               $pager = new Pager(DI::args()->getQueryString(), 20);
+               $pager = new Pager(DI::l10n(), DI::args()->getQueryString(), 20);
 
                /// @TODO I have seen this many times, maybe generalize it script-wide and encapsulate it?
                $order_field = $_GET['order'] ?? '';
@@ -1236,7 +1253,7 @@ function photos_content(App $a)
                        } else {
                                $tools['edit'] = ['photos/' . $a->data['user']['nickname'] . '/image/' . $datum . '/edit', DI::l10n()->t('Edit photo')];
                                $tools['delete'] = ['photos/' . $a->data['user']['nickname'] . '/image/' . $datum . '/drop', DI::l10n()->t('Delete photo')];
-                               $tools['profile'] = ['profile_photo/use/'.$ph[0]['resource-id'], DI::l10n()->t('Use as profile photo')];
+                               $tools['profile'] = ['settings/profile/photo/crop/' . $ph[0]['resource-id'], DI::l10n()->t('Use as profile photo')];
                        }
 
                        if (
@@ -1282,7 +1299,7 @@ function photos_content(App $a)
                        $condition = ["`parent` = ? AND `parent` != `id`",  $link_item['parent']];
                        $total = DBA::count('item', $condition);
 
-                       $pager = new Pager(DI::args()->getQueryString());
+                       $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);
@@ -1355,7 +1372,6 @@ function photos_content(App $a)
                $likebuttons = '';
                $comments = '';
                $paginate = '';
-               $responses = '';
 
                if (!empty($link_item['id']) && !empty($link_item['uri'])) {
                        $cmnt_tpl = Renderer::getMarkupTemplate('comment_item.tpl');
@@ -1367,7 +1383,7 @@ function photos_content(App $a)
                                $likebuttons = Renderer::replaceMacros($like_tpl, [
                                        '$id' => $link_item['id'],
                                        '$likethis' => DI::l10n()->t("I like this \x28toggle\x29"),
-                                       '$nolike' => DI::l10n()->t("I don't like this \x28toggle\x29"),
+                                       '$dislike' => DI::pConfig()->get(local_user(), 'system', 'hide_dislike') ? '' : DI::l10n()->t("I don't like this \x28toggle\x29"),
                                        '$wait' => DI::l10n()->t('Please wait'),
                                        '$return_path' => DI::args()->getQueryString(),
                                ]);
@@ -1387,6 +1403,7 @@ function photos_content(App $a)
                                                '$comment' => DI::l10n()->t('Comment'),
                                                '$submit' => DI::l10n()->t('Submit'),
                                                '$preview' => DI::l10n()->t('Preview'),
+                                               '$loading' => DI::l10n()->t('Loading...'),
                                                '$sourceapp' => DI::l10n()->t($a->sourcename),
                                                '$ww' => '',
                                                '$rand_num' => Crypto::randomDigits(12)
@@ -1395,10 +1412,17 @@ function photos_content(App $a)
                        }
 
                        $conv_responses = [
-                               'like' => ['title' => DI::l10n()->t('Likes','title')],'dislike' => ['title' => DI::l10n()->t('Dislikes','title')],
-                               'attendyes' => ['title' => DI::l10n()->t('Attending','title')], 'attendno' => ['title' => DI::l10n()->t('Not attending','title')], 'attendmaybe' => ['title' => DI::l10n()->t('Might attend','title')]
+                               'like'        => [],
+                               'dislike'     => [],
+                               'attendyes'   => [],
+                               'attendno'    => [],
+                               'attendmaybe' => []
                        ];
 
+                       if (DI::pConfig()->get(local_user(), 'system', 'hide_dislike')) {
+                               unset($conv_responses['dislike']);
+                       }
+
                        // display comments
                        if (DBA::isResult($items)) {
                                foreach ($items as $item) {
@@ -1435,7 +1459,6 @@ function photos_content(App $a)
                                foreach ($items as $item) {
                                        $comment = '';
                                        $template = $tpl;
-                                       $sparkle = '';
 
                                        $activity = DI::activity();
 
@@ -1497,9 +1520,6 @@ function photos_content(App $a)
                                        }
                                }
                        }
-                       $response_verbs = ['like'];
-                       $response_verbs[] = 'dislike';
-                       $responses = get_responses($conv_responses, $response_verbs, $link_item);
 
                        $paginate = $pager->renderFull($total);
                }
@@ -1520,7 +1540,6 @@ function photos_content(App $a)
                        '$likebuttons' => $likebuttons,
                        '$like' => $like,
                        '$dislike' => $dislike,
-                       'responses' => $responses,
                        '$comments' => $comments,
                        '$paginate' => $paginate,
                ]);
@@ -1547,7 +1566,7 @@ function photos_content(App $a)
                $total = count($r);
        }
 
-       $pager = new Pager(DI::args()->getQueryString(), 20);
+       $pager = new Pager(DI::l10n(), DI::args()->getQueryString(), 20);
 
        $r = q("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`,