Various fixes and improvements

This commit is contained in:
Frédéric Guillot
2015-01-02 21:11:19 -05:00
parent 3076ba22dd
commit 45c95d74fc
15 changed files with 100 additions and 46 deletions

View File

@@ -16,7 +16,7 @@ class CommentCreation extends Base
* Get the list of compatible events
*
* @access public
* @return array
* @return string[]
*/
public function getCompatibleEvents()
{
@@ -29,7 +29,7 @@ class CommentCreation extends Base
* Get the required parameter for the action (defined by the user)
*
* @access public
* @return array
* @return string[]
*/
public function getActionRequiredParameters()
{

View File

@@ -198,11 +198,10 @@ class Board extends Base
*
* @access public
*/
public function edit()
public function edit(array $values = array(), array $errors = array())
{
$project = $this->getProject();
$columns = $this->board->getColumns($project['id']);
$values = array();
foreach ($columns as $column) {
$values['title['.$column['id'].']'] = $column['title'];
@@ -210,7 +209,7 @@ class Board extends Base
}
$this->response->html($this->projectLayout('board/edit', array(
'errors' => array(),
'errors' => $errors,
'values' => $values + array('project_id' => $project['id']),
'columns' => $columns,
'project' => $project,
@@ -249,13 +248,7 @@ class Board extends Base
}
}
$this->response->html($this->projectLayout('board/edit', array(
'errors' => $errors,
'values' => $values + array('project_id' => $project['id']),
'columns' => $columns,
'project' => $project,
'title' => t('Edit board')
)));
$this->edit($values, $errors);
}
/**
@@ -287,13 +280,7 @@ class Board extends Base
}
}
$this->response->html($this->projectLayout('board/edit', array(
'errors' => $errors,
'values' => $values + $data,
'columns' => $columns,
'project' => $project,
'title' => t('Edit board')
)));
$this->edit($values, $errors);
}
/**

View File

@@ -438,7 +438,7 @@ class Task extends Base
if ($this->taskDuplication->moveToProject($task['id'], $values['project_id'])) {
$this->session->flash(t('Task updated successfully.'));
$this->response->redirect('?controller=task&action=show&task_id='.$task['id'].'&project_id='.$task['project_id']);
$this->response->redirect('?controller=task&action=show&task_id='.$task['id'].'&project_id='.$values['project_id']);
}
else {
$this->session->flashError(t('Unable to update your task.'));
@@ -477,7 +477,7 @@ class Task extends Base
$task_id = $this->taskDuplication->duplicateToProject($task['id'], $values['project_id']);
if ($task_id) {
$this->session->flash(t('Task created successfully.'));
$this->response->redirect('?controller=task&action=show&task_id='.$task_id.'&project_id='.$task['project_id']);
$this->response->redirect('?controller=task&action=show&task_id='.$task_id.'&project_id='.$values['project_id']);
}
else {
$this->session->flashError(t('Unable to create your task.'));

View File

@@ -14,6 +14,7 @@ use Parsedown;
* @property \Core\Session $session
* @property \Model\Acl $acl
* @property \Model\User $user
* @property \Model\UserSession $userSession
*/
class Helper
{

View File

@@ -324,17 +324,29 @@ class ProjectPermission extends Base
/**
* Copy user access from a project to another one
*
* @author Antonio Rabelo
* @param integer $project_from Project Template
* @return integer $project_to Project that receives the copy
* @param integer $project_src Project Template
* @return integer $project_dst Project that receives the copy
* @return boolean
*/
public function duplicate($project_from, $project_to)
public function duplicate($project_src, $project_dst)
{
$users = $this->getMembers($project_from);
$rows = $this->db
->table(self::TABLE)
->columns('project_id', 'user_id', 'is_owner')
->eq('project_id', $project_src)
->findAll();
foreach ($users as $user_id => $name) {
if (! $this->addMember($project_to, $user_id)) { // TODO: Duplicate managers
foreach ($rows as $row) {
$result = $this->db
->table(self::TABLE)
->save(array(
'project_id' => $project_dst,
'user_id' => $row['user_id'],
'is_owner' => (int) $row['is_owner'], // (int) for postgres
));
if (! $result) {
return false;
}
}

View File

@@ -21,6 +21,10 @@ class TaskCreation extends Base
*/
public function create(array $values)
{
if (! $this->project->exists($values['project_id'])) {
return 0;
}
$this->prepare($values);
$task_id = $this->persist(Task::TABLE, $values);
@@ -51,6 +55,10 @@ class TaskCreation extends Base
$values['color_id'] = $this->color->getDefaultColor();
}
if (empty($values['title'])) {
$values['title'] = t('Untitled');
}
$values['swimlane_id'] = empty($values['swimlane_id']) ? 0 : $values['swimlane_id'];
$values['date_creation'] = time();
$values['date_modification'] = $values['date_creation'];

View File

@@ -39,7 +39,7 @@
'controller' => 'task',
'action' => 'show',
'params' => array(
'project_id' => $project['id']
'project_id' => $task['project_id']
)
)
) ?>

View File

@@ -24,7 +24,7 @@
<li>
<?= $this->a(t('Swimlanes'), 'swimlane', 'index', array('project_id' => $project['id'])) ?>
</li>
<?php if ($project['is_private'] == 0): ?>
<?php if ($this->userSession->isAdmin() || $project['is_private'] == 0): ?>
<li>
<?= $this->a(t('User management'), 'project', 'users', array('project_id' => $project['id'])) ?>
</li>

View File

@@ -13,12 +13,15 @@
<tr>
<th><?= t('User') ?></th>
<th><?= t('Role for this project') ?></th>
<th><?= t('Actions') ?></th>
<?php if ($project['is_private'] == 0): ?>
<th><?= t('Actions') ?></th>
<?php endif ?>
</tr>
<?php foreach ($users['allowed'] as $user_id => $username): ?>
<tr>
<td><?= $this->e($username) ?></td>
<td><?= isset($users['managers'][$user_id]) ? t('Project manager') : t('Project member') ?></td>
<?php if ($project['is_private'] == 0): ?>
<td>
<ul>
<li><?= $this->a(t('Revoke'), 'project', 'revoke', array('project_id' => $project['id'], 'user_id' => $user_id), true) ?></li>
@@ -31,6 +34,7 @@
</li>
</ul>
</td>
<?php endif ?>
</tr>
<?php endforeach ?>
</table>

View File

@@ -10,7 +10,7 @@
<p><strong><?= $this->e($subtask['title']) ?></strong></p>
<div class="form-actions">
<?= $this->a(t('Yes'), 'subtask', 'remove', array('task_id' => $task['id'], 'subtask_id' => $subtask['id']), true, 'btn btn-red') ?>
<?= $this->a(t('Yes'), 'subtask', 'remove', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'subtask_id' => $subtask['id']), true, 'btn btn-red') ?>
<?= t('or') ?>
<?= $this->a(t('cancel'), 'task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>
</div>

View File

@@ -44,10 +44,10 @@
<td>
<ul>
<li>
<?= $this->a(t('Edit'), 'subtask', 'edit', array('task_id' => $task['id'], 'subtask_id' => $subtask['id'])) ?>
<?= $this->a(t('Edit'), 'subtask', 'edit', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'subtask_id' => $subtask['id'])) ?>
</li>
<li>
<?= $this->a(t('Remove'), 'subtask', 'confirm', array('task_id' => $task['id'], 'subtask_id' => $subtask['id'])) ?>
<?= $this->a(t('Remove'), 'subtask', 'confirm', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'subtask_id' => $subtask['id'])) ?>
</li>
</ul>
</td>