Skip to content

Commit

Permalink
*8094* Centralize public files actions
Browse files Browse the repository at this point in the history
  • Loading branch information
asmecher committed Jan 30, 2013
1 parent e0d3f3b commit b7f4883
Showing 1 changed file with 28 additions and 17 deletions.
45 changes: 28 additions & 17 deletions classes/file/PublicFileManager.inc.php
Expand Up @@ -29,7 +29,18 @@ function PublicFileManager() {
* @return string
*/
function getJournalFilesPath($journalId) {
return Config::getVar('files', 'public_files_dir') . '/journals/' . $journalId;
return $this->getContextFilesPath(ASSOC_TYPE_JOURNAL, $journalId);
}

/**
* Get the path to a press' public files directory.
* @param $assocType int Assoc type for context
* @param $contextId int Press ID
* @return string
*/
function getContextFilesPath($assocType, $contextId) {
assert($assocType == ASSOC_TYPE_JOURNAL);
return Config::getVar('files', 'public_files_dir') . '/journals/' . (int) $contextId;
}

/**
Expand All @@ -39,9 +50,9 @@ function getJournalFilesPath($journalId) {
* @param $destFileName string the destination file name
* @return boolean
*/
function uploadJournalFile($journalId, $fileName, $destFileName) {
return $this->uploadFile($fileName, $this->getJournalFilesPath($journalId) . '/' . $destFileName);
}
function uploadJournalFile($journalId, $fileName, $destFileName) {
return $this->uploadContextFile(ASSOC_TYPE_JOURNAL, $journalId, $fileName, $destFileName);
}

/**
* Write a file to a journals's public directory.
Expand All @@ -50,9 +61,9 @@ function uploadJournalFile($journalId, $fileName, $destFileName) {
* @param $contents string the contents to write to the file
* @return boolean
*/
function writeJournalFile($journalId, $destFileName, &$contents) {
return $this->writeFile($this->getJournalFilesPath($journalId) . '/' . $destFileName, $contents);
}
function writeJournalFile($journalId, $destFileName, $contents) {
return $this->writeContextFile(ASSOC_TYPE_JOURNAL, $journalId, $destFileName, $contents);
}

/**
* Copy a file to a journals's public directory.
Expand All @@ -61,19 +72,19 @@ function writeJournalFile($journalId, $destFileName, &$contents) {
* @param $destFileName string the destination file name
* @return boolean
*/
function copyJournalFile($journalId, $sourceFile, $destFileName) {
return $this->copyFile($sourceFile, $this->getJournalFilesPath($journalId) . '/' . $destFileName);
}
function copyJournalFile($journalId, $sourceFile, $destFileName) {
return $this->copyContextFile(ASSOC_TYPE_JOURNAL, $journalId, $sourceFile, $destFileName);
}

/**
/**
* Delete a file from a journal's public directory.
* @param $journalId int
* @param $fileName string the target file name
* @param $journalId int
* @param $fileName string the target file name
* @return boolean
*/
function removeJournalFile($journalId, $fileName) {
return $this->deleteFile($this->getJournalFilesPath($journalId) . '/' . $fileName);
}
*/
function removeJournalFile($journalId, $fileName) {
return $this->removeContextFile(ASSOC_TYPE_JOURNAL, $journalId, $fileName);
}
}

?>

0 comments on commit b7f4883

Please sign in to comment.