Exemplo n.º 1
0
 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;
 }
Exemplo n.º 2
0
 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;
 }
Exemplo n.º 3
0
 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;
 }
Exemplo n.º 4
0
 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;
 }
Exemplo n.º 5
0
    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;

    }
Exemplo n.º 6
0
 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;
 }
 function CSeoPageChecker($site, $url, $get = true, $check_errors = true)
 {
     global $APPLICATION;
     if (CModule::IncludeModule('search')) {
         $this->bSearch = true;
     } else {
         $APPLICATION->ThrowException(GetMessage('SEO_ERROR_NO_SEARCH'));
     }
     // don't return false or set bError!
     $this->__bCheckErrors = $check_errors;
     $this->__site = $site;
     $dbRes = CSite::GetByID($this->__site);
     if ($arRes = $dbRes->Fetch()) {
         $this->__lang = $arRes['LANGUAGE_ID'];
         $this->__server_name = $arRes['SERVER_NAME'];
         if (strlen($this->__server_name) <= 0) {
             $this->__server_name = COption::GetOptionString('main', 'server_name', '');
         }
         if (strlen($this->__server_name) > 0) {
             $this->__url = 'http://' . $this->__server_name . $url;
             return $get ? $this->GetHTTPData() : true;
         } else {
             $this->bError = true;
             $APPLICATION->ThrowException(str_replace('#SITE_ID#', $this->__site, GetMessage('SEO_ERROR_NO_SERVER_NAME')));
             return false;
         }
     }
     return false;
 }
Exemplo n.º 8
0
function cp_fetch_site_info($site_id = 0)
{
    static $info;
    if (!isset($info)) {
        $rsSites = CSite::GetByID(coalesce($site_id, SITE_ID));
        $info = $rsSites->Fetch();
    }
    return $info;
}
Exemplo n.º 9
0
 /**
  * getMailTo
  * Отправитель по-умолчанию
  *
  * @return str
  */
 public static function getMailTo()
 {
     static $mailTo;
     if (empty($mailTo)) {
         $rsSites = CSite::GetByID(SITE_ID);
         $arSite = $rsSites->Fetch();
         $mailTo = empty($arSite['EMAIL']) ? DEFAULT_EMAIL_TO : $arSite['EMAIL'];
     }
     return $mailTo;
 }
Exemplo n.º 10
0
 function GetIncludeSitePage($site)
 {
     if (strlen($site) <= 0) {
         return false;
     }
     $db_site = CSite::GetByID($site);
     if ($arSite = $db_site->Fetch()) {
         $arSite["DIR"] = RTrim($arSite["DIR"], ' \\/');
         $cur_page = GetPagePath();
         if (strlen($arSite["DIR"]) > 0) {
             global $REQUEST_URI;
             $REQUEST_URI = $arSite["DIR"] . $cur_page;
             $_SERVER["REQUEST_URI"] = $REQUEST_URI;
             return $_SERVER["DOCUMENT_ROOT"] . $REQUEST_URI;
         }
     }
     return false;
 }
Exemplo n.º 11
0
 protected function processActionCreateDefaultProcesses()
 {
     try {
         $defaultSiteId = CSite::GetDefSite();
         $iterator = CSite::GetByID($defaultSiteId);
         $site = $iterator->Fetch();
         $defaultLang = $site ? $site['LANGUAGE_ID'] : 'en';
         if ($defaultLang == 'ua') {
             $defaultLang = 'ru';
         }
         \Bitrix\Lists\Importer::installProcesses($defaultLang, $this->request->getPost('siteId'));
     } catch (Exception $e) {
         $this->errorCollection->add(array(new Error($e->getMessage())));
     }
     if ($this->errorCollection->hasErrors()) {
         $this->sendJsonErrorResponse();
     }
     $this->sendJsonSuccessResponse();
 }
Exemplo n.º 12
0
 function CheckFields($arFields, $ID = false)
 {
     global $DB;
     $arMsg = array();
     if ((is_set($arFields, "NAME") || $ID === false) && strlen(trim($arFields["NAME"])) <= 0) {
         $arMsg[] = array("id" => "NAME", "text" => GetMessage("LEARNING_BAD_NAME"));
     }
     if (is_set($arFields, "ACTIVE_FROM") && strlen($arFields["ACTIVE_FROM"]) > 0 && !$DB->IsDate($arFields["ACTIVE_FROM"], false, LANG, "FULL")) {
         $arMsg[] = array("id" => "ACTIVE_FROM", "text" => GetMessage("LEARNING_BAD_ACTIVE_FROM"));
     }
     if (is_set($arFields, "ACTIVE_TO") && strlen($arFields["ACTIVE_TO"]) > 0 && !$DB->IsDate($arFields["ACTIVE_TO"], false, LANG, "FULL")) {
         $arMsg[] = array("id" => "ACTIVE_TO", "text" => GetMessage("LEARNING_BAD_ACTIVE_TO"));
     }
     if (is_set($arFields, "PREVIEW_PICTURE") && is_array($arFields["PREVIEW_PICTURE"])) {
         $error = CFile::CheckImageFile($arFields["PREVIEW_PICTURE"]);
         if (strlen($error) > 0) {
             $arMsg[] = array("id" => "PREVIEW_PICTURE", "text" => $error);
         }
     }
     //Sites
     if ($ID === false && !is_set($arFields, "SITE_ID") || is_set($arFields, "SITE_ID") && (!is_array($arFields["SITE_ID"]) || empty($arFields["SITE_ID"]))) {
         $arMsg[] = array("id" => "SITE_ID[]", "text" => GetMessage("LEARNING_BAD_SITE_ID"));
     } elseif (is_set($arFields, "SITE_ID")) {
         $tmp = "";
         foreach ($arFields["SITE_ID"] as $lang) {
             $res = CSite::GetByID($lang);
             if (!$res->Fetch()) {
                 $tmp .= "'" . $lang . "' - " . GetMessage("LEARNING_BAD_SITE_ID_EX") . "<br>";
             }
         }
         if ($tmp != "") {
             $arMsg[] = array("id" => "SITE_ID[]", "text" => $tmp);
         }
     }
     if (!empty($arMsg)) {
         $e = new CAdminException($arMsg);
         $GLOBALS["APPLICATION"]->ThrowException($e);
         return false;
     }
     return true;
 }
Exemplo n.º 13
0
 function CheckFields($ACTION, &$arFields, $ID = 0)
 {
     global $DB, $arSocNetUserEvents;
     if ($ACTION != "ADD" && IntVal($ID) <= 0) {
         $GLOBALS["APPLICATION"]->ThrowException("System error 870164", "ERROR");
         return false;
     }
     if ((is_set($arFields, "USER_ID") || $ACTION == "ADD") && IntVal($arFields["USER_ID"]) <= 0) {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_UE_EMPTY_USER_ID"), "EMPTY_USER_ID");
         return false;
     } elseif (is_set($arFields, "USER_ID")) {
         $dbResult = CUser::GetByID($arFields["USER_ID"]);
         if (!$dbResult->Fetch()) {
             $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_UE_ERROR_NO_USER_ID"), "ERROR_NO_USER_ID");
             return false;
         }
     }
     if ((is_set($arFields, "EVENT_ID") || $ACTION == "ADD") && strlen($arFields["EVENT_ID"]) <= 0) {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_UE_EMPTY_EVENT_ID"), "EMPTY_EVENT_ID");
         return false;
     } elseif (is_set($arFields, "EVENT_ID") && !in_array($arFields["EVENT_ID"], $arSocNetUserEvents)) {
         $GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["EVENT_ID"], GetMessage("SONET_UE_ERROR_NO_EVENT_ID")), "ERROR_NO_EVENT_ID");
         return false;
     }
     if ((is_set($arFields, "SITE_ID") || $ACTION == "ADD") && strlen($arFields["SITE_ID"]) <= 0) {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_UE_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("SONET_UE_ERROR_NO_SITE")), "ERROR_NO_SITE");
             return false;
         }
     }
     if ((is_set($arFields, "ACTIVE") || $ACTION == "ADD") && $arFields["ACTIVE"] != "Y" && $arFields["ACTIVE"] != "N") {
         $arFields["ACTIVE"] = "Y";
     }
     return True;
 }
Exemplo n.º 14
0
 function CheckFields($ACTION, &$arFields, $ID = 0)
 {
     if ((is_set($arFields, "NAME") || $ACTION == "ADD") && strlen($arFields["NAME"]) <= 0) {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("BLG_GG_EMPTY_NAME"), "EMPTY_NAME");
         return false;
     } elseif (is_set($arFields, "NAME")) {
         $dbResult = CBlogGroup::GetList(array(), array("NAME" => $arFields["NAME"], "!ID" => $ID, "SITE_ID" => $arFields["SITE_ID"]), false, false, array("ID"));
         if ($dbResult->Fetch()) {
             $GLOBALS["APPLICATION"]->ThrowException(GetMessage("BLG_GG_DUBLICATE_NAME"), "DUBLICATE_NAME");
             return false;
         }
     }
     if ((is_set($arFields, "SITE_ID") || $ACTION == "ADD") && strlen($arFields["SITE_ID"]) <= 0) {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("BLG_GG_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_GG_ERROR_NO_SITE")), "ERROR_NO_SITE");
             return false;
         }
     }
     return True;
 }
Exemplo n.º 15
0
<?php

