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

/drupal/sites/all/modules/civicrm/CRM/Event/DAO/ParticipantStatusType.php

https://github.com/michaelmcandrew/vaw
PHP | 331 lines | 160 code | 0 blank | 171 comment | 11 complexity | 5be2e3efe593261555f18dd8bacddb04 MD5 | raw file
  1. <?php
  2. /*
  3. +--------------------------------------------------------------------+
  4. | CiviCRM version 3.4 |
  5. +--------------------------------------------------------------------+
  6. | Copyright CiviCRM LLC (c) 2004-2011 |
  7. +--------------------------------------------------------------------+
  8. | This file is a part of CiviCRM. |
  9. | |
  10. | CiviCRM is free software; you can copy, modify, and distribute it |
  11. | under the terms of the GNU Affero General Public License |
  12. | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
  13. | |
  14. | CiviCRM is distributed in the hope that it will be useful, but |
  15. | WITHOUT ANY WARRANTY; without even the implied warranty of |
  16. | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
  17. | See the GNU Affero General Public License for more details. |
  18. | |
  19. | You should have received a copy of the GNU Affero General Public |
  20. | License and the CiviCRM Licensing Exception along |
  21. | with this program; if not, contact CiviCRM LLC |
  22. | at info[AT]civicrm[DOT]org. If you have questions about the |
  23. | GNU Affero General Public License or the licensing of CiviCRM, |
  24. | see the CiviCRM license FAQ at http://civicrm.org/licensing |
  25. +--------------------------------------------------------------------+
  26. */
  27. /**
  28. *
  29. * @package CRM
  30. * @copyright CiviCRM LLC (c) 2004-2011
  31. * $Id$
  32. *
  33. */
  34. require_once 'CRM/Core/DAO.php';
  35. require_once 'CRM/Utils/Type.php';
  36. class CRM_Event_DAO_ParticipantStatusType extends CRM_Core_DAO
  37. {
  38. /**
  39. * static instance to hold the table name
  40. *
  41. * @var string
  42. * @static
  43. */
  44. static $_tableName = 'civicrm_participant_status_type';
  45. /**
  46. * static instance to hold the field values
  47. *
  48. * @var array
  49. * @static
  50. */
  51. static $_fields = null;
  52. /**
  53. * static instance to hold the FK relationships
  54. *
  55. * @var string
  56. * @static
  57. */
  58. static $_links = null;
  59. /**
  60. * static instance to hold the values that can
  61. * be imported / apu
  62. *
  63. * @var array
  64. * @static
  65. */
  66. static $_import = null;
  67. /**
  68. * static instance to hold the values that can
  69. * be exported / apu
  70. *
  71. * @var array
  72. * @static
  73. */
  74. static $_export = null;
  75. /**
  76. * static value to see if we should log any modifications to
  77. * this table in the civicrm_log table
  78. *
  79. * @var boolean
  80. * @static
  81. */
  82. static $_log = true;
  83. /**
  84. * unique participant status type id
  85. *
  86. * @var int unsigned
  87. */
  88. public $id;
  89. /**
  90. * non-localized name of the status type
  91. *
  92. * @var string
  93. */
  94. public $name;
  95. /**
  96. * localized label for display of this status type
  97. *
  98. * @var string
  99. */
  100. public $label;
  101. /**
  102. * the general group of status type this one belongs to
  103. *
  104. * @var enum('Positive', 'Pending', 'Waiting', 'Negative')
  105. */
  106. public $class;
  107. /**
  108. * whether this is a status type required by the system
  109. *
  110. * @var boolean
  111. */
  112. public $is_reserved;
  113. /**
  114. * whether this status type is active
  115. *
  116. * @var boolean
  117. */
  118. public $is_active;
  119. /**
  120. * whether this status type is counted against event size limit
  121. *
  122. * @var boolean
  123. */
  124. public $is_counted;
  125. /**
  126. * controls sort order
  127. *
  128. * @var int unsigned
  129. */
  130. public $weight;
  131. /**
  132. * whether the status type is visible to the public, an implicit foreign key to option_value.value related to the `visibility` option_group
  133. *
  134. * @var int unsigned
  135. */
  136. public $visibility_id;
  137. /**
  138. * class constructor
  139. *
  140. * @access public
  141. * @return civicrm_participant_status_type
  142. */
  143. function __construct()
  144. {
  145. parent::__construct();
  146. }
  147. /**
  148. * returns all the column names of this table
  149. *
  150. * @access public
  151. * @return array
  152. */
  153. function &fields()
  154. {
  155. if (!(self::$_fields)) {
  156. self::$_fields = array(
  157. 'id' => array(
  158. 'name' => 'id',
  159. 'type' => CRM_Utils_Type::T_INT,
  160. 'required' => true,
  161. ) ,
  162. 'participant_status' => array(
  163. 'name' => 'name',
  164. 'type' => CRM_Utils_Type::T_STRING,
  165. 'title' => ts('Participant Status') ,
  166. 'maxlength' => 64,
  167. 'size' => CRM_Utils_Type::BIG,
  168. 'import' => true,
  169. 'where' => 'civicrm_participant_status_type.name',
  170. 'headerPattern' => '',
  171. 'dataPattern' => '',
  172. 'export' => true,
  173. ) ,
  174. 'label' => array(
  175. 'name' => 'label',
  176. 'type' => CRM_Utils_Type::T_STRING,
  177. 'title' => ts('Label') ,
  178. 'maxlength' => 255,
  179. 'size' => CRM_Utils_Type::HUGE,
  180. ) ,
  181. 'class' => array(
  182. 'name' => 'class',
  183. 'type' => CRM_Utils_Type::T_ENUM,
  184. 'title' => ts('Class') ,
  185. 'enumValues' => 'Positive, Pending, Waiting, Negative',
  186. ) ,
  187. 'is_reserved' => array(
  188. 'name' => 'is_reserved',
  189. 'type' => CRM_Utils_Type::T_BOOLEAN,
  190. ) ,
  191. 'is_active' => array(
  192. 'name' => 'is_active',
  193. 'type' => CRM_Utils_Type::T_BOOLEAN,
  194. 'default' => '',
  195. ) ,
  196. 'is_counted' => array(
  197. 'name' => 'is_counted',
  198. 'type' => CRM_Utils_Type::T_BOOLEAN,
  199. ) ,
  200. 'weight' => array(
  201. 'name' => 'weight',
  202. 'type' => CRM_Utils_Type::T_INT,
  203. 'title' => ts('Weight') ,
  204. 'required' => true,
  205. ) ,
  206. 'visibility_id' => array(
  207. 'name' => 'visibility_id',
  208. 'type' => CRM_Utils_Type::T_INT,
  209. ) ,
  210. );
  211. }
  212. return self::$_fields;
  213. }
  214. /**
  215. * returns the names of this table
  216. *
  217. * @access public
  218. * @return string
  219. */
  220. function getTableName()
  221. {
  222. global $dbLocale;
  223. return self::$_tableName . $dbLocale;
  224. }
  225. /**
  226. * returns if this table needs to be logged
  227. *
  228. * @access public
  229. * @return boolean
  230. */
  231. function getLog()
  232. {
  233. return self::$_log;
  234. }
  235. /**
  236. * returns the list of fields that can be imported
  237. *
  238. * @access public
  239. * return array
  240. */
  241. function &import($prefix = false)
  242. {
  243. if (!(self::$_import)) {
  244. self::$_import = array();
  245. $fields = & self::fields();
  246. foreach($fields as $name => $field) {
  247. if (CRM_Utils_Array::value('import', $field)) {
  248. if ($prefix) {
  249. self::$_import['participant_status_type'] = & $fields[$name];
  250. } else {
  251. self::$_import[$name] = & $fields[$name];
  252. }
  253. }
  254. }
  255. }
  256. return self::$_import;
  257. }
  258. /**
  259. * returns the list of fields that can be exported
  260. *
  261. * @access public
  262. * return array
  263. */
  264. function &export($prefix = false)
  265. {
  266. if (!(self::$_export)) {
  267. self::$_export = array();
  268. $fields = & self::fields();
  269. foreach($fields as $name => $field) {
  270. if (CRM_Utils_Array::value('export', $field)) {
  271. if ($prefix) {
  272. self::$_export['participant_status_type'] = & $fields[$name];
  273. } else {
  274. self::$_export[$name] = & $fields[$name];
  275. }
  276. }
  277. }
  278. }
  279. return self::$_export;
  280. }
  281. /**
  282. * returns an array containing the enum fields of the civicrm_participant_status_type table
  283. *
  284. * @return array (reference) the array of enum fields
  285. */
  286. static function &getEnums()
  287. {
  288. static $enums = array(
  289. 'class',
  290. );
  291. return $enums;
  292. }
  293. /**
  294. * returns a ts()-translated enum value for display purposes
  295. *
  296. * @param string $field the enum field in question
  297. * @param string $value the enum value up for translation
  298. *
  299. * @return string the display value of the enum
  300. */
  301. static function tsEnum($field, $value)
  302. {
  303. static $translations = null;
  304. if (!$translations) {
  305. $translations = array(
  306. 'class' => array(
  307. 'Positive' => ts('Positive') ,
  308. 'Pending' => ts('Pending') ,
  309. 'Waiting' => ts('Waiting') ,
  310. 'Negative' => ts('Negative') ,
  311. ) ,
  312. );
  313. }
  314. return $translations[$field][$value];
  315. }
  316. /**
  317. * adds $value['foo_display'] for each $value['foo'] enum from civicrm_participant_status_type
  318. *
  319. * @param array $values (reference) the array up for enhancing
  320. * @return void
  321. */
  322. static function addDisplayEnums(&$values)
  323. {
  324. $enumFields = & CRM_Event_DAO_ParticipantStatusType::getEnums();
  325. foreach($enumFields as $enum) {
  326. if (isset($values[$enum])) {
  327. $values[$enum . '_display'] = CRM_Event_DAO_ParticipantStatusType::tsEnum($enum, $values[$enum]);
  328. }
  329. }
  330. }
  331. }