From 362464ad568dec0c266bcb5b76a83486646c9363 Mon Sep 17 00:00:00 2001 From: thomasmars Date: Mon, 27 Feb 2017 16:01:08 +0100 Subject: [PATCH 1/2] Updated endpoint JI-90 --- h5p.classes.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/h5p.classes.php b/h5p.classes.php index 93c9597..7d7327f 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -2765,7 +2765,7 @@ class H5PCore { * @return bool|object Returns endpoint data if found, otherwise FALSE */ public function updateContentTypeCache($postData = NULL) { - $endpoint = 'http://hubendpoints/contenttypes'; + $endpoint = 'http://api.h5p.org/v1/content-types'; $interface = $this->h5pF; @@ -2791,7 +2791,7 @@ class H5PCore { $json = json_decode($data); // No libraries received - if (!isset($json->libraries) || empty($json->libraries)) { + if (!isset($json->contentTypes) || empty($json->contentTypes)) { $interface->setErrorMessage( $interface->t('No libraries was received from the Content Type Hub. Please try again later.') ); From 0f08031abf2508159283afe95a3e63431d764b72 Mon Sep 17 00:00:00 2001 From: Frode Petterson Date: Tue, 28 Feb 2017 13:05:11 +0100 Subject: [PATCH 2/2] Allow Core to override permission check HFP-504 HFP-505 --- h5p.classes.php | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/h5p.classes.php b/h5p.classes.php index 93c9597..3f07493 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -783,7 +783,7 @@ class H5PValidator { } // The rest should be library folders - elseif ($this->h5pF->mayUpdateLibraries()) { + elseif ($this->h5pC->mayUpdateLibraries()) { if (!is_dir($filePath)) { // Ignore this. Probably a file that shouldn't have been included. continue; @@ -866,7 +866,7 @@ class H5PValidator { foreach ($missingLibraries as $libString => $library) { $this->h5pF->setErrorMessage($this->h5pF->t('Missing required library @library', array('@library' => $libString))); } - if (!$this->h5pF->mayUpdateLibraries()) { + if (!$this->h5pC->mayUpdateLibraries()) { $this->h5pF->setInfoMessage($this->h5pF->t("Note that the libraries may exist in the file you uploaded, but you're not allowed to upload new libraries. Contact the site administrator about this.")); } } @@ -1303,7 +1303,7 @@ class H5PStorage { * FALSE otherwise */ public function savePackage($content = NULL, $contentMainId = NULL, $skipContent = FALSE, $options = array()) { - if ($this->h5pF->mayUpdateLibraries()) { + if ($this->h5pC->mayUpdateLibraries()) { // Save the libraries we processed during validation $this->saveLibraries(); } @@ -2907,6 +2907,29 @@ class H5PCore { return $val; } + + /** + * Check if the current user has permission to update and install new + * libraries. + * + * @param bool [$set] Optional, sets the permission + * @return bool + */ + public function mayUpdateLibraries($set = null) { + static $can; + + if ($set !== null) { + // Use value set + $can = $set; + } + + if ($can === null) { + // Ask our framework + $can = $this->h5pF->mayUpdateLibraries(); + } + + return $can; + } } /**