From 594cddae6efa9e0eb797eb71eb47e61f59d95749 Mon Sep 17 00:00:00 2001 From: Cameron Date: Thu, 21 Jan 2021 13:04:54 -0800 Subject: [PATCH] Some forum code cleanup --- e107_plugins/forum/forum.php | 929 +++++----- e107_plugins/forum/forum_admin.php | 1635 +---------------- e107_plugins/forum/forum_conf.php | 222 --- e107_plugins/forum/forum_post.php | 6 +- e107_plugins/forum/forum_stats.php | 5 +- e107_plugins/forum/forum_test.php | 20 - e107_plugins/forum/forum_update.php | 915 ++++----- e107_plugins/forum/forum_uploads.php | 19 +- e107_plugins/forum/forum_viewforum.php | 8 +- .../forum/languages/English/English_front.php | 2 +- 10 files changed, 981 insertions(+), 2780 deletions(-) delete mode 100644 e107_plugins/forum/forum_conf.php delete mode 100644 e107_plugins/forum/forum_test.php diff --git a/e107_plugins/forum/forum.php b/e107_plugins/forum/forum.php index 445772e03..236d6fdda 100644 --- a/e107_plugins/forum/forum.php +++ b/e107_plugins/forum/forum.php @@ -11,13 +11,13 @@ */ if(!defined('e107_INIT')) { - require_once(__DIR__.'/../../class2.php'); + require_once(__DIR__ . '/../../class2.php'); } $e107 = e107::getInstance(); $tp = e107::getParser(); $sql = e107::getDb(); -if (!$e107->isInstalled('forum')) +if(!$e107->isInstalled('forum')) { e107::redirect(); exit; @@ -25,193 +25,214 @@ if (!$e107->isInstalled('forum')) e107::lan('forum', "front", true); -if(!deftrue('BOOTSTRAP')) + +class forum_front { - $bcDefs = array( - 'FORLAN_11' => 'LAN_FORUM_0039', - 'FORLAN_12' => 'LAN_FORUM_0040', - 'FORLAN_18' => 'LAN_FORUM_0041', - ); + private $sc; - e107::getLanguage()->bcDefs($bcDefs); -} - - -require_once(e_PLUGIN.'forum/forum_class.php'); -$forum = new e107forum; - -if(e_AJAX_REQUEST) -{ - if(varset($_POST['action']) == 'track') + function __construct($forum) { - $forum->ajaxTrack(); + $this->init($forum); } -} -/* -if ($untrackId = varset($_REQUEST['untrack'])) -{ - $forum->track('del', USERID, $untrackId); - header('location:'.$e107->url->create('forum/thread/track', array(), 'full=1&encode=0')); - exit; -} -*/ + /** -if(isset($_GET['f'])) -{ - if(isset($_GET['id'])) + */ + public function init($forum) { - $id = (int)$_GET['id']; - } - switch($_GET['f']) - { - case 'mfar': - $forum->forumMarkAsRead($id); - header('location:'.e_SELF); - exit; - break; + global $FORUM_TEMPLATE, $FORUM_MAIN_FORUM, $forumList ; - case 'rules': - include_once(HEADERF); + $ns = e107::getRender(); + $tp = e107::getParser(); - forum_rules('show'); - include_once(FOOTERF); - exit; - break; + $text = ''; - case 'track': - include_once(HEADERF); - - forum_track(); - include_once(FOOTERF); - exit; - break; - } -} -else -{ - e107::canonical('forum'); -} - - - -/** @var forum_shortcodes $sc */ -$sc = e107::getScBatch('forum', true); - - -if(empty($FORUM_TEMPLATE)) -{ - // Override with theme template - if(THEME_LEGACY !== true) //v2.x - { - $FORUM_TEMPLATE = e107::getTemplate('forum','forum'); // required to use v2.x wrapper shortcode wrappers. - } - elseif (file_exists(THEME.'forum_template.php')) //v1.x fallback. - { - include(e_PLUGIN.'forum/templates/forum_template.php'); - include_once(THEME.'forum_template.php'); - } - elseif(file_exists(THEME.'templates/forum/forum_template.php')) - { - // $FORUM_TEMPLATE = e107::getTemplate('forum','forum'); - require_once(THEME.'templates/forum/forum_template.php'); - } - else - { - require_once(e_PLUGIN.'forum/templates/forum_template.php'); - } -} - -if(is_array($FORUM_TEMPLATE) && THEME_LEGACY !== true) // new v2.x format. -{ - - if(varset($FORUM_TEMPLATE['main-start'])) // correction of previous v2.x setup. - { - $FORUM_TEMPLATE['main']['start'] = $FORUM_TEMPLATE['main-start']; - $FORUM_TEMPLATE['main']['parent'] = $FORUM_TEMPLATE['main-parent']; - $FORUM_TEMPLATE['main']['forum'] = $FORUM_TEMPLATE['main-forum']; - $FORUM_TEMPLATE['main']['end'] = $FORUM_TEMPLATE['main-end']; - } - - $FORUM_MAIN_START = $FORUM_TEMPLATE['main']['start']; - $FORUM_MAIN_PARENT = $FORUM_TEMPLATE['main']['parent']; - $FORUM_MAIN_PARENT_END = varset($FORUM_TEMPLATE['main']['parent_end']); - $FORUM_MAIN_FORUM = $FORUM_TEMPLATE['main']['forum']; - $FORUM_MAIN_END = $FORUM_TEMPLATE['main']['end']; - - $FORUM_NEWPOSTS_START = $FORUM_TEMPLATE['main']['start']; // $FORUM_TEMPLATE['new-start']; - $FORUM_NEWPOSTS_MAIN = $FORUM_TEMPLATE['main']['forum']; // $FORUM_TEMPLATE['new-main']; - $FORUM_NEWPOSTS_END = $FORUM_TEMPLATE['main']['end']; // $FORUM_TEMPLATE['new-end']; -} - -require_once(HEADERF); - -$forumList = $forum->forumGetForumList(); -$newflag_list = $forum->forumGetUnreadForums(); - -$sc->newFlagList = $newflag_list; - - -if (!$forumList) -{ - $ns->tablerender(LAN_PLUGIN_FORUM_NAME, LAN_FORUM_0067, 'forum-empty'); - require_once(FOOTERF); - exit; -} - -$forum_string = ''; - -foreach ($forumList['parents'] as $parent) -{ - - $parent = (array) $parent; - - $sc->setVars($parent); -// $sc->setScVar('forumParent', $parent); - $sc->wrapper('forum/main/parent'); - - $forum_string .= $tp->parseTemplate($FORUM_MAIN_PARENT, true, $sc); - - $fid = $parent['forum_id']; - if (empty($forumList['forums'][$parent['forum_id']])) - { - $text .= "".LAN_FORUM_0068.""; - } - else - { - //TODO: Rework the restricted string - foreach($forumList['forums'][$parent['forum_id']] as $f) + if(!deftrue('BOOTSTRAP')) { - if ($f['forum_class'] == e_UC_ADMIN && ADMIN) + $bcDefs = array( + 'FORLAN_11' => 'LAN_FORUM_0039', + 'FORLAN_12' => 'LAN_FORUM_0040', + 'FORLAN_18' => 'LAN_FORUM_0041', + ); + + e107::getLanguage()->bcDefs($bcDefs); + } + + + + + if(e_AJAX_REQUEST) + { + if(varset($_POST['action']) == 'track') { - $forum_string .= parse_forum($f, LAN_FORUM_0005); + $forum->ajaxTrack(); } - elseif($f['forum_class'] == e_UC_MEMBER && USER) + + } + + /* + if ($untrackId = varset($_REQUEST['untrack'])) + { + $forum->track('del', USERID, $untrackId); + header('location:'.$e107->url->create('forum/thread/track', array(), 'full=1&encode=0')); + exit; + } + */ + + if(isset($_GET['f'])) + { + + $id = (isset($_GET['id'])) ? (int) $_GET['id'] : null; + + + switch($_GET['f']) { - $forum_string .= parse_forum($f, LAN_FORUM_0006); - } - elseif($f['forum_class'] == e_UC_READONLY) - { - $forum_string .= parse_forum($f, LAN_FORUM_0007); - } - elseif($f['forum_class'] && check_class($f['forum_class'])) - { - $forum_string .= parse_forum($f, LAN_FORUM_0008); - } - elseif(!$f['forum_class']) - { - $forum_string .= parse_forum($f); + case 'mfar': + $forum->forumMarkAsRead($id); + header('location:' . e_SELF); + exit; + break; + + case 'rules': + include_once(HEADERF); + + forum_rules('show'); + include_once(FOOTERF); + exit; + break; + + case 'track': + include_once(HEADERF); + + forum_track(); + include_once(FOOTERF); + exit; + break; } } - if (isset($FORUM_MAIN_PARENT_END)) + else { + e107::canonical('forum'); + } + + + /** @var forum_shortcodes $this->sc */ + $this->sc = e107::getScBatch('forum', true); + + + if(empty($FORUM_TEMPLATE)) + { + // Override with theme template + if(THEME_LEGACY !== true) //v2.x + { + $FORUM_TEMPLATE = e107::getTemplate('forum', 'forum'); // required to use v2.x wrapper shortcode wrappers. + } + elseif(file_exists(THEME . 'forum_template.php')) //v1.x fallback. + { + include(e_PLUGIN . 'forum/templates/forum_template.php'); + include_once(THEME . 'forum_template.php'); + } + elseif(file_exists(THEME . 'templates/forum/forum_template.php')) + { + // $FORUM_TEMPLATE = e107::getTemplate('forum','forum'); + require_once(THEME . 'templates/forum/forum_template.php'); + } + else + { + require_once(e_PLUGIN . 'forum/templates/forum_template.php'); + } + } + + if(is_array($FORUM_TEMPLATE) && THEME_LEGACY !== true) // new v2.x format. + { + + if(varset($FORUM_TEMPLATE['main-start'])) // correction of previous v2.x setup. + { + $FORUM_TEMPLATE['main']['start'] = $FORUM_TEMPLATE['main-start']; + $FORUM_TEMPLATE['main']['parent'] = $FORUM_TEMPLATE['main-parent']; + $FORUM_TEMPLATE['main']['forum'] = $FORUM_TEMPLATE['main-forum']; + $FORUM_TEMPLATE['main']['end'] = $FORUM_TEMPLATE['main-end']; + } + + $FORUM_MAIN_START = $FORUM_TEMPLATE['main']['start']; + $FORUM_MAIN_PARENT = $FORUM_TEMPLATE['main']['parent']; + $FORUM_MAIN_PARENT_END = varset($FORUM_TEMPLATE['main']['parent_end']); + $FORUM_MAIN_FORUM = $FORUM_TEMPLATE['main']['forum']; + $FORUM_MAIN_END = $FORUM_TEMPLATE['main']['end']; + + $FORUM_NEWPOSTS_START = $FORUM_TEMPLATE['main']['start']; // $FORUM_TEMPLATE['new-start']; + $FORUM_NEWPOSTS_MAIN = $FORUM_TEMPLATE['main']['forum']; // $FORUM_TEMPLATE['new-main']; + $FORUM_NEWPOSTS_END = $FORUM_TEMPLATE['main']['end']; // $FORUM_TEMPLATE['new-end']; + } + + require_once(HEADERF); + + $forumList = $forum->forumGetForumList(); + $newflag_list = $forum->forumGetUnreadForums(); + + $this->sc->newFlagList = $newflag_list; + + + if(!$forumList) + { + $ns->tablerender(LAN_PLUGIN_FORUM_NAME, LAN_FORUM_0067, 'forum-empty'); + require_once(FOOTERF); + return null; + } + + $forum_string = ''; + + foreach($forumList['parents'] as $parent) + { + + $parent = (array) $parent; + + $this->sc->setVars($parent); +// $this->sc->setScVar('forumParent', $parent); + $this->sc->wrapper('forum/main/parent'); + + $forum_string .= $tp->parseTemplate($FORUM_MAIN_PARENT, true, $this->sc); + + $fid = $parent['forum_id']; + if(empty($forumList['forums'][$parent['forum_id']])) + { + $text .= "" . LAN_FORUM_0068 . ""; + } + else + { + //TODO: Rework the restricted string + foreach($forumList['forums'][$parent['forum_id']] as $f) + { + if($f['forum_class'] == e_UC_ADMIN && ADMIN) + { + $forum_string .= $this->parse_forum($f, LAN_FORUM_0005); + } + elseif($f['forum_class'] == e_UC_MEMBER && USER) + { + $forum_string .= $this->parse_forum($f, LAN_FORUM_0006); + } + elseif($f['forum_class'] == e_UC_READONLY) + { + $forum_string .= $this->parse_forum($f, LAN_FORUM_0007); + } + elseif($f['forum_class'] && check_class($f['forum_class'])) + { + $forum_string .= $this->parse_forum($f, LAN_FORUM_0008); + } + elseif(!$f['forum_class']) + { + $forum_string .= $this->parse_forum($f); + } + } + if(isset($FORUM_MAIN_PARENT_END)) + { //-- $forum_string .= $tp->simpleParse($FORUM_MAIN_PARENT_END, $pVars); - $forum_string .= $tp->parseTemplate($FORUM_MAIN_PARENT_END, true, $sc); + $forum_string .= $tp->parseTemplate($FORUM_MAIN_PARENT_END, true, $this->sc); + } + } } - } -} //if (e_QUERY == 'track') @@ -219,325 +240,339 @@ foreach ($forumList['parents'] as $parent) //} -if (e_QUERY == 'new') -{ -//-- $nVars = new e_vars; - $newThreadList = $forum->threadGetNew(10); - foreach($newThreadList as $thread) - { - $sc->setVars($thread); - $forum_newstring .= $tp->parseTemplate($FORUM_NEWPOSTS_MAIN, true, $sc); - } - - if (empty($newThreadList)) - { - $forum_newstring = $tp->parseTemplate($FORUM_NEWPOSTS_MAIN, true, $sc); - - } - - $forum_new_start = $tp->parseTemplate($FORUM_NEWPOSTS_START, true, $sc); - $forum_new_end = $tp->parseTemplate($FORUM_NEWPOSTS_END, true, $sc); - - if ($forum->prefs->get('enclose')) - { - $ns->tablerender($forum->prefs->get('title'), $forum_new_start.$forum_newstring.$forum_new_end, 'forum'); - } - else - { - echo $forum_new_start.$forum_newstring.$forum_new_end; - } -} - - - -$breadarray = array( - array('text'=> $forum->prefs->get('title'), 'url' => e107::url('forum','index') ) -); - -e107::breadcrumb($breadarray); - -$sc->wrapper('forum/main/start'); -$forum_main_start = $tp->parseTemplate($FORUM_MAIN_START, true, $sc); -//-- $forum_main_end = $tp->simpleParse($FORUM_MAIN_END, $fVars); - -$sc->wrapper('forum/main/end'); -$forum_main_end = $tp->parseTemplate($FORUM_MAIN_END, true, $sc); - -if ($forum->prefs->get('enclose')) -{ - $ns->tablerender($forum->prefs->get('title'), $forum_main_start.$forum_string.$forum_main_end, 'forum'); -} -else -{ - echo $forum_main_start.$forum_string.$forum_main_end; -} - - -require_once(FOOTERF); - -function forum_rules($action = 'check') -{ - if (ADMIN == true) - { - $type = 'forum_rules_admin'; - } - elseif(USER == true) - { - $type = 'forum_rules_member'; - } - else - { - $type = 'forum_rules_guest'; - } - $result = e107::getDb()->select('generic', 'gen_chardata', "gen_type = '$type' AND gen_intdata = 1"); - if ($action == 'check') { return $result; } - - if ($result) - { - $row = e107::getDb()->fetch(); - $rules_text = e107::getParser()->toHTML($row['gen_chardata'], true); - } - else - { - $rules_text = LAN_FORUM_0072; - } - - $text = ''; - - if(deftrue('BOOTSTRAP')) - { - $breadarray = array( - array('text'=> e107::pref('forum','title', LAN_PLUGIN_FORUM_NAME), 'url' => e107::url('forum','index') ), - array('text'=>LAN_FORUM_0016, 'url'=>null) - ); - - $text = e107::getForm()->breadcrumb($breadarray); - e107::breadcrumb($breadarray); // assign to {---BREADCRUMB---} - } - - $text .= "
".$rules_text."
"; - $text .= "
".e107::getForm()->pagination(e107::url('forum','index'), LAN_BACK)."
"; - - e107::getRender()->tablerender(LAN_FORUM_0016, $text, 'forum-rules'); -} - - -function forum_track() -{ - global $forum; - - $trackPref = $forum->prefs->get('track'); - $trackEmailPref = $forum->prefs->get('trackemail',true); - - - if(empty($trackPref)) - { - echo "Disabled"; - return false; - } - - - $FORUM_TEMPLATE = null; - - include(e_PLUGIN.'forum/templates/forum_template.php'); - - // Override with theme template - if (file_exists(THEME.'forum_template.php')) - { - include(THEME.'forum_template.php'); - } - elseif(file_exists(THEME.'templates/forum/forum_template.php')) - { - require(THEME.'templates/forum/forum_template.php'); - } - - $IMAGE_nonew_small = IMAGE_nonew_small; - $IMAGE_new_small = IMAGE_new_small; - - if(is_array($FORUM_TEMPLATE) && deftrue('BOOTSTRAP',false)) // new v2.x format. - { - $FORUM_TRACK_START = $FORUM_TEMPLATE['track']['start']; // $FORUM_TEMPLATE['track-start']; - $FORUM_TRACK_MAIN = $FORUM_TEMPLATE['track']['item']; // $FORUM_TEMPLATE['track-main']; - $FORUM_TRACK_END = $FORUM_TEMPLATE['track']['end']; // $FORUM_TEMPLATE['track-end']; - - $IMAGE_nonew_small = IMAGE_nonew; - $IMAGE_new_small = IMAGE_new; - - } - - $sql = e107::getDb(); - $tp = e107::getParser(); - - $trackDiz = ($trackEmailPref) ? LAN_FORUM_3040 : LAN_FORUM_3041; - - - if($trackedThreadList = $forum->getTrackedThreadList(USERID, 'list')) - { - - $viewed = $forum->threadGetUserViewed(); - - $qry = "SELECT t.*,th.*, f.*,u.user_name FROM `#forum_track` AS t - LEFT JOIN `#forum_thread` AS th ON t.track_thread = th.thread_id - LEFT JOIN `#forum` AS f ON th.thread_forum_id = f.forum_id - LEFT JOIN `#user` AS u ON th.thread_lastuser = u.user_id - WHERE t.track_userid = ".USERID." ORDER BY th.thread_lastpost DESC"; - - $forum_trackstring = ''; - $data = array(); - if($sql->gen($qry)) + if(e_QUERY == 'new') { - while($row = $sql->fetch()) + $forum_newstring = ''; +//-- $nVars = new e_vars; + $newThreadList = $forum->threadGetNew(10); + foreach($newThreadList as $thread) { - // e107::getDebug()->log($row); - $row['thread_sef'] = eHelper::title2sef($row['thread_name'],'dashl'); + $this->sc->setVars($thread); + $forum_newstring .= $tp->parseTemplate($FORUM_NEWPOSTS_MAIN, true, $this->sc); + } - $data['NEWIMAGE'] = $IMAGE_nonew_small; + if(empty($newThreadList)) + { + $forum_newstring = $tp->parseTemplate($FORUM_NEWPOSTS_MAIN, true, $this->sc); - if ($row['thread_datestamp'] > USERLV && !in_array($row['thread_id'], $viewed)) - { - $data['NEWIMAGE'] = $IMAGE_new_small; - } + } - $data['LASTPOSTUSER'] = !empty($row['user_name']) ? " $row['user_name'], 'id' => $row['thread_lastuser']))."'>".$row['user_name']."" : LAN_ANONYMOUS; - $data['LASTPOSTDATE'] = $tp->toDate($row['thread_lastpost'],'relative'); + $forum_new_start = $tp->parseTemplate($FORUM_NEWPOSTS_START, true, $this->sc); + $forum_new_end = $tp->parseTemplate($FORUM_NEWPOSTS_END, true, $this->sc); - $buttonId = "forum-track-button-".intval($row['thread_id']); - - $forumUrl = e107::url('forum','forum',$row); - $threadUrl = e107::url('forum','topic',$row, array('query'=>array('last'=>1))); // ('forum/thread/view', $row); // configs will be able to map thread_* vars to the url - $data['TRACKPOSTNAME'] = "". $row['forum_name']." / ".$tp->toHTML($row['thread_name'], false, 'TITLE').''; - // $data['UNTRACK'] = "".LAN_FORUM_0070.""; - - - $data['UNTRACK'] = "".IMAGE_track.""; - - $data['_WRAPPER_'] = 'forum/track/item'; - $forum_trackstring .= $tp->parseTemplate($FORUM_TRACK_MAIN, true, $data); + if($forum->prefs->get('enclose')) + { + $ns->tablerender($forum->prefs->get('title'), $forum_new_start . $forum_newstring . $forum_new_end, 'forum'); + } + else + { + echo $forum_new_start . $forum_newstring . $forum_new_end; } } - // print_a($FORUM_TRACK_START); + $breadarray = array( + array('text' => $forum->prefs->get('title'), 'url' => e107::url('forum', 'index')) + ); + + e107::breadcrumb($breadarray); + + $this->sc->wrapper('forum/main/start'); + $forum_main_start = $tp->parseTemplate($FORUM_MAIN_START, true, $this->sc); +//-- $forum_main_end = $tp->simpleParse($FORUM_MAIN_END, $fVars); + + $this->sc->wrapper('forum/main/end'); + $forum_main_end = $tp->parseTemplate($FORUM_MAIN_END, true, $this->sc); + + if($forum->prefs->get('enclose')) + { + $ns->tablerender($forum->prefs->get('title'), $forum_main_start . $forum_string . $forum_main_end, 'forum'); + } + else + { + echo $forum_main_start . $forum_string . $forum_main_end; + } + + + require_once(FOOTERF); + } + + + function forum_rules($action = 'check') + { + + if(ADMIN == true) + { + $type = 'forum_rules_admin'; + } + elseif(USER == true) + { + $type = 'forum_rules_member'; + } + else + { + $type = 'forum_rules_guest'; + } + $result = e107::getDb()->select('generic', 'gen_chardata', "gen_type = '$type' AND gen_intdata = 1"); + if($action == 'check') + { + return $result; + } + + if($result) + { + $row = e107::getDb()->fetch(); + $rules_text = e107::getParser()->toHTML($row['gen_chardata'], true); + } + else + { + $rules_text = LAN_FORUM_0072; + } + + $text = ''; + if(deftrue('BOOTSTRAP')) { $breadarray = array( - array('text'=> e107::pref('forum','title', LAN_PLUGIN_FORUM_NAME), 'url' => e107::url('forum','index') ), - array('text'=>LAN_FORUM_0030, 'url'=>null) + array('text' => e107::pref('forum', 'title', LAN_PLUGIN_FORUM_NAME), 'url' => e107::url('forum', 'index')), + array('text' => LAN_FORUM_0016, 'url' => null) ); + $text = e107::getForm()->breadcrumb($breadarray); e107::breadcrumb($breadarray); // assign to {---BREADCRUMB---} - - $data['FORUM_BREADCRUMB'] = e107::getForm()->breadcrumb($breadarray); } - $data['_WRAPPER_'] = 'forum/track/start'; - $forum_track_start = $tp->parseTemplate($FORUM_TRACK_START, true, $data); + $text .= "
" . $rules_text . "
"; + $text .= "
" . e107::getForm()->pagination(e107::url('forum', 'index'), LAN_BACK) . "
"; - $data['_WRAPPER_'] = 'forum/track/end'; - $forum_track_end = $tp->parseTemplate($FORUM_TRACK_END, true, $data); - - - // if ($forum->prefs->get('enclose')) - { - // $ns->tablerender($forum->prefs->get('title'), $forum_track_start.$forum_trackstring.$forum_track_end, array('forum', 'main1')); - } - // else - { - $tracktext = $forum_track_start.$forum_trackstring.$forum_track_end; - } + e107::getRender()->tablerender(LAN_FORUM_0016, $text, 'forum-rules'); } - $text =''; - - - - $text .= $tracktext; - $text .= "
".e107::getForm()->pagination(e107::url('forum','index'), LAN_BACK)."
"; - - - e107::getRender()->tablerender(LAN_FORUM_0030, $text, 'forum-track'); - - return null; -} - - - -function parse_forum($f, $restricted_string = '') -{ - - global $FORUM_MAIN_FORUM, $forumList, $sc; - - $tp = e107::getParser(); - - if(!empty($forumList['subs']) && is_array($forumList['subs'][$f['forum_id']])) + function forum_track() { - $lastPost = explode('.', $f['forum_lastpost_info']); - $lastpost_datestamp = reset($lastPost); - $ret = parse_subs($forumList, $f['forum_id'], $lastpost_datestamp); - $f['forum_threads'] += $ret['threads']; - $f['forum_replies'] += $ret['replies']; - if(isset($ret['lastpost_info'])) + global $forum; + + $trackPref = $forum->prefs->get('track'); + $trackEmailPref = $forum->prefs->get('trackemail', true); + + + if(empty($trackPref)) { - $f['forum_lastpost_info'] = $ret['lastpost_info']; - $f['forum_lastpost_user'] = $ret['lastpost_user']; - $f['forum_lastpost_user_anon'] = $ret['lastpost_user_anon']; - $f['user_name'] = $ret['user_name']; + echo "Disabled"; + + return false; } - $f['text'] = $ret['text']; + + $FORUM_TEMPLATE = null; + + include(e_PLUGIN . 'forum/templates/forum_template.php'); + + // Override with theme template + if(file_exists(THEME . 'forum_template.php')) + { + include(THEME . 'forum_template.php'); + } + elseif(file_exists(THEME . 'templates/forum/forum_template.php')) + { + require(THEME . 'templates/forum/forum_template.php'); + } + + $IMAGE_nonew_small = IMAGE_nonew_small; + $IMAGE_new_small = IMAGE_new_small; + + if(is_array($FORUM_TEMPLATE) && deftrue('BOOTSTRAP', false)) // new v2.x format. + { + $FORUM_TRACK_START = $FORUM_TEMPLATE['track']['start']; // $FORUM_TEMPLATE['track-start']; + $FORUM_TRACK_MAIN = $FORUM_TEMPLATE['track']['item']; // $FORUM_TEMPLATE['track-main']; + $FORUM_TRACK_END = $FORUM_TEMPLATE['track']['end']; // $FORUM_TEMPLATE['track-end']; + + $IMAGE_nonew_small = IMAGE_nonew; + $IMAGE_new_small = IMAGE_new; + + } + + $sql = e107::getDb(); + $tp = e107::getParser(); + + $trackDiz = ($trackEmailPref) ? LAN_FORUM_3040 : LAN_FORUM_3041; + + + if($trackedThreadList = $forum->getTrackedThreadList(USERID, 'list')) + { + + $viewed = $forum->threadGetUserViewed(); + + $qry = "SELECT t.*,th.*, f.*,u.user_name FROM `#forum_track` AS t + LEFT JOIN `#forum_thread` AS th ON t.track_thread = th.thread_id + LEFT JOIN `#forum` AS f ON th.thread_forum_id = f.forum_id + LEFT JOIN `#user` AS u ON th.thread_lastuser = u.user_id + WHERE t.track_userid = " . USERID . " ORDER BY th.thread_lastpost DESC"; + + $forum_trackstring = ''; + $data = array(); + if($sql->gen($qry)) + { + while($row = $sql->fetch()) + { + // e107::getDebug()->log($row); + $row['thread_sef'] = eHelper::title2sef($row['thread_name'], 'dashl'); + + $data['NEWIMAGE'] = $IMAGE_nonew_small; + + if($row['thread_datestamp'] > USERLV && !in_array($row['thread_id'], $viewed)) + { + $data['NEWIMAGE'] = $IMAGE_new_small; + } + + $data['LASTPOSTUSER'] = !empty($row['user_name']) ? " $row['user_name'], 'id' => $row['thread_lastuser'])) . "'>" . $row['user_name'] . "" : LAN_ANONYMOUS; + $data['LASTPOSTDATE'] = $tp->toDate($row['thread_lastpost'], 'relative'); + + $buttonId = "forum-track-button-" . intval($row['thread_id']); + + $forumUrl = e107::url('forum', 'forum', $row); + $threadUrl = e107::url('forum', 'topic', $row, array('query' => array('last' => 1))); // ('forum/thread/view', $row); // configs will be able to map thread_* vars to the url + $data['TRACKPOSTNAME'] = "" . $row['forum_name'] . " / " . $tp->toHTML($row['thread_name'], false, 'TITLE') . ''; + // $data['UNTRACK'] = "".LAN_FORUM_0070.""; + + + $data['UNTRACK'] = "" . IMAGE_track . ""; + + $data['_WRAPPER_'] = 'forum/track/item'; + $forum_trackstring .= $tp->parseTemplate($FORUM_TRACK_MAIN, true, $data); + } + } + // print_a($FORUM_TRACK_START); + + + if(deftrue('BOOTSTRAP')) + { + $breadarray = array( + array('text' => e107::pref('forum', 'title', LAN_PLUGIN_FORUM_NAME), 'url' => e107::url('forum', 'index')), + array('text' => LAN_FORUM_0030, 'url' => null) + ); + + e107::breadcrumb($breadarray); // assign to {---BREADCRUMB---} + + $data['FORUM_BREADCRUMB'] = e107::getForm()->breadcrumb($breadarray); + } + + $data['_WRAPPER_'] = 'forum/track/start'; + $forum_track_start = $tp->parseTemplate($FORUM_TRACK_START, true, $data); + + $data['_WRAPPER_'] = 'forum/track/end'; + $forum_track_end = $tp->parseTemplate($FORUM_TRACK_END, true, $data); + + + // if ($forum->prefs->get('enclose')) + { + // $ns->tablerender($forum->prefs->get('title'), $forum_track_start.$forum_trackstring.$forum_track_end, array('forum', 'main1')); + } + // else + { + $tracktext = $forum_track_start . $forum_trackstring . $forum_track_end; + } + } + + + $text = ''; + + + $text .= $tracktext; + $text .= "
" . e107::getForm()->pagination(e107::url('forum', 'index'), LAN_BACK) . "
"; + + + e107::getRender()->tablerender(LAN_FORUM_0030, $text, 'forum-track'); + + return null; } - $sc->setVars($f); - $sc->wrapper('forum/main/forum'); - - return $tp->parseTemplate($FORUM_MAIN_FORUM, true, $sc); -} - - - -function parse_subs($forumList, $id, $lastpost_datestamp) -{ - - $tp = e107::getParser(); - $ret = array(); - - $subList = $forumList['subs'][$id]; - - $ret['text'] = ''; - $ret['threads'] = 0; - $ret['replies'] = 0; - - foreach($subList as $sub) + private function parse_forum($f, $restricted_string = '') { - // print_a($sub); - $ret['text'] .= ($ret['text'] ? ', ' : ''); + global $FORUM_MAIN_FORUM, $forumList; - $urlData = $sub; - $urlData['parent_sef'] = $forumList['all'][$sub['forum_sub']]['forum_sef']; // = array('parent_sef'=> - $suburl = e107::url('forum','forum', $urlData); + $tp = e107::getParser(); - $ret['text'] .= "".$tp->toHTML($sub['forum_name']).''; - $ret['threads'] += $sub['forum_threads']; - $ret['replies'] += $sub['forum_replies']; - $tmp = explode('.', $sub['forum_lastpost_info']); - - if($tmp[0] > $lastpost_datestamp) + if(!empty($forumList['subs']) && is_array($forumList['subs'][$f['forum_id']])) { - $ret['lastpost_info'] = $sub['forum_lastpost_info']; - $ret['lastpost_user'] = $sub['forum_lastpost_user']; - $ret['lastpost_user_anon'] = $sub['forum_lastpost_user_anon']; - $ret['user_name'] = $sub['user_name']; - $lastpost_datestamp = $tmp[0]; + $lastPost = explode('.', $f['forum_lastpost_info']); + $lastpost_datestamp = reset($lastPost); + $ret = $this->parse_subs($forumList, $f['forum_id'], $lastpost_datestamp); + + $f['forum_threads'] += $ret['threads']; + $f['forum_replies'] += $ret['replies']; + if(isset($ret['lastpost_info'])) + { + $f['forum_lastpost_info'] = $ret['lastpost_info']; + $f['forum_lastpost_user'] = $ret['lastpost_user']; + $f['forum_lastpost_user_anon'] = $ret['lastpost_user_anon']; + $f['user_name'] = $ret['user_name']; + } + + $f['text'] = $ret['text']; } + + $this->sc->setVars($f); + + $this->sc->wrapper('forum/main/forum'); + + return $tp->parseTemplate($FORUM_MAIN_FORUM, true, $this->sc); } - return $ret; + function parse_subs($forumList, $id, $lastpost_datestamp) + { + + $tp = e107::getParser(); + $ret = array(); + + $subList = $forumList['subs'][$id]; + + $ret['text'] = ''; + $ret['threads'] = 0; + $ret['replies'] = 0; + + foreach($subList as $sub) + { + // print_a($sub); + + $ret['text'] .= ($ret['text'] ? ', ' : ''); + + $urlData = $sub; + $urlData['parent_sef'] = $forumList['all'][$sub['forum_sub']]['forum_sef']; // = array('parent_sef'=> + $suburl = e107::url('forum', 'forum', $urlData); + + $ret['text'] .= "" . $tp->toHTML($sub['forum_name']) . ''; + $ret['threads'] += $sub['forum_threads']; + $ret['replies'] += $sub['forum_replies']; + $tmp = explode('.', $sub['forum_lastpost_info']); + + if($tmp[0] > $lastpost_datestamp) + { + $ret['lastpost_info'] = $sub['forum_lastpost_info']; + $ret['lastpost_user'] = $sub['forum_lastpost_user']; + $ret['lastpost_user_anon'] = $sub['forum_lastpost_user_anon']; + $ret['user_name'] = $sub['user_name']; + $lastpost_datestamp = $tmp[0]; + } + } + + + return $ret; + } + } +require_once(e_PLUGIN . 'forum/forum_class.php'); +/** @var e107forum $forum */ +$forum = new e107forum; + +new forum_front($forum); + + diff --git a/e107_plugins/forum/forum_admin.php b/e107_plugins/forum/forum_admin.php index bd2f01255..7b5117906 100644 --- a/e107_plugins/forum/forum_admin.php +++ b/e107_plugins/forum/forum_admin.php @@ -28,18 +28,9 @@ e107::css('inline'," "); -$legacy = false; -if(E107_DEBUG_LEVEL > 0 && $legacy == true) -{ - define('OLD_FORUMADMIN', true); - //e107::getMessage()->addwarning("Experimental code now active. Using this page in debug mode active could break your forum configuration."); -} -// Generated e107 Plugin Admin Area -if(!deftrue('OLD_FORUMADMIN')) -{ class forum_admin extends e_admin_dispatcher { @@ -1222,1629 +1213,11 @@ if(!deftrue('OLD_FORUMADMIN')) } } - new forum_admin(); +new forum_admin(); - require_once(e_ADMIN."auth.php"); - e107::getAdminUI()->runPage(); +require_once(e_ADMIN."auth.php"); +e107::getAdminUI()->runPage(); +require_once(e_ADMIN."footer.php"); - require_once(e_ADMIN."footer.php"); - exit; -} - -/* -$e_sub_cat = 'forum'; - -require_once(e_ADMIN.'auth.php'); -require_once(e_HANDLER.'userclass_class.php'); -require_once(e_HANDLER.'form_handler.php'); -require_once(e_PLUGIN.'forum/forum_class.php'); - -$for = new e107forum; -$forum = new forumAdmin; - -$mes = e107::getMessage(); -$sql = e107::getDb(); -$tp = e107::getParser(); - -$fPref = e107::getPlugConfig('forum', '', false); - -print_a($fPref); - -define('IMAGE_new', ""); -define('IMAGE_sub', "".FORLAN_145.""); -define('IMAGE_nosub', "".FORLAN_145.""); - -$deltest = array_flip($_POST); - -if (e_QUERY) -{ - $tmp = explode('.', e_QUERY); - $action = $tmp[0]; - $sub_action = $tmp[1]; - $id = $tmp[2]; - unset($tmp); -} - -if(isset($_POST['delete'])) -{ - $tmp = array_pop(array_flip($_POST['delete'])); - list($delete, $del_id) = explode('_', $tmp); -} - -if(isset($_POST['setMods'])) -{ - foreach($_POST['mods'] as $fid => $modid) - { - if($sql->update('forum',"forum_moderators = '{$modid}' WHERE forum_id = {$fid}")) - { - $mes->addSuccess(LAN_UPDATED); - } - else - { - $mes->addError(LAN_UPDATED_FAILED); - } - - } - - $ns->tablerender($caption, $mes->render().$text); -} - - -if(isset($_POST['tools'])) -{ - $msg = ''; - if(isset($_POST['forum_all'])) - { - $fList[]='all'; - } - else - { - foreach(array_keys($_POST['forumlist']) as $k) - { - $fList[] = $k; - } - } - foreach($fList as $fid) - { - if(isset($_POST['counts'])) - { - $for->forumUpdateCounts($fid, $_POST['counts_threads']); - $msg .= FORLAN_167.": $fid
"; - } - if(isset($_POST['lastpost'])) - { - $with_threads = (isset($_POST['lastpost_nothread'])) ? FALSE : TRUE; - $for->forumUpdateLastpost('forum', $fid, $with_threads); - $msg .= FORLAN_168.": $fid
"; - } - } - if(isset($_POST['userpostcounts'])) - { - require_once(e_HANDLER.'user_extended_class.php'); - $ue = new e107_user_extended; - - $list = $for->getUserCounts(); - foreach($list as $uid => $cnt) - { - $ue->user_extended_setvalue($uid, 'user_plugin_forum_posts', $cnt, 'int'); - } - $msg .= FORLAN_169.'
'; - } - $mes->addSuccess($msg); - $ns->tablerender($caption, $mes->render().$text); -} - - - -if(isset($_POST['create_sub'])) -{ - $fid = (int)($sub_action); - $tmp = array(); - $tmp['forum_name'] = $tp->toDB($_POST['subname_new']); - $tmp['forum_description'] = $tp->toDB($_POST['subdesc_new']); - $tmp['forum_order'] = (int)$_POST['suborder_new']; - - if($tmp['forum_name'] != '' && $sql->select('forum', '*', "forum_id = {$fid}")) - { - $row = $sql->fetch(); - $tmp['forum_parent'] = $row['forum_parent']; - $tmp['forum_moderators'] = $row['forum_moderators']; - $tmp['forum_class'] = $row['forum_class']; - $tmp['forum_postclass'] = $row['forum_postclass']; - $tmp['forum_sub'] = $fid; - if($sql->insert('forum', $tmp)) - { - $mes->addSuccess(LAN_CREATED); - } - else - { - $mes->addError(LAN_CREATED_FAILED); - } - } - $ns->tablerender($caption, $mes->render().$text); -} - - -if(isset($_POST['update_subs'])) -{ - $msg = ""; - foreach(array_keys($_POST['subname']) as $id) - { - if($_POST['subname'][$id] == "") - { - if ($sql->delete("forum", "forum_id='$id' ")) - { - $msg .= LAN_FORUM_1002." ". LAN_ID.":"." ".$id." ".LAN_DELETED."
"; - $cnt = $sql->delete("forum_thread", "thread_forum_id = {$id}"); - $msg .= $cnt." ".FORLAN_152." ".LAN_DELETED."
"; - } - } - else - { - $_name = $tp->toDB($_POST['subname'][$id]); - $_desc = $tp->toDB($_POST['subdesc'][$id]); - $_order = (int)$_POST['suborder'][$id]; - if($sql->update('forum', "forum_name='{$_name}', forum_description='{$_desc}', forum_order='{$_order}' WHERE forum_id = {$id}")) - { - $msg .= LAN_FORUM_1002 ." ". LAN_ID.":"." ".$id." ".LAN_UPDATED."
"; - } - } - } - if($msg) - { - $mes->addSuccess($msg); - $ns->tablerender($caption, $mes->render().$text); - } -} - -if(isset($_POST['submit_parent'])) -{ - unset($insert); - $insert = array( - 'forum_name' => $tp->toDB($_POST['forum_name']), - 'forum_datestamp' => time(), - 'forum_class' => (int)$_POST['forum_class'], - 'forum_postclass' => (int)$_POST['forum_postclass'], - 'forum_threadclass' => (int)$_POST['forum_threadclass'], - ); - - if($sql->insert('forum', $insert)) - { - $mes->addSuccess(LAN_CREATED); - } - else - { - $mes->addError(LAN_CREATED_FAILED); - } - - $ns->tablerender($caption, $mes->render().$text); -} - - - -if(isset($_POST['update_parent'])) -{ - unset($update); - $update = array( - 'forum_name' => $tp->toDb($_POST['forum_name']), - 'forum_datestamp' => time(), - 'forum_class' => (int)$_POST['forum_class'], - 'forum_postclass' => (int)$_POST['forum_postclass'], - 'forum_threadclass' => (int)$_POST['forum_threadclass'], - 'WHERE' => 'forum_id = '.(int)$id - ); - - if($sql->update('forum', $update)) - { - $mes->addSuccess(LAN_UPDATED); - } - else - { - $mes->addError(LAN_UPDATED_FAILED); - } - - $action = 'main'; - $ns->tablerender($caption, $mes->render().$text); -} - - - -if(isset($_POST['submit_forum'])) -{ - $tmp = array(); - $tmp['forum_moderators'] = (int)$_POST['forum_moderators']; - $tmp['forum_name'] = $tp->toDB($_POST['forum_name']); - $tmp['forum_description'] = $tp->toDB($_POST['forum_description']); - $tmp['forum_datestamp'] = time(); - $tmp['forum_class'] = (int)$_POST['forum_class']; - $tmp['forum_postclass'] = (int)$_POST['forum_postclass']; - $tmp['forum_threadclass'] = (int)$_POST['forum_threadclass']; - $tmp['forum_parent'] = (int)$_POST['forum_parent']; - - if($sql->insert('forum', $tmp)) - { - $mes->addSuccess(LAN_CREATED); - } - else - { - $mes->addError(LAN_CREATED_FAILED); - } - $ns->tablerender($caption, $mes->render().$text); -} - - - -if(isset($_POST['update_forum'])) -{ - unset($_POST['update_forum']); - $tmp['data'] = $_POST; - $tmp['WHERE'] = 'forum_id = '.(int)$id; - - $tmp2['forum_moderators'] = $tmp['forum_moderators']; - $tmp2['forum_class'] = $tmp['forum_class']; - $tmp2['forum_postclass'] = $tmp['forum_postclass']; - $tmp2['forum_threadclass'] = $tmp['forum_threadclass']; - $tmp2['WHERE'] = 'forum_sub = '.(int)$id; - - $sql->update('forum', $tmp); - $sql->update('forum', $tmp2); - - $mes->addSuccess(LAN_UPDATED); - $ns->tablerender($caption, $mes->render().$text); - $action = 'main'; -} - - - -if (isset($_POST['update_order'])) -{ - while (list($key, $id) = each($_POST['forum_order'])) - { - $tmp = explode('.', $id); - $sql->update('forum', "forum_order=".$tmp[1]." WHERE forum_id=".$tmp[0]); - } - $mes->addSuccess(LAN_UPDATED); - $ns->tablerender($caption, $mes->render().$text); -} - - - -if (isset($_POST['updateoptions'])) -{ - $fPref->set('notify', $_POST['email_notify']); - $fPref->set('notify_on', $_POST['email_notify_on']); - $fPref->set('poll', $_POST['forum_poll']); - $fPref->set('popular', $_POST['forum_popular']); - $fPref->set('track', $_POST['forum_track']); - $fPref->set('eprefix', $_POST['forum_eprefix']); - $fPref->set('enclose', $_POST['forum_enclose']); - $fPref->set('title', $_POST['forum_title']); - $fPref->set('postspage', $_POST['forum_postspage']); - $fPref->set('threadspage', $_POST['forum_threadspage']); - $fPref->set('html_post', $_POST['html_post']); - $fPref->set('attach', $_POST['forum_attach']); - $fPref->set('redirect', $_POST['forum_redirect']); - $fPref->set('reported_post_email', $_POST['reported_post_email']); - $fPref->set('tooltip', $_POST['forum_tooltip']); - $fPref->set('tiplength', $_POST['forum_tiplength']); - $fPref->set('hilightsticky', $_POST['forum_hilightsticky']); - $fPref->set('maxwidth', $_POST['forum_maxwidth']); - $fPref->set('linkimg', $_POST['forum_linkimg']); - $fPref->save(true, true); - - $mes->addSuccess(); - $ns->tablerender($caption, $mes->render().$text); -} - - - -if (isset($_POST['do_prune'])) -{ - $msg = $for->forumPrune($_POST['prune_type'], $_POST['prune_days'], $_POST['pruneForum']); - $mes->addSuccess($msg); - $action = 'main'; - $ns->tablerender($caption, $mes->render().$text); - -} - - -if (isset($_POST['frsubmit'])) -{ - $guestrules = $tp->toDB($_POST['guestrules']); - $memberrules = $tp->toDB($_POST['memberrules']); - $adminrules = $tp->toDB($_POST['adminrules']); - if(!$sql->update("generic", "gen_chardata ='$guestrules', gen_intdata='".$_POST['guest_active']."' WHERE gen_type='forum_rules_guest' ")) - { - $sql->insert("generic", "0, 'forum_rules_guest', '".time()."', 0, '', '".$_POST['guest_active']."', '$guestrules' "); - } - if(!$sql->update("generic", "gen_chardata ='$memberrules', gen_intdata='".$_POST['member_active']."' WHERE gen_type='forum_rules_member' ")) - { - $sql->insert("generic", "0, 'forum_rules_member', '".time()."', 0, '', '".$_POST['member_active']."', '$memberrules' "); - } - if(!$sql->update("generic", "gen_chardata ='$adminrules', gen_intdata='".$_POST['admin_active']."' WHERE gen_type='forum_rules_admin' ")) - { - $sql->insert("generic", "0, 'forum_rules_admin', '".time()."', 0, '', '".$_POST['admin_active']."', '$adminrules' "); - } - $ns->tablerender($caption, $mes->render().$text); -} - -if (vartrue($delete) == 'main') { - if ($sql->delete('forum', "forum_id='$del_id' ")) - { - $mes->addSuccess(LAN_DELETED); - } - else - { - $mes->addError(LAN_DELETED_FAILED); - } - $ns->tablerender($caption, $mes->render().$text); -} - - -if (vartrue($action) == 'create') -{ - if ($sql->select('forum', '*', "forum_parent='0' ")) - { - $forum->create_forums($sub_action, $id); - } - else - { - header('location:'.e_ADMIN.'forum.php'); - exit; - } -} - -if ($delete == 'cat') -{ - if ($sql->delete('forum', "forum_id='$del_id' ")) - { - $sql->delete('forum', "forum_parent='$del_id' "); - $mes->addSuccess(LAN_DELETED); - $action = 'main'; - } - else - { - $mes->addError(LAN_DELETED_FAILED); - } - - $ns->tablerender($caption, $mes->render().$text); -} - - - -switch($action) -{ - case 'delete': - $forum->delete_item(intval($sub_action)); - break; - - case 'cat': - $forum->create_parents($sub_action, $id); - break; - - case 'order': - $forum->show_existing_forums($sub_action, $id, true); - break; - - case 'opt': - $forum->show_prefs(); - break; - - case 'mods': - $forum->show_mods(); - break; - - case 'tools': - $forum->show_tools(); - break; - - case 'prune': - $forum->show_prune(); - break; - - case 'rules': - $forum->show_rules(); - break; - - case 'subs': - $forum->show_subs($sub_action); - break; - - case 'sr': - $forum->show_reported($sub_action); - break; -} - - -if ($delete == 'reported') -{ - $sql->delete("generic", "gen_id='$del_id' "); - $mes->addSuccess(LAN_DELETED); -} - - -if (!e_QUERY || $action == 'main') -{ - $forum->show_existing_forums(vartrue($sub_action), vartrue($id)); -} - -require_once(e_ADMIN.'footer.php'); -// function headerjs() -// { -// $e107 = e107::getInstance(); -// $tp = e107::getParser(); - -// // These functions need to be removed and replaced with the generic jsconfirm() function. -// $headerjs = ""; -// return $headerjs; -// } - -function forum_admin_adminmenu() -{ - global $forum; - global $action; - $forum->show_options($action); -} - - - - -class forumAdmin -{ - - function show_options($action) - { - - $sql = e107::getDb(); - if ($action == '') { $action = 'main'; } - - // ##### Display options --------------------------------------------------------------------------------------------------------- - $var['main']['text'] = FORLAN_76; - $var['main']['link'] = e_SELF; - $var['cat']['text'] = FORLAN_83; - $var['cat']['link'] = e_SELF.'?cat'; - if ($sql->select('forum', 'forum_id', "forum_parent='0' LIMIT 1")) - { - $var['create']['text'] = FORLAN_77; - $var['create']['link'] = e_SELF.'?create'; - } - $var['order']['text'] = FORLAN_78; - $var['order']['link'] = e_SELF.'?order'; - $var['opt']['text'] = LAN_PREFS; - $var['opt']['link'] = e_SELF.'?opt'; - $var['prune']['text'] = LAN_PRUNE; - $var['prune']['link'] = e_SELF.'?prune'; - $var['rules']['text'] = LAN_FORUM_0016; - $var['rules']['link'] = e_SELF.'?rules'; - $var['sr']['text'] = FORLAN_116; - $var['sr']['link'] = e_SELF.'?sr'; - $var['mods']['text'] = LAN_FORUM_2003; - $var['mods']['link'] = e_SELF.'?mods'; - $var['tools']['text'] = FORLAN_153; - $var['tools']['link'] = e_SELF.'?tools'; - - show_admin_menu(FORLAN_7, $action, $var); - } - - // Initial delete function. Determines which delete routine should be applied. - function delete_item($id) - { - // If a delete routine is cancelled, redirect back to forum listing - if($_POST['cancel']) - { - $this->show_existing_forums(vartrue($sub_action), vartrue($id)); - return; - } - - $sql = e107::getDb(); - $id = (int)$id; - - $confirm = isset($_POST['confirm']) ? true : false; - - if($confirm) - { - e107::getRender()->tablerender('Forums', e107::getMessage()->render().$txt); - } - else - { - $this->delete_show_confirm($txt); - } - - if($row = $sql->retrieve('forum', 'forum_parent, forum_sub', "forum_id = {$id}")) - { - $txt = ""; - - // is parent - if($row['forum_parent'] == 0) - { - $txt .= $this->delete_parent($id, $confirm); - } - // is subforum - elseif($row['forum_sub'] > 0) - { - $txt .= $this->delete_sub($id, $confirm); - } - // is forum - else - { - $txt .= $this->delete_forum($id, $confirm); - } - } - // forum_id not found, should not happen. - else - { - $this->show_existing_forums(vartrue($sub_action), vartrue($id)); - return; - } - } - - function delete_parent($id, $confirm = false) - { - $sql = e107::getDb(); - $mes = e107::getMessage(); - $ns = e107::getRender(); - - // check if parent contains forums and delete them if needed - if($sql->select('forum', 'forum_id', 'forum_parent = '.$id)) - { - $fList = $sql->rows(); - foreach($fList as $f) - { - $this->delete_forum($f['forum_id'], $confirm); - } - } - - if($confirm) - { - if($sql->delete('forum', "forum_id = {$id}")) - { - $mes->addSuccess(LAN_DELETED); - } - else - { - $mes->addError(LAN_DELETED_FAILED); - } - } - } - - // function deleteForum($forumId) - // { - // $sql = e107::getDb(); - // $forumId = (int)$forumId; - - // // Check for any sub forums - // if($sql->select('forum', 'forum_id', "forum_sub = {$forumId}")) - // { - // $list = $sql->rows(); - // foreach($list as $f) - // { - // $ret .= $this->deleteForum($f['forum_id']); - // } - // } - // require_once(e_PLUGIN.'forum/forum_class.php'); - // $f = new e107Forum; - // if($sql->delete('forum_thread', 'thread_id','thread_forum_id='.$forumId)) - // { - // $list = $sql->rows(); - // foreach($list as $t) - // { - // $f->threadDelete($t['thread_id'], false); - // } - // } - // return $sql->delete('forum', 'forum_id = '.$forumId); - // } - - // delete forum - function delete_forum($id, $confirm = false) - { - $sql = e107::getDb(); - $tp = e107::getParser(); - $ns = e107::getRender(); - $mes = e107::getMessage(); - - // check if forum contains subforums - if($sql->select('forum', 'forum_id', 'forum_sub = '.$id)) - { - $fList = $sql->rows(); - foreach($fList as $f) - { - $this->delete_sub($f['forum_id'], $confirm); - } - } - if($confirm) - { - if($this->deleteForum($id)) - { - $mes->addSuccess(LAN_DELETED); - } - else - { - $mes->addError(LAN_DELETED_FAILED); - } - } - - $sql->select('forum', 'forum_name, forum_threads, forum_replies', 'forum_id = '.$id); - $row = $sql->fetch(); - - $mes->addInfo("Forum {$id} [".$tp->toHTML($row['forum_name'])."] has {$row['forum_threads']} threads and {$row['forum_replies']} replies."); - } - - function delete_sub($id, $confirm = FALSE) - { - $sql = e107::getDb(); - $tp = e107::getParser(); - $mes = e107::getMessage(); - $ns = e107::getRender(); - - if($confirm) - { - if($this->deleteForum($id)) - { - $mes->addSuccess(LAN_DELETED); - } - else - { - $mes->addError(LAN_DELETED); - } - } - - $sql->select('forum', '*', 'forum_id = '.$id); - $row = $sql->fetch(); - $mes->addInfo("Sub-forum {$id} [".$tp->toHTML($row['forum_name'])."] has {$row['forum_threads']} threads, {$row['forum_replies']} replies."); - } - - function delete_show_confirm($message) - { - $mes = e107::getMessage(); - - $mes->addInfo($message); - - $text = " -
-
- ".e107::getForm()->admin_button('confirm', LAN_UI_DELETE_LABEL, 'delete')." - ".e107::getForm()->admin_button('cancel', LAN_CANCEL, 'cancel')." -
-
- "; - e107::getRender()->tablerender('Forum'.SEP.'Delete forum(s)', $mes->render().$text); - } - - function show_subs($id) - { - $sql = e107::getDb(); - $tp = e107::getParser(); - $ns = e107::getRender(); - $frm = e107::getForm(); - $txt = " -
- - - - - - - - - "; - if($sql->select('forum', 'forum_id, forum_name, forum_description, forum_order', "forum_sub = {$id} ORDER by forum_order ASC")) - { - $subList = $sql->db_getList(); - foreach($subList as $sub) - { - $txt .= " - - - - - - - - "; - } - $txt .= " - - - - - - - "; - - } - else - { - $txt .= ""; - } - - $txt .= " - - - - - - - - - - - - - - - - - -
".LAN_ID."".LAN_NAME."".LAN_DESCRIPTION."".LAN_ORDER."".LAN_DELETE."
{$sub['forum_id']} - ".ADMIN_DELETE_ICON." -
".$frm->admin_button('update_subs', LAN_UPDATE, 'update')."
 
