-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrequestJoinGroup.php
42 lines (42 loc) · 1.26 KB
/
requestJoinGroup.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
require 'database.php';
require 'generalNotificationFuncs.php';
$gid = $_POST["gid"];
$uid = $_POST["uid"];
$oid = $_POST["oid"];
if (!empty($gid)) {
$db = new Database();
$stmt = $db->prepare("SELECT groupID FROM groupUserRel
WHERE userID = :uid AND groupID = :gid");
$stmt->bindValue(":uid", $uid, SQLITE3_INTEGER);
$stmt->bindValue(":gid", $gid, SQLITE3_INTEGER);
$tempRes = $stmt->execute();
$temp = $tempRes->fetchArray();
if (!$temp) {
$stmt = $db->prepare("SELECT notifications.notiID FROM notifications
INNER JOIN notiGroup USING(notiID)
INNER JOIN notiUser USING(notiID)
WHERE groupID = :gid AND secondUserID = :uid AND userID = :oid AND typeID=17");
$stmt->bindValue(":gid", $gid, SQLITE3_INTEGER);
$stmt->bindValue(":uid", $uid, SQLITE3_INTEGER);
$stmt->bindValue(":oid", $oid, SQLITE3_INTEGER);
$tempRes = $stmt->execute();
$temp = $tempRes->fetchArray();
if (!$temp) {
$stmt = $db->prepare("INSERT INTO notifications(userID, typeID) VALUES(:oid, 17)");
$stmt->bindValue(":oid", $oid, SQLITE3_INTEGER);
$stmt->execute();
$liid = $db->lastInsertRowID();
notiLumpGroup($db, $liid, $gid);
notiLumpUser($db, $liid, $uid);
echo 2;
} else {
echo 1;
}
} else {
echo 0;
}
exit();
}
?>
<?php require "wrongTurn.php"; ?>