1
0
Fork 0

Merge branch 'libravatar' of https://github.com/dawnbreak/friendica into pull

This commit is contained in:
friendica 2012-04-10 15:28:48 -07:00
commit 3c66816938
7 changed files with 24 additions and 40 deletions

View file

@ -164,10 +164,15 @@ Your module functions will often contain the function plugin_name_content(&$a),
**'init_1'** - called just after DB has been opened and before session start **'init_1'** - called just after DB has been opened and before session start
$b is not used or passed $b is not used or passed
**'page_end'** - called after HTML content functions have completed **'page_end'** - called after HTML content functions have completed
$b is (string) HTML of content div $b is (string) HTML of content div
**'avatar_lookup'** - called when looking up the avatar
$b is (array)
'size' => the size of the avatar that will be looked up
'email' => email to look up the avatar for
'url' => the (string) generated URL of the avatar
A complete list of all hook callbacks with file locations (generated 14-Feb-2012): Please see the source for details of any hooks not documented above. A complete list of all hook callbacks with file locations (generated 14-Feb-2012): Please see the source for details of any hooks not documented above.

View file

@ -172,16 +172,6 @@ $a->config['system']['no_regfullname'] = true;
``` ```
**Gravatars**
During registration, we will try to automatically find a user photo for you on the web using the gravatar service. You may turn this off by setting 'no_gravatar' to true. Default is false.
Config:
```
$a->config['system']['no_gravatar'] = true;
```
**OpenID** **OpenID**
By default, OpenID may be used for both registration and logins. If you do not wish to make OpenID facilities available on your system (at all), set 'no_openid' to true. Default is false. By default, OpenID may be used for both registration and logins. If you do not wish to make OpenID facilities available on your system (at all), set 'no_openid' to true. Default is false.

View file

@ -446,7 +446,7 @@ function probe_url($url, $mode = PROBE_NORMAL) {
$phost = substr($url,strpos($url,'@')+1); $phost = substr($url,strpos($url,'@')+1);
$profile = 'http://' . $phost; $profile = 'http://' . $phost;
// fix nick character range // fix nick character range
$vcard = array('fn' => $name, 'nick' => $name, 'photo' => gravatar_img($url)); $vcard = array('fn' => $name, 'nick' => $name, 'photo' => avatar_img($url));
$notify = 'smtp ' . random_string(); $notify = 'smtp ' . random_string();
$poll = 'email ' . random_string(); $poll = 'email ' . random_string();
$priority = 0; $priority = 0;
@ -655,7 +655,7 @@ function probe_url($url, $mode = PROBE_NORMAL) {
} }
if((! $vcard['photo']) && strlen($email)) if((! $vcard['photo']) && strlen($email))
$vcard['photo'] = gravatar_img($email); $vcard['photo'] = avatar_img($email);
if($poll === $profile) if($poll === $profile)
$lnk = $feed->get_permalink(); $lnk = $feed->get_permalink();
if(isset($lnk) && strlen($lnk)) if(isset($lnk) && strlen($lnk))

View file

@ -692,18 +692,16 @@ function allowed_email($email) {
}} }}
if(! function_exists('gravatar_img')) { if(! function_exists('avatar_img')) {
function gravatar_img($email) { function avatar_img($email) {
$size = 175; $avatar['size'] = 175;
$opt = 'identicon'; // psuedo-random geometric pattern if not found $avatar['email'] = $email;
$rating = 'pg'; $avatar['url'] = '';
$hash = md5(trim(strtolower($email)));
$url = 'http://www.gravatar.com/avatar/' . $hash . '.jpg'
. '?s=' . $size . '&d=' . $opt . '&r=' . $rating;
logger('gravatar: ' . $email . ' ' . $url); call_hooks('avatar_lookup', $avatar);
return $url;
logger('Avatar: ' . $avatar['email'] . ' ' . $avatar['url']);
return $avatar['url'];
}} }}

View file

