]> git.mxchange.org Git - friendica.git/blobdiff - mod/contacts.php
Merge pull request #5267 from miqrogroove/patch-2
[friendica.git] / mod / contacts.php
index 43e6ae826d2d50a52d93729fde6bc1c58b40db66..59b96d87a98c82ffbf311cc6df53661ff91ae98c 100644 (file)
@@ -6,6 +6,7 @@
 use Friendica\App;
 use Friendica\Content\ContactSelector;
 use Friendica\Content\Nav;
+use Friendica\Content\Text\BBCode;
 use Friendica\Content\Widget;
 use Friendica\Core\Addon;
 use Friendica\Core\L10n;
@@ -17,7 +18,7 @@ use Friendica\Model\GContact;
 use Friendica\Model\Group;
 use Friendica\Model\Profile;
 use Friendica\Network\Probe;
-use Friendica\Util\Temporal;
+use Friendica\Util\DateTimeFormat;
 
 require_once 'mod/proxy.php';
 
@@ -44,6 +45,14 @@ function contacts_init(App $a)
        }
 
        if (DBM::is_result($contact)) {
+               if ($contact['self']) {
+                       if (($a->argc == 3) && intval($a->argv[1]) && ($a->argv[2] == "posts")) {
+                               goaway('profile/' . $contact['nick']);
+                       } else {
+                               goaway('profile/' . $contact['nick'] . '?tab=profile');
+                       }
+               }
+
                $a->data['contact'] = $contact;
 
                if (($a->data['contact']['network'] != "") && ($a->data['contact']['network'] != NETWORK_DFRN)) {
@@ -56,7 +65,7 @@ function contacts_init(App $a)
                $vcard_widget = replace_macros(get_markup_template("vcard-widget.tpl"), [
                        '$name' => htmlentities($a->data['contact']['name']),
                        '$photo' => $a->data['contact']['photo'],
-                       '$url' => ($a->data['contact']['network'] == NETWORK_DFRN) ? "redir/" . $a->data['contact']['id'] : $a->data['contact']['url'],
+                       '$url' => Contact::MagicLink($a->data['contact']['url']),
                        '$addr' => (($a->data['contact']['addr'] != "") ? ($a->data['contact']['addr']) : ""),
                        '$network_name' => $networkname,
                        '$network' => L10n::t('Network:'),
@@ -348,9 +357,6 @@ function _contact_archive($contact_id, $orig_record)
                intval($contact_id),
                intval(local_user())
        );
-       if ($archived) {
-               q("UPDATE `item` SET `private` = 2 WHERE `contact-id` = %d AND `uid` = %d", intval($contact_id), intval(local_user()));
-       }
        return DBM::is_result($r);
 }
 
@@ -530,17 +536,16 @@ function contacts_content(App $a)
 
                $relation_text = sprintf($relation_text, htmlentities($contact['name']));
 
-               if (($contact['network'] === NETWORK_DFRN) && ($contact['rel'])) {
-                       $url = "redir/{$contact['id']}";
+               $url = Contact::magicLink($contact['url']);
+               if (strpos($url, 'redir/') === 0) {
                        $sparkle = ' class="sparkle" ';
                } else {
-                       $url = $contact['url'];
                        $sparkle = '';
                }
 
                $insecure = L10n::t('Private communications are not available for this contact.');
 
-               $last_update = (($contact['last-update'] <= NULL_DATE) ? L10n::t('Never') : Temporal::convert($contact['last-update'], date_default_timezone_get(), 'UTC', 'D, j M Y, g:i A'));
+               $last_update = (($contact['last-update'] <= NULL_DATE) ? L10n::t('Never') : DateTimeFormat::local($contact['last-update'], 'D, j M Y, g:i A'));
 
                if ($contact['last-update'] > NULL_DATE) {
                        $last_update .= ' ' . (($contact['last-update'] <= $contact['success_update']) ? L10n::t("\x28Update was successful\x29") : L10n::t("\x28Update was not successful\x29"));
@@ -554,7 +559,7 @@ function contacts_content(App $a)
                // tabs
                $tab_str = contacts_tab($a, $contact_id, 2);
 
-               $lost_contact = (($contact['archive'] && $contact['term-date'] > NULL_DATE && $contact['term-date'] < datetime_convert('', '', 'now')) ? L10n::t('Communications lost with this contact!') : '');
+               $lost_contact = (($contact['archive'] && $contact['term-date'] > NULL_DATE && $contact['term-date'] < DateTimeFormat::utcNow()) ? L10n::t('Communications lost with this contact!') : '');
 
                $fetch_further_information = null;
                if ($contact['network'] == NETWORK_FEED) {
@@ -581,9 +586,10 @@ function contacts_content(App $a)
                        $profile_select = ContactSelector::profileAssign($contact['profile-id'], (($contact['network'] !== NETWORK_DFRN) ? true : false));
                }
 
+               /// @todo Only show the following link with DFRN when the remote version supports it
                $follow = '';
                $follow_text = '';
-               if (in_array($contact['network'], [NETWORK_DIASPORA, NETWORK_OSTATUS])) {
+               if (in_array($contact['network'], [NETWORK_DIASPORA, NETWORK_OSTATUS, NETWORK_DFRN])) {
                        if ($contact['rel'] == CONTACT_IS_FOLLOWER) {
                                $follow = System::baseUrl(true) . "/follow?url=" . urlencode($contact["url"]);
                                $follow_text = L10n::t("Connect/Follow");
@@ -649,11 +655,11 @@ function contacts_content(App $a)
                        '$profileurllabel' => L10n::t('Profile URL'),
                        '$profileurl' => $contact['url'],
                        '$account_type' => Contact::getAccountType($contact),
-                       '$location' => bbcode($contact["location"]),
+                       '$location' => BBCode::convert($contact["location"]),
                        '$location_label' => L10n::t("Location:"),
-                       '$xmpp' => bbcode($contact["xmpp"]),
+                       '$xmpp' => BBCode::convert($contact["xmpp"]),
                        '$xmpp_label' => L10n::t("XMPP:"),
-                       '$about' => bbcode($contact["about"], false, false),
+                       '$about' => BBCode::convert($contact["about"], false),
                        '$about_label' => L10n::t("About:"),
                        '$keywords' => $contact["keywords"],
                        '$keywords_label' => L10n::t("Tags:"),
@@ -933,10 +939,17 @@ function _contact_detail_for_template($rr)
                default:
                        break;
        }
-       if (($rr['network'] === NETWORK_DFRN) && ($rr['rel'])) {
-               $url = "redir/{$rr['id']}";
+
+       $url = Contact::magicLink($rr['url']);
+       if (strpos($url, 'redir/') === 0) {
                $sparkle = ' class="sparkle" ';
        } else {
+               $sparkle = '';
+       }
+
+       if ($rr['self']) {
+               $dir_icon = 'images/larrow.gif';
+               $alt_text = L10n::t('This is you');
                $url = $rr['url'];
                $sparkle = '';
        }
@@ -956,6 +969,7 @@ function _contact_detail_for_template($rr)
                'itemurl' => (($rr['addr'] != "") ? $rr['addr'] : $rr['url']),
                'url' => $url,
                'network' => ContactSelector::networkToName($rr['network'], $rr['url']),
+               'nick' => htmlentities($rr['nick']),
        ];
 }