ICommentsManager

interface OCP\Comments\ICommentsManager
Interface ICommentsManager
This class manages the access to comments
Implemented by:OC\Comments\Manager
Source:lib/public/Comments/ICommentsManager.php#41

Constants

DELETED_USER = deleted_users
Source:

lib/public/Comments/ICommentsManager.php#52

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:

lib/public/Comments/ICommentsManager.php#62

Parameters:
  • $id (string) the ID of the comment
Returns:

\OCP\Comments\IComment

Throws:

\OCP\Comments\NotFoundException

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:

lib/public/Comments/ICommentsManager.php#100

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:

lib/public/Comments/ICommentsManager.php#117

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 returned

Returns:

\OCP\Comments\IComment[]

Since:

9.0.0

public OCP\Comments\ICommentsManager::getForObjectSince($objectType, $objectId, $lastKnownCommentId, $sortDirection=asc, $limit=30, $includeLastKnown=false)
Source:

lib/public/Comments/ICommentsManager.php#136

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:

\OCP\Comments\IComment[]

Since:

14.0.0

public OCP\Comments\ICommentsManager::search($search, $objectType, $objectId, $verb, $offset, $limit=50)
Search for comments with a given content
Source:

lib/public/Comments/ICommentsManager.php#157

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:

\OCP\Comments\IComment[]

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:

lib/public/Comments/ICommentsManager.php#171

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:

\OCP\Comments\IComment[]

Since:

21.0.0

public OCP\Comments\ICommentsManager::getNumberOfCommentsForObject($objectType, $objectId, $notOlderThan=null, $verb="")
Source:

lib/public/Comments/ICommentsManager.php#182

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:

lib/public/Comments/ICommentsManager.php#193

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:

lib/public/Comments/ICommentsManager.php#203

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:

lib/public/Comments/ICommentsManager.php#213

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:

lib/public/Comments/ICommentsManager.php#225

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:

lib/public/Comments/ICommentsManager.php#241

Parameters:
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 not
saved in the used data storage. Use save() after setting other fields
of the comment (e.g. message or verb).
Source:

lib/public/Comments/ICommentsManager.php#255

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:

\OCP\Comments\IComment

Since:

9.0.0

public OCP\Comments\ICommentsManager::delete($id)
permanently deletes the comment specified by the ID
When the comment has child comments, their parent ID will be changed to
the parent ID of the item that is to be deleted.
Source:

lib/public/Comments/ICommentsManager.php#267

Parameters:
  • $id (string)
Returns:

bool

Since:

9.0.0

public OCP\Comments\ICommentsManager::save($comment)
saves the comment permanently
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.
Source:

lib/public/Comments/ICommentsManager.php#285

Parameters:
Returns:

bool

Throws:

\OCP\Comments\NotFoundException

Since:

9.0.0

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 the
value of the DELETED_USER constant of this interface.
Source:

lib/public/Comments/ICommentsManager.php#299

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:

lib/public/Comments/ICommentsManager.php#309

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 the
provided user
Source:

lib/public/Comments/ICommentsManager.php#321

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 the
provided user. It returns null, when the marker is not present, i.e.
no comments were marked as read.
Source:

lib/public/Comments/ICommentsManager.php#334

Parameters:
  • $objectType (string)
  • $objectId (string)
  • $user (OCP\IUser)
Returns:

\DateTime | null

Since:

9.0.0

public OCP\Comments\ICommentsManager::deleteReadMarksFromUser($user)
deletes the read markers for the specified user
Source:

lib/public/Comments/ICommentsManager.php#343

Parameters:
Returns:

bool

Since:

9.0.0

public OCP\Comments\ICommentsManager::deleteReadMarksOnObject($objectType, $objectId)
deletes the read markers on the specified object
Source:

lib/public/Comments/ICommentsManager.php#353

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 send
to consumers of the comments infrastructure
Source:

lib/public/Comments/ICommentsManager.php#362

Parameters:
  • $closure (Closure)
Since:

11.0.0

public OCP\Comments\ICommentsManager::registerDisplayNameResolver($type, $closure)
registers a method that resolves an ID to a display name for a given type
Source:

lib/public/Comments/ICommentsManager.php#375

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:

lib/public/Comments/ICommentsManager.php#390

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