From 67129d70dc0e9ad5715a7df66fa433cbf8c20acd Mon Sep 17 00:00:00 2001 From: Tijn Kuyper Date: Tue, 26 Mar 2019 21:16:05 +0100 Subject: [PATCH] Fixes #3757 - Check for forum categories present in NFP menu --- .../forum/languages/English/English_menu.php | 2 +- e107_plugins/forum/newforumposts_menu.php | 117 +++++------------- 2 files changed, 31 insertions(+), 88 deletions(-) diff --git a/e107_plugins/forum/languages/English/English_menu.php b/e107_plugins/forum/languages/English/English_menu.php index f8d3512fb..3172e6a8a 100755 --- a/e107_plugins/forum/languages/English/English_menu.php +++ b/e107_plugins/forum/languages/English/English_menu.php @@ -26,4 +26,4 @@ define("LAN_FORUM_MENU_013", "Use zero on a quiet site; setting a value in days define("LAN_FORUM_MENU_014", "Scrolling layer height (in pixels)"); define("LAN_FORUM_MENU_015", "Leave blank for no scrolling"); -?> \ No newline at end of file +define("LAN_FORUM_MENU_016", "No forum categories created yet!"); \ No newline at end of file diff --git a/e107_plugins/forum/newforumposts_menu.php b/e107_plugins/forum/newforumposts_menu.php index 0e5a9b025..f19823060 100755 --- a/e107_plugins/forum/newforumposts_menu.php +++ b/e107_plugins/forum/newforumposts_menu.php @@ -64,6 +64,12 @@ if(!class_exists('forum_newforumposts_menu')) $forumList = implode(',', $this->forumObj->getForumPermList('view')); + // if forumlist is empty (no forum categories created yet), return false; + if(!$forumList) + { + return false; + } + $qry = ''; $this->menuPref['layout'] = vartrue($this->menuPref['layout'], 'default'); @@ -156,107 +162,44 @@ if(!class_exists('forum_newforumposts_menu')) } - - if($results = $sql->gen($qry)) + if($qry) { - - /* if($tp->thumbWidth() > 250) // Fix for unset image size. + if($results = $sql->gen($qry)) { - $tp->setThumbSize(40,40,true); - }*/ - - $sc = e107::getScBatch('view', 'forum')->setScVar('param',$param); - - $list = $tp->parseTemplate($template['start'], true); - - while($row = $sql->fetch()) - { - $row['thread_sef'] = $this->forumObj->getThreadSef($row); - - - - $sc->setScVar('postInfo', $row); - $sc->setVars($row); - $list .= $tp->parseTemplate($template['item'], true, $sc); - - - /* - $datestamp = $tp->toDate($row['post_datestamp'], 'relative'); - $id = $row['thread_id']; - $topic = ($row['thread_datestamp'] == $row['post_datestamp'] ? '' : 'Re:'); - $topic .= strip_tags($tp->toHTML($row['thread_name'], true, 'emotes_off, no_make_clickable, parse_bb', '', $pref['menu_wordwrap'])); - - $row['thread_sef'] = $this->forumObj->getThreadSef($row); - - if($row['post_user_anon']) + /* if($tp->thumbWidth() > 250) // Fix for unset image size. { - $poster = $row['post_user_anon']; - } - else + $tp->setThumbSize(40,40,true); + }*/ + + $sc = e107::getScBatch('view', 'forum')->setScVar('param',$param); + + $list = $tp->parseTemplate($template['start'], true); + + while($row = $sql->fetch()) { - if($row['user_name']) - { - $poster = " $row['user_name'], 'id' => $row['post_user']))."'>{$row['user_name']}"; - } - else - { - $poster = '[deleted]'; - } + $row['thread_sef'] = $this->forumObj->getThreadSef($row); + + $sc->setScVar('postInfo', $row); + $sc->setVars($row); + $list .= $tp->parseTemplate($template['item'], true, $sc); } - $post = strip_tags($tp->toHTML($row['post_entry'], true, 'emotes_off, no_make_clickable', '', $pref['menu_wordwrap'])); - $post = $tp->text_truncate($post, varset($this->menuPref['characters'],120), varset($this->menuPref['postfix'],'...')); - - // Count previous posts for calculating proper (topic) page number for the current post. - // $postNum = $sql2->count('forum_post', '(*)', "WHERE post_id <= " . $row['post_id'] . " AND post_thread = " . $row['thread_id'] . " ORDER BY post_id ASC"); - // $postPage = ceil($postNum / vartrue($this->plugPref['postspage'], 10)); // Calculate (topic) page number for the current post. - // $thread = $sql->retrieve('forum_thread', '*', 'thread_id = ' . $row['thread_id']); // Load thread for passing it to e107::url(). - - // Create URL for post. - // like: e107_plugins/forum/forum_viewtopic.php?f=post&id=1 - $url = e107::url('forum', 'topic', $row, array( - 'query' => array( - 'f' => 'post', - 'id' => intval($row['post_id']) // proper page number - ), - )); - - - $list .= "
  • "; - - $list .= ""; - - $list .= "
    "; - - if (!empty($this->menuPref['title'])) - { - $list .= "

    {$topic}

    {$post}
    ".LAN_FORUM_MENU_001." {$poster} {$datestamp}"; - } - else - { - $list .= "".LAN_FORUM_MENU_001." {$poster} {$datestamp}
    {$post}
    "; - } - - $list .= "
  • "; - */ + $TOTALS = array('TOTAL_TOPICS'=>$this->total['topics'], 'TOTAL_VIEWS'=>$this->total['views'], 'TOTAL_REPLIES'=>$this->total['replies']); + $list .= $tp->parseTemplate($template['end'], true, $TOTALS); + $text = $list; + } + else + { + $text = LAN_FORUM_MENU_002; } - - $TOTALS = array('TOTAL_TOPICS'=>$this->total['topics'], 'TOTAL_VIEWS'=>$this->total['views'], 'TOTAL_REPLIES'=>$this->total['replies']); - - $list .= $tp->parseTemplate($template['end'], true, $TOTALS); - - $text = $list; } else { - $text = LAN_FORUM_MENU_002; + $text = LAN_FORUM_MENU_016; } - if(!empty($this->menuPref['caption'])) { if (array_key_exists(e_LANGUAGE, $this->menuPref['caption']))