mirror of https://github.com/FreshRSS/FreshRSS.git
Merge 08f4befe8f
into 08d6328975
This commit is contained in:
commit
f221157430
|
@ -65,6 +65,7 @@ class FreshRSS_auth_Controller extends FreshRSS_ActionController {
|
|||
*
|
||||
* It forwards to the correct login page (form) or main page if
|
||||
* the user is already connected.
|
||||
* @throws Minz_ConfigurationParamException|FreshRSS_Context_Exception
|
||||
*/
|
||||
public function loginAction(): void {
|
||||
if (FreshRSS_Auth::hasAccess() && Minz_Request::paramString('u') === '') {
|
||||
|
@ -99,7 +100,7 @@ class FreshRSS_auth_Controller extends FreshRSS_ActionController {
|
|||
* This action handles form login page.
|
||||
*
|
||||
* If this action is reached through a POST request, username and password
|
||||
* are compared to login the current user.
|
||||
* are compared to log in the current user.
|
||||
*
|
||||
* Parameters are:
|
||||
* - nonce (default: false)
|
||||
|
@ -107,8 +108,8 @@ class FreshRSS_auth_Controller extends FreshRSS_ActionController {
|
|||
* - challenge (default: '')
|
||||
* - keep_logged_in (default: false)
|
||||
*
|
||||
* @todo move unsafe autologin in an extension.
|
||||
* @throws Exception
|
||||
* @todo move unsafe autologin in an extension.
|
||||
*/
|
||||
public function formLoginAction(): void {
|
||||
invalidateHttpCache();
|
||||
|
|
|
@ -8,7 +8,7 @@ declare(strict_types=1);
|
|||
class FreshRSS_category_Controller extends FreshRSS_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
|
||||
* the common boilerplate for every action. It is triggered by the
|
||||
* underlying framework.
|
||||
*
|
||||
*/
|
||||
|
|
|
@ -42,6 +42,7 @@ class FreshRSS_configure_Controller extends FreshRSS_ActionController {
|
|||
* - display of open action in footer
|
||||
* - html5 notification timeout (default: 0)
|
||||
* Default values are false unless specified.
|
||||
* @throws FreshRSS_Context_Exception
|
||||
*/
|
||||
public function displayAction(): void {
|
||||
if (Minz_Request::isPost()) {
|
||||
|
@ -109,6 +110,7 @@ class FreshRSS_configure_Controller extends FreshRSS_ActionController {
|
|||
* - received
|
||||
* - focus
|
||||
* Default values are false unless specified.
|
||||
* @throws FreshRSS_Context_Exception
|
||||
*/
|
||||
public function readingAction(): void {
|
||||
if (Minz_Request::isPost()) {
|
||||
|
@ -166,6 +168,7 @@ class FreshRSS_configure_Controller extends FreshRSS_ActionController {
|
|||
*
|
||||
* Before v1.16, we used sharing instead of integration. This has
|
||||
* some unwanted behavior when the end-user was using an ad-blocker.
|
||||
* @throws FreshRSS_Context_Exception
|
||||
*/
|
||||
public function integrationAction(): void {
|
||||
FreshRSS_View::appendScript(Minz_Url::display('/scripts/integration.js?' . @filemtime(PUBLIC_PATH . '/scripts/integration.js')));
|
||||
|
@ -194,6 +197,7 @@ class FreshRSS_configure_Controller extends FreshRSS_ActionController {
|
|||
* to 9), function keys (f1 to f12), backspace, delete, down, end, enter,
|
||||
* escape, home, insert, left, page down, page up, return, right, space,
|
||||
* tab and up.
|
||||
* @throws FreshRSS_Context_Exception|Minz_FileNotExistException
|
||||
*/
|
||||
public function shortcutAction(): void {
|
||||
$this->view->list_keys = SHORTCUT_KEYS;
|
||||
|
|
|
@ -16,7 +16,7 @@ class FreshRSS_error_Controller extends FreshRSS_ActionController {
|
|||
*/
|
||||
public function indexAction(): void {
|
||||
$code_int = Minz_Session::paramInt('error_code') ?: 404;
|
||||
/** @var array<string> */
|
||||
/** @var array<string> $error_logs */
|
||||
$error_logs = Minz_Session::paramArray('error_logs');
|
||||
Minz_Session::_params([
|
||||
'error_code' => false,
|
||||
|
|
|
@ -7,7 +7,7 @@ declare(strict_types=1);
|
|||
class FreshRSS_extension_Controller extends FreshRSS_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
|
||||
* the common boilerplate for every action. It is triggered by the
|
||||
* underlying framework.
|
||||
*/
|
||||
#[\Override]
|
||||
|
@ -53,7 +53,7 @@ class FreshRSS_extension_Controller extends FreshRSS_ActionController {
|
|||
}
|
||||
|
||||
// fetch the list as an array
|
||||
/** @var array<string,mixed> $list*/
|
||||
/** @var array<string,mixed> $list */
|
||||
$list = json_decode($json, true);
|
||||
if (!is_array($list) || empty($list['extensions']) || !is_array($list['extensions'])) {
|
||||
Minz_Log::warning('Failed to convert extension file list');
|
||||
|
@ -88,7 +88,7 @@ class FreshRSS_extension_Controller extends FreshRSS_ActionController {
|
|||
*
|
||||
* Parameters are:
|
||||
* - e: the extension name (urlencoded)
|
||||
* - additional parameters which should be handle by the extension
|
||||
* - additional parameters which should be handled by the extension
|
||||
* handleConfigureAction() method (POST request).
|
||||
*/
|
||||
public function configureAction(): void {
|
||||
|
|
|
@ -137,6 +137,7 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {
|
|||
* If no category is given, feed is added to the default one.
|
||||
*
|
||||
* If url_rss is false, nothing happened.
|
||||
* @throws FreshRSS_Context_Exception
|
||||
*/
|
||||
public function addAction(): void {
|
||||
$url = Minz_Request::paramString('url_rss');
|
||||
|
@ -345,7 +346,7 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {
|
|||
|
||||
$feed = $feedDAO->searchByUrl($this->view->feed->url());
|
||||
if ($feed) {
|
||||
// Already subscribe so we redirect to the feed configuration page.
|
||||
// Already subscribe, so we redirect to the feed configuration page.
|
||||
$url_redirect['a'] = 'feed';
|
||||
$url_redirect['params']['id'] = $feed->id();
|
||||
Minz_Request::good(_t('feedback.sub.feed.already_subscribed', $feed->name()), $url_redirect);
|
||||
|
@ -387,6 +388,7 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {
|
|||
/**
|
||||
* @return array{0:int,1:FreshRSS_Feed|null,2:int} Number of updated feeds, first feed or null, number of new articles
|
||||
* @throws FreshRSS_BadUrl_Exception
|
||||
* @throws FreshRSS_Context_Exception
|
||||
*/
|
||||
public static function actualizeFeeds(?int $feed_id = null, ?string $feed_url = null, ?int $maxFeeds = null, ?SimplePie $simplePiePush = null): array {
|
||||
if (function_exists('set_time_limit')) {
|
||||
|
@ -515,13 +517,11 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {
|
|||
// Feed is cached and unchanged
|
||||
$newGuids = [];
|
||||
$entries = [];
|
||||
$feedIsEmpty = false; // We do not know
|
||||
$feedIsUnchanged = true;
|
||||
} else {
|
||||
$newGuids = $feed->loadGuids($simplePie);
|
||||
$entries = $feed->loadEntries($simplePie);
|
||||
$feedIsEmpty = $simplePiePush !== null && empty($newGuids);
|
||||
$feedIsUnchanged = false;
|
||||
}
|
||||
$mtime = $feed->cacheModifiedTime() ?: time();
|
||||
} catch (FreshRSS_Feed_Exception $e) {
|
||||
|
@ -952,6 +952,11 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws FreshRSS_Context_Exception
|
||||
* @throws Minz_ConfigurationNamespaceException
|
||||
* @throws Minz_PDOConnectionException
|
||||
*/
|
||||
public static function deleteFeed(int $feed_id): bool {
|
||||
FreshRSS_UserDAO::touch();
|
||||
$feedDAO = FreshRSS_Factory::createFeedDao();
|
||||
|
@ -1039,6 +1044,7 @@ class FreshRSS_feed_Controller extends FreshRSS_ActionController {
|
|||
* - id (mandatory - no default): Feed ID
|
||||
*
|
||||
* @throws FreshRSS_BadUrl_Exception
|
||||
* @throws FreshRSS_Context_Exception
|
||||
*/
|
||||
public function reloadAction(): void {
|
||||
if (function_exists('set_time_limit')) {
|
||||
|
|
|
@ -287,6 +287,7 @@ class FreshRSS_importExport_Controller extends FreshRSS_ActionController {
|
|||
* @return bool false if an error occurred, true otherwise.
|
||||
* @throws Minz_ConfigurationNamespaceException
|
||||
* @throws Minz_PDOConnectionException
|
||||
* @throws FreshRSS_Context_Exception
|
||||
*/
|
||||
private function importJson(string $article_file, bool $starred = false): bool {
|
||||
$article_object = json_decode($article_file, true);
|
||||
|
@ -608,7 +609,7 @@ class FreshRSS_importExport_Controller extends FreshRSS_ActionController {
|
|||
$export_opml = Minz_Request::paramBoolean('export_opml');
|
||||
$export_starred = Minz_Request::paramBoolean('export_starred');
|
||||
$export_labelled = Minz_Request::paramBoolean('export_labelled');
|
||||
/** @var array<numeric-string> */
|
||||
/** @var array<numeric-string> $export_feeds */
|
||||
$export_feeds = Minz_Request::paramArray('export_feeds');
|
||||
$max_number_entries = 50;
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ class FreshRSS_index_Controller extends FreshRSS_ActionController {
|
|||
|
||||
/**
|
||||
* This action displays the normal view of FreshRSS.
|
||||
* @throws FreshRSS_Context_Exception
|
||||
*/
|
||||
public function normalAction(): void {
|
||||
$allow_anonymous = FreshRSS_Context::systemConf()->allow_anonymous;
|
||||
|
@ -77,7 +78,7 @@ class FreshRSS_index_Controller extends FreshRSS_ActionController {
|
|||
// +1 to account for paging logic
|
||||
$view->entries = FreshRSS_index_Controller::listEntriesByContext(FreshRSS_Context::$number + 1);
|
||||
ob_start(); //Buffer "one entry at a time"
|
||||
} catch (FreshRSS_EntriesGetter_Exception $e) {
|
||||
} catch (Throwable $e) {
|
||||
Minz_Log::notice($e->getMessage());
|
||||
Minz_Error::error(404);
|
||||
}
|
||||
|
@ -96,6 +97,7 @@ class FreshRSS_index_Controller extends FreshRSS_ActionController {
|
|||
/**
|
||||
* This action displays the reader view of FreshRSS.
|
||||
*
|
||||
* @throws FreshRSS_Context_Exception
|
||||
* @todo: change this view into specific CSS rules?
|
||||
*/
|
||||
public function readerAction(): void {
|
||||
|
@ -104,6 +106,7 @@ class FreshRSS_index_Controller extends FreshRSS_ActionController {
|
|||
|
||||
/**
|
||||
* This action displays the global view of FreshRSS.
|
||||
* @throws FreshRSS_Context_Exception
|
||||
*/
|
||||
public function globalAction(): void {
|
||||
$allow_anonymous = FreshRSS_Context::systemConf()->allow_anonymous;
|
||||
|
@ -163,7 +166,7 @@ class FreshRSS_index_Controller extends FreshRSS_ActionController {
|
|||
|
||||
try {
|
||||
$this->view->entries = FreshRSS_index_Controller::listEntriesByContext();
|
||||
} catch (FreshRSS_EntriesGetter_Exception $e) {
|
||||
} catch (Throwable $e) {
|
||||
Minz_Log::notice($e->getMessage());
|
||||
Minz_Error::error(404);
|
||||
}
|
||||
|
|
|
@ -17,6 +17,11 @@ class FreshRSS_javascript_Controller extends FreshRSS_ActionController {
|
|||
$this->view->_layout(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws FreshRSS_Context_Exception
|
||||
* @throws Minz_ConfigurationNamespaceException
|
||||
* @throws Minz_PDOConnectionException
|
||||
*/
|
||||
public function actualizeAction(): void {
|
||||
header('Content-Type: application/json; charset=UTF-8');
|
||||
Minz_Session::_param('actualize_feeds', false);
|
||||
|
@ -32,6 +37,10 @@ class FreshRSS_javascript_Controller extends FreshRSS_ActionController {
|
|||
$this->view->feeds = $feedDAO->listFeedsOrderUpdate(FreshRSS_Context::userConf()->ttl_default);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Minz_ConfigurationNamespaceException
|
||||
* @throws Minz_PDOConnectionException
|
||||
*/
|
||||
public function nbUnreadsPerFeedAction(): void {
|
||||
header('Content-Type: application/json; charset=UTF-8');
|
||||
$catDAO = FreshRSS_Factory::createCategoryDao();
|
||||
|
|
|
@ -67,18 +67,25 @@ class FreshRSS_stats_Controller extends FreshRSS_ActionController {
|
|||
|
||||
$feedByCategory = [];
|
||||
$feedByCategory_calculated = $statsDAO->calculateFeedByCategory();
|
||||
for ($i = 0; $i < count($feedByCategory_calculated); $i++) {
|
||||
|
||||
$iMax = count($feedByCategory_calculated);
|
||||
for ($i = 0; $i < $iMax; $i++) {
|
||||
$feedByCategory['label'][$i] = $feedByCategory_calculated[$i]['label'];
|
||||
$feedByCategory['data'][$i] = $feedByCategory_calculated[$i]['data'];
|
||||
}
|
||||
|
||||
$this->view->feedByCategory = $feedByCategory;
|
||||
|
||||
$entryByCategory = [];
|
||||
$entryByCategory_calculated = $statsDAO->calculateEntryByCategory();
|
||||
for ($i = 0; $i < count($entryByCategory_calculated); $i++) {
|
||||
|
||||
$iMax = count($entryByCategory_calculated);
|
||||
|
||||
for ($i = 0; $i < $iMax; $i++) {
|
||||
$entryByCategory['label'][$i] = $entryByCategory_calculated[$i]['label'];
|
||||
$entryByCategory['data'][$i] = $entryByCategory_calculated[$i]['data'];
|
||||
}
|
||||
|
||||
$this->view->entryByCategory = $entryByCategory;
|
||||
|
||||
$this->view->topFeed = $statsDAO->calculateTopFeed();
|
||||
|
|
|
@ -63,6 +63,10 @@ class FreshRSS_tag_Controller extends FreshRSS_ActionController {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Minz_ConfigurationNamespaceException
|
||||
* @throws Minz_PDOConnectionException
|
||||
*/
|
||||
public function deleteAction(): void {
|
||||
if (!FreshRSS_Auth::hasAccess()) {
|
||||
Minz_Error::error(403);
|
||||
|
@ -84,7 +88,6 @@ class FreshRSS_tag_Controller extends FreshRSS_ActionController {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This action updates the given tag.
|
||||
*/
|
||||
|
@ -129,6 +132,7 @@ class FreshRSS_tag_Controller extends FreshRSS_ActionController {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public function getTagsForEntryAction(): void {
|
||||
if (!FreshRSS_Auth::hasAccess() && !FreshRSS_Context::systemConf()->allow_anonymous) {
|
||||
Minz_Error::error(403);
|
||||
|
@ -141,6 +145,10 @@ class FreshRSS_tag_Controller extends FreshRSS_ActionController {
|
|||
$this->view->tagsForEntry = $tagDAO->getTagsForEntry($id_entry) ?: [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Minz_ConfigurationNamespaceException
|
||||
* @throws Minz_PDOConnectionException
|
||||
*/
|
||||
public function addAction(): void {
|
||||
if (!FreshRSS_Auth::hasAccess()) {
|
||||
Minz_Error::error(403);
|
||||
|
|
|
@ -168,6 +168,9 @@ class FreshRSS_update_Controller extends FreshRSS_ActionController {
|
|||
via Git, if available.
|
||||
Else via system configuration auto_update_url
|
||||
*/
|
||||
/**
|
||||
* @throws FreshRSS_Context_Exception
|
||||
*/
|
||||
public function checkAction(): void {
|
||||
FreshRSS_View::prependTitle(_t('admin.update.title') . ' · ');
|
||||
$this->view->_path('update/index.phtml');
|
||||
|
@ -257,6 +260,9 @@ class FreshRSS_update_Controller extends FreshRSS_ActionController {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws FreshRSS_Context_Exception
|
||||
*/
|
||||
public function applyAction(): void {
|
||||
if (FreshRSS_Context::systemConf()->disable_update || !file_exists(UPDATE_FILENAME) || !touch(FRESHRSS_PATH . '/index.html')) {
|
||||
Minz_Request::forward(['c' => 'update'], true);
|
||||
|
|
|
@ -19,7 +19,10 @@ class FreshRSS_user_Controller extends FreshRSS_ActionController {
|
|||
return @file_exists(USERS_PATH . '/' . $username . '/config.php');
|
||||
}
|
||||
|
||||
/** @param array<string,mixed> $userConfigUpdated */
|
||||
/**
|
||||
* @param array<string,mixed> $userConfigUpdated
|
||||
* @throws FreshRSS_Context_Exception
|
||||
*/
|
||||
public static function updateUser(string $user, ?string $email, string $passwordPlain, array $userConfigUpdated = []): bool {
|
||||
$userConfig = get_user_configuration($user);
|
||||
if ($userConfig === null) {
|
||||
|
@ -48,10 +51,12 @@ class FreshRSS_user_Controller extends FreshRSS_ActionController {
|
|||
}
|
||||
}
|
||||
|
||||
$ok = $userConfig->save();
|
||||
return $ok;
|
||||
return $userConfig->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws FreshRSS_Context_Exception
|
||||
*/
|
||||
public function updateAction(): void {
|
||||
if (!FreshRSS_Auth::hasAccess('admin')) {
|
||||
Minz_Error::error(403);
|
||||
|
@ -82,6 +87,7 @@ class FreshRSS_user_Controller extends FreshRSS_ActionController {
|
|||
|
||||
/**
|
||||
* This action displays the user profile page.
|
||||
* @throws FreshRSS_Context_Exception
|
||||
*/
|
||||
public function profileAction(): void {
|
||||
if (!FreshRSS_Auth::hasAccess()) {
|
||||
|
@ -146,6 +152,10 @@ class FreshRSS_user_Controller extends FreshRSS_ActionController {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Minz_ConfigurationNamespaceException
|
||||
* @throws Minz_PDOConnectionException
|
||||
*/
|
||||
public function purgeAction(): void {
|
||||
if (!FreshRSS_Auth::hasAccess('admin')) {
|
||||
Minz_Error::error(403);
|
||||
|
@ -165,6 +175,8 @@ class FreshRSS_user_Controller extends FreshRSS_ActionController {
|
|||
|
||||
/**
|
||||
* This action displays the user management page.
|
||||
* @throws FreshRSS_Context_Exception
|
||||
* @throws Exception
|
||||
*/
|
||||
public function manageAction(): void {
|
||||
if (!FreshRSS_Auth::hasAccess('admin')) {
|
||||
|
@ -280,6 +292,7 @@ class FreshRSS_user_Controller extends FreshRSS_ActionController {
|
|||
* - new_user_passwordPlain
|
||||
* - r (i.e. a redirection url, optional)
|
||||
*
|
||||
* @throws FreshRSS_Context_Exception
|
||||
* @todo clean up this method. Idea: write a method to init a user with basic information.
|
||||
*/
|
||||
public function createAction(): void {
|
||||
|
@ -379,6 +392,11 @@ class FreshRSS_user_Controller extends FreshRSS_ActionController {
|
|||
Minz_Request::forward($redirect_url, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws FreshRSS_Context_Exception
|
||||
* @throws Minz_ConfigurationNamespaceException
|
||||
* @throws Minz_PDOConnectionException
|
||||
*/
|
||||
public static function deleteUser(string $username): bool {
|
||||
$ok = self::checkUsername($username);
|
||||
if ($ok) {
|
||||
|
@ -418,6 +436,7 @@ class FreshRSS_user_Controller extends FreshRSS_ActionController {
|
|||
* user doesn’t exist.
|
||||
*
|
||||
* It returns 403 if user isn’t logged in and `username` param isn’t passed.
|
||||
* @throws FreshRSS_Context_Exception
|
||||
*/
|
||||
public function validateEmailAction(): void {
|
||||
if (!FreshRSS_Context::systemConf()->force_email_validation) {
|
||||
|
@ -483,6 +502,7 @@ class FreshRSS_user_Controller extends FreshRSS_ActionController {
|
|||
* It returns 403 error if the user is not logged in or 404 if request is
|
||||
* not POST. Else it redirects silently to the index if user has already
|
||||
* validated its email, or to the user#validateEmail route.
|
||||
* @throws FreshRSS_Context_Exception
|
||||
*/
|
||||
public function sendValidationEmailAction(): void {
|
||||
if (!FreshRSS_Auth::hasAccess()) {
|
||||
|
@ -525,6 +545,7 @@ class FreshRSS_user_Controller extends FreshRSS_ActionController {
|
|||
* Request parameter is:
|
||||
* - username
|
||||
*
|
||||
* @throws FreshRSS_Context_Exception
|
||||
* @todo clean up this method. Idea: create a User->clean() method.
|
||||
*/
|
||||
public function deleteAction(): void {
|
||||
|
@ -618,6 +639,9 @@ class FreshRSS_user_Controller extends FreshRSS_ActionController {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function detailsAction(): void {
|
||||
if (!FreshRSS_Auth::hasAccess('admin')) {
|
||||
Minz_Error::error(403);
|
||||
|
@ -637,7 +661,10 @@ class FreshRSS_user_Controller extends FreshRSS_ActionController {
|
|||
FreshRSS_View::prependTitle($username . ' · ' . _t('gen.menu.user_management') . ' · ');
|
||||
}
|
||||
|
||||
/** @return array{'feed_count':int,'article_count':int,'database_size':int,'language':string,'mail_login':string,'enabled':bool,'is_admin':bool,'last_user_activity':string,'is_default':bool} */
|
||||
/**
|
||||
* @return array{'feed_count':int,'article_count':int,'database_size':int,'language':string,'mail_login':string,'enabled':bool,'is_admin':bool,'last_user_activity':string,'is_default':bool}
|
||||
* @throws FreshRSS_Context_Exception
|
||||
*/
|
||||
private function retrieveUserDetails(string $username): array {
|
||||
$feedDAO = FreshRSS_Factory::createFeedDao($username);
|
||||
$entryDAO = FreshRSS_Factory::createEntryDao($username);
|
||||
|
|
Loading…
Reference in New Issue