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 ";
151 // FIXME: deprecated?
152 CRM_Core_PseudoConstant
::populate(
154 'CRM_Case_DAO_CaseType',
167 * Get all the Encounter Medium
170 * @param string $column
171 * @param bool $onlyActive
173 * @return array - array reference of all Encounter Medium.
176 public static function encounterMedium($column = 'label', $onlyActive = TRUE) {
177 $cacheKey = "{$column}_" . (int) $onlyActive;
178 if (!isset(self
::$encounterMedium[$cacheKey])) {
179 self
::$encounterMedium[$cacheKey] = CRM_Core_OptionGroup
::values('encounter_medium',
180 FALSE, FALSE, FALSE, NULL,
185 return self
::$encounterMedium[$cacheKey];
189 * Get all Activty types for the CiviCase component
191 * The static array activityType is returned
193 * @param bool $indexName
194 * True return activity name in array.
195 * key else activity id as array key.
201 * @return array - array reference of all activity types.
203 public static function &caseActivityType($indexName = TRUE, $all = FALSE) {
204 $cache = (int) $indexName . '_' . (int) $all;
206 if (!array_key_exists($cache, self
::$activityTypeList)) {
207 self
::$activityTypeList[$cache] = array();
210 SELECT v.label as label ,v.value as value, v.name as name, v.description as description
211 FROM civicrm_option_value v,
212 civicrm_option_group g
213 WHERE v.option_group_id = g.id
214 AND g.name = 'activity_type'
216 AND g.is_active = 1";
219 $componentId = CRM_Core_DAO
::getFieldValue('CRM_Core_DAO_Component',
223 $query .= " AND v.component_id = {$componentId} ";
226 $query .= " ORDER BY v.weight";
228 $dao = CRM_Core_DAO
::executeQuery($query);
230 $activityTypes = array();
231 while ($dao->fetch()) {
236 $index = $dao->value
;
238 $activityTypes[$index] = array();
239 $activityTypes[$index]['id'] = $dao->value
;
240 $activityTypes[$index]['label'] = $dao->label
;
241 $activityTypes[$index]['name'] = $dao->name
;
242 $activityTypes[$index]['description'] = $dao->description
;
244 self
::$activityTypeList[$cache] = $activityTypes;
246 return self
::$activityTypeList[$cache];
250 * Flush given pseudoconstant so it can be reread from db
251 * next time it's requested.
255 * @param bool|string $name pseudoconstant to be flushed
257 public static function flush($name = 'cache') {
258 if (isset(self
::$
$name)) {