blob: 0c1fa3e06370015ea8509221f8101cf94bd3bf94 (
plain)
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
|
<?php
namespace Courseware\Filesystem;
use Folder;
use FolderType;
use Icon;
use StandardFolder;
class PublicFolder extends StandardFolder
{
protected $folder;
/**
* {@inheritdoc}
*/
public function __construct($folder = null)
{
$this->folder = $folder instanceof Folder ? $folder : Folder::build($folder);
$this->folder['folder_type'] = get_class($this);
}
/**
* {@inheritdoc}
*/
public function __get($attribute)
{
return $this->folder[$attribute];
}
/**
* {@inheritdoc}
*/
public static function getTypeName()
{
return _('Ein Ordner für öffentlich zugängliche Dateien einer Courseware');
}
/**
* {@inheritdoc}
*/
public static function availableInRange($rangeIdOrObject, $userId)
{
return false;
}
/**
* {@inheritdoc}
*/
public function getIcon($role = Icon::DEFAULT_ROLE)
{
return Icon::create('folder-public-full', $role);
}
/**
* {@inheritdoc}
*/
public function getId()
{
return $this->folder->id;
}
/**
* {@inheritdoc}
*/
public function isVisible($userId)
{
return true;
}
/**
* {@inheritdoc}
*/
public function isReadable($userId)
{
return true;
}
/**
* {@inheritdoc}
*/
public function isWritable($userId)
{
// TODO
return true;
}
/**
* {@inheritdoc}
*/
public function isEditable($userId)
{
return false;
}
/**
* {@inheritdoc}
*/
public function isSubfolderAllowed($userId)
{
return false;
}
/**
* {@inheritdoc}
*/
public function getDescriptionTemplate()
{
return '';
}
/**
* {@inheritdoc}
*/
public function getSubfolders()
{
return [];
}
/**
* {@inheritdoc}
*/
public function getParent()
{
return null;
}
/**
* {@inheritdoc}
*/
public function getEditTemplate()
{
return '';
}
/**
* {@inheritdoc}
*/
public function setDataFromEditTemplate($request)
{
return $this;
}
/**
* {@inheritdoc}
*/
public function deleteFile($fileRefId)
{
$fileRefs = $this->folder->file_refs;
if (is_array($fileRefs)) {
foreach ($fileRefs as $fileRef) {
if ($fileRef->id === $fileRefId) {
return $fileRef->delete();
}
}
}
return false;
}
/**
* {@inheritdoc}
*/
public function store()
{
return $this->folder->store();
}
/**
* {@inheritdoc}
*/
public function createSubfolder(FolderType $folderdata)
{
return null;
}
/**
* {@inheritdoc}
*/
public function deleteSubfolder($subfolderId)
{
return false;
}
/**
* {@inheritdoc}
*/
public function delete()
{
return $this->folder->delete();
}
/**
* {@inheritdoc}
*/
public function isFileDownloadable($fileRefId, $userId)
{
return true;
}
/**
* {@inheritdoc}
*/
public function isFileEditable($fileRefId, $userId)
{
return false;
}
/**
* {@inheritdoc}
*/
public function isFileWritable($fileRefId, $userId)
{
return false;
}
}
|