Esempio n. 1
1
 /**
  * Establishes a connection to the database.
  * Includes php_interface/after_connect_d7.php on success.
  * Throws exception on failure.
  *
  * @return void
  * @throws \Bitrix\Main\DB\ConnectionException
  */
 protected function connectInternal()
 {
     if ($this->isConnected) {
         return;
     }
     $connectionInfo = array("UID" => $this->login, "PWD" => $this->password, "Database" => $this->database, "ReturnDatesAsStrings" => true);
     if (($this->options & self::PERSISTENT) != 0) {
         $connectionInfo["ConnectionPooling"] = true;
     } else {
         $connectionInfo["ConnectionPooling"] = false;
     }
     $connection = sqlsrv_connect($this->host, $connectionInfo);
     if (!$connection) {
         throw new ConnectionException('MS Sql connect error', $this->getErrorMessage());
     }
     $this->resource = $connection;
     $this->isConnected = true;
     // hide cautions
     sqlsrv_configure("WarningsReturnAsErrors", 0);
     /** @noinspection PhpUnusedLocalVariableInspection */
     global $DB, $USER, $APPLICATION;
     if ($fn = \Bitrix\Main\Loader::getPersonal("php_interface/after_connect_d7.php")) {
         include $fn;
     }
 }
Esempio n. 2
0
 protected static function checkParams($arMessage = array(), &$arTopic, &$arForum)
 {
     if (\Bitrix\Main\Loader::includeModule('forum')) {
         $arTopic = !empty($arTopic) ? $arTopic : \CForumTopic::GetByID($arMessage["TOPIC_ID"]);
         if (empty($arTopic)) {
             return false;
         }
         $arSitemaps = SitemapForumTable::getSitemapsByEntityId($arTopic["FORUM_ID"]);
         if (!empty($arSitemaps) && ($arForum = \CForumNew::GetByIDEx($arTopic["FORUM_ID"])) && $arForum) {
             $arForum["PATH2FORUM_MESSAGE"] = \CForumNew::GetSites($arTopic["FORUM_ID"]);
             $date = MakeTimeStamp($arTopic['LAST_POST_DATE']);
             $result = array();
             foreach ($arSitemaps as $arSitemap) {
                 $path = $arForum["PATH2FORUM_MESSAGE"][$arSitemap["SITE_ID"]];
                 if (!empty($path)) {
                     $arSitemap["fileName"] = str_replace("#FORUM_ID#", $arForum["ID"], $arSitemap['SITEMAP_FILE_FORUM']);
                     $arSitemap["url"] = \CForumNew::PreparePath2Message($path, array("FORUM_ID" => $arForum["ID"], "TOPIC_ID" => $arTopic["ID"], "TITLE_SEO" => $arTopic["TITLE_SEO"], "MESSAGE_ID" => "s", "SOCNET_GROUP_ID" => $arTopic["SOCNET_GROUP_ID"], "OWNER_ID" => $arTopic["OWNER_ID"], "PARAM1" => $arTopic["PARAM1"], "PARAM2" => $arTopic["PARAM2"]));
                     $arSitemap["date"] = $date;
                     $result[] = $arSitemap;
                 }
             }
             return empty($result) ? false : $result;
         }
     }
     return false;
 }
Esempio n. 3
0
 public function uninstallDB()
 {
     if (Loader::includeModule($this->MODULE_ID)) {
         $connection = Application::getInstance()->getConnection();
         $connection->dropTable(ExampleTable::getTableName());
     }
 }
Esempio n. 4
0
 public function onPrepareComponentParams($arParams)
 {
     $arParams['ERROR'] = array();
     if (!Loader::includeModule('lists') || !Loader::includeModule('bizproc')) {
         $arParams['ERROR'][] = Loc::getMessage('CC_BLL_MODULE_NOT_INSTALLED');
         return $arParams;
     }
     global $USER;
     $arParams['LIST_PERM'] = CListPermissions::CheckAccess($USER, COption::GetOptionString("lists", "livefeed_iblock_type_id"), false);
     if ($arParams['LIST_PERM'] < 0) {
         switch ($arParams['LIST_PERM']) {
             case CListPermissions::WRONG_IBLOCK_TYPE:
                 $arParams['ERROR'][] = Loc::getMessage("CC_BLL_WRONG_IBLOCK_TYPE");
                 break;
             case CListPermissions::WRONG_IBLOCK:
                 $arParams['ERROR'][] = Loc::getMessage("CC_BLL_WRONG_IBLOCK");
                 break;
             case CListPermissions::LISTS_FOR_SONET_GROUP_DISABLED:
                 $arParams['ERROR'][] = Loc::getMessage("CC_BLL_LISTS_FOR_SONET_GROUP_DISABLED");
                 break;
             default:
                 $arParams['ERROR'][] = Loc::getMessage("CC_BLL_UNKNOWN_ERROR");
                 break;
         }
     } elseif ($arParams['LIST_PERM'] <= CListPermissions::ACCESS_DENIED) {
         $arParams['ERROR'][] = Loc::getMessage("CC_BLL_ACCESS_DENIED");
     }
     $arParams['IBLOCK_TYPE_ID'] = COption::GetOptionString("lists", "livefeed_iblock_type_id");
     return $arParams;
 }
