Skip to content

Commit

Permalink
pre-release fixes (#321)
Browse files Browse the repository at this point in the history
* pre-release fixes

* improving instance create method
  • Loading branch information
ferishili authored Mar 14, 2023
1 parent 66e19c8 commit 78f4b0d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
23 changes: 23 additions & 0 deletions block_opencast.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
2 changes: 1 addition & 1 deletion renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ public function render_status($statuscode, $countfailed = 0) {

// If needed, add the number of failed uploads.
if ($countfailed > 1) {
$statusstring .= '<br />' . get_string('failedtransferattempts', 'block_opencast', $countfailed);
$statusstring .= ' (' . get_string('failedtransferattempts', 'block_opencast', $countfailed) . ')';
}

// Return string.
Expand Down
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 78f4b0d

Please sign in to comment.