1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
attach.php
См. документацию.
1<?php
8namespace Bitrix\Vote;
9use \Bitrix\Main\AccessDeniedException;
10use \Bitrix\Main\ArgumentNullException;
11use \Bitrix\Main\ArgumentTypeException;
12use \Bitrix\Main\Entity;
13use \Bitrix\Main\Error;
14use \Bitrix\Main\ErrorCollection;
15use \Bitrix\Main\InvalidOperationException;
16use \Bitrix\Main\Localization\Loc;
17use \Bitrix\Main\ArgumentException;
18use \Bitrix\Main\NotSupportedException;
19use Bitrix\Main\Result;
20use Bitrix\Main\Security\Random;
21use \Bitrix\Main\Type\DateTime;
22use \Bitrix\Vote\Attachment\Connector;
23use \Bitrix\Vote\Base\BaseObject;
24use \Bitrix\Vote\DBResult;
25use \Bitrix\Main\SystemException;
26use \Bitrix\Vote\Event;
27use \Bitrix\Main\ObjectNotFoundException;
28use Bitrix\Vote\Integration\Pull\VoteChangesSender;
29use Bitrix\Vote\Model\Dto\UserBallot;
30use Bitrix\Vote\Vote\Anonymity;
31
32Loc::loadMessages(__FILE__);
33
61class AttachTable extends Entity\DataManager
62{
67 public static function getTableName()
68 {
69 return 'b_vote_attached_object';
70 }
71
76 public static function getMap()
77 {
78 return array(
79 'ID' => array(
80 'data_type' => 'integer',
81 'primary' => true,
82 'autocomplete' => true,
83 'title' => Loc::getMessage('V_TABLE_FIELD_ID'),
84 ),
85 'OBJECT_ID' => array(
86 'data_type' => 'integer',
87 'title' => Loc::getMessage('V_TABLE_FIELD_OBJECT_ID'),
88 ),
89 'MODULE_ID' => array(
90 'data_type' => 'string',
91 'size' => 32,
92 'title' => Loc::getMessage('V_TABLE_FIELD_MODULE_ID')
93 ),
94 'ENTITY_TYPE' => array(
95 'data_type' => 'string',
96 'size' => 100,
97 'title' => Loc::getMessage('V_TABLE_FIELD_ENTITY_TYPE')
98 ),
99 'ENTITY_ID' => array(
100 'data_type' => 'integer',
101 'title' => Loc::getMessage('V_TABLE_FIELD_OBJECT_ID'),
102 ),
103 'CREATE_TIME' => array(
104 'data_type' => 'datetime',
105 'title' => Loc::getMessage('V_TABLE_FIELD_TIMESTAMP_X'),
106 ),
107 'CREATED_BY' => array(
108 'data_type' => 'integer',
109 'title' => Loc::getMessage('V_TABLE_FIELD_AUTHOR_ID'),
110 ),
111 'UID' => [
112 'data_type' => 'string',
113 'size' => 255,
114 ],
115 'VOTE' => array(
116 'data_type' => '\Bitrix\Vote\VoteTable',
117 'reference' => array(
118 '=this.OBJECT_ID' => 'ref.ID',
119 ),
120 'join_type' => 'INNER',
121 ),
122 );
123 }
124
129 public static function getList(array $parameters = array())
130 {
131 return new DBResult(parent::getList($parameters));
132 }
133
140 public static function deleteByFilter(array $filter)
141 {
142 if (!$filter)
143 {
144 throw new \Bitrix\Main\ArgumentNullException('filter');
145 }
146
147 $result = static::getList(array(
148 'select' => array('ID'),
149 'filter' => $filter,
150 ));
151 while($row = $result->fetch())
152 {
153 if(!empty($row['ID']))
154 {
155 $resultDelete = static::delete($row['ID']);
156 if(!$resultDelete->isSuccess())
157 {
158 return false;
159 }
160 }
161 }
162 return true;
163 }
164
165 public static function getIdByUid(string $uid): ?int
166 {
167 $row = AttachTable::query()
168 ->where('UID', $uid)
169 ->setSelect(['ID'])
170 ->setLimit(1)
171 ->exec()
172 ->fetch()
173 ;
174
175 return $row['ID'] ?? null;
176 }
177}
178
179class Attach extends BaseObject implements \ArrayAccess
180{
181 public const UID_LENGTH = 16;
182
184 protected $attach;
186 protected $vote;
188 protected $connector;
190 protected $channel;
191
192 public static $storage = array();
193 protected static $loaded = array(
194 "attachIds" => array(),
195 "voteIds" => array(),
196 "entities" => array()
197 );
198
204 function init()
205 {
206 $attach = null;
207 $vote = null;
208 if (is_array($this->id))
209 {
211 }
212 else
213 {
214 $data = self::getData($this->id);
215 if (is_null($data))
216 {
217 throw new ObjectNotFoundException("Attach");
218 }
219 [$attach, $vote] = $data;
220 }
221 if (!is_array($attach) || empty($attach))
222 {
223 throw new ObjectNotFoundException("Wrong attach id!");
224 }
225
226 if (!array_key_exists("MODULE_ID", $attach) || $attach["MODULE_ID"] == '')
227 throw new ArgumentNullException("module ID");
228 if (!array_key_exists("ENTITY_TYPE", $attach) || $attach["ENTITY_TYPE"] == '')
229 throw new ArgumentNullException("entity type");
230 if (array_key_exists("ID", $attach))
231 $this->id = intval($attach["ID"]);
232 else
233 {
234 $this->id = null;
235 unset($attach["ID"]);
236 }
237
238 $this->attach = $attach;
239
240 if (is_array($vote))
241 {
242 $this->setVote($vote["ID"]);
243 $this->setStorage($this->vote["CHANNEL_ID"]);
244 }
245 }
246
250 public function setVote($vote)
251 {
252 if ($vote instanceof Vote)
253 $this->vote = $vote;
254 else
255 $this->vote = Vote::loadFromId($vote);
256 }
257
262 public function setStorage($id)
263 {
264 $this->channel = new Channel($id);
265 }
266
271 public static function getData($id)
272 {
273 $filter = array();
274
275 if (is_array($id))
276 {
277 $filter = array_change_key_case($id, CASE_UPPER);
278 $id = md5(serialize($filter));
279 }
280 else if (($id = intval($id)) && $id > 0)
281 $filter["ID"] = $id;
282 else
283 return null;
284
285 if (!array_key_exists($id, self::$storage))
286 {
287 self::$storage[$id] = null;
289 'select' => array(
290 'O_' => "*",
291 'V_' => 'VOTE.*',
292 'V_LAMP' => 'VOTE.LAMP',
293 'Q_' => 'VOTE.QUESTION.*',
294 'A_' => 'VOTE.QUESTION.ANSWER',
295 ),
296 'order' => array(
297 'VOTE.ID' => 'ASC',
298 'VOTE.QUESTION.C_SORT' => 'ASC',
299 'VOTE.QUESTION.ID' => 'ASC',
300 'VOTE.QUESTION.ANSWER.C_SORT' => 'ASC',
301 'VOTE.QUESTION.ANSWER.ID' => 'ASC',
302 ),
303 'filter' => $filter
304 ));
305 $attaches = [];
306 $images = [];
307 $attach = ["ID" => null];
308 $vote = ["ID" => null];
309 $question = ["ID" => null];
310
311 while (($res = $dbRes->fetch()) && $res)
312 {
313 $buffer = ["attach" => [], "vote" => [], "question" => []];
314 unset($answer);
315 $answer = [];
316 foreach ($res as $key => $val)
317 {
318 if (mb_strpos($key, "O_") === 0)
319 $buffer["attach"][mb_substr($key, 2)] = $val;
320 else if (mb_strpos($key, "V_") === 0)
321 $buffer["vote"][mb_substr($key, 2)] = $val;
322 else if (mb_strpos($key, "Q_") === 0)
323 $buffer["question"][mb_substr($key, 2)] = $val;
324 else if (mb_strpos($key, "A_") === 0)
325 $answer[mb_substr($key, 2)] = $val;
326 }
327 if ($buffer["attach"]["ID"] != $attach["ID"])
328 {
329 unset($attach);
330 $attach = $buffer["attach"];
331 $attaches[$attach["ID"]] = $attach;
332 }
333 if ($buffer["vote"]["ID"] != $vote["ID"])
334 {
335 unset($vote);
336 $vote = $buffer["vote"] + array(
337 "FIELD_NAME" => \Bitrix\Vote\Event::getExtrasFieldName($attach["ID"], "#ENTITY_ID#"),
338 "IMAGE" => null,
339 "QUESTIONS" => array());
340 if ($vote["IMAGE_ID"] > 0)
341 $images[$vote["IMAGE_ID"]] = &$vote["IMAGE"];
342 if (!array_key_exists($vote["ID"], Vote::$storage))
343 Vote::$storage[$vote["ID"]] = &$vote;
344 }
345 if ($buffer["question"]["ID"] != $question["ID"])
346 {
347 unset($question);
348 $question = $buffer["question"] + array(
349 "FIELD_NAME" => \Bitrix\Vote\Event::getFieldName($attach["ID"], $buffer["question"]["ID"]),
350 "IMAGE" => null,
351 "ANSWERS" => array()
352 );
353 if ($question["IMAGE_ID"] > 0)
354 $images[$question["IMAGE_ID"]] = &$question["IMAGE"];
355 if (!array_key_exists($question["ID"], Question::$storage))
356 Question::$storage[$question["ID"]] = &$question;
357 $vote["QUESTIONS"][$question["ID"]] = &$question;
358 }
359 $answer["FIELD_NAME"] = $answer["~FIELD_NAME"] = \Bitrix\Vote\Event::getFieldName($attach["ID"], $question["ID"]);
360 $answer["MESSAGE_FIELD_NAME"] = \Bitrix\Vote\Event::getMessageFieldName($attach["ID"], $question["ID"], $answer["ID"]);
361 if (
362 $answer["FIELD_TYPE"] == \Bitrix\Vote\AnswerTypes::TEXT ||
363 $answer["FIELD_TYPE"] == \Bitrix\Vote\AnswerTypes::TEXTAREA
364 )
365 {
366 if ($question["FIELD_TYPE"] == \Bitrix\Vote\QuestionTypes::COMPATIBILITY)
367 $answer["FIELD_NAME"] = $answer["MESSAGE_FIELD_NAME"];
368 }
369 else if ($question["FIELD_TYPE"] != \Bitrix\Vote\QuestionTypes::COMPATIBILITY)
370 {
371 $answer["FIELD_TYPE"] = $question["FIELD_TYPE"];
372 }
373 $answer["~PERCENT"] = ($question["COUNTER"] > 0 ? $answer["COUNTER"] * 100 / $question["COUNTER"] : 0);
374 $answer["PERCENT"] = round($answer["~PERCENT"], 2);
375 $question["ANSWERS"][$answer["ID"]] = &$answer;
376 Answer::$storage[$answer["ID"]] = &$answer;
377 unset($answer);
378 }
379 unset($vote); unset($question);
380 //region Getting images
381 if (count($images) > 0)
382 {
383 $dbRes = \Bitrix\Main\FileTable::getList(array('select' => array('*'), 'filter' => array('ID' => array_keys($images))));
384 while ($res = $dbRes->fetch())
385 {
386 $images[$res["ID"]] = $res + array("SRC" => \CFile::GetFileSRC($res));
387 }
388 }
389 //endregion
390 //region Setting data into local storages
391 foreach ($attaches as $attach)
392 {
393 self::$storage[$attach["ID"]] = array($attach, Vote::$storage[$attach["OBJECT_ID"]]);
394 if (is_string($id))
395 {
396 self::$storage[$id] = (is_array(self::$storage[$id]) ? self::$storage[$id] : array());
397 self::$storage[$id][$attach["ID"]] = array($attach, Vote::$storage[$attach["OBJECT_ID"]]);
398 }
399 }
400 //endregion
401 }
402 return self::$storage[$id];
403 }
404
410 public static function getDataByEntity(array $id)
411 {
412 $id1 = md5(serialize($id));
413 if (!array_key_exists($id1, self::$storage))
414 {
415 self::$storage[$id1] = array();
416
418 'select' => array(
419 'O_' => "*",
420 'V_' => 'VOTE.*',
421 'V_LAMP' => 'VOTE.LAMP',
422 'Q_' => 'VOTE.QUESTION.*',
423 'A_' => 'VOTE.QUESTION.ANSWER',
424 ),
425 'order' => array(
426 'VOTE.QUESTION.C_SORT' => 'ASC',
427 'VOTE.QUESTION.ID' => 'ASC',
428 'VOTE.QUESTION.ANSWER.C_SORT' => 'ASC',
429 'VOTE.QUESTION.ANSWER.ID' => 'ASC',
430 ),
431 'filter' => array(
432 'ENTITY_TYPE' => $id['ENTITY_TYPE'],
433 'ENTITY_ID' => $id['ENTITY_ID']
434 )
435 ));
436 if (($res = $dbRes->fetch()) && $res)
437 {
438 $attach = array();
439 $vote = array();
440 foreach ($res as $key => $val)
441 if (mb_strpos($key, "O_") === 0)
442 $attach[mb_substr($key, 2)] = $val;
443 else if (mb_strpos($key, "V_") === 0)
444 $vote[mb_substr($key, 2)] = $val;
445 $vote["QUESTIONS"] = array();
446 $questions = &$vote["QUESTIONS"];
447 do
448 {
449 $question = array(); $answer = array();
450 foreach ($res as $key => $val)
451 {
452 if (mb_strpos($key, "Q_") === 0)
453 $question[mb_substr($key, 2)] = $val;
454 else if (mb_strpos($key, "A_") === 0)
455 $answer[mb_substr($key, 2)] = $val;
456 }
457 $qid = "".$question["ID"];
458 if (!array_key_exists($qid, $questions))
459 $questions[$qid] = array_merge($question, array("ANSWERS" => array()));
460 if (!array_key_exists($qid, Question::$storage))
461 Question::$storage[$qid] = $question;
462 $answers = &$questions[$qid]["ANSWERS"];
463 if (!empty($answer))
464 {
465 if (!array_key_exists($answer["ID"], $answers))
466 $answers[$answer["ID"]] = $answer;
467 if (!array_key_exists($answer["ID"], Answer::$storage))
468 Answer::$storage[$answer["ID"]] = $answer;
469 }
470
471 } while (($res = $dbRes->fetch()) && $res);
472 Vote::$storage[$vote["ID"]] = $vote;
473 self::$storage[$id1] = array($attach, $vote);
474 }
475 }
476 return self::$storage[$id1];
477 }
478
485 public function canRead($userId)
486 {
487 return $this->getConnector()->canRead($userId);
488 }
489
495 public function canParticipate($userId)
496 {
497 return $this->getConnector()->canRead($userId) && is_object($this->vote) && $this->vote["LAMP"] == "green";
498 }
499
500 public function canVote($userId)
501 {
502 return $this->vote->canVote($userId);
503 }
504
505 public function canRevote($userId)
506 {
507 return $this->vote->canRevote($userId);
508 }
509
510 public function canReadResult($userId)
511 {
512 return $this->vote->canReadResult($userId);
513 }
514
520 public function canEdit($userId)
521 {
522 return $this->getConnector()->canEdit($userId);
523 }
524
531 public function getConnector()
532 {
533 if ($this->connector === null)
534 {
535 $this->connector = Connector::buildFromAttachedObject($this);
536 }
537 return $this->connector;
538 }
539
543 public function getStorage()
544 {
545 if (!($this->channel instanceof Channel))
546 {
547 $this->setStorage($this->vote instanceof Vote ? $this->vote["CHANNEL_ID"] : null);
548 }
549 return $this->channel;
550 }
551
555 public function getAttachId()
556 {
557 return $this->attach['ID'] ?? null;
558 }
559
563 public function getVoteId()
564 {
565 return is_object($this->vote) ? $this->vote["ID"] : null;
566 }
567
571 public function getModuleId()
572 {
573 return $this->attach["MODULE_ID"];
574 }
575
579 public function getEntityType()
580 {
581 return $this->attach["ENTITY_TYPE"];
582 }
583
587 public function getEntityId()
588 {
589 return $this->attach["ENTITY_ID"];
590 }
591
595 public function fillStatistic()
596 {
597 if (is_object($this->vote))
598 $this->vote->fillStatistic();
599 }
600
605 public function delete()
606 {
607 if (empty($this->vote))
608 return true;
609
610 if ($this->attach["ID"] > 0)
611 AttachTable::delete($this->attach["ID"]);
612
613 $othersAttaches = AttachTable::getList(array(
614 "select" => array("ID", "OBJECT_ID"),
615 "filter" => array("OBJECT_ID" => $this->vote["ID"]),
616 'order' => array(
617 'ID' => 'ASC'
618 )
619 ))->fetch();
620
621 if (empty($othersAttaches) && ($channel = $this->getStorage()) && $channel["HIDDEN"] == "Y")
622 Vote::delete($this->vote["ID"]);
623
624 return true;
625 }
626
648 public function checkData(array &$data)
649 {
650 $channel = $this->getStorage();
651 if ($channel["ACTIVE"] !== "Y")
652 throw new AccessDeniedException(Loc::getMessage("VOTE_CHANNEL_IS_NOT_ACTIVE"));
653 $data = array_merge($data, (is_null($this->vote) ? [
654 "ACTIVE" => "Y",
655 "DATE_START" => new DateTime(),
656 ] : []), [
657 "CHANNEL_ID" => $channel["ID"],
658 "DATE_END" => (isset($data["DATE_END"]) ? new DateTime($data["DATE_END"]) : (new DateTime())->add("1Y"))
659 ]);
660 $this->getConnector()->checkFields($data);
661 Vote::checkData($data, $data["ID"]);
662 if (($data["TITLE"] ?? null) == '' && is_array($data["QUESTIONS"]))
663 {
664 $q = reset($data["QUESTIONS"]);
665 if (is_array($q) && $q["QUESTION"] <> '')
666 {
667 $data["TITLE"] = $q["QUESTION"];
668 }
669 }
670 }
671
693 public function save($data, $createdBy = 0)
694 {
695 if (!isset($data["AUTHOR_ID"]))
696 $data["AUTHOR_ID"] = $createdBy;
697
698 $this->checkData($data);
699
700 $voteId = Vote::saveData(is_null($this->vote) ? 0 : $this->vote["ID"], $data);
701 if ($voteId > 0)
702 {
703 if (!array_key_exists("ID", $this->attach))
704 {
705 $id = AttachTable::add(array(
706 'MODULE_ID' => $this->getModuleId(),
707 'OBJECT_ID' => $voteId,
708 'ENTITY_ID' => $this->getEntityId(),
709 'ENTITY_TYPE' => $this->getEntityType(),
710 'CREATED_BY' => $createdBy,
711 'CREATE_TIME' => new DateTime()
712 ))->getId();
713 }
714 else
715 {
716 $id = $this->attach["ID"];
717 }
719 $this->attach = $attach;
720 $this->vote = $vote;
721 }
722 else if ($this->attach["ID"] ?? null > 0)
723 {
724 $this->attach = null;
725 $this->vote = null;
726 }
727 return true;
728 }
729
744 public function voteFor(array $request, string $actionUuid = ''): bool
745 {
746 if (!is_object($this->vote))
747 throw new InvalidOperationException("Poll is not found.");
749 if (empty($res)) // for custom templates
750 $result = $this->vote->voteFor($request, ["revote" => true]);
751 else
752 $result = $this->vote->registerEvent($res, ["revote" => true], User::getCurrent());
753 if ($result)
754 {
755 $this->sendVotingPush($actionUuid);
756 }
757 else
758 {
759 $this->errorCollection->add($this->vote->getErrors());
760 }
761
762 return (bool)$result;
763 }
764
769 public function exportExcel()
770 {
771 if (!is_object($this->vote))
772 throw new InvalidOperationException("Poll is not found.");
773 $this->vote->exportExcel();
774 }
775
780 public function isVotedFor($userId)
781 {
782 if ($this->vote)
783 return $this->vote->isVotedFor($userId);
784 return false;
785 }
786
795 public function resume(string $actionUuid = '')
796 {
797 if (!is_object($this->vote))
798 throw new InvalidOperationException("Poll is not found.");
799 $this->vote->resume();
800 (new VoteChangesSender())->sendResume(
801 $this->getVoteId(),
802 (int)$this->getEntityId(),
803 $actionUuid,
804 );
805 }
806
815 public function stop(string $actionUuid = '')
816 {
817 if (!is_object($this->vote))
818 throw new InvalidOperationException("Poll is not found.");
819 $this->vote->stop();
820 (new VoteChangesSender())->sendStop(
821 $this->getVoteId(),
822 (int)$this->getEntityId(),
823 $actionUuid,
824 );
825 $connector = $this->getConnector();
826 if ($connector instanceof Connector)
827 {
828 $connector->onVoteStop($this);
829 }
830 }
831
836 public function offsetExists($offset)
837 {
838 if (is_array($this->attach) && array_key_exists($offset, $this->attach) || is_object($this->vote) && isset($this->vote[$offset]))
839 return true;
840 if ($offset == "VOTE_ID" && is_object($this->vote))
841 return true;
842 return false;
843 }
844
849 public function offsetGet($offset)
850 {
851 if (is_array($this->attach) && array_key_exists($offset, $this->attach))
852 return $this->attach[$offset];
853 if (is_object($this->vote))
854 {
855 if (isset($this->vote[$offset]))
856 return $this->vote[$offset];
857 if ($offset == "VOTE_ID")
858 return $this->vote["ID"];
859 }
860 return null;
861 }
862
870 public function offsetSet($offset, $value)
871 {
872 throw new NotSupportedException('Model provide ArrayAccess only for reading');
873 }
874
881 public function offsetUnset($offset)
882 {
883 throw new NotSupportedException('Model provide ArrayAccess only for reading');
884 }
885
890 public static function loadFromId($id, $shouldBeNewIfIdIsNull = false)
891 {
892 return parent::loadFromId($id, true);
893 }
894
896 {
897 $eventId = $this->getUserEventId($userId);
898 if (!$eventId)
899 {
900 return [];
901 }
902
903 return $this->getUserEventAnswers($eventId)->stat;
904 }
905
906 public function getUserEventAnswers(int $eventId): UserBallot
907 {
908 $dbRes = EventTable::getList(array(
909 "select" => [
910 "V_" => "*",
911 "Q_" => "QUESTION.*",
912 "A_" => "QUESTION.ANSWER.*",
913 "U_ID" => "USER.USER.ID",
914 ],
915 "filter" => [
916 "ID" => $eventId,
917 "VOTE_ID" => $this["VOTE_ID"],
918 ]
919 ));
920 $questions = $this["QUESTIONS"];
921 $userId = null;
922 $stat = [];
923 $extras = [];
924 if ($dbRes && ($res = $dbRes->fetch()))
925 {
926 $userId = $res["U_ID"];
927 $extras = array(
928 "VISIBLE" => $res["V_VISIBLE"],
929 "VALID" => $res["V_VALID"]
930 );
931 do
932 {
933 if (!array_key_exists($res["Q_QUESTION_ID"], $questions) ||
934 !array_key_exists($res["A_ANSWER_ID"], $questions[$res["Q_QUESTION_ID"]]["ANSWERS"]))
935 continue;
936 if (!array_key_exists($res["Q_QUESTION_ID"], $stat))
937 $stat[$res["Q_QUESTION_ID"]] = array();
938
939 $stat[$res["Q_QUESTION_ID"]][$res["A_ANSWER_ID"]] = array(
940 "EVENT_ID" => $res["A_ID"],
941 "EVENT_QUESTION_ID" => $res["Q_ID"],
942 "ANSWER_ID" => $res["A_ANSWER_ID"],
943 "ID" => $res["A_ID"],
944 "MESSAGE" => $res["A_MESSAGE"]
945 );
946 } while ($res = $dbRes->fetch());
947 }
948
949 return new UserBallot($stat, $extras, $userId);
950 }
951
952 public function recall(int $userId, string $actionUuid = ''): Result
953 {
954 $canRevoteResult = $this->canRevote($userId);
955 if (!$canRevoteResult->isSuccess())
956 {
957 return $canRevoteResult;
958 }
959
960 $result = $this->vote->recall($userId);
961 if ($result->isSuccess())
962 {
963 $this->sendVotingPush($actionUuid);
964 }
965
966 return $result;
967 }
968
969 private function getUserEventId(int $userId): ?int
970 {
971 $eventData = $this->canVote($userId)->getData();
972 $firstKey = array_key_first($eventData);
973 if ($firstKey === null)
974 {
975 return null;
976 }
977
978 return $eventData[$firstKey]['ID'] ?? null;
979 }
980
981 private function sendVotingPush(string $actionUuid): void
982 {
983 (new VoteChangesSender())->sendVoting($this, $actionUuid);
984 }
985
986 public function isFinished(): bool
987 {
988 return $this['DATE_END'] instanceof DateTime && $this['DATE_END']->getTimestamp() <= time();
989 }
990
991 public function isPublicVote(): bool
992 {
993 $anonymity = (int)($this['ANONYMITY'] ?? Anonymity::UNDEFINED);
994
995 return $anonymity === Anonymity::PUBLICLY;
996 }
997
998 public static function generateUid(): string
999 {
1000 return Random::getStringByAlphabet(self::UID_LENGTH, Random::ALPHABET_ALPHALOWER | Random::ALPHABET_NUM);
1001 }
1002}
if(!Loader::includeModule('catalog')) if(!AccessController::getCurrent() ->check(ActionDictionary::ACTION_PRICE_EDIT)) if(!check_bitrix_sessid()) $request
Определения catalog_reindex.php:36
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
getTimestamp()
Определения date.php:218
static $storage
Определения answer.php:133
const TEXT
Определения answertypes.php:19
const TEXTAREA
Определения answertypes.php:20
Определения attach.php:180
getEntityId()
Определения attach.php:587
setStorage($id)
Определения attach.php:262
canEdit($userId)
Определения attach.php:520
isPublicVote()
Определения attach.php:991
static $storage
Определения attach.php:192
offsetUnset($offset)
Определения attach.php:881
offsetExists($offset)
Определения attach.php:836
const UID_LENGTH
Определения attach.php:181
getStorage()
Определения attach.php:543
static $loaded
Определения attach.php:193
stop(string $actionUuid='')
Определения attach.php:815
init()
Определения attach.php:204
save($data, $createdBy=0)
Определения attach.php:693
voteFor(array $request, string $actionUuid='')
Определения attach.php:744
getVoteId()
Определения attach.php:563
$channel
Определения attach.php:190
offsetGet($offset)
Определения attach.php:849
isVotedFor($userId)
Определения attach.php:780
getUserEventAnswers(int $eventId)
Определения attach.php:906
static getData($id)
Определения attach.php:271
static getDataByEntity(array $id)
Определения attach.php:410
checkData(array &$data)
Определения attach.php:648
$connector
Определения attach.php:188
getConnector()
Определения attach.php:531
getUserEventsAnswersStatByUserId(int $userId)
Определения attach.php:895
canRead($userId)
Определения attach.php:485
$attach
Определения attach.php:184
$vote
Определения attach.php:186
fillStatistic()
Определения attach.php:595
resume(string $actionUuid='')
Определения attach.php:795
recall(int $userId, string $actionUuid='')
Определения attach.php:952
getModuleId()
Определения attach.php:571
canRevote($userId)
Определения attach.php:505
offsetSet($offset, $value)
Определения attach.php:870
canReadResult($userId)
Определения attach.php:510
getEntityType()
Определения attach.php:579
isFinished()
Определения attach.php:986
canVote($userId)
Определения attach.php:500
canParticipate($userId)
Определения attach.php:495
static loadFromId($id, $shouldBeNewIfIdIsNull=false)
Определения attach.php:890
exportExcel()
Определения attach.php:769
getAttachId()
Определения attach.php:555
setVote($vote)
Определения attach.php:250
static generateUid()
Определения attach.php:998
static getMap()
Определения attach.php:76
static getIdByUid(string $uid)
Определения attach.php:165
static deleteByFilter(array $filter)
Определения attach.php:140
static getList(array $parameters=array())
Определения attach.php:129
static getTableName()
Определения attach.php:67
static loadFromId($id, $shouldBeNewIfIdIsNull=false)
Определения baseobject.php:141
Определения channel.php:225
static getExtrasFieldName($id, $name)
Определения event.php:461
static getMessageFieldName($id, $questionId, $answerId)
Определения event.php:457
static getDataFromRequest($id, array $request)
Определения event.php:466
static getFieldName($id, $questionId)
Определения event.php:453
static $storage
Определения question.php:178
const COMPATIBILITY
Определения questiontypes.php:19
static getCurrent()
Определения user.php:312
$data['IS_AVAILABLE']
Определения .description.php:13
if(!defined("ADMIN_AJAX_MODE") &&(($_REQUEST["mode"] ?? '') !='excel')) $buffer
Определения epilog_admin_after.php:40
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$res
Определения filter_act.php:7
$result
Определения get_property_values.php:14
$uid
Определения hot_keys_act.php:8
$filter
Определения iblock_catalog_list.php:54
Определения anonymity.php:8
if(empty($signedUserToken)) $key
Определения quickway.php:257
</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."%"
Определения waybill.php:936
$val
Определения options.php:1793
$dbRes
Определения yandex_detail.php:168