/drupal/sites/all/modules/civicrm/CRM/Project/DAO/TaskStatus.php

https://github.com/michaelmcandrew/lbc · PHP · 307 lines · 144 code · 0 blank · 163 comment · 10 complexity · 3c2a01d6ce9b2733b01b088213698280 MD5 · raw file

  1. <?php
  2. /*
  3. +--------------------------------------------------------------------+
  4. | CiviCRM version 4.1 |
  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_Project_DAO_TaskStatus 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_task_status';
  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
  62. *
  63. * @var array
  64. * @static
  65. */
  66. static $_import = null;
  67. /**
  68. * static instance to hold the values that can
  69. * be exported
  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. * Task ID
  85. *
  86. * @var int unsigned
  87. */
  88. public $id;
  89. /**
  90. * Status is for which task.
  91. *
  92. * @var int unsigned
  93. */
  94. public $task_id;
  95. /**
  96. * Entity responsible for this task_status instance (table where entity is stored e.g. civicrm_contact or civicrm_group).
  97. *
  98. * @var string
  99. */
  100. public $responsible_entity_table;
  101. /**
  102. * Foreign key to responsible entity (contact, group, etc.).
  103. *
  104. * @var int unsigned
  105. */
  106. public $responsible_entity_id;
  107. /**
  108. * Optional target entity for this task_status instance, i.e. review this membership application-prospect member contact record is target (table where entity is stored e.g. civicrm_contact or civicrm_group).
  109. *
  110. * @var string
  111. */
  112. public $target_entity_table;
  113. /**
  114. * Foreign key to target entity (contact, group, etc.).
  115. *
  116. * @var int unsigned
  117. */
  118. public $target_entity_id;
  119. /**
  120. * Encoded array of status details used for programmatic progress reporting and tracking.
  121. *
  122. * @var text
  123. */
  124. public $status_detail;
  125. /**
  126. * Configurable status value (e.g. Not Started, In Progress, Completed, Deferred...). FK to civicrm_option_value.
  127. *
  128. * @var int unsigned
  129. */
  130. public $status_id;
  131. /**
  132. * Date this record was created (date work on task started).
  133. *
  134. * @var datetime
  135. */
  136. public $create_date;
  137. /**
  138. * Date-time of last update to this task_status record.
  139. *
  140. * @var datetime
  141. */
  142. public $modified_date;
  143. /**
  144. * class constructor
  145. *
  146. * @access public
  147. * @return civicrm_task_status
  148. */
  149. function __construct()
  150. {
  151. parent::__construct();
  152. }
  153. /**
  154. * return foreign links
  155. *
  156. * @access public
  157. * @return array
  158. */
  159. function &links()
  160. {
  161. if (!(self::$_links)) {
  162. self::$_links = array(
  163. 'task_id' => 'civicrm_task:id',
  164. );
  165. }
  166. return self::$_links;
  167. }
  168. /**
  169. * returns all the column names of this table
  170. *
  171. * @access public
  172. * @return array
  173. */
  174. function &fields()
  175. {
  176. if (!(self::$_fields)) {
  177. self::$_fields = array(
  178. 'id' => array(
  179. 'name' => 'id',
  180. 'type' => CRM_Utils_Type::T_INT,
  181. 'required' => true,
  182. ) ,
  183. 'task_id' => array(
  184. 'name' => 'task_id',
  185. 'type' => CRM_Utils_Type::T_INT,
  186. 'required' => true,
  187. 'FKClassName' => 'CRM_Project_DAO_Task',
  188. ) ,
  189. 'responsible_entity_table' => array(
  190. 'name' => 'responsible_entity_table',
  191. 'type' => CRM_Utils_Type::T_STRING,
  192. 'title' => ts('Responsible Entity Table') ,
  193. 'required' => true,
  194. 'maxlength' => 64,
  195. 'size' => CRM_Utils_Type::BIG,
  196. ) ,
  197. 'responsible_entity_id' => array(
  198. 'name' => 'responsible_entity_id',
  199. 'type' => CRM_Utils_Type::T_INT,
  200. 'title' => ts('Responsible') ,
  201. 'required' => true,
  202. ) ,
  203. 'target_entity_table' => array(
  204. 'name' => 'target_entity_table',
  205. 'type' => CRM_Utils_Type::T_STRING,
  206. 'title' => ts('Target Entity Table') ,
  207. 'required' => true,
  208. 'maxlength' => 64,
  209. 'size' => CRM_Utils_Type::BIG,
  210. ) ,
  211. 'target_entity_id' => array(
  212. 'name' => 'target_entity_id',
  213. 'type' => CRM_Utils_Type::T_INT,
  214. 'title' => ts('Target') ,
  215. 'required' => true,
  216. ) ,
  217. 'status_detail' => array(
  218. 'name' => 'status_detail',
  219. 'type' => CRM_Utils_Type::T_TEXT,
  220. 'title' => ts('Status Details') ,
  221. ) ,
  222. 'status_id' => array(
  223. 'name' => 'status_id',
  224. 'type' => CRM_Utils_Type::T_INT,
  225. 'title' => ts('Status') ,
  226. ) ,
  227. 'create_date' => array(
  228. 'name' => 'create_date',
  229. 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
  230. 'title' => ts('Created') ,
  231. ) ,
  232. 'modified_date' => array(
  233. 'name' => 'modified_date',
  234. 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
  235. 'title' => ts('Last Modified') ,
  236. ) ,
  237. );
  238. }
  239. return self::$_fields;
  240. }
  241. /**
  242. * returns the names of this table
  243. *
  244. * @access public
  245. * @return string
  246. */
  247. function getTableName()
  248. {
  249. return self::$_tableName;
  250. }
  251. /**
  252. * returns if this table needs to be logged
  253. *
  254. * @access public
  255. * @return boolean
  256. */
  257. function getLog()
  258. {
  259. return self::$_log;
  260. }
  261. /**
  262. * returns the list of fields that can be imported
  263. *
  264. * @access public
  265. * return array
  266. */
  267. function &import($prefix = false)
  268. {
  269. if (!(self::$_import)) {
  270. self::$_import = array();
  271. $fields = self::fields();
  272. foreach($fields as $name => $field) {
  273. if (CRM_Utils_Array::value('import', $field)) {
  274. if ($prefix) {
  275. self::$_import['task_status'] = & $fields[$name];
  276. } else {
  277. self::$_import[$name] = & $fields[$name];
  278. }
  279. }
  280. }
  281. }
  282. return self::$_import;
  283. }
  284. /**
  285. * returns the list of fields that can be exported
  286. *
  287. * @access public
  288. * return array
  289. */
  290. function &export($prefix = false)
  291. {
  292. if (!(self::$_export)) {
  293. self::$_export = array();
  294. $fields = self::fields();
  295. foreach($fields as $name => $field) {
  296. if (CRM_Utils_Array::value('export', $field)) {
  297. if ($prefix) {
  298. self::$_export['task_status'] = & $fields[$name];
  299. } else {
  300. self::$_export[$name] = & $fields[$name];
  301. }
  302. }
  303. }
  304. }
  305. return self::$_export;
  306. }
  307. }