Add support for Github Issue Webhooks

This commit is contained in:
Frédéric Guillot 2014-09-28 18:23:21 -04:00
parent 03fa01ac7b
commit 33f9cdbc97
29 changed files with 766 additions and 17 deletions

View File

@ -0,0 +1,84 @@
<?php
namespace Action;
use Model\GithubWebhook;
/**
* Set a category automatically according to a label
*
* @package action
* @author Frederic Guillot
*/
class TaskAssignCategoryLabel extends Base
{
/**
* Get the list of compatible events
*
* @access public
* @return array
*/
public function getCompatibleEvents()
{
return array(
GithubWebhook::EVENT_ISSUE_LABEL_CHANGE,
);
}
/**
* Get the required parameter for the action (defined by the user)
*
* @access public
* @return array
*/
public function getActionRequiredParameters()
{
return array(
'label' => t('Label'),
'category_id' => t('Category'),
);
}
/**
* Get the required parameter for the event
*
* @access public
* @return string[]
*/
public function getEventRequiredParameters()
{
return array(
'task_id',
'label',
);
}
/**
* Execute the action (change the category)
*
* @access public
* @param array $data Event data dictionary
* @return bool True if the action was executed or false when not executed
*/
public function doAction(array $data)
{
$values = array(
'id' => $data['task_id'],
'category_id' => isset($data['category_id']) ? $data['category_id'] : $this->getParam('category_id'),
);
return $this->task->update($values, false);
}
/**
* Check if the event data meet the action condition
*
* @access public
* @param array $data Event data dictionary
* @return bool
*/
public function hasRequiredCondition(array $data)
{
return $data['label'] == $this->getParam('label');
}
}

View File

@ -0,0 +1,81 @@
<?php
namespace Action;
use Model\GithubWebhook;
/**
* Assign a task to someone
*
* @package action
* @author Frederic Guillot
*/
class TaskAssignUser extends Base
{
/**
* Get the list of compatible events
*
* @access public
* @return array
*/
public function getCompatibleEvents()
{
return array(
GithubWebhook::EVENT_ISSUE_ASSIGNEE_CHANGE,
);
}
/**
* Get the required parameter for the action (defined by the user)
*
* @access public
* @return array
*/
public function getActionRequiredParameters()
{
return array();
}
/**
* Get the required parameter for the event
*
* @access public
* @return string[]
*/
public function getEventRequiredParameters()
{
return array(
'task_id',
'owner_id',
);
}
/**
* Execute the action (assign the given user)
*
* @access public
* @param array $data Event data dictionary
* @return bool True if the action was executed or false when not executed
*/
public function doAction(array $data)
{
$values = array(
'id' => $data['task_id'],
'owner_id' => $data['owner_id'],
);
return $this->task->update($values, false);
}
/**
* Check if the event data meet the action condition
*
* @access public
* @param array $data Event data dictionary
* @return bool
*/
public function hasRequiredCondition(array $data)
{
return true;
}
}

View File

