Class humhub\modules\notification\components\NotificationManager

Inheritancehumhub\modules\notification\components\NotificationManager

The NotificationManager component is responsible for sending BaseNotifications to Users over different notification targets by using the send and sendBulk function.

A notification target may be disabled for a specific user and will be skipped.

Public Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$targets array Target configuration. humhub\modules\notification\components\NotificationManager

Public Methods

Hide inherited methods

MethodDescriptionDefined By
getContainerFollowers() Returns all notification followers for the given $container. If $public is set to false only members with send_notifications settings are returned. humhub\modules\notification\components\NotificationManager
getDesktopNoficationSettings() Determines the enable_html5_desktop_notifications setting either for the given user or global if no user is given. humhub\modules\notification\components\NotificationManager
getFollowers() Returns all notification followers for the given $content instance. humhub\modules\notification\components\NotificationManager
getNonNotificationSpaces() Returns all spaces this user is not following. humhub\modules\notification\components\NotificationManager
getNotificationCategories() Returns all available NotificationCategories as array with category id as key and a category instance as value. humhub\modules\notification\components\NotificationManager
getNotifications() Returns all available Notifications humhub\modules\notification\components\NotificationManager
getSpaces() Returns all spaces this user is following (including member spaces) with sent_notification setting. humhub\modules\notification\components\NotificationManager
getTarget() Factory function for receiving a target instance for the given class. humhub\modules\notification\components\NotificationManager
getTargets() Returns all active targets for the given user. humhub\modules\notification\components\NotificationManager
isFollowingSpace() Checks if the given user is following notifications for the given space. humhub\modules\notification\components\NotificationManager
send() Sends the given $notification to all enabled targets of a single user. humhub\modules\notification\components\NotificationManager
sendBulk() Sends the given $notification to all enabled targets of the given $users if possible as bulk message. humhub\modules\notification\components\NotificationManager
setDesktopNoficationSettings() Defines the enable_html5_desktop_notifications setting for the given user or global if no user is given. humhub\modules\notification\components\NotificationManager
setSpaceSetting() Sets the send_notifications settings for the given space and user. humhub\modules\notification\components\NotificationManager
setSpaces() Sets the notification space settings for this user (or global if no user is given). humhub\modules\notification\components\NotificationManager

Property Details

$_categories protected property
$_notifications protected property

Cached array of BaseNotification instances.

$_targets protected property

Cached target instances.

$targets public property

Target configuration.

public array $targets = []

Method Details

createNotifications() protected method

protected void createNotifications ( $notificationClasses )
$notificationClasses
getContainerFollowers() public method

Returns all notification followers for the given $container. If $public is set to false only members with send_notifications settings are returned.

public humhub\modules\user\components\ActiveQueryUser getContainerFollowers ( humhub\modules\content\components\ContentContainerActiveRecord $container, $public true )
$container humhub\modules\content\components\ContentContainerActiveRecord
$public boolean
getDesktopNoficationSettings() public method

Determines the enable_html5_desktop_notifications setting either for the given user or global if no user is given.

By default the setting is enabled.

public integer getDesktopNoficationSettings ( humhub\modules\user\models\User $user null )
$user humhub\modules\user\models\User
getFollowers() public method

Returns all notification followers for the given $content instance.

This function includes ContentContainer followers only if the content visibility is set to public, else only space members with send_notifications settings are returned.

public humhub\modules\user\components\ActiveQueryUser getFollowers ( humhub\modules\content\models\Content $content )
$content humhub\modules\content\models\Content
throws \yii\base\Exception
getNonNotificationSpaces() public method

Returns all spaces this user is not following.

public humhub\modules\space\models\Space[] getNonNotificationSpaces ( humhub\modules\user\models\User $user null, $limit 25 )
$user humhub\modules\user\models\User
$limit
getNotificationCategories() public method

Returns all available NotificationCategories as array with category id as key and a category instance as value.

public void getNotificationCategories ( $user null )
$user
getNotifications() public method

Returns all available Notifications

public humhub\modules\notification\components\BaseNotification[] getNotifications ( )
throws \yii\base\Exception
getSpaces() public method

Returns all spaces this user is following (including member spaces) with sent_notification setting.

public humhub\modules\space\models\Space[] getSpaces ( humhub\modules\user\models\User $user )
$user humhub\modules\user\models\User
getTarget() public method

Factory function for receiving a target instance for the given class.

public humhub\modules\notification\targets\BaseTarget getTarget ( $class )
$class string
getTargets() public method

Returns all active targets for the given user.

If no user is given, all configured targets will be returned.

public humhub\modules\notification\targets\BaseTarget[] getTargets ( humhub\modules\user\models\User $user null )
$user humhub\modules\user\models\User

|null the user

return humhub\modules\notification\targets\BaseTarget[]

The target

throws \yii\base\InvalidConfigException
isFollowingSpace() public method

Checks if the given user is following notifications for the given space.

This is the case for members and followers with the sent_notifications settings.

public boolean isFollowingSpace ( humhub\modules\user\models\User $user, humhub\modules\space\models\Space $space )
$user humhub\modules\user\models\User
$space humhub\modules\space\models\Space
searchModuleNotifications() protected method

Searches for all Notifications exported by modules.

protected \humhub\modules\notification\components\type searchModuleNotifications ( )
throws \yii\base\Exception
send() public method

Sends the given $notification to all enabled targets of a single user.

public void send ( humhub\modules\notification\components\BaseNotification $notification, humhub\modules\user\models\User $user )
$notification humhub\modules\notification\components\BaseNotification
$user humhub\modules\user\models\User

Target user

sendBulk() public method

Sends the given $notification to all enabled targets of the given $users if possible as bulk message.

public void sendBulk ( humhub\modules\notification\components\BaseNotification $notification, $userQuery )
$notification humhub\modules\notification\components\BaseNotification
$userQuery humhub\modules\user\components\ActiveQueryUser
throws \yii\base\InvalidConfigException
setDesktopNoficationSettings() public method

Defines the enable_html5_desktop_notifications setting for the given user or global if no user is given.

public void setDesktopNoficationSettings ( $value 0, humhub\modules\user\models\User $user null )
$value integer
$user humhub\modules\user\models\User
setSpaceSetting() public method

Sets the send_notifications settings for the given space and user.

public void setSpaceSetting ( humhub\modules\user\models\User $user null, humhub\modules\space\models\Space $space, $follow true )
$user humhub\modules\user\models\User

User instance for which this settings will aplly

$space humhub\modules\space\models\Space

Which notifications will be followed / unfollowed

$follow boolean

The setting value (true by default)

setSpaces() public method

Sets the notification space settings for this user (or global if no user is given).

Those are the spaces for which the user want to receive ContentCreated Notifications.

public void setSpaces ( $spaceGuids, humhub\modules\user\models\User $user null )
$spaceGuids string[]

Array of space guids

$user humhub\modules\user\models\User