Skip to content

Commit

Permalink
2022122000 release code. (#193)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmalmsten-panopto authored Dec 21, 2022
1 parent f636c2f commit 63cba01
Show file tree
Hide file tree
Showing 37 changed files with 1,343 additions and 323 deletions.
121 changes: 121 additions & 0 deletions .github/workflows/moodle-plugin-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
name: Moodle Plugin CI

on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-latest

services:
postgres:
image: postgres:12
env:
POSTGRES_USER: 'postgres'
POSTGRES_HOST_AUTH_METHOD: 'trust'
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 3
mariadb:
image: mariadb:10
env:
MYSQL_USER: 'root'
MYSQL_ALLOW_EMPTY_PASSWORD: "true"
MYSQL_CHARACTER_SET_SERVER: "utf8mb4"
MYSQL_COLLATION_SERVER: "utf8mb4_unicode_ci"

ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 3

strategy:
fail-fast: false
matrix:
include:
- php: '8.0'
moodle-branch: 'master'
database: 'pgsql'
- php: '8.0'
moodle-branch: 'MOODLE_400_STABLE'
database: 'mariadb'
- php: '7.4'
moodle-branch: 'MOODLE_311_STABLE'
database: 'pgsql'
- php: '7.4'
moodle-branch: 'MOODLE_39_STABLE'
database: 'mariadb'

steps:
- name: Check out repository code
uses: actions/checkout@v2
with:
path: plugin

- name: Setup PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: ${{ matrix.extensions }}
ini-values: max_input_vars=5000
# none to use phpdbg fallback. Specify pcov (Moodle 3.10 and up) or xdebug to use them instead.
coverage: none

- name: Initialise moodle-plugin-ci
run: |
composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^3
echo $(cd ci/bin; pwd) >> $GITHUB_PATH
echo $(cd ci/vendor/bin; pwd) >> $GITHUB_PATH
sudo locale-gen en_AU.UTF-8
echo "NVM_DIR=$HOME/.nvm" >> $GITHUB_ENV
- name: Install moodle-plugin-ci
run: |
moodle-plugin-ci install --plugin ./plugin --db-host=127.0.0.1
env:
DB: ${{ matrix.database }}
MOODLE_BRANCH: ${{ matrix.moodle-branch }}

- name: PHP Lint
if: ${{ always() }}
run: moodle-plugin-ci phplint

- name: PHP Copy/Paste Detector
continue-on-error: true # This step will show errors but will not fail
if: ${{ always() }}
run: moodle-plugin-ci phpcpd

- name: PHP Mess Detector
continue-on-error: true # This step will show errors but will not fail
if: ${{ always() }}
run: moodle-plugin-ci phpmd

- name: Moodle Code Checker
if: ${{ always() }}
# Allow 3 warnings for privacy provider interfaces (Moodle <3.6)
run: moodle-plugin-ci codechecker --max-warnings 3

- name: Moodle PHPDoc Checker
if: ${{ always() }}
run: moodle-plugin-ci phpdoc

- name: Validating
if: ${{ always() }}
run: moodle-plugin-ci validate

- name: Check upgrade savepoints
if: ${{ always() }}
run: moodle-plugin-ci savepoints

- name: Mustache Lint
if: ${{ always() }}
run: moodle-plugin-ci mustache

- name: Grunt
if: ${{ always() }}
run: moodle-plugin-ci grunt --max-lint-warnings 0

- name: PHPUnit tests
if: ${{ always() }}
run: moodle-plugin-ci phpunit --fail-on-warning

- name: Behat features
if: ${{ always() }}
run: moodle-plugin-ci behat --profile chrome
2 changes: 1 addition & 1 deletion SSO.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
break;
}

// Strip ReturnUrl so we can append it on the end
// 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'] : "";

Expand Down
5 changes: 1 addition & 4 deletions build_category_structure.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,8 @@
* @copyright Panopto 2009 - 2017
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
global $CFG;
if (empty($CFG)) {
require_once(dirname(__FILE__) . '/../../config.php');
}

