3 +--------------------------------------------------------------------+
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2018 |
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-2018
35 * This class holds all the Pseudo constants that are specific for CiviCase.
37 class CRM_Case_PseudoConstant
extends CRM_Core_PseudoConstant
{
43 static $activityTypeList = array();
46 * Get all the case statues.
49 * @param string $column
50 * @param bool $onlyActive
51 * @param null $condition
55 * array reference of all case statues
57 public static function caseStatus($column = 'label', $onlyActive = TRUE, $condition = NULL, $fresh = FALSE) {
59 $condition = 'AND filter = 0';
62 return CRM_Core_OptionGroup
::values('case_status',
63 FALSE, FALSE, FALSE, $condition,
64 $column, $onlyActive, $fresh
70 * Get all the redaction rules.
76 * array reference of all redaction rules
78 public static function redactionRule($filter = NULL) {
81 $condition = " AND (v.filter = 0 OR v.filter IS NULL)";
83 elseif ($filter === 1) {
84 $condition = " AND v.filter = 1";
87 return CRM_Core_OptionGroup
::values('redaction_rule', TRUE, FALSE, FALSE, $condition);
91 * Get all the case type.
94 * @param string $column
95 * @param bool $onlyActive
98 * array reference of all case type
100 public static function caseType($column = 'title', $onlyActive = TRUE) {
102 $condition = " is_active = 1 ";
108 // FIXME: deprecated?
109 CRM_Core_PseudoConstant
::populate(
111 'CRM_Case_DAO_CaseType',
124 * Get all the Encounter Medium.
127 * @param string $column
128 * @param bool $onlyActive
131 * array reference of all Encounter Medium.
133 public static function encounterMedium($column = 'label', $onlyActive = TRUE) {
134 return CRM_Core_OptionGroup
::values('encounter_medium',
135 FALSE, FALSE, FALSE, NULL,
141 * Get all Activity types for the CiviCase component.
143 * The static array activityType is returned
145 * @param bool $indexName
146 * True return activity name in array.
147 * key else activity id as array key.
153 * array reference of all activity types.
155 public static function &caseActivityType($indexName = TRUE, $all = FALSE) {
156 $cache = (int) $indexName . '_' . (int) $all;
158 if (!array_key_exists($cache, self
::$activityTypeList)) {
159 self
::$activityTypeList[$cache] = array();
162 SELECT v.label as label ,v.value as value, v.name as name, v.description as description, v.icon
163 FROM civicrm_option_value v,
164 civicrm_option_group g
165 WHERE v.option_group_id = g.id
166 AND g.name = 'activity_type'
168 AND g.is_active = 1";
171 $componentId = CRM_Core_DAO
::getFieldValue('CRM_Core_DAO_Component',
175 $query .= " AND v.component_id = {$componentId} ";
178 $query .= " ORDER BY v.weight";
180 $dao = CRM_Core_DAO
::executeQuery($query);
182 $activityTypes = array();
183 while ($dao->fetch()) {
188 $index = $dao->value
;
190 $activityTypes[$index] = array();
191 $activityTypes[$index]['id'] = $dao->value
;
192 $activityTypes[$index]['label'] = $dao->label
;
193 $activityTypes[$index]['name'] = $dao->name
;
194 $activityTypes[$index]['icon'] = $dao->icon
;
195 $activityTypes[$index]['description'] = $dao->description
;
197 self
::$activityTypeList[$cache] = $activityTypes;
199 return self
::$activityTypeList[$cache];
203 * Flush given pseudoconstant so it can be reread from db
204 * next time it's requested.
207 * @param bool|string $name pseudoconstant to be flushed
209 public static function flush($name = 'cache') {
210 if (isset(self
::$
$name)) {