3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
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 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();
78 * Get all the case statues
81 * @param string $column
82 * @param bool $onlyActive
83 * @param null $condition
86 * @return array - array reference of all case statues
89 public static function caseStatus($column = 'label', $onlyActive = TRUE, $condition = NULL, $fresh = FALSE) {
90 $cacheKey = "{$column}_" . (int) $onlyActive;
92 $condition = 'AND filter = 0';
95 if (!isset(self
::$caseStatus[$cacheKey]) ||
$fresh) {
96 self
::$caseStatus[$cacheKey] = CRM_Core_OptionGroup
::values('case_status',
97 FALSE, FALSE, FALSE, $condition,
98 $column, $onlyActive, $fresh
102 return self
::$caseStatus[$cacheKey];
106 * Get all the redaction rules
109 * @param null $filter
111 * @return array - array reference of all redaction rules
115 public static function redactionRule($filter = NULL) {
116 // if ( ! self::$redactionRule ) {
117 self
::$redactionRule = array();
120 $condition = " AND (v.filter = 0 OR v.filter IS NULL)";
122 elseif ($filter === 1) {
123 $condition = " AND v.filter = 1";
125 elseif ($filter === NULL) {
129 self
::$redactionRule = CRM_Core_OptionGroup
::values('redaction_rule', TRUE, FALSE, FALSE, $condition);
131 return self
::$redactionRule;
135 * Get all the case type
138 * @param string $column
139 * @param bool $onlyActive
141 * @return array - array reference of all case type
144 public static function caseType($column = 'title', $onlyActive = TRUE) {
146 $condition = " is_active = 1 ";
152 // FIXME: deprecated?
153 CRM_Core_PseudoConstant
::populate(
155 'CRM_Case_DAO_CaseType',
168 * Get all the Encounter Medium
171 * @param string $column
172 * @param bool $onlyActive
174 * @return array - array reference of all Encounter Medium.
177 public static function encounterMedium($column = 'label', $onlyActive = TRUE) {
178 $cacheKey = "{$column}_" . (int) $onlyActive;
179 if (!isset(self
::$encounterMedium[$cacheKey])) {
180 self
::$encounterMedium[$cacheKey] = CRM_Core_OptionGroup
::values('encounter_medium',
181 FALSE, FALSE, FALSE, NULL,
186 return self
::$encounterMedium[$cacheKey];
190 * Get all Activty types for the CiviCase component
192 * The static array activityType is returned
194 * @param bool $indexName
195 * True return activity name in array.
196 * key else activity id as array key.
202 * @return array - array reference of all activity types.
204 public static function &caseActivityType($indexName = TRUE, $all = FALSE) {
205 $cache = (int) $indexName . '_' . (int) $all;
207 if (!array_key_exists($cache, self
::$activityTypeList)) {
208 self
::$activityTypeList[$cache] = array();
211 SELECT v.label as label ,v.value as value, v.name as name, v.description as description
212 FROM civicrm_option_value v,
213 civicrm_option_group g
214 WHERE v.option_group_id = g.id
215 AND g.name = 'activity_type'
217 AND g.is_active = 1";
220 $componentId = CRM_Core_DAO
::getFieldValue('CRM_Core_DAO_Component',
224 $query .= " AND v.component_id = {$componentId} ";
227 $query .= " ORDER BY v.weight";
229 $dao = CRM_Core_DAO
::executeQuery($query);
231 $activityTypes = array();
232 while ($dao->fetch()) {
237 $index = $dao->value
;
239 $activityTypes[$index] = array();
240 $activityTypes[$index]['id'] = $dao->value
;
241 $activityTypes[$index]['label'] = $dao->label
;
242 $activityTypes[$index]['name'] = $dao->name
;
243 $activityTypes[$index]['description'] = $dao->description
;
245 self
::$activityTypeList[$cache] = $activityTypes;
247 return self
::$activityTypeList[$cache];
251 * Flush given pseudoconstant so it can be reread from db
252 * next time it's requested.
256 * @param bool|string $name pseudoconstant to be flushed
258 public static function flush($name = 'cache') {
259 if (isset(self
::$
$name)) {