Bedankt voor het meedenken Ger. Helaas heeft je antwoord me nog geen 'soelaas' kunnen bieden.
dat
$data['subject_title']
en
$subject
los van elkaar staan ben ik ondertussen achter. Maar de 'grap' is, is dat bij
$mode='edit'
zowel de hoofdtitel van het topic worden aangepast èn van de betreffende post.
Daarnaast gebruikt
submit_post();
een string voor
$username
, niet het
$user
(class) object. En de naam die ik hier dan gebruik, wordt ook veranderd voor de 1e (hoofd) post.
Dus stel, de eerste post van het topic was van gebruiker "B" met als titel "Btitle". Vervolgens wil ik post 12 wil aanpassen dat oorspronkelijk gepost is door gebruiker "A" met als titel "Atitle", dan doe ik:
Code: Selecteer alles
submit_post($mode='edit', $subject="Atitle", $username="A", POST_NORMAL,$poll=false,$data)
Nu veranderd dus in het forumoverzicht de titel van het topic van "Btitle" naar "Atitle" en de gebruiker van "B" naar "A".
Misschien is het ook handiger als ik een stuk van m'n script post:
Eerst een stuk van de aanhef voor de conversie:
Code: Selecteer alles
define('IN_PHPBB', true);
//$phpbb_root_path = $_SERVER['SCRIPT_FILENAME'];
$phpbb_root_path = '../';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
/* DB connect stuff */
$query = "Select post_text, bbcode_uid, poster_id, post_subject FROM phpbb_posts WHERE post_id = {$postid} LIMIT 1";
$result = mysqli_query($cxn, $query);
$row = mysqli_fetch_assoc($result);
// Decoden van de BB-tags van het bericht... (zie http://wiki.phpbb.com/Tutorial.Parsing_text)
decode_message($row['post_text'], $row['bbcode_uid']);
// Converteren van de tags (custom functie)
$message = html_to_bb( html_entity_decode($row['post_text']) );
//$txt = getAllTags( html_entity_decode($row['post_text']) );
// We kiezen de juiste fora...
$forumid = 1;
$topicid = 2;
$poster_id = $row['poster_id']; //Vanuit DB gehaald--> oorspronkelijke poster
$post_subject = $row['post_subject']; // Vanuit DB gehaald --> oorspronkelijke post title
//En nu weer terug posten.
sendphpbbpost($message,$poster_id,$post_subject,$forumid,$topicid, 'edit', $postid, $poster_id);
En dit is de functie om 'makkelijk' het
$data
structure op te bouwen het uiteindelijk te posten (ergens opgeduikeld):
Code: Selecteer alles
function sendphpbbpost($posttext,$userid,$postsubject,$forumid,$topicid, $action='reply', $postid = false, $poster_id = false) {
global $phpbb_root_path;
global $phpEx;
global $sql_data;
global $user;
include($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
$postsubject = utf8_normalize_nfc($postsubject, '', true);
$posttext = utf8_normalize_nfc($posttext, '', true);
$uid = $bitfield = $options = '';
$allow_bbcode = $allow_smilies = true;
$allow_urls = true;
generate_text_for_storage($postsubject, $uid, $bitfield, $options, false, false, false);
generate_text_for_storage($posttext, $uid, $bitfield, $options, $allow_bbcode, $allow_urls, $allow_smilies);
$data = array(
// General Posting Settings
'forum_id' => $forumid, // The forum ID in which the post will be placed. (int)
'topic_id' => $topicid, // Post a new topic or in an existing one? Set to 0 to create a new one, if not, specify your topic ID here instead.
'icon_id' => false, // The Icon ID in which the post will be displayed with on the viewforum, set to false for icon_id. (int)
// Defining Post Options
'enable_bbcode' => true, // Enable BBcode in this post. (bool)
'enable_smilies' => true, // Enabe smilies in this post. (bool)
'enable_urls' => false, // Enable self-parsing URL links in this post. (bool)
'enable_sig' => true, // Enable the signature of the poster to be displayed in the post. (bool)
// Message Body
'message' => $posttext, // Your text you wish to have submitted. It should pass through generate_text_for_storage() before this. (string)
'message_md5' => md5($posttext), // The md5 hash of your message
// Values from generate_text_for_storage()
'bbcode_bitfield' => $bitfield, // Value created from the generate_text_for_storage() function.
'bbcode_uid' => $uid, // Value created from the generate_text_for_storage() function.
// Other Options
'post_edit_locked' => 0,
'topic_title' => $postsubject,
// Email Notification Settings
'notify_set' => false, // (bool)
'notify' => false, // (bool)
'post_time' => 0, // Set a specific time, use 0 to let submit_post() take care of getting the proper time (int)
'forum_name' => '', // For identifying the name of the forum in a notification email. (string)
// Indexing
'enable_indexing' => true,
'force_approved_state' => true,
);
if($postid && $poster_id){
$data['post_id'] = $postid;
$data['poster_id'] = $poster_id;
$data['post_edit_user'] = 'xxx'; //Usernumber of an admin.
$data['post_edit_reason'] = '';
$data['topic_replies_real'] = '';
$data['post_edit_count'] = 0;
}
else
{
die('Missing parameters for sendphpbbpost!');
}
//Now send that post...
//submit_post('reply', '', '', POST_NORMAL, $poll, $data, $update_message = true);
submit_post($action, $postsubject, $user->data['username'], POST_NORMAL, $poll=false, $data, $update_message = true);
}
ja, ik weet het: het kan netter. Maar ik heb nu dus nog alleen 'snel' geprogrammeerd voor eigen gebruik (lokaal om te testen).
Schiet maar.
