PageRenderTime 35ms CodeModel.GetById 10ms RepoModel.GetById 0ms app.codeStats 0ms

/ojs/ojs-2.3.2-1/classes/article/log/ArticleEventLogEntry.inc.php

https://github.com/mcrider/pkpUpgradeTestSuite
PHP | 494 lines | 293 code | 56 blank | 145 comment | 6 complexity | 9478dce18f011b71e5867492392f89c5 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1
  1. <?php
  2. /**
  3. * @file classes/article/log/ArticleEventLogEntry.inc.php
  4. *
  5. * Copyright (c) 2003-2009 John Willinsky
  6. * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
  7. *
  8. * @class ArticleEventLogEntry
  9. * @ingroup article_log
  10. * @see ArticleEventLogDAO
  11. *
  12. * @brief Describes an entry in the article history log.
  13. */
  14. // $Id$
  15. // Log levels
  16. define('ARTICLE_LOG_LEVEL_INFO', 'I');
  17. define('ARTICLE_LOG_LEVEL_NOTICE', 'N');
  18. define('ARTICLE_LOG_LEVEL_WARNING', 'W');
  19. define('ARTICLE_LOG_LEVEL_ERROR', 'E');
  20. // Log entry associative types. All types must be defined here
  21. define('ARTICLE_LOG_TYPE_DEFAULT', 0);
  22. define('ARTICLE_LOG_TYPE_AUTHOR', 0x01);
  23. define('ARTICLE_LOG_TYPE_EDITOR', 0x02);
  24. define('ARTICLE_LOG_TYPE_REVIEW', 0x03);
  25. define('ARTICLE_LOG_TYPE_COPYEDIT', 0x04);
  26. define('ARTICLE_LOG_TYPE_LAYOUT', 0x05);
  27. define('ARTICLE_LOG_TYPE_PROOFREAD', 0x06);
  28. // Log entry event types. All types must be defined here
  29. define('ARTICLE_LOG_DEFAULT', 0);
  30. // General events 0x10000000
  31. define('ARTICLE_LOG_ARTICLE_SUBMIT', 0x10000001);
  32. define('ARTICLE_LOG_METADATA_UPDATE', 0x10000002);
  33. define('ARTICLE_LOG_SUPPFILE_UPDATE', 0x10000003);
  34. define('ARTICLE_LOG_ISSUE_SCHEDULE', 0x10000004);
  35. define('ARTICLE_LOG_ISSUE_ASSIGN', 0x10000005);
  36. define('ARTICLE_LOG_ARTICLE_PUBLISH', 0x10000006);
  37. define('ARTICLE_LOG_ARTICLE_IMPORT', 0x10000007);
  38. // Author events 0x20000000
  39. define('ARTICLE_LOG_AUTHOR_REVISION', 0x20000001);
  40. // Editor events 0x30000000
  41. define('ARTICLE_LOG_EDITOR_ASSIGN', 0x30000001);
  42. define('ARTICLE_LOG_EDITOR_UNASSIGN', 0x30000002);
  43. define('ARTICLE_LOG_EDITOR_DECISION', 0x30000003);
  44. define('ARTICLE_LOG_EDITOR_FILE', 0x30000004);
  45. define('ARTICLE_LOG_EDITOR_ARCHIVE', 0x30000005);
  46. define('ARTICLE_LOG_EDITOR_RESTORE', 0x30000006);
  47. define('ARTICLE_LOG_EDITOR_EXPEDITE', 0x30000007);
  48. // Reviewer events 0x40000000
  49. define('ARTICLE_LOG_REVIEW_ASSIGN', 0x40000001);
  50. define('ARTICLE_LOG_REVIEW_UNASSIGN', 0x40000002);
  51. define('ARTICLE_LOG_REVIEW_INITIATE', 0x40000003);
  52. define('ARTICLE_LOG_REVIEW_CANCEL', 0x40000004);
  53. define('ARTICLE_LOG_REVIEW_REINITIATE', 0x40000005);
  54. define('ARTICLE_LOG_REVIEW_ACCEPT', 0x40000006);
  55. define('ARTICLE_LOG_REVIEW_DECLINE', 0x40000007);
  56. define('ARTICLE_LOG_REVIEW_REVISION', 0x40000008);
  57. define('ARTICLE_LOG_REVIEW_RECOMMENDATION', 0x40000009);
  58. define('ARTICLE_LOG_REVIEW_RATE', 0x40000010);
  59. define('ARTICLE_LOG_REVIEW_SET_DUE_DATE', 0x40000011);
  60. define('ARTICLE_LOG_REVIEW_RESUBMIT', 0x40000012);
  61. define('ARTICLE_LOG_REVIEW_FILE', 0x40000013);
  62. define('ARTICLE_LOG_REVIEW_CLEAR', 0x40000014);
  63. define('ARTICLE_LOG_REVIEW_CONFIRM_BY_PROXY', 0x40000015);
  64. define('ARTICLE_LOG_REVIEW_RECOMMENDATION_BY_PROXY', 0x40000016);
  65. define('ARTICLE_LOG_REVIEW_FILE_BY_PROXY', 0x40000017);
  66. // Copyeditor events 0x50000000
  67. define('ARTICLE_LOG_COPYEDIT_ASSIGN', 0x50000001);
  68. define('ARTICLE_LOG_COPYEDIT_UNASSIGN', 0x50000002);
  69. define('ARTICLE_LOG_COPYEDIT_INITIATE', 0x50000003);
  70. define('ARTICLE_LOG_COPYEDIT_REVISION', 0x50000004);
  71. define('ARTICLE_LOG_COPYEDIT_INITIAL', 0x50000005);
  72. define('ARTICLE_LOG_COPYEDIT_FINAL', 0x50000006);
  73. define('ARTICLE_LOG_COPYEDIT_SET_FILE', 0x50000007);
  74. define('ARTICLE_LOG_COPYEDIT_COPYEDIT_FILE', 0x50000008);
  75. define('ARTICLE_LOG_COPYEDIT_COPYEDITOR_FILE', 0x50000009);
  76. // Proofreader events 0x60000000
  77. define('ARTICLE_LOG_PROOFREAD_ASSIGN', 0x60000001);
  78. define('ARTICLE_LOG_PROOFREAD_UNASSIGN', 0x60000002);
  79. define('ARTICLE_LOG_PROOFREAD_INITIATE', 0x60000003);
  80. define('ARTICLE_LOG_PROOFREAD_REVISION', 0x60000004);
  81. define('ARTICLE_LOG_PROOFREAD_COMPLETE', 0x60000005);
  82. // Layout events 0x70000000
  83. define('ARTICLE_LOG_LAYOUT_ASSIGN', 0x70000001);
  84. define('ARTICLE_LOG_LAYOUT_UNASSIGN', 0x70000002);
  85. define('ARTICLE_LOG_LAYOUT_INITIATE', 0x70000003);
  86. define('ARTICLE_LOG_LAYOUT_GALLEY', 0x70000004);
  87. define('ARTICLE_LOG_LAYOUT_COMPLETE', 0x70000005);
  88. class ArticleEventLogEntry extends DataObject {
  89. /**
  90. * Constructor.
  91. */
  92. function ArticleEventLogEntry() {
  93. parent::DataObject();
  94. }
  95. /**
  96. * Set localized log message (in the journal's primary locale)
  97. * @param $key localization message key
  98. * @param $params array optional array of parameters
  99. */
  100. function setLogMessage($key, $params = array()) {
  101. $this->setMessage(Locale::translate($key, $params, Locale::getPrimaryLocale()));
  102. }
  103. //
  104. // Get/set methods
  105. //
  106. /**
  107. * Get ID of log entry.
  108. * @return int
  109. */
  110. function getLogId() {
  111. return $this->getData('logId');
  112. }
  113. /**
  114. * Set ID of log entry.
  115. * @param $logId int
  116. */
  117. function setLogId($logId) {
  118. return $this->setData('logId', $logId);
  119. }
  120. /**
  121. * Get ID of article.
  122. * @return int
  123. */
  124. function getArticleId() {
  125. return $this->getData('articleId');
  126. }
  127. /**
  128. * Set ID of article.
  129. * @param $articleId int
  130. */
  131. function setArticleId($articleId) {
  132. return $this->setData('articleId', $articleId);
  133. }
  134. /**
  135. * Get user ID of user that initiated the event.
  136. * @return int
  137. */
  138. function getUserId() {
  139. return $this->getData('userId');
  140. }
  141. /**
  142. * Set user ID of user that initiated the event.
  143. * @param $userId int
  144. */
  145. function setUserId($userId) {
  146. return $this->setData('userId', $userId);
  147. }
  148. /**
  149. * Get date entry was logged.
  150. * @return datestamp
  151. */
  152. function getDateLogged() {
  153. return $this->getData('dateLogged');
  154. }
  155. /**
  156. * Set date entry was logged.
  157. * @param $dateLogged datestamp
  158. */
  159. function setDateLogged($dateLogged) {
  160. return $this->setData('dateLogged', $dateLogged);
  161. }
  162. /**
  163. * Get IP address of user that initiated the event.
  164. * @return string
  165. */
  166. function getIPAddress() {
  167. return $this->getData('ipAddress');
  168. }
  169. /**
  170. * Set IP address of user that initiated the event.
  171. * @param $ipAddress string
  172. */
  173. function setIPAddress($ipAddress) {
  174. return $this->setData('ipAddress', $ipAddress);
  175. }
  176. /**
  177. * Get the log level.
  178. * @return int
  179. */
  180. function getLogLevel() {
  181. return $this->getData('logLevel');
  182. }
  183. /**
  184. * Set the log level.
  185. * @param $logLevel char
  186. */
  187. function setLogLevel($logLevel) {
  188. return $this->setData('logLevel', $logLevel);
  189. }
  190. /**
  191. * Get event type.
  192. * @return int
  193. */
  194. function getEventType() {
  195. return $this->getData('eventType');
  196. }
  197. /**
  198. * Set event type.
  199. * @param $eventType int
  200. */
  201. function setEventType($eventType) {
  202. return $this->setData('eventType', $eventType);
  203. }
  204. /**
  205. * Get associated type.
  206. * @return int
  207. */
  208. function getAssocType() {
  209. return $this->getData('assocType');
  210. }
  211. /**
  212. * Set associated type.
  213. * @param $assocType int
  214. */
  215. function setAssocType($assocType) {
  216. return $this->setData('assocType', $assocType);
  217. }
  218. /**
  219. * Get associated ID.
  220. * @return int
  221. */
  222. function getAssocId() {
  223. return $this->getData('assocId');
  224. }
  225. /**
  226. * Set associated ID.
  227. * @param $assocId int
  228. */
  229. function setAssocId($assocId) {
  230. return $this->setData('assocId', $assocId);
  231. }
  232. /**
  233. * Get custom log message (non-localized).
  234. * @return string
  235. */
  236. function getMessage() {
  237. return $this->getData('message');
  238. }
  239. /**
  240. * Set custom log message (non-localized).
  241. * @param $message string
  242. */
  243. function setMessage($message) {
  244. return $this->setData('message', $message);
  245. }
  246. /**
  247. * Return locale message key for the log level.
  248. * @return string
  249. */
  250. function getLogLevelString() {
  251. switch ($this->getData('logLevel')) {
  252. case ARTICLE_LOG_LEVEL_INFO:
  253. return 'submission.event.logLevel.info';
  254. case ARTICLE_LOG_LEVEL_NOTICE:
  255. return 'submission.event.logLevel.notice';
  256. case ARTICLE_LOG_LEVEL_WARNING:
  257. return 'submission.event.logLevel.warning';
  258. case ARTICLE_LOG_LEVEL_ERROR:
  259. return 'submission.event.logLevel.error';
  260. default:
  261. return 'submission.event.logLevel.notice';
  262. }
  263. }
  264. /**
  265. * Return locale message key describing event type.
  266. * @return string
  267. */
  268. function getEventTitle() {
  269. switch ($this->getData('eventType')) {
  270. // General events
  271. case ARTICLE_LOG_ARTICLE_SUBMIT:
  272. return 'submission.event.general.articleSubmitted';
  273. case ARTICLE_LOG_METADATA_UPDATE:
  274. return 'submission.event.general.metadataUpdated';
  275. case ARTICLE_LOG_SUPPFILE_UPDATE:
  276. return 'submission.event.general.suppFileUpdated';
  277. case ARTICLE_LOG_ISSUE_SCHEDULE:
  278. return 'submission.event.general.issueScheduled';
  279. case ARTICLE_LOG_ISSUE_ASSIGN:
  280. return 'submission.event.general.issueAssigned';
  281. case ARTICLE_LOG_ARTICLE_PUBLISH:
  282. return 'submission.event.general.articlePublished';
  283. // Author events
  284. case ARTICLE_LOG_AUTHOR_REVISION:
  285. return 'submission.event.author.authorRevision';
  286. // Editor events
  287. case ARTICLE_LOG_EDITOR_ASSIGN:
  288. return 'submission.event.editor.editorAssigned';
  289. case ARTICLE_LOG_EDITOR_UNASSIGN:
  290. return 'submission.event.editor.editorUnassigned';
  291. case ARTICLE_LOG_EDITOR_DECISION:
  292. return 'submission.event.editor.editorDecision';
  293. case ARTICLE_LOG_EDITOR_FILE:
  294. return 'submission.event.editor.editorFile';
  295. case ARTICLE_LOG_EDITOR_ARCHIVE:
  296. return 'submission.event.editor.submissionArchived';
  297. case ARTICLE_LOG_EDITOR_RESTORE:
  298. return 'submission.event.editor.submissionRestored';
  299. // Reviewer events
  300. case ARTICLE_LOG_REVIEW_ASSIGN:
  301. return 'submission.event.reviewer.reviewerAssigned';
  302. case ARTICLE_LOG_REVIEW_UNASSIGN:
  303. return 'submission.event.reviewer.reviewerUnassigned';
  304. case ARTICLE_LOG_REVIEW_INITIATE:
  305. return 'submission.event.reviewer.reviewInitiated';
  306. case ARTICLE_LOG_REVIEW_CANCEL:
  307. return 'submission.event.reviewer.reviewCancelled';
  308. case ARTICLE_LOG_REVIEW_REINITIATE:
  309. return 'submission.event.reviewer.reviewReinitiated';
  310. case ARTICLE_LOG_REVIEW_CONFIRM_BY_PROXY:
  311. return 'submission.event.reviewer.reviewAcceptedByProxy';
  312. case ARTICLE_LOG_REVIEW_ACCEPT:
  313. return 'submission.event.reviewer.reviewAccepted';
  314. case ARTICLE_LOG_REVIEW_DECLINE:
  315. return 'submission.event.reviewer.reviewDeclined';
  316. case ARTICLE_LOG_REVIEW_REVISION:
  317. return 'submission.event.reviewer.reviewRevision';
  318. case ARTICLE_LOG_REVIEW_RECOMMENDATION:
  319. return 'submission.event.reviewer.reviewRecommendation';
  320. case ARTICLE_LOG_REVIEW_RATE:
  321. return 'submission.event.reviewer.reviewerRated';
  322. case ARTICLE_LOG_REVIEW_SET_DUE_DATE:
  323. return 'submission.event.reviewer.reviewDueDate';
  324. case ARTICLE_LOG_REVIEW_RESUBMIT:
  325. return 'submission.event.reviewer.reviewResubmitted';
  326. case ARTICLE_LOG_REVIEW_FILE:
  327. return 'submission.event.reviewer.reviewFile';
  328. // Copyeditor events
  329. case ARTICLE_LOG_COPYEDIT_ASSIGN:
  330. return 'submission.event.copyedit.copyeditorAssigned';
  331. case ARTICLE_LOG_COPYEDIT_UNASSIGN:
  332. return 'submission.event.copyedit.copyeditorUnassigned';
  333. case ARTICLE_LOG_COPYEDIT_INITIATE:
  334. return 'submission.event.copyedit.copyeditInitiated';
  335. case ARTICLE_LOG_COPYEDIT_REVISION:
  336. return 'submission.event.copyedit.copyeditRevision';
  337. case ARTICLE_LOG_COPYEDIT_INITIAL:
  338. return 'submission.event.copyedit.copyeditInitialCompleted';
  339. case ARTICLE_LOG_COPYEDIT_FINAL:
  340. return 'submission.event.copyedit.copyeditFinalCompleted';
  341. case ARTICLE_LOG_COPYEDIT_SET_FILE:
  342. return 'submission.event.copyedit.copyeditSetFile';
  343. // Proofreader events
  344. case ARTICLE_LOG_PROOFREAD_ASSIGN:
  345. return 'submission.event.proofread.proofreaderAssigned';
  346. case ARTICLE_LOG_PROOFREAD_UNASSIGN:
  347. return 'submission.event.proofread.proofreaderUnassigned';
  348. case ARTICLE_LOG_PROOFREAD_INITIATE:
  349. return 'submission.event.proofread.proofreadInitiated';
  350. case ARTICLE_LOG_PROOFREAD_REVISION:
  351. return 'submission.event.proofread.proofreadRevision';
  352. case ARTICLE_LOG_PROOFREAD_COMPLETE:
  353. return 'submission.event.proofread.proofreadCompleted';
  354. // Layout events
  355. case ARTICLE_LOG_LAYOUT_ASSIGN:
  356. return 'submission.event.layout.layoutEditorAssigned';
  357. case ARTICLE_LOG_LAYOUT_UNASSIGN:
  358. return 'submission.event.layout.layoutEditorUnassigned';
  359. case ARTICLE_LOG_LAYOUT_INITIATE:
  360. return 'submission.event.layout.layoutInitiated';
  361. case ARTICLE_LOG_LAYOUT_GALLEY:
  362. return 'submission.event.layout.layoutGalleyCreated';
  363. case ARTICLE_LOG_LAYOUT_COMPLETE:
  364. return 'submission.event.layout.layoutComplete';
  365. default:
  366. return 'submission.event.general.defaultEvent';
  367. }
  368. }
  369. /**
  370. * Return the full name of the user.
  371. * @return string
  372. */
  373. function getUserFullName() {
  374. $userFullName =& $this->getData('userFullName');
  375. if(!isset($userFullName)) {
  376. $userDao =& DAORegistry::getDAO('UserDAO');
  377. $userFullName = $userDao->getUserFullName($this->getUserId(), true);
  378. }
  379. return $userFullName ? $userFullName : '';
  380. }
  381. /**
  382. * Return the email address of the user.
  383. * @return string
  384. */
  385. function getUserEmail() {
  386. $userEmail =& $this->getData('userEmail');
  387. if(!isset($userEmail)) {
  388. $userDao =& DAORegistry::getDAO('UserDAO');
  389. $userEmail = $userDao->getUserEmail($this->getUserId(), true);
  390. }
  391. return $userEmail ? $userEmail : '';
  392. }
  393. /**
  394. * Return string representation of the associated type.
  395. * @return string
  396. */
  397. function getAssocTypeString() {
  398. switch ($this->getData('assocType')) {
  399. case ARTICLE_LOG_TYPE_AUTHOR:
  400. return 'AUT';
  401. case ARTICLE_LOG_TYPE_EDITOR:
  402. return 'EDR';
  403. case ARTICLE_LOG_TYPE_REVIEW:
  404. return 'REV';
  405. case ARTICLE_LOG_TYPE_COPYEDIT:
  406. return 'CPY';
  407. case ARTICLE_LOG_TYPE_LAYOUT:
  408. return 'LYT';
  409. case ARTICLE_LOG_TYPE_PROOFREAD:
  410. return 'PRF';
  411. default:
  412. return 'ART';
  413. }
  414. }
  415. /**
  416. * Return locale message key for the long format of the associated type.
  417. * @return string
  418. */
  419. function getAssocTypeLongString() {
  420. switch ($this->getData('assocType')) {
  421. case ARTICLE_LOG_TYPE_AUTHOR:
  422. return 'submission.logType.author';
  423. case ARTICLE_LOG_TYPE_EDITOR:
  424. return 'submission.logType.editor';
  425. case ARTICLE_LOG_TYPE_REVIEW:
  426. return 'submission.logType.review';
  427. case ARTICLE_LOG_TYPE_COPYEDIT:
  428. return 'submission.logType.copyedit';
  429. case ARTICLE_LOG_TYPE_LAYOUT:
  430. return 'submission.logType.layout';
  431. case ARTICLE_LOG_TYPE_PROOFREAD:
  432. return 'submission.logType.proofread';
  433. default:
  434. return 'submission.logType.article';
  435. }
  436. }
  437. }
  438. ?>