Skip to content

Commit

Permalink
MDL-79844 core_ltix: add legacy preconfigured tools, hidden, to admin…
Browse files Browse the repository at this point in the history
… tree
  • Loading branch information
snake committed May 2, 2024
1 parent c5597f2 commit 82a3de4
Showing 1 changed file with 148 additions and 0 deletions.
148 changes: 148 additions & 0 deletions admin/settings/ltix.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,151 @@
/** @var \core\plugininfo\ltixsource $plugin */
$plugin->load_settings($ADMIN, 'ltix', $hassiteconfig);
}

// Now, add the old 'manage preconfigured tools' settings page but mark it hidden.
// It'll be linked to directly from ltix/toolconfigure.php.
$settings = new admin_settingpage('ltisettings', new lang_string('manage_tools', 'core_ltix'), ['moodle/site:config'], true);
$ADMIN->add('ltix', $settings);

// TODO: this section still refers to mod_lti and uses mod_lti strings. We'll need to migrate these but I haven't done that here.
if ($ADMIN->fulltree) {
global $PAGE, $USER;
require_once($CFG->dirroot.'/mod/lti/locallib.php');
require_once($CFG->dirroot.'/ltix/constants.php');

$configuredtoolshtml = '';
$pendingtoolshtml = '';
$rejectedtoolshtml = '';

$active = get_string('active', 'lti');
$pending = get_string('pending', 'lti');
$rejected = get_string('rejected', 'lti');

// Gather strings used for labels in the inline JS.
$PAGE->requires->strings_for_js(
array(
'typename',
'baseurl',
'action',
'createdon'
),
'mod_lti'
);

$types = \core_ltix\helper::filter_get_types(get_site()->id);

$configuredtools = \core_ltix\helper::filter_tool_types($types, LTI_TOOL_STATE_CONFIGURED);

$configuredtoolshtml = \core_ltix\helper::get_tool_table($configuredtools, 'lti_configured');

$pendingtools = \core_ltix\helper::filter_tool_types($types, LTI_TOOL_STATE_PENDING);

$pendingtoolshtml = \core_ltix\helper::get_tool_table($pendingtools, 'lti_pending');

$rejectedtools = \core_ltix\helper::filter_tool_types($types, LTI_TOOL_STATE_REJECTED);

$rejectedtoolshtml = \core_ltix\helper::get_tool_table($rejectedtools, 'lti_rejected');

$tab = optional_param('tab', '', PARAM_ALPHAEXT);
$activeselected = '';
$pendingselected = '';
$rejectedselected = '';
switch ($tab) {
case 'lti_pending':
$pendingselected = 'class="selected"';
break;
case 'lti_rejected':
$rejectedselected = 'class="selected"';
break;
default:
$activeselected = 'class="selected"';
break;
}
$addtype = get_string('addtype', 'lti');
$config = get_string('manage_tool_proxies', 'lti');

$addtypeurl = "{$CFG->wwwroot}/mod/lti/typessettings.php?action=add&sesskey={$USER->sesskey}";

$template = <<< EOD
<div id="lti_tabs" class="yui-navset">
<ul id="lti_tab_heading" class="yui-nav" style="display:none">
<li {$activeselected}>
<a href="#tab1">
<em>$active</em>
</a>
</li>
<li {$pendingselected}>
<a href="#tab2">
<em>$pending</em>
</a>
</li>
<li {$rejectedselected}>
<a href="#tab3">
<em>$rejected</em>
</a>
</li>
</ul>
<div class="yui-content">
<div>
<div><a style="margin-top:.25em" href="{$addtypeurl}">{$addtype}</a></div>
$configuredtoolshtml
</div>
<div>
$pendingtoolshtml
</div>
<div>
$rejectedtoolshtml
</div>
</div>
</div>
<script type="text/javascript">
//<![CDATA[
YUI().use('yui2-tabview', 'yui2-datatable', function(Y) {
//If javascript is disabled, they will just see the three tabs one after another
var lti_tab_heading = document.getElementById('lti_tab_heading');
lti_tab_heading.style.display = '';
new Y.YUI2.widget.TabView('lti_tabs');
var setupTools = function(id, sort){
var lti_tools = Y.YUI2.util.Dom.get(id);
if(lti_tools){
var dataSource = new Y.YUI2.util.DataSource(lti_tools);
var configuredColumns = [
{key:'name', label: M.util.get_string('typename', 'mod_lti'), sortable: true},
{key:'baseURL', label: M.util.get_string('baseurl', 'mod_lti'), sortable: true},
{key:'timecreated', label: M.util.get_string('createdon', 'mod_lti'), sortable: true},
{key:'action', label: M.util.get_string('action', 'mod_lti')}
];
dataSource.responseType = Y.YUI2.util.DataSource.TYPE_HTMLTABLE;
dataSource.responseSchema = {
fields: [
{key:'name'},
{key:'baseURL'},
{key:'timecreated'},
{key:'action'}
]
};
new Y.YUI2.widget.DataTable(id + '_container', configuredColumns, dataSource,
{
sortedBy: sort
}
);
}
};
setupTools('lti_configured_tools', {key:'name', dir:'asc'});
setupTools('lti_pending_tools', {key:'timecreated', dir:'desc'});
setupTools('lti_rejected_tools', {key:'timecreated', dir:'desc'});
});
//]]
</script>
EOD;
$settings->add(new admin_setting_heading('lti_types', new lang_string('external_tool_types', 'lti') .
$OUTPUT->help_icon('main_admin', 'lti'), $template));
}

0 comments on commit 82a3de4

Please sign in to comment.