- Модуль: socialnetwork
- Путь к файлу: ~/bitrix/modules/socialnetwork/classes/general/user_relations.php
- Класс: CAllSocNetUserRelations
- Вызов: CAllSocNetUserRelations::UnBanMember
static 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 ($errorMessage == '')
$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;
}