diff options
Diffstat (limited to 'include/identity.php')
-rw-r--r-- | include/identity.php | 142 |
1 files changed, 135 insertions, 7 deletions
diff --git a/include/identity.php b/include/identity.php index 98ba26bd8..037cf5061 100644 --- a/include/identity.php +++ b/include/identity.php @@ -178,7 +178,7 @@ function create_identity($arr) { $ret = array('success' => false); if(! $arr['account_id']) { - $ret['message'] = t('No account identifier'); + $ret['message'] = t('No account identifier'); return $ret; } $ret = identity_check_service_class($arr['account_id']); @@ -352,7 +352,7 @@ function create_identity($arr) { ); if($role_permissions) { - $myperms = ((array_key_exists('perms_auto',$role_permissions) && $role_permissions['perms_auto']) ? intval($role_permissions['perms_accept']) : 0); + $myperms = ((array_key_exists('perms_accept',$role_permissions)) ? intval($role_permissions['perms_accept']) : 0); } else $myperms = PERMS_R_STREAM|PERMS_R_PROFILE|PERMS_R_PHOTOS|PERMS_R_ABOOK @@ -482,6 +482,8 @@ function identity_basic_export($channel_id, $items = false) { $ret = array(); + // use constants here as otherwise we will have no idea if we can import from a site + // with a non-standard platform and version. $ret['compatibility'] = array('project' => PLATFORM_NAME, 'version' => RED_VERSION, 'database' => DB_UPDATE_VERSION); $r = q("select * from channel where channel_id = %d limit 1", @@ -922,6 +924,13 @@ function profile_sidebar($profile, $block = 0, $show_connect = true) { $pdesc = true; $reddress = true; + if(! perm_is_allowed($profile['uid'],((is_array($observer)) ? $observer['xchan_hash'] : ''),'view_profile')) { + $block = true; + } + + if($block && intval(get_config('system','block_public_blackout'))) + return $o; + if((! is_array($profile)) && (! count($profile))) return $o; @@ -933,6 +942,7 @@ function profile_sidebar($profile, $block = 0, $show_connect = true) { $show_connect = false; + $profile['picdate'] = urlencode($profile['picdate']); call_hooks('profile_sidebar_enter', $profile); @@ -1006,9 +1016,6 @@ function profile_sidebar($profile, $block = 0, $show_connect = true) { // logger('online: ' . $profile['online']); - if(! perm_is_allowed($profile['uid'],((is_array($observer)) ? $observer['xchan_hash'] : ''),'view_profile')) { - $block = true; - } if(($profile['hidewall'] && (! local_channel()) && (! remote_channel())) || $block ) { $location = $reddress = $pdesc = $gender = $marital = $homepage = False; @@ -1049,8 +1056,10 @@ function profile_sidebar($profile, $block = 0, $show_connect = true) { $tpl = get_markup_template('profile_vcard.tpl'); require_once('include/widgets.php'); - $z = widget_rating(array('target' => $profile['channel_hash'])); + if(! feature_enabled($profile['uid'],'hide_rating')) + $z = widget_rating(array('target' => $profile['channel_hash'])); + $o .= replace_macros($tpl, array( '$profile' => $profile, '$connect' => $connect, @@ -1258,7 +1267,7 @@ function advanced_profile(&$a) { $profile['like_button_label'] = tt('Like','Likes',$profile['like_count'],'noun'); if($likers) { foreach($likers as $l) - $profile['likers'][] = array('name' => $l['xchan_name'],'url' => zid($l['xchan_url'])); + $profile['likers'][] = array('name' => $l['xchan_name'],'photo' => zid($l['xchan_photo_s']), 'url' => zid($l['xchan_url'])); } if(($a->profile['dob']) && ($a->profile['dob'] != '0000-00-00')) { @@ -1695,3 +1704,122 @@ function profiles_build_sync($channel_id) { build_sync_packet($channel_id,array('profile' => $r)); } } + + +function auto_channel_create($account_id) { + + if(! $account_id) + return false; + + $arr = array(); + $arr['account_id'] = $account_id; + $arr['name'] = get_aconfig($account_id,'register','channel_name'); + $arr['nickname'] = legal_webbie(get_aconfig($account_id,'register','channel_address')); + $arr['permissions_role'] = get_aconfig($account_id,'register','permissions_role'); + + del_aconfig($account_id,'register','channel_name'); + del_aconfig($account_id,'register','channel_address'); + del_aconfig($account_id,'register','permissions_role'); + + if((! $arr['name']) || (! $arr['nickname'])) { + $x = q("select * from account where account_id = %d limit 1", + intval($account_id) + ); + if($x) { + if(! $arr['name']) + $arr['name'] = substr($x[0]['account_email'],0,strpos($x[0]['account_email'],'@')); + if(! $arr['nickname']) + $arr['nickname'] = legal_webbie(substr($x[0]['account_email'],0,strpos($x[0]['account_email'],'@'))); + } + } + if(! $arr['permissions_role']) + $arr['permissions_role'] = 'social'; + + if(validate_channelname($arr['name'])) + return false; + if($arr['nickname'] === 'sys') + $arr['nickname'] = $arr['nickname'] . mt_rand(1000,9999); + + $arr['nickname'] = check_webbie(array($arr['nickname'], $arr['nickname'] . mt_rand(1000,9999))); + + return create_identity($arr); + +} + +function get_cover_photo($channel_id,$format = 'bbcode', $res = PHOTO_RES_COVER_1200) { + + $r = q("select height, width, resource_id, type from photo where uid = %d and scale = %d and photo_usage = %d", + intval($channel_id), + intval($res), + intval(PHOTO_COVER) + ); + if(! $r) + return false; + + $output = false; + + $url = z_root() . '/photo/' . $r[0]['resource_id'] . '-' . $res ; + + switch($format) { + case 'bbcode': + $output = '[zrl=' . $r[0]['width'] . 'x' . $r[0]['height'] . ']' . $url . '[/zrl]'; + break; + case 'html': + $output = '<img class="zrl" width="' . $r[0]['width'] . '" height="' . $r[0]['height'] . '" src="' . $url . '" alt="' . t('cover photo') . '" />'; + break; + case 'array': + default: + $output = array( + 'width' => $r[0]['width'], + 'height' => $r[0]['type'], + 'type' => $r[0]['type'], + 'url' => $url + ); + break; + } + + return $output; + +} + +function get_zcard($channel,$observer_hash = '',$args = array()) { + + logger('get_zcard'); + + $channel['channel_addr'] = $channel['channel_address'] . '@' . get_app()->get_hostname(); + + $r = q("select height, width, resource_id, scale, type from photo where uid = %d and scale = %d and photo_usage = %d", + intval($channel['channel_id']), + intval(PHOTO_RES_COVER_1200), + intval(PHOTO_COVER) + ); + + if($r) { + $cover = $r[0]; + $cover['href'] = z_root() . '/photo/' . $r[0]['resource_id'] . '-' . $r[0]['scale']; + } + + $pphoto = array('type' => $channel['xchan_photo_mimetype'], + 'width' => 300 , 'height' => 300, 'href' => $channel['xchan_photo_l']); + + $maxwidth = (($args['width']) ? intval($args['width']) : 0); + $maxheight = (($args['height']) ? intval($args['height']) : 0); + + $zcard = array('chan' => $channel); + if(($maxwidth > 1200) || ($maxwidth < 1)) + $maxwidth = 1200; + $scale = (float) $maxwidth / 1200; + + $translate = intval(($scale / 1.0) * 100); + + $o .= replace_macros(get_markup_template('zcard.tpl'),array( + '$scale' => $scale, + '$translate' => $translate, + '$cover' => $cover, + '$pphoto' => $pphoto, + '$zcard' => $zcard + )); + + return $o; + +}
\ No newline at end of file |