<?php
// ------------------------------------------------------------------------- //
//                XOOPS - PHP Content Management System                      //
//                       <http://www.xoops.org/>                             //
// ------------------------------------------------------------------------- //
// Based on:								     //
// myPHPNUKE Web Portal System - http://myphpnuke.com/	  		     //
// PHP-NUKE Web Portal System - http://phpnuke.org/	  		     //
// Thatware - http://thatware.org/					     //
// ------------------------------------------------------------------------- //
//  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., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
// ------------------------------------------------------------------------- //
function b_xoopsmembers_posters_show($options){
	$block = array();
	$block['content'] = "<table border='0' cellpadding='0' cellspacing='0' valign='top' width='100%'><tr><td class='bg2'><table width='100%' border='0' cellpadding='4' cellspacing='1'>\n";
	$criteria = array("level>0");
	$limit = (!empty($options[0])) ? $options[0] : 10;
	$size = sizeof($options);
	for ( $i = 2; $i < $size; $i++) {
		array_push($criteria, "rank<>".$options[$i]);
	}
	$topposters = XoopsUser::getAllUsers($criteria, true, "posts DESC", $limit);
	$count = 1;
	foreach ( $topposters as $tp ) {
		$block['content'] .= "<tr class='bg1'><td>".$count."</td>";
		if ( $options[1] == 1 ) {
			$avatar = $tp->getVar("user_avatar") ? "<img src='".XOOPS_URL."/images/avatar/".$tp->getVar("user_avatar")."' alt='' width='32' />" : "&nbsp;";
			$block['content'] .= "<td align='center'>$avatar</td>";
		}
		$block['content'] .= "<td><a href='".XOOPS_URL."/userinfo.php?uid=".$tp->getVar("uid")."'>".$tp->getVar("uname")."</a></td><td align='center'>".$tp->getVar("posts")."</td>";
		$count++;
	}
	$block['content'] .= "</tr></table></td></tr></table>\n";
	$block['title'] = _MB_MEMBERS_TITLE1;

	return $block;
}

function b_xoopsmembers_posters_edit($options) {
	include_once(XOOPS_ROOT_PATH."/class/xoopslists.php");
	$inputtag = "<input type='text' name='options[]' value='".$options[0]."' />";
	$form = sprintf(_MB_MEMBERS_DISPLAY,$inputtag);
	$form .= "<br />"._MB_MEMBERS_DISPLAYA."&nbsp;<input type='radio' id='options[]' name='options[]' value='1'";
	if ( $options[1] == 1 ) {
		$form .= " checked='checked'";
	}
	$form .= " />&nbsp;"._YES."<input type='radio' id='options[]' name='options[]' value='0'";
	if ( $options[1] == 0 ) {
		$form .= " checked='checked'";
	}
	$form .= " />&nbsp;"._NO."";
	$form .= "<br />"._MB_MEMBERS_NODISPGR."<br /><select id='options[]' name='options[]' multiple='multiple'>";
	$ranks = XoopsLists::getUserRankList();
	$size = sizeof($options);
	foreach ($ranks as $k => $v) {
		$sel = "";
		for ( $i = 2; $i < $size; $i++ ) {
			if ($k == $options[$i]) {
				$sel = " selected='selected'";
			}
		}
		$form .= "<option value='$k'$sel>$v</option>";
	}
	$form .= "</select>";
	return $form;
}
?>