本文整理汇总了PHP中CRM_Core_BAO_RecurringEntity::delEntity方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_RecurringEntity::delEntity方法的具体用法?PHP CRM_Core_BAO_RecurringEntity::delEntity怎么用?PHP CRM_Core_BAO_RecurringEntity::delEntity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_BAO_RecurringEntity
的用法示例。
在下文中一共展示了CRM_Core_BAO_RecurringEntity::delEntity方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postProcess
/**
* Process the form submission.
*
* @param array $params
* @param string $type
* @param array $linkedEntities
*
* @throws \CiviCRM_API3_Exception
*/
public static function postProcess($params = array(), $type, $linkedEntities = array())
{
//Check entity_id not present in params take it from class variable
if (empty($params['entity_id'])) {
$params['entity_id'] = self::$_entityId;
}
//Process this function only when you get this variable
if ($params['allowRepeatConfigToSubmit'] == 1) {
if (!empty($params['entity_table']) && !empty($params['entity_id']) && $type) {
$params['used_for'] = $type;
if (empty($params['parent_entity_id'])) {
$params['parent_entity_id'] = self::$_parentEntityId;
}
if (!empty($params['schedule_reminder_id'])) {
$params['id'] = $params['schedule_reminder_id'];
} else {
$params['id'] = self::$_scheduleReminderID;
}
//Save post params to the schedule reminder table
$recurobj = new CRM_Core_BAO_RecurringEntity();
$dbParams = $recurobj->mapFormValuesToDB($params);
//Delete repeat configuration and rebuild
if (!empty($params['id'])) {
CRM_Core_BAO_ActionSchedule::del($params['id']);
unset($params['id']);
}
$actionScheduleObj = CRM_Core_BAO_ActionSchedule::add($dbParams);
//exclude dates
$excludeDateList = array();
if (CRM_Utils_Array::value('exclude_date_list', $params) && CRM_Utils_Array::value('parent_entity_id', $params) && $actionScheduleObj->entity_value) {
//Since we get comma separated values lets get them in array
$excludeDates = explode(",", $params['exclude_date_list']);
//Check if there exists any values for this option group
$optionGroupIdExists = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', $type . '_repeat_exclude_dates_' . $params['parent_entity_id'], 'id', 'name');
if ($optionGroupIdExists) {
CRM_Core_BAO_OptionGroup::del($optionGroupIdExists);
}
$optionGroupParams = array('name' => $type . '_repeat_exclude_dates_' . $actionScheduleObj->entity_value, 'title' => $type . ' recursion', 'is_reserved' => 0, 'is_active' => 1);
$opGroup = CRM_Core_BAO_OptionGroup::add($optionGroupParams);
if ($opGroup->id) {
$oldWeight = 0;
$fieldValues = array('option_group_id' => $opGroup->id);
foreach ($excludeDates as $val) {
$optionGroupValue = array('option_group_id' => $opGroup->id, 'label' => CRM_Utils_Date::processDate($val), 'value' => CRM_Utils_Date::processDate($val), 'name' => $opGroup->name, 'description' => 'Used for recurring ' . $type, 'weight' => CRM_Utils_Weight::updateOtherWeights('CRM_Core_DAO_OptionValue', $oldWeight, CRM_Utils_Array::value('weight', $params), $fieldValues), 'is_active' => 1);
$excludeDateList[] = $optionGroupValue['value'];
CRM_Core_BAO_OptionValue::create($optionGroupValue);
}
}
}
//Set type for API
$apiEntityType = explode("_", $type);
if (!empty($apiEntityType[1])) {
$apiType = $apiEntityType[1];
}
//Delete relations if any from recurring entity tables before inserting new relations for this entity id
if ($params['entity_id']) {
//If entity has any pre delete function, consider that first
if (CRM_Utils_Array::value('pre_delete_func', CRM_Core_BAO_RecurringEntity::$_recurringEntityHelper[$params['entity_table']]) && CRM_Utils_Array::value('helper_class', CRM_Core_BAO_RecurringEntity::$_recurringEntityHelper[$params['entity_table']])) {
$preDeleteResult = call_user_func_array(CRM_Core_BAO_RecurringEntity::$_recurringEntityHelper[$params['entity_table']]['pre_delete_func'], array($params['entity_id']));
if (!empty($preDeleteResult)) {
call_user_func(array(CRM_Core_BAO_RecurringEntity::$_recurringEntityHelper[$params['entity_table']]['helper_class'], $preDeleteResult));
}
}
//Ready to execute delete on entities if it has delete function set
if (CRM_Utils_Array::value('delete_func', CRM_Core_BAO_RecurringEntity::$_recurringEntityHelper[$params['entity_table']]) && CRM_Utils_Array::value('helper_class', CRM_Core_BAO_RecurringEntity::$_recurringEntityHelper[$params['entity_table']])) {
//Check if pre delete function has some ids to be deleted
if (!empty(CRM_Core_BAO_RecurringEntity::$_entitiesToBeDeleted)) {
foreach (CRM_Core_BAO_RecurringEntity::$_entitiesToBeDeleted as $eid) {
$result = civicrm_api3(ucfirst(strtolower($apiType)), CRM_Core_BAO_RecurringEntity::$_recurringEntityHelper[$params['entity_table']]['delete_func'], array('sequential' => 1, 'id' => $eid));
if ($result['error']) {
CRM_Core_Error::statusBounce('Error creating recurring list');
}
}
} else {
$getRelatedEntities = CRM_Core_BAO_RecurringEntity::getEntitiesFor($params['entity_id'], $params['entity_table'], FALSE);
foreach ($getRelatedEntities as $key => $value) {
$result = civicrm_api3(ucfirst(strtolower($apiType)), CRM_Core_BAO_RecurringEntity::$_recurringEntityHelper[$params['entity_table']]['delete_func'], array('sequential' => 1, 'id' => $value['id']));
if ($result['error']) {
CRM_Core_Error::statusBounce('Error creating recurring list');
}
}
}
}
// find all entities from the recurring set. At this point we 'll get entities which were not deleted
// for e.g due to participants being present. We need to delete them from recurring tables anyway.
$pRepeatingEntities = CRM_Core_BAO_RecurringEntity::getEntitiesFor($params['entity_id'], $params['entity_table']);
foreach ($pRepeatingEntities as $val) {
CRM_Core_BAO_RecurringEntity::delEntity($val['id'], $val['table'], TRUE);
}
}
$recursion = new CRM_Core_BAO_RecurringEntity();
//.........这里部分代码省略.........
示例2: delEntity
/**
* This function deletes main entity and related linked entities from recurring-entity table
*
* @param int $entityId
* Entity id
* @param string $entityTable
* Name of the entity table
*
*
* @return bool|CRM_Core_DAO_RecurringEntity
*/
public static function delEntity($entityId, $entityTable, $isDelLinkedEntities = FALSE)
{
if (empty($entityId) || empty($entityTable)) {
return FALSE;
}
$dao = new CRM_Core_DAO_RecurringEntity();
$dao->entity_id = $entityId;
$dao->entity_table = $entityTable;
if ($dao->find(TRUE)) {
// make sure its not a linked entity thats being deleted
if ($isDelLinkedEntities && !array_key_exists($entityTable, self::$_linkedEntitiesInfo)) {
// delete all linked entities from recurring entity table
foreach (self::$_linkedEntitiesInfo as $linkedTable => $linfo) {
$daoName = self::$_tableDAOMapper[$linkedTable];
if (!$daoName) {
CRM_Core_Error::fatal("DAO Mapper missing for {$linkedTable}.");
}
$linkedDao = new $daoName();
$linkedDao->{$linfo}['entity_id_col'] = $entityId;
$linkedDao->{$linfo}['entity_table_col'] = $entityTable;
$linkedDao->find();
while ($linkedDao->fetch()) {
CRM_Core_BAO_RecurringEntity::delEntity($linkedDao->id, $linkedTable, FALSE);
}
}
}
// delete main entity
return $dao->delete();
}
return FALSE;
}