25 private const ENTITY_IDS_LIMIT = 50;
42 CheckAttachReadAccess::class,
47 '-prefilters' => [CheckAttachReadAccess::class],
51 '-prefilters' => [CheckAttachReadAccess::class],
55 '-prefilters' => [CheckAttachReadAccess::class],
64 parent::getDefaultPreFilters(),
76 AttachedVotePayload::class,
84 AttachedVotePayload::class,
92 AttachedVotePayload::class,
104 $attach = $attachPayload->attach;
105 $this->changesSender->addUserWatch($this->getUserId(), $attach->getVoteId());
108 'attach' => $this->formatService->format($attach, $this->getUserId()),
115 string $actionUuid =
'',
118 $attach = $attachPayload->attach;
119 $voted = $attach->voteFor(
126 'attach' => $this->formatService->format($attach, $this->getUserId()),
131 ? $attach->getErrors()
132 : [
new Error(
'VOTE_CONTROLLER_ATTACH_VOTE_DEFAULT_ERROR')]
141 $attach = $attachPayload->attach;
142 $this->throwAccessDeniedIfNotAbleToEdit($attach);
143 $attach->stop($actionUuid);
150 $attach = $attachPayload->attach;
151 $this->throwAccessDeniedIfNotAbleToEdit($attach);
152 $attach->resume($actionUuid);
161 bool $userForMobileFormat =
false,
164 $attach = $attachPayload->attach;
165 $this->throwAccessDeniedIfAnswerNotBelongsAttachedVote($attach, $answerId);
168 $votedUserPage = $votedService->getByAnswerId($answerId, $pageNavigation->
getPageSize(), $pageNavigation->
getCurrentPage());
170 return new Page(
'items', $votedUserPage->items, $votedUserPage->totalCount);
175 $attach = $attachPayload->attach;
176 if (!$attach->canRead($this->getUserId()))
178 $this->addError(
new Error(
'Attach read access denied',
'ATTACH_READ_ACCESS_DENIED'));
183 $result = $attach->recall($this->getUserId(), $actionUuid);
187 'attach' => $this->formatService->format($attach, $this->getUserId()),
191 $this->addErrors(
$result->getErrors());
198 $attach = $attachPayload->attach;
199 $attach->exportExcel();
205 bool $userForMobileFormat =
false,
208 $attach = $attachPayload->attach;
210 $this->changesSender->addUserWatch($this->getUserId(), $attach->getVoteId());
213 'attach' => $this->formatService->format($attach, $this->getUserId()),
214 'voted' => $votedService->getByAttach($attach,
$pageSize),
220 $entityIds = array_filter(array_map(fn($value) => (
int)$value, $entityIds));
221 if (
count($entityIds) > self::ENTITY_IDS_LIMIT)
223 $this->addError(
new Error(
'To many entity ids'));
235 $this->addError(
new Error(
"Attach with entityId $entityId not found "));
240 if (!$attach->canRead(
$userId))
242 $this->addError(
new Error(
"Attach with entityId $entityId read access denied"));
247 $formatted[] = $this->formatService->format($attach,
$userId);
248 $this->changesSender->addUserWatch($this->getUserId(), $attach->getVoteId());
252 'items' => $formatted,
256 private function throwAccessDeniedIfNotAbleToEdit(
Attach $attach): void
258 if (!$attach->
canEdit($this->getUserId()))
264 private function getUserId(): int
266 return (
int)$this->getCurrentUser()?->getId();
269 private function throwAccessDeniedIfAnswerNotBelongsAttachedVote(Attach $attach,
int $answerId): void
271 if (!$this->isAnswerBelongsToAttachedVote($attach, $answerId))
273 throw new AccessDeniedException();
277 private function isAnswerBelongsToAttachedVote(Attach $attach,
int $answerId): bool
279 foreach ($attach[
"QUESTIONS"] ?? [] as $question)
281 if (array_key_exists($answerId, $question[
"ANSWERS"]))
297 parent::writeToLogException($e);
if(!Loader::includeModule('catalog')) if(!AccessController::getCurrent() ->check(ActionDictionary::ACTION_PRICE_EDIT)) if(!check_bitrix_sessid()) $request
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
static loadFirstFromEntity(string $moduleId, string $entityType, int $entityId)
getAction(AttachedVotePayload $attachPayload)
getAnswerVotedAction(AttachedVotePayload $attachPayload, int $answerId, PageNavigation $pageNavigation, bool $userForMobileFormat=false,)
__construct(Request $request=null)
getManyAction(string $moduleId, string $entityType, array $entityIds)
getWithVotedAction(AttachedVotePayload $attachPayload, int $pageSize=10, bool $userForMobileFormat=false,)
stopAction(AttachedVotePayload $attachPayload, string $actionUuid='')
resumeAction(AttachedVotePayload $attachPayload, string $actionUuid='')
voteAction(AttachedVotePayload $attachPayload, array $ballot, string $actionUuid='',)
recallAction(AttachedVotePayload $attachPayload, string $actionUuid='')
downloadAction(AttachedVotePayload $attachPayload)
writeToLogException(\Throwable $e)
static makeByAttachId(int $attachId)
static makeBySignedAttachId(string $signedAttachId)
static makeByEntityId(string $moduleId, string $entityType, int $entityId)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"