Merge pull request #4837 from eileenmcnaughton/CRM-15779
[civicrm-core.git] / CRM / Contact / Form / Inline / ContactInfo.php
index 796aefed89b8e37e25580a12d2267629422743cf..30c486823e75b5cc2841a835875f6276013dad12 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.5                                                |
+ | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
 class CRM_Contact_Form_Inline_ContactInfo extends CRM_Contact_Form_Inline {
 
   /**
-   * build the form elements
+   * Build the form object elements
    *
    * @return void
-   * @access public
    */
   public function buildQuickForm() {
     parent::buildQuickForm();
@@ -53,20 +52,18 @@ class CRM_Contact_Form_Inline_ContactInfo extends CRM_Contact_Form_Inline {
   }
 
   /**
-   * set defaults for the form
+   * Set defaults for the form
    *
    * @return array
-   * @access public
    */
   public function setDefaultValues() {
     return parent::setDefaultValues();
   }
 
   /**
-   * process the form
+   * Process the form
    *
    * @return void
-   * @access public
    */
   public function postProcess() {
     $params = $this->exportValues();
@@ -81,10 +78,16 @@ class CRM_Contact_Form_Inline_ContactInfo extends CRM_Contact_Form_Inline {
 
     CRM_Contact_BAO_Contact::create($params);
 
-    // Saving current employer affects relationship tab
+    // Saving current employer affects relationship tab, and possibly related memberships and contributions
     $this->ajaxResponse['updateTabs'] = array(
       '#tab_rel' => CRM_Contact_BAO_Contact::getCountComponent('rel', $this->_contactId),
     );
+    if (CRM_Core_Permission::access('CiviContribute')) {
+      $this->ajaxResponse['updateTabs']['#tab_contribute'] = CRM_Contact_BAO_Contact::getCountComponent('contribution', $this->_contactId);
+    }
+    if (CRM_Core_Permission::access('CiviMember')) {
+      $this->ajaxResponse['updateTabs']['#tab_member'] = CRM_Contact_BAO_Contact::getCountComponent('membership', $this->_contactId);
+    }
 
     $this->response();
   }