PluginProbe
ShiftController Employee Shift Scheduling / 4.9.87
ShiftController Employee Shift Scheduling v4.9.87
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 / _wordpress / permission.php

permission.php in ShiftController Employee Shift Scheduling 4.9.87, at sh4/_wordpress/permission.php

58 lines 1.2 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_Permission implements HC3_IPermission
3 {
4 protected $_adminIds = array();
5 protected $_adminRoles = array( 'administrator', 'developer', 'sh4_admin' );
6
7 public $usersQuery;
8
9 public function __construct(
10 HC3_Hooks $hooks,
11 HC3_Users_Query $usersQuery
12 )
13 {
14 $this->usersQuery = $hooks->wrap( $usersQuery );
15 }
16
17 public function isAdmin( HC3_Users_Model $user )
18 {
19 $return = FALSE;
20
21 $id = $user->getId();
22
23 if( in_array($id, $this->_adminIds) ){
24 $return = TRUE;
25 return $return;
26 }
27
28 $wpUser = get_userdata( $id );
29
30 if( ! isset($wpUser->roles) ){
31 return $return;
32 }
33
34 $thisRoles = $wpUser->roles;
35 if( array_intersect($this->_adminRoles, $thisRoles) ){
36 $return = TRUE;
37 }
38
39 return $return;
40 }
41
42 public function findAdmins()
43 {
44 $args = array();
45 $args[] = array('role', 'IN', $this->_adminRoles);
46
47 $return = $this->usersQuery->read( $args );
48
49 if( $this->_adminIds ){
50 $args = array();
51 $args[] = array('id', '=', $this->_adminIds);
52 $return2 = $this->usersQuery->read( $args );
53 $return = array_merge( $return, $return2 );
54 }
55
56 return $return;
57 }
58 }