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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
|
<?php
# Lifter002: TODO
# Lifter007: TODO
# Lifter003: TODO
# Lifter010: TODO
// +--------------------------------------------------------------------------+
// This file is part of Stud.IP
// Issue.class.php
//
// Repräsentiert ein einzelnes Thema einer Veranstaltung
//
// +--------------------------------------------------------------------------+
// This program 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 2
// of the License, or any later version.
// +--------------------------------------------------------------------------+
// This program 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 this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// +--------------------------------------------------------------------------+
/**
* Issue.class.php
*
*
* @author Till Glöggler <tgloeggl@uos.de>
* @version 19. Oktober 2005
* @access protected
* @package raumzeit
*/
class Issue {
var $issue_id = '';
var $seminar_id = '';
var $author_id = '';
var $title = '';
var $description = '';
var $mkdate = 0;
var $chdate = 0;
var $priority = 0;
var $file = FALSE;
var $folder_id = '';
var $messages = [];
var $new = false;
var $hasForum = false;
/**
* Constructor for class Issue
*
* $data is an Array with the following possible fields:
* issue_id: when set, the Issue with this id is restored
* seminar_id: when set and issue_id is not set, a new issue for this seminar is created
*
* returns NULL if both are unset
*/
function __construct($data = []) {
global $user;
if ($data['issue_id']) {
$this->issue_id = $data['issue_id'];
$this->restore();
} else if ($data['seminar_id']) {
$this->issue_id = md5(uniqid('Issue'));
$this->seminar_id = $data['seminar_id'];
$this->mkdate = time();
$this->chdate = time();
$this->author_id = $user->id;
$this->new = true;
} else {
return NULL;
}
}
function getPriority() {
return $this->priority;
}
function setPriority($priority) {
$this->priority = $priority;
}
function getMkDate() {
return $this->mkdate;
}
function getChDate() {
return $this->chdate;
}
function getTitle() {
return $this->title;
}
function setTitle($title) {
$this->title = $title;
}
function getDescription() {
return $this->description;
}
function setDescription($description) {
$this->description = $description;
}
function getAuthorID() {
return $this->author_id;
}
function getIssueID() {
return $this->issue_id;
}
function setSeminarID($seminar_id) {
$this->seminar_id = $seminar_id;
}
function getSeminarID() {
return $this->seminar_id;
}
function readSingleDates() {
/*if ($termin_data = IssueDB::getTermine($this->issue_id)) {
foreach ($termin_data as $val) {
$this->singleDates[] = $val['termin_id'];
}
return TRUE;
}*/
return FALSE;
}
function store() {
$this->chdate = time();
if ($this->hasForum) {
$sem = Seminar::getInstance($this->seminar_id);
$forum_module = $sem->getSlotModule('forum');
if ($forum_module instanceof ForumModule) {
$forum_module->setThreadForIssue($this->issue_id, $this->title, $this->description);
}
}
IssueDB::storeIssue($this);
$this->new = false;
}
function restore() {
/*
* To avoid inconsistency, the restore function has been removed.
* The only way to load an Issue is via the Seminar.class.php, with the function fillValuesFromArray
*/
$this->fillValuesFromArray(IssueDB::restoreIssue($this->issue_id));
}
function delete() {
$dates = IssueDB::getDatesforIssue($this->issue_id);
$titles = [];
$title = '';
foreach ($dates as $termin_id => $termin_data) {
$titles[] = date('d.m.y, H:i', $termin_data['date']).' - '.date('H:i', $termin_data['end_time']);
}
if (sizeof($titles) > 0) {
$title = implode(', ', $titles).', '.$this->getTitle() . ' ' ._("(Thema gelöscht)");
} else {
$title = $this->getTitle() . ' ' ._("(Thema gelöscht)");
}
$description = _("Dateiordner bezieht sich auf ein nicht mehr vorhandenes Thema.");
IssueDB::deleteIssue($this->issue_id, $this->seminar_id, $title, $description);
}
function fillValuesFromArray($data) {
$this->issue_id = $data['issue_id'];
$this->seminar_id = $data['seminar_id'];
$this->author_id = $data['author_id'];
$this->title = $data['title'];
$this->description = $data['description'];
$this->mkdate = $data['mkdate'];
$this->chdate = $data['chdate'];
$this->priority = $data['priority'];
$this->file = ($data['range_id'] == '') ? FALSE : TRUE;
if ($this->file) {
$this->folder_id = $data['folder_id'];
}
$this->new = false;
// check, if there is a forums-connection
$sem = Seminar::getInstance($this->seminar_id);
$forum_module = $sem->getSlotModule('forum');
if ($forum_module instanceof ForumModule) {
$this->hasForum = $forum_module->getLinkToThread($this->issue_id) ? true : false;
}
$this->readSingleDates();
}
function toString() {
return $this->title;
}
function getFolderID() {
if ($this->file) {
return $this->folder_id;
} else {
return FALSE;
}
}
function hasFile() {
return $this->file;
}
function setFile($file) {
if ($file != $this->file) {
if ($file) {
$this->messages[] = sprintf(_("Dateiordner für das Thema \"%s\" angelegt."),$this->toString());
} else {
//$this->messages[] = sprintf(_("Dateiordner für das Thema \"%s\" gelöscht!"),$this->toString());
}
}
$this->file = $file;
}
function setForum($newForumValue) {
// only do something, if we enable the link to a thread in a forum
if ($newForumValue) {
// find the ForumModule which takes the role of the CoreForum in the current Seminar
$sem = Seminar::getInstance($this->seminar_id);
$forum_module = $sem->getSlotModule('forum');
if ($forum_module instanceof ForumModule) {
// only link if there is none yet
if (!$forum_module->getLinkToThread($this->issue_id)) {
$forum_module->setThreadForIssue($this->issue_id, $this->title, $this->description);
$this->messages[] = sprintf(_("Ordner im Forum für das Thema \"%s\" angelegt."), $this->toString());
}
}
}
}
function getMessages() {
$temp = $this->messages;
$this->messages = NULL;
return $temp;
}
/* * * * * * * * * * * * * * * * * * * *
* * S T A T I C F U N C T I O N S * *
* * * * * * * * * * * * * * * * * * * */
function isIssue($issue_id) {
return IssueDB::isIssue($issue_id);
}
}
|