mirror of
https://github.com/e107inc/e107.git
synced 2025-08-01 12:20:44 +02:00
thread and post deletion now working
This commit is contained in:
0
e107_plugins/forum/attachments/index.html
Normal file
0
e107_plugins/forum/attachments/index.html
Normal file
0
e107_plugins/forum/attachments/thumb/index.html
Normal file
0
e107_plugins/forum/attachments/thumb/index.html
Normal file
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
// $Id: thread.php,v 1.4 2008-12-07 04:16:38 mcfly_e107 Exp $
|
||||
// $Id: thread.php,v 1.5 2008-12-11 16:02:05 mcfly_e107 Exp $
|
||||
function url_forum_thread($parms)
|
||||
{
|
||||
switch($parms['func'])
|
||||
@@ -34,6 +34,10 @@ function url_forum_thread($parms)
|
||||
return e_PLUGIN_ABS."forum/forum_post.php?f=edit&id={$parms['id']}";
|
||||
break;
|
||||
|
||||
case 'move':
|
||||
return e_PLUGIN_ABS."forum/forum_post.php?f=move&id={$parms['id']}";
|
||||
break;
|
||||
|
||||
case 'quote':
|
||||
return e_PLUGIN_ABS."forum/forum_post.php?f=quote&id={$parms['id']}";
|
||||
break;
|
||||
|
@@ -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.22 $
|
||||
| $Date: 2008-12-10 21:00:48 $
|
||||
| $Revision: 1.23 $
|
||||
| $Date: 2008-12-11 16:02:05 $
|
||||
| $Author: mcfly_e107 $
|
||||
+----------------------------------------------------------------------------+
|
||||
*/
|
||||
@@ -356,11 +356,71 @@ class e107forum
|
||||
$viewed = $tmp['plugin_forum_user_viewed'];
|
||||
unset($tmp);
|
||||
}
|
||||
|
||||
return explode(',', $viewed);
|
||||
|
||||
}
|
||||
|
||||
function postDeleteAttachments($type = 'post', $id='', $f='')
|
||||
{
|
||||
$e107 = e107::getInstance();
|
||||
$id = (int)$id;
|
||||
if(!$id) { return; }
|
||||
if($type == 'thread')
|
||||
{
|
||||
if(!$e107->sql->db_Select('forum_post', 'post_id', 'post_attachments IS NOT NULL'))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
$postList = array();
|
||||
while($row = $e107->sql->dbFetch(MYSQL_ASSOC))
|
||||
{
|
||||
$postList[] = $row['post_id'];
|
||||
}
|
||||
foreach($postList as $postId)
|
||||
{
|
||||
$this->postDeleteAttachment('post', $postId);
|
||||
}
|
||||
}
|
||||
if($type == 'post')
|
||||
{
|
||||
if(!$e107->sql->db_Select('forum_post', 'post_attachments', 'post_id = '.$id))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
$tmp = $e107->sql->db_Fetch(MYSQL_ASSOC);
|
||||
$attachments = explode(',', $tmp['post_attachments']);
|
||||
foreach($attachments as $k => $a)
|
||||
{
|
||||
$info = explode('*', $a);
|
||||
if('' == $f || $info[1] == $f)
|
||||
{
|
||||
$fname = e_PLUGIN."forum/attachments/{$info[1]}";
|
||||
@unlink($fname);
|
||||
|
||||
//If attachment is an image and there is a thumb, remove it
|
||||
if('img' == $info[0] && $info[2])
|
||||
{
|
||||
$fname = e_PLUGIN."forum/attachments/thumb/{$info[2]}";
|
||||
@unlink($fname);
|
||||
}
|
||||
}
|
||||
unset($attachments[$k]);
|
||||
}
|
||||
$tmp = array();
|
||||
if(count($attachments))
|
||||
{
|
||||
$tmp['post_attachments'] = implode(',', $attachments);
|
||||
}
|
||||
else
|
||||
{
|
||||
$tmp['post_attachments'] = '_NULL_';
|
||||
}
|
||||
$tmp['_FILE_TYPES']['post_attachments'] = 'escape';
|
||||
$tmp['WHERE'] = 'post_id = '.$id;
|
||||
$e107->sql->db_update('forum_post', $tmp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function thread_postnum($thread_id)
|
||||
{
|
||||
global $sql;
|
||||
@@ -388,23 +448,24 @@ class e107forum
|
||||
$sql2 = new db;
|
||||
if ($type == 'thread')
|
||||
{
|
||||
$id = intval($id);
|
||||
$thread_info = $this->thread_get_lastpost($id);
|
||||
list($uid, $uname) = explode(".", $thread_info['thread_user'], 2);
|
||||
if ($thread_info)
|
||||
$id = (int)$id;
|
||||
$lpInfo = $this->threadGetLastpost($id);
|
||||
$tmp = array();
|
||||
if($lpInfo['user_name'])
|
||||
{
|
||||
if($thread_info['user_name'] != "")
|
||||
{
|
||||
$thread_lastuser = $uid.".".$thread_info['user_name'];
|
||||
$tmp['thread_lastuser'] = $lpInfo['post_user'];
|
||||
$tmp['thread_lastuser_anon'] = '_NULL_';
|
||||
}
|
||||
else
|
||||
{
|
||||
$tmp = explode(chr(1), $thread_info['thread_user']);
|
||||
$thread_lastuser = $tmp[0];
|
||||
$tmp['thread_lastuser'] = 0;
|
||||
$tmp['thread_lastuser_anon'] = $lpInfo['post_user_anon'];
|
||||
}
|
||||
$sql->db_Update('forum_t', "thread_lastpost = ".intval($thread_info['thread_datestamp']).", thread_lastuser = '".$tp -> toDB($thread_lastuser, true)."' WHERE thread_id = ".$id);
|
||||
}
|
||||
return $thread_info;
|
||||
$tmp['thread_lastpost'] = $lpInfo['post_datestamp'];
|
||||
$tmp['_FIELD_TYPES'] = $this->fieldTypes['forum_thread'];
|
||||
$sql->db_Update('forum_thread', $tmp);
|
||||
|
||||
return $lpInfo;
|
||||
}
|
||||
if ($type == 'forum') {
|
||||
if ($id == 'all')
|
||||
@@ -753,29 +814,21 @@ class e107forum
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function thread_get_lastpost($forum_id)
|
||||
function threadGetLastpost($id)
|
||||
{
|
||||
$forum_id = intval($forum_id);
|
||||
global $sql;
|
||||
if ($sql->db_Count('forum_t', '(*)', "WHERE thread_parent = {$forum_id} "))
|
||||
{
|
||||
$where = "WHERE t.thread_parent = $forum_id ";
|
||||
}
|
||||
else
|
||||
{
|
||||
$where = "WHERE t.thread_id = $forum_id ";
|
||||
}
|
||||
$e107 = e107::getInstance();
|
||||
$id = (int)$id;
|
||||
$qry = "
|
||||
SELECT t.thread_user, t.thread_datestamp, u.user_name FROM #forum_t AS t
|
||||
LEFT JOIN #user AS u ON SUBSTRING_INDEX(t.thread_user,'.',1) = u.user_id
|
||||
{$where}
|
||||
ORDER BY t.thread_datestamp DESC LIMIT 0,1
|
||||
SELECT p.post_user, p.post_user_anon, p.post_datestamp, p.post_thread, u.user_name FROM `#forum_post` AS p
|
||||
LEFT JOIN `#user` AS u ON u.user_id = p.post_user
|
||||
WHERE p.post_thread = {$id}
|
||||
ORDER BY p.post_datestamp DESC LIMIT 0,1
|
||||
";
|
||||
if ($sql->db_Select_gen($qry))
|
||||
if ($e107->sql->db_Select_gen($qry))
|
||||
{
|
||||
return $sql->db_Fetch(MYSQL_ASSOC);
|
||||
return $e107->sql->db_Fetch(MYSQL_ASSOC);
|
||||
}
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
// function forum_get_topic_count($forum_id)
|
||||
|
@@ -11,8 +11,8 @@
|
||||
| GNU General Public License (http://gnu.org).
|
||||
|
|
||||
| $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum_mod.php,v $
|
||||
| $Revision: 1.3 $
|
||||
| $Date: 2008-12-09 21:46:14 $
|
||||
| $Revision: 1.4 $
|
||||
| $Date: 2008-12-11 16:02:05 $
|
||||
| $Author: mcfly_e107 $
|
||||
+----------------------------------------------------------------------------+
|
||||
*/
|
||||
@@ -33,6 +33,7 @@ function forum_thread_moderate($p)
|
||||
if (preg_match("#(.*?)_(\d+)_x#", $key, $matches))
|
||||
{
|
||||
$act = $matches[1];
|
||||
// print_a($matches); return;
|
||||
$id = (int)$matches[2];
|
||||
|
||||
switch ($act)
|
||||
@@ -61,6 +62,10 @@ function forum_thread_moderate($p)
|
||||
return forumDeleteThread($id);
|
||||
break;
|
||||
|
||||
case 'deletePost':
|
||||
return forumDeletePost($id);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -103,4 +108,47 @@ function forumDeleteThread($threadId)
|
||||
}
|
||||
}
|
||||
|
||||
function forumDeletePost($postId)
|
||||
{
|
||||
$postId = (int)$postId;
|
||||
require_once (e_PLUGIN.'forum/forum_class.php');
|
||||
$e107 = e107::getInstance();
|
||||
$f = &new e107forum;
|
||||
if(!$e107->sql->db_Select('forum_post', '*', 'post_id = '.$postId))
|
||||
{
|
||||
echo 'NOT FOUND!'; return;
|
||||
}
|
||||
$row = $e107->sql->db_Fetch(MYSQL_ASSOC);
|
||||
|
||||
//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']);
|
||||
}
|
||||
|
||||
//delete attachments if they exist
|
||||
if($row['post_attachments'])
|
||||
{
|
||||
$f->postDeleteAttachments('post', $postId);
|
||||
}
|
||||
|
||||
// delete post
|
||||
$e107->sql->db_Delete('forum_post', 'post_id='.$postId);
|
||||
|
||||
// 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']);
|
||||
|
||||
// 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']);
|
||||
|
||||
// update thread lastpost info
|
||||
$f->forumUpdateLastpost('thread', $row['post_thread']);
|
||||
|
||||
// update forum lastpost info
|
||||
$f->forumUpdateLastpost('forum', $row['post_forum']);
|
||||
return FORLAN_6.' and '.$threadInfo['thread_total_replies'].' '.FORLAN_7.'.';
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
@@ -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.28 $
|
||||
| $Date: 2008-12-10 15:29:31 $
|
||||
| $Revision: 1.29 $
|
||||
| $Date: 2008-12-11 16:02:05 $
|
||||
| $Author: mcfly_e107 $
|
||||
+----------------------------------------------------------------------------+
|
||||
*/
|
||||
@@ -258,7 +258,7 @@ if (isset($_POST['newthread']) || isset($_POST['reply']))
|
||||
}
|
||||
$postInfo['post_attachments'] = implode(',', $attachments);
|
||||
}
|
||||
var_dump($uploadResult);
|
||||
// var_dump($uploadResult);
|
||||
|
||||
switch($action)
|
||||
{
|
||||
@@ -576,7 +576,10 @@ function process_upload()
|
||||
require_once(e_HANDLER.'resize_handler.php');
|
||||
$orig_file = $upload['name'];
|
||||
$new_file = 'th_'.$orig_file;
|
||||
if(resize_image($attachmentDir.$orig_file, $attachmentDir.'thumb/'.$new_file, $pref['forum_maxwidth']))
|
||||
|
||||
$resizeDir = ($pref['forum_linkimg'] ? 'thumb/' : '');
|
||||
|
||||
if(resize_image($attachmentDir.$orig_file, $attachmentDir.$resizeDir.$new_file, $pref['forum_maxwidth']))
|
||||
{
|
||||
if($pref['forum_linkimg'])
|
||||
{
|
||||
|
@@ -49,6 +49,10 @@ if($postInfo['post_attachments'])
|
||||
{
|
||||
$txt .= "<a href='".e_PLUGIN_ABS."forum/attachments/{$info[1]}'><img src='".e_PLUGIN_ABS."forum/attachments/thumb/{$info[2]}' alt='' /></a>";
|
||||
}
|
||||
else
|
||||
{
|
||||
$txt .= "<img src='".e_PLUGIN_ABS."forum/attachments/{$info[1]}' alt='' />";
|
||||
}
|
||||
}
|
||||
}
|
||||
return $txt;
|
||||
@@ -212,7 +216,6 @@ if (USER && $postInfo['post_user'] == USERID && $threadInfo['thread_active'])
|
||||
{
|
||||
return "<a href='".$e107->url->getUrl('forum', 'thread', array('func' => 'edit', 'id' => $postInfo['post_id']))."'>".IMAGE_edit.'</a> ';
|
||||
}
|
||||
return '';
|
||||
SC_END
|
||||
|
||||
SC_BEGIN QUOTEIMG
|
||||
|
@@ -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.11 $
|
||||
| $Date: 2008-12-09 21:46:14 $
|
||||
| $Revision: 1.12 $
|
||||
| $Date: 2008-12-11 16:02:05 $
|
||||
| $Author: mcfly_e107 $
|
||||
+----------------------------------------------------------------------------+
|
||||
*/
|
||||
@@ -69,22 +69,6 @@ if (USER || USER != $threadInfo['thread_user'] || !$thread->noInc)
|
||||
$forum->threadIncview($threadId);
|
||||
}
|
||||
|
||||
//print_a($postList);
|
||||
//if(intval($thread_info['head']['thread_forum_id']) == 0)
|
||||
//{
|
||||
// require_once(HEADERF);
|
||||
// $ns->tablerender(LAN_01, FORLAN_104, array('forum_viewtopic', '104'));
|
||||
// require_once(FOOTERF);
|
||||
// exit;
|
||||
//}
|
||||
|
||||
//$forum_info = $forum->forum_get($thread_info['head']['thread_forum_id']);
|
||||
//
|
||||
//if (!check_class($forum_info['forum_class']) || !check_class($forum_info['parent_class'])) {
|
||||
// header("Location:".e_PLUGIN."forum/forum.php");
|
||||
// exit;
|
||||
//}
|
||||
|
||||
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']);
|
||||
define('MODERATOR', (USER && is_array($modArray) && in_array(USERID, array_keys($modArray))));
|
||||
@@ -286,7 +270,7 @@ else
|
||||
|
||||
echo "<script type=\"text/javascript\">
|
||||
function confirm_(mode, forum_id, thread_id, thread) {
|
||||
if (mode == 'thread') {
|
||||
if (mode == 'Thread') {
|
||||
return confirm(\"" . $tp->toJS(LAN_409) . "\");
|
||||
} else {
|
||||
return confirm(\"" . $tp->toJS(LAN_410) . " [ " . $tp->toJS(LAN_411) . "\" + thread + \" ]\");
|
||||
@@ -297,30 +281,35 @@ require_once (FOOTERF);
|
||||
|
||||
function showmodoptions()
|
||||
{
|
||||
global $thread_id;
|
||||
global $thread_info;
|
||||
global $forum_info;
|
||||
global $post_info;
|
||||
$forum_id = $forum_info['forum_id'];
|
||||
if ($post_info['thread_parent'] == false)
|
||||
global $thread, $postInfo;
|
||||
|
||||
// var_dump($thread);
|
||||
// var_dump($postInfo);
|
||||
|
||||
$e107 = e107::getInstance();
|
||||
$forum_id = $thread->threadInfo['forum_id'];
|
||||
if ($postInfo['thread_start'])
|
||||
{
|
||||
$type = 'thread';
|
||||
$ret = "<form method='post' action='" . e_PLUGIN . "forum/forum_viewforum.php?{$forum_id}' id='frmMod_{$forum_id}_{$post_info['thread_id']}'>";
|
||||
$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 = 'reply';
|
||||
$ret = "<form method='post' action='" . e_SELF . "?" . e_QUERY . "' id='frmMod_{$forum_id}_{$post_info['thread_id']}'>";
|
||||
$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='" . e_PLUGIN . "forum/forum_post.php?edit.{$post_info['thread_id']}.{$topic_from}'>" . IMAGE_admin_edit . "</a>
|
||||
<input type='image' " . IMAGE_admin_delete . " name='delete_{$post_info['thread_id']}' value='thread_action' onclick=\"return confirm_('{$type}', {$forum_id}, {$thread_id}, '{$post_info['user_name']}')\" />
|
||||
<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')
|
||||
if ($type == 'Thread')
|
||||
{
|
||||
$ret .= "<a href='" . e_PLUGIN . "forum/forum_conf.php?move.{$thread_id}'>" . IMAGE_admin_move2 . "</a>";
|
||||
$ret .= "<a href='" . $e107->url->getUrl('forum', 'thread', array('func' => 'move', 'id' => $postInfo['post_id']))."'>" . IMAGE_admin_move2 . "</a>";
|
||||
}
|
||||
$ret .= "
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user