submit_post() question

Discussion of general topics related to the new version and its place in the world. Don't discuss new features, report bugs, ask for support, et cetera. Don't use this to spam for other boards or attack those boards!
Forum rules
Discussion of general topics related to the new release and its place in the world. Don't discuss new features, report bugs, ask for support, et cetera. Don't use this to spam for other boards or attack those boards!
User avatar
reboots
Registered User
Posts: 11
Joined: Sat Dec 30, 2006 9:58 am
Contact:

submit_post() question

Post by reboots » Sun Mar 25, 2007 4:08 pm

I tried to insert news postin my test forum with

Code: Select all

define('IN_PHPBB', true);
$phpbb_root_path = '../../phpBB/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);

include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
include($phpbb_root_path . 'includes/message_parser.' . $phpEx);


$user->session_begin();
$auth->acl($user->data);
$user->setup();

 
$my_subject  	= utf8_normalize_nfc('subject');
$my_text	= utf8_normalize_nfc('message text');
			

$poll = $uid = $bitfield = $options = ''; 

generate_text_for_storage($my_subject, $uid, $bitfield, $options, false, false, false);
generate_text_for_storage($my_text, $uid, $bitfield, $options, true, true, true);
				
$data = array( 
	'forum_id'		=> 2,
	'icon_id'		=> false,

	'enable_bbcode'	=> true,
	'enable_smilies'	=> true,
	'enable_urls'		=> true,
	'enable_sig'		=> true,
					
	'message'		=> $my_text,
	'message_md5'	=> md5($my_text),
				
	'bbcode_bitfield'	=> $bitfield,
	'bbcode_uid'		=> $uid,
			
	'post_edit_locked'	=> 0,
	'topic_title'		=> $my_subject,
	'notify_set'		=> false,
	'notify'			=> false,
	'post_time' 		=> 0,
	'forum_name'		=> '',
	'enable_indexing'	=> true,
);

				
submit_post('post', $my_subject, '', POST_NORMAL, $poll, $data);
But the post is marked as "This post is waiting for approval" and isn't posted by logged user but "guest":?
Immagine.jpg
(17.36 KiB) Downloaded 7083 times
How I can solve?

Tnx in advance ;)
Free software compression?............. http://www.zippho.org

User avatar
Handyman
Registered User
Posts: 522
Joined: Thu Feb 03, 2005 5:09 am
Location: Where no man has gone before!
Contact:

Re: submit_post() question

Post by Handyman » Sun Mar 25, 2007 5:11 pm

When you post it, you have to fill the user details… otherwise by default… I believe it shows as guest.
Also, you don't need to include the message_parser at the top of the page, since you are using functions instead.
My phpBB3 Mods || My Mod Queue
Search Engine Friendly (SEO) URLs || Profile link on Avatar and/or Username || AJAX Chat
Display Posts Anywhere || CashMod || AJAX Quick Edit || AJAX Quick Reply

Image

User avatar
Kellanved
Former Team Member
Posts: 407
Joined: Sun Jul 30, 2006 4:59 pm
Location: Berlin

Re: submit_post() question

Post by Kellanved » Sun Mar 25, 2007 5:43 pm

The MOD docs are starting to take shape :D
http://www.phpbb.com/mods/documentation/


submit_post always uses the currently logged in user - we plan to supply a more flexible post insertion method.
No support via PM.
Trust me, I'm a doctor.

User avatar
reboots
Registered User
Posts: 11
Joined: Sat Dec 30, 2006 9:58 am
Contact:

Re: submit_post() question

Post by reboots » Sun Mar 25, 2007 5:56 pm

I have read it ;)

I tried to insert login code before posting

Code: Select all

$auth->login('username','**pwd**');
The topic now is correctly assigned on logged poster but I still have the problem that the topic is marked "This post is waiting for approval" :(

How I can approve directly the topic?

In the documentation I haven't found nothing about this.

Tnx :D
Free software compression?............. http://www.zippho.org

User avatar
jojobarjo32
Registered User
Posts: 164
Joined: Wed Jun 22, 2005 7:38 pm
Location: France

Re: submit_post() question

Post by jojobarjo32 » Sun Mar 25, 2007 6:40 pm

Have you checked the permissions of the forum with ID 2 ?

User avatar
reboots
Registered User
Posts: 11
Joined: Sat Dec 30, 2006 9:58 am
Contact:

Re: submit_post() question

Post by reboots » Sun Mar 25, 2007 6:59 pm

jojobarjo32 wrote: Have you checked the permissions of the forum with ID 2 ?



Yes :?
Free software compression?............. http://www.zippho.org

User avatar
Lastof
Registered User
Posts: 518
Joined: Wed Mar 17, 2004 8:10 pm
Location: Two weeks last wednesday
Contact:

Re: submit_post() question

Post by Lastof » Mon Mar 26, 2007 8:27 am

What is "post_approved" set to?
Last edited by Lastof on 04 May 2008, 00:00, edited -1 times in total
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Look, I'm officially not a bug!!
SHS`: "Oooh Bertie, spank me with that casing stick, spank me spank me spaaaaannnnk mee!"
Image

User avatar
reboots
Registered User
Posts: 11
Joined: Sat Dec 30, 2006 9:58 am
Contact:

Re: submit_post() question

Post by reboots » Mon Mar 26, 2007 11:21 am

Lastof wrote: What is "post_approved" set to?


Where I can set this? :roll:
Free software compression?............. http://www.zippho.org

User avatar
Lastof
Registered User
Posts: 518
Joined: Wed Mar 17, 2004 8:10 pm
Location: Two weeks last wednesday
Contact:

Re: submit_post() question

Post by Lastof » Mon Mar 26, 2007 3:21 pm

It's in the posts table, same as the others you are setting.
Last edited by Lastof on 04 May 2008, 00:00, edited -1 times in total
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Look, I'm officially not a bug!!
SHS`: "Oooh Bertie, spank me with that casing stick, spank me spank me spaaaaannnnk mee!"
Image

User avatar
reboots
Registered User
Posts: 11
Joined: Sat Dec 30, 2006 9:58 am
Contact:

Re: submit_post() question

Post by reboots » Mon Mar 26, 2007 7:53 pm

Lastof wrote: It's in the posts table, same as the others you are setting.


"post_approved" flag is calculate in function submit_post() around line 1441

Code: Select all

'post_approved'		=> (!$auth->acl_get('f_noapprove', $data['forum_id']) && !$auth->acl_get('m_approve', $data['forum_id'])) ? 0 : 1,

therefore it is useless set it on $data array ;)
Free software compression?............. http://www.zippho.org

Post Reply