- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/lib/sitebutton/preset.php
- Класс: Bitrix\Crm\SiteButton\Preset
- Вызов: Preset::installVersion1
static function installVersion1()
{
$serverAddress = ResourceManager::getServerAddress() . '/bitrix/components/bitrix/crm.button.edit/templates/.default/images/';
$defaultCondition = array(
'ICON' => $serverAddress . 'upload-girl-mini-1.png',
'NAME' => Loc::getMessage('CRM_BUTTON_PRESET_HELLO_DEF_NAME'),
'TEXT' => Loc::getMessage('CRM_BUTTON_PRESET_HELLO_DEF_TEXT'),
'DELAY' => 1,
'PAGES' => array(
'LIST' => array()
),
);
$dataDb = Internals\ButtonTable::getList(array(
'select' => array('ID', 'SETTINGS'),
'filter' => array('=IS_SYSTEM' => 'Y'),
));
while($buttonData = $dataDb->fetch())
{
if (!is_array($buttonData['SETTINGS']))
{
$buttonData['SETTINGS'] = array();
}
$needUpdate = false;
if (empty($buttonData['SETTINGS']['HELLO']))
{
$needUpdate = true;
$buttonData['SETTINGS']['HELLO'] = array(
'ACTIVE' => true,
'MODE' => 'EXCLUDE',
'CONDITIONS' => array($defaultCondition)
);
}
else
{
$hello = $buttonData['SETTINGS']['HELLO'];
if (!$hello['ACTIVE'])
{
$needUpdate = true;
$buttonData['SETTINGS']['HELLO']['ACTIVE'] = true;
}
if (!$hello['MODE'])
{
$needUpdate = true;
$buttonData['SETTINGS']['HELLO']['MODE'] = 'EXCLUDE';
}
if (!is_array($hello['CONDITIONS']) || count($hello['CONDITIONS']) == 0)
{
$needUpdate = true;
$hello['CONDITIONS'] = array($defaultCondition);
}
}
if ($needUpdate)
{
$updateResult = Internals\ButtonTable::update(
$buttonData['ID'],
array('SETTINGS' => $buttonData['SETTINGS'])
);
if ($updateResult->isSuccess())
{
Manager::updateScriptCache($buttonData['ID']);
}
}
}
}