3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
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-2015
37 * This class holds all the Pseudo constants that are specific for CiviCase.
40 class CRM_Case_PseudoConstant
extends CRM_Core_PseudoConstant
{
46 static $caseStatus = array();
52 static $redactionRule;
58 static $caseType = array();
64 static $encounterMedium = array();
70 static $activityTypeList = array();
73 * Get all the case statues.
76 * @param string $column
77 * @param bool $onlyActive
78 * @param null $condition
82 * array reference of all case statues
84 public static function caseStatus($column = 'label', $onlyActive = TRUE, $condition = NULL, $fresh = FALSE) {
85 $cacheKey = "{$column}_" . (int) $onlyActive;
87 $condition = 'AND filter = 0';
90 if (!isset(self
::$caseStatus[$cacheKey]) ||
$fresh) {
91 self
::$caseStatus[$cacheKey] = CRM_Core_OptionGroup
::values('case_status',
92 FALSE, FALSE, FALSE, $condition,
93 $column, $onlyActive, $fresh
97 return self
::$caseStatus[$cacheKey];
101 * Get all the redaction rules.
104 * @param null $filter
107 * array reference of all redaction rules
109 public static function redactionRule($filter = NULL) {
110 // if ( ! self::$redactionRule ) {
111 self
::$redactionRule = array();
114 $condition = " AND (v.filter = 0 OR v.filter IS NULL)";
116 elseif ($filter === 1) {
117 $condition = " AND v.filter = 1";
119 elseif ($filter === NULL) {
123 self
::$redactionRule = CRM_Core_OptionGroup
::values('redaction_rule', TRUE, FALSE, FALSE, $condition);
125 return self
::$redactionRule;
129 * Get all the case type.
132 * @param string $column
133 * @param bool $onlyActive
136 * array reference of all case type
138 public static function caseType($column = 'title', $onlyActive = TRUE) {
140 $condition = " is_active = 1 ";
146 // FIXME: deprecated?
147 CRM_Core_PseudoConstant
::populate(
149 'CRM_Case_DAO_CaseType',
162 * Get all the Encounter Medium.
165 * @param string $column
166 * @param bool $onlyActive
169 * array reference of all Encounter Medium.
171 public static function encounterMedium($column = 'label', $onlyActive = TRUE) {
172 $cacheKey = "{$column}_" . (int) $onlyActive;
173 if (!isset(self
::$encounterMedium[$cacheKey])) {
174 self
::$encounterMedium[$cacheKey] = CRM_Core_OptionGroup
::values('encounter_medium',
175 FALSE, FALSE, FALSE, NULL,
180 return self
::$encounterMedium[$cacheKey];
184 * Get all Activity types for the CiviCase component.
186 * The static array activityType is returned
188 * @param bool $indexName
189 * True return activity name in array.
190 * key else activity id as array key.
196 * array reference of all activity types.
198 public static function &caseActivityType($indexName = TRUE, $all = FALSE) {
199 $cache = (int) $indexName . '_' . (int) $all;
201 if (!array_key_exists($cache, self
::$activityTypeList)) {
202 self
::$activityTypeList[$cache] = array();
205 SELECT v.label as label ,v.value as value, v.name as name, v.description as description
206 FROM civicrm_option_value v,
207 civicrm_option_group g
208 WHERE v.option_group_id = g.id
209 AND g.name = 'activity_type'
211 AND g.is_active = 1";
214 $componentId = CRM_Core_DAO
::getFieldValue('CRM_Core_DAO_Component',
218 $query .= " AND v.component_id = {$componentId} ";
221 $query .= " ORDER BY v.weight";
223 $dao = CRM_Core_DAO
::executeQuery($query);
225 $activityTypes = array();
226 while ($dao->fetch()) {
231 $index = $dao->value
;
233 $activityTypes[$index] = array();
234 $activityTypes[$index]['id'] = $dao->value
;
235 $activityTypes[$index]['label'] = $dao->label
;
236 $activityTypes[$index]['name'] = $dao->name
;
237 $activityTypes[$index]['description'] = $dao->description
;
239 self
::$activityTypeList[$cache] = $activityTypes;
241 return self
::$activityTypeList[$cache];
245 * Flush given pseudoconstant so it can be reread from db
246 * next time it's requested.
249 * @param bool|string $name pseudoconstant to be flushed
251 public static function flush($name = 'cache') {
252 if (isset(self
::$
$name)) {