Skip to content

Commit

Permalink
MDL-81199 core_ltix: move return.php to core
Browse files Browse the repository at this point in the history
  • Loading branch information
ismael-texidor authored and snake committed May 10, 2024
1 parent 68a8490 commit fdc6aa9
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 33 deletions.
8 changes: 8 additions & 0 deletions lang/en/ltix.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,13 @@
$string['keytype_keyset'] = 'Keyset URL';
$string['keytype_rsa'] = 'RSA key';
$string['lti_administration'] = 'Edit preconfigured tool';
$string['ltix_launch_error'] = 'An error occurred when launching the external tool:';
$string['ltix_launch_error_tool_request'] = '<p>
To submit a request for an administrator to complete the tool configuration, click <a href="{$a->admin_request_url}" target="_top">here</a>.
</p>';
$string['ltix_launch_error_unsigned_help'] = '<p>This error may be a result of a missing consumer key and shared secret for the tool provider.</p>
<p>If you have a consumer key and shared secret, you may enter it when editing the external tool instance (make sure advanced options are visible).</p>
<p>Alternatively, you may <a href="{$a->course_tool_editor}">create a course level tool provider configuration</a>.</p>';
$string['ltiversion'] = 'LTI version';
$string['ltiversion_help'] = 'The version of LTI being used for signing messages and service requests: LTI 1.0/1.1 and LTI 2.0 use the OAuth 1.0A security profile; LTI 1.3.0 uses JWTs.';
$string['ltiunknownserviceapicall'] = 'LTI unknown service API call.';
Expand Down Expand Up @@ -202,6 +209,7 @@
may not require a resource key.';
$string['restricttocategory'] = 'Restrict to category';
$string['restricttocategory_help'] = 'To restrict use of this tool to courses within a category, select the category or categories from the list.';
$string['return_to_course'] = 'Click <a href="{$a->link}" target="_top">here</a> to return to the course.';
$string['secure_icon_url'] = 'Secure icon URL';
$string['secure_icon_url_help'] = 'Similar to the icon URL, but used when the site is accessed securely through SSL. This field is to prevent the browser from displaying a warning about an insecure image.';
$string['secure_launch_url'] = 'Secure tool URL';
Expand Down
1 change: 1 addition & 0 deletions lang/en/role.php
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@
$string['ltix:manage'] = 'Be an instructor when the tool is launched';
$string['ltix:admin'] = 'Be an administrator when the tool is launched';
$string['ltix:viewcoursetools'] = 'View course external tools';
$string['ltix:requesttooladd'] = 'The ability to request the administrator to configure a particular external tool globally.';
$string['mainadmin'] = 'Main administrator';
$string['mainadminset'] = 'Set main admin';
$string['manageadmins'] = 'Manage site administrators';
Expand Down
11 changes: 11 additions & 0 deletions lib/db/access.php
Original file line number Diff line number Diff line change
Expand Up @@ -2793,4 +2793,15 @@
'manager' => CAP_ALLOW
]
],

// The ability to request the administrator to configure a particular
// External tool globally.
'moodle/ltix:requesttooladd' => array(
'captype' => 'write',
'contextlevel' => CONTEXT_COURSE,
'archetypes' => array(
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW
)
)
);
2 changes: 1 addition & 1 deletion ltix/classes/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -2212,7 +2212,7 @@ public static function get_launch_data($instance, $nonce = '', $messagetype = 'b
'sesskey' => sesskey());

// Add the return URL. We send the launch container along to help us avoid frames-within-frames when the user returns.
$url = new \moodle_url('/mod/lti/return.php', $returnurlparams);
$url = new \moodle_url('/ltix/return.php', $returnurlparams);
$returnurl = $url->out(false);

