use zrl to get home again

This commit is contained in:
friendica 2012-03-29 20:58:32 -07:00
parent cd47ba6ed1
commit bb8beb26b4
7 changed files with 54 additions and 17 deletions

View file

@ -1415,3 +1415,21 @@ function profile_tabs($a, $is_owner=False, $nickname=Null){
return replace_macros($tpl,array('$tabs' => $arr['tabs'])); return replace_macros($tpl,array('$tabs' => $arr['tabs']));
}} }}
function get_my_url() {
if(x($_SESSION,'my_url'))
return $_SESSION['my_url'];
return false;
}
function zrl($s) {
if(! strlen($s))
return $s;
if(! strpos($s,'/profile/'))
return $s;
$achar = strpos($s,'?') ? '&' : '?';
$mine = get_my_url();
if($mine and ! link_compare($mine,$s))
return $s . $achar . 'zrl=' . urlencode($mine);
return $s;
}

View file

@ -94,9 +94,9 @@ function localize_item(&$item){
} }
$A = '[url=' . $Alink . ']' . $Aname . '[/url]'; $A = '[url=' . zrl($Alink) . ']' . $Aname . '[/url]';
$B = '[url=' . $Blink . ']' . $Bname . '[/url]'; $B = '[url=' . zrl($Blink) . ']' . $Bname . '[/url]';
if ($Bphoto!="") $Bphoto = '[url=' . $Blink . '][img]' . $Bphoto . '[/img][/url]'; if ($Bphoto!="") $Bphoto = '[url=' . zrl($Blink) . '][img]' . $Bphoto . '[/img][/url]';
$item['body'] = sprintf( t('%1$s is now friends with %2$s'), $A, $B)."\n\n\n".$Bphoto; $item['body'] = sprintf( t('%1$s is now friends with %2$s'), $A, $B)."\n\n\n".$Bphoto;
@ -108,8 +108,8 @@ function localize_item(&$item){
if(count($r)==0) return; if(count($r)==0) return;
$obj=$r[0]; $obj=$r[0];
$author = '[url=' . $item['author-link'] . ']' . $item['author-name'] . '[/url]'; $author = '[url=' . zrl($item['author-link']) . ']' . $item['author-name'] . '[/url]';
$objauthor = '[url=' . $obj['author-link'] . ']' . $obj['author-name'] . '[/url]'; $objauthor = '[url=' . zrl($obj['author-link']) . ']' . $obj['author-name'] . '[/url]';
switch($obj['verb']){ switch($obj['verb']){
case ACTIVITY_POST: case ACTIVITY_POST:
@ -158,8 +158,8 @@ function localize_item(&$item){
$target = $r[0]; $target = $r[0];
$Bname = $target['author-name']; $Bname = $target['author-name'];
$Blink = $target['author-link']; $Blink = $target['author-link'];
$A = '[url=' . $Alink . ']' . $Aname . '[/url]'; $A = '[url=' . zrl($Alink) . ']' . $Aname . '[/url]';
$B = '[url=' . $Blink . ']' . $Bname . '[/url]'; $B = '[url=' . zrl($Blink) . ']' . $Bname . '[/url]';
$P = '[url=' . $target['plink'] . ']' . t('post/item') . '[/url]'; $P = '[url=' . $target['plink'] . ']' . t('post/item') . '[/url]';
$item['body'] = sprintf( t('%1$s marked %2$s\'s %3$s as favorite'), $A, $B, $P)."\n"; $item['body'] = sprintf( t('%1$s marked %2$s\'s %3$s as favorite'), $A, $B, $P)."\n";
@ -276,13 +276,16 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
if($item['author-link'] && (! $item['author-name'])) if($item['author-link'] && (! $item['author-name']))
$profile_name = $item['author-link']; $profile_name = $item['author-link'];
$sp = false; $sp = false;
$profile_link = best_link_url($item,$sp); $profile_link = best_link_url($item,$sp);
if($sp)
$sparkle = ' sparkle';
if($profile_link === 'mailbox') if($profile_link === 'mailbox')
$profile_link = ''; $profile_link = '';
if($sp)
$sparkle = ' sparkle';
else
$profile_link = zrl($profile_link);
$normalised = normalise_link((strlen($item['author-link'])) ? $item['author-link'] : $item['url']); $normalised = normalise_link((strlen($item['author-link'])) ? $item['author-link'] : $item['url']);
if(($normalised != 'mailbox') && (x($a->contacts[$normalised]))) if(($normalised != 'mailbox') && (x($a->contacts[$normalised])))
@ -484,7 +487,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
// This will have been stored in $a->page_contact by our calling page. // This will have been stored in $a->page_contact by our calling page.
// Put this person on the left of the wall-to-wall notice. // Put this person on the left of the wall-to-wall notice.
$owner_url = $a->page_contact['url']; $owner_url = zrl($a->page_contact['url']);
$owner_photo = $a->page_contact['thumb']; $owner_photo = $a->page_contact['thumb'];
$owner_name = $a->page_contact['name']; $owner_name = $a->page_contact['name'];
$template = $wallwall; $template = $wallwall;
@ -501,10 +504,12 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
$commentww = 'ww'; $commentww = 'ww';
// If it is our contact, use a friendly redirect link // If it is our contact, use a friendly redirect link
if((link_compare($item['owner-link'],$item['url'])) if((link_compare($item['owner-link'],$item['url']))
&& ($item['network'] === 'dfrn')) { && ($item['network'] === NETWORK_DFRN)) {
$owner_url = $redirect_url; $owner_url = $redirect_url;
$osparkle = ' sparkle'; $osparkle = ' sparkle';
} }
else
$owner_url = zrl($owner_url);
} }
} }
@ -596,14 +601,14 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
if($item['author-link'] && (! $item['author-name'])) if($item['author-link'] && (! $item['author-name']))
$profile_name = $item['author-link']; $profile_name = $item['author-link'];
$sp = false; $sp = false;
$profile_link = best_link_url($item,$sp); $profile_link = best_link_url($item,$sp);
if($sp)
$sparkle = ' sparkle';
if($profile_link === 'mailbox') if($profile_link === 'mailbox')
$profile_link = ''; $profile_link = '';
if($sp)
$sparkle = ' sparkle';
else
$profile_link = zrl($profile_link);
$normalised = normalise_link((strlen($item['author-link'])) ? $item['author-link'] : $item['url']); $normalised = normalise_link((strlen($item['author-link'])) ? $item['author-link'] : $item['url']);
if(($normalised != 'mailbox') && (x($a->contacts,$normalised))) if(($normalised != 'mailbox') && (x($a->contacts,$normalised)))
@ -767,8 +772,10 @@ function item_photo_menu($item){
$photos_link = $profile_link . "?url=photos"; $photos_link = $profile_link . "?url=photos";
$profile_link = $profile_link . "?url=profile"; $profile_link = $profile_link . "?url=profile";
$pm_url = $a->get_baseurl($ssl_state) . '/message/new/' . $cid; $pm_url = $a->get_baseurl($ssl_state) . '/message/new/' . $cid;
$zurl = '';
} }
else { else {
$profile_link = zrl($profile_link);
if(local_user() && local_user() == $item['uid'] && link_compare($item['url'],$item['author-link'])) { if(local_user() && local_user() == $item['uid'] && link_compare($item['url'],$item['author-link'])) {
$cid = $item['contact-id']; $cid = $item['contact-id'];
} }
@ -795,7 +802,7 @@ function item_photo_menu($item){
$menu = Array( $menu = Array(
t("View status") => $status_link, t("View status") => $status_link,
t("View profile") => $profile_link, t("View profile") => $profile_link,
t("View photos") => $photos_link, t("View photos") => $photos_link,
t("View recent") => $posts_link, t("View recent") => $posts_link,
t("Edit contact") => $contact_url, t("Edit contact") => $contact_url,
t("Send PM") => $pm_url, t("Send PM") => $pm_url,
@ -828,6 +835,8 @@ function like_puller($a,$item,&$arr,$mode) {
$url = $a->get_baseurl(true) . '/redir/' . $item['contact-id']; $url = $a->get_baseurl(true) . '/redir/' . $item['contact-id'];
$sparkle = ' class="sparkle" '; $sparkle = ' class="sparkle" ';
} }
else
$url = zrl($url);
if(! ((isset($arr[$item['parent'] . '-l'])) && (is_array($arr[$item['parent'] . '-l'])))) if(! ((isset($arr[$item['parent'] . '-l'])) && (is_array($arr[$item['parent'] . '-l']))))
$arr[$item['parent'] . '-l'] = array(); $arr[$item['parent'] . '-l'] = array();
if(! isset($arr[$item['parent']])) if(! isset($arr[$item['parent']]))

View file

@ -70,6 +70,8 @@ function nav(&$a) {
*/ */
$homelink = ((x($_SESSION,'visitor_home')) ? $_SESSION['visitor_home'] : ''); $homelink = ((x($_SESSION,'visitor_home')) ? $_SESSION['visitor_home'] : '');
if(get_my_url())
$homelink = get_my_url();
if(($a->module != 'home') && (! (local_user()))) if(($a->module != 'home') && (! (local_user())))
$nav['home'] = array($homelink, t('Home'), "", t('Home Page')); $nav['home'] = array($homelink, t('Home'), "", t('Home Page'));

View file

@ -9,6 +9,7 @@ function authenticate_success($user_record, $login_initial = false, $interactive
$_SESSION['authenticated'] = 1; $_SESSION['authenticated'] = 1;
$_SESSION['page_flags'] = $user_record['page-flags']; $_SESSION['page_flags'] = $user_record['page-flags'];
$_SESSION['my_url'] = $a->get_baseurl() . '/profile/' . $user_record['nickname']; $_SESSION['my_url'] = $a->get_baseurl() . '/profile/' . $user_record['nickname'];
$_SESSION['my_address'] = $user_record['nickname'] . '@' . substr($a->get_baseurl(),strpos($a->get_baseurl(),'://')+3);
$_SESSION['addr'] = $_SERVER['REMOTE_ADDR']; $_SESSION['addr'] = $_SERVER['REMOTE_ADDR'];
$a->user = $user_record; $a->user = $user_record;

View file

@ -610,6 +610,8 @@ function micropro($contact, $redirect = false, $class = '', $textmode = false) {
$url = $redirect_url; $url = $redirect_url;
$sparkle = ' sparkle'; $sparkle = ' sparkle';
} }
else
$url = zrl($url);
} }
$click = ((x($contact,'click')) ? ' onclick="' . $contact['click'] . '" ' : ''); $click = ((x($contact,'click')) ? ' onclick="' . $contact['click'] . '" ' : '');
if($click) if($click)

View file

@ -93,6 +93,9 @@ if((x($_SESSION,'language')) && ($_SESSION['language'] !== $lang)) {
load_translation_table($lang); load_translation_table($lang);
} }
if(x($_GET,'zurl')) {
$_SESSION['my_url'] = $_GET['zurl'];
}
/** /**
* *

View file

@ -54,6 +54,8 @@ function viewcontacts_content(&$a) {
if($is_owner && ($rr['network'] === NETWORK_DFRN) && ($rr['rel'])) if($is_owner && ($rr['network'] === NETWORK_DFRN) && ($rr['rel']))
$url = 'redir/' . $rr['id']; $url = 'redir/' . $rr['id'];
else
$url = zrl($url);
$contacts[] = array( $contacts[] = array(
'id' => $rr['id'], 'id' => $rr['id'],