Merge pull request #9331 from annando/stay-local
authorTobias Diekershoff <tobias.diekershoff@gmx.net>
Thu, 1 Oct 2020 15:04:11 +0000 (17:04 +0200)
committerGitHub <noreply@github.com>
Thu, 1 Oct 2020 15:04:11 +0000 (17:04 +0200)
Added option to stay on the local machine when clicking on a contact link

include/conversation.php
src/Model/Contact.php
src/Model/Item.php
src/Module/Contact/Hovercard.php
src/Module/Settings/Display.php
view/templates/settings/display.tpl
view/theme/frio/templates/settings/display.tpl

index b984c3d..996d02d 100644 (file)
@@ -734,7 +734,7 @@ function conversation_fetch_comments($thread_items, $pinned) {
                                $row['direction'] = ['direction' => 4, 'title' => DI::l10n()->t('Tagged')];
                                break;
                        case Item::PT_ANNOUNCEMENT:
-                               if (!empty($row['causer-id']) && DI::pConfig()->get(local_user(), 'system', 'display_resharer')  ) {
+                               if (!empty($row['causer-id']) && DI::pConfig()->get(local_user(), 'system', 'display_resharer')) {
                                        $row['owner-link'] = $row['causer-link'];
                                        $row['owner-avatar'] = $row['causer-avatar'];
                                        $row['owner-name'] = $row['causer-name'];
index 1ec1424..f89945a 100644 (file)
@@ -2578,7 +2578,7 @@ class Contact
        {
                $destination = $url ?: $contact['url']; // Equivalent to ($url != '') ? $url : $contact['url'];
 
-               if (!Session::isAuthenticated() || ($contact['network'] != Protocol::DFRN)) {
+               if (!Session::isAuthenticated()) {
                        return $destination;
                }
 
@@ -2587,6 +2587,14 @@ class Contact
                        return $url;
                }
 
+               if (DI::pConfig()->get(local_user(), 'system', 'stay_local') && ($url == '')) {
+                       return 'contact/' . $contact['id'] . '/conversations';
+               }
+
+               if ($contact['network'] != Protocol::DFRN) {
+                       return $destination;
+               }
+
                if (!empty($contact['uid'])) {
                        return self::magicLink($contact['url'], $url);
                }
index 1c307c6..c384eb4 100644 (file)
@@ -3595,11 +3595,9 @@ class Item
                                        DI::page()['htmlhead'] .= Renderer::replaceMacros(Renderer::getMarkupTemplate('videos_head.tpl'));
                                }
 
-                               $url_parts = explode('/', $the_url);
-                               $id = end($url_parts);
                                $as .= Renderer::replaceMacros(Renderer::getMarkupTemplate('video_top.tpl'), [
                                        '$video' => [
-                                               'id'     => $id,
+                                               'id'     => $item['author-id'],
                                                'title'  => DI::l10n()->t('View Video'),
                                                'src'    => $the_url,
                                                'mime'   => $mime,
index 1d2fe85..c67d6d2 100644 (file)
@@ -49,6 +49,13 @@ class Hovercard extends BaseModule
                // the real url (nurl)
                if (strpos($contact_url, 'redir/') === 0) {
                        $cid = intval(substr($contact_url, 6));
+               }
+
+               if (strpos($contact_url, 'contact/') === 0) {
+                       $cid = intval(substr($contact_url, 8));
+               }
+
+               if (!empty($cid)) {                     
                        $remote_contact = Contact::selectFirst(['nurl'], ['id' => $cid]);
                        $contact_url = $remote_contact['nurl'] ?? '';
                }
index 4433853..cdafbb1 100644 (file)
@@ -53,6 +53,7 @@ class Display extends BaseSettings
                $no_smart_threading = !empty($_POST['no_smart_threading']) ? intval($_POST['no_smart_threading']) : 0;
                $hide_dislike       = !empty($_POST['hide_dislike'])       ? intval($_POST['hide_dislike'])       : 0;
                $display_resharer   = !empty($_POST['display_resharer'])   ? intval($_POST['display_resharer'])   : 0;
+               $stay_local         = !empty($_POST['stay_local'])         ? intval($_POST['stay_local'])         : 0;
                $browser_update     = !empty($_POST['browser_update'])     ? intval($_POST['browser_update'])     : 0;
                if ($browser_update != -1) {
                        $browser_update = $browser_update * 1000;
@@ -87,6 +88,7 @@ class Display extends BaseSettings
                DI::pConfig()->set(local_user(), 'system', 'no_smart_threading'      , $no_smart_threading);
                DI::pConfig()->set(local_user(), 'system', 'hide_dislike'            , $hide_dislike);
                DI::pConfig()->set(local_user(), 'system', 'display_resharer'        , $display_resharer);
+               DI::pConfig()->set(local_user(), 'system', 'stay_local'              , $stay_local);
                DI::pConfig()->set(local_user(), 'system', 'first_day_of_week'       , $first_day_of_week);
 
                if (in_array($theme, Theme::getAllowedList())) {
@@ -169,6 +171,8 @@ class Display extends BaseSettings
                $no_smart_threading = DI::pConfig()->get(local_user(), 'system', 'no_smart_threading', 0);
                $hide_dislike       = DI::pConfig()->get(local_user(), 'system', 'hide_dislike', 0);
                $display_resharer   = DI::pConfig()->get(local_user(), 'system', 'display_resharer', 0);
+               $stay_local         = DI::pConfig()->get(local_user(), 'system', 'stay_local', 0);
+
 
                $first_day_of_week = DI::pConfig()->get(local_user(), 'system', 'first_day_of_week', 0);
                $weekdays = [0 => DI::l10n()->t("Sunday"), 1 => DI::l10n()->t("Monday")];
@@ -206,6 +210,7 @@ class Display extends BaseSettings
                        '$no_smart_threading'       => ['no_smart_threading'      , DI::l10n()->t('Disable Smart Threading'), $no_smart_threading, DI::l10n()->t('Disable the automatic suppression of extraneous thread indentation.')],
                        '$hide_dislike'             => ['hide_dislike'            , DI::l10n()->t('Hide the Dislike feature'), $hide_dislike, DI::l10n()->t('Hides the Dislike button and dislike reactions on posts and comments.')],
                        '$display_resharer'         => ['display_resharer'        , DI::l10n()->t('Display the resharer'), $display_resharer, DI::l10n()->t('Display the first resharer as icon and text on a reshared item.')],
+                       '$stay_local'               => ['stay_local'              , DI::l10n()->t('Stay local'), $stay_local, DI::l10n()->t("Don't go to a remote system when following a contact link.")],
 
                        '$first_day_of_week' => ['first_day_of_week', DI::l10n()->t('Beginning of week:'), $first_day_of_week, '', $weekdays, false],
                ]);
index 3700c4f..3d76908 100644 (file)
@@ -19,6 +19,7 @@
        {{include file="field_checkbox.tpl" field=$no_smart_threading}}
        {{include file="field_checkbox.tpl" field=$hide_dislike}}
        {{include file="field_checkbox.tpl" field=$display_resharer}}
+       {{include file="field_checkbox.tpl" field=$stay_local}}
 
        <h2>{{$calendar_title}}</h2>
        {{include file="field_select.tpl" field=$first_day_of_week}}
index 4ba7518..6e018df 100644 (file)
@@ -66,6 +66,7 @@
                                                {{include file="field_checkbox.tpl" field=$no_smart_threading}}
                                                {{include file="field_checkbox.tpl" field=$hide_dislike}}
                                                {{include file="field_checkbox.tpl" field=$display_resharer}}
+                                               {{include file="field_checkbox.tpl" field=$stay_local}}
                                        </div>
                                        <div class="panel-footer">
                                                <button type="submit" name="submit" class="btn btn-primary" value="{{$submit}}">{{$submit}}</button>