From 78f4b0da4f9d956896a1fe66cebf99782b94fd98 Mon Sep 17 00:00:00 2001 From: FarbodZamani <53179227+ferishili@users.noreply.github.com> Date: Tue, 14 Mar 2023 16:18:20 +0100 Subject: [PATCH] pre-release fixes (#321) * pre-release fixes * improving instance create method --- block_opencast.php | 23 +++++++++++++++++++++++ renderer.php | 2 +- version.php | 2 +- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/block_opencast.php b/block_opencast.php index 6311f59c..93af14f9 100644 --- a/block_opencast.php +++ b/block_opencast.php @@ -170,4 +170,27 @@ public function instance_delete() { return $success; } + + /** + * Do any additional initialization you may need at the time a new block instance is created: + * If the multiple is not allowed, we only allow one (first) block instance in a context. Others will be deleted. + * @return boolean + */ + public function instance_create() { + global $DB; + + if ($this->instance_allow_multiple() === false) { + $ocblockinstances = $DB->get_records('block_instances', + ['blockname' => 'opencast', 'parentcontextid' => $this->instance->parentcontextid]); + if (count($ocblockinstances) > 1) { + $idstoremove = array_keys($ocblockinstances); + sort($idstoremove); + array_shift($idstoremove); + foreach ($idstoremove as $id) { + blocks_delete_instance($ocblockinstances[$id]); + } + } + } + return true; + } } diff --git a/renderer.php b/renderer.php index 1494c4cd..7720c03d 100644 --- a/renderer.php +++ b/renderer.php @@ -591,7 +591,7 @@ public function render_status($statuscode, $countfailed = 0) { // If needed, add the number of failed uploads. if ($countfailed > 1) { - $statusstring .= '
' . get_string('failedtransferattempts', 'block_opencast', $countfailed); + $statusstring .= ' (' . get_string('failedtransferattempts', 'block_opencast', $countfailed) . ')'; } // Return string. diff --git a/version.php b/version.php index e2bc1bb9..161fc2f6 100644 --- a/version.php +++ b/version.php @@ -24,7 +24,7 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = 'block_opencast'; -$plugin->release = 'development-version'; +$plugin->release = 'development-version'; $plugin->version = 2023030100; $plugin->requires = 2020061500; // Requires Moodle 3.9+. $plugin->maturity = MATURITY_ALPHA;