Merge branch 4.5 into master
[civicrm-core.git] / CRM / Case / XMLRepository.php
index 067af0bd5e4c95e7af157fcf41569c6137173cd5..8ec73aabfef4655a6ecbf56a14db450aae77d3a3 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.5                                                |
+ | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
@@ -81,7 +81,11 @@ class CRM_Case_XMLRepository {
     $definition = CRM_Core_DAO::getFieldValue('CRM_Case_DAO_CaseType', $caseType, 'definition', 'name');
 
     if (!empty($definition)) {
-      return simplexml_load_string($definition);
+      list ($xml, $error) = CRM_Utils_XML::parseString($definition);
+      if (!$xml) {
+        throw new CRM_Core_Exception("Failed to parse CaseType XML: $error");
+      }
+      return $xml;
     }
 
     // TODO In 4.6 or 5.0, remove support for weird machine-names
@@ -94,7 +98,8 @@ class CRM_Case_XMLRepository {
       $fileXml = $this->retrieveFile($caseType);
       if ($fileXml) {
         $this->xml[$caseType] = $fileXml;
-      } else {
+      }
+      else {
         return FALSE;
       }
     }
@@ -135,7 +140,8 @@ class CRM_Case_XMLRepository {
    * @param string $caseType
    * @return null|string file path
    */
-  public function findXmlFile($caseType) { // first check custom templates directory
+  public function findXmlFile($caseType) {
+    // first check custom templates directory
     $fileName = NULL;
 
     if (!$fileName || !file_exists($fileName)) {
@@ -250,10 +256,11 @@ class CRM_Case_XMLRepository {
    * Determine the number of times a particular activity-type is
    * referenced in CiviCase XML.
    *
-   * @param string $activityType symbolic-name of an activity type
+   * @param string $activityType
+   *   Symbolic-name of an activity type.
    * @return int
    */
-  function getActivityReferenceCount($activityType) {
+  public function getActivityReferenceCount($activityType) {
     $p = new CRM_Case_XMLProcessor_Process();
     $count = 0;
     foreach ($this->getAllCaseTypes() as $caseTypeName) {
@@ -269,10 +276,11 @@ class CRM_Case_XMLRepository {
    * Determine the number of times a particular activity-type is
    * referenced in CiviCase XML.
    *
-   * @param string $relationshipTypeName symbolic-name of a relationship-type
+   * @param string $relationshipTypeName
+   *   Symbolic-name of a relationship-type.
    * @return int
    */
-  function getRelationshipReferenceCount($relationshipTypeName) {
+  public function getRelationshipReferenceCount($relationshipTypeName) {
     $p = new CRM_Case_XMLProcessor_Process();
     $count = 0;
     foreach ($this->getAllCaseTypes() as $caseTypeName) {