From c2ff3b2d696224800cb70513edb3ed0c84cc87a5 Mon Sep 17 00:00:00 2001 From: Colin Williams Date: Sat, 31 Jan 2015 15:04:32 +0000 Subject: Use $max_length parameter in getClonedProjectName. --- app/Model/ProjectDuplication.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app/Model') diff --git a/app/Model/ProjectDuplication.php b/app/Model/ProjectDuplication.php index 11a606d7..ef4558ba 100644 --- a/app/Model/ProjectDuplication.php +++ b/app/Model/ProjectDuplication.php @@ -23,8 +23,8 @@ class ProjectDuplication extends Base { $suffix = ' ('.t('Clone').')'; - if (strlen($name.$suffix) > 50) { - $name = substr($name, 0, 50 - strlen($suffix)); + if (strlen($name.$suffix) > $max_length) { + $name = substr($name, 0, $max_length - strlen($suffix)); } return $name.$suffix; -- cgit v1.2.3 From ce13fced30fffa78c1a0e73368f39b6381643c1f Mon Sep 17 00:00:00 2001 From: Colin Williams Date: Sat, 31 Jan 2015 15:07:07 +0000 Subject: Reduce duplication in Notification::getMailSubject() --- app/Model/Notification.php | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) (limited to 'app/Model') diff --git a/app/Model/Notification.php b/app/Model/Notification.php index 95306e86..49691f85 100644 --- a/app/Model/Notification.php +++ b/app/Model/Notification.php @@ -118,6 +118,18 @@ class Notification extends Base } } + /** + * Get the mail subject for a given label + * + * @access private + * @param string $label Label + * @param array $data Template data + */ + private function getStandardMailSubject($label, array $data) + { + return e('[%s][%s] %s (#%d)', $data['task']['project_name'], $label, $data['task']['title'], $data['task']['id']); + } + /** * Get the mail subject for a given template name * @@ -129,40 +141,40 @@ class Notification extends Base { switch ($template) { case 'file_creation': - $subject = e('[%s][New attachment] %s (#%d)', $data['task']['project_name'], $data['task']['title'], $data['task']['id']); + $subject = $this->getStandardMailSubject('New attachment', $data); break; case 'comment_creation': - $subject = e('[%s][New comment] %s (#%d)', $data['task']['project_name'], $data['task']['title'], $data['task']['id']); + $subject = $this->getStandardMailSubject('New comment', $data); break; case 'comment_update': - $subject = e('[%s][Comment updated] %s (#%d)', $data['task']['project_name'], $data['task']['title'], $data['task']['id']); + $subject = $this->getStandardMailSubject('Comment updated', $data); break; case 'subtask_creation': - $subject = e('[%s][New subtask] %s (#%d)', $data['task']['project_name'], $data['task']['title'], $data['task']['id']); + $subject = $this->getStandardMailSubject('New subtask', $data); break; case 'subtask_update': - $subject = e('[%s][Subtask updated] %s (#%d)', $data['task']['project_name'], $data['task']['title'], $data['task']['id']); + $subject = $this->getStandardMailSubject('Subtask updated', $data); break; case 'task_creation': - $subject = e('[%s][New task] %s (#%d)', $data['task']['project_name'], $data['task']['title'], $data['task']['id']); + $subject = $this->getStandardMailSubject('New task', $data); break; case 'task_update': - $subject = e('[%s][Task updated] %s (#%d)', $data['task']['project_name'], $data['task']['title'], $data['task']['id']); + $subject = $this->getStandardMailSubject('Task updated', $data); break; case 'task_close': - $subject = e('[%s][Task closed] %s (#%d)', $data['task']['project_name'], $data['task']['title'], $data['task']['id']); + $subject = $this->getStandardMailSubject('Task closed', $data); break; case 'task_open': - $subject = e('[%s][Task opened] %s (#%d)', $data['task']['project_name'], $data['task']['title'], $data['task']['id']); + $subject = $this->getStandardMailSubject('Task opened', $data); break; case 'task_move_column': - $subject = e('[%s][Column Change] %s (#%d)', $data['task']['project_name'], $data['task']['title'], $data['task']['id']); + $subject = $this->getStandardMailSubject('Column Change', $data); break; case 'task_move_position': - $subject = e('[%s][Position Change] %s (#%d)', $data['task']['project_name'], $data['task']['title'], $data['task']['id']); + $subject = $this->getStandardMailSubject('Position Change', $data); break; case 'task_assignee_change': - $subject = e('[%s][Assignee Change] %s (#%d)', $data['task']['project_name'], $data['task']['title'], $data['task']['id']); + $subject = $this->getStandardMailSubject('Assignee Change', $data); break; case 'task_due': $subject = e('[%s][Due tasks]', $data['project']); -- cgit v1.2.3