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
From 079150eee4eebce3549c3d7db84dd0180bdd11e7 Mon Sep 17 00:00:00 2001
From: Alexandre Alapetite
Date: Fri, 3 Jul 2015 23:47:18 +0200
Subject: Updated log visibility
In particular, ensure that ERROR is only used for errors that may affect
FreshRSS integrity, and ensure that feed errors are visible also in
production, i.e. visibility of WARNING
https://github.com/FreshRSS/FreshRSS/issues/885
https://github.com/FreshRSS/FreshRSS/issues/884
---
app/Controllers/authController.php | 2 +-
app/Controllers/feedController.php | 2 +-
app/Controllers/importExportController.php | 6 +++---
app/Controllers/updateController.php | 2 +-
app/Models/CategoryDAO.php | 2 +-
5 files changed, 7 insertions(+), 7 deletions(-)
(limited to 'app/Controllers/updateController.php')
diff --git a/app/Controllers/authController.php b/app/Controllers/authController.php
index 937c0759d..b55892475 100644
--- a/app/Controllers/authController.php
+++ b/app/Controllers/authController.php
@@ -253,7 +253,7 @@ class FreshRSS_auth_Controller extends Minz_ActionController {
FreshRSS_Auth::giveAccess();
invalidateHttpCache();
} else {
- Minz_Log::error($reason);
+ Minz_Log::warning($reason);
$res = array();
$res['status'] = 'failure';
diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php
index b91f63b5b..488d066a9 100755
--- a/app/Controllers/feedController.php
+++ b/app/Controllers/feedController.php
@@ -322,7 +322,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
$feed->load(false);
}
} catch (FreshRSS_Feed_Exception $e) {
- Minz_Log::notice($e->getMessage());
+ Minz_Log::warning($e->getMessage());
$feedDAO->updateLastUpdate($feed->id(), true);
$feed->unlock();
continue;
diff --git a/app/Controllers/importExportController.php b/app/Controllers/importExportController.php
index 26b163e43..60e467255 100644
--- a/app/Controllers/importExportController.php
+++ b/app/Controllers/importExportController.php
@@ -47,7 +47,7 @@ class FreshRSS_importExport_Controller extends Minz_ActionController {
$status_file = $file['error'];
if ($status_file !== 0) {
- Minz_Log::error('File cannot be uploaded. Error code: ' . $status_file);
+ Minz_Log::warning('File cannot be uploaded. Error code: ' . $status_file);
Minz_Request::bad(_t('feedback.import_export.file_cannot_be_uploaded'),
array('c' => 'importExport', 'a' => 'index'));
}
@@ -69,7 +69,7 @@ class FreshRSS_importExport_Controller extends Minz_ActionController {
if (!is_resource($zip)) {
// zip_open cannot open file: something is wrong
- Minz_Log::error('Zip archive cannot be imported. Error code: ' . $zip);
+ Minz_Log::warning('Zip archive cannot be imported. Error code: ' . $zip);
Minz_Request::bad(_t('feedback.import_export.zip_error'),
array('c' => 'importExport', 'a' => 'index'));
}
@@ -77,7 +77,7 @@ class FreshRSS_importExport_Controller extends Minz_ActionController {
while (($zipfile = zip_read($zip)) !== false) {
if (!is_resource($zipfile)) {
// zip_entry() can also return an error code!
- Minz_Log::error('Zip file cannot be imported. Error code: ' . $zipfile);
+ Minz_Log::warning('Zip file cannot be imported. Error code: ' . $zipfile);
} else {
$type_zipfile = $this->guessFileType(zip_entry_name($zipfile));
if ($type_file !== 'unknown') {
diff --git a/app/Controllers/updateController.php b/app/Controllers/updateController.php
index 4797a3486..84a33fe85 100644
--- a/app/Controllers/updateController.php
+++ b/app/Controllers/updateController.php
@@ -63,7 +63,7 @@ class FreshRSS_update_Controller extends Minz_ActionController {
curl_close($c);
if ($c_status !== 200) {
- Minz_Log::error(
+ Minz_Log::warning(
'Error during update (HTTP code ' . $c_status . '): ' . $c_error
);
diff --git a/app/Models/CategoryDAO.php b/app/Models/CategoryDAO.php
index 189a5f0e4..b5abac519 100644
--- a/app/Models/CategoryDAO.php
+++ b/app/Models/CategoryDAO.php
@@ -13,7 +13,7 @@ class FreshRSS_CategoryDAO extends Minz_ModelPdo implements FreshRSS_Searchable
return $this->bd->lastInsertId();
} else {
$info = $stm == null ? array(2 => 'syntax error') : $stm->errorInfo();
- Minz_Log::error('SQL error addCategory: ' . $info[2] );
+ Minz_Log::error('SQL error addCategory: ' . $info[2]);
return false;
}
}
--
cgit v1.2.3
From bb0556543d3d5d54832ea6d81372587b88062a5b Mon Sep 17 00:00:00 2001
From: Marien Fressinaud
Date: Mon, 2 Nov 2015 20:20:40 +0100
Subject: Move auto-update server URL in configuration
Fix https://github.com/FreshRSS/FreshRSS/issues/1019
---
app/Controllers/updateController.php | 5 +++--
constants.php | 1 -
data/config.default.php | 3 +++
3 files changed, 6 insertions(+), 3 deletions(-)
(limited to 'app/Controllers/updateController.php')
diff --git a/app/Controllers/updateController.php b/app/Controllers/updateController.php
index 84a33fe85..64c984b04 100644
--- a/app/Controllers/updateController.php
+++ b/app/Controllers/updateController.php
@@ -53,7 +53,8 @@ class FreshRSS_update_Controller extends Minz_ActionController {
return;
}
- $c = curl_init(FRESHRSS_UPDATE_WEBSITE);
+ $auto_update_url = FreshRSS_Context::$system_conf->auto_update_url . '?v=' . FRESHRSS_VERSION;
+ $c = curl_init($auto_update_url);
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
curl_setopt($c, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($c, CURLOPT_SSL_VERIFYHOST, 2);
@@ -70,7 +71,7 @@ class FreshRSS_update_Controller extends Minz_ActionController {
$this->view->message = array(
'status' => 'bad',
'title' => _t('gen.short.damn'),
- 'body' => _t('feedback.update.server_not_found', FRESHRSS_UPDATE_WEBSITE)
+ 'body' => _t('feedback.update.server_not_found', $auto_update_url)
);
return;
}
diff --git a/constants.php b/constants.php
index 0035c259b..1c50d4a83 100644
--- a/constants.php
+++ b/constants.php
@@ -1,7 +1,6 @@
'',
+ # Specify address of the FreshRSS auto-update server.
+ 'auto_update_url' => 'https://update.freshrss.org',
+
# Natural language of the user interface, e.g. `en`, `fr`.
'language' => 'en',
--
cgit v1.2.3
From 21e63595083d556bd4a6ff56c4ccaab5cd318dd4 Mon Sep 17 00:00:00 2001
From: Alexandre Alapetite
Date: Sat, 5 Nov 2016 15:08:10 +0100
Subject: Add compatibility with git in Web update
https://github.com/FreshRSS/FreshRSS/issues/907
https://github.com/FreshRSS/FreshRSS/issues/1355
---
CHANGELOG.md | 3 +
README.fr.md | 4 +-
README.md | 2 +-
app/Controllers/updateController.php | 159 ++++++++++++++++++++++++-----------
4 files changed, 118 insertions(+), 50 deletions(-)
(limited to 'app/Controllers/updateController.php')
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 77ec29aed..140c8cfaf 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,9 @@
## 2016-xx-xx FreshRSS 1.7.0-dev
+* Features
+ * Add git compatibility in Web update system [#1357](https://github.com/FreshRSS/FreshRSS/issues/1357)
+ * Requires that the initial installation is done with git
## 2016-11-02 FreshRSS 1.6.1
diff --git a/README.fr.md b/README.fr.md
index 2587c2d8f..afa8fa1ce 100644
--- a/README.fr.md
+++ b/README.fr.md
@@ -23,7 +23,7 @@ Voir la [liste des versions](../../releases).
* Pour ceux qui veulent bien aider à tester ou déveloper les dernières fonctionnalités, [la branche dev](https://github.com/FreshRSS/FreshRSS/tree/dev) vous ouvre les bras !
# Avertissements
-Cette application a été développée pour s’adapter principalement à des besoins personnels, et aucune garantie n'est fournie.
+Cette application a été développée pour s’adapter principalement à des besoins personnels, et aucune garantie n’est fournie.
Les demandes de fonctionnalités, rapports de bugs, et autres contributions sont les bienvenues. Privilégiez pour cela des [demandes sur GitHub](https://github.com/FreshRSS/FreshRSS/issues).
Nous sommes une communauté amicale.
@@ -85,7 +85,7 @@ sudo git checkout -b dev origin/dev
# Mettre les droits d’accès pour le serveur Web
sudo chown -R :www-data . && sudo chmod -R g+r . && sudo chmod -R g+w ./data/
-# Si vous souhaitez permettre les mises à jour par l'interface Web (inutile pour les mises à jour par git)
+# Si vous souhaitez permettre les mises à jour par l’interface Web
sudo chmod -R g+w .
# Publier FreshRSS dans votre répertoire HTML public
diff --git a/README.md b/README.md
index cfb7b6769..ebf1e3c5f 100644
--- a/README.md
+++ b/README.md
@@ -85,7 +85,7 @@ sudo git checkout -b dev origin/dev
# Set the rights so that your Web server can access the files
sudo chown -R :www-data . && sudo chmod -R g+r . && sudo chmod -R g+w ./data/
-# If you would like to allow Web updates (not needed for updates with git)
+# If you would like to allow updates from the Web interface
sudo chmod -R g+w .
# Publish FreshRSS in your public HTML directory
diff --git a/app/Controllers/updateController.php b/app/Controllers/updateController.php
index 64c984b04..8f939dbdb 100644
--- a/app/Controllers/updateController.php
+++ b/app/Controllers/updateController.php
@@ -2,6 +2,45 @@
class FreshRSS_update_Controller extends Minz_ActionController {
+ public static function isGit() {
+ return is_dir(FRESHRSS_PATH . '/.git/');
+ }
+
+ public static function hasGitUpdate() {
+ $cwd = getcwd();
+ chdir(FRESHRSS_PATH);
+ $output = array();
+ try {
+ exec('git fetch', $output, $return);
+ if ($return == 0) {
+ exec('git status -sb --porcelain remote', $output, $return);
+ } else {
+ $line = is_array($output) ? implode('; ', $output) : '' . $output;
+ Minz_Log::warning('git fetch warning:' . $line);
+ }
+ } catch (Exception $e) {
+ Minz_Log::warning('git fetch error:' . $e->getMessage());
+ }
+ chdir($cwd);
+ $line = is_array($output) ? implode('; ', $output) : '' . $output;
+ return strpos($line, '[behind') !== false;
+ }
+
+ public static function gitPull() {
+ $cwd = getcwd();
+ chdir(FRESHRSS_PATH);
+ $output = array();
+ $return = 1;
+ try {
+ exec('git pull --ff-only', $output, $return);
+ } catch (Exception $e) {
+ Minz_Log::warning('git pull error:' . $e->getMessage());
+ }
+ chdir($cwd);
+ $line = is_array($output) ? implode('; ', $output) : '' . $output;
+ return $return == 0 ? true : 'Git error: ' . $line;
+ }
+
public function firstAction() {
if (!FreshRSS_Auth::hasAccess('admin')) {
Minz_Error::error(403);
@@ -20,7 +59,7 @@ class FreshRSS_update_Controller extends Minz_ActionController {
public function indexAction() {
Minz_View::prependTitle(_t('admin.update.title') . ' · ');
- if (file_exists(UPDATE_FILENAME) && !is_writable(FRESHRSS_PATH)) {
+ if (!is_writable(FRESHRSS_PATH)) {
$this->view->message = array(
'status' => 'bad',
'title' => _t('gen.short.damn'),
@@ -53,49 +92,65 @@ class FreshRSS_update_Controller extends Minz_ActionController {
return;
}
- $auto_update_url = FreshRSS_Context::$system_conf->auto_update_url . '?v=' . FRESHRSS_VERSION;
- $c = curl_init($auto_update_url);
- curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($c, CURLOPT_SSL_VERIFYPEER, true);
- curl_setopt($c, CURLOPT_SSL_VERIFYHOST, 2);
- $result = curl_exec($c);
- $c_status = curl_getinfo($c, CURLINFO_HTTP_CODE);
- $c_error = curl_error($c);
- curl_close($c);
-
- if ($c_status !== 200) {
- Minz_Log::warning(
- 'Error during update (HTTP code ' . $c_status . '): ' . $c_error
- );
+ $script = '';
+ $version = '';
- $this->view->message = array(
- 'status' => 'bad',
- 'title' => _t('gen.short.damn'),
- 'body' => _t('feedback.update.server_not_found', $auto_update_url)
- );
- return;
- }
-
- $res_array = explode("\n", $result, 2);
- $status = $res_array[0];
- if (strpos($status, 'UPDATE') !== 0) {
- $this->view->message = array(
- 'status' => 'bad',
- 'title' => _t('gen.short.damn'),
- 'body' => _t('feedback.update.none')
- );
+ if (self::isGit()) {
+ if (self::hasGitUpdate()) {
+ $version = 'git';
+ } else {
+ $this->view->message = array(
+ 'status' => 'bad',
+ 'title' => _t('gen.short.damn'),
+ 'body' => _t('feedback.update.none')
+ );
+ @touch(join_path(DATA_PATH, 'last_update.txt'));
+ return;
+ }
+ } else {
+ $auto_update_url = FreshRSS_Context::$system_conf->auto_update_url . '?v=' . FRESHRSS_VERSION;
+ Minz_Log::debug('HTTP GET ' . $auto_update_url);
+ $c = curl_init($auto_update_url);
+ curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
+ curl_setopt($c, CURLOPT_SSL_VERIFYPEER, true);
+ curl_setopt($c, CURLOPT_SSL_VERIFYHOST, 2);
+ $result = curl_exec($c);
+ $c_status = curl_getinfo($c, CURLINFO_HTTP_CODE);
+ $c_error = curl_error($c);
+ curl_close($c);
+
+ if ($c_status !== 200) {
+ Minz_Log::warning(
+ 'Error during update (HTTP code ' . $c_status . '): ' . $c_error
+ );
+
+ $this->view->message = array(
+ 'status' => 'bad',
+ 'title' => _t('gen.short.damn'),
+ 'body' => _t('feedback.update.server_not_found', $auto_update_url)
+ );
+ return;
+ }
- @touch(join_path(DATA_PATH, 'last_update.txt'));
+ $res_array = explode("\n", $result, 2);
+ $status = $res_array[0];
+ if (strpos($status, 'UPDATE') !== 0) {
+ $this->view->message = array(
+ 'status' => 'bad',
+ 'title' => _t('gen.short.damn'),
+ 'body' => _t('feedback.update.none')
+ );
+ @touch(join_path(DATA_PATH, 'last_update.txt'));
+ return;
+ }
- return;
+ $script = $res_array[1];
+ $version = explode(' ', $status, 2);
+ $version = $version[1];
}
- $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'), true);
} else {
$this->view->message = array(
@@ -111,10 +166,13 @@ class FreshRSS_update_Controller extends Minz_ActionController {
Minz_Request::forward(array('c' => 'update'), true);
}
- require(UPDATE_FILENAME);
-
if (Minz_Request::param('post_conf', false)) {
- $res = do_post_update();
+ if (self::isGit()) {
+ $res = !self::hasGitUpdate();
+ } else {
+ require(UPDATE_FILENAME);
+ $res = do_post_update();
+ }
Minz_ExtensionManager::callHook('post_update');
@@ -126,14 +184,21 @@ class FreshRSS_update_Controller extends Minz_ActionController {
Minz_Request::bad(_t('feedback.update.error', $res),
array('c' => 'update', 'a' => 'index'));
}
- }
-
- if (Minz_Request::isPost()) {
- save_info_update();
- }
+ } else {
+ $res = false;
- if (!need_info_update()) {
- $res = apply_update();
+ if (self::isGit()) {
+ $res = self::gitPull();
+ } else {
+ if (Minz_Request::isPost()) {
+ save_info_update();
+ }
+ if (!need_info_update()) {
+ $res = apply_update();
+ } else {
+ return;
+ }
+ }
if ($res === true) {
Minz_Request::forward(array(
--
cgit v1.2.3