1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-31 20:00:37 +02:00

Forum changes...trying to make it much more OO, will probably be lots of breakage.

This commit is contained in:
mcfly
2009-09-06 04:30:46 +00:00
parent 01c5c94475
commit 4177c1607b
9 changed files with 1814 additions and 389 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,72 @@
<?php
/*
* e107 website system
*
* Copyright (C) 2001-2008 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* forumThread class file
*
* $Source: /cvs_backup/e107_0.8/e107_plugins/forum/classes/forumPost.php,v $
* $Revision: 1.1 $
* $Date: 2009-09-06 04:30:46 $
* $Author: mcfly_e107 $
*
*/
class plugin_forum_classes_forumPost
{
public $post;
public function __construct($id=false, $start=0, $num=0)
{
if($id) {
$this->loadPost($id, $start, $num);
}
}
function loadPost($id, $start, $num)
{
$e107 = e107::getInstance();
$id = (int)$id;
$ret = false;
if('post' === $start)
{
$qry = '
SELECT u.user_name, t.thread_active, t.thread_datestamp, t.thread_name, p.* FROM `#forum_post` AS p
LEFT JOIN `#forum_thread` AS t ON t.thread_id = p.post_thread
LEFT JOIN `#user` AS u ON u.user_id = p.post_user
WHERE p.post_id = '.$id;
}
else
{
$qry = "
SELECT p.*,
u.user_name, u.user_customtitle, u.user_hideemail, u.user_email, u.user_signature,
u.user_admin, u.user_image, u.user_join, ue.user_plugin_forum_posts,
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
LEFT JOIN `#user_extended` AS ue ON ue.user_extended_id = p.post_user
WHERE p.post_thread = {$id}
ORDER BY p.post_datestamp ASC
LIMIT {$start}, {$num}
";
}
if($e107->sql->db_Select_gen($qry))
{
$this->post = array();
while($row = $e107->sql->db_Fetch())
{
$this->post[] = $row;
}
if('post' === $start) { $this->post = $this->post[0]; }
return true;
}
return false;
}
}

View File