".FORLAN_146."
".LAN_ID."".LAN_NAME."".LAN_DESCRIPTION."".LAN_ORDER." 
  
".$frm->admin_button('create_sub', LAN_CREATE, 'submit')."
-
"; - - $ns->tablerender(LAN_FORUM_0069, $txt); - } - - function show_existing_forums($sub_action, $id, $mode = false) - { - global $for; // $e107 - $frm = e107::getForm(); - $sql = e107::getDb(); - $tp = e107::getParser(); - $mes = e107::getMessage(); - $ns = e107::getRender(); - - $subList = $for->forumGetSubs(); - - if (!$mode) - { - $text = "
"; - } - else - { - $text = "
"; - } - - if (!$parent_amount = $sql->select('forum', '*', "forum_parent='0' ORDER BY forum_order ASC")) - { - //$text .= "".FORLAN_29.""; - $mes->addInfo(FORLAN_29); - } - else - { - $text .= " - - - - - "; - while ($row = $sql->fetch()) - { - $parentList[] = $row; - } - foreach($parentList as $parent) - { - $text .= " - - "; - - $text .= ""; - - $forumCount = $sql->select('forum', '*', "forum_parent='".$parent['forum_id']."' AND forum_sub = 0 ORDER BY forum_order ASC"); - if (!$forumCount) - { - $text .= ""; - } - else - { - $forumList = array(); - while ($row = $sql->fetch()) - { - $forumList[] = $row; - } - foreach($forumList as $forum) - { - $text .= " - - \n\n - - \n"; - } - } - } - } - - if (!$mode) - { - $text .= "
".LAN_FORUM_1001."".LAN_OPTIONS."
".$parent['forum_name']." -
".FORLAN_140.": ".e107::getUserClass()->getName($parent['forum_class'])."  ".LAN_FORUM_2015.": ".e107::getUserClass()->getName($parent['forum_postclass'])." -
"; - - if ($mode) - { - $text .= ""; - } - else - { - $text .= " - - "; - } - $text .= "
".FORLAN_29."
".IMAGE_new."".$tp->toHTML($forum['forum_name']).""; -// ".IMAGE_new."".$tp->toHTML($forum['forum_name']).""; - - $text .= " -
".$tp->toHTML($forum['forum_description'])."  -
".FORLAN_140.": ".e107::getUserClass()->getName($forum['forum_class'])."  ".LAN_FORUM_2015.": ".e107::getUserClass()->getName($forum['forum_postclass'])." - -
"; - - if ($mode) - { - $text .= ""; - } - else - { - //$sub_img = count($subList[$forum['forum_parent']][$forum['forum_id']]) ? IMAGE_sub : IMAGE_nosub; - $sub_img = ADMIN_DOWN_ICON; - $sub_total = count($subList[$forum['forum_parent']][$forum['forum_id']]); - $text .= " - - "; - } - $text .= "
"; - $ns->tablerender(FORLAN_30, $mes->render() . $text); - } - else - { - $text .= "
".$frm->admin_button('update_order', LAN_UPDATE, 'update')."
"; - $ns->tablerender(LAN_ORDER, $mes->render() . $text); - } - - } - - - function create_parents($sub_action, $id) - { - $frm = e107::getForm(); - $sql = e107::getDb(); - $tp = e107::getParser(); - $ns = e107::getRender(); - - $id = (int)$id; - if ($sub_action == 'edit' && !$_POST['update_parent']) - { - if ($sql->select('forum', '*', "forum_id=$id")) - { - $row = $sql->fetch(); - } - } - else - { - $row = array(); - $row['forum_name'] = ''; - $row['forum_class'] = e_UC_PUBLIC; - $row['forum_postclass'] = e_UC_MEMBER; - $row['forum_threadclass'] = e_UC_MEMBER; - } - - $text = " -
- - - - - - - - - - - - - - - - - - - - - -
".LAN_NAME.":
".FORLAN_23.":".e107::getUserClass()->uc_dropdown('forum_class', $row['forum_class'], 'nobody,public,member,admin,classes')."".FORLAN_24."
".FORLAN_142.":".e107::getUserClass()->uc_dropdown("forum_postclass", $row['forum_postclass'], 'nobody,public,member,admin,classes')."".FORLAN_143."
".FORLAN_184.":".e107::getUserClass()->uc_dropdown('forum_threadclass', $row['forum_threadclass'], 'nobody,public,member,admin,classes')."".FORLAN_185."
-
"; - if ($sub_action == 'edit') - { - $text .= $frm->admin_button('update_parent', LAN_UPDATE, 'update'); - } - else - { - $text .= $frm->admin_button('submit_parent', LAN_CREATE, 'submit'); - } - $text .= " -
-
"; - - $ns->tablerender(FORLAN_75, $text); - } - - function create_forums($sub_action, $id) - { - //global $e107; - $frm = e107::getForm(); - $sql = e107::getDb(); - $tp = e107::getParser(); - $ns = e107::getRender(); - - $id = (int)$id; - if ($sub_action == 'edit' && !$_POST['update_forum']) - { - if ($sql->select('forum', '*', "forum_id=$id")) - { - $fInfo = $sql->fetch(); - } - } - else - { - $fInfo = array( - 'forum_parent' => 0, - 'forum_moderators' => e_UC_ADMIN, - 'forum_class' => e_UC_PUBLIC, - 'forum_postclass' => e_UC_MEMBER, - 'forum_threadclass' => e_UC_MEMBER - ); - } - - $text = " -
\n - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
".LAN_FORUM_0004.":"; - - $sql->select('forum', '*', 'forum_parent=0'); - $text .= " -
".LAN_NAME.":".FORLAN_179."
".LAN_DESCRIPTION.":
".LAN_FORUM_2003.":"; - $text .= e107::getUserClass()->uc_dropdown('forum_moderators', $fInfo['forum_moderators'], 'admin,classes')."".FORLAN_34.""; - $text .= "
".FORLAN_23.":".e107::getUserClass()->uc_dropdown('forum_class', $fInfo['forum_class'], 'nobody,public,member,admin,classes')."".FORLAN_24."
".FORLAN_142.":".e107::getUserClass()->uc_dropdown('forum_postclass', $fInfo['forum_postclass'], 'nobody,public,member,admin,classes')."".FORLAN_143."
".FORLAN_184.":".e107::getUserClass()->uc_dropdown('forum_threadclass', $fInfo['forum_threadclass'], 'nobody,public,member,admin,classes')."".FORLAN_185."
- -
"; - if ($sub_action == "edit") - { - $text .= $frm->admin_button('update_forum', LAN_UPDATE, 'update'); - } - else - { - $text .= $frm->admin_button('submit_forum', LAN_CREATE, 'submit'); - } - $text .= " -
-
-"; - $ns->tablerender(LAN_FORUM_1001, $text); - } - - - // function show_message($message) - // { - - // e107::getRender();->tablerender('', $message); - // } - - - function show_tools() - { - $sql = e107::getDb(); - $ns = e107::getRender(); - $tp = e107::getParser(); - $frm = e107::getForm(); - - $txt = " -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
".FORLAN_156."
- "; - if($sql->select("forum", "*", "1 ORDER BY forum_order")) - { - $fList = $sql->db_getList(); - foreach($fList as $f) - { - $txt .= " ".$tp->toHTML($f['forum_name'])."
"; - } - $txt .= " ".LAN_PLUGIN_FORUM_ALLFORUMS.""; - } - $txt .= " -
".FORLAN_158."
- ".FORLAN_159."
     - ".FORLAN_160." -
