Merge remote-tracking branch 'upstream/4.4' into 4.4-master-2014-08-25-10-57-01
[civicrm-core.git] / CRM / Report / Form / Contribute / OrganizationSummary.php
index d0b9b2a6c302574f27c92fc05724f098aff630d2..8e3463896a4720fc6129771596525a33a0d73391 100644 (file)
@@ -2,9 +2,9 @@
 
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.4                                                |
+ | CiviCRM version 4.5                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013                                |
+ | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -29,7 +29,7 @@
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2013
+ * @copyright CiviCRM LLC (c) 2004-2014
  * $Id$
  *
  */
@@ -43,6 +43,12 @@ class CRM_Report_Form_Contribute_OrganizationSummary extends CRM_Report_Form {
 
   protected $_summary = NULL;
 
+  /**
+   *
+   */
+  /**
+   *
+   */
   function __construct() {
     self::validRelationships();
     $config = CRM_Core_Config::singleton();
@@ -69,6 +75,14 @@ class CRM_Report_Form_Contribute_OrganizationSummary extends CRM_Report_Form {
             'no_display' => TRUE,
             'required' => TRUE,
           ),
+          'contact_type' =>
+          array(
+            'title' => ts('Contact Type'),
+          ),
+          'contact_sub_type' =>
+          array(
+            'title' => ts('Contact SubType'),
+          ),
         ),
         'filters' =>
         array(
@@ -213,9 +227,7 @@ class CRM_Report_Form_Contribute_OrganizationSummary extends CRM_Report_Form {
     foreach ($this->_columns as $tableName => $table) {
       if (array_key_exists('fields', $table)) {
         foreach ($table['fields'] as $fieldName => $field) {
-          if (CRM_Utils_Array::value('required', $field) ||
-            CRM_Utils_Array::value($fieldName, $this->_params['fields'])
-          ) {
+          if (!empty($field['required']) || !empty($this->_params['fields'][$fieldName])) {
             if ($tableName == 'civicrm_address') {
               $this->_addressField = TRUE;
             }
@@ -223,7 +235,7 @@ class CRM_Report_Form_Contribute_OrganizationSummary extends CRM_Report_Form {
               $this->_emailField = TRUE;
             }
 
-            if (CRM_Utils_Array::value('statistics', $field)) {
+            if (!empty($field['statistics'])) {
               foreach ($field['statistics'] as $stat => $label) {
                 $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}_{$stat}";
                 $this->_columnHeaders["{$tableName}_{$fieldName}_{$stat}"]['title'] = $label;
@@ -328,6 +340,11 @@ class CRM_Report_Form_Contribute_OrganizationSummary extends CRM_Report_Form {
     $this->_orderBy = " ORDER BY {$this->_aliases['civicrm_contact_organization']}.organization_name, {$this->_aliases['civicrm_relationship']}.$this->orgContact, {$this->_aliases['civicrm_contact']}.sort_name, {$this->_aliases['civicrm_relationship']}.$this->otherContact";
   }
 
+  /**
+   * @param $rows
+   *
+   * @return array
+   */
   function statistics(&$rows) {
     $statistics = parent::statistics($rows);
 
@@ -372,7 +389,7 @@ class CRM_Report_Form_Contribute_OrganizationSummary extends CRM_Report_Form {
     $params = array('contact_type_b' => 'Organization', 'version' => 3);
     $typesA = &civicrm_api('relationship_type', 'get', $params);
 
-    if (!CRM_Utils_Array::value('is_error', $typesA)) {
+    if (empty($typesA['is_error'])) {
       foreach ($typesA['values'] as $rel) {
         $relationTypes[$rel['id']][$rel['id'] . '_b_a'] = $rel['label_b_a'];
       }
@@ -381,7 +398,7 @@ class CRM_Report_Form_Contribute_OrganizationSummary extends CRM_Report_Form {
     $params = array('contact_type_a' => 'Organization', 'version' => 3);
     $typesB = &civicrm_api('relationship_type', 'get', $params);
 
-    if (!CRM_Utils_Array::value('is_error', $typesB)) {
+    if (empty($typesB['is_error'])) {
       foreach ($typesB['values'] as $rel) {
         $relationTypes[$rel['id']][$rel['id'] . '_a_b'] = $rel['label_a_b'];
       }
@@ -395,6 +412,9 @@ class CRM_Report_Form_Contribute_OrganizationSummary extends CRM_Report_Form {
     }
   }
 
+  /**
+   * @param $rows
+   */
   function alterDisplay(&$rows) {
     // custom code to alter rows
     $type = substr($this->_params['relationship_type_id_value'], -3);
@@ -441,10 +461,8 @@ class CRM_Report_Form_Contribute_OrganizationSummary extends CRM_Report_Form {
       }
 
       // convert Organization display name to links
-      if (array_key_exists('civicrm_contact_organization_organization_name', $row) &&
-        CRM_Utils_Array::value('civicrm_contact_organization_organization_name',
-          $rows[$rowNum]
-        ) &&
+      if (array_key_exists('civicrm_contact_organization_organization_name', $row) && !empty($rows[$rowNum]
+['civicrm_contact_organization_organization_name']) &&
         array_key_exists('civicrm_contact_organization_id', $row)
       ) {
         $url = CRM_Utils_System::url('civicrm/contact/view',