@@ -0,0 +1,306 @@
<?php
/*
* e107 website system
*
* Copyright (C) 2001-2008 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* forumThread class file
*
* $Source: /cvs_backup/e107_0.8/e107_plugins/forum/classes/forumThread.php,v $
* $Revision: 1.1 $
* $Date: 2009-09-06 04:30:46 $
* $Author: mcfly_e107 $
*
*/
class plugin_forum_classes_forumThread {
var $message, $threadId, $forumId, $perPage, $noInc, $pages;
public $e107, $forum, $postList;
public function __construct($threadId=false, &$forum)
{
$this->e107 = e107::getInstance();
$this->forum = $forum;
$this->threadId = $threadId;
if('post' == varset($_GET['f'])) {
$this->processFunction();
}
$this->init();
if(isset($_POST['track_toggle']))
{
$this->toggle_track();
exit;
}
if($threadId) {
$this->loadPosts();
}
// var_dump($this->forum);
}
function init()
{
// global $pref, $forum;
global $pref;
$this->perPage = (varset($_GET['perpage']) ? (int)$_GET['perpage'] : $pref['forum_postspage']);
$this->page = (varset($_GET['p']) ? (int)$_GET['p'] : 0);
if('last' == varset($_GET['f']))
{
$this->processFunction();
}
//If threadId doesn't exist, or not given, redirect to main forum page
if (!$this->threadId || !$this->threadInfo = $this->loadThread($this->threadId))
{
header('Location:' . $this->e107->url->getUrl('forum', 'forum', array('func' => 'main')));
exit;
}
//If not permitted to view forum, redirect to main forum page
if (!$this->forum->checkPerm($this->threadInfo['thread_forum_id'], 'view'))
{
header('Location:' . $this->e107->url->getUrl('forum', 'forum', array('func' => 'main')));
exit;
}
$this->pages = (int)ceil(($this->threadInfo['thread_total_replies'] + 1) / $this->perPage);
$this->noInc = false;
}
public function loadPosts()
{
$this->postList = new plugin_forum_classes_forumPost($this->threadId, $this->page * $this->perPage, $this->perPage);
}
function toggle_track()
{
if (!USER || !isset($_GET['id'])) { return; }
if($this->threadInfo['track_userid'])
{
$this->forum->track('del', USERID, $_GET['id']);
$img = IMAGE_untrack;
}
else
{
$this->forum->track('add', USERID, $_GET['id']);
$img = IMAGE_track;
}
if(e_AJAX_REQUEST)
{
$url = $this->e107->url->getUrl('forum', 'thread', array('func' => 'view', 'id' => $this->threadId));
echo "<a href='{$url}' id='forum-track-trigger'>{$img}</a>";
exit();
}
}
function processFunction()
{
global $pref;
if (!isset($_GET['f'])) { return; }
$function = trim($_GET['f']);
switch ($function)
{
case 'post':
$postId = varset($_GET['id']);
$postInfo = $forum->postGet($postId,'post');
$postNum = $forum->postGetPostNum($postInfo['post_thread'], $postId);
$postPage = ceil($postNum / $pref['forum_postspage'])-1;
$url = $this->e107->url->getUrl('forum', 'thread', "func=view&id={$postInfo['post_thread']}&page=$postPage");
header('location: '.$url);
exit;
break;
case 'last':
$pages = ceil(($thread->threadInfo['thread_total_replies'] + 1) / $thread->perPage);
$thread->page = ($pages - 1);
break;
case 'next':
$next = $forum->threadGetNextPrev('next', $this->threadId, $this->threadInfo['forum_id'], $this->threadInfo['thread_lastpost']);
if ($next)
{
$url = $e107->url->getUrl('forum', 'thread', array('func' => 'view', 'id' => $next));
header("location: {$url}");
exit;
}
$this->message = LAN_405;
break;
case 'prev':
$prev = $forum->threadGetNextPrev('prev', $this->threadId, $this->threadInfo['forum_id'], $this->threadInfo['thread_lastpost']);
if ($prev)
{
$url = $e107->url->getUrl('forum', 'thread', array('func' => 'view', 'id' => $prev));
header("location: {$url}");
exit;
}
$this->message = LAN_404;
break;
case 'report':
$postId = (int)$_GET['id'];
$postInfo = $forum->postGet($postId, 'post');
if (isset($_POST['report_thread']))
{
$report_add = $e107->tp->toDB($_POST['report_add']);
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;
sendemail(SITEADMINEMAIL, $subject, $report);
}
$e107->sql->db_Insert('generic', "0, 'reported_post', " . time() . ", '" . USERID . "', '{$thread_info['head']['thread_name']}', " . intval($thread_id) . ", '{$report_add}'");
define('e_PAGETITLE', LAN_01 . " / " . LAN_428);
require_once (HEADERF);
$text = LAN_424 . "<br /><br /><a href='forum_viewtopic.php?" . $thread_id . ".post'>" . LAN_429 . '</a>';
$e107->ns->tablerender(LAN_414, $text, array('forum_viewtopic', 'report'));
}
else
{
$thread_name = $e107->tp->toHTML($postInfo['thread_name'], true, 'no_hook, emotes_off');
define('e_PAGETITLE', LAN_01 . ' / ' . LAN_426 . ' ' . $thread_name);
require_once (HEADERF);
$url = $e107->url->getUrl('forum', 'thread', 'func=post&id='.$postId);
$actionUrl = $e107->url->getUrl('forum', 'thread', 'func=report&id='.$postId);
$text = "<form action='".$actionUrl."' method='post'>
<table style='width:100%'>
<tr>
<td style='width:50%' >
" . LAN_415 . ': ' . $thread_name . " <a href='".$url."'><span class='smalltext'>" . LAN_420 . " </span>
</a>
</td>
<td style='text-align:center;width:50%'>
</td>
</tr>
<tr>
<td>" . LAN_417 . "<br />" . LAN_418 . "
</td>
<td style='text-align:center;'>
<textarea cols='40' rows='10' class='tbox' name='report_add'></textarea>
</td>
</tr>
<tr>
<td colspan='2' style='text-align:center;'><br />
<input class='button' type='submit' name='report_thread' value='" . LAN_419 . "' />
</td>
</tr>
</table>";
$e107->ns->tablerender(LAN_414, $text, array('forum_viewtopic', 'report2'));
}
require_once (FOOTERF);
exit;
break;
}
}
function loadThread($id, $joinForum = true, $uid = USERID)
{
$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.*,
fp.forum_id as parent_id, fp.forum_name as parent_name,
sp.forum_id as forum_sub, sp.forum_name as sub_parent,
tr.track_userid
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
LEFT JOIN `#forum` AS sp ON sp.forum_id = f.forum_sub
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($this->e107->sql->db_Select_gen($qry))
{
$tmp = $this->e107->sql->db_Fetch();
if($tmp)
{
if(trim($tmp['thread_options']) != '')
{
$tmp['thread_options'] = unserialize($tmp['thread_options']);
}
return $tmp;
}
}
return false;
}
public function render()
{
global $FORUMREPLYSTYLE, $FORUMREPLYSTYLE_ALT, $FORUMTHREADSTYLE, $FORUMDELETEDSTYLE, $FORUMDELETEDSTYLE_ALT;
global $forum_shortcodes;
$ret = "";
if(!$FORUMREPLYSTYLE) $FORUMREPLYSTYLE = $FORUMTHREADSTYLE;
$alt = false;
$i = $this->page;
//var_dump($forum->thread->postList);
foreach ($this->postList->post as $postInfo)
{
if($postInfo['post_options'])
{
$postInfo['post_options'] = unserialize($postInfo['post_options']);
}
$loop_uid = (int)$postInfo['post_user'];
$i++;
//TODO: Look into fixing this, to limit to a single query per pageload
$e_hide_query = "SELECT post_id FROM `#forum_post` WHERE (`post_thread` = {$threadId} AND post_user= " . USERID . ' LIMIT 1';
$e_hide_hidden = FORLAN_HIDDEN;
$e_hide_allowed = USER;
if ($i > 1)
{
$postInfo['thread_start'] = false;
$alt = !$alt;
if($postInfo['post_status'])
{
$_style = (isset($FORUMDELETEDSTYLE_ALT) && $alt ? $FORUMDELETEDSTYLE_ALT : $FORUMDELETEDSTYLE);
}
else
{
$_style = (isset($FORUMREPLYSTYLE_ALT) && $alt ? $FORUMREPLYSTYLE_ALT : $FORUMREPLYSTYLE);
}
setScVar('forum_shortcodes', 'postInfo', $postInfo);
$ret .= $this->e107->tp->parseTemplate($_style, true, $forum_shortcodes) . "\n";
}
else
{
$postInfo['thread_start'] = true;
setScVar('forum_shortcodes', 'postInfo', $postInfo);
$ret .= $this->e107->tp->parseTemplate($FORUMTHREADSTYLE, true, $forum_shortcodes) . "\n";
}
}
unset($loop_uid);
return $ret;
}
public function IncrementViews($id=0)
{
$e107 = e107::getInstance();
$id = ($id ? (int)$id : $this->threadId);
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.php,v $
| $Revision: 1.13 $
| $Date: 2008-12-18 14:08:33 $
| $Revision: 1.14 $
| $Date: 2009-09-06 04:30:46 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
@@ -23,8 +23,7 @@ if(!defined('e107_INIT'))
include_lan(e_PLUGIN.'forum/languages/'.e_LANGUAGE.'/lan_forum.php');
require_once(e_PLUGIN.'forum/forum_class.php');
$forum = new e107forum;
$forum = new plugin_forum_forumClass;
if ($untrackId = varset($_REQUEST['untrack']))
{
@@ -47,7 +46,7 @@ if(isset($_GET['f']))
header('location:'.e_SELF);
exit;
break;
case 'rules':
include_once(HEADERF);
forum_rules('show');
@@ -333,7 +332,7 @@ function parse_forum($f, $restricted_string = '')
list($lastpost_datestamp, $lastpost_thread) = explode('.', $f['forum_lastpost_info']);
if ($f['user_name'])
{
$lastpost_name = "<a href='".$e107->url->getUrl('core:user','main','func=profile&id='.$f['forum_lastpost_user'])."'>{$f['user_name']}</a>";
}
else

View File

@@ -9,24 +9,27 @@
* Message Handler
*
* $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum_class.php,v $
* $Revision: 1.38 $
* $Date: 2009-01-25 17:44:13 $
* $Revision: 1.39 $
* $Date: 2009-09-06 04:30:46 $
* $Author: mcfly_e107 $
*
*/
if (!defined('e107_INIT')) { exit; }
class e107forum
class plugin_forum_forumClass
{
var $permList = array();
var $fieldTypes = array();
var $userViewed = array();
var $modArray = array();
var $e107;
private $threadList = array();
private $postList = array();
function e107forum()
function __construct()
{
$this->e107 = e107::getInstance();
$this->loadPermList();
$this->fieldTypes['forum_post']['post_user'] = 'int';
$this->fieldTypes['forum_post']['post_forum'] = 'int';
@@ -49,21 +52,20 @@ class e107forum
$this->fieldTypes['forum_thread']['thread_options'] = 'escape';
$this->fieldTypes['forum']['forum_lastpost_user'] = 'int';
$this->e107 = e107::getInstance();
}
function loadPermList()
{
global $e107;
if($tmp = $e107->ecache->retrieve_sys('forum_perms'))
// var_dump($this->e107);
if($tmp = $this->e107->ecache->retrieve_sys('forum_perms'))
{
$this->permList = $e107->arrayStorage->ReadArray($tmp);
}
else
{
$this->getForumPermList();
$tmp = $e107->arrayStorage->WriteArray($this->permList, false);
$e107->ecache->set_sys('forum_perms', $tmp);
$tmp = $this->e107->arrayStorage->WriteArray($this->permList, false);
$this->e107->ecache->set_sys('forum_perms', $tmp);
}
unset($tmp);
@@ -72,26 +74,24 @@ class e107forum
function getForumPermList()
{
global $e107;
$this->permList = array();
$qryList = array();
$qryList[view] = "
$qryList['view'] = "
SELECT f.forum_id
FROM `#forum` AS f
LEFT JOIN `#forum` AS fp ON f.forum_parent = fp.forum_id AND fp.forum_class IN (".USERCLASS_LIST.")
WHERE f.forum_class IN (".USERCLASS_LIST.") AND f.forum_parent != 0 AND fp.forum_id IS NOT NULL
";
$qryList[post] = "
$qryList['post'] = "
SELECT f.forum_id
FROM `#forum` AS f
LEFT JOIN `#forum` AS fp ON f.forum_parent = fp.forum_id AND fp.forum_postclass IN (".USERCLASS_LIST.")
WHERE f.forum_postclass IN (".USERCLASS_LIST.") AND f.forum_parent != 0 AND fp.forum_id IS NOT NULL
";
$qryList[thread] = "
$qryList['thread'] = "
SELECT f.forum_id
FROM `#forum` AS f
LEFT JOIN `#forum` AS fp ON f.forum_parent = fp.forum_id AND fp.forum_threadclass IN (".USERCLASS_LIST.")
@@ -100,9 +100,9 @@ class e107forum
foreach($qryList as $key => $qry)
{
if($e107->sql->db_Select_gen($qry))
if($this->e107->sql->db_Select_gen($qry))
{
while($row = $e107->sql->db_Fetch(MYSQL_ASSOC))
while($row = $this->e107->sql->db_Fetch())
{
$this->permList[$key][] = $row['forum_id'];
}
@@ -110,19 +110,36 @@ class e107forum
}
}
/**
* Test for forum permissions.
*
* 'view' - user is able to view forumId
* 'post' - user is able to create new post in forumId
* 'thread' - user is able to create new thread in forumId
*
* @param integer $forumId
* @param string $type (view, post, thread)
* @return boolean
*/
function checkPerm($forumId, $type='view')
{
return (in_array($forumId, $this->permList[$type]));
}
/**
* Check to see of thread has been viewed by current user
*
*
* @param integer $threadId
* @return boolean
*/
function threadViewed($threadId)
{
$e107 = e107::getInstance();
if(!$this->userViewed)
{
if(isset($e107->currentUser['user_plugin_forum_viewed']))
if(isset($this->e107->currentUser['user_plugin_forum_viewed']))
{
$this->userViewed = explode(',', $e107->currentUser['user_plugin_forum_viewed']);
$this->userViewed = explode(',', $this->e107->currentUser['user_plugin_forum_viewed']);
}
}
return (is_array($this->userViewed) && in_array($threadId, $this->userViewed));
@@ -130,11 +147,10 @@ class e107forum
function getTrackedThreadList($id, $retType = 'array')
{
$e107 = e107::getInstance();
$id = (int)$id;
if($e107->sql->db_Select('forum_track', 'track_thread', 'track_userid = '.$id))
if($this->e107->sql->db_Select('forum_track', 'track_thread', 'track_userid = '.$id))
{
while($row = $e107->sql->db_Fetch(MYSQL_ASSOC))
while($row = $this->e107->sql->db_Fetch())
{
$ret[] = $row['track_thread'];
}
@@ -151,16 +167,14 @@ class e107forum
*/
function postAdd($postInfo, $updateThread = true, $updateForum = true)
{
// var_dump($postInfo);
//Future option, will just set to true here
$addUserPostCount = true;
$result = false;
$e107 = e107::getInstance();
$info = array();
$info['_FIELD_TYPES'] = $this->fieldTypes['forum_post'];
$info['data'] = $postInfo;
$postId = $e107->sql->db_Insert('forum_post', $info);
$postId = $this->e107->sql->db_Insert('forum_post', $info);
$forumInfo = array();
if($postId && $updateThread)
@@ -189,7 +203,7 @@ class e107forum
$info['_FIELD_TYPES'] = $this->fieldTypes['forum_thread'];
$info['_FIELD_TYPES']['thread_total_replies'] = 'cmd';
$result = $e107->sql->db_Update('forum_thread', $info);
$result = $this->e107->sql->db_Update('forum_thread', $info);
}
@@ -222,7 +236,7 @@ class e107forum
$info['data'] = $forumInfo;
$info['data']['forum_lastpost_info'] = $postInfo['post_datestamp'].'.'.$postInfo['post_thread'];
$info['WHERE'] = 'forum_id = '.$postInfo['post_forum'];
$result = $e107->sql->db_Update('forum', $info);
$result = $this->e107->sql->db_Update('forum', $info);
}
if($result && USER && $addUserPostCount)
@@ -232,18 +246,17 @@ class e107forum
VALUES ('.USERID.', 1)
ON DUPLICATE KEY UPDATE user_plugin_forum_posts = user_plugin_forum_posts + 1
';
$result = $e107->sql->db_Select_gen($qry);
$result = $this->e107->sql->db_Select_gen($qry);
}
return $postId;
}
function threadAdd($threadInfo, $postInfo)
{
$e107 = e107::getInstance();
$info = array();
$info['_FIELD_TYPES'] = $this->fieldTypes['forum_thread'];
$info['data'] = $threadInfo;
if($newThreadId = $e107->sql->db_Insert('forum_thread', $info))
if($newThreadId = $this->e107->sql->db_Insert('forum_thread', $info))
{
$postInfo['post_thread'] = $newThreadId;
$newPostId = $this->postAdd($postInfo, false);
@@ -255,34 +268,30 @@ class e107forum
function threadUpdate($threadId, $threadInfo)
{
$e107 = e107::getInstance();
$info = array();
$info['data'] = $threadInfo;
$info['_FIELD_TYPES'] = $this->fieldTypes['forum_thread'];
$info['WHERE'] = 'thread_id = '.(int)$threadId;
$e107->sql->db_Update('forum_thread', $info);
$this->e107->sql->db_Update('forum_thread', $info);
}
function postUpdate($postId, $postInfo)
{
$e107 = e107::getInstance();
$info = array();
$info['data'] = $postInfo;
$info['_FIELD_TYPES'] = $this->fieldTypes['forum_post'];
$info['WHERE'] = 'post_id = '.(int)$postId;
$e107->sql->db_Update('forum_post', $info);
$this->e107->sql->db_Update('forum_post', $info);
}
function threadGet($id, $joinForum = true, $uid = USERID)
{
global $pref;
$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
// TODO: Fix query to get only forum and parent info needed, with correct naming
$qry = '
SELECT t.*, f.*,
fp.forum_id as parent_id, fp.forum_name as parent_name,
@@ -302,9 +311,9 @@ class e107forum
FROM `#forum_thread`
WHERE thread_id = '.$id;
}
if($e107->sql->db_Select_gen($qry))
if($this->e107->sql->db_Select_gen($qry))
{
$tmp = $e107->sql->db_Fetch(MYSQL_ASSOC);
$tmp = $this->e107->sql->db_Fetch();
if($tmp)
{
if(trim($tmp['thread_options']) != '')
@@ -321,7 +330,6 @@ class e107forum
{
$id = (int)$id;
$ret = false;
$e107 = e107::getInstance();
if('post' === $start)
{
$qry = '
@@ -346,10 +354,10 @@ class e107forum
LIMIT {$start}, {$num}
";
}
if($e107->sql->db_Select_gen($qry))
if($this->e107->sql->db_Select_gen($qry))
{
$ret = array();
while($row = $e107->sql->db_Fetch(MYSQL_ASSOC))
while($row = $this->e107->sql->db_Fetch())
{
$ret[] = $row;
}
@@ -362,17 +370,16 @@ class e107forum
function threadGetUserPostcount($threadId)
{
$threadId = (int)$threadId;
$e107 = e107::getInstance();
$ret = false;
$qry = "
SELECT post_user, count(post_user) AS post_count FROM `#forum_post`
WHERE post_thread = {$threadId} AND post_user IS NOT NULL
GROUP BY post_user
";
if($e107->sql->db_Select_gen($qry))
if($this->e107->sql->db_Select_gen($qry))
{
$ret = array();
while($row = $e107->sql->db_Fetch(MYSQL_ASSOC))
while($row = $this->e107->sql->db_Fetch())
{
$ret[$row['post_user']] = $row['post_count'];
}
@@ -382,10 +389,9 @@ class e107forum
function threadGetUserViewed($uid = USERID)
{
$e107 = e107::getInstance();
if($uid == USERID)
{
$viewed = $e107->currentUser['user_plugin_forum_viewed'];
$viewed = $this->e107->currentUser['user_plugin_forum_viewed'];
}
else
{
@@ -505,7 +511,7 @@ class e107forum
{
if ($sql->db_Select('forum', 'forum_id', 'forum_parent != 0'))
{
while ($row = $sql->db_Fetch(MYSQL_ASSOC))
while ($row = $sql->db_Fetch())
{
$parentList[] = $row['forum_id'];
}
@@ -635,7 +641,7 @@ class e107forum
}
return $this->modArray;
}
function isModerator($uid)
{
return ($uid && in_array($uid, array_keys($this->modArray)));
@@ -857,8 +863,10 @@ class e107forum
function forumGetThreads($forumId, $from, $view)
{
$e107 = e107::getInstance();
$forumId = (int)$forumId;
$from = (int)$from;
$view = (int)$view;
$qry = "
SELECT t.*, u.user_name, lpu.user_name AS lastpost_username from `#forum_thread` as t
LEFT JOIN `#user` AS u ON t.thread_user = u.user_id
@@ -867,17 +875,18 @@ class e107forum
ORDER BY
t.thread_sticky DESC,
t.thread_lastpost DESC
LIMIT ".(int)$from.','.(int)$view;
LIMIT {$from},{$view}";
$ret = array();
if ($e107->sql->db_Select_gen($qry))
$this->threadList = array();
if ($this->e107->sql->db_Select_gen($qry))
{
while ($row = $e107->sql->db_Fetch(MYSQL_ASSOC))
while ($row = $this->e107->sql->db_Fetch())
{
$ret[] = $row;
$this->threadList = $row;
}
return true;
}
return $ret;
return false;
}
function threadGetLastpost($id)
@@ -1218,12 +1227,11 @@ class e107forum
function postDelete($postId, $updateCounts = true)
{
$postId = (int)$postId;
$e107 = e107::getInstance();
if(!$e107->sql->db_Select('forum_post', '*', 'post_id = '.$postId))
if(!$e107->sql->db_Select('forum_post', 'post_user, post_forum, post_thread', 'post_id = '.$postId))
{
echo 'NOT FOUND!'; return;
}
$row = $e107->sql->db_Fetch(MYSQL_ASSOC);
$row = $this->e107->sql->db_Fetch();
//delete attachments if they exist
if($row['post_attachments'])
@@ -1232,21 +1240,21 @@ class e107forum
}
// delete post
$e107->sql->db_Delete('forum_post', 'post_id='.$postId);
$this->e107->sql->db_Delete('forum_post', 'post_id='.$postId);
if($updateCounts)
{
//decrement user post counts
if ($row['post_user'])
{
$e107->sql->db_Update('user_extended', 'user_plugin_forum_posts=GREATEST(user_plugin_forum_posts-1,0) WHERE user_id='.$row['post_user']);
$this->e107->sql->db_Update('user_extended', 'user_plugin_forum_posts=GREATEST(user_plugin_forum_posts-1,0) WHERE user_id='.$row['post_user']);
}
// update thread with correct reply counts
$e107->sql->db_Update('forum_thread', "thread_total_replies=GREATEST(thread_total_replies-1,0) WHERE thread_id=".$row['post_thread']);
$this->e107->sql->db_Update('forum_thread', "thread_total_replies=GREATEST(thread_total_replies-1,0) WHERE thread_id=".$row['post_thread']);
// update forum with correct thread/reply counts
$e107->sql->db_Update('forum', "forum_replies=GREATEST(forum_replies-1,0) WHERE forum_id=".$row['post_forum']);
$this->e107->sql->db_Update('forum', "forum_replies=GREATEST(forum_replies-1,0) WHERE forum_id=".$row['post_forum']);
// update thread lastpost info
$this->forumUpdateLastpost('thread', $row['post_thread']);

View File

@@ -3,7 +3,7 @@
+ ----------------------------------------------------------------------------+
| e107 website system
|
| <20>Steve Dunstan 2001-2002
| <20>Steve Dunstan 2001-2002
| http://e107.org
| jalist@e107.org
|
@@ -11,9 +11,9 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum_post.php,v $
| $Revision: 1.36 $
| $Date: 2009-07-14 11:05:53 $
| $Author: e107coders $
| $Revision: 1.37 $
| $Date: 2009-09-06 04:30:46 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
@@ -22,6 +22,8 @@ require_once('../../class2.php');
$lan_file = e_PLUGIN.'forum/languages/'.e_LANGUAGE.'/lan_forum_post.php';
include(file_exists($lan_file) ? $lan_file : e_PLUGIN.'forum/languages/English/lan_forum_post.php');
e107::getScParser();
if (isset($_POST['fjsubmit']))
{
header('location:'.$e107->url->getUrl('forum', 'thread', array('func' => 'view', 'id'=>$_POST['forumjump'])));

View File

@@ -11,7 +11,7 @@ class forum_shortcodes
var $postInfo;
var $thread;
var $forum;
function forum_shortcodes()
{
$this->e107 = e107::getInstance();
@@ -280,14 +280,14 @@ class forum_shortcodes
$rankInfo = $this->e107->userRank->getRanks($this->postInfo['post_user']);
if(!$parm) { $parm = 'name'; }
switch($parm)
{
case 'userid' :
return $this->sc_memberid();
break;
case 'special':
if(isset($rankInfo['special'])) { return $rankInfo['special']; }
if($this->forum->isModerator($this->postInfo['post_user']))
@@ -296,7 +296,7 @@ class forum_shortcodes
}
return '';
break;
default:
return varset($rankInfo[$parm], '');
break;
@@ -307,7 +307,7 @@ class forum_shortcodes
{
if (MODERATOR)
{
return showmodoptions();
return $this->showModOptions();
}
}
@@ -345,5 +345,48 @@ class forum_shortcodes
// Defined in case an indicator is required
return '';
}
function showModOptions()
{
global $thread, $postInfo;
$e107 = e107::getInstance();
$forum_id = $thread->threadInfo['forum_id'];
if ($this->postInfo['thread_start'])
{
$type = 'Thread';
$ret = "<form method='post' action='" . $this->e107->url->getUrl('forum', 'thread', array('func' => 'view', 'id' => $this->postInfo['post_thread']))."' id='frmMod_{$this->postInfo['post_forum']}_{$this->postInfo['post_thread']}'>";
$delId = $postInfo['post_thread'];
}
else
{
$type = 'Post';
$ret = "<form method='post' action='" . e_SELF . '?' . e_QUERY . "' id='frmMod_{$this->postInfo['post_forum']}_{$this->postInfo['post_thread']}'>";
$delId = $this->postInfo['post_id'];
}
$ret .= "
<div>
<a href='" . $this->e107->url->getUrl('forum', 'thread', array('func' => 'edit', 'id' => $postInfo['post_id']))."'>" . IMAGE_admin_edit . "</a>
<input type='image' " . IMAGE_admin_delete . " name='delete{$type}_{$delId}' value='thread_action' onclick=\"return confirm_('{$type}', {$this->postInfo['post_forum']}, {$this->postInfo['post_thread']}, '{$this->postInfo['user_name']}')\" />
<input type='hidden' name='mod' value='1'/>
";
if ($type == 'Thread')
{
$ret .= "<a href='" . $this->e107->url->getUrl('forum', 'thread', array('func' => 'move', 'id' => $this->postInfo['post_id']))."'>" . IMAGE_admin_move2 . "</a>";
}
else
{
$ret .= "<a href='" . $this->e107->url->getUrl('forum', 'thread', array('func' => 'split', 'id' => $this->postInfo['post_id']))."'>" . IMAGE_admin_split . '</a>';
}
$ret .= "
</div>
</form>";
return $ret;
}
}
?>

View File

@@ -9,8 +9,8 @@
* View specific forums
*
* $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum_viewforum.php,v $
* $Revision: 1.12 $
* $Date: 2008-12-18 14:08:33 $
* $Revision: 1.13 $
* $Date: 2009-09-06 04:30:46 $
* $Author: mcfly_e107 $
*
*/
@@ -38,7 +38,7 @@ $page = (varset($_GET['p']) ? $_GET['p'] : 0);
$threadFrom = $page * $view;
require_once(e_PLUGIN.'forum/forum_class.php');
$forum = new e107forum;
$forum = new plugin_forum_forumClass;
$STARTERTITLE = LAN_54;
$THREADTITLE = LAN_53;
@@ -496,7 +496,7 @@ function parse_sub($subInfo)
$SUB_REPLIES = $subInfo['forum_replies'];
if(USER && is_array($newflag_list) && in_array($subInfo['forum_id'], $newflag_list))
{
$NEWFLAG = "<a href='".$e107->url->getUrl('forum','forum', 'func=mfar&id='.$subInfo['forum_id'])."'>".IMAGE_new.'</a>';
}
else

View File

@@ -6,18 +6,17 @@
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* Message Handler
* Forum Viewtopic
*
* $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum_viewtopic.php,v $
* $Revision: 1.20 $
* $Date: 2009-01-25 17:44:13 $
* $Revision: 1.21 $
* $Date: 2009-09-06 04:30:46 $
* $Author: mcfly_e107 $
*
*/
require_once ('../../class2.php');
if (isset($_POST['fjsubmit']))
{
header('location:' . $e107->url->getUrl('forum', 'forum', array('func' => 'view', 'id' => $_POST['forumjump'])));
@@ -31,48 +30,29 @@ if (!e_QUERY)
header('Location:' . $e107->url->getUrl('forum', 'forum', array('func' => 'main')));
exit;
}
e107::getScParser();
include_lan(e_PLUGIN.'forum/languages/English/lan_forum_viewtopic.php');
include_lan(e_PLUGIN . 'forum/languages/English/lan_forum_viewtopic.php');
include_once (e_PLUGIN . 'forum/forum_class.php');
include_lan(e_PLUGIN . 'forum/templates/forum_icons_template.php');
$forum = new plugin_forum_classes_forumClass;
include_lan(e_PLUGIN.'forum/languages/English/lan_forum_viewtopic.php');
include_lan(e_PLUGIN.'forum/templates/forum_icons_template.php');
$forum->threadNew(varset($_GET['id']));
$forum = new e107forum;
$thread = new e107ForumThread;
if(isset($_GET['f']) && $_GET['f'] == 'post')
{
$thread->processFunction();
}
$thread->init();
if(isset($_POST['track_toggle']))
{
$thread->toggle_track();
exit;
}
//print_a($_POST);
if(isset($_GET['f']))
{
$thread->processFunction();
if($_GET['f'] != 'last') { $thread->init(); }
}
require_once (e_HANDLER . 'level_handler.php');
require_once (e_HANDLER.'level_handler.php');
if (!is_object($e107->userRank)) { $e107->userRank = new e107UserRank; }
require_once (e_PLUGIN . 'forum/forum_shortcodes.php');
setScVar('forum_shortcodes', 'thread', $thread);
$pm_installed = plugInstalled('pm');
require_once (e_PLUGIN.'forum/forum_shortcodes.php');
setScVar('forum_shortcodes', 'thread', $forum->thread);
$pm_installed = e107::isInstalled('pm');
//Only increment thread views if not being viewed by thread starter
if (USER && (USERID != $thread->threadInfo['thread_user'] || $thread->threadInfo['thread_total_replies'] > 0) || !$thread->noInc)
if (USER && (USERID != $forum->thread->threadInfo['thread_user'] || $forum->thread->threadInfo['thread_total_replies'] > 0) || !$forum->thread->noInc)
{
$forum->threadIncview($threadId);
$forum->thread->IncrementViews();
}
define('e_PAGETITLE', LAN_01 . ' / ' . $e107->tp->toHTML($thread->threadInfo['forum_name'], true, 'no_hook, emotes_off') . " / " . $tp->toHTML($thread->threadInfo['thread_name'], true, 'no_hook, emotes_off'));
define('e_PAGETITLE', LAN_01 . ' / ' . $e107->tp->toHTML($forum->thread->threadInfo['forum_name'], true, 'no_hook, emotes_off') . " / " . $tp->toHTML($thread->threadInfo['thread_name'], true, 'no_hook, emotes_off'));
$forum->modArray = $forum->forumGetMods($thread->threadInfo['forum_moderators']);
define('MODERATOR', (USER && $forum->isModerator(USERID)));
setScVar('forum_shortcodes', 'forum', $forum);
@@ -80,25 +60,24 @@ setScVar('forum_shortcodes', 'forum', $forum);
if (MODERATOR && isset($_POST['mod']))
{
require_once (e_PLUGIN . 'forum/forum_mod.php');
$thread->message = forum_thread_moderate($_POST);
$thread->threadInfo = $forum->threadGet($thread->threadId);
$forum->thread->message = forum_thread_moderate($_POST);
}
$postList = $forum->PostGet($thread->threadId, $thread->page * $thread->perPage, $thread->perPage);
$forum->thread->loadPosts();
$gen = new convert;
if ($thread->message)
if ($forum->thread->message)
{
$ns->tablerender('', $thread->message, array('forum_viewtopic', 'msg'));
$ns->tablerender('', $forum->thread->message, array('forum_viewtopic', 'msg'));
}
if (isset($thread->threadInfo['thread_options']['poll']))
if (isset($forum->thread->threadInfo['thread_options']['poll']))
{
if (!defined('POLLCLASS'))
{
include (e_PLUGIN . 'poll/poll_class.php');
}
$_qry = 'SELECT * FROM `#polls` WHERE `poll_datestamp` = ' . $thread->threadId;
$_qry = 'SELECT * FROM `#polls` WHERE `poll_datestamp` = ' . $forum->thread->threadId;
$poll = new poll;
$pollstr = "<div class='spacer'>" . $poll->render_poll($_qry, 'forum', 'query', true) . '</div>';
}
@@ -127,15 +106,15 @@ if (!$FORUMSTART)
// get info for main thread -------------------------------------------------------------------------------------------------------------------------------------------------------------------
$forum->set_crumb(true); // Set $BREADCRUMB (and BACKLINK)
$THREADNAME = $e107->tp->toHTML($thread->threadInfo['thread_name'], true, 'no_hook, emotes_off');
$THREADNAME = $e107->tp->toHTML($forum->thread->threadInfo['thread_name'], true, 'no_hook, emotes_off');
$NEXTPREV = "&lt;&lt; <a href='" . $e107->url->getUrl('forum', 'thread', array('func' => 'prev', 'id' => $thread->threadId)) . "'>" . LAN_389 . "</a>";
$NEXTPREV .= ' | ';
$NEXTPREV .= "<a href='" . $e107->url->getUrl('forum', 'thread', array('func' => 'next', 'id' => $thread->threadId)) . "'>" . LAN_390 . "</a> &gt;&gt;";
if ($pref['forum_track'] && USER)
{
$img = ($thread->threadInfo['track_userid'] ? IMAGE_track : IMAGE_untrack);
$url = $e107->url->getUrl('forum', 'thread', array('func' => 'view', 'id' => $thread->threadId));
$img = ($forum->thread->threadInfo['track_userid'] ? IMAGE_track : IMAGE_untrack);
$url = $e107->url->getUrl('forum', 'thread', array('func' => 'view', 'id' => $forum->thread->threadId));
$TRACK .= "
<span id='forum-track-trigger-container'>
<a href='{$url}' id='forum-track-trigger'>{$img}</a>
@@ -159,75 +138,32 @@ if ($pref['forum_track'] && USER)
$MODERATORS = LAN_321 . implode(', ', $forum->modArray);
$THREADSTATUS = (!$thread->threadInfo['thread_active'] ? LAN_66 : '');
$THREADSTATUS = (!$forum->thread->threadInfo['thread_active'] ? LAN_66 : '');
if ($thread->pages > 1)
if ($forum->thread->pages > 1)
{
$parms = ($thread->pages).",1,{$thread->page},url::forum::thread::func=view&id={$thread->threadId}&page=[FROM],off";
$parms = ($forum->thread->pages).",1,{$forum->thread->page},url::forum::thread::func=view&id={$forum->thread->threadId}&page=[FROM],off";
$GOTOPAGES = $tp->parseTemplate("{NEXTPREV={$parms}}");
}
$BUTTONS = '';
if ($forum->checkPerm($thread->threadInfo['thread_forum_id'], 'post') && $thread->threadInfo['thread_active'])
if ($forum->checkPerm($forum->thread->threadInfo['thread_forum_id'], 'post') && $forum->thread->threadInfo['thread_active'])
{
$BUTTONS .= "<a href='" . $e107->url->getUrl('forum', 'thread', array('func' => 'rp', 'id' => $thread->threadId)) . "'>" . IMAGE_reply . "</a>";
$BUTTONS .= "<a href='" . $e107->url->getUrl('forum', 'thread', array('func' => 'rp', 'id' => $forum->thread->threadId)) . "'>" . IMAGE_reply . "</a>";
}
if ($forum->checkPerm($thread->threadInfo['thread_forum_id'], 'thread'))
if ($forum->checkPerm($forum->thread->threadInfo['thread_forum_id'], 'thread'))
{
$BUTTONS .= "<a href='" . $e107->url->getUrl('forum', 'thread', array('func' => 'nt', 'id' => $thread->threadInfo['thread_forum_id'])) . "'>" . IMAGE_newthread . "</a>";
$BUTTONS .= "<a href='" . $e107->url->getUrl('forum', 'thread', array('func' => 'nt', 'id' => $forum->thread->threadInfo['thread_forum_id'])) . "'>" . IMAGE_newthread . "</a>";
}
$POLL = $pollstr;
$FORUMJUMP = forumjump();
$forstr = preg_replace("/\{(.*?)\}/e", '$\1', $FORUMSTART);
unset($forrep);
if (!$FORUMREPLYSTYLE) $FORUMREPLYSTYLE = $FORUMTHREADSTYLE;
$alt = false;
$forthread = $forum->thread->render();
$i = $thread->page;
foreach ($postList as $postInfo)
{
if($postInfo['post_options'])
{
$postInfo['post_options'] = unserialize($postInfo['post_options']);
}
$loop_uid = (int)$postInfo['post_user'];
$i++;
//TODO: Look into fixing this, to limit to a single query per pageload
$e_hide_query = "SELECT post_id FROM `#forum_post` WHERE (`post_thread` = {$threadId} AND post_user= " . USERID . ' LIMIT 1';
$e_hide_hidden = FORLAN_HIDDEN;
$e_hide_allowed = USER;
if ($i > 1)
{
$postInfo['thread_start'] = false;
$alt = !$alt;
if($postInfo['post_status'])
{
$_style = (isset($FORUMDELETEDSTYLE_ALT) && $alt ? $FORUMDELETEDSTYLE_ALT : $FORUMDELETEDSTYLE);
}
else
{
$_style = (isset($FORUMREPLYSTYLE_ALT) && $alt ? $FORUMREPLYSTYLE_ALT : $FORUMREPLYSTYLE);
}
setScVar('forum_shortcodes', 'postInfo', $postInfo);
$forrep .= $e107->tp->parseTemplate($_style, true, $forum_shortcodes) . "\n";
}
else
{
$postInfo['thread_start'] = true;
setScVar('forum_shortcodes', 'postInfo', $postInfo);
$forthr = $e107->tp->parseTemplate($FORUMTHREADSTYLE, true, $forum_shortcodes) . "\n";
}
}
unset($loop_uid);
if ($forum->checkPerm($thread->threadInfo['thread_forum_id'], 'post') && $thread->threadInfo['thread_active'])
if ($forum->checkPerm($forum->thread->threadInfo['thread_forum_id'], 'post') && $forum->thread->threadInfo['thread_active'])
{
if (!$forum_quickreply)
{
@@ -249,13 +185,13 @@ if ($forum->checkPerm($thread->threadInfo['thread_forum_id'], 'post') && $thread
}
$forend = preg_replace("/\{(.*?)\}/e", '$\1', $FORUMEND);
$forumstring = $forstr . $forthr . $forrep . $forend;
$forumstring = $forstr . $forthread . $forend;
//If last post came after USERLV and not yet marked as read, mark the thread id as read
$threadsViewed = explode(',', $currentUser['user_plugin_forum_viewed']);
if ($thread->threadInfo['thread_lastpost'] > USERLV && !in_array($thread->threadId, $threadsViewed))
if ($forum->thread->threadInfo['thread_lastpost'] > USERLV && !in_array($forum->thread->threadId, $threadsViewed))
{
$tst = $forum->threadMarkAsRead($thread->threadId);
$tst = $forum->threadMarkAsRead($forum->thread->threadId);
}
require_once (HEADERF);
@@ -282,46 +218,6 @@ echo "<script type=\"text/javascript\">
</script>";
require_once (FOOTERF);
function showmodoptions()
{
global $thread, $postInfo;
$e107 = e107::getInstance();
$forum_id = $thread->threadInfo['forum_id'];
if ($postInfo['thread_start'])
{
$type = 'Thread';
$ret = "<form method='post' action='" . $e107->url->getUrl('forum', 'thread', array('func' => 'view', 'id' => $postInfo['post_thread']))."' id='frmMod_{$postInfo['post_forum']}_{$postInfo['post_thread']}'>";
$delId = $postInfo['post_thread'];
}
else
{
$type = 'Post';
$ret = "<form method='post' action='" . e_SELF . '?' . e_QUERY . "' id='frmMod_{$postInfo['post_forum']}_{$postInfo['post_thread']}'>";
$delId = $postInfo['post_id'];
}
$ret .= "
<div>
<a href='" . $e107->url->getUrl('forum', 'thread', array('func' => 'edit', 'id' => $postInfo['post_id']))."'>" . IMAGE_admin_edit . "</a>
<input type='image' " . IMAGE_admin_delete . " name='delete{$type}_{$delId}' value='thread_action' onclick=\"return confirm_('{$type}', {$postInfo['post_forum']}, {$postInfo['post_thread']}, '{$postInfo['user_name']}')\" />
<input type='hidden' name='mod' value='1'/>
";
if ($type == 'Thread')
{
$ret .= "<a href='" . $e107->url->getUrl('forum', 'thread', array('func' => 'move', 'id' => $postInfo['post_id']))."'>" . IMAGE_admin_move2 . "</a>";
}
else
{
$ret .= "<a href='" . $e107->url->getUrl('forum', 'thread', array('func' => 'split', 'id' => $postInfo['post_id']))."'>" . IMAGE_admin_split . '</a>';
}
$ret .= "
</div>
</form>";
return $ret;
}
function forumjump()
{
global $forum;
@@ -439,167 +335,3 @@ function rpg($user_join, $user_forums)
$rpg_info .= "</div>";
return $rpg_info;
}
class e107ForumThread
{
var $message, $threadId, $forumId, $perPage, $noInc, $pages;
function init()
{
global $pref, $forum;
$e107 = e107::getInstance();
$this->threadId = (int)varset($_GET['id']);
$this->perPage = (varset($_GET['perpage']) ? (int)$_GET['perpage'] : $pref['forum_postspage']);
$this->page = (varset($_GET['p']) ? (int)$_GET['p'] : 0);
//If threadId doesn't exist, or not given, redirect to main forum page
if (!$this->threadId || !$this->threadInfo = $forum->threadGet($this->threadId))
{
header('Location:' . $e107->url->getUrl('forum', 'forum', array('func' => 'main')));
exit;
}
//If not permitted to view forum, redirect to main forum page
if (!$forum->checkPerm($this->threadInfo['thread_forum_id'], 'view'))
{
header('Location:' . $e107->url->getUrl('forum', 'forum', array('func' => 'main')));
exit;
}
$this->pages = ceil(($this->threadInfo['thread_total_replies'] + 1) / $this->perPage);
$this->noInc = false;
}
function toggle_track()
{
global $forum, $thread;
$e107 = e107::getInstance();
if (!USER || !isset($_GET['id'])) { return; }
if($thread->threadInfo['track_userid'])
{
$forum->track('del', USERID, $_GET['id']);
$img = IMAGE_untrack;
}
else
{
$forum->track('add', USERID, $_GET['id']);
$img = IMAGE_track;
}
if(e_AJAX_REQUEST)
{
$url = $e107->url->getUrl('forum', 'thread', array('func' => 'view', 'id' => $thread->threadId));
echo "<a href='{$url}' id='forum-track-trigger'>{$img}</a>";
exit();
}
}
function processFunction()
{
global $forum, $thread, $pref;
$e107 = e107::getInstance();
if (!isset($_GET['f']))
{
return;
}
$function = trim($_GET['f']);
switch ($function)
{
case 'post':
$postId = varset($_GET['id']);
$postInfo = $forum->postGet($postId,'post');
$postNum = $forum->postGetPostNum($postInfo['post_thread'], $postId);
$postPage = ceil($postNum / $pref['forum_postspage'])-1;
$url = $e107->url->getUrl('forum', 'thread', "func=view&id={$postInfo['post_thread']}&page=$postPage");
header('location: '.$url);
exit;
break;
case 'last':
$pages = ceil(($thread->threadInfo['thread_total_replies'] + 1) / $thread->perPage);
$thread->page = ($pages - 1);
break;
case 'next':
$next = $forum->threadGetNextPrev('next', $this->threadId, $this->threadInfo['forum_id'], $this->threadInfo['thread_lastpost']);
if ($next)
{
$url = $e107->url->getUrl('forum', 'thread', array('func' => 'view', 'id' => $next));
header("location: {$url}");
exit;
}
$this->message = LAN_405;
break;
case 'prev':
$prev = $forum->threadGetNextPrev('prev', $this->threadId, $this->threadInfo['forum_id'], $this->threadInfo['thread_lastpost']);
if ($prev)
{
$url = $e107->url->getUrl('forum', 'thread', array('func' => 'view', 'id' => $prev));
header("location: {$url}");
exit;
}
$this->message = LAN_404;
break;
case 'report':
$postId = (int)$_GET['id'];
$postInfo = $forum->postGet($postId, 'post');
if (isset($_POST['report_thread']))
{
$report_add = $e107->tp->toDB($_POST['report_add']);
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;
sendemail(SITEADMINEMAIL, $subject, $report);
}
$e107->sql->db_Insert('generic', "0, 'reported_post', " . time() . ", '" . USERID . "', '{$thread_info['head']['thread_name']}', " . intval($thread_id) . ", '{$report_add}'");
define('e_PAGETITLE', LAN_01 . " / " . LAN_428);
require_once (HEADERF);
$text = LAN_424 . "<br /><br /><a href='forum_viewtopic.php?" . $thread_id . ".post'>" . LAN_429 . '</a>';
$e107->ns->tablerender(LAN_414, $text, array('forum_viewtopic', 'report'));
}
else
{
$thread_name = $e107->tp->toHTML($postInfo['thread_name'], true, 'no_hook, emotes_off');
define('e_PAGETITLE', LAN_01 . ' / ' . LAN_426 . ' ' . $thread_name);
require_once (HEADERF);
$url = $e107->url->getUrl('forum', 'thread', 'func=post&id='.$postId);
$actionUrl = $e107->url->getUrl('forum', 'thread', 'func=report&id='.$postId);
$text = "<form action='".$actionUrl."' method='post'>
<table style='width:100%'>
<tr>
<td style='width:50%' >
" . LAN_415 . ': ' . $thread_name . " <a href='".$url."'><span class='smalltext'>" . LAN_420 . " </span>
</a>
</td>
<td style='text-align:center;width:50%'>
</td>
</tr>
<tr>
<td>" . LAN_417 . "<br />" . LAN_418 . "
</td>
<td style='text-align:center;'>
<textarea cols='40' rows='10' class='tbox' name='report_add'></textarea>
</td>
</tr>
<tr>
<td colspan='2' style='text-align:center;'><br />
<input class='button' type='submit' name='report_thread' value='" . LAN_419 . "' />
</td>
</tr>
</table>";
$e107->ns->tablerender(LAN_414, $text, array('forum_viewtopic', 'report2'));
}
require_once (FOOTERF);
exit;
break;
}
}
}
?>