diff --git a/website/public/js/masonry.js b/website/public/js/masonry.js index e9419a2..2bddf59 100644 --- a/website/public/js/masonry.js +++ b/website/public/js/masonry.js @@ -73,4 +73,12 @@ function mansonry() { } $("div.posts div.column").width(100/columnCount + "%"); + + $(".post").click(function () { + $(".modal").show(); + }); + + $(".modal-close").click(function () { + $(".modal").hide(); + }); } \ 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..e69de29 diff --git a/website/public/profile.php b/website/public/profile.php index e4f1452..f7cae2b 100644 --- a/website/public/profile.php +++ b/website/public/profile.php @@ -2,9 +2,10 @@
- + @@ -12,6 +13,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..c4a2a4c --- /dev/null +++ b/website/public/styles/post-popup.css @@ -0,0 +1,38 @@ +/* modal based on: http://www.w3schools.com/howto/howto_css_modals.asp */ + +.modal { + /*display: none; !* Hidden by default *!*/ + position: fixed; /* Stay in place */ + z-index: 1; /* Sit on top */ + left: 0; + top: 0; + width: calc(100% - 256px); /* Full width */ + height: calc(100% - 80px); /* Full height */ + overflow: visible; /* Enable scroll if needed */ + background-color: rgb(0,0,0); /* Fallback color */ + background-color: rgba(0,0,0,0.4); /* Black w/ opacity */ +} + +/* Modal Content/Box */ +.modal-content { + background-color: #fefefe; + margin: 15% auto; /* 15% from the top and centered */ + padding: 20px; + border: 1px solid #888; + width: 80%; /* Could be more or less, depending on screen size */ +} + +.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; +} \ 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/views/post-view.php b/website/views/post-view.php new file mode 100644 index 0000000..2450468 --- /dev/null +++ b/website/views/post-view.php @@ -0,0 +1,53 @@ +fetch(PDO::FETCH_ASSOC); + $fullname = $post['fname'] . " " . $post['lname'] . " (" . $post['username'] . ")"; +?> + +