Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
helper.php
1<?php
2namespace Bitrix\B24Connector;
3
6use Bitrix\Main\Page\Asset;
8
9Loc::loadMessages(__FILE__);
10
16class Helper
17{
24 public static function onBuildGlobalMenu(&$aGlobalMenu, &$aModuleMenu)
25 {
26 global $APPLICATION;
27
28 $moduleAccess = $APPLICATION->GetGroupRight('b24connector');
29
30 if($moduleAccess < "R")
31 return false;
32
33 $menu = array(
34 "parent_menu" => "global_menu_b24connector",
35 "section" => "b24connector",
36 "sort" => 100,
37 "text" => Loc::getMessage("B24C_HLP_INTEGRATION"),
38 "icon" => "b24connector_menu_icon",
39 "page_icon" => "b24connector_page_icon",
40 "items_id" => "menu_b24connector",
41 "url" => "b24connector_b24connector.php?lang=".LANGUAGE_ID,
42 "more_url" => array("b24connector_chat.php", "sale_crm.php"),
43 "items" => array(),
44 );
45
46 $menu["items"][] = array(
47 "text" => Loc::getMessage("B24C_HLP_BUTTONS"),
48 "url" => "/bitrix/admin/b24connector_buttons.php?lang=".LANGUAGE_ID,
49 "icon" => "b24connector_menu_icon_butt",
50 "more_url" => array(
51 "b24connector_buttons.php"
52 )
53 );
54
55 $menu["items"][] = array(
56 "text" => Loc::getMessage("B24C_HLP_CHAT"),
57 "url" => "/bitrix/admin/b24connector_chat.php?lang=".LANGUAGE_ID,
58 "icon" => "b24connector_menu_icon_chat",
59 "more_url" => array(
60 "b24connector_chat.php"
61 )
62 );
63
64 $menu["items"][] = array(
65 "text" => Loc::getMessage('B24C_HLP_RECALL'),
66 "url" => "/bitrix/admin/b24connector_recall.php?lang=".LANGUAGE_ID,
67 "icon" => "b24connector_menu_icon_recall",
68 "more_url" => array(
69 "b24connector_recall.php"
70 )
71 );
72
73 $menu["items"][] = array(
74 "text" => Loc::getMessage('B24C_HLP_CRM_FORM'),
75 "url" => "/bitrix/admin/b24connector_crm_forms.php?lang=".LANGUAGE_ID,
76 "icon" => "b24connector_menu_icon_cform",
77 "more_url" => array(
78 "b24connector_crm_forms.php"
79 )
80 );
81
82 $menu["items"][] = array(
83 "text" => Loc::getMessage('B24C_HLP_OL'),
84 "url" => "/bitrix/admin/b24connector_open_lines.php?lang=".LANGUAGE_ID,
85 "icon" => "b24connector_menu_icon_ol",
86 "more_url" => array(
87 "b24connector_open_lines.php"
88 )
89 );
90
91 $menu["items"][] = array(
92 "text" => Loc::getMessage('B24C_HLP_TELEPHONY'),
93 "url" => "/bitrix/admin/b24connector_telefonia.php?lang=".LANGUAGE_ID,
94 "icon" => "b24connector_menu_icon_telephony",
95 "more_url" => array(
96 "b24connector_telefonia.php"
97 )
98 );
99
100 return array(
101 "global_menu_b24connector" => array(
102 "menu_id" => "b24connector",
103 "text" => Loc::getMessage("B24C_HLP_GM_TEXT"),
104 "title" => Loc::getMessage("B24C_HLP_GM_TITLE"),
105 "sort" => 210,
106 "items_id" => "global_menu_b24connector",
107 "help_section" => "b24connector",
108 "items" => array($menu)
109 ));
110 }
111
116 public static function onBeforeProlog()
117 {
118 global $APPLICATION;
119
120 if(defined('ADMIN_SECTION') && ADMIN_SECTION === true)
121 return;
122
123 if (defined('B24CONNECTOR_SKIP') && B24CONNECTOR_SKIP === true)
124 {
125 return;
126 }
127
128 if($connection = Connection::getFields())
129 {
130 $result = '';
131
132 $restrictions = ButtonSiteTable::getAllRestrictions();
133
134 $dbRes = ButtonTable::getList(array(
135 'filter' => array(
136 '=APP_ID' => $connection['ID']
137 )
138 ));
139
140 while ($button = $dbRes->fetch())
141 {
142 $allowedSites = $restrictions[$button['ID']] ?? [SITE_ID];
143
144 if($button['SCRIPT'] !== '' && in_array(SITE_ID, $allowedSites))
145 {
146 $result .= $button['SCRIPT']."\n";
147 }
148 }
149
150 if ($result !== '')
151 {
152 Asset::getInstance()->addString($result, false, AssetLocation::BODY_END);
153
154 ob_start();
155 $APPLICATION->IncludeComponent('bitrix:b24connector.openline.info', '', ['COMPOSITE_FRAME_TYPE' => 'STATIC']);
156 $saoRes = ob_get_contents();
157 ob_end_clean();
158
159 Asset::getInstance()->addString($saoRes, false, AssetLocation::BODY_END);
160 }
161 }
162 }
163}
static onBuildGlobalMenu(&$aGlobalMenu, &$aModuleMenu)
Definition helper.php:24
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29