1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
mp_notifications.php
См. документацию.
1<?php
8
10
11require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/classes/general/update_client_partner.php");
12require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/classes/general/admin_informer.php");
13
15{
16 public static function OnAdminInformerInsertItemsHandlerMP()
17 {
18 global $USER;
19 if(\Bitrix\Main\Application::getInstance()->getLicense()->isDemoKey())
20 {
21 return false;
22 }
23 if(!$USER->CanDoOperation('install_updates'))
24 {
25 return false;
26 }
27 $daysCheck = intval(COption::GetOptionString('main', 'update_autocheck', '1'));
28 if($daysCheck > 0)
29 {
30 $arModulesResult = unserialize(COption::GetOptionString("main", "last_mp_modules_result"), ['allowed_classes' => false]);
31 if(!is_array($arModulesResult))
32 {
33 $arModulesResult = array("check_date" => 0);
34 }
35
36 if ($arModulesResult["check_date"] + 86400*$daysCheck < time())
37 {
38 $arInstalledModules = self::getClientInstalledModules();
39 $arModulesUpdates = ($arInstalledModules ? self::checkUpdates($arInstalledModules, 2, $daysCheck) : array());
40 $arDateEndModules = ($arInstalledModules ? self::checkModulesEndDate($arInstalledModules, $daysCheck) : array());
41 $arNewPartnersModules = ($arInstalledModules ? self::checkUpdates($arInstalledModules, 1, $daysCheck) : array());
42 $arModulesResult = array(
43 "check_date" => time(),
44 'update_module' => $arModulesUpdates,
45 'end_update' => $arDateEndModules,
46 'new_module' => $arNewPartnersModules,
47 );
48 COption::SetOptionString(
49 'main',
50 'last_mp_modules_result',
51 serialize($arModulesResult)
52 );
53 }
54 self::addMpNotifications($arModulesResult);
55 }
56 else
57 {
58 return false;
59 }
60 }
61
62 //checks for modules the end of the update period
63 public static function checkModulesEndDate($arRequestedModules, $daysCheck)
64 {
65 $errorMessage = "";
66 $stableVersionsOnly = COption::GetOptionString("main", "stable_versions_only", "Y");
69 LANGUAGE_ID,
70 $stableVersionsOnly,
71 $arRequestedModules,
72 Array("fullmoduleinfo" => "Y")
73 );
74 $arEndUpdateModules = array();
75 if ($arUpdateList)
76 {
77 if (isset($arUpdateList["MODULE"]) && is_array($arUpdateList["MODULE"]))
78 {
79 $daysCheck += 30;
80 $curDateFrom = new Date;
81 $curDateTo = new Date;
82 $curDateFrom = $curDateFrom->add("30 days");
83 $curDateTo = $curDateTo->add(strval($daysCheck)." days");
84
85 for ($i = 0, $cnt = count($arUpdateList["MODULE"]); $i < $cnt; $i++)
86 {
87 if ($arUpdateList["MODULE"][$i]['@']['DATE_TO'] <> '' && Date::isCorrect($arUpdateList["MODULE"][$i]['@']['DATE_TO']))
88 {
89 $dateTo = new Date($arUpdateList["MODULE"][$i]['@']['DATE_TO']);
90 $ID = $arUpdateList["MODULE"][$i]["@"]["ID"];
91 if ($dateTo >= $curDateFrom && $dateTo < $curDateTo)
92 {
93 $arEndUpdateModules[$ID] = array(
94 'ID' => $arUpdateList["MODULE"][$i]["@"]["ID"],
95 'NAME' => $arUpdateList["MODULE"][$i]["@"]["NAME"],
96 'VERSION' => $arUpdateList["MODULE"][$i]["@"]["DATE_TO"],
97 'DATE_TO' => $arUpdateList["MODULE"][$i]["@"]["DATE_TO"],
98 );
99 }
100 }
101 }
102 }
103 }
104 return $arEndUpdateModules;
105 }
106
107 //check updates and new modules
108 public static function checkUpdates($arModules, $searchType, $daysCheck){
109 $stableVersionsOnly = COption::GetOptionString("main", "stable_versions_only", "Y");
110 $strError_tmp = "";
112 $strError_tmp,
113 LANGUAGE_ID,
114 $stableVersionsOnly,
115 array(),
116 array(
117 "search_module_id" => (is_array($arModules) ? implode(",", $arModules) : $arModules),
118 "search_page" => "SEARCH_NEW",
119 "search_category" => $daysCheck,
120 "search_type" => $searchType,
121 )
122 );
123 $content = CUpdateClientPartner::__GetHTTPPage("SEARCH_NEW", $strQuery, $strError_tmp);
124 $arResult = Array();
125 $arResultModules = array();
126
127 if ($strError_tmp == '')
128 {
130 if (!empty($arResult['DATA']['#']['MODULE']) && is_array($arResult['DATA']['#']['MODULE']))
131 {
132 foreach ($arResult['DATA']['#']['MODULE'] as $arModule)
133 {
134 if ($searchType == 1)
135 {
136 $arResultModules[$arModule['@']['PARTNER_ID']][] = $arModule['@'];
137 }
138 else
139 {
140 $arResultModules[$arModule['@']['ID']] = $arModule['@'];
141 }
142 }
143 }
144 }
145 return $arResultModules;
146 }
147
148 //add notifications to admin informer
149 public static function addNotificationsToInformer($arModules, $arNotifierText, $arrayId, $serverName){
150 foreach ($arModules as $arModule)
151 {
152 $moduleLink = (($arrayId == 'end_update') ? '/bitrix/admin/partner_modules.php' : '/bitrix/admin/update_system_market.php?module='.$arModule['ID']);
154 'TITLE' => GetMessage($arNotifierText['TITLE']),
155 'COLOR' => 'green',
156 'FOOTER' => "<a href=\"javascript:void(0)\" onclick=\"hideMpNotification(this, '".
157 CUtil::JSEscape($arModule['ID']).
158 "', '".
159 CUtil::JSEscape($arrayId).
160 "')\" ".
161 "style=\"float: right !important; font-size: 0.8em !important;\">".
162 GetMessage('TOP_PANEL_AI_MODULE_UPDATE_BUTTON_HIDE').
163 "</a>".
164 "<a href=\"".
165 $serverName.
166 $moduleLink.
167 "\" target=\"_blank\" ".
168 "onclick=\"hideMpNotification(this, '".
169 CUtil::JSEscape($arModule['ID']).
170 "', '".
171 CUtil::JSEscape($arrayId).
172 "')\">".
173 GetMessage('TOP_PANEL_AI_MODULE_UPDATE_BUTTON_VIEW').
174 "</a>",
175 'ALERT' => true,
176 'HTML' => GetMessage($arNotifierText['HTML'], array("#NAME#" => $arModule["NAME"], "#PARTNER#" => $arModule["PARTNER"])).self::addJsToInformer(),
177 );
179 }
180
181 }
182
183 //get installed mp modules
184 public static function getClientInstalledModules(){
185 $strError_tmp = "";
186 $arRequestedModules = array();
187 $arClientModules = CUpdateClientPartner::GetCurrentModules($strError_tmp);
188 if ($strError_tmp == '')
189 {
190 if (!empty($arClientModules))
191 {
192 foreach ($arClientModules as $key => $value)
193 {
194 if (str_contains($key, "."))
195 {
196 $arRequestedModules[] = $key;
197 }
198 }
199 return $arRequestedModules;
200 }
201 }
202 return false;
203 }
204
205 //check notification's type to add
206 public static function addMpNotifications($arModulesResult)
207 {
208 $serverName = (CMain::IsHTTPS() ? "https" : "http")."://".((defined("SITE_SERVER_NAME") && SITE_SERVER_NAME <> '') ? SITE_SERVER_NAME : COption::GetOptionString("main", "server_name", ""));
209 if (empty($arModulesResult['update_module']) && empty($arModulesResult['end_update']) && ($arModulesResult['new_module']) <= 0)
210 {
211 return false;
212 }
213 if (!empty($arModulesResult['update_module']))
214 {
215 self::addNotificationsToInformer($arModulesResult['update_module'], array('TITLE' => 'TOP_PANEL_AI_MODULE_UPDATE', 'HTML' => 'TOP_PANEL_AI_MODULE_UPDATE_DESC'), 'update_module', $serverName);
216 }
217 if (!empty($arModulesResult['end_update']))
218 {
219 self::addNotificationsToInformer($arModulesResult['end_update'], array('TITLE' => 'TOP_PANEL_AI_MODULE_END_UPDATE', 'HTML' => 'TOP_PANEL_AI_MODULE_END_UPDATE_DESC'), 'end_update', $serverName);
220 }
221 if (!empty($arModulesResult['new_module']))
222 {
223 self::addNotificationsPartnersNewModulesToInformer($arModulesResult['new_module'], $serverName);
224 }
225 }
226
227 //add notifications about new partner modules
228 public static function addNotificationsPartnersNewModulesToInformer($arModules, $serverName) {
229 foreach ($arModules as $partnerID => $arPartnerModules)
230 {
232 'TITLE' => GetMessage("TOP_PANEL_AI_NEW_MODULE_TITLE"),
233 'COLOR' => 'green',
234 'FOOTER' => "<a href=\"javascript:void(0)\" onclick=\"hideMpNotification(this, '".
235 CUtil::JSEscape($partnerID).
236 "', '".
237 CUtil::JSEscape('new_module').
238 "')\" ".
239 "style=\"float: right !important; font-size: 0.8em !important;\">".
240 GetMessage('TOP_PANEL_AI_MODULE_UPDATE_BUTTON_HIDE').
241 "</a>",
242 'ALERT' => true,
243 'HTML' => GetMessage('TOP_PANEL_AI_NEW_MODULE_DESC', array("#PARTNER#" => $arPartnerModules[0]['PARTNER'])),
244 );
245 foreach ($arPartnerModules as $arModule)
246 {
247 $arParams['HTML'] .= '<a href="'.$serverName.'/bitrix/admin/update_system_market.php?module='.$arModule['ID'].'" target="_blank">'.$arModule['NAME'].'</a><br>';
248 }
249 $arParams['HTML'] .= self::addJsToInformer();
251 }
252 }
253
254 public static function addJsToInformer()
255 {
256 return $script = '
257 <script>
258 function hideMpNotification(el, module, array_id)
259 {
260 if(el.parentNode.parentNode.parentNode)
261 BX.hide(el.parentNode.parentNode.parentNode);
262 BX.ajax({
263 "method": "POST",
264 "dataType": "json",
265 "url": "/bitrix/admin/partner_modules.php",
266 "data": "module="+module+"&'.bitrix_sessid_get().'&act=unnotify_mp&array_id="+array_id,
267 "async": true,
268 "processData": false,
269 "cache": false,
270 });
271 }
272 </script>';
273 }
274
275}
276
277?>
$arParams
Определения access_dialog.php:21
$arResult
Определения generate_coupon.php:16
Определения date.php:9
add($interval)
Определения date.php:145
static AddItem($arParams)
Определения admin_informer.php:27
static checkModulesEndDate($arRequestedModules, $daysCheck)
Определения mp_notifications.php:63
static getClientInstalledModules()
Определения mp_notifications.php:184
static addNotificationsPartnersNewModulesToInformer($arModules, $serverName)
Определения mp_notifications.php:228
static addNotificationsToInformer($arModules, $arNotifierText, $arrayId, $serverName)
Определения mp_notifications.php:149
static addJsToInformer()
Определения mp_notifications.php:254
static checkUpdates($arModules, $searchType, $daysCheck)
Определения mp_notifications.php:108
static OnAdminInformerInsertItemsHandlerMP()
Определения mp_notifications.php:16
static addMpNotifications($arModulesResult)
Определения mp_notifications.php:206
static GetCurrentModules(&$strError)
Определения update_client_partner.php:943
static __ParseServerData(&$strServerOutput, &$arRes, &$strError)
Определения update_client_partner.php:2073
static GetUpdatesList(&$strError, $lang=false, $stableVersionsOnly="Y", $arRequestedModules=array(), $aditData=Array())
Определения update_client_partner.php:1007
static __CollectRequestData(&$strError, $lang=false, $stableVersionsOnly="Y", $arRequestedModules=array(), $arAdditionalData=array(), $bStrongList=false)
Определения update_client_partner.php:846
static __GetHTTPPage($page, $strVars, &$strError)
Определения update_client_partner.php:1937
$content
Определения commerceml.php:144
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
if($ajaxMode) $ID
Определения get_user.php:27
while($arParentIBlockProperty=$dbParentIBlockProperty->Fetch()) $errorMessage
$_SERVER["DOCUMENT_ROOT"]
Определения cron_frame.php:9
global $USER
Определения csv_new_run.php:40
GetMessage($name, $aReplace=null)
Определения tools.php:3397
if(empty($signedUserToken)) $key
Определения quickway.php:257
$i
Определения factura.php:643
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения waybill.php:936