Inheriting global disable setting for export & embed when saving [HFP-277]
parent
ea0362c3da
commit
7b39a6900c
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue