Newer
Older
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
<?php
class FileController extends PluginController
{
function validate_args(&$args, $types = NULL)
{
reset($args);
}
/**
* The action for editing a file reference.
*/
public function edit_action($file_ref_id)
{
$file_id = substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], "plugins.php/owncloudplugin/file/edit/") + strlen("plugins.php/owncloudplugin/file/edit/"));
if (strpos($file_id, "?") !== false) {
$file_id = substr($file_id, 0, strpos($file_id, "?"));
}
$plugin = PluginManager::getInstance()->getPlugin("OwnCloudPlugin");
$this->file = $plugin->getPreparedFile($file_id);
$this->from_plugin = Request::get("from_plugin");
$this->folder = $this->file->getFoldertype();
if (!$this->folder || !$this->folder->isFileEditable($this->file->getId(), $GLOBALS['user']->id)) {
throw new AccessDeniedException();
}
if (Request::isPost()) {
//form was sent
CSRFProtection::verifyUnsafeRequest();
$this->errors = [];
$this->name = trim(Request::get('name'));
$result = $this->folder->editFile(
$file_id,
$this->name
);
if (!$result instanceof FileRef) {
$this->errors = array_merge($this->errors, $result);
}
if ($this->errors) {
PageLayout::postError(
sprintf(
_('Fehler beim Ändern der Datei %s!'),
htmlReady($this->file->getFilename())
),
$this->errors
);
} else {
PageLayout::postSuccess(_('Änderungen gespeichert!'));
$this->redirect(URLHelper::getURL("dispatch.php/files/system/".$this->plugin->getPluginId()."/".$this->folder->getId()));
}
}
$this->name = $this->file->getFilename();
$tf = new Flexi_TemplateFactory($GLOBALS['STUDIP_BASE_PATH']."/app/views");
$this->aside_template = $tf->open("file/_file_aside.php");
$this->aside_template->file = $this->file;
}
/**
* This action is responsible for updating a file reference.
*/
public function update_action($file_ref_id)
{
$file_id = substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], "plugins.php/owncloudplugin/file/update/") + strlen("plugins.php/owncloudplugin/file/update/"));
if (strpos($file_id, "?") !== false) {
$file_id = substr($file_id, 0, strpos($file_id, "?"));
}
$plugin = PluginManager::getInstance()->getPlugin(Request::get("from_plugin"));
if (!$plugin) {
throw new Trails_Exception(404, _('Plugin existiert nicht.'));
}
$this->file = $plugin->getPreparedFile($file_id);
$this->from_plugin = Request::get("from_plugin");
$this->folder = $this->file->getFolderType();
if (!$this->file->isEditable($GLOBALS['user']->id)) {
throw new AccessDeniedException();
}
$this->errors = [];
if (Request::submitted('confirm')) {
CSRFProtection::verifyUnsafeRequest();
//Form was sent
if (Request::isPost() && is_array($_FILES['file'])) {
$this->file->update($_FILES['file']['tmp_name']);
if (Request::submitted("update_filename")) {
$new_name = ($this->folder->id ? $this->folder->id."/" : "").$_FILES['file']['name'];
$this->folder->editFile(
$file_id,
$new_name
);
}
} else {
$this->errors[] = _('Es wurde keine neue Dateiversion gewählt!');
}
if ($this->errors) {
PageLayout::postError(
sprintf(
_('Fehler beim Aktualisieren der Datei %s!'),
htmlReady($this->file_ref->name)
),
$this->errors
);
} else {
PageLayout::postSuccess(
sprintf(
_('Datei %s wurde aktualisiert!'),
htmlReady($this->file_ref->name)
)
);
}
$this->redirect(URLHelper::getURL("dispatch.php/files/system/".$this->plugin->getPluginId()."/".$this->folder->getId()));
}
}
}