moving a lot of structure around. 'entity' is now 'channel'

This commit is contained in:
friendica
2012-09-25 17:57:20 -07:00
parent dd5725c272
commit fbafd92f7f
28 changed files with 307 additions and 300 deletions

View File

@@ -1,7 +1,7 @@
<?php
function map_perms($entity,$zguid,$zsig) {
function map_perms($channel,$zguid,$zsig) {
$is_contact = false;
$is_site = false;
@@ -19,18 +19,18 @@ function map_perms($entity,$zguid,$zsig) {
$r = q("select * from contact where guid = '%s' and uid = %d limit 1",
dbesc($zguid),
intval($entity['entity_id'])
intval($channel['channel_id'])
);
if($r && count($r)) {
$is_contact = true;
$contact = $r[0];
}
$r = q("select * from entity where entity_global_id = '%s'",
$r = q("select * from channel where channel_global_id = '%s'",
dbesc($zguid)
);
if($r && count($r)) {
foreach($r as $rr) {
if(base64url_encode(rsa_sign($rr['entity_global_id'],$rr['entity_prvkey'])) === $zsig) {
if(base64url_encode(rsa_sign($rr['channel_global_id'],$rr['channel_prvkey'])) === $zsig) {
$is_site = true;
break;
}
@@ -39,25 +39,25 @@ function map_perms($entity,$zguid,$zsig) {
}
$perms = array(
'view_stream' => array('entity_r_stream', PERMS_R_STREAM ),
'view_profile' => array('entity_r_profile', PERMS_R_PROFILE),
'view_photos' => array('entity_r_photos', PERMS_R_PHOTOS),
'view_contacts' => array('entity_r_abook', PERMS_R_ABOOK),
'view_stream' => array('channel_r_stream', PERMS_R_STREAM ),
'view_profile' => array('channel_r_profile', PERMS_R_PROFILE),
'view_photos' => array('channel_r_photos', PERMS_R_PHOTOS),
'view_contacts' => array('channel_r_abook', PERMS_R_ABOOK),
'send_stream' => array('entity_w_stream', PERMS_W_STREAM),
'post_wall' => array('entity_w_wall', PERMS_W_WALL),
'tag_deliver' => array('entity_w_tagwall', PERMS_W_TAGWALL),
'post_comments' => array('entity_w_comment', PERMS_W_COMMENT),
'post_mail' => array('entity_w_mail', PERMS_W_MAIL),
'post_photos' => array('entity_w_photos', PERMS_W_PHOTOS),
'chat' => array('entity_w_chat', PERMS_W_CHAT),
'send_stream' => array('channel_w_stream', PERMS_W_STREAM),
'post_wall' => array('channel_w_wall', PERMS_W_WALL),
'tag_deliver' => array('channel_w_tagwall', PERMS_W_TAGWALL),
'post_comments' => array('channel_w_comment', PERMS_W_COMMENT),
'post_mail' => array('channel_w_mail', PERMS_W_MAIL),
'post_photos' => array('channel_w_photos', PERMS_W_PHOTOS),
'chat' => array('channel_w_chat', PERMS_W_CHAT),
);
$ret = array();
foreach($perms as $k => $v) {
$ret[$k] = z_check_perms($k,$v,$entity,$contact,$is_contact,$is_site,$is_network,$is_anybody);
$ret[$k] = z_check_perms($k,$v,$channel,$contact,$is_contact,$is_site,$is_network,$is_anybody);
}
@@ -65,11 +65,11 @@ function map_perms($entity,$zguid,$zsig) {
}
function z_check_perms($k,$v,$entity,$contact,$is_contact,$is_site,$is_network,$is_anybody) {
function z_check_perms($k,$v,$channel,$contact,$is_contact,$is_site,$is_network,$is_anybody) {
$allow = (($contact['self']) ? true : false);
switch($entity[$v[0]]) {
switch($channel[$v[0]]) {
case PERMS_PUBLIC:
if($is_anybody)
$allow = true;

View File

@@ -7,7 +7,7 @@ require_once('include/crypto.php');
function identity_check_service_class($account_id) {
$ret = array('success' => false, $message => '');
$r = q("select count(entity_id) as total from entity were entity_account_id = %d ",
$r = q("select count(channel_id) as total from channel were channel_account_id = %d ",
intval($account_id)
);
if(! ($r && count($r))) {
@@ -53,9 +53,9 @@ function create_identity($arr) {
$primary = true;
$r = q("insert into entity ( entity_account_id, entity_primary,
entity_name, entity_address, entity_global_id, entity_prvkey,
entity_pubkey, entity_pageflags )
$r = q("insert into channel ( channel_account_id, channel_primary,
channel_name, channel_address, channel_global_id, channel_prvkey,
channel_pubkey, channel_pageflags )
values ( %d, %d, '%s', '%s', '%s', '%s', '%s', %d ) ",
intval($arr['account_id']),
@@ -68,8 +68,8 @@ function create_identity($arr) {
intval(PAGE_NORMAL)
);
$r = q("select * from entity where entity_account_id = %d
and entity_global_id = '%s' limit 1",
$r = q("select * from channel where channel_account_id = %d
and channel_global_id = '%s' limit 1",
intval($arr['account_id']),
dbesc($guid)
);
@@ -79,50 +79,50 @@ function create_identity($arr) {
return $ret;
}
$ret['entity'] = $r[0];
$ret['channel'] = $r[0];
set_default_login_identity($arr['account_id'],$ret['entity']['entity_id'],false);
set_default_login_identity($arr['account_id'],$ret['channel']['channel_id'],false);
// Create a verified hub location pointing to this site.
$r = q("insert into hubloc ( hubloc_guid, hubloc_guid_sig, hubloc_flags,
hubloc_url, hubloc_url_sig, hubloc_callback, hubloc_sitekey )
values ( '%s', '%s', %d, '%s', '%s', '%s', '%s' )",
dbesc($ret['entity']['entity_global_id']),
dbesc(base64url_encode(rsa_sign($ret['entity']['entity_global_id'],$ret['entity']['entity_prvkey']))),
dbesc($ret['channel']['channel_global_id']),
dbesc(base64url_encode(rsa_sign($ret['channel']['channel_global_id'],$ret['channel']['channel_prvkey']))),
intval(($primary) ? HUBLOC_FLAGS_PRIMARY : 0),
dbesc(z_root()),
dbesc(base64url_encode(rsa_sign(z_root(),$ret['entity']['entity_prvkey']))),
dbesc(base64url_encode(rsa_sign(z_root(),$ret['channel']['channel_prvkey']))),
dbesc(z_root() . '/post'),
dbesc(get_config('system','pubkey'))
);
if(! $r)
logger('create_identity: Unable to store hub location');
$newuid = $ret['entity']['entity_id'];
$newuid = $ret['channel']['channel_id'];
$r = q("INSERT INTO `profile` ( `aid`, `uid`, `profile_name`, `is_default`, `name`, `photo`, `thumb`)
VALUES ( %d, %d, '%s', %d, '%s', '%s', '%s') ",
intval($ret['entity']['entity_account_id']),
intval($ret['channel']['channel_account_id']),
intval($newuid),
t('default'),
1,
dbesc($ret['entity']['entity_name']),
dbesc($ret['channel']['channel_name']),
dbesc($a->get_baseurl() . "/photo/profile/{$newuid}"),
dbesc($a->get_baseurl() . "/photo/avatar/{$newuid}")
);
$r = q("INSERT INTO `contact` ( `aid`, `uid`, `created`, `self`, `name`, `nick`, `photo`, `thumb`, `micro`, `blocked`, `pending`, `url`, `name_date`, `uri_date`, `avatar_date`, `closeness` )
VALUES ( %d, %d, '%s', 1, '%s', '%s', '%s', '%s', '%s', 0, 0, '%s', '%s', '%s', '%s', 0 ) ",
intval($ret['entity']['entity_account_id']),
intval($ret['channel']['channel_account_id']),
intval($newuid),
datetime_convert(),
dbesc($ret['entity']['entity_name']),
dbesc($ret['entity']['entity_address']),
dbesc($ret['channel']['channel_name']),
dbesc($ret['channel']['channel_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($a->get_baseurl() . "/profile/{$ret['channel']['channel_address']}"),
dbesc(datetime_convert()),
dbesc(datetime_convert()),
dbesc(datetime_convert())
@@ -141,16 +141,16 @@ function create_identity($arr) {
}
// set default identity for account_id to identity_id
// set default identity for account_id to channel_id
// if $force is false only do this if there is no current default
function set_default_login_identity($account_id,$entity_id,$force = true) {
$r = q("select account_default_entity from account where account_id = %d limit 1",
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_entity'])) || $force)) {
$r = q("update account set account_default_entity = %d where account_id = %d limit 1",
intval($entity_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)
);
}

View File

@@ -27,7 +27,9 @@ function nav(&$a) {
*
*/
$myident = ((is_array($a->identity) && isset($a->identity['entity_address'])) ? $a->identity['entity_address'] . '@' : '');
$channel = $a->get_channel();
$myident = ((is_array($channel) && isset($channel['channel_address'])) ? $channel['channel_address'] . '@' : '');
$sitelocation = $myident . substr($a->get_baseurl($ssl_state),strpos($a->get_baseurl($ssl_state),'//') + 2 );
@@ -46,16 +48,16 @@ function nav(&$a) {
$nav['logout'] = Array('logout',t('Logout'), "", t('End this session'));
// user menu
$nav['usermenu'][] = Array('profile/' . $a->identity['entity_address'], t('Status'), "", t('Your posts and conversations'));
$nav['usermenu'][] = Array('profile/' . $a->identity['entity_address']. '?tab=profile', t('Profile'), "", t('Your profile page'));
$nav['usermenu'][] = Array('photos/' . $a->identity['entity_address'], t('Photos'), "", t('Your photos'));
$nav['usermenu'][] = Array('profile/' . $channel['channel_address'], t('Status'), "", t('Your posts and conversations'));
$nav['usermenu'][] = Array('profile/' . $channel['channel_address']. '?tab=profile', t('Profile'), "", t('Your profile page'));
$nav['usermenu'][] = Array('photos/' . $channel['channel_address'], t('Photos'), "", t('Your photos'));
$nav['usermenu'][] = Array('events/', t('Events'), "", t('Your events'));
// user info
$r = q("SELECT micro FROM contact WHERE uid=%d AND self=1", intval($a->identity['entity_id']));
$r = q("SELECT micro FROM contact WHERE uid=%d AND self=1", intval($channel['channel_id']));
$userinfo = array(
'icon' => $r[0]['micro'],
'name' => $a->identity['entity_name'],
'name' => $channel['channel_name'],
);
}
@@ -111,9 +113,9 @@ function nav(&$a) {
$nav['network'] = array('network', t('Network'), "", t('Conversations from your friends'));
$nav['home'] = array('profile/' . $a->identity['entity_address'], t('Home'), "", t('Your posts and conversations'));
$nav['home'] = array('profile/' . $channel['channel_address'], t('Home'), "", t('Your posts and conversations'));
if($a->identity['entity_pageflags'] == PAGE_NORMAL) {
if($channel['channel_pageflags'] == PAGE_NORMAL) {
$nav['introductions'] = array('notifications/intros', t('Introductions'), "", t('Friend Requests'));
$nav['notifications'] = array('notifications', t('Notifications'), "", t('Notifications'));
$nav['notifications']['all']=array('notifications/system', t('See all notifications'), "", "");

View File

@@ -27,27 +27,27 @@ function authenticate_success($user_record, $login_initial = false, $interactive
$uid_to_load = (((x($_SESSION,'uid')) && (intval($_SESSION['uid']))) ? intval($_SESSION['uid']) : 0);
if(! $uid_to_load)
$uid_to_load = intval($a->account['account_default_entity']);
$uid_to_load = intval($a->account['account_default_channel']);
if($uid_to_load) {
$r = q("select * from entity where entity_id = %d and entity_account_id = %d limit 1",
$r = q("select * from channel where channel_id = %d and channel_account_id = %d limit 1",
intval($uid_to_load),
intval($a->account['account_id'])
);
if($r && count($r)) {
$_SESSION['uid'] = intval($r[0]['entity_id']);
$a->identity = $r[0];
$_SESSION['theme'] = $a->identity['entity_theme'];
date_default_timezone_set($a->identity['entity_timezone']);
$_SESSION['uid'] = intval($r[0]['channel_id']);
$a->set_channel($r[0]);
$_SESSION['theme'] = $r[0]['channel_theme'];
date_default_timezone_set($r[0]['channel_timezone']);
}
$r = q("SELECT * FROM contact WHERE uid = %d AND self = 1 LIMIT 1",
intval($a->identity['entity_id'])
$c = q("SELECT * FROM contact WHERE uid = %d AND self = 1 LIMIT 1",
intval($r[0]['channel_id'])
);
if($r && count($r)) {
$a->contact = $r[0];
$a->cid = $r[0]['id'];
if($c && count($c)) {
$a->contact = $c[0];
$a->cid = $c[0]['id'];
$_SESSION['cid'] = $a->cid;
}

View File

@@ -1665,10 +1665,10 @@ function check_webbie($arr) {
}
}
if(strlen($str)) {
$r = q("select entity_address from entity where entity_address in ( $str ) ");
$r = q("select channel_address from channel where channel_address in ( $str ) ");
if(count($r)) {
foreach($r as $rr) {
$taken[] = $rr['entity_address'];
$taken[] = $rr['channel_address'];
}
}
foreach($arr as $x) {

View File

@@ -2,14 +2,14 @@
/**
*
* @function zot_new_uid($entity_nick)
* @entity_id = unique nickname of controlling entity
* @function zot_new_uid($channel_nick)
* @channel_id = unique nickname of controlling entity
* @returns string
*
*/
function zot_new_uid($entity_nick) {
$rawstr = z_root() . '/' . $entity_nick . '.' . mt_rand();
function zot_new_uid($channel_nick) {
$rawstr = z_root() . '/' . $channel_nick . '.' . mt_rand();
return(base64url_encode(hash('whirlpool',$rawstr,true),true));
}
@@ -59,13 +59,13 @@ function zot_verify(&$item,$identity) {
function zot_notify($entity,$url) {
function zot_notify($channel,$url) {
$x = z_post_url($url, array(
'type' => 'notify',
'guid' => $entity['entity_global_id'],
'guid_sig' => base64url_encode($guid,$entity['prvkey']),
'guid' => $channel['channel_global_id'],
'guid_sig' => base64url_encode($guid,$channel['prvkey']),
'hub' => z_root(),
'hub_sig' => base64url_encode(z_root,$entity['prvkey']),
'hub_sig' => base64url_encode(z_root,$channel['prvkey']),
'callback' => '/post',
'spec' => ZOT_REVISION)
);