Exemple #1
0
 function IncludeComponent($componentName, $componentTemplate, $arParams = array(), $parentComponent = null, $arFunctionParams = array())
 {
     /** @global CMain $APPLICATION */
     global $APPLICATION, $USER;
     if (is_array($this->arComponentMatch)) {
         $skipComponent = true;
         foreach ($this->arComponentMatch as $cValue) {
             if (strpos($componentName, $cValue) !== false) {
                 $skipComponent = false;
                 break;
             }
         }
         if ($skipComponent) {
             return false;
         }
     }
     $componentRelativePath = CComponentEngine::MakeComponentPath($componentName);
     if (StrLen($componentRelativePath) <= 0) {
         return False;
     }
     if ($_SESSION["SESS_SHOW_INCLUDE_TIME_EXEC"] == "Y" && ($USER->CanDoOperation('edit_php') || $_SESSION["SHOW_SQL_STAT"] == "Y")) {
         $debug = new CDebugInfo();
         $debug->Start();
     } elseif ($APPLICATION->ShowIncludeStat) {
         $debug = new CDebugInfo();
         $debug->Start();
     } else {
         $debug = null;
     }
     if (is_object($parentComponent)) {
         if (!$parentComponent instanceof cbitrixcomponent) {
             $parentComponent = null;
         }
     }
     $bDrawIcons = (!isset($arFunctionParams["HIDE_ICONS"]) || $arFunctionParams["HIDE_ICONS"] != "Y") && $APPLICATION->GetShowIncludeAreas();
     if ($bDrawIcons) {
         echo $this->IncludeStringBefore();
     }
     $result = null;
     $bComponentEnabled = !isset($arFunctionParams["ACTIVE_COMPONENT"]) || $arFunctionParams["ACTIVE_COMPONENT"] != "N";
     $component = new CBitrixComponent();
     if ($component->InitComponent($componentName)) {
         $obAjax = null;
         if ($bComponentEnabled) {
             if ($arParams['AJAX_MODE'] == 'Y') {
                 $obAjax = new CComponentAjax($componentName, $componentTemplate, $arParams, $parentComponent);
             }
             $result = $component->IncludeComponent($componentTemplate, $arParams, $parentComponent);
         }
         if ($bDrawIcons) {
             $panel = new CComponentPanel($component, $componentName, $componentTemplate, $parentComponent, $bComponentEnabled);
             $arIcons = $panel->GetIcons();
             echo $s = $this->IncludeStringAfter($arIcons["icons"], $arIcons["parameters"]);
         }
         if ($bComponentEnabled && $obAjax) {
             $obAjax->Process();
         }
     }
     if ($_SESSION["SESS_SHOW_INCLUDE_TIME_EXEC"] == "Y" && ($USER->CanDoOperation('edit_php') || $_SESSION["SHOW_SQL_STAT"] == "Y")) {
         echo $debug->Output($componentName, "/bitrix/components" . $componentRelativePath . "/component.php", $arParams["CACHE_TYPE"] . $arParams["MENU_CACHE_TYPE"]);
     } elseif (is_object($debug)) {
         $debug->Stop($componentName, "/bitrix/components" . $componentRelativePath . "/component.php", $arParams["CACHE_TYPE"] . $arParams["MENU_CACHE_TYPE"]);
     }
     return $result;
 }
Exemple #2
0
 public static function CopyTemplate($componentName, $templateName, $siteTemplate, $newSiteTemplate, $newName = false, $bRewrite = false)
 {
     global $APPLICATION;
     $componentName = trim($componentName);
     if (strlen($componentName) <= 0) {
         $APPLICATION->ThrowException(GetMessage("comp_util_err1"), "EMPTY_COMPONENT_NAME");
         return false;
     }
     $path2Comp = CComponentEngine::MakeComponentPath($componentName);
     if (strlen($path2Comp) <= 0) {
         $APPLICATION->ThrowException(str_replace("#NAME#", $componentName, GetMessage("comp_util_err2")), "ERROR_NOT_COMPONENT");
         return false;
     }
     $componentPath = getLocalPath("components" . $path2Comp);
     if (!CComponentUtil::isComponent($componentPath)) {
         $APPLICATION->ThrowException(str_replace("#NAME#", $componentName, GetMessage("comp_util_err2")), "ERROR_NOT_COMPONENT");
         return false;
     }
     if (strlen($templateName) <= 0) {
         $templateName = ".default";
     }
     $templateNameTmp = preg_replace("#[^A-Za-z0-9_.-]#i", "", $templateName);
     if ($templateNameTmp != $templateName) {
         $APPLICATION->ThrowException(str_replace("#NAME#", $templateName, GetMessage("comp_util_err7")), "ERROR_BAD_TEMPLATE_NAME");
         return false;
     }
     if (strlen($siteTemplate) <= 0) {
         $siteTemplate = false;
     }
     if ($siteTemplate != false) {
         $siteTemplateDir = getLocalPath("templates/" . $siteTemplate, BX_PERSONAL_ROOT);
         if ($siteTemplateDir === false || !is_dir($_SERVER["DOCUMENT_ROOT"] . $siteTemplateDir)) {
             $APPLICATION->ThrowException(str_replace("#NAME#", $siteTemplate, GetMessage("comp_util_err8")), "ERROR_NO_SITE_TEMPL");
             return false;
         }
     }
     if ($siteTemplate != false) {
         $path = getLocalPath("templates/" . $siteTemplate . "/components" . $path2Comp . "/" . $templateName, BX_PERSONAL_ROOT);
     } else {
         $path = getLocalPath("components" . $path2Comp . "/templates/" . $templateName);
     }
     if ($path === false || !file_exists($_SERVER["DOCUMENT_ROOT"] . $path)) {
         $APPLICATION->ThrowException(str_replace("#C_NAME#", $componentName, str_replace("#T_NAME#", $templateName, GetMessage("comp_util_err9"))), "ERROR_NO_TEMPL");
         return false;
     }
     if (strlen($newSiteTemplate) <= 0) {
         $APPLICATION->ThrowException(GetMessage("comp_util_err10"), "ERROR_EMPTY_SITE_TEMPL");
         return false;
     }
     $newSiteTemplateDir = getLocalPath("templates/" . $newSiteTemplate, BX_PERSONAL_ROOT);
     if ($newSiteTemplateDir === false || !is_dir($_SERVER["DOCUMENT_ROOT"] . $newSiteTemplateDir)) {
         $APPLICATION->ThrowException(str_replace("#NAME#", $newSiteTemplate, GetMessage("comp_util_err8")), "ERROR_NO_SITE_TEMPL");
         return false;
     }
     if ($siteTemplate !== false && $siteTemplate == $newSiteTemplate && ($newName === false || $newName !== false && $templateName == $newName)) {
         $APPLICATION->ThrowException(GetMessage("comp_util_err11"), "ERROR_DUPL1");
         return false;
     }
     if ($newName !== false) {
         $templateNameNew = $newName;
     } else {
         $templateNameNew = $templateName;
     }
     $templateNameNewTmp = preg_replace("#[^A-Za-z0-9_.-]#i", "", $templateNameNew);
     if ($templateNameNewTmp != $templateNameNew) {
         $APPLICATION->ThrowException(str_replace("#NAME#", $templateNameNew, GetMessage("comp_util_err7")), "ERROR_BAD_TEMPLATE_NAME");
         return false;
     }
     $pathNew = $newSiteTemplateDir . "/components" . $path2Comp . "/" . $templateNameNew;
     if (file_exists($_SERVER["DOCUMENT_ROOT"] . $pathNew)) {
         if (!$bRewrite) {
             $APPLICATION->ThrowException(str_replace("#NAME#", $templateNameNew, GetMessage("comp_util_err12")), "ERROR_EXISTS");
             return false;
         } else {
             DeleteDirFilesEx($pathNew);
         }
     }
     CopyDirFiles($_SERVER["DOCUMENT_ROOT"] . $path, $_SERVER["DOCUMENT_ROOT"] . $pathNew, true, true, false);
     return true;
 }
