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

Fixes #3757 - Check for forum categories present in NFP menu

This commit is contained in:
Tijn Kuyper
2019-03-26 21:16:05 +01:00
parent 87b053c095
commit 67129d70dc
2 changed files with 31 additions and 88 deletions

View File

@@ -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_014", "Scrolling layer height (in pixels)");
define("LAN_FORUM_MENU_015", "Leave blank for no scrolling"); define("LAN_FORUM_MENU_015", "Leave blank for no scrolling");
?> define("LAN_FORUM_MENU_016", "No forum categories created yet!");

View File

@@ -64,6 +64,12 @@ if(!class_exists('forum_newforumposts_menu'))
$forumList = implode(',', $this->forumObj->getForumPermList('view')); $forumList = implode(',', $this->forumObj->getForumPermList('view'));
// if forumlist is empty (no forum categories created yet), return false;
if(!$forumList)
{
return false;
}
$qry = ''; $qry = '';
$this->menuPref['layout'] = vartrue($this->menuPref['layout'], 'default'); $this->menuPref['layout'] = vartrue($this->menuPref['layout'], 'default');
@@ -156,107 +162,44 @@ if(!class_exists('forum_newforumposts_menu'))
} }
if($qry)
if($results = $sql->gen($qry))
{ {
if($results = $sql->gen($qry))
/* if($tp->thumbWidth() > 250) // Fix for unset image size.
{ {
$tp->setThumbSize(40,40,true); /* if($tp->thumbWidth() > 250) // Fix for unset image size.
}*/
$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'])
{ {
$poster = $row['post_user_anon']; $tp->setThumbSize(40,40,true);
} }*/
else
$sc = e107::getScBatch('view', 'forum')->setScVar('param',$param);
$list = $tp->parseTemplate($template['start'], true);
while($row = $sql->fetch())
{ {
if($row['user_name']) $row['thread_sef'] = $this->forumObj->getThreadSef($row);
{
$poster = "<a href='".e107::getUrl()->create('user/profile/view', array('name' => $row['user_name'], 'id' => $row['post_user']))."'>{$row['user_name']}</a>"; $sc->setScVar('postInfo', $row);
} $sc->setVars($row);
else $list .= $tp->parseTemplate($template['item'], true, $sc);
{
$poster = '[deleted]';
}
} }
$post = strip_tags($tp->toHTML($row['post_entry'], true, 'emotes_off, no_make_clickable', '', $pref['menu_wordwrap'])); $TOTALS = array('TOTAL_TOPICS'=>$this->total['topics'], 'TOTAL_VIEWS'=>$this->total['views'], 'TOTAL_REPLIES'=>$this->total['replies']);
$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 .= "<li class='media'>";
$list .= "<div class='media-left'>";
$list .= "<a href='".$url."'>".$tp->toAvatar($row, array('shape'=>'circle'))."</a>";
$list .= "</div>";
$list .= "<div class='media-body'>";
if (!empty($this->menuPref['title']))
{
$list .= "<h4 class='media-heading'><a href='{$url}'>{$topic}</a></h4>{$post}<br /><small class='text-muted muted'>".LAN_FORUM_MENU_001." {$poster} {$datestamp}</small>";
}
else
{
$list .= "<a href='{$url}'>".LAN_FORUM_MENU_001."</a> {$poster} <small class='text-muted muted'>{$datestamp}</small><br />{$post}<br />";
}
$list .= "</div></li>";
*/
$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 else
{ {
$text = LAN_FORUM_MENU_002; $text = LAN_FORUM_MENU_016;
} }
if(!empty($this->menuPref['caption'])) if(!empty($this->menuPref['caption']))
{ {
if (array_key_exists(e_LANGUAGE, $this->menuPref['caption'])) if (array_key_exists(e_LANGUAGE, $this->menuPref['caption']))