".FORLAN_161."
- ".FORLAN_162."
-      ".FORLAN_182."
".FORLAN_183."

-
".FORLAN_163."
".FORLAN_164."
-
- ".$frm->admin_button('tools', LAN_GO, 'submit')." -
-
- "; - $ns->tablerender(FORLAN_166, $txt); - } - - function show_prefs() - { - global $fPref; - $ns = e107::getRender(); - $sql = e107::getDb(); - //$e107 = e107::getInstance(); - $frm = e107::getForm(); - $mes = e107::getMessage(); - - $poll_installed = e107::isInstalled('poll'); - - - if(!$poll_installed) - { - if($fPref->get('poll') == 1) - { - $fPref['forum_poll'] = e_UC_NOBODY; - $fPref->save(false, true); - } - } - - $text = " -
\n - - - - - - - - - - - - - - - - - - - - - - - - - - - "; - if($poll_installed) - { - // - $text .= "'; - } - else - { - $text .= ""; - } - $text .= " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
".FORLAN_44.":".($fPref->get('enclose') ? "" : "")."".FORLAN_45."
".FORLAN_65.":
".FORLAN_47.":".($fPref->get('notify') ? "" : "")."".FORLAN_48."
".FORLAN_177.":".($fPref->get('notify_on') ? "" : "")."".FORLAN_178."
".FORLAN_49.":".e107::getUserClass()->uc_dropdown("mods[{$f['forum_id']}]", $f['forum_moderators'], 'admin,classes')."".e107::getUserClass()->uc_dropdown('forum_poll', $fPref->get('poll'), 'nobody,public,member,admin,main,classes').''.FORLAN_50.'".FORLAN_66."
".FORLAN_70.":"; - - if(!$pref['image_post']) - { - $text .= "
".FORLAN_139.""; // - } - if(!is_writable(e_PLUGIN.'forum/attachments')) - { - $text .= "
Attachment dir (".e_PLUGIN_ABS.'forum/attachments'.") is not writable!"; // - } - - $text .= "
".($fPref->get('attach') ? "" : "")."".FORLAN_71." ".FORLAN_130." ". FORLAN_131."
".FORLAN_134.":".FORLAN_135."
".FORLAN_136.":".($fPref->get('linkimg') ? "" : "")."".FORLAN_137."
".FORLAN_51.":".($fPref->get('track') ? "" : "")."".FORLAN_52."
".FORLAN_112.":".($fPref->get('redirect') ? "" : "")."".FORLAN_113."
".FORLAN_116.":".($fPref->get('reported_post_email') ? "" : "")."".FORLAN_122."
".FORLAN_126.":".($fPref->get('forum_tooltip') ? "" : "")."".FORLAN_127."
".FORLAN_128.":".FORLAN_129."
".FORLAN_53.":".FORLAN_54."
".FORLAN_55.":".FORLAN_56."
".FORLAN_57.":".FORLAN_58."
".FORLAN_186.":".FORLAN_187."
".FORLAN_132.":".($fPref->get('hilightsticky') ? "" : "")."".FORLAN_133."
- -
- ".$frm->admin_button('updateoptions', LAN_UPDATE, 'update')." -
-
-"; - $ns->tablerender(FORLAN_7, $mes->render() . $text); - } - - function show_reported($sub_action) - { - $rs = new form; - $sql = e107::getDb(); - $ns = e107::getRender(); - $tp = e107::getParser(); - $mes = e107::getMessage(); - - if ($sub_action) { - $sql->select("generic", "*", "gen_id='".$sub_action."'"); - $row = $sql->fetch(); - $sql->select("user", "*", "user_id='". $row['gen_user_id']."'"); - $user = $sql->fetch(); - //$con = new convert; - $text = " - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
".FORLAN_171.":#".$row['gen_intdata']."
".FORLAN_173.":".$row['gen_ip']."
".FORLAN_174.":".$user['user_name']." -
".FORLAN_175.":".e107::getDate()->convert_date($row['gen_datestamp'], "long")."
".LAN_FORUM_2046.":".$row['gen_chardata']."
- ".$rs->form_open("post", e_SELF."?sr", "", "", "", " onsubmit=\"return confirm_('sr',".$row['gen_datestamp'].")\"")." - ".$rs->form_button("submit", "delete[reported_{$row['gen_id']}]", FORLAN_172)." - ".$rs->form_close()." -
"; - - $ns->tablerender(FORLAN_116, $text); - - } - else - { - if ($reported_total = $sql->select("generic", "*", "gen_type='reported_post' OR gen_type='Reported Forum Post'")) - { - $text = " - - - - - "; - while ($row = $sql->fetch()) - { - $text .= " - - ".FORLAN_171." #".$row['gen_intdata']." - - "; - } - $text .= "
".FORLAN_170."".LAN_OPTIONS."
- ".$rs->form_open("post", e_SELF."?sr", "", "", "", " onsubmit=\"return confirm_('sr',".$row['gen_datestamp'].")\"")." - ".$rs->form_button("submit", "delete[reported_{$row['gen_id']}]", FORLAN_172)." - ".$rs->form_close()." -
"; - } - else - { - //$text = "
".FORLAN_121."
"; - $mes->addInfo(FORLAN_121); - } - $ns->tablerender(FORLAN_116, $mes->render().$text); - } - } - - function show_prune() - { - $ns = e107::getRender(); - $sql = e107::getDB(); - $frm = e107::getForm(); - - // $sql->select("forum", "forum_id, forum_name", "forum_parent!=0 ORDER BY forum_order ASC"); - $qry = " - SELECT f.forum_id, f.forum_name, sp.forum_name AS sub_parent, fp.forum_name AS forum_parent - FROM #forum AS f - LEFT JOIN #forum AS sp ON sp.forum_id = f.forum_sub - LEFT JOIN #forum AS fp ON fp.forum_id = f.forum_parent - WHERE f.forum_parent != 0 - ORDER BY f.forum_parent ASC, f.forum_sub, f.forum_order ASC - "; - $sql->gen($qry); - $forums = $sql->db_getList(); - - $text = " -
\n - - - - - - - - - - - - - - -
".FORLAN_60."
".FORLAN_87."
".FORLAN_2."
- ".FORLAN_89."     - ".FORLAN_90." -
".FORLAN_138.":
"; - - foreach($forums as $forum) - { - $for_name = $forum['forum_parent']." -> "; - $for_name .= ($forum['sub_parent'] ? $forum['sub_parent']." -> " : ""); - $for_name .= $forum['forum_name']; - $text .= " ".$for_name."
"; - } - - - $text .= " -
-
- ".$frm->admin_button('do_prune', LAN_PRUNE, 'submit')." -
-
"; - $ns->tablerender(LAN_PRUNE, $text); - } - - - function show_mods() - { - global $for; - $ns = e107::getRender(); - $sql = e107::getDB(); - //$e107 = e107::getInstance(); - $forumList = $for->forum_getforums('all'); - $parentList = $for->forum_getparents('list'); - $subList = $for->forumGetSubs('bysub'); - $frm = e107::getForm(); - $tp = e107::getParser(); - - $txt = "
- - - - - "; - - foreach($parentList as $p) - { - $txt .= " - - - - "; - - foreach($forumList[$p['forum_id']] as $f) - { - $txt .= " - - - - - "; - foreach($subList[$f['forum_id']] as $s) - { - $txt .= " - - - - - "; - } - } - } - $txt .= " -
".$tp->toHTML($p['forum_name'])."
{$f['forum_name']}".e107::getUserClass()->uc_dropdown("mods[{$f['forum_id']}]", $f['forum_moderators'], 'admin,classes')."
    {$s['forum_name']}".e107::getUserClass()->uc_dropdown("mods[{$s['forum_id']}]", $s['forum_moderators'], 'admin,classes')."
