Merge branch 'wip-MDL-31763-master' of git://github.com/abgreeve/moodle
[moodle.git] / user / repository.php
blob23ed84f160b588b7db3ddf4cedfa0d9634eb524b
1 <?php
3 // This file is part of Moodle - http://moodle.org/
4 //
5 // Moodle is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // Moodle is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
18 /**
19 * This file is part of the User section Moodle
21 * @copyright 1999 Martin Dougiamas http://dougiamas.com
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23 * @package user
26 require_once(dirname(dirname(__FILE__)) . '/config.php');
27 require_once($CFG->dirroot . '/repository/lib.php');
29 $config = optional_param('config', 0, PARAM_INT);
30 $course = optional_param('course', SITEID, PARAM_INT);
32 $url = new moodle_url('/user/repository.php', array('course'=>$course));
33 if ($config !== 0) {
34 $url->param('config', $config);
36 $PAGE->set_url($url);
38 $course = $DB->get_record("course", array("id"=>$course), '*', MUST_EXIST);
40 $user = $USER;
41 $baseurl = $CFG->wwwroot . '/user/repository.php';
42 $namestr = get_string('name');
43 $fullname = fullname($user);
44 $strrepos = get_string('repositories', 'repository');
45 $configstr = get_string('manageuserrepository', 'repository');
46 $pluginstr = get_string('plugin', 'repository');
48 require_login($course, false);
49 $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id, MUST_EXIST);
51 $link = new moodle_url('/user/view.php', array('id'=>$user->id));
52 $PAGE->navbar->add($fullname, $link);
53 $PAGE->navbar->add($strrepos);
54 $PAGE->set_title("$course->fullname: $fullname: $strrepos");
55 $PAGE->set_heading($course->fullname);
57 echo $OUTPUT->header();
59 $currenttab = 'repositories';
60 include('tabs.php');
62 echo $OUTPUT->heading($configstr);
63 echo $OUTPUT->box_start();
65 $params = array();
66 $params['context'] = $coursecontext;
67 $params['currentcontext'] = $PAGE->context;
68 $params['userid'] = $USER->id;
69 if (!$instances = repository::get_instances($params)) {
70 print_error('noinstances', 'repository', $CFG->wwwroot . '/user/view.php');
73 $table = new html_table();
74 $table->head = array($namestr, $pluginstr, '');
75 $table->data = array();
77 foreach ($instances as $i) {
78 $path = '/repository/'.$i->type.'/settings.php';
79 $settings = file_exists($CFG->dirroot.$path);
80 $table->data[] = array($i->name, $i->type,
81 $settings ? '<a href="'.$CFG->wwwroot.$path.'">'
82 .get_string('settings', 'repository').'</a>' : '');
85 echo html_writer::table($table);
86 echo $OUTPUT->footer();