-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeletesubmit.php
73 lines (62 loc) · 2.87 KB
/
deletesubmit.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?PHP // $Id: view.php,v 1.1 2003/09/30 02:45:19 moodler Exp $
/// This page prints a particular instance of programming
/// (Replace programming with the name of your module)
require_once('../../config.php');
require_once('lib.php');
$submitid = optional_param('submitid');
$a = optional_param('a');
$confirm = optional_param('confirm');
$href = optional_param('href', $_SERVER['HTTP_REFERER'], PARAM_URL);
if (! $programming = get_record('programming', 'id', $a)) {
error('Course module is incorrect');
}
if (! $course = get_record('course', 'id', $programming->course)) {
error('Course is misconfigured');
}
if (! $cm = get_coursemodule_from_instance('programming', $programming->id, $course->id)) {
error('Course Module ID was incorrect');
}
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_login($course->id);
require_capability('mod/programming:deleteothersubmit', $context);
/// Print the page header
$pagename = get_string('deletesubmits', 'programming');
include_once('pageheader.php');
/// Print the main part of the page
if ($confirm) {
foreach ($submitid as $id) {
$submit = get_record('programming_submits', 'id', $id);
if ($submit) programming_delete_submit($submit);
}
add_to_log($course->id, 'programming', 'delete submit', '', implode($submitid, ','));
echo '<div class="maincontent generalbox">';
echo '<p align="center">'.get_string('deleted').'</p>';
echo '<p align="center"><a href="'.$href.'">'.get_string('continue').'</a></p>';
echo '</div>';
} else {
echo '<table align="center" width="60%" class="noticebox" border="0" cellpadding="20" cellspacing="0">';
echo '<tr><td bgcolor="#FFAAAA" class="noticeboxcontent">';
echo '<h2 class="main">'.get_string('deletesubmitconfirm', 'programming').'</h2>';
echo '<ul>';
foreach ($submitid as $id) {
$submit = get_record('programming_submits', 'id', $id);
$tm = userdate($submit->timemodified);
$user = fullname(get_record('user', 'id', $submit->userid));
echo "<li>$id $user $tm</li>";
}
echo '</ul>';
echo '<form name="form" method="post">';
foreach ($submitid as $id) {
echo "<input type='hidden' name='submitid[]' value='$id' />";
}
echo "<input type='hidden' name='a' value='$a' />";
echo '<input type="hidden" name="confirm" value="1" />';
echo "<input type='hidden' name='href' value='$href' />";
echo '<input type="submit" value=" '.get_string('yes').' " /> ';
echo '<input type="button" value=" '.get_string('no').' " onclick="javascript:history.go(-1);" />';
echo '</form>';
echo '</td></tr></table>';
}
/// Finish the page
print_footer($course);
?>