Skip to content

Commit

Permalink
Merge pull request #58 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 3c45310 + c4fdc1a commit 8111cba
Show file tree
Hide file tree
Showing 12 changed files with 117 additions and 117 deletions.
44 changes: 22 additions & 22 deletions classes/local/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ public static function get_courses_series_title($courseid) {
* @throws \moodle_exception
*/
public static function get_instance($instanceid = null,
$settings = array(),
$customconfigs = array(),
$settings = [],
$customconfigs = [],
$enableingest = false) {

if (self::use_test_api() === true) {
Expand Down Expand Up @@ -203,8 +203,8 @@ private static function use_test_api() : bool {
* @throws \moodle_exception
*/
public function __construct($instanceid = null,
$settings = array(),
$customconfigs = array(),
$settings = [],
$customconfigs = [],
$enableingest = false) {
// Allow access to local ips.
$settings['ignoresecurity'] = true;
Expand Down Expand Up @@ -268,9 +268,9 @@ public function __construct($instanceid = null,
throw new empty_configuration_exception('apiurlempty', 'tool_opencast');
}

$this->setopt(array(
$this->setopt([
'CURLOPT_TIMEOUT_MS' => $this->timeout,
'CURLOPT_CONNECTTIMEOUT_MS' => $this->connecttimeout));
'CURLOPT_CONNECTTIMEOUT_MS' => $this->connecttimeout, ]);

$config = [
'url' => $this->baseurl,
Expand All @@ -289,7 +289,7 @@ public function __construct($instanceid = null,
*/
public function set_timeout($timeout) {
$this->timeout = $timeout;
$this->setopt(array('CURLOPT_TIMEOUT_MS' => $this->timeout));
$this->setopt(['CURLOPT_TIMEOUT_MS' => $this->timeout]);
}

/**
Expand All @@ -298,7 +298,7 @@ public function set_timeout($timeout) {
*/
public function set_connecttimeout($connecttimeout) {
$this->connecttimeout = $connecttimeout;
$this->setopt(array('CURLOPT_CONNECTTIMEOUT_MS' => $this->connecttimeout));
$this->setopt(['CURLOPT_CONNECTTIMEOUT_MS' => $this->connecttimeout]);
}

/**
Expand Down Expand Up @@ -331,9 +331,9 @@ public function get_http_code() {
* @return array of authentification headers
* @throws \moodle_exception
*/
private function get_authentication_header($runwithroles = array()) {
private function get_authentication_header($runwithroles = []) {

$options = array('CURLOPT_HEADER' => true);
$options = ['CURLOPT_HEADER' => true];
$this->setopt($options);

// Restrict to Roles.
Expand All @@ -344,7 +344,7 @@ private function get_authentication_header($runwithroles = array()) {

$basicauth = base64_encode($this->username . ":" . $this->password);

$header = array();
$header = [];

$header[] = sprintf(
'Authorization: Basic %s', $basicauth
Expand All @@ -362,14 +362,14 @@ private function get_authentication_header($runwithroles = array()) {
* @return string JSON String of result.
* @throws \moodle_exception
*/
public function oc_get($resource, $runwithroles = array()) {
public function oc_get($resource, $runwithroles = []) {
$url = $this->baseurl . $resource;

$this->resetHeader();
$header = $this->get_authentication_header($runwithroles);
$header[] = 'Content-Type: application/json';
$this->setHeader($header);
$this->setopt(array('CURLOPT_HEADER' => false));
$this->setopt(['CURLOPT_HEADER' => false]);

return $this->get($url);
}
Expand Down Expand Up @@ -460,20 +460,20 @@ private function add_postname_chunkupload($file, $key) {
* @return string JSON String of result.
* @throws \moodle_exception
*/
public function oc_post($resource, $params = array(), $runwithroles = array()) {
public function oc_post($resource, $params = [], $runwithroles = []) {

$url = $this->baseurl . $resource;

$this->resetHeader();
$header = $this->get_authentication_header($runwithroles);
$header[] = "Content-Type: multipart/form-data";
$this->setHeader($header);
$this->setopt(array('CURLOPT_HEADER' => false));
$this->setopt(['CURLOPT_HEADER' => false]);

$options['CURLOPT_POST'] = 1;

if (is_array($params)) {
$this->_tmp_file_post_params = array();
$this->_tmp_file_post_params = [];
foreach ($params as $key => $value) {
if ($value instanceof \stored_file) {
$value->add_to_curl_request($this, $key);
Expand Down Expand Up @@ -505,18 +505,18 @@ public function oc_post($resource, $params = array(), $runwithroles = array()) {
* @return string JSON String of result.
* @throws \moodle_exception
*/
public function oc_put($resource, $params = array(), $runwithroles = array()) {
public function oc_put($resource, $params = [], $runwithroles = []) {

$url = $this->baseurl . $resource;

$this->resetHeader();
$header = $this->get_authentication_header($runwithroles);
$this->setHeader($header);
$this->setopt(array('CURLOPT_HEADER' => false));
$this->setopt(['CURLOPT_HEADER' => false]);

$options['CURLOPT_CUSTOMREQUEST'] = "PUT";
if (is_array($params)) {
$this->_tmp_file_post_params = array();
$this->_tmp_file_post_params = [];
foreach ($params as $key => $value) {
$this->_tmp_file_post_params[$key] = $value;
}
Expand All @@ -540,18 +540,18 @@ public function oc_put($resource, $params = array(), $runwithroles = array()) {
* @return string JSON String of result.
* @throws \moodle_exception
*/
public function oc_delete($resource, $params = array(), $runwithroles = array()) {
public function oc_delete($resource, $params = [], $runwithroles = []) {

$url = $this->baseurl . $resource;

$this->resetHeader();
$header = $this->get_authentication_header($runwithroles);
$this->setHeader($header);
$this->setopt(array('CURLOPT_HEADER' => false));
$this->setopt(['CURLOPT_HEADER' => false]);

$options['CURLOPT_CUSTOMREQUEST'] = "DELETE";
if (is_array($params)) {
$this->_tmp_file_post_params = array();
$this->_tmp_file_post_params = [];
foreach ($params as $key => $value) {
$this->_tmp_file_post_params[$key] = $value;
}
Expand Down
6 changes: 3 additions & 3 deletions classes/local/api_testable.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function __construct($instanceid = null, $enableingest = false) {
'password' => $this->password,
'timeout' => (intval($this->timeout) / 1000),
'connect_timeout' => (intval($this->connecttimeout) / 1000),
'version' => $this->version
'version' => $this->version,
];

$handler = \OpencastApi\Mock\OcMockHanlder::getHandlerStackWithPath($this->jsonresponses);
Expand Down Expand Up @@ -139,10 +139,10 @@ public static function add_json_response($resource, $method, $status = 200, $bod
$jsonresponses = [];
}
if (!array_key_exists($resource, $jsonresponses)) {
$jsonresponses[$resource] = array();
$jsonresponses[$resource] = [];
}
if (!isset($jsonresponses[$resource][strtoupper($method)])) {
$jsonresponses[$resource][strtoupper($method)] = array();
$jsonresponses[$resource][strtoupper($method)] = [];
}
$responseobject = compact('status', 'body', 'version', 'reason', 'params', 'headers');
$jsonresponses[$resource][strtoupper($method)][] = $responseobject;
Expand Down
6 changes: 3 additions & 3 deletions classes/local/settings_api.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,12 @@ public static function get_ocinstances() : array {
try {
$ocinstancesconfig = get_config('tool_opencast', 'ocinstances');
} catch (\dml_exception $exception) {
return array();
return [];
}

$dynamicocinstances = json_decode($ocinstancesconfig);

$ocinstances = array();
$ocinstances = [];
foreach ($dynamicocinstances as $dynamicocinstance) {
$ocinstances[] = new opencast_instance($dynamicocinstance);
}
Expand All @@ -243,7 +243,7 @@ public static function get_ocinstances() : array {
* The Opencast instance, to that all configured Opencast instances are set to.
*/
public static function set_ocinstances_to_ocinstance($dynamicocinstance) : void {
set_config('ocinstances', json_encode(array($dynamicocinstance)), 'tool_opencast');
set_config('ocinstances', json_encode([$dynamicocinstance]), 'tool_opencast');
}

/**
Expand Down
28 changes: 14 additions & 14 deletions classes/seriesmapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,26 +45,26 @@ class seriesmapping extends \core\persistent {
*/
protected static function define_properties() {

return array(
'id' => array(
return [
'id' => [
'type' => PARAM_INT,
),
'courseid' => array(
],
'courseid' => [
'type' => PARAM_INT,
),
'series' => array(
],
'series' => [
'type' => PARAM_ALPHANUMEXT,
),
'ocinstanceid' => array(
],
'ocinstanceid' => [
'type' => PARAM_INT,
'default' => function () {
return settings_api::get_default_ocinstance()->id;
}
),
'isdefault' => array(
},
],
'isdefault' => [
'type' => PARAM_BOOL,
),
);
],
];
}

/**
Expand All @@ -73,7 +73,7 @@ protected static function define_properties() {
* @param false $skipdefault
* @return false|seriesmapping
*/
public static function get_record($filters = array(), $skipdefault = false) {
public static function get_record($filters = [], $skipdefault = false) {
// TODO later deprecate skipdefault and remove this compatibility stuff.
// Keep it compatible with old versions.
if (!$skipdefault && !array_key_exists('isdefault', $filters)) {
Expand Down
2 changes: 1 addition & 1 deletion classes/settings/admin_settings_builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ private static function add_connection_test_tool(\admin_settingpage $settings,
'class' => 'btn btn-warning disabled testtool-modal',
'disabled' => 'disabled',
'title' => get_string('testtooldisabledbuttontitle', self::PLUGINNAME),
'data-instanceid' => strval($instanceid)
'data-instanceid' => strval($instanceid),
];

$connectiontoolbutton = \html_writer::tag(
Expand Down
30 changes: 15 additions & 15 deletions db/access.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,30 +24,30 @@

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

$capabilities = array(
$capabilities = [

'tool/opencast:instructor' => array(
'tool/opencast:instructor' => [
'captype' => 'read',
'contextlevel' => CONTEXT_COURSE,
'archetypes' => array(
'editingteacher' => CAP_ALLOW
)
),
'archetypes' => [
'editingteacher' => CAP_ALLOW,
],
],

'tool/opencast:learner' => array(
'tool/opencast:learner' => [
'captype' => 'read',
'contextlevel' => CONTEXT_COURSE,
'archetypes' => array(
'archetypes' => [
'student' => CAP_ALLOW,
'teacher' => CAP_ALLOW,
'manager' => CAP_ALLOW,
)
),
],
],

'tool/opencast:externalapi' => array(
'tool/opencast:externalapi' => [
'captype' => 'read',
'contextlevel' => CONTEXT_SYSTEM,
'archetypes' => array(
)
),
);
'archetypes' => [
],
],
];
32 changes: 16 additions & 16 deletions db/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,32 @@
*/
defined('MOODLE_INTERNAL') || die();

$functions = array(
'tool_opencast_get_courses_for_learner' => array(
$functions = [
'tool_opencast_get_courses_for_learner' => [
'classname' => 'tool_opencast_external',
'methodname' => 'get_courses_for_learner',
'classpath' => 'admin/tool/opencast/external.php',
'description' => 'Service to query the courses in which a user has the capability of a learner',
'type' => 'read',
'capabilities' => 'tool/opencast:externalapi',
),
'tool_opencast_get_courses_for_instructor' => array(
],
'tool_opencast_get_courses_for_instructor' => [
'classname' => 'tool_opencast_external',
'methodname' => 'get_courses_for_instructor',
'classpath' => 'admin/tool/opencast/external.php',
'description' => 'Service to query the courses in which a user has the capability of a instructor',
'type' => 'read',
'capabilities' => 'tool/opencast:externalapi',
),
'tool_opencast_get_groups_for_learner' => array(
],
'tool_opencast_get_groups_for_learner' => [
'classname' => 'tool_opencast_external',
'methodname' => 'get_groups_for_learner',
'classpath' => 'admin/tool/opencast/external.php',
'description' => 'Service to query the groups in which a user has a membership in',
'type' => 'read',
'capabilities' => 'tool/opencast:externalapi, moodle/site:accessallgroups',
),
'tool_opencast_connection_test_tool' => array(
],
'tool_opencast_connection_test_tool' => [
'classname' => 'tool_opencast_external',
'methodname' => 'connection_test_tool',
'classpath' => 'admin/tool/opencast/external.php',
Expand All @@ -56,19 +56,19 @@
'capabilities' => 'tool/opencast:externalapi',
'ajax' => true,
'loginrequired' => true,
),
);
],
];

$services = array(
'Opencast web service' => array(
'functions' => array (
$services = [
'Opencast web service' => [
'functions' => [
'tool_opencast_get_courses_for_learner',
'tool_opencast_get_courses_for_instructor',
'tool_opencast_get_groups_for_learner',
'core_user_get_users_by_field',
),
],
'restrictedusers' => 1, // If 1, the administrator must manually select which user can use this service.
// (Administration > Plugins > Web services > Manage services > Authorised users).
'enabled' => 1, // If 0, then token linked to this service won't work.
)
);
],
];
Loading

0 comments on commit 8111cba

Please sign in to comment.