/** * Add * @param $fields * @return array * @throws \Exception */ public static function Add($fields) { $arReqFields = array('LID', 'FORMAT_DATE', 'FORMAT_DATETIME', 'CHARSET', 'DIR'); foreach ($arReqFields as $key) { if (empty($fields[$key])) { throw new BimException('Field ' . $key . ' is empty.'); } } if (isset($fields['FORMAT_NAME']) and empty($fields['FORMAT_NAME'])) { $fields['FORMAT_NAME'] = "#NOBR##NAME# #LAST_NAME##/NOBR#"; } if (!isset($fields['ACTIVE']) || empty($fields['ACTIVE'])) { $fields['ACTIVE'] = "N"; } if (!isset($fields['DEF']) || empty($fields['DEF'])) { $fields['DEF'] = "N"; } $obSite = new \CSite(); $ID = $obSite->Add($fields); if ($ID) { return $ID; } else { throw new BimException($obSite->LAST_ERROR); } }
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')))); } }
function InstallDB() { /** @global string $DBType */ global $DB, $DBType, $DBHost, $DBLogin, $DBPassword, $DBName, $APPLICATION; if (!is_object($APPLICATION)) { $APPLICATION = new CMain(); } $DB = new CDatabase(); $DB->DebugToFile = false; $DB->debug = true; if (!defined("DBPersistent")) { define("DBPersistent", false); } if (!$DB->Connect($DBHost, $DBName, $DBLogin, $DBPassword)) { $APPLICATION->ThrowException(GetMessage("MAIN_INSTALL_DB_ERROR")); return false; } $result = $DB->Query("SELECT * FROM b_module WHERE ID='main'", true, "", array("fixed_connection" => true)); $success = $result && $result->Fetch(); if ($success) { return true; } if ($DBType == "mysql" && defined("MYSQL_TABLE_TYPE") && strlen(MYSQL_TABLE_TYPE) > 0) { $DB->Query("SET storage_engine = '" . MYSQL_TABLE_TYPE . "'", true); } $errors = $DB->RunSQLBatch($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/install/" . $DBType . "/install.sql"); if ($errors !== false) { $APPLICATION->ThrowException(implode("", $errors)); return false; } $this->InstallTasks(); $group = new CGroup(); $arGroups = array(array("~ID" => 1, "ACTIVE" => "Y", "C_SORT" => 1, "NAME" => GetMessage("MAIN_ADMIN_GROUP_NAME"), "ANONYMOUS" => "N", "DESCRIPTION" => GetMessage("MAIN_ADMIN_GROUP_DESC")), array("~ID" => 2, "ACTIVE" => "Y", "C_SORT" => 2, "NAME" => GetMessage("MAIN_EVERYONE_GROUP_NAME"), "ANONYMOUS" => "Y", "DESCRIPTION" => GetMessage("MAIN_EVERYONE_GROUP_DESC")), array("~ID" => 3, "ACTIVE" => "Y", "C_SORT" => 3, "NAME" => GetMessage("MAIN_VOTE_RATING_GROUP_NAME"), "ANONYMOUS" => "N", "DESCRIPTION" => GetMessage("MAIN_VOTE_RATING_GROUP_DESC"), "STRING_ID" => "RATING_VOTE"), array("~ID" => 4, "ACTIVE" => "Y", "C_SORT" => 4, "NAME" => GetMessage("MAIN_VOTE_AUTHORITY_GROUP_NAME"), "ANONYMOUS" => "N", "DESCRIPTION" => GetMessage("MAIN_VOTE_AUTHORITY_GROUP_DESC"), "STRING_ID" => "RATING_VOTE_AUTHORITY")); foreach ($arGroups as $arGroup) { $rsGroup = CGroup::GetByID($arGroup["~ID"]); if ($rsGroup->Fetch()) { continue; } //mssql does not allow insert identity by default if (strtolower($DB->type) == "mssql") { unset($arGroup["~ID"]); } $success = (bool) $group->Add($arGroup); if (!$success) { $APPLICATION->ThrowException($group->LAST_ERROR); return false; } } self::InstallRatings(); $arLanguages = array(array("LID" => LANGUAGE_ID, "ACTIVE" => "Y", "SORT" => 1, "DEF" => "Y", "NAME" => GetMessage("MAIN_DEFAULT_LANGUAGE_NAME"), "FORMAT_DATE" => GetMessage("MAIN_DEFAULT_LANGUAGE_FORMAT_DATE"), "FORMAT_DATETIME" => GetMessage("MAIN_DEFAULT_LANGUAGE_FORMAT_DATETIME"), "FORMAT_NAME" => GetMessage("MAIN_DEFAULT_LANGUAGE_FORMAT_NAME"), "CHARSET" => defined("BX_UTF") ? "UTF-8" : GetMessage("MAIN_DEFAULT_LANGUAGE_FORMAT_CHARSET"))); if (LANGUAGE_ID != "en") { $arLanguages[] = array("LID" => "en", "ACTIVE" => "Y", "SORT" => 2, "DEF" => "N", "NAME" => "English", "FORMAT_DATE" => "MM/DD/YYYY", "FORMAT_DATETIME" => "MM/DD/YYYY H:MI:SS T", "FORMAT_NAME" => "#NAME# #LAST_NAME#", "CHARSET" => defined("BX_UTF") ? "UTF-8" : "iso-8859-1"); } if (LANGUAGE_ID != "de" && file_exists($_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/lang/de/install/index.php')) { $arLanguages[] = array("LID" => "de", "ACTIVE" => "Y", "SORT" => 3, "DEF" => "N", "NAME" => "German", "FORMAT_DATE" => "DD.MM.YYYY", "FORMAT_DATETIME" => "DD.MM.YYYY HH:MI:SS", "FORMAT_NAME" => "#NAME# #LAST_NAME#", "CHARSET" => defined("BX_UTF") ? "UTF-8" : "iso-8859-1"); } if (LANGUAGE_ID != "ru" && file_exists($_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/lang/ru/install/index.php')) { $arLanguages[] = array("LID" => "ru", "ACTIVE" => "Y", "SORT" => 3, "DEF" => "N", "NAME" => "Russian", "FORMAT_DATE" => "DD.MM.YYYY", "FORMAT_DATETIME" => "DD.MM.YYYY HH:MI:SS", "FORMAT_NAME" => "#NAME# #LAST_NAME#", "CHARSET" => defined("BX_UTF") ? "UTF-8" : "windows-1251"); } $lang = new CLanguage(); foreach ($arLanguages as $arLanguage) { $rsLang = CLanguage::GetByID($arLanguage["LID"]); if ($rsLang->Fetch()) { continue; } $success = (bool) $lang->Add($arLanguage); if (!$success) { $APPLICATION->ThrowException($lang->LAST_ERROR); return false; } } $arSite = array("LID" => "s1", "ACTIVE" => "Y", "SORT" => 1, "DEF" => "Y", "NAME" => GetMessage("MAIN_DEFAULT_SITE_NAME"), "DIR" => "/", "FORMAT_DATE" => GetMessage("MAIN_DEFAULT_SITE_FORMAT_DATE"), "FORMAT_DATETIME" => GetMessage("MAIN_DEFAULT_SITE_FORMAT_DATETIME"), "FORMAT_NAME" => GetMessage("MAIN_DEFAULT_SITE_FORMAT_NAME"), "CHARSET" => defined("BX_UTF") ? "UTF-8" : GetMessage("MAIN_DEFAULT_SITE_FORMAT_CHARSET"), "LANGUAGE_ID" => LANGUAGE_ID); $rsSites = CSite::GetByID($arSite["LID"]); if (!$rsSites->Fetch()) { $site = new CSite(); $success = (bool) $site->Add($arSite); if (!$success) { $APPLICATION->ThrowException($site->LAST_ERROR); return false; } } RegisterModule("main"); RegisterModuleDependences('iblock', 'OnIBlockPropertyBuildList', 'main', 'CIBlockPropertyUserID', 'GetUserTypeDescription', 100, '/modules/main/tools/prop_userid.php'); RegisterModuleDependences('main', 'OnUserDelete', 'main', 'CFavorites', 'OnUserDelete', 100, "/modules/main/classes/" . strtolower($GLOBALS["DB"]->type) . "/favorites.php"); RegisterModuleDependences('main', 'OnLanguageDelete', 'main', 'CFavorites', 'OnLanguageDelete', 100, "/modules/main/classes/" . strtolower($GLOBALS["DB"]->type) . "/favorites.php"); RegisterModuleDependences('main', 'OnUserDelete', 'main', 'CUserOptions', 'OnUserDelete'); RegisterModuleDependences('main', 'OnChangeFile', 'main', 'CMain', 'OnChangeFileComponent'); RegisterModuleDependences('main', 'OnUserTypeRightsCheck', 'main', 'CUser', 'UserTypeRightsCheck'); RegisterModuleDependences('main', 'OnUserLogin', 'main', 'UpdateTools', 'CheckUpdates'); RegisterModuleDependences('main', 'OnModuleUpdate', 'main', 'UpdateTools', 'SetUpdateResult'); RegisterModuleDependences('main', 'OnUpdateCheck', 'main', 'UpdateTools', 'SetUpdateError'); RegisterModuleDependences('main', 'OnPanelCreate', 'main', 'CUndo', 'CheckNotifyMessage'); RegisterModuleDependences('main', 'OnAfterAddRating', 'main', 'CRatingsComponentsMain', 'OnAfterAddRating'); RegisterModuleDependences('main', 'OnAfterUpdateRating', 'main', 'CRatingsComponentsMain', 'OnAfterUpdateRating'); RegisterModuleDependences('main', 'OnSetRatingsConfigs', 'main', 'CRatingsComponentsMain', 'OnSetRatingConfigs'); RegisterModuleDependences('main', 'OnGetRatingsConfigs', 'main', 'CRatingsComponentsMain', 'OnGetRatingConfigs'); RegisterModuleDependences('main', 'OnGetRatingsObjects', 'main', 'CRatingsComponentsMain', 'OnGetRatingObject'); RegisterModuleDependences('main', 'OnGetRatingContentOwner', 'main', 'CRatingsComponentsMain', 'OnGetRatingContentOwner'); RegisterModuleDependences('main', 'OnAfterAddRatingRule', 'main', 'CRatingRulesMain', 'OnAfterAddRatingRule'); RegisterModuleDependences('main', 'OnAfterUpdateRatingRule', 'main', 'CRatingRulesMain', 'OnAfterUpdateRatingRule'); RegisterModuleDependences('main', 'OnGetRatingRuleObjects', 'main', 'CRatingRulesMain', 'OnGetRatingRuleObjects'); RegisterModuleDependences('main', 'OnGetRatingRuleConfigs', 'main', 'CRatingRulesMain', 'OnGetRatingRuleConfigs'); RegisterModuleDependences('main', 'OnAfterUserAdd', 'main', 'CRatings', 'OnAfterUserRegister'); RegisterModuleDependences('main', 'OnUserDelete', 'main', 'CRatings', 'OnUserDelete'); RegisterModuleDependences('main', 'OnUserDelete', 'main', 'CAccess', 'OnUserDelete'); RegisterModuleDependences('main', 'OnAfterGroupAdd', 'main', 'CGroupAuthProvider', 'OnAfterGroupAdd'); RegisterModuleDependences('main', 'OnBeforeGroupUpdate', 'main', 'CGroupAuthProvider', 'OnBeforeGroupUpdate'); RegisterModuleDependences('main', 'OnBeforeGroupDelete', 'main', 'CGroupAuthProvider', 'OnBeforeGroupDelete'); RegisterModuleDependences('main', 'OnAfterUserUpdate', 'main', 'CGroupAuthProvider', 'OnAfterUserUpdate'); RegisterModuleDependences('main', 'OnUserLogin', 'main', 'CGroupAuthProvider', 'OnUserLogin'); RegisterModuleDependences("main", "OnEventLogGetAuditTypes", "main", "CEventMain", "GetAuditTypes"); RegisterModuleDependences("main", "OnEventLogGetAuditHandlers", "main", "CEventMain", "MakeMainObject"); RegisterModuleDependences("perfmon", "OnGetTableSchema", "main", "CTableSchema", "OnGetTableSchema"); RegisterModuleDependences("main", "OnUserTypeBuildList", "main", "CUserTypeString", "GetUserTypeDescription", 110); RegisterModuleDependences("main", "OnUserTypeBuildList", "main", "CUserTypeInteger", "GetUserTypeDescription", 120); RegisterModuleDependences("main", "OnUserTypeBuildList", "main", "CUserTypeDouble", "GetUserTypeDescription", 130); RegisterModuleDependences("main", "OnUserTypeBuildList", "main", "CUserTypeDateTime", "GetUserTypeDescription", 140); RegisterModuleDependences("main", "OnUserTypeBuildList", "main", "CUserTypeBoolean", "GetUserTypeDescription", 150); RegisterModuleDependences("main", "OnUserTypeBuildList", "main", "CUserTypeFile", "GetUserTypeDescription", 160); RegisterModuleDependences("main", "OnUserTypeBuildList", "main", "CUserTypeEnum", "GetUserTypeDescription", 170); RegisterModuleDependences("main", "OnUserTypeBuildList", "main", "CUserTypeIBlockSection", "GetUserTypeDescription", 180); RegisterModuleDependences("main", "OnUserTypeBuildList", "main", "CUserTypeIBlockElement", "GetUserTypeDescription", 190); RegisterModuleDependences("main", "OnUserTypeBuildList", "main", "CUserTypeStringFormatted", "GetUserTypeDescription", 200); COption::SetOptionString('main', 'auth_comp2', 'Y'); COption::SetOptionString("main", "PARAM_MAX_SITES", "2"); COption::SetOptionString("main", "PARAM_MAX_USERS", "0"); COption::SetOptionString("main", "distributive6", "Y"); COption::SetOptionString("main", "~new_license11_sign", "Y"); COption::SetOptionString("main", "GROUP_DEFAULT_TASK", "1"); if (LANGUAGE_ID == "ru") { COption::SetOptionString("main", "vendor", "1c_bitrix"); } else { COption::SetOptionString("main", "vendor", "bitrix"); } COption::SetOptionString("main", "admin_lid", LANGUAGE_ID); COption::SetOptionString("main", "update_site", "www.bitrixsoft.com"); COption::SetOptionString("main", "update_site_ns", "Y"); COption::SetOptionString("main", "optimize_css_files", "Y"); COption::SetOptionString("main", "optimize_js_files", "Y"); CAgent::AddAgent("CEvent::CleanUpAgent();", "main", "Y", 86400); CAgent::AddAgent("CUser::CleanUpHitAuthAgent();", "main", "Y", 86400); CAgent::AddAgent("CCaptchaAgent::DeleteOldCaptcha(3600);", "main", "N", 3600); CAgent::AddAgent("CUndo::CleanUpOld();", "main", "Y", 86400); self::InstallDesktop(); self::InstallSmiles(); 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) { CheckDirPath($_SERVER["DOCUMENT_ROOT"] . "/site_" . $newSiteID . "/"); $indexContent = '<' . '?' . 'define("B_PROLOG_INCLUDED", true);' . 'define("WIZARD_DEFAULT_SITE_ID", "' . $newSiteID . '");' . 'define("WIZARD_DEFAULT_TONLY", true);' . 'define("PRE_LANGUAGE_ID","' . LANGUAGE_ID . '");' . 'define("PRE_INSTALL_CHARSET","' . SITE_CHARSET . '");' . 'include_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/install/wizard/wizard.php");' . '?' . '>'; $handler = fopen($_SERVER["DOCUMENT_ROOT"] . "/site_" . $newSiteID . "/index.php", "wb"); fwrite($handler, $indexContent); fclose($handler); LocalRedirect("/site_" . $newSiteID . "/"); } else { echo $obSite->LAST_ERROR; } } if ($_REQUEST['delete_button_sol'] == 'sol' && check_bitrix_sessid()) { UnRegisterModuleDependences('main', 'OnBeforeProlog', 'main', 'CWizardSolPanel', 'ShowPanel', '/modules/main/install/wizard_sol/panel_button.php'); LocalRedirect($APPLICATION->GetCurPage()); } $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"))); $arMenu[] = array("ACTION" => "if(confirm('" . AddSlashes(GetMessage("SOL_BUTTON_CONFIRM_W2")) . "')) jsUtils.Redirect([], '" . CUtil::JSEscape(SITE_DIR) . "?delete_button_sol=sol&" . bitrix_sessid_get() . "');", "TEXT" => GetMessage("SOL_BUTTON_DEL_TEXT"), "TITLE" => GetMessage("SOL_BUTTON_DEL_TITLE")); $protocol = CMain::IsHTTPS() ? 'https://' : 'http://'; $arSites = array(); $dbrSites = CSite::GetList($by, $ord, array("ACTIVE" => "Y")); while ($arSite = $dbrSites->GetNext()) { $url = $arSite["DIR"]; if ($arSite["DOMAIN_LIMITED"] == "Y" && $arSite["LID"] != SITE_ID) { $site = trim(preg_replace("#^(http://|https://)#i", "", $arSite["SERVER_NAME"]), " \t\n\r\v/"); if ($site != '') { $url = $protocol . $site . '/' . ltrim($url, '/'); } } $arSites[] = array("ACTION" => "jsUtils.Redirect([], '" . CUtil::JSEscape($url) . "');", "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')))); } }
function OnPostForm() { $wizard =& $this->GetWizard(); $serviceID = $wizard->GetVar("nextStep"); $serviceStage = $wizard->GetVar("nextStepStage"); if ($serviceID == "finish") { $wizard->SetCurrentStep("finish"); return; } $defSiteName = GetMessage("wiz_site_default_name"); if (GetMessage("wiz_site_name") != "") { $defSiteName = GetMessage("wiz_site_name"); } elseif ($wizard->wizardName != "") { $defSiteName = $wizard->wizardName; } $res = false; $site_id = $wizard->GetVar("siteID"); if ($site_id != "") { $db_res = CSite::GetList($by = "sort", $order = "desc", array("LID" => $site_id)); if ($db_res) { $res = $db_res->Fetch(); } } if ($wizard->GetVar("siteCreate") == "Y") { if (!$res) { $arFields = array("LID" => $site_id, "ACTIVE" => "Y", "SORT" => 100, "DEF" => "N", "NAME" => $defSiteName, "DIR" => $wizard->GetVar("siteFolder"), "FORMAT_DATE" => LANGUAGE_ID == "en" ? "MM/DD/YYYY" : "DD.MM.YYYY", "FORMAT_DATETIME" => LANGUAGE_ID == "en" ? "MM/DD/YYYY H:MI T" : "DD.MM.YYYY HH:MI:SS", "FORMAT_NAME" => CSite::GetDefaultNameFormat(), "CHARSET" => defined("BX_UTF") ? "UTF-8" : (LANGUAGE_ID == "ru" ? "windows-1251" : "ISO-8859-1"), "SITE_NAME" => $defSiteName, "SERVER_NAME" => $_SERVER["SERVER_NAME"], "EMAIL" => COption::GetOptionString("main", "email_from"), "LANGUAGE_ID" => LANGUAGE_ID, "DOC_ROOT" => ""); $obSite = new CSite(); $result = $obSite->Add($arFields); if ($result) { } else { echo $obSite->LAST_ERROR; die; } } $wizard->SetVar("siteCreate", "N"); } $pattern = '/^(.*):(.*)\\((.*)\\)/'; preg_match($pattern, $res["NAME"], $matches); if ($res && (count($matches) > 0 || $res["NAME"] == $site_id) && $site_id != "s1") { $templateID = $wizard->GetVar("templateID"); $themeVarName = $templateID . "_themeID"; $themeID = $wizard->GetVar($themeVarName); $templatesPath = WizardServices::GetTemplatesPath($wizard->GetPath() . "/site"); $arTemplates = WizardServices::GetTemplates($templatesPath); $templatesPath = WizardServices::GetTemplatesPath($wizard->GetPath() . "/site"); $arThemes = WizardServices::GetThemes($templatesPath . "/" . $templateID . "/themes", $templatesPath . "/" . $templateID); $siteNemNew = $defSiteName . ": " . $arTemplates[$templateID]["NAME"] . ' (' . $arThemes[$themeID]["NAME"] . ')'; $obSite = new CSite(); $result = $obSite->Update($site_id, array("NAME" => $siteNemNew, "SITE_NAME" => $siteNemNew)); } elseif ($res["NAME"] == GetMessage("MAIN_DEFAULT_SITE_NAME")) { $SiteNAME = $defSiteName . " (" . GetMessage("MAIN_DEFAULT_SITE_NAME") . ")"; $obSite = new CSite(); $result = $obSite->Update($site_id, array("NAME" => $SiteNAME, "SITE_NAME" => $defSiteName)); } CModule::IncludeModule('fileman'); COption::SetOptionString("fileman", "different_set", "Y"); $arMenuTypes = GetMenuTypes($site_id); if (count($arMenuTypes) == 0) { $arMenuTypes = array('left' => GetMessage("WIZ_MENU_LEFT"), 'top' => GetMessage("WIZ_MENU_TOP"), 'bottom' => GetMessage("WIZ_MENU_BOTTOM")); } else { if (!$arMenuTypes['left'] || $arMenuTypes['left'] == GetMessage("WIZ_MENU_LEFT_DEFAULT")) { $arMenuTypes['left'] = GetMessage("WIZ_MENU_LEFT"); } if (!$arMenuTypes['top'] || $arMenuTypes['top'] == GetMessage("WIZ_MENU_TOP_DEFAULT")) { $arMenuTypes['top'] = GetMessage("WIZ_MENU_TOP"); } if (!$arMenuTypes['bottom']) { $arMenuTypes['bottom'] = GetMessage("WIZ_MENU_BOTTOM"); } } SetMenuTypes($arMenuTypes, $site_id); $arServices = WizardServices::GetServices($_SERVER["DOCUMENT_ROOT"] . $wizard->GetPath(), "/site/services/"); $this->CorrectServices($arServices); if ($serviceStage == "skip") { $success = true; } else { $success = $this->InstallService($serviceID, $serviceStage); } if (!$this->repeatCurrentService) { list($nextService, $nextServiceStage, $stepsComplete, $status) = $this->GetNextStep($arServices, $serviceID, $serviceStage); } if ($nextService == "finish") { $formName = $wizard->GetFormName(); $response = "window.ajaxForm.StopAjax(); window.ajaxForm.SetStatus('100'); window.ajaxForm.Post('" . $nextService . "', '" . $nextServiceStage . "','" . $status . "');"; COption::SetOptionString("main", "wizard_first" . substr($wizard->GetID(), 7) . "_" . $wizard->GetVar("siteID"), "Y", false, $siteID); } else { $arServiceID = array_keys($arServices); $lastService = array_pop($arServiceID); $stepsCount = $arServices[$lastService]["POSITION"]; if (array_key_exists("STAGES", $arServices[$lastService]) && is_array($arServices[$lastService])) { $stepsCount += count($arServices[$lastService]["STAGES"]) - 1; } $percent = round($stepsComplete / $stepsCount * 100); $response = "window.ajaxForm.SetStatus('" . $percent . "'); window.ajaxForm.Post('" . $nextService . "', '" . $nextServiceStage . "','" . $status . "');"; } die("[response]" . $response . "[/response]"); }
die; } if (!defined("WIZARD_SITE_ID")) { return; } use Bitrix\Main\Localization\CultureTable; $site_id = ""; if (COption::GetOptionString("main", "site_personal_create", "N") == "Y") { $site_id = COption::GetOptionString("main", "site_personal_id"); $db_res = CSite::GetList($by = "sort", $order = "desc", array("LID" => $site_id)); if (!($db_res && ($res = $db_res->Fetch()))) { $culture = CultureTable::getRow(array('filter' => array("=FORMAT_DATE" => "DD.MM.YYYY", "=FORMAT_DATETIME" => "DD.MM.YYYY HH:MI:SS", "=FORMAT_NAME" => CSite::GetDefaultNameFormat(), "=CHARSET" => defined("BX_UTF") ? "UTF-8" : "windows-1251"))); if ($culture) { $cultureId = $culture["ID"]; } else { $addResult = CultureTable::add(array("NAME" => $site_id, "CODE" => $site_id, "FORMAT_DATE" => "DD.MM.YYYY", "FORMAT_DATETIME" => "DD.MM.YYYY HH:MI:SS", "FORMAT_NAME" => CSite::GetDefaultNameFormat(), "CHARSET" => defined("BX_UTF") ? "UTF-8" : "windows-1251")); $cultureId = $addResult->getId(); } $arFields = array("LID" => $site_id, "ACTIVE" => "Y", "SORT" => 100, "DEF" => "N", "NAME" => GetMessage("wiz_site_personal_name"), "DIR" => COption::GetOptionString("main", "site_personal_folder"), "SITE_NAME" => GetMessage("wiz_site_personal_name"), "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) { COption::SetOptionString("main", "site_personal_create", "N"); } else { echo $obSite->LAST_ERROR; die; } } } COption::SetOptionString("main", "new_user_registration", "N"); COption::SetOptionString('socialnetwork', 'allow_tooltip', 'N', false, $site_id);