-
- ".$frm->admin_button('setMods', LAN_UPDATE, 'update')." -
-
"; - $ns->tablerender(LAN_FORUM_2003, $txt); - } -*/ - // -/* - function show_rules() - { - $pref = e107::getPref(); - $ns = e107::getRender(); - $sql = e107::getDB(); - $tp = e107::getParser(); - $frm = e107::getForm(); -*/ - /* - $sql->select("wmessage"); - list($null) = $sql->fetch(); - list($null) = $sql->fetch(); - list($null) = $sql->fetch(); - list($id, $guestrules, $wm_active4) = $sql->fetch(); - list($id, $memberrules, $wm_active5) = $sql->fetch(); - list($id, $adminrules, $wm_active6) = $sql->fetch(); - */ - -/* - if($sql->select('generic','*',"gen_type='forum_rules_guest'")) - { - $guest_rules = $sql->fetch(); - } - if($sql->select('generic','*',"gen_type='forum_rules_member'")) - { - $member_rules = $sql->fetch(); - } - if($sql->select('generic','*',"gen_type='forum_rules_admin'")) - { - $admin_rules = $sql->fetch(); - } - - $guesttext = $tp->toForm(vartrue($guest_rules['gen_chardata'])); - $membertext = $tp->toForm(vartrue($member_rules['gen_chardata'])); - $admintext = $tp->toForm(vartrue($admin_rules['gen_chardata'])); - - $text = " -
- - - - - - - - - - - - - - - - - - - - - -
".WMGLAN_1.":
- ".WMGLAN_6.":"; - if (vartrue($guest_rules['gen_intdata'])) - { - $text .= ""; - } - else - { - $text .= ""; - } - $text .= "
- ".$frm->bbarea('guestrules', $guesttext)." -
".WMGLAN_2.":
- ".WMGLAN_6.":"; - if (vartrue($member_rules['gen_intdata'])) - { - $text .= ""; - } - else - { - $text .= ""; - } - $text .= "
- ".$frm->bbarea('memberrules', $membertext)." -
".WMGLAN_3.":
- ".WMGLAN_6.": "; - - if (vartrue($admin_rules['gen_intdata'])) - { - $text .= ""; - } - else - { - $text .= ""; - } - - $text .= "
- ".$frm->bbarea('adminrules', $admintext)." -
-
- ".$frm->admin_button('frsubmit', LAN_UPDATE, 'submit')." -
-
"; - - $ns->tablerender(WMGLAN_5, $text); - - echo " - - "; - - } - } - */ - diff --git a/e107_plugins/forum/forum_conf.php b/e107_plugins/forum/forum_conf.php deleted file mode 100644 index 64814a853..000000000 --- a/e107_plugins/forum/forum_conf.php +++ /dev/null @@ -1,222 +0,0 @@ -isInstalled('forum')) -{ - e107::redirect('admin'); - exit; -} - -$ns = e107::getRender(); -$tp = e107::getParser(); - -require_once(e_PLUGIN.'forum/forum_class.php'); -$forum = new e107forum; - -e107::lan('forum', 'admin'); -//include_lan(e_PLUGIN.'forum/languages/'.e_LANGUAGE.'/lan_forum_conf.php'); - -$e_sub_cat = 'forum'; - -if(!USER || !isset($_GET['f']) || !isset($_GET['id'])) -{ - header('location:'.$e107::getUrl()->create('/'), array(), array('encode' => false, 'full' => 1)); - exit; -} - -$id = (int)$_GET['id']; -$action = $_GET['f']; - -$qry = " -SELECT t.*, f.*, fp.forum_id AS forum_parent_id FROM #forum_thread as t -LEFT JOIN #forum AS f ON t.thread_forum_id = f.forum_id -LEFT JOIN #forum AS fp ON fp.forum_id = f.forum_parent -WHERE t.thread_id = {$thread_id} -"; - -$threadInfo = $forum->threadGet($id); -$modList = $forum->forumGetMods($threadInfo->forum_moderators); - -//var_dump($threadInfo); -//var_dump($modList); - -//If user is not a moderator of indicated forum, redirect to index page -if(!in_array(USERID, array_keys($modList))) -{ - header('location:'.$e107::getUrl()->create('/'), array(), array('encode' => false, 'full' => 1)); - exit; -} - -require_once(HEADERF); - -if (isset($_POST['deletepollconfirm'])) -{ - $sql->delete("poll", "poll_id='".intval($thread_parent)."' "); - $sql->select("forum_thread", "*", "thread_id='".$thread_id."' "); - $row = $sql->fetch(); - extract($row); - $thread_name = str_replace("[poll] ", "", $thread_name); - $sql->update("forum_thread", "thread_name='$thread_name' WHERE thread_id='$thread_id' "); - $message = LAN_FORUM_5001; - $url = e_PLUGIN."forum/forum_viewtopic.php?".$thread_id; -} - - - -// Moved to forum_post.php -/* -if (isset($_POST['move'])) -{ -// print_a($_POST); - require_once(e_PLUGIN.'forum/forum_class.php'); - $forum = new e107forum; - - $newThreadTitle = ''; - if($_POST['rename_thread'] == 'add') - { - $newThreadTitle = '['.LAN_FORUM_5021.']'; - $newThreadTitleType = 0; - } - elseif($_POST['rename_thread'] == 'rename' && trim($_POST['newtitle']) != '') - { - $newThreadTitle = $tp->toDB($_POST['newtitle']); - $newThreadTitleType = 1; - } - - $threadId = $_GET['id']; - $toForum = $_POST['forum_move']; - - $forum->threadMove($threadId, $toForum, $newThreadTitle, $newThreadTitleType); - - $message = LAN_FORUM_5005;// XXX _URL_ thread name - $url = $e107::getUrl()->create('forum/thread/view', 'id='.$threadId); -} - -if (isset($_POST['movecancel'])) -{ - require_once(e_PLUGIN.'forum/forum_class.php'); - $forum = new e107forum; - $postInfo = $forum->postGet($id, 0, 1); - - $message = LAN_FORUM_5006; -// $url = e_PLUGIN."forum/forum_viewforum.php?".$info['forum_id']; - $url = $e107::getUrl()->create('forum/forum/view', 'id='.$postInfo[0]['post_forum']);// XXX _URL_ thread name -} - - - -*/ - - - -if ($message) -{ - $text = "
".$message." -
- ".LAN_FORUM_5007.' -
'; - $ns->tablerender(LAN_FORUM_5008, $text); - require_once(FOOTERF); - exit; -} - -if ($action == "delete_poll") -{ - $text = "
- ".LAN_FORUM_5009." -

