Sortable extension events

Note: We are moving the topics of this forum and it will be deleted at some point

Publish your own request for comments/change or patches for the next version of phpBB. Discuss the contributions and proposals of others. Upcoming releases are 3.2/Rhea and 3.3.
User avatar
Pico88
Registered User
Posts: 73
Joined: Tue Apr 12, 2011 2:32 pm

Sortable extension events

Post by Pico88 »

phpBB 3.1. provides extensions system, which doesn't allow admins to change extension events order.
IMO, the ability to change the events order should be a part of extension system.

I have alreadyprepered a mockup on my localhost, which works fine.
event_1.png
(33.37 KiB) Downloaded 1789 times
event_2.png
(37.1 KiB) Downloaded 1789 times
Some explanations how it works:
The extensions events are stored in DB, so they can be move up/down and activate/deactivate.
Click "Mange events order" move us to page, where are displayed all events stored in DB. By clicking the event location, it moves us to management page.

The only problem is how to add events to DB. I think the best option for it, is adding events via migration - that will require extensions developers to define all events, which are used by their extension.

What do you think about that?

User avatar
wintstar
Registered User
Posts: 108
Joined: Sun Dec 02, 2012 1:38 pm
Location: Gießen /Hessen Germany
Contact:

Re: Sortable extension events

Post by wintstar »

+1
Greeting Stephan :-)

User avatar
nickvergessen
Former Team Member
Posts: 733
Joined: Sun Oct 07, 2007 11:54 am
Location: Stuttgart, Germany
Contact:

Re: Sortable extension events

Post by nickvergessen »

How do you think to implement this into the template engine?
Member of the Development-TeamNo Support via PM

User avatar
EXreaction
Registered User
Posts: 1555
Joined: Sat Sep 10, 2005 2:15 am

Re: Sortable extension events

Post by EXreaction »

The finder would need to be modified to sort properly. The template engine uses the finder to grab the listeners (I think).

User avatar
imkingdavid
Registered User
Posts: 1050
Joined: Thu Jul 30, 2009 12:06 pm

Re: Sortable extension events

Post by imkingdavid »

I like the concept, but we'll need to figure out the best implementation. Note that it should also be possible to disable an event from being triggered.

Should this work for both PHP events and Template events or just Template events? It makes sense to want to reorder template events because that affects visual position. But it might also be helpful to order PHP events because you might have two extensions that act on an event and need one to perform an action before or after another.
I do custom MODs. PM for a quote!
View My: MODs | Portfolio
Please do NOT contact for support via PM or email.
Remember, the enemy's gate is down.

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

Re: Sortable extension events

Post by Pico88 »

I think each template events should have small descriotion for what it is responsible for and which pages are affected.

The core event also can be sortable.
It can contain 2 headres: Core events and Template events.

I can tell that template events doesn't require so much changes but only problem is how to add them to DB.

In my mockup, when an event is disabled, the twig doesn't put its code to cache file.

User avatar
EXreaction
Registered User
Posts: 1555
Joined: Sat Sep 10, 2005 2:15 am

Re: Sortable extension events

Post by EXreaction »

What would need to be done is:
1. Find all template events
2. Find all template files included in a particular event
3. Store sorting in the database for any which are moved
4. Fetch the entire table per page (cached) and pass it to whatever is going to find/sort the events (not sure if this should/could be the finder or the template engine).

User avatar
imkingdavid
Registered User
Posts: 1050
Joined: Thu Jul 30, 2009 12:06 pm

Re: Sortable extension events

Post by imkingdavid »

Another thing I just thought of, a template event can be on separate pages and in a different page in different styles. In fact, an event could theoretically even be in the same file twice, though we should probably avoid this, and I'm not sure the best way to handle it.

On the event management page, we'll need be to able to select which style's events we are working with, and we'll need to account for that in the database when we store the event, so we'll need two tables, one to hold events and one to hold extensions' uses of the events.

Code: Select all

CREATE TABLE phpbb_event_locations (
event_id int(8) not null auto_increment,
event_name varchar(255) not null,
event_description text,
event_template_filename varchar(255) not null # should be full path from ./styles/ directory so we can differentiate between events in different styles.
);

Code: Select all

CREATE TABLE phpbb_extension_events (
extension_event_id int(8) not null auto_increment,
extension_event_ext_name varchar(255) default '' not null, # relates this to the ext_name in phpbb_ext
extension_event_order int(8) not null, # events with the same order should be served in the order they are found
extension_event_active int(1) default 1 not null # allow event location to be disabled
);
Or something like that. I haven't actually thought it through very far.
I do custom MODs. PM for a quote!
View My: MODs | Portfolio
Please do NOT contact for support via PM or email.
Remember, the enemy's gate is down.

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

Re: Sortable extension events

Post by Pico88 »

ATM I used such table

Code: Select all

CREATE TABLE IF NOT EXISTS `phpbb_ext_events` (
  `event_id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `event_name` varchar(255) COLLATE utf8_bin NOT NULL DEFAULT '',
  `event_active` tinyint(1) unsigned NOT NULL DEFAULT '0',
  `event_order` mediumint(8) unsigned NOT NULL DEFAULT '0',
  `ext_name` varchar(255) COLLATE utf8_bin NOT NULL DEFAULT '',
  PRIMARY KEY (`event_id`),
);
EDIT:
I will make a PR at the weekend.

User avatar
naderman
Consultant
Posts: 1727
Joined: Sun Jan 11, 2004 2:11 am
Location: Berlin, Germany
Contact:

Re: Sortable extension events

Post by naderman »

I don't think anything ever happened with this. I really don't think this should be based on the database. Instead we should allow extensions to specify other extensions that they have to run before/after and if they should default to the end or beginning, I think that should be enough to sort them sufficiently for extensions to work correctly.

Post Reply