4
I am not able to reproduce the error
plz modify wordpress/blocks/wp_authors.php to the following content, check if it works
// $Id: xoops_version.php,v 1.8 2005/06/03 01:35:02 phppp Exp $
// ------------------------------------------------------------------------ //
// XOOPS - PHP Content Management System //
// Copyright (c) 2000 XOOPS.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. //
// //
// You may not change or alter any portion of this comment or credits //
// of supporting developers from this source code or any supporting //
// source code which is considered copyrighted (c) material of the //
// original comment or credit authors. //
// //
// 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 //
// ------------------------------------------------------------------------ //
// Author: phppp (D.J.) //
// URL: http://xoopsforge.com, https://xoops.org.cn //
// ------------------------------------------------------------------------- //
class myXoopsUserHandler extends XoopsUserHandler
{
/**
* Constructor
*
* @param object $db reference to the {@link XoopsDatabase} object
**/
function myXoopsUserHandler(&$db) {
$this->XoopsUserHandler($db);
}
/**
* get a list of user realnames and their IDs
*
* @param object $criteria {@link CriteriaElement} object
* @param string extraIdentiferName
* @return array associative array of user-IDs and names
*/
function &getList($criteria = null, $limit = 0, $start = 0, $extraIdentiferName = "") {
$ret = array();
$profile_handler =& xoops_gethandler('profile');
$sql = 'SELECT '.$this->keyName.', '.$this->identifierName.(($extraIdentiferName)?", ".$extraIdentiferName:"").' FROM '.$this->table.' u, '.$profile_handler->table.' p WHERE u.'.$this->keyName.' = p.'.$this->_pHandler->keyName;
if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
$clause = $criteria->render();
if ($clause != "") {
$sql .= ' AND '.$clause;
}
if ($criteria->getSort() != '') {
$sql .= ' ORDER BY '.$criteria->getSort().' '.$criteria->getOrder();
}
else {
$sql .= ' ORDER BY '.$this->identifierName;
}
$limit = $criteria->getLimit();
$start = $criteria->getStart();
}
$result = $this->db->query($sql, $limit, $start);
if (!$result) {
return $ret;
}
$myts =& MyTextSanitizer::getInstance();
while ($myrow = $this->db->fetchArray($result)) {
//identifiers should be textboxes, so sanitize them like that
$ret[$myrow[$this->keyName]] =
empty($myrow[$extraIdentiferName])?
$myts->htmlSpecialChars($myrow[$this->identifierName]):
$myts->htmlSpecialChars($myrow[$extraIdentiferName]);
}
return $ret;
}
}
function b_wordpress_authors_show($options)
{
$block['content'] = ".list_authors_xoops($options[0], $options[1], $options[2])."";
$block['content'] = encoding_wp2xoops($block['content']);
return $block;
}
function b_wordpress_authors_edit($options)
{
$form = _MB_WORDPRESS_COUNT.". $options[0] . "' />";
$form .= "
"._MB_WORDPRESS_EXCLUEDEADMIN . "radio" name="options[1]" value="1"";
if ($options[1] == 1) $form .= " checked="checked"";
$form .= " />"._YES."; radio" name="options[1]" value="0"";
if ($options[1] == 0) $form .= " checked="checked"";
$form .= " />"._NO;
$form .= "
"._MB_WORDPRESS_REALNAME . "radio" name="options[2]" value="1"";
if ($options[2] == 1) $form .= " checked="checked"";
$form .= " />"._YES."; radio" name="options[2]" value="0"";
if ($options[2] == 0) $form .= " checked="checked"";
$form .= " />"._NO;
return $form;
}
function list_authors_xoops($count = 10, $exclude_admin = true, $show_realname = false)
{
/* For wp blocks */
global $wpdb, $wp_query, $wp_rewrite;
global $m, $monthnum, $year, $timedifference, $month, $month_abbrev, $weekday, $weekday_initial, $weekday_abbrev, $posts, $category_posts, $use_cache;
/* */
$myts =& MyTextSanitizer::getInstance();
$member_handler =& xoops_getHandler("member");
if($exclude_admin){
$admins = implode(",",$member_handler->getUsersByGroup(XOOPS_GROUP_ADMIN));
}
require(dirname(__FILE__).'/../wp-config.php');
$query = "SELECT COUNT(ID) AS pcount, post_author AS uid from $wpdb->posts WHERE post_status = 'publish' " . ($exclude_admin ? "AND post_author NOT IN (".$admins.") " : '') . " GROUP BY post_author ORDER BY pcount DESC";
$_authors = $wpdb->get_results($query);
if(!is_array($_authors) || count($_authors) == 0) return null;
$authors = array();
foreach($_authors as $author) {
$authors[$author->uid] = $author->pcount;
}
$uids = "(".implode(",", array_keys($authors)).")";
if(empty($show_realname)){
$users = $member_handler->getUserList(new Criteria("uid", $uids, "IN"));
}else{
$user_handler = new myXoopsUserHandler($GLOBALS["xoopsDB"]);
$users = $user_handler->getList(new Criteria("uid", $uids, "IN"), 0, 0, "name");
}
$author_link ="";
foreach(array_keys($authors) as $uid) {
$author_link .= "$uid, $users[$uid])."" title="Posts by ".$myts->htmlspecialchars($users[$uid])."">".$myts->htmlspecialchars($users[$uid])." (".intval($authors[$uid]).")";
}
return $author_link;
}
?>