コード例 #1
0
 public function handleSaveAnswer($request_method, $request_data)
 {
     $msg = NULL;
     $error = FALSE;
     switch ($request_method) {
         case 'POST':
             filter_all_post($request_data);
             $request_data['answer'] = trim($request_data['answer']);
             if (empty($request_data['answer'])) {
                 $msg = __('Answer can not be left blank');
                 $error = true;
             } else {
                 $comment = new Comment();
                 // setting some variables
                 $usr = PA::$user;
                 $comment->comment = $comment->subject = $request_data['answer'];
                 $comment->parent_type = TYPE_ANSWER;
                 $id = $comment->parent_id = $comment->content_id = $request_data['id'];
                 $comment->user_id = $usr->user_id;
                 $comment->name = $usr->login_name;
                 $comment->email = $usr->email;
                 if ($comment->spam_check()) {
                     $msg = __('Sorry, your Answer cannot be posted as it looks like spam. Try removing any links to possibly suspect sites, and re-submitting.');
                     $error = true;
                     Logger::log('Comment rejected by spam filter', LOGGER_ACTION);
                 } else {
                     $msg = __('Your Answer has been posted successfully');
                     $comment->save_comment();
                     if ($comment->spam_state != SPAM_STATE_OK) {
                         $msg = __('Sorry, your answer cannot be posted as it was classified as spam by Akismet, or contained links to blacklisted sites. Please check the links in your post, and that your name and e-mail address are correct.');
                         $error = true;
                     } else {
                         unset($request_data);
                         //invalidate cache of content block as it is modified now
                         if (PA::$network_info) {
                             $nid = '_network_' . PA::$network_info->network_id;
                         } else {
                             $nid = '';
                         }
                         //unique name
                         $cache_id = 'content_' . $id . $nid;
                         CachedTemplate::invalidate_cache($cache_id);
                     }
                 }
             }
             break;
     }
     $msg_array = array();
     $msg_array['failure_msg'] = $msg;
     $msg_array['success_msg'] = NULL;
     $redirect_url = NULL;
     $query_str = NULL;
     set_web_variables($msg_array, $redirect_url, $query_str);
 }
コード例 #2
0
ファイル: LiveController.php プロジェクト: jjsub/samesub
 public function actionSendcomment($text = "")
 {
     global $arr_response;
     $model = new Comment();
     if ($_REQUEST['text']) {
         $model->comment = $_REQUEST['text'];
         $model->update_live = true;
         if (Comment::save_comment($model)) {
             $arr_response['response_message'] = 'Comment sent.';
         } else {
             $arr_response['response_code'] = 409;
             $arr_response['response_message'] = Yii::t('comment', 'Comment could not be saved.');
         }
     } else {
         $arr_response['response_code'] = 409;
         $arr_response['response_message'] = Yii::t('comment', "No 'text' parameter received.");
     }
 }
コード例 #3
0
ファイル: CommentController.php プロジェクト: jjsub/samesub
 public function actionPush($text = "")
 {
     $this->model = new Comment();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($this->model);
     if (isset($_POST['Comment']) or $text or $_POST['text']) {
         if (isset($_POST['Comment'])) {
             $this->model->attributes = $_POST['Comment'];
         }
         if ($text) {
             $this->model->comment = $text;
         }
         if ($_POST['text']) {
             $this->model->comment = $_POST['text'];
         }
         $this->model->update_live = true;
         Comment::save_comment($this->model);
         //we need to jsonecode something, as not doing so, can provoke an
         //ajax response error on the client site if the ajax request is of type json
         echo json_encode(array('success' => 'yes'));
         return;
     }
     $this->render('add', array('model' => $this->model));
 }
コード例 #4
0
 $usr = get_user();
 $comment->comment = $_POST['comment'];
 $comment->subject = $_POST['comment'];
 $comment->parent_type = TYPE_CONTENT;
 $comment->parent_id = $_POST['id'];
 $comment->content_id = $_POST['id'];
 $comment->user_id = $usr->user_id;
 $comment->name = $usr->login_name;
 $comment->email = $usr->email;
 $id = $_POST['id'];
 if ($comment->spam_check()) {
     $error_message = "Sorry, your comment cannot be posted as it looks like spam.  Try removing any links to possibly suspect sites, and re-submitting.";
     Logger::log("Comment rejected by spam filter", LOGGER_ACTION);
 } else {
     $error_message = 'Your comment has been posted successfully';
     $comment->save_comment();
     if ($comment->spam_state != SPAM_STATE_OK) {
         $error_message = "Sorry, your comment cannot be posted as it was classified as spam by Akismet, or contained links to blacklisted sites.  Please check the links in your post, and that your name and e-mail address are correct.";
     } else {
         //TO DO: comment should be posted to contents of other network rather then just mother network
         //$params['cid'] = $comment->content_id;
         //auto_email_notification('comment_posted', $params );
         //** when uncommenting the above line, don't forget to uncomment the include of auto_email_notify.php at the top of this file too!
         unset($_POST);
         //invalidate cache of content block as it is modified now
         if ($network_info) {
             $nid = '_network_' . $network_info->network_id;
         } else {
             $nid = '';
         }
         //unique name
コード例 #5
0
ファイル: add_comment.php プロジェクト: jdarrohn/goal-cms
<?php

include_once $_SERVER["DOCUMENT_ROOT"] . '/config.php';
include_once ROOT_PATH . '/App/Models/Database.class.php';
include_once ROOT_PATH . '/App/Models/Comment.class.php';
$comment_goal_id = $_POST['comment-goal-id'];
$comment_body = $_POST["goal-{$comment_goal_id}-comment"];
$Comment = new Comment($comment_body, $comment_goal_id);
$Comment->save_comment($Comment);
header('Location: /public_html/goals?message=comment_added');
コード例 #6
0
 private function handleAJAX_addUserComment($request_data)
 {
     $msg = 'success';
     $html = 'null';
     filter_all_post($request_data);
     if (!empty($request_data['content'])) {
         $comment = new Comment();
         $usr = PA::$login_user;
         $comment->comment = $request_data['content'];
         $comment->subject = $request_data['content'];
         $comment->parent_type = TYPE_USER;
         $comment->parent_id = PA::$page_uid;
         $comment->content_id = PA::$page_uid;
         $comment->user_id = $usr->user_id;
         $comment->name = $usr->login_name;
         $comment->email = $usr->email;
         $id = PA::$page_uid;
         if ($comment->spam_check()) {
             Logger::log("Comment rejected by spam filter", LOGGER_ACTION);
             $msg = $html = __("Comment rejected by spam filter");
         } else {
             try {
                 $comment->save_comment();
                 if ($comment->spam_state != SPAM_STATE_OK) {
                     $msg = $html = __("Comment rejected by spam filter");
                 }
                 $html = $this->render();
             } catch (Exception $e) {
                 $msg = $html = $e->getMessage();
             }
         }
     } else {
         $msg = __("Comment can't be empty.");
     }
     echo json_encode(array("msg" => $msg, "result" => htmlspecialchars($html)));
     exit;
 }