@ -24,6 +24,7 @@ class TaskClose extends Base
return array(
Task::EVENT_MOVE_COLUMN,
GithubWebhook::EVENT_COMMIT,
GithubWebhook::EVENT_ISSUE_CLOSED,
);
}
@ -37,6 +38,7 @@ class TaskClose extends Base
{
switch ($this->event_name) {
case GithubWebhook::EVENT_COMMIT:
case GithubWebhook::EVENT_ISSUE_CLOSED:
return array();
default:
return array('column_id' => t('Column'));
@ -53,6 +55,7 @@ class TaskClose extends Base
{
switch ($this->event_name) {
case GithubWebhook::EVENT_COMMIT:
case GithubWebhook::EVENT_ISSUE_CLOSED:
return array('task_id');
default:
return array('task_id', 'column_id');
@ -82,6 +85,7 @@ class TaskClose extends Base
{
switch ($this->event_name) {
case GithubWebhook::EVENT_COMMIT:
case GithubWebhook::EVENT_ISSUE_CLOSED:
return true;
default:
return $data['column_id'] == $this->getParam('column_id');

View File

@ -0,0 +1,81 @@
<?php
namespace Action;
use Model\GithubWebhook;
/**
* Create automatically a task from a webhook
*
* @package action
* @author Frederic Guillot
*/
class TaskCreation extends Base
{
/**
* Get the list of compatible events
*
* @access public
* @return array
*/
public function getCompatibleEvents()
{
return array(
GithubWebhook::EVENT_ISSUE_OPENED,
);
}
/**
* Get the required parameter for the action (defined by the user)
*
* @access public
* @return array
*/
public function getActionRequiredParameters()
{
return array();
}
/**
* Get the required parameter for the event
*
* @access public
* @return string[]
*/
public function getEventRequiredParameters()
{
return array(
'reference',
'title',
);
}
/**
* Execute the action (create a new task)
*
* @access public
* @param array $data Event data dictionary
* @return bool True if the action was executed or false when not executed
*/
public function doAction(array $data)
{
return $this->task->create(array(
'project_id' => $data['project_id'],
'title' => $data['title'],
'reference' => $data['reference'],
'description' => $data['description'],
));
}
/**
* Check if the event data meet the action condition
*
* @access public
* @param array $data Event data dictionary
* @return bool
*/
public function hasRequiredCondition(array $data)
{
return true;
}
}

73
app/Action/TaskOpen.php Normal file
View File

@ -0,0 +1,73 @@
<?php
namespace Action;
use Model\GithubWebhook;
/**
* Open automatically a task
*
* @package action
* @author Frederic Guillot
*/
class TaskOpen extends Base
{
/**
* Get the list of compatible events
*
* @access public
* @return array
*/
public function getCompatibleEvents()
{
return array(
GithubWebhook::EVENT_ISSUE_REOPENED,
);
}
/**
* Get the required parameter for the action (defined by the user)
*
* @access public
* @return array
*/
public function getActionRequiredParameters()
{
return array();
}
/**
* Get the required parameter for the event
*
* @access public
* @return string[]
*/
public function getEventRequiredParameters()
{
return array('task_id');
}
/**
* Execute the action (close the task)
*
* @access public
* @param array $data Event data dictionary
* @return bool True if the action was executed or false when not executed
*/
public function doAction(array $data)
{
return $this->task->open($data['task_id']);
}
/**
* Check if the event data meet the action condition
*
* @access public
* @param array $data Event data dictionary
* @return bool
*/
public function hasRequiredCondition(array $data)
{
return true;
}
}

View File

@ -53,6 +53,8 @@ class Webhook extends Base
$this->response->text('Not Authorized', 401);
}
$this->githubWebhook->setProjectId($this->request->getIntegerParam('project_id'));
$this->githubWebhook->parsePayload(
$this->request->getHeader('X-Github-Event'),
$this->request->getBody()

View File

@ -505,4 +505,15 @@ return array(
// 'New password for the user "%s"' => '',
// 'Choose an event' => '',
// 'Github commit received' => '',
// 'Github issue opened' => '',
// 'Github issue closed' => '',
// 'Github issue reopened' => '',
// 'Github issue assignee change' => '',
// 'Github issue label change' => '',
// 'Create a task from an external provider' => '',
// 'Change the assignee based on an external username' => '',
// 'Change the category based on an external label' => '',
// 'Reference' => '',
// 'Reference: %s' => '',
// 'Label' => '',
);

View File

@ -505,4 +505,15 @@ return array(
'New password for the user "%s"' => 'Nueva contraseña para el usuario "%s"',
// 'Choose an event' => '',
// 'Github commit received' => '',
// 'Github issue opened' => '',
// 'Github issue closed' => '',
// 'Github issue reopened' => '',
// 'Github issue assignee change' => '',
// 'Github issue label change' => '',
// 'Create a task from an external provider' => '',
// 'Change the assignee based on an external username' => '',
// 'Change the category based on an external label' => '',
// 'Reference' => '',
// 'Reference: %s' => '',
// 'Label' => '',
);

View File

@ -505,4 +505,15 @@ return array(
// 'New password for the user "%s"' => '',
// 'Choose an event' => '',
// 'Github commit received' => '',
// 'Github issue opened' => '',
// 'Github issue closed' => '',
// 'Github issue reopened' => '',
// 'Github issue assignee change' => '',
// 'Github issue label change' => '',
// 'Create a task from an external provider' => '',
// 'Change the assignee based on an external username' => '',
// 'Change the category based on an external label' => '',
// 'Reference' => '',
// 'Reference: %s' => '',
// 'Label' => '',
);

View File

@ -505,4 +505,15 @@ return array(
'New password for the user "%s"' => 'Nouveau mot de passe pour l\'utilisateur « %s »',
'Choose an event' => 'Choisir un événement',
'Github commit received' => '« Commit » reçu via Github',
'Github issue opened' => 'Ouverture d\'un ticket sur Github',
'Github issue closed' => 'Fermeture d\'un ticket sur Github',
'Github issue reopened' => 'Réouverture d\'un ticket sur Github',
'Github issue assignee change' => 'Changement d\'assigné sur un ticket Github',
'Github issue label change' => 'Changement de libellé sur un ticket Github',
'Create a task from an external provider' => 'Créer une tâche depuis un fournisseur externe',
'Change the assignee based on an external username' => 'Changer l\'assigné en fonction d\'un utilisateur externe',
'Change the category based on an external label' => 'Changer la catégorie en fonction d\'un libellé externe',
'Reference' => 'Référence',
'Reference: %s' => 'Référence : %s',
'Label' => 'Libellé',
);

View File

@ -505,4 +505,15 @@ return array(
// 'New password for the user "%s"' => '',
// 'Choose an event' => '',
// 'Github commit received' => '',
// 'Github issue opened' => '',
// 'Github issue closed' => '',
// 'Github issue reopened' => '',
// 'Github issue assignee change' => '',
// 'Github issue label change' => '',
// 'Create a task from an external provider' => '',
// 'Change the assignee based on an external username' => '',
// 'Change the category based on an external label' => '',
// 'Reference' => '',
// 'Reference: %s' => '',
// 'Label' => '',
);

View File

@ -505,4 +505,15 @@ return array(
// 'New password for the user "%s"' => '',
// 'Choose an event' => '',
// 'Github commit received' => '',
// 'Github issue opened' => '',
// 'Github issue closed' => '',
// 'Github issue reopened' => '',
// 'Github issue assignee change' => '',
// 'Github issue label change' => '',
// 'Create a task from an external provider' => '',
// 'Change the assignee based on an external username' => '',
// 'Change the category based on an external label' => '',
// 'Reference' => '',
// 'Reference: %s' => '',
// 'Label' => '',
);

View File

@ -505,4 +505,15 @@ return array(
// 'New password for the user "%s"' => '',
// 'Choose an event' => '',
// 'Github commit received' => '',
// 'Github issue opened' => '',
// 'Github issue closed' => '',
// 'Github issue reopened' => '',
// 'Github issue assignee change' => '',
// 'Github issue label change' => '',
// 'Create a task from an external provider' => '',
// 'Change the assignee based on an external username' => '',
// 'Change the category based on an external label' => '',
// 'Reference' => '',
// 'Reference: %s' => '',
// 'Label' => '',
);

View File

@ -505,4 +505,15 @@ return array(
// 'New password for the user "%s"' => '',
// 'Choose an event' => '',
// 'Github commit received' => '',
// 'Github issue opened' => '',
// 'Github issue closed' => '',
// 'Github issue reopened' => '',
// 'Github issue assignee change' => '',
// 'Github issue label change' => '',
// 'Create a task from an external provider' => '',
// 'Change the assignee based on an external username' => '',
// 'Change the category based on an external label' => '',
// 'Reference' => '',
// 'Reference: %s' => '',
// 'Label' => '',
);

View File

@ -505,4 +505,15 @@ return array(
// 'New password for the user "%s"' => '',
// 'Choose an event' => '',
// 'Github commit received' => '',
// 'Github issue opened' => '',
// 'Github issue closed' => '',
// 'Github issue reopened' => '',
// 'Github issue assignee change' => '',
// 'Github issue label change' => '',
// 'Create a task from an external provider' => '',
// 'Change the assignee based on an external username' => '',
// 'Change the category based on an external label' => '',
// 'Reference' => '',
// 'Reference: %s' => '',
// 'Label' => '',
);

View File

@ -505,4 +505,15 @@ return array(
// 'New password for the user "%s"' => '',
// 'Choose an event' => '',
// 'Github commit received' => '',
// 'Github issue opened' => '',
// 'Github issue closed' => '',
// 'Github issue reopened' => '',
// 'Github issue assignee change' => '',
// 'Github issue label change' => '',
// 'Create a task from an external provider' => '',
// 'Change the assignee based on an external username' => '',
// 'Change the category based on an external label' => '',
// 'Reference' => '',
// 'Reference: %s' => '',
// 'Label' => '',
);

View File

@ -36,8 +36,9 @@ class Action extends Base
*/
public function getAvailableActions()
{
return array(
$values = array(
'TaskClose' => t('Close a task'),
'TaskOpen' => t('Open a task'),
'TaskAssignSpecificUser' => t('Assign the task to a specific user'),
'TaskAssignCurrentUser' => t('Assign the task to the person who does the action'),
'TaskDuplicateAnotherProject' => t('Duplicate the task to another project'),
@ -45,7 +46,14 @@ class Action extends Base
'TaskAssignColorUser' => t('Assign a color to a specific user'),
'TaskAssignColorCategory' => t('Assign automatically a color based on a category'),
'TaskAssignCategoryColor' => t('Assign automatically a category based on a color'),
'TaskCreation' => t('Create a task from an external provider'),
'TaskAssignUser' => t('Change the assignee based on an external username'),
'TaskAssignCategoryLabel' => t('Change the category based on an external label'),
);
asort($values);
return $values;
}
/**
@ -56,7 +64,7 @@ class Action extends Base
*/
public function getAvailableEvents()
{
return array(
$values = array(
Task::EVENT_MOVE_COLUMN => t('Move a task to another column'),
Task::EVENT_UPDATE => t('Task modification'),
Task::EVENT_CREATE => t('Task creation'),
@ -65,7 +73,16 @@ class Action extends Base
Task::EVENT_CREATE_UPDATE => t('Task creation or modification'),
Task::EVENT_ASSIGNEE_CHANGE => t('Task assignee change'),
GithubWebhook::EVENT_COMMIT => t('Github commit received'),
GithubWebhook::EVENT_ISSUE_OPENED => t('Github issue opened'),
GithubWebhook::EVENT_ISSUE_CLOSED => t('Github issue closed'),
GithubWebhook::EVENT_ISSUE_REOPENED => t('Github issue reopened'),
GithubWebhook::EVENT_ISSUE_ASSIGNEE_CHANGE => t('Github issue assignee change'),
GithubWebhook::EVENT_ISSUE_LABEL_CHANGE => t('Github issue label change'),
);
asort($values);
return $values;
}
/**

View File

@ -15,11 +15,32 @@ class GithubWebhook extends Base
*
* @var string
*/
const EVENT_ISSUE_OPENED = 'github.webhook.issue.opened';
const EVENT_ISSUE_CLOSED = 'github.webhook.issue.closed';
const EVENT_ISSUE_LABELED = 'github.webhook.issue.labeled';
const EVENT_ISSUE_COMMENT = 'github.webhook.issue.commented';
const EVENT_COMMIT = 'github.webhook.commit';
const EVENT_ISSUE_OPENED = 'github.webhook.issue.opened';
const EVENT_ISSUE_CLOSED = 'github.webhook.issue.closed';
const EVENT_ISSUE_REOPENED = 'github.webhook.issue.reopened';
const EVENT_ISSUE_ASSIGNEE_CHANGE = 'github.webhook.issue.assignee';
const EVENT_ISSUE_LABEL_CHANGE = 'github.webhook.issue.label';
const EVENT_ISSUE_COMMENT = 'github.webhook.issue.commented';
const EVENT_COMMIT = 'github.webhook.commit';
/**
* Project id
*
* @access private
* @var integer
*/
private $project_id = 0;
/**
* Set the project id
*
* @access public
* @param integer $project_id Project id
*/
public function setProjectId($project_id)
{
$this->project_id = $project_id;
}
/**
* Parse Github events
@ -76,6 +97,184 @@ class GithubWebhook extends Base
*/
public function parseIssueEvent(array $payload)
{
switch ($payload['action']) {
case 'opened':
$this->handleIssueOpened($payload['issue']);
break;
case 'closed':
$this->handleIssueClosed($payload['issue']);
break;
case 'reopened':
$this->handleIssueReopened($payload['issue']);
break;
case 'assigned':
$this->handleIssueAssigned($payload['issue']);
break;
case 'unassigned':
$this->handleIssueUnassigned($payload['issue']);
break;
case 'labeled':
$this->handleIssueLabeled($payload['issue'], $payload['label']);
break;
case 'unlabeled':
$this->handleIssueUnlabeled($payload['issue'], $payload['label']);
break;
}
}
/**
* Handle new issues
*
* @access public
* @param array $issue Issue data
*/
public function handleIssueOpened(array $issue)
{
$event = array(
'project_id' => $this->project_id,
'reference' => $issue['number'],
'title' => $issue['title'],
'description' => $issue['body']."\n\n[".t('Github Issue').']('.$issue['html_url'].')',
);
$this->event->trigger(self::EVENT_ISSUE_OPENED, $event);
}
/**
* Handle issue closing
*
* @access public
* @param array $issue Issue data
*/
public function handleIssueClosed(array $issue)
{
$task = $this->task->getByReference($issue['number']);
if ($task) {
$event = array(
'project_id' => $this->project_id,
'task_id' => $task['id'],
'reference' => $issue['number'],
);
$this->event->trigger(self::EVENT_ISSUE_CLOSED, $event);
}
}
/**
* Handle issue reopened
*
* @access public
* @param array $issue Issue data
*/
public function handleIssueReopened(array $issue)
{
$task = $this->task->getByReference($issue['number']);
if ($task) {
$event = array(
'project_id' => $this->project_id,
'task_id' => $task['id'],
'reference' => $issue['number'],
);
$this->event->trigger(self::EVENT_ISSUE_REOPENED, $event);
}
}
/**
* Handle issue assignee change
*
* @access public
* @param array $issue Issue data
*/
public function handleIssueAssigned(array $issue)
{
$user = $this->user->getByUsername($issue['assignee']['login']);
$task = $this->task->getByReference($issue['number']);
if ($user && $task) {
$event = array(
'project_id' => $this->project_id,
'task_id' => $task['id'],
'owner_id' => $user['id'],
'reference' => $issue['number'],
);
$this->event->trigger(self::EVENT_ISSUE_ASSIGNEE_CHANGE, $event);
}
}
/**
* Handle unassigned issue
*
* @access public
* @param array $issue Issue data
*/
public function handleIssueUnassigned(array $issue)
{
$task = $this->task->getByReference($issue['number']);
if ($task) {
$event = array(
'project_id' => $this->project_id,
'task_id' => $task['id'],
'owner_id' => 0,
'reference' => $issue['number'],
);
$this->event->trigger(self::EVENT_ISSUE_ASSIGNEE_CHANGE, $event);
}
}
/**
* Handle labeled issue
*
* @access public
* @param array $issue Issue data
* @param array $label Label data
*/
public function handleIssueLabeled(array $issue, array $label)
{
$task = $this->task->getByReference($issue['number']);
if ($task) {
$event = array(
'project_id' => $this->project_id,
'task_id' => $task['id'],
'reference' => $issue['number'],
'label' => $label['name'],
);
$this->event->trigger(self::EVENT_ISSUE_LABEL_CHANGE, $event);
}
}
/**
* Handle unlabeled issue
*
* @access public
* @param array $issue Issue data
* @param array $label Label data
*/
public function handleIssueUnlabeled(array $issue, array $label)
{
$task = $this->task->getByReference($issue['number']);
if ($task) {
$event = array(
'project_id' => $this->project_id,
'task_id' => $task['id'],
'reference' => $issue['number'],
'label' => $label['name'],
'category_id' => 0,
);
$this->event->trigger(self::EVENT_ISSUE_LABEL_CHANGE, $event);
}
}
}

View File

@ -505,6 +505,13 @@ class Project extends Base
Task::EVENT_MOVE_COLUMN,
Task::EVENT_MOVE_POSITION,
Task::EVENT_ASSIGNEE_CHANGE,
GithubWebhook::EVENT_ISSUE_OPENED,
GithubWebhook::EVENT_ISSUE_CLOSED,
GithubWebhook::EVENT_ISSUE_REOPENED,
GithubWebhook::EVENT_ISSUE_ASSIGNEE_CHANGE,
GithubWebhook::EVENT_ISSUE_LABEL_CHANGE,
GithubWebhook::EVENT_ISSUE_COMMENT,
GithubWebhook::EVENT_COMMIT,
);
$listener = new ProjectModificationDate($this);

View File

@ -82,6 +82,7 @@ class Task extends Base
$sql = '
SELECT
tasks.id,
tasks.reference,
tasks.title,
tasks.description,
tasks.date_creation,
@ -118,7 +119,7 @@ class Task extends Base
}
/**
* Fetch one task
* Fetch a task by the id
*
* @access public
* @param integer $task_id Task id
@ -129,6 +130,18 @@ class Task extends Base
return $this->db->table(self::TABLE)->eq('id', $task_id)->findOne();
}
/**
* Fetch a task by the reference (external id)
*
* @access public
* @param string $reference Task reference
* @return array
*/
public function getByReference($reference)
{
return $this->db->table(self::TABLE)->eq('reference', $reference)->findOne();
}
/**
* Count all tasks for a given project and status
*
@ -200,6 +213,7 @@ class Task extends Base
'(SELECT count(*) FROM task_has_subtasks WHERE task_id=tasks.id) AS nb_subtasks',
'(SELECT count(*) FROM task_has_subtasks WHERE task_id=tasks.id AND status=2) AS nb_completed_subtasks',
'tasks.id',
'tasks.reference',
'tasks.title',
'tasks.description',
'tasks.date_creation',

View File

@ -4,7 +4,16 @@ namespace Schema;
use Core\Security;
const VERSION = 27;
const VERSION = 28;
function version_28($pdo)
{
$pdo->exec("ALTER TABLE tasks ADD COLUMN reference VARCHAR(50) DEFAULT ''");
$pdo->exec("ALTER TABLE comments ADD COLUMN reference VARCHAR(50) DEFAULT ''");
$pdo->exec('CREATE INDEX tasks_reference_idx ON tasks(reference)');
$pdo->exec('CREATE INDEX comments_reference_idx ON comments(reference)');
}
function version_27($pdo)
{

View File

@ -4,7 +4,16 @@ namespace Schema;
use Core\Security;
const VERSION = 8;
const VERSION = 9;
function version_9($pdo)
{
$pdo->exec("ALTER TABLE tasks ADD COLUMN reference VARCHAR(50) DEFAULT ''");
$pdo->exec("ALTER TABLE comments ADD COLUMN reference VARCHAR(50) DEFAULT ''");
$pdo->exec('CREATE INDEX tasks_reference_idx ON tasks(reference)');
$pdo->exec('CREATE INDEX comments_reference_idx ON comments(reference)');
}
function version_8($pdo)
{
@ -22,7 +31,7 @@ function version_6($pdo)
CREATE TABLE task_has_events (
id SERIAL PRIMARY KEY,
date_creation INTEGER NOT NULL,
event_name TEXT NOT NULL,
event_name VARCHAR(50) NOT NULL,
creator_id INTEGER,
project_id INTEGER,
task_id INTEGER,
@ -37,7 +46,7 @@ function version_6($pdo)
CREATE TABLE subtask_has_events (
id SERIAL PRIMARY KEY,
date_creation INTEGER NOT NULL,
event_name TEXT NOT NULL,
event_name VARCHAR(50) NOT NULL,
creator_id INTEGER,
project_id INTEGER,
subtask_id INTEGER,
@ -54,7 +63,7 @@ function version_6($pdo)
CREATE TABLE comment_has_events (
id SERIAL PRIMARY KEY,
date_creation INTEGER NOT NULL,
event_name TEXT NOT NULL,
event_name VARCHAR(50) NOT NULL,
creator_id INTEGER,
project_id INTEGER,
comment_id INTEGER,

View File

@ -4,7 +4,16 @@ namespace Schema;
use Core\Security;
const VERSION = 27;
const VERSION = 28;
function version_28($pdo)
{
$pdo->exec("ALTER TABLE tasks ADD COLUMN reference TEXT DEFAULT ''");
$pdo->exec("ALTER TABLE comments ADD COLUMN reference TEXT DEFAULT ''");
$pdo->exec('CREATE INDEX tasks_reference_idx ON tasks(reference)');
$pdo->exec('CREATE INDEX comments_reference_idx ON comments(reference)');
}
function version_27($pdo)
{

View File

@ -33,6 +33,8 @@
<?= Helper\in_list($param['value'], $colors_list) ?>
<?php elseif (Helper\contains($param['name'], 'category_id')): ?>
<?= Helper\in_list($param['value'], $categories_list) ?>
<?php elseif (Helper\contains($param['name'], 'label')): ?>
<?= Helper\escape($param['value']) ?>
<?php endif ?>
</strong>
</li>

View File

@ -26,7 +26,11 @@
<?php elseif (Helper\contains($param_name, 'category_id')): ?>
<?= Helper\form_label($param_desc, $param_name) ?>
<?= Helper\form_select('params['.$param_name.']', $categories_list, $values) ?><br/>
<?php elseif (Helper\contains($param_name, 'label')): ?>
<?= Helper\form_label($param_desc, $param_name) ?>
<?= Helper\form_text('params['.$param_name.']', $values) ?>
<?php endif ?>
<?php endforeach ?>
<div class="form-actions">

View File

@ -1,6 +1,14 @@
<?php if (isset($not_editable)): ?>
<a href="?controller=task&amp;action=readonly&amp;task_id=<?= $task['id'] ?>&amp;token=<?= $project['token'] ?>">#<?= $task['id'] ?></a> -
<a href="?controller=task&amp;action=readonly&amp;task_id=<?= $task['id'] ?>&amp;token=<?= $project['token'] ?>">#<?= $task['id'] ?></a>
<?php if ($task['reference']): ?>
<span class="task-board-reference" title="<?= t('Reference') ?>">
(<?= $task['reference'] ?>)
</span>
<?php endif ?>
&nbsp;-&nbsp;
<span class="task-board-user">
<?php if (! empty($task['owner_id'])): ?>
@ -22,7 +30,15 @@
<?php else: ?>
<a class="task-edit-popover" href="?controller=task&amp;action=edit&amp;task_id=<?= $task['id'] ?>" title="<?= t('Edit this task') ?>">#<?= $task['id'] ?></a> -
<a class="task-edit-popover" href="?controller=task&amp;action=edit&amp;task_id=<?= $task['id'] ?>" title="<?= t('Edit this task') ?>">#<?= $task['id'] ?></a>
<?php if ($task['reference']): ?>
<span class="task-board-reference" title="<?= t('Reference') ?>">
(<?= $task['reference'] ?>)
</span>
<?php endif ?>
&nbsp;-&nbsp;
<span class="task-board-user">
<a class="assignee-popover" href="?controller=board&amp;action=changeAssignee&amp;task_id=<?= $task['id'] ?>" title="<?= t('Change assignee') ?>">

View File

@ -1,6 +1,6 @@
<section id="main">
<div class="page-header">
<h2><?= t('Project "%s"', $project['name']) ?></h2>
<h2><?= t('Project "%s"', $project['name']) ?> (#<?= $project['id'] ?>)</h2>
<ul>
<li><a href="?controller=board&amp;action=show&amp;project_id=<?= $project['id'] ?>"><?= t('Back to the board') ?></a></li>
<li><a href="?controller=project"><?= t('All projects') ?></a></li>

View File

@ -4,6 +4,11 @@
<span class="task-score"><?= Helper\escape($task['score']) ?></span>
<?php endif ?>
<ul>
<?php if ($task['reference']): ?>
<li>
<strong><?= t('Reference: %s', $task['reference']) ?></strong>
</li>
<?php endif ?>
<li>
<?= dt('Created on %B %e, %Y at %k:%M %p', $task['date_creation']) ?>
</li>

View File

@ -546,3 +546,26 @@ function form_numeric($name, $values = array(), array $errors = array(), array $
{
return form_input('text', $name, $values, $errors, $attributes, $class.' form-numeric');
}
/**
* Link
*
* a('link', 'task', 'show', array('task_id' => $task_id))
*
* @param string $label Link label
* @param string $controller Controller name
* @param string $action Action name
* @param array $params Url parameters
* @param string $class CSS class attribute
* @return string
*/
function a($label, $controller, $action, array $params = array(), $css = '')
{
$html = '<a href="?controller='.$controller.'&amp;action='.$action;
foreach ($params as $key => $value) {
$html .= '&amp;'.$key.'='.$value;
}
return '" class="'.$class.'"/>'.$label.'</a>';
}