Esempio n. 5
0
	/**
	 * Function checks if required modules installed. If not, throws an exception
	 * @return void
	 */
	protected static function checkRequiredModules()
	{
		if (!Loader::includeModule('sale'))
			$this->errors['FATAL'][] = Loc::getMessage("SALE_SLS_SALE_MODULE_NOT_INSTALL");

		return true;
	}
 public function filter()
 {
     \Bitrix\Main\Loader::includeModule('sale');
     $daysBasketForgotten = $this->getFieldValue('DAYS_BASKET_FORGOTTEN');
     if (!is_numeric($daysBasketForgotten)) {
         $daysBasketForgotten = 90;
     }
     $dateFrom = new \Bitrix\Main\Type\DateTime();
     $dateTo = new \Bitrix\Main\Type\DateTime();
     $dateFrom->setTime(0, 0, 0)->add('-' . $daysBasketForgotten . ' days');
     $dateTo->setTime(0, 0, 0)->add('1 days')->add('-' . $daysBasketForgotten . ' days');
     if ($this->isRunForOldData()) {
         $filter = array('<MIN_DATE_INSERT' => $dateTo->format(\Bitrix\Main\UserFieldTable::MULTIPLE_DATETIME_FORMAT));
     } else {
         $filter = array('>MIN_DATE_INSERT' => $dateFrom->format(\Bitrix\Main\UserFieldTable::MULTIPLE_DATETIME_FORMAT), '<MIN_DATE_INSERT' => $dateTo->format(\Bitrix\Main\UserFieldTable::MULTIPLE_DATETIME_FORMAT));
     }
     $filter = $filter + array('!FUSER.USER_ID' => null, '=ORDER_ID' => null, '=LID' => $this->getSiteId());
     $userListDb = \Bitrix\Sale\BasketTable::getList(array('select' => array('USER_ID' => 'FUSER.USER_ID', 'EMAIL' => 'FUSER.USER.EMAIL', 'FUSER_USER_NAME' => 'FUSER.USER.NAME'), 'filter' => $filter, 'runtime' => array(new \Bitrix\Main\Entity\ExpressionField('MIN_DATE_INSERT', 'MIN(%s)', 'DATE_INSERT')), 'order' => array('USER_ID' => 'ASC')));
     if ($userListDb->getSelectedRowsCount() > 0) {
         $userListDb->addFetchDataModifier(array($this, 'getFetchDataModifier'));
         $this->recipient = $userListDb;
         return true;
     } else {
         return false;
     }
 }
 function onExecuteStartWriting(\Bitrix\Main\Event $event)
 {
     $parameters = $event->getParameters();
     $userId = $parameters[0];
     $dialogId = $parameters[1] . $parameters[2];
     if ($userId > 0) {
         if (!\Bitrix\Main\Loader::includeModule('pull')) {
             return;
         }
         \CPushManager::DeleteFromQueueBySubTag($userId, 'IM_MESS');
         if (intval($dialogId) > 0) {
             \CPullStack::AddByUser($dialogId, array('module_id' => 'im', 'command' => 'startWriting', 'expiry' => 60, 'params' => array('senderId' => $userId, 'dialogId' => $dialogId)));
         } elseif (substr($dialogId, 0, 4) == 'chat') {
             $chatId = substr($dialogId, 4);
             $arRelation = \CIMChat::GetRelationById($chatId);
             unset($arRelation[$userId]);
             $pullMessage = array('module_id' => 'im', 'command' => 'startWriting', 'expiry' => 60, 'params' => array('senderId' => $userId, 'dialogId' => $dialogId));
             \CPullStack::AddByUsers(array_keys($arRelation), $pullMessage);
             $orm = \Bitrix\Im\ChatTable::getById($chatId);
             $chat = $orm->fetch();
             if ($chat['TYPE'] == IM_MESSAGE_OPEN) {
                 \CPullWatch::AddToStack('IM_PUBLIC_' . $chatId, $pullMessage);
             }
         }
     }
 }
