EditController.class.php
2.31 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
77
78
79
80
<?php
/**
* 编辑管理员角色信息
* EditController.class.php
*
*/
namespace Apicp\Controller\AdminRole;
use Com\Validator;
use VcySDK\Adminer;
class EditController extends AbstractController
{
public function Index()
{
// 当前管理员为分级管理时,无权操作
$user = $this->_login->user;
if (!isset($user['eaLevel'])) {
E('_ERR_ADMIN_MANAGER_EALEVEL_UNDEFINED');
}
if ($user['eaLevel'] == Adminer::ADMIN_LEVEL_BRANCH) {
E('_ERR_ADMIN_BRANCH_CANNOT_OPERATE');
}
// 接收数据
$earId = I('post.earId');
$earName = I('post.earName', '', 'trim');
$earCpmenu = I('post.earCpmenu', '{}', 'htmlspecialchars_decode');
$earDesc = I('post.earDesc');
$readDpIdList = I('post.readDpIdList');
$writeDpIdList = I('post.writeDpIdList');
// 管理员ID非空验证
if (empty($earId)) {
$this->_set_error('_ERR_ADMIN_ROLE_ID_EMPTY');
return false;
}
// 如果是保护角色名称
if ($this->_isProtectName($earName)) {
$this->_set_error('_ERR_ADMIN_ROLE_NAME_PROTECT');
return false;
}
if (empty($earName)) {
$this->_set_error("_ERR_ADMIN_ROLE_NAME_EMPTY");
return false;
}
if (! Validator::is_realname($earName, 3, 255)) {
$this->_set_error(L('_ERR_ADMIN_ROLE_NAME_LENGTH_INVALID', array('min' => 3, 'max' => 255)));
return false;
}
// 判断权限菜单
if (empty($earCpmenu)) {
$earCpmenu = '{}';
}
// 可见部门ID
$readDpIdList = $this->_filterDp($readDpIdList);
// 可编辑部门ID
$writeDpIdList = $this->_filterDp($writeDpIdList);
// 获取修改管理员的参数
$param = array(
'earName' => $earName,
'earCpmenu' => $earCpmenu,
'earId' => $earId,
'earDesc' => $earDesc,
'readDpIdList' => empty($readDpIdList) ? '' : json_encode($readDpIdList),
'writeDpIdList' => empty($writeDpIdList) ? '' : json_encode($writeDpIdList),
);
// 调用UC,编辑管理员提交
$this->_result = $this->_sdkRole->modify($param);
return true;
}
}