A free, self-hostable news aggregator…
Bouge anon_access dans config.php
Alexandre Alapetite9ac1496d63da
diff --git a/app/Controllers/configureController.php b/app/Controllers/configureController.phpindex 487f6e4ad..dd9674588 100755--- a/app/Controllers/configureController.php+++ b/app/Controllers/configureController.php@@ -398,15 +398,13 @@ class FreshRSS_configure_Controller extends Minz_ActionController {$current_token = $this->view->conf->token();$mail = Minz_Request::param('mail_login', false);- $anon = Minz_Request::param('anon_access', 'no');$token = Minz_Request::param('token', $current_token);+$this->view->conf->_mailLogin($mail);- $this->view->conf->_anonAccess($anon);$this->view->conf->_token($token);$values = array('mail_login' => $this->view->conf->mailLogin(),- 'anon_access' => $this->view->conf->anonAccess(),'token' => $this->view->conf->token(),);@@ -415,7 +413,12 @@ class FreshRSS_configure_Controller extends Minz_ActionController {Minz_Session::_param('conf', $this->view->conf);Minz_Session::_param('mail', $this->view->conf->mailLogin());- // notif+ $anon = (bool)(Minz_Request::param('anon_access', false));+ if ($anon != Minz_Configuration::allowAnonymous()) {+ Minz_Configuration::_allowAnonymous($anon);+ Minz_Configuration::writeFile();+ }+$notif = array('type' => 'good','content' => Minz_Translate::t('configuration_updated')diff --git a/app/Controllers/indexController.php b/app/Controllers/indexController.phpindex 6c0ba9058..0c229aedb 100755--- a/app/Controllers/indexController.php+++ b/app/Controllers/indexController.php@@ -24,7 +24,7 @@ class FreshRSS_index_Controller extends Minz_ActionController {// check if user is log inif(login_is_conf ($this->view->conf) &&!is_logged() &&- $this->view->conf->anonAccess() === 'no' &&+ !Minz_Configuration::allowAnonymous() &&!($output === 'rss' && $token_is_ok)) {return;}@@ -36,8 +36,8 @@ class FreshRSS_index_Controller extends Minz_ActionController {$params['search'] = urlencode ($params['search']);}if (login_is_conf($this->view->conf) &&- $this->view->conf->anonAccess() === 'no' &&- $token != '') {+ !Minz_Configuration::allowAnonymous() &&+ $token !== '') {$params['token'] = $token;}$this->view->rss_url = array (diff --git a/app/Models/Configuration.php b/app/Models/Configuration.phpindex cb2f90655..7f4be474d 100644--- a/app/Models/Configuration.php+++ b/app/Models/Configuration.php@@ -20,7 +20,6 @@ class FreshRSS_Configuration extends Minz_Model {private $mark_when = array ();private $sharing = array ();private $theme;- private $anon_access;private $token;private $auto_load_more;private $topline_read;@@ -52,7 +51,6 @@ class FreshRSS_Configuration extends Minz_Model {$this->_sharing ($confDAO->sharing);$this->_theme ($confDAO->theme);FreshRSS_Themes::setThemeId ($confDAO->theme);- $this->_anonAccess ($confDAO->anon_access);$this->_token ($confDAO->token);$this->_autoLoadMore ($confDAO->auto_load_more);$this->_topline_read ($confDAO->topline_read);@@ -132,9 +130,6 @@ class FreshRSS_Configuration extends Minz_Model {public function theme () {return $this->theme;}- public function anonAccess () {- return $this->anon_access;- }public function token () {return $this->token;}@@ -283,13 +278,6 @@ class FreshRSS_Configuration extends Minz_Model {public function _theme ($value) {$this->theme = $value;}- public function _anonAccess ($value) {- if ($value == 'yes') {- $this->anon_access = 'yes';- } else {- $this->anon_access = 'no';- }- }public function _token ($value) {$this->token = $value;}diff --git a/app/Models/ConfigurationDAO.php b/app/Models/ConfigurationDAO.phpindex 91210e701..fa4d3338f 100644--- a/app/Models/ConfigurationDAO.php+++ b/app/Models/ConfigurationDAO.php@@ -38,7 +38,6 @@ class FreshRSS_ConfigurationDAO extends Minz_ModelArray {'print' => true);public $theme = 'default';- public $anon_access = 'no';public $token = '';public $auto_load_more = 'yes';public $topline_read = 'yes';@@ -108,9 +107,6 @@ class FreshRSS_ConfigurationDAO extends Minz_ModelArray {if (isset ($this->array['theme'])) {$this->theme = $this->array['theme'];}- if (isset ($this->array['anon_access'])) {- $this->anon_access = $this->array['anon_access'];- }if (isset ($this->array['token'])) {$this->token = $this->array['token'];}diff --git a/app/layout/header.phtml b/app/layout/header.phtmlindex bba22508e..aeb417a6e 100644--- a/app/layout/header.phtml+++ b/app/layout/header.phtml@@ -21,7 +21,7 @@<div class="item search"><?php if(!login_is_conf ($this->conf) ||is_logged() ||- $this->conf->anonAccess() == 'yes') { ?>+ Minz_Configuration::allowAnonymous()) { ?><form action="<?php echo _url ('index', 'index'); ?>" method="get"><div class="stick"><?php $search = Minz_Request::param ('search', ''); ?>diff --git a/app/views/configure/users.phtml b/app/views/configure/users.phtmlindex 40cce590e..c57671ef3 100644--- a/app/views/configure/users.phtml+++ b/app/views/configure/users.phtml@@ -50,7 +50,7 @@<div class="form-group"><div class="group-controls"><label class="checkbox" for="anon_access">- <input type="checkbox" name="anon_access" id="anon_access" value="yes"<?php echo $this->conf->anonAccess() == 'yes' ? ' checked="checked"' : ''; ?> />+ <input type="checkbox" name="anon_access" id="anon_access" value="1"<?php echo Minz_Configuration::allowAnonymous() ? ' checked="checked"' : ''; ?> /><?php echo Minz_Translate::t('allow_anonymous'); ?></label></div>diff --git a/app/views/index/index.phtml b/app/views/index/index.phtmlindex cf98060c4..2d134ba4e 100644--- a/app/views/index/index.phtml+++ b/app/views/index/index.phtml@@ -7,7 +7,7 @@ $token_is_ok = ($token != '' && $token == $token_param);if(!login_is_conf ($this->conf) ||is_logged() ||- $this->conf->anonAccess() == 'yes' ||+ Minz_Configuration::allowAnonymous() ||($output == 'rss' && $token_is_ok)) {if($output == 'rss') {$this->renderHelper ('view/rss_view');diff --git a/data/.gitignore b/data/.gitignoreindex a8091901a..1d8393f3b 100644--- a/data/.gitignore+++ b/data/.gitignore@@ -3,4 +3,5 @@ config.php*_user.php*.sqlitetouch.txt-no-cache.txt\ No newline at end of file+no-cache.txt+*.bakdiff --git a/lib/Minz/Configuration.php b/lib/Minz/Configuration.phpindex 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;}}}