From 059e090b53643cb07a2634b700ada5cf3b6894e8 Mon Sep 17 00:00:00 2001 From: Mike Macgirvin Date: Fri, 16 Jul 2010 06:24:41 -0700 Subject: sorting out visitor sessions --- mod/dfrn_notify.php | 14 +++++++++++++- mod/dfrn_poll.php | 2 +- mod/profile.php | 23 +++++++++++++---------- 3 files changed, 27 insertions(+), 12 deletions(-) (limited to 'mod') diff --git a/mod/dfrn_notify.php b/mod/dfrn_notify.php index 501147142..6ab8d584a 100644 --- a/mod/dfrn_notify.php +++ b/mod/dfrn_notify.php @@ -32,6 +32,13 @@ function get_atom_elements($item) { if($rawedited) $res['edited'] = $rawcreated[0]['data']; + $rawowner = $item->get_item_tags('http://purl.org/macgirvin/dfrn/1.0", 'owner'); + if($rawowner[0]['child']['http://purl.org/macgirvin/dfrn/1.0']['name'][0]['data']) + $res['owner-name'] = rawowner[0]['child']['http://purl.org/macgirvin/dfrn/1.0']['name'][0]['data']; + if($rawowner[0]['child']['http://purl.org/macgirvin/dfrn/1.0']['uri'][0]['data']) + $res['owner-link'] = rawowner[0]['child']['http://purl.org/macgirvin/dfrn/1.0']['uri'][0]['data']; + if($rawowner[0]['child']['http://purl.org/macgirvin/dfrn/1.0']['avatar'][0]['data']) + $res['owner-avatar'] = rawowner[0]['child']['http://purl.org/macgirvin/dfrn/1.0']['avatar'][0]['data']; return $res; @@ -45,13 +52,18 @@ function post_remote($arr) { $arr['remote-name'] = notags(trim($arr['remote-name'])); $arr['remote-link'] = notags(trim($arr['remote-link'])); $arr['remote-avatar'] = notags(trim($arr['remote-avatar'])); + $arr['owner-name'] = notags(trim($arr['owner-name'])); + $arr['owner-link'] = notags(trim($arr['owner-link'])); + $arr['owner-avatar'] = notags(trim($arr['owner-avatar'])); if(! strlen($arr['remote-avatar'])) $arr['remote-avatar'] = $a->get_baseurl() . '/images/default-profile-sm.jpg'; + if(! strlen($arr['owner-avatar'])) + $arr['owner-avatar'] = $a->get_baseurl() . '/images/default-profile-sm.jpg'; $arr['created'] = datetime_convert('UTC','UTC',$arr['created'],'Y-m-d H:i:s'); $arr['edited'] = datetime_convert('UTC','UTC',$arr['edited'],'Y-m-d H:i:s'); $arr['title'] = notags(trim($arr['title'])); $arr['body'] = escape_tags(trim($arr['body'])); - $arr['last-child'] = intval($arr['last_child']); + $arr['last-child'] = intval($arr['last-child']); $arr['visible'] = 1; $arr['deleted'] = 0; diff --git a/mod/dfrn_poll.php b/mod/dfrn_poll.php index da60eb629..887352694 100644 --- a/mod/dfrn_poll.php +++ b/mod/dfrn_poll.php @@ -39,7 +39,7 @@ function dfrn_poll_init(&$a) { } } $profile = ((strlen($r[0]['nickname'])) ? $r[0]['nickname'] : $r[0]['uid']); - goaway($a->get_baseurl() . "/profile/$profile"); + goaway($a->get_baseurl() . "/profile/$profile/visit"); } goaway($a->get_baseurl()); } diff --git a/mod/profile.php b/mod/profile.php index 5a1ac0639..6bd265562 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -43,12 +43,6 @@ function profile_load(&$a,$uid,$profile = 0) { function profile_init(&$a) { - if($_SESSION['authenticated']) { - - // choose which page to show (could be remote auth) - - } - if($a->argc > 1) $which = $a->argv[1]; else { @@ -57,6 +51,15 @@ function profile_init(&$a) { return; } + if(($remote_user) && ($a->argc > 2) && ($a->argv[2] == 'visit')) + $_SESSION['is_visitor'] = 1; + else { + unset($_SESSION['is_visitor']); + unset($_SESSION['visitor_id']); + if(! $_SESSION['uid']) + unset($_SESSION['authenticated']); + } + profile_load($a,$which); $a->page['htmlhead'] .= "get_baseurl() . "/profile/%s" . "\" />\r\n"; @@ -79,9 +82,9 @@ function item_display(&$a, $item,$template,$comment) { $o .= replace_macros($template,array( '$id' => $item['item_id'], - '$profile_url' => $profile_url, - '$name' => $item['name'], - '$thumb' => $thumb, + '$profile_url' => ((strlen($item['remote-link'])) ? $item['remote-link'] : $profile_url), + '$name' => ((strlen($item['remote-name'])) ? $item['remote-name'] : $item['name']), + '$thumb' => ((strlen($item['remote-avatar'])) ? $item['remote-avatar'] : $thumb), '$body' => bbcode($item['body']), '$ago' => relative_date($item['created']), '$indent' => (($item['parent'] != $item['item_id']) ? 'comment-' : ''), @@ -196,7 +199,7 @@ function profile_content(&$a) { if(count($r)) $a->set_pager_total($r[0]['total']); - +dbg(2); $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, `contact`.`name`, `contact`.`photo`, `contact`.`url`, -- cgit v1.2.3