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
|
||||
|
||||
if(empty($_POST["usr"])) {
|
||||
if(empty($_POST["usr"]) and empty($_POST["grp"])) {
|
||||
header('HTTP/1.1 500 Non enough arguments');
|
||||
}
|
||||
|
||||
require_once ("../../queries/user.php");
|
||||
require_once ("../../queries/post.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) {
|
||||
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[0]["niceTime"] = nicetime($results[0]["creationdate"]);
|
||||
|
||||
echo json_encode($results);
|
||||
@@ -3,7 +3,7 @@
|
||||
session_start();
|
||||
|
||||
require("../../queries/post.php");
|
||||
require("../../queries/connect.php");
|
||||
require_once("../../queries/connect.php");
|
||||
require("../../queries/checkInput.php");
|
||||
print_r($_POST);
|
||||
if ($_POST['button'] == 'reaction') {
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
<?php include("../views/head.php"); ?>
|
||||
<style>
|
||||
@import url("styles/profile.css");
|
||||
@import url("styles/post-popup.css");
|
||||
@import url('https://fonts.googleapis.com/css?family=Anton');
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
@@ -30,6 +32,20 @@ include("../views/group.php");
|
||||
|
||||
/* This adds the footer. */
|
||||
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>
|
||||
</html>
|
||||
|
||||
@@ -90,7 +90,7 @@ function masonry(mode) {
|
||||
/*
|
||||
* Get the posts from the server.
|
||||
*/
|
||||
$.post("API/getPosts.php", { usr : userID })
|
||||
$.post("API/getPosts.php", { usr : userID, grp : groupID })
|
||||
.done(function(data) {
|
||||
posts = JSON.parse(data);
|
||||
|
||||
|
||||
@@ -4,7 +4,9 @@ function postComment(buttonValue) {
|
||||
$.post(
|
||||
"API/postComment.php",
|
||||
formData
|
||||
);
|
||||
).done(function(data) {
|
||||
console.log(data);
|
||||
});
|
||||
|
||||
$("#newcomment").val("");
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@ if(empty($_GET["username"])) {
|
||||
$user = selectUser($_SESSION["userID"], $userID);
|
||||
$profile_friends = selectAllFriends($userID);
|
||||
$profile_groups = selectAllUserGroups($userID);
|
||||
$posts = selectAllUserPosts($userID);
|
||||
|
||||
|
||||
if ($userID == $_SESSION["userID"]) {
|
||||
@@ -54,23 +53,12 @@ include("../views/footer.php");
|
||||
<script src="js/friendButtons.js"></script>
|
||||
<script src="js/masonry.js"></script>
|
||||
<script>
|
||||
var posts;
|
||||
|
||||
$(document).ready(function() {
|
||||
userID = <?= $userID ?>;
|
||||
groupID = 0;
|
||||
placeFriendButtons();
|
||||
|
||||
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>
|
||||
</body>
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
<?php
|
||||
|
||||
require("connect.php");
|
||||
require_once("connect.php");
|
||||
|
||||
function selectGroupByName($name) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
`group_page`.`groupID`,
|
||||
`group_page`.`groupID`,
|
||||
`name`,
|
||||
`description`,
|
||||
|
||||
@@ -1,5 +1,51 @@
|
||||
<?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) {
|
||||
$stmt = prepareQuery("
|
||||
SELECT
|
||||
|
||||
@@ -103,47 +103,47 @@ function selectAllUserGroups($userID) {
|
||||
return $stmt;
|
||||
}
|
||||
|
||||
function selectAllUserPosts($userID) {
|
||||
$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(`commentID`) AS `comments`,
|
||||
COUNT(`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
|
||||
GROUP BY
|
||||
`post`.`postID`
|
||||
ORDER BY
|
||||
`post`.`creationdate` DESC
|
||||
");
|
||||
|
||||
$stmt->bindParam(':userID', $userID, PDO::PARAM_INT);
|
||||
if(!$stmt->execute()) {
|
||||
return False;
|
||||
}
|
||||
return $stmt;
|
||||
}
|
||||
//function selectAllUserPosts($userID) {
|
||||
// $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(`commentID`) AS `comments`,
|
||||
// COUNT(`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
|
||||
// GROUP BY
|
||||
// `post`.`postID`
|
||||
// ORDER BY
|
||||
// `post`.`creationdate` DESC
|
||||
// ");
|
||||
//
|
||||
// $stmt->bindParam(':userID', $userID, PDO::PARAM_INT);
|
||||
// if(!$stmt->execute()) {
|
||||
// return False;
|
||||
// }
|
||||
// return $stmt;
|
||||
//}
|
||||
|
||||
function select20UsersFromN($n) {
|
||||
$q = prepareQuery("
|
||||
|
||||
@@ -13,88 +13,24 @@
|
||||
<p>
|
||||
<?php
|
||||
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>
|
||||
</div>
|
||||
|
||||
<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>
|
||||
@@ -38,7 +38,7 @@
|
||||
<p>
|
||||
<?php
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user