3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.3 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
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-2013
37 * This class holds all the Pseudo constants that are specific for CiviCase.
40 class CRM_Case_PseudoConstant
extends CRM_Core_PseudoConstant
{
47 static $caseStatus = array();
54 static $redactionRule;
61 static $caseType = array();
68 static $encounterMedium = array();
75 static $activityTypeList = array();
82 static $caseTypePair = array();
85 * Get all the case statues
89 * @return array - array reference of all case statues
92 public static function caseStatus($column = 'label', $onlyActive = TRUE) {
93 $cacheKey = "{$column}_" . (int)$onlyActive;
94 if (!isset(self
::$caseStatus[$cacheKey])) {
95 self
::$caseStatus[$cacheKey] = CRM_Core_OptionGroup
::values('case_status',
96 FALSE, FALSE, FALSE, NULL,
101 return self
::$caseStatus[$cacheKey];
105 * Get all the redaction rules
109 * @return array - array reference of all redaction rules
113 public static function redactionRule($filter = NULL) {
114 // if ( ! self::$redactionRule ) {
115 self
::$redactionRule = array();
118 $condition = " AND (v.filter = 0 OR v.filter IS NULL)";
120 elseif ($filter === 1) {
121 $condition = " AND v.filter = 1";
123 elseif ($filter === NULL) {
127 self
::$redactionRule = CRM_Core_OptionGroup
::values('redaction_rule', TRUE, FALSE, FALSE, $condition);
129 return self
::$redactionRule;
133 * Get all the case type
137 * @return array - array reference of all case type
140 public static function caseType($column = 'label', $onlyActive = TRUE) {
141 $cacheKey = "{$column}_" . (int)$onlyActive;
142 if (!isset(self
::$caseType[$cacheKey])) {
143 self
::$caseType[$cacheKey] = CRM_Core_OptionGroup
::values('case_type',
144 FALSE, FALSE, FALSE, NULL,
149 return self
::$caseType[$cacheKey];
153 * Get all the Encounter Medium
157 * @return array - array reference of all Encounter Medium.
160 public static function encounterMedium($column = 'label', $onlyActive = TRUE) {
161 $cacheKey = "{$column}_" . (int)$onlyActive;
162 if (!isset(self
::$encounterMedium[$cacheKey])) {
163 self
::$encounterMedium[$cacheKey] = CRM_Core_OptionGroup
::values('encounter_medium',
164 FALSE, FALSE, FALSE, NULL,
169 return self
::$encounterMedium[$cacheKey];
173 * Get all Activty types for the CiviCase component
175 * The static array activityType is returned
177 * @param boolean $indexName - true return activity name in array
178 * key else activity id as array key.
183 * @return array - array reference of all activty types.
185 public static function &caseActivityType($indexName = TRUE, $all = FALSE) {
186 $cache = (int) $indexName . '_' . (int) $all;
188 if (!array_key_exists($cache, self
::$activityTypeList)) {
189 self
::$activityTypeList[$cache] = array();
192 SELECT v.label as label ,v.value as value, v.name as name, v.description as description
193 FROM civicrm_option_value v,
194 civicrm_option_group g
195 WHERE v.option_group_id = g.id
196 AND g.name = 'activity_type'
198 AND g.is_active = 1";
201 $componentId = CRM_Core_DAO
::getFieldValue('CRM_Core_DAO_Component',
205 $query .= " AND v.component_id = {$componentId} ";
208 $query .= " ORDER BY v.weight";
210 $dao = CRM_Core_DAO
::executeQuery($query);
212 $activityTypes = array();
213 while ($dao->fetch()) {
218 $index = $dao->value
;
220 $activityTypes[$index] = array();
221 $activityTypes[$index]['id'] = $dao->value
;
222 $activityTypes[$index]['label'] = $dao->label
;
223 $activityTypes[$index]['name'] = $dao->name
;
224 $activityTypes[$index]['description'] = $dao->description
;
226 self
::$activityTypeList[$cache] = $activityTypes;
228 return self
::$activityTypeList[$cache];
232 * Get the associated case type name/id, given a case Id
236 * @return array - array reference of all case type name/id
239 public static function caseTypeName($caseId, $column = 'name') {
244 if (!array_key_exists($caseId, self
::$caseTypePair) ||
empty(self
::$caseTypePair[$caseId][$column])) {
245 $caseTypes = self
::caseType($column);
246 $caseTypeIds = CRM_Core_DAO
::getFieldValue('CRM_Case_DAO_Case',
250 $caseTypeId = explode(CRM_Core_DAO
::VALUE_SEPARATOR
,
252 CRM_Core_DAO
::VALUE_SEPARATOR
255 $caseTypeId = $caseTypeId[0];
257 self
::$caseTypePair[$caseId][$column] = array(
259 'name' => $caseTypes[$caseTypeId],
263 return self
::$caseTypePair[$caseId][$column];
267 * Flush given pseudoconstant so it can be reread from db
268 * next time it's requested.
273 * @param boolean $name pseudoconstant to be flushed
276 public static function flush($name = 'cache') {
277 if (isset(self
::$
$name)) {