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)  

TrackDAO.inc.php
Go to the documentation of this file.
1 <?php
2 
17 // $Id$
18 
19 
20 import ('conference.Track');
21 
22 class TrackDAO extends DAO {
28  function &getTrack($trackId) {
29  $result =& $this->retrieve(
30  'SELECT * FROM tracks WHERE track_id = ?', $trackId
31  );
32 
33  $returner = null;
34  if ($result->RecordCount() != 0) {
35  $returner =& $this->_returnTrackFromRow($result->GetRowAssoc(false));
36  }
37 
38  $result->Close();
39  unset($result);
40 
41  return $returner;
42  }
43 
50  function &getTrackByAbbrev($trackAbbrev, $schedConfId, $locale = null) {
51  $sql = 'SELECT * FROM tracks t, track_settings l WHERE l.track_id = t.track_id AND l.setting_name = ? AND l.setting_value = ? AND t.sched_conf_id = ?';
52  $params = array('abbrev', $trackAbbrev, $schedConfId);
53 
54  if ($locale !== null) {
55  $sql .= ' AND l.locale = ?';
56  $params[] = $locale;
57  }
58  $result =& $this->retrieve($sql, $params);
59 
60  $returner = null;
61  if ($result->RecordCount() != 0) {
62  $returner =& $this->_returnTrackFromRow($result->GetRowAssoc(false));
63  }
64 
65  $result->Close();
66  unset($result);
67 
68  return $returner;
69  }
70 
77  function &getTrackByTitle($trackTitle, $schedConfId, $locale = null) {
78  $sql = 'SELECT * FROM tracks t, track_settings l WHERE l.track_id = t.track_id AND l.setting_name = ? AND l.setting_value = ? AND t.sched_conf_id = ?';
79  $params = array('title', $trackTitle, $schedConfId);
80 
81  if ($locale !== null) {
82  $sql .= ' AND l.locale = ?';
83  $params[] = $locale;
84  }
85  $result =& $this->retrieve($sql, $params);
86 
87  $returner = null;
88  if ($result->RecordCount() != 0) {
89  $returner =& $this->_returnTrackFromRow($result->GetRowAssoc(false));
90  }
91 
92  $result->Close();
93  unset($result);
94 
95  return $returner;
96  }
97 
105  function &getTrackByTitleAndAbbrev($trackTitle, $trackAbbrev, $schedConfId, $locale = null) {
106  $params = array('title', 'abbrev', $trackTitle, $trackAbbrev, $schedConfId);
107  if ($locale !== null) {
108  $params[] = $locale;
109  $params[] = $locale;
110  }
111 
112  $sql = 'SELECT t.*
113  FROM tracks t,
114  track_settings l1,
115  track_settings l2
116  WHERE l1.track_id = t.track_id AND
117  l2.track_id = t.track_id AND
118  l1.setting_name = ? AND
119  l2.setting_name = ? AND
120  l1.setting_value = ? AND
121  l2.setting_value = ? AND
122  t.sched_conf_id = ?';
123  if ($locale !== null) $sql .= ' AND l1.locale = ? AND l2.locale = ?';
124  $result =& $this->retrieve($sql, $params);
125 
126  $returner = null;
127  if ($result->RecordCount() != 0) {
128  $returner =& $this->_returnTrackFromRow($result->GetRowAssoc(false));
129  }
130 
131  $result->Close();
132  unset($result);
133 
134  return $returner;
135  }
136 
142  function &_returnTrackFromRow(&$row) {
143  $track = new Track();
144  $track->setId($row['track_id']);
145  $track->setSchedConfId($row['sched_conf_id']);
146  $track->setReviewFormId($row['review_form_id']);
147  $track->setSequence($row['seq']);
148  $track->setMetaReviewed($row['meta_reviewed']);
149  $track->setDirectorRestricted($row['director_restricted']);
150  $track->setHideAbout($row['hide_about']);
151  $track->setDisableComments($row['disable_comments']);
152  $track->setAbstractWordCount($row['abstract_word_count']);
153 
154  $this->getDataObjectSettings('track_settings', 'track_id', $row['track_id'], $track);
155 
156  HookRegistry::call('TrackDAO::_returnTrackFromRow', array(&$track, &$row));
157 
158  return $track;
159  }
160 
165  function getLocaleFieldNames() {
166  return array('title', 'abbrev', 'policy', 'identifyType');
167  }
168 
173  function updateLocaleFields(&$track) {
174  $this->updateDataObjectSettings('track_settings', $track, array(
175 
176  'track_id' => $track->getId()
177  ));
178  }
179 
184  function insertTrack(&$track) {
185  $this->update(
186  'INSERT INTO tracks
187  (sched_conf_id, review_form_id, seq, meta_reviewed, director_restricted, hide_about, disable_comments, abstract_word_count)
188  VALUES
189  (?, ?, ?, ?, ?, ?, ?, ?)',
190  array(
191  (int) $track->getSchedConfId(),
192  $track->getReviewFormId(),
193  (int) $track->getSequence(),
194  $track->getMetaReviewed() ? 1 : 0,
195  $track->getDirectorRestricted() ? 1 : 0,
196  $track->getHideAbout() ? 1 : 0,
197  $track->getDisableComments() ? 1 : 0,
198  (int) $track->getAbstractWordCount()
199  )
200  );
201 
202  $track->setId($this->getInsertTrackId());
203  $this->updateLocaleFields($track);
204  return $track->getId();
205  }
206 
211  function updateTrack(&$track) {
212  $returner = $this->update(
213  'UPDATE tracks
214  SET review_form_id = ?,
215  seq = ?,
216  meta_reviewed = ?,
217  director_restricted = ?,
218  hide_about = ?,
219  disable_comments = ?,
220  abstract_word_count = ?
221  WHERE track_id = ?',
222  array(
223  $track->getReviewFormId(),
224  (int) $track->getSequence(),
225  $track->getMetaReviewed()?1:0,
226  $track->getDirectorRestricted()?1:0,
227  $track->getHideAbout()?1:0,
228  $track->getDisableComments()?1:0,
229  (int) $track->getAbstractWordCount(),
230  (int) $track->getId()
231  )
232  );
233  $this->updateLocaleFields($track);
234  return $returner;
235  }
236 
241  function deleteTrack(&$track) {
242  return $this->deleteTrackById($track->getId(), $track->getSchedConfId());
243  }
244 
250  function deleteTrackById($trackId, $schedConfId = null) {
251  $trackDirectorsDao =& DAORegistry::getDAO('TrackDirectorsDAO');
252  $trackDirectorsDao->deleteDirectorsByTrackId($trackId, $schedConfId);
253 
254  // Remove papers from this track
255  $paperDao =& DAORegistry::getDAO('PaperDAO');
256  $paperDao->removePapersFromTrack($trackId);
257 
258  // Delete published paper entries from this track -- they must
259  // be re-published.
260  $publishedPaperDao =& DAORegistry::getDAO('PublishedPaperDAO');
261  $publishedPaperDao->deletePublishedPapersByTrackId($trackId);
262 
263  if (isset($schedConfId) && !$this->trackExists($trackId, $schedConfId)) return false;
264  $this->update('DELETE FROM track_settings WHERE track_id = ?', array($trackId));
265  return $this->update('DELETE FROM tracks WHERE track_id = ?', array($trackId));
266  }
267 
272  function deleteTracksBySchedConf($schedConfId) {
273  $tracks =& $this->getSchedConfTracks($schedConfId);
274  while (($track =& $tracks->next())) {
275  $this->deleteTrack($track);
276  unset($track);
277  }
278  }
279 
285  function &getDirectorTracks($schedConfId) {
286  $returner = array();
287 
288  $result =& $this->retrieve(
289  'SELECT t.*, td.user_id AS director_id FROM track_directors td, tracks t WHERE td.track_id = t.track_id AND t.sched_conf_id = td.sched_conf_id AND t.sched_conf_id = ?',
290  $schedConfId
291  );
292 
293  while (!$result->EOF) {
294  $row = $result->GetRowAssoc(false);
295  $track =& $this->_returnTrackFromRow($row);
296  if (!isset($returner[$row['director_id']])) {
297  $returner[$row['director_id']] = array($track);
298  } else {
299  $returner[$row['director_id']][] = $track;
300  }
301  $result->moveNext();
302  }
303 
304  $result->Close();
305  unset($result);
306 
307  return $returner;
308  }
309 
315  function &getTracksBySchedConfId($schedConfId) {
316  $returner = array();
317 
318  $result =& $this->retrieve(
319  'SELECT DISTINCT t.*,
320  t.seq AS track_seq
321  FROM tracks t, papers p
322  LEFT JOIN sched_confs i ON (p.sched_conf_id = i.sched_conf_id) AND (i.sched_conf_id = ?)
323  WHERE t.track_id = p.track_id ORDER BY track_seq',
324  array($schedConfId)
325  );
326 
327  while (!$result->EOF) {
328  $row = $result->GetRowAssoc(false);
329  $returner[] =& $this->_returnTrackFromRow($row);
330  $result->moveNext();
331  }
332 
333  $result->Close();
334  unset($result);
335 
336  return $returner;
337  }
338 
345  function &getSchedConfTracks($schedConfId, $rangeInfo = null) {
346  $result =& $this->retrieveRange(
347  'SELECT *
348  FROM tracks
349  WHERE sched_conf_id = ?
350  ORDER BY seq',
351  (int) $schedConfId,
352  $rangeInfo
353  );
354 
355  $returner = new DAOResultFactory($result, $this, '_returnTrackFromRow');
356  return $returner;
357  }
358 
365  function &getConferenceTracks($conferenceId, $rangeInfo = null) {
366  $result =& $this->retrieveRange(
367  'SELECT t.*
368  FROM tracks t,
369  sched_confs sc
370  WHERE t.sched_conf_id = sc.sched_conf_id AND
371  sc.conference_id = ?
372  ORDER BY sc.seq, t.seq',
373  (int) $conferenceId,
374  $rangeInfo
375  );
376 
377  $returner = new DAOResultFactory($result, $this, '_returnTrackFromRow');
378  return $returner;
379  }
380 
385  function &getTrackTitles($schedConfId, $submittableOnly = false) {
386  $tracks = array();
387  $tracksIterator =& $this->getSchedConfTracks($schedConfId);
388  while (($track =& $tracksIterator->next())) {
389  if (!$submittableOnly || !$track->getDirectorRestricted()) {
390  $tracks[$track->getId()] = $track->getLocalizedTitle();
391  }
392 
393  unset($track);
394  }
395 
396  return $tracks;
397  }
398 
405  function trackExists($trackId, $schedConfId) {
406  $result =& $this->retrieve(
407  'SELECT COUNT(*) FROM tracks WHERE track_id = ? AND sched_conf_id = ?',
408  array($trackId, $schedConfId)
409  );
410  $returner = isset($result->fields[0]) && $result->fields[0] == 1 ? true : false;
411 
412  $result->Close();
413  unset($result);
414 
415  return $returner;
416  }
417 
422  function resequenceTracks($schedConfId) {
423  $result =& $this->retrieve(
424  'SELECT track_id FROM tracks WHERE sched_conf_id = ? ORDER BY seq',
425  $schedConfId
426  );
427 
428  for ($i=1; !$result->EOF; $i++) {
429  list($trackId) = $result->fields;
430  $this->update(
431  'UPDATE tracks SET seq = ? WHERE track_id = ?',
432  array(
433  $i,
434  $trackId
435  )
436  );
437 
438  $result->moveNext();
439  }
440 
441  $result->close();
442  unset($result);
443  }
444 
449  function getInsertTrackId() {
450  return $this->getInsertId('tracks', 'track_id');
451  }
452 }
453 
454 ?>
config TEMPLATE inc php
Definition: config.inc.php:4
Operations for retrieving and modifying objects from a database.
Definition: DAO.inc.php:30
resequenceTracks($schedConfId)
deleteTracksBySchedConf($schedConfId)
& retrieve($sql, $params=false, $callHooks=true)
Definition: DAO.inc.php:62
trackExists($trackId, $schedConfId)
& getTrackTitles($schedConfId, $submittableOnly=false)
deleteTrackById($trackId, $schedConfId=null)
updateLocaleFields(&$track)
deleteTrack(&$track)
getInsertId($table='', $id='', $callHooks=true)
Definition: DAO.inc.php:225
& _returnTrackFromRow(&$row)
& getConferenceTracks($conferenceId, $rangeInfo=null)
updateDataObjectSettings($tableName, &$dataObject, $idArray)
Definition: DAO.inc.php:412
& retrieveRange($sql, $params=false, $dbResultRange=null, $callHooks=true)
Definition: DAO.inc.php:152
& getTrackByTitleAndAbbrev($trackTitle, $trackAbbrev, $schedConfId, $locale=null)
insertTrack(&$track)
Wrapper around ADORecordSet providing "factory" features for generating objects from DAOs.
& getTracksBySchedConfId($schedConfId)
Operations for retrieving and modifying Track objects.
getLocaleFieldNames()
& getTrackByTitle($trackTitle, $schedConfId, $locale=null)
& getDirectorTracks($schedConfId)
& getDAO($name, $dbconn=null)
& getTrackByAbbrev($trackAbbrev, $schedConfId, $locale=null)
getInsertTrackId()
call($hookName, $args=null)
getDataObjectSettings($tableName, $idFieldName, $idFieldValue, &$dataObject)
Definition: DAO.inc.php:498
& getSchedConfTracks($schedConfId, $rangeInfo=null)
& getTrack($trackId)
update($sql, $params=false, $callHooks=true, $dieOnError=true)
Definition: DAO.inc.php:186
Describes basic track properties.
Definition: Track.inc.php:20
updateTrack(&$track)