Minahito
minah****@users*****
2005年 12月 25日 (日) 16:00:00 JST
Index: xoops2jp/html/kernel/group.php diff -u xoops2jp/html/kernel/group.php:1.2 xoops2jp/html/kernel/group.php:1.2.8.1 --- xoops2jp/html/kernel/group.php:1.2 Fri Mar 18 21:52:14 2005 +++ xoops2jp/html/kernel/group.php Sun Dec 25 16:00:00 2005 @@ -1,5 +1,5 @@ <?php -// $Id: group.php,v 1.2 2005/03/18 12:52:14 onokazu Exp $ +// $Id: group.php,v 1.2.8.1 2005/12/25 07:00:00 minahito Exp $ // ------------------------------------------------------------------------ // // XOOPS - PHP Content Management System // // Copyright (c) 2000 XOOPS.org // @@ -430,7 +430,35 @@ function getUsersByGroup($groupid, $limit=0, $start=0) { $ret = array(); - $sql = 'SELECT uid FROM '.$this->db->prefix('groups_users_link').' WHERE groupid='.intval($groupid); + $sql = 'SELECT u.uid FROM ' . $this->db->prefix('users') . ' WHERE groupid='.intval($groupid); + + $result = $this->db->query($sql, $limit, $start); + if (!$result) { + return $ret; + } + while ($myrow = $this->db->fetchArray($result)) { + $ret[] = $myrow['uid']; + } + return $ret; + } + + /** + * @see getUsersByGroup + */ + function getUsersByNoGroup($groupid, $limit=0, $start=0) + { + $ret = array(); + + $groupid = intval($groupid); + $usersTable = $this->db->prefix('users'); + $linkTable = $this->db->prefix('groups_users_link'); + + $sql = "SELECT u.uid FROM ${usersTable} u LEFT JOIN ${linkTable} g ON u.uid=g.uid," . + "${usersTable} u2 LEFT JOIN ${linkTable} g2 ON u2.uid=g2.uid AND g2.groupid=${groupid} " . + "WHERE (g.groupid != ${groupid} OR g.groupid IS NULL) " . + "AND (g2.groupid = ${groupid} OR g2.groupid IS NULL) " . + "AND u.uid = u2.uid AND g2.uid IS NULL GROUP BY u.uid"; + $result = $this->db->query($sql, $limit, $start); if (!$result) { return $ret;