From: unknown Date: Tue, 16 Sep 2014 15:50:24 +0000 (+0100) Subject: Confirm pop up called only for the core tabs of the manage event and cascade changes... X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=345c1ff5b847d84b91933eec79dd9710060e8015;p=civicrm-core.git Confirm pop up called only for the core tabs of the manage event and cascade changes works for friends and pcp --- diff --git a/CRM/Core/Page/AJAX/RecurringEntity.php b/CRM/Core/Page/AJAX/RecurringEntity.php index eb81cad5a6..a5e78c91cb 100644 --- a/CRM/Core/Page/AJAX/RecurringEntity.php +++ b/CRM/Core/Page/AJAX/RecurringEntity.php @@ -15,20 +15,29 @@ class CRM_Core_Page_AJAX_RecurringEntity { public static function updateMode() { - if(CRM_Utils_Array::value('mode', $_REQUEST) && CRM_Utils_Array::value('entityId', $_REQUEST)){ + if(CRM_Utils_Array::value('mode', $_REQUEST) && CRM_Utils_Array::value('entityId', $_REQUEST) && CRM_Utils_Array::value('entityTable', $_REQUEST)){ + $finalResult = array(); $mode = CRM_Utils_Type::escape($_REQUEST['mode'], 'Integer'); $entityId = CRM_Utils_Type::escape($_REQUEST['entityId'], 'Integer'); + $entityTable = CRM_Utils_Type::escape($_REQUEST['entityTable'], 'String'); - $sql = "UPDATE - civicrm_recurring_entity - SET mode = %1 - WHERE entity_id = %2 AND entity_table = 'civicrm_event'"; - $params = array( - 1 => array($mode, 'Integer'), - 2 => array($entityId, 'Integer') - ); - CRM_Core_DAO::executeQuery($sql, $params); + if(CRM_Utils_Array::value('linkedEntityTable', $_REQUEST)){ + $result = array(); + $result = CRM_Event_BAO_Event::updateModeRecurringEntityForEvent($entityId, $_REQUEST['linkedEntityTable']); + } + + $dao = new CRM_Core_DAO_RecurringEntity(); + if(!empty($result)){ + $dao->entity_id = $result['entityId']; + $dao->entityTable = $result['entityTable']; + }else{ + $dao->entity_id = $entityId; + $dao->entityTable = $entityTable; + } + $dao->find(TRUE); + $dao->mode = $mode; + $dao->save(); $finalResult['status'] = 'Done'; } echo json_encode($finalResult); diff --git a/CRM/Event/BAO/Event.php b/CRM/Event/BAO/Event.php index e56c286297..8b31dc0d1b 100644 --- a/CRM/Event/BAO/Event.php +++ b/CRM/Event/BAO/Event.php @@ -2200,5 +2200,49 @@ LEFT JOIN civicrm_price_field_value value ON ( value.id = lineItem.price_field } return CRM_Core_PseudoConstant::get(__CLASS__, $fieldName, $params, $context); } + + /** + * Update mode column in civicrm_recurring_entity table for event related tabs + * + * @params int $entityId event id + * @params string $linkedEntityTable Linked entity table name for this event + * @return array + */ + public static function updateModeRecurringEntityForEvent($entityId, $linkedEntityTable){ + $result = array(); + if( $entityId && $linkedEntityTable ){ + switch ($linkedEntityTable) { + case 'civicrm_tell_friend': + $params = array( + 'entity_id' => $entityId, + 'entity_table' => 'civicrm_event' + ); + $defaults = array(); + CRM_Core_DAO::commonRetrieve('CRM_Friend_DAO_Friend', $params, $defaults); + if(CRM_Utils_Array::value('id', $defaults)){ + $result['entityId'] = $defaults['id']; + $result['entityTable'] = 'civicrm_tell_friend'; + } + break; + + case 'civicrm_pcp_block': + $params = array( + 'entity_id' => $entityId, + 'entity_table' => 'civicrm_event' + ); + $defaults = array(); + CRM_Core_DAO::commonRetrieve('CRM_PCP_DAO_PCPBlock', $params, $defaults); + if(CRM_Utils_Array::value('id', $defaults)){ + $result['entityId'] = $defaults['id']; + $result['entityTable'] = 'civicrm_pcp_block'; + } + break; + + default: + break; + } + } + return $result; + } } diff --git a/templates/CRM/Event/Form/ManageEvent/ConfirmRepeatMode.tpl b/templates/CRM/Event/Form/ManageEvent/ConfirmRepeatMode.tpl index dd2fe864fd..d10c44e262 100644 --- a/templates/CRM/Event/Form/ManageEvent/ConfirmRepeatMode.tpl +++ b/templates/CRM/Event/Form/ManageEvent/ConfirmRepeatMode.tpl @@ -68,18 +68,39 @@ {literal}