Select Git revision
-
Chris Sangwin authored
commit 292bab008c6507b1cd565e293baf8e6ce390bbde Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk> Date: Wed Jun 1 08:13:30 2022 +0100 Update the docs. commit b4330bdfdb24bf85fd6c5feeb84e89fe22613b89 Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk> Date: Wed Jun 1 07:35:37 2022 +0100 Add namespace: further code tidy. commit e1b8ca10386039794fd730fb62dcd59a2f3b096a Merge: b86ea123 e73cd13f Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk> Date: Wed Jun 1 05:13:34 2022 +0100 Merge branch 'jsxgraph_update' of https://github.com/maths/moodle-qtype_stack into jsxgraph_update commit b86ea123b616dd58cb794d81ec71b7931a770ff6 Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk> Date: Wed Jun 1 05:12:36 2022 +0100 Code tidy: add namespace to unit test classes (WIP). commit e73cd13fac2ca4e0b5b057f20438db44a0a1c3e6 Merge: 3b362d45 abe2a2e0 Author: Chris Sangwin <c.j.sangwin@gmail.com> Date: Tue May 31 18:05:39 2022 +0100 Merge pull request #806 from timhunt/fix-behat Update Behat tests to work with 4.0 commit f5f2676bebc040e6f92957063baa8ff15d316f79 Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk> Date: Tue May 31 17:23:49 2022 +0100 Move mariadb test to older moodle. commit abe2a2e0395c8d4dfb80082f406f8c2a63e1a878 Author: Tim Hunt <T.J.Hunt@open.ac.uk> Date: Tue May 31 15:46:53 2022 +0100 Update Behat tests to work with 4.0 commit 3b362d450e7e70a5c9fc5cad1c5fd9f6b5658c33 Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk> Date: Tue May 31 17:10:53 2022 +0100 WIP code tidy. commit 46435f94fbd0cb52371a16839d0d2901df65145d Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk> Date: Tue May 31 16:46:22 2022 +0100 Rebuild JS files. commit 9380fb70fd03da82c739c45e14a4c1652c84b6d8 Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk> Date: Tue May 31 16:02:33 2022 +0100 WIP code tidy: add coverage information to test classes. commit 4466fbca411d34c718f14712e02185ddad32c8c9 Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk> Date: Tue May 31 15:59:22 2022 +0100 Code tidy: revert attempt to add namespace and coverage. commit f5114460a758431724d9b814d7b58f9253bfb6c7 Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk> Date: Tue May 31 15:45:23 2022 +0100 WIP: code tidy, adding namespace to test files. commit 742fc9de1a2036054f64526324a0adbd7b3af176 Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk> Date: Tue May 31 15:12:13 2022 +0100 Code tidy. commit b4d67fb5cd712c0e4fb8f09ccab93f643fc82d76 Author: Chris Sangwin <c.j.sangwin@gmail.com> Date: Tue May 31 13:29:10 2022 +0100 Update Updating_JSXGraph.md Update the docs. commit 9ac55ec2b7837ed2fb7efe6d831b9cdd0d0485d0 Author: Michael Kallweit <michael.kallweit@rub.de> Date: Tue May 31 12:22:12 2022 +0200 Added source map for minified jsxgraph commit 79df67068d06769f7140ec0b5f59e39faaa4fa83 Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk> Date: Tue May 31 08:00:46 2022 +0100 Rebuild input.min.js.map, and update the docs. commit d63364e5dfe6d5bf3d9ae52017b00817a57937db Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk> Date: Mon May 30 22:26:52 2022 +0100 Postpone unit test to dev branch. commit 2f946df443f92855be5c15ef7e42df4e3374c8d1 Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk> Date: Mon May 30 21:43:06 2022 +0100 Move commented out code to future plans. commit 3b1bfed1079cba839318e64818975949e751f534 Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk> Date: Mon May 30 20:53:23 2022 +0100 Code tidy. commit f20be9a1a9e1766444b84fbec02eb1a5d8f871cd Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk> Date: Mon May 30 20:22:17 2022 +0100 Update google-ci config to fix unit tests, remove references to travis and tidy. commit ef99433f3924c613e8c1702f58fa9b45a041e521 Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk> Date: Mon May 30 18:13:04 2022 +0100 Adopt moodle-ci. commit e37b68a67832bf396bd5548683a76a646165cce9 Merge: 887e5dfb fccc53de Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk> Date: Mon May 30 16:26:39 2022 +0100 Merge branch 'jsxgraph_update' of https://github.com/maths/moodle-qtype_stack into jsxgraph_update commit 887e5dfbc600c84a2ac514f7ab7a485098d554d4 Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk> Date: Mon May 30 16:26:30 2022 +0100 Bump version number. commit fccc53de573d68ad5ebcb4ff44ef57cd40d6da6a Author: Michael Kallweit <michael.kallweit@rub.de> Date: Mon May 30 17:16:04 2022 +0200 Minor text changes commit e69739ed5fa7b4c388eddbc55c5bb79b84b23b8a Author: Michael Kallweit <michael.kallweit@rub.de> Date: Mon May 30 17:06:44 2022 +0200 Added doc on how to update jsxgraph commit e3c44f236a94fafcf9fccc123a6bab3e8b1e9099 Merge: dc422f00 869d228b Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk> Date: Mon May 30 15:55:18 2022 +0100 Merge branch 'jsxgraph_update' of https://github.com/maths/moodle-qtype_stack into jsxgraph_update commit dc422f007e33773482b4fbbbc36aced10b0b0de8 Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk> Date: Mon May 30 15:54:27 2022 +0100 Prepare for the 4.3.11 release. commit 869d228b0989dc25054d2103eb6e0cb446289c16 Author: Michael Kallweit <michael.kallweit@rub.de> Date: Mon May 30 16:38:03 2022 +0200 Added minified file for jsxgraph 1.4.4 commit bbcc9f0be0f6f09298dc13f7dfd1b12615295cf0 Author: Michael Kallweit <michael.kallweit@rub.de> Date: Mon May 30 14:21:43 2022 +0200 Update JSXGraph to 1.4.4
Chris Sangwin authoredcommit 292bab008c6507b1cd565e293baf8e6ce390bbde Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk> Date: Wed Jun 1 08:13:30 2022 +0100 Update the docs. commit b4330bdfdb24bf85fd6c5feeb84e89fe22613b89 Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk> Date: Wed Jun 1 07:35:37 2022 +0100 Add namespace: further code tidy. commit e1b8ca10386039794fd730fb62dcd59a2f3b096a Merge: b86ea123 e73cd13f Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk> Date: Wed Jun 1 05:13:34 2022 +0100 Merge branch 'jsxgraph_update' of https://github.com/maths/moodle-qtype_stack into jsxgraph_update commit b86ea123b616dd58cb794d81ec71b7931a770ff6 Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk> Date: Wed Jun 1 05:12:36 2022 +0100 Code tidy: add namespace to unit test classes (WIP). commit e73cd13fac2ca4e0b5b057f20438db44a0a1c3e6 Merge: 3b362d45 abe2a2e0 Author: Chris Sangwin <c.j.sangwin@gmail.com> Date: Tue May 31 18:05:39 2022 +0100 Merge pull request #806 from timhunt/fix-behat Update Behat tests to work with 4.0 commit f5f2676bebc040e6f92957063baa8ff15d316f79 Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk> Date: Tue May 31 17:23:49 2022 +0100 Move mariadb test to older moodle. commit abe2a2e0395c8d4dfb80082f406f8c2a63e1a878 Author: Tim Hunt <T.J.Hunt@open.ac.uk> Date: Tue May 31 15:46:53 2022 +0100 Update Behat tests to work with 4.0 commit 3b362d450e7e70a5c9fc5cad1c5fd9f6b5658c33 Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk> Date: Tue May 31 17:10:53 2022 +0100 WIP code tidy. commit 46435f94fbd0cb52371a16839d0d2901df65145d Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk> Date: Tue May 31 16:46:22 2022 +0100 Rebuild JS files. commit 9380fb70fd03da82c739c45e14a4c1652c84b6d8 Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk> Date: Tue May 31 16:02:33 2022 +0100 WIP code tidy: add coverage information to test classes. commit 4466fbca411d34c718f14712e02185ddad32c8c9 Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk> Date: Tue May 31 15:59:22 2022 +0100 Code tidy: revert attempt to add namespace and coverage. commit f5114460a758431724d9b814d7b58f9253bfb6c7 Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk> Date: Tue May 31 15:45:23 2022 +0100 WIP: code tidy, adding namespace to test files. commit 742fc9de1a2036054f64526324a0adbd7b3af176 Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk> Date: Tue May 31 15:12:13 2022 +0100 Code tidy. commit b4d67fb5cd712c0e4fb8f09ccab93f643fc82d76 Author: Chris Sangwin <c.j.sangwin@gmail.com> Date: Tue May 31 13:29:10 2022 +0100 Update Updating_JSXGraph.md Update the docs. commit 9ac55ec2b7837ed2fb7efe6d831b9cdd0d0485d0 Author: Michael Kallweit <michael.kallweit@rub.de> Date: Tue May 31 12:22:12 2022 +0200 Added source map for minified jsxgraph commit 79df67068d06769f7140ec0b5f59e39faaa4fa83 Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk> Date: Tue May 31 08:00:46 2022 +0100 Rebuild input.min.js.map, and update the docs. commit d63364e5dfe6d5bf3d9ae52017b00817a57937db Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk> Date: Mon May 30 22:26:52 2022 +0100 Postpone unit test to dev branch. commit 2f946df443f92855be5c15ef7e42df4e3374c8d1 Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk> Date: Mon May 30 21:43:06 2022 +0100 Move commented out code to future plans. commit 3b1bfed1079cba839318e64818975949e751f534 Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk> Date: Mon May 30 20:53:23 2022 +0100 Code tidy. commit f20be9a1a9e1766444b84fbec02eb1a5d8f871cd Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk> Date: Mon May 30 20:22:17 2022 +0100 Update google-ci config to fix unit tests, remove references to travis and tidy. commit ef99433f3924c613e8c1702f58fa9b45a041e521 Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk> Date: Mon May 30 18:13:04 2022 +0100 Adopt moodle-ci. commit e37b68a67832bf396bd5548683a76a646165cce9 Merge: 887e5dfb fccc53de Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk> Date: Mon May 30 16:26:39 2022 +0100 Merge branch 'jsxgraph_update' of https://github.com/maths/moodle-qtype_stack into jsxgraph_update commit 887e5dfbc600c84a2ac514f7ab7a485098d554d4 Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk> Date: Mon May 30 16:26:30 2022 +0100 Bump version number. commit fccc53de573d68ad5ebcb4ff44ef57cd40d6da6a Author: Michael Kallweit <michael.kallweit@rub.de> Date: Mon May 30 17:16:04 2022 +0200 Minor text changes commit e69739ed5fa7b4c388eddbc55c5bb79b84b23b8a Author: Michael Kallweit <michael.kallweit@rub.de> Date: Mon May 30 17:06:44 2022 +0200 Added doc on how to update jsxgraph commit e3c44f236a94fafcf9fccc123a6bab3e8b1e9099 Merge: dc422f00 869d228b Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk> Date: Mon May 30 15:55:18 2022 +0100 Merge branch 'jsxgraph_update' of https://github.com/maths/moodle-qtype_stack into jsxgraph_update commit dc422f007e33773482b4fbbbc36aced10b0b0de8 Author: Chris Sangwin <C.J.Sangwin@ed.ac.uk> Date: Mon May 30 15:54:27 2022 +0100 Prepare for the 4.3.11 release. commit 869d228b0989dc25054d2103eb6e0cb446289c16 Author: Michael Kallweit <michael.kallweit@rub.de> Date: Mon May 30 16:38:03 2022 +0200 Added minified file for jsxgraph 1.4.4 commit bbcc9f0be0f6f09298dc13f7dfd1b12615295cf0 Author: Michael Kallweit <michael.kallweit@rub.de> Date: Mon May 30 14:21:43 2022 +0200 Update JSXGraph to 1.4.4
connect_class.php 11.10 KiB
<?php
/**
* connection class
*
* This class communicates with an adobe connect server making REST calls
* to access the Adobe Connect API
*/
/**
* @package mod
* @subpackage adobeconnect
* @author Akinsaya Delamarre (adelamarre@remote-learner.net)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class connect_class {
var $_serverurl;
var $_serverport;
var $_username;
var $_password;
var $_cookie;
var $_xmlrequest;
var $_xmlresponse;
var $_apicall;
var $_connection;
var $_https;
public function __construct($serverurl = '', $serverport = 80,
$username = '', $password = '',
$cookie = '', $https = false) {
$this->_serverurl = $serverurl;
$this->_serverport = $serverport;
$this->_username = $username;
$this->_password = $password;
$this->_cookie = $cookie;
$this->_https = $https;
}
/**
* Accessor methods
*/
public function set_serverport($serverport = '') {
$this->_serverport = $serverport;
}
public function set_serverurl($serverurl = '') {
$this->_serverurl = $serverurl;
}
public function set_username($username = '') {
$this->_username = $username;
}
public function set_password($password = '') {
$this->_password = $password;
}
public function set_cookie($cookie = '') {
$this->_cookie = $cookie;
}
public function set_xmlrequest($xml = '') {
$this->_xmlrequest = $xml;
}
public function set_connection($connection = 0) {
$this->_connection = $connection;
}
public function set_https($https = false) {
$this->_https = $https;
}
public function get_serverurl() {
return $this->_serverurl;
}
public function get_username() {
return $this->_username;
}
public function get_password() {
return $this->_password;
}
public function get_cookie() {
return $this->_cookie;
}
public function get_connection() {
return $this->_connection;
}
public function get_serverport() {
return $this->_serverport;
}
private function get_default_header() {
return array('Content-Type: text/xml');
}
public function get_https() {
return $this->_https;
}
// DFNVC
public function get_header() {
return $this->_header;
}
/**
* Adds or replaces http:// with https:// for secured connections
* @return string - server URL with the HTTPS protocol
*/
private function make_https() {
$serverurl = $this->_serverurl;
$httpsexists = strpos($this->_serverurl, 'https://');
$httpexists = strpos($this->_serverurl, 'http://');
if (false === $httpsexists and false !== $httpexists) {
$serverurl = str_replace('http://', 'https://', $this->_serverurl);
} elseif (false === $httpsexists) {
$serverurl = 'https://' . $this->_serverurl;
}
return $serverurl;
}
/**
* Posts XML to the Adobe Connect server and returns the results
* @param int $return_header 1 to include the response header, 0 to not
* @param array $add_header an array of headers to add to the request
*/
public function send_request($return_header = 0, $add_header = array(), $stop = false) {
global $CFG;
$ch = curl_init();
$serverurl = $this->_serverurl;
if ($this->_https) {
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
$serverurl = $this->make_https();
}
if ($stop) {
// echo $this->_serverurl . '?session='. $this->_cookie; die();
// https://example.com/api/xml?action=principal=list
curl_setopt($ch, CURLOPT_URL, $serverurl/* . '?action=login&external-auth=use'*/);
} else {
$querystring = (!empty($this->_cookie)) ? '?session='. $this->_cookie : '';
curl_setopt($ch, CURLOPT_URL, $serverurl . $querystring);
}
// Connect through a proxy if Moodle config says we should
if(isset($CFG->proxyhost)) {
curl_setopt($ch, CURLOPT_PROXY, $CFG->proxyhost);
if(isset($CFG->proxyport)) {
curl_setopt($ch, CURLOPT_PROXYPORT, $CFG->proxyport);
}
}
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $this->_xmlrequest);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch, CURLOPT_PORT, $this->_serverport);
$header = $this->get_default_header();
$header = array_merge($header, $add_header);
// DFNVC
// $header = array("Hugo: test");
$this->_header = $header;
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
// Include header from response
//curl_setopt($ch, CURLOPT_HEADER, $return_header);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
/**
* Sends the HTTP header login request and returns the response xml
* @param string username username to use for header x-user-id
*/
/* DFNVC */
/* public function request_http_header_login($return_header = 0, $username = '', $stop = false) {
global $CFG;
$hearder = array();
$this->create_http_head_login_xml();
// The first parameter is 1 because we want to include the response header
// to extract the session cookie
if (!empty($username)) {
$hearder = array("$CFG->adobeconnect_admin_httpauth: " . $username);
}
$this->_xmlresponse = $this->send_request($return_header, $hearder, $stop);
$this->set_session_cookie($this->_xmlresponse);
return $this->_xmlresponse;
}
*/
public function create_request($params = array(), $sentrequest = true) {
if (empty($params)) {
return false;
}
@date_default_timezone_set("GMT");
$writer = new XMLWriter();
$writer->openMemory();
$writer->startDocument('1.0', 'UTF-8');
$writer->startElement('params');
foreach($params as $key => $data) {
$writer->startElement('param');
$writer->writeAttribute('name', $key);
$writer->text($data);
$writer->endElement();
}
$writer->endElement();
$writer->endDocument();
$this->_xmlrequest = $writer->outputMemory();
if ($sentrequest) {
$this->_xmlresponse = $this->send_request();
}
}
/**
* Call to common-info
* @param nothing
* @return nothing
*/
public function set_session_cookie($data) {
$sessionval = false;
$sessionstart = strpos($data, 'BREEZESESSION=');
if (false !== $sessionstart) {
$sessionend = strpos($data, ';');
// $sessionend = strpos($data, 'Expires:');
$sessionlength = strlen('BREEZESESSION=');
$sessionvallength = $sessionend - ($sessionstart + $sessionlength);
$sessionval = substr($data, $sessionstart+$sessionlength, $sessionvallength);
}
$this->_cookie = $sessionval;
return $sessionval;
}
/**
* Parses through xml and looks for the 'status' parameter
* and return true if the 'code' attribute equals 'ok' otherwise
* false is returned
* @param string xml the xml to parse
*/
public function read_status_xml() {
$reader = new XMLReader();
$reader->XML($this->_xmlresponse, 'UTF-8');
$return = false;
while ($reader->read()) {
if (0 == strcmp($reader->name, 'status')) {
if (1 == $reader->nodeType) {
if (0 == strcmp('ok', $reader->getAttribute('code'))) {
$return = true;
}
}
}
}
$reader->close();
return $return;
}
/**
* Parses through xml and looks for the 'cookie' parameter
* @param string $xml the xml to parse through
* @return string $sessoin returns the session id
*/
public function read_cookie_xml($xml = '') {
global $CFG, $USER, $COURSE;
if (empty($xml)) {
if (is_siteadmin($USER->id)) {
notice(get_string('adminemptyxml', 'adobeconnect'),
$CFG->wwwroot . '/admin/settings.php?section=modsettingadobeconnect');
} else {
notice(get_string('emptyxml', 'adobeconnect'),
'', $COURSE);
}
}
$session = false;
// $accountid = false;
$reader = new XMLReader();
$reader->XML($xml, 'UTF-8');
while ($reader->read()) {
if (0 == strcmp($reader->name, 'cookie')) {
if (1 == $reader->nodeType) {
$session = $reader->readString();
}
}
}
$reader->close();
$this->_cookie = $session;
return $session;
}
public function response_to_object() {
$xml = new SimpleXMLElement($this->_xmlresponse);
return $xml;
}
public function call_success() {
global $CFG, $USER, $COURSE;
if (empty($this->_xmlresponse)) {
if (is_siteadmin($USER->id)) {
notice(get_string('adminemptyxml', 'adobeconnect'),
$CFG->wwwroot . '/admin/settings.php?section=modsettingadobeconnect');
} else {
notice(get_string('emptyxml', 'adobeconnect'),
'', $COURSE);
}
}
$xml = new SimpleXMLElement($this->_xmlresponse);
if (0 == strcmp('ok', $xml->status[0]['code'])) {
return true;
} else {
return false;
}
}
private function create_http_head_login_xml() {
@date_default_timezone_set("GMT");
$writer = new XMLWriter();
$writer->openMemory();
$writer->startDocument('1.0', 'UTF-8');
$writer->startElement('params');
$writer->startElement('param');
$writer->writeAttribute('name', 'action');
$writer->text('login');
$writer->endElement();
$writer->startElement('param');
$writer->writeAttribute('name', 'external-auth');
$writer->text('use');
$writer->endElement();
$writer->endElement();
$writer->endDocument();
$this->_xmlrequest = $writer->outputMemory();
}
}