Löschen von downloadbaren Dateien eingebaut
This commit is contained in:
committed by
Eric Blommel
parent
7c5dfdfa92
commit
5ca5899368
@@ -187,10 +187,20 @@ class TopicData
|
|||||||
*/
|
*/
|
||||||
private function addDownload(string $name, string $tmp_name): bool
|
private function addDownload(string $name, string $tmp_name): bool
|
||||||
{
|
{
|
||||||
if(!move_uploaded_file($tmp_name, Config::getTopicDirectory($this->getSubjectId() , $this->getId()) . "downloads/" . $name)) {
|
$downloadDirectory = Config::getTopicDirectory($this->getSubjectId() , $this->getId()) . "downloads/";
|
||||||
|
|
||||||
|
if(!is_dir($downloadDirectory)) {
|
||||||
|
if(!mkdir($downloadDirectory)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!move_uploaded_file($tmp_name, $downloadDirectory . $name)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->files[] = $name;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -222,6 +232,21 @@ class TopicData
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function deleteDownload(string $name): bool
|
||||||
|
{
|
||||||
|
if(!isset($this->files[$name])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!unlink(Config::getTopicDirectory($this->getSubjectId() , $this->getId()) . "downloads/$name")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->files = array_diff($this->files, [$name]);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Löscht das Thema inklusive aller zugehörigen Dateien
|
* Löscht das Thema inklusive aller zugehörigen Dateien
|
||||||
* @return bool true, wenn erfolgreich gelöscht, sonst false
|
* @return bool true, wenn erfolgreich gelöscht, sonst false
|
||||||
|
|||||||
Reference in New Issue
Block a user