当前位置: 首页>>代码示例>>PHP>>正文


PHP CSocNetUserRelations::GetByUserID方法代码示例

本文整理汇总了PHP中CSocNetUserRelations::GetByUserID方法的典型用法代码示例。如果您正苦于以下问题:PHP CSocNetUserRelations::GetByUserID方法的具体用法?PHP CSocNetUserRelations::GetByUserID怎么用?PHP CSocNetUserRelations::GetByUserID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CSocNetUserRelations的用法示例。


在下文中一共展示了CSocNetUserRelations::GetByUserID方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: DeleteRelation

	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"].")
//.........这里部分代码省略.........
开发者ID:ASDAFF,项目名称:bitrix-5,代码行数:101,代码来源:user_relations.php

示例2: DeleteRelation

 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"])) {
         if (CModule::IncludeModule("im")) {
             $rsUser = CUser::GetByID($senderUserID);
             if ($arUser = $rsUser->Fetch()) {
                 switch ($arUser["PERSONAL_GENDER"]) {
                     case "M":
                         $gender_suffix = "_M";
                         break;
                     case "F":
                         $gender_suffix = "_F";
                         break;
                     default:
                         $gender_suffix = "";
                 }
             }
             $arMessageFields = array("MESSAGE_TYPE" => IM_MESSAGE_SYSTEM, "FROM_USER_ID" => $senderUserID, "TO_USER_ID" => $targetUserID, "NOTIFY_TYPE" => IM_NOTIFY_FROM, "NOTIFY_MODULE" => "socialnetwork", "NOTIFY_EVENT" => "inout_user", "NOTIFY_TAG" => "SOCNET|FRIENDS|" . intval($arRelation["ID"]), "NOTIFY_MESSAGE" => GetMessage("SONET_UR_IM_UNFRIEND" . $gender_suffix));
             CIMNotify::Add($arMessageFields);
         }
         if ($arRelation["RELATION"] == SONET_RELATIONS_FRIEND) {
             $GLOBALS["DB"]->Query("DELETE FROM b_sonet_event_user_view WHERE\n\t\t\t\t\tENTITY_TYPE = '" . SONET_ENTITY_USER . "'\n\t\t\t\t\tAND (\n\t\t\t\t\t\t(USER_ID = " . $arRelation["FIRST_USER_ID"] . " AND ENTITY_ID = " . $arRelation["SECOND_USER_ID"] . ")\n\t\t\t\t\t\tOR (USER_ID = " . $arRelation["SECOND_USER_ID"] . " AND ENTITY_ID = " . $arRelation["FIRST_USER_ID"] . ")\n\t\t\t\t\t\tOR (ENTITY_ID = " . $arRelation["FIRST_USER_ID"] . " AND USER_IM_ID = " . $arRelation["SECOND_USER_ID"] . ")\n\t\t\t\t\t\tOR (ENTITY_ID = " . $arRelation["SECOND_USER_ID"] . " AND USER_IM_ID = " . $arRelation["FIRST_USER_ID"] . ")\n\t\t\t\t\t\tOR (USER_ID = " . $arRelation["FIRST_USER_ID"] . " AND USER_IM_ID = " . $arRelation["SECOND_USER_ID"] . ")\n\t\t\t\t\t\tOR (USER_ID = " . $arRelation["SECOND_USER_ID"] . " AND USER_IM_ID = " . $arRelation["FIRST_USER_ID"] . ")\n\t\t\t\t\t)", 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;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:53,代码来源:user_relations.php


注:本文中的CSocNetUserRelations::GetByUserID方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。