Esempio n. 8
0
 public static function getDirStructure($bLogical, $site, $path)
 {
     global $USER;
     $arDirContent = array();
     if ($USER->CanDoFileOperation('fm_view_listing', array($site, $path))) {
         \Bitrix\Main\Loader::includeModule('fileman');
         $arDirs = array();
         $arFiles = array();
         \CFileMan::GetDirList(array($site, $path), $arDirs, $arFiles, array(), array("NAME" => "asc"), "DF", $bLogical, true);
         $arDirContent_t = array_merge($arDirs, $arFiles);
         for ($i = 0, $l = count($arDirContent_t); $i < $l; $i++) {
             $file = $arDirContent_t[$i];
             $arPath = array($site, $file['ABS_PATH']);
             if ($file["TYPE"] == "F" && !$USER->CanDoFileOperation('fm_view_file', $arPath) || $file["TYPE"] == "D" && !$USER->CanDoFileOperation('fm_view_listing', $arPath) || $file["TYPE"] == "F" && $file["NAME"] == ".section.php") {
                 continue;
             }
             $f = $file['TYPE'] == 'F' ? new \Bitrix\Main\IO\File($file['PATH'], $site) : new \Bitrix\Main\IO\Directory($file['PATH'], $site);
             $p = $f->getName();
             if ($f->isSystem() || $file['TYPE'] == 'F' && in_array($p, array("urlrewrite.php")) || $file['TYPE'] == 'D' && preg_match("/\\/(bitrix|" . \COption::getOptionString("main", "upload_dir", "upload") . ")\\//", "/" . $p . "/")) {
                 continue;
             }
             $arFileData = array('NAME' => $bLogical ? $file['LOGIC_NAME'] : $p, 'FILE' => $p, 'TYPE' => $file['TYPE'], 'DATA' => $file);
             if (strlen($arFileData['NAME']) <= 0) {
                 $arFileData['NAME'] = GetMessage('SEO_DIR_LOGICAL_NO_NAME');
             }
             $arDirContent[] = $arFileData;
         }
         unset($arDirContent_t);
     }
     return $arDirContent;
 }
Esempio n. 9
0
 /**
  * @param array $config
  */
 public function __construct(array $config = null)
 {
     Loader::includeModule('highloadblock');
     if ($config) {
         $this->config($config);
     }
 }
Esempio n. 10
0
 /**
  * Increments conversion post day counter
  *
  * @param int $id Topic ID.
  * @param array $message Message fields.
  * @param array $topicInfo Message TOPIC_INFO field.
  * @param array $forumInfo Message FORUM_INFO field.
  * @param array $fields Message fields used to insert.
  * @return void
  */
 public static function onMessageAdd($id, $message, $topicInfo, $forumInfo, $fields)
 {
     if (Loader::includeModule('conversion')) {
         $context = DayContext::getInstance();
         $context->addDayCounter('forum_post_add_day', 1);
     }
 }
