30 $key =
'DEP_'.$userId;
31 if (!array_key_exists($key, static::$cache))
33 $res = \Bitrix\Main\UserTable::getList(
38 'select' => [
'UF_DEPARTMENT']
43 while ($row = $res->fetch())
45 if (is_array($row[
'UF_DEPARTMENT']))
47 $departments = array_merge($departments, $row[
'UF_DEPARTMENT']);
51 static::$cache[$key] = $departments;
54 return static::$cache[$key];
64 if ($this->userId === $userId)
69 if (!\CModule::IncludeModule(
'intranet'))
74 $key =
'SUB_' . $this->userId .
'_'. $userId;
76 array_key_exists($key, static::$cache)
79 return static::$cache[$key];
82 $managers = self::getAllManagers();
84 $selfDepartments = self::getUserDepartments($this->userId);
85 $foreignDepartments = self::getUserDepartments($userId);
87 $inDepartment = !empty(array_intersect($selfDepartments, $foreignDepartments));
89 $selfManagers = $this->getDepartmentsManagers($selfDepartments);
90 $foreignManagers = $this->getDepartmentsManagers($foreignDepartments,
true);
92 if (in_array($this->userId, $foreignManagers))
96 elseif (in_array($userId, $selfManagers))
100 elseif ($inDepartment)
104 elseif (in_array($userId, $managers))
113 return static::$cache[$key];