Here's what i've done so far:
- in the table 'paper_files', I have set the 'original_file_name' column to be UNIQUE
- in AuthorSubmitStep2Form.php, I have added this line (so that when there is a file uploaded for a second time, I would see Step 2 of Author Submission loaded again with an error message) :
- Code: Select all
$this->addCheck(new FormValidatorCustom($this, 'submissionFile', 'required', 'author.submit.form.titleExists', array(DAORegistry::getDAO('PaperFileDAO'), 'paperFileExists'), array(), true));
- also i have added this function to PaperFileDAO.php :
- Code: Select all
function paperFileExists($originalFileName, $fileId = null, $allowDisabled = true) {
$result =& $this->retrieve(
'SELECT COUNT(*) FROM paper_files WHERE original_file_name = ?' . (isset($userId) ? ' AND file_id != ?' : '') . ($allowDisabled?'':' AND disabled = 0'),
isset($fileId) ? array($originalFileName, (int) $fileId) : array($originalFileName)
);
$returner = isset($result->fields[0]) && $result->fields[0] == 1 ? true : false;
$result->Close();
unset($result);
return $returner;
}
But I still cannot return to Step 2 of Submission process when there is such error.
The page i get, is a page with only this error message on:
DB Error: Duplicate Entry for "xxxx.doc" for key 2.
Have I done all the required things?
Anyone know what else i need to do?
