PluginProbe
ShiftController Employee Shift Scheduling / 4.9.60
ShiftController Employee Shift Scheduling v4.9.60
4.9.97 4.9.96 4.9.95 4.9.74 4.9.75 4.9.76 4.9.77 4.9.78 4.9.84 4.9.85 4.9.87 4.9.91 4.9.92 trunk 2.1.0 2.1.1 2.1.2 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 3.2.4 All 38 releases
shiftcontroller / sh4 / users / html / user / view / profile / roles.php

roles.php in ShiftController Employee Shift Scheduling 4.9.60, at sh4/users/html/user/view/profile/roles.php

214 lines 4.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php if (! defined('ABSPATH')) exit; // Exit if accessed directly
2 #[AllowDynamicProperties]
3 class SH4_Users_Html_User_View_Profile_Roles
4 {
5 public function __construct(
6 HC3_Hooks $hooks,
7 HC3_Ui $ui,
8 HC3_Ui_Layout1 $layout,
9
10 HC3_Auth $auth,
11 HC3_IPermission $permission,
12
13 SH4_Calendars_Presenter $calendarsPresenter,
14 SH4_Employees_Presenter $employeesPresenter,
15 SH4_App_Query $appQuery
16 )
17 {
18 $this->self = $hooks->wrap($this);
19
20 $this->ui = $ui;
21 $this->layout = $layout;
22
23 $this->auth = $hooks->wrap( $auth );
24 $this->permission = $hooks->wrap($permission);
25 $this->calendarsPresenter = $hooks->wrap( $calendarsPresenter );
26 $this->employeesPresenter = $hooks->wrap( $employeesPresenter );
27
28 $this->appQuery = $hooks->wrap( $appQuery );
29 }
30
31 public function render()
32 {
33 $user = $this->auth->getCurrentUser();
34
35 $out = array();
36
37 $roleAdmin = $this->self->renderAdmin();
38 if( $roleAdmin )
39 $out[] = $roleAdmin;
40
41 $roleManager = $this->self->renderManager();
42 if( $roleManager ){
43 $out[] = $roleManager;
44 }
45
46 $roleViewer = $this->self->renderViewer();
47 if( $roleViewer ){
48 $out[] = $roleViewer;
49 }
50
51 $roleEmployee = $this->self->renderEmployee();
52 if( $roleEmployee ){
53 $out[] = $roleEmployee;
54 }
55
56 if( ! $out ){
57 $out[] = '__You have no roles at the moment__';
58 }
59
60 $out = $this->ui->makeList( $out );
61
62 $this->layout
63 ->setContent( $out )
64 ->setBreadcrumb( $this->self->breadcrumb() )
65 ->setHeader( $this->self->header() )
66 ;
67
68 $out = $this->layout->render();
69 return $out;
70 }
71
72 public function renderAdmin()
73 {
74 $out = NULL;
75
76 $user = $this->auth->getCurrentUser();
77 if( ! $this->permission->isAdmin( $user ) ){
78 return $out;
79 }
80
81 $out = array();
82
83 $label = '__Admin__';
84 $label = $this->ui->makeBlock( $label )
85 ->tag('font-size', 4)
86 ;
87 $out[] = $label;
88
89 $out = $this->ui->makeList( $out )->gutter(1);
90 $out = $this->ui->makeBlock( $out )
91 ->tag('border')
92 ->tag('padding', 2)
93 ;
94
95 return $out;
96 }
97
98 public function renderManager()
99 {
100 $out = NULL;
101
102 $user = $this->auth->getCurrentUser();
103 $calendars = $this->appQuery->findCalendarsManagedByUser( $user );
104 if( ! $calendars ){
105 return $out;
106 }
107
108 $out = array();
109
110 $label = '__Manager__';
111 $label = $this->ui->makeBlock( $label )
112 ->tag('font-size', 4)
113 ;
114 $out[] = $label;
115
116 $calendarsView = array();
117 foreach( $calendars as $calendar ){
118 $calendarsView[] = $this->calendarsPresenter->presentTitle( $calendar );
119 }
120 $calendarsView = $this->ui->makeListInline( $calendarsView );
121 $out[] = $calendarsView;
122
123 $out = $this->ui->makeList( $out )->gutter(1);
124 $out = $this->ui->makeBlock( $out )
125 ->tag('border')
126 ->tag('padding', 2)
127 ;
128
129 return $out;
130 }
131
132 public function renderViewer()
133 {
134 $out = NULL;
135
136 $user = $this->auth->getCurrentUser();
137 $calendars = $this->appQuery->findCalendarsViewedByUser( $user );
138 if( ! $calendars ){
139 return $out;
140 }
141
142 $out = array();
143
144 $label = '__Viewer__';
145 $label = $this->ui->makeBlock( $label )
146 ->tag('font-size', 4)
147 ;
148 $out[] = $label;
149
150 $calendarsView = array();
151 foreach( $calendars as $calendar ){
152 $calendarsView[] = $this->calendarsPresenter->presentTitle( $calendar );
153 }
154 $calendarsView = $this->ui->makeListInline( $calendarsView );
155 $out[] = $calendarsView;
156
157 $out = $this->ui->makeList( $out )->gutter(1);
158 $out = $this->ui->makeBlock( $out )
159 ->tag('border')
160 ->tag('padding', 2)
161 ;
162
163 return $out;
164 }
165
166 public function renderEmployee()
167 {
168 $out = NULL;
169
170 $user = $this->auth->getCurrentUser();
171 $employee = $this->appQuery->findEmployeeByUser( $user );
172 if( ! $employee ){
173 return $out;
174 }
175
176 $label = '__Employee__';
177 $label = $this->ui->makeBlock( $label )
178 ->tag('font-size', 4)
179 ;
180 $out[] = $label;
181
182 $employeeView = $this->employeesPresenter->presentTitle( $employee );
183 $out[] = $employeeView;
184
185 $calendars = $this->appQuery->findCalendarsForEmployee( $employee );
186 $calendarsView = array();
187 foreach( $calendars as $calendar ){
188 $calendarsView[] = $this->calendarsPresenter->presentTitle($calendar);
189 }
190 $calendarsView = $this->ui->makeListInline( $calendarsView );
191 $out[] = $calendarsView;
192
193 $out = $this->ui->makeList( $out )->gutter(1);
194 $out = $this->ui->makeBlock( $out )
195 ->tag('border')
196 ->tag('padding', 2)
197 ;
198
199 return $out;
200 }
201
202 public function header()
203 {
204 $out = '__My Roles__';
205 return $out;
206 }
207
208 public function breadcrumb()
209 {
210 $return = array();
211 $return['profile'] = array( 'user/profile', '__Profile__' );
212 return $return;
213 }
214 }