diff --git a/amd/src/form.js b/amd/src/form.js index 35df3b2fe97068dc7c6d426b4fe230af95c23b4b..adb0e42b9e982af12fd6d76101ce8eabab246278 100644 --- a/amd/src/form.js +++ b/amd/src/form.js @@ -36,8 +36,8 @@ define(['jquery'], function ($) { type: 'post', xhrFields: {withCredentials: true}, data: $('#ltiLaunchForm').serialize(), - complete: function() { - $("iframe").each(function() { + complete: function () { + $("iframe").each(function () { $(this).attr('src', $(this).data('framesrc')); }); } diff --git a/classes/rest.php b/classes/rest.php deleted file mode 100644 index 838dd50ac5e12680f83364f973545b185168c55d..0000000000000000000000000000000000000000 --- a/classes/rest.php +++ /dev/null @@ -1,41 +0,0 @@ -<?php -namespace filter_opencast; - -defined('MOODLE_INTERNAL') || die(); - -class rest extends \core\oauth2\rest { - /** - * Define the functions of the rest API. - * - * @return array Example: - * [ 'listFiles' => [ 'method' => 'get', 'endpoint' => 'http://...', 'args' => [ 'folder' => PARAM_STRING ] ] ] - */ - public function get_api_functions() { - $baseurl = get_config('filter_opencast', 'baseurlapi'); - - return [ - 'me' => [ - 'endpoint' => $baseurl . '/info/me.json', - 'method' => 'get', - 'args' => [], - 'response' => 'raw' - ], - 'episode' => [ - 'endpoint' => $baseurl . '/search/episode.json', - 'method' => 'get', - 'args' => [ - 'id' => PARAM_RAW - ], - 'response' => 'raw' - ], - 'footprint' => [ - 'endpoint' => $baseurl . '/usertracking/footprint.json', - 'method' => 'get', - 'args' => [ - 'id' => PARAM_RAW - ], - 'response' => 'raw' - ], - ]; - } -} \ No newline at end of file diff --git a/filter.php b/filter.php index 3a1d8e5e8278c90b3fa8bbdec93162247c680513..cb67b87376df9ad8add6466af09110986115dc19 100644 --- a/filter.php +++ b/filter.php @@ -53,11 +53,11 @@ class filter_opencast extends moodle_text_filter { if ($matches) { // Login if user is not logged in yet. - $loggedIn = true; - if(!isset($_COOKIE['JSESSIONID'])) { + $loggedin = true; + if (!isset($_COOKIE['JSESSIONID'])) { // Login and set cookie. filter_opencast_login(); - $loggedIn = false; + $loggedin = false; } $video = false; @@ -72,25 +72,24 @@ class filter_opencast extends moodle_text_filter { $apiurl = get_config('tool_opencast', 'apiurl'); // Check if video is from opencast. - if(strpos($match, $apiurl) === false) { + if (strpos($match, $apiurl) === false) { continue; } - if(strpos($apiurl, 'http') !== 0) { + if (strpos($apiurl, 'http') !== 0) { $apiurl = 'http://' . $apiurl; } // Extract id. $id = substr($match, strpos($match, 'api/') + 4, 36); - $src = $CFG->wwwroot . '/filter/opencast/player/core.html?id='.$id.'&ocurl='.urlencode($apiurl); + $src = $CFG->wwwroot . '/filter/opencast/player/core.html?id=' . $id . '&ocurl=' . urlencode($apiurl); - if($loggedIn) { + if ($loggedin) { // Set the source attribute directly. - $player = '<iframe src="'. $src .'" width="95%" height="455px" class="ocplayer"></iframe>'; - } - else { + $player = '<iframe src="' . $src . '" width="95%" height="455px" class="ocplayer"></iframe>'; + } else { // Set the source attribute after login. - $player = '<iframe src="" data-frameSrc="' . $src .'" width="95%" height="455px" class="ocplayer"></iframe>'; + $player = '<iframe data-frameSrc="' . $src . '" width="95%" height="455px" class="ocplayer"></iframe>'; } diff --git a/info/episode.json b/info/episode.json deleted file mode 100644 index 555b7efdfc01843f861e135eda1a82c9bd118a90..0000000000000000000000000000000000000000 --- a/info/episode.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "search-results": { - "offset": "0", - "limit": "0", - "total": "0", - "searchTime": "7", - "query": "(id:caffc928\\-255b\\-4a8d\\-8302\\-d91d55c2a126) AND oc_organization:mh_default_org AND (oc_acl_read:ROLE_ANONYMOUS) AND -oc_mediatype:Series AND -oc_deleted:[* TO *]" - } -} \ No newline at end of file diff --git a/info/footprint.json b/info/footprint.json deleted file mode 100644 index 28bc7f0e0b37fe026b1c08d1d18a37a8d41003a1..0000000000000000000000000000000000000000 --- a/info/footprint.json +++ /dev/null @@ -1 +0,0 @@ -{"footprints":{"total":"1","footprint":{"position":0,"views":0}}} \ No newline at end of file diff --git a/info/me.json b/info/me.json deleted file mode 100644 index 09fd35683184834930f85adc29c794d361d72998..0000000000000000000000000000000000000000 --- a/info/me.json +++ /dev/null @@ -1,93 +0,0 @@ -{ - "org": { - "anonymousRole": "ROLE_ANONYMOUS", - "name": "Opencast Project", - "adminRole": "ROLE_ADMIN", - "id": "mh_default_org", - "properties": { - "admin.shortcut.general.series_view": "s", - "admin.shortcut.editor.split_at_current_time": "v", - "player.shortcut.controls.nextChapter": "pageup", - "engageui.annotations.enable": "true", - "player.shortcut.controls.jumpToBegin": "backspace", - "admin.shortcut.general.select_previous_dashboard_filter": "F", - "admin.shortcut.player.mute": "m", - "admin.shortcut.editor.play_ending_of_current_segment": "n", - "player.mastervideotype": "presenter\/delivery", - "player.shortcut.layout.focusPrev": "<", - "org.opencastproject.admin.help.documentation.url": "http:\/\/docs.opencast.org", - "player.shortcut.controls.prevChapter": "pagedown", - "player.positioncontrols": "bottom", - "player.shortcut.zoom.moveLeft": "a", - "admin.shortcut.general.event_view": "e", - "admin.shortcut.editor.clear_list": "ctrl+backspace", - "adminui.user.external_role_display": "false", - "admin.shortcut.general.help": "?", - "logo_mediamodule": "\/engage\/ui\/img\/logo\/opencast-icon.svg", - "org.opencastproject.admin.help.restdocs.url": "\/rest_docs.html", - "admin.shortcut.general.new_series": "N", - "engageui.link_mobile_redirect.description": "For more information have a look at the official site.", - "player.shortcut.zoom.moveRight": "d", - "player.hide_video_context_menu": "false", - "player.shortcut.layout.movePiP": "p", - "player.shortcut.playbackrate.decrease": "T", - "admin.shortcut.general.select_next_dashboard_filter": "f", - "player.shortcut.zoom.in": "+", - "admin.shortcut.player.next_segment": "down", - "admin.shortcut.general.new_event": "n", - "player.shortcut.controls.playPause": "space", - "admin.shortcut.player.next_frame": "right", - "player.shortcut.fullscreen.cancel": "escape", - "org.opencastproject.admin.mediamodule.url": "\/engage\/ui", - "player.focusedflavor": "presentation", - "player.allowedtags": "engage-download,engage-streaming", - "player.shortcut.zoom.moveUp": "w", - "player.shortcut.zoom.out": "-", - "player.shortcut.layout.focusNext": ">", - "player.shortcut-sequence": "controls,volume,playbackrate,layout,zoom,fullscreen", - "player.shortcut.controls.seekLeft": "left", - "player.shortcut.playbackrate.increase": "t", - "admin.shortcut.editor.play_current_segment_with_pre-roll": "C", - "player.shortcut.volume.up": "9", - "adminui.chunksize": "2048", - "admin.shortcut.editor.cut_selected_segment": "backspace", - "admin.shortcut.player.step_backward": "ctrl+left", - "player.shortcut.controls.seekRight": "right", - "admin.shortcut.editor.play_current_segment": "c", - "logo_player": "\/engage\/theodul\/ui\/img\/opencast.svg", - "admin.shortcut.general.remove_filters": "r", - "player": "\/engage\/theodul\/ui\/core.html", - "player.shortcut.volume.down": "8", - "admin.shortcut.general.main_menu": "m", - "engageui.link_download.enable": "false", - "engageui.links_media_module.enable": "true", - "engageui.link_mobile_redirect.enable": "false", - "login.display_defaults": "true", - "show_embed_links": "true", - "admin.shortcut.player.volume_up": "+", - "player.layout": "off", - "link_mediamodule": "true", - "admin.shortcut.player.previous_frame": "left", - "player.shortcut.fullscreen.enable": "mod+enter", - "admin.shortcut.player.play_pause": "space", - "player.shortcut.volume.muteToggle": "m", - "admin.shortcut.player.volume_down": "-", - "admin.shortcut.player.previous_segment": "up", - "engageui.link_mobile_redirect.url": "http:\/\/opencast.org\/", - "org.opencastproject.oaipmh.server.hosturl": "", - "player.shortcut.layout.togglePiP": "o", - "admin.shortcut.player.step_forward": "ctrl+right", - "player.shortcut.zoom.moveDown": "s" - } - }, - "roles": [ - "ROLE_ANONYMOUS" - ], - "userRole": "ROLE_USER_ANONYMOUS", - "user": { - "provider": null, - "name": null, - "email": null, - "username": "anonymous" - } -} \ No newline at end of file diff --git a/lib.php b/lib.php index df83dec8b1a71df3f2f8d7fb6a37a05964bc9c8f..2cf9b0b9dea85c9f5b081461befa13d5c083c0c5 100644 --- a/lib.php +++ b/lib.php @@ -13,9 +13,6 @@ // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. -require_once($CFG->dirroot.'/mod/lti/locallib.php'); -require_once($CFG->dirroot.'/lib/oauthlib.php'); - /** * Opencast library functions. * @@ -26,6 +23,8 @@ require_once($CFG->dirroot.'/lib/oauthlib.php'); */ defined('MOODLE_INTERNAL') || die(); +require_once($CFG->dirroot . '/mod/lti/locallib.php'); +require_once($CFG->dirroot . '/lib/oauthlib.php'); /** * Use lti to login and retrieve cookie from opencast. @@ -44,8 +43,8 @@ function filter_opencast_login() { $consumerkey = get_config('filter_opencast', 'consumerkey'); $consumersecret = get_config('filter_opencast', 'consumersecret'); - $helper = new oauth_helper(array('oauth_consumer_key' => $consumerkey, - 'oauth_consumer_secret' => $consumersecret)); + $helper = new oauth_helper(array('oauth_consumer_key' => $consumerkey, + 'oauth_consumer_secret' => $consumersecret)); // Set all necessary parameters. $params = array(); @@ -61,7 +60,7 @@ function filter_opencast_login() { $params['resource_link_title'] = 'Opencast'; $params['context_type'] = ($COURSE->format == 'site') ? 'Group' : 'CourseSection'; $params['lis_person_name_given'] = $USER->firstname; - $params['lis_person_name_family'] = $USER->lastname; + $params['lis_person_name_family'] = $USER->lastname; $params['lis_person_name_full'] = $USER->firstname . ' ' . $USER->lastname; $params['ext_user_username'] = $USER->username; $params['lis_person_contact_email_primary'] = $USER->email; @@ -84,7 +83,7 @@ function filter_opencast_login() { $params['launch_presentation_document_target'] = 'iframe'; $params['oauth_signature_method'] = 'HMAC-SHA1'; - $params['oauth_signature'] = $helper->sign("POST", $endpoint, $params, $consumersecret.'&'); + $params['oauth_signature'] = $helper->sign("POST", $endpoint, $params, $consumersecret . '&'); $content = "<form action=\"" . $endpoint . "\" name=\"ltiLaunchForm\" id=\"ltiLaunchForm\" method=\"post\" encType=\"application/x-www-form-urlencoded\">\n"; @@ -102,5 +101,5 @@ function filter_opencast_login() { echo $content; // Submit form. - $PAGE->requires->js_call_amd('filter_opencast/form','init'); + $PAGE->requires->js_call_amd('filter_opencast/form', 'init'); } \ No newline at end of file diff --git a/settings.php b/settings.php index a3128ec3d446bd9d6d93932a3b4561e80a55abde..cd977f93eb94af47607c0b78e11dd5f50338c6fd 100644 --- a/settings.php +++ b/settings.php @@ -24,8 +24,10 @@ defined('MOODLE_INTERNAL') || die; if ($ADMIN->fulltree) { - $settings->add(new admin_setting_configtext('filter_opencast/consumerkey', get_string('setting_consumerkey', 'filter_opencast'), + $settings->add(new admin_setting_configtext('filter_opencast/consumerkey', + get_string('setting_consumerkey', 'filter_opencast'), get_string('setting_consumerkey_desc', 'filter_opencast'), '')); - $settings->add(new admin_setting_configtext('filter_opencast/consumersecret', get_string('setting_consumersecret', 'filter_opencast'), + $settings->add(new admin_setting_configtext('filter_opencast/consumersecret', + get_string('setting_consumersecret', 'filter_opencast'), get_string('setting_consumersecret_desc', 'filter_opencast'), '')); } diff --git a/test.php b/test.php deleted file mode 100644 index f67695bbd3bfe19b60ce11c9d963fb92cad3665b..0000000000000000000000000000000000000000 --- a/test.php +++ /dev/null @@ -1,45 +0,0 @@ -<?php -// This file is part of Moodle - http://moodle.org/ -// -// Moodle is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Moodle is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with Moodle. If not, see <http://www.gnu.org/licenses/>. - -/** - * Opencast filter settings - * - * @package filter_opencastfilter - * @copyright 2017 Tamara Gunkel - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -require_once(__DIR__ . '/../../config.php'); - -// TODO get issuerid -$issuerid = get_config('filter_opencast', 'issuerid'); -$issuer = \core\oauth2\api::get_issuer($issuerid); -// Get an OAuth client from the issuer. -// TODO return url -$returnurl = new moodle_url('/filter/opencastfilter/adminsettings.php'); -$client = \core\oauth2\api::get_user_oauth_client($issuer, $returnurl); - -$service = new \filter_opencast\rest($client); -$me = $service->call('me', []); -file_put_contents('info/me.json', $me); - -$id = '607e3bc5-f134-4ca2-87fd-b87a76ea3a65'; -$params = ['id' => $id]; -$episode = $service->call('episode', $params); -file_put_contents('info/episode.json', $episode); - -$params = ['id' => '6103ef9b-d699-435d-9e69-4676afd30c87']; -$footprint = $service->call('footprint', $params); -file_put_contents('info/footprint.json', $footprint); diff --git a/version.php b/version.php index 1e76d9a7aa14ecf9c3b273a21e672592ee23c5f4..f781a9371a50a34ff4bab8d30ae105e36a158dc1 100644 --- a/version.php +++ b/version.php @@ -25,7 +25,7 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2018021500; // The current plugin version (Date: YYYYMMDDXX) -$plugin->requires = 2017050500; // Requires this Moodle version -$plugin->component = 'filter_opencast'; // Full name of the plugin (used for diagnostics) +$plugin->version = 2018021500; // The current plugin version (Date: YYYYMMDDXX). +$plugin->requires = 2017050500; // Requires this Moodle version. +$plugin->component = 'filter_opencast'; // Full name of the plugin. $plugin->dependencies = array('tool_opencast' => ANY_VERSION);