Пример #1
0
function timkiembinhluan()
{
    global $wpdb;
    $noidungtimkiem = $_POST['tieude'];
    $id = $_POST['id'];
    $course_curriculum = vibe_sanitize(get_post_meta($id, 'vibe_course_curriculum', false));
    $unit_id = wplms_get_course_unfinished_unit($id);
    $unit_comments = vibe_get_option('unit_comments');
    $units = array();
    if (isset($course_curriculum) && is_array($course_curriculum) && count($course_curriculum)) {
        foreach ($course_curriculum as $key => $curriculum) {
            if (is_numeric($curriculum)) {
                $units[] = $curriculum;
            }
        }
    }
    $bien = '';
    for ($i = 0; $i < count($units); $i++) {
        if ($i == count($units) - 1) {
            $bien .= $wpdb->comments . ".comment_post_ID=" . $units[$i];
        } else {
            $bien .= $wpdb->comments . ".comment_post_ID=" . $units[$i] . " OR ";
        }
    }
    $query = "select * from " . $wpdb->comments . " , " . $wpdb->commentmeta . " where " . $wpdb->comments . ".comment_ID = " . $wpdb->commentmeta . ".comment_id AND " . $wpdb->commentmeta . ".meta_key = 'title_discussion' AND " . $wpdb->comments . ".comment_parent=0 AND (" . $wpdb->commentmeta . ".meta_value like '%" . $noidungtimkiem . "%' OR " . $wpdb->comments . ".comment_content like '%" . $noidungtimkiem . "%') AND ( " . $wpdb->comments . ".comment_post_id=" . $id . " OR " . $bien . ") GROUP BY " . $wpdb->comments . ".comment_id Order by " . $wpdb->comments . ".comment_date DESC LIMIT 0,10";
    //    $query = "select * from ".$wpdb->comments." , ".$wpdb->commentmeta." where ".$wpdb->comments.".comment_ID = ".$wpdb->commentmeta.".comment_id AND ".$wpdb->comments.".comment_parent=0 AND (".$wpdb->commentmeta.".meta_value like '%".$noidungtimkiem."%' OR ".$wpdb->comments.".comment_content like '%".$noidungtimkiem."%') AND ( ".$wpdb->comments.".comment_post_id=".$id." OR ".$bien.") GROUP BY ".$wpdb->comments.".comment_id LIMIT 0,10";
    //    $querytong = "select * from ".$wpdb->comments." , ".$wpdb->commentmeta." where ".$wpdb->comments.".comment_ID = ".$wpdb->commentmeta.".comment_id AND ".$wpdb->comments.".comment_parent=0 AND (".$wpdb->commentmeta.".meta_value like '%".$noidungtimkiem."%' OR ".$wpdb->comments.".comment_content like '%".$noidungtimkiem."%') AND ( ".$wpdb->comments.".comment_post_id=".$id." OR ".$bien.") GROUP BY ".$wpdb->comments.".comment_id";
    $querytong = "select * from " . $wpdb->comments . " , " . $wpdb->commentmeta . " where " . $wpdb->comments . ".comment_ID = " . $wpdb->commentmeta . ".comment_id AND " . $wpdb->commentmeta . ".meta_key = 'title_discussion' AND " . $wpdb->comments . ".comment_parent=0 AND (" . $wpdb->commentmeta . ".meta_value like '%" . $noidungtimkiem . "%' OR " . $wpdb->comments . ".comment_content like '%" . $noidungtimkiem . "%') AND ( " . $wpdb->comments . ".comment_post_id=" . $id . " OR " . $bien . ") GROUP BY " . $wpdb->comments . ".comment_id Order by " . $wpdb->comments . ".comment_date DESC";
    $result = $wpdb->get_results($query);
    $resulttong = $wpdb->get_results($querytong);
    $dulieu = '';
    $dulieu .= '<div class="append-content-discussion" >';
    foreach ($result as $value) {
        $checkCommentMeta = get_comment_meta($value->comment_ID, 'review_rating', true);
        if (empty($checkCommentMeta)) {
            $args = array('post_id' => $value->comment_post_ID, 'parent' => $value->comment_ID, 'order' => 'ASC');
            $comments_child = get_comments($args);
            //đếm số comment con
            $args = array('post_id' => $value->comment_post_ID, 'parent' => $value->comment_ID, 'count' => true);
            $number_comments_child = get_comments($args);
            $dulieu .= '<div class="item-discustion">';
            $dulieu .= '<div class="cmtauthor row">';
            $dulieu .= '<div class="HieuChinh-ds">';
            if ($value->user_id == get_current_user_id()) {
                $dulieu .= '<div class="Xoads"><i class="icon-x"></i> </div>';
                $dulieu .= '<div class="Suads"><i class="icon-edit-pen-1"></i> </div>';
            }
            $dulieu .= '<input class="id-comment-ds" type="hidden" value="' . $value->comment_ID . '">';
            $dulieu .= '</div>';
            $dulieu .= '<div class="col-md-1">';
            $dulieu .= get_avatar($value->user_id, 32);
            $dulieu .= '</div>';
            $dulieu .= '<div class="col-md-10" >';
            foreach ($units as $unit_id_comment) {
                if ($value->comment_post_ID == $unit_id_comment) {
                    $thaoluantaiunit = $value->comment_post_ID;
                }
            }
            if ($thaoluantaiunit != 0) {
                $dulieu .= '<span class="authorname">' . $value->comment_author . '</span>' . '<span style="font-style:italic"> đã gửi 1 thảo luận tại bài <span class="unit_line"> <a class="unit" data-unit="' . $thaoluantaiunit . '" ><b>' . get_the_title($thaoluantaiunit) . '</b></a> </span> cách đây ' . human_time_diff(strtotime($value->comment_date), strtotime(current_time('mysql'))) . '</span>';
            } else {
                $dulieu .= '<span class="authorname">' . $value->comment_author . '</span>' . '<span style="font-style:italic"> đã gửi 1 thảo luận cách đây ' . human_time_diff(strtotime($value->comment_date), strtotime(current_time('mysql'))) . '</span>';
            }
            $dulieu .= '</div></div><br>';
            if ($thaoluantaiunit != 0) {
                $dulieu .= '<div data-id="' . $value->comment_ID . '" data-course-id="' . $thaoluantaiunit . '" class="NoiDungCMTUser row">';
            } else {
                $dulieu .= '<div data-id="' . $value->comment_ID . '" data-course-id="' . $id . '" class="NoiDungCMTUser row">';
            }
            //            $dulieu.='<div data-id="'.$value->comment_ID.'" data-course-id="'.$id.'" class="NoiDungCMTUser row">';
            $dulieu .= '<div class="col-md-1"></div>';
            $dulieu .= '<div class="col-md-10">';
            $dulieu .= '<div class="comment-title-user">' . get_comment_meta($value->comment_ID, 'title_discussion', true) . ' </div>';
            $dulieu .= '<div class="comment-content-user">' . $value->comment_content . '</div>';
            if ($number_comments_child != 0) {
                $dulieu .= '<div class="list-comment"><ul><li><a class="rely_comment" data-commnent-id="comment-child-editor-' . $value->comment_ID . '">Hiện ' . $number_comments_child . ' trả lời</a></li></ul></div>';
                $dulieu .= '<div class="hide-list-comment"><ul><li><a class="hide_comment" data-commnent-id="comment-child-editor-' . $value->comment_ID . '">Ẩn ' . $number_comments_child . ' trả lời</a></li></ul></div>';
            } else {
                $dulieu .= '<div class="list-comment be-frist"><ul><li><a class="rely_comment" data-commnent-id="comment-child-editor-' . $value->comment_ID . '">Hãy là người đầu tiên trả lời bình luận này</a></li></ul></div>';
                $dulieu .= '<div class="hide-list-comment"><ul><li><a class="hide_comment" data-commnent-id="comment-child-editor-' . $value->comment_ID . '">Ẩn đi</a></li></ul></div>';
            }
            //                            echo '<div class="content_child_comment">
            //
            //                                    </div>';
            $dulieu .= '<div class="child_comment">';
            $dulieu .= '<div class="content_child_comment_start">';
            foreach ($comments_child as $value1) {
                $dulieu .= '<li>';
                $dulieu .= '<div class="item-discustion child">';
                $dulieu .= '<div class="cmtauthor child row">';
                $dulieu .= '<div class="HieuChinh-ds child">';
                if ($value1->user_id == get_current_user_id()) {
                    $dulieu .= '<div class="Xoads"><i class="icon-x"></i> </div>';
                    $dulieu .= '<div class="Suads"><i class="icon-edit-pen-1"></i> </div>';
                }
                $dulieu .= '<input class="child id-comment-ds" type="hidden" value="' . $value1->comment_ID . '">';
                $dulieu .= '</div>';
                $dulieu .= '<div class="col-md-1">';
                $dulieu .= get_avatar($value1->user_id, 32);
                $dulieu .= '</div>';
                $dulieu .= '<div class="col-md-10" >';
                $dulieu .= '<span class="authorname">' . $value1->comment_author . '</span>' . '<span style="font-style:italic"> đã gửi 1 thảo luận cách đây ' . human_time_diff(strtotime($value1->comment_date), strtotime(current_time('mysql'))) . '</span>';
                $dulieu .= '</div></div><br>';
                $dulieu .= '<div data-id="' . $value1->comment_ID . '" data-course-id="' . $thaoluantaiunit . '" class="child NoiDungCMTUser row">';
                $dulieu .= '<div class="col-md-1"></div>';
                $dulieu .= '<div class="col-md-10">';
                $dulieu .= '<div class="comment-title-user">' . get_comment_meta($value1->comment_ID, 'title_discussion', true) . ' </div>';
                $dulieu .= '<div class="comment-content-user">' . $value1->comment_content . '</div>';
                $dulieu .= '</div></div>';
                $dulieu .= '<div class="edit_content_editor_child"></div>';
                $dulieu .= '</li>';
            }
            $dulieu .= '</div>';
            $dulieu .= '<div class="content_child_comment"></div>';
            $dulieu .= '</div>';
            $dulieu .= '</div></div>';
            $dulieu .= '<div class="edit_content_editor "></div><hr>';
            $dulieu .= '</div>';
        }
    }
    $tong = count($resulttong);
    if ($tong > 10) {
        $dulieu .= '<div data-page="10" data-course-id="' . $id . '" class="xemthembinhluan"><span class="btn btn-primary"><i style="display: none" class="noidungthongbaoloading icon-refresh glyphicon-refresh-animate"></i> Xem thêm...</span></div>';
    }
    echo $dulieu;
    die;
}
Пример #2
0
            ?>
                        </div>

                        <div class="item-instructor">
                            <?php 
            bp_course_instructor();
            ?>
                        </div>
                        <div class="item-action"><?php 
            bp_course_action();
            ?>
