core.acp_board_config_edit_add and config_text

Discussion forum for Extension Writers regarding Extension Development.
Post Reply
User avatar
Ger
Registered User
Posts: 2108
Joined: Wed Jan 02, 2008 7:35 pm
Location: 192.168.1.100
Contact:

core.acp_board_config_edit_add and config_text

Post by Ger »

I'd like to append a setting to core.acp_board_config_edit_add. It's a config that I've placed in config_text since it might become more than 255 characters.

I've made the migration, that added a record to phpbb_config_text table. So far so good. In my listener I added this:

Code: Select all

if ($event['mode'] == 'post')
{
    $display_vars = $event['display_vars'];            

    $add = array ('ger_magicogp_blacklist'  => array('lang' => 'MOGP_BLACKLIST', 'validate' => 'string', 'type' => 'textarea:5:30', 'explain' => true));
    $position = array_search('allowed_schemes_links', array_keys($display_vars['vars'])) + 1;
    $display_vars['vars'] = array_merge(
        array_slice($display_vars['vars'], 0, $position),
        $add,
        array_slice($display_vars['vars'], $position)
    );
    $event['display_vars'] = $display_vars;
}
That kind of works, however: when I submit the ACP page there isn't anything stored in phpbb_config_text, yet I see a new record in phpbb_config table. I kind of was afraid for something like that. :P

Is there a way to specify that config vars should go in phpbb_config_text?
My extensions:
Simple CMS, Feed post bot, Avatar Resize, Modbreak, Magic OGP, Live topic update, Modern Quote, Quoted Where (GDPR) and Autoresponder.
Newest: FAQ manager for 3.2

Like my work? Buy me a coffee to keep it coming. :ugeek:

-Don't PM me for support-
User avatar
david63
Registered User
Posts: 20646
Joined: Thu Dec 19, 2002 8:08 am

Re: core.acp_board_config_edit_add and config_text

Post by david63 »

Ger wrote: Thu Apr 26, 2018 3:01 pm Is there a way to specify that config vars should go in phpbb_config_text?
Yes

Does this help - https://area51.phpbb.com/docs/dev/3.2.x ... _text.html
David
Remember: You only know what you know and - you don't know what you don't know!

I now no longer support any of my extensions but they will start to become available here
User avatar
Kailey
Community Team Leader
Community Team Leader
Posts: 3732
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Snay
Contact:

Re: core.acp_board_config_edit_add and config_text

Post by Kailey »

Ger wrote: Thu Apr 26, 2018 3:01 pm

Code: Select all

    $position = array_search('allowed_schemes_links', array_keys($display_vars['vars'])) + 1;
    $display_vars['vars'] = array_merge(
        array_slice($display_vars['vars'], 0, $position),
        $add,
        array_slice($display_vars['vars'], $position)
    );
I'm sure you know this, but this whole section right here can be replaced with the phpbb_insert_config_array() function. Have a look here.
Kailey Snay - Community Team Leader
Knowledge Base | Documentation | Community rules

If you have any questions about the rules/customs of this website, feel free to send me a PM.
User avatar
Ger
Registered User
Posts: 2108
Joined: Wed Jan 02, 2008 7:35 pm
Location: 192.168.1.100
Contact:

Re: core.acp_board_config_edit_add and config_text

Post by Ger »

Yeah I've got that part sorted al ready, I mean how to specify it in the display_vars array within the event
My extensions:
Simple CMS, Feed post bot, Avatar Resize, Modbreak, Magic OGP, Live topic update, Modern Quote, Quoted Where (GDPR) and Autoresponder.
Newest: FAQ manager for 3.2

Like my work? Buy me a coffee to keep it coming. :ugeek:

-Don't PM me for support-
User avatar
3Di
I've Been Banned!
Posts: 17538
Joined: Mon Apr 04, 2005 11:09 pm
Location: I'm with Ukraine 🇺🇦
Name: Marco
Contact:

Re: core.acp_board_config_edit_add and config_text

Post by 3Di »

🆓 Free support for our extensions also provided here: phpBB Studio
🚀 Looking for a specific feature or alternative option? We will rock you!
Please PM me only to request paid works. Thx. Buy me a coffee -> Image
My development's activity º PhpStorm's proud user º Extensions, Scripts, MOD porting, Update/Upgrades
User avatar
Ger
Registered User
Posts: 2108
Joined: Wed Jan 02, 2008 7:35 pm
Location: 192.168.1.100
Contact:

Re: core.acp_board_config_edit_add and config_text

Post by Ger »

I know, but that does nothing within this event.

I know config text, used it many times already but only in dedicated modules or functions. I though it would be better for a simple config setting to as it to the posting mode in the board module instead of creating an entire module for just 1 setting.

I guess it's not possible.
My extensions:
Simple CMS, Feed post bot, Avatar Resize, Modbreak, Magic OGP, Live topic update, Modern Quote, Quoted Where (GDPR) and Autoresponder.
Newest: FAQ manager for 3.2

Like my work? Buy me a coffee to keep it coming. :ugeek:

