Skip to content

Commit

Permalink
2018050700 beta release candidate. (#133)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmalmsten-panopto authored May 7, 2018
1 parent 6a920bd commit b4a4074
Show file tree
Hide file tree
Showing 19 changed files with 308 additions and 125 deletions.
11 changes: 9 additions & 2 deletions block_panopto.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ public function instance_allow_config() {
public function instance_config_save($data, $nolongerused = false) {
if (!empty($data->course)) {

panopto_data::set_panopto_course_id($this->page->course->id, $data->course);
// Add roles mapping.
$publisherroles = (isset($data->publisher)) ? $data->publisher : array();
$creatorroles = (isset($data->creator)) ? $data->creator : array();
Expand All @@ -90,8 +89,16 @@ public function instance_config_save($data, $nolongerused = false) {
);

$panoptodata = new panopto_data($this->page->course->id);

// 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();
$panoptodata->provision_course($provisioninginfo, false);
$provisioneddata = $panoptodata->provision_course($provisioninginfo, false);
if (isset($provisioneddata->Id) && !empty($provisioneddata->Id)) {
panopto_data::set_panopto_course_id($this->page->course->id, $data->course);
}
}
}

Expand Down
13 changes: 11 additions & 2 deletions db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@

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

require_once(dirname(__FILE__) . '/../lib/panopto_data.php');

/**
* Upgrades Panopto for xmldb
*
Expand Down Expand Up @@ -260,5 +258,16 @@ function xmldb_block_panopto_upgrade($oldversion = 0) {
upgrade_block_savepoint(true, 2017110600, 'panopto');
}

if ($oldversion < 2018030200) {

// Since this toggle got changed/removed for a select, get the old value and if it's set then set the new feature as appropriate.
if (get_config('block_panopto', 'prefix_new_folder_names')) {
set_config('folder_name_style', 'combination', 'block_panopto');
}

// Panopto savepoint reached.
upgrade_block_savepoint(true, 2018030200, 'panopto');
}

return true;
}
14 changes: 11 additions & 3 deletions lang/en/block_panopto.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
$string['attempted_import_course_id'] = 'Moodle Id of the source import course';
$string['attempted_panopto_server'] = 'Attempted Panopto Server';
$string['attempt_provision_course'] = 'Attempting to provision a Panopto folder with an External Id of: {$a}.';
$string['attempted_provisioning_personal_folder'] = 'Attempted to provision to a personal folder, this is not currently an action supported by Panopto. Please map the course to a different folder through the block instance config and try reprovisioning.';
$string['attempt_sync_user'] = 'Attempting to sync a user with and Id of {$a} to Panopto.';
$string['attempt_sync_user_server'] = 'Target server of the attempted sync is {$a}.';
$string['api_manager_unavailable'] = 'Unable to create the {$a} manager api client! (Is the Panopto server available, if so are the instance name and application key correct?)';
Expand Down Expand Up @@ -80,8 +81,12 @@
$string['block_panopto_auto_provision_desc'] = 'Enable this option to automatically provision a Panopto course folder when a course is created.';
$string['block_panopto_async_tasks'] = 'Asynchronous sync tasks';
$string['block_panopto_async_tasks_desc'] = 'Enable this option to allow the enrolment, unenrolment, and delete user tasks to happen asynchronously (may have a short delay before running)';
$string['block_panopto_prefix_new_folder_shortnames'] = 'Prefix new Panopto folder display names with the Moodle course\'s shortname';
$string['block_panopto_prefix_new_folder_shortnames_desc'] = 'Enable this option to add the provisioned course shortname to the beginning of newly made Panopto folder\'s display name.';
$string['block_panopto_folder_name_style'] = 'Panopto folder name style';
$string['block_panopto_folder_name_style_desc'] = 'Use this option to select which visual name style you wish to have for your new Panopto folders';
$string['block_panopto_wsdl_proxy_host'] = 'WSDL proxy host';
$string['block_panopto_wsdl_proxy_host_desc'] = 'The host address used as a proxy for any Panopto service WSDL. (Optional)';
$string['block_panopto_wsdl_proxy_port'] = 'WSDL proxy port';
$string['block_panopto_wsdl_proxy_port_desc'] = 'The port used as a proxy for any Panopto service WSDL. (Optional)';
$string['completed_recordings'] = 'Completed Recordings';
$string['course'] = 'Course';
$string['course_name'] = 'Course Name';
Expand All @@ -93,7 +98,7 @@
$string['download_recorder'] = 'Download Recorder';
$string['error_retrieving'] = 'Error retrieving Panopto course folder.';
$string['no_access'] = 'You do not have access to view this Panopto folder.';
$string['existing_course'] = 'Select an existing Panopto folder:';
$string['existing_course'] = 'Select an existing Panopto folder that is not currently mapped to another course:';
$string['fetching_content'] = 'Fetching Panopto Content...';
$string['folder_not_found_error'] = 'The folder currenty provisioned to the target Moodle course on the Panopto server could not be found, was it deleted? Provisioning will continue by linking to the default Moodle folder or creating one if it does not already exist.';
$string['get_provisioning_info'] = 'Attempting to get provisioning info for a course with the Moodle Id: {$a}.';
Expand All @@ -108,6 +113,9 @@
$string['live_sessions'] = 'Live Sessions';
$string['missing_required_version'] = 'API call failed to return a response, this could be because the Panopto server you attempted to use does not meet the minimum required version to support this version of the Moodle Panopto Block. This could also be caused by the server being unavailable.';
$string['moodle_course_not_exist'] = 'Moving row to old foldermap, course did not exist inside Moodle.';
$string['name_style_shortname'] = '[short name]';
$string['name_style_fullname'] = '[full name]';
$string['name_style_combination'] = '[short name]: [full name]';
$string['no_completed_recordings'] = 'No Completed Recordings';
$string['no_course_selected'] = 'No Panopto course folder selected';
$string['no_creators'] = 'No creators.';
Expand Down
2 changes: 1 addition & 1 deletion lib/AuthManagement/AuthManagementWsdlClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class AuthManagementWsdlClass extends stdClass implements ArrayAccess,Iterator,C
* Constant to define the default WSDL URI
* @var string
*/
const VALUE_WSDL_URL = 'https://demo.hosted.panopto.com/Panopto/PublicAPI/4.2/Auth.svc?wsdl';
const VALUE_WSDL_URL = 'https://demo.hosted.panopto.com/Panopto/PublicAPI/4.2/Auth.svc?singlewsdl';
/**
* Option key to define WSDL login
* @var string
Expand Down
4 changes: 2 additions & 2 deletions lib/AuthManagement/sample-authmanagement.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Test with AuthManagement for 'https://demo.hosted.panopto.com/Panopto/PublicAPI/4.2/Auth.svc?wsdl'
* Test with AuthManagement for 'https://demo.hosted.panopto.com/Panopto/PublicAPI/4.2/Auth.svc?singlewsdl'
* @package AuthManagement
* @author WsdlToPhp Team <[email protected]>
* @version 20150429-01
Expand All @@ -24,7 +24,7 @@
*
* Here is below an example of how you can set the array:
* $wsdl = array();
* $wsdl[AuthManagementWsdlClass::WSDL_URL] = 'https://demo.hosted.panopto.com/Panopto/PublicAPI/4.2/Auth.svc?wsdl';
* $wsdl[AuthManagementWsdlClass::WSDL_URL] = 'https://demo.hosted.panopto.com/Panopto/PublicAPI/4.2/Auth.svc?singlewsdl';
* $wsdl[AuthManagementWsdlClass::WSDL_CACHE_WSDL] = WSDL_CACHE_NONE;
* $wsdl[AuthManagementWsdlClass::WSDL_TRACE] = true;
* $wsdl[AuthManagementWsdlClass::WSDL_LOGIN] = 'myLogin';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,25 @@ class SessionManagementEnumSessionSortField extends SessionManagementWsdlClass
* @return string 'Relevance'
*/
const VALUE_RELEVANCE = 'Relevance';
/**
* Constant for value 'Order'
* @return string 'Order'
*/
const VALUE_ORDER = 'Order';
/**
* Return true if value is allowed
* @uses SessionManagementEnumSessionSortField::VALUE_NAME
* @uses SessionManagementEnumSessionSortField::VALUE_DATE
* @uses SessionManagementEnumSessionSortField::VALUE_DURATION
* @uses SessionManagementEnumSessionSortField::VALUE_STATE
* @uses SessionManagementEnumSessionSortField::VALUE_RELEVANCE
* @uses SessionManagementEnumSessionSortField::VALUE_ORDER
* @param mixed $_value value
* @return bool true|false
*/
public static function valueIsValid($_value)
{
return in_array($_value,array(SessionManagementEnumSessionSortField::VALUE_NAME,SessionManagementEnumSessionSortField::VALUE_DATE,SessionManagementEnumSessionSortField::VALUE_DURATION,SessionManagementEnumSessionSortField::VALUE_STATE,SessionManagementEnumSessionSortField::VALUE_RELEVANCE));
return in_array($_value,array(SessionManagementEnumSessionSortField::VALUE_NAME,SessionManagementEnumSessionSortField::VALUE_DATE,SessionManagementEnumSessionSortField::VALUE_DURATION,SessionManagementEnumSessionSortField::VALUE_STATE,SessionManagementEnumSessionSortField::VALUE_RELEVANCE,SessionManagementEnumSessionSortField::VALUE_ORDER));
}
/**
* Method returning the class name
Expand Down
2 changes: 1 addition & 1 deletion lib/SessionManagement/SessionManagementWsdlClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class SessionManagementWsdlClass extends stdClass implements ArrayAccess,Iterato
* Constant to define the default WSDL URI
* @var string
*/
const VALUE_WSDL_URL = 'https://demo.hosted.panopto.com/Panopto/PublicAPI/4.6/SessionManagement.svc?wsdl';
const VALUE_WSDL_URL = 'https://demo.hosted.panopto.com/Panopto/PublicAPI/4.6/SessionManagement.svc?singlewsdl';
/**
* Option key to define WSDL login
* @var string
Expand Down
4 changes: 2 additions & 2 deletions lib/SessionManagement/sample-sessionmanagement.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Test with SessionManagement for 'https://demo.hosted.panopto.com/Panopto/PublicAPI/4.6/SessionManagement.svc?wsdl'
* Test with SessionManagement for 'https://demo.hosted.panopto.com/Panopto/PublicAPI/4.6/SessionManagement.svc?singlewsdl'
* @package SessionManagement
* @author WsdlToPhp Team <[email protected]>
* @version 20150429-01
Expand All @@ -24,7 +24,7 @@
*
* Here is below an example of how you can set the array:
* $wsdl = array();
* $wsdl[SessionManagementWsdlClass::WSDL_URL] = 'https://demo.hosted.panopto.com/Panopto/PublicAPI/4.6/SessionManagement.svc?wsdl';
* $wsdl[SessionManagementWsdlClass::WSDL_URL] = 'https://demo.hosted.panopto.com/Panopto/PublicAPI/4.6/SessionManagement.svc?singlewsdl';
* $wsdl[SessionManagementWsdlClass::WSDL_CACHE_WSDL] = WSDL_CACHE_NONE;
* $wsdl[SessionManagementWsdlClass::WSDL_TRACE] = true;
* $wsdl[SessionManagementWsdlClass::WSDL_LOGIN] = 'myLogin';
Expand Down
4 changes: 2 additions & 2 deletions lib/UserManagement/sample-usermanagement.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* Test with UserManagement for 'https://demo.hosted.panopto.com/Panopto/PublicAPI/4.6/UserManagement.svc?wsdl'
* Test with UserManagement for 'https://demo.hosted.panopto.com/Panopto/PublicAPI/4.6/UserManagement.svc?singlewsdl'
* @package UserManagement
* @author WsdlToPhp Team <[email protected]>
* @version 20150429-01
Expand All @@ -24,7 +24,7 @@
*
* Here is below an example of how you can set the array:
* $wsdl = array();
* $wsdl[UserManagementWsdlClass::WSDL_URL] = 'https://demo.hosted.panopto.com/Panopto/PublicAPI/4.6/UserManagement.svc?wsdl';
* $wsdl[UserManagementWsdlClass::WSDL_URL] = 'https://demo.hosted.panopto.com/Panopto/PublicAPI/4.6/UserManagement.svc?singlewsdl';
* $wsdl[UserManagementWsdlClass::WSDL_CACHE_WSDL] = WSDL_CACHE_NONE;
* $wsdl[UserManagementWsdlClass::WSDL_TRACE] = true;
* $wsdl[UserManagementWsdlClass::WSDL_LOGIN] = 'myLogin';
Expand Down
34 changes: 34 additions & 0 deletions lib/block_panopto_lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@

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

/**
* Send a Javascript alert to the window for the current user to see.
*
* @param string $alertmessage - the message the user is supposed to see.
*/
function panopto_alert_user($alertmessage) {
echo '<script language="javascript">';
echo 'alert("' . $alertmessage . '")';
echo '</script>';
}

/**
* Prepend the instance name to the Moodle course ID to create an external ID for Panopto Focus.
*
Expand Down Expand Up @@ -78,4 +89,27 @@ function panopto_validate_auth_code($payload, $authcode) {
return (panopto_generate_auth_code($payload) == $authcode);
}

/**
* takes an api url, then checks the Panopto config for proxy settings, and returns the relevant serviceparams object.
*
* @param string apiurl
*/
function generate_wsdl_service_params($apiurl) {
$serviceparams = array('wsdl_url' => $apiurl);

// Check to see if the user set any proxy options
$proxyhost = get_config('block_panopto', 'wsdl_proxy_host');
$proxyport = get_config('block_panopto', 'wsdl_proxy_port');

if (isset($proxyhost) && !empty($proxyhost)) {
$serviceparams['wsdl_proxy_host'] = $proxyhost;
}

if (isset($proxyport) && !empty($proxyport)) {
$serviceparams['wsdl_proxy_port'] = $proxyport;
}

return $serviceparams;
}

/* End of file block_panopto_lib.php */
49 changes: 35 additions & 14 deletions lib/panopto_auth_soap_client.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
*/
require_once(dirname(__FILE__) . '/AuthManagement/AuthManagementAutoload.php');
require_once(dirname(__FILE__) . '/panopto_data.php');
require_once(dirname(__FILE__) . '/block_panopto_lib.php');

class panopto_auth_soap_client extends SoapClient {

Expand All @@ -44,9 +45,19 @@ class panopto_auth_soap_client extends SoapClient {
private $authparam;

/**
* @var array $apiurl
* @var array $serviceparams the url used to get the service wsdl, as well as optional proxy options
*/
private $apiurl;
private $serviceparams;

/**
* @var AuthManagementServiceReport authmanagementservicereport object used to call the auth report service
*/
private $authmanagementservicereport;

/**
* @var AuthManagementServiceGet authmanagementserviceget object used to call the auth get service
*/
private $authmanagementserviceget;

/**
* main constructor
Expand All @@ -57,24 +68,31 @@ class panopto_auth_soap_client extends SoapClient {
*/
public function __construct($servername, $apiuseruserkey, $apiuserauthcode) {

// Instantiate SoapClient in WSDL mode.
// Set call timeout to 5 minutes.
$this->apiurl = 'https://'. $servername . '/Panopto/PublicAPI/4.2/Auth.svc?wsdl';

// Cache web service credentials for all calls requiring authentication.
$this->authparam = new AuthManagementStructAuthenticationInfo($apiuserauthcode, null, $apiuseruserkey);
$this->authparam = new AuthManagementStructAuthenticationInfo(
$apiuserauthcode,
null,
$apiuseruserkey
);

$this->serviceparams = generate_wsdl_service_params('https://'. $servername . '/Panopto/PublicAPI/4.2/Auth.svc?singlewsdl');

}

/**
* gets the version of the server.
*/
public function get_server_version() {
$returnvalue = false;
$authmanagementserviceget = new AuthManagementServiceGet(array('wsdl_url' => $this->apiurl));
if ($authmanagementserviceget->GetServerVersion()) {
$returnvalue = $authmanagementserviceget->getResult()->GetServerVersionResult;

if (!isset($this->authmanagementserviceget)) {
$this->authmanagementserviceget = new AuthManagementServiceGet($this->serviceparams);
}

if ($this->authmanagementserviceget->GetServerVersion()) {
$returnvalue = $this->authmanagementserviceget->getResult()->GetServerVersionResult;
} else {
panopto_data::print_log(print_r($authmanagementserviceget->getLastError(), true));
panopto_data::print_log(print_r($this->authmanagementserviceget->getLastError(), true));
}
return $returnvalue;
}
Expand All @@ -88,18 +106,21 @@ public function get_server_version() {
public function report_integration_info($idprovidername, $moduleversion, $targetplatformversion) {
$returnvalue = false;

$authmanagementservicereport = new AuthManagementServiceReport(array('wsdl_url' => $this->apiurl));
if (!isset($this->authmanagementservicereport)) {
$this->authmanagementservicereport = new AuthManagementServiceReport($this->serviceparams);
}

$reportparams = new AuthManagementStructReportIntegrationInfo(
$this->authparam,
strval($idprovidername),
strval($moduleversion),
strval($targetplatformversion)
);

if ($authmanagementservicereport->ReportIntegrationInfo($reportparams)) {
if ($this->authmanagementservicereport->ReportIntegrationInfo($reportparams)) {
$returnvalue = true;
} else {
$lasterror = $authmanagementservicereport->getLastError()['AuthManagementServiceReport::ReportIntegrationInfo'];
$lasterror = $this->authmanagementservicereport->getLastError()['AuthManagementServiceReport::ReportIntegrationInfo'];
panopto_data::print_log(print_r($lasterror, true));
}

Expand Down
Loading

0 comments on commit b4a4074

Please sign in to comment.