if (isset($typeconfig['forcessl']) && ($typeconfig['forcessl'] == '1')) {
Expand Down
22 changes: 10 additions & 12 deletions mod/lti/return.php → ltix/return.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@
/**
* Handle the return back to Moodle from the tool provider
*
* @package mod_lti
* @package core_ltix
* @copyright Copyright (c) 2011 Moodlerooms Inc. (http://www.moodlerooms.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @author Chris Scribner
*/

require_once('../../config.php');
require_once($CFG->dirroot.'/mod/lti/lib.php');
require_once($CFG->dirroot.'/mod/lti/locallib.php');
require_once('../config.php');
require_once($CFG->dirroot.'/ltix/constants.php');

$courseid = required_param('course', PARAM_INT);
Expand All @@ -51,7 +49,7 @@
require_sesskey();

if (!empty($errormsg) || !empty($msg)) {
$url = new moodle_url('/mod/lti/return.php', array('course' => $courseid));
$url = new moodle_url('/ltix/return.php', array('course' => $courseid));
$PAGE->set_url($url);

$pagetitle = strip_tags($course->shortname);
Expand All @@ -72,7 +70,7 @@
}

if (!empty($errormsg)) {
echo get_string('lti_launch_error', 'lti');
echo get_string('ltix_launch_error', 'core_ltix');

p($errormsg);

Expand All @@ -83,17 +81,17 @@
$links = new stdClass();

if (has_capability('moodle/ltix:addcoursetool', $contextcourse)) {
$coursetooleditor = new moodle_url('mod/lti/coursetools.php', ['id' => $courseid]);
$coursetooleditor = new moodle_url('/ltix/coursetools.php', ['id' => $courseid]);
$links->course_tool_editor = $coursetooleditor->out(false);

echo get_string('lti_launch_error_unsigned_help', 'lti', $links);
echo get_string('ltix_launch_error_unsigned_help', 'core_ltix', $links);
}

if (!empty($lti) && has_capability('mod/lti:requesttooladd', $contextcourse)) {
$adminrequesturl = new moodle_url('/mod/lti/request_tool.php', array('instanceid' => $lti->id, 'sesskey' => sesskey()));
if (!empty($lti) && has_capability('moodle/ltix:requesttooladd', $contextcourse)) {
$adminrequesturl = new moodle_url('/ltix/request_tool.php', array('instanceid' => $lti->id, 'sesskey' => sesskey()));
$links->admin_request_url = $adminrequesturl->out(false);

echo get_string('lti_launch_error_tool_request', 'lti', $links);
echo get_string('ltix_launch_error_tool_request', 'core_ltix', $links);
}
}

Expand Down Expand Up @@ -126,7 +124,7 @@
</script>
";

$clickhere = get_string('return_to_course', 'lti', (object)array('link' => $url));
$clickhere = get_string('return_to_course', 'core_ltix', (object)array('link' => $url));

$noscript = "
<noscript>
Expand Down
16 changes: 5 additions & 11 deletions mod/lti/db/access.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,6 @@
),
'clonepermissionsfrom' => 'mod/lti:addinstance',
),

