summaryrefslogtreecommitdiff
path: root/app/Model/ProjectTaskDuplicationModel.php
blob: 5d2e1322cb3d567d00c446399b72a73868e21878 (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
<?php

namespace Kanboard\Model;

use Kanboard\Core\Base;

/**
 * Project Task Duplication Model
 *
 * @package  Kanboard\Model
 * @author   Frederic Guillot
 */
class ProjectTaskDuplicationModel extends Base
{
    /**
     * Duplicate all tasks to another project
     *
     * @access public
     * @param  integer $src_project_id
     * @param  integer $dst_project_id
     * @return boolean
     */
    public function duplicate($src_project_id, $dst_project_id)
    {
        $task_ids = $this->taskFinderModel->getAllIds($src_project_id, array(TaskModel::STATUS_OPEN, TaskModel::STATUS_CLOSED));

        foreach ($task_ids as $task_id) {
            if (! $this->taskProjectDuplicationModel->duplicateToProject($task_id, $dst_project_id)) {
                return false;
            }
        }

        return true;
    }
}