Merge pull request #5097 from PalanteJon/CRM-15917
[civicrm-core.git] / CRM / Contact / Form / CustomData.php
index 022534ea151568443f4524745f970f583b3b65f8..c090fbc3788e460045c04126ea107f378a31636d 100644 (file)
@@ -23,7 +23,7 @@
  | GNU Affero General Public License or the licensing of CiviCRM,     |
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
-*/
+ */
 
 /**
  *
@@ -102,6 +102,7 @@ class CRM_Contact_Form_CustomData extends CRM_Core_Form {
   public $_multiRecordDisplay;
 
   public $_copyValueId;
+
   /**
    * Pre processing work done here.
    *
@@ -110,8 +111,6 @@ class CRM_Contact_Form_CustomData extends CRM_Core_Form {
    * @param
    *
    * @return void
-   *
-   *
    */
   public function preProcess() {
     $this->_cdType = CRM_Utils_Array::value('type', $_GET);
@@ -125,7 +124,7 @@ class CRM_Contact_Form_CustomData extends CRM_Core_Form {
       // this is due to some condition inside it which restricts it from saving in session
       // so doing this for multi record edit action
       $entityId = CRM_Utils_Request::retrieve('entityID', 'Positive', $this);
-      if(!empty($entityId)) {
+      if (!empty($entityId)) {
         $subType = CRM_Contact_BAO_Contact::getContactSubType($entityId, ',');
       }
       CRM_Custom_Form_CustomData::preProcess($this, NULL, $subType, NULL, NULL, $entityId);
@@ -172,7 +171,7 @@ class CRM_Contact_Form_CustomData extends CRM_Core_Form {
   }
 
   /**
-   * Build the form object
+   * Build the form object.
    *
    * @return void
    */
@@ -186,7 +185,7 @@ class CRM_Contact_Form_CustomData extends CRM_Core_Form {
         );
         if ($isMultiple) {
           $this->assign('multiRecordDisplay', $this->_multiRecordDisplay);
-          $saveButtonName = $this->_copyValueId ? 'Save a Copy': 'Save';
+          $saveButtonName = $this->_copyValueId ? 'Save a Copy' : 'Save';
           $this->addButtons(array(
               array(
                 'type' => 'upload',
@@ -230,10 +229,11 @@ class CRM_Contact_Form_CustomData extends CRM_Core_Form {
   }
 
   /**
-   * Set the default form values
+   * Set the default form values.
    *
    *
-   * @return array the default array reference
+   * @return array
+   *   the default array reference
    */
   public function setDefaultValues() {
     if ($this->_cdType || $this->_multiRecordDisplay == 'single') {
@@ -307,9 +307,22 @@ class CRM_Contact_Form_CustomData extends CRM_Core_Form {
     $cgcount += 1;
     $buttonName = $this->controller->getButtonName();
     if ($buttonName == $this->getButtonName('upload', 'new')) {
-      CRM_Core_Session::singleton()->pushUserContext(CRM_Utils_System::url('civicrm/contact/view/cd/edit', "reset=1&type={$this->_contactType}&groupID={$this->_groupID}&entityID={$this->_tableID}&cgcount={$cgcount}&multiRecordDisplay=single&mode=add"));
+      CRM_Core_Session::singleton()
+        ->pushUserContext(CRM_Utils_System::url('civicrm/contact/view/cd/edit', "reset=1&type={$this->_contactType}&groupID={$this->_groupID}&entityID={$this->_tableID}&cgcount={$cgcount}&multiRecordDisplay=single&mode=add"));
     }
+
+    // Add entry in the log table
+    CRM_Core_BAO_Log::register($this->_tableID,
+      'civicrm_contact',
+      $this->_tableID
+    );
+
+    if (CRM_Core_Resources::isAjaxMode()) {
+      $this->ajaxResponse += CRM_Contact_Form_Inline::renderFooter($this->_tableID);
+    }
+
     // reset the group contact cache for this group
     CRM_Contact_BAO_GroupContactCache::remove();
   }
+
 }