/** * function to build location block * * @return None * @access public */ public function buildQuickForm() { //load form for child blocks if ($this->_addBlockName) { require_once str_replace('_', DIRECTORY_SEPARATOR, "CRM_Contact_Form_Edit_" . $this->_addBlockName) . ".php"; return eval('CRM_Contact_Form_Edit_' . $this->_addBlockName . '::buildQuickForm( $this );'); } $this->applyFilter('__ALL__', 'trim'); //build location blocks. CRM_Contact_Form_Location::buildQuickForm($this); //fix for CRM-1971 $this->assign('action', $this->_action); if ($this->_id) { $this->_oldLocBlockId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_id, 'loc_block_id'); } // get the list of location blocks being used by other events $locationEvents = CRM_Event_BAO_Event::getLocationEvents(); // remove duplicates and make sure that the duplicate entry with key as // loc_block_id of this event (this->_id) is preserved if (CRM_Utils_Array::value($this->_oldLocBlockId, $locationEvents)) { $possibleDuplicate = $locationEvents[$this->_oldLocBlockId]; $locationEvents = array_flip(array_unique($locationEvents)); if (CRM_Utils_Array::value($possibleDuplicate, $locationEvents)) { $locationEvents[$possibleDuplicate] = $this->_oldLocBlockId; } $locationEvents = array_flip($locationEvents); } else { $locationEvents = array_unique($locationEvents); } $events = array(); if (!empty($locationEvents)) { $this->assign('locEvents', true); $optionTypes = array('1' => ts('Create new location'), '2' => ts('Use existing location')); $this->addRadio('location_option', ts("Choose Location"), $optionTypes, array('onclick' => "showLocFields();"), '<br/>', false); if (!isset($locationEvents[$this->_oldLocBlockId]) || !$this->_oldLocBlockId) { $locationEvents = array('' => ts('- select -')) + $locationEvents; } $this->add('select', 'loc_event_id', ts('Use Location'), $locationEvents); } $this->addElement('advcheckbox', 'is_show_location', ts('Show Location?')); parent::buildQuickForm(); }
/** * function to build location block. * * @return void */ public function buildQuickForm() { //load form for child blocks if ($this->_addBlockName) { $className = "CRM_Contact_Form_Edit_{$this->_addBlockName}"; return $className::buildQuickForm($this); } $this->applyFilter('__ALL__', 'trim'); //build location blocks. CRM_Contact_Form_Location::buildQuickForm($this); //fix for CRM-1971 $this->assign('action', $this->_action); if ($this->_id) { $this->_oldLocBlockId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_id, 'loc_block_id'); } // get the list of location blocks being used by other events $locationEvents = CRM_Event_BAO_Event::getLocationEvents(); // remove duplicates and make sure that the duplicate entry with key as // loc_block_id of this event (this->_id) is preserved if (!empty($locationEvents[$this->_oldLocBlockId])) { $possibleDuplicate = $locationEvents[$this->_oldLocBlockId]; $locationEvents = array_flip(array_unique($locationEvents)); if (!empty($locationEvents[$possibleDuplicate])) { $locationEvents[$possibleDuplicate] = $this->_oldLocBlockId; } $locationEvents = array_flip($locationEvents); } else { $locationEvents = array_unique($locationEvents); } $events = array(); if (!empty($locationEvents)) { $this->assign('locEvents', TRUE); $optionTypes = array('1' => ts('Create new location'), '2' => ts('Use existing location')); $this->addRadio('location_option', ts("Choose Location"), $optionTypes); if (!isset($locationEvents[$this->_oldLocBlockId]) || !$this->_oldLocBlockId) { $locationEvents = array('' => ts('- select -')) + $locationEvents; } $this->add('select', 'loc_event_id', ts('Use Location'), $locationEvents); } $this->addElement('advcheckbox', 'is_show_location', ts('Show Location?')); parent::buildQuickForm(); }