$arGroupsId[$ind] = IntVal($idTmp);
                } else {
                    if ($e = $GLOBALS["APPLICATION"]->GetException()) {
                        $errorString .= $e->GetString();
                    }
                    $bSonetError = true;
                }
            }
        }
        if (!$bSonetError) {
            foreach ($arGroupsId as $ind => $val) {
                CSocNetUserToGroup::Add(array("USER_ID" => 1, "GROUP_ID" => $val, "ROLE" => "A", "=DATE_CREATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "=DATE_UPDATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "INITIATED_BY_TYPE" => SONET_INITIATED_BY_USER, "INITIATED_BY_USER_ID" => 1, "MESSAGE" => false));
            }
            foreach ($arGroupsId as $ind => $val) {
                CSocNetFeatures::Add(array("ENTITY_TYPE" => SONET_ENTITY_GROUP, "ENTITY_ID" => $val, "FEATURE" => "forum", "FEATURE_NAME" => GetSocNetMessageLocal("SONET_I_FEATURE_FORUM", $arSite["LANGUAGE_ID"]), "ACTIVE" => "Y", "=DATE_UPDATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "=DATE_CREATE" => $GLOBALS["DB"]->CurrentTimeFunction()));
                CSocNetFeatures::Add(array("ENTITY_TYPE" => SONET_ENTITY_GROUP, "ENTITY_ID" => $val, "FEATURE" => "blog", "FEATURE_NAME" => GetSocNetMessageLocal("SONET_I_FEATURE_BLOG", $arSite["LANGUAGE_ID"]), "ACTIVE" => "Y", "=DATE_UPDATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "=DATE_CREATE" => $GLOBALS["DB"]->CurrentTimeFunction()));
            }
        }
    }
}
// ------------------ FORUM -------------------------------
$forumID = 0;
if (CModule::IncludeModule("forum")) {
    $dbResult = CForumNew::GetListEx(array(), array("SITE_ID" => $arSite["SITE_ID"], "XML_ID" => "car_forum_demo"));
    if ($arResult = $dbResult->Fetch()) {
        $forumID = $arResult["ID"];
    } else {
        $arFields = array("NAME" => GetSocNetMessageLocal("SONET_I_FORUM_NAME", $arSite["LANGUAGE_ID"]), "ACTIVE" => "Y", "XML_ID" => "car_forum_demo", "MODERATION" => "N", "SITES" => array($arSite["SITE_ID"] => StrLen($arSite["DIR"]) > 0 ? $arSite["DIR"] : "/"));
        $forumID = CForumNew::Add($arFields);
    }
}
Esempio n. 2
0
 function SetFeature($type, $id, $feature, $active, $featureName = false)
 {
     global $arSocNetAllowedEntityTypes, $APPLICATION;
     $type = Trim($type);
     if (StrLen($type) <= 0 || !in_array($type, $arSocNetAllowedEntityTypes)) {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_GF_ERROR_NO_ENTITY_TYPE"), "ERROR_EMPTY_TYPE");
         return false;
     }
     $id = IntVal($id);
     if ($id <= 0) {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_GF_EMPTY_ENTITY_ID"), "ERROR_EMPTY_ENTITY_ID");
         return false;
     }
     $feature = StrToLower(Trim($feature));
     if (StrLen($feature) <= 0) {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_GF_EMPTY_FEATURE_ID"), "ERROR_EMPTY_FEATURE_ID");
         return false;
     }
     $arSocNetFeaturesSettings = CSocNetAllowed::GetAllowedFeatures();
     if (!array_key_exists($feature, $arSocNetFeaturesSettings) || !in_array($type, $arSocNetFeaturesSettings[$feature]["allowed"])) {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_GF_ERROR_NO_FEATURE_ID"), "ERROR_NO_FEATURE_ID");
         return false;
     }
     $active = $active ? "Y" : "N";
     $dbResult = CSocNetFeatures::GetList(array(), array("ENTITY_TYPE" => $type, "ENTITY_ID" => $id, "FEATURE" => $feature), false, false, array("ID", "ACTIVE"));
     if ($arResult = $dbResult->Fetch()) {
         $r = CSocNetFeatures::Update($arResult["ID"], array("FEATURE_NAME" => $featureName, "ACTIVE" => $active, "=DATE_UPDATE" => $GLOBALS["DB"]->CurrentTimeFunction()));
     } else {
         $r = CSocNetFeatures::Add(array("ENTITY_TYPE" => $type, "ENTITY_ID" => $id, "FEATURE" => $feature, "FEATURE_NAME" => $featureName, "ACTIVE" => $active, "=DATE_UPDATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "=DATE_CREATE" => $GLOBALS["DB"]->CurrentTimeFunction()));
     }
     if (!$r) {
         $errorMessage = "";
         if ($e = $APPLICATION->GetException()) {
             $errorMessage = $e->GetString();
         }
         if (StrLen($errorMessage) <= 0) {
             $errorMessage = GetMessage("SONET_GF_ERROR_SET") . ".";
         }
         $GLOBALS["APPLICATION"]->ThrowException($errorMessage, "ERROR_SET_RECORD");
         return false;
     }
     return $r;
 }