Esempio n. 11
0
function getPropDirectory(&$property)
{
    if (empty($property)) {
        return false;
    }
    if (!is_array($property)) {
        return false;
    }
    if (!isset($property['USER_TYPE_SETTINGS']['TABLE_NAME']) || empty($property['USER_TYPE_SETTINGS']['TABLE_NAME'])) {
        return false;
    }
    $highLoadInclude = \Bitrix\Main\Loader::includeModule('highloadblock');
    $highBlock = \Bitrix\Highloadblock\HighloadBlockTable::getList(array("filter" => array('TABLE_NAME' => $property['USER_TYPE_SETTINGS']['TABLE_NAME'])))->fetch();
    if (!isset($highBlock['ID'])) {
        return false;
    }
    $entity = \Bitrix\Highloadblock\HighloadBlockTable::compileEntity($highBlock);
    $entityDataClass = $entity->getDataClass();
    $entityList = $entityDataClass::getList();
    while ($arEntityItem = $entityList->Fetch()) {
        $val =& $property["VALUES"][$arEntityItem["UF_XML_ID"]];
        //foreach($property["VALUES"] as &$val){
        if (!empty($arEntityItem["UF_FILE"])) {
            $property["PICTURE_INCLUDED"] = true;
            $arEntityItem["~UF_FILE"] = $arEntityItem["UF_FILE"];
            $arEntityItem["PICTURE"] = CFile::GetPath($arEntityItem["~UF_FILE"]);
        }
        if (!empty($arEntityItem)) {
            $val = array_merge($val, $arEntityItem);
        }
        //}
        //echo'<pre>';print_r($arEntityItem);echo'</pre>';
    }
    return true;
}
Esempio n. 12
0
function OnBasketAddHandler($ID, $arFields)
{
    global $USER;
    \Bitrix\Main\Loader::includeModule('catalog');
    \Bitrix\Main\Loader::includeModule('sale');
    if ($USER->IsAuthorized()) {
        $arFilter = array("USER_ID" => $USER->GetID());
        $db_sales = CSaleOrder::GetList(array("DATE_INSERT" => "ASC"), $arFilter);
        $arrCount = [];
        while ($ar_sales = $db_sales->Fetch()) {
            $arrCount[] = $ar_sales;
        }
        if (is_array($arrCount) == false) {
            $res = CCatalogDiscount::SetCoupon('SL-CDUEA-HI8MMPY');
            //3%
        } else {
            if (count($arrCount) >= 1) {
                $resClean = CCatalogDiscount::ClearCoupon('SL-CDUEA-HI8MMPY');
                $res5 = CCatalogDiscount::SetCoupon('SL-0JG2C-XIHBEYZ');
                //5%
            } else {
            }
        }
    } else {
        $res = CCatalogDiscountCoupon::SetCoupon('SL-CDUEA-HI8MMPY');
        //3%
    }
}
Esempio n. 13
0
 /**
  * Checks online status of IM.
  * @return bool
  */
 public static function isDesktopImOnline()
 {
     if (!Loader::includeModule('im')) {
         return false;
     }
     return \CIMMessenger::checkDesktopStatusOnline();
 }
Esempio n. 14
0
 public static function initClassesList()
 {
     if (static::$classes !== null) {
         return true;
     }
     $classes = array('\\Bitrix\\Sale\\Delivery\\ExtraServices\\Enum' => 'lib/delivery/extra_services/enum.php', '\\Bitrix\\Sale\\Delivery\\ExtraServices\\Store' => 'lib/delivery/extra_services/store.php', '\\Bitrix\\Sale\\Delivery\\ExtraServices\\String' => 'lib/delivery/extra_services/string.php', '\\Bitrix\\Sale\\Delivery\\ExtraServices\\Checkbox' => 'lib/delivery/extra_services/checkbox.php');
     \Bitrix\Main\Loader::registerAutoLoadClasses('sale', $classes);
     unset($classes['\\Bitrix\\Sale\\Delivery\\ExtraServices\\Store']);
     static::$classes = array_keys($classes);
     $event = new Event('sale', 'onSaleDeliveryExtraServicesClassNamesBuildList');
     $event->send();
     $resultList = $event->getResults();
     if (is_array($resultList) && !empty($resultList)) {
         $customClasses = array();
         foreach ($resultList as $eventResult) {
             /** @var  EventResult $eventResult*/
             if ($eventResult->getType() != EventResult::SUCCESS) {
                 throw new SystemException("Can't add custom tracking class successfully");
             }
             $params = $eventResult->getParameters();
             if (!empty($params) && is_array($params)) {
                 $customClasses = array_merge($customClasses, $params);
             }
         }
         if (!empty($customClasses)) {
             \Bitrix\Main\Loader::registerAutoLoadClasses(null, $customClasses);
             $classes = array_merge($customClasses, $classes);
         }
     }
     static::$classes = array_merge(array_keys($classes), static::$classes);
     return static::$classes;
 }
 /**
  * Returns entity map definition.
  *
  * @return array
  */
 public static function getMap()
 {
     \Bitrix\Main\Loader::includeModule('iblock');
     $metadata = ElementTable::getMetadata(static::$_iblockId);
     $map = array('IBLOCK_ELEMENT_ID' => array('data_type' => 'integer', 'primary' => true));
     foreach ($metadata['props'] as $arProp) {
         //            if ($arProp['MULTIPLE'] == 'Y') {
         //                continue;
         //            }
         switch ($arProp['PROPERTY_TYPE']) {
             case 'N':
                 $map[] = new Entity\FloatField($arProp['CODE'], array('column_name' => 'PROPERTY_' . $arProp['ID']));
                 break;
             case 'L':
             case 'E':
             case 'G':
                 $map[] = new IntegerField($arProp['CODE'], array('column_name' => 'PROPERTY_' . $arProp['ID']));
                 break;
             case 'S':
             default:
                 $map[] = new Entity\StringField($arProp['CODE'], array('column_name' => 'PROPERTY_' . $arProp['ID']));
                 break;
         }
     }
     return $map;
 }
