Description of Gravatar v.0.3Until 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 2009Instructions:
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.phpThere are two optional changes you can make here:
$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
$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:// 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:
// 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:$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:
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.php6. Open /templates/yourtemplate/profile_center.tpl and near the top you should see this: <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.