Minahito
minah****@users*****
2005年 12月 25日 (日) 19:52:36 JST
Index: xoops2jp/html/kernel/member.php diff -u xoops2jp/html/kernel/member.php:1.2.8.4 xoops2jp/html/kernel/member.php:1.2.8.5 --- xoops2jp/html/kernel/member.php:1.2.8.4 Sun Dec 25 16:10:19 2005 +++ xoops2jp/html/kernel/member.php Sun Dec 25 19:52:36 2005 @@ -1,5 +1,5 @@ <?php -// $Id: member.php,v 1.2.8.4 2005/12/25 07:10:19 minahito Exp $ +// $Id: member.php,v 1.2.8.5 2005/12/25 10:52:36 minahito Exp $ // ------------------------------------------------------------------------ // // XOOPS - PHP Content Management System // // Copyright (c) 2000 XOOPS.org // @@ -273,10 +273,28 @@ */ function addUserToGroup($group_id, $user_id) { - $mship =& $this->_mHandler->create(); - $mship->setVar('groupid', $group_id); - $mship->setVar('uid', $user_id); - return $this->_mHandler->insert($mship); + $group_ids = $this->getGroupsByUser($user_id); + if (!in_array($group_id, $group_ids)) { + $mship =& $this->_mHandler->create(); + $mship->setVar('groupid', $group_id); + $mship->setVar('uid', $user_id); + return $this->_mHandler->insert($mship); + } + + return true; + } + + + /** + * remove a one user from a group. + * @param int $group_id ID of the group + * @param int $user_id ID of the user + * @return bool success? + */ + function removeUserFromGroup($group_id, $user_id) + { + $user_ids = array($user_id); + return $this->removeUsersFromGroup($group_id, $user_ids); } /** @@ -431,8 +449,6 @@ */ function getUserCountByNoGroup($group_id) { - $ret = array(); - $groupid = intval($group_id); $usersTable = $this->_mHandler->db->prefix('users'); $linkTable = $this->_mHandler->db->prefix('groups_users_link'); @@ -445,13 +461,10 @@ $result = $this->_mHandler->db->query($sql); if (!$result) { - return $ret; - } - if (!$result) { return 0; } - list($count) = $this->_mHandler->db->fetchRow($result); + $count = $this->_mHandler->db->getRowsNum($result); return $count; }