$this->assign('action', $this->_action);
- $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE, NULL, 'GET');
- if ($this->_id) {
+ if ($this->getEventID()) {
$this->_isRepeatingEvent = CRM_Core_BAO_RecurringEntity::getParentFor($this->_id, 'civicrm_event');
$this->assign('eventId', $this->_id);
$this->_single = TRUE;
CRM_UF_Page_ProfileEditor::registerSchemas(['IndividualModel', 'ParticipantModel']);
}
+ /**
+ * @return int|null
+ * @throws \CRM_Core_Exception
+ */
+ public function getEventID() {
+ if (!$this->_id) {
+ $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE, NULL, 'GET');
+ }
+ return $this->_id ? (int) $this->_id : NULL;
+ }
+
}
* @copyright CiviCRM LLC https://civicrm.org/licensing
*/
+use Civi\Api4\Event;
+
/**
* This class generates form components for processing Event.
*/
* Event type.
* @var int
*/
- protected $_eventType = NULL;
+ protected $_eventType;
/**
* Set variables up before form is built.
+ *
+ * @throws \CRM_Core_Exception
*/
- public function preProcess() {
+ public function preProcess(): void {
parent::preProcess();
$this->setSelectedChild('settings');
- $entityID = $this->_id ?: $this->_templateId;
- if ($entityID) {
- $this->assign('entityID', $entityID);
- $eventType = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event',
- $entityID,
- 'event_type_id'
- );
- }
- else {
- $eventType = 'null';
- }
-
- $showLocation = FALSE;
+ $entityID = $this->getEventID() ?: $this->_templateId;
+ $this->assign('eventID', $entityID);
// when custom data is included in this page
if (!empty($_POST['hidden_custom'])) {
$this->set('type', 'Event');
/**
* Set default values for the form.
*
- * For edit/view mode he default values are retrieved from the database.
+ * For edit/view mode the default values are retrieved from the database.
+ *
+ * @return array
*/
public function setDefaultValues() {
$defaults = parent::setDefaultValues();
$this->assign('customDataSubType', $defaults['event_type_id']);
}
- $this->_showHide = new CRM_Core_ShowHideBlocks();
+ $showHideBlocks = new CRM_Core_ShowHideBlocks();
// Show waitlist features or event_full_text if max participants set
if (!empty($defaults['max_participants'])) {
- $this->_showHide->addShow('id-waitlist');
+ $showHideBlocks->addShow('id-waitlist');
if (!empty($defaults['has_waitlist'])) {
- $this->_showHide->addShow('id-waitlist-text');
- $this->_showHide->addHide('id-event_full');
+ $showHideBlocks->addShow('id-waitlist-text');
+ $showHideBlocks->addHide('id-event_full');
}
else {
- $this->_showHide->addHide('id-waitlist-text');
- $this->_showHide->addShow('id-event_full');
+ $showHideBlocks->addHide('id-waitlist-text');
+ $showHideBlocks->addShow('id-event_full');
}
}
else {
- $this->_showHide->addHide('id-event_full');
- $this->_showHide->addHide('id-waitlist');
- $this->_showHide->addHide('id-waitlist-text');
+ $showHideBlocks->addHide('id-event_full');
+ $showHideBlocks->addHide('id-waitlist');
+ $showHideBlocks->addHide('id-waitlist-text');
}
- $this->_showHide->addToTemplate();
+ $showHideBlocks->addToTemplate();
$this->assign('elemType', 'table-row');
$this->assign('description', CRM_Utils_Array::value('description', $defaults));
/**
* Build the form object.
+ *
+ * @throws \CRM_Core_Exception
*/
- public function buildQuickForm() {
+ public function buildQuickForm(): void {
//need to assign custom data type and subtype to the template
$this->assign('customDataType', 'Event');
if ($this->_eventType) {
}
if ($this->_action & CRM_Core_Action::ADD) {
- $eventTemplates = \Civi\Api4\Event::get(FALSE)
+ $eventTemplates = Event::get(FALSE)
->addWhere('is_template', '=', TRUE)
->addWhere('is_active', '=', TRUE)
->execute()
$url = 'civicrm/event/manage/location';
$urlParams = "action=update&reset=1&id={$event->id}";
// special case for 'Save and Done' consistency.
- if ($this->controller->getButtonName('submit') == '_qf_EventInfo_upload_done') {
+ if ('_qf_EventInfo_upload_done' === $this->controller->getButtonName('submit')) {
$url = 'civicrm/event/manage';
$urlParams = 'reset=1';
CRM_Core_Session::setStatus(ts("'%1' information has been saved.",
*
* @return string
*/
- public function getTitle() {
+ public function getTitle(): string {
return ts('Event Information and Settings');
}
*/
protected $_parentEventEndDate = NULL;
- /**
- * @return int
- */
- protected function getEventId() {
- return $this->_id;
- }
-
public function preProcess() {
parent::preProcess();
$this->setSelectedChild('repeat');
- $this->assign('currentEventId', $this->getEventId());
+ $this->assign('currentEventId', $this->getEventID());
- $checkParentExistsForThisId = CRM_Core_BAO_RecurringEntity::getParentFor($this->getEventId(), 'civicrm_event');
+ $checkParentExistsForThisId = CRM_Core_BAO_RecurringEntity::getParentFor($this->getEventID(), 'civicrm_event');
//If this ID has parent, send parent id
if ($checkParentExistsForThisId) {
/**
}
}
- $parentEventParams = ['id' => $this->getEventId()];
+ $parentEventParams = ['id' => $this->getEventID()];
$parentEventValues = [];
$parentEventReturnProperties = ['start_date', 'end_date'];
$parentEventAttributes = CRM_Core_DAO::commonRetrieve('CRM_Event_DAO_Event', $parentEventParams, $parentEventValues, $parentEventReturnProperties);
$defaults = [];
//Always pass current event's start date by default
- $defaults['repetition_start_date'] = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->getEventId(), '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);
}
CRM_Core_Form_RecurringEntity::buildQuickForm($this);
}
+ /**
+ * @throws \CRM_Core_Exception
+ */
public function postProcess() {
- if ($this->getEventId()) {
+ if ($this->getEventID()) {
$params = $this->controller->exportValues($this->_name);
if ($this->_parentEventStartDate && $this->_parentEventEndDate) {
$interval = CRM_Core_BAO_RecurringEntity::getInterval($this->_parentEventStartDate, $this->_parentEventEndDate);
$params['dateColumns'] = ['start_date'];
$params['excludeDateRangeColumns'] = ['start_date', 'end_date'];
$params['entity_table'] = 'civicrm_event';
- $params['entity_id'] = $this->getEventId();
+ $params['entity_id'] = $this->getEventID();
// CRM-16568 - check if parent exist for the event.
- $parentId = CRM_Core_BAO_RecurringEntity::getParentFor($this->getEventId(), '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->getEventId()}&selectedChild=repeat";
+ $urlParams = "action=update&reset=1&id={$this->getEventID()}&selectedChild=repeat";
$linkedEntities = [
[
'table' => 'civicrm_price_set_entity',
'findCriteria' => [
- 'entity_id' => $this->getEventId(),
+ 'entity_id' => $this->getEventID(),
'entity_table' => 'civicrm_event',
],
'linkedColumns' => ['entity_id'],
[
'table' => 'civicrm_uf_join',
'findCriteria' => [
- 'entity_id' => $this->getEventId(),
+ 'entity_id' => $this->getEventID(),
'entity_table' => 'civicrm_event',
],
'linkedColumns' => ['entity_id'],
[
'table' => 'civicrm_tell_friend',
'findCriteria' => [
- 'entity_id' => $this->getEventId(),
+ 'entity_id' => $this->getEventID(),
'entity_table' => 'civicrm_event',
],
'linkedColumns' => ['entity_id'],
[
'table' => 'civicrm_pcp_block',
'findCriteria' => [
- 'entity_id' => $this->getEventId(),
+ 'entity_id' => $this->getEventID(),
'entity_table' => 'civicrm_event',
],
'linkedColumns' => ['entity_id'],
{* Step 1 of New Event Wizard, and Edit Event Info form. *}
<div class="crm-block crm-form-block crm-event-manage-eventinfo-form-block">
- {assign var=eventID value=$id}
<div class="crm-submit-buttons">
{include file="CRM/common/formButtons.tpl" location="top"}
</div>
</td>
</tr>
<tr class="crm-event-manage-eventinfo-form-block-participant_listing_id">
- <td class="label">{$form.participant_listing_id.label} {help id="id-listing" isTemplate=$isTemplate action=$action entityId=$entityId}</td>
+ <td class="label">{$form.participant_listing_id.label} {help id="id-listing" isTemplate=$isTemplate action=$action entityId=$eventID}</td>
<td>{$form.participant_listing_id.html}</td>
</tr>
<tr class="crm-event-manage-eventinfo-form-block-title">