-
Notifications
You must be signed in to change notification settings - Fork 0
/
upload.php
executable file
·59 lines (44 loc) · 1.93 KB
/
upload.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
require_once(dirname(dirname(dirname(__FILE__))).'/config.php');
require_once(dirname(__FILE__).'/lib.php');
require_once(dirname(__FILE__).'/locallib.php');
require_once(dirname(__FILE__).'/mod_form.php');
$id = optional_param('id', 0, PARAM_INT); // course_module ID, or
$n = optional_param('n', 0, PARAM_INT); // diplome instance ID - it should be named as the first character of the module
$remove = optional_param('remove', 0, PARAM_INT);
if ($id) {
$cm = get_coursemodule_from_id('diplome', $id, 0, false, MUST_EXIST);
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
$diplome = $DB->get_record('diplome', array('id' => $cm->instance), '*', MUST_EXIST);
$param = 'id';
$val = $id;
} elseif ($n) {
$diplome = $DB->get_record('diplome', array('id' => $n), '*', MUST_EXIST);
$course = $DB->get_record('course', array('id' => $diplome->course), '*', MUST_EXIST);
$cm = get_coursemodule_from_instance('diplome', $diplome->id, $course->id, false, MUST_EXIST);
$param = 'n';
$val = $n;
} else {
print_error('You must specify a course_module ID or an instance ID');
}
require_login($course, true, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
add_to_log($course->id, 'diplome', 'Upload', "upload.php?id={$cm->id}", $diplome->name, $cm->id);
$PAGE->set_url('/mod/diplome/upload.php', array('id' => $cm->id));
$PAGE->set_title(format_string($diplome->name));
$PAGE->set_heading(format_string($course->fullname));
$PAGE->set_context($context);
echo $OUTPUT->header();
build_tabs('upload', $id, $n);
if(has_capability('mod/diplome:upload', $context)) {
$options[] = new tabobject ('upload',
'view.php?'.$param.'='.$val.'&page=1',
get_string('tabupload', 'diplome'),
get_string('tabuploaddesc', 'diplome'),
true);
print_upload_table($course, $cm, $n, $id);
}
else {
echo 'nu are capabilitati';
}
echo $OUTPUT->footer();