]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Profile.php
Fix birthday display and setting
[friendica.git] / src / Model / Profile.php
index 341727ceef4f6c84427705f4bcf03faa8ab988da..b993562cecc76ab140266ae3e48458f49a114336 100644 (file)
@@ -126,13 +126,13 @@ class Profile
         *
         * @param App     $a
         * @param string  $nickname     string
-        * @param int     $profile      int
+        * @param int     $profile_id   int
         * @param array   $profiledata  array
         * @param boolean $show_connect Show connect link
         * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         * @throws \ImagickException
         */
-       public static function load(App $a, $nickname, $profile = 0, array $profiledata = [], $show_connect = true)
+       public static function load(App $a, $nickname, $profile_id = 0, array $profiledata = [], $show_connect = true)
        {
                $user = DBA::selectFirst('user', ['uid'], ['nickname' => $nickname, 'account_removed' => false]);
 
@@ -155,31 +155,31 @@ class Profile
                        }
                }
 
-               $pdata = self::getByNickname($nickname, $user['uid'], $profile);
+               $profile = self::getByNickname($nickname, $user['uid'], $profile_id);
 
-               if (empty($pdata) && empty($profiledata)) {
+               if (empty($profile) && empty($profiledata)) {
                        Logger::log('profile error: ' . DI::args()->getQueryString(), Logger::DEBUG);
                        return;
                }
 
-               if (empty($pdata)) {
-                       $pdata = ['uid' => 0, 'profile_uid' => 0, 'is-default' => false,'name' => $nickname];
+               if (empty($profile)) {
+                       $profile = ['uid' => 0, 'is-default' => false,'name' => $nickname];
                }
 
                // fetch user tags if this isn't the default profile
 
-               if (!$pdata['is-default']) {
-                       $condition = ['uid' => $pdata['profile_uid'], 'is-default' => true];
-                       $profile = DBA::selectFirst('profile', ['pub_keywords'], $condition);
-                       if (DBA::isResult($profile)) {
-                               $pdata['pub_keywords'] = $profile['pub_keywords'];
+               if (!$profile['is-default']) {
+                       $condition = ['uid' => $profile['uid'], 'is-default' => true];
+                       $profile_id = DBA::selectFirst('profile', ['pub_keywords'], $condition);
+                       if (DBA::isResult($profile_id)) {
+                               $profile['pub_keywords'] = $profile_id['pub_keywords'];
                        }
                }
 
-               $a->profile = $pdata;
-               $a->profile_uid = $pdata['profile_uid'];
+               $a->profile = $profile;
+               $a->profile_uid = $profile['uid'];
 
-               $a->profile['mobile-theme'] = DI::pConfig()->get($a->profile['profile_uid'], 'system', 'mobile_theme');
+               $a->profile['mobile-theme'] = DI::pConfig()->get($a->profile['uid'], 'system', 'mobile_theme');
                $a->profile['network'] = Protocol::DFRN;
 
                DI::page()['title'] = $a->profile['name'] . ' @ ' . DI::config()->get('config', 'sitename');
@@ -255,7 +255,7 @@ class Profile
                        $profile = DBA::fetchFirst(
                                "SELECT `contact`.`id` AS `contact_id`, `contact`.`photo` AS `contact_photo`,
                                        `contact`.`thumb` AS `contact_thumb`, `contact`.`micro` AS `contact_micro`,
-                                       `profile`.`uid` AS `profile_uid`, `profile`.*,
+                                       `profile`.*,
                                        `contact`.`avatar-date` AS picdate, `contact`.`addr`, `contact`.`url`, `user`.*
                                FROM `profile`
                                INNER JOIN `contact` on `contact`.`uid` = `profile`.`uid` AND `contact`.`self`
@@ -269,7 +269,7 @@ class Profile
                        $profile = DBA::fetchFirst(
                                "SELECT `contact`.`id` AS `contact_id`, `contact`.`photo` as `contact_photo`,
                                        `contact`.`thumb` AS `contact_thumb`, `contact`.`micro` AS `contact_micro`,
-                                       `profile`.`uid` AS `profile_uid`, `profile`.*,
+                                       `profile`.*,
                                        `contact`.`avatar-date` AS picdate, `contact`.`addr`, `contact`.`url`, `user`.*
                                FROM `profile`
                                INNER JOIN `contact` ON `contact`.`uid` = `profile`.`uid` AND `contact`.`self`
@@ -350,7 +350,7 @@ class Profile
 
                $profile_is_dfrn = $profile['network'] == Protocol::DFRN;
                $profile_is_native = in_array($profile['network'], Protocol::NATIVE_SUPPORT);
-               $local_user_is_self = local_user() && local_user() == ($profile['profile_uid'] ?? 0);
+               $local_user_is_self = local_user() && local_user() == ($profile['uid'] ?? 0);
                $visitor_is_authenticated = (bool)self::getMyURL();
                $visitor_is_following =
                        in_array($visitor_contact['rel'] ?? 0, [Contact::FOLLOWER, Contact::FRIEND])
@@ -527,7 +527,7 @@ class Profile
 
                $p['url'] = Contact::magicLink(($p['url'] ?? '') ?: $profile_url);
 
-               $tpl = Renderer::getMarkupTemplate('profile_vcard.tpl');
+               $tpl = Renderer::getMarkupTemplate('profile/vcard.tpl');
                $o .= Renderer::replaceMacros($tpl, [
                        '$profile' => $p,
                        '$xmpp' => $xmpp,
@@ -747,8 +747,6 @@ class Profile
                $uid = intval($a->profile['uid']);
 
                if ($a->profile['name']) {
-                       $tpl = Renderer::getMarkupTemplate('profile_advanced.tpl');
-
                        $profile = [];
 
                        $profile['fullname'] = [DI::l10n()->t('Full Name:'), $a->profile['name']];
@@ -776,9 +774,9 @@ class Profile
 
                        if (!empty($a->profile['dob'])
                                && $a->profile['dob'] > DBA::NULL_DATE
-                               && $age = Temporal::getAgeByTimezone($a->profile['dob'], $a->profile['timezone'], '')
+                               && $age = Temporal::getAgeByTimezone($a->profile['dob'], $a->profile['timezone'])
                        ) {
-                               $profile['age'] = [DI::l10n()->t('Age:'), $age];
+                               $profile['age'] = [DI::l10n()->t('Age: ') , DI::l10n()->tt('%d year old', '%d years old', $age)];
                        }
 
                        if ($a->profile['marital']) {
@@ -875,6 +873,7 @@ class Profile
                                $profile['edit'] = [DI::baseUrl() . '/profiles/' . $a->profile['id'], DI::l10n()->t('Edit profile'), '', DI::l10n()->t('Edit profile')];
                        }
 
+                       $tpl = Renderer::getMarkupTemplate('profile/advanced.tpl');
                        return Renderer::replaceMacros($tpl, [
                                '$title' => DI::l10n()->t('Profile'),
                                '$basic' => DI::l10n()->t('Basic'),