Skip to content
Snippets Groups Projects
Commit f7026ec1 authored by Thomas Marstrander's avatar Thomas Marstrander
Browse files

JI-1010 Add help message if iframe embedding is disabled on site

Disable download button for mobile view, since it does not work
Add white background when viewing the H5P, makes resizing look better
parent ee672807
No related branches found
No related tags found
No related merge requests found
...@@ -27,6 +27,23 @@ class mobile { ...@@ -27,6 +27,23 @@ class mobile {
global $DB, $CFG, $OUTPUT, $USER; global $DB, $CFG, $OUTPUT, $USER;
$cmid = $args['cmid']; $cmid = $args['cmid'];
if (!$CFG->allowframembedding) {
$context = \context_system::instance();
if (has_capability('moodle/site:config', $context)) {
$template = 'mod_hvp/iframe_embedding_disabled';
}
else {
$template = 'mod_hvp/contact_site_administrator';
}
return array(
'templates' => array(
array(
'id' => 'noiframeembedding',
'html' => $OUTPUT->render_from_template($template, [])
)
)
);
}
// Verify course context. // Verify course context.
$cm = get_coursemodule_from_id('hvp', $cmid); $cm = get_coursemodule_from_id('hvp', $cmid);
......
...@@ -45,7 +45,7 @@ class view_assets { ...@@ -45,7 +45,7 @@ class view_assets {
protected $embedtype; protected $embedtype;
protected $files; protected $files;
public function __construct($cm, $course, $forceembedtype = null) { public function __construct($cm, $course, $options = []) {
global $CFG; global $CFG;
$this->cm = $cm; $this->cm = $cm;
...@@ -58,6 +58,9 @@ class view_assets { ...@@ -58,6 +58,9 @@ class view_assets {
$context = \context_module::instance($this->cm->id); $context = \context_module::instance($this->cm->id);
$displayoptions = $this->core->getDisplayOptionsForView($this->content['disable'], $context->instanceid); $displayoptions = $this->core->getDisplayOptionsForView($this->content['disable'], $context->instanceid);
if (isset($options['disabledownload']) && $options['disabledownload']) {
$displayoptions[\H5PCore::DISPLAY_OPTION_DOWNLOAD] = false;
}
// Add JavaScript settings for this content. // Add JavaScript settings for this content.
$cid = 'cid-' . $this->content['id']; $cid = 'cid-' . $this->content['id'];
...@@ -78,7 +81,7 @@ class view_assets { ...@@ -78,7 +81,7 @@ class view_assets {
) )
); );
$this->embedtype = isset($forceembedtype) ? $forceembedtype : \H5PCore::determineEmbedType( $this->embedtype = isset($options->forceembedtype) ? $options->forceembedtype : \H5PCore::determineEmbedType(
$this->content['embedType'], $this->content['library']['embedTypes'] $this->content['embedType'], $this->content['library']['embedTypes']
); );
......
...@@ -30,9 +30,11 @@ $id = required_param('id', PARAM_INT); ...@@ -30,9 +30,11 @@ $id = required_param('id', PARAM_INT);
// Allow login through an authentication token. // Allow login through an authentication token.
$userid = optional_param('user_id', null, PARAM_ALPHANUMEXT); $userid = optional_param('user_id', null, PARAM_ALPHANUMEXT);
$secret = optional_param('secret', null, PARAM_RAW); $secret = optional_param('secret', null, PARAM_RAW);
$disabledownload = false;
if (\mod_hvp\mobile_auth::has_valid_token($userid, $secret)) { if (\mod_hvp\mobile_auth::has_valid_token($userid, $secret)) {
$user = get_complete_user_data('id', $userid); $user = get_complete_user_data('id', $userid);
complete_user_login($user); complete_user_login($user);
$disabledownload = true;
} }
// Verify course context. // Verify course context.
...@@ -67,7 +69,7 @@ $context = context_module::instance($cm->id); ...@@ -67,7 +69,7 @@ $context = context_module::instance($cm->id);
require_capability('mod/hvp:view', $context); require_capability('mod/hvp:view', $context);
// Set up view assets. // Set up view assets.
$view = new \mod_hvp\view_assets($cm, $course); $view = new \mod_hvp\view_assets($cm, $course, ['disabledownload' => $disabledownload]);
$content = $view->getcontent(); $content = $view->getcontent();
$view->validatecontent(); $view->validatecontent();
......
<div style="padding: 1em;">This site is not configured properly for displaying mobile H5P content. Please contact a site administrator.</div>
\ No newline at end of file
<div style="padding: 1em">
<div>Iframe embedding must be enabled in order to display H5P content in the mobile app.</div>
<div>You can enable it by checking "Allow frame embedding" in <a href="/admin/settings.php?section=httpsecurity" core-link>Site Administration / Security / Http Security</a></div>
</div>
\ No newline at end of file
{{=<% %>=}} {{=<% %>=}}
<div style="height: 100%; width: 100%; background: white;">
<iframe <iframe
src="<% wwwroot %>/mod/hvp/embed.php?id=<% cmid %>&user_id=<% user_id %>&secret=<% secret %>" src="<% wwwroot %>/mod/hvp/embed.php?id=<% cmid %>&user_id=<% user_id %>&secret=<% secret %>"
frameborder="0" frameborder="0"
allowfullscreen="allowfullscreen"> allowfullscreen="allowfullscreen">
</iframe> </iframe>
</div>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment