X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fidentity.php;h=2230d98a42f66385948fbf8d6efafd15bda3ecc3;hb=37bd03422bf74bd7fe8213fa519c3eb3efd83af5;hp=0fba0c592f02d60f214d34838837e58befd96590;hpb=af5da5bece626f0a8b42055fa4fae465e4cd7a23;p=friendica.git diff --git a/include/identity.php b/include/identity.php index 0fba0c592f..2230d98a42 100644 --- a/include/identity.php +++ b/include/identity.php @@ -1,4 +1,9 @@ query_string, LOGGER_DEBUG); notice( t('Requested profile is not available.') . EOL ); $a->error = 404; @@ -81,16 +56,16 @@ if(! function_exists('profile_load')) { // fetch user tags if this isn't the default profile - if(!$r[0]['is-default']) { - $x = q("select `pub_keywords` from `profile` where uid = %d and `is-default` = 1 limit 1", - intval($r[0]['profile_uid']) + if(!$pdata['is-default']) { + $x = q("SELECT `pub_keywords` FROM `profile` WHERE `uid` = %d AND `is-default` = 1 LIMIT 1", + 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; @@ -142,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 @@ -156,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(); @@ -165,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; @@ -173,12 +198,8 @@ 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']); - } else + $profile['network_name'] = format_network_name($profile['network'],$profile['url']); + } else $profile['network_name'] = ""; call_hooks('profile_sidebar_enter', $profile); @@ -211,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; @@ -260,6 +286,16 @@ if(! function_exists('profile_sidebar')) { ); } + // check if profile is a forum + if((x($profile['page-flags']) == 2) + || (x($profile['page-flags']) == 5) + || (x($profile['forum'])) + || (x($profile['prv'])) + || (x($profile['community']))) + $account_type = t('Forum'); + else + $account_type = ""; + if((x($profile,'address') == 1) || (x($profile,'locality') == 1) || (x($profile,'region') == 1) @@ -306,7 +342,7 @@ if(! function_exists('profile_sidebar')) { if(count($r)) $updated = date("c", strtotime($r[0]['updated'])); - $r = q("SELECT COUNT(*) AS `total` FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 and `pending` = 0 AND `hidden` = 0 AND `archive` = 0 + $r = q("SELECT COUNT(*) AS `total` FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 AND `pending` = 0 AND `hidden` = 0 AND `archive` = 0 AND `network` IN ('%s', '%s', '%s', '')", intval($profile['uid']), dbesc(NETWORK_DFRN), @@ -332,10 +368,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, @@ -501,7 +539,7 @@ if(! function_exists('get_events')) { } $today = ((substr($strt,0,10) === datetime_convert('UTC',$a->timezone,'now','Y-m-d')) ? true : false); - + $rr['title'] = $title; $rr['description'] = $desciption; $rr['date'] = day_translate(datetime_convert('UTC', $rr['adjust'] ? $a->timezone : 'UTC', $rr['start'], $bd_format)) . (($today) ? ' ' . t('[today]') : ''); @@ -525,29 +563,30 @@ if(! function_exists('get_events')) { function advanced_profile(&$a) { $o = ''; + $uid = $a->profile['uid']; - $o .= replace_macros(get_markup_template("section_title.tpl"),array( + $o .= replace_macros(get_markup_template('section_title.tpl'),array( '$title' => t('Profile') )); if($a->profile['name']) { $tpl = get_markup_template('profile_advanced.tpl'); - + $profile = array(); - + $profile['fullname'] = array( t('Full Name:'), $a->profile['name'] ) ; - + if($a->profile['gender']) $profile['gender'] = array( t('Gender:'), $a->profile['gender'] ); - + if(($a->profile['dob']) && ($a->profile['dob'] != '0000-00-00')) { - + $year_bd_format = t('j F, Y'); $short_bd_format = t('j F'); - - $val = ((intval($a->profile['dob'])) + + $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))); @@ -556,7 +595,7 @@ function advanced_profile(&$a) { } if($age = age($a->profile['dob'],$a->profile['timezone'],'')) $profile['age'] = array( t('Age:'), $age ); - + if($a->profile['marital']) $profile['marital'] = array( t('Status:'), $a->profile['marital']); @@ -591,7 +630,7 @@ function advanced_profile(&$a) { if($txt = prepare_text($a->profile['contact'])) $profile['contact'] = array( t('Contact information and Social Networks:'), $txt); if($txt = prepare_text($a->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($a->profile['tv'])) $profile['tv'] = array( t('Television:'), $txt); @@ -599,14 +638,19 @@ function advanced_profile(&$a) { if($txt = prepare_text($a->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($a->profile['work'])) $profile['work'] = array( t('Work/employment:'), $txt); if($txt = prepare_text($a->profile['education'])) $profile['education'] = array( t('School/education:'), $txt ); - + + //show subcribed forum if it is enabled in the usersettings + if (feature_enabled($uid,'forumlist_profile')) { + $profile['forumlist'] = array( t('Forums:'), forumlist_profile_advanced($uid)); + } + if ($a->profile['uid'] == local_user()) $profile['edit'] = array($a->get_baseurl(). '/profiles/'.$a->profile['id'], t('Edit profile'),"", t('Edit profile')); - + return replace_macros($tpl, array( '$title' => t('Profile'), '$profile' => $profile @@ -664,14 +708,15 @@ if(! function_exists('profile_tabs')){ ); if ($is_owner){ - $tabs[] = array( - 'label' => t('Events'), - 'url' => $a->get_baseurl() . '/events', - 'sel' =>((!isset($tab)&&$a->argv[0]=='events')?'active':''), - 'title' => t('Events and Calendar'), - 'id' => 'events-tab', - 'accesskey' => 'e', - ); + if ($a->theme_events_in_profile) + $tabs[] = array( + 'label' => t('Events'), + 'url' => $a->get_baseurl() . '/events', + 'sel' =>((!isset($tab)&&$a->argv[0]=='events')?'active':''), + 'title' => t('Events and Calendar'), + 'id' => 'events-tab', + 'accesskey' => 'e', + ); $tabs[] = array( 'label' => t('Personal Notes'), 'url' => $a->get_baseurl() . '/notes', @@ -682,6 +727,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); @@ -709,7 +764,7 @@ function zrl_init(&$a) { $result = Cache::get("gprobe:".$urlparts["host"]); if (!is_null($result)) { $result = unserialize($result); - if ($result["network"] == NETWORK_FEED) { + if (in_array($result["network"], array(NETWORK_FEED, NETWORK_PHANTOM))) { logger("DDoS attempt detected for ".$urlparts["host"]." by ".$_SERVER["REMOTE_ADDR"].". server data: ".print_r($_SERVER, true), LOGGER_DEBUG); return; } @@ -737,8 +792,8 @@ function zrl($s,$force = false) { // Used from within PCSS themes to set theme parameters. If there's a // puid request variable, that is the "page owner" and normally their theme -// settings take precedence; unless a local user sets the "always_my_theme" -// system pconfig, which means they don't want to see anybody else's theme +// settings take precedence; unless a local user sets the "always_my_theme" +// system pconfig, which means they don't want to see anybody else's theme // settings except their own while on this site. function get_theme_uid() {