summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-03-05 13:39:55 -0500
committerFrederic Guillot <fred@kanboard.net>2016-03-05 13:39:55 -0500
commit1e169ae16c68c28b4626a731366a658f6ddfd3a3 (patch)
tree7ecd01f4b1ae8e282447f0fee4ae050a88d27791 /app
parent9983e1422b6a473bf8be0b56773140a3886a239a (diff)
Import automatic actions from another project
Diffstat (limited to 'app')
-rw-r--r--app/Controller/ActionProject.php38
-rw-r--r--app/ServiceProvider/AuthenticationProvider.php1
-rw-r--r--app/Template/action/index.php6
-rw-r--r--app/Template/action_project/project.php22
4 files changed, 67 insertions, 0 deletions
diff --git a/app/Controller/ActionProject.php b/app/Controller/ActionProject.php
new file mode 100644
index 00000000..6de0fe58
--- /dev/null
+++ b/app/Controller/ActionProject.php
@@ -0,0 +1,38 @@
+<?php
+
+namespace Kanboard\Controller;
+
+/**
+ * Duplicate automatic action from another project
+ *
+ * @package controller
+ * @author Frederic Guillot
+ */
+class ActionProject extends Base
+{
+ public function project()
+ {
+ $project = $this->getProject();
+ $projects = $this->projectUserRole->getProjectsByUser($this->userSession->getId());
+ unset($projects[$project['id']]);
+
+ $this->response->html($this->helper->layout->project('action_project/project', array(
+ 'project' => $project,
+ 'projects_list' => $projects,
+ )));
+ }
+
+ public function save()
+ {
+ $project = $this->getProject();
+ $src_project_id = $this->request->getValue('src_project_id');
+
+ if ($this->action->duplicate($src_project_id, $project['id'])) {
+ $this->flash->success(t('Actions duplicated successfully.'));
+ } else {
+ $this->flash->failure(t('Unable to duplicate actions.'));
+ }
+
+ $this->response->redirect($this->helper->url->to('Action', 'index', array('project_id' => $project['id'])));
+ }
+}
diff --git a/app/ServiceProvider/AuthenticationProvider.php b/app/ServiceProvider/AuthenticationProvider.php
index 700fe05b..6d55a1e1 100644
--- a/app/ServiceProvider/AuthenticationProvider.php
+++ b/app/ServiceProvider/AuthenticationProvider.php
@@ -67,6 +67,7 @@ class AuthenticationProvider implements ServiceProviderInterface
$acl->setRoleHierarchy(Role::PROJECT_MEMBER, array(Role::PROJECT_VIEWER));
$acl->add('Action', '*', Role::PROJECT_MANAGER);
+ $acl->add('ActionProject', '*', Role::PROJECT_MANAGER);
$acl->add('Analytic', '*', Role::PROJECT_MANAGER);
$acl->add('Board', 'save', Role::PROJECT_MEMBER);
$acl->add('BoardPopover', '*', Role::PROJECT_MEMBER);
diff --git a/app/Template/action/index.php b/app/Template/action/index.php
index 6e9c16a5..1cc14782 100644
--- a/app/Template/action/index.php
+++ b/app/Template/action/index.php
@@ -1,5 +1,11 @@
<div class="page-header">
<h2><?= t('Automatic actions for the project "%s"', $project['name']) ?></h2>
+ <ul>
+ <li>
+ <i class="fa fa-plus fa-fw"></i>
+ <?= $this->url->link(t('Import from another project'), 'ActionProject', 'project', array('project_id' => $project['id']), false, 'popover') ?>
+ </li>
+ </ul>
</div>
<?php if (! empty($actions)): ?>
diff --git a/app/Template/action_project/project.php b/app/Template/action_project/project.php
new file mode 100644
index 00000000..d056239b
--- /dev/null
+++ b/app/Template/action_project/project.php
@@ -0,0 +1,22 @@
+<section id="main">
+ <div class="page-header">
+ <h2><?= t('Import actions from another project') ?></h2>
+ </div>
+ <?php if (empty($projects_list)): ?>
+ <p class="alert"><?= t('There is no available project.') ?></p>
+ <?php else: ?>
+ <form class="popover-form" method="post" action="<?= $this->url->href('ActionProject', 'save', array('project_id' => $project['id'])) ?>" autocomplete="off">
+
+ <?= $this->form->csrf() ?>
+
+ <?= $this->form->label(t('Create from another project'), 'src_project_id') ?>
+ <?= $this->form->select('src_project_id', $projects_list) ?>
+
+ <div class="form-actions">
+ <button type="submit" class="btn btn-blue"><?= t('Save') ?></button>
+ <?= t('or') ?>
+ <?= $this->url->link(t('cancel'), 'Action', 'index', array(), false, 'close-popover') ?>
+ </div>
+ </form>
+ <?php endif ?>
+</section> \ No newline at end of file