]> git.mxchange.org Git - friendica.git/blobdiff - src/Module/Admin/Site.php
Disable mail setting when imap support is disabled
[friendica.git] / src / Module / Admin / Site.php
index a04b4194df4f921967c7699a4e9ae9237455dc28..36e43a6df902dc6ae9222e0cd30567a981131b4e 100644 (file)
@@ -183,8 +183,8 @@ class Site extends BaseAdmin
                $poco_discovery         = (!empty($_POST['poco_discovery'])         ? intval(trim($_POST['poco_discovery']))         : false);
                $poco_local_search      = !empty($_POST['poco_local_search']);
                $nodeinfo               = !empty($_POST['nodeinfo']);
-               $dfrn_only              = !empty($_POST['dfrn_only']);
-               $ostatus_disabled       = !empty($_POST['ostatus_disabled']);
+               $mail_enabled           = !empty($_POST['mail_enabled']);
+               $ostatus_enabled        = !empty($_POST['ostatus_enabled']);
                $diaspora_enabled       = !empty($_POST['diaspora_enabled']);
                $ssl_policy             = (!empty($_POST['ssl_policy'])             ? intval($_POST['ssl_policy'])                    : 0);
                $force_ssl              = !empty($_POST['force_ssl']);
@@ -194,13 +194,10 @@ class Site extends BaseAdmin
                $dbclean_unclaimed      = (!empty($_POST['dbclean_unclaimed'])      ? intval($_POST['dbclean_unclaimed'])             : 0);
                $dbclean_expire_conv    = (!empty($_POST['dbclean_expire_conv'])    ? intval($_POST['dbclean_expire_conv'])           : 0);
                $suppress_tags          = !empty($_POST['suppress_tags']);
-               $itemcache              = (!empty($_POST['itemcache'])              ? Strings::escapeTags(trim($_POST['itemcache']))  : '');
-               $itemcache_duration     = (!empty($_POST['itemcache_duration'])     ? intval($_POST['itemcache_duration'])            : 0);
                $max_comments           = (!empty($_POST['max_comments'])           ? intval($_POST['max_comments'])                  : 0);
                $max_display_comments   = (!empty($_POST['max_display_comments'])   ? intval($_POST['max_display_comments'])          : 0);
                $temppath               = (!empty($_POST['temppath'])               ? Strings::escapeTags(trim($_POST['temppath']))   : '');
                $singleuser             = (!empty($_POST['singleuser'])             ? Strings::escapeTags(trim($_POST['singleuser'])) : '');
-               $proxy_disabled         = !empty($_POST['proxy_disabled']);
                $only_tag_search        = !empty($_POST['only_tag_search']);
                $rino                   = (!empty($_POST['rino'])                   ? intval($_POST['rino'])                          : 0);
                $check_new_version_url  = (!empty($_POST['check_new_version_url'])  ? Strings::escapeTags(trim($_POST['check_new_version_url'])) : 'none');
@@ -215,39 +212,6 @@ class Site extends BaseAdmin
                $relay_user_tags   = !empty($_POST['relay_user_tags']);
                $active_panel      = (!empty($_POST['active_panel'])      ? "#" . Strings::escapeTags(trim($_POST['active_panel'])) : '');
 
