ocs  2.3.6
About: OCS (Open Conference System) is a Web publishing tool that will create a complete Web presence for your scholarly conference.
  Fossies Dox: ocs-2.3.6.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

TemporaryFileDAO.inc.php
Go to the documentation of this file.
1 <?php
2 
16 // $Id$
17 
18 
19 import('file.TemporaryFile');
20 
21 class TemporaryFileDAO extends DAO {
28  function &getTemporaryFile($fileId, $userId) {
29  $result =& $this->retrieveLimit(
30  'SELECT t.* FROM temporary_files t WHERE t.file_id = ? and t.user_id = ?',
31  array($fileId, $userId),
32  1
33  );
34 
35  $returner = null;
36  if (isset($result) && $result->RecordCount() != 0) {
37  $returner =& $this->_returnTemporaryFileFromRow($result->GetRowAssoc(false));
38  }
39 
40  $result->Close();
41  unset($result);
42 
43  return $returner;
44  }
45 
51  function &_returnTemporaryFileFromRow(&$row) {
52  $temporaryFile = new TemporaryFile();
53  $temporaryFile->setId($row['file_id']);
54  $temporaryFile->setFileName($row['file_name']);
55  $temporaryFile->setFileType($row['file_type']);
56  $temporaryFile->setFileSize($row['file_size']);
57  $temporaryFile->setUserId($row['user_id']);
58  $temporaryFile->setOriginalFileName($row['original_file_name']);
59  $temporaryFile->setDateUploaded($this->datetimeFromDB($row['date_uploaded']));
60 
61  HookRegistry::call('TemporaryFileDAO::_returnTemporaryFileFromRow', array(&$temporaryFile, &$row));
62 
63  return $temporaryFile;
64  }
65 
71  function insertTemporaryFile(&$temporaryFile) {
72  $this->update(
73  sprintf('INSERT INTO temporary_files
74  (user_id, file_name, file_type, file_size, original_file_name, date_uploaded)
75  VALUES
76  (?, ?, ?, ?, ?, %s)',
77  $this->datetimeToDB($temporaryFile->getDateUploaded())),
78  array(
79  (int) $temporaryFile->getUserId(),
80  $temporaryFile->getFileName(),
81  $temporaryFile->getFileType(),
82  (int) $temporaryFile->getFileSize(),
83  $temporaryFile->getOriginalFileName()
84  )
85  );
86 
87  $temporaryFile->setId($this->getInsertTemporaryFileId());
88  return $temporaryFile->getId();
89  }
90 
95  function updateObject(&$temporaryFile) {
96  $this->update(
97  sprintf('UPDATE temporary_files
98  SET
99  file_name = ?,
100  file_type = ?,
101  file_size = ?,
102  user_id = ?,
103  original_file_name = ?,
104  date_uploaded = %s
105  WHERE file_id = ?',
106  $this->datetimeToDB($temporaryFile->getDateUploaded())),
107  array(
108  $temporaryFile->getFileName(),
109  $temporaryFile->getFileType(),
110  (int) $temporaryFile->getFileSize(),
111  (int) $temporaryFile->getUserId(),
112  $temporaryFile->getOriginalFileName(),
113  (int) $temporaryFile->getId()
114  )
115  );
116 
117  return $temporaryFile->getId();
118  }
119 
120  function updateTemporaryFile(&$temporaryFile) {
121  if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
122  return $this->updateObject($temporaryFile);
123  }
124 
130  function deleteTemporaryFileById($fileId, $userId) {
131  return $this->update(
132  'DELETE FROM temporary_files WHERE file_id = ? AND user_id = ?',
133  array((int) $fileId, (int) $userId)
134  );
135  }
136 
141  function deleteTemporaryFilesByUserId($userId) {
142  return $this->update(
143  'DELETE FROM temporary_files WHERE user_id = ?',
144  array((int) $userId)
145  );
146  }
147 
148  function &getExpiredFiles() {
149  // Files older than one day can be cleaned up.
150  $expiryThresholdTimestamp = time() - (60 * 60 * 24);
151 
152  $temporaryFiles = array();
153 
154  $result =& $this->retrieve(
155  'SELECT * FROM temporary_files WHERE date_uploaded < ' . $this->datetimeToDB($expiryThresholdTimestamp)
156  );
157 
158  while (!$result->EOF) {
159  $temporaryFiles[] =& $this->_returnTemporaryFileFromRow($result->GetRowAssoc(false));
160  $result->MoveNext();
161  }
162 
163  $result->Close();
164  unset($result);
165 
166  return $temporaryFiles;
167  }
168 
174  return $this->getInsertId('temporary_files', 'file_id');
175  }
176 }
177 
178 ?>
deleteTemporaryFileById($fileId, $userId)
config TEMPLATE inc php
Definition: config.inc.php:4
Operations for retrieving and modifying objects from a database.
Definition: DAO.inc.php:30
& retrieveLimit($sql, $params=false, $numRows=false, $offset=false, $callHooks=true)
Definition: DAO.inc.php:124
& retrieve($sql, $params=false, $callHooks=true)
Definition: DAO.inc.php:62
& getTemporaryFile($fileId, $userId)
getInsertId($table='', $id='', $callHooks=true)
Definition: DAO.inc.php:225
updateTemporaryFile(&$temporaryFile)
Temporary file class.
datetimeFromDB($dt)
Definition: DAO.inc.php:276
getVar($section, $key, $default=null)
Definition: Config.inc.php:35
Operations for retrieving and modifying TemporaryFile objects.
call($hookName, $args=null)
insertTemporaryFile(&$temporaryFile)
& _returnTemporaryFileFromRow(&$row)
updateObject(&$temporaryFile)
datetimeToDB($dt)
Definition: DAO.inc.php:258
update($sql, $params=false, $callHooks=true, $dieOnError=true)
Definition: DAO.inc.php:186
deleteTemporaryFilesByUserId($userId)