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
33 class CRM_Case_XMLProcessor
{
36 * FIXME: This does *NOT* belong in a static property, but we're too late in
37 * the 4.5-cycle to do the necessary cleanup.
39 * Format is [int $id => string $relTypeCname].
43 public static $activityTypes = NULL;
46 * FIXME: This does *NOT* belong in a static property, but we're too late in
47 * the 4.5-cycle to do the necessary cleanup.
49 * Format is array(int $id => string $relTypeCname).
53 public static $relationshipTypes = NULL;
56 * Relationship-types have four name fields (name_a_b, name_b_a, label_a_b,
57 * label_b_a), but CiviCase XML refers to reltypes by a single name.
58 * REL_TYPE_CNAME identifies the canonical name field as used by CiviCase XML.
60 * This appears to be "label_b_a", but IMHO "name_b_a" would be more
63 const REL_TYPE_CNAME
= 'label_b_a';
68 * @return FALSE|SimpleXMLElement
70 public function retrieve($caseType) {
71 return CRM_Case_XMLRepository
::singleton()->retrieve($caseType);
75 * This function was previously used to convert a case-type's
76 * machine-name to a file-name. However, it's mind-boggling
77 * that the file-name might be a munged version of the
78 * machine-name (which is itself a munged version of the
79 * display-name), and naming is now a more visible issue (since
80 * the overhaul of CaseType admin UI).
82 * Usage note: This is called externally by civix stubs as a
83 * sort of side-ways validation of the case-type's name
84 * (validation which was needed because of the unintuitive
85 * double-munge). We should update civix templates and then
86 * remove this function in Civi 4.6 or 5.0.
88 * @param string $caseType
91 * @see CRM_Case_BAO_CaseType::isValidName
93 public static function mungeCaseType($caseType) {
94 // trim all spaces from $caseType
95 $caseType = str_replace('_', ' ', $caseType);
96 $caseType = CRM_Utils_String
::munge(ucwords($caseType), '', 0);
101 * @param bool $indexName
106 public function &allActivityTypes($indexName = TRUE, $all = FALSE) {
107 if (self
::$activityTypes === NULL) {
108 self
::$activityTypes = CRM_Case_PseudoConstant
::caseActivityType($indexName, $all);
110 return self
::$activityTypes;
116 public function &allRelationshipTypes() {
117 if (self
::$relationshipTypes === NULL) {
118 $relationshipInfo = CRM_Core_PseudoConstant
::relationshipType('label', TRUE);
120 self
::$relationshipTypes = [];
121 foreach ($relationshipInfo as $id => $info) {
122 self
::$relationshipTypes[$id] = $info[CRM_Case_XMLProcessor
::REL_TYPE_CNAME
];
126 return self
::$relationshipTypes;
130 * FIXME: This should not exist
132 public static function flushStaticCaches() {
133 self
::$activityTypes = NULL;
134 self
::$relationshipTypes = NULL;