5use Bitrix\Im\Model\EO_LinkReminder_Collection;
8use Bitrix\Im\V2\Common\SidebarFilterProcessorTrait;
27 use SidebarFilterProcessorTrait;
31 return ReminderItem::class;
34 public static function find(
41 $context = $context ?? Locator::getContext();
43 $reminderOrder = [
'ID' =>
'DESC'];
45 if (isset($order[
'ID']))
47 $reminderOrder[
'ID'] = $order[
'ID'];
51 ->setSelect([
'ID',
'CHAT_ID',
'AUTHOR_ID',
'DATE_CREATE',
'MESSAGE_ID',
'DATE_REMIND',
'IS_REMINDED',
'MESSAGE'])
52 ->where(
'AUTHOR_ID', $context->getUserId())
53 ->setOrder($reminderOrder)
57 $query->setLimit($limit);
59 static::processFilters($query, $filter, $reminderOrder);
61 return static::initByEntityCollection($query->fetchCollection());
66 $reminderCollection =
new static();
68 foreach ($entityCollection as $entity)
73 return $reminderCollection;
79 ->setSelect([
'ID',
'CHAT_ID',
'AUTHOR_ID',
'DATE_CREATE',
'MESSAGE_ID',
'DATE_REMIND',
'IS_REMINDED'])
84 if ($entities ===
null)
89 $links = static::initByEntityCollection($entities);
91 foreach ($links as $link)
93 $link->setEntity($message);
101 $links = static::getByMessageIdsAndAuthorId($messages->
getIds(), $userId);
103 foreach ($links as $link)
105 $link->setEntity($messages[$link->getMessageId()]);
113 if (empty($messageIds))
119 ->setSelect([
'ID',
'CHAT_ID',
'AUTHOR_ID',
'DATE_CREATE',
'MESSAGE_ID',
'DATE_REMIND',
'IS_REMINDED'])
120 ->whereIn(
'MESSAGE_ID', $messageIds)
121 ->where(
'AUTHOR_ID', $userId)
125 if ($entities ===
null)
130 return static::initByEntityCollection($entities);
136 ->setSelect([
'ID',
'CHAT_ID',
'AUTHOR_ID',
'DATE_CREATE',
'MESSAGE_ID',
'DATE_REMIND',
'IS_REMINDED',
'MESSAGE'])
137 ->where(
'DATE_REMIND',
'<',
new DateTime())
138 ->where(
'IS_REMINDED',
false)
142 if ($entities ===
null)
147 return static::initByEntityCollection($entities);
154 foreach ($this as $reminderItem)
156 $messageCollection->add($reminderItem->getEntity());
159 return $messageCollection;
164 $excludedList[] = ReminderPopupItem::class;
166 if (!in_array(FilePopupItem::class, $excludedList,
true))
171 return parent::getPopupData($excludedList);
176 if (!isset($option[
'WITHOUT_MESSAGES']) || $option[
'WITHOUT_MESSAGES'] !==
'Y')
181 return parent::toRestFormat($option);
186 static::processSidebarFilters(
190 [
'AUTHOR_ID' =>
'MESSAGE.AUTHOR_ID',
'DATE_CREATE' =>
'MESSAGE.DATE_CREATE']
193 if (isset($filter[
'SEARCH_MESSAGE']))
195 $query->whereLike(
'MESSAGE.MESSAGE',
"%{$filter['SEARCH_MESSAGE']}%");
198 if (isset($filter[
'IS_REMINDED']))
200 $query->where(
'IS_REMINDED', (
bool)$filter[
'IS_REMINDED']);
static getByMessageIdsAndAuthorId(array $messageIds, int $userId)
static find(array $filter, array $order, ?int $limit=null, ?Context $context=null)
toRestFormat(array $option=[])
static getCollectionElementClass()
static processFilters(Query $query, array $filter, array $order)
getPopupData(array $excludedList=[])
static initByEntityCollection(EO_LinkReminder_Collection $entityCollection)
static getByMessagesAndAuthorId(MessageCollection $messages, int $userId)
static getByMessage(Message $message)
static initByEntity(EO_LinkReminder $entity)