Skip to content

Commit

Permalink
NEW: Set Template Overrides
Browse files Browse the repository at this point in the history
  • Loading branch information
aljawaid committed Oct 20, 2022
1 parent 4ace072 commit f544b4a
Show file tree
Hide file tree
Showing 5 changed files with 189 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ public function initialize()
if (!file_exists('plugins/AutoSubtasks')) {
$this->template->setTemplateOverride('action_creation/params', 'kanboardEmailHistory:action_creation/params');
}

This comment has been minimized.

Copy link
@creecros

creecros Oct 20, 2022

Collaborator

This is alot of overrides. If you are overriding just for the sake of the email that will be sent, it may be best just to use these templates, instead of overriding their main functions.

This comment has been minimized.

Copy link
@aljawaid

aljawaid Oct 22, 2022

Author Owner

you commented too late.... I managed to remove them haha (I didn't class them as ALOT though, I just wasn't comfortable changing the core templates risking affecting other plugins etc)

This comment has been minimized.

Copy link
@creecros

creecros Oct 22, 2022

Collaborator

yes, that was my concern as well. always best to limit overrides, but sometimes there is no choice.

//Task Comments
$this->template->setTemplateOverride('notification/task_create', 'kanboardEmailHistory:notification/task_create');
$this->template->setTemplateOverride('task_comments/show', 'kanboardEmailHistory:task_comments/show');
$this->template->setTemplateOverride('comment/show', 'kanboardEmailHistory:comment/show');
$this->template->setTemplateOverride('notification/footer', 'kanboardEmailHistory:notification/footer');


}
Expand Down
23 changes: 23 additions & 0 deletions Template/comment/show.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<div class="comment <?= isset($preview) ? 'comment-preview' : '' ?>" id="comment-<?= $comment['id'] ?>">

<div class="comment-title">
<?php if (! empty($comment['username'])): ?>
<strong class="comment-username"><?= $this->text->e($comment['name'] ?: $comment['username']) ?></strong>
<?php endif ?>

<small class="comment-date"><?= t('Created at:') ?>&nbsp;
<kbd class="comment-created"><?= $this->dt->datetime($comment['date_creation']) ?><abbr title="Local Time">LT</abbr></kbd>
</small>
<small class="comment-date updated-comment"><?= t('Updated at:') ?>&nbsp;
<kbd class="comment-updated"><?= $this->dt->datetime($comment['date_modification']) ?><abbr title="Local Time">LT</abbr></kbd>
</small>
<small class="comment-date comment-id"><i class="fa fa-comment-o fa-fw"></i> <?= t('ID: ') ?> <kbd class="comment-created"><?= $this->text->e($comment['id']) ?></kbd></small>
</div>

<div class="comment-content">
<div class="markdown">
<?= $this->text->markdown($comment['comment'], isset($is_public) && $is_public) ?>
</div>
</div>
</div>
<hr>
11 changes: 11 additions & 0 deletions Template/notification/footer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<hr/>
My PP Workspace

