/
Article.inc.php
871 lines (772 loc) · 23.9 KB
/
Article.inc.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
<?php
/**
* @defgroup article
*/
/**
* @file classes/article/Article.inc.php
*
* Copyright (c) 2013-2019 Simon Fraser University
* Copyright (c) 2003-2019 John Willinsky
* Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
*
* @class Article
* @ingroup article
* @see ArticleDAO
*
* @brief Article class.
*/
// Submission status constants
define('STATUS_ARCHIVED', 0);
define('STATUS_QUEUED', 1);
// define('STATUS_SCHEDULED', 2); // #2187: Scheduling queue removed.
define('STATUS_PUBLISHED', 3);
define('STATUS_DECLINED', 4);
// AuthorSubmission::getSubmissionStatus will return one of these in place of QUEUED:
define ('STATUS_QUEUED_UNASSIGNED', 5);
define ('STATUS_QUEUED_REVIEW', 6);
define ('STATUS_QUEUED_EDITING', 7);
define ('STATUS_INCOMPLETE', 8);
// Author display in ToC
define ('AUTHOR_TOC_DEFAULT', 0);
define ('AUTHOR_TOC_HIDE', 1);
define ('AUTHOR_TOC_SHOW', 2);
// Article RT comments
define ('COMMENTS_SECTION_DEFAULT', 0);
define ('COMMENTS_DISABLE', 1);
define ('COMMENTS_ENABLE', 2);
// License settings (internal use only)
define ('PERMISSIONS_FIELD_LICENSE_URL', 1);
define ('PERMISSIONS_FIELD_COPYRIGHT_HOLDER', 2);
define ('PERMISSIONS_FIELD_COPYRIGHT_YEAR', 3);
import('lib.pkp.classes.submission.Submission');
class Article extends Submission {
/**
* Constructor.
*/
function Article() {
// Switch on meta-data adapter support.
$this->setHasLoadableAdapters(true);
parent::Submission();
}
/**
* @see Submission::getAssocType()
*/
function getAssocType() {
return ASSOC_TYPE_ARTICLE;
}
/**
* Get "localized" article title (if applicable). DEPRECATED
* in favour of getLocalizedTitle.
* @return string
*/
function getArticleTitle() {
if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
return $this->getLocalizedTitle();
}
/**
* Get "localized" article abstract (if applicable). DEPRECATED
* in favour of getLocalizedAbstract.
* @return string
*/
function getArticleAbstract() {
if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
return $this->getLocalizedAbstract();
}
//
// Get/set methods
//
/**
* Get ID of article. DEPRECATED in favor of getId()
* @return int
*/
function getArticleId() {
if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
return $this->getId();
}
/**
* Set ID of article. DEPRECATED in favor of setId($id)
* @param $articleId int
*/
function setArticleId($articleId) {
if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
return $this->setId($articleId);
}
/**
* Return the "best" article ID -- If a public article ID is set,
* use it; otherwise use the internal article Id. (Checks the journal
* settings to ensure that the public ID feature is enabled.)
* @param $journal Object the journal this article is in
* @return string
*/
function getBestArticleId($journal = null) {
// Retrieve the journal, if necessary.
if (!isset($journal)) {
$journalDao =& DAORegistry::getDAO('JournalDAO');
$journal = $journalDao->getById($this->getJournalId());
}
if ($journal->getSetting('enablePublicArticleId')) {
$publicArticleId = $this->getPubId('publisher-id');
if (!empty($publicArticleId)) return $publicArticleId;
}
return $this->getId();
}
/**
* Get the localized copyright holder for this article.
*/
function getLocalizedCopyrightHolder($preferredLocale = null) {
return $this->getLocalizedData('copyrightHolder', $preferredLocale);
}
/**
* Get the license URL for this article.
*/
function getDefaultLicenseUrl() {
return $this->_getDefaultLicenseFieldValue(null, PERMISSIONS_FIELD_LICENSE_URL);
}
/**
* Get the copyright holder for this article.
* @param $locale string Locale
*/
function getDefaultCopyrightHolder($locale) {
return $this->_getDefaultLicenseFieldValue($locale, PERMISSIONS_FIELD_COPYRIGHT_HOLDER);
}
/**
* Get the copyright year for this article.
*/
function getDefaultCopyrightYear() {
return $this->_getDefaultLicenseFieldValue(null, PERMISSIONS_FIELD_COPYRIGHT_YEAR);
}
/**
* Get the best guess license field for this article.
* Return the existing value if the field is already set,
* otherwise calculate a best value based on the Journal Settings.
* @param $locale string Locale
* @param $field int PERMISSIONS_FIELD_... Which to return
*/
function _getDefaultLicenseFieldValue($locale, $field) {
// If already set, use the stored permissions info
switch ($field) {
case PERMISSIONS_FIELD_LICENSE_URL:
$fieldValue = $this->getLicenseURL();
break;
case PERMISSIONS_FIELD_COPYRIGHT_HOLDER:
$fieldValue = $this->getCopyrightHolder($locale);
break;
case PERMISSIONS_FIELD_COPYRIGHT_YEAR:
$fieldValue = $this->getCopyrightYear();
break;
default: assert(false);
}
if (!empty($fieldValue)) {
if ($locale === null || !is_array($fieldValue)) return $fieldValue;
if (isset($fieldValue[$locale])) return $fieldValue[$locale];
}
// Otherwise, get the permissions info from journal settings.
$journalDao = DAORegistry::getDAO('JournalDAO');
$journal =& $journalDao->getById($this->getJournalId());
switch ($field) {
case PERMISSIONS_FIELD_LICENSE_URL:
$licenseUrl = $journal->getSetting('licenseURL');
break;
case PERMISSIONS_FIELD_COPYRIGHT_HOLDER:
switch($journal->getSetting('copyrightHolderType')) {
case 'author':
$copyrightHolder = array($journal->getPrimaryLocale() => $this->getAuthorString());
break;
case 'other':
$copyrightHolder = $journal->getSetting('copyrightHolderOther');
break;
case 'journal':
default:
$copyrightHolder = $journal->getTitle(null);
break;
}
break;
case PERMISSIONS_FIELD_COPYRIGHT_YEAR:
// Default copyright year to current year
$copyrightYear = date('Y');
// Override based on journal settings
$publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO');
$publishedArticle = $publishedArticleDao->getPublishedArticleByArticleId($this->getId());
if ($publishedArticle) {
switch($journal->getSetting('copyrightYearBasis')) {
case 'article':
// override to the article's year if published as you go
$copyrightYear = date('Y', strtotime($publishedArticle->getDatePublished()));
break;
case 'issue':
if ($publishedArticle->getIssueId()) {
// override to the issue's year if published as issue-based
$issueDao =& DAORegistry::getDAO('IssueDAO');
$issue = $issueDao->getIssueByArticleId($this->getId());
if ($issue && $issue->getDatePublished()) {
$copyrightYear = date('Y', strtotime($issue->getDatePublished()));
}
}
break;
default: assert(false);
}
}
break;
default: assert(false);
}
switch ($field) {
case PERMISSIONS_FIELD_LICENSE_URL:
$fieldValue = $licenseUrl;
break;
case PERMISSIONS_FIELD_COPYRIGHT_HOLDER:
$fieldValue = $copyrightHolder;
break;
case PERMISSIONS_FIELD_COPYRIGHT_YEAR:
$fieldValue = $copyrightYear;
break;
default: assert(false);
}
// Return the fetched license field
if ($locale === null || !is_array($fieldValue)) return $fieldValue;
if (isset($fieldValue[$locale])) return $fieldValue[$locale];
return null;
}
/**
* Get a public ID for this article.
* @param $pubIdType string One of the NLM pub-id-type values or
* 'other::something' if not part of the official NLM list
* (see <http://dtd.nlm.nih.gov/publishing/tag-library/n-4zh0.html>).
* @var $preview boolean If true, generate a non-persisted preview only.
*/
function getPubId($pubIdType, $preview = false) {
// FIXME: Move publisher-id to PID plug-in.
if ($pubIdType === 'publisher-id') {
$pubId = $this->getStoredPubId($pubIdType);
return ($pubId ? $pubId : null);
}
$pubIdPlugins =& PluginRegistry::loadCategory('pubIds', true, $this->getJournalId());
if (is_array($pubIdPlugins)) {
foreach ($pubIdPlugins as $pubIdPlugin) {
if ($pubIdPlugin->getPubIdType() == $pubIdType) {
// If we already have an assigned ID, use it.
$storedId = $this->getStoredPubId($pubIdType);
if (!empty($storedId)) return $storedId;
return $pubIdPlugin->getPubId($this, $preview);
}
}
}
return null;
}
/**
* Get ID of journal.
* @return int
*/
function getJournalId() {
return $this->getData('journalId');
}
/**
* Set ID of journal.
* @param $journalId int
*/
function setJournalId($journalId) {
return $this->setData('journalId', $journalId);
}
/**
* Get ID of article's section.
* @return int
*/
function getSectionId() {
return $this->getData('sectionId');
}
/**
* Set ID of article's section.
* @param $sectionId int
*/
function setSectionId($sectionId) {
return $this->setData('sectionId', $sectionId);
}
/**
* Get stored public ID of the submission.
* @param $pubIdType string One of the NLM pub-id-type values or
* 'other::something' if not part of the official NLM list
* (see <http://dtd.nlm.nih.gov/publishing/tag-library/n-4zh0.html>).
* @return int
*/
function getStoredPubId($pubIdType) {
return $this->getData('pub-id::'.$pubIdType);
}
/**
* Set the stored public ID of the submission.
* @param $pubIdType string One of the NLM pub-id-type values or
* 'other::something' if not part of the official NLM list
* (see <http://dtd.nlm.nih.gov/publishing/tag-library/n-4zh0.html>).
* @param $pubId string
*/
function setStoredPubId($pubIdType, $pubId) {
return $this->setData('pub-id::'.$pubIdType, $pubId);
}
/**
* Get stored copyright holder for the submission.
* @param $locale string locale
* @return string
*/
function getCopyrightHolder($locale) {
return $this->getData('copyrightHolder', $locale);
}
/**
* Set the stored copyright holder for the submission.
* @param $copyrightHolder string Copyright holder
* @param $locale string locale
*/
function setCopyrightHolder($copyrightHolder, $locale) {
return $this->setData('copyrightHolder', $copyrightHolder, $locale);
}
/**
* Get stored copyright year for the submission.
* @return string
*/
function getCopyrightYear() {
return $this->getData('copyrightYear');
}
/**
* Set the stored copyright year for the submission.
* @param $copyrightYear string Copyright holder
*/
function setCopyrightYear($copyrightYear) {
return $this->setData('copyrightYear', $copyrightYear);
}
/**
* Get stored license URL for the submission content.
* @return string
*/
function getLicenseURL() {
return $this->getData('licenseURL');
}
/**
* Set the stored license URL for the submission content.
* @param $license string License of submission content
*/
function setLicenseURL($licenseUrl) {
return $this->setData('licenseURL', $licenseUrl);
}
/**
* Get title of article's section.
* @return string
*/
function getSectionTitle() {
return $this->getData('sectionTitle');
}
/**
* Set title of article's section.
* @param $sectionTitle string
*/
function setSectionTitle($sectionTitle) {
return $this->setData('sectionTitle', $sectionTitle);
}
/**
* Get section abbreviation.
* @return string
*/
function getSectionAbbrev() {
return $this->getData('sectionAbbrev');
}
/**
* Set section abbreviation.
* @param $sectionAbbrev string
*/
function setSectionAbbrev($sectionAbbrev) {
return $this->setData('sectionAbbrev', $sectionAbbrev);
}
/**
* Return the localized discipline. DEPRECATED in favour of
* getLocalizedDiscipline.
* @return string
*/
function getArticleDiscipline() {
if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
return $this->getLocalizedDiscipline();
}
/**
* Return the localized subject classification. DEPRECATED
* in favour of getLocalizedSubjectClass.
* @return string
*/
function getArticleSubjectClass() {
if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
return $this->getLocalizedSubjectClass();
}
/**
* Return the localized subject. DEPRECATED in favour of
* getLocalizedSubject.
* @return string
*/
function getArticleSubject() {
if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
return $this->getLocalizedSubject();
}
/**
* Return the localized geographical coverage. DEPRECATED
* in favour of getLocalizedCoverageGeo.
* @return string
*/
function getArticleCoverageGeo() {
if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
return $this->getLocalizedCoverageGeo();
}
/**
* Return the localized chronological coverage. DEPRECATED
* in favour of getLocalizedCoverageChron.
* @return string
*/
function getArticleCoverageChron() {
if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
return $this->getLocalizedCoverageChron();
}
/**
* Return the localized sample coverage. DEPRECATED in favour
* of getLocalizedCoverageSample.
* @return string
*/
function getArticleCoverageSample() {
if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
return $this->getLocalizedCoverageSample();
}
/**
* Return the localized type (method/approach). DEPRECATED
* in favour of getLocalizedType.
* @return string
*/
function getArticleType() {
if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
return $this->getLocalizedType();
}
/**
* Return the localized sponsor. DEPRECATED in favour
* of getLocalizedSponsor.
* @return string
*/
function getArticleSponsor() {
if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
return $this->getLocalizedSponsor();
}
/**
* Get the localized article cover filename. DEPRECATED
* in favour of getLocalizedFileName.
* @return string
*/
function getArticleFileName() {
if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
return $this->getLocalizedFileName('fileName');
}
/**
* Get the localized article cover width. DEPRECATED
* in favour of getLocalizedWidth.
* @return string
*/
function getArticleWidth() {
if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
return $this->getLocalizedWidth();
}
/**
* Get the localized article cover height. DEPRECATED
* in favour of getLocalizedHeight.
* @return string
*/
function getArticleHeight() {
if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
return $this->getLocalizedHeight();
}
/**
* Get the localized article cover filename on the uploader's computer.
* DEPRECATED in favour of getLocalizedOriginalFileName.
* @return string
*/
function getArticleOriginalFileName() {
if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
return $this->getLocalizedData('originalFileName');
}
/**
* Get the localized article cover alternate text. DEPRECATED
* in favour of getLocalizedCoverPageAltText.
* @return string
*/
function getArticleCoverPageAltText() {
if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
return $this->getLocalizedCoverPageAltText();
}
/**
* Get the flag indicating whether or not to show
* an article cover page. DEPRECATED in favour of
* getLocalizedShowCoverPage.
* @return string
*/
function getArticleShowCoverPage() {
if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
return $this->getLocalizedShowCoverPage();
}
/**
* Get comments to editor.
* @return string
*/
function getCommentsToEditor() {
return $this->getData('commentsToEditor');
}
/**
* Set comments to editor.
* @param $commentsToEditor string
*/
function setCommentsToEditor($commentsToEditor) {
return $this->setData('commentsToEditor', $commentsToEditor);
}
/**
* Get current review round.
* @return int
*/
function getCurrentRound() {
return $this->getData('currentRound');
}
/**
* Set current review round.
* @param $currentRound int
*/
function setCurrentRound($currentRound) {
return $this->setData('currentRound', $currentRound);
}
/**
* Get editor file id.
* @return int
*/
function getEditorFileId() {
return $this->getData('editorFileId');
}
/**
* Set editor file id.
* @param $editorFileId int
*/
function setEditorFileId($editorFileId) {
return $this->setData('editorFileId', $editorFileId);
}
/**
* get expedited
* @return boolean
*/
function getFastTracked() {
return $this->getData('fastTracked');
}
/**
* set fastTracked
* @param $fastTracked boolean
*/
function setFastTracked($fastTracked) {
return $this->setData('fastTracked',$fastTracked);
}
/**
* Return option selection indicating if author should be hidden in issue ToC.
* @return int AUTHOR_TOC_...
*/
function getHideAuthor() {
return $this->getData('hideAuthor');
}
/**
* Set option selection indicating if author should be hidden in issue ToC.
* @param $hideAuthor int AUTHOR_TOC_...
*/
function setHideAuthor($hideAuthor) {
return $this->setData('hideAuthor', $hideAuthor);
}
/**
* Return locale string corresponding to RT comments status.
* @return string
*/
function getCommentsStatusString() {
switch ($this->getCommentsStatus()) {
case COMMENTS_DISABLE:
return 'article.comments.disable';
case COMMENTS_ENABLE:
return 'article.comments.enable';
default:
return 'article.comments.sectionDefault';
}
}
/**
* Return boolean indicating if article RT comments should be enabled.
* Checks both the section and article comments status. Article status
* overrides section status.
* @return int
*/
function getEnableComments() {
switch ($this->getCommentsStatus()) {
case COMMENTS_DISABLE:
return false;
case COMMENTS_ENABLE:
return true;
case COMMENTS_SECTION_DEFAULT:
$sectionDao =& DAORegistry::getDAO('SectionDAO');
$section =& $sectionDao->getSection($this->getSectionId(), $this->getJournalId(), true);
if (!$section || $section->getDisableComments()) {
return false;
} else {
return true;
}
}
}
/**
* Get an associative array matching RT comments status codes with locale strings.
* @return array comments status => localeString
*/
function &getCommentsStatusOptions() {
static $commentsStatusOptions = array(
COMMENTS_SECTION_DEFAULT => 'article.comments.sectionDefault',
COMMENTS_DISABLE => 'article.comments.disable',
COMMENTS_ENABLE => 'article.comments.enable'
);
return $commentsStatusOptions;
}
/**
* Get an array of user IDs associated with this article
* @param $authors boolean
* @param $reviewers boolean
* @param $editors boolean
* @param $proofreader boolean
* @param $copyeditor boolean
* @param $layoutEditor boolean
* @return array User IDs
*/
function getAssociatedUserIds($authors = true, $reviewers = true, $editors = true, $proofreader = true, $copyeditor = true, $layoutEditor = true) {
$articleId = $this->getId();
$signoffDao =& DAORegistry::getDAO('SignoffDAO');
$userIds = array();
if($authors) {
$userId = $this->getUserId();
if ($userId) $userIds[] = array('id' => $userId, 'role' => 'author');
}
if($editors) {
$editAssignmentDao =& DAORegistry::getDAO('EditAssignmentDAO');
$editAssignments =& $editAssignmentDao->getEditorAssignmentsByArticleId($articleId);
while ($editAssignment =& $editAssignments->next()) {
$userId = $editAssignment->getEditorId();
if ($userId) $userIds[] = array('id' => $userId, 'role' => 'editor');
unset($editAssignment);
}
}
if($copyeditor) {
$copyedSignoff = $signoffDao->build('SIGNOFF_COPYEDITING_INITIAL', ASSOC_TYPE_ARTICLE, $articleId);
$userId = $copyedSignoff->getUserId();
if ($userId) $userIds[] = array('id' => $userId, 'role' => 'copyeditor');
}
if($layoutEditor) {
$layoutSignoff = $signoffDao->build('SIGNOFF_LAYOUT', ASSOC_TYPE_ARTICLE, $articleId);
$userId = $layoutSignoff->getUserId();
if ($userId) $userIds[] = array('id' => $userId, 'role' => 'layoutEditor');
}
if($proofreader) {
$proofSignoff = $signoffDao->build('SIGNOFF_PROOFREADING_PROOFREADER', ASSOC_TYPE_ARTICLE, $articleId);
$userId = $proofSignoff->getUserId();
if ($userId) $userIds[] = array('id' => $userId, 'role' => 'proofreader');
}
if($reviewers) {
$reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
$reviewAssignments =& $reviewAssignmentDao->getBySubmissionId($articleId);
foreach ($reviewAssignments as $reviewAssignment) {
$userId = $reviewAssignment->getReviewerId();
if ($userId) $userIds[] = array('id' => $userId, 'role' => 'reviewer');
unset($reviewAssignment);
}
}
return $userIds;
}
/**
* Get the signoff for this article
* @param $signoffType string
* @return Signoff
*/
function getSignoff($signoffType) {
$signoffDao =& DAORegistry::getDAO('SignoffDAO');
return $signoffDao->build($signoffType, ASSOC_TYPE_ARTICLE, $this->getId());
}
/**
* Get the file for this article at a given signoff stage
* @param $signoffType string
* @param $idOnly boolean Return only file ID
* @return ArticleFile
*/
function &getFileBySignoffType($signoffType, $idOnly = false) {
$articleFileDao =& DAORegistry::getDAO('ArticleFileDAO');
$signoffDao =& DAORegistry::getDAO('SignoffDAO');
$signoff = $signoffDao->build($signoffType, ASSOC_TYPE_ARTICLE, $this->getId());
if (!$signoff) {
$returner = false;
return $returner;
}
if ($idOnly) {
$returner = $signoff->getFileId();
return $returner;
}
$articleFile =& $articleFileDao->getArticleFile($signoff->getFileId(), $signoff->getFileRevision());
return $articleFile;
}
/**
* Get the user associated with a given signoff and this article
* @param $signoffType string
* @return User
*/
function &getUserBySignoffType($signoffType) {
$signoffDao =& DAORegistry::getDAO('SignoffDAO');
$userDao =& DAORegistry::getDAO('UserDAO');
$signoff = $signoffDao->build($signoffType, ASSOC_TYPE_ARTICLE, $this->getId());
if (!$signoff) {
$returner = false;
return $returner;
}
$user =& $userDao->getById($signoff->getUserId());
return $user;
}
/**
* Get the user id associated with a given signoff and this article
* @param $signoffType string
* @return int
*/
function getUserIdBySignoffType($signoffType) {
$signoffDao =& DAORegistry::getDAO('SignoffDAO');
$signoff = $signoffDao->build($signoffType, ASSOC_TYPE_ARTICLE, $this->getId());
if (!$signoff) return false;
return $signoff->getUserId();
}
/**
* Get starting page of an article.
* @return int
*/
function getStartingPage() {
preg_match('/^[^\d]*(\d+)\D*(.*)$/', $this->getPages(), $pages);
return $pages[1];
}
/**
* Get ending page of an article.
* @return int
*/
function getEndingPage() {
preg_match('/^[^\d]*(\d+)\D*(.*)$/', $this->getPages(), $pages);
return $pages[2];
}
/**
* Initialize the copyright and license metadata for an article.
* This should be called at creation and at publication, to setup license/copyright holder and copyright year, respectively.
* This depends on the permissions configuration in Journal Setup, and (potentially) on the authors of a article being populated.
* Only initializes empty fields because of the getDefault...() behaviour, so subsequent calls are safe.
*/
function initializePermissions() {
$this->setLicenseURL($this->getDefaultLicenseURL());
$this->setCopyrightHolder($this->getDefaultCopyrightHolder(null), null);
if ($this->getStatus() == STATUS_PUBLISHED) {
$this->setCopyrightYear($this->getDefaultCopyrightYear());
}
}
/**
* Determines whether or not the license for copyright on this Article is
* a Creative Commons license or not.
* @return boolean
*/
function isCCLicense() {
if (preg_match('/creativecommons\.org/i', $this->getLicenseURL())) {
return true;
} else {
return false;
}
}
}
?>