Open Journal Systems  2.4.4
 All Classes Namespaces Functions Variables Groups Pages
ArticleDAO.inc.php
1 <?php
2 
18 import('classes.article.Article');
19 
20 class ArticleDAO extends DAO {
21  var $authorDao;
22 
23  var $cache;
24 
25  function _cacheMiss(&$cache, $id) {
26  $article =& $this->getArticle($id, null, false);
27  $cache->setCache($id, $article);
28  return $article;
29  }
30 
31  function &_getCache() {
32  if (!isset($this->cache)) {
33  $cacheManager =& CacheManager::getManager();
34  $this->cache =& $cacheManager->getObjectCache('articles', 0, array(&$this, '_cacheMiss'));
35  }
36  return $this->cache;
37  }
38 
42  function ArticleDAO() {
43  parent::DAO();
44  $this->authorDao =& DAORegistry::getDAO('AuthorDAO');
45  }
46 
51  function getLocaleFieldNames() {
52  return array(
53  'title', 'cleanTitle', 'abstract', 'coverPageAltText', 'showCoverPage', 'hideCoverPageToc', 'hideCoverPageAbstract', 'originalFileName', 'fileName', 'width', 'height',
54  'discipline', 'subjectClass', 'subject', 'coverageGeo', 'coverageChron', 'coverageSample', 'type', 'sponsor',
55  'copyrightHolder'
56  );
57  }
58 
65  $additionalFields = parent::getAdditionalFieldNames();
66  // FIXME: Move this to a PID plug-in.
67  $additionalFields[] = 'pub-id::publisher-id';
68  $additionalFields[] = 'copyrightYear';
69  $additionalFields[] = 'licenseURL';
70  return $additionalFields;
71  }
72 
77  function updateLocaleFields(&$article) {
78  $this->updateDataObjectSettings('article_settings', $article, array(
79  'article_id' => $article->getId()
80  ));
81  }
82 
90  function &getArticle($articleId, $journalId = null, $useCache = false) {
91  if ($useCache) {
92  $cache =& $this->_getCache();
93  $returner = $cache->get($articleId);
94  if ($returner && $journalId != null && $journalId != $returner->getJournalId()) $returner = null;
95  return $returner;
96  }
97 
98  $primaryLocale = AppLocale::getPrimaryLocale();
99  $locale = AppLocale::getLocale();
100  $params = array(
101  'title',
102  $primaryLocale,
103  'title',
104  $locale,
105  'abbrev',
106  $primaryLocale,
107  'abbrev',
108  $locale,
109  $articleId
110  );
111  $sql = 'SELECT a.*,
112  COALESCE(stl.setting_value, stpl.setting_value) AS section_title,
113  COALESCE(sal.setting_value, sapl.setting_value) AS section_abbrev
114  FROM articles a
115  LEFT JOIN sections s ON s.section_id = a.section_id
116  LEFT JOIN section_settings stpl ON (s.section_id = stpl.section_id AND stpl.setting_name = ? AND stpl.locale = ?)
117  LEFT JOIN section_settings stl ON (s.section_id = stl.section_id AND stl.setting_name = ? AND stl.locale = ?)
118  LEFT JOIN section_settings sapl ON (s.section_id = sapl.section_id AND sapl.setting_name = ? AND sapl.locale = ?)
119  LEFT JOIN section_settings sal ON (s.section_id = sal.section_id AND sal.setting_name = ? AND sal.locale = ?)
120  WHERE article_id = ?';
121  if ($journalId !== null) {
122  $sql .= ' AND a.journal_id = ?';
123  $params[] = $journalId;
124  }
125 
126  $result =& $this->retrieve($sql, $params);
127 
128  $returner = null;
129  if ($result->RecordCount() != 0) {
130  $returner =& $this->_returnArticleFromRow($result->GetRowAssoc(false));
131  }
132 
133  $result->Close();
134  unset($result);
135 
136  return $returner;
137  }
138 
139 
148  function &getBySetting($settingName, $settingValue, $journalId = null, $rangeInfo = null) {
149  $primaryLocale = AppLocale::getPrimaryLocale();
150  $locale = AppLocale::getLocale();
151 
152  $params = array(
153  'title',
154  $primaryLocale,
155  'title',
156  $locale,
157  'abbrev',
158  $primaryLocale,
159  'abbrev',
160  $locale,
161  $settingName
162  );
163 
164  $sql = 'SELECT a.*,
165  COALESCE(stl.setting_value, stpl.setting_value) AS section_title,
166  COALESCE(sal.setting_value, sapl.setting_value) AS section_abbrev
167  FROM articles a
168  LEFT JOIN sections s ON s.section_id = a.section_id
169  LEFT JOIN section_settings stpl ON (s.section_id = stpl.section_id AND stpl.setting_name = ? AND stpl.locale = ?)
170  LEFT JOIN section_settings stl ON (s.section_id = stl.section_id AND stl.setting_name = ? AND stl.locale = ?)
171  LEFT JOIN section_settings sapl ON (s.section_id = sapl.section_id AND sapl.setting_name = ? AND sapl.locale = ?)
172  LEFT JOIN section_settings sal ON (s.section_id = sal.section_id AND sal.setting_name = ? AND sal.locale = ?) ';
173  if (is_null($settingValue)) {
174  $sql .= 'LEFT JOIN article_settings ast ON a.article_id = ast.article_id AND ast.setting_name = ?
175  WHERE (ast.setting_value IS NULL OR ast.setting_value = "")';
176  } else {
177  $params[] = $settingValue;
178  $sql .= 'INNER JOIN article_settings ast ON a.article_id = ast.article_id
179  WHERE ast.setting_name = ? AND ast.setting_value = ?';
180  }
181  if ($journalId) {
182  $params[] = (int) $journalId;
183  $sql .= ' AND a.journal_id = ?';
184  }
185  $sql .= ' ORDER BY a.journal_id, a.article_id';
186  $result =& $this->retrieveRange($sql, $params, $rangeInfo);
187 
188  $returner = new DAOResultFactory($result, $this, '_returnArticleFromRow');
189  return $returner;
190  }
191 
197  function &_returnArticleFromRow(&$row) {
198  $article = new Article();
199  $this->_articleFromRow($article, $row);
200  return $article;
201  }
202 
208  function _articleFromRow(&$article, &$row) {
209  $article->setId($row['article_id']);
210  $article->setLocale($row['locale']);
211  $article->setUserId($row['user_id']);
212  $article->setJournalId($row['journal_id']);
213  $article->setSectionId($row['section_id']);
214  $article->setSectionTitle($row['section_title']);
215  $article->setSectionAbbrev($row['section_abbrev']);
216  $article->setLanguage($row['language']);
217  $article->setCommentsToEditor($row['comments_to_ed']);
218  $article->setCitations($row['citations']);
219  $article->setDateSubmitted($this->datetimeFromDB($row['date_submitted']));
220  $article->setDateStatusModified($this->datetimeFromDB($row['date_status_modified']));
221  $article->setLastModified($this->datetimeFromDB($row['last_modified']));
222  $article->setStatus($row['status']);
223  $article->setSubmissionProgress($row['submission_progress']);
224  $article->setCurrentRound($row['current_round']);
225  $article->setSubmissionFileId($row['submission_file_id']);
226  $article->setRevisedFileId($row['revised_file_id']);
227  $article->setReviewFileId($row['review_file_id']);
228  $article->setEditorFileId($row['editor_file_id']);
229  $article->setPages($row['pages']);
230  $article->setFastTracked($row['fast_tracked']);
231  $article->setHideAuthor($row['hide_author']);
232  $article->setCommentsStatus($row['comments_status']);
233 
234  $this->getDataObjectSettings('article_settings', 'article_id', $row['article_id'], $article);
235 
236  HookRegistry::call('ArticleDAO::_returnArticleFromRow', array(&$article, &$row));
237 
238  }
239 
244  function insertArticle(&$article) {
245  $article->stampModified();
246  $this->update(
247  sprintf('INSERT INTO articles
248  (locale, user_id, journal_id, section_id, language, comments_to_ed, citations, date_submitted, date_status_modified, last_modified, status, submission_progress, current_round, submission_file_id, revised_file_id, review_file_id, editor_file_id, pages, fast_tracked, hide_author, comments_status)
249  VALUES
250  (?, ?, ?, ?, ?, ?, ?, %s, %s, %s, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
251  $this->datetimeToDB($article->getDateSubmitted()), $this->datetimeToDB($article->getDateStatusModified()), $this->datetimeToDB($article->getLastModified())),
252  array(
253  $article->getLocale(),
254  $article->getUserId(),
255  $article->getJournalId(),
256  $article->getSectionId(),
257  $article->getLanguage(),
258  $article->getCommentsToEditor(),
259  $article->getCitations(),
260  $article->getStatus() === null ? STATUS_QUEUED : $article->getStatus(),
261  $article->getSubmissionProgress() === null ? 1 : $article->getSubmissionProgress(),
262  $article->getCurrentRound() === null ? 1 : $article->getCurrentRound(),
263  $this->nullOrInt($article->getSubmissionFileId()),
264  $this->nullOrInt($article->getRevisedFileId()),
265  $this->nullOrInt($article->getReviewFileId()),
266  $this->nullOrInt($article->getEditorFileId()),
267  $article->getPages(),
268  (int) $article->getFastTracked(),
269  (int) $article->getHideAuthor(),
270  (int) $article->getCommentsStatus()
271  )
272  );
273 
274  $article->setId($this->getInsertArticleId());
275  $this->updateLocaleFields($article);
276 
277  // Insert authors for this article
278  $authors =& $article->getAuthors();
279  for ($i=0, $count=count($authors); $i < $count; $i++) {
280  $authors[$i]->setSubmissionId($article->getId());
281  $this->authorDao->insertAuthor($authors[$i]);
282  }
283 
284  return $article->getId();
285  }
286 
291  function updateArticle(&$article) {
292  $article->stampModified();
293  $this->update(
294  sprintf('UPDATE articles
295  SET locale = ?,
296  user_id = ?,
297  section_id = ?,
298  language = ?,
299  comments_to_ed = ?,
300  citations = ?,
301  date_submitted = %s,
302  date_status_modified = %s,
303  last_modified = %s,
304  status = ?,
305  submission_progress = ?,
306  current_round = ?,
307  submission_file_id = ?,
308  revised_file_id = ?,
309  review_file_id = ?,
310  editor_file_id = ?,
311  pages = ?,
312  fast_tracked = ?,
313  hide_author = ?,
314  comments_status = ?
315  WHERE article_id = ?',
316  $this->datetimeToDB($article->getDateSubmitted()), $this->datetimeToDB($article->getDateStatusModified()), $this->datetimeToDB($article->getLastModified())),
317  array(
318  $article->getLocale(),
319  (int) $article->getUserId(),
320  (int) $article->getSectionId(),
321  $article->getLanguage(),
322  $article->getCommentsToEditor(),
323  $article->getCitations(),
324  (int) $article->getStatus(),
325  (int) $article->getSubmissionProgress(),
326  (int) $article->getCurrentRound(),
327  $this->nullOrInt($article->getSubmissionFileId()),
328  $this->nullOrInt($article->getRevisedFileId()),
329  $this->nullOrInt($article->getReviewFileId()),
330  $this->nullOrInt($article->getEditorFileId()),
331  $article->getPages(),
332  (int) $article->getFastTracked(),
333  (int) $article->getHideAuthor(),
334  (int) $article->getCommentsStatus(),
335  $article->getId()
336  )
337  );
338 
339  $this->updateLocaleFields($article);
340 
341  // update authors for this article
342  $authors =& $article->getAuthors();
343  for ($i=0, $count=count($authors); $i < $count; $i++) {
344  if ($authors[$i]->getId() > 0) {
345  $this->authorDao->updateAuthor($authors[$i]);
346  } else {
347  $this->authorDao->insertAuthor($authors[$i]);
348  }
349  }
350 
351  // Update author sequence numbers
352  $this->authorDao->resequenceAuthors($article->getId());
353 
354  $this->flushCache();
355  }
356 
361  function deleteArticle(&$article) {
362  return $this->deleteArticleById($article->getId());
363  }
364 
369  function deleteArticleById($articleId) {
370  $this->authorDao->deleteAuthorsByArticle($articleId);
371 
372  $publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO');
373  $publishedArticleDao->deletePublishedArticleByArticleId($articleId);
374 
375  $commentDao =& DAORegistry::getDAO('CommentDAO');
376  $commentDao->deleteBySubmissionId($articleId);
377 
378  $noteDao =& DAORegistry::getDAO('NoteDAO');
379  $noteDao->deleteByAssoc(ASSOC_TYPE_ARTICLE, $articleId);
380 
381  $sectionEditorSubmissionDao =& DAORegistry::getDAO('SectionEditorSubmissionDAO');
382  $sectionEditorSubmissionDao->deleteDecisionsByArticle($articleId);
383  $sectionEditorSubmissionDao->deleteReviewRoundsByArticle($articleId);
384 
385  $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
386  $reviewAssignmentDao->deleteBySubmissionId($articleId);
387 
388  $editAssignmentDao =& DAORegistry::getDAO('EditAssignmentDAO');
389  $editAssignmentDao->deleteEditAssignmentsByArticle($articleId);
390 
391  // Delete copyedit, layout, and proofread signoffs
392  $signoffDao =& DAORegistry::getDAO('SignoffDAO');
393  $copyedInitialSignoffs = $signoffDao->getBySymbolic('SIGNOFF_COPYEDITING_INITIAL', ASSOC_TYPE_ARTICLE, $articleId);
394  $copyedAuthorSignoffs = $signoffDao->getBySymbolic('SIGNOFF_COPYEDITING_AUTHOR', ASSOC_TYPE_ARTICLE, $articleId);
395  $copyedFinalSignoffs = $signoffDao->getBySymbolic('SIGNOFF_COPYEDITING_FINAL', ASSOC_TYPE_ARTICLE, $articleId);
396  $layoutSignoffs = $signoffDao->getBySymbolic('SIGNOFF_LAYOUT', ASSOC_TYPE_ARTICLE, $articleId);
397  $proofreadAuthorSignoffs = $signoffDao->getBySymbolic('SIGNOFF_PROOFREADING_AUTHOR', ASSOC_TYPE_ARTICLE, $articleId);
398  $proofreadProofreaderSignoffs = $signoffDao->getBySymbolic('SIGNOFF_PROOFREADING_PROOFREADER', ASSOC_TYPE_ARTICLE, $articleId);
399  $proofreadLayoutSignoffs = $signoffDao->getBySymbolic('SIGNOFF_PROOFREADING_LAYOUT', ASSOC_TYPE_ARTICLE, $articleId);
400  $signoffs = array($copyedInitialSignoffs, $copyedAuthorSignoffs, $copyedFinalSignoffs, $layoutSignoffs,
401  $proofreadAuthorSignoffs, $proofreadProofreaderSignoffs, $proofreadLayoutSignoffs);
402  foreach ($signoffs as $signoff) {
403  if ( $signoff ) $signoffDao->deleteObject($signoff);
404  }
405 
406  $articleCommentDao =& DAORegistry::getDAO('ArticleCommentDAO');
407  $articleCommentDao->deleteArticleComments($articleId);
408 
409  $articleGalleyDao =& DAORegistry::getDAO('ArticleGalleyDAO');
410  $articleGalleyDao->deleteGalleysByArticle($articleId);
411 
412  $articleSearchDao =& DAORegistry::getDAO('ArticleSearchDAO');
413  $articleSearchDao->deleteArticleKeywords($articleId);
414 
415  $articleEventLogDao =& DAORegistry::getDAO('ArticleEventLogDAO');
416  $articleEventLogDao->deleteByAssoc(ASSOC_TYPE_ARTICLE, $articleId);
417 
418  $articleEmailLogDao =& DAORegistry::getDAO('ArticleEmailLogDAO');
419  $articleEmailLogDao->deleteByAssoc(ASSOC_TYPE_ARTICLE, $articleId);
420 
421  $notificationDao =& DAORegistry::getDAO('NotificationDAO');
422  $notificationDao->deleteByAssoc(ASSOC_TYPE_ARTICLE, $articleId);
423 
424  $suppFileDao =& DAORegistry::getDAO('SuppFileDAO');
425  $suppFileDao->deleteSuppFilesByArticle($articleId);
426 
427  // Delete article files -- first from the filesystem, then from the database
428  import('classes.file.ArticleFileManager');
429  $articleFileDao =& DAORegistry::getDAO('ArticleFileDAO');
430  $articleFiles =& $articleFileDao->getArticleFilesByArticle($articleId);
431 
432  $articleFileManager = new ArticleFileManager($articleId);
433  foreach ($articleFiles as $articleFile) {
434  $articleFileManager->deleteFile($articleFile->getFileId());
435  }
436 
437  $articleFileDao->deleteArticleFiles($articleId);
438 
439  // Delete article citations.
440  $citationDao =& DAORegistry::getDAO('CitationDAO');
441  $citationDao->deleteObjectsByAssocId(ASSOC_TYPE_ARTICLE, $articleId);
442 
443  $this->update('DELETE FROM article_settings WHERE article_id = ?', $articleId);
444  $this->update('DELETE FROM articles WHERE article_id = ?', $articleId);
445 
446  import('classes.search.ArticleSearchIndex');
447  $articleSearchIndex = new ArticleSearchIndex();
448  $articleSearchIndex->articleDeleted($articleId);
449  $articleSearchIndex->articleChangesFinished();
450 
451  $this->flushCache();
452  }
453 
459  function &getArticlesByJournalId($journalId = null) {
460  $primaryLocale = AppLocale::getPrimaryLocale();
461  $locale = AppLocale::getLocale();
462 
463  $params = array(
464  'title',
465  $primaryLocale,
466  'title',
467  $locale,
468  'abbrev',
469  $primaryLocale,
470  'abbrev',
471  $locale
472  );
473  if ($journalId !== null) $params[] = (int) $journalId;
474 
475  $result =& $this->retrieve(
476  'SELECT a.*,
477  COALESCE(stl.setting_value, stpl.setting_value) AS section_title,
478  COALESCE(sal.setting_value, sapl.setting_value) AS section_abbrev
479  FROM articles a
480  LEFT JOIN sections s ON s.section_id = a.section_id
481  LEFT JOIN section_settings stpl ON (s.section_id = stpl.section_id AND stpl.setting_name = ? AND stpl.locale = ?)
482  LEFT JOIN section_settings stl ON (s.section_id = stl.section_id AND stl.setting_name = ? AND stl.locale = ?)
483  LEFT JOIN section_settings sapl ON (s.section_id = sapl.section_id AND sapl.setting_name = ? AND sapl.locale = ?)
484  LEFT JOIN section_settings sal ON (s.section_id = sal.section_id AND sal.setting_name = ? AND sal.locale = ?)
485  ' . ($journalId !== null ? 'WHERE a.journal_id = ?' : ''),
486  $params
487  );
488 
489  $returner = new DAOResultFactory($result, $this, '_returnArticleFromRow');
490  return $returner;
491  }
492 
497  function deleteArticlesByJournalId($journalId) {
498  $articles = $this->getArticlesByJournalId($journalId);
499 
500  while (!$articles->eof()) {
501  $article =& $articles->next();
502  $this->deleteArticleById($article->getId());
503  }
504  }
505 
512  function &getArticlesByUserId($userId, $journalId = null) {
513  $primaryLocale = AppLocale::getPrimaryLocale();
514  $locale = AppLocale::getLocale();
515  $params = array(
516  'title',
517  $primaryLocale,
518  'title',
519  $locale,
520  'abbrev',
521  $primaryLocale,
522  'abbrev',
523  $locale,
524  $userId
525  );
526  if ($journalId) $params[] = $journalId;
527  $articles = array();
528 
529  $result =& $this->retrieve(
530  'SELECT a.*,
531  COALESCE(stl.setting_value, stpl.setting_value) AS section_title,
532  COALESCE(sal.setting_value, sapl.setting_value) AS section_abbrev
533  FROM articles a
534  LEFT JOIN sections s ON s.section_id = a.section_id
535  LEFT JOIN section_settings stpl ON (s.section_id = stpl.section_id AND stpl.setting_name = ? AND stpl.locale = ?)
536  LEFT JOIN section_settings stl ON (s.section_id = stl.section_id AND stl.setting_name = ? AND stl.locale = ?)
537  LEFT JOIN section_settings sapl ON (s.section_id = sapl.section_id AND sapl.setting_name = ? AND sapl.locale = ?)
538  LEFT JOIN section_settings sal ON (s.section_id = sal.section_id AND sal.setting_name = ? AND sal.locale = ?)
539  WHERE a.user_id = ?' .
540  (isset($journalId)?' AND a.journal_id = ?':''),
541  $params
542  );
543 
544  while (!$result->EOF) {
545  $articles[] =& $this->_returnArticleFromRow($result->GetRowAssoc(false));
546  $result->MoveNext();
547  }
548 
549  $result->Close();
550  unset($result);
551 
552  return $articles;
553  }
554 
560  function getArticleJournalId($articleId) {
561  $result =& $this->retrieve(
562  'SELECT journal_id FROM articles WHERE article_id = ?', $articleId
563  );
564  $returner = isset($result->fields[0]) ? $result->fields[0] : false;
565 
566  $result->Close();
567  unset($result);
568 
569  return $returner;
570  }
571 
579  function incompleteSubmissionExists($articleId, $userId, $journalId) {
580  $result =& $this->retrieve(
581  'SELECT submission_progress FROM articles WHERE article_id = ? AND user_id = ? AND journal_id = ? AND date_submitted IS NULL',
582  array($articleId, $userId, $journalId)
583  );
584  $returner = isset($result->fields[0]) ? $result->fields[0] : false;
585 
586  $result->Close();
587  unset($result);
588 
589  return $returner;
590  }
591 
597  function changeArticleStatus($articleId, $status) {
598  $this->update(
599  'UPDATE articles SET status = ? WHERE article_id = ?', array((int) $status, (int) $articleId)
600  );
601 
602  $this->flushCache();
603  }
604 
613  function updateSetting($articleId, $name, $value, $type, $isLocalized = false) {
614  // Check and prepare setting data.
615  if ($isLocalized) {
616  if (is_array($value)) {
617  $values =& $value;
618  } else {
619  // We expect localized data to come in as an array.
620  assert(false);
621  return;
622  }
623  } else {
624  // Normalize non-localized data to an array so that
625  // we can treat updates uniformly.
626  $values = array('' => $value);
627  }
628  unset($value);
629 
630  // Update setting values.
631  $keyFields = array('setting_name', 'locale', 'article_id');
632  foreach ($values as $locale => $value) {
633  // Locale-specific entries will be deleted when no value exists.
634  // Non-localized settings will always be set.
635  if ($isLocalized) {
636  $this->update(
637  'DELETE FROM article_settings WHERE article_id = ? AND setting_name = ? AND locale = ?',
638  array($articleId, $name, $locale)
639  );
640  if (empty($value)) continue;
641  }
642 
643  // Convert the new value to the correct type.
644  $value = $this->convertToDB($value, $type);
645 
646  // Update the database.
647  $this->replace('article_settings',
648  array(
649  'article_id' => $articleId,
650  'setting_name' => $name,
651  'setting_value' => $value,
652  'setting_type' => $type,
653  'locale' => $locale
654  ),
655  $keyFields
656  );
657  }
658  $this->flushCache();
659  }
660 
669  function changePubId($articleId, $pubIdType, $pubId) {
670  $this->updateSetting($articleId, 'pub-id::'.$pubIdType, $pubId, 'string');
671  }
672 
684  function pubIdExists($pubIdType, $pubId, $articleId, $journalId) {
685  $result =& $this->retrieve(
686  'SELECT COUNT(*)
687  FROM article_settings ast
688  INNER JOIN articles a ON ast.article_id = a.article_id
689  WHERE ast.setting_name = ? and ast.setting_value = ? and ast.article_id <> ? AND a.journal_id = ?',
690  array(
691  'pub-id::'.$pubIdType,
692  $pubId,
693  (int) $articleId,
694  (int) $journalId
695  )
696  );
697  $returner = $result->fields[0] ? true : false;
698  $result->Close();
699  return $returner;
700  }
701 
706  function removeArticlesFromSection($sectionId) {
707  $this->update(
708  'UPDATE articles SET section_id = null WHERE section_id = ?', $sectionId
709  );
710 
711  $this->flushCache();
712  }
713 
718  function deletePermissions($journalId) {
719  $journalId = (int) $journalId;
720  $articles =& $this->getArticlesByJournalId($journalId);
721  while ($article =& $articles->next()) {
722  $this->update(
723  'DELETE FROM article_settings WHERE (setting_name = ? OR setting_name = ? OR setting_name = ?) AND article_id = ?',
724  array(
725  'licenseURL',
726  'copyrightHolder',
727  'copyrightYear',
728  (int) $article->getId()
729  )
730  );
731  unset($article);
732  }
733  $this->flushCache();
734  }
735 
743  function deleteAllPubIds($journalId, $pubIdType) {
744  $journalId = (int) $journalId;
745  $settingName = 'pub-id::'.$pubIdType;
746 
747  $articles =& $this->getArticlesByJournalId($journalId);
748  while ($article =& $articles->next()) {
749  $this->update(
750  'DELETE FROM article_settings WHERE setting_name = ? AND article_id = ?',
751  array(
752  $settingName,
753  (int)$article->getId()
754  )
755  );
756  unset($article);
757  }
758  $this->flushCache();
759  }
760 
765  function getInsertArticleId() {
766  return $this->getInsertId('articles', 'article_id');
767  }
768 
769  function flushCache() {
770  // Because both publishedArticles and articles are cached by
771  // article ID, flush both caches on update.
772  $cache =& $this->_getCache();
773  $cache->flush();
774  unset($cache);
775 
776  $publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO');
777  $cache =& $publishedArticleDao->_getPublishedArticleCache();
778  $cache->flush();
779  unset($cache);
780  }
781 }
782 
783 ?>
Operations for retrieving and modifying objects from a database.
Definition: DAO.inc.php:29
removeArticlesFromSection($sectionId)
_articleFromRow(&$article, &$row)
& retrieve($sql, $params=false, $callHooks=true)
Definition: DAO.inc.php:83
deleteArticle(&$article)
changeArticleStatus($articleId, $status)
& getArticlesByJournalId($journalId=null)
getInsertId($table= '', $id= '', $callHooks=true)
Definition: DAO.inc.php:252
Article class.
Definition: Article.inc.php:52
& getBySetting($settingName, $settingValue, $journalId=null, $rangeInfo=null)
& getArticlesByUserId($userId, $journalId=null)
updateDataObjectSettings($tableName, &$dataObject, $idArray)
Definition: DAO.inc.php:460
deletePermissions($journalId)
insertArticle(&$article)
& retrieveRange($sql, $params=false, $dbResultRange=null, $callHooks=true)
Definition: DAO.inc.php:176
datetimeFromDB($dt)
Definition: DAO.inc.php:316
updateLocaleFields(&$article)
incompleteSubmissionExists($articleId, $userId, $journalId)
changePubId($articleId, $pubIdType, $pubId)
Wrapper around ADORecordSet providing &quot;factory&quot; features for generating objects from DAOs...
updateSetting($articleId, $name, $value, $type, $isLocalized=false)
& getDAO($name, $dbconn=null)
& _returnArticleFromRow(&$row)
deleteArticlesByJournalId($journalId)
Class defining operations for article file management.
convertToDB($value, &$type)
Definition: DAO.inc.php:394
call($hookName, $args=null)
& getArticle($articleId, $journalId=null, $useCache=false)
Class to maintain the article search index.
replace($table, $arrFields, $keyCols)
Definition: DAO.inc.php:240
Operations for retrieving and modifying Article objects.
deleteAllPubIds($journalId, $pubIdType)
datetimeToDB($dt)
Definition: DAO.inc.php:296
update($sql, $params=false, $callHooks=true, $dieOnError=true)
Definition: DAO.inc.php:211
pubIdExists($pubIdType, $pubId, $articleId, $journalId)
deleteArticleById($articleId)
getArticleJournalId($articleId)
updateArticle(&$article)
getAdditionalFieldNames()