Skip to content

Commit

Permalink
2022090700 release code. (#191)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmalmsten-panopto authored Sep 7, 2022
1 parent 9a859fc commit f636c2f
Show file tree
Hide file tree
Showing 242 changed files with 1,466 additions and 1,057 deletions.
2 changes: 2 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -672,3 +672,5 @@ may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.

END OF TERMS AND CONDITIONS
41 changes: 29 additions & 12 deletions SSO.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,7 @@

// This can't be defined Moodle internal because it is called from Panopto to authorize login.

global $CFG, $USER;

if (empty($CFG)) {
require_once(dirname(__FILE__) . '/../../config.php');
}
require_once(dirname(__FILE__) . '/../../config.php');
require_once($CFG->libdir . '/weblib.php');
require_once(dirname(__FILE__) . '/lib/block_panopto_lib.php');

Expand All @@ -37,7 +33,7 @@
$configuredserverarray = panopto_get_configured_panopto_servers();

$callbackverified = false;
foreach($configuredserverarray as $possibleserver) {
foreach ($configuredserverarray as $possibleserver) {
if (strcasecmp($possibleserver, $servername) == 0) {
$callbackhost = parse_url($callbackurl, PHP_URL_HOST);

Expand All @@ -49,7 +45,7 @@
}

if ($callbackverified) {
if (strpos($callbackurl, 'http%') !== false
if (strpos($callbackurl, 'http%') !== false
|| strpos($callbackurl, 'https%') !== false) {
$callbackurl = urldecode($callbackurl);
}
Expand All @@ -74,7 +70,7 @@
return;
}

// No course ID (0). Don't autologin guests (false).
// No course ID (0). Don't autologin guests (false).
require_login(0, false);

// Reproduce canonically-ordered incoming auth payload.
Expand Down Expand Up @@ -105,18 +101,39 @@
\core\task\manager::queue_adhoc_task($ssosynctask);
break;
}

// Strip ReturnUrl so we can append it on the end
parse_str(parse_url($callbackurl, PHP_URL_QUERY), $params);
$returnurl = isset($params['ReturnUrl']) ? $params['ReturnUrl'] : "";

// Handle fragment with hash.
$fragment = "#";
if (strpos($callbackurl, "#") !== false) {
$fragment .= strtok(explode("#", $callbackurl)[1], '&');
} else {
$fragment = "";
}

// Strip ReturnUrl from original URL and clean if necessary.
// This is constant LoginPageRedirectParamKey = "ReturnUrl" so it should always arrive in this format.
$url = preg_replace('/&?ReturnUrl=[^&]*/', '', $callbackurl);
$url = str_replace('?&', '?', $url);
$url = rtrim($url, '?');

// Generate canonically-ordered auth payload string.
$responseparams = 'serverName=' . $servername . '&externalUserKey=' . $userkey . '&expiration=' . $expiration;
// Sign payload with shared key and hash.
$responseauthcode = panopto_generate_auth_code($responseparams);

// Encode user key in case the backslash causes a sequence to be interpreted as an escape sequence
// Encode user key in case the backslash causes a sequence to be interpreted as an escape sequence.
// (e.g. in the case of usernames that begin with digits).
// Maintain the original canonical string to avoid signature mismatch.
$responseparamsencoded = 'serverName=' . $servername . '&externalUserKey=' . urlencode($userkey) . '&expiration=' . $expiration;
$responseparamsencoded =
'serverName=' . $servername . '&externalUserKey=' . urlencode($userkey) . '&expiration=' . $expiration;

$separator = (strpos($callbackurl, '?') ? '&' : '?');
$redirecturl = $callbackurl . $separator . $responseparamsencoded . '&authCode=' . $responseauthcode;
$fullreturnurl = !empty($returnurl) ? '&ReturnUrl=' . $returnurl . $fragment : "";
$separator = (strpos($url, '?') ? '&' : '?');
$redirecturl = $url . $separator . $responseparamsencoded . '&authCode=' . $responseauthcode . $fullreturnurl;

// Redirect to Panopto Focus login page.
redirect($redirecturl);
Expand Down
21 changes: 10 additions & 11 deletions block_panopto.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,22 +99,21 @@ public function instance_config_save($data, $nolongerused = false) {
$publisherroles,
$creatorroles
);

if (!empty($data->course)) {

// Only perform this chunk if we are remapping to a new folder.
$panoptodata = new \panopto_data($this->page->course->id);

if (strcasecmp($panoptodata->sessiongroupid, $data->course) != 0) {
$oldsessionid = null;
if (!empty($panoptodata->sessiongroupid)) {
$oldsessionid = $panoptodata->sessiongroupid;
$panoptodata->unprovision_course();
}


// Manually overwrite the sessiongroupid on this Panopto_Data instance so we can test provision the attempted new mapping. If the provision fails do not allow it.
// Provision could fail if the user attempts to provision a personal folder.
// Manually overwrite the sessiongroupid on this Panopto_Data instance,
// so we can test provision the attempted new mapping.
// If the provision fails do not allow it. Provision could fail if the user attempts to provision a personal folder.
$panoptodata->sessiongroupid = $data->course;

$provisioninginfo = $panoptodata->get_provisioning_info();
Expand Down Expand Up @@ -142,7 +141,7 @@ public function cron() {
* Generate HTML for block contents.
*/
public function get_content() {
global $COURSE, $PAGE;
global $COURSE;

if ($this->content !== null) {
return $this->content;
Expand All @@ -157,7 +156,7 @@ public function get_content() {

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

$PAGE->requires->yui_module('moodle-block_panopto-asyncload',
$this->page->requires->yui_module('moodle-block_panopto-asyncload',
'M.block_panopto.asyncload.init',
array($params),
null,
Expand Down Expand Up @@ -193,7 +192,7 @@ public function get_content() {
'var showAllToggle = document.getElementById("showAllToggle");' .
'var hiddenLecturesDiv = document.getElementById("hiddenLecturesDiv");' .

'if(hiddenLecturesDiv.style.display == "block") {' .
'if (hiddenLecturesDiv.style.display == "block") {' .
'hiddenLecturesDiv.style.display = "none";' .
'showAllToggle.innerHTML = "' . get_string('show_all', 'block_panopto') . '";' .
'} else {' .
Expand All @@ -211,13 +210,13 @@ public function get_content() {
* @return array
*/
public function applicable_formats() {
// Since block is dealing with courses and enrolments the only possible.
// 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);
}

/**
* allow more than one instance of the block on a page
* Allow more than one instance of the block on a page
*
* @return boolean
*/
Expand Down
9 changes: 6 additions & 3 deletions build_category_structure.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* the code used to build the Moodle category structure on Panopto
* The code used to build the Moodle category structure on Panopto
*
* @package block_panopto
* @copyright Panopto 2009 - 2017
Expand Down Expand Up @@ -67,7 +67,10 @@
require_login();

/**
* The category structure process workhorse funciton
* The category structure process workhorse function
*
* @param string $selectedserver server name
* @param string $selectedkey selected key
*/
function build_category_structure($selectedserver, $selectedkey) {
global $DB;
Expand Down Expand Up @@ -124,7 +127,7 @@ function build_category_structure($selectedserver, $selectedkey) {

echo "<a href='$returnurl'>" . get_string('back_to_config', 'block_panopto') . '</a>';
} else {
$mform->display();
$mform->display();
}

echo $OUTPUT->footer();
Expand Down
8 changes: 3 additions & 5 deletions classes/admin/trim_configtext.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,14 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* a new admin setting that trims any input.
* A new admin setting that trims any input.
*
* @package block_panopto
* @copyright Panopto 2009 - 2016 /With contributions from Spenser Jones ([email protected]),
* Skylar Kelty <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

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

/**
* Text input that trims any extra whitespace.
* @copyright Panopto 2016
Expand All @@ -49,7 +47,7 @@ public function __construct($name, $visiblename, $description, $defaultsetting,
}

/**
* write data to storage
* Write data to storage
*
* @param string $data the data being written.
*/
Expand All @@ -59,7 +57,7 @@ public function write_setting($data) {
$data = 0;
}

// ...$data is a string.
// The ...$data is a string.
$trimmeddata = trim($data);
$validated = $this->validate($trimmeddata);
if ($validated !== true) {
Expand Down
7 changes: 4 additions & 3 deletions classes/categorytasks.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* adds category tasks to the Panopto plugin
* Adds category tasks to the Panopto plugin
*
* @package block_panopto
* @copyright Panopto 2009 - 2018
Expand All @@ -38,13 +38,14 @@
* When a category is moved or updated: course_category_updated is called
*/
class block_panopto_categorytasks {

/**
* Called when a category has been created
*
* @param \core\event\course_category_updated $event
* @param \core\event\course_category_created $event
*/
public static function coursecategorycreated(\core\event\course_category_created $event) {

if (!\panopto_data::is_main_block_configured() ||
!\panopto_data::has_minimum_version()) {
return;
Expand Down
9 changes: 6 additions & 3 deletions classes/panopto_build_category_structure_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,18 @@
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

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

require_once($CFG->libdir . '/formslib.php');

/**
* the form wrapper used to build the Moodle category structure on Panopto
* The form wrapper used to build the Moodle category structure on Panopto
*
* @package block_panopto
* @copyright Panopto 2020
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once($CFG->libdir . '/formslib.php');

class panopto_build_category_structure_form extends moodleform {

/**
Expand Down
7 changes: 5 additions & 2 deletions classes/panopto_provision_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,18 @@
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

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

require_once($CFG->libdir . '/formslib.php');

/**
* Create form for server selection for bulk course provisioning
*
* @package block_panopto
* @copyright Panopto 2020
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once($CFG->libdir . '/formslib.php');

class panopto_provision_form extends moodleform {

/**
Expand Down
6 changes: 4 additions & 2 deletions classes/panopto_rename_all_folders_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,17 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

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

require_once($CFG->libdir . '/formslib.php');

/**
* Form to update all currently mapped Panopto folder names to match their mapped course name
*
* @package block_panopto
* @copyright Panopto 2020
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once($CFG->libdir . '/formslib.php');

class panopto_rename_all_folders_form extends moodleform {

/**
Expand Down
1 change: 1 addition & 0 deletions classes/panopto_unprovision_course_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Create form for server selection.
*
Expand Down
6 changes: 4 additions & 2 deletions classes/panopto_unprovision_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Create form for course unprovision.
*
* @package block_panopto
* @copyright Panopto 2020
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
Expand All @@ -39,8 +41,8 @@ public function definition() {
global $DB;

$mform = & $this->_form;
// Get all categories with no children (all leaf nodes)

// Get all categories with no children (all leaf nodes).
$coursesraw = $DB->get_records_sql(
'SELECT id, shortname, fullname FROM {course} WHERE id IN (SELECT moodleid FROM {block_panopto_foldermap})'
);
Expand Down
6 changes: 4 additions & 2 deletions classes/panopto_upgrade_all_folders_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,17 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

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

require_once($CFG->libdir . '/formslib.php');

/**
* Form for the Generation 1 to Generation 2 Panopto upgrade
*
* @package block_panopto
* @copyright Panopto 2020
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once($CFG->libdir . '/formslib.php');

class panopto_upgrade_all_folders_form extends moodleform {

/**
Expand Down
Loading

0 comments on commit f636c2f

Please sign in to comment.