Added option to stay on the local machine when clicking on a contact link

This commit is contained in:
Michael 2020-09-30 17:30:26 +00:00
parent 0b37f1d56c
commit 5dd426f526
7 changed files with 25 additions and 5 deletions

View file

@ -734,7 +734,7 @@ function conversation_fetch_comments($thread_items, $pinned) {
$row['direction'] = ['direction' => 4, 'title' => DI::l10n()->t('Tagged')]; $row['direction'] = ['direction' => 4, 'title' => DI::l10n()->t('Tagged')];
break; break;
case Item::PT_ANNOUNCEMENT: 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-link'] = $row['causer-link'];
$row['owner-avatar'] = $row['causer-avatar']; $row['owner-avatar'] = $row['causer-avatar'];
$row['owner-name'] = $row['causer-name']; $row['owner-name'] = $row['causer-name'];

View file

@ -2578,7 +2578,7 @@ class Contact
{ {
$destination = $url ?: $contact['url']; // Equivalent to ($url != '') ? $url : $contact['url']; $destination = $url ?: $contact['url']; // Equivalent to ($url != '') ? $url : $contact['url'];
if (!Session::isAuthenticated() || ($contact['network'] != Protocol::DFRN)) { if (!Session::isAuthenticated()) {
return $destination; return $destination;
} }
@ -2587,6 +2587,14 @@ class Contact
return $url; 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'])) { if (!empty($contact['uid'])) {
return self::magicLink($contact['url'], $url); return self::magicLink($contact['url'], $url);
} }

View file

@ -3595,11 +3595,9 @@ class Item
DI::page()['htmlhead'] .= Renderer::replaceMacros(Renderer::getMarkupTemplate('videos_head.tpl')); 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'), [ $as .= Renderer::replaceMacros(Renderer::getMarkupTemplate('video_top.tpl'), [
'$video' => [ '$video' => [
'id' => $id, 'id' => $item['author-id'],
'title' => DI::l10n()->t('View Video'), 'title' => DI::l10n()->t('View Video'),
'src' => $the_url, 'src' => $the_url,
'mime' => $mime, 'mime' => $mime,

View file

@ -49,6 +49,13 @@ class Hovercard extends BaseModule
// the real url (nurl) // the real url (nurl)
if (strpos($contact_url, 'redir/') === 0) { if (strpos($contact_url, 'redir/') === 0) {
$cid = intval(substr($contact_url, 6)); $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]); $remote_contact = Contact::selectFirst(['nurl'], ['id' => $cid]);
$contact_url = $remote_contact['nurl'] ?? ''; $contact_url = $remote_contact['nurl'] ?? '';
} }

View file

@ -53,6 +53,7 @@ class Display extends BaseSettings
$no_smart_threading = !empty($_POST['no_smart_threading']) ? intval($_POST['no_smart_threading']) : 0; $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; $hide_dislike = !empty($_POST['hide_dislike']) ? intval($_POST['hide_dislike']) : 0;
$display_resharer = !empty($_POST['display_resharer']) ? intval($_POST['display_resharer']) : 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; $browser_update = !empty($_POST['browser_update']) ? intval($_POST['browser_update']) : 0;
if ($browser_update != -1) { if ($browser_update != -1) {
$browser_update = $browser_update * 1000; $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', 'no_smart_threading' , $no_smart_threading);
DI::pConfig()->set(local_user(), 'system', 'hide_dislike' , $hide_dislike); 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', '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); DI::pConfig()->set(local_user(), 'system', 'first_day_of_week' , $first_day_of_week);
if (in_array($theme, Theme::getAllowedList())) { 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); $no_smart_threading = DI::pConfig()->get(local_user(), 'system', 'no_smart_threading', 0);
$hide_dislike = DI::pConfig()->get(local_user(), 'system', 'hide_dislike', 0); $hide_dislike = DI::pConfig()->get(local_user(), 'system', 'hide_dislike', 0);
$display_resharer = DI::pConfig()->get(local_user(), 'system', 'display_resharer', 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); $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")]; $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.')], '$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.')], '$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.')], '$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], '$first_day_of_week' => ['first_day_of_week', DI::l10n()->t('Beginning of week:'), $first_day_of_week, '', $weekdays, false],
]); ]);

View file

@ -19,6 +19,7 @@
{{include file="field_checkbox.tpl" field=$no_smart_threading}} {{include file="field_checkbox.tpl" field=$no_smart_threading}}
{{include file="field_checkbox.tpl" field=$hide_dislike}} {{include file="field_checkbox.tpl" field=$hide_dislike}}
{{include file="field_checkbox.tpl" field=$display_resharer}} {{include file="field_checkbox.tpl" field=$display_resharer}}
{{include file="field_checkbox.tpl" field=$stay_local}}
<h2>{{$calendar_title}}</h2> <h2>{{$calendar_title}}</h2>
{{include file="field_select.tpl" field=$first_day_of_week}} {{include file="field_select.tpl" field=$first_day_of_week}}

View file

@ -66,6 +66,7 @@
{{include file="field_checkbox.tpl" field=$no_smart_threading}} {{include file="field_checkbox.tpl" field=$no_smart_threading}}
{{include file="field_checkbox.tpl" field=$hide_dislike}} {{include file="field_checkbox.tpl" field=$hide_dislike}}
{{include file="field_checkbox.tpl" field=$display_resharer}} {{include file="field_checkbox.tpl" field=$display_resharer}}
{{include file="field_checkbox.tpl" field=$stay_local}}
</div> </div>
<div class="panel-footer"> <div class="panel-footer">
<button type="submit" name="submit" class="btn btn-primary" value="{{$submit}}">{{$submit}}</button> <button type="submit" name="submit" class="btn btn-primary" value="{{$submit}}">{{$submit}}</button>