Esempio n. 16
0
 public static function getTabs($iblockElementInfo)
 {
     $showTab = false;
     $request = Context::getCurrent()->getRequest();
     if ($iblockElementInfo["ID"] > 0 && (!isset($request['action']) || $request['action'] != 'copy')) {
         $showTab = true;
         if (Loader::includeModule('catalog')) {
             /*
             				$dbRes = CatalogIblockTable::getList(array(
             					'filter' => array(
             						'=IBLOCK_ID' => $iblockElementInfo["IBLOCK"]["ID"],
             						'!PRODUCT_IBLOCK_ID' => 0
             					),
             					'select' => array('IBLOCK_ID'),
             				));
             				if($dbRes->fetch())
             				{
             					$showTab = false;
             				}
             */
             if (\CCatalogSku::getInfoByOfferIBlock($iblockElementInfo["IBLOCK"]["ID"]) !== false) {
                 $showTab = false;
             }
         }
     }
     return $showTab ? array(array("DIV" => "seo_adv", "SORT" => 4, "TAB" => Loc::getMessage("SEO_ADV_TAB"), "TITLE" => Loc::getMessage("SEO_ADV_TAB_TITLE"))) : null;
 }
Esempio n. 17
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if (!Loader::includeModule('search')) {
         throw new BitrixException('Search module is not installed');
     }
     $searchResult = array();
     $bar = new ProgressBar($output, 0);
     do {
         $bar->display();
         $searchResult = \CSearch::ReIndexAll($input->getOption('full'), static::UPDATE_TIME, $searchResult);
         $bar->advance();
         $bar->clear();
         if (is_array($searchResult) && $searchResult['MODULE'] == 'main') {
             list(, $path) = explode("|", $searchResult["ID"], 2);
             $output->writeln("\r       " . $path, OutputInterface::VERBOSITY_VERBOSE);
         }
     } while (is_array($searchResult));
     $bar->finish();
     $bar->clear();
     $output->write("\r");
     if (ModuleManager::isModuleInstalled('socialnetwork')) {
         $output->writeln('<info>The Social Network module needs to be reindexed using the Social Network component in the public section of site.</info>');
     }
     $output->writeln(sprintf('<info>Reindexed</info> %d element%s.', $searchResult, $searchResult > 1 ? 's' : ''));
     return 0;
 }
Esempio n. 18
0
File: CInc.php Progetto: Tvaruga/ae
 public static function getJobName($id)
 {
     if (empty($id)) {
         return false;
     }
     $result = false;
     $obCache = new CPHPCache();
     $dir = '/companies/names';
     if ($obCache->InitCache(9999999999, md5($id), $dir)) {
         $result = $obCache->GetVars();
     } elseif ($obCache->StartDataCache() && \Bitrix\Main\Loader::includeModule('iblock')) {
         if ($result = CIBlockElement::GetByID($id)->Fetch()) {
             if (defined('BX_COMP_MANAGED_CACHE')) {
                 $GLOBALS['CACHE_MANAGER']->StartTagCache($dir);
                 $GLOBALS['CACHE_MANAGER']->RegisterTag('iblock_id_' . $result['IBLOCK_ID']);
             }
             $result = $result['NAME'];
             if (defined('BX_COMP_MANAGED_CACHE')) {
                 $GLOBALS['CACHE_MANAGER']->EndTagCache();
             }
         }
         $obCache->EndDataCache($result);
     }
     return $result;
 }
