Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/mod/lti/typessettings.php
Go to the documentation of this file.
00001 <?php
00002 // This file is part of Moodle - http://moodle.org/
00003 //
00004 // Moodle is free software: you can redistribute it and/or modify
00005 // it under the terms of the GNU General Public License as published by
00006 // the Free Software Foundation, either version 3 of the License, or
00007 // (at your option) any later version.
00008 //
00009 // Moodle is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
00016 //
00017 // This file is part of BasicLTI4Moodle
00018 //
00019 // BasicLTI4Moodle is an IMS BasicLTI (Basic Learning Tools for Interoperability)
00020 // consumer for Moodle 1.9 and Moodle 2.0. BasicLTI is a IMS Standard that allows web
00021 // based learning tools to be easily integrated in LMS as native ones. The IMS BasicLTI
00022 // specification is part of the IMS standard Common Cartridge 1.1 Sakai and other main LMS
00023 // are already supporting or going to support BasicLTI. This project Implements the consumer
00024 // for Moodle. Moodle is a Free Open source Learning Management System by Martin Dougiamas.
00025 // BasicLTI4Moodle is a project iniciated and leaded by Ludo(Marc Alier) and Jordi Piguillem
00026 // at the GESSI research group at UPC.
00027 // SimpleLTI consumer for Moodle is an implementation of the early specification of LTI
00028 // by Charles Severance (Dr Chuck) htp://dr-chuck.com , developed by Jordi Piguillem in a
00029 // Google Summer of Code 2008 project co-mentored by Charles Severance and Marc Alier.
00030 //
00031 // BasicLTI4Moodle is copyright 2009 by Marc Alier Forment, Jordi Piguillem and Nikolas Galanis
00032 // of the Universitat Politecnica de Catalunya http://www.upc.edu
00033 // Contact info: Marc Alier Forment granludo @ gmail.com or marc.alier @ upc.edu
00034 
00051 require_once('../../config.php');
00052 require_once($CFG->libdir.'/adminlib.php');
00053 require_once($CFG->dirroot.'/mod/lti/edit_form.php');
00054 require_once($CFG->dirroot.'/mod/lti/locallib.php');
00055 
00056 $section      = 'modsettinglti';
00057 $return       = optional_param('return', '', PARAM_ALPHA);
00058 $adminediting = optional_param('adminedit', -1, PARAM_BOOL);
00059 $action       = optional_param('action', null, PARAM_ACTION);
00060 $id           = optional_param('id', null, PARAM_INT);
00061 $useexisting  = optional_param('useexisting', null, PARAM_INT);
00062 $definenew    = optional_param('definenew', null, PARAM_INT);
00063 
00064 // no guest autologin
00065 require_login(0, false);
00066 $url = new moodle_url('/mod/lti/typesettings.php');
00067 $PAGE->set_url($url);
00068 
00069 admin_externalpage_setup('managemodules'); // Hacky solution for printing the admin page
00070 
00071 $tab = optional_param('tab', '', PARAM_ALPHAEXT);
00072 $redirect = "$CFG->wwwroot/$CFG->admin/settings.php?section=modsettinglti&tab={$tab}";
00073 
00074 // WRITING SUBMITTED DATA (IF ANY)
00075 
00076 $statusmsg = '';
00077 $errormsg  = '';
00078 $focus = '';
00079 
00080 $data = data_submitted();
00081 
00082 // Any posted data & any action
00083 if (!empty($data) || !empty($action)) {
00084     require_sesskey();
00085 }
00086 
00087 if (isset($data->submitbutton)) {
00088     $type = new stdClass();
00089 
00090     if (isset($id)) {
00091         $type->id = $id;
00092 
00093         lti_update_type($type, $data);
00094 
00095         redirect($redirect);
00096     } else {
00097         $type->state = LTI_TOOL_STATE_CONFIGURED;
00098 
00099         lti_add_type($type, $data);
00100 
00101         redirect($redirect);
00102     }
00103 
00104 } else if (isset($data->cancel)) {
00105     redirect($redirect);
00106 
00107 } else if ($action == 'accept') {
00108     lti_set_state_for_type($id, LTI_TOOL_STATE_CONFIGURED);
00109     redirect($redirect);
00110 
00111 } else if ($action == 'reject') {
00112     lti_set_state_for_type($id, LTI_TOOL_STATE_REJECTED);
00113     redirect($redirect);
00114 
00115 } else if ($action == 'delete') {
00116     lti_delete_type($id);
00117     redirect($redirect);
00118 }
00119 
00120 // print header stuff
00121 $PAGE->set_focuscontrol($focus);
00122 if (empty($SITE->fullname)) {
00123     $PAGE->set_title($settingspage->visiblename);
00124     $PAGE->set_heading($settingspage->visiblename);
00125 
00126     $PAGE->navbar->add(get_string('lti_administration', 'lti'), $CFG->wwwroot.'/admin/settings.php?section=modsettinglti');
00127 
00128     echo $OUTPUT->header();
00129 
00130     echo $OUTPUT->box(get_string('configintrosite', 'admin'));
00131 
00132     if ($errormsg !== '') {
00133         echo $OUTPUT->notification($errormsg);
00134 
00135     } else if ($statusmsg !== '') {
00136         echo $OUTPUT->notification($statusmsg, 'notifysuccess');
00137     }
00138 
00139     echo '<form action="typesettings.php" method="post" id="'.$id.'" >';
00140     echo '<div class="settingsform clearfix">';
00141     echo html_writer::input_hidden_params($PAGE->url);
00142     echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
00143     echo '<input type="hidden" name="return" value="'.$return.'" />';
00144 
00145     echo $settingspage->output_html();
00146 
00147     echo '<div class="form-buttons"><input class="form-submit" type="submit" value="'.get_string('savechanges', 'admin').'" /></div>';
00148 
00149     echo '</div>';
00150     echo '</form>';
00151 
00152 } else {
00153     if ($PAGE->user_allowed_editing()) {
00154         $url = clone($PAGE->url);
00155         if ($PAGE->user_is_editing()) {
00156             $caption = get_string('blockseditoff');
00157             $url->param('adminedit', 'off');
00158         } else {
00159             $caption = get_string('blocksediton');
00160             $url->param('adminedit', 'on');
00161         }
00162         $buttons = $OUTPUT->single_button($url, $caption, 'get');
00163     }
00164 
00165     $PAGE->set_title("$SITE->shortname: " . get_string('toolsetup', 'lti'));
00166 
00167     $PAGE->navbar->add(get_string('lti_administration', 'lti'), $CFG->wwwroot.'/admin/settings.php?section=modsettinglti');
00168 
00169     echo $OUTPUT->header();
00170 
00171     if ($errormsg !== '') {
00172         echo $OUTPUT->notification($errormsg);
00173 
00174     } else if ($statusmsg !== '') {
00175         echo $OUTPUT->notification($statusmsg, 'notifysuccess');
00176     }
00177 
00178     echo $OUTPUT->heading(get_string('toolsetup', 'lti'));
00179     echo $OUTPUT->box_start('generalbox');
00180     if ($action == 'add') {
00181         $form = new mod_lti_edit_types_form(null, (object)array('isadmin' => true));
00182         $form->display();
00183     } else if ($action == 'update') {
00184         $form = new mod_lti_edit_types_form('typessettings.php?id='.$id, (object)array('isadmin' => true));
00185         $type = lti_get_type_type_config($id);
00186         $form->set_data($type);
00187         $form->display();
00188     }
00189 
00190     echo $OUTPUT->box_end();
00191 }
00192 
00193 echo $OUTPUT->footer();
 All Data Structures Namespaces Files Functions Variables Enumerations