global $CACHE_MANAGER;

if(!$USER->CanDoOperation('cache_control') || !check_bitrix_sessid())
	die(GetMessage("ACCESS_DENIED"));

if($_GET["site_id"] == '')
	die("Empty site_id.");

$sites = CSite::GetByID($_GET["site_id"]);
if(!($site = $sites->Fetch()))
	die("Incorrect site_id.");

$aComponents = explode(",", $_GET["component_name"]);
foreach($aComponents as $component_name)
{
	$componentRelativePath = CComponentEngine::MakeComponentPath($component_name);
	if (strlen($componentRelativePath) > 0)
	{
		$arComponentDescription = CComponentUtil::GetComponentDescr($component_name);
		if (isset($arComponentDescription) && is_array($arComponentDescription))
		{
			if (array_key_exists("CACHE_PATH", $arComponentDescription))
			{
				if($arComponentDescription["CACHE_PATH"] == "Y")
					$arComponentDescription["CACHE_PATH"] = "/".$site["ID"].$componentRelativePath;
				if(strlen($arComponentDescription["CACHE_PATH"]) > 0)
				{
					$obCache = new CPHPCache;
					$obCache->CleanDir($arComponentDescription["CACHE_PATH"], "cache");
					BXClearCache(true, $arComponentDescription["CACHE_PATH"]);
				}
Exemple #4
0
define("NO_AGENT_STATISTIC", "Y");
define("NO_AGENT_CHECK", true);
define("DisableEventsCheck", true);
/************** CACHE **********************************************/
$arResult["nPageSize"] = 10;
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php";
$arVoteList = array("ID" => $_REQUEST["ID"], "answer_id" => $_REQUEST["answer_id"], "request_id" => $_REQUEST["request_id"], "items" => array(), "StatusPage" => "done");
$_REQUEST["ID"] = is_array($_REQUEST["ID"]) ? $_REQUEST["ID"] : !empty($_REQUEST["ID"]) ? explode(",", $_REQUEST["ID"]) : array();
$_REQUEST["URL_TEMPLATE"] = !empty($_REQUEST["URL_TEMPLATE"]) ? $_REQUEST["URL_TEMPLATE"] : '/company/personal/user/#USER_ID#/';
$_REQUEST["NAME_TEMPLATE"] = !empty($_REQUEST["NAME_TEMPLATE"]) ? $_REQUEST["NAME_TEMPLATE"] : CSite::GetNameFormat(false);
if ((!empty($_REQUEST["ID"]) || !empty($_REQUEST["answer_id"])) && check_bitrix_sessid()) {
    $arParams["CACHE_TIME"] = 600;
    global $CACHE_MANAGER;
    $cache = new CPHPCache();
    $cache_id = "vote_user_list_" . serialize(array($arResult["nPageSize"], $_REQUEST["ID"], $_REQUEST["answer_id"], $_REQUEST["iNumPage"], $_REQUEST["NAME_TEMPLATE"], $_REQUEST["URL_TEMPLATE"]));
    $cache_path = $CACHE_MANAGER->GetCompCachePath(CComponentEngine::MakeComponentPath("voting.current"));
    $arVoteList = $arParams["CACHE_TIME"] > 0 && $cache->InitCache($arParams["CACHE_TIME"], $cache_id, $cache_path) ? $cache->GetVars() : array();
    if (!is_array($arVoteList) || empty($arVoteList)) {
        $arEventsInfo = array();
        $arVoteList = array("ID" => $_REQUEST["ID"], "answer_id" => $_REQUEST["answer_id"], "request_id" => $_REQUEST["request_id"], "items" => array(), "StatusPage" => "done");
        if (empty($_REQUEST["ID"]) && CModule::IncludeModule("vote")) {
            $db_res = CVoteEvent::GetUserAnswerStat(array(), array("ANSWER_ID" => $_REQUEST["answer_id"], "VALID" => "Y", "bGetVoters" => "Y", "bGetMemoStat" => "N"), array("nPageSize" => $arResult["nPageSize"], "bShowAll" => false, "iNumPage" => $_REQUEST["iNumPage"] > 0 ? $_REQUEST["iNumPage"] : false));
            if ($db_res && ($res = $db_res->Fetch())) {
                $arEventsInfo = $res;
                $arVoteList["StatusPage"] = $db_res->NavPageNomer >= $db_res->NavPageCount || $arResult["nPageSize"] > $db_res->NavRecordCount ? "done" : "continue";
                if ($_REQUEST["iNumPage"] <= $db_res->NavPageCount) {
                    $_REQUEST["ID"] = array();
                    do {
                        $_REQUEST["ID"][] = $res["AUTH_USER_ID"];
                    } while ($res = $db_res->Fetch());
                } else {
Exemple #5
0
    $arParams["SITE_LIST"] = array();
} else {
    $bSiteAll = false;
}
$arParams["CACHE_TIME"] = is_set($arParams, "CACHE_TIME") ? intval($arParams["CACHE_TIME"]) : 86400;
$bCache = $arParams["CACHE_TIME"] > 0 && ($arParams["CACHE_TYPE"] == "Y" || $arParams["CACHE_TYPE"] == "A" && COption::GetOptionString("main", "component_cache_on", "Y") == "Y");
if ($bCache) {
    $arCacheParams = array();
    foreach ($arParams as $key => $value) {
        if (substr($key, 0, 1) != "~") {
            $arCacheParams[$key] = $value;
        }
    }
    $cache = new CPHPCache();
    $CACHE_ID = SITE_ID . "|" . $componentName . "|" . md5(serialize($arCacheParams)) . "|" . $USER->GetGroups();
    $CACHE_PATH = "/" . SITE_ID . CComponentEngine::MakeComponentPath($componentName);
}
if ($bCache && $cache->InitCache($arParams["CACHE_TIME"], $CACHE_ID, $CACHE_PATH)) {
    $vars = $cache->GetVars();
    $arResult = $vars["arResult"];
} else {
    if ($bCache) {
        $cache->StartDataCache();
    }
    $rsSite = CSite::GetList($by = "sort", $order = "asc", $arFilter = array("ACTIVE" => "Y"));
    $arResult["SITES"] = array();
    while ($arSite = $rsSite->GetNext()) {
        if ($bSiteAll || in_array($arSite["LID"], $arParams["SITE_LIST"])) {
            if (strlen($arSite['DOMAINS']) > 0) {
                $arSite['DOMAINS'] = explode("\n", $arSite['DOMAINS']);
                foreach ($arSite['DOMAINS'] as $key => $domain) {
                $functionParams = ",\n" . "\tarray(\n" . "\t\t" . PHPParser::ReturnPHPStr2($arComponent["DATA"]["FUNCTION_PARAMS"]) . "\n" . "\t)";
            }
            $code = ($arComponent["DATA"]["VARIABLE"] ? $arComponent["DATA"]["VARIABLE"] . " = " : "") . "\$APPLICATION->IncludeComponent(\n" . "\t\"" . $arComponent["DATA"]["COMPONENT_NAME"] . "\", \n" . "\t\"" . $sTemplateName . "\", \n" . "\tarray(\n" . "\t\t" . PHPParser::ReturnPHPStr2($aPostValues) . "\n" . "\t),\n" . "\t" . ($arComponent["DATA"]["PARENT_COMP"] != '' ? $arComponent["DATA"]["PARENT_COMP"] : "false") . $functionParams . "\n);";
            $filesrc_for_save = substr($filesrc, 0, $arComponent["START"]) . $code . substr($filesrc, $arComponent["END"]);
            $f = $io->GetFile($abs_path);
            $arUndoParams = array('module' => 'fileman', 'undoType' => 'edit_component_props', 'undoHandler' => 'CFileman::UndoEditFile', 'arContent' => array('absPath' => $abs_path, 'content' => $f->GetContents()));
            if ($APPLICATION->SaveFileContent($abs_path, $filesrc_for_save)) {
                CUndo::ShowUndoMessage(CUndo::Add($arUndoParams));
                $obJSPopup->Close();
            } else {
                $strWarning .= GetMessage("comp_prop_err_save") . "<br>";
            }
        }
    }
}
$componentPath = CComponentEngine::MakeComponentPath($componentName);
if ($strWarning !== "") {
    $obJSPopup->ShowValidationError($strWarning);
    ?>
	<script>
		(function()
		{
			if (BX && BX.WindowManager)
			{
				var oPopup = BX.WindowManager.Get();
				if (oPopup && oPopup.PARTS && oPopup.PARTS.CONTENT_DATA)
				{
					oPopup.PARTS.CONTENT_DATA.style.display = 'none';
				}
			}
		})();
 public static function includeComponent($componentName, $componentTemplate, $arParams = array(), $parentComponent = null, $arFunctionParams = array())
 {
     $componentRelativePath = \CComponentEngine::MakeComponentPath($componentName);
     if (StrLen($componentRelativePath) <= 0) {
         return False;
     }
     if (is_object($parentComponent)) {
         if (!$parentComponent instanceof \cbitrixcomponent) {
             $parentComponent = null;
         }
     }
     $result = null;
     $bComponentEnabled = !isset($arFunctionParams["ACTIVE_COMPONENT"]) || $arFunctionParams["ACTIVE_COMPONENT"] != "N";
     $component = new \CBitrixComponent();
     if ($component->InitComponent($componentName)) {
         $obAjax = null;
         if ($bComponentEnabled) {
             $component->setSiteId(static::getInstance()->getSiteId());
             $component->setLanguageId(static::getInstance()->getLanguageId());
             $component->setSiteTemplateId(static::getInstance()->getSiteTemplateId());
             $result = $component->IncludeComponent($componentTemplate, $arParams, $parentComponent);
             $arThemeCss = array();
             // TODO: use styles array from $component
             foreach ($arThemeCss as $cssPath) {
                 static::getInstance()->setStyle($cssPath);
             }
         }
     }
     return $result;
 }
                }
            }
            $code = ($arComponent["DATA"]["VARIABLE"] ? $arComponent["DATA"]["VARIABLE"] . "=" : "") . "\$APPLICATION->IncludeComponent(\"" . $arComponent["DATA"]["COMPONENT_NAME"] . "\", " . "\"" . $sTemplateName . "\", " . "array(\n\t" . PHPParser::ReturnPHPStr2($aPostValues) . "\n\t)" . ",\n\t" . (strlen($arComponent["DATA"]["PARENT_COMP"]) > 0 ? $arComponent["DATA"]["PARENT_COMP"] : "false") . (!empty($arComponent["DATA"]["FUNCTION_PARAMS"]) ? ",\n\t" . "array(\n\t" . PHPParser::ReturnPHPStr2($arComponent["DATA"]["FUNCTION_PARAMS"]) . "\n\t)" : "") . "\n);";
            $filesrc_for_save = substr($filesrc, 0, $arComponent["START"]) . $code . substr($filesrc, $arComponent["END"]);
            $f = $io->GetFile($abs_path);
            $arUndoParams = array('module' => 'fileman', 'undoType' => 'edit_component_props', 'undoHandler' => 'CFileman::UndoEditFile', 'arContent' => array('absPath' => $abs_path, 'content' => $f->GetContents()));
            if ($APPLICATION->SaveFileContent($abs_path, $filesrc_for_save)) {
                CUndo::ShowUndoMessage(CUndo::Add($arUndoParams));
                $obJSPopup->Close();
            } else {
                $strWarning .= GetMessage("comp_prop_err_save") . "<br>";
            }
        }
    }
}
$componentPath = CComponentEngine::MakeComponentPath($_GET["component_name"]);
$arComponentDescription["ICON"] = ltrim($arComponentDescription["ICON"], "/");
$localPath = getLocalPath("components" . $componentPath);
if ($localPath !== false && $arComponentDescription["ICON"] != "" && $io->FileExists($io->RelativeToAbsolutePath($localPath . "/" . $arComponentDescription["ICON"]))) {
    $sIcon = $localPath . "/" . $arComponentDescription["ICON"];
} else {
    $sIcon = "/bitrix/images/fileman/htmledit2/component.gif";
}
$obJSPopup->StartDescription($sIcon);
if ($arComponentDescription["NAME"] != "") {
    ?>
<p title="<?php 
    echo GetMessage("comp_prop_name");
    ?>
" class="title"><?php 
    echo htmlspecialcharsbx($arComponentDescription["NAME"]);
Exemple #9
0
 /**
  * Function clears entire component cache.
  *
  * <p>Note: parameters must exactly match to startResultCache call.</p>
  * @param string $componentName
  * @param string $siteId
  * @return void
  *
  */
 public static final function clearComponentCache($componentName, $siteId = "")
 {
     /** @global CCacheManager $CACHE_MANAGER */
     global $CACHE_MANAGER;
     $componentRelativePath = CComponentEngine::MakeComponentPath($componentName);
     if ($componentRelativePath != "") {
         $componentDescription = CComponentUtil::GetComponentDescr($componentName);
         if (isset($componentDescription) && is_array($componentDescription)) {
             if (isset($componentDescription["CACHE_PATH"]) && $componentDescription["CACHE_PATH"] == "Y") {
                 if ($siteId == "") {
                     $rsSite = CSite::GetList($by = "sort", $order = "asc");
                     while ($site = $rsSite->Fetch()) {
                         $componentCachePath = "/" . $site["ID"] . $componentRelativePath;
                         $obCache = new CPHPCache();
                         $obCache->CleanDir($componentCachePath, "cache");
                         BXClearCache(true, $componentCachePath);
                     }
                 } else {
                     $componentCachePath = "/" . $siteId . $componentRelativePath;
                     $obCache = new CPHPCache();
                     $obCache->CleanDir($componentCachePath, "cache");
                     BXClearCache(true, $componentCachePath);
                 }
             }
         }
         if (defined("BX_COMP_MANAGED_CACHE")) {
             $CACHE_MANAGER->ClearByTag($componentName);
         }
     }
 }
Exemple #10
0
     $DB->Query("UPDATE b_blog_image SET POST_ID=" . $newID . " WHERE BLOG_ID=" . $arBlog["ID"] . " AND POST_ID=0", true);
     $bHasImg = false;
     $bHasTag = false;
     $bHasProps = false;
     $bHasOnlyAll = false;
     if (!empty($CATEGORYtmp)) {
         $bHasTag = true;
     }
     $dbImg = CBlogImage::GetList(array(), array("BLOG_ID" => $arBlog["ID"], "POST_ID" => $newID, "IS_COMMENT" => "N"), false, false, array("ID"));
     if ($dbImg->Fetch()) {
         $bHasImg = true;
     }
     $arPostFieldsOLD = $arPostFields;
     $arPostFields = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFields("BLOG_POST", $newID, LANGUAGE_ID);
     if ($arPostFields["UF_BLOG_POST_IMPRTNT"]["VALUE"] != $arPostFieldsOLD["UF_BLOG_POST_IMPRTNT"]["VALUE"] || $arParams["ID"] > 0 && ($arResult["Post"]["~DETAIL_TEXT"] != $arFields["DETAIL_TEXT"] || $arResult["Post"]["~TITLE"] != $arFields["TITLE"])) {
         BXClearCache(true, CComponentEngine::MakeComponentPath("bitrix:socialnetwork.blog.blog"));
     }
     foreach ($arPostFields as $FIELD_NAME => $arPostField) {
         if (!empty($arPostField["VALUE"]) > 0) {
             $bHasProps = true;
             break;
         }
     }
     if (!empty($arFields["SOCNET_RIGHTS"]) && count($arFields["SOCNET_RIGHTS"]) == 1 && in_array("UA", $arFields["SOCNET_RIGHTS"])) {
         $bHasOnlyAll = true;
     }
     $arFieldsHave = array("HAS_IMAGES" => $bHasImg ? "Y" : "N", "HAS_TAGS" => $bHasTag ? "Y" : "N", "HAS_PROPS" => $bHasProps ? "Y" : "N", "HAS_SOCNET_ALL" => $bHasOnlyAll ? "Y" : "N");
     CBlogPost::Update($newID, $arFieldsHave, false);
 }
 if ($bAdd && $newID && $arFields["PUBLISH_STATUS"] == BLOG_PUBLISH_STATUS_PUBLISH || $arOldPost["PUBLISH_STATUS"] != BLOG_PUBLISH_STATUS_PUBLISH && $arFields["PUBLISH_STATUS"] == BLOG_PUBLISH_STATUS_PUBLISH) {
     $arFields["ID"] = $newID;
Exemple #11
0
function ForumClearComponentCache($components)
{
    if (empty($components)) {
        return false;
    }
    $aComponents = is_array($components) ? $components : explode(",", $components);
    foreach ($aComponents as $component_name) {
        $componentRelativePath = CComponentEngine::MakeComponentPath($component_name);
        if (strlen($componentRelativePath) > 0) {
            $arComponentDescription = CComponentUtil::GetComponentDescr($component_name);
            if (is_array($arComponentDescription) && array_key_exists("CACHE_PATH", $arComponentDescription)) {
                if ($arComponentDescription["CACHE_PATH"] == "Y") {
                    $arComponentDescription["CACHE_PATH"] = "/" . SITE_ID . $componentRelativePath;
                }
                if (strlen($arComponentDescription["CACHE_PATH"]) > 0) {
                    BXClearCache(true, $arComponentDescription["CACHE_PATH"]);
                }
            }
        }
    }
}
Exemple #12
0
/************** CACHE **********************************************/
if (!isset($arParams["CACHE_TIME"])) {
    $arParams["CACHE_TIME"] = 3600 * 24 * 7;
}
if ($arParams["CACHE_TYPE"] == "Y" || $arParams["CACHE_TYPE"] == "A" && COption::GetOptionString("main", "component_cache_on", "Y") == "Y") {
    $arParams["CACHE_TIME"] = intval($arParams["CACHE_TIME"]);
} else {
    $arParams["CACHE_TIME"] = 0;
}
$arParams["CACHE_TAGS"] = !empty($arParams["CACHE_TAGS"]) ? $arParams["CACHE_TAGS"] : array();
//$arParams["CACHE_TIME"] = 0;
/********************************************************************
				/Input params
********************************************************************/
global $CACHE_MANAGER;
$cache_path = CComponentEngine::MakeComponentPath("bitrix:socialnetwork.blog.blog");
$bGroupMode = $arParams["SOCNET_GROUP_ID"] > 0;
$feature = "blog";
$user_id = intval($USER->GetID());
$arResult["ERROR_MESSAGE"] = array();
$arResult["OK_MESSAGE"] = array();
if (!($bGroupMode && CSocNetFeatures::IsActiveFeature(SONET_ENTITY_GROUP, $arParams["SOCNET_GROUP_ID"], $feature) || CSocNetFeatures::IsActiveFeature(SONET_ENTITY_USER, $arParams["USER_ID"], $feature))) {
    $arResult["ERROR_MESSAGE"][] = array("id" => "SONET_MODULE_NOT_AVAIBLE", "text" => GetMessage("BLOG_SONET_MODULE_NOT_AVAIBLE"));
} else {
    if (!($arParams["USER_ID"] > 0 || $bGroupMode)) {
        $arResult["ERROR_MESSAGE"][] = array("id" => "NO_BLOG", "text" => GetMessage("BLOG_BLOG_BLOG_NO_BLOG"));
        CHTTP::SetStatus("404 Not Found");
    } else {
        $arResult["perms"] = BLOG_PERMS_DENY;
        $bCurrentUserIsAdmin = CSocNetUser::IsCurrentUserModuleAdmin();
        if ($bGroupMode) {
Exemple #13
0
function PClearComponentCache($components)
{
    if (empty($components)) {
        return false;
    }
    if (is_array($components)) {
        $aComponents = $components;
    } else {
        $aComponents = explode(",", $components);
    }
    foreach ($aComponents as $component_name) {
        $add_path = "";
        if (strpos($component_name, "/") !== false) {
            $add_path = substr($component_name, strpos($component_name, "/"));
            $component_name = substr($component_name, 0, strpos($component_name, "/"));
        }
        $componentRelativePath = CComponentEngine::MakeComponentPath($component_name);
        if (strlen($componentRelativePath) > 0) {
            BXClearCache(true, "/" . $componentRelativePath . $add_path);
            BXClearCache(true, "/" . SITE_ID . $componentRelativePath . $add_path);
        }
    }
    BXClearCache(true, "/photogallery");
    BXClearCache(true, "/" . SITE_ID . "/photogallery");
}
Exemple #14
0
             if (!isset(${"parser_" . LANGUAGE_ID})) {
                 ${"parser_" . LANGUAGE_ID} = new forumTextParser(LANGUAGE_ID);
             }
             $POST_MESSAGE = ${"parser_" . LANGUAGE_ID}->convert4mail(str_replace("#SERVER_NAME#", SITE_SERVER_NAME, $_REQUEST["POST_MESSAGE"]));
             $arFields = array("FROM_NAME" => $res["AUTHOR_NAME"], "FROM_USER_ID" => $USER->GetID(), "FROM_EMAIL" => $USER->GetEmail(), "TO_NAME" => $res["RECIPIENT_NAME"], "TO_USER_ID" => $res["RECIPIENT_ID"], "TO_EMAIL" => $res["RECIPIENT_EMAIL"], "SUBJECT" => $_REQUEST["POST_SUBJ"], "MESSAGE" => $POST_MESSAGE, "MESSAGE_DATE" => date("d.m.Y H:i:s"), "MESSAGE_LINK" => "http://" . SITE_SERVER_NAME . CComponentEngine::MakePathFromTemplate($arParams["~URL_TEMPLATES_PM_READ"], array("FID" => "1", "MID" => $arParams["MID"])) . " \n");
             $event->Send("NEW_FORUM_PRIVATE_MESSAGE", SITE_ID, $arFields, "N");
         }
     }
     if ($arParams['AUTOSAVE']) {
         $arParams['AUTOSAVE']->Reset();
     }
     // Clear cache.
     BXClearCache(true, "/bitrix/forum/user/" . $res["RECIPIENT_ID"] . "/");
     $arComponentPath = array("bitrix:forum");
     foreach ($arComponentPath as $path) {
         $componentRelativePath = CComponentEngine::MakeComponentPath($path);
         $arComponentDescription = CComponentUtil::GetComponentDescr($path);
         if (strLen($componentRelativePath) <= 0 || !is_array($arComponentDescription)) {
             continue;
         } elseif (!array_key_exists("CACHE_PATH", $arComponentDescription)) {
             continue;
         }
         $path = str_replace("//", "/", $componentRelativePath . "/user" . $res["RECIPIENT_ID"]);
         if ($arComponentDescription["CACHE_PATH"] == "Y") {
             $path = "/" . SITE_ID . $path;
         }
         if (!empty($path)) {
             BXClearCache(true, $path);
         }
     }
 }
Exemple #15
0
	function CopyTemplate($componentName, $templateName, $siteTemplate, $newSiteTemplate, $newName = False, $bRewrite = False)
	{
		$componentName = Trim($componentName);
		if (StrLen($componentName) <= 0)
		{
			$GLOBALS["APPLICATION"]->ThrowException(GetMessage("comp_util_err1"), "EMPTY_COMPONENT_NAME");
			return false;
		}

		$path2Comp = CComponentEngine::MakeComponentPath($componentName);
		if (StrLen($path2Comp) <= 0)
		{
			$GLOBALS["APPLICATION"]->ThrowException(str_replace("#NAME#", $componentName, GetMessage("comp_util_err2")), "ERROR_NOT_COMPONENT");
			return false;
		}

		$componentPath = "/bitrix/components".$path2Comp;

		if (!CComponentUtil::isComponent($componentPath))
		{
			$GLOBALS["APPLICATION"]->ThrowException(str_replace("#NAME#", $componentName, GetMessage("comp_util_err2")), "ERROR_NOT_COMPONENT");
			return false;
		}

		if (StrLen($templateName) <= 0)
			$templateName = ".default";

		$templateNameTmp = preg_replace("#[^A-Za-z0-9_.-]#i", "", $templateName);
		if ($templateNameTmp != $templateName)
		{
			$GLOBALS["APPLICATION"]->ThrowException(str_replace("#NAME#", $templateName, GetMessage("comp_util_err7")), "ERROR_BAD_TEMPLATE_NAME");
			return false;
		}

		if (StrLen($siteTemplate) <= 0)
			$siteTemplate = False;

		if ($siteTemplate != False)
		{
			if (!file_exists($_SERVER["DOCUMENT_ROOT"].BX_PERSONAL_ROOT."/templates/".$siteTemplate)
				|| !is_dir($_SERVER["DOCUMENT_ROOT"].BX_PERSONAL_ROOT."/templates/".$siteTemplate))
			{
				$GLOBALS["APPLICATION"]->ThrowException(str_replace("#NAME#", $siteTemplate, GetMessage("comp_util_err8")), "ERROR_NO_SITE_TEMPL");
				return false;
			}
		}

		if ($siteTemplate != False)
			$path = BX_PERSONAL_ROOT."/templates/".$siteTemplate."/components".$path2Comp."/".$templateName;
		else
			$path = "/bitrix/components".$path2Comp."/templates/".$templateName;

		if (!file_exists($_SERVER["DOCUMENT_ROOT"].$path))
		{
			$GLOBALS["APPLICATION"]->ThrowException(str_replace("#C_NAME#", $componentName, str_replace("#T_NAME#", $templateName, GetMessage("comp_util_err9"))), "ERROR_NO_TEMPL");
			return false;
		}

		if (StrLen($newSiteTemplate) <= 0)
		{
			$GLOBALS["APPLICATION"]->ThrowException(GetMessage("comp_util_err10"), "ERROR_EMPTY_SITE_TEMPL");
			return false;
		}

		if (!file_exists($_SERVER["DOCUMENT_ROOT"].BX_PERSONAL_ROOT."/templates/".$newSiteTemplate)
			|| !is_dir($_SERVER["DOCUMENT_ROOT"].BX_PERSONAL_ROOT."/templates/".$newSiteTemplate))
		{
			$GLOBALS["APPLICATION"]->ThrowException(str_replace("#NAME#", $newSiteTemplate, GetMessage("comp_util_err8")), "ERROR_NO_SITE_TEMPL");
			return false;
		}

		if ($siteTemplate !== False
			&& $siteTemplate == $newSiteTemplate
			&& ($newName === False || $newName !== False && $templateName == $newName))
		{
			$GLOBALS["APPLICATION"]->ThrowException(GetMessage("comp_util_err11"), "ERROR_DUPL1");
			return false;
		}

		if ($newName !== False)
			$templateNameNew = $newName;
		else
			$templateNameNew = $templateName;

		$templateNameNewTmp = preg_replace("#[^A-Za-z0-9_.-]#i", "", $templateNameNew);
		if ($templateNameNewTmp != $templateNameNew)
		{
			$GLOBALS["APPLICATION"]->ThrowException(str_replace("#NAME#", $templateNameNew, GetMessage("comp_util_err7")), "ERROR_BAD_TEMPLATE_NAME");
			return false;
		}

		$pathNew = BX_PERSONAL_ROOT."/templates/".$newSiteTemplate."/components".$path2Comp."/".$templateNameNew;

		if (file_exists($_SERVER["DOCUMENT_ROOT"].$pathNew))
		{
			if (!$bRewrite)
			{
				$GLOBALS["APPLICATION"]->ThrowException(str_replace("#NAME#", $templateNameNew, GetMessage("comp_util_err12")), "ERROR_EXISTS");
				return false;
			}
			else
			{
				DeleteDirFilesEx($pathNew);
			}
		}

		CopyDirFiles($_SERVER["DOCUMENT_ROOT"].$path, $_SERVER["DOCUMENT_ROOT"].$pathNew, True, True, False);

		return True;
	}
Exemple #16
0
 public function GetIcons()
 {
     /** @global CMain $APPLICATION */
     global $USER, $APPLICATION;
     $arIcons = array();
     $arPanelParams = array();
     $arComponentDescription = CComponentUtil::GetComponentDescr($this->componentName);
     $bComponentAccess = $USER->CanDoOperation('edit_php') || $this->bSrcFound && $USER->CanDoFileOperation('fm_lpa', array(SITE_ID, $this->sSrcFile));
     if ($bComponentAccess && !$this->parentComponent && $this->bSrcFound) {
         $url = $APPLICATION->GetPopupLink(array('URL' => "/freetrix/admin/component_props.php?" . "component_name=" . urlencode(CUtil::addslashes($this->componentName)) . "&component_template=" . urlencode(CUtil::addslashes($this->componentTemplate)) . "&template_id=" . urlencode(CUtil::addslashes(SITE_TEMPLATE_ID)) . "&lang=" . urlencode(CUtil::addslashes(LANGUAGE_ID)) . "&src_path=" . urlencode(CUtil::addslashes($this->sSrcFile)) . "&src_line=" . $this->iSrcLine . "&src_page=" . urlencode(CUtil::addslashes($APPLICATION->GetCurPage())) . "&src_site=" . urlencode(CUtil::addslashes(SITE_ID)), "PARAMS" => array("min_width" => 450)));
         $arIcons[] = array('URL' => 'javascript:' . $url, 'TYPE' => 'components2_props', 'ICON' => "bx-context-toolbar-settings-icon", 'TITLE' => GetMessage("main_incl_file_comp_param"), 'DEFAULT' => true);
         $aMenuItem = array("TEXT" => $arComponentDescription["NAME"], "TITLE" => GetMessage("main_comp_button_menu_title") . ' ' . $this->componentName, "ICON" => "parameters-2", "ACTION" => $url);
         $APPLICATION->AddPanelButtonMenu("components", $aMenuItem);
     }
     if ($bComponentAccess) {
         $template = $this->component->GetTemplate();
         if (is_null($template)) {
             if ($this->component->InitComponentTemplate()) {
                 $template = $this->component->GetTemplate();
             }
         }
         if (!is_null($template)) {
             $urlCopy = '';
             if ($this->bSrcFound && $template->IsInTheme() == false) {
                 //copy template dialog
                 $urlCopy = "/freetrix/admin/template_copy.php?" . "lang=" . urlencode(CUtil::addslashes(LANGUAGE_ID)) . "&component_name=" . urlencode(CUtil::addslashes($this->componentName)) . "&component_template=" . urlencode(CUtil::addslashes($this->componentTemplate)) . "&template_id=" . urlencode(CUtil::addslashes(SITE_TEMPLATE_ID)) . "&template_site_template=" . urlencode(CUtil::addslashes($template->GetSiteTemplate())) . "&src_path=" . urlencode(CUtil::addslashes($this->sSrcFile)) . "&src_line=" . $this->iSrcLine . "&src_site=" . urlencode(CUtil::addslashes(SITE_ID)) . "&edit_file=" . urlencode($template->GetPageName()) . "&back_path=" . urlencode($_SERVER["REQUEST_URI"]);
                 $arIcons[] = array('URL' => 'javascript:' . $APPLICATION->GetPopupLink(array('URL' => $urlCopy, "PARAMS" => array("min_width" => 450))), 'ICON' => "copy-2", 'TITLE' => GetMessage("main_comp_copy_templ"), 'IN_MENU' => true);
             }
             if ($USER->CanDoOperation('edit_php') && strlen($template->GetSiteTemplate()) > 0) {
                 //edit template copied to site template
                 $arIcons[] = array('URL' => 'javascript:' . $APPLICATION->GetPopupLink(array('URL' => "/freetrix/admin/public_file_edit_src.php?site=" . SITE_ID . "&" . 'path=' . urlencode($template->GetFile()) . "&back_url=" . urlencode($_SERVER["REQUEST_URI"]) . "&lang=" . LANGUAGE_ID, 'PARAMS' => array('width' => 770, 'height' => 470, 'resize' => true, "dialog_type" => 'EDITOR'))), 'ICON' => 'edit-2', 'TITLE' => GetMessage("main_comp_edit_templ"), 'IN_MENU' => true);
                 if (strlen($template->GetFolder()) > 0) {
                     if (file_exists($_SERVER["DOCUMENT_ROOT"] . $template->GetFolder() . "/style.css")) {
                         //edit template CSS copied to site template
                         $arIcons[] = array('URL' => 'javascript:' . $APPLICATION->GetPopupLink(array('URL' => "/freetrix/admin/public_file_edit_src.php?site=" . SITE_ID . "&" . 'path=' . urlencode($template->GetFolder() . "/style.css") . "&back_url=" . urlencode($_SERVER["REQUEST_URI"]) . "&lang=" . LANGUAGE_ID, 'PARAMS' => array('width' => 770, 'height' => 470, 'resize' => true, "dialog_type" => 'EDITOR'))), 'ICON' => 'edit-css', 'TITLE' => GetMessage("main_comp_edit_css"), 'IN_MENU' => true);
                     }
                     $bWasSep = false;
                     if (file_exists($_SERVER["DOCUMENT_ROOT"] . $template->GetFolder() . "/result_modifier.php")) {
                         $bWasSep = true;
                         $arIcons[] = array('SEPARATOR' => true);
                         $arIcons[] = array('URL' => 'javascript:' . $APPLICATION->GetPopupLink(array('URL' => "/freetrix/admin/public_file_edit_src.php?site=" . SITE_ID . "&" . 'path=' . urlencode($template->GetFolder() . "/result_modifier.php") . "&back_url=" . urlencode($_SERVER["REQUEST_URI"]) . "&lang=" . LANGUAGE_ID, 'PARAMS' => array('width' => 770, 'height' => 470, 'resize' => true, "dialog_type" => 'EDITOR'))), 'TITLE' => GetMessage("main_comp_edit_res_mod"), 'IN_MENU' => true);
                     }
                     if (file_exists($_SERVER["DOCUMENT_ROOT"] . $template->GetFolder() . "/component_epilog.php")) {
                         if (!$bWasSep) {
                             $arIcons[] = array('SEPARATOR' => true);
                         }
                         $arIcons[] = array('URL' => 'javascript:' . $APPLICATION->GetPopupLink(array('URL' => "/freetrix/admin/public_file_edit_src.php?site=" . SITE_ID . "&" . 'path=' . urlencode($template->GetFolder() . "/component_epilog.php") . "&back_url=" . urlencode($_SERVER["REQUEST_URI"]) . "&lang=" . LANGUAGE_ID, 'PARAMS' => array('width' => 770, 'height' => 470, 'resize' => true, "dialog_type" => 'EDITOR'))), 'TITLE' => GetMessage("main_comp_edit_epilog"), 'IN_MENU' => true);
                     }
                 }
             } elseif ($urlCopy != '') {
                 //copy template for future editing
                 $urlCopy .= '&system_template=Y';
                 $arIcons[] = array('URL' => 'javascript:' . $APPLICATION->GetPopupLink(array('URL' => $urlCopy, "PARAMS" => array("min_width" => 450))), 'ICON' => "edit-2", 'TITLE' => GetMessage("main_comp_edit_templ"), 'ALT' => GetMessage("main_comp_copy_title"), 'IN_MENU' => true);
             }
         }
     }
     $aAddIcons = array();
     $arPanelParams['COMPONENT'] = $this->componentName;
     if ($arComponentDescription && is_array($arComponentDescription)) {
         $arPanelParams['COMPONENT_DESCRIPTION'] = $arComponentDescription;
         //component bar tooltip
         $arPanelParams['TOOLTIP'] = array('TITLE' => $arComponentDescription["NAME"], 'TEXT' => '(' . GetMessage('main_incl_comp_component') . ' ' . $this->componentName . ')' . (isset($arComponentDescription["DESCRIPTION"]) && $arComponentDescription["DESCRIPTION"] != "" ? '<br />' . $arComponentDescription["DESCRIPTION"] : ''));
         //clear cache
         if (array_key_exists("CACHE_PATH", $arComponentDescription) && $USER->CanDoOperation('cache_control')) {
             if (strlen($arComponentDescription["CACHE_PATH"]) > 0) {
                 $arIcons[] = array("URL" => "javascript:jsComponentUtils.ClearCache('component_name=" . urlencode(CUtil::addslashes($this->componentName)) . "&site_id=" . SITE_ID . "&" . freetrix_sessid_get() . "');", "ICON" => "del-cache", "TITLE" => GetMessage("MAIN_FX_COMPONENT_CACHE_CLEAR"), 'IN_MENU' => true);
                 $APPLICATION->aCachedComponents[] = $this->componentName;
             }
         }
         //additional buttons from component description
         if (array_key_exists("AREA_BUTTONS", $arComponentDescription)) {
             $componentRelativePath = CComponentEngine::MakeComponentPath($this->componentName);
             $localPath = getLocalPath("components" . $componentRelativePath);
             foreach ($arComponentDescription["AREA_BUTTONS"] as $value) {
                 if (array_key_exists("SRC", $value)) {
                     $value["SRC"] = $localPath . $value["SRC"];
                 }
                 $aAddIcons[] = $value;
             }
         }
     }
     if (!empty($arIcons) && !empty($aAddIcons)) {
         $arIcons[] = array("SEPARATOR" => true);
     }
     $arIcons = array_merge($arIcons, $aAddIcons);
     $aAddIcons = $this->component->GetIncludeAreaIcons();
     if (!empty($arIcons) && !empty($aAddIcons)) {
         $arIcons[] = array("SEPARATOR" => true);
     }
     $arIcons = array_merge($arIcons, $aAddIcons);
     // enable/disable menu item
     if ($bComponentAccess && !$this->parentComponent && $this->bSrcFound) {
         if (!empty($arIcons)) {
             $arIcons[] = array("SEPARATOR" => true);
         }
         $arIcons[] = array("URL" => "javascript:jsComponentUtils.EnableComponent('component_name=" . urlencode(CUtil::addslashes($this->componentName)) . "&lang=" . urlencode(CUtil::addslashes(LANGUAGE_ID)) . "&src_path=" . urlencode(CUtil::addslashes($this->sSrcFile)) . "&src_line=" . $this->iSrcLine . "&src_site=" . urlencode(CUtil::addslashes(SITE_ID)) . '&active=' . ($this->bComponentEnabled ? 'N' : 'Y') . '&' . freetrix_sessid_get() . "');", "TITLE" => $this->bComponentEnabled ? GetMessage("main_comp_disable") : GetMessage("main_comp_enable"), "ALT" => $this->bComponentEnabled ? GetMessage("main_comp_disable_title") : GetMessage("main_comp_enable_title"), 'IN_MENU' => true);
     }
     if ($this->bSrcFound) {
         $arPanelParams['COMPONENT_ID'] = md5($arPanelParams['COMPONENT'] . '|' . $this->sSrcFile . ':' . $this->iSrcLine);
     }
     return array("icons" => $arIcons, "parameters" => $arPanelParams);
 }
Exemple #17
0
 /**
  * Function clears entire component cache.
  *
  * <p>Note: parameters must exactly match to startResultCache call.</p>
  * @param string $componentName
  * @param string $siteId
  * @return void
  *
  */
 public static final function clearComponentCache($componentName, $siteId = "")
 {
     /** @global CCacheManager $CACHE_MANAGER */
     global $CACHE_MANAGER;
     $componentRelativePath = CComponentEngine::MakeComponentPath($componentName);
     if ($componentRelativePath != "") {
         $obCache = new CPHPCache();
         $obCache->CleanDir($componentRelativePath, "cache");
         BXClearCache(true, $componentRelativePath);
         if ($siteId == "") {
             $rsSite = \Bitrix\Main\SiteTable::getList(array('order' => array('SORT' => 'ASC')));
             while ($site = $rsSite->fetch()) {
                 $componentCachePath = "/" . $site["LID"] . $componentRelativePath;
                 $obCache = new CPHPCache();
                 $obCache->CleanDir($componentCachePath, "cache");
                 BXClearCache(true, $componentCachePath);
             }
         } else {
             $componentCachePath = "/" . $siteId . $componentRelativePath;
             $obCache = new CPHPCache();
             $obCache->CleanDir($componentCachePath, "cache");
             BXClearCache(true, $componentCachePath);
         }
         if (defined("BX_COMP_MANAGED_CACHE")) {
             $CACHE_MANAGER->ClearByTag($componentName);
         }
     }
 }
Exemple #18
0
    $arResult["USER"]["HIDDEN_GROUPS"] = is_array($res["groups"]) ? $res["groups"] : array();
    $arResult["USER"]["HIDDEN_FORUMS"] = is_array($res["forums"]) ? $res["forums"] : array();
}
foreach ($arParams["FID_RANGE"] as $key => $val) {
    if (intVal($val) > 0) {
        $res[] = $val;
    }
}
$arParams["FID_RANGE"] = $res;
$cache = new CPHPCache();
global $NavNum;
$PAGEN_NAME = "PAGEN_" . ($NavNum + 1);
global ${$PAGEN_NAME};
$PAGEN = ${$PAGEN_NAME};
global $CACHE_MANAGER;
$cache_path = $CACHE_MANAGER->GetCompCachePath(CComponentEngine::MakeComponentPath($this->__name));
/********************************************************************
				/Default values
********************************************************************/
/********************************************************************
				Data
********************************************************************/
$arFilter = array();
if ($arParams["SHOW_FORUM_ANOTHER_SITE"] == "N" || !CForumUser::IsAdmin()) {
    $arFilter["LID"] = SITE_ID;
}
if (!empty($arParams["FID_RANGE"]) && (!CForumUser::IsAdmin() || $arParams["SHOW_FORUMS_LIST"] == "Y")) {
    $arFilter["@ID"] = $arParams["FID_RANGE"];
}
if (!CForumUser::IsAdmin()) {
    $arFilter["PERMS"] = array($USER->GetGroups(), 'A');
Exemple #19
0
 public static function getBlogPostUsersImprtnt($arFields)
 {
     if (!is_array($arFields)) {
         throw new Exception('Incorrect input data');
     }
     $arParams["postId"] = intval($arFields['POST_ID']);
     if ($arParams["postId"] <= 0) {
         throw new Exception('Wrong post ID');
     }
     $arParams["nTopCount"] = 500;
     $arParams["paramName"] = 'BLOG_POST_IMPRTNT';
     $arParams["paramValue"] = 'Y';
     $arResult = array();
     $cache = new CPHPCache();
     $cache_id = "blog_post_param_" . serialize(array($arParams["postId"], $arParams["nTopCount"], $arParams["paramName"], $arParams["paramValue"]));
     $cache_path = $GLOBALS["CACHE_MANAGER"]->GetCompCachePath(CComponentEngine::MakeComponentPath("socialnetwork.blog.blog")) . "/" . $arParams["postId"];
     $cache_time = defined("BX_COMP_MANAGED_CACHE") ? 3600 * 24 * 365 : 600;
     if ($cache->InitCache($cache_time, $cache_id, $cache_path)) {
         $arResult = $cache->GetVars();
     } else {
         $cache->StartDataCache($cache_time, $cache_id, $cache_path);
         if (CModule::IncludeModule("blog")) {
             if (defined("BX_COMP_MANAGED_CACHE")) {
                 $GLOBALS["CACHE_MANAGER"]->StartTagCache($cache_path);
                 $GLOBALS["CACHE_MANAGER"]->RegisterTag($arParams["paramName"] . $arParams["postId"]);
             }
             if ($arBlogPost = CBlogPost::GetByID($arParams["postId"])) {
                 $postPerms = CBlogPost::GetSocNetPostPerms($arParams["postId"], true, $GLOBALS["USER"]->GetID(), $arBlogPost["AUTHOR_ID"]);
                 if ($postPerms >= BLOG_PERMS_READ) {
                     $db_res = CBlogUserOptions::GetList(array(), array('POST_ID' => $arParams["postId"], 'NAME' => $arParams["paramName"], 'VALUE' => $arParams["paramValue"], 'USER_ACTIVE' => 'Y'), array("nTopCount" => $arParams["nTopCount"], "SELECT" => array("USER_ID")));
                     if ($db_res) {
                         while ($res = $db_res->Fetch()) {
                             $arResult[] = $res["USER_ID"];
                         }
                     }
                 }
             }
             if (defined("BX_COMP_MANAGED_CACHE")) {
                 $GLOBALS["CACHE_MANAGER"]->EndTagCache();
             }
             $cache->EndDataCache($arResult);
         }
     }
     return $arResult;
 }
Exemple #20
0
	/**
	* Function initializes the component. Returns true on success.
	*
	* <p>It is absolutly necessery to call this function before any component usage.</p>
	* @param string $componentName
	* @param string $componentTemplate
	* @return bool
	*
	*/
	final public function initComponent($componentName, $componentTemplate = false)
	{
		$this->__bInited = false;

		$componentName = trim($componentName);
		if (strlen($componentName) <= 0)
		{
			$this->__ShowError("Empty component name");
			return false;
		}

		$path2Comp = CComponentEngine::MakeComponentPath($componentName);
		if (strlen($path2Comp) <= 0)
		{
			$this->__ShowError(sprintf("'%s' is not a valid component name", $componentName));
			return false;
		}

		$componentPath = "/bitrix/components".$path2Comp;
		$this->classOfComponent = self::__getClassForPath($componentPath);

		if($this->classOfComponent !== "")
		{
			$componentFile = $_SERVER["DOCUMENT_ROOT"].$componentPath."/component.php";
			if (!file_exists($componentFile) || !is_file($componentFile))
			{
				$this->__ShowError(sprintf("'%s' is not a component", $componentName));
				return false;
			}
		}

		$this->__name = $componentName;
		$this->__relativePath = $path2Comp;
		$this->__path = $componentPath;
		$this->arResult = array();
		$this->arParams = array();
		$this->__parent = null;
		$this->__arIncludeAreaIcons = array();
		$this->__cache = null;
		if ($componentTemplate !== false)
			$this->setTemplateName($componentTemplate);

		$this->__bInited = true;

		return true;
	}
Exemple #21
0
/************** CACHE **********************************************/
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php";
$APPLICATION->RestartBuffer();
$arList = array("post_id" => $_REQUEST["post_id"], "items" => array(), "StatusPage" => "done", "RecordCount" => 0);
$arResult["nPageSize"] = 20;
$_REQUEST["post_id"] = intval($_REQUEST["post_id"]);
$_REQUEST["name"] = trim($_REQUEST["name"]);
$_REQUEST["value"] = trim($_REQUEST["value"]);
$_REQUEST["PATH_TO_USER"] = !empty($_REQUEST["PATH_TO_UER"]) ? $_REQUEST["PATH_TO_UER"] : (!empty($_REQUEST["PATH_TO_USER"]) ? $_REQUEST["PATH_TO_USER"] : '******');
$_REQUEST["NAME_TEMPLATE"] = !empty($_REQUEST["NAME_TEMPLATE"]) ? $_REQUEST["NAME_TEMPLATE"] : CSite::GetNameFormat(false);
if ($_REQUEST["post_id"] > 0 && !empty($_REQUEST["name"]) && !empty($_REQUEST["value"]) && check_bitrix_sessid()) {
    $arParams["CACHE_TIME"] = $_REQUEST["iNumPage"] >= 2 ? 0 : 600;
    global $CACHE_MANAGER;
    $cache = new CPHPCache();
    $cache_id = "blog_post_param_" . serialize(array($arResult["nPageSize"], $_REQUEST["post_id"], $_REQUEST["name"], $_REQUEST["iNumPage"], $_REQUEST["value"], $_REQUEST["NAME_TEMPLATE"], $_REQUEST["PATH_TO_USER"]));
    $cache_path = $CACHE_MANAGER->GetCompCachePath(CComponentEngine::MakeComponentPath("socialnetwork.blog.blog")) . "/" . $_REQUEST["post_id"];
    $arList = $arParams["CACHE_TIME"] > 0 && $cache->InitCache($arParams["CACHE_TIME"], $cache_id, $cache_path) ? $cache->GetVars() : array();
    if ((!is_array($arList) || empty($arList)) && CModule::IncludeModule("blog")) {
        $db_res = CBlogUserOptions::GetList(array("RANK" => "DESC", "OWNER_ID" => $GLOBALS["USER"]->GetID()), array("POST_ID" => $_REQUEST["post_id"], "NAME" => $_REQUEST["name"], "VALUE" => $_REQUEST["value"], "USER_ACTIVE" => "Y"), array("iNumPage" => $_REQUEST["iNumPage"] > 0 ? $_REQUEST["iNumPage"] : 0, "bDescPageNumbering" => false, "nPageSize" => $arResult["nPageSize"], "bShowAll" => false, "SELECT" => array("USER_ID", "USER_NAME", "USER_LAST_NAME", "USER_SECOND_NAME", "USER_LOGIN", "USER_PERSONAL_PHOTO")));
        if ($db_res && ($res = $db_res->Fetch())) {
            $arList["StatusPage"] = $db_res->NavPageNomer >= $db_res->NavPageCount || $arResult["nPageSize"] > $db_res->NavRecordCount ? "done" : "continue";
            $arList["RecordCount"] = $db_res->NavRecordCount;
            if ($_REQUEST["iNumPage"] <= $db_res->NavPageCount) {
                do {
                    $arUser = array("ID" => $res["USER_ID"], "PHOTO" => "", "FULL_NAME" => CUser::FormatName($_REQUEST["NAME_TEMPLATE"], array("NAME" => $res["USER_NAME"], "LAST_NAME" => $res["USER_LAST_NAME"], "SECOND_NAME" => $res["USER_SECOND_NAME"], "LOGIN" => $res["USER_LOGIN"])), "URL" => CUtil::JSEscape(CComponentEngine::MakePathFromTemplate($_REQUEST["PATH_TO_USER"], array("UID" => $res["USER_ID"], "user_id" => $res["USER_ID"], "USER_ID" => $res["USER_ID"]))));
                    if (array_key_exists("USER_PERSONAL_PHOTO", $res)) {
                        $arFileTmp = CFile::ResizeImageGet($res["USER_PERSONAL_PHOTO"], array("width" => 21, "height" => 21), BX_RESIZE_IMAGE_EXACT, false);
                        $arUser["PHOTO"] = CFile::ShowImage($arFileTmp["src"], 21, 21, "border=0");
                    }
                    $arList["items"][] = $arUser;
                } while ($res = $db_res->Fetch());