Example #1
0
/**
 * Display comments results table
 *
 * @param array Params
 */
function comments_results_block($params = array())
{
    // Make sure we are not missing any param:
    $params = array_merge(array('edited_User' => NULL, 'results_param_prefix' => 'actv_comment_', 'results_title' => T_('Comments posted by the user'), 'results_no_text' => T_('User has not posted any comment yet')), $params);
    if (!is_logged_in()) {
        // Only logged in users can access to this function
        return;
    }
    global $current_User;
    if (!$current_User->check_perm('users', 'edit')) {
        // Check minimum permission:
        return;
    }
    $edited_User = $params['edited_User'];
    if (!$edited_User) {
        // No defined User, probably the function is calling from AJAX request
        $user_ID = param('user_ID', 'integer', 0);
        if (empty($user_ID)) {
            // Bad request, Exit here
            return;
        }
        $UserCache =& get_UserCache();
        if (($edited_User =& $UserCache->get_by_ID($user_ID, false)) === false) {
            // Bad request, Exit here
            return;
        }
    }
    global $DB;
    param('user_tab', 'string', '', true);
    param('user_ID', 'integer', 0, true);
    $SQL = new SQL();
    $SQL->SELECT('*');
    $SQL->FROM('T_comments');
    $SQL->WHERE('comment_author_ID = ' . $DB->quote($edited_User->ID));
    // Create result set:
    $comments_Results = new Results($SQL->get(), $params['results_param_prefix'], 'D');
    $comments_Results->Cache =& get_CommentCache();
    $comments_Results->title = $params['results_title'];
    $comments_Results->no_results_text = $params['results_no_text'];
    // Get a count of the comments which current user can delete
    $deleted_comments_count = count($edited_User->get_deleted_comments());
    if ($comments_Results->total_rows > 0 && $deleted_comments_count) {
        // Display action icon to delete all records if at least one record exists & current user can delete at least one comment posted by user
        $comments_Results->global_icon(sprintf(T_('Delete all comments posted by %s'), $edited_User->login), 'delete', '?ctrl=user&user_tab=activity&action=delete_all_comments&user_ID=' . $edited_User->ID . '&' . url_crumb('user'), ' ' . T_('Delete all'), 3, 4);
    }
    // Initialize Results object
    comments_results($comments_Results, array('field_prefix' => 'comment_', 'display_kind' => false, 'display_additional_columns' => true, 'plugin_table_name' => 'activity', 'display_spam' => false));
    if (is_ajax_content()) {
        // init results param by template name
        if (!isset($params['skin_type']) || !isset($params['skin_name'])) {
            debug_die('Invalid ajax results request!');
        }
        $comments_Results->init_params_by_skin($params['skin_type'], $params['skin_name']);
    }
    $display_params = array('before' => '<div class="results" style="margin-top:25px" id="comments_result">');
    $comments_Results->display($display_params);
    if (!is_ajax_content()) {
        // Create this hidden div to get a function name for AJAX request
        echo '<div id="' . $params['results_param_prefix'] . 'ajax_callback" style="display:none">' . __FUNCTION__ . '</div>';
    }
}
<?php

/**
 * This is the template that displays user's comments
 *
 * This file is not meant to be called directly.
 * It is meant to be called by an include in the main.page.php template.
 *
 * b2evolution - {@link http://b2evolution.net/}
 * Released under GNU GPL License - {@link http://b2evolution.net/about/gnu-gpl-license}
 * @copyright (c)2003-2015 by Francois Planque - {@link http://fplanque.com/}
 *
 * @package evoskins
 */
if (!defined('EVO_MAIN_INIT')) {
    die('Please, do not access this page directly.');
}
global $user_ID, $viewed_User, $display_params, $user_CommentList;
// Default params:
$params = array_merge(array('user_commentlist_title' => T_('Comments posted by %s'), 'user_commentlist_no_results' => T_('User has not posted any comment yet'), 'user_commentlist_col_post' => T_('Comment on:')), $params);
$user_CommentList->title = sprintf($params['user_commentlist_title'], $viewed_User->get_identity_link(array('link_text' => 'name')));
$user_CommentList->no_results_text = $params['user_commentlist_no_results'];
// Initialize Results object
comments_results($user_CommentList, array('field_prefix' => $user_CommentList->param_prefix, 'display_permalink' => false, 'display_item' => true, 'display_status' => true, 'display_kind' => false, 'display_spam' => false, 'display_author' => false, 'display_url' => false, 'display_email' => false, 'display_ip' => false, 'display_visibility' => false, 'display_actions' => false, 'col_post' => $params['user_commentlist_col_post']));
$user_CommentList->display($display_params);
if (!defined('EVO_MAIN_INIT')) {
    die('Please, do not access this page directly.');
}
/**
 * @var Blog
 */
global $Blog;
/**
 * @var CommentList
 */
global $CommentList;
/*
 * Display comments:
 */
$CommentList->query();
// Dispay a form to mass delete the comments:
display_comment_mass_delete($CommentList);
// Display title depending on selection params:
echo $CommentList->get_filter_title('<h2>', '</h2>', '<br />', NULL, 'htmlbody');
$CommentList->title = T_('Comment List');
if (check_comment_mass_delete($CommentList)) {
    // A form for mass deleting is availabl, Display link
    $CommentList->global_icon(T_('Delete all comments!'), 'delete', regenerate_url('action', 'action=mass_delete'), T_('Mass delete...'), 3, 3);
}
if ($CommentList->is_filtered()) {
    // List is filtered, offer option to reset filters:
    $CommentList->global_icon(T_('Reset all filters!'), 'reset_filters', '?ctrl=comments&amp;blog=' . $Blog->ID . '&amp;tab3=listview&amp;filter=reset', T_('Reset filters'), 3, 3);
}
// Initialize Results object
comments_results($CommentList);
$CommentList->display();