PageRenderTime 38ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/pkp/classes/announcement/PKPAnnouncement.inc.php

https://github.com/lib-uoguelph-ca/ocs
PHP | 265 lines | 105 code | 35 blank | 125 comment | 8 complexity | 8fb4282aad6612dac97e28d9df9e77c1 MD5 | raw file
Possible License(s): GPL-2.0
  1. <?php
  2. /**
  3. * @defgroup announcement
  4. */
  5. /**
  6. * @file PKPAnnouncement.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 PKPAnnouncement
  12. * @ingroup announcement
  13. * @see AnnouncementDAO, PKPAnnouncementDAO
  14. *
  15. * @brief Basic class describing a announcement.
  16. *
  17. */
  18. define('ANNOUNCEMENT_EXPIRE_YEAR_OFFSET_FUTURE', '+10');
  19. class PKPAnnouncement extends DataObject {
  20. //
  21. // Get/set methods
  22. //
  23. /**
  24. * Get the ID of the announcement.
  25. * @return int
  26. */
  27. function getAnnouncementId() {
  28. if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
  29. return $this->getId();
  30. }
  31. /**
  32. * Set the ID of the announcement.
  33. * @param $announcementId int
  34. */
  35. function setAnnouncementId($announcementId) {
  36. if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
  37. return $this->setId($announcementId);
  38. }
  39. /**
  40. * Get assoc ID for this annoucement.
  41. * @return int
  42. */
  43. function getAssocId() {
  44. return $this->getData('assocId');
  45. }
  46. /**
  47. * Set assoc ID for this annoucement.
  48. * @param $assocId int
  49. */
  50. function setAssocId($assocId) {
  51. return $this->setData('assocId', $assocId);
  52. }
  53. /**
  54. * Get assoc type for this annoucement.
  55. * @return int
  56. */
  57. function getAssocType() {
  58. return $this->getData('assocType');
  59. }
  60. /**
  61. * Set assoc type for this annoucement.
  62. * @param $assocType int
  63. */
  64. function setAssocType($assocType) {
  65. return $this->setData('assocType', $assocType);
  66. }
  67. /**
  68. * Get the announcement type of the announcement.
  69. * @return int
  70. */
  71. function getTypeId() {
  72. return $this->getData('typeId');
  73. }
  74. /**
  75. * Set the announcement type of the announcement.
  76. * @param $typeId int
  77. */
  78. function setTypeId($typeId) {
  79. return $this->setData('typeId', $typeId);
  80. }
  81. /**
  82. * Get the announcement type name of the announcement.
  83. * @return string
  84. */
  85. function getAnnouncementTypeName() {
  86. $announcementTypeDao =& DAORegistry::getDAO('AnnouncementTypeDAO');
  87. return $announcementTypeDao->getAnnouncementTypeName($this->getData('typeId'));
  88. }
  89. /**
  90. * Get localized announcement title
  91. * @return string
  92. */
  93. function getLocalizedTitle() {
  94. return $this->getLocalizedData('title');
  95. }
  96. function getAnnouncementTitle() {
  97. if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
  98. return $this->getLocalizedTitle();
  99. }
  100. /**
  101. * Get full localized announcement title including type name
  102. * @return string
  103. */
  104. function getLocalizedTitleFull() {
  105. $typeName = $this->getAnnouncementTypeName();
  106. $title = $this->getAnnouncementTitle();
  107. if (!empty($typeName)) {
  108. return $typeName . ': ' . $title;
  109. } else {
  110. return $title;
  111. }
  112. }
  113. function getAnnouncementTitleFull() {
  114. if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
  115. return $this->getLocalizedTitleFull();
  116. }
  117. /**
  118. * Get announcement title.
  119. * @param $locale
  120. * @return string
  121. */
  122. function getTitle($locale) {
  123. return $this->getData('title', $locale);
  124. }
  125. /**
  126. * Set announcement title.
  127. * @param $title string
  128. * @param $locale string
  129. */
  130. function setTitle($title, $locale) {
  131. return $this->setData('title', $title, $locale);
  132. }
  133. /**
  134. * Get localized short description
  135. * @return string
  136. */
  137. function getLocalizedDescriptionShort() {
  138. return $this->getLocalizedData('descriptionShort');
  139. }
  140. function getAnnouncementDescriptionShort() {
  141. if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
  142. return $this->getLocalizedDescriptionShort();
  143. }
  144. /**
  145. * Get announcement brief description.
  146. * @param $locale string
  147. * @return string
  148. */
  149. function getDescriptionShort($locale) {
  150. return $this->getData('descriptionShort', $locale);
  151. }
  152. /**
  153. * Set announcement brief description.
  154. * @param $descriptionShort string
  155. * @param $locale string
  156. */
  157. function setDescriptionShort($descriptionShort, $locale) {
  158. return $this->setData('descriptionShort', $descriptionShort, $locale);
  159. }
  160. /**
  161. * Get localized full description
  162. * @return string
  163. */
  164. function getLocalizedDescription() {
  165. return $this->getLocalizedData('description');
  166. }
  167. function getAnnouncementDescription() {
  168. if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
  169. return $this->getLocalizedDescription();
  170. }
  171. /**
  172. * Get announcement description.
  173. * @param $locale string
  174. * @return string
  175. */
  176. function getDescription($locale) {
  177. return $this->getData('description', $locale);
  178. }
  179. /**
  180. * Set announcement description.
  181. * @param $description string
  182. * @param $locale string
  183. */
  184. function setDescription($description, $locale) {
  185. return $this->setData('description', $description, $locale);
  186. }
  187. /**
  188. * Get announcement expiration date.
  189. * @return date (YYYY-MM-DD)
  190. */
  191. function getDateExpire() {
  192. return $this->getData('dateExpire');
  193. }
  194. /**
  195. * Set announcement expiration date.
  196. * @param $dateExpire date (YYYY-MM-DD)
  197. */
  198. function setDateExpire($dateExpire) {
  199. return $this->setData('dateExpire', $dateExpire);
  200. }
  201. /**
  202. * Get announcement posted date.
  203. * @return date (YYYY-MM-DD)
  204. */
  205. function getDatePosted() {
  206. return date('Y-m-d', strtotime($this->getData('datePosted')));
  207. }
  208. /**
  209. * Get announcement posted datetime.
  210. * @return datetime (YYYY-MM-DD HH:MM:SS)
  211. */
  212. function getDatetimePosted() {
  213. return $this->getData('datePosted');
  214. }
  215. /**
  216. * Set announcement posted date.
  217. * @param $datePosted date (YYYY-MM-DD)
  218. */
  219. function setDatePosted($datePosted) {
  220. return $this->setData('datePosted', $datePosted);
  221. }
  222. /**
  223. * Set announcement posted datetime.
  224. * @param $datetimePosted date (YYYY-MM-DD HH:MM:SS)
  225. */
  226. function setDatetimePosted($datetimePosted) {
  227. return $this->setData('datePosted', $datetimePosted);
  228. }
  229. }
  230. ?>