25 use SidebarFilterProcessorTrait;
26 use MigrationStatusCheckerTrait;
32 return FileItem::class;
35 public static function find(
37 array $order = [
'ID' =>
'DESC'],
42 $context = $context ?? Locator::getContext();
44 $fileOrder = [
'ID' =>
'DESC'];
46 if (isset($order[
'ID']))
48 $fileOrder[
'ID'] = $order[
'ID'];
51 $query = LinkFileTable::query();
52 static::addRightsCheckToQuery($query, $context->getUserId(), [
'FILE.ID',
'FILE.CREATED_BY']);
54 ->setSelect([
'ID',
'DISK_FILE_ID',
'SUBTYPE',
'AUTHOR_ID',
'MESSAGE_ID',
'CHAT_ID',
'DATE_CREATE'])
55 ->setOrder($fileOrder)
59 $query->setLimit($limit);
61 static::processFilters($query, $filter, $fileOrder);
62 $collection =
new static($query->fetchCollection());
63 $collection->fillFiles();
72 $entities = \Bitrix\Im\V2\Entity\File\FileCollection::initByDiskFilesIds($diskFilesIds);
74 foreach ($this as $file)
76 if ($entities->getById($file->getEntityId()) !==
null)
78 $file->setEntity($entities->getById($file->getEntityId()));
89 return parent::getPopupData($excludedList)->merge($data);
94 if (!static::isMigrationFinished())
99 return parent::save($isGroupSave);
104 static::processSidebarFilters($query, $filter, $order);
106 if (isset($filter[
'SEARCH_FILE_NAME']))
108 $query->whereLike(
'FILE.NAME',
"{$filter['SEARCH_FILE_NAME']}%");
111 if (isset($filter[
'SUBTYPE']))
113 if (is_array($filter[
'SUBTYPE']))
115 $subtypes = array_filter($filter[
'SUBTYPE'],
static fn (
string $subtype) => FileItem::isSubtypeValid($subtype));
116 $query->whereIn(
'SUBTYPE', $subtypes);
118 elseif (FileItem::isSubtypeValid($filter[
'SUBTYPE']))
120 $query->where(
'SUBTYPE', $filter[
'SUBTYPE']);
125 protected static function addRightsCheckToQuery(
Query $query,
int $userId, array $specificColumns):
Query
127 $securityContext = new \Bitrix\Disk\Security\DiskSecurityContext($userId);
129 $parameters = \Bitrix\Disk\Driver::getInstance()
131 ->addRightsCheck($securityContext, $parameters, $specificColumns)
135 $field = $parameters[
'runtime'][0];
136 $field->configureValueType(Fields\IntegerField::class);
139 ->where(
'RIGHTS_CHECK', 1);
registerRuntimeField($name, $fieldInfo=null)