]> git.mxchange.org Git - friendica.git/commitdiff
[vier] Add mute author server link in photo menu
authorHypolite Petovan <hypolite@mrpetovan.com>
Tue, 25 Jul 2023 11:18:58 +0000 (13:18 +0200)
committerHypolite Petovan <hypolite@mrpetovan.com>
Sun, 20 Aug 2023 18:27:43 +0000 (14:27 -0400)
src/Content/Item.php
src/Module/Settings/Server/Action.php
static/routes.config.php
view/templates/admin/federation.tpl
view/templates/settings/server/action.tpl [new file with mode: 0644]
view/templates/settings/server/index.tpl
view/theme/vier/style.css

index c25e5296f01e78504a0c5f4cfb28588b3fda3961..86493385f26cf76d697798e10175efdb0090107e 100644 (file)
@@ -50,6 +50,7 @@ use Friendica\Protocol\Activity;
 use Friendica\Util\ACLFormatter;
 use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Emailer;
+use Friendica\Util\Network;
 use Friendica\Util\ParseUrl;
 use Friendica\Util\Profiler;
 use Friendica\Util\Proxy;
@@ -367,7 +368,7 @@ class Item
        {
                $this->profiler->startRecording('rendering');
                $sub_link = $contact_url = $pm_url = $status_link = '';
-               $photos_link = $posts_link = $block_link = $ignore_link = '';
+               $photos_link = $posts_link = $block_link = $ignore_link = $collapse_link = $ignoreserver_link = '';
 
                if ($this->userSession->getLocalUserId() && $this->userSession->getLocalUserId() == $item['uid'] && $item['gravity'] == ItemModel::GRAVITY_PARENT && !$item['self'] && !$item['mention']) {
                        $sub_link = 'javascript:doFollowThread(' . $item['id'] . '); return false;';
@@ -407,6 +408,10 @@ class Item
                        $collapse_link = $item['self'] ? '' : $contact_url . '/collapse?t=' . $formSecurityToken;
                }
 
+               if (!empty($item['author-gsid'])) {
+                       $ignoreserver_link = Network::isLocalLink($contact_url) ? '' : 'settings/server/' . $item['author-gsid'] . '/ignore';
+               }
+
                if ($cid && !$item['self']) {
                        $contact_url = 'contact/' . $cid;
                        $posts_link  = $contact_url . '/posts';
@@ -427,7 +432,8 @@ class Item
                                $this->l10n->t('Send PM') => $pm_url,
                                $this->l10n->t('Block') => $block_link,
                                $this->l10n->t('Ignore') => $ignore_link,
-                               $this->l10n->t('Collapse') => $collapse_link
+                               $this->l10n->t('Collapse') => $collapse_link,
+                               $this->l10n->t("Ignore %s's server", $item['author-name']) => $ignoreserver_link,
                        ];
 
                        if (!empty($item['language'])) {
index 13c1cf5c742a7b586743fcc499eda4e032808415..e06cbf26be65af9b7268ce3a7bc9e6a445f945fb 100644 (file)
@@ -23,8 +23,10 @@ namespace Friendica\Module\Settings\Server;
 
 use Friendica\App;
 use Friendica\Core\L10n;
+use Friendica\Core\Renderer;
 use Friendica\Core\Session\Capability\IHandleUserSessions;
 use Friendica\Core\System;
+use Friendica\Federation\Repository\GServer;
 use Friendica\Module\Response;
 use Friendica\Network\HTTPException\BadRequestException;
 use Friendica\User\Settings\Repository\UserGServer;
@@ -37,17 +39,60 @@ class Action extends \Friendica\BaseModule
        private $session;
        /** @var UserGServer */
        private $repository;
+       /** @var GServer */
+       private $gserverRepo;
 
-       public function __construct(UserGServer $repository, IHandleUserSessions $session, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
+       public function __construct(GServer $gserverRepo, UserGServer $repository, IHandleUserSessions $session, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
        {
                parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
 
-               $this->session    = $session;
-               $this->repository = $repository;
+               $this->session     = $session;
+               $this->repository  = $repository;
+               $this->gserverRepo = $gserverRepo;
+       }
+
+       public function content(array $request = []): string
+       {
+               $GServer = $this->gserverRepo->selectOneById($this->parameters['gsid']);
+
+               switch ($this->parameters['action']) {
+                       case 'ignore':
+                               $action = $this->t('Do you want to ignore this server?');
+                               $desc   = $this->t("You won't see any content from this server including reshares in your Network page, the community pages and individual conversations.");
+                               break;
+                       case 'unignore':
+                               $action = $this->t('Do you want to unignore this server?');
+                               $desc   = '';
+                               break;
+                       default:
+                               throw new BadRequestException('Unknown user server action ' . $this->parameters['action']);
+               }
+
+               $tpl = Renderer::getMarkupTemplate('settings/server/action.tpl');
+               return Renderer::replaceMacros($tpl, [
+                       '$l10n' => [
+                               'title'    => $this->t('Remote server settings'),
+                               'action'   => $action,
+                               'siteName' => $this->t('Server Name'),
+                               'siteUrl'  => $this->t('Server URL'),
+                               'desc'     => $desc,
+                               'submit'   => $this->t('Submit'),
+                       ],
+
+                       '$action' => $this->args->getQueryString(),
+
+                       '$GServer' => $GServer,
+
+                       '$form_security_token' => self::getFormSecurityToken('settings-server'),
+               ]);
        }
 
        public function post(array $request = [])
        {
+               if (!empty($request['redirect_url'])) {
+                       self::checkFormSecurityTokenRedirectOnError($this->args->getQueryString(), 'settings-server');
+               }
+
                $userGServer = $this->repository->getOneByUserAndServer($this->session->getLocalUserId(), $this->parameters['gsid']);
 
                switch ($this->parameters['action']) {
@@ -63,6 +108,10 @@ class Action extends \Friendica\BaseModule
 
                $this->repository->save($userGServer);
 
+               if (!empty($request['redirect_url'])) {
+                       $this->baseUrl->redirect($request['redirect_url']);
+               }
+
                System::exit();
        }
 }
index f16a1936272a2639b2c1f853d6ad4eae75487f0d..36ba2f2493dfe16bc5fba5b6dcd3f56d36b1ee30 100644 (file)
@@ -641,7 +641,7 @@ return [
        '/settings' => [
                '/server' => [
                        '[/]'                  => [Module\Settings\Server\Index::class,  [R::GET, R::POST]],
-                       '/{gsid:\d+}/{action}' => [Module\Settings\Server\Action::class, [        R::POST]],
+                       '/{gsid:\d+}/{action}' => [Module\Settings\Server\Action::class, [R::GET, R::POST]],
                ],
                '[/]'         => [Module\Settings\Account::class,               [R::GET, R::POST]],
                '/account' => [
index dbee2ec3e8dbcb89b72a3d6658d64baabc2933c2..8f8d70cd2bee82984da30db5940aea108c446106 100644 (file)
@@ -57,7 +57,7 @@
                {{if $c[0]['total'] > 0}}
                <tr>
                        <th>{{$c[0]['platform']}}</th>
-                       <th><strong>{{$c[0]['total']}}</strong></td>
+                       <th><strong>{{$c[0]['total']}}</strong></th>
                        <td>{{$c[0]['network']}}</td>
                </tr>
                <tr>
diff --git a/view/templates/settings/server/action.tpl b/view/templates/settings/server/action.tpl
new file mode 100644 (file)
index 0000000..2ead14e
--- /dev/null
@@ -0,0 +1,27 @@
+<div id="settings-server" class="generic-page-wrapper">
+       <h1>{{$l10n.title}}</h1>
+
+       <form action="{{$action}}" method="POST">
+               <input type="hidden" name="form_security_token" value="{{$form_security_token}}">
+               <input type="hidden" name="redirect_url" value="settings/server">
+
+               <p>{{$l10n.action}}</p>
+
+               {{if $l10n.desc}}
+               <p>{{$l10n.desc}}</p>
+        {{/if}}
+
+               <table>
+                       <tr>
+                               <th>{{$l10n.siteName}}</th>
+                               <td>{{$GServer->siteName}}</td>
+                       </tr>
+                       <tr>
+                               <th>{{$l10n.siteUrl}}</th>
+                               <td><a href="{{$GServer->url}}">{{$GServer->url}}</a></td>
+                       </tr>
+               </table>
+
+               <p><button type="submit" class="btn btn-primary">{{$l10n.submit}}</button></p>
+       </form>
+</div>
index 112af6d07ed813ccc04d2f057c920a16b18c4051..61df4c4bc093910458027494dec12a7cf80b1d47 100644 (file)
                <table class="table table-striped table-condensed table-bordered">
                        <tr>
                                <th>{{$l10n.siteName}}</th>
-                               <th><span title="{{$l10n.ignored_title}}">{{$l10n.ignored}} <i class="fa fa-question-circle"></i></span></th>
-                               <th><span title="{{$l10n.delete_title}}"><i class="fa fa-trash"  aria-hidden="true" title="{{$l10n.delete}}"></i> <span class="sr-only">{{$l10n.delete}}</span> <i class="fa fa-question-circle"></i></span></th>
+                               <th><span title="{{$l10n.ignored_title}}">{{$l10n.ignored}} <i class="fa fa-question-circle icon-question-sign"></i></span></th>
+                               <th>
+                                       <span title="{{$l10n.delete_title}}">
+                                               <i class="fa fa-trash icon-trash" aria-hidden="true" title="{{$l10n.delete}}"></i>
+                                               <span class="sr-only">{{$l10n.delete}}</span>
+                                               <i class="fa fa-question-circle icon-question-sign"></i>
+                                       </span>
+                               </th>
                        </tr>
 
 {{foreach $servers as $index => $server}}
index ddc5fc6638d0f87ed07b128d37f32a1367617e97..b2ef72f5f5d2a0784cff86cc80a0566b9cdafbf9 100644 (file)
@@ -3281,3 +3281,7 @@ fbrowser.photo .photo-album-image-wrapper { margin-left: 10px; }
 #colorbox img {
        max-width: 100%;
 }
+
+#settings-server td + td {
+       text-align: center;
+}