-
- - -
-
"; - $ns->tablerender(LAN_UI_DELETE_LABEL, $text); - require_once(FOOTERF); - exit; -} -/* -if ($action == 'move') -{ - $postInfo = $forum->postGet($id, 0, 1); - - $frm = e107::getForm(); - - $qry = " - SELECT f.forum_id, f.forum_name, fp.forum_name AS forum_parent, sp.forum_name AS sub_parent - FROM `#forum` AS f - LEFT JOIN `#forum` AS fp ON f.forum_parent = fp.forum_id - LEFT JOIN `#forum` AS sp ON f.forum_sub = sp.forum_id - WHERE f.forum_parent != 0 - AND f.forum_id != ".(int)$threadInfo['thread_forum_id']." - ORDER BY f.forum_parent ASC, f.forum_sub, f.forum_order ASC - "; - - $sql->gen($qry); - $fList = $sql->db_getList(); - - $text = " -
-
- - - - - - - - - -
".LAN_FORUM_5019.": - -
".LAN_FORUM_5026."
- ".$frm->radio('rename_thread','none',true, 'label='.LAN_FORUM_5022)." - ".$frm->radio('rename_thread', 'add', false, array('label'=> LAN_ADD.' ['.LAN_FORUM_5021.'] '.LAN_FORUM_5024)). " -
".$frm->radio('rename_thread','rename', false, array('label'=>LAN_FORUM_5025))." - ".$frm->text('newtitle', $tp->toForm($threadInfo['thread_name']), 250)." -
-
-
- - -
- -
-
"; - - - $threadName = $tp->toHTML($threadInfo['thread_name'], true); - $threadText = $tp->toHTML($postInfo[0]['post_entry'], true); - - $text .= "

