User Profile plugin + gravatar

Creating and modifying plugins.
jerwarren

User Profile plugin + gravatar

Post by jerwarren »

I've extended the user profile plugin to enable the ability to use gravatar images rather than local user image files. It doesn't cache the images like the gravatar plugin for comments does, because I think that is silly. The user can now select whether to use the local image or gravatar, and also the size of the gravatar image to be displayed.

diff here: http://nyquil.org/uploads/serendipity_e ... .php.patch
(This needs to be rightclick and saved, the browser apparently strips out all the newlines, which is new to me)
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: User Profile plugin + gravatar

Post by garvinhicking »

The caching for gravatar images was done, because gravatar.com was unstable and down for a larger time period in the past, BTW.

Thanks a lot for your patch, I just committed it to our CVS. BTW, I changed your indenting from TABS to Spaces and abstracted the language to use constants!

Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
jerwarren

Post by jerwarren »

I was under the impression that the SPARTACUS plugin was fetching plugins from CVS, but when installing this plugin now, the changes aren't in it. Am I just mistaken about how this works?

Do changes of this type not show up until the next revision of s9y?
judebert
Regular
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL
Contact:

Post by judebert »

The stuff is built on a 24-hour cycle. Just wait a bit and it'll show eventually.
jerwarren

Post by jerwarren »

awesome. Thanks for the info
jerwarren

Bugfixes + more features.

Post by jerwarren »

I forgot to actually add the gravatar size to the configuration setup, so I went ahead and fixed that. Also, I added a configuration for a default gravatar image to be displayed, and a configuration of gravatar rating level.

As, I feel it would be alot more configurable to wrap a div around the user image so that people can add background colors, borders, and reposition it, I've gone ahead and changed that as well.

If you'd like to see it in action on the test install I use to troubleshoot, check out http://balloondating.com/blog/.

Here's a patch:
serendipity_event_userprofiles.diff

That patch should make the necessary changes to both the php and the english language includes, but I'm new to this whole patchmaking thing. My apolgies if it doesn't work like it is supposed to.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Bugfixes + more features.

Post by garvinhicking »

Great, your patch was perfect! I committed it as is! :)

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
jerwarren

user profile?

Post by jerwarren »

While looking through the code in the plugin, there appears to be a huge amount of options such as AIM, Yahoo, Skype, etc. Is that a planned feature that never made it to the plugin release? There are many, many things the plugin thinks a user ought to be able to specify, but I can't figure out how one would specify them.

I figured I would ask before I start tinkering around trying to "finish" the plugin..
jerwarren

figured it out

Post by jerwarren »

i just noticed the 'profiles' link on the admin page, which answered my question, but raised another.

There currently doesn't appear to be a way for a non-admin user to edit their own profile.

In order to achieve this, would the best plan of action be to have the profile plugin add options to the 'personal settings' page?
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: figured it out

Post by garvinhicking »

That's a very good suggestion. And quite easy to implement, actually.

Just edit your include/admin/personal.inc.php file, and after the closing </form> at the end of the file add this:

Code: Select all

<?php
$add = array('internal' => true);
serendipity_plugin_api::hook_event('backend_sidebar_entries_event_display_profiles', $from, $add);
?>
Then the page should show up in the personal preferences...

Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
jerwarren

personal settings

Post by jerwarren »

That code did indeed add it to the personal settings page, but it doesn't appear to enable the ability to edit. View is the only option.

I'll dig through the plugin and see if I can't figure it out on my own, but if anyone has any ideas I'd be happy to hear them.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: personal settings

Post by garvinhicking »

Hm, the userprofile plugin does have some code that checks the permissions.

This code:

Code: Select all

    function checkUser(&$user) {
        global $serendipity;

        return ($user['userlevel'] < $serendipity['serendipityUserlevel'] || $user['authorid'] == $serendipity['authorid'] || $serendipity['serendipityUserlevel'] >= USERLEVEL_ADMIN);
    }

Is responsible for fetching the users. Do you get any values in the dropdown of the profile plugin so that it contains the own userid, or is the dropdown empty? (the one with the view button next to it)

Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
jerwarren

user profile editing

Post by jerwarren »

Yeh, I found that bit of code, and it seems as if it should be doing it, but it isn't.

(Incidentally, doesn't the first part of that OR statement and the last part do exactly the same thing?)

It's almost as if $user isn't getting set properly when backend_sidebar_entries_event_display_profiles gets called from the personal settings page, causing neither of the OR conditions involving $user to be met.

I get the full list of users in the dropdown, and can view all of them, but can only ever see the edit button as an administrator. The currently logged in user is always selected by default upon loading the personal settings page.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: user profile editing

Post by garvinhicking »

jerwarren: Did you try a print_r($user) within the function call? That you can check what the actual input is?

(The first and last IF statement can be different, if the current user is not a Admin!)

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
jerwarren

Post by jerwarren »

Something is indeed fishy.

while logged in as the non admin user 'jer' (authorid 2) $user['authorid'] before calling backend_sidebar_entries_event_display_profiles' is 2, inside the checkUser function it is 1.

I've been up and down through the plugin trying to figure out where $user is getting assigned improperly, but I can't find it.
Post Reply