1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-30 19:30:25 +02:00

#4929: Fix type mismatch in usage of e107forum::getForumClassMembers()

Also, `e107forum::getForumClassMembers()` is now documented and
deprecated because it has unintuitive return values.

Fixes: https://github.com/e107inc/e107/issues/4929
This commit is contained in:
Nick Liu
2022-12-25 11:58:46 +01:00
parent ec68c88910
commit 566cde0f4c
2 changed files with 24 additions and 11 deletions

View File

@@ -174,6 +174,22 @@ class e107forum
}
/**
* Get an array of the first alphabetical 50 usernames, user IDs, and the users' serialized user classes that match
* the forum's allowed viewers or a user class ID if the allowed viewers is a special user class except if the
* special user class is {@see e_UC_MAINADMIN} or {@see false} if the previous two possibilities are not encountered
*
* @deprecated v2.3.3 Due to the confusing usage, consider writing another method to get the list of members that
* can see the forum identified by its forum ID.
* @param $forumId int The ID from `e107_forum`.`forum_id`
* @param $type string Can only be "view"
* @return array|int|false When an array, the first 50 users, sorted alphabetically by username, that can view this
* forum, along with their user ID, username, and serialized user classes.
* When an int, the special user class ID as defined in {@see e107::set_constants()} except
* {@see e_UC_MAINADMIN}.
* When boolean false, this is an unhandled case probably due to the
* `e107_forum`.`forum_class` column missing from the table.
*/
function getForumClassMembers($forumId, $type='view')
{

View File

@@ -239,29 +239,26 @@
{
global $forum, $forumId;
if($users = $forum->getForumClassMembers($forumId))
if($usersOrUserClassId = $forum->getForumClassMembers($forumId))
{
$userList = array();
$viewable = e107::getUserClass()->getFixedClassDescription($users);
if(is_array($users))
if(is_array($usersOrUserClassId))
{
foreach($users as $user)
foreach($usersOrUserClassId as $user)
{
$userList[] = "<a href='" . e107::getUrl()->create('user/profile/view', $user) . "'>" . $user['user_name'] . "</a>";
}
$viewable = implode(', ', $userList);;
}
elseif($users == 0)
elseif($usersOrUserClassId == 0)
{
$viewable = '';
}
/*--
else
{
$viewable = e107::getUserClass()->getFixedClassDescription($users);
}
--*/
else
{
$viewable = e107::getUserClass()->getFixedClassDescription($usersOrUserClassId);
}
}
/*--