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)  

RTDAO.inc.php
Go to the documentation of this file.
1 <?php
2 
16 //$Id$
17 
18 import('rt.ocs.ConferenceRT');
19 
20 class RTDAO extends DAO {
21  //
22  // RT
23  //
24 
30  function &getConferenceRTByConference(&$conference) {
31  $rt = new ConferenceRT($conference->getId());
32  $rt->setEnabled($conference->getSetting('rtEnabled')?true:false);
33  $rt->setVersion((int) $conference->getSetting('rtVersionId'));
34  $rt->setAbstract($conference->getSetting('rtAbstract')?true:false);
35  $rt->setCaptureCite($conference->getSetting('rtCaptureCite')?true:false);
36  $rt->setViewMetadata($conference->getSetting('rtViewMetadata')?true:false);
37  $rt->setSupplementaryFiles($conference->getSetting('rtSupplementaryFiles')?true:false);
38  $rt->setPrinterFriendly($conference->getSetting('rtPrinterFriendly')?true:false);
39  $rt->setAuthorBio($conference->getSetting('rtAuthorBio')?true:false);
40  $rt->setDefineTerms($conference->getSetting('rtDefineTerms')?true:false);
41  $rt->setAddComment($conference->getSetting('rtAddComment')?true:false);
42  $rt->setEmailAuthor($conference->getSetting('rtEmailAuthor')?true:false);
43  $rt->setEmailOthers($conference->getSetting('rtEmailOthers')?true:false);
44  $rt->setFindingReferences($conference->getSetting('rtFindingReferences')?true:false);
45  return $rt;
46  }
47 
48  function updateConferenceRT(&$rt) {
49  $conferenceDao =& DAORegistry::getDAO('ConferenceDAO');
50  $conference =& $conferenceDao->getConference($rt->getConferenceId());
51 
52  $conference->updateSetting('rtEnabled', $rt->getEnabled(), 'bool');
53  $conference->updateSetting('rtVersionId', $rt->getVersion(), 'int');
54  $conference->updateSetting('rtAbstract', $rt->getAbstract(), 'bool');
55  $conference->updateSetting('rtCaptureCite', $rt->getCaptureCite(), 'bool');
56  $conference->updateSetting('rtViewMetadata', $rt->getViewMetadata(), 'bool');
57  $conference->updateSetting('rtSupplementaryFiles', $rt->getSupplementaryFiles(), 'bool');
58  $conference->updateSetting('rtPrinterFriendly', $rt->getPrinterFriendly(), 'bool');
59  $conference->updateSetting('rtAuthorBio', $rt->getAuthorBio(), 'bool');
60  $conference->updateSetting('rtDefineTerms', $rt->getDefineTerms(), 'bool');
61  $conference->updateSetting('rtAddComment', $rt->getAddComment(), 'bool');
62  $conference->updateSetting('rtEmailAuthor', $rt->getEmailAuthor(), 'bool');
63  $conference->updateSetting('rtEmailOthers', $rt->getEmailOthers(), 'bool');
64  $conference->updateSetting('rtFindingReferences', $rt->getFindingReferences());
65  return true;
66  }
67 
72  function insertConferenceRT(&$rt) {
73  return $this->updateConferenceRT($rt);
74  }
75 
76  //
77  // RT Versions
78  //
79 
86  function &getVersions($conferenceId, $pagingInfo = null) {
87  $versions = array();
88 
89  $result =& $this->retrieveRange(
90  'SELECT * FROM rt_versions WHERE conference_id = ? ORDER BY version_key',
91  (int) $conferenceId,
92  $pagingInfo
93  );
94 
95  $returner = new DAOResultFactory($result, $this, '_returnVersionFromRow');
96  return $returner;
97  }
98 
105  function &getVersion($versionId, $conferenceId) {
106  $result =& $this->retrieve(
107  'SELECT * FROM rt_versions WHERE version_id = ? AND conference_id = ?',
108  array((int) $versionId, (int) $conferenceId)
109  );
110 
111  $returner = null;
112  if ($result->RecordCount() != 0) {
113  $returner =& $this->_returnVersionFromRow($result->GetRowAssoc(false));
114  }
115 
116  $result->Close();
117  unset($result);
118 
119  return $returner;
120  }
121 
127  function insertVersion($conferenceId, &$version) {
128  $this->update(
129  'INSERT INTO rt_versions
130  (conference_id, version_key, locale, title, description)
131  VALUES
132  (?, ?, ?, ?, ?)',
133  array((int) $conferenceId, $version->key, $version->locale, $version->title, $version->description)
134  );
135 
136  $version->versionId = $this->getInsertId('rt_versions', 'version_id');
137 
138  foreach ($version->contexts as $context) {
139  $context->versionId = $version->versionId;
140  $this->insertContext($context);
141  }
142 
143  return $version->versionId;
144  }
145 
151  function updateVersion($conferenceId, &$version) {
152  // FIXME Update contexts and searches?
153  return $this->update(
154  'UPDATE rt_versions
155  SET
156  title = ?,
157  description = ?,
158  version_key = ?,
159  locale = ?
160  WHERE version_id = ? AND conference_id = ?',
161  array(
162  $version->getTitle(),
163  $version->getDescription(),
164  $version->getKey(),
165  $version->getLocale(),
166  (int) $version->getVersionId(),
167  (int) $conferenceId
168  )
169  );
170  }
171 
176  function deleteVersionsByConferenceId($conferenceId) {
177  $versions =& $this->getVersions($conferenceId);
178  foreach ($versions->toArray() as $version) {
179  $this->deleteVersion($version->getVersionId(), $conferenceId);
180  }
181  }
182 
188  function deleteVersion($versionId, $conferenceId) {
189  $this->deleteContextsByVersionId($versionId);
190  return $this->update(
191  'DELETE FROM rt_versions WHERE version_id = ? AND conference_id = ?',
192  array((int) $versionId, (int) $conferenceId)
193  );
194  }
195 
200  function deleteVersionsByConference($conferenceId) {
201  $versions =& RTDAO::getVersions($conferenceId);
202  while (!$versions->eof()) {
203  $version =& $versions->next();
204  $this->deleteVersion($version->getVersionId(), $conferenceId);
205  }
206  }
207 
213  function &_returnVersionFromRow(&$row) {
214  $version = new RTVersion();
215  $version->setVersionId($row['version_id']);
216  $version->setKey($row['version_key']);
217  $version->setLocale($row['locale']);
218  $version->setTitle($row['title']);
219  $version->setDescription($row['description']);
220 
221  if (!HookRegistry::call('RTDAO::_returnVersionFromRow', array(&$version, &$row))) {
222  $contextsIterator =& $this->getContexts($row['version_id']);
223  $version->setContexts($contextsIterator->toArray());
224  }
225 
226  return $version;
227  }
228 
234  function &_returnSearchFromRow(&$row) {
235  $search = new RTSearch();
236  $search->setSearchId($row['search_id']);
237  $search->setContextId($row['context_id']);
238  $search->setTitle($row['title']);
239  $search->setDescription($row['description']);
240  $search->setUrl($row['url']);
241  $search->setSearchUrl($row['search_url']);
242  $search->setSearchPost($row['search_post']);
243  $search->setOrder($row['seq']);
244 
245  HookRegistry::call('RTDAO::_returnSearchFromRow', array(&$search, &$row));
246 
247  return $search;
248  }
249 
250 
251 
252  //
253  // RT Contexts
254  //
255 
261  function &getContext($contextId) {
262  $result =& $this->retrieve(
263  'SELECT * FROM rt_contexts WHERE context_id = ?',
264  array((int) $contextId)
265  );
266 
267  $returner = null;
268  if ($result->RecordCount() != 0) {
269  $returner =& $this->_returnContextFromRow($result->GetRowAssoc(false));
270  }
271 
272  $result->Close();
273  unset($result);
274 
275  return $returner;
276  }
277 
284  function &getContexts($versionId, $pagingInfo = null) {
285  $contexts = array();
286 
287  $result =& $this->retrieveRange(
288  'SELECT * FROM rt_contexts WHERE version_id = ? ORDER BY seq',
289  array((int) $versionId),
290  $pagingInfo
291  );
292 
293  $returner = new DAOResultFactory($result, $this, '_returnContextFromRow');
294  return $returner;
295  }
296 
302  function insertContext(&$context) {
303  $this->update(
304  'INSERT INTO rt_contexts
305  (version_id, title, abbrev, description, cited_by, author_terms, geo_terms, define_terms, seq)
306  VALUES
307  (?, ?, ?, ?, ?, ?, ?, ?, ?)',
308  array(
309  (int) $context->versionId,
310  $context->title,
311  $context->abbrev,
312  $context->description,
313  $context->citedBy?1:0,
314  $context->authorTerms?1:0,
315  $context->geoTerms?1:0,
316  $context->defineTerms?1:0,
317  (int) $context->order
318  )
319  );
320 
321  $context->contextId = $this->getInsertId('rt_contexts', 'context_id');
322 
323  foreach ($context->searches as $search) {
324  $search->contextId = $context->contextId;
325  $this->insertSearch($search);
326  }
327 
328  return $context->contextId;
329  }
330 
335  function updateContext(&$context) {
336  // FIXME Update searches?
337  return $this->update(
338  'UPDATE rt_contexts
339  SET title = ?, abbrev = ?, description = ?, cited_by = ?, author_terms = ?, geo_terms = ?, define_terms = ?, seq = ?
340  WHERE context_id = ? AND version_id = ?',
341  array($context->title, $context->abbrev, $context->description, $context->citedBy?1:0, $context->authorTerms?1:0, $context->geoTerms?1:0, $context->defineTerms?1:0, (int) $context->order, (int) $context->contextId, (int) $context->versionId)
342  );
343  }
344 
349  function deleteContextsByVersionId($versionId) {
350  $contexts =& $this->getContexts($versionId);
351  foreach ($contexts->toArray() as $context) {
352  $this->deleteContext(
353  $context->getContextId(),
354  $context->getVersionId()
355  );
356  }
357  }
358 
364  function deleteContext($contextId, $versionId) {
365  $result = $this->update(
366  'DELETE FROM rt_contexts WHERE context_id = ? AND version_id = ?',
367  array((int) $contextId, (int) $versionId)
368  );
369  if ($result) $this->deleteSearchesByContextId($contextId);
370  return $result;
371  }
372 
376  function resequenceContexts($versionId) {
377  $result =& $this->retrieve(
378  'SELECT context_id FROM rt_contexts WHERE version_id = ? ORDER BY seq',
379  array((int) $versionId)
380  );
381 
382  for ($i=1; !$result->EOF; $i++) {
383  list($contextId) = $result->fields;
384  $this->update(
385  'UPDATE rt_contexts SET seq = ? WHERE context_id = ?',
386  array(
387  $i,
388  $contextId
389  )
390  );
391 
392  $result->moveNext();
393  }
394 
395  $result->close();
396  unset($result);
397  }
398 
404  function &_returnContextFromRow(&$row) {
405  $context = new RTContext();
406  $context->setContextId($row['context_id']);
407  $context->setVersionId($row['version_id']);
408  $context->setTitle($row['title']);
409  $context->setAbbrev($row['abbrev']);
410  $context->setDescription($row['description']);
411  $context->setCitedBy($row['cited_by']);
412  $context->setAuthorTerms($row['author_terms']);
413  $context->setGeoTerms($row['geo_terms']);
414  $context->setDefineTerms($row['define_terms']);
415  $context->setOrder($row['seq']);
416 
417  if (!HookRegistry::call('RTDAO::_returnContextFromRow', array(&$context, &$row))) {
418  $searchesIterator =& $this->getSearches($row['context_id']);
419  $context->setSearches($searchesIterator->toArray());
420  }
421 
422  return $context;
423  }
424 
425 
426 
427  //
428  // RT Searches
429  //
430 
436  function &getSearch($searchId) {
437  $result =& $this->retrieve(
438  'SELECT * FROM rt_searches WHERE search_id = ?',
439  array((int) $searchId)
440  );
441 
442  $returner = null;
443  if ($result->RecordCount() != 0) {
444  $returner =& $this->_returnSearchFromRow($result->GetRowAssoc(false));
445  }
446 
447  $result->Close();
448  unset($result);
449 
450  return $returner;
451  }
452 
459  function &getSearches($contextId, $pagingInfo = null) {
460  $searches = array();
461 
462  $result =& $this->retrieveRange(
463  'SELECT * FROM rt_searches WHERE context_id = ? ORDER BY seq',
464  array((int) $contextId),
465  $pagingInfo
466  );
467 
468  $returner = new DAOResultFactory($result, $this, '_returnSearchFromRow');
469  return $returner;
470  }
471 
476  function insertSearch(&$search) {
477  $this->update(
478  'INSERT INTO rt_searches
479  (context_id, title, description, url, search_url, search_post, seq)
480  VALUES
481  (?, ?, ?, ?, ?, ?, ?)',
482  array(
483  (int) $search->getContextId(),
484  $search->getTitle(),
485  $search->getDescription(),
486  $search->getUrl(),
487  $search->getSearchUrl(),
488  $search->getSearchPost(),
489  (int) $search->getOrder()
490  )
491  );
492 
493  $search->searchId = $this->getInsertId('rt_searches', 'search_id');
494  return $search->searchId;
495  }
496 
501  function updateSearch(&$search) {
502  return $this->update(
503  'UPDATE rt_searches
504  SET title = ?, description = ?, url = ?, search_url = ?, search_post = ?, seq = ?
505  WHERE search_id = ? AND context_id = ?',
506  array(
507  $search->getTitle(),
508  $search->getDescription(),
509  $search->getUrl(),
510  $search->getSearchUrl(),
511  $search->getSearchPost(),
512  (int) $search->getOrder(),
513  (int) $search->getSearchId(),
514  (int) $search->getContextId()
515  )
516  );
517  }
518 
523  function deleteSearchesByContextId($contextId) {
524  return $this->update(
525  'DELETE FROM rt_searches WHERE context_id = ?',
526  array((int) $contextId)
527  );
528  }
529 
535  function deleteSearch($searchId, $contextId) {
536  return $this->update(
537  'DELETE FROM rt_searches WHERE search_id = ? AND context_id = ?',
538  array((int) $searchId, (int) $contextId)
539  );
540  }
541 
545  function resequenceSearches($contextId) {
546  $result =& $this->retrieve(
547  'SELECT search_id FROM rt_searches WHERE context_id = ? ORDER BY seq',
548  array((int) $contextId)
549  );
550 
551  for ($i=1; !$result->EOF; $i++) {
552  list($searchId) = $result->fields;
553  $this->update(
554  'UPDATE rt_searches SET seq = ? WHERE search_id = ?',
555  array(
556  $i,
557  $searchId
558  )
559  );
560 
561  $result->moveNext();
562  }
563 
564  $result->close();
565  unset($result);
566  }
567 }
568 
569 ?>
updateConferenceRT(&$rt)
Definition: RTDAO.inc.php:48
config TEMPLATE inc php
Definition: config.inc.php:4
Operations for retrieving and modifying objects from a database.
Definition: DAO.inc.php:30
setEnabled($enabled)
Definition: RT.inc.php:67
& getVersion($versionId, $conferenceId)
Definition: RTDAO.inc.php:105
deleteVersionsByConferenceId($conferenceId)
Definition: RTDAO.inc.php:176
& getSearch($searchId)
Definition: RTDAO.inc.php:436
& getSearches($contextId, $pagingInfo=null)
Definition: RTDAO.inc.php:459
& _returnVersionFromRow(&$row)
Definition: RTDAO.inc.php:213
& retrieve($sql, $params=false, $callHooks=true)
Definition: DAO.inc.php:62
insertConferenceRT(&$rt)
Definition: RTDAO.inc.php:72
insertVersion($conferenceId, &$version)
Definition: RTDAO.inc.php:127
getInsertId($table='', $id='', $callHooks=true)
Definition: DAO.inc.php:225
& getVersions($conferenceId, $pagingInfo=null)
Definition: RTDAO.inc.php:86
updateVersion($conferenceId, &$version)
Definition: RTDAO.inc.php:151
& retrieveRange($sql, $params=false, $dbResultRange=null, $callHooks=true)
Definition: DAO.inc.php:152
deleteVersion($versionId, $conferenceId)
Definition: RTDAO.inc.php:188
updateContext(&$context)
Definition: RTDAO.inc.php:335
& getContexts($versionId, $pagingInfo=null)
Definition: RTDAO.inc.php:284
resequenceSearches($contextId)
Definition: RTDAO.inc.php:545
Wrapper around ADORecordSet providing "factory" features for generating objects from DAOs.
DAO operations for the OCS Reading Tools interface.
Definition: RTDAO.inc.php:20
resequenceContexts($versionId)
Definition: RTDAO.inc.php:376
updateSearch(&$search)
Definition: RTDAO.inc.php:501
& _returnContextFromRow(&$row)
Definition: RTDAO.inc.php:404
Data structures associated with the Reading Tools component.
deleteVersionsByConference($conferenceId)
Definition: RTDAO.inc.php:200
deleteSearchesByContextId($contextId)
Definition: RTDAO.inc.php:523
deleteContextsByVersionId($versionId)
Definition: RTDAO.inc.php:349
& getDAO($name, $dbconn=null)
insertContext(&$context)
Definition: RTDAO.inc.php:302
insertSearch(&$search)
Definition: RTDAO.inc.php:476
& _returnSearchFromRow(&$row)
Definition: RTDAO.inc.php:234
call($hookName, $args=null)
deleteContext($contextId, $versionId)
Definition: RTDAO.inc.php:364
OCS-specific Reading Tools end-user interface.
& getConferenceRTByConference(&$conference)
Definition: RTDAO.inc.php:30
update($sql, $params=false, $callHooks=true, $dieOnError=true)
Definition: DAO.inc.php:186
& getContext($contextId)
Definition: RTDAO.inc.php:261
deleteSearch($searchId, $contextId)
Definition: RTDAO.inc.php:535