</div>
                        <div class="item_process">
                            <?php 
            $course_id = $post->ID;
            $unit_id = wplms_get_course_unfinished_unit($post->ID);
            do_action('child_wplms_course_start_after_time', $course_id, $unit_id);
            ?>

                        </div>
                        <?php 
            do_action('bp_directory_course_item');
            ?>

                    </div>
                    <?php 
            $result = ob_get_clean();
        }
        if ($cache_duration) {
            wp_cache_set($course_key, $result, 'course_loop', $cache_duration);
        }
Пример #3
0
get_header(vibe_get_header());
$user_id = get_current_user_id();
if (isset($_POST['course_id'])) {
    $course_id = $_POST['course_id'];
    $coursetaken = get_user_meta($user_id, $course_id, true);
} else {
    if (isset($_COOKIE['course'])) {
        $course_id = $_COOKIE['course'];
        $coursetaken = 1;
    }
}
if (!isset($course_id) || !is_numeric($course_id)) {
    wp_die(__('INCORRECT COURSE VALUE. CONTACT ADMIN', 'vibe'));
}
$course_curriculum = vibe_sanitize(get_post_meta($course_id, 'vibe_course_curriculum', false));
$unit_id = wplms_get_course_unfinished_unit($course_id);
$unit_comments = vibe_get_option('unit_comments');
$class = '';
if (isset($unit_comments) && is_numeric($unit_comments)) {
    $class .= 'enable_comments';
}
$class = apply_filters('wplms_unit_wrap', $class, $unit_id, $user_id);
if (have_posts()) {
    while (have_posts()) {
        the_post();
        ?>
<section id="content">
    <div class="<?php 
        echo vibe_get_container();
        ?>
">