From 2dedb86ba8c252d996f11d66d141fd642cd254e2 Mon Sep 17 00:00:00 2001 From: Cameron Date: Sat, 26 Mar 2016 15:17:11 -0700 Subject: [PATCH] Viewable By shortcode added. Forum deleted template corrected. --- e107_handlers/userclass_class.php | 11 ++++ e107_plugins/forum/forum_class.php | 36 +++++++++-- e107_plugins/forum/forum_viewforum.php | 49 +++++++++++++++ e107_plugins/forum/forum_viewtopic.php | 3 +- .../templates/forum_viewforum_template.php | 15 +++-- .../templates/forum_viewtopic_template.php | 60 +++++++++++++++++++ 6 files changed, 164 insertions(+), 10 deletions(-) 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 = " + +
+
Viewable by
+
+ ".$viewable." +
+
+ + "; +} +else +{ + $fVars->VIEWABLE_BY = ''; +} + + +// ------------------------------------------------------------ +///TODO XXX All these $fVars items need to be put into a shortcode class so they can be parsed with parms and wrappers. Big Job! + + $fVars->SEARCH = "
diff --git a/e107_plugins/forum/forum_viewtopic.php b/e107_plugins/forum/forum_viewtopic.php index 3d9f9a2f1..8692fc98a 100644 --- a/e107_plugins/forum/forum_viewtopic.php +++ b/e107_plugins/forum/forum_viewtopic.php @@ -226,7 +226,8 @@ if(is_array($FORUM_VIEWTOPIC_TEMPLATE) && deftrue('BOOTSTRAP',false)) $FORUMSTART = $FORUM_VIEWTOPIC_TEMPLATE['start']; $FORUMTHREADSTYLE = $FORUM_VIEWTOPIC_TEMPLATE['thread']; $FORUMEND = $FORUM_VIEWTOPIC_TEMPLATE['end']; - $FORUMREPLYSTYLE = $FORUM_VIEWTOPIC_TEMPLATE['replies']; + $FORUMREPLYSTYLE = $FORUM_VIEWTOPIC_TEMPLATE['replies']; + $FORUMDELETEDSTYLE = $FORUM_VIEWTOPIC_TEMPLATE['deleted']; } //TODO Clean up this mess!! diff --git a/e107_plugins/forum/templates/forum_viewforum_template.php b/e107_plugins/forum/templates/forum_viewforum_template.php index 01829d14d..6dff6ca35 100644 --- a/e107_plugins/forum/templates/forum_viewforum_template.php +++ b/e107_plugins/forum/templates/forum_viewforum_template.php @@ -350,11 +350,18 @@ $FORUM_VIEWFORUM_TEMPLATE['footer'] = "
{THREADPAGES}
{NEWTHREADBUTTONX}
-
-
- {ICONKEY} -
+ +
+
+
Status Keys
+
+ {ICONKEY} + +
+
+ {VIEWABLE_BY} + "; $FORUM_VIEWFORUM_TEMPLATE['end'] = " \n"; diff --git a/e107_plugins/forum/templates/forum_viewtopic_template.php b/e107_plugins/forum/templates/forum_viewtopic_template.php index 2b5be011a..089fbbc87 100644 --- a/e107_plugins/forum/templates/forum_viewtopic_template.php +++ b/e107_plugins/forum/templates/forum_viewtopic_template.php @@ -413,6 +413,66 @@ $FORUM_VIEWTOPIC_TEMPLATE['end'] = " $FORUM_VIEWTOPIC_TEMPLATE['replies'] = $FORUM_VIEWTOPIC_TEMPLATE['thread']; + + +$FORUM_VIEWTOPIC_TEMPLATE['deleted'] = " +
  • + + +
    + +
    +
    + +
    {AVATAR: shape=rounded}
    +
    {USERCOMBO}
    {CUSTOMTITLE}
    + +
    {POSTOPTIONS}

    {THREADDATESTAMP=relative}
    +
    +
    +

    +
    + {POSTDELETED} +
    +
    + + +
    +
    +   +
    +
    + {SIGNATURE=clean} +
    + +
    +
    +
    + + +
  • + + "; + + + $FORUM_VIEWTOPIC_WRAPPER['ATTACHMENTS'] = "
    {---}
    ";