Exemple #1
0
 /**
  * <p>Метод проверяет, может ли пользователь совершать указанную операцию над профайлом заданного пользователя.</p>
  *
  *
  * @param int $fromUserID  Код пользователя, права которого проверяются.
  *
  * @param int $toUserID  Код пользователя, к профайлу которого осуществляется доступ.
  *
  * @param string $operation  Операция.</bod
  *
  * @param bool $bCurrentUserIsAdmin = false Является ли администратором пользователь, права которого
  * проверяются. Необязательный парамтер. По умолчанию равен false.
  *
  * @return bool <p>True, если права на выполнение операции есть. Иначе - false.</p> <br><br>
  *
  * @static
  * @link http://dev.1c-bitrix.ru/api_help/socialnetwork/classes/csocnetuserperms/canperformoperation.php
  * @author Bitrix
  */
 public static function CanPerformOperation($fromUserID, $toUserID, $operation, $bCurrentUserIsAdmin = false)
 {
     global $arSocNetUserOperations;
     $fromUserID = IntVal($fromUserID);
     $toUserID = IntVal($toUserID);
     if ($toUserID <= 0) {
         return false;
     }
     $operation = StrToLower(Trim($operation));
     if (!array_key_exists($operation, $arSocNetUserOperations)) {
         return false;
     }
     // use no profile private permission restrictions at the extranet site
     if (CModule::IncludeModule('extranet') && CExtranet::IsExtranetSite()) {
         return true;
     }
     if ($bCurrentUserIsAdmin) {
         return true;
     }
     if ($fromUserID == $toUserID) {
         return true;
     }
     $usersRelation = CSocNetUserRelations::GetRelation($fromUserID, $toUserID);
     if ($usersRelation == SONET_RELATIONS_BAN && !IsModuleInstalled("im")) {
         return false;
     }
     $toUserOperationPerms = CSocNetUserPerms::GetOperationPerms($toUserID, $operation);
     if ($toUserOperationPerms == SONET_RELATIONS_TYPE_NONE) {
         return false;
     }
     if ($toUserOperationPerms == SONET_RELATIONS_TYPE_ALL) {
         return true;
     }
     if ($toUserOperationPerms == SONET_RELATIONS_TYPE_AUTHORIZED) {
         return $fromUserID > 0;
     }
     if ($toUserOperationPerms == SONET_RELATIONS_TYPE_FRIENDS || $toUserOperationPerms == SONET_RELATIONS_TYPE_FRIENDS2) {
         return CSocNetUserRelations::IsFriends($fromUserID, $toUserID);
     }
     return false;
 }
