public function setFile(File $toSave) { $permissionEngine = PermissionEngine::getInstance(); if (!$permissionEngine->currentUserCanDo('uploadFile')) { return false; } $database = Database::getInstance(); if (!$database->isConnected()) { return false; } $validator = new checkIfKnownMimeType(); if (!$validator->validate($toSave->getMimeType())) { return false; } if (!is_readable($toSave->getLocation())) { return false; } $id = $database->escapeString($toSave->getID()); $dateUploaded = $database->escapeString($toSave->getUploadedDate()->format('Y-m-d H:i:s')); $title = $database->escapeString(strip_tags($toSave->getTitle())); $mimeType = $database->escapeString($toSave->getMimeType()); $size = $database->escapeString($toSave->getSize()); $location = $database->escapeString($toSave->getLocation()); $nodeID = $database->escapeString($toSave->getNodeID()); $uploader = $database->escapeString($toSave->getUploaderID()); $folder = $database->escapeString($toSave->getFolderID()); $result = $database->updateTable('file', "uploaded='{$dateUploaded}', title='{$title}', mimeType='{$mimeType}', size={$size}, location='{$location}', nodeID={$nodeID}, uploader={$uploader}, folderID={$folder}", "fileID='{$id}'"); if ($result === false) { return false; } return true; }
public function setMimeType($inMimeType) { $validator = new checkIfKnownMimeType(); if (!$validator->validate($inMimeType)) { return; } $this->mimeType = $inMimeType; }