Skip to content

Commit

Permalink
Merge pull request #24418 from mattwire/advancedevents
Browse files Browse the repository at this point in the history
REF Code cleanup for event configuration extracted from advancedevents extension
  • Loading branch information
demeritcowboy authored Aug 30, 2022
2 parents 02fcadf + f257268 commit 91997d6
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 22 deletions.
47 changes: 28 additions & 19 deletions CRM/Event/Form/ManageEvent/Repeat.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC. All rights reserved. |
| |
| This work is published under the GNU AGPLv3 license with some |
| permitted exceptions and without any warranty. For full license |
| and copyright information, see https://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/

/**
* Description of Repeat
*
* @author Priyanka
* Class to manage the "Repeat" functionality for event
*/
class CRM_Event_Form_ManageEvent_Repeat extends CRM_Event_Form_ManageEvent {

Expand All @@ -24,12 +26,19 @@ class CRM_Event_Form_ManageEvent_Repeat extends CRM_Event_Form_ManageEvent {
*/
protected $_parentEventEndDate = NULL;

/**
* @return int
*/
protected function getEventId() {
return $this->_id;
}

public function preProcess() {
parent::preProcess();
$this->setSelectedChild('repeat');
$this->assign('currentEventId', $this->_id);
$this->assign('currentEventId', $this->getEventId());

$checkParentExistsForThisId = CRM_Core_BAO_RecurringEntity::getParentFor($this->_id, 'civicrm_event');
$checkParentExistsForThisId = CRM_Core_BAO_RecurringEntity::getParentFor($this->getEventId(), 'civicrm_event');
//If this ID has parent, send parent id
if ($checkParentExistsForThisId) {
/**
Expand Down Expand Up @@ -64,7 +73,7 @@ public function preProcess() {
}
}

$parentEventParams = ['id' => $this->_id];
$parentEventParams = ['id' => $this->getEventId()];
$parentEventValues = [];
$parentEventReturnProperties = ['start_date', 'end_date'];
$parentEventAttributes = CRM_Core_DAO::commonRetrieve('CRM_Event_DAO_Event', $parentEventParams, $parentEventValues, $parentEventReturnProperties);
Expand All @@ -83,7 +92,7 @@ public function setDefaultValues() {
$defaults = [];

//Always pass current event's start date by default
$defaults['repetition_start_date'] = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_id, 'start_date', 'id');
$defaults['repetition_start_date'] = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->getEventId(), 'start_date', 'id');
$recurringEntityDefaults = CRM_Core_Form_RecurringEntity::setDefaultValues();
return array_merge($defaults, $recurringEntityDefaults);
}
Expand All @@ -93,7 +102,7 @@ public function buildQuickForm() {
}

public function postProcess() {
if ($this->_id) {
if ($this->getEventId()) {
$params = $this->controller->exportValues($this->_name);
if ($this->_parentEventStartDate && $this->_parentEventEndDate) {
$interval = CRM_Core_BAO_RecurringEntity::getInterval($this->_parentEventStartDate, $this->_parentEventEndDate);
Expand All @@ -102,22 +111,22 @@ public function postProcess() {
$params['dateColumns'] = ['start_date'];
$params['excludeDateRangeColumns'] = ['start_date', 'end_date'];
$params['entity_table'] = 'civicrm_event';
$params['entity_id'] = $this->_id;
$params['entity_id'] = $this->getEventId();

// CRM-16568 - check if parent exist for the event.
$parentId = CRM_Core_BAO_RecurringEntity::getParentFor($this->_id, 'civicrm_event');
$parentId = CRM_Core_BAO_RecurringEntity::getParentFor($this->getEventId(), 'civicrm_event');
$params['parent_entity_id'] = !empty($parentId) ? $parentId : $params['entity_id'];
//Unset event id
unset($params['id']);

$url = 'civicrm/event/manage/repeat';
$urlParams = "action=update&reset=1&id={$this->_id}&selectedChild=repeat";
$urlParams = "action=update&reset=1&id={$this->getEventId()}&selectedChild=repeat";

$linkedEntities = [
[
'table' => 'civicrm_price_set_entity',
'findCriteria' => [
'entity_id' => $this->_id,
'entity_id' => $this->getEventId(),
'entity_table' => 'civicrm_event',
],
'linkedColumns' => ['entity_id'],
Expand All @@ -126,7 +135,7 @@ public function postProcess() {
[
'table' => 'civicrm_uf_join',
'findCriteria' => [
'entity_id' => $this->_id,
'entity_id' => $this->getEventId(),
'entity_table' => 'civicrm_event',
],
'linkedColumns' => ['entity_id'],
Expand All @@ -135,7 +144,7 @@ public function postProcess() {
[
'table' => 'civicrm_tell_friend',
'findCriteria' => [
'entity_id' => $this->_id,
'entity_id' => $this->getEventId(),
'entity_table' => 'civicrm_event',
],
'linkedColumns' => ['entity_id'],
Expand All @@ -144,7 +153,7 @@ public function postProcess() {
[
'table' => 'civicrm_pcp_block',
'findCriteria' => [
'entity_id' => $this->_id,
'entity_id' => $this->getEventId(),
'entity_table' => 'civicrm_event',
],
'linkedColumns' => ['entity_id'],
Expand All @@ -155,7 +164,7 @@ public function postProcess() {
CRM_Utils_System::redirect(CRM_Utils_System::url($url, $urlParams));
}
else {
CRM_Core_Error::statusBounce("Could not find Event ID");
CRM_Core_Error::statusBounce(ts('Could not find Event ID'));
}
parent::endPostProcess();
}
Expand Down
6 changes: 3 additions & 3 deletions templates/CRM/Event/Page/ManageEvent.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -94,22 +94,22 @@
<ul class="panel" id="panel_participants_{$row.id}">
{if $findParticipants.statusCounted}
<li>
<a class="action-item crm-hover-button" href="{crmURL p='civicrm/event/search'
<a title="{ts}Counted Participants{/ts}" class="action-item crm-hover-button" href="{crmURL p='civicrm/event/search'
q="reset=1&force=1&status=true&event=`$row.id`"}">{$findParticipants.statusCounted}
</a>
</li>
{/if}
{if $findParticipants.statusNotCounted}
<li>
<a class="action-item crm-hover-button"
<a title="{ts}Participants Not Counted{/ts}" class="action-item crm-hover-button"
href="{crmURL p='civicrm/event/search'
q="reset=1&force=1&status=false&event=`$row.id`"}">{$findParticipants.statusNotCounted}
</a>
</li>
{/if}
{if $row.participant_listing_id}
<li>
<a class="action-item crm-hover-button"
<a title="{ts}Public Participant Listing{/ts}" class="action-item crm-hover-button"
href="{crmURL p='civicrm/event/participant' q="reset=1&id=`$row.id`"
fe='true'}">{ts}Public Participant Listing{/ts}
</a>
Expand Down

0 comments on commit 91997d6

Please sign in to comment.