From eb6e4d30edf9a12206a2f23410768b81a46032ba Mon Sep 17 00:00:00 2001
From: juancp-contidosdixitais
<93096561+juancp-contidosdixitais@users.noreply.github.com>
Date: Fri, 3 Nov 2023 16:17:17 +0100
Subject: [PATCH] Admin: Learnpath: Add configuration setting
'lp_ios_hide_open_in_new_window_button' to remove button in lp on iOS - refs
#4954
Author: Juan Cortizas Ponte <124381395+juancpbinario@users.noreply.github.com>
---
main/install/configuration.dist.php | 3 ++
main/lp/lp_view.php | 7 +++++
main/template/default/learnpath/view.tpl | 38 +++++++++++++-----------
3 files changed, 31 insertions(+), 17 deletions(-)
diff --git a/main/install/configuration.dist.php b/main/install/configuration.dist.php
index 8a36d0945d..776c1ce0a1 100644
--- a/main/install/configuration.dist.php
+++ b/main/install/configuration.dist.php
@@ -1634,6 +1634,9 @@ requires extension "php-soap" sudo apt-get install php-soap
// LP view menu location. Options: "left" or "right"
// $_configuration['lp_menu_location'] = 'left';
+// Hide the "Open in new window" button in learning paths when viewing long content (using the button disconnects SCORM tracking - more details in #4954)
+//$_configuration['lp_ios_hide_open_in_new_window_button'] = false;
+
// Show notification events
/*CREATE TABLE IF NOT EXISTS notification_event (
id INT unsigned NOT NULL auto_increment PRIMARY KEY,
diff --git a/main/lp/lp_view.php b/main/lp/lp_view.php
index d06219b621..a1bd450b7e 100755
--- a/main/lp/lp_view.php
+++ b/main/lp/lp_view.php
@@ -656,6 +656,13 @@ $template->assign(
)
);
+// Check if the 'Open in new window' button for IOs hosts must be hidden
+$iosHideOpenInNewWindow = false;
+if (api_get_configuration_value('lp_ios_hide_open_in_new_window_button') === true) {
+ $iosHideOpenInNewWindow = api_get_configuration_value('lp_ios_hide_open_in_new_window_button');
+}
+$template->assign('ios_hide_open_in_new_window', $iosHideOpenInNewWindow);
+
$frameReady = Display::getFrameReadyBlock(
'#content_id, #content_id_blank',
$itemType,
diff --git a/main/template/default/learnpath/view.tpl b/main/template/default/learnpath/view.tpl
index 6aa173e7d8..1fc2e643ae 100644
--- a/main/template/default/learnpath/view.tpl
+++ b/main/template/default/learnpath/view.tpl
@@ -255,23 +255,27 @@
'style',
'width:100%; overflow:auto; position:auto; -webkit-overflow-scrolling:touch !important;'
);
- $('')
- .attr({
- 'id': 'btn-content-new-tab',
- 'target': '_blank',
- 'href': '{{ iframe_src }}'
- })
- .css({
- 'position': 'absolute',
- 'right': '5px',
- 'top': '5px',
- 'z-index': '9999',
- 'font-weight': 'bold'
- })
- .addClass('btn btn-default btn-sm')
- .text('{{ 'OpenContentInNewTab'|get_lang|escape('js') }}')
- .prependTo('#wrapper-iframe');
- $('#wrapper-iframe').css('position', 'relative');
+
+ {% if ios_hide_open_in_new_window == false %}
+ $('')
+ .attr({
+ 'id': 'btn-content-new-tab',
+ 'target': '_blank',
+ 'href': '{{ iframe_src }}'
+ })
+ .css({
+ 'position': 'absolute',
+ 'right': '5px',
+ 'top': '5px',
+ 'z-index': '9999',
+ 'font-weight': 'bold'
+ })
+ .addClass('btn btn-default btn-sm')
+ .text('{{ 'OpenContentInNewTab'|get_lang|escape('js') }}')
+ .prependTo('#wrapper-iframe');
+ $('#wrapper-iframe').css('position', 'relative');
+ {% endif %}
+
// Fix another issue whereby buttons do not react to click below
// second screen in learning paths on Apple devices
document.getElementById('content_id').setAttribute('style', 'overflow: auto;');