diff --git a/mod/lti/OAuth.php b/mod/lti/OAuth.php
index 9c9d9637818..47bb8cddf8f 100644
--- a/mod/lti/OAuth.php
+++ b/mod/lti/OAuth.php
@@ -54,13 +54,15 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
+namespace moodle\mod\lti;//Using a namespace as the basicLTI module imports classes with the same names
+
defined('MOODLE_INTERNAL') || die;
$oauth_last_computed_signature = false;
/* Generic exception class
*/
-class OAuthException extends Exception {
+class OAuthException extends \Exception {
// pass
}
@@ -704,7 +706,7 @@ class OAuthUtil {
public static function urlencode_rfc3986($input) {
if (is_array($input)) {
return array_map(array(
- 'OAuthUtil',
+ 'moodle\mod\lti\OAuthUtil',
'urlencode_rfc3986'
), $input);
} else {
diff --git a/mod/lti/OAuthBody.php b/mod/lti/OAuthBody.php
index 757bbf0ad17..514a99957dc 100644
--- a/mod/lti/OAuthBody.php
+++ b/mod/lti/OAuthBody.php
@@ -54,6 +54,8 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
+namespace moodle\mod\lti;//Using a namespace as the basicLTI module imports classes with the same names
+
require_once($CFG->dirroot . '/mod/lti/OAuth.php');
require_once($CFG->dirroot . '/mod/lti/TrivialStore.php');
diff --git a/mod/lti/TrivialStore.php b/mod/lti/TrivialStore.php
index 88940932b0f..afe686c3b8f 100644
--- a/mod/lti/TrivialStore.php
+++ b/mod/lti/TrivialStore.php
@@ -58,6 +58,8 @@
* @license http://www.apache.org/licenses/LICENSE-2.0
*/
+namespace moodle\mod\lti;//Using a namespace as the basicLTI module imports classes with the same names
+
defined('MOODLE_INTERNAL') || die;
/**
diff --git a/mod/lti/locallib.php b/mod/lti/locallib.php
index ac025422c95..60162b3b580 100644
--- a/mod/lti/locallib.php
+++ b/mod/lti/locallib.php
@@ -47,6 +47,8 @@
defined('MOODLE_INTERNAL') || die;
+use moodle\mod\lti as lti;
+
require_once($CFG->dirroot.'/mod/lti/OAuth.php');
define('LTI_URL_DOMAIN_REGEX', '/(?:https?:\/\/)?(?:www\.)?([^\/]+)(?:\/|$)/i');
@@ -240,6 +242,87 @@ function lti_build_request($instance, $typeconfig, $course) {
return $requestparams;
}
+function lti_get_tool_table($tools, $id){
+ global $CFG, $USER;
+ $html = '';
+
+ $typename = get_string('typename', 'lti');
+ $baseurl = get_string('baseurl', 'lti');
+ $action = get_string('action', 'lti');
+ $createdon = get_string('createdon', 'lti');
+
+ if($id == 'lti_configured'){
+ $html .= '
';
+ }
+
+ if (!empty($tools)) {
+ $html .= <<
+ ';
+ } else {
+ $html .= get_string('no_' . $id, 'lti');
+ }
+
+ return $html;
+}
+
/**
* Splits the custom parameters field to the various parameters
*
@@ -823,10 +906,10 @@ function lti_sign_parameters($oldparms, $endpoint, $method, $oauthconsumerkey, $
$testtoken = '';
- $hmacmethod = new OAuthSignatureMethod_HMAC_SHA1();
- $testconsumer = new OAuthConsumer($oauthconsumerkey, $oauthconsumersecret, null);
+ $hmacmethod = new lti\OAuthSignatureMethod_HMAC_SHA1();
+ $testconsumer = new lti\OAuthConsumer($oauthconsumerkey, $oauthconsumersecret, null);
- $accreq = OAuthRequest::from_consumer_and_token($testconsumer, $testtoken, $method, $endpoint, $parms);
+ $accreq = lti\OAuthRequest::from_consumer_and_token($testconsumer, $testtoken, $method, $endpoint, $parms);
$accreq->sign_request($hmacmethod, $testconsumer, $testtoken);
// Pass this back up "out of band" for debugging
diff --git a/mod/lti/servicelib.php b/mod/lti/servicelib.php
index e913aee762e..b3a61682d44 100644
--- a/mod/lti/servicelib.php
+++ b/mod/lti/servicelib.php
@@ -2,6 +2,8 @@
require_once($CFG->dirroot.'/mod/lti/OAuthBody.php');
+use moodle\mod\lti as lti;
+
define('LTI_ITEM_TYPE', 'mod');
define('LTI_ITEM_MODULE', 'lti');
define('LTI_SOURCE', 'mod/lti');
@@ -150,7 +152,7 @@ function lti_verify_message($ltiinstance, $body, $headers = null){
$secret = $ltiinstance->password;
}
- handleOAuthBodyPOST($key, $secret, $body, $headers);
+ lti\handleOAuthBodyPOST($key, $secret, $body, $headers);
}
function lti_verify_sourcedid($ltiinstance, $parsed){
diff --git a/mod/lti/settings.php b/mod/lti/settings.php
index 04331e5bcf5..81940c369d6 100644
--- a/mod/lti/settings.php
+++ b/mod/lti/settings.php
@@ -51,87 +51,6 @@ global $PAGE, $CFG, $SITE;
require_once($CFG->dirroot.'/mod/lti/locallib.php');
-function lti_get_tool_table($tools, $id){
- global $CFG, $USER;
- $html = '';
-
- $typename = get_string('typename', 'lti');
- $baseurl = get_string('baseurl', 'lti');
- $action = get_string('action', 'lti');
- $createdon = get_string('createdon', 'lti');
-
- if($id == 'lti_configured'){
- $html .= '';
- }
-
- if (!empty($tools)) {
- $html .= <<
- ';
- } else {
- $html .= get_string('no_' . $id, 'lti');
- }
-
- return $html;
-}
-
if ($ADMIN->fulltree) {
$configuredtoolshtml = '';
$pendingtoolshtml = '';