mirror of
https://github.com/e107inc/e107.git
synced 2025-07-31 11:50:30 +02:00
More forum work, neearly all display functionality working. Beginning work on moderator functionality
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
// $Id: forum.php,v 1.4 2008-12-15 00:29:20 mcfly_e107 Exp $
|
||||
// $Id: forum.php,v 1.5 2008-12-17 04:22:37 mcfly_e107 Exp $
|
||||
function url_forum_forum($parms)
|
||||
{
|
||||
switch($parms['func'])
|
||||
@@ -21,5 +21,13 @@ function url_forum_forum($parms)
|
||||
return e_PLUGIN_ABS."forum/forum_post.php?f={$parms['type']}}id={$parms['id']}";
|
||||
break;
|
||||
|
||||
case 'rules':
|
||||
return e_PLUGIN_ABS.'forum/forum.php?f=rules';
|
||||
break;
|
||||
|
||||
case 'mfar':
|
||||
return e_PLUGIN_ABS.'forum/forum.php?f=mfar&id='.$parms['id'];
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
// $Id: thread.php,v 1.8 2008-12-15 00:29:20 mcfly_e107 Exp $
|
||||
// $Id: thread.php,v 1.9 2008-12-17 04:22:37 mcfly_e107 Exp $
|
||||
function url_forum_thread($parms)
|
||||
{
|
||||
switch($parms['func'])
|
||||
@@ -28,7 +28,7 @@ function url_forum_thread($parms)
|
||||
|
||||
case 'report':
|
||||
$page = (isset($parms['page']) ? (int)$parms['page'] : 0 );
|
||||
return e_PLUGIN_ABS."forum/forum_viewtopic.php?f=report&id={$parms['report']}&p={$page}";
|
||||
return e_PLUGIN_ABS."forum/forum_viewtopic.php?f=report&id={$parms['id']}&p={$page}";
|
||||
break;
|
||||
|
||||
case 'edit':
|
||||
|
@@ -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.11 $
|
||||
| $Date: 2008-12-15 00:29:20 $
|
||||
| $Revision: 1.12 $
|
||||
| $Date: 2008-12-17 04:22:37 $
|
||||
| $Author: mcfly_e107 $
|
||||
+----------------------------------------------------------------------------+
|
||||
*/
|
||||
@@ -33,28 +33,28 @@ if ($untrackId = varset($_REQUEST['untrack']))
|
||||
exit;
|
||||
}
|
||||
|
||||
//Mark all threads as read
|
||||
if (e_QUERY == 'mark.all.as.read')
|
||||
if(isset($_GET['f']))
|
||||
{
|
||||
$forum->forum_markasread('all');
|
||||
header('location:'.e_SELF);
|
||||
exit;
|
||||
}
|
||||
if(isset($_GET['id']))
|
||||
{
|
||||
$id = (int)$_GET['id'];
|
||||
}
|
||||
|
||||
//Mark all threads in specific forum as read
|
||||
if (varset($_REQUEST['mfar']))
|
||||
{
|
||||
$forum->forum_markasread((int)$_REQUEST['mfar']);
|
||||
header('location:'.e_SELF);
|
||||
exit;
|
||||
}
|
||||
|
||||
if (e_QUERY == 'rules')
|
||||
{
|
||||
include_once(HEADERF);
|
||||
forum_rules('show');
|
||||
include_once(FOOTERF);
|
||||
exit;
|
||||
switch($_GET['f'])
|
||||
{
|
||||
case 'mfar':
|
||||
$forum->forumMarkAsRead($id);
|
||||
header('location:'.e_SELF);
|
||||
exit;
|
||||
break;
|
||||
|
||||
case 'rules':
|
||||
include_once(HEADERF);
|
||||
forum_rules('show');
|
||||
include_once(FOOTERF);
|
||||
exit;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$gen = new convert;
|
||||
@@ -74,7 +74,7 @@ $rules_text = forum_rules('check');
|
||||
$USERINFO = "<a href='".e_BASE."top.php?0.top.forum.10'>".LAN_429."</a> | <a href='".e_BASE."top.php?0.active'>".LAN_430."</a>";
|
||||
if(USER)
|
||||
{
|
||||
$USERINFO .= " | <a href='".e_BASE."userposts.php?0.forums.".USERID."'>".LAN_431."</a> | <a href='".e_BASE."usersettings.php'>".LAN_432."</a> | <a href='".e_BASE."user.php?id.".USERID."'>".LAN_435."</a>";
|
||||
$USERINFO .= " | <a href='".e_BASE.'userposts.php?0.forums.'.USERID."'>".LAN_431."</a> | <a href='".e_BASE."usersettings.php'>".LAN_432."</a> | <a href='".e_BASE."user.php?id.".USERID."'>".LAN_435."</a>";
|
||||
if($pref['forum_attach'] && (check_class($pref['upload_class']) || getperms('0')))
|
||||
{
|
||||
$USERINFO .= " | <a href='".e_PLUGIN."forum/forum_uploads.php'>".FORLAN_442."</a>";
|
||||
@@ -82,7 +82,7 @@ if(USER)
|
||||
}
|
||||
if($rules_text != '')
|
||||
{
|
||||
$USERINFO .= " | <a href='".e_PLUGIN."forum/forum.php?rules'>".LAN_433."</a>";
|
||||
$USERINFO .= " | <a href='".$e107->url->getUrl('forum', 'forum', "func=rules")."'>".LAN_433.'</a>';
|
||||
}
|
||||
$total_topics = $sql->db_Count("forum_t", "(*)", " WHERE thread_parent='0' ");
|
||||
$total_replies = $sql->db_Count("forum_t", "(*)", " WHERE thread_parent!='0' ");
|
||||
@@ -198,7 +198,7 @@ if (USER && varsettrue($pref['forum_track']) && e_QUERY != 'track')
|
||||
$INFO .= "<br /><a href='".e_SELF."?track'>".LAN_393.'</a>';
|
||||
}
|
||||
|
||||
$FORUMINFO = LAN_192.($total_topics+$total_replies)." ".LAN_404." ($total_topics ".($total_topics == 1 ? LAN_411 : LAN_413).", $total_replies ".($total_replies == 1 ? LAN_412 : LAN_414).").".(!defined("e_TRACKING_DISABLED") ? "" : "<br />".$users." ".($users == 1 ? LAN_415 : LAN_416)." (".$member_users." ".($member_users == 1 ? LAN_417 : LAN_419).", ".$guest_users." ".($guest_users == 1 ? LAN_418 : LAN_420).")<br />".LAN_42.$total_members."<br />".LAN_41."<a href='".e_BASE."user.php?id.".$nuser_id."'>".$nuser_name."</a>.\n");
|
||||
$FORUMINFO = LAN_192.($total_topics+$total_replies).' '.LAN_404." ($total_topics ".($total_topics == 1 ? LAN_411 : LAN_413).", $total_replies ".($total_replies == 1 ? LAN_412 : LAN_414).").".(!defined("e_TRACKING_DISABLED") ? "" : "<br />".$users." ".($users == 1 ? LAN_415 : LAN_416)." (".$member_users." ".($member_users == 1 ? LAN_417 : LAN_419).", ".$guest_users." ".($guest_users == 1 ? LAN_418 : LAN_420).")<br />".LAN_42.$total_members."<br />".LAN_41."<a href='".e_BASE."user.php?id.".$nuser_id."'>".$nuser_name."</a>.\n");
|
||||
|
||||
if (!isset($FORUM_MAIN_START))
|
||||
{
|
||||
@@ -210,12 +210,10 @@ if (!isset($FORUM_MAIN_START))
|
||||
include(e_PLUGIN.'forum/templates/forum_template.php');
|
||||
require_once(HEADERF);
|
||||
|
||||
$parent_list = $forum->forum_getparents();
|
||||
$forum_list = $forum->forum_getforums();
|
||||
$sub_list = $forum->forumGetSubs();
|
||||
$newflag_list = $forum->forum_newflag_list();
|
||||
$forumList = $forum->forumGetForumList();
|
||||
$newflag_list = $forum->forumGetUnreadForums();
|
||||
|
||||
if (!$parent_list)
|
||||
if (!$forumList)
|
||||
{
|
||||
$ns->tablerender(PAGE_NAME, "<div style='text-align:center'>".LAN_51.'</div>', array('forum', '51'));
|
||||
require_once(FOOTERF);
|
||||
@@ -223,7 +221,7 @@ if (!$parent_list)
|
||||
}
|
||||
|
||||
$forum_string = '';
|
||||
foreach ($parent_list as $parent)
|
||||
foreach ($forumList['parents'] as $parent)
|
||||
{
|
||||
$status = parse_parent($parent);
|
||||
$PARENTSTATUS = $status[0];
|
||||
@@ -231,14 +229,13 @@ foreach ($parent_list as $parent)
|
||||
{
|
||||
$PARENTNAME = $parent['forum_name'];
|
||||
$forum_string .= preg_replace("/\{(.*?)\}/e", '$\1', $FORUM_MAIN_PARENT);
|
||||
// $forums = $forum->forum_getforums($parent['forum_id']);
|
||||
if (!count($forum_list[$parent['forum_id']]))
|
||||
if (!count($forumList['forums'][$parent['forum_id']]))
|
||||
{
|
||||
$text .= "<td colspan='5' style='text-align:center' class='forumheader3'>".LAN_52."</td>";
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach($forum_list[$parent['forum_id']] as $f)
|
||||
foreach($forumList['forums'][$parent['forum_id']] as $f)
|
||||
{
|
||||
if ($f['forum_class'] == e_UC_ADMIN && ADMIN)
|
||||
{
|
||||
@@ -273,8 +270,8 @@ function parse_parent($parent)
|
||||
{
|
||||
if(check_class($parent['forum_class']))
|
||||
{
|
||||
$status[0]="";
|
||||
$status[1] = TRUE;
|
||||
$status[0] = '';
|
||||
$status[1] = true;
|
||||
if(!check_class($parent['forum_postclass']))
|
||||
{
|
||||
$status[0] = '( '.LAN_405.' )';
|
||||
@@ -282,19 +279,20 @@ function parse_parent($parent)
|
||||
}
|
||||
else
|
||||
{
|
||||
$status[1] = FALSE;
|
||||
$status[1] = false;
|
||||
}
|
||||
return $status;
|
||||
}
|
||||
|
||||
function parse_forum($f, $restricted_string = '')
|
||||
{
|
||||
global $FORUM_MAIN_FORUM, $gen, $forum, $tp, $newflag_list, $sub_list;
|
||||
global $FORUM_MAIN_FORUM, $gen, $forum, $newflag_list, $forumList;
|
||||
$e107 = e107::getInstance();
|
||||
|
||||
if(USER && is_array($newflag_list) && in_array($f['forum_id'], $newflag_list))
|
||||
{
|
||||
$NEWFLAG = "<a href='".e_SELF."?mfar.{$f['forum_id']}'>".IMAGE_new."</a>";
|
||||
|
||||
$NEWFLAG = "<a href='".$e107->url->getUrl('forum','forum', 'func=mfar&id='.$f['forum_id'])."'>".IMAGE_new.'</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -305,58 +303,49 @@ function parse_forum($f, $restricted_string = '')
|
||||
{
|
||||
$f['forum_name'] = substr($f['forum_name'], 1);
|
||||
}
|
||||
$f['forum_name'] = $tp -> toHTML($f['forum_name'], TRUE, 'no_hook');
|
||||
$f['forum_description'] = $tp -> toHTML($f['forum_description'], TRUE, 'no_hook');
|
||||
|
||||
// $e107->url->getUrl('forum', 'thread', array('func' => 'track')))
|
||||
$f['forum_name'] = $e107->tp->toHTML($f['forum_name'], true, 'no_hook');
|
||||
$f['forum_description'] = $e107->tp->toHTML($f['forum_description'], true, 'no_hook');
|
||||
|
||||
$FORUMNAME = "<a href='".$e107->url->getUrl('forum', 'forum', "func=view&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'];
|
||||
$FORUMSUBFORUMS = "";
|
||||
$FORUMSUBFORUMS = '';
|
||||
|
||||
if(is_array($sub_list[$f['forum_parent']][$f['forum_id']]))
|
||||
if(is_array($forumList['subs'][$f['forum_id']]))
|
||||
{
|
||||
list($lastpost_datestamp, $lastpost_thread) = explode(".", $f['forum_lastpost_info']);
|
||||
$ret = parse_subs($sub_list[$f['forum_parent']][$f['forum_id']], $lastpost_datestamp);
|
||||
list($lastpost_datestamp, $lastpost_thread) = explode('.', $f['forum_lastpost_info']);
|
||||
$ret = parse_subs($forumList['subs'][$f['forum_id']], $lastpost_datestamp);
|
||||
$FORUMSUBFORUMS = "<br /><div class='smalltext'>".FORLAN_444.": {$ret['text']}</div>";
|
||||
$THREADS += $ret['threads'];
|
||||
$REPLIES += $ret['replies'];
|
||||
if(isset($ret['lastpost_info']))
|
||||
{
|
||||
$f['forum_lastpost_info'] = $ret['lastpost_info'];
|
||||
$f['forum_lastpost_user'] = $ret['lastpost_user'];
|
||||
$f['forum_lastpost_user_anon'] = $ret['lastpost_user_anon'];
|
||||
$f['user_name'] = $ret['user_name'];
|
||||
}
|
||||
}
|
||||
|
||||
if ($f['forum_lastpost_user'])
|
||||
if ($f['forum_lastpost_info'])
|
||||
{
|
||||
list($lastpost_datestamp, $lastpost_thread) = explode(".", $f['forum_lastpost_info']);
|
||||
$tmp = explode(".", $f['forum_lastpost_user'], 2);
|
||||
list($lastpost_datestamp, $lastpost_thread) = explode('.', $f['forum_lastpost_info']);
|
||||
if ($f['user_name'])
|
||||
{
|
||||
$lastpost_name = "<a href='".e_BASE."user.php?id.{$tmp[0]}'>{$f['user_name']}</a>";
|
||||
|
||||
$lastpost_name = "<a href='".$e107->url->getUrl('core:user','main','func=profile&id='.$f['forum_lastpost_user'])."'>{$f['user_name']}</a>";
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!$tmp[1])
|
||||
{
|
||||
$lastpost_name = FORLAN_443;
|
||||
}
|
||||
else
|
||||
{
|
||||
$lastpost_name = $tp->toHTML($tmp[1]);
|
||||
}
|
||||
$lastpost_name = $e107->tp->toHTML($f['forum_lastpost_user_anon']);
|
||||
}
|
||||
$lastpost_datestamp = $gen->convert_date($lastpost_datestamp, 'forum');
|
||||
// $e107->url->getUrl('forum', 'thread', array('func' => 'last', 'id' => $lastpost_thread));
|
||||
|
||||
$LASTPOST = $lastpost_datestamp.'<br />'.$lastpost_name." <a href='".$e107->url->getUrl('forum', 'thread', array('func' => 'last', 'id' => $lastpost_thread))."'>".IMAGE_post2.'</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$LASTPOST = "-";
|
||||
$LASTPOST = '-';
|
||||
}
|
||||
return(preg_replace("/\{(.*?)\}/e", '$\1', $FORUM_MAIN_FORUM));
|
||||
}
|
||||
@@ -365,7 +354,7 @@ function parse_subs($subList, $lastpost_datestamp)
|
||||
{
|
||||
$e107 = e107::getInstance();
|
||||
$ret = array();
|
||||
$ret['text'] = "";
|
||||
$ret['text'] = '';
|
||||
foreach($subList as $sub)
|
||||
{
|
||||
$ret['text'] .= ($ret['text'] ? ', ' : '');
|
||||
@@ -377,6 +366,8 @@ function parse_subs($subList, $lastpost_datestamp)
|
||||
if($tmp[0] > $lastpost_datestamp)
|
||||
{
|
||||
$ret['lastpost_info'] = $sub['forum_lastpost_info'];
|
||||
$ret['lastpost_user'] = $sub['forum_lastpost_user'];
|
||||
$ret['lastpost_user_anon'] = $sub['lastpost_user_anon'];
|
||||
$ret['user_name'] = $sub['user_name'];
|
||||
$lastpost_datestamp = $tmp[0];
|
||||
}
|
||||
@@ -386,12 +377,8 @@ function parse_subs($subList, $lastpost_datestamp)
|
||||
|
||||
if (e_QUERY == 'track')
|
||||
{
|
||||
// if(!USER) { return ; }
|
||||
if($trackedThreadList = $forum->getTrackedThreadList(USERID, 'list'))
|
||||
{
|
||||
|
||||
// $sql2 = new db;
|
||||
// $tmp = explode("-", USERREALM);
|
||||
$viewed = $forum->threadGetUserViewed();
|
||||
$qry = "
|
||||
SELECT t.*, p.* from `#forum_thread` AS t
|
||||
@@ -488,12 +475,12 @@ require_once(FOOTERF);
|
||||
|
||||
function forum_rules($action = 'check')
|
||||
{
|
||||
global $tp, $sql, $ns;
|
||||
if (ADMIN == TRUE)
|
||||
$e107 = e107::getInstance();
|
||||
if (ADMIN == true)
|
||||
{
|
||||
$type = 'forum_rules_admin';
|
||||
}
|
||||
elseif(USER == TRUE)
|
||||
elseif(USER == true)
|
||||
{
|
||||
$type = 'forum_rules_member';
|
||||
}
|
||||
@@ -501,27 +488,18 @@ function forum_rules($action = 'check')
|
||||
{
|
||||
$type = 'forum_rules_guest';
|
||||
}
|
||||
$result = $sql->db_Select('generic', 'gen_chardata', "gen_type = '$type' AND gen_intdata = 1");
|
||||
if ($action == 'check')
|
||||
{
|
||||
if ($result)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
$result = $e107->sql->db_Select('generic', 'gen_chardata', "gen_type = '$type' AND gen_intdata = 1");
|
||||
if ($action == 'check') { return $result; }
|
||||
|
||||
if ($result)
|
||||
{
|
||||
$row = $sql->db_Fetch();
|
||||
$rules_text = $tp->toHTML($row['gen_chardata'], TRUE);
|
||||
$row = $e107->sql->db_Fetch();
|
||||
$rules_text = $e107->tp->toHTML($row['gen_chardata'], true);
|
||||
}
|
||||
else
|
||||
{
|
||||
$rules_text = FORLAN_441;
|
||||
}
|
||||
$ns->tablerender(LAN_433, "<div style='text-align:center'>{$rules_text}</div>", array('forum', 'forum_rules'));
|
||||
$e107->ns->tablerender(LAN_433, "<div style='text-align:center'>{$rules_text}</div>", array('forum', 'forum_rules'));
|
||||
}
|
||||
?>
|
@@ -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.27 $
|
||||
| $Date: 2008-12-15 00:29:20 $
|
||||
| $Revision: 1.28 $
|
||||
| $Date: 2008-12-17 04:22:37 $
|
||||
| $Author: mcfly_e107 $
|
||||
+----------------------------------------------------------------------------+
|
||||
*/
|
||||
@@ -39,9 +39,9 @@ class e107forum
|
||||
$this->fieldTypes['forum_thread']['thread_user'] = 'int';
|
||||
$this->fieldTypes['forum_thread']['thread_lastpost'] = 'int';
|
||||
$this->fieldTypes['forum_thread']['thread_lastuser'] = 'int';
|
||||
$this->fieldTypes['forum_thread']['thread_sticky'] = 'int';
|
||||
$this->fieldTypes['forum_thread']['thread_sticky'] = 'int';
|
||||
$this->fieldTypes['forum_thread']['thread_forum_id'] = 'int';
|
||||
$this->fieldTypes['forum_thread']['thread_active'] = 'int';
|
||||
$this->fieldTypes['forum_thread']['thread_active'] = 'int';
|
||||
$this->fieldTypes['forum_thread']['thread_datestamp'] = 'int';
|
||||
$this->fieldTypes['forum_thread']['thread_views'] = 'int';
|
||||
$this->fieldTypes['forum_thread']['thread_replies'] = 'int';
|
||||
@@ -49,7 +49,6 @@ class e107forum
|
||||
|
||||
$this->fieldTypes['forum']['forum_lastpost_user'] = 'int';
|
||||
|
||||
// var_dump($this->permList);
|
||||
}
|
||||
|
||||
function loadPermList()
|
||||
@@ -108,7 +107,6 @@ class e107forum
|
||||
}
|
||||
}
|
||||
}
|
||||
//var_dump($this->permList);
|
||||
}
|
||||
|
||||
|
||||
@@ -188,8 +186,6 @@ class e107forum
|
||||
|
||||
$threadInfo['_FIELD_TYPES'] = $this->fieldTypes['forum_thread'];
|
||||
$threadInfo['_FIELD_TYPES']['thread_total_replies'] = 'cmd';
|
||||
// var_dump($threadInfo);
|
||||
// exit;
|
||||
$result = $e107->sql->db_Update('forum_thread', $threadInfo);
|
||||
|
||||
}
|
||||
@@ -255,10 +251,7 @@ class e107forum
|
||||
$e107 = e107::getInstance();
|
||||
$threadInfo['_FIELD_TYPES'] = $this->fieldTypes['forum_thread'];
|
||||
$threadInfo['WHERE'] = 'thread_id = '.(int)$threadId;
|
||||
// var_dump($threadInfo);
|
||||
// exit;
|
||||
$e107->sql->db_Update('forum_thread', $threadInfo);
|
||||
//TODO: Add this
|
||||
}
|
||||
|
||||
function postUpdate($postId, $postInfo)
|
||||
@@ -383,12 +376,12 @@ class e107forum
|
||||
$e107 = e107::getInstance();
|
||||
if($uid == USERID)
|
||||
{
|
||||
$viewed = $e107->currentUser['plugin_forum_user_viewed'];
|
||||
$viewed = $e107->currentUser['user_plugin_forum_viewed'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$tmp = get_user_data($uid);
|
||||
$viewed = $tmp['plugin_forum_user_viewed'];
|
||||
$viewed = $tmp['user_plugin_forum_viewed'];
|
||||
unset($tmp);
|
||||
}
|
||||
return explode(',', $viewed);
|
||||
@@ -467,28 +460,6 @@ class e107forum
|
||||
return $e107->sql->db_Count('forum_post', '(*)', "WHERE post_id <= {$postId} AND post_thread = {$threadId} ORDER BY post_id ASC");
|
||||
}
|
||||
|
||||
|
||||
function thread_postnum($thread_id)
|
||||
{
|
||||
global $sql;
|
||||
$ret = array();
|
||||
$ret['parent'] = $thread_id;
|
||||
$query = "
|
||||
SELECT ft.thread_id, fp.thread_id as parent
|
||||
FROM #forum_t AS t
|
||||
LEFT JOIN #forum_t AS ft ON ft.thread_parent = t.thread_parent AND ft.thread_id <= ".intval($thread_id)."
|
||||
LEFT JOIN #forum_t as fp ON fp.thread_id = t.thread_parent
|
||||
WHERE t.thread_id = ".intval($thread_id)." AND t.thread_parent != 0
|
||||
ORDER BY ft.thread_datestamp ASC
|
||||
";
|
||||
if($ret['post_num'] = $sql->db_Select_gen($query))
|
||||
{
|
||||
$row = $sql->db_Fetch(MYSQL_ASSOC);
|
||||
$ret['parent'] = $row['parent'];
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function forumUpdateLastpost($type, $id, $update_threads = FALSE)
|
||||
{
|
||||
global $sql, $tp;
|
||||
@@ -525,7 +496,6 @@ class e107forum
|
||||
}
|
||||
foreach($parentList as $id)
|
||||
{
|
||||
// echo "Updating forum #{$id}<br />";
|
||||
$this->update_lastpost('forum', $id, $update_threads);
|
||||
}
|
||||
}
|
||||
@@ -563,37 +533,53 @@ class e107forum
|
||||
}
|
||||
}
|
||||
|
||||
function forum_markasread($forum_id)
|
||||
function forumMarkAsRead($forum_id)
|
||||
{
|
||||
global $sql;
|
||||
if ($forum_id != 'all')
|
||||
{
|
||||
$forum_id = intval($forum_id);
|
||||
$extra = " AND thread_forum_id={$forum_id}";
|
||||
}
|
||||
$qry = "thread_lastpost > ".USERLV." AND thread_parent = 0 {$extra} ";
|
||||
if ($sql->db_Select('forum_t', 'thread_id', $qry))
|
||||
{
|
||||
while ($row = $sql->db_Fetch(MYSQL_ASSOC))
|
||||
$e107 = e107::getInstance();
|
||||
$extra = '';
|
||||
$newIdList = array();
|
||||
if ($forum_id !== 0)
|
||||
{
|
||||
$u_new .= $row['thread_id'].".";
|
||||
$forum_id = (int)$forum_id;
|
||||
$flist = array();
|
||||
$flist[] = $forum_id;
|
||||
if($subList = $this->forumGetSubs($forum_id))
|
||||
{
|
||||
foreach($subList as $sub)
|
||||
{
|
||||
$flist[] = $sub['forum_id'];
|
||||
}
|
||||
}
|
||||
$forumList = implode(',', $flist);
|
||||
$extra = " AND thread_forum_id IN($forumList)";
|
||||
}
|
||||
$u_new .= USERVIEWED;
|
||||
$t = array_unique(explode('.',$u_new)); // Filter duplicates
|
||||
$u_new = implode('.',$t);
|
||||
$sql->db_Update('user', "user_viewed='{$u_new}' WHERE user_id=".USERID);
|
||||
header("location:".e_SELF);
|
||||
$qry = 'thread_lastpost > '.USERLV.$extra;
|
||||
|
||||
if ($e107->sql->db_Select('forum_thread', 'thread_id', $qry))
|
||||
{
|
||||
while ($row = $e107->sql->db_Fetch(MYSQL_ASSOC))
|
||||
{
|
||||
$newIdList[] = $row['thread_id'];
|
||||
}
|
||||
if(count($newIdList))
|
||||
{
|
||||
$this->threadMarkAsRead($newIdList);
|
||||
}
|
||||
}
|
||||
header('location:'.e_SELF);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function threadMarkAsRead($threadId)
|
||||
{
|
||||
global $currentUser;
|
||||
$e107 = e107::getInstance();
|
||||
$threadId = (int)$threadId;
|
||||
$_tmp = preg_split('#\,+#', $currentUser['user_plugin_forum_viewed']);
|
||||
$_tmp[] = $threadId;
|
||||
if(!is_array($threadId)) { $threadId = array($threadId); }
|
||||
foreach($threadId as $tid)
|
||||
{
|
||||
$_tmp[] = (int)$tid;
|
||||
}
|
||||
$tmp = array_unique($tmp);
|
||||
$viewed = trim(implode(',', $_tmp), ',');
|
||||
return $e107->sql->db_Update('user_extended', "user_plugin_forum_viewed = '{$viewed}' WHERE user_extended_id = ".USERID);
|
||||
@@ -602,7 +588,7 @@ class e107forum
|
||||
function forum_getparents()
|
||||
{
|
||||
global $sql;
|
||||
if ($sql->db_Select('forum', '*', "forum_parent=0 ORDER BY forum_order ASC"))
|
||||
if ($sql->db_Select('forum', '*', 'forum_parent=0 ORDER BY forum_order ASC'))
|
||||
{
|
||||
while ($row = $sql->db_Fetch(MYSQL_ASSOC)) {
|
||||
$ret[] = $row;
|
||||
@@ -612,7 +598,7 @@ class e107forum
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
function forum_getmods($uclass = e_UC_ADMIN)
|
||||
function forumGetMods($uclass = e_UC_ADMIN)
|
||||
{
|
||||
$e107 = e107::getInstance();
|
||||
if($uclass == e_UC_ADMIN || trim($uclass) == '')
|
||||
@@ -630,6 +616,38 @@ class e107forum
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function forumGetForumList()
|
||||
{
|
||||
$e107 = e107::getInstance();
|
||||
$qry = '
|
||||
SELECT f.*, u.user_name FROM `#forum` AS f
|
||||
LEFT JOIN `#user` AS u ON f.forum_lastpost_user IS NOT NULL AND u.user_id = f.forum_lastpost_user
|
||||
ORDER BY f.forum_order ASC
|
||||
';
|
||||
if ($e107->sql->db_Select_gen($qry))
|
||||
{
|
||||
$ret = array();
|
||||
while ($row = $e107->sql->db_Fetch(MYSQL_ASSOC))
|
||||
{
|
||||
if(!$row['forum_parent'])
|
||||
{
|
||||
$ret['parents'][] = $row;
|
||||
}
|
||||
elseif($row['forum_sub'])
|
||||
{
|
||||
// $ret['subs'][$row['forum_parent']][$row['forum_sub']][] = $row;
|
||||
$ret['subs'][$row['forum_sub']][] = $row;
|
||||
}
|
||||
else
|
||||
{
|
||||
$ret['forums'][$row['forum_parent']][] = $row;
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function forum_getforums($type = 'all')
|
||||
{
|
||||
global $sql;
|
||||
@@ -689,32 +707,33 @@ class e107forum
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function forum_newflag_list()
|
||||
/**
|
||||
* List of forums with unread threads
|
||||
*
|
||||
* Get a list of forum IDs that have unread threads.
|
||||
* If a forum is a subforum, also ensure the parent is in the list.
|
||||
*
|
||||
* @return type description
|
||||
* @access public
|
||||
*/
|
||||
function forumGetUnreadForums()
|
||||
{
|
||||
if (!USER) return FALSE; // Can't determine new threads for non-logged in users
|
||||
global $sql;
|
||||
$viewed = "";
|
||||
if(USERVIEWED)
|
||||
if (!USER) {return false; } // Can't determine new threads for non-logged in users
|
||||
$e107 = e107::getInstance();
|
||||
$viewed = '';
|
||||
|
||||
if($e107->currentUser['user_plugin_forum_viewed'])
|
||||
{
|
||||
$viewed = preg_replace("#\.+#", ".", USERVIEWED);
|
||||
$viewed = preg_replace("#^\.#", "", $viewed);
|
||||
$viewed = preg_replace("#\.$#", "", $viewed);
|
||||
$viewed = str_replace(".", ",", $viewed);
|
||||
}
|
||||
if($viewed != "")
|
||||
{
|
||||
$viewed = " AND thread_id NOT IN (".$viewed.")";
|
||||
$viewed = " AND thread_id NOT IN (".$e107->currentUser['user_plugin_forum_viewed'].")";
|
||||
}
|
||||
|
||||
$_newqry = "
|
||||
SELECT DISTINCT ff.forum_sub, ft.thread_forum_id FROM #forum_t AS ft
|
||||
LEFT JOIN #forum AS ff ON ft.thread_forum_id = ff.forum_id
|
||||
WHERE thread_parent = 0 AND thread_lastpost > ".USERLV." {$viewed}
|
||||
";
|
||||
if($sql->db_Select_gen($_newqry))
|
||||
$_newqry = '
|
||||
SELECT DISTINCT f.forum_sub, ft.thread_forum_id FROM `#forum_thread` AS ft
|
||||
LEFT JOIN `#forum` AS f ON f.forum_id = ft.thread_forum_id
|
||||
WHERE ft.thread_lastpost > '.USERLV.' '.$viewed;
|
||||
if($e107->sql->db_Select_gen($_newqry))
|
||||
{
|
||||
while($row = $sql->db_Fetch(MYSQL_ASSOC))
|
||||
while($row = $e107->sql->db_Fetch(MYSQL_ASSOC))
|
||||
{
|
||||
$ret[] = $row['thread_forum_id'];
|
||||
if($row['forum_sub'])
|
||||
@@ -726,7 +745,7 @@ class e107forum
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -823,19 +842,6 @@ class e107forum
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function thread_update($thread_id, $newvals)
|
||||
{
|
||||
global $sql, $tp;
|
||||
foreach($newvals as $var => $val)
|
||||
{
|
||||
$var = $tp -> toDB($var);
|
||||
$val = $tp -> toDB($val);
|
||||
$newvalArray[] = "{$var} = '{$val}'";
|
||||
}
|
||||
$newString = implode(', ', $newvalArray)." WHERE thread_id=".intval($thread_id);
|
||||
return $sql->db_Update('forum_t', $newString);
|
||||
}
|
||||
|
||||
function forumGetThreads($forumId, $from, $view)
|
||||
{
|
||||
$e107 = e107::getInstance();
|
||||
@@ -921,202 +927,13 @@ class e107forum
|
||||
return false;
|
||||
}
|
||||
|
||||
function thread_getprev($thread_id, $forum_id, $from = 0, $limit = 100)
|
||||
{
|
||||
global $sql;
|
||||
$forum_id = intval($forum_id);
|
||||
global $sql;
|
||||
$ftab = MPREFIX.'forum_t';
|
||||
while (!$found)
|
||||
{
|
||||
$qry = "
|
||||
SELECT t.thread_id from #forum_t AS t
|
||||
WHERE t.thread_forum_id = $forum_id
|
||||
AND t.thread_parent = 0
|
||||
ORDER BY
|
||||
t.thread_sticky DESC,
|
||||
t.thread_lastpost DESC,
|
||||
t.thread_datestamp DESC
|
||||
LIMIT ".intval($from).",".intval($limit);
|
||||
if ($sql->db_Select_gen($qry))
|
||||
{
|
||||
$i = 0;
|
||||
while ($row = $sql->db_Fetch(MYSQL_ASSOC))
|
||||
{
|
||||
$threadList[$i++] = $row['thread_id'];
|
||||
}
|
||||
|
||||
if (($id = array_search($thread_id, $threadList)) !== FALSE)
|
||||
{
|
||||
if ($id != 0)
|
||||
{
|
||||
return $threadList[$id-1];
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($from == 0)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
return $this->thread_getprev($thread_id, $forum_id, $from-1, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
$from += 100;
|
||||
}
|
||||
}
|
||||
|
||||
function thread_get($thread_id, $start = 0, $limit = 10)
|
||||
{
|
||||
$thread_id = intval($thread_id);
|
||||
global $sql;
|
||||
$ftab = MPREFIX.'forum_t';
|
||||
$utab = MPREFIX.'user';
|
||||
|
||||
if ($start === "last")
|
||||
{
|
||||
$tcount = $this->thread_count($thread_id);
|
||||
$start = max(0, $tcount-$limit);
|
||||
}
|
||||
$start = max(0, $start);
|
||||
if ($start != 0)
|
||||
{
|
||||
$array_start = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$limit--;
|
||||
$array_start = 1;
|
||||
}
|
||||
$sortdir = "ASC";
|
||||
|
||||
$qry = "
|
||||
SELECT t.*, u.*, ue.* FROM #forum_t as t
|
||||
LEFT JOIN #user AS u
|
||||
ON SUBSTRING_INDEX(t.thread_user,'.',1) = u.user_id
|
||||
LEFT JOIN #user_extended AS ue
|
||||
ON SUBSTRING_INDEX(t.thread_user,'.',1) = ue.user_extended_id
|
||||
WHERE t.thread_parent = $thread_id
|
||||
ORDER by t.thread_datestamp {$sortdir}
|
||||
LIMIT ".intval($start).",".intval($limit);
|
||||
$ret = array();
|
||||
if ($sql->db_Select_gen($qry))
|
||||
{
|
||||
$i = $array_start;
|
||||
while ($row = $sql->db_Fetch(MYSQL_ASSOC))
|
||||
{
|
||||
$ret[$i] = $row;
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
$qry = "
|
||||
SELECT t.*,u.*,ue.* from #forum_t AS t
|
||||
LEFT JOIN #user AS u
|
||||
ON SUBSTRING_INDEX(t.thread_user,'.',1) = u.user_id
|
||||
LEFT JOIN #user_extended AS ue
|
||||
ON SUBSTRING_INDEX(t.thread_user,'.',1) = ue.user_extended_id
|
||||
WHERE t.thread_id = $thread_id
|
||||
LIMIT 0,1
|
||||
";
|
||||
if ($sql->db_Select_gen($qry))
|
||||
{
|
||||
$row = $sql->db_Fetch(MYSQL_ASSOC);
|
||||
$ret['head'] = $row;
|
||||
if (!array_key_exists(0, $ret))
|
||||
{
|
||||
$ret[0] = $row;
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function thread_count($thread_id)
|
||||
{
|
||||
$thread_id = intval($thread_id);
|
||||
global $sql;
|
||||
return $sql->db_Count('forum_t', '(*)', "WHERE thread_parent = $thread_id")+1;
|
||||
}
|
||||
|
||||
function thread_count_list($thread_list)
|
||||
{
|
||||
global $sql, $tp;
|
||||
$qry = "
|
||||
SELECT t.thread_parent, t.COUNT(*) as thread_replies
|
||||
FROM #forum_t AS t
|
||||
WHERE t.thread_parent
|
||||
IN ".$tp -> toDB($thread_list, true)."
|
||||
GROUP BY t.thread_parent
|
||||
";
|
||||
if ($sql->db_Select_gen($qry))
|
||||
{
|
||||
while ($row = $sql->db_Fetch(MYSQL_ASSOC))
|
||||
{
|
||||
$ret[$row['thread_parent']] = $row['thread_replies'];
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function threadIncView($id)
|
||||
{
|
||||
$e107 = e107::getInstance();
|
||||
$id = (int)($id);
|
||||
$id = (int)$id;
|
||||
return $e107->sql->db_Update('forum_thread', 'thread_views=thread_views+1 WHERE thread_id='.$id);
|
||||
}
|
||||
|
||||
|
||||
function thread_get_postinfo($thread_id, $head = FALSE)
|
||||
{
|
||||
$thread_id = intval($thread_id);
|
||||
global $sql;
|
||||
$ret = array();
|
||||
$qry = "
|
||||
SELECT t.*, u.user_name, u.user_id, u.user_email from #forum_t AS t
|
||||
LEFT JOIN #user AS u
|
||||
ON SUBSTRING_INDEX(t.thread_user,'.',1) = u.user_id
|
||||
WHERE t.thread_id = $thread_id
|
||||
LIMIT 0,1
|
||||
";
|
||||
if ($sql->db_Select_gen($qry))
|
||||
{
|
||||
$ret[0] = $sql->db_Fetch(MYSQL_ASSOC);
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
if ($head == FALSE)
|
||||
{
|
||||
return $ret;
|
||||
}
|
||||
$parent_id = $ret[0]['thread_parent'];
|
||||
if ($parent_id == 0)
|
||||
{
|
||||
$ret['head'] = $ret[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
$qry = "
|
||||
SELECT t.*, u.user_name, u.user_id from #forum_t AS t
|
||||
LEFT JOIN #user AS u
|
||||
ON SUBSTRING_INDEX(t.thread_user,'.',1) = u.user_id
|
||||
WHERE t.thread_id = ".intval($parent_id)."
|
||||
LIMIT 0,1
|
||||
";
|
||||
if ($sql->db_Select_gen($qry))
|
||||
{
|
||||
$row = $sql->db_Fetch(MYSQL_ASSOC);
|
||||
$ret['head'] = $row;
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
function _forum_lp_update($lp_type, $lp_user, $lp_info, $lp_forum_id, $lp_forum_sub)
|
||||
{
|
||||
global $sql;
|
||||
@@ -1127,98 +944,6 @@ class e107forum
|
||||
}
|
||||
}
|
||||
|
||||
function thread_insert($thread_name, $thread_thread, $thread_forum_id, $thread_parent, $thread_poster, $thread_active, $thread_sticky, $forum_sub)
|
||||
{
|
||||
$post_time = time();
|
||||
global $sql, $tp, $pref, $e107;
|
||||
$forum_sub = intval($forum_sub);
|
||||
$ip = $e107->getip();
|
||||
//Check for duplicate post
|
||||
if ($sql->db_Count('forum_t', '(*)', "WHERE thread_thread='{$thread_thread}' and thread_datestamp > ".($post_time - 180)))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
$post_user = $thread_poster['post_userid'].".".$thread_poster['post_user_name'];
|
||||
$thread_post_user = $post_user;
|
||||
if($thread_poster['post_userid'] == 0)
|
||||
{
|
||||
$thread_post_user = $post_user.chr(1).$ip;
|
||||
}
|
||||
|
||||
$post_last_user = ($thread_parent ? "" : $post_user);
|
||||
$vals = "'0', '{$thread_name}', '{$thread_thread}', '".intval($thread_forum_id)."', '".intval($post_time)."', '".intval($thread_parent)."', '{$thread_post_user}', '0', '".intval($thread_active)."', '$post_time', '$thread_sticky', '0', '{$post_last_user}', '0'";
|
||||
$newthread_id = $sql->db_Insert('forum_t', $vals);
|
||||
if(!$newthread_id)
|
||||
{
|
||||
echo "thread creation failed! <br />
|
||||
Values sent were: ".htmlentities($vals)."<br /><br />Please save these values for dev team for troubleshooting.";
|
||||
exit;
|
||||
}
|
||||
|
||||
// Increment user thread count and set user as viewed this thread
|
||||
if (USER)
|
||||
{
|
||||
$new_userviewed = USERVIEWED.".".($thread_parent ? intval($thread_parent) : $newthread_id);
|
||||
$sql->db_Update('user', "user_forums=user_forums+1, user_viewed='{$new_userviewed}' WHERE user_id='".USERID."' ");
|
||||
}
|
||||
|
||||
//If post is a reply
|
||||
if ($thread_parent)
|
||||
{
|
||||
$forum_lp_info = $post_time.".".intval($thread_parent);
|
||||
$gen = new convert;
|
||||
// Update main forum with last post info and increment reply count
|
||||
$this->_forum_lp_update("forum_replies", $post_user, $forum_lp_info, $thread_forum_id, $forum_sub);
|
||||
|
||||
// Update head post with last post info and increment reply count
|
||||
$sql->db_Update('forum_t', "thread_lastpost={$post_time}, thread_lastuser='{$post_user}', thread_total_replies=thread_total_replies+1 WHERE thread_id = ".intval($thread_parent));
|
||||
|
||||
$parent_thread = $this->thread_get_postinfo($thread_parent);
|
||||
global $PLUGINS_DIRECTORY;
|
||||
$thread_name = $tp->toText($parent_thread[0]['thread_name']);
|
||||
$datestamp = $gen->convert_date($post_time, "long");
|
||||
$email_post = $tp->toHTML($thread_thread, TRUE);
|
||||
$mail_link = "<a href='".SITEURL.$PLUGINS_DIRECTORY."forum/forum_viewtopic.php?".$thread_parent.".last'>".SITEURL.$PLUGINS_DIRECTORY."forum/forum_viewtopic.php?".$thread_parent.".last</a>";
|
||||
if(!isset($pref['forum_eprefix']))
|
||||
{
|
||||
$pref['forum_eprefix'] = "[forum]";
|
||||
}
|
||||
// Send email to originator if 'notify' set
|
||||
$email_addy = '';
|
||||
if ($pref['email_notify'] && $parent_thread[0]['thread_active'] == 99 && $parent_thread[0]['user_id'] != USERID)
|
||||
{
|
||||
$gen = new convert;
|
||||
$email_name = $parent_thread[0]['user_name'];
|
||||
$email_addy = $parent_thread[0]['user_email'];
|
||||
$message = LAN_384.SITENAME.".<br /><br />". LAN_382.$datestamp."<br />". LAN_94.": ".$thread_poster['post_user_name']."<br /><br />". LAN_385.$email_post."<br /><br />". LAN_383."<br /><br />".$mail_link;
|
||||
include_once(e_HANDLER."mail.php");
|
||||
sendemail($email_addy, $pref['forum_eprefix']." '".$thread_name."', ".LAN_381.SITENAME, $message, $email_name);
|
||||
}
|
||||
|
||||
|
||||
// Send email to all users tracking thread - except the one that's just posted
|
||||
if ($pref['forum_track'] && $sql->db_Select("user", "user_id, user_email, user_name", "user_realm REGEXP('-".intval($thread_parent)."-') "))
|
||||
{
|
||||
include_once(e_HANDLER.'mail.php');
|
||||
$message = LAN_385.SITENAME.".<br /><br />". LAN_382.$datestamp."<br />". LAN_94.": ".$thread_poster['post_user_name']."<br /><br />". LAN_385.$email_post."<br /><br />". LAN_383."<br /><br />".$mail_link;
|
||||
while ($row = $sql->db_Fetch(MYSQL_ASSOC))
|
||||
{ // Don't sent to self, nor to originator of thread if they've got 'notify' set
|
||||
if ($row['user_email'] && ($row['user_email'] != $email_addy) && ($row['user_id'] != USERID)) // (May be wrong, but this could be faster than filtering current user in the query)
|
||||
{
|
||||
sendemail($row['user_email'], $pref['forum_eprefix']." '".$thread_name."', ".LAN_381.SITENAME, $message, $row['user_name']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//post is a new thread
|
||||
$forum_lp_info = $post_time.".".$newthread_id;
|
||||
$this->_forum_lp_update("forum_threads", $post_user, $forum_lp_info, $thread_forum_id, $forum_sub);
|
||||
}
|
||||
return $newthread_id;
|
||||
}
|
||||
|
||||
function post_getnew($count = 50, $userviewed = USERVIEWED)
|
||||
{
|
||||
|
@@ -11,20 +11,27 @@
|
||||
| GNU General Public License (http://gnu.org).
|
||||
|
|
||||
| $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum_conf.php,v $
|
||||
| $Revision: 1.3 $
|
||||
| $Date: 2007-09-26 19:28:47 $
|
||||
| $Author: e107steved $
|
||||
| $Revision: 1.4 $
|
||||
| $Date: 2008-12-17 04:22:37 $
|
||||
| $Author: mcfly_e107 $
|
||||
+---------------------------------------------------------------+
|
||||
*/
|
||||
require_once("../../class2.php");
|
||||
@include_once e_PLUGIN.'forum/languages/'.e_LANGUAGE.'/lan_forum_conf.php';
|
||||
@include_once e_PLUGIN.'forum/languages/English/lan_forum_conf.php';
|
||||
require_once('../../class2.php');
|
||||
require_once(e_PLUGIN.'forum/forum_class.php');
|
||||
$forum = new e107forum;
|
||||
|
||||
include_lan(e_PLUGIN.'forum/languages/English/lan_forum_conf.php');
|
||||
|
||||
$e_sub_cat = 'forum';
|
||||
|
||||
$qs = explode(".", e_QUERY);
|
||||
$action = $qs[0];
|
||||
$thread_id = intval($qs[1]);
|
||||
if(!USER || !isset($_GET['f']) || !isset($_GET['id']))
|
||||
{
|
||||
header('location:'.$e107->url->getUrl('core:core', 'main', 'action=index'));
|
||||
exit;
|
||||
}
|
||||
|
||||
$id = (int)$_GET['id'];
|
||||
$action = $_GET['f'];
|
||||
|
||||
$qry = "
|
||||
SELECT t.*, f.*, fp.forum_id AS forum_parent_id FROM #forum_t as t
|
||||
@@ -33,18 +40,16 @@ LEFT JOIN #forum AS fp ON fp.forum_id = f.forum_parent
|
||||
WHERE t.thread_id = {$thread_id}
|
||||
";
|
||||
|
||||
if($sql->db_Select_gen($qry))
|
||||
$threadInfo = $forum->threadGet($id);
|
||||
$modList = $forum->forumGetMods($threadInfo->forum_moderators);
|
||||
|
||||
//var_dump($threadInfo);
|
||||
//var_dump($modList);
|
||||
|
||||
//If user is not a moderator of indicated forum, redirect to index page
|
||||
if(!in_array(USERID, array_keys($modList)))
|
||||
{
|
||||
$info=$sql->db_Fetch();
|
||||
if(!check_class($info['forum_moderators']))
|
||||
{
|
||||
header("location:".e_BASE."index.php");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
header("location:".e_BASE."index.php");
|
||||
header('location:'.$e107->url->getUrl('core:core', 'main', 'action=index'));
|
||||
exit;
|
||||
}
|
||||
|
||||
@@ -127,10 +132,11 @@ if ($action == "delete_poll")
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($action == "move")
|
||||
if ($action == 'move')
|
||||
{
|
||||
$postInfo = $forum->postGet($id, 0, 1);
|
||||
$text = "
|
||||
<form method='post' action='".e_SELF."?".e_QUERY."'>
|
||||
<form method='post' action='".e_SELF.'?'.e_QUERY."'>
|
||||
<div style='text-align:center'>
|
||||
<table style='".ADMIN_WIDTH."'>
|
||||
<tr>
|
||||
@@ -139,29 +145,26 @@ if ($action == "move")
|
||||
<select name='forum_move' class='tbox'>";
|
||||
$qry = "
|
||||
SELECT f.forum_id, f.forum_name, fp.forum_name AS forum_parent, sp.forum_name AS sub_parent
|
||||
FROM #forum AS f
|
||||
LEFT JOIN #forum AS fp ON f.forum_parent = fp.forum_id
|
||||
LEFT JOIN #forum AS sp ON f.forum_sub = sp.forum_id
|
||||
FROM `#forum` AS f
|
||||
LEFT JOIN `#forum` AS fp ON f.forum_parent = fp.forum_id
|
||||
LEFT JOIN `#forum` AS sp ON f.forum_sub = sp.forum_id
|
||||
WHERE f.forum_parent != 0
|
||||
AND f.forum_id != ".intval($info['forum_id'])."
|
||||
AND f.forum_class IN (".USERCLASS_LIST.")
|
||||
AND fp.forum_class IN (".USERCLASS_LIST.")
|
||||
AND f.forum_id != ".(int)$threadInfo['thread_forum_id']."
|
||||
ORDER BY f.forum_parent ASC, f.forum_sub, f.forum_order ASC
|
||||
";
|
||||
$sql->db_Select_gen($qry);
|
||||
$fList = $sql->db_getList();
|
||||
$e107->sql->db_Select_gen($qry);
|
||||
$fList = $e107->sql->db_getList();
|
||||
|
||||
foreach($fList as $f)
|
||||
{
|
||||
if($f['forum_sub'] > 0)
|
||||
if(substr($f['forum_name'], 0, 1) != '*')
|
||||
{
|
||||
$f['forum_name'] = "subforum -> ".$f['forum_name'];
|
||||
$f['sub_parent'] = ltrim($f['sub_parent'], '*');
|
||||
$for_name = $f['forum_parent'].' -> ';
|
||||
$for_name .= ($f['sub_parent'] ? $f['sub_parent'].' -> ' : '');
|
||||
$for_name .= $f['forum_name'];
|
||||
$text .= "<option value='{$f['forum_id']}'>".$for_name."</option>";
|
||||
}
|
||||
$for_name = $f['forum_parent']." -> ";
|
||||
$for_name .= ($f['sub_parent'] ? $f['sub_parent']." -> " : "");
|
||||
$for_name .= $f['forum_name'];
|
||||
|
||||
$text .= "<option value='{$f['forum_id']}'>".$for_name."</option>";
|
||||
}
|
||||
$text .= "</select>
|
||||
</td>
|
||||
@@ -170,7 +173,7 @@ if ($action == "move")
|
||||
<td colspan='2'><br />
|
||||
<b>".FORLAN_32."</b><br />
|
||||
<input type='radio' name='rename_thread' checked='checked' value='none' /> ".FORLAN_28."<br />
|
||||
<input type='radio' name='rename_thread' value='add' /> ".FORLAN_29." [".FORLAN_27."] ".FORLAN_30."<br />
|
||||
<input type='radio' name='rename_thread' value='add' /> ".FORLAN_29.' ['.FORLAN_27.'] '.FORLAN_30."<br />
|
||||
<input type='radio' name='rename_thread' value='rename' /> ".FORLAN_31." <input type='text' class='tbox' name='newtitle' size='60' maxlength='250' value='".$tp->toForm($info['thread_name'])."'/>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -183,8 +186,8 @@ if ($action == "move")
|
||||
</table>
|
||||
</div>
|
||||
</form><br />";
|
||||
$text = $ns->tablerender($tp->toHTML($info['thread_name']), $tp->toHTML($info['thread_thread']), '', TRUE).$ns->tablerender("", $text, '', true);
|
||||
$ns->tablerender(FORLAN_25, $text);
|
||||
$text = $e107->ns->tablerender($e107->tp->toHTML($threadInfo['thread_name']), $e107->tp->toHTML($postInfo[0]['post_entry']), '', true).$ns->tablerender('', $text, '', true);
|
||||
$e107->ns->tablerender(FORLAN_25, $text);
|
||||
|
||||
}
|
||||
require_once(FOOTERF);
|
||||
|
@@ -244,12 +244,7 @@ SC_BEGIN REPORTIMG
|
||||
global $postInfo, $page;
|
||||
if (USER) {
|
||||
$e107 = e107::getInstance();
|
||||
$tmp = array (
|
||||
'func' => 'report',
|
||||
'id' => $postInfo['post_thread'],
|
||||
'report' => $postInfo['post_id']
|
||||
);
|
||||
return "<a href='".$e107->url->getUrl('forum', 'thread', $tmp)."'>".IMAGE_report.'</a> ';
|
||||
return "<a href='".$e107->url->getUrl('forum', 'thread', 'func=report&id='.$postInfo['post_thread'])."'>".IMAGE_report.'</a> ';
|
||||
}
|
||||
SC_END
|
||||
|
||||
|
@@ -9,8 +9,8 @@
|
||||
* View specific forums
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum_viewforum.php,v $
|
||||
* $Revision: 1.10 $
|
||||
* $Date: 2008-12-15 00:29:20 $
|
||||
* $Revision: 1.11 $
|
||||
* $Date: 2008-12-17 04:22:37 $
|
||||
* $Author: mcfly_e107 $
|
||||
*
|
||||
*/
|
||||
@@ -57,6 +57,8 @@ if (!$forum->checkPerm($forumId, 'view'))
|
||||
}
|
||||
|
||||
$forumInfo = $forum->forum_get($forumId);
|
||||
$threadsViewed = $forum->threadGetUserViewed();
|
||||
|
||||
|
||||
//var_dump($forumInfo);
|
||||
|
||||
@@ -84,7 +86,7 @@ define('e_PAGETITLE', LAN_01.' / '.$_forum_name);
|
||||
//define('MODERATOR', $forum_info['forum_moderators'] != '' && check_class($forum_info['forum_moderators']));
|
||||
//$modArray = $forum->forum_getmods($forum_info['forum_moderators']);
|
||||
|
||||
$modArray = $forum->forum_getmods($thread->forum_info['forum_moderators']);
|
||||
$modArray = $forum->forumGetMods($thread->forum_info['forum_moderators']);
|
||||
define('MODERATOR', (USER && is_array($modArray) && in_array(USERID, array_keys($modArray))));
|
||||
|
||||
$message = '';
|
||||
@@ -217,7 +219,7 @@ $gen = new convert;
|
||||
$SUBFORUMS = '';
|
||||
if(is_array($subList) && isset($subList[$forumInfo['forum_parent']][$forumId]))
|
||||
{
|
||||
$newflag_list = $forum->forum_newflag_list();
|
||||
$newflag_list = $forum->forumGetUnreadForums();
|
||||
$sub_info = '';
|
||||
foreach($subList[$forumInfo['forum_parent']][$forumId] as $sub)
|
||||
{
|
||||
@@ -313,7 +315,7 @@ require_once(FOOTERF);
|
||||
|
||||
function parse_thread($thread_info)
|
||||
{
|
||||
global $forum, $FORUM_VIEW_FORUM, $FORUM_VIEW_FORUM_STICKY, $FORUM_VIEW_FORUM_ANNOUNCE, $gen, $pref, $forum_id, $menu_pref;
|
||||
global $forum, $FORUM_VIEW_FORUM, $FORUM_VIEW_FORUM_STICKY, $FORUM_VIEW_FORUM_ANNOUNCE, $gen, $pref, $menu_pref, $threadsViewed;
|
||||
$e107 = e107::getInstance();
|
||||
$text = '';
|
||||
|
||||
@@ -345,14 +347,7 @@ function parse_thread($thread_info)
|
||||
$LASTPOST .= '<br />'.$lastpost_datestamp;
|
||||
}
|
||||
|
||||
$newflag = false;
|
||||
if (USER)
|
||||
{
|
||||
if ($thread_info['thread_lastpost'] > USERLV && !$forum->threadViewed($thread_info['thread_id']))
|
||||
{
|
||||
$newflag = true;
|
||||
}
|
||||
}
|
||||
$newflag = (USER && $thread_info['thread_lastpost'] > USERLV && !in_array($thread_info['thread_id'], $threadsViewed));
|
||||
|
||||
$THREADDATE = $gen->convert_date($thread_info['thread_datestamp'], 'forum');
|
||||
$ICON = ($newflag ? IMAGE_new : IMAGE_nonew);
|
||||
@@ -501,7 +496,8 @@ 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='".e_SELF."?mfar.{$subInfo['forum_id']}'>".IMAGE_new."</a>";
|
||||
|
||||
$NEWFLAG = "<a href='".$e107->url->getUrl('forum','forum', 'func=mfar&id='.$subInfo['forum_id'])."'>".IMAGE_new.'</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -12,8 +12,8 @@
|
||||
| GNU General Public License (http://gnu.org).
|
||||
|
|
||||
| $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum_viewtopic.php,v $
|
||||
| $Revision: 1.16 $
|
||||
| $Date: 2008-12-15 00:29:20 $
|
||||
| $Revision: 1.17 $
|
||||
| $Date: 2008-12-17 04:22:37 $
|
||||
| $Author: mcfly_e107 $
|
||||
+----------------------------------------------------------------------------+
|
||||
*/
|
||||
@@ -74,7 +74,7 @@ if (USER && (USERID != $threadInfo['thread_user'] || $threadInfo['thread_total_r
|
||||
}
|
||||
|
||||
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'));
|
||||
$modArray = $forum->forum_getmods($thread->threadInfo['forum_moderators']);
|
||||
$modArray = $forum->forumGetMods($thread->threadInfo['forum_moderators']);
|
||||
define('MODERATOR', (USER && is_array($modArray) && in_array(USERID, array_keys($modArray))));
|
||||
|
||||
if (MODERATOR && isset($_POST['mod']))
|
||||
@@ -86,7 +86,6 @@ if (MODERATOR && isset($_POST['mod']))
|
||||
|
||||
$postList = $forum->PostGet($thread->threadId, $thread->page * $thread->perPage, $thread->perPage);
|
||||
|
||||
//var_dump($thread->threadInfo);
|
||||
require_once (e_HANDLER . 'level_handler.php');
|
||||
$gen = new convert;
|
||||
if ($thread->message)
|
||||
@@ -144,7 +143,6 @@ if ($pref['forum_track'] && USER)
|
||||
</span>
|
||||
<script type='text/javascript'>
|
||||
e107.runOnLoad(function(){
|
||||
//put this in header_js or as inline script just after the markup above
|
||||
$('forum-track-trigger').observe('click', function(e) {
|
||||
e.stop();
|
||||
new e107Ajax.Updater('forum-track-trigger-container', '{$url}', {
|
||||
@@ -164,10 +162,6 @@ $MODERATORS = LAN_321 . implode(', ', $modArray);
|
||||
|
||||
$THREADSTATUS = (!$thread->threadInfo['thread_active'] ? LAN_66 : '');
|
||||
|
||||
//$pages = ceil(($threadInfo['thread_total_replies'] + 1) / $perPage);
|
||||
|
||||
//echo "pages = {$thread->pages}<br />";
|
||||
//var_dump($thread);
|
||||
if ($thread->pages > 1)
|
||||
{
|
||||
$parms = ($thread->pages).",1,{$thread->page},url::forum::thread::func=view&id={$thread->threadId}&page=[FROM],off";
|
||||
@@ -257,7 +251,6 @@ if ($forum->checkPerm($thread->threadInfo['thread_forum_id'], 'post') && $thread
|
||||
$forend = preg_replace("/\{(.*?)\}/e", '$\1', $FORUMEND);
|
||||
$forumstring = $forstr . $forthr . $forrep . $forend;
|
||||
|
||||
require_once (HEADERF);
|
||||
//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))
|
||||
@@ -265,6 +258,8 @@ if ($thread->threadInfo['thread_lastpost'] > USERLV && !in_array($thread->thread
|
||||
$tst = $forum->threadMarkAsRead($thread->threadId);
|
||||
}
|
||||
|
||||
require_once (HEADERF);
|
||||
|
||||
if ($pref['forum_enclose'])
|
||||
{
|
||||
$ns->tablerender(LAN_01, $forumstring, array('forum_viewtopic', 'main'));
|
||||
@@ -274,7 +269,6 @@ else
|
||||
echo $forumstring;
|
||||
}
|
||||
|
||||
|
||||
// end -------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
echo "<script type=\"text/javascript\">
|
||||
@@ -292,9 +286,6 @@ function showmodoptions()
|
||||
{
|
||||
global $thread, $postInfo;
|
||||
|
||||
// var_dump($thread);
|
||||
// var_dump($postInfo);
|
||||
|
||||
$e107 = e107::getInstance();
|
||||
$forum_id = $thread->threadInfo['forum_id'];
|
||||
if ($postInfo['thread_start'])
|
||||
@@ -333,7 +324,6 @@ function showmodoptions()
|
||||
|
||||
function forumjump()
|
||||
{
|
||||
|
||||
global $forum;
|
||||
$jumpList = $forum->forum_get_allowed();
|
||||
$text = "<form method='post' action='" . e_SELF . "'><p>" . LAN_65 . ": <select name='forumjump' class='tbox'>";
|
||||
@@ -526,10 +516,7 @@ class e107ForumThread
|
||||
break;
|
||||
|
||||
case 'last':
|
||||
// $pref['forum_postspage'] = ($pref['forum_postspage'] ? $pref['forum_postspage'] : 10);
|
||||
// var_dump($thread);
|
||||
$pages = ceil(($thread->threadInfo['thread_total_replies'] + 1) / $thread->perPage);
|
||||
// echo "pages = $pages<br />";
|
||||
$thread->page = ($pages - 1);
|
||||
break;
|
||||
|
||||
@@ -541,10 +528,7 @@ class e107ForumThread
|
||||
header("location: {$url}");
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->message = LAN_405;
|
||||
}
|
||||
$this->message = LAN_405;
|
||||
break;
|
||||
|
||||
case 'prev':
|
||||
@@ -555,40 +539,41 @@ class e107ForumThread
|
||||
header("location: {$url}");
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->message = LAN_404;
|
||||
}
|
||||
$this->message = LAN_404;
|
||||
break;
|
||||
|
||||
case 'report':
|
||||
$thread_info = $forum->thread_get_postinfo($thread_id, true);
|
||||
$postId = (int)$_GET['id'];
|
||||
$postInfo = $forum->postGet($postId, 'post');
|
||||
|
||||
if (isset($_POST['report_thread']))
|
||||
{
|
||||
$report_add = $tp->toDB($_POST['report_add']);
|
||||
$report_add = $e107->tp->toDB($_POST['report_add']);
|
||||
if ($pref['reported_post_email'])
|
||||
{
|
||||
require_once (e_HANDLER . "mail.php");
|
||||
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);
|
||||
}
|
||||
$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);
|
||||
$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";
|
||||
$ns->tablerender(LAN_414, $text, array('forum_viewtopic', 'report'));
|
||||
$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 = $tp->toHTML($thread_info['head']['thread_name'], true, 'no_hook, emotes_off');
|
||||
define("e_PAGETITLE", LAN_01 . " / " . LAN_426 . " " . $thread_name);
|
||||
$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);
|
||||
$text = "<form action='" . e_PLUGIN . "forum/forum_viewtopic.php?" . e_QUERY . "' method='post'> <table style='width:100%'>
|
||||
$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='" . e_PLUGIN . "forum/forum_viewtopic.php?" . $thread_id . ".post'><span class='smalltext'>" . LAN_420 . " </span>
|
||||
" . LAN_415 . ': ' . $thread_name . " <a href='".$url."'><span class='smalltext'>" . LAN_420 . " </span>
|
||||
</a>
|
||||
</td>
|
||||
<td style='text-align:center;width:50%'>
|
||||
@@ -607,7 +592,7 @@ class e107ForumThread
|
||||
</td>
|
||||
</tr>
|
||||
</table>";
|
||||
$ns->tablerender(LAN_414, $text, array('forum_viewtopic', 'report2'));
|
||||
$e107->ns->tablerender(LAN_414, $text, array('forum_viewtopic', 'report2'));
|
||||
}
|
||||
require_once (FOOTERF);
|
||||
exit;
|
||||
|
Reference in New Issue
Block a user