[PHP] core.acp_manage_groups_request_data

These requests for events in core phpBB have been merged into 3.1/Ascraeus and will be available with the next release.
User avatar
tbackoff
Registered User
Posts: 180
Joined: Sat Jun 12, 2010 3:25 am

[PHP] core.acp_manage_groups_request_data

Post by tbackoff »

Need an PHP event to add data to the submit_ary(). Should take two parameters - action (add/edit) and submit_ary (data to be added to the array). Location is after the following code in /includes/acp/acp_groups.php:

Code: Select all

					$submit_ary = array(
						'colour'			=> request_var('group_colour', ''),
						'rank'				=> request_var('group_rank', 0),
						'receive_pm'		=> isset($_REQUEST['group_receive_pm']) ? 1 : 0,
						'legend'			=> isset($_REQUEST['group_legend']) ? 1 : 0,
						'teampage'			=> isset($_REQUEST['group_teampage']) ? 1 : 0,
						'message_limit'		=> request_var('group_message_limit', 0),
						'max_recipients'	=> request_var('group_max_recipients', 0),
						'founder_manage'	=> 0,
						'skip_auth'			=> request_var('group_skip_auth', 0),
					);
The only problem is furter down, there is another array that defines the type for each variable (int, string).

Code: Select all

						$test_variables = array(
							'rank'			=> 'int',
							'colour'		=> 'string',
							'avatar'		=> 'string',
							'avatar_type'	=> 'string',
							'avatar_width'	=> 'int',
							'avatar_height'	=> 'int',
							'receive_pm'	=> 'int',
							'legend'		=> 'int',
							'teampage'		=> 'int',
							'message_limit'	=> 'int',
							'max_recipients'=> 'int',
							'founder_manage'=> 'int',
							'skip_auth'		=> 'int',
						);
Not sure if we will need a second event here or not.

User avatar
tbackoff
Registered User
Posts: 180
Joined: Sat Jun 12, 2010 3:25 am

Re: [PHP] core.acp_manage_groups_request_data

Post by tbackoff »

Bump. The template event that was added to the core requires this PHP event. I imagine the above to sections will need one, along with the template->assign_vars section. I tried on my own and am failing miserably.

User avatar
Pico88
Registered User
Posts: 73
Joined: Tue Apr 12, 2011 2:32 pm

Re: [PHP] core.acp_manage_groups_request_data

Post by Pico88 »

Have a look how it is done in acp_forums.php ;)

User avatar
tbackoff
Registered User
Posts: 180
Joined: Sat Jun 12, 2010 3:25 am

Re: [PHP] core.acp_manage_groups_request_data

Post by tbackoff »

I did and still couldn't get it done.

Side note - I may have made the correct edits to the PHP file, but when I clicked the checkbox that my extension adds, it would say it updated successfully, but the checkbox would remain unchecked. Is there an extension in development that utilized the forums PHP events? I had a quick look last night and couldn't find one.

User avatar
Pico88
Registered User
Posts: 73
Joined: Tue Apr 12, 2011 2:32 pm

Re: [PHP] core.acp_manage_groups_request_data

Post by Pico88 »

I used it - not published yet.

Code: Select all

	/**
	* Add reputation request data
	*
	* @param object $event The event object
	* @return null
	* @access public
	*/
	public function forum_reputation_request($event)
	{
		$forum_data = $event['forum_data'];
		$forum_data['reputation_enabled'] = $this->request->variable('reputation_enabled', 0);
		$event['forum_data'] = $forum_data;
	}

	/**
	* Assign reputation data to template
	*
	* @param object $event The event object
	* @return null
	* @access public
	*/
	public function forum_display_reputation($event)
	{
		$template_data = $event['template_data'];
		$template_data['S_ENABLE_REPUTATION'] = $event['forum_data']['reputation_enabled'];
		$event['template_data'] = $template_data;
	}
And event assign

Code: Select all

			'core.acp_manage_forums_request_data'		=> 'forum_reputation_request',
			'core.acp_manage_forums_display_form'		=> 'forum_display_reputation',

User avatar
tbackoff
Registered User
Posts: 180
Joined: Sat Jun 12, 2010 3:25 am

Re: [PHP] core.acp_manage_groups_request_data

Post by tbackoff »

Thanks! I'll give it a go tonight or tomorrow.

User avatar
tbackoff
Registered User
Posts: 180
Joined: Sat Jun 12, 2010 3:25 am

Re: [PHP] core.acp_manage_groups_request_data

Post by tbackoff »

Still having trouble. Can you check and see if I'm doing this right? I have a feeling one of the two is wrong, just not sure which one.

/includes/acp/acp_groups.php changes

Extension: Post Count Requirements

User avatar
Pico88
Registered User
Posts: 73
Joined: Tue Apr 12, 2011 2:32 pm

Re: [PHP] core.acp_manage_groups_request_data

Post by Pico88 »

The acp_group_options_display_form works fine but require important change - just replace group_data with group_row ;)
The event code should look like:

Code: Select all

$template_data['GROUP_BYPASS_PCR'] = $event['group_row']['group_bypass_pcr'] ? 'checked="checked"' : '';
I have to go. Later I will check request event.

EDIT:
Checked. There should one more event after $test_variables = array(...); ;)

We need to check our variable and put it to group attributes

User avatar
tbackoff
Registered User
Posts: 180
Joined: Sat Jun 12, 2010 3:25 am

Re: [PHP] core.acp_manage_groups_request_data

Post by tbackoff »

Is this right now? updated branch

As for the event in the listener:

Code: Select all

    'core.acp_group_options_initialise_data'    => 'group_options_data',
// snip
    public function group_options_data($event)
    {
        $test_variables = $event['test_variables'];
        $test_variables['group_bypass_pcr'] = // <~~ what goes here?
        $event['test_variables'] = $test_variables;
    }

User avatar
Pico88
Registered User
Posts: 73
Joined: Tue Apr 12, 2011 2:32 pm

Re: [PHP] core.acp_manage_groups_request_data

Post by Pico88 »

Shall I create a ticket and PR? Or the ticket is already created?

Post Reply