[ Index ]

PHP Cross Reference of moodle-2.8

title

Body

[close]

/mod/lti/ -> registersettings.php (source)

   1  <?php
   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  
  17  /**
  18   * This file contains the script used to register a new external tool.
  19   *
  20   * It is used to create a new form used to configure the capabilities
  21   * and services to be offered to the tool provider.
  22   *
  23   * @package mod_lti
  24   * @copyright  2014 Vital Source Technologies http://vitalsource.com
  25   * @author     Stephen Vickers
  26   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  27   */
  28  
  29  require_once('../../config.php');
  30  require_once($CFG->libdir.'/adminlib.php');
  31  require_once($CFG->dirroot.'/mod/lti/register_form.php');
  32  require_once($CFG->dirroot.'/mod/lti/locallib.php');
  33  
  34  $action       = optional_param('action', null, PARAM_ALPHANUMEXT);
  35  $id           = optional_param('id', null, PARAM_INT);
  36  $tab          = optional_param('tab', '', PARAM_ALPHAEXT);
  37  
  38  // No guest autologin.
  39  require_login(0, false);
  40  
  41  $isupdate = !empty($id);
  42  $pageurl = new moodle_url('/mod/lti/registersettings.php');
  43  if ($isupdate) {
  44      $pageurl->param('id', $id);
  45  }
  46  $PAGE->set_url($pageurl);
  47  
  48  admin_externalpage_setup('ltitoolproxies');
  49  
  50  $redirect = new moodle_url('/mod/lti/toolproxies.php', array('tab' => $tab));
  51  $redirect = $redirect->out();
  52  
  53  require_sesskey();
  54  
  55  if ($action == 'delete') {
  56      lti_delete_tool_proxy($id);
  57      redirect($redirect);
  58  }
  59  
  60  $data = array();
  61  if ($isupdate) {
  62      $data['isupdate'] = true;
  63  }
  64  
  65  $form = new mod_lti_register_types_form($pageurl, (object)$data);
  66  
  67  if ($form->is_cancelled()) {
  68      redirect($redirect);
  69  } else if ($data = $form->get_data()) {
  70      $id = lti_add_tool_proxy($data);
  71      redirect($redirect);
  72  } else {
  73      $PAGE->set_title("{$SITE->shortname}: " . get_string('toolregistration', 'lti'));
  74      $PAGE->navbar->add(get_string('lti_administration', 'lti'), $redirect);
  75  
  76      echo $OUTPUT->header();
  77      echo $OUTPUT->heading(get_string('toolregistration', 'lti'));
  78      echo $OUTPUT->box_start('generalbox');
  79      if ($action == 'update') {
  80          $toolproxy = lti_get_tool_proxy_config($id);
  81          $form->set_data($toolproxy);
  82          if ($toolproxy->state == LTI_TOOL_PROXY_STATE_ACCEPTED) {
  83              $form->disable_fields();
  84          }
  85      }
  86      $form->display();
  87  
  88      echo $OUTPUT->box_end();
  89      echo $OUTPUT->footer();
  90  }


Generated: Fri Nov 28 20:29:05 2014 Cross-referenced by PHPXref 0.7.1