function InstallFiles() { CopyDirFiles($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/mobile/public/mobile/", $_SERVER["DOCUMENT_ROOT"] . "/mobile/", True, True); CopyDirFiles($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/mobile/install/templates/", $_SERVER["DOCUMENT_ROOT"] . "/bitrix/templates/", True, True); CopyDirFiles($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/mobile/install/components/", $_SERVER["DOCUMENT_ROOT"] . "/bitrix/components", true, true); $default_site_id = CSite::GetDefSite(); if ($default_site_id) { $arAppTempalate = array("SORT" => 1, "CONDITION" => "CSite::InDir('/mobile/')", "TEMPLATE" => "mobile_app"); $arFields = array("TEMPLATE" => array()); $dbTemplates = CSite::GetTemplateList($default_site_id); $mobileAppFound = false; while ($template = $dbTemplates->Fetch()) { if ($template["TEMPLATE"] == "mobile_app") { $mobileAppFound = true; $template = $arAppTempalate; } $arFields["TEMPLATE"][] = array("TEMPLATE" => $template['TEMPLATE'], "SORT" => $template['SORT'], "CONDITION" => $template['CONDITION']); } if (!$mobileAppFound) { $arFields["TEMPLATE"][] = $arAppTempalate; } $obSite = new CSite(); $arFields["LID"] = $default_site_id; $obSite->Update($default_site_id, $arFields); } CUrlRewriter::ReindexFile("/mobile/webdav/index.php"); CUrlRewriter::ReindexFile("/mobile/disk/index.php"); CUrlRewriter::Add(array("CONDITION" => "#^/mobile/disk/(?<hash>[0-9]+)/download#", "RULE" => "download=1&objectId=\$1", "ID" => "bitrix:mobile.disk.file.detail", "PATH" => "/mobile/disk/index.php")); return true; }
function InstallFiles($site_dir = "/", $default_site_id = false) { CopyDirFiles($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/eshopapp/install/components", $_SERVER["DOCUMENT_ROOT"] . "/bitrix/components", true, true); CopyDirFiles($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/eshopapp/install/templates/", $_SERVER["DOCUMENT_ROOT"] . "/bitrix/templates/", true, true); if (!$default_site_id) { $default_site_id = CSite::GetDefSite(); } if ($default_site_id) { $arAppTempalate = array("SORT" => 1, "CONDITION" => "CSite::InDir('" . $site_dir . "eshop_app/')", "TEMPLATE" => "eshop_app"); $arFields = array("TEMPLATE" => array()); $dbTemplates = CSite::GetTemplateList($default_site_id); $eshopAppFound = false; while ($template = $dbTemplates->Fetch()) { if ($template["TEMPLATE"] == "eshop_app") { $eshopAppFound = true; $template = $arAppTempalate; } $arFields["TEMPLATE"][] = array("TEMPLATE" => $template['TEMPLATE'], "SORT" => $template['SORT'], "CONDITION" => $template['CONDITION']); } if (!$eshopAppFound) { $arFields["TEMPLATE"][] = $arAppTempalate; } $obSite = new CSite(); $arFields["LID"] = $default_site_id; $obSite->Update($default_site_id, $arFields); } return true; }
function ShowPanel() { global $USER, $APPLICATION; if (defined("ADMIN_SECTION") && ADMIN_SECTION == true) { return; } if ($USER->IsAdmin()) { if ($_REQUEST['add_new_site_sol'] == 'sol' && check_bitrix_sessid()) { $dbrSites = CSite::GetList($by, $ord); $arSitesID = array(); $arSitesPath = array(); $siteCnt = 0; while ($arSite = $dbrSites->Fetch()) { if ($arSite["ACTIVE"] == "Y") { $siteCnt++; } $arSitesID[] = strtolower($arSite["ID"]); $arSitesPath[] = strtolower($arSite["PATH"]); } $newSiteID = ""; while (true) { $newSiteID = chr(rand(ord("a"), ord("z"))) . chr(rand(ord("a"), ord("z"))); if (!in_array($newSiteID, $arSitesID) && !in_array("/site" . $newSiteID . "/", $arSitesPath) && !file_exists($_SERVER['DOCUMENT_ROOT'] . "/site" . $newSiteID)) { break; } } $culture = CultureTable::getRow(array('filter' => array("=FORMAT_DATE" => FORMAT_DATE, "=FORMAT_DATETIME" => FORMAT_DATETIME, "=FORMAT_NAME" => CSite::GetDefaultNameFormat(), "=CHARSET" => SITE_CHARSET))); if ($culture) { $cultureId = $culture["ID"]; } else { $addResult = CultureTable::add(array("NAME" => $newSiteID, "CODE" => $newSiteID, "FORMAT_DATE" => FORMAT_DATE, "FORMAT_DATETIME" => FORMAT_DATETIME, "FORMAT_NAME" => CSite::GetDefaultNameFormat(), "CHARSET" => SITE_CHARSET)); $cultureId = $addResult->getId(); } $arFields = array("LID" => $newSiteID, "ACTIVE" => "Y", "SORT" => 100, "DEF" => "N", "NAME" => $newSiteID, "DIR" => "/site_" . $newSiteID . "/", "SITE_NAME" => $newSiteID, "SERVER_NAME" => $_SERVER["SERVER_NAME"], "EMAIL" => COption::GetOptionString("main", "email_from"), "LANGUAGE_ID" => LANGUAGE_ID, "DOC_ROOT" => "", "CULTURE_ID" => $cultureId); $obSite = new CSite(); $result = $obSite->Add($arFields); if ($result) { LocalRedirect("/bitrix/admin/wizard_install.php?lang=" . LANGUAGE_ID . "&wizardName=bitrix:portal&wizardSiteID=" . $newSiteID . "&" . bitrix_sessid_get()); } else { echo $obSite->LAST_ERROR; } } $arMenu = array(array("ACTION" => "jsUtils.Redirect([], '" . CUtil::JSEscape(SITE_DIR) . "?add_new_site_sol=sol&" . bitrix_sessid_get() . "')", "TEXT" => "<b>" . GetMessage("SOL_BUTTON_TEST_TEXT", array("#BR#" => " ")) . "</b>", "TITLE" => GetMessage("SOL_BUTTON_TEST_TITLE"))); $arSites = array(); $dbrSites = CSite::GetList($by, $ord, array("ACTIVE" => "Y")); while ($arSite = $dbrSites->GetNext()) { $arSites[] = array("ACTION" => "jsUtils.Redirect([], '" . CUtil::JSEscape($arSite["DIR"]) . "');", "ICON" => $arSite["LID"] == SITE_ID ? "checked" : "", "TEXT" => $arSite["NAME"], "TITLE" => GetMessage("SOL_BUTTON_GOTOSITE") . " " . $arSite["NAME"]); } $arMenu[] = array("SEPARATOR" => true); $arMenu[] = array("TEXT" => GetMessage("SOL_BUTTON_GOTOSITE"), "MENU" => $arSites); $APPLICATION->AddPanelButton(array("HREF" => SITE_DIR . "?add_new_site_sol=sol&" . bitrix_sessid_get(), "ID" => "solutions_wizard", "ICON" => "bx-panel-install-solution-icon", "TYPE" => "BIG", "ALT" => GetMessage("SOL_BUTTON_TEST_TITLE"), "TEXT" => GetMessage("SOL_BUTTON_TEST_TEXT"), "MAIN_SORT" => 2520, "SORT" => 20, "MENU" => $arMenu, 'HINT' => array('TITLE' => str_replace('#BR#', ' ', GetMessage("SOL_BUTTON_TEST_TEXT")), 'TEXT' => GetMessage('SOL_BUTTON_TEST_TEXT_HINT')), 'HINT_MENU' => array('TITLE' => str_replace('#BR#', ' ', GetMessage("SOL_BUTTON_TEST_TEXT")), 'TEXT' => GetMessage('SOL_BUTTON_TEST_MENU_HINT')))); } }
/** * Delete * @param $ID * @return mixed * @throws \Exception */ public static function Delete($ID) { $obSite = new \CSite(); $dbSite = $obSite->GetList($by = "sort", $order = "desc", array('ID' => $ID)); if ($arSite = $dbSite->Fetch()) { $res = $obSite->Delete($ID); if ($res) { return $ID; } else { throw new BimException($obSite->LAST_ERROR); } } }
private static function getDefaultSiteID() { if (self::$defaultSiteID !== null) { return self::$defaultSiteID; } $siteEntity = new \CSite(); $dbSites = $siteEntity->GetList($by = 'sort', $order = 'desc', array('DEFAULT' => 'Y', 'ACTIVE' => 'Y')); $defaultSite = is_object($dbSites) ? $dbSites->Fetch() : null; if (is_array($defaultSite)) { return self::$defaultSiteID = $defaultSite['LID']; } return self::$defaultSiteID = 's1'; }
public static function getNearestEntities($entityID, $currentDate, $startDate = '', $responsibleID = 0, $intervalInDays = 7, $checkPermissions = true, $limit = 5) { if (!is_string($startDate) || $startDate === '') { $startDate = $currentDate; } $site = new \CSite(); $dateFormat = $site->GetDateFormat('SHORT'); $curretTime = $currentDate !== '' ? MakeTimeStamp($currentDate, $dateFormat) : false; $startTime = $startDate !== '' ? MakeTimeStamp($startDate, $dateFormat) : false; if ($startTime === false) { return array(); } $dt = new \DateTime(); $dt->setTimestamp($startTime); $dt->add(new \DateInterval("P{$intervalInDays}D")); $endTime = $dt->getTimeStamp(); $currentSorting = self::internalPrepareSorting($curretTime); $startSorting = self::internalPrepareSorting($startTime); $endSorting = self::internalPrepareSorting($endTime); $result = array(); if ($entityID === \CCrmOwnerType::Lead) { $filter = array('>=BIRTHDAY_SORT' => $startSorting, '<=BIRTHDAY_SORT' => $endSorting, 'CHECK_PERMISSIONS' => $checkPermissions ? 'Y' : 'N'); if ($responsibleID > 0) { $filter['=ASSIGNED_BY_ID'] = $responsibleID; } $dbResult = \CCrmLead::GetListEx(array(), $filter, false, array('nTopCount' => $limit), array('ID', 'BIRTHDATE', 'BIRTHDAY_SORT', 'HONORIFIC', 'NAME', 'SECOND_NAME', 'LAST_NAME')); while ($fields = $dbResult->Fetch()) { $fields['ENTITY_TYPE_ID'] = \CCrmOwnerType::Lead; $fields['IMAGE_ID'] = 0; $sorting = isset($fields['BIRTHDAY_SORT']) ? (int) $fields['BIRTHDAY_SORT'] : 512; $fields['IS_BIRTHDAY'] = $sorting === $currentSorting; $result[] = $fields; } } elseif ($entityID === \CCrmOwnerType::Contact) { $filter = array('>=BIRTHDAY_SORT' => $startSorting, '<=BIRTHDAY_SORT' => $endSorting, 'CHECK_PERMISSIONS' => $checkPermissions ? 'Y' : 'N'); if ($responsibleID > 0) { $filter['=ASSIGNED_BY_ID'] = $responsibleID; } $dbResult = \CCrmContact::GetListEx(array(), $filter, false, array('nTopCount' => $limit), array('ID', 'BIRTHDATE', 'BIRTHDAY_SORT', 'HONORIFIC', 'NAME', 'SECOND_NAME', 'LAST_NAME', 'PHOTO')); while ($fields = $dbResult->Fetch()) { $fields['ENTITY_TYPE_ID'] = \CCrmOwnerType::Contact; $fields['IMAGE_ID'] = isset($fields['PHOTO']) ? (int) $fields['PHOTO'] : 0; $sorting = isset($fields['BIRTHDAY_SORT']) ? (int) $fields['BIRTHDAY_SORT'] : 512; $fields['IS_BIRTHDAY'] = $sorting === $currentSorting; $result[] = $fields; } } return $result; }
public function getConfiguredDomains() { $result = array(); $converter = CBXPunycode::GetConverter(); $domainName = COption::GetOptionString("main", "server_name", ""); if ($domainName != "") { $result[$domainName] = $domainName; } $by = ""; $order = ""; $siteList = CSite::GetList($by, $order, array("ACTIVE" => "Y")); while ($site = $siteList->Fetch()) { $domains = explode("\r\n", $site["DOMAINS"]); foreach ($domains as $domainName) { if ($domainName != "") { $punyName = $converter->Encode($domainName); if ($punyName !== false) { $result[$punyName] = $domainName; } } } } ksort($result); return $result; }
public static function Add($settings) { global $DB, $USER; $name = $settings['title']; $description = $settings['description']; $owner = $settings['owner']; unset($settings['title']); unset($settings['description']); unset($settings['owner']); $fields = array('TITLE' => $name, 'DESCRIPTION' => $description, 'OWNER_ID' => $owner, 'CREATED_DATE' => date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL")), time() + CTimeZone::GetOffset()), 'CREATED_BY' => $USER->GetID()); if (isset($settings['mark_default'])) { $fields['MARK_DEFAULT'] = $settings['mark_default']; unset($settings['mark_default']); } $fields['SETTINGS'] = serialize($settings); // pre-events foreach (GetModuleEvents("report", "OnBeforeReportAdd", true) as $arEvent) { if (ExecuteModuleEventEx($arEvent, array(&$fields)) === false) { return false; } } // save data $ID = $DB->Add("b_report", $fields, array("SETTINGS", "DESCRIPTION"), "report"); // clear view params self::clearViewParams($ID); // post-events foreach (GetModuleEvents("report", "OnBeforeReportAdd", true) as $arEvent) { ExecuteModuleEventEx($arEvent, array($ID, &$fields)); } return $ID; }
/** * * return array() BasketList - experation - Send Order **/ public static function OrderBasket($experation = NULL,$sort = array("ID" => "ASC"), $limit = NULL){ global $DB; $arItems = array(); if(! $experation){ $experation = 30*24*60*60; } $time = date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL", SITE_ID)), time() - $experation); $arPages = false; if(! empty($limit)){ $arPages = array('nTopCount' => $limit); } $arFilter = array('>=DATE_UPDATE' => $time, "ORDER_ID" => true, "CAN_BUY" => "Y"); $arSelect = array("ID", "USER_ID", "PRODUCT_ID", "CAN_BUY", "DELAY", "SUBSCRIBE", "QUANTITY","DATE_UPDATE","DETAIL_PAGE_URL"); $dbBasketList = CSaleBasket::GetList( $sort, $arFilter, false, $arPages, $arSelect ); while($_arItems = $dbBasketList->Fetch()){ $arItems[] = $_arItems; } return $arItems; }
function init() { $this->username = CSalePaySystemAction::GetParamValue("USER"); $this->pwd = CSalePaySystemAction::GetParamValue("PWD"); $this->signature = CSalePaySystemAction::GetParamValue("SIGNATURE"); $this->currency = CSalePaySystemAction::GetParamValue("CURRENCY"); $this->testMode = CSalePaySystemAction::GetParamValue("TEST") == "Y"; if ($this->testMode) { $this->domain = "sandbox."; } if (strlen($_REQUEST["token"]) > 0) { $this->token = $_REQUEST["token"]; } if (strlen($_REQUEST["PayerID"]) > 0) { $this->payerId = $_REQUEST["PayerID"]; } $this->version = "98.0"; $dbSite = CSite::GetByID(SITE_ID); $arSite = $dbSite->Fetch(); $this->serverName = $arSite["SERVER_NAME"]; if (strLen($this->serverName) <= 0) { if (defined("SITE_SERVER_NAME") && strlen(SITE_SERVER_NAME) > 0) { $this->serverName = SITE_SERVER_NAME; } else { $this->serverName = COption::GetOptionString("main", "server_name", "www.bitrixsoft.com"); } } $this->serverName = (CMain::IsHTTPS() ? "https" : "http") . "://" . $this->serverName; if (strlen($this->username) <= 0 || strlen($this->username) <= 0 || strlen($this->username) <= 0) { $GLOBALS["APPLICATION"]->ThrowException("CSalePaySystempaypal: init error", "CSalePaySystempaypal_init_error"); return false; } return true; }
private function fetchSites() { if (!isset($this->sites)) { $res = \CSite::GetList(); self::$sites = $res->arResult; } }
public static function CheckFields($ACTION, &$arFields, $ID = 0) { global $DB; if ($ACTION != "ADD" && IntVal($ID) <= 0) { $GLOBALS["APPLICATION"]->ThrowException("System error 870164", "ERROR"); return false; } if ((is_set($arFields, "SITE_ID") || $ACTION == "ADD") && (is_array($arFields["SITE_ID"]) && count($arFields["SITE_ID"]) <= 0 || !is_array($arFields["SITE_ID"]) && strlen($arFields["SITE_ID"]) <= 0)) { $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_GS_EMPTY_SITE_ID"), "EMPTY_SITE_ID"); return false; } elseif (is_set($arFields, "SITE_ID")) { if (!is_array($arFields["SITE_ID"])) { $arFields["SITE_ID"] = array($arFields["SITE_ID"]); } foreach ($arFields["SITE_ID"] as $v) { $dbResult = CSite::GetByID($v); if (!$dbResult->Fetch()) { $GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $v, GetMessage("SONET_GS_ERROR_NO_SITE")), "ERROR_NO_SITE"); return false; } } } if ((is_set($arFields, "NAME") || $ACTION == "ADD") && strlen($arFields["NAME"]) <= 0) { $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_GS_EMPTY_NAME"), "EMPTY_NAME"); return false; } if (is_set($arFields, "SORT") || $ACTION == "ADD") { $arFields["SORT"] = intVal($arFields["SORT"]) > 0 ? intVal($arFields["SORT"]) : 100; } return True; }
function Fetch() { static $arSite = array(); $r = parent::Fetch(); if ($r) { $site_id = $r["SITE_ID"]; if (!isset($arSite[$site_id])) { $rsSite = CSite::GetList($b, $o, array("ID" => $site_id)); $arSite[$site_id] = $rsSite->Fetch(); } $r["DIR"] = $arSite[$site_id]["DIR"]; $r["SERVER_NAME"] = $arSite[$site_id]["SERVER_NAME"]; if (strlen($r["SITE_URL"]) > 0) { $r["URL"] = $r["SITE_URL"]; } if (substr($r["URL"], 0, 1) == "=") { foreach (GetModuleEvents("search", "OnSearchGetURL", true) as $arEvent) { $r["URL"] = ExecuteModuleEventEx($arEvent, array($r)); } } $r["URL"] = str_replace(array("#LANG#", "#SITE_DIR#", "#SERVER_NAME#"), array($r["DIR"], $r["DIR"], $r["SERVER_NAME"]), $r["URL"]); $r["URL"] = preg_replace("'(?<!:)/+'s", "/", $r["URL"]); unset($r["SITE_URL"]); } return $r; }
public static function GetFormatedUserName($userId) { static $userCache = array(); $userId = IntVal($userId); if($userId > 0) { if (!isset($userCache[$userId]) || !is_array($userCache[$userId])) { $dbUser = CUser::GetByID($userId); if ($arUser = $dbUser->Fetch()) { $userCache[$userId] = CUser::FormatName( CSite::GetNameFormat(false), array( "NAME" => $arUser["NAME"], "LAST_NAME" => $arUser["LAST_NAME"], "SECOND_NAME" => $arUser["SECOND_NAME"], "LOGIN" => $arUser["LOGIN"] ), true ); } } } return $userCache[$userId]; }
function DoInstall() { global $APPLICATION, $USER, $step, $arSitesList; if ($USER->IsAdmin()) { $arSitesList = array(); $rsSites = CSite::GetList($by = "sort", $order = "desc", array()); while ($arSite = $rsSites->Fetch()) { $arSitesList[$arSite['ID']] = $arSite['NAME']; } $step = IntVal($step); if ($step < 2) { $APPLICATION->IncludeAdminFile(GetMessage("CONTENT_INCLUDER_MODULE_INSTALL_TITLE") . $this->MODULE_ID, $this->sModuleInstallFullPath . "step1.php"); } elseif ($step == 2) { RegisterModule($this->MODULE_ID); RegisterModuleDependences("main", "OnEndBufferContent", $this->MODULE_ID, '\\Bit\\Includer\\Handlers', "OnEndBufferContentHandler"); RegisterModuleDependences("fileman", "OnIncludeHTMLEditorScript", $this->MODULE_ID, '\\Bit\\Includer\\Handlers', "OnIncludeHTMLEditorScriptHandler"); $this->InstallFiles(); $sSiteId = array_key_exists($_REQUEST['site_id'], $arSitesList) ? $_REQUEST['site_id'] : SITE_ID; if ($_REQUEST['install_sample_iblock'] === "Y") { $this->createSampleIblock($sSiteId); } if ($_REQUEST['disable_new_editor'] === "Y") { COption::setOptionString("fileman", "use_editor_3", ""); } COption::SetOptionString("bit.includer", "include_jquery", $_REQUEST['include_jquery_for_component'] === "Y" ? "Y" : "N"); $APPLICATION->IncludeAdminFile(GetMessage("CONTENT_INCLUDER_MODULE_INSTALL_TITLE"), $this->sModuleInstallFullPath . "step2.php"); } } }
function CreateWizardIndex($wizardName, &$errorMessage) { $indexContent = '<' . '?' . 'define("WIZARD_DEFAULT_SITE_ID", "' . (defined("WIZARD_DEFAULT_SITE_ID") ? WIZARD_DEFAULT_SITE_ID : "s1") . '");' . 'require(' . '$' . '_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php");' . 'require_once(' . '$' . '_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/classes/general/wizard.php");' . '$' . 'wizard = new CWizard("' . $wizardName . '");' . '$' . 'wizard->Install();' . 'require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog_after.php");' . '?' . '>'; $p = $_SERVER["DOCUMENT_ROOT"] . "/index.php"; if (defined("WIZARD_DEFAULT_SITE_ID")) { $rsSite = CSite::GetList($by = "sort", $order = "asc", array("ID" => WIZARD_DEFAULT_SITE_ID)); $arSite = $rsSite->GetNext(); $p = CSite::GetSiteDocRoot($arSite["LID"]) . $arSite["DIR"] . "/index.php"; } $handler = @fopen($p, "wb"); if (!$handler) { $errorMessage = InstallGetMessage("INST_WIZARD_INDEX_ACCESS_ERROR"); return false; } $success = @fwrite($handler, $indexContent); if (!$success) { $errorMessage = InstallGetMessage("INST_WIZARD_INDEX_ACCESS_ERROR"); return false; } if (defined("BX_FILE_PERMISSIONS")) { @chmod($_SERVER["DOCUMENT_ROOT"] . "/index.php", BX_FILE_PERMISSIONS); } fclose($handler); return true; }
function UnInstallDB($arParams = array()) { global $DB, $APPLICATION; $this->errors = false; if (!array_key_exists("savedata", $arParams) || $arParams["savedata"] != "Y") { $this->errors = $DB->RunSQLBatch($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/meeting/install/db/" . strtolower($DB->type) . "/uninstall.sql"); if ($this->errors === false && CModule::IncludeModule('forum')) { $dbRes = CSite::GetList($by = 'sort', $order = 'asc', array()); while ($arSite = $dbRes->Fetch()) { $forumId = COption::GetOptionInt('meeting', 'comments_forum_id', 0, $arSite['ID']); if ($forumId > 0) { CForumNew::Delete($forumId); } } } } UnRegisterModuleDependences("calendar", "OnAfterCalendarConvert", "meeting", "CMeetingEventHandlers", "OnAfterCalendarConvert"); UnRegisterModuleDependences("tasks", "OnTaskDelete", "meeting", "CMeetingEventHandlers", "OnTaskDelete"); UnRegisterModule("meeting"); if ($this->errors !== false) { $APPLICATION->ThrowException(implode("<br>", $this->errors)); return false; } return true; }
public function Load() { global $USER; if (!isset($_SESSION["SESS_AUTH"]["USER_ID"]) || !$_SESSION["SESS_AUTH"]["USER_ID"]) { $USER = new CUser(); } $this->isLogged = true; $defaultSite = CSite::GetList($by = "def", $order = "desc", array())->Fetch(); $this->encodingDefault = $defaultSite["CHARSET"]; $this->PrepareSettings(); $this->fp = $this->PrepareFile($this->filename . '.tmp'); if ($this->isLogged) { $this->fpLog = $this->PrepareFile($this->logFile); $this->WriteLog("Start Loading"); } $this->PreWriteCatalog(); $categories = $this->GetCategories(); $this->WriteCategories($categories); $this->PreWriteOffers(); $this->BuildOffers($categories); $this->PostWriteOffers(); $this->PostWriteCatalog(); if ($this->isLogged) { $this->WriteLog("Loading was ended successfully (peek memory usage: " . memory_get_peak_usage() . ")"); } $this->CloseFile($this->fp); $this->CloseFile($this->fpLog); unlink($_SERVER["DOCUMENT_ROOT"] . $this->filename); rename($_SERVER["DOCUMENT_ROOT"] . $this->filename . '.tmp', $_SERVER["DOCUMENT_ROOT"] . $this->filename); return true; }
private function prepareParams(&$arParams) { if (strlen($arParams["FORM_ID"]) <= 0) { $arParams["FORM_ID"] = "POST_FORM_" . RandString(3); } $arParams['NAME_TEMPLATE'] = empty($arParams['NAME_TEMPLATE']) ? \CSite::GetNameFormat(false) : str_replace(array("#NOBR#", "#/NOBR#"), "", $arParams["NAME_TEMPLATE"]); }
public static function fillFilterReferenceColumn(&$filterElement, Entity\ReferenceField $field) { if ($field->GetDataType() == 'Bitrix\\Main\\User') { // USER if ($filterElement['value']) { $res = CUser::GetByID($filterElement['value']); $user = $res->fetch(); if ($user) { $username = CUser::FormatName(CSite::GetNameFormat(false), $user, true); $filterElement['value'] = array('id' => $user['ID'], 'name' => $username); } else { $filterElement['value'] = array('id' => $filterElement['value'], 'name' => GetMessage('REPORT_USER_NOT_FOUND')); } } else { $filterElement['value'] = array('id' => ''); } } else { if ($field->GetDataType() == 'Bitrix\\Socialnetwork\\Workgroup') { // GROUP if ($filterElement['value']) { $group = CSocNetGroup::GetByID($filterElement['value']); if ($group) { $filterElement['value'] = array(array('id' => $group['ID'], 'title' => $group['NAME'])); } else { $filterElement['value'] = array(array('id' => $filterElement['value'], 'title' => GetMessage('REPORT_PROJECT_NOT_FOUND'))); } } else { $filterElement['value'] = array(array('id' => '')); } } } }
function InstallDB() { global $APPLICATION, $DB, $errors; if (!$DB->Query("SELECT 'x' FROM b_adv_banner", true)) { $EMPTY = "Y"; } else { $EMPTY = "N"; } if ($EMPTY == "Y") { $errors = $DB->RunSQLBatch($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/advertising/install/db/" . strtolower($DB->type) . "/install.sql"); if (!empty($errors)) { $APPLICATION->ThrowException(implode("", $errors)); return false; } } RegisterModule("advertising"); RegisterModuleDependences("main", "OnBeforeProlog", "advertising"); RegisterModuleDependences("main", "OnEndBufferContent", "advertising", "CAdvBanner", "FixShowAll"); RegisterModuleDependences("main", "OnBeforeRestartBuffer", "advertising", "CAdvBanner", "BeforeRestartBuffer"); CAgent::AddAgent("CAdvContract::SendInfo();", "advertising", "N", 7200); CAgent::AddAgent("CAdvBanner::CleanUpDynamics();", "advertising", "N", 86400); if ($EMPTY == "Y") { CModule::IncludeModule('advertising'); $arSites = array(); $rs = CSite::GetList($b = "sort", $o = "asc"); while ($ar = $rs->Fetch()) { $arSites[] = $ar['ID']; } $ac = new CAdvContract(); $arFields = array('ACTIVE' => 'Y', 'NAME' => 'Default', 'SORT' => 10000, 'DESCRIPTION' => 'all site without any restrictions', 'EMAIL_COUNT' => 1, 'arrTYPE' => array('ALL'), 'arrWEEKDAY' => array('MONDAY' => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23), 'SATURDAY' => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23), 'SUNDAY' => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23), 'THURSDAY' => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23), 'TUESDAY' => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23), 'WEDNESDAY' => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23), 'FRIDAY' => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23)), 'arrSITE' => $arSites); $ac->Set($arFields, 0, 'N'); } return true; }
function UnInstallDB($arParams = array()) { global $APPLICATION, $DB, $DOCUMENT_ROOT; if(!array_key_exists("savedata", $arParams) || $arParams["savedata"] != "Y") { $errors = $DB->RunSQLBatch($DOCUMENT_ROOT."/bitrix/modules/socialservices/install/db/".strtolower($DB->type)."/uninstall.sql"); if (!empty($errors)) { $APPLICATION->ThrowException(implode("", $errors)); return false; } } UnRegisterModuleDependences("main", "OnUserDelete", "socialservices", "CSocServAuthDB", "OnUserDelete"); UnRegisterModuleDependences('socialnetwork', 'OnFillSocNetLogEvents', 'socialservices', 'CSocServEventHandlers', 'OnFillSocNetLogEvents'); UnRegisterModuleDependences('timeman', 'OnAfterTMReportDailyAdd', 'socialservices', 'CSocServAuthDB', 'OnAfterTMReportDailyAdd'); UnRegisterModuleDependences('timeman', 'OnAfterTMDayStart', 'socialservices', 'CSocServAuthDB', 'OnAfterTMDayStart'); UnRegisterModuleDependences('timeman', 'OnTimeManShow', 'socialservices', 'CSocServEventHandlers', 'OnTimeManShow'); $dbSites = CSite::GetList(($b="sort"), ($o="asc"), array("ACTIVE" => "Y")); while ($arSite = $dbSites->Fetch()) { $siteId = $arSite['ID']; CAgent::RemoveAgent("CSocServAuthManager::GetTwitMessages($siteId);", "socialservices"); } UnRegisterModule("socialservices"); return true; }
function CheckFields($ACTION, &$arFields, $ID = false) { global $DB, $USER; if ((is_set($arFields, "NAME") || $ACTION == "ADD") && strlen(trim($arFields["NAME"])) <= 0) { $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGP_NO_NAME_TP"), "ERROR_NO_NAME"); return false; } $arMsg = array(); if ($ID === false && !is_set($arFields, "LID") || is_set($arFields, "LID") && (is_array($arFields["LID"]) && count($arFields["LID"]) <= 0 || !is_array($arFields["LID"]) && strlen($arFields["LID"]) <= 0)) { //$this->LAST_ERROR .= GetMessage("SKGP_BAD_SITE_NA")."<br>"; $arMsg[] = array("id" => "LID", "text" => GetMessage("SKGP_BAD_SITE_NA")); } elseif (is_set($arFields, "LID")) { if (!is_array($arFields["LID"])) { $arFields["LID"] = array($arFields["LID"]); } foreach ($arFields["LID"] as $v) { $r = CSite::GetByID($v); if (!$r->Fetch()) { //$this->LAST_ERROR .= str_replace("#ID#", $arFields["LID"], GetMessage("SKGP_NO_SITE")); $arMsg[] = array("id" => "LID", "text" => GetMessage("MAIN_EVENT_BAD_SITE")); } } } if (!empty($arMsg)) { $e = new CAdminException($arMsg); $GLOBALS["APPLICATION"]->ThrowException($e); return false; } return True; }
public function onPrepareComponentParams($params) { if (empty($params['NAME_TEMPLATE'])) { $params['NAME_TEMPLATE'] = COption::GetOptionString("bizproc", "name_template", CSite::GetNameFormat(false), SITE_ID); } return $params; }
function CheckFields($ACTION, &$arFields) { global $DB, $USER; if ((is_set($arFields, "NAME") || $ACTION == "ADD") && strlen($arFields["NAME"]) <= 0) { $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGPS_EMPTY_NAME"), "ERROR_NO_NAME"); return false; } /* if (is_set($arFields, "LID") && $ACTION!="ADD") UnSet($arFields["LID"]); if ((is_set($arFields, "CURRENCY") || $ACTION=="ADD") && strlen($arFields["CURRENCY"])<=0) { $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGPS_EMPTY_CURRENCY"), "ERROR_NO_CURRENCY"); return false; } */ if (is_set($arFields, "LID")) { $dbSite = CSite::GetByID($arFields["LID"]); if (!$dbSite->Fetch()) { $GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["LID"], GetMessage("SKGPS_NO_SITE")), "ERROR_NO_SITE"); return false; } } if (is_set($arFields, "ACTIVE") && $arFields["ACTIVE"] != "Y") { $arFields["ACTIVE"] = "N"; } if (is_set($arFields, "SORT") && IntVal($arFields["SORT"]) <= 0) { $arFields["SORT"] = 100; } return True; }
function CheckFields($ACTION, &$arFields, $ID = 0) { /* if ((is_set($arFields, "TYPE") || $ACTION=="ADD") && strlen($arFields["TYPE"]) <= 0) { $GLOBALS["APPLICATION"]->ThrowException(GetMessage("BLG_GSP_EMPTY_TYPE"), "EMPTY_TYPE"); return false; } */ if ((is_set($arFields, "PATH") || $ACTION == "ADD") && strlen($arFields["PATH"]) <= 0) { $GLOBALS["APPLICATION"]->ThrowException(GetMessage("BLG_GSP_EMPTY_PATH"), "EMPTY_PATH"); return false; } elseif (is_set($arFields, "PATH")) { $arFields["PATH"] = trim(str_replace("\\", "/", $arFields["PATH"])); } if ((is_set($arFields, "SITE_ID") || $ACTION == "ADD") && strlen($arFields["SITE_ID"]) <= 0) { $GLOBALS["APPLICATION"]->ThrowException(GetMessage("BLG_GSP_EMPTY_SITE_ID"), "EMPTY_SITE_ID"); return false; } elseif (is_set($arFields, "SITE_ID")) { $dbResult = CSite::GetByID($arFields["SITE_ID"]); if (!$dbResult->Fetch()) { $GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["SITE_ID"], GetMessage("BLG_GSP_ERROR_NO_SITE")), "ERROR_NO_SITE"); return false; } } return True; }
function AddGoogleAnaliticsEcommerceCode($orderId, $arOrder, $arParams){ global $APPLICATION; if(isset($_SESSION['GA_ORDER_ID']) && $_SESSION['GA_ORDER_ID'] == $orderId) return; $gaOutput = array(); $arSite = CSite::GetByID($arOrder['LID'])->Fetch(); $gaOutput[] = "<script>"; $gaOutput[] = "ga('require', 'ecommerce', 'ecommerce.js');"; $gaOutput[] = sprintf( "ga('ecommerce:addTransaction', { 'id': '%s', 'affiliation': '%s', 'revenue': '%s', 'shipping': '%s', 'tax': '' });", $orderId, $arSite['NAME'], $arOrder['PRICE'], $arOrder['PRICE_DELIVERY'] ); $dbBasket = CSaleBasket::GetList( array("NAME" => "ASC"), array("ORDER_ID" => $orderId) ); while($basketItem = $dbBasket->fetch()){ $gaOutput[] = sprintf( "ga('ecommerce:addItem', { 'id': '%s', 'name': '%s', 'sku': '%s', 'category': '', 'price': '%s', 'quantity': '%s' });", $orderId, $basketItem['NAME'], $basketItem['PRODUCT_ID'], $basketItem['PRICE'], $basketItem['QUANTITY'] ); } $gaOutput[] = "ga('ecommerce:send');"; $gaOutput[] = "</script>"; $APPLICATION->AddHeadString(implode("\n", $gaOutput), true); $_SESSION['GA_ORDER_ID'] = $orderId; }
/** * Creates events for sending e-mail. * @return bool */ public static function installEvents() { $dbEvent = \CEventMessage::GetList($b = "ID", $order = "ASC", array("EVENT_NAME" => "SALE_EBAY_ERROR")); if (!$dbEvent->Fetch()) { $langs = \CLanguage::GetList($b = "", $o = ""); while ($lang = $langs->Fetch()) { $lid = $lang["LID"]; $obEventType = new \CEventType(); $obEventType->Add(array("EVENT_NAME" => "SALE_EBAY_ERROR", "NAME" => Loc::getMessage("SALE_EBAY_HLP_EVNT_TYPE_ERROR"), "LID" => $lid, "DESCRIPTION" => "\n\t\t\t\t\t#ERROR_TYPE# - " . Loc::getMessage("SALE_EBAY_HLP_EVNT_TYPE_ERROR_TYPE") . "\n\t\t\t\t\t#ERROR_DETAILS# - " . Loc::getMessage("SALE_EBAY_HLP_EVNT_TYPE_ERROR_DETAIL") . "\n\t\t\t\t\t#EMAIL_FROM# - " . Loc::getMessage("SALE_EBAY_HLP_EVNT_TYPE_FROM") . "\n\t\t\t\t\t#EMAIL_TO# - " . Loc::getMessage("SALE_EBAY_HLP_EVNT_TYPE_TO") . "\n\t\t\t\t\t#BCC# - " . Loc::getMessage("SALE_EBAY_HLP_EVNT_TYPE_BCC"))); $arSites = array(); $sites = \CSite::GetList($b = "", $o = "", array("LANGUAGE_ID" => $lid)); while ($site = $sites->Fetch()) { $arSites[] = $site["LID"]; } if (count($arSites) > 0) { $arr = array(); $arr["ACTIVE"] = "Y"; $arr["EVENT_NAME"] = "SALE_EBAY_ERROR"; $arr["LID"] = $arSites; $arr["EMAIL_FROM"] = "#DEFAULT_EMAIL_FROM#"; $arr["EMAIL_TO"] = "#EMAIL_TO#"; $arr["BCC"] = "#BCC#"; $arr["SUBJECT"] = "#SITE_NAME# " . Loc::getMessage("SALE_EBAY_EVNT_MSG_SBUJ']") . "."; $arr["BODY_TYPE"] = "text"; $arr["MESSAGE"] = Loc::getMessage("SALE_EBAY_EVNT_MSG_INFO_SITE") . " #SITE_NAME#.\n\n" . Loc::getMessage("SALE_EBAY_EVNT_MSG") . ":\n\n" . "#ERROR_TYPE#\n\n" . "#ERROR_DETAILS#"; $obTemplate = new \CEventMessage(); $obTemplate->Add($arr); } } } return true; }
function InstallDB($arParams = array()) { RegisterModuleDependences('main', 'OnBuildGlobalMenu', self::MODULE_ID, 'CIpdesignK', 'OnBuildGlobalMenu'); $arsites = array(); $rsSites = CSite::GetList($by="sort", $order="desc", false); while ($arSite = $rsSites->Fetch()){ $arsites[] = $arSite['ID']; } $arFilter = array( "TYPE_ID" => "SENDWISHLIST", ); $rsET = CEventType::GetList($arFilter); $arET = $rsET->Fetch(); if(empty($arET)){ $et = new CEventType; $arMessageFields = array("USER_ID" => $UserProduct['USER']['ID'], "USER_NAME" => $UserProduct['USER']["NAME"].' '.$UserProduct['USER']["LAST_NAME"], "USER_EMAIL" => $UserProduct['USER']["EMAIL"], "PRODUCTS_LIST" => $strListProduct); $DESCRIPTION = '#USER_ID# - '.GetMessage("IT_BASKET_SENDER_USER_ID"); $DESCRIPTION .= '\n#USER_NAME# - '.GetMessage("IT_BASKET_SENDER_USER_NAME"); $DESCRIPTION .= '\n#USER_EMAIL# - '.GetMessage("IT_BASKET_SENDER_USER_EMAIL"); $DESCRIPTION .= '\n#PRODUCTS_LIST# - '.GetMessage("IT_BASKET_SENDER_PRODUCTS_LIST"); $sendType = $et->Add(array( "LID" => 'ru', "EVENT_NAME" => "SENDWISHLIST", "NAME" => GetMessage("IT_SENDER_TYPE_NAME"), "DESCRIPTION" => $DESCRIPTION )); }else{ $sendType = $arET['ID']; } $rsMess = CEventMessage::GetList($by="site_id", $order="desc", array('TYPE' => 'SENDWISHLIST')); $arMess = $rsMess->Fetch(); if(empty($arMess)){ $message = ''; $message .= '<h2>'.GetMessage("IT_BASKET_SENDER_TEMPLATE_HELLO").',#USER_NAME#</h2>'; $message .= '<p>'.GetMessage("IT_BASKET_SENDER_TEMPLATE_WHISHLIST").'</p>'; $message .= '<hr />'; $message .= '#PRODUCTS_LIST#'; $arFields = array("ACTIVE" => 'Y', "EVENT_NAME" => "SENDWISHLIST", "LID" => $arsites, "EMAIL_FROM" => "#DEFAULT_EMAIL_FROM#", "EMAIL_TO" => "#USER_EMAIL#", "BCC" => "", "MESSAGE" => $message, "BODY_TYPE" => "html", "SUBJECT" => GetMessage("IT_SENDER_MESSAGE_SUBJECT"). " #SERVER_NAME# ", ); $emess = new CEventMessage; if($emess->Add($arFields)){ } }; RegisterModuleDependences("sale", "OnCondSaleActionsControlBuildList", self::MODULE_ID, "CSaleActionCtrlBasketMain", "GetControlDescr"); RegisterModuleDependences("main", "OnBeforeProlog", "main", "", "", 110, '/modules/ipdesign.k1785/itdiscount.php'); return true; }
public static function NormalizeDateTime($str) { // Add seconds if omitted if (strpos(CSite::GetTimeFormat(), 'SS') !== false && preg_match('/\\d{1,2}\\s*:\\s*\\d{1,2}\\s*:\\s*\\d{1,2}/', $str) !== 1) { $str = preg_replace('/\\d{1,2}\\s*:\\s*\\d{1,2}/', '$0:00', $str); } return $str; }