Open Journal Systems  3.0.0
 All Data Structures Namespaces Functions Variables Groups Pages
SubmissionArtworkFileDAODelegate.inc.php
1 <?php
2 
20 import('lib.pkp.classes.submission.SubmissionFileDAODelegate');
21 import('lib.pkp.classes.submission.SubmissionArtworkFile');
22 
28  parent::SubmissionFileDAODelegate();
29  }
30 
31 
32  //
33  // Public methods
34  //
42  function insertObject($artworkFile, $sourceFile, $isUpload = false) {
43  // First insert the data for the super-class.
44  $artworkFile = parent::insertObject($artworkFile, $sourceFile, $isUpload);
45  if (!$artworkFile) return null;
46 
47  // Now insert the artwork-specific data.
48  $this->update(
49  'INSERT INTO submission_artwork_files
50  (file_id, revision, caption, chapter_id, contact_author, copyright_owner, copyright_owner_contact, credit, permission_file_id, permission_terms)
51  VALUES
52  (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
53  array(
54  $artworkFile->getFileId(),
55  $artworkFile->getRevision(),
56  $artworkFile->getCaption(),
57  $artworkFile->getChapterId(),
58  $artworkFile->getContactAuthor(),
59  $artworkFile->getCopyrightOwner(),
60  $artworkFile->getCopyrightOwnerContactDetails(),
61  $artworkFile->getCredit(),
62  $artworkFile->getPermissionFileId(),
63  $artworkFile->getPermissionTerms()
64  )
65  );
66 
67  return $artworkFile;
68  }
69 
76  function updateObject($artworkFile, $previousFile) {
77  // Update the parent class table first.
78  if (!parent::updateObject($artworkFile, $previousFile)) return false;
79 
80  // Now update the artwork file table.
81  $this->update(
82  'UPDATE submission_artwork_files
83  SET
84  file_id = ?,
85  revision = ?,
86  caption = ?,
87  chapter_id = ?,
88  contact_author = ?,
89  copyright_owner = ?,
90  copyright_owner_contact = ?,
91  credit = ?,
92  permission_file_id = ?,
93  permission_terms = ?
94  WHERE file_id = ? and revision = ?',
95  array(
96  (int)$artworkFile->getFileId(),
97  (int)$artworkFile->getRevision(),
98  $artworkFile->getCaption(),
99  is_null($artworkFile->getChapterId()) ? null : (int)$artworkFile->getChapterId(),
100  $artworkFile->getContactAuthor(),
101  $artworkFile->getCopyrightOwner(),
102  $artworkFile->getCopyrightOwnerContactDetails(),
103  $artworkFile->getCredit(),
104  is_null($artworkFile->getPermissionFileId()) ? null : (int)$artworkFile->getPermissionFileId(),
105  $artworkFile->getPermissionTerms(),
106  (int)$previousFile->getFileId(),
107  (int)$previousFile->getRevision()
108  )
109  );
110  return true;
111  }
112 
116  function deleteObject($submissionFile) {
117  // First delete the submission file entry.
118  if (!parent::deleteObject($submissionFile)) return false;
119 
120  // Delete the artwork file entry.
121  return $this->update(
122  'DELETE FROM submission_artwork_files
123  WHERE file_id = ? AND revision = ?',
124  array(
125  (int)$submissionFile->getFileId(),
126  (int)$submissionFile->getRevision()
127  )
128  );
129  }
130 
135  function fromRow($row) {
136  $artworkFile = parent::fromRow($row);
137  $artworkFile->setCredit($row['credit']);
138  $artworkFile->setCaption($row['caption']);
139  $artworkFile->setChapterId(is_null($row['chapter_id']) ? null : (int)$row['chapter_id']);
140  $artworkFile->setContactAuthor($row['contact_author']);
141  $artworkFile->setCopyrightOwner($row['copyright_owner']);
142  $artworkFile->setPermissionTerms($row['permission_terms']);
143  $artworkFile->setPermissionFileId(is_null($row['permission_file_id']) ? null : (int)$row['permission_file_id']);
144  $artworkFile->setCopyrightOwnerContactDetails($row['copyright_owner_contact']);
145 
146  return $artworkFile;
147  }
148 
152  function newDataObject() {
153  return new SubmissionArtworkFile();
154  }
155 }
156 
157 ?>
Base class for operations for retrieving and modifying ArtworkFile objects.
Abstract class to support DAO delegates that provide operations to retrieve and modify SubmissionFile...
insertObject($artworkFile, $sourceFile, $isUpload=false)
update($sql, $params=false, $callHooks=true, $dieOnError=true)
Definition: DAO.inc.php:208