Page 1 of 6

Avatars via phpBB group Avatar

Posted: Mon May 08, 2017 6:50 am
by Lepalose
Hi, let me first say pretty solid plugin you have written, so thanks for the work on it!

Now to the issue...
May 7th, 2017 - WP_w3all Version 1.7.0

  • With phpBB group avatars set on the forums, on wordpress the WP_w3all plugin show a broken link for users with no personal avatar uploaded
Detailed issue:
On my phpBB forums I am using "Group Avatars" when users have not set their own avatar
(via phpBB ACP --> Users & Groups --> Groups/Manage Groups: {Group Avatar})

WP_w3all provides a widget on WordPress to login, as well as show posts, etc. with the associated avatars.

This works when the phpBB user has uploaded their own image to the phpBB forum. This creates the avatar file that WP_w3all is fetching.

When a user has not uploaded their own avatar, but group avatars are set, WP_w3all tries to fetch the avatar for the user from a file pathway based on the user id, and not the phpBB logic in determining the avatar.

By going to to broken image URL you get a phpBB forum error page with:
No route found for "GET /images/avatars/upload/<some userID>_0.png" (from "http://<URL of requesting page with broken image>")

The issue is with the definition being used in the WP plugin on lines 1347-1351 of /wp-w3all-phpbb-integration/class.wp.w3all-phpbb.php file

Code: Select all

 	$avatar_entry = $user_ava->user_avatar;
            $ext = substr(strrchr($avatar_entry, '.'), 1);
	          $avatar_entry	= intval($avatar_entry);
	          $phpbb_avatar_filename = $phpbb_config["avatar_salt"] . '_' . $avatar_entry . '.' . $ext;
            $phpbb_avatar_url = get_option( 'w3all_url_to_cms' ).'/'.$phpbb_config["avatar_path"].'/'.$phpbb_avatar_filename;


THE SOLUTION

In /wp-w3all-phpbb-integration/class.wp.w3all-phpbb.php

Old line 1349:

Code: Select all

 $avatar_entry	= intval($avatar_entry);
Replaced line with:

Code: Select all

$avatar_entry = strtok($avatar_entry, '_');

For group-set avatars, the $avatar_entry takes the form like "g10_0000HASHEDKEY0000.png", note that the entry starts with a 'g' character. Using strtok($avatar_entry,'_') the avatar id before '_' is returned in full as a string, which in this case would be 'g10' that is then used to get the correct image location. The old code using intval would produce a '0' and give an incorrect image location.


If you needed a group avatar fix for WP_w3all fix, I hope this helps you as well!

Re: Avatars via phpBB group Avatar

Posted: Mon May 08, 2017 2:35 pm
by axew3
Oh nice!?! Yes thank you for report and appreciation.
Would like to mention that only posts/hits like this let improve the plugin in short time: i can't really test any situation possible, because it require more time than write the code and to be honest, i confess ... i even do not know, or i've lost it along the time somewhere, that exist an avatar group in phpBB! ops ... what shame
So it will be added as soon, as patch of 1.7.1. Taking a look into, i hope it will not be so hard, so I will inform in any case also you here when patch to 1.7.1 has been applied to fix this or any going on.

1.7.1 is coming today to resolve this in the while:

= 1.7.1 =
*Release Date - 8 May, 2017*

Code: Select all

* Fix users addition error on MSMU: see https://wordpress.org/support/topic/1-7-0-released/#post-9106748
* Tested to fix adding/registering/login users into WP default, WP Network Multisite, Buddypress (and presumably any other plugin that use signups). Not add all profile fields update for Buddypress, that will be done (hope) on 1.7.2. 
* Fix cookie setting to be detected and setup one time, not at 'runtime' at each page load, that was since 1.7.0, and correct detect of cookie setting for any www existent domain (for advanced -> see new function: w3all_extract_cookie_domain() on wp_w3all.php).
* Added manual setting on wp_w3all.php to force plugin deactivation if necessary, to make possible a clean uninstall of the plugin even on most worse situations or just for testing purpose. This is completely redundant and not needed, if the plugin is installed using phpBB custom manual config.php, because you can deactivate the plugin within this file instead (as explained on inline hints in file, and as maybe you already know)). A documentation help for common problems about will be done asap (if never necessary for someone).
* Added manual setting on wp_w3all.php also for cookie to force cookie setting change.

Re: Avatars via phpBB group Avatar

Posted: Mon May 08, 2017 9:20 pm
by Lepalose
Further testing of this problem reveals a further issue.

The solution above is a fix to show a logged-in user's own Group Avatar correctly on WP - both on the sidebar widgets, in comments, etc. etc.


The issue now is that it does not display Group Avatars for other users! Users with a Group Avatar, who are not the current user, will have the default WordPress assigned avatar instead. A non-logged in user for instance, will not see any Group Avatars.

Working on trying to isolate this issue that is separate than the solution above.

Re: Avatars via phpBB group Avatar

Posted: Mon May 08, 2017 10:45 pm
by axew3
i'm over right now, but i'm experiencing this, that stop me at moment:

in phpBB, now that i've setup for registered users, group avatar on ACP, this happen:
avatar of the group is shown on related member/group list page on top.
So i've reset the default avatar for a test user to not have an avatar.
But no avatar of the group display for this user, in place of the one that the user have not setup.
So i can't see the joke how work on db at moment!
Sorry stupid question, sure that an avatar group is shown for user, if he have not choose one in phpBB? Or asking my self what i'm doing wrong ...

p.s sure yes it is ... so i think there is in case some problem here on my install: before to display gallery i had to clean cache and add two galleries: one was not showed, even if correctly named... and some error about twig on log ...

Re: Avatars via phpBB group Avatar

Posted: Mon May 08, 2017 11:37 pm
by Lepalose
On phpBB, for a group avatar to be selected and used for a user, you must make certain that it is the group default for the user.
ACP--> Users and Groups --> Manage Users --> {Select test user} --> Select form: Groups

There is a separate phpBB issue with Group Avatars - if you delete an individual user's avatar (you can even delete an individual user's Group Avatar), it sets the MySQL phpbb_users DB values for the user of 'user_avatar' and 'user_avatar_type' to "". In this situation, you can make the user a default member of another group, then return to being the default member of desired group to reset the Group Avatar.

When managing users on phpBB you can quickly checkthat the user's Group Avatar is working or not just by checking ACP--> Users and Groups --> Manage Users --> {Select test user} --> Select form: Avatar.



I have not looked too much into the phpBB code of this, but for Group Avatars, but I believe when you change a user's Default Group it does a check to see if that group has an avatar AND if the user does not have an avatar. If both are true, it sets the MySQL phpbb_users DB values for the user of 'user_avatar' and 'user_avatar_type' to the values determine for the Group Avatar.

I hope that helps.

Re: Avatars via phpBB group Avatar

Posted: Tue May 09, 2017 7:06 am
by axew3
nope, it is just that i see old users aren't updated ... in fact i've register after a new user, and he result with avatar now.
So finally today i can start a test