@ -174,7 +174,6 @@ function admin_page_site_post(&$a){
return; return;
} }
$sitename = ((x($_POST,'sitename')) ? notags(trim($_POST['sitename'])) : ''); $sitename = ((x($_POST,'sitename')) ? notags(trim($_POST['sitename'])) : '');
$banner = ((x($_POST,'banner')) ? trim($_POST['banner']) : false); $banner = ((x($_POST,'banner')) ? trim($_POST['banner']) : false);
$language = ((x($_POST,'language')) ? notags(trim($_POST['language'])) : ''); $language = ((x($_POST,'language')) ? notags(trim($_POST['language'])) : '');
@ -194,7 +193,6 @@ function admin_page_site_post(&$a){
$global_directory = ((x($_POST,'directory_submit_url')) ? notags(trim($_POST['directory_submit_url'])) : ''); $global_directory = ((x($_POST,'directory_submit_url')) ? notags(trim($_POST['directory_submit_url'])) : '');
$no_multi_reg = ((x($_POST,'no_multi_reg')) ? True : False); $no_multi_reg = ((x($_POST,'no_multi_reg')) ? True : False);
$no_openid = !((x($_POST,'no_openid')) ? True : False); $no_openid = !((x($_POST,'no_openid')) ? True : False);
$no_gravatar = !((x($_POST,'no_gravatar')) ? True : False);
$no_regfullname = !((x($_POST,'no_regfullname')) ? True : False); $no_regfullname = !((x($_POST,'no_regfullname')) ? True : False);
$no_utf = !((x($_POST,'no_utf')) ? True : False); $no_utf = !((x($_POST,'no_utf')) ? True : False);
$no_community_page = !((x($_POST,'no_community_page')) ? True : False); $no_community_page = !((x($_POST,'no_community_page')) ? True : False);
@ -204,7 +202,7 @@ function admin_page_site_post(&$a){
$proxy = ((x($_POST,'proxy')) ? notags(trim($_POST['proxy'])) : ''); $proxy = ((x($_POST,'proxy')) ? notags(trim($_POST['proxy'])) : '');
$timeout = ((x($_POST,'timeout')) ? intval(trim($_POST['timeout'])) : 60); $timeout = ((x($_POST,'timeout')) ? intval(trim($_POST['timeout'])) : 60);
$dfrn_only = ((x($_POST,'dfrn_only')) ? True : False); $dfrn_only = ((x($_POST,'dfrn_only')) ? True : False);
$ostatus_disabled = !((x($_POST,'ostatus_disabled')) ? True : False); $ostatus_disabled = !((x($_POST,'ostatus_disabled')) ? True : False);
$diaspora_enabled = ((x($_POST,'diaspora_enabled')) ? True : False); $diaspora_enabled = ((x($_POST,'diaspora_enabled')) ? True : False);
$ssl_policy = ((x($_POST,'ssl_policy')) ? intval($_POST['ssl_policy']) : 0); $ssl_policy = ((x($_POST,'ssl_policy')) ? intval($_POST['ssl_policy']) : 0);
@ -283,7 +281,6 @@ function admin_page_site_post(&$a){
set_config('system','directory_search_url', $global_search_url); set_config('system','directory_search_url', $global_search_url);
set_config('system','block_extended_register', $no_multi_reg); set_config('system','block_extended_register', $no_multi_reg);
set_config('system','no_openid', $no_openid); set_config('system','no_openid', $no_openid);
set_config('system','no_gravatar', $no_gravatar);
set_config('system','no_regfullname', $no_regfullname); set_config('system','no_regfullname', $no_regfullname);
set_config('system','no_community_page', $no_community_page); set_config('system','no_community_page', $no_community_page);
set_config('system','no_utf', $no_utf); set_config('system','no_utf', $no_utf);
@ -380,7 +377,6 @@ function admin_page_site(&$a) {
'$no_multi_reg' => array('no_multi_reg', t("Block multiple registrations"), get_config('system','block_extended_register'), t("Disallow users to register additional accounts for use as pages.")), '$no_multi_reg' => array('no_multi_reg', t("Block multiple registrations"), get_config('system','block_extended_register'), t("Disallow users to register additional accounts for use as pages.")),
'$no_openid' => array('no_openid', t("OpenID support"), !get_config('system','no_openid'), t("OpenID support for registration and logins.")), '$no_openid' => array('no_openid', t("OpenID support"), !get_config('system','no_openid'), t("OpenID support for registration and logins.")),
'$no_gravatar' => array('no_gravatar', t("Gravatar support"), !get_config('system','no_gravatar'), t("Search new user's photo on Gravatar.")),
'$no_regfullname' => array('no_regfullname', t("Fullname check"), !get_config('system','no_regfullname'), t("Force users to register with a space between firstname and lastname in Full name, as an antispam measure")), '$no_regfullname' => array('no_regfullname', t("Fullname check"), !get_config('system','no_regfullname'), t("Force users to register with a space between firstname and lastname in Full name, as an antispam measure")),
'$no_utf' => array('no_utf', t("UTF-8 Regular expressions"), !get_config('system','no_utf'), t("Use PHP UTF8 regular expressions")), '$no_utf' => array('no_utf', t("UTF-8 Regular expressions"), !get_config('system','no_utf'), t("Use PHP UTF8 regular expressions")),
'$no_community_page' => array('no_community_page', t("Show Community Page"), !get_config('system','no_community_page'), t("Display a Community page showing all recent public postings on this site.")), '$no_community_page' => array('no_community_page', t("Show Community Page"), !get_config('system','no_community_page'), t("Display a Community page showing all recent public postings on this site.")),

View file

@ -314,17 +314,13 @@ function register_post(&$a) {
} }
$use_gravatar = ((get_config('system','no_gravatar')) ? false : true); // if we have no OpenID photo try to look up an avatar
if(! strlen($photo))
// if we have an openid photo use it. $photo = avatar_img($email);
// otherwise unless it is disabled, use gravatar
if($use_gravatar || strlen($photo)) {
// unless there is no avatar-plugin loaded
if(strlen($photo)) {
require_once('include/Photo.php'); require_once('include/Photo.php');
if(($use_gravatar) && (! strlen($photo)))
$photo = gravatar_img($email);
$photo_failure = false; $photo_failure = false;
$filename = basename($photo); $filename = basename($photo);
@ -333,7 +329,7 @@ function register_post(&$a) {
if($img->is_valid()) { if($img->is_valid()) {
$img->scaleImageSquare(175); $img->scaleImageSquare(175);
$hash = photo_new_resource(); $hash = photo_new_resource();
$r = $img->store($newuid, 0, $hash, $filename, t('Profile Photos'), 4 ); $r = $img->store($newuid, 0, $hash, $filename, t('Profile Photos'), 4 );

View file

@ -17,7 +17,6 @@
{{ inc field_checkbox.tpl with $field=$no_multi_reg }}{{ endinc }} {{ inc field_checkbox.tpl with $field=$no_multi_reg }}{{ endinc }}
{{ inc field_checkbox.tpl with $field=$no_openid }}{{ endinc }} {{ inc field_checkbox.tpl with $field=$no_openid }}{{ endinc }}
{{ inc field_checkbox.tpl with $field=$no_gravatar }}{{ endinc }}
{{ inc field_checkbox.tpl with $field=$no_regfullname }}{{ endinc }} {{ inc field_checkbox.tpl with $field=$no_regfullname }}{{ endinc }}
<div class="submit"><input type="submit" name="page_site" value="$submit" /></div> <div class="submit"><input type="submit" name="page_site" value="$submit" /></div>