|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the Tinyissue package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Mohamed Alsharaf <[email protected]> |
|
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 Tinyissue\Http\Controllers; |
|
13
|
|
|
|
|
14
|
|
|
use Tinyissue\Form\UserSetting as Form; |
|
15
|
|
|
use Tinyissue\Form\UserMessagesSettings as MessagesForm; |
|
16
|
|
|
use Tinyissue\Http\Requests\FormRequest; |
|
17
|
|
|
use Tinyissue\Model\Project; |
|
18
|
|
|
use Tinyissue\Model\User; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* UserController is the controller class for managing request related to logged in user account. |
|
22
|
|
|
* |
|
23
|
|
|
* @author Mohamed Alsharaf <[email protected]> |
|
24
|
|
|
*/ |
|
25
|
|
|
class UserController extends Controller |
|
26
|
|
|
{ |
|
27
|
|
|
/** |
|
28
|
|
|
* Edit the user's settings. |
|
29
|
|
|
* |
|
30
|
|
|
* @param Form $form |
|
31
|
|
|
* |
|
32
|
|
|
* @return \Illuminate\View\View |
|
33
|
|
|
*/ |
|
34
|
4 |
|
public function getSettings(Form $form) |
|
35
|
|
|
{ |
|
36
|
4 |
|
return view('user.settings', [ |
|
|
|
|
|
|
37
|
4 |
|
'form' => $form, |
|
38
|
4 |
|
'projects' => $this->auth->user()->projects()->get(), |
|
|
|
|
|
|
39
|
4 |
|
]); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* To update user settings. |
|
44
|
|
|
* |
|
45
|
|
|
* @param FormRequest\UserSetting $request |
|
46
|
|
|
* |
|
47
|
|
|
* @return \Illuminate\Http\RedirectResponse |
|
48
|
|
|
*/ |
|
49
|
3 |
|
public function postSettings(FormRequest\UserSetting $request) |
|
50
|
|
|
{ |
|
51
|
3 |
|
$this->auth->user()->updateSetting($request->all()); |
|
|
|
|
|
|
52
|
|
|
|
|
53
|
3 |
|
return redirect('user/settings')->with('notice', trans('tinyissue.settings_updated')); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* Shows the user's assigned issues. |
|
58
|
|
|
* |
|
59
|
|
|
* @param string $display |
|
60
|
|
|
* @param Project $project |
|
61
|
|
|
* |
|
62
|
|
|
* @return \Illuminate\View\View |
|
63
|
|
|
*/ |
|
64
|
2 |
|
public function getIssues($display = 'list', Project $project = null) |
|
65
|
|
|
{ |
|
66
|
2 |
|
$view = $display === 'kanban' ? 'kanban' : 'list'; |
|
67
|
2 |
|
$data = []; |
|
68
|
|
|
|
|
69
|
2 |
|
if ($display === 'kanban') { |
|
70
|
1 |
|
$data['columns'] = []; |
|
71
|
1 |
|
$data['issues'] = []; |
|
72
|
1 |
|
if ($project->id) { |
|
73
|
1 |
|
$data['columns'] = $project->getKanbanTagsForUser(auth()->user()); |
|
|
|
|
|
|
74
|
1 |
|
$ids = $data['columns']->lists('id')->all(); |
|
75
|
1 |
|
$data['issues'] = $this->auth->user()->issuesGroupByTags($ids, $project->id); |
|
|
|
|
|
|
76
|
1 |
|
} |
|
77
|
|
|
|
|
78
|
1 |
|
$data['project'] = $project; |
|
79
|
1 |
|
$data['projects'] = $this->auth->user()->projects()->get(); |
|
|
|
|
|
|
80
|
1 |
|
} else { |
|
81
|
1 |
|
$data['projects'] = $this->auth->user()->projectsWidthIssues(Project::STATUS_OPEN)->get(); |
|
|
|
|
|
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
2 |
|
return view('user.issues-' . $view, $data); |
|
|
|
|
|
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* Edit the user's message settings. |
|
89
|
|
|
* |
|
90
|
|
|
* @param MessagesForm $form |
|
91
|
|
|
* |
|
92
|
|
|
* @return \Illuminate\View\View |
|
93
|
|
|
*/ |
|
94
|
1 |
|
public function getMessagesSettings(MessagesForm $form) |
|
95
|
|
|
{ |
|
96
|
1 |
|
$projects = $this->auth->user()->projects()->with('projectUsers')->get(); |
|
|
|
|
|
|
97
|
1 |
|
$form->setProjects($projects); |
|
98
|
|
|
|
|
99
|
1 |
|
return view('user.messages-settings', [ |
|
|
|
|
|
|
100
|
1 |
|
'form' => $form, |
|
101
|
1 |
|
'projects' => $projects, |
|
102
|
1 |
|
]); |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
/** |
|
106
|
|
|
* To update user settings. |
|
107
|
|
|
* |
|
108
|
|
|
* @param FormRequest\UserMessagesSettings $request |
|
109
|
|
|
* |
|
110
|
|
|
* @return \Illuminate\Http\RedirectResponse |
|
111
|
|
|
*/ |
|
112
|
1 |
|
public function postMessagesSettings(FormRequest\UserMessagesSettings $request) |
|
113
|
|
|
{ |
|
114
|
1 |
|
$this->auth->user()->updateMessagesSettings($request->input('projects', [])); |
|
|
|
|
|
|
115
|
|
|
|
|
116
|
1 |
|
return redirect('user/settings/messages')->with('notice', trans('tinyissue.messages_settings_updated')); |
|
117
|
|
|
} |
|
118
|
|
|
} |
|
119
|
|
|
|