[ Index ]

PHP Cross Reference of moodle-2.8

title

Body

[close]

/mod/lti/ -> ajax.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   * AJAX service used when adding an External Tool.
  19   *
  20   * It is used to provide immediate feedback
  21   * of which tool provider is to be used based on the Launch URL.
  22   *
  23   * @package    mod_lti
  24   * @subpackage xml
  25   * @copyright Copyright (c) 2011 Moodlerooms Inc. (http://www.moodlerooms.com)
  26   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  27   * @author     Chris Scribner
  28   */
  29  
  30  require_once(dirname(__FILE__) . "/../../config.php");
  31  require_once($CFG->dirroot . '/mod/lti/locallib.php');
  32  
  33  $courseid = required_param('course', PARAM_INT);
  34  
  35  require_login($courseid, false);
  36  
  37  $action = required_param('action', PARAM_TEXT);
  38  
  39  $response = new stdClass();
  40  
  41  switch ($action) {
  42      case 'find_tool_config':
  43          $toolurl = required_param('toolurl', PARAM_RAW);
  44          $toolid = optional_param('toolid', 0, PARAM_INT);
  45  
  46          if (empty($toolid) && !empty($toolurl)) {
  47              $tool = lti_get_tool_by_url_match($toolurl, $courseid);
  48  
  49              if (!empty($tool)) {
  50                  $toolid = $tool->id;
  51  
  52                  $response->toolid = $tool->id;
  53                  $response->toolname = htmlspecialchars($tool->name);
  54                  $response->tooldomain = htmlspecialchars($tool->tooldomain);
  55              }
  56          } else {
  57              $response->toolid = $toolid;
  58          }
  59  
  60          if (!empty($toolid)) {
  61              // Look up privacy settings.
  62              $query = '
  63                  SELECT name, value
  64                  FROM {lti_types_config}
  65                  WHERE
  66                      typeid = :typeid
  67                  AND name IN (\'sendname\', \'sendemailaddr\', \'acceptgrades\')
  68              ';
  69  
  70              $privacyconfigs = $DB->get_records_sql($query, array('typeid' => $toolid));
  71              foreach ($privacyconfigs as $config) {
  72                  $configname = $config->name;
  73                  $response->$configname = $config->value;
  74              }
  75          }
  76          break;
  77  }
  78  
  79  echo json_encode($response);
  80  
  81  die;


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