%PDF- %PDF-
Server IP : 37.220.80.31 / Your IP : 18.191.39.181 Web Server : Apache/2.4.52 (Ubuntu) System : Linux 3051455-guretool.twc1.net 5.15.0-107-generic #117-Ubuntu SMP Fri Apr 26 12:26:49 UTC 2024 x86_64 User : www-root ( 1010) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/www-root/data/www/dev.artlot24.ru/bitrix/modules/messageservice/lib/ |
Upload File : |
<?php namespace Bitrix\MessageService; use Bitrix\Main; use Bitrix\Bizproc; class Converter { public static function onInstallModule() { static::convertBizprocProviders(); static::convertOptions(); } public static function convertBizprocProviders() { if (!Main\Loader::includeModule('bizproc')) return false; $providerList = Bizproc\RestProviderTable::getList(); while ($row = $providerList->fetch()) { static::addRestSender(array( 'APP_ID' => $row['APP_ID'], 'APP_NAME' => $row['APP_NAME'], 'CODE' => $row['CODE'], 'TYPE' => $row['TYPE'], 'HANDLER' => $row['HANDLER'], 'NAME' => $row['NAME'], 'DESCRIPTION' => $row['DESCRIPTION'] )); } return true; } public static function convertOptions() { $checkList = array('smsru', 'twilio'); foreach ($checkList as $senderId) { $optionString = Main\Config\Option::get('crm', 'integration.sms.'.$senderId); if (!$optionString) continue; $options = unserialize($optionString, ['allowed_classes' => false]); if (!is_array($options)) continue; if (isset($options['default_sender'])) { $options['default_from'] = $options['default_sender']; unset($options['default_sender']); } Main\Config\Option::set('messageservice','sender.sms.'.$senderId, serialize($options)); } } private static function addRestSender($params) { $iterator = Internal\Entity\RestAppTable::getList(array( 'select' => array('ID'), 'filter' => array( '=APP_ID' => $params['APP_ID'], '=CODE' => $params['CODE'] ) )); $result = $iterator->fetch(); if ($result) { return true; } $senderLang = array( 'NAME' => $params['NAME'], 'DESCRIPTION' => $params['DESCRIPTION'], 'APP_NAME' => $params['APP_NAME'] ); unset($params['NAME'], $params['DESCRIPTION'], $params['APP_NAME']); $params['AUTHOR_ID'] = 0; $result = Internal\Entity\RestAppTable::add($params); if ($result->getErrors()) { return false; } $senderLang['APP_ID'] = $result->getId(); static::addRestSenderLang($senderLang); return true; } private static function addRestSenderLang($langFields) { $langData = array(); foreach ($langFields['NAME'] as $langId => $langName) { $langCode = mb_strtolower($langId); if ($langCode === '*') $langCode = '**'; $langData[$langCode] = array( 'APP_ID' => $langFields['APP_ID'], 'LANGUAGE_ID' => $langCode, 'NAME' => $langFields['NAME'][$langId], 'DESCRIPTION' => isset($langFields['DESCRIPTION'][$langId]) ? (string)$langFields['DESCRIPTION'][$langId] : null, 'APP_NAME' => isset($langFields['APP_NAME'][$langId]) ? (string)$langFields['APP_NAME'][$langId] : null, ); if (!isset($langData['**'])) { $langData['**'] = $langData[$langCode]; $langData['**']['LANGUAGE_ID'] = '**'; } } foreach ($langData as $toAdd) { Internal\Entity\RestAppLangTable::add($toAdd); } } }