if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
    die;
}
if (!CModule::IncludeModule('sale')) {
    return;
}
$siteID = $arParams["site_id"];
if (strlen($arParams["site_id"]) <= 0) {
    $siteID = "s1";
}
$dbSite = CSite::GetByID($siteID);
if ($arSite = $dbSite->Fetch()) {
    $lang = $arSite["LANGUAGE_ID"];
}
if (strlen($lang) <= 0) {
    $lang = "ru";
}
$bRus = false;
if ($lang == "ru") {
    $bRus = true;
}
__IncludeLang(GetLangFileName(dirname(__FILE__) . "/lang/", "/" . basename(__FILE__), $lang));
$dbLocation = CSaleLocation::GetList(array("ID" => "ASC"), array("LID" => $lang));
if ($arLocation = $dbLocation->Fetch()) {
    $arLocationArr = array();
    $arLocation4Delivery = array();
    do {
        $arLocationArr[] = $arLocation["ID"];
    } while ($arLocation = $dbLocation->Fetch());
Exemplo n.º 16
0
<?php

if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
    die;
}
if (!CModule::IncludeModule("sale") || !CModule::IncludeModule("currency")) {
    return false;
}
$saleModulePermissions = $GLOBALS["APPLICATION"]->GetGroupRight("sale");
if (intval($arGadgetParams["ITEMS_COUNT"]) <= 0 || intval($arGadgetParams["ITEMS_COUNT"]) > 40) {
    $arGadgetParams["ITEMS_COUNT"] = 10;
}
if (strlen($arGadgetParams["SITE_ID"]) > 0) {
    $arGadgetParams["SITE_CURRENCY"] = CSaleLang::GetLangCurrency($arGadgetParams["SITE_ID"]);
    if (strlen($arGadgetParams["TITLE_STD"]) <= 0) {
        $rsSites = CSite::GetByID($arGadgetParams["SITE_ID"]);
        if ($arSite = $rsSites->GetNext()) {
            $arGadget["TITLE"] .= " / [" . $arSite["ID"] . "] " . $arSite["NAME"];
        }
    }
} else {
    $arGadgetParams["SITE_CURRENCY"] = CCurrency::GetBaseCurrency();
}
$arGadgetParams["RND_STRING"] = randString(8);
$arOrderStats = array();
$arOrders = array();
$arCurUsed = array();
if (strlen($arGadgetParams["SITE_ID"]) > 0) {
    $arFilterLID = array("LID" => $arGadgetParams["SITE_ID"]);
} else {
    $arFilterLID = array();
Exemplo n.º 17
0
 function GetStsSyncURL($arSectionParams, $type = 'calendar', $employees = false)
 {
     global $USER, $APPLICATION;
     if (!is_array($arSectionParams)) {
         $arSectionParams = array('ID' => intval($arSectionParams));
     }
     //if (!$arSectionParams['ID'])
     //	return false;
     $arAllowedTypes = array('calendar', 'tasks', 'contacts');
     if (!in_array($type, $arAllowedTypes)) {
         $type = 'calendar';
     }
     if ($type == 'calendar') {
         $calendar2 = COption::GetOptionString("intranet", "calendar_2", "N") == "Y" && CModule::IncludeModule("calendar");
         $fld_EXTERNAL_ID = 'XML_ID';
         if ($calendar2) {
             // $arSectionParams = array(
             // 'ID' => int
             // 'XML_ID' => string
             // 'NAME' => string
             // 'PREFIX' => string
             // 'LINK_URL' => string
             // 'TYPE' => string
             // )
             if (strlen($arSectionParams['XML_ID']) !== 32) {
                 $arSectionParams[$fld_EXTERNAL_ID] = md5($arSectionParams['TYPE'] . '_' . $arSectionParams['ID'] . '_' . RandString(8));
                 // Set XML_ID
                 CCalendar::SaveSection(array('arFields' => array('ID' => $arSectionParams['ID'], 'XML_ID' => $arSectionParams[$fld_EXTERNAL_ID]), 'bAffectToDav' => false, 'bCheckPermissions' => false));
             }
         } else {
             if (!$arSectionParams['IBLOCK_ID'] || !$arSectionParams['NAME'] || !$arSectionParams[$fld_EXTERNAL_ID]) {
                 $dbRes = CIBlockSection::GetByID($arSectionParams['ID']);
                 $arSection = $dbRes->Fetch();
                 if ($arSection) {
                     $arSectionParams['IBLOCK_ID'] = $arSection['IBLOCK_ID'];
                     $arSectionParams['NAME'] = $arSection['NAME'];
                     $arSectionParams[$fld_EXTERNAL_ID] = $arSection[$fld_EXTERNAL_ID];
                 } else {
                     return false;
                 }
             }
             if (strlen($arSectionParams[$fld_EXTERNAL_ID]) !== 32) {
                 $arSectionParams[$fld_EXTERNAL_ID] = md5($arSectionParams['IBLOCK_ID'] . '_' . $arSectionParams['ID'] . '_' . RandString(8));
                 $obSect = new CIBlockSection();
                 if (!$obSect->Update($arSectionParams['ID'], array($fld_EXTERNAL_ID => $arSectionParams[$fld_EXTERNAL_ID]), false, false)) {
                     return false;
                 }
             }
         }
         if (!$arSectionParams['PREFIX']) {
             $rsSites = CSite::GetByID(SITE_ID);
             $arSite = $rsSites->Fetch();
             if (strlen($arSite["NAME"]) > 0) {
                 $arSectionParams['PREFIX'] = $arSite["NAME"];
             } else {
                 $arSectionParams['PREFIX'] = COption::GetOptionString('main', 'site_name', GetMessage('INTR_OUTLOOK_PREFIX_CONTACTS'));
             }
         }
         $GUID = CIntranetUtils::makeGUID($arSectionParams[$fld_EXTERNAL_ID]);
     } elseif ($type == 'contacts') {
         if (!$arSectionParams['LINK_URL']) {
             if (CModule::IncludeModule('extranet') && CExtranet::IsExtranetSite()) {
                 $arSectionParams['LINK_URL'] = SITE_DIR . 'contacts/';
             } else {
                 $arSectionParams['LINK_URL'] = SITE_DIR . 'company/';
             }
         }
         if (!$arSectionParams['NAME']) {
             if (CModule::IncludeModule('extranet') && CExtranet::IsExtranetSite() && !$employees) {
                 $arSectionParams['NAME'] = GetMessage('INTR_OUTLOOK_TITLE_CONTACTS_EXTRANET');
             } else {
                 $arSectionParams['NAME'] = GetMessage('INTR_OUTLOOK_TITLE_CONTACTS');
             }
         }
         if (!$arSectionParams['PREFIX']) {
             $rsSites = CSite::GetByID(SITE_ID);
             $arSite = $rsSites->Fetch();
             if (strlen($arSite["NAME"]) > 0) {
                 $arSectionParams['PREFIX'] = $arSite["NAME"];
             } else {
                 $arSectionParams['PREFIX'] = COption::GetOptionString('main', 'site_name', GetMessage('INTR_OUTLOOK_PREFIX_CONTACTS'));
             }
         }
         $SERVER_NAME = $_SERVER['SERVER_NAME'];
         $GUID_DATA = $SERVER_NAME . '|' . $type;
         if (CModule::IncludeModule('extranet') && CExtranet::IsExtranetSite()) {
             $GUID_DATA .= "|extranet";
             if ($employees) {
                 $GUID_DATA .= "|employees";
             }
         }
         $GUID = CIntranetUtils::makeGUID(md5($GUID_DATA));
     } elseif ($type == 'tasks') {
         if (!$arSectionParams['LINK_URL']) {
             if (CModule::IncludeModule('extranet') && CExtranet::IsExtranetSite()) {
                 $arSectionParams['LINK_URL'] = SITE_DIR . 'contacts/personal/user/' . $USER->GetID() . '/tasks/';
             } else {
                 $arSectionParams['LINK_URL'] = SITE_DIR . 'company/personal/user/' . $USER->GetID() . '/tasks/';
             }
         }
         if (!$arSectionParams['NAME']) {
             $arSectionParams['NAME'] = GetMessage('INTR_OUTLOOK_TITLE_TASKS');
         }
         if (!$arSectionParams['PREFIX']) {
             $rsSites = CSite::GetByID(SITE_ID);
             $arSite = $rsSites->Fetch();
             if (strlen($arSite["NAME"]) > 0) {
                 $arSectionParams['PREFIX'] = $arSite["NAME"];
             } else {
                 $arSectionParams['PREFIX'] = COption::GetOptionString('main', 'site_name', GetMessage('INTR_OUTLOOK_PREFIX_CONTACTS'));
             }
         }
         $SERVER_NAME = $_SERVER['SERVER_NAME'];
         $GUID_DATA = $SERVER_NAME . '|' . $type;
         if (CModule::IncludeModule('extranet') && CExtranet::IsExtranetSite()) {
             $GUID_DATA .= "|extranet";
         }
         $GUID = CIntranetUtils::makeGUID(md5($GUID_DATA));
     }
     if (substr($arSectionParams['LINK_URL'], -9) == 'index.php') {
         $arSectionParams['LINK_URL'] = substr($arSectionParams['LINK_URL'], 0, -9);
     }
     if (substr($arSectionParams['LINK_URL'], -4) != '.php' && substr($arSectionParams['LINK_URL'], -1) != '/') {
         $arSectionParams['LINK_URL'] .= '/';
     }
     // another dirty hack to avoid some M$ stssync protocol restrictions
     if (substr($arSectionParams['LINK_URL'], -1) != '/') {
         $arSectionParams['LINK_URL'] .= '/';
     }
     $GLOBALS['APPLICATION']->AddHeadScript('/bitrix/js/intranet/outlook.js');
     $type_script = $type;
     if (CModule::IncludeModule('extranet') && CExtranet::IsExtranetSite()) {
         $type_script .= "_extranet";
         if ($employees) {
             $type_script .= "_emp";
         }
     }
     $port = $APPLICATION->IsHTTPS() ? 443 : 80;
     if (\Bitrix\Main\Loader::includeModule('ldap')) {
         $port = CLdapUtil::getTargetPort();
     }
     return 'jsOutlookUtils.Sync(\'' . $type . '\', \'/bitrix/tools/ws_' . $type_script . '\', \'' . $arSectionParams['LINK_URL'] . '\', \'' . CUtil::JSEscape(htmlspecialcharsbx($arSectionParams['PREFIX'])) . '\', \'' . CUtil::JSEscape($arSectionParams['NAME']) . '\', \'' . $GUID . '\', ' . intval($port) . ')';
 }
Exemplo n.º 18
0
 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;
 }
Exemplo n.º 19
0
 public function CheckFields($strAction, &$arFields, $intID = 0)
 {
     global $APPLICATION;
     global $DB;
     global $USER;
     $strAction = strtoupper($strAction);
     if ('UPDATE' != $strAction && 'ADD' != $strAction) {
         return false;
     }
     $intID = (int) $intID;
     $arCurrencyList = Currency\CurrencyManager::getCurrencyList();
     $boolResult = true;
     $arMsg = array();
     $clearFields = array('ID', '~ID', 'UNPACK', '~UNPACK', '~CONDITIONS', 'CONDITIONS', 'USE_COUPONS', '~USE_COUPONS', 'HANDLERS', '~HANDLERS', '~TYPE', '~RENEWAL', '~PRIORITY', '~LAST_DISCOUNT', '~VERSION', 'TIMESTAMP_X', 'DATE_CREATE', '~DATE_CREATE', '~MODIFIED_BY', '~CREATED_BY');
     if ($strAction == 'UPDATE') {
         $clearFields[] = 'CREATED_BY';
     }
     $arFields = array_filter($arFields, 'CCatalogDiscountSave::clearFields');
     foreach ($clearFields as &$fieldName) {
         if (isset($arFields[$fieldName])) {
             unset($arFields[$fieldName]);
         }
     }
     unset($fieldName, $clearFields);
     $arFields['TYPE'] = self::ENTITY_ID;
     $arFields["RENEWAL"] = 'N';
     $arFields['PRIORITY'] = 1;
     $arFields['LAST_DISCOUNT'] = 'Y';
     $arFields['VERSION'] = Catalog\DiscountTable::ACTUAL_VERSION;
     if ((is_set($arFields, "SITE_ID") || $strAction == "ADD") && empty($arFields["SITE_ID"])) {
         $arMsg[] = array('id' => 'SITE_ID', 'text' => Loc::getMessage('BT_MOD_CAT_DSC_SV_ERR_EMPTY_SITE'));
         $boolResult = false;
     } else {
         $rsSites = CSite::GetByID($arFields['SITE_ID']);
         if (!($arSite = $rsSites->Fetch())) {
             $arMsg[] = array('id' => 'SITE_ID', 'text' => Loc::getMessage('BT_MOD_CAT_DSC_SV_ERR_BAD_SITE'));
             $boolResult = false;
         }
     }
     if ((is_set($arFields, "NAME") || $strAction == "ADD") && strlen(trim($arFields["NAME"])) <= 0) {
         $arMsg[] = array('id' => 'NAME', 'text' => Loc::getMessage('BT_MOD_CAT_DSC_SV_ERR_EMPTY_NAME'));
         $boolResult = false;
     }
     if ((is_set($arFields, "ACTIVE") || $strAction == "ADD") && $arFields["ACTIVE"] != "N") {
         $arFields["ACTIVE"] = "Y";
     }
     if ((is_set($arFields, 'SORT') || $strAction == 'ADD') && intval($arFields['SORT']) <= 0) {
         $arFields['SORT'] = 500;
     }
     if ((is_set($arFields, "CURRENCY") || $strAction == "ADD") && empty($arFields["CURRENCY"])) {
         $arMsg[] = array('id' => 'CURRENCY', 'text' => Loc::getMessage('BT_MOD_CAT_DSC_SV_ERR_EMPTY_CURRENCY'));
         $boolResult = false;
     }
     if ((is_set($arFields, "ACTIVE_FROM") || $strAction == "ADD") && !$DB->IsDate($arFields["ACTIVE_FROM"], false, LANGUAGE_ID, "FULL")) {
         $arFields["ACTIVE_FROM"] = false;
     }
     if ((is_set($arFields, "ACTIVE_TO") || $strAction == "ADD") && !$DB->IsDate($arFields["ACTIVE_TO"], false, LANGUAGE_ID, "FULL")) {
         $arFields["ACTIVE_TO"] = false;
     }
     if ((is_set($arFields, 'COUNT_SIZE') || $strAction == 'ADD') && intval($arFields['COUNT_SIZE']) < 0) {
         $arFields['COUNT_SIZE'] = 0;
     }
     if ((is_set($arFields, 'COUNT_TYPE') || $strAction == 'ADD') && !in_array($arFields['COUNT_TYPE'], array('D', 'M', 'Y'))) {
         $arFields['COUNT_TYPE'] = 'Y';
     }
     if ((is_set($arFields, "COUNT_FROM") || $strAction == "ADD") && !$DB->IsDate($arFields["COUNT_FROM"], false, LANGUAGE_ID, "FULL")) {
         $arFields["COUNT_FROM"] = false;
     }
     if ((is_set($arFields, "COUNT_TO") || $strAction == "ADD") && !$DB->IsDate($arFields["COUNT_TO"], false, LANGUAGE_ID, "FULL")) {
         $arFields["COUNT_TO"] = false;
     }
     if (is_set($arFields, 'COUNT_PERIOD')) {
         unset($arFields['COUNT_PERIOD']);
     }
     $strCountPeriod = self::COUNT_TIME_ALL;
     if (is_set($arFields, 'COUNT_SIZE') && intval($arFields['COUNT_SIZE']) > 0) {
         $strCountPeriod = self::COUNT_TIME_PERIOD;
     }
     if (!empty($arFields["COUNT_FROM"]) || !empty($arFields["COUNT_TO"])) {
         $strCountPeriod = self::COUNT_TIME_INTERVAL;
     }
     $arFields['COUNT_PERIOD'] = $strCountPeriod;
     if ((is_set($arFields, 'ACTION_SIZE') || $strAction == 'ADD') && intval($arFields['ACTION_SIZE']) < 0) {
         $arFields['ACTION_SIZE'] = 0;
     }
     if ((is_set($arFields, 'ACTION_TYPE') || $strAction == 'ADD') && !in_array($arFields['ACTION_TYPE'], array('D', 'M', 'Y'))) {
         $arFields['ACTION_TYPE'] = 'Y';
     }
     $intUserID = 0;
     $boolUserExist = CCatalog::IsUserExists();
     if ($boolUserExist) {
         $intUserID = (int) $USER->GetID();
     }
     $strDateFunction = $DB->GetNowFunction();
     $arFields['~TIMESTAMP_X'] = $strDateFunction;
     if ($boolUserExist) {
         if (!array_key_exists('MODIFIED_BY', $arFields) || (int) $arFields["MODIFIED_BY"] <= 0) {
             $arFields["MODIFIED_BY"] = $intUserID;
         }
     }
     if ('ADD' == $strAction) {
         $arFields['~DATE_CREATE'] = $strDateFunction;
         if ($boolUserExist) {
             if (!array_key_exists('CREATED_BY', $arFields) || (int) $arFields["CREATED_BY"] <= 0) {
                 $arFields["CREATED_BY"] = $intUserID;
             }
         }
     }
     if (is_set($arFields, 'RANGES') || $strAction == 'ADD') {
         if (!is_array($arFields['RANGES']) || empty($arFields['RANGES'])) {
             $arMsg[] = array('id' => 'RANGES', 'text' => Loc::getMessage('BT_MOD_CAT_DSC_SV_ERR_EMPTY_RANGES'));
             $boolResult = false;
         } else {
             $boolRepeat = false;
             $arRangeList = array();
             foreach ($arFields['RANGES'] as &$arRange) {
                 if (!is_array($arRange) || empty($arRange)) {
                     $arMsg[] = array('id' => 'RANGES', 'text' => Loc::getMessage('BT_MOD_CAT_DSC_SV_ERR_BAD_RANGE'));
                     $boolResult = false;
                 } else {
                     if (empty($arRange['TYPE']) || $arRange['TYPE'] != self::TYPE_FIX) {
                         $arRange['TYPE'] = self::TYPE_PERCENT;
                     }
                     if (isset($arRange['VALUE'])) {
                         $arRange["VALUE"] = str_replace(",", ".", $arRange["VALUE"]);
                         $arRange["VALUE"] = doubleval($arRange["VALUE"]);
                         if (!(0 < $arRange["VALUE"])) {
                             $arMsg[] = array('id' => 'RANGES', 'text' => Loc::getMessage('BT_MOD_CAT_DSC_SV_ERR_BAD_RANGE_VALUE'));
                             $boolResult = false;
                         } elseif (self::TYPE_PERCENT == $arRange['TYPE'] && 100 < $arRange["VALUE"]) {
                             $arMsg[] = array('id' => 'RANGES', 'text' => Loc::getMessage('BT_MOD_CAT_DSC_SV_ERR_BAD_RANGE_VALUE'));
                             $boolResult = false;
                         }
                     } else {
                         $arMsg[] = array('id' => 'RANGES', 'text' => Loc::getMessage('BT_MOD_CAT_DSC_SV_ERR_BAD_RANGE_VALUE'));
                         $boolResult = false;
                     }
                     if (isset($arRange['RANGE_FROM'])) {
                         $arRange["RANGE_FROM"] = str_replace(",", ".", $arRange["RANGE_FROM"]);
                         $arRange["RANGE_FROM"] = doubleval($arRange["RANGE_FROM"]);
                         if (0 > $arRange["RANGE_FROM"]) {
                             $arMsg[] = array('id' => 'RANGES', 'text' => Loc::getMessage('BT_MOD_CAT_DSC_SV_ERR_BAD_RANGE_FROM'));
                             $boolResult = false;
                         } else {
                             if (in_array($arRange["RANGE_FROM"], $arRangeList)) {
                                 $boolRepeat = true;
                             } else {
                                 $arRangeList[] = $arRange["RANGE_FROM"];
                             }
                         }
                     } else {
                         $arMsg[] = array('id' => 'RANGES', 'text' => Loc::getMessage('BT_MOD_CAT_DSC_SV_ERR_BAD_RANGE_FROM'));
                         $boolResult = false;
                     }
                 }
             }
             if (isset($arRange)) {
                 unset($arRange);
             }
             if ($boolRepeat) {
                 $arMsg[] = array('id' => 'RANGES', 'text' => Loc::getMessage('BT_MOD_CAT_DSC_SV_ERR_DUP_RANGE_FROM'));
                 $boolResult = false;
             }
         }
     }
     if (isset($arFields['GROUP_IDS']) || $strAction == 'ADD') {
         if (!empty($arFields['GROUP_IDS'])) {
             if (!is_array($arFields['GROUP_IDS'])) {
                 $arFields['GROUP_IDS'] = array($arFields['GROUP_IDS']);
             }
             $arValid = array();
             foreach ($arFields['GROUP_IDS'] as &$intGroupID) {
                 $intGroupID = (int) $intGroupID;
                 if (0 < $intGroupID && 2 != $intGroupID) {
                     $arValid[] = $intGroupID;
                 }
             }
             if (isset($intGroupID)) {
                 unset($intGroupID);
             }
             $arFields['GROUP_IDS'] = array_unique($arValid);
         }
         if (empty($arFields['GROUP_IDS'])) {
             $arMsg[] = array('id' => 'GROUP_IDS', 'text' => Loc::getMessage('BT_MOD_CAT_DSC_SV_ERR_EMPTY_GROUP_IDS'));
             $boolResult = false;
         }
     }
     if ($boolResult) {
         $cond = new CCatalogCondTree();
         $boolCond = $cond->Init(BT_COND_MODE_GENERATE, BT_COND_BUILD_CATALOG, array());
         if (!$boolCond) {
             $boolResult = false;
         } else {
             $arFields['CONDITIONS'] = $cond->GetDefaultConditions();
             $arFields['UNPACK'] = $cond->Generate($arFields['CONDITIONS'], array());
             $arFields['CONDITIONS'] = serialize($arFields['CONDITIONS']);
         }
     }
     if (!$boolResult) {
         $obError = new CAdminException($arMsg);
         $APPLICATION->ResetException();
         $APPLICATION->ThrowException($obError);
     }
     return $boolResult;
 }