Esempio n. 19
0
 function DoInstall() {
     global $APPLICATION, $data;
     $loc = \WS\Migrations\Module::getInstance()->getLocalization('setup');
     $options = \WS\Migrations\Module::getInstance()->getOptions();
     global $errors;
     $errors = array();
     if ($data['catalog']) {
         $dir = $_SERVER['DOCUMENT_ROOT'].$data['catalog'];
         if (!is_dir($dir)) {
             mkdir($dir);
         }
         if (!is_dir($dir)) {
             $errors[] = $loc->getDataByPath('error.notCreateDir');
         }
         if (!$errors) {
             $options->catalogPath = $data['catalog'];
         }
         $this->InstallFiles();
         $this->InstallDB();
         RegisterModule(self::MODULE_ID);
         \Bitrix\Main\Loader::includeModule(self::MODULE_ID);
         \Bitrix\Main\Loader::includeModule('iblock');
         \WS\Migrations\Module::getInstance()->install();
     }
     if (!$data || $errors) {
         $APPLICATION->IncludeAdminFile($loc->getDataByPath('title'), __DIR__.'/form.php');
         return;
     }
 }
Esempio n. 20
0
 /**
  * Gets security context (access provider) for user.
  * Attention! File/Folder can use anywhere and SecurityContext have to check rights anywhere (any module).
  * @param mixed $user User which use for check rights.
  * @return SecurityContext
  */
 public function getSecurityContextByUser($user)
 {
     if ($this->isCurrentUser($user)) {
         /** @noinspection PhpDynamicAsStaticMethodCallInspection */
         if (Loader::includeModule('socialnetwork') && \CSocnetUser::isCurrentUserModuleAdmin()) {
             return new FakeSecurityContext($user);
         }
         if (UserModel::isCurrentUserAdmin()) {
             return new FakeSecurityContext($user);
         }
     } else {
         $userId = UserModel::resolveUserId($user);
         /** @noinspection PhpDynamicAsStaticMethodCallInspection */
         if ($userId && Loader::includeModule('socialnetwork') && \CSocnetUser::isUserModuleAdmin($userId)) {
             return new FakeSecurityContext($user);
         }
         try {
             if ($userId && ModuleManager::isModuleInstalled('bitrix24') && Loader::includeModule('bitrix24') && \CBitrix24::isPortalAdmin($userId)) {
                 return new FakeSecurityContext($user);
             } elseif ($userId) {
                 //Check user group 1 ('Admins')
                 $tmpUser = new \CUser();
                 $arGroups = $tmpUser->getUserGroup($userId);
                 if (in_array(1, $arGroups)) {
                     return new FakeSecurityContext($user);
                 }
             }
         } catch (\Exception $e) {
         }
     }
     return new DiskSecurityContext($user);
 }
Esempio n. 21
0
 public function __construct($component = null)
 {
     parent::__construct($component);
     \Bitrix\Main\Loader::includeModule("forum");
     $this->componentId = $this->isAjaxRequest() ? randString(7) : $this->randString();
     $this->errorCollection = new ErrorCollection();
 }
Esempio n. 22
0
 public function executeComponent()
 {
     try {
         if ($this->notCache() || $this->StartResultCache(false)) {
             if (!Loader::includeModule('iblock')) {
                 ShowError(GetMessage("IT_MODULE_NOT_INSTALLED"));
                 return;
             }
             $this->inCacheFunction();
             if ($this->includeComponentTemplateInCache) {
                 $this->SetResultCacheKeys($this->arSaveInCacheKeys);
                 $this->IncludeComponentTemplate();
             } else {
                 $this->EndResultCache();
             }
         }
         $this->lastCacheFunction();
         if (!$this->includeComponentTemplateInCache) {
             $this->IncludeComponentTemplate();
         }
     } catch (Exception $exc) {
         if ($this->set404) {
             @define("ERROR_404", "Y");
         } elseif ($this->showError) {
             $this->__showError($exc->getMessage());
         }
         $this->AbortResultCache();
     }
 }
Esempio n. 23
0
 protected function checkRequiredModules()
 {
     if (!Loader::includeModule('bizproc')) {
         throw new SystemException('Install module "bizproc"');
     }
     return $this;
 }
Esempio n. 24
0
 /**
  * Increments conversion banner click day counter
  *
  * @param int $id Banner ID.
  * @param array $fields Banner fields.
  * @return void
  */
 public static function onBannerClick($id, $fields)
 {
     if (Loader::includeModule('conversion')) {
         $context = DayContext::getInstance();
         $context->addDayCounter('advertising_banner_click_day', 1);
     }
 }
Esempio n. 25
0
	public function __construct(Base $section)
	{
		if(!\Bitrix\Main\Loader::includeModule("iblock"))
			throw new \Exception("Iblock module not installed");

		$this->section = $section;
	}
