]> git.mxchange.org Git - friendica.git/commitdiff
Fixing .htconfig
authorPhilipp Holzer <admin@philipp.info>
Sat, 16 Mar 2019 19:31:10 +0000 (20:31 +0100)
committerPhilipp Holzer <admin@philipp.info>
Sat, 16 Mar 2019 19:31:10 +0000 (20:31 +0100)
src/Core/Config/Cache/ConfigCacheLoader.php
tests/datasets/config/.htconfig.test.php
tests/src/Core/Config/Cache/ConfigCacheLoaderTest.php

index 95d6041d46d95e8d92b991420f21ec333428ecca..8a2dc2b1e29f2ae6c4bc80dd99e60427dcbb77ba 100644 (file)
@@ -106,8 +106,27 @@ class ConfigCacheLoader
                $config = [];
 
                if (file_exists($filePath)) {
+                       $a = new \stdClass();
+                       $a->config = [];
                        include $filePath;
 
+                       $htconfigAr = array_keys($a->config);
+
+                       // map the legacy configuration structure to the current structure
+                       foreach ($htconfigAr as $htconfig) {
+                               if (isset($a->config[$htconfig]) && is_array($a->config[$htconfig])) {
+                                       $keys = array_keys($a->config[$htconfig]);
+
+                                       foreach ($keys as $key) {
+                                               $config[$htconfig][$key] = $a->config[$htconfig][$key];
+                                       }
+                               } else {
+                                       $config['config'][$htconfig] = $a->config[$htconfig];
+                               }
+                       }
+
+                       unset($a);
+
                        if (isset($db_host)) {
                                $config['database']['hostname'] = $db_host;
                                unset($db_host);
@@ -124,8 +143,8 @@ class ConfigCacheLoader
                                $config['database']['database'] = $db_data;
                                unset($db_data);
                        }
-                       if (isset($a->config['system']['db_charset'])) {
-                               $a->config['database']['charset'] = $config['system']['charset'];
+                       if (isset($config['system']['db_charset'])) {
+                               $config['database']['charset'] = $config['system']['db_charset'];
                        }
                        if (isset($pidfile)) {
                                $config['system']['pidfile'] = $pidfile;
@@ -139,22 +158,6 @@ class ConfigCacheLoader
                                $config['system']['language'] = $lang;
                                unset($lang);
                        }
-                       if (isset($admin_email)) {
-                               $config['config']['admin_email'] = $admin_email;
-                               unset($admin_email);
-                       }
-                       if (isset($admin_nickname)) {
-                               $config['config']['admin_nickname'] = $admin_nickname;
-                               unset($admin_nickname);
-                       }
-                       if (isset($php_path)) {
-                               $config['config']['php_path'] = $php_path;
-                               unset($php_path);
-                       }
-                       if (isset($max_import_size)) {
-                               $config['config']['max_import_size'] = $max_import_size;
-                               unset($max_import_size);
-                       }
                }
 
                return $config;
index 78bb6bcdae423e512cc6108581b517fa23752d52..193142c49c0f5463ee6b58b18ab185eae7e1360b 100644 (file)
@@ -8,12 +8,56 @@ $db_user = 'testuser';
 $db_pass = 'testpw';
 $db_data = 'testdb';
 
-$admin_email = 'admin@friendica.local';
-$admin_nickname = 'Friendly admin';
-
 $pidfile = '/var/run/friendica.pid';
+
+// Set the database connection charset to UTF8.
+// Changing this value will likely corrupt the special characters.
+// You have been warned.
+$a->config['system']['db_charset'] = "anotherCharset";
+
+// Choose a legal default timezone. If you are unsure, use "America/Los_Angeles".
+// It can be changed later and only applies to timestamps for anonymous viewers.
 $default_timezone = 'Europe/Berlin';
 $lang = 'fr';
 
-$php_path = '/another/php';
-$max_import_size = 999;
\ No newline at end of file
+// What is your site name?
+$a->config['sitename'] = "Friendica My Network";
+
+// Your choices are REGISTER_OPEN, REGISTER_APPROVE, or REGISTER_CLOSED.
+// Be certain to create your own personal account before setting
+// REGISTER_CLOSED. 'register_text' (if set) will be displayed prominently on
+// the registration page. REGISTER_APPROVE requires you set 'admin_email'
+// to the email address of an already registered person who can authorise
+// and/or approve/deny the request.
+// In order to perform system administration via the admin panel, admin_email
+// must precisely match the email address of the person logged in.
+$a->config['register_policy'] = REGISTER_OPEN;
+$a->config['register_text'] = 'A register text';
+$a->config['admin_email'] = 'admin@friendica.local';
+$a->config['admin_nickname'] = 'Friendly admin';
+
+// Maximum size of an imported message, 0 is unlimited
+$a->config['max_import_size'] = 999;
+
+// maximum size of uploaded photos
+$a->config['system']['maximagesize'] = 666;
+
+// Location of PHP command line processor
+$a->config['php_path'] = '/another/php';
+
+// PuSH - aka pubsubhubbub URL. This makes delivery of public posts as fast as private posts
+$a->config['system']['huburl'] = '[internal]';
+
+// allowed themes (change this from admin panel after installation)
+$a->config['system']['allowed_themes'] = 'quattro,vier,duepuntozero';
+
+// default system theme
+$a->config['system']['theme'] = 'duepuntozero';
+
+// By default allow pseudonyms
+$a->config['system']['no_regfullname'] = true;
+
+//Deny public access to the local directory
+//$a->config['system']['block_local_dir'] = false;
+// Location of the global directory
+$a->config['system']['directory'] = 'http://another.url';
index 4fd0b46509c4c3e635b32f829a6302a22bd61790..c9acdfff362d184e65a96895e147e751a6fbb698 100644 (file)
@@ -131,6 +131,7 @@ class ConfigCacheLoaderTest extends MockedTest
                $this->assertEquals('testuser', $configCache->get('database', 'username'));
                $this->assertEquals('testpw', $configCache->get('database', 'password'));
                $this->assertEquals('testdb', $configCache->get('database', 'database'));
+               $this->assertEquals('anotherCharset', $configCache->get('database', 'charset'));
 
                $this->assertEquals('/var/run/friendica.pid', $configCache->get('system', 'pidfile'));
                $this->assertEquals('Europe/Berlin', $configCache->get('system', 'default_timezone'));
@@ -141,6 +142,10 @@ class ConfigCacheLoaderTest extends MockedTest
 
                $this->assertEquals('/another/php', $configCache->get('config', 'php_path'));
                $this->assertEquals('999', $configCache->get('config', 'max_import_size'));
+               $this->assertEquals('666', $configCache->get('system', 'maximagesize'));
+
+               $this->assertEquals('quattro,vier,duepuntozero', $configCache->get('system', 'allowed_themes'));
+               $this->assertEquals('1', $configCache->get('system', 'no_regfullname'));
        }
 
        public function testLoadAddonConfig()