Esempio n. 1
0
File: Post.php Progetto: sks40gb/jnv
 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);
 }
Esempio n. 2
0
 function index()
 {
     \SKS\LIB\Session::checkAuthorPermission();
     $this->view->title = 'Settings';
     $this->view->settings = $this->getSettings();
     //echo "---". print_r($this->view->settings);
     $this->view->render('setting/setting');
 }
Esempio n. 3
0
 function update_setting($id, $value)
 {
     \SKS\LIB\Session::isSuperAdmin();
     $db = new DB();
     $sql = "UPDATE setting SET value = \"" . $value . "\" WHERE id = {$id} ";
     $db->executeUpdateQuery($sql);
     $this->view->message = "Record updated.";
     $this->view->render("message/message", false);
 }
Esempio n. 4
0
 function deleteEmail($id)
 {
     \SKS\LIB\Session::checkAuthorPermission();
     $db = new DB();
     $email = new \SKS\DB\Entity\Email();
     $email = $db->findById($email, $id);
     $db->remove($email);
     $this->view->message = "Emeil is deleted successfully.";
     $this->index();
 }
Esempio n. 5
0
 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);
 }
Esempio n. 6
0
 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);
 }
Esempio n. 7
0
 function secureLogin($user)
 {
     if (isset($user)) {
         // login
         \SKS\LIB\Session::init();
         \SKS\LIB\Session::setLoggedInUser($user);
         header("location:" . URL . "dashboard");
     } else {
         $this->view->email = $_POST["email"];
         $this->view->title = "Login";
         $this->view->error = "Email or Password is wrong.";
         $this->view->render("login/index");
     }
 }
Esempio n. 8
0
 function secureLogin($user)
 {
     if (isset($user)) {
         // login
         \SKS\LIB\Session::init();
         \SKS\LIB\Session::setLoggedInUser($user);
         //echo "setting user session" . $user-getId();
         header("location:" . URL);
     } else {
         $this->view->email = $this->getPostValue("login_email");
         $this->view->title = "Login";
         $this->view->error = "Email or Password is wrong.";
         $this->setTitle('Login');
         $this->view->render("login/login");
     }
 }
Esempio n. 9
0
 public function updateUser($id = null)
 {
     \SKS\LIB\Session::checkAdminPermission();
     $db = new DB();
     $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();
     $user = new \SKS\DB\Entity\User();
     if ($id != null) {
         $user = $db->findById($user, $id);
     }
     $current_email = $user->getEmail();
     $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);
     //set the User
     $this->view->user = $user;
     //If error occurs
     if (isset($errors)) {
         $this->view->errors = $errors;
         //save user
     } else {
         $is_same = $user->getEmail() == $current_email;
         $exists = $is_same ? false : $user->exist(array("email" => $user->getEmail()));
         if ($exists) {
             $this->view->errors = array("Email already exits");
         } else {
             // Save the user
             $user = $db->update($user, true);
             $this->view->user = $user;
             $this->view->message = "Profile is updated successfully.";
         }
     }
     $this->view->render('user/include/user_form', false);
 }
Esempio n. 10
0
 public function saveComment()
 {
     \SKS\LIB\Session::checkAdminPermission();
     if (isset($_POST["comment_id"])) {
         $db = new DB();
         $comment = new \SKS\DB\Entity\Comment();
         $comment = $db->findById($comment, $_POST["comment_id"]);
         $comment->setComment($_POST["comment"]);
         $db->update($comment, true);
         $this->setTitle("Comment");
         $this->view->message = "Comment is updated.";
         $this->view->comment = $comment;
         $this->view->render('comment/comment');
     } else {
         $this->view->error = "Comment id is missing.";
         $this->view->title = 'Update Commment';
         $this->view->render('comment/comment');
     }
 }
Esempio n. 11
0
 function uploadMultiImage()
 {
     \SKS\LIB\Session::checkAdminPermission();
     $uploader = new \Uploader();
     //print_r($_FILES['files']);
     $errors = array();
     $success = array();
     foreach ($_FILES['files']['name'] as $f => $name) {
         if ($_FILES['files']['error'][$f] != 0) {
             $errors[] = "Failed uploading file : " . $name;
             continue;
             // Skip file if any error found
         }
         $uploader->uploadAndPersistImage($name, $_FILES['files']['tmp_name'][$f], "Gallery");
         $success[] = "File uploaded : " . $name;
     }
     $this->view->errors = $errors;
     $this->view->messages = $success;
     $this->index();
 }
Esempio n. 12
0
 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;
     }
 }
Esempio n. 13
0
<?php

require_once VIEWS . 'message.php';
?>
    
    <!-- Posted Comments -->
    <?php 
