Exemplo n.º 1
0
 /**
  * Returns a list of properties for this nodes.
  *
  * The properties list is a list of propertynames the client requested,
  * encoded in clark-notation {xmlnamespace}tagname
  *
  * If the array is empty, it means 'all properties' were requested.
  *
  * Note that it's fine to liberally give properties back, instead of
  * conforming to the list of requested properties.
  * The Server class will filter out the extra.
  *
  * @param array $properties
  * @return array
  */
 function getProperties($properties)
 {
     $properties = array_keys($this->properties);
     $result = [];
     foreach ($properties as $property) {
         $getter = $this->properties[$property];
         if (method_exists($this->comment, $getter)) {
             $result[$property] = $this->comment->{$getter}();
         }
     }
     if ($this->comment->getActorType() === 'users') {
         $user = $this->userManager->get($this->comment->getActorId());
         $displayName = is_null($user) ? null : $user->getDisplayName();
         $result[self::PROPERTY_NAME_ACTOR_DISPLAYNAME] = $displayName;
     }
     $unread = null;
     $user = $this->userSession->getUser();
     if (!is_null($user)) {
         $readUntil = $this->commentsManager->getReadMark($this->comment->getObjectType(), $this->comment->getObjectId(), $user);
         if (is_null($readUntil)) {
             $unread = 'true';
         } else {
             $unread = $this->comment->getCreationDateTime() > $readUntil;
             // re-format for output
             $unread = $unread ? 'true' : 'false';
         }
     }
     $result[self::PROPERTY_NAME_UNREAD] = $unread;
     return $result;
 }
Exemplo n.º 2
0
 /**
  * returns the number of unread comments for the currently logged in user
  * on the given file or directory node
  *
  * @param Node $node
  * @return Int|null
  */
 public function getUnreadCount(Node $node)
 {
     $user = $this->userSession->getUser();
     if (is_null($user)) {
         return null;
     }
     $lastRead = $this->commentsManager->getReadMark('files', strval($node->getId()), $user);
     return $this->commentsManager->getNumberOfCommentsForObject('files', strval($node->getId()), $lastRead);
 }