Phpbb Feed Id is Topic or Post
Hello all
I run a website about computer building, and I'm currently working on a system that will allow users to post their own pages about projects they've done, etc. This is external to the phpbb3 forum. However, comments on the projects will be done through the forum. Here is how it's setup:
A user fills out some forms, adds pictures, etc and their project page is created. When this happens, the data acquired is used to submit a post to the forum using the submit_post function. The post includes the title, description, and other things about the project. Users do not have permission to make new topics in this section, they can only reply to them. But, the topic generated should have the project creator as the author. To accomplish this, the permissions of a bot user with permission to post topics are temporarily stolen, and the post is made successfully. The user cannot go in an edit the post, because it is submitted with the lock constant set to 1. That all works just fine.
Here is the function that accomplishes that:
Code: Select all
/* *submit_forum_post_via_user */ function submit_forum_post_via_user($post_title, $post_content, $forum_num, $spoof_id) { //make sure this function knows about the necessary global information global $auth, $db, $user; // note that multibyte support is enabled here $subject = utf8_normalize_nfc(request_var('subject', $post_title, true)); $text = utf8_normalize_nfc(request_var('text', $post_content, true)); // variables to hold the parameters for submit_post $poll = $uid = $bitfield = $options = ''; //generate the information generate_text_for_storage($subject, $uid, $bitfield, $options, false, false, false); generate_text_for_storage($text, $uid, $bitfield, $options, true, true, true); //backup current permissions $old_user = $user; $old_auth = $auth; //Load information about the current user $user->session_begin(); $auth->acl($user->data); $user->setup(); //Temporarily spoof the permissions of a Bot that has permission to post $sql = 'SELECT user_permissions FROM phpbb_users WHERE user_id = ' . $spoof_id; $dbresult = $db->sql_query($sql); $row = $db->sql_fetchrow($dbresult); $db->sql_freeresult($result); $user->data['user_permissions'] = $row['user_permissions']; //Apply the spoofed permissions $auth->acl($user->data); //This is all the inportant info about the post $data = array( 'forum_id' => $forum_num, 'icon_id' => false, 'enable_bbcode' => true, 'enable_smilies' => true, 'enable_urls' => true, 'enable_sig' => true, 'message' => $text, 'message_md5' => md5($text), 'bbcode_bitfield' => $bitfield, 'bbcode_uid' => $uid, 'post_edit_locked' => 1, 'topic_title' => $subject, 'notify_set' => false, 'notify' => false, 'post_time' => 0, 'forum_name' => '', 'enable_indexing' => true, ); //perform the actual submission submit_post('post', $subject, '', POST_NORMAL, $poll, $data); //set back original permissions $auth = $old_auth; $user = $old_user; }
Now here is the tricky part. Once that post has been made I need to know the topic_id and the post_id of the post just made for a few reasons:
1. The project page needs to be linked to the associated topic in the forum. To generate the link, I need that info
2. If the project page is edited (ie. description changed), the post needs to automatically get edited as well, and I need the topic and post id for that.
3. If the project page gets deleted, the associated topic in the forum should get locked.
So basically what I'm asking is this: after using submit_post, is there some kind of way to make it return the info about the post just made? I know I could probably use the MAX function SQL to gets the last post made, but what if somebody else makes a post at the split second that could mess it up? Should I just do that anyways and cross reference it with the username? If so, could you help me figure out the code to do that? I'd appreciate your input. Thanks!
UltimateComputers.net
^A website and forum for computer building enthusiasts and newbs!^
Source: https://www.phpbb.com/community/viewtopic.php?t=1402675
0 Response to "Phpbb Feed Id is Topic or Post"
Post a Comment