Exemple #2
0
 if ($arParams["USER_ID"] <= 0) {
     $arResult["FatalError"] = GetMessage("SONET_C40_NO_USER_ID") . ".";
 }
 if (StrLen($arResult["FatalError"]) <= 0) {
     $dbUser = CUser::GetByID($arParams["USER_ID"]);
     $arResult["User"] = $dbUser->GetNext();
     if (is_array($arResult["User"])) {
         $arResult["CurrentUserPerms"] = CSocNetUserPerms::InitUserPerms($GLOBALS["USER"]->GetID(), $arResult["User"]["ID"], CSocNetUser::IsCurrentUserModuleAdmin());
         if ($arResult["CurrentUserPerms"]["Operations"]["modifyuser"]) {
             $arResult["Features"] = array();
             global $arSocNetUserOperations;
             foreach ($arSocNetUserOperations as $feature => $perm) {
                 if (IsModuleInstalled("im") && $feature == "message") {
                     continue;
                 }
                 $perm = CSocNetUserPerms::GetOperationPerms($arResult["User"]["ID"], $feature);
                 if ($bExtranetInstalled && $perm == SONET_RELATIONS_TYPE_ALL) {
                     $perm = SONET_RELATIONS_TYPE_AUTHORIZED;
                 }
                 $arResult["Features"][$feature] = $perm;
             }
         } else {
             $arResult["FatalError"] = GetMessage("SONET_C40_NO_PERMS") . ".";
         }
     } else {
         $arResult["FatalError"] = GetMessage("SONET_C40_NO_USER") . ".";
     }
 }
 if (StrLen($arResult["FatalError"]) <= 0) {
     $arResult["Urls"]["User"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_USER"], array("user_id" => $arResult["User"]["ID"]));
     $arTmpUser = array('NAME' => $arResult["User"]["~NAME"], 'LAST_NAME' => $arResult["User"]["~LAST_NAME"], 'SECOND_NAME' => $arResult["User"]["~SECOND_NAME"], 'LOGIN' => $arResult["User"]["~LOGIN"]);
Exemple #3
0
	function DeleteRelation($senderUserID, $targetUserID)
	{
		global $APPLICATION;

		$senderUserID = IntVal($senderUserID);
		if ($senderUserID <= 0)
		{
			$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_UR_EMPTY_SENDER_USER_ID"), "ERROR_SENDER_USER_ID");
			return false;
		}

		$targetUserID = IntVal($targetUserID);
		if ($targetUserID <= 0)
		{
			$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_UR_EMPTY_TARGET_USER_ID"), "ERROR_TARGET_USER_ID");
			return false;
		}

		$arRelation = CSocNetUserRelations::GetByUserID($senderUserID, $targetUserID);
		if (!$arRelation)
		{
			$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_UR_RELATION_NOT_FOUND"), "ERROR_RELATION_NOT_FOUND");
			return false;
		}

		if (CSocNetUserRelations::Delete($arRelation["ID"]))
		{
			$logID = CSocNetLog::Add(
				array(
					"ENTITY_TYPE" => SONET_ENTITY_USER,
					"ENTITY_ID" => $senderUserID,
					"EVENT_ID" => "system_friends",
					"=LOG_DATE" => $GLOBALS["DB"]->CurrentTimeFunction(),
					"TITLE_TEMPLATE" => false,
					"TITLE" => "unfriend",
					"MESSAGE" => $targetUserID,
					"URL" => false,
					"MODULE_ID" => false,
					"CALLBACK_FUNC" => false,
					"USER_ID" => $targetUserID,
				),
				false
			);
			if (intval($logID) > 0)
			{
				CSocNetLog::Update($logID, array("TMP_ID" => $logID));

				$perm = CSocNetUserPerms::GetOperationPerms($senderUserID, "viewfriends");
				if (in_array($perm, array(SONET_RELATIONS_TYPE_FRIENDS2, SONET_RELATIONS_TYPE_FRIENDS)))
					CSocNetLogRights::Add($logID, array("SA", "U".$senderUserID, "S".SONET_ENTITY_USER.$senderUserID."_".$perm));
				elseif ($perm == SONET_RELATIONS_TYPE_NONE)
					CSocNetLogRights::Add($logID, array("SA", "U".$senderUserID));
				elseif ($perm == SONET_RELATIONS_TYPE_AUTHORIZED)
					CSocNetLogRights::Add($logID, array("SA", "AU"));
				elseif ($perm == SONET_RELATIONS_TYPE_ALL)
					CSocNetLogRights::Add($logID, array("SA", "G2"));

				$tmpID = $logID;
			}

			$logID2 = CSocNetLog::Add(
				array(
					"ENTITY_TYPE" => SONET_ENTITY_USER,
					"ENTITY_ID" => $targetUserID,
					"EVENT_ID" => "system_friends",
					"=LOG_DATE" => $GLOBALS["DB"]->CurrentTimeFunction(),
					"TITLE_TEMPLATE" => false,
					"TITLE" => "unfriend",
					"MESSAGE" => $senderUserID,
					"URL" => false,
					"MODULE_ID" => false,
					"CALLBACK_FUNC" => false,
					"USER_ID" => $senderUserID,
					"TMP_ID" => (intval($tmpID) > 0 ? $tmpID : false),
				),
				false
			);

			if (intval($logID2) > 0)
			{
				$perm = CSocNetUserPerms::GetOperationPerms($targetUserID, "viewfriends");
				if (in_array($perm, array(SONET_RELATIONS_TYPE_FRIENDS2, SONET_RELATIONS_TYPE_FRIENDS)))
					CSocNetLogRights::Add($logID2, array("SA", "U".$targetUserID, "S".SONET_ENTITY_USER.$targetUserID."_".$perm));
				elseif ($perm == SONET_RELATIONS_TYPE_NONE)
					CSocNetLogRights::Add($logID2, array("SA", "U".$targetUserID));
				elseif ($perm == SONET_RELATIONS_TYPE_AUTHORIZED)
					CSocNetLogRights::Add($logID2, array("SA", "AU"));
				elseif ($perm == SONET_RELATIONS_TYPE_ALL)
					CSocNetLogRights::Add($logID2, array("SA", "G2"));
			}

			CSocNetLog::SendEvent($logID, "SONET_NEW_EVENT", $tmpID);			

			if ($arRelation["RELATION"] == SONET_RELATIONS_FRIEND)
				$GLOBALS["DB"]->Query("DELETE FROM b_sonet_event_user_view WHERE
					ENTITY_TYPE = '".SONET_ENTITY_USER."'
					AND (
						(USER_ID = ".$arRelation["FIRST_USER_ID"]." AND ENTITY_ID = ".$arRelation["SECOND_USER_ID"].")
						OR (USER_ID = ".$arRelation["SECOND_USER_ID"]." AND ENTITY_ID = ".$arRelation["FIRST_USER_ID"].")
						OR (ENTITY_ID = ".$arRelation["FIRST_USER_ID"]." AND USER_IM_ID = ".$arRelation["SECOND_USER_ID"].")
						OR (ENTITY_ID = ".$arRelation["SECOND_USER_ID"]." AND USER_IM_ID = ".$arRelation["FIRST_USER_ID"].")
						OR (USER_ID = ".$arRelation["FIRST_USER_ID"]." AND USER_IM_ID = ".$arRelation["SECOND_USER_ID"].")
						OR (USER_ID = ".$arRelation["SECOND_USER_ID"]." AND USER_IM_ID = ".$arRelation["FIRST_USER_ID"].")
					)", true);
		}
		else
		{
			$errorMessage = "";
			if ($e = $APPLICATION->GetException())
				$errorMessage = $e->GetString();
			if (StrLen($errorMessage) <= 0)
				$errorMessage = GetMessage("SONET_UR_RELATION_DELETE_ERROR");

			$GLOBALS["APPLICATION"]->ThrowException($errorMessage, "ERROR_DELETE_RELATION");
			return false;
		}

		CSocNetUserRelations::__SpeedFileCheckMessages($senderUserID);

		return true;
	}
Exemple #4
0
         $perm = CSocNetUserPerms::GetOperationPerms($arLog["ENTITY_ID"], $operation);
         if (in_array($perm, array(SONET_RELATIONS_TYPE_FRIENDS2, SONET_RELATIONS_TYPE_FRIENDS))) {
             CSocNetLogRights::Add($arLog["ID"], array("SA", "U" . $arLog["ENTITY_ID"], "SU" . $arLog["ENTITY_ID"] . "_" . $perm));
         } elseif ($perm == SONET_RELATIONS_TYPE_NONE) {
             CSocNetLogRights::Add($arLog["ID"], array("SA", "U" . $arLog["ENTITY_ID"]));
         } elseif ($perm == SONET_RELATIONS_TYPE_AUTHORIZED) {
             CSocNetLogRights::Add($arLog["ID"], array("SA", "AU"));
         } elseif ($perm == SONET_RELATIONS_TYPE_ALL) {
             CSocNetLogRights::Add($arLog["ID"], array("SA", "G2"));
         }
     } elseif ($featureID = CSocNetLogTools::FindFeatureByEventID($arLog["EVENT_ID"])) {
         CSocNetLogRights::SetForSonet($arLog["ID"], $arLog["ENTITY_TYPE"], $arLog["ENTITY_ID"], $featureID, $GLOBALS["arSocNetFeaturesSettings"][$featureID]["subscribe_events"][$arLog["EVENT_ID"]]["OPERATION"]);
     } elseif ($arLog["ENTITY_TYPE"] == SONET_SUBSCRIBE_ENTITY_GROUP) {
         CSocNetLogRights::Add($arLog["ID"], array("SA", "SG" . $arLog["ENTITY_ID"] . "_" . SONET_ROLES_OWNER, "SG" . $arLog["ENTITY_ID"] . "_" . SONET_ROLES_MODERATOR, "SG" . $arLog["ENTITY_ID"] . "_" . SONET_ROLES_USER));
     } elseif ($arLog["ENTITY_TYPE"] == SONET_SUBSCRIBE_ENTITY_USER) {
         $perm = CSocNetUserPerms::GetOperationPerms($arLog["ENTITY_ID"], "viewprofile");
         if (in_array($perm, array(SONET_RELATIONS_TYPE_FRIENDS2, SONET_RELATIONS_TYPE_FRIENDS))) {
             CSocNetLogRights::Add($arLog["ID"], array("SA", "U" . $arLog["ENTITY_ID"], "SU" . $arLog["ENTITY_ID"] . "_" . $perm));
         } elseif ($perm == SONET_RELATIONS_TYPE_NONE) {
             CSocNetLogRights::Add($arLog["ID"], array("SA", "U" . $arLog["ENTITY_ID"]));
         } elseif ($perm == SONET_RELATIONS_TYPE_AUTHORIZED) {
             CSocNetLogRights::Add($arLog["ID"], array("SA", "AU"));
         } elseif ($perm == SONET_RELATIONS_TYPE_ALL) {
             CSocNetLogRights::Add($arLog["ID"], array("SA", "G2"));
         }
         // tasks!!!
     }
 } elseif (in_array($arLog["ENTITY_TYPE"], array('R'))) {
     // reports
 } elseif (in_array($arLog["ENTITY_TYPE"], array('T'))) {
     // timeman
 function SetFeature($entityType, $entityID, $feature, $op = false, $permX = false, $bCheckEmpty = false)
 {
     global $APPLICATION, $DB, $arSocNetAllowedEntityTypes;
     $arSocNetFeaturesSettings = CSocNetAllowed::GetAllowedFeatures();
     $arSocNetAllowedSubscribeEntityTypesDesc = CSocNetAllowed::GetAllowedEntityTypesDesc();
     $CacheRelatedUsers = array();
     $entityType = trim($entityType);
     if (!in_array($entityType, $arSocNetAllowedEntityTypes)) {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_EUV_INCORRECT_ENTITY_TYPE"), "ERROR_INCORRECT_ENTITY_TYPE");
         return false;
     }
     $entityID = IntVal($entityID);
     if ($entityID <= 0) {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_EUV_EMPTY_ENTITY_ID"), "ERROR_EMPTY_ENTITY_ID");
         return false;
     }
     if (!$bCheckEmpty || !CSocNetEventUserView::IsEntityEmpty($entityType, $entityID)) {
         $event_id = array();
         if (!$op || !$permX) {
             if (array_key_exists($feature, $arSocNetFeaturesSettings) && array_key_exists("subscribe_events", $arSocNetFeaturesSettings[$feature])) {
                 foreach ($arSocNetFeaturesSettings[$feature]["subscribe_events"] as $event_id_tmp => $arEventIDTmp) {
                     if (array_key_exists("NO_SET", $arEventIDTmp) && $arEventIDTmp["NO_SET"]) {
                         continue;
                     }
                     if (!array_key_exists("ENTITIES", $arEventIDTmp) || !array_key_exists($entityType, $arEventIDTmp["ENTITIES"])) {
                         continue;
                     }
                     $event_id[$arEventIDTmp["OPERATION"]][] = $event_id_tmp;
                     if (array_key_exists("COMMENT_EVENT", $arEventIDTmp) && is_array($arEventIDTmp["COMMENT_EVENT"]) && array_key_exists("OPERATION", $arEventIDTmp["COMMENT_EVENT"]) && strlen($arEventIDTmp["COMMENT_EVENT"]["OPERATION"]) > 0) {
                         $event_id[$arEventIDTmp["OPERATION"]][] = $arEventIDTmp["COMMENT_EVENT"]["EVENT_ID"];
                     }
                 }
                 if (is_array($event_id[$arEventIDTmp["OPERATION"]])) {
                     $event_id[$arEventIDTmp["OPERATION"]] = array_unique($event_id[$arEventIDTmp["OPERATION"]]);
                 }
             }
         } else {
             $arOpTmp = array();
             if (array_key_exists($feature, $arSocNetFeaturesSettings) && array_key_exists("subscribe_events", $arSocNetFeaturesSettings[$feature])) {
                 foreach ($arSocNetFeaturesSettings[$feature]["subscribe_events"] as $event_id_tmp => $arEventIDTmp) {
                     if (array_key_exists("NO_SET", $arEventIDTmp) && $arEventIDTmp["NO_SET"]) {
                         continue;
                     }
                     if (!array_key_exists("ENTITIES", $arEventIDTmp) || !array_key_exists($entityType, $arEventIDTmp["ENTITIES"])) {
                         continue;
                     }
                     if (!array_key_exists("OPERATION", $arEventIDTmp) || strlen($arEventIDTmp["OPERATION"]) <= 0) {
                         continue;
                     }
                     $arOpTmp[] = $arEventIDTmp["OPERATION"];
                     if (array_key_exists("COMMENT_EVENT", $arEventIDTmp) && is_array($arEventIDTmp["COMMENT_EVENT"]) && array_key_exists("OPERATION", $arEventIDTmp["COMMENT_EVENT"]) && strlen($arEventIDTmp["COMMENT_EVENT"]["OPERATION"]) > 0) {
                         $arOpTmp[] = $arEventIDTmp["COMMENT_EVENT"]["OPERATION"];
                     }
                 }
             }
             if (is_array($arOpTmp)) {
                 $arOpTmp = array_unique($arOpTmp);
             }
             if (in_array($op, $arOpTmp)) {
                 foreach ($arSocNetFeaturesSettings[$feature]["subscribe_events"] as $event_id_tmp => $arEventIDTmp) {
                     if ($arEventIDTmp["OPERATION"] == $op) {
                         $event_id[$op][] = $event_id_tmp;
                     }
                     if (array_key_exists("COMMENT_EVENT", $arEventIDTmp) && is_array($arEventIDTmp["COMMENT_EVENT"]) && array_key_exists("OPERATION", $arEventIDTmp["COMMENT_EVENT"]) && $arEventIDTmp["COMMENT_EVENT"]["OPERATION"] == $op) {
                         $event_id[$op][] = $arEventIDTmp["COMMENT_EVENT"]["EVENT_ID"];
                     }
                 }
                 if (is_array($event_id[$op])) {
                     $event_id[$op] = array_unique($event_id[$op]);
                 }
             } else {
                 return true;
             }
         }
         if (intval($entityID) > 0 && array_key_exists($entityType, $arSocNetAllowedSubscribeEntityTypesDesc) && array_key_exists("CLASS_DESC_GET", $arSocNetAllowedSubscribeEntityTypesDesc[$entityType]) && array_key_exists("METHOD_DESC_GET", $arSocNetAllowedSubscribeEntityTypesDesc[$entityType])) {
             $arEntityTmp = call_user_func(array($arSocNetAllowedSubscribeEntityTypesDesc[$entityType]["CLASS_DESC_GET"], $arSocNetAllowedSubscribeEntityTypesDesc[$entityType]["METHOD_DESC_GET"]), $entityID);
         }
         foreach ($event_id as $op => $arEvent) {
             $arRelatedUsers = array();
             if (is_array($arEvent)) {
                 foreach ($arEvent as $event) {
                     if (!CSocNetEventUserView::Delete($entityType, $entityID, $feature, $event)) {
                         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_EUV_ERROR_DELETE"), "ERROR_DELETE");
                         return false;
                     }
                     if (!$feature || !$permX) {
                         $perm = CSocNetFeaturesPerms::GetOperationPerm($entityType, $entityID, $feature, $op);
                     } else {
                         $perm = $permX;
                     }
                     if ($entityType == SONET_SUBSCRIBE_ENTITY_GROUP && $arEntityTmp && $arEntityTmp["VISIBLE"] == "N" && $perm > SONET_ROLES_USER) {
                         $perm = SONET_ROLES_USER;
                     } elseif ($entityType == SONET_SUBSCRIBE_ENTITY_USER) {
                         $perm_profile = CSocNetUserPerms::GetOperationPerms($entityID, "viewprofile");
                         if ($perm < $perm_profile) {
                             $perm = $perm_profile;
                         }
                     }
                     if (array_key_exists($entityType, $CacheRelatedUsers) && array_key_exists($entityID, $CacheRelatedUsers[$entityType]) && array_key_exists($perm, $CacheRelatedUsers[$entityType][$entityID])) {
                         $arRelatedUsers = $CacheRelatedUsers[$entityType][$entityID][$perm];
                     } else {
                         if ($entityType == SONET_SUBSCRIBE_ENTITY_USER) {
                             switch ($perm) {
                                 case SONET_RELATIONS_TYPE_FRIENDS:
                                     $arRelatedUsers[] = array("entity_id" => $entityID, "user_id" => $entityID);
                                     $dbFriends = CSocNetUserRelations::GetRelatedUsers($entityID, SONET_RELATIONS_FRIEND);
                                     while ($arFriends = $dbFriends->Fetch()) {
                                         $friendID = $entityID == $arFriends["FIRST_USER_ID"] ? $arFriends["SECOND_USER_ID"] : $arFriends["FIRST_USER_ID"];
                                         $arRelatedUsers[] = array("entity_id" => $entityID, "user_id" => $friendID);
                                     }
                                     break;
                                 case SONET_RELATIONS_TYPE_FRIENDS2:
                                     $arRelatedUsers[] = array("entity_id" => $entityID, "user_id" => $entityID);
                                     $dbFriends = CSocNetUserRelations::GetRelatedUsers($entityID, SONET_RELATIONS_FRIEND);
                                     while ($arFriends = $dbFriends->Fetch()) {
                                         $friendID = $entityID == $arFriends["FIRST_USER_ID"] ? $arFriends["SECOND_USER_ID"] : $arFriends["FIRST_USER_ID"];
                                         $arRelatedUsers[] = array("entity_id" => $entityID, "user_id" => $friendID);
                                         $dbFriends2 = CSocNetUserRelations::GetRelatedUsers($friendID, SONET_RELATIONS_FRIEND);
                                         while ($arFriends2 = $dbFriends2->Fetch()) {
                                             $friendID2 = $friendID == $arFriends2["FIRST_USER_ID"] ? $arFriends2["SECOND_USER_ID"] : $arFriends2["FIRST_USER_ID"];
                                             if ($friendID2 != $entityID) {
                                                 $arRelatedUsers[] = array("entity_id" => $entityID, "user_id" => $friendID2, "user_im_id" => $friendID);
                                             }
                                         }
                                     }
                                     break;
                                 case SONET_RELATIONS_TYPE_NONE:
                                     $arRelatedUsers[] = array("entity_id" => $entityID, "user_id" => $entityID);
                                     break;
                                 case SONET_RELATIONS_TYPE_AUTHORIZED:
                                     $arRelatedUsers[] = array("entity_id" => $entityID, "user_id" => 0);
                                     break;
                                 case SONET_RELATIONS_TYPE_ALL:
                                     $arRelatedUsers = false;
                                     break;
                             }
                             if (!empty($arRelatedUsers)) {
                                 $arRelatedUsers = array_unique($arRelatedUsers);
                             }
                             $CacheRelatedUsers[SONET_ENTITY_USER][$entityID][$perm] = $arRelatedUsers;
                         } elseif ($entityType == SONET_SUBSCRIBE_ENTITY_GROUP) {
                             switch ($perm) {
                                 case SONET_ROLES_USER:
                                     $dbResult = CSocNetUserToGroup::GetList(array(), array("GROUP_ID" => $entityID, "<=ROLE" => SONET_ROLES_USER, "USER_ACTIVE" => "Y"), false, false, array("USER_ID"));
                                     while ($arResult = $dbResult->Fetch()) {
                                         $arRelatedUsers[] = $arResult["USER_ID"];
                                     }
                                     break;
                                 case SONET_ROLES_MODERATOR:
                                     $dbResult = CSocNetUserToGroup::GetList(array(), array("GROUP_ID" => $entityID, "<=ROLE" => SONET_ROLES_MODERATOR, "USER_ACTIVE" => "Y"), false, false, array("USER_ID"));
                                     while ($arResult = $dbResult->Fetch()) {
                                         $arRelatedUsers[] = $arResult["USER_ID"];
                                     }
                                     break;
                                 case SONET_ROLES_OWNER:
                                     $dbResult = CSocNetUserToGroup::GetList(array(), array("GROUP_ID" => $entityID, "<=ROLE" => SONET_ROLES_OWNER, "USER_ACTIVE" => "Y"), false, false, array("USER_ID"));
                                     while ($arResult = $dbResult->Fetch()) {
                                         $arRelatedUsers[] = $arResult["USER_ID"];
                                     }
                                     break;
                                 case SONET_ROLES_AUTHORIZED:
                                     $arRelatedUsers[] = 0;
                                     break;
                                 case SONET_ROLES_ALL:
                                     $arRelatedUsers = false;
                                     break;
                             }
                             if ($arRelatedUsers && is_array($arRelatedUsers) && in_array(0, $arRelatedUsers)) {
                                 $arRelatedUsers = array(0);
                             } elseif ($arRelatedUsers && is_array($arRelatedUsers)) {
                                 $arRelatedUsers = array_unique($arRelatedUsers);
                             }
                             $CacheRelatedUsers[SONET_ENTITY_GROUP][$entityID][$perm] = $arRelatedUsers;
                         }
                     }
                     if ($arRelatedUsers && is_array($arRelatedUsers)) {
                         foreach ($arRelatedUsers as $relatedUserID) {
                             if (is_array($relatedUserID)) {
                                 $arFields = array("ENTITY_TYPE" => $entityType, "ENTITY_ID" => $relatedUserID["entity_id"], "EVENT_ID" => $event, "USER_ID" => $relatedUserID["user_id"], "USER_ANONYMOUS" => "N");
                                 if (array_key_exists("user_im_id", $relatedUserID)) {
                                     $arFields["USER_IM_ID"] = $relatedUserID["user_im_id"];
                                 }
                                 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;
                                 }
                             } else {
                                 $arFields = array("ENTITY_TYPE" => $entityType, "ENTITY_ID" => $entityID, "EVENT_ID" => $event, "USER_ID" => $relatedUserID, "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;
                                 }
                             }
                         }
                     } else {
                         $arFields = array("ENTITY_TYPE" => $entityType, "ENTITY_ID" => $entityID, "EVENT_ID" => $event, "USER_ID" => 0, "USER_ANONYMOUS" => "Y");
                         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;
                         }
                     }
                 }
             }
         }
     } elseif ($entityType == SONET_ENTITY_GROUP) {
         CSocNetEventUserView::SetGroup($entityID, true);
     } elseif ($entityType == SONET_ENTITY_USER) {
         CSocNetEventUserView::SetUser($entityID, false, false, true);
     }
     return true;
 }
