aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2024-10-14 09:35:41 +0200
committerGravatar GitHub <noreply@github.com> 2024-10-14 09:35:41 +0200
commitdf763eb8b34b9823511d93ec078d4644d3e6ff64 (patch)
tree0dcdf0aa45e8f3a1b3ebe154277bac2c7fa960f0
parent256dcc21bb222184d5e917ea57cec334b74b96f4 (diff)
Add hook entries_favorite (#6880)
Called when entries are starred or unstarred
-rw-r--r--app/Models/EntryDAO.php1
-rw-r--r--docs/fr/developers/03_Backend/05_Extensions.md2
-rw-r--r--lib/Minz/ExtensionManager.php4
3 files changed, 7 insertions, 0 deletions
diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php
index e22650f0d..23874a8e1 100644
--- a/app/Models/EntryDAO.php
+++ b/app/Models/EntryDAO.php
@@ -362,6 +362,7 @@ SQL;
$values = array_merge($values, $ids);
$stm = $this->pdo->prepare($sql);
if ($stm !== false && $stm->execute($values)) {
+ Minz_ExtensionManager::callHook('entries_favorite', $ids, $is_favorite);
return $stm->rowCount();
} else {
$info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo();
diff --git a/docs/fr/developers/03_Backend/05_Extensions.md b/docs/fr/developers/03_Backend/05_Extensions.md
index 61d0589ef..8d2866f26 100644
--- a/docs/fr/developers/03_Backend/05_Extensions.md
+++ b/docs/fr/developers/03_Backend/05_Extensions.md
@@ -233,6 +233,8 @@ The following events are available:
executed when a feed is refreshed and new entries will be imported into
the database. The new entry (instance of FreshRSS\_Entry) will be passed
as parameter.
+* `entries_favorite` (`function(array $ids, bool $is_favorite): void`):
+ will be executed when some entries are marked or unmarked as favorites (starred)
* `feed_before_actualize` (`function($feed) -> Feed | null`): will be
executed when a feed is updated. The feed (instance of FreshRSS\_Feed)
will be passed as parameter.
diff --git a/lib/Minz/ExtensionManager.php b/lib/Minz/ExtensionManager.php
index 2d7c92d6b..b3756372e 100644
--- a/lib/Minz/ExtensionManager.php
+++ b/lib/Minz/ExtensionManager.php
@@ -26,6 +26,10 @@ final class Minz_ExtensionManager {
'list' => array(),
'signature' => 'OneToOne',
),
+ 'entries_favorite' => [ // function(array $ids, bool $is_favorite): void
+ 'list' => [],
+ 'signature' => 'PassArguments',
+ ],
'entry_auto_read' => array( // function(FreshRSS_Entry $entry, string $why): void
'list' => array(),
'signature' => 'PassArguments',