Merge branch 'MDL-50015-master' of git://github.com/jleyva/moodle
[moodle.git] / user / repository.php
blobdcabb9246b9f0198410df64ca87f5b7e9a022591
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.
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/>.
17 /**
18 * This file is part of the User section Moodle
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
25 require_once(dirname(dirname(__FILE__)) . '/config.php');
26 require_once($CFG->dirroot . '/repository/lib.php');
28 $config = optional_param('config', 0, PARAM_INT);
29 $course = optional_param('course', SITEID, PARAM_INT);
31 $url = new moodle_url('/user/repository.php', array('course' => $course));
32 if ($config !== 0) {
33 $url->param('config', $config);
35 $PAGE->set_url($url);
37 $course = $DB->get_record("course", array("id" => $course), '*', MUST_EXIST);
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');
47 require_login($course, false);
48 $coursecontext = context_course::instance($course->id, MUST_EXIST);
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);
56 echo $OUTPUT->header();
58 $currenttab = 'repositories';
59 require('tabs.php');
61 echo $OUTPUT->heading($configstr);
62 echo $OUTPUT->box_start();
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');
72 $table = new html_table();
73 $table->head = array($namestr, $pluginstr, '');
74 $table->data = array();
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>' : '');
84 echo html_writer::table($table);
85 echo $OUTPUT->footer();