aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--boot.php86
-rw-r--r--include/identity.php88
-rw-r--r--mod/profile.php19
3 files changed, 139 insertions, 54 deletions
diff --git a/boot.php b/boot.php
index cfcdbd222..976d8e332 100644
--- a/boot.php
+++ b/boot.php
@@ -929,7 +929,8 @@ if(! function_exists('login')) {
));
$tpl = get_markup_template("login.tpl");
- $_SESSION['return_url'] = $a->query_string;
+ if(strlen($a->query_string))
+ $_SESSION['return_url'] = $a->query_string;
}
@@ -1055,55 +1056,56 @@ if(! function_exists('get_max_import_size')) {
*/
if(! function_exists('profile_load')) {
- function profile_load(&$a, $nickname, $profile = 0) {
- if(remote_user()) {
- $r = q("SELECT `profile-id` FROM `contact` WHERE `id` = %d LIMIT 1",
- intval($_SESSION['visitor_id']));
- if(count($r))
- $profile = $r[0]['profile-id'];
- }
+function profile_load(&$a, $nickname, $profile = 0) {
+ if(remote_user()) {
+ $r = q("SELECT `profile-id` FROM `contact` WHERE `id` = %d LIMIT 1",
+ intval($_SESSION['visitor_id']));
+ if(count($r))
+ $profile = $r[0]['profile-id'];
+ }
- $r = null;
+ $r = null;
- if($profile) {
- $profile_int = intval($profile);
- $r = q("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `contact`.`avatar-date` AS picdate, `user`.* FROM `profile`
- left join `contact` on `contact`.`uid` = `profile`.`uid` LEFT JOIN `user` ON `profile`.`uid` = `user`.`uid`
- WHERE `user`.`nickname` = '%s' AND `profile`.`id` = %d and `contact`.`self` = 1 LIMIT 1",
- dbesc($nickname),
- intval($profile_int)
- );
- }
- if((! $r) && (! count($r))) {
- $r = q("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `contact`.`avatar-date` AS picdate, `user`.* FROM `profile`
- left join `contact` on `contact`.`uid` = `profile`.`uid` LEFT JOIN `user` ON `profile`.`uid` = `user`.`uid`
- WHERE `user`.`nickname` = '%s' AND `profile`.`is-default` = 1 and `contact`.`self` = 1 LIMIT 1",
- dbesc($nickname)
- );
- }
+ if($profile) {
+ $profile_int = intval($profile);
+ $r = q("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `contact`.`avatar-date` AS picdate, entity.* FROM `profile`
+ left join `contact` on `contact`.`uid` = `profile`.`uid` LEFT JOIN entity ON `profile`.`uid` = entity.entity_id
+ WHERE entity.entity_address = '%s' AND `profile`.`id` = %d and `contact`.`self` = 1 LIMIT 1",
+ dbesc($nickname),
+ intval($profile_int)
+ );
+ }
+ if((! $r) && (! count($r))) {
+ $r = q("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `contact`.`avatar-date` AS picdate, `entity`.* FROM `profile`
+ left join `contact` on `contact`.`uid` = `profile`.`uid` LEFT JOIN `entity` ON `profile`.`uid` = entity.entity_id
+ WHERE entity.entity_address = '%s' AND `profile`.`is-default` = 1 and `contact`.`self` = 1 LIMIT 1",
+ dbesc($nickname)
+ );
+ }
- if(($r === false) || (! count($r))) {
- logger('profile error: ' . $a->query_string, LOGGER_DEBUG);
- notice( t('Requested profile is not available.') . EOL );
- $a->error = 404;
- return;
- }
+ if(($r === false) || (! count($r))) {
+ logger('profile error: ' . $a->query_string, LOGGER_DEBUG);
+ notice( t('Requested profile is not available.') . EOL );
+ $a->error = 404;
+ return;
+ }
- // fetch user tags if this isn't the default profile
+ // fetch user tags if this isn't the default profile
- if(! $r[0]['is-default']) {
- $x = q("select `pub_keywords` from `profile` where uid = %d and `is-default` = 1 limit 1",
- intval($profile_uid)
- );
- if($x && count($x))
- $r[0]['pub_keywords'] = $x[0]['pub_keywords'];
- }
+ if(! $r[0]['is-default']) {
+ $x = q("select `pub_keywords` from `profile` where uid = %d and `is-default` = 1 limit 1",
+ intval($profile_uid)
+ );
+ if($x && count($x))
+ $r[0]['pub_keywords'] = $x[0]['pub_keywords'];
+ }
- $a->profile = $r[0];
+ $a->profile = $r[0];
- $a->page['title'] = $a->profile['name'] . " @ " . $a->config['sitename'];
- $_SESSION['theme'] = $a->profile['theme'];
+ $a->page['title'] = $a->profile['entity_name'] . " @ " . $a->config['sitename'];
+// FIXME
+ $_SESSION['theme'] = $a->profile['theme'];
/**
* load/reload current theme info
diff --git a/include/identity.php b/include/identity.php
index 9b8065f6f..a1bf4196b 100644
--- a/include/identity.php
+++ b/include/identity.php
@@ -31,6 +31,7 @@ function identity_check_service_class($account_id) {
function create_identity($arr) {
+ $a = get_app();
$ret = array('success' => false);
if(! $arr['account_id']) {
@@ -97,6 +98,93 @@ function create_identity($arr) {
);
if(! $r)
logger('create_identity: Unable to store hub location');
+
+ $newuid = $ret['entity']['entity_id'];
+
+ $r = q("INSERT INTO `profile` ( `uid`, `profile_name`, `is-default`, `name`, `photo`, `thumb`)
+ VALUES ( %d, '%s', %d, '%s', '%s', '%s') ",
+ intval($ret['entity']['entity_id']),
+ t('default'),
+ 1,
+ dbesc($ret['entity']['entity_name']),
+ dbesc($a->get_baseurl() . "/photo/profile/{$newuid}"),
+ dbesc($a->get_baseurl() . "/photo/avatar/{$newuid}")
+ );
+
+ $r = q("INSERT INTO `contact` ( `uid`, `created`, `self`, `name`, `nick`, `photo`, `thumb`, `micro`, `blocked`, `pending`, `url`, `name-date`, `uri-date`, `avatar-date`, `closeness` )
+ VALUES ( %d, '%s', 1, '%s', '%s', '%s', '%s', '%s', 0, 0, '%s', '%s', '%s', '%s', 0 ) ",
+ intval($ret['entity']['entity_id']),
+ datetime_convert(),
+ dbesc($ret['entity']['entity_name']),
+ dbesc($ret['entity']['entity_address']),
+ dbesc($a->get_baseurl() . "/photo/profile/{$newuid}"),
+ dbesc($a->get_baseurl() . "/photo/avatar/{$newuid}"),
+ dbesc($a->get_baseurl() . "/photo/micro/{$newuid}"),
+ dbesc($a->get_baseurl() . "/profile/{$ret['entity']['entity_address']}"),
+ dbesc(datetime_convert()),
+ dbesc(datetime_convert()),
+ dbesc(datetime_convert())
+ );
+
+ // Create a group with no members. This allows somebody to use it
+ // right away as a default group for new contacts.
+
+ require_once('include/group.php');
+ group_add($ret['entity']['entity_id'], t('Friends'));
+
+
+ // if we have no OpenID photo try to look up an avatar
+ // FIXME - we need the top level account email
+
+ $photo = avatar_img($email);
+ $photo = '';
+
+ // unless there is no avatar-plugin loaded
+ if(strlen($photo)) {
+ require_once('include/Photo.php');
+ $photo_failure = false;
+
+ $filename = basename($photo);
+ $img_str = fetch_url($photo,true);
+ // guess mimetype from headers or filename
+ $type = guess_image_type($photo,true);
+
+
+ $img = new Photo($img_str, $type);
+ if($img->is_valid()) {
+
+ $img->scaleImageSquare(175);
+
+ $hash = photo_new_resource();
+
+ $r = $img->store($newuid, 0, $hash, $filename, t('Profile Photos'), 4 );
+
+ if($r === false)
+ $photo_failure = true;
+
+ $img->scaleImage(80);
+
+ $r = $img->store($newuid, 0, $hash, $filename, t('Profile Photos'), 5 );
+
+ if($r === false)
+ $photo_failure = true;
+
+ $img->scaleImage(48);
+
+ $r = $img->store($newuid, 0, $hash, $filename, t('Profile Photos'), 6 );
+
+ if($r === false)
+ $photo_failure = true;
+
+ if(! $photo_failure) {
+ q("UPDATE `photo` SET `profile` = 1 WHERE `resource-id` = '%s' ",
+ dbesc($hash)
+ );
+ }
+ }
+ }
+
+ call_hooks('register_account', $newuid);
$ret['success'] = true;
diff --git a/mod/profile.php b/mod/profile.php
index 1b5bfa40c..af8f684b3 100644
--- a/mod/profile.php
+++ b/mod/profile.php
@@ -9,21 +9,16 @@ function profile_init(&$a) {
$blocked = (((get_config('system','block_public')) && (! local_user()) && (! remote_user())) ? true : false);
- if($a->argc > 1)
- $which = $a->argv[1];
+ if(argc() > 1)
+ $which = argv(1);
else {
- $r = q("select nickname from user where blocked = 0 and account_expired = 0 and verified = 1 order by rand() limit 1");
- if(count($r)) {
- goaway($a->get_baseurl() . '/profile/' . $r[0]['nickname']);
- }
- else {
- logger('profile error: mod_profile ' . $a->query_string, LOGGER_DEBUG);
- notice( t('Requested profile is not available.') . EOL );
- $a->error = 404;
- return;
- }
+ logger('profile error: mod_profile ' . $a->query_string, LOGGER_DEBUG);
+ notice( t('Requested profile is not available.') . EOL );
+ $a->error = 404;
+ return;
}
+
$profile = 0;
if((local_user()) && ($a->argc > 2) && ($a->argv[2] === 'view')) {
$which = $a->user['nickname'];