summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/Action/CommentCreation.php4
-rw-r--r--app/Controller/Board.php21
-rw-r--r--app/Controller/Task.php4
-rw-r--r--app/Core/Helper.php1
-rw-r--r--app/Model/ProjectPermission.php28
-rw-r--r--app/Model/TaskCreation.php8
-rw-r--r--app/Template/comment/show.php2
-rw-r--r--app/Template/project/sidebar.php2
-rw-r--r--app/Template/project/users.php6
-rw-r--r--app/Template/subtask/remove.php2
-rw-r--r--app/Template/subtask/show.php4
11 files changed, 47 insertions, 35 deletions
diff --git a/app/Action/CommentCreation.php b/app/Action/CommentCreation.php
index 27ed011b..54d7be7d 100644
--- a/app/Action/CommentCreation.php
+++ b/app/Action/CommentCreation.php
@@ -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()
{
diff --git a/app/Controller/Board.php b/app/Controller/Board.php
index 128d9215..48f2b518 100644
--- a/app/Controller/Board.php
+++ b/app/Controller/Board.php
@@ -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);
}
/**
diff --git a/app/Controller/Task.php b/app/Controller/Task.php
index 77ea60d9..773183fe 100644
--- a/app/Controller/Task.php
+++ b/app/Controller/Task.php
@@ -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.'));
diff --git a/app/Core/Helper.php b/app/Core/Helper.php
index 1db8afc6..e9fa1868 100644
--- a/app/Core/Helper.php
+++ b/app/Core/Helper.php
@@ -14,6 +14,7 @@ use Parsedown;
* @property \Core\Session $session
* @property \Model\Acl $acl
* @property \Model\User $user
+ * @property \Model\UserSession $userSession
*/
class Helper
{
diff --git a/app/Model/ProjectPermission.php b/app/Model/ProjectPermission.php
index fc7ab0d5..0249b3b1 100644
--- a/app/Model/ProjectPermission.php
+++ b/app/Model/ProjectPermission.php
@@ -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);
-
- foreach ($users as $user_id => $name) {
- if (! $this->addMember($project_to, $user_id)) { // TODO: Duplicate managers
+ $rows = $this->db
+ ->table(self::TABLE)
+ ->columns('project_id', 'user_id', 'is_owner')
+ ->eq('project_id', $project_src)
+ ->findAll();
+
+ 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;
}
}
diff --git a/app/Model/TaskCreation.php b/app/Model/TaskCreation.php
index e99bf6d2..17e5ff70 100644
--- a/app/Model/TaskCreation.php
+++ b/app/Model/TaskCreation.php
@@ -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'];
diff --git a/app/Template/comment/show.php b/app/Template/comment/show.php
index 2cf9708b..23389c06 100644
--- a/app/Template/comment/show.php
+++ b/app/Template/comment/show.php
@@ -39,7 +39,7 @@
'controller' => 'task',
'action' => 'show',
'params' => array(
- 'project_id' => $project['id']
+ 'project_id' => $task['project_id']
)
)
) ?>
diff --git a/app/Template/project/sidebar.php b/app/Template/project/sidebar.php
index 991a1c73..f28f6b0d 100644
--- a/app/Template/project/sidebar.php
+++ b/app/Template/project/sidebar.php
@@ -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>
diff --git a/app/Template/project/users.php b/app/Template/project/users.php
index 5dc4a7e5..f223b8fa 100644
--- a/app/Template/project/users.php
+++ b/app/Template/project/users.php
@@ -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>
diff --git a/app/Template/subtask/remove.php b/app/Template/subtask/remove.php
index af193c59..c623791d 100644
--- a/app/Template/subtask/remove.php
+++ b/app/Template/subtask/remove.php
@@ -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>
diff --git a/app/Template/subtask/show.php b/app/Template/subtask/show.php
index c0f61f0e..265883b7 100644
--- a/app/Template/subtask/show.php
+++ b/app/Template/subtask/show.php
@@ -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>