NewVersionAvailable
extends BaseNotification
in package
HumHubUpdateNotification
Notifies about new HumHub Version
Tags
Table of Contents
Properties
- $groupCount : int
- $markAsSeenOnClick : bool
- $moduleId : mixed
- $originator : User
- User which performed the activity.
- $payload : array<string|int, mixed>|null
- Additional user data available for the notification
- $priority : bool
- Priority flag, if set to true, this Notification type will be marked as high priority.
- $record : ActiveRecord
- An SocialActivity can be represented in the database as ActiveRecord.
- $record : Notification
- An SocialActivity can be represented in the database as ActiveRecord.
- $recordClass : string
- $requireOriginator : mixed
- $requireSource : mixed
- $source : ActiveRecord
- The source instance which created this activity
- $suppressSendToOriginator : bool
- $viewName : string
- $_category : NotificationCategory
- $_groupKey : string
Methods
- __call() : mixed
- Calls the named method which is not a class method.
- __construct() : mixed
- Constructor.
- __get() : mixed
- Returns the value of an object property.
- __isset() : bool
- Checks if a property is set, i.e. defined and not null.
- __serialize() : array<string|int, mixed>
- Serializes the $source and $originator fields.
- __set() : mixed
- Sets value of an object property.
- __unserialize() : mixed
- Unserializes the given string, calls the init() function and sets the $source and $originator fields (and $record indirectyl).
- __unset() : mixed
- Sets an object property to null.
- about() : $this
- Builder function for the source.
- asArray() : mixed
- Returns an array representation of this notification.
- beforeMailSend() : bool
- This method is invoked right before a mail will be send for this notificatoin
- canGetProperty() : bool
- Returns a value indicating whether a property can be read.
- canSetProperty() : bool
- Returns a value indicating whether a property can be set.
- category() : NotificationCategory
- Returns a new NotificationCategory instance.
- className() : string
- Returns the fully qualified name of this class.
- delete() : mixed
- Deletes this notification
- from() : SocialActivity
- Builder function for the originator.
- getAsHtml() : mixed
- Use html() instead
- getAsText() : mixed
- Use text() instead
- getCategory() : NotificationCategory
- Returns the notification category instance. If no category class is set (default) the default notification settings can't be overwritten.
- getContent() : Content
- Returns the related content instance in case the source is of type ContentOwner.
- getContentContainer() : ContentContainerActiveRecord
- Determines if the activity source is related to an ContentContainer.
- getContentInfo() : string|null
- Build info text about a content
- getContentName() : string|null
- Returns the content name of $content or if not $content is provided of the notification source.
- getContentPlainTextInfo() : string|null
- Builds plain text info text about a given content
- getContentPlainTextPreview() : string|null
- Returns a short preview text of the content in plain text. The max length can be defined by setting $maxLength (60 by default).
- getContentPreview() : string|null
- Returns a short preview text of the content. The max length can be defined by setting $maxLength (60 by default).
- getGroupKey() : string
- Returns a key for grouping notifications.
- getGroupLastUsers() : array<string|int, User>
- Returns the last users of a grouped notification
- getGroupUserDisplayNames() : string
- Returns the combined display names of a grouped notification.
- getLatestHumHubVersion() : mixed
- getMailSubject() : string
- Returns a non html encoded mail subject which will be used in the notification e-mail
- getSpace() : Space
- getSpaceId() : int
- getUrl() : string
- Url of the origin of this notification If source is a Content / ContentAddon / ContentContainer this will automatically generated.
- getViewName() : string
- getViewParams() : mixed
- Returns an array of view parameter, required for rendering.
- hasContent() : bool
- Determines if this activity is related to a content. This is the case if the activitiy source is of type ContentOwner.
- hasMethod() : bool
- Returns a value indicating whether a method is defined.
- hasProperty() : bool
- Returns a value indicating whether a property is defined.
- html() : string
- Should be overwritten by subclasses for a html representation of the notification.
- init() : mixed
- Initializes the object.
- instance() : static
- Static initializer should be prefered over new initialization, since it makes use of Yii::createObject dependency injection/configuration.
- isBlockedForUser() : bool
- Checks if the source is blocked for the receiver $user.
- isBlockedFromUser() : bool
- Checks if the originator blocked the given $user in order to avoid receive any notifications from the $user.
- isOriginator() : bool
- Checks if the given $user is the originator of this notification.
- isValid() : bool
- Checks if notification is still valid before sending
- json() : string
- markAsSeen() : mixed
- Marks notification as seen
- payload() : $this
- Set additional data
- render() : string
- Renders the Notificaiton for the given notification target.
- saveRecord() : bool
- Creates the Notification instance of the current BaseNotification type for the given $user.
- send() : mixed
- Sends this notification to all notification targets of the given User.
- sendBulk() : mixed
- Sends this notification to a set of users.
- text() : string
- validate() : bool
- Validates the existence of required attributes
- isSpaceContent() : bool
- Check if the source is a Content from a Space
Properties
$groupCount
public
int
$groupCount
= 0
number of combined notifications
$markAsSeenOnClick
public
bool
$markAsSeenOnClick
= true
automatically mark notification as seen after click on it
$moduleId
public
mixed
$moduleId
= 'admin'
Tags
$originator
User which performed the activity.
public
User
$originator
$payload
Additional user data available for the notification
public
array<string|int, mixed>|null
$payload
= null
Tags
$priority
Priority flag, if set to true, this Notification type will be marked as high priority.
public
bool
$priority
= false
This can be used by a given BaseTarget while handling a Notification.
A MobileTargetProvider for example could use this flag for Android devices to wake up the device out of doze mode.
if set to true marks this notification type as high priority.
Tags
$record
An SocialActivity can be represented in the database as ActiveRecord.
public
ActiveRecord
$record
By defining the $recordClass an ActiveRecord will be created automatically within the init function.
The related record for this activitiy
$record
An SocialActivity can be represented in the database as ActiveRecord.
public
Notification
$record
The related record for this activitiy
$recordClass
public
string
$recordClass
= \humhub\modules\notification\models\Notification::class
Record class used for instantiation.
Tags
$requireOriginator
public
mixed
$requireOriginator
= false
Tags
$requireSource
public
mixed
$requireSource
= false
Tags
$source
The source instance which created this activity
public
ActiveRecord
$source
$suppressSendToOriginator
public
bool
$suppressSendToOriginator
= true
do not send this notification also to the originator
Tags
$viewName
public
string
$viewName
= 'default.php'
view name used for rendering the activity
$_category
protected
NotificationCategory
$_category
= null
cached category instance
$_groupKey
protected
string
$_groupKey
= null
the group key
Methods
__call()
Calls the named method which is not a class method.
public
__call(string $name, array<string|int, mixed> $params) : mixed
Do not call this method directly as it is a PHP magic method that will be implicitly called when an unknown method is being invoked.
Parameters
- $name : string
-
the method name
- $params : array<string|int, mixed>
-
method parameters
Tags
Return values
mixed —the method return value
__construct()
Constructor.
public
__construct([array<string|int, mixed> $config = [] ]) : mixed
The default implementation does two things:
- Initializes the object with the given configuration
$config
. - Call [[init()]].
If this method is overridden in a child class, it is recommended that
- the last parameter of the constructor is a configuration array, like
$config
here. - call the parent implementation at the end of the constructor.
Parameters
- $config : array<string|int, mixed> = []
-
name-value pairs that will be used to initialize the object properties
__get()
Returns the value of an object property.
public
__get(string $name) : mixed
Do not call this method directly as it is a PHP magic method that
will be implicitly called when executing $value = $object->property;
.
Parameters
- $name : string
-
the property name
Tags
Return values
mixed —the property value
__isset()
Checks if a property is set, i.e. defined and not null.
public
__isset(string $name) : bool
Do not call this method directly as it is a PHP magic method that
will be implicitly called when executing isset($object->property)
.
Note that if the property is not defined, false will be returned.
Parameters
- $name : string
-
the property name or the event name
Tags
Return values
bool —whether the named property is set (not null).
__serialize()
Serializes the $source and $originator fields.
public
__serialize() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>__set()
Sets value of an object property.
public
__set(string $name, mixed $value) : mixed
Do not call this method directly as it is a PHP magic method that
will be implicitly called when executing $object->property = $value;
.
Parameters
- $name : string
-
the property name or the event name
- $value : mixed
-
the property value
Tags
__unserialize()
Unserializes the given string, calls the init() function and sets the $source and $originator fields (and $record indirectyl).
public
__unserialize(mixed $unserializedArr) : mixed
Parameters
- $unserializedArr : mixed
Tags
__unset()
Sets an object property to null.
public
__unset(string $name) : mixed
Do not call this method directly as it is a PHP magic method that
will be implicitly called when executing unset($object->property)
.
Note that if the property is not defined, this method will do nothing. If the property is read-only, it will throw an exception.
Parameters
- $name : string
-
the property name
Tags
about()
Builder function for the source.
public
about(mixed $source) : $this
Parameters
- $source : mixed
Tags
Return values
$thisasArray()
Returns an array representation of this notification.
public
asArray(User $user) : mixed
Parameters
- $user : User
Tags
beforeMailSend()
This method is invoked right before a mail will be send for this notificatoin
public
beforeMailSend(MessageInterface $message) : bool
Parameters
- $message : MessageInterface
Tags
Return values
bool —when true the mail will be send
canGetProperty()
Returns a value indicating whether a property can be read.
public
canGetProperty(string $name[, bool $checkVars = true ]) : bool
A property is readable if:
- the class has a getter method associated with the specified name (in this case, property name is case-insensitive);
- the class has a member variable with the specified name (when
$checkVars
is true);
Parameters
- $name : string
-
the property name
- $checkVars : bool = true
-
whether to treat member variables as properties
Tags
Return values
bool —whether the property can be read
canSetProperty()
Returns a value indicating whether a property can be set.
public
canSetProperty(string $name[, bool $checkVars = true ]) : bool
A property is writable if:
- the class has a setter method associated with the specified name (in this case, property name is case-insensitive);
- the class has a member variable with the specified name (when
$checkVars
is true);
Parameters
- $name : string
-
the property name
- $checkVars : bool = true
-
whether to treat member variables as properties
Tags
Return values
bool —whether the property can be written
category()
Returns a new NotificationCategory instance.
public
category() : NotificationCategory
Tags
Return values
NotificationCategoryclassName()
Returns the fully qualified name of this class.
public
static className() : string
Tags
Return values
string —the fully qualified name of this class.
delete()
Deletes this notification
public
delete([User $user = null ]) : mixed
Parameters
- $user : User = null
from()
Builder function for the originator.
public
from(mixed $originator) : SocialActivity
Parameters
- $originator : mixed
Tags
Return values
SocialActivitygetAsHtml()
Use html() instead
public
getAsHtml() : mixed
Tags
getAsText()
Use text() instead
public
getAsText() : mixed
Tags
getCategory()
Returns the notification category instance. If no category class is set (default) the default notification settings can't be overwritten.
public
getCategory() : NotificationCategory
The category instance is cached, once created.
If the Notification configuration should be configurable subclasses have to overwrite this method.
Return values
NotificationCategorygetContent()
Returns the related content instance in case the source is of type ContentOwner.
public
getContent() : Content
Return values
Content —Content ActiveRecord or null if not related to a ContentOwner source
getContentContainer()
Determines if the activity source is related to an ContentContainer.
public
getContentContainer() : ContentContainerActiveRecord
This is the case if the source is either a ContentContainerActiveRecord itself or a ContentOwner.
Tags
Return values
ContentContainerActiveRecordgetContentInfo()
Build info text about a content
public
getContentInfo([Content $content = null ][, mixed $withContentName = true ]) : string|null
This is a combination of the type of the content with a short preview of it.
If no $content is provided the contentInfo of $source is returned.
Parameters
- $content : Content = null
- $withContentName : mixed = true
Tags
Return values
string|nullgetContentName()
Returns the content name of $content or if not $content is provided of the notification source.
public
getContentName([ContentOwner $content = null ]) : string|null
Parameters
- $content : ContentOwner = null
Return values
string|nullgetContentPlainTextInfo()
Builds plain text info text about a given content
public
getContentPlainTextInfo([Content $content = null ][, mixed $withContentName = true ]) : string|null
This is a combination of the type of the content with a short preview of it.
Note: This should only be used for mail subjects and other plain text
If no $content is provided the contentInfo of $source is returned.
Parameters
- $content : Content = null
- $withContentName : mixed = true
Tags
Return values
string|nullgetContentPlainTextPreview()
Returns a short preview text of the content in plain text. The max length can be defined by setting $maxLength (60 by default).
public
getContentPlainTextPreview([ContentOwner $content = null ][, int $maxLength = 60 ]) : string|null
If no $content is provided the contentPreview of $source is returned.
Note: This should only be used for mail subjects and other plain text
Parameters
- $content : ContentOwner = null
- $maxLength : int = 60
Tags
Return values
string|nullgetContentPreview()
Returns a short preview text of the content. The max length can be defined by setting $maxLength (60 by default).
public
getContentPreview([ContentOwner $content = null ][, int $maxLength = 60 ]) : string|null
If no $content is provided the contentPreview of $source is returned.
Parameters
- $content : ContentOwner = null
- $maxLength : int = 60
Tags
Return values
string|nullgetGroupKey()
Returns a key for grouping notifications.
public
getGroupKey() : string
If null is returned (default) the notification grouping for this BaseNotification type disabled.
The returned key could for example be a combination of classname related content id.
Return values
string —the group key
getGroupLastUsers()
Returns the last users of a grouped notification
public
getGroupLastUsers([int $limit = 2 ]) : array<string|int, User>
Parameters
- $limit : int = 2
-
users to return
Return values
array<string|int, User> —the number of user
getGroupUserDisplayNames()
Returns the combined display names of a grouped notification.
public
getGroupUserDisplayNames([bool $html = true ]) : string
Examples: User A and User B User A and 5 others
Parameters
- $html : bool = true
-
if true the result will be encoded and may contain html
Return values
string —the display names
getLatestHumHubVersion()
public
getLatestHumHubVersion() : mixed
Tags
getMailSubject()
Returns a non html encoded mail subject which will be used in the notification e-mail
public
getMailSubject() : string
Tags
Return values
string —the subject
getSpace()
public
getSpace() : Space
Tags
Return values
Space —related space instance in case the activity source is an related contentcontainer of type space, otherwise null
getSpaceId()
public
getSpaceId() : int
Tags
Return values
int —related space id in case the activity source is an related contentcontainer of type space, otherwise null
getUrl()
Url of the origin of this notification If source is a Content / ContentAddon / ContentContainer this will automatically generated.
public
getUrl() : string
Tags
Return values
stringgetViewName()
public
getViewName() : string
Tags
Return values
string —viewname of this viewable
getViewParams()
Returns an array of view parameter, required for rendering.
public
getViewParams([mixed $params = [] ]) : mixed
Parameters
- $params : mixed = []
Tags
hasContent()
Determines if this activity is related to a content. This is the case if the activitiy source is of type ContentOwner.
public
hasContent() : bool
Return values
bool —true if this activity is related to a ContentOwner else false
hasMethod()
Returns a value indicating whether a method is defined.
public
hasMethod(string $name) : bool
The default implementation is a call to php function method_exists()
.
You may override this method when you implemented the php magic method __call()
.
Parameters
- $name : string
-
the method name
Return values
bool —whether the method is defined
hasProperty()
Returns a value indicating whether a property is defined.
public
hasProperty(string $name[, bool $checkVars = true ]) : bool
A property is defined if:
- the class has a getter or setter method associated with the specified name (in this case, property name is case-insensitive);
- the class has a member variable with the specified name (when
$checkVars
is true);
Parameters
- $name : string
-
the property name
- $checkVars : bool = true
-
whether to treat member variables as properties
Tags
Return values
bool —whether the property is defined
html()
Should be overwritten by subclasses for a html representation of the notification.
public
html() : string
Tags
Return values
stringinit()
Initializes the object.
public
init() : mixed
Tags
instance()
Static initializer should be prefered over new initialization, since it makes use of Yii::createObject dependency injection/configuration.
public
static instance([array<string|int, mixed> $options = [] ]) : static
Parameters
- $options : array<string|int, mixed> = []
Tags
Return values
staticisBlockedForUser()
Checks if the source is blocked for the receiver $user.
public
isBlockedForUser(User $user) : bool
For example, if the $user is not a member of a private Space
Parameters
- $user : User
Tags
Return values
boolisBlockedFromUser()
Checks if the originator blocked the given $user in order to avoid receive any notifications from the $user.
public
isBlockedFromUser(User $user) : bool
Parameters
- $user : User
Tags
Return values
boolisOriginator()
Checks if the given $user is the originator of this notification.
public
isOriginator(User $user) : bool
Parameters
- $user : User
Return values
boolisValid()
Checks if notification is still valid before sending
public
isValid() : bool
Tags
Return values
booljson()
public
json() : string
Tags
Return values
string —json content representation of this viewable.
markAsSeen()
Marks notification as seen
public
markAsSeen() : mixed
payload()
Set additional data
public
payload(mixed $payload) : $this
Parameters
- $payload : mixed
Tags
Return values
$thisrender()
Renders the Notificaiton for the given notification target.
public
render([BaseTarget $target = null ]) : string
Subclasses are able to use custom renderer for different targets by overwriting this function.
Parameters
- $target : BaseTarget = null
Return values
string —render result
saveRecord()
Creates the Notification instance of the current BaseNotification type for the given $user.
public
saveRecord(User $user) : bool
Parameters
- $user : User
Return values
boolsend()
Sends this notification to all notification targets of the given User.
public
send(User $user) : mixed
This function will not send notifications to the originator itself.
Parameters
- $user : User
Tags
sendBulk()
Sends this notification to a set of users.
public
sendBulk(ActiveQueryUser|array<string|int, mixed>|array<string|int, User> $query) : mixed
Note: For compatibility reasons this method also allows to pass an array of user objects. This support will removed in future versions.
Parameters
- $query : ActiveQueryUser|array<string|int, mixed>|array<string|int, User>
-
the user query
Tags
text()
public
text() : string
Tags
Return values
string —text content representation of this viewable.
validate()
Validates the existence of required attributes
public
validate() : bool
Return values
boolisSpaceContent()
Check if the source is a Content from a Space
private
isSpaceContent() : bool