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

Some forum code cleanup #5320

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions e107_plugins/forum/forum.php
Original file line number Diff line number Diff line change
Expand Up @@ -402,9 +402,10 @@ function forum_track()
$tp = e107::getParser();

$trackDiz = ($trackEmailPref) ? LAN_FORUM_3040 : LAN_FORUM_3041;
$text = '';
// if($trackedThreadList = $forum->getTrackedThreadList(USERID, 'list')) //$trackedThreadList is not used anywhere in function, so why declare it?
if($forum->getTrackedThreadList(USERID, 'list'))


if($trackedThreadList = $forum->getTrackedThreadList(USERID, 'list'))
{

$viewed = $forum->threadGetUserViewed();
Expand Down Expand Up @@ -476,15 +477,19 @@ function forum_track()
}
// else
{
$tracktext = $forum_track_start . $forum_trackstring . $forum_track_end;
$text = $forum_track_start . $forum_trackstring . $forum_track_end;
}
}


$text = '';

// $text = '';
if(!$text)
{
e107::redirect();
exit;
}

$text .= $tracktext;
// $text .= $tracktext;
$text .= "<div class='center'>" . e107::getForm()->pagination(e107::url('forum', 'index'), LAN_BACK) . "</div>";


Expand Down
12 changes: 6 additions & 6 deletions e107_plugins/forum/forum_class.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function __construct($update= false)
}

$this->e107 = e107::getInstance();
$tp = e107::getParser();
// $tp = e107::getParser(); // $tp not used here, so why declare it? Better would be declare it as class scope var, ie $this->tp
$this->userViewed = array();
$this->modArray = array();

Expand Down Expand Up @@ -809,7 +809,7 @@ function threadViewed($threadId)

function getTrackedThreadList($id, $retType = 'array')
{
$e107 = e107::getInstance();
// $e107 = e107::getInstance(); // $e107 variable is not used anywhere in fuction, why declare it?
$sql = e107::getDb();

$id = (int)$id;
Expand All @@ -831,12 +831,12 @@ function getTrackedThreadList($id, $retType = 'array')
function isDuplicatePost($postInfo)
{

$sql = e107::getDb();
$tp = e107::getParser();
// $sql = e107::getDb(); // Only used once, why declare a variable? Better would be declare a class scope variable, something like $this->sql = e107::getDb()
// $tp = e107::getParser(); // Only used once, why declare a variable? Better would be declare a class scope variable, something like $this->tp = e107::getParser()

$post = $tp->toDB($postInfo['post_entry']);
$post = e107::getParser()->toDB($postInfo['post_entry']);

if($sql->select('forum_post', 'post_id', "post_forum = ".intval($postInfo['post_forum'])." AND post_entry='".$post."' AND post_user = ".USERID." LIMIT 1"))
if(e107::getDb()->select('forum_post', 'post_id', "post_forum = ".intval($postInfo['post_forum'])." AND post_entry='".$post."' AND post_user = ".USERID." LIMIT 1"))
{
return true;
}
Expand Down
41 changes: 20 additions & 21 deletions e107_plugins/forum/shortcodes/batch/forum_shortcodes.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,41 +32,41 @@ function sc_forumtitle()
}

// LEGACY shortcodes, to be deprecated & directly handled in template file???
function sc_threadtitle()
/* function sc_threadtitle()
{
return LAN_FORUM_0002;
}

function sc_replytitle()
*/
/* function sc_replytitle()
{
return LAN_FORUM_0003;
}

function sc_lastpostitle()
*/
/* function sc_lastpostitle()
{
return LAN_FORUM_0004;
}

function sc_infotitle()
*/
/* function sc_infotitle()
{
return LAN_FORUM_0009;
}

function sc_newthreadtitle()
*/
/* function sc_newthreadtitle()
{
return LAN_FORUM_0075;
}

function sc_postedtitle()
*/
/* function sc_postedtitle()
{
return LAN_FORUM_0074;
}

function sc_tracktitle()
*/
/* function sc_tracktitle()
{
return LAN_FORUM_0073;
}

*/
function sc_statlink()
{
return "<a href='".e107::url('forum','stats')."'>".LAN_FORUM_0017."</a>\n";
Expand All @@ -84,7 +84,11 @@ function sc_iconkey()
return null;
}

return "
// global $FORUM_TEMPLATE;
// if($FORUM_TEMPLATE['iconkey']){return $FORUM_TEMPLATE['iconkey'];}
$FORUM_TEMPLATE = varset($GLOBALS['FORUM_TEMPLATE']);
return (defset('BOOTSTRAP') && !empty($FORUM_TEMPLATE['iconkey'])) ? e107::getParser()->parseTemplate($FORUM_TEMPLATE['iconkey'], true, $this) :
"
<table class='table table-bordered' style='width:100%'>\n<tr>
<td style='width:2%'>".defset('IMAGE_new_small')."</td>
<td style='width:10%'><span class='smallblacktext'>".LAN_FORUM_0039."</span></td>
Expand Down Expand Up @@ -469,7 +473,6 @@ function sc_replies($parm = '')
return $this->sc_repliesx($parm);
}


