3 +--------------------------------------------------------------------+
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2019 |
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-2019
35 * This class holds all the Pseudo constants that are specific for CiviCase.
37 class CRM_Case_PseudoConstant
extends CRM_Core_PseudoConstant
{
40 * Get all the case statues.
43 * @param string $column
44 * @param bool $onlyActive
45 * @param null $condition
49 * array reference of all case statues
51 public static function caseStatus($column = 'label', $onlyActive = TRUE, $condition = NULL, $fresh = FALSE) {
53 $condition = 'AND filter = 0';
56 return CRM_Core_OptionGroup
::values('case_status',
57 FALSE, FALSE, FALSE, $condition,
58 $column, $onlyActive, $fresh
64 * Get all the redaction rules.
70 * array reference of all redaction rules
72 public static function redactionRule($filter = NULL) {
75 $condition = " AND (v.filter = 0 OR v.filter IS NULL)";
77 elseif ($filter === 1) {
78 $condition = " AND v.filter = 1";
81 return CRM_Core_OptionGroup
::values('redaction_rule', TRUE, FALSE, FALSE, $condition);
85 * Get all the case type.
88 * @param string $column
89 * @param bool $onlyActive
92 * array reference of all case type
94 public static function caseType($column = 'title', $onlyActive = TRUE) {
96 $condition = " is_active = 1 ";
102 // FIXME: deprecated?
103 CRM_Core_PseudoConstant
::populate(
105 'CRM_Case_DAO_CaseType',
118 * Get all the Encounter Medium.
121 * @param string $column
122 * @param bool $onlyActive
125 * array reference of all Encounter Medium.
127 public static function encounterMedium($column = 'label', $onlyActive = TRUE) {
128 return CRM_Core_OptionGroup
::values('encounter_medium',
129 FALSE, FALSE, FALSE, NULL,
135 * Get all Activity types for the CiviCase component.
137 * The static array activityType is returned
139 * @param bool $indexName
140 * True return activity name in array.
141 * key else activity id as array key.
147 * array reference of all activity types.
149 public static function &caseActivityType($indexName = TRUE, $all = FALSE) {
150 $cache = (int) $indexName . '_' . (int) $all;
152 if (!isset(Civi
::$statics[__CLASS__
]['activityTypeList'][$cache])) {
153 Civi
::$statics[__CLASS__
]['activityTypeList'][$cache] = [];
156 SELECT v.label as label ,v.value as value, v.name as name, v.description as description, v.icon
157 FROM civicrm_option_value v,
158 civicrm_option_group g
159 WHERE v.option_group_id = g.id
160 AND g.name = 'activity_type'
162 AND g.is_active = 1";
165 $componentId = CRM_Core_DAO
::getFieldValue('CRM_Core_DAO_Component',
169 $query .= " AND v.component_id = {$componentId} ";
172 $query .= " ORDER BY v.weight";
174 $dao = CRM_Core_DAO
::executeQuery($query);
177 while ($dao->fetch()) {
182 $index = $dao->value
;
184 $activityTypes[$index] = [];
185 $activityTypes[$index]['id'] = $dao->value
;
186 $activityTypes[$index]['label'] = $dao->label
;
187 $activityTypes[$index]['name'] = $dao->name
;
188 $activityTypes[$index]['icon'] = $dao->icon
;
189 $activityTypes[$index]['description'] = $dao->description
;
191 Civi
::$statics[__CLASS__
]['activityTypeList'][$cache] = $activityTypes;
193 return Civi
::$statics[__CLASS__
]['activityTypeList'][$cache];
197 * Flush given pseudoconstant so it can be reread from db
198 * next time it's requested.
201 * @param bool|string $name pseudoconstant to be flushed
203 public static function flush($name = 'cache') {
204 if (isset(self
::$
$name)) {