/** * Process the form when submitted * * @return void * @access public */ public function postProcess() { require_once 'CRM/Core/Transaction.php'; $transaction = new CRM_Core_Transaction(); // first delete the join entries associated with this contribution page require_once 'CRM/Core/DAO/UFJoin.php'; $dao = new CRM_Core_DAO_UFJoin(); $params = array('entity_table' => 'civicrm_contribution_page', 'entity_id' => $this->_id); $dao->copyValues($params); $dao->delete(); require_once 'CRM/Core/OptionGroup.php'; $groupName = "civicrm_contribution_page.amount.{$this->_id}"; CRM_Core_OptionGroup::deleteAssoc($groupName); //next delete the membership block fields require_once 'CRM/Member/DAO/MembershipBlock.php'; $dao = new CRM_Member_DAO_MembershipBlock(); $dao->entity_table = 'civicrm_contribution_page'; $dao->entity_id = $this->_id; $dao->delete(); //next delete the pcp block fields require_once 'CRM/Contribute/DAO/PCPBlock.php'; $dao = new CRM_Contribute_DAO_PCPBlock(); $dao->entity_table = 'civicrm_contribution_page'; $dao->entity_id = $this->_id; $dao->delete(); // need to delete premiums. CRM-4586 require_once 'CRM/Contribute/BAO/Premium.php'; CRM_Contribute_BAO_Premium::deletePremium($this->_id); // price set cleanup, CRM-5527 require_once 'CRM/Price/BAO/Set.php'; CRM_Price_BAO_Set::removeFrom('civicrm_contribution_page', $this->_id); // finally delete the contribution page require_once 'CRM/Contribute/DAO/ContributionPage.php'; $dao = new CRM_Contribute_DAO_ContributionPage(); $dao->id = $this->_id; $dao->delete(); $transaction->commit(); CRM_Core_Session::setStatus(ts('The contribution page \'%1\' has been deleted.', array(1 => $this->_title))); }
/** * Process the form * * @return void * @access public */ public function postProcess() { // get the submitted form values. $params = $this->controller->exportValues($this->_name); if (CRM_Utils_Array::value('payment_processor_id', $params) == CRM_Core_DAO::getFieldValue('CRM_Core_DAO_PaymentProcessor', 'AuthNet', 'id', 'payment_processor_type')) { CRM_Core_Session::setStatus(ts(' Please note that the Authorize.net payment processor only allows recurring contributions and auto-renew memberships with payment intervals from 7-365 days or 1-12 months (i.e. not greater than 1 year).')); } // check for price set. $priceSetID = CRM_Utils_Array::value('price_set_id', $params); // get required fields. $fields = array('id' => $this->_id, 'is_recur' => false, 'min_amount' => "null", 'max_amount' => "null", 'is_monetary' => false, 'is_pay_later' => false, 'is_recur_interval' => false, 'recur_frequency_unit' => "null", 'default_amount_id' => "null", 'is_allow_other_amount' => false, 'amount_block_is_active' => false); $resetFields = array(); if ($priceSetID) { $resetFields = array('min_amount', 'max_amount', 'is_allow_other_amount'); } if (!CRM_Utils_Array::value('is_recur', $params)) { $resetFields = array_merge($resetFields, array('is_recur_interval', 'recur_frequency_unit')); } foreach ($fields as $field => $defaultVal) { $val = CRM_Utils_Array::value($field, $params, $defaultVal); if (in_array($field, $resetFields)) { $val = $defaultVal; } if (in_array($field, array('min_amount', 'max_amount'))) { $val = CRM_Utils_Rule::cleanMoney($val); } $params[$field] = $val; } if ($params['is_recur']) { require_once 'CRM/Core/BAO/CustomOption.php'; $params['recur_frequency_unit'] = implode(CRM_Core_BAO_CustomOption::VALUE_SEPERATOR, array_keys($params['recur_frequency_unit'])); $params['is_recur_interval'] = CRM_Utils_Array::value('is_recur_interval', $params, false); } require_once 'CRM/Contribute/BAO/ContributionPage.php'; $contributionPage = CRM_Contribute_BAO_ContributionPage::create($params); $contributionPageID = $contributionPage->id; // prepare for data cleanup. $deleteAmountBlk = $deletePledgeBlk = $deletePriceSet = false; if ($this->_priceSetID) { $deletePriceSet = true; } if ($this->_pledgeBlockID) { $deletePledgeBlk = true; } if (!empty($this->_amountBlock)) { $deleteAmountBlk = true; } if ($contributionPageID) { require_once 'CRM/Price/BAO/Set.php'; require_once 'CRM/Core/OptionGroup.php'; require_once 'CRM/Pledge/BAO/PledgeBlock.php'; if (CRM_Utils_Array::value('amount_block_is_active', $params)) { // handle price set. if ($priceSetID) { // add/update price set. $deletePriceSet = false; CRM_Price_BAO_Set::addTo('civicrm_contribution_page', $contributionPageID, $priceSetID); } else { // process contribution amount block $deleteAmountBlk = false; $labels = CRM_Utils_Array::value('label', $params); $values = CRM_Utils_Array::value('value', $params); $default = CRM_Utils_Array::value('default', $params); $options = array(); for ($i = 1; $i < self::NUM_OPTION; $i++) { if (isset($values[$i]) && strlen(trim($values[$i])) > 0) { $options[] = array('label' => trim($labels[$i]), 'value' => CRM_Utils_Rule::cleanMoney(trim($values[$i])), 'weight' => $i, 'is_active' => 1, 'is_default' => $default == $i); } } CRM_Core_OptionGroup::createAssoc("civicrm_contribution_page.amount.{$contributionPageID}", $options, $params['default_amount_id']); if ($params['default_amount_id']) { CRM_Core_DAO::setFieldValue('CRM_Contribute_DAO_ContributionPage', $contributionPageID, 'default_amount_id', $params['default_amount_id']); } if (CRM_Utils_Array::value('is_pledge_active', $params)) { $deletePledgeBlk = false; $pledgeBlockParams = array('entity_id' => $contributionPageID, 'entity_table' => ts('civicrm_contribution_page')); if ($this->_pledgeBlockID) { $pledgeBlockParams['id'] = $this->_pledgeBlockID; } $pledgeBlock = array('pledge_frequency_unit', 'max_reminders', 'initial_reminder_day', 'additional_reminder_day'); foreach ($pledgeBlock as $key) { $pledgeBlockParams[$key] = CRM_Utils_Array::value($key, $params); } $pledgeBlockParams['is_pledge_interval'] = CRM_Utils_Array::value('is_pledge_interval', $params, false); // create pledge block. require_once 'CRM/Pledge/BAO/PledgeBlock.php'; CRM_Pledge_BAO_PledgeBlock::create($pledgeBlockParams); } } } // delete pledge block. if ($deletePledgeBlk) { CRM_Pledge_BAO_PledgeBlock::deletePledgeBlock($this->_pledgeBlockID); } // delete previous price set. if ($deletePriceSet) { CRM_Price_BAO_Set::removeFrom('civicrm_contribution_page', $contributionPageID); } // delete amount block. if ($deleteAmountBlk) { CRM_Core_OptionGroup::deleteAssoc("civicrm_contribution_page.amount.{$contributionPageID}"); } } }
/** * (Queue Task Callback) * * Upgrade code to create priceset for contribution pages and events */ public static function task_4_2_alpha1_createPriceSets(CRM_Queue_TaskContext $ctx, $rev) { $upgrade = new CRM_Upgrade_Form(); $daoName = array('civicrm_contribution_page' => array('CRM_Contribute_BAO_ContributionPage', CRM_Core_Component::getComponentID('CiviContribute')), 'civicrm_event' => array('CRM_Event_BAO_Event', CRM_Core_Component::getComponentID('CiviEvent'))); // get all option group used for event and contribution page $query = "\nSELECT id, name\nFROM civicrm_option_group\nWHERE name LIKE '%.amount.%' "; $dao = CRM_Core_DAO::executeQuery($query); while ($dao->fetch()) { $addTo = explode('.', $dao->name); if (!empty($addTo[2])) { $options = array('optionGroup' => $dao->name); self::createPriceSet($daoName, $addTo, $options); } CRM_Core_OptionGroup::deleteAssoc($dao->name); } //create pricesets for contribution with only other amount $query = "\nSELECT ccp.id as contribution_page_id, ccp.is_allow_other_amount, cmb.id as membership_block_id\nFROM civicrm_contribution_page ccp\nLEFT JOIN civicrm_membership_block cmb ON cmb.entity_id = ccp.id AND cmb.entity_table = 'civicrm_contribution_page'\nLEFT JOIN civicrm_price_set_entity cpse ON cpse.entity_id = ccp.id and cpse.entity_table = 'civicrm_contribution_page'\nWHERE cpse.price_set_id IS NULL"; $dao = CRM_Core_DAO::executeQuery($query); $addTo = array('civicrm_contribution_page'); while ($dao->fetch()) { $addTo[2] = $dao->contribution_page_id; $options = array('otherAmount' => $dao->is_allow_other_amount, 'membership' => $dao->membership_block_id); self::createPriceSet($daoName, $addTo, $options); } return TRUE; }
/** * Function to delete the event * * @param int $id event id * * @access public * @static * */ static function del($id) { if (!$id) { return null; } require_once 'CRM/Utils/Hook.php'; CRM_Utils_Hook::pre('delete', 'Event', $id, CRM_Core_DAO::$_nullArray); require_once 'CRM/Core/BAO/CustomGroup.php'; $extends = array('event'); $groupTree = CRM_Core_BAO_CustomGroup::getGroupDetail(null, null, $extends); foreach ($groupTree as $values) { $query = "DELETE FROM " . $values['table_name'] . " WHERE entity_id = " . $id; $params = array(1 => array($values['table_name'], 'string'), 2 => array($id, 'integer')); CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray); } $dependencies = array('CRM_Core_DAO_OptionGroup' => array('name' => 'civicrm_event.amount.' . $id), 'CRM_Core_DAO_UFJoin' => array('entity_id' => $id, 'entity_table' => 'civicrm_event')); require_once 'CRM/Core/BAO/OptionGroup.php'; foreach ($dependencies as $daoName => $values) { require_once str_replace('_', DIRECTORY_SEPARATOR, $daoName) . ".php"; eval('$dao = new ' . $daoName . '( );'); if ($daoName == 'CRM_Core_DAO_OptionGroup') { $dao->name = $values['name']; $dao->find(); while ($dao->fetch()) { CRM_Core_BAO_OptionGroup::del($dao->id); } } else { foreach ($values as $fieldName => $fieldValue) { $dao->{$fieldName} = $fieldValue; } $dao->find(); while ($dao->fetch()) { $dao->delete(); } } } require_once 'CRM/Core/OptionGroup.php'; CRM_Core_OptionGroup::deleteAssoc("civicrm_event.amount.{$id}.discount.%", "LIKE"); // price set cleanup, CRM-5527 require_once 'CRM/Price/BAO/Set.php'; CRM_Price_BAO_Set::removeFrom('civicrm_event', $id); require_once 'CRM/Event/DAO/Event.php'; $event = new CRM_Event_DAO_Event(); $event->id = $id; if ($event->find(true)) { $locBlockId = $event->loc_block_id; $result = $event->delete(); if (!is_null($locBlockId)) { self::deleteEventLocBlock($locBlockId, $id); } CRM_Utils_Hook::post('delete', 'Event', $id, $event); return $result; } return null; }
/** * @param $rev */ public function upgrade_4_1_beta1($rev) { //CRM-9311 $groupNames = array('directory_preferences', 'url_preferences'); foreach ($groupNames as $groupName) { CRM_Core_OptionGroup::deleteAssoc($groupName); } $domainCols = array(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME => array('contact_ajax_check_similar', 'activity_assignee_notification'), CRM_Core_BAO_Setting::CAMPAIGN_PREFERENCES_NAME => array('tag_unconfirmed', 'petition_contacts'), CRM_Core_BAO_Setting::EVENT_PREFERENCES_NAME => array('enable_cart'), CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME => array('profile_double_optin', 'profile_add_to_group_double_optin', 'track_civimail_replies', 'civimail_workflow', 'civimail_server_wide_lock'), CRM_Core_BAO_Setting::MEMBER_PREFERENCES_NAME => array('default_renewal_contribution_page'), CRM_Core_BAO_Setting::MULTISITE_PREFERENCES_NAME => array('is_enabled', 'uniq_email_per_site', 'domain_group_id', 'event_price_set_domain_id'), CRM_Core_BAO_Setting::DIRECTORY_PREFERENCES_NAME => array('uploadDir', 'imageUploadDir', 'customFileUploadDir', 'customTemplateDir', 'customPHPPathDir', 'extensionsDir'), CRM_Core_BAO_Setting::URL_PREFERENCES_NAME => array('userFrameworkResourceURL', 'imageUploadURL', 'customCSSURL')); $arrGroupNames = array_keys($domainCols); $groupNames = implode("','", $arrGroupNames); $arrNames = array(); foreach ($domainCols as $groupName => $names) { $arrNames[] = implode("','", $names); } $name = implode("','", $arrNames); $sql = "\n update civicrm_setting set is_domain = 1 where is_domain = 0 and group_name in ( '{$groupNames}' ) and name in ('{$name}')"; CRM_Core_DAO::executeQuery($sql); $upgrade = new CRM_Upgrade_Form(); $upgrade->assign('addWightForActivity', !CRM_Core_DAO::checkFieldExists('civicrm_activity', 'weight')); $upgrade->processSQL($rev); }
/** * Process the form * * @return void * @access public */ public function postProcess() { $params = array(); $params = $this->exportValues(); $this->set('discountSection', 0); if (CRM_Utils_Array::value('_qf_Fee_submit', $_POST)) { $this->buildAmountLabel(); $this->set('discountSection', 1); CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/event/manage', '#isDiscount')); return; } $params['is_pay_later'] = CRM_Utils_Array::value('is_pay_later', $params, 0); if ($this->_id) { require_once 'CRM/Price/BAO/Set.php'; // delete all the prior label values or discounts in the custom options table // and delete a price set if one exists if (!CRM_Price_BAO_Set::removeFrom('civicrm_event', $this->_id)) { require_once 'CRM/Core/OptionGroup.php'; CRM_Core_OptionGroup::deleteAssoc("civicrm_event.amount.{$this->_id}"); CRM_Core_OptionGroup::deleteAssoc("civicrm_event.amount.{$this->_id}.discount.%", "LIKE"); } } if ($params['is_monetary']) { if ($params['price_set_id']) { CRM_Price_BAO_Set::addTo('civicrm_event', $this->_id, $params['price_set_id']); } else { // if there are label / values, create custom options for them $labels = CRM_Utils_Array::value('label', $params); $values = CRM_Utils_Array::value('value', $params); $default = CRM_Utils_Array::value('default', $params); $options = array(); if (!CRM_Utils_System::isNull($labels) && !CRM_Utils_System::isNull($values)) { for ($i = 1; $i < self::NUM_OPTION; $i++) { if (!empty($labels[$i]) && !CRM_Utils_System::isNull($values[$i])) { $options[] = array('label' => trim($labels[$i]), 'value' => CRM_Utils_Rule::cleanMoney(trim($values[$i])), 'weight' => $i, 'is_active' => 1, 'is_default' => $default == $i); } } if (!empty($options)) { $params['default_fee_id'] = null; CRM_Core_OptionGroup::createAssoc("civicrm_event.amount.{$this->_id}", $options, $params['default_fee_id']); } } if (CRM_Utils_Array::value('is_discount', $params) == 1) { // if there are discounted set of label / values, // create custom options for them $labels = CRM_Utils_Array::value('discounted_label', $params); $values = CRM_Utils_Array::value('discounted_value', $params); $default = CRM_Utils_Array::value('discounted_default', $params); if (!CRM_Utils_System::isNull($labels) && !CRM_Utils_System::isNull($values)) { for ($j = 1; $j <= self::NUM_DISCOUNT; $j++) { $discountOptions = array(); for ($i = 1; $i < self::NUM_OPTION; $i++) { if (!empty($labels[$i]) && CRM_Utils_Array::value($j, $values[$i])) { $discountOptions[] = array('label' => trim($labels[$i]), 'value' => CRM_Utils_Rule::cleanMoney(trim($values[$i][$j])), 'weight' => $i, 'is_active' => 1, 'is_default' => $default == $i); } } if (!empty($discountOptions)) { $params['default_discount_fee_id'] = null; $discountOptionsGroupId = CRM_Core_OptionGroup::createAssoc("civicrm_event.amount.{$this->_id}.discount.{$params['discount_name'][$j]}", $discountOptions, $params['default_discount_fee_id'], $params['discount_name'][$j]); $discountParams = array('entity_table' => 'civicrm_event', 'entity_id' => $this->_id, 'option_group_id' => $discountOptionsGroupId, 'start_date' => CRM_Utils_Date::format($params["discount_start_date"][$j]), 'end_date' => CRM_Utils_Date::format($params["discount_end_date"][$j])); require_once 'CRM/Core/BAO/Discount.php'; CRM_Core_BAO_Discount::add($discountParams); } } } } } } else { $params['contribution_type_id'] = ''; } //update events table require_once 'CRM/Event/BAO/Event.php'; $params['id'] = $this->_id; CRM_Event_BAO_Event::add($params); parent::endPostProcess(); }
/** * Delete the price set field. * * @param int $id Field Id * * @return boolean * * @access public * @static * */ public static function deleteField($id) { $field =& new CRM_Price_DAO_Field(); $field->id = $id; if ($field->find(true)) { // delete the options for this field require_once 'CRM/Core/OptionGroup.php'; CRM_Core_OptionGroup::deleteAssoc("civicrm_price_field.amount.{$id}"); // reorder the weight before delete $fieldValues = array('price_set_id' => $field->price_set_id); require_once 'CRM/Utils/Weight.php'; CRM_Utils_Weight::delWeight('CRM_Price_DAO_Field', $field->id, $fieldValues); // now delete the field return $field->delete(); } return null; }
public function upgrade_1108() { $this->ctx->log->info('Applying update 1108'); if (CRM_Core_DAO::checkFieldExists('civicrm_hrjob_health', 'provider') && CRM_Core_DAO::checkFieldExists('civicrm_hrjob_health', 'provider_life_insurance')) { $opt_grp_name = array('hrjob_health_provider' => array('name' => 'Health_Insurance_Provider', 'label' => ts('Health Insurance Provider'), 'column' => 'provider'), 'hrjob_life_provider' => array('name' => 'Life_Insurance_Provider', 'label' => ts('Life Insurance Provider'), 'column' => 'provider_life_insurance')); $org_id = array_search('Organization', CRM_Contact_BAO_ContactType::basicTypePairs(FALSE, 'id')); $orgSubType = CRM_Contact_BAO_ContactType::subTypeInfo('Organization'); foreach ($opt_grp_name as $oKey => $oValue) { $subID = array_key_exists($oValue['name'], $orgSubType); if (!$subID) { CRM_Contact_BAO_ContactType::add(array('parent_id' => $org_id, 'is_active' => 1, 'name' => $oValue['name'], 'label' => $oValue['label'])); } $options = CRM_Core_OptionGroup::values($oKey, TRUE, FALSE); foreach ($options as $orgKey => $orgValue) { $params = array('organization_name' => $orgValue, 'sort_name' => $orgValue, 'display_name' => $orgValue, 'legal_name' => $orgValue, 'contact_type' => 'Organization', 'contact_sub_type' => $oValue['name']); $result = civicrm_api3('contact', 'create', $params); if ($result['id']) { CRM_Core_DAO::executeQuery("UPDATE civicrm_hrjob_health SET {$oValue['column']} = {$result['id']} WHERE {$oValue['column']} LIKE '{$orgValue}'"); CRM_Core_DAO::executeQuery("UPDATE civicrm_hrjob_health SET {$oValue['column']} = NULL WHERE {$oValue['column']} = ''"); } } CRM_Core_OptionGroup::deleteAssoc($oKey); } CRM_Core_DAO::executeQuery("ALTER TABLE `civicrm_hrjob_health`\n MODIFY COLUMN `provider` int(10) unsigned DEFAULT NULL,\n MODIFY COLUMN `provider_life_insurance` int(10) unsigned DEFAULT NULL,\n ADD CONSTRAINT `FK_civicrm_hrjob_health_provider` FOREIGN KEY (`provider`) REFERENCES `civicrm_contact`(`id`) ON DELETE SET NULL,\n ADD CONSTRAINT `FK_civicrm_hrjob_health_provider_life_insurance` FOREIGN KEY (`provider_life_insurance`) REFERENCES `civicrm_contact`(`id`) ON DELETE SET NULL"); } return TRUE; }
public function installAbsenceTypes() { $leaves = TRUE; $weight = 0; $values = ''; $options = CRM_Core_OptionGroup::values('hrjob_leave_type', TRUE, FALSE); if (empty($options)) { $leaves = FALSE; $options = array('Sick' => 'Sick', 'Vacation' => 'Vacation', 'Maternity' => 'Maternity', 'Paternity' => 'Paternity', 'TOIL' => 'TOIL', 'Other' => 'Other'); } $seperator = CRM_Core_DAO::VALUE_SEPARATOR; foreach ($options as $orgKey => $orgValue) { $params = array('title' => $orgValue, 'is_active' => 1, 'allow_debits' => 1); if ($orgKey == 'TOIL') { $params['allow_credits'] = 1; } $absenceTypes = CRM_HRAbsence_BAO_HRAbsenceType::create($params); $values .= " WHEN '{$orgValue}' THEN '{$absenceTypes->id}'"; if ($absenceTypes->debit_activity_type_id) { $absenceTypeID[] = $absenceTypes->debit_activity_type_id; if ($orgKey == 'Sick') { $sickTypeID = $absenceTypes->debit_activity_type_id; } } if ($absenceTypes->credit_activity_type_id) { $absenceTypeID[] = $absenceTypes->credit_activity_type_id; if ($orgKey == 'Sick') { $sickTypeID = $absenceTypes->debit_activity_type_id; } } } if (CRM_Core_DAO::checkTableExists('civicrm_hrjobcontract_leave') && $leaves) { $query = "UPDATE civicrm_hrjobcontract_leave\n SET leave_type = CASE leave_type\n {$values}\n END;"; CRM_Core_DAO::executeQuery($query); } CRM_Core_OptionGroup::deleteAssoc('hrjob_leave_type'); $absenceTypeIDs = implode($seperator, $absenceTypeID); $paramsCGroup = array('title' => 'Absence Comment', 'extends' => array('0' => 'Activity'), 'style' => 'Inline', 'extends_entity_column_value' => array('0' => $absenceTypeIDs), 'is_active' => 1); $customGroup = civicrm_api3('CustomGroup', 'get', array('sequential' => 1, 'title' => $paramsCGroup['title'])); $resultCGroup = CRM_Utils_Array::first($customGroup['values']); if (empty($resultCGroup['id'])) { $resultCGroup = civicrm_api3('custom_group', 'create', $paramsCGroup); } $paramsCField = array('custom_group_id' => $resultCGroup['id'], 'label' => 'Comment', 'html_type' => 'TextArea', 'data_type' => 'Memo', 'is_active' => 1); $resultCField = civicrm_api3('custom_field', 'get', $paramsCField); if ($resultCField['count'] == 0) { $resultCField = civicrm_api3('custom_field', 'create', $paramsCField); } $paramsSGroup = array('title' => 'Type of Sickness', 'extends' => array('0' => 'Activity'), 'style' => 'Inline', 'extends_entity_column_value' => array('0' => $sickTypeID), 'is_active' => 1); $sickGroup = civicrm_api3('CustomGroup', 'get', array('sequential' => 1, 'title' => $paramsSGroup['title'])); $resultSGroup = CRM_Utils_Array::first($sickGroup['values']); if (empty($resultSGroup['id'])) { $resultSGroup = civicrm_api3('custom_group', 'create', $paramsSGroup); } $paramsSField = array('custom_group_id' => $resultSGroup['id'], 'label' => 'Sick Type', 'html_type' => 'Select', 'data_type' => 'String', 'is_active' => 1); $resultSField = civicrm_api3('custom_field', 'get', $paramsSField); if ($resultSField['count'] == 0) { $resultSField = civicrm_api3('custom_field', 'create', $paramsSField); } $sickType = array('Cold', 'Cough', 'Fever'); foreach ($sickType as $Key => $val) { $paramsOVal = array('sequential' => 1, 'name' => $val, 'option_group_id' => $resultSField['values'][$resultSField['id']]['option_group_id']); $optionValue = civicrm_api3('OptionValue', 'get', array('sequential' => 1, 'option_group_id' => $paramsOVal['option_group_id'], 'name' => $paramsOVal['name'])); if ($optionValue['count'] == 0) { civicrm_api3('OptionValue', 'create', $paramsOVal); } } }