From b5bee8560345e4123432a8bd3bcd63b938549ef9 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Sun, 21 Dec 2014 13:10:02 +0100 Subject: BREAKING FEATURE: move user data - Create ./data/users/ folder - Move user configuration to ./data/users/username/config.php - Move sqlite db to ./data/users/username/db.sqlite - Move user logs to ./data/users/username/log.txt See https://github.com/FreshRSS/FreshRSS/issues/729 --- app/Models/UserDAO.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'app/Models/UserDAO.php') diff --git a/app/Models/UserDAO.php b/app/Models/UserDAO.php index f04ae26bf..6514080bc 100644 --- a/app/Models/UserDAO.php +++ b/app/Models/UserDAO.php @@ -38,7 +38,7 @@ class FreshRSS_UserDAO extends Minz_ModelPdo { require_once(APP_PATH . '/SQL/install.sql.' . $db['type'] . '.php'); if ($db['type'] === 'sqlite') { - return unlink(DATA_PATH . '/' . $username . '.sqlite'); + return unlink(join_path(DATA_PATH, 'users', $username, 'db.sqlite')); } else { $userPDO = new Minz_ModelPdo($username); @@ -55,14 +55,14 @@ class FreshRSS_UserDAO extends Minz_ModelPdo { } public static function exist($username) { - return file_exists(DATA_PATH . '/' . $username . '_user.php'); + return is_dir(join_path(DATA_PATH , 'users', $username)); } public static function touch($username) { - return touch(DATA_PATH . '/' . $username . '_user.php'); + return touch(join_path(DATA_PATH , 'users', $username, 'config.php')); } public static function mtime($username) { - return @filemtime(DATA_PATH . '/' . $username . '_user.php'); + return @filemtime(join_path(DATA_PATH , 'users', $username, 'config.php')); } } -- cgit v1.2.3 From 5f9672111f86c693d843138c00934a6c3eeede45 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Tue, 6 Jan 2015 20:50:58 +0100 Subject: Fix last calls to Minz_Configuration methods - We have still to fix actualize_script and greader api (refactoring?) - We have to fix the FreshRSS_Configuration calls - We have to fix availableLanguages calls See https://github.com/FreshRSS/FreshRSS/issues/730 --- app/Controllers/authController.php | 7 +++---- app/Models/Auth.php | 14 ++++++++++++-- app/Models/EntryDAO.php | 2 +- app/Models/UserDAO.php | 4 ++-- app/layout/aside_feed.phtml | 2 +- app/layout/header.phtml | 6 +++--- app/layout/layout.phtml | 1 - app/layout/nav_menu.phtml | 2 +- app/views/auth/index.phtml | 32 ++++++++++++++++---------------- app/views/helpers/export/opml.phtml | 2 +- app/views/index/index.phtml | 2 +- app/views/user/profile.phtml | 2 +- 12 files changed, 42 insertions(+), 34 deletions(-) (limited to 'app/Models/UserDAO.php') diff --git a/app/Controllers/authController.php b/app/Controllers/authController.php index 4ae9ff7fb..02b8119e9 100644 --- a/app/Controllers/authController.php +++ b/app/Controllers/authController.php @@ -310,7 +310,7 @@ class FreshRSS_auth_Controller extends Minz_ActionController { } // TODO #730 - $conf = new FreshRSS_Configuration(Minz_Configuration::defaultUser()); + $conf = new FreshRSS_Configuration(FreshRSS_Context::$system_conf->default_user); // Admin user must have set its master password. if (!$conf->passwordHash) { $this->view->message = array( @@ -334,9 +334,8 @@ class FreshRSS_auth_Controller extends Minz_ActionController { ); if ($ok) { - // TODO #730 - Minz_Configuration::_authType('form'); - $ok = Minz_Configuration::writeFile(); + FreshRSS_Context::$system_conf->auth_type = 'form'; + $ok = FreshRSS_Context::$system_conf->save(); if ($ok) { Minz_Request::good(_t('feedback.auth.form.set')); diff --git a/app/Models/Auth.php b/app/Models/Auth.php index 05ec61d0e..917e151ca 100644 --- a/app/Models/Auth.php +++ b/app/Models/Auth.php @@ -158,7 +158,16 @@ class FreshRSS_Auth { /** * Return if authentication is enabled on this instance of FRSS. */ - public static function accessNeedLogin() { + public static function accessNeedsLogin() { + $conf = Minz_Configuration::get('system'); + $auth_type = $conf->auth_type; + return $auth_type !== 'none'; + } + + /** + * Return if authentication requires a PHP action. + */ + public static function accessNeedsAction() { $conf = Minz_Configuration::get('system'); $auth_type = $conf->auth_type; return $auth_type === 'form' || $auth_type === 'persona'; @@ -206,7 +215,8 @@ class FreshRSS_FormAuth { public static function makeCookie($username, $password_hash) { do { - $token = sha1(Minz_Configuration::salt() . $username . uniqid(mt_rand(), true)); + $conf = Minz_Configuration::get('system'); + $token = sha1($conf->salt . $username . uniqid(mt_rand(), true)); $token_file = DATA_PATH . '/tokens/' . $token . '.txt'; } while (file_exists($token_file)); diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php index 4d06ac028..61beeea13 100644 --- a/app/Models/EntryDAO.php +++ b/app/Models/EntryDAO.php @@ -586,7 +586,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo { } public function size($all = false) { - $db = Minz_Configuration::dataBase(); + $db = FreshRSS_Context::$system_conf->db; $sql = 'SELECT SUM(data_length + index_length) FROM information_schema.TABLES WHERE table_schema=?'; //MySQL $values = array($db['base']); if (!$all) { diff --git a/app/Models/UserDAO.php b/app/Models/UserDAO.php index 6514080bc..b55766ab4 100644 --- a/app/Models/UserDAO.php +++ b/app/Models/UserDAO.php @@ -2,7 +2,7 @@ class FreshRSS_UserDAO extends Minz_ModelPdo { public function createUser($username) { - $db = Minz_Configuration::dataBase(); + $db = FreshRSS_Context::$system_conf->db; require_once(APP_PATH . '/SQL/install.sql.' . $db['type'] . '.php'); $userPDO = new Minz_ModelPdo($username); @@ -34,7 +34,7 @@ class FreshRSS_UserDAO extends Minz_ModelPdo { } public function deleteUser($username) { - $db = Minz_Configuration::dataBase(); + $db = FreshRSS_Context::$system_conf->db; require_once(APP_PATH . '/SQL/install.sql.' . $db['type'] . '.php'); if ($db['type'] === 'sqlite') { diff --git a/app/layout/aside_feed.phtml b/app/layout/aside_feed.phtml index a384455b4..d2612e751 100644 --- a/app/layout/aside_feed.phtml +++ b/app/layout/aside_feed.phtml @@ -15,7 +15,7 @@ - + diff --git a/app/layout/header.phtml b/app/layout/header.phtml index 97e24a1d9..0c2e171dd 100644 --- a/app/layout/header.phtml +++ b/app/layout/header.phtml @@ -1,6 +1,6 @@ - +
diff --git a/app/layout/layout.phtml b/app/layout/layout.phtml index ed8029fe0..083ffd4b3 100644 --- a/app/layout/layout.phtml +++ b/app/layout/layout.phtml @@ -10,7 +10,6 @@ renderHelper('javascript_vars'); ?> //]]> - + allow_anonymous_refresh) { ?> diff --git a/app/views/auth/index.phtml b/app/views/auth/index.phtml index bb07cc2af..f7a862ac9 100644 --- a/app/views/auth/index.phtml +++ b/app/views/auth/index.phtml @@ -10,13 +10,13 @@
@@ -24,9 +24,9 @@
@@ -34,8 +34,8 @@
@@ -44,21 +44,21 @@
- +
token; ?>
/> + echo FreshRSS_Auth::accessNeedsAction() ? '' : ' disabled="disabled"'; ?> /> array('output' => 'rss', 'token' => $token)), 'html', true); ?>
@@ -68,8 +68,8 @@
diff --git a/app/views/helpers/export/opml.phtml b/app/views/helpers/export/opml.phtml index 8622d9144..236cca303 100644 --- a/app/views/helpers/export/opml.phtml +++ b/app/views/helpers/export/opml.phtml @@ -2,7 +2,7 @@ $opml_array = array( 'head' => array( - 'title' => Minz_Configuration::title(), + 'title' => FreshRSS_Context::$system_conf->title, 'dateCreated' => date('D, d M Y H:i:s') ), 'body' => array() diff --git a/app/views/index/index.phtml b/app/views/index/index.phtml index 8b93461dd..8b94c7f7d 100644 --- a/app/views/index/index.phtml +++ b/app/views/index/index.phtml @@ -2,7 +2,7 @@ $output = Minz_Request::param('output', 'normal'); -if (FreshRSS_Auth::hasAccess() || Minz_Configuration::allowAnonymous()) { +if (FreshRSS_Auth::hasAccess() || FreshRSS_Context::$system_conf->allow_anonymous) { if ($output === 'normal') { $this->renderHelper('view/normal_view'); } elseif ($output === 'reader') { diff --git a/app/views/user/profile.phtml b/app/views/user/profile.phtml index a3f7bf15d..d85499ad8 100644 --- a/app/views/user/profile.phtml +++ b/app/views/user/profile.phtml @@ -28,7 +28,7 @@
- + api_enabled) { ?>
-- cgit v1.2.3