ICommentsManager
Interface ICommentsManager
This class manages the access to comments
Tags
Table of Contents
- DELETED_USER = 'deleted_users'
- create() : IComment
- creates a new comment and returns it. At this point of time, it is not saved in the used data storage. Use save() after setting other fields of the comment (e.g. message or verb).
- delete() : bool
- permanently deletes the comment specified by the ID
- deleteCommentsAtObject() : bool
- deletes all comments made of a specific object (e.g. on file delete)
- deleteReadMarksFromUser() : bool
- deletes the read markers for the specified user
- deleteReadMarksOnObject() : bool
- deletes the read markers on the specified object
- deleteReferencesOfActor() : bool
- removes references to specific actor (e.g. on user delete) of a comment.
- get() : IComment
- returns a comment instance
- getForObject() : \OCP\Comments\IComment[]
- returns comments for a specific object (e.g. a file).
- getForObjectSince() : \OCP\Comments\IComment[]
- getNumberOfCommentsForObject() : int
- getNumberOfUnreadCommentsForFolder() : array
- Get the number of unread comments for all files in a folder
- getReadMark() : DateTime|null
- returns the read marker for a given file to the specified date for the provided user. It returns null, when the marker is not present, i.e.
- getTree() : array
- returns the comment specified by the id and all it's child comments
- registerDisplayNameResolver() : mixed
- registers a method that resolves an ID to a display name for a given type
- registerEventHandler() : mixed
- registers an Entity to the manager, so event notifications can be send to consumers of the comments infrastructure
- resolveDisplayName() : string
- resolves a given ID of a given Type to a display name.
- save() : bool
- saves the comment permanently
- search() : \OCP\Comments\IComment[]
- Search for comments with a given content
- setReadMark() : mixed
- sets the read marker for a given file to the specified date for the provided user
Constants
DELETED_USER
public
mixed
DELETED_USER
= 'deleted_users'
Tags
Methods
create()
creates a new comment and returns it. At this point of time, it is not saved in the used data storage. Use save() after setting other fields of the comment (e.g. message or verb).
public
create(string $actorType, string $actorId, string $objectType, string $objectId) : IComment
Parameters
- $actorType : string
-
the actor type (e.g. 'users')
- $actorId : string
-
a user id
- $objectType : string
-
the object type the comment is attached to
- $objectId : string
-
the object id the comment is attached to
Tags
Return values
IComment —delete()
permanently deletes the comment specified by the ID
public
delete(string $id) : bool
When the comment has child comments, their parent ID will be changed to the parent ID of the item that is to be deleted.
Parameters
- $id : string
Tags
Return values
bool —deleteCommentsAtObject()
deletes all comments made of a specific object (e.g. on file delete)
public
deleteCommentsAtObject(string $objectType, string $objectId) : bool
Parameters
- $objectType : string
-
the object type (e.g. 'files')
- $objectId : string
-
e.g. the file id
Tags
Return values
bool —deleteReadMarksFromUser()
deletes the read markers for the specified user
public
deleteReadMarksFromUser(IUser $user) : bool
Parameters
- $user : IUser
Tags
Return values
bool —deleteReadMarksOnObject()
deletes the read markers on the specified object
public
deleteReadMarksOnObject(string $objectType, string $objectId) : bool
Parameters
- $objectType : string
- $objectId : string
Tags
Return values
bool —deleteReferencesOfActor()
removes references to specific actor (e.g. on user delete) of a comment.
public
deleteReferencesOfActor(string $actorType, string $actorId) : bool
The comment itself must not get lost/deleted.
A 'users' type actor (type and id) should get replaced by the value of the DELETED_USER constant of this interface.
Parameters
- $actorType : string
-
the actor type (e.g. 'users')
- $actorId : string
-
a user id
Tags
Return values
bool —get()
returns a comment instance
public
get(string $id) : IComment
Parameters
- $id : string
-
the ID of the comment
Tags
Return values
IComment —getForObject()
returns comments for a specific object (e.g. a file).
public
getForObject(string $objectType, string $objectId, int $limit, int $offset[, DateTime|null $notOlderThan = null ]) : \OCP\Comments\IComment[]
The sort order is always newest to oldest.
Parameters
- $objectType : string
-
the object type, e.g. 'files'
- $objectId : string
-
the id of the object
- $limit : int
-
optional, number of maximum comments to be returned. if not specified, all comments are returned.
- $offset : int
-
optional, starting point
- $notOlderThan : DateTime|null = null
-
optional, timestamp of the oldest comments that may be returned
Tags
Return values
\OCP\Comments\IComment[] —getForObjectSince()
public
getForObjectSince(string $objectType, string $objectId, int $lastKnownCommentId[, string $sortDirection = 'asc' ][, int $limit = 30 ]) : \OCP\Comments\IComment[]
Parameters
- $objectType : string
-
the object type, e.g. 'files'
- $objectId : string
-
the id of the object
- $lastKnownCommentId : int
-
the last known comment (will be used as offset)
- $sortDirection : string = 'asc'
-
direction of the comments (
asc
ordesc
) - $limit : int = 30
-
optional, number of maximum comments to be returned. if set to 0, all comments are returned.
Tags
Return values
\OCP\Comments\IComment[] —getNumberOfCommentsForObject()
public
getNumberOfCommentsForObject( $objectType, $objectId[, DateTime|null $notOlderThan = null ][, string $verb = '' ]) : int
Parameters
- $objectType :
-
the object type, e.g. 'files'
- $objectId :
-
the id of the object
- $notOlderThan : DateTime|null = null
-
optional, timestamp of the oldest comments that may be returned
- $verb : string = ''
-
Limit the verb of the comment - Added in 14.0.0
Tags
Return values
int —getNumberOfUnreadCommentsForFolder()
Get the number of unread comments for all files in a folder
public
getNumberOfUnreadCommentsForFolder(int $folderId, IUser $user) : array
Parameters
- $folderId : int
- $user : IUser
Tags
Return values
array —[$fileId => $unreadCount]
getReadMark()
returns the read marker for a given file to the specified date for the provided user. It returns null, when the marker is not present, i.e.
public
getReadMark(string $objectType, string $objectId, IUser $user) : DateTime|null
no comments were marked as read.
Parameters
- $objectType : string
- $objectId : string
- $user : IUser
Tags
Return values
DateTime|null —getTree()
returns the comment specified by the id and all it's child comments
public
getTree(string $id, int $limit, int $offset) : array
Parameters
- $id : string
- $limit : int
-
max number of entries to return, 0 returns all
- $offset : int
-
the start entry
Tags
Return values
array —registerDisplayNameResolver()
registers a method that resolves an ID to a display name for a given type
public
registerDisplayNameResolver(string $type, Closure $closure) : mixed
Parameters
- $type : string
- $closure : Closure
Tags
Return values
mixed —registerEventHandler()
registers an Entity to the manager, so event notifications can be send to consumers of the comments infrastructure
public
registerEventHandler(Closure $closure) : mixed
Parameters
- $closure : Closure
Tags
Return values
mixed —resolveDisplayName()
resolves a given ID of a given Type to a display name.
public
resolveDisplayName(string $type, string $id) : string
Parameters
- $type : string
- $id : string
Tags
Return values
string —save()
saves the comment permanently
public
save(IComment $comment) : bool
if the supplied comment has an empty ID, a new entry comment will be saved and the instance updated with the new ID.
Otherwise, an existing comment will be updated.
Throws NotFoundException when a comment that is to be updated does not exist anymore at this point of time.
Parameters
- $comment : IComment
Tags
Return values
bool —search()
Search for comments with a given content
public
search(string $search, string $objectType, string $objectId, string $verb, int $offset[, int $limit = 50 ]) : \OCP\Comments\IComment[]
Parameters
- $search : string
-
content to search for
- $objectType : string
-
Limit the search by object type
- $objectId : string
-
Limit the search by object id
- $verb : string
-
Limit the verb of the comment
- $offset : int
- $limit : int = 50
Tags
Return values
\OCP\Comments\IComment[] —setReadMark()
sets the read marker for a given file to the specified date for the provided user
public
setReadMark(string $objectType, string $objectId, DateTime $dateTime, IUser $user) : mixed
Parameters
- $objectType : string
- $objectId : string
- $dateTime : DateTime
- $user : IUser