|
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\Http\Controllers\Task; |
|
13
|
|
|
|
|
14
|
|
|
use Jitamin\Filter\TaskIdExclusionFilter; |
|
15
|
|
|
use Jitamin\Filter\TaskIdFilter; |
|
16
|
|
|
use Jitamin\Filter\TaskProjectFilter; |
|
17
|
|
|
use Jitamin\Filter\TaskProjectsFilter; |
|
18
|
|
|
use Jitamin\Filter\TaskTitleFilter; |
|
19
|
|
|
use Jitamin\Formatter\TaskAutoCompleteFormatter; |
|
20
|
|
|
use Jitamin\Formatter\TaskGanttFormatter; |
|
21
|
|
|
use Jitamin\Foundation\Exceptions\AccessForbiddenException; |
|
22
|
|
|
use Jitamin\Foundation\Exceptions\PageNotFoundException; |
|
23
|
|
|
use Jitamin\Http\Controllers\Controller; |
|
24
|
|
|
use Jitamin\Model\TaskModel; |
|
25
|
|
|
use Jitamin\Model\UserMetadataModel; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Task Controller. |
|
29
|
|
|
*/ |
|
30
|
|
|
class TaskController extends Controller |
|
31
|
|
|
{ |
|
32
|
|
|
/** |
|
33
|
|
|
* Show list view for projects. |
|
34
|
|
|
*/ |
|
35
|
|
|
public function index() |
|
36
|
|
|
{ |
|
37
|
|
|
$project = $this->getProject(); |
|
38
|
|
|
$search = $this->helper->projectHeader->getSearchQuery($project); |
|
|
|
|
|
|
39
|
|
|
|
|
40
|
|
|
$paginator = $this->paginator |
|
|
|
|
|
|
41
|
|
|
->setUrl('Task/TaskController', 'index', ['project_id' => $project['id']]) |
|
42
|
|
|
->setMax(30) |
|
43
|
|
|
->setOrder(TaskModel::TABLE.'.id') |
|
44
|
|
|
->setDirection('DESC') |
|
45
|
|
|
->setQuery($this->taskLexer |
|
|
|
|
|
|
46
|
|
|
->build($search) |
|
47
|
|
|
->withFilter(new TaskProjectFilter($project['id'])) |
|
48
|
|
|
->getQuery() |
|
49
|
|
|
) |
|
50
|
|
|
->calculate(); |
|
51
|
|
|
|
|
52
|
|
|
$this->response->html($this->helper->layout->app('task/index', [ |
|
|
|
|
|
|
53
|
|
|
'project' => $project, |
|
54
|
|
|
'title' => $project['name'], |
|
55
|
|
|
'description' => $this->helper->projectHeader->getDescription($project), |
|
|
|
|
|
|
56
|
|
|
'paginator' => $paginator, |
|
57
|
|
|
])); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* Show a task. |
|
62
|
|
|
*/ |
|
63
|
|
|
public function show() |
|
64
|
|
|
{ |
|
65
|
|
|
$task = $this->getTask(); |
|
66
|
|
|
$subtasks = $this->subtaskModel->getAll($task['id']); |
|
|
|
|
|
|
67
|
|
|
$commentSortingDirection = $this->userMetadataCacheDecorator->get(UserMetadataModel::KEY_COMMENT_SORTING_DIRECTION, 'ASC'); |
|
|
|
|
|
|
68
|
|
|
|
|
69
|
|
|
$this->response->html($this->helper->layout->task('task/show', [ |
|
|
|
|
|
|
70
|
|
|
'task' => $task, |
|
71
|
|
|
'project' => $this->projectModel->getById($task['project_id']), |
|
|
|
|
|
|
72
|
|
|
'files' => $this->taskFileModel->getAllDocuments($task['id']), |
|
|
|
|
|
|
73
|
|
|
'images' => $this->taskFileModel->getAllImages($task['id']), |
|
|
|
|
|
|
74
|
|
|
'comments' => $this->commentModel->getAll($task['id'], $commentSortingDirection), |
|
|
|
|
|
|
75
|
|
|
'subtasks' => $subtasks, |
|
76
|
|
|
'internal_links' => $this->taskLinkModel->getAllGroupedByLabel($task['id']), |
|
|
|
|
|
|
77
|
|
|
'external_links' => $this->taskExternalLinkModel->getAll($task['id']), |
|
|
|
|
|
|
78
|
|
|
'link_label_list' => $this->linkModel->getList(0, false), |
|
|
|
|
|
|
79
|
|
|
'tags' => $this->taskTagModel->getList($task['id']), |
|
|
|
|
|
|
80
|
|
|
])); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* Show Gantt chart for one project. |
|
85
|
|
|
*/ |
|
86
|
|
|
public function gantt() |
|
87
|
|
|
{ |
|
88
|
|
|
$project = $this->getProject(); |
|
89
|
|
|
$search = $this->helper->projectHeader->getSearchQuery($project); |
|
|
|
|
|
|
90
|
|
|
$sorting = $this->request->getStringParam('sorting', 'board'); |
|
|
|
|
|
|
91
|
|
|
$filter = $this->taskLexer->build($search)->withFilter(new TaskProjectFilter($project['id'])); |
|
|
|
|
|
|
92
|
|
|
|
|
93
|
|
|
if ($sorting === 'date') { |
|
94
|
|
|
$filter->getQuery()->asc(TaskModel::TABLE.'.date_started')->asc(TaskModel::TABLE.'.date_creation'); |
|
95
|
|
|
} else { |
|
96
|
|
|
$filter->getQuery()->asc('column_position')->asc(TaskModel::TABLE.'.position'); |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
$this->response->html($this->helper->layout->app('task/gantt', [ |
|
|
|
|
|
|
100
|
|
|
'project' => $project, |
|
101
|
|
|
'title' => $project['name'], |
|
102
|
|
|
'description' => $this->helper->projectHeader->getDescription($project), |
|
|
|
|
|
|
103
|
|
|
'sorting' => $sorting, |
|
104
|
|
|
'tasks' => $filter->format(new TaskGanttFormatter($this->container)), |
|
105
|
|
|
])); |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
/** |
|
109
|
|
|
* Public access (display a task). |
|
110
|
|
|
*/ |
|
111
|
|
|
public function readonly() |
|
112
|
|
|
{ |
|
113
|
|
|
$project = $this->projectModel->getByToken($this->request->getStringParam('token')); |
|
|
|
|
|
|
114
|
|
|
|
|
115
|
|
|
if (empty($project)) { |
|
116
|
|
|
throw AccessForbiddenException::getInstance()->withoutLayout(); |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
$task = $this->taskFinderModel->getDetails($this->request->getIntegerParam('task_id')); |
|
|
|
|
|
|
120
|
|
|
|
|
121
|
|
|
if (empty($task)) { |
|
122
|
|
|
throw PageNotFoundException::getInstance()->withoutLayout(); |
|
123
|
|
|
} |
|
124
|
|
|
|
|
125
|
|
|
if ($task['project_id'] != $project['id']) { |
|
126
|
|
|
throw AccessForbiddenException::getInstance()->withoutLayout(); |
|
127
|
|
|
} |
|
128
|
|
|
|
|
129
|
|
|
$this->response->html($this->helper->layout->app('task/public', [ |
|
|
|
|
|
|
130
|
|
|
'project' => $project, |
|
131
|
|
|
'comments' => $this->commentModel->getAll($task['id']), |
|
|
|
|
|
|
132
|
|
|
'subtasks' => $this->subtaskModel->getAll($task['id']), |
|
|
|
|
|
|
133
|
|
|
'links' => $this->taskLinkModel->getAllGroupedByLabel($task['id']), |
|
|
|
|
|
|
134
|
|
|
'task' => $task, |
|
135
|
|
|
'columns_list' => $this->columnModel->getList($task['project_id']), |
|
|
|
|
|
|
136
|
|
|
'colors_list' => $this->colorModel->getList(), |
|
|
|
|
|
|
137
|
|
|
'tags' => $this->taskTagModel->getList($task['id']), |
|
|
|
|
|
|
138
|
|
|
'title' => $task['title'], |
|
139
|
|
|
'no_layout' => true, |
|
140
|
|
|
'auto_refresh' => true, |
|
141
|
|
|
'not_editable' => true, |
|
142
|
|
|
])); |
|
143
|
|
|
} |
|
144
|
|
|
|
|
145
|
|
|
/** |
|
146
|
|
|
* Display task analytics. |
|
147
|
|
|
*/ |
|
148
|
|
|
public function analytics() |
|
149
|
|
|
{ |
|
150
|
|
|
$task = $this->getTask(); |
|
151
|
|
|
|
|
152
|
|
|
$this->response->html($this->helper->layout->task('task/analytics', [ |
|
|
|
|
|
|
153
|
|
|
'task' => $task, |
|
154
|
|
|
'project' => $this->projectModel->getById($task['project_id']), |
|
|
|
|
|
|
155
|
|
|
'lead_time' => $this->taskAnalyticModel->getLeadTime($task), |
|
|
|
|
|
|
156
|
|
|
'cycle_time' => $this->taskAnalyticModel->getCycleTime($task), |
|
|
|
|
|
|
157
|
|
|
'time_spent_columns' => $this->taskAnalyticModel->getTimeSpentByColumn($task), |
|
|
|
|
|
|
158
|
|
|
'tags' => $this->taskTagModel->getList($task['id']), |
|
|
|
|
|
|
159
|
|
|
])); |
|
160
|
|
|
} |
|
161
|
|
|
|
|
162
|
|
|
/** |
|
163
|
|
|
* Display the time tracking details. |
|
164
|
|
|
*/ |
|
165
|
|
|
public function timetracking() |
|
166
|
|
|
{ |
|
167
|
|
|
$task = $this->getTask(); |
|
168
|
|
|
|
|
169
|
|
|
$subtask_paginator = $this->paginator |
|
|
|
|
|
|
170
|
|
|
->setUrl('Task/TaskController', 'timetracking', ['task_id' => $task['id'], 'project_id' => $task['project_id'], 'pagination' => 'subtasks']) |
|
171
|
|
|
->setMax(15) |
|
172
|
|
|
->setOrder('start') |
|
173
|
|
|
->setDirection('DESC') |
|
174
|
|
|
->setQuery($this->subtaskTimeTrackingModel->getTaskQuery($task['id'])) |
|
|
|
|
|
|
175
|
|
|
->calculateOnlyIf($this->request->getStringParam('pagination') === 'subtasks'); |
|
|
|
|
|
|
176
|
|
|
|
|
177
|
|
|
$this->response->html($this->helper->layout->task('task/time_tracking_details', [ |
|
|
|
|
|
|
178
|
|
|
'task' => $task, |
|
179
|
|
|
'project' => $this->projectModel->getById($task['project_id']), |
|
|
|
|
|
|
180
|
|
|
'subtask_paginator' => $subtask_paginator, |
|
181
|
|
|
'tags' => $this->taskTagModel->getList($task['id']), |
|
|
|
|
|
|
182
|
|
|
])); |
|
183
|
|
|
} |
|
184
|
|
|
|
|
185
|
|
|
/** |
|
186
|
|
|
* Display the task transitions. |
|
187
|
|
|
*/ |
|
188
|
|
View Code Duplication |
public function transitions() |
|
|
|
|
|
|
189
|
|
|
{ |
|
190
|
|
|
$task = $this->getTask(); |
|
191
|
|
|
|
|
192
|
|
|
$this->response->html($this->helper->layout->task('task/transitions', [ |
|
|
|
|
|
|
193
|
|
|
'task' => $task, |
|
194
|
|
|
'project' => $this->projectModel->getById($task['project_id']), |
|
|
|
|
|
|
195
|
|
|
'transitions' => $this->transitionModel->getAllByTask($task['id']), |
|
|
|
|
|
|
196
|
|
|
'tags' => $this->taskTagModel->getList($task['id']), |
|
|
|
|
|
|
197
|
|
|
])); |
|
198
|
|
|
} |
|
199
|
|
|
|
|
200
|
|
|
/** |
|
201
|
|
|
* Display a form to create a new task. |
|
202
|
|
|
* |
|
203
|
|
|
* @param array $values |
|
204
|
|
|
* @param array $errors |
|
205
|
|
|
* |
|
206
|
|
|
* @throws PageNotFoundException |
|
207
|
|
|
*/ |
|
208
|
|
|
public function create(array $values = [], array $errors = []) |
|
209
|
|
|
{ |
|
210
|
|
|
$project = $this->getProject(); |
|
211
|
|
|
$swimlanes_list = $this->swimlaneModel->getList($project['id'], false, true); |
|
|
|
|
|
|
212
|
|
|
|
|
213
|
|
|
if (empty($values)) { |
|
214
|
|
|
$values = $this->prepareValues($swimlanes_list); |
|
215
|
|
|
} |
|
216
|
|
|
|
|
217
|
|
|
$values = $this->hook->merge('controller:task:form:default', $values, ['default_values' => $values]); |
|
|
|
|
|
|
218
|
|
|
$values = $this->hook->merge('controller:task-creation:form:default', $values, ['default_values' => $values]); |
|
|
|
|
|
|
219
|
|
|
|
|
220
|
|
|
$this->response->html($this->template->render('task/create', [ |
|
|
|
|
|
|
221
|
|
|
'project' => $project, |
|
222
|
|
|
'errors' => $errors, |
|
223
|
|
|
'values' => $values + ['project_id' => $project['id']], |
|
224
|
|
|
'columns_list' => $this->columnModel->getList($project['id']), |
|
|
|
|
|
|
225
|
|
|
'users_list' => $this->projectUserRoleModel->getAssignableUsersList($project['id'], true, false, true), |
|
|
|
|
|
|
226
|
|
|
'categories_list' => $this->categoryModel->getList($project['id']), |
|
|
|
|
|
|
227
|
|
|
'swimlanes_list' => $swimlanes_list, |
|
228
|
|
|
])); |
|
229
|
|
|
} |
|
230
|
|
|
|
|
231
|
|
|
/** |
|
232
|
|
|
* Validate and store a new task. |
|
233
|
|
|
*/ |
|
234
|
|
|
public function store() |
|
235
|
|
|
{ |
|
236
|
|
|
$project = $this->getProject(); |
|
237
|
|
|
$values = $this->request->getValues(); |
|
|
|
|
|
|
238
|
|
|
|
|
239
|
|
|
list($valid, $errors) = $this->taskValidator->validateCreation($values); |
|
|
|
|
|
|
240
|
|
|
|
|
241
|
|
|
if (!$valid) { |
|
242
|
|
|
$this->flash->failure(t('Unable to create your task.')); |
|
|
|
|
|
|
243
|
|
|
$this->show($values, $errors); |
|
|
|
|
|
|
244
|
|
|
} elseif (!$this->helper->projectRole->canCreateTaskInColumn($project['id'], $values['column_id'])) { |
|
|
|
|
|
|
245
|
|
|
$this->flash->failure(t('You cannot create tasks in this column.')); |
|
|
|
|
|
|
246
|
|
|
$this->response->redirect($this->helper->url->to('Project/Board/BoardController', 'show', ['project_id' => $project['id']]), true); |
|
|
|
|
|
|
247
|
|
|
} else { |
|
248
|
|
|
$task_id = $this->taskModel->create($values); |
|
|
|
|
|
|
249
|
|
|
$this->flash->success(t('Task created successfully.')); |
|
|
|
|
|
|
250
|
|
|
$this->afterSave($project, $values, $task_id); |
|
251
|
|
|
} |
|
252
|
|
|
} |
|
253
|
|
|
|
|
254
|
|
|
/** |
|
255
|
|
|
* Set automatically the start date. |
|
256
|
|
|
*/ |
|
257
|
|
|
public function start() |
|
258
|
|
|
{ |
|
259
|
|
|
$task = $this->getTask(); |
|
260
|
|
|
$this->taskModel->update(['id' => $task['id'], 'date_started' => time()]); |
|
|
|
|
|
|
261
|
|
|
$this->response->redirect($this->helper->url->to('Task/TaskController', 'show', ['project_id' => $task['project_id'], 'task_id' => $task['id']])); |
|
|
|
|
|
|
262
|
|
|
} |
|
263
|
|
|
|
|
264
|
|
|
/** |
|
265
|
|
|
* Save new task start date and due date. |
|
266
|
|
|
*/ |
|
267
|
|
View Code Duplication |
public function set_date() |
|
|
|
|
|
|
268
|
|
|
{ |
|
269
|
|
|
$this->getProject(); |
|
270
|
|
|
$values = $this->request->getJson(); |
|
|
|
|
|
|
271
|
|
|
|
|
272
|
|
|
$result = $this->taskModel->update([ |
|
|
|
|
|
|
273
|
|
|
'id' => $values['id'], |
|
274
|
|
|
'date_started' => strtotime($values['start']), |
|
275
|
|
|
'date_due' => strtotime($values['end']), |
|
276
|
|
|
]); |
|
277
|
|
|
|
|
278
|
|
|
if (!$result) { |
|
279
|
|
|
$this->response->json(['message' => 'Unable to save task'], 400); |
|
|
|
|
|
|
280
|
|
|
} else { |
|
281
|
|
|
$this->response->json(['message' => 'OK'], 201); |
|
|
|
|
|
|
282
|
|
|
} |
|
283
|
|
|
} |
|
284
|
|
|
|
|
285
|
|
|
/** |
|
286
|
|
|
* Display a form to edit a task. |
|
287
|
|
|
* |
|
288
|
|
|
* @param array $values |
|
289
|
|
|
* @param array $errors |
|
290
|
|
|
* |
|
291
|
|
|
* @throws \Jitamin\Foundation\Exceptions\AccessForbiddenException |
|
292
|
|
|
* @throws \Jitamin\Foundation\Exceptions\PageNotFoundException |
|
293
|
|
|
*/ |
|
294
|
|
|
public function edit(array $values = [], array $errors = []) |
|
295
|
|
|
{ |
|
296
|
|
|
$task = $this->getTask(); |
|
297
|
|
|
$project = $this->projectModel->getById($task['project_id']); |
|
|
|
|
|
|
298
|
|
|
|
|
299
|
|
|
if (empty($values)) { |
|
300
|
|
|
$values = $task; |
|
301
|
|
|
} |
|
302
|
|
|
|
|
303
|
|
|
$values = $this->hook->merge('controller:task:form:default', $values, ['default_values' => $values]); |
|
|
|
|
|
|
304
|
|
|
$values = $this->hook->merge('controller:task-modification:form:default', $values, ['default_values' => $values]); |
|
|
|
|
|
|
305
|
|
|
|
|
306
|
|
|
$this->response->html($this->template->render('task/edit', [ |
|
|
|
|
|
|
307
|
|
|
'project' => $project, |
|
308
|
|
|
'values' => $values, |
|
309
|
|
|
'errors' => $errors, |
|
310
|
|
|
'task' => $task, |
|
311
|
|
|
'tags' => $this->taskTagModel->getList($task['id']), |
|
|
|
|
|
|
312
|
|
|
'users_list' => $this->projectUserRoleModel->getAssignableUsersList($task['project_id']), |
|
|
|
|
|
|
313
|
|
|
'categories_list' => $this->categoryModel->getList($task['project_id']), |
|
|
|
|
|
|
314
|
|
|
])); |
|
315
|
|
|
} |
|
316
|
|
|
|
|
317
|
|
|
/** |
|
318
|
|
|
* Validate and update a task. |
|
319
|
|
|
*/ |
|
320
|
|
View Code Duplication |
public function update() |
|
|
|
|
|
|
321
|
|
|
{ |
|
322
|
|
|
$task = $this->getTask(); |
|
323
|
|
|
$values = $this->request->getValues(); |
|
|
|
|
|
|
324
|
|
|
|
|
325
|
|
|
list($valid, $errors) = $this->taskValidator->validateModification($values); |
|
|
|
|
|
|
326
|
|
|
|
|
327
|
|
|
if ($valid && $this->taskModel->update($values)) { |
|
|
|
|
|
|
328
|
|
|
$this->flash->success(t('Task updated successfully.')); |
|
|
|
|
|
|
329
|
|
|
$this->response->redirect($this->helper->url->to('Task/TaskController', 'show', ['project_id' => $task['project_id'], 'task_id' => $task['id']]), true); |
|
|
|
|
|
|
330
|
|
|
} else { |
|
331
|
|
|
$this->flash->failure(t('Unable to update your task.')); |
|
|
|
|
|
|
332
|
|
|
$this->edit($values, $errors); |
|
333
|
|
|
} |
|
334
|
|
|
} |
|
335
|
|
|
|
|
336
|
|
|
/** |
|
337
|
|
|
* Duplicate created tasks to multiple projects. |
|
338
|
|
|
* |
|
339
|
|
|
* @throws PageNotFoundException |
|
340
|
|
|
*/ |
|
341
|
|
|
public function duplicateProjects() |
|
342
|
|
|
{ |
|
343
|
|
|
$project = $this->getProject(); |
|
344
|
|
|
$values = $this->request->getValues(); |
|
|
|
|
|
|
345
|
|
|
|
|
346
|
|
|
if (isset($values['project_ids'])) { |
|
347
|
|
|
foreach ($values['project_ids'] as $project_id) { |
|
348
|
|
|
$this->taskProjectDuplicationModel->duplicateToProject($values['task_id'], $project_id); |
|
|
|
|
|
|
349
|
|
|
} |
|
350
|
|
|
} |
|
351
|
|
|
|
|
352
|
|
|
$this->response->redirect($this->helper->url->to('Project/Board/BoardController', 'show', ['project_id' => $project['id']]), true); |
|
|
|
|
|
|
353
|
|
|
} |
|
354
|
|
|
|
|
355
|
|
|
/** |
|
356
|
|
|
* Task auto-completion (Ajax). |
|
357
|
|
|
*/ |
|
358
|
|
|
public function autocomplete() |
|
359
|
|
|
{ |
|
360
|
|
|
$search = $this->request->getStringParam('term'); |
|
|
|
|
|
|
361
|
|
|
$project_ids = $this->projectPermissionModel->getActiveProjectIds($this->userSession->getId()); |
|
|
|
|
|
|
362
|
|
|
$exclude_task_id = $this->request->getIntegerParam('exclude_task_id'); |
|
|
|
|
|
|
363
|
|
|
|
|
364
|
|
|
if (empty($project_ids)) { |
|
365
|
|
|
$this->response->json([]); |
|
|
|
|
|
|
366
|
|
|
} else { |
|
367
|
|
|
$filter = $this->taskQuery->withFilter(new TaskProjectsFilter($project_ids)); |
|
|
|
|
|
|
368
|
|
|
|
|
369
|
|
|
if (!empty($exclude_task_id)) { |
|
370
|
|
|
$filter->withFilter(new TaskIdExclusionFilter([$exclude_task_id])); |
|
371
|
|
|
} |
|
372
|
|
|
|
|
373
|
|
|
if (ctype_digit($search)) { |
|
374
|
|
|
$filter->withFilter(new TaskIdFilter($search)); |
|
375
|
|
|
} else { |
|
376
|
|
|
$filter->withFilter(new TaskTitleFilter($search)); |
|
377
|
|
|
} |
|
378
|
|
|
|
|
379
|
|
|
$this->response->json($filter->format(new TaskAutoCompleteFormatter($this->container))); |
|
|
|
|
|
|
380
|
|
|
} |
|
381
|
|
|
} |
|
382
|
|
|
|
|
383
|
|
|
/** |
|
384
|
|
|
* Executed after the task is saved. |
|
385
|
|
|
* |
|
386
|
|
|
* @param array $project |
|
387
|
|
|
* @param array $values |
|
388
|
|
|
* @param int $task_id |
|
389
|
|
|
*/ |
|
390
|
|
|
protected function afterSave(array $project, array &$values, $task_id) |
|
391
|
|
|
{ |
|
392
|
|
|
if (isset($values['duplicate_multiple_projects']) && $values['duplicate_multiple_projects'] == 1) { |
|
393
|
|
|
$this->chooseProjects($project, $task_id); |
|
394
|
|
|
} elseif (isset($values['another_task']) && $values['another_task'] == 1) { |
|
395
|
|
|
$this->create([ |
|
396
|
|
|
'owner_id' => $values['owner_id'], |
|
397
|
|
|
'color_id' => $values['color_id'], |
|
398
|
|
|
'category_id' => isset($values['category_id']) ? $values['category_id'] : 0, |
|
399
|
|
|
'column_id' => $values['column_id'], |
|
400
|
|
|
'swimlane_id' => isset($values['swimlane_id']) ? $values['swimlane_id'] : 0, |
|
401
|
|
|
'another_task' => 1, |
|
402
|
|
|
]); |
|
403
|
|
|
} else { |
|
404
|
|
|
$this->response->redirect($this->helper->url->to('Project/Board/BoardController', 'show', ['project_id' => $project['id']]), true); |
|
|
|
|
|
|
405
|
|
|
} |
|
406
|
|
|
} |
|
407
|
|
|
|
|
408
|
|
|
/** |
|
409
|
|
|
* Prepare form values. |
|
410
|
|
|
* |
|
411
|
|
|
* @param array $swimlanes_list |
|
412
|
|
|
* |
|
413
|
|
|
* @return array |
|
414
|
|
|
*/ |
|
415
|
|
|
protected function prepareValues(array $swimlanes_list) |
|
416
|
|
|
{ |
|
417
|
|
|
$values = [ |
|
418
|
|
|
'swimlane_id' => $this->request->getIntegerParam('swimlane_id', key($swimlanes_list)), |
|
|
|
|
|
|
419
|
|
|
'column_id' => $this->request->getIntegerParam('column_id'), |
|
|
|
|
|
|
420
|
|
|
'color_id' => $this->colorModel->getDefaultColor(), |
|
|
|
|
|
|
421
|
|
|
'owner_id' => $this->userSession->getId(), |
|
|
|
|
|
|
422
|
|
|
]; |
|
423
|
|
|
|
|
424
|
|
|
return $values; |
|
425
|
|
|
} |
|
426
|
|
|
|
|
427
|
|
|
/** |
|
428
|
|
|
* Choose projects. |
|
429
|
|
|
* |
|
430
|
|
|
* @param array $project |
|
431
|
|
|
* @param int $task_id |
|
432
|
|
|
*/ |
|
433
|
|
|
protected function chooseProjects(array $project, $task_id) |
|
434
|
|
|
{ |
|
435
|
|
|
$task = $this->taskFinderModel->getById($task_id); |
|
|
|
|
|
|
436
|
|
|
$projects = $this->projectUserRoleModel->getActiveProjectsByUser($this->userSession->getId()); |
|
|
|
|
|
|
437
|
|
|
unset($projects[$project['id']]); |
|
438
|
|
|
|
|
439
|
|
|
$this->response->html($this->template->render('task/duplicate_projects', [ |
|
|
|
|
|
|
440
|
|
|
'project' => $project, |
|
441
|
|
|
'task' => $task, |
|
442
|
|
|
'projects_list' => $projects, |
|
443
|
|
|
'values' => ['task_id' => $task['id']], |
|
444
|
|
|
])); |
|
445
|
|
|
} |
|
446
|
|
|
} |
|
447
|
|
|
|
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.