Skip to content

Commit

Permalink
2022022300 release code. (#187)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmalmsten-panopto authored Feb 24, 2022
1 parent b70bfff commit adac105
Show file tree
Hide file tree
Showing 9 changed files with 120 additions and 49 deletions.
2 changes: 1 addition & 1 deletion lang/en/block_panopto.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@
$string['copy_api_error'] = 'Error importing course with Id {$a->importedcourseid}. Please see the Panopto PHP error logs for more details.';
$string['copy_api_error_auth'] = 'Error getting authorized with the panopto server {$a}.';
$string['copy_api_error_response'] = 'Failed copy response: {$a}';
$string['copy_course_init'] = 'Course copy has initialized, queueing job to copy content from Panopto folder mapped to Moodle course with Id {$a->SourceCourseContexts} to a Panopto folder mapped to the Moodle course with Id {$a->TargetCourseContext}';
$string['copy_course_init'] = 'Course copy has initialized, queueing job to copy content from Panopto folder mapped to Moodle course with Id {$a->SourceCourseContexts[0]} to a Panopto folder mapped to the Moodle course with Id {$a->TargetCourseContext}';
$string['course'] = 'Course';
$string['course_already_provisioned'] = 'This course has already been provisioned to folder with a public Id of: {$a}.';
$string['course_has_invalid_panopto_data'] = 'The target Moodle course is no associated with valid Panopto folder data.';
Expand Down
18 changes: 9 additions & 9 deletions lib/AuthManagement/AuthManagementWsdlClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,14 +228,22 @@ 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']);
}

if(array_key_exists('panopto_connection_timeout', $_arrayOfValues)) {
self::$soapClient->__setConnectionTimeout($_arrayOfValues['panopto_connection_timeout']);
}

if(array_key_exists('wsdl_proxy_host', $_arrayOfValues)) {
self::$soapClient->__setProxyHost($_arrayOfValues['wsdl_proxy_host']);
}