Exemple #6
0
 function SetSonetLogRights($logID, $entity_type, $entity_id, $event_id)
 {
     if (!CModule::IncludeModule("socialnetwork")) {
         return;
     }
     if (in_array($entity_type, array(SONET_SUBSCRIBE_ENTITY_USER, SONET_SUBSCRIBE_ENTITY_GROUP))) {
         if (in_array($event_id, array("blog_post", "forum", "photo", "blog_post_micro", "files", "wiki"))) {
             $arLogEventTmp = CSocNetLogTools::FindLogEventByID($event_id);
             CSocNetLogRights::SetForSonet($logID, $entity_type, $entity_id, CSocNetLogTools::FindFeatureByEventID($event_id), $arLogEventTmp["OPERATION"]);
         } elseif (in_array($event_id, array("data", "system")) && $entity_type == SONET_SUBSCRIBE_ENTITY_GROUP) {
             CSocNetLogRights::Add($logID, array("SA", "S" . SONET_SUBSCRIBE_ENTITY_GROUP . $entity_id, "S" . SONET_SUBSCRIBE_ENTITY_GROUP . $entity_id . "_" . SONET_ROLES_OWNER, "S" . SONET_SUBSCRIBE_ENTITY_GROUP . $entity_id . "_" . SONET_ROLES_MODERATOR, "S" . SONET_SUBSCRIBE_ENTITY_GROUP . $entity_id . "_" . SONET_ROLES_USER));
         } elseif (in_array($event_id, array("data", "system")) && $entity_type == SONET_SUBSCRIBE_ENTITY_USER) {
             $perm = CSocNetUserPerms::GetOperationPerms($entity_id, "viewprofile");
             if (in_array($perm, array(SONET_RELATIONS_TYPE_FRIENDS2, SONET_RELATIONS_TYPE_FRIENDS))) {
                 CSocNetLogRights::Add($logID, array("SA", "U" . $entity_id, "S" . SONET_SUBSCRIBE_ENTITY_USER . $entity_id . "_" . $perm));
             } elseif ($perm == SONET_RELATIONS_TYPE_AUTHORIZED) {
                 CSocNetLogRights::Add($logID, array("SA", "AU"));
             } elseif ($perm == SONET_RELATIONS_TYPE_ALL) {
                 CSocNetLogRights::Add($logID, array("SA", "G2"));
             }
         }
     } elseif ($entity_type == SONET_SUBSCRIBE_ENTITY_PROVIDER) {
         $arRights = array("SA");
         $rsSchemeRights = CXDILFSchemeRights::GetList(array(), array("SCHEME_ID" => $entity_id));
         while ($arSchemeRights = $rsSchemeRights->Fetch()) {
             if (substr($arSchemeRights["GROUP_CODE"], 0, 1) == "U") {
                 if (substr($arSchemeRights["GROUP_CODE"], 1) == "A") {
                     $arRights[] = "AU";
                     break;
                 } elseif (substr($arSchemeRights["GROUP_CODE"], 1) == "N") {
                     $arRights[] = "G2";
                     break;
                 } elseif (intval(substr($arSchemeRights["GROUP_CODE"], 1)) > 0) {
                     $arRights[] = "U" . substr($arSchemeRights["GROUP_CODE"], 1);
                 }
             }
         }
         if (count($arRights) > 0) {
             CSocNetLogRights::Add($logID, $arRights);
         }
     } elseif (defined("SONET_SUBSCRIBE_ENTITY_NEWS") && $entity_type == SONET_SUBSCRIBE_ENTITY_NEWS) {
         CSocNetLogRights::Add($logID, array("SA", "G2"));
     }
 }
Exemple #7
0
 protected function initSonetUserPerms($arUserID)
 {
     if (!is_array($arUserID)) {
         $arUserID = array(intval($arUserID));
     }
     CSocNetUserPerms::GetOperationPerms($arUserID, "viewprofile");
 }