Open Monograph Press  1.1
 All Classes Namespaces Functions Variables Groups Pages
Submission.inc.php
1 <?php
2 
25 // Submission status constants
26 define('STATUS_ARCHIVED', 0);
27 define('STATUS_QUEUED', 1);
28 define('STATUS_PUBLISHED', 3);
29 define('STATUS_DECLINED', 4);
30 
31 abstract class Submission extends DataObject {
35  function Submission() {
36  // Switch on meta-data adapter support.
37  $this->setHasLoadableAdapters(true);
38 
39  parent::DataObject();
40  }
41 
49  function getPubId($pubIdType, $preview = false) {
50  // FIXME: Move publisher-id to PID plug-in.
51  if ($pubIdType === 'publisher-id') {
52  $pubId = $this->getStoredPubId($pubIdType);
53  return ($pubId ? $pubId : null);
54  }
55 
56  $pubIdPlugins = PluginRegistry::loadCategory('pubIds', true, $this->getJournalId());
57 
58  if (is_array($pubIdPlugins)) {
59  foreach ($pubIdPlugins as $pubIdPlugin) {
60  if ($pubIdPlugin->getPubIdType() == $pubIdType) {
61  // If we already have an assigned ID, use it.
62  $storedId = $this->getStoredPubId($pubIdType);
63  if (!empty($storedId)) return $storedId;
64 
65  return $pubIdPlugin->getPubId($this, $preview);
66  }
67  }
68  }
69  return null;
70  }
71 
72 
73  //
74  // Getters / setters
75  //
76 
81  function getContextId() {
82  return $this->getData('contextId');
83  }
84 
89  function setContextId($contextId) {
90  return $this->setData('contextId', $contextId);
91  }
92 
100  function &getLocalizedData($key, $preferredLocale = null) {
101  if (is_null($preferredLocale)) $preferredLocale = AppLocale::getLocale();
102  $localePrecedence = array($preferredLocale, $this->getLocale());
103  foreach ($localePrecedence as $locale) {
104  if (empty($locale)) continue;
105  $value =& $this->getData($key, $locale);
106  if (!empty($value)) return $value;
107  unset($value);
108  }
109 
110  // Fallback: Get the first available piece of data.
111  $data =& $this->getData($key, null);
112  if (!empty($data)) {
113  $keys = array_keys($data);
114  return $data[array_shift($keys)];
115  }
116 
117  // No data available; return null.
118  unset($data);
119  $data = null;
120  return $data;
121  }
122 
130  function getStoredPubId($pubIdType) {
131  return $this->getData('pub-id::'.$pubIdType);
132  }
133 
141  function setStoredPubId($pubIdType, $pubId) {
142  return $this->setData('pub-id::'.$pubIdType, $pubId);
143  }
144 
149  function getCommentsToEditor() {
150  return $this->getData('commentsToEditor');
151  }
152 
157  function getHideAuthor() {
158  return $this->getData('hideAuthor');
159  }
160 
165  function setHideAuthor($hideAuthor) {
166  return $this->setData('hideAuthor', $hideAuthor);
167  }
168 
173  function setCommentsToEditor($commentsToEditor) {
174  return $this->setData('commentsToEditor', $commentsToEditor);
175  }
176 
182  function getFirstAuthor($lastOnly = false) {
183  $authors = $this->getAuthors();
184  if (is_array($authors) && !empty($authors)) {
185  $author = $authors[0];
186  return $lastOnly ? $author->getLastName() : $author->getFullName();
187  } else {
188  return null;
189  }
190  }
191 
199  function getAuthorString($lastOnly = false, $nameSeparator = ', ', $userGroupSeparator = '; ') {
200  $authors = $this->getAuthors();
201 
202  $str = '';
203  $lastUserGroupId = null;
204  $author = null;
205  $userGroupDao = DAORegistry::getDAO('UserGroupDAO');
206  foreach($authors as $author) {
207  if (!empty($str)) {
208  if ($lastUserGroupId != $author->getUserGroupId()) {
209  $userGroup = $userGroupDao->getById($lastUserGroupId);
210  if ($userGroup->getShowTitle()) $str .= ' (' . $userGroup->getLocalizedName() . ')';
211  $str .= $userGroupSeparator;
212  } else {
213  $str .= $nameSeparator;
214  }
215  }
216  $str .= $lastOnly ? $author->getLastName() : $author->getFullName();
217  $lastUserGroupId = $author->getUserGroupId();
218  }
219 
220  // If there needs to be a trailing user group title, add it
221  if ($author && $author->getShowTitle()) {
222  $userGroup = $userGroupDao->getById($author->getUserGroupId());
223  $str .= ' (' . $userGroup->getLocalizedName() . ')';
224  }
225 
226  return $str;
227  }
228 
233  function getAuthorEmails() {
234  $authors = $this->getAuthors();
235 
236  import('lib.pkp.classes.mail.Mail');
237  $returner = array();
238  foreach($authors as $author) {
239  $returner[] = Mail::encodeDisplayName($author->getFullName()) . ' <' . $author->getEmail() . '>';
240  }
241  return $returner;
242  }
243 
248  function getAuthors() {
249  $authorDao = DAORegistry::getDAO('AuthorDAO');
250  return $authorDao->getBySubmissionId($this->getId());
251  }
252 
257  function getPrimaryAuthor() {
258  $authorDao = DAORegistry::getDAO('AuthorDAO');
259  return $authorDao->getPrimaryContact($this->getId());
260  }
261 
266  function getUserId() {
267  return $this->getData('userId');
268  }
269 
274  function setUserId($userId) {
275  return $this->setData('userId', $userId);
276  }
277 
282  function getUser() {
283  $userDao = DAORegistry::getDAO('UserDAO');
284  return $userDao->getById($this->getUserId(), true);
285  }
286 
291  function getLocale() {
292  return $this->getData('locale');
293  }
294 
299  function setLocale($locale) {
300  return $this->setData('locale', $locale);
301  }
302 
308  function getLocalizedTitle($preferredLocale = null) {
309  return $this->getLocalizedData('title', $preferredLocale);
310  }
311 
317  function getTitle($locale) {
318  return $this->getData('title', $locale);
319  }
320 
326  function setTitle($title, $locale) {
327  $this->setCleanTitle($title, $locale);
328  return $this->setData('title', $title, $locale);
329  }
330 
336  function setCleanTitle($cleanTitle, $locale) {
337  $punctuation = array ('"', '\'', ',', '.', '!', '?', '-', '$', '(', ')');
338  $cleanTitle = str_replace($punctuation, '', $cleanTitle);
339  return $this->setData('cleanTitle', $cleanTitle, $locale);
340  }
341 
346  function getLocalizedSubtitle() {
347  return $this->getLocalizedData('subtitle');
348  }
349 
355  function getSubtitle($locale) {
356  return $this->getData('subtitle', $locale);
357  }
358 
364  function setSubtitle($subtitle, $locale) {
365  return $this->setData('subtitle', $subtitle, $locale);
366  }
367 
374  $fullTitle = null;
375  if ($prefix = $this->getLocalizedPrefix()) {
376  $fullTitle = $prefix . ' ';
377  }
378 
379  $fullTitle .= $this->getLocalizedTitle();
380 
381  if ($subtitle = $this->getLocalizedSubtitle()) {
382  $fullTitle = String::concatTitleFields(array($fullTitle, $subtitle));
383  }
384 
385  return $fullTitle;
386  }
387 
392  function getLocalizedPrefix() {
393  return $this->getLocalizedData('prefix');
394  }
395 
401  function getPrefix($locale) {
402  return $this->getData('prefix', $locale);
403  }
404 
410  function setPrefix($prefix, $locale) {
411  return $this->setData('prefix', $prefix, $locale);
412  }
413 
418  function getLocalizedAbstract() {
419  return $this->getLocalizedData('abstract');
420  }
421 
427  function getAbstract($locale) {
428  return $this->getData('abstract', $locale);
429  }
430 
436  function setAbstract($abstract, $locale) {
437  return $this->setData('abstract', $abstract, $locale);
438  }
439 
445  return $this->getLocalizedData('discipline');
446  }
447 
453  function getDiscipline($locale) {
454  return $this->getData('discipline', $locale);
455  }
456 
462  function setDiscipline($discipline, $locale) {
463  return $this->setData('discipline', $discipline, $locale);
464  }
465 
471  return $this->getLocalizedData('subjectClass');
472  }
473 
479  function getSubjectClass($locale) {
480  return $this->getData('subjectClass', $locale);
481  }
482 
488  function setSubjectClass($subjectClass, $locale) {
489  return $this->setData('subjectClass', $subjectClass, $locale);
490  }
491 
496  function getLocalizedSubject() {
497  return $this->getLocalizedData('subject');
498  }
499 
505  function getSubject($locale) {
506  return $this->getData('subject', $locale);
507  }
508 
514  function setSubject($subject, $locale) {
515  return $this->setData('subject', $subject, $locale);
516  }
517 
523  return $this->getLocalizedData('coverageGeo');
524  }
525 
531  function getCoverageGeo($locale) {
532  return $this->getData('coverageGeo', $locale);
533  }
534 
540  function setCoverageGeo($coverageGeo, $locale) {
541  return $this->setData('coverageGeo', $coverageGeo, $locale);
542  }
543 
549  return $this->getLocalizedData('coverageChron');
550  }
551 
557  function getCoverageChron($locale) {
558  return $this->getData('coverageChron', $locale);
559  }
560 
566  function setCoverageChron($coverageChron, $locale) {
567  return $this->setData('coverageChron', $coverageChron, $locale);
568  }
569 
575  return $this->getLocalizedData('coverageSample');
576  }
577 
583  function getCoverageSample($locale) {
584  return $this->getData('coverageSample', $locale);
585  }
586 
592  function setCoverageSample($coverageSample, $locale) {
593  return $this->setData('coverageSample', $coverageSample, $locale);
594  }
595 
600  function getLocalizedType() {
601  return $this->getLocalizedData('type');
602  }
603 
609  function getType($locale) {
610  return $this->getData('type', $locale);
611  }
612 
618  function setType($type, $locale) {
619  return $this->setData('type', $type, $locale);
620  }
621 
627  function getRights($locale) {
628  return $this->getData('rights', $locale);
629  }
630 
636  function setRights($rights, $locale) {
637  return $this->setData('rights', $rights, $locale);
638  }
639 
645  function getSource($locale) {
646  return $this->getData('source', $locale);
647  }
648 
654  function setSource($source, $locale) {
655  return $this->setData('source', $source, $locale);
656  }
657 
662  function getLanguage() {
663  return $this->getData('language');
664  }
665 
670  function setLanguage($language) {
671  return $this->setData('language', $language);
672  }
673 
678  function getLocalizedSponsor() {
679  return $this->getLocalizedData('sponsor');
680  }
681 
687  function getSponsor($locale) {
688  return $this->getData('sponsor', $locale);
689  }
690 
696  function setSponsor($sponsor, $locale) {
697  return $this->setData('sponsor', $sponsor, $locale);
698  }
699 
705  function getCopyrightNotice($locale) {
706  return $this->getData('copyrightNotice', $locale);
707  }
708 
714  function setCopyrightNotice($copyrightNotice, $locale) {
715  return $this->setData('copyrightNotice', $copyrightNotice, $locale);
716  }
717 
722  function getCitations() {
723  return $this->getData('citations');
724  }
725 
730  function setCitations($citations) {
731  return $this->setData('citations', $citations);
732  }
733 
738  function getLocalizedFileName() {
739  return $this->getLocalizedData('fileName');
740  }
741 
747  function getFileName($locale) {
748  return $this->getData('fileName', $locale);
749  }
750 
756  function setFileName($fileName, $locale) {
757  return $this->setData('fileName', $fileName, $locale);
758  }
759 
764  function getLocalizedWidth() {
765  return $this->getLocalizedData('width');
766  }
767 
773  function getWidth($locale) {
774  return $this->getData('width', $locale);
775  }
776 
782  function setWidth($width, $locale) {
783  return $this->setData('width', $width, $locale);
784  }
785 
790  function getLocalizedHeight() {
791  return $this->getLocalizedData('height');
792  }
793 
799  function getHeight($locale) {
800  return $this->getData('height', $locale);
801  }
802 
808  function setHeight($height, $locale) {
809  return $this->setData('height', $height, $locale);
810  }
811 
817  return $this->getLocalizedData('originalFileName');
818  }
819 
825  function getOriginalFileName($locale) {
826  return $this->getData('originalFileName', $locale);
827  }
828 
834  function setOriginalFileName($originalFileName, $locale) {
835  return $this->setData('originalFileName', $originalFileName, $locale);
836  }
837 
843  return $this->getLocalizedData('coverPageAltText');
844  }
845 
851  function getCoverPageAltText($locale) {
852  return $this->getData('coverPageAltText', $locale);
853  }
854 
860  function setCoverPageAltText($coverPageAltText, $locale) {
861  return $this->setData('coverPageAltText', $coverPageAltText, $locale);
862  }
863 
870  return $this->getLocalizedData('showCoverPage');
871  }
872 
878  function getShowCoverPage($locale) {
879  return $this->getData('showCoverPage', $locale);
880  }
881 
887  function setShowCoverPage($showCoverPage, $locale) {
888  return $this->setData('showCoverPage', $showCoverPage, $locale);
889  }
890 
896  function getHideCoverPageToc($locale) {
897  return $this->getData('hideCoverPageToc', $locale);
898  }
899 
905  function setHideCoverPageToc($hideCoverPageToc, $locale) {
906  return $this->setData('hideCoverPageToc', $hideCoverPageToc, $locale);
907  }
908 
914  function getHideCoverPageAbstract($locale) {
915  return $this->getData('hideCoverPageAbstract', $locale);
916  }
917 
923  function setHideCoverPageAbstract($hideCoverPageAbstract, $locale) {
924  return $this->setData('hideCoverPageAbstract', $hideCoverPageAbstract, $locale);
925  }
926 
931  return $this->getLocalizedData('hideCoverPageAbstract');
932  }
933 
938  function getDateSubmitted() {
939  return $this->getData('dateSubmitted');
940  }
941 
946  function setDateSubmitted($dateSubmitted) {
947  return $this->setData('dateSubmitted', $dateSubmitted);
948  }
949 
955  return $this->getData('dateStatusModified');
956  }
957 
962  function setDateStatusModified($dateModified) {
963  return $this->setData('dateStatusModified', $dateModified);
964  }
965 
970  function getLastModified() {
971  return $this->getData('lastModified');
972  }
973 
978  function setLastModified($dateModified) {
979  return $this->setData('lastModified', $dateModified);
980  }
981 
985  function stampModified() {
986  return $this->setLastModified(Core::getCurrentDate());
987  }
988 
992  function stampStatusModified() {
994  }
995 
1000  function getStatus() {
1001  return $this->getData('status');
1002  }
1003 
1008  function setStatus($status) {
1009  return $this->setData('status', $status);
1010  }
1011 
1016  function &getStatusMap() {
1017  static $statusMap;
1018  if (!isset($statusMap)) {
1019  $statusMap = array(
1020  STATUS_ARCHIVED => 'submissions.archived',
1021  STATUS_QUEUED => 'submissions.queued',
1022  STATUS_PUBLISHED => 'submissions.published',
1023  STATUS_DECLINED => 'submissions.declined',
1024  STATUS_INCOMPLETE => 'submissions.incomplete'
1025  );
1026  }
1027  return $statusMap;
1028  }
1029 
1034  function getStatusKey() {
1035  $statusMap =& $this->getStatusMap();
1036  return $statusMap[$this->getStatus()];
1037  }
1038 
1044  return $this->getData('submissionProgress');
1045  }
1046 
1051  function setSubmissionProgress($submissionProgress) {
1052  return $this->setData('submissionProgress', $submissionProgress);
1053  }
1054 
1059  function getPages() {
1060  return $this->getData('pages');
1061  }
1062 
1067  function setPages($pages) {
1068  return $this->setData('pages',$pages);
1069  }
1070 
1075  function getCommentsStatus() {
1076  return $this->getData('commentsStatus');
1077  }
1078 
1083  function setCommentsStatus($commentsStatus) {
1084  return $this->setData('commentsStatus', $commentsStatus);
1085  }
1086 
1091  function getStageId() {
1092  return $this->getData('stageId');
1093  }
1094 
1099  function setStageId($stageId) {
1100  return $this->setData('stageId', $stageId);
1101  }
1102 
1107  function getDatePublished() {
1108  return $this->getData('datePublished');
1109  }
1110 
1115  function setDatePublished($datePublished) {
1116  return $this->SetData('datePublished', $datePublished);
1117  }
1118 
1119 
1120  //
1121  // Abstract methods.
1122  //
1127  abstract function getSectionId();
1128 }
1129 
1130 ?>
getShowCoverPage($locale)
getLocalizedCoverPageAltText()
setCoverageSample($coverageSample, $locale)
getHideCoverPageAbstract($locale)
static & getDAO($name, $dbconn=null)
getLocalizedCoverageChron()
getFirstAuthor($lastOnly=false)
setHideAuthor($hideAuthor)
getLocalizedHideCoverPageAbstract()
getDiscipline($locale)
setAbstract($abstract, $locale)
setContextId($contextId)
setWidth($width, $locale)
setLastModified($dateModified)
setSponsor($sponsor, $locale)
getSource($locale)
getLocalizedSubjectClass()
setCommentsToEditor($commentsToEditor)
getSubtitle($locale)
setShowCoverPage($showCoverPage, $locale)
static & loadCategory($category, $enabledOnly=false, $mainContextId=null)
setStageId($stageId)
getAbstract($locale)
setSubtitle($subtitle, $locale)
getPrefix($locale)
getRights($locale)
getTitle($locale)
setCleanTitle($cleanTitle, $locale)
setCommentsStatus($commentsStatus)
setDateSubmitted($dateSubmitted)
getFileName($locale)
static getLocale()
& getData($key, $locale=null)
encodeDisplayName($displayName, $send=false)
Definition: Mail.inc.php:514
setType($type, $locale)
setHideCoverPageToc($hideCoverPageToc, $locale)
setTitle($title, $locale)
setLanguage($language)
getHideCoverPageToc($locale)
getLocalizedOriginalFileName()
setHeight($height, $locale)
getWidth($locale)
setCoverageChron($coverageChron, $locale)
setDiscipline($discipline, $locale)
setFileName($fileName, $locale)
getAuthorString($lastOnly=false, $nameSeparator= ', ', $userGroupSeparator= '; ')
getStoredPubId($pubIdType)
getHeight($locale)
setCoverageGeo($coverageGeo, $locale)
setPrefix($prefix, $locale)
getCoverageGeo($locale)
& getLocalizedData($key, $preferredLocale=null)
setHasLoadableAdapters($hasLoadableAdapters)
setStoredPubId($pubIdType, $pubId)
setDatePublished($datePublished)
getCoverageSample($locale)
getLocalizedShowCoverPage()
Any class with an associated DAO should extend this class.
setLocale($locale)
static concatTitleFields($fields)
Definition: String.inc.php:717
setCoverPageAltText($coverPageAltText, $locale)
getLocalizedCoverageSample()
setOriginalFileName($originalFileName, $locale)
setData($key, $value, $locale=null)
getCoverageChron($locale)
getCopyrightNotice($locale)
setSubmissionProgress($submissionProgress)
getSponsor($locale)
setSubjectClass($subjectClass, $locale)
getType($locale)
getPubId($pubIdType, $preview=false)
getLocalizedTitle($preferredLocale=null)
setPages($pages)
setCitations($citations)
getSubject($locale)
setDateStatusModified($dateModified)
setCopyrightNotice($copyrightNotice, $locale)
The Submission class implements the abstract data model of a scholarly submission.
setRights($rights, $locale)
setSource($source, $locale)
getSubjectClass($locale)
getCoverPageAltText($locale)
setHideCoverPageAbstract($hideCoverPageAbstract, $locale)
setStatus($status)
setSubject($subject, $locale)
getOriginalFileName($locale)
setUserId($userId)
static getCurrentDate($ts=null)
Definition: Core.inc.php:95