diff --git a/e107_handlers/userclass_class.php b/e107_handlers/userclass_class.php index 7666b1fbb..0e3439d9d 100644 --- a/e107_handlers/userclass_class.php +++ b/e107_handlers/userclass_class.php @@ -95,6 +95,17 @@ class user_class } + public function getFixedClassDescription($id) + { + if(isset($this->fixed_classes[$id])) + { + return $this->fixed_classes[$id]; + } + + return false; + } + + /** * Take a key value such as 'member' and return it's numerical value. * @param $text diff --git a/e107_plugins/forum/forum_class.php b/e107_plugins/forum/forum_class.php index 1c2f0b78c..1e516cddc 100644 --- a/e107_plugins/forum/forum_class.php +++ b/e107_plugins/forum/forum_class.php @@ -104,12 +104,12 @@ class e107forum */ } - /** - * Grab the forum data up front to reduce LEFT JOIN usage. Currently only forum_id and forum_sef but may be expanded as needed. - */ - function getForumData() + /** + * Grab the forum data up front to reduce LEFT JOIN usage. Currently only forum_id and forum_sef but may be expanded as needed. + */ + private function getForumData() { - $data = e107::getDb()->retrieve("SELECT forum_id, forum_sef FROM `#forum`", true); // no ordering for better performance. + $data = e107::getDb()->retrieve("SELECT forum_id, forum_sef, forum_class FROM `#forum`", true); // no ordering for better performance. $newData = array(); foreach($data as $row) @@ -138,6 +138,32 @@ class e107forum } + function getForumClassMembers($forumId, $type='view') + { + + $fieldTypes = array('view' => 'forum_class'); + $field = $fieldTypes[$type]; + + if(isset($this->forumData[$forumId][$field])) + { + $class = $this->forumData[$forumId]['forum_class']; + + if($class == 0 || ($class > 250 && $class < 256)) + { + return $class; + } + + + $qry = "SELECT user_id, user_name, user_class FROM `#user` WHERE FIND_IN_SET(".$class.", user_class) OR user_class = ".$class." ORDER by user_name LIMIT 50"; // FIND_IN_SET(user_class, ".$class.") + $users = e107::getDb()->retrieve($qry, true); + + return $users; + } + + return false; + + } + /** * @param $user integer userid (if empty "anon" will be used) diff --git a/e107_plugins/forum/forum_viewforum.php b/e107_plugins/forum/forum_viewforum.php index 1a4422b3f..7e1268686 100644 --- a/e107_plugins/forum/forum_viewforum.php +++ b/e107_plugins/forum/forum_viewforum.php @@ -339,6 +339,55 @@ else // v1.x } +// ----------------- { VIEWABLE_BY } --------------------------- + +if($users = $forum->getForumClassMembers($forumId)) +{ + $userList = array(); + if(is_array($users)) + { + foreach($users as $user) + { + $userList[] = "".$user['user_name'].""; + } + + $viewable = implode(', ', $userList);; + } + elseif($users == 0) + { + $viewable = ''; + } + else + { + $viewable = e107::getUserClass()->getFixedClassDescription($users); + } + +} + +if(!empty($viewable)) +{ + + $fVars->VIEWABLE_BY = " + +