PHP Класс ActivityModel, vanilla

Наследование: extends Gdn_Model
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$ActivityTypes Allowed activity types.
$MaxMergeCount Limit on number of activity to combine.
$Queue Activity to be saved.

Открытые методы

Метод Описание
__construct ( ) Defines the related database table name.
activityQuery ( boolean $Join = true ) Build basis of common activity SQL query.
add ( integer $ActivityUserID, string $ActivityType, string $Story = null, integer | null $RegardingUserID = null, integer $CommentActivityID = null, string $Route = null, string | boolean $SendEmail = '' ) : integer Add a new activity item.
calculateData ( &$Data )
calculateRow ( &$Row )
canDelete ( $activity ) : boolean
clearNotificationQueue ( ) Clear notification queue.
comment ( array $Comment ) : integer | boolean | string Save a comment on an activity.
defineType ( string $Name, array $Activity = [] ) Define a new activity type.
delete ( $where = [], $options = [] )
deleteComment ( integer $ID ) : Gdn_DataSet Delete an activity comment.
deleteID ( integer $ActivityID, array $Options = [] ) : boolean Delete a particular activity item.
email ( &$Activity, boolean $NoDelete = false ) : boolean
getActivityType ( $ActivityType ) : boolean
getByUser ( integer | boolean $NotifyUserID = false, integer $Offset, integer $Limit = 30 ) : Gdn_DataSet Modifies standard Gdn_Model->Get to use AcitivityQuery.
getComment ( integer $ID ) : array | false
getComments ( array $ActivityIDs ) : Gdn_DataSet Get comments related to designated activity items.
getCount ( string $UserID = '' ) : integer Get number of activity related to a user.
getCountForRole ( integer | string $RoleID = '' ) : integer Get number of activity related to a particular role.
getForRole ( string $RoleID = '', integer $Offset, integer $Limit = 50 ) : Gdn_DataSet Get activity related to a particular role.
getID ( integer $activityID, boolean | string $dataSetType = false, array $options = [] ) : array | object Get a particular activity record.
getNotifications ( integer $NotifyUserID, integer $Offset, integer $Limit = 30 ) : Gdn_DataSet Get notifications for a user.
getNotificationsSince ( integer $UserID, integer $LastActivityID, array | string $FilterToActivityTypeIDs = '', integer $Limit = 5 ) : Gdn_DataSet Get notifications for a user since designated ActivityID.
getPruneAfter ( ) : string Get the delete after time.
getUsers ( &$Data )
getWhere ( array $Where = [], string $orderFields = '', string $orderDirection = '', integer | boolean $Limit = false, integer | boolean $Offset = false ) : Gdn_DataSet Modifies standard Gdn_Model->GetWhere to use AcitivityQuery.
getWhereRecent ( array $where, integer $limit, integer $offset ) : Gdn_DataSet Get the recent activities.
joinComments ( &$Activities )
joinUsers ( &$Activities ) Join the users to the activities.
markRead ( $UserID )
mergeActivities ( $OldActivity, $NewActivity, array $Options = [] ) : array
notificationPreference ( string $ActivityType, array $Preferences, string $Type = null ) : boolean | bool[] Get default notification preference for an activity type.
queue ( array $Data, string | boolean $Preference = false, array $Options = [] ) Queue an activity for saving later.
queueNotification ( integer $ActivityID, string $Story = '', string $Position = 'last', boolean $Force = false ) Queue a notification for sending.
save ( array $Data, boolean $Preference = false, array $Options = [] ) : array | boolean | string | null
saveQueue ( ) : array
sendNotification ( integer $ActivityID, array | string $Story = '', boolean $Force = false ) Send notification.
sendNotificationQueue ( ) Send all notifications in the queue.
setNotified ( $ActivityIDs )
setPruneAfter ( string $pruneAfter ) : ActivityModel Set the prune after date.
share ( &$Activity )

Защищенные методы

Метод Описание
_touch ( &$Data )
notifyWallComment ( array $Comment, $WallPost ) Notify the user of wall comments.
notifyWallPost ( $WallPost )

Приватные методы

Метод Описание
getEmailMessage ( array | object $activity ) : string Takes an array representing an activity and builds the email message based on the activity's story and the contents of the global config Garden.Email.Prefix.
getPruneDate ( ) : DateTime | null Get the exact timestamp to prune.
prune ( ) Prune old activities.

Описание методов

__construct() публичный Метод

Defines the related database table name.
public __construct ( )

_touch() защищенный Метод

protected _touch ( &$Data )
$Data

