Ejemplo n.º 1
0
/**
 * Get array of latest comments
 *
 * @param array of params
 *			- Blog (object)
 *			- User (object)
 *			- limit (int) the number of comments to return
 *			- comment_ID (int) return specified comment or NULL to return all available
 *			- item_ID (int) return comments for specified item only
 * @return xmlrpcmsg
 */
function xmlrpc_get_comments($params, &$Blog)
{
    global $DB, $current_User;
    $params = array_merge(array('limit' => 0, 'comment_ID' => 0, 'item_ID' => 0, 'statuses' => '', 'types' => array('comment', 'trackback', 'pingback')), $params);
    $params['comment_ID'] = abs(intval($params['comment_ID']));
    $params['item_ID'] = abs(intval($params['item_ID']));
    if (empty($params['statuses'])) {
        // Return all except 'trash'
        $params['statuses'] = array('published', 'deprecated', 'draft');
    }
    if (!empty($params['comment_ID'])) {
        logIO('Getting comment #' . $params['comment_ID']);
        $filters = array('comment_ID' => $params['comment_ID'], 'types' => $params['types'], 'statuses' => $params['statuses']);
    } elseif (!empty($params['item_ID'])) {
        logIO('Getting comments to item #' . $params['item_ID']);
        $ItemCache =& get_ItemCache();
        $Item =& $ItemCache->get_by_ID($params['item_ID'], false, false);
        if (empty($Item)) {
            // Item not found
            return xmlrpcs_resperror(5, 'Requested post/Item (' . $params['item_ID'] . ') does not exist.');
        }
        if (!$Item->can_see_comments()) {
            // Cannot see comments
            return xmlrpcs_resperror(5, 'You are not allowed to view comments for this post/Item (' . $params['item_ID'] . ').');
        }
        $filters = array('post_ID' => $Item->ID, 'types' => $params['types'], 'statuses' => $params['statuses'], 'comments' => $params['limit'], 'order' => 'DESC');
    } else {
        logIO(sprintf('Trying to get latest comments (%s)', $params['limit'] ? $params['limit'] : 'all'));
        $filters = array('types' => $params['types'], 'statuses' => $params['statuses'], 'comments' => $params['limit'], 'order' => 'DESC');
    }
    //logIO( "Filters:\n".var_export($filters, true) );
    $CommentList = new CommentList2($Blog);
    // Filter list:
    $CommentList->set_filters($filters, false);
    // Get ready for display (runs the query):
    $CommentList->display_init();
    logIO('Comments found: ' . $CommentList->result_num_rows);
    $data = array();
    if ($CommentList->result_num_rows) {
        while ($Comment =& $CommentList->get_next()) {
            // Loop through comments:
            $Comment->get_Item();
            $data[] = array('dateCreated' => new xmlrpcval(datetime_to_iso8601($Comment->date, true), 'dateTime.iso8601'), 'date_created_gmt' => new xmlrpcval(datetime_to_iso8601($Comment->date, true), 'dateTime.iso8601'), 'user_id' => new xmlrpcval(intval($Comment->author_user_ID)), 'comment_id' => new xmlrpcval($Comment->ID), 'parent' => new xmlrpcval(intval($Comment->in_reply_to_cmt_ID)), 'status' => new xmlrpcval(wp_or_b2evo_comment_status($Comment->status, 'wp')), 'content' => new xmlrpcval($Comment->content), 'link' => new xmlrpcval($Comment->get_permanent_url()), 'post_id' => new xmlrpcval($Comment->Item->ID), 'post_title' => new xmlrpcval($Comment->Item->title), 'author' => new xmlrpcval($Comment->get_author_name()), 'author_url' => new xmlrpcval($Comment->get_author_url()), 'author_email' => new xmlrpcval($Comment->get_author_email()), 'author_ip' => new xmlrpcval($Comment->author_IP), 'type' => new xmlrpcval($Comment->type == 'comment' ? '' : $Comment->type));
        }
    }
    return $data;
}
Ejemplo n.º 2
0
$CommentList->display_if_empty(array('msg_empty' => T_('No replies yet...')));
if ($CommentList->result_num_rows > 0) {
    ?>
<table class="bForums fixed_layout evo_content_block" width="100%" cellspacing="1" cellpadding="2" border="0">
	<tr>
		<th class="col1"><?php 
    echo T_('Author');
    ?>
</th>
		<th><?php 
    echo T_('Message');
    ?>
</th>
	</tr>
<?php 
    while ($Comment =& $CommentList->get_next()) {
        // Loop through comments:
        // Load comment's Item object:
        $Item = $Comment->get_Item();
        // ------------------ COMMENT INCLUDED HERE ------------------
        skin_include('_item_comment.inc.php', array('Comment' => &$Comment, 'comment_start' => '<div class="bText">', 'comment_end' => '</div>', 'display_vote_helpful' => false));
        // Note: You can customize the default item comment by copying the generic
        // /skins/_item_comment.inc.php file into the current skin folder.
        // ---------------------- END OF COMMENT ---------------------
    }
    // End of comment loop.
    ?>
</table>
<?php 
}
echo_comment_moderate_js();
 /**
  * Display the widget!
  *
  * @param array MUST contain at least the basic display params
  */
 function display($params)
 {
     global $Blog;
     $this->init_display($params);
     $blog_ID = intval($this->disp_params['blog_ID']);
     $blogCache =& get_BlogCache();
     $listBlog = $blog_ID ? $blogCache->get_by_ID($blog_ID) : $Blog;
     // Create ItemList
     // Note: we pass a widget specific prefix in order to make sure to never interfere with the mainlist
     $limit = intval($this->disp_params['limit']);
     $order = $this->disp_params['disp_order'];
     $CommentList = new CommentList2($listBlog, $limit, 'CommentCache', $this->code . '_');
     $filters = array('types' => array('comment', 'trackback', 'pingback'), 'statuses' => array('published'), 'order' => $order, 'comments' => $limit);
     if (isset($this->disp_params['page'])) {
         $filters['page'] = $this->disp_params['page'];
     }
     // Filter list:
     $CommentList->set_filters($filters);
     // Get ready for display (runs the query):
     $CommentList->display_init();
     echo $this->disp_params['block_start'];
     // Display title if requested
     $this->disp_title();
     echo $this->disp_params['block_body_start'];
     echo $this->disp_params['list_start'];
     if (empty($this->disp_params['author_link_text'])) {
         $this->disp_params['author_link_text'] = 'login';
     }
     /**
      * @var Comment
      */
     while ($Comment =& $CommentList->get_next()) {
         // Loop through comments:
         // Load comment's Item object:
         $Comment->get_Item();
         echo $this->disp_params['item_start'];
         $Comment->author('', ' ', '', ' ', 'htmlbody', $this->disp_params['author_links'], $this->disp_params['author_link_text']);
         echo T_('on ');
         $Comment->permanent_link(array('text' => $Comment->Item->title, 'title' => $this->disp_params['hover_text']));
         echo $this->disp_params['item_end'];
     }
     // End of comment loop.}
     if (isset($this->disp_params['page'])) {
         if (empty($this->disp_params['pagination'])) {
             $this->disp_params['pagination'] = array();
         }
         $CommentList->page_links($this->disp_params['pagination']);
     }
     echo $this->disp_params['list_end'];
     echo $this->disp_params['block_body_end'];
     echo $this->disp_params['block_end'];
     return true;
 }