<?php if ($this->app->config('application_url') != ''): ?>
<?php if (isset($task['id'])): ?>
- <?= $this->url->absoluteLink(t('view the task on Kanboard'), 'TaskViewController', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>
<?php endif ?>
- <?= $this->url->absoluteLink(t('view the board on Kanboard'), 'BoardViewController', 'show', array('project_id' => $task['project_id'])) ?>
<?php endif ?>
</body>
</html>
123 changes: 123 additions & 0 deletions Template/notification/task_create.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
<html>
<body>
<h2><?= $this->text->e($task['title']) ?> (#<?= $task['id'] ?>)</h2>

<h3><?= t('Summary') ?></h3>
<ul class="">
<li class="">
Task Status: <?php if ($task['is_active'] == 1): ?>
<strong style="text-transform: uppercase; color: green;"><?= t('open') ?></strong>
<?php else: ?>
<strong style="text-transform: uppercase; color: red;"><?= t('closed') ?></strong>
<?php endif ?>
</li>
<li class="">
Task N°: <strong>#<?= $this->text->e($task['id']) ?></strong>
</li>
<li class="">
<?= t('Project:') ?> <strong><?= $this->text->e($task['project_name']) ?></strong>
</li>
<?php if (! empty($task['priority'])): ?>
<li class="">
<hr style="list-style-type: none;">
<?= t('Priority:') ?> <strong><?= $this->text->e($task['priority']) ?></strong>
</li>
<?php endif ?>
<?php if (! empty($task['reference'])): ?>
<li class="">
<?= t('Reference:') ?> <strong><?= $this->task->renderReference($task) ?></strong>
</li>
<?php endif ?>
<?php if (! empty($task['score'])): ?>
<li class="">
<?= t('Complexity:') ?> <strong><?= $this->text->e($task['score']) ?></strong>
</li>
<?php endif ?>
<li class="">
<hr style="list-style-type: none;">
<?= t('Created:').' '.$this->dt->datetime($task['date_creation']) ?>
</li>
<?php if ($task['date_started']): ?>
<li class="">
<?= t('Started:') ?> <strong><?= $this->dt->datetime($task['date_started']) ?></strong>
</li>
<?php endif ?>
<li class="">
<?= t('Modified:').' '.$this->dt->datetime($task['date_modification']) ?>
</li>
<?php if ($task['date_due']): ?>
<li class="">
<strong><?= t('Due date:').' '.$this->dt->datetime($task['date_due']) ?></strong>
</li>
<?php endif ?>
<?php if ($task['date_completed']): ?>
<li class="">
<?= t('Completed:') ?> <strong><?= $this->dt->datetime($task['date_completed']) ?></strong>
<hr style="list-style-type: none;">
</li>
<?php endif ?>
<?php if (! empty($task['creator_username'])): ?>
<li class="">
<?= t('Created by %s', $task['creator_name'] ?: $task['creator_username']) ?>
</li>
<?php endif ?>
<li class="">
<strong>
<?php if (! empty($task['assignee_username'])): ?>
<?= t('Assigned to %s', $task['assignee_name'] ?: $task['assignee_username']) ?>
<?php else: ?>
<?= t('There is nobody assigned') ?>
<?php endif ?>
</strong>
</li>
<li class="">
<hr style="list-style-type: none;">
<?= t('Column on the board:') ?> <strong><?= $this->text->e($task['column_title']) ?></strong>
</li>
<?php if (! empty($task['swimlane_name'])): ?>
<li class="">
<?= t('Swimlane:') ?> <strong><?= $this->text->e($task['swimlane_name']) ?></strong>
</li>
<?php endif ?>
<?php if (! empty($task['category_name'])): ?>
<li class="">
<?= t('Category:') ?> <strong><?= $this->text->e($task['category_name']) ?></strong>
</li>
<?php endif ?>
<li class="">
<?= t('Task position:').' '.$this->text->e($task['position']) ?>
</li>
<?php if ($task['recurrence_status'] == \Kanboard\Model\TaskModel::RECURRING_STATUS_PENDING): ?>
<li class="">
<hr style="list-style-type: none;">
<?= t('Recurrence:') ?> <i><?= t('Recurrent task is scheduled to be generated') ?></i>
</li>
<?php endif ?>
<?php if ($task['recurrence_status'] == \Kanboard\Model\TaskModel::RECURRING_STATUS_PROCESSED): ?>
<li class="">
<hr style="list-style-type: none;">
<?= t('Recurrence:') ?> <?= t('Recurrent task has been generated') ?>
</li>
<?php if ($task['recurrence_parent'] || $task['recurrence_child']): ?>
<?php if ($task['recurrence_parent']): ?>
<li>
<?= t('This task has been created by: ') ?>
<?= $this->url->link('#'.$task['recurrence_parent'], 'TaskViewController', 'show', array('task_id' => $task['recurrence_parent'], 'project_id' => $task['project_id'])) ?>
</li>
<?php endif ?>
<?php if ($task['recurrence_child']): ?>
<li>
<?= t('This task has created this child task: ') ?>
<?= $this->url->link('#'.$task['recurrence_child'], 'TaskViewController', 'show', array('task_id' => $task['recurrence_child'], 'project_id' => $task['project_id'])) ?>
</li>
<?php endif ?>
<?php endif ?>
<?php endif ?>
</ul>
<hr>
<?php if (! empty($task['description'])): ?>
<h3><?= t('Description') ?></h3>
<?= $this->text->markdown($task['description'], true) ?>
<?php endif ?>

<hr>
26 changes: 26 additions & 0 deletions Template/task_comments/show.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<details class="accordion-section" <?= empty($comments) ? '' : 'open' ?>>
<summary class="accordion-title acc-comments-title">
<h3><?= t('Comments') ?></h3>
<?php if (! empty($comments)): ?>
<span class="">(<?= count($comments) ?>)</span>
<?php endif ?>
</summary>
<div class="accordion-content comments" id="comments">
<?php if (empty($comments)): ?>
<hr>
<div class="no-data"><i><?= t('No comments') ?></i></div>
<?php endif ?>

<hr>
<?php foreach ($comments as $comment): ?>
<?= $this->render('comment/show', array(
'comment' => $comment,
'task' => $task,
'project' => $project,
'editable' => false,
'is_public' => isset($is_public) && $is_public,
)) ?>
<?php endforeach ?>

</div>
</details>

0 comments on commit f544b4a

Please sign in to comment.