• Модуль: imopenlines
  • Путь к файлу: ~/bitrix/modules/imopenlines/lib/config.php
  • Класс: BitrixImOpenLinesConfig
  • Вызов: Config::create
public function create($params = [])
{
	$fields = $this->prepareFields($params);

	if ($this->userId)
	{
		$fields['MODIFY_USER_ID'] = $this->userId;
	}

	$result = ModelConfigTable::add($fields);
	if(!$result->isSuccess())
	{
		$this->error = new BasicError(__METHOD__, 'ADD_ERROR', Loc::getMessage('IMOL_ADD_ERROR'));
		return false;
	}
	$configId = (int)$result->getId();
	$data = $result->getData();


	ConfigStatistic::add($configId);

	$queueManager = new QueueManager($configId);
	if (isset($params['QUEUE']) && is_array($params['QUEUE']) && !empty($params['QUEUE']))
	{
		if(!isset($params['QUEUE_USERS_FIELDS']))
		{
			$params['QUEUE_USERS_FIELDS'] = false;
		}

		$queueManager->compatibleUpdate($params['QUEUE'], $params['QUEUE_USERS_FIELDS']);
	}
	else
	{
		$queueManager->update([]);
	}

	CGlobalCounter::Increment('imol_line_number', CGlobalCounter::ALL_SITES, false);
	if ($fields['TEMPORARY'] == 'Y')
	{
		$date = new DateTime();
		$date->add('8 HOUR');
		CAgent::AddAgent('BitrixImOpenLinesConfig::deleteTemporaryConfigAgent('.$configId.');', "imopenlines", "N", 28800, "", "Y", $date);
	}

	self::sendUpdateForQueueList(Array(
		'ID' => $configId,
		'NAME' => $data['LINE_NAME'],
		'SESSION_PRIORITY' => $data['SESSION_PRIORITY'],
		'QUEUE_TYPE' => $data['QUEUE_TYPE'],
	));

	if($fields['QUICK_ANSWERS_IBLOCK_ID'] > 0)
	{
		ListsDataManager::updateIblockRights($fields['QUICK_ANSWERS_IBLOCK_ID']);
	}

	$eventData = [
		'line' => $configId
	];
	$event = new MainEvent('imopenlines', self::EVENT_IMOPENLINE_CREATE, $eventData);
	$event->send();

	return $configId;
}