]> git.mxchange.org Git - friendica.git/commitdiff
remote_user is replaced
authorMichael <heluecht@pirati.ca>
Sat, 28 Sep 2019 09:59:08 +0000 (09:59 +0000)
committerMichael <heluecht@pirati.ca>
Sat, 28 Sep 2019 09:59:08 +0000 (09:59 +0000)
boot.php
mod/cal.php
mod/display.php
mod/item.php
mod/photos.php
mod/redir.php
mod/videos.php
mod/wall_attach.php
mod/wall_upload.php
src/Model/Profile.php
src/Module/Profile.php

index 3aca931492d2ac6f373ae82e55117c4086491327..6aada42cbef6a9399f124ecf553091634eb4e17e 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -414,15 +414,13 @@ function public_contact()
  *
  * @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']);
        }
 
index 158856d21ee4e23b30ed84cfe2f22d7256f87741..70667707030b1bba589e389804c8ddf3864d7b25 100644 (file)
@@ -14,6 +14,7 @@ use Friendica\Core\Config;
 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;
@@ -109,8 +110,8 @@ function cal_content(App $a)
        $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) {
index 7f77be37efe8da71ff72f7f8684bc5b0abca51d5..874e2e8bf36dfb43bda90f1e6caa8906d79f5920 100644 (file)
@@ -14,6 +14,7 @@ use Friendica\Core\Logger;
 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;
@@ -53,7 +54,7 @@ function display_init(App $a)
                                $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'];
@@ -225,7 +226,7 @@ function display_content(App $a, $update = false, $update_uid = 0)
                                        $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"];
@@ -273,7 +274,7 @@ function display_content(App $a, $update = false, $update_uid = 0)
                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'];
                        }
index 5ffee86a06dbb18b6a517bdde44f4a12e0cf673e..b059f63d1fe20ba890cd1c7691ad7df065bbfb4f 100644 (file)
@@ -348,8 +348,8 @@ function item_post(App $a) {
        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)) {
index 3bf49f37be9141adc55ae2882fcbb19f93139344..1514458717b415b9ba410ff395cdce3f9204edde 100644 (file)
@@ -15,6 +15,7 @@ use Friendica\Core\L10n;
 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;
@@ -84,7 +85,7 @@ function photos_init(App $a) {
                        $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'],
@@ -150,8 +151,8 @@ function photos_post(App $a)
 
        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;
        }
@@ -874,8 +875,8 @@ function photos_content(App $a)
 
        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)) {
@@ -886,8 +887,8 @@ function photos_content(App $a)
        }
 
        // 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]);
 
@@ -1563,7 +1564,7 @@ function photos_content(App $a)
                $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;
                        }
 
index 6b492473a0dd24742e129e85e9dbc0dbed87d476..5345b1d81b364fdfbb99ab1e9d268047d745bf62 100644 (file)
@@ -66,7 +66,7 @@ function redir_init(App $a) {
                        // 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);
@@ -139,23 +139,6 @@ function redir_magic($a, $cid, $url)
                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]);
index 6ff4236a1bdca54aa959c5d77f5da0d8806450c6..fd40e79c90dcf6c390b18620315ff0d06c7dbe58 100644 (file)
@@ -10,6 +10,7 @@ use Friendica\Core\Config;
 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;
@@ -22,7 +23,7 @@ use Friendica\Util\Security;
 
 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;
        }
 
@@ -110,7 +111,7 @@ function videos_content(App $a)
        // 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;
        }
@@ -150,16 +151,16 @@ function videos_content(App $a)
 
        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;
        }
 
index 096439fa74ef335f199cfc5752f1bbce1906e8f9..0324a5581ca9a674d48ac08381edd6289e392964 100644 (file)
@@ -6,6 +6,7 @@
 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;
@@ -45,8 +46,8 @@ function wall_attach_post(App $a) {
 
        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)
index 0848c05906d888b863e9d6b21ecf88cf12bda4a4..1224b6dab0a6cb00fbaea2c0ceacf1c20fda365f 100644 (file)
@@ -12,6 +12,7 @@ use Friendica\App;
 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;
@@ -74,8 +75,8 @@ function wall_upload_post(App $a, $desktopmode = true)
 
        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
index 1aaa1907ced4c12f8bdf2ec1a4f9066c02f615f1..bdb69750dc9cdea5b7022f1dc83869a70d077449 100644 (file)
@@ -248,8 +248,8 @@ class Profile
         */
        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'];
                        }
index d1e76bf01ae31b6c078af727180b569e2f4393a4..cb710b10ba97bee752cc13cd3dcf7aab7156603c 100644 (file)
@@ -84,8 +84,8 @@ class Profile extends BaseModule
 
                        $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";
@@ -151,7 +151,7 @@ class Profile extends BaseModule
 
                $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();
                }
 
@@ -164,7 +164,7 @@ class Profile extends BaseModule
                        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;