Merge pull request #4812 from colemanw/CRM-15495
[civicrm-core.git] / CRM / Contact / Form / CustomData.php
index f2f49e53605b872d318b5c4ab58c10e012e9713d..022534ea151568443f4524745f970f583b3b65f8 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.5                                                |
+ | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
@@ -51,22 +51,21 @@ class CRM_Contact_Form_CustomData extends CRM_Core_Form {
   protected $_tableId;
 
   /**
-   * entity type of the table id
+   * Entity type of the table id
    *
    * @var string
    */
   protected $_entityType;
 
   /**
-   * entity sub type of the table id
+   * Entity sub type of the table id
    *
    * @var string
-   * @access protected
    */
   protected $_entitySubType;
 
   /**
-   * the group tree data
+   * The group tree data
    *
    * @var array
    */
@@ -94,10 +93,9 @@ class CRM_Contact_Form_CustomData extends CRM_Core_Form {
   protected $_groupCollapseDisplay;
 
   /**
-   * custom group id
+   * Custom group id
    *
    * @int
-   * @access public
    */
   public $_groupID;
 
@@ -105,7 +103,7 @@ class CRM_Contact_Form_CustomData extends CRM_Core_Form {
 
   public $_copyValueId;
   /**
-   * pre processing work done here.
+   * Pre processing work done here.
    *
    * gets session variables for table name, id of entity in table, type of entity and stores them.
    *
@@ -113,10 +111,9 @@ class CRM_Contact_Form_CustomData extends CRM_Core_Form {
    *
    * @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);
@@ -127,7 +124,11 @@ class CRM_Contact_Form_CustomData extends CRM_Core_Form {
       // NOTE : group id is not stored in session from within CRM_Custom_Form_CustomData::preProcess func
       // this is due to some condition inside it which restricts it from saving in session
       // so doing this for multi record edit action
-      CRM_Custom_Form_CustomData::preProcess($this);
+      $entityId = CRM_Utils_Request::retrieve('entityID', 'Positive', $this);
+      if(!empty($entityId)) {
+        $subType = CRM_Contact_BAO_Contact::getContactSubType($entityId, ',');
+      }
+      CRM_Custom_Form_CustomData::preProcess($this, NULL, $subType, NULL, NULL, $entityId);
       if ($this->_multiRecordDisplay) {
         $this->_groupID = CRM_Utils_Request::retrieve('groupID', 'Positive', $this);
         $this->_tableID = $this->_entityId;
@@ -171,10 +172,9 @@ class CRM_Contact_Form_CustomData extends CRM_Core_Form {
   }
 
   /**
-   * Function to actually build the form
+   * Build the form object
    *
    * @return void
-   * @access public
    */
   public function buildQuickForm() {
     if ($this->_cdType || $this->_multiRecordDisplay == 'single') {
@@ -232,11 +232,10 @@ class CRM_Contact_Form_CustomData extends CRM_Core_Form {
   /**
    * Set the default form values
    *
-   * @access protected
    *
    * @return array the default array reference
    */
-  function setDefaultValues() {
+  public function setDefaultValues() {
     if ($this->_cdType || $this->_multiRecordDisplay == 'single') {
       if ($this->_copyValueId) {
         // cached tree is fetched
@@ -290,7 +289,6 @@ class CRM_Contact_Form_CustomData extends CRM_Core_Form {
   /**
    * Process the user submitted custom data values.
    *
-   * @access public
    *
    * @return void
    */
@@ -314,4 +312,4 @@ class CRM_Contact_Form_CustomData extends CRM_Core_Form {
     // reset the group contact cache for this group
     CRM_Contact_BAO_GroupContactCache::remove();
   }
-}
\ No newline at end of file
+}