Skip to content

Commit

Permalink
[FIX] 0036305: Instruction Files Issue - Unizip a zip-file does not w…
Browse files Browse the repository at this point in the history
…ork, and with German language -> it is possible to "unzip" a standard-file
  • Loading branch information
chfsx committed Sep 6, 2023
1 parent 831ef8e commit 36dcd70
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
5 changes: 3 additions & 2 deletions Services/FileSystem/classes/class.ilFileSystemGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ public function uploadFile(): void
$name,
true
);
// end upload
// end upload
} elseif ($uploaded_file) {
// check if the file is in the ftp directory and readable
if (ilUploadFiles::_checkUploadFile($uploaded_file)) {
Expand Down Expand Up @@ -935,7 +935,8 @@ public function defineCommands(): void
"method" => "unzipFile",
"name" => $this->lng->txt("unzip"),
"int" => true,
"single" => true
"single" => true,
"id" => "unzip_file"
),
3 => array(
"object" => $this,
Expand Down
24 changes: 19 additions & 5 deletions Services/FileSystem/classes/class.ilFileSystemTableGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ public function __construct(
$this->row_commands[] = array(
"cmd" => "extCommand_" . $i,
"caption" => $command["name"],
"allow_dir" => $command["allow_dir"] ?? ""
"allow_dir" => $command["allow_dir"] ?? "",
"id" => $command["id"] ?? "",
);
}
}
Expand Down Expand Up @@ -254,13 +255,26 @@ protected function fillRow(array $a_set): void
}

// single item commands
if (sizeof($this->row_commands) &&
!($a_set["type"] == "dir" && $a_set["entry"] == "..")) {

$zip_mime_types = [
"application/zip",
"application/x-zip"
];

if (count($this->row_commands) > 0
&& !(($a_set["type"] ?? '') === "dir" && ($a_set["entry"] ?? '') === "..")) {
$advsel = new ilAdvancedSelectionListGUI();
$advsel->setListTitle('');
foreach ($this->row_commands as $rcom) {
if ($rcom["allow_dir"] || $a_set["type"] != "dir") {
if (($rcom["caption"] == "Unzip" && MimeType::getMimeType($this->cur_dir . $a_set['entry']) == "application/zip") || $rcom["caption"] != "Unzip") {
if ($rcom["allow_dir"] || ($a_set["type"] ?? '') !== "dir") {
// see https://mantis.ilias.de/view.php?id=36305
// will be dropped soon anyway...
$path = $this->cur_dir . $a_set['entry'];
$mime_type = MimeType::getMimeType($path);
if (
$rcom["id"] !== "unzip_file"
|| ($rcom["id"] === "unzip_file" && in_array($mime_type, $zip_mime_types))
) {
$this->ctrl->setParameter($this->parent_obj, "fhsh", $hash);
$url = $this->ctrl->getLinkTarget($this->parent_obj, $rcom["cmd"]);
$this->ctrl->setParameter($this->parent_obj, "fhsh", "");
Expand Down

0 comments on commit 36dcd70

Please sign in to comment.