diff options
-rw-r--r-- | app/Core/Translator.php | 11 | ||||
-rw-r--r-- | app/Model/Notification.php | 39 | ||||
-rw-r--r-- | app/Templates/notification_task_creation.php | 4 | ||||
-rw-r--r-- | app/Templates/notification_task_update.php | 4 |
4 files changed, 43 insertions, 15 deletions
diff --git a/app/Core/Translator.php b/app/Core/Translator.php index 14a2d372..c34a40ba 100644 --- a/app/Core/Translator.php +++ b/app/Core/Translator.php @@ -47,6 +47,17 @@ class Translator } /** + * Enable HTML escaping for translations + * + * @static + * @access public + */ + public static function enableEscaping() + { + self::$enable_escaping = true; + } + + /** * Get a translation * * $translator->translate('I have %d kids', 5); diff --git a/app/Model/Notification.php b/app/Model/Notification.php index e0f932a4..a92ce73e 100644 --- a/app/Model/Notification.php +++ b/app/Model/Notification.php @@ -2,6 +2,7 @@ namespace Model; +use Core\Translator; use Core\Template; use Event\TaskNotificationListener; use Event\CommentNotificationListener; @@ -114,30 +115,46 @@ class Notification extends Base */ public function getMailSubject($template, array $data) { + Translator::disableEscaping(); + switch ($template) { case 'notification_file_creation': - return t('[%s][New attachment] %s (#%d)', $data['task']['project_name'], $data['task']['title'], $data['task']['id']); + $subject = t('[%s][New attachment] %s (#%d)', $data['task']['project_name'], $data['task']['title'], $data['task']['id']); + break; case 'notification_comment_creation': - return t('[%s][New comment] %s (#%d)', $data['task']['project_name'], $data['task']['title'], $data['task']['id']); + $subject = t('[%s][New comment] %s (#%d)', $data['task']['project_name'], $data['task']['title'], $data['task']['id']); + break; case 'notification_comment_update': - return t('[%s][Comment updated] %s (#%d)', $data['task']['project_name'], $data['task']['title'], $data['task']['id']); + $subject = t('[%s][Comment updated] %s (#%d)', $data['task']['project_name'], $data['task']['title'], $data['task']['id']); + break; case 'notification_subtask_creation': - return t('[%s][New subtask] %s (#%d)', $data['task']['project_name'], $data['task']['title'], $data['task']['id']); + $subject = t('[%s][New subtask] %s (#%d)', $data['task']['project_name'], $data['task']['title'], $data['task']['id']); + break; case 'notification_subtask_update': - return t('[%s][Subtask updated] %s (#%d)', $data['task']['project_name'], $data['task']['title'], $data['task']['id']); + $subject = t('[%s][Subtask updated] %s (#%d)', $data['task']['project_name'], $data['task']['title'], $data['task']['id']); + break; case 'notification_task_creation': - return t('[%s][New task] %s (#%d)', $data['task']['project_name'], $data['task']['title'], $data['task']['id']); + $subject = t('[%s][New task] %s (#%d)', $data['task']['project_name'], $data['task']['title'], $data['task']['id']); + break; case 'notification_task_update': - return t('[%s][Task updated] %s (#%d)', $data['task']['project_name'], $data['task']['title'], $data['task']['id']); + $subject = t('[%s][Task updated] %s (#%d)', $data['task']['project_name'], $data['task']['title'], $data['task']['id']); + break; case 'notification_task_close': - return t('[%s][Task closed] %s (#%d)', $data['task']['project_name'], $data['task']['title'], $data['task']['id']); + $subject = t('[%s][Task closed] %s (#%d)', $data['task']['project_name'], $data['task']['title'], $data['task']['id']); + break; case 'notification_task_open': - return t('[%s][Task opened] %s (#%d)', $data['task']['project_name'], $data['task']['title'], $data['task']['id']); + $subject = t('[%s][Task opened] %s (#%d)', $data['task']['project_name'], $data['task']['title'], $data['task']['id']); + break; case 'notification_task_due': - return t('[%s][Due tasks]', $data['project']); + $subject = t('[%s][Due tasks]', $data['project']); + break; + default: + $subject = t('[Kanboard] Notification'); } - return t('[Kanboard] Notification'); + Translator::enableEscaping(); + + return $subject; } /** diff --git a/app/Templates/notification_task_creation.php b/app/Templates/notification_task_creation.php index 9515e889..69beda92 100644 --- a/app/Templates/notification_task_creation.php +++ b/app/Templates/notification_task_creation.php @@ -11,13 +11,13 @@ <?php endif ?> <?php if ($task['creator_username']): ?> <li> - <?= t('Created by %s', $task['creator_username']) ?> + <?= t('Created by %s', $task['creator_name'] ?: $task['creator_username']) ?> </li> <?php endif ?> <li> <strong> <?php if ($task['assignee_username']): ?> - <?= t('Assigned to %s', $task['assignee_username']) ?> + <?= t('Assigned to %s', $task['assignee_name'] ?: $task['assignee_username']) ?> <?php else: ?> <?= t('There is nobody assigned') ?> <?php endif ?> diff --git a/app/Templates/notification_task_update.php b/app/Templates/notification_task_update.php index 28be9db2..3f61dd2f 100644 --- a/app/Templates/notification_task_update.php +++ b/app/Templates/notification_task_update.php @@ -11,13 +11,13 @@ <?php endif ?> <?php if ($task['creator_username']): ?> <li> - <?= t('Created by %s', $task['creator_username']) ?> + <?= t('Created by %s', $task['creator_name'] ?: $task['creator_username']) ?> </li> <?php endif ?> <li> <strong> <?php if ($task['assignee_username']): ?> - <?= t('Assigned to %s', $task['assignee_username']) ?> + <?= t('Assigned to %s', $task['assignee_name'] ?: $task['assignee_username']) ?> <?php else: ?> <?= t('There is nobody assigned') ?> <?php endif ?> |