".$threadName."

".$threadText."
"; // $e107->ns->tablerender(, ), '', true).$ns->tablerender('', $text, '', true); - $ns->tablerender(LAN_FORUM_5019, $text); - -} -*/ - - - - -require_once(FOOTERF); diff --git a/e107_plugins/forum/forum_post.php b/e107_plugins/forum/forum_post.php index 78213e9e6..9ea19139a 100644 --- a/e107_plugins/forum/forum_post.php +++ b/e107_plugins/forum/forum_post.php @@ -128,7 +128,7 @@ class forum_post_handler if (!e_QUERY || empty($_GET['id'])) { - $url = e107::url('forum','index',null,'full'); + $url = e107::url('forum','index',null,['mode'=>'full']); $this->redirect($url); // header('Location:'.e107::getUrl()->create('forum/forum/main', array(), 'full=1&encode=0')); exit; @@ -183,7 +183,7 @@ class forum_post_handler break; default: - $url = e107::url('forum','index',null,'full'); + $url = e107::url('forum','index',null,['mode'=>'full']); $this->redirect($url); // header("Location:".e107::getUrl()->create('forum/forum/main', array(), 'full=1&encode=0')); exit; @@ -1756,7 +1756,7 @@ class forum_post_handler require_once(HEADERF); new forum_post_handler; require_once(FOOTERF); -exit; + diff --git a/e107_plugins/forum/forum_stats.php b/e107_plugins/forum/forum_stats.php index a0afcc5f0..c8c167b9a 100644 --- a/e107_plugins/forum/forum_stats.php +++ b/e107_plugins/forum/forum_stats.php @@ -66,7 +66,7 @@ class forumStats $firstpost = $sql->select('forum_post', 'post_datestamp', 'post_datestamp > 0 ORDER BY post_datestamp ASC LIMIT 0,1', 'default'); $fp = $sql->fetch(); - $open_ds = $fp['post_datestamp']; + $open_ds = (int) varset($fp['post_datestamp']); $open_date = $gen->convert_date($open_ds, 'long'); $open_since = $gen -> computeLapse($open_ds); $open_days = floor((time()-$open_ds) / 86400); @@ -77,6 +77,8 @@ class forumStats $query = "SHOW TABLE STATUS FROM `{$mySQLdefaultdb}`"; $sql->gen($query); $array = $sql -> db_getList(); + $db_size = 0; + $avg_row_len = 0; foreach($array as $table) { if($table['Name'] == MPREFIX.'forum_post') @@ -153,6 +155,7 @@ class forumStats $top_repliers_data_c = $sql->db_getList('ALL', false, false, 'user_id'); $top_repliers = array(); + $top_repliers_sort = array(); foreach($top_repliers_data as $uid => $poster) { $poster['post_count'] = $poster['post_count'] - $top_repliers_data_c[$uid]['thread_count']; diff --git a/e107_plugins/forum/forum_test.php b/e107_plugins/forum/forum_test.php deleted file mode 100644 index 041516672..000000000 --- a/e107_plugins/forum/forum_test.php +++ /dev/null @@ -1,20 +0,0 @@ -update_lastpost('thread',$i); -//} - -set_time_limit(240); -$forum->update_lastpost('forum', 'all'); -//$x = $forum->update_lastpost('forum',16); - - -$timeend = microtime(); -$diff = number_format(((substr($timeend, 0, 9)) + (substr($timeend, -10)) - (substr($timestart, 0, 9)) - (substr($timestart, -10))), 4); -echo "
script generation took $diff s"; - diff --git a/e107_plugins/forum/forum_update.php b/e107_plugins/forum/forum_update.php index c3420bb6d..454a429aa 100644 --- a/e107_plugins/forum/forum_update.php +++ b/e107_plugins/forum/forum_update.php @@ -10,20 +10,23 @@ * */ -define('e_ADMIN_AREA', true); -require_once ('../../class2.php'); +if(!defined('e_ADMIN_AREA')) +{ + define('e_ADMIN_AREA', true); +} +require_once(__DIR__ . '/../../class2.php'); -if (!getperms('P')) +if(!getperms('P')) { e107::redirect(); - exit ; + exit; } -require_once (e_PLUGIN . 'forum/forum_class.php'); -require_once (e_ADMIN . 'auth.php'); +require_once(e_PLUGIN . 'forum/forum_class.php'); +require_once(e_ADMIN . 'auth.php'); -if (e_QUERY == "reset") +if(e_QUERY == "reset") { unset($_SESSION['forumUpgrade']); unset($_SESSION['forumupdate']); @@ -36,6 +39,7 @@ if (e_QUERY == "reset") $forum = new e107forum(true); $timestart = microtime(); +global $f; $f = new forumUpgrade; $sql = e107::getDb(); @@ -44,24 +48,23 @@ if(!empty($_GET['reset'])) { unset($_SESSION['forumUpgrade']); unset($_SESSION['forumupdate']); - $f -> updateInfo['currentStep'] = intval($_GET['reset']); - $f -> setUpdateInfo(); + $f->updateInfo['currentStep'] = intval($_GET['reset']); + $f->setUpdateInfo(); } - -if (e_AJAX_REQUEST) +if(e_AJAX_REQUEST) { - if (!vartrue($_GET['mode'])) + if(!vartrue($_GET['mode'])) { echo "data-progress-mode not set!"; - exit ; + exit; } $func = 'step' . intval($_GET['mode']) . "_ajax"; - if (function_exists($func)) + if(function_exists($func)) { call_user_func($func); } @@ -70,69 +73,69 @@ if (e_AJAX_REQUEST) echo $func . "() doesn't exist!"; } - exit ; + exit; } -$upgradeNeeded = $f -> checkUpdateNeeded(); +$upgradeNeeded = $f->checkUpdateNeeded(); $upgradeNeeded = true; -if (!$upgradeNeeded) +if(!$upgradeNeeded) { $mes = e107::getMessage(); - $mes -> addInfo("The forum is already at the most recent version, no upgrade is required"); - $ns -> tablerender('Forum Upgrade', $mes -> render()); - require (e_ADMIN . 'footer.php'); - exit ; + $mes->addInfo("The forum is already at the most recent version, no upgrade is required"); + $ns->tablerender('Forum Upgrade', $mes->render()); + require(e_ADMIN . 'footer.php'); + exit; } -if (isset($_POST) && count($_POST)) +if(isset($_POST) && count($_POST)) { - if (isset($_POST['skip_attach'])) + if(isset($_POST['skip_attach'])) { - $f -> updateInfo['skip_attach'] = 1; - $f -> updateInfo['currentStep'] = 2; - $f -> setUpdateInfo(); + $f->updateInfo['skip_attach'] = 1; + $f->updateInfo['currentStep'] = 2; + $f->setUpdateInfo(); } - if (isset($_POST['nextStep'])) + if(isset($_POST['nextStep'])) { $tmp = array_keys($_POST['nextStep']); - $f -> updateInfo['currentStep'] = $tmp[0]; - $f -> setUpdateInfo(); + $f->updateInfo['currentStep'] = $tmp[0]; + $f->setUpdateInfo(); } } -$currentStep = (isset($f -> updateInfo['currentStep']) ? $f -> updateInfo['currentStep'] : 1); +$currentStep = (isset($f->updateInfo['currentStep']) ? $f->updateInfo['currentStep'] : 1); $stepParms = (isset($stepParms) ? $stepParms : ''); //echo "currentStep = $currentStep
"; -if (function_exists('step' . $currentStep)) +if(function_exists('step' . $currentStep)) { $result = call_user_func('step' . $currentStep, $stepParms); } -require (e_ADMIN . 'footer.php'); -exit ; +require(e_ADMIN . 'footer.php'); + function step1() { global $f; - $f -> updateInfo['currentStep'] = 1; - $f -> setUpdateInfo(); + $f->updateInfo['currentStep'] = 1; + $f->setUpdateInfo(); $mes = e107::getMessage(); //Check attachment dir permissions - if (!isset($f -> updateInfo['skip_attach'])) + if(!isset($f->updateInfo['skip_attach'])) { - $f -> checkAttachmentDirs(); - if (isset($f -> error['attach'])) + $f->checkAttachmentDirs(); + if(isset($f->error['attach'])) { $text = "