Ejemplo n.º 4
0
 function display_list_comments($limit = 6)
 {
     global $Blog, $app_version;
     if (version_compare($app_version, '4.0') < 0) {
         $CommentList = new CommentList($Blog, "'comment'", array('published'), '', '', 'DESC', '', $limit);
     } else {
         $CommentList = new CommentList2($Blog, $limit);
         // Filter list:
         $CommentList->set_filters(array('types' => array('comment'), 'statuses' => array('published'), 'post_ID' => NULL, 'order' => 'DESC'));
         // Get ready for display (runs the query):
         $CommentList->display_init();
     }
     if ($CommentList->result_num_rows > 0) {
         while ($Comment =& $CommentList->get_next()) {
             $Comment->get_Item();
             echo '<li class="clearfix"><a class="fadeThis" href="' . $Comment->get_permanent_url() . '"><span class="avatar post-thumb">' . $this->get_avatar($Comment, 'crop-48x48', 48) . '</span><span class="clearfix entry">' . $Comment->get_author_name() . ': <span class="details">' . strmaxlen($Comment->get_content('text'), 60) . '</span></span></a></li>';
         }
     }
     return false;
 }
Ejemplo n.º 5
0
/**
 * Show comments awaiting moderation
 *
 * @todo fp> move this to a more appropriate place
 *
 * @param integer blog ID
 * @param object CommentList
 * @param integer limit
 * @param array comment IDs to exclude
 * @param boolean TRUE - for script
 */
