" . $post['content'] . "
+diff --git a/website/public/API/loadPost.php b/website/public/API/loadPost.php new file mode 100644 index 0000000..f73fe42 --- /dev/null +++ b/website/public/API/loadPost.php @@ -0,0 +1,12 @@ +').append(columns[i][1]); console.log(column); container.append(column); - } $("div.posts div.column").width(100/columnCount + "%"); + + $(".modal-close").click(function () { + $(".modal").hide(); + scrollbarMargin(0, 'auto'); + $('#modal-response').hide(); + $('.modal-default').show(); + }); } \ No newline at end of file diff --git a/website/public/js/profile.js b/website/public/js/profile.js new file mode 100644 index 0000000..2a47dce --- /dev/null +++ b/website/public/js/profile.js @@ -0,0 +1,8 @@ +function loadPost(postID) { + $.get( + "API/loadPost.php", + $(postID).serialize() + ).done(function (data) { + $('#modal-response').innerHTML= JSON.parse(data); + }); +} \ No newline at end of file diff --git a/website/public/profile.php b/website/public/profile.php index 6e188c4..c0fa0fc 100644 --- a/website/public/profile.php +++ b/website/public/profile.php @@ -2,9 +2,11 @@
- + + @@ -12,6 +14,7 @@ include("../queries/user.php"); include("../queries/friendship.php"); include("../queries/nicetime.php"); +include("../queries/post.php"); if(empty($_GET["username"])) { $userID = $_SESSION["userID"]; diff --git a/website/public/styles/post-popup.css b/website/public/styles/post-popup.css new file mode 100644 index 0000000..11fe03b --- /dev/null +++ b/website/public/styles/post-popup.css @@ -0,0 +1,72 @@ +/* modal based on: http://www.w3schools.com/howto/howto_css_modals.asp */ + +.modal { + display: none; + position: fixed; + top: 80px; + left: 256px; + width: calc(100% - 256px); /* Full width */ + height: calc(100% - 80px); /* Full height */ + background-color: rgb(0,0,0); /* Fallback color */ + background-color: rgba(0,0,0,0.4); /* Black w/ opacity */ + overflow-y: auto; +} + +/* Modal Content/Box */ +.modal-content { + margin: 5% auto; + width: 70%; /* Could be more or less, depending on screen size */ + overflow-y: auto; +} + +.modal-close { + color: #aaa; + float: right; + font-size: 28px; + font-weight: bold; + margin: auto; +} + +.modal-close:hover, +.modal-close:focus { + color: black; + text-decoration: none; + cursor: pointer; +} + +.modal-content img { + max-height: 100%; + max-width: 100%; +} + +.post-header h4 { + font-size: 20pt; +} + +.post-content { + margin: 30px auto; + width: 90%; +} + +.commentfield { + margin-bottom: 20px; +} + +.commentfield textarea { + width: 100%; +} + +.comment { + padding-top: 10px; + padding-bottom: 10px; + border-top: 1px solid #4CAF50; +} + +.commentinfo { + font-size: 10pt; +} + +.commentcontent { + margin: 5px auto; + width: 95%; +} \ No newline at end of file diff --git a/website/public/styles/search.css b/website/public/styles/search.css index 86fd41d..565723e 100644 --- a/website/public/styles/search.css +++ b/website/public/styles/search.css @@ -25,5 +25,5 @@ } li.search-item:hover{ - background-color: #EEE; + background-color: #FBC02D; } \ No newline at end of file diff --git a/website/queries/post.php b/website/queries/post.php new file mode 100644 index 0000000..0183a5d --- /dev/null +++ b/website/queries/post.php @@ -0,0 +1,97 @@ +prepare(" + SELECT + `user`.`fname`, + `user`.`lname`, + `user`.`username`, + `post`.`groupID`, + `post`.`title`, + `post`.`content`, + `post`.`creationdate` + FROM + `post` + INNER JOIN + `user` + ON + `post`.`author` = `user`. `userID` + WHERE + `post`.`postID` = :postID + "); + + $stmt->bindParam(':postID', $postID); + $stmt->execute(); + return $stmt; +} + +function selectCommentsByPostId($postID) { + $stmt = $GLOBALS["db"]->prepare(" + SELECT + `comment`.`commentID`, + `comment`.`postID`, + `comment`.`author`, + `comment`.`content`, + `comment`.`creationdate`, + `user`.`fname`, + `user`.`lname`, + `user`.`username` + FROM + `comment` + INNER JOIN + `user` + ON + `comment`.`author` = `user`.`userID` + WHERE + `comment`.`postID` = :postID + "); + + $stmt->bindParam(':postID', $postID); + $stmt->execute(); + return $stmt; +} + +function makePost($userID, $groupID, $title, $content) { + $stmt = $GLOBALS["db"]->prepare(" + INSERT INTO + `post` ( + `author`, + `groupID`, + `title`, + `content` + ) + VALUES ( + :userID, + :groupID, + :title, + :content + ) + "); + + $stmt->bindParam(':userID', $userID); + $stmt->bindParam(':groupID', $groupID); + $stmt->bindParam(':title', $title); + $stmt->bindParam(':content', $content); + $stmt->execute(); +} + +function makeComment($postID, $userID, $content) { + $stmt = $_GLOBAL["db"]->prepare(" + INSERT INTO + `comment` ( + `postID`, + `author`, + `content` + ) + VALUES ( + :postID, + :userID, + :content + ) + "); + + $stmt->bindParam(':postID', $postID); + $stmt->bindParam(':userID', $userID); + $stmt->bindParam(':content', $content); + $stmt->execute(); +} \ No newline at end of file diff --git a/website/queries/user.php b/website/queries/user.php index 9904eee..be06197 100644 --- a/website/queries/user.php +++ b/website/queries/user.php @@ -321,7 +321,10 @@ function searchSomeUsers($n, $m, $search) $stmt = $GLOBALS["db"]->prepare(" SELECT `username`, - `profilepicture`, + IFNULL( + `profilepicture`, + '../img/notbad.jpg' + ) AS profilepicture, `fname`, `lname` FROM diff --git a/website/views/post-view.php b/website/views/post-view.php new file mode 100644 index 0000000..044c23e --- /dev/null +++ b/website/views/post-view.php @@ -0,0 +1,52 @@ +fetch(PDO::FETCH_ASSOC); +$fullname = $post['fname'] . " " . $post['lname'] . " (" . $post['username'] . ")"; + +echo(" +" . $post['content'] . "
+${post["content"]}
-${nicetime} geplaatst.
+${nicetime} geplaatst.
+