예제 #1
0
 public function reply_submit()
 {
     $user_id = $this->input->post('user_id');
     $story_id = $this->input->post('story_id');
     $reply_id = $this->input->post('reply_id');
     $textarea = filterCommentBeforeSave($this->input->post('textarea'));
     $pop = $this->input->post('pop') < 0 ? 1 : 0;
     $date = date('Y-m-d  h:i');
     $data_insert = array('comments' => $textarea, 'user_id' => $user_id, 'parent_comment_id' => $reply_id, 'section_type' => '2', 'section_type_id' => $story_id, 'is_approved' => '1', 'is_enable' => '1', 'created_date' => $date);
     $this->db->insert('comments', $data_insert);
     $msg = comments_data_id($story_id, $reply_id, $pop);
     //$msg="Thanks for successfully submit your reply";
     echo $msg;
 }
        function comments_data_col($story_id, $limit = '0', $pop = 'pop')
        {
            $ci =& get_instance();
            if ($limit > 0) {
                $limit_data = 'LIMIT ' . $limit;
            } else {
                $limit_data = '';
            }
            $comment_data_dev = $pop != 'pop' ? 'comment_data_dev_' . $story_id : 'comment_data_pop_' . $story_id;
            $html = '<div class="comment-list-css common-new comment_data_main ' . $comment_data_dev . '">';
            $comment = $ci->db->query("select * from comments where section_type_id='" . $story_id . "' and section_type='0' and parent_comment_id='0' order by id desc {$limit_data}")->result_array();
            if (is_array($comment) && !empty($comment)) {
                $html .= ' <h3>Discussion</h3>
		<div class="comment-main-box-css common-new ">';
                foreach ($comment as $comment_val) {
                    $comment_user = user_allinfo_id($comment_val['user_id']);
                    $user_link = base_url() . 'usersinfo/' . $comment_val['user_id'];
                    $onclick_comment = array('user_id' => $ci->session->userdata('user_logged'), 'section_title' => $comment_val['comments'], 'section_type' => '3', 'section_type_action' => 'upvote', 'section_action_id' => $comment_val['id']);
                    if ($ci->session->userdata('user_logged') != '') {
                        $htmlreply = 'class="replyshowhide' . $pop . '"';
                    } else {
                        $htmlreply = 'data-popup-open="popup-1"';
                    }
                    $vote = vote_count_by_id('3', $comment_val['id']);
                    $vote_msg = $vote > 0 ? '<span id="comment_3_' . $comment_val['id'] . '">' . $vote . '</span>' : '<span id="comment_3_' . $comment_val['id'] . '">Upvote</span>';
                    $html .= '  <div class="comment-box-css common-new" >

		<div class="col-lg-1 col-md-1 col-sm-2 pro-left">
		<a href="' . $user_link . '" class="avatar-image-css" target="_blank">' . username_photo_by_id($comment_val['user_id']) . '</a>
		</div>

		<div class="col-lg-11 col-md-11 col-sm-10 pro-right">


		<div class="comment-main-box comment-main-new">

		<div class="name-user"><a href="' . base_url() . 'usersinfo/' . $comment_user['id'] . '" target="_blank" >' . $comment_user['first_name'] . ' ' . $comment_user['last_name'] . '</a></div> 
		<div>' . $comment_val['comments'] . '</div>
		<div class="share-list">
		<a href="javascript:;" ' . onclick_upvote($onclick_comment) . '><i class="fa  fa-caret-up"></i>' . $vote_msg . '</a>
		
		<a ' . $htmlreply . ' id="' . $comment_val['id'] . '" href="javascript:;"> Reply</a>
		<a href="javascript:;" class="days-after">' . get_days_count_from_dates($comment_val['created_date'], date('Y-m-d')) . '</a>
		</div>';
                    $html .= '</div><span id="reply_msg' . $pop . '_' . $comment_val['id'] . '"></span>
		</div>

		
		';
                    $html .= '<div class="common-new comment-textarea" style="display:none;" id="showhide' . $pop . '_' . $comment_val['id'] . '">

				 <textarea class="form-control from-reply mention' . $pop . '" placeholder="Add a reply....." onclick="onfocus_onblur();"   id="' . $pop . 'formreply_' . $story_id . '_' . $comment_val['id'] . '"></textarea>

                         <a href="javascript:;" class="enter-text mformreply" rel="' . $comment_val['id'] . '" id="' . $pop . 'mformreply_' . $story_id . '_' . $comment_val['id'] . '"><i class="fa fa-level-down"></i></a>
                 
                     </div>';
                    $html .= comments_data_id($story_id, $comment_val['id'], $limit);
                    $html .= ' 	</div> ';
                }
                $html .= ' 	</div> ';
            }
            $html .= '   </div> ';
            return $html;
        }