{"action":"created","issue":{"url":"https://api.github.com/repos/FreshRSS/FreshRSS/issues/730","labels_url":"https://api.github.com/repos/FreshRSS/FreshRSS/issues/730/labels{/name}","comments_url":"https://api.github.com/repos/FreshRSS/FreshRSS/issues/730/comments","events_url":"https://api.github.com/repos/FreshRSS/FreshRSS/issues/730/events","html_url":"https://github.com/FreshRSS/FreshRSS/issues/730","id":52294427,"number":730,"title":"Improve configuration system","user":{"login":"marienfressinaud","id":1436309,"avatar_url":"https://avatars.githubusercontent.com/u/1436309?v=3","gravatar_id":"","url":"https://api.github.com/users/marienfressinaud","html_url":"https://github.com/marienfressinaud","followers_url":"https://api.github.com/users/marienfressinaud/followers","following_url":"https://api.github.com/users/marienfressinaud/following{/other_user}","gists_url":"https://api.github.com/users/marienfressinaud/gists{/gist_id}","starred_url":"https://api.github.com/users/marienfressinaud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marienfressinaud/subscriptions","organizations_url":"https://api.github.com/users/marienfressinaud/orgs","repos_url":"https://api.github.com/users/marienfressinaud/repos","events_url":"https://api.github.com/users/marienfressinaud/events{/privacy}","received_events_url":"https://api.github.com/users/marienfressinaud/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/FreshRSS/FreshRSS/labels/Important","name":"Important","color":"ffaa99"},{"url":"https://api.github.com/repos/FreshRSS/FreshRSS/labels/Update+action","name":"Update action","color":"fef2c0"}],"state":"closed","locked":false,"assignee":{"login":"marienfressinaud","id":1436309,"avatar_url":"https://avatars.githubusercontent.com/u/1436309?v=3","gravatar_id":"","url":"https://api.github.com/users/marienfressinaud","html_url":"https://github.com/marienfressinaud","followers_url":"https://api.github.com/users/marienfressinaud/followers","following_url":"https://api.github.com/users/marienfressinaud/following{/other_user}","gists_url":"https://api.github.com/users/marienfressinaud/gists{/gist_id}","starred_url":"https://api.github.com/users/marienfressinaud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marienfressinaud/subscriptions","organizations_url":"https://api.github.com/users/marienfressinaud/orgs","repos_url":"https://api.github.com/users/marienfressinaud/repos","events_url":"https://api.github.com/users/marienfressinaud/events{/privacy}","received_events_url":"https://api.github.com/users/marienfressinaud/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/FreshRSS/FreshRSS/milestones/8","labels_url":"https://api.github.com/repos/FreshRSS/FreshRSS/milestones/8/labels","id":479690,"number":8,"title":"0.10-dev","description":"","creator":{"login":"Alkarex","id":1008324,"avatar_url":"https://avatars.githubusercontent.com/u/1008324?v=3","gravatar_id":"","url":"https://api.github.com/users/Alkarex","html_url":"https://github.com/Alkarex","followers_url":"https://api.github.com/users/Alkarex/followers","following_url":"https://api.github.com/users/Alkarex/following{/other_user}","gists_url":"https://api.github.com/users/Alkarex/gists{/gist_id}","starred_url":"https://api.github.com/users/Alkarex/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Alkarex/subscriptions","organizations_url":"https://api.github.com/users/Alkarex/orgs","repos_url":"https://api.github.com/users/Alkarex/repos","events_url":"https://api.github.com/users/Alkarex/events{/privacy}","received_events_url":"https://api.github.com/users/Alkarex/received_events","type":"User","site_admin":false},"open_issues":24,"closed_issues":15,"state":"open","created_at":"2013-11-09T19:06:46Z","updated_at":"2015-01-08T11:26:37Z","due_on":"2014-12-19T08:00:00Z","closed_at":null},"comments":18,"created_at":"2014-12-17T21:31:11Z","updated_at":"2015-01-08T19:01:02Z","closed_at":"2015-01-08T11:24:14Z","body":"**Edit (configuration system implemented):**\r\n\r\nI have finished my work on the new configuration system (I hope!). I planned to merge it tomorrow so I can continue to work on the extension system.\r\n\r\nWhen it will be available, PLEASE REMEMBER TO UPDATE YOUR CONF FILE AFTER PULLING. Instructions have been given in https://github.com/FreshRSS/FreshRSS/commit/d3a93ea2905ae50a2365d293f9f3ef3e51bf5f30\r\n\r\nHere are some explanations of the new system:\r\n\r\n- The configuration is handled by only one generic class (`Minz_Configuration`). All is documented in the `./lib/Minz/Configuration.php` file.\r\n- Current user configuration is accessible with `FreshRSS_Context::$user_conf`, system configuration with `FreshRSS_Context::$system_conf`.\r\n- If you need to create a temporary configuration for another user, please use the lib function: `get_user_conf($username)`.\r\n- If `FreshRSS_Context` is not initialized yet (so no access to generic user and system confs) you can use instead `Minz_Configuration::get('user')` and `Minz_Configuration::get('system')` to get the related configuration. You should use this `get()` method in `./lib/lib_rss.php` because we cannot know if `FreshRSS_Context` has been initialized in these functions.\r\n- You can access conf parameters directly (e.g. `$allow = $conf->allow_anonymous;` and `$conf->allow_anonymous = $allow;`).\r\n- Checks on the values are done at the setting time by the `FreshRSS_ConfigurationSetter` object (in `./app/Models/ConfigurationSetter.php`). To test a new param, only add the corresponding method. For instance, if you add in the system configuration a new parameter `timezone` and you want to test its value, add the following method:\r\n\r\n```php\r\n// If param is \"timezone\", the \"_timezone()\" method is called automatically\r\n// $data must be passed by reference.\r\nprivate function _timezone(&$data, $value) {\r\n    // It's just an example, don't do that at home!\r\n    if ($value != 'Europe/Paris') {\r\n        $value = 'Europe/Paris';\r\n    }\r\n    $data['timezone'] = $value;\r\n}\r\n```\r\n\r\nI guess it was all I have to say :).\r\n\r\n---\r\n\r\n**First message (does not correspond to the current implementation):**\r\n\r\nThis suggestion is based on #729 and on #252 \r\n\r\nWhen extensions will be available, it could be really great to give them the possibility to store their own configuration values. For now it's a bit difficult and we have two configuration systems (a global one managed by Minz and a user one managed by FRSS). I suggest to keep only one system (the Minz one) and improve it. This ticket is higly opened to discussions!\r\n\r\nI imagine a sort of namespace system which could work as following.\r\n\r\nFirst, we will need to initialize configuration system (in the FRSS FrontController). The idea is to map a namespace to a configuration file:\r\n\r\n```php\r\nMinz_Configuration::init(array(\r\n    'global.basic' => DATA_PATH . '/config.php',\r\n    'global.extension.$1' => DATA_PATH . '/config.$1.php',\r\n    'users.$1.basic' => DATA_PATH . '/users/$1/config.php',\r\n    'users.$1.extension.$2' => DATA_PATH . '/users/$1/config.$2.php',\r\n));\r\n```\r\n\r\nNext, to get the corresponding configuration. For the global configuration:\r\n\r\n```php\r\n$namespace = 'global.basic';\r\n$global_conf = Minz_Configuration::getConf($namespace);\r\n$name_default_user = $global_conf->default_user;\r\n```\r\n\r\nFor a user configuration:\r\n\r\n```php\r\n$namespace = 'users.' . $user_name . '.basic';\r\n$current_user_conf = Minz_Configuration::getConf($namespace);\r\n$default_view = $current_user_conf->default_view;\r\n```\r\n\r\nFor a system extension:\r\n\r\n```php\r\n$namespace = 'global.extension.' . $name_extension;\r\n…\r\n```\r\n\r\nFor a user extension:\r\n\r\n```php\r\n$namespace = 'users.' . $user_name . '.extension.' . $name_extension;\r\n…\r\n```\r\n\r\nThis system must be very generic so we will to forget about specifying keys one by one with their own getter and setter. Here is a very basic structure of my future `Minz_Configuration`:\r\n\r\n```php\r\nclass Minz_Configuration {\r\n    // Initialize Minz_Configuration to map namespace to a conf file\r\n    public static function init($map);\r\n    // Return an instance of Minz_Configuration for the given $namespace\r\n    public static function getConf($namespace);\r\n\r\n    // Parse the file configuration\r\n    private function parse();\r\n    // Add or modify a conf key with a given value\r\n    public function register($key, $value);\r\n    // Return the current value for the given key\r\n    public function get($key, $default=false);\r\n    // Remove a key\r\n    public function remove($key);\r\n    // Save the conf file\r\n    public function save();\r\n}\r\n```\r\n\r\nWhat do you think? Is it too complicated? Have you some ideas to improve my suggestion?"},"comment":{"url":"https://api.github.com/repos/FreshRSS/FreshRSS/issues/comments/69229899","html_url":"https://github.com/FreshRSS/FreshRSS/issues/730#issuecomment-69229899","issue_url":"https://api.github.com/repos/FreshRSS/FreshRSS/issues/730","id":69229899,"user":{"login":"Draky50110","id":1558487,"avatar_url":"https://avatars.githubusercontent.com/u/1558487?v=3","gravatar_id":"","url":"https://api.github.com/users/Draky50110","html_url":"https://github.com/Draky50110","followers_url":"https://api.github.com/users/Draky50110/followers","following_url":"https://api.github.com/users/Draky50110/following{/other_user}","gists_url":"https://api.github.com/users/Draky50110/gists{/gist_id}","starred_url":"https://api.github.com/users/Draky50110/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Draky50110/subscriptions","organizations_url":"https://api.github.com/users/Draky50110/orgs","repos_url":"https://api.github.com/users/Draky50110/repos","events_url":"https://api.github.com/users/Draky50110/events{/privacy}","received_events_url":"https://api.github.com/users/Draky50110/received_events","type":"User","site_admin":false},"created_at":"2015-01-08T19:01:02Z","updated_at":"2015-01-08T19:01:02Z","body":"By the way, what should be the correct name of the config file now ?\r\nconfig.default.php ?\r\nconfig.php ?\r\nUername.config.php ?"}}