update( 'INSERT INTO submission_artwork_files (file_id, revision, caption, chapter_id, contact_author, copyright_owner, copyright_owner_contact, credit, permission_file_id, permission_terms) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', array( $artworkFile->getFileId(), $artworkFile->getRevision(), $artworkFile->getCaption(), $artworkFile->getChapterId(), $artworkFile->getContactAuthor(), $artworkFile->getCopyrightOwner(), $artworkFile->getCopyrightOwnerContactDetails(), $artworkFile->getCredit(), $artworkFile->getPermissionFileId(), $artworkFile->getPermissionTerms() ) ); return $artworkFile; } /** * @see SubmissionFileDAODelegate::update() * @param $artworkFile ArtworkFile * @param $previousFile ArtworkFile * @return boolean True if success. */ function updateObject($artworkFile, $previousFile) { // Update the parent class table first. if (!parent::updateObject($artworkFile, $previousFile)) return false; // Now update the artwork file table. $this->update( 'UPDATE submission_artwork_files SET file_id = ?, revision = ?, caption = ?, chapter_id = ?, contact_author = ?, copyright_owner = ?, copyright_owner_contact = ?, credit = ?, permission_file_id = ?, permission_terms = ? WHERE file_id = ? and revision = ?', array( (int)$artworkFile->getFileId(), (int)$artworkFile->getRevision(), $artworkFile->getCaption(), is_null($artworkFile->getChapterId()) ? null : (int)$artworkFile->getChapterId(), $artworkFile->getContactAuthor(), $artworkFile->getCopyrightOwner(), $artworkFile->getCopyrightOwnerContactDetails(), $artworkFile->getCredit(), is_null($artworkFile->getPermissionFileId()) ? null : (int)$artworkFile->getPermissionFileId(), $artworkFile->getPermissionTerms(), (int)$previousFile->getFileId(), (int)$previousFile->getRevision() ) ); return true; } /** * @see SubmissionFileDAODelegate::deleteObject() */ function deleteObject($submissionFile) { // First delete the submission file entry. if (!parent::deleteObject($submissionFile)) return false; // Delete the artwork file entry. return $this->update( 'DELETE FROM submission_artwork_files WHERE file_id = ? AND revision = ?', array( (int)$submissionFile->getFileId(), (int)$submissionFile->getRevision() ) ); } /** * @see SubmissionFileDAODelegate::fromRow() * @return ArtworkFile */ function fromRow($row) { $artworkFile = parent::fromRow($row); $artworkFile->setCredit($row['credit']); $artworkFile->setCaption($row['caption']); $artworkFile->setChapterId(is_null($row['chapter_id']) ? null : (int)$row['chapter_id']); $artworkFile->setContactAuthor($row['contact_author']); $artworkFile->setCopyrightOwner($row['copyright_owner']); $artworkFile->setPermissionTerms($row['permission_terms']); $artworkFile->setPermissionFileId(is_null($row['permission_file_id']) ? null : (int)$row['permission_file_id']); $artworkFile->setCopyrightOwnerContactDetails($row['copyright_owner_contact']); return $artworkFile; } /** * @copydoc SubmissionFileDAODelegate::newDataObject() */ function newDataObject() { return new SubmissionArtworkFile(); } } ?>