From 1e169ae16c68c28b4626a731366a658f6ddfd3a3 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sat, 5 Mar 2016 13:39:55 -0500 Subject: Import automatic actions from another project --- app/Controller/ActionProject.php | 38 ++++++++++++++++++++++++++ app/ServiceProvider/AuthenticationProvider.php | 1 + app/Template/action/index.php | 6 ++++ app/Template/action_project/project.php | 22 +++++++++++++++ 4 files changed, 67 insertions(+) create mode 100644 app/Controller/ActionProject.php create mode 100644 app/Template/action_project/project.php (limited to 'app') 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 @@ +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 @@ 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 @@ +
+ + +

+ +
+ + form->csrf() ?> + + form->label(t('Create from another project'), 'src_project_id') ?> + form->select('src_project_id', $projects_list) ?> + +
+ + + url->link(t('cancel'), 'Action', 'index', array(), false, 'close-popover') ?> +
+
+ +
\ No newline at end of file -- cgit v1.2.3