-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdelete_submit.php
More file actions
213 lines (181 loc) · 7.08 KB
/
delete_submit.php
File metadata and controls
213 lines (181 loc) · 7.08 KB
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* prints the form to confirm the deleting of a submit
*
* @author Andreas Grabs
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package apply
*/
require_once('../../config.php');
require_once(dirname(__FILE__).'/delete_submit_form.php');
require_once(dirname(__FILE__).'/jbxl/jbxl_moodle_tools.php');
require_once(dirname(__FILE__).'/locallib.php');
$id = required_param('id', PARAM_INT);
$submit_id = required_param('submit_id', PARAM_INT);
$submit_ver = optional_param('submit_ver', -1, PARAM_INT);
$courseid = optional_param('courseid', false, PARAM_INT);
$action = optional_param('action', '', PARAM_ALPHAEXT);
$urlparams['id'] = $id;
$urlparams['courseid'] = $courseid;
$urlparams['action'] = $action;
if (!confirm_sesskey()) {
print_error('invalidsesskey');
}
//
if (!$submit_id) {
print_error('no_submit_data', 'apply', 'mod/apply/view.php?id='.$id.'&do_show=view');
}
$submit = $DB->get_record('apply_submit', array('id'=>$submit_id));
if (!$submit) {
print_error('no_submit_data', 'apply', 'mod/apply/view.php?id='.$id.'&do_show=view');
}
//
$PAGE->set_url('/mod/apply/delete_submit.php', array('id'=>$id, 'submit_id'=>$submit_id, 'submit_ver'=>$submit_ver));
if (! $cm = get_coursemodule_from_id('apply', $id)) {
print_error('invalidcoursemodule');
}
if (! $course = $DB->get_record('course', array('id'=>$cm->course))) {
print_error('coursemisconf');
}
if (! $apply = $DB->get_record('apply', array('id'=>$cm->instance))) {
print_error('invalidcoursemodule');
}
if (!$courseid) $courseid = $course->id;
//
require_login($course, true, $cm);
//
$context = context_module::instance($cm->id);
if ($USER->id!=$submit->user_id) {
require_capability('mod/apply:deletesubmissions', $context);
}
//
$mform = new mod_apply_delete_submit_form();
$newformdata = array('id'=>$id, 'submit_id'=>$submit_id, 'confirmdelete'=>'1', 'do_show'=>'edit', 'action'=>$action);
$mform->set_data($newformdata);
$formdata = $mform->get_data();
if ($mform->is_cancelled()) {
redirect('view.php?id='.$id.'&do_show=view');
}
// Discard
if (isset($formdata->confirmdelete) and $formdata->confirmdelete==1) {
if ($submit = $DB->get_record('apply_submit', array('id'=>$submit_id))) {
//
if (isset($formdata->action) and $formdata->action=='delete_submit' and $apply->enable_deletemode) {
// 任意の申請を削除
require_capability('mod/apply:deletesubmissions', $context);
apply_delete_submit($submit_id);
$event = apply_get_event($cm, 'delete', $urlparams, 'delete_submit');
jbxl_add_to_log($event);
redirect('view_entries.php?id='.$id.'&do_show=view_entries');
}
//
else {
$log_url = 'delete_submit.php?id='.$cm->id.'&submit_id='.$submit_id.'&submit_ver='.$submit_ver;
if ($submit->version<=1 and $submit->acked!=APPLY_ACKED_ACCEPT) {
// 全体を削除可能
apply_delete_submit_safe($submit_id);
$event = apply_get_event($cm, 'delete', $urlparams, 'delete');
jbxl_add_to_log($event);
}
else if ($submit->acked!=APPLY_ACKED_ACCEPT) {
// 最新の申請(未認証)のみ取消可能(ロールバック)
apply_rollback_submit($submit_id);
$event = apply_get_event($cm, 'delete', $urlparams, 'rollback');
jbxl_add_to_log($event);
}
else {
// 申請の解除
apply_cancel_submit($submit_id);
$event = apply_get_event($cm, 'delete', $urlparams, 'cancel');
jbxl_add_to_log($event);
}
//
redirect('view.php?id='.$id.'&do_show=view');
}
}
}
///////////////////////////////////////////////////////////////////////////
// Print the page header
$strapplys = get_string('modulenameplural', 'apply');
$strapply = get_string('modulename', 'apply');
if ($action=='delete_submit' and $apply->enable_deletemode) {
// 任意の申請を削除
require_capability('mod/apply:deletesubmissions', $context);
$PAGE->navbar->add(get_string('delete_submit', 'apply'));
}
//
else {
if ($submit->version<=1 and $submit->acked!=APPLY_ACKED_ACCEPT) {
// 全体を削除可能
$PAGE->navbar->add(get_string('delete_entry', 'apply'));
}
else if ($submit->acked!=APPLY_ACKED_ACCEPT) {
// 最新の申請(未認証)のみ取消可能(ロールバック)
$PAGE->navbar->add(get_string('rollback_entry', 'apply'));
}
else {
// 申請の解除
$PAGE->navbar->add(get_string('cancel_entry', 'apply'));
}
}
$PAGE->set_heading(format_string($course->fullname), 3);
$PAGE->set_title(format_string($apply->name));
echo $OUTPUT->header();
echo '<style type="text/css">';
include('./html/html.css');
echo '</style>';
///////////////////////////////////////////////////////////////////////////
///Print the main part of the page
echo '<div align="center">';
echo $OUTPUT->heading(format_text($apply->name), 3);
echo '</div>';
echo '<br />';
echo $OUTPUT->box_start('generalbox errorboxcontent boxaligncenter boxwidthnormal');
//
if ($action=='delete_submit' and $apply->enable_deletemode) {
// 任意の申請を削除
require_capability('mod/apply:deletesubmissions', $context);
$user_name = jbxl_get_user_name($submit->user_id, $apply->name_pattern);
echo $OUTPUT->heading(get_string('confirm_delete_submit', 'apply'), 4);
echo '<br />';
echo $OUTPUT->heading($user_name.' : '.$submit->title, 4);
}
//
else {
if ($submit->version<=1 and $submit->acked!=APPLY_ACKED_ACCEPT) {
// 全体を削除可能
echo $OUTPUT->heading(get_string('confirm_delete_entry', 'apply'), 4);
echo '<br />';
echo $OUTPUT->heading($submit->title, 4);
}
else if ($submit->acked!=APPLY_ACKED_ACCEPT) {
// 最新の申請(未認証)のみ取消可能(ロールバック)
echo $OUTPUT->heading(get_string('confirm_rollback_entry', 'apply'), 4);
echo '<br />';
echo $OUTPUT->heading($submit->title, 4);
}
else {
// 申請の解除
echo $OUTPUT->heading(get_string('confirm_cancel_entry', 'apply'), 4);
echo '<br />';
echo $OUTPUT->heading($submit->title, 4);
}
}
//
$mform->display();
echo $OUTPUT->box_end();
echo $OUTPUT->footer();