23 public function saveLinkRule(
string $linkHash, array $ruleArray)
26 $link = (new \Bitrix\Calendar\Sharing\Link\Factory())->getLinkByHash($linkHash);
32 if ($link instanceof
UserLink && \CCalendar::GetCurUserId() !== $link->
getUserId())
37 if ($this->isUserResponsibleForLink($link))
42 $linkObjectRule = (
new Factory())->getLinkObjectRuleByLink($link);
43 if (is_null($linkObjectRule))
48 $sharingRuleMapper =
new Mapper();
49 $rule = $sharingRuleMapper->buildRuleFromArray($ruleArray);
50 $sharingRuleMapper->saveForLinkObject($rule, $linkObjectRule);
60 private function isUserResponsibleForLink(
Link $link):
bool
62 if (!Loader::includeModule(
'crm'))
72 $currentUserId = (new \Bitrix\Crm\Service\Context())->getUserId();
74 return $this->getAssignedByIdCrmDeal($link) !== $currentUserId;
81 private function getAssignedByIdCrmDeal(
CrmDealLink $link): ?
int
83 $entityBroker = \Bitrix\Crm\Service\Container::getInstance()->getEntityBroker(\CCrmOwnerType::Deal);
89 $entity = $entityBroker->getById($link->getEntityId());
95 return $entity->getAssignedById();