Exemplo n.º 1
0
// 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()) {
    CSocNetLogEvents::Delete($arResult["ID"]);
}
$dbResult = CSocNetLogEvents::GetList(array("ENTITY_ID" => "DESC"), array("EVENT_ID" => "blog"));
while ($arResult = $dbResult->Fetch()) {
    $arLogEvent = array("USER_ID" => $arResult["USER_ID"], "ENTITY_TYPE" => $arResult["ENTITY_TYPE"], "ENTITY_ID" => $arResult["ENTITY_ID"], "ENTITY_CB" => $arResult["ENTITY_CB"], "ENTITY_MY" => $arResult["ENTITY_MY"], "MAIL_EVENT" => $arResult["MAIL_EVENT"], "TRANSPORT" => $arResult["TRANSPORT"], "VISIBLE" => $arResult["VISIBLE"]);
    if (strlen($arResult["SITE_ID"]) > 0) {
        $arLogEvent["SITE_ID"] = $arResult["SITE_ID"];
    } else {
        $arLogEvent["SITE_ID"] = false;
    }
    $arLogEventToAdd = array_merge($arLogEvent, array("EVENT_ID" => "blog_post"));
Exemplo n.º 2
0
 function SetGroup($entityID, $bSetFeatures = false)
 {
     global $APPLICATION, $DB;
     $entityID = IntVal($entityID);
     if ($entityID <= 0) {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_EUV_EMPTY_ENTITY_ID"), "ERROR_EMPTY_ENTITY_ID");
         return false;
     }
     $arGroup = CSocNetGroup::GetByID($entityID);
     if (!$arGroup) {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_EUV_NO_ENTITY"), "SONET_EUV_NO_ENTITY");
         return false;
     }
     $arLogEvent = array();
     $arSocNetLogEvents = CSocNetAllowed::GetAllowedLogEvents();
     foreach ($arSocNetLogEvents as $event_tmp_id => $arLogEventTmp) {
         if (!array_key_exists("ENTITIES", $arLogEventTmp) || !array_key_exists(SONET_SUBSCRIBE_ENTITY_GROUP, $arLogEventTmp["ENTITIES"])) {
             continue;
         }
         if (array_key_exists("NO_SET", $arLogEventTmp) && $arLogEventTmp["NO_SET"]) {
             continue;
         }
         $arLogEvent[] = $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) {
             $arLogEvent[] = $arLogEventTmp["COMMENT_EVENT"]["EVENT_ID"];
         }
     }
     $arLogEvent = array_unique($arLogEvent);
     foreach ($arLogEvent as $event_tmp_id) {
         if (!CSocNetEventUserView::Delete(SONET_ENTITY_GROUP, $entityID, $event_tmp_id)) {
             $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_EUV_ERROR_DELETE"), "ERROR_DELETE");
             return false;
         }
     }
     $dbResult = CSocNetUserToGroup::GetList(array(), array("GROUP_ID" => $entityID, "<=ROLE" => SONET_ROLES_USER, "USER_ACTIVE" => "Y"), false, false, array("USER_ID"));
     while ($arResult = $dbResult->Fetch()) {
         foreach ($arLogEvent as $event_tmp_id) {
             $arFields = array("ENTITY_TYPE" => SONET_ENTITY_GROUP, "ENTITY_ID" => $entityID, "EVENT_ID" => $event_tmp_id, "USER_ID" => $arResult["USER_ID"], "USER_ANONYMOUS" => "N");
             if (!CSocNetEventUserView::Add($arFields)) {
                 $errorMessage = "";
                 if ($e = $APPLICATION->GetException()) {
                     $errorMessage = $e->GetString();
                 }
                 if (StrLen($errorMessage) <= 0) {
                     $errorMessage = GetMessage("SONET_EUV_ERROR_SET");
                 }
                 $APPLICATION->ThrowException($errorMessage, "ERROR_SET");
                 return false;
             }
         }
     }
     if ($bSetFeatures) {
         $arActiveFeatures = array_keys(CSocNetFeatures::GetActiveFeaturesNames(SONET_ENTITY_GROUP, $entityID));
         foreach ($arActiveFeatures as $feature) {
             CSocNetEventUserView::SetFeature(SONET_ENTITY_GROUP, $entityID, $feature);
         }
     }
     return true;
 }