示例#1
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);
 }
示例#2
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');
     }
 }
示例#3
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();
 }
示例#4
0
 public function index()
 {
     \SKS\LIB\Session::checkAdminPermission();
     $this->view->title = 'Email';
     $this->view->render('email/manage_emails');
 }
示例#5
0
文件: Post.php 项目: 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');
 }