Jump to content


Editing a post does not apply changes in IP.Board


1 reply to this topic

#1 mm21xx

    Rookie

  • Active Member
  • 2 posts

Posted 24 January 2012 - 09:55 PM

I've been coding and encountered a wall...

Basically, I'm coding a page that will allow me to administer posts within the boards from an easier control panel.

One of the tools would allow the moderator to deduct points from a user and add a simple line at the end of the post that tells the member he was penalized.

The issue I'm having is simply this:
Querying the DB to retrieve the post, parse the post to contain only BBCode and line breaks and saving it to the database is no problem.

When I get on IPBoard to view the message though, the post content itself will show the content with BBCode instead of formatting it. I'd have to proceed and click on "Edit" and then simply click "Save" and the post then appears fine.

Is there something that needs to be done for IPBoard to display the post correctly without the need to do that?
I noticed there were other fields in the ibf_posts table which I don't know what their purpose are...

Here's part of my code:
   	 //Parse the topic ID
		$postURL = trim($_POST['post_url']);
		$parsedTopic = str_replace("http://www.dgemu.com/forums/index.php?/topic/", "", $postURL);
		$removeEnd = strpos($parsedTopic, "-");
		$parsedTopic = substr($parsedTopic, 0, $removeEnd);

		//Parse the post ID
		$removeFront = strrpos($postURL, "_") + 1;
		$setEnd = strlen($postURL);
		$parsedPost = substr($postURL, $removeFront, $setEnd);

		//Update the post
		$post = $ipbwi->post->info($parsedPost);
   	 $ipbwi->ips_wrapper->DB->query("SELECT author_id, post FROM ibf_posts WHERE pid=" . $parsedPost . " AND topic_id=" . $parsedTopic);
		if($post = $ipbwi->ips_wrapper->DB->fetch())
		{
			if($post['author_id'] == $memberId)
			{
		   	 //Note: <br /><br /> tags needed to reproduce 1 carriage return due to IPBoard bug.
				$modifiedPost = nl2br($post['post']) . "<br /><br /><br /><br />[b][color=#ff0000]" . $staffName . " deducted " . $GPmodifier . "GPs for this post.[/color][/b]";
				$modifiedPost = br2nl($modifiedPost);
		   	
		   	 $ipbwi->post->edit($parsedPost, $ipbwi->bbcode->html2bbcode($modifiedPost), false, false, false, false);
	   	 }
   	 }
Note: br2nl is a function that will replace the double <br /> tags generated from IPBoard into a simple return carriage \r
Note 2: Using the $ipbwi->post->info() function to retrieve a post gives the exact same output problem.

Edited by mm21xx, 24 January 2012 - 09:57 PM.


#2 Matthias Reuter

    Forensklave

  • Admin
  • PipPipPipPipPipPipPipPip
  • 9165 posts
  • Gender:Male
  • Location:Hamburg / Germany

Posted 25 January 2012 - 10:48 AM

if your are not using the IP.board Richtexteditor via IPBWI, so you are using bbcode to style the posts, you have to perform $ipbwi->bbcode->bbcode2html to the post string before creating the post.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users