aboutsummaryrefslogtreecommitdiffstats
path: root/include/identity.php
diff options
context:
space:
mode:
Diffstat (limited to 'include/identity.php')
-rw-r--r--include/identity.php473
1 files changed, 328 insertions, 145 deletions
diff --git a/include/identity.php b/include/identity.php
index 98ba26bd8..1c899048a 100644
--- a/include/identity.php
+++ b/include/identity.php
@@ -174,11 +174,10 @@ function channel_total() {
*/
function create_identity($arr) {
- $a = get_app();
$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']);
@@ -275,7 +274,7 @@ function create_identity($arr) {
intval($pageflags),
intval($system),
intval($expire),
- dbesc($a->timezone)
+ dbesc(App::$timezone)
);
$r = q("select * from channel where channel_account_id = %d
@@ -302,11 +301,11 @@ function create_identity($arr) {
dbesc($guid),
dbesc($sig),
dbesc($hash),
- dbesc($ret['channel']['channel_address'] . '@' . get_app()->get_hostname()),
+ dbesc($ret['channel']['channel_address'] . '@' . App::get_hostname()),
intval($primary),
dbesc(z_root()),
dbesc(base64url_encode(rsa_sign(z_root(),$ret['channel']['channel_prvkey']))),
- dbesc(get_app()->get_hostname()),
+ dbesc(App::get_hostname()),
dbesc(z_root() . '/post'),
dbesc(get_config('system','pubkey')),
dbesc('zot')
@@ -321,10 +320,10 @@ function create_identity($arr) {
dbesc($guid),
dbesc($sig),
dbesc($key['pubkey']),
- dbesc($a->get_baseurl() . "/photo/profile/l/{$newuid}"),
- dbesc($a->get_baseurl() . "/photo/profile/m/{$newuid}"),
- dbesc($a->get_baseurl() . "/photo/profile/s/{$newuid}"),
- dbesc($ret['channel']['channel_address'] . '@' . get_app()->get_hostname()),
+ dbesc(z_root() . "/photo/profile/l/{$newuid}"),
+ dbesc(z_root() . "/photo/profile/m/{$newuid}"),
+ dbesc(z_root() . "/photo/profile/s/{$newuid}"),
+ dbesc($ret['channel']['channel_address'] . '@' . App::get_hostname()),
dbesc(z_root() . '/channel/' . $ret['channel']['channel_address']),
dbesc(z_root() . '/follow?f=&url=%s'),
dbesc(z_root() . '/poco/' . $ret['channel']['channel_address']),
@@ -347,12 +346,12 @@ function create_identity($arr) {
1,
$publish,
dbesc($ret['channel']['channel_name']),
- dbesc($a->get_baseurl() . "/photo/profile/l/{$newuid}"),
- dbesc($a->get_baseurl() . "/photo/profile/m/{$newuid}")
+ dbesc(z_root() . "/photo/profile/l/{$newuid}"),
+ dbesc(z_root() . "/photo/profile/m/{$newuid}")
);
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
@@ -410,7 +409,15 @@ function create_identity($arr) {
set_pconfig($ret['channel']['channel_id'],'system','photo_path', '%Y-%m');
set_pconfig($ret['channel']['channel_id'],'system','attach_path','%Y-%m');
}
-
+
+ // UNO: channel defaults, incl addons (addons specific pconfig will only work after the relevant addon is enabled by the admin). It's located here, so members can modify these defaults after the channel is created.
+ if(UNO) {
+ //diaspora protocol addon
+ set_pconfig($ret['channel']['channel_id'],'system','diaspora_allowed', '1');
+ set_pconfig($ret['channel']['channel_id'],'system','diaspora_public_comments', '1');
+ set_pconfig($ret['channel']['channel_id'],'system','prevent_tag_hijacking', '0');
+ }
+
// auto-follow any of the hub's pre-configured channel choices.
// Only do this if it's the first channel for this account;
// otherwise it could get annoying. Don't make this list too big
@@ -482,7 +489,9 @@ function identity_basic_export($channel_id, $items = false) {
$ret = array();
- $ret['compatibility'] = array('project' => PLATFORM_NAME, 'version' => RED_VERSION, 'database' => DB_UPDATE_VERSION);
+ // 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, 'server_role' => Zotlabs\Project\System::get_server_role());
$r = q("select * from channel where channel_id = %d limit 1",
intval($channel_id)
@@ -503,8 +512,12 @@ function identity_basic_export($channel_id, $items = false) {
if($r) {
$ret['abook'] = $r;
- foreach($r as $rr)
- $xchans[] = $rr['abook_xchan'];
+ for($x = 0; $x < count($ret['abook']); $x ++) {
+ $xchans[] = $ret['abook'][$x]['abook_chan'];
+ $abconfig = load_abconfig($ret['channel']['channel_hash'],$ret['abook'][$x]['abook_xchan']);
+ if($abconfig)
+ $ret['abook'][$x]['abconfig'] = $abconfig;
+ }
stringify_array_elms($xchans);
}
@@ -537,7 +550,8 @@ function identity_basic_export($channel_id, $items = false) {
if($r)
$ret['config'] = $r;
- $r = q("select type, data, os_storage from photo where scale = 4 and profile = 1 and uid = %d limit 1",
+ $r = q("select type, data, os_storage from photo where scale = 4 and photo_usage = %d and uid = %d limit 1",
+ intval(PHOTO_PROFILE),
intval($channel_id)
);
@@ -766,14 +780,14 @@ function profile_load(&$a, $nickname, $profile = '') {
);
if(! $user) {
- logger('profile error: ' . $a->query_string, LOGGER_DEBUG);
+ logger('profile error: ' . App::$query_string, LOGGER_DEBUG);
notice( t('Requested channel is not available.') . EOL );
- $a->error = 404;
+ App::$error = 404;
return;
}
// get the current observer
- $observer = $a->get_observer();
+ $observer = App::get_observer();
$can_view_profile = true;
@@ -812,9 +826,9 @@ function profile_load(&$a, $nickname, $profile = '') {
}
if(! $p) {
- logger('profile error: ' . $a->query_string, LOGGER_DEBUG);
+ logger('profile error: ' . App::$query_string, LOGGER_DEBUG);
notice( t('Requested profile is not available.') . EOL );
- $a->error = 404;
+ App::$error = 404;
return;
}
@@ -860,9 +874,8 @@ function profile_load(&$a, $nickname, $profile = '') {
// fetch user tags if this isn't the default profile
if(! $p[0]['is_default']) {
- /** @BUG $profile_uid is undefinded for this query, so should not work. */
$x = q("select `keywords` from `profile` where uid = %d and `is_default` = 1 limit 1",
- intval($profile_uid)
+ intval($p[0]['profile_uid'])
);
if($x && $can_view_profile)
$p[0]['keywords'] = $x[0]['keywords'];
@@ -871,23 +884,23 @@ function profile_load(&$a, $nickname, $profile = '') {
if($p[0]['keywords']) {
$keywords = str_replace(array('#',',',' ',',,'),array('',' ',',',','),$p[0]['keywords']);
if(strlen($keywords) && $can_view_profile)
- $a->page['htmlhead'] .= '<meta name="keywords" content="' . htmlentities($keywords,ENT_COMPAT,'UTF-8') . '" />' . "\r\n" ;
+ App::$page['htmlhead'] .= '<meta name="keywords" content="' . htmlentities($keywords,ENT_COMPAT,'UTF-8') . '" />' . "\r\n" ;
}
- $a->profile = $p[0];
- $a->profile_uid = $p[0]['profile_uid'];
- $a->page['title'] = $a->profile['channel_name'] . " - " . $a->profile['channel_address'] . "@" . $a->get_hostname();
+ App::$profile = $p[0];
+ App::$profile_uid = $p[0]['profile_uid'];
+ App::$page['title'] = App::$profile['channel_name'] . " - " . App::$profile['channel_address'] . "@" . App::get_hostname();
- $a->profile['permission_to_view'] = $can_view_profile;
+ App::$profile['permission_to_view'] = $can_view_profile;
if($can_view_profile) {
$online = get_online_status($nickname);
- $a->profile['online_status'] = $online['result'];
+ App::$profile['online_status'] = $online['result'];
}
if(local_channel()) {
- $a->profile['channel_mobile_theme'] = get_pconfig(local_channel(),'system', 'mobile_theme');
- $_SESSION['mobile_theme'] = $a->profile['channel_mobile_theme'];
+ App::$profile['channel_mobile_theme'] = get_pconfig(local_channel(),'system', 'mobile_theme');
+ $_SESSION['mobile_theme'] = App::$profile['channel_mobile_theme'];
}
/*
@@ -898,6 +911,54 @@ function profile_load(&$a, $nickname, $profile = '') {
}
+function profile_edit_menu($uid) {
+
+ $ret = array();
+
+ $is_owner = (($uid == local_channel()) ? true : false);
+
+ // show edit profile to profile owner
+ if($is_owner) {
+ $ret['menu'] = array(
+ 'chg_photo' => t('Change profile photo'),
+ 'entries' => array(),
+ );
+
+ $multi_profiles = feature_enabled(local_channel(), 'multi_profiles');
+ if($multi_profiles) {
+ $ret['multi'] = 1;
+ $ret['edit'] = array(z_root(). '/profiles', t('Edit Profiles'), '', t('Edit'));
+ $ret['menu']['cr_new'] = t('Create New Profile');
+ }
+ else {
+ $ret['edit'] = array(z_root() . '/profiles/' . $uid, t('Edit Profile'), '', t('Edit'));
+ }
+
+ $r = q("SELECT * FROM profile WHERE uid = %d",
+ local_channel()
+ );
+
+ if($r) {
+ foreach($r as $rr) {
+ if(!($multi_profiles || $rr['is_default']))
+ continue;
+ $ret['menu']['entries'][] = array(
+ 'photo' => $rr['thumb'],
+ 'id' => $rr['id'],
+ 'alt' => t('Profile Image'),
+ 'profile_name' => $rr['profile_name'],
+ 'isdefault' => $rr['is_default'],
+ 'visible_to_everybody' => t('Visible to everybody'),
+ 'edit_visibility' => t('Edit visibility'),
+ );
+ }
+ }
+ }
+
+ return $ret;
+
+}
+
/**
* @brief Formats a profile for display in the sidebar.
*
@@ -911,28 +972,27 @@ function profile_load(&$a, $nickname, $profile = '') {
* @return HTML string suitable for sidebar inclusion
* Exceptions: Returns empty string if passed $profile is wrong type or not populated
*/
-function profile_sidebar($profile, $block = 0, $show_connect = true) {
-
- $a = get_app();
+function profile_sidebar($profile, $block = 0, $show_connect = true, $zcard = false) {
- $observer = $a->get_observer();
+ $observer = App::get_observer();
$o = '';
$location = false;
$pdesc = true;
$reddress = true;
+ if(! perm_is_allowed($profile['uid'],((is_array($observer)) ? $observer['xchan_hash'] : ''),'view_profile')) {
+ $block = true;
+ }
+
if((! is_array($profile)) && (! count($profile)))
return $o;
head_set_icon($profile['thumb']);
- $is_owner = (($profile['uid'] == local_channel()) ? true : false);
-
if(is_sys_channel($profile['uid']))
$show_connect = false;
-
$profile['picdate'] = urlencode($profile['picdate']);
call_hooks('profile_sidebar_enter', $profile);
@@ -946,7 +1006,7 @@ function profile_sidebar($profile, $block = 0, $show_connect = true) {
$connect_url = rconnect_url($profile['uid'],get_observer_hash());
$connect = (($connect_url) ? t('Connect') : '');
if($connect_url)
- $connect_url = sprintf($connect_url,urlencode($profile['channel_address'] . '@' . $a->get_hostname()));
+ $connect_url = sprintf($connect_url,urlencode($profile['channel_address'] . '@' . App::get_hostname()));
// premium channel - over-ride
@@ -954,42 +1014,6 @@ function profile_sidebar($profile, $block = 0, $show_connect = true) {
$connect_url = z_root() . '/connect/' . $profile['channel_address'];
}
- // show edit profile to yourself
- if($is_owner) {
- $profile['menu'] = array(
- 'chg_photo' => t('Change profile photo'),
- 'entries' => array(),
- );
-
- $multi_profiles = feature_enabled(local_channel(), 'multi_profiles');
- if($multi_profiles) {
- $profile['edit'] = array($a->get_baseurl(). '/profiles', t('Profiles'),"", t('Manage/edit profiles'));
- $profile['menu']['cr_new'] = t('Create New Profile');
- }
- else
- $profile['edit'] = array($a->get_baseurl() . '/profiles/' . $profile['id'], t('Edit Profile'),'',t('Edit Profile'));
-
- $r = q("SELECT * FROM `profile` WHERE `uid` = %d",
- local_channel());
-
- if($r) {
- foreach($r as $rr) {
- if(!($multi_profiles || $rr['is_default']))
- continue;
- $profile['menu']['entries'][] = array(
- 'photo' => $rr['thumb'],
- 'id' => $rr['id'],
- 'alt' => t('Profile Image'),
- 'profile_name' => $rr['profile_name'],
- 'isdefault' => $rr['is_default'],
- 'visible_to_everybody' => t('visible to everybody'),
- 'edit_visibility' => t('Edit visibility'),
- );
- }
- }
- }
-
-
if((x($profile,'address') == 1)
|| (x($profile,'locality') == 1)
|| (x($profile,'region') == 1)
@@ -1006,9 +1030,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;
@@ -1046,12 +1067,18 @@ function profile_sidebar($profile, $block = 0, $show_connect = true) {
$channel_menu .= comanche_block($menublock);
}
- $tpl = get_markup_template('profile_vcard.tpl');
+ if($zcard)
+ $tpl = get_markup_template('profile_vcard_short.tpl');
+ else
+ $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(
+ '$zcard' => $zcard,
'$profile' => $profile,
'$connect' => $connect,
'$connect_url' => $connect_url,
@@ -1065,6 +1092,7 @@ function profile_sidebar($profile, $block = 0, $show_connect = true) {
'$reddress' => $reddress,
'$rating' => $z,
'$contact_block' => $contact_block,
+ '$editmenu' => profile_edit_menu($profile['uid'])
));
$arr = array('profile' => &$profile, 'entry' => &$o);
@@ -1080,7 +1108,6 @@ function profile_sidebar($profile, $block = 0, $show_connect = true) {
*/
function get_birthdays() {
- $a = get_app();
$o = '';
if(! local_channel())
@@ -1127,12 +1154,12 @@ function profile_sidebar($profile, $block = 0, $show_connect = true) {
$url = $rr['url'];
if($rr['network'] === NETWORK_DFRN) {
$sparkle = " sparkle";
- $url = $a->get_baseurl() . '/redir/' . $rr['cid'];
+ $url = z_root() . '/redir/' . $rr['cid'];
}
$rr['link'] = $url;
$rr['title'] = $rr['name'];
- $rr['date'] = day_translate(datetime_convert('UTC', $a->timezone, $rr['start'], $rr['adjust'] ? $bd_format : $bd_short)) . (($today) ? ' ' . t('[today]') : '');
+ $rr['date'] = day_translate(datetime_convert('UTC', App::$timezone, $rr['start'], $rr['adjust'] ? $bd_format : $bd_short)) . (($today) ? ' ' . t('[today]') : '');
$rr['startime'] = Null;
$rr['today'] = $today;
}
@@ -1140,7 +1167,7 @@ function profile_sidebar($profile, $block = 0, $show_connect = true) {
}
$tpl = get_markup_template("birthdays_reminder.tpl");
return replace_macros($tpl, array(
- '$baseurl' => $a->get_baseurl(),
+ '$baseurl' => z_root(),
'$classtoday' => $classtoday,
'$count' => $total,
'$event_reminders' => t('Birthday Reminders'),
@@ -1159,8 +1186,6 @@ function profile_sidebar($profile, $block = 0, $show_connect = true) {
require_once('include/bbcode.php');
- $a = get_app();
-
if(! local_channel())
return $o;
@@ -1182,15 +1207,15 @@ function profile_sidebar($profile, $block = 0, $show_connect = true) {
if(strlen($rr['name']))
$total ++;
- $strt = datetime_convert('UTC',$rr['convert'] ? $a->timezone : 'UTC',$rr['start'],'Y-m-d');
- if($strt === datetime_convert('UTC',$a->timezone,'now','Y-m-d'))
+ $strt = datetime_convert('UTC',$rr['convert'] ? App::$timezone : 'UTC',$rr['start'],'Y-m-d');
+ if($strt === datetime_convert('UTC',App::$timezone,'now','Y-m-d'))
$istoday = true;
}
$classtoday = (($istoday) ? 'event-today' : '');
foreach($r as &$rr) {
if($rr['adjust'])
- $md = datetime_convert('UTC',$a->timezone,$rr['start'],'Y/m');
+ $md = datetime_convert('UTC',App::$timezone,$rr['start'],'Y/m');
else
$md = datetime_convert('UTC','UTC',$rr['start'],'Y/m');
$md .= "/#link-".$rr['id'];
@@ -1199,12 +1224,12 @@ function profile_sidebar($profile, $block = 0, $show_connect = true) {
if(! $title)
$title = t('[No description]');
- $strt = datetime_convert('UTC',$rr['convert'] ? $a->timezone : 'UTC',$rr['start']);
- $today = ((substr($strt,0,10) === datetime_convert('UTC',$a->timezone,'now','Y-m-d')) ? true : false);
+ $strt = datetime_convert('UTC',$rr['convert'] ? App::$timezone : 'UTC',$rr['start']);
+ $today = ((substr($strt,0,10) === datetime_convert('UTC',App::$timezone,'now','Y-m-d')) ? true : false);
$rr['link'] = $md;
$rr['title'] = $title;
- $rr['date'] = day_translate(datetime_convert('UTC', $rr['adjust'] ? $a->timezone : 'UTC', $rr['start'], $bd_format)) . (($today) ? ' ' . t('[today]') : '');
+ $rr['date'] = day_translate(datetime_convert('UTC', $rr['adjust'] ? App::$timezone : 'UTC', $rr['start'], $bd_format)) . (($today) ? ' ' . t('[today]') : '');
$rr['startime'] = $strt;
$rr['today'] = $today;
}
@@ -1212,7 +1237,7 @@ function profile_sidebar($profile, $block = 0, $show_connect = true) {
$tpl = get_markup_template("events_reminder.tpl");
return replace_macros($tpl, array(
- '$baseurl' => $a->get_baseurl(),
+ '$baseurl' => z_root(),
'$classtoday' => $classtoday,
'$count' => count($r),
'$event_reminders' => t('Event Reminders'),
@@ -1224,32 +1249,46 @@ function profile_sidebar($profile, $block = 0, $show_connect = true) {
function advanced_profile(&$a) {
require_once('include/text.php');
- if(! perm_is_allowed($a->profile['profile_uid'],get_observer_hash(),'view_profile'))
+ if(! perm_is_allowed(App::$profile['profile_uid'],get_observer_hash(),'view_profile'))
return '';
- $o = '';
+ if(App::$profile['name']) {
+
+ $profile_fields_basic = get_profile_fields_basic();
+ $profile_fields_advanced = get_profile_fields_advanced();
+
+ $advanced = ((feature_enabled(App::$profile['profile_uid'],'advanced_profiles')) ? true : false);
+ if($advanced)
+ $fields = $profile_fields_advanced;
+ else
+ $fields = $profile_fields_basic;
+
+ $clean_fields = array();
+ if($fields) {
+ foreach($fields as $k => $v) {
+ $clean_fields[] = trim($k);
+ }
+ }
- $o .= '<h2>' . t('Profile') . '</h2>';
- if($a->profile['name']) {
$tpl = get_markup_template('profile_advanced.tpl');
$profile = array();
- $profile['fullname'] = array( t('Full Name:'), $a->profile['name'] ) ;
+ $profile['fullname'] = array( t('Full Name:'), App::$profile['name'] ) ;
- if($a->profile['gender']) $profile['gender'] = array( t('Gender:'), $a->profile['gender'] );
+ if(App::$profile['gender']) $profile['gender'] = array( t('Gender:'), App::$profile['gender'] );
$ob_hash = get_observer_hash();
- if($ob_hash && perm_is_allowed($a->profile['profile_uid'],$ob_hash,'post_like')) {
+ if($ob_hash && perm_is_allowed(App::$profile['profile_uid'],$ob_hash,'post_like')) {
$profile['canlike'] = true;
$profile['likethis'] = t('Like this channel');
- $profile['profile_guid'] = $a->profile['profile_guid'];
+ $profile['profile_guid'] = App::$profile['profile_guid'];
}
$likers = q("select liker, xchan.* from likes left join xchan on liker = xchan_hash where channel_id = %d and target_type = '%s' and verb = '%s'",
- intval($a->profile['profile_uid']),
+ intval(App::$profile['profile_uid']),
dbesc(ACTIVITY_OBJ_PROFILE),
dbesc(ACTIVITY_LIKE)
);
@@ -1258,90 +1297,90 @@ 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')) {
+ if((App::$profile['dob']) && (App::$profile['dob'] != '0000-00-00')) {
$val = '';
- if((substr($a->profile['dob'],5,2) === '00') || (substr($a->profile['dob'],8,2) === '00'))
- $val = substr($a->profile['dob'],0,4);
+ if((substr(App::$profile['dob'],5,2) === '00') || (substr(App::$profile['dob'],8,2) === '00'))
+ $val = substr(App::$profile['dob'],0,4);
$year_bd_format = t('j F, Y');
$short_bd_format = t('j F');
if(! $val) {
- $val = ((intval($a->profile['dob']))
- ? day_translate(datetime_convert('UTC','UTC',$a->profile['dob'] . ' 00:00 +00:00',$year_bd_format))
- : day_translate(datetime_convert('UTC','UTC','2001-' . substr($a->profile['dob'],5) . ' 00:00 +00:00',$short_bd_format)));
+ $val = ((intval(App::$profile['dob']))
+ ? day_translate(datetime_convert('UTC','UTC',App::$profile['dob'] . ' 00:00 +00:00',$year_bd_format))
+ : day_translate(datetime_convert('UTC','UTC','2001-' . substr(App::$profile['dob'],5) . ' 00:00 +00:00',$short_bd_format)));
}
$profile['birthday'] = array( t('Birthday:'), $val);
}
- if($age = age($a->profile['dob'],$a->profile['timezone'],''))
+ if($age = age(App::$profile['dob'],App::$profile['timezone'],''))
$profile['age'] = array( t('Age:'), $age );
- if($a->profile['marital'])
- $profile['marital'] = array( t('Status:'), $a->profile['marital']);
+ if(App::$profile['marital'])
+ $profile['marital'] = array( t('Status:'), App::$profile['marital']);
- if($a->profile['with'])
- $profile['marital']['with'] = bbcode($a->profile['with']);
+ if(App::$profile['with'])
+ $profile['marital']['with'] = bbcode(App::$profile['with']);
- if(strlen($a->profile['howlong']) && $a->profile['howlong'] !== NULL_DATE) {
- $profile['howlong'] = relative_date($a->profile['howlong'], t('for %1$d %2$s'));
+ if(strlen(App::$profile['howlong']) && App::$profile['howlong'] !== NULL_DATE) {
+ $profile['howlong'] = relative_date(App::$profile['howlong'], t('for %1$d %2$s'));
}
- if($a->profile['sexual']) $profile['sexual'] = array( t('Sexual Preference:'), $a->profile['sexual'] );
+ if(App::$profile['sexual']) $profile['sexual'] = array( t('Sexual Preference:'), App::$profile['sexual'] );
- if($a->profile['homepage']) $profile['homepage'] = array( t('Homepage:'), linkify($a->profile['homepage']) );
+ if(App::$profile['homepage']) $profile['homepage'] = array( t('Homepage:'), linkify(App::$profile['homepage']) );
- if($a->profile['hometown']) $profile['hometown'] = array( t('Hometown:'), linkify($a->profile['hometown']) );
+ if(App::$profile['hometown']) $profile['hometown'] = array( t('Hometown:'), linkify(App::$profile['hometown']) );
- if($a->profile['keywords']) $profile['keywords'] = array( t('Tags:'), $a->profile['keywords']);
+ if(App::$profile['keywords']) $profile['keywords'] = array( t('Tags:'), App::$profile['keywords']);
- if($a->profile['politic']) $profile['politic'] = array( t('Political Views:'), $a->profile['politic']);
+ if(App::$profile['politic']) $profile['politic'] = array( t('Political Views:'), App::$profile['politic']);
- if($a->profile['religion']) $profile['religion'] = array( t('Religion:'), $a->profile['religion']);
+ if(App::$profile['religion']) $profile['religion'] = array( t('Religion:'), App::$profile['religion']);
- if($txt = prepare_text($a->profile['about'])) $profile['about'] = array( t('About:'), $txt );
+ if($txt = prepare_text(App::$profile['about'])) $profile['about'] = array( t('About:'), $txt );
- if($txt = prepare_text($a->profile['interest'])) $profile['interest'] = array( t('Hobbies/Interests:'), $txt);
+ if($txt = prepare_text(App::$profile['interest'])) $profile['interest'] = array( t('Hobbies/Interests:'), $txt);
- if($txt = prepare_text($a->profile['likes'])) $profile['likes'] = array( t('Likes:'), $txt);
+ if($txt = prepare_text(App::$profile['likes'])) $profile['likes'] = array( t('Likes:'), $txt);
- if($txt = prepare_text($a->profile['dislikes'])) $profile['dislikes'] = array( t('Dislikes:'), $txt);
+ if($txt = prepare_text(App::$profile['dislikes'])) $profile['dislikes'] = array( t('Dislikes:'), $txt);
- if($txt = prepare_text($a->profile['contact'])) $profile['contact'] = array( t('Contact information and Social Networks:'), $txt);
+ if($txt = prepare_text(App::$profile['contact'])) $profile['contact'] = array( t('Contact information and Social Networks:'), $txt);
- if($txt = prepare_text($a->profile['channels'])) $profile['channels'] = array( t('My other channels:'), $txt);
+ if($txt = prepare_text(App::$profile['channels'])) $profile['channels'] = array( t('My other channels:'), $txt);
- if($txt = prepare_text($a->profile['music'])) $profile['music'] = array( t('Musical interests:'), $txt);
+ if($txt = prepare_text(App::$profile['music'])) $profile['music'] = array( t('Musical interests:'), $txt);
- if($txt = prepare_text($a->profile['book'])) $profile['book'] = array( t('Books, literature:'), $txt);
+ if($txt = prepare_text(App::$profile['book'])) $profile['book'] = array( t('Books, literature:'), $txt);
- if($txt = prepare_text($a->profile['tv'])) $profile['tv'] = array( t('Television:'), $txt);
+ if($txt = prepare_text(App::$profile['tv'])) $profile['tv'] = array( t('Television:'), $txt);
- if($txt = prepare_text($a->profile['film'])) $profile['film'] = array( t('Film/dance/culture/entertainment:'), $txt);
+ if($txt = prepare_text(App::$profile['film'])) $profile['film'] = array( t('Film/dance/culture/entertainment:'), $txt);
- if($txt = prepare_text($a->profile['romance'])) $profile['romance'] = array( t('Love/Romance:'), $txt);
+ if($txt = prepare_text(App::$profile['romance'])) $profile['romance'] = array( t('Love/Romance:'), $txt);
- if($txt = prepare_text($a->profile['work'])) $profile['work'] = array( t('Work/employment:'), $txt);
+ if($txt = prepare_text(App::$profile['work'])) $profile['work'] = array( t('Work/employment:'), $txt);
- if($txt = prepare_text($a->profile['education'])) $profile['education'] = array( t('School/education:'), $txt );
+ if($txt = prepare_text(App::$profile['education'])) $profile['education'] = array( t('School/education:'), $txt );
- if($a->profile['extra_fields']) {
- foreach($a->profile['extra_fields'] as $f) {
+ if(App::$profile['extra_fields']) {
+ foreach(App::$profile['extra_fields'] as $f) {
$x = q("select * from profdef where field_name = '%s' limit 1",
dbesc($f)
);
- if($x && $txt = prepare_text($a->profile[$f]))
+ if($x && $txt = prepare_text(App::$profile[$f]))
$profile[$f] = array( $x[0]['field_desc'] . ':',$txt);
}
- $profile['extra_fields'] = $a->profile['extra_fields'];
+ $profile['extra_fields'] = App::$profile['extra_fields'];
}
- $things = get_things($a->profile['profile_guid'],$a->profile['profile_uid']);
+ $things = get_things(App::$profile['profile_guid'],App::$profile['profile_uid']);
// logger('mod_profile: things: ' . print_r($things,true), LOGGER_DATA);
@@ -1350,6 +1389,8 @@ function advanced_profile(&$a) {
'$canlike' => (($profile['canlike'])? true : false),
'$likethis' => t('Like this thing'),
'$profile' => $profile,
+ '$fields' => $clean_fields,
+ '$editmenu' => profile_edit_menu(App::$profile['profile_uid']),
'$things' => $things
));
}
@@ -1392,7 +1433,7 @@ function zid_init(&$a) {
$tmp_str = get_my_address();
if(validate_email($tmp_str)) {
proc_run('php','include/gprobe.php',bin2hex($tmp_str));
- $arr = array('zid' => $tmp_str, 'url' => $a->cmd);
+ $arr = array('zid' => $tmp_str, 'url' => App::$cmd);
call_hooks('zid_init',$arr);
if(! local_channel()) {
$r = q("select * from hubloc where hubloc_addr = '%s' order by hubloc_connected desc limit 1",
@@ -1402,7 +1443,7 @@ function zid_init(&$a) {
return;
logger('zid_init: not authenticated. Invoking reverse magic-auth for ' . $tmp_str);
// try to avoid recursion - but send them home to do a proper magic auth
- $query = $a->query_string;
+ $query = App::$query_string;
$query = str_replace(array('?zid=','&zid='),array('?rzid=','&rzid='),$query);
$dest = '/' . urlencode($query);
if($r && ($r[0]['hubloc_url'] != z_root()) && (! strstr($dest,'/magic')) && (! strstr($dest,'/rmagic'))) {
@@ -1583,7 +1624,7 @@ function identity_selector() {
intval(get_account_id())
);
if (count($r) > 1) {
- //$account = get_app()->get_account();
+ //$account = App::get_account();
$o = replace_macros(get_markup_template('channel_id_select.tpl'), array(
'$channels' => $r,
'$selected' => local_channel()
@@ -1601,7 +1642,7 @@ function is_public_profile() {
return false;
if(intval(get_config('system','block_public')))
return false;
- $channel = get_app()->get_channel();
+ $channel = App::get_channel();
if($channel && $channel['channel_r_profile'] == PERMS_PUBLIC)
return true;
@@ -1695,3 +1736,145 @@ 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');
+
+ $maxwidth = (($args['width']) ? intval($args['width']) : 0);
+ $maxheight = (($args['height']) ? intval($args['height']) : 0);
+
+
+ if(($maxwidth > 1200) || ($maxwidth < 1))
+ $maxwidth = 1200;
+
+ if($maxwidth <= 425) {
+ $width = 425;
+ $size = 'hz_small';
+ $cover_size = PHOTO_RES_COVER_425;
+ $pphoto = array('type' => $channel['xchan_photo_mimetype'], 'width' => 80 , 'height' => 80, 'href' => $channel['xchan_photo_m']);
+ }
+ elseif($maxwidth <= 900) {
+ $width = 900;
+ $size = 'hz_medium';
+ $cover_size = PHOTO_RES_COVER_850;
+ $pphoto = array('type' => $channel['xchan_photo_mimetype'], 'width' => 160 , 'height' => 160, 'href' => $channel['xchan_photo_l']);
+ }
+ elseif($maxwidth <= 1200) {
+ $width = 1200;
+ $size = 'hz_large';
+ $cover_size = PHOTO_RES_COVER_1200;
+ $pphoto = array('type' => $channel['xchan_photo_mimetype'], 'width' => 300 , 'height' => 300, 'href' => $channel['xchan_photo_l']);
+ }
+
+// $scale = (float) $maxwidth / $width;
+// $translate = intval(($scale / 1.0) * 100);
+
+
+ $channel['channel_addr'] = $channel['channel_address'] . '@' . App::get_hostname();
+ $zcard = array('chan' => $channel);
+
+ $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($cover_size),
+ intval(PHOTO_COVER)
+ );
+
+ if($r) {
+ $cover = $r[0];
+ $cover['href'] = z_root() . '/photo/' . $r[0]['resource_id'] . '-' . $r[0]['scale'];
+ }
+ else {
+ $cover = $pphoto;
+ }
+
+ $o .= replace_macros(get_markup_template('zcard.tpl'),array(
+ '$maxwidth' => $maxwidth,
+ '$scale' => $scale,
+ '$translate' => $translate,
+ '$size' => $size,
+ '$cover' => $cover,
+ '$pphoto' => $pphoto,
+ '$zcard' => $zcard
+ ));
+
+ return $o;
+
+}