DepartmentListController.class.php
2.7 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
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php
/**
* Created by PhpStorm.
* User: liyifei2012it
* Date: 16/9/18
* Time: 11:51
*/
namespace Api\Controller\User;
use Common\Common\Cache;
use Common\Common\Department;
use Common\Service\DeptRightService;
use Common\Service\InviteSettingService;
use Common\Service\UserService;
use VcySDK\Enterprise;
use VcySDK\Service;
class DepartmentListController extends AbstractController
{
/**
* 【通讯录】部门列表
* @author liyifei
*/
public function Index_post()
{
$user = $this->_login->user;
if (empty($user['memUid'])) {
E('_ERR_NOT_LOGIN');
return false;
}
// 检查管理权限
$this->checkCurrentManagePower($user);
// 实例化
$rightServ = new DeptRightService();
$settingServ = new InviteSettingService();
$epServ = new Enterprise(Service::instance());
// 获取邀请函设置信息
$setting = $settingServ->get_by_conds([]);
$checkUdpids = unserialize($setting['check_udpids']);
$inviteUdpids = unserialize($setting['invite_udpids']);
// 查询登录人员是否有邀请人员权限
$isInvite = is_array($inviteUdpids) && in_array($user['memUid'], $inviteUdpids) ? InviteSettingService::IS_INVITE_YES : InviteSettingService::IS_INVITE_NO;
// 查询登录人员是否有审核权限
$isCheck = is_array($checkUdpids) && in_array($user['memUid'], $checkUdpids) ? InviteSettingService::IS_CHECK_YES : InviteSettingService::IS_CHECK_NO;
// 人员通讯录可查看范围-列表
//$range = $rightServ->getDpListByUid($user['memUid']);
// 我的部门-列表
//$myList = $rightServ->getMyDeptList($user['memUid']);
// 获取部门列表
$userService = new UserService();
list($currentDpId, $p2c, $childIds, $dpIds) = $userService->getUserTopDpId($user);
// 取出所有部门
$departments = Department::instance()->listAll();
$myDepartments = array();
foreach ($departments as $_dp) {
if (!in_array($_dp['dpId'], $dpIds)) {
continue;
}
$myDepartments[$_dp['dpId']] = $_dp;
}
// 企业信息
$ep = Cache::instance()->get(
'Common.EnterpriseDetail',
'',
['expire' => cfg('ENTERPRISE_DETAIL_CACHE_EXPIRE')]
);
$this->_result = array(
'is_check' => $isCheck,
'is_invite' => $isInvite,
'qy_name' => $ep['epName'],
'myDpIds' => $childIds,
'list' => $myDepartments,
'currentDpId' => $currentDpId,
'p2c' => $p2c
);
return true;
}
}