/** * Fix what blocks to show/hide based on the default values set * * @param array $defaults the array of default values * @param boolean $force should we set show hide based on input defaults * * @return void */ function setShowHide(&$defaults, $force) { $this->_showHide =& new CRM_Core_ShowHideBlocks(array('commPrefs' => 1), ''); if ($this->_contactType == 'Individual') { $this->_showHide->addShow('demographics[show]'); $this->_showHide->addHide('demographics'); } // first do the defaults showing CRM_Contact_Form_Location::setShowHideDefaults($this->_showHide, CRM_CONTACT_FORM_EDIT_LOCATION_BLOCKS); if ($this->_action & CRM_CORE_ACTION_ADD) { // notes are only included in the template for New Contact $this->_showHide->addShow('notes[show]'); $this->_showHide->addHide('notes'); } //add group and tags $contactGroup = $contactTag = array(); if ($this->_contactId) { $contactGroup =& CRM_Contact_BAO_GroupContact::getContactGroup($this->_contactId, 'Added'); $contactTag =& CRM_Core_BAO_EntityTag::getTag('civicrm_contact', $this->_contactId); } if (empty($contactGroup) || empty($contactTag)) { $this->_showHide->addShow('group[show]'); $this->_showHide->addHide('group'); } else { $this->_showHide->addShow('group'); $this->_showHide->addHide('group[show]'); } // is there any demographics data? if (CRM_Utils_Array::value('gender_id', $defaults) || CRM_Utils_Array::value('is_deceased', $defaults) || CRM_Utils_Array::value('birth_date', $defaults)) { $this->_showHide->addShow('demographics'); $this->_showHide->addHide('demographics[show]'); } if ($force) { $locationDefaults = CRM_Utils_Array::value('location', $defaults); CRM_Contact_Form_Location::updateShowHide($this->_showHide, $locationDefaults, CRM_CONTACT_FORM_EDIT_LOCATION_BLOCKS); } $this->_showHide->addToTemplate(); }