Merge branch 'kevin-prototype' into 'master'
POSTS ON GROUP PAGES See merge request !151
This commit was merged in pull request #155.
This commit is contained in:
@@ -1,13 +1,17 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
if(empty($_POST["usr"])) {
|
if(empty($_POST["usr"]) and empty($_POST["grp"])) {
|
||||||
header('HTTP/1.1 500 Non enough arguments');
|
header('HTTP/1.1 500 Non enough arguments');
|
||||||
}
|
}
|
||||||
|
|
||||||
require_once ("../../queries/user.php");
|
require_once ("../../queries/post.php");
|
||||||
require_once ("../../queries/nicetime.php");
|
require_once ("../../queries/nicetime.php");
|
||||||
|
|
||||||
$posts = selectAllUserPosts($_POST["usr"]);
|
if(empty($_POST["usr"])) {
|
||||||
|
$posts = selectAllPosts(0, $_POST["grp"]);
|
||||||
|
} else {
|
||||||
|
$posts = selectAllPosts($_POST["usr"], 0);
|
||||||
|
}
|
||||||
|
|
||||||
if(!$posts) {
|
if(!$posts) {
|
||||||
header('HTTP/1.1 500 Query failed');
|
header('HTTP/1.1 500 Query failed');
|
||||||
@@ -19,6 +23,4 @@ for($i = 0; $i < sizeof($results); $i++) {
|
|||||||
$results[$i]["nicetime"] = nicetime($results[$i]["creationdate"]);
|
$results[$i]["nicetime"] = nicetime($results[$i]["creationdate"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
//$results[0]["niceTime"] = nicetime($results[0]["creationdate"]);
|
|
||||||
|
|
||||||
echo json_encode($results);
|
echo json_encode($results);
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
require("../../queries/post.php");
|
require("../../queries/post.php");
|
||||||
require("../../queries/connect.php");
|
require_once("../../queries/connect.php");
|
||||||
require("../../queries/checkInput.php");
|
require("../../queries/checkInput.php");
|
||||||
print_r($_POST);
|
print_r($_POST);
|
||||||
if ($_POST['button'] == 'reaction') {
|
if ($_POST['button'] == 'reaction') {
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
<?php include("../views/head.php"); ?>
|
<?php include("../views/head.php"); ?>
|
||||||
<style>
|
<style>
|
||||||
@import url("styles/profile.css");
|
@import url("styles/profile.css");
|
||||||
|
@import url("styles/post-popup.css");
|
||||||
|
@import url('https://fonts.googleapis.com/css?family=Anton');
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@@ -30,6 +32,20 @@ include("../views/group.php");
|
|||||||
|
|
||||||
/* This adds the footer. */
|
/* This adds the footer. */
|
||||||
include("../views/footer.php");
|
include("../views/footer.php");
|
||||||
|
|
||||||
|
$masonry_mode = 0;
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
<script src="js/masonry.js"></script>
|
||||||
|
<script src="js/post.js"></script>
|
||||||
|
<script>
|
||||||
|
$(document).ready(function() {
|
||||||
|
userID = 0;
|
||||||
|
groupID = <?= $group["groupID"] ?>;
|
||||||
|
|
||||||
|
masonry(<?= $masonry_mode ?>);
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ function masonry(mode) {
|
|||||||
/*
|
/*
|
||||||
* Get the posts from the server.
|
* Get the posts from the server.
|
||||||
*/
|
*/
|
||||||
$.post("API/getPosts.php", { usr : userID })
|
$.post("API/getPosts.php", { usr : userID, grp : groupID })
|
||||||
.done(function(data) {
|
.done(function(data) {
|
||||||
posts = JSON.parse(data);
|
posts = JSON.parse(data);
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,9 @@ function postComment(buttonValue) {
|
|||||||
$.post(
|
$.post(
|
||||||
"API/postComment.php",
|
"API/postComment.php",
|
||||||
formData
|
formData
|
||||||
);
|
).done(function(data) {
|
||||||
|
console.log(data);
|
||||||
|
});
|
||||||
|
|
||||||
$("#newcomment").val("");
|
$("#newcomment").val("");
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ if(empty($_GET["username"])) {
|
|||||||
$user = selectUser($_SESSION["userID"], $userID);
|
$user = selectUser($_SESSION["userID"], $userID);
|
||||||
$profile_friends = selectAllFriends($userID);
|
$profile_friends = selectAllFriends($userID);
|
||||||
$profile_groups = selectAllUserGroups($userID);
|
$profile_groups = selectAllUserGroups($userID);
|
||||||
$posts = selectAllUserPosts($userID);
|
|
||||||
|
|
||||||
|
|
||||||
if ($userID == $_SESSION["userID"]) {
|
if ($userID == $_SESSION["userID"]) {
|
||||||
@@ -54,23 +53,12 @@ include("../views/footer.php");
|
|||||||
<script src="js/friendButtons.js"></script>
|
<script src="js/friendButtons.js"></script>
|
||||||
<script src="js/masonry.js"></script>
|
<script src="js/masonry.js"></script>
|
||||||
<script>
|
<script>
|
||||||
var posts;
|
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
userID = <?= $userID ?>;
|
userID = <?= $userID ?>;
|
||||||
|
groupID = 0;
|
||||||
placeFriendButtons();
|
placeFriendButtons();
|
||||||
|
|
||||||
masonry(<?= $masonry_mode ?>);
|
masonry(<?= $masonry_mode ?>);
|
||||||
// alert("blap");
|
|
||||||
// $.post("API/getPosts.php", { usr : userID }, "json")
|
|
||||||
// .done(function(data) {
|
|
||||||
// posts = JSON.parse(data);
|
|
||||||
// alert(posts[0]["content"]);
|
|
||||||
// }).fail(function() {
|
|
||||||
// alert("failure...");
|
|
||||||
// });
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
require("connect.php");
|
require_once("connect.php");
|
||||||
|
|
||||||
function selectGroupByName($name) {
|
function selectGroupByName($name) {
|
||||||
$stmt = prepareQuery("
|
$stmt = prepareQuery("
|
||||||
SELECT
|
SELECT
|
||||||
|
`group_page`.`groupID`,
|
||||||
`group_page`.`groupID`,
|
`group_page`.`groupID`,
|
||||||
`name`,
|
`name`,
|
||||||
`description`,
|
`description`,
|
||||||
|
|||||||
@@ -1,5 +1,51 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
require_once("connect.php");
|
||||||
|
|
||||||
|
function selectAllPosts($userID, $groupID) {
|
||||||
|
$stmt = prepareQuery("
|
||||||
|
SELECT
|
||||||
|
`post`.`postID`,
|
||||||
|
`post`.`author`,
|
||||||
|
`title`,
|
||||||
|
CASE LENGTH(`post`.`content`) >= 150 AND `post`.`content` NOT LIKE '<img%'
|
||||||
|
WHEN TRUE THEN
|
||||||
|
CONCAT(LEFT(`post`.`content`, 150), '...')
|
||||||
|
WHEN FALSE THEN
|
||||||
|
`post`.`content`
|
||||||
|
END
|
||||||
|
AS `content`,
|
||||||
|
`post`.`creationdate`,
|
||||||
|
COUNT(DISTINCT `commentID`) AS `comments`,
|
||||||
|
COUNT(DISTINCT `niet_slecht`.`postID`) AS `niet_slechts`
|
||||||
|
FROM
|
||||||
|
`post`
|
||||||
|
LEFT JOIN
|
||||||
|
`niet_slecht`
|
||||||
|
ON
|
||||||
|
`post`.`postID` = `niet_slecht`.`postID`
|
||||||
|
LEFT JOIN
|
||||||
|
`comment`
|
||||||
|
ON
|
||||||
|
`post`.`postID` = `comment`.`postID`
|
||||||
|
WHERE
|
||||||
|
`post`.`author` = :userID AND
|
||||||
|
`groupID` IS NULL OR
|
||||||
|
`groupID` = :groupID
|
||||||
|
GROUP BY
|
||||||
|
`post`.`postID`
|
||||||
|
ORDER BY
|
||||||
|
`post`.`creationdate` DESC
|
||||||
|
");
|
||||||
|
$stmt->bindParam(':userID', $userID, PDO::PARAM_INT);
|
||||||
|
$stmt->bindParam(':groupID', $groupID , PDO::PARAM_INT);
|
||||||
|
if(!$stmt->execute()) {
|
||||||
|
return False;
|
||||||
|
}
|
||||||
|
return $stmt;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
function selectPostById($postID) {
|
function selectPostById($postID) {
|
||||||
$stmt = prepareQuery("
|
$stmt = prepareQuery("
|
||||||
SELECT
|
SELECT
|
||||||
|
|||||||
@@ -103,47 +103,47 @@ function selectAllUserGroups($userID) {
|
|||||||
return $stmt;
|
return $stmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectAllUserPosts($userID) {
|
//function selectAllUserPosts($userID) {
|
||||||
$stmt = prepareQuery("
|
// $stmt = prepareQuery("
|
||||||
SELECT
|
// SELECT
|
||||||
`post`.`postID`,
|
// `post`.`postID`,
|
||||||
`post`.`author`,
|
// `post`.`author`,
|
||||||
`title`,
|
// `title`,
|
||||||
CASE LENGTH(`post`.`content`) >= 150 AND `post`.`content` NOT LIKE '<img%'
|
// CASE LENGTH(`post`.`content`) >= 150 AND `post`.`content` NOT LIKE '<img%'
|
||||||
WHEN TRUE THEN
|
// WHEN TRUE THEN
|
||||||
CONCAT(LEFT(`post`.`content`, 150), '...')
|
// CONCAT(LEFT(`post`.`content`, 150), '...')
|
||||||
WHEN FALSE THEN
|
// WHEN FALSE THEN
|
||||||
`post`.`content`
|
// `post`.`content`
|
||||||
END
|
// END
|
||||||
AS `content`,
|
// AS `content`,
|
||||||
`post`.`creationdate`,
|
// `post`.`creationdate`,
|
||||||
COUNT(`commentID`) AS `comments`,
|
// COUNT(`commentID`) AS `comments`,
|
||||||
COUNT(`niet_slecht`.`postID`) AS `niet_slechts`
|
// COUNT(`niet_slecht`.`postID`) AS `niet_slechts`
|
||||||
FROM
|
// FROM
|
||||||
`post`
|
// `post`
|
||||||
LEFT JOIN
|
// LEFT JOIN
|
||||||
`niet_slecht`
|
// `niet_slecht`
|
||||||
ON
|
// ON
|
||||||
`post`.`postID` = `niet_slecht`.`postID`
|
// `post`.`postID` = `niet_slecht`.`postID`
|
||||||
LEFT JOIN
|
// LEFT JOIN
|
||||||
`comment`
|
// `comment`
|
||||||
ON
|
// ON
|
||||||
`post`.`postID` = `comment`.`postID`
|
// `post`.`postID` = `comment`.`postID`
|
||||||
WHERE
|
// WHERE
|
||||||
`post`.`author` = :userID AND
|
// `post`.`author` = :userID AND
|
||||||
`groupID` IS NULL
|
// `groupID` IS NULL
|
||||||
GROUP BY
|
// GROUP BY
|
||||||
`post`.`postID`
|
// `post`.`postID`
|
||||||
ORDER BY
|
// ORDER BY
|
||||||
`post`.`creationdate` DESC
|
// `post`.`creationdate` DESC
|
||||||
");
|
// ");
|
||||||
|
//
|
||||||
$stmt->bindParam(':userID', $userID, PDO::PARAM_INT);
|
// $stmt->bindParam(':userID', $userID, PDO::PARAM_INT);
|
||||||
if(!$stmt->execute()) {
|
// if(!$stmt->execute()) {
|
||||||
return False;
|
// return False;
|
||||||
}
|
// }
|
||||||
return $stmt;
|
// return $stmt;
|
||||||
}
|
//}
|
||||||
|
|
||||||
function select20UsersFromN($n) {
|
function select20UsersFromN($n) {
|
||||||
$q = prepareQuery("
|
$q = prepareQuery("
|
||||||
|
|||||||
@@ -13,88 +13,24 @@
|
|||||||
<p>
|
<p>
|
||||||
<?php
|
<?php
|
||||||
foreach($members as $member) {
|
foreach($members as $member) {
|
||||||
echo "<a href=\"profile.php?username=" . $member["username"] . "\" data-title=\"" . $member["username"] . "\"><img class=\"profile-picture\" src=\"" . $member["profilepicture"] . "\" alt=\"" . $member["username"] . "'s profielfoto\">";
|
echo "<a href=\"profile.php?username=" . $member["username"] . "\" data-title=\"" . $member["username"] . "\"><img class=\"profile-picture\" src=\"" . $member["profilepicture"] . "\" alt=\"" . $member["username"] . "'s profielfoto\"></a>";
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="posts">
|
<div class="posts">
|
||||||
<div class="post platform">
|
|
||||||
<h2>Lorem</h2>
|
|
||||||
<p>Lorem ipsum dolor sit amet, consectetur.</p>
|
|
||||||
<p class="subscript">Enkele minuten geleden geplaatst</p>
|
|
||||||
</div>
|
|
||||||
<div class="post platform">
|
|
||||||
<h2>Image</h2>
|
|
||||||
<img src="http://i.imgur.com/ypIQKjE.jpg" alt="Olympic Mountains, Washington">
|
|
||||||
<p class="subscript">Gisteren geplaatst</p>
|
|
||||||
</div>
|
|
||||||
<div class="post platform">
|
|
||||||
<h2>Ipsum</h2>
|
|
||||||
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Rem nihil alias amet dolores fuga totam sequi a cupiditate ipsa voluptas id facilis nobis.</p>
|
|
||||||
<p class="subscript">Maandag geplaatst</p>
|
|
||||||
</div>
|
|
||||||
<div class="post platform">
|
|
||||||
<h2>Dolor</h2>
|
|
||||||
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
|
|
||||||
<p class="subscript">4 Januari geplaatst</p>
|
|
||||||
</div>
|
|
||||||
<div class="post platform">
|
|
||||||
<h2>Sit</h2>
|
|
||||||
<p>Lorem ipsum dolor sit.</p>
|
|
||||||
<p class="subscript">4 Januari geplaatst</p>
|
|
||||||
</div>
|
|
||||||
<div class="post platform">
|
|
||||||
<h2>Image</h2>
|
|
||||||
<img src="https://i.redditmedia.com/EBWWiEojgkRrdn89R7qF7tBZjJszJaIqgkWUH23s11A.jpg?w=576&s=ba4fe1f02485cb2327305924ef869a66" alt="Nunobiki Falls, Kobe Japan">
|
|
||||||
<p class="subscript">4 Januari geplaatst</p>
|
|
||||||
</div>
|
|
||||||
<div class="post platform">
|
|
||||||
<h2>Amet</h2>
|
|
||||||
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Minima asperiores eveniet vero velit eligendi aliquid in.</p>
|
|
||||||
<p class="subscript">4 Januari geplaatst</p>
|
|
||||||
</div>
|
|
||||||
<div class="post platform">
|
|
||||||
<h2>Consectetur</h2>
|
|
||||||
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Error aliquid reprehenderit expedita odio beatae est.</p>
|
|
||||||
<p class="subscript">4 Januari geplaatst</p>
|
|
||||||
</div>
|
|
||||||
<div class="post platform">
|
|
||||||
<h2>Adipisicing</h2>
|
|
||||||
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quaerat architecto quis tenetur fugiat veniam iste molestiae fuga labore!</p>
|
|
||||||
<p class="subscript">4 Januari geplaatst</p>
|
|
||||||
</div>
|
|
||||||
<div class="post platform">
|
|
||||||
<h2>Elit</h2>
|
|
||||||
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Rem ut debitis dolorum earum expedita eveniet voluptatem quibusdam facere eos numquam commodi ad iusto laboriosam rerum aliquam.</p>
|
|
||||||
<p class="subscript">4 Januari geplaatst</p>
|
|
||||||
</div>
|
|
||||||
<div class="post platform">
|
|
||||||
<h2>Geen error</h2>
|
|
||||||
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Doloribus dolorem maxime minima animi cum.</p>
|
|
||||||
<p class="subscript">4 Januari geplaatst</p>
|
|
||||||
</div>
|
|
||||||
<div class="post platform">
|
|
||||||
<h2>Image</h2>
|
|
||||||
<img src="https://i.reddituploads.com/82c1c4dd0cfb4a4aa1cfa16f93f5dbfa?fit=max&h=1536&w=1536&s=dd629d407f3646ee6e3adb4da78c93f2" alt="Oregon cliffs are no joke.">
|
|
||||||
<p class="subscript">4 Januari geplaatst</p>
|
|
||||||
</div>
|
|
||||||
<div class="post platform">
|
|
||||||
<h2>Aliquid</h2>
|
|
||||||
<p>Lorem ipsum dolor sit amet, consectetur.</p>
|
|
||||||
<p class="subscript">4 Januari geplaatst</p>
|
|
||||||
</div>
|
|
||||||
<div class="post platform">
|
|
||||||
<h2>Odit</h2>
|
|
||||||
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Odit accusamus tempore at porro officia rerum est impedit ea ipsa tenetur. Labore libero hic error sunt laborum expedita.</p>
|
|
||||||
<p class="subscript">4 Januari geplaatst</p>
|
|
||||||
</div>
|
|
||||||
<div class="post platform">
|
|
||||||
<h2>Accusamus</h2>
|
|
||||||
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nobis quaerat suscipit ad.</p>
|
|
||||||
<p class="subscript">4 Januari geplaatst</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="modal">
|
||||||
|
<div class="modal-content platform">
|
||||||
|
<div class="modal-close">
|
||||||
|
×
|
||||||
|
</div>
|
||||||
|
<div class="modal-response" id="modal-response">
|
||||||
|
<span class="modal-default">Aan het laden...</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -38,7 +38,7 @@
|
|||||||
<p>
|
<p>
|
||||||
<?php
|
<?php
|
||||||
while($group = $profile_groups->fetch()) {
|
while($group = $profile_groups->fetch()) {
|
||||||
echo "<a href='/group/${group["name"]}/' data-title='${group["name"]}'><img class='group-picture' src='${group["picture"]}' alt='${group["name"]}s logo'></a>";
|
echo "<a href='group.php?groupname=${group['name']}' data-title='${group["name"]}'><img class='group-picture' src='${group["picture"]}' alt='${group["name"]}s logo'></a>";
|
||||||
}
|
}
|
||||||
|
|
||||||
if($profile_groups->rowCount() === 0) {
|
if($profile_groups->rowCount() === 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user