Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
taskscounter.php
1<?php
2
4
7use Bitrix\Tasks\Internals\Counter\CounterDictionary;
8use Bitrix\Tasks\UI\ScopeDictionary;
9
11{
12 public static function getAccessToTasksCounters(array $params = []): bool
13 {
14 $mode = ($params['mode'] ?? '');
15 $contextUserId = (int)($params['contextUserId'] ?? 0);
16 $currentUserId = (int)($params['currentUserId'] ?? \Bitrix\Socialnetwork\Helper\User::getCurrentUserId());
17
18 if (
19 !Loader::includeModule('tasks')
20 || !in_array($mode, WorkgroupList::getTasksModeList(), true)
21 )
22 {
23 return false;
24 }
25
26 return (
27 $currentUserId === $contextUserId
28 || \Bitrix\Tasks\Util\User::isSuper($currentUserId)
29 || \CTasks::IsSubordinate($contextUserId, $currentUserId)
30 );
31 }
32
33 public static function getTasksCounters(array $params = []): array
34 {
35 $mode = ($params['mode'] ?? '');
36
37 $result = [];
38
39 if (
40 !Loader::includeModule('tasks')
41 || !in_array($mode, WorkgroupList::getTasksModeList(), true)
42 )
43 {
44 return $result;
45 }
46
47 switch ($mode)
48 {
50 $result = [
51 CounterDictionary::COUNTER_SONET_TOTAL_EXPIRED,
52 CounterDictionary::COUNTER_SONET_TOTAL_COMMENTS,
53 CounterDictionary::COUNTER_SONET_FOREIGN_EXPIRED,
54 CounterDictionary::COUNTER_SONET_FOREIGN_COMMENTS,
55 ];
56 break;
58 $result = [
59 CounterDictionary::COUNTER_SCRUM_TOTAL_COMMENTS,
60 CounterDictionary::COUNTER_SCRUM_FOREIGN_COMMENTS,
61 ];
62 break;
63 default:
64 }
65
66 return $result;
67 }
68
69 public static function getTasksCountersScope(array $params = []): string
70 {
71 $mode = ($params['mode'] ?? '');
72
73 $result = '';
74
75 if (
76 !Loader::includeModule('tasks')
77 || !in_array($mode, WorkgroupList::getTasksModeList(), true)
78 )
79 {
80 return $result;
81 }
82
83 switch ($mode)
84 {
86 $result = ScopeDictionary::SCOPE_PROJECTS_GRID;
87 break;
89 $result = ScopeDictionary::SCOPE_SCRUM_PROJECTS_GRID;
90 break;
91 default:
92 }
93
94 return $result;
95 }
96}