Archived : Techno Babble

This is the archived version of my b2evolution code blog.
If you require any help regarding b2evolution then
visit it's support forums

You can find my current blogs here
Code : {@link : WafflesOn}
Personal : {@link : InnerVisions}

« Do you captcha your target audience?Opening the blogrums »

AM Deluxe Profiles

Posted on 9th Jun 2008 in : Plugins & Widgets

Extend your users profiles

This plugin adds a shiny new tab to your users profiles tab in admin and allows your users to have such delights as avatars, signatures, location. It also adds the ability for each user to enter their time offset from the server and set the date and time formats that they prefer to use, although that bit means you need to do a tad of skin work ;) These extra profile fields, and settings, can then be used to enhance your current skin and there's also the ability to display each/any users profile instead of that ugly "edit profile" page that you get in the stock evo skins. There's a setting to allow you to restrict the viewing of profiles to logged in members so that the spamming arses don't get access to any details like aim/msn/etc

Admin settings

Allow Avatars
This one's pretty self explanatory, untick it and the ability to use avatars is removed
Guest Avatar
This needs to be the full url to an image to use for guests ( note : this one is not auto-resized, so make sure you upload an appropriate sized image ;) ). Leave this blank to disable guest avatars
Guests
This setting allows you to control if guests can view members profiles, it defaults to "no". Note : this only works if you have an appropriate _profile.disp.php, a sample one is included in teh download. If you don't have an appropriate one then the normal evo action of showing the "edit profile" is shown, which bars guests anyway ;)
Allow Signature
This is another self-explanatory one, untick it and signatures are disabled ;) Note : Signatures will be stripped of any html
Renderers
This is a list of plugin codes that you want to be used to render the signatures, one per line. The default is to use the smilies, bbcode, code highlighter and auto-p plugins, but you can add any that you like. Note : The bbcode plugin will use the post replacements not the comments, this is to enable you to allow urls and images and stuff without getting bitch slapped in your comments by spammers ;)
Timezone
This is the default offset ( in minutes ) from the servers current time, which is handily displayed in the notes field
Time format
This is the default time format to use, meander over top php.net for the various settings you can use
Date format
Uncannily this is the default date format to use, and once again you should hit the php.net link for available settings

New Profile settings and how to use them in your skin

There's actually a couple of ways that you can call up the new settings in your skin. The individual methods are listed below. I'll ( try and ) explain the second method after them all ;)

Avatar
If enabled this will allow the users to select an avatar. They need to upload a file called avatar.jpg or avatar.gif or avatar.png or all 3 if they like to their user directory. The avatar will automatically be resized to 80px x 80px or summat. The user can choose any of the three images to use
Skin call ( default parameters shown ):

PHP:

<?php
$Plugins->trigger_event'UserAvatar'array(
        'display' => true// echo the results
        'block_start' => '<div class="userAvatar">'// html used before the <img> tag
        'block_end' => '</div>'// html used after the <img> tag
    );
?>
Signature
If enabled this allows users to slap in the signature of their choice. This will be rendered with the plugins that you slapped in the admin setting after any html has been stripped
Skin call ( default parameters shown ):

PHP:

<?php
$Plugins->trigger_event'UserSignature'array(
        'display' => true// echo the results
        'block_start' => '<div class="userSignature">'// html used before the signature
        'block_end' => '</div>'// html used after the signature
    );
?>
Location
This allows users to type in a witty location like at my bloody keyboard huh?. This is text only, any html will be stripped
Skin call ( default parameters shown ):

PHP:

<?php
$Plugins->trigger_event'UserSignature'array(
        'display' => true// echo the results
        'block_start' => '<div class="userLocation">'// html used before the location
        'block_end' => '</div>'// html used after the location
    );
?>
Timezone, Time format, Date format
This is exactly the same as the admin version and allows the user to see all dates and times in the format of their choice and in their local time. This one is a tad more complicated in your skin
Skin call ( default parameters shown ):

PHP:

<?php
$Plugins->trigger_event'UserSignature'array(
        'block_start' => '<p class="userDateTime">',
        'block_end' => '</p>',
        'display' => true,
        'output_format' => '$date$ @ $time$'// $date$ && $time$ will be replaced with users preferred format for date and time
    );
?>
You also need to pass the date-time that you wish to convert.

PHP:

// for $Item use :
        'localdatetime' => $Item->get'datecreated' );
// for comments use
        'localdatetime' => $Comment->get'date' );

An alternative method

An alternative method is to use the skintag call and pass it multiple parameters at the same time. It looks a tad more complicated but it really isn't that bad ;) Rather than repeat what's in the plugin code I'll just copy + paste it here and then try and explain it :p

PHP:

