-
Notifications
You must be signed in to change notification settings - Fork 0
/
rejectgroupinvite.php
44 lines (32 loc) · 1.78 KB
/
rejectgroupinvite.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
43
44
<?php
session_start();
include 'dbh.php';
include_once 'functions.php';
$groupId=mysqli_real_escape_string($conn,$_POST['groupId']);
$inviteId=mysqli_real_escape_string($conn,$_POST['inviteId']);
/*$sql="UPDATE group_participants_table SET invitationStatus=2 WHERE id='$inviteId'";
$result=mysqli_query($conn,$sql);*/
$sql="DELETE FROM group_participants_table WHERE id='$inviteId'";
$result=mysqli_query($conn,$sql);
$sql1="UPDATE groups_table SET numberOfPendingInvitations=numberOfPendingInvitations-1 WHERE id='$groupId'";
$result1=mysqli_query($conn,$sql1);
//notification(for the invite sender)
date_default_timezone_set('Asia/Kolkata');//setting the timezone
$datetime=date('Y-m-d H:i:s');
$sql01="SELECT inviterId,participantId,groupname FROM group_participants_table WHERE id='$inviteId'";
$result01=mysqli_query($conn,$sql01);
$row01=mysqli_fetch_assoc($result01);
$inviterId=$row01['inviterId'];
$participantId=$row01['participantId'];
$groupname=$row01['groupname'];
$sql02="SELECT username FROM memberstable WHERE id='$participantId'";
$result02=mysqli_query($conn,$sql02);
$row02=mysqli_fetch_assoc($result02);
$participantUsername=$row02['username'];
//echo '$participantUsername='.$participantUsername;
$notificationString=htmlentities($participantUsername).' rejected your invitation to the group "<i>'.$groupname.'</i>".';
$notificationLink='groupspage.php?id='.$groupId;
$notificationType="acceptGroupInvite";
$sql4="INSERT INTO notifications_table (senderId,receiverId,notificationType,notification,notificationLink,viewingStatus,datetime,notificationForEventId) VALUES ('$participantId','$inviterId','$notificationType','$notificationString','$notificationLink',0,'$datetime','$groupId')";
$result4=mysqli_query($conn,$sql4);
echo "success";