ICommentsManager¶
-
interface
OCP\Comments\
ICommentsManager
¶ - Interface ICommentsManagerThis class manages the access to comments
Implemented by: OC\Comments\Manager
Source: lib/public/Comments/ICommentsManager.php#41
Constants¶
-
DELETED_USER = deleted_users
Source: See: \OCP\Comments\deleteReferencesOfActor
Since: 9.0.0 To be used as replacement for user type actors in deleteReferencesOfActor().
User interfaces shall show “Deleted user” as display name, if needed.
Methods¶
-
public
OCP\Comments\ICommentsManager::
get
($id)¶ - returns a comment instance
Source: Parameters: - $id (string) the ID of the comment
Returns: Throws: Since: 9.0.0
-
public
OCP\Comments\ICommentsManager::
getTree
($id, $limit=0, $offset=0)¶ - returns the comment specified by the id and all it’s child comments
Source: Parameters: - $id (string)
- $limit (int) max number of entries to return, 0 returns all
- $offset (int) the start entry
Returns: array
Since: 9.0.0 The return array looks like this [
‘comment’ => IComment, // root comment
‘replies’ => [
0 => [
‘comment’ => IComment, ‘replies’ => [
0 => [
‘comment’ => IComment, ‘replies’ => [ … ]
], …
]
] 1 => [
‘comment’ => IComment, ‘replies’=> [ … ]
], …
]
]
-
public
OCP\Comments\ICommentsManager::
getForObject
($objectType, $objectId, $limit=0, $offset=0, $notOlderThan=null)¶ - returns comments for a specific object (e.g. a file).The sort order is always newest to oldest.
Source: 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) optional, timestamp of the oldest comments that may be returnedReturns: Since: 9.0.0
-
public
OCP\Comments\ICommentsManager::
getForObjectSince
($objectType, $objectId, $lastKnownCommentId, $sortDirection=asc, $limit=30, $includeLastKnown=false)¶ Source: 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) direction of the comments (asc or desc)
- $limit (int) optional, number of maximum comments to be returned. if
set to 0, all comments are returned. * $includeLastKnown (bool)
Returns: Since: 14.0.0
-
public
OCP\Comments\ICommentsManager::
search
($search, $objectType, $objectId, $verb, $offset, $limit=50)¶ - Search for comments with a given content
Source: 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)
Returns: Since: 14.0.0
-
public
OCP\Comments\ICommentsManager::
searchForObjects
($search, $objectType, $objectIds, $verb, $offset, $limit=50)¶ - Search for comments on one or more objects with a given content
Source: Parameters: - $search (string) content to search for
- $objectType (string) Limit the search by object type
- $objectIds (array) Limit the search by object ids
- $verb (string) Limit the verb of the comment
- $offset (int)
- $limit (int)
Returns: Since: 21.0.0
-
public
OCP\Comments\ICommentsManager::
getNumberOfCommentsForObject
($objectType, $objectId, $notOlderThan=null, $verb="")¶ Source: Parameters: - $objectType string the object type, e.g. ‘files’
- $objectId string the id of the object
- $notOlderThan (
DateTime
| null) optional, timestamp of the oldest comments
that may be returned * $verb (string) Limit the verb of the comment - Added in 14.0.0
Returns: int
Since: 9.0.0
-
public
OCP\Comments\ICommentsManager::
getNumberOfUnreadCommentsForObjects
($objectType, $objectIds, $user, $verb="")¶ Source: Parameters: - $objectType (string) the object type, e.g. ‘files’
- $objectIds (string[]) the id of the object
- $user (
OCP\IUser
) - $verb (string) Limit the verb of the comment - Added in 14.0.0
Returns: array Map with object id => # of unread comments
Since: 21.0.0
-
public
OCP\Comments\ICommentsManager::
getNumberOfCommentsForObjectSinceComment
($objectType, $objectId, $lastRead, $verb="")¶ Source: Parameters: - $objectType (string)
- $objectId (string)
- $lastRead (int)
- $verb (string)
Returns: int
Since: 21.0.0
-
public
OCP\Comments\ICommentsManager::
getLastCommentBeforeDate
($objectType, $objectId, $beforeDate, $verb="")¶ Source: Parameters: - $objectType (string)
- $objectId (string)
- $beforeDate (
DateTime
) - $verb (string)
Returns: int
Since: 21.0.0
-
public
OCP\Comments\ICommentsManager::
getLastCommentDateByActor
($objectType, $objectId, $verb, $actorType, $actors)¶ Source: Parameters: - $objectType (string)
- $objectId (string)
- $verb (string)
- $actorType (string)
- $actors (string[])
Returns: \DateTime[]
Map of “string actor” => “\DateTime most recent comment date”Since: 21.0.0
-
public
OCP\Comments\ICommentsManager::
getNumberOfUnreadCommentsForFolder
($folderId, $user)¶ - Get the number of unread comments for all files in a folder
Source: Parameters: - $folderId (int)
- $user (
OCP\IUser
)
Returns: array [$fileId => $unreadCount]
Since: 12.0.0
-
public
OCP\Comments\ICommentsManager::
create
($actorType, $actorId, $objectType, $objectId)¶ - creates a new comment and returns it. At this point of time, it is notsaved in the used data storage. Use save() after setting other fieldsof the comment (e.g. message or verb).
Source: 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
Returns: Since: 9.0.0
-
public
OCP\Comments\ICommentsManager::
delete
($id)¶ - permanently deletes the comment specified by the IDWhen the comment has child comments, their parent ID will be changed tothe parent ID of the item that is to be deleted.
Source: Parameters: - $id (string)
Returns: bool
Since: 9.0.0
-
public
OCP\Comments\ICommentsManager::
save
($comment)¶ - saves the comment permanentlyif the supplied comment has an empty ID, a new entry comment will besaved 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 notexist anymore at this point of time.
Source: Parameters: - $comment (
OCP\Comments\IComment
)
Returns: bool
Throws: Since: 9.0.0
- $comment (
-
public
OCP\Comments\ICommentsManager::
deleteReferencesOfActor
($actorType, $actorId)¶ - removes references to specific actor (e.g. on user delete) of a comment.The comment itself must not get lost/deleted.A ‘users’ type actor (type and id) should get replaced by thevalue of the DELETED_USER constant of this interface.
Source: Parameters: - $actorType (string) the actor type (e.g. ‘users’)
- $actorId (string) a user id
Returns: bool
Since: 9.0.0
-
public
OCP\Comments\ICommentsManager::
deleteCommentsAtObject
($objectType, $objectId)¶ - deletes all comments made of a specific object (e.g. on file delete)
Source: Parameters: - $objectType (string) the object type (e.g. ‘files’)
- $objectId (string) e.g. the file id
Returns: bool
Since: 9.0.0
-
public
OCP\Comments\ICommentsManager::
setReadMark
($objectType, $objectId, $dateTime, $user)¶ - sets the read marker for a given file to the specified date for theprovided user
Source: Parameters: - $objectType (string)
- $objectId (string)
- $dateTime (
DateTime
) - $user (
OCP\IUser
)
Since: 9.0.0
-
public
OCP\Comments\ICommentsManager::
getReadMark
($objectType, $objectId, $user)¶ - returns the read marker for a given file to the specified date for theprovided user. It returns null, when the marker is not present, i.e.no comments were marked as read.
Source: Parameters: - $objectType (string)
- $objectId (string)
- $user (
OCP\IUser
)
Returns: \DateTime
| nullSince: 9.0.0
-
public
OCP\Comments\ICommentsManager::
deleteReadMarksFromUser
($user)¶ - deletes the read markers for the specified user
Source: Parameters: - $user (
OCP\IUser
)
Returns: bool
Since: 9.0.0
- $user (
-
public
OCP\Comments\ICommentsManager::
deleteReadMarksOnObject
($objectType, $objectId)¶ - deletes the read markers on the specified object
Source: Parameters: - $objectType (string)
- $objectId (string)
Returns: bool
Since: 9.0.0
-
public
OCP\Comments\ICommentsManager::
registerEventHandler
($closure)¶ - registers an Entity to the manager, so event notifications can be sendto consumers of the comments infrastructure
Source: Parameters: - $closure (
Closure
)
Since: 11.0.0
- $closure (
-
public
OCP\Comments\ICommentsManager::
registerDisplayNameResolver
($type, $closure)¶ - registers a method that resolves an ID to a display name for a given type
Source: Parameters: - $type (string)
- $closure (
Closure
)
Throws: \OutOfBoundsException
Since: 11.0.0 Only one resolver shall be registered per type. Otherwise a \OutOfBoundsException has to thrown.
-
public
OCP\Comments\ICommentsManager::
resolveDisplayName
($type, $id)¶ - resolves a given ID of a given Type to a display name.
Source: Parameters: - $type (string)
- $id (string)
Returns: string
Throws: \OutOfBoundsException
Since: 11.0.0 If a provided type was not registered, an \OutOfBoundsException shall be thrown. It is upon the resolver discretion what to return of the provided ID is unknown. It must be ensured that a string is returned.
-
public
OCP\Comments\ICommentsManager::
load
()¶ - Load the Comments app into the page
Source: lib/public/Comments/ICommentsManager.php#397 Since: 21.0.0