Merge pull request #5097 from PalanteJon/CRM-15917
[civicrm-core.git] / CRM / Contact / Form / CustomData.php
index 79113aa551d11f77ec7d464b662c61d273f9ff8a..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        |
  +--------------------------------------------------------------------+
-*/
+ */
 
 /**
  *
@@ -61,7 +61,6 @@ class CRM_Contact_Form_CustomData extends CRM_Core_Form {
    * Entity sub type of the table id
    *
    * @var string
-   * @access protected
    */
   protected $_entitySubType;
 
@@ -97,13 +96,13 @@ class CRM_Contact_Form_CustomData extends CRM_Core_Form {
    * Custom group id
    *
    * @int
-   * @access public
    */
   public $_groupID;
 
   public $_multiRecordDisplay;
 
   public $_copyValueId;
+
   /**
    * Pre processing work done here.
    *
@@ -112,11 +111,8 @@ class CRM_Contact_Form_CustomData extends CRM_Core_Form {
    * @param
    *
    * @return void
-   *
-   * @access public
-   *
    */
-  function preProcess() {
+  public function preProcess() {
     $this->_cdType = CRM_Utils_Array::value('type', $_GET);
     $this->assign('cdType', FALSE);
     $this->_multiRecordDisplay = CRM_Utils_Request::retrieve('multiRecordDisplay', 'String', $this);
@@ -128,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);
@@ -175,10 +171,9 @@ class CRM_Contact_Form_CustomData extends CRM_Core_Form {
   }
 
   /**
-   * Build the form object
+   * Build the form object.
    *
    * @return void
-   * @access public
    */
   public function buildQuickForm() {
     if ($this->_cdType || $this->_multiRecordDisplay == 'single') {
@@ -190,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',
@@ -234,13 +229,13 @@ class CRM_Contact_Form_CustomData extends CRM_Core_Form {
   }
 
   /**
-   * Set the default form values
+   * Set the default form values.
    *
-   * @access protected
    *
-   * @return array the default array reference
+   * @return array
+   *   the default array reference
    */
-  function setDefaultValues() {
+  public function setDefaultValues() {
     if ($this->_cdType || $this->_multiRecordDisplay == 'single') {
       if ($this->_copyValueId) {
         // cached tree is fetched
@@ -294,7 +289,6 @@ class CRM_Contact_Form_CustomData extends CRM_Core_Form {
   /**
    * Process the user submitted custom data values.
    *
-   * @access public
    *
    * @return void
    */
@@ -313,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();
   }
-}
\ No newline at end of file
+
+}