diff --git a/h5p.classes.php b/h5p.classes.php index 302242e..08f2a8e 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -2465,21 +2465,33 @@ class H5PCore { } /** - * Determine disable state from sources. + * Create representation of display options as int * * @param array $sources * @param int $current * @return int */ - public function getDisplayOptionsAsByte(&$sources, $current) { + public function getStorableDisplayOptions(&$sources, $current) { + // Download - force setting it if always on or always off + $export = $this->h5pF->getOption('export', H5PDisplayOptionBehaviour::ALWAYS_SHOW); + if ($export == H5PDisplayOptionBehaviour::ALWAYS_SHOW || + $export == H5PDisplayOptionBehaviour::NEVER_SHOW) { + $sources['download'] = ($export == H5PDisplayOptionBehaviour::ALWAYS_SHOW); + } + + // Embed - force setting it if always on or always off + $embed = $this->h5pF->getOption('embed', H5PDisplayOptionBehaviour::ALWAYS_SHOW); + if ($embed == H5PDisplayOptionBehaviour::ALWAYS_SHOW || + $embed == H5PDisplayOptionBehaviour::NEVER_SHOW) { + $sources['embed'] = ($embed == H5PDisplayOptionBehaviour::ALWAYS_SHOW); + } + foreach (H5PCore::$disable as $bit => $option) { - if ($this->h5pF->getOption(($bit & H5PCore::DISABLE_DOWNLOAD ? 'export' : $option), TRUE)) { - if (!isset($sources[$option]) || !$sources[$option]) { - $current |= $bit; // Disable - } - else { - $current &= ~$bit; // Enable - } + if (!isset($sources[$option]) || !$sources[$option]) { + $current |= $bit; // Disable + } + else { + $current &= ~$bit; // Enable } } return $current;