]> git.mxchange.org Git - friendica.git/blobdiff - mod/admin.php
Merge pull request #7039 from annando/api-reshare-quote
[friendica.git] / mod / admin.php
index 0df907cbaa9718dda978bb83fa0b44829758644b..a067b516ffad4df391edc539cd7038bff96b6ca7 100644 (file)
@@ -32,6 +32,7 @@ use Friendica\Module\Tos;
 use Friendica\Protocol\PortableContact;
 use Friendica\Util\Arrays;
 use Friendica\Util\BasePath;
+use Friendica\Util\BaseURL;
 use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Network;
 use Friendica\Util\Strings;
@@ -1041,9 +1042,6 @@ function admin_page_site_post(App $a)
                update_table($a, "gcontact", ['connect', 'addr'], $old_host, $new_host);
 
                // update config
-               $configFileSaver = new \Friendica\Util\Config\ConfigFileSaver($a->getBasePath());
-               $configFileSaver->addConfigValue('config', 'hostname', parse_url($new_url, PHP_URL_HOST));
-               $configFileSaver->saveToConfigFile();
                Config::set('system', 'url', $new_url);
                $a->setBaseURL($new_url);
 
@@ -1154,40 +1152,41 @@ function admin_page_site_post(App $a)
         * @var $storagebackend \Friendica\Model\Storage\IStorage
         */
        $storagebackend    = Strings::escapeTags(trim(defaults($_POST, 'storagebackend', '')));
-       if (!StorageManager::setBackend($storagebackend)) {
-               info(L10n::t('Invalid storage backend setting value.'));
-       }
 
        // save storage backend form
        if (!is_null($storagebackend) && $storagebackend != "") {
-               $storage_opts = $storagebackend::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 = defaults($_POST, $fieldname, '');
+               if (StorageManager::setBackend($storagebackend)) {
+                       $storage_opts = $storagebackend::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 = defaults($_POST, $fieldname, '');
+                               }
+                               $storage_opts_data[$name] = $value;
                        }
-                       $storage_opts_data[$name] = $value;
-               }
-               unset($name);
-               unset($info);
-       
-               $storage_form_errors = $storagebackend::saveOptions($storage_opts_data);
-               if (count($storage_form_errors)) {
-                       foreach($storage_form_errors as $name => $err) {
-                               notice('Storage backend, ' . $storage_opts[$name][1] . ': ' . $err);
+                       unset($name);
+                       unset($info);
+
+                       $storage_form_errors = $storagebackend::saveOptions($storage_opts_data);
+                       if (count($storage_form_errors)) {
+                               foreach ($storage_form_errors as $name => $err) {
+                                       notice('Storage backend, ' . $storage_opts[$name][1] . ': ' . $err);
+                               }
+                               $a->internalRedirect('admin/site' . $active_panel);
                        }
-                       $a->internalRedirect('admin/site' . $active_panel);
+               } else {
+                       info(L10n::t('Invalid storage backend setting value.'));
                }
        }
 
-       
+
 
        // Has the directory url changed? If yes, then resubmit the existing profiles there
        if ($global_directory != Config::get('system', 'directory') && ($global_directory != '')) {
@@ -1199,7 +1198,7 @@ function admin_page_site_post(App $a)
                $diaspora_enabled = false;
        }
        if ($ssl_policy != intval(Config::get('system', 'ssl_policy'))) {
-               if ($ssl_policy == SSL_POLICY_FULL) {
+               if ($ssl_policy == BaseURL::SSL_POLICY_FULL) {
                        q("UPDATE `contact` SET
                                `url`     = REPLACE(`url`    , 'http:' , 'https:'),
                                `photo`   = REPLACE(`photo`  , 'http:' , 'https:'),
@@ -1217,7 +1216,7 @@ function admin_page_site_post(App $a)
                                `thumb`   = REPLACE(`thumb`  , 'http:' , 'https:')
                                WHERE 1 "
                        );
-               } elseif ($ssl_policy == SSL_POLICY_SELFSIGN) {
+               } elseif ($ssl_policy == BaseURL::SSL_POLICY_SELFSIGN) {
                        q("UPDATE `contact` SET
                                `url`     = REPLACE(`url`    , 'https:' , 'http:'),
                                `photo`   = REPLACE(`photo`  , 'https:' , 'http:'),
@@ -1473,9 +1472,9 @@ function admin_page_site(App $a)
        ];
 
        $ssl_choices = [
-               SSL_POLICY_NONE => L10n::t("No SSL policy, links will track page SSL state"),
-               SSL_POLICY_FULL => L10n::t("Force all links to use SSL"),
-               SSL_POLICY_SELFSIGN => L10n::t("Self-signed certificate, use SSL for local links only \x28discouraged\x29")
+               BaseURL::SSL_POLICY_NONE => L10n::t("No SSL policy, links will track page SSL state"),
+               BaseURL::SSL_POLICY_FULL => L10n::t("Force all links to use SSL"),
+               BaseURL::SSL_POLICY_SELFSIGN => L10n::t("Self-signed certificate, use SSL for local links only \x28discouraged\x29")
        ];
 
        $check_git_version_choices = [
@@ -1499,17 +1498,22 @@ function admin_page_site(App $a)
         */
        $storage_current_backend = StorageManager::getBackend();
 
-       $storage_backends_choices = [
-               '' => L10n::t('Database (legacy)')
-       ];
-       foreach($storage_backends as $name=>$class) {
+       $storage_backends_choices = [];
+
+       // show legacy option only if it is the current backend:
+       // once changed can't be selected anymore
+       if ($storage_current_backend == '') {
+               $storage_backends_choices[''] = L10n::t('Database (legacy)');
+       };
+
+       foreach ($storage_backends as $name => $class) {
                $storage_backends_choices[$class] = $name;
        }
        unset($storage_backends);
 
        // build storage config form,
        $storage_form_prefix=preg_replace('|[^a-zA-Z0-9]|' ,'', $storage_current_backend);
-       
+
        $storage_form = [];
        if (!is_null($storage_current_backend) && $storage_current_backend != "") {
                foreach ($storage_current_backend::getOptions() as $name => $info) {