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


PHP CSocNetUserRelations::GetByID方法代码示例

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


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

示例1: Update

 function Update($ID, $arFields)
 {
     global $DB;
     if (!CSocNetGroup::__ValidateID($ID)) {
         return false;
     }
     $ID = IntVal($ID);
     $arFields1 = array();
     foreach ($arFields as $key => $value) {
         if (substr($key, 0, 1) == "=") {
             $arFields1[substr($key, 1)] = $value;
             unset($arFields[$key]);
         }
     }
     if (!CSocNetUserRelations::CheckFields("UPDATE", $arFields, $ID)) {
         return false;
     }
     $db_events = GetModuleEvents("socialnetwork", "OnBeforeSocNetUserRelationsUpdate");
     while ($arEvent = $db_events->Fetch()) {
         if (ExecuteModuleEventEx($arEvent, array($ID, $arFields)) === false) {
             return false;
         }
     }
     $arUserRelationOld = CSocNetUserRelations::GetByID($ID);
     $strUpdate = $DB->PrepareUpdate("b_sonet_user_relations", $arFields);
     foreach ($arFields1 as $key => $value) {
         if (strlen($strUpdate) > 0) {
             $strUpdate .= ", ";
         }
         $strUpdate .= $key . "=" . $value . " ";
     }
     if (strlen($strUpdate) > 0) {
         $strSql = "UPDATE b_sonet_user_relations SET " . "\t" . $strUpdate . " " . "WHERE ID = " . $ID . " ";
         $DB->Query($strSql, False, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         $events = GetModuleEvents("socialnetwork", "OnSocNetUserRelationsUpdate");
         while ($arEvent = $events->Fetch()) {
             ExecuteModuleEventEx($arEvent, array($ID, $arFields));
         }
         if ((!array_key_exists("SEND_MAIL", $arFields) || $arFields["SEND_MAIL"] != "N") && !IsModuleInstalled("im")) {
             $mailType = "";
             if ($arUserRelationOld["RELATION"] != SONET_RELATIONS_FRIEND && $arFields["RELATION"] == SONET_RELATIONS_FRIEND) {
                 $mailType = "AGREE_FRIEND";
             } elseif ($arUserRelationOld["RELATION"] != SONET_RELATIONS_BAN && $arFields["RELATION"] == SONET_RELATIONS_BAN) {
                 $mailType = "BAN_FRIEND";
             } elseif ($arUserRelationOld["RELATION"] != SONET_RELATIONS_REQUEST && $arFields["RELATION"] == SONET_RELATIONS_REQUEST) {
                 $mailType = "INVITE_FRIEND";
             }
             if (StrLen($mailType) > 0) {
                 CSocNetUserRelations::SendEvent($ID, $mailType);
             }
         }
         CSocNetSearch::OnUserRelationsChange($arUserRelationOld["FIRST_USER_ID"]);
         CSocNetSearch::OnUserRelationsChange($arUserRelationOld["SECOND_USER_ID"]);
     } else {
         $ID = False;
     }
     return $ID;
 }
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:58,代码来源:user_relations.php

示例2: getRelatedUser

 function getRelatedUser($firstUserID, $relationID)
 {
     $arRel = CSocNetUserRelations::GetByID($relationID);
     if ($arRel) {
         $secondUserID = $firstUserID == $arRel["FIRST_USER_ID"] ? $arRel["SECOND_USER_ID"] : $arRel["FIRST_USER_ID"];
         $dbUser = CUser::GetByID($secondUserID);
         if ($arUser = $dbUser->Fetch()) {
             return CUser::FormatName(CSite::GetNameFormat(false), $arUser, true);
         } else {
             return false;
         }
     } else {
         false;
     }
 }
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:15,代码来源:component.php

示例3: UnBanMember

	function UnBanMember($senderUserID, $relationID)
	{
		global $APPLICATION, $DB;

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

		$relationID = IntVal($relationID);
		if ($relationID <= 0)
		{
			$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_UR_EMPTY_RELATION"), "ERROR_RELATIONID");
			return false;
		}

		$arRelation = CSocNetUserRelations::GetByID($relationID);
		if (!$arRelation)
		{
			$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_UR_ERROR_NO_RELATION"), "ERROR_NO_RELATION");
			return false;
		}

		if ($arRelation["RELATION"] == SONET_RELATIONS_BAN
			&&
			($arRelation["FIRST_USER_ID"] == $senderUserID && $arRelation["INITIATED_BY"] == "F"
			|| $arRelation["SECOND_USER_ID"] == $senderUserID && $arRelation["INITIATED_BY"] == "S"))
		{
			if (CSocNetUserRelations::Delete($arRelation["ID"]))
			{
				$arMessageFields = array(
					"FROM_USER_ID" => $senderUserID,
					"TO_USER_ID" => ($arRelation["FIRST_USER_ID"] == $senderUserID ? $arRelation["SECOND_USER_ID"] : $arRelation["FIRST_USER_ID"]),
					"MESSAGE" => GetMessage("SONET_UR_UNBANUSER_MESSAGE"),
					"=DATE_CREATE" => $GLOBALS["DB"]->CurrentTimeFunction(),
					"MESSAGE_TYPE" => SONET_MESSAGE_SYSTEM
				);
				CSocNetMessages::Add($arMessageFields);
			}
			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;
			}
		}
		else
		{
			$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_UR_UNBAN_ERROR"), "ERROR_UNBAN");
			return false;
		}

		return true;
	}
开发者ID:ASDAFF,项目名称:bitrix-5,代码行数:61,代码来源:user_relations.php


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