class Notification

Class Notification

Constants

deprecated TYPE_ACTIVITY

deprecated TYPE_TODO

deprecated TYPE_MESSAGE

deprecated TYPES

deprecated STATUS_READ

RETURN_TYPE_MODEL_COLLECTION

Methods

add(mixed $instance_id, int|int[] $user_id, string $token, string $status = NotificationState::NEW, string $subject = null, string $plaintext = null, string $html = null, string $link = null, string $icon = 'icon-info', string $type = NotificationType::ACTIVITY) deprecated

Add a Notification to System Using $this->mod->notify()

add_vars(mixed $instance_id, mixed $user_id, string $token, $status, VarsTemplate $vars, mixed $link = null, string $icon = null, string $type = NotificationType::ACTIVITY)

Add a Notification to System with Vars Using $this->mod->notify_vars()

int
count_activity()

Count notifications

int|mixed
count_messages()

Count messages

int|mixed
count_todos()

Count todos

bool
email(mixed $email, string $subject, string $text, bool|string $cc = false, bool|string $bcc = false, array|bool $attachment = false, string $input_format = 'plaintext', array $optional = array())

Send an email with notification template

getActivityNotifications(string[] $status = [], int $user_id = null, int $timestamp = null)

This function returns a scoped but unloaded collection. You can apply limit and additional scopes

getMessageNotifications(int $user_id = null, string[] $status = [], int $timestamp = null)

This function returns a scoped but unloaded collection. You can apply limit and additional scopes

getTodoNotifications(int $user_id = null)

This function returns a scoped but unloaded collection. You can apply limit and additional scopes

array
getTodos()

Returns the todo notification with added features:

  • Lookbook Friend requests
  • Pending workflows

get_attachment_by_file($file)

No description

xelos_global_template
get_mail_template(string $format = 'html')

Get mail Template

get_notification(mixed $instance_id, mixed $user_id, mixed $token)

Get single notification by token to discover information before notify

get_notifications(int $user_id, string[] $status = [], int $timestamp = null, array $type_restriction = [], int|int[] $limit = null)

get all notifications

invalidate_counts(int $user_id = null)

Invalidate counts

bool
mark(Notification[] $notifications, mixed $status)

mark any status by Notification

bool
mark_read(int $user_id, string $type = NotificationType::ACTIVITY)

mark seen notifications by user_id and typ

bool
mark_seen(int $user_id)

mark seen notifications by user_id and typ

messenger(mixed $recipient_users, mixed $subject, mixed $text)

Send Messenger-Message

publish(NotificationMessage $notificationMessage)

Add Notificaton Message to Queue

int
remove(mixed $instance_id, string $token, mixed $user_id = false)

Remove an existing notification (by Instance ID and Token) for all users or specific users Using $this->mod->notify()

bool
send(int|int[] $user_ids, string $subject, $text, bool $is_html = false, array $allowed_sending_methods = array('email', 'messenger'), array $attachment = false) deprecated

No description

bool
send_vars(mixed $user_ids, VarsTemplate $vars_object, array $allowed_sending_methods = array('email', 'messenger'), $attachment = false)

Send with Vars Object

Details

at line 333
add(mixed $instance_id, int|int[] $user_id, string $token, string $status = NotificationState::NEW, string $subject = null, string $plaintext = null, string $html = null, string $link = null, string $icon = 'icon-info', string $type = NotificationType::ACTIVITY) deprecated

deprecated Use NotificationBuilder::create()->buildAndPublish()

Add a Notification to System Using $this->mod->notify()

Parameters

mixed $instance_id

Instance-ID

int|int[] $user_id

User-ID or Array of User-IDs

string $token

Token for updates for this Notification

string $status

('new','processed','seen','read')

string $subject

Subject without HTML

string $plaintext

Plaintext/Shortmessage without HTML

string $html

HTML-Message

string $link

Link as URL or as Array (get_current_url)

string $icon

FontAwesome-Icon Class

string $type

message, todo, activity, admin

Exceptions

Exception

at line 293
add_vars(mixed $instance_id, mixed $user_id, string $token, $status, VarsTemplate $vars, mixed $link = null, string $icon = null, string $type = NotificationType::ACTIVITY)

Add a Notification to System with Vars Using $this->mod->notify_vars()

Parameters

mixed $instance_id

Instance-ID

mixed $user_id

User-ID or Array of Users

string $token

Token for updates for this Notification

$status
VarsTemplate $vars
mixed $link

Link as URL or as Array (get_current_url)

string $icon

FontAwesome-Icon

string $type

Type of notification

at line 803
int count_activity()

Count notifications

Return Value

int

at line 742
int|mixed count_messages()

Count messages

Return Value

int|mixed

at line 761
int|mixed count_todos()

Count todos

Return Value

int|mixed

at line 158
bool email(mixed $email, string $subject, string $text, bool|string $cc = false, bool|string $bcc = false, array|bool $attachment = false, string $input_format = 'plaintext', array $optional = array())

Send an email with notification template

Parameters

