UniqueNotification
extends Notification
in package
Subclass of Notification, but with unique constraint.
If a new message is created exactly like another one, it will be marked as unread.
Table of Contents
Constants
- HIGH_IMPORTANCE = 3
- NAG_ONCE_IMPORTANCE = 2
- NORMAL_IMPORTANCE = 1
Properties
- $bEncryption : mixed
- $created : string
- $display_class : string
- $entity : string
- $entity_id : string
- $first_read : string
- $hash : string
- $id : int
- $importance : int
- $message : string
- $status : string
- $title : string
- $markAsNew : bool
- Whether or not this message should be marked as unread ('new') second time it's saved.
- $setNormalImportance : bool
- Whether or not the importance should be set to normal second time it's saved.
- $xssFilterAttributes : array<string|int, string>
Methods
- __construct() : mixed
- As parent constructor but with markAsUndread
- attributeLabels() : mixed
- behaviors() : array<string|int, mixed>
- Lists the behaviors of this model
- broadcast() : mixed
- Broadcast a message to all users See example usage at manual page: https://manual.limesurvey.org/Notifications#Examples
- countImportantNotifications() : string
- Count important notifications
- countNewNotifications() : string
- Returns number of notifications with status 'new'
- countNotifications() : string
- Count how many notifications we have
- decrypt() : mixed
- Decrypt values from database
- decryptEncryptAttributes() : mixed
- Encrypt/decrypt values
- decryptSingle() : string
- Decrypt single value
- decryptSingleOld() : string
- Decrypt single value
- deleteAllByAttributes() : int
- dispatchPluginModelEvent() : PluginEvent
- encrypt() : mixed
- Encrypt values
- encryptAttributeValues() : array<string|int, mixed>
- Attribute values are encrypted ( if needed )to be used for searching purposes
- encryptSave() : mixed
- Encrypt values before saving to the database
- encryptSingle() : mixed
- Enrypt single value
- findAllAsArray() : array<string|int, mixed>
- Finds all active records satisfying the specified condition but returns them as array
- findAllByAttributes() : array<string|int, static>
- Overriding of Yii's findAllByAttributes method to provide encrypted attribute value search
- findByAttributes() : static|null
- Overriding of Yii's findByAttributes method to provide encrypted attribute value search
- getAjaxUrl() : string
- Returns a URL to the Ajax action in notification controller Used when user clicks on a notification link
- getAllEncryptedAttributes() : array<string|int, mixed>
- getImportantNotifications() : array<string|int, Notification>
- Get notifications of importance HIGH_IMPORTANCE
- getMaxId() : false|int
- Return the max value for a field
- getMinId() : false|int
- Return the min value for a field
- getNotifications() : array<string|int, Notification>
- Get latest notifications to show in the menu
- getReadUrl() : string
- Url that is used to mark that user read the message
- getUpdateUrl() : string
- Url to fetch the complete notification menu widget
- markAsRead() : bool
- Mark notification as read NOW()
- model() : Notification
- primaryKey() : mixed
- relations() : mixed
- rules() : mixed
- save() : void
- Check for already existing notification and update that. Importance will be set to normal.
- search() : mixed
- setEncryptedAttributeLabel() : string
- Function to show encryption symbol in gridview attribute header if value ois encrypted
- tableName() : mixed
- updateAll() : int
- Updates records with the specified condition.
- checkMandatoryFields() : void
- Check so all mandatory fields are defined when constructing a new notification.
- checkShortcuts() : mixed
- Some shortcuts for easier use
- getCriteria() : CDbCriteria
- Criteria to fetch all notifications for this survey and this user
- query() : mixed
- Modified version that default to do the same as the original, but allows via a third parameter to retrieve the result as array instead of active records. This solves a joining problem. Usage via findAllAsArray method
Constants
HIGH_IMPORTANCE
public
mixed
HIGH_IMPORTANCE
= 3
NAG_ONCE_IMPORTANCE
public
mixed
NAG_ONCE_IMPORTANCE
= 2
NORMAL_IMPORTANCE
public
mixed
NORMAL_IMPORTANCE
= 1
Properties
$bEncryption
public
mixed
$bEncryption
= \false
$created
public
string
$created
When the notification was created
$display_class
public
string
$display_class
warning, danger, success
$entity
public
string
$entity
survey or user
$entity_id
public
string
$entity_id
survey ID or user id
$first_read
public
string
$first_read
When the notification was read
$hash
public
string
$hash
$id
public
int
$id
$importance
public
int
$importance
1 or 3. 3 will show popup on page load, 2 is reserved for future bell animation.
$message
public
string
$message
$status
public
string
$status
new, read
$title
public
string
$title
$markAsNew
Whether or not this message should be marked as unread ('new') second time it's saved.
protected
bool
$markAsNew
= \true
$setNormalImportance
Whether or not the importance should be set to normal second time it's saved.
protected
bool
$setNormalImportance
= \true
$xssFilterAttributes
protected
array<string|int, string>
$xssFilterAttributes
= []
Array of attributes that should be XSS filtered on mass updates
Methods
__construct()
As parent constructor but with markAsUndread
public
__construct([mixed $options = null ]) : mixed
Parameters
- $options : mixed = null
-
If string then scenario
Tags
attributeLabels()
public
attributeLabels() : mixed
Tags
behaviors()
Lists the behaviors of this model
public
behaviors() : array<string|int, mixed>
Below is a list of all behaviors we register:
Tags
Return values
array<string|int, mixed>broadcast()
Broadcast a message to all users See example usage at manual page: https://manual.limesurvey.org/Notifications#Examples
public
static broadcast(array<string|int, mixed> $options[, array<string|int, mixed> $users = null ]) : mixed
Parameters
- $options : array<string|int, mixed>
- $users : array<string|int, mixed> = null
Tags
countImportantNotifications()
Count important notifications
public
static countImportantNotifications(int|null $surveyId) : string
Parameters
- $surveyId : int|null
Return values
stringcountNewNotifications()
Returns number of notifications with status 'new'
public
static countNewNotifications(int|null $surveyId) : string
Parameters
- $surveyId : int|null
Return values
stringcountNotifications()
Count how many notifications we have
public
static countNotifications(int|null $surveyId) : string
Parameters
- $surveyId : int|null
Return values
stringdecrypt()
Decrypt values from database
public
decrypt([mixed $value = '' ]) : mixed
Parameters
- $value : mixed = ''
decryptEncryptAttributes()
Encrypt/decrypt values
public
decryptEncryptAttributes([mixed $action = 'decrypt' ]) : mixed
Parameters
- $action : mixed = 'decrypt'
decryptSingle()
Decrypt single value
public
static decryptSingle([string $value = '' ]) : string
Parameters
- $value : string = ''
-
String value which needs to be decrypted
Return values
string —the decrypted string
decryptSingleOld()
Decrypt single value
public
static decryptSingleOld([string $value = '' ]) : string
Parameters
- $value : string = ''
-
String value which needs to be decrypted
Return values
string —the decrypted string
deleteAllByAttributes()
public
deleteAllByAttributes(array<string|int, mixed> $attributes[, string $condition = '' ][, array<string|int, mixed> $params = [] ]) : int
Parameters
- $attributes : array<string|int, mixed>
-
list of attribute values (indexed by attribute names) that the active records should match. An attribute value can be an array which will be used to generate an IN condition.
- $condition : string = ''
-
query condition or criteria.
- $params : array<string|int, mixed> = []
-
parameters to be bound to an SQL statement.
Tags
Return values
int —number of rows affected by the execution.
dispatchPluginModelEvent()
public
dispatchPluginModelEvent(string $sEventName, CDbCriteria $criteria = null, array<string|int, mixed> $eventParams = []) : PluginEvent
Parameters
- $sEventName : string
- $criteria = null : CDbCriteria
- $eventParams = [] : array<string|int, mixed>
Return values
PluginEventencrypt()
Encrypt values
public
encrypt() : mixed
encryptAttributeValues()
Attribute values are encrypted ( if needed )to be used for searching purposes
public
encryptAttributeValues([array<string|int, mixed> $attributes = null ][, mixed $bEncryptedOnly = false ][, mixed $bReplaceValues = true ]) : array<string|int, mixed>
Parameters
- $attributes : array<string|int, mixed> = null
-
list of attribute values (indexed by attribute names) that the active records should match. An attribute value can be an array which will be used to generate an IN condition.
- $bEncryptedOnly : mixed = false
- $bReplaceValues : mixed = true
Return values
array<string|int, mixed> —attributes array with encrypted atrribute values is returned
encryptSave()
Encrypt values before saving to the database
public
encryptSave([mixed $runValidation = false ]) : mixed
Parameters
- $runValidation : mixed = false
encryptSingle()
Enrypt single value
public
static encryptSingle([string $value = '' ]) : mixed
Parameters
- $value : string = ''
-
String value which needs to be encrypted
findAllAsArray()
Finds all active records satisfying the specified condition but returns them as array
public
findAllAsArray([mixed $condition = '' ][, array<string|int, mixed> $params = [] ]) : array<string|int, mixed>
Parameters
- $condition : mixed = ''
-
query condition or criteria.
- $params : array<string|int, mixed> = []
-
parameters to be bound to an SQL statement.
Return values
array<string|int, mixed> —list of active records satisfying the specified condition. An empty array is returned if none is found.
findAllByAttributes()
Overriding of Yii's findAllByAttributes method to provide encrypted attribute value search
public
findAllByAttributes(array<string|int, mixed> $attributes[, mixed $condition = '' ][, array<string|int, mixed> $params = [] ]) : array<string|int, static>
Parameters
- $attributes : array<string|int, mixed>
-
list of attribute values (indexed by attribute names) that the active records should match. An attribute value can be an array which will be used to generate an IN condition.
- $condition : mixed = ''
-
query condition or criteria.
- $params : array<string|int, mixed> = []
-
parameters to be bound to an SQL statement.
Return values
array<string|int, static> —the records found. An empty array is returned if none is found.
findByAttributes()
Overriding of Yii's findByAttributes method to provide encrypted attribute value search
public
findByAttributes(array<string|int, mixed> $attributes[, mixed $condition = '' ][, array<string|int, mixed> $params = [] ]) : static|null
Parameters
- $attributes : array<string|int, mixed>
-
list of attribute values (indexed by attribute names) that the active record should match. An attribute value can be an array which will be used to generate an IN condition.
- $condition : mixed = ''
-
query condition or criteria.
- $params : array<string|int, mixed> = []
-
parameters to be bound to an SQL statement.
Return values
static|null —the record found. Null if none is found.
getAjaxUrl()
Returns a URL to the Ajax action in notification controller Used when user clicks on a notification link
public
getAjaxUrl() : string
Return values
stringgetAllEncryptedAttributes()
public
getAllEncryptedAttributes(int $iSurveyId, string $sClassName) : array<string|int, mixed>
Parameters
- $iSurveyId : int
- $sClassName : string
Return values
array<string|int, mixed> —TODO: Should be split into seperate functions in the appropiate model or helper class TODO: Make an interface for records that support encryption.
getImportantNotifications()
Get notifications of importance HIGH_IMPORTANCE
public
static getImportantNotifications(int|null $surveyId) : array<string|int, Notification>
Parameters
- $surveyId : int|null
Return values
array<string|int, Notification>getMaxId()
Return the max value for a field
public
getMaxId([string $field = null ][, bool $forceRefresh = false ]) : false|int
This is a convenience method, that uses the primary key of the model to retrieve the highest value.
Parameters
- $field : string = null
-
The field that contains the Id, when null primary key is used if it is a single field
- $forceRefresh : bool = false
-
Don't use value from static cache but always requery the database
Tags
Return values
false|intgetMinId()
Return the min value for a field
public
getMinId([string $field = null ][, bool $forceRefresh = false ]) : false|int
This is a convenience method, that uses the primary key of the model to retrieve the highest value.
Parameters
- $field : string = null
-
The field that contains the Id, when null primary key is used if it is a single field
- $forceRefresh : bool = false
-
Don't use value from static cache but always requery the database
Tags
Return values
false|intgetNotifications()
Get latest notifications to show in the menu
public
static getNotifications(int|null $surveyId) : array<string|int, Notification>
Parameters
- $surveyId : int|null
Return values
array<string|int, Notification>getReadUrl()
Url that is used to mark that user read the message
public
getReadUrl() : string
Return values
stringgetUpdateUrl()
Url to fetch the complete notification menu widget
public
static getUpdateUrl([int|null $surveyId = null ]) : string
Parameters
- $surveyId : int|null = null
Return values
stringmarkAsRead()
Mark notification as read NOW()
public
markAsRead() : bool
Return values
bool —Result of update
model()
public
static model([mixed $className = __CLASS__ ]) : Notification
Parameters
- $className : mixed = __CLASS__
Tags
Return values
Notification —the static model class
primaryKey()
public
primaryKey() : mixed
Tags
relations()
public
relations() : mixed
Tags
rules()
public
rules() : mixed
Tags
save()
Check for already existing notification and update that. Importance will be set to normal.
public
save([mixed $runValidation = true ][, mixed $attributes = null ]) : void
Parameters
- $runValidation : mixed = true
- $attributes : mixed = null
Tags
search()
public
search() : mixed
Tags
setEncryptedAttributeLabel()
Function to show encryption symbol in gridview attribute header if value ois encrypted
public
setEncryptedAttributeLabel(int $surveyId, string $className, string $attributeName) : string
Parameters
- $surveyId : int
- $className : string
- $attributeName : string
Tags
Return values
stringtableName()
public
tableName() : mixed
Tags
updateAll()
Updates records with the specified condition.
public
updateAll(array<string|int, mixed> $attributes[, mixed $condition = '' ][, array<string|int, mixed> $params = array() ]) : int
XSS filtering is enforced for attributes listed in model's $xssFilterAttributes property. See for detailed explanation about $condition and $params. Note, the attributes are not checked for safety and no validation is done.
Parameters
- $attributes : array<string|int, mixed>
-
list of attributes (name=>$value) to be updated
- $condition : mixed = ''
-
query condition or criteria.
- $params : array<string|int, mixed> = array()
-
parameters to be bound to an SQL statement.
Return values
int —the number of rows being updated
checkMandatoryFields()
Check so all mandatory fields are defined when constructing a new notification.
protected
checkMandatoryFields(array<string, string> $options, array<string|int, string> $mandatory) : void
Parameters
- $options : array<string, string>
- $mandatory : array<string|int, string>
Tags
checkShortcuts()
Some shortcuts for easier use
protected
checkShortcuts(mixed $options) : mixed
Parameters
- $options : mixed
getCriteria()
Criteria to fetch all notifications for this survey and this user
protected
static getCriteria([int|null $surveyId = null ]) : CDbCriteria
Parameters
- $surveyId : int|null = null
Return values
CDbCriteriaquery()
Modified version that default to do the same as the original, but allows via a third parameter to retrieve the result as array instead of active records. This solves a joining problem. Usage via findAllAsArray method
protected
query(CDbCriteria $criteria[, bool $all = false ][, bool $asAR = true ]) : mixed
Performs the actual DB query and populates the AR objects with the query result. This method is mainly internally used by other AR query methods.
Parameters
- $criteria : CDbCriteria
-
the query criteria
- $all : bool = false
-
whether to return all data
- $asAR : bool = true
Tags
Return values
mixed —the AR objects populated with the query result