<?php
|
namespace JVBase\managers;
|
|
use JVBase\managers\Notifications\Content;
|
use JVBase\managers\Notifications\EmailDigests;
|
use JVBase\managers\Notifications\Notifications;
|
use JVBase\managers\Notifications\Preferences;
|
|
if (!defined('ABSPATH')) {
|
exit; // Exit if accessed directly
|
}
|
/**
|
* NotificationManager - Centralized notification system for edmonton.ink
|
*
|
* This refactored class handles notifications with a clearer separation of concerns
|
* between system notifications and content updates. It uses the new database structure
|
* to efficiently track and display notifications.
|
*/
|
class NotificationManager
|
{
|
protected Notifications $notifications;
|
protected Content $content;
|
protected EmailDigests $digest;
|
protected Preferences $preferences;
|
|
public function __construct()
|
{
|
$this->notifications = new Notifications();
|
$this->content = new Content();
|
$this->digest = new EmailDigests();
|
$this->preferences = new Preferences();
|
}
|
|
/************************************************
|
* PREFERENCES
|
************************************************/
|
public function getUsersByFrequency(string $frequency):array
|
{
|
return $this->preferences->getUsersByFrequency($frequency);
|
}
|
|
public function getUserSubscriptions(int $userID, string $frequency):array
|
{
|
return $this->preferences->getUserSubscriptions($userID, $frequency);
|
}
|
|
public function addUserPreference(int $userID, int $item_id, string $item_type, string $frequency):bool
|
{
|
return $this->preferences->addUserPreference($userID, $item_id, $item_type, $frequency);
|
}
|
|
public function deleteUserPreference(int $userID, int $item_id, string $item_type):bool
|
{
|
return $this->preferences->deleteUserPreference($userID, $item_id, $item_type);
|
}
|
/************************************************
|
* NOTIFICATIONS
|
************************************************/
|
public function notify(int|array $user_ids, string $notification_type, int $fromUser = 0, array $args = []):bool
|
{
|
return $this->notifications->notify($user_ids, $notification_type, $fromUser, $args);
|
}
|
public function unnotify(int|array $user_ids, string $notification_type, int $fromUser = 0, array $args = []):bool
|
{
|
return $this->notifications->unnotify($user_ids, $notification_type, $fromUser, $args);
|
}
|
public function getUserNotifications(int $user_id, array $args = []):array
|
{
|
return $this->notifications->getUserNotifications($user_id, $args);
|
}
|
|
public function markRead(int $userID, int|array $notification_id):bool
|
{
|
return $this->notifications->markRead($userID, $notification_id);
|
}
|
public function markDismissed(int $userID, int|array $notification_id):bool
|
{
|
return $this->notifications->markDismissed($userID, $notification_id);
|
}
|
public function markActioned(int $userID, int|array $notification_id, array $result = []):bool
|
{
|
return $this->notifications->markActioned($userID, $notification_id, $result);
|
}
|
|
public function getNotificationTypes(bool $all = false):array
|
{
|
return $this->notifications->getNotificationTypes($all);
|
}
|
|
/************************************************
|
* CONTENT NOTIFICATIONS
|
* These are pooled notifications of new content for:
|
* - a particular artist
|
* - a particular term
|
************************************************/
|
/************************************************
|
* EMAIL DIGESTS
|
************************************************/
|
}
|