Open Journal Systems  2.4.8
 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_merge(parent::getLocaleFieldNames(), 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  return $article->getId();
278  }
279 
284  function updateArticle(&$article) {
285  $article->stampModified();
286  $this->update(
287  sprintf('UPDATE articles
288  SET locale = ?,
289  user_id = ?,
290  section_id = ?,
291  language = ?,
292  comments_to_ed = ?,
293  citations = ?,
294  date_submitted = %s,
295  date_status_modified = %s,
296  last_modified = %s,
297  status = ?,
298  submission_progress = ?,
299  current_round = ?,
300  submission_file_id = ?,
301  revised_file_id = ?,
302  review_file_id = ?,
303  editor_file_id = ?,
304  pages = ?,
305  fast_tracked = ?,
306  hide_author = ?,
307  comments_status = ?
308  WHERE article_id = ?',
309  $this->datetimeToDB($article->getDateSubmitted()), $this->datetimeToDB($article->getDateStatusModified()), $this->datetimeToDB($article->getLastModified())),
310  array(
311  $article->getLocale(),
312  (int) $article->getUserId(),
313  (int) $article->getSectionId(),
314  $article->getLanguage(),
315  $article->getCommentsToEditor(),
316  $article->getCitations(),
317  (int) $article->getStatus(),
318  (int) $article->getSubmissionProgress(),
319  (int) $article->getCurrentRound(),
320  $this->nullOrInt($article->getSubmissionFileId()),
321  $this->nullOrInt($article->getRevisedFileId()),
322  $this->nullOrInt($article->getReviewFileId()),
323  $this->nullOrInt($article->getEditorFileId()),
324  $article->getPages(),
325  (int) $article->getFastTracked(),
326  (int) $article->getHideAuthor(),
327  (int) $article->getCommentsStatus(),
328  $article->getId()
329  )
330  );
331 
332  $this->updateLocaleFields($article);
333 
334  // update authors for this article
335  $authors =& $article->getAuthors();
336  for ($i=0, $count=count($authors); $i < $count; $i++) {
337  if ($authors[$i]->getId() > 0) {
338  $this->authorDao->updateAuthor($authors[$i]);
339  } else {
340  $this->authorDao->insertAuthor($authors[$i]);
341  }
342  }
343 
344  // Update author sequence numbers
345  $this->authorDao->resequenceAuthors($article->getId());
346 
347  $this->flushCache();
348  }
349 
354  function deleteArticle(&$article) {
355  return $this->deleteArticleById($article->getId());
356  }
357 
362  function deleteArticleById($articleId) {
363  $this->authorDao->deleteAuthorsByArticle($articleId);
364 
365  $publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO');
366  $publishedArticleDao->deletePublishedArticleByArticleId($articleId);
367 
368  $commentDao =& DAORegistry::getDAO('CommentDAO');
369  $commentDao->deleteBySubmissionId($articleId);
370 
371  $noteDao =& DAORegistry::getDAO('NoteDAO');
372  $noteDao->deleteByAssoc(ASSOC_TYPE_ARTICLE, $articleId);
373 
374  $sectionEditorSubmissionDao =& DAORegistry::getDAO('SectionEditorSubmissionDAO');
375  $sectionEditorSubmissionDao->deleteDecisionsByArticle($articleId);
376  $sectionEditorSubmissionDao->deleteReviewRoundsByArticle($articleId);
377 
378  $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
379  $reviewAssignmentDao->deleteBySubmissionId($articleId);
380 
381  $editAssignmentDao =& DAORegistry::getDAO('EditAssignmentDAO');
382  $editAssignmentDao->deleteEditAssignmentsByArticle($articleId);
383 
384  // Delete copyedit, layout, and proofread signoffs
385  $signoffDao =& DAORegistry::getDAO('SignoffDAO');
386  $copyedInitialSignoffs = $signoffDao->getBySymbolic('SIGNOFF_COPYEDITING_INITIAL', ASSOC_TYPE_ARTICLE, $articleId);
387  $copyedAuthorSignoffs = $signoffDao->getBySymbolic('SIGNOFF_COPYEDITING_AUTHOR', ASSOC_TYPE_ARTICLE, $articleId);
388  $copyedFinalSignoffs = $signoffDao->getBySymbolic('SIGNOFF_COPYEDITING_FINAL', ASSOC_TYPE_ARTICLE, $articleId);
389  $layoutSignoffs = $signoffDao->getBySymbolic('SIGNOFF_LAYOUT', ASSOC_TYPE_ARTICLE, $articleId);
390  $proofreadAuthorSignoffs = $signoffDao->getBySymbolic('SIGNOFF_PROOFREADING_AUTHOR', ASSOC_TYPE_ARTICLE, $articleId);
391  $proofreadProofreaderSignoffs = $signoffDao->getBySymbolic('SIGNOFF_PROOFREADING_PROOFREADER', ASSOC_TYPE_ARTICLE, $articleId);
392  $proofreadLayoutSignoffs = $signoffDao->getBySymbolic('SIGNOFF_PROOFREADING_LAYOUT', ASSOC_TYPE_ARTICLE, $articleId);
393  $signoffs = array($copyedInitialSignoffs, $copyedAuthorSignoffs, $copyedFinalSignoffs, $layoutSignoffs,
394  $proofreadAuthorSignoffs, $proofreadProofreaderSignoffs, $proofreadLayoutSignoffs);
395  foreach ($signoffs as $signoff) {
396  if ( $signoff ) $signoffDao->deleteObject($signoff);
397  }
398 
399  $articleCommentDao =& DAORegistry::getDAO('ArticleCommentDAO');
400  $articleCommentDao->deleteArticleComments($articleId);
401 
402  $articleGalleyDao =& DAORegistry::getDAO('ArticleGalleyDAO');
403  $articleGalleyDao->deleteGalleysByArticle($articleId);
404 
405  $articleSearchDao =& DAORegistry::getDAO('ArticleSearchDAO');
406  $articleSearchDao->deleteArticleKeywords($articleId);
407 
408  $articleEventLogDao =& DAORegistry::getDAO('ArticleEventLogDAO');
409  $articleEventLogDao->deleteByAssoc(ASSOC_TYPE_ARTICLE, $articleId);
410 
411  $articleEmailLogDao =& DAORegistry::getDAO('ArticleEmailLogDAO');
412  $articleEmailLogDao->deleteByAssoc(ASSOC_TYPE_ARTICLE, $articleId);
413 
414  $notificationDao =& DAORegistry::getDAO('NotificationDAO');
415  $notificationDao->deleteByAssoc(ASSOC_TYPE_ARTICLE, $articleId);
416 
417  $suppFileDao =& DAORegistry::getDAO('SuppFileDAO');
418  $suppFileDao->deleteSuppFilesByArticle($articleId);
419 
420  // Delete article files -- first from the filesystem, then from the database
421  import('classes.file.ArticleFileManager');
422  $articleFileDao =& DAORegistry::getDAO('ArticleFileDAO');
423  $articleFiles =& $articleFileDao->getArticleFilesByArticle($articleId);
424 
425  $articleFileManager = new ArticleFileManager($articleId);
426  foreach ($articleFiles as $articleFile) {
427  $articleFileManager->deleteFile($articleFile->getFileId());
428  }
429 
430  $articleFileDao->deleteArticleFiles($articleId);
431 
432  // Delete article citations.
433  $citationDao =& DAORegistry::getDAO('CitationDAO');
434  $citationDao->deleteObjectsByAssocId(ASSOC_TYPE_ARTICLE, $articleId);
435 
436  $this->update('DELETE FROM article_settings WHERE article_id = ?', $articleId);
437  $this->update('DELETE FROM articles WHERE article_id = ?', $articleId);
438 
439  import('classes.search.ArticleSearchIndex');
440  $articleSearchIndex = new ArticleSearchIndex();
441  $articleSearchIndex->articleDeleted($articleId);
442  $articleSearchIndex->articleChangesFinished();
443 
444  $this->flushCache();
445  }
446 
452  function &getArticlesByJournalId($journalId = null) {
453  $primaryLocale = AppLocale::getPrimaryLocale();
454  $locale = AppLocale::getLocale();
455 
456  $params = array(
457  'title',
458  $primaryLocale,
459  'title',
460  $locale,
461  'abbrev',
462  $primaryLocale,
463  'abbrev',
464  $locale
465  );
466  if ($journalId !== null) $params[] = (int) $journalId;
467 
468  $result =& $this->retrieve(
469  'SELECT a.*,
470  COALESCE(stl.setting_value, stpl.setting_value) AS section_title,
471  COALESCE(sal.setting_value, sapl.setting_value) AS section_abbrev
472  FROM articles a
473  LEFT JOIN sections s ON s.section_id = a.section_id
474  LEFT JOIN section_settings stpl ON (s.section_id = stpl.section_id AND stpl.setting_name = ? AND stpl.locale = ?)
475  LEFT JOIN section_settings stl ON (s.section_id = stl.section_id AND stl.setting_name = ? AND stl.locale = ?)
476  LEFT JOIN section_settings sapl ON (s.section_id = sapl.section_id AND sapl.setting_name = ? AND sapl.locale = ?)
477  LEFT JOIN section_settings sal ON (s.section_id = sal.section_id AND sal.setting_name = ? AND sal.locale = ?)
478  ' . ($journalId !== null ? 'WHERE a.journal_id = ?' : ''),
479  $params
480  );
481 
482  $returner = new DAOResultFactory($result, $this, '_returnArticleFromRow');
483  return $returner;
484  }
485 
490  function deleteArticlesByJournalId($journalId) {
491  $articles = $this->getArticlesByJournalId($journalId);
492 
493  while (!$articles->eof()) {
494  $article =& $articles->next();
495  $this->deleteArticleById($article->getId());
496  }
497  }
498 
505  function &getArticlesByUserId($userId, $journalId = null) {
506  $primaryLocale = AppLocale::getPrimaryLocale();
507  $locale = AppLocale::getLocale();
508  $params = array(
509  'title',
510  $primaryLocale,
511  'title',
512  $locale,
513  'abbrev',
514  $primaryLocale,
515  'abbrev',
516  $locale,
517  $userId
518  );
519  if ($journalId) $params[] = $journalId;
520  $articles = array();
521 
522  $result =& $this->retrieve(
523  'SELECT a.*,
524  COALESCE(stl.setting_value, stpl.setting_value) AS section_title,
525  COALESCE(sal.setting_value, sapl.setting_value) AS section_abbrev
526  FROM articles a
527  LEFT JOIN sections s ON s.section_id = a.section_id
528  LEFT JOIN section_settings stpl ON (s.section_id = stpl.section_id AND stpl.setting_name = ? AND stpl.locale = ?)
529  LEFT JOIN section_settings stl ON (s.section_id = stl.section_id AND stl.setting_name = ? AND stl.locale = ?)
530  LEFT JOIN section_settings sapl ON (s.section_id = sapl.section_id AND sapl.setting_name = ? AND sapl.locale = ?)
531  LEFT JOIN section_settings sal ON (s.section_id = sal.section_id AND sal.setting_name = ? AND sal.locale = ?)
532  WHERE a.user_id = ?' .
533  (isset($journalId)?' AND a.journal_id = ?':''),
534  $params
535  );
536 
537  while (!$result->EOF) {
538  $articles[] =& $this->_returnArticleFromRow($result->GetRowAssoc(false));
539  $result->MoveNext();
540  }
541 
542  $result->Close();
543  unset($result);
544 
545  return $articles;
546  }
547 
553  function getArticleJournalId($articleId) {
554  $result =& $this->retrieve(
555  'SELECT journal_id FROM articles WHERE article_id = ?', $articleId
556  );
557  $returner = isset($result->fields[0]) ? $result->fields[0] : false;
558 
559  $result->Close();
560  unset($result);
561 
562  return $returner;
563  }
564 
572  function incompleteSubmissionExists($articleId, $userId, $journalId) {
573  $result =& $this->retrieve(
574  'SELECT submission_progress FROM articles WHERE article_id = ? AND user_id = ? AND journal_id = ? AND date_submitted IS NULL',
575  array($articleId, $userId, $journalId)
576  );
577  $returner = isset($result->fields[0]) ? $result->fields[0] : false;
578 
579  $result->Close();
580  unset($result);
581 
582  return $returner;
583  }
584 
590  function changeArticleStatus($articleId, $status) {
591  $this->update(
592  'UPDATE articles SET status = ? WHERE article_id = ?', array((int) $status, (int) $articleId)
593  );
594 
595  $this->flushCache();
596  }
597 
606  function updateSetting($articleId, $name, $value, $type, $isLocalized = false) {
607  // Check and prepare setting data.
608  if ($isLocalized) {
609  if (is_array($value)) {
610  $values =& $value;
611  } else {
612  // We expect localized data to come in as an array.
613  assert(false);
614  return;
615  }
616  } else {
617  // Normalize non-localized data to an array so that
618  // we can treat updates uniformly.
619  $values = array('' => $value);
620  }
621  unset($value);
622 
623  // Update setting values.
624  $keyFields = array('setting_name', 'locale', 'article_id');
625  foreach ($values as $locale => $value) {
626  // Locale-specific entries will be deleted when no value exists.
627  // Non-localized settings will always be set.
628  if ($isLocalized) {
629  $this->update(
630  'DELETE FROM article_settings WHERE article_id = ? AND setting_name = ? AND locale = ?',
631  array($articleId, $name, $locale)
632  );
633  if (empty($value)) continue;
634  }
635 
636  // Convert the new value to the correct type.
637  $value = $this->convertToDB($value, $type);
638 
639  // Update the database.
640  $this->replace('article_settings',
641  array(
642  'article_id' => $articleId,
643  'setting_name' => $name,
644  'setting_value' => $value,
645  'setting_type' => $type,
646  'locale' => $locale
647  ),
648  $keyFields
649  );
650  }
651  $this->flushCache();
652  }
653 
662  function changePubId($articleId, $pubIdType, $pubId) {
663  $this->updateSetting($articleId, 'pub-id::'.$pubIdType, $pubId, 'string');
664  }
665 
677  function pubIdExists($pubIdType, $pubId, $articleId, $journalId) {
678  $result =& $this->retrieve(
679  'SELECT COUNT(*)
680  FROM article_settings ast
681  INNER JOIN articles a ON ast.article_id = a.article_id
682  WHERE ast.setting_name = ? and ast.setting_value = ? and ast.article_id <> ? AND a.journal_id = ?',
683  array(
684  'pub-id::'.$pubIdType,
685  $pubId,
686  (int) $articleId,
687  (int) $journalId
688  )
689  );
690  $returner = $result->fields[0] ? true : false;
691  $result->Close();
692  return $returner;
693  }
694 
699  function removeArticlesFromSection($sectionId) {
700  $this->update(
701  'UPDATE articles SET section_id = null WHERE section_id = ?', $sectionId
702  );
703 
704  $this->flushCache();
705  }
706 
711  function resetPermissions($journalId) {
712  $journalId = (int) $journalId;
713  $articles =& $this->getArticlesByJournalId($journalId);
714  while ($article =& $articles->next()) {
715  $this->update(
716  'DELETE FROM article_settings WHERE (setting_name = ? OR setting_name = ? OR setting_name = ?) AND article_id = ?',
717  array(
718  'licenseURL',
719  'copyrightHolder',
720  'copyrightYear',
721  (int) $article->getId()
722  )
723  );
724  $article = $this->getArticle($article->getId());
725  $article->initializePermissions();
726  $this->updateLocaleFields($article);
727  unset($article);
728  }
729  $this->flushCache();
730  }
731 
739  function deleteAllPubIds($journalId, $pubIdType) {
740  $journalId = (int) $journalId;
741  $settingName = 'pub-id::'.$pubIdType;
742 
743  $articles =& $this->getArticlesByJournalId($journalId);
744  while ($article =& $articles->next()) {
745  $this->update(
746  'DELETE FROM article_settings WHERE setting_name = ? AND article_id = ?',
747  array(
748  $settingName,
749  (int)$article->getId()
750  )
751  );
752  unset($article);
753  }
754  $this->flushCache();
755  }
756 
764  function deletePubId($articleId, $pubIdType) {
765  $settingName = 'pub-id::'.$pubIdType;
766  $this->update(
767  'DELETE FROM article_settings WHERE setting_name = ? AND article_id = ?',
768  array(
769  $settingName,
770  (int)$articleId
771  )
772  );
773  $this->flushCache();
774  }
775 
780  function getInsertArticleId() {
781  return $this->getInsertId('articles', 'article_id');
782  }
783 
784  function flushCache() {
785  // Because both publishedArticles and articles are cached by
786  // article ID, flush both caches on update.
787  $cache =& $this->_getCache();
788  $cache->flush();
789  unset($cache);
790 
791  $publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO');
792  $cache =& $publishedArticleDao->_getPublishedArticleCache();
793  $cache->flush();
794  unset($cache);
795  }
796 }
797 
798 ?>
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
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
resetPermissions($journalId)
Operations for retrieving and modifying Article objects.
deleteAllPubIds($journalId, $pubIdType)
datetimeToDB($dt)
Definition: DAO.inc.php:296
deletePubId($articleId, $pubIdType)
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()