1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-30 19:30:25 +02:00

Some moderator functions now working, last post info and user post count should be accurate. Other fixes.

This commit is contained in:
mcfly
2008-12-09 21:46:14 +00:00
parent ceaae186e6
commit 3cf2171b31
7 changed files with 175 additions and 167 deletions

View File

@@ -1,11 +1,11 @@
<?php
// $Id: forum.php,v 1.1 2008-12-02 00:33:29 secretr Exp $
// $Id: forum.php,v 1.2 2008-12-09 21:46:14 mcfly_e107 Exp $
function url_forum_forum($parms)
{
switch($parms['func'])
{
case 'view':
return e_PLUGIN_ABS."forum/viewforum.php?id={$parms['id']}";
return e_PLUGIN_ABS."forum/forum_viewforum.php?id={$parms['id']}";
break;
case 'track':

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.8 $
| $Date: 2008-12-05 01:30:56 $
| $Revision: 1.9 $
| $Date: 2008-12-09 21:46:14 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
@@ -299,14 +299,16 @@ function parse_forum($f, $restricted_string = "")
$NEWFLAG = IMAGE_nonew;
}
if(substr($f['forum_name'], 0, 1) == "*")
if(substr($f['forum_name'], 0, 1) == '*')
{
$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");
$f['forum_name'] = $tp -> toHTML($f['forum_name'], TRUE, 'no_hook');
$f['forum_description'] = $tp -> toHTML($f['forum_description'], TRUE, 'no_hook');
$FORUMNAME = "<a href='".e_PLUGIN."forum/viewforum.php?id={$f['forum_id']}'>{$f['forum_name']}</a>";
// $e107->url->getUrl('forum', 'thread', array('func' => 'track')))
$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'];
@@ -365,7 +367,7 @@ function parse_subs($subList, $lastpost_datestamp)
foreach($subList as $sub)
{
$ret['text'] .= ($ret['text'] ? ", " : "");
$suburl = $e107->url->getUrl('forum', 'forum', array('func' => 'view', 'id' => $sub['forum_id']));
$suburl = $e107->url->getUrl('forum', 'forum', array('func' => 'view', 'id' => $sub['forum_id']));
$ret['text'] .= "<a href='{$suburl}'>".$e107->tp->toHTML($sub['forum_name']).'</a>';
$ret['threads'] += $sub['forum_threads'];
$ret['replies'] += $sub['forum_replies'];
@@ -389,7 +391,12 @@ if (e_QUERY == 'track')
// $sql2 = new db;
// $tmp = explode("-", USERREALM);
$qry = "SELECT * from `#forum_thread` WHERE thread_id IN({$trackedThreadList}) ORDER BY thread_lastpost DESC";
$qry = "
SELECT t.*, p.* from `#forum_thread` AS t
LEFT JOIN `#forum_post` AS p ON p.post_thread = t.thread_id AND p.post_datestamp = t.thread_datestamp
WHERE thread_id IN({$trackedThreadList})
ORDER BY thread_lastpost DESC
";
if($e107->sql->db_Select_gen($qry))
{
while($row = $e107->sql->db_Fetch(MYSQL_ASSOC))

View File

@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum_class.php,v $
| $Revision: 1.20 $
| $Date: 2008-12-07 04:16:38 $
| $Revision: 1.21 $
| $Date: 2008-12-09 21:46:14 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
@@ -186,13 +186,13 @@ class e107forum
$threadInfo['_FIELD_TYPES'] = $this->fieldTypes['forum_thread'];
$threadInfo['_FIELD_TYPES']['thread_total_replies'] = 'cmd';
// print_a($threadInfo);
// var_dump($threadInfo);
// exit;
$result = $e107->sql->db_Update('forum_thread', $threadInfo);
}
if($result && $updateForum)
if(($result || !$updateThread) && $updateForum)
{
if(varset($postInfo['post_user']))
{
@@ -232,7 +232,6 @@ class e107forum
$result = $e107->sql->db_Select_gen($qry);
}
return $postId;
}
function threadAdd($threadInfo, $postInfo)
@@ -322,6 +321,29 @@ class e107forum
return $ret;
}
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))
{
$ret = array();
while($row = $e107->sql->db_Fetch(MYSQL_ASSOC))
{
$ret[$row['post_user']] = $row['post_count'];
}
}
return $ret;
}
function thread_postnum($thread_id)
{
global $sql;
@@ -343,7 +365,7 @@ class e107forum
return $ret;
}
function update_lastpost($type, $id, $update_threads = FALSE)
function forumUpdateLastpost($type, $id, $update_threads = FALSE)
{
global $sql, $tp;
$sql2 = new db;
@@ -385,10 +407,10 @@ class e107forum
}
else
{
$id = intval($id);
$forum_lp_user = '';
$forum_lp_info = '';
if($update_threads == TRUE)
$id = (int)$id;
$lp_info = '';
$lp_user = 'NULL';
if($update_threads == true)
{
if ($sql2->db_Select('forum_t', 'thread_id', "thread_forum_id = $id AND thread_parent = 0"))
{
@@ -398,15 +420,20 @@ class e107forum
}
}
}
if ($sql->db_Select("forum_t", "*", "thread_forum_id={$id} ORDER BY thread_datestamp DESC LIMIT 0,1"))
if ($sql->db_Select('forum_thread', 'thread_id, thread_lastuser, thread_lastuser_anon, thread_datestamp', 'thread_forum_id='.$id.' ORDER BY thread_datestamp DESC LIMIT 1'))
{
$row = $sql->db_Fetch(MYSQL_ASSOC);
$tmp = explode(chr(1), $row['thread_user']);
$forum_lp_user = $tmp[0];
$last_id = $row['thread_parent'] ? $row['thread_parent'] : $row['thread_id'];
$forum_lp_info = $row['thread_datestamp'].".".$last_id;
$lp_info = $row['thread_datestamp'].'.'.$row['thread_id'];
$lp_user = $row['thread_lastuser'];
}
if($row['thread_lastuser_anon'])
{
$sql->db_Update('forum', "forum_lastpost_user = 0, forum_lastpost_anon = '{$row['thread_lastuser_anon']}', forum_lastpost_info = '{$lp_info}' WHERE forum_id=".$id);
}
else
{
$sql->db_Update('forum', "forum_lastpost_user = {$lp_user}, forum_lastpost_user_anon = NULL, forum_lastpost_info = '{$lp_info}' WHERE forum_id=".$id);
}
$sql->db_Update('forum', "forum_lastpost_user = '{$forum_lp_user}', forum_lastpost_info = '{$forum_lp_info}' WHERE forum_id={$id}");
}
}
}

