diff options
| author | 2013-12-28 13:54:52 +0100 | |
|---|---|---|
| committer | 2013-12-28 13:54:52 +0100 | |
| commit | 9ac1496d63da32524a33696187342ce061e9ef28 (patch) | |
| tree | fc45025f1055c9a4fa2eee26240617badecef969 /lib/Minz/Configuration.php | |
| parent | 45b2decce03e218fe7ad66479491123ce398ab1f (diff) | |
Bouge anon_access dans config.php
L'accès anonyme n'est pas au niveau utilisateur mais au niveau global.
Bouge FreshRSS_Configuration::conf->anonAccess() qui était stocké dans
*_user.php vers Minz_Configuration::allowAnonymous() stocké dans
config.php
Contribue à https://github.com/marienfressinaud/FreshRSS/issues/126
+ autres optimisations
Contribue à https://github.com/marienfressinaud/FreshRSS/issues/260
Diffstat (limited to 'lib/Minz/Configuration.php')
| -rw-r--r-- | lib/Minz/Configuration.php | 58 |
1 files changed, 46 insertions, 12 deletions
diff --git a/lib/Minz/Configuration.php b/lib/Minz/Configuration.php index 1e8058dc2..fc0a4c2c1 100644 --- a/lib/Minz/Configuration.php +++ b/lib/Minz/Configuration.php @@ -52,6 +52,7 @@ class Minz_Configuration { private static $delay_cache = 3600; private static $default_user = ''; private static $current_user = ''; + private static $allow_anonymous = false; private static $db = array ( 'host' => false, @@ -99,6 +100,12 @@ class Minz_Configuration { public static function isAdmin () { return self::$current_user === self::$default_user; } + public static function allowAnonymous() { + return self::$allow_anonymous; + } + public static function _allowAnonymous($allow = false) { + self::$allow_anonymous = (bool)$allow; + } /** * Initialise les variables de configuration @@ -116,8 +123,25 @@ class Minz_Configuration { } } + public static function writeFile() { + $ini_array = array( + 'general' => array( + 'environment' => self::$environment, + 'use_url_rewriting' => self::$use_url_rewriting, + 'sel_application' => self::$sel_application, + 'base_url' => self::$base_url, + 'title' => self::$title, + 'default_user' => self::$default_user, + 'allow_anonymous' => self::$allow_anonymous, + ), + 'db' => self::$db, + ); + @rename(DATA_PATH . self::CONF_PATH_NAME, DATA_PATH . self::CONF_PATH_NAME . '.bak'); + return file_put_contents(DATA_PATH . self::CONF_PATH_NAME, "<?php\n return " . var_export($ini_array, true) . ';'); + } + /** - * Parse un fichier de configuration de type ".ini" + * Parse un fichier de configuration * @exception Minz_FileNotExistException si le CONF_PATH_NAME n'existe pas * @exception Minz_BadConfigurationException si CONF_PATH_NAME mal formaté */ @@ -158,12 +182,15 @@ class Minz_Configuration { if (isset ($general['environment'])) { switch ($general['environment']) { + case Minz_Configuration::SILENT: case 'silent': self::$environment = Minz_Configuration::SILENT; break; + case Minz_Configuration::DEVELOPMENT: case 'development': self::$environment = Minz_Configuration::DEVELOPMENT; break; + case Minz_Configuration::PRODUCTION: case 'production': self::$environment = Minz_Configuration::PRODUCTION; break; @@ -204,6 +231,9 @@ class Minz_Configuration { self::$default_user = $general['default_user']; self::$current_user = self::$default_user; } + if (isset ($general['allow_anonymous'])) { + self::$allow_anonymous = (bool)($general['allow_anonymous']); + } // Base de données $db = false; @@ -245,17 +275,21 @@ class Minz_Configuration { } } - private static function setReporting () { - if (self::environment () == self::DEVELOPMENT) { - error_reporting (E_ALL); - ini_set ('display_errors','On'); - ini_set('log_errors', 'On'); - } elseif (self::environment () == self::PRODUCTION) { - error_reporting(E_ALL); - ini_set('display_errors','Off'); - ini_set('log_errors', 'On'); - } else { - error_reporting(0); + private static function setReporting() { + switch (self::$environment) { + case self::PRODUCTION: + error_reporting(E_ALL); + ini_set('display_errors','Off'); + ini_set('log_errors', 'On'); + break; + case self::DEVELOPMENT: + error_reporting(E_ALL); + ini_set('display_errors','On'); + ini_set('log_errors', 'On'); + break; + case self::SILENT: + error_reporting(0); + break; } } } |
