aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2012-08-28 01:55:18 -0700
committerfriendica <info@friendica.com>2012-08-28 01:55:18 -0700
commit5d23e701c04a6962bf11489a3c5d0c0ef0283bc8 (patch)
tree68ef8895eba1be1143d72d9a59b7a741774ce1a5 /include
parentfb714f9e724115993977b7a26acdda93bf84f605 (diff)
downloadvolse-hubzilla-5d23e701c04a6962bf11489a3c5d0c0ef0283bc8.tar.gz
volse-hubzilla-5d23e701c04a6962bf11489a3c5d0c0ef0283bc8.tar.bz2
volse-hubzilla-5d23e701c04a6962bf11489a3c5d0c0ef0283bc8.zip
now it gets hard
Diffstat (limited to 'include')
-rw-r--r--include/identity.php88
1 files changed, 88 insertions, 0 deletions
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;