Page 1 of 3
serendipity_event_forum<>PHPbb3
Posted: Tue Jan 01, 2008 5:53 pm
by ReLight
Hi, just started setting up de first serendipitysite with a PHPbb combination.
I run into the fact that the serendipity_event_forum plugin is made for PHPbb-2.x.
Has anybody finished a adapted plugin allready ?
I have myself adapted a piece of the plugin to work with the PHPBB-3 forum, and it 'seems' to be working now for me. It had some apearent bug as standard and those were fixed as well.
Adapting the plugin globally is needed because the phpbb3 has dropped the seperate table phpbb_posts_texts table and merged it with phpbb_posts. This requires some renaming, and altering inserts into Updates. Also fields like topic_replies_real need filling and poster_id fields need proper id entries.
One issue remains, and I wonder if anyone can tell me if its legacy or new:
-i'm unable to remove any comments in the serendipity site below an article.
any idea ?
Re: serendipity_event_forum<>PHPbb3
Posted: Tue Jan 01, 2008 6:15 pm
by garvinhicking
Hi!
That's true, it's suitable for 2.x only, the DB structure has changed a lot.
So it would be cool if the plugin could get a config option switch so that people can choose between 2.x and 3.x, and the code forks to the appropriate SQL insert statements.
Thus, I'd be very interested in your code changes, could you provide a patch so that I can merge it with the official plugin?
One issue remains, and I wonder if anyone can tell me if its legacy or new:
-i'm unable to remove any comments in the serendipity site below an article.
That's actually a missing feature, and didn't work with 2.x before. Since comments are stored in the phpbb table, you'd need to delete "comments" inside phpbb, instead of in s9y. Codewise, I don't think it would be possible to replace s9y's comment routine to access the phpbb installation completely.
Regards,
Garvin
Posted: Tue Jan 01, 2008 6:26 pm
by ReLight
A patch set is a little difficult for me now, but i'd be happy to give you the changed file so you can do a diff yourself (sry about that).
Let me explain my problem in more detail, as I get the impression you misunderstood;
Adding a comment in my current setup adds the comment to
BOTH serendipity and PHPbb3.
When I try to remove a comment from the serendipity site comment list, it popups with a confirmation, but then does not delete the comment from the s9y comment list. (i did not expect it to do it in phpbb anyway, but would be cool

)
I'll add some comment to the places I refactored to make it work with phpbb3 and mail or PM you the file. If you want it to another address just PM me with it.
Posted: Tue Jan 01, 2008 6:37 pm
by garvinhicking
Hi!
ReLight wrote:A patch set is a little difficult for me now, but i'd be happy to give you the changed file so you can do a diff yourself (sry about that).
Sure, that would be fine enough for me
When I try to remove a comment from the serendipity site comment list, it popups with a confirmation, but then does not delete the comment from the s9y comment list. (i did not expect it to do it in phpbb anyway, but would be cool

)
Ah, okay. Indeed I misunderstood you, sorry for that.
Actually, the plugin should not be responsible for not deleting the comment; it shouldn't affect that. Can you delete a comment frmo the s9y administration panel successfully?
Are you logged in as an admin when deleting a comment? It might be that the internal s9y comment deletion routine performs stricter checks than those that are performed when showing you the "delete comment" link, that could be a bug indeed.
I'll add some comment to the places I refactored to make it work with phpbb3 and mail or PM you the file. If you want it to another address just PM me with it.
A PM to this forum would be sufficient, thanks a lot.
Regards,
Garvin
Posted: Tue Jan 01, 2008 8:30 pm
by ReLight
Indeed I can delete the comments from the AdminInterface, its the same user loged in so it seems a bug in s9y.
I PM'd the diff text to you. The mirror plugin is great but can be expanded in functionality. A functional switch for phpbb2 or phpbb3 would be best.
->update.
Comments added to articles created before the phpbb3 intergration can be deleted. So there is a relation to the plugin i think.
Posted: Wed Jan 02, 2008 10:15 am
by garvinhicking
Hi!
Hm, I can't exactly reproduce this here. A link when deleting a comment should look like:
http://.../comment.php?serendipity[delete]=1239&serendipity[entry]=67&serendipity[type]=comments
Can you check if the comments you made after phpbb integration have a similar link?
This link should open comment.php, which calls the serendipity_deleteComment() function. That is defined in include/functions_comments.inc.php. Could you check that function?
And please check, how the entry of a phpbb-comment looks in your serendipity_comments DB table, and can you see if it looks different than the comments made before phpbb3 integration? I think it could be, that a column like "type" or "status" could be different?
Regards,
Garvin
Posted: Wed Jan 02, 2008 1:23 pm
by ReLight
Normal link of article before plugin intergration:
Code: Select all
/serendipity/comment.php?serendipity[delete]=10&serendipity[entry]=2&serendipity[type]=comments
Remove link of article AFTER plugin intergration:
Code: Select all
/serendipity/comment.php?serendipity[delete]=28&serendipity[entry]=15&serendipity[type]=comments
-> seems the same.
Content of DB is totally different.
SQL-query: SELECT * FROM `comments` LIMIT 0, 30 ;
Rijen: 2
Code: Select all
id entry_id parent_id timestamp title author email url ip body type subscribed status referer
normal s9y comment
Code: Select all
10 2 0 1199274991 Remon remon@mail.net 212.123.144.148 Een net artikel. NORMAL false approved http://moederwordennaje36ste.nl/serendipity/index....
phpbb mirror comment
Code: Select all
11 15 0 NULL phpbb_mirror NULL NULL http://www.xxxxxxx.nl/phpBB3/viewtop... NULL NORMAL false approved NULL
Posted: Thu Jan 03, 2008 1:59 pm
by garvinhicking
Hi!
Could you please replace your serendipity_deleteComment() function in include/functions_comments.inc.php with this:
Code: Select all
function serendipity_deleteComment($id, $entry_id, $type='comments') {
global $serendipity;
$id = (int)$id;
$entry_id = (int)$entry_id;
if ($id < 1 OR $entry_id < 1) {
die('No valid entryid!');
return false;
}
if ($_SESSION['serendipityAuthedUser'] === true) {
$admin = '';
if (!serendipity_checkPermission('adminEntriesMaintainOthers')) {
$admin = " AND authorid = " . (int)$_SESSION['serendipityAuthorid'];
}
/* We have to figure out if the comment we are about to delete, is awaiting approval,
if so - we should *not* subtract it from the entries table */
$q1 = "SELECT type, status, parent_id, body FROM {$serendipity['dbPrefix']}comments
WHERE entry_id = ". $entry_id ."
AND id = ". $id;
$sql = serendipity_db_query($q1, true);
/* Check to see if the comment has children
* if it does, don't delete, but replace with "*(COMMENT DELETED)*"
to delete a tree, delete children first */
$has_parent = serendipity_db_query("SELECT count(id) AS count
FROM {$serendipity['dbPrefix']}comments
WHERE parent_id = ". $id . "
LIMIT 1", true);
if (is_array($has_parent) && isset($has_parent['count']) && $has_parent['count'] > 0 && $sql['body'] != 'COMMENT_DELETED') {
// Comment has childs, so don't delete it.
$q2 = "UPDATE {$serendipity['dbPrefix']}comments
SET body = 'COMMENT_DELETED'
WHERE id = " . $id;
serendipity_db_query($q2);
$q3 = $q4 = "EMPTY-A!";
} else {
// Comment has no childs or had already been deleted., it can be safely removed.
$q2 = "DELETE FROM {$serendipity['dbPrefix']}comments
WHERE entry_id = ". $entry_id ."
AND id = ". $id;
serendipity_db_query($q2);
if (is_array($sql) && $sql['status'] !== 'pending') {
if (!empty($sql['type']) && $sql['type'] != 'NORMAL') {
$type = 'trackbacks';
} else {
$type = 'comments';
}
$q3 = "UPDATE {$serendipity['dbPrefix']}entries SET $type = $type-1 WHERE id = ". $entry_id ." AND $type > 0 $admin";
serendipity_db_query($q3);
} else {
$q3 = "EMPTY-B!";
}
$q4 = "UPDATE {$serendipity['dbPrefix']}comments SET parent_id = " . (int)$sql['parent_id'] . " WHERE parent_id = " . $id;
serendipity_db_query($q4);
}
$addData = array('cid' => $id, 'entry_id' => $entry_id);
serendipity_plugin_api::hook_event('backend_deletecomment', $sql, $addData);
die($q1 . "\n" . $q2 . "\n" . $q3 . "\n" . $q4);
return true;
} else {
die('Not authorized!');
return false;
}
}
I've added debug output that you should see after clicking the delete link of a comment.
Regards,
Garvin
Posted: Thu Jan 03, 2008 3:59 pm
by ReLight
output when deleting a comment that was initially made on the s9y site with phpbb3 plugin active:
Code: Select all
SELECT type, status, parent_id, body FROM comments WHERE entry_id = 15 AND id = 28 DELETE FROM comments WHERE entry_id = 15 AND id = 28 EMPTY-B! UPDATE comments SET parent_id = 0 WHERE parent_id = 28
I did not realise the interaction was 2 ways, postings added on the forum also show on the s9y site

very cool !
There is a little bug in the number of reactions counted beneath the article on the frontpage of s9y though. The forum added comments are not counted.
Posted: Thu Jan 03, 2008 4:22 pm
by garvinhicking
Hi!
Hm, according to that Debout output, the comment #28 should actually be deleted from your serendipity-comment database?
I think the reason it might still show up is because the comment still exists on the phpbb side, can that be?
There is a little bug in the number of reactions counted beneath the article on the frontpage of s9y though. The forum added comments are not counted.
Yeah, that's sadly not changeable. s9y does not count this dynamically, it uses the serendipity_entries.comments counter for that. This could only be corrected, if the phpbb forum would also update the s9y table, which I doubt can happen...
Regards,
Garvin
Posted: Thu Jan 03, 2008 5:11 pm
by ReLight
garvinhicking wrote:Hi!
Hm, according to that Debout output, the comment #28 should actually be deleted from your serendipity-comment database?
I think the reason it might still show up is because the comment still exists on the phpbb side, can that be?
YES 
your right. When I also removed the comment on the phpbb3 side the entry was gone! So this needs an comment delete function extention into the event_forum plugin reversing a comment insert. (that kind of thing goes somewhat beyond my level atm I think.)
addition:
The comments added via phpBB to the s9y comment view all have ánonymous' as author.
Is this normal ? Extrapolating on your earlier reply on author names should this not be the member name from the phpbb forum ?
Yeah, that's sadly not changeable. s9y does not count this dynamically, it uses the serendipity_entries.comments counter for that. This could only be corrected, if the phpbb forum would also update the s9y table, which I doubt can happen...
Hmm, there no triggers in mysql possible, so that might be difficult. Only option would be to make it dynamic/ realtime so that its checked everytime the phpbb comments are retrieved anyway. (I pesume that the comment display function just retieves the s9y comments and the phpbb comments and puts them in order befor print)[/b]
Posted: Fri Jan 04, 2008 9:38 am
by ReLight
>seperate double reaction to keep the overview.
Hi Garvin,
The 0,28 update contains 2 problems.
1) The phpbb2 or 3 detection does not work properly. Workarround hack by hard coding $phpbb_mirror = 3; in the plugin on line 2326.
2) The s9y comments are inserted into the phpbb3 forum DB but are not visible. The poster_id in the db is set to 0, and this makes phpbb3 not show the post. Changing it to another (existing id) makes it show. This is why I created the 53 user id. (line 2655, -1 to 53)
Posted: Fri Jan 04, 2008 10:28 am
by garvinhicking
Hi!
1) The phpbb2 or 3 detection does not work properly. Workarround hack by hard coding $phpbb_mirror = 3; in the plugin on line 2326.
Hm, I wonder why?
Code: Select all
if ((int)$phpbb_mirror === 3) {
$phpbb_mirror = 3;
} elseif ((int)$phpbb_mirror === 2) {
$phpbb_mirror = 2;
} elseif (serendipity_db_bool($phpbb_mirror)) {
$phpbb_mirror = 2;
} else {
$phpbb_mirror = false;
}
looks good to me - can you try if it works by using "==" instead of "==="?
2) The s9y comments are inserted into the phpbb3 forum DB but are not visible. The poster_id in the db is set to 0, and this makes phpbb3 not show the post. Changing it to another (existing id) makes it show. This is why I created the 53 user id. (line 2655, -1 to 53)
Can you please try what phpbb3 requires so that a non-registered user can post?
You can try this by posting to your board with an anonymous user (who has entered his username on posting) and see what his userid is set to. This should be possible, phpbb2 at least never required users to register before they can post.
Regards,
Garvin
Posted: Fri Jan 04, 2008 10:39 am
by ReLight
garvinhicking wrote:Hi!
1) The phpbb2 or 3 detection does not work properly. Workarround hack by hard coding $phpbb_mirror = 3; in the plugin on line 2326.
Hm, I wonder why?
Code: Select all
if ((int)$phpbb_mirror === 3) {
$phpbb_mirror = 3;
} elseif ((int)$phpbb_mirror === 2) {
$phpbb_mirror = 2;
} elseif (serendipity_db_bool($phpbb_mirror)) {
$phpbb_mirror = 2;
} else {
$phpbb_mirror = false;
}
looks good to me - can you try if it works by using "==" instead of "==="?
> Tried, no good.
in s9y i see: "Table 'mwnj36ste_phpbb.phpbb_posts_text' doesn't exist ", so its defaulting to phpbb2.
2) The s9y comments are inserted into the phpbb3 forum DB but are not visible. The poster_id in the db is set to 0, and this makes phpbb3 not show the post. Changing it to another (existing id) makes it show. This is why I created the 53 user id. (line 2655, -1 to 53)
Can you please try what phpbb3 requires so that a non-registered user can post?
You can try this by posting to your board with an anonymous user (who has entered his username on posting) and see what his userid is set to. This should be possible, phpbb2 at least never required users to register before they can post.
Anonymous posting from the webinterface without registration is disabled at my phpbb forum. (who ever has that still turned on?), that might be it.
but as these are direct db inserts thats not prevented. I guess there is a double post-rights lookup making sure non registered users can not show posts even if they hack direct into the db.
Posted: Fri Jan 04, 2008 10:49 am
by garvinhicking
Hi!
> Tried, no good.
Hm, can you modify it to:
Code: Select all
if ((int)$phpbb_mirror === 3) {
$phpbb_mirror = 3;
die('3!');
} elseif ((int)$phpbb_mirror === 2) {
$phpbb_mirror = 2;
die('2a!');
} elseif (serendipity_db_bool($phpbb_mirror)) {
$phpbb_mirror = 2;
die('2b!');
} else {
$phpbb_mirror = false;
die('0!');
}
And see with which message it dies?
Anonymous posting from the webinterface without registration is disabled at my phpbb forum. (who ever has that still turned on?), that might be it.
Would be nice if you could test it. It's really required to not use a fixed username.
but as these are direct db inserts thats not prevented. I guess there is a double post-rights lookup making sure non registered users can not show posts even if they hack direct into the db.
That would be a new feature of phpb3 then, which I don't think is really useful in our usage scenario. There must be a way to circumvent that, or else you would never know who commented what on your phpbb forum!
Regards,
Garvin