X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fidentity.php;h=d87d891a5cdf3120ff350542b51602849c28e430;hb=8944ad1ac1bb4293eeacd79536cdeed3173cad9a;hp=a785ce981dc8074873c9fb354b2e72a4e31f310d;hpb=5fe8ae514bedd3e53617f07eda96dff14755684d;p=friendica.git diff --git a/include/identity.php b/include/identity.php index a785ce981d..d87d891a5c 100644 --- a/include/identity.php +++ b/include/identity.php @@ -4,7 +4,8 @@ */ require_once('include/forums.php'); - +require_once('include/bbcode.php'); +require_once("mod/proxy.php"); /** * @@ -45,39 +46,9 @@ if(! function_exists('profile_load')) { return; } - if(remote_user() && count($_SESSION['remote'])) { - foreach($_SESSION['remote'] as $visitor) { - if($visitor['uid'] == $user[0]['uid']) { - $r = q("SELECT `profile-id` FROM `contact` WHERE `id` = %d LIMIT 1", - intval($visitor['cid']) - ); - if(count($r)) - $profile = $r[0]['profile-id']; - break; - } - } - } - - $r = null; - - if($profile) { - $profile_int = intval($profile); - $r = q("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `contact`.`avatar-date` AS picdate, `contact`.`addr` AS faddr, `user`.* FROM `profile` - INNER JOIN `contact` on `contact`.`uid` = `profile`.`uid` INNER JOIN `user` ON `profile`.`uid` = `user`.`uid` - WHERE `user`.`nickname` = '%s' AND `profile`.`id` = %d AND `contact`.`self` = 1 LIMIT 1", - dbesc($nickname), - intval($profile_int) - ); - } - if((!$r) && (!count($r))) { - $r = q("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `contact`.`avatar-date` AS picdate, `contact`.`addr` AS faddr, `user`.* FROM `profile` - INNER JOIN `contact` ON `contact`.`uid` = `profile`.`uid` INNER JOIN `user` ON `profile`.`uid` = `user`.`uid` - WHERE `user`.`nickname` = '%s' AND `profile`.`is-default` = 1 AND `contact`.`self` = 1 LIMIT 1", - dbesc($nickname) - ); - } + $pdata = get_profiledata_by_nick($nickname, $user[0]['uid'], $profile); - if(($r === false) || (!count($r)) && !count($profiledata)) { + if(($pdata === false) || (!count($pdata)) && !count($profiledata)) { logger('profile error: ' . $a->query_string, LOGGER_DEBUG); notice( t('Requested profile is not available.') . EOL ); $a->error = 404; @@ -86,16 +57,16 @@ if(! function_exists('profile_load')) { // fetch user tags if this isn't the default profile - if(!$r[0]['is-default']) { + if(!$pdata['is-default']) { $x = q("SELECT `pub_keywords` FROM `profile` WHERE `uid` = %d AND `is-default` = 1 LIMIT 1", - intval($r[0]['profile_uid']) + intval($pdata['profile_uid']) ); if($x && count($x)) - $r[0]['pub_keywords'] = $x[0]['pub_keywords']; + $pdata['pub_keywords'] = $x[0]['pub_keywords']; } - $a->profile = $r[0]; - $a->profile_uid = $r[0]['profile_uid']; + $a->profile = $pdata; + $a->profile_uid = $pdata['profile_uid']; $a->profile['mobile-theme'] = get_pconfig($a->profile['profile_uid'], 'system', 'mobile_theme'); $a->profile['network'] = NETWORK_DFRN; @@ -138,7 +109,6 @@ if(! function_exists('profile_load')) { else $a->page['aside'] .= profile_sidebar($a->profile, $block); - /*if(! $block) $a->page['aside'] .= contact_block();*/ @@ -147,6 +117,58 @@ if(! function_exists('profile_load')) { } +/** + * @brief Get all profil data of a local user + * If the viewer is an authenticated remote viewer, the profile displayed is the + * one that has been configured for his/her viewing in the Contact manager. + * Passing a non-zero profile ID can also allow a preview of a selected profile + * by the owner + * + * @param string $nickname + * @param int $uid + * @param int $profile + * ID of the profile + * @returns array + * Includes all available profile data + */ +function get_profiledata_by_nick($nickname, $uid = 0, $profile = 0) { + if(remote_user() && count($_SESSION['remote'])) { + foreach($_SESSION['remote'] as $visitor) { + if($visitor['uid'] == $uid) { + $r = q("SELECT `profile-id` FROM `contact` WHERE `id` = %d LIMIT 1", + intval($visitor['cid']) + ); + if(count($r)) + $profile = $r[0]['profile-id']; + break; + } + } + } + + $r = null; + + if($profile) { + $profile_int = intval($profile); + $r = q("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `contact`.`avatar-date` AS picdate, `contact`.`addr`, `user`.* FROM `profile` + INNER JOIN `contact` on `contact`.`uid` = `profile`.`uid` INNER JOIN `user` ON `profile`.`uid` = `user`.`uid` + WHERE `user`.`nickname` = '%s' AND `profile`.`id` = %d AND `contact`.`self` = 1 LIMIT 1", + dbesc($nickname), + intval($profile_int) + ); + } + if((!$r) && (!count($r))) { + $r = q("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `contact`.`avatar-date` AS picdate, `contact`.`addr`, `user`.* FROM `profile` + INNER JOIN `contact` ON `contact`.`uid` = `profile`.`uid` INNER JOIN `user` ON `profile`.`uid` = `user`.`uid` + WHERE `user`.`nickname` = '%s' AND `profile`.`is-default` = 1 AND `contact`.`self` = 1 LIMIT 1", + dbesc($nickname) + ); + } + + return $r[0]; + +} + + /** * * Function: profile_sidebar @@ -161,8 +183,6 @@ if(! function_exists('profile_load')) { * Exceptions: Returns empty string if passed $profile is wrong type or not populated * */ - - if(! function_exists('profile_sidebar')) { function profile_sidebar($profile, $block = 0) { $a = get_app(); @@ -170,7 +190,7 @@ if(! function_exists('profile_sidebar')) { $o = ''; $location = false; $address = false; - $pdesc = true; +// $pdesc = true; if((! is_array($profile)) && (! count($profile))) return $o; @@ -178,11 +198,7 @@ if(! function_exists('profile_sidebar')) { $profile['picdate'] = urlencode($profile['picdate']); if (($profile['network'] != "") AND ($profile['network'] != NETWORK_DFRN)) { - require_once('include/contact_selectors.php'); - if ($profile['url'] != "") - $profile['network_name'] = ''.network_to_name($profile['network'], $profile['url']).""; - else - $profile['network_name'] = network_to_name($profile['network']); + $profile['network_name'] = format_network_name($profile['network'],$profile['url']); } else $profile['network_name'] = ""; @@ -216,12 +232,17 @@ if(! function_exists('profile_sidebar')) { } if ($connect AND ($profile['network'] != NETWORK_DFRN) AND !isset($profile['remoteconnect'])) - $connect = false; + $connect = false; if (isset($profile['remoteconnect'])) $remoteconnect = $profile['remoteconnect']; - if( get_my_url() && $profile['unkmail'] && ($profile['uid'] != local_user()) ) + if ($connect AND ($profile['network'] == NETWORK_DFRN) AND !isset($remoteconnect)) + $subscribe_feed = t("Atom feed"); + else + $subscribe_feed = false; + + if(get_my_url() && $profile['unkmail'] && ($profile['uid'] != local_user())) $wallmessage = t('Message'); else $wallmessage = false; @@ -265,6 +286,16 @@ if(! function_exists('profile_sidebar')) { ); } + // check if profile is a forum + if((intval($profile['page-flags']) == PAGE_COMMUNITY) + || (intval($profile['page-flags']) == PAGE_PRVGROUP) + || (intval($profile['forum'])) + || (intval($profile['prv'])) + || (intval($profile['community']))) + $account_type = t('Forum'); + else + $account_type = ""; + if((x($profile,'address') == 1) || (x($profile,'locality') == 1) || (x($profile,'region') == 1) @@ -329,6 +360,15 @@ if(! function_exists('profile_sidebar')) { $p[$k] = $v; } + if (isset($p["about"])) + $p["about"] = bbcode($p["about"]); + + if (isset($p["location"])) + $p["location"] = bbcode($p["location"]); + + if (isset($p["photo"])) + $p["photo"] = proxy_url($p["photo"], false, PROXY_SIZE_SMALL); + if($a->theme['template_engine'] === 'internal') $location = template_escape($location); @@ -337,10 +377,12 @@ if(! function_exists('profile_sidebar')) { '$profile' => $p, '$connect' => $connect, '$remoteconnect' => $remoteconnect, + '$subscribe_feed' => $subscribe_feed, '$wallmessage' => $wallmessage, + '$account_type' => $account_type, '$location' => $location, '$gender' => $gender, - '$pdesc' => $pdesc, +// '$pdesc' => $pdesc, '$marital' => $marital, '$homepage' => $homepage, '$about' => $about, @@ -694,6 +736,16 @@ if(! function_exists('profile_tabs')){ ); } + if ((! $is_owner) && ((count($a->profile)) || (! $a->profile['hide-friends']))) { + $tabs[] = array( + 'label' => t('Contacts'), + 'url' => $a->get_baseurl() . '/viewcontacts/' . $nickname, + 'sel' => ((!isset($tab)&&$a->argv[0]=='viewcontacts')?'active':''), + 'title' => t('Contacts'), + 'id' => 'viewcontacts-tab', + 'accesskey' => 'k', + ); + } $arr = array('is_owner' => $is_owner, 'nickname' => $nickname, 'tab' => (($tab) ? $tab : false), 'tabs' => $tabs); call_hooks('profile_tabs', $arr);