Open Journal Systems  3.0.0
 All Classes Namespaces Functions Variables Groups Pages
SubmissionArtworkFileDAODelegate.inc.php
1 <?php
2 
20 import('lib.pkp.classes.submission.SubmissionFileDAODelegate');
21 
27  parent::SubmissionFileDAODelegate();
28  }
29 
30 
31  //
32  // Public methods
33  //
39  function &insertObject($artworkFile, $sourceFile, $isUpload = false) {
40  // First insert the data for the super-class.
41  $artworkFile = parent::insertObject($artworkFile, $sourceFile, $isUpload);
42  if (is_null($artworkFile)) return $artworkFile;
43 
44  // Now insert the artwork-specific data.
45  $this->update(
46  'INSERT INTO submission_artwork_files
47  (file_id, revision, caption, chapter_id, contact_author, copyright_owner, copyright_owner_contact, credit, permission_file_id, permission_terms)
48  VALUES
49  (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
50  array(
51  $artworkFile->getFileId(),
52  $artworkFile->getRevision(),
53  $artworkFile->getCaption(),
54  $artworkFile->getChapterId(),
55  $artworkFile->getContactAuthor(),
56  $artworkFile->getCopyrightOwner(),
57  $artworkFile->getCopyrightOwnerContactDetails(),
58  $artworkFile->getCredit(),
59  $artworkFile->getPermissionFileId(),
60  $artworkFile->getPermissionTerms()
61  )
62  );
63 
64  return $artworkFile;
65  }
66 
72  function updateObject(&$artworkFile, &$previousFile) {
73  // Update the parent class table first.
74  if (!parent::updateObject($artworkFile, $previousFile)) return false;
75 
76  // Now update the artwork file table.
77  $this->update(
78  'UPDATE submission_artwork_files
79  SET
80  file_id = ?,
81  revision = ?,
82  caption = ?,
83  chapter_id = ?,
84  contact_author = ?,
85  copyright_owner = ?,
86  copyright_owner_contact = ?,
87  credit = ?,
88  permission_file_id = ?,
89  permission_terms = ?
90  WHERE file_id = ? and revision = ?',
91  array(
92  (int)$artworkFile->getFileId(),
93  (int)$artworkFile->getRevision(),
94  $artworkFile->getCaption(),
95  is_null($artworkFile->getChapterId()) ? null : (int)$artworkFile->getChapterId(),
96  $artworkFile->getContactAuthor(),
97  $artworkFile->getCopyrightOwner(),
98  $artworkFile->getCopyrightOwnerContactDetails(),
99  $artworkFile->getCredit(),
100  is_null($artworkFile->getPermissionFileId()) ? null : (int)$artworkFile->getPermissionFileId(),
101  $artworkFile->getPermissionTerms(),
102  (int)$previousFile->getFileId(),
103  (int)$previousFile->getRevision()
104  )
105  );
106  return true;
107  }
108 
112  function deleteObject(&$submissionFile) {
113  // First delete the submission file entry.
114  if (!parent::deleteObject($submissionFile)) return false;
115 
116  // Delete the artwork file entry.
117  return $this->update(
118  'DELETE FROM submission_artwork_files
119  WHERE file_id = ? AND revision = ?',
120  array(
121  (int)$submissionFile->getFileId(),
122  (int)$submissionFile->getRevision()
123  ));
124  }
125 
130  function fromRow($row) {
131  $artworkFile = parent::fromRow($row);
132  $artworkFile->setCredit($row['credit']);
133  $artworkFile->setCaption($row['caption']);
134  $artworkFile->setChapterId(is_null($row['chapter_id']) ? null : (int)$row['chapter_id']);
135  $artworkFile->setContactAuthor($row['contact_author']);
136  $artworkFile->setCopyrightOwner($row['copyright_owner']);
137  $artworkFile->setPermissionTerms($row['permission_terms']);
138  $artworkFile->setPermissionFileId(is_null($row['permission_file_id']) ? null : (int)$row['permission_file_id']);
139  $artworkFile->setCopyrightOwnerContactDetails($row['copyright_owner_contact']);
140 
141  return $artworkFile;
142  }
143 
148  function newDataObject() {
149  assert(false);
150  }
151 }
152 
153 ?>
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