copyFile($file, $destinationPath, $move); if (isset($result['error'])) { if ($move) { $feedback[] = '' . tr('Move was not successful for "%0"', $file['filename']) . '
(' . $result['error'] . ')
'; } else { $feedback[] = '' . tr('Copy was not successful for "%0"', $file['filename']) . '
(' . $result['error'] . ')
'; } } else { if ($move) { $feedback[] = tra('Move was successful') . ': ' . $file['filename']; } else { $feedback[] = tra('Copy was successful') . ': ' . $file['filename']; } } } return $feedback; } /** * Takes a file from a file gallery and copies/moves it to a local path * * @param array $file * @param string $destinationPath * @param string $sourcePath * @param bool $move * @return array [fileName[,error]] */ public function copyFile($file, $destinationPath, $move = false) { $file = \Tiki\FileGallery\File::id($file['fileId']); $source = $file->getWrapper()->getReadableFile(); if (! copy($source, $destinationPath . $file->filename)) { if (! is_writable($destinationPath)) { return ['error' => tra('Cannot write to this path: ') . $destinationPath]; } else { return ['error' => tra('Cannot read this file: ') . $source]; } } if ($move) { if ($this->remove_file($file->getParams(), '', true) === false) { return ['error' => tra('Cannot remove file from gallery')]; } } return [ 'fileName' => $file->filename, ]; } }