public function uninstall() { // if( !array_key_exists( $this->ext->key, $this->customReports ) ) { // CRM_Core_Error::fatal( 'This report is not registered.' ); // } $cr = CRM_Core_OptionGroup::values(self::REPORT_GROUP_NAME, false, false, false, null, 'id', false); $id = $cr[$this->customReports[$this->ext->key]]; $optionValue = CRM_Core_BAO_OptionValue::del($id); }
public function uninstall() { if (!array_key_exists($this->ext->key, $this->customSearches)) { CRM_Core_Error::fatal('This custom search is not registered.'); } $cs = CRM_Core_OptionGroup::values(self::CUSTOM_SEARCH_GROUP_NAME, false, false, false, null, 'id', false); $id = $cs[$this->customSearches[$this->ext->key]]; $optionValue = CRM_Core_BAO_OptionValue::del($id); }
/** * Deletes an existing OptionValue * * @param array $params * * {@example OptionValueDelete.php 0} * * @return array Api result * {@getfields OptionValue_create} * @access public */ function civicrm_api3_option_value_delete($params) { // we will get the option group id before deleting so we can flush pseudoconstants $optionGroupID = civicrm_api('option_value', 'getvalue', array('version' => 3, 'id' => $params['id'], 'return' => 'option_group_id')); if (CRM_Core_BAO_OptionValue::del((int) $params['id'])) { civicrm_api('option_value', 'getfields', array('version' => 3, 'cache_clear' => 1, 'option_group_id' => $optionGroupID)); return civicrm_api3_create_success(); } else { civicrm_api3_create_error('Could not delete OptionValue ' . $params['id']); } }
/** * @param CRM_Extension_Info $info * * @return bool * @throws Exception */ public function onPreUninstall(CRM_Extension_Info $info) { $customSearchesByName = $this->getCustomSearchesByName(); if (!array_key_exists($info->key, $customSearchesByName)) { CRM_Core_Error::fatal('This custom search is not registered.'); } $cs = $this->getCustomSearchesById(); $id = $cs[$customSearchesByName[$info->key]]; $optionValue = CRM_Core_BAO_OptionValue::del($id); return TRUE; }
/** * @param CRM_Extension_Info $info * * @return bool */ public function onPreUninstall(CRM_Extension_Info $info) { // if( !array_key_exists( $info->key, $this->customReports ) ) { // CRM_Core_Error::fatal( 'This report is not registered.' ); // } $customReports = $this->getCustomReportsByName(); $cr = $this->getCustomReportsById(); $id = $cr[$customReports[$info->key]]; $optionValue = CRM_Core_BAO_OptionValue::del($id); return $optionValue ? TRUE : FALSE; }
/** * Implementation of hook_civicrm_uninstall */ function clickatell_civicrm_uninstall() { $optionID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', 'clickatell', 'id', 'name'); if ($optionID) { CRM_Core_BAO_OptionValue::del($optionID); } $filter = array('name' => 'org.civicrm.sms.clickatell'); $Providers = CRM_SMS_BAO_Provider::getProviders(False, $filter, False); if ($Providers) { foreach ($Providers as $key => $value) { CRM_SMS_BAO_Provider::del($value['id']); } } return _clickatell_civix_civicrm_uninstall(); }
/** * Function to process the form * * @access public * * @return void */ public function postProcess() { if ($this->_action & CRM_Core_Action::DELETE) { $fieldValues = array('option_group_id' => $this->_gid); $wt = CRM_Utils_Weight::delWeight('CRM_Core_DAO_OptionValue', $this->_id, $fieldValues); if (CRM_Core_BAO_OptionValue::del($this->_id)) { CRM_Core_Session::setStatus(ts('Selected Survey type has been deleted.'), ts('Record Deleted'), 'success'); } } else { $params = $ids = array(); $params = $this->exportValues(); // set db value of filter in params if filter is non editable if ($this->_id && !array_key_exists('filter', $params)) { $params['filter'] = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', $this->_id, 'filter', 'id'); } $groupParams = array('name' => $this->_gName); $params['component_id'] = CRM_Core_Component::getComponentID('CiviCampaign'); $optionValue = CRM_Core_OptionValue::addOptionValue($params, $groupParams, $this->_action, $this->_id); CRM_Core_Session::setStatus(ts('The Survey type \'%1\' has been saved.', array(1 => $optionValue->label)), ts('Saved'), 'success'); } }
/** * Function to delete activity type * * @param activityTypeId int activity type id to delete * * @return boolen * * @access public * * @deprecated - we will introduce OptionValue Delete- plse consider helping with this if not done * {@example ActivityTypeDelete.php 0} */ function civicrm_api3_activity_type_delete($params) { civicrm_api3_verify_mandatory($params, NULL, array('activity_type_id')); $activityTypeId = $params['activity_type_id']; require_once 'CRM/Core/BAO/OptionValue.php'; return CRM_Core_BAO_OptionValue::del($activityTypeId); }
private function _removeExtensionEntry() { CRM_Core_BAO_OptionValue::del($this->id); CRM_Core_Session::setStatus(ts('Selected option value has been deleted.')); }
/** * Function to process the form * * @access public * * @return None */ public function postProcess() { CRM_Utils_System::flushCache(); $params = $this->exportValues(); if ($this->_action & CRM_Core_Action::DELETE) { CRM_Core_BAO_OptionValue::del($this->_id); CRM_Core_Session::setStatus(ts('Selected option value has been deleted.'), ts('Record Deleted'), 'success'); } else { $params = $ids = array(); // store the submitted values in an array $params = $this->exportValues(); $params['option_group_id'] = $this->_gid; if ($this->_action & CRM_Core_Action::UPDATE) { $ids['optionValue'] = $this->_id; } //set defaultGreeting option in params to save default value as per contactOption-defaultValue mapping if (CRM_Utils_Array::value('contactOptions', $params)) { $params['filter'] = CRM_Utils_Array::value('contactOptions', $params); $params['defaultGreeting'] = 1; } $optionValue = CRM_Core_BAO_OptionValue::add($params, $ids); // CRM-11516 if (CRM_Utils_Array::value('financial_account_id', $params)) { $relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Asset Account is' ")); $params = array('entity_table' => 'civicrm_option_value', 'entity_id' => $optionValue->id, 'account_relationship' => $relationTypeId, 'financial_account_id' => $params['financial_account_id']); CRM_Financial_BAO_FinancialTypeAccount::add($params); } CRM_Core_Session::setStatus(ts('The Option Value \'%1\' has been saved.', array(1 => $optionValue->label)), ts('Saved'), 'success'); } }
public static function del($absenceTypeId) { $absenceType = new CRM_HRAbsence_DAO_HRAbsenceType(); $absenceType->id = $absenceTypeId; $absenceType->find(TRUE); $absenceActivities = CRM_Core_OptionGroup::values('activity_type', FALSE, FALSE, FALSE, " AND grouping = 'Timesheet'", 'id'); if ($absenceType->debit_activity_type_id && ($id = CRM_Utils_Array::value($absenceType->debit_activity_type_id, $absenceActivities))) { CRM_Core_BAO_OptionValue::del($id); } if ($absenceType->credit_activity_type_id && ($id = CRM_Utils_Array::value($absenceType->credit_activity_type_id, $absenceActivities))) { CRM_Core_BAO_OptionValue::del($id); } $absenceType->delete(); }
/** * Function to delete activity type * @param activityTypeId int activity type id to delete * @return boolen * * @access public */ function civicrm_activity_type_delete($activityTypeId) { require_once 'CRM/Core/BAO/OptionValue.php'; return CRM_Core_BAO_OptionValue::del($activityTypeId); }
/** * Function to process the form * * @access public * @return None */ public function postProcess() { if ($this->_action & CRM_Core_Action::DELETE) { $fieldValues = array('option_group_id' => $this->_gid); $wt = CRM_Utils_Weight::delWeight('CRM_Core_DAO_OptionValue', $this->_id, $fieldValues); if (CRM_Core_BAO_OptionValue::del($this->_id)) { if ($this->_gName == 'phone_type') { require_once 'CRM/Core/BAO/Phone.php'; CRM_Core_BAO_Phone::setOptionToNull(CRM_Utils_Array::value('value', $this->_defaultValues)); } CRM_Core_Session::setStatus(ts('Selected %1 type has been deleted.', array(1 => $this->_GName))); } else { CRM_Core_Session::setStatus(ts('Selected %1 type has not been deleted.', array(1 => $this->_GName))); CRM_Utils_Weight::correctDuplicateWeights('CRM_Core_DAO_OptionValue', $fieldValues); } } else { $params = $ids = array(); $params = $this->exportValues(); // allow multiple defaults within group. $allowMultiDefaults = array('email_greeting', 'postal_greeting', 'addressee', 'from_email_address'); if (CRM_Utils_Array::value('is_default', $params) && in_array($this->_gName, $allowMultiDefaults)) { if ($this->_gName == 'from_email_address') { $params['reset_default_for'] = array('domain_id' => CRM_Core_Config::domainID()); } else { if ($filter = CRM_Utils_Array::value('contactOptions', $params)) { $params['filter'] = $filter; $params['reset_default_for'] = array('filter' => "0, " . $params['filter']); } } } $groupParams = array('name' => $this->_gName); require_once 'CRM/Core/OptionValue.php'; $optionValue = CRM_Core_OptionValue::addOptionValue($params, $groupParams, $this->_action, $this->_id); CRM_Core_Session::setStatus(ts('The %1 \'%2\' has been saved.', array(1 => $this->_GName, 2 => $optionValue->label))); } }
/** * Function to process the form * * @access public * @return None */ public function postProcess() { if ($this->_action & CRM_Core_Action::DELETE) { $fieldValues = array('option_group_id' => $this->_gid); $wt = CRM_Utils_Weight::delWeight('CRM_Core_DAO_OptionValue', $this->_id, $fieldValues); if (CRM_Core_BAO_OptionValue::del($this->_id)) { if ($this->_gName == 'phone_type') { require_once 'CRM/Core/BAO/Phone.php'; CRM_Core_BAO_Phone::setOptionToNull(CRM_Utils_Array::value('value', $this->_defaultValues)); } CRM_Core_Session::setStatus(ts('Selected %1 type has been deleted.', array(1 => $this->_GName))); } else { CRM_Core_Session::setStatus(ts('Selected %1 type has not been deleted.', array(1 => $this->_GName))); CRM_Utils_Weight::correctDuplicateWeights('CRM_Core_DAO_OptionValue', $fieldValues); } } else { $params = $ids = array(); $params = $this->exportValues(); //set defaultGreeting option in params as per contact type if (CRM_Utils_Array::value('contactOptions', $params)) { $params['filter'] = CRM_Utils_Array::value('contactOptions', $params); $params['defaultGreeting'] = 1; } $groupParams = array('name' => $this->_gName); require_once 'CRM/Core/OptionValue.php'; $optionValue = CRM_Core_OptionValue::addOptionValue($params, $groupParams, $this->_action, $this->_id); CRM_Core_Session::setStatus(ts('The %1 \'%2\' has been saved.', array(1 => $this->_GName, 2 => $optionValue->label))); } }
/** * Function to process the form * * @access public * * @return None */ public function postProcess() { if ($this->_action & CRM_Core_Action::DELETE) { $fieldValues = array('option_group_id' => $this->_gid); $wt = CRM_Utils_Weight::delWeight('CRM_Core_DAO_OptionValue', $this->_id, $fieldValues); if (CRM_Core_BAO_OptionValue::del($this->_id)) { if ($this->_gName == 'phone_type') { CRM_Core_BAO_Phone::setOptionToNull(CRM_Utils_Array::value('value', $this->_defaultValues)); } CRM_Core_Session::setStatus(ts('Selected %1 type has been deleted.', array(1 => $this->_GName))); } else { CRM_Core_Session::setStatus(ts('Selected %1 type has not been deleted.', array(1 => $this->_GName))); CRM_Utils_Weight::correctDuplicateWeights('CRM_Core_DAO_OptionValue', $fieldValues); } } else { $params = $ids = array(); $params = $this->exportValues(); // allow multiple defaults within group. $allowMultiDefaults = array('email_greeting', 'postal_greeting', 'addressee', 'from_email_address'); if (in_array($this->_gName, $allowMultiDefaults)) { if ($this->_gName == 'from_email_address') { $params['reset_default_for'] = array('domain_id' => CRM_Core_Config::domainID()); } elseif ($filter = CRM_Utils_Array::value('contactOptions', $params)) { $params['filter'] = $filter; $params['reset_default_for'] = array('filter' => "0, " . $params['filter']); } //make sure we should has to have space, CRM-6977 if ($this->_gName == 'from_email_address') { $params['label'] = str_replace('"<', '" <', $params['label']); } } // set db value of filter in params if filter is non editable if ($this->_id && !array_key_exists('filter', $params) && !$this->_gName == 'participant_role') { $params['filter'] = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', $this->_id, 'filter', 'id'); } $groupParams = array('name' => $this->_gName); $optionValue = CRM_Core_OptionValue::addOptionValue($params, $groupParams, $this->_action, $this->_id); CRM_Core_Session::setStatus(ts('The %1 \'%2\' has been saved.', array(1 => $this->_GName, 2 => $optionValue->label))); } }
/** * This function preserve the civicrm_domain.email_name and civicrm_domain.email_address * as a default option value into "from_email_address" option group * and drop these columns from civicrm_domain table. * @access public * * @return void */ function upgradeDomainFromEmail() { $query = "\nSELECT id\n FROM civicrm_option_group\n WHERE name = 'from_Email_address'"; $fmaGroup = CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray); $fmaGroupId = NULL; if ($fmaGroup->fetch()) { $fmaGroupId = $fmaGroup->id; } else { //insert 'from_mailing_address' option group. $query = "\nINSERT INTO civicrm_option_group ( name, description, is_reserved, is_active )\nVALUES ('from_email_address', 'From Email Address', 0, 1)"; CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray); //get the group id. $query = "\nSELECT id\n FROM civicrm_option_group\n WHERE name = 'from_email_address'"; $dao = CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray); if ($dao->fetch()) { $fmaGroupId = $dao->id; } } if ($fmaGroupId) { //get domain from email address and name as default value. $domain = CRM_Core_BAO_Domain::getDomain(); $domain->selectAdd(); $domain->selectAdd('email_name', 'email_address'); $domain->find(TRUE); $formEmailAddress = '"' . $domain->email_name . '"<' . $domain->email_address . '>'; //first check given domain email address exist in option //value, if yes make it as domain email address by making //it as default from email address.. //get the existing from email address. $optionValues = array(); $grpParams['name'] = 'from_email_address'; CRM_Core_OptionValue::getValues($grpParams, $optionValues); $maxVal = $maxWt = 1; $insertEmailAddress = TRUE; if (!empty($optionValues)) { //make existing is_default = 0 $query = "\nUPDATE civicrm_option_value\n SET is_default = 0\n WHERE option_group_id = %1"; $params = array(1 => array($fmaGroupId, 'Integer')); CRM_Core_DAO::executeQuery($query, $params); //if domain from name and email exist as name or label in option value //table need to preserve that name and label and take care that label //and name both remain unique in db. $labelValues = $nameValues = array(); foreach ($optionValues as $id => $value) { if ($value['label'] == $formEmailAddress) { $labelValues = $value; } elseif ($value['name'] == $formEmailAddress) { $nameValues = $value; } } //as we consider label so label should preserve. $updateValues = array(); if (!empty($labelValues)) { $updateValues = $labelValues; } //if matching name found need to preserve it. if (!empty($nameValues)) { //copy domain from email address as label. if (empty($updateValues)) { $updateValues = $nameValues; $updateValues['label'] = $formEmailAddress; } else { //since name is also imp so preserve it //as name for domain email address record. $updateValues['name'] = $nameValues['name']; //name is unique so drop name value record. //since we transfer this name to found label record. CRM_Core_BAO_OptionValue::del($nameValues['id']); } } if (!empty($updateValues)) { $insertEmailAddress = FALSE; //update label/name found record w/ manupulated values. $updateValues['is_active'] = $updateValues['is_default'] = 1; $optionValue = new CRM_Core_DAO_OptionValue(); $optionValue->copyValues($updateValues); $optionValue->save(); } //get the max value and wt. if ($insertEmailAddress) { $query = "\nSELECT max(ROUND(civicrm_option_value.value)) as maxVal,\n max(civicrm_option_value.weight) as maxWt\n FROM civicrm_option_value, civicrm_option_group\n WHERE civicrm_option_group.name = 'from_Email_address'\n AND civicrm_option_value.option_group_id = civicrm_option_group.id\nGROUP BY civicrm_option_group.id"; $dao = CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray); if ($dao->fetch()) { $maxWt += $dao->maxWt; $maxVal += $dao->maxVal; } } } if ($insertEmailAddress) { //insert domain from email address and name. $query = "\nINSERT INTO `civicrm_option_value`\n (`option_group_id`, `label`, `value`, `name` , `grouping`, `filter`, `is_default`,\n `weight`, `description`, `is_optgroup`, `is_reserved`, `is_active`, `component_id`)\n VALUES ( %1, %2, %3, %2, NULL, 0, 1, %4, 'Default domain email address and from name.', 0, 0, 1, NULL)"; $params = array(1 => array($fmaGroupId, 'Integer'), 2 => array($formEmailAddress, 'String'), 3 => array($maxVal, 'Integer'), 4 => array($maxWt, 'Integer')); CRM_Core_DAO::executeQuery($query, $params); } //drop civicrm_domain.email_name and //civicrm_domain.email_address. $query = "\nALTER TABLE `civicrm_domain`\n DROP `email_name`,\n DROP `email_address`"; CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray); } }
/** * Delete ActivityType. * * @param array $params * Array including id of activity_type to delete. * * @return array * API result array * * @deprecated use OptionValue api */ function civicrm_api3_activity_type_delete($params) { return civicrm_api3_create_success(CRM_Core_BAO_OptionValue::del($params['id']), $params); }
/** * Deletes an existing OptionValue * * @param array $params * * {@example OptionValueDelete.php 0} * * @return array Api result * {@getfields OptionValue_create} * @access public */ function civicrm_api3_option_value_delete($params) { return CRM_Core_BAO_OptionValue::del((int) $params['id']) ? civicrm_api3_create_success() : civicrm_api3_create_error('Could not delete OptionValue ' . $params['id']); }
/** * Delete ActivityType. * * @param array $params * Array including id of activity_type to delete. * * @return array * API result array * * @deprecated use OptionValue api */ function civicrm_api3_activity_type_delete($params) { $result = CRM_Core_BAO_OptionValue::del($params['id']); if ($result) { return civicrm_api3_create_success(TRUE, $params); } throw new API_Exception("Failure to delete activity type id {$params['id']}"); }
/** * Function to process the form * * @access public * * @return None */ public function postProcess() { if ($this->_action & CRM_Core_Action::DELETE) { if (CRM_Core_BAO_OptionValue::del($this->_id)) { CRM_Core_Session::setStatus(ts('Selected %1 Report has been deleted.', array(1 => $this->_GName))); CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin/report/options/report_template', "reset=1")); } else { CRM_Core_Session::setStatus(ts('Selected %1 type has not been deleted.', array(1 => $this->_GName))); CRM_Utils_Weight::correctDuplicateWeights('CRM_Core_DAO_OptionValue', $fieldValues); } } else { // get the submitted form values. $params = $this->controller->exportValues($this->_name); $ids = array(); $groupParams = array('name' => 'report_template'); $optionValue = CRM_Core_OptionValue::addOptionValue($params, $groupParams, $this->_action, $this->_id); CRM_Core_Session::setStatus(ts('The %1 \'%2\' has been saved.', array(1 => 'Report Template', 2 => $optionValue->label))); CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin/report/options/report_template', "reset=1")); } }
/** * Process the form * * @param null * * @return void * @access public */ public function postProcess() { require_once 'CRM/Core/OptionValue.php'; if ($this->_action == CRM_Core_Action::DELETE) { $fieldValues = array('option_group_id' => $this->_ogId); $wt = CRM_Utils_Weight::delWeight('CRM_Core_DAO_OptionValue', $this->_oid, $fieldValues); $label = CRM_Core_DAO::getFieldValue("CRM_Core_DAO_OptionValue", $this->_oid, 'label', 'id'); if (CRM_Core_BAO_OptionValue::del($this->_oid)) { CRM_Core_Session::setStatus(ts('%1 option has been deleted.', array(1 => $label))); } return; } else { $params = $ids = array(); $params = $this->controller->exportValues('Option'); $fieldLabel = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_Field', $this->_fid, 'label'); $params['description'] = $fieldLabel . ' - ' . $params['label']; $params['value'] = CRM_Utils_Rule::cleanMoney(trim($params['value'])); $groupParams = array('id' => $this->_ogId); // make name value consistant. $params['name'] = $params['value']; $optionValue = CRM_Core_OptionValue::addOptionValue($params, $groupParams, $this->_action, $this->_oid); CRM_Core_Session::setStatus(ts('The option \'%1\' has been saved.', array(1 => $params['label']))); } }
/** * Process the form submission. */ public function postProcess() { if ($this->_action & CRM_Core_Action::DELETE) { $fieldValues = array('option_group_id' => $this->_gid); $wt = CRM_Utils_Weight::delWeight('CRM_Core_DAO_OptionValue', $this->_id, $fieldValues); if (CRM_Core_BAO_OptionValue::del($this->_id)) { if ($this->_gName == 'phone_type') { CRM_Core_BAO_Phone::setOptionToNull(CRM_Utils_Array::value('value', $this->_defaultValues)); } CRM_Core_Session::setStatus(ts('Selected %1 type has been deleted.', array(1 => $this->_gLabel)), ts('Record Deleted'), 'success'); } else { CRM_Core_Session::setStatus(ts('Selected %1 type has not been deleted.', array(1 => $this->_gLabel)), ts('Sorry'), 'error'); CRM_Utils_Weight::correctDuplicateWeights('CRM_Core_DAO_OptionValue', $fieldValues); } } else { $params = $ids = array(); $params = $this->exportValues(); // allow multiple defaults within group. $allowMultiDefaults = array('email_greeting', 'postal_greeting', 'addressee', 'from_email_address'); if (in_array($this->_gName, $allowMultiDefaults)) { if ($this->_gName == 'from_email_address') { $params['reset_default_for'] = array('domain_id' => CRM_Core_Config::domainID()); } elseif ($filter = CRM_Utils_Array::value('contactOptions', $params)) { $params['filter'] = $filter; $params['reset_default_for'] = array('filter' => "0, " . $params['filter']); } //make sure we should has to have space, CRM-6977 if ($this->_gName == 'from_email_address') { $params['label'] = str_replace('"<', '" <', $params['label']); } } // set value of filter if not present in params if ($this->_id && !array_key_exists('filter', $params)) { if ($this->_gName == 'participant_role') { $params['filter'] = 0; } else { $params['filter'] = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', $this->_id, 'filter', 'id'); } } $groupParams = array('name' => $this->_gName); $optionValue = CRM_Core_OptionValue::addOptionValue($params, $groupParams, $this->_action, $this->_id); // CRM-11516 if (!empty($params['financial_account_id'])) { $relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Asset Account is' ")); $params = array('entity_table' => 'civicrm_option_value', 'entity_id' => $optionValue->id, 'account_relationship' => $relationTypeId, 'financial_account_id' => $params['financial_account_id']); CRM_Financial_BAO_FinancialTypeAccount::add($params); } CRM_Core_Session::setStatus(ts('The %1 \'%2\' has been saved.', array(1 => $this->_gLabel, 2 => $optionValue->label)), ts('Saved'), 'success'); } }
/** * Function to process the form * * @access public * @return None */ public function postProcess() { $params = $this->exportValues(); require_once 'CRM/Core/BAO/OptionValue.php'; if ($this->_action & CRM_Core_Action::DELETE) { CRM_Core_BAO_OptionValue::del($this->_id); CRM_Core_Session::setStatus(ts('Selected option value has been deleted.')); } else { $params = $ids = array(); // store the submitted values in an array $params = $this->exportValues(); $params['option_group_id'] = $this->_gid; if ($this->_action & CRM_Core_Action::UPDATE) { $ids['optionValue'] = $this->_id; } //set defaultGreeting option in params to save default value as per contactOption-defaultValue mapping if (CRM_Utils_Array::value('contactOptions', $params)) { $params['filter'] = CRM_Utils_Array::value('contactOptions', $params); $params['defaultGreeting'] = 1; } $optionValue = CRM_Core_BAO_OptionValue::add($params, $ids); CRM_Core_Session::setStatus(ts('The Option Value \'%1\' has been saved.', array(1 => $optionValue->label))); } }
/** * Function to delete activity type * * @param activityTypeId int activity type id to delete * * @return boolen * * @access public */ function civicrm_activity_type_delete($params) { if (!isset($params['activity_type_id'])) { return civicrm_create_error(ts('Required parameter "activity_type_id" not found')); } $activityTypeId = $params['activity_type_id']; require_once 'CRM/Core/BAO/OptionValue.php'; return CRM_Core_BAO_OptionValue::del($activityTypeId); }
/** * Example: Run an external SQL script when the module is uninstalled **/ public function uninstall() { $dao = CRM_Core_DAO::executeQuery('SELECT * from civicrm_hrabsence_type'); while ($dao->fetch()) { if ($dao->credit_activity_type_id) { $query = "DELETE FROM civicrm_activity WHERE activity_type_id IN ( {$dao->credit_activity_type_id} )"; CRM_Core_DAO::executeQuery($query); CRM_Core_BAO_OptionValue::del($dao->credit_activity_type_id); } if ($dao->debit_activity_type_id) { $query = "DELETE FROM civicrm_activity WHERE activity_type_id IN ( {$dao->debit_activity_type_id} )"; CRM_Core_DAO::executeQuery($query); CRM_Core_BAO_OptionValue::del($dao->debit_activity_type_id); } } CRM_Core_DAO::executeQuery('DROP TABLE civicrm_hrabsence_entitlement'); CRM_Core_DAO::executeQuery('DROP TABLE civicrm_hrabsence_period'); CRM_Core_DAO::executeQuery('DROP TABLE civicrm_hrabsence_type'); }