Beispiel #1
0
<?php

// set EUV for logged events
$dbResult = CSocNetLog::GetList(array("ENTITY_ID" => "ASC"), array(), array("ENTITY_TYPE", "ENTITY_ID"));
while ($arResult = $dbResult->Fetch()) {
    if ($arResult["ENTITY_TYPE"] == "U" && intval($arResult["ENTITY_ID"]) > 0) {
        CSocNetEventUserView::SetUser($arResult["ENTITY_ID"], false, false, true);
    } elseif ($arResult["ENTITY_TYPE"] == "G" && intval($arResult["ENTITY_ID"]) > 0) {
        CSocNetEventUserView::SetGroup($arResult["ENTITY_ID"], true);
    }
}
// set EUV for wiki
$dbResult = CSocNetEventUserView::GetList(array("ENTITY_ID" => "DESC"), array("ENTITY_TYPE" => "G"), array("ENTITY_ID"));
while ($arResult = $dbResult->Fetch()) {
    CSocNetEventUserView::SetFeature("G", $arResult["ENTITY_ID"], "wiki");
}
// set EUV for news
if (IsModuleInstalled("intranet")) {
    $dbResult = CSocNetEventUserView::GetList(array("ENTITY_ID" => "ASC"), array("ENTITY_TYPE" => "N"));
    $arResult = $dbResult->Fetch();
    if (!$arResult) {
        CSocNetEventUserView::Add(array("ENTITY_TYPE" => "N", "ENTITY_ID" => 0, "EVENT_ID" => "news", "USER_ID" => 0, "USER_ANONYMOUS" => "N"));
    }
}
$dbResult = CSocNetEventUserView::GetList(array("ENTITY_ID" => "DESC"), array("ENTITY_TYPE" => "G"), array("ENTITY_ID"));
while ($arResult = $dbResult->Fetch()) {
    CSocNetEventUserView::SetFeature("G", $arResult["ENTITY_ID"], "wiki");
}
// set blog_comment and blog_post for blog
$dbResult = CSocNetLogEvents::GetList(array("ENTITY_ID" => "DESC"), array("EVENT_ID" => array("blog_post", "blog_comment", "blog_post_micro")), false, false, array("ID"));
while ($arResult = $dbResult->Fetch()) {
 function Entity2UserAdd($entityType, $entityID, $userID, $role)
 {
     global $APPLICATION, $DB, $arSocNetAllowedEntityTypes;
     $CacheRelatedUsers = array();
     $entityType = trim($entityType);
     if (!in_array($entityType, $arSocNetAllowedEntityTypes)) {
         $APPLICATION->ThrowException(GetMessage("SONET_EUV_INCORRECT_ENTITY_TYPE"), "ERROR_INCORRECT_ENTITY_TYPE");
         return false;
     }
     $entityID = IntVal($entityID);
     if ($entityID <= 0) {
         $APPLICATION->ThrowException(GetMessage("SONET_EUV_EMPTY_ENTITY_ID"), "ERROR_EMPTY_ENTITY_ID");
         return false;
     }
     $userID = IntVal($userID);
     if ($userID <= 0) {
         $APPLICATION->ThrowException(GetMessage("SONET_EUV_EMPTY_USER_ID"), "ERROR_EMPTY_USER_ID");
         return false;
     }
     if (is_array($role)) {
         if (count($role) <= 0) {
             $APPLICATION->ThrowException(GetMessage("SONET_EUV_EMPTY_ROLE"), "ERROR_EMPTY_ROLE");
             return false;
         }
     } else {
         $role = trim($role);
         if (strlen($role) <= 0) {
             $APPLICATION->ThrowException(GetMessage("SONET_EUV_EMPTY_ROLE"), "ERROR_EMPTY_ROLE");
             return false;
         }
         $role = array($role);
     }
     if (!CSocNetEventUserView::IsEntityEmpty($entityType, $entityID)) {
         $arEvents = array();
         $arSocNetLogEvents = CSocNetAllowed::GetAllowedLogEvents();
         foreach ($arSocNetLogEvents as $event_tmp_id => $arLogEventTmp) {
             if (!array_key_exists("ENTITIES", $arLogEventTmp) || !array_key_exists($entityType, $arLogEventTmp["ENTITIES"])) {
                 continue;
             }
             if (array_key_exists("NO_SET", $arLogEventTmp) && $arLogEventTmp["NO_SET"]) {
                 continue;
             }
             $arEvents[] = $event_tmp_id;
             if (array_key_exists("COMMENT_EVENT", $arLogEventTmp) && is_array($arLogEventTmp["COMMENT_EVENT"]) && array_key_exists("EVENT_ID", $arLogEventTmp["COMMENT_EVENT"]) && strlen($arLogEventTmp["COMMENT_EVENT"]["EVENT_ID"]) > 0) {
                 $arEvents[] = $arLogEventTmp["COMMENT_EVENT"]["EVENT_ID"];
             }
         }
         $arSocNetFeaturesSettings = CSocNetAllowed::GetAllowedEntityTypes();
         foreach ($arSocNetFeaturesSettings as $feature => $arFeature) {
             if (!array_key_exists("subscribe_events", $arFeature)) {
                 continue;
             }
             foreach ($arFeature["subscribe_events"] as $event_id_tmp => $arEventIDTmp) {
                 if (array_key_exists("NO_SET", $arEventIDTmp) && $arEventIDTmp["NO_SET"]) {
                     continue;
                 }
                 if (!array_key_exists("OPERATION", $arEventIDTmp) || strlen($arEventIDTmp["OPERATION"]) <= 0) {
                     continue;
                 }
                 $featureOperationPerms = CSocNetFeaturesPerms::GetOperationPerm($entityType, $entityID, $feature, $arEventIDTmp["OPERATION"]);
                 if (in_array($featureOperationPerms, $role)) {
                     $arEvents[] = $event_id_tmp;
                 }
                 if (array_key_exists("COMMENT_EVENT", $arEventIDTmp) && is_array($arEventIDTmp["COMMENT_EVENT"]) && array_key_exists("EVENT_ID", $arEventIDTmp["COMMENT_EVENT"]) && array_key_exists("OPERATION", $arEventIDTmp["COMMENT_EVENT"]) && strlen($arEventIDTmp["COMMENT_EVENT"]["EVENT_ID"]) > 0 && strlen($arEventIDTmp["COMMENT_EVENT"]["OPERATION"]) > 0 && $arEventIDTmp["COMMENT_EVENT"]["EVENT_ID"] != $event_id_tmp) {
                     $featureOperationPerms = CSocNetFeaturesPerms::GetOperationPerm($entityType, $entityID, $feature, $arEventIDTmp["COMMENT_EVENT"]["OPERATION"]);
                     if (in_array($featureOperationPerms, $role)) {
                         $arEvents[] = $arEventIDTmp["COMMENT_EVENT"]["EVENT_ID"];
                     }
                 }
             }
         }
         $arEvents = array_unique($arEvents);
         foreach ($arEvents as $event) {
             $arFieldsEUV = array("ENTITY_TYPE" => SONET_ENTITY_GROUP, "ENTITY_ID" => $entityID, "EVENT_ID" => $event, "USER_ID" => $userID, "USER_ANONYMOUS" => "N");
             CSocNetEventUserView::Add($arFieldsEUV);
         }
     } elseif ($entityType == SONET_ENTITY_GROUP) {
         CSocNetEventUserView::SetGroup($entityID, true);
     } elseif ($entityType == SONET_ENTITY_USER) {
         CSocNetEventUserView::SetUser($entityID, false, false, true);
     }
 }