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
269
270
271
272
273
274
275
276
|
<?php
/**
* ResourceLabel.php - model class for a resource label
*
* The BrokenResource class represents resources whose class
* cannot be found due to missing Resource specialisations
* that cannot be loaded. This can happen if a plugin is uninstalled
* without removing the resources that are handled by the plugin.
*
* 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 (at your option) any later version.
*
* @author Moritz Strohm <strohm@data-quest.de>
* @copyright 2019
* @license http://www.gnu.org/licenses/gpl-2.0.html GPL version 2
* @category Stud.IP
* @package resources
* @since 4.5
*
* All properties are inherited from the parent class (Resource).
*
* @property string $id database column
* @property string $parent_id database column
* @property string $category_id database column
* @property int|null $level database column
* @property string $name database column
* @property I18NString|null $description database column
* @property int $requestable database column
* @property int $lockable database column
* @property int $booking_plan_request database column
* @property int $mkdate database column
* @property int $chdate database column
* @property int $sort_position database column
* @property SimpleORMapCollection<ResourceProperty> $properties has_many ResourceProperty
* @property SimpleORMapCollection<ResourcePermission> $permissions has_many ResourcePermission
* @property SimpleORMapCollection<ResourceRequest> $requests has_many ResourceRequest
* @property SimpleORMapCollection<ResourceBooking> $bookings has_many ResourceBooking
* @property SimpleORMapCollection<Resource> $children has_many Resource
* @property ResourceCategory $category belongs_to ResourceCategory
* @property Resource $parent belongs_to Resource
* @property mixed $class_name additional field
*/
class BrokenResource extends Resource
{
public function store()
{
//Broken resources shall not be stored or modified.
//Modification may break things.
return false;
}
public function getFolder($create_if_missing = true)
{
return null;
}
public function setFolder(ResourceFolder $folder)
{
return false;
}
public function createFolder()
{
return null;
}
public function createSimpleBooking(
User $user,
DateTime $begin,
DateTime $end,
$preparation_time = 0,
$description = '',
$internal_comment = '',
$booking_type = ResourceBooking::TYPE_NORMAL
)
{
return null;
}
public function createBookingFromRequest(
User $user,
ResourceRequest $request,
$preparation_time = 0,
$description = '',
$internal_comment = '',
$booking_type = ResourceBooking::TYPE_NORMAL,
$prepend_preparation_time = false,
$notify_lecturers = false
)
{
return null;
}
public function createBooking(
User $user,
$range_id = null,
$time_ranges = [],
$repetition_interval = null,
$repetition_amount = 0,
$repetition_end_date = null,
$preparation_time = 0,
$description = '',
$internal_comment = '',
$booking_type = ResourceBooking::TYPE_NORMAL,
$force_booking = false,
string $weekdays = ''
) {
return null;
}
public function createSimpleRequest(
User $user,
DateTime $begin,
DateTime $end,
$comment = '',
$preparation_time = 0
)
{
return null;
}
public function createRequest(
User $user,
$date_range_ids = null,
$comment = '',
$properties = [],
$preparation_time = 0
)
{
return null;
}
public function createLock(
User $user,
DateTime $begin,
DateTime $end,
$internal_comment = ''
)
{
return null;
}
public function propertyExists($name = '')
{
//Resource labels don't have properties:
return false;
}
public function getPropertyObject(string $name = '')
{
return null;
}
public function getProperty(string $name = '')
{
return null;
}
public function getPropertyRelatedObject(string $name = '')
{
return null;
}
public function setProperty(string $name = '', $state = '', $user_id = null)
{
return false;
}
public function isPropertyEditable(string $name, User $user)
{
return false;
}
public function setPropertyByDefinitionId(
$property_definition_id = null,
$state = null
)
{
return false;
}
public function setPropertyRelatedObject(string $name, SimpleORMap $object)
{
return false;
}
public function getIcon($role = Icon::ROLE_INFO)
{
return Icon::create('resources-broken', $role);
}
public function getPropertyArray($only_requestable_properties = false)
{
return [];
}
public function isAssigned(
DateTime $begin,
DateTime $end,
$excluded_booking_ids = []
)
{
return false;
}
public function isReserved(
DateTime $begin,
DateTime $end,
$excluded_reservation_ids = []
)
{
return false;
}
public function isLocked(
DateTime $begin,
DateTime $end,
$excluded_lock_ids = []
)
{
return true;
}
public function isAvailable(
DateTime $begin,
DateTime $end,
$excluded_booking_ids = []
)
{
return false;
}
public function isAvailableForRequest(ResourceRequest $request)
{
return false;
}
public function getFullName()
{
return sprintf('%1$s (%2$s)', $this->name, _('defekt'));
}
public function getOpenResourceRequests(DateTime $begin, DateTime $end)
{
return [];
}
public function getResourceBookings(DateTime $begin, DateTime $end, array $booking_types = [0])
{
return [];
}
public function getResourceLocks(DateTime $begin, DateTime $end)
{
return [];
}
public function hasFiles()
{
return false;
}
public function checkHierarchy()
{
return true;
}
public function getItemAvatarURL()
{
return Icon::create('info', Icon::ROLE_INFO)->asImagePath();
}
}
|