Example #1
0
            if (!in_array($arRelation["FIRST_USER_ID"], $arFriendID) && !in_array($arRelation["SECOND_USER_ID"], $arFriendID)) {
                continue;
            }
            $arRelationID[] = $arRelation["ID"];
            $arRelationUserID[] = $arRelation[($user_id == $arRelation["FIRST_USER_ID"] ? "SECOND" : "FIRST") . "_USER_ID"];
        }
        if (count(array_diff($arFriendID, $arRelationUserID)) > 0) {
            echo CUtil::PhpToJsObject(array('ERROR' => 'FRIEND_ID_INCORRECT_2'));
            die;
        }
        if ($_POST['ACTION'] == "BAN") {
            foreach ($arRelationUserID as $relation_user_id) {
                if (!CSocNetUserRelations::BanUser($user_id, $relation_user_id)) {
                    echo CUtil::PhpToJsObject(array('ERROR' => 'USER_ACTION_FAILED: ' . (($e = $APPLICATION->GetException()) ? $e->GetString() : "")));
                    die;
                }
            }
        } else {
            foreach ($arRelationID as $relation_id) {
                if ($_POST['ACTION'] == "EX" && !CSocNetUserRelations::Delete($relation_id) || $_POST['ACTION'] == "UNBAN" && !CSocNetUserRelations::UnBanMember($user_id, $relation_id)) {
                    echo CUtil::PhpToJsObject(array('ERROR' => 'USER_ACTION_FAILED: ' . (($e = $APPLICATION->GetException()) ? $e->GetString() : "")));
                    die;
                }
            }
        }
    }
    echo CUtil::PhpToJsObject(array('SUCCESS' => 'Y'));
} else {
    echo CUtil::PhpToJsObject(array('ERROR' => 'SESSION_ERROR'));
}
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_after.php";
Example #2
0
	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;
	}
Example #3
0
                                 $errorMessage .= $e->GetString();
                             }
                             if (StrLen($errorMessage) <= 0) {
                                 $errorMessage .= GetMessage("SONET_GRE_CANT_DELETE_INVITATION", array("#RELATION_ID#" => $arRelation["ID"]));
                             }
                         }
                     }
                 }
                 if (count($arUserRelationIDs) > 0) {
                     $errorMessage = "";
                     foreach ($arUserRelationIDs as $relationID) {
                         $arRelation = CSocNetUserRelations::GetByID($relationID);
                         if (!$arRelation) {
                             continue;
                         }
                         if (!CSocNetUserRelations::Delete($arRelation["ID"])) {
                             if ($e = $APPLICATION->GetException()) {
                                 $errorMessage .= $e->GetString();
                             }
                             if (StrLen($errorMessage) <= 0) {
                                 $errorMessage .= GetMessage("SONET_GRE_CANT_DELETE_INVITATION", array("#RELATION_ID#" => $arRelation["ID"]));
                             }
                         }
                     }
                 }
             }
         }
     }
 }
 //Handling confirmation with e-mail links
 if ($_SERVER["REQUEST_METHOD"] == "GET" && isset($_GET["CONFIRM"])) {