3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
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
35 * This class holds all the Pseudo constants that are specific for CiviCase.
37 class CRM_Case_PseudoConstant
extends CRM_Core_PseudoConstant
{
43 static $caseStatus = array();
49 static $redactionRule;
55 static $caseType = array();
61 static $encounterMedium = array();
67 static $activityTypeList = array();
70 * Get all the case statues.
73 * @param string $column
74 * @param bool $onlyActive
75 * @param null $condition
79 * array reference of all case statues
81 public static function caseStatus($column = 'label', $onlyActive = TRUE, $condition = NULL, $fresh = FALSE) {
82 $cacheKey = "{$column}_" . (int) $onlyActive;
84 $condition = 'AND filter = 0';
87 if (!isset(self
::$caseStatus[$cacheKey]) ||
$fresh) {
88 self
::$caseStatus[$cacheKey] = CRM_Core_OptionGroup
::values('case_status',
89 FALSE, FALSE, FALSE, $condition,
90 $column, $onlyActive, $fresh
94 return self
::$caseStatus[$cacheKey];
98 * Get all the redaction rules.
101 * @param null $filter
104 * array reference of all redaction rules
106 public static function redactionRule($filter = NULL) {
107 // if ( ! self::$redactionRule ) {
108 self
::$redactionRule = array();
111 $condition = " AND (v.filter = 0 OR v.filter IS NULL)";
113 elseif ($filter === 1) {
114 $condition = " AND v.filter = 1";
116 elseif ($filter === NULL) {
120 self
::$redactionRule = CRM_Core_OptionGroup
::values('redaction_rule', TRUE, FALSE, FALSE, $condition);
122 return self
::$redactionRule;
126 * Get all the case type.
129 * @param string $column
130 * @param bool $onlyActive
133 * array reference of all case type
135 public static function caseType($column = 'title', $onlyActive = TRUE) {
137 $condition = " is_active = 1 ";
143 // FIXME: deprecated?
144 CRM_Core_PseudoConstant
::populate(
146 'CRM_Case_DAO_CaseType',
159 * Get all the Encounter Medium.
162 * @param string $column
163 * @param bool $onlyActive
166 * array reference of all Encounter Medium.
168 public static function encounterMedium($column = 'label', $onlyActive = TRUE) {
169 $cacheKey = "{$column}_" . (int) $onlyActive;
170 if (!isset(self
::$encounterMedium[$cacheKey])) {
171 self
::$encounterMedium[$cacheKey] = CRM_Core_OptionGroup
::values('encounter_medium',
172 FALSE, FALSE, FALSE, NULL,
177 return self
::$encounterMedium[$cacheKey];
181 * Get all Activity types for the CiviCase component.
183 * The static array activityType is returned
185 * @param bool $indexName
186 * True return activity name in array.
187 * key else activity id as array key.
193 * array reference of all activity types.
195 public static function &caseActivityType($indexName = TRUE, $all = FALSE) {
196 $cache = (int) $indexName . '_' . (int) $all;
198 if (!array_key_exists($cache, self
::$activityTypeList)) {
199 self
::$activityTypeList[$cache] = array();
202 SELECT v.label as label ,v.value as value, v.name as name, v.description as description
203 FROM civicrm_option_value v,
204 civicrm_option_group g
205 WHERE v.option_group_id = g.id
206 AND g.name = 'activity_type'
208 AND g.is_active = 1";
211 $componentId = CRM_Core_DAO
::getFieldValue('CRM_Core_DAO_Component',
215 $query .= " AND v.component_id = {$componentId} ";
218 $query .= " ORDER BY v.weight";
220 $dao = CRM_Core_DAO
::executeQuery($query);
222 $activityTypes = array();
223 while ($dao->fetch()) {
228 $index = $dao->value
;
230 $activityTypes[$index] = array();
231 $activityTypes[$index]['id'] = $dao->value
;
232 $activityTypes[$index]['label'] = $dao->label
;
233 $activityTypes[$index]['name'] = $dao->name
;
234 $activityTypes[$index]['description'] = $dao->description
;
236 self
::$activityTypeList[$cache] = $activityTypes;
238 return self
::$activityTypeList[$cache];
242 * Flush given pseudoconstant so it can be reread from db
243 * next time it's requested.
246 * @param bool|string $name pseudoconstant to be flushed
248 public static function flush($name = 'cache') {
249 if (isset(self
::$
$name)) {