<?php
function widget_contributors() {
	$options = get_option("widget_contributors");
	$admin = $options['admin'];
	global $wpdb; 
	echo '<ul class="authorlist">';
	if($admin==0) {
		$authors = $wpdb->get_results("SELECT ID, user_nicename from $wpdb->users WHERE display_name <> 'admin' ORDER BY display_name");
	} else {
		$authors = $wpdb->get_results("SELECT ID, user_nicename from $wpdb->users ORDER BY display_name");
	}
	foreach($authors as $author) {
		echo "<li>";
		echo "<a href=\"".get_bloginfo('url')."/?author=";
		echo $author->ID;
		echo "\">";
		echo get_avatar($author->ID);
		echo "</a>";
		echo '<div class="authname">';
		echo "<a href=\"".get_bloginfo('url')."/?author=";
		echo $author->ID;
		echo "\">";
		the_author_meta('display_name', $author->ID);
		echo "</a>";
		echo "</div>";
		echo "</li>";
		}
	echo '</ul>';
}

function widget_myContributors($args) {
	extract($args); 
	
	$options = get_option("widget_contributors");
	
	echo $before_widget;
    echo $before_title;
    echo $options['title'];
    echo $after_title;
	widget_contributors();
	echo $after_widget; 
}

function myContributors_control()
{
  $options = get_option("widget_contributors");

  if (!is_array( $options ))
	{
		$options = array(
		'title' => __('Contributors', "moderno"),
		'admin' => '0'
	    );
  }      

  if ($_POST['contributors-Submit'])
  {
    $options['title'] = htmlspecialchars($_POST['contributors-WidgetTitle']);
    $options['admin'] = htmlspecialchars($_POST['contributors-DiplayAdmin']);

    update_option("widget_contributors", $options);
  }

?>
  <p>
    <label><strong><?php _e('Title', "moderno"); ?>:</strong> </label><br />
    <input class="widefat" type="text" id="contributors-WidgetTitle" name="contributors-WidgetTitle" value="<?php echo $options['title'];?>" />
    <br /><br />
    <label><strong><?php _e('Display admin', "moderno"); ?>:</strong></label><br />
    <input type="radio" name="contributors-DiplayAdmin" value="1" <?php if($options['admin']==1) echo "checked"; ?> /><label>&nbsp;<?php _e('Yes', "moderno"); ?>&nbsp;&nbsp;&nbsp;</label>
    <input type="radio" name="contributors-DiplayAdmin" value="0" <?php if($options['admin']==0) echo "checked"; ?> /><label>&nbsp;<?php _e('No', "moderno"); ?></label>
    <input type="hidden" name="contributors-Submit" value="1" />
  </p>
<?php
}
wp_register_sidebar_widget( 'contributors', __('Mod - Contributors', "moderno"), 'widget_myContributors', array('description' => __('Displays a list of your blog contributors', "moderno")) );
wp_register_widget_control( 'contributors', __('Mod - Contributors', "moderno"), 'myContributors_control');

?>