summaryrefslogtreecommitdiff
path: root/app/Controller/ProjectActionDuplicationController.php
blob: a4993cca5dbc4e9ac07d6d311f2ec23580eae5e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php

namespace Kanboard\Controller;

/**
 * Duplicate automatic action from another project
 *
 * @package Kanboard\Controller
 * @author  Frederic Guillot
 */
class ProjectActionDuplicationController extends BaseController
{
    public function show()
    {
        $project = $this->getProject();
        $projects = $this->projectUserRoleModel->getProjectsByUser($this->userSession->getId());
        unset($projects[$project['id']]);

        $this->response->html($this->template->render('project_action_duplication/show', array(
            'project' => $project,
            'projects_list' => $projects,
        )));
    }

    public function save()
    {
        $project = $this->getProject();
        $src_project_id = $this->request->getValue('src_project_id');

        if ($this->actionModel->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('ActionController', 'index', array('project_id' => $project['id'])));
    }
}