PageRenderTime 55ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/classes/paper/Paper.inc.php

https://github.com/lib-uoguelph-ca/ocs
PHP | 537 lines | 238 code | 68 blank | 231 comment | 28 complexity | e1342059fb7faf4845b41221597faf76 MD5 | raw file
Possible License(s): GPL-2.0
  1. <?php
  2. /**
  3. * @defgroup paper
  4. */
  5. /**
  6. * @file Paper.inc.php
  7. *
  8. * Copyright (c) 2000-2012 John Willinsky
  9. * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
  10. *
  11. * @class Paper
  12. * @ingroup paper
  13. * @see PaperDAO
  14. *
  15. * @brief Paper class.
  16. *
  17. */
  18. // $Id$
  19. // Submission status constants
  20. define('STATUS_ARCHIVED', 0);
  21. define('STATUS_QUEUED', 1);
  22. define('STATUS_PUBLISHED', 3);
  23. define('STATUS_DECLINED', 4);
  24. // AuthorSubmission::getSubmissionStatus will return one of these in place of QUEUED:
  25. define ('STATUS_QUEUED_UNASSIGNED', 5);
  26. define ('STATUS_QUEUED_REVIEW', 6);
  27. define ('STATUS_QUEUED_EDITING', 7);
  28. define ('STATUS_INCOMPLETE', 8);
  29. define ('REVIEW_STAGE_ABSTRACT', 1);
  30. define ('REVIEW_STAGE_PRESENTATION', 2);
  31. /* These constants are used as search fields for the various submission lists */
  32. define('SUBMISSION_FIELD_AUTHOR', 1);
  33. define('SUBMISSION_FIELD_DIRECTOR', 2);
  34. define('SUBMISSION_FIELD_TITLE', 3);
  35. define('SUBMISSION_FIELD_REVIEWER', 4);
  36. define('SUBMISSION_FIELD_DATE_SUBMITTED', 5);
  37. // Paper RT comments
  38. define ('COMMENTS_TRACK_DEFAULT', 0);
  39. define ('COMMENTS_DISABLE', 1);
  40. define ('COMMENTS_ENABLE', 2);
  41. import('submission.Submission');
  42. class Paper extends Submission {
  43. /**
  44. * Constructor.
  45. */
  46. function Paper() {
  47. parent::Submission();
  48. }
  49. /**
  50. * Add an author.
  51. * @param $author Author
  52. */
  53. function addAuthor($author) {
  54. if ($author->getPaperId() == null) {
  55. $author->setPaperId($this->getId());
  56. }
  57. parent::addAuthor($author);
  58. }
  59. /**
  60. * Get "localized" paper title (if applicable). DEPRECATED
  61. * in favour of getLocalizedTitle.
  62. * @return string
  63. */
  64. function getPaperTitle() {
  65. if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
  66. return $this->getLocalizedTitle();
  67. }
  68. /**
  69. * Get "localized" paper abstract (if applicable). DEPRECATED
  70. * in favour of getLocalizedAbstract.
  71. * @return string
  72. */
  73. function getPaperAbstract() {
  74. if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
  75. return $this->getLocalizedAbstract();
  76. }
  77. //
  78. // Get/set methods
  79. //
  80. /**
  81. * Get ID of paper.
  82. * @return int
  83. */
  84. function getPaperId() {
  85. if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
  86. return $this->getId();
  87. }
  88. /**
  89. * Set ID of paper.
  90. * @param $paperId int
  91. */
  92. function setPaperId($paperId) {
  93. if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
  94. return $this->setId($paperId);
  95. }
  96. /**
  97. * Get ID of scheduled conference.
  98. * @return int
  99. */
  100. function getSchedConfId() {
  101. return $this->getData('schedConfId');
  102. }
  103. /**
  104. * Set ID of scheduled conference.
  105. * @param $schedConfId int
  106. */
  107. function setSchedConfId($schedConfId) {
  108. return $this->setData('schedConfId', $schedConfId);
  109. }
  110. /**
  111. * Get ID of paper's track.
  112. * @return int
  113. */
  114. function getTrackId() {
  115. return $this->getData('trackId');
  116. }
  117. /**
  118. * Set ID of paper's track.
  119. * @param $trackId int
  120. */
  121. function setTrackId($trackId) {
  122. return $this->setData('trackId', $trackId);
  123. }
  124. /**
  125. * Get title of paper's track.
  126. * @return string
  127. */
  128. function getTrackTitle() {
  129. return $this->getData('trackTitle');
  130. }
  131. /**
  132. * Set title of paper's track.
  133. * @param $trackTitle string
  134. */
  135. function setTrackTitle($trackTitle) {
  136. return $this->setData('trackTitle', $trackTitle);
  137. }
  138. /**
  139. * Get track abbreviation.
  140. * @return string
  141. */
  142. function getTrackAbbrev() {
  143. return $this->getData('trackAbbrev');
  144. }
  145. /**
  146. * Set track abbreviation.
  147. * @param $trackAbbrev string
  148. */
  149. function setTrackAbbrev($trackAbbrev) {
  150. return $this->setData('trackAbbrev', $trackAbbrev);
  151. }
  152. /**
  153. * Return the localized discipline. DEPRECATED in favour
  154. * of getLocalizedDiscipline.
  155. * @param $locale string
  156. * @return string
  157. */
  158. function getPaperDiscipline() {
  159. if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
  160. return $this->getLocalizedDiscipline();
  161. }
  162. /**
  163. * Return the localized subject classification. DEPRECATED
  164. * in favour of getLocalizedSubjectClass.
  165. * @param $locale string
  166. * @return string
  167. */
  168. function getPaperSubjectClass() {
  169. if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
  170. return $this->getLocalizedSubjectClass();
  171. }
  172. /**
  173. * Return the localized subject. DEPRECATED
  174. * in favour of getLocalizedSubject.
  175. * @return string
  176. */
  177. function getPaperSubject() {
  178. if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
  179. return $this->getLocalizedSubject();
  180. }
  181. /**
  182. * Return the localized geo coverage. DEPRECATED in favour of
  183. * getLocalizedCoverageGeo.
  184. * @return string
  185. */
  186. function getPaperCoverageGeo() {
  187. if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
  188. return $this->getLocalizedCoverageGeo();
  189. }
  190. /**
  191. * Return the localized chron coverage. DEPRECATED in favour
  192. * of getLocalizedCoverageChron.
  193. * @return string
  194. */
  195. function getPaperCoverageChron() {
  196. if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
  197. return $this->getLocalizedCoverageChron();
  198. }
  199. /**
  200. * Return the localized sample coverage. DEPRECATED in favour
  201. * of getLocalizedCoverageSample.
  202. * @return string
  203. */
  204. function getPaperCoverageSample() {
  205. if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
  206. return $this->getLocalizedCoverageSample();
  207. }
  208. /**
  209. * Return the localized type. DEPRECATED in favour of
  210. * getLocalizedType.
  211. * @return string
  212. */
  213. function getPaperType() {
  214. if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
  215. return $this->getLocalizedType();
  216. }
  217. /**
  218. * Return the localized sponsor. DEPRECATED in favour of
  219. * getLocalizedSponsor.
  220. * @return string
  221. */
  222. function getPaperSponsor() {
  223. if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
  224. return $this->getLocalizedSponsor();
  225. }
  226. /**
  227. * Get comments to director.
  228. * @return string
  229. */
  230. function getCommentsToDirector() {
  231. return $this->getData('commentsToDirector');
  232. }
  233. /**
  234. * Set comments to director.
  235. * @param $commentsToDirector string
  236. */
  237. function setCommentsToDirector($commentsToDirector) {
  238. return $this->setData('commentsToDirector', $commentsToDirector);
  239. }
  240. /**
  241. * Get date sent to presentations.
  242. * @return date
  243. */
  244. function getDateToPresentations() {
  245. return $this->getData('dateToPresentations');
  246. }
  247. /**
  248. * Set date sent to presentations.
  249. * @param $dateToPresentations date
  250. */
  251. function setDateToPresentations($dateToPresentations) {
  252. return $this->setData('dateToPresentations', $dateToPresentations);
  253. }
  254. /**
  255. * Get date sent to presentations.
  256. * @return date
  257. */
  258. function getDateToArchive() {
  259. return $this->getData('dateToArchive');
  260. }
  261. /**
  262. * Set date sent to presentations.
  263. * @param $dateToArchive date
  264. */
  265. function setDateToArchive($dateToArchive) {
  266. return $this->setData('dateToArchive', $dateToArchive);
  267. }
  268. /**
  269. * Stamp the date moved to the archive to the current time.
  270. */
  271. function stampDateToArchive() {
  272. return $this->setDateToArchive(Core::getCurrentDate());
  273. }
  274. /**
  275. * Stamp the date moved to presentations to the current time.
  276. */
  277. function stampDateToPresentations() {
  278. return $this->setDateToPresentations(Core::getCurrentDate());
  279. }
  280. /**
  281. * Get the date of the "submission due" reminder.
  282. * @return date
  283. */
  284. function getDateReminded() {
  285. return $this->getData('dateReminded');
  286. }
  287. /**
  288. * Set the date of the "submission due" reminder.
  289. * @param $dateModified date
  290. */
  291. function setDateReminded($dateReminded) {
  292. return $this->setData('dateReminded', $dateReminded);
  293. }
  294. /**
  295. * Get the presentation start time.
  296. * @return date
  297. */
  298. function getStartTime() {
  299. return $this->getData('startTime');
  300. }
  301. /**
  302. * Set the presentation start time.
  303. * @param $startTime date
  304. */
  305. function setStartTime($startTime) {
  306. return $this->setData('startTime', $startTime);
  307. }
  308. /**
  309. * Get the presentation end time.
  310. * @return date
  311. */
  312. function getEndTime() {
  313. return $this->getData('endTime');
  314. }
  315. /**
  316. * Get the presentation end time.
  317. * @param $endTime date
  318. */
  319. function setEndTime($endTime) {
  320. return $this->setData('endTime', $endTime);
  321. }
  322. /**
  323. * Get current stage.
  324. * @return int
  325. */
  326. function getCurrentStage() {
  327. return $this->getData('currentStage');
  328. }
  329. /**
  330. * Set current stage.
  331. * @param $currentStage int
  332. */
  333. function setCurrentStage($currentStage) {
  334. return $this->setData('currentStage', $currentStage);
  335. }
  336. /**
  337. * Get review mode.
  338. * @return int REVIEW_MODE_...
  339. */
  340. function getReviewMode() {
  341. return $this->getData('reviewMode');
  342. }
  343. /**
  344. * Set review mode.
  345. * @param $reviewMode int REVIEW_MODE_...
  346. */
  347. function setReviewMode($reviewMode) {
  348. return $this->setData('reviewMode', $reviewMode);
  349. }
  350. /**
  351. * Get layout file id.
  352. * @return int
  353. */
  354. function getLayoutFileId() {
  355. return $this->getData('layoutFileId');
  356. }
  357. /**
  358. * Set layout file id.
  359. * @param $layoutFileId int
  360. */
  361. function setLayoutFileId($layoutFileId) {
  362. return $this->setData('layoutFileId', $layoutFileId);
  363. }
  364. /**
  365. * Get director file id.
  366. * @return int
  367. */
  368. function getDirectorFileId() {
  369. return $this->getData('directorFileId');
  370. }
  371. /**
  372. * Set director file id.
  373. * @param $directorFileId int
  374. */
  375. function setDirectorFileId($directorFileId) {
  376. return $this->setData('directorFileId', $directorFileId);
  377. }
  378. /**
  379. * Return locale string corresponding to RT comments status.
  380. * @return string
  381. */
  382. function getCommentsStatusString() {
  383. switch ($this->getCommentsStatus()) {
  384. case COMMENTS_DISABLE:
  385. return 'paper.comments.disable';
  386. case COMMENTS_ENABLE:
  387. return 'paper.comments.enable';
  388. default:
  389. return 'paper.comments.trackDefault';
  390. }
  391. }
  392. /**
  393. * Return boolean indicating if paper RT comments should be enabled.
  394. * Checks both the track and paper comments status. Paper status
  395. * overrides track status.
  396. * @return int
  397. */
  398. function getEnableComments() {
  399. switch ($this->getCommentsStatus()) {
  400. case COMMENTS_DISABLE:
  401. return false;
  402. case COMMENTS_ENABLE:
  403. return true;
  404. case COMMENTS_TRACK_DEFAULT:
  405. $trackDao =& DAORegistry::getDAO('TrackDAO');
  406. $track =& $trackDao->getTrack($this->getTrackId(), $this->getSchedConfId());
  407. if ($track->getDisableComments()) {
  408. return false;
  409. } else {
  410. return true;
  411. }
  412. }
  413. }
  414. /**
  415. * Get an associative array matching RT comments status codes with locale strings.
  416. * @return array comments status => localeString
  417. */
  418. function &getCommentsStatusOptions() {
  419. static $commentsStatusOptions = array(
  420. COMMENTS_TRACK_DEFAULT => 'paper.comments.trackDefault',
  421. COMMENTS_DISABLE => 'paper.comments.disable',
  422. COMMENTS_ENABLE => 'paper.comments.enable'
  423. );
  424. return $commentsStatusOptions;
  425. }
  426. /**
  427. * Get an array of user IDs associated with this paper
  428. * @param $authors boolean
  429. * @param $reviewers boolean
  430. * @param $trackDirectors boolean
  431. * @param $directors boolean
  432. * @return array User IDs
  433. */
  434. function getAssociatedUserIds($authors = true, $reviewers = true, $trackDirectors = true, $directors = true) {
  435. $paperId = $this->getId();
  436. $userIds = array();
  437. if($authors) {
  438. $userId = $this->getUserId();
  439. if ($userId) $userIds[] = array('id' => $userId, 'role' => 'author');
  440. }
  441. if($reviewers) {
  442. $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
  443. $reviewAssignments =& $reviewAssignmentDao->getReviewAssignmentsByPaperId($paperId);
  444. foreach ($reviewAssignments as $reviewAssignment) {
  445. $userId = $reviewAssignment->getReviewerId();
  446. if ($userId) $userIds[] = array('id' => $userId, 'role' => 'reviewer');
  447. unset($reviewAssignment);
  448. }
  449. }
  450. $editAssignmentDao =& DAORegistry::getDAO('EditAssignmentDAO');
  451. if($trackDirectors) {
  452. $editAssignments =& $editAssignmentDao->getTrackDirectorAssignmentsByPaperId($paperId);
  453. while ($editAssignment =& $editAssignments->next()) {
  454. $userId = $editAssignment->getDirectorId();
  455. if ($userId) $userIds[] = array('id' => $userId, 'role' => 'trackDirector');
  456. unset($editAssignment);
  457. }
  458. }
  459. if($directors) {
  460. $editAssignments =& $editAssignmentDao->getDirectorAssignmentsByPaperId($paperId);
  461. while ($editAssignment =& $editAssignments->next()) {
  462. $userId = $editAssignment->getDirectorId();
  463. if ($userId) $userIds[] = array('id' => $userId, 'role' => 'director');
  464. }
  465. }
  466. return $userIds;
  467. }
  468. }
  469. ?>