Add comment icons and "You commented" translations
This commit is contained in:
parent
da95db78d0
commit
d59860aacd
|
@ -105,7 +105,7 @@ class Extension implements IExtension {
|
||||||
public function getTypeIcon($type) {
|
public function getTypeIcon($type) {
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case self::APP_NAME:
|
case self::APP_NAME:
|
||||||
return false;
|
return 'icon-comment';
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -150,6 +150,9 @@ class Extension implements IExtension {
|
||||||
|
|
||||||
switch ($text) {
|
switch ($text) {
|
||||||
case self::ADD_COMMENT_SUBJECT:
|
case self::ADD_COMMENT_SUBJECT:
|
||||||
|
if ($this->authorIsCurrentUser($params[0])) {
|
||||||
|
return (string) $l->t('You commented');
|
||||||
|
}
|
||||||
return (string) $l->t('%1$s commented', $params);
|
return (string) $l->t('%1$s commented', $params);
|
||||||
case self::ADD_COMMENT_MESSAGE:
|
case self::ADD_COMMENT_MESSAGE:
|
||||||
return $this->convertParameterToComment($params[0], 120);
|
return $this->convertParameterToComment($params[0], 120);
|
||||||
|
@ -168,6 +171,9 @@ class Extension implements IExtension {
|
||||||
|
|
||||||
switch ($text) {
|
switch ($text) {
|
||||||
case self::ADD_COMMENT_SUBJECT:
|
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);
|
return (string) $l->t('%1$s commented on %2$s', $params);
|
||||||
case self::ADD_COMMENT_MESSAGE:
|
case self::ADD_COMMENT_MESSAGE:
|
||||||
return $this->convertParameterToComment($params[0]);
|
return $this->convertParameterToComment($params[0]);
|
||||||
|
@ -176,6 +182,21 @@ class Extension implements IExtension {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
* The extension can define the type of parameters for translation
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue