ListController.class.php
2.4 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
<?php
/**
* 管理员角色列表
* ListController.class.php
*
*/
namespace Apicp\Controller\AdminRole;
use VcySDK\Adminer;
use VcySDK\AdminerRole;
class ListController extends AbstractController
{
public function Index()
{
// 接收数据
$pageSize = I('post.limit', 1500); // 每页条数
$pageNum = I('post.page'); // 页码
$earId = I('post.earId'); // 角色ID
$eaLevel = I('post.eaLevel'); // 管理级别
// 当前管理员信息
$user = $this->_login->user;
if (!isset($user['eaLevel'])) {
E('_ERR_ADMIN_MANAGER_EALEVEL_UNDEFINED');
}
// 当前管理员为分级管理,只可见本身所在的角色组(添加、编辑管理员页面;管理员列表页面)
if ($user['eaLevel'] == Adminer::ADMIN_LEVEL_BRANCH) {
$earId = $user['earId'];
}
// 查询条件数组拼接
$condition = array(
'earId' => $earId,
'filterType' => AdminerRole::ROLE_LIST_FILTER_TYPE,
);
// 调用UC接口,查询符合条件的列表
$result = $this->_sdkRole->listAll($condition, $pageNum, $pageSize);
// 当前管理员为超级管理,设置超级管理、分级管理(添加、编辑管理员页面)
$list = [];
if (!empty($result['list']) && !empty($eaLevel) && $user['eaLevel'] == Adminer::ADMIN_LEVEL_SUPER) {
foreach ($result['list'] as $v) {
// 设置超管时,获取通讯录管理权限为全公司的角色组列表
if ($eaLevel == Adminer::ADMIN_LEVEL_SUPER && empty($v['readDpIdList']) && empty($v['writeDpIdList'])) {
$list[] = $v;
}
// 设置分管时,获取通讯录管理权限为制定对象的角色组列表
if ($eaLevel == Adminer::ADMIN_LEVEL_BRANCH && (!empty($v['readDpIdList']) || !empty($v['writeDpIdList']))) {
$list[] = $v;
}
}
}
// 输出
$this->_result = array(
'total' => $user['eaLevel'] == Adminer::ADMIN_LEVEL_SUPER && !empty($eaLevel) ? count($list) : $result['total'],
'limit' => $pageSize,
'page' => $pageNum,
'list' => $user['eaLevel'] == Adminer::ADMIN_LEVEL_SUPER && !empty($eaLevel) ? $list : $result['list'],
);
return true;
}
}