diff options
-rw-r--r-- | app/EventBuilder/TaskFileEventBuilder.php | 8 | ||||
-rw-r--r-- | app/Model/FileModel.php | 11 | ||||
-rw-r--r-- | app/Model/ProjectFileModel.php | 12 | ||||
-rw-r--r-- | app/Model/TaskFileModel.php | 12 | ||||
-rw-r--r-- | app/Subscriber/NotificationSubscriber.php | 1 | ||||
-rwxr-xr-x | app/Template/event/task_file_destroy.php | 10 | ||||
-rw-r--r-- | app/Template/notification/task_file_destroy.php | 5 |
7 files changed, 59 insertions, 0 deletions
diff --git a/app/EventBuilder/TaskFileEventBuilder.php b/app/EventBuilder/TaskFileEventBuilder.php index 8c985cc0..de514b59 100644 --- a/app/EventBuilder/TaskFileEventBuilder.php +++ b/app/EventBuilder/TaskFileEventBuilder.php @@ -64,6 +64,10 @@ class TaskFileEventBuilder extends BaseEventBuilder return e('%s attached a file to the task #%d', $author, $eventData['task']['id']); } + if ($eventName === TaskFileModel::EVENT_DESTROY) { + return e('%s removed a file from the task #%d', $author, $eventData['task']['id']); + } + return ''; } @@ -81,6 +85,10 @@ class TaskFileEventBuilder extends BaseEventBuilder return e('New attachment on task #%d: %s', $eventData['file']['task_id'], $eventData['file']['name']); } + if ($eventName === TaskFileModel::EVENT_DESTROY) { + return e('Attachment removed from task #%d: %s', $eventData['file']['task_id'], $eventData['file']['name']); + } + return ''; } } diff --git a/app/Model/FileModel.php b/app/Model/FileModel.php index d04b03bf..1519cfaf 100644 --- a/app/Model/FileModel.php +++ b/app/Model/FileModel.php @@ -52,6 +52,15 @@ abstract class FileModel extends Base abstract protected function fireCreationEvent($file_id); /** + * Fire file destruction event + * + * @abstract + * @access protected + * @param integer $file_id + */ + abstract protected function fireDestructionEvent($file_id); + + /** * Get PicoDb query to get all files * * @access protected @@ -187,6 +196,8 @@ abstract class FileModel extends Base public function remove($file_id) { try { + $this->fireDestructionEvent($file_id); + $file = $this->getById($file_id); $this->objectStorage->remove($file['path']); diff --git a/app/Model/ProjectFileModel.php b/app/Model/ProjectFileModel.php index 4de4d66d..7da5741c 100644 --- a/app/Model/ProjectFileModel.php +++ b/app/Model/ProjectFileModel.php @@ -23,6 +23,7 @@ class ProjectFileModel extends FileModel * @var string */ const EVENT_CREATE = 'project.file.create'; + const EVENT_DESTROY = 'project.file.destroy'; /** * Get the table @@ -70,4 +71,15 @@ class ProjectFileModel extends FileModel { $this->queueManager->push($this->projectFileEventJob->withParams($file_id, self::EVENT_CREATE)); } + + /** + * Fire file destruction event + * + * @access protected + * @param integer $file_id + */ + protected function fireDestructionEvent($file_id) + { + $this->queueManager->push($this->projectFileEventJob->withParams($file_id, self::EVENT_DESTROY)); + } } diff --git a/app/Model/TaskFileModel.php b/app/Model/TaskFileModel.php index 0163da28..9d446004 100644 --- a/app/Model/TaskFileModel.php +++ b/app/Model/TaskFileModel.php @@ -23,6 +23,7 @@ class TaskFileModel extends FileModel * @var string */ const EVENT_CREATE = 'task.file.create'; + const EVENT_DESTROY = 'task.file.destroy'; /** * Get the table @@ -100,4 +101,15 @@ class TaskFileModel extends FileModel { $this->queueManager->push($this->taskFileEventJob->withParams($file_id, self::EVENT_CREATE)); } + + /** + * Fire file destruction event + * + * @access protected + * @param integer $file_id + */ + protected function fireDestructionEvent($file_id) + { + $this->queueManager->push($this->taskFileEventJob->withParams($file_id, self::EVENT_DESTROY)); + } } diff --git a/app/Subscriber/NotificationSubscriber.php b/app/Subscriber/NotificationSubscriber.php index ad16685b..6db48b46 100644 --- a/app/Subscriber/NotificationSubscriber.php +++ b/app/Subscriber/NotificationSubscriber.php @@ -32,6 +32,7 @@ class NotificationSubscriber extends BaseSubscriber implements EventSubscriberIn CommentModel::EVENT_DELETE => 'handleEvent', CommentModel::EVENT_USER_MENTION => 'handleEvent', TaskFileModel::EVENT_CREATE => 'handleEvent', + TaskFileModel::EVENT_DESTROY => 'handleEvent', TaskLinkModel::EVENT_CREATE_UPDATE => 'handleEvent', TaskLinkModel::EVENT_DELETE => 'handleEvent', ); diff --git a/app/Template/event/task_file_destroy.php b/app/Template/event/task_file_destroy.php new file mode 100755 index 00000000..cb21c42a --- /dev/null +++ b/app/Template/event/task_file_destroy.php @@ -0,0 +1,10 @@ +<p class="activity-title"> + <?= e('%s removed a file from the task %s', + $this->text->e($author), + $this->url->link(t('#%d', $task['id']), 'TaskViewController', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) + ) ?> + <small class="activity-date"><?= $this->dt->datetime($date_creation) ?></small> +</p> +<div class="activity-description"> + <p class="activity-task-title"><?= $this->text->e($file['name']) ?></p> +</div> diff --git a/app/Template/notification/task_file_destroy.php b/app/Template/notification/task_file_destroy.php new file mode 100644 index 00000000..dbd79c5e --- /dev/null +++ b/app/Template/notification/task_file_destroy.php @@ -0,0 +1,5 @@ +<h2><?= $this->text->e($task['title']) ?> (#<?= $task['id'] ?>)</h2> + +<p><?= t('Attachment removed "%s"', $file['name']) ?></p> + +<?= $this->render('notification/footer', array('task' => $task)) ?> |