-Don't PM me for support-
User avatar
3Di
I've Been Banned!
Posts: 17538
Joined: Mon Apr 04, 2005 11:09 pm
Location: I'm with Ukraine 🇺🇦
Name: Marco
Contact:

Re: core.acp_board_config_edit_add and config_text

Post by 3Di »

I see, the event you are using, as you certainly know, doesn't effectively allow to use a different clone than the $config object.
There are no other events available in case you would want to clone the config_text Object, if applicable.

If your config is somethig that could be set on a per forum basis I suggest you to use ACP Forums's events instead
https://github.com/phpBB-Studio/DateTop ... hp#L82-L84
https://github.com/phpBB-Studio/DateTop ... #L360-L418

I am using the forums table here though.
https://github.com/phpBB-Studio/DateTop ... hp#L35-L37
🆓 Free support for our extensions also provided here: phpBB Studio
🚀 Looking for a specific feature or alternative option? We will rock you!
Please PM me only to request paid works. Thx. Buy me a coffee -> Image
My development's activity º PhpStorm's proud user º Extensions, Scripts, MOD porting, Update/Upgrades
User avatar
Ger
Registered User
Posts: 2108
Joined: Wed Jan 02, 2008 7:35 pm
Location: 192.168.1.100
Contact:

Re: core.acp_board_config_edit_add and config_text

Post by Ger »

It's just a global list of blacklisted domains for the Magic OGP extension, not per forum or anything like that.

Unfortunately it's not possible in a straightforward way. So that leaves me with an option to either make a dedicated table for this or a dedicated module. I'll think about the best approach...

Thanks for the help. :)
My extensions:
Simple CMS, Feed post bot, Avatar Resize, Modbreak, Magic OGP, Live topic update, Modern Quote, Quoted Where (GDPR) and Autoresponder.
Newest: FAQ manager for 3.2

Like my work? Buy me a coffee to keep it coming. :ugeek:

-Don't PM me for support-
User avatar
3Di
I've Been Banned!
Posts: 17538
Joined: Mon Apr 04, 2005 11:09 pm
Location: I'm with Ukraine 🇺🇦
Name: Marco
Contact:

Re: core.acp_board_config_edit_add and config_text

Post by 3Di »

I was thinking about to use the same event as a simple "hook" instead, I mean not using the ($event) parameter and the related $config's validation procedure. A bit tricky, I know, and I really haven't had the time to put some effort on this due to my scheduled duties. Have a look..
🆓 Free support for our extensions also provided here: phpBB Studio
🚀 Looking for a specific feature or alternative option? We will rock you!
Please PM me only to request paid works. Thx. Buy me a coffee -> Image
My development's activity º PhpStorm's proud user º Extensions, Scripts, MOD porting, Update/Upgrades
User avatar
martti
Registered User
Posts: 911
Joined: Thu Jul 31, 2014 8:23 am
Location: Belgium

Re: core.acp_board_config_edit_add and config_text

Post by martti »

You can inject \phpbb\config\db_text in the constructor in the class where you need it.

i.e your listener:

Code: Select all

public function __construct(\phpbb\config\db_text $config_text)
{
	$this->config_text = $config_text;
}
in service.yml:

Code: Select all

    vendorname.extensionname.event.my_listener:
        class: vendorname\extensionname\event\my_listener
        arguments:
            - '@config_text'
Then you can use it in your listener (or other class):

Code: Select all

$this->config_text('my_storage_key', $my_long_data_string);
...
$my_long_data_string = $this->config_text->get('my_storage_key');
User avatar
martti
Registered User
Posts: 911
Joined: Thu Jul 31, 2014 8:23 am
Location: Belgium

Re: core.acp_board_config_edit_add and config_text

Post by martti »

You can inject \phpbb\config\db_text in the constructor of the class where you need it.

i.e your listener:

Code: Select all

public function __construct(\phpbb\config\db_text $config_text)
{
	$this->config_text = $config_text;
}
in service.yml:

Code: Select all

    vendorname.extensionname.event.my_listener:
        class: vendorname\extensionname\event\my_listener
        arguments:
            - '@config_text'
Then you can use it in your listener (or other class):

Code: Select all

$this->config_text('my_storage_key', $my_long_data_string);
//
$my_long_data_string = $this->config_text->get('my_storage_key');
User avatar
Ger
Registered User
Posts: 2108
Joined: Wed Jan 02, 2008 7:35 pm
Location: 192.168.1.100
Contact:

Re: core.acp_board_config_edit_add and config_text

Post by Ger »

@martti:
Thanks, but like I wrote that's not what Iḿ looking for. I know how to work around this, I was just looking for a more simple approach.
My extensions:
Simple CMS, Feed post bot, Avatar Resize, Modbreak, Magic OGP, Live topic update, Modern Quote, Quoted Where (GDPR) and Autoresponder.
Newest: FAQ manager for 3.2

Like my work? Buy me a coffee to keep it coming. :ugeek:

-Don't PM me for support-
Post Reply

Return to “Extension Writers Discussion”