/**
     * This is gonna be a doozy to write :p
     * Displays all the various bits and bobs from the users profile
     * Triggers event AMProfileSkinTag() to allow other plugins to hook in ;)
     *
     * @param array $params
     *     avatar         - html output $avatar$ replaced with <img> tag for users avatar
     *     joined         - html output $date$ && $time$ replaced with date/time user registered, display in current users preferred format and time offset
     *     location     - html output $location$ replaced with users location
     *     name             - html output $name$ replaced with users name ( replaces 'profile' if no linked profile )
     *     posts         - html output $posts$ replaced with total posts and comments by user
     *     profile     - html output $profile$ replaced with profile link
     *     signature - html output $signature$ replaced by users signature
     *     website     - html output $website$ replaced by website url, $name$ replaced with users preferred name
     *     no_guests - html output displayed when telling guests to piss off
     *     profile_display - boolean are we displaying the profile
     *     ouput_format - html output
     *         replacement vars
     *             $avatar$ - replaced with avatar html if set
     *             $joined$ - replaced with joined html if set
     *             $location$ - replaced with location html if set
     *             $posts$ - replaced with posts html if set
     *             $profile$ - replaced with profile html if set
     *             $signature$ - replaced with signature html if set
     *             $website$ - replaced with website html if set
     *
     */
    function SkinTag$params )
    {
        $params array_mergearray(
                'signature' => '<p class="userSignature">$signature$</p>',
                'profile' => '<p class="userProfile">$profile$</p>',
                'name' => '<p class="userName">$name$</p>',
                'avatar' => '<p class="userAvatar">$avatar$</p>',
                'datetime' => '<p class="userDateTime">$date$ @ $time$</p>',
                'location' => '<p class="userLocation">$location$</p>',
                'joined' => '<p class="userJoined">$date$</p>',
                'posts' => '<p class="userPosts">$posts$</p>',
                'website' => '<p class="userWebsite"><a href="$website$" title=" '.sprintf$this->T_'visit %s\'s website' ), '$name$' ).' ">'.get_icon'www''imgtag' ).'</a></p>',
                'no_guests' => $this->T_'You need to be a registered member to view profiles' ),
                'profile_display' => false,
                'output_format' => '',
            ), $params );

Looks simple huh ? :roll: The main value is the output format, this is where you get to choose what's spat out and in which order. Continuing in my copy + paste fashion this is how it's called for the comments on my blog :

PHP:

<?php
$Plugins->call_by_code'am_profiles'array(
        'obj' => $Comment// change this to $Item for posts or $current_User for profiles
        'profile' => '<span class="profileLink">$profile$</span>',
        'name' => '<span class="userName">$name$</span>',
        'avatar' => '$avatar$',
        'posts' => '<p class="postCount">Posts : $posts$</p>',
        'joined' => '<p class="userJoined">Joined : $date$</p>',
        'location' => '<div class="userLocation">Location : $location$</div>',
        'output_format' => '$profile$'."\n"
                    .'$avatar$'."\n"
                    .'$posts$'."\n"
                    .'$joined$'."\n"
                    .'$location$'."\n"
    ) );
    ?>

and finally, displaying profiles

Displaying profiles is pretty similar to the code I pasted above. The main difference is that you want all fields and you pass on an extra parameter to tell the plugin that it's displaying the profile as opposed to just showing the users fancy new settings. When you do that the plugin will automatically trigger any other plugins that have the right hooks ;) Rather than re-pasting the sample profile pages code ( which is included in the zip ), you can see it here ( Sample _profile.disp.php ). You can just drop that page into your skins folder and it'll work

Did I mention hooks for other plugins?

To enable other plugin developers to add their own profiles stuff this plugin adds a few new hooks. To use them you need to inform the core that you can react to them with the following :

PHP:

function GetExtraEvents()
    {
        return array(
            'AMProfileTabAction' => 'AdminTabAction() when on our profile tab',
            'AMProfileTabPayload' => 'AdminTabPayload() when on our profile tab',
            'AMProfileSkinTag' => 'Triggered when our SkinTag() is called',
             );
    }

The events should be pretty self explanatory and are passed the following parameters :

PHP:

$Plugins->trigger_event'AMProfileTabAction'array(
                    'AMProfileUrl' => $this->url,
                    'user_ID' => $user,
            ) );

PHP:

$Plugins->trigger_event'AMProfileTabPayload'array(
                            'AMProfileUrl' => $this->url,
                            'Form' => & $Form,
                            'user_ID' => $user,
                ) );

PHP:

$Plugins->trigger_event'AMProfileSkinTag'array(
                    'AMProfileUrl' => $this->url,
                    'output_format' => $params['output_format'],
                    'user_ID' => $user,
        ) );

