2 // This file is part of Moodle - http://moodle.org/
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.
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.
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/>.
18 * This file contains all necessary code to launch a Tool Proxy registration
21 * @copyright 2014 Vital Source Technologies http://vitalsource.com
22 * @author Stephen Vickers
23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26 require_once('../../config.php');
27 require_once($CFG->libdir
.'/adminlib.php');
28 require_once($CFG->dirroot
.'/mod/lti/locallib.php');
30 // No guest autologin.
31 require_login(0, false);
33 $pageurl = new moodle_url('/mod/lti/toolproxies.php');
34 $PAGE->set_url($pageurl);
36 admin_externalpage_setup('ltitoolproxies');
38 $PAGE->set_title(get_string('toolregistration', 'lti'));
40 $configuredtoolproxieshtml = '';
41 $pendingtoolproxieshtml = '';
42 $acceptedtoolproxieshtml = '';
43 $rejectedtoolproxieshtml = '';
45 $configured = get_string('configured', 'lti');
46 $pending = get_string('pending', 'lti');
47 $accepted = get_string('accepted', 'lti');
48 $rejected = get_string('rejected', 'lti');
50 $name = get_string('name', 'lti');
51 $url = get_string('registrationurl', 'lti');
52 $action = get_string('action', 'lti');
53 $createdon = get_string('createdon', 'lti');
55 $toolproxies = $DB->get_records('lti_tool_proxies');
57 $configuredtoolproxies = lti_filter_tool_proxy_types($toolproxies, LTI_TOOL_PROXY_STATE_CONFIGURED
);
58 $configuredtoolproxieshtml = lti_get_tool_proxy_table($configuredtoolproxies, 'tp_configured');
60 $pendingtoolproxies = lti_filter_tool_proxy_types($toolproxies, LTI_TOOL_PROXY_STATE_PENDING
);
61 $pendingtoolproxieshtml = lti_get_tool_proxy_table($pendingtoolproxies, 'tp_pending');
63 $acceptedtoolproxies = lti_filter_tool_proxy_types($toolproxies, LTI_TOOL_PROXY_STATE_ACCEPTED
);
64 $acceptedtoolproxieshtml = lti_get_tool_proxy_table($acceptedtoolproxies, 'tp_accepted');
66 $rejectedtoolproxies = lti_filter_tool_proxy_types($toolproxies, LTI_TOOL_PROXY_STATE_REJECTED
);
67 $rejectedtoolproxieshtml = lti_get_tool_proxy_table($rejectedtoolproxies, 'tp_rejected');
69 $tab = optional_param('tab', '', PARAM_ALPHAEXT
);
70 $configuredselected = '';
71 $pendingselected = '';
72 $acceptedselected = '';
73 $rejectedselected = '';
76 $pendingselected = 'class="selected"';
79 $acceptedselected = 'class="selected"';
82 $rejectedselected = 'class="selected"';
85 $configuredselected = 'class="selected"';
88 $registertype = get_string('registertype', 'lti');
89 $config = get_string('manage_tools', 'lti');
91 $registertypeurl = "{$CFG->wwwroot}/mod/lti/registersettings.php?action=add&sesskey={$USER->sesskey}&tab=tool_proxy";
94 <div id
="tp_tabs" class="yui-navset">
95 <ul id
="tp_tab_heading" class="yui-nav" style
="display:none">
96 <li
{$configuredselected}>
101 <li
{$pendingselected}>
106 <li
{$acceptedselected}>
111 <li
{$rejectedselected}>
117 <div
class="yui-content">
119 <div
><a style
="margin-top:.25em" href
="{$registertypeurl}">{$registertype}</a
></div
>
120 $configuredtoolproxieshtml
123 $pendingtoolproxieshtml
126 $acceptedtoolproxieshtml
129 $rejectedtoolproxieshtml
134 <script type
="text/javascript">
136 YUI().use('yui2-tabview', 'yui2-datatable', function(Y
) {
137 //If javascript is disabled, they will just see the three tabs one after another
138 var tp_tab_heading
= document
.getElementById('tp_tab_heading');
139 tp_tab_heading
.style
.display
= '';
141 new Y
.YUI2
.widget
.TabView('tp_tabs');
143 var setupTools
= function(id
, sort
){
144 var tp_tool_proxies
= Y
.YUI2
.util
.Dom
.get(id
);
147 var dataSource
= new Y
.YUI2
.util
.DataSource(tp_tool_proxies
);
149 var configuredColumns
= [
150 {key
:'name', label
:'$name', sortable
:true},
151 {key
:'url', label
:'$url', sortable
:true},
152 {key
:'timecreated', label
:'$createdon', sortable
:true},
153 {key
:'action', label
:'$action'}
156 dataSource
.responseType
= Y
.YUI2
.util
.DataSource
.TYPE_HTMLTABLE
;
157 dataSource
.responseSchema
= {
166 new Y
.YUI2
.widget
.DataTable(id +
'_container', configuredColumns
, dataSource
,
174 setupTools('tp_configured_tool_proxies', {key
:'name', dir
:'asc'});
175 setupTools('tp_pending_tool_proxies', {key
:'timecreated', dir
:'desc'});
176 setupTools('tp_accepted_tool_proxies', {key
:'timecreated', dir
:'desc'});
177 setupTools('tp_rejected_tool_proxies', {key
:'timecreated', dir
:'desc'});
183 echo $OUTPUT->header();
184 echo $OUTPUT->heading(get_string('manage_tool_proxies', 'lti'), 2);
185 echo $OUTPUT->heading(new lang_string('toolproxy', 'lti') .
186 $OUTPUT->help_icon('toolproxy', 'lti'), 3);
188 echo $OUTPUT->box_start('generalbox');
192 echo $OUTPUT->box_end();
193 echo $OUTPUT->footer();