AbstractController.class.php
1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
/**
* 管理员角色基类
* AbstractController.class.php
* $author$
*/
namespace Apicp\Controller\AdminRole;
use VcySDK\Service;
use VcySDK\AdminerRole;
use Common\Common\Department;
abstract class AbstractController extends \Common\Controller\Apicp\AbstractController
{
/**
* @type AdminerRole
*/
protected $_sdkRole = null;
protected $needCheckThePayment = false;
public function before_action($action = '')
{
if (! parent::before_action($action)) {
return false;
}
// 调用UC接口,查询管理员角色详情
$this->_sdkRole = new AdminerRole(Service::instance());
return true;
}
/**
* 判断是否为保护角色名称
*
* @param string $name 角色名称
*
* @return bool
*/
protected function _isProtectName($name)
{
return cfg('ADMIN_ROLE_PROTECT_NAME') == $name;
}
/**
* 过滤父级部门
* @param array $dp_ids 部门ID
* @return array
*/
protected function _filterDp($dp_ids)
{
if (!is_array($dp_ids) || empty($dp_ids)) {
return [];
}
$dp_ids = array_unique($dp_ids);
$dpServ = &Department::instance();
foreach ($dp_ids as $k => $dp_id) {
// 获取所有子级部门ID
$children = $dpServ->list_childrens_by_cdid($dp_id);
// 判断子级部门ID是否存在于数组中
if (array_intersect($children, $dp_ids)) {
unset($dp_ids[$k]);
}
}
return array_values($dp_ids);
}
}