So, now that you've read all that, go download the plugin ( am_profiles.zip ) and enjoy your shiny new tab ;)

¥

19 comments

Comment by John on 10/06/08
You keep this up and you will be awarded the gold medal for productivity B)
Comment by Gary { @link http://garysblog.co.uk } on 10/06/08
He certainly has pulled some b2evo rabbits out of the hat recently :p
He has always told me that he was good, but now he is proving it :)
Gz
Comment by ¥åßßå on 11/06/08
Good? .... GOOD?? ffs, I'm a bloody genius :|

Mind you, they do say that there's a fine line between genius and totally lost the plot huh? ;)

¥
Comment by Lurker on 12/06/08
nice introduction by ¥åßßå 88| 88| 88|
Comment by ¥åßßå on 12/06/08
I'm after the Randsco Prize for most verbose post :D

¥
Comment by Gary { @link http://garysblog.co.uk } on 13/06/08
most verbose post


verbose
adjective FORMAL DISAPPROVING
using or containing more words than are necessary:
a verbose explanation/report/speech/style
He was a notoriously verbose after-dinner speaker.


Lol Gz,
Comment by ¥åßßå on 13/06/08
This is probably not the time to tell yah that the rest of the world knows what verbose means?


Ask Oxford wrote :


sarcasm
noun the use of irony to mock or convey contempt.

— ORIGIN Greek sarkasmos, from sarkazein ‘tear flesh’, later ‘gnash the teeth, speak bitterly’.



:roll:

¥


Comment by Gary { @link http://garysblog.co.uk } on 13/06/08
Lol, especially 'Just kidding' - Just kidding ;)

Gz
Comment by ¥åßßå on 14/06/08
;)

¥

just kidding, I'm not really winking at you, it's just a bunch of 1's and 0's that represent an image :|
Comment by Na { @link http://puppetsinmelbourne.com.au } on 09/10/08
How would one add a list of members using the extended profile plugin? (Ie. have a list of members, which when you click on the name of the member, goes to their profile.disp page)

Thanks,

Na
Comment by ¥åßßå on 10/10/08
The chances are that wouldn't be to hard to do, but I'm about to sod off for a two week holiday in the sun ;)

Remind me when I get back and I'll look into it

¥
Comment by Lurker on 23/10/08
Does this require another one of your plugins?
I've uploaded this plugin and I'm getting errors about undefined variables, two specifically.

Notice: Undefined property: subtab in /home/robin43/public_html/plugins/am_profiles_plugin/_am_profiles.plugin.php on line 247

Fatal error: Call to undefined function: array_diff_key() in /home/robin43/public_html/plugins/am_profiles_plugin/_am_profiles.plugin.php on line 422

I cannot explain either of these issues.
Comment by Lurker on 24/10/08
Also, is there a way to control how many comments per page there is? If i have a thread with 800 replies, I wouldn't want them to all be displayed on the same page.
Comment by ¥åßßå on 31/10/08
Do you have a link to where this is happening?

It is possible to page comments but I haven't done it for ages.

¥
Comment by EdB { @link http://wonderwinds.com } on 04/03/09
Ya know what? This thing not remembering me really sucks.

But I for sure will finally be using this plugin. I got me a shiny bright awesome installation with a monstrously huge plugin and the FIRST thing someone did was figure out how to upload an avatar. Doh!
Comment by EdB { @link http://wonderwinds.com } on 05/03/09
Hey I just found a bug! It's not in the plugin though: it's in the first 4 code blocks up above here. Line 6 in the first three, and line 7 in the fourth are all missing something. I'll give you a hint: it's a ) before the ); Neato eh?

Looking good so far by the way.
Comment by Lurker on 05/03/09
Oops. Spoke too soon :( It seems that for some reason installing this plugin makes me have no preference for "simple" or "expert" when writing or editing a post. Checked the database and my value for both pref_edit_tab and pref_browse_tab have changed to 'full' for some reason, which I only see once in this plugin.

Also it wouldn't put an avatar in a post that previously existed even though I know it made the resize (because I made up 120x240 just for this purpose.

Weird...
Comment by Lurker on 05/03/09
Aha! Apparently $bar = param( 'tab', 'string', 'full' ); is matching the tab in pref_edit_tab and setting it to 'full'. Since that is a valid value for the pref_browse_tab usersetting I didn't notice that it was going there even if I last left it with 'list' in that field.

Oh well. Still too smart for me to figure out a workaround :(
Comment by ¥åßßå on 05/03/09
How come you find a bug on the one day I'm busy as buggery with a clients website? :|

When I get a moment I'll see if I can squash that bug flatter than the earth used to be ;)

¥
Page archived : 11th Nov 2009
 

X