activityQuery() публичный Метод

Build basis of common activity SQL query.
С версии: 2.0.0
public activityQuery ( boolean $Join = true )
$Join boolean

add() публичный Метод

Getting reworked for 2.1 so I'm cheating and skipping params for now. -mlr
public add ( integer $ActivityUserID, string $ActivityType, string $Story = null, integer | null $RegardingUserID = null, integer $CommentActivityID = null, string $Route = null, string | boolean $SendEmail = '' ) : integer
$ActivityUserID integer
$ActivityType string
$Story string
$RegardingUserID integer | null
$CommentActivityID integer
$Route string
$SendEmail string | boolean
Результат integer ActivityID of item created.

calculateData() публичный Метод

public calculateData ( &$Data )
$Data

calculateRow() публичный Метод

public calculateRow ( &$Row )
$Row

canDelete() публичный статический Метод

public static canDelete ( $activity ) : boolean
$activity
Результат boolean

clearNotificationQueue() публичный Метод

Clear notification queue.
С версии: 2.0.17

comment() публичный Метод

Save a comment on an activity.
С версии: 2.1
public comment ( array $Comment ) : integer | boolean | string
$Comment array
Результат integer | boolean | string

defineType() публичный Метод

Define a new activity type.
С версии: 2.1
public defineType ( string $Name, array $Activity = [] )
$Name string The string code of the activity type.
$Activity array The data that goes in the ActivityType table.

delete() публичный Метод

public delete ( $where = [], $options = [] )

deleteComment() публичный Метод

Delete an activity comment.
С версии: 2.1
public deleteComment ( integer $ID ) : Gdn_DataSet
$ID integer
Результат Gdn_DataSet

deleteID() публичный Метод

Delete a particular activity item.
public deleteID ( integer $ActivityID, array $Options = [] ) : boolean
$ActivityID integer The unique ID of activity to be deleted.
$Options array Not used.
Результат boolean Returns **true** if the activity was deleted or **false** otherwise.

email() публичный Метод

public email ( &$Activity, boolean $NoDelete = false ) : boolean
$Activity
$NoDelete boolean
Результат boolean

getActivityType() публичный статический Метод

public static getActivityType ( $ActivityType ) : boolean
$ActivityType
Результат boolean

getByUser() публичный Метод

Events: BeforeGet, AfterGet.
public getByUser ( integer | boolean $NotifyUserID = false, integer $Offset, integer $Limit = 30 ) : Gdn_DataSet
$NotifyUserID integer | boolean Unique ID of user to gather activity for or one of the NOTIFY_* constants in this class.
$Offset integer Number to skip.
$Limit integer How many to return.
Результат Gdn_DataSet SQL results.

getComment() публичный Метод

public getComment ( integer $ID ) : array | false
$ID integer
Результат array | false

getComments() публичный Метод

Events: BeforeGetComments.
public getComments ( array $ActivityIDs ) : Gdn_DataSet
$ActivityIDs array IDs of activity items.
Результат Gdn_DataSet SQL results.

getCount() публичный Метод

Events: BeforeGetCount.
С версии: 2.0.0
public getCount ( string $UserID = '' ) : integer
$UserID string Unique ID of user.
Результат integer Number of activity items found.

getCountForRole() публичный Метод

Get number of activity related to a particular role.
С версии: 2.0.18
public getCountForRole ( integer | string $RoleID = '' ) : integer
$RoleID integer | string Unique ID of role.
Результат integer Number of activity items.

getForRole() публичный Метод

Events: AfterGet.
С версии: 2.0.18
public getForRole ( string $RoleID = '', integer $Offset, integer $Limit = 50 ) : Gdn_DataSet
$RoleID string Unique ID of role.
$Offset integer Number to skip.
$Limit integer Max number to return.
Результат Gdn_DataSet SQL results.

getID() публичный Метод

Get a particular activity record.
public getID ( integer $activityID, boolean | string $dataSetType = false, array $options = [] ) : array | object
$activityID integer Unique ID of activity item.
$dataSetType boolean | string The format of the resulting data.
$options array Not used.
Результат array | object A single SQL result.

getNotifications() публичный Метод

Events: BeforeGetNotifications.
С версии: 2.0.0
public getNotifications ( integer $NotifyUserID, integer $Offset, integer $Limit = 30 ) : Gdn_DataSet
$NotifyUserID integer Unique ID of user.
$Offset integer Number to skip.
$Limit integer Max number to return.
Результат Gdn_DataSet SQL results.

