3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
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
82 * @param string $column
83 * @param bool $onlyActive
84 * @param null $condition
87 * @return array - array reference of all case statues
90 public static function caseStatus($column = 'label', $onlyActive = TRUE, $condition = NULL, $fresh = FALSE) {
91 $cacheKey = "{$column}_" . (int)$onlyActive;
93 $condition = 'AND filter = 0';
96 if (!isset(self
::$caseStatus[$cacheKey]) ||
$fresh) {
97 self
::$caseStatus[$cacheKey] = CRM_Core_OptionGroup
::values('case_status',
98 FALSE, FALSE, FALSE, $condition,
99 $column, $onlyActive, $fresh
103 return self
::$caseStatus[$cacheKey];
107 * Get all the redaction rules
111 * @param null $filter
113 * @return array - array reference of all redaction rules
117 public static function redactionRule($filter = NULL) {
118 // if ( ! self::$redactionRule ) {
119 self
::$redactionRule = array();
122 $condition = " AND (v.filter = 0 OR v.filter IS NULL)";
124 elseif ($filter === 1) {
125 $condition = " AND v.filter = 1";
127 elseif ($filter === NULL) {
131 self
::$redactionRule = CRM_Core_OptionGroup
::values('redaction_rule', TRUE, FALSE, FALSE, $condition);
133 return self
::$redactionRule;
137 * Get all the case type
141 * @param string $column
142 * @param bool $onlyActive
144 * @return array - array reference of all case type
147 public static function caseType($column = 'title', $onlyActive = TRUE) {
149 $condition = " is_active = 1 ";
154 // FIXME: deprecated?
155 CRM_Core_PseudoConstant
::populate(
157 'CRM_Case_DAO_CaseType',
170 * Get all the Encounter Medium
174 * @param string $column
175 * @param bool $onlyActive
177 * @return array - array reference of all Encounter Medium.
180 public static function encounterMedium($column = 'label', $onlyActive = TRUE) {
181 $cacheKey = "{$column}_" . (int)$onlyActive;
182 if (!isset(self
::$encounterMedium[$cacheKey])) {
183 self
::$encounterMedium[$cacheKey] = CRM_Core_OptionGroup
::values('encounter_medium',
184 FALSE, FALSE, FALSE, NULL,
189 return self
::$encounterMedium[$cacheKey];
193 * Get all Activty types for the CiviCase component
195 * The static array activityType is returned
197 * @param boolean $indexName - true return activity name in array
198 * key else activity id as array key.
205 * @return array - array reference of all activty types.
207 public static function &caseActivityType($indexName = TRUE, $all = FALSE) {
208 $cache = (int) $indexName . '_' . (int) $all;
210 if (!array_key_exists($cache, self
::$activityTypeList)) {
211 self
::$activityTypeList[$cache] = array();
214 SELECT v.label as label ,v.value as value, v.name as name, v.description as description
215 FROM civicrm_option_value v,
216 civicrm_option_group g
217 WHERE v.option_group_id = g.id
218 AND g.name = 'activity_type'
220 AND g.is_active = 1";
223 $componentId = CRM_Core_DAO
::getFieldValue('CRM_Core_DAO_Component',
227 $query .= " AND v.component_id = {$componentId} ";
230 $query .= " ORDER BY v.weight";
232 $dao = CRM_Core_DAO
::executeQuery($query);
234 $activityTypes = array();
235 while ($dao->fetch()) {
240 $index = $dao->value
;
242 $activityTypes[$index] = array();
243 $activityTypes[$index]['id'] = $dao->value
;
244 $activityTypes[$index]['label'] = $dao->label
;
245 $activityTypes[$index]['name'] = $dao->name
;
246 $activityTypes[$index]['description'] = $dao->description
;
248 self
::$activityTypeList[$cache] = $activityTypes;
250 return self
::$activityTypeList[$cache];
254 * Flush given pseudoconstant so it can be reread from db
255 * next time it's requested.
260 * @param bool|string $name pseudoconstant to be flushed
262 public static function flush($name = 'cache') {
263 if (isset(self
::$
$name)) {