Repository navigation
Expand file tree
/
Copy pathdeliverables.controller.php
More file actions
161 lines (132 loc) · 6.02 KB
/
Copy pathdeliverables.controller.php
File metadata and controls
161 lines (132 loc) · 6.02 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
<?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/>.
/**
* @package mod_techproject
* @category mod
* @author Valery Fremaux (France) (admin@www.ethnoinformatique.fr)
* @date 2008/03/03
* @version phase1
* @contributors LUU Tao Meng, So Gerard (parts of treelib.php), Guillaume Magnien, Olivier Petit
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
*/
defined('MOODLE_INTERNAL') || die();
// Controller.
if ($work == 'dodelete') {
$delivid = required_param('delivid', PARAM_INT);
$oldrecord = $DB->get_record('techproject_deliverable', array('id' => $delivid));
techproject_tree_delete($delivid, 'techproject_deliverable');
$event = \mod_techproject\event\deliverable_deleted::create_from_deliverable($project, $context, $oldrecord, $currentgroupid);
$event->trigger();
} else if ($work == 'domove' || $work == 'docopy') {
$ids = required_param_array('ids', PARAM_INT);
$to = required_param('to', PARAM_ALPHA);
switch ($to) {
case 'requs': {
$table2 = 'techproject_requirement';
$redir = 'requirement';
break;
}
case 'specs': {
$table2 = 'techproject_specification';
$redir = 'specification';
break;
}
case 'tasks': {
$table2 = 'techproject_task';
$redir = 'task';
break;
}
case 'deliv': {
$table2 = 'techproject_deliverable';
$redir = 'deliverable';
break;
}
}
techproject_tree_copy_set($ids, 'techproject_deliverable', $table2);
$event = \mod_techproject\event\deliverable_mutated::create_from_deliverable($project, $context, $olddeliverable,
$currentgroupid, $redir);
$event->trigger();
if ($work == 'domove') {
// Bounce to deleteitems.
$work = 'dodeleteitems';
$withredirect = 1;
} else {
$redirecturl = new moodle_url('/mod/techproject/view.php', array('id' => $cm->id, 'view' => $redir.'s'));
redirect($redirecturl, get_string('redirectingtoview', 'techproject').get_string($redir, 'techproject'));
}
}
if ($work == 'dodeleteitems') {
$ids = required_param_array('ids', PARAM_INT);
foreach ($ids as $anitem) {
// Save record for further cleanups and propagation.
$oldrecord = $DB->get_record('techproject_deliverable', array('id' => $anitem));
$childs = $DB->get_records('techproject_deliverable', array('fatherid' => $anitem));
// Update fatherid in childs.
$sql = "
UPDATE
{techproject_deliverable}
SET
fatherid = ?
WHERE
fatherid = $anitem
";
$DB->execute($sql, array($oldrecord->fatherid));
$DB->delete_records('techproject_deliverable', array('id' => $anitem));
// Delete all related records.
$DB->delete_records('techproject_task_to_deliv', array('delivid' => $anitem));
}
$event = \mod_techproject\event\deliverable_deleted::create_from_deliverable($project, $context, $oldrecord, $currentgroupid);
$event->trigger();
if (isset($withredirect) && $withredirect) {
$redirecturl = new moodle_url('/mod/techproject/view.php', array('id' => $cm->id, 'view' => $redir.'s'));
redirect($redirecturl, get_string('redirectingtoview', 'techproject').' : '.get_string($redir, 'techproject'));
}
} else if ($work == 'doclearall') {
// Delete all records. POWERFUL AND DANGEROUS COMMAND.
$DB->delete_records('techproject_deliverable', array('projectid' => $project->id));
$event = \mod_techproject\event\deliverable_cleared::create_for_group($project, $context, $currentgroupid);
$event->trigger();
} else if ($work == 'doexport') {
$ids = required_param_array('ids', PARAM_INT);
$idlist = implode("','", $ids);
$select = "
id IN ('$idlist')
";
$deliverables = $DB->get_records_select('techproject_deliverable', $select);
$worktypes = techproject_get_options('delivstatus', $this->project->id);
include_once($CFG->dirroot.'/mod/techproject/xmllib.php');
$xmldelivstatusses = recordstoxml($delivstatusses, 'deliv_status_option', '', false, 'techproject');
$xml = recordstoxml($deliverables, 'deliverable', $xmldelivstatusses, true, null);
$escaped = str_replace('<', '<', $xml);
$escaped = str_replace('>', '>', $escaped);
echo $OUTPUT->heading(get_string('xmlexport', 'techproject'));
echo $OUTPUT->simple_box("<pre>$escaped</pre>");
$viewurl = new moodle_url('/mod/techproject/view.php', array('view' => 'deliverables', 'id' => $cm->id));
echo $OUTPUT->continue_button($viewurl);
return;
} else if ($work == 'up') {
$delivid = required_param('delivid', PARAM_INT);
techproject_tree_up($project, $currentgroupid, $delivid, 'techproject_deliverable');
} else if ($work == 'down') {
$delivid = required_param('delivid', PARAM_INT);
techproject_tree_down($project, $currentgroupid, $delivid, 'techproject_deliverable');
} else if ($work == 'left') {
$delivid = required_param('delivid', PARAM_INT);
techproject_tree_left($project, $currentgroupid, $delivid, 'techproject_deliverable');
} else if ($work == 'right') {
$delivid = required_param('delivid', PARAM_INT);
techproject_tree_right($project, $currentgroupid, $delivid, 'techproject_deliverable');
}