本文整理汇总了PHP中CRM_Utils_Hook::custom方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_Hook::custom方法的具体用法?PHP CRM_Utils_Hook::custom怎么用?PHP CRM_Utils_Hook::custom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Utils_Hook
的用法示例。
在下文中一共展示了CRM_Utils_Hook::custom方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
/**
* @param array $customParams
*
* @throws Exception
*/
public static function create(&$customParams)
{
if (empty($customParams) || !is_array($customParams)) {
return;
}
foreach ($customParams as $tableName => $tables) {
foreach ($tables as $index => $fields) {
$sqlOP = NULL;
$hookID = NULL;
$hookOP = NULL;
$entityID = NULL;
$isMultiple = FALSE;
$set = array();
$params = array();
$count = 1;
foreach ($fields as $field) {
if (!$sqlOP) {
$entityID = $field['entity_id'];
$hookID = $field['custom_group_id'];
$isMultiple = $field['is_multiple'];
if (array_key_exists('id', $field)) {
$sqlOP = "UPDATE {$tableName} ";
$where = " WHERE id = %{$count}";
$params[$count] = array($field['id'], 'Integer');
$count++;
$hookOP = 'edit';
} else {
$sqlOP = "INSERT INTO {$tableName} ";
$where = NULL;
$hookOP = 'create';
}
}
// fix the value before we store it
$value = $field['value'];
$type = $field['type'];
switch ($type) {
case 'StateProvince':
$type = 'Integer';
if (is_array($value)) {
$value = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, $value) . CRM_Core_DAO::VALUE_SEPARATOR;
$type = 'String';
} elseif (!is_numeric($value) && !strstr($value, CRM_Core_DAO::VALUE_SEPARATOR)) {
//fix for multi select state, CRM-3437
$mulValues = explode(',', $value);
$validStates = array();
foreach ($mulValues as $key => $stateVal) {
$states = array();
$states['state_province'] = trim($stateVal);
CRM_Utils_Array::lookupValue($states, 'state_province', CRM_Core_PseudoConstant::stateProvince(), TRUE);
if (empty($states['state_province_id'])) {
CRM_Utils_Array::lookupValue($states, 'state_province', CRM_Core_PseudoConstant::stateProvinceAbbreviation(), TRUE);
}
$validStates[] = CRM_Utils_Array::value('state_province_id', $states);
}
$value = implode(CRM_Core_DAO::VALUE_SEPARATOR, $validStates);
$type = 'String';
} elseif (!$value) {
// CRM-3415
// using type of timestamp allows us to sneak in a null into db
// gross but effective hack
$value = NULL;
$type = 'Timestamp';
} else {
$type = 'String';
}
break;
case 'Country':
$type = 'Integer';
$mulValues = explode(',', $value);
if (is_array($value)) {
$value = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, $value) . CRM_Core_DAO::VALUE_SEPARATOR;
$type = 'String';
} elseif (!is_numeric($value) && !strstr($value, CRM_Core_DAO::VALUE_SEPARATOR)) {
//fix for multi select country, CRM-3437
$mulValues = explode(',', $value);
$validCountries = array();
foreach ($mulValues as $key => $countryVal) {
$countries = array();
$countries['country'] = trim($countryVal);
CRM_Utils_Array::lookupValue($countries, 'country', CRM_Core_PseudoConstant::country(), TRUE);
if (empty($countries['country_id'])) {
CRM_Utils_Array::lookupValue($countries, 'country', CRM_Core_PseudoConstant::countryIsoCode(), TRUE);
}
$validCountries[] = CRM_Utils_Array::value('country_id', $countries);
}
$value = implode(CRM_Core_DAO::VALUE_SEPARATOR, $validCountries);
$type = 'String';
} elseif (!$value) {
// CRM-3415
// using type of timestamp allows us to sneak in a null into db
// gross but effective hack
$value = NULL;
$type = 'Timestamp';
} else {
$type = 'String';
//.........这里部分代码省略.........
示例2: deleteCustomValue
/**
* Delete option value give an option value and custom group id.
*
* @param int $customValueID
* Custom value ID.
* @param int $customGroupID
* Custom group ID.
*
* @return void
*/
public static function deleteCustomValue($customValueID, $customGroupID)
{
// first we need to find custom value table, from custom group ID
$tableName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $customGroupID, 'table_name');
// delete custom value from corresponding custom value table
$sql = "DELETE FROM {$tableName} WHERE id = {$customValueID}";
CRM_Core_DAO::executeQuery($sql);
CRM_Utils_Hook::custom('delete', $customGroupID, NULL, $customValueID);
}