function sc_threadsx($parm = null) // EQUAL TO SC_THREADS.......................
{
$val = ($this->var['forum_threads']) ? $this->var['forum_threads'] : '0';
Expand All @@ -482,7 +485,6 @@ function sc_threadsx($parm = null) // EQUAL TO SC_THREADS.......................
return e107::getParser()->toBadge($val);
}


function sc_repliesx($parm = null) // EQUAL TO SC_REPLIES.......................
{
//print_a($parm);
Expand All @@ -496,7 +498,6 @@ function sc_repliesx($parm = null) // EQUAL TO SC_REPLIES.......................
return e107::getParser()->toBadge($val);
}


function sc_forumsubforums()
{
return (!empty($this->var['text'])) ? "<br /><div class='smalltext'>".LAN_FORUM_0069.": {$this->var['text']}</div>":"";
Expand All @@ -507,13 +508,11 @@ function sc_lastpostuser()
return $this->sc_lastpost(array('type'=>'username'));
}


function sc_lastpostdate()
{
return $this->sc_lastpost(array('type'=>'datelink'));
return $this->sc_lastpost(array('type'=>'datelink'));
}


function sc_lastpost($parm = null)
{
if (empty($this->var['forum_lastpost_info']))
Expand Down
16 changes: 8 additions & 8 deletions e107_plugins/forum/shortcodes/batch/view_shortcodes.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,14 +188,14 @@ function sc_topic_datestamp($parm = null)
* @return string
* @example {TOPIC_LASTPOST_DATE: format=relative}
*/
function sc_topic_lastpost_date($parm = null)
function sc_topic_lastpost_date($parm = null)
{

/*
if(empty($this->var['thread_total_replies']))
{
return '';
}

*/

$mode = empty($parm['format']) ? 'forum' : $parm['format'];

Expand All @@ -206,8 +206,8 @@ function sc_topic_lastpost_date($parm = null)
function sc_topic_lastpost_author($parm = null)
{

if($this->var['thread_views'] && !empty($this->var['thread_total_replies']))
{
// if($this->var['thread_views'] && !empty($this->var['thread_total_replies']))
// {

if(!empty($this->var['thread_lastuser_username']))
{
Expand All @@ -224,9 +224,9 @@ function sc_topic_lastpost_author($parm = null)
return LAN_FORUM_1015;

}
}
// }

return ' - ';
// return ' - ';

}

Expand Down Expand Up @@ -1059,7 +1059,7 @@ function sc_nextprev()
function sc_track()
{

global $forum;
//global $forum; //$forum is not used inside function, so why global here?
if(!empty($this->pref['track']) && USER)
{
// BC Fix for old template.
Expand Down
8 changes: 4 additions & 4 deletions e107_plugins/forum/templates/forum_template.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
$FORUM_MAIN_START = "<div style='text-align:center'>\n<div class='spacer'>\n<table style='".USER_WIDTH."' class='fborder table'>\n<tr>\n<th colspan='2' style='width:60%; text-align:center' class='fcaption'>{FORUMTITLE}</th>\n<th style='width:10%; text-align:center' class='fcaption'>{LAN=FORUM_0002}</th>\n<th style='width:10%; text-align:center' class='fcaption'>{LAN=FORUM_0003}</th>\n<th style='width:20%; text-align:center' class='fcaption'>{LAN=FORUM_0004}</th>\n</tr>";
*/
// LEGACY definition with LAN Shortcodes ({THREADTITLE}, {REPLYTITLE}, {LASTPOSTITLE}).....
$FORUM_MAIN_START = "<div style='text-align:center'>\n<div class='spacer'>\n<table style='".USER_WIDTH."' class='fborder table'>\n<tr>\n<th colspan='2' style='width:60%; text-align:center' class='fcaption'>{FORUMTITLE}</th>\n<th style='width:10%; text-align:center' class='fcaption'>{THREADTITLE}</th>\n<th style='width:10%; text-align:center' class='fcaption'>{REPLYTITLE}</th>\n<th style='width:20%; text-align:center' class='fcaption'>{LASTPOSTITLE}</th>\n</tr>";
$FORUM_MAIN_START = "<div style='text-align:center'>\n<div class='spacer'>\n<table style='".USER_WIDTH."' class='fborder table'>\n<tr>\n<th colspan='2' style='width:60%; text-align:center' class='fcaption'>{FORUMTITLE}</th>\n<th style='width:10%; text-align:center' class='fcaption'>{LAN=FORUM_0002}</th>\n<th style='width:10%; text-align:center' class='fcaption'>{LAN=FORUM_0003}</th>\n<th style='width:20%; text-align:center' class='fcaption'>{LAN=FORUM_0004}</th>\n</tr>";
}
if (!isset($FORUM_MAIN_PARENT))
{
Expand All @@ -36,7 +36,7 @@
$FORUM_MAIN_END = "</table></div>\n<div class='spacer'>\n<table style='".USER_WIDTH."' class='fborder table'>\n<tr>\n<td colspan='2' style='width:60%' class='fcaption'>{LAN=FORUM_0009}</td>\n</tr>\n<tr>\n<td rowspan='4' style='width:5%; text-align:center' class='forumheader3'>{LOGO}</td>\n<td style='width:auto' class='forumheader3'>{USERINFO}</td>\n</tr>\n<tr>\n<td style='width:95%' class='forumheader3'>{INFO}</td>\n</tr><tr>\n<td style='width:95%' class='forumheader3'>{FORUMINFO}</td>\n</tr>\n<tr>\n<td style='width:95%' class='forumheader3'>{USERLIST}<br />{STATLINK}</td>\n</tr>\n</table>\n</div>\n<div class='spacer'>\n<table class='fborder table' style='".USER_WIDTH."'>\n<tr>\n<td class='forumheader3' style='text-align:center; width:33%'>{ICONKEY}</td>\n<td style='text-align:center; width:33%' class='forumheader3'>{SEARCH}</td>\n<td style='width:33%; text-align:center; vertical-align:middle' class='forumheader3'><span class='smallblacktext'>{PERMS}</span>\n</td>\n</tr>\n</table>\n</div>\n</div>";
*/
// LEGACY definition with LAN Shortcodes ({INFOTITLE}).....
$FORUM_MAIN_END = "</table></div>\n<div class='spacer'>\n<table style='".USER_WIDTH."' class='fborder table'>\n<tr>\n<td colspan='2' style='width:60%' class='fcaption'>{INFOTITLE}</td>\n</tr>\n<tr>\n<td rowspan='4' style='width:5%; text-align:center' class='forumheader3'>{LOGO}</td>\n<td style='width:auto' class='forumheader3'>{USERINFO}</td>\n</tr>\n<tr>\n<td style='width:95%' class='forumheader3'>{INFO}</td>\n</tr><tr>\n<td style='width:95%' class='forumheader3'>{FORUMINFO}</td>\n</tr>\n<tr>\n<td style='width:95%' class='forumheader3'>{USERLIST}<br />{STATLINK}</td>\n</tr>\n</table>\n</div>\n<div class='spacer'>\n<table class='fborder table' style='".USER_WIDTH."'>\n<tr>\n<td class='forumheader3' style='text-align:center; width:33%'>{ICONKEY}</td>\n<td style='text-align:center; width:33%' class='forumheader3'>{SEARCH}</td>\n<td style='width:33%; text-align:center; vertical-align:middle' class='forumheader3'><span class='smallblacktext'>{PERMS}</span>\n</td>\n</tr>\n</table>\n</div>\n</div>";
$FORUM_MAIN_END = "</table></div>\n<div class='spacer'>\n<table style='".USER_WIDTH."' class='fborder table'>\n<tr>\n<td colspan='2' style='width:60%' class='fcaption'>{LAN=FORUM_0009}</td>\n</tr>\n<tr>\n<td rowspan='4' style='width:5%; text-align:center' class='forumheader3'>{LOGO}</td>\n<td style='width:auto' class='forumheader3'>{USERINFO}</td>\n</tr>\n<tr>\n<td style='width:95%' class='forumheader3'>{INFO}</td>\n</tr><tr>\n<td style='width:95%' class='forumheader3'>{FORUMINFO}</td>\n</tr>\n<tr>\n<td style='width:95%' class='forumheader3'>{USERLIST}<br />{STATLINK}</td>\n</tr>\n</table>\n</div>\n<div class='spacer'>\n<table class='fborder table' style='".USER_WIDTH."'>\n<tr>\n<td class='forumheader3' style='text-align:center; width:33%'>{ICONKEY}</td>\n<td style='text-align:center; width:33%' class='forumheader3'>{SEARCH}</td>\n<td style='width:33%; text-align:center; vertical-align:middle' class='forumheader3'><span class='smallblacktext'>{PERMS}</span>\n</td>\n</tr>\n</table>\n</div>\n</div>";
}

if (!isset($FORUM_NEWPOSTS_START))
Expand All @@ -46,7 +46,7 @@
$FORUM_NEWPOSTS_START = "<div style='text-align:center'>\n<div class='spacer'>\n<table style='".USER_WIDTH."' class='fborder table'>\n<tr>\n<td style='width:3%' class='fcaption'>&nbsp;</td>\n<td style='width:60%' class='fcaption'>{LAN=FORUM_0075}</td>\n<td style='width:27%; text-align:center' class='fcaption'>{LAN=FORUM_0074}</td>\n</tr>";
*/
// LEGACY definition with LAN Shortcodes ({NEWTHREADTITLE}, {POSTEDTITLE}).....
$FORUM_NEWPOSTS_START = "<div style='text-align:center'>\n<div class='spacer'>\n<table style='".USER_WIDTH."' class='fborder table'>\n<tr>\n<td style='width:3%' class='fcaption'>&nbsp;</td>\n<td style='width:60%' class='fcaption'>{NEWTHREADTITLE}</td>\n<td style='width:27%; text-align:center' class='fcaption'>{POSTEDTITLE}</td>\n</tr>";
$FORUM_NEWPOSTS_START = "<div style='text-align:center'>\n<div class='spacer'>\n<table style='".USER_WIDTH."' class='fborder table'>\n<tr>\n<td style='width:3%' class='fcaption'>&nbsp;</td>\n<td style='width:60%' class='fcaption'>{LAN=FORUM_0075}</td>\n<td style='width:27%; text-align:center' class='fcaption'>{LAN=FORUM_0074}</td>\n</tr>";
}

if (!isset($FORUM_NEWPOSTS_MAIN))
Expand All @@ -66,7 +66,7 @@
$FORUM_TRACK_START = "<div style='text-align:center'>\n<div class='spacer'>\n<table style='".USER_WIDTH."' class='fborder table'>\n<tr>\n<td colspan='3' style='width:60%' class='fcaption'>{LAN=FORUM_0073}</td>\n</tr>\n";
*/
// LEGACY definition with LAN Shortcodes ({TRACKTITLE}).....
$FORUM_TRACK_START = "<div style='text-align:center'>\n<div class='spacer'>\n<table style='".USER_WIDTH."' class='fborder table'>\n<tr>\n<td colspan='3' style='width:60%' class='fcaption'>{TRACKTITLE}</td>\n</tr>\n";
$FORUM_TRACK_START = "<div style='text-align:center'>\n<div class='spacer'>\n<table style='".USER_WIDTH."' class='fborder table'>\n<tr>\n<td colspan='3' style='width:60%' class='fcaption'>{LAN=FORUM_0073}</td>\n</tr>\n";

if (!isset($FORUM_TRACK_MAIN))
{
Expand Down
Loading