View File

@@ -11,132 +11,96 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum_mod.php,v $
| $Revision: 1.2 $
| $Date: 2007-08-14 21:11:29 $
| $Author: e107steved $
| $Revision: 1.3 $
| $Date: 2008-12-09 21:46:14 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
if (!defined('e107_INIT')) { exit; }
if (!defined('e107_INIT'))
{
exit;
}
include_lan(e_PLUGIN.'forum/languages/English/lan_forum_admin.php');
@include_once e_PLUGIN.'forum/languages/'.e_LANGUAGE.'/lan_forum_admin.php';
@include_once e_PLUGIN.'forum/languages/English/lan_forum_admin.php';
function forum_thread_moderate($p)
{
// var_dump($_POST);
// return;
$e107 = e107::getInstance();
global $sql;
foreach($p as $key => $val) {
foreach ($p as $key => $val)
{
if (preg_match("#(.*?)_(\d+)_x#", $key, $matches))
{
$act = $matches[1];
$id = intval($matches[2]);
switch($act)
$id = (int)$matches[2];
switch ($act)
{
case 'lock' :
$sql->db_Update("forum_t", "thread_active='0' WHERE thread_id='$id' ");
return FORLAN_CLOSE;
break;
case 'unlock' :
$sql->db_Update("forum_t", "thread_active='1' WHERE thread_id='$id' ");
return FORLAN_OPEN;
break;
case 'stick' :
$sql->db_Update("forum_t", "thread_s='1' WHERE thread_id='$id' ");
return FORLAN_STICK;
break;
case 'unstick' :
$sql->db_Update("forum_t", "thread_s='0' WHERE thread_id='$id' ");
return FORLAN_UNSTICK;
break;
case 'delete' :
return forum_delete_thread($id);
break;
case 'lock':
$e107->sql->db_Update('forum_thread', 'thread_active=0 WHERE thread_id='.$id);
return FORLAN_CLOSE;
break;
case 'unlock':
$e107->sql->db_Update('forum_thread', 'thread_active=1 WHERE thread_id='.$id);
return FORLAN_OPEN;
break;
case 'stick':
$e107->sql->db_Update('forum_thread', 'thread_s=1 WHERE thread_id='.$id);
return FORLAN_STICK;
break;
case 'unstick':
$e107->sql->db_Update('forum_thread', 'thread_s=0 WHERE thread_id='.$id);
return FORLAN_UNSTICK;
break;
case 'deleteThread':
return forumDeleteThread($id);
break;
}
}
}
}
function forum_delete_thread($thread_id)
function forumDeleteThread($threadId)
{
global $sql;
@require_once(e_PLUGIN.'forum/forum_class.php');
$f =& new e107forum;
$sql->db_Select("forum_t", "*", "thread_id='".intval($thread_id)."' ");
$row = $sql->db_Fetch();
if ($row['thread_parent'])
require_once (e_PLUGIN.'forum/forum_class.php');
$e107 = e107::getInstance();
$f = &new e107forum;
if ($threadInfo = $f->threadGet($threadId))
{
// post is a reply?
$sql->db_Delete("forum_t", "thread_id='".intval($thread_id)."' ");
// dec forum reply count by 1
$sql->db_Update("forum", "forum_replies=forum_replies-1 WHERE forum_id='".$row['thread_forum_id']."' AND forum_replies>0");
// dec thread reply count by 1
$sql->db_Update("forum_t", "thread_total_replies=thread_total_replies-1 WHERE thread_id='".$row['thread_parent']."' AND thread_total_replies>0");
// dec user forum post count by 1
$tmp = explode(".", $row['thread_user']);
$uid = intval($tmp[0]);
if($uid > 0)
{
$sql->db_Update("user", "user_forums=user_forums-1 WHERE user_id='".$uid."' AND user_forums>0");
}
// update lastpost info
$f->update_lastpost('thread', $row['thread_parent']);
$f->update_lastpost('forum', $row['thread_forum_id']);
return FORLAN_154;
}
else
{
// post is thread
// delete poll if there is one
$sql->db_Delete("poll", "poll_datestamp='".intval($thread_id)."'");
$e107->sql->db_Delete('poll', 'poll_datestamp='.$threadId);
//decrement user post counts
forum_userpost_count("WHERE thread_id = '".intval($thread_id)."' OR thread_parent = '".intval($thread_id)."'", "dec");
// delete replies and grab how many there were
$count = $sql->db_Delete("forum_t", "thread_parent='".intval($thread_id)."'");
// delete the post itself
$sql->db_Delete("forum_t", "thread_id='".intval($thread_id)."'");
// update thread/reply counts
$sql->db_Update("forum", "forum_threads=LEAST(forum_threads-1,0), forum_replies=LEAST(forum_replies-{$count},0) WHERE forum_id='".$row['thread_forum_id']."'");
// update lastpost info
$f->update_lastpost('forum', $row['thread_forum_id']);
return FORLAN_6.($count ? ", ".$count." ".FORLAN_7."." : ".");
}
}
function forum_userpost_count($where = "", $type = "dec")
{
global $sql;
$qry = "
SELECT thread_user, count(thread_user) AS cnt FROM #forum_t
{$where}
GROUP BY thread_user
";
if($sql->db_Select_gen($qry))
{
$uList = $sql->db_getList();
foreach($uList as $u)
if ($postCount = $f->threadGetUserPostcount($threadId))
{
$tmp = explode(".", $u['thread_user']);
$uid = intval($tmp[0]);
if($uid > 0)
foreach ($postCount as $k => $v)
{
if("set" == $type)
{
$sql->db_Update("user", "user_forums={$u['cnt']} WHERE user_id='".$uid."'");
}
else
{ // user_forums is unsigned, so underflow will give a very big number
$sql->db_Update("user", "user_forums=LEAST(user_forums-{$u['cnt']},0) WHERE user_id='".$uid."'");
}
$e107->sql->db_Update('user_extended', 'user_plugin_forum_posts=GREATEST(user_plugin_forum_posts-'.$v.',0) WHERE user_id='.$k);
}
}
// delete all posts
$e107->sql->db_Delete('forum_post', 'post_thread='.$threadId);
// delete the thread itself
$e107->sql->db_Delete('forum_thread', 'thread_id='.$threadId);
//Delete any thread tracking
$e107->sql->db_Delete('forum_track', 'track_thread='.$threadId);
// update forum with correct thread/reply counts
$e107->sql->db_Update('forum', "forum_threads=GREATEST(forum_threads-1,0), forum_replies=GREATEST(forum_replies-{$threadInfo['thread_total_replies']},0) WHERE forum_id=".$threadInfo['thread_forum_id']);
// update lastpost info
$f->forumUpdateLastpost('forum', $threadInfo['thread_forum_id']);
return FORLAN_6.' and '.$threadInfo['thread_total_replies'].' '.FORLAN_7.'.';
}
}
?>

View File

@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum_post.php,v $
| $Revision: 1.26 $
| $Date: 2008-12-08 02:33:34 $
| $Revision: 1.27 $
| $Date: 2008-12-09 21:46:14 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
@@ -113,9 +113,9 @@ if($pref['forum_attach'])
$a_filetypes = get_filetypes();
$max_upload_size = calc_max_upload_size(-1); // Find overriding maximum upload size
$max_upload_size = set_max_size($a_filetypes, $max_upload_size);
$max_upload_size = $e107->parseMemorySize($max_upload_size, 0);
$max_upload_size = $e107->parseMemorySize($max_upload_size, 0);
$a_filetypes = array_keys($a_filetypes);
$allowed_filetypes = implode(' | ', $a_filetypes);
$allowed_filetypes = implode(' | ', $a_filetypes);
}
if (isset($_POST['submitpoll']))
@@ -212,7 +212,7 @@ if (isset($_POST['newthread']) || isset($_POST['reply']))
$threadInfo = array();
$postOptions = array();
$threadOptions = array();
if ((isset($_POST['newthread']) && trim($_POST['subject']) == '') || trim($_POST['post']) == '')
{
message_handler('ALERT', 5);
@@ -272,7 +272,7 @@ if (isset($_POST['newthread']) || isset($_POST['reply']))
// New thread started. Add the thread info (with lastest post info), add the post.
// Update forum with latest post info
case 'nt':
$threadInfo['thread_s'] = (MODERATOR ? $_POST['threadtype'] : 0);
$threadInfo['thread_s'] = (MODERATOR ? (int)$_POST['threadtype'] : 0);
$threadInfo['thread_name'] = $_POST['subject'];
$threadInfo['thread_forum_id'] = $forumId;
$threadInfo['thread_active'] = 1;
@@ -281,21 +281,26 @@ if (isset($_POST['newthread']) || isset($_POST['reply']))
{
$threadOptions['poll'] = '1';
}
$threadInfo['thread_options'] = serialize($threadOptions);
if(is_array($threadOptions) && count($threadOptions))
{
$threadInfo['thread_options'] = serialize($threadOptions);
}
else
{
$threadInfo['thread_options'] = '';
}
if($postResult = $forum->threadAdd($threadInfo, $postInfo))
{
$newPostId = $postResult['postid'];
$newThreadId = $postResult['threadid'];
$newPostId = $postResult['postid'];
$newThreadId = $postResult['threadid'];
if($_POST['email_notify'])
{
$forum->track('add', USERID, $newThreadId);
}
}
break;
}
// $email_notify = ($_POST['email_notify'] ? 99 : 1);
// if ($_POST['poll_title'] != "" && $_POST['poll_option'][0] != "" && $_POST['poll_option'][1] != "")
// {
// $subject = "[".LAN_402."] ".$subject;
// }
// print_a($threadInfo);
// print_a($postInfo);
// exit;
@@ -541,9 +546,9 @@ function forumjump()
function process_upload()
{
global $pref, $forum_info, $thread_info, $admin_log;
$postId = (int)$postId;
$ret = array();
$ret = array();
// var_dump($_FILES);
if (isset($_FILES['file_userfile']['error']))

View File

@@ -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.10 $
| $Date: 2008-12-08 02:33:34 $
| $Revision: 1.11 $
| $Date: 2008-12-09 21:46:14 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
@@ -149,7 +149,7 @@ $NEXTPREV .= "<a href='" . $e107->url->getUrl('forum', 'thread', array('func' =>
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));
$url = $e107->url->getUrl('forum', 'thread', array('func' => 'view', 'id' => $thread->threadId));
$TRACK .= "
<span id='forum-track-trigger-container'>
<a href='{$url}' id='forum-track-trigger'>{$img}</a>
@@ -157,8 +157,8 @@ if ($pref['forum_track'] && USER)
<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();
$('forum-track-trigger').observe('click', function(e) {
e.stop();
new e107Ajax.Updater('forum-track-trigger-container', '{$url}', {
method: 'post',
parameters: { //send query parameters here
@@ -208,6 +208,10 @@ $i = $thread->page;
global $postInfo;
foreach ($postList as $postInfo)
{
if($postInfo['post_options'])
{
$postInfo['post_options'] = unserialize($postInfo['post_options']);
}
$loop_uid = (int)$postInfo['post_user'];
$i++;
@@ -489,7 +493,7 @@ class e107ForumThread
}
if(e_AJAX_REQUEST)
{
$url = $e107->url->getUrl('forum', 'thread', array('func' => 'view', 'id' => $thread->threadId));
$url = $e107->url->getUrl('forum', 'thread', array('func' => 'view', 'id' => $thread->threadId));
echo "<a href='{$url}' id='forum-track-trigger'>{$img}</a>";
exit();
}
@@ -529,10 +533,10 @@ class e107ForumThread
case 'track':
if (!USER || !isset($_GET['id'])) { return; }
$forum->track('add', USERID, $_GET['id']);
if(e_AJAX_REQUEST)
{
$url = $e107->url->getUrl('forum', 'thread', array('func' => 'untrack', 'id' => $thread->threadId));
$url = $e107->url->getUrl('forum', 'thread', array('func' => 'untrack', 'id' => $thread->threadId));
echo "<a href='{$url}' id='forum-track-trigger'>".IMAGE_untrack."</a>";
exit();
}
@@ -543,7 +547,7 @@ class e107ForumThread
$forum->track('del', USERID, $_GET['id']);
if(e_AJAX_REQUEST)
{
$url = $e107->url->getUrl('forum', 'thread', array('func' => 'track', 'id' => $thread->threadId));
$url = $e107->url->getUrl('forum', 'thread', array('func' => 'track', 'id' => $thread->threadId));
echo "<a href='{$url}' id='forum-track-trigger'>".IMAGE_track."</a>";
exit();
}

View File

@@ -4,13 +4,13 @@
| e107 website system - Language File.
|
| $Source: /cvs_backup/e107_0.8/e107_plugins/forum/languages/English/lan_forum_viewforum.php,v $
| $Revision: 1.1.1.1 $
| $Date: 2006-12-02 04:35:18 $
| $Revision: 1.2 $
| $Date: 2008-12-09 21:46:14 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
define("PAGE_NAME", "Forum");
define("LAN_01", "Forums");
define("LAN_02", "Back to top");
define("LAN_03", "Go");
@@ -39,9 +39,9 @@ define("LAN_317", "None");
define("LAN_321", "Moderators: ");
define("LAN_395", "[popular]");
define("LAN_396", "Announcement");
define("LAN_397", "This forum is read only");
define("LAN_398", "Unstick thread");
define("LAN_399", "Lock thread");
define("LAN_400", "Unlock thread");
@@ -49,14 +49,14 @@ define("LAN_401", "Stick thread");
define("LAN_402", "Move thread");
define("LAN_403", "Jump to forum");
define("LAN_404", "This forum is moderated by");
define("LAN_405", "user is browsing this forum at the moment");
define("LAN_406", "users are browsing this forum at the moment");
define("LAN_407", "member");
define("LAN_408", "guest");
define("LAN_409", "members");
define("LAN_410", "guests");
//v.616
define("LAN_411", "Important Threads");
define("LAN_412", "Forum Threads");
@@ -66,7 +66,7 @@ define("LAN_433", "Syndicate this forum: RDF");
define("LAN_434", "Are you sure you want to delete this thread and any replies?");
define("LAN_435", "Delete thread");
//v.617
define("FORLAN_CLOSE", "Thread closed.");
define("FORLAN_OPEN", "Thread reopened.");
@@ -76,7 +76,7 @@ define("FORLAN_6", "Thread deleted");
define("FORLAN_7", "replies deleted");
define("FORLAN_8", "here");
define("FORLAN_9", "to sign up or login from the login menu.");
define("FORLAN_10", "Begin New Thread");
define("FORLAN_11", "New Posts");
define("FORLAN_12", "No New Posts");
@@ -90,5 +90,6 @@ define('FORLAN_19', '[user deleted]');
define('FORLAN_20', 'Sub-forum');
define('FORLAN_21', 'Threads');
define('FORLAN_22', 'Last Post');
define('FORLAN_23', 'Poll');
?>