]> git.mxchange.org Git - friendica.git/commitdiff
New option to disallow
authorMichael <heluecht@pirati.ca>
Sun, 7 Jan 2024 19:22:56 +0000 (19:22 +0000)
committerRoland Häder <roland@mxchange.org>
Sun, 28 Jan 2024 15:37:29 +0000 (16:37 +0100)
src/Model/Item.php
src/Module/Admin/Site.php
src/Module/Settings/Account.php
src/Module/Settings/Channels.php
static/settings.config.php
view/templates/admin/site.tpl
view/templates/settings/pagetypes.tpl
view/theme/frio/templates/admin/site.tpl

index 1b749a891082db6dfee77da8d45ad9e08d730a92..aa2d9aa7e57530f150b88b95fc936292219a469e 100644 (file)
@@ -1452,6 +1452,10 @@ class Item
 
        private static function reshareChannelPost(int $uri_id)
        {
+               if (!DI::config()->get('system', 'allow_relay_channels')) {
+                       return;
+               }
+
                $item = Post::selectFirst(['id', 'private', 'network', 'language', 'owner-id'], ['uri-id' => $uri_id, 'uid' => 0]);
                if (empty($item['id'])) {
                        return;
index acae44ddce465c034745e19691c0da25f5cda477..d4d07b25bcb2849839846d1d61849c9084ad4737 100644 (file)
@@ -92,6 +92,7 @@ class Site extends BaseAdmin
                $private_addons         = !empty($_POST['private_addons']);
                $disable_embedded       = !empty($_POST['disable_embedded']);
                $allow_users_remote_self = !empty($_POST['allow_users_remote_self']);
+               $allow_relay_channels   = !empty($_POST['allow_relay_channels']);
                $adjust_poll_frequency  = !empty($_POST['adjust_poll_frequency']);
                $min_poll_interval      = (!empty($_POST['min_poll_interval']) ? intval(trim($_POST['min_poll_interval']))                : 0);
                $explicit_content       = !empty($_POST['explicit_content']);
@@ -262,6 +263,7 @@ class Site extends BaseAdmin
                $transactionConfig->set('system', 'enotify_no_content'     , $enotify_no_content);
                $transactionConfig->set('system', 'disable_embedded'       , $disable_embedded);
                $transactionConfig->set('system', 'allow_users_remote_self', $allow_users_remote_self);
+               $transactionConfig->set('system', 'allow_relay_channels'   , $allow_relay_channels);
                $transactionConfig->set('system', 'adjust_poll_frequency'  , $adjust_poll_frequency);
                $transactionConfig->set('system', 'min_poll_interval'      , $min_poll_interval);
                $transactionConfig->set('system', 'explicit_content'       , $explicit_content);
@@ -514,6 +516,7 @@ class Site extends BaseAdmin
                        '$blocked_tags'           => ['blocked_tags', DI::l10n()->t('Blocked tags for trending tags'), DI::config()->get('system', 'blocked_tags'), DI::l10n()->t("Comma separated list of hashtags that shouldn't be displayed in the trending tags.")],
                        '$cache_contact_avatar'   => ['cache_contact_avatar', DI::l10n()->t('Cache contact avatars'), DI::config()->get('system', 'cache_contact_avatar'), DI::l10n()->t('Locally store the avatar pictures of the contacts. This uses a lot of storage space but it increases the performance.')],
                        '$allow_users_remote_self'=> ['allow_users_remote_self', DI::l10n()->t('Allow Users to set remote_self'), DI::config()->get('system', 'allow_users_remote_self'), DI::l10n()->t('With checking this, every user is allowed to mark every contact as a remote_self in the repair contact dialog. Setting this flag on a contact causes mirroring every posting of that contact in the users stream.')],
+                       '$allow_relay_channels'   => ['allow_relay_channels', DI::l10n()->t('Allow Users to set up relay channels'), DI::config()->get('system', 'allow_relay_channels'), DI::l10n()->t('If enabled, it is possible to create relay users that are used to reshare content based on user defined channels.')],
                        '$adjust_poll_frequency'  => ['adjust_poll_frequency', DI::l10n()->t('Adjust the feed poll frequency'), DI::config()->get('system', 'adjust_poll_frequency'), DI::l10n()->t('Automatically detect and set the best feed poll frequency.')],
                        '$min_poll_interval'      => ['min_poll_interval', DI::l10n()->t('Minimum poll interval'), DI::config()->get('system', 'min_poll_interval'), DI::l10n()->t('Minimal distance in minutes between two polls for mail and feed contacts. Reasonable values are between 1 and 59.')],
                        '$enable_multi_reg'       => ['enable_multi_reg', DI::l10n()->t('Enable multiple registrations'), !DI::config()->get('system', 'block_extended_register'), DI::l10n()->t('Enable users to register additional accounts for use as pages.')],
index 543762a7fdee5045f6b7fea0211dff16253338e1..8fac596a0971752005a0812b15830a65b3c844e9 100644 (file)
@@ -425,6 +425,18 @@ class Account extends BaseSettings
                        $user['account-type'] = User::ACCOUNT_TYPE_COMMUNITY;
                }
 
+               if (DI::config()->get('system', 'allow_relay_channels')) {
+                       $account_relay = [
+                               'account-type',
+                               DI::l10n()->t('Channel Relay'),
+                               User::ACCOUNT_TYPE_RELAY,
+                               DI::l10n()->t('Account for a service that automatically shares content based on user defined channels.'),
+                               $user['account-type'] == User::ACCOUNT_TYPE_RELAY
+                       ];
+               } else {
+                       $account_relay = null;
+               }
+
                $pageset_tpl = Renderer::getMarkupTemplate('settings/pagetypes.tpl');
                $pagetype    = Renderer::replaceMacros($pageset_tpl, [
                        '$account_types'     => DI::l10n()->t("Account Types"),
@@ -464,13 +476,7 @@ class Account extends BaseSettings
                                DI::l10n()->t('Account for community discussions.'),
                                $user['account-type'] == User::ACCOUNT_TYPE_COMMUNITY
                        ],
-                       '$account_relay' => [
-                               'account-type',
-                               DI::l10n()->t('Channel Relay'),
-                               User::ACCOUNT_TYPE_RELAY,
-                               DI::l10n()->t('Account for a service that automatically shares content based on user defined channels.'),
-                               $user['account-type'] == User::ACCOUNT_TYPE_RELAY
-                       ],
+                       '$account_relay' => $account_relay,
                        '$page_normal' => [
                                'page-flags',
                                DI::l10n()->t('Normal Account Page'),
index c15081d75927a135eae1050dd28a32c398a945bf..1d8e7f8133c3c9994dcb3766ca44f89825a6c955 100644 (file)
@@ -24,6 +24,7 @@ namespace Friendica\Module\Settings;
 use Friendica\App;
 use Friendica\Content\Conversation\Factory;
 use Friendica\Content\Conversation\Repository\UserDefinedChannel;
+use Friendica\Core\Config\Capability\IManageConfigValues;
 use Friendica\Core\L10n;
 use Friendica\Core\Renderer;
 use Friendica\Core\Session\Capability\IHandleUserSessions;
@@ -41,13 +42,16 @@ class Channels extends BaseSettings
        private $channel;
        /** @var Factory\UserDefinedChannel */
        private $userDefinedChannel;
+       /** @var IManageConfigValues */
+       private $config;
 
-       public function __construct(Factory\UserDefinedChannel $userDefinedChannel, UserDefinedChannel $channel, App\Page $page, IHandleUserSessions $session, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
+       public function __construct(Factory\UserDefinedChannel $userDefinedChannel, UserDefinedChannel $channel, App\Page $page, IHandleUserSessions $session, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, IManageConfigValues $config, array $server, array $parameters = [])
        {
                parent::__construct($session, $page, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
 
                $this->userDefinedChannel = $userDefinedChannel;
                $this->channel            = $channel;
+               $this->config             = $config;
        }
 
        protected function post(array $request = [])
@@ -161,7 +165,7 @@ class Channels extends BaseSettings
                                $open = false;
                        }
 
-                       if (in_array($account_type, [User::ACCOUNT_TYPE_COMMUNITY, User::ACCOUNT_TYPE_RELAY])) {
+                       if ($this->config->get('system', 'allow_relay_channels') && in_array($account_type, [User::ACCOUNT_TYPE_COMMUNITY, User::ACCOUNT_TYPE_RELAY])) {
                                $publish = ["publish[$channel->code]", $this->t("Publish"), $channel->publish, $this->t("When selected, the channel results are reshared. This only works for public ActivityPub posts from the public timeline or the user defined circles.")];
                        } else {
                                $publish = null;
index d6cf142caed78d57156023de8cc137f24ccdf295..a4cfc1b3e77590fd31545b057918a0226d9915d2 100644 (file)
@@ -56,6 +56,10 @@ return [
                // Automatically detect and set the best feed poll frequency.
                'adjust_poll_frequency' => false,
 
+               // allow_relay_channels (Boolean)
+               // Allow Users to set remote_self
+               'allow_relay_channels' => true,
+
                // allowed_themes (Comma-separated list)
                // Themes users can change to in their settings.
                'allowed_themes' => 'frio,vier',
index a0adf1b804105d02bebd75ece83642b41ea51a5a..94404b90209f9bb2e87e7a0424313c0edafc11b4 100644 (file)
@@ -84,6 +84,7 @@
                {{include file="field_checkbox.tpl" field=$private_addons}}
                {{include file="field_checkbox.tpl" field=$disable_embedded}}
                {{include file="field_checkbox.tpl" field=$allow_users_remote_self}}
+               {{include file="field_checkbox.tpl" field=$allow_relay_channels}}
                {{include file="field_checkbox.tpl" field=$adjust_poll_frequency}}
                {{include file="field_checkbox.tpl" field=$explicit_content}}
                {{include file="field_checkbox.tpl" field=$proxify_content}}
index 71285572792e47476c1833cd7f4ee867630b449d..3f6eb803d2627ceb1825e4711df6b7f5c53d6360 100644 (file)
@@ -18,7 +18,9 @@
        {{include file="field_radio.tpl" field=$page_prvgroup}}
 </div>
 
-{{include file="field_radio.tpl" field=$account_relay}}
+{{if $account_relay}}
+       {{include file="field_radio.tpl" field=$account_relay}}
+{{/if}}
 
 <script language="javascript" type="text/javascript">
        // This js part changes the state of page-flags radio buttons according
index 418eb1237b49f50727e15fb837801a1646b42536..0d3a8a311889c5ec0d56d693e3a8023c37cf261b 100644 (file)
                                                {{include file="field_checkbox.tpl" field=$private_addons}}
                                                {{include file="field_checkbox.tpl" field=$disable_embedded}}
                                                {{include file="field_checkbox.tpl" field=$allow_users_remote_self}}
+                                               {{include file="field_checkbox.tpl" field=$allow_relay_channels}}
                                                {{include file="field_checkbox.tpl" field=$adjust_poll_frequency}}
                                                {{include file="field_checkbox.tpl" field=$explicit_content}}
                                                {{include file="field_checkbox.tpl" field=$proxify_content}}