3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2014
37 * This class contains the functions for Case Type management
40 class CRM_Case_BAO_CaseType
extends CRM_Case_DAO_CaseType
{
43 * static field for all the case information that we can potentially export
48 static $_exportableFields = NULL;
51 * takes an associative array and creates a Case Type object
53 * the function extract all the params it needs to initialize the create a
54 * case type object. the params array could contain additional unused name/value
57 * @param array $params (reference ) an assoc array of name/value pairs
58 * @param array $ids the array that holds all the db ids
60 * @return object CRM_Case_BAO_CaseType object
64 static function add(&$params) {
65 $caseTypeDAO = new CRM_Case_DAO_CaseType();
66 $caseTypeDAO->copyValues($params);
67 return $caseTypeDAO->save();
71 * Given the list of params in the params array, fetch the object
72 * and store the values in the values array
74 * @param array $params input parameters to find object
75 * @param array $values output values of the object
76 * @param array $ids the array that holds all the db ids
78 * @return CRM_Case_BAO_CaseType|null the found object or null
82 static function &getValues(&$params, &$values) {
83 $caseType = new CRM_Case_BAO_CaseType();
85 $caseType->copyValues($params);
87 if ($caseType->find(TRUE)) {
88 CRM_Core_DAO
::storeValues($caseType, $values);
95 * takes an associative array and creates a case type object
97 * @param array $params (reference ) an assoc array of name/value pairs
98 * @param array $ids the array that holds all the db ids
100 * @return object CRM_Case_BAO_CaseType object
104 static function &create(&$params) {
105 $transaction = new CRM_Core_Transaction();
107 if (!empty($params['id'])) {
108 CRM_Utils_Hook
::pre('edit', 'CaseType', $params['id'], $params);
111 CRM_Utils_Hook
::pre('create', 'CaseType', NULL, $params);
114 $caseType = self
::add($params);
116 if (is_a($caseType, 'CRM_Core_Error')) {
117 $transaction->rollback();
121 if (!empty($params['id'])) {
122 CRM_Utils_Hook
::post('edit', 'CaseType', $caseType->id
, $case);
125 CRM_Utils_Hook
::post('create', 'CaseType', $caseType->id
, $case);
127 $transaction->commit();
133 * Takes a bunch of params that are needed to match certain criteria and
134 * retrieves the relevant objects. We'll tweak this function to be more
135 * full featured over a period of time. This is the inverse function of
136 * create. It also stores all the retrieved values in the default array
138 * @param array $params (reference ) an assoc array of name/value pairs
139 * @param array $defaults (reference ) an assoc array to hold the name / value pairs
140 * in a hierarchical manner
141 * @param array $ids (reference) the array that holds all the db ids
143 * @return object CRM_Case_BAO_CaseType object
147 static function retrieve(&$params, &$defaults) {
148 $caseType = CRM_Case_BAO_CaseType
::getValues($params, $defaults);
152 static function del($caseTypeId) {
153 $caseType = new CRM_Case_DAO_CaseType();
154 $caseType->id
= $caseTypeId;
155 return $caseType->delete();