-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathfetchSinglePost.php
More file actions
147 lines (120 loc) · 5.09 KB
/
fetchSinglePost.php
File metadata and controls
147 lines (120 loc) · 5.09 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<?php
session_start();
include_once('header.php');
include_once('topbar.php');
require_once 'QOB/qobConfig.php';
if(!isset($_GET['ref']))
{
echo '<script>alert("Invalid url. Redirecting to home page..");window.location.href="http://localhost/4pi";</script>';
}
else
{
echo '<script>var postIdHash="'.$_GET['ref'].'";</script>';
}
?>
<script>
function fetchSinglePost()
{
$.post('/4pi/handlers/fetchSinglePost.php',{
_postId:postIdHash
})
.error(function(){
alert("Server overload. Please try again.:(");
})
.success(function(data){
console.log(data);
if(checkData(data)==1)
{
if(data==404)
{
alert("The post does not exist.");
}
else if(data==505)
{
alert("The post is not shared with you.");
}
else
{
console.log(data);
data=JSON.parse(data);
postInsert("first",data);
for(i=0;i<data.comments.length;i++)
{
commentInsert('first', data.comments[i], data.postId);
}
callAfterAjax();
}
}
});
}
$(document).ready(function(){
fetchSinglePost();
});
var userIdHash="<?php echo $_SESSION['vj'];?>";
</script>
<body style="padding:0px;" >
<div id="wrap" >
<div class="row">
<!-- left column code starts here -->
<?php
//echo $_SESSION['vj'];
include_once('leftBlock.php'); ?>
<!-- left column code ends here -->
<?php include_once('singlePostBlock.php'); ?>
<!-- BLOCK in the right code starts here -->
<?php include_once('rightBlock.php');?>
<!-- right block code ends here -->
</div>
<?php
include_once("footer.php");
?>
<!-- edit post modal -->
<div class="modal fade" id="editPostModal" tabindex="-1" role="dialog" aria-labelledby="editPostModal" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
<h4 class="modal-title" id="editPost"><i class="fa fa-pencil"></i> Edit Post [<i class="fa fa-question popOver" data-trigger="hover click" data-toggle="popover" data-content="Maximum size of the post can be 3MB. Post content can contain upto 8000 characters."></i>]</h4>
</div>
<div id="editPostId" class="hidden"></div>
<div class="modal-body">
<form role="form">
<div class="form-group">
<label for="postSubject">Subject</label> [<i class="fa fa-question popOver" data-trigger="hover click" data-toggle="popover" data-content="Post Subject is useful when you search for posts. It is not mandatory."></i>]
<input type="email" name="postSubject" class="form-control input-sm" style="background-color:white !important;border-radius:0px;" id="editPostSubject" placeholder="Subject">
</div>
<div class="form-group">
<label for="postContent">Content</label> [<i class="fa fa-question popOver" data-trigger="hover click" data-toggle="popover" data-content="Post Content is compulsory"></i>]
<textarea type="text" name="postContent" id="editPostContent" style="background-color:white;border-radius:0px;resize:none;" class="form-control" id="exampleInputPassword1"></textarea>
</div>
<!-- <div class="form-group">
<label for="fileInput">Attach Image </label> [<i class="fa fa-question popOver" data-trigger="hover click" data-toggle="popover" data-content="Allowed Extensions are .jpg, .png."></i>]
<input name="fileInput" type="file" id="fileInput">
</div> -->
<div class="form-group">
<label for="shareWith">Share with</label> [<i class="fa fa-question popOver" data-trigger="hover click" data-toggle="popover" data-content="Leaving it blank makes the post visible to everyone. Examples would be like COE12, B.Tech12, etc. You can share the post with multiple groups by separating the groups with commas."></i>]
<input name="editPostSharedWith" class="form-control"type="text" id="editPostSharedWith">
</div>
<div class="form-group">
<label for="editPostValidity">Post Validity</label> [<i class="fa fa-question popOver" data-trigger="hover click" data-toggle="popover" data-content="A post lives only for a fixed time. You can also REQUEST for a lifetime validity. "></i>]
<!-- <input name="postLivingTime" class="form-control" type="text" id="postLivingTime"> -->
<!-- <input name="postLivingTime" class="form-control" type="text" id="postLivingTime"> -->
<select class="form-control" id="editPostLivingTime" name="editPostLivingTime" >
<option value="1">1 day</option>
<option value="7">1 week</option>
<option value="15">15 days</option>
<option value="30">1 month</option>
<option value="90">3 months</option>
<option value="180">6 months</option>
<option value="365">1 year</option>
<option value="9999">Request Lifetime</option>
</select>
</div>
<input class="hidden" id="postId" name="postId">
</form>
<button onclick="editedPostSend();" class="btn btn-primary">Post</button>
</div>
</div>
</div>
</div>
<!-- edit create post modal -->