]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Profile.php
Merge pull request #5193 from annando/dbstructure
[friendica.git] / src / Model / Profile.php
index 1088ea600ed0042ee59c375e8904e5e43c64ce6f..39a89694a891c911a9a6c433bc12a224d7fe2d39 100644 (file)
@@ -90,16 +90,16 @@ class Profile
         */
        public static function load(App $a, $nickname, $profile = 0, $profiledata = [], $show_connect = true)
        {
-               $user = dba::selectFirst('user', ['uid'], ['nickname' => $nickname]);
+               $user = dba::selectFirst('user', ['uid'], ['nickname' => $nickname, 'account_removed' => false]);
 
-               if (!$user && !count($user) && !count($profiledata)) {
+               if (!DBM::is_result($user) && empty($profiledata)) {
                        logger('profile error: ' . $a->query_string, LOGGER_DEBUG);
                        notice(L10n::t('Requested account is not available.') . EOL);
                        $a->error = 404;
                        return;
                }
 
-               if (!x($a->page, 'aside')) {
+               if (empty($a->page['aside'])) {
                        $a->page['aside'] = '';
                }
 
@@ -152,15 +152,11 @@ class Profile
 
                $a->set_template_engine(); // reset the template engine to the default in case the user's theme doesn't specify one
 
-               $theme_info_file = 'view/theme/' . current_theme() . '/theme.php';
+               $theme_info_file = 'view/theme/' . $a->getCurrentTheme() . '/theme.php';
                if (file_exists($theme_info_file)) {
                        require_once $theme_info_file;
                }
 
-               if (!x($a->page, 'aside')) {
-                       $a->page['aside'] = '';
-               }
-
                if (local_user() && local_user() == $a->profile['uid'] && $profiledata) {
                        $a->page['aside'] .= replace_macros(
                                get_markup_template('profile_edlink.tpl'),
@@ -500,7 +496,7 @@ class Profile
                        $p['photo'] = proxy_url($p['photo'], false, PROXY_SIZE_SMALL);
                }
 
-               $p['url'] = self::magicLink($p['url']);
+               $p['url'] = Contact::magicLink($p['url']);
 
                $tpl = get_markup_template('profile_vcard.tpl');
                $o .= replace_macros($tpl, [
@@ -598,12 +594,8 @@ class Profile
                                        $cids[] = $rr['cid'];
 
                                        $today = (((strtotime($rr['start'] . ' +00:00') < $now) && (strtotime($rr['finish'] . ' +00:00') > $now)) ? true : false);
-                                       $url = $rr['url'];
-                                       if ($rr['network'] === NETWORK_DFRN) {
-                                               $url = System::baseUrl() . '/redir/' . $rr['cid'];
-                                       }
 
-                                       $rr['link'] = $url;
+                                       $rr['link'] = Contact::magicLink($rr['url']);
                                        $rr['title'] = $rr['name'];
                                        $rr['date'] = day_translate(DateTimeFormat::convert($rr['start'], $a->timezone, 'UTC', $rr['adjust'] ? $bd_format : $bd_short)) . (($today) ? ' ' . L10n::t('[today]') : '');
                                        $rr['startime'] = null;
@@ -643,8 +635,6 @@ class Profile
                $bd_format = L10n::t('g A l F d'); // 8 AM Friday January 18
                $classtoday = '';
 
-               $self = dba::selectFirst('contact', ['id'], ['uid' => local_user(), 'self' => true]);
-
                $s = dba::p(
                        "SELECT `event`.*
                        FROM `event`
@@ -663,7 +653,7 @@ class Profile
                        local_user(),
                        DateTimeFormat::utc('now + 7 days'),
                        DateTimeFormat::utc('now - 1 days'),
-                       $self['id'],
+                       public_contact(),
                        ACTIVITY_ATTEND,
                        ACTIVITY_ATTENDMAYBE
                );
@@ -956,7 +946,7 @@ class Profile
                        ];
                }
 
-               if ((!$is_owner) && ((count($a->profile)) || (!$a->profile['hide-friends']))) {
+               if (!$is_owner && empty($a->profile['hide-friends'])) {
                        $tabs[] = [
                                'label' => L10n::t('Contacts'),
                                'url'   => System::baseUrl() . '/viewcontacts/' . $nickname,
@@ -1009,29 +999,6 @@ class Profile
                }
        }
 
-       /**
-        * @brief Returns a magic link to authenticate remote visitors
-        *
-        * @param string $contact_url The address of the contact profile
-        * @param integer $uid The user id, "local_user" is the default
-        *
-        * @return string with "redir" link
-        */
-       public static function magicLink($contact_url, $uid = -1)
-       {
-               if ($uid == -1) {
-                       $uid = local_user();
-               }
-               $condition = ['pending' => false, 'uid' => $uid,
-                               'nurl' => normalise_link($contact_url),
-                               'network' => NETWORK_DFRN, 'self' => false];
-               $contact = dba::selectFirst('contact', ['id'], $condition);
-               if (DBM::is_result($contact)) {
-                       return System::baseUrl() . '/redir/' . $contact['id'];
-               }
-               return self::zrl($contact_url);
-       }
-
        public static function zrl($s, $force = false)
        {
                if (!strlen($s)) {