/** * Rename all the submitted files * Enter description here ... */ function renameSubmittedFiles() { import('classes.file.ArticleFileManager'); $article =& $this->article; $articleFileDao =& DAORegistry::getDAO('ArticleFileDAO'); $articleFiles =& $articleFileDao->getArticleFilesByArticle($article->getId()); $articleId = $article->getId(); $articleFileManager = new ArticleFileManager($articleId); $suppFileCounter = array(); $suppFileDao =& DAORegistry::getDAO('SuppFileDAO'); /*Rename each uploaded file*/ foreach ($articleFiles as $file) { if ($file->getType() == 'supp') { $suppFile = $suppFileDao->getSuppFileByFileId($file->getFileId()); if (!array_key_exists($suppFile->getType(), $suppFileCounter)) { $suppFileCounter[$suppFile->getType()] = 0; } $suppFileCounter[$suppFile->getType()] = $articleFileManager->renameFile($file->getFileId(), $file->getType(), $suppFileCounter[$suppFile->getType()], $suppFile->getType()); } else { $articleFileManager->renameFile($file->getFileId(), $file->getType()); } } }