function _token_example_get_comment

Same name in other branches
  1. 7.x-1.x token_example/token_example.module \_token_example_get_comment()

Build a list of available comments.

Related topics

File

token_example/token_example.module, line 180

Code

function _token_example_get_comment() {
    if (!module_exists('comment') || !user_access('access comments') && !user_access('administer comments')) {
        return array();
    }
    $sql = 'SELECT c.cid, c.subject FROM {comments} c WHERE c.status = %d ORDER BY c.timestamp DESC';
    $query = db_query_range(db_rewrite_sql($sql, 'c', 'cid'), COMMENT_PUBLISHED, 0, 10);
    $comments = array();
    while ($result = db_fetch_object($query)) {
        $comments[$result->cid] = $result->subject;
    }
    $comments = array_map('check_plain', $comments);
    return $comments;
}