1
0
mirror of https://github.com/e107inc/e107.git synced 2025-06-10 21:21:03 +02:00

More forum code changes

Committed on the Free edition of March Hare Software CVSNT Server.
Upgrade to CVS Suite for more features and support:
http://march-hare.com/cvsnt/
This commit is contained in:
mcfly
2008-12-01 01:10:50 +00:00
parent 2407827501
commit 326b718b43
7 changed files with 191 additions and 92 deletions

View File

@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/class2.php,v $
| $Revision: 1.79 $
| $Date: 2008-11-30 23:15:15 $
| $Revision: 1.80 $
| $Date: 2008-12-01 01:10:50 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
@ -1265,7 +1265,7 @@ function get_user_data($uid, $extra = '')
}
}
}
$tmp = $e107->arrayStorage->WriteArray($extended_struct);
$tmp = $e107->arrayStorage->WriteArray($extended_struct, false);
$e107->ecache->set_sys('nomd5_extended_struct', $tmp);
unset($tmp);
}

View File

@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum.php,v $
| $Revision: 1.5 $
| $Date: 2008-11-26 04:00:36 $
| $Revision: 1.6 $
| $Date: 2008-12-01 01:10:50 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
@ -305,7 +305,7 @@ function parse_forum($f, $restricted_string = "")
$f['forum_name'] = $tp -> toHTML($f['forum_name'], TRUE, "no_hook");
$f['forum_description'] = $tp -> toHTML($f['forum_description'], TRUE, "no_hook");
$FORUMNAME = "<a href='".e_PLUGIN."forum/forum_viewforum.php?{$f['forum_id']}'>{$f['forum_name']}</a>";
$FORUMNAME = "<a href='".e_PLUGIN."forum/viewforum.php?id={$f['forum_id']}'>{$f['forum_name']}</a>";
$FORUMDESCRIPTION = $f['forum_description'].($restricted_string ? "<br /><span class='smalltext'><i>$restricted_string</i></span>" : "");
$THREADS = $f['forum_threads'];
$REPLIES = $f['forum_replies'];

View File

@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum_class.php,v $
| $Revision: 1.12 $
| $Date: 2008-11-30 22:05:12 $
| $Revision: 1.13 $
| $Date: 2008-12-01 01:10:50 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
@ -56,7 +56,7 @@ class e107forum
else
{
$this->getForumPermList();
$tmp = $e107->arrayStorage->WriteArray($this->permList);
$tmp = $e107->arrayStorage->WriteArray($this->permList, false);
$e107->ecache->set_sys('forum_perms', $tmp);
}
@ -195,8 +195,66 @@ class e107forum
function threadUpdate($threadInfo, $inc)
{
$e107 = e107::getInstance();
//TODO: Add this
}
function threadGet($id, $joinForum = true, $uid = USERID)
{
$e107 = e107::getInstance();
$id = (int)$id;
$uid = (int)$uid;
if($joinForum)
{
//TODO: Fix query to get only forum and parent info needed, with correct naming
$qry = '
SELECT t.*, f.*, tr.track_userid
FROM `#forum_thread` AS t
LEFT JOIN `#forum` AS f ON t.thread_forum_id = f.forum_id
LEFT JOIN `#forum_track` AS tr ON tr.track_thread = t.thread_id AND tr.track_userid = '.$uid.'
WHERE thread_id = '.$id;
}
else
{
$qry = '
SELECT *
FROM `#forum_thread`
WHERE thread_id = '.$id;
}
if($e107->sql->db_Select_gen($qry, true))
{
$tmp = $e107->sql->db_Fetch(MYSQL_ASSOC);
if($tmp)
{
if(trim($tmp['thread_options']) != '')
{
$tmp['thread_options'] = inserialize($tmp['thread_options']);
}
return $tmp;
}
}
return false;
}
function postGet($threadId, $start, $num)
{
$e107 = e107::getInstance();
$qry = '
SELECT p.*, u.user_name, u.user_customtitle, eu.user_name AS edit_name
FROM `#forum_post` AS p
LEFT JOIN `#user` AS u ON p.post_user = u.user_id
LEFT JOIN `#user` AS eu ON p.post_edit_user IS NOT NULL AND p.post_edit_user = eu.user_id
WHERE p.post_thread = '.$threadId."
ORDER BY p.post_datestamp ASC
LIMIT {$start}, {$num}
";
if($e107->sql->db_Select_gen($qry, true))
{
return $e107->sql->db_Fetch(MYSQL_ASSOC);
}
return false;
}
function thread_postnum($thread_id)
{
global $sql;
@ -465,7 +523,7 @@ class e107forum
function track($which, $uid, $threadId)
{
global $e107;
$e107 = e107::getInstance();
$threadId = (int)$threadId;
$uid = (int)$uid;
$result = false;
@ -481,8 +539,12 @@ class e107forum
case 'delete':
case 'del':
$result = $e107->sql->db_Delete('forum_track', 'WHERE `track_userid` = {$uid} AND `track_thread');
$result = $e107->sql->db_Delete('forum_track', "`track_userid` = {$uid} AND `track_thread` = {$threadId}");
break;
case 'check':
$result = $e107->sql->db_Count('forum_track', '(*)', "WHERE `track_userid` = {$uid} AND `track_thread` = {$threadId}");
break;
}
return $result;
}
@ -789,11 +851,11 @@ class e107forum
return $ret;
}
function thread_incview($thread_id)
function threadIncView($id)
{
$thread_id = intval($thread_id);
global $sql;
return $sql->db_Update("forum_t", "thread_views=thread_views+1 WHERE thread_id=".$thread_id);
$e107 = e107::getInstance();
$id = (int)($id);
return $e107->sql->db_Update('forum_thread', 'thread_views=thread_views+1 WHERE thread_id='.$id);
}

