示例#1
0
        if ($comusers_url and mso_get_option('allow_comment_comuser_url', 'general', 0)) {
            $comment_info .= ' <a href="' . $comusers_url . '" rel="nofollow" class="outlink"><img src="' . getinfo('template_url') . 'images/outlink.png" width="16" height="16" alt="link" title="' . tf('Сайт комментатора') . '"></a>';
        }
        $comment_info .= ' | <span class="date"><a href="#comment-' . $comments_id . '" id="comment-' . $comments_id . '">' . $comments_date . '</a></span>';
        if ($edit_link) {
            $comment_info .= ' | <a href="' . $edit_link . $comments_id . '">edit</a>';
        }
        if (!$comments_approved) {
            $comment_info .= ' | ' . tf('Ожидает модерации');
        }
        if ($f = mso_page_foreach('page-comments-out')) {
            require $f;
            // подключаем кастомный вывод
        } else {
            echo '<div class="comment-info">' . $comment_info . '</div>';
            echo '<div class="comments_content">' . mso_avatar($comment) . mso_comments_content($comments_content) . '</div>';
        }
        echo '<div class="clearfix"></div>';
        echo '</li>';
        //	pr($comment);
    }
    echo '</ol>';
    echo '</div>' . NR;
}
if ($page_comment_allow and $page_text_ok) {
    // если запрещены комментарии и от анонимов и от комюзеров, то выходим
    if (mso_get_option('allow_comment_anonim', 'general', '1') or mso_get_option('allow_comment_comusers', 'general', '1')) {
        if ($f = mso_page_foreach('page-comment-form-do')) {
            require $f;
        } else {
            echo '<div class="break"></div>' . mso_get_val('leave_a_comment_start', '<h3 class="comments">') . mso_get_option('leave_a_comment', 'templates', tf('Оставьте комментарий!')) . mso_get_val('leave_a_comment_end', '</h3>');
示例#2
0
function mso_get_comuser($id = 0, $args = array())
{
    global $MSO;
    if (!$id) {
        // не указан id, получаем его из сессии
        if (isset($MSO->data['session']['comuser']) and $MSO->data['session']['comuser']) {
            $id = $MSO->data['session']['comuser']['comusers_id'];
        } else {
            $id = mso_segment(2);
        }
        // или сегмент в url
    }
    if (!$id) {
        return array();
    }
    // нет номера, выходим
    if (!is_numeric($id)) {
        return array();
    }
    // если id указан не номером, выходим
    if (!isset($args['limit'])) {
        $args['limit'] = 20;
    }
    if (!isset($args['tags'])) {
        $args['tags'] = '<p><img><strong><em><i><b><u><s><font><pre><code><blockquote>';
    }
    if (!isset($args['order'])) {
        $args['order'] = 'comments_date';
    }
    if (!isset($args['asc'])) {
        $args['asc'] = 'desc';
    }
    $CI =& get_instance();
    $CI->db->select('comusers.*, COUNT(comments_comusers_id) as comusers_count_comment_real');
    $CI->db->from('comusers');
    $CI->db->where('comusers_id', $id);
    $CI->db->limit(1);
    // отдавать все комменты, включая и неотмодерированные
    //$CI->db->where('comments.comments_approved', '1');
    $CI->db->join('comments', 'comusers.comusers_id = comments.comments_comusers_id', 'left');
    $CI->db->group_by('comments_comusers_id');
    $query = $CI->db->get();
    if ($query->num_rows() > 0) {
        $comuser = $query->result_array();
        // данные комюзера
        // pr($comuser);
        $comuser_count_comment_first = $comuser[0]['comusers_count_comments'];
        // первоначальное значание колво комментариев
        // подсоединим к нему [comments] - все его комментарии
        $CI->db->select('comments.*, page.page_id, page.page_title, page.page_slug');
        $CI->db->from('comments');
        $CI->db->where('comments_comusers_id', $id);
        // $CI->db->where('page.page_status', 'publish');
        // $CI->db->where('page_date_publish <', date('Y-m-d H:i:s'));
        $CI->db->where('comments.comments_approved', '1');
        $CI->db->join('page', 'page.page_id = comments.comments_page_id');
        $CI->db->order_by('comments_date', $args['asc']);
        if ($args['limit']) {
            $CI->db->limit($args['limit']);
        }
        $query = $CI->db->get();
        $comments = array();
        // все комменты
        if ($query->num_rows() > 0) {
            // нужно обработать тексты комментариев на предмет всяких хуков и лишних тэгов
            $comments = $query->result_array();
            foreach ($comments as $key => $comment) {
                $comments[$key]['comments_content'] = mso_comments_content($comment['comments_content']);
            }
            $comuser[0]['comments'] = $comments;
            // $comuser[0]['comments'] = $query->result_array();
            $comuser[0]['comusers_count_comments'] = count($comments);
        } else {
            $comuser[0]['comments'] = array();
        }
        if ($comuser_count_comment_first != count($comments)) {
            mso_comuser_set_count_comment($id, count($comments));
        }
        // в секцию meta добавим все метаполя данного юзера
        $CI->db->select('meta_key, meta_value');
        $CI->db->from('meta');
        $CI->db->where('meta_table', 'comusers');
        $CI->db->where('meta_id_obj', $id);
        $query = $CI->db->get();
        if ($query->num_rows() > 0) {
            // переделаем полученный массив в key = value
            foreach ($query->result_array() as $val) {
                $comuser[0]['comusers_meta'][$val['meta_key']] = $val['meta_value'];
            }
        } else {
            $comuser[0]['comusers_meta'] = array();
        }
        // от вских гадостей
        $comuser[0]['comusers_url'] = mso_xss_clean($comuser[0]['comusers_url']);
        if ($comuser[0]['comusers_url'] and strpos($comuser[0]['comusers_url'], 'http://') === false) {
            $comuser[0]['comusers_url'] = 'http://' . $comuser[0]['comusers_url'];
        }
        $comuser[0]['comusers_msn'] = mso_xss_clean($comuser[0]['comusers_msn']);
        // twitter
        $comuser[0]['comusers_msn'] = mso_slug(str_replace('@', '', $comuser[0]['comusers_msn']));
        // подчистка
        $comuser[0] = mso_clean_post(array('comusers_nik' => 'base', 'comusers_icq' => 'base', 'comusers_jaber' => 'base', 'comusers_skype' => 'base', 'comusers_description' => 'base', 'comusers_msn' => 'base', 'comusers_url' => 'base'), $comuser[0]);
        // pr($comuser);
        return $comuser;
    } else {
        return array();
    }
}