Skip to content

Commit

Permalink
Merge pull request #212 from Panopto/ahrnjica/2024012500-release-code
Browse files Browse the repository at this point in the history
2024012500 release code
  • Loading branch information
zeroAps authored Jan 25, 2024
2 parents 3b63cdb + 83c67c1 commit a05f8b6
Show file tree
Hide file tree
Showing 28 changed files with 427 additions and 345 deletions.
4 changes: 2 additions & 2 deletions SSO.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@
$targetserver->name = $servername;
$targetserver->appkey = panopto_get_app_key($servername);

$ssosynctask->set_custom_data(array(
$ssosynctask->set_custom_data([
'userid' => $USER->id,
'targetserver' => $targetserver
));
]);

switch ($selectedssotype) {
case 'sync':
Expand Down
10 changes: 5 additions & 5 deletions block_panopto.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ public function instance_allow_config() {
public function instance_config_save($data, $nolongerused = false) {

// Add roles mapping.
$publisherroles = (isset($data->publisher)) ? $data->publisher : array();
$creatorroles = (isset($data->creator)) ? $data->creator : array();
$publisherroles = (isset($data->publisher)) ? $data->publisher : [];
$creatorroles = (isset($data->creator)) ? $data->creator : [];

// Get the current role mappings set for the current course from the db.
$mappings = \panopto_data::get_course_role_mappings($this->page->course->id);
Expand Down Expand Up @@ -154,11 +154,11 @@ public function get_content() {
$this->content->text = '';
$this->content->footer = '';

$params = array('id' => self::CONTENTID, 'courseid' => $COURSE->id);
$params = ['id' => self::CONTENTID, 'courseid' => $COURSE->id];

$this->page->requires->yui_module('moodle-block_panopto-asyncload',
'M.block_panopto.asyncload.init',
array($params),
[$params],
null,
true);

Expand Down Expand Up @@ -212,7 +212,7 @@ public function get_content() {
public function applicable_formats() {
// Since block is dealing with courses and enrollment's the only possible.
// place where Panopto block can be used is the course.
return array('course-view' => true);
return ['course-view' => true];
}

/**
Expand Down
4 changes: 2 additions & 2 deletions build_category_structure.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
require_once(dirname(__FILE__) . '/lib/panopto_category_data.php');

// Populate list of servernames to select from.
$aserverarray = array();
$appkeyarray = array();
$aserverarray = [];
$appkeyarray = [];

$numservers = get_config('block_panopto', 'server_number');
$numservers = isset($numservers) ? $numservers : 0;
Expand Down
8 changes: 4 additions & 4 deletions classes/categorytasks.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ public static function coursecategorycreated(\core\event\course_category_created
if (get_config('block_panopto', 'enforce_category_structure')) {

$task = new \block_panopto\task\ensure_category();
$task->set_custom_data(array(
$task->set_custom_data([
'categoryid' => $event->contextinstanceid
));
]);

if (get_config('block_panopto', 'async_tasks')) {
\core\task\manager::queue_adhoc_task($task);
Expand All @@ -82,9 +82,9 @@ public static function coursecategoryupdated(\core\event\course_category_updated
if (get_config('block_panopto', 'enforce_category_structure')) {

$task = new \block_panopto\task\ensure_category();
$task->set_custom_data(array(
$task->set_custom_data([
'categoryid' => $event->contextinstanceid
));
]);

if (get_config('block_panopto', 'async_tasks')) {
\core\task\manager::queue_adhoc_task($task);
Expand Down
2 changes: 1 addition & 1 deletion classes/panopto_provision_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function definition() {
$mform = & $this->_form;
$selectquery = 'id <> 1';
$coursesraw = $DB->get_records_select('course', $selectquery, null, 'id, shortname, fullname');
$courses = array();
$courses = [];
if ($coursesraw) {
foreach ($coursesraw as $course) {
$courses[$course->id] = $course->shortname . ': ' . $course->fullname;
Expand Down
2 changes: 1 addition & 1 deletion classes/panopto_unprovision_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function definition() {
$coursesraw = $DB->get_records_sql(
'SELECT id, shortname, fullname FROM {course} WHERE id IN (SELECT moodleid FROM {block_panopto_foldermap})'
);
$courses = array();
$courses = [];
if ($coursesraw) {
foreach ($coursesraw as $course) {
$courses[$course->id] = $course->shortname . ': ' . $course->fullname;
Expand Down
6 changes: 3 additions & 3 deletions classes/privacy/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public static function get_users_in_context(\core_privacy\local\request\userlist
}

$enrolledusers = \get_enrolled_users($context);
$enrolleduserids = array();
$enrolleduserids = [];
foreach ($enrolledusers as $user) {
$enrolleduserids[] = $user->id;
}
Expand Down Expand Up @@ -155,7 +155,7 @@ public static function export_user_data(\core_privacy\local\request\approved_con
\panopto_user_info_valid($panoptouser->FirstName) &&
\panopto_user_info_valid($panoptouser->LastName) &&
\panopto_user_info_valid($panoptouser->Email)) {
$subcontext = array();
$subcontext = [];
$subcontext[] = \get_string('pluginname', 'block_panopto');
$subcontext[] = $currentpanopto->servername;

Expand Down Expand Up @@ -184,7 +184,7 @@ public static function delete_data_for_users(\core_privacy\local\request\approve
$currentpanopto->servername = $panoptoserver->name;
$currentpanopto->applicationkey = $panoptoserver->appkey;

$userids = array();
$userids = [];
foreach ($targetusers as $targetuser) {
// Search for user in panopto, if they exist then export the below data, if they do not exist then skip.
$panoptouser = $currentpanopto->get_user_by_key($instancename . '\\' . $targetuser->username);
Expand Down
124 changes: 72 additions & 52 deletions classes/rollingsync.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public static function coursecreated(\core\event\course_created $event) {
if (!empty($tool)) {
// Default intro should be a folderview.
$draftideditor = file_get_submitted_draft_itemid('introeditor');
file_prepare_draft_area($draftideditor, null, null, null, null, array('subdirs' => true));
file_prepare_draft_area($draftideditor, null, null, null, null, ['subdirs' => true]);

$moduleinfo = new stdClass();
$moduleinfo->modulename = 'lti';
Expand All @@ -82,13 +82,13 @@ public static function coursecreated(\core\event\course_created $event) {
$moduleinfo->visible = true;
$moduleinfo->intro = '';
$moduleinfo->icon = 'https://static-contents.panopto.com/prod/panopto_logo_moodle_tool_60x60.png';
$moduleinfo->introeditor = array('text' => $moduleinfo->intro, 'format' => FORMAT_HTML, 'itemid' => $draftideditor);
$moduleinfo->introeditor = ['text' => $moduleinfo->intro, 'format' => FORMAT_HTML, 'itemid' => $draftideditor];
create_module($moduleinfo);
}
}

if (get_config('block_panopto', 'auto_add_block_to_new_courses')) {
$course = $DB->get_record('course', array('id' => $event->courseid));
$course = $DB->get_record('course', ['id' => $event->courseid]);

if ($event->courseid == SITEID) {
$pagetypepattern = 'site-index';
Expand All @@ -98,7 +98,7 @@ public static function coursecreated(\core\event\course_created $event) {

$page = new moodle_page();
$page->set_course($course);
$page->blocks->add_blocks(array(BLOCK_POS_LEFT => array('panopto')), $pagetypepattern);
$page->blocks->add_blocks([BLOCK_POS_LEFT => ['panopto']], $pagetypepattern);
}

if (!\panopto_data::is_main_block_configured() ||
Expand All @@ -110,12 +110,12 @@ public static function coursecreated(\core\event\course_created $event) {

if ($allowautoprovision == 'oncoursecreation') {
$task = new \block_panopto\task\provision_course();
$task->set_custom_data(array(
$task->set_custom_data([
'courseid' => $event->courseid,
'relateduserid' => $event->relateduserid,
'contextid' => $event->contextid,
'eventtype' => 'role'
));
]);
$task->execute();
}
}
Expand Down Expand Up @@ -155,23 +155,64 @@ public static function courserestored(\core\event\course_restored $event) {
return;
}

// Which course or courses to provision.
$provisionduringcopy = get_config('block_panopto', 'provisioning_during_copy');

$panoptodata = new \panopto_data($newcourseid);
$originalpanoptodata = new \panopto_data($originalcourseid);

// This is target or course where we are doing copy or import.
$istargetcourseprovisioned =
isset($panoptodata->servername) && !empty($panoptodata->servername) &&
isset($panoptodata->applicationkey) && !empty($panoptodata->applicationkey) &&
isset($panoptodata->sessiongroupid) && !empty($panoptodata->sessiongroupid);

// This is course which we are copying or importing.
$isoriginalcourseprovisioned =
isset($originalpanoptodata->servername) && !empty($originalpanoptodata->servername) &&
isset($originalpanoptodata->applicationkey) && !empty($originalpanoptodata->applicationkey) &&
isset($originalpanoptodata->sessiongroupid) && !empty($originalpanoptodata->sessiongroupid);

// If any is provisioned, check if we need to provision the other course.
if ($istargetcourseprovisioned || $isoriginalcourseprovisioned) {
// Source course not provisioned, lets provision with target servername and applicationkey.
if (!$isoriginalcourseprovisioned) {
if ($provisionduringcopy == 'both') {
// If any is provisioned, check if we need to provision the other course.
if ($istargetcourseprovisioned || $isoriginalcourseprovisioned) {
if (!$isoriginalcourseprovisioned) {
// Provision original course.
$panoptodata = new \panopto_data($newcourseid);
$originalpanoptodata->servername = $panoptodata->servername;
$originalpanoptodata->applicationkey = $panoptodata->applicationkey;
$originalprovisioninginfo = $originalpanoptodata->get_provisioning_info();
$originalprovisioneddata = $originalpanoptodata->provision_course($originalprovisioninginfo, false);
if (isset($originalprovisioneddata->Id) && !empty($originalprovisioneddata->Id)) {
$isoriginalcourseprovisioned = true;
}
}

if (!$istargetcourseprovisioned) {
// Provision target course.
$originalpanoptodata = new \panopto_data($originalcourseid);
$panoptodata->servername = $originalpanoptodata->servername;
$panoptodata->applicationkey = $originalpanoptodata->applicationkey;
$provisioninginfo = $panoptodata->get_provisioning_info();
$targetprovisioneddata = $panoptodata->provision_course($provisioninginfo, false);
if (isset($targetprovisioneddata->Id) && !empty($targetprovisioneddata->Id)) {
$istargetcourseprovisioned = true;
}
}
} else {
// Neither course is provisioned.

// Provision target course using automatic operation server.
$targetserver = panopto_get_target_panopto_server();
$panoptodata->servername = $targetserver->name;
$panoptodata->applicationkey = $targetserver->appkey;
$provisioninginfo = $panoptodata->get_provisioning_info();
$targetprovisioneddata = $panoptodata->provision_course($provisioninginfo, false);
if (isset($targetprovisioneddata->Id) && !empty($targetprovisioneddata->Id)) {
$istargetcourseprovisioned = true;
}

// Provision original course using target course servername and applicationkey.
$panoptodata = new \panopto_data($newcourseid);
$originalpanoptodata->servername = $panoptodata->servername;
$originalpanoptodata->applicationkey = $panoptodata->applicationkey;
Expand All @@ -181,44 +222,23 @@ public static function courserestored(\core\event\course_restored $event) {
$isoriginalcourseprovisioned = true;
}
}

// Target course not provisioned, lets provision with original servername and applicationkey.
if (!$istargetcourseprovisioned) {
$originalpanoptodata = new \panopto_data($originalcourseid);
$panoptodata->servername = $originalpanoptodata->servername;
$panoptodata->applicationkey = $originalpanoptodata->applicationkey;
} else if ($provisionduringcopy == 'onlytarget') {
// Provision new course only if source is already provisioned.
if ($isoriginalcourseprovisioned && !$istargetcourseprovisioned) {
// Provision target course.
$targetserver = new \panopto_data($originalcourseid);
$panoptodata->servername = $targetserver->servername;
$panoptodata->applicationkey = $targetserver->applicationkey;
$provisioninginfo = $panoptodata->get_provisioning_info();
$targetprovisioneddata = $panoptodata->provision_course($provisioninginfo, false);
if (isset($targetprovisioneddata->Id) && !empty($targetprovisioneddata->Id)) {
$istargetcourseprovisioned = true;
}
}
} else {
// Neither course is provisioned.

// Provision target course using automatic operation server.
$targetserver = panopto_get_target_panopto_server();
$panoptodata->servername = $targetserver->name;
$panoptodata->applicationkey = $targetserver->appkey;
$provisioninginfo = $panoptodata->get_provisioning_info();
$targetprovisioneddata = $panoptodata->provision_course($provisioninginfo, false);
if (isset($targetprovisioneddata->Id) && !empty($targetprovisioneddata->Id)) {
$istargetcourseprovisioned = true;
}

// Provision original course using target course servername and applicationkey.
$panoptodata = new \panopto_data($newcourseid);
$originalpanoptodata->servername = $panoptodata->servername;
$originalpanoptodata->applicationkey = $panoptodata->applicationkey;
$originalprovisioninginfo = $originalpanoptodata->get_provisioning_info();
$originalprovisioneddata = $originalpanoptodata->provision_course($originalprovisioninginfo, false);
if (isset($originalprovisioneddata->Id) && !empty($originalprovisioneddata->Id)) {
$isoriginalcourseprovisioned = true;
}
}

// We should only perform the import if both the target and the source courses are provisioned in panopto.
if ($istargetcourseprovisioned && $isoriginalcourseprovisioned) {
// We should only perform the import if source course is provisioned in panopto.
if ($isoriginalcourseprovisioned) {

// If courses are provisioned to different servers, log an error and return.
if (strcmp($panoptodata->servername, $originalpanoptodata->servername) !== 0) {
Expand Down Expand Up @@ -255,10 +275,10 @@ public static function userenrolmentdeleted(\core\event\user_enrolment_deleted $
}

$task = new \block_panopto\task\sync_user();
$task->set_custom_data(array(
$task->set_custom_data([
'courseid' => $event->courseid,
'userid' => $event->relateduserid
));
]);

if (get_config('block_panopto', 'async_tasks')) {
\core\task\manager::queue_adhoc_task($task);
Expand All @@ -279,10 +299,10 @@ public static function userenrolmentupdated(\core\event\user_enrolment_updated $
}

$task = new \block_panopto\task\sync_user();
$task->set_custom_data(array(
$task->set_custom_data([
'courseid' => $event->courseid,
'userid' => $event->relateduserid
));
]);

if (get_config('block_panopto', 'async_tasks')) {
\core\task\manager::queue_adhoc_task($task);
Expand All @@ -304,10 +324,10 @@ public static function roleassigned(core\event\role_assigned $event) {

if (get_config('block_panopto', 'sync_on_enrolment')) {
$task = new \block_panopto\task\sync_user();
$task->set_custom_data(array(
$task->set_custom_data([
'courseid' => $event->courseid,
'userid' => $event->relateduserid
));
]);

if (get_config('block_panopto', 'async_tasks')) {
\core\task\manager::queue_adhoc_task($task);
Expand All @@ -330,10 +350,10 @@ public static function roleunassigned(core\event\role_unassigned $event) {

if (get_config('block_panopto', 'sync_on_enrolment')) {
$task = new \block_panopto\task\sync_user();
$task->set_custom_data(array(
$task->set_custom_data([
'courseid' => $event->courseid,
'userid' => $event->relateduserid
));
]);

if (get_config('block_panopto', 'async_tasks')) {
\core\task\manager::queue_adhoc_task($task);
Expand All @@ -357,9 +377,9 @@ public static function userloggedin(\core\event\user_loggedin $event) {
if (get_config('block_panopto', 'sync_after_login')) {

$task = new \block_panopto\task\sync_user_login();
$task->set_custom_data(array(
$task->set_custom_data([
'userid' => $event->userid
));
]);

if (get_config('block_panopto', 'async_tasks')) {
\core\task\manager::queue_adhoc_task($task);
Expand All @@ -384,9 +404,9 @@ public static function userloggedinas(\core\event\user_loggedinas $event) {
if (get_config('block_panopto', 'sync_after_login')) {

$task = new \block_panopto\task\sync_user_login();
$task->set_custom_data(array(
$task->set_custom_data([
'userid' => $event->relateduserid
));
]);

if (get_config('block_panopto', 'async_tasks')) {
\core\task\manager::queue_adhoc_task($task);
Expand Down
Loading

0 comments on commit a05f8b6

Please sign in to comment.