fixes to render multiple timelines, CRM-14725
authorkurund <kurund@civicrm.org>
Tue, 27 May 2014 20:01:50 +0000 (01:31 +0530)
committerkurund <kurund@civicrm.org>
Tue, 27 May 2014 20:01:50 +0000 (01:31 +0530)
----------------------------------------
* CRM-14725: Edit Case Type - Use AJAX load/save
  https://issues.civicrm.org/jira/browse/CRM-14725

CRM/Case/BAO/CaseType.php

index 0ae9533528b26f212ea2f7b3393093bd92d5b647..cc1b36a3009f0e8fa13e7d0a120542f3371fb53c 100644 (file)
@@ -168,10 +168,22 @@ class CRM_Case_BAO_CaseType extends CRM_Case_DAO_CaseType {
 
     // set activity sets
     $activitySets = json_decode(json_encode($xml->ActivitySets), TRUE);
-    foreach ($activitySets as $key => $value) {
-      $caseType['values'][0]['definition']['activitySets'] = array($key => $value);
-      $caseType['values'][0]['definition']['activitySets'][$key]['activityTypes'] = $activitySets['ActivitySet']['ActivityTypes']['ActivityType'];
-      unset($caseType['values'][0]['definition']['activitySets'][$key]['ActivityTypes']);
+
+    // hack to fix the case when we have only one activityset
+    if (!empty($activitySets['ActivitySet']['name'])) {
+      $temp = $activitySets['ActivitySet'];
+      $activitySets['ActivitySet'] = array($temp);
+    }
+
+    foreach ($activitySets['ActivitySet'] as $key => $value) {
+      foreach ($value as $k => $val) {
+        if ( $k == 'ActivityTypes') {
+          $caseType['values'][0]['definition']['activitySets'][$key]['activityTypes'] = array_pop(array_values($val));
+        }
+        else {
+          $caseType['values'][0]['definition']['activitySets'][$key][$k] = $val;
+        }
+      }
     }
 
     // set case roles