getNotificationsSince() публичный Метод

Events: BeforeGetNotificationsSince.
С версии: 2.0.18
public getNotificationsSince ( integer $UserID, integer $LastActivityID, array | string $FilterToActivityTypeIDs = '', integer $Limit = 5 ) : Gdn_DataSet
$UserID integer Unique ID of user.
$LastActivityID integer ID of activity to start at.
$FilterToActivityTypeIDs array | string Limits returned activity to particular types.
$Limit integer Max number to return.
Результат Gdn_DataSet SQL results.

getPruneAfter() публичный Метод

Get the delete after time.
public getPruneAfter ( ) : string
Результат string Returns a string compatible with {@link strtotime()}.

getUsers() публичный статический Метод

public static getUsers ( &$Data )

getWhere() публичный Метод

Events: AfterGet.
public getWhere ( array $Where = [], string $orderFields = '', string $orderDirection = '', integer | boolean $Limit = false, integer | boolean $Offset = false ) : Gdn_DataSet
$Where array A filter suitable for passing to Gdn_SQLDriver::Where().
$orderFields string A comma delimited string to order the data.
$orderDirection string One of **asc** or **desc**.
$Limit integer | boolean The database limit.
$Offset integer | boolean The database offset.
Результат Gdn_DataSet SQL results.

getWhereRecent() публичный Метод

Get the recent activities.
public getWhereRecent ( array $where, integer $limit, integer $offset ) : Gdn_DataSet
$where array
$limit integer
$offset integer
Результат Gdn_DataSet

joinComments() публичный Метод

С версии: 2.1
public joinComments ( &$Activities )

joinUsers() публичный статический Метод

Join the users to the activities.
public static joinUsers ( &$Activities )

markRead() публичный Метод

public markRead ( $UserID )
$UserID

mergeActivities() публичный Метод

public mergeActivities ( $OldActivity, $NewActivity, array $Options = [] ) : array
$OldActivity
$NewActivity
$Options array
Результат array

notificationPreference() публичный статический Метод

Get default notification preference for an activity type.
С версии: 2.0.0
public static notificationPreference ( string $ActivityType, array $Preferences, string $Type = null ) : boolean | bool[]
$ActivityType string
$Preferences array
$Type string One of the following: - Popup: Popup a notification. - Email: Email the notification. - NULL: True if either notification is true. - both: Return an array of (Popup, Email).
Результат boolean | bool[]

notifyWallComment() защищенный Метод

Notify the user of wall comments.
protected notifyWallComment ( array $Comment, $WallPost )
$Comment array
$WallPost

notifyWallPost() защищенный Метод

protected notifyWallPost ( $WallPost )
$WallPost

queue() публичный Метод

Queue an activity for saving later.
public queue ( array $Data, string | boolean $Preference = false, array $Options = [] )
$Data array The data in the activity.
$Preference string | boolean The name of the preference governing the activity.
$Options array Additional options for saving.

queueNotification() публичный Метод

Queue a notification for sending.
С версии: 2.0.17
public queueNotification ( integer $ActivityID, string $Story = '', string $Position = 'last', boolean $Force = false )
$ActivityID integer
$Story string
$Position string
$Force boolean

save() публичный Метод

public save ( array $Data, boolean $Preference = false, array $Options = [] ) : array | boolean | string | null
$Data array
$Preference boolean
$Options array
Результат array | boolean | string | null

saveQueue() публичный Метод

public saveQueue ( ) : array
Результат array

sendNotification() публичный Метод

Send notification.
С версии: 2.0.17
public sendNotification ( integer $ActivityID, array | string $Story = '', boolean $Force = false )
$ActivityID integer
$Story array | string
$Force boolean

sendNotificationQueue() публичный Метод

Send all notifications in the queue.
С версии: 2.0.17

setNotified() публичный Метод

public setNotified ( $ActivityIDs )
$ActivityIDs

setPruneAfter() публичный Метод

Set the prune after date.
public setPruneAfter ( string $pruneAfter ) : ActivityModel
$pruneAfter string A string compatible with {@link strtotime()}. Be sure to specify a negative string.
Результат ActivityModel Returns `$this` for fluent calls.

share() публичный Метод

public share ( &$Activity )
$Activity

Описание свойств

$ActivityTypes публичное статическое свойство

Allowed activity types.
public static $ActivityTypes

$MaxMergeCount публичное статическое свойство

Limit on number of activity to combine.
public static $MaxMergeCount

$Queue публичное статическое свойство

Activity to be saved.
public static $Queue