Updates to get the plugin to work side-by-side with the basicLTI plugin
This commit is contained in:
+4
-2
@@ -54,13 +54,15 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
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 {
|
||||
|
||||
@@ -54,6 +54,8 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
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');
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
|
||||
+86
-3
@@ -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 .= '<div><a style="margin-top:.25em" href="'.$CFG->wwwroot.'/mod/lti/typessettings.php?action=add&sesskey='.$USER->sesskey.'">'.get_string('addtype', 'lti').'</a></div>';
|
||||
}
|
||||
|
||||
if (!empty($tools)) {
|
||||
$html .= <<<HTML
|
||||
<div id="{$id}_container" style="margin-top:.5em;margin-bottom:.5em">
|
||||
<table id="{$id}_tools">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>$typename</th>
|
||||
<th>$baseurl</th>
|
||||
<th>$createdon</th>
|
||||
<th>$action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
HTML;
|
||||
|
||||
foreach ($tools as $type) {
|
||||
$date = userdate($type->timecreated);
|
||||
$accept = get_string('accept', 'lti');
|
||||
$update = get_string('update', 'lti');
|
||||
$delete = get_string('delete', 'lti');
|
||||
|
||||
$accepthtml = <<<HTML
|
||||
<a class="editing_accept" href="{$CFG->wwwroot}/mod/lti/typessettings.php?action=accept&id={$type->id}&sesskey={$USER->sesskey}&tab={$id}" title="{$accept}">
|
||||
<img class="iconsmall" alt="{$accept}" src="{$CFG->wwwroot}/pix/t/clear.gif"/>
|
||||
</a>
|
||||
HTML;
|
||||
|
||||
$deleteaction = 'delete';
|
||||
|
||||
if($type->state == LTI_TOOL_STATE_CONFIGURED){
|
||||
$accepthtml = '';
|
||||
}
|
||||
|
||||
if($type->state != LTI_TOOL_STATE_REJECTED) {
|
||||
$deleteaction = 'reject';
|
||||
$delete = get_string('reject', 'lti');
|
||||
}
|
||||
|
||||
$html .= <<<HTML
|
||||
<tr>
|
||||
<td>
|
||||
{$type->name}
|
||||
</td>
|
||||
<td>
|
||||
{$type->baseurl}
|
||||
</td>
|
||||
<td>
|
||||
{$date}
|
||||
</td>
|
||||
<td align="center">
|
||||
{$accepthtml}
|
||||
<a class="editing_update" href="{$CFG->wwwroot}/mod/lti/typessettings.php?action=update&id={$type->id}&sesskey={$USER->sesskey}&tab={$id}" title="{$update}">
|
||||
<img class="iconsmall" alt="{$update}" src="{$CFG->wwwroot}/pix/t/edit.gif"/>
|
||||
</a>
|
||||
<a class="editing_delete" href="{$CFG->wwwroot}/mod/lti/typessettings.php?action={$deleteaction}&id={$type->id}&sesskey={$USER->sesskey}&tab={$id}" title="{$delete}">
|
||||
<img class="iconsmall" alt="{$delete}" src="{$CFG->wwwroot}/pix/t/delete.gif"/>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
HTML;
|
||||
}
|
||||
$html .= '</table></div>';
|
||||
} 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
|
||||
|
||||
@@ -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){
|
||||
|
||||
@@ -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 .= '<div><a style="margin-top:.25em" href="'.$CFG->wwwroot.'/mod/lti/typessettings.php?action=add&sesskey='.$USER->sesskey.'">'.get_string('addtype', 'lti').'</a></div>';
|
||||
}
|
||||
|
||||
if (!empty($tools)) {
|
||||
$html .= <<<HTML
|
||||
<div id="{$id}_container" style="margin-top:.5em;margin-bottom:.5em">
|
||||
<table id="{$id}_tools">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>$typename</th>
|
||||
<th>$baseurl</th>
|
||||
<th>$createdon</th>
|
||||
<th>$action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
HTML;
|
||||
|
||||
foreach ($tools as $type) {
|
||||
$date = userdate($type->timecreated);
|
||||
$accept = get_string('accept', 'lti');
|
||||
$update = get_string('update', 'lti');
|
||||
$delete = get_string('delete', 'lti');
|
||||
|
||||
$accepthtml = <<<HTML
|
||||
<a class="editing_accept" href="{$CFG->wwwroot}/mod/lti/typessettings.php?action=accept&id={$type->id}&sesskey={$USER->sesskey}&tab={$id}" title="{$accept}">
|
||||
<img class="iconsmall" alt="{$accept}" src="{$CFG->wwwroot}/pix/t/clear.gif"/>
|
||||
</a>
|
||||
HTML;
|
||||
|
||||
$deleteaction = 'delete';
|
||||
|
||||
if($type->state == LTI_TOOL_STATE_CONFIGURED){
|
||||
$accepthtml = '';
|
||||
}
|
||||
|
||||
if($type->state != LTI_TOOL_STATE_REJECTED) {
|
||||
$deleteaction = 'reject';
|
||||
$delete = get_string('reject', 'lti');
|
||||
}
|
||||
|
||||
$html .= <<<HTML
|
||||
<tr>
|
||||
<td>
|
||||
{$type->name}
|
||||
</td>
|
||||
<td>
|
||||
{$type->baseurl}
|
||||
</td>
|
||||
<td>
|
||||
{$date}
|
||||
</td>
|
||||
<td align="center">
|
||||
{$accepthtml}
|
||||
<a class="editing_update" href="{$CFG->wwwroot}/mod/lti/typessettings.php?action=update&id={$type->id}&sesskey={$USER->sesskey}&tab={$id}" title="{$update}">
|
||||
<img class="iconsmall" alt="{$update}" src="{$CFG->wwwroot}/pix/t/edit.gif"/>
|
||||
</a>
|
||||
<a class="editing_delete" href="{$CFG->wwwroot}/mod/lti/typessettings.php?action={$deleteaction}&id={$type->id}&sesskey={$USER->sesskey}&tab={$id}" title="{$delete}">
|
||||
<img class="iconsmall" alt="{$delete}" src="{$CFG->wwwroot}/pix/t/delete.gif"/>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
HTML;
|
||||
}
|
||||
$html .= '</table></div>';
|
||||
} else {
|
||||
$html .= get_string('no_' . $id, 'lti');
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
if ($ADMIN->fulltree) {
|
||||
$configuredtoolshtml = '';
|
||||
$pendingtoolshtml = '';
|
||||
|
||||
Reference in New Issue
Block a user