function addComment() { \SKS\LIB\Session::checkUserPermission(); $db = new DB(); $post = new \SKS\DB\Entity\Post(); $post = $db->findById($post, $_POST["post_id"]); if (isset($_POST["action"])) { $form = new \SKS\LIB\Form(); $form->post("comment")->addRule("required")->addRule("minlength", 5); $errors = $form->validate(); //set the comment $comment = new \SKS\DB\Entity\Comment(); $comment->setComment($_POST["comment"]); $user = $db->findById(Session::getLoggedInUser(), Session::getLoggedInUser()->getId()); $comment->setCommentedBy($user); if (isset($errors)) { $this->view->comment = $comment; $this->view->errors = $errors; } else { //Set the post $post->addComment($comment); $comment->setPost($post); $post = $db->update($post, true); $comment = $db->update($comment, true); $this->view->message = 'Commented Successfully'; } } $this->view->post = $post; $this->view->title = 'Post'; $this->view->render('post/addComment', false); }
function pagination($url = null) { $sql = "SELECT p.id AS id, p.title AS title, c.type AS type , c.name AS category_name, NULL AS comments, \n p.posted_at AS posted_at, p.publish AS publish, u.first_name AS posted_by,\n img.thumb_small as thumb_small, img.original as original \n FROM post p \n LEFT JOIN post_category c ON p.post_category_id = c.id\n LEFT JOIN user u ON p.user_id = u.id\n LEFT JOIN image img ON img.id = p.banner_image"; if (!\SKS\LIB\Session::isSuperAdmin()) { $sql .= " WHERE u.id = " . \SKS\LIB\Session::getLoggedInUser()->getId(); } $table_page = PATH_ADMIN_VIEWS . "publish/paginator/row.php"; $paginator = new \Paginator(); $paginator->execute($sql, $table_page, $url); }
function pagination($url = null) { $sql = "SELECT i.id AS id, `name`, size, `from`,`date`, original, thumb_small, thumb_medium, thumb_big, u.id AS user_id, u.first_name AS uploaded_by, i.active as active " . " FROM image i LEFT JOIN user u ON u.id = i.user_id "; if (\SKS\LIB\Session::isAuthor()) { $sql .= " WHERE u.id = " . \SKS\LIB\Session::getLoggedInUser()->getId(); } $sql .= " ORDER BY date DESC "; $table_page = PATH_ADMIN_VIEWS . "gallery/paginator/row.php"; $paginator = new \Paginator(); $paginator->execute($sql, $table_page, $url); }
function savePost() { Session::checkAuthorPermission(); //execute this line for save and update else create form. $db = new DB(); if (isset($_POST["action"])) { //Form validation $form = new \SKS\LIB\Form(); $form->post("title")->addRule("required")->post("post")->addRule("required")->post("post_type")->addRule("required")->post("category_id")->addRule("required")->post("banner_image_id")->addRule("required"); $errors = $form->validate(); // Get Post $post = new \SKS\DB\Entity\Post(); if (isset($_POST["post_id"]) && \Text::not_empty($_POST["post_id"])) { $post = $db->findById($post, $_POST["post_id"]); } //Get Category $postCategory = new PostCategory(); $postCategory = $db->findById($postCategory, $_POST["category_id"]); //Get Image $image = new \SKS\DB\Entity\Image(); $image = $db->findById($image, $_POST["banner_image_id"]); //Set the field value $post->setTitle($_POST["title"]); $post->setPost($_POST["post"]); $user = $db->findById(Session::getLoggedInUser(), Session::getLoggedInUser()->getId()); $post->setUser($user); $post->setPostCategory($postCategory); $post->setBannerImage($image); // Set view variable $this->view->title = 'Post'; $this->view->post = $post; $this->view->postType = $_POST["post_type"]; //If no error encoutered if (isset($errors)) { $this->view->errors = $errors; } else { $post = $db->update($post, true); $post->setPostCategory($postCategory); $this->view->message = "Posted saved successfully"; } } $this->view->post = $post; $this->view->categories = $this->getCategories(); $this->view->render('publish/post'); }
public function uploadAndPersistImage($filename, $tempFilePath, $from = "default") { $info = $this->uploadImage($filename, $tempFilePath, $from); if ($info["status"] == 0) { return $info; } else { $image = new SKS\DB\Entity\Image(); $image->setName($info["name"]); $image->setOriginal($info["original"]); $image->setThumbSmall($info["thumb_small"]); $image->setThumbMedium($info["thumb_medium"]); $image->setThumbBig($info["thumb_big"]); $image->setSize($info["file_size"]); $image->setFrom($from); $image->setUser(\SKS\LIB\Session::getLoggedInUser()); $db = new DB(); $image = $db->update($image, true); $info["image_id"] = $image->getId(); $info["image"] = $image; return $info; } }
public function updateProfile($id) { \SKS\LIB\Session::checkUserPermission(); $this->view->title = 'Update Profile'; //validate the form $form = new \SKS\LIB\Form(); $form->post('first_name')->addRule('minlength', 2)->post('email')->addRule('email')->post('last_name')->addRule('required'); $errors = $form->validate(); $db = new DB(); $user = new \SKS\DB\Entity\User(); $user = $db->findById($user, $id); $user->setFirstName($this->getPostValue("first_name")); $user->setLastName($this->getPostValue("last_name")); $user->setEmail($this->getPostValue("email")); //Set the profile Image $profileImage = new \SKS\DB\Entity\Image(); if (isset($_POST["profile_image_id"])) { $profileImage = $db->findById($profileImage, $_POST["profile_image_id"]); } $user->setProfileImage($profileImage); $this->view->user = $user; //If error occurs if (isset($errors)) { $this->view->errors = $errors; //save user } else { $is_same = $user->getEmail() == \SKS\LIB\Session::getLoggedInUser()->getEmail(); $exists = $is_same ? false : $user->exist(array("email" => $user->getEmail())); if ($exists) { $this->view->errors = array("Email already exits"); } else { // Save the user $db->update($user, true); $this->view->message = "Profile is updated successfully."; } } $this->view->render('user/profile_form', false); }
<button type = "button" class = "navbar-toggle collapsed" data-toggle = "collapse" data-target = "#navbar" aria-expanded = "false" aria-controls = "navbar"> <span class = "sr-only">Toggle navigation</span> <span class = "icon-bar"></span> <span class = "icon-bar"></span> <span class = "icon-bar"></span> </button> <!--LOGO --> <!--TEXT BASED LOGO --> <a class = "navbar-brand" href = "<?php echo URL; ?> ">JNV <span>Basdei</span><span> <?php if (\SKS\LIB\Session::isLoggedInUser()) { echo "<img src=" . \SKS\LIB\Session::getLoggedInUser()->getProfileImageURL() . " style='width:40px;height:40px' class='img-circle'/>"; } ?> </span> </a> <!-- IMG BASED LOGO --> <!-- <a class="navbar-brand" href="index.html"><img src="image/logo.png" alt="logo"></a> --> </div> <div id="navbar" class="navbar-collapse collapse"> <ul id="top-menu" class="nav navbar-nav navbar-right main-nav"> <li class="<?php echo \SKS\LIB\Session::getActiveClass("Home", $this->title); ?> "><a href="<?php echo URL;
<span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a href="<?php echo URL; ?> " class="navbar-brand">SKS</a> </div><!-- Navbar Header--> <div class="collapse navbar-collapse" id="navbar-collapse"> <?php if (\SKS\LIB\Session::isLoggedInUser()) { echo '<a href="' . URL . 'login/logout" class="btn btn-warning navbar-btn navbar-right">Logout</a>'; echo '<a href="' . URL . '" class="btn btn-message navbar-btn navbar-right">' . \SKS\LIB\Session::getLoggedInUser()->getFirstName() . ' ' . \SKS\LIB\Session::getLoggedInUser()->getFirstName() . '</a>'; } else { echo '<a href="' . URL . 'login" class="btn btn-warning navbar-btn navbar-right">Login</a>'; } ?> <ul class="nav navbar-nav"> <li><a href="#feedback">Feedback</a> <li><a href="#gallery">Gallery</a> <li><a href="#features">Features</a> <li><a href="#faq">Faq</a> <li><a href="#contact">ContactUs</a> <li><a href="<?php echo URL; ?> post/index">Post</a></li> <?php