4use Bitrix\Main\Entity\ExpressionField;
23 public static function add(array $fields)
26 $entityType = $fields[
'ENTITY_TYPE'];
27 $entityId = $fields[
'ENTITY_ID'];
30 ($fields[
'ENTITY_TYPE'] !== self::ENTITY_TYPE_VIDEOCONF && empty($entityId))
41 $result = \Bitrix\Im\Model\AliasTable::add(Array(
43 'ENTITY_TYPE' => $entityType,
44 'ENTITY_ID' => $entityId,
47 if (!$result->isSuccess())
52 return $result->getId();
57 $alias = \Bitrix\Im\Alias::prepareAlias(self::generateUnique());
58 $fields[
'ALIAS'] = $alias;
69 'LINK' => self::getPublicLink($fields[
'ENTITY_TYPE'], $alias)
73 public static function update($id, $fields)
80 if (isset($fields[
'ALIAS']))
90 if (isset($fields[
'ENTITY_TYPE']))
92 $update[
'ENTITY_TYPE'] = $fields[
'ENTITY_TYPE'];
94 if (isset($fields[
'ENTITY_ID']))
96 $update[
'ENTITY_ID'] = $fields[
'ENTITY_ID'];
102 \Bitrix\Im\Model\AliasTable::update($id, $update);
109 if ($filter == self::FILTER_BY_ALIAS)
117 $aliasData[
'ID'] = intval($id);
120 \Bitrix\Im\Model\AliasTable::delete($aliasData[
'ID']);
125 public static function get($alias)
133 $query = \Bitrix\Im\Model\AliasTable::query();
135 $connection = \Bitrix\Main\Application::getConnection();
136 if ($connection instanceof \
Bitrix\Main\DB\PgsqlConnection)
138 $alias = $connection->getSqlHelper()->forSql($alias);
141 ->whereExpr(
"LOWER(%s) = LOWER('{$alias}')", [
'ALIAS'])
148 ->where(
'ALIAS', $alias)
152 $result = $query->exec()->fetch();
166 $query = \Bitrix\Im\Model\AliasTable::query();
172 $connection = \Bitrix\Main\Application::getConnection();
173 if ($connection instanceof \
Bitrix\Main\DB\PgsqlConnection)
175 $code = $connection->getSqlHelper()->forSql($code);
176 $query->whereExpr(
"LOWER(%s) = LOWER('{$code}')", [
'ALIAS']);
180 $query->where(
'ALIAS', $code);
183 return $query->exec()->fetch();
188 $result = \Bitrix\Im\Model\AliasTable::getList(Array(
189 'filter' => [
'=ENTITY_TYPE' => $entityType,
'=ENTITY_ID' => $entityId]
204 $alias = preg_replace(
"/[^\.\-0-9a-zA-Z]+/",
"", $alias);
205 $alias = mb_substr($alias, 0, 255);
214 if ($type === self::ENTITY_TYPE_VIDEOCONF || $type === self::ENTITY_TYPE_JITSICONF)
218 else if ($type === self::ENTITY_TYPE_LIVECHAT)
223 return \Bitrix\Im\Common::getPublicDomain() . $path . $alias;
228 if (\
Bitrix\Main\Loader::includeModule(
'security'))
230 return \Bitrix\Main\Security\Random::getString(8,
true);
234 return mb_substr(uniqid(),-8);
const ENTITY_TYPE_LIVECHAT
static getByIdAndCode($id, $code)
const ENTITY_TYPE_VIDEOCONF
static update($id, $fields)
static addUnique(array $fields)
const ENTITY_TYPE_JITSICONF
static getByEntity($entityType, $entityId)
const ENTITY_TYPE_OPEN_LINE
static prepareAlias($alias)
static getPublicLink($type, $alias)
static add(array $fields)