mirror of
https://github.com/e107inc/e107.git
synced 2025-07-16 20:41:27 +02:00
Forum: code cleanup. BC Fixes for Breadcrumb.
This commit is contained in:
@@ -1205,7 +1205,7 @@ if(!deftrue('OLD_FORUMADMIN'))
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
$e_sub_cat = 'forum';
|
$e_sub_cat = 'forum';
|
||||||
|
|
||||||
require_once(e_ADMIN.'auth.php');
|
require_once(e_ADMIN.'auth.php');
|
||||||
@@ -2405,11 +2405,11 @@ class forumAdmin
|
|||||||
|
|
||||||
if(!$pref['image_post'])
|
if(!$pref['image_post'])
|
||||||
{
|
{
|
||||||
$text .= "<br /><b>".FORLAN_139."</b>"; // TODO LAN
|
$text .= "<br /><b>".FORLAN_139."</b>"; //
|
||||||
}
|
}
|
||||||
if(!is_writable(e_PLUGIN.'forum/attachments'))
|
if(!is_writable(e_PLUGIN.'forum/attachments'))
|
||||||
{
|
{
|
||||||
$text .= "<br /><b>Attachment dir (".e_PLUGIN_ABS.'forum/attachments'.") is not writable!</b>"; // TODO LAN
|
$text .= "<br /><b>Attachment dir (".e_PLUGIN_ABS.'forum/attachments'.") is not writable!</b>"; //
|
||||||
}
|
}
|
||||||
|
|
||||||
$text .= "</td>
|
$text .= "</td>
|
||||||
@@ -2489,7 +2489,7 @@ class forumAdmin
|
|||||||
|
|
||||||
function show_reported($sub_action)
|
function show_reported($sub_action)
|
||||||
{
|
{
|
||||||
$rs = new form; // FIXME - update to $frm
|
$rs = new form;
|
||||||
$sql = e107::getDb();
|
$sql = e107::getDb();
|
||||||
$ns = e107::getRender();
|
$ns = e107::getRender();
|
||||||
$tp = e107::getParser();
|
$tp = e107::getParser();
|
||||||
@@ -2685,8 +2685,9 @@ class forumAdmin
|
|||||||
</form>";
|
</form>";
|
||||||
$ns->tablerender(LAN_FORUM_2003, $txt);
|
$ns->tablerender(LAN_FORUM_2003, $txt);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
// TODO: check media category on $frm->bbarea()
|
//
|
||||||
|
/*
|
||||||
function show_rules()
|
function show_rules()
|
||||||
{
|
{
|
||||||
$pref = e107::getPref();
|
$pref = e107::getPref();
|
||||||
@@ -2694,7 +2695,7 @@ class forumAdmin
|
|||||||
$sql = e107::getDB();
|
$sql = e107::getDB();
|
||||||
$tp = e107::getParser();
|
$tp = e107::getParser();
|
||||||
$frm = e107::getForm();
|
$frm = e107::getForm();
|
||||||
|
*/
|
||||||
/*
|
/*
|
||||||
$sql->select("wmessage");
|
$sql->select("wmessage");
|
||||||
list($null) = $sql->fetch();
|
list($null) = $sql->fetch();
|
||||||
@@ -2705,7 +2706,7 @@ class forumAdmin
|
|||||||
list($id, $adminrules, $wm_active6) = $sql->fetch();
|
list($id, $adminrules, $wm_active6) = $sql->fetch();
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
if($sql->select('generic','*',"gen_type='forum_rules_guest'"))
|
if($sql->select('generic','*',"gen_type='forum_rules_guest'"))
|
||||||
{
|
{
|
||||||
$guest_rules = $sql->fetch();
|
$guest_rules = $sql->fetch();
|
||||||
@@ -2817,4 +2818,5 @@ class forumAdmin
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
?>
|
?>
|
@@ -1888,6 +1888,7 @@ class e107forum
|
|||||||
|
|
||||||
if(is_array($FORUM_CRUMB))
|
if(is_array($FORUM_CRUMB))
|
||||||
{
|
{
|
||||||
|
|
||||||
$search = array('{SITENAME}', '{SITENAME_HREF}');
|
$search = array('{SITENAME}', '{SITENAME_HREF}');
|
||||||
$replace = array(SITENAME, e107::getUrl()->create('/'));
|
$replace = array(SITENAME, e107::getUrl()->create('/'));
|
||||||
$FORUM_CRUMB['sitename']['value'] = str_replace($search, $replace, $FORUM_CRUMB['sitename']['value']);
|
$FORUM_CRUMB['sitename']['value'] = str_replace($search, $replace, $FORUM_CRUMB['sitename']['value']);
|
||||||
@@ -1903,7 +1904,7 @@ class e107forum
|
|||||||
if($forumInfo['forum_sub'])
|
if($forumInfo['forum_sub'])
|
||||||
{
|
{
|
||||||
$search = array('{SUBPARENT_TITLE}', '{SUBPARENT_HREF}');
|
$search = array('{SUBPARENT_TITLE}', '{SUBPARENT_HREF}');
|
||||||
$replace = array(ltrim($forumInfo['sub_parent'], '*'), e107::getUrl()->create('forum/forum/view', "id={$forumInfo['forum_sub']}")); // XXX forum sub name
|
$replace = array(ltrim($forumInfo['sub_parent'], '*'), e107::url('forum', 'forum', array('forum_id'=>$forumInfo['parent_id'],'forum_sef'=>$forumInfo['parent_sef'])));
|
||||||
$FORUM_CRUMB['subparent']['value'] = str_replace($search, $replace, $FORUM_CRUMB['subparent']['value']);
|
$FORUM_CRUMB['subparent']['value'] = str_replace($search, $replace, $FORUM_CRUMB['subparent']['value']);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -1912,13 +1913,12 @@ class e107forum
|
|||||||
}
|
}
|
||||||
|
|
||||||
$search = array('{FORUM_TITLE}', '{FORUM_HREF}');
|
$search = array('{FORUM_TITLE}', '{FORUM_HREF}');
|
||||||
// TODO - remove 'href=' from the return value
|
$replace = array(ltrim($forumInfo['forum_name'], '*'), e107::url('forum', 'forum', $forumInfo));
|
||||||
$replace = array(ltrim($forumInfo['forum_name'], '*'), e107::getUrl()->create('forum/forum/view', $forumInfo));
|
|
||||||
$FORUM_CRUMB['forum']['value'] = str_replace($search, $replace, $FORUM_CRUMB['forum']['value']);
|
$FORUM_CRUMB['forum']['value'] = str_replace($search, $replace, $FORUM_CRUMB['forum']['value']);
|
||||||
|
|
||||||
$threadInfo['thread_id'] = intval($threadInfo['thread_id']);
|
$threadInfo['thread_id'] = intval($threadInfo['thread_id']);
|
||||||
$search = array('{THREAD_TITLE}', '{THREAD_HREF}');
|
$search = array('{THREAD_TITLE}', '{THREAD_HREF}');
|
||||||
$replace = array(vartrue($threadInfo['thread_name']), e107::getUrl()->create('forum/thread/view', $threadInfo)); // $thread->threadInfo - no reference found
|
$replace = array(vartrue($threadInfo['thread_name']), ''); // $thread->threadInfo - no reference found
|
||||||
$FORUM_CRUMB['thread']['value'] = str_replace($search, $replace, $FORUM_CRUMB['thread']['value']);
|
$FORUM_CRUMB['thread']['value'] = str_replace($search, $replace, $FORUM_CRUMB['thread']['value']);
|
||||||
|
|
||||||
$FORUM_CRUMB['fieldlist'] = 'sitename,forums,parent,subparent,forum,thread';
|
$FORUM_CRUMB['fieldlist'] = 'sitename,forums,parent,subparent,forum,thread';
|
||||||
@@ -1927,6 +1927,9 @@ class e107forum
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$dfltsep = ' :: ';
|
$dfltsep = ' :: ';
|
||||||
$BREADCRUMB = "<a class='forumlink' href='".e_BASE."index.php'>".SITENAME."</a>".$dfltsep."<a class='forumlink' href='".e_PLUGIN."forum/forum.php'>".LAN_PLUGIN_FORUM_NAME."</a>".$dfltsep;
|
$BREADCRUMB = "<a class='forumlink' href='".e_BASE."index.php'>".SITENAME."</a>".$dfltsep."<a class='forumlink' href='".e_PLUGIN."forum/forum.php'>".LAN_PLUGIN_FORUM_NAME."</a>".$dfltsep;
|
||||||
if($forumInfo['sub_parent'])
|
if($forumInfo['sub_parent'])
|
||||||
@@ -1937,6 +1940,7 @@ class e107forum
|
|||||||
|
|
||||||
$tmpFname = $forumInfo['forum_name'];
|
$tmpFname = $forumInfo['forum_name'];
|
||||||
if(substr($tmpFname, 0, 1) == "*") { $tmpFname = substr($tmpFname, 1); }
|
if(substr($tmpFname, 0, 1) == "*") { $tmpFname = substr($tmpFname, 1); }
|
||||||
|
|
||||||
if ($forum_href)
|
if ($forum_href)
|
||||||
{
|
{
|
||||||
$BREADCRUMB .= "<a class='forumlink' href='".e_PLUGIN."forum/forum_viewforum.php?{$forumInfo['forum_id']}'>".$tp->toHTML($tmpFname, TRUE, 'no_hook,emotes_off')."</a>";
|
$BREADCRUMB .= "<a class='forumlink' href='".e_PLUGIN."forum/forum_viewforum.php?{$forumInfo['forum_id']}'>".$tp->toHTML($tmpFname, TRUE, 'no_hook,emotes_off')."</a>";
|
||||||
|
@@ -20,12 +20,11 @@ if(!defined('e107_INIT'))
|
|||||||
|
|
||||||
define('NAVIGATION_ACTIVE','forum'); // ??
|
define('NAVIGATION_ACTIVE','forum'); // ??
|
||||||
|
|
||||||
$e107 = e107::getInstance();
|
|
||||||
$tp = e107::getParser();
|
$tp = e107::getParser();
|
||||||
$ns = e107::getRender();
|
$ns = e107::getRender();
|
||||||
$mes = e107::getMessage();
|
$mes = e107::getMessage();
|
||||||
|
|
||||||
if (!$e107->isInstalled('forum'))
|
if (!e107::isInstalled('forum'))
|
||||||
{
|
{
|
||||||
e107::redirect();
|
e107::redirect();
|
||||||
exit;
|
exit;
|
||||||
@@ -492,10 +491,6 @@ class forum_post_handler
|
|||||||
</form>";
|
</form>";
|
||||||
|
|
||||||
|
|
||||||
// $threadName = $tp->toHTML($this->data['thread_name'], true);
|
|
||||||
// $threadText = ;
|
|
||||||
|
|
||||||
// $text .= "<h3>".$threadName."</h3><div>".$threadText."</div>"; // $e107->ns->tablerender(, ), '', true).$ns->tablerender('', $text, '', true);
|
|
||||||
$ns->tablerender(LAN_FORUM_5019, $text);
|
$ns->tablerender(LAN_FORUM_5019, $text);
|
||||||
|
|
||||||
|
|
||||||
@@ -1199,601 +1194,4 @@ require_once(FOOTERF);
|
|||||||
exit;
|
exit;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
require_once(e_PLUGIN.'forum/forum_class.php');
|
|
||||||
$forum = new e107forum();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$action = trim($_GET['f']); //
|
|
||||||
$id = (int)$_GET['id']; // topic / thread.
|
|
||||||
$post = (int) $_GET['post']; // individual post.
|
|
||||||
|
|
||||||
if(!empty($_POST['action']))
|
|
||||||
{
|
|
||||||
$action = $_POST['action'];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
switch($action)
|
|
||||||
{
|
|
||||||
case 'rp':
|
|
||||||
$threadInfo = $forum->threadGet($id, false);
|
|
||||||
$forumId = $threadInfo['thread_forum_id'];
|
|
||||||
$forumInfo = $forum->forumGet($forumId);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'nt':
|
|
||||||
$forumInfo = $forum->forumGet($id);
|
|
||||||
$forumId = $id;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'quote':
|
|
||||||
case 'edit':
|
|
||||||
$postInfo = $forum->postGet($post, 'post');
|
|
||||||
$threadInfo = $postInfo;
|
|
||||||
$forumId = $postInfo['post_forum'];
|
|
||||||
$forumInfo = $forum->forumGet($forumId);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
header("Location:".e107::getUrl()->create('forum/forum/main', array(), 'full=1&encode=0'));
|
|
||||||
exit;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// check if user can post to this forum ...
|
|
||||||
if (!$forum->checkPerm($forumId, 'post'))
|
|
||||||
{
|
|
||||||
require_once(HEADERF);
|
|
||||||
$mes->addError(LAN_FORUM_3001);
|
|
||||||
//$mes->addDebug("action: ".$action);
|
|
||||||
// $mes->addDebug("id: ".$id);
|
|
||||||
// $mes->addDebug(print_a($threadInfo, true));
|
|
||||||
$ns->tablerender(LAN_FORUM_1001, $mes->render());
|
|
||||||
require_once(FOOTERF);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
define('MODERATOR', USER && $forum->isModerator(USERID));
|
|
||||||
require_once(e_HANDLER.'ren_help.php'); // FIXME deprecated
|
|
||||||
|
|
||||||
//e107::getScBatch('view', 'forum'); //XXX FIXME Conflicting shortcode names. Find a solution without renaming them.
|
|
||||||
$sc = e107::getScBatch('post', 'forum')->setScVar('forum', $forum)->setScVar('threadInfo', vartrue($threadInfo));
|
|
||||||
|
|
||||||
$gen = new convert;
|
|
||||||
$fp = new floodprotect;
|
|
||||||
$e107 = e107::getInstance();
|
|
||||||
|
|
||||||
//if thread is not active and not new thread, show warning
|
|
||||||
if ($action != 'nt' && !$threadInfo['thread_active'] && !MODERATOR)
|
|
||||||
{
|
|
||||||
require_once(HEADERF);
|
|
||||||
$mes->addError(LAN_FORUM_3002);
|
|
||||||
$ns->tablerender(LAN_FORUM_1001, $mes->render());
|
|
||||||
require_once(FOOTERF);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
$forumInfo['forum_name'] = $tp->toHTML($forumInfo['forum_name'], true);
|
|
||||||
define('e_PAGETITLE', ($action == 'rp' ? LAN_FORUM_3003.": ".$threadInfo['thread_name'] : LAN_FORUM_1018).' / '.$forumInfo['forum_name'].' / '.LAN_FORUM_1001);
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
if($forum->prefs->get('attach'))
|
|
||||||
{
|
|
||||||
global $allowed_filetypes, $max_upload_size;
|
|
||||||
include_once(e_HANDLER.'upload_handler.php');
|
|
||||||
$a_filetypes = get_filetypes();
|
|
||||||
$max_upload_size = calc_max_upload_size(-1); // Find overriding maximum upload size
|
|
||||||
$max_upload_size = set_max_size($a_filetypes, $max_upload_size);
|
|
||||||
$max_upload_size = $e107->parseMemorySize($max_upload_size, 0);
|
|
||||||
$a_filetypes = array_keys($a_filetypes);
|
|
||||||
$allowed_filetypes = implode(', ', $a_filetypes);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($_POST['submitpoll']))
|
|
||||||
{
|
|
||||||
require_once(e_PLUGIN.'poll/poll_class.php');
|
|
||||||
$poll = new poll;
|
|
||||||
|
|
||||||
require_once(HEADERF);
|
|
||||||
if (!$FORUMPOST)
|
|
||||||
{
|
|
||||||
if (file_exists(THEME.'forum_posted_template.php'))
|
|
||||||
{
|
|
||||||
require_once(THEME.'forum_posted_template.php');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
require_once(e_PLUGIN.'forum/templates/forum_posted_template.php');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
echo $FORUMPOLLPOSTED;
|
|
||||||
require_once(FOOTERF);
|
|
||||||
exit;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
/*if (isset($_POST['fpreview']))
|
|
||||||
{
|
|
||||||
process_upload();
|
|
||||||
require_once(HEADERF);
|
|
||||||
if (USER)
|
|
||||||
{
|
|
||||||
$poster = USERNAME;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$poster = ($_POST['anonname']) ? $_POST['anonname'] : LAN_ANONYMOUS;
|
|
||||||
}
|
|
||||||
$postdate = $gen->convert_date(time(), "forum");
|
|
||||||
$tsubject = $tp->post_toHTML($_POST['subject'], true);
|
|
||||||
$tpost = $tp->post_toHTML($_POST['post'], true);
|
|
||||||
|
|
||||||
if ($_POST['poll_title'] != '' && check_class($forum->prefs->get('poll')))
|
|
||||||
{
|
|
||||||
require_once(e_PLUGIN."poll/poll_class.php");
|
|
||||||
$poll = new poll;
|
|
||||||
$poll->render_poll($_POST, 'forum', 'notvoted');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$FORUM_PREVIEW)
|
|
||||||
{
|
|
||||||
if (file_exists(THEME."forum_preview_template.php"))
|
|
||||||
{
|
|
||||||
require_once(THEME."forum_preview_template.php");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
require_once(e_PLUGIN."forum/templates/forum_preview_template.php");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$text = $FORUM_PREVIEW;
|
|
||||||
|
|
||||||
if ($poll_text)
|
|
||||||
{
|
|
||||||
$ns->tablerender($_POST['poll_title'], $poll_text);
|
|
||||||
}
|
|
||||||
$ns->tablerender(LAN_FORUM_3005, $text);
|
|
||||||
$anonname = $tp->post_toHTML($_POST['anonname'], FALSE);
|
|
||||||
|
|
||||||
$post = $tp->post_toForm($_POST['post']);
|
|
||||||
$subject = $tp->post_toHTML($_POST['subject'], false);
|
|
||||||
|
|
||||||
if ($action == 'edit')
|
|
||||||
{
|
|
||||||
if ($_POST['subject'])
|
|
||||||
{
|
|
||||||
$action = 'edit';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$action = 'reply';
|
|
||||||
}
|
|
||||||
$eaction = true;
|
|
||||||
}
|
|
||||||
else if($action == 'quote')
|
|
||||||
{
|
|
||||||
$action = 'reply';
|
|
||||||
$eaction = false;
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
/*
|
|
||||||
if (isset($_POST['newthread']) || isset($_POST['reply']))
|
|
||||||
{
|
|
||||||
$postInfo = array();
|
|
||||||
$threadInfo = array();
|
|
||||||
$postOptions = array();
|
|
||||||
$threadOptions = array();
|
|
||||||
|
|
||||||
if ((isset($_POST['newthread']) && trim($_POST['subject']) == '') || trim($_POST['post']) == '')
|
|
||||||
{
|
|
||||||
message_handler('ALERT', 5);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ($fp->flood('forum_thread', 'thread_datestamp') == false && !ADMIN)
|
|
||||||
{
|
|
||||||
echo "<script type='text/javascript'>document.location.href='".e_BASE."index.php'</script>\n";
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
$hasPoll = ($action == 'nt' && varset($_POST['poll_title']) && $_POST['poll_option'][0] != '' && $_POST['poll_option'][1] != '');
|
|
||||||
$postInfo['post_ip'] = e107::getIPHandler()->getIP(FALSE);
|
|
||||||
|
|
||||||
if (USER)
|
|
||||||
{
|
|
||||||
$postInfo['post_user'] = USERID;
|
|
||||||
$threadInfo['thread_lastuser'] = USERID;
|
|
||||||
$threadInfo['thread_user'] = USERID;
|
|
||||||
$threadInfo['thread_lastuser_anon'] = '';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$postInfo['post_user_anon'] = $_POST['anonname'];
|
|
||||||
$threadInfo['thread_lastuser_anon'] = $_POST['anonname'];
|
|
||||||
$threadInfo['thread_user_anon'] = $_POST['anonname'];
|
|
||||||
}
|
|
||||||
$time = time();
|
|
||||||
$postInfo['post_entry'] = $_POST['post'];
|
|
||||||
$postInfo['post_forum'] = $forumId;
|
|
||||||
$postInfo['post_datestamp'] = $time;
|
|
||||||
$threadInfo['thread_lastpost'] = $time;
|
|
||||||
if(isset($_POST['no_emote']))
|
|
||||||
{
|
|
||||||
$postInfo['post_options'] = serialize(array('no_emote' => 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
//If we've successfully uploaded something, we'll have to edit the post_entry and post_attachments
|
|
||||||
if($uploadResult = process_upload($newPostId))
|
|
||||||
{
|
|
||||||
foreach($uploadResult as $ur)
|
|
||||||
{
|
|
||||||
//$postInfo['post_entry'] .= $ur['txt'];
|
|
||||||
// $_tmp = $ur['type'].'*'.$ur['file'];
|
|
||||||
// if($ur['thumb']) { $_tmp .= '*'.$ur['thumb']; }
|
|
||||||
// if($ur['fname']) { $_tmp .= '*'.$ur['fname']; }
|
|
||||||
|
|
||||||
$type = $ur['type'];
|
|
||||||
$newValues[$type][] = $ur['file'];
|
|
||||||
// $attachments[] = $_tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
// $postInfo['_FIELD_TYPES']['post_attachments'] = 'array';
|
|
||||||
$postInfo['post_attachments'] = e107::serialize($newValues);
|
|
||||||
}
|
|
||||||
// var_dump($uploadResult);
|
|
||||||
|
|
||||||
switch($action)
|
|
||||||
{
|
|
||||||
// Reply only. Add the post, update thread record with latest post info.
|
|
||||||
// Update forum with latest post info
|
|
||||||
case 'rp':
|
|
||||||
$postInfo['post_thread'] = $id;
|
|
||||||
$newPostId = $forum->postAdd($postInfo);
|
|
||||||
break;
|
|
||||||
|
|
||||||
// New thread started. Add the thread info (with lastest post info), add the post.
|
|
||||||
// Update forum with latest post info
|
|
||||||
case 'nt':
|
|
||||||
$threadInfo['thread_sticky'] = (MODERATOR ? (int)$_POST['threadtype'] : 0);
|
|
||||||
$threadInfo['thread_name'] = $_POST['subject'];
|
|
||||||
$threadInfo['thread_forum_id'] = $forumId;
|
|
||||||
$threadInfo['thread_active'] = 1;
|
|
||||||
$threadInfo['thread_datestamp'] = $time;
|
|
||||||
if($hasPoll)
|
|
||||||
{
|
|
||||||
$threadOptions['poll'] = '1';
|
|
||||||
}
|
|
||||||
if(is_array($threadOptions) && count($threadOptions))
|
|
||||||
{
|
|
||||||
$threadInfo['thread_options'] = serialize($threadOptions);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$threadInfo['thread_options'] = '';
|
|
||||||
}
|
|
||||||
if($postResult = $forum->threadAdd($threadInfo, $postInfo))
|
|
||||||
{
|
|
||||||
$newPostId = $postResult['postid'];
|
|
||||||
$newThreadId = $postResult['threadid'];
|
|
||||||
if($_POST['email_notify'])
|
|
||||||
{
|
|
||||||
$forum->track('add', USERID, $newThreadId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// print_a($threadInfo);
|
|
||||||
// print_a($postInfo);
|
|
||||||
// print_a('action: '.$action);
|
|
||||||
// print_a("newId:".$newPostId);
|
|
||||||
// print_a($_POST);
|
|
||||||
// exit;
|
|
||||||
|
|
||||||
if($postResult === -1) //Duplicate post
|
|
||||||
{
|
|
||||||
require_once(HEADERF);
|
|
||||||
$ns->tablerender('', LAN_FORUM_3007);
|
|
||||||
require_once(FOOTERF);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
$threadId = ($action == 'nt' ? $newThreadId : $id);
|
|
||||||
|
|
||||||
|
|
||||||
//If a poll was submitted, let's add it to the poll db
|
|
||||||
if ($action == 'nt' && varset($_POST['poll_title']) && $_POST['poll_option'][0] != '' && $_POST['poll_option'][1] != '')
|
|
||||||
{
|
|
||||||
require_once(e_PLUGIN.'poll/poll_class.php');
|
|
||||||
$_POST['iid'] = $threadId;
|
|
||||||
$poll = new poll;
|
|
||||||
$poll->submit_poll(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
e107::getCache()->clear('newforumposts');
|
|
||||||
|
|
||||||
|
|
||||||
$postInfo = $forum->postGet($newPostId, 'post');
|
|
||||||
$forumInfo = $forum->forumGet($postInfo['post_forum']);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$threadLink = e107::getUrl()->create('forum/thread/last', $postInfo);
|
|
||||||
$forumLink = e107::getUrl()->create('forum/forum/view', $forumInfo);
|
|
||||||
if ($forum->prefs->get('redirect'))
|
|
||||||
{
|
|
||||||
header('location:'.e107::getUrl()->create('forum/thread/last', $postInfo, array('encode' => false, 'full' => true)));
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
require_once(HEADERF);
|
|
||||||
if (!$FORUMPOST)
|
|
||||||
{
|
|
||||||
if (file_exists(THEME."forum_posted_template.php"))
|
|
||||||
{
|
|
||||||
require_once(THEME."forum_posted_template.php");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
require_once(e_PLUGIN."forum/templates/forum_posted_template.php");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// $FORUMTHREADPOSTED
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$txt = (isset($_POST['newthread']) ? $FORUMTHREADPOSTED : $FORUMREPLYPOSTED);
|
|
||||||
e107::getRender()->tablerender('Forums', e107::getMessage()->render().$txt);
|
|
||||||
require_once(FOOTERF);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($_POST['update_thread']))
|
|
||||||
{
|
|
||||||
// var_dump($_POST);
|
|
||||||
// var_dump($threadInfo);
|
|
||||||
// var_dump($postInfo);
|
|
||||||
// exit;
|
|
||||||
if (!$_POST['subject'] || !$_POST['post'])
|
|
||||||
{
|
|
||||||
$error = "<div style='text-align:center'>".LAN_FORUM_3007."</div>";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!isAuthor())
|
|
||||||
{
|
|
||||||
require_once(HEADERF);
|
|
||||||
$mes->addError(LAN_FORUM_3009);
|
|
||||||
$ns->tablerender(LAN_FORUM_3008, $mes->render());
|
|
||||||
require_once(FOOTERF);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
if($uploadResult = process_upload($postInfo['post_id']))
|
|
||||||
{
|
|
||||||
$attachments = explode(',', $postInfo['post_attachments']);
|
|
||||||
foreach($uploadResult as $ur)
|
|
||||||
{
|
|
||||||
$_tmp = $ur['type'].'*'.$ur['file'];
|
|
||||||
if($ur['thumb']) { $_tmp .= '*'.$ur['thumb']; }
|
|
||||||
if($ur['fname']) { $_tmp .= '*'.$ur['fname']; }
|
|
||||||
$attachments[] = $_tmp;
|
|
||||||
}
|
|
||||||
$postVals['post_attachments'] = implode(',', $attachments);
|
|
||||||
}
|
|
||||||
|
|
||||||
$postVals['post_edit_datestamp'] = time();
|
|
||||||
$postVals['post_edit_user'] = USERID;
|
|
||||||
$postVals['post_entry'] = $_POST['post'];
|
|
||||||
|
|
||||||
$threadVals['thread_name'] = $_POST['subject'];
|
|
||||||
|
|
||||||
$forum->threadUpdate($postInfo['post_thread'], $threadVals);
|
|
||||||
$forum->postUpdate($postInfo['post_id'], $postVals);
|
|
||||||
e107::getCache()->clear('newforumposts');
|
|
||||||
$url = e107::getUrl()->create('forum/thread/post', array('name'=>$threadVals['thread_name'], 'id' => $postInfo['post_id'], 'thread' => $postInfo['post_thread']), array('encode'=>false));
|
|
||||||
header('location:'.$url);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($_POST['update_reply']))
|
|
||||||
{
|
|
||||||
if (!$_POST['post'])
|
|
||||||
{
|
|
||||||
$error = "<div style='text-align:center'>".LAN_FORUM_3007.'</div>';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!isAuthor())
|
|
||||||
{
|
|
||||||
require_once(HEADERF);
|
|
||||||
$mes->addError(LAN_FORUM_3009);
|
|
||||||
$ns->tablerender(LAN_FORUM_3008, $mes->render());
|
|
||||||
require_once(FOOTERF);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
$postVals['post_edit_datestamp'] = time();
|
|
||||||
$postVals['post_edit_user'] = USERID;
|
|
||||||
$postVals['post_entry'] = $_POST['post'];
|
|
||||||
|
|
||||||
$forum->postUpdate($postInfo['post_id'], $postVals);
|
|
||||||
e107::getCache()->clear('newforumposts');
|
|
||||||
$url = e107::getUrl()->create('forum/thread/post', "id={$postInfo['post_id']}", 'encode=0&full=1'); // XXX what data is available, find thread name
|
|
||||||
header('location:'.$url);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
require_once(HEADERF);
|
|
||||||
|
|
||||||
if (vartrue($error))
|
|
||||||
{
|
|
||||||
$ns->tablerender(LAN_ERROR, $error); // LAN?
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ($action == 'edit' || $action == 'quote')
|
|
||||||
{
|
|
||||||
if ($action == 'edit')
|
|
||||||
{
|
|
||||||
if (!isAuthor())
|
|
||||||
{
|
|
||||||
$mes->addError(LAN_FORUM_3009);
|
|
||||||
$ns->tablerender(LAN_FORUM_3008, $mes->render());
|
|
||||||
require_once(FOOTERF);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isset($_POST['fpreview']))
|
|
||||||
{
|
|
||||||
$post = $tp->toForm($postInfo['post_entry']);
|
|
||||||
if($postInfo['post_datestamp'] == $postInfo['thread_datestamp'])
|
|
||||||
{
|
|
||||||
$subject = $tp->toForm($postInfo['thread_name']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($action == 'quote')
|
|
||||||
{
|
|
||||||
|
|
||||||
//remote [hide] bbcode, or else it doesn't hide stuff too well :)
|
|
||||||
// $post = preg_replace('#\[hide].*?\[/hide]#s', '', $post);
|
|
||||||
// $quoteName = ($postInfo['user_name'] ? $postInfo['user_name'] : $postInfo['post_user_anon']);
|
|
||||||
// $post = "[quote={$quoteName}]\n".$post."\n[/quote]\n";
|
|
||||||
|
|
||||||
// $eaction = true;
|
|
||||||
// $action = 'reply';
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$eaction = true;
|
|
||||||
if($postInfo['post_datestamp'] != $postInfo['thread_datestamp'])
|
|
||||||
{
|
|
||||||
$action = 'rp';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$action = 'nt';
|
|
||||||
$sact = 'canc'; // added to override the bugtracker query below
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$postInfo['action'] = $action;
|
|
||||||
|
|
||||||
$sc->setVars($postInfo); // send data to shortcodes - remove globals!
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
||||||
//Load forumpost template
|
|
||||||
|
|
||||||
if (!vartrue($FORUMPOST))
|
|
||||||
{
|
|
||||||
if (is_readable(THEME.'forum_post_template.php'))
|
|
||||||
{
|
|
||||||
include_once(THEME.'forum_post_template.php');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
include_once(e_PLUGIN.'forum/templates/forum_post_template.php');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(isset($FORUMPOST_TEMPLATE) && (deftrue('BOOTSTRAP',false)))
|
|
||||||
{
|
|
||||||
$FORUMPOST = $FORUMPOST_TEMPLATE['form'];
|
|
||||||
$FORUMPOST_REPLY = $FORUMPOST_TEMPLATE['form'];
|
|
||||||
}
|
|
||||||
|
|
||||||
if($action == 'rp')
|
|
||||||
{
|
|
||||||
$FORUMPOST = $FORUMPOST_REPLY;
|
|
||||||
}
|
|
||||||
e107::lan('forum','English_front');
|
|
||||||
$text = $tp->parseTemplate($FORUMPOST, true, $sc);
|
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
if ($forum->prefs->get('enclose'))
|
|
||||||
{
|
|
||||||
$ns->tablerender($forum->prefs->get('title'), $text);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
echo $text;
|
|
||||||
}
|
|
||||||
|
|
||||||
function isAuthor()
|
|
||||||
{
|
|
||||||
global $postInfo;
|
|
||||||
return ((USERID === (int)$postInfo['post_user']) || MODERATOR);
|
|
||||||
}
|
|
||||||
|
|
||||||
function forumjump()
|
|
||||||
{
|
|
||||||
global $forum;
|
|
||||||
$jumpList = $forum->forumGetAllowed('view');
|
|
||||||
$text = "<form method='post' action='".e_SELF."'><p>".LAN_FORUM_1017.": <select name='forumjump' class='tbox'>";
|
|
||||||
foreach($jumpList as $key => $val)
|
|
||||||
{
|
|
||||||
$text .= "\n<option value='".e107::url('forum','forum', $val)."'>".$val['forum_name']."</option>";
|
|
||||||
}
|
|
||||||
$text .= "</select> <input class='btn btn-default button' type='submit' name='fjsubmit' value='".LAN_GO."' /></p></form>";
|
|
||||||
return $text;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function image_getsize($fname)
|
|
||||||
{
|
|
||||||
if($imginfo = getimagesize($fname))
|
|
||||||
{
|
|
||||||
return ":width={$imginfo[0]}&height={$imginfo[1]}";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
require_once(FOOTERF);*/
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@@ -127,25 +127,27 @@ class forumStats
|
|||||||
ORDER BY post_count DESC LIMIT 0,10";
|
ORDER BY post_count DESC LIMIT 0,10";
|
||||||
|
|
||||||
$sql->gen($query);
|
$sql->gen($query);
|
||||||
$top_repliers_data = $sql->db_getList('ALL', false, false, 'user_id');
|
// $top_repliers_data = $sql->db_getList('ALL', false, false, 'user_id');
|
||||||
|
$top_repliers_data = $sql->retrieve($query,true);
|
||||||
|
|
||||||
// build top posters meanwhile
|
// build top posters meanwhile
|
||||||
$top_posters = array();
|
$top_posters = array();
|
||||||
|
$topReplier = array();
|
||||||
foreach($top_repliers_data as $poster)
|
foreach($top_repliers_data as $poster)
|
||||||
{
|
{
|
||||||
$percent = round(($poster['post_count'] / $total_posts) * 100, 2);
|
$percent = round(($poster['post_count'] / $total_posts) * 100, 2);
|
||||||
$top_posters[] = array("user_id" => $poster['user_id'], "user_name" => $poster['user_name'], "user_forums" => $poster['post_count'], "percentage" => $percent);
|
$topReplier[] = intval($poster['user_id']);
|
||||||
|
$top_posters[] = array("user_id" => $poster['user_id'], "user_name" => vartrue($poster['user_name'],LAN_ANONYMOUS), "user_forums" => $poster['post_count'], "percentage" => $percent);
|
||||||
}
|
}
|
||||||
// end build top posters
|
// end build top posters
|
||||||
|
|
||||||
$ids = implode(',', array_keys($top_repliers_data));
|
$ids = implode(',', $topReplier);
|
||||||
|
|
||||||
// find topics by top 10 users
|
// find topics by top 10 users
|
||||||
$query = "
|
$query = "
|
||||||
SELECT COUNT(ft.thread_id) AS thread_count, u.user_id FROM #forum_thread as ft
|
SELECT COUNT(ft.thread_id) AS thread_count, u.user_id FROM #forum_thread as ft
|
||||||
LEFT JOIN #user AS u ON ft.thread_user = u.user_id
|
LEFT JOIN #user AS u ON ft.thread_user = u.user_id
|
||||||
WHERE u.user_id IN ({$ids})
|
WHERE u.user_id IN ({$ids}) GROUP BY ft.thread_user";
|
||||||
GROUP BY ft.thread_user";
|
|
||||||
|
|
||||||
$sql->gen($query);
|
$sql->gen($query);
|
||||||
$top_repliers_data_c = $sql->db_getList('ALL', false, false, 'user_id');
|
$top_repliers_data_c = $sql->db_getList('ALL', false, false, 'user_id');
|
||||||
@@ -186,7 +188,7 @@ class forumStats
|
|||||||
foreach($top_topic_starters_data as $poster)
|
foreach($top_topic_starters_data as $poster)
|
||||||
{
|
{
|
||||||
$percent = round(($poster['thread_count'] / $total_topics) * 100, 2);
|
$percent = round(($poster['thread_count'] / $total_topics) * 100, 2);
|
||||||
$top_topic_starters[] = array("user_id" => $poster['user_id'], "user_name" => $poster['user_name'], "user_forums" => $poster['thread_count'], "percentage" => $percent);
|
$top_topic_starters[] = array("user_id" => $poster['user_id'], "user_name" => vartrue($poster['user_name'],LAN_ANONYMOUS), "user_forums" => $poster['thread_count'], "percentage" => $percent);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -355,15 +357,12 @@ class forumStats
|
|||||||
$count=1;
|
$count=1;
|
||||||
foreach($top_posters as $ma)
|
foreach($top_posters as $ma)
|
||||||
{
|
{
|
||||||
extract($ma); // TODO Remove me.
|
|
||||||
|
|
||||||
//TODO SEf Url .
|
|
||||||
$text_3 .= "<tr>
|
$text_3 .= "<tr>
|
||||||
<td style='width: 10%; text-align: center;' class='forumheader3'>$count</td>
|
<td style='width: 10%; text-align: center;' class='forumheader3'>$count</td>
|
||||||
<td style='width: 20%;' class='forumheader3'><a href='".e107::getUrl()->create('user/profile/view', $ma)."'>".$ma['user_name']."</a></td>
|
<td style='width: 20%;' class='forumheader3'><a href='".e107::getUrl()->create('user/profile/view', $ma)."'>".$ma['user_name']."</a></td>
|
||||||
<td style='width: 10%; text-align: center;' class='forumheader3'>$user_forums</td>
|
<td style='width: 10%; text-align: center;' class='forumheader3'>".$ma['user_forums']."</td>
|
||||||
<td style='width: 10%; text-align: center;' class='forumheader3'>$percentage%</td>
|
<td style='width: 10%; text-align: center;' class='forumheader3'>".$ma['percentage']."%</td>
|
||||||
<td style='width: 50%;' class='forumheader3'>".$this->showBar($percentage)."
|
<td style='width: 50%;' class='forumheader3'>".$this->showBar($ma['percentage'])."
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
";
|
";
|
||||||
@@ -392,16 +391,12 @@ class forumStats
|
|||||||
$count=1;
|
$count=1;
|
||||||
foreach($top_topic_starters as $ma)
|
foreach($top_topic_starters as $ma)
|
||||||
{
|
{
|
||||||
extract($ma); // TODO Remove me.
|
|
||||||
//TODO SEf Url .
|
|
||||||
|
|
||||||
|
|
||||||
$text_4 .= "<tr>
|
$text_4 .= "<tr>
|
||||||
<td style='width: 10%; text-align: center;' class='forumheader3'>$count</td>
|
<td style='width: 10%; text-align: center;' class='forumheader3'>$count</td>
|
||||||
<td style='width: 20%;' class='forumheader3'><a href='".e107::getUrl()->create('user/profile/view', $ma)."'>$user_name</a></td>
|
<td style='width: 20%;' class='forumheader3'><a href='".e107::getUrl()->create('user/profile/view', $ma)."'>".$ma['user_name']."</a></td>
|
||||||
<td style='width: 10%; text-align: center;' class='forumheader3'>$user_forums</td>
|
<td style='width: 10%; text-align: center;' class='forumheader3'>".$ma['user_forums']."</td>
|
||||||
<td style='width: 10%; text-align: center;' class='forumheader3'>$percentage%</td>
|
<td style='width: 10%; text-align: center;' class='forumheader3'>".$ma['percentage']."%</td>
|
||||||
<td style='width: 50%; text-align: center;' class='forumheader3'>".$this->showBar($percentage)."</td>
|
<td style='width: 50%; text-align: center;' class='forumheader3'>".$this->showBar($ma['percentage'])."</td>
|
||||||
</tr>
|
</tr>
|
||||||
";
|
";
|
||||||
$count++;
|
$count++;
|
||||||
@@ -426,16 +421,13 @@ class forumStats
|
|||||||
$count=1;
|
$count=1;
|
||||||
foreach($top_repliers as $ma)
|
foreach($top_repliers as $ma)
|
||||||
{
|
{
|
||||||
extract($ma); // TODO Remove me.
|
|
||||||
//TODO SEf Url .
|
|
||||||
|
|
||||||
$text_5 .= "
|
$text_5 .= "
|
||||||
<tr>
|
<tr>
|
||||||
<td style='width: 10%; text-align: center;' class='forumheader3'>$count</td>
|
<td style='width: 10%; text-align: center;' class='forumheader3'>$count</td>
|
||||||
<td style='width: 20%;' class='forumheader3'><a href='".e107::getUrl()->create('user/profile/view', $ma)."'>$user_name</a></td>
|
<td style='width: 20%;' class='forumheader3'><a href='".e107::getUrl()->create('user/profile/view', $ma)."'>".$ma['user_name']."</a></td>
|
||||||
<td style='width: 10%; text-align: center;' class='forumheader3'>$user_forums</td>
|
<td style='width: 10%; text-align: center;' class='forumheader3'>".$ma['user_forums']."</td>
|
||||||
<td style='width: 10%; text-align: center;' class='forumheader3'>$percentage%</td>
|
<td style='width: 10%; text-align: center;' class='forumheader3'>".$ma['percentage']."%</td>
|
||||||
<td style='width: 50%; text-align: center;' class='forumheader3'>".$this->showBar($percentage)."</td>
|
<td style='width: 50%; text-align: center;' class='forumheader3'>".$this->showBar($ma['percentage'])."</td>
|
||||||
</tr>
|
</tr>
|
||||||
";
|
";
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user