PluginProbe
ShiftController Employee Shift Scheduling / 4.9.24
ShiftController Employee Shift Scheduling v4.9.24
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 / app / acl.php

acl.php in ShiftController Employee Shift Scheduling 4.9.24, at sh4/app/acl.php

130 lines 2.4 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 class SH4_App_Acl
3 {
4 public function __construct(
5 HC3_Hooks $hooks,
6
7 SH4_App_Query $appQuery,
8
9 HC3_Auth $auth,
10 HC3_IPermission $permission
11 )
12 {
13 $this->appQuery = $hooks->wrap( $appQuery );
14 $this->auth = $hooks->wrap( $auth );
15 $this->permission = $hooks->wrap( $permission );
16 }
17
18 public function checkUserProfile()
19 {
20 $haveRoles = false;
21
22 $user = $this->auth->getCurrentUser();
23
24 // admin?
25 if( ! $haveRoles ){
26 if( $this->permission->isAdmin($user) ){
27 $haveRoles = true;
28 }
29 }
30
31 // manager?
32 if( ! $haveRoles ){
33 $calendars = $this->appQuery->findCalendarsManagedByUser( $user );
34 if( $calendars ){
35 $haveRoles = true;
36 }
37 }
38
39 // viewer?
40 if( ! $haveRoles ){
41 $calendars = $this->appQuery->findCalendarsViewedByUser( $user );
42 if( $calendars ){
43 $haveRoles = true;
44 }
45 }
46
47 // employee?
48 if( ! $haveRoles ){
49 $employee = $this->appQuery->findEmployeeByUser( $user );
50 if( $employee ){
51 $haveRoles = true;
52 }
53 }
54
55 $ret = $haveRoles ? true : false;
56 return $ret;
57 }
58
59 public function checkUser()
60 {
61 $return = FALSE;
62
63 $currentUser = $this->auth->getCurrentUser();
64 $currentUserId = $currentUser->getId();
65 if( ! $currentUserId ){
66 return $return;
67 }
68
69 $return = TRUE;
70 return $return;
71 }
72
73 public function checkAdmin()
74 {
75 $return = FALSE;
76
77 $currentUser = $this->auth->getCurrentUser();
78 $currentUserId = $currentUser->getId();
79
80 if( ! $currentUserId ){
81 return $return;
82 }
83
84 if( $this->permission->isAdmin($currentUser) ){
85 $return = TRUE;
86 }
87
88 return $return;
89 }
90
91 public function checkManager()
92 {
93 $return = FALSE;
94
95 $currentUser = $this->auth->getCurrentUser();
96 $currentUserId = $currentUser->getId();
97 if( ! $currentUserId ){
98 return $return;
99 }
100
101 $calendars = $this->appQuery->findCalendarsManagedByUser( $currentUser );
102 if( ! $calendars ){
103 return $return;
104 }
105
106 $return = TRUE;
107
108 return $return;
109 }
110
111 public function checkEmployee()
112 {
113 $return = FALSE;
114
115 $currentUser = $this->auth->getCurrentUser();
116 $currentUserId = $currentUser->getId();
117 if( ! $currentUserId ){
118 return $return;
119 }
120
121 $employee = $this->appQuery->findEmployeeByUser( $currentUser );
122 if( ! $employee ){
123 return $return;
124 }
125
126 $return = TRUE;
127
128 return $return;
129 }
130 }