64 if ($this->userId === $userId)
66 return self::RELATION_HIMSELF;
69 if (!\CModule::IncludeModule(
'intranet'))
71 return self::RELATION_OTHER;
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))
94 static::$cache[
$key] = self::RELATION_SUBORDINATE;
96 elseif (in_array($userId, $selfManagers))
98 static::$cache[
$key] = self::RELATION_DIRECTOR;
102 static::$cache[
$key] = self::RELATION_DEPARTMENT;
104 elseif (in_array($userId, $managers))
106 static::$cache[
$key] = self::RELATION_OTHER_DIRECTOR;
110 static::$cache[
$key] = self::RELATION_OTHER;
113 return static::$cache[
$key];