_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE, NULL, $_REQUEST); $this->assign('contactId', $this->_contactId); // get contact type and subtype if (empty($this->_contactType)) { $contactTypeInfo = CRM_Contact_BAO_Contact::getContactTypes($this->_contactId); $this->_contactType = $contactTypeInfo[0]; // check if subtype is set if (isset($contactTypeInfo[1])) { // unset contact type which is 0th element unset($contactTypeInfo[0]); $this->_contactSubType = $contactTypeInfo; } } $this->assign('contactType', $this->_contactType); } /** * Common form elements * * @return void * @access public */ public function buildQuickForm() { CRM_Contact_Form_Inline_Lock::buildQuickForm($this, $this->_contactId); $buttons = array( array( 'type' => 'upload', 'name' => ts('Save'), 'isDefault' => TRUE, ), array( 'type' => 'cancel', 'name' => ts('Cancel'), ), ); $this->addButtons($buttons); } /** * Override default cancel action * * @return void * @access public */ public function cancelAction() { $response = array('status' => 'cancel'); echo json_encode($response); CRM_Utils_System::civiExit(); } /** * Set defaults for the form * * @return array * @access public */ public function setDefaultValues() { $defaults = $params = array(); $params['id'] = $this->_contactId; CRM_Contact_BAO_Contact::getValues($params, $defaults); return $defaults; } /** * Add entry to log table * * @return void * @protected */ protected function log() { CRM_Core_BAO_Log::register($this->_contactId, 'civicrm_contact', $this->_contactId ); } /** * Final response from successful form submit * * @param response: array - data to send to the client * * @return void * @protected */ protected function response($response = array()) { // Load changelog footer from template $smarty = CRM_Core_Smarty::singleton(); $smarty->assign('contactId', $this->_contactId); $smarty->assign('external_identifier', CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_contactId, 'external_identifier')); $smarty->assign('lastModified', CRM_Core_BAO_Log::lastModified($this->_contactId, 'civicrm_contact')); $viewOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_view_options', TRUE ); $smarty->assign('changeLog', $viewOptions['log']); $response = array_merge( array( 'status' => 'save', 'changeLog' => array( 'count' => CRM_Contact_BAO_Contact::getCountComponent('log', $this->_contactId), 'markup' => $smarty->fetch('CRM/common/contactFooter.tpl'), ), ), $response, CRM_Contact_Form_Inline_Lock::getResponse($this->_contactId) ); $this->postProcessHook(); // CRM-11831 @see http://www.malsup.com/jquery/form/#file-upload $xhr = isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'; if (!$xhr) { echo ''; } CRM_Utils_System::civiExit(); } }