// The ability to request the administrator to configure a particular
// External tool globally.
'mod/lti:requesttooladd' => array(
'captype' => 'write',
'contextlevel' => CONTEXT_COURSE,
'archetypes' => array(
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW
)
)
);
$deprecatedcapabilities = [
// The ability to add a manual instance (i.e. not from a preconfigured tool) to the course.
Expand All @@ -99,4 +88,9 @@
'message' => 'This capability has been replaced by an equivalent core capability as part of moving large parts of mod_lti'.
' to core.'
],
'mod/lti:requesttooladd' => [
'replacement' => 'moodle/ltix:requesttooladd',
'message' => 'This capability has been replaced by an equivalent core capability as part of moving large parts of mod_lti'.
' to core.'
],
];
1 change: 1 addition & 0 deletions mod/lti/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ function xmldb_lti_upgrade($oldversion) {
'mod/lti:manage' => 'moodle/ltix:manage',
'mod/lti:addcoursetool' => 'moodle/ltix:addcoursetool',
'mod/lti:addpreconfiguredinstance' => 'moodle/ltix:viewcoursetools',
'mod/lti:requesttooladd' => 'moodle/ltix:requesttooladd',
];
foreach ($capmapping as $oldcap => $newcap) {

Expand Down
4 changes: 4 additions & 0 deletions mod/lti/lang/en/deprecated.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,7 @@ courseexternaltoolsnoviewpermissions,mod_lti
courseexternaltooliconalt,mod_lti
courseexternaltools,mod_lti
courseexternaltoolsinfo,mod_lti
return_to_course,mod_lti
lti_launch_error,mod_lti
lti_launch_error_tool_request,mod_lti
lti_launch_error_unsigned_help,mod_lti
16 changes: 8 additions & 8 deletions mod/lti/lang/en/lti.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,13 +267,6 @@
$string['ltisettings'] = 'LTI settings';
$string['lti_administration'] = 'Edit preconfigured tool';
$string['lti_errormsg'] = 'The tool returned the following error message: "{$a}"';
$string['lti_launch_error'] = 'An error occurred when launching the external tool:';
$string['lti_launch_error_tool_request'] = '<p>
To submit a request for an administrator to complete the tool configuration, click <a href="{$a->admin_request_url}" target="_top">here</a>.
</p>';
$string['lti_launch_error_unsigned_help'] = '<p>This error may be a result of a missing consumer key and shared secret for the tool provider.</p>
<p>If you have a consumer key and shared secret, you may enter it when editing the external tool instance (make sure advanced options are visible).</p>
<p>Alternatively, you may <a href="{$a->course_tool_editor}">create a course level tool provider configuration</a>.</p>';
$string['lti_tool_request_added'] = 'Tool configuration request successfully submitted. You may need to contact an administrator to complete the tool configuration.';
$string['lti_tool_request_existing'] = 'A tool configuration for the tool domain has already been submitted.';
$string['ltiunknownserviceapicall'] = 'LTI unknown service API call.';
Expand Down Expand Up @@ -446,7 +439,6 @@
$string['resourceurl'] = 'Resource URL';
$string['restricttocategory'] = 'Restrict to category';
$string['restricttocategory_help'] = 'To restrict use of this tool to courses within a category, select the category or categories from the list.';
$string['return_to_course'] = 'Click <a href="{$a->link}" target="_top">here</a> to return to the course.';
$string['saveallfeedback'] = 'Save all my feedback';
$string['search:activity'] = 'External tool - activity information';
$string['secure_icon_url'] = 'Secure icon URL';
Expand Down Expand Up @@ -609,3 +601,11 @@
$string['courseexternaltooliconalt'] = 'Icon for {$a}';
$string['courseexternaltools'] = 'LTI External tools';
$string['courseexternaltoolsinfo'] = 'LTI External tools are add-on apps you can integrate into your course, such as interactive content or assessments. Your students can access and use them without leaving your course.';
$string['return_to_course'] = 'Click <a href="{$a->link}" target="_top">here</a> to return to the course.';
$string['lti_launch_error'] = 'An error occurred when launching the external tool:';
$string['lti_launch_error_tool_request'] = '<p>
To submit a request for an administrator to complete the tool configuration, click <a href="{$a->admin_request_url}" target="_top">here</a>.
</p>';
$string['lti_launch_error_unsigned_help'] = '<p>This error may be a result of a missing consumer key and shared secret for the tool provider.</p>
<p>If you have a consumer key and shared secret, you may enter it when editing the external tool instance (make sure advanced options are visible).</p>
<p>Alternatively, you may <a href="{$a->course_tool_editor}">create a course level tool provider configuration</a>.</p>';
2 changes: 1 addition & 1 deletion mod/lti/request_tool.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

require_sesskey();

require_capability('mod/lti:requesttooladd', context_course::instance($lti->course));
require_capability('moodle/ltix:requesttooladd', context_course::instance($lti->course));

$baseurl = \core_ltix\helper::get_domain_from_url($lti->toolurl);

Expand Down

0 comments on commit fdc6aa9

Please sign in to comment.