Add subtasks and comments history
This commit is contained in:
@@ -28,6 +28,8 @@ use Model\LastLogin;
|
|||||||
* @property \Model\SubTask $subTask
|
* @property \Model\SubTask $subTask
|
||||||
* @property \Model\Task $task
|
* @property \Model\Task $task
|
||||||
* @property \Model\TaskHistory $taskHistory
|
* @property \Model\TaskHistory $taskHistory
|
||||||
|
* @property \Model\CommentHistory $commentHistory
|
||||||
|
* @property \Model\SubtaskHistory $subtaskHistory
|
||||||
* @property \Model\User $user
|
* @property \Model\User $user
|
||||||
* @property \Model\Webhook $webhook
|
* @property \Model\Webhook $webhook
|
||||||
*/
|
*/
|
||||||
@@ -131,11 +133,29 @@ abstract class Base
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Attach events
|
// Attach events
|
||||||
$this->action->attachEvents();
|
$this->attachEvents();
|
||||||
$this->project->attachEvents();
|
}
|
||||||
$this->webhook->attachEvents();
|
|
||||||
$this->notification->attachEvents();
|
/**
|
||||||
$this->taskHistory->attachEvents();
|
* Attach events
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
private function attachEvents()
|
||||||
|
{
|
||||||
|
$models = array(
|
||||||
|
'action',
|
||||||
|
'project',
|
||||||
|
'webhook',
|
||||||
|
'notification',
|
||||||
|
'taskHistory',
|
||||||
|
'commentHistory',
|
||||||
|
'subtaskHistory',
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach ($models as $model) {
|
||||||
|
$this->$model->attachEvents();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -72,7 +72,6 @@ class Project extends Base
|
|||||||
$to = $this->request->getStringParam('to');
|
$to = $this->request->getStringParam('to');
|
||||||
|
|
||||||
if ($from && $to) {
|
if ($from && $to) {
|
||||||
Translator::disableEscaping();
|
|
||||||
$data = $this->task->export($project['id'], $from, $to);
|
$data = $this->task->export($project['id'], $from, $to);
|
||||||
$this->response->forceDownload('Export_'.date('Y_m_d_H_i_S').'.csv');
|
$this->response->forceDownload('Export_'.date('Y_m_d_H_i_S').'.csv');
|
||||||
$this->response->csv($data);
|
$this->response->csv($data);
|
||||||
|
|||||||
@@ -26,44 +26,13 @@ class Translator
|
|||||||
*/
|
*/
|
||||||
private static $locales = array();
|
private static $locales = array();
|
||||||
|
|
||||||
/**
|
|
||||||
* Flag to enable HTML escaping
|
|
||||||
*
|
|
||||||
* @static
|
|
||||||
* @access private
|
|
||||||
* @var boolean
|
|
||||||
*/
|
|
||||||
private static $enable_escaping = true;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Disable HTML escaping for translations
|
|
||||||
*
|
|
||||||
* @static
|
|
||||||
* @access public
|
|
||||||
*/
|
|
||||||
public static function disableEscaping()
|
|
||||||
{
|
|
||||||
self::$enable_escaping = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Enable HTML escaping for translations
|
|
||||||
*
|
|
||||||
* @static
|
|
||||||
* @access public
|
|
||||||
*/
|
|
||||||
public static function enableEscaping()
|
|
||||||
{
|
|
||||||
self::$enable_escaping = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a translation
|
* Get a translation
|
||||||
*
|
*
|
||||||
* $translator->translate('I have %d kids', 5);
|
* $translator->translate('I have %d kids', 5);
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @param $identifier
|
* @param string $identifier Default string
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function translate($identifier)
|
public function translate($identifier)
|
||||||
@@ -73,10 +42,8 @@ class Translator
|
|||||||
array_shift($args);
|
array_shift($args);
|
||||||
array_unshift($args, $this->get($identifier, $identifier));
|
array_unshift($args, $this->get($identifier, $identifier));
|
||||||
|
|
||||||
if (self::$enable_escaping) {
|
foreach ($args as &$arg) {
|
||||||
foreach ($args as &$arg) {
|
$arg = htmlspecialchars($arg, ENT_QUOTES, 'UTF-8', false);
|
||||||
$arg = htmlspecialchars($arg, ENT_QUOTES, 'UTF-8', false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return call_user_func_array(
|
return call_user_func_array(
|
||||||
@@ -85,6 +52,28 @@ class Translator
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a translation with no HTML escaping
|
||||||
|
*
|
||||||
|
* $translator->translateNoEscaping('I have %d kids', 5);
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param string $identifier Default string
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function translateNoEscaping($identifier)
|
||||||
|
{
|
||||||
|
$args = func_get_args();
|
||||||
|
|
||||||
|
array_shift($args);
|
||||||
|
array_unshift($args, $this->get($identifier, $identifier));
|
||||||
|
|
||||||
|
return call_user_func_array(
|
||||||
|
'sprintf',
|
||||||
|
$args
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a formatted number
|
* Get a formatted number
|
||||||
*
|
*
|
||||||
|
|||||||
62
app/Event/CommentHistoryListener.php
Normal file
62
app/Event/CommentHistoryListener.php
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Event;
|
||||||
|
|
||||||
|
use Core\Listener;
|
||||||
|
use Model\CommentHistory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Comment history listener
|
||||||
|
*
|
||||||
|
* @package event
|
||||||
|
* @author Frederic Guillot
|
||||||
|
*/
|
||||||
|
class CommentHistoryListener implements Listener
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Comment History model
|
||||||
|
*
|
||||||
|
* @accesss private
|
||||||
|
* @var \Model\CommentHistory
|
||||||
|
*/
|
||||||
|
private $model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param \Model\CommentHistory $model Comment History model instance
|
||||||
|
*/
|
||||||
|
public function __construct(CommentHistory $model)
|
||||||
|
{
|
||||||
|
$this->model = $model;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the action
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param array $data Event data dictionary
|
||||||
|
* @return bool True if the action was executed or false when not executed
|
||||||
|
*/
|
||||||
|
public function execute(array $data)
|
||||||
|
{
|
||||||
|
$creator_id = $this->model->acl->getUserId();
|
||||||
|
|
||||||
|
if ($creator_id && isset($data['task_id']) && isset($data['id'])) {
|
||||||
|
|
||||||
|
$task = $this->model->task->getById($data['task_id']);
|
||||||
|
|
||||||
|
$this->model->create(
|
||||||
|
$task['project_id'],
|
||||||
|
$data['task_id'],
|
||||||
|
$data['id'],
|
||||||
|
$creator_id,
|
||||||
|
$this->model->event->getLastTriggeredEvent(),
|
||||||
|
$data['comment']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
62
app/Event/SubtaskHistoryListener.php
Normal file
62
app/Event/SubtaskHistoryListener.php
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Event;
|
||||||
|
|
||||||
|
use Core\Listener;
|
||||||
|
use Model\SubtaskHistory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Subtask history listener
|
||||||
|
*
|
||||||
|
* @package event
|
||||||
|
* @author Frederic Guillot
|
||||||
|
*/
|
||||||
|
class SubtaskHistoryListener implements Listener
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Comment History model
|
||||||
|
*
|
||||||
|
* @accesss private
|
||||||
|
* @var \Model\SubtaskHistory
|
||||||
|
*/
|
||||||
|
private $model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param \Model\SubtaskHistory $model Subtask History model instance
|
||||||
|
*/
|
||||||
|
public function __construct(SubtaskHistory $model)
|
||||||
|
{
|
||||||
|
$this->model = $model;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the action
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param array $data Event data dictionary
|
||||||
|
* @return bool True if the action was executed or false when not executed
|
||||||
|
*/
|
||||||
|
public function execute(array $data)
|
||||||
|
{
|
||||||
|
$creator_id = $this->model->acl->getUserId();
|
||||||
|
|
||||||
|
if ($creator_id && isset($data['task_id']) && isset($data['id'])) {
|
||||||
|
|
||||||
|
$task = $this->model->task->getById($data['task_id']);
|
||||||
|
|
||||||
|
$this->model->create(
|
||||||
|
$task['project_id'],
|
||||||
|
$data['task_id'],
|
||||||
|
$data['id'],
|
||||||
|
$creator_id,
|
||||||
|
$this->model->event->getLastTriggeredEvent(),
|
||||||
|
''
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,7 +14,7 @@ use Model\TaskHistory;
|
|||||||
class TaskHistoryListener implements Listener
|
class TaskHistoryListener implements Listener
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* TaskHistory model
|
* Task History model
|
||||||
*
|
*
|
||||||
* @accesss private
|
* @accesss private
|
||||||
* @var \Model\TaskHistory
|
* @var \Model\TaskHistory
|
||||||
@@ -25,7 +25,7 @@ class TaskHistoryListener implements Listener
|
|||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @param \Model\TaskHistory $model TaskHistory model instance
|
* @param \Model\TaskHistory $model Task History model instance
|
||||||
*/
|
*/
|
||||||
public function __construct(TaskHistory $model)
|
public function __construct(TaskHistory $model)
|
||||||
{
|
{
|
||||||
|
|||||||
70
app/Model/BaseHistory.php
Normal file
70
app/Model/BaseHistory.php
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Model;
|
||||||
|
|
||||||
|
use PDO;
|
||||||
|
use Core\Template;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Task history model
|
||||||
|
*
|
||||||
|
* @package model
|
||||||
|
* @author Frederic Guillot
|
||||||
|
*/
|
||||||
|
abstract class BaseHistory extends Base
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* SQL table name
|
||||||
|
*
|
||||||
|
* @access protected
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $table = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove old event entries to avoid a large table
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param integer $max Maximum number of items to keep in the table
|
||||||
|
*/
|
||||||
|
public function cleanup($max)
|
||||||
|
{
|
||||||
|
if ($this->db->table($this->table)->count() > $max) {
|
||||||
|
|
||||||
|
$this->db->execute('
|
||||||
|
DELETE FROM '.$this->table.'
|
||||||
|
WHERE id <= (
|
||||||
|
SELECT id FROM (
|
||||||
|
SELECT id FROM '.$this->table.' ORDER BY id DESC LIMIT 1 OFFSET '.$max.'
|
||||||
|
) foo
|
||||||
|
)');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all events for a given project
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getAllByProjectId($project_id)
|
||||||
|
{
|
||||||
|
return $this->db->table($this->table)
|
||||||
|
->eq('project_id', $project_id)
|
||||||
|
->desc('id')
|
||||||
|
->findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the event html content
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param array $params Event properties
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getContent(array $params)
|
||||||
|
{
|
||||||
|
$tpl = new Template;
|
||||||
|
return $tpl->load('event_'.str_replace('.', '_', $params['event_name']), $params);
|
||||||
|
}
|
||||||
|
}
|
||||||
152
app/Model/CommentHistory.php
Normal file
152
app/Model/CommentHistory.php
Normal file
@@ -0,0 +1,152 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Model;
|
||||||
|
|
||||||
|
use PDO;
|
||||||
|
use Core\Registry;
|
||||||
|
use Event\CommentHistoryListener;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Comment history model
|
||||||
|
*
|
||||||
|
* @package model
|
||||||
|
* @author Frederic Guillot
|
||||||
|
*/
|
||||||
|
class CommentHistory extends BaseHistory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* SQL table name
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
const TABLE = 'comment_has_events';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Maximum number of events
|
||||||
|
*
|
||||||
|
* @var integer
|
||||||
|
*/
|
||||||
|
const MAX_EVENTS = 5000;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param \Core\Registry $registry Registry instance
|
||||||
|
*/
|
||||||
|
public function __construct(Registry $registry)
|
||||||
|
{
|
||||||
|
parent::__construct($registry);
|
||||||
|
$this->table = self::TABLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new event
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param integer $project_id Project id
|
||||||
|
* @param integer $task_id Task id
|
||||||
|
* @param integer $comment_id Comment id
|
||||||
|
* @param integer $creator_id Author of the event (user id)
|
||||||
|
* @param string $event_name Task event name
|
||||||
|
* @param string $data Current comment
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function create($project_id, $task_id, $comment_id, $creator_id, $event_name, $data)
|
||||||
|
{
|
||||||
|
$values = array(
|
||||||
|
'project_id' => $project_id,
|
||||||
|
'task_id' => $task_id,
|
||||||
|
'comment_id' => $comment_id,
|
||||||
|
'creator_id' => $creator_id,
|
||||||
|
'event_name' => $event_name,
|
||||||
|
'date_creation' => time(),
|
||||||
|
'data' => $data,
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->db->startTransaction();
|
||||||
|
|
||||||
|
$this->cleanup(self::MAX_EVENTS - 1);
|
||||||
|
$result = $this->db->table(self::TABLE)->insert($values);
|
||||||
|
|
||||||
|
$this->db->closeTransaction();
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all necessary content to display activity feed
|
||||||
|
*
|
||||||
|
* $author_name
|
||||||
|
* $author_username
|
||||||
|
* $task['id', 'title', 'position', 'column_name']
|
||||||
|
*/
|
||||||
|
public function getAllContentByProjectId($project_id, $limit = 50)
|
||||||
|
{
|
||||||
|
$sql = '
|
||||||
|
SELECT
|
||||||
|
comment_has_events.id,
|
||||||
|
comment_has_events.date_creation,
|
||||||
|
comment_has_events.event_name,
|
||||||
|
comment_has_events.data as comment,
|
||||||
|
comment_has_events.task_id,
|
||||||
|
tasks.title as task_title,
|
||||||
|
users.username as author_username,
|
||||||
|
users.name as author_name
|
||||||
|
FROM comment_has_events
|
||||||
|
LEFT JOIN users ON users.id=comment_has_events.creator_id
|
||||||
|
LEFT JOIN tasks ON tasks.id=comment_has_events.task_id
|
||||||
|
WHERE comment_has_events.project_id = ?
|
||||||
|
ORDER BY comment_has_events.id DESC
|
||||||
|
LIMIT 0, '.$limit.'
|
||||||
|
';
|
||||||
|
|
||||||
|
$rq = $this->db->execute($sql, array($project_id));
|
||||||
|
$events = $rq->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
foreach ($events as &$event) {
|
||||||
|
$event['author'] = $event['author_name'] ?: $event['author_username'];
|
||||||
|
$event['event_title'] = $this->getTitle($event);
|
||||||
|
$event['event_content'] = $this->getContent($event);
|
||||||
|
$event['event_type'] = 'comment';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $events;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the event title (translated)
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param array $event Event properties
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getTitle(array $event)
|
||||||
|
{
|
||||||
|
$titles = array(
|
||||||
|
Comment::EVENT_UPDATE => t('%s updated a comment on the task #%d', $event['author'], $event['task_id']),
|
||||||
|
Comment::EVENT_CREATE => t('%s commented on the task #%d', $event['author'], $event['task_id']),
|
||||||
|
);
|
||||||
|
|
||||||
|
return isset($titles[$event['event_name']]) ? $titles[$event['event_name']] : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attach events to be able to record the history
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
public function attachEvents()
|
||||||
|
{
|
||||||
|
$events = array(
|
||||||
|
Comment::EVENT_UPDATE,
|
||||||
|
Comment::EVENT_CREATE,
|
||||||
|
);
|
||||||
|
|
||||||
|
$listener = new CommentHistoryListener($this);
|
||||||
|
|
||||||
|
foreach ($events as $event_name) {
|
||||||
|
$this->event->attach($event_name, $listener);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -115,45 +115,41 @@ class Notification extends Base
|
|||||||
*/
|
*/
|
||||||
public function getMailSubject($template, array $data)
|
public function getMailSubject($template, array $data)
|
||||||
{
|
{
|
||||||
Translator::disableEscaping();
|
|
||||||
|
|
||||||
switch ($template) {
|
switch ($template) {
|
||||||
case 'notification_file_creation':
|
case 'notification_file_creation':
|
||||||
$subject = t('[%s][New attachment] %s (#%d)', $data['task']['project_name'], $data['task']['title'], $data['task']['id']);
|
$subject = e('[%s][New attachment] %s (#%d)', $data['task']['project_name'], $data['task']['title'], $data['task']['id']);
|
||||||
break;
|
break;
|
||||||
case 'notification_comment_creation':
|
case 'notification_comment_creation':
|
||||||
$subject = t('[%s][New comment] %s (#%d)', $data['task']['project_name'], $data['task']['title'], $data['task']['id']);
|
$subject = e('[%s][New comment] %s (#%d)', $data['task']['project_name'], $data['task']['title'], $data['task']['id']);
|
||||||
break;
|
break;
|
||||||
case 'notification_comment_update':
|
case 'notification_comment_update':
|
||||||
$subject = t('[%s][Comment updated] %s (#%d)', $data['task']['project_name'], $data['task']['title'], $data['task']['id']);
|
$subject = e('[%s][Comment updated] %s (#%d)', $data['task']['project_name'], $data['task']['title'], $data['task']['id']);
|
||||||
break;
|
break;
|
||||||
case 'notification_subtask_creation':
|
case 'notification_subtask_creation':
|
||||||
$subject = t('[%s][New subtask] %s (#%d)', $data['task']['project_name'], $data['task']['title'], $data['task']['id']);
|
$subject = e('[%s][New subtask] %s (#%d)', $data['task']['project_name'], $data['task']['title'], $data['task']['id']);
|
||||||
break;
|
break;
|
||||||
case 'notification_subtask_update':
|
case 'notification_subtask_update':
|
||||||
$subject = t('[%s][Subtask updated] %s (#%d)', $data['task']['project_name'], $data['task']['title'], $data['task']['id']);
|
$subject = e('[%s][Subtask updated] %s (#%d)', $data['task']['project_name'], $data['task']['title'], $data['task']['id']);
|
||||||
break;
|
break;
|
||||||
case 'notification_task_creation':
|
case 'notification_task_creation':
|
||||||
$subject = t('[%s][New task] %s (#%d)', $data['task']['project_name'], $data['task']['title'], $data['task']['id']);
|
$subject = e('[%s][New task] %s (#%d)', $data['task']['project_name'], $data['task']['title'], $data['task']['id']);
|
||||||
break;
|
break;
|
||||||
case 'notification_task_update':
|
case 'notification_task_update':
|
||||||
$subject = t('[%s][Task updated] %s (#%d)', $data['task']['project_name'], $data['task']['title'], $data['task']['id']);
|
$subject = e('[%s][Task updated] %s (#%d)', $data['task']['project_name'], $data['task']['title'], $data['task']['id']);
|
||||||
break;
|
break;
|
||||||
case 'notification_task_close':
|
case 'notification_task_close':
|
||||||
$subject = t('[%s][Task closed] %s (#%d)', $data['task']['project_name'], $data['task']['title'], $data['task']['id']);
|
$subject = e('[%s][Task closed] %s (#%d)', $data['task']['project_name'], $data['task']['title'], $data['task']['id']);
|
||||||
break;
|
break;
|
||||||
case 'notification_task_open':
|
case 'notification_task_open':
|
||||||
$subject = t('[%s][Task opened] %s (#%d)', $data['task']['project_name'], $data['task']['title'], $data['task']['id']);
|
$subject = e('[%s][Task opened] %s (#%d)', $data['task']['project_name'], $data['task']['title'], $data['task']['id']);
|
||||||
break;
|
break;
|
||||||
case 'notification_task_due':
|
case 'notification_task_due':
|
||||||
$subject = t('[%s][Due tasks]', $data['project']);
|
$subject = e('[%s][Due tasks]', $data['project']);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$subject = t('[Kanboard] Notification');
|
$subject = e('[Kanboard] Notification');
|
||||||
}
|
}
|
||||||
|
|
||||||
Translator::enableEscaping();
|
|
||||||
|
|
||||||
return $subject;
|
return $subject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -720,7 +720,25 @@ class Project extends Base
|
|||||||
*/
|
*/
|
||||||
public function getActivity($project_id)
|
public function getActivity($project_id)
|
||||||
{
|
{
|
||||||
// TODO: merge comments and subtasks activity
|
$activity = array();
|
||||||
return $this->taskHistory->getAllContentByProjectId($project_id);
|
$tasks = $this->taskHistory->getAllContentByProjectId($project_id, 25);
|
||||||
|
$comments = $this->commentHistory->getAllContentByProjectId($project_id, 25);
|
||||||
|
$subtasks = $this->subtaskHistory->getAllContentByProjectId($project_id, 25);
|
||||||
|
|
||||||
|
foreach ($tasks as &$task) {
|
||||||
|
$activity[$task['date_creation'].'-'.$task['id']] = $task;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($subtasks as &$subtask) {
|
||||||
|
$activity[$subtask['date_creation'].'-'.$subtask['id']] = $subtask;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($comments as &$comment) {
|
||||||
|
$activity[$comment['date_creation'].'-'.$comment['id']] = $comment;
|
||||||
|
}
|
||||||
|
|
||||||
|
krsort($activity);
|
||||||
|
|
||||||
|
return $activity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
161
app/Model/SubtaskHistory.php
Normal file
161
app/Model/SubtaskHistory.php
Normal file
@@ -0,0 +1,161 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Model;
|
||||||
|
|
||||||
|
use PDO;
|
||||||
|
use Core\Registry;
|
||||||
|
use Event\SubtaskHistoryListener;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Comment history model
|
||||||
|
*
|
||||||
|
* @package model
|
||||||
|
* @author Frederic Guillot
|
||||||
|
*/
|
||||||
|
class SubtaskHistory extends BaseHistory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* SQL table name
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
const TABLE = 'subtask_has_events';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Maximum number of events
|
||||||
|
*
|
||||||
|
* @var integer
|
||||||
|
*/
|
||||||
|
const MAX_EVENTS = 5000;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param \Core\Registry $registry Registry instance
|
||||||
|
*/
|
||||||
|
public function __construct(Registry $registry)
|
||||||
|
{
|
||||||
|
parent::__construct($registry);
|
||||||
|
$this->table = self::TABLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new event
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param integer $project_id Project id
|
||||||
|
* @param integer $task_id Task id
|
||||||
|
* @param integer $subtask_id Subtask id
|
||||||
|
* @param integer $creator_id Author of the event (user id)
|
||||||
|
* @param string $event_name Task event name
|
||||||
|
* @param string $data Current comment
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function create($project_id, $task_id, $subtask_id, $creator_id, $event_name, $data)
|
||||||
|
{
|
||||||
|
$values = array(
|
||||||
|
'project_id' => $project_id,
|
||||||
|
'task_id' => $task_id,
|
||||||
|
'subtask_id' => $subtask_id,
|
||||||
|
'creator_id' => $creator_id,
|
||||||
|
'event_name' => $event_name,
|
||||||
|
'date_creation' => time(),
|
||||||
|
'data' => $data,
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->db->startTransaction();
|
||||||
|
|
||||||
|
$this->cleanup(self::MAX_EVENTS - 1);
|
||||||
|
$result = $this->db->table(self::TABLE)->insert($values);
|
||||||
|
|
||||||
|
$this->db->closeTransaction();
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all necessary content to display activity feed
|
||||||
|
*
|
||||||
|
* $author_name
|
||||||
|
* $author_username
|
||||||
|
* $task['id', 'title', 'position', 'column_name']
|
||||||
|
*/
|
||||||
|
public function getAllContentByProjectId($project_id, $limit = 50)
|
||||||
|
{
|
||||||
|
$sql = '
|
||||||
|
SELECT
|
||||||
|
subtask_has_events.id,
|
||||||
|
subtask_has_events.date_creation,
|
||||||
|
subtask_has_events.event_name,
|
||||||
|
subtask_has_events.task_id,
|
||||||
|
tasks.title as task_title,
|
||||||
|
users.username as author_username,
|
||||||
|
users.name as author_name,
|
||||||
|
assignees.name as subtask_assignee_name,
|
||||||
|
assignees.username as subtask_assignee_username,
|
||||||
|
task_has_subtasks.title as subtask_title,
|
||||||
|
task_has_subtasks.status as subtask_status,
|
||||||
|
task_has_subtasks.time_spent as subtask_time_spent,
|
||||||
|
task_has_subtasks.time_estimated as subtask_time_estimated
|
||||||
|
FROM subtask_has_events
|
||||||
|
LEFT JOIN users ON users.id=subtask_has_events.creator_id
|
||||||
|
LEFT JOIN tasks ON tasks.id=subtask_has_events.task_id
|
||||||
|
LEFT JOIN task_has_subtasks ON task_has_subtasks.id=subtask_has_events.subtask_id
|
||||||
|
LEFT JOIN users AS assignees ON assignees.id=task_has_subtasks.user_id
|
||||||
|
WHERE subtask_has_events.project_id = ?
|
||||||
|
ORDER BY subtask_has_events.id DESC
|
||||||
|
LIMIT 0, '.$limit.'
|
||||||
|
';
|
||||||
|
|
||||||
|
$rq = $this->db->execute($sql, array($project_id));
|
||||||
|
$events = $rq->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
foreach ($events as &$event) {
|
||||||
|
$event['author'] = $event['author_name'] ?: $event['author_username'];
|
||||||
|
$event['subtask_assignee'] = $event['subtask_assignee_name'] ?: $event['subtask_assignee_username'];
|
||||||
|
$event['subtask_status_list'] = $this->subTask->getStatusList();
|
||||||
|
$event['event_title'] = $this->getTitle($event);
|
||||||
|
$event['event_content'] = $this->getContent($event);
|
||||||
|
$event['event_type'] = 'subtask';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $events;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the event title (translated)
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param array $event Event properties
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getTitle(array $event)
|
||||||
|
{
|
||||||
|
$titles = array(
|
||||||
|
SubTask::EVENT_UPDATE => t('%s updated a subtask for the task #%d', $event['author'], $event['task_id']),
|
||||||
|
SubTask::EVENT_CREATE => t('%s created a subtask for the task #%d', $event['author'], $event['task_id']),
|
||||||
|
);
|
||||||
|
|
||||||
|
return isset($titles[$event['event_name']]) ? $titles[$event['event_name']] : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attach events to be able to record the history
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
public function attachEvents()
|
||||||
|
{
|
||||||
|
$events = array(
|
||||||
|
SubTask::EVENT_UPDATE,
|
||||||
|
SubTask::EVENT_CREATE,
|
||||||
|
);
|
||||||
|
|
||||||
|
$listener = new SubtaskHistoryListener($this);
|
||||||
|
|
||||||
|
foreach ($events as $event_name) {
|
||||||
|
$this->event->attach($event_name, $listener);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -936,21 +936,21 @@ class Task extends Base
|
|||||||
$tasks = $rq->fetchAll(PDO::FETCH_ASSOC);
|
$tasks = $rq->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
$columns = array(
|
$columns = array(
|
||||||
t('Task Id'),
|
e('Task Id'),
|
||||||
t('Project'),
|
e('Project'),
|
||||||
t('Status'),
|
e('Status'),
|
||||||
t('Category'),
|
e('Category'),
|
||||||
t('Column'),
|
e('Column'),
|
||||||
t('Position'),
|
e('Position'),
|
||||||
t('Color'),
|
e('Color'),
|
||||||
t('Due date'),
|
e('Due date'),
|
||||||
t('Creator'),
|
e('Creator'),
|
||||||
t('Assignee'),
|
e('Assignee'),
|
||||||
t('Complexity'),
|
e('Complexity'),
|
||||||
t('Title'),
|
e('Title'),
|
||||||
t('Creation date'),
|
e('Creation date'),
|
||||||
t('Modification date'),
|
e('Modification date'),
|
||||||
t('Completion date'),
|
e('Completion date'),
|
||||||
);
|
);
|
||||||
|
|
||||||
$results = array($columns);
|
$results = array($columns);
|
||||||
@@ -973,7 +973,7 @@ class Task extends Base
|
|||||||
{
|
{
|
||||||
$colors = $this->getColors();
|
$colors = $this->getColors();
|
||||||
$task['score'] = $task['score'] ?: '';
|
$task['score'] = $task['score'] ?: '';
|
||||||
$task['is_active'] = $task['is_active'] == self::STATUS_OPEN ? t('Open') : t('Closed');
|
$task['is_active'] = $task['is_active'] == self::STATUS_OPEN ? e('Open') : e('Closed');
|
||||||
$task['color_id'] = $colors[$task['color_id']];
|
$task['color_id'] = $colors[$task['color_id']];
|
||||||
$task['date_creation'] = date('Y-m-d', $task['date_creation']);
|
$task['date_creation'] = date('Y-m-d', $task['date_creation']);
|
||||||
$task['date_due'] = $task['date_due'] ? date('Y-m-d', $task['date_due']) : '';
|
$task['date_due'] = $task['date_due'] ? date('Y-m-d', $task['date_due']) : '';
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
namespace Model;
|
namespace Model;
|
||||||
|
|
||||||
use PDO;
|
use PDO;
|
||||||
use Core\Template;
|
use Core\Registry;
|
||||||
use Event\TaskHistoryListener;
|
use Event\TaskHistoryListener;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -12,7 +12,7 @@ use Event\TaskHistoryListener;
|
|||||||
* @package model
|
* @package model
|
||||||
* @author Frederic Guillot
|
* @author Frederic Guillot
|
||||||
*/
|
*/
|
||||||
class TaskHistory extends Base
|
class TaskHistory extends BaseHistory
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* SQL table name
|
* SQL table name
|
||||||
@@ -28,6 +28,18 @@ class TaskHistory extends Base
|
|||||||
*/
|
*/
|
||||||
const MAX_EVENTS = 5000;
|
const MAX_EVENTS = 5000;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param \Core\Registry $registry Registry instance
|
||||||
|
*/
|
||||||
|
public function __construct(Registry $registry)
|
||||||
|
{
|
||||||
|
parent::__construct($registry);
|
||||||
|
$this->table = self::TABLE;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new event
|
* Create a new event
|
||||||
*
|
*
|
||||||
@@ -58,40 +70,6 @@ class TaskHistory extends Base
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove old event entries to avoid a large table
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @param integer $max Maximum number of items to keep in the table
|
|
||||||
*/
|
|
||||||
public function cleanup($max)
|
|
||||||
{
|
|
||||||
if ($this->db->table(self::TABLE)->count() > $max) {
|
|
||||||
|
|
||||||
$this->db->execute('
|
|
||||||
DELETE FROM '.self::TABLE.'
|
|
||||||
WHERE id <= (
|
|
||||||
SELECT id FROM (
|
|
||||||
SELECT id FROM '.self::TABLE.' ORDER BY id DESC LIMIT 1 OFFSET '.$max.'
|
|
||||||
) foo
|
|
||||||
)');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get all events for a given project
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function getAllByProjectId($project_id)
|
|
||||||
{
|
|
||||||
return $this->db->table(self::TABLE)
|
|
||||||
->eq('project_id', $project_id)
|
|
||||||
->desc('id')
|
|
||||||
->findAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all necessary content to display activity feed
|
* Get all necessary content to display activity feed
|
||||||
*
|
*
|
||||||
@@ -103,6 +81,7 @@ class TaskHistory extends Base
|
|||||||
{
|
{
|
||||||
$sql = '
|
$sql = '
|
||||||
SELECT
|
SELECT
|
||||||
|
task_has_events.id,
|
||||||
task_has_events.date_creation,
|
task_has_events.date_creation,
|
||||||
task_has_events.event_name,
|
task_has_events.event_name,
|
||||||
task_has_events.task_id,
|
task_has_events.task_id,
|
||||||
@@ -154,19 +133,6 @@ class TaskHistory extends Base
|
|||||||
return isset($titles[$event['event_name']]) ? $titles[$event['event_name']] : '';
|
return isset($titles[$event['event_name']]) ? $titles[$event['event_name']] : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the event html content
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @param array $params Event properties
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getContent(array $params)
|
|
||||||
{
|
|
||||||
$tpl = new Template;
|
|
||||||
return $tpl->load('event_'.str_replace('.', '_', $params['event_name']), $params);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attach events to be able to record the history
|
* Attach events to be able to record the history
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -4,7 +4,59 @@ namespace Schema;
|
|||||||
|
|
||||||
use Core\Security;
|
use Core\Security;
|
||||||
|
|
||||||
const VERSION = 24;
|
const VERSION = 25;
|
||||||
|
|
||||||
|
function version_25($pdo)
|
||||||
|
{
|
||||||
|
$pdo->exec("
|
||||||
|
CREATE TABLE task_has_events (
|
||||||
|
id INT NOT NULL AUTO_INCREMENT,
|
||||||
|
date_creation INT NOT NULL,
|
||||||
|
event_name TEXT NOT NULL,
|
||||||
|
creator_id INT,
|
||||||
|
project_id INT,
|
||||||
|
task_id INT,
|
||||||
|
data TEXT,
|
||||||
|
FOREIGN KEY(creator_id) REFERENCES users(id) ON DELETE CASCADE,
|
||||||
|
FOREIGN KEY(project_id) REFERENCES projects(id) ON DELETE CASCADE,
|
||||||
|
FOREIGN KEY(task_id) REFERENCES tasks(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
");
|
||||||
|
|
||||||
|
$pdo->exec("
|
||||||
|
CREATE TABLE subtask_has_events (
|
||||||
|
id INT NOT NULL AUTO_INCREMENT,
|
||||||
|
date_creation INT NOT NULL,
|
||||||
|
event_name TEXT NOT NULL,
|
||||||
|
creator_id INT,
|
||||||
|
project_id INT,
|
||||||
|
subtask_id INT,
|
||||||
|
task_id INT,
|
||||||
|
data TEXT,
|
||||||
|
FOREIGN KEY(creator_id) REFERENCES users(id) ON DELETE CASCADE,
|
||||||
|
FOREIGN KEY(project_id) REFERENCES projects(id) ON DELETE CASCADE,
|
||||||
|
FOREIGN KEY(subtask_id) REFERENCES task_has_subtasks(id) ON DELETE CASCADE,
|
||||||
|
FOREIGN KEY(task_id) REFERENCES tasks(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
");
|
||||||
|
|
||||||
|
$pdo->exec("
|
||||||
|
CREATE TABLE comment_has_events (
|
||||||
|
id INT NOT NULL AUTO_INCREMENT,
|
||||||
|
date_creation INT NOT NULL,
|
||||||
|
event_name TEXT NOT NULL,
|
||||||
|
creator_id INT,
|
||||||
|
project_id INT,
|
||||||
|
comment_id INT,
|
||||||
|
task_id INT,
|
||||||
|
data TEXT,
|
||||||
|
FOREIGN KEY(creator_id) REFERENCES users(id) ON DELETE CASCADE,
|
||||||
|
FOREIGN KEY(project_id) REFERENCES projects(id) ON DELETE CASCADE,
|
||||||
|
FOREIGN KEY(comment_id) REFERENCES comments(id) ON DELETE CASCADE,
|
||||||
|
FOREIGN KEY(task_id) REFERENCES tasks(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
");
|
||||||
|
}
|
||||||
|
|
||||||
function version_24($pdo)
|
function version_24($pdo)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,7 +4,59 @@ namespace Schema;
|
|||||||
|
|
||||||
use Core\Security;
|
use Core\Security;
|
||||||
|
|
||||||
const VERSION = 5;
|
const VERSION = 6;
|
||||||
|
|
||||||
|
function version_6($pdo)
|
||||||
|
{
|
||||||
|
$pdo->exec("
|
||||||
|
CREATE TABLE task_has_events (
|
||||||
|
id SERIAL PRIMARY KEY,
|
||||||
|
date_creation INTEGER NOT NULL,
|
||||||
|
event_name TEXT NOT NULL,
|
||||||
|
creator_id INTEGER,
|
||||||
|
project_id INTEGER,
|
||||||
|
task_id INTEGER,
|
||||||
|
data TEXT,
|
||||||
|
FOREIGN KEY(creator_id) REFERENCES users(id) ON DELETE CASCADE,
|
||||||
|
FOREIGN KEY(project_id) REFERENCES projects(id) ON DELETE CASCADE,
|
||||||
|
FOREIGN KEY(task_id) REFERENCES tasks(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
");
|
||||||
|
|
||||||
|
$pdo->exec("
|
||||||
|
CREATE TABLE subtask_has_events (
|
||||||
|
id SERIAL PRIMARY KEY,
|
||||||
|
date_creation INTEGER NOT NULL,
|
||||||
|
event_name TEXT NOT NULL,
|
||||||
|
creator_id INTEGER,
|
||||||
|
project_id INTEGER,
|
||||||
|
subtask_id INTEGER,
|
||||||
|
task_id INTEGER,
|
||||||
|
data TEXT,
|
||||||
|
FOREIGN KEY(creator_id) REFERENCES users(id) ON DELETE CASCADE,
|
||||||
|
FOREIGN KEY(project_id) REFERENCES projects(id) ON DELETE CASCADE,
|
||||||
|
FOREIGN KEY(subtask_id) REFERENCES task_has_subtasks(id) ON DELETE CASCADE,
|
||||||
|
FOREIGN KEY(task_id) REFERENCES tasks(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
");
|
||||||
|
|
||||||
|
$pdo->exec("
|
||||||
|
CREATE TABLE comment_has_events (
|
||||||
|
id SERIAL PRIMARY KEY,
|
||||||
|
date_creation INTEGER NOT NULL,
|
||||||
|
event_name TEXT NOT NULL,
|
||||||
|
creator_id INTEGER,
|
||||||
|
project_id INTEGER,
|
||||||
|
comment_id INTEGER,
|
||||||
|
task_id INTEGER,
|
||||||
|
data TEXT,
|
||||||
|
FOREIGN KEY(creator_id) REFERENCES users(id) ON DELETE CASCADE,
|
||||||
|
FOREIGN KEY(project_id) REFERENCES projects(id) ON DELETE CASCADE,
|
||||||
|
FOREIGN KEY(comment_id) REFERENCES comments(id) ON DELETE CASCADE,
|
||||||
|
FOREIGN KEY(task_id) REFERENCES tasks(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
");
|
||||||
|
}
|
||||||
|
|
||||||
function version_5($pdo)
|
function version_5($pdo)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -11,16 +11,51 @@ function version_25($pdo)
|
|||||||
$pdo->exec("
|
$pdo->exec("
|
||||||
CREATE TABLE task_has_events (
|
CREATE TABLE task_has_events (
|
||||||
id INTEGER PRIMARY KEY,
|
id INTEGER PRIMARY KEY,
|
||||||
date_creation INTEGER,
|
date_creation INTEGER NOT NULL,
|
||||||
event_name TEXT NOT NULL,
|
event_name TEXT NOT NULL,
|
||||||
creator_id INTEGER,
|
creator_id INTEGER,
|
||||||
project_id INTEGER,
|
project_id INTEGER,
|
||||||
task_id INTEGER,
|
task_id INTEGER,
|
||||||
|
data TEXT,
|
||||||
FOREIGN KEY(creator_id) REFERENCES users(id) ON DELETE CASCADE,
|
FOREIGN KEY(creator_id) REFERENCES users(id) ON DELETE CASCADE,
|
||||||
FOREIGN KEY(project_id) REFERENCES projects(id) ON DELETE CASCADE,
|
FOREIGN KEY(project_id) REFERENCES projects(id) ON DELETE CASCADE,
|
||||||
FOREIGN KEY(task_id) REFERENCES tasks(id) ON DELETE CASCADE
|
FOREIGN KEY(task_id) REFERENCES tasks(id) ON DELETE CASCADE
|
||||||
);
|
);
|
||||||
");
|
");
|
||||||
|
|
||||||
|
$pdo->exec("
|
||||||
|
CREATE TABLE subtask_has_events (
|
||||||
|
id INTEGER PRIMARY KEY,
|
||||||
|
date_creation INTEGER NOT NULL,
|
||||||
|
event_name TEXT NOT NULL,
|
||||||
|
creator_id INTEGER,
|
||||||
|
project_id INTEGER,
|
||||||
|
subtask_id INTEGER,
|
||||||
|
task_id INTEGER,
|
||||||
|
data TEXT,
|
||||||
|
FOREIGN KEY(creator_id) REFERENCES users(id) ON DELETE CASCADE,
|
||||||
|
FOREIGN KEY(project_id) REFERENCES projects(id) ON DELETE CASCADE,
|
||||||
|
FOREIGN KEY(subtask_id) REFERENCES task_has_subtasks(id) ON DELETE CASCADE,
|
||||||
|
FOREIGN KEY(task_id) REFERENCES tasks(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
");
|
||||||
|
|
||||||
|
$pdo->exec("
|
||||||
|
CREATE TABLE comment_has_events (
|
||||||
|
id INTEGER PRIMARY KEY,
|
||||||
|
date_creation INTEGER NOT NULL,
|
||||||
|
event_name TEXT NOT NULL,
|
||||||
|
creator_id INTEGER,
|
||||||
|
project_id INTEGER,
|
||||||
|
comment_id INTEGER,
|
||||||
|
task_id INTEGER,
|
||||||
|
data TEXT,
|
||||||
|
FOREIGN KEY(creator_id) REFERENCES users(id) ON DELETE CASCADE,
|
||||||
|
FOREIGN KEY(project_id) REFERENCES projects(id) ON DELETE CASCADE,
|
||||||
|
FOREIGN KEY(comment_id) REFERENCES comments(id) ON DELETE CASCADE,
|
||||||
|
FOREIGN KEY(task_id) REFERENCES tasks(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
");
|
||||||
}
|
}
|
||||||
|
|
||||||
function version_24($pdo)
|
function version_24($pdo)
|
||||||
|
|||||||
7
app/Templates/event_comment_create.php
Normal file
7
app/Templates/event_comment_create.php
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<p class="activity-title">
|
||||||
|
<?= e('%s commented the task <a href="?controller=task&action=show&task_id=%d">#%d</a>', Helper\escape($author), $task_id, $task_id) ?>
|
||||||
|
</p>
|
||||||
|
<p class="activity-description">
|
||||||
|
<em><?= Helper\escape($task_title) ?></em><br/>
|
||||||
|
<div class="markdown"><?= Helper\parse($comment) ?></div>
|
||||||
|
</p>
|
||||||
7
app/Templates/event_comment_update.php
Normal file
7
app/Templates/event_comment_update.php
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<p class="activity-title">
|
||||||
|
<?= e('%s updated a comment on the task <a href="?controller=task&action=show&task_id=%d">#%d</a>', Helper\escape($author), $task_id, $task_id) ?>
|
||||||
|
</p>
|
||||||
|
<p class="activity-description">
|
||||||
|
<em><?= Helper\escape($task_title) ?></em><br/>
|
||||||
|
<div class="markdown"><?= Helper\parse($comment) ?></div>
|
||||||
|
</p>
|
||||||
12
app/Templates/event_subtask_create.php
Normal file
12
app/Templates/event_subtask_create.php
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<p class="activity-title">
|
||||||
|
<?= e('%s created a subtask for the task <a href="?controller=task&action=show&task_id=%d">#%d</a>', Helper\escape($author), $task_id, $task_id) ?>
|
||||||
|
</p>
|
||||||
|
<p class="activity-description">
|
||||||
|
<em><?= Helper\escape($task_title) ?></em><br/>
|
||||||
|
<p><?= Helper\escape($subtask_title) ?> <strong>(<?= Helper\in_list($subtask_status, $subtask_status_list) ?>)</strong></p>
|
||||||
|
<?php if ($subtask_assignee): ?>
|
||||||
|
<p><?= t('Assigned to %s with estimate of %s/%sh', $subtask_assignee, $subtask_time_spent, $subtask_time_estimated) ?></p>
|
||||||
|
<?php else: ?>
|
||||||
|
<p><?= t('Not assigned, estimate of %sh', $subtask_time_estimated) ?></p>
|
||||||
|
<?php endif ?>
|
||||||
|
</p>
|
||||||
12
app/Templates/event_subtask_update.php
Normal file
12
app/Templates/event_subtask_update.php
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<p class="activity-title">
|
||||||
|
<?= e('%s updated a subtask for the task <a href="?controller=task&action=show&task_id=%d">#%d</a>', Helper\escape($author), $task_id, $task_id) ?>
|
||||||
|
</p>
|
||||||
|
<p class="activity-description">
|
||||||
|
<em><?= Helper\escape($task_title) ?></em><br/>
|
||||||
|
<p><?= Helper\escape($subtask_title) ?> <strong>(<?= Helper\in_list($subtask_status, $subtask_status_list) ?>)</strong></p>
|
||||||
|
<?php if ($subtask_assignee): ?>
|
||||||
|
<p><?= t('Assigned to %s with estimate of %s/%sh', $subtask_assignee, $subtask_time_spent, $subtask_time_estimated) ?></p>
|
||||||
|
<?php else: ?>
|
||||||
|
<p><?= t('Not assigned, estimate of %sh', $subtask_time_estimated) ?></p>
|
||||||
|
<?php endif ?>
|
||||||
|
</p>
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<p class="activity-title">
|
<p class="activity-title">
|
||||||
<?= t('%s closed the task #%d', $author, $task_id) ?>
|
<?= e('%s closed the task <a href="?controller=task&action=show&task_id=%d">#%d</a>', Helper\escape($author), $task_id, $task_id) ?>
|
||||||
</p>
|
</p>
|
||||||
<p class="activity-description">
|
<p class="activity-description">
|
||||||
<em><?= Helper\escape($task_title) ?></em>
|
<em><?= Helper\escape($task_title) ?></em>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<p class="activity-title">
|
<p class="activity-title">
|
||||||
<?= t('%s created the task #%d', $author, $task_id) ?>
|
<?= e('%s created the task <a href="?controller=task&action=show&task_id=%d">#%d</a>', Helper\escape($author), $task_id, $task_id) ?>
|
||||||
</p>
|
</p>
|
||||||
<p class="activity-description">
|
<p class="activity-description">
|
||||||
<em><?= Helper\escape($task_title) ?></em>
|
<em><?= Helper\escape($task_title) ?></em>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<p class="activity-title">
|
<p class="activity-title">
|
||||||
<?= t('%s moved the task #%d to the column %s', $author, $task_id, $task_column_name) ?>
|
<?= e('%s moved the task <a href="?controller=task&action=show&task_id=%d">#%d</a> to the column "%s"', Helper\escape($author), $task_id, $task_id, Helper\escape($task_column_name)) ?>
|
||||||
</p>
|
</p>
|
||||||
<p class="activity-description">
|
<p class="activity-description">
|
||||||
<em><?= Helper\escape($task_title) ?></em>
|
<em><?= Helper\escape($task_title) ?></em>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<p class="activity-title">
|
<p class="activity-title">
|
||||||
<?= t('%s moved the task #%d to the position %d in the column %s', $author, $task_id, $task_position, $task_column_name) ?>
|
<?= e('%s moved the task <a href="?controller=task&action=show&task_id=%d">#%d</a> to the position #%d in the column "%s"', Helper\escape($author), $task_id, $task_id, $task_position, Helper\escape($task_column_name)) ?>
|
||||||
</p>
|
</p>
|
||||||
<p class="activity-description">
|
<p class="activity-description">
|
||||||
<em><?= Helper\escape($task_title) ?></em>
|
<em><?= Helper\escape($task_title) ?></em>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<p class="activity-title">
|
<p class="activity-title">
|
||||||
<?= t('%s open the task #%d', $author, $task_id) ?>
|
<?= e('%s open the task <a href="?controller=task&action=show&task_id=%d">#%d</a>', Helper\escape($author), $task_id, $task_id) ?>
|
||||||
</p>
|
</p>
|
||||||
<p class="activity-description">
|
<p class="activity-description">
|
||||||
<em><?= Helper\escape($task_title ?></em>
|
<em><?= Helper\escape($task_title) ?></em>
|
||||||
</p>
|
</p>
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<p class="activity-title">
|
<p class="activity-title">
|
||||||
<?= t('%s updated the task #%d', $author, $task_id) ?>
|
<?= e('%s updated the task <a href="?controller=task&action=show&task_id=%d">#%d</a>', Helper\escape($author), $task_id, $task_id) ?>
|
||||||
</p>
|
</p>
|
||||||
<p class="activity-description">
|
<p class="activity-description">
|
||||||
<em><?= Helper\escape($task_title) ?></em>
|
<em><?= Helper\escape($task_title) ?></em>
|
||||||
|
|||||||
@@ -17,6 +17,10 @@
|
|||||||
<p class="activity-datetime">
|
<p class="activity-datetime">
|
||||||
<?php if ($event['event_type'] === 'task'): ?>
|
<?php if ($event['event_type'] === 'task'): ?>
|
||||||
<i class="fa fa-newspaper-o"></i>
|
<i class="fa fa-newspaper-o"></i>
|
||||||
|
<?php elseif ($event['event_type'] === 'subtask'): ?>
|
||||||
|
<i class="fa fa-tasks"></i>
|
||||||
|
<?php elseif ($event['event_type'] === 'comment'): ?>
|
||||||
|
<i class="fa fa-comments-o"></i>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
<?= dt('%B %e, %Y at %k:%M %p', $event['date_creation']) ?>
|
<?= dt('%B %e, %Y at %k:%M %p', $event['date_creation']) ?>
|
||||||
</p>
|
</p>
|
||||||
|
|||||||
@@ -9,6 +9,13 @@ function t()
|
|||||||
return call_user_func_array(array($t, 'translate'), func_get_args());
|
return call_user_func_array(array($t, 'translate'), func_get_args());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// translate with no html escaping
|
||||||
|
function e()
|
||||||
|
{
|
||||||
|
$t = new Translator;
|
||||||
|
return call_user_func_array(array($t, 'translateNoEscaping'), func_get_args());
|
||||||
|
}
|
||||||
|
|
||||||
// Get a locale currency
|
// Get a locale currency
|
||||||
function c($value)
|
function c($value)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -43,7 +43,10 @@ require_once __DIR__.'/../../app/Model/Action.php';
|
|||||||
require_once __DIR__.'/../../app/Model/Category.php';
|
require_once __DIR__.'/../../app/Model/Category.php';
|
||||||
require_once __DIR__.'/../../app/Model/SubTask.php';
|
require_once __DIR__.'/../../app/Model/SubTask.php';
|
||||||
require_once __DIR__.'/../../app/Model/File.php';
|
require_once __DIR__.'/../../app/Model/File.php';
|
||||||
|
require_once __DIR__.'/../../app/Model/BaseHistory.php';
|
||||||
require_once __DIR__.'/../../app/Model/TaskHistory.php';
|
require_once __DIR__.'/../../app/Model/TaskHistory.php';
|
||||||
|
require_once __DIR__.'/../../app/Model/SubtaskHistory.php';
|
||||||
|
require_once __DIR__.'/../../app/Model/CommentHistory.php';
|
||||||
|
|
||||||
require_once __DIR__.'/../../app/Action/Base.php';
|
require_once __DIR__.'/../../app/Action/Base.php';
|
||||||
require_once __DIR__.'/../../app/Action/TaskClose.php';
|
require_once __DIR__.'/../../app/Action/TaskClose.php';
|
||||||
|
|||||||
Reference in New Issue
Block a user