diff options
author | Joas Schilling <nickvergessen@owncloud.com> | 2016-03-21 09:41:13 +0100 |
---|---|---|
committer | Joas Schilling <nickvergessen@owncloud.com> | 2016-03-21 09:41:13 +0100 |
commit | b2f4e4559f0064544dbc708785967b61a03b6486 (patch) | |
tree | 573687a09cb7845ce72ab26df4eef8b92c225784 /apps/comments | |
parent | a6c921267e00d0fb5021e8bdbd4d202931d7a58a (diff) | |
download | nextcloud-server-b2f4e4559f0064544dbc708785967b61a03b6486.tar.gz nextcloud-server-b2f4e4559f0064544dbc708785967b61a03b6486.zip |
Add comment icons and "You commented" translations
Diffstat (limited to 'apps/comments')
-rw-r--r-- | apps/comments/activity/extension.php | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/apps/comments/activity/extension.php b/apps/comments/activity/extension.php index b65f1911d17..6bf7cae5882 100644 --- a/apps/comments/activity/extension.php +++ b/apps/comments/activity/extension.php @@ -105,7 +105,7 @@ class Extension implements IExtension { public function getTypeIcon($type) { switch ($type) { case self::APP_NAME: - return false; + return 'icon-comment'; } return false; @@ -150,6 +150,9 @@ class Extension implements IExtension { switch ($text) { case self::ADD_COMMENT_SUBJECT: + if ($this->authorIsCurrentUser($params[0])) { + return (string) $l->t('You commented'); + } return (string) $l->t('%1$s commented', $params); case self::ADD_COMMENT_MESSAGE: return $this->convertParameterToComment($params[0], 120); @@ -168,6 +171,9 @@ class Extension implements IExtension { switch ($text) { case self::ADD_COMMENT_SUBJECT: + if ($this->authorIsCurrentUser($params[0])) { + return (string) $l->t('You commented on %2$s', $params); + } return (string) $l->t('%1$s commented on %2$s', $params); case self::ADD_COMMENT_MESSAGE: return $this->convertParameterToComment($params[0]); @@ -177,6 +183,21 @@ class Extension implements IExtension { } /** + * Check if the author is the current user + * + * @param string $user Parameter e.g. `<user display-name="admin">admin</user>` + * @return bool + */ + protected function authorIsCurrentUser($user) { + try { + return strip_tags($user) === $this->activityManager->getCurrentUserId(); + } catch (\UnexpectedValueException $e) { + // FIXME this is awkward, but we have no access to the current user in emails + return false; + } + } + + /** * The extension can define the type of parameters for translation * * Currently known types are: |