X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fprofile.php;h=827530bc8aa63afa8a1c532c16a84a5d9ec7a2e8;hb=fecef140d5181348e1f46cf8405f13bb05401b3e;hp=6923b092326c685657ae7edb4365b3db2179737c;hpb=65a420b22755f774dc2422f7fdf3709e01289945;p=friendica.git diff --git a/mod/profile.php b/mod/profile.php index 6923b09232..827530bc8a 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -1,50 +1,5 @@ error = 404; - return; - } - - $a->profile = $r[0]; - - $a->page['template'] = 'profile'; - - $a->page['title'] = $a->profile['name']; - $_SESSION['theme'] = $a->profile['theme']; - - return; -}} - function profile_init(&$a) { if($a->argc > 1) @@ -56,17 +11,29 @@ function profile_init(&$a) { } $profile = 0; - if((local_user()) && ($a->argc > 2) && ($a->argv[2] == 'view')) { + if((local_user()) && ($a->argc > 2) && ($a->argv[2] === 'view')) { $which = $a->user['nickname']; $profile = $a->argv[1]; } + profile_load($a,$which,$profile); - $a->page['htmlhead'] .= '' . "\r\n" ; - $a->page['htmlhead'] .= '' . "\r\n" ; - $a->page['htmlhead'] .= '' . "\r\n" ; - - + if((x($a->profile,'page-flags')) && ($a->profile['page-flags'] & PAGE_COMMUNITY)) { + $a->page['htmlhead'] .= ''; + } + if(x($a->profile,'openidserver')) + $a->page['htmlhead'] .= '' . "\r\n"; + if(x($a->profile,'openid')) { + $delegate = ((strstr($a->profile['openid'],'://')) ? $a->profile['openid'] : 'http://' . $a->profile['openid']); + $a->page['htmlhead'] .= '' . "\r\n"; + } + + $a->page['htmlhead'] .= '' . "\r\n" ; + $a->page['htmlhead'] .= '' . "\r\n" ; + $uri = urlencode('acct:' . $a->profile['nickname'] . '@' . $a->get_hostname() . (($a->path) ? '/' . $a->path : '')); + $a->page['htmlhead'] .= '' . "\r\n"; + header('Link: <' . $a->get_baseurl() . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false); + $dfrn_pages = array('request', 'confirm', 'notify', 'poll'); foreach($dfrn_pages as $dfrn) $a->page['htmlhead'] .= "get_baseurl()."/dfrn_{$dfrn}/{$which}\" />\r\n"; @@ -74,7 +41,7 @@ function profile_init(&$a) { } -function profile_content(&$a, $update = false) { +function profile_content(&$a, $update = 0) { require_once("include/bbcode.php"); require_once('include/security.php'); @@ -82,16 +49,15 @@ function profile_content(&$a, $update = false) { $groups = array(); $tab = 'posts'; - + $o = ''; if($update) { // Ensure we've got a profile owner if updating. - $a->profile['profile_uid'] = $_SESSION['profile_uid']; + $a->profile['profile_uid'] = $update; } else { - $o .= ''; - // set the uid so we can pick it up during update - $_SESSION['profile_uid'] = $a->profile['uid']; + if($a->profile['profile_uid'] == local_user()) + $o .= ''; } $contact = null; @@ -117,11 +83,13 @@ function profile_content(&$a, $update = false) { } } + $is_owner = ((local_user()) && (local_user() == $a->profile['profile_uid']) ? true : false); + if(! $update) { if(x($_GET,'tab')) $tab = notags(trim($_GET['tab'])); - $tpl = file_get_contents('view/profile_tabs.tpl'); + $tpl = load_view_file('view/profile_tabs.tpl'); $o .= replace_macros($tpl,array( '$url' => $a->get_baseurl() . '/' . $a->cmd, @@ -129,50 +97,88 @@ function profile_content(&$a, $update = false) { )); - if($tab == 'profile') { - require_once('view/profile_advanced.php'); + if($tab === 'profile') { + $profile_lang = get_config('system','language'); + if(! $profile_lang) + $profile_lang = 'en'; + if(file_exists("view/$profile_lang/profile_advanced.php")) + require_once("view/$profile_lang/profile_advanced.php"); + else + require_once('view/profile_advanced.php'); + + call_hooks('profile_advanced',$o); + return $o; } + $commpage = (($a->profile['page-flags'] == PAGE_COMMUNITY) ? true : false); + $commvisitor = (($commpage && $remote_contact == true) ? true : false); + + $celeb = ((($a->profile['page-flags'] == PAGE_SOAPBOX) || ($a->profile['page-flags'] == PAGE_COMMUNITY)) ? true : false); + if(can_write_wall($a,$a->profile['profile_uid'])) { - $tpl = file_get_contents('view/jot-header.tpl'); + + $geotag = ((($is_owner || $commvisitor) && $a->profile['allow_location']) ? load_view_file('view/jot_geotag.tpl') : ''); + + $tpl = load_view_file('view/jot-header.tpl'); - $a->page['htmlhead'] .= replace_macros($tpl, array('$baseurl' => $a->get_baseurl())); - require_once('view/acl_selectors.php'); + $a->page['htmlhead'] .= replace_macros($tpl, array( + '$baseurl' => $a->get_baseurl(), + '$geotag' => $geotag, + '$nickname' => $a->profile['nickname'] + )); + + require_once('include/acl_selectors.php'); + + $tpl = load_view_file('view/jot.tpl'); - $tpl = file_get_contents("view/jot.tpl"); if(is_array($a->user) && ((strlen($a->user['allow_cid'])) || (strlen($a->user['allow_gid'])) || (strlen($a->user['deny_cid'])) || (strlen($a->user['deny_gid'])))) $lockstate = 'lock'; else $lockstate = 'unlock'; + + $jotplugins = ''; + $jotnets = ''; + call_hooks('jot_tool', $jotplugins); + + call_hooks('jot_networks', $jotnets); + + $tpl = replace_macros($tpl,array('$jotplugins' => $jotplugins)); + $o .= replace_macros($tpl,array( '$baseurl' => $a->get_baseurl(), - '$defloc' => (($_SESSION['uid'] == $a->profile['profile_uid']) ? $a->user['default-location'] : ''), + '$defloc' => (($is_owner) ? $a->user['default-location'] : ''), '$return_path' => $a->cmd, - '$visitor' => (($_SESSION['uid'] == $a->profile['profile_uid']) ? 'block' : 'none'), + '$visitor' => (($is_owner || $commvisitor) ? 'block' : 'none'), '$lockstate' => $lockstate, + '$emailcc' => t('CC: email addresses'), + '$jotnets' => $jotnets, + '$emtitle' => t('Example: bob@example.com, mary@example.com'), '$bang' => '', - '$acl' => (($_SESSION['uid'] == $a->profile['profile_uid']) ? populate_acl($a->user) : ''), + '$acl' => (($is_owner) ? populate_acl($a->user, $celeb) : ''), '$profile_uid' => $a->profile['profile_uid'] )); } - if($tab == 'posts' && (! $a->pager['start'])) + // This is ugly, but we can't pass the profile_uid through the session to the ajax updater, + // because browser prefetching might change it on us. We have to deliver it with the page. + + if($tab === 'posts') { $o .= '
' . "\r\n"; + $o .= "\r\n"; + } } - // TODO alter registration and settings and profile to update contact table when names and photos change. + // Construct permissions // default permissions - anonymous user $sql_extra = " AND `allow_cid` = '' AND `allow_gid` = '' AND `deny_cid` = '' AND `deny_gid` = '' "; - - - // Profile owner - everything is visible - if(local_user() && ($_SESSION['uid'] == $a->profile['profile_uid'])) { + if($is_owner) { $sql_extra = ''; // Oh - while we're here... reset the Unseen messages @@ -221,8 +227,8 @@ function profile_content(&$a, $update = false) { $a->set_pager_total($r[0]['total']); $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, - `contact`.`name`, `contact`.`photo`, `contact`.`url`, - `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`, + `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`network`, `contact`.`rel`, + `contact`.`thumb`, `contact`.`self`, `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid` FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 @@ -237,11 +243,17 @@ function profile_content(&$a, $update = false) { ); - $cmnt_tpl = file_get_contents('view/comment_item.tpl'); + if($is_owner && ! $update) + $o .= get_birthdays(); + + $cmnt_tpl = load_view_file('view/comment_item.tpl'); - $like_tpl = file_get_contents('view/like.tpl'); + $like_tpl = load_view_file('view/like.tpl'); - $tpl = file_get_contents('view/wall_item.tpl'); + $tpl = load_view_file('view/wall_item.tpl'); + + $droptpl = load_view_file('view/wall_item_drop.tpl'); + $fakedrop = load_view_file('view/wall_fake_drop.tpl'); if($update) $return_url = $_SESSION['return_url']; @@ -251,33 +263,16 @@ function profile_content(&$a, $update = false) { $alike = array(); $dlike = array(); - if(count($r)) { + if($r !== false && count($r)) { foreach($r as $item) { - - if(($item['verb'] == ACTIVITY_LIKE) && ($item['id'] != $item['parent'])) { - $url = $item['url']; - if(($item['rel'] == REL_VIP || $item['rel'] == REL_BUD) && (! $item['self'])) - $url = $a->get_baseurl() . '/redir/' . $item['contact-id']; - if(! is_array($alike[$item['parent'] . '-l'])) - $alike[$item['parent'] . '-l'] = array(); - $alike[$item['parent']] ++; - $alike[$item['parent'] . '-l'][] = '' . $item['name'] . ''; - } - if(($item['verb'] == ACTIVITY_DISLIKE) && ($item['id'] != $item['parent'])) { - $url = $item['url']; - if(($item['rel'] == REL_VIP || $item['rel'] == REL_BUD) && (! $item['self'])) - $url = $a->get_baseurl() . '/redir/' . $item['contact-id']; - if(! is_array($dlike[$item['parent'] . '-l'])) - $dlike[$item['parent'] . '-l'] = array(); - $dlike[$item['parent']] ++; - $dlike[$item['parent'] . '-l'][] = '' . $item['name'] . ''; - } + like_puller($a,$item,$alike,'like'); + like_puller($a,$item,$dlike,'dislike'); } foreach($r as $item) { - + $sparkle = ''; $comment = ''; $likebuttons = ''; @@ -285,22 +280,29 @@ function profile_content(&$a, $update = false) { $redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'] ; - if((($item['verb'] == ACTIVITY_LIKE) || ($item['verb'] == ACTIVITY_DISLIKE)) && ($item['id'] != $item['parent'])) + if(((activity_match($item['verb'],ACTIVITY_LIKE)) || (activity_match($item['verb'],ACTIVITY_DISLIKE))) + && ($item['id'] != $item['parent'])) continue; + $lock = ((($item['private']) || (($item['uid'] == local_user()) && (strlen($item['allow_cid']) || strlen($item['allow_gid']) + || strlen($item['deny_cid']) || strlen($item['deny_gid'])))) + ? '