From b2093b096213e9bbeec92890871b3aec7d06a799 Mon Sep 17 00:00:00 2001 From: ferishili Date: Fri, 20 Sep 2024 11:16:49 +0200 Subject: [PATCH 1/6] upgrade oc-php-lib to 1.8.0 --- composer.json | 4 +- composer.lock | 22 +-- thirdpartylibs.xml | 2 +- vendor/autoload.php | 18 ++ vendor/composer/ClassLoader.php | 137 ++++++++------- vendor/composer/InstalledVersions.php | 33 ++-- vendor/composer/LICENSE | 2 + vendor/composer/autoload_classmap.php | 2 +- vendor/composer/autoload_files.php | 4 +- vendor/composer/autoload_namespaces.php | 2 +- vendor/composer/autoload_psr4.php | 2 +- vendor/composer/autoload_real.php | 56 ++---- vendor/composer/autoload_static.php | 2 +- vendor/composer/installed.json | 30 ++-- vendor/composer/installed.php | 54 +++--- vendor/composer/platform_check.php | 26 +++ vendor/elan-ev/opencast-api/CHANGELOG.md | 14 ++ vendor/elan-ev/opencast-api/README.md | 6 + vendor/elan-ev/opencast-api/composer.json | 2 +- .../src/OpencastApi/Mock/OcMockHanlder.php | 2 +- .../opencast-api/src/OpencastApi/Opencast.php | 50 +++--- .../src/OpencastApi/Rest/OcIngest.php | 76 +++++---- .../src/OpencastApi/Rest/OcPlaylistsApi.php | 161 ++++++++++++++++++ .../src/OpencastApi/Rest/OcRest.php | 1 + .../src/OpencastApi/Rest/OcRestClient.php | 31 +++- .../src/OpencastApi/Rest/OcSearch.php | 144 +++++++++++----- .../DataProvider/PlaylistsDataProvider.php | 26 +++ .../tests/DataProvider/SearchDataProvider.php | 12 +- .../tests/DataProvider/SetupDataProvider.php | 27 ++- .../mock_responses/api_playlists.json | 59 +++++++ .../opencast-api/tests/Unit/OcIngestTest.php | 6 +- .../tests/Unit/OcPlaylistsApiTest.php | 139 +++++++++++++++ .../opencast-api/tests/Unit/OcSearchTest.php | 16 +- .../tests/UnitMock/OcEventsApiTestMock.php | 2 +- .../tests/UnitMock/OcPlaylistsApiTestMock.php | 134 +++++++++++++++ .../tests/UnitMock/OcSearchTestMock.php | 4 +- 36 files changed, 995 insertions(+), 313 deletions(-) create mode 100644 vendor/composer/platform_check.php create mode 100644 vendor/elan-ev/opencast-api/src/OpencastApi/Rest/OcPlaylistsApi.php create mode 100644 vendor/elan-ev/opencast-api/tests/DataProvider/PlaylistsDataProvider.php create mode 100644 vendor/elan-ev/opencast-api/tests/DataProvider/mock_responses/api_playlists.json create mode 100644 vendor/elan-ev/opencast-api/tests/Unit/OcPlaylistsApiTest.php create mode 100644 vendor/elan-ev/opencast-api/tests/UnitMock/OcPlaylistsApiTestMock.php diff --git a/composer.json b/composer.json index ca310ce..c0c6ed2 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "moodle/tool_opencast", - "require-dev": { - "elan-ev/opencast-api": "^1.5" + "require": { + "elan-ev/opencast-api": "1.8" } } diff --git a/composer.lock b/composer.lock index c70aa6c..16d2119 100644 --- a/composer.lock +++ b/composer.lock @@ -4,25 +4,24 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "5ddd6a7859b062a8e533c6198a0b9d93", - "packages": [], - "packages-dev": [ + "content-hash": "302ddd15ba0b6044e1ca5c4057fad613", + "packages": [ { "name": "elan-ev/opencast-api", - "version": "1.5.0", + "version": "1.8.0", "source": { "type": "git", "url": "https://github.com/elan-ev/opencast-php-library.git", - "reference": "dfcfa0789c8a670623ed27434ced88f595941b73" + "reference": "183619e86e60f97e8ba2d5b482d29a825506258b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/elan-ev/opencast-php-library/zipball/dfcfa0789c8a670623ed27434ced88f595941b73", - "reference": "dfcfa0789c8a670623ed27434ced88f595941b73", + "url": "https://api.github.com/repos/elan-ev/opencast-php-library/zipball/183619e86e60f97e8ba2d5b482d29a825506258b", + "reference": "183619e86e60f97e8ba2d5b482d29a825506258b", "shasum": "" }, "require": { - "guzzlehttp/guzzle": "7.5.1", + "guzzlehttp/guzzle": ">=7.5.1", "php": ">=7.2.5" }, "require-dev": { @@ -62,9 +61,9 @@ ], "support": { "issues": "https://github.com/elan-ev/opencast-php-library/issues", - "source": "https://github.com/elan-ev/opencast-php-library/tree/1.5.0" + "source": "https://github.com/elan-ev/opencast-php-library/tree/1.8.0" }, - "time": "2023-11-13T16:47:55+00:00" + "time": "2024-09-20T09:03:48+00:00" }, { "name": "guzzlehttp/guzzle", @@ -661,6 +660,7 @@ "time": "2023-05-23T14:45:45+00:00" } ], + "packages-dev": [], "aliases": [], "minimum-stability": "stable", "stability-flags": [], @@ -668,5 +668,5 @@ "prefer-lowest": false, "platform": [], "platform-dev": [], - "plugin-api-version": "2.2.0" + "plugin-api-version": "2.6.0" } diff --git a/thirdpartylibs.xml b/thirdpartylibs.xml index 2d4c033..6d3cb86 100644 --- a/thirdpartylibs.xml +++ b/thirdpartylibs.xml @@ -10,7 +10,7 @@ vendor/elan-ev/opencast-api Opencast PHP Library - 1.3 + 1.8 GPL 3.0-or-later diff --git a/vendor/autoload.php b/vendor/autoload.php index 7ef4359..d9dcda3 100644 --- a/vendor/autoload.php +++ b/vendor/autoload.php @@ -2,6 +2,24 @@ // autoload.php @generated by Composer +if (PHP_VERSION_ID < 50600) { + if (!headers_sent()) { + header('HTTP/1.1 500 Internal Server Error'); + } + $err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL; + if (!ini_get('display_errors')) { + if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') { + fwrite(STDERR, $err); + } elseif (!headers_sent()) { + echo $err; + } + } + trigger_error( + $err, + E_USER_ERROR + ); +} + require_once __DIR__ . '/composer/autoload_real.php'; return ComposerAutoloaderInit8ba2ca4e105ea351f7cb241590a7de7e::getLoader(); diff --git a/vendor/composer/ClassLoader.php b/vendor/composer/ClassLoader.php index afef3fa..7824d8f 100644 --- a/vendor/composer/ClassLoader.php +++ b/vendor/composer/ClassLoader.php @@ -42,35 +42,37 @@ */ class ClassLoader { - /** @var ?string */ + /** @var \Closure(string):void */ + private static $includeFile; + + /** @var string|null */ private $vendorDir; // PSR-4 /** - * @var array[] - * @psalm-var array> + * @var array> */ private $prefixLengthsPsr4 = array(); /** - * @var array[] - * @psalm-var array> + * @var array> */ private $prefixDirsPsr4 = array(); /** - * @var array[] - * @psalm-var array + * @var list */ private $fallbackDirsPsr4 = array(); // PSR-0 /** - * @var array[] - * @psalm-var array> + * List of PSR-0 prefixes + * + * Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2'))) + * + * @var array>> */ private $prefixesPsr0 = array(); /** - * @var array[] - * @psalm-var array + * @var list */ private $fallbackDirsPsr0 = array(); @@ -78,8 +80,7 @@ class ClassLoader private $useIncludePath = false; /** - * @var string[] - * @psalm-var array + * @var array */ private $classMap = array(); @@ -87,29 +88,29 @@ class ClassLoader private $classMapAuthoritative = false; /** - * @var bool[] - * @psalm-var array + * @var array */ private $missingClasses = array(); - /** @var ?string */ + /** @var string|null */ private $apcuPrefix; /** - * @var self[] + * @var array */ private static $registeredLoaders = array(); /** - * @param ?string $vendorDir + * @param string|null $vendorDir */ public function __construct($vendorDir = null) { $this->vendorDir = $vendorDir; + self::initializeIncludeClosure(); } /** - * @return string[] + * @return array> */ public function getPrefixes() { @@ -121,8 +122,7 @@ public function getPrefixes() } /** - * @return array[] - * @psalm-return array> + * @return array> */ public function getPrefixesPsr4() { @@ -130,8 +130,7 @@ public function getPrefixesPsr4() } /** - * @return array[] - * @psalm-return array + * @return list */ public function getFallbackDirs() { @@ -139,8 +138,7 @@ public function getFallbackDirs() } /** - * @return array[] - * @psalm-return array + * @return list */ public function getFallbackDirsPsr4() { @@ -148,8 +146,7 @@ public function getFallbackDirsPsr4() } /** - * @return string[] Array of classname => path - * @psalm-return array + * @return array Array of classname => path */ public function getClassMap() { @@ -157,8 +154,7 @@ public function getClassMap() } /** - * @param string[] $classMap Class to filename map - * @psalm-param array $classMap + * @param array $classMap Class to filename map * * @return void */ @@ -175,24 +171,25 @@ public function addClassMap(array $classMap) * Registers a set of PSR-0 directories for a given prefix, either * appending or prepending to the ones previously set for this prefix. * - * @param string $prefix The prefix - * @param string[]|string $paths The PSR-0 root directories - * @param bool $prepend Whether to prepend the directories + * @param string $prefix The prefix + * @param list|string $paths The PSR-0 root directories + * @param bool $prepend Whether to prepend the directories * * @return void */ public function add($prefix, $paths, $prepend = false) { + $paths = (array) $paths; if (!$prefix) { if ($prepend) { $this->fallbackDirsPsr0 = array_merge( - (array) $paths, + $paths, $this->fallbackDirsPsr0 ); } else { $this->fallbackDirsPsr0 = array_merge( $this->fallbackDirsPsr0, - (array) $paths + $paths ); } @@ -201,19 +198,19 @@ public function add($prefix, $paths, $prepend = false) $first = $prefix[0]; if (!isset($this->prefixesPsr0[$first][$prefix])) { - $this->prefixesPsr0[$first][$prefix] = (array) $paths; + $this->prefixesPsr0[$first][$prefix] = $paths; return; } if ($prepend) { $this->prefixesPsr0[$first][$prefix] = array_merge( - (array) $paths, + $paths, $this->prefixesPsr0[$first][$prefix] ); } else { $this->prefixesPsr0[$first][$prefix] = array_merge( $this->prefixesPsr0[$first][$prefix], - (array) $paths + $paths ); } } @@ -222,9 +219,9 @@ public function add($prefix, $paths, $prepend = false) * Registers a set of PSR-4 directories for a given namespace, either * appending or prepending to the ones previously set for this namespace. * - * @param string $prefix The prefix/namespace, with trailing '\\' - * @param string[]|string $paths The PSR-4 base directories - * @param bool $prepend Whether to prepend the directories + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param list|string $paths The PSR-4 base directories + * @param bool $prepend Whether to prepend the directories * * @throws \InvalidArgumentException * @@ -232,17 +229,18 @@ public function add($prefix, $paths, $prepend = false) */ public function addPsr4($prefix, $paths, $prepend = false) { + $paths = (array) $paths; if (!$prefix) { // Register directories for the root namespace. if ($prepend) { $this->fallbackDirsPsr4 = array_merge( - (array) $paths, + $paths, $this->fallbackDirsPsr4 ); } else { $this->fallbackDirsPsr4 = array_merge( $this->fallbackDirsPsr4, - (array) $paths + $paths ); } } elseif (!isset($this->prefixDirsPsr4[$prefix])) { @@ -252,18 +250,18 @@ public function addPsr4($prefix, $paths, $prepend = false) throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); } $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; - $this->prefixDirsPsr4[$prefix] = (array) $paths; + $this->prefixDirsPsr4[$prefix] = $paths; } elseif ($prepend) { // Prepend directories for an already registered namespace. $this->prefixDirsPsr4[$prefix] = array_merge( - (array) $paths, + $paths, $this->prefixDirsPsr4[$prefix] ); } else { // Append directories for an already registered namespace. $this->prefixDirsPsr4[$prefix] = array_merge( $this->prefixDirsPsr4[$prefix], - (array) $paths + $paths ); } } @@ -272,8 +270,8 @@ public function addPsr4($prefix, $paths, $prepend = false) * Registers a set of PSR-0 directories for a given prefix, * replacing any others previously set for this prefix. * - * @param string $prefix The prefix - * @param string[]|string $paths The PSR-0 base directories + * @param string $prefix The prefix + * @param list|string $paths The PSR-0 base directories * * @return void */ @@ -290,8 +288,8 @@ public function set($prefix, $paths) * Registers a set of PSR-4 directories for a given namespace, * replacing any others previously set for this namespace. * - * @param string $prefix The prefix/namespace, with trailing '\\' - * @param string[]|string $paths The PSR-4 base directories + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param list|string $paths The PSR-4 base directories * * @throws \InvalidArgumentException * @@ -425,7 +423,8 @@ public function unregister() public function loadClass($class) { if ($file = $this->findFile($class)) { - includeFile($file); + $includeFile = self::$includeFile; + $includeFile($file); return true; } @@ -476,9 +475,9 @@ public function findFile($class) } /** - * Returns the currently registered loaders indexed by their corresponding vendor directories. + * Returns the currently registered loaders keyed by their corresponding vendor directories. * - * @return self[] + * @return array */ public static function getRegisteredLoaders() { @@ -555,18 +554,26 @@ private function findFileWithExtension($class, $ext) return false; } -} -/** - * Scope isolated include. - * - * Prevents access to $this/self from included files. - * - * @param string $file - * @return void - * @private - */ -function includeFile($file) -{ - include $file; + /** + * @return void + */ + private static function initializeIncludeClosure() + { + if (self::$includeFile !== null) { + return; + } + + /** + * Scope isolated include. + * + * Prevents access to $this/self from included files. + * + * @param string $file + * @return void + */ + self::$includeFile = \Closure::bind(static function($file) { + include $file; + }, null, null); + } } diff --git a/vendor/composer/InstalledVersions.php b/vendor/composer/InstalledVersions.php index d50e0c9..51e734a 100644 --- a/vendor/composer/InstalledVersions.php +++ b/vendor/composer/InstalledVersions.php @@ -21,12 +21,14 @@ * See also https://getcomposer.org/doc/07-runtime.md#installed-versions * * To require its presence, you can require `composer-runtime-api ^2.0` + * + * @final */ class InstalledVersions { /** * @var mixed[]|null - * @psalm-var array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array}|array{}|null + * @psalm-var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array}|array{}|null */ private static $installed; @@ -37,7 +39,7 @@ class InstalledVersions /** * @var array[] - * @psalm-var array}> + * @psalm-var array}> */ private static $installedByVendor = array(); @@ -96,7 +98,7 @@ public static function isInstalled($packageName, $includeDevRequirements = true) { foreach (self::getInstalled() as $installed) { if (isset($installed['versions'][$packageName])) { - return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']); + return $includeDevRequirements || !isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === false; } } @@ -117,7 +119,7 @@ public static function isInstalled($packageName, $includeDevRequirements = true) */ public static function satisfies(VersionParser $parser, $packageName, $constraint) { - $constraint = $parser->parseConstraints($constraint); + $constraint = $parser->parseConstraints((string) $constraint); $provided = $parser->parseConstraints(self::getVersionRanges($packageName)); return $provided->matches($constraint); @@ -241,7 +243,7 @@ public static function getInstallPath($packageName) /** * @return array - * @psalm-return array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string} + * @psalm-return array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool} */ public static function getRootPackage() { @@ -255,7 +257,7 @@ public static function getRootPackage() * * @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect. * @return array[] - * @psalm-return array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array} + * @psalm-return array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} */ public static function getRawData() { @@ -278,7 +280,7 @@ public static function getRawData() * Returns the raw data of all installed.php which are currently loaded for custom implementations * * @return array[] - * @psalm-return list}> + * @psalm-return list}> */ public static function getAllRawData() { @@ -301,7 +303,7 @@ public static function getAllRawData() * @param array[] $data A vendor/composer/installed.php data set * @return void * - * @psalm-param array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array} $data + * @psalm-param array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} $data */ public static function reload($data) { @@ -311,7 +313,7 @@ public static function reload($data) /** * @return array[] - * @psalm-return list}> + * @psalm-return list}> */ private static function getInstalled() { @@ -326,7 +328,9 @@ private static function getInstalled() if (isset(self::$installedByVendor[$vendorDir])) { $installed[] = self::$installedByVendor[$vendorDir]; } elseif (is_file($vendorDir.'/composer/installed.php')) { - $installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php'; + /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} $required */ + $required = require $vendorDir.'/composer/installed.php'; + $installed[] = self::$installedByVendor[$vendorDir] = $required; if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) { self::$installed = $installed[count($installed) - 1]; } @@ -338,12 +342,17 @@ private static function getInstalled() // only require the installed.php file if this file is loaded from its dumped location, // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 if (substr(__DIR__, -8, 1) !== 'C') { - self::$installed = require __DIR__ . '/installed.php'; + /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} $required */ + $required = require __DIR__ . '/installed.php'; + self::$installed = $required; } else { self::$installed = array(); } } - $installed[] = self::$installed; + + if (self::$installed !== array()) { + $installed[] = self::$installed; + } return $installed; } diff --git a/vendor/composer/LICENSE b/vendor/composer/LICENSE index 62ecfd8..f27399a 100644 --- a/vendor/composer/LICENSE +++ b/vendor/composer/LICENSE @@ -1,3 +1,4 @@ + Copyright (c) Nils Adermann, Jordi Boggiano Permission is hereby granted, free of charge, to any person obtaining a copy @@ -17,3 +18,4 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php index b26f1b1..0fb0a2c 100644 --- a/vendor/composer/autoload_classmap.php +++ b/vendor/composer/autoload_classmap.php @@ -2,7 +2,7 @@ // autoload_classmap.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( diff --git a/vendor/composer/autoload_files.php b/vendor/composer/autoload_files.php index a3788e4..4470736 100644 --- a/vendor/composer/autoload_files.php +++ b/vendor/composer/autoload_files.php @@ -2,12 +2,12 @@ // autoload_files.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( '7b11c4dc42b3b3023073cb14e519683c' => $vendorDir . '/ralouphie/getallheaders/src/getallheaders.php', - '6e3fae29631ef280660b3cdad06f25a8' => $vendorDir . '/symfony/deprecation-contracts/function.php', 'c964ee0ededf28c96ebd9db5099ef910' => $vendorDir . '/guzzlehttp/promises/src/functions_include.php', + '6e3fae29631ef280660b3cdad06f25a8' => $vendorDir . '/symfony/deprecation-contracts/function.php', '37a3dc5111fe8f707ab4c132ef1dbc62' => $vendorDir . '/guzzlehttp/guzzle/src/functions_include.php', ); diff --git a/vendor/composer/autoload_namespaces.php b/vendor/composer/autoload_namespaces.php index b7fc012..15a2ff3 100644 --- a/vendor/composer/autoload_namespaces.php +++ b/vendor/composer/autoload_namespaces.php @@ -2,7 +2,7 @@ // autoload_namespaces.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( diff --git a/vendor/composer/autoload_psr4.php b/vendor/composer/autoload_psr4.php index c015a5c..a18c82f 100644 --- a/vendor/composer/autoload_psr4.php +++ b/vendor/composer/autoload_psr4.php @@ -2,7 +2,7 @@ // autoload_psr4.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index 21bebff..e9c2a4e 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -22,57 +22,29 @@ public static function getLoader() return self::$loader; } + require __DIR__ . '/platform_check.php'; + spl_autoload_register(array('ComposerAutoloaderInit8ba2ca4e105ea351f7cb241590a7de7e', 'loadClassLoader'), true, true); - self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__))); + self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); spl_autoload_unregister(array('ComposerAutoloaderInit8ba2ca4e105ea351f7cb241590a7de7e', 'loadClassLoader')); - $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); - if ($useStaticLoader) { - require __DIR__ . '/autoload_static.php'; + require __DIR__ . '/autoload_static.php'; + call_user_func(\Composer\Autoload\ComposerStaticInit8ba2ca4e105ea351f7cb241590a7de7e::getInitializer($loader)); - call_user_func(\Composer\Autoload\ComposerStaticInit8ba2ca4e105ea351f7cb241590a7de7e::getInitializer($loader)); - } else { - $map = require __DIR__ . '/autoload_namespaces.php'; - foreach ($map as $namespace => $path) { - $loader->set($namespace, $path); - } + $loader->register(true); - $map = require __DIR__ . '/autoload_psr4.php'; - foreach ($map as $namespace => $path) { - $loader->setPsr4($namespace, $path); - } + $filesToLoad = \Composer\Autoload\ComposerStaticInit8ba2ca4e105ea351f7cb241590a7de7e::$files; + $requireFile = \Closure::bind(static function ($fileIdentifier, $file) { + if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { + $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; - $classMap = require __DIR__ . '/autoload_classmap.php'; - if ($classMap) { - $loader->addClassMap($classMap); + require $file; } - } - - $loader->register(true); - - if ($useStaticLoader) { - $includeFiles = Composer\Autoload\ComposerStaticInit8ba2ca4e105ea351f7cb241590a7de7e::$files; - } else { - $includeFiles = require __DIR__ . '/autoload_files.php'; - } - foreach ($includeFiles as $fileIdentifier => $file) { - composerRequire8ba2ca4e105ea351f7cb241590a7de7e($fileIdentifier, $file); + }, null, null); + foreach ($filesToLoad as $fileIdentifier => $file) { + $requireFile($fileIdentifier, $file); } return $loader; } } - -/** - * @param string $fileIdentifier - * @param string $file - * @return void - */ -function composerRequire8ba2ca4e105ea351f7cb241590a7de7e($fileIdentifier, $file) -{ - if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { - $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; - - require $file; - } -} diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index e753df9..059c1df 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -8,8 +8,8 @@ class ComposerStaticInit8ba2ca4e105ea351f7cb241590a7de7e { public static $files = array ( '7b11c4dc42b3b3023073cb14e519683c' => __DIR__ . '/..' . '/ralouphie/getallheaders/src/getallheaders.php', - '6e3fae29631ef280660b3cdad06f25a8' => __DIR__ . '/..' . '/symfony/deprecation-contracts/function.php', 'c964ee0ededf28c96ebd9db5099ef910' => __DIR__ . '/..' . '/guzzlehttp/promises/src/functions_include.php', + '6e3fae29631ef280660b3cdad06f25a8' => __DIR__ . '/..' . '/symfony/deprecation-contracts/function.php', '37a3dc5111fe8f707ab4c132ef1dbc62' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/functions_include.php', ); diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index a4a1c4e..0e5703f 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -2,21 +2,21 @@ "packages": [ { "name": "elan-ev/opencast-api", - "version": "1.5.0", - "version_normalized": "1.5.0.0", + "version": "1.8.0", + "version_normalized": "1.8.0.0", "source": { "type": "git", "url": "https://github.com/elan-ev/opencast-php-library.git", - "reference": "dfcfa0789c8a670623ed27434ced88f595941b73" + "reference": "183619e86e60f97e8ba2d5b482d29a825506258b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/elan-ev/opencast-php-library/zipball/dfcfa0789c8a670623ed27434ced88f595941b73", - "reference": "dfcfa0789c8a670623ed27434ced88f595941b73", + "url": "https://api.github.com/repos/elan-ev/opencast-php-library/zipball/183619e86e60f97e8ba2d5b482d29a825506258b", + "reference": "183619e86e60f97e8ba2d5b482d29a825506258b", "shasum": "" }, "require": { - "guzzlehttp/guzzle": "7.5.1", + "guzzlehttp/guzzle": ">=7.5.1", "php": ">=7.2.5" }, "require-dev": { @@ -24,7 +24,7 @@ "phpunit/phpunit": "^9.5", "squizlabs/php_codesniffer": "^3.7" }, - "time": "2023-11-13T16:47:55+00:00", + "time": "2024-09-20T09:03:48+00:00", "type": "library", "extra": { "branch-alias": { @@ -58,7 +58,7 @@ ], "support": { "issues": "https://github.com/elan-ev/opencast-php-library/issues", - "source": "https://github.com/elan-ev/opencast-php-library/tree/1.5.0" + "source": "https://github.com/elan-ev/opencast-php-library/tree/1.8.0" }, "install-path": "../elan-ev/opencast-api" }, @@ -681,16 +681,6 @@ "install-path": "../symfony/deprecation-contracts" } ], - "dev": true, - "dev-package-names": [ - "elan-ev/opencast-api", - "guzzlehttp/guzzle", - "guzzlehttp/promises", - "guzzlehttp/psr7", - "psr/http-client", - "psr/http-factory", - "psr/http-message", - "ralouphie/getallheaders", - "symfony/deprecation-contracts" - ] + "dev": false, + "dev-package-names": [] } diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index b05cf9e..e7ca578 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -1,71 +1,71 @@ array( + 'name' => 'moodle/tool_opencast', 'pretty_version' => 'dev-master', 'version' => 'dev-master', + 'reference' => '420c1dd6d78963cdf2cb56c58c25128d47f83649', 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), - 'reference' => '7255dedbafbbb1db81745bdfde8aa8aaeb9f9846', - 'name' => 'moodle/tool_opencast', - 'dev' => true, + 'dev' => false, ), 'versions' => array( 'elan-ev/opencast-api' => array( - 'pretty_version' => '1.5.0', - 'version' => '1.5.0.0', + 'pretty_version' => '1.8.0', + 'version' => '1.8.0.0', + 'reference' => '183619e86e60f97e8ba2d5b482d29a825506258b', 'type' => 'library', 'install_path' => __DIR__ . '/../elan-ev/opencast-api', 'aliases' => array(), - 'reference' => 'dfcfa0789c8a670623ed27434ced88f595941b73', - 'dev_requirement' => true, + 'dev_requirement' => false, ), 'guzzlehttp/guzzle' => array( 'pretty_version' => '7.5.1', 'version' => '7.5.1.0', + 'reference' => 'b964ca597e86b752cd994f27293e9fa6b6a95ed9', 'type' => 'library', 'install_path' => __DIR__ . '/../guzzlehttp/guzzle', 'aliases' => array(), - 'reference' => 'b964ca597e86b752cd994f27293e9fa6b6a95ed9', - 'dev_requirement' => true, + 'dev_requirement' => false, ), 'guzzlehttp/promises' => array( 'pretty_version' => '1.5.3', 'version' => '1.5.3.0', + 'reference' => '67ab6e18aaa14d753cc148911d273f6e6cb6721e', 'type' => 'library', 'install_path' => __DIR__ . '/../guzzlehttp/promises', 'aliases' => array(), - 'reference' => '67ab6e18aaa14d753cc148911d273f6e6cb6721e', - 'dev_requirement' => true, + 'dev_requirement' => false, ), 'guzzlehttp/psr7' => array( 'pretty_version' => '2.6.1', 'version' => '2.6.1.0', + 'reference' => 'be45764272e8873c72dbe3d2edcfdfcc3bc9f727', 'type' => 'library', 'install_path' => __DIR__ . '/../guzzlehttp/psr7', 'aliases' => array(), - 'reference' => 'be45764272e8873c72dbe3d2edcfdfcc3bc9f727', - 'dev_requirement' => true, + 'dev_requirement' => false, ), 'moodle/tool_opencast' => array( 'pretty_version' => 'dev-master', 'version' => 'dev-master', + 'reference' => '420c1dd6d78963cdf2cb56c58c25128d47f83649', 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), - 'reference' => '7255dedbafbbb1db81745bdfde8aa8aaeb9f9846', 'dev_requirement' => false, ), 'psr/http-client' => array( 'pretty_version' => '1.0.3', 'version' => '1.0.3.0', + 'reference' => 'bb5906edc1c324c9a05aa0873d40117941e5fa90', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/http-client', 'aliases' => array(), - 'reference' => 'bb5906edc1c324c9a05aa0873d40117941e5fa90', - 'dev_requirement' => true, + 'dev_requirement' => false, ), 'psr/http-client-implementation' => array( - 'dev_requirement' => true, + 'dev_requirement' => false, 'provided' => array( 0 => '1.0', ), @@ -73,14 +73,14 @@ 'psr/http-factory' => array( 'pretty_version' => '1.0.2', 'version' => '1.0.2.0', + 'reference' => 'e616d01114759c4c489f93b099585439f795fe35', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/http-factory', 'aliases' => array(), - 'reference' => 'e616d01114759c4c489f93b099585439f795fe35', - 'dev_requirement' => true, + 'dev_requirement' => false, ), 'psr/http-factory-implementation' => array( - 'dev_requirement' => true, + 'dev_requirement' => false, 'provided' => array( 0 => '1.0', ), @@ -88,14 +88,14 @@ 'psr/http-message' => array( 'pretty_version' => '2.0', 'version' => '2.0.0.0', + 'reference' => '402d35bcb92c70c026d1a6a9883f06b2ead23d71', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/http-message', 'aliases' => array(), - 'reference' => '402d35bcb92c70c026d1a6a9883f06b2ead23d71', - 'dev_requirement' => true, + 'dev_requirement' => false, ), 'psr/http-message-implementation' => array( - 'dev_requirement' => true, + 'dev_requirement' => false, 'provided' => array( 0 => '1.0', ), @@ -103,20 +103,20 @@ 'ralouphie/getallheaders' => array( 'pretty_version' => '3.0.3', 'version' => '3.0.3.0', + 'reference' => '120b605dfeb996808c31b6477290a714d356e822', 'type' => 'library', 'install_path' => __DIR__ . '/../ralouphie/getallheaders', 'aliases' => array(), - 'reference' => '120b605dfeb996808c31b6477290a714d356e822', - 'dev_requirement' => true, + 'dev_requirement' => false, ), 'symfony/deprecation-contracts' => array( 'pretty_version' => 'v3.3.0', 'version' => '3.3.0.0', + 'reference' => '7c3aff79d10325257a001fcf92d991f24fc967cf', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/deprecation-contracts', 'aliases' => array(), - 'reference' => '7c3aff79d10325257a001fcf92d991f24fc967cf', - 'dev_requirement' => true, + 'dev_requirement' => false, ), ), ); diff --git a/vendor/composer/platform_check.php b/vendor/composer/platform_check.php new file mode 100644 index 0000000..4c3a5d6 --- /dev/null +++ b/vendor/composer/platform_check.php @@ -0,0 +1,26 @@ += 80100)) { + $issues[] = 'Your Composer dependencies require a PHP version ">= 8.1.0". You are running ' . PHP_VERSION . '.'; +} + +if ($issues) { + if (!headers_sent()) { + header('HTTP/1.1 500 Internal Server Error'); + } + if (!ini_get('display_errors')) { + if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') { + fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL); + } elseif (!headers_sent()) { + echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL; + } + } + trigger_error( + 'Composer detected issues in your platform: ' . implode(' ', $issues), + E_USER_ERROR + ); +} diff --git a/vendor/elan-ev/opencast-api/CHANGELOG.md b/vendor/elan-ev/opencast-api/CHANGELOG.md index 578b963..94d37f1 100644 --- a/vendor/elan-ev/opencast-api/CHANGELOG.md +++ b/vendor/elan-ev/opencast-api/CHANGELOG.md @@ -36,3 +36,17 @@ # 1.5.0 - PHP 8.2 compatibility: prevent dynamic property declarations + +# 1.6.0 +- Introducing OcPlaylistApi REST API service endpoint. +- Fix ingest tags issues + +# 1.7.0 +- Adopt Opencast 16 changes (lucene search endpoint removal by toggle it in the config -> features -> lucene [default false]) +- runWithRoles does not apply the headers when api version is not defined +- Playlist endpoint minor changes +- Add workflow configuration params into ingest method. +- Make guzzle version require from (>=) v7.5.1 in composer. + +# 1.8.0 +- Fix for unauthorized access when extracting the Opencast API Version. diff --git a/vendor/elan-ev/opencast-api/README.md b/vendor/elan-ev/opencast-api/README.md index d1deca1..38e8a15 100644 --- a/vendor/elan-ev/opencast-api/README.md +++ b/vendor/elan-ev/opencast-api/README.md @@ -26,6 +26,7 @@ $config = [ 'connect_timeout' => 0, // The API connection timeout. In seconds (default 0 to wait indefinitely) (optional) 'version' => null, // The API Version. (Default null). (optional) 'handler' => null // The callable Handler or HandlerStack. (Default null). (optional) + 'features' => null // A set of additional features [e.g. lucene search]. (Default null). (optional) ]; $engageConfig = [ @@ -36,6 +37,7 @@ $engageConfig = [ 'connect_timeout' => 0, // The API connection timeout. In seconds (default 0 to wait indefinitely) (optional) 'version' => null, // The API version. (Default null). (optional) 'handler' => null // The callable Handler or HandlerStack. (Default null). (optional) + 'features' => null // A set of additional features [e.g. lucene search]. (Default null). (optional) ]; use OpencastApi\Opencast; @@ -73,6 +75,7 @@ $config = [ 'connect_timeout' => 0, // The API connection timeout. In seconds (default 0 to wait indefinitely) (optional) 'version' => null, // The API version. (Default null). (optional) 'handler' => null // The callable Handler or HandlerStack. (Default null). (optional) + 'features' => null // A set of additional features [e.g. lucene search]. (Default null). (optional) ]; @@ -112,8 +115,11 @@ $config = [ 'connect_timeout' => 0, // The API connection timeout. In seconds (default 0 to wait indefinitely) (optional) 'version' => null, // The API version. (Default null). (optional) 'handler' => null // The callable Handler or HandlerStack. (Default null). (optional) + 'features' => null // A set of additional features [e.g. lucene search]. (Default null). (optional) ]; ``` +**UPDATE (v1.7.0):** the new items called `features` is added to the configuration array. As of now, it is meant to hanlde the toggle behavior to enable/disable Lucene search endpoint simply by adding `'features' => ['lucene' => true]`. Just keep in mind that this endpoint id off by default and won't work in Opencast 16 onwards. Therefore, developer must be very careful to use this feature and to toggle it! + NOTE: the configuration for presentation (`engage` node) responsible for search has to follow the same definition as normal config. But in case any parameter is missing, the value will be taken from the main config param. #### Extra: Dynamically loading the ingest endpoint class into Opencast instance. diff --git a/vendor/elan-ev/opencast-api/composer.json b/vendor/elan-ev/opencast-api/composer.json index 80bd09b..6055765 100644 --- a/vendor/elan-ev/opencast-api/composer.json +++ b/vendor/elan-ev/opencast-api/composer.json @@ -19,7 +19,7 @@ "homepage": "https://docs.opencast.org/", "require": { "php": ">=7.2.5", - "guzzlehttp/guzzle": "7.5.1" + "guzzlehttp/guzzle": ">=7.5.1" }, "autoload": { "psr-4": { diff --git a/vendor/elan-ev/opencast-api/src/OpencastApi/Mock/OcMockHanlder.php b/vendor/elan-ev/opencast-api/src/OpencastApi/Mock/OcMockHanlder.php index 65cf90a..79f86e6 100644 --- a/vendor/elan-ev/opencast-api/src/OpencastApi/Mock/OcMockHanlder.php +++ b/vendor/elan-ev/opencast-api/src/OpencastApi/Mock/OcMockHanlder.php @@ -50,7 +50,7 @@ public static function getHandlerStackWithPath($data, $recordFilePath = null) ]; $response = new Response($status, $headers, $body, $version, json_encode($reasonData)); - if ($method === 'PUT' && !empty($requestBody)) { + if (in_array($method, ['POST', 'PUT']) && !empty($requestBody)) { $requestBody = urldecode($requestBody); } foreach ($data as $resPath => $resData) { diff --git a/vendor/elan-ev/opencast-api/src/OpencastApi/Opencast.php b/vendor/elan-ev/opencast-api/src/OpencastApi/Opencast.php index 24fb06a..652bfe7 100644 --- a/vendor/elan-ev/opencast-api/src/OpencastApi/Opencast.php +++ b/vendor/elan-ev/opencast-api/src/OpencastApi/Opencast.php @@ -6,67 +6,70 @@ class Opencast { - /** @var OpencastApi\Rest\OcRestClient the rest client */ + /** @var OcRestClient the rest client */ private $restClient; - /** @var OpencastApi\Rest\OcRestClient the engage node rest client */ + /** @var OcRestClient the engage node rest client */ private $engageRestClient; - // Avoid PHP 8.2 deprecates the creation of dynamic class properties. + // PHP 8.2 deprecates the creation of dynamic class properties. // We also need to avoid the type declaration to provide the possibility of using Decorate proxy. - /** @var OpencastApi\Rest\OcAgentsApi $agentsApi */ + /** @var \OpencastApi\Rest\OcAgentsApi $agentsApi */ public $agentsApi; - /** @var OpencastApi\Rest\OcBaseApi $baseApi */ + /** @var \OpencastApi\Rest\OcBaseApi $baseApi */ public $baseApi; - /** @var OpencastApi\Rest\OcCaptureAdmin $captureAdmin */ + /** @var \OpencastApi\Rest\OcCaptureAdmin $captureAdmin */ public $captureAdmin; - /** @var OpencastApi\Rest\OcEventAdminNg $eventAdminNg */ + /** @var \OpencastApi\Rest\OcEventAdminNg $eventAdminNg */ public $eventAdminNg; - /** @var OpencastApi\Rest\OcEventsApi $eventsApi */ + /** @var \OpencastApi\Rest\OcEventsApi $eventsApi */ public $eventsApi; - /** @var OpencastApi\Rest\OcGroupsApi $groupsApi */ + /** @var \OpencastApi\Rest\OcGroupsApi $groupsApi */ public $groupsApi; - /** @var OpencastApi\Rest\OcRecordings $recordings */ + /** @var \OpencastApi\Rest\OcPlaylistsApi $playlistsApi */ + public $playlistsApi; + + /** @var \OpencastApi\Rest\OcRecordings $recordings */ public $recordings; - /** @var OpencastApi\Rest\OcSearch $search */ + /** @var \OpencastApi\Rest\OcSearch $search */ public $search; - /** @var OpencastApi\Rest\OcSecurityApi $securityApi */ + /** @var \OpencastApi\Rest\OcSecurityApi $securityApi */ public $securityApi; - /** @var OpencastApi\Rest\OcSeriesApi $seriesApi */ + /** @var \OpencastApi\Rest\OcSeriesApi $seriesApi */ public $seriesApi; - /** @var OpencastApi\Rest\OcSeries $series */ + /** @var \OpencastApi\Rest\OcSeries $series */ public $series; - /** @var OpencastApi\Rest\OcServices $services */ + /** @var \OpencastApi\Rest\OcServices $services */ public $services; - /** @var OpencastApi\Rest\OcStatisticsApi $statisticsApi */ + /** @var \OpencastApi\Rest\OcStatisticsApi $statisticsApi */ public $statisticsApi; - /** @var OpencastApi\Rest\OcSysinfo $sysinfo */ + /** @var \OpencastApi\Rest\OcSysinfo $sysinfo */ public $sysinfo; - /** @var OpencastApi\Rest\OcWorkflow $agentsApi */ + /** @var \OpencastApi\Rest\OcWorkflow $agentsApi */ public $workflow; - /** @var OpencastApi\Rest\OcWorkflowsApi $workflowsApi */ + /** @var \OpencastApi\Rest\OcWorkflowsApi $workflowsApi */ public $workflowsApi; - /** @var OpencastApi\Rest\OcIngest $ingest */ + /** @var \OpencastApi\Rest\OcIngest $ingest */ public $ingest; - /** @var OpencastApi\Rest\OcListProvidersApi $listProvidersApi */ + /** @var \OpencastApi\Rest\OcListProvidersApi $listProvidersApi */ public $listProvidersApi; /* @@ -78,6 +81,7 @@ class Opencast 'connect_timeout' => 0 // The API connection timeout. In seconds (default 0 to wait indefinitely) (optional) 'version' => null // The API Version. (Default null). (optional) 'handler' => null // The callable Handler or HandlerStack. (Default null). (optional) + 'features' => null // A set of additional features [e.g. lucene search]. (Default null). (optional) ] $engageConfig = [ @@ -88,6 +92,7 @@ class Opencast 'connect_timeout' => 0 // The API connection timeout. In seconds (default 0 to wait indefinitely) (optional) 'version' => null // The API Version. (Default null). (optional) 'handler' => null // The callable Handler or HandlerStack. (Default null). (optional) + 'features' => null // A set of additional features [e.g. lucene search]. (Default null). (optional) ] */ /** @@ -168,6 +173,9 @@ private function setEngageRestClient($config, $engageConfig) if (!isset($engageConfig['handler']) && isset($config['handler'])) { $engageConfig['handler'] = $config['handler']; } + if (!isset($engageConfig['features']) && isset($config['features'])) { + $engageConfig['features'] = $config['features']; + } $this->engageRestClient = new OcRestClient($engageConfig); } diff --git a/vendor/elan-ev/opencast-api/src/OpencastApi/Rest/OcIngest.php b/vendor/elan-ev/opencast-api/src/OpencastApi/Rest/OcIngest.php index ec80356..b18873e 100644 --- a/vendor/elan-ev/opencast-api/src/OpencastApi/Rest/OcIngest.php +++ b/vendor/elan-ev/opencast-api/src/OpencastApi/Rest/OcIngest.php @@ -13,7 +13,7 @@ public function __construct($restClient) /** * Create an empty media package. - * + * * @return array the response result ['code' => 200, 'body' => '{XML (text) media package}'] */ public function createMediaPackage() @@ -39,13 +39,14 @@ public function addCatalog($mediaPackage, $flavor, $file, $tags = '') $formData = [ 'mediaPackage' => $mediaPackage, 'flavor' => $flavor, - 'dublincore-episode.xml' => $file ]; if (!empty($tags)) { $formData['tags'] = $tags; } + $formData['BODY'] = $file; + $options = $this->restClient->getMultiPartFormParams($formData); return $this->restClient->performPost($uri, $options); } @@ -67,13 +68,14 @@ public function addCatalogUrl($mediaPackage, $flavor, $url, $tags = '') $formData = [ 'mediaPackage' => $mediaPackage, 'flavor' => $flavor, - 'url' => $url ]; if (!empty($tags)) { $formData['tags'] = $tags; } + $formData['url'] = $url; + $options = $this->restClient->getFormParams($formData); return $this->restClient->performPost($uri, $options); } @@ -84,7 +86,7 @@ public function addCatalogUrl($mediaPackage, $flavor, $url, $tags = '') * @param string $mediaPackage The media package * @param string $dublinCore DublinCore catalog * @param string $flavor (optional) DublinCore Flavor (Default value=dublincore/episode) - * + * * @return array the response result ['code' => 200, 'body' => '{XML (text) augmented media package}'] */ public function addDCCatalog($mediaPackage, $dublinCore, $flavor = '') @@ -99,7 +101,7 @@ public function addDCCatalog($mediaPackage, $dublinCore, $flavor = '') $formData['flavor'] = $flavor; } - $options = $this->restClient->getFormParams($formData); + $options = $this->restClient->getFormParams($formData); return $this->restClient->performPost($uri, $options); } @@ -120,13 +122,14 @@ public function addAttachment($mediaPackage, $flavor, $file, $tags = '') $formData = [ 'mediaPackage' => $mediaPackage, 'flavor' => $flavor, - 'attachment.xml' => $file ]; if (!empty($tags)) { $formData['tags'] = $tags; } + $formData['BODY'] = $file; + $options = $this->restClient->getMultiPartFormParams($formData); return $this->restClient->performPost($uri, $options); } @@ -148,27 +151,28 @@ public function addAttachmentUrl($mediaPackage, $flavor, $url, $tags = '') $formData = [ 'mediaPackage' => $mediaPackage, 'flavor' => $flavor, - 'url' => $url ]; if (!empty($tags)) { $formData['tags'] = $tags; } + $formData['url'] = $url; + $options = $this->restClient->getFormParams($formData); return $this->restClient->performPost($uri, $options); } /** * Create and ingest media package from media tracks with additional Dublin Core metadata. - * It is mandatory to set a title for the recording. This can be done with the 'title' form field or by supplying a DC catalog with a title included. + * It is mandatory to set a title for the recording. This can be done with the 'title' form field or by supplying a DC catalog with a title included. * (deprecated*) The identifier of the newly created media package will be taken from the identifier field or the episode DublinCore catalog (deprecated*). * If no identifier is set, a new random UUIDv4 will be generated. This endpoint is not meant to be used by capture agents for scheduled recordings. Its primary use is for manual ingests with command line tools like cURL. - * + * * Multiple tracks can be ingested by using multiple form fields. It is important to always set the flavor of the next media file before sending the media file itself. - * - * (*) The special treatment of the identifier field is deprecated and may be removed in future versions without further notice in favor of a random UUID generation to ensure uniqueness of identifiers. - * + * + * (*) The special treatment of the identifier field is deprecated and may be removed in future versions without further notice in favor of a random UUID generation to ensure uniqueness of identifiers. + * * * @param array $flavor (optional) The kind of media track. This has to be specified prior to each media track (default: "presenter/source"): * @param array $file (partially optional) media track file, could be null if mediaUri in $params is defined. @@ -205,15 +209,15 @@ public function addAttachmentUrl($mediaPackage, $flavor, $url, $tags = '') * 'type' => '', // Episode metadata value. * 'episodeDCCatalogUri' => '', // URL of episode DublinCore Catalog. * 'episodeDCCatalog' => '', // URL of episode DublinCore Catalog. - * 'seriesDCCatalogUri' => '', // URL of series DublinCore Catalog - * 'seriesDCCatalog' => '', // Series DublinCore Catalog - * 'acl' => '', // Access control list in XACML or JSON form + * 'seriesDCCatalogUri' => '', // URL of series DublinCore Catalog + * 'seriesDCCatalog' => '', // Series DublinCore Catalog + * 'acl' => '', // Access control list in XACML or JSON form * 'tag' => '', // Tag of the next media file * 'mediaUri' => '', // URL of a media track file * ] - * + * * @param string $wdID (optional) Workflow definition id - * + * * @return array the response result ['code' => 200, 'body' => '{Ingest successful. Returns workflow instance as XML (text)'] */ public function addMediaPackage($flavor = 'presenter/source', $file = null, $params = [], $wdID = '') @@ -243,7 +247,7 @@ public function addMediaPackage($flavor = 'presenter/source', $file = null, $par } else { $options = $this->restClient->getFormParams($formData); } - + return $this->restClient->performPost($uri, $options); } @@ -268,7 +272,7 @@ public function addZippedMediaPackage($zipFile, $workflowDefinitionId, $workflow $formData['workflowInstanceId'] = $workflowInstanceId; } - $options = $this->restClient->getMultiPartFormParams($formData); + $options = $this->restClient->getMultiPartFormParams($formData); return $this->restClient->performPost($uri, $options); } @@ -305,7 +309,7 @@ public function discardMediaPackage($mediaPackage) * Add a partial media track to a given media package using an input stream * * @param string $mediaPackage The XML media package as string - * @param string $flavor The kind of media track + * @param string $flavor The kind of media track * @param object $file The media track file * @param int $startTime The start time in milliseconds * @@ -319,10 +323,10 @@ public function addPartialTrack($mediaPackage, $flavor, $file, $startTime = 0) 'mediaPackage' => $mediaPackage, 'flavor' => $flavor, 'startTime' => $startTime, - 'track.mp4' => $file + 'BODY' => $file ]; - $options = $this->restClient->getMultiPartFormParams($formData); + $options = $this->restClient->getMultiPartFormParams($formData); return $this->restClient->performPost($uri, $options); } @@ -330,7 +334,7 @@ public function addPartialTrack($mediaPackage, $flavor, $file, $startTime = 0) * Add a partial media track to a given media package using an URL * * @param string $mediaPackage The XML media package as string - * @param string $flavor The kind of media track + * @param string $flavor The kind of media track * @param string $url The location of the media * @param int $startTime The start time in milliseconds * @@ -347,13 +351,13 @@ public function addPartialTrackUrl($mediaPackage, $flavor, $url, $startTime = 0) 'url' => $url ]; - $options = $this->restClient->getFormParams($formData); + $options = $this->restClient->getFormParams($formData); return $this->restClient->performPost($uri, $options); } /** * Add a media track to a given media package using an input stream - * + * * @param string $mediaPackage The media package * @param string $flavor The kind of media track * @param object $file The media track file @@ -375,13 +379,14 @@ public function addTrack($mediaPackage, $flavor, $file, $tags = '', $progressCal $formData = [ 'mediaPackage' => $mediaPackage, 'flavor' => $flavor, - 'track.mp4' => $file ]; if (!empty($tags)) { $formData['tags'] = $tags; } + $formData['BODY'] = $file; + $options = $this->restClient->getMultiPartFormParams($formData); if (!empty($progressCallable)) { $options['progress'] = $progressCallable; @@ -392,7 +397,7 @@ public function addTrack($mediaPackage, $flavor, $file, $tags = '', $progressCal /** * Add a media track to a given media package using an URL - * + * * @param string $mediaPackage The media package * @param string $flavor The kind of media track * @param string $url The location of the media @@ -407,14 +412,15 @@ public function addTrackUrl($mediaPackage, $flavor, $url, $tags = '') $formData = [ 'mediaPackage' => $mediaPackage, 'flavor' => $flavor, - 'url' => $url ]; if (!empty($tags)) { $formData['tags'] = $tags; } - $options = $this->restClient->getFormParams($formData); + $formData['url'] = $url; + + $options = $this->restClient->getFormParams($formData); return $this->restClient->performPost($uri, $options); } @@ -425,10 +431,11 @@ public function addTrackUrl($mediaPackage, $flavor, $url, $tags = '') * @param string $mediaPackage The media package * @param string $workflowDefinitionId (optional) Workflow definition id * @param string $workflowInstanceId (optional) The workflow instance ID to associate this ingest with scheduled events. + * @param array $workflowConfiguration Workflow configuration * * @return array the response result ['code' => 200, 'body' => '{XML (text) media package}'] */ - public function ingest($mediaPackage, $workflowDefinitionId = '', $workflowInstanceId = '') + public function ingest($mediaPackage, $workflowDefinitionId = '', $workflowInstanceId = '', $workflowConfiguration = []) { $uri = self::URI . "/ingest"; if (!empty($workflowDefinitionId) && empty($workflowInstanceId)) { @@ -444,6 +451,13 @@ public function ingest($mediaPackage, $workflowDefinitionId = '', $workflowInsta $formData['workflowInstanceId'] = $workflowInstanceId; } + if (!empty($workflowConfiguration)) { + // Adding workflow configuration params into the form data one by one. + foreach ($workflowConfiguration as $config => $value) { + $formData[$config] = $value; + } + } + $options = $this->restClient->getFormParams($formData); return $this->restClient->performPost($uri, $options); @@ -472,4 +486,4 @@ public function schedule($mediaPackage, $workflowDefinitionId = '') return $this->restClient->performPost($uri, $options); } } -?> \ No newline at end of file +?> diff --git a/vendor/elan-ev/opencast-api/src/OpencastApi/Rest/OcPlaylistsApi.php b/vendor/elan-ev/opencast-api/src/OpencastApi/Rest/OcPlaylistsApi.php new file mode 100644 index 0000000..b14bef7 --- /dev/null +++ b/vendor/elan-ev/opencast-api/src/OpencastApi/Rest/OcPlaylistsApi.php @@ -0,0 +1,161 @@ + (int) {The maximum number of results to return for a single request}, + * 'offset' => (int) {The index of the first result to return}, + * 'sort' => {The sort criteria. A criteria is specified by a case-sensitive sort name and the order separated by a colon (e.g. updated:ASC). Supported sort names: 'updated'. Use the order ASC to sort ascending or DESC to sort descending.} + * ] + * + * @return array the response result ['code' => 200, 'body' => '{A (potentially empty) list of playlists}'] + */ + public function getAll($params = []) + { + $uri = self::URI; + + $query = []; + + if (array_key_exists('limit', $params) && !empty($params['limit'])) { + $query['limit'] = $params['limit']; + } + if (array_key_exists('offset', $params) && !empty($params['offset'])) { + $query['offset'] = $params['offset']; + } + + $supportedSortNames = ['updated']; + $supportedSorts= []; + foreach ($supportedSortNames as $sortName) { + $supportedSorts[] = "$sortName:ASC"; + $supportedSorts[] = "$sortName:DESC"; + } + + if (array_key_exists('sort', $params) && !empty($params['sort']) && + in_array($params['sort'], $supportedSorts)) { + $query['sort'] = $params['sort']; + } + + $options = $this->restClient->getQueryParams($query); + return $this->restClient->performGet($uri, $options); + } + + /** + * Get a playlist. + * + * @param string $playlistId the identifier of the playlist + * + * @return array the response result ['code' => 200, 'body' => '{The playlist (object)}'] + */ + public function get($playlistId) + { + $uri = self::URI . "/{$playlistId}"; + return $this->restClient->performGet($uri); + } + + /** + * Creates a playlist. + * + * @param string|array $playlist A playlist + * + * @return array the response result ['code' => 201, 'body' => '{The new playlist (object)}'] + */ + public function create($playlist) + { + $formData = [ + 'playlist' => $playlist, + ]; + + $options = $this->restClient->getFormParams($formData); + return $this->restClient->performPost(self::URI, $options); + } + + /** + * Updates a playlist. + * + * @param string $playlistId the identifier of the playlist + * @param string|array $playlist the updated playlist + * + * @return array the response result ['code' => 200, 'body' => '{The updated playlist (object)}'] + */ + public function update($playlistId, $playlist) + { + $uri = self::URI . "/{$playlistId}"; + + $formData = [ + 'playlist' => $playlist, + ]; + + $options = $this->restClient->getFormParams($formData); + return $this->restClient->performPut($uri, $options); + } + + /** + * Removes a playlist. + * + * @param string $playlistId the identifier of the playlist + * + * @return array the response result ['code' => 200, 'body' => '{The removed playlist (object)}'] + */ + public function delete($playlistId) + { + $uri = self::URI . "/{$playlistId}"; + return $this->restClient->performDelete($uri); + } + + ## End of [Section 1]: General API endpoints. + + ## [Section 2]: Entries. + + /** + * Updates the entries of a playlist + * + * @param string $playlistId the identifier of the playlist + * @param string|array $playlistEntries the playlist entries + * + * @return array the response result ['code' => 200, 'body' => '{The updated playlist (object)}'] + */ + public function updateEntries($playlistId, $playlistEntries) + { + $uri = self::URI . "/{$playlistId}"; + + $formData = [ + 'playlist' => [ + 'entries' => $playlistEntries + ] + ]; + + $options = $this->restClient->getFormParams($formData); + return $this->restClient->performPut($uri, $options); + } + + /** + * Removes all entries of the playlist + * + * @param string $playlistId the identifier of the playlist + * + * @return array the response result ['code' => 200, 'body' => '{The updated playlist (object)}'] + */ + public function emptyEntries($playlistId) + { + return $this->updateEntries($playlistId, []); + } + + ## End of [Section 2]: Entries. +} +?> diff --git a/vendor/elan-ev/opencast-api/src/OpencastApi/Rest/OcRest.php b/vendor/elan-ev/opencast-api/src/OpencastApi/Rest/OcRest.php index 3fbcd18..3363815 100644 --- a/vendor/elan-ev/opencast-api/src/OpencastApi/Rest/OcRest.php +++ b/vendor/elan-ev/opencast-api/src/OpencastApi/Rest/OcRest.php @@ -2,6 +2,7 @@ namespace OpencastApi\Rest; abstract class OcRest { + /** @var OcRestClient */ protected $restClient; public function __construct($restClient) diff --git a/vendor/elan-ev/opencast-api/src/OpencastApi/Rest/OcRestClient.php b/vendor/elan-ev/opencast-api/src/OpencastApi/Rest/OcRestClient.php index f871cff..6d5dbbb 100644 --- a/vendor/elan-ev/opencast-api/src/OpencastApi/Rest/OcRestClient.php +++ b/vendor/elan-ev/opencast-api/src/OpencastApi/Rest/OcRestClient.php @@ -17,6 +17,7 @@ class OcRestClient extends Client private $additionalHeaders = []; private $noHeader = false; private $origin; + private $features = []; /* $config = [ 'url' => 'https://develop.opencast.org/', // The API url of the opencast instance (required) @@ -24,8 +25,9 @@ class OcRestClient extends Client 'password' => 'opencast', // The API password. (required) 'timeout' => 0, // The API timeout. In seconds (default 0 to wait indefinitely). (optional) 'connect_timeout' => 0, // The API connection timeout. In seconds (default 0 to wait indefinitely) (optional) - 'version' => null // The API Version. (Default null). (optional) - 'handler' => null // The callable Handler or HandlerStack. (Default null). (optional) + 'version' => null, // The API Version. (Default null). (optional) + 'handler' => null, // The callable Handler or HandlerStack. (Default null). (optional) + 'features' => null // A set of additional features [e.g. lucene search]. (Default null). (optional) ] */ public function __construct($config) @@ -51,9 +53,25 @@ public function __construct($config) if (isset($config['handler']) && is_callable($config['handler'])) { $parentConstructorConfig['handler'] = $config['handler']; } + + if (isset($config['features'])) { + $this->features = $config['features']; + } + parent::__construct($parentConstructorConfig); } + public function readFeatures($key = null) { + if (empty($key)) { + return $this->features; + } + + if (isset($this->features[$key])) { + return $this->features[$key]; + } + return false; + } + public function registerHeaderException($header, $path) { $path = ltrim($path, '/'); if (!isset($this->headerExceptions[$header]) || !in_array($path, $this->headerExceptions[$header])) { @@ -140,7 +158,14 @@ public function hasVersion($version) { if (empty($this->version)) { try { - $defaultVersion = $this->performGet('/api/version/default'); + // We have to use an aux object, in order to prevent overwriting arguments of current object. + $aux = clone $this; + $aux->enableNoHeader(); + $options = []; + if (!empty($this->username) && !empty($this->password)) { + $options['auth'] = [$this->username, $this->password]; + } + $defaultVersion = $aux->performGet('/api/version/default', $options); if (!empty($defaultVersion['body']) && isset($defaultVersion['body']->default)) { $this->setVersion(str_replace(['application/', 'v', '+json'], ['', '', ''], $defaultVersion['body']->default)); } else { diff --git a/vendor/elan-ev/opencast-api/src/OpencastApi/Rest/OcSearch.php b/vendor/elan-ev/opencast-api/src/OpencastApi/Rest/OcSearch.php index 8ac996b..57644e4 100644 --- a/vendor/elan-ev/opencast-api/src/OpencastApi/Rest/OcSearch.php +++ b/vendor/elan-ev/opencast-api/src/OpencastApi/Rest/OcSearch.php @@ -1,21 +1,25 @@ -registerHeaderException('Accept', self::URI); parent::__construct($restClient); + if ($restClient->readFeatures('lucene')) { + $this->lucene = true; + } } - + /** * Search for episodes matching the query parameters as object (JSON) by default or XML (text) on demand. - * - * @param array $params the params to pass to the call: it must cointain the following: + * + * @param array $params the params to pass to the call: it must cointain the following: * $params = [ * 'id' => '{The ID of the single episode to be returned, if it exists}', * 'q' => '{Any episode that matches this free-text query.}', @@ -28,7 +32,7 @@ public function __construct($restClient) * 'sign' => '{If results are to be signed (Default value=true)}', * ] * @param string $format The output format (json or xml) of the response body. (Default value = 'json') - * + * * @return array the response result ['code' => 200, 'body' => '{The search results, formatted as xml or json}'] */ public function getEpisodes($params = [], $format = '') @@ -64,30 +68,58 @@ public function getEpisodes($params = [], $format = '') $query['sign'] = $params['sign']; } - $sortsASC = [ - 'DATE_CREATED', 'DATE_MODIFIED', 'TITLE', 'SERIES_ID', - 'MEDIA_PACKAGE_ID', 'CREATOR', 'CONTRIBUTOR', 'LANGUAGE', - 'LICENSE','SUBJECT','DESCRIPTION','PUBLISHER', - ]; - $sortsDESC = array_map(function ($sort) { - return "{$sort}_DESC"; - }, $sortsASC); - $sorts = array_merge($sortsASC, $sortsDESC); - - if (array_key_exists('sort', $params) && !empty($params['sort']) && - in_array($params['sort'], $sorts)) { - $query['sort'] = $params['sort']; + // OC <= 15 + if ($this->lucene) { + $sortsASC = [ + 'DATE_CREATED', 'DATE_MODIFIED', 'TITLE', 'SERIES_ID', + 'MEDIA_PACKAGE_ID', 'CREATOR', 'CONTRIBUTOR', 'LANGUAGE', + 'LICENSE','SUBJECT','DESCRIPTION','PUBLISHER', + ]; + $sortsDESC = array_map(function ($sort) { + return "{$sort}_DESC"; + }, $sortsASC); + + $sorts = array_merge($sortsASC, $sortsDESC); + + if (array_key_exists('sort', $params) && !empty($params['sort']) && + in_array($params['sort'], $sorts)) { + $query['sort'] = $params['sort']; + } + + // OC >= 16 + } else { + $sorts = [ + 'modified', 'title', 'creator', 'contributor' + ]; + + $sortsASC = array_map(function ($sort) { + return "{$sort} asc"; + }, $sorts); + + $sortsDESC = array_map(function ($sort) { + return "{$sort} desc"; + }, $sorts); + + $sorts_list = array_merge($sorts, $sortsASC, $sortsDESC); + + if (array_key_exists('sort', $params) && !empty($params['sort']) && + in_array(strtolower($params['sort']), $sorts_list)) { + $query['sort'] = strtolower($params['sort']); + } } - + $options = $this->restClient->getQueryParams($query); return $this->restClient->performGet($uri, $options); } + /** * Search a lucene query as object (JSON) by default or XML (text) on demand. - * - * @param array $params the params to pass to the call: it must cointain the following: + * + * INFO: This endpoint is removed in Opencast 16. + * + * @param array $params the params to pass to the call: it must cointain the following: * $params = [ * 'q' => '{ The lucene query. }', * 'series' => '{ Include series in the search result. (Default value=false)}', @@ -98,11 +130,15 @@ public function getEpisodes($params = [], $format = '') * 'sign' => '{If results are to be signed (Default value=true)}', * ] * @param string $format The output format (json or xml) of the response body. (Default value = 'json') - * + * * @return array the response result ['code' => 200, 'body' => '{The search results, formatted as xml or json}'] */ public function getLucene($params = [], $format = '') { + if (!$this->lucene) { + return ['code' => 410, 'reason' => 'Lucene search endpoint is not available!']; + } + $uri = self::URI . "/lucene.json"; if (!empty($format) && strtolower($format) == 'xml') { $uri = str_replace('json', 'xml', $uri); @@ -138,20 +174,20 @@ public function getLucene($params = [], $format = '') }, $sortsASC); $sorts = array_merge($sortsASC, $sortsDESC); - + if (array_key_exists('sort', $params) && !empty($params['sort']) && in_array($params['sort'], $sorts)) { $query['sort'] = $params['sort']; } - + $options = $this->restClient->getQueryParams($query); return $this->restClient->performGet($uri, $options); } /** * Search for series matching the query parameters and returns JSON (object) by default or XML (text) on demand - * - * @param array $params the params to pass to the call: it must cointain the following: + * + * @param array $params the params to pass to the call: it must cointain the following: * $params = [ * 'id' = '{The series ID. If the additional boolean parameter "episodes" is "true", the result set will include this series episodes.}' * 'q' => '{Any series that matches this free-text query. If the additional boolean parameter "episodes" is "true", the result set will include this series episodes.}', @@ -163,7 +199,7 @@ public function getLucene($params = [], $format = '') * 'sign' => '{If results are to be signed (Default value=true)}', * ] * @param string $format The output format (json or xml) of the response body. (Default value = 'json') - * + * * @return array the response result ['code' => 200, 'body' => '{The search results, formatted as xml or json}'] */ public function getSeries($params = [], $format = '') @@ -196,24 +232,48 @@ public function getSeries($params = [], $format = '') $query['sign'] = $params['sign']; } - $sortsASC = [ - 'DATE_CREATED', 'DATE_MODIFIED', 'TITLE', 'SERIES_ID', - 'MEDIA_PACKAGE_ID', 'CREATOR', 'CONTRIBUTOR', 'LANGUAGE', - 'LICENSE','SUBJECT','DESCRIPTION','PUBLISHER', - ]; - $sortsDESC = array_map(function ($sort) { - return "{$sort}_DESC"; - }, $sortsASC); + // OC <= 15 + if ($this->lucene) { + $sortsASC = [ + 'DATE_CREATED', 'DATE_MODIFIED', 'TITLE', 'SERIES_ID', + 'MEDIA_PACKAGE_ID', 'CREATOR', 'CONTRIBUTOR', 'LANGUAGE', + 'LICENSE','SUBJECT','DESCRIPTION','PUBLISHER', + ]; + $sortsDESC = array_map(function ($sort) { + return "{$sort}_DESC"; + }, $sortsASC); - $sorts = array_merge($sortsASC, $sortsDESC); - - if (array_key_exists('sort', $params) && !empty($params['sort']) && - in_array($params['sort'], $sorts)) { - $query['sort'] = $params['sort']; + $sorts = array_merge($sortsASC, $sortsDESC); + + if (array_key_exists('sort', $params) && !empty($params['sort']) && + in_array($params['sort'], $sorts)) { + $query['sort'] = $params['sort']; + } + + // OC >= 16 + } else { + $sorts = [ + 'modified', 'title', 'creator', 'contributor' + ]; + + $sortsASC = array_map(function ($sort) { + return "{$sort} asc"; + }, $sorts); + + $sortsDESC = array_map(function ($sort) { + return "{$sort} desc"; + }, $sorts); + + $sorts_list = array_merge($sorts, $sortsASC, $sortsDESC); + + if (array_key_exists('sort', $params) && !empty($params['sort']) && + in_array(strtolower($params['sort']), $sorts_list)) { + $query['sort'] = strtolower($params['sort']); + } } - + $options = $this->restClient->getQueryParams($query); return $this->restClient->performGet($uri, $options); } } -?> \ No newline at end of file +?> diff --git a/vendor/elan-ev/opencast-api/tests/DataProvider/PlaylistsDataProvider.php b/vendor/elan-ev/opencast-api/tests/DataProvider/PlaylistsDataProvider.php new file mode 100644 index 0000000..ea4884a --- /dev/null +++ b/vendor/elan-ev/opencast-api/tests/DataProvider/PlaylistsDataProvider.php @@ -0,0 +1,26 @@ + 'updated:DESC']], + [['limit' => 2]], + [['offset' => 1]], + ]; + } + + public static function getPlaylist() + { + return '{"title":"Opencast Playlist","description":"PHP UNIT TEST_' . strtotime('now') . '_{update_replace}","creator":"Opencast","entries":[{"contentId":"ID-about-opencast","type":"EVENT"}],"accessControlEntries":[{"allow":true,"role":"ROLE_USER_BOB","action":"read"}]}'; + } + + public static function getEntries() + { + return json_decode('[{"contentId":"ID-about-opencast","type":"EVENT"},{"contentId":"ID-3d-print","type":"EVENT"}]'); + } +} +?> diff --git a/vendor/elan-ev/opencast-api/tests/DataProvider/SearchDataProvider.php b/vendor/elan-ev/opencast-api/tests/DataProvider/SearchDataProvider.php index f894b9d..77f9ea3 100644 --- a/vendor/elan-ev/opencast-api/tests/DataProvider/SearchDataProvider.php +++ b/vendor/elan-ev/opencast-api/tests/DataProvider/SearchDataProvider.php @@ -1,18 +1,16 @@ - 'fe0b45b0-7ed5-4944-8b0a-a0a283331791'], ''], [['sid' => '8010876e-1dce-4d38-ab8d-24b956e3d8b7'], ''], [['sname' => 'HUB_LOCAL_TEST'], ''], - [['sort' => 'DATE_CREATED_DESC'], ''], + [['sort' => 'modified asc'], ''], [['offset' => 1], ''], [['limit' => 1], ''], [['admin' => true], ''], @@ -39,11 +37,9 @@ public static function getSeriesQueryCases(): array { return [ [[], 'json'], - [[], 'xml'], - [[], 'XML'], [['id' => '8010876e-1dce-4d38-ab8d-24b956e3d8b7'], ''], [['episodes' => true], ''], - [['sort' => 'DATE_CREATED_DESC'], ''], + [['sort' => 'modified desc'], ''], [['offset' => 1], ''], [['limit' => 1], ''], [['admin' => true], ''], diff --git a/vendor/elan-ev/opencast-api/tests/DataProvider/SetupDataProvider.php b/vendor/elan-ev/opencast-api/tests/DataProvider/SetupDataProvider.php index 80feb3c..8ff6534 100644 --- a/vendor/elan-ev/opencast-api/tests/DataProvider/SetupDataProvider.php +++ b/vendor/elan-ev/opencast-api/tests/DataProvider/SetupDataProvider.php @@ -15,8 +15,11 @@ public static function getConfig($version = ''): array 'username' => $username, 'password' => $password, 'timeout' => $timeout, - 'version' => '1.9.0', - 'connect_timeout' => $connectTimeout + 'version' => '1.11.0', + 'connect_timeout' => $connectTimeout, + 'features' => [ + 'lucene' => false + ] ]; if (!empty($version)) { $config['version'] = $version; @@ -24,15 +27,23 @@ public static function getConfig($version = ''): array return $config; } - public static function getMockResponses($fileName): array + public static function getMockResponses($data): array { + $responseNames = []; + if (!is_array($data)) { + $responseNames[] = $data; + } else { + $responseNames = $data; + } $mockResponse = []; $mockResponsesDir = __DIR__ . "/mock_responses"; - $fileFullName = basename($fileName, ".json") . '.json'; - $filePath = $mockResponsesDir . "/" . $fileFullName; - if (file_exists($filePath)) { - $responseStr = file_get_contents($filePath); - $mockResponse = json_decode($responseStr, true); + foreach ($responseNames as $fileName) { + $fileFullName = basename($fileName, ".json") . '.json'; + $filePath = $mockResponsesDir . "/" . $fileFullName; + if (file_exists($filePath)) { + $responseStr = file_get_contents($filePath); + $mockResponse = array_merge($mockResponse, json_decode($responseStr, true)); + } } return $mockResponse !== false ? $mockResponse : []; } diff --git a/vendor/elan-ev/opencast-api/tests/DataProvider/mock_responses/api_playlists.json b/vendor/elan-ev/opencast-api/tests/DataProvider/mock_responses/api_playlists.json new file mode 100644 index 0000000..9a203fd --- /dev/null +++ b/vendor/elan-ev/opencast-api/tests/DataProvider/mock_responses/api_playlists.json @@ -0,0 +1,59 @@ +{ + "/api/playlists": { + "GET": [ + { + "body": "[{\"entries\":[{\"contentId\":\"ID-about-opencast\",\"id\":\"ID-entry-opencast\",\"type\":\"EVENT\"},{\"contentId\":\"ID-3d-print\",\"id\":\"ID-entry-print\",\"type\":\"EVENT\"}],\"creator\":\"Opencast\",\"description\":\"This is a playlist about Opencast\",\"id\":\"ID-opencast-playlist\",\"title\":\"Opencast Playlist\",\"updated\":\"2024-02-14T08:56:40Z\",\"accessControlEntries\":[{\"allow\":true,\"role\":\"ROLE_USER_BOB\",\"action\":\"read\"}]},{\"entries\":[{\"contentId\":\"ID-about-opencast\",\"id\":\"ID-about-opencast\",\"type\":\"EVENT\"}],\"creator\":\"Opencast\",\"description\":\"This is a playlist about Opencast\",\"id\":\"ID-another-opencast-playlist\",\"title\":\"Another Opencast Playlist\",\"updated\":\"2024-03-05T15:10:55Z\",\"accessControlEntries\":[{\"allow\":true,\"role\":\"ROLE_USER_BOB\",\"action\":\"read\"}]}]", + "params": "", + "status": 200 + } + ], + "POST": [ + { + "body": "{\"entries\":[{\"contentId\":\"ID-about-opencast\",\"id\":\"ID-entry-opencast\",\"type\":\"EVENT\"}],\"creator\":\"Opencast\",\"description\":\"This is a playlist about Opencast\",\"id\":\"ID-opencast-playlist\",\"title\":\"Opencast Playlist\",\"updated\":\"2024-03-05T15:10:55Z\",\"accessControlEntries\":[{\"allow\":true,\"role\":\"ROLE_USER_BOB\",\"action\":\"read\"}]}", + "params": "", + "status": 201 + } + ] + }, + "/api/playlists/ID-opencast-playlist": { + "GET": [ + { + "body": "{\"entries\":[{\"contentId\":\"ID-about-opencast\",\"id\":\"ID-entry-opencast\",\"type\":\"EVENT\"}],\"creator\":\"Opencast\",\"description\":\"This is a playlist about Opencast\",\"id\":\"ID-opencast-playlist\",\"title\":\"Opencast Playlist\",\"updated\":\"2024-03-05T15:10:55Z\",\"accessControlEntries\":[{\"allow\":true,\"role\":\"ROLE_USER_BOB\",\"action\":\"read\"}]}", + "params": "", + "status": 200 + } + ], + "PUT": [ + { + "body": "{\"entries\":[{\"contentId\":\"ID-about-opencast\",\"id\":\"ID-entry-opencast\",\"type\":\"EVENT\"}],\"creator\":\"Opencast\",\"description\":\"This is a playlist about Opencast\",\"id\":\"ID-opencast-playlist\",\"title\":\"Opencast Playlist\",\"updated\":\"2024-03-05T15:10:55Z\",\"accessControlEntries\":[{\"allow\":true,\"role\":\"ROLE_USER_BOB\",\"action\":\"read\"}]}", + "params": "", + "status": 200 + } + ], + "DELETE": [ + { + "body": "{\"entries\":[{\"contentId\":\"ID-about-opencast\",\"id\":\"ID-entry-opencast\",\"type\":\"EVENT\"}],\"creator\":\"Opencast\",\"description\":\"This is a playlist about Opencast\",\"id\":\"ID-opencast-playlist\",\"title\":\"Opencast Playlist\",\"updated\":\"2024-03-05T15:10:55Z\",\"accessControlEntries\":[{\"allow\":true,\"role\":\"ROLE_USER_BOB\",\"action\":\"read\"}]}", + "params": "", + "status": 200 + } + ] + }, + "/api/playlists/ID-opencast-playlist/entries": { + "POST": [ + { + "body": "{\"entries\":[],\"creator\":\"Opencast\",\"description\":\"This is a playlist about Opencast\",\"id\":\"ID-opencast-playlist\",\"title\":\"Opencast Playlist\",\"updated\":\"2024-03-05T15:10:55Z\",\"accessControlEntries\":[{\"allow\":true,\"role\":\"ROLE_USER_BOB\",\"action\":\"read\"}]}", + "params": { + "unique_request_identifier": "playlistEntries=[]" + }, + "status": 200 + }, + { + "body": "{\"entries\":[{\"contentId\":\"ID-about-opencast\",\"id\":ID-entry-opencast,\"type\":\"EVENT\"}],\"creator\":\"Opencast\",\"description\":\"This is a playlist about Opencast\",\"id\":\"ID-opencast-playlist\",\"title\":\"Opencast Playlist\",\"updated\":\"2024-03-05T15:10:55Z\",\"accessControlEntries\":[{\"allow\":true,\"role\":\"ROLE_USER_BOB\",\"action\":\"read\"}]}", + "params": { + "unique_request_identifier": "\"type\":\"EVENT\"" + }, + "status": 200 + } + ] + } +} \ No newline at end of file diff --git a/vendor/elan-ev/opencast-api/tests/Unit/OcIngestTest.php b/vendor/elan-ev/opencast-api/tests/Unit/OcIngestTest.php index e02a9e8..7daa48a 100644 --- a/vendor/elan-ev/opencast-api/tests/Unit/OcIngestTest.php +++ b/vendor/elan-ev/opencast-api/tests/Unit/OcIngestTest.php @@ -206,7 +206,11 @@ public function add_attachment_all(array $ingestData): array public function ingest(array $ingestData): void { $workflowDefinitionId = 'schedule-and-upload'; - $responseIngest = $this->ocIngest->ingest($ingestData['mediaPackage'], $workflowDefinitionId); + // Add workflow configuration params. + $workflowConfiguration = [ + 'straightToPublishing' => false + ]; + $responseIngest = $this->ocIngest->ingest($ingestData['mediaPackage'], $workflowDefinitionId, '', $workflowConfiguration); $this->assertSame(200, $responseIngest['code'], 'Failure to ingest'); $mediaPackage = $responseIngest['body']; $this->assertNotEmpty($mediaPackage); diff --git a/vendor/elan-ev/opencast-api/tests/Unit/OcPlaylistsApiTest.php b/vendor/elan-ev/opencast-api/tests/Unit/OcPlaylistsApiTest.php new file mode 100644 index 0000000..2838d66 --- /dev/null +++ b/vendor/elan-ev/opencast-api/tests/Unit/OcPlaylistsApiTest.php @@ -0,0 +1,139 @@ +baseApi->getVersion(); + if ($response['code'] != 200 || !in_array('v1.11.0', $response['body']->versions)) { + $this->markTestSkipped('Playlists api is not available in configured Opencast and is supported since api version 1.11.0.'); + } + + // Setup playlists api + $config = \Tests\DataProvider\SetupDataProvider::getConfig('1.11.0'); + $ocRestApi = new Opencast($config, [], false); + $this->ocPlaylistsApi = $ocRestApi->playlistsApi; + } + + /** + * @test + * @dataProvider \Tests\DataProvider\PlaylistsDataProvider::getAllCases() + */ + public function get_all_playlists($params): void + { + $response = $this->ocPlaylistsApi->getAll($params); + $this->assertSame(200, $response['code'], 'Failure to get playlists list'); + } + + /** + * @test + */ + public function empty_created_id(): string + { + $createdSeriesIdentifier = ''; + $this->assertEmpty($createdSeriesIdentifier); + + return $createdSeriesIdentifier; + } + + /** + * @test + * @depends empty_created_id + */ + public function create_get_playlist(string $identifier): string + { + // Create Playlist. + $response1 = $this->ocPlaylistsApi->create( + \Tests\DataProvider\PlaylistsDataProvider::getPlaylist() + ); + //error_log(json_encode($response1)); + $this->assertSame(201, $response1['code'], 'Failure to create a playlist'); + $playlist = $response1['body']; + $this->assertNotEmpty($playlist); + + $identifier = $playlist->id; + + // Get the playlist. + $response2 = $this->ocPlaylistsApi->get($identifier); + $this->assertSame(200, $response2['code'], 'Failure to get a playlist'); + $playlist = $response2['body']; + $this->assertNotEmpty($playlist); + + $this->assertNotEmpty($identifier); + return $identifier; + } + + /** + * @test + * @depends create_get_playlist + */ + public function get_update_playlist(string $identifier): string + { + // Get playlist. + $response1 = $this->ocPlaylistsApi->get($identifier); + $this->assertSame(200, $response1['code'], 'Failure to get playlist'); + $playlist = $response1['body']; + $this->assertNotEmpty($playlist); + + // Update playlist. + $playlist = str_replace( + '{update_replace}', + 'UPDATED ON: ' . strtotime('now'), + \Tests\DataProvider\PlaylistsDataProvider::getPlaylist() + ); + $response3 = $this->ocPlaylistsApi->update($identifier, $playlist); + $this->assertSame(200, $response3['code'], 'Failure to update playlist'); + $playlist = $response3['body']; + $this->assertNotEmpty($playlist); + + $this->assertNotEmpty($identifier); + return $identifier; + } + + /** + * @test + * @depends get_update_playlist + */ + public function update_delete_entries(string $identifier): string + { + // Delete all entries. + $response1 = $this->ocPlaylistsApi->emptyEntries($identifier); + $this->assertSame(200, $response1['code'], 'Failure to delete entries of a playlist'); + $playlist = $response1['body']; + $this->assertNotEmpty($playlist); + + // Prepare to update entries. + $entries = \Tests\DataProvider\PlaylistsDataProvider::getEntries(); + $response2 = $this->ocPlaylistsApi->updateEntries($identifier, $entries); + $this->assertSame(200, $response2['code'], 'Failure to update entries of a playlist'); + $playlist = $response2['body']; + $this->assertNotEmpty($playlist); + + $this->assertNotEmpty($identifier); + return $identifier; + } + + /** + * @test + * @depends update_delete_entries + */ + public function delete_playlist(string $identifier): void + { + $response = $this->ocPlaylistsApi->delete($identifier); + $this->assertSame(200, $response['code'], 'Failure to delete a playlist'); + $playlist = $response['body']; + $this->assertNotEmpty($playlist); + } +} +?> diff --git a/vendor/elan-ev/opencast-api/tests/Unit/OcSearchTest.php b/vendor/elan-ev/opencast-api/tests/Unit/OcSearchTest.php index db87859..0529aad 100644 --- a/vendor/elan-ev/opencast-api/tests/Unit/OcSearchTest.php +++ b/vendor/elan-ev/opencast-api/tests/Unit/OcSearchTest.php @@ -28,22 +28,22 @@ public function get_eposides($params, $format): void /** * @test - * @dataProvider \Tests\DataProvider\SearchDataProvider::getLuceneQueryCases() + * @dataProvider \Tests\DataProvider\SearchDataProvider::getSeriesQueryCases() */ - public function get_lucenes($params, $format): void + public function get_series($params, $format): void { - $response = $this->ocSearch->getLucene($params, $format); - $this->assertSame(200, $response['code'], 'Failure to search lucene'); + $response = $this->ocSearch->getSeries($params, $format); + $this->assertSame(200, $response['code'], 'Failure to search series'); } /** * @test - * @dataProvider \Tests\DataProvider\SearchDataProvider::getSeriesQueryCases() + * @dataProvider \Tests\DataProvider\SearchDataProvider::getLuceneQueryCases() */ - public function get_series($params, $format): void + public function get_lucenes($params, $format): void { - $response = $this->ocSearch->getSeries($params, $format); - $this->assertSame(200, $response['code'], 'Failure to search series'); + $response = $this->ocSearch->getLucene($params, $format); + $this->assertContains($response['code'], [200, 410], 'Failure to create an event'); } } ?> diff --git a/vendor/elan-ev/opencast-api/tests/UnitMock/OcEventsApiTestMock.php b/vendor/elan-ev/opencast-api/tests/UnitMock/OcEventsApiTestMock.php index 3013421..071c96c 100644 --- a/vendor/elan-ev/opencast-api/tests/UnitMock/OcEventsApiTestMock.php +++ b/vendor/elan-ev/opencast-api/tests/UnitMock/OcEventsApiTestMock.php @@ -12,7 +12,7 @@ class OcEventsApiTestMock extends TestCase protected function setUp(): void { parent::setUp(); - $mockResponse = \Tests\DataProvider\SetupDataProvider::getMockResponses('api_events'); + $mockResponse = \Tests\DataProvider\SetupDataProvider::getMockResponses(['api_events', 'api_base']); if (empty($mockResponse)) { $this->markTestIncomplete('No mock responses for events api could be found!'); } diff --git a/vendor/elan-ev/opencast-api/tests/UnitMock/OcPlaylistsApiTestMock.php b/vendor/elan-ev/opencast-api/tests/UnitMock/OcPlaylistsApiTestMock.php new file mode 100644 index 0000000..1744a34 --- /dev/null +++ b/vendor/elan-ev/opencast-api/tests/UnitMock/OcPlaylistsApiTestMock.php @@ -0,0 +1,134 @@ +markTestIncomplete('No mock responses for playlists api could be found!'); + } + $mockHandler = OcMockHanlder::getHandlerStackWithPath($mockResponse); + $config = \Tests\DataProvider\SetupDataProvider::getConfig(); + $config['handler'] = $mockHandler; + $ocRestApi = new Opencast($config, [], false); + $this->ocPlaylistsApi = $ocRestApi->playlistsApi; + } + + /** + * @test + */ + public function get_all_playlists(): void + { + $response = $this->ocPlaylistsApi->getAll(); + $this->assertSame(200, $response['code'], 'Failure to get playlists list'); + } + + /** + * @test + */ + public function empty_created_id(): string + { + $createdSeriesIdentifier = ''; + $this->assertEmpty($createdSeriesIdentifier); + + return $createdSeriesIdentifier; + } + + /** + * @test + * @depends empty_created_id + */ + public function create_get_playlist(string $identifier): string + { + // Create Playlist. + $response1 = $this->ocPlaylistsApi->create( + \Tests\DataProvider\PlaylistsDataProvider::getPlaylist() + ); + $this->assertSame(201, $response1['code'], 'Failure to create a playlist'); + $playlist = $response1['body']; + $this->assertNotEmpty($playlist); + + $identifier = $playlist->id; + + // Get the playlist. + $response2 = $this->ocPlaylistsApi->get($identifier); + $this->assertSame(200, $response2['code'], 'Failure to get a playlist'); + $playlist = $response2['body']; + $this->assertNotEmpty($playlist); + + $this->assertNotEmpty($identifier); + return $identifier; + } + + /** + * @test + * @depends create_get_playlist + */ + public function get_update_playlist(string $identifier): string + { + // Get playlist. + $response1 = $this->ocPlaylistsApi->get($identifier); + $this->assertSame(200, $response1['code'], 'Failure to get playlist'); + $playlist = $response1['body']; + $this->assertNotEmpty($playlist); + + // Update playlist. + $playlist = str_replace( + '{update_replace}', + 'UPDATED ON: ' . strtotime('now'), + \Tests\DataProvider\PlaylistsDataProvider::getPlaylist() + ); + $response3 = $this->ocPlaylistsApi->update($identifier, $playlist); + $this->assertSame(200, $response3['code'], 'Failure to update playlist'); + $playlist = $response3['body']; + $this->assertNotEmpty($playlist); + + $this->assertNotEmpty($identifier); + return $identifier; + } + + /** + * @test + * @depends get_update_playlist + */ + public function update_delete_entries(string $identifier): string + { + // Delete all entries. + $response1 = $this->ocPlaylistsApi->emptyEntries($identifier); + $this->assertSame(200, $response1['code'], 'Failure to delete entries of a playlist'); + $playlist = $response1['body']; + $this->assertNotEmpty($playlist); + + // Prepare to update entries. + $entries = \Tests\DataProvider\PlaylistsDataProvider::getEntries(); + $response2 = $this->ocPlaylistsApi->updateEntries($identifier, $entries); + $this->assertSame(200, $response2['code'], 'Failure to update entries of a playlist'); + $playlist = $response2['body']; + $this->assertNotEmpty($playlist); + + $this->assertNotEmpty($identifier); + return $identifier; + } + + /** + * @test + * @depends update_delete_entries + */ + public function delete_playlist(string $identifier): void + { + $response = $this->ocPlaylistsApi->delete($identifier); + $this->assertSame(200, $response['code'], 'Failure to delete a playlist'); + $playlist = $response['body']; + $this->assertNotEmpty($playlist); + } +} +?> diff --git a/vendor/elan-ev/opencast-api/tests/UnitMock/OcSearchTestMock.php b/vendor/elan-ev/opencast-api/tests/UnitMock/OcSearchTestMock.php index 0214f4f..f127f16 100644 --- a/vendor/elan-ev/opencast-api/tests/UnitMock/OcSearchTestMock.php +++ b/vendor/elan-ev/opencast-api/tests/UnitMock/OcSearchTestMock.php @@ -37,10 +37,10 @@ public function get_eposides(): void * @test */ public function get_lucenes(): void - { +{ $params = ['series' => true]; $response = $this->ocSearch->getLucene($params); - $this->assertSame(200, $response['code'], 'Failure to search lucene'); + $this->assertContains($response['code'], [200, 410], 'Failure to create an event'); } /** From 8d2483fc1002819e1ebee43499abad38eb0383b9 Mon Sep 17 00:00:00 2001 From: ferishili Date: Fri, 20 Sep 2024 14:29:33 +0200 Subject: [PATCH 2/6] add api version setting --- classes/local/api.php | 8 ++++++++ classes/local/api_testable.php | 6 +++++- classes/local/settings_api.php | 16 ++++++++++++++++ classes/settings/admin_settings_builder.php | 6 ++++++ lang/en/tool_opencast.php | 2 ++ 5 files changed, 37 insertions(+), 1 deletion(-) diff --git a/classes/local/api.php b/classes/local/api.php index ef3208e..1c8b01d 100644 --- a/classes/local/api.php +++ b/classes/local/api.php @@ -54,6 +54,8 @@ class api extends \curl { private $connecttimeout = 1000; /** @var string the api baseurl */ private $baseurl; + /** @var string the api version */ + public $version; /** @var \OpencastApi\Opencast the opencast endpoints instance */ public $opencastapi; /** @var \OpencastApi\Rest\OcRestClient the opencast REST Client instance */ @@ -227,6 +229,7 @@ public function __construct($instanceid = null, $this->timeout = settings_api::get_apitimeout($storedconfigocinstanceid); $this->connecttimeout = settings_api::get_apiconnecttimeout($storedconfigocinstanceid); $this->baseurl = settings_api::get_apiurl($storedconfigocinstanceid); + $this->version = settings_api::get_apiversion($storedconfigocinstanceid); if (empty($this->username)) { throw new empty_configuration_exception('apiusernameempty', 'tool_opencast'); @@ -256,6 +259,10 @@ public function __construct($instanceid = null, if (array_key_exists('apiconnecttimeout', $customconfigs)) { $this->connecttimeout = $customconfigs['apiconnecttimeout']; } + + if (array_key_exists('apiversion', $customconfigs)) { + $this->version = $customconfigs['version']; + } } // If the admin omitted the protocol part, add the HTTPS protocol on-the-fly. @@ -278,6 +285,7 @@ public function __construct($instanceid = null, 'password' => $this->password, 'timeout' => (intval($this->timeout) / 1000), 'connect_timeout' => (intval($this->connecttimeout) / 1000), + 'version' => !empty($this->version) ? $this->version : null, ]; $this->opencastapi = new \OpencastApi\Opencast($config, [], $enableingest); $this->opencastrestclient = new \OpencastApi\Rest\OcRestClient($config); diff --git a/classes/local/api_testable.php b/classes/local/api_testable.php index 56829e2..299c8bd 100644 --- a/classes/local/api_testable.php +++ b/classes/local/api_testable.php @@ -43,7 +43,7 @@ class api_testable extends api { private $httpcode; /** @var string version api version to apply for */ - public $version = '1.9.0'; + public $version; /** @var string the username. */ private string $username; @@ -85,6 +85,10 @@ public function __construct($instanceid = null, $enableingest = false) { $this->timeout = settings_api::get_apitimeout($storedconfigocinstanceid); $this->connecttimeout = settings_api::get_apiconnecttimeout($storedconfigocinstanceid); $this->baseurl = settings_api::get_apiurl($storedconfigocinstanceid); + $this->version = settings_api::get_apiversion($storedconfigocinstanceid); + if (empty($this->version)) { + $this->version = '1.10.0'; + } $config = [ 'url' => $this->baseurl, diff --git a/classes/local/settings_api.php b/classes/local/settings_api.php index 5b0ba39..7d3bfa0 100644 --- a/classes/local/settings_api.php +++ b/classes/local/settings_api.php @@ -72,6 +72,22 @@ public static function get_apiurl(int $ocinstanceid) { return get_config('tool_opencast', 'apiurl_' . $ocinstanceid); } + /** + * Returns the api version of an Opencast instance as string + * or false, if the corresponding config was not found. + * + * @param int $ocinstanceid + * The id of the Opencast instance, for that the config is retrieved. + * + * @return string|bool + * The requested config as string or false, if the corresponding config was not found. + * + * @throws \dml_exception + */ + public static function get_apiversion(int $ocinstanceid) { + return get_config('tool_opencast', 'apiversion_' . $ocinstanceid); + } + /** * Returns the api username of an Opencast instance as string * or false, if the corresponding config was not found. diff --git a/classes/settings/admin_settings_builder.php b/classes/settings/admin_settings_builder.php index a35f56e..9774ad5 100644 --- a/classes/settings/admin_settings_builder.php +++ b/classes/settings/admin_settings_builder.php @@ -301,6 +301,12 @@ private static function add_config_settings_fulltree(\admin_settingpage $setting PARAM_URL ); + self::add_admin_setting_configtext($settings, + 'tool_opencast/apiversion_' . $instanceid, + 'apiversion', 'apiversiondesc', + '' + ); + self::add_admin_setting_configtext($settings, 'tool_opencast/apiusername_' . $instanceid, 'apiusername', 'apiusernamedesc', diff --git a/lang/en/tool_opencast.php b/lang/en/tool_opencast.php index 720b14e..e69174a 100644 --- a/lang/en/tool_opencast.php +++ b/lang/en/tool_opencast.php @@ -36,6 +36,8 @@ $string['apiusername'] = 'Username of Opencast API user'; $string['apiusernamedesc'] = 'Configure the username of the Opencast user who is used to do the Opencast API calls. Moodle uses this Opencast user for all communication with Opencast. Authorization is done by adding suitable roles to the call.'; $string['apiusernameempty'] = 'Username of Opencast API user is not configured correctly. Go to the settings of the Opencast API tool to fix this.'; +$string['apiversion'] = 'Opencast API version'; +$string['apiversiondesc'] = 'This is the api version of the opencast instance (e.g. "v1.11.0") to be configured. This would increase the overall performance when configured, because it reduces the automated version extraction step.
Use this link format to get the api version from your opencast: [your opencast address]/docs.html?path=/api#getversiondefault-8'; $string['timeout'] = 'Overall API request execution timeout'; $string['timeoutdesc'] = 'Configure the time in milliseconds each API request to Opencast may take. If Opencast does not finish answering the request within this time, the request is aborted.'; $string['connecttimeout'] = 'Connection timeout'; From 7e8e78c55bf114b03ec49474851a9047bd4befbf Mon Sep 17 00:00:00 2001 From: ferishili Date: Fri, 20 Sep 2024 15:21:21 +0200 Subject: [PATCH 3/6] code checker mdl 4.4 --- classes/local/api.php | 2 +- classes/local/environment_util.php | 4 +- classes/local/settings_api.php | 10 ++-- classes/privacy/provider.php | 1 + classes/settings/admin_settings_builder.php | 28 ++++----- db/services.php | 2 + db/upgrade.php | 4 +- external.php | 2 +- lang/en/tool_opencast.php | 66 +++++++++------------ 9 files changed, 57 insertions(+), 62 deletions(-) diff --git a/classes/local/api.php b/classes/local/api.php index 1c8b01d..f045feb 100644 --- a/classes/local/api.php +++ b/classes/local/api.php @@ -167,7 +167,7 @@ public static function get_instance($instanceid = null, * @return bool * @throws \dml_exception */ - private static function use_test_api() : bool { + private static function use_test_api(): bool { if (defined('BEHAT_SITE_RUNNING') && BEHAT_SITE_RUNNING) { $defaultocinstance = settings_api::get_default_ocinstance(); if ($defaultocinstance === null) { diff --git a/classes/local/environment_util.php b/classes/local/environment_util.php index 4087e0d..ec878ad 100644 --- a/classes/local/environment_util.php +++ b/classes/local/environment_util.php @@ -38,7 +38,7 @@ private function __construct() { * @return bool Returns, true, if the current application is a CLI application, * and false otherwise. */ - public static function is_cli_application() : bool { + public static function is_cli_application(): bool { return http_response_code() === false; } @@ -49,7 +49,7 @@ public static function is_cli_application() : bool { * @return bool Returns, true, if the current application runs in the environment of a moodle-plugin-ci workflow, * and false otherwise. */ - public static function is_moodle_plugin_ci_workflow() : bool { + public static function is_moodle_plugin_ci_workflow(): bool { return !(getenv('is_moodle_plugin_ci_workflow') === false); } } diff --git a/classes/local/settings_api.php b/classes/local/settings_api.php index 7d3bfa0..032268b 100644 --- a/classes/local/settings_api.php +++ b/classes/local/settings_api.php @@ -194,7 +194,7 @@ public static function get_lticonsumersecret(int $ocinstanceid) { * @return opencast_instance|null * The corresponding Opencast instance or null. */ - public static function get_ocinstance(int $ocinstanceid) : ?opencast_instance { + public static function get_ocinstance(int $ocinstanceid): ?opencast_instance { $ocinstances = self::get_ocinstances(); foreach ($ocinstances as $ocinstance) { @@ -213,7 +213,7 @@ public static function get_ocinstance(int $ocinstanceid) : ?opencast_instance { * @return opencast_instance|null * The corresponding Opencast instance or null. */ - public static function get_default_ocinstance() : ?opencast_instance { + public static function get_default_ocinstance(): ?opencast_instance { $ocinstances = self::get_ocinstances(); foreach ($ocinstances as $ocinstance) { @@ -233,7 +233,7 @@ public static function get_default_ocinstance() : ?opencast_instance { * @return array * All configured Opencast instances as array. */ - public static function get_ocinstances() : array { + public static function get_ocinstances(): array { try { $ocinstancesconfig = get_config('tool_opencast', 'ocinstances'); } catch (\dml_exception $exception) { @@ -258,7 +258,7 @@ public static function get_ocinstances() : array { * @param \stdClass $dynamicocinstance * The Opencast instance, to that all configured Opencast instances are set to. */ - public static function set_ocinstances_to_ocinstance($dynamicocinstance) : void { + public static function set_ocinstances_to_ocinstance($dynamicocinstance): void { set_config('ocinstances', json_encode([$dynamicocinstance]), 'tool_opencast'); } @@ -268,7 +268,7 @@ public static function set_ocinstances_to_ocinstance($dynamicocinstance) : void * @return int * The number of configured Opencast instances. */ - public static function num_ocinstances() : int { + public static function num_ocinstances(): int { return count(self::get_ocinstances()); } } diff --git a/classes/privacy/provider.php b/classes/privacy/provider.php index 7377e75..28c2c00 100644 --- a/classes/privacy/provider.php +++ b/classes/privacy/provider.php @@ -13,6 +13,7 @@ // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . + /** * Privacy Subsystem implementation for tool opencast. * diff --git a/classes/settings/admin_settings_builder.php b/classes/settings/admin_settings_builder.php index 9774ad5..f1f53cd 100644 --- a/classes/settings/admin_settings_builder.php +++ b/classes/settings/admin_settings_builder.php @@ -51,7 +51,7 @@ private function __construct() { * * @return void */ - public static function create_settings() : void { + public static function create_settings(): void { $instances = settings_api::get_ocinstances(); global $ADMIN; @@ -71,7 +71,7 @@ public static function create_settings() : void { * * @return void */ - private static function create_settings_no_fulltree($instances) : void { + private static function create_settings_no_fulltree($instances): void { self::add_admin_category(); self::add_admin_settingpage('tool_opencast_instances', 'ocinstances'); @@ -94,7 +94,7 @@ private static function create_settings_no_fulltree($instances) : void { * * @return void */ - private static function create_settings_fulltree($instances) : void { + private static function create_settings_fulltree($instances): void { self::add_admin_category(); self::add_admin_instances_config(); @@ -122,7 +122,7 @@ private static function create_settings_fulltree($instances) : void { * * @return void */ - private static function add_admin_category() : void { + private static function add_admin_category(): void { $category = new \admin_category(self::PLUGINNAME, new \lang_string('pluginname', self::PLUGINNAME) ); @@ -147,7 +147,7 @@ private static function add_admin_category() : void { * @return void */ private static function add_admin_settingpage(string $name, string $stringidentifier, - $stringidentifierarguments = null) : void { + $stringidentifierarguments = null): void { $settingpage = self::create_admin_settingpage($name, $stringidentifier, $stringidentifierarguments); self::include_admin_settingpage($settingpage); } @@ -169,7 +169,7 @@ private static function add_admin_settingpage(string $name, string $stringidenti * The created admin settingpage. */ private static function create_admin_settingpage(string $name, string $stringidentifier, - $stringidentifierarguments = null) : \admin_settingpage { + $stringidentifierarguments = null): \admin_settingpage { return new \admin_settingpage($name, new \lang_string($stringidentifier, self::PLUGINNAME, $stringidentifierarguments) ); @@ -183,7 +183,7 @@ private static function create_admin_settingpage(string $name, string $stringide * * @return void */ - private static function include_admin_settingpage(\admin_settingpage $settingpage) : void { + private static function include_admin_settingpage(\admin_settingpage $settingpage): void { global $ADMIN; $ADMIN->add(self::PLUGINNAME, $settingpage); } @@ -199,7 +199,7 @@ private static function include_admin_settingpage(\admin_settingpage $settingpag * * @return void */ - private static function add_admin_instances_config() : void { + private static function add_admin_instances_config(): void { $instancesconfig = new admin_setting_configtextwithvalidation( 'tool_opencast/ocinstances', get_string('ocinstances', self::PLUGINNAME), @@ -233,7 +233,7 @@ private static function add_admin_instances_config() : void { * * @return void */ - private static function require_amds(string $pluginnameid) : void { + private static function require_amds(string $pluginnameid): void { global $PAGE; // Crashes, if plugins.php is opened, because css cannot be included anymore. @@ -261,7 +261,7 @@ private static function require_amds(string $pluginnameid) : void { * @return void */ private static function add_notification_banner_for_demo_instance(\admin_settingpage $settings, - int $instanceid) : void { + int $instanceid): void { $instanceapiurl = settings_api::get_apiurl($instanceid); // Show a notification banner, if the plugin is connected to the Opencast demo server. @@ -293,7 +293,7 @@ private static function add_notification_banner_for_demo_instance(\admin_setting * @return void */ private static function add_config_settings_fulltree(\admin_settingpage $settings, - int $instanceid) : void { + int $instanceid): void { self::add_admin_setting_configtext($settings, 'tool_opencast/apiurl_' . $instanceid, 'apiurl', 'apiurldesc', @@ -374,7 +374,7 @@ private static function add_admin_setting_configtext(\admin_settingpage $setting string $visiblenameidentifier, string $descriptionidentifier, string $defaultsetting, - $paramtype = PARAM_RAW) : void { + $paramtype = PARAM_RAW): void { $settingconfigtext = new \admin_setting_configtext( $name, get_string($visiblenameidentifier, self::PLUGINNAME), @@ -409,7 +409,7 @@ private static function add_admin_setting_configpasswordunmask(\admin_settingpag string $name, string $visiblenameidentifier, string $descriptionidentifier, - string $defaultsetting) : void { + string $defaultsetting): void { $settingconfigpasswordunmask = new \admin_setting_configpasswordunmask( $name, get_string($visiblenameidentifier, self::PLUGINNAME), @@ -436,7 +436,7 @@ private static function add_admin_setting_configpasswordunmask(\admin_settingpag * @return void */ private static function add_connection_test_tool(\admin_settingpage $settings, - int $instanceid) : void { + int $instanceid): void { // Provide Connection Test Tool button. $attributes = [ 'class' => 'btn btn-warning disabled testtool-modal', diff --git a/db/services.php b/db/services.php index 42d8c0a..b18c864 100644 --- a/db/services.php +++ b/db/services.php @@ -13,6 +13,7 @@ // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . + /** * Services for the Opencast API. * @@ -20,6 +21,7 @@ * @copyright 2018 Tobias Reischmann * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ + defined('MOODLE_INTERNAL') || die(); $functions = [ diff --git a/db/upgrade.php b/db/upgrade.php index 6ce2c01..12f9781 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -167,7 +167,7 @@ function xmldb_tool_opencast_upgrade($oldversion) { * @return bool * Returns true, if this update of the database was successful, and false otherwise. */ -function remove_default_opencast_instance_settings_without_id() : bool { +function remove_default_opencast_instance_settings_without_id(): bool { $helpersettingsname = 'apiurl'; $pluginname = 'tool_opencast'; @@ -214,7 +214,7 @@ function remove_default_opencast_instance_settings_without_id() : bool { * @throws \dml_exception */ function replace_default_opencast_instance_setting_without_id(int $defaultinstanceid, - string $name) : void { + string $name): void { $pluginname = 'tool_opencast'; $value = get_config($pluginname, $name); diff --git a/external.php b/external.php index 1a9e64b..ddb699a 100644 --- a/external.php +++ b/external.php @@ -253,7 +253,7 @@ public static function connection_test_tool_parameters() { */ private static function connection_test_tool_build_html_alert_tag($connectiontestresult, string $testsuccessfulstringidentifier, - string $testfailedstringidentifier) : string { + string $testfailedstringidentifier): string { // Check, if the test was successful. if ($connectiontestresult === true) { return html_writer::tag( diff --git a/lang/en/tool_opencast.php b/lang/en/tool_opencast.php index e69174a..13ccc75 100644 --- a/lang/en/tool_opencast.php +++ b/lang/en/tool_opencast.php @@ -25,11 +25,14 @@ defined('MOODLE_INTERNAL') || die(); -$string['pluginname'] = 'Opencast API'; - +$string['addinstance'] = 'Add instance'; +$string['apicreadentialstestsuccessfulshort'] = 'Opencast API User Credentials test successful.'; +$string['apicreadentialstestfailedshort'] = 'Opencast API User Credentials test failed with http code: {$a}'; $string['apipassword'] = 'Password of Opencast API user'; $string['apipassworddesc'] = 'Configure the password of the Opencast user who is used to do the Opencast API calls.'; $string['apipasswordempty'] = 'Password of Opencast API user is not configured correctly. Go to the settings of the Opencast API tool to fix this.'; +$string['apiurltestsuccessfulshort'] = 'Opencast API URL test successful.'; +$string['apiurltestfailedshort'] = 'Opencast API URL test failed with http code: {$a}'; $string['apiurl'] = 'Opencast API URL'; $string['apiurldesc'] = 'Configure the base URL of the Opencast system. A valid URL is required here. If you omit the protocol part here, \'https://\' is added on-the-fly when doing Opencast API calls.'; $string['apiurlempty'] = 'URL of Opencast API is not configured correctly. Go to the settings of the Opencast API tool to fix this.'; @@ -38,53 +41,42 @@ $string['apiusernameempty'] = 'Username of Opencast API user is not configured correctly. Go to the settings of the Opencast API tool to fix this.'; $string['apiversion'] = 'Opencast API version'; $string['apiversiondesc'] = 'This is the api version of the opencast instance (e.g. "v1.11.0") to be configured. This would increase the overall performance when configured, because it reduces the automated version extraction step.
Use this link format to get the api version from your opencast: [your opencast address]/docs.html?path=/api#getversiondefault-8'; -$string['timeout'] = 'Overall API request execution timeout'; -$string['timeoutdesc'] = 'Configure the time in milliseconds each API request to Opencast may take. If Opencast does not finish answering the request within this time, the request is aborted.'; -$string['connecttimeout'] = 'Connection timeout'; -$string['connecttimeoutdesc'] = 'Configure the time in milliseconds while Moodle is trying to connect to Opencast. If Opencast does not answer within this time, the connection attempt times out.'; -$string['demoservernotification'] = 'The Opencast API tool is currently configured to connect to the public Opencast demo server. You can use this Opencast server for evaluating this plugin.
Do not use it for any production purposes. Please setup your own Opencast server instead.'; $string['apiurltestfailedlong'] = 'There is no Opencast instance running on the given URL.
Please use a valid URL in order to avoid fatal error during tasks which use this setting.'; $string['apiurltestsucceedbutnocredentialslong'] = 'The Opencast API URL is valid, but Username or Password are not yet provided.
Please enter valid Username and Password in order to avoid fatal error during tasks which use this setting.'; $string['apicreadentialstestfailedlong'] = 'The given Username or Password for the Opencast API is not valid.
Please use valid Username and Password in order to avoid fatal error during tasks which use this setting.'; -$string['testtoolheader'] = 'Connection test tool'; -$string['testtoolheaderdesc'] = 'To test the current Opencast API settings use: {$a}'; -$string['testtoolurl'] = 'Connection Test Tool'; -$string['apiurltestsuccessfulshort'] = 'Opencast API URL test successful.'; -$string['apiurltestfailedshort'] = 'Opencast API URL test failed with http code: {$a}'; -$string['apicreadentialstestsuccessfulshort'] = 'Opencast API User Credentials test successful.'; -$string['apicreadentialstestfailedshort'] = 'Opencast API User Credentials test failed with http code: {$a}'; -$string['testtooldisabledbuttontitle'] = 'Unable to conduct the connection test due to unloaded js modules.'; - -$string['lticonsumerkey'] = 'Consumer key'; -$string['lticonsumerkey_desc'] = 'LTI Consumer key for the integration of Opencast services that require authentication such as Studio or the editor.'; -$string['lticonsumersecret'] = 'Consumer secret'; -$string['lticonsumersecret_desc'] = 'LTI Consumer secret for the integration of Opencast services that require authentication.'; $string['configuration'] = 'Configuration'; $string['configuration_instance'] = 'Configuration: {$a}'; -$string['ocinstances'] = 'Opencast Instances'; -$string['ocinstancesdesc'] = 'Defines a list of Opencast Instances to which the Opencast plugins can connect.'; -$string['name'] = 'Name'; -$string['isvisible'] = 'Is visible to teachers'; -$string['isdefault'] = 'Default'; -$string['addinstance'] = 'Add instance'; +$string['connecttimeout'] = 'Connection timeout'; +$string['connecttimeoutdesc'] = 'Configure the time in milliseconds while Moodle is trying to connect to Opencast. If Opencast does not answer within this time, the connection attempt times out.'; $string['delete_instance'] = 'Delete instance'; $string['delete_instance_confirm'] = 'Do you really want to delete this instance?
Teachers will not be able to see videos used in this instance anymore.
Caution: All data related to this instance will be lost.

