From 79aa5beaf44af13a1828bfa5fc824a08c62054dc Mon Sep 17 00:00:00 2001
From: Marien Fressinaud
Date: Mon, 6 Oct 2014 23:29:20 +0200
Subject: Refactor authentication system.
Big work, not finished. A lot of features have been removed.
See https://github.com/marienfressinaud/FreshRSS/issues/655
---
app/Controllers/updateController.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'app/Controllers/updateController.php')
diff --git a/app/Controllers/updateController.php b/app/Controllers/updateController.php
index da5bddc65..9da1e8657 100644
--- a/app/Controllers/updateController.php
+++ b/app/Controllers/updateController.php
@@ -3,7 +3,7 @@
class FreshRSS_update_Controller extends Minz_ActionController {
public function firstAction() {
$current_user = Minz_Session::param('currentUser', '');
- if (!$this->view->loginOk && Minz_Configuration::isAdmin($current_user)) {
+ if (!FreshRSS_Auth::hasAccess() && Minz_Configuration::isAdmin($current_user)) {
Minz_Error::error(
403,
array('error' => array(_t('access_denied')))
--
cgit v1.2.3
From 6009990935a2d06c252073f6b51ea5378536ef52 Mon Sep 17 00:00:00 2001
From: Marien Fressinaud
Date: Tue, 7 Oct 2014 10:16:38 +0200
Subject: Introduce FreshRSS_Auth::hasAccess('admin')
Replace Minz_Configuration::isAdmin($user). FreshRSS_Auth::hasAccess() could
be extended to others scopes later.
See https://github.com/marienfressinaud/FreshRSS/issues/655
---
app/Controllers/configureController.php | 2 +-
app/Controllers/updateController.php | 2 +-
app/Controllers/usersController.php | 8 ++++----
app/Models/Auth.php | 19 +++++++++++++++----
app/layout/aside_configure.phtml | 5 +----
app/layout/header.phtml | 5 +----
app/views/configure/archiving.phtml | 2 +-
app/views/users/index.phtml | 6 +++---
lib/Minz/Configuration.php | 3 ---
9 files changed, 27 insertions(+), 25 deletions(-)
(limited to 'app/Controllers/updateController.php')
diff --git a/app/Controllers/configureController.php b/app/Controllers/configureController.php
index 7e77a757a..fb8c1466e 100755
--- a/app/Controllers/configureController.php
+++ b/app/Controllers/configureController.php
@@ -229,7 +229,7 @@ class FreshRSS_configure_Controller extends Minz_ActionController {
$this->view->nb_total = $entryDAO->count();
$this->view->size_user = $entryDAO->size();
- if (Minz_Configuration::isAdmin(Minz_Session::param('currentUser', '_'))) {
+ if (FreshRSS_Auth::hasAccess('admin')) {
$this->view->size_total = $entryDAO->size(true);
}
}
diff --git a/app/Controllers/updateController.php b/app/Controllers/updateController.php
index 9da1e8657..9d1e1ddf5 100644
--- a/app/Controllers/updateController.php
+++ b/app/Controllers/updateController.php
@@ -3,7 +3,7 @@
class FreshRSS_update_Controller extends Minz_ActionController {
public function firstAction() {
$current_user = Minz_Session::param('currentUser', '');
- if (!FreshRSS_Auth::hasAccess() && Minz_Configuration::isAdmin($current_user)) {
+ if (!FreshRSS_Auth::hasAccess('admin')) {
Minz_Error::error(
403,
array('error' => array(_t('access_denied')))
diff --git a/app/Controllers/usersController.php b/app/Controllers/usersController.php
index c2b1d163f..11862ce27 100644
--- a/app/Controllers/usersController.php
+++ b/app/Controllers/usersController.php
@@ -51,7 +51,7 @@ class FreshRSS_users_Controller extends Minz_ActionController {
$this->view->conf->_apiPasswordHash($passwordHash);
}
- if (Minz_Configuration::isAdmin(Minz_Session::param('currentUser', '_'))) {
+ if (FreshRSS_Auth::hasAccess('admin')) {
$this->view->conf->_mail_login(Minz_Request::param('mail_login', '', true));
}
$email = $this->view->conf->mail_login;
@@ -65,7 +65,7 @@ class FreshRSS_users_Controller extends Minz_ActionController {
$ok &= (file_put_contents($personaFile, Minz_Session::param('currentUser', '_')) !== false);
}
- if (Minz_Configuration::isAdmin(Minz_Session::param('currentUser', '_'))) {
+ if (FreshRSS_Auth::hasAccess('admin')) {
$current_token = $this->view->conf->token;
$token = Minz_Request::param('token', $current_token);
$this->view->conf->_token($token);
@@ -105,7 +105,7 @@ class FreshRSS_users_Controller extends Minz_ActionController {
}
public function createAction() {
- if (Minz_Request::isPost() && Minz_Configuration::isAdmin(Minz_Session::param('currentUser', '_'))) {
+ if (Minz_Request::isPost() && FreshRSS_Auth::hasAccess('admin')) {
$db = Minz_Configuration::dataBase();
require_once(APP_PATH . '/SQL/install.sql.' . $db['type'] . '.php');
@@ -177,7 +177,7 @@ class FreshRSS_users_Controller extends Minz_ActionController {
}
public function deleteAction() {
- if (Minz_Request::isPost() && Minz_Configuration::isAdmin(Minz_Session::param('currentUser', '_'))) {
+ if (Minz_Request::isPost() && FreshRSS_Auth::hasAccess('admin')) {
$db = Minz_Configuration::dataBase();
require_once(APP_PATH . '/SQL/install.sql.' . $db['type'] . '.php');
diff --git a/app/Models/Auth.php b/app/Models/Auth.php
index c4a3abd98..992b444a5 100644
--- a/app/Models/Auth.php
+++ b/app/Models/Auth.php
@@ -99,12 +99,23 @@ class FreshRSS_Auth {
}
/**
- * Returns if current user is connected.
+ * Returns if current user has access to the given scope.
*
- * @return boolean true if user is connected, false else.
+ * @param string $scope general (default) or admin
+ * @return boolean true if user has corresponding access, false else.
*/
- public static function hasAccess() {
- return self::$login_ok;
+ public static function hasAccess($scope = 'general') {
+ $ok = self::$login_ok;
+ switch ($scope) {
+ case 'general':
+ break;
+ case 'admin':
+ $ok &= Minz_Session::param('currentUser') === Minz_Configuration::defaultUser();
+ break;
+ default:
+ $ok = false;
+ }
+ return $ok;
}
/**
diff --git a/app/layout/aside_configure.phtml b/app/layout/aside_configure.phtml
index e17bcb254..59846a7c8 100644
--- a/app/layout/aside_configure.phtml
+++ b/app/layout/aside_configure.phtml
@@ -22,10 +22,7 @@
-
+
diff --git a/app/layout/header.phtml b/app/layout/header.phtml
index fadfd13d7..12c86d61d 100644
--- a/app/layout/header.phtml
+++ b/app/layout/header.phtml
@@ -64,10 +64,7 @@ if (Minz_Configuration::canLogIn()) {
-
+
diff --git a/app/views/configure/archiving.phtml b/app/views/configure/archiving.phtml
index a883571aa..adbfdb77e 100644
--- a/app/views/configure/archiving.phtml
+++ b/app/views/configure/archiving.phtml
@@ -67,7 +67,7 @@
-
+
-
+
diff --git a/lib/Minz/Configuration.php b/lib/Minz/Configuration.php
index 4e9da58b4..554bc8c96 100644
--- a/lib/Minz/Configuration.php
+++ b/lib/Minz/Configuration.php
@@ -100,9 +100,6 @@ class Minz_Configuration {
public static function defaultUser () {
return self::$default_user;
}
- public static function isAdmin($currentUser) {
- return $currentUser === self::$default_user;
- }
public static function allowAnonymous() {
return self::$allow_anonymous;
}
--
cgit v1.2.3
From 7080a32650ab8b19e917d8add944a75cc98381bc Mon Sep 17 00:00:00 2001
From: Marien Fressinaud
Date: Mon, 20 Oct 2014 11:54:31 +0200
Subject: Add checking installation feature
---
app/Controllers/updateController.php | 14 +++++-
app/Models/DatabaseDAO.php | 83 ++++++++++++++++++++++++++++++++++++
app/Models/DatabaseDAOSQLite.php | 48 +++++++++++++++++++++
app/Models/Factory.php | 9 ++++
app/SQL/install.sql.mysql.php | 2 -
app/SQL/install.sql.sqlite.php | 2 -
app/layout/aside_configure.phtml | 7 ++-
app/layout/header.phtml | 1 +
app/views/update/checkInstall.phtml | 30 +++++++++++++
lib/lib_rss.php | 62 +++++++++++++++++++++++++++
10 files changed, 252 insertions(+), 6 deletions(-)
create mode 100644 app/Models/DatabaseDAO.php
create mode 100644 app/Models/DatabaseDAOSQLite.php
create mode 100644 app/views/update/checkInstall.phtml
(limited to 'app/Controllers/updateController.php')
diff --git a/app/Controllers/updateController.php b/app/Controllers/updateController.php
index 9d1e1ddf5..4ebb11f51 100644
--- a/app/Controllers/updateController.php
+++ b/app/Controllers/updateController.php
@@ -12,7 +12,6 @@ class FreshRSS_update_Controller extends Minz_ActionController {
invalidateHttpCache();
- Minz_View::prependTitle(_t('update_system') . ' · ');
$this->view->update_to_apply = false;
$this->view->last_update_time = 'unknown';
$this->view->check_last_hour = false;
@@ -24,6 +23,8 @@ class FreshRSS_update_Controller extends Minz_ActionController {
}
public function indexAction() {
+ Minz_View::prependTitle(_t('update_system') . ' · ');
+
if (file_exists(UPDATE_FILENAME) && !is_writable(FRESHRSS_PATH)) {
$this->view->message = array(
'status' => 'bad',
@@ -126,4 +127,15 @@ class FreshRSS_update_Controller extends Minz_ActionController {
}
}
}
+
+ /**
+ * This action displays information about installation.
+ */
+ public function checkInstallAction() {
+ Minz_View::prependTitle(_t('gen.title.check_install') . ' · ');
+
+ $this->view->status_php = check_install_php();
+ $this->view->status_files = check_install_files();
+ $this->view->status_database = check_install_database();
+ }
}
diff --git a/app/Models/DatabaseDAO.php b/app/Models/DatabaseDAO.php
new file mode 100644
index 000000000..0d85718e3
--- /dev/null
+++ b/app/Models/DatabaseDAO.php
@@ -0,0 +1,83 @@
+bd->prepare($sql);
+ $stm->execute();
+ $res = $stm->fetchAll(PDO::FETCH_ASSOC);
+
+ $tables = array(
+ $this->prefix . 'category' => false,
+ $this->prefix . 'feed' => false,
+ $this->prefix . 'entry' => false,
+ );
+ foreach ($res as $value) {
+ $tables[array_pop($value)] = true;
+ }
+
+ return count(array_keys($tables, true, true)) == count($tables);
+ }
+
+ public function getSchema($table) {
+ $sql = 'DESC ' . $this->prefix . $table;
+ $stm = $this->bd->prepare($sql);
+ $stm->execute();
+
+ return $this->listDaoToSchema($stm->fetchAll(PDO::FETCH_ASSOC));
+ }
+
+ public function checkTable($table, $schema) {
+ $columns = $this->getSchema($table);
+
+ $ok = (count($columns) == count($schema));
+ foreach ($columns as $c) {
+ $ok &= in_array($c['name'], $schema);
+ }
+
+ return $ok;
+ }
+
+ public function categoryIsCorrect() {
+ return $this->checkTable('category', array(
+ 'id', 'name'
+ ));
+ }
+
+ public function feedIsCorrect() {
+ return $this->checkTable('feed', array(
+ 'id', 'url', 'category', 'name', 'website', 'description', 'lastUpdate',
+ 'priority', 'pathEntries', 'httpAuth', 'error', 'keep_history', 'ttl',
+ 'cache_nbEntries', 'cache_nbUnreads'
+ ));
+ }
+
+ public function entryIsCorrect() {
+ return $this->checkTable('entry', array(
+ 'id', 'guid', 'title', 'author', 'content_bin', 'link', 'date', 'is_read',
+ 'is_favorite', 'id_feed', 'tags'
+ ));
+ }
+
+ public function daoToSchema($dao) {
+ return array(
+ 'name' => $dao['Field'],
+ 'type' => strtolower($dao['Type']),
+ 'notnull' => (bool)$dao['Null'],
+ 'default' => $dao['Default'],
+ );
+ }
+
+ public function listDaoToSchema($listDAO) {
+ $list = array();
+
+ foreach ($listDAO as $dao) {
+ $list[] = $this->daoToSchema($dao);
+ }
+
+ return $list;
+ }
+}
diff --git a/app/Models/DatabaseDAOSQLite.php b/app/Models/DatabaseDAOSQLite.php
new file mode 100644
index 000000000..7f53f967d
--- /dev/null
+++ b/app/Models/DatabaseDAOSQLite.php
@@ -0,0 +1,48 @@
+bd->prepare($sql);
+ $stm->execute();
+ $res = $stm->fetchAll(PDO::FETCH_ASSOC);
+
+ $tables = array(
+ 'category' => false,
+ 'feed' => false,
+ 'entry' => false,
+ );
+ foreach ($res as $value) {
+ $tables[$value['name']] = true;
+ }
+
+ return count(array_keys($tables, true, true)) == count($tables);
+ }
+
+ public function getSchema($table) {
+ $sql = 'PRAGMA table_info(' . $table . ')';
+ $stm = $this->bd->prepare($sql);
+ $stm->execute();
+
+ return $this->listDaoToSchema($stm->fetchAll(PDO::FETCH_ASSOC));
+ }
+
+ public function entryIsCorrect() {
+ return $this->checkTable('entry', array(
+ 'id', 'guid', 'title', 'author', 'content', 'link', 'date', 'is_read',
+ 'is_favorite', 'id_feed', 'tags'
+ ));
+ }
+
+ public function daoToSchema($dao) {
+ return array(
+ 'name' => $dao['name'],
+ 'type' => strtolower($dao['type']),
+ 'notnull' => $dao['notnull'] === '1' ? true : false,
+ 'default' => $dao['dflt_value'],
+ );
+ }
+}
diff --git a/app/Models/Factory.php b/app/Models/Factory.php
index 93f4552f7..91cb84998 100644
--- a/app/Models/Factory.php
+++ b/app/Models/Factory.php
@@ -29,4 +29,13 @@ class FreshRSS_Factory {
}
}
+ public static function createDatabaseDAO($username = null) {
+ $db = Minz_Configuration::dataBase();
+ if ($db['type'] === 'sqlite') {
+ return new FreshRSS_DatabaseDAOSQLite($username);
+ } else {
+ return new FreshRSS_DatabaseDAO($username);
+ }
+ }
+
}
diff --git a/app/SQL/install.sql.mysql.php b/app/SQL/install.sql.mysql.php
index 16cb3a3b8..cf0159199 100644
--- a/app/SQL/install.sql.mysql.php
+++ b/app/SQL/install.sql.mysql.php
@@ -57,5 +57,3 @@ INSERT IGNORE INTO `%1$scategory` (id, name) VALUES(1, "%2$s");
');
define('SQL_DROP_TABLES', 'DROP TABLES %1$sentry, %1$sfeed, %1$scategory');
-
-define('SQL_SHOW_TABLES', 'SHOW tables;');
diff --git a/app/SQL/install.sql.sqlite.php b/app/SQL/install.sql.sqlite.php
index 7988ada04..30bca2810 100644
--- a/app/SQL/install.sql.sqlite.php
+++ b/app/SQL/install.sql.sqlite.php
@@ -55,5 +55,3 @@ $SQL_CREATE_TABLES = array(
);
define('SQL_DROP_TABLES', 'DROP TABLES %1$sentry, %1$sfeed, %1$scategory');
-
-define('SQL_SHOW_TABLES', 'SELECT name FROM sqlite_master WHERE type="table"');
diff --git a/app/layout/aside_configure.phtml b/app/layout/aside_configure.phtml
index 20446c877..32dc19a4e 100644
--- a/app/layout/aside_configure.phtml
+++ b/app/layout/aside_configure.phtml
@@ -31,7 +31,12 @@
-
+
+
+
+
diff --git a/app/layout/header.phtml b/app/layout/header.phtml
index e848ac4eb..506cec175 100644
--- a/app/layout/header.phtml
+++ b/app/layout/header.phtml
@@ -68,6 +68,7 @@ if (Minz_Configuration::canLogIn()) {
+
diff --git a/app/views/update/checkInstall.phtml b/app/views/update/checkInstall.phtml
new file mode 100644
index 000000000..32058714e
--- /dev/null
+++ b/app/views/update/checkInstall.phtml
@@ -0,0 +1,30 @@
+partial('aside_configure'); ?>
+
+
+
+
+
+
+ status_php as $key => $status) { ?>
+
+
+
+
+
+
+
+ status_files as $key => $status) { ?>
+
+
+
+
+
+
+
+ status_database as $key => $status) { ?>
+
+
+
+
+
+
diff --git a/lib/lib_rss.php b/lib/lib_rss.php
index 2f9a2ea45..dbed207d0 100644
--- a/lib/lib_rss.php
+++ b/lib/lib_rss.php
@@ -245,3 +245,65 @@ function is_referer_from_same_domain() {
}
return (isset($host['port']) ? $host['port'] : 0) === (isset($referer['port']) ? $referer['port'] : 0);
}
+
+
+/**
+ *
+ */
+function check_install_php() {
+ return array(
+ 'php' => version_compare(PHP_VERSION, '5.2.1') >= 0,
+ 'minz' => file_exists(LIB_PATH . '/Minz'),
+ 'curl' => extension_loaded('curl'),
+ 'pdo_mysql' => extension_loaded('pdo_mysql'),
+ 'pdo_sqlite' => extension_loaded('pdo_sqlite'),
+ 'pdo' => extension_loaded('pdo_mysql') || extension_loaded('pdo_sqlite'),
+ 'pcre' => extension_loaded('pcre'),
+ 'ctype' => extension_loaded('ctype'),
+ 'dom' => class_exists('DOMDocument'),
+ 'json' => extension_loaded('json'),
+ 'zip' => extension_loaded('zip'),
+ );
+}
+
+
+/**
+ *
+ */
+function check_install_files() {
+ return array(
+ 'data' => DATA_PATH && is_writable(DATA_PATH),
+ 'cache' => CACHE_PATH && is_writable(CACHE_PATH),
+ 'logs' => LOG_PATH && is_writable(LOG_PATH),
+ 'favicons' => is_writable(DATA_PATH . '/favicons'),
+ 'persona' => is_writable(DATA_PATH . '/persona'),
+ 'tokens' => is_writable(DATA_PATH . '/tokens'),
+ );
+}
+
+
+/**
+ *
+ */
+function check_install_database() {
+ $status = array(
+ 'connection' => true,
+ 'tables' => false,
+ 'categories' => false,
+ 'feeds' => false,
+ 'entries' => false,
+ );
+
+ try {
+ $dbDAO = FreshRSS_Factory::createDatabaseDAO();
+
+ $status['tables'] = $dbDAO->tablesAreCorrect();
+ $status['categories'] = $dbDAO->categoryIsCorrect();
+ $status['feeds'] = $dbDAO->feedIsCorrect();
+ $status['entries'] = $dbDAO->entryIsCorrect();
+ } catch(Minz_PDOConnectionException $e) {
+ $status['connection'] = false;
+ }
+
+ return $status;
+}
--
cgit v1.2.3
From 9478d2f0116be69e08071dd02c0f945c5f78d7e0 Mon Sep 17 00:00:00 2001
From: Marien Fressinaud
Date: Thu, 30 Oct 2014 12:43:52 +0100
Subject: Add do_post_update support
---
app/Controllers/updateController.php | 22 ++++++++++++++++++----
1 file changed, 18 insertions(+), 4 deletions(-)
(limited to 'app/Controllers/updateController.php')
diff --git a/app/Controllers/updateController.php b/app/Controllers/updateController.php
index 4ebb11f51..4ef5357ea 100644
--- a/app/Controllers/updateController.php
+++ b/app/Controllers/updateController.php
@@ -109,6 +109,19 @@ class FreshRSS_update_Controller extends Minz_ActionController {
require(UPDATE_FILENAME);
+ if (Minz_Request::param('post_conf', false)) {
+ $res = do_post_update();
+
+ if ($res === true) {
+ @unlink(UPDATE_FILENAME);
+ @file_put_contents(DATA_PATH . '/last_update.txt', time());
+ Minz_Request::good(_t('update_finished'));
+ } else {
+ Minz_Request::bad(_t('update_problem', $res),
+ array('c' => 'update', 'a' => 'index'));
+ }
+ }
+
if (Minz_Request::isPost()) {
save_info_update();
}
@@ -117,10 +130,11 @@ class FreshRSS_update_Controller extends Minz_ActionController {
$res = apply_update();
if ($res === true) {
- @unlink(UPDATE_FILENAME);
- @file_put_contents(DATA_PATH . '/last_update.txt', time());
-
- Minz_Request::good(_t('update_finished'));
+ Minz_Request::forward(array(
+ 'c' => 'update',
+ 'a' => 'apply',
+ 'params' => array('post_conf' => true)
+ ), true);
} else {
Minz_Request::bad(_t('update_problem', $res),
array('c' => 'update', 'a' => 'index'));
--
cgit v1.2.3
From 58deab37cdd97e93ac25aba574a32befe1db2243 Mon Sep 17 00:00:00 2001
From: Marien Fressinaud
Date: Thu, 30 Oct 2014 19:57:08 +0100
Subject: Fix Minz_Error::error() -> use default values
---
app/Controllers/authController.php | 3 +--
app/Controllers/categoryController.php | 5 +----
app/Controllers/configureController.php | 5 +----
app/Controllers/entryController.php | 5 +----
app/Controllers/feedController.php | 10 ++--------
app/Controllers/importExportController.php | 5 +----
app/Controllers/statsController.php | 29 +++++++++++++----------------
app/Controllers/subscriptionController.php | 10 ++--------
app/Controllers/updateController.php | 5 +----
app/Controllers/userController.php | 8 ++------
10 files changed, 25 insertions(+), 60 deletions(-)
(limited to 'app/Controllers/updateController.php')
diff --git a/app/Controllers/authController.php b/app/Controllers/authController.php
index 491be8d8a..44496cd3e 100644
--- a/app/Controllers/authController.php
+++ b/app/Controllers/authController.php
@@ -19,8 +19,7 @@ class FreshRSS_auth_Controller extends Minz_ActionController {
*/
public function indexAction() {
if (!FreshRSS_Auth::hasAccess('admin')) {
- Minz_Error::error(403,
- array('error' => array(_t('access_denied'))));
+ Minz_Error::error(403);
}
Minz_View::prependTitle(_t('gen.title.authentication') . ' · ');
diff --git a/app/Controllers/categoryController.php b/app/Controllers/categoryController.php
index 609284559..50b1d841a 100644
--- a/app/Controllers/categoryController.php
+++ b/app/Controllers/categoryController.php
@@ -13,10 +13,7 @@ class FreshRSS_category_Controller extends Minz_ActionController {
*/
public function firstAction() {
if (!FreshRSS_Auth::hasAccess()) {
- Minz_Error::error(
- 403,
- array('error' => array(_t('access_denied')))
- );
+ Minz_Error::error(403);
}
$catDAO = new FreshRSS_CategoryDAO();
diff --git a/app/Controllers/configureController.php b/app/Controllers/configureController.php
index deb8cc849..1c8ac9111 100755
--- a/app/Controllers/configureController.php
+++ b/app/Controllers/configureController.php
@@ -11,10 +11,7 @@ class FreshRSS_configure_Controller extends Minz_ActionController {
*/
public function firstAction() {
if (!FreshRSS_Auth::hasAccess()) {
- Minz_Error::error(
- 403,
- array('error' => array(_t('access_denied')))
- );
+ Minz_Error::error(403);
}
}
diff --git a/app/Controllers/entryController.php b/app/Controllers/entryController.php
index d11f3a520..b4beed619 100755
--- a/app/Controllers/entryController.php
+++ b/app/Controllers/entryController.php
@@ -11,10 +11,7 @@ class FreshRSS_entry_Controller extends Minz_ActionController {
*/
public function firstAction() {
if (!FreshRSS_Auth::hasAccess()) {
- Minz_Error::error(
- 403,
- array('error' => array(_t('access_denied')))
- );
+ Minz_Error::error(403);
}
// If ajax request, we do not print layout
diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php
index 8563b1c0f..9990a852c 100755
--- a/app/Controllers/feedController.php
+++ b/app/Controllers/feedController.php
@@ -20,10 +20,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
$action = Minz_Request::actionName();
if ($action !== 'actualize' ||
!(Minz_Configuration::allowAnonymousRefresh() || $token_is_ok)) {
- Minz_Error::error(
- 403,
- array('error' => array(_t('access_denied')))
- );
+ Minz_Error::error(403);
}
}
}
@@ -442,10 +439,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
} else {
Minz_Log::warning('Cannot move feed `' . $feed_id . '` ' .
'in the category `' . $cat_id . '`');
- Minz_Error::error(
- 404,
- array('error' => array(_t('error_occurred')))
- );
+ Minz_Error::error(404);
}
}
diff --git a/app/Controllers/importExportController.php b/app/Controllers/importExportController.php
index 8028af8ed..4e2dbd157 100644
--- a/app/Controllers/importExportController.php
+++ b/app/Controllers/importExportController.php
@@ -11,10 +11,7 @@ class FreshRSS_importExport_Controller extends Minz_ActionController {
*/
public function firstAction() {
if (!FreshRSS_Auth::hasAccess()) {
- Minz_Error::error(
- 403,
- array('error' => array(_t('access_denied')))
- );
+ Minz_Error::error(403);
}
require_once(LIB_PATH . '/lib_opml.php');
diff --git a/app/Controllers/statsController.php b/app/Controllers/statsController.php
index 0e3430fcc..18fbca6df 100644
--- a/app/Controllers/statsController.php
+++ b/app/Controllers/statsController.php
@@ -5,6 +5,19 @@
*/
class FreshRSS_stats_Controller extends Minz_ActionController {
+ /**
+ * This action is called before every other action in that class. It is
+ * the common boiler plate for every action. It is triggered by the
+ * underlying framework.
+ */
+ public function firstAction() {
+ if (!FreshRSS_Auth::hasAccess()) {
+ Minz_Error::error(403);
+ }
+
+ Minz_View::prependTitle(_t('stats') . ' · ');
+ }
+
/**
* This action handles the statistic main page.
*
@@ -111,20 +124,4 @@ class FreshRSS_stats_Controller extends Minz_ActionController {
$this->view->repartitionMonth = $statsDAO->calculateEntryRepartitionPerFeedPerMonth($id);
$this->view->averageMonth = $statsDAO->calculateEntryAveragePerFeedPerMonth($id);
}
-
- /**
- * This action is called before every other action in that class. It is
- * the common boiler plate for every action. It is triggered by the
- * underlying framework.
- */
- public function firstAction() {
- if (!FreshRSS_Auth::hasAccess()) {
- Minz_Error::error(
- 403, array('error' => array(_t('access_denied')))
- );
- }
-
- Minz_View::prependTitle(_t('stats') . ' · ');
- }
-
}
diff --git a/app/Controllers/subscriptionController.php b/app/Controllers/subscriptionController.php
index a89168eb3..67b95eba6 100644
--- a/app/Controllers/subscriptionController.php
+++ b/app/Controllers/subscriptionController.php
@@ -11,10 +11,7 @@ class FreshRSS_subscription_Controller extends Minz_ActionController {
*/
public function firstAction() {
if (!FreshRSS_Auth::hasAccess()) {
- Minz_Error::error(
- 403,
- array('error' => array(_t('access_denied')))
- );
+ Minz_Error::error(403);
}
$catDAO = new FreshRSS_CategoryDAO();
@@ -71,10 +68,7 @@ class FreshRSS_subscription_Controller extends Minz_ActionController {
$id = Minz_Request::param('id');
if ($id === false || !isset($this->view->feeds[$id])) {
- Minz_Error::error(
- 404,
- array('error' => array(_t('page_not_found')))
- );
+ Minz_Error::error(404);
return;
}
diff --git a/app/Controllers/updateController.php b/app/Controllers/updateController.php
index 4ef5357ea..0896b13ac 100644
--- a/app/Controllers/updateController.php
+++ b/app/Controllers/updateController.php
@@ -4,10 +4,7 @@ class FreshRSS_update_Controller extends Minz_ActionController {
public function firstAction() {
$current_user = Minz_Session::param('currentUser', '');
if (!FreshRSS_Auth::hasAccess('admin')) {
- Minz_Error::error(
- 403,
- array('error' => array(_t('access_denied')))
- );
+ Minz_Error::error(403);
}
invalidateHttpCache();
diff --git a/app/Controllers/userController.php b/app/Controllers/userController.php
index 39db1d879..5050571a9 100644
--- a/app/Controllers/userController.php
+++ b/app/Controllers/userController.php
@@ -15,10 +15,7 @@ class FreshRSS_user_Controller extends Minz_ActionController {
*/
public function firstAction() {
if (!FreshRSS_Auth::hasAccess()) {
- Minz_Error::error(
- 403,
- array('error' => array(_t('access_denied')))
- );
+ Minz_Error::error(403);
}
}
@@ -88,8 +85,7 @@ class FreshRSS_user_Controller extends Minz_ActionController {
*/
public function manageAction() {
if (!FreshRSS_Auth::hasAccess('admin')) {
- Minz_Error::error(403,
- array('error' => array(_t('access_denied'))));
+ Minz_Error::error(403);
}
Minz_View::prependTitle(_t('gen.title.user_management') . ' · ');
--
cgit v1.2.3
From 59fc73baa9cbd87fdc2d63e83533a36533c740bf Mon Sep 17 00:00:00 2001
From: Marien Fressinaud
Date: Thu, 11 Dec 2014 19:32:59 +0100
Subject: Fix i18n for update and user controllers
---
app/Controllers/updateController.php | 30 +++++++++++++++---------------
app/Controllers/userController.php | 12 ++++++------
app/i18n/en/admin.php | 5 +++++
app/i18n/en/conf.php | 3 +++
app/i18n/en/feedback.php | 21 ++++++++++++++++++++-
app/i18n/en/gen.php | 15 ---------------
app/i18n/fr/admin.php | 7 ++++++-
app/i18n/fr/conf.php | 3 +++
app/i18n/fr/feedback.php | 21 ++++++++++++++++++++-
app/i18n/fr/gen.php | 14 --------------
10 files changed, 78 insertions(+), 53 deletions(-)
(limited to 'app/Controllers/updateController.php')
diff --git a/app/Controllers/updateController.php b/app/Controllers/updateController.php
index 0896b13ac..1b44a739c 100644
--- a/app/Controllers/updateController.php
+++ b/app/Controllers/updateController.php
@@ -20,21 +20,21 @@ class FreshRSS_update_Controller extends Minz_ActionController {
}
public function indexAction() {
- Minz_View::prependTitle(_t('update_system') . ' · ');
+ Minz_View::prependTitle(_t('admin.update.title') . ' · ');
if (file_exists(UPDATE_FILENAME) && !is_writable(FRESHRSS_PATH)) {
$this->view->message = array(
'status' => 'bad',
- 'title' => _t('damn'),
- 'body' => _t('file_is_nok', FRESHRSS_PATH)
+ 'title' => _t('gen.short.damn'),
+ 'body' => _t('feedback.update.file_is_nok', FRESHRSS_PATH)
);
} elseif (file_exists(UPDATE_FILENAME)) {
// There is an update file to apply!
$this->view->update_to_apply = true;
$this->view->message = array(
'status' => 'good',
- 'title' => _t('ok'),
- 'body' => _t('update_can_apply')
+ 'title' => _t('gen.short.ok'),
+ 'body' => _t('feedback.update.can_apply')
);
}
}
@@ -67,8 +67,8 @@ class FreshRSS_update_Controller extends Minz_ActionController {
$this->view->message = array(
'status' => 'bad',
- 'title' => _t('damn'),
- 'body' => _t('update_server_not_found', FRESHRSS_UPDATE_WEBSITE)
+ 'title' => _t('gen.short.damn'),
+ 'body' => _t('feedback.update.server_not_found', FRESHRSS_UPDATE_WEBSITE)
);
return;
}
@@ -78,8 +78,8 @@ class FreshRSS_update_Controller extends Minz_ActionController {
if (strpos($status, 'UPDATE') !== 0) {
$this->view->message = array(
'status' => 'bad',
- 'title' => _t('damn'),
- 'body' => _t('no_update')
+ 'title' => _t('gen.short.damn'),
+ 'body' => _t('feedback.update.none')
);
@file_put_contents(DATA_PATH . '/last_update.txt', time());
@@ -93,8 +93,8 @@ class FreshRSS_update_Controller extends Minz_ActionController {
} else {
$this->view->message = array(
'status' => 'bad',
- 'title' => _t('damn'),
- 'body' => _t('update_problem', 'Cannot save the update script')
+ 'title' => _t('gen.short.damn'),
+ 'body' => _t('feedback.update.error', 'Cannot save the update script')
);
}
}
@@ -112,9 +112,9 @@ class FreshRSS_update_Controller extends Minz_ActionController {
if ($res === true) {
@unlink(UPDATE_FILENAME);
@file_put_contents(DATA_PATH . '/last_update.txt', time());
- Minz_Request::good(_t('update_finished'));
+ Minz_Request::good(_t('feedback.update.finished'));
} else {
- Minz_Request::bad(_t('update_problem', $res),
+ Minz_Request::bad(_t('feedback.update.error', $res),
array('c' => 'update', 'a' => 'index'));
}
}
@@ -133,7 +133,7 @@ class FreshRSS_update_Controller extends Minz_ActionController {
'params' => array('post_conf' => true)
), true);
} else {
- Minz_Request::bad(_t('update_problem', $res),
+ Minz_Request::bad(_t('feedback.update.error', $res),
array('c' => 'update', 'a' => 'index'));
}
}
@@ -143,7 +143,7 @@ class FreshRSS_update_Controller extends Minz_ActionController {
* This action displays information about installation.
*/
public function checkInstallAction() {
- Minz_View::prependTitle(_t('gen.title.check_install') . ' · ');
+ Minz_View::prependTitle(_t('admin.check_install.title') . ' · ');
$this->view->status_php = check_install_php();
$this->view->status_files = check_install_files();
diff --git a/app/Controllers/userController.php b/app/Controllers/userController.php
index 5050571a9..3b40e42dc 100644
--- a/app/Controllers/userController.php
+++ b/app/Controllers/userController.php
@@ -23,7 +23,7 @@ class FreshRSS_user_Controller extends Minz_ActionController {
* This action displays the user profile page.
*/
public function profileAction() {
- Minz_View::prependTitle(_t('gen.title.user_profile') . ' · ');
+ Minz_View::prependTitle(_t('conf.profile.title') . ' · ');
if (Minz_Request::isPost()) {
$ok = true;
@@ -71,10 +71,10 @@ class FreshRSS_user_Controller extends Minz_ActionController {
}
if ($ok) {
- Minz_Request::good(_t('feedback.user_profile.updated'),
+ Minz_Request::good(_t('feedback.profile.updated'),
array('c' => 'user', 'a' => 'profile'));
} else {
- Minz_Request::bad(_t('error_occurred'),
+ Minz_Request::bad(_t('feedback.profile.error'),
array('c' => 'user', 'a' => 'profile'));
}
}
@@ -88,7 +88,7 @@ class FreshRSS_user_Controller extends Minz_ActionController {
Minz_Error::error(403);
}
- Minz_View::prependTitle(_t('gen.title.user_management') . ' · ');
+ Minz_View::prependTitle(_t('admin.user.title') . ' · ');
// Get the correct current user.
$username = Minz_Request::param('u', Minz_Session::param('currentUser'));
@@ -168,7 +168,7 @@ class FreshRSS_user_Controller extends Minz_ActionController {
$notif = array(
'type' => $ok ? 'good' : 'bad',
- 'content' => _t($ok ? 'user_created' : 'error_occurred', $new_user_name)
+ 'content' => _t('feedback.user.created' . (!$ok ? '.error' : ''), $new_user_name)
);
Minz_Session::_param('notification', $notif);
}
@@ -201,7 +201,7 @@ class FreshRSS_user_Controller extends Minz_ActionController {
$notif = array(
'type' => $ok ? 'good' : 'bad',
- 'content' => _t($ok ? 'user_deleted' : 'error_occurred', $username)
+ 'content' => _t('feedback.user.deleted' . (!$ok ? '.error' : ''), $username)
);
Minz_Session::_param('notification', $notif);
}
diff --git a/app/i18n/en/admin.php b/app/i18n/en/admin.php
index 05077cf66..7778c56a7 100644
--- a/app/i18n/en/admin.php
+++ b/app/i18n/en/admin.php
@@ -81,6 +81,7 @@ return array(
'nok' => 'There is one or more lacking tables in the database.',
'ok' => 'Tables are existing in the database.',
),
+ 'title' => 'Installation checking',
'tokens' => array(
'nok' => 'Check permissions on ./data/tokens directory. HTTP server must have rights to write into',
'ok' => 'Permissions on tokens directory are good.',
@@ -122,7 +123,11 @@ return array(
'title' => 'Statistics',
'top_feed' => 'Top ten feeds',
),
+ 'update' => array(
+ 'title' => 'Update system',
+ ),
'users' => array(
'articles_and_size' => '%s articles (%s)',
+ 'title' => 'Manage users',
),
);
diff --git a/app/i18n/en/conf.php b/app/i18n/en/conf.php
index 0a1aa9f8e..09f9fa9ce 100644
--- a/app/i18n/en/conf.php
+++ b/app/i18n/en/conf.php
@@ -11,6 +11,9 @@ return array(
'number' => 'Query n°%d',
'title' => 'User queries',
),
+ 'profile' => array(
+ 'title' => 'Profile',
+ ),
'reading' => array(
'title' => 'Reading',
),
diff --git a/app/i18n/en/feedback.php b/app/i18n/en/feedback.php
index 0dcbbe44d..192a33fcf 100644
--- a/app/i18n/en/feedback.php
+++ b/app/i18n/en/feedback.php
@@ -70,7 +70,26 @@ return array(
),
'purge_completed' => 'Purge completed (%d articles deleted)',
),
- 'user_profile' => array(
+ 'update' => array(
+ 'can_apply' => 'An update is available.',
+ 'error' => 'The update process has encountered an error: %s',
+ 'file_is_nok' => 'Check permissions on %s directory. HTTP server must have rights to write into',
+ 'finished' => 'Update completed!',
+ 'none' => 'No update to apply',
+ 'server_not_found' => 'Update server cannot be found. [%s]',
+ ),
+ 'user' => array(
+ 'created' => array(
+ '_' => 'User %s has been created',
+ 'error' => 'User %s cannot be created',
+ ),
+ 'deleted' => array(
+ '_' => 'User %s has been deleted',
+ 'error' => 'User %s cannot be deleted',
+ ),
+ ),
+ 'profile' => array(
+ 'error' => 'Your profile cannot be modified',
'updated' => 'Your profile has been modified',
),
);
diff --git a/app/i18n/en/gen.php b/app/i18n/en/gen.php
index 2a858d6a6..761d566bf 100644
--- a/app/i18n/en/gen.php
+++ b/app/i18n/en/gen.php
@@ -123,12 +123,6 @@ return array(
'or' => 'or',
'yes' => 'Yes',
),
- 'title' => array(
- 'authentication' => 'Authentication',
- 'check_install' => 'Installation checking',
- 'user_management' => 'Manage users',
- 'user_profile' => 'Profile',
- ),
'freshrss' => 'FreshRSS',
'activate_sharing' => 'Activate sharing',
'after_onread' => 'After “mark all as read”,',
@@ -203,7 +197,6 @@ return array(
'favicons_is_ok' => 'Permissions on favicons directory are good',
'feed' => 'Feed',
'feeds' => 'Feeds',
- 'file_is_nok' => 'Check permissions on %s directory. HTTP server must have rights to write into',
'finish_installation' => 'Complete installation',
'first_article' => 'Skip to the first article',
'fix_errors_before' => 'Fix errors before skip to the next step.',
@@ -250,7 +243,6 @@ return array(
'no_query_filter' => 'No filter',
'no_rss_feed' => 'No RSS feed',
'no_selected_feed' => 'No feed selected.',
- 'no_update' => 'No update to apply',
'not_read' => '%d unread',
'not_reads' => '%d unread',
'not_yet_implemented' => 'Not yet implemented',
@@ -323,20 +315,13 @@ return array(
'top_line' => 'Top line',
'unsafe_autologin' => 'Allow unsafe automatic login using the format: ',
'update_apply' => 'Apply',
- 'update_can_apply' => 'An update is available.',
'update_check' => 'Check for new updates',
'update_end' => 'Update process is completed, now you can go to the final step.',
- 'update_finished' => 'Update completed!',
'update_last' => 'Last verification: %s',
'update_long' => 'This can take a long time, depending on the size of your database. You may have to wait for this page to time out (~5 minutes) and then refresh this page.',
- 'update_problem' => 'The update process has encountered an error: %s',
- 'update_server_not_found' => 'Update server cannot be found. [%s]',
'update_start' => 'Start update process',
- 'update_system' => 'Update system',
'updated' => 'Modifications have been updated',
'upon_reception' => 'upon reception of the article',
- 'user_created' => 'User %s has been created',
- 'user_deleted' => 'User %s has been deleted',
'user_filter' => 'Access user filters',
'user_filter_help' => 'If there is only one user filter, it is used. Else filters are accessible by their number.',
'username' => 'Username',
diff --git a/app/i18n/fr/admin.php b/app/i18n/fr/admin.php
index 25c62c6ea..ffb390876 100644
--- a/app/i18n/fr/admin.php
+++ b/app/i18n/fr/admin.php
@@ -81,6 +81,7 @@ return array(
'nok' => 'Il manque une ou plusieurs tables en base de données.',
'ok' => 'Les tables sont bien présentes en base de données.',
),
+ 'title' => 'Vérification de l’installation',
'tokens' => array(
'nok' => 'Veuillez vérifier les droits sur le répertoire ./data/tokens. Le serveur HTTP doit être capable d’écrire dedans',
'ok' => 'Les droits sur le répertoire des tokens sont bons.',
@@ -122,7 +123,11 @@ return array(
'title' => 'Statistiques',
'top_feed' => 'Les dix plus gros flux',
),
- 'users' => array(
+ 'update' => array(
+ 'title' => 'Système de mise à jour',
+ ),
+ 'user' => array(
'articles_and_size' => '%s articles (%s)',
+ 'title' => 'Gestion des utilisateurs',
),
);
diff --git a/app/i18n/fr/conf.php b/app/i18n/fr/conf.php
index deba4509e..9f78fde87 100644
--- a/app/i18n/fr/conf.php
+++ b/app/i18n/fr/conf.php
@@ -11,6 +11,9 @@ return array(
'number' => 'Filtre n°%d',
'title' => 'Filtres utilisateurs',
),
+ 'profile' => array(
+ 'title' => 'Profil',
+ ),
'reading' => array(
'title' => 'Lecture',
),
diff --git a/app/i18n/fr/feedback.php b/app/i18n/fr/feedback.php
index 539fce55d..992300c7d 100644
--- a/app/i18n/fr/feedback.php
+++ b/app/i18n/fr/feedback.php
@@ -70,7 +70,26 @@ return array(
),
'purge_completed' => 'Purge effectuée (%d articles supprimés).',
),
- 'user_profile' => array(
+ 'update' => array(
+ 'can_apply' => 'Une mise à jour est disponible.',
+ 'error' => 'La mise à jour a rencontré un problème : %s',
+ 'file_is_nok' => 'Veuillez vérifier les droits sur le répertoire %s. Le serveur HTTP doit être capable d’écrire dedans',
+ 'finished' => 'La mise à jour est terminée !',
+ 'none' => 'Aucune mise à jour à appliquer',
+ 'server_not_found' => 'Le serveur de mise à jour n’a pas été trouvé. [%s]',
+ ),
+ 'user' => array(
+ 'created' => array(
+ '_' => 'L’utilisateur %s a été créé.',
+ 'error' => 'L’utilisateur %s ne peut pas être créé.',
+ ),
+ 'deleted' => array(
+ '_' => 'L’utilisateur %s a été supprimé.',
+ 'error' => 'L’utilisateur %s ne peut pas être supprimé.',
+ ),
+ ),
+ 'profile' => array(
+ 'error' => 'Votre profil n’a pas pu être mis à jour',
'updated' => 'Votre profil a été mis à jour',
),
);
diff --git a/app/i18n/fr/gen.php b/app/i18n/fr/gen.php
index f67ee3d52..1866f8e22 100644
--- a/app/i18n/fr/gen.php
+++ b/app/i18n/fr/gen.php
@@ -123,11 +123,6 @@ return array(
'or' => 'ou',
'yes' => 'Oui',
),
- 'title' => array(
- 'check_install' => 'Vérification de l’installation',
- 'user_management' => 'Gestion des utilisateurs',
- 'user_profile' => 'Profil',
- ),
'freshrss' => 'FreshRSS',
'activate_sharing' => 'Activer le partage',
'after_onread' => 'Après “marquer tout comme lu”,',
@@ -202,7 +197,6 @@ return array(
'favicons_is_ok' => 'Les droits sur le répertoire des favicons sont bons',
'feed' => 'Flux',
'feeds' => 'Flux',
- 'file_is_nok' => 'Veuillez vérifier les droits sur le répertoire %s. Le serveur HTTP doit être capable d’écrire dedans',
'finish_installation' => 'Terminer l’installation',
'first_article' => 'Passer au premier article',
'fix_errors_before' => 'Veuillez corriger les erreurs avant de passer à l’étape suivante.',
@@ -249,7 +243,6 @@ return array(
'no_query_filter' => 'Aucun filtre appliqué',
'no_rss_feed' => 'Aucun flux RSS',
'no_selected_feed' => 'Aucun flux sélectionné.',
- 'no_update' => 'Aucune mise à jour à appliquer',
'not_read' => '%d non lu',
'not_reads' => '%d non lus',
'not_yet_implemented' => 'Pas encore implémenté',
@@ -322,20 +315,13 @@ return array(
'top_line' => 'Ligne du haut',
'unsafe_autologin' => 'Autoriser les connexions automatiques non-sûres au format : ',
'update_apply' => 'Appliquer la mise à jour',
- 'update_can_apply' => 'Une mise à jour est disponible.',
'update_check' => 'Vérifier les mises à jour',
'update_end' => 'La mise à jour est terminée, vous pouvez maintenant passer à l’étape finale.',
- 'update_finished' => 'La mise à jour est terminée !',
'update_last' => 'Dernière vérification : %s',
'update_long' => 'Ce processus peut prendre longtemps, selon la taille de votre base de données. Vous aurez peut-être à attendre que cette page dépasse son temps maximum d’exécution (~5 minutes) puis à la recharger.',
- 'update_problem' => 'La mise à jour a rencontré un problème : %s',
- 'update_server_not_found' => 'Le serveur de mise à jour n’a pas été trouvé. [%s]',
'update_start' => 'Lancer la mise à jour',
- 'update_system' => 'Système de mise à jour',
'updated' => 'Modifications enregistrées.',
'upon_reception' => 'dès la réception du nouvel article',
- 'user_created' => 'L’utilisateur %s a été créé.',
- 'user_deleted' => 'L’utilisateur %s a été supprimé.',
'user_filter' => 'Accéder aux filtres utilisateur',
'user_filter_help' => 'S’il n’y a qu’un filtre utilisateur, celui-ci est utilisé automatiquement. Sinon ils sont accessibles par leur numéro.',
'username' => 'Nom d’utilisateur',
--
cgit v1.2.3
From e7c24b5d41c293fa13e4d92efb2aee7778ddcab4 Mon Sep 17 00:00:00 2001
From: Marien Fressinaud
Date: Tue, 13 Jan 2015 12:02:35 +0100
Subject: Show the version number during update process.
Number is stored inside the data/last_update.txt file and shown if there
is an update script.
See https://github.com/FreshRSS/FreshRSS/issues/699
---
app/Controllers/updateController.php | 17 +++++++++++------
app/i18n/en/feedback.php | 2 +-
app/i18n/fr/feedback.php | 2 +-
3 files changed, 13 insertions(+), 8 deletions(-)
(limited to 'app/Controllers/updateController.php')
diff --git a/app/Controllers/updateController.php b/app/Controllers/updateController.php
index 1b44a739c..4bdd96f6d 100644
--- a/app/Controllers/updateController.php
+++ b/app/Controllers/updateController.php
@@ -1,8 +1,8 @@
view->update_to_apply = false;
$this->view->last_update_time = 'unknown';
$this->view->check_last_hour = false;
- $timestamp = (int)@file_get_contents(DATA_PATH . '/last_update.txt');
- if (is_numeric($timestamp) && $timestamp > 0) {
+ $timestamp = @filemtime(join_path(DATA_PATH, 'last_update.txt'));
+ if ($timestamp !== false) {
$this->view->last_update_time = timestamptodate($timestamp);
$this->view->check_last_hour = (time() - 3600) <= $timestamp;
}
@@ -30,11 +30,12 @@ class FreshRSS_update_Controller extends Minz_ActionController {
);
} elseif (file_exists(UPDATE_FILENAME)) {
// There is an update file to apply!
+ $version = file_get_contents(join_path(DATA_PATH, 'last_update.txt'));
$this->view->update_to_apply = true;
$this->view->message = array(
'status' => 'good',
'title' => _t('gen.short.ok'),
- 'body' => _t('feedback.update.can_apply')
+ 'body' => _t('feedback.update.can_apply', $version)
);
}
}
@@ -82,13 +83,17 @@ class FreshRSS_update_Controller extends Minz_ActionController {
'body' => _t('feedback.update.none')
);
- @file_put_contents(DATA_PATH . '/last_update.txt', time());
+ @touch(join_path(DATA_PATH, 'last_update.txt'));
return;
}
$script = $res_array[1];
if (file_put_contents(UPDATE_FILENAME, $script) !== false) {
+ $version = explode(' ', $status, 2);
+ $version = $version[1];
+ @file_put_contents(join_path(DATA_PATH, 'last_update.txt'), $version);
+
Minz_Request::forward(array('c' => 'update'));
} else {
$this->view->message = array(
@@ -111,7 +116,7 @@ class FreshRSS_update_Controller extends Minz_ActionController {
if ($res === true) {
@unlink(UPDATE_FILENAME);
- @file_put_contents(DATA_PATH . '/last_update.txt', time());
+ @file_put_contents(join_path(DATA_PATH, 'last_update.txt'), '');
Minz_Request::good(_t('feedback.update.finished'));
} else {
Minz_Request::bad(_t('feedback.update.error', $res),
diff --git a/app/i18n/en/feedback.php b/app/i18n/en/feedback.php
index 5f7183da3..e9499ed46 100644
--- a/app/i18n/en/feedback.php
+++ b/app/i18n/en/feedback.php
@@ -80,7 +80,7 @@ return array(
'purge_completed' => 'Purge completed (%d articles deleted)',
),
'update' => array(
- 'can_apply' => 'An update is available.',
+ 'can_apply' => 'FreshRSS will be now updated to the version %s.',
'error' => 'The update process has encountered an error: %s',
'file_is_nok' => 'Check permissions on %s directory. HTTP server must have rights to write into',
'finished' => 'Update completed!',
diff --git a/app/i18n/fr/feedback.php b/app/i18n/fr/feedback.php
index 5c71bbae1..c99314411 100644
--- a/app/i18n/fr/feedback.php
+++ b/app/i18n/fr/feedback.php
@@ -80,7 +80,7 @@ return array(
'purge_completed' => 'Purge effectuée (%d articles supprimés).',
),
'update' => array(
- 'can_apply' => 'Une mise à jour est disponible.',
+ 'can_apply' => 'FreshRSS va maintenant être mis à jour vers la version %s.',
'error' => 'La mise à jour a rencontré un problème : %s',
'file_is_nok' => 'Veuillez vérifier les droits sur le répertoire %s. Le serveur HTTP doit être capable d’écrire dedans',
'finished' => 'La mise à jour est terminée !',
--
cgit v1.2.3
From 556f4ad4bfa722e3350f20ab91a08f0af1d11f9e Mon Sep 17 00:00:00 2001
From: Marien Fressinaud
Date: Thu, 15 Jan 2015 11:20:16 +0100
Subject: Remove restriction of 1h for update checking
---
app/Controllers/updateController.php | 8 +++-----
app/views/update/index.phtml | 8 +-------
2 files changed, 4 insertions(+), 12 deletions(-)
(limited to 'app/Controllers/updateController.php')
diff --git a/app/Controllers/updateController.php b/app/Controllers/updateController.php
index 4bdd96f6d..1ea5816da 100644
--- a/app/Controllers/updateController.php
+++ b/app/Controllers/updateController.php
@@ -11,11 +11,9 @@ class FreshRSS_update_Controller extends Minz_ActionController {
$this->view->update_to_apply = false;
$this->view->last_update_time = 'unknown';
- $this->view->check_last_hour = false;
$timestamp = @filemtime(join_path(DATA_PATH, 'last_update.txt'));
if ($timestamp !== false) {
$this->view->last_update_time = timestamptodate($timestamp);
- $this->view->check_last_hour = (time() - 3600) <= $timestamp;
}
}
@@ -43,11 +41,11 @@ class FreshRSS_update_Controller extends Minz_ActionController {
public function checkAction() {
$this->view->change_view('update', 'index');
- if (file_exists(UPDATE_FILENAME) || $this->view->check_last_hour) {
+ if (file_exists(UPDATE_FILENAME)) {
// There is already an update file to apply: we don't need to check
// the webserver!
// Or if already check during the last hour, do nothing.
- Minz_Request::forward(array('c' => 'update'));
+ Minz_Request::forward(array('c' => 'update'), true);
return;
}
@@ -94,7 +92,7 @@ class FreshRSS_update_Controller extends Minz_ActionController {
$version = $version[1];
@file_put_contents(join_path(DATA_PATH, 'last_update.txt'), $version);
- Minz_Request::forward(array('c' => 'update'));
+ Minz_Request::forward(array('c' => 'update'), true);
} else {
$this->view->message = array(
'status' => 'bad',
diff --git a/app/views/update/index.phtml b/app/views/update/index.phtml
index 4c88a0d18..da1bc7ef5 100644
--- a/app/views/update/index.phtml
+++ b/app/views/update/index.phtml
@@ -18,16 +18,10 @@
message['title']; ?>
message['body']; ?>
- check_last_hour) { ?>
-
-
-
-
check_last_hour &&
- (empty($this->message) || $this->message['status'] !== 'good')) {
+ if (empty($this->message) || $this->message['status'] !== 'good') {
?>
--
cgit v1.2.3
From 13cf8b5f9f22a50bba5d1223174407abb1c1d94c Mon Sep 17 00:00:00 2001
From: Marien Fressinaud
Date: Thu, 15 Jan 2015 12:02:42 +0100
Subject: Improve hook calls and add post_update hook
- To the hook is associated a method signature (OneToOne or NoneToNone for now) so
it is easier to call hooks correctly
- post_update hook is called during the post update moment.
---
app/Controllers/updateController.php | 2 +
lib/Minz/ExtensionManager.php | 74 +++++++++++++++++++++++++++++-------
2 files changed, 63 insertions(+), 13 deletions(-)
(limited to 'app/Controllers/updateController.php')
diff --git a/app/Controllers/updateController.php b/app/Controllers/updateController.php
index 1ea5816da..61b62773b 100644
--- a/app/Controllers/updateController.php
+++ b/app/Controllers/updateController.php
@@ -112,6 +112,8 @@ class FreshRSS_update_Controller extends Minz_ActionController {
if (Minz_Request::param('post_conf', false)) {
$res = do_post_update();
+ Minz_ExtensionManager::callHook('post_update');
+
if ($res === true) {
@unlink(UPDATE_FILENAME);
@file_put_contents(join_path(DATA_PATH, 'last_update.txt'), '');
diff --git a/lib/Minz/ExtensionManager.php b/lib/Minz/ExtensionManager.php
index 8369e242a..7edc7afaa 100644
--- a/lib/Minz/ExtensionManager.php
+++ b/lib/Minz/ExtensionManager.php
@@ -15,9 +15,22 @@ class Minz_ExtensionManager {
// List of available hooks. Please keep this list sorted.
private static $hook_list = array(
- 'entry_before_display' => array(), // function($entry) -> Entry | null
- 'entry_before_insert' => array(), // function($entry) -> Entry | null
- 'feed_before_insert' => array(), // function($feed) -> Feed | null
+ 'entry_before_display' => array( // function($entry) -> Entry | null
+ 'list' => array(),
+ 'signature' => 'OneToOne',
+ ),
+ 'entry_before_insert' => array( // function($entry) -> Entry | null
+ 'list' => array(),
+ 'signature' => 'OneToOne',
+ ),
+ 'feed_before_insert' => array( // function($feed) -> Feed | null
+ 'list' => array(),
+ 'signature' => 'OneToOne',
+ ),
+ 'post_update' => array( // function(none) -> none
+ 'list' => array(),
+ 'signature' => 'NoneToNone',
+ ),
);
private static $ext_to_hooks = array();
@@ -214,7 +227,7 @@ class Minz_ExtensionManager {
*/
public static function addHook($hook_name, $hook_function, $ext) {
if (isset(self::$hook_list[$hook_name]) && is_callable($hook_function)) {
- self::$hook_list[$hook_name][] = $hook_function;
+ self::$hook_list[$hook_name]['list'][] = $hook_function;
self::$ext_to_hooks[$ext->getName()][] = $hook_name;
}
}
@@ -226,25 +239,60 @@ class Minz_ExtensionManager {
* array keys.
*
* @param $hook_name the hook to call.
- * @param additionnal parameters (for signature, please see self::$hook_list comments)
- * @todo hook functions will have different signatures. So the $res = func($args);
- * $args = $res; will not work for all of them in the future. We must
- * find a better way to call hooks.
+ * @param additionnal parameters (for signature, please see self::$hook_list).
+ * @return the final result of the called hook.
*/
public static function callHook($hook_name) {
+ if (!isset(self::$hook_list[$hook_name])) {
+ return;
+ }
+
+ $signature = self::$hook_list[$hook_name]['signature'];
+ $signature = 'self::call' . $signature;
$args = func_get_args();
- unset($args[0]);
- $result = $args[1];
- foreach (self::$hook_list[$hook_name] as $function) {
- $result = call_user_func_array($function, $args);
+ return call_user_func_array($signature, $args);
+ }
+
+ /**
+ * Call a hook which takes one argument and return a result.
+ *
+ * The result is chained between the extension, for instance, first extension
+ * hook will receive the initial argument and return a result which will be
+ * passed as an argument to the next extension hook and so on.
+ *
+ * If a hook return a null value, the method is stopped and return null.
+ *
+ * @param $hook_name is the hook to call.
+ * @param $arg is the argument to pass to the first extension hook.
+ * @return the final chained result of the hooks. If nothing is changed,
+ * the initial argument is returned.
+ */
+ private static function callOneToOne($hook_name, $arg) {
+ $result = $arg;
+ foreach (self::$hook_list[$hook_name]['list'] as $function) {
+ $result = call_user_func($function, $arg);
if (is_null($result)) {
break;
}
- $args = $result;
+ $arg = $result;
}
return $result;
}
+
+ /**
+ * Call a hook which takes no argument and returns nothing.
+ *
+ * This case is simpler than callOneToOne because hooks are called one by
+ * one, without any consideration of argument nor result.
+ *
+ * @param $hook_name is the hook to call.
+ */
+ private static function callNoneToNone($hook_name) {
+ foreach (self::$hook_list[$hook_name]['list'] as $function) {
+ call_user_func($function);
+ }
+ }
}
--
cgit v1.2.3
From d30b3becfa50b96982a3b4880c07cc2b770d7eed Mon Sep 17 00:00:00 2001
From: Alexandre Alapetite
Date: Mon, 19 Jan 2015 13:54:57 +0100
Subject: Addressed warnings when reading from new files
There were warnings when reading extensions (trying to use e.g. README
and .gitignore as directories), and when reading update file.
https://github.com/FreshRSS/FreshRSS/issues/733
---
app/Controllers/updateController.php | 5 ++++-
lib/Minz/ExtensionManager.php | 3 +++
2 files changed, 7 insertions(+), 1 deletion(-)
(limited to 'app/Controllers/updateController.php')
diff --git a/app/Controllers/updateController.php b/app/Controllers/updateController.php
index 61b62773b..4797a3486 100644
--- a/app/Controllers/updateController.php
+++ b/app/Controllers/updateController.php
@@ -28,7 +28,10 @@ class FreshRSS_update_Controller extends Minz_ActionController {
);
} elseif (file_exists(UPDATE_FILENAME)) {
// There is an update file to apply!
- $version = file_get_contents(join_path(DATA_PATH, 'last_update.txt'));
+ $version = @file_get_contents(join_path(DATA_PATH, 'last_update.txt'));
+ if (empty($version)) {
+ $version = 'unknown';
+ }
$this->view->update_to_apply = true;
$this->view->message = array(
'status' => 'good',
diff --git a/lib/Minz/ExtensionManager.php b/lib/Minz/ExtensionManager.php
index 7edc7afaa..f00453f6c 100644
--- a/lib/Minz/ExtensionManager.php
+++ b/lib/Minz/ExtensionManager.php
@@ -56,6 +56,9 @@ class Minz_ExtensionManager {
foreach ($list_potential_extensions as $ext_dir) {
$ext_pathname = EXTENSIONS_PATH . '/' . $ext_dir;
+ if (!is_dir($ext_pathname)) {
+ continue;
+ }
$metadata_filename = $ext_pathname . '/' . self::$ext_metaname;
// Try to load metadata file.
--
cgit v1.2.3