use optional openid photo for registration - if supplied

This commit is contained in:
Friendika 2010-11-23 20:56:20 -08:00
parent f9f08b4355
commit dd52aec243
4 changed files with 28 additions and 8 deletions

View file

@ -114,7 +114,7 @@ else {
// new account
$_SESSION['register'] = 1;
$openid->required = array('namePerson/friendly', 'contact/email', 'namePerson');
$openid->optional = array('namePerson/first','media/image/aspect11');
$openid->optional = array('namePerson/first','media/image/aspect11','media/image/default');
goaway($openid->authUrl());
// NOTREACHED
}

View file

@ -25,6 +25,10 @@ function openid_content(&$a) {
$args .= '&username=' . notags(trim($v));
if($k === 'contact/email')
$args .= '&email=' . notags(trim($v));
if($k === 'media/image/aspect11')
$photosq = bin2hex(trim($v));
if($k === 'media/image/default')
$photo = bin2hex(trim($v));
}
}
if($nick)
@ -32,6 +36,11 @@ function openid_content(&$a) {
elseif($first)
$args .= '&nickname=' . $first;
if($photosq)
$args .= '&photo=' . $photosq;
elseif($photo)
$args .= '&photo=' . $photo;
$args .= '&openid_url=' . notags(trim($_SESSION['openid']));
if($a->config['register_policy'] != REGISTER_CLOSED)
goaway($a->get_baseurl() . '/register' . $args);

View file

@ -39,6 +39,8 @@ function register_post(&$a) {
if(x($_POST,'openid_url'))
$openid_url = notags(trim($_POST['openid_url']));
$photo = ((x($_POST,'photo')) ? notags(trim($_POST['photo'])) : '');
if((! x($username)) || (! x($email)) || (! x($nickname))) {
if($openid_url) {
@ -49,7 +51,7 @@ function register_post(&$a) {
$openid->identity = $openid_url;
$openid->returnUrl = $a->get_baseurl() . '/openid';
$openid->required = array('namePerson/friendly', 'contact/email', 'namePerson');
$openid->optional = array('namePerson/first','media/image/aspect11');
$openid->optional = array('namePerson/first','media/image/aspect11','media/image/default');
goaway($openid->authUrl());
// NOTREACHED
}
@ -206,11 +208,16 @@ function register_post(&$a) {
}
$use_gravatar = ((get_config('system','no_gravatar')) ? false : true);
if($use_gravatar) {
// if we have an openid photo use it.
// otherwise unless it is disabled, use gravatar
if($use_gravatar || strlen($photo)) {
require_once('include/Photo.php');
$photo = gravatar_img($email);
if(($use_gravatar) && (! strlen($photo)))
$photo = gravatar_img($email);
$photo_failure = false;
$filename = basename($photo);
@ -327,10 +334,11 @@ function register_content(&$a) {
return;
}
$username = ((x($_POST,'username')) ? $_POST['username'] : ((x($_GET,'username')) ? $_GET['username'] : ''));
$email = ((x($_POST,'email')) ? $_POST['email'] : ((x($_GET,'email')) ? $_GET['email'] : ''));
$openid_url = ((x($_POST,'openid_url')) ? $_POST['openid_url'] : ((x($_GET,'openid_url')) ? $_GET['openid_url'] : ''));
$nickname = ((x($_POST,'nickname')) ? $_POST['nickname'] : ((x($_GET,'nickname')) ? $_GET['nickname'] : ''));
$username = ((x($_POST,'username')) ? $_POST['username'] : ((x($_GET,'username')) ? $_GET['username'] : ''));
$email = ((x($_POST,'email')) ? $_POST['email'] : ((x($_GET,'email')) ? $_GET['email'] : ''));
$openid_url = ((x($_POST,'openid_url')) ? $_POST['openid_url'] : ((x($_GET,'openid_url')) ? $_GET['openid_url'] : ''));
$nickname = ((x($_POST,'nickname')) ? $_POST['nickname'] : ((x($_GET,'nickname')) ? $_GET['nickname'] : ''));
$photo = ((x($_POST,'photo')) ? $_POST['photo'] : ((x($_GET,'photo')) ? hex2bin($_GET['photo']) : ''));
$o = load_view_file("view/register.tpl");
$o = replace_macros($o, array(
@ -346,6 +354,7 @@ function register_content(&$a) {
'$addrlabel' => t('Your Email Address: '),
'$nickdesc' => t('Choose a profile nickname. This must begin with a text character. Your global profile locator will then be \'<strong>nickname@$sitename</strong>\'.'),
'$nicklabel' => t('Choose a nickname: '),
'$photo' => $photo,
'$regbutt' => t('Register'),
'$username' => $username,
'$email' => $email,

View file

@ -2,6 +2,8 @@
<form action="register" method="post" >
<input type="hidden" name="photo" value="$photo" />
$registertext