From b7bd18148e65bbdd6be442036a295eb43ca1501e Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Tue, 14 Oct 2025 15:43:43 +0200 Subject: Option to show user labels instead of tags in RSS share (#8112) * Option to show user labels instead of tags in RSS share fix https://github.com/FreshRSS/FreshRSS/discussions/8108#discussioncomment-14668813 image --- app/Models/UserQuery.php | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'app/Models/UserQuery.php') diff --git a/app/Models/UserQuery.php b/app/Models/UserQuery.php index 077ae0b90..26264fa24 100644 --- a/app/Models/UserQuery.php +++ b/app/Models/UserQuery.php @@ -21,6 +21,7 @@ class FreshRSS_UserQuery { private string $token = ''; private bool $shareRss = false; private bool $shareOpml = false; + private bool $publishLabelsInsteadOfTags = false; /** @var array $categories where the key is the category ID */ private array $categories; /** @var array $labels where the key is the label ID */ @@ -43,7 +44,7 @@ class FreshRSS_UserQuery { /** * @param array{get?:string,name?:string,order?:string,search?:string,state?:int,url?:string,token?:string, - * shareRss?:bool,shareOpml?:bool,description?:string,imageUrl?:string} $query + * shareRss?:bool,shareOpml?:bool,publishLabelsInsteadOfTags?:bool,description?:string,imageUrl?:string} $query * @param array $categories * @param array $labels */ @@ -75,6 +76,7 @@ class FreshRSS_UserQuery { unset($link['name']); unset($link['shareOpml']); unset($link['shareRss']); + unset($link['publishLabelsInsteadOfTags']); $this->url = Minz_Url::display(['params' => $link]); } } else { @@ -92,6 +94,9 @@ class FreshRSS_UserQuery { if (isset($query['shareOpml'])) { $this->shareOpml = $query['shareOpml']; } + if (isset($query['publishLabelsInsteadOfTags'])) { + $this->publishLabelsInsteadOfTags = (bool)$query['publishLabelsInsteadOfTags']; + } if (isset($query['description'])) { $this->description = $query['description']; } @@ -109,7 +114,9 @@ class FreshRSS_UserQuery { /** * Convert the current object to an array. * - * @return array{'get'?:string,'name'?:string,'order'?:string,'search'?:string,'state'?:int,'url'?:string,'token'?:string} + * @return array{get?:string,name?:string,order?:string,search?:string, + * state?:int,url?:string,token?:string,shareRss?:bool,shareOpml?:bool, + * publishLabelsInsteadOfTags?:bool,description?:string,imageUrl?:string} */ public function toArray(): array { return array_filter([ @@ -122,6 +129,7 @@ class FreshRSS_UserQuery { 'token' => $this->token, 'shareRss' => $this->shareRss, 'shareOpml' => $this->shareOpml, + 'publishLabelsInsteadOfTags' => $this->publishLabelsInsteadOfTags, 'description' => $this->description, 'imageUrl' => $this->imageUrl, ], fn($v): bool => $v !== '' && $v !== 0 && $v !== false); @@ -279,6 +287,14 @@ class FreshRSS_UserQuery { return $this->shareOpml; } + public function setPublishLabelsInsteadOfTags(bool $publishLabelsInsteadOfTags): void { + $this->publishLabelsInsteadOfTags = $publishLabelsInsteadOfTags; + } + + public function publishLabelsInsteadOfTags(): bool { + return $this->publishLabelsInsteadOfTags; + } + protected function sharedUrl(bool $xmlEscaped = true): string { $currentUser = Minz_User::name() ?? ''; return Minz_Url::display("/api/query.php?user={$currentUser}&t={$this->token}", $xmlEscaped ? 'html' : '', true); -- cgit v1.2.3