Add fields: task creator and modification date

This commit is contained in:
Frédéric Guillot
2014-07-08 15:07:07 -03:00
parent 7a64053cb8
commit ba93061f4d
13 changed files with 93 additions and 33 deletions

View File

@@ -108,6 +108,8 @@ class Task extends Base
public function save() public function save()
{ {
$values = $this->request->getValues(); $values = $this->request->getValues();
$values['creator_id'] = $this->acl->getUserId();
$this->checkProjectPermissions($values['project_id']); $this->checkProjectPermissions($values['project_id']);
list($valid, $errors) = $this->task->validateCreation($values); list($valid, $errors) = $this->task->validateCreation($values);

View File

@@ -384,4 +384,14 @@ return array(
// 'Maximum size: ' => '', // 'Maximum size: ' => '',
// 'Unable to upload the file.' => '', // 'Unable to upload the file.' => '',
// 'Display another project' => '', // 'Display another project' => '',
// 'Your GitHub account was successfully linked to your profile.' => '',
// 'Unable to link your GitHub Account.' => '',
// 'GitHub authentication failed' => '',
// 'Your GitHub account is no longer linked to your profile.' => '',
// 'Unable to unlink your GitHub Account.' => '',
// 'Login with my GitHub Account' => '',
// 'Link my GitHub Account' => '',
// 'Unlink my GitHub Account' => '',
// 'Created by %s' => 'Créé par %s',
// 'Last modified on %B %e, %G at %k:%M %p' => '',
); );

View File

@@ -384,4 +384,6 @@ return array(
// 'Login with my GitHub Account' => '', // 'Login with my GitHub Account' => '',
// 'Link my GitHub Account' => '', // 'Link my GitHub Account' => '',
// 'Unlink my GitHub Account' => '', // 'Unlink my GitHub Account' => '',
// 'Created by %s' => 'Créé par %s',
// 'Last modified on %B %e, %G at %k:%M %p' => '',
); );

View File

@@ -382,4 +382,6 @@ return array(
'Login with my GitHub Account' => 'Se connecter avec mon compte Github', 'Login with my GitHub Account' => 'Se connecter avec mon compte Github',
'Link my GitHub Account' => 'Lier mon compte Github', 'Link my GitHub Account' => 'Lier mon compte Github',
'Unlink my GitHub Account' => 'Ne plus utiliser mon compte Github', 'Unlink my GitHub Account' => 'Ne plus utiliser mon compte Github',
'Created by %s' => 'Créé par %s',
'Last modified on %B %e, %G at %k:%M %p' => 'Modifié le %d/%m/%Y à %H:%M',
); );

View File

@@ -385,4 +385,6 @@ return array(
// 'Login with my GitHub Account' => '', // 'Login with my GitHub Account' => '',
// 'Link my GitHub Account' => '', // 'Link my GitHub Account' => '',
// 'Unlink my GitHub Account' => '', // 'Unlink my GitHub Account' => '',
// 'Created by %s' => 'Créé par %s',
// 'Last modified on %B %e, %G at %k:%M %p' => '',
); );

View File

@@ -382,4 +382,6 @@ return array(
// 'Login with my GitHub Account' => '', // 'Login with my GitHub Account' => '',
// 'Link my GitHub Account' => '', // 'Link my GitHub Account' => '',
// 'Unlink my GitHub Account' => '', // 'Unlink my GitHub Account' => '',
// 'Created by %s' => 'Créé par %s',
// 'Last modified on %B %e, %G at %k:%M %p' => '',
); );

View File

@@ -384,4 +384,6 @@ return array(
// 'Login with my GitHub Account' => '', // 'Login with my GitHub Account' => '',
// 'Link my GitHub Account' => '', // 'Link my GitHub Account' => '',
// 'Unlink my GitHub Account' => '', // 'Unlink my GitHub Account' => '',
// 'Created by %s' => 'Créé par %s',
// 'Last modified on %B %e, %G at %k:%M %p' => '',
); );

View File

@@ -390,4 +390,6 @@ return array(
// 'Login with my GitHub Account' => '', // 'Login with my GitHub Account' => '',
// 'Link my GitHub Account' => '', // 'Link my GitHub Account' => '',
// 'Unlink my GitHub Account' => '', // 'Unlink my GitHub Account' => '',
// 'Created by %s' => 'Créé par %s',
// 'Last modified on %B %e, %G at %k:%M %p' => '',
); );

View File