Esempio n. 26
0
 public function checkByShipment(\Bitrix\Sale\Shipment $shipment, array $restrictionParams, $deliveryId = 0)
 {
     if (!\Bitrix\Main\Loader::includeModule('iblock')) {
         return array();
     }
     if (!\Bitrix\Main\Loader::includeModule('catalog')) {
         return array();
     }
     $productIds = array();
     /** @var \Bitrix\Sale\ShipmentItem $shipmentItem */
     foreach ($shipment->getShipmentItemCollection() as $shipmentItem) {
         /** @var \Bitrix\Sale\BasketItem $basketItem */
         $basketItem = $shipmentItem->getBasketItem();
         if ($basketItem->getField('MODULE') != 'catalog') {
             continue;
         }
         $productId = intval($basketItem->getField('PRODUCT_ID'));
         $iblockId = (int) \CIBlockElement::getIBlockByID($productId);
         $info = \CCatalogSKU::getProductInfo($productId, $iblockId);
         if (!empty($info['ID'])) {
             $candidate = $info['ID'];
         } else {
             $candidate = $productId;
         }
         if (!in_array($candidate, $productIds)) {
             $productIds[] = $candidate;
         }
     }
     $categoriesIds = self::getGroupsIds($productIds);
     return $this->check($categoriesIds, $restrictionParams, $deliveryId);
 }
Esempio n. 27
0
 /**
  * Increments conversion post day counter
  *
  * @param int $id Post ID.
  * @param array $fields Post fields.
  * @return void
  */
 public static function onPostAdd($id, $fields)
 {
     if (Loader::includeModule('conversion')) {
         $context = DayContext::getInstance();
         $context->addDayCounter('blog_post_add_day', 1);
     }
 }
Esempio n. 28
0
 public static function initClassesList()
 {
     if (static::$classes !== null) {
         return true;
     }
     $classes = array('\\Bitrix\\Sale\\Delivery\\ExtraServices\\Enum' => 'lib/delivery/extra_services/enum.php', '\\Bitrix\\Sale\\Delivery\\ExtraServices\\Store' => 'lib/delivery/extra_services/store.php', '\\Bitrix\\Sale\\Delivery\\ExtraServices\\String' => 'lib/delivery/extra_services/string.php', '\\Bitrix\\Sale\\Delivery\\ExtraServices\\Checkbox' => 'lib/delivery/extra_services/checkbox.php');
     \Bitrix\Main\Loader::registerAutoLoadClasses('sale', $classes);
     unset($classes['\\Bitrix\\Sale\\Delivery\\ExtraServices\\Store']);
     static::$classes = array_keys($classes);
     foreach (GetModuleEvents("sale", "onSaleDeliveryExtraServicesClassesCustom", true) as $arHandler) {
         $classes = ExecuteModuleEventEx($arHandler);
         if (!is_array($classes)) {
             throw new SystemException('Handler of onSaleDeliveryExtraServicesClassesCustom must return Bitrix\\Sale\\Delivery\\ExtraServices\\Base[]');
         }
         foreach ($classes as $class) {
             if (!class_exists($class)) {
                 throw new SystemException('onSaleDeliveryExtraServicesClassesCustom class doesn\'t exist: "' . $class . '"');
             }
             if (in_array($class, static::$classes)) {
                 throw new SystemException('onSaleDeliveryExtraServicesClassesCustom class with such name alredy exists: "' . $class . '"');
             }
             static::$classes[] = $class;
         }
     }
     return true;
 }
Esempio n. 29
0
 public function process()
 {
     parent::process();
     Loader::includeModule('catalog');
     if (!CCatalog::GetByID($this->id())) {
         CCatalog::Add(['IBLOCK_ID' => $this->id()]);
     }
 }
Esempio n. 30
0
 protected function getFilter()
 {
     $result = array(array('id' => 'MODIFIED', 'name' => Loc::getMessage('BPWI_MODIFIED'), 'type' => 'date', 'default' => true), array('id' => 'WS_STARTED', 'name' => Loc::getMessage('BPWI_WS_STARTED'), 'type' => 'date', 'default' => false));
     if ($this->isAdmin() && Loader::includeModule('intranet')) {
         $result[] = array('id' => 'WS_STARTED_BY', 'name' => Loc::getMessage('BPWI_WS_STARTED_BY'), 'type' => 'user', 'default' => true);
     }
     return $result;
 }