Changed friendship buttons. We now use AJAX, changed button style and added FA icons.
This commit is contained in:
28
website/public/API/editFriendship.php
Normal file
28
website/public/API/editFriendship.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
|
||||
require_once ("../../queries/connect.php");
|
||||
require_once ("../../queries/friendship.php");
|
||||
|
||||
if(empty($_POST["usr"]) OR empty($_POST["action"]) OR !in_array($_POST["action"], array("request", "accept", "delete"))) {
|
||||
header('HTTP/1.1 500 Non enough arguments');
|
||||
}
|
||||
|
||||
$friendship_status = getFriendshipStatus($_POST["usr"]);
|
||||
|
||||
if($_POST["action"] == "request" AND $friendship_status == 0) {
|
||||
if (!requestFriendship($_POST["usr"])) {
|
||||
header('HTTP/1.1 500 Query (request) failed');
|
||||
}
|
||||
} else if($_POST["action"] == "delete" AND in_array($friendship_status, array(1, 2, 3))) {
|
||||
if (!removeFriendship($_POST["usr"])) {
|
||||
header('HTTP/1.1 500 Query (delete) failed');
|
||||
}
|
||||
} else if ($_POST["action"] == "accept" AND $friendship_status == 3) {
|
||||
if (!acceptFriendship($_POST["usr"])) {
|
||||
header('HTTP/1.1 500 Query (accept) failed');
|
||||
}
|
||||
} else {
|
||||
header('HTTP/1.1 500 Not the right friendship status');
|
||||
}
|
||||
18
website/public/API/getFriendshipStatus.php
Normal file
18
website/public/API/getFriendshipStatus.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
|
||||
require_once ("../../queries/connect.php");
|
||||
require_once ("../../queries/friendship.php");
|
||||
|
||||
if(empty($_POST["usr"])) {
|
||||
header('HTTP/1.1 500 Non enough arguments');
|
||||
}
|
||||
|
||||
$friendship_status = getFriendshipStatus($_POST["usr"]);
|
||||
|
||||
if($friendship_status == -2) {
|
||||
header('HTTP/1.1 500 Query failed');
|
||||
}
|
||||
|
||||
echo $friendship_status;
|
||||
Reference in New Issue
Block a user