Beispiel #1
0
 public function edit($id = NULL)
 {
     $id = (int) $id;
     if (!$id) {
         $this->redirect('admin');
     }
     $statuses = array("publish", "draft");
     if ($this->data) {
         if (isset($this->data['cancelar'])) {
             $this->redirect("admin/");
         } else {
             $P = new post();
             $P->find($id);
             if (!preg_match("/\\S+/", $this->data['title']) or $this->data['title'] == "") {
                 $this->data['title'] = "Untitled";
             }
             if (!preg_match("/\\S+/", $this->data['urlfriendly']) or $this->data['urlfriendly'] == "") {
                 $this->data['urlfriendly'] = $this->data['title'];
             }
             $this->data['urlfriendly'] = $P->buildUrl($this->data['urlfriendly'], $id);
             $P->updateTags($id, $this->data['tags']);
             unset($this->data['tags']);
             $P->prepareFromArray($this->data);
             $P->save();
             $this->session->flash('Información guardada correctamente.');
             $this->redirect("admin/edit/{$id}");
         }
     }
     $P = new post();
     $post = $P->find($id);
     $post['title'] = utils::convert2HTML($P['title']);
     $post['content'] = utils::convert2HTML($P['content']);
     $post['tags'] = $P->getTags($id, 'string');
     $this->title_for_layout($this->l10n->__("Editar post - Codice CMS"));
     $this->view->id = $id;
     $this->view->post = $post;
     $this->view->statuses = $statuses;
     $this->view->setLayout("admin");
     $this->render();
 }
Beispiel #2
0
<?php

require "../../includes/conf.inc.php";
require "../../includes/functions.inc.php";
if (isset($_POST['id'])) {
    $id = intval($_POST['id']);
    $postTitle = $_POST['postTitle'];
    $textArea = $_POST['postText'];
    $imp = $_POST['imp'];
    $postTitle = ucfirst(sanitize_text($postTitle));
    $textArea = trim(mysql_real_escape_string(stripslashes($textArea)));
    if ($postTitle == '' || $textArea == '') {
        $response = array('success' => 0, 'error' => 1, 'errorMsg' => 'Either Post Title Or Post Body is empty!');
    } else {
        $newPost = array('postTitle' => $postTitle, 'postText' => $textArea, 'imp' => $imp);
        if (!post::save($newPost, $id)) {
            $response = array('success' => 0, 'error' => 2, 'errorMsg' => 'Opps! Something Went Wrong!');
        } else {
            $response = array('success' => 1, 'error' => 0);
        }
    }
    echo json_encode($response);
}
Beispiel #3
0
<?php

require "../../includes/conf.inc.php";
require "../../includes/functions.inc.php";
if (isset($_POST['postId'])) {
    $postId = $_POST['postId'];
    if (!post::save(array('statusId' => 1), $postId)) {
        $response = array('success' => 0, 'error' => 1, 'errorMsg' => 'Opps! Something Went Wrong! Please Try Again Later', 'debugMsg' => mysql_error());
    } else {
        $post = post::view($postId, 1);
        $postTitle = $post['postTitle'];
        $previewLink = '<a href="' . generate_link($postTitle, $postId) . '" target="_blank" class="ico_preview"></a>';
        $response = array('success' => 1, 'preview' => $previewLink, 'error' => 0);
    }
    echo json_encode($response);
}
 public static function testPost($request, $context)
 {
     $data = array("texte" => $request["texte"], "date" => $request["date"], "image" => $request["image"]);
     $post = new post($data);
     $post->id = $post->save();
     if (is_null($post->id)) {
         return NULL;
     } else {
         return $post;
     }
 }
 public static function tweetme($request, $context)
 {
     //print_r($request);
     if (!empty($request['tweetform'])) {
         $image = empty($request['image']) ? "null" : $request['image'];
         $postInfo['texte'] = $request['text'];
         $postInfo['image'] = $image;
         $postInfo['date'] = date("Y-m-d H:i:s");
         $post = new post($postInfo);
         $idPost = $post->save();
         //print_r($idPost);
         $tweetInfo['emetteur'] = $context->getSessionAttribute('id');
         $tweetInfo['parent'] = $context->getSessionAttribute('id');
         $tweetInfo['post'] = $idpost;
         $tweet = new tweet($tweetInfo);
         $idTweet = $tweet->save();
         //print_r($idTweet);
         return context::SUCCESS;
     }
     return context::ERROR;
 }
Beispiel #6
0
 private function save_edit_post($data)
 {
     if (isset($data['cat']) && isset($data['thread']) && isset($data['post']) && isset($data['content']) && !$this->banned()) {
         // Set variables
         $category_id = $data['cat'];
         $thread_id = $data['thread'];
         $post_id = $data['post'];
         //Fetch post to edit
         $post = post::get($data['post']);
         $editTime = Time();
         $content = $data['content'];
         //Fetch forum data
         // $category = category::get($category);
         // $thread = thread::get($thread);
         thread::update_post_count($thread_id);
         if ($this->user['Username'] == $post['author'] || $this->user['SiteRank'] >= 4) {
             $result = post::save($category_id, $thread_id, $post_id, $content, $editTime, $this->user);
         } else {
             self::errorJSON('You do not have permission to edit this post!');
         }
     } else {
         self::errorJSON('Something went wrong!');
     }
 }