core.acp_board_config_edit_add and config_text

Discussion forum for Extension Writers regarding Extension Development.
Post Reply
User avatar
Ger
Recognised Extension Developer
Posts: 1593
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 » Thu Apr 26, 2018 3:01 pm

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 and Modern Quote
Newest: Quoted Where + anonymize

Like my work? Buy me a coffee to keep it coming. :ugeek:
-Available for custom work-

User avatar
david63
Jr. Extension Validator
Posts: 14561
Joined: Thu Dec 19, 2002 8:08 am
Location: Lancashire, UK
Name: David Wood
Contact:

Re: core.acp_board_config_edit_add and config_text

Post by david63 » Thu Apr 26, 2018 3:09 pm

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!
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
kinerity
Community Team Member
Community Team Member
Posts: 1743
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Truscott
Contact:

Re: core.acp_board_config_edit_add and config_text

Post by kinerity » Thu Apr 26, 2018 5:49 pm

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 Truscott - Community Team

User avatar
Ger
Recognised Extension Developer
Posts: 1593
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 » Thu Apr 26, 2018 5:51 pm

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 and Modern Quote
Newest: Quoted Where + anonymize

Like my work? Buy me a coffee to keep it coming. :ugeek:
-Available for custom work-

User avatar
3Di
Registered User
Posts: 12753
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milan (IT) Frankfurt (DE)
Name: Marco
Contact:

Re: core.acp_board_config_edit_add and config_text

Post by 3Di » Thu Apr 26, 2018 9:12 pm

Want to compensate me for my interest? Donate
Please PM me only to request paid works. Thx.
Extensions, Scripts, MOD porting, Update/Upgrades
My development's activity º PhpStorm's proud user

User avatar
Ger
Recognised Extension Developer
Posts: 1593
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 » Fri Apr 27, 2018 7:07 am

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 and Modern Quote
Newest: Quoted Where + anonymize

Like my work? Buy me a coffee to keep it coming. :ugeek:
-Available for custom work-

User avatar
3Di
Registered User
Posts: 12753
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milan (IT) Frankfurt (DE)
Name: Marco
Contact:

Re: core.acp_board_config_edit_add and config_text

Post by 3Di » Fri Apr 27, 2018 10:06 pm

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
Want to compensate me for my interest? Donate
Please PM me only to request paid works. Thx.
Extensions, Scripts, MOD porting, Update/Upgrades
My development's activity º PhpStorm's proud user

User avatar
Ger
Recognised Extension Developer
Posts: 1593
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 » Mon Apr 30, 2018 7:57 am

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 and Modern Quote
Newest: Quoted Where + anonymize

Like my work? Buy me a coffee to keep it coming. :ugeek:
-Available for custom work-

User avatar
3Di
Registered User
Posts: 12753
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milan (IT) Frankfurt (DE)
Name: Marco
Contact:

Re: core.acp_board_config_edit_add and config_text

Post by 3Di » Mon Apr 30, 2018 8:13 am

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..
Want to compensate me for my interest? Donate
Please PM me only to request paid works. Thx.
Extensions, Scripts, MOD porting, Update/Upgrades
My development's activity º PhpStorm's proud user

User avatar
martti
Registered User
Posts: 583
Joined: Thu Jul 31, 2014 8:23 am
Location: Belgium

Re: core.acp_board_config_edit_add and config_text

Post by martti » Mon May 07, 2018 10:19 am

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: 583
Joined: Thu Jul 31, 2014 8:23 am
Location: Belgium

Re: core.acp_board_config_edit_add and config_text

Post by martti » Mon May 07, 2018 10:19 am

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
Recognised Extension Developer
Posts: 1593
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 » Mon May 07, 2018 11:46 am

@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 and Modern Quote
Newest: Quoted Where + anonymize

Like my work? Buy me a coffee to keep it coming. :ugeek:
-Available for custom work-

Post Reply

Return to “Extension Writers Discussion”

Who is online

Users browsing this forum: No registered users and 3 guests