- Модуль: imopenlines
- Путь к файлу: ~/bitrix/modules/imopenlines/lib/config.php
- Класс: BitrixImOpenLinesConfig
- Вызов: Config::getList
public function getList(array $params, $options = [])
{
if(
isset($options['QUEUE']) &&
(string)$options['QUEUE'] === 'Y'
)
{
$withQueue = true;
}
else
{
$withQueue = false;
}
if(
isset($options['CONFIG_QUEUE']) &&
(string)$options['CONFIG_QUEUE'] === 'Y'
)
{
$withConfigQueue = true;
}
else
{
$withConfigQueue = false;
}
$checkPermission = false;
$permissionAllowedUsers = [];
if (isset($options['CHECK_PERMISSION']))
{
$permission = SecurityPermissions::createWithUserId($this->userId);
$permissionAllowedUsers = SecurityHelper::getAllowedUserIds(
$this->userId,
$permission->getPermission(
SecurityPermissions::ENTITY_LINES,
$options['CHECK_PERMISSION']
)
);
if (is_array($permissionAllowedUsers))
{
$checkPermission = true;
$permissionAccessConfig = [];
if (!empty($permissionAllowedUsers))
{
$orm = ModelQueueTable::getList([
'filter' => [
'=USER_ID' => $permissionAllowedUsers
]
]);
while ($row = $orm->fetch())
{
$permissionAccessConfig[$row['CONFIG_ID']] = true;
}
}
}
}
$configs = [];
$orm = ModelConfigTable::getList($params);
while ($config = $orm->fetch())
{
if (
$checkPermission
&& !isset($permissionAccessConfig[$config['ID']])
&& !in_array($config['MODIFY_USER_ID'], $permissionAllowedUsers)
)
{
continue;
}
if (isset($config['WORKTIME_DAYOFF']))
{
$config['WORKTIME_DAYOFF'] = explode(',', $config['WORKTIME_DAYOFF']);
}
if (isset($config['WORKTIME_HOLIDAYS']))
{
$config['WORKTIME_HOLIDAYS'] = explode(',', $config['WORKTIME_HOLIDAYS']);
}
if ($withQueue === true)
{
$config['QUEUE'] = [];
$config['QUEUE_USERS_FIELDS'] = [];
$ormQueue = ModelQueueTable::getList([
'filter' => ['=CONFIG_ID' => $config['ID']],
'order' => [
'SORT' => 'ASC',
'ID' => 'ASC'
]
]);
while ($row = $ormQueue->fetch())
{
$config['QUEUE'][] = $row['USER_ID'];
$config['QUEUE_USERS_FIELDS'][$row['USER_ID']] = [
'USER_NAME' => $row['USER_NAME'],
'USER_WORK_POSITION' => $row['USER_WORK_POSITION'],
'USER_AVATAR' => $row['USER_AVATAR'],
'USER_AVATAR_ID' => $row['USER_AVATAR_ID']
];
}
}
if ($withConfigQueue === true)
{
$config['CONFIG_QUEUE'] = [];
$ormConfigQueue = ConfigQueueTable::getList([
'filter' => ['=CONFIG_ID' => $config['ID']],
'order' => [
'SORT' => 'ASC',
'ID' => 'ASC'
]
]);
while ($row = $ormConfigQueue->fetch())
{
$config['CONFIG_QUEUE'][] = [
'ENTITY_ID' => $row['ENTITY_ID'],
'ENTITY_TYPE' => $row['ENTITY_TYPE'],
];
}
}
$configs[] = $config;
}
return $configs;
}