<?php
/*
Plugin Name: Random Talk
Plugin URI: http://www.proyectoisla.com/mangasverdes/?page_id=1226
Description: Shows a random list of comments authors in your WordPress blog
Version: 1.0 Beta
Author: Manuel M. Almeida
Author URI: http://www.proyectoisla.com/mangasverdes

Based on Comment Plugger by Nick Momrik (MtDewVirus)
http://mtdewvirus.com/code/wordpress-plugins

Random Talk is a "social" WordPress plugin that allows yourself to include a list of comments authors outside the loop.
It serves to create a random blogroll of your users or random lists of your users with many possibilities.

Copyright (c) 2005 by Manuel M. Almeida

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
*/

//$limit is the number of authors you want to show.
//Change if you need and enjoy.

//Functions:

//random_talk: muestra sólo aquellos comentaristas que tienen URL (pingbacks y trackbacks no aparecerán).

function random_talk($limit=10) {
        global 
$wpdb;
        
$commenters $wpdb->get_results("SELECT comment_author, comment_author_url FROM $wpdb->comments WHERE comment_approved = '1' AND comment_type <> 'pingback' AND comment_type <> 'trackback' GROUP BY comment_author_url ORDER BY RAND() LIMIT $limit");
        foreach (
$commenters as $commenter) {
        if (!empty(
$commenter->comment_author_url)) {
        
$output .= '<li><a href="' $commenter->comment_author_url '" title="Visit ' $commenter->comment_author '">' $commenter->comment_author '</a> </li>';
       }
    }
        echo 
'<ul>' $output '</ul>';
}
        
        

//get_random_talk: muestra todos los comentaristas (pero no pingbacks ni trackbacks).

function get_random_talk($limit=10) {
        global 
$wpdb;
        
$commenters $wpdb->get_results("SELECT comment_author, comment_author_email, comment_author_url FROM $wpdb->comments WHERE comment_approved = '1' AND comment_type <> 'pingback' AND comment_type <> 'trackback' GROUP BY comment_author_email, comment_author ORDER BY RAND() LIMIT $limit");
        foreach (
$commenters as $commenter) {
        if (!empty(
$commenter->comment_author)) {
        if (!empty(
$commenter->comment_author_url))
        
$output .= '<li><a href="' $commenter->comment_author_url '" title="Visit ' $commenter->comment_author '">' $commenter->comment_author '</a> </li>';
        else 
$output .= '<li>' $commenter->comment_author ' </li>'
       }
    }
        echo 
'<ul>' $output '</ul>';
}



//all_random_talk: muestra todos los comentaristas, incluidos pingbacks and trackbacks.

function all_random_talk($limit=10) {
        global 
$wpdb;
        
$commenters $wpdb->get_results("SELECT comment_author, comment_author_email, comment_author_url FROM $wpdb->comments WHERE comment_approved = '1' GROUP BY comment_author_email, comment_author ORDER BY RAND() LIMIT $limit");
        foreach (
$commenters as $commenter) {
        if (!empty(
$commenter->comment_author)) {
        if (!empty(
$commenter->comment_author_url))
        
$output .= '<li><a href="' $commenter->comment_author_url '" title="Visit ' $commenter->comment_author '">' $commenter->comment_author '</a> </li>';
        else 
$output .= '<li>' $commenter->comment_author ' </li>'
       }
    }
        echo 
'<ul>' $output '</ul>';

}

?>