Advertisement
pnzdevelop

init.php (bitrix24)

Dec 24th, 2020
836
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.83 KB | None | 0 0
  1. <?
  2. function GetGlobalID()
  3. {
  4.     global $GLOBAL_IBLOCK_ID;
  5.     global $GLOBAL_FORUM_ID;
  6.     global $GLOBAL_BLOG_GROUP;
  7.     global $GLOBAL_STORAGE_ID;
  8.     $ttl = 2592000;
  9.     $cache_id = 'id_to_code_';
  10.     $cache_dir = '/bx/code';
  11.     $obCache = new CPHPCache;
  12.  
  13.     if ($obCache->InitCache($ttl, $cache_id, $cache_dir))
  14.     {
  15.         $tmpVal = $obCache->GetVars();
  16.         $GLOBAL_IBLOCK_ID = $tmpVal['IBLOCK_ID'];
  17.         $GLOBAL_FORUM_ID = $tmpVal['FORUM_ID'];
  18.         $GLOBAL_BLOG_GROUP = $tmpVal['BLOG_GROUP'];
  19.         $GLOBAL_STORAGE_ID = $tmpVal['STORAGE_ID'];
  20.  
  21.         unset($tmpVal);
  22.     }
  23.     else
  24.     {
  25.         if (CModule::IncludeModule("iblock"))
  26.         {
  27.             $res = CIBlock::GetList(
  28.                 Array(),
  29.                 Array("CHECK_PERMISSIONS" => "N")
  30.             );
  31.  
  32.             while ($ar_res = $res->Fetch())
  33.             {
  34.                 $GLOBAL_IBLOCK_ID[$ar_res["CODE"]] = $ar_res["ID"];
  35.             }
  36.         }
  37.  
  38.         if (CModule::IncludeModule("forum"))
  39.         {
  40.             $res = CForumNew::GetList(
  41.                 Array()
  42.             );
  43.  
  44.             while ($ar_res = $res->Fetch())
  45.             {
  46.                 $GLOBAL_FORUM_ID[$ar_res["XML_ID"]] = $ar_res["ID"];
  47.             }
  48.         }
  49.  
  50.         if (CModule::IncludeModule("blog"))
  51.         {
  52.             $arFields = Array("ID", "SITE_ID");
  53.  
  54.             $dbGroup = CBlogGroup::GetList(array(), array(), false, false, $arFields);
  55.             if ($arGroup = $dbGroup->Fetch())
  56.             {
  57.                 $GLOBAL_BLOG_GROUP[$arGroup["SITE_ID"]] = $arGroup["ID"];
  58.             }
  59.         }
  60.  
  61.         if (CModule::IncludeModule("disk"))
  62.         {
  63.             $dbDisk = Bitrix\Disk\Storage::getList(array("filter"=>array("=ENTITY_TYPE" => Bitrix\Disk\ProxyType\Common::className())));
  64.             if ($commonStorage = $dbDisk->Fetch())
  65.             {
  66.                 $GLOBAL_STORAGE_ID["shared_files"] = $commonStorage["ID"];
  67.             }
  68.         }
  69.  
  70.         if ($obCache->StartDataCache())
  71.         {
  72.             $obCache->EndDataCache(array(
  73.                'IBLOCK_ID' => $GLOBAL_IBLOCK_ID,
  74.                'FORUM_ID' => $GLOBAL_FORUM_ID,
  75.                'BLOG_GROUP' => $GLOBAL_BLOG_GROUP,
  76.                'STORAGE_ID' => $GLOBAL_STORAGE_ID,
  77.            ));
  78.         }
  79.     }
  80. }
  81. ?>
  82.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement