Skip to content

Commit

Permalink
Merge pull request #37 from Opencast-Moodle/update/4.3
Browse files Browse the repository at this point in the history
blind phpcbf run
  • Loading branch information
NinaHerrmann authored Nov 23, 2023
2 parents 5a0e8a5 + 201dda5 commit 9685cca
Show file tree
Hide file tree
Showing 18 changed files with 108 additions and 108 deletions.
6 changes: 3 additions & 3 deletions backup/moodle2/backup_opencast_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ protected function define_structure() {
// The Opencast module stores no user info.

// Define each element separated.
$opencast = new backup_nested_element('opencast', array('id'), array(
$opencast = new backup_nested_element('opencast', ['id'], [
'name', 'timecreated', 'timemodified', 'intro', 'introformat',
'opencastid', 'ocinstanceid', 'type'));
'opencastid', 'ocinstanceid', 'type', ]);

// Define sources.
$opencast->set_source_table('opencast', array('id' => backup::VAR_ACTIVITYID));
$opencast->set_source_table('opencast', ['id' => backup::VAR_ACTIVITYID]);

// Define id annotations.
// Module has no id annotations.
Expand Down
10 changes: 5 additions & 5 deletions backup/moodle2/restore_opencast_activity_task.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ protected function define_my_steps() {
* processed by the link decoder
*/
public static function define_decode_contents() {
$contents = array();
$contents = [];

$contents[] = new restore_decode_content('opencast', array('intro'), 'opencast');
$contents[] = new restore_decode_content('opencast', ['intro'], 'opencast');

return $contents;
}
Expand All @@ -63,7 +63,7 @@ public static function define_decode_contents() {
* to the activity to be executed by the link decoder
*/
public static function define_decode_rules() {
$rules = array();
$rules = [];

$rules[] = new restore_decode_rule('OPENCASTINDEX', '/mod/opencast/index.php?id=$1', 'course');
$rules[] = new restore_decode_rule('OPENCASTVIEWBYID', '/mod/opencast/view.php?id=$1', 'course_module');
Expand All @@ -80,7 +80,7 @@ public static function define_decode_rules() {
* of {@see restore_log_rule} objects
*/
public static function define_restore_log_rules() {
$rules = array();
$rules = [];

$rules[] = new restore_log_rule('opencast', 'add', 'view.php?id={course_module}', '{opencast}');
$rules[] = new restore_log_rule('opencast', 'update', 'view.php?id={course_module}', '{opencast}');
Expand All @@ -100,7 +100,7 @@ public static function define_restore_log_rules() {
* activity level. All them are rules not linked to any module instance (cmid = 0)
*/
public static function define_restore_log_rules_for_course() {
$rules = array();
$rules = [];

$rules[] = new restore_log_rule('opencast', 'view all', 'index.php?id={course}', null);

Expand Down
2 changes: 1 addition & 1 deletion backup/moodle2/restore_opencast_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class restore_opencast_activity_structure_step extends restore_activity_structur
*/
protected function define_structure() {

$paths = array();
$paths = [];
$paths[] = new restore_path_element('opencast', '/activity/opencast');

// Return the paths wrapped into standard activity structure.
Expand Down
2 changes: 1 addition & 1 deletion classes/event/course_module_viewed.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ protected function init() {
* @return string[]
*/
public static function get_objectid_mapping() {
return array('db' => 'opencast', 'restore' => 'opencast');
return ['db' => 'opencast', 'restore' => 'opencast'];
}
}
8 changes: 4 additions & 4 deletions classes/local/apibridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@ public function get_episode($episodeid, $ensureseries = null) {
* @throws \coding_exception
*/
public static function get_course_series_and_episodes($courseid) {
$series = seriesmapping::get_records(array('courseid' => $courseid));
$serieschoices = array();
$episodechoices = array();
$series = seriesmapping::get_records(['courseid' => $courseid]);
$serieschoices = [];
$episodechoices = [];

foreach ($series as $s) {
$apibridge = new apibridge($s->get('ocinstanceid'));
Expand All @@ -166,7 +166,7 @@ public static function get_course_series_and_episodes($courseid) {
$serieschoices[$serieskey] = $ocseries->title;
$episodes = $apibridge->get_episodes_in_series($ocseries->identifier);

$episodechoices[$serieskey] = array('allvideos' => get_string('allvideos', 'mod_opencast'));
$episodechoices[$serieskey] = ['allvideos' => get_string('allvideos', 'mod_opencast')];

foreach ($episodes as $episode) {
$episodechoices[$serieskey][$episode->identifier] = $episode->title;
Expand Down
6 changes: 3 additions & 3 deletions classes/local/output_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public static function output_episode($ocinstanceid, $episodeid, $modinstanceid,
$PAGE->requires->js_call_amd('mod_opencast/opencast_player', 'init',
[$configurl->out(false), $themeurl->out(false)]);

$moduleinstance = $DB->get_record('opencast', array('id' => $modinstanceid), '*', MUST_EXIST);
$moduleinstance = $DB->get_record('opencast', ['id' => $modinstanceid], '*', MUST_EXIST);
if (get_config('mod_opencast', 'global_download_' . $ocinstanceid) || $moduleinstance->allowdownload) {
self::output_download_menu($ocinstanceid, $episodeid, $modinstanceid);
}
Expand Down Expand Up @@ -188,8 +188,8 @@ public static function output_download_menu($ocinstanceid, $episodeid, $modinsta
$name = ucwords(explode('/', $media->flavor)[0]) . ' (' . $media->width . 'x' . $media->height . ')';
$actionmenu->add(new action_menu_link_secondary(
new \moodle_url('/mod/opencast/downloadvideo.php',
array('e' => $video->identifier, 'o' => $modinstanceid,
'mediaid' => $media->id, 'ocinstanceid' => $ocinstanceid)),
['e' => $video->identifier, 'o' => $modinstanceid,
'mediaid' => $media->id, 'ocinstanceid' => $ocinstanceid, ]),
null,
$name
));
Expand Down
16 changes: 8 additions & 8 deletions classes/local/paella_transform.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ private static function get_frame_list($publication) {
'mimetype' => $attachment->mediatype,
'time' => $time,
'url' => $attachment->url,
'thumb' => $attachment->url
'thumb' => $attachment->url,
];
} else {
if (substr($attachment->flavor, -5) === 'hires') {
Expand Down Expand Up @@ -187,7 +187,7 @@ private static function get_streams($publication) {
$streams[$content] = [
'sources' => [],
'content' => $content,
'type' => 'video'
'type' => 'video',
];
$hasadaptivemastertrack[$content] = false;
}
Expand All @@ -211,10 +211,10 @@ private static function get_streams($publication) {
'mimetype' => $media->mediatype,
'res' => [
'w' => isset($media->width) ? $media->width : 0,
'h' => isset($media->height) ? $media->height : 0
'h' => isset($media->height) ? $media->height : 0,
],
'master' => $ismaster,
'isLiveStream' => isset($media->is_live) && $media->is_live
'isLiveStream' => isset($media->is_live) && $media->is_live,
];

if (!$ismainaudioset && isset($media->has_audio) && $media->has_audio) {
Expand Down Expand Up @@ -246,7 +246,7 @@ private static function get_captions($publication) {
'lang' => $lang,
'text' => $lang,
'format' => $format,
'url' => $attachment->url
'url' => $attachment->url,
];
}
}
Expand All @@ -259,7 +259,7 @@ private static function get_captions($publication) {
'lang' => $lang,
'text' => $lang,
'format' => $format,
'url' => $media->url
'url' => $media->url,
];
}
}
Expand Down Expand Up @@ -288,11 +288,11 @@ public static function get_paella_data_json($ocinstanceid, $episodeid, $seriesid
'metadata' => [
'title' => $episode->title,
'duration' => self::get_duration($publication),
'preview' => self::get_preview_image($publication)
'preview' => self::get_preview_image($publication),
],
'streams' => self::get_streams($publication),
'frameList' => self::get_frame_list($publication),
'captions' => self::get_captions($publication)
'captions' => self::get_captions($publication),
];
}
}
2 changes: 1 addition & 1 deletion classes/local/table_series_list_view.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function set_data($episodes) {
get_string('title', 'mod_opencast'),
get_string('duration', 'mod_opencast'),
get_string('date', 'mod_opencast'),
''
'',
]);
$this->setup();
foreach ($episodes as $episode) {
Expand Down
14 changes: 7 additions & 7 deletions db/access.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@

defined('MOODLE_INTERNAL') || die();

$capabilities = array(
$capabilities = [

'mod/opencast:addinstance' => array(
'mod/opencast:addinstance' => [
'riskbitmask' => RISK_XSS,

'captype' => 'write',
'contextlevel' => CONTEXT_COURSE,
'archetypes' => array(
'archetypes' => [
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW
),
'manager' => CAP_ALLOW,
],
'clonepermissionsfrom' => 'moodle/course:manageactivities',
)
);
],
];
4 changes: 2 additions & 2 deletions db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ function xmldb_opencast_upgrade($oldversion) {

if ($oldversion < 2021072000) {
// Check if settings were upgraded without upgrading the plugin.
if ($DB->get_record('config_plugins', array('plugin' => 'mod_opencast', 'name' => 'channel')) &&
$DB->get_record('config_plugins', array('plugin' => 'mod_opencast', 'name' => 'channel_1'))) {
if ($DB->get_record('config_plugins', ['plugin' => 'mod_opencast', 'name' => 'channel']) &&
$DB->get_record('config_plugins', ['plugin' => 'mod_opencast', 'name' => 'channel_1'])) {
// Remove already upgraded settings and only keep old ones.
$DB->execute("DELETE FROM {config_plugins} WHERE plugin='mod_opencast' AND name = 'channel' OR name = 'configurl'");
}
Expand Down
4 changes: 2 additions & 2 deletions downloadvideo.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
$mediaid = required_param('mediaid', PARAM_ALPHANUMEXT);
$ocinstanceid = optional_param('ocinstanceid', \tool_opencast\local\settings_api::get_default_ocinstance()->id, PARAM_INT);

$moduleinstance = $DB->get_record('opencast', array('id' => $o), '*', MUST_EXIST);
$course = $DB->get_record('course', array('id' => $moduleinstance->course), '*', MUST_EXIST);
$moduleinstance = $DB->get_record('opencast', ['id' => $o], '*', MUST_EXIST);
$course = $DB->get_record('course', ['id' => $moduleinstance->course], '*', MUST_EXIST);
$cm = get_coursemodule_from_instance('opencast', $moduleinstance->id, $course->id, false, MUST_EXIST);

require_login($course, true, $cm);
Expand Down
34 changes: 17 additions & 17 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@

$id = required_param('id', PARAM_INT);

$course = $DB->get_record('course', array('id' => $id), '*', MUST_EXIST);
$course = $DB->get_record('course', ['id' => $id], '*', MUST_EXIST);
require_course_login($course);

$coursecontext = context_course::instance($course->id);

$event = \mod_opencast\event\course_module_instance_list_viewed::create(array(
'context' => $coursecontext
));
$event = \mod_opencast\event\course_module_instance_list_viewed::create([
'context' => $coursecontext,
]);
$event->add_record_snapshot('course', $course);
$event->trigger();

$PAGE->set_url('/mod/opencast/index.php', array('id' => $id));
$PAGE->set_url('/mod/opencast/index.php', ['id' => $id]);
$PAGE->set_title(format_string($course->fullname));
$PAGE->set_heading(format_string($course->fullname));
$PAGE->set_context($coursecontext);
Expand All @@ -52,39 +52,39 @@
$opencastinstances = get_all_instances_in_course('opencast', $course);

if (empty($opencastinstances)) {
notice(get_string('nonewmodules', 'mod_opencast'), new moodle_url('/course/view.php', array('id' => $course->id)));
notice(get_string('nonewmodules', 'mod_opencast'), new moodle_url('/course/view.php', ['id' => $course->id]));
}

$table = new html_table();
$table->attributes['class'] = 'generaltable mod_index';

if ($course->format == 'weeks') {
$table->head = array(get_string('week'), get_string('name'));
$table->align = array('center', 'left');
$table->head = [get_string('week'), get_string('name')];
$table->align = ['center', 'left'];
} else if ($course->format == 'topics') {
$table->head = array(get_string('topic'), get_string('name'));
$table->align = array('center', 'left', 'left', 'left');
$table->head = [get_string('topic'), get_string('name')];
$table->align = ['center', 'left', 'left', 'left'];
} else {
$table->head = array(get_string('name'));
$table->align = array('left', 'left', 'left');
$table->head = [get_string('name')];
$table->align = ['left', 'left', 'left'];
}

foreach ($opencastinstances as $opencastinstance) {
if (!$opencastinstance->visible) {
$link = html_writer::link(
new moodle_url('/mod/opencast/view.php', array('id' => $opencastinstance->coursemodule)),
new moodle_url('/mod/opencast/view.php', ['id' => $opencastinstance->coursemodule]),
format_string($opencastinstance->name, true),
array('class' => 'dimmed'));
['class' => 'dimmed']);
} else {
$link = html_writer::link(
new moodle_url('/mod/opencast/view.php', array('id' => $opencastinstance->coursemodule)),
new moodle_url('/mod/opencast/view.php', ['id' => $opencastinstance->coursemodule]),
format_string($opencastinstance->name, true));
}

if ($course->format == 'weeks' || $course->format == 'topics') {
$table->data[] = array($opencastinstance->section, $link);
$table->data[] = [$opencastinstance->section, $link];
} else {
$table->data[] = array($link);
$table->data[] = [$link];
}
}

Expand Down
8 changes: 4 additions & 4 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function opencast_add_instance($moduleinstance, $mform = null) {

// Make sure that the course module has the latest data, in order for everything to work as intended.
$cmid = $moduleinstance->coursemodule;
$DB->set_field('course_modules', 'instance', $id, array('id' => $cmid));
$DB->set_field('course_modules', 'instance', $id, ['id' => $cmid]);

\core_completion\api::update_completion_date_event($cmid, 'opencast', $id,
$moduleinstance->completionexpected ?? null);
Expand Down Expand Up @@ -112,15 +112,15 @@ function opencast_update_instance($moduleinstance, $mform = null) {
function opencast_delete_instance($id) {
global $DB;

$exists = $DB->get_record('opencast', array('id' => $id));
$exists = $DB->get_record('opencast', ['id' => $id]);
if (!$exists) {
return false;
}

$cm = get_coursemodule_from_instance('opencast', $id);
\core_completion\api::update_completion_date_event($cm->id, 'opencast', $id, null);

$DB->delete_records('opencast', array('id' => $id));
$DB->delete_records('opencast', ['id' => $id]);

return true;
}
Expand All @@ -132,7 +132,7 @@ function mod_opencast_get_fontawesome_icon_map() {
return [
'mod_opencast:i/grid' => 'fa-th-large',
'mod_opencast:i/list' => 'fa-list-ul',
'mod_opencast:i/tv' => 'fa-tv'
'mod_opencast:i/tv' => 'fa-tv',
];
}

Expand Down
12 changes: 6 additions & 6 deletions mod_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function definition() {
$mform->addElement('header', 'general', get_string('general', 'form'));

// Adding the standard "name" field.
$mform->addElement('text', 'name', get_string('modulename', 'mod_opencast'), array('size' => '64'));
$mform->addElement('text', 'name', get_string('modulename', 'mod_opencast'), ['size' => '64']);

if (!empty($CFG->formatstringstriptags)) {
$mform->setType('name', PARAM_TEXT);
Expand Down Expand Up @@ -89,15 +89,15 @@ public function definition() {

if (count($choices[1]) === 0) {
$mform->addElement('select', 'episode',
get_string('episode', 'mod_opencast'), array());
get_string('episode', 'mod_opencast'), []);
} else {
$mform->addElement('select', 'episode',
get_string('episode', 'mod_opencast'), array_merge(...array_values($choices[1])));
}
$mform->setType('episode', PARAM_ALPHANUMEXT);
$mform->hideIf('episode', 'manualocid', 'eq', '1');

$ocoptions = array();
$ocoptions = [];
foreach (\tool_opencast\local\settings_api::get_ocinstances() as $oci) {
$ocoptions[$oci->id] = $oci->name;
}
Expand All @@ -109,7 +109,7 @@ public function definition() {
$mform->hideIf('ocinstanceid', 'manualocid', 'eq', '0');

$mform->addElement('text', 'opencastid', get_string('opencastid', 'mod_opencast'),
array('size' => 64));
['size' => 64]);
$mform->setType('opencastid', PARAM_ALPHANUMEXT);
$mform->addRule('opencastid', get_string('required'), 'required');
$mform->hideIf('opencastid', 'manualocid', 'eq', '0');
Expand All @@ -128,7 +128,7 @@ public function definition() {

$mform->addElement('select', 'sortseriesby', get_string('sortseriesby', 'mod_opencast'), [
0 => get_string('uploaddate', 'mod_opencast'),
1 => get_string('videotitle', 'mod_opencast')
1 => get_string('videotitle', 'mod_opencast'),
]);
$mform->addHelpButton('sortseriesby', 'sortseriesby', 'mod_opencast');
}
Expand All @@ -143,7 +143,7 @@ public function definition() {
$this->add_action_buttons();

if ($isuploadinstance) {
$PAGE->requires->js_call_amd('mod_opencast/form_dependent_select', 'init', array($choices[1]));
$PAGE->requires->js_call_amd('mod_opencast/form_dependent_select', 'init', [$choices[1]]);
}
}

Expand Down
Loading

0 comments on commit 9685cca

Please sign in to comment.