require_once(dirname(__FILE__) . '/../../config.php');
require_once($CFG->libdir . '/formslib.php');
require_once(dirname(__FILE__) . '/classes/panopto_build_category_structure_form.php');
require_once(dirname(__FILE__) . '/lib/block_panopto_lib.php');
Expand Down
18 changes: 1 addition & 17 deletions classes/admin/trim_configtext.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,29 +30,13 @@
*/
class admin_setting_configtext_trimmed extends admin_setting_configtext {

/**
* Config text constructor
*
* @param string $name unique ascii name, either 'mysetting' for settings that in config,
* or 'myplugin/mysetting' for ones in config_plugins.
* @param string $visiblename localised
* @param string $description long localised info
* @param string $defaultsetting
* @param mixed $paramtype int means PARAM_XXX type, string is a allowed format in regex
* @param int $size default field size
*/
public function __construct($name, $visiblename, $description, $defaultsetting, $paramtype=PARAM_RAW,
$size=null) {
parent::__construct($name, $visiblename, $description, $defaultsetting, $paramtype, $size);
}

/**
* Write data to storage
*
* @param string $data the data being written.
*/
public function write_setting($data) {
if ($this->paramtype === PARAM_INT and $data === '') {
if ($this->paramtype === PARAM_INT && $data === '') {
// Do not complain if '' used instead of 0.
$data = 0;
}
Expand Down
8 changes: 4 additions & 4 deletions classes/categorytasks.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
*/

defined('MOODLE_INTERNAL') || die();
global $CFG;
if (empty($CFG)) {
require_once(dirname(__FILE__) . '/../../../config.php');
}

// No login check is expected since we can run this from console.
// @codingStandardsIgnoreLine
require_once(dirname(__FILE__) . '/../../../config.php');
require_once(dirname(__FILE__) . '/../lib/panopto_data.php');

/**
Expand Down
8 changes: 5 additions & 3 deletions classes/privacy/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,29 +30,31 @@

use \core_privacy\local\metadata\collection;

// @codingStandardsIgnoreStart
if (interface_exists('\core_privacy\local\request\userlist')) {
interface my_userlist extends \core_privacy\local\request\userlist {
}
} else {
interface my_userlist {
};
}
}

if (interface_exists('\core_privacy\local\request\core_userlist_provider')) {
interface my_userlist_provider extends \core_privacy\local\request\core_userlist_provider {
}
} else {
interface my_userlist_provider {
};
}
}

if (interface_exists('\core_privacy\local\request\core_user_data_provider')) {
interface my_userdataprovider extends \core_privacy\local\request\core_user_data_provider {
}
} else {
interface my_userdataprovider {
};
}
}
// @codingStandardsIgnoreEnd

/**
* Provider that stores user data.
Expand Down
83 changes: 73 additions & 10 deletions classes/rollingsync.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,11 @@

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

global $CFG;
if (empty($CFG)) {
require_once(dirname(__FILE__) . '/../../../config.php');
}

// No login check is expected since we can run this from console.
// @codingStandardsIgnoreLine
require_once(dirname(__FILE__) . '/../../../config.php');
require_once(dirname(__FILE__) . '/../lib/panopto_data.php');
require_once(dirname(__FILE__) . '/../lib/panoptoblock_lti_utility.php');
require_once(dirname(__FILE__) . '/../lib/lti/panoptoblock_lti_utility.php');
require_once($CFG->libdir . '/pagelib.php');
require_once($CFG->libdir . '/blocklib.php');

Expand Down Expand Up @@ -150,16 +148,81 @@ public static function courserestored(\core\event\course_restored $event) {
$newcourseid = intval($event->courseid);
$originalcourseid = intval($event->other['originalcourseid']);

// Make sure we cannot copy/import course into itself.
if ($originalcourseid == $newcourseid) {
return;
}

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

// We should only perform the import if both the target and the source course are provisioned in panopto.
if (isset($panoptodata->servername) && !empty($panoptodata->servername) &&
$istargetcourseprovisioned =
isset($panoptodata->servername) && !empty($panoptodata->servername) &&
isset($panoptodata->applicationkey) && !empty($panoptodata->applicationkey) &&
isset($panoptodata->sessiongroupid) && !empty($panoptodata->sessiongroupid) &&
isset($panoptodata->sessiongroupid) && !empty($panoptodata->sessiongroupid);

$isoriginalcourseprovisioned =
isset($originalpanoptodata->servername) && !empty($originalpanoptodata->servername) &&
isset($originalpanoptodata->applicationkey) && !empty($originalpanoptodata->applicationkey) &&
isset($originalpanoptodata->sessiongroupid) && !empty($originalpanoptodata->sessiongroupid)) {
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) {
$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;
}
}

// 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;
$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) {

// If courses are provisioned to different servers, log an error and return.
if (strcmp($panoptodata->servername, $originalpanoptodata->servername) !== 0) {
\panopto_data::print_log('ERROR: Mismatch in server name inside "courserestored" during course import/copy.');
return;
}

$panoptodata->ensure_auth_manager();
$activepanoptoserverversion = $panoptodata->authmanager->get_server_version();
Expand Down
2 changes: 1 addition & 1 deletion db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function xmldb_block_panopto_upgrade($oldversion = 0) {
upgrade_block_savepoint(true, 2015012901, 'panopto');
}

if ($oldversion <= 2016101227) {
if ($oldversion < 2016101227) {
// Move block global settings to <prefix>_config_plugin table.
// First, move each server configuration. We are not relying here on
// block_panopto_server_number to determine number of servers, as there
Expand Down
6 changes: 3 additions & 3 deletions lib/AuthManagement/AuthManagementWsdlClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public function __construct($_arrayOfValues = array(),$_resetSoapClient = true)
foreach($_arrayOfValues as $name=>$value)
$this->_set($name,$value);
}

if(array_key_exists('panopto_socket_timeout', $_arrayOfValues)) {
self::$soapClient->__setSocketTimeout($_arrayOfValues['panopto_socket_timeout']);
}
Expand Down Expand Up @@ -1000,15 +1000,15 @@ public function __construct ($wsdl, array $options = null) {
}

/**
* wrapper around dorequest so we can enforce https on all calls
* Wrapper around dorequest so we can enforce https on all calls
*
* @param object $request - the request being made
* @param string $location - the location the request will be made to
* @param string $action
* @param string $version
* @param int $one_way
*/
public function __doRequest ($request, $location, $action, $version, $one_way = 0) {
public function __doRequest($request, $location, $action, $version, $one_way = 0) {
if (get_config('block_panopto', 'enforce_https_on_wsdl')) {
$location = str_replace('http://', 'https://', $location);
}
Expand Down
6 changes: 3 additions & 3 deletions lib/SessionManagement/SessionManagementWsdlClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public function __construct($_arrayOfValues = array(),$_resetSoapClient = true)
foreach($_arrayOfValues as $name=>$value)
$this->_set($name,$value);
}

if(array_key_exists('panopto_socket_timeout', $_arrayOfValues)) {
self::$soapClient->__setSocketTimeout($_arrayOfValues['panopto_socket_timeout']);
}
Expand Down Expand Up @@ -999,15 +999,15 @@ public function __construct ($wsdl, array $options = null) {
}

/**
* wrapper around dorequest so we can enforce https on all calls
* Wrapper around dorequest so we can enforce https on all calls
*
* @param object $request - the request being made
* @param string $location - the location the request will be made to
* @param string $action
* @param string $version
* @param int $one_way
*/
public function __doRequest ($request, $location, $action, $version, $one_way = 0) {
public function __doRequest($request, $location, $action, $version, $one_way = 0) {
if (get_config('block_panopto', 'enforce_https_on_wsdl')) {
$location = str_replace('http://', 'https://', $location);
}
Expand Down
Loading

0 comments on commit 63cba01

Please sign in to comment.