/** * Implementation of hook_civicrm_uninstall * * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_uninstall */ function hrjobcontract_civicrm_uninstall() { $subTypeInfo = CRM_Contact_BAO_ContactType::subTypeInfo('Organization'); $sub_type_name = array('Health Insurance Provider', 'Life Insurance Provider'); foreach ($sub_type_name as $sub_type_name) { $subTypeName = ucfirst(CRM_Utils_String::munge($sub_type_name)); $orid = array_key_exists($subTypeName, $subTypeInfo); if ($orid) { $id = $subTypeInfo[$subTypeName]['id']; CRM_Contact_BAO_ContactType::del($id); } } $jobContractMenu = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'job_contracts', 'id', 'name'); if (!empty($jobContractMenu)) { CRM_Core_BAO_Navigation::processDelete($jobContractMenu); } CRM_Core_DAO::executeQuery("DELETE FROM civicrm_navigation WHERE name IN ('job_contracts', 'import_export_job_contracts', 'jobImport', 'hoursType', 'pay_scale','hours_location', 'hrjc_contact_type', 'hrjc_location', 'hrjc_pay_cycle', 'hrjc_benefit_name', 'hrjc_benefit_type', 'hrjc_deduction_name', 'hrjc_deduction_type', 'hrjc_health_provider', 'hrjc_life_provider', 'hrjc_pension_type', 'hrjc_revision_change_reason')"); CRM_Core_BAO_Navigation::resetNavigation(); //delete custom groups and field $customGroup = civicrm_api3('CustomGroup', 'get', array('name' => "HRJobContract_Summary")); $customGroupData = CRM_Utils_Array::first($customGroup['values']); if (!empty($customGroupData['id'])) { civicrm_api3('CustomGroup', 'delete', array('id' => $customGroupData['id'])); } $customGroup = civicrm_api3('CustomGroup', 'get', array('name' => "HRJobContract_Summary")); $customGroupData = CRM_Utils_Array::first($customGroup['values']); if (!empty($customGroupData['id'])) { civicrm_api3('CustomGroup', 'delete', array('id' => $customGroupData['id'])); } //delete all option group and values CRM_Core_DAO::executeQuery("DELETE FROM civicrm_option_group WHERE name IN ('job_contracts', 'hoursType', 'pay_scale','hours_location', 'hrjc_contact_type', 'hrjc_location', 'hrjc_pay_cycle', 'hrjc_benefit_name', 'hrjc_benefit_type', 'hrjc_deduction_name', 'hrjc_deduction_type', 'hrjc_health_provider', 'hrjc_life_provider', 'hrjc_pension_type', 'hrjc_revision_change_reason', 'hrjc_contract_type', 'hrjc_level_type', 'hrjc_department', 'hrjc_hours_type', 'hrjc_pay_grade', 'hrjc_health_provider', 'hrjc_life_provider', 'hrjc_location', 'hrjc_pension_type', 'hrjc_region', 'hrjc_pay_scale')"); //delete job contract files to entities relations CRM_Core_DAO::executeQuery("DELETE FROM civicrm_entity_file WHERE entity_table LIKE 'civicrm_hrjobcontract_%'"); return _hrjobcontract_civix_civicrm_uninstall(); }
/** * Function to process the form * * @access public * @return None */ public function postProcess() { if ($this->_action & CRM_Core_Action::DELETE) { $isDelete = CRM_Contact_BAO_ContactType::del($this->_id); if ($isDelete) { CRM_Core_Session::setStatus(ts('Selected Contact Type has been deleted.')); } else { CRM_Core_Session::setStatus(ts('Selected Contact Type can not be deleted.') . '<br/>' . ts('If you want to delete Contact Type ,first delete all custom data related to Type. ')); } return; } // store the submitted values in an array $params = $this->exportValues(); if ($this->_action & CRM_Core_Action::UPDATE) { $params['id'] = $this->_id; } if ($this->_action & CRM_Core_Action::ADD) { $params['name'] = ucfirst(CRM_Utils_String::munge($params['label'])); } $contactType = CRM_Contact_BAO_ContactType::add($params); CRM_Core_Session::setStatus(ts("The Contact Type '%1' has been saved.", array(1 => $contactType->label))); }
/** * Test del() with invalid data */ public function testDelInvalid() { $del = CRM_Contact_BAO_ContactType::del(NULL); $this->assertEquals($del, FALSE); }
/** * Process the form submission. */ public function postProcess() { CRM_Utils_System::flushCache(); if ($this->_action & CRM_Core_Action::DELETE) { $isDelete = CRM_Contact_BAO_ContactType::del($this->_id); if ($isDelete) { CRM_Core_Session::setStatus(ts('Selected contact type has been deleted.'), ts('Record Deleted'), 'success'); } else { CRM_Core_Session::setStatus(ts("Selected contact type can not be deleted. Make sure contact type doesn't have any associated custom data or group."), ts('Sorry'), 'error'); } return; } // store the submitted values in an array $params = $this->exportValues(); if ($this->_action & CRM_Core_Action::UPDATE) { $params['id'] = $this->_id; // Force Enabled = true for built-in contact types to fix problems caused by CRM-6471 (parent_id is NULL for these types) if (is_null($this->_parentId)) { $params['is_active'] = 1; } } if ($this->_action & CRM_Core_Action::ADD) { $params['name'] = ucfirst(CRM_Utils_String::munge($params['label'])); } $contactType = CRM_Contact_BAO_ContactType::add($params); CRM_Core_Session::setStatus(ts("The Contact Type '%1' has been saved.", array(1 => $contactType->label)), ts('Saved'), 'success'); }
function testDelInvalid() { $del = CRM_Contact_BAO_ContactType::del(NULL); $this->assertEquals($del, FALSE, 'In line ' . __LINE__); }
/** * @param int $contactTypeId * * @throws Exception */ public function contactTypeDelete($contactTypeId) { $result = CRM_Contact_BAO_ContactType::del($contactTypeId); if (!$result) { throw new Exception('Could not delete contact type'); } }
/** * Implementation of hook_civicrm_uninstall */ function hrjob_civicrm_uninstall() { $subTypeInfo = CRM_Contact_BAO_ContactType::subTypeInfo('Organization'); $sub_type_name = array('Health Insurance Provider', 'Life Insurance Provider'); foreach ($sub_type_name as $sub_type_name) { $subTypeName = ucfirst(CRM_Utils_String::munge($sub_type_name)); $orid = array_key_exists($subTypeName, $subTypeInfo); if ($orid) { $id = $subTypeInfo[$subTypeName]['id']; CRM_Contact_BAO_ContactType::del($id); } } //delete job import navigation menu CRM_Core_DAO::executeQuery("DELETE FROM civicrm_navigation WHERE name IN ('jobImport','hoursType')"); CRM_Core_BAO_Navigation::resetNavigation(); //delete custom groups and field $customGroup = civicrm_api3('CustomGroup', 'getsingle', array('return' => "id", 'name' => "HRJob_Summary")); civicrm_api3('CustomGroup', 'delete', array('id' => $customGroup['id'])); //delete all option group and values CRM_Core_DAO::executeQuery("DELETE FROM civicrm_option_group WHERE name IN ('hrjob_contract_type', 'hrjob_level_type', 'hrjob_department', 'hrjob_hours_type', 'hrjob_pay_grade', 'hrjob_health_provider', 'hrjob_life_provider', 'hrjob_location', 'hrjob_pension_type', 'hrjob_region', 'hrjob_pay_scale')"); return _hrjob_civix_civicrm_uninstall(); }
/** * @param $contactTypeId * * @throws Exception */ function contactTypeDelete($contactTypeId) { require_once 'CRM/Contact/BAO/ContactType.php'; $result = CRM_Contact_BAO_ContactType::del($contactTypeId); if (!$result) { throw new Exception('Could not delete contact type'); } }
/** * Function to process the form * * @access public * @return None */ public function postProcess() { if ($this->_action & CRM_Core_Action::DELETE) { $isDelete = CRM_Contact_BAO_ContactType::del($this->_id); if ($isDelete) { CRM_Core_Session::setStatus(ts('Selected contact type has been deleted.')); } else { CRM_Core_Session::setStatus(ts('Selected contact type can not be deleted. Make sure contact type doesn\'t have any associated custom data or group.')); } return; } // store the submitted values in an array $params = $this->exportValues(); if ($this->_action & CRM_Core_Action::UPDATE) { $params['id'] = $this->_id; } if ($this->_action & CRM_Core_Action::ADD) { $params['name'] = ucfirst(CRM_Utils_String::munge($params['label'])); } $contactType = CRM_Contact_BAO_ContactType::add($params); CRM_Core_Session::setStatus(ts("The Contact Type '%1' has been saved.", array(1 => $contactType->label))); }