mixed $email

email (string or array)

string $subject

subject

string $text

text

bool|string $cc

or array CC Emails (if string , or ; as separator)

bool|string $bcc

or array BCC Emails (if string , or ; as separator)

array|bool $attachment

Attachment of format: $attachment['binary'],$attachment['name'], $attachment['type'], $attachment['encoding'] = (default) base64, $attachment['embedded'] for embedded images

string $input_format

InputFormat [plaintext|html|fullhtml] Important: it's NOT the target format for the mail content (instead it is swapped)

  • plaintext | will be transformed into HTML with system-template
  • html | plaintext version will be generated with reverse_markdown
  • fullhtml | won't be transformed in any way and will be sent without system-template
array $optional

Return Value

bool

success

at line 701
ModelCollection getActivityNotifications(string[] $status = [], int $user_id = null, int $timestamp = null)

This function returns a scoped but unloaded collection. You can apply limit and additional scopes

Parameters

string[] $status
int $user_id
int $timestamp

Return Value

ModelCollection

at line 686
ModelCollection getMessageNotifications(int $user_id = null, string[] $status = [], int $timestamp = null)

This function returns a scoped but unloaded collection. You can apply limit and additional scopes

Parameters

int $user_id
string[] $status
int $timestamp

Return Value

ModelCollection

at line 714
ModelCollection getTodoNotifications(int $user_id = null)

This function returns a scoped but unloaded collection. You can apply limit and additional scopes

Parameters

int $user_id

Return Value

ModelCollection

at line 592
array getTodos()

Returns the todo notification with added features:

  • Lookbook Friend requests
  • Pending workflows

Return Value

array

['contacts' => "Friend Requests", 'workflows' => "Pending workflows", 'notifications' => 'notifications']

at line 827
get_attachment_by_file($file)

No description

Parameters

$file

at line 247
xelos_global_template get_mail_template(string $format = 'html')

Get mail Template

Parameters

string $format

Format (html, plain)

Return Value

xelos_global_template

at line 580
Notification get_notification(mixed $instance_id, mixed $user_id, mixed $token)

Get single notification by token to discover information before notify

Parameters

mixed $instance_id
mixed $user_id
mixed $token

Return Value

Notification

at line 668
ModelCollection get_notifications(int $user_id, string[] $status = [], int $timestamp = null, array $type_restriction = [], int|int[] $limit = null)

get all notifications

Parameters

int $user_id
string[] $status
int $timestamp

Will return only notifications which have been updated AFTER this time

array $type_restriction
int|int[] $limit

Return Value

ModelCollection

at line 726
invalidate_counts(int $user_id = null)

Invalidate counts

Parameters

int $user_id

at line 561
bool mark(Notification[] $notifications, mixed $status)

mark any status by Notification

Parameters

Notification[] $notifications
mixed $status

Return Value

bool

at line 545
bool mark_read(int $user_id, string $type = NotificationType::ACTIVITY)

mark seen notifications by user_id and typ

Parameters

int $user_id
string $type

self::TYPES

Return Value

bool

at line 529
bool mark_seen(int $user_id)

mark seen notifications by user_id and typ

Parameters

int $user_id

Return Value

bool

at line 128
messenger(mixed $recipient_users, mixed $subject, mixed $text)

Send Messenger-Message

Parameters

mixed $recipient_users
mixed $subject
mixed $text

at line 434
publish(NotificationMessage $notificationMessage)

Add Notificaton Message to Queue

Parameters

NotificationMessage $notificationMessage

at line 509
int remove(mixed $instance_id, string $token, mixed $user_id = false)

Remove an existing notification (by Instance ID and Token) for all users or specific users Using $this->mod->notify()

Parameters

mixed $instance_id

Instance-ID

string $token

Token for updates for this Notification

mixed $user_id

User-ID or Array of Users

Return Value

int

Count of deleted notifications

Exceptions

Exception

at line 74
bool send(int|int[] $user_ids, string $subject, $text, bool $is_html = false, array $allowed_sending_methods = array('email', 'messenger'), array $attachment = false) deprecated

deprecated Please use $XF->lib->notification->add or Core::notify removal planned in XELOS 7.x

No description

Parameters

int|int[] $user_ids

or array of int user id to notify

string $subject

of message

$text
bool $is_html

default: false Set to true if passed text contains html

array $allowed_sending_methods

allowed sending methods: email and/or messenger; default array('email', 'messenger')

array $attachment

Attachment of format: $attachment['binary'],$attachment['name'], $attachment['type'], $attachment['encoding'] = (default) base64, $attachment['embedded'] for embedded images

Return Value

bool

success

at line 50
bool send_vars(mixed $user_ids, VarsTemplate $vars_object, array $allowed_sending_methods = array('email', 'messenger'), $attachment = false)

Send with Vars Object

Parameters

mixed $user_ids
VarsTemplate $vars_object
array $allowed_sending_methods

allowed sending methods: email and/or messenger; default array('email', 'messenger')

$attachment

Return Value

bool