|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of Jitamin. |
|
5
|
|
|
* |
|
6
|
|
|
* Copyright (C) Jitamin Team |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Jitamin\Model; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Task Project Duplication. |
|
16
|
|
|
*/ |
|
17
|
|
|
class TaskProjectDuplicationModel extends TaskDuplicationModel |
|
18
|
|
|
{ |
|
19
|
|
|
/** |
|
20
|
|
|
* Duplicate a task to another project. |
|
21
|
|
|
* |
|
22
|
|
|
* @param int $task_id |
|
23
|
|
|
* @param int $project_id |
|
24
|
|
|
* @param int $swimlane_id |
|
25
|
|
|
* @param int $column_id |
|
26
|
|
|
* @param int $category_id |
|
27
|
|
|
* @param int $owner_id |
|
28
|
|
|
* |
|
29
|
|
|
* @return bool|int |
|
30
|
|
|
*/ |
|
31
|
|
|
public function duplicateToProject($task_id, $project_id, $swimlane_id = null, $column_id = null, $category_id = null, $owner_id = null) |
|
32
|
|
|
{ |
|
33
|
|
|
$values = $this->prepare($task_id, $project_id, $swimlane_id, $column_id, $category_id, $owner_id); |
|
34
|
|
|
$this->checkDestinationProjectValues($values); |
|
35
|
|
|
$new_task_id = $this->save($task_id, $values); |
|
36
|
|
|
|
|
37
|
|
|
if ($new_task_id !== false) { |
|
38
|
|
|
$this->tagDuplicationModel->duplicateTaskTagsToAnotherProject($task_id, $new_task_id, $project_id); |
|
|
|
|
|
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
return $new_task_id; |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* Prepare values before duplication. |
|
46
|
|
|
* |
|
47
|
|
|
* @param int $task_id |
|
48
|
|
|
* @param int $project_id |
|
49
|
|
|
* @param int $swimlane_id |
|
50
|
|
|
* @param int $column_id |
|
51
|
|
|
* @param int $category_id |
|
52
|
|
|
* @param int $owner_id |
|
53
|
|
|
* |
|
54
|
|
|
* @return array |
|
55
|
|
|
*/ |
|
56
|
|
|
protected function prepare($task_id, $project_id, $swimlane_id, $column_id, $category_id, $owner_id) |
|
57
|
|
|
{ |
|
58
|
|
|
$values = $this->copyFields($task_id); |
|
59
|
|
|
$values['project_id'] = $project_id; |
|
60
|
|
|
$values['column_id'] = $column_id !== null ? $column_id : $values['column_id']; |
|
61
|
|
|
$values['swimlane_id'] = $swimlane_id !== null ? $swimlane_id : $values['swimlane_id']; |
|
62
|
|
|
$values['category_id'] = $category_id !== null ? $category_id : $values['category_id']; |
|
63
|
|
|
$values['owner_id'] = $owner_id !== null ? $owner_id : $values['owner_id']; |
|
64
|
|
|
|
|
65
|
|
|
return $values; |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
|
Since your code implements the magic getter
_get, this function will be called for any read access on an undefined variable. You can add the@propertyannotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.