The deletion will be performed after you click on "Save changes" on the main settings page.'; +$string['demoservernotification'] = 'The Opencast API tool is currently configured to connect to the public Opencast demo server. You can use this Opencast server for evaluating this plugin.
Do not use it for any production purposes. Please setup your own Opencast server instead.'; $string['errornumdefaultinstances'] = 'There must be exactly one default Opencast instance.'; - +$string['isvisible'] = 'Is visible to teachers'; +$string['isdefault'] = 'Default'; +$string['lticonsumerkey'] = 'Consumer key'; +$string['lticonsumerkey_desc'] = 'LTI Consumer key for the integration of Opencast services that require authentication such as Studio or the editor.'; +$string['lticonsumersecret'] = 'Consumer secret'; +$string['lticonsumersecret_desc'] = 'LTI Consumer secret for the integration of Opencast services that require authentication.'; +$string['name'] = 'Name'; +$string['needphp55orhigher'] = 'PHP Version 5.5 or higher is needed'; +$string['nomockhandler'] = 'The Opencast Api Object is unable to handle the responses for testing purposes.'; +$string['notestingjsonresponses'] = 'The JSON responses are not set, please make sure to use api_testable::add_json_response before running and using the class.'; +$string['ocinstances'] = 'Opencast Instances'; +$string['ocinstancesdesc'] = 'Defines a list of Opencast Instances to which the Opencast plugins can connect.'; $string['opencast:externalapi'] = 'Access to Opencast API webservices'; $string['opencast:instructor'] = 'Gives the role of an instructor in Opencast'; $string['opencast:learner'] = 'Gives the role of a learner in Opencast'; - -$string['needphp55orhigher'] = 'PHP Version 5.5 or higher is needed'; -$string['wrongmimetypedetected'] = 'Wrong mimetype was detected, while trying to upload {$a->filename} from course {$a->coursename}. You can only upload video files!'; -$string['serverconnectionerror'] = 'There was a problem with the connection to the Opencast server. Please check your Opencast API credentials and your network settings.'; - -// Privacy API. +$string['pluginname'] = 'Opencast API'; $string['privacy:metadata'] = 'The Opencast API admin tool only provides API endpoints and general settings for the set of Opencast plugins. It stores which Opencast series belongs to which Moodle course, but it does not store any personal data.'; - -// Testing API. -$string['nomockhandler'] = 'The Opencast Api Object is unable to handle the responses for testing purposes.'; -$string['notestingjsonresponses'] = 'The JSON responses are not set, please make sure to use api_testable::add_json_response before running and using the class.'; +$string['serverconnectionerror'] = 'There was a problem with the connection to the Opencast server. Please check your Opencast API credentials and your network settings.'; +$string['testtooldisabledbuttontitle'] = 'Unable to conduct the connection test due to unloaded js modules.'; +$string['testtoolheader'] = 'Connection test tool'; +$string['testtoolheaderdesc'] = 'To test the current Opencast API settings use: {$a}'; +$string['testtoolurl'] = 'Connection Test Tool'; +$string['timeout'] = 'Overall API request execution timeout'; +$string['timeoutdesc'] = 'Configure the time in milliseconds each API request to Opencast may take. If Opencast does not finish answering the request within this time, the request is aborted.'; +$string['wrongmimetypedetected'] = 'Wrong mimetype was detected, while trying to upload {$a->filename} from course {$a->coursename}. You can only upload video files!'; From e95b60bcfa6e030ec09fa09d12b8fcf10faee08a Mon Sep 17 00:00:00 2001 From: ferishili Date: Fri, 20 Sep 2024 15:27:27 +0200 Subject: [PATCH 4/6] code checker lang sort part 2 --- classes/local/environment_util.php | 2 -- lang/en/tool_opencast.php | 12 ++++++------ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/classes/local/environment_util.php b/classes/local/environment_util.php index ec878ad..300f8ce 100644 --- a/classes/local/environment_util.php +++ b/classes/local/environment_util.php @@ -16,8 +16,6 @@ namespace tool_opencast\local; -defined('MOODLE_INTERNAL') || die; - /** * An environment util for the Opencast Moodle plugins. * diff --git a/lang/en/tool_opencast.php b/lang/en/tool_opencast.php index 13ccc75..7b03b93 100644 --- a/lang/en/tool_opencast.php +++ b/lang/en/tool_opencast.php @@ -26,24 +26,24 @@ defined('MOODLE_INTERNAL') || die(); $string['addinstance'] = 'Add instance'; -$string['apicreadentialstestsuccessfulshort'] = 'Opencast API User Credentials test successful.'; $string['apicreadentialstestfailedshort'] = 'Opencast API User Credentials test failed with http code: {$a}'; +$string['apicreadentialstestfailedlong'] = 'The given Username or Password for the Opencast API is not valid.
Please use valid Username and Password in order to avoid fatal error during tasks which use this setting.'; +$string['apicreadentialstestsuccessfulshort'] = 'Opencast API User Credentials test successful.'; $string['apipassword'] = 'Password of Opencast API user'; $string['apipassworddesc'] = 'Configure the password of the Opencast user who is used to do the Opencast API calls.'; $string['apipasswordempty'] = 'Password of Opencast API user is not configured correctly. Go to the settings of the Opencast API tool to fix this.'; -$string['apiurltestsuccessfulshort'] = 'Opencast API URL test successful.'; -$string['apiurltestfailedshort'] = 'Opencast API URL test failed with http code: {$a}'; $string['apiurl'] = 'Opencast API URL'; $string['apiurldesc'] = 'Configure the base URL of the Opencast system. A valid URL is required here. If you omit the protocol part here, \'https://\' is added on-the-fly when doing Opencast API calls.'; $string['apiurlempty'] = 'URL of Opencast API is not configured correctly. Go to the settings of the Opencast API tool to fix this.'; +$string['apiurltestfailedshort'] = 'Opencast API URL test failed with http code: {$a}'; +$string['apiurltestfailedlong'] = 'There is no Opencast instance running on the given URL.
Please use a valid URL in order to avoid fatal error during tasks which use this setting.'; +$string['apiurltestsucceedbutnocredentialslong'] = 'The Opencast API URL is valid, but Username or Password are not yet provided.
Please enter valid Username and Password in order to avoid fatal error during tasks which use this setting.'; +$string['apiurltestsuccessfulshort'] = 'Opencast API URL test successful.'; $string['apiusername'] = 'Username of Opencast API user'; $string['apiusernamedesc'] = 'Configure the username of the Opencast user who is used to do the Opencast API calls. Moodle uses this Opencast user for all communication with Opencast. Authorization is done by adding suitable roles to the call.'; $string['apiusernameempty'] = 'Username of Opencast API user is not configured correctly. Go to the settings of the Opencast API tool to fix this.'; $string['apiversion'] = 'Opencast API version'; $string['apiversiondesc'] = 'This is the api version of the opencast instance (e.g. "v1.11.0") to be configured. This would increase the overall performance when configured, because it reduces the automated version extraction step.
Use this link format to get the api version from your opencast: [your opencast address]/docs.html?path=/api#getversiondefault-8'; -$string['apiurltestfailedlong'] = 'There is no Opencast instance running on the given URL.
Please use a valid URL in order to avoid fatal error during tasks which use this setting.'; -$string['apiurltestsucceedbutnocredentialslong'] = 'The Opencast API URL is valid, but Username or Password are not yet provided.
Please enter valid Username and Password in order to avoid fatal error during tasks which use this setting.'; -$string['apicreadentialstestfailedlong'] = 'The given Username or Password for the Opencast API is not valid.
Please use valid Username and Password in order to avoid fatal error during tasks which use this setting.'; $string['configuration'] = 'Configuration'; $string['configuration_instance'] = 'Configuration: {$a}'; $string['connecttimeout'] = 'Connection timeout'; From d0c1e7913216748c67bbc5a869656eb571e68ad0 Mon Sep 17 00:00:00 2001 From: ferishili Date: Fri, 20 Sep 2024 16:59:09 +0200 Subject: [PATCH 5/6] remove platform checker for php < 8.1 --- composer.json | 3 +++ vendor/composer/autoload_real.php | 2 -- vendor/composer/platform_check.php | 26 -------------------------- 3 files changed, 3 insertions(+), 28 deletions(-) delete mode 100644 vendor/composer/platform_check.php diff --git a/composer.json b/composer.json index c0c6ed2..a616639 100644 --- a/composer.json +++ b/composer.json @@ -2,5 +2,8 @@ "name": "moodle/tool_opencast", "require": { "elan-ev/opencast-api": "1.8" + }, + "config": { + "platform-check": false } } diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index e9c2a4e..3bbb734 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -22,8 +22,6 @@ public static function getLoader() return self::$loader; } - require __DIR__ . '/platform_check.php'; - spl_autoload_register(array('ComposerAutoloaderInit8ba2ca4e105ea351f7cb241590a7de7e', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); spl_autoload_unregister(array('ComposerAutoloaderInit8ba2ca4e105ea351f7cb241590a7de7e', 'loadClassLoader')); diff --git a/vendor/composer/platform_check.php b/vendor/composer/platform_check.php deleted file mode 100644 index 4c3a5d6..0000000 --- a/vendor/composer/platform_check.php +++ /dev/null @@ -1,26 +0,0 @@ -= 80100)) { - $issues[] = 'Your Composer dependencies require a PHP version ">= 8.1.0". You are running ' . PHP_VERSION . '.'; -} - -if ($issues) { - if (!headers_sent()) { - header('HTTP/1.1 500 Internal Server Error'); - } - if (!ini_get('display_errors')) { - if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') { - fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL); - } elseif (!headers_sent()) { - echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL; - } - } - trigger_error( - 'Composer detected issues in your platform: ' . implode(' ', $issues), - E_USER_ERROR - ); -} From 92b380d3a1cda7c2c0d1033667a695a1084eddf5 Mon Sep 17 00:00:00 2001 From: ferishili Date: Mon, 21 Oct 2024 15:42:57 +0200 Subject: [PATCH 6/6] revert api version setting --- classes/local/api.php | 8 -------- classes/local/api_testable.php | 6 +----- classes/local/settings_api.php | 16 ---------------- classes/settings/admin_settings_builder.php | 6 ------ lang/en/tool_opencast.php | 2 -- 5 files changed, 1 insertion(+), 37 deletions(-) diff --git a/classes/local/api.php b/classes/local/api.php index f045feb..acf1e70 100644 --- a/classes/local/api.php +++ b/classes/local/api.php @@ -54,8 +54,6 @@ class api extends \curl { private $connecttimeout = 1000; /** @var string the api baseurl */ private $baseurl; - /** @var string the api version */ - public $version; /** @var \OpencastApi\Opencast the opencast endpoints instance */ public $opencastapi; /** @var \OpencastApi\Rest\OcRestClient the opencast REST Client instance */ @@ -229,7 +227,6 @@ public function __construct($instanceid = null, $this->timeout = settings_api::get_apitimeout($storedconfigocinstanceid); $this->connecttimeout = settings_api::get_apiconnecttimeout($storedconfigocinstanceid); $this->baseurl = settings_api::get_apiurl($storedconfigocinstanceid); - $this->version = settings_api::get_apiversion($storedconfigocinstanceid); if (empty($this->username)) { throw new empty_configuration_exception('apiusernameempty', 'tool_opencast'); @@ -259,10 +256,6 @@ public function __construct($instanceid = null, if (array_key_exists('apiconnecttimeout', $customconfigs)) { $this->connecttimeout = $customconfigs['apiconnecttimeout']; } - - if (array_key_exists('apiversion', $customconfigs)) { - $this->version = $customconfigs['version']; - } } // If the admin omitted the protocol part, add the HTTPS protocol on-the-fly. @@ -285,7 +278,6 @@ public function __construct($instanceid = null, 'password' => $this->password, 'timeout' => (intval($this->timeout) / 1000), 'connect_timeout' => (intval($this->connecttimeout) / 1000), - 'version' => !empty($this->version) ? $this->version : null, ]; $this->opencastapi = new \OpencastApi\Opencast($config, [], $enableingest); $this->opencastrestclient = new \OpencastApi\Rest\OcRestClient($config); diff --git a/classes/local/api_testable.php b/classes/local/api_testable.php index 299c8bd..e0fbb37 100644 --- a/classes/local/api_testable.php +++ b/classes/local/api_testable.php @@ -43,7 +43,7 @@ class api_testable extends api { private $httpcode; /** @var string version api version to apply for */ - public $version; + public $version = '1.10.0'; /** @var string the username. */ private string $username; @@ -85,10 +85,6 @@ public function __construct($instanceid = null, $enableingest = false) { $this->timeout = settings_api::get_apitimeout($storedconfigocinstanceid); $this->connecttimeout = settings_api::get_apiconnecttimeout($storedconfigocinstanceid); $this->baseurl = settings_api::get_apiurl($storedconfigocinstanceid); - $this->version = settings_api::get_apiversion($storedconfigocinstanceid); - if (empty($this->version)) { - $this->version = '1.10.0'; - } $config = [ 'url' => $this->baseurl, diff --git a/classes/local/settings_api.php b/classes/local/settings_api.php index 032268b..4386950 100644 --- a/classes/local/settings_api.php +++ b/classes/local/settings_api.php @@ -72,22 +72,6 @@ public static function get_apiurl(int $ocinstanceid) { return get_config('tool_opencast', 'apiurl_' . $ocinstanceid); } - /** - * Returns the api version of an Opencast instance as string - * or false, if the corresponding config was not found. - * - * @param int $ocinstanceid - * The id of the Opencast instance, for that the config is retrieved. - * - * @return string|bool - * The requested config as string or false, if the corresponding config was not found. - * - * @throws \dml_exception - */ - public static function get_apiversion(int $ocinstanceid) { - return get_config('tool_opencast', 'apiversion_' . $ocinstanceid); - } - /** * Returns the api username of an Opencast instance as string * or false, if the corresponding config was not found. diff --git a/classes/settings/admin_settings_builder.php b/classes/settings/admin_settings_builder.php index f1f53cd..1ec838f 100644 --- a/classes/settings/admin_settings_builder.php +++ b/classes/settings/admin_settings_builder.php @@ -301,12 +301,6 @@ private static function add_config_settings_fulltree(\admin_settingpage $setting PARAM_URL ); - self::add_admin_setting_configtext($settings, - 'tool_opencast/apiversion_' . $instanceid, - 'apiversion', 'apiversiondesc', - '' - ); - self::add_admin_setting_configtext($settings, 'tool_opencast/apiusername_' . $instanceid, 'apiusername', 'apiusernamedesc', diff --git a/lang/en/tool_opencast.php b/lang/en/tool_opencast.php index 7b03b93..1719835 100644 --- a/lang/en/tool_opencast.php +++ b/lang/en/tool_opencast.php @@ -42,8 +42,6 @@ $string['apiusername'] = 'Username of Opencast API user'; $string['apiusernamedesc'] = 'Configure the username of the Opencast user who is used to do the Opencast API calls. Moodle uses this Opencast user for all communication with Opencast. Authorization is done by adding suitable roles to the call.'; $string['apiusernameempty'] = 'Username of Opencast API user is not configured correctly. Go to the settings of the Opencast API tool to fix this.'; -$string['apiversion'] = 'Opencast API version'; -$string['apiversiondesc'] = 'This is the api version of the opencast instance (e.g. "v1.11.0") to be configured. This would increase the overall performance when configured, because it reduces the automated version extraction step.
Use this link format to get the api version from your opencast: [your opencast address]/docs.html?path=/api#getversiondefault-8'; $string['configuration'] = 'Configuration'; $string['configuration_instance'] = 'Configuration: {$a}'; $string['connecttimeout'] = 'Connection timeout';