@@ -73,34 +73,40 @@ class Task extends Base
{ {
if ($more) { if ($more) {
return $this->db $sql = '
->table(self::TABLE) SELECT
->columns( tasks.id,
self::TABLE.'.id', tasks.title,
self::TABLE.'.title', tasks.description,
self::TABLE.'.description', tasks.date_creation,
self::TABLE.'.date_creation', tasks.date_completed,
self::TABLE.'.date_completed', tasks.date_modification,
self::TABLE.'.date_due', tasks.date_due,
self::TABLE.'.color_id', tasks.color_id,
self::TABLE.'.project_id', tasks.project_id,
self::TABLE.'.column_id', tasks.column_id,
self::TABLE.'.owner_id', tasks.owner_id,
self::TABLE.'.position', tasks.creator_id,
self::TABLE.'.is_active', tasks.position,
self::TABLE.'.score', tasks.is_active,
self::TABLE.'.category_id', tasks.score,
Category::TABLE.'.name AS category_name', tasks.category_id,
Project::TABLE.'.name AS project_name', project_has_categories.name AS category_name,
Board::TABLE.'.title AS column_title', projects.name AS project_name,
User::TABLE.'.username' columns.title AS column_title,
) users.username AS assignee_username,
->join(Category::TABLE, 'id', 'category_id') creators.username AS creator_username
->join(Project::TABLE, 'id', 'project_id') FROM tasks
->join(Board::TABLE, 'id', 'column_id') LEFT JOIN users ON users.id = tasks.owner_id
->join(User::TABLE, 'id', 'owner_id') LEFT JOIN users AS creators ON creators.id = tasks.creator_id
->eq(self::TABLE.'.id', $task_id) LEFT JOIN project_has_categories ON project_has_categories.id = tasks.category_id
->findOne(); LEFT JOIN projects ON projects.id = tasks.project_id
LEFT JOIN columns ON columns.id = tasks.column_id
WHERE tasks.id = ?
';
$rq = $this->db->execute($sql, array($task_id));
return $rq->fetch(\PDO::FETCH_ASSOC);
} }
else { else {
@@ -385,6 +391,7 @@ class Task extends Base
} }
$updated_task = $values; $updated_task = $values;
$updated_task['date_modification'] = time();
unset($updated_task['id']); unset($updated_task['id']);
$result = $this->db->table(self::TABLE)->eq('id', $values['id'])->update($updated_task); $result = $this->db->table(self::TABLE)->eq('id', $values['id'])->update($updated_task);
@@ -514,6 +521,7 @@ class Task extends Base
new Validators\Required('column_id', t('The column is required')), new Validators\Required('column_id', t('The column is required')),
new Validators\Integer('column_id', t('This value must be an integer')), new Validators\Integer('column_id', t('This value must be an integer')),
new Validators\Integer('owner_id', t('This value must be an integer')), new Validators\Integer('owner_id', t('This value must be an integer')),
new Validators\Integer('creator_id', t('This value must be an integer')),
new Validators\Integer('score', t('This value must be an integer')), new Validators\Integer('score', t('This value must be an integer')),
new Validators\Required('title', t('The title is required')), new Validators\Required('title', t('The title is required')),
new Validators\MaxLength('title', t('The maximum length is %d characters', 200), 200), new Validators\MaxLength('title', t('The maximum length is %d characters', 200), 200),

View File

@@ -4,7 +4,13 @@ namespace Schema;
use Core\Security; use Core\Security;
const VERSION = 20; const VERSION = 21;
function version_21($pdo)
{
$pdo->exec("ALTER TABLE tasks ADD COLUMN creator_id INTEGER DEFAULT '0'");
$pdo->exec("ALTER TABLE tasks ADD COLUMN date_modification INTEGER DEFAULT '0'");
}
function version_20($pdo) function version_20($pdo)
{ {

View File

@@ -4,7 +4,13 @@ namespace Schema;
use Core\Security; use Core\Security;
const VERSION = 1; const VERSION = 2;
function version_2($pdo)
{
$pdo->exec("ALTER TABLE tasks ADD COLUMN creator_id INTEGER DEFAULT 0");
$pdo->exec("ALTER TABLE tasks ADD COLUMN date_modification INTEGER DEFAULT 0");
}
function version_1($pdo) function version_1($pdo)
{ {

View File

@@ -4,7 +4,13 @@ namespace Schema;
use Core\Security; use Core\Security;
const VERSION = 20; const VERSION = 21;
function version_21($pdo)
{
$pdo->exec("ALTER TABLE tasks ADD COLUMN creator_id INTEGER DEFAULT '0'");
$pdo->exec("ALTER TABLE tasks ADD COLUMN date_modification INTEGER DEFAULT '0'");
}
function version_20($pdo) function version_20($pdo)
{ {

View File

@@ -7,6 +7,11 @@
<li> <li>
<?= dt('Created on %B %e, %G at %k:%M %p', $task['date_creation']) ?> <?= dt('Created on %B %e, %G at %k:%M %p', $task['date_creation']) ?>
</li> </li>
<?php if ($task['date_modification']): ?>
<li>
<?= dt('Last modified on %B %e, %G at %k:%M %p', $task['date_modification']) ?>
</li>
<?php endif ?>
<?php if ($task['date_completed']): ?> <?php if ($task['date_completed']): ?>
<li> <li>
<?= dt('Completed on %B %e, %G at %k:%M %p', $task['date_completed']) ?> <?= dt('Completed on %B %e, %G at %k:%M %p', $task['date_completed']) ?>
@@ -17,10 +22,15 @@
<strong><?= dt('Must be done before %B %e, %G', $task['date_due']) ?></strong> <strong><?= dt('Must be done before %B %e, %G', $task['date_due']) ?></strong>
</li> </li>
<?php endif ?> <?php endif ?>
<?php if ($task['creator_username']): ?>
<li>
<?= t('Created by %s', $task['creator_username']) ?>
</li>
<?php endif ?>
<li> <li>
<strong> <strong>
<?php if ($task['username']): ?> <?php if ($task['assignee_username']): ?>
<?= t('Assigned to %s', $task['username']) ?> <?= t('Assigned to %s', $task['assignee_username']) ?>
<?php else: ?> <?php else: ?>
<?= t('There is nobody assigned') ?> <?= t('There is nobody assigned') ?>
<?php endif ?> <?php endif ?>