if (\SKS\LIB\Session::isLoggedInUser()) {
    require_once 'comment_form.php';
} else {
    echo '<a class="btn btn-primary" href=' . URL . 'login>Login in to comment</a>';
}
echo "<hr>";
function printComment($comment)
{
    if (!isset($comment)) {
        return;
    } else {
        echo '<div class="media">
                <a class="pull-left" href="#">
                    <img class="media-object" src="http://placehold.it/64x64" alt="">
                </a>
                <div class="media-body">
                    <h4 class="media-heading">' . $comment->getCommentedBy()->getFirstName() . '
                        <small>' . $comment->getCommentedAt()->format('Y-m-d H:i:s') . '</small>
                    </h4>';
        echo $comment->getComment();
        foreach ($comment->getComments() as $c) {
            printComment($c);
        }
        echo '   
Esempio n. 14
0
 public static function getLoggedInUser()
 {
     \SKS\LIB\Session::get("loggedInUser");
 }
Esempio n. 15
0
gallery">Gallery</a></li>                
                                                    <li class="<?php 
echo \SKS\LIB\Session::getActiveClass("Contact", $this->title);
?>
"><a href="<?php 
echo URL;
?>
contact">Contact</a></li>
                                                    <?php 
if (\SKS\LIB\Session::isLoggedInUser()) {
    echo '<li class="' . \SKS\LIB\Session::getActiveClass("Profile", $this->title) . '"><a href="' . URL . 'user/profile">My Profile</a></li>';
    echo '<li><a href="' . URL . 'login/logout">Logout</a></li>';
} else {
    echo '<li class="' . \SKS\LIB\Session::getActiveClass("Login", $this->title) . '"><a href="' . URL . 'login">Login</a></li>';
}
if (\SKS\LIB\Session::isAdmin()) {
    echo '<li><a href="' . URL . 'dashboardAction">Dashboard</a></li>';
}
?>

                                                </ul>           
                                            </div><!--/.nav-collapse -->
                                        </div>     
                                    </nav>  
                                </div>
                                <!-- END MENU -->    
                            </header>
                            <!--=========== END HEADER SECTION ================--> 
                            <section>
                                <div class="row">
                                    <div class="col-lg-12 col-md-12">
Esempio n. 16
0
File: Post.php Progetto: sks40gb/sks
 function addCategory()
 {
     \SKS\LIB\Session::checkAdminPermission();
     if (isset($_POST["action"])) {
         $form = new \SKS\LIB\Form();
         $form->post("name")->addRule("minlength", 2)->post("post_type")->addRule("required");
         $errors = $form->validate();
         $category = new \SKS\DB\Entity\PostCategory();
         $category->setName($_POST["name"]);
         $category->setType($_POST["post_type"]);
         $exists = $category->exist(array("name" => $category->getName()));
         if ($exists) {
             $errors = array("Category already exits");
         }
         if (isset($errors)) {
             $this->view->errors = $errors;
         } else {
             $category->persist(true);
             $this->view->message = 'Saved Successfully';
         }
         $this->view->category = $category;
     }
     $this->view->title = 'Post';
     $this->view->render('post/addCategory');
 }
Esempio n. 17
0
 function ajaxPostList()
 {
     Session::checkAuthorPermission();
     $this->view->render('publish/paginator/table', false);
     //$this->view->render('publish/paginator/main');
 }
Esempio n. 18
0
<?php

define('PATH_ROOT', __DIR__ . "/");
require_once 'libs/boot/init.php';
\SKS\LIB\Session::initializeIfNotExits();
// Also spl_autoload_register (Take a look at it if you like)
/*function __autoload($class) {
    require_once PATH_LIBS . $class .".php";
}*/
// Load the Bootstrap!
$bootstrap = new \SKS\LIB\Bootstrap();
// Optional Path Settings
//$bootstrap->setControllerPath();
//$bootstrap->setModelPath();
//$bootstrap->setDefaultFile();
//$bootstrap->setErrorFile();
$bootstrap->init();
Esempio n. 19
0
                    </div>
                </div>
                <a href="<?php 
echo URL . 'publish/managePost';
?>
">
                    <div class="panel-footer pb">
                        <span class="pull-left">View Details</span>
                        <span class="pull-right"><i class="fa fa-arrow-circle-right"></i></span>
                        <div class="clearfix"></div>
                    </div>
                </a>
            </div>
        </div>
         <?php 
if (\SKS\LIB\Session::isSuperAdmin()) {
    ?>
        <div class="col-lg-3 col-md-6">
            <div class="panel panel-yellow">
                <div class="panel-heading">
                    <div class="row">
                        <div class="col-xs-3">
                            <i class="fa fa-users fa-5x"></i>
                        </div>
                        <div class="col-xs-9 text-right">
                            <div class="huge"><?php 
    echo $this->user_count;
    ?>
</div>
                            <div>Users !</div>
                        </div>