1 | <?php |
||
29 | class ProjectController extends Controller |
||
30 | { |
||
31 | /** |
||
32 | * Display activity for a project. |
||
33 | * |
||
34 | * @param Project $project |
||
35 | * |
||
36 | * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View |
||
37 | */ |
||
38 | public function getIndex(Project $project) |
||
39 | { |
||
40 | $activities = $project->getRecentActivities($this->getLoggedUser()); |
||
41 | |||
42 | return $this->indexView([ |
||
43 | 'activities' => $activities, |
||
44 | 'notes_count' => $project->countNotes(), |
||
45 | 'open_issues_count' => $project->countOpenIssues($this->getLoggedUser()), |
||
46 | 'closed_issues_count' => $project->countClosedIssues($this->getLoggedUser()), |
||
47 | ], 'activity', $project); |
||
48 | } |
||
49 | |||
50 | /** |
||
51 | * Display issues for a project. |
||
52 | * |
||
53 | * @param FilterForm $filterForm |
||
54 | * @param Request $request |
||
55 | * @param Project $project |
||
56 | * @param int $status |
||
57 | * |
||
58 | * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View |
||
59 | */ |
||
60 | public function getIssues(FilterForm $filterForm, Request $request, Project $project, $status = Issue::STATUS_OPEN) |
||
61 | { |
||
62 | if ($status === Issue::STATUS_OPEN) { |
||
63 | return $this->getOpenIssues($filterForm, $request, $project); |
||
64 | } |
||
65 | |||
66 | return $this->getClosedIssues($filterForm, $request, $project); |
||
67 | } |
||
68 | |||
69 | /** |
||
70 | * Display open issues. |
||
71 | * |
||
72 | * @param FilterForm $filterForm |
||
73 | * @param Request $request |
||
74 | * @param Project $project |
||
75 | * |
||
76 | * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View |
||
77 | */ |
||
78 | public function getOpenIssues(FilterForm $filterForm, Request $request, Project $project) |
||
79 | { |
||
80 | $issues = $project->getIssuesForLoggedUser(Issue::STATUS_OPEN, $request->all()); |
||
81 | |||
82 | return $this->indexView([ |
||
83 | 'notes_count' => $project->countNotes(), |
||
84 | 'issues' => $issues, |
||
85 | 'filterForm' => $filterForm, |
||
86 | 'open_issues_count' => $issues->count(), |
||
87 | 'closed_issues_count' => $project->countClosedIssues($this->getLoggedUser()), |
||
88 | ], 'open_issues', $project); |
||
89 | } |
||
90 | |||
91 | /** |
||
92 | * Display closed issues. |
||
93 | * |
||
94 | * @param FilterForm $filterForm |
||
95 | * @param Request $request |
||
96 | * @param Project $project |
||
97 | * |
||
98 | * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View |
||
99 | */ |
||
100 | public function getClosedIssues(FilterForm $filterForm, Request $request, Project $project) |
||
101 | { |
||
102 | $issues = $project->getIssuesForLoggedUser(Issue::STATUS_CLOSED, $request->all()); |
||
103 | |||
104 | return $this->indexView([ |
||
105 | 'notes_count' => $project->countNotes(), |
||
106 | 'issues' => $issues, |
||
107 | 'filterForm' => $filterForm, |
||
108 | 'open_issues_count' => $project->countOpenIssues($this->getLoggedUser()), |
||
109 | 'closed_issues_count' => $issues->count(), |
||
110 | ], 'closed_issues', $project); |
||
111 | } |
||
112 | |||
113 | /** |
||
114 | * Display issues assigned to current user for a project. |
||
115 | * |
||
116 | * @param Project $project |
||
117 | * |
||
118 | * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View |
||
119 | */ |
||
120 | public function getAssigned(Project $project) |
||
121 | { |
||
122 | $issues = $project->getAssignedOrCreatedIssues($this->getLoggedUser()); |
||
123 | |||
124 | return $this->indexView([ |
||
125 | 'notes_count' => $project->countNotes(), |
||
126 | 'open_issues_count' => $project->countOpenIssues($this->getLoggedUser()), |
||
127 | 'closed_issues_count' => $project->countClosedIssues($this->getLoggedUser()), |
||
128 | 'assigned_issues_count' => $issues->count(), |
||
129 | 'issues' => $issues, |
||
130 | ], 'activity', $project); |
||
131 | } |
||
132 | |||
133 | /** |
||
134 | * Display issues created to current user for a project. |
||
135 | * |
||
136 | * @param Project $project |
||
137 | * |
||
138 | * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View |
||
139 | */ |
||
140 | public function getCreated(Project $project) |
||
141 | { |
||
142 | $issues = $project->getAssignedOrCreatedIssues($this->getLoggedUser()); |
||
143 | |||
144 | return $this->indexView([ |
||
145 | 'notes_count' => $project->countNotes(), |
||
146 | 'open_issues_count' => $project->countOpenIssues($this->getLoggedUser()), |
||
147 | 'closed_issues_count' => $project->countClosedIssues($this->getLoggedUser()), |
||
148 | 'assigned_issues_count' => $issues->count(), |
||
149 | 'issues' => $issues, |
||
150 | ], 'issue_created_by_you', $project); |
||
151 | } |
||
152 | |||
153 | /** |
||
154 | * Display notes for a project. |
||
155 | * |
||
156 | * @param Project $project |
||
157 | * @param NoteForm $form |
||
158 | * |
||
159 | * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View |
||
160 | */ |
||
161 | public function getNotes(Project $project, NoteForm $form) |
||
162 | { |
||
163 | $notes = $project->getNotes(); |
||
164 | |||
165 | return $this->indexView([ |
||
166 | 'notes_count' => $project->countNotes(), |
||
167 | 'open_issues_count' => $project->countOpenIssues($this->getLoggedUser()), |
||
168 | 'closed_issues_count' => $project->countClosedIssues($this->getLoggedUser()), |
||
169 | 'notes' => $notes, |
||
170 | 'notes_count' => $notes->count(), |
||
171 | 'noteForm' => $form, |
||
172 | ], 'notes', $project); |
||
173 | } |
||
174 | |||
175 | /** |
||
176 | * @param mixed $data |
||
177 | * @param string $active |
||
178 | * @param Project $project |
||
179 | * |
||
180 | * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View |
||
181 | */ |
||
182 | protected function indexView($data, $active, Project $project) |
||
198 | |||
199 | /** |
||
200 | * Edit the project. |
||
201 | * |
||
202 | * @param Project $project |
||
203 | * @param Form $form |
||
204 | * |
||
205 | * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View |
||
206 | */ |
||
207 | public function getEdit(Project $project, Form $form) |
||
215 | |||
216 | /** |
||
217 | * To update project details. |
||
218 | * |
||
219 | * @param Project $project |
||
220 | * @param FormRequest\Project $request |
||
221 | * |
||
222 | * @return \Illuminate\Http\RedirectResponse |
||
223 | */ |
||
224 | public function postEdit(Project $project, FormRequest\Project $request) |
||
239 | |||
240 | /** |
||
241 | * Ajax: returns list of users that are not in the project. |
||
242 | * |
||
243 | * @param Project $project |
||
244 | * |
||
245 | * @return \Symfony\Component\HttpFoundation\Response |
||
246 | */ |
||
247 | public function getInactiveUsers(Project $project) |
||
253 | |||
254 | /** |
||
255 | * Ajax: add user to the project. |
||
256 | * |
||
257 | * @param Project $project |
||
258 | * @param Request $request |
||
259 | * |
||
260 | * @return \Symfony\Component\HttpFoundation\Response |
||
261 | */ |
||
262 | public function postAssign(Project $project, Request $request) |
||
268 | |||
269 | /** |
||
270 | * Ajax: remove user from the project. |
||
271 | * |
||
272 | * @param Project $project |
||
273 | * @param Request $request |
||
274 | * |
||
275 | * @return \Symfony\Component\HttpFoundation\Response |
||
276 | */ |
||
277 | public function postUnassign(Project $project, Request $request) |
||
283 | |||
284 | /** |
||
285 | * To add a new note to the project. |
||
286 | * |
||
287 | * @param Project $project |
||
288 | * @param Note $note |
||
289 | * @param FormRequest\Note $request |
||
290 | * |
||
291 | * @return \Illuminate\Http\RedirectResponse |
||
292 | */ |
||
293 | public function postAddNote(Project $project, Note $note, FormRequest\Note $request) |
||
294 | { |
||
295 | $note->setRelation('project', $project); |
||
296 | $note->setRelation('createdBy', $this->getLoggedUser()); |
||
297 | $note->updater($this->getLoggedUser())->create($request->all()); |
||
298 | |||
299 | return redirect($note->to())->with('notice', trans('tinyissue.your_note_added')); |
||
300 | } |
||
301 | |||
302 | /** |
||
303 | * Ajax: To update project note. |
||
304 | * |
||
305 | * @param Project $project |
||
306 | * @param Note $note |
||
307 | * @param Request $request |
||
308 | * |
||
309 | * @return \Symfony\Component\HttpFoundation\Response |
||
310 | */ |
||
311 | public function postEditNote(Project $project, Note $note, Request $request) |
||
312 | { |
||
313 | $body = ''; |
||
314 | if ($request->has('body')) { |
||
315 | $note->setRelation('project', $project); |
||
316 | $note->updater($this->getLoggedUser())->updateBody((string)$request->input('body')); |
||
317 | |||
318 | $body = \Html::format($note->body); |
||
319 | } |
||
320 | |||
321 | return response()->json(['status' => true, 'text' => $body]); |
||
322 | } |
||
323 | |||
324 | /** |
||
325 | * Ajax: to delete a project note. |
||
326 | * |
||
327 | * @param Project $project |
||
328 | * @param Note $note |
||
329 | * |
||
330 | * @return \Symfony\Component\HttpFoundation\Response |
||
331 | */ |
||
332 | public function getDeleteNote(Project $project, Note $note) |
||
339 | |||
340 | /** |
||
341 | * Ajax: generate the issues export file. |
||
342 | * |
||
343 | * @param Project $project |
||
344 | * @param Exporter $exporter |
||
345 | * @param Request $request |
||
346 | * |
||
347 | * @return \Symfony\Component\HttpFoundation\Response |
||
348 | */ |
||
349 | public function postExportIssues(Project $project, Exporter $exporter, Request $request) |
||
372 | |||
373 | /** |
||
374 | * Download and then delete an export file. |
||
375 | * |
||
376 | * @param Project $project |
||
377 | * @param string $file |
||
378 | * |
||
379 | * @return \Symfony\Component\HttpFoundation\BinaryFileResponse |
||
380 | */ |
||
381 | public function getDownloadExport(Project $project, $file) |
||
391 | } |
||
392 |
This check looks at variables that are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.