Social Web CMS
February 09, 2010, 06:43:09 am *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: We have reinvented SocialWebCMS as HotaruCMS, which is available to download from http://hotarucms.org.
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Gravatar Module v.0.3  (Read 1041 times)
Nick
Administrator
Hero Member
*****
Offline Offline

Posts: 668



View Profile WWW
« on: December 20, 2008, 12:43:08 pm »

Description of Gravatar v.0.3
Until now, your users could only choose between the default avatar or uploading one of their own. Now, with this module, they can also choose to use their "global" avatar from Gravatar.com. Gravatar is becoming standard on many social platforms, including Wordpress, and Social Web CMS has now got it, too!

Updated to v.0.3.1 on Feb. 1st 2009

Instructions:

WARNING: Although this is a module, you will have to make some changes to core files and template files. Any changes you make to core files will be overwritten when you next upgrade SWCMS (unless the changes get put in the next version).

1. Download the attached .zip file, unzip it and open /gravatar/gravatar_main.php

There are two optional changes you can make here:

Code:
$default = my_base_url . "/" . my_pligg_base . "/avatars/Gravatar_" . $size;
$rating = "PG";

- $default is the url of the avatar that SWCMS will fall back on if the user has chosen "I want to use Gravatar" but doesn't have a gravatar attached to the email address he used to register on SWCMS. The above url will return the default SWCMS avatar, but if you want to use the default Gravatar (blue square that says "GRAVATAR"), change it to

Code:
$default = "";

- $rating can be set to G, PG, R and X. Choose the maximum rating you will allow on your site.

If you make any of those changes, save the file then...

2. Upload the gravatar folder to your modules folder. Install it from Module Management in Admin.

3. Open /libs/html1.php and look for the function get_avatar. In that function, you will see this:

Code:
// use the user uploaded avatars ?
        if(Enable_User_Upload_Avatar == true && $avatarsource == "useruploaded"){
                $imgsrc = my_pligg_base . User_Upload_Avatar_Folder . "/" . $user_name . "_" . $imgsize . ".jpg";
                return $imgsrc;
        }

We need to expand on that so change it to this:

Code:
// use the user uploaded avatars ?
        if(Enable_User_Upload_Avatar == true && $avatarsource == "useruploaded"){
                $imgsrc = my_pligg_base . User_Upload_Avatar_Folder . "/" . $user_name . "_" . $imgsize . ".jpg";
                return $imgsrc;
        } elseif(Enable_User_Upload_Avatar == true && $avatarsource == "gravatar"){
                $vars = array('userid' => $user_id, 'username' => $user_name, 'imgsize' => $imgsize, 'imgsrc' => '');
                check_actions('gravatar', $vars);
                $imgsrc = $vars['imgsrc'];
                if($imgsrc != '') { return $imgsrc; }
        }

Save and close.

4. Open /profile.php and look for this in the save_profile function:

Code:
$avatar_source = sanitize($_POST['avatarsource'], 3);
if($avatar_source != "" && $avatar_source != "useruploaded"){
loghack('Updating profile, avatar source is not one of the list options.', 'username: ' . sanitize($_POST["username"], 3) . '|email: ' . sanitize($_POST["email"], 3));
$avatar_source == "";
}
$user->avatar_source=$avatar_source;

Change the "if" line to this:

Code:
if($avatar_source != "" && $avatar_source != "useruploaded" && $avatar_source != "gravatar"){

Save and close.

5. Upload the files you edited in steps 3 and 4: /libs/html1.php and /profile.php

6. Open /templates/yourtemplate/profile_center.tpl and near the top you should see this:

Code:
<input type="radio" name="avatarsource" value="" {if $user_avatar_source eq ""}CHECKED{/if}> {#PLIGG_Visual_Profile_UseDefaultAvatar#}<br />
<input type="radio" name="avatarsource" value="useruploaded" {if $user_avatar_source eq "useruploaded"}CHECKED{/if}> {#PLIGG_Visual_Profile_UploadAvatar#}<br/>

On the next line, add this:

{checkActionsTpl location="tpl_profile_center_pre_save_avatar"}

Save, close and upload.

Now you're finished. If you go to your profile and click Modify, you'll see the extra option of using Gravatar.


Revision History
  • v0.3 2009/01/20 LongCountdown - New module hook for compatibility with other modules.
  • v0.2 2008/12/31 LongCountdown - Added missing .gif extension to default url.
  • v0.1 2008/12/21 LongCountdown - First version.


* gravatar_module.jpg (21.17 KB, 339x169 - viewed 124 times.)
* gravatar.zip (18.31 KB - downloaded 72 times.)
« Last Edit: February 01, 2009, 10:46:55 am by Nick » Logged

Reinventing SWCMS at HotaruCMS.org - testers, designers and developers wanted!
Nick
Administrator
Hero Member
*****
Offline Offline

Posts: 668



View Profile WWW
« Reply #1 on: December 30, 2008, 10:30:13 pm »

[BUG FIX] Updated Gravatar to version 0.2. This version adds a missing .gif to the default avatar url.
Logged

Reinventing SWCMS at HotaruCMS.org - testers, designers and developers wanted!
Nick
Administrator
Hero Member
*****
Offline Offline

Posts: 668



View Profile WWW
« Reply #2 on: January 20, 2009, 06:02:56 am »

Gravatar Module updated to v.0.3

Changes:
Replaced "input" lines with a module hook in profile_center.tpl

If you are upgrading from v.0.1 or v.0.2...
In /templates/yourtemplate/profile_center.tpl:

Replace:
Code:
<input type="radio" name="avatarsource" value="gravatar" {if $user_avatar_source eq "gravatar"}CHECKED{/if}> I want to use my avatar from Gravatar.com<br/>
With:
{checkActionsTpl location="tpl_profile_center_pre_save_avatar"}
Logged

Reinventing SWCMS at HotaruCMS.org - testers, designers and developers wanted!
fourteez
Jr. Member
**
Offline Offline

Posts: 64


View Profile
« Reply #3 on: April 27, 2009, 08:31:54 am »

Hey Nick,

Getting a token error in Modify Profile and the Gravatar option doesn't show.

Thanks!
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.9 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!