Quellcode durchsuchen

Configure user defaults (#2490)

* new users inherit defaults from config-user.php

* installer creates ./data/config-user.php

* fixed typo

* .gitignore fix

* fixed style issues

* Fixed comments

* Update according to feedback

- rename file into `data/config-user.custom.php`
- make it optional (and so, don't copy it during installation)

* fixup! Update according to feedback
Joris Kinable vor 6 Jahren
Ursprung
Commit
80590daeb3
3 geänderte Dateien mit 18 neuen und 3 gelöschten Zeilen
  1. 14 3
      app/Controllers/userController.php
  2. 3 0
      config-user.default.php
  3. 1 0
      data/.gitignore

+ 14 - 3
app/Controllers/userController.php

@@ -211,9 +211,20 @@ class FreshRSS_user_Controller extends Minz_ActionController {
 		}
 	}
 
-	public static function createUser($new_user_name, $email, $passwordPlain, $apiPasswordPlain, $userConfig = array(), $insertDefaultFeeds = true) {
-		if (!is_array($userConfig)) {
-			$userConfig = array();
+	public static function createUser($new_user_name, $email, $passwordPlain, $apiPasswordPlain, $userConfigOverride = array(), $insertDefaultFeeds = true) {
+		$userConfig = array();
+
+		$customUserConfigPath = join_path(DATA_PATH, 'config-user.custom.php');
+		if (file_exists($customUserConfigPath)) {
+			$customUserConfig = include($customUserConfigPath);
+		}
+
+		if (is_array($customUserConfig)) {
+			$userConfig = $customUserConfig;
+		}
+
+		if (is_array($userConfigOverride)) {
+			$userConfig = array_merge($userConfig, $userConfigOverride);
 		}
 
 		$ok = self::checkUsername($new_user_name);

+ 3 - 0
config-user.default.php

@@ -1,5 +1,8 @@
 <?php
 
+# Do not modify this file, which defines default values, but create a
+# `./data/config-user.custom.php` file instead, containing the keys you want to
+# override.
 return array (
 	'language' => 'en',
 	'old_entries' => 3,

+ 1 - 0
data/.gitignore

@@ -1,6 +1,7 @@
 .htpasswd
 config.php
 config.php.bak.php
+config-user.custom.php
 force-https.txt
 last_update.txt
 no-cache.txt