vB_Library_Notification
extends vB_Library
in package
vB_Library_Notification
Tags
Table of Contents
- DATASTOREKEY_TRIGGERS = 'vBNotificationEvents'
- DATASTOREKEY_TYPES = 'vBNotificationTypes'
- $assertor : mixed
- DB Assertor object
- $emailQueue : mixed
- Array An array of queued emails This array is built by the various generate{}Notifications() methods, and cleared in sendEmailNotifications().
- $fcmQueue : mixed
- $insertsPerBulk : mixed
- Int Number of rows per assert that insertNotificationsToDB() will insert.
- $instance : mixed
- $notificationQueue : mixed
- Array[String] An array of queued notifications awaiting DB insert.
- $subscribers : mixed
- __serialize() : mixed
- __sleep() : mixed
- __unserialize() : mixed
- __wakeup() : mixed
- cleanupDefunctNotificationClasses() : mixed
- Go through `notificationtype` & `notificationevent` records and remove any classes that no longer exist. Useful when deleting or reoganizing notification types.
- clearCache() : mixed
- deleteNotification() : mixed
- Deletes specified notificationds, ignoring ownership
- fetchNotificationCountForUser() : int
- Returns the count of specified user's notifications based on provided filterParams
- fetchNotificationsForCurrentUser() : array<string|int, mixed>
- Return current user's notifications from DB.
- fetchTotalNotificationCountForUser() : int
- Returns the total count of specified user's notifications
- getContentInstance() : mixed
- getDefaultTypes() : mixed
- Returns default notification types' classes
- getInsertPerBulk() : int
- Returns class variable $insertsPerBulk. Also @see setInsertPerBulk()
- getNotificationEvents() : mixed
- getNotificationQueue() : array<string|int, mixed>
- Returns the class variable $notificationQueue. Used for testing.
- getNotificationTypes() : mixed
- insertNotificationEventsToDB() : mixed
- insertNotificationsToDB() : mixed
- Insert all items in $this->notificationQueue into the database.
- insertNotificationTypeToDB() : mixed
- Only used during install/update. Insert this particular notification type into DB, populating the notificationtype, & notificationevent categories.
- instance() : vB_PageCache
- Returns singleton instance of self.
- monitorWords() : mixed
- Checks if the text contains monitored words, and if so, sends notifications to admins and moderators if the setting is on.
- setInsertPerBulk() : mixed
- Sets $this->insertsPerBulk, which is the maximum number of rows that insertNotificationsToDB() will insert into the DB in each database assert.
- triggerNotificationEvent() : mixed
- __construct() : mixed
- checkCombineNotifications() : mixed
- getLibraryClassNameInternal() : mixed
- processFCMQueue() : mixed
- reloadNotificationEventsFromDB() : mixed
- reloadNotificationTypesFromDB() : mixed
- sendEmailNotification() : mixed
- sendEmailNotifications() : mixed
- sendLegacyEmailNotification() : mixed
- updateNotificationClassInDB() : mixed
- Updates the old class name associated with a type, and changes it to the new class name.
Constants
DATASTOREKEY_TRIGGERS
public
mixed
DATASTOREKEY_TRIGGERS
= 'vBNotificationEvents'
DATASTOREKEY_TYPES
public
mixed
DATASTOREKEY_TYPES
= 'vBNotificationTypes'
Properties
$assertor
DB Assertor object
protected
mixed
$assertor
$emailQueue
Array An array of queued emails This array is built by the various generate{}Notifications() methods, and cleared in sendEmailNotifications().
protected
mixed
$emailQueue
Structure: Array[] = Array( 'email' => Str 'username' => Str 'languageid' => Int 'recipient' => $recipient, 'sender' => $notificationData['sender'], 'lookupid' => $notificationData['lookupid'], 'sentbynodeid' => $notificationData['sentbynodeid'], 'customdata' => $notificationData['customdata'], 'typeid' => $notificationData['typeid'], 'lastsenttime' => $lastsenttime, );
$fcmQueue
protected
mixed
$fcmQueue
$insertsPerBulk
Int Number of rows per assert that insertNotificationsToDB() will insert.
protected
mixed
$insertsPerBulk
= 2000
@see insertNotificationsToDB() for more information.
$instance
protected
static mixed
$instance
= array()
$notificationQueue
Array[String] An array of queued notifications awaiting DB insert.
protected
mixed
$notificationQueue
This array is built by the various generate}Notifications() methods, and cleared when inserted into the DB by insertNotificationsToDB().
Structure: TODO...
Note that the key-string is based on the table's UNIQUE KEY: TODO...
Note that the following columns are never set during notification generation: 'lastreadtime' => INT(10) UNSIGNED NOT NULL DEFAULT '0', 'lastcheckedtime' => INT(10) UNSIGNED NOT NULL DEFAULT '0', These are meant to be used for read/delete, and thus should only be set by updates from the message center / node visit (VBV-4958).
$subscribers
protected
mixed
$subscribers
Methods
__serialize()
public
__serialize() : mixed
Return values
mixed —__sleep()
public
__sleep() : mixed
Return values
mixed —__unserialize()
public
__unserialize(mixed $serialized) : mixed
Parameters
- $serialized : mixed
Return values
mixed —__wakeup()
public
__wakeup() : mixed
Return values
mixed —cleanupDefunctNotificationClasses()
Go through `notificationtype` & `notificationevent` records and remove any classes that no longer exist. Useful when deleting or reoganizing notification types.
public
cleanupDefunctNotificationClasses() : mixed
Return values
mixed —clearCache()
public
static clearCache() : mixed
Return values
mixed —deleteNotification()
Deletes specified notificationds, ignoring ownership
public
deleteNotification(int|array<string|int, int> $notificationids) : mixed
Parameters
- $notificationids : int|array<string|int, int>
-
Array of notificationids to delete.
Return values
mixed —fetchNotificationCountForUser()
Returns the count of specified user's notifications based on provided filterParams
public
fetchNotificationCountForUser(int $userid[, array<string|int, mixed> $data = array() ]) : int
Parameters
- $userid : int
- $data : array<string|int, mixed> = array()
-
Optional. If not empty, should have
- 'typeid'
Return values
int —fetchNotificationsForCurrentUser()
Return current user's notifications from DB.
public
fetchNotificationsForCurrentUser([array<string|int, mixed> $data = array() ]) : array<string|int, mixed>
Parameters
- $data : array<string|int, mixed> = array()
-
Fields
- 'sortDir' Optional String sort direction. If not "ASC", sort order will be DESC. The sort field is notification.lastsenttime
- 'perpage' Optional unsigned integer results per page. Default is 20 per page.
- 'page' Optional unsigned integer page # to return. Default is the first page.
- 'showdetail' Optional boolean, set true to display details about node ratings.
- 'about' Optional String legacy about string.
- 'typename' Optional String Notification typename. If 'about' is set, that will be used instead. If a valid 'about & 'typename' is set, only notifications of that type will be returned.
- 'readFilter' Optional String filter by new/dismissed status. If NOT SET, function will default to 'unread_only'. If is SET, the expected values are ('unread_only'| 'read_only'|'*'). If SET but not to 'unread_only' OR 'read_only', function will return both new & dismissed notifications.
- 'skipIds' Optional Int[], only used internally by vB_Api_Notification::dismissNotification()
Return values
array<string|int, mixed> —Keyed by integer notificationid, contains all data from the notification table and possibly the following fields:
- 'categoryname'
- 'typename'
- 'sender_username'
- 'sender_avatarpath' For CONTENT category
- 'aboutstartertitle'
- 'aboutstarterrouteid'
- 'otherParticipantsCount' For POLLVOTE category
- 'votes' poll.votes for sentbynodeid
- 'lastvote' poll.lastvote for sentbynodeid
- 'otherVotersCount' For NODEACTION category's NODEACTION_LIKE type:
- 'showdetail' Based on user's genericpermissions.canseewholiked permission
- 'totalRatersCount'
- 'otherRatersCount'
.. TODO finish this docblock
fetchTotalNotificationCountForUser()
Returns the total count of specified user's notifications
public
fetchTotalNotificationCountForUser(int $userid) : int
Parameters
- $userid : int
Return values
int —getContentInstance()
public
static getContentInstance(mixed $contenttypeid) : mixed
Parameters
- $contenttypeid : mixed
Return values
mixed —getDefaultTypes()
Returns default notification types' classes
public
getDefaultTypes() : mixed
Tags
Return values
mixed —getInsertPerBulk()
Returns class variable $insertsPerBulk. Also @see setInsertPerBulk()
public
getInsertPerBulk() : int
Return values
int —getNotificationEvents()
public
getNotificationEvents() : mixed
Return values
mixed —getNotificationQueue()
Returns the class variable $notificationQueue. Used for testing.
public
getNotificationQueue() : array<string|int, mixed>
Return values
array<string|int, mixed> —@see $notificationQueue
getNotificationTypes()
public
getNotificationTypes() : mixed
Return values
mixed —insertNotificationEventsToDB()
public
insertNotificationEventsToDB(mixed $class) : mixed
Parameters
- $class : mixed
Return values
mixed —insertNotificationsToDB()
Insert all items in $this->notificationQueue into the database.
public
insertNotificationsToDB() : mixed
The actual bulk of this function should probably live in the vBForum querydefs file.
Return values
mixed —insertNotificationTypeToDB()
Only used during install/update. Insert this particular notification type into DB, populating the notificationtype, & notificationevent categories.
public
insertNotificationTypeToDB(string $class) : mixed
Parameters
- $class : string
-
Class name of the new notification type. The class must be a subclass of vB_Notification, and placed in a location the auto-loader can find.
Return values
mixed —instance()
Returns singleton instance of self.
public
static instance(mixed $class) : vB_PageCache
Parameters
- $class : mixed
Return values
vB_PageCache —- Reference to singleton instance of the cache handler
monitorWords()
Checks if the text contains monitored words, and if so, sends notifications to admins and moderators if the setting is on.
public
monitorWords(mixed $text, mixed $type, mixed $nodeid[, mixed $userid = null ][, mixed $insertNotifications = true ], mixed $currentuserid) : mixed
Parameters
- $text : mixed
- $type : mixed
- $nodeid : mixed
- $userid : mixed = null
- $insertNotifications : mixed = true
- $currentuserid : mixed
Return values
mixed —setInsertPerBulk()
Sets $this->insertsPerBulk, which is the maximum number of rows that insertNotificationsToDB() will insert into the DB in each database assert.
public
setInsertPerBulk(int $newInsertsPerBulk) : mixed
Set this before calling insertNotificationsToDB() to affect the inserts.
Parameters
- $newInsertsPerBulk : int
-
Will have no affect if smaller than 1.
Return values
mixed —triggerNotificationEvent()
public
triggerNotificationEvent(string $eventstring[, array<string|int, mixed> $data = array() ][, array<string|int, int> $recipients = array() ]) : mixed
Parameters
- $eventstring : string
- $data : array<string|int, mixed> = array()
-
Array of event data, or notification data Expected for notification data: - int sentbynodeid - int sender
- $recipients : array<string|int, int> = array()
-
List of recipients, only required for content-less notification types, like SenderAcceptedFollow, SenderAcceptedFollow
Return values
mixed —__construct()
protected
__construct() : mixed
Return values
mixed —checkCombineNotifications()
protected
checkCombineNotifications(mixed $key, mixed $notification, mixed $notificationData) : mixed
Parameters
- $key : mixed
- $notification : mixed
- $notificationData : mixed
Return values
mixed —getLibraryClassNameInternal()
protected
static getLibraryClassNameInternal(mixed $controller) : mixed
Parameters
- $controller : mixed
Return values
mixed —processFCMQueue()
protected
processFCMQueue() : mixed
Return values
mixed —reloadNotificationEventsFromDB()
protected
reloadNotificationEventsFromDB() : mixed
Return values
mixed —reloadNotificationTypesFromDB()
protected
reloadNotificationTypesFromDB() : mixed
Return values
mixed —sendEmailNotification()
protected
sendEmailNotification(mixed $data) : mixed
Parameters
- $data : mixed
Return values
mixed —sendEmailNotifications()
protected
sendEmailNotifications() : mixed
Return values
mixed —sendLegacyEmailNotification()
protected
sendLegacyEmailNotification(mixed $data) : mixed
Parameters
- $data : mixed
Return values
mixed —updateNotificationClassInDB()
Updates the old class name associated with a type, and changes it to the new class name.
protected
updateNotificationClassInDB(mixed $typename, mixed $oldclass, mixed $newclass) : mixed
Parameters
- $typename : mixed
- $oldclass : mixed
- $newclass : mixed