MDL-49159 mod_lti: Incorrect IDs in tools table
[moodle.git] / mod / lti / settings.php
CommitLineData
996b0fd9 1<?php
61eb12d4
CS
2// This file is part of Moodle - http://moodle.org/
3//
4// Moodle is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// Moodle is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16//
996b0fd9
CS
17// This file is part of BasicLTI4Moodle
18//
19// BasicLTI4Moodle is an IMS BasicLTI (Basic Learning Tools for Interoperability)
20// consumer for Moodle 1.9 and Moodle 2.0. BasicLTI is a IMS Standard that allows web
21// based learning tools to be easily integrated in LMS as native ones. The IMS BasicLTI
22// specification is part of the IMS standard Common Cartridge 1.1 Sakai and other main LMS
23// are already supporting or going to support BasicLTI. This project Implements the consumer
24// for Moodle. Moodle is a Free Open source Learning Management System by Martin Dougiamas.
25// BasicLTI4Moodle is a project iniciated and leaded by Ludo(Marc Alier) and Jordi Piguillem
26// at the GESSI research group at UPC.
27// SimpleLTI consumer for Moodle is an implementation of the early specification of LTI
28// by Charles Severance (Dr Chuck) htp://dr-chuck.com , developed by Jordi Piguillem in a
29// Google Summer of Code 2008 project co-mentored by Charles Severance and Marc Alier.
30//
31// BasicLTI4Moodle is copyright 2009 by Marc Alier Forment, Jordi Piguillem and Nikolas Galanis
32// of the Universitat Politecnica de Catalunya http://www.upc.edu
e3f69b58 33// Contact info: Marc Alier Forment granludo @ gmail.com or marc.alier @ upc.edu.
996b0fd9
CS
34
35/**
61eb12d4 36 * This file defines the global lti administration form
996b0fd9 37 *
2b17ec3d 38 * @package mod_lti
61eb12d4 39 * @copyright 2009 Marc Alier, Jordi Piguillem, Nikolas Galanis
996b0fd9 40 * marc.alier@upc.edu
61eb12d4
CS
41 * @copyright 2009 Universitat Politecnica de Catalunya http://www.upc.edu
42 * @author Marc Alier
43 * @author Jordi Piguillem
44 * @author Nikolas Galanis
8f45215d 45 * @author Chris Scribner
c86cf019 46 * @copyright 2015 Vital Source Technologies http://vitalsource.com
47 * @author Stephen Vickers
61eb12d4 48 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
996b0fd9
CS
49 */
50
51defined('MOODLE_INTERNAL') || die;
52
e3f69b58 53/*
54 * @var admin_settingpage $settings
55 */
e9033d11
MN
56$modltifolder = new admin_category('modltifolder', new lang_string('pluginname', 'mod_lti'), $module->is_enabled() === false);
57$ADMIN->add('modsettings', $modltifolder);
e3f69b58 58$settings->visiblename = new lang_string('manage_tools', 'mod_lti');
e9033d11 59$ADMIN->add('modltifolder', $settings);
e3f69b58 60$ADMIN->add('modltifolder', new admin_externalpage('ltitoolproxies',
61 get_string('manage_tool_proxies', 'lti'),
62 new moodle_url('/mod/lti/toolproxies.php')));
e9033d11
MN
63
64foreach (core_plugin_manager::instance()->get_plugins_of_type('ltisource') as $plugin) {
e3f69b58 65 /*
66 * @var \mod_lti\plugininfo\ltisource $plugin
67 */
e9033d11
MN
68 $plugin->load_settings($ADMIN, 'modltifolder', $hassiteconfig);
69}
70
e3f69b58 71$toolproxiesurl = new moodle_url('/mod/lti/toolproxies.php');
72$toolproxiesurl = $toolproxiesurl->out();
73
996b0fd9 74if ($ADMIN->fulltree) {
b9fbe554
EL
75 require_once($CFG->dirroot.'/mod/lti/locallib.php');
76
996b0fd9
CS
77 $configuredtoolshtml = '';
78 $pendingtoolshtml = '';
79 $rejectedtoolshtml = '';
80
81 $active = get_string('active', 'lti');
82 $pending = get_string('pending', 'lti');
83 $rejected = get_string('rejected', 'lti');
d7f87343
MR
84
85 // Gather strings used for labels in the inline JS.
86 $PAGE->requires->strings_for_js(
87 array(
88 'typename',
89 'baseurl',
90 'action',
91 'createdon'
92 ),
93 'mod_lti'
94 );
e27cb316 95
b9fbe554 96 $types = lti_filter_get_types(get_site()->id);
e27cb316 97
d81a603e 98 $configuredtools = lti_filter_tool_types($types, LTI_TOOL_STATE_CONFIGURED);
e27cb316 99
996b0fd9
CS
100 $configuredtoolshtml = lti_get_tool_table($configuredtools, 'lti_configured');
101
d81a603e 102 $pendingtools = lti_filter_tool_types($types, LTI_TOOL_STATE_PENDING);
e27cb316 103
996b0fd9 104 $pendingtoolshtml = lti_get_tool_table($pendingtools, 'lti_pending');
e27cb316 105
d81a603e 106 $rejectedtools = lti_filter_tool_types($types, LTI_TOOL_STATE_REJECTED);
e27cb316 107
996b0fd9 108 $rejectedtoolshtml = lti_get_tool_table($rejectedtools, 'lti_rejected');
e27cb316 109
996b0fd9
CS
110 $tab = optional_param('tab', '', PARAM_ALPHAEXT);
111 $activeselected = '';
112 $pendingselected = '';
113 $rejectedselected = '';
ea04a9f9 114 switch ($tab) {
996b0fd9
CS
115 case 'lti_pending':
116 $pendingselected = 'class="selected"';
117 break;
118 case 'lti_rejected':
119 $rejectedselected = 'class="selected"';
120 break;
121 default:
122 $activeselected = 'class="selected"';
123 break;
124 }
e3f69b58 125 $addtype = get_string('addtype', 'lti');
126 $config = get_string('manage_tool_proxies', 'lti');
e27cb316 127
e3f69b58 128 $addtypeurl = "{$CFG->wwwroot}/mod/lti/typessettings.php?action=add&amp;sesskey={$USER->sesskey}";
129
130 $template = <<< EOD
131<div id="lti_tabs" class="yui-navset">
132 <ul id="lti_tab_heading" class="yui-nav" style="display:none">
996b0fd9 133 <li {$activeselected}>
e3f69b58 134 <a href="#tab1">
996b0fd9
CS
135 <em>$active</em>
136 </a>
137 </li>
138 <li {$pendingselected}>
e3f69b58 139 <a href="#tab2">
996b0fd9
CS
140 <em>$pending</em>
141 </a>
142 </li>
143 <li {$rejectedselected}>
e3f69b58 144 <a href="#tab3">
996b0fd9
CS
145 <em>$rejected</em>
146 </a>
147 </li>
148 </ul>
e3f69b58 149 <div class="yui-content">
996b0fd9 150 <div>
e3f69b58 151 <div><a style="margin-top:.25em" href="{$addtypeurl}">{$addtype}</a></div>
996b0fd9
CS
152 $configuredtoolshtml
153 </div>
154 <div>
155 $pendingtoolshtml
156 </div>
157 <div>
158 $rejectedtoolshtml
159 </div>
160 </div>
161</div>
162
e3f69b58 163<script type="text/javascript">
996b0fd9 164//<![CDATA[
426f2d5b 165 YUI().use('yui2-tabview', 'yui2-datatable', function(Y) {
996b0fd9
CS
166 //If javascript is disabled, they will just see the three tabs one after another
167 var lti_tab_heading = document.getElementById('lti_tab_heading');
168 lti_tab_heading.style.display = '';
169
426f2d5b 170 new Y.YUI2.widget.TabView('lti_tabs');
e27cb316 171
996b0fd9 172 var setupTools = function(id, sort){
c86cf019 173 var lti_tools = Y.YUI2.util.Dom.get(id);
e27cb316 174
996b0fd9 175 if(lti_tools){
426f2d5b 176 var dataSource = new Y.YUI2.util.DataSource(lti_tools);
e27cb316 177
996b0fd9 178 var configuredColumns = [
d7f87343
MR
179 {key:'name', label: M.util.get_string('typename', 'mod_lti'), sortable: true},
180 {key:'baseURL', label: M.util.get_string('baseurl', 'mod_lti'), sortable: true},
181 {key:'timecreated', label: M.util.get_string('createdon', 'mod_lti'), sortable: true},
182 {key:'action', label: M.util.get_string('action', 'mod_lti')}
996b0fd9
CS
183 ];
184
426f2d5b 185 dataSource.responseType = Y.YUI2.util.DataSource.TYPE_HTMLTABLE;
996b0fd9
CS
186 dataSource.responseSchema = {
187 fields: [
5de15b83
CS
188 {key:'name'},
189 {key:'baseURL'},
101ec5fd 190 {key:'timecreated'},
5de15b83 191 {key:'action'}
996b0fd9
CS
192 ]
193 };
194
426f2d5b 195 new Y.YUI2.widget.DataTable(id + '_container', configuredColumns, dataSource,
996b0fd9
CS
196 {
197 sortedBy: sort
198 }
199 );
200 }
201 };
202
e3f69b58 203 setupTools('lti_configured_tools', {key:'name', dir:'asc'});
204 setupTools('lti_pending_tools', {key:'timecreated', dir:'desc'});
205 setupTools('lti_rejected_tools', {key:'timecreated', dir:'desc'});
426f2d5b 206 });
996b0fd9
CS
207//]]
208</script>
e3f69b58 209EOD;
210 $settings->add(new admin_setting_heading('lti_types', new lang_string('external_tool_types', 'lti') .
211 $OUTPUT->help_icon('main_admin', 'lti'), $template));
e9033d11 212}
8fa50fdd 213
e3f69b58 214// Tell core we already added the settings structure.
215$settings = null;
8fa50fdd 216