Exemplo n.º 20
0
define('NO_LANG_FILES', true);
define('DisableEventsCheck', true);
define('BX_STATISTIC_BUFFER_USED', false);
define('BX_PUBLIC_TOOLS', true);
define('PUBLIC_AJAX_MODE', true);
if (isset($_REQUEST['site_id']) && is_string($_REQUEST['site_id'])) {
    $siteID = $_REQUEST['site_id'];
    //Prevent LFI in prolog_before.php
    if ($siteID !== '' && preg_match('/^[a-z0-9_]{2}$/i', $siteID) === 1) {
        define('SITE_ID', $siteID);
    }
}
require_once $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/bx_root.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/include/prolog_before.php';
if (!defined('LANGUAGE_ID')) {
    $dbSite = CSite::GetByID(SITE_ID);
    $arSite = $dbSite ? $dbSite->Fetch() : null;
    define('LANGUAGE_ID', $arSite ? $arSite['LANGUAGE_ID'] : 'en');
}
//session_write_close();
if (!CModule::IncludeModule('crm')) {
    die;
}
if (CModule::IncludeModule('compression')) {
    CCompress::Disable2048Spaces();
}
global $APPLICATION, $DB;
$curUser = CCrmSecurityHelper::GetCurrentUser();
if (!$curUser || !$curUser->IsAuthorized() || !check_bitrix_sessid() || $_SERVER['REQUEST_METHOD'] != 'POST') {
    die;
}
Exemplo n.º 21
0
 protected function __ConvertOldFormat($strAction, &$arFields)
 {
     global $APPLICATION;
     $arMsg = array();
     $boolResult = true;
     $arNeedFields = array('LID', 'CURRENCY', 'DISCOUNT_TYPE', 'DISCOUNT_VALUE', 'PRICE_FROM', 'PRICE_TO');
     $arUpdateFields = array('DISCOUNT_VALUE', 'PRICE_FROM', 'PRICE_TO');
     $strAction = ToUpper($strAction);
     if (!array_key_exists('CONDITIONS', $arFields) && !array_key_exists('ACTIONS', $arFields)) {
         $strSiteCurrency = '';
         $boolUpdate = false;
         if ('UPDATE' == $strAction) {
             $boolNeedQuery = false;
             foreach ($arUpdateFields as &$strFieldID) {
                 if (array_key_exists($strFieldID, $arFields)) {
                     $boolUpdate = true;
                     break;
                 }
             }
             if (isset($strFieldID)) {
                 unset($strFieldID);
             }
             if ($boolUpdate) {
                 foreach ($arNeedFields as &$strFieldID) {
                     if (!array_key_exists($strFieldID, $arFields)) {
                         $boolNeedQuery = true;
                         break;
                     }
                 }
                 if (isset($strFieldID)) {
                     unset($strFieldID);
                 }
                 if ($boolNeedQuery) {
                     $rsDiscounts = CSaleDiscount::GetList(array(), array('ID' => $arFields['ID']), false, false, $arNeedFields);
                     if ($arDiscount = $rsDiscounts->Fetch()) {
                         foreach ($arNeedFields as &$strFieldID) {
                             if (!array_key_exists($strFieldID, $arFields)) {
                                 $arFields[$strFieldID] = $arDiscount[$strFieldID];
                             }
                         }
                         if (isset($strFieldID)) {
                             unset($strFieldID);
                         }
                     } else {
                         $boolUpdate = false;
                         $boolResult = false;
                         $arMsg[] = array('id' => 'ID', 'text' => Loc::getMessage('BT_MOD_SALE_ERR_DSC_ABSENT'));
                     }
                 }
             }
         }
         if ('ADD' == $strAction || $boolUpdate) {
             if (!array_key_exists('LID', $arFields)) {
                 $boolResult = false;
                 $arMsg[] = array('id' => 'LID', 'text' => Loc::getMessage('BT_MOD_SALE_ERR_DSC_SITE_ID_ABSENT'));
             } else {
                 $arFields['LID'] = strval($arFields['LID']);
                 if ('' == $arFields['LID']) {
                     $boolResult = false;
                     $arMsg[] = array('id' => 'LID', 'text' => Loc::getMessage('BT_MOD_SALE_ERR_DSC_SITE_ID_ABSENT'));
                 } else {
                     $rsSites = CSite::GetByID($arFields["LID"]);
                     if (!($arSite = $rsSites->Fetch())) {
                         $boolResult = false;
                         $arMsg[] = array('id' => 'LID', 'text' => Loc::getMessage('SKGD_NO_SITE', array('#ID#' => $arFields['LID'])));
                     } else {
                         $strSiteCurrency = CSaleLang::GetLangCurrency($arFields['LID']);
                     }
                 }
             }
             if (!array_key_exists('CURRENCY', $arFields)) {
                 $boolResult = false;
                 $arMsg[] = array('id' => 'CURRENCY', 'text' => Loc::getMessage('BT_MOD_SALE_ERR_DSC_CURRENCY_ABSENT'));
             } else {
                 $arFields['CURRENCY'] = strval($arFields['CURRENCY']);
                 if ('' == $arFields['CURRENCY']) {
                     $boolResult = false;
                     $arMsg[] = array('id' => 'CURRENCY', 'text' => Loc::getMessage('BT_MOD_SALE_ERR_DSC_CURRENCY_ABSENT'));
                 } else {
                     if (!($arCurrency = CCurrency::GetByID($arFields["CURRENCY"]))) {
                         $boolResult = false;
                         $arMsg[] = array('id' => 'CURRENCY', 'text' => Loc::getMessage('SKGD_NO_CURRENCY', array('#ID#' => $arFields['CURRENCY'])));
                     }
                 }
             }
             if (!array_key_exists("DISCOUNT_TYPE", $arFields)) {
                 $boolResult = false;
                 $arMsg[] = array('id' => 'DISCOUNT_TYPE', 'text' => Loc::getMessage('BT_MOD_SALE_ERR_DSC_TYPE_ABSENT'));
             } else {
                 $arFields["DISCOUNT_TYPE"] = strval($arFields["DISCOUNT_TYPE"]);
                 if (CSaleDiscount::OLD_DSC_TYPE_PERCENT != $arFields["DISCOUNT_TYPE"] && CSaleDiscount::OLD_DSC_TYPE_FIX != $arFields["DISCOUNT_TYPE"]) {
                     $boolResult = false;
                     $arMsg[] = array('id' => 'DISCOUNT_TYPE', 'text' => Loc::getMessage('BT_MOD_SALE_ERR_DSC_TYPE_BAD'));
                 }
             }
             if (!array_key_exists('DISCOUNT_VALUE', $arFields)) {
                 $boolResult = false;
                 $arMsg[] = array('id' => 'DISCOUNT_VALUE', 'text' => Loc::getMessage('BT_MOD_SALE_ERR_DSC_VALUE_ABSENT'));
             } else {
                 $arFields['DISCOUNT_VALUE'] = (double) str_replace(',', '.', $arFields['DISCOUNT_VALUE']);
                 if (0 >= $arFields['DISCOUNT_VALUE']) {
                     $boolResult = false;
                     $arMsg[] = array('id' => 'DISCOUNT_VALUE', 'text' => Loc::getMessage('BT_MOD_SALE_ERR_DSC_VALUE_BAD'));
                 }
             }
             if ($boolResult) {
                 $arConditions = array('CLASS_ID' => 'CondGroup', 'DATA' => array('All' => 'AND', 'True' => 'True'), 'CHILDREN' => array());
                 $arActions = array('CLASS_ID' => 'CondGroup', 'DATA' => array('All' => 'AND', 'True' => 'True'), 'CHILDREN' => array());
                 $boolCurrency = $arFields['CURRENCY'] == $strSiteCurrency;
                 if (array_key_exists('PRICE_FROM', $arFields)) {
                     $arFields["PRICE_FROM"] = str_replace(",", ".", strval($arFields["PRICE_FROM"]));
                     $arFields["PRICE_FROM"] = doubleval($arFields["PRICE_FROM"]);
                     if (0 < $arFields["PRICE_FROM"]) {
                         $dblValue = roundEx($boolCurrency ? $arFields['PRICE_FROM'] : CCurrencyRates::ConvertCurrency($arFields['PRICE_FROM'], $arFields['CURRENCY'], $strSiteCurrency), SALE_VALUE_PRECISION);
                         $arConditions['CHILDREN'][] = array('CLASS_ID' => 'CondBsktAmtGroup', 'DATA' => array('logic' => 'EqGr', 'Value' => (string) $dblValue, 'All' => 'AND'), 'CHILDREN' => array());
                         $arFields["PRICE_FROM"] = $dblValue;
                     }
                 }
                 if (array_key_exists('PRICE_TO', $arFields)) {
                     $arFields["PRICE_TO"] = str_replace(",", ".", strval($arFields["PRICE_TO"]));
                     $arFields["PRICE_TO"] = doubleval($arFields["PRICE_TO"]);
                     if (0 < $arFields["PRICE_TO"]) {
                         $dblValue = roundEx($boolCurrency ? $arFields['PRICE_TO'] : CCurrencyRates::ConvertCurrency($arFields['PRICE_TO'], $arFields['CURRENCY'], $strSiteCurrency), SALE_VALUE_PRECISION);
                         $arConditions['CHILDREN'][] = array('CLASS_ID' => 'CondBsktAmtGroup', 'DATA' => array('logic' => 'EqLs', 'Value' => (string) $dblValue, 'All' => 'AND'), 'CHILDREN' => array());
                         $arFields["PRICE_TO"] = $dblValue;
                     }
                 }
                 if (self::OLD_DSC_TYPE_PERCENT == $arFields['DISCOUNT_TYPE']) {
                     $arActions['CHILDREN'][] = array('CLASS_ID' => 'ActSaleBsktGrp', 'DATA' => array('Type' => 'Discount', 'Value' => (string) roundEx($arFields['DISCOUNT_VALUE'], SALE_VALUE_PRECISION), 'Unit' => 'Perc', 'All' => 'AND'), 'CHILDREN' => array());
                 } else {
                     $dblValue = roundEx($boolCurrency ? $arFields['DISCOUNT_VALUE'] : CCurrencyRates::ConvertCurrency($arFields['DISCOUNT_VALUE'], $arFields['CURRENCY'], $strSiteCurrency), SALE_VALUE_PRECISION);
                     $arActions['CHILDREN'][] = array('CLASS_ID' => 'ActSaleBsktGrp', 'DATA' => array('Type' => 'Discount', 'Value' => (string) $dblValue, 'Unit' => 'CurAll', 'All' => 'AND'), 'CHILDREN' => array());
                     $arFields['DISCOUNT_VALUE'] = $dblValue;
                 }
                 $arFields['CONDITIONS'] = $arConditions;
                 $arFields['ACTIONS'] = $arActions;
                 $arFields['CURRENCY'] = $strSiteCurrency;
             } else {
                 $obError = new CAdminException($arMsg);
                 $APPLICATION->ThrowException($obError);
             }
         }
     }
     return $boolResult;
 }
