$this->_contactId); $values = array(); $this->_websites = CRM_Core_BAO_Website::getValues($params, $values); } /** * Build the form object elements for website object. * * @return void */ public function buildQuickForm() { parent::buildQuickForm(); $totalBlocks = $this->_blockCount; $actualBlockCount = 1; if (count($this->_websites) > 1) { $actualBlockCount = $totalBlocks = count($this->_websites); if ($totalBlocks < $this->_blockCount) { $additionalBlocks = $this->_blockCount - $totalBlocks; $totalBlocks += $additionalBlocks; } else { $actualBlockCount++; $totalBlocks++; } } $this->assign('actualBlockCount', $actualBlockCount); $this->assign('totalBlocks', $totalBlocks); $this->applyFilter('__ALL__', 'trim'); for ($blockId = 1; $blockId < $totalBlocks; $blockId++) { CRM_Contact_Form_Edit_Website::buildQuickForm($this, $blockId, TRUE); } } /** * Set defaults for the form. * * @return array */ public function setDefaultValues() { $defaults = array(); if (!empty($this->_websites)) { foreach ($this->_websites as $id => $value) { $defaults['website'][$id] = $value; } } else { // set the default website type $defaults['website'][1]['website_type_id'] = key(CRM_Core_OptionGroup::values('website_type', FALSE, FALSE, FALSE, ' AND is_default = 1' )); } return $defaults; } /** * Process the form. * * @return void */ public function postProcess() { $params = $this->exportValues(); // Process / save websites CRM_Core_BAO_Website::create($params['website'], $this->_contactId, TRUE); $this->log(); $this->response(); } }