PluginProbe
ShiftController Employee Shift Scheduling / 4.9.66
ShiftController Employee Shift Scheduling v4.9.66
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.66, at sh4/app/acl.php

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