예제 #1
0
             }
         }
     }
 }
 if (StrLen($errorMessage) <= 0) {
     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));
     }
 }
 if (StrLen($errorMessage) <= 0) {
     // set EUV vor news
     $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"));
         CSocNetEventUserView::Add(array("ENTITY_TYPE" => "N", "ENTITY_ID" => 0, "EVENT_ID" => "news_comment", "USER_ID" => 0, "USER_ANONYMOUS" => "N"));
     }
     $blogGroupID = 0;
     if (CModule::IncludeModule("blog")) {
         $dbRes = CBlogGroup::GetList(array("ID" => "DESC"), array("SITE_ID" => WIZARD_SITE_ID));
         if ($arRes = $dbRes->Fetch()) {
             $blogGroupID = $arRes["ID"];
         }
     }
     $forumID = 0;
     $photoForumID = 0;
     if (CModule::IncludeModule("forum")) {
         $dbRes = CForumNew::GetListEx(array(), array("SITE_ID" => WIZARD_SITE_ID, "XML_ID" => "USERS_AND_GROUPS"));
         if ($arRes = $dbRes->Fetch()) {
             $forumID = $arRes["ID"];
         }
예제 #2
0
 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);
     }
 }