Constants

DELETED_USER

DELETED_USER

Methods

get()

get(string  $id) : \OCP\Comments\IComment

returns a comment instance

Parameters

string $id

the ID of the comment

Throws

\OCP\Comments\NotFoundException

Returns

\OCP\Comments\IComment

getTree()

getTree(string  $id, integer  $limit, integer  $offset) : array

returns the comment specified by the id and all it's child comments

Parameters

string $id
integer $limit

max number of entries to return, 0 returns all

integer $offset

the start entry

Returns

array

getForObject()

getForObject(string  $objectType, string  $objectId, integer  $limit, integer  $offset, \DateTime  $notOlderThan = null) : array<mixed,\OCP\Comments\IComment>

returns comments for a specific object (e.g. a file).

The sort order is always newest to oldest.

Parameters

string $objectType

the object type, e.g. 'files'

string $objectId

the id of the object

integer $limit

optional, number of maximum comments to be returned. if not specified, all comments are returned.

integer $offset

optional, starting point

\DateTime $notOlderThan

optional, timestamp of the oldest comments that may be returned

Returns

array<mixed,\OCP\Comments\IComment>

getNumberOfUnreadCommentsForNodes()

getNumberOfUnreadCommentsForNodes(string  $objectType, array<mixed,integer>  $objectIds, \OCP\IUser  $user) : array<mixed,integer>

Returns number of unread messages for specified nodeIDs, if there are any unread comments

Example query: SELECT object_id, COUNT(object_id) FROM oc_comments C WHERE object_id IN('79', '80', '34', '36', '38', '33') AND object_id NOT IN( SELECT object_id FROM oc_comments_read_markers CRM WHERE C.object_id = CRM.object_id AND user_id = 'receiver2' AND marker_datetime > C.creation_timestamp) GROUP BY object_id;

Parameters

string $objectType

string the object type: Example 'files'

array<mixed,integer> $objectIds

NodeIDs that may be returned: Example { 44, 36, 50, 60 }[4]

\OCP\IUser $user

Returns

array<mixed,integer> —

$unreadCountsForNodes hash table: Example { 44 => 2, 36 => 1 }[2]

getNumberOfCommentsForObject()

getNumberOfCommentsForObject(  $objectType,   $objectId, \DateTime  $notOlderThan = null) : Int

Parameters

$objectType

string the object type, e.g. 'files'

$objectId

string the id of the object

\DateTime $notOlderThan

optional, timestamp of the oldest comments that may be returned

Returns

Int

create()

create(string  $actorType, string  $actorId, string  $objectType, string  $objectId) : \OCP\Comments\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).

Parameters

string $actorType

the actor type (e.g. 'users')

string $actorId

a user id

string $objectType

the object type the comment is attached to

string $objectId

the object id the comment is attached to

Returns

\OCP\Comments\IComment

delete()

delete(string  $id) : boolean

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.

Parameters

string $id

Returns

boolean

save()

save(\OCP\Comments\IComment  $comment) : boolean

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.

Parameters

\OCP\Comments\IComment $comment

Throws

\OCP\Comments\NotFoundException

Returns

boolean

deleteReferencesOfActor()

deleteReferencesOfActor(string  $actorType, string  $actorId) : boolean

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.

Parameters

string $actorType

the actor type (e.g. 'users')

string $actorId

a user id

Returns

boolean

deleteCommentsAtObject()

deleteCommentsAtObject(string  $objectType, string  $objectId) : boolean

deletes all comments made of a specific object (e.g. on file delete)

Parameters

string $objectType

the object type (e.g. 'files')

string $objectId

e.g. the file id

Returns

boolean

setReadMark()

setReadMark(string  $objectType, string  $objectId, \DateTime  $dateTime, \OCP\IUser  $user) 

sets the read marker for a given file to the specified date for the provided user

Parameters

string $objectType
string $objectId
\DateTime $dateTime
\OCP\IUser $user

getReadMark()

getReadMark(string  $objectType, string  $objectId, \OCP\IUser  $user) : \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.

no comments were marked as read.

Parameters

string $objectType
string $objectId
\OCP\IUser $user

Returns

\DateTime|null

deleteReadMarksFromUser()

deleteReadMarksFromUser(\OCP\IUser  $user) : boolean

deletes the read markers for the specified user

Parameters

\OCP\IUser $user

Returns

boolean

deleteReadMarksOnObject()

deleteReadMarksOnObject(string  $objectType, string  $objectId) : boolean

deletes the read markers on the specified object

Parameters

string $objectType
string $objectId

Returns

boolean