23 $cacheKey = serialize($siteIdList);
24 if (!array_key_exists($cacheKey, self::$moduleAdminListCache))
26 $cache = new \CPHPCache;
27 $cacheTime = 31536000;
28 $cacheId =
'site'.($siteIdList ?
'_'.implode(
'|', $siteIdList) :
'').
'new';
29 $cachePath =
"/sonet/user_admin/";
31 $adminList = $moduleAdminList = array();
33 if ($cache->initCache($cacheTime, $cacheId, $cachePath))
35 $cacheVars = $cache->getVars();
36 $adminList = $cacheVars[
"ADMIN"];
37 $moduleAdminList = $cacheVars[
"MODULE_ADMIN"];
41 $cache->startDataCache($cacheTime, $cacheId, $cachePath);
43 $connection = Main\HttpApplication::getConnection();
44 $helper = $connection->getSqlHelper();
48 MAX(".$DB->datetimeToTimestampFunction(
"UG.DATE_ACTIVE_FROM").
") UG_DATE_FROM_TS,
49 MAX(".$DB->datetimeToTimestampFunction(
"UG.DATE_ACTIVE_TO").
") UG_DATE_TO_TS
57 $result = $connection->query($sql);
59 while($ar = $result->fetch())
61 if(!array_key_exists($ar[
"U_ID"], $moduleAdminList))
63 $adminList[$ar[
"U_ID"]] = array(
64 "USER_ID" => $ar[
"U_ID"],
65 "DATE_FROM_TS" => $ar[
"UG_DATE_FROM_TS"],
66 "DATE_TO_TS" => $ar[
"UG_DATE_TO_TS"]
73 $sqlSite =
"AND MG.SITE_ID IS NULL";
78 foreach($siteIdList as $i => $siteId)
85 $sqlSite .=
"MG.SITE_ID " . ($siteId ?
"= '" . $helper->forSQL($siteId) .
"'" :
"IS NULL");
93 MAX(".$DB->datetimeToTimestampFunction(
"UG.DATE_ACTIVE_FROM").
") UG_DATE_FROM_TS,
94 MAX(".$DB->datetimeToTimestampFunction(
"UG.DATE_ACTIVE_TO").
") UG_DATE_TO_TS,
95 MAX(MG.G_ACCESS) G_ACCESS
104 AND MG.MODULE_ID = 'socialnetwork'
109 OR G.ANONYMOUS IS NULL
116 $result = $connection->query($sql);
118 while($ar = $result->fetch())
120 if(!array_key_exists($ar[
"U_ID"], $moduleAdminList))
122 $moduleAdminList[$ar[
"U_ID"]] = array(
123 "USER_ID" => $ar[
"U_ID"],
124 "DATE_FROM_TS" => $ar[
"UG_DATE_FROM_TS"],
125 "DATE_TO_TS" => $ar[
"UG_DATE_TO_TS"]
132 "ADMIN" => $adminList,
133 "MODULE_ADMIN" => $moduleAdminList
136 $cache->endDataCache($cacheData);
138 foreach ($adminList as $key => $arUserData)
142 !empty($arUserData[
"DATE_FROM_TS"])
143 && $arUserData[
"DATE_FROM_TS"] > time()
146 !empty($arUserData[
"DATE_TO_TS"])
147 && $arUserData[
"DATE_TO_TS"] < time()
151 unset($adminList[$key]);
155 foreach ($moduleAdminList as $key => $arUserData)
159 !empty($arUserData[
"DATE_FROM_TS"])
160 && $arUserData[
"DATE_FROM_TS"] > time()
163 !empty($arUserData[
"DATE_TO_TS"])
164 && $arUserData[
"DATE_TO_TS"] < time()
167 isset($adminList[$key])
169 empty($adminList[$key][
"DATE_TO_TS"])
170 || $adminList[$key][
"DATE_TO_TS"] > $arUserData[
"DATE_FROM_TS"]
175 unset($moduleAdminList[$key]);
179 self::$moduleAdminListCache[$cacheKey] = $adminList + $moduleAdminList;
182 return self::$moduleAdminListCache[$cacheKey];