Jake Vanderwerf
2026-05-12 c32ed859f4abd1591c882f4f2a6ee16b1ec275e2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?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
    ************************************************/
}