function show_comments_awaiting_moderation($blog_ID, $CommentList = NULL, $limit = 5, $comment_IDs = array(), $script = true)
{
    global $current_User, $dispatcher;
    if (is_null($CommentList)) {
        // Inititalize CommentList
        $BlogCache =& get_BlogCache();
        $Blog =& $BlogCache->get_by_ID($blog_ID, false, false);
        $CommentList = new CommentList2($Blog, NULL, 'CommentCache', 'cmnt_fullview_', 'fullview');
        $exlude_ID_list = NULL;
        if (!empty($comment_IDs)) {
            $exlude_ID_list = '-' . implode(",", $comment_IDs);
        }
        $moderation_statuses = explode(',', $Blog->get_setting('moderation_statuses'));
        // Filter list:
        $CommentList->set_filters(array('types' => array('comment', 'trackback', 'pingback'), 'statuses' => $moderation_statuses, 'comment_ID_list' => $exlude_ID_list, 'post_statuses' => array('published', 'community', 'protected'), 'order' => 'DESC', 'comments' => $limit));
        // Get ready for display (runs the query):
        $CommentList->display_init();
    }
    $new_comment_IDs = array();
    while ($Comment =& $CommentList->get_next()) {
        // Loop through comments:
        $new_comment_IDs[] = $Comment->ID;
        echo '<div id="comment_' . $Comment->ID . '" class="dashboard_post dashboard_post_' . ($CommentList->current_idx % 2 ? 'even' : 'odd') . '">';
        echo '<div class="floatright"><span class="note status_' . $Comment->status . '"><span>';
        $Comment->status();
        echo '</span></span></div>';
        if ($Comment->status !== 'draft' || $Comment->author_user_ID == $current_User->ID) {
            // Display Comment permalink icon
            echo '<span style="float: left; padding-right: 5px; margin-top: 4px">' . $Comment->get_permanent_link('#icon#') . '</span>';
        }
        echo '<h3 class="dashboard_post_title">';
        echo $Comment->get_title(array('author_format' => '<strong>%s</strong>', 'link_text' => 'avatar', 'thumb_size' => 'crop-top-15x15'));
        $comment_Item =& $Comment->get_Item();
        echo ' ' . T_('in response to') . ' <a href="?ctrl=items&amp;blog=' . $comment_Item->get_blog_ID() . '&amp;p=' . $comment_Item->ID . '"><strong>' . $comment_Item->dget('title') . '</strong></a>';
        echo '</h3>';
        echo '<div class="notes">';
        $Comment->rating(array('before' => '<div class="dashboard_rating">', 'after' => '</div> &bull; '));
        $Comment->date();
        $Comment->author_url_with_actions('', true);
        $Comment->author_email('', ' &bull; Email: <span class="bEmail">', '</span> &bull; ');
        $Comment->author_ip('IP: <span class="bIP">', '</span> ', true);
        $Comment->ip_country();
        $Comment->spam_karma(' &bull; ' . T_('Spam Karma') . ': %s%', ' &bull; ' . T_('No Spam Karma'));
        echo '</div>';
        echo '<div class="small">';
        $Comment->content('htmlbody', true);
        echo '</div>';
        echo '<div class="dashboard_action_area">';
        // Display edit button if current user has the rights:
        $redirect_to = NULL;
        if (!$script) {
            // Set page, where to redirect, because the function is called from async.php (regenerate_url gives => async.php)
            global $admin_url;
            $redirect_to = $admin_url . '?ctrl=dashboard&blog=' . $blog_ID;
        }
        echo '<div class="floatleft">';
        $Comment->edit_link(' ', ' ', get_icon('edit'), '#', 'roundbutton', '&amp;', true, $redirect_to);
        echo '<span class="roundbutton_group">';
        // Display publish NOW button if current user has the rights:
        $Comment->publish_link('', '', '#', '#', 'roundbutton_text', '&amp;', true, true);
        // Display deprecate button if current user has the rights:
        $Comment->deprecate_link('', '', '#', '#', 'roundbutton_text', '&amp;', true, true);
        // Display delete button if current user has the rights:
        $Comment->delete_link('', '', '#', '#', 'roundbutton_text', false, '&amp;', true, true);
        echo '</span>';
        echo '</div>';
        // Display Spam Voting system
        $Comment->vote_spam('', '', '&amp;', true, true);
        echo '<div class="clear"></div>';
        echo '</div>';
        echo '</div>';
    }
    if (!$script) {
        echo '<input type="hidden" id="new_badge" value="' . $CommentList->total_rows . '"/>';
    }
}