Better events for rank generation

General discussion of development ideas and the approaches taken in the 3.x branch of phpBB. The next feature release of phpBB 3 will be 3.3/Proteus.
Forum rules
Please do not post support questions regarding installing, updating, or upgrading phpBB 3.2.x. If you need support for phpBB 3.2.x please visit the 3.2.x Support Forum on phpbb.com.

If you have questions regarding writing extensions please post in Extension Writers Discussion to receive proper guidance from our staff and community.
Post Reply
peterbill
Registered User
Posts: 1
Joined: Wed Apr 24, 2019 9:25 am

Better events for rank generation

Post by peterbill »

Hi all,

I'm using a dual ranklist (users can choose their rank alignement in their profile) and while it's a trivial change editing the core files, the event system does not seem to allow for an efficient way of achieving the same thing:

forum/includes/functions_display.php, line 1546, replace:
CODE: SELECT ALL

if ($user_posts >= $rank['rank_min'])
with:
CODE: SELECT ALL

if ($user_posts >= $rank['rank_min'] && $user_data['user_rank_alignment'] == $rank['rank_alignment'])
It would be ideal if the native behaviour could be changed inside phpbb_get_user_rank rather than having to loop through all ranks a second time.

A simple idea would be to provide core.modify_user_rank with an additional argument such as a closure that could be overridden to change the way of determining if a rank 'suits' a user:

New line 1546
CODE: SELECT ALL

if ($rank_suits_user($user_data, $rank))
However I haven't seen a closure used in any of the phpBB events so that might be something the development team wants to avoid, in which case a rewriting of the phpbb_get_user_rank method would be the only solution.

Post Reply