ERROR:

The following errors have occured. These issues must be resolved if you ever want to enable attachment or image uploading in your forums.
If you do not ever plan on enabling this setting in your forum, you may click the 'skip' button

"; - foreach ($f->error['attach'] as $e) + foreach($f->error['attach'] as $e) { $text .= '** ' . $e . '
'; } @@ -147,23 +150,24 @@ function step1() } else { - $mes -> addSuccess("Attachment and attachment/thumb directories are writable"); + $mes->addSuccess("Attachment and attachment/thumb directories are writable"); $text = "
"; } - e107::getRender() -> tablerender('Step 1: Attachment directory permissions', $mes -> render() . $text); + e107::getRender()->tablerender('Step 1: Attachment directory permissions', $mes->render() . $text); } } function step2() { + $mes = e107::getMessage(); $ns = e107::getRender(); - if (!isset($_POST['create_tables'])) + if(!isset($_POST['create_tables'])) { $text = " This step will create the new forum_thread, forum_post, and forum_attach tables. It will also create a forum_new table that will become the 'real' forum table once the data from the current table is migrated. @@ -172,26 +176,27 @@ function step2() "; - $ns -> tablerender('Step 2: Forum table creation', $text); + $ns->tablerender('Step 2: Forum table creation', $text); + return; } // FIXME - use db_verify. ?? - require_once (e_HANDLER . 'db_table_admin_class.php'); + require_once(e_HANDLER . 'db_table_admin_class.php'); $db = new db_table_admin; $tabList = array( - 'forum' => 'forum_new', + 'forum' => 'forum_new', 'forum_thread' => '', - 'forum_post' => '', - 'forum_track' => '' + 'forum_post' => '', + 'forum_track' => '' ); // $ret = ''; $failed = false; $text = ''; $sql = e107::getDb(); - foreach ($tabList as $name => $rename) + foreach($tabList as $name => $rename) { $message = 'Creating table ' . ($rename ? $rename : $name); @@ -199,26 +204,26 @@ function step2() if($sql->isTable($curTable) && $sql->isEmpty($curTable)) { - $mes -> addSuccess("Skipping table ".$name." (already exists)"); + $mes->addSuccess("Skipping table " . $name . " (already exists)"); continue; } $result = $db->createTable(e_PLUGIN . 'forum/forum_sql.php', $name, true, $rename); - if ($result === true) + if($result === true) { - $mes -> addSuccess($message); + $mes->addSuccess($message); // $text .= 'Success
'; } - elseif ($result !== true) + elseif($result !== true) { // $text .= 'Failed
'; - $mes -> addError($message); + $mes->addError($message); $failed = true; } } - if ($failed) + if($failed) { - $mes -> addError("Creation of table(s) failed. You can not continue until these are created successfully!"); + $mes->addError("Creation of table(s) failed. You can not continue until these are created successfully!"); } else @@ -227,20 +232,20 @@ function step2() "; } - $ns -> tablerender('Step 2: Forum table creation', $mes -> render() . $text); + $ns->tablerender('Step 2: Forum table creation', $mes->render() . $text); } - // FIXME - use e107::getPlugin()->manage_extended_field('add', $name, $attrib, $source) function step3() { + $ns = e107::getRender(); $mes = e107::getMessage(); $text = ''; $stepCaption = 'Step 3: Extended user field creation'; - if (!isset($_POST['create_extended'])) + if(!isset($_POST['create_extended'])) { $text = " This step will create the new extended user fields required for the new forum code:
@@ -254,39 +259,40 @@ function step3() "; - $ns -> tablerender($stepCaption, $text); + $ns->tablerender($stepCaption, $text); + return; } $fieldList = array( - 'plugin_forum_posts' => 'integer', + 'plugin_forum_posts' => 'integer', 'plugin_forum_viewed' => 'radio' ); $failed = false; $ext = e107::getUserExt(); - foreach ($fieldList as $fieldName => $fieldType) + foreach($fieldList as $fieldName => $fieldType) { $result = $ext->user_extended_add_system($fieldName, $fieldType); - if ($result === true) + if($result === true) { - $mes -> addSuccess('Creating extended user field user_' . $fieldName); + $mes->addSuccess('Creating extended user field user_' . $fieldName); } else { - $mes -> addError('Creating extended user field user_' . $fieldName); - $mes->addDebug(print_a($result,true)); + $mes->addError('Creating extended user field user_' . $fieldName); + $mes->addDebug(print_a($result, true)); $failed = true; } } - if ($failed) + if($failed) { - $mes -> addError("Creation of extended field(s) failed. You can not continue until these are create successfully!"); + $mes->addError("Creation of extended field(s) failed. You can not continue until these are create successfully!"); } else @@ -298,19 +304,20 @@ function step3() "; } - $ns -> tablerender($stepCaption, $mes -> render() . $text); + $ns->tablerender($stepCaption, $mes->render() . $text); } function step4() { + global $pref; $mes = e107::getMessage(); $ns = e107::getRender(); $stepCaption = 'Step 4: Move user specific forum data and forum prefs'; - if (!isset($_POST['move_user_data'])) + if(!isset($_POST['move_user_data'])) { $text = " This step will move the main forum preferences into its own table row. It will also move all user_viewed data from user table into the user extended table.
@@ -322,7 +329,8 @@ function step4() "; - $ns -> tablerender($stepCaption, $text); + $ns->tablerender($stepCaption, $text); + return; } @@ -330,14 +338,14 @@ function step4() $fconf = e107::getPlugConfig('forum', '', false); $coreConfig = e107::getConfig(); $old_prefs = array(); - foreach ($pref as $k => $v) + foreach($pref as $k => $v) { - if (substr($k, 0, 6) == 'forum_') + if(substr($k, 0, 6) == 'forum_') { $nk = substr($k, 6); - $mes -> addDebug("Converting $k to $nk"); + $mes->addDebug("Converting $k to $nk"); $old_prefs[$nk] = $v; - $coreConfig -> remove($k); + $coreConfig->remove($k); } } @@ -348,15 +356,15 @@ function step4() //'email_notify_on' ); - foreach ($forumPrefList as $_fp) + foreach($forumPrefList as $_fp) { - $mes -> addDebug("converting $_fp to $_fp"); - $old_prefs[$_fp] = $coreConfig -> get($_fp); - $coreConfig -> remove($_fp); + $mes->addDebug("converting $_fp to $_fp"); + $old_prefs[$_fp] = $coreConfig->get($_fp); + $coreConfig->remove($_fp); } - $fconf -> setPref($old_prefs) -> save(false, true); - $coreConfig -> save(false, true); + $fconf->setPref($old_prefs)->save(false, true); + $coreConfig->save(false, true); // -----Upgrade old menu prefs ---------------- @@ -366,22 +374,21 @@ function step4() // -------------------- - $result = array( - 'usercount' => 0, - 'viewcount' => 0, + 'usercount' => 0, + 'viewcount' => 0, 'trackcount' => 0 ); $db = new db; - if ($db -> select('user', 'user_id, user_viewed, user_realm', "user_viewed != '' OR user_realm != ''")) + if($db->select('user', 'user_id, user_viewed, user_realm', "user_viewed != '' OR user_realm != ''")) { - require_once (e_HANDLER . 'user_extended_class.php'); + require_once(e_HANDLER . 'user_extended_class.php'); $ue = new e107_user_extended; - while ($row = $db -> fetch()) + while($row = $db->fetch()) { $result['usercount']++; - $userId = (int)$row['user_id']; + $userId = (int) $row['user_id']; $viewed = $row['user_viewed']; $viewed = trim($viewed, '.'); @@ -397,35 +404,35 @@ function step4() $debug .= 'viewed = ' . $viewed . '
'; $debug .= 'realm = ' . $realm . '
'; $debug .= 'tracking = ' . implode(',', $trackList) . '
'; - // $debug .= print_a($trackList, true); - // $mes -> addDebug($debug); + // $debug .= print_a($trackList, true); + // $mes -> addDebug($debug); - if ($viewed != '') + if($viewed != '') { $ue->user_extended_setvalue($userId, 'plugin_forum_viewed', ($viewed)); $result['viewcount']++; } - if (is_array($trackList) && count($trackList)) + if(is_array($trackList) && count($trackList)) { - foreach ($trackList as $threadId) + foreach($trackList as $threadId) { $result['trackcount']++; - $threadId = (int)$threadId; - if ($threadId > 0) + $threadId = (int) $threadId; + if($threadId > 0) { $tmp = array(); $tmp['track_userid'] = $userId; $tmp['track_thread'] = $threadId; - e107::getDb() -> insert('forum_track', $tmp); + e107::getDb()->insert('forum_track', $tmp); } } } } } - $mes -> addSuccess("User data move results: + $mes->addSuccess("User data move results: