*
* @return int|bool visitor_id or false
*/
-function remote_user($uid = null)
+function remote_user()
{
if (empty($_SESSION['authenticated'])) {
return false;
}
- if (!is_null($uid)) {
- return Session::getRemoteContactID($uid);
- } elseif (is_null($uid) && !empty($_SESSION['visitor_id'])) {
+ if (!empty($_SESSION['visitor_id'])) {
return intval($_SESSION['visitor_id']);
}
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
use Friendica\Core\System;
+use Friendica\Core\Session;
use Friendica\Database\DBA;
use Friendica\Model\Contact;
use Friendica\Model\Event;
$owner_uid = intval($a->data['user']['uid']);
$nick = $a->data['user']['nickname'];
- if (!empty(remote_user($a->profile['profile_uid']))) {
- $contact_id = remote_user($a->profile['profile_uid']);
+ if (!empty(Session::getRemoteContactID($a->profile['profile_uid']))) {
+ $contact_id = Session::getRemoteContactID($a->profile['profile_uid']);
}
if ($contact_id) {
use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
use Friendica\Core\System;
+use Friendica\Core\Session;
use Friendica\Database\DBA;
use Friendica\Model\Contact;
use Friendica\Model\Group;
$nick = $a->user["nickname"];
}
// Is this item private but could be visible to the remove visitor?
- } elseif (remote_user($item['uid'])) {
+ } elseif (Session::getRemoteContactID($item['uid'])) {
$item = Item::selectFirst($fields, ['guid' => $a->argv[1], 'private' => 1]);
if (DBA::isResult($item)) {
$item_user = $item['uid'];
$item_parent = $item["parent"];
$item_parent_uri = $item['parent-uri'];
}
- } elseif (remote_user($item['uid'])) {
+ } elseif (Session::getRemoteContactID($item['uid'])) {
$item = Item::selectFirst($fields, ['guid' => $a->argv[1], 'private' => 1]);
if (DBA::isResult($item)) {
$item_id = $item["id"];
if (DBA::isResult($parent)) {
$a->profile['uid'] = defaults($a->profile, 'uid', $parent['uid']);
$a->profile['profile_uid'] = defaults($a->profile, 'profile_uid', $parent['uid']);
- $is_remote_contact = remote_user($a->profile['profile_uid']);
+ $is_remote_contact = Session::getRemoteContactID($a->profile['profile_uid']);
if ($is_remote_contact) {
$item_uid = $parent['uid'];
}
if (local_user() && ((local_user() == $profile_uid) || $allow_comment)) {
$self = true;
$author = DBA::selectFirst('contact', [], ['uid' => local_user(), 'self' => true]);
- } elseif (!empty(remote_user($profile_uid))) {
- $author = DBA::selectFirst('contact', [], ['id' => remote_user($profile_uid)]);
+ } elseif (!empty(Session::getRemoteContactID($profile_uid))) {
+ $author = DBA::selectFirst('contact', [], ['id' => Session::getRemoteContactID($profile_uid)]);
}
if (DBA::isResult($author)) {
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
use Friendica\Core\System;
+use Friendica\Core\Session;
use Friendica\Database\DBA;
use Friendica\Model\Contact;
use Friendica\Model\Group;
$ret['albums'] = [];
foreach ($albums as $k => $album) {
//hide profile photos to others
- if (!$is_owner && !remote_user($a->profile_uid) && ($album['album'] == L10n::t('Profile Photos')))
+ if (!$is_owner && !Session::getRemoteContactID($a->profile_uid) && ($album['album'] == L10n::t('Profile Photos')))
continue;
$entry = [
'text' => $album['album'],
if (local_user() && (local_user() == $page_owner_uid)) {
$can_post = true;
- } elseif ($community_page && !empty(remote_user($page_owner_uid))) {
- $contact_id = remote_user($page_owner_uid);
+ } elseif ($community_page && !empty(Session::getRemoteContactID($page_owner_uid))) {
+ $contact_id = Session::getRemoteContactID($page_owner_uid);
$can_post = true;
$visitor = $contact_id;
}
if (local_user() && (local_user() == $owner_uid)) {
$can_post = true;
- } elseif ($community_page && !empty(remote_user($owner_uid))) {
- $contact_id = remote_user($owner_uid);
+ } elseif ($community_page && !empty(Session::getRemoteContactID($owner_uid))) {
+ $contact_id = Session::getRemoteContactID($owner_uid);
$contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => $owner_uid, 'blocked' => false, 'pending' => false]);
if (DBA::isResult($contact)) {
}
// perhaps they're visiting - but not a community page, so they wouldn't have write access
- if (!empty(remote_user($owner_uid)) && !$visitor) {
- $contact_id = remote_user($owner_uid);
+ if (!empty(Session::getRemoteContactID($owner_uid)) && !$visitor) {
+ $contact_id = Session::getRemoteContactID($owner_uid);
$contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => $owner_uid, 'blocked' => false, 'pending' => false]);
$twist = false;
foreach ($r as $rr) {
//hide profile photos to others
- if (!$is_owner && !remote_user($owner_uid) && ($rr['album'] == L10n::t('Profile Photos'))) {
+ if (!$is_owner && !Session::getRemoteContactID($owner_uid) && ($rr['album'] == L10n::t('Profile Photos'))) {
continue;
}
// with the local contact. Otherwise the local user would ask the local contact
// for authentification everytime he/she is visiting a profile page of the local
// contact.
- if (($host == $remotehost) && (remote_user(Session::get('visitor_visiting')) == Session::get('visitor_id'))) {
+ if (($host == $remotehost) && (Session::getRemoteContactID(Session::get('visitor_visiting')) == Session::get('visitor_id'))) {
// Remote user is already authenticated.
$target_url = defaults($url, $contact_url);
Logger::log($contact['name'] . " is already authenticated. Redirecting to " . $target_url, Logger::DEBUG);
Logger::info('Got my url', ['visitor' => $visitor]);
}
- /// @todo Most likely these lines are superfluous. We will remove them in the next version
- if (empty($visitor) && remote_user()) {
- $contact = DBA::selectFirst('contact', ['url'], ['id' => remote_user()]);
- if (!empty($contact['url'])) {
- $visitor = $contact['url'];
- Logger::info('Got remote user', ['visitor' => $visitor]);
- }
- }
-
- if (empty($visitor) && local_user()) {
- $contact = DBA::selectFirst('contact', ['url'], ['id' => local_user()]);
- if (!empty($contact['url'])) {
- $visitor = $contact['url'];
- Logger::info('Got local user', ['visitor' => $visitor]);
- }
- }
-
$contact = DBA::selectFirst('contact', ['url'], ['id' => $cid]);
if (!DBA::isResult($contact)) {
Logger::info('Contact not found', ['id' => $cid]);
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
use Friendica\Core\System;
+use Friendica\Core\Session;
use Friendica\Database\DBA;
use Friendica\Model\Attach;
use Friendica\Model\Contact;
function videos_init(App $a)
{
- if ((Config::get('system', 'block_public')) && (!local_user()) && (!remote_user())) {
+ if (Config::get('system', 'block_public') && !local_user() && !remote_user()) {
return;
}
// videos/name/video/xxxxx/edit
- if ((Config::get('system', 'block_public')) && (!local_user()) && (!remote_user())) {
+ if (Config::get('system', 'block_public') && !local_user() && !remote_user()) {
notice(L10n::t('Public access denied.') . EOL);
return;
}
if ((local_user()) && (local_user() == $owner_uid)) {
$can_post = true;
- } elseif ($community_page && !empty(remote_user($owner_uid))) {
- $contact_id = remote_user($owner_uid);
+ } elseif ($community_page && !empty(Session::getRemoteContactID($owner_uid))) {
+ $contact_id = Session::getRemoteContactID($owner_uid);
$can_post = true;
$remote_contact = true;
$visitor = $contact_id;
}
// perhaps they're visiting - but not a community page, so they wouldn't have write access
- if (!empty(remote_user($owner_uid)) && !$visitor) {
- $contact_id = remote_user($owner_uid);
+ if (!empty(Session::getRemoteContactID($owner_uid)) && !$visitor) {
+ $contact_id = Session::getRemoteContactID($owner_uid);
$remote_contact = true;
}
use Friendica\App;
use Friendica\Core\Config;
use Friendica\Core\L10n;
+use Friendica\Core\Session;
use Friendica\Database\DBA;
use Friendica\Model\Attach;
use Friendica\Model\User;
if (local_user() && (local_user() == $page_owner_uid)) {
$can_post = true;
- } elseif ($community_page && !empty(remote_user($page_owner_uid))) {
- $contact_id = remote_user($page_owner_uid);
+ } elseif ($community_page && !empty(Session::getRemoteContactID($page_owner_uid))) {
+ $contact_id = Session::getRemoteContactID($page_owner_uid);
$r = q("SELECT `uid` FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `id` = %d AND `uid` = %d LIMIT 1",
intval($contact_id),
intval($page_owner_uid)
use Friendica\Core\L10n;
use Friendica\Core\Logger;
use Friendica\Core\System;
+use Friendica\Core\Session;
use Friendica\Core\Config;
use Friendica\Database\DBA;
use Friendica\Model\Contact;
if ((local_user()) && (local_user() == $page_owner_uid)) {
$can_post = true;
- } elseif ($community_page && !empty(remote_user($page_owner_uid))) {
- $contact_id = remote_user($page_owner_uid);
+ } elseif ($community_page && !empty(Session::getRemoteContactID($page_owner_uid))) {
+ $contact_id = Session::getRemoteContactID($page_owner_uid);
$r = q("SELECT `uid` FROM `contact`
WHERE `blocked` = 0 AND `pending` = 0
*/
public static function getByNickname($nickname, $uid = 0, $profile_id = 0)
{
- if (!empty(remote_user($uid))) {
- $contact = DBA::selectFirst('contact', ['profile-id'], ['id' => remote_user($uid)]);
+ if (!empty(Session::getRemoteContactID($uid))) {
+ $contact = DBA::selectFirst('contact', ['profile-id'], ['id' => Session::getRemoteContactID($uid)]);
if (DBA::isResult($contact)) {
$profile_id = $contact['profile-id'];
}
$a->page['htmlhead'] .= "\n";
- $blocked = !local_user() && !remote_user($a->profile['profile_uid']) && Config::get('system', 'block_public');
- $userblock = !local_user() && !remote_user($a->profile['profile_uid']) && $a->profile['hidewall'];
+ $blocked = !local_user() && !Session::getRemoteContactID($a->profile['profile_uid']) && Config::get('system', 'block_public');
+ $userblock = !local_user() && !Session::getRemoteContactID($a->profile['profile_uid']) && $a->profile['hidewall'];
if (!empty($a->profile['page-flags']) && $a->profile['page-flags'] == User::PAGE_FLAGS_COMMUNITY) {
$a->page['htmlhead'] .= '<meta name="friendica.community" content="true" />' . "\n";
$hashtags = defaults($_GET, 'tag', '');
- if (Config::get('system', 'block_public') && !local_user() && !remote_user($a->profile['profile_uid'])) {
+ if (Config::get('system', 'block_public') && !local_user() && !Session::getRemoteContactID($a->profile['profile_uid'])) {
return Login::form();
}
Nav::setSelected('home');
}
- $remote_contact = remote_user($a->profile['profile_uid']);
+ $remote_contact = Session::getRemoteContactID($a->profile['profile_uid']);
$is_owner = local_user() == $a->profile['profile_uid'];
$last_updated_key = "profile:" . $a->profile['profile_uid'] . ":" . local_user() . ":" . $remote_contact;