Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/bitrix/ext_www/ilovecveti.ru/bitrix/modules/sproduction.datasync/lib/ |
Upload File : |
<?php /** * Event handlers of portal * * @mail support@s-production.online * @link s-production.online */ namespace SProduction\Datasync; use Bitrix\Main, Bitrix\Main\Type, Bitrix\Main\Entity, Bitrix\Main\Localization\Loc, Bitrix\Main\SiteTable, Bitrix\Sale; Loc::loadMessages(__FILE__); class PortalHandlers { const MODULE_ID = 'sproduction.datasync'; public const EVENTS_HANDLER = '/bitrix/sprod_dsync_handler.php'; /** * Listen events of the portal */ public static function reg() { // $sync_direction = Settings::get('direction'); // if ( ! $sync_direction || $sync_direction == 'full' || $sync_direction == 'ctos') { // try { // Rest::execute('event.bind', [ // 'event' => 'ONCRMPRODUCTUPDATE', // 'handler' => self::getCrmHandlersLink(), // ]); // } catch (\Exception $e) { // } // PortalOfflineEvents::eventsBind(); // } } /** * Check portal listeners */ public static function check() { $is_exist = false; $list = Rest::execute('event.get'); if (is_array($list) && ! empty($list)) { $e_add_exist = false; $e_upd_exist = false; foreach ($list as $event) { if ($event['event'] == 'ONCRMPRODUCTUPDATE' && $event['handler'] == self::getLink()) { $e_upd_exist = true; } } if ($e_upd_exist) { $is_exist = true; } } return $is_exist; } /** * Remove portal listeners */ public static function unreg() { try { Rest::execute('event.unbind', [ 'event' => 'ONCRMPRODUCTUPDATE', 'handler' => self::getLink(), ]); } catch (\Exception $e) { } PortalOfflineEvents::eventsUnbind(); } /** * Get portal listeners */ public static function getList() { $list = [ 'add' => [], 'update' => [], ]; $full_list = Rest::execute('event.get'); if (is_array($full_list) && ! empty($full_list)) { foreach ($full_list as $event) { if ($event['event'] == 'ONCRMDEALUPDATE' && $event['handler'] == self::getLink()) { $list['update'][] = $event; } if ($event['event'] == 'ONCRMDEALADD' && $event['handler'] == self::getLink()) { $list['add'][] = $event; } } } return $list; } public static function getLink() { $link = Controller::getServerAddr() . self::EVENTS_HANDLER; return $link; } }