aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2015-01-06 18:53:36 +0100
committerGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2015-01-06 18:53:36 +0100
commitd3a93ea2905ae50a2365d293f9f3ef3e51bf5f30 (patch)
treefbf240e82b244fc19907529750dd8be912d97b4b
parentd27efeec04c7c41cf0f52bc7f89879e66f2e44a9 (diff)
BREAKING FEATURE: Remove general in config
General attribute has been removed from system config. Now subattributes (e.g. environment, salt, title, etc.) are directly accessible. YOU HAVE TO FIX YOUR ./data/config.php file! - Remove the general array - Values inside this array must be kept - To see what it must look like, please have a look to ./data/config.default.php (but keep your values!!). See https://github.com/FreshRSS/FreshRSS/issues/730
-rw-r--r--app/Controllers/authController.php28
-rwxr-xr-xapp/Controllers/feedController.php2
-rwxr-xr-xapp/Controllers/indexController.php6
-rwxr-xr-xapp/Controllers/javascriptController.php2
-rw-r--r--app/Controllers/userController.php4
-rw-r--r--app/FreshRSS.php2
-rw-r--r--app/Models/Auth.php14
-rw-r--r--app/Models/Feed.php4
-rw-r--r--app/layout/header.phtml6
-rw-r--r--app/layout/layout.phtml2
-rw-r--r--app/views/helpers/javascript_vars.phtml3
-rw-r--r--data/config.default.php24
-rw-r--r--lib/Minz/Error.php2
-rw-r--r--lib/Minz/FrontController.php2
-rw-r--r--lib/Minz/Log.php2
-rw-r--r--lib/Minz/Request.php2
-rw-r--r--lib/Minz/Translate.php2
-rw-r--r--lib/Minz/View.php2
18 files changed, 51 insertions, 58 deletions
diff --git a/app/Controllers/authController.php b/app/Controllers/authController.php
index 3a1ad4605..4ae9ff7fb 100644
--- a/app/Controllers/authController.php
+++ b/app/Controllers/authController.php
@@ -27,7 +27,6 @@ class FreshRSS_auth_Controller extends Minz_ActionController {
if (Minz_Request::isPost()) {
$ok = true;
- $general = FreshRSS_Context::$system_conf->general;
$current_token = FreshRSS_Context::$user_conf->token;
$token = Minz_Request::param('token', $current_token);
FreshRSS_Context::$user_conf->_token($token);
@@ -40,20 +39,19 @@ class FreshRSS_auth_Controller extends Minz_ActionController {
$auth_type = Minz_Request::param('auth_type', 'none');
$unsafe_autologin = Minz_Request::param('unsafe_autologin', false);
$api_enabled = Minz_Request::param('api_enabled', false);
- if ($anon != $general['allow_anonymous'] ||
- $auth_type != $general['auth_type'] ||
- $anon_refresh != $general['allow_anonymous_refresh'] ||
- $unsafe_autologin != $general['unsafe_autologin_enabled'] ||
- $api_enabled != $general['api_enabled']) {
+ if ($anon != FreshRSS_Context::$system_conf->allow_anonymous ||
+ $auth_type != FreshRSS_Context::$system_conf->auth_type ||
+ $anon_refresh != FreshRSS_Context::$system_conf->allow_anonymous_refresh ||
+ $unsafe_autologin != FreshRSS_Context::$system_conf->unsafe_autologin_enabled ||
+ $api_enabled != FreshRSS_Context::$system_conf->api_enabled) {
// TODO: test values from form
- $general['auth_type'] = $auth_type;
- $general['allow_anonymous'] = $anon;
- $general['allow_anonymous_refresh'] = $anon_refresh;
- $general['unsafe_autologin_enabled'] = $unsafe_autologin;
- $general['api_enabled'] = $api_enabled;
+ FreshRSS_Context::$system_conf->auth_type = $auth_type;
+ FreshRSS_Context::$system_conf->allow_anonymous = $anon;
+ FreshRSS_Context::$system_conf->allow_anonymous_refresh = $anon_refresh;
+ FreshRSS_Context::$system_conf->unsafe_autologin_enabled = $unsafe_autologin;
+ FreshRSS_Context::$system_conf->api_enabled = $api_enabled;
- $system_conf->general = $general;
$ok &= $system_conf->save();
}
@@ -80,7 +78,7 @@ class FreshRSS_auth_Controller extends Minz_ActionController {
Minz_Request::forward(array('c' => 'index', 'a' => 'index'), true);
}
- $auth_type = FreshRSS_Context::$system_conf->general['auth_type'];
+ $auth_type = FreshRSS_Context::$system_conf->auth_type;
switch ($auth_type) {
case 'form':
Minz_Request::forward(array('c' => 'auth', 'a' => 'formLogin'));
@@ -160,7 +158,7 @@ class FreshRSS_auth_Controller extends Minz_ActionController {
Minz_Request::bad(_t('feedback.auth.login.invalid'),
array('c' => 'auth', 'a' => 'login'));
}
- } elseif (FreshRSS_Context::$system_conf->general['unsafe_autologin_enabled']) {
+ } elseif (FreshRSS_Context::$system_conf->unsafe_autologin_enabled) {
$username = Minz_Request::param('u', '');
$password = Minz_Request::param('p', '');
Minz_Request::_param('p');
@@ -301,7 +299,7 @@ class FreshRSS_auth_Controller extends Minz_ActionController {
$this->view->no_form = false;
// Enable changement of auth only if Persona!
- if (FreshRSS_Context::$system_conf->general['auth_type'] != 'persona') {
+ if (FreshRSS_Context::$system_conf->auth_type != 'persona') {
$this->view->message = array(
'status' => 'bad',
'title' => _t('gen.short.damn'),
diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php
index df1e559bc..c22669361 100755
--- a/app/Controllers/feedController.php
+++ b/app/Controllers/feedController.php
@@ -18,7 +18,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
$token_param = Minz_Request::param('token', '');
$token_is_ok = ($token != '' && $token == $token_param);
$action = Minz_Request::actionName();
- $allow_anonymous_refresh = FreshRSS_Context::$system_conf->general['allow_anonymous_refresh'];
+ $allow_anonymous_refresh = FreshRSS_Context::$system_conf->allow_anonymous_refresh;
if ($action !== 'actualize' ||
!($allow_anonymous_refresh || $token_is_ok)) {
Minz_Error::error(403);
diff --git a/app/Controllers/indexController.php b/app/Controllers/indexController.php
index d948504cc..c53d3223e 100755
--- a/app/Controllers/indexController.php
+++ b/app/Controllers/indexController.php
@@ -20,7 +20,7 @@ class FreshRSS_index_Controller extends Minz_ActionController {
* This action displays the normal view of FreshRSS.
*/
public function normalAction() {
- $allow_anonymous = FreshRSS_Context::$system_conf->general['allow_anonymous'];
+ $allow_anonymous = FreshRSS_Context::$system_conf->allow_anonymous;
if (!FreshRSS_Auth::hasAccess() && !$allow_anonymous) {
Minz_Request::forward(array('c' => 'auth', 'a' => 'login'));
return;
@@ -83,7 +83,7 @@ class FreshRSS_index_Controller extends Minz_ActionController {
* This action displays the global view of FreshRSS.
*/
public function globalAction() {
- $allow_anonymous = FreshRSS_Context::$system_conf->general['allow_anonymous'];
+ $allow_anonymous = FreshRSS_Context::$system_conf->allow_anonymous;
if (!FreshRSS_Auth::hasAccess() && !$allow_anonymous) {
Minz_Request::forward(array('c' => 'auth', 'a' => 'login'));
return;
@@ -111,7 +111,7 @@ class FreshRSS_index_Controller extends Minz_ActionController {
* This action displays the RSS feed of FreshRSS.
*/
public function rssAction() {
- $allow_anonymous = FreshRSS_Context::$system_conf->general['allow_anonymous'];
+ $allow_anonymous = FreshRSS_Context::$system_conf->allow_anonymous;
$token = FreshRSS_Context::$user_conf->token;
$token_param = Minz_Request::param('token', '');
$token_is_ok = ($token != '' && $token === $token_param);
diff --git a/app/Controllers/javascriptController.php b/app/Controllers/javascriptController.php
index dd9aa6189..acd3fef69 100755
--- a/app/Controllers/javascriptController.php
+++ b/app/Controllers/javascriptController.php
@@ -28,7 +28,7 @@ class FreshRSS_javascript_Controller extends Minz_ActionController {
$user = isset($_GET['user']) ? $_GET['user'] : '';
if (ctype_alnum($user)) {
try {
- $salt = FreshRSS_Context::$system_conf->general['salt'];
+ $salt = FreshRSS_Context::$system_conf->salt;
$conf = new FreshRSS_Configuration($user);
$s = $conf->passwordHash;
if (strlen($s) >= 60) {
diff --git a/app/Controllers/userController.php b/app/Controllers/userController.php
index be2ae943e..bfc2dfb3b 100644
--- a/app/Controllers/userController.php
+++ b/app/Controllers/userController.php
@@ -118,7 +118,7 @@ class FreshRSS_user_Controller extends Minz_ActionController {
$ok = ($new_user_name != '') && ctype_alnum($new_user_name);
if ($ok) {
- $default_user = FreshRSS_Context::$system_conf->general['default_user'];
+ $default_user = FreshRSS_Context::$system_conf->default_user;
$ok &= (strcasecmp($new_user_name, $default_user) !== 0); //It is forbidden to alter the default user
$ok &= !in_array(strtoupper($new_user_name), array_map('strtoupper', listUsers())); //Not an existing user, case-insensitive
@@ -188,7 +188,7 @@ class FreshRSS_user_Controller extends Minz_ActionController {
$user_data = join_path(DATA_PATH, 'users', $username);
if ($ok) {
- $default_user = FreshRSS_Context::$system_conf->general['default_user'];
+ $default_user = FreshRSS_Context::$system_conf->default_user;
$ok &= (strcasecmp($username, $default_user) !== 0); //It is forbidden to delete the default user
}
if ($ok) {
diff --git a/app/FreshRSS.php b/app/FreshRSS.php
index b22bfdb4b..a53174394 100644
--- a/app/FreshRSS.php
+++ b/app/FreshRSS.php
@@ -62,7 +62,7 @@ class FreshRSS extends Minz_FrontController {
Minz_View::appendScript(Minz_Url::display('/scripts/shortcut.js?' . @filemtime(PUBLIC_PATH . '/scripts/shortcut.js')));
Minz_View::appendScript(Minz_Url::display('/scripts/main.js?' . @filemtime(PUBLIC_PATH . '/scripts/main.js')));
- if (FreshRSS_Context::$system_conf->general['auth_type'] === 'persona') {
+ if (FreshRSS_Context::$system_conf->auth_type === 'persona') {
// TODO move it in a plugin
// Needed for login AND logout with Persona.
Minz_View::appendScript('https://login.persona.org/include.js');
diff --git a/app/Models/Auth.php b/app/Models/Auth.php
index 84b4e3721..05ec61d0e 100644
--- a/app/Models/Auth.php
+++ b/app/Models/Auth.php
@@ -17,7 +17,7 @@ class FreshRSS_Auth {
$current_user = Minz_Session::param('currentUser', '');
if ($current_user === '') {
$conf = Minz_Configuration::get('system');
- $current_user = $conf->general['default_user'];
+ $current_user = $conf->default_user;
Minz_Session::_param('currentUser', $current_user);
}
@@ -42,7 +42,7 @@ class FreshRSS_Auth {
*/
private static function accessControl() {
$conf = Minz_Configuration::get('system');
- $auth_type = $conf->general['auth_type'];
+ $auth_type = $conf->auth_type;
switch ($auth_type) {
case 'form':
$credentials = FreshRSS_FormAuth::getCredentialsFromCookie();
@@ -84,7 +84,7 @@ class FreshRSS_Auth {
public static function giveAccess() {
$user_conf = Minz_Configuration::get('user');
$system_conf = Minz_Configuration::get('system');
- $auth_type = $system_conf->general['auth_type'];
+ $auth_type = $system_conf->auth_type;
switch ($auth_type) {
case 'form':
@@ -115,7 +115,7 @@ class FreshRSS_Auth {
*/
public static function hasAccess($scope = 'general') {
$conf = Minz_Configuration::get('system');
- $default_user = $conf->general['default_user'];
+ $default_user = $conf->default_user;
$ok = self::$login_ok;
switch ($scope) {
case 'general':
@@ -136,9 +136,9 @@ class FreshRSS_Auth {
Minz_Session::_param('loginOk');
self::$login_ok = false;
$conf = Minz_Configuration::get('system');
- Minz_Session::_param('currentUser', $conf->general['default_user']);
+ Minz_Session::_param('currentUser', $conf->default_user);
- switch ($conf->general['auth_type']) {
+ switch ($conf->auth_type) {
case 'form':
Minz_Session::_param('passwordHash');
FreshRSS_FormAuth::deleteCookie();
@@ -160,7 +160,7 @@ class FreshRSS_Auth {
*/
public static function accessNeedLogin() {
$conf = Minz_Configuration::get('system');
- $auth_type = $conf->general['auth_type'];
+ $auth_type = $conf->auth_type;
return $auth_type === 'form' || $auth_type === 'persona';
}
}
diff --git a/app/Models/Feed.php b/app/Models/Feed.php
index 071eafdf6..86cbb783e 100644
--- a/app/Models/Feed.php
+++ b/app/Models/Feed.php
@@ -39,9 +39,9 @@ class FreshRSS_Feed extends Minz_Model {
}
public function hash() {
- $conf = Minz_Configuration::get('system');
if ($this->hash === null) {
- $this->hash = hash('crc32b', $conf->general['salt'] . $this->url);
+ $salt = FreshRSS_Context::$system_conf->salt;
+ $this->hash = hash('crc32b', $salt . $this->url);
}
return $this->hash;
}
diff --git a/app/layout/header.phtml b/app/layout/header.phtml
index 2f16b5f63..97e24a1d9 100644
--- a/app/layout/header.phtml
+++ b/app/layout/header.phtml
@@ -1,7 +1,5 @@
<?php
-$conf = Minz_Configuration::get('system');
-
if (FreshRSS_Auth::accessNeedLogin()) {
?><ul class="nav nav-head nav-login"><?php
if (FreshRSS_Auth::hasAccess()) {
@@ -18,13 +16,13 @@ if (FreshRSS_Auth::accessNeedLogin()) {
<h1>
<a href="<?php echo _url('index', 'index'); ?>">
<img class="logo" src="<?php echo _i('icon', true); ?>" alt="⊚" />
- <?php echo $conf->general['title']; ?>
+ <?php echo FreshRSS_Context::$system_conf->title; ?>
</a>
</h1>
</div>
<div class="item search">
- <?php if (FreshRSS_Auth::hasAccess() || $conf->general['allow_anonymous']) { ?>
+ <?php if (FreshRSS_Auth::hasAccess() || FreshRSS_Context::$system_conf->allow_anonymous) { ?>
<form action="<?php echo _url('index', 'index'); ?>" method="get">
<div class="stick">
<?php $search = Minz_Request::param('search', ''); ?>
diff --git a/app/layout/layout.phtml b/app/layout/layout.phtml
index b3734aa56..ed8029fe0 100644
--- a/app/layout/layout.phtml
+++ b/app/layout/layout.phtml
@@ -35,7 +35,7 @@
<link rel="apple-touch-icon" href="<?php echo Minz_Url::display('/themes/icons/apple-touch-icon.png'); ?>">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
- <meta name="apple-mobile-web-app-title" content="<?php echo $conf->general['title'] ?>">
+ <meta name="apple-mobile-web-app-title" content="<?php echo FreshRSS_Context::$system_conf->title; ?>">
<meta name="msapplication-TileColor" content="#FFF" />
<meta name="robots" content="noindex,nofollow" />
</head>
diff --git a/app/views/helpers/javascript_vars.phtml b/app/views/helpers/javascript_vars.phtml
index aa73e297e..fec3a6f7c 100644
--- a/app/views/helpers/javascript_vars.phtml
+++ b/app/views/helpers/javascript_vars.phtml
@@ -1,7 +1,6 @@
"use strict";
<?php
-$conf = Minz_Configuration::get('system');
$mark = FreshRSS_Context::$user_conf->mark_when;
$mail = Minz_Session::param('mail', false);
$auto_actualize = Minz_Session::param('actualize_feeds', false);
@@ -30,7 +29,7 @@ echo 'var context={',
'does_lazyload:', FreshRSS_Context::$user_conf->lazyload ? 'true' : 'false', ',',
'sticky_post:', FreshRSS_Context::isStickyPostEnabled() ? 'true' : 'false', ',',
'html5_notif_timeout:', FreshRSS_Context::$user_conf->html5_notif_timeout, ',',
- 'auth_type:"', $conf->general['auth_type'], '",',
+ 'auth_type:"', FreshRSS_Context::$system_conf->auth_type, '",',
'current_user_mail:', $mail ? ('"' . $mail . '"') : 'null', ',',
'current_view:"', Minz_Request::param('output', 'normal'), '"',
"},\n";
diff --git a/data/config.default.php b/data/config.default.php
index a69d8050b..193ac5726 100644
--- a/data/config.default.php
+++ b/data/config.default.php
@@ -1,19 +1,17 @@
<?php
return array(
- 'general' => array(
- 'environment' => 'production',
- 'salt' => '',
- 'base_url' => '',
- 'language' => 'en',
- 'title' => 'FreshRSS',
- 'default_user' => '_',
- 'allow_anonymous' => false,
- 'allow_anonymous_refresh' => false,
- 'auth_type' => 'none',
- 'api_enabled' => false,
- 'unsafe_autologin_enabled' => false,
- ),
+ 'environment' => 'production',
+ 'salt' => '',
+ 'base_url' => '',
+ 'language' => 'en',
+ 'title' => 'FreshRSS',
+ 'default_user' => '_',
+ 'allow_anonymous' => false,
+ 'allow_anonymous_refresh' => false,
+ 'auth_type' => 'none',
+ 'api_enabled' => false,
+ 'unsafe_autologin_enabled' => false,
'limits' => array(
'cache_duration' => 800,
'timeout' => 10,
diff --git a/lib/Minz/Error.php b/lib/Minz/Error.php
index 6af23a566..3eadc6d98 100644
--- a/lib/Minz/Error.php
+++ b/lib/Minz/Error.php
@@ -83,7 +83,7 @@ class Minz_Error {
*/
private static function processLogs ($logs) {
$conf = Minz_Configuration::get('system');
- $env = $conf->general['environment'];
+ $env = $conf->environment;
$logs_ok = array ();
$error = array ();
$warning = array ();
diff --git a/lib/Minz/FrontController.php b/lib/Minz/FrontController.php
index 974cf4260..f9eff3db6 100644
--- a/lib/Minz/FrontController.php
+++ b/lib/Minz/FrontController.php
@@ -116,7 +116,7 @@ class Minz_FrontController {
private function setReporting() {
$conf = Minz_Configuration::get('system');
- switch($conf->general['environment']) {
+ switch($conf->environment) {
case 'production':
error_reporting(E_ALL);
ini_set('display_errors','Off');
diff --git a/lib/Minz/Log.php b/lib/Minz/Log.php
index 2063efe7e..2a9e10993 100644
--- a/lib/Minz/Log.php
+++ b/lib/Minz/Log.php
@@ -33,7 +33,7 @@ class Minz_Log {
public static function record ($information, $level, $file_name = null) {
try {
$conf = Minz_Configuration::get('system');
- $env = $conf->general['environment'];
+ $env = $conf->environment;
} catch (Minz_ConfigurationException $e) {
$env = 'production';
}
diff --git a/lib/Minz/Request.php b/lib/Minz/Request.php
index 5f2f6a858..6db2e9c7a 100644
--- a/lib/Minz/Request.php
+++ b/lib/Minz/Request.php
@@ -97,7 +97,7 @@ class Minz_Request {
*/
public static function getBaseUrl() {
$conf = Minz_Configuration::get('system');
- $defaultBaseUrl = $conf->general['base_url'];
+ $defaultBaseUrl = $conf->base_url;
if (!empty($defaultBaseUrl)) {
return $defaultBaseUrl;
} elseif (isset($_SERVER['REQUEST_URI'])) {
diff --git a/lib/Minz/Translate.php b/lib/Minz/Translate.php
index 7525e95cc..39200e81f 100644
--- a/lib/Minz/Translate.php
+++ b/lib/Minz/Translate.php
@@ -29,7 +29,7 @@ class Minz_Translate {
*/
public static function init() {
$conf = Minz_Configuration::get('system');
- $l = $conf->general['language'];
+ $l = $conf->language;
self::$lang_name = Minz_Session::param('language', $l);
self::$lang_path = APP_PATH . '/i18n/' . self::$lang_name . '/';
}
diff --git a/lib/Minz/View.php b/lib/Minz/View.php
index 24ad630d0..481b0376d 100644
--- a/lib/Minz/View.php
+++ b/lib/Minz/View.php
@@ -30,7 +30,7 @@ class Minz_View {
Minz_Request::actionName());
$conf = Minz_Configuration::get('system');
- self::$title = $conf->general['title'];
+ self::$title = $conf->title;
}
/**