aboutsummaryrefslogtreecommitdiff
path: root/app/Controllers/feedController.php
diff options
context:
space:
mode:
authorGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2015-01-15 14:17:00 +0100
committerGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2015-01-15 14:17:00 +0100
commiteaf6c2c33e3c058bd6890c9fb30308b13727b19d (patch)
tree6a797374b348e5a42ddd5b8dc26079525f9194eb /app/Controllers/feedController.php
parentcaa274c75b6a7471f09f9c21057749c686e155fb (diff)
parent4c143426712f75fa04999f4e8b3c0b6900bf062d (diff)
Merge branch 'dev' into beta
Diffstat (limited to 'app/Controllers/feedController.php')
-rwxr-xr-xapp/Controllers/feedController.php55
1 files changed, 39 insertions, 16 deletions
diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php
index 121cb8921..6f544d834 100755
--- a/app/Controllers/feedController.php
+++ b/app/Controllers/feedController.php
@@ -14,12 +14,13 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
// Token is useful in the case that anonymous refresh is forbidden
// and CRON task cannot be used with php command so the user can
// set a CRON task to refresh his feeds by using token inside url
- $token = FreshRSS_Context::$conf->token;
+ $token = FreshRSS_Context::$user_conf->token;
$token_param = Minz_Request::param('token', '');
$token_is_ok = ($token != '' && $token == $token_param);
$action = Minz_Request::actionName();
+ $allow_anonymous_refresh = FreshRSS_Context::$system_conf->allow_anonymous_refresh;
if ($action !== 'actualize' ||
- !(Minz_Configuration::allowAnonymousRefresh() || $token_is_ok)) {
+ !($allow_anonymous_refresh || $token_is_ok)) {
Minz_Error::error(403);
}
}
@@ -65,7 +66,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
'params' => array(),
);
- $limits = Minz_Configuration::limits();
+ $limits = FreshRSS_Context::$system_conf->limits;
$this->view->feeds = $feedDAO->listFeeds();
if (count($this->view->feeds) >= $limits['max_feeds']) {
Minz_Request::bad(_t('feedback.sub.feed.over_max', $limits['max_feeds']),
@@ -141,6 +142,13 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
$feed->_category($cat);
$feed->_httpAuth($http_auth);
+ // Call the extension hook
+ $name = $feed->name();
+ $feed = Minz_ExtensionManager::callHook('feed_before_insert', $feed);
+ if (is_null($feed)) {
+ Minz_Request::bad(_t('feed_not_added', $name), $url_redirect);
+ }
+
$values = array(
'url' => $feed->url(),
'category' => $feed->category(),
@@ -161,14 +169,14 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
$feed->_id($id);
$feed->faviconPrepare();
- $is_read = FreshRSS_Context::$conf->mark_when['reception'] ? 1 : 0;
+ $is_read = FreshRSS_Context::$user_conf->mark_when['reception'] ? 1 : 0;
$entryDAO = FreshRSS_Factory::createEntryDao();
// We want chronological order and SimplePie uses reverse order.
$entries = array_reverse($feed->entries());
// Calculate date of oldest entries we accept in DB.
- $nb_month_old = FreshRSS_Context::$conf->old_entries;
+ $nb_month_old = FreshRSS_Context::$user_conf->old_entries;
$date_min = time() - (3600 * 24 * 30 * $nb_month_old);
// Use a shared statement and a transaction to improve a LOT the
@@ -177,10 +185,17 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
$feedDAO->beginTransaction();
foreach ($entries as $entry) {
// Entries are added without any verification.
+ $entry->_feed($feed->id());
+ $entry->_id(min(time(), $entry->date(true)) . uSecString());
+ $entry->_isRead($is_read);
+
+ $entry = Minz_ExtensionManager::callHook('entry_before_insert', $entry);
+ if (is_null($entry)) {
+ // An extension has returned a null value, there is nothing to insert.
+ continue;
+ }
+
$values = $entry->toArray();
- $values['id_feed'] = $feed->id();
- $values['id'] = min(time(), $entry->date(true)) . uSecString();
- $values['is_read'] = $is_read;
$entryDAO->addEntry($values, $prepared_statement);
}
$feedDAO->updateLastUpdate($feed->id());
@@ -272,15 +287,15 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
$feeds[] = $feed;
}
} else {
- $feeds = $feedDAO->listFeedsOrderUpdate(FreshRSS_Context::$conf->ttl_default);
+ $feeds = $feedDAO->listFeedsOrderUpdate(FreshRSS_Context::$user_conf->ttl_default);
}
// Calculate date of oldest entries we accept in DB.
- $nb_month_old = max(FreshRSS_Context::$conf->old_entries, 1);
+ $nb_month_old = max(FreshRSS_Context::$user_conf->old_entries, 1);
$date_min = time() - (3600 * 24 * 30 * $nb_month_old);
$updated_feeds = 0;
- $is_read = FreshRSS_Context::$conf->mark_when['reception'] ? 1 : 0;
+ $is_read = FreshRSS_Context::$user_conf->mark_when['reception'] ? 1 : 0;
foreach ($feeds as $feed) {
if (!$feed->lock()) {
Minz_Log::notice('Feed already being actualized: ' . $feed->url());
@@ -302,7 +317,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
if ($feed_history == -2) {
// TODO: -2 must be a constant!
// -2 means we take the default value from configuration
- $feed_history = FreshRSS_Context::$conf->keep_history_default;
+ $feed_history = FreshRSS_Context::$user_conf->keep_history_default;
}
// We want chronological order and SimplePie uses reverse order.
@@ -332,9 +347,16 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
$id = min(time(), $entry_date) . uSecString();
}
+ $entry->_id($id);
+ $entry->_isRead($is_read);
+
+ $entry = Minz_ExtensionManager::callHook('entry_before_insert', $entry);
+ if (is_null($entry)) {
+ // An extension has returned a null value, there is nothing to insert.
+ continue;
+ }
+
$values = $entry->toArray();
- $values['id'] = $id;
- $values['is_read'] = $is_read;
$entryDAO->addEntry($values, $prepared_statement);
}
}
@@ -476,8 +498,9 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
// TODO: Delete old favicon
// Remove related queries
- FreshRSS_Context::$conf->remove_query_by_get('f_' . $id);
- FreshRSS_Context::$conf->save();
+ FreshRSS_Context::$user_conf->queries = remove_query_by_get(
+ 'f_' . $id, FreshRSS_Context::$user_conf->queries);
+ FreshRSS_Context::$user_conf->save();
Minz_Request::good(_t('feedback.sub.feed.deleted'), $redirect_url);
} else {