No way to save extra group settings?

Discussion forum for Extension Writers regarding Extension Development.
Post Reply
User avatar
MarkDHamill
Registered User
Posts: 4342
Joined: Fri Aug 02, 2002 12:36 am
Location: Florence, MA USA
Contact:

No way to save extra group settings?

Post by MarkDHamill »

Before I file a bug report on this, want to make sure I'm right.

As best I can tell on the ACP Group settings page, you can add extra fields on the screen at appropriate events, you can't actually use the same screen to save any of these new fields to the database. Events are there that look like they should work, such as core.acp_manage_group_initialise_data.

But these settings are stored to the phpbb_groups table in /includes/functions_user.php in function group_create() on line 2289. The settings are stored starting at line 2426:

Code: Select all

			$sql = 'UPDATE ' . GROUPS_TABLE . '
				SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "
				WHERE group_id = $group_id";
			$db->sql_query($sql);
but $sql_ary is given a defined array starting on line 2380:

Code: Select all

		$sql_ary = array(
			'group_name'			=> (string) $name,
			'group_desc'			=> (string) $desc,
			'group_desc_uid'		=> '',
			'group_desc_bitfield'	=> '',
			'group_type'			=> (int) $type,
		);
So it appears there is no way to inject any values from new form fields on the group settings page so that they'll be stored to the database.

I assume if you want to do this you have to write your own interface somewhere else, such as in an ACP controller.
Need phpBB services or a phpBB consultant? I offer most phpBB services. Getting lost managing phpBB? Buy my book, Mastering phpBB Administration. eBook and paper versions available.
User avatar
KaileyT
Community Team Member
Community Team Member
Posts: 2898
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Truscott
Contact:

Re: No way to save extra group settings?

Post by KaileyT »

It's old, but it's still correct. Have a look at the example here. Let me know if something doesn't make sense.
postcountrequirements event listener - L107-L128
Kailey Truscott - Community Team
User avatar
david63
Registered User
Posts: 18821
Joined: Thu Dec 19, 2002 8:08 am
Location: Lancashire, UK
Contact:

Re: No way to save extra group settings?

Post by david63 »

Line 2397 of group_create() is $sql_ary = array_merge($sql_ary, $group_attributes); and $group_attributes contains the data from core.acp_manage_group_initialise_data on line 571 $group_attributes['group_' . $test] = $group_row['group_' . $test] = $submit_ary[$test]; so as long as you are returning the $submit_ary from your listener I cannot see why there should be a problem.
David
Remember: You only know what you know and - you don't know what you don't know!
My CDB Contributions | How to install an extension
I will not be accepting translations for any of my extensions in Github - please post any translations in the appropriate topic.
No support requests via PM or email as they will be ignored
User avatar
MarkDHamill
Registered User
Posts: 4342
Joined: Fri Aug 02, 2002 12:36 am
Location: Florence, MA USA
Contact:

Re: No way to save extra group settings?

Post by MarkDHamill »

Thanks. I feel better. I added the $test_variables and $submit_ary arrays to my code, but added both using the core.acp_manage_group_initialise_data event, it just wouldn't work. It's a bit confusing to me the difference between the core.acp_manage_group_initialise_data and core.acp_manage_group_initialise_data events. Nothing I tried would work.
Need phpBB services or a phpBB consultant? I offer most phpBB services. Getting lost managing phpBB? Buy my book, Mastering phpBB Administration. eBook and paper versions available.
User avatar
RMcGirr83
Former Team Member
Posts: 21821
Joined: Wed Jun 22, 2005 4:33 pm
Location: Your display
Name: Rich McGirr

Re: No way to save extra group settings?

Post by RMcGirr83 »

MarkDHamill wrote:
Thu Nov 26, 2020 2:08 pm
It's a bit confusing to me the difference between the core.acp_manage_group_initialise_data and core.acp_manage_group_initialise_data events. Nothing I tried would work.
These are the same events...no?
Former Modifications/Extensions Team Member | My extensions | github | All requests for support via PM will be ignored
Appreciate the extensions/mods/support then buy me a beerImage
User avatar
david63
Registered User
Posts: 18821
Joined: Thu Dec 19, 2002 8:08 am
Location: Lancashire, UK
Contact:

Re: No way to save extra group settings?

Post by david63 »

RMcGirr83 wrote:
Thu Nov 26, 2020 3:08 pm
These are the same events...no?
Look the same to me

Perhaps Mark has had a drop too much Thanksgiving "pop" ;) ;)
David
Remember: You only know what you know and - you don't know what you don't know!
My CDB Contributions | How to install an extension
I will not be accepting translations for any of my extensions in Github - please post any translations in the appropriate topic.
No support requests via PM or email as they will be ignored
User avatar
MarkDHamill
Registered User
Posts: 4342
Joined: Fri Aug 02, 2002 12:36 am
Location: Florence, MA USA
Contact:

Re: No way to save extra group settings?

Post by MarkDHamill »

Whoops, sorry. core.acp_manage_group_request_data and core.acp_manage_group_initialise_data. Also, it's unintuitive that $test_variables and $submit_ary assume "group_" as a prefix.

Haven't hit the sauce yet today, but the day is still young. ;-)
Need phpBB services or a phpBB consultant? I offer most phpBB services. Getting lost managing phpBB? Buy my book, Mastering phpBB Administration. eBook and paper versions available.
Post Reply

Return to “Extension Writers Discussion”