Steve
Premium Member
Registered: 30th Mar 02
Location: Worcestershire Drives: Defender
User status: Offline
|
Iv made it so when a user deletes a post it just moves it to another forum (the thread dump).
http://www.vagweb.co.uk/forums/viewforum.php?f=20 (need to be registered)
When it moves it i get it to rename the Post title to 'Deleted from topic-ID 444' for example.
Now i want to rename it to 'Deleted from topic title' instead
The functions for this reside in fucntions_post.php and here is the snippet of code for the function wthin that does the moving
code: function delete_post($mode, &$post_data, &$message, &$meta, &$forum_id, &$topic_id, &$post_id, &$poll_id)
{
global $board_config, $lang, $db, $phpbb_root_path, $phpEx, $topic_title;
global $userdata, $user_ip;
if (intval($board_config['delete_post_forum']) != 0)
{
$sql = "SELECT * FROM " . FORUMS_TABLE . "
WHERE forum_id = " . $board_config['delete_post_forum'];
if (!$result = $db->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Error in deleting post', '', __LINE__, __FILE__, $sql);
}
$forum_count = $db->sql_numrows($result);
$db->sql_freeresult($result);
$forum_check = ($forum_count != 0) ? TRUE : 0;
}
else
{
$forum_check = 0;
}
if ($mode != 'poll_delete')
{
include($phpbb_root_path . 'includes/functions_search.'.$phpEx);
if ($userdata['user_level'] == ADMIN || ($userdata['user_level'] == MOD && $board_config['mod_allow_delete_post'] == 1))
{
$sql = "DELETE FROM " . POSTS_TABLE . "
WHERE post_id = $post_id";
if (!$db->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Error in deleting post', '', __LINE__, __FILE__, $sql);
}
$sql = "DELETE FROM " . POSTS_TEXT_TABLE . "
WHERE post_id = $post_id";
if (!$db->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Error in deleting post', '', __LINE__, __FILE__, $sql);
}
}
else if ($post_data['first_post'] == '' && $forum_check == TRUE)
{
$sql = "INSERT INTO " . TOPICS_TABLE . "
(forum_id, topic_title, topic_poster, topic_time, topic_views, topic_replies, topic_status, topic_vote, topic_type, topic_first_post_id, topic_last_post_id, topic_moved_id)
******VALUES (".$board_config['delete_post_forum'].", '".sprintf($lang['Deleted_post_from_topic'], $topic_id*******)."', ".$post_data['poster_id'].", ".time().", 0, 0, ".TOPIC_UNLOCKED.", 0, ".POST_NORMAL.", $post_id, $post_id, 0)";
if (!$db->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Error in deleting post', '', __LINE__, __FILE__, $sql);
}
$new_topic_id = $db->sql_nextid();
$sql = "UPDATE " . POSTS_TABLE . "
SET topic_id = $new_topic_id, forum_id = ".$board_config['delete_post_forum']."
WHERE post_id = $post_id";
if (!$db->sql_query($sql))
{
message_die(GENERAL_ERROR, 'Error in deleting post', '', __LINE__, __FILE__, $sql);
}
}
i have made in ******'s the line that sets the post title as it stands.
Iv tried the obvious and replaced $topic_id with $topic_title that is declared elsewhere in the php but that dont work
|
James
Member
Registered: 1st Jun 02
Location: Surrey
User status: Offline
|
What happened when you replaced topic_id with topic_title?
|
Steve
Premium Member
Registered: 30th Mar 02
Location: Worcestershire Drives: Defender
User status: Offline
|
gets nothing, topic_title on what you can see is just the name of the SQL table
|
James
Member
Registered: 1st Jun 02
Location: Surrey
User status: Offline
|
Can you post the code where $topic_id is passed into that function?
I reckon you can just pass in topic title instead....
|
Steve
Premium Member
Registered: 30th Mar 02
Location: Worcestershire Drives: Defender
User status: Offline
|
thats almost the whole function there, $topic_title is part of a different function, even if i make the variable global it still doesnt pick it up.
topic_title is made by
$topic_title = (count($orig_word)) ? preg_replace($orig_word, $replacement_word, unprepare_message($topic_title)) : unprepare_message($topic_title);
utilising bits and bobs from other functions
|
James
Member
Registered: 1st Jun 02
Location: Surrey
User status: Offline
|
Yeah but when the Delete_Post function is called, the topic_id is passed in as a paramater which is then used in that insert query, if you could just pass in the topic title as a parameter instead, you could use that?
|
Steve
Premium Member
Registered: 30th Mar 02
Location: Worcestershire Drives: Defender
User status: Offline
|
the problem is topic_id is set for many different functions, changing it would mean screwing up a lot of things
|
Steve
Premium Member
Registered: 30th Mar 02
Location: Worcestershire Drives: Defender
User status: Offline
|
i cant even find where $topic_id is set in that php document, it may be a superglobal declared elsewhere
|
James
Member
Registered: 1st Jun 02
Location: Surrey
User status: Offline
|
Well you dont need to change it, just pass in topic_title instead.
Where you've got this:
code:
function delete_post($mode, &$post_data, &$message, &$meta, &$forum_id, &$topic_id, &$post_id, &$poll_id)
Change it to this:
code:
function delete_post($mode, $post_data, $message, $meta, $forum_id, $topic_id, $post_id, $poll_id, $topic_title)
And then when the delete_post function is called (looks like this):
code:
delete_post("parameter1", "parameter2", "parameter3", "parameter4", "parameter5", "parameter6",
"parameter7", "parameter8", "topic title")
And then where it does this insert:
code:
$sql = "INSERT INTO " . TOPICS_TABLE . "
(forum_id, topic_title, topic_poster, topic_time, topic_views, topic_replies, topic_status, topic_vote, topic_type, topic_first_post_id, topic_last_post_id, topic_moved_id)
******VALUES (".$board_config['delete_post_forum'].", '".sprintf($lang['Deleted_post_from_topic'], $topic_id*******)."', ".$post_data['poster_id'].", ".time().", 0, 0, ".TOPIC_UNLOCKED.", 0, ".POST_NORMAL.", $post_id, $post_id, 0)";
Change it to this
code:
$sql = "INSERT INTO " . TOPICS_TABLE . "
(forum_id, topic_title, topic_poster, topic_time, topic_views, topic_replies, topic_status, topic_vote, topic_type, topic_first_post_id, topic_last_post_id, topic_moved_id)
******VALUES (".$board_config['delete_post_forum'].", '".sprintf($lang['Deleted_post_from_topic'], $topic_title*******)."', ".$post_data['poster_id'].", ".time().", 0, 0, ".TOPIC_UNLOCKED.", 0, ".POST_NORMAL.", $post_id, $post_id, 0)";
Do you get me?
[Edited on 03-10-2006 by James]
|
Cosmo
Member
Registered: 29th Mar 01
Location: Im the real one!
User status: Offline
|
wrong forum, this should be in uber geek day
|
Steve
Premium Member
Registered: 30th Mar 02
Location: Worcestershire Drives: Defender
User status: Offline
|
i did try that one of the first things i did and got
Warning: Missing argument 9 for delete_post() in /home/sites/vagweb.co.uk/public_html/forums/includes/functions_post.php on line 469
|
John
Member
Registered: 30th Jun 03
User status: Offline
|
Sorry to crash your post steve but I don't have a clue.
I would however like to.
What do I need to get something like this going.
I know there will be millions on google but i'll look into things further when I have a basic idea of what i'm looking for.
|
Steve
Premium Member
Registered: 30th Mar 02
Location: Worcestershire Drives: Defender
User status: Offline
|
something like what going? a forum?
|
John
Member
Registered: 30th Jun 03
User status: Offline
|
Yip, your forum or here for instance.
|
Steve
Premium Member
Registered: 30th Mar 02
Location: Worcestershire Drives: Defender
User status: Offline
|
http://www.phpbb.com/downloads.php
will get you the basic stuff of what mines running on. This forum is XMB unsure if xmb is free, phpbb is free.
Bear in mind mine and this is very modified so wont look like it out the box or have half the functions but its a good start
|
John
Member
Registered: 30th Jun 03
User status: Offline
|
Cheers.
Thats plenty to get me going
|
Steve
Premium Member
Registered: 30th Mar 02
Location: Worcestershire Drives: Defender
User status: Offline
|
if you cant be arsed to design your own layout etc then you can quickly apply themes from
http://www.phpbb-design.com/
|
Ian
Site Administrator
Registered: 28th Aug 99
Location: Liverpool
User status: Online
|
The ways its done here is that the forum id becomes that of the trash - in this case 29 - and thats the only change in the posts and threads tables.
At this time it also writes the thread id and a reason to another table.
Its forumdisplay and viewthread where the difference happens, they don't allow regular members to view threads with that forum id.
Forumdisplay also does the join now with the posts in fid=29 and the reasons table to get that.
What you're needing to do means you need the thread title available to you when you process the move, which you probably have, if all else fails throw a select in there and get it.
|
Steve
Premium Member
Registered: 30th Mar 02
Location: Worcestershire Drives: Defender
User status: Offline
|
i was thinking about doing an sql query to get
|
Ian
Site Administrator
Registered: 28th Aug 99
Location: Liverpool
User status: Online
|
That would work, its an extra query and I would make double sure you don't already have it in memory somewhere before you query for it, but if you don't then yeah, that would sort it.
|
Steve
Premium Member
Registered: 30th Mar 02
Location: Worcestershire Drives: Defender
User status: Offline
|
got it working with the SQL query cheers ian
|
Steve
Premium Member
Registered: 30th Mar 02
Location: Worcestershire Drives: Defender
User status: Offline
|
thread dump is completed, now tells you when it was trashed and who by
also stopped it from showing in the results from show posts since last visit
|
|