diff --git a/lang/en/block_panopto.php b/lang/en/block_panopto.php index 4a6d489..2457a42 100644 --- a/lang/en/block_panopto.php +++ b/lang/en/block_panopto.php @@ -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.'; diff --git a/lib/AuthManagement/AuthManagementWsdlClass.php b/lib/AuthManagement/AuthManagementWsdlClass.php index 20a8514..92986cf 100644 --- a/lib/AuthManagement/AuthManagementWsdlClass.php +++ b/lib/AuthManagement/AuthManagementWsdlClass.php @@ -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']); } @@ -236,6 +236,14 @@ public function __construct($_arrayOfValues = array(),$_resetSoapClient = true) 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 @@ -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']); - } } } /** diff --git a/lib/SessionManagement/List/Request/SessionManagementStructListFoldersRequest.php b/lib/SessionManagement/List/Request/SessionManagementStructListFoldersRequest.php index 571af20..92cf8d1 100644 --- a/lib/SessionManagement/List/Request/SessionManagementStructListFoldersRequest.php +++ b/lib/SessionManagement/List/Request/SessionManagementStructListFoldersRequest.php @@ -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() @@ -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 @@ -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 diff --git a/lib/SessionManagement/SessionManagementWsdlClass.php b/lib/SessionManagement/SessionManagementWsdlClass.php index 937f3ed..910d216 100644 --- a/lib/SessionManagement/SessionManagementWsdlClass.php +++ b/lib/SessionManagement/SessionManagementWsdlClass.php @@ -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']); } @@ -236,6 +236,14 @@ public function __construct($_arrayOfValues = array(),$_resetSoapClient = true) 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 @@ -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']); - } } } /** diff --git a/lib/UserManagement/UserManagementWsdlClass.php b/lib/UserManagement/UserManagementWsdlClass.php index 89e3306..ef4372a 100644 --- a/lib/UserManagement/UserManagementWsdlClass.php +++ b/lib/UserManagement/UserManagementWsdlClass.php @@ -224,7 +224,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']); } @@ -232,6 +232,14 @@ public function __construct($_arrayOfValues = array(),$_resetSoapClient = true) 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 @@ -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']); - } } } /** diff --git a/lib/panopto_data.php b/lib/panopto_data.php index 4d5475e..73b52fa 100644 --- a/lib/panopto_data.php +++ b/lib/panopto_data.php @@ -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)); @@ -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)); @@ -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; @@ -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); diff --git a/lib/panopto_session_soap_client.php b/lib/panopto_session_soap_client.php index 279342e..ef40d5d 100644 --- a/lib/panopto_session_soap_client.php +++ b/lib/panopto_session_soap_client.php @@ -311,6 +311,7 @@ public function get_creator_folders_list() { $sortby = SessionManagementEnumFolderSortField::VALUE_NAME; $sortincreasing = true; $wildcardsearchnameonly = false; + $unmappedonly = true; $folderlistrequest = new SessionManagementStructListFoldersRequest( $pagination, @@ -318,7 +319,8 @@ public function get_creator_folders_list() { $publiconly, $sortby, $sortincreasing, - $wildcardsearchnameonly + $wildcardsearchnameonly, + $unmappedonly ); $searchquery = null; @@ -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; diff --git a/lib/panopto_timeout_soap_client.php b/lib/panopto_timeout_soap_client.php index 22a49ef..bbee79e 100644 --- a/lib/panopto_timeout_soap_client.php +++ b/lib/panopto_timeout_soap_client.php @@ -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) @@ -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; @@ -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); diff --git a/version.php b/version.php index 749186f..55f8c7c 100644 --- a/version.php +++ b/version.php @@ -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;