From d85815b3be7ed0c2b573c4ab686d6b4874b6eebf Mon Sep 17 00:00:00 2001 From: Frode Petterson Date: Fri, 22 May 2015 15:31:28 +0200 Subject: [PATCH] Keep the content's disable settings when re-saving after global options have changed. (More consistent and reliable) --- h5p.classes.php | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/h5p.classes.php b/h5p.classes.php index 34f637e..4c34549 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -2351,23 +2351,24 @@ class H5PCore { * Determine disable state from sources. * * @param array $sources + * @param int $current * @return int */ - public static function getDisable(&$sources) { - $disable = H5PCore::DISABLE_NONE; - if (!isset($sources['frame']) || !$sources['frame']) { - $disable |= H5PCore::DISABLE_FRAME; + public function getDisable(&$sources, $current) { + foreach (H5PCore::$disable as $bit => $option) { + if ($option === 'download') { + $option = 'export'; + } + if ($this->h5pF->getOption($option, TRUE) ) { + if (!isset($sources[$option]) || !$sources[$option]) { + $current |= $bit; // Disable + } + else { + $current &= ~$bit; // Enable + } + } } - if (!isset($sources['download']) || !$sources['download']) { - $disable |= H5PCore::DISABLE_DOWNLOAD; - } - if (!isset($sources['copyright']) || !$sources['copyright']) { - $disable |= H5PCore::DISABLE_COPYRIGHT; - } - if (!isset($sources['embed']) || !$sources['embed']) { - $disable |= H5PCore::DISABLE_EMBED; - } - return $disable; + return $current; } // Cache for getting library ids