View File

@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum_post.php,v $
| $Revision: 1.19 $
| $Date: 2008-11-29 01:24:27 $
| $Revision: 1.20 $
| $Date: 2008-12-01 01:10:50 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
@ -242,7 +242,6 @@ if (isset($_POST['newthread']) || isset($_POST['reply']))
$postInfo['post_datestamp'] = $time;
$threadInfo['thread_lastpost'] = $time;
switch($action)
{
// Reply only. Add the post, update thread record with latest post info.

View File

@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum_viewtopic.php,v $
| $Revision: 1.2 $
| $Date: 2008-11-29 01:24:27 $
| $Revision: 1.3 $
| $Date: 2008-12-01 01:10:50 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
@ -22,7 +22,6 @@ require_once('../../class2.php');
include_lan(e_PLUGIN.'forum/languages/English/lan_forum_viewtopic.php');
include_once(e_PLUGIN.'forum/forum_class.php');
if (file_exists(THEME.'forum_design.php'))
{
include_once(THEME.'forum_design.php');
@ -31,7 +30,7 @@ if (file_exists(THEME.'forum_design.php'))
$forum = new e107forum;
if (isset($_POST['fjsubmit']))
{
header("location:".e_PLUGIN."forum/forum_viewforum.php?".$_POST['forumjump']);
header('location:'.$e107->url->getUrl('forum', 'forum', array('func' => 'view', 'id'=>$_POST['forumjump'])));
exit;
}
$highlight_search = isset($_POST['highlight_search']);
@ -39,22 +38,39 @@ $highlight_search = isset($_POST['highlight_search']);
if (!e_QUERY)
{
//No paramters given, redirect to forum home
header("Location:".e_PLUGIN."forum/forum.php");
header('Location:'.$e107->url->getUrl('forum', 'forum', array('func' => 'main')));
exit;
}
else
$threadId = (int)varset($_GET['id']);
$perPage = (varset($_REQUEST['perpage']) ? (int)$_REQUEST['perpage'] : $pref['forum_postspage']);
$start = (varset($_REQUEST['start']) ? (int)$_REQUEST['start'] : 0);
// $tmp = explode(".", e_QUERY);
// $thread_id = varset($tmp[0]);
// $topic_from = varset($tmp[1], 0);
// $action = varset($tmp[2]);
//$threadInfo = $forum->threadGet($threadId);
//print_a($threadInfo);
//exit;
if (!$threadId || !$threadInfo = $forum->threadGet($threadId))
{
$tmp = explode(".", e_QUERY);
$thread_id = varset($tmp[0]);
$topic_from = varset($tmp[1], 0);
$action = varset($tmp[2]);
if (!$thread_id || !is_numeric($thread_id))
{
header("Location:".e_PLUGIN."forum/forum.php");
exit;
}
header('Location:'.$e107->url->getUrl('forum', 'forum', array('func' => 'main')));
exit;
}
if(!in_array($threadInfo['thread_forum_id'], $forum->permList['view']))
{
header('Location:'.$e107->url->getUrl('forum', 'forum', array('func' => 'main')));
exit;
}
print_a($threadInfo);
print_a($forum->permList);
//die('here');
if($topic_from === 'post')
{
if($thread_id)
@ -70,28 +86,28 @@ if($topic_from === 'post')
}
else
{
header("Location:".e_PLUGIN."forum/forum.php");
header('Location:'.$e107->url->getUrl('forum', 'forum', array('func' => 'main')));
exit;
}
}
require_once(e_PLUGIN.'forum/forum_shortcodes.php');
if ($action == "track" && USER)
if ($action == 'track' && USER)
{
$forum->track($thread_id);
header("location:".e_SELF."?{$thread_id}.{$topic_from}");
exit;
}
if ($action == "untrack" && USER)
if ($action == 'untrack' && USER)
{
$forum->untrack($thread_id);
header("location:".e_SELF."?{$thread_id}.{$topic_from}");
exit;
}
if ($action == "next")
if ($action == 'next')
{
$next = $forum->thread_getnext($thread_id, $topic_from);
if ($next)
@ -108,26 +124,32 @@ if ($action == "next")
}
}
if ($action == "prev") {
if ($action == 'prev')
{
$prev = $forum->thread_getprev($thread_id, $topic_from);
if ($prev) {
if ($prev)
{
header("location:".e_SELF."?{$prev}");
exit;
} else {
}
else
{
require_once(HEADERF);
$ns->tablerender('', LAN_404, array('forum_viewtopic', '404'));
require_once(FOOTERF);
exit;
}
}
if ($action == "report") {
if ($action == 'report')
{
$thread_info = $forum->thread_get_postinfo($thread_id, TRUE);
if (isset($_POST['report_thread'])) {
if (isset($_POST['report_thread']))
{
$report_add = $tp -> toDB($_POST['report_add']);
if ($pref['reported_post_email']) {
if ($pref['reported_post_email'])
{
require_once(e_HANDLER."mail.php");
$report = LAN_422.SITENAME." : ".(substr(SITEURL, -1) == "/" ? SITEURL : SITEURL."/").$PLUGINS_DIRECTORY."forum/forum_viewtopic.php?".$thread_id.".post\n".LAN_425.USERNAME."\n".$report_add;
$subject = LAN_421." ".SITENAME;
@ -138,7 +160,9 @@ if ($action == "report") {
require_once(HEADERF);
$text = LAN_424."<br /><br /><a href='forum_viewtopic.php?".$thread_id.".post'>".LAN_429."</a";
$ns->tablerender(LAN_414, $text, array('forum_viewtopic', 'report'));
} else {
}
else
{
$thread_name = $tp -> toHTML($thread_info['head']['thread_name'], TRUE, 'no_hook, emotes_off');
define("e_PAGETITLE", LAN_01." / ".LAN_426." ".$thread_name);
require_once(HEADERF);
@ -169,38 +193,40 @@ if ($action == "report") {
require_once(FOOTERF);
exit;
}
$pm_installed = ($pref['pm_title'] ? TRUE : FALSE);
$pm_installed = plugInstalled('pm');
$replies = $forum->thread_count($thread_id)-1;
if ($topic_from === 'last') {
//$replies = $forum->thread_count($thread_id)-1;
if ($topic_from === 'last')
{
$pref['forum_postspage'] = ($pref['forum_postspage'] ? $pref['forum_postspage'] : 10);
$pages = ceil(($replies+1)/$pref['forum_postspage']);
$pages = ceil(($threadInfo['thread_total_replies']+1)/$pref['forum_postspage']);
$topic_from = ($pages-1) * $pref['forum_postspage'];
}
$gen = new convert;
$thread_info = $forum->thread_get($thread_id, $topic_from-1, $pref['forum_postspage']);
//$thread_info = $forum->thread_get($thread_id, $topic_from-1, $pref['forum_postspage']);
$postList = $forum->PostGet($threadId, $start, $perPage);
print_a($postList);
//if(intval($thread_info['head']['thread_forum_id']) == 0)
//{
// require_once(HEADERF);
// $ns->tablerender(LAN_01, FORLAN_104, array('forum_viewtopic', '104'));
// require_once(FOOTERF);
// exit;
//}
if(intval($thread_info['head']['thread_forum_id']) == 0)
{
require_once(HEADERF);
$ns->tablerender(LAN_01, FORLAN_104, array('forum_viewtopic', '104'));
require_once(FOOTERF);
exit;
}
$forum_info = $forum->forum_get($thread_info['head']['thread_forum_id']);
//$forum_info = $forum->forum_get($thread_info['head']['thread_forum_id']);
//
//if (!check_class($forum_info['forum_class']) || !check_class($forum_info['parent_class'])) {
// header("Location:".e_PLUGIN."forum/forum.php");
// exit;
//}
if (!check_class($forum_info['forum_class']) || !check_class($forum_info['parent_class'])) {
header("Location:".e_PLUGIN."forum/forum.php");
exit;
}
$forum->thread_incview($thread_id);
define("e_PAGETITLE", LAN_01." / ".$tp->toHTML($forum_info['forum_name'], TRUE, 'no_hook, emotes_off')." / ".$tp->toHTML($thread_info['head']['thread_name'], TRUE, 'no_hook, emotes_off'));
define('e_PAGETITLE', LAN_01.' / '.$e107->tp->toHTML($forum_info['forum_name'], true, 'no_hook, emotes_off')." / ".$tp->toHTML($thread_info['head']['thread_name'], TRUE, 'no_hook, emotes_off'));
//define("MODERATOR", (preg_match("/".preg_quote(ADMINNAME)."/", $forum_info['forum_moderators']) && getperms('A') ? TRUE : FALSE));
define("MODERATOR", $forum_info['forum_moderators'] != "" && check_class($forum_info['forum_moderators']));
$modArray = $forum->forum_getmods($forum_info['forum_moderators']);
define('MODERATOR', ($forum_info['forum_moderators'] != '' && check_class($forum_info['forum_moderators'])));
//$modArray = $forum->forum_getmods($forum_info['forum_moderators']);
$message = '';
if (MODERATOR)
@ -212,54 +238,63 @@ if (MODERATOR)
$thread_info = $forum->thread_get($thread_id, $topic_from-1, $pref['forum_postspage']);
}
}
$forum->threadIncview($threadId);
require_once(HEADERF);
require_once(e_HANDLER."level_handler.php");
require_once(e_HANDLER.'level_handler.php');
if ($message)
{
$ns->tablerender("", $message, array('forum_viewtopic', 'msg'));
$ns->tablerender('', $message, array('forum_viewtopic', 'msg'));
}
if (stristr($thread_info['head']['thread_name'], "[".LAN_430."]"))
if(isset($threadInfo['thread_options']['poll']))
//if (stristr($thread_info['head']['thread_name'], "[".LAN_430."]"))
{
if(!defined("POLLCLASS"))
if(!defined('POLLCLASS'))
{
require(e_PLUGIN."poll/poll_class.php");
include(e_PLUGIN.'poll/poll_class.php');
}
$_qry = "SELECT * FROM #polls WHERE `poll_datestamp` = '{$thread_info['head']['thread_id']}'";
$_qry = 'SELECT * FROM `#polls` WHERE `poll_datestamp` = '.$threadId;
$poll = new poll;
$pollstr = "<div class='spacer'>".$poll->render_poll($_qry, "forum", "query", TRUE)."</div>";
$pollstr = "<div class='spacer'>".$poll->render_poll($_qry, 'forum', 'query', true).'</div>';
}
//Load forum templates
if (!$FORUMSTART) {
if (file_exists(THEME."forum_viewtopic_template.php"))
if (file_exists(THEME.'forum_viewtopic_template.php'))
{
require_once(THEME."forum_viewtopic_template.php");
require_once(THEME.'forum_viewtopic_template.php');
}
else if (file_exists(THEME."forum_template.php"))
elseif (file_exists(THEME.'forum_template.php'))
{
require_once(THEME."forum_template.php");
require_once(THEME.'forum_template.php');
}
else
{
require_once(e_PLUGIN."forum/templates/forum_viewtopic_template.php");
require_once(e_PLUGIN.'forum/templates/forum_viewtopic_template.php');
}
}
$forum_info['forum_name'] = $tp -> toHTML($forum_info['forum_name'], TRUE,'no_hook,emotes_off');
$forum_info['forum_name'] = $e107->tp->toHTML($forum_info['forum_name'], true, 'no_hook,emotes_off');
// get info for main thread -------------------------------------------------------------------------------------------------------------------------------------------------------------------
$forum->set_crumb(TRUE); // Set $BREADCRUMB (and BACKLINK)
$THREADNAME = $tp->toHTML($thread_info['head']['thread_name'], TRUE, 'no_hook, emotes_off');
$THREADNAME = $e107->tp->toHTML($threadInfo['thread_name'], true, 'no_hook, emotes_off');
$NEXTPREV = "&lt;&lt; <a href='".e_SELF."?{$thread_id}.{$forum_info['forum_id']}.prev'>".LAN_389."</a>";
$NEXTPREV .= " | ";
$NEXTPREV .= "<a href='".e_SELF."?{$thread_id}.{$forum_info['forum_id']}.next'>".LAN_390."</a> &gt;&gt;";
if ($pref['forum_track'] && USER)
{
$TRACK = (strpos(USERREALM, "-".$thread_id."-") !== FALSE ? "<span class='smalltext'><a href='".e_SELF."?".$thread_id.".0."."untrack'>".LAN_392."</a></span>" : "<span class='smalltext'><a href='".e_SELF."?".$thread_id.".0."."track'>".LAN_391."</a></span>");
if($forum->track('check', USERID, $threadId))
{
$TRACK = "<span class='smalltext'><a href='".e_SELF."?".$thread_id.".0."."untrack'>".LAN_392."</a></span>";
}
else
{
$TRACK = "<span class='smalltext'><a href='".e_SELF."?".$thread_id.".0."."track'>".LAN_391."</a></span>";
}
}
$MODERATORS = LAN_321.implode(", ", $modArray);

View File

@ -1,5 +1,5 @@
<?php
// $Id: thread.php,v 1.2 2008-11-26 19:59:06 mcfly_e107 Exp $
// $Id: thread.php,v 1.3 2008-12-01 01:10:50 mcfly_e107 Exp $
function url_forum_thread($parms)
{
switch($parms['func'])
@ -13,5 +13,9 @@ function url_forum_thread($parms)
return e_PLUGIN_ABS."forum/forum_post.php?f=nt&id={$parms['id']}";
break;
case 'view':
return e_PLUGIN_ABS."forum/forum_viewtopic.php?id={$parms['id']}";
break;
}
}

View File

@ -9,25 +9,24 @@
* View specific forums
*
* $Source: /cvs_backup/e107_0.8/e107_plugins/forum/viewforum.php,v $
* $Revision: 1.3 $
* $Date: 2008-11-27 03:02:26 $
* $Revision: 1.4 $
* $Date: 2008-12-01 01:10:50 $
* $Author: mcfly_e107 $
*
*/
require_once('../../class2.php');
$lan_file = e_PLUGIN.'forum/languages/'.e_LANGUAGE.'/lan_forum_viewforum.php';
include_once(file_exists($lan_file) ? $lan_file : e_PLUGIN.'forum/languages/English/lan_forum_viewforum.php');
include_lan(e_PLUGIN.'forum/languages/English/lan_forum_viewforum.php');
if (isset($_POST['fjsubmit']))
{
header("location:".e_SELF.'?'.$_POST['forumjump']);
header('location:'.$e107->url->getUrl('forum', 'forum', array('func' => 'view', 'id'=>$_POST['forumjump'])));
exit;
}
if (!e_QUERY)
{
js_location(e_PLUGIN.'forum/forum.php');
header('Location:'.$e107->url->getUrl('forum', 'forum', array('func' => 'main')));
exit;
}
@ -74,7 +73,7 @@ if (!$FORUM_VIEW_START) {
{
require_once(THEME.'forum_viewforum_template.php');
}
else if (file_exists(THEME.'forum_template.php'))
elseif (file_exists(THEME.'forum_template.php'))
{
require_once(THEME.'forum_template.php');
}
@ -392,7 +391,7 @@ function parse_thread($thread_info)
} else {
$title = "";
}
$THREADNAME = "<a {$title} href='".e_PLUGIN."forum/forum_viewtopic.php?{$thread_info['thread_id']}'>{$thread_name}</a>";
$THREADNAME = "<a {$title} href='".e_PLUGIN."forum/forum_viewtopic.php?id={$thread_info['thread_id']}'>{$thread_name}</a>";
$pages = ceil(($REPLIES+1)/$pref['forum_postspage']);
if ($pages > 1)