-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpromoteUser.php
42 lines (37 loc) · 1.25 KB
/
promoteUser.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"];
$name = $_POST["name"];
if (!empty($gid)) {
$db = new Database();
$stmt = $db->prepare("UPDATE groupUserRel SET owner = 1
WHERE userID = :uid AND groupID = :gid");
$stmt->bindValue(":gid", $gid, SQLITE3_INTEGER);
$stmt->bindValue(":uid", $uid, SQLITE3_INTEGER);
$stmt->execute();
$stmt = $db->prepare("UPDATE groupUserRel SET owner = 0
WHERE userID = :oid AND groupID = :gid");
$stmt->bindValue(":gid", $gid, SQLITE3_INTEGER);
$stmt->bindValue(":oid", $oid, SQLITE3_INTEGER);
$stmt->execute();
//Now notify the whole groupID
$stmt = $db->prepare("SELECT userID FROM groupUserRel WHERE groupID = :gid");
$stmt->bindValue(":gid", $gid, SQLITE3_INTEGER);
$result = $stmt->execute();
while ($user = $result->fetchArray()) {
$stmt = $db->prepare("INSERT INTO notifications(userID, typeID, custmsg) VALUES(:uid, 21, :name)");
$stmt->bindValue(":uid", $user[0], SQLITE3_INTEGER);
$stmt->bindValue(":name", $name, SQLITE3_TEXT);
$stmt->execute();
$liid = $db->lastInsertRowID();
notiLumpGroup($db, $liid, $gid);
notiLumpUser($db, $liid, $uid);
}
echo 'Good';
exit();
}
?>
<?php include "wrongTurn.php";?>