if(array_key_exists('wsdl_proxy_port', $_arrayOfValues)) {
self::$soapClient->__setProxyPort($_arrayOfValues['wsdl_proxy_port']);
}
}
/**
* Generic method called when an object has been exported with var_export() functions
Expand Down Expand Up @@ -308,14 +316,6 @@ public function initSoapClient($_wsdlOptions)
$soapClientClassName = self::getSoapClientClassName();
self::setSoapClient(new $soapClientClassName($wsdlUrl,$wsdlOptions));
}

if(array_key_exists('panopto_socket_timeout', $wsdlOptions)) {
self::$soapClient->__setSocketTimeout($wsdlOptions['panopto_socket_timeout']);
}

if(array_key_exists('panopto_connection_timeout', $wsdlOptions)) {
self::$soapClient->__setConnectionTimeout($wsdlOptions['panopto_connection_timeout']);
}
}
}
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ class SessionManagementStructListFoldersRequest extends SessionManagementWsdlCla
* @var boolean
*/
public $WildcardSearchNameOnly;
/**
* The UnmappedOnly
* Meta informations extracted from the WSDL
* - minOccurs : 0
* @var boolean
*/
public $UnmappedOnly;
/**
* Constructor method for ListFoldersRequest
* @see parent::__construct()
Expand All @@ -94,11 +101,12 @@ class SessionManagementStructListFoldersRequest extends SessionManagementWsdlCla
* @param SessionManagementEnumFolderSortField $_sortBy
* @param boolean $_sortIncreasing
* @param boolean $_wildcardSearchNameOnly
* @param boolean $_unmappedOnly
* @return SessionManagementStructListFoldersRequest
*/
public function __construct($_pagination = NULL,$_parentFolderId = NULL,$_publicOnly = NULL,$_sortBy = NULL,$_sortIncreasing = NULL,$_wildcardSearchNameOnly = NULL)
public function __construct($_pagination = NULL,$_parentFolderId = NULL,$_publicOnly = NULL,$_sortBy = NULL,$_sortIncreasing = NULL,$_wildcardSearchNameOnly = NULL, $__unmappedOnly = NULL)
{
parent::__construct(array('Pagination'=>$_pagination,'ParentFolderId'=>$_parentFolderId,'PublicOnly'=>$_publicOnly,'SortBy'=>$_sortBy,'SortIncreasing'=>$_sortIncreasing,'WildcardSearchNameOnly'=>$_wildcardSearchNameOnly),false);
parent::__construct(array('Pagination'=>$_pagination,'ParentFolderId'=>$_parentFolderId,'PublicOnly'=>$_publicOnly,'SortBy'=>$_sortBy,'SortIncreasing'=>$_sortIncreasing,'WildcardSearchNameOnly'=>$_wildcardSearchNameOnly,'UnmappedOnly'=>$__unmappedOnly),false);
}
/**
* Get Pagination value
Expand Down Expand Up @@ -207,6 +215,23 @@ public function setWildcardSearchNameOnly($_wildcardSearchNameOnly)
{
return ($this->WildcardSearchNameOnly = $_wildcardSearchNameOnly);
}
/**
* Get UnmappedOnly value
* @return boolean|null
*/
public function getUnmappedOnly()
{
return $this->UnmappedOnly;
}
/**
* Set UnmappedOnly value
* @param boolean $_unmappedOnly the UnmappedOnly
* @return boolean
*/
public function setUnmappedOnly($_unmappedOnly)
{
return ($this->UnmappedOnly = $_unmappedOnly);
}
/**
* Method called when an object has been exported with var_export() functions
* It allows to return an object instantiated with the values
Expand Down
18 changes: 9 additions & 9 deletions lib/SessionManagement/SessionManagementWsdlClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,14 +228,22 @@ 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']);
}

if(array_key_exists('panopto_connection_timeout', $_arrayOfValues)) {
self::$soapClient->__setConnectionTimeout($_arrayOfValues['panopto_connection_timeout']);
}

if(array_key_exists('wsdl_proxy_host', $_arrayOfValues)) {
self::$soapClient->__setProxyHost($_arrayOfValues['wsdl_proxy_host']);
}

if(array_key_exists('wsdl_proxy_port', $_arrayOfValues)) {
self::$soapClient->__setProxyPort($_arrayOfValues['wsdl_proxy_port']);
}
}
/**
* Generic method called when an object has been exported with var_export() functions
Expand Down Expand Up @@ -307,14 +315,6 @@ public function initSoapClient($_wsdlOptions)
$soapClientClassName = self::getSoapClientClassName();
self::setSoapClient(new $soapClientClassName($wsdlUrl,$wsdlOptions));
}

if(array_key_exists('panopto_socket_timeout', $wsdlOptions)) {
self::$soapClient->__setSocketTimeout($wsdlOptions['panopto_socket_timeout']);
}

if(array_key_exists('panopto_connection_timeout', $wsdlOptions)) {
self::$soapClient->__setConnectionTimeout($wsdlOptions['panopto_connection_timeout']);
}
}
}
/**
Expand Down
18 changes: 9 additions & 9 deletions lib/UserManagement/UserManagementWsdlClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,14 +224,22 @@ 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']);
}

if(array_key_exists('panopto_connection_timeout', $_arrayOfValues)) {
self::$soapClient->__setConnectionTimeout($_arrayOfValues['panopto_connection_timeout']);
}

if(array_key_exists('wsdl_proxy_host', $_arrayOfValues)) {
self::$soapClient->__setProxyHost($_arrayOfValues['wsdl_proxy_host']);
}

if(array_key_exists('wsdl_proxy_port', $_arrayOfValues)) {
self::$soapClient->__setProxyPort($_arrayOfValues['wsdl_proxy_port']);
}
}
/**
* Generic method called when an object has been exported with var_export() functions
Expand Down Expand Up @@ -303,14 +311,6 @@ public function initSoapClient($_wsdlOptions)
$soapClientClassName = self::getSoapClientClassName();
self::setSoapClient(new $soapClientClassName($wsdlUrl,$wsdlOptions));
}

if(array_key_exists('panopto_socket_timeout', $wsdlOptions)) {
self::$soapClient->__setSocketTimeout($wsdlOptions['panopto_socket_timeout']);
}

if(array_key_exists('panopto_connection_timeout', $wsdlOptions)) {
self::$soapClient->__setConnectionTimeout($wsdlOptions['panopto_connection_timeout']);
}
}
}
/**
Expand Down
57 changes: 40 additions & 17 deletions lib/panopto_data.php
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,17 @@ public function copy_panopto_content($originalcourseid) {
if (!!$connection_timeout) {
$options['CURLOPT_CONNECTTIMEOUT'] = $connection_timeout;
}

$proxyhost = get_config('block_panopto', 'wsdl_proxy_host');
$proxyport = get_config('block_panopto', 'wsdl_proxy_port');

if (!empty($proxyhost)) {
$options['CURLOPT_PROXY'] = $proxyhost;
}

if (!empty($proxyport)) {
$options['CURLOPT_PROXYPORT'] = $proxyport;
}

$response = json_decode($curl->post($location, json_encode($coursecopytask), $options));

Expand Down Expand Up @@ -717,13 +728,9 @@ public function copy_panopto_content($originalcourseid) {
* @param int $newimportid the id of the course being imported
*
*/
public function init_and_sync_import_ccv1($newimportid, $importresults = array(), $handledimports = array()) {
// If we are importing a nested child make sure we have not already imported
if (in_array($newimportid, $handledimports)) {
return $importresults;
} else {
$handledimports[] = $newimportid;
}
public function init_and_sync_import_ccv1($newimportid) {
$importresults = array();
$handledimports = array();

self::print_log_verbose(get_string('init_import_target', 'block_panopto', $this->moodlecourseid));
self::print_log_verbose(get_string('init_import_source', 'block_panopto', $newimportid));
Expand All @@ -743,20 +750,36 @@ public function init_and_sync_import_ccv1($newimportid, $importresults = array()
if (!isset($importpanopto->sessiongroupid)) {
self::print_log(get_string('import_not_mapped', 'block_panopto'));
} else if (!isset($provisioninginfo->accesserror)) {
$sessiongroupids = array();
$sessiongroupids[] = $importpanopto->sessiongroupid;
// We need to make sure this course gets access to anything the course it imported had access to.
$nestedimports = self::get_import_list($newimportid);
$nestedimportresults = array();
foreach ($nestedimports as $nestedimportid) {
$nestedimportpanopto = new \panopto_data($nestedimportid);
// If we are importing a nested child make sure we have not already imported
if (isset($nestedimportpanopto->sessiongroupid) && !in_array($nestedimportid, $handledimports)) {
$handledimports[] = $nestedimportid;
$sessiongroupids[] = $nestedimportpanopto->sessiongroupid;

$importresult = new stdClass;
$importresult->importedcourseid = $nestedimportid;
$nestedimportresults[] = $importresult;
}
}

// Only do this code if we have proper access to the target Panopto course folder.
$importresult = $this->sessionmanager->set_copied_external_course_access_for_roles(
$this->sessionmanager->set_copied_external_course_access_for_roles(
$provisioninginfo->fullname,
$provisioninginfo->externalcourseid,
$importpanopto->sessiongroupid
$sessiongroupids
);

$importresult = new stdClass;
$importresult->importedcourseid = $newimportid;
$importresults[] = $importresult;
$importresults[] = $importresult;
$importresults = array_merge($importresults, $nestedimportresults);

// We need to make sure this course gets access to anything the course it imported had access to.
$nestedimports = self::get_import_list($newimportid);
foreach ($nestedimports as $nestedimportid) {
$importresults = $this->init_and_sync_import_ccv1($nestedimportid, $importresults, $handledimports);
}
} else {
$importresult = new stdClass;
$importresult->importedcourseid = $newimportid;
Expand Down Expand Up @@ -1430,9 +1453,9 @@ public function get_course_options() {
}
}
} else if (isset($panoptofolders)) {
$options = array('Error' => array('-- No Courses Available --'));
$options = array('Error' => '-- No Courses Available --');
} else {
$options = array('Error' => array('!! Unable to retrieve course list !!'));
$options = array('Error' => '!! Unable to retrieve course list !!');
}

return array('courses' => $options, 'selected' => $this->sessiongroupid);
Expand Down
7 changes: 6 additions & 1 deletion lib/panopto_session_soap_client.php
Original file line number Diff line number Diff line change
Expand Up @@ -311,14 +311,16 @@ public function get_creator_folders_list() {
$sortby = SessionManagementEnumFolderSortField::VALUE_NAME;
$sortincreasing = true;
$wildcardsearchnameonly = false;
$unmappedonly = true;

$folderlistrequest = new SessionManagementStructListFoldersRequest(
$pagination,
$parentfolderid,
$publiconly,
$sortby,
$sortincreasing,
$wildcardsearchnameonly
$wildcardsearchnameonly,
$unmappedonly
);
$searchquery = null;

Expand Down Expand Up @@ -368,6 +370,9 @@ public function get_creator_folders_list() {
++$currentpage;
$folderstoget -= $resultsperpage;
}
} else if ($totalresults === 0) {
// In this case folderlist will be null but that is handled poorly in the UI.
$folderlist = array();
}

return $folderlist;
Expand Down
18 changes: 18 additions & 0 deletions lib/panopto_timeout_soap_client.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class PanoptoTimeoutSoapClient extends SoapClient
{
private $socket_timeout;
private $connect_timeout;
private $proxy_host;
private $proxy_port;
private $panoptocookies;

public function __setConnectionTimeout($connect_timeout)
Expand All @@ -54,6 +56,14 @@ public function __setSocketTimeout($socket_timeout)
$this->socket_timeout = $socket_timeout;
}

public function __setProxyHost($proxy_host) {
$this->proxy_host = $proxy_host;
}

public function __setProxyPort($proxy_port) {
$this->proxy_port = $proxy_port;
}

public function getpanoptocookies()
{
return $this->panoptocookies;
Expand Down Expand Up @@ -93,6 +103,14 @@ public function __doRequest($request, $location, $action, $version, $one_way = F
if(!is_null($this->connect_timeout)) {
$options['CURLOPT_CONNECTTIMEOUT'] = $this->connect_timeout;
}

if(!empty($this->proxy_host)) {
$options['CURLOPT_PROXY'] = $this->proxy_host;
}

if(!empty($this->proxy_port)) {
$options['CURLOPT_PROXYPORT'] = $this->proxy_port;
}

$response = $curl->post($location, $request, $options);

Expand Down
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

// Plugin version should normally be the same as the internal version.
// If an admin wants to install with an older version number, however, set that here.
$plugin->version = 2021120900;
$plugin->version = 2022022300;

// Requires this Moodle version - 2.7.
$plugin->requires = 2014051200;
Expand Down

0 comments on commit adac105

Please sign in to comment.