-               $storagebackend    = Strings::escapeTags(trim($_POST['storagebackend'] ?? ''));
-
-               // save storage backend form
-               if (DI::storageManager()->setBackend($storagebackend)) {
-                       $storage_opts     = DI::storage()->getOptions();
-                       $storage_form_prefix = preg_replace('|[^a-zA-Z0-9]|', '', $storagebackend);
-                       $storage_opts_data   = [];
-                       foreach ($storage_opts as $name => $info) {
-                               $fieldname = $storage_form_prefix . '_' . $name;
-                               switch ($info[0]) { // type
-                                       case 'checkbox':
-                                       case 'yesno':
-                                               $value = !empty($_POST[$fieldname]);
-                                               break;
-                                       default:
-                                               $value = $_POST[$fieldname] ?? '';
-                               }
-                               $storage_opts_data[$name] = $value;
-                       }
-                       unset($name);
-                       unset($info);
-
-                       $storage_form_errors = DI::storage()->saveOptions($storage_opts_data);
-                       if (count($storage_form_errors)) {
-                               foreach ($storage_form_errors as $name => $err) {
-                                       notice('Storage backend, ' . $storage_opts[$name][1] . ': ' . $err);
-                               }
-                               DI::baseUrl()->redirect('admin/site' . $active_panel);
-                       }
-               } elseif (!empty($storagebackend)) {
-                       notice(DI::l10n()->t('Invalid storage backend setting value.'));
-               }
-
                // Has the directory url changed? If yes, then resubmit the existing profiles there
                if ($global_directory != DI::config()->get('system', 'directory') && ($global_directory != '')) {
                        DI::config()->set('system', 'directory', $global_directory);
@@ -376,8 +340,8 @@ class Site extends BaseAdmin
                DI::config()->set('system', 'proxyuser'              , $proxyuser);
                DI::config()->set('system', 'proxy'                  , $proxy);
                DI::config()->set('system', 'curl_timeout'           , $timeout);
-               DI::config()->set('system', 'dfrn_only'              , $dfrn_only);
-               DI::config()->set('system', 'ostatus_disabled'       , $ostatus_disabled);
+               DI::config()->set('system', 'imap_disabled'          , !$mail_enabled && function_exists('imap_open'));
+               DI::config()->set('system', 'ostatus_disabled'       , !$ostatus_enabled);
                DI::config()->set('system', 'diaspora_enabled'       , $diaspora_enabled);
 
                DI::config()->set('config', 'private_addons'         , $private_addons);
@@ -395,12 +359,6 @@ class Site extends BaseAdmin
 
                DI::config()->set('system', 'dbclean-expire-unclaimed', $dbclean_unclaimed);
 
-               if ($itemcache != '') {
-                       $itemcache = BasePath::getRealPath($itemcache);
-               }
-
-               DI::config()->set('system', 'itemcache', $itemcache);
-               DI::config()->set('system', 'itemcache_duration', $itemcache_duration);
                DI::config()->set('system', 'max_comments', $max_comments);
                DI::config()->set('system', 'max_display_comments', $max_display_comments);
 
@@ -410,7 +368,6 @@ class Site extends BaseAdmin
 
                DI::config()->set('system', 'temppath', $temppath);
 
-               DI::config()->set('system', 'proxy_disabled'   , $proxy_disabled);
                DI::config()->set('system', 'only_tag_search'  , $only_tag_search);
 
                DI::config()->set('system', 'worker_queues'    , $worker_queues);
@@ -506,7 +463,6 @@ class Site extends BaseAdmin
 
                // Automatically create temporary paths
                get_temppath();
-               get_itemcachepath();
 
                /* Register policy */
                $register_choices = [
@@ -537,40 +493,6 @@ class Site extends BaseAdmin
 
                $diaspora_able = (DI::baseUrl()->getUrlPath() == '');
 
-               $current_storage_backend = DI::storage();
-               $available_storage_backends = [];
-
-               // show legacy option only if it is the current backend:
-               // once changed can't be selected anymore
-               if ($current_storage_backend == null) {
-                       $available_storage_backends[''] = DI::l10n()->t('Database (legacy)');
-               }
-
-               foreach (DI::storageManager()->listBackends() as $name => $class) {
-                       $available_storage_backends[$name] = $name;
-               }
-
-               // build storage config form,
-               $storage_form_prefix = preg_replace('|[^a-zA-Z0-9]|' ,'', $current_storage_backend);
-
-               $storage_form = [];
-               if (!is_null($current_storage_backend) && $current_storage_backend != '') {
-                       foreach ($current_storage_backend->getOptions() as $name => $info) {
-                               $type = $info[0];
-                               // Backward compatibilty with yesno field description
-                               if ($type == 'yesno') {
-                                       $type = 'checkbox';
-                                       // Remove translated labels Yes No from field info
-                                       unset($info[4]);
-                               }
-
-                               $info[0] = $storage_form_prefix . '_' . $name;
-                               $info['type'] = $type;
-                               $info['field'] = 'field_' . $type . '.tpl';
-                               $storage_form[$name] = $info;
-                       }
-               }
-
                $t = Renderer::getMarkupTemplate('admin/site.tpl');
                return Renderer::replaceMacros($t, [
                        '$title'             => DI::l10n()->t('Administration'),
@@ -611,8 +533,6 @@ class Site extends BaseAdmin
                        '$hide_help'        => ['hide_help', DI::l10n()->t('Hide help entry from navigation menu'), DI::config()->get('system', 'hide_help'), DI::l10n()->t('Hides the menu entry for the Help pages from the navigation menu. You can still access it calling /help directly.')],
                        '$singleuser'       => ['singleuser', DI::l10n()->t('Single user instance'), DI::config()->get('system', 'singleuser', '---'), DI::l10n()->t('Make this instance multi-user or single-user for the named user'), $user_names],
 
-                       '$storagebackend'   => ['storagebackend', DI::l10n()->t('File storage backend'), $current_storage_backend, DI::l10n()->t('The backend used to store uploaded data. If you change the storage backend, you can manually move the existing files. If you do not do so, the files uploaded before the change will still be available at the old backend. Please see <a href="/help/Settings#1_2_3_1">the settings documentation</a> for more information about the choices and the moving procedure.'), $available_storage_backends],
-                       '$storageform'      => $storage_form,
                        '$maximagesize'     => ['maximagesize', DI::l10n()->t('Maximum image size'), DI::config()->get('system', 'maximagesize'), DI::l10n()->t('Maximum size in bytes of uploaded images. Default is 0, which means no limits.')],
                        '$maximagelength'   => ['maximagelength', DI::l10n()->t('Maximum image length'), DI::config()->get('system', 'max_image_length'), DI::l10n()->t('Maximum length in pixels of the longest side of uploaded images. Default is -1, which means no limits.')],
                        '$jpegimagequality' => ['jpegimagequality', DI::l10n()->t('JPEG image quality'), DI::config()->get('system', 'jpeg_quality'), DI::l10n()->t('Uploaded JPEGS will be saved at this quality setting [0-100]. Default is 100, which is full quality.')],
@@ -640,12 +560,13 @@ class Site extends BaseAdmin
                        '$no_regfullname'         => ['no_regfullname', DI::l10n()->t('No Fullname check'), DI::config()->get('system', 'no_regfullname'), DI::l10n()->t('Allow users to register without a space between the first name and the last name in their full name.')],
                        '$community_page_style'   => ['community_page_style', DI::l10n()->t('Community pages for visitors'), DI::config()->get('system', 'community_page_style'), DI::l10n()->t('Which community pages should be available for visitors. Local users always see both pages.'), $community_page_style_choices],
                        '$max_author_posts_community_page' => ['max_author_posts_community_page', DI::l10n()->t('Posts per user on community page'), DI::config()->get('system', 'max_author_posts_community_page'), DI::l10n()->t('The maximum number of posts per user on the community page. (Not valid for "Global Community")')],
-                       '$ostatus_disabled'       => ['ostatus_disabled', DI::l10n()->t('Disable OStatus support'), DI::config()->get('system', 'ostatus_disabled'), DI::l10n()->t('Disable built-in OStatus (StatusNet, GNU Social etc.) compatibility. All communications in OStatus are public, so privacy warnings will be occasionally displayed.')],
-                       '$ostatus_not_able'       => DI::l10n()->t('OStatus support can only be enabled if threading is enabled.'),
+                       '$mail_able'              => function_exists('imap_open'),
+                       '$mail_enabled'           => ['mail_enabled', DI::l10n()->t('Enable Mail support'), !DI::config()->get('system', 'imap_disabled', !function_exists('imap_open')), DI::l10n()->t('Enable built-in mail support to poll IMAP folders and to reply via mail.')],
+                       '$mail_not_able'          => DI::l10n()->t('Mail support can\'t be enabled because the PHP IMAP module is not installed.'),
+                       '$ostatus_enabled'        => ['ostatus_enabled', DI::l10n()->t('Enable OStatus support'), !DI::config()->get('system', 'ostatus_disabled'), DI::l10n()->t('Enable built-in OStatus (StatusNet, GNU Social etc.) compatibility. All communications in OStatus are public.')],
                        '$diaspora_able'          => $diaspora_able,
                        '$diaspora_not_able'      => DI::l10n()->t('Diaspora support can\'t be enabled because Friendica was installed into a sub directory.'),
-                       '$diaspora_enabled'       => ['diaspora_enabled', DI::l10n()->t('Enable Diaspora support'), DI::config()->get('system', 'diaspora_enabled', $diaspora_able), DI::l10n()->t('Provide built-in Diaspora network compatibility.')],
-                       '$dfrn_only'              => ['dfrn_only', DI::l10n()->t('Only allow Friendica contacts'), DI::config()->get('system', 'dfrn_only'), DI::l10n()->t('All contacts must use Friendica protocols. All other built-in communication protocols disabled.')],
+                       '$diaspora_enabled'       => ['diaspora_enabled', DI::l10n()->t('Enable Diaspora support'), DI::config()->get('system', 'diaspora_enabled', $diaspora_able), DI::l10n()->t('Enable built-in Diaspora network compatibility for communicating with diaspora servers.')],
                        '$verifyssl'              => ['verifyssl', DI::l10n()->t('Verify SSL'), DI::config()->get('system', 'verifyssl'), DI::l10n()->t('If you wish, you can turn on strict certificate checking. This will mean you cannot connect (at all) to self-signed SSL sites.')],
                        '$proxyuser'              => ['proxyuser', DI::l10n()->t('Proxy user'), DI::config()->get('system', 'proxyuser'), ''],
                        '$proxy'                  => ['proxy', DI::l10n()->t('Proxy URL'), DI::config()->get('system', 'proxy'), ''],
@@ -674,12 +595,9 @@ class Site extends BaseAdmin
                        '$dbclean_expire_days'    => ['dbclean_expire_days', DI::l10n()->t('Lifespan of remote items'), DI::config()->get('system', 'dbclean-expire-days'), DI::l10n()->t('When the database cleanup is enabled, this defines the days after which remote items will be deleted. Own items, and marked or filed items are always kept. 0 disables this behaviour.')],
                        '$dbclean_unclaimed'      => ['dbclean_unclaimed', DI::l10n()->t('Lifespan of unclaimed items'), DI::config()->get('system', 'dbclean-expire-unclaimed'), DI::l10n()->t('When the database cleanup is enabled, this defines the days after which unclaimed remote items (mostly content from the relay) will be deleted. Default value is 90 days. Defaults to the general lifespan value of remote items if set to 0.')],
                        '$dbclean_expire_conv'    => ['dbclean_expire_conv', DI::l10n()->t('Lifespan of raw conversation data'), DI::config()->get('system', 'dbclean_expire_conversation'), DI::l10n()->t('The conversation data is used for ActivityPub and OStatus, as well as for debug purposes. It should be safe to remove it after 14 days, default is 90 days.')],
-                       '$itemcache'              => ['itemcache', DI::l10n()->t('Path to item cache'), DI::config()->get('system', 'itemcache'), DI::l10n()->t('The item caches buffers generated bbcode and external images.')],
-                       '$itemcache_duration'     => ['itemcache_duration', DI::l10n()->t('Cache duration in seconds'), DI::config()->get('system', 'itemcache_duration'), DI::l10n()->t('How long should the cache files be hold? Default value is 86400 seconds (One day). To disable the item cache, set the value to -1.')],
                        '$max_comments'           => ['max_comments', DI::l10n()->t('Maximum numbers of comments per post'), DI::config()->get('system', 'max_comments'), DI::l10n()->t('How much comments should be shown for each post? Default value is 100.')],
                        '$max_display_comments'   => ['max_display_comments', DI::l10n()->t('Maximum numbers of comments per post on the display page'), DI::config()->get('system', 'max_display_comments'), DI::l10n()->t('How many comments should be shown on the single view for each post? Default value is 1000.')],
                        '$temppath'               => ['temppath', DI::l10n()->t('Temp path'), DI::config()->get('system', 'temppath'), DI::l10n()->t('If you have a restricted system where the webserver can\'t access the system temp path, enter another path here.')],
-                       '$proxy_disabled'         => ['proxy_disabled', DI::l10n()->t('Disable picture proxy'), DI::config()->get('system', 'proxy_disabled'), DI::l10n()->t('The picture proxy increases performance and privacy. It shouldn\'t be used on systems with very low bandwidth.')],
                        '$only_tag_search'        => ['only_tag_search', DI::l10n()->t('Only search in tags'), DI::config()->get('system', 'only_tag_search'), DI::l10n()->t('On large systems the text search can slow down the system extremely.')],
 
                        '$relocate_url'           => ['relocate_url', DI::l10n()->t('New base url'), DI::baseUrl()->get(), DI::l10n()->t('Change base url for this server. Sends relocate message to all Friendica and Diaspora* contacts of all users.')],