Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 311 and 401] [Versions 311 and 402]

   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 is part of the User section Moodle
  19   *
  20   * @copyright 1999 Martin Dougiamas  http://dougiamas.com
  21   * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  22   * @package core_user
  23   */
  24  
  25  require_once(__DIR__ . '/../config.php');
  26  require_once($CFG->dirroot . '/repository/lib.php');
  27  
  28  $config = optional_param('config', 0, PARAM_INT);
  29  $course  = optional_param('course', SITEID, PARAM_INT);
  30  
  31  $url = new moodle_url('/user/repository.php', array('course' => $course));
  32  if ($config !== 0) {
  33      $url->param('config', $config);
  34  }
  35  $PAGE->set_url($url);
  36  
  37  $course = $DB->get_record("course", array("id" => $course), '*', MUST_EXIST);
  38  
  39  $user = $USER;
  40  $baseurl = $CFG->wwwroot . '/user/repository.php';
  41  $namestr = get_string('name');
  42  $fullname = fullname($user);
  43  $strrepos = get_string('repositories', 'repository');
  44  $configstr = get_string('manageuserrepository', 'repository');
  45  $pluginstr = get_string('plugin', 'repository');
  46  
  47  require_login($course, false);
  48  $coursecontext = context_course::instance($course->id, MUST_EXIST);
  49  
  50  $link = new moodle_url('/user/view.php', array('id' => $user->id));
  51  $PAGE->navbar->add($fullname, $link);
  52  $PAGE->navbar->add($strrepos);
  53  $PAGE->set_title("$course->fullname: $fullname: $strrepos");
  54  $PAGE->set_heading($course->fullname);
  55  
  56  echo $OUTPUT->header();
  57  
  58  $currenttab = 'repositories';
  59  require ('tabs.php');
  60  
  61  echo $OUTPUT->heading($configstr);
  62  echo $OUTPUT->box_start();
  63  
  64  $params = array();
  65  $params['context'] = $coursecontext;
  66  $params['currentcontext'] = $PAGE->context;
  67  $params['userid']   = $USER->id;
  68  if (!$instances = repository::get_instances($params)) {
  69      print_error('noinstances', 'repository', $CFG->wwwroot . '/user/view.php');
  70  }
  71  
  72  $table = new html_table();
  73  $table->head = array($namestr, $pluginstr, '');
  74  $table->data = array();
  75  
  76  foreach ($instances as $i) {
  77      $path = '/repository/'.$i->type.'/settings.php';
  78      $settings = file_exists($CFG->dirroot.$path);
  79      $table->data[] = array($i->name, $i->type,
  80          $settings ? '<a href="'.$CFG->wwwroot.$path.'">'
  81              .get_string('settings', 'repository').'</a>' : '');
  82  }
  83  
  84  echo html_writer::table($table);
  85  echo $OUTPUT->footer();
  86  
  87