Open Journal Systems  3.0.0
 All Classes Namespaces Functions Variables Groups Pages
IssueFileDAO.inc.php
1 <?php
2 
17 import('lib.pkp.classes.file.PKPFileDAO');
18 import('classes.issue.IssueFile');
19 
20 
21 class IssueFileDAO extends PKPFileDAO {
22 
23  /* @var array MIME types that can be displayed inline in a browser */
24  var $_inlineableTypes = null;
25 
29  function IssueFileDAO() {
30  parent::DAO();
31  }
32 
37  function getInlineableTypes() {
38  return $this->_inlineableTypes;
39  }
40 
45  function setInlineableTypes($inlineableTypes) {
46  $this->_inlineableTypes = $inlineableTypes;
47  }
48 
55  function getById($fileId, $issueId = null) {
56  $params = array((int) $fileId);
57  if ($issueId) $params[] = (int) $issueId;
58  $result = $this->retrieve(
59  'SELECT f.*
60  FROM issue_files f
61  WHERE f.file_id = ?
62  ' . ($issueId?' AND f.issue_id = ?':''),
63  $params
64  );
65  $returner = null;
66  if (isset($result) && $result->RecordCount() != 0) {
67  $returner = $this->_fromRow($result->GetRowAssoc(false));
68  }
69  $result->Close();
70  return $returner;
71  }
72 
77  function newDataObject() {
78  return new IssueFile();
79  }
80 
86  function _fromRow($row) {
87  $issueFile = $this->newDataObject();
88  $issueFile->setId($row['file_id']);
89  $issueFile->setIssueId($row['issue_id']);
90  $issueFile->setServerFileName($row['file_name']);
91  $issueFile->setFileType($row['file_type']);
92  $issueFile->setFileSize($row['file_size']);
93  $issueFile->setContentType($row['content_type']);
94  $issueFile->setOriginalFileName($row['original_file_name']);
95  $issueFile->setDateUploaded($this->datetimeFromDB($row['date_uploaded']));
96  $issueFile->setDateModified($this->datetimeFromDB($row['date_modified']));
97  HookRegistry::call('IssueFileDAO::_returnIssueFileFromRow', array(&$issueFile, &$row));
98  return $issueFile;
99  }
100 
106  function insertObject($issueFile) {
107  $this->update(
108  sprintf(
109  'INSERT INTO issue_files
110  (issue_id,
111  file_name,
112  file_type,
113  file_size,
114  content_type,
115  original_file_name,
116  date_uploaded,
117  date_modified)
118  VALUES
119  (?, ?, ?, ?, ?, ?, %s, %s)',
120  $this->datetimeToDB($issueFile->getDateUploaded()),
121  $this->datetimeToDB($issueFile->getDateModified())
122  ),
123  array(
124  (int) $issueFile->getIssueId(),
125  $issueFile->getServerFileName(),
126  $issueFile->getFileType(),
127  $issueFile->getFileSize(),
128  $issueFile->getContentType(),
129  $issueFile->getOriginalFileName()
130  )
131  );
132 
133  $issueFile->setId($this->getInsertId());
134  return $issueFile->getId();
135  }
136 
141  function updateObject($issueFile) {
142  $this->update(
143  sprintf('UPDATE issue_files
144  SET
145  issue_id = ?,
146  file_name = ?,
147  file_type = ?,
148  file_size = ?,
149  content_type = ?,
150  original_file_name = ?,
151  date_uploaded = %s,
152  date_modified = %s
153  WHERE file_id = ?',
154  $this->datetimeToDB($issueFile->getDateUploaded()),
155  $this->datetimeToDB($issueFile->getDateModified())
156  ),
157  array(
158  (int) $issueFile->getIssueId(),
159  $issueFile->getServerFileName(),
160  $issueFile->getFileType(),
161  $issueFile->getFileSize(),
162  $issueFile->getContentType(),
163  $issueFile->getOriginalFileName(),
164  (int) $issueFile->getId()
165  )
166  );
167 
168  return $issueFile->getId();
169 
170  }
171 
176  function deleteObject($issueFile) {
177  $this->deleteById($issueFile->getId());
178  }
184  function deleteById($fileId) {
185  $this->update(
186  'DELETE FROM issue_files WHERE file_id = ?', (int) $fileId
187  );
188  }
189 
194  function deleteByIssueId($issueId) {
195  $this->update(
196  'DELETE FROM issue_files WHERE issue_id = ?', (int) $issueId
197  );
198  }
199 
204  function getInsertId() {
205  return $this->_getInsertId('issue_files', 'file_id');
206  }
207 }
208 
209 ?>
Issue file class.
& retrieve($sql, $params=false, $callHooks=true)
Definition: DAO.inc.php:84
getById($fileId, $issueId=null)
updateObject($issueFile)
insertObject($issueFile)
_getInsertId($table= '', $id= '')
Definition: DAO.inc.php:249
datetimeFromDB($dt)
Definition: DAO.inc.php:313
static call($hookName, $args=null)
Operations for retrieving and modifying IssueFile objects.
Abstract base class for retrieving and modifying PKPFile objects and their decendents.
deleteObject($issueFile)
datetimeToDB($dt)
Definition: DAO.inc.php:293
update($sql, $params=false, $callHooks=true, $dieOnError=true)
Definition: DAO.inc.php:208
setInlineableTypes($inlineableTypes)
deleteByIssueId($issueId)