Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from Dec 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 16 additions & 0 deletions e107_plugins/forum/forum_class.php
Expand Up @@ -174,6 +174,22 @@ function getForumSef($threadInfo)

}

/**
* 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')
{

Expand Down
19 changes: 8 additions & 11 deletions e107_plugins/forum/shortcodes/batch/viewforum_shortcodes.php
Expand Up @@ -239,29 +239,26 @@ function sc_viewable_by()
{
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);
}
}

/*--
Expand Down