Add unsupported service support.
[moodle.git] / mod / lti / typessettings.php
CommitLineData
996b0fd9
CS
1<?php
2// This file is part of BasicLTI4Moodle
3//
4// BasicLTI4Moodle is an IMS BasicLTI (Basic Learning Tools for Interoperability)
5// consumer for Moodle 1.9 and Moodle 2.0. BasicLTI is a IMS Standard that allows web
6// based learning tools to be easily integrated in LMS as native ones. The IMS BasicLTI
7// specification is part of the IMS standard Common Cartridge 1.1 Sakai and other main LMS
8// are already supporting or going to support BasicLTI. This project Implements the consumer
9// for Moodle. Moodle is a Free Open source Learning Management System by Martin Dougiamas.
10// BasicLTI4Moodle is a project iniciated and leaded by Ludo(Marc Alier) and Jordi Piguillem
11// at the GESSI research group at UPC.
12// SimpleLTI consumer for Moodle is an implementation of the early specification of LTI
13// by Charles Severance (Dr Chuck) htp://dr-chuck.com , developed by Jordi Piguillem in a
14// Google Summer of Code 2008 project co-mentored by Charles Severance and Marc Alier.
15//
16// BasicLTI4Moodle is copyright 2009 by Marc Alier Forment, Jordi Piguillem and Nikolas Galanis
17// of the Universitat Politecnica de Catalunya http://www.upc.edu
18// Contact info: Marc Alier Forment granludo @ gmail.com or marc.alier @ upc.edu
19//
20// Moodle is free software: you can redistribute it and/or modify
21// it under the terms of the GNU General Public License as published by
22// the Free Software Foundation, either version 3 of the License, or
23// (at your option) any later version.
24//
25// Moodle is distributed in the hope that it will be useful,
26// but WITHOUT ANY WARRANTY; without even the implied warranty of
27// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28// GNU General Public License for more details.
29//
30// You should have received a copy of the GNU General Public License
31// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
32
33/**
34 * This file contains the script used to clone Moodle admin setting page.
35 * It is used to create a new form used to pre-configure basiclti
36 * activities
37 *
38 * @package lti
39 * @copyright 2009 Marc Alier, Jordi Piguillem, Nikolas Galanis
40 * marc.alier@upc.edu
41 * @copyright 2009 Universitat Politecnica de Catalunya http://www.upc.edu
42 *
43 * @author Marc Alier
44 * @author Jordi Piguillem
45 * @author Nikolas Galanis
46 *
47 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
48 */
49
50require_once('../../config.php');
51require_once($CFG->libdir.'/adminlib.php');
52require_once($CFG->dirroot.'/mod/lti/edit_form.php');
53require_once($CFG->dirroot.'/mod/lti/locallib.php');
54
55$section = 'modsettinglti';
56$return = optional_param('return', '', PARAM_ALPHA);
57$adminediting = optional_param('adminedit', -1, PARAM_BOOL);
58$action = optional_param('action', null, PARAM_TEXT);
59$id = optional_param('id', null, PARAM_INT);
60$useexisting = optional_param('useexisting', null, PARAM_INT);
61$definenew = optional_param('definenew', null, PARAM_INT);
62
63/// no guest autologin
64require_login(0, false);
65$url = new moodle_url('/mod/lti/typesettings.php');
66$PAGE->set_url($url);
67
68admin_externalpage_setup('managemodules'); // Hacky solution for printing the admin page
69
70$tab = optional_param('tab', '', PARAM_ALPHAEXT);
71$redirect = "$CFG->wwwroot/$CFG->admin/settings.php?section=modsettinglti&tab={$tab}";
72
73/// WRITING SUBMITTED DATA (IF ANY) -------------------------------------------------------------------------------
74
75$statusmsg = '';
76$errormsg = '';
77$focus = '';
78
79$data = data_submitted();
80
81if (confirm_sesskey() && isset($data->submitbutton)) {
82 $type = new stdClass();
83
84 if (isset($id)) {
85 $type->id = $id;
86
87 lti_update_type($type, $data);
88
89 redirect($redirect);
90 die;
91 } else {
92 $type->state = LTI_TOOL_STATE_CONFIGURED;
93
94 lti_add_type($type, $data);
95
96 redirect($redirect);
97 die;
98 }
99} else if(isset($data->cancel)){
100 redirect($redirect);
101 die;
102}
103
104if ($action == 'accept') {
105 lti_set_state_for_type($id, LTI_TOOL_STATE_CONFIGURED);
106 redirect($redirect);
107 die;
108}
109
110if ($action == 'reject') {
111 lti_set_state_for_type($id, LTI_TOOL_STATE_REJECTED);
112 redirect($redirect);
113 die;
114}
115
116if ($action == 'delete') {
117 lti_delete_type($id);
118 redirect($redirect);
119 die;
120}
121
122/// print header stuff ------------------------------------------------------------
123$PAGE->set_focuscontrol($focus);
124if (empty($SITE->fullname)) {
125 $PAGE->set_title($settingspage->visiblename);
126 $PAGE->set_heading($settingspage->visiblename);
127
d8d04121 128 $PAGE->navbar->add(get_string('lti_administration', 'lti'), $CFG->wwwroot.'/admin/settings.php?section=modsettinglti');
996b0fd9
CS
129
130 echo $OUTPUT->header();
131
132 echo $OUTPUT->box(get_string('configintrosite', 'admin'));
133
134 if ($errormsg !== '') {
135 echo $OUTPUT->notification($errormsg);
136
137 } else if ($statusmsg !== '') {
138 echo $OUTPUT->notification($statusmsg, 'notifysuccess');
139 }
140
141 // ---------------------------------------------------------------------------------------------------------------
142
143 echo '<form action="typesettings.php" method="post" id="'.$id.'" >';
144 echo '<div class="settingsform clearfix">';
145 echo html_writer::input_hidden_params($PAGE->url);
146 echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
147 echo '<input type="hidden" name="return" value="'.$return.'" />';
148
149 echo $settingspage->output_html();
150
151 echo '<div class="form-buttons"><input class="form-submit" type="submit" value="'.get_string('savechanges', 'admin').'" /></div>';
152
153 echo '</div>';
154 echo '</form>';
155
156} else {
157 if ($PAGE->user_allowed_editing()) {
158 $url = clone($PAGE->url);
159 if ($PAGE->user_is_editing()) {
160 $caption = get_string('blockseditoff');
161 $url->param('adminedit', 'off');
162 } else {
163 $caption = get_string('blocksediton');
164 $url->param('adminedit', 'on');
165 }
166 $buttons = $OUTPUT->single_button($url, $caption, 'get');
167 }
168
169 $PAGE->set_title("$SITE->shortname: " . get_string('toolsetup', 'lti'));
170
d8d04121 171 $PAGE->navbar->add(get_string('lti_administration', 'lti'), $CFG->wwwroot.'/admin/settings.php?section=modsettinglti');
996b0fd9
CS
172
173 echo $OUTPUT->header();
174
175 if ($errormsg !== '') {
176 echo $OUTPUT->notification($errormsg);
177
178 } else if ($statusmsg !== '') {
179 echo $OUTPUT->notification($statusmsg, 'notifysuccess');
180 }
181
182 // ---------------------------------------------------------------------------------------------------------------
183 echo $OUTPUT->heading(get_string('toolsetup', 'lti'));
184 echo $OUTPUT->box_start('generalbox');
185 if ($action == 'add') {
186 $form = new mod_lti_edit_types_form(null, (object)array('isadmin' => true));
187 $form->display();
188 } else if ($action == 'update') {
189 $form = new mod_lti_edit_types_form('typessettings.php?id='.$id, (object)array('isadmin' => true));
190 $type = lti_get_type_type_config($id);
191 $form->set_data($type);
192 $form->display();
193 }
194
195 echo $OUTPUT->box_end();
196}
197
198echo $OUTPUT->footer();