diff --git a/boot.php b/boot.php index b45bc5767..03a376165 100644 --- a/boot.php +++ b/boot.php @@ -866,7 +866,7 @@ function goaway($path) */ function local_user() { - if (x($_SESSION, 'authenticated') && x($_SESSION, 'uid')) { + if (!empty($_SESSION['authenticated']) && !empty($_SESSION['uid'])) { return intval($_SESSION['uid']); } return false; @@ -909,6 +909,11 @@ function remote_user() // if (local_user()) { // return false; // } + + if (empty($_SESSION)) { + return false; + } + if (x($_SESSION, 'authenticated') && x($_SESSION, 'visitor_id')) { return intval($_SESSION['visitor_id']); } diff --git a/include/api.php b/include/api.php index dd8daa9e6..4e8e9c232 100644 --- a/include/api.php +++ b/include/api.php @@ -169,7 +169,8 @@ function api_login(App $a) $oauth1 = new FKOAuth1(); // login with oauth try { - list($consumer, $token) = $oauth1->verify_request(OAuthRequest::from_request()); + $request = OAuthRequest::from_request(); + list($consumer, $token) = $oauth1->verify_request($request); if (!is_null($token)) { $oauth1->loginUser($token->uid); Addon::callHooks('logged_in', $a->user); diff --git a/include/conversation.php b/include/conversation.php index 5ce02a55f..de7a13626 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -349,7 +349,10 @@ function localize_item(&$item) // add sparkle links to appropriate permalinks $author = ['uid' => 0, 'id' => $item['author-id'], 'network' => $item['author-network'], 'url' => $item['author-link']]; - $item['plink'] = Contact::magicLinkbyContact($author, $item['plink']); + + if (!empty($item['plink'])) { + $item['plink'] = Contact::magicLinkbyContact($author, $item['plink']); + } } /** @@ -482,7 +485,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false, $order = $profile_owner = $a->profile['uid']; if (!$update) { $live_update_div = '
' . "\r\n" - . ""; } } elseif ($mode === 'community') { @@ -631,8 +634,8 @@ function conversation(App $a, $items, $mode, $update, $preview = false, $order = $tmp_item = [ 'template' => $tpl, - 'id' => (($preview) ? 'P0' : $item['item_id']), - 'guid' => (($preview) ? 'Q0' : $item['guid']), + 'id' => ($preview ? 'P0' : $item['id']), + 'guid' => ($preview ? 'Q0' : $item['guid']), 'network' => $item['network'], 'network_name' => ContactSelector::networkToName($item['network'], $profile_link), 'linktitle' => L10n::t('View %s\'s profile @ %s', $profile_name, $item['author-link']), @@ -679,7 +682,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false, $order = $arr = ['item' => $item, 'output' => $tmp_item]; Addon::callHooks('display_item', $arr); - $threads[$threadsid]['id'] = $item['item_id']; + $threads[$threadsid]['id'] = $item['id']; $threads[$threadsid]['network'] = $item['network']; $threads[$threadsid]['items'] = [$arr['output']]; diff --git a/include/enotify.php b/include/enotify.php index f33b16f50..a19693816 100644 --- a/include/enotify.php +++ b/include/enotify.php @@ -34,7 +34,7 @@ function notification($params) $siteurl = System::baseUrl(true); $thanks = L10n::t('Thank You,'); $sitename = $a->config['sitename']; - if (!x($a->config['admin_name'])) { + if (empty($a->config['admin_name'])) { $site_admin = L10n::t('%s Administrator', $sitename); } else { $site_admin = L10n::t('%1$s, %2$s Administrator', $a->config['admin_name'], $sitename); @@ -93,6 +93,8 @@ function notification($params) } if ($params['type'] == NOTIFY_MAIL) { + $itemlink = $siteurl.'/message/'.$params['item']['id']; + $subject = L10n::t('[Friendica:Notify] New mail received at %s', $sitename); $preamble = L10n::t('%1$s sent you a new private message at %2$s.', $params['source_name'], $sitename); @@ -101,7 +103,6 @@ function notification($params) $sitelink = L10n::t('Please visit %s to view and/or reply to your private messages.'); $tsitelink = sprintf($sitelink, $siteurl.'/message/'.$params['item']['id']); $hsitelink = sprintf($sitelink, ''.$sitename.''); - $itemlink = $siteurl.'/message/'.$params['item']['id']; } if ($params['type'] == NOTIFY_COMMENT) { @@ -130,10 +131,11 @@ function notification($params) $item = null; if ($params['otype'] === 'item' && $parent_id) { - $item = Item::selectFirstForUser($params['uid'], [], ['id' => $parent_id]); + $item = Item::selectFirstForUser($params['uid'], Item::ITEM_FIELDLIST, ['id' => $parent_id]); } $item_post_type = item_post_type($item); + $itemlink = $item['plink']; // "a post" $dest_str = L10n::t('%1$s commented on [url=%2$s]a %3$s[/url]', @@ -242,6 +244,7 @@ function notification($params) } if ($params['type'] == NOTIFY_TAGSHARE) { + $itemlink = $params['link']; $subject = L10n::t('[Friendica:Notify] %s tagged your post', $params['source_name']); $preamble = L10n::t('%1$s tagged your post at %2$s', $params['source_name'], $sitename); @@ -253,10 +256,10 @@ function notification($params) $sitelink = L10n::t('Please visit %s to view and/or reply to the conversation.'); $tsitelink = sprintf($sitelink, $siteurl); $hsitelink = sprintf($sitelink, ''.$sitename.''); - $itemlink = $params['link']; } if ($params['type'] == NOTIFY_INTRO) { + $itemlink = $params['link']; $subject = L10n::t('[Friendica:Notify] Introduction received'); $preamble = L10n::t('You\'ve received an introduction from \'%1$s\' at %2$s', $params['source_name'], $sitename); @@ -270,7 +273,6 @@ function notification($params) $sitelink = L10n::t('Please visit %s to approve or reject the introduction.'); $tsitelink = sprintf($sitelink, $siteurl); $hsitelink = sprintf($sitelink, ''.$sitename.''); - $itemlink = $params['link']; switch ($params['verb']) { case ACTIVITY_FRIEND: @@ -300,6 +302,7 @@ function notification($params) } if ($params['type'] == NOTIFY_SUGGEST) { + $itemlink = $params['link']; $subject = L10n::t('[Friendica:Notify] Friend suggestion received'); $preamble = L10n::t('You\'ve received a friend suggestion from \'%1$s\' at %2$s', $params['source_name'], $sitename); @@ -316,11 +319,11 @@ function notification($params) $sitelink = L10n::t('Please visit %s to approve or reject the suggestion.'); $tsitelink = sprintf($sitelink, $siteurl); $hsitelink = sprintf($sitelink, ''.$sitename.''); - $itemlink = $params['link']; } if ($params['type'] == NOTIFY_CONFIRM) { if ($params['verb'] == ACTIVITY_FRIEND) { // mutual connection + $itemlink = $params['link']; $subject = L10n::t('[Friendica:Notify] Connection accepted'); $preamble = L10n::t('\'%1$s\' has accepted your connection request at %2$s', $params['source_name'], $sitename); @@ -334,8 +337,8 @@ function notification($params) $sitelink = L10n::t('Please visit %s if you wish to make any changes to this relationship.'); $tsitelink = sprintf($sitelink, $siteurl); $hsitelink = sprintf($sitelink, ''.$sitename.''); - $itemlink = $params['link']; } else { // ACTIVITY_FOLLOW + $itemlink = $params['link']; $subject = L10n::t('[Friendica:Notify] Connection accepted'); $preamble = L10n::t('\'%1$s\' has accepted your connection request at %2$s', $params['source_name'], $sitename); @@ -351,13 +354,13 @@ function notification($params) $sitelink = L10n::t('Please visit %s if you wish to make any changes to this relationship.'); $tsitelink = sprintf($sitelink, $siteurl); $hsitelink = sprintf($sitelink, ''.$sitename.''); - $itemlink = $params['link']; } } if ($params['type'] == NOTIFY_SYSTEM) { switch($params['event']) { case "SYSTEM_REGISTER_REQUEST": + $itemlink = $params['link']; $subject = L10n::t('[Friendica System Notify]') . ' ' . L10n::t('registration request'); $preamble = L10n::t('You\'ve received a registration request from \'%1$s\' at %2$s', $params['source_name'], $sitename); @@ -375,7 +378,6 @@ function notification($params) $sitelink = L10n::t('Please visit %s to approve or reject the request.'); $tsitelink = sprintf($sitelink, $params['link']); $hsitelink = sprintf($sitelink, ''.$sitename.'