diff options
| author | 2017-10-01 18:31:28 +0200 | |
|---|---|---|
| committer | 2017-10-01 18:31:28 +0200 | |
| commit | ceda55c75b158fc1cf4813fe0f258527754b9289 (patch) | |
| tree | 7c84ac32cc845ab1d70ea5a3fb263c6613de34b0 /app/Controllers | |
| parent | cb7ba3e47576aa1d0c3f53e5966f831e6540bbc3 (diff) | |
| parent | f241fc1841df89285ecb6f124f0d70198d712b2f (diff) | |
Merge pull request #1651 from FreshRSS/dev1.8.0
Release 1.8.0
Diffstat (limited to 'app/Controllers')
| -rw-r--r-- | app/Controllers/categoryController.php | 4 | ||||
| -rwxr-xr-x | app/Controllers/feedController.php | 17 | ||||
| -rw-r--r-- | app/Controllers/importExportController.php | 17 | ||||
| -rwxr-xr-x | app/Controllers/indexController.php | 4 | ||||
| -rw-r--r-- | app/Controllers/subscriptionController.php | 7 | ||||
| -rw-r--r-- | app/Controllers/userController.php | 50 |
6 files changed, 62 insertions, 37 deletions
diff --git a/app/Controllers/categoryController.php b/app/Controllers/categoryController.php index 922f92844..f3b35a323 100644 --- a/app/Controllers/categoryController.php +++ b/app/Controllers/categoryController.php @@ -127,11 +127,11 @@ class FreshRSS_category_Controller extends Minz_ActionController { Minz_Request::bad(_t('feedback.sub.category.no_id'), $url_redirect); } - if ($id === FreshRSS_CategoryDAO::defaultCategoryId) { + if ($id === FreshRSS_CategoryDAO::DEFAULTCATEGORYID) { Minz_Request::bad(_t('feedback.sub.category.not_delete_default'), $url_redirect); } - if ($feedDAO->changeCategory($id, FreshRSS_CategoryDAO::defaultCategoryId) === false) { + if ($feedDAO->changeCategory($id, FreshRSS_CategoryDAO::DEFAULTCATEGORYID) === false) { Minz_Request::bad(_t('feedback.sub.category.error'), $url_redirect); } diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index c9b6deaa7..45cba9e98 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -42,7 +42,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController { if ($cat == null) { $catDAO->checkDefault(); } - $cat_id = $cat == null ? FreshRSS_CategoryDAO::defaultCategoryId : $cat->id(); + $cat_id = $cat == null ? FreshRSS_CategoryDAO::DEFAULTCATEGORYID : $cat->id(); $feed = new FreshRSS_Feed($url); //Throws FreshRSS_BadUrl_Exception $feed->_httpAuth($http_auth); @@ -320,11 +320,16 @@ class FreshRSS_feed_Controller extends Minz_ActionController { } // For this feed, check existing GUIDs already in database. $existingHashForGuids = $entryDAO->listHashForFeedGuids($feed->id(), $newGuids); - unset($newGuids); + $newGuids = array(); $oldGuids = array(); // Add entries in database if possible. foreach ($entries as $entry) { + if (isset($newGuids[$entry->guid()])) { + continue; //Skip subsequent articles with same GUID + } + $newGuids[$entry->guid()] = true; + $entry_date = $entry->date(true); if (isset($existingHashForGuids[$entry->guid()])) { $existingHash = $existingHashForGuids[$entry->guid()]; @@ -420,8 +425,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController { $feedDAO->updateFeed($feed->id(), array('url' => $feed->url())); } } - } - elseif ($feed->url() !== $url) { // HTTP 301 Moved Permanently + } elseif ($feed->url() !== $url) { // HTTP 301 Moved Permanently Minz_Log::notice('Feed ' . $url . ' moved permanently to ' . $feed->url()); $feedDAO->updateFeed($feed->id(), array('url' => $feed->url())); } @@ -537,7 +541,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController { } if ($cat_id <= 1) { $catDAO->checkDefault(); - $cat_id = FreshRSS_CategoryDAO::defaultCategoryId; + $cat_id = FreshRSS_CategoryDAO::DEFAULTCATEGORYID; } $feedDAO = FreshRSS_Factory::createFeedDao(); @@ -566,6 +570,9 @@ class FreshRSS_feed_Controller extends Minz_ActionController { if (self::moveFeed($feed_id, $cat_id)) { // TODO: return something useful + // Log a notice to prevent "Empty IF statement" warning in PHP_CodeSniffer + Minz_Log::notice('Moved feed `' . $feed_id . '` ' . + 'in the category `' . $cat_id . '`');; } else { Minz_Log::warning('Cannot move feed `' . $feed_id . '` ' . 'in the category `' . $cat_id . '`'); diff --git a/app/Controllers/importExportController.php b/app/Controllers/importExportController.php index 2bc68848c..a76dd9a2b 100644 --- a/app/Controllers/importExportController.php +++ b/app/Controllers/importExportController.php @@ -152,8 +152,7 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { // And finally, we get import status and redirect to the home page Minz_Session::_param('actualize_feeds', true); - $content_notif = $error === true ? _t('feedback.import_export.feeds_imported_with_errors') : - _t('feedback.import_export.feeds_imported'); + $content_notif = $error === true ? _t('feedback.import_export.feeds_imported_with_errors') : _t('feedback.import_export.feeds_imported'); Minz_Request::good($content_notif); } @@ -427,7 +426,7 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { } // For this feed, check existing GUIDs already in database. $existingHashForGuids = $this->entryDAO->listHashForFeedGuids($feed->id(), $newGuids); - unset($newGuids); + $newGuids = array(); // Then, articles are imported. $this->entryDAO->beginTransaction(); @@ -439,8 +438,7 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { $feed_id = $article_to_feed[$item['id']]; $author = isset($item['author']) ? $item['author'] : ''; - $key_content = ($google_compliant && !isset($item['content'])) ? - 'summary' : 'content'; + $key_content = ($google_compliant && !isset($item['content'])) ? 'summary' : 'content'; $tags = $item['categories']; if ($google_compliant) { // Remove tags containing "/state/com.google" which are useless. @@ -457,6 +455,11 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { $entry->_id(min(time(), $entry->date(true)) . uSecString()); $entry->_tags($tags); + if (isset($newGuids[$entry->guid()])) { + continue; //Skip subsequent articles with same GUID + } + $newGuids[$entry->guid()] = true; + $entry = Minz_ExtensionManager::callHook('entry_before_insert', $entry); if ($entry == null) { // An extension has returned a null value, there is nothing to insert. @@ -501,7 +504,7 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { try { // Create a Feed object and add it in database. $feed = new FreshRSS_Feed($url); - $feed->_category(FreshRSS_CategoryDAO::defaultCategoryId); + $feed->_category(FreshRSS_CategoryDAO::DEFAULTCATEGORYID); $feed->_name($name); $feed->_website($website); @@ -640,7 +643,7 @@ class FreshRSS_importExport_Controller extends Minz_ActionController { * @param FreshRSS_Feed $feed feed of which we want to get entries. * @return string the JSON file content. */ - private function generateEntries($type, $feed = NULL, $maxFeedEntries = 50) { + private function generateEntries($type, $feed = null, $maxFeedEntries = 50) { $this->view->categories = $this->catDAO->listCategories(); if ($type == 'starred') { diff --git a/app/Controllers/indexController.php b/app/Controllers/indexController.php index 5ca147ff3..e8dde36fa 100755 --- a/app/Controllers/indexController.php +++ b/app/Controllers/indexController.php @@ -46,9 +46,7 @@ class FreshRSS_index_Controller extends Minz_ActionController { } $first_entry = $nb_entries > 0 ? $entries[0] : null; - FreshRSS_Context::$id_max = $first_entry === null ? - (time() - 1) . '000000' : - $first_entry->id(); + FreshRSS_Context::$id_max = $first_entry === null ? (time() - 1) . '000000' : $first_entry->id(); if (FreshRSS_Context::$order === 'ASC') { // In this case we do not know but we guess id_max $id_max = (time() - 1) . '000000'; diff --git a/app/Controllers/subscriptionController.php b/app/Controllers/subscriptionController.php index aa9f18663..6af048b84 100644 --- a/app/Controllers/subscriptionController.php +++ b/app/Controllers/subscriptionController.php @@ -113,4 +113,11 @@ class FreshRSS_subscription_Controller extends Minz_ActionController { } } } + + /** + * This action displays the bookmarklet page. + */ + public function bookmarkletAction() { + Minz_View::prependTitle(_t('sub.title.subscription_tools') . ' . '); + } } diff --git a/app/Controllers/userController.php b/app/Controllers/userController.php index 3cbbd8633..a58501186 100644 --- a/app/Controllers/userController.php +++ b/app/Controllers/userController.php @@ -44,6 +44,29 @@ class FreshRSS_user_Controller extends Minz_ActionController { return preg_match('/^' . self::USERNAME_PATTERN . '$/', $username) === 1; } + public static function updateContextUser($passwordPlain, $apiPasswordPlain, $userConfigUpdated = array()) { + if ($passwordPlain != '') { + $passwordHash = self::hashPassword($passwordPlain); + FreshRSS_Context::$user_conf->passwordHash = $passwordHash; + } + + if ($apiPasswordPlain != '') { + $apiPasswordHash = self::hashPassword($apiPasswordPlain); + FreshRSS_Context::$user_conf->apiPasswordHash = $apiPasswordHash; + } + + if (is_array($userConfigUpdated)) { + foreach ($userConfigUpdated as $configName => $configValue) { + if ($configValue !== null) { + FreshRSS_Context::$user_conf->_param($configName, $configValue); + } + } + } + + $ok = FreshRSS_Context::$user_conf->save(); + return $ok; + } + /** * This action displays the user profile page. */ @@ -55,30 +78,17 @@ class FreshRSS_user_Controller extends Minz_ActionController { )); if (Minz_Request::isPost()) { - $ok = true; - $passwordPlain = Minz_Request::param('newPasswordPlain', '', true); - if ($passwordPlain != '') { - Minz_Request::_param('newPasswordPlain'); //Discard plain-text password ASAP - $_POST['newPasswordPlain'] = ''; - $passwordHash = self::hashPassword($passwordPlain); - $ok &= ($passwordHash != ''); - FreshRSS_Context::$user_conf->passwordHash = $passwordHash; - } - Minz_Session::_param('passwordHash', FreshRSS_Context::$user_conf->passwordHash); + Minz_Request::_param('newPasswordPlain'); //Discard plain-text password ASAP + $_POST['newPasswordPlain'] = ''; - $passwordPlain = Minz_Request::param('apiPasswordPlain', '', true); - if ($passwordPlain != '') { - $passwordHash = self::hashPassword($passwordPlain); - $ok &= ($passwordHash != ''); - FreshRSS_Context::$user_conf->apiPasswordHash = $passwordHash; - } + $apiPasswordPlain = Minz_Request::param('apiPasswordPlain', '', true); - $current_token = FreshRSS_Context::$user_conf->token; - $token = Minz_Request::param('token', $current_token); - FreshRSS_Context::$user_conf->token = $token; + $ok = self::updateContextUser($passwordPlain, $apiPasswordPlain, array( + 'token' => Minz_Request::param('token', null), + )); - $ok &= FreshRSS_Context::$user_conf->save(); + Minz_Session::_param('passwordHash', FreshRSS_Context::$user_conf->passwordHash); if ($ok) { Minz_Request::good(_t('feedback.profile.updated'), |