Exemplo n.º 22
0
    <div class="include_module_error">
        <img src="<?php 
echo SITE_TEMPLATE_PATH;
?>
/images/error.jpg" title=":-(">

        <p><?php 
echo GetMessage("ERROR_INCLUDE_MODULE_ALLCORP_TEXT");
?>
</p>
    </div>
    <? die(); ?>
<? endif; ?>
<? CAllCorp::SetJSOptions(); ?>
<? global $arSite, $arTheme; ?>
<? $arSite = CSite::GetByID(SITE_ID)->Fetch(); ?>
<? $arTheme = $APPLICATION->IncludeComponent(
    "aspro:theme.allcorp",
    "",
    [
    ],
    false
); ?>
<div class="body">
    <div class="body_media"></div>
    <div class="top-row">
        <div class="container maxwidth-theme">
            <div class="row">
                <div class="col-md-12">
                    <div class="row">
                        <div class="col-md-6">
Exemplo n.º 23
0
 function NotifyIm($arParams)
 {
     if (!CModule::IncludeModule("im")) {
         return;
     }
     $arUsers = array();
     if (!empty($arParams["TO_USER_ID"])) {
         foreach ($arParams["TO_USER_ID"] as $val) {
             $val = IntVal($val);
             if ($val > 0 && $val != $arParams["FROM_USER_ID"]) {
                 $arUsers[] = $val;
             }
         }
     }
     if (!empty($arParams["TO_SOCNET_RIGHTS"])) {
         foreach ($arParams["TO_SOCNET_RIGHTS"] as $v) {
             if (substr($v, 0, 1) == "U") {
                 $u = IntVal(substr($v, 1));
                 if ($u > 0 && !in_array($u, $arUsers) && empty($arParams["TO_SOCNET_RIGHTS_OLD"][$u]) && $u != $arParams["FROM_USER_ID"]) {
                     $arUsers[] = $u;
                 }
             }
         }
     }
     $arMessageFields = array("MESSAGE_TYPE" => IM_MESSAGE_SYSTEM, "TO_USER_ID" => "", "FROM_USER_ID" => $arParams["FROM_USER_ID"], "NOTIFY_TYPE" => IM_NOTIFY_FROM, "NOTIFY_MODULE" => "blog");
     if (CModule::IncludeModule("socialnetwork")) {
         $rsLog = CSocNetLog::GetList(array(), array("EVENT_ID" => array("blog_post", "blog_post_micro"), "SOURCE_ID" => $arParams["ID"]), false, false, array("ID"));
         if ($arLog = $rsLog->Fetch()) {
             $arMessageFields["LOG_ID"] = $arLog["ID"];
         }
     }
     $arParams["TITLE"] = str_replace(array("\r\n", "\n"), " ", $arParams["TITLE"]);
     $arParams["TITLE"] = TruncateText($arParams["TITLE"], 100);
     $arParams["TITLE_OUT"] = TruncateText($arParams["TITLE"], 255);
     $dbSite = CSite::GetByID(SITE_ID);
     $arSite = $dbSite->Fetch();
     $serverName = htmlspecialcharsEx($arSite["SERVER_NAME"]);
     if (strlen($serverName) <= 0) {
         if (defined("SITE_SERVER_NAME") && strlen(SITE_SERVER_NAME) > 0) {
             $serverName = SITE_SERVER_NAME;
         } else {
             $serverName = COption::GetOptionString("main", "server_name", "");
         }
     }
     $serverName = (CMain::IsHTTPS() ? "https" : "http") . "://" . $serverName;
     if ($arParams["TYPE"] == "POST") {
         $arMessageFields["NOTIFY_EVENT"] = "post";
         $arMessageFields["NOTIFY_TAG"] = "BLOG|POST|" . $arParams["ID"];
         $arMessageFields["NOTIFY_MESSAGE"] = GetMessage("BLG_GP_IM_1", array("#title#" => "<a href=\"" . $arParams["URL"] . "\" class=\"bx-notifier-item-action\">" . htmlspecialcharsbx($arParams["TITLE"]) . "</a>"));
         $arMessageFields["NOTIFY_MESSAGE_OUT"] = GetMessage("BLG_GP_IM_1", array("#title#" => htmlspecialcharsbx($arParams["TITLE_OUT"]))) . " (" . $serverName . $arParams["URL"] . ")";
     } elseif ($arParams["TYPE"] == "COMMENT") {
         $arMessageFields["NOTIFY_EVENT"] = "comment";
         $arMessageFields["NOTIFY_TAG"] = "BLOG|COMMENT|" . $arParams["ID"];
         $arMessageFields["NOTIFY_MESSAGE"] = GetMessage("BLG_GP_IM_4", array("#title#" => "<a href=\"" . $arParams["URL"] . "\" class=\"bx-notifier-item-action\">" . htmlspecialcharsbx($arParams["TITLE"]) . "</a>"));
         $arMessageFields["NOTIFY_MESSAGE_OUT"] = GetMessage("BLG_GP_IM_4", array("#title#" => htmlspecialcharsbx($arParams["TITLE_OUT"]))) . " (" . $serverName . $arParams["URL"] . ")";
         $arMessageFields["NOTIFY_MESSAGE_AUTHOR"] = GetMessage("BLG_GP_IM_5", array("#title#" => "<a href=\"" . $arParams["URL"] . "\" class=\"bx-notifier-item-action\">" . htmlspecialcharsbx($arParams["TITLE"]) . "</a>"));
         $arMessageFields["NOTIFY_MESSAGE_AUTHOR_OUT"] = GetMessage("BLG_GP_IM_5", array("#title#" => htmlspecialcharsbx($arParams["TITLE_OUT"]))) . " (" . $serverName . $arParams["URL"] . ")";
     }
     foreach ($arUsers as $v) {
         if (!empty($arParams["EXCLUDE_USERS"]) && IntVal($arParams["EXCLUDE_USERS"][$v]) > 0) {
             continue;
         }
         $arMessageFieldsTmp = $arMessageFields;
         if ($arParams["TYPE"] == "COMMENT") {
             if ($arParams["AUTHOR_ID"] == $v) {
                 $arMessageFieldsTmp["NOTIFY_MESSAGE"] = $arMessageFields["NOTIFY_MESSAGE_AUTHOR"];
                 $arMessageFieldsTmp["NOTIFY_MESSAGE_OUT"] = $arMessageFields["NOTIFY_MESSAGE_AUTHOR_OUT"];
             }
         }
         $arMessageFieldsTmp["TO_USER_ID"] = $v;
         $ID = CIMNotify::Add($arMessageFieldsTmp);
     }
     if (!empty($arParams["MENTION_ID"])) {
         if (!is_array($arParams["MENTION_ID_OLD"])) {
             $arParams["MENTION_ID_OLD"] = array();
         }
         foreach ($arParams["MENTION_ID"] as $val) {
             $val = IntVal($val);
             if (IntVal($val) > 0 && !in_array($val, $arUsers) && !in_array($val, $arParams["MENTION_ID_OLD"]) && $val != $arParams["FROM_USER_ID"]) {
                 if (CBlogPost::GetSocNetPostPerms($arParams["ID"], false, $val) >= BLOG_PERMS_READ) {
                     $arMessageFields["TO_USER_ID"] = $val;
                     $arMessageFields["NOTIFY_EVENT"] = "mention";
                     if ($arParams["TYPE"] == "POST") {
                         $arMessageFields["NOTIFY_TAG"] = "BLOG|POST_MENTION|" . $arParams["ID"];
                         $arMessageFields["NOTIFY_MESSAGE"] = GetMessage("BLG_GP_IM_6", array("#title#" => "<a href=\"" . $arParams["URL"] . "\" class=\"bx-notifier-item-action\">" . htmlspecialcharsbx($arParams["TITLE"]) . "</a>"));
                         $arMessageFields["NOTIFY_MESSAGE_OUT"] = GetMessage("BLG_GP_IM_6", array("#title#" => htmlspecialcharsbx($arParams["TITLE_OUT"]))) . " (" . $arParams["URL"] . ")";
                     } elseif ($arParams["TYPE"] == "COMMENT") {
                         $arMessageFields["NOTIFY_TAG"] = "BLOG|COMMENT_MENTION|" . $arParams["ID"];
                         $arMessageFields["NOTIFY_MESSAGE"] = GetMessage("BLG_GP_IM_7", array("#title#" => "<a href=\"" . $arParams["URL"] . "\" class=\"bx-notifier-item-action\">" . htmlspecialcharsbx($arParams["TITLE"]) . "</a>"));
                         $arMessageFields["NOTIFY_MESSAGE_OUT"] = GetMessage("BLG_GP_IM_7", array("#title#" => htmlspecialcharsbx($arParams["TITLE_OUT"]))) . " (" . $arParams["URL"] . ")";
                     }
                     $ID = CIMNotify::Add($arMessageFields);
                     if (intval($ID) > 0 && intval($arMessageFields["LOG_ID"]) > 0) {
                         $db_events = GetModuleEvents("blog", "OnBlogPostMentionNotifyIm");
                         while ($arEvent = $db_events->Fetch()) {
                             ExecuteModuleEventEx($arEvent, array($ID, $arMessageFields));
                         }
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 24
0
	public static function SendEvent($ID, $mailTemplate = "SONET_NEW_EVENT", $tmp_id = false, $bAgent = false, $bTransport = false)
	{
		$ID = IntVal($ID);
		if ($ID <= 0)
			return false;

		if (intval($tmp_id) > 0)
			$arFilter = array("ID" => $tmp_id);
		else
			$arFilter = array("ID" => $ID);

		$dbLog = CSocNetLog::GetList(
			array(),
			$arFilter,
			false,
			false,
			array("ID", "ENTITY_TYPE", "ENTITY_ID", "USER_ID", "USER_NAME", "USER_LAST_NAME", "USER_SECOND_NAME", "USER_LOGIN", "EVENT_ID", "LOG_DATE", "TITLE_TEMPLATE", "TITLE", "MESSAGE", "TEXT_MESSAGE", "URL", "MODULE_ID", "CALLBACK_FUNC", "SITE_ID", "PARAMS", "SOURCE_ID", "GROUP_NAME", "CREATED_BY_NAME", "CREATED_BY_SECOND_NAME", "CREATED_BY_LAST_NAME", "CREATED_BY_LOGIN", "LOG_SOURCE_ID"),
			array("MIN_ID_JOIN" => true)
		);
		$arLog = $dbLog->Fetch();
		if (!$arLog)
			return $bAgent;

		if (MakeTimeStamp($arLog["LOG_DATE"]) > (time() + CTimeZone::GetOffset()))
		{
			$agent = "CSocNetLog::SendEventAgent(".$ID.", '".$mailTemplate."', ".($tmp_id ? $tmp_id : 'false').");";
			$rsAgents = CAgent::GetList(array("ID"=>"DESC"), array("NAME" => $agent));
			if(!$rsAgents->Fetch())
			{
				$res = CAgent::AddAgent($agent, "socialnetwork", "N", 0, $arLog["LOG_DATE"], "Y", $arLog["LOG_DATE"]);
				if(!$res)
					$GLOBALS["APPLICATION"]->ResetException();
			}
			elseif ($bAgent)
			{
				CAgent::RemoveAgent($agent, "socialnetwork");
				CAgent::AddAgent($agent, "socialnetwork", "N", 0, $arLog["LOG_DATE"], "Y", $arLog["LOG_DATE"]);
				return true;
			}
			return false;
		}

		$arEvent = CSocNetLogTools::FindLogEventByID($arLog["EVENT_ID"], $arLog["ENTITY_TYPE"]);
		if (
			$arEvent
			&& array_key_exists("CLASS_FORMAT", $arEvent)
			&& array_key_exists("METHOD_FORMAT", $arEvent)
		)
		{
			$dbSiteCurrent = CSite::GetByID(SITE_ID);
			if ($arSiteCurrent = $dbSiteCurrent->Fetch())
				if ($arSiteCurrent["LANGUAGE_ID"] != LANGUAGE_ID)
					$arLog["MAIL_LANGUAGE_ID"] = $arSiteCurrent["LANGUAGE_ID"];

			$arLog["FIELDS_FORMATTED"] = call_user_func(array($arEvent["CLASS_FORMAT"], $arEvent["METHOD_FORMAT"]), $arLog, array(), true);
		}

		if (
			array_key_exists($arLog["ENTITY_TYPE"], $GLOBALS["arSocNetAllowedSubscribeEntityTypesDesc"])
			&& array_key_exists("HAS_MY", $GLOBALS["arSocNetAllowedSubscribeEntityTypesDesc"][$arLog["ENTITY_TYPE"]])
			&& $GLOBALS["arSocNetAllowedSubscribeEntityTypesDesc"][$arLog["ENTITY_TYPE"]]["HAS_MY"] == "Y"
			&& array_key_exists("CLASS_OF", $GLOBALS["arSocNetAllowedSubscribeEntityTypesDesc"][$arLog["ENTITY_TYPE"]])
			&& array_key_exists("METHOD_OF", $GLOBALS["arSocNetAllowedSubscribeEntityTypesDesc"][$arLog["ENTITY_TYPE"]])
			&& strlen($GLOBALS["arSocNetAllowedSubscribeEntityTypesDesc"][$arLog["ENTITY_TYPE"]]["CLASS_OF"]) > 0
			&& strlen($GLOBALS["arSocNetAllowedSubscribeEntityTypesDesc"][$arLog["ENTITY_TYPE"]]["METHOD_OF"]) > 0
			&& method_exists($GLOBALS["arSocNetAllowedSubscribeEntityTypesDesc"][$arLog["ENTITY_TYPE"]]["CLASS_OF"], $GLOBALS["arSocNetAllowedSubscribeEntityTypesDesc"][$arLog["ENTITY_TYPE"]]["METHOD_OF"])
		)
			$arOfEntities = call_user_func(array($GLOBALS["arSocNetAllowedSubscribeEntityTypesDesc"][$arLog["ENTITY_TYPE"]]["CLASS_OF"], $GLOBALS["arSocNetAllowedSubscribeEntityTypesDesc"][$arLog["ENTITY_TYPE"]]["METHOD_OF"]), $arLog["ENTITY_ID"]);

		if ($bTransport)
		{
			$arListParams = array(
				"USE_SUBSCRIBE" => "Y",
				"ENTITY_TYPE" => $arLog["ENTITY_TYPE"],
				"ENTITY_ID" => $arLog["ENTITY_ID"],
				"EVENT_ID" => $arLog["EVENT_ID"],
				"USER_ID" => $arLog["USER_ID"],
				"OF_ENTITIES" => $arOfEntities,
				"TRANSPORT" => array("M", "X")
			);

			$arLogSites = array();
			$rsLogSite = CSocNetLog::GetSite($ID);

			while($arLogSite = $rsLogSite->Fetch())
				$arLogSites[] = $arLogSite["LID"];

			if (CModule::IncludeModule("extranet"))
			{
				$arSites = array();
				$dbSite = CSite::GetList($by="sort", $order="desc", array("ACTIVE" => "Y"));
				while($arSite = $dbSite->Fetch())
					$arSites[$arSite["ID"]] = array(
						"DIR" => (strlen(trim($arSite["DIR"])) > 0 ? $arSite["DIR"] : "/"),
						"SERVER_NAME" => (strlen(trim($arSite["SERVER_NAME"])) > 0 ? $arSite["SERVER_NAME"] : COption::GetOptionString("main", "server_name", $_SERVER["HTTP_HOST"]))
					);

				$extranet_site_id = CExtranet::GetExtranetSiteID();
				$intranet_site_id = CSite::GetDefSite();

				$arIntranetUsers = CExtranet::GetIntranetUsers();
			}

			$dbSubscribers = CSocNetLogEvents::GetList(
				array("TRANSPORT" => "DESC"),
				array(
					"USER_ACTIVE" => "Y",
					"SITE_ID" => array_merge($arLogSites, array(false))
				),
				false,
				false,
				array("USER_ID", "SITE_ID", "ENTITY_TYPE", "ENTITY_ID", "ENTITY_CB", "ENTITY_MY", "USER_NAME", "USER_LAST_NAME", "USER_LOGIN", "USER_LID", "USER_EMAIL", "TRANSPORT"),
				$arListParams
			);

			$arListParams = array(
				"USE_SUBSCRIBE" => "Y",
				"ENTITY_TYPE" => $arLog["ENTITY_TYPE"],
				"ENTITY_ID" => $arLog["ENTITY_ID"],
				"EVENT_ID" => $arLog["EVENT_ID"],
				"USER_ID" => $arLog["USER_ID"],
				"OF_ENTITIES" => $arOfEntities,
				"TRANSPORT" => "N"
			);

			$dbUnSubscribers = CSocNetLogEvents::GetList(
				array("TRANSPORT" => "DESC"),
				array(
					"USER_ACTIVE" => "Y",
					"SITE_ID" => array_merge($arLogSites, array(false))
				),
				false,
				false,
				array("USER_ID", "SITE_ID", "ENTITY_TYPE", "ENTITY_ID", "ENTITY_CB", "ENTITY_MY", "TRANSPORT", "EVENT_ID"),
				$arListParams
			);

			$arUnSubscribers = array();
			while ($arUnSubscriber = $dbUnSubscribers->Fetch())
				$arUnSubscribers[] = $arUnSubscriber["USER_ID"]."_".$arUnSubscriber["ENTITY_TYPE"]."_".$arUnSubscriber["ENTITY_ID"]."_".$arUnSubscriber["ENTITY_MY"]."_".$arUnSubscriber["ENTITY_CB"]."_".$arUnSubscriber["EVENT_ID"];

			$bHasAccessAll = CSocNetLogRights::CheckForUserAll($arLog["ID"]);

			$arSentUserID = array("M" => array(), "X" => array());
			while ($arSubscriber = $dbSubscribers->Fetch())
			{
				if (
					is_array($arIntranetUsers)
					&& !in_array($arSubscriber["USER_ID"], $arIntranetUsers)
					&& !in_array($extranet_site_id, $arLogSites)
				)
					continue;

				if (
					array_key_exists($arSubscriber["TRANSPORT"], $arSentUserID)
					&& in_array($arSubscriber["USER_ID"], $arSentUserID[$arSubscriber["TRANSPORT"]])
				)
					continue;

				if (
					intval($arSubscriber["ENTITY_ID"]) != 0
					&& $arSubscriber["EVENT_ID"] == "all"
					&&
					(
						in_array($arSubscriber["USER_ID"]."_".$arSubscriber["ENTITY_TYPE"]."_".$arSubscriber["ENTITY_ID"]."_N_".$arSubscriber["ENTITY_CB"]."_".$arLog["EVENT_ID"], $arUnSubscribers)
						|| in_array($arSubscriber["USER_ID"]."_".$arSubscriber["ENTITY_TYPE"]."_".$arSubscriber["ENTITY_ID"]."_Y_".$arSubscriber["ENTITY_CB"]."_".$arLog["EVENT_ID"], $arUnSubscribers)
					)
				)
					continue;
				elseif (
					intval($arSubscriber["ENTITY_ID"]) == 0
					&& $arSubscriber["ENTITY_CB"] == "N"
					&& $arSubscriber["EVENT_ID"] != "all"
					&&
					(
						in_array($arSubscriber["USER_ID"]."_".$arSubscriber["ENTITY_TYPE"]."_".$arLog["ENTITY_ID"]."_Y_N_all", $arUnSubscribers)
						|| in_array($arSubscriber["USER_ID"]."_".$arSubscriber["ENTITY_TYPE"]."_".$arLog["ENTITY_ID"]."_N_N_all", $arUnSubscribers)
						|| in_array($arSubscriber["USER_ID"]."_".$arSubscriber["ENTITY_TYPE"]."_".$arLog["ENTITY_ID"]."_Y_N_".$arLog["EVENT_ID"], $arUnSubscribers)
						|| in_array($arSubscriber["USER_ID"]."_".$arSubscriber["ENTITY_TYPE"]."_".$arLog["ENTITY_ID"]."_N_N_".$arLog["EVENT_ID"], $arUnSubscribers)
					)
				)
					continue;

				$arSentUserID[$arSubscriber["TRANSPORT"]][] = $arSubscriber["USER_ID"];

				if (!$bHasAccessAll)
				{
					$bHasAccess = CSocNetLogRights::CheckForUserOnly($arLog["ID"], $arSubscriber["USER_ID"]);
					if (!$bHasAccess)
						continue;
				}

				if (CModule::IncludeModule("extranet"))
				{
					$server_name = $arSites[((!in_array($arSubscriber["USER_ID"], $arIntranetUsers) && $extranet_site_id) ? $extranet_site_id : $intranet_site_id)]["SERVER_NAME"];
					$arLog["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["URL_TO_SEND"] = str_replace(
						array("#SERVER_NAME#", "#GROUPS_PATH#"),
						array(
							$server_name,
							COption::GetOptionString("socialnetwork", "workgroups_page", false, ((!in_array($arSubscriber["USER_ID"], $arIntranetUsers) && $extranet_site_id) ? $extranet_site_id : $intranet_site_id))
						),
						$arLog["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["URL"]
					);
					$arLog["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["MESSAGE_TO_SEND"] = str_replace(
						array("#SERVER_NAME#", "#GROUPS_PATH#"),
						array(
							$server_name,
							COption::GetOptionString("socialnetwork", "workgroups_page", false, ((!in_array($arSubscriber["USER_ID"], $arIntranetUsers) && $extranet_site_id) ? $extranet_site_id : $intranet_site_id))
						),
						$arLog["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["MESSAGE"]
					);
				}
				else
					$arLog["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["MESSAGE_TO_SEND"] = $arLog["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["MESSAGE"];

				switch ($arSubscriber["TRANSPORT"])
				{
					case "X":

						if (
							array_key_exists("URL_TO_SEND", $arLog["FIELDS_FORMATTED"]["EVENT_FORMATTED"])
							&& strlen($arLog["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["URL_TO_SEND"]) > 0
						)
							$link = GetMessage("SONET_GL_SEND_EVENT_LINK").$arLog["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["URL_TO_SEND"];
						elseif (
							array_key_exists("URL", $arLog["FIELDS_FORMATTED"]["EVENT_FORMATTED"])
							&& strlen($arLog["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["URL"]) > 0
						)
							$link = GetMessage("SONET_GL_SEND_EVENT_LINK").$arLog["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["URL"];
						else
							$link = "";

						$arMessageFields = array(
							"FROM_USER_ID" => (intval($arLog["USER_ID"]) > 0 ? $arLog["USER_ID"] : 1),
							"TO_USER_ID" => $arSubscriber["USER_ID"],
							"MESSAGE" => $arLog["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["TITLE"]." #BR#".$arLog["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["MESSAGE_TO_SEND"].(strlen($link) > 0 ? "#BR# ".$link : ""),
							"=DATE_CREATE" => $GLOBALS["DB"]->CurrentTimeFunction(),
							"MESSAGE_TYPE" => SONET_MESSAGE_SYSTEM,
							"IS_LOG" => "Y"
						);
						CSocNetMessages::Add($arMessageFields);
						break;
					case "M":
						$arFields["SUBSCRIBER_ID"] = $arSubscriber["USER_ID"];
						$arFields["SUBSCRIBER_NAME"] = $arSubscriber["USER_NAME"];
						$arFields["SUBSCRIBER_LAST_NAME"] = $arSubscriber["USER_LAST_NAME"];
						$arFields["SUBSCRIBER_LOGIN"] = $arSubscriber["USER_LOGIN"];
						$arFields["SUBSCRIBER_EMAIL"] = $arSubscriber["USER_EMAIL"];
						$arFields["EMAIL_TO"] = $arSubscriber["USER_EMAIL"];
						$arFields["TITLE"] = str_replace("#BR#", "\n", $arLog["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["TITLE"]);
						$arFields["MESSAGE"] = str_replace("#BR#", "\n", $arLog["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["MESSAGE_TO_SEND"]);
						$arFields["ENTITY"] = $arLog["FIELDS_FORMATTED"]["ENTITY"]["FORMATTED"];
						$arFields["ENTITY_TYPE"] = $arLog["FIELDS_FORMATTED"]["ENTITY"]["TYPE_MAIL"];

						if (
							array_key_exists("URL_TO_SEND", $arLog["FIELDS_FORMATTED"]["EVENT_FORMATTED"])
							&& strlen($arLog["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["URL_TO_SEND"]) > 0
						)
							$arFields["URL"] = $arLog["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["URL_TO_SEND"];
						elseif (
							array_key_exists("URL", $arLog["FIELDS_FORMATTED"]["EVENT_FORMATTED"])
							&& strlen($arLog["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["URL"]) > 0
						)
							$arFields["URL"] = $arLog["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["URL"];
						else
							$arFields["URL"] = $arLog["URL"];

						if (CModule::IncludeModule("extranet"))
							$arUserGroup = CUser::GetUserGroup($arSubscriber["USER_ID"]);

						foreach ($arLogSites as $site_id_tmp)
						{
							if (IsModuleInstalled("extranet"))
							{
								if (
									(
										CExtranet::IsExtranetSite($site_id_tmp)
										&& in_array(CExtranet::GetExtranetUserGroupID(), $arUserGroup)
									)
									||
									(
										!CExtranet::IsExtranetSite($site_id_tmp)
										&& !in_array(CExtranet::GetExtranetUserGroupID(), $arUserGroup)
									)
								)
								{
									$siteID = $site_id_tmp;
									break;
								}
								else
									continue;
							}
							else
							{
								$siteID = $site_id_tmp;
								break;
							}
						}

						if (!$siteID)
							$siteID = (defined("SITE_ID") ? SITE_ID : $arSubscriber["SITE_ID"]);

						if (StrLen($siteID) <= 0)
							$siteID = $arSubscriber["USER_LID"];
						if (StrLen($siteID) <= 0)
							continue;

						$event = new CEvent;
						$event->Send($mailTemplate, $siteID, $arFields, "N");
						break;
					default:
				}
			}
		}

		CSocNetLog::CounterIncrement($arLog["ID"], $arLog["EVENT_ID"], $arOfEntities);

		return true;
	}
Exemplo n.º 25
0
    }
    if (!$USER->CanDoOperation("fileman_edit_existent_files")) {
        $canEditNewPage = false;
    }
}
$io = CBXVirtualIo::GetInstance();
//Page path
$path = "/";
if (isset($_REQUEST["path"]) && strlen($_REQUEST["path"]) > 0) {
    $path = $io->CombinePath("/", $_REQUEST["path"]);
}
$documentRoot = CSite::GetSiteDocRoot($site);
//Site ID
$site = SITE_ID;
if (isset($_REQUEST["site"]) && $_REQUEST["site"] != '') {
    $obSite = CSite::GetByID($_REQUEST["site"]);
    if ($arSite = $obSite->Fetch()) {
        $site = $arSite["ID"];
    }
}
//Check permissions
if ($createNewFolder && (!$USER->CanDoFileOperation("fm_create_new_folder", array($site, $path)) || !$USER->CanDoFileOperation("fm_create_new_file", array($site, $path)))) {
    $popupWindow->ShowError(GetMessage("PAGE_NEW_ACCESS_DENIED"));
} elseif (!$USER->CanDoFileOperation("fm_create_new_file", array($site, $path))) {
    $popupWindow->ShowError(GetMessage("PAGE_NEW_ACCESS_DENIED"));
} elseif (!$io->DirectoryExists($documentRoot . $path)) {
    $popupWindow->ShowError(GetMessage("PAGE_NEW_FOLDER_NOT_FOUND") . " (" . htmlspecialcharsbx($path) . ")");
}
if (!$USER->CanDoFileOperation("fm_edit_existent_file", array($site, $path))) {
    $canEditNewPage = false;
}
Exemplo n.º 26
0
 function StemIndex($arLID, $ID, $sContent)
 {
     $DB = CDatabase::GetModuleConnection('search');
     static $CACHE_SITE_LANGS = array();
     $ID = intval($ID);
     $arLang = array();
     if (!is_array($arLID)) {
         $arLID = array();
     }
     foreach ($arLID as $site => $url) {
         if (!array_key_exists($site, $CACHE_SITE_LANGS)) {
             $db_site_tmp = CSite::GetByID($site);
             if ($ar_site_tmp = $db_site_tmp->Fetch()) {
                 $CACHE_SITE_LANGS[$site] = array("LANGUAGE_ID" => $ar_site_tmp["LANGUAGE_ID"], "CHARSET" => $ar_site_tmp["CHARSET"], "SERVER_NAME" => $ar_site_tmp["SERVER_NAME"]);
             } else {
                 $CACHE_SITE_LANGS[$site] = false;
             }
         }
         if (is_array($CACHE_SITE_LANGS[$site])) {
             $arLang[$CACHE_SITE_LANGS[$site]["LANGUAGE_ID"]] = true;
         }
     }
     foreach ($arLang as $lang => $value) {
         $sql_lang = $DB->ForSql($lang);
         $arDoc = stemming($sContent, $lang);
         $docLength = array_sum($arDoc);
         if (BX_SEARCH_VERSION > 1) {
             $arPos = stemming($sContent, $lang, false, true);
             CSearch::RegisterStem($arDoc);
         }
         if ($docLength > 0) {
             $doc = "";
             $logDocLength = log($docLength < 20 ? 20 : $docLength);
             $strSqlPrefix = "\n\t\t\t\t\t\tinsert ignore into b_search_content_stem\n\t\t\t\t\t\t(SEARCH_CONTENT_ID, LANGUAGE_ID, STEM, TF" . (BX_SEARCH_VERSION > 1 ? ",PS" : "") . ")\n\t\t\t\t\t\tvalues\n\t\t\t\t";
             $maxValuesLen = 2048;
             $strSqlValues = "";
             if (BX_SEARCH_VERSION > 1) {
                 foreach ($arDoc as $word => $count) {
                     $stem_id = CSearch::RegisterStem($word);
                     //This is almost impossible, but happens
                     if ($stem_id > 0) {
                         $strSqlValues .= ",\n(" . $ID . ", '" . $sql_lang . "'" . ", " . CSearch::RegisterStem($word) . ", " . number_format(log($count + 1) / $logDocLength, 4, ".", "") . ", " . number_format($arPos[$word] / $count, 4, ".", "") . ")";
                     }
                     if (strlen($strSqlValues) > $maxValuesLen) {
                         $DB->Query($strSqlPrefix . substr($strSqlValues, 2), false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
                         $strSqlValues = "";
                     }
                 }
             } else {
                 foreach ($arDoc as $word => $count) {
                     $strSqlValues .= ",\n(" . $ID . ", '" . $sql_lang . "'" . ", '" . $DB->ForSQL($word) . "'" . ", " . number_format(log($count + 1) / $logDocLength, 4, ".", "") . ")";
                     if (strlen($strSqlValues) > $maxValuesLen) {
                         $DB->Query($strSqlPrefix . substr($strSqlValues, 2), false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
                         $strSqlValues = "";
                     }
                 }
             }
             if (strlen($strSqlValues) > 0) {
                 $DB->Query($strSqlPrefix . substr($strSqlValues, 2), false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
                 $strSqlValues = "";
             }
         }
     }
 }
Exemplo n.º 27
0
         $userType = new CUserTypeEntity();
         $userType->Update($arRes["ID"], $arProperty);
     }
     //if($ex = $APPLICATION->GetException())
     //$strError = $ex->GetString();
 }
 //demo discount
 $dbDiscount = CCatalogDiscount::GetList(array(), array("SITE_ID" => WIZARD_SITE_ID));
 if (!$dbDiscount->Fetch()) {
     if (CModule::IncludeModule("iblock")) {
         $dbSect = CIBlockSection::GetList(array(), array("IBLOCK_TYPE" => "catalog", "IBLOCK_ID" => $IBLOCK_CATALOG_ID, "CODE" => "underwear", "IBLOCK_SITE_ID" => WIZARD_SITE_ID));
         if ($arSect = $dbSect->Fetch()) {
             $sofasSectId = $arSect["ID"];
         }
     }
     $dbSite = CSite::GetByID(WIZARD_SITE_ID);
     if ($arSite = $dbSite->Fetch()) {
         $lang = $arSite["LANGUAGE_ID"];
     }
     $defCurrency = "EUR";
     if ($lang == "ru") {
         $defCurrency = "RUB";
     } elseif ($lang == "en") {
         $defCurrency = "USD";
     }
     $arF = array("SITE_ID" => WIZARD_SITE_ID, "ACTIVE" => "Y", "RENEWAL" => "N", "NAME" => GetMessage("WIZ_DISCOUNT"), "SORT" => 100, "MAX_DISCOUNT" => 0, "VALUE_TYPE" => "P", "VALUE" => 10, "CURRENCY" => $defCurrency, "CONDITIONS" => array("CLASS_ID" => "CondGroup", "DATA" => array("All" => "OR", "True" => "True"), "CHILDREN" => array(array("CLASS_ID" => "CondIBSection", "DATA" => array("logic" => "Equal", "value" => $sofasSectId)))));
     CCatalogDiscount::Add($arF);
 }
 //precet
 $dbProperty = CIBlockProperty::GetList(array(), array("IBLOCK_ID" => $IBLOCK_CATALOG_ID, "CODE" => "SALELEADER"));
 $arFields = array();
Exemplo n.º 28
0
        return;
    }
    $success = $package->ImportPackage();
    if ($success) {
        $dbResult = CCourse::GetList(array(), array("CODE" => "BX-ADM001"));
        $arCourse = $dbResult->Fetch();
    }
}
if (isset($arCourse["ID"])) {
    CCourse::SetPermission($arCourse["ID"], array("2" => "R"));
}
//Public files
CopyDirFiles($pathToService . "/" . LANGUAGE_ID . "/public", $_SERVER["DOCUMENT_ROOT"] . "/communication/learning", $rewrite = false, $recursive = true);
//Left menu
DemoSiteUtil::AddMenuItem("/communication/.left.menu.php", array(GetMessage("SERVICE_LEARNING"), "/communication/learning/", array(), array(), ""));
//Template
CopyDirFiles($pathToService . "/" . LANGUAGE_ID . "/template", $_SERVER["DOCUMENT_ROOT"] . BX_PERSONAL_ROOT . "/templates/learning", $rewrite = true, $recursive = true);
$obSite = CSite::GetByID("s1");
if (!($arSite = $obSite->Fetch())) {
    return;
}
$arTemplates = array();
$obTemplate = CSite::GetTemplateList("s1");
while ($arTemplate = $obTemplate->Fetch()) {
    $arTemplates[] = $arTemplate;
}
$arTemplates[] = array("CONDITION" => "CSite::InDir('/communication/learning/course/')", "SORT" => 150, "TEMPLATE" => "learning");
$obSite = new CSite();
$obSite->Update("s1", array("TEMPLATE" => $arTemplates, "NAME" => $arSite["NAME"]));
//Communication section
include dirname(__FILE__) . "/../communication/install.php";
Exemplo n.º 29
0
    function EditPost($params)
    {
        global $USER, $DB;
        $postId = IntVal(CBlogMetaWeblog::DecodeParams($params[0]["#"]["value"][0]["#"]));
        $user = CBlogMetaWeblog::DecodeParams($params[1]["#"]["value"][0]["#"]);
        $password = CBlogMetaWeblog::DecodeParams($params[2]["#"]["value"][0]["#"]);
        $arPostInfo = $params[3]["#"]["value"][0]["#"]["struct"][0]["#"]["member"];
        $publish = $params[4]["#"]["value"][0]["#"]["boolean"][0]["#"];
        foreach ($arPostInfo as $val) {
            ${$val["#"]["name"][0]["#"]} = CBlogMetaWeblog::DecodeParams($val["#"]["value"][0]["#"]);
        }
        $arCategory = array();
        if (is_array($categories["data"][0]["#"]["value"])) {
            foreach ($categories["data"][0]["#"]["value"] as $val) {
                $catTmp = CBlogMetaWeblog::DecodeParams($val["#"]);
                if (strlen($catTmp) > 0) {
                    $arCategory[] = $catTmp;
                }
            }
        }
        if (CBlogMetaWeblog::Authorize($user, $password)) {
            $result = '';
            $userId = $USER->GetID();
            if (IntVal($postId) > 0) {
                $arSelectedFields = array("ID", "BLOG_ID", "TITLE", "DATE_PUBLISH", "AUTHOR_ID", "DETAIL_TEXT", "DETAIL_TEXT_TYPE");
                $dbPost = CBlogPost::GetList(array(), array("AUTHOR_ID" => $userId, "ID" => $postId), false, array("nTopCount" => 1), $arSelectedFields);
                if ($arPost = $dbPost->Fetch()) {
                    $arBlog = CBlog::GetByID($arPost["BLOG_ID"]);
                    if (intval($arBlog["SOCNET_GROUP_ID"]) > 0 && CModule::IncludeModule("socialnetwork") && method_exists("CSocNetGroup", "GetSite")) {
                        $arSites = array();
                        $rsGroupSite = CSocNetGroup::GetSite($arBlog["SOCNET_GROUP_ID"]);
                        while ($arGroupSite = $rsGroupSite->Fetch()) {
                            $arSites[] = $arGroupSite["LID"];
                        }
                    } else {
                        $arSites = array(SITE_ID);
                    }
                    $CATEGORYtmp = array();
                    $dbCategory = CBlogCategory::GetList(array(), array("BLOG_ID" => $arPost["BLOG_ID"]));
                    while ($arCat = $dbCategory->Fetch()) {
                        $arCatBlog[ToLower($arCat["NAME"])] = $arCat["ID"];
                    }
                    foreach ($arCategory as $tg) {
                        $tg = trim($tg);
                        if (!in_array($arCatBlog[ToLower($tg)], $CATEGORYtmp)) {
                            if (IntVal($arCatBlog[ToLower($tg)]) > 0) {
                                $CATEGORYtmp[] = $arCatBlog[ToLower($tg)];
                            } else {
                                $CATEGORYtmp[] = CBlogCategory::Add(array("BLOG_ID" => $arPost["BLOG_ID"], "NAME" => $tg));
                                foreach ($arSites as $site_id_tmp) {
                                    BXClearCache(True, "/" . $site_id_tmp . "/blog/" . $arBlog["URL"] . "/category/");
                                }
                            }
                        }
                    }
                    $dbSite = CSite::GetByID(SITE_ID);
                    $arSite = $dbSite->Fetch();
                    $serverName = htmlspecialcharsEx($arSite["SERVER_NAME"]);
                    if (strlen($serverName) <= 0) {
                        if (defined("SITE_SERVER_NAME") && strlen(SITE_SERVER_NAME) > 0) {
                            $serverName = SITE_SERVER_NAME;
                        } else {
                            $serverName = COption::GetOptionString("main", "server_name", "www.bitrixsoft.com");
                        }
                    }
                    $dbImage = CBlogImage::GetList(array(), array("POST_ID" => false, "BLOG_ID" => $arBlog["ID"], "IS_COMMENT" => "N"));
                    while ($arImage = $dbImage->Fetch()) {
                        $path = "";
                        $path = CFile::GetPath($arImage["FILE_ID"]);
                        $path = "http://" . $serverName . $path;
                        if (strpos($description, $path) !== false) {
                            $description = str_replace('<img src="' . $path . '" alt=""/>', "[IMG ID=" . $arImage["ID"] . "]", $description);
                            CBlogImage::Update($arImage["ID"], array("POST_ID" => $arPost["ID"]));
                        }
                    }
                    $arFields = array("TITLE" => $title, "DETAIL_TEXT" => $description, "DETAIL_TEXT_TYPE" => "html", "PUBLISH_STATUS" => $publish == 1 ? "P" : "D", "CATEGORY_ID" => implode(",", $CATEGORYtmp));
                    $postId = CBlogPost::Update($arPost["ID"], $arFields);
                    CBlogPostCategory::DeleteByPostID($arPost["ID"]);
                    foreach ($CATEGORYtmp as $v) {
                        CBlogPostCategory::Add(array("BLOG_ID" => $arPost["BLOG_ID"], "POST_ID" => $arPost["ID"], "CATEGORY_ID" => $v));
                    }
                    if (IntVal($postId) > 0) {
                        foreach ($arSites as $site_id_tmp) {
                            BXClearCache(True, "/" . $site_id_tmp . "/blog/" . $arBlog["URL"] . "/first_page/");
                            BXClearCache(True, "/" . $site_id_tmp . "/blog/" . $arBlog["URL"] . "/calendar/");
                            BXClearCache(True, "/" . $site_id_tmp . "/blog/last_messages/");
                            BXClearCache(True, "/" . $site_id_tmp . "/blog/commented_posts/");
                            BXClearCache(True, "/" . $site_id_tmp . "/blog/popular_posts/");
                            BXClearCache(True, "/" . $site_id_tmp . "/blog/last_comments/");
                            BXClearCache(True, "/" . $site_id_tmp . "/blog/groups/" . $arBlog["GROUP_ID"] . "/");
                            BXClearCache(True, "/" . $site_id_tmp . "/blog/" . $arBlog["URL"] . "/trackback/" . $arPost["ID"] . "/");
                            BXClearCache(True, "/" . $site_id_tmp . "/blog/" . $arBlog["URL"] . "/comment/" . $arPost["ID"] . "/");
                            BXClearCache(True, "/" . $site_id_tmp . "/blog/" . $arBlog["URL"] . "/rss_out/");
                            BXClearCache(True, "/" . $site_id_tmp . "/blog/" . $arBlog["URL"] . "/rss_all/");
                            BXClearCache(True, "/" . $site_id_tmp . "/blog/rss_sonet/");
                            BXClearCache(True, "/" . $site_id_tmp . "/blog/rss_all/");
                            BXClearCache(True, "/" . $site_id_tmp . "/blog/" . $arBlog["URL"] . "/favorite/");
                            BXClearCache(True, "/" . $site_id_tmp . "/blog/" . $arBlog["URL"] . "/post/" . $arPost["ID"] . "/");
                        }
                        return '<params>
									<param>
										<value>
											<i4>' . $postId . '</i4>
										</value>
									</param>
								</params>';
                    } else {
                        return '<fault>
							<value>
								<struct>
									<member>
										<name>faultCode</name>
										<value><int>3</int></value>
										</member>
									<member>
										<name>faultString</name>
										<value><string>Error on saving post</string></value>
										</member>
									</struct>
								</value>
							</fault>';
                    }
                }
            }
        } else {
            return '<fault>
				<value>
					<struct>
						<member>
							<name>faultCode</name>
							<value><int>3</int></value>
							</member>
						<member>
							<name>faultString</name>
							<value><string>' . $arAuthResult["MESSAGE"] . '</string></value>
							</member>
						</struct>
					</value>
				</fault>';
        }
    }
Exemplo n.º 30
0
 function convertText($text)
 {
     $text = preg_replace(array("#([?&;])PHPSESSID=([0-9a-zA-Z]{32})#is", "/\\x{00A0}/" . BX_UTF_PCRE_MODIFIER), array("\\1PHPSESSID1=", " "), $text);
     $this->type = $this->type == "rss" ? "rss" : "html";
     $this->serverName = "";
     if ($this->type == "rss") {
         $dbSite = CSite::GetByID(SITE_ID);
         $arSite = $dbSite->Fetch();
         $serverName = $arSite["SERVER_NAME"];
         if (strlen($serverName) <= 0) {
             if (defined("SITE_SERVER_NAME") && strlen(SITE_SERVER_NAME) > 0) {
                 $serverName = SITE_SERVER_NAME;
             } else {
                 $serverName = COption::GetOptionString("main", "server_name", "www.bitrixsoft.com");
             }
         }
         $this->serverName = "http://" . $serverName;
     }
     $this->preg = array("counter" => 0, "pattern" => array(), "replace" => array(), "cache" => array());
     foreach (GetModuleEvents("main", "TextParserBefore", true) as $arEvent) {
         ExecuteModuleEventEx($arEvent, array(&$text, &$this));
     }
     if ($this->allow["HTML"] != "Y" && $this->allow['NL2BR'] == 'Y') {
         $text = preg_replace("#<br(.*?)>#is", "\n", $text);
     }
     if ($this->allow["CODE"] == "Y") {
         $text = preg_replace_callback(array("#(\\[code(?:\\s+[^\\]]*\\]|\\]))(.+?)(\\[/code(?:\\s+[^\\]]*\\]|\\]))#is" . BX_UTF_PCRE_MODIFIER, "#(<code(?:\\s+[^>]*>|>))(.+?)(</code(?:\\s+[^>]*>|>))#is" . BX_UTF_PCRE_MODIFIER), array($this, "convertCode"), $text);
     }
     if ($this->allow["HTML"] != "Y") {
         if ($this->allow["ANCHOR"] == "Y") {
             $text = preg_replace(array("#<a[^>]+href\\s*=\\s*('|\")(.+?)(?:\\1)[^>]*>(.*?)</a[^>]*>#is" . BX_UTF_PCRE_MODIFIER, "#<a[^>]+href(\\s*=\\s*)([^'\">]+)>(.*?)</a[^>]*>#is" . BX_UTF_PCRE_MODIFIER), "[url=\\2]\\3[/url]", $text);
         }
         if ($this->allow["BIU"] == "Y") {
             $replaced = 0;
             do {
                 $text = preg_replace("/<([busi])[^>a-z]*>(.+?)<\\/(\\1)[^>a-z]*>/is" . BX_UTF_PCRE_MODIFIER, "[\\1]\\2[/\\1]", $text, -1, $replaced);
             } while ($replaced > 0);
         }
         if ($this->allow["IMG"] == "Y") {
             $text = preg_replace("#<img[^>]+src\\s*=[\\s'\"]*(((http|https|ftp)://[.-_:a-z0-9@]+)*(\\/[-_/=:.a-z0-9@{}&?%]+)+)[\\s'\"]*[^>]*>#is" . BX_UTF_PCRE_MODIFIER, "[img]\\1[/img]", $text);
         }
         if ($this->allow["FONT"] == "Y") {
             $text = preg_replace(array("/\\<font[^>]+size\\s*=[\\s'\"]*([0-9]+)[\\s'\"]*[^>]*\\>(.+?)\\<\\/font[^>]*\\>/is" . BX_UTF_PCRE_MODIFIER, "/\\<font[^>]+color\\s*=[\\s'\"]*(\\#[a-f0-9]{6})[^>]*\\>(.+?)\\<\\/font[^>]*>/is" . BX_UTF_PCRE_MODIFIER, "/\\<font[^>]+face\\s*=[\\s'\"]*([a-z\\s\\-]+)[\\s'\"]*[^>]*>(.+?)\\<\\/font[^>]*>/is" . BX_UTF_PCRE_MODIFIER), array("[size=\\1]\\2[/size]", "[color=\\1]\\2[/color]", "[font=\\1]\\2[/font]"), $text);
         }
         if ($this->allow["LIST"] == "Y") {
             $text = preg_replace(array("/\\<ul((\\s[^>]*)|(\\s*))\\>(.+?)<\\/ul([^>]*)\\>/is" . BX_UTF_PCRE_MODIFIER, "/\\<ol((\\s[^>]*)|(\\s*))\\>(.+?)<\\/ol([^>]*)\\>/is" . BX_UTF_PCRE_MODIFIER, "/\\<li((\\s[^>]*)|(\\s*))\\>/is" . BX_UTF_PCRE_MODIFIER), array("[list]\\4[/list]", "[list=1]\\4[/list]", "[*]"), $text);
         }
         if ($this->allow["TABLE"] == "Y") {
             $text = preg_replace(array("/\\<table((\\s[^>]*)|(\\s*))\\>/is" . BX_UTF_PCRE_MODIFIER, "/\\<\\/table([^>]*)\\>/is" . BX_UTF_PCRE_MODIFIER, "/\\<tr((\\s[^>]*)|(\\s*))\\>/is" . BX_UTF_PCRE_MODIFIER, "/\\<\\/tr([^>]*)\\>/is" . BX_UTF_PCRE_MODIFIER, "/\\<td((\\s[^>]*)|(\\s*))\\>/is" . BX_UTF_PCRE_MODIFIER, "/\\<\\/td([^>]*)\\>/is" . BX_UTF_PCRE_MODIFIER, "/\\<th((\\s[^>]*)|(\\s*))\\>/is" . BX_UTF_PCRE_MODIFIER, "/\\<\\/th([^>]*)\\>/is" . BX_UTF_PCRE_MODIFIER), array("[table]", "[/table]", "[tr]", "[/tr]", "[td]", "[/td]", "[th]", "[/th]"), $text);
         }
         if ($this->allow["QUOTE"] == "Y") {
             $text = preg_replace("#<(/?)quote(.*?)>#is", "[\\1quote]", $text);
         }
         if (strlen($text) > 0) {
             if ($this->preg["counter"] > 0) {
                 $res = strlen((string) $this->preg["counter"]);
                 $p = array('\\d');
                 while ($res-- > 1) {
                     $p[] = '\\d{' . ($res + 1) . '}';
                 }
                 $text = preg_replace(array("/\\<(?!\\#(" . implode(")|(", $p) . ")\\>)/", "/(?<!\\<\\#(" . implode(")|(", $p) . "))\\>/", "/\"/"), array("&lt;", "&gt;", "&quot;"), $text);
             } else {
                 $text = str_replace(array("<", ">", "/\"/"), array("&lt;", "&gt;", "&quot;"), $text);
             }
         }
     }
     $patt = array();
     if ($this->allow["VIDEO"] == "Y") {
         $patt[] = "/\\[video([^\\]]*)\\](.+?)\\[\\/video[\\s]*\\]/is" . BX_UTF_PCRE_MODIFIER;
     }
     if ($this->allow["IMG"] == "Y") {
         $patt[] = "/\\[img([^\\]]*)\\](.+?)\\[\\/img\\]/is" . BX_UTF_PCRE_MODIFIER;
     }
     if ($this->allow["ANCHOR"] == "Y") {
         $patt[] = "/\\[url\\](.*?)\\[\\/url\\]/i" . BX_UTF_PCRE_MODIFIER;
         $patt[] = "/\\[url\\s*=\\s*(\n\t\t\t(?:\n\t\t\t\t[^\\[\\]]++\n\t\t\t\t|\\[ (?: (?>[^\\[\\]]+) | (?:\\1) )* \\]\n\t\t\t)+\n\t\t\t)\\s*\\](.*?)\\[\\/url\\]/ixs" . BX_UTF_PCRE_MODIFIER;
         $text = preg_replace_callback($patt, array($this, "preconvertAnchor"), $text);
         $word_separator = str_replace("?", "", $this->wordSeparator);
         $patt = array("/(?<=^|[" . $word_separator . "]|\\s)(?<!\\[nomodify\\]|<nomodify>)((" . $this->getAnchorSchemes() . "):\\/\\/[._:a-z0-9@-].*?)(?=[\\s'\"{}\\[\\]]|&quot;|\$)/is" . BX_UTF_PCRE_MODIFIER);
         if (self::strpos($text, "“") !== false) {
             $patt[] = "/(?<=[" . self::chr("“") . "])(?<!\\[nomodify\\]|<nomodify>)((" . $this->getAnchorSchemes() . "):\\/\\/[._:a-z0-9@-].*?)(?=[" . self::chr("”") . "])/is" . BX_UTF_PCRE_MODIFIER;
         }
         if (self::strpos($text, "‘") !== false) {
             $patt[] = "/(?<=[" . self::chr("‘") . "])(?<!\\[nomodify\\]|<nomodify>)((" . $this->getAnchorSchemes() . "):\\/\\/[._:a-z0-9@-].*?)(?=[" . self::chr("’") . "])/is" . BX_UTF_PCRE_MODIFIER;
         }
         if (self::strpos($text, "«") !== false) {
             $patt[] = "/(?<=[" . self::chr("«") . "])(?<!\\[nomodify\\]|<nomodify>)((" . $this->getAnchorSchemes() . "):\\/\\/[._:a-z0-9@-].*?)(?=[" . self::chr("»") . "])/is" . BX_UTF_PCRE_MODIFIER;
         }
         $text = preg_replace_callback($patt, array($this, "preconvertUrl"), $text);
     } else {
         if (!empty($patt)) {
             $text = preg_replace_callback($patt, array($this, "preconvertAnchor"), $text);
         }
     }
     $text = preg_replace("/<\\/?nomodify>/i" . BX_UTF_PCRE_MODIFIER, "", $text);
     foreach (GetModuleEvents("main", "TextParserBeforeTags", true) as $arEvent) {
         ExecuteModuleEventEx($arEvent, array(&$text, &$this));
     }
     if ($this->allow["SMILES"] == "Y") {
         if (strpos($text, "<nosmile>") !== false) {
             $text = preg_replace_callback("/<nosmile>(.*?)<\\/nosmile>/is" . BX_UTF_PCRE_MODIFIER, array($this, "defendTags"), $text);
         }
         if ($this->smiles === null) {
             $this->initSmiles();
         }
         if (!empty($this->smiles)) {
             if ($this->smilePatterns === null) {
                 $this->initSmilePatterns();
             }
             if (!empty($this->smilePatterns)) {
                 $text = preg_replace_callback($this->smilePatterns, array($this, "convertEmoticon"), ' ' . $text . ' ');
             }
         }
     }
     $text = $this->post_convert_anchor_tag($text);
     $res = array_merge(array("VIDEO" => "N", "IMG" => "N", "ANCHOR" => "N", "BIU" => "N", "LIST" => "N", "FONT" => "N", "TABLE" => "N", "ALIGN" => "N", "QUOTE" => "N"), $this->allow);
     foreach ($res as $tag => $val) {
         if ($val != "Y") {
             continue;
         }
         if (strpos($text, "<nomodify>") !== false) {
             $text = preg_replace_callback("/<nomodify>(.*?)<\\/nomodify>/is" . BX_UTF_PCRE_MODIFIER, array($this, "defendTags"), $text);
         }
         switch ($tag) {
             case "VIDEO":
                 $text = preg_replace_callback("/\\[video([^\\]]*)\\](.+?)\\[\\/video[\\s]*\\]/is" . BX_UTF_PCRE_MODIFIER, array($this, "convertVideo"), $text);
                 break;
             case "IMG":
                 $text = preg_replace_callback("/\\[img([^\\]]*)\\](.+?)\\[\\/img\\]/is" . BX_UTF_PCRE_MODIFIER, array($this, "convertImage"), $text);
                 break;
             case "ANCHOR":
                 $arUrlPatterns = array("/\\[url\\](.*?)\\[\\/url\\]/i" . BX_UTF_PCRE_MODIFIER, "/\\[url\\s*=\\s*(\n\t\t\t\t\t\t\t(?:\n\t\t\t\t\t\t\t\t[^\\[\\]]++\n\t\t\t\t\t\t\t\t|\\[ (?: (?>[^\\[\\]]+) | (?:\\1) )* \\]\n\t\t\t\t\t\t\t)+\n\t\t\t\t\t\t\t)\\s*\\](.*?)\\[\\/url\\]/ixs" . BX_UTF_PCRE_MODIFIER);
                 if ($this->allow["CUT_ANCHOR"] != "Y") {
                     $text = preg_replace_callback($arUrlPatterns, array($this, "convertAnchor"), $text);
                 } else {
                     $text = preg_replace($arUrlPatterns, "", $text);
                 }
                 break;
             case "BIU":
                 $replaced = 0;
                 do {
                     $text = preg_replace("/\\[([busi])\\](.*?)\\[\\/(\\1)\\]/is" . BX_UTF_PCRE_MODIFIER, "<\\1>\\2</\\1>", $text, -1, $replaced);
                 } while ($replaced > 0);
                 break;
             case "LIST":
                 while (preg_match("/\\[list\\s*=\\s*(1|a)\\s*\\](.+?)\\[\\/list\\]/is" . BX_UTF_PCRE_MODIFIER, $text)) {
                     $text = preg_replace(array("/\\[list\\s*=\\s*1\\s*\\](\\s*)(.+?)\\[\\/list\\](([ \\r\\t]*)\\n?)/is" . BX_UTF_PCRE_MODIFIER, "/\\[list\\s*=\\s*a\\s*\\](\\s*)(.+?)\\[\\/list\\](([ \\r\\t]*)\\n?)/is" . BX_UTF_PCRE_MODIFIER, "/\\[\\*\\]/" . BX_UTF_PCRE_MODIFIER), array("<ol>\\2</ol>", "<ol type=\"a\">\\2</ol>", "<li>"), $text);
                 }
                 while (preg_match("/\\[list\\](.+?)\\[\\/list\\](([\\040\\r\\t]*)\\n?)/is" . BX_UTF_PCRE_MODIFIER, $text)) {
                     $text = preg_replace(array("/\\[list\\](\\s*)(.+?)\\[\\/list\\](([\\040\\r\\t]*)\\n?)/is" . BX_UTF_PCRE_MODIFIER, "/\\[\\*\\]/" . BX_UTF_PCRE_MODIFIER), array("<ul>\\2</ul>", "<li>"), $text);
                 }
                 break;
             case "FONT":
                 while (preg_match("/\\[size\\s*=\\s*([^\\]]+)\\](.*?)\\[\\/size\\]/is" . BX_UTF_PCRE_MODIFIER, $text)) {
                     $text = preg_replace_callback("/\\[size\\s*=\\s*([^\\]]+)\\](.*?)\\[\\/size\\]/is" . BX_UTF_PCRE_MODIFIER, array($this, "convertFontSize"), $text);
                 }
                 while (preg_match("/\\[font\\s*=\\s*([^\\]]+)\\](.*?)\\[\\/font\\]/is" . BX_UTF_PCRE_MODIFIER, $text)) {
                     $text = preg_replace_callback("/\\[font\\s*=\\s*([^\\]]+)\\](.*?)\\[\\/font\\]/is" . BX_UTF_PCRE_MODIFIER, array($this, "convertFont"), $text);
                 }
                 while (preg_match("/\\[color\\s*=\\s*([^\\]]+)\\](.*?)\\[\\/color\\]/is" . BX_UTF_PCRE_MODIFIER, $text)) {
                     $text = preg_replace_callback("/\\[color\\s*=\\s*([^\\]]+)\\](.*?)\\[\\/color\\]/is" . BX_UTF_PCRE_MODIFIER, array($this, "convertFontColor"), $text);
                 }
                 break;
             case "TABLE":
                 while (preg_match("/\\[table\\](.+?)\\[\\/table\\]/is" . BX_UTF_PCRE_MODIFIER, $text)) {
                     $text = preg_replace_callback("/\\[table\\](.*?)\\[\\/table\\](?:(?:[\\040\\r\\t]*)\\n?)/is" . BX_UTF_PCRE_MODIFIER, array($this, "convertTable"), $text);
                 }
                 break;
             case "ALIGN":
                 $replaced = 0;
                 do {
                     $text = preg_replace(array("/\\[left\\](.*?)\\[\\/left\\](([\\040\\r\\t]*)\\n?)/is" . BX_UTF_PCRE_MODIFIER, "/\\[right\\](.*?)\\[\\/right\\](([\\040\\r\\t]*)\\n?)/is" . BX_UTF_PCRE_MODIFIER, "/\\[center\\](.*?)\\[\\/center\\](([\\040\\r\\t]*)\\n?)/is" . BX_UTF_PCRE_MODIFIER, "/\\[justify\\](.*?)\\[\\/justify\\](([\\040\\r\\t]*)\\n?)/is" . BX_UTF_PCRE_MODIFIER), array("<div align=\"left\">\\1</div>", "<div align=\"right\">\\1</div>", "<div align=\"center\">\\1</div>", "<div align=\"justify\">\\1</div>"), $text, -1, $replaced);
                 } while ($replaced > 0);
                 break;
             case "QUOTE":
                 while (preg_match("/\\[quote[^\\]]*\\](.*?)\\[\\/quote[^\\]]*\\]/is" . BX_UTF_PCRE_MODIFIER, $text)) {
                     $text = preg_replace_callback("/\\[quote[^\\]]*\\](.*?)\\[\\/quote[^\\]]*\\](([\\040\\r\\t]*)\\n?)/is" . BX_UTF_PCRE_MODIFIER, array($this, "convertQuote"), $text);
                 }
                 break;
         }
     }
     if (strpos($text, "<nomodify>") !== false) {
         $text = preg_replace_callback("/<nomodify>(.*?)<\\/nomodify>/is" . BX_UTF_PCRE_MODIFIER, array($this, "defendTags"), $text);
     }
     if (!empty($this->allow["USERFIELDS"]) && is_array($this->allow["USERFIELDS"])) {
         foreach ($this->allow["USERFIELDS"] as $userField) {
             if (is_array($userField["USER_TYPE"]) && array_key_exists("TAG", $userField["USER_TYPE"])) {
                 $userField["TAG"] = $userField["USER_TYPE"]["TAG"];
             }
             if (empty($userField["TAG"])) {
                 switch ($userField["USER_TYPE_ID"]) {
                     case "webdav_element":
                         $userField["TAG"] = "DOCUMENT ID";
                         break;
                     case "vote":
                         $userField["TAG"] = "VOTE ID";
                         break;
                 }
             }
             if (!empty($userField["TAG"]) && array_key_exists("VALUE", $userField) && !empty($userField["VALUE"]) && method_exists($userField["USER_TYPE"]["CLASS_NAME"], "GetPublicViewHTML")) {
                 $userField["VALUE"] = is_array($userField["VALUE"]) ? $userField["VALUE"] : array($userField["VALUE"]);
                 $this->userField = $userField;
                 $text = preg_replace_callback("/\\[(" . (is_array($userField["TAG"]) ? implode("|", $userField["TAG"]) : $userField["TAG"]) . ")\\s*=\\s*([a-z0-9]+)([^\\]]*)\\]/is" . BX_UTF_PCRE_MODIFIER, array($this, "convert_userfields"), $text);
             }
         }
     }
     foreach (GetModuleEvents("main", "TextParserAfterTags", true) as $arEvent) {
         ExecuteModuleEventEx($arEvent, array(&$text, &$this));
     }
     if ($this->allow["HTML"] != "Y" || $this->allow['NL2BR'] == 'Y') {
         $text = str_replace("\n", "<br />", $text);
         $text = preg_replace(array("/\\<br \\/\\>(\\<\\/table[^>]*\\>)/is" . BX_UTF_PCRE_MODIFIER, "/\\<br \\/\\>(\\<thead[^>]*\\>)/is" . BX_UTF_PCRE_MODIFIER, "/\\<br \\/\\>(\\<\\/thead[^>]*\\>)/is" . BX_UTF_PCRE_MODIFIER, "/\\<br \\/\\>(\\<tfoot[^>]*\\>)/is" . BX_UTF_PCRE_MODIFIER, "/\\<br \\/\\>(\\<\\/tfoot[^>]*\\>)/is" . BX_UTF_PCRE_MODIFIER, "/\\<br \\/\\>(\\<tbody[^>]*\\>)/is" . BX_UTF_PCRE_MODIFIER, "/\\<br \\/\\>(\\<\\/tbody[^>]*\\>)/is" . BX_UTF_PCRE_MODIFIER, "/\\<br \\/\\>(\\<tr[^>]*\\>)/is" . BX_UTF_PCRE_MODIFIER, "/\\<br \\/\\>(\\<\\/tr[^>]*\\>)/is" . BX_UTF_PCRE_MODIFIER, "/\\<br \\/\\>(\\<td[^>]*\\>)/is" . BX_UTF_PCRE_MODIFIER, "/\\<br \\/\\>(\\<\\/td[^>]*\\>)/is" . BX_UTF_PCRE_MODIFIER), "\\1", $text);
     }
     $text = str_replace(array("(c)", "(C)", "(tm)", "(TM)", "(Tm)", "(tM)", "(r)", "(R)"), array("&#169;", "&#169;", "&#153;", "&#153;", "&#153;", "&#153;", "&#174;", "&#174;"), $text);
     if ($this->allow["HTML"] != "Y" && $this->maxStringLen > 0) {
         $text = preg_replace("/(\\&\\#\\d{1,3}\\;)/is" . BX_UTF_PCRE_MODIFIER, "<9\\1>", $text);
         $text = preg_replace_callback("/(?<=^|\\>)([^\\<\\>\\[]+?)(?=\\<|\\[|\$)/is" . BX_UTF_PCRE_MODIFIER, array($this, "partWords"), $text);
         $text = preg_replace("/(\\<9((\\&\\#\\d{1,3}\\;))\\>)/is" . BX_UTF_PCRE_MODIFIER, "\\2", $text);
     }
     foreach (GetModuleEvents("main", "TextParserBeforePattern", true) as $arEvent) {
         ExecuteModuleEventEx($arEvent, array(&$text, &$this));
     }
     if ($this->preg["counter"] > 0) {
         $text = str_replace($this->preg["pattern"], $this->preg["replace"], $text);
     }
     foreach (GetModuleEvents("main", "TextParserAfter", true) as $arEvent) {
         ExecuteModuleEventEx($arEvent, array(&$text, &$this));
     }
     return trim($text);
 }