How to inverse avatar_drivers?

Need some custom code changes to the phpBB core simple enough that you feel doesn't require an extension? Then post your request here so that community members can provide some assistance.

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Post Reply
User avatar
Tarantino
Registered User
Posts: 658
Joined: Sat Feb 18, 2012 1:51 pm
Contact:

How to inverse avatar_drivers?

Post by Tarantino » Sat Feb 24, 2018 1:24 pm

Hi there,

on UCP, when we want to change avatars on the dropdown list where we've Upload Avatar option, my html uses "avatar_drivers" variable.

I want to know how can I inverse the order of that list. Right now its Ascending (a->z), I want to put Descending (z->a)

How can I acheive that?

It can be with core edits.

User avatar
stevemaury
Support Team Member
Support Team Member
Posts: 49445
Joined: Thu Nov 02, 2006 12:21 am
Location: The U.P.
Name: Steve
Contact:

Re: How to inverse avatar_drivers?

Post by stevemaury » Sat Feb 24, 2018 2:40 pm

You mean you want those four options, which are all easily visible at once, to start with "Upload avatar" instead of "Gravatar"?
For REALLY good and VERY inexpensive hosting CLICK HERE

I can stop all your spam. PM or email me.

All unsolicited PMs will be ignored.

User avatar
Tarantino
Registered User
Posts: 658
Joined: Sat Feb 18, 2012 1:51 pm
Contact:

Re: How to inverse avatar_drivers?

Post by Tarantino » Sat Feb 24, 2018 5:51 pm

Exactly.

jackennils
Registered User
Posts: 176
Joined: Mon Jun 01, 2009 7:48 pm

Re: How to inverse avatar_drivers?

Post by jackennils » Sat Feb 24, 2018 11:24 pm

Same here, would like to change the order as well.

User avatar
Tarantino
Registered User
Posts: 658
Joined: Sat Feb 18, 2012 1:51 pm
Contact:

Re: How to inverse avatar_drivers?

Post by Tarantino » Sun Feb 25, 2018 1:25 am

With core edits:

/includes/ucp/ucp_profile.php

Find: $avatar_drivers = $phpbb_avatar_manager->get_enabled_drivers();
Replace with: $avatar_drivers = array_reverse($phpbb_avatar_manager->get_enabled_drivers());

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

Re: How to inverse avatar_drivers?

Post by 3Di » Sun Feb 25, 2018 1:31 am

Questions like this should be posted in the Custom Coding forum, created on purpose.

On a side note I don't see the above suggestion as the right one.
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
stevemaury
Support Team Member
Support Team Member
Posts: 49445
Joined: Thu Nov 02, 2006 12:21 am
Location: The U.P.
Name: Steve
Contact:

Re: How to inverse avatar_drivers?

Post by stevemaury » Sun Feb 25, 2018 1:44 am

Can I ask why?
For REALLY good and VERY inexpensive hosting CLICK HERE

I can stop all your spam. PM or email me.

All unsolicited PMs will be ignored.

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

Re: How to inverse avatar_drivers?

Post by 3Di » Sun Feb 25, 2018 1:53 am

That list is managed elsewhere, see forumroot/phpbb/avatar/manager.php, function load_enabled_drivers() just to begin with, array indices should maintain their correlation with the array elements they are associated with, that's why uses asort().
That array_reverse() hack should be set to true at least.
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
Tarantino
Registered User
Posts: 658
Joined: Sat Feb 18, 2012 1:51 pm
Contact:

Re: How to inverse avatar_drivers?

Post by Tarantino » Sun Feb 25, 2018 4:37 am

My edit worked.
And I don't see any post with a better solution.

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

Re: How to inverse avatar_drivers?

Post by 3Di » Tue Feb 27, 2018 4:06 pm

Tarantino wrote:
Sun Feb 25, 2018 4:37 am
My edit worked.
And I don't see any post with a better solution.
The post of mine above yours is the better solution. Again..
3Di wrote:
Sun Feb 25, 2018 1:53 am
That list is managed elsewhere, see forumroot/phpbb/avatar/manager.php, function load_enabled_drivers() just to begin with, array indices should maintain their correlation with the array elements they are associated with, that's why uses asort().
And here is the function

Code: Select all

	/**
	* Load the list of enabled drivers
	* This is executed once and fills self::$enabled_drivers
	*/
	protected function load_enabled_drivers()
	{
		if (!empty($this->avatar_drivers))
		{
			self::$enabled_drivers = array();
			foreach ($this->avatar_drivers as $driver)
			{
				if ($this->is_enabled($driver))
				{
					self::$enabled_drivers[$driver->get_name()] = $driver->get_name();
				}
			}
			asort(self::$enabled_drivers);
		}
	}
The line to be changed is asort(self::$enabled_drivers);

Based on this list of possible PHP function to use in order to modify that line (which excludes array_reverse() ofcourse)..
https://www.w3schools.com/Php/php_arrays_sort.asp
.. what would it be the right one for your use case?
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
Tarantino
Registered User
Posts: 658
Joined: Sat Feb 18, 2012 1:51 pm
Contact:

Re: How to inverse avatar_drivers?

Post by Tarantino » Wed Feb 28, 2018 6:48 pm

I see. arsort would be the case.

Thanks for pointing that out ;)

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

Re: How to inverse avatar_drivers?

Post by 3Di » Wed Feb 28, 2018 7:26 pm

Tarantino wrote:
Wed Feb 28, 2018 6:48 pm
I see. arsort would be the case.

Thanks for pointing that out ;)
Anytime.
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

Post Reply

Return to “phpBB Custom Coding”

Who is online

Users browsing this forum: JH14 and 5 guests