summaryrefslogtreecommitdiff
path: root/app/Helper
diff options
context:
space:
mode:
Diffstat (limited to 'app/Helper')
-rw-r--r--app/Helper/CalendarHelper.php126
-rw-r--r--app/Helper/ICalHelper.php37
-rw-r--r--app/Helper/ProjectHeaderHelper.php4
-rw-r--r--app/Helper/ProjectRoleHelper.php180
-rw-r--r--app/Helper/SubtaskHelper.php46
-rw-r--r--app/Helper/TaskHelper.php107
-rw-r--r--app/Helper/TextHelper.php12
7 files changed, 251 insertions, 261 deletions
diff --git a/app/Helper/CalendarHelper.php b/app/Helper/CalendarHelper.php
deleted file mode 100644
index 0942177d..00000000
--- a/app/Helper/CalendarHelper.php
+++ /dev/null
@@ -1,126 +0,0 @@
-<?php
-
-namespace Kanboard\Helper;
-
-use Kanboard\Core\Base;
-use Kanboard\Core\Filter\QueryBuilder;
-use Kanboard\Filter\TaskDueDateRangeFilter;
-
-/**
- * Calendar Helper
- *
- * @package helper
- * @author Frederic Guillot
- */
-class CalendarHelper extends Base
-{
- /**
- * Render calendar component
- *
- * @param string $checkUrl
- * @param string $saveUrl
- * @return string
- */
- public function render($checkUrl, $saveUrl)
- {
- $params = array(
- 'checkUrl' => $checkUrl,
- 'saveUrl' => $saveUrl,
- );
-
- return '<div class="js-calendar" data-params=\''.json_encode($params, JSON_HEX_APOS).'\'></div>';
- }
-
- /**
- * Get formatted calendar task due events
- *
- * @access public
- * @param QueryBuilder $queryBuilder
- * @param string $start
- * @param string $end
- * @return array
- */
- public function getTaskDateDueEvents(QueryBuilder $queryBuilder, $start, $end)
- {
- $formatter = $this->taskCalendarFormatter;
- $formatter->setFullDay();
- $formatter->setColumns('date_due');
-
- return $queryBuilder
- ->withFilter(new TaskDueDateRangeFilter(array($start, $end)))
- ->format($formatter);
- }
-
- /**
- * Get formatted calendar task events
- *
- * @access public
- * @param QueryBuilder $queryBuilder
- * @param string $start
- * @param string $end
- * @return array
- */
- public function getTaskEvents(QueryBuilder $queryBuilder, $start, $end)
- {
- $startColumn = $this->configModel->get('calendar_project_tasks', 'date_started');
-
- $queryBuilder->getQuery()->addCondition($this->getCalendarCondition(
- $this->dateParser->getTimestampFromIsoFormat($start),
- $this->dateParser->getTimestampFromIsoFormat($end),
- $startColumn,
- 'date_due'
- ));
-
- $formatter = $this->taskCalendarFormatter;
- $formatter->setColumns($startColumn, 'date_due');
-
- return $queryBuilder->format($formatter);
- }
-
- /**
- * Get formatted calendar subtask time tracking events
- *
- * @access public
- * @param integer $user_id
- * @param string $start
- * @param string $end
- * @return array
- */
- public function getSubtaskTimeTrackingEvents($user_id, $start, $end)
- {
- return $this->subtaskTimeTrackingCalendarFormatter
- ->withQuery($this->subtaskTimeTrackingModel->getUserQuery($user_id)
- ->addCondition($this->getCalendarCondition(
- $this->dateParser->getTimestampFromIsoFormat($start),
- $this->dateParser->getTimestampFromIsoFormat($end),
- 'start',
- 'end'
- ))
- )
- ->format();
- }
-
- /**
- * Build SQL condition for a given time range
- *
- * @access public
- * @param string $start_time Start timestamp
- * @param string $end_time End timestamp
- * @param string $start_column Start column name
- * @param string $end_column End column name
- * @return string
- */
- public function getCalendarCondition($start_time, $end_time, $start_column, $end_column)
- {
- $start_column = $this->db->escapeIdentifier($start_column);
- $end_column = $this->db->escapeIdentifier($end_column);
-
- $conditions = array(
- "($start_column >= '$start_time' AND $start_column <= '$end_time')",
- "($start_column <= '$start_time' AND $end_column >= '$start_time')",
- "($start_column <= '$start_time' AND ($end_column = '0' OR $end_column IS NULL))",
- );
-
- return $start_column.' IS NOT NULL AND '.$start_column.' > 0 AND ('.implode(' OR ', $conditions).')';
- }
-}
diff --git a/app/Helper/ICalHelper.php b/app/Helper/ICalHelper.php
deleted file mode 100644
index 95723417..00000000
--- a/app/Helper/ICalHelper.php
+++ /dev/null
@@ -1,37 +0,0 @@
-<?php
-
-namespace Kanboard\Helper;
-
-use Kanboard\Core\Base;
-use Kanboard\Core\Filter\QueryBuilder;
-use Kanboard\Filter\TaskDueDateRangeFilter;
-use Eluceo\iCal\Component\Calendar as iCalendar;
-
-/**
- * ICal Helper
- *
- * @package helper
- * @author Frederic Guillot
- */
-class ICalHelper extends Base
-{
- /**
- * Get formatted calendar task due events
- *
- * @access public
- * @param QueryBuilder $queryBuilder
- * @param iCalendar $calendar
- * @param string $start
- * @param string $end
- */
- public function addTaskDateDueEvents(QueryBuilder $queryBuilder, iCalendar $calendar, $start, $end)
- {
- $queryBuilder->withFilter(new TaskDueDateRangeFilter(array($start, $end)));
-
- $this->taskICalFormatter
- ->setColumns('date_due')
- ->setCalendar($calendar)
- ->withQuery($queryBuilder->getQuery())
- ->addFullDayEvents();
- }
-}
diff --git a/app/Helper/ProjectHeaderHelper.php b/app/Helper/ProjectHeaderHelper.php
index 9514f4f2..e4f96107 100644
--- a/app/Helper/ProjectHeaderHelper.php
+++ b/app/Helper/ProjectHeaderHelper.php
@@ -34,15 +34,17 @@ class ProjectHeaderHelper extends Base
* @param string $controller
* @param string $action
* @param bool $boardView
+ * @param string $plugin
* @return string
*/
- public function render(array $project, $controller, $action, $boardView = false)
+ public function render(array $project, $controller, $action, $boardView = false, $plugin = '')
{
$filters = array(
'controller' => $controller,
'action' => $action,
'project_id' => $project['id'],
'search' => $this->getSearchQuery($project),
+ 'plugin' => $plugin,
);
return $this->template->render('project_header/header', array(
diff --git a/app/Helper/ProjectRoleHelper.php b/app/Helper/ProjectRoleHelper.php
index 6f9cf10c..a9f0596a 100644
--- a/app/Helper/ProjectRoleHelper.php
+++ b/app/Helper/ProjectRoleHelper.php
@@ -19,12 +19,12 @@ class ProjectRoleHelper extends Base
* Get project role for the current user
*
* @access public
- * @param integer $project_id
+ * @param integer $projectId
* @return string
*/
- public function getProjectUserRole($project_id)
+ public function getProjectUserRole($projectId)
{
- return $this->memoryCache->proxy($this->projectUserRoleModel, 'getUserRole', $project_id, $this->userSession->getId());
+ return $this->memoryCache->proxy($this->projectUserRoleModel, 'getUserRole', $projectId, $this->userSession->getId());
}
/**
@@ -36,7 +36,7 @@ class ProjectRoleHelper extends Base
public function isDraggable(array &$task)
{
if ($task['is_active'] == 1 && $this->helper->user->hasProjectAccess('BoardAjaxController', 'save', $task['project_id'])) {
- return $this->isSortableColumn($task['project_id'], $task['column_id']);
+ return $this->isSortableColumn($task['project_id'], $task['column_id'], $task['owner_id']);
}
return false;
@@ -45,24 +45,29 @@ class ProjectRoleHelper extends Base
/**
* Return true is the column is sortable
*
- * @param int $project_id
- * @param int $column_id
+ * @param int $projectId
+ * @param int $columnId
+ * @param int $assigneeId
* @return bool
*/
- public function isSortableColumn($project_id, $column_id)
+ public function isSortableColumn($projectId, $columnId, $assigneeId = null)
{
- $role = $this->getProjectUserRole($project_id);
+ $role = $this->getProjectUserRole($projectId);
if ($this->role->isCustomProjectRole($role)) {
- $sortableColumns = $this->columnMoveRestrictionCacheDecorator->getSortableColumns($project_id, $role);
+ $sortableColumns = $this->columnMoveRestrictionCacheDecorator->getSortableColumns($projectId, $role);
foreach ($sortableColumns as $column) {
- if ($column['src_column_id'] == $column_id || $column['dst_column_id'] == $column_id) {
+ if ($column['src_column_id'] == $columnId || $column['dst_column_id'] == $columnId) {
+ if ($column['only_assigned'] == 1 && $assigneeId !== null && $assigneeId != $this->userSession->getId()) {
+ return false;
+ }
+
return true;
}
}
- return empty($sortableColumns) && $this->isAllowedToMoveTask($project_id, $role);
+ return empty($sortableColumns) && $this->isAllowedToMoveTask($projectId, $role);
}
return true;
@@ -71,33 +76,33 @@ class ProjectRoleHelper extends Base
/**
* Check if the user can move a task
*
- * @param int $project_id
- * @param int $src_column_id
- * @param int $dst_column_id
+ * @param int $projectId
+ * @param int $srcColumnId
+ * @param int $dstColumnId
* @return bool|int
*/
- public function canMoveTask($project_id, $src_column_id, $dst_column_id)
+ public function canMoveTask($projectId, $srcColumnId, $dstColumnId)
{
- $role = $this->getProjectUserRole($project_id);
+ $role = $this->getProjectUserRole($projectId);
if ($this->role->isCustomProjectRole($role)) {
- if ($src_column_id == $dst_column_id) {
+ if ($srcColumnId == $dstColumnId) {
return true;
}
- $sortableColumns = $this->columnMoveRestrictionCacheDecorator->getSortableColumns($project_id, $role);
+ $sortableColumns = $this->columnMoveRestrictionCacheDecorator->getSortableColumns($projectId, $role);
foreach ($sortableColumns as $column) {
- if ($column['src_column_id'] == $src_column_id && $column['dst_column_id'] == $dst_column_id) {
+ if ($column['src_column_id'] == $srcColumnId && $column['dst_column_id'] == $dstColumnId) {
return true;
}
- if ($column['dst_column_id'] == $src_column_id && $column['src_column_id'] == $dst_column_id) {
+ if ($column['dst_column_id'] == $srcColumnId && $column['src_column_id'] == $dstColumnId) {
return true;
}
}
- return empty($sortableColumns) && $this->isAllowedToMoveTask($project_id, $role);
+ return empty($sortableColumns) && $this->isAllowedToMoveTask($projectId, $role);
}
return true;
@@ -106,41 +111,41 @@ class ProjectRoleHelper extends Base
/**
* Return true if the user can create a task for the given column
*
- * @param int $project_id
- * @param int $column_id
+ * @param int $projectId
+ * @param int $columnId
* @return bool
*/
- public function canCreateTaskInColumn($project_id, $column_id)
+ public function canCreateTaskInColumn($projectId, $columnId)
{
- $role = $this->getProjectUserRole($project_id);
+ $role = $this->getProjectUserRole($projectId);
if ($this->role->isCustomProjectRole($role)) {
- if (! $this->isAllowedToCreateTask($project_id, $column_id, $role)) {
+ if (! $this->isAllowedToCreateTask($projectId, $columnId, $role)) {
return false;
}
}
- return $this->helper->user->hasProjectAccess('TaskCreationController', 'show', $project_id);
+ return $this->helper->user->hasProjectAccess('TaskCreationController', 'show', $projectId);
}
/**
* Return true if the user can create a task for the given column
*
- * @param int $project_id
- * @param int $column_id
+ * @param int $projectId
+ * @param int $columnId
* @return bool
*/
- public function canChangeTaskStatusInColumn($project_id, $column_id)
+ public function canChangeTaskStatusInColumn($projectId, $columnId)
{
- $role = $this->getProjectUserRole($project_id);
+ $role = $this->getProjectUserRole($projectId);
if ($this->role->isCustomProjectRole($role)) {
- if (! $this->isAllowedToChangeTaskStatus($project_id, $column_id, $role)) {
+ if (! $this->isAllowedToChangeTaskStatus($projectId, $columnId, $role)) {
return false;
}
}
- return $this->helper->user->hasProjectAccess('TaskStatusController', 'close', $project_id);
+ return $this->helper->user->hasProjectAccess('TaskStatusController', 'close', $projectId);
}
/**
@@ -154,6 +159,12 @@ class ProjectRoleHelper extends Base
*/
public function canRemoveTask(array $task)
{
+ $role = $this->getProjectUserRole($task['project_id']);
+
+ if ($this->hasRestriction($task['project_id'], $role, ProjectRoleRestrictionModel::RULE_TASK_SUPPRESSION)) {
+ return false;
+ }
+
if (isset($task['creator_id']) && $task['creator_id'] == $this->userSession->getId()) {
return true;
}
@@ -166,14 +177,50 @@ class ProjectRoleHelper extends Base
}
/**
+ * Return true if the user can change assignee
+ *
+ * @public
+ * @param array $task
+ * @return bool
+ */
+ public function canChangeAssignee(array $task)
+ {
+ $role = $this->getProjectUserRole($task['project_id']);
+
+ if ($this->role->isCustomProjectRole($role) && $this->hasRestriction($task['project_id'], $role, ProjectRoleRestrictionModel::RULE_TASK_CHANGE_ASSIGNEE)) {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Return true if the user can update a task
+ *
+ * @public
+ * @param array $task
+ * @return bool
+ */
+ public function canUpdateTask(array $task)
+ {
+ $role = $this->getProjectUserRole($task['project_id']);
+
+ if ($this->role->isCustomProjectRole($role) && $task['owner_id'] != $this->userSession->getId() && $this->hasRestriction($task['project_id'], $role, ProjectRoleRestrictionModel::RULE_TASK_UPDATE_ASSIGNED)) {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
* Check project access
*
* @param string $controller
* @param string $action
- * @param integer $project_id
+ * @param integer $projectId
* @return bool
*/
- public function checkProjectAccess($controller, $action, $project_id)
+ public function checkProjectAccess($controller, $action, $projectId)
{
if (! $this->userSession->isLogged()) {
return false;
@@ -187,7 +234,7 @@ class ProjectRoleHelper extends Base
return false;
}
- $role = $this->getProjectUserRole($project_id);
+ $role = $this->getProjectUserRole($projectId);
if ($this->role->isCustomProjectRole($role)) {
$result = $this->projectAuthorization->isAllowed($controller, $action, Role::PROJECT_MEMBER);
@@ -201,17 +248,17 @@ class ProjectRoleHelper extends Base
/**
* Check authorization for a custom project role to change the task status
*
- * @param int $project_id
- * @param int $column_id
+ * @param int $projectId
+ * @param int $columnId
* @param string $role
* @return bool
*/
- protected function isAllowedToChangeTaskStatus($project_id, $column_id, $role)
+ protected function isAllowedToChangeTaskStatus($projectId, $columnId, $role)
{
- $columnRestrictions = $this->columnRestrictionCacheDecorator->getAllByRole($project_id, $role);
+ $columnRestrictions = $this->columnRestrictionCacheDecorator->getAllByRole($projectId, $role);
foreach ($columnRestrictions as $restriction) {
- if ($restriction['column_id'] == $column_id) {
+ if ($restriction['column_id'] == $columnId) {
if ($restriction['rule'] == ColumnRestrictionModel::RULE_ALLOW_TASK_OPEN_CLOSE) {
return true;
} else if ($restriction['rule'] == ColumnRestrictionModel::RULE_BLOCK_TASK_OPEN_CLOSE) {
@@ -220,31 +267,23 @@ class ProjectRoleHelper extends Base
}
}
- $projectRestrictions = $this->projectRoleRestrictionCacheDecorator->getAllByRole($project_id, $role);
-
- foreach ($projectRestrictions as $restriction) {
- if ($restriction['rule'] == ProjectRoleRestrictionModel::RULE_TASK_OPEN_CLOSE) {
- return false;
- }
- }
-
- return true;
+ return ! $this->hasRestriction($projectId, $role, ProjectRoleRestrictionModel::RULE_TASK_OPEN_CLOSE);
}
/**
* Check authorization for a custom project role to create a task
*
- * @param int $project_id
- * @param int $column_id
+ * @param int $projectId
+ * @param int $columnId
* @param string $role
* @return bool
*/
- protected function isAllowedToCreateTask($project_id, $column_id, $role)
+ protected function isAllowedToCreateTask($projectId, $columnId, $role)
{
- $columnRestrictions = $this->columnRestrictionCacheDecorator->getAllByRole($project_id, $role);
+ $columnRestrictions = $this->columnRestrictionCacheDecorator->getAllByRole($projectId, $role);
foreach ($columnRestrictions as $restriction) {
- if ($restriction['column_id'] == $column_id) {
+ if ($restriction['column_id'] == $columnId) {
if ($restriction['rule'] == ColumnRestrictionModel::RULE_ALLOW_TASK_CREATION) {
return true;
} else if ($restriction['rule'] == ColumnRestrictionModel::RULE_BLOCK_TASK_CREATION) {
@@ -253,10 +292,22 @@ class ProjectRoleHelper extends Base
}
}
- $projectRestrictions = $this->projectRoleRestrictionCacheDecorator->getAllByRole($project_id, $role);
+ return ! $this->hasRestriction($projectId, $role, ProjectRoleRestrictionModel::RULE_TASK_CREATION);
+ }
+
+ /**
+ * Check if the role can move task in the given project
+ *
+ * @param int $projectId
+ * @param string $role
+ * @return bool
+ */
+ protected function isAllowedToMoveTask($projectId, $role)
+ {
+ $projectRestrictions = $this->projectRoleRestrictionCacheDecorator->getAllByRole($projectId, $role);
foreach ($projectRestrictions as $restriction) {
- if ($restriction['rule'] == ProjectRoleRestrictionModel::RULE_TASK_CREATION) {
+ if ($restriction['rule'] == ProjectRoleRestrictionModel::RULE_TASK_MOVE) {
return false;
}
}
@@ -265,22 +316,23 @@ class ProjectRoleHelper extends Base
}
/**
- * Check if the role can move task in the given project
+ * Check if given role has a restriction
*
- * @param int $project_id
+ * @param integer $projectId
* @param string $role
+ * @param string $rule
* @return bool
*/
- protected function isAllowedToMoveTask($project_id, $role)
+ protected function hasRestriction($projectId, $role, $rule)
{
- $projectRestrictions = $this->projectRoleRestrictionCacheDecorator->getAllByRole($project_id, $role);
+ $projectRestrictions = $this->projectRoleRestrictionCacheDecorator->getAllByRole($projectId, $role);
foreach ($projectRestrictions as $restriction) {
- if ($restriction['rule'] == ProjectRoleRestrictionModel::RULE_TASK_MOVE) {
- return false;
+ if ($restriction['rule'] == $rule) {
+ return true;
}
}
- return true;
+ return false;
}
}
diff --git a/app/Helper/SubtaskHelper.php b/app/Helper/SubtaskHelper.php
index eea1ed63..67875a63 100644
--- a/app/Helper/SubtaskHelper.php
+++ b/app/Helper/SubtaskHelper.php
@@ -3,6 +3,7 @@
namespace Kanboard\Helper;
use Kanboard\Core\Base;
+use Kanboard\Model\SubtaskModel;
/**
* Subtask helpers
@@ -45,26 +46,30 @@ class SubtaskHelper extends Base
* Get the link to toggle subtask status
*
* @access public
- * @param array $task
- * @param array $subtask
+ * @param array $task
+ * @param array $subtask
+ * @param string $fragment
+ * @param int $userId
* @return string
*/
- public function renderToggleStatus(array $task, array $subtask)
+ public function renderToggleStatus(array $task, array $subtask, $fragment = '', $userId = 0)
{
if (! $this->helper->user->hasProjectAccess('SubtaskController', 'edit', $task['project_id'])) {
$html = $this->renderTitle($subtask);
} else {
$title = $this->renderTitle($subtask);
$params = array(
- 'project_id' => $task['project_id'],
- 'task_id' => $subtask['task_id'],
- 'subtask_id' => $subtask['id'],
+ 'project_id' => $task['project_id'],
+ 'task_id' => $subtask['task_id'],
+ 'subtask_id' => $subtask['id'],
+ 'user_id' => $userId,
+ 'fragment' => $fragment,
);
if ($subtask['status'] == 0 && $this->hasSubtaskInProgress()) {
- $html = $this->helper->url->link($title, 'SubtaskRestrictionController', 'show', $params, false, 'js-modal-confirm');
+ $html = $this->helper->url->link($title, 'SubtaskRestrictionController', 'show', $params, false, 'js-modal-confirm', $this->getSubtaskTooltip($subtask));
} else {
- $html = $this->helper->url->link($title, 'SubtaskStatusController', 'change', $params, false, 'js-subtask-toggle-status');
+ $html = $this->helper->url->link($title, 'SubtaskStatusController', 'change', $params, false, 'js-subtask-toggle-status', $this->getSubtaskTooltip($subtask));
}
}
@@ -87,6 +92,17 @@ class SubtaskHelper extends Base
return $html;
}
+ public function renderBulkTitleField(array $values, array $errors = array(), array $attributes = array())
+ {
+ $attributes = array_merge(array('tabindex="1"', 'required'), $attributes);
+
+ $html = $this->helper->form->label(t('Title'), 'title');
+ $html .= $this->helper->form->textarea('title', $values, $errors, $attributes);
+ $html .= '<p class="form-help">'.t('Enter one subtask by line.').'</p>';
+
+ return $html;
+ }
+
public function renderTitleField(array $values, array $errors = array(), array $attributes = array())
{
$attributes = array_merge(array('tabindex="1"', 'required', 'maxlength="255"'), $attributes);
@@ -132,4 +148,18 @@ class SubtaskHelper extends Base
return $html;
}
+
+ public function getSubtaskTooltip(array $subtask)
+ {
+ switch ($subtask['status']) {
+ case SubtaskModel::STATUS_TODO:
+ return t('Subtask not started');
+ case SubtaskModel::STATUS_INPROGRESS:
+ return t('Subtask currently in progress');
+ case SubtaskModel::STATUS_DONE:
+ return t('Subtask completed');
+ }
+
+ return '';
+ }
}
diff --git a/app/Helper/TaskHelper.php b/app/Helper/TaskHelper.php
index 69520c03..cc164ce0 100644
--- a/app/Helper/TaskHelper.php
+++ b/app/Helper/TaskHelper.php
@@ -61,6 +61,30 @@ class TaskHelper extends Base
return $this->helper->form->textEditor('description', $values, $errors, array('tabindex' => 2));
}
+ public function renderDescriptionTemplateDropdown($projectId)
+ {
+ $templates = $this->predefinedTaskDescriptionModel->getAll($projectId);
+
+ if (! empty($templates)) {
+ $html = '<div class="dropdown dropdown-smaller">';
+ $html .= '<a href="#" class="dropdown-menu dropdown-menu-link-icon"><i class="fa fa-floppy-o fa-fw" aria-hidden="true"></i>'.t('Template for the task description').' <i class="fa fa-caret-down" aria-hidden="true"></i></a>';
+ $html .= '<ul>';
+
+ foreach ($templates as $template) {
+ $html .= '<li>';
+ $html .= '<a href="#" data-template-target="textarea[name=description]" data-template="'.$this->helper->text->e($template['description']).'" class="js-template">';
+ $html .= $this->helper->text->e($template['title']);
+ $html .= '</a>';
+ $html .= '</li>';
+ }
+
+ $html .= '</ul></div>';
+ return $html;
+ }
+
+ return '';
+ }
+
public function renderTagField(array $project, array $tags = array())
{
$options = $this->tagModel->getAssignableList($project['id']);
@@ -93,6 +117,10 @@ class TaskHelper extends Base
public function renderAssigneeField(array $users, array $values, array $errors = array(), array $attributes = array())
{
+ if (isset($values['project_id']) && ! $this->helper->projectRole->canChangeAssignee($values)) {
+ return '';
+ }
+
$attributes = array_merge(array('tabindex="3"'), $attributes);
$html = $this->helper->form->label(t('Assignee'), 'owner_id');
@@ -204,7 +232,7 @@ class TaskHelper extends Base
public function renderDueDateField(array $values, array $errors = array(), array $attributes = array())
{
$attributes = array_merge(array('tabindex="9"'), $attributes);
- return $this->helper->form->date(t('Due Date'), 'date_due', $values, $errors, $attributes);
+ return $this->helper->form->datetime(t('Due Date'), 'date_due', $values, $errors, $attributes);
}
public function renderPriority($priority)
@@ -216,6 +244,21 @@ class TaskHelper extends Base
return $html;
}
+ public function renderReference(array $task)
+ {
+ if (! empty($task['reference'])) {
+ $reference = $this->helper->text->e($task['reference']);
+
+ if (filter_var($task['reference'], FILTER_VALIDATE_URL) !== false) {
+ return sprintf('<a href="%s" target=_blank">%s</a>', $reference, $reference);
+ }
+
+ return $reference;
+ }
+
+ return '';
+ }
+
public function getProgress($task)
{
if (! isset($this->columns[$task['project_id']])) {
@@ -225,31 +268,57 @@ class TaskHelper extends Base
return $this->taskModel->getProgress($task, $this->columns[$task['project_id']]);
}
- public function getNewTaskDropdown($projectId, $swimlaneId, $columnId)
+ public function getNewBoardTaskButton(array $swimlane, array $column)
{
- $providers = $this->externalTaskManager->getProvidersList();
+ $html = '<div class="board-add-icon">';
+ $providers = $this->externalTaskManager->getProviders();
if (empty($providers)) {
- return '';
- }
-
- $html = '<small class="pull-right"><div class="dropdown">';
- $html .= '<a href="#" class="dropdown-menu"><i class="fa fa-cloud-download" aria-hidden="true"></i> <i class="fa fa-caret-down"></i></a><ul>';
-
- foreach ($providers as $providerName) {
- $link = $this->helper->url->link(
- t('New External Task: %s', $providerName),
- 'ExternalTaskCreationController',
- 'step1',
- array('project_id' => $projectId, 'swimlane_id' => $swimlaneId, 'column_id' => $columnId, 'provider_name' => $providerName),
- false,
- 'js-modal-replace'
+ $html .= $this->helper->modal->largeIcon(
+ 'plus',
+ t('Add a new task'),
+ 'TaskCreationController',
+ 'show', array(
+ 'project_id' => $column['project_id'],
+ 'column_id' => $column['id'],
+ 'swimlane_id' => $swimlane['id'],
+ )
);
+ } else {
+ $html .= '<div class="dropdown">';
+ $html .= '<a href="#" class="dropdown-menu"><i class="fa fa-plus" aria-hidden="true"></i></a><ul>';
+
+ $link = $this->helper->modal->large(
+ 'plus',
+ t('Add a new Kanboard task'),
+ 'TaskCreationController',
+ 'show', array(
+ 'project_id' => $column['project_id'],
+ 'column_id' => $column['id'],
+ 'swimlane_id' => $swimlane['id'],
+ )
+ );
+
+ $html .= '<li>'.$link.'</li>';
+
+ foreach ($providers as $provider) {
+ $link = $this->helper->url->link(
+ $provider->getMenuAddLabel(),
+ 'ExternalTaskCreationController',
+ 'step1',
+ array('project_id' => $column['project_id'], 'swimlane_id' => $swimlane['id'], 'column_id' => $column['id'], 'provider_name' => $provider->getName()),
+ false,
+ 'js-modal-large'
+ );
- $html .= '<li><i class="fa fa-fw fa-plus-square" aria-hidden="true"></i> '.$link.'</li>';
+ $html .= '<li>'.$provider->getIcon().' '.$link.'</li>';
+ }
+
+ $html .= '</ul></div>';
}
- $html .= '</ul></div></small>';
+ $html .= '</div>';
+
return $html;
}
}
diff --git a/app/Helper/TextHelper.php b/app/Helper/TextHelper.php
index 89c1a8f3..698bef6d 100644
--- a/app/Helper/TextHelper.php
+++ b/app/Helper/TextHelper.php
@@ -90,19 +90,19 @@ class TextHelper extends Base
*/
public function phpToBytes($val)
{
- $val = trim($val);
- $last = strtolower($val[strlen($val)-1]);
+ $size = (int) substr($val, 0, -1);
+ $last = strtolower(substr($val, -1));
switch ($last) {
case 'g':
- $val *= 1024;
+ $size *= 1024;
case 'm':
- $val *= 1024;
+ $size *= 1024;
case 'k':
- $val *= 1024;
+ $size *= 1024;
}
- return $val;
+ return $size;
}
/**