diff options
Diffstat (limited to 'include/identity.php')
-rw-r--r-- | include/identity.php | 82 |
1 files changed, 65 insertions, 17 deletions
diff --git a/include/identity.php b/include/identity.php index 62092443e..8f8a71fee 100644 --- a/include/identity.php +++ b/include/identity.php @@ -1,4 +1,4 @@ -<?php +<?php /** @file */ require_once('include/zot.php'); require_once('include/crypto.php'); @@ -44,6 +44,29 @@ function validate_channelname($name) { } +// Create the system channel for directory synchronisation - this has no account attached + + +function create_dir_account() { + create_account(array( + 'account_id' => 'xxx', // This will create an identity with an (integer) account_id of 0, but account_id is required + 'nickname' => 'dir', + 'name' => 'Directory', + 'pageflags' => PAGE_DIRECTORY_CHANNEL|PAGE_HIDDEN, + 'publish' => 0 + )); +} + + +function channel_total() { + $r = q("select channel_id from channel where true"); + if(is_array($r)) + return count($r); + return false; +} + + + // Required: name, nickname, account_id // optional: pageflags @@ -107,7 +130,7 @@ function create_identity($arr) { dbesc($hash), dbesc($key['prvkey']), dbesc($key['pubkey']), - intval(PAGE_NORMAL) + intval($pageflags) ); $r = q("select * from channel where channel_account_id = %d @@ -123,7 +146,8 @@ function create_identity($arr) { $ret['channel'] = $r[0]; - set_default_login_identity($arr['account_id'],$ret['channel']['channel_id'],false); + if(intval($arr['account_id'])) + set_default_login_identity($arr['account_id'],$ret['channel']['channel_id'],false); // Ensure that there is a host keypair. @@ -200,16 +224,18 @@ function create_identity($arr) { intval(ABOOK_FLAG_SELF) ); + if(intval($ret['channel']['channel_account_id'])) { - // Create a group with no members. This allows somebody to use it - // right away as a default group for new contacts. + // 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($newuid, t('Friends')); + require_once('include/group.php'); + group_add($newuid, t('Friends')); - call_hooks('register_account', $newuid); - - proc_run('php','include/directory.php', $ret['channel']['channel_id']); + call_hooks('register_account', $newuid); + + proc_run('php','include/directory.php', $ret['channel']['channel_id']); + } $ret['success'] = true; return $ret; @@ -223,11 +249,13 @@ function set_default_login_identity($account_id,$channel_id,$force = true) { $r = q("select account_default_channel from account where account_id = %d limit 1", intval($account_id) ); - if(($r) && (count($r)) && ((! intval($r[0]['account_default_channel'])) || $force)) { - $r = q("update account set account_default_channel = %d where account_id = %d limit 1", - intval($channel_id), - intval($account_id) - ); + if($r) { + if((intval($r[0]['account_default_channel']) == 0) || ($force)) { + $r = q("update account set account_default_channel = %d where account_id = %d limit 1", + intval($channel_id), + intval($account_id) + ); + } } } @@ -239,7 +267,7 @@ function identity_basic_export($channel_id) { $ret = array(); - $ret['compatibility'] = array('project' => FRIENDICA_PLATFORM, 'version' => FRIENDICA_VERSION, 'database' => DB_UPDATE_VERSION); + $ret['compatibility'] = array('project' => RED_PLATFORM, 'version' => RED_VERSION, 'database' => DB_UPDATE_VERSION); $r = q("select * from channel where channel_id = %d limit 1", intval($channel_id) @@ -275,6 +303,26 @@ function identity_basic_export($channel_id) { $ret['hubloc'] = $r; } + $r = q("select * from `group` where uid = %d ", + intval($channel_id) + ); + + if($r) + $ret['group'] = $r; + + $r = q("select * from group_member where uid = %d ", + intval($channel_id) + ); + if($r) + $ret['group_member'] = $r; + + $r = q("select * from pconfig where uid = %d", + intval($channel_id) + ); + if($r) + $ret['config'] = $r; + + $r = q("select type, data from photo where scale = 4 and profile = 1 and uid = %d limit 1", intval($channel_id) ); @@ -334,4 +382,4 @@ function identity_basic_import($arr, $seize_primary = false) { return $ret; -}
\ No newline at end of file +} |