3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
17 class CRM_Case_XMLProcessor
{
20 * FIXME: This does *NOT* belong in a static property, but we're too late in
21 * the 4.5-cycle to do the necessary cleanup.
23 * Format is [int $id => string $relTypeCname].
27 public static $activityTypes = NULL;
32 * @return FALSE|SimpleXMLElement
34 public function retrieve($caseType) {
35 return CRM_Case_XMLRepository
::singleton()->retrieve($caseType);
39 * This function was previously used to convert a case-type's
40 * machine-name to a file-name. However, it's mind-boggling
41 * that the file-name might be a munged version of the
42 * machine-name (which is itself a munged version of the
43 * display-name), and naming is now a more visible issue (since
44 * the overhaul of CaseType admin UI).
46 * Usage note: This is called externally by civix stubs as a
47 * sort of side-ways validation of the case-type's name
48 * (validation which was needed because of the unintuitive
49 * double-munge). We should update civix templates and then
50 * remove this function in Civi 4.6 or 5.0.
52 * @param string $caseType
55 * @see CRM_Case_BAO_CaseType::isValidName
57 public static function mungeCaseType($caseType) {
58 // trim all spaces from $caseType
59 $caseType = str_replace('_', ' ', $caseType);
60 $caseType = CRM_Utils_String
::munge(ucwords($caseType), '', 0);
67 * @param bool $indexName
72 public static function &allActivityTypes($indexName = TRUE, $all = FALSE) {
73 CRM_Core_Error
::deprecatedFunctionWarning('CRM_Case_PseudoConstant::caseActivityType');
74 if (self
::$activityTypes === NULL) {
75 self
::$activityTypes = CRM_Case_PseudoConstant
::caseActivityType($indexName, $all);
77 return self
::$activityTypes;
81 * Get all relationship type display labels (not machine names)
83 * @param bool $fromXML
84 * TODO: This parameter is always FALSE now so no longer needed.
85 * Is this to be used for lookup of values from XML?
86 * Relationships are recorded in XML from the perspective of the non-client
87 * while relationships in the UI and everywhere else are from the
88 * perspective of the client. Since the XML can't be expected to be
89 * switched, the direction needs to be translated.
92 public function &allRelationshipTypes($fromXML = FALSE) {
93 if (!isset(Civi
::$statics[__CLASS__
]['reltypes'][$fromXML])) {
94 // Note this now includes disabled types too. The only place this
95 // function is being used is for comparison against a list, not
96 // displaying a dropdown list or something like that, so we need
97 // to include disabled.
98 $relationshipInfo = civicrm_api3('RelationshipType', 'get', [
99 'options' => ['limit' => 0],
102 Civi
::$statics[__CLASS__
]['reltypes'][$fromXML] = [];
103 foreach ($relationshipInfo['values'] as $id => $info) {
104 Civi
::$statics[__CLASS__
]['reltypes'][$fromXML][$id . '_b_a'] = ($fromXML) ?
$info['label_a_b'] : $info['label_b_a'];
106 * Exclude if bidirectional
107 * (Why? I'm thinking this was for consistency with the dropdown
108 * in ang/crmCaseType.js where it would be needed to avoid seeing
109 * duplicates in the dropdown. Not sure if needed here but keeping
112 if ($info['label_b_a'] !== $info['label_a_b']) {
113 Civi
::$statics[__CLASS__
]['reltypes'][$fromXML][$id . '_a_b'] = ($fromXML) ?
$info['label_b_a'] : $info['label_a_b'];
118 return Civi
::$statics[__CLASS__
]['reltypes'][$fromXML];
122 * FIXME: This should not exist
124 public static function flushStaticCaches() {
125 self
::$activityTypes = NULL;
126 unset(Civi
::$statics[__CLASS__
]['reltypes']);