INFRA-132 - Put space after flow-control (if/switch/for/foreach/while)
[civicrm-core.git] / CRM / Group / Page / AJAX.php
index fef31e7fe3637e5b6a8a82ba569ef76cc1aeb6bf..a5ed2d72b14d6bf51301fbe4e86317df68118d27 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.5                                                |
+ | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
@@ -36,7 +36,7 @@
  * This class contains the functions that are called using AJAX (jQuery)
  */
 class CRM_Group_Page_AJAX {
-  static function getGroupList() {
+  public static function getGroupList() {
     $params = $_REQUEST;
 
     if (isset($params['parent_id'])) {
@@ -45,13 +45,16 @@ class CRM_Group_Page_AJAX {
       $params['rp']   = 0;
       $groups = CRM_Contact_BAO_Group::getGroupListSelector($params);
 
-      echo json_encode($groups);
-      CRM_Utils_System::civiExit();
+      CRM_Utils_JSON::output($groups);
     }
     else {
       $sortMapper = array(
-        0 => 'groups.title', 1 => 'groups.id', 2 => 'createdBy.sort_name', 3 => '',
-        4 => 'groups.group_type', 5 => 'groups.visibility',
+        0 => 'groups.title',
+      1 => 'count',
+      2 => 'createdBy.sort_name',
+      3 => '',
+        4 => 'groups.group_type',
+      5 => 'groups.visibility',
       );
 
       $sEcho     = CRM_Utils_Type::escape($_REQUEST['sEcho'], 'Integer');
@@ -84,17 +87,17 @@ class CRM_Group_Page_AJAX {
 
       $iFilteredTotal = $iTotal = $params['total'];
       $selectorElements = array(
-        'group_name', 'group_id', 'created_by', 'group_description',
+        'group_name', 'count', 'created_by', 'group_description',
         'group_type', 'visibility', 'org_info', 'links', 'class',
       );
 
       if (empty($params['showOrgInfo'])) {
         unset($selectorElements[6]);
       }
-     //add setting so this can be tested by unit test
-     //@todo - ideally the portion of this that retrieves the groups should be extracted into a function separate
-     // from the one which deals with web inputs & outputs so we have a properly testable & re-usable function
-      if(!empty($params['is_unit_test'])) {
+      //add setting so this can be tested by unit test
+      //@todo - ideally the portion of this that retrieves the groups should be extracted into a function separate
+      // from the one which deals with web inputs & outputs so we have a properly testable & re-usable function
+      if (!empty($params['is_unit_test'])) {
         return array($groups, $iFilteredTotal);
       }
       echo CRM_Utils_JSON::encodeDataTableSelector($groups, $sEcho, $iTotal, $iFilteredTotal, $selectorElements);
@@ -102,4 +105,3 @@ class CRM_Group_Page_AJAX {
     }
   }
 }
-