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/rospirotorg.ru/bitrix/modules/skyweb24.popuppro/lib/ |
Upload File : |
<? namespace Skyweb24\Popuppro; \Bitrix\Main\Loader::includeModule('iblock'); use Bitrix\Main\Mail\Event, Bitrix\Main\Localization\Loc; Loc::loadMessages(__FILE__); class Tools { public static function getBasketRules() { $currentModules = []; $groupDiscountIterator = \Bitrix\Sale\Internals\DiscountTable::getList([ 'select' => ['ID', 'NAME'], 'filter' => ['=ACTIVE' => 'Y'] ]); while ($groupDiscount = $groupDiscountIterator->fetch()) { $currentModules[$groupDiscount['ID']] = $groupDiscount['NAME'] . ' [' . $groupDiscount['ID'] . ']'; } return $currentModules; } public static function returnPropId($iblock_id, $prop_code, $prop_name) { $properties = \CIBlockProperty::GetList(["sort" => "asc", "name" => "asc"], ["IBLOCK_ID" => $iblock_id, 'CODE' => strtoupper($prop_code)]); if ($prop_fields = $properties->GetNext()) { return $prop_fields["ID"]; } $ibp = new \CIBlockProperty; return $ibp->Add([ "NAME" => $prop_name, "ACTIVE" => "Y", "SORT" => "100", "CODE" => strtoupper($prop_code), "PROPERTY_TYPE" => "S", "IBLOCK_ID" => $iblock_id ]); } public static function getListType($idPopup, $name) { $groups = []; $addType = true; $groupList = \Bitrix\Sender\ListTable::GetList( ['order' => ['NAME' => 'asc']] ); while ($row = $groupList->fetch()) { if ($row['CODE'] == 'skyweb24PopupPro_' . $idPopup) { $addType = false; } $groups[$row['ID']] = $row['NAME']; } if ($addType && (int)$idPopup > 0) { $listAddDb = \Bitrix\Sender\ListTable::add([ 'NAME' => $name, 'CODE' => 'skyweb24PopupPro_' . $idPopup, ]); if ($listAddDb->isSuccess()) { $listId = $listAddDb->getId(); $groups[$listId] = $name; } } return $groups; } public static function getPersonalizationValues() { $tempArr = []; foreach (self::getPersonalization() as $nextKey => $nexrVal) { $tempArr[$nextKey] = ''; } global $USER; if ($USER->IsAuthorized()) { $rsUser = \CUser::GetByID($USER->GetID()); $arUser = $rsUser->Fetch(); if (!empty($arUser['NAME'])) { $tempArr['NAME'] = $arUser['NAME']; } if (!empty($arUser['LAST_NAME'])) { $tempArr['LAST_NAME'] = $arUser['LAST_NAME']; } if (!empty($arUser['SECOND_NAME'])) { $tempArr['SECOND_NAME'] = $arUser['SECOND_NAME']; } if (!empty($arUser['EMAIL'])) { $tempArr['EMAIL'] = $arUser['EMAIL']; } if (!empty($arUser['PERSONAL_MOBILE'])) { $tempArr['MOBILE'] = $arUser['PERSONAL_MOBILE']; } if (!empty($arUser['PERSONAL_PHONE'])) { $tempArr['PHONE'] = $arUser['PERSONAL_PHONE']; } } return $tempArr; } public static function getPersonalization() { return [ 'NAME' => Loc::getMessage("skyweb24.popuppro_PERS_NAME"), 'LAST_NAME' => Loc::getMessage("skyweb24.popuppro_PERS_LAST_NAME"), 'SECOND_NAME' => Loc::getMessage("skyweb24.popuppro_PERS_SECOND_NAME"), 'EMAIL' => Loc::getMessage("skyweb24.popuppro_PERS_EMAIL"), 'PHONE' => Loc::getMessage("skyweb24.popuppro_PERS_PHONE"), 'MOBILE' => Loc::getMessage("skyweb24.popuppro_PERS_MOBILE") ]; } public static function getUserGroup() { $res = \CGroup::getList(($by = "ID"), ($order = "asc")); $result = []; while ($r = $res->Fetch()) { if ($r['ID'] < 3) { continue; } $result[$r['ID']] = $r['NAME']; } return $result; } public static function getRandSectorRoulette($idPopup) { global $DB; $res = $DB->Query('select * from skyweb24_popuppro where id=' . $idPopup . ' limit 1;'); if ($row = $res->Fetch()) { $settings = unserialize($row['settings']); if (!empty($settings['roulett'])) { $roulettArr = $settings['roulett']; $randomArr = []; foreach ($roulettArr as $key => $value) { if ($key == 'count') { continue; } $chance = empty($value['chance']) ? 0 : $value['chance']; $chance = (string)$chance == 'NaN' ? 1 : ($chance * 10); if ($chance > 0) { $randomArr = array_pad($randomArr, count($randomArr) + $chance, $key); } } shuffle($randomArr); if (count($randomArr) > 0) { $sector = $randomArr[array_rand($randomArr)]; $_SESSION['skyweb_popup_coupon_' . $idPopup] = $sector; return $sector; } } } return false; } public function sheckUserSector($idPopup, $idSector) { if (!empty($_SESSION['skyweb_popup_coupon_' . $idPopup]) && $_SESSION['skyweb_popup_coupon_' . $idPopup] == $idSector) { unset($_SESSION['skyweb_popup_coupon_' . $idPopup]); return true; } return false; } public function getMailTemplates(): array { /*CEventMessage::GetList( string &by="id", string &order="desc", array filter )*/ return []; } } ?>