Skip to content

multi event#1657

Open
tarunnjoshi wants to merge 1 commit into
devfrom
Multi-Event
Open

multi event#1657
tarunnjoshi wants to merge 1 commit into
devfrom
Multi-Event

Conversation

@tarunnjoshi
Copy link
Copy Markdown
Member

@tarunnjoshi tarunnjoshi commented May 4, 2026

Summary by CodeRabbit

  • New Features
    • Enhanced event registration form with duplicate prevention to avoid accidental multiple registrations
    • Added Event Type filter to simplify event selection
    • Automatic account linking for existing email addresses during registration
    • Smart duplicate detection with customizable redirect pages for improved user experience

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 4, 2026

Walkthrough

This PR adds event registration customization for the Goonj CiviCRM extension, introducing server-side duplicate participant detection via email-based contact lookup and in-request pair tracking, alongside client-side Angular UI for event type filtering and conditional post-submission redirects based on duplicate outcomes.

Changes

Event Registration Feature

Layer / File(s) Summary
Settings Configuration
wp-content/civi-extensions/goonjcustom/settings/GoonjEventRegistration.setting.php, wp-content/civi-extensions/goonjcustom/goonjcustom.php (alterSettingsFolders)
Five domain-scoped settings defined: success/duplicate redirect URLs, event type filter label/help text, and "All types" option label; settings folder registration enabled.
Backend Service & Duplicate Detection
wp-content/civi-extensions/goonjcustom/Civi/EventRegistrationService.php
EventRegistrationService subscriber implements email-based contact lookup on civi.afform.submit for Individual1 records, and blocks duplicate participants via in-request tracking and database queries on hook_civicrm_pre for Participant creates.
Extension Hook Integration
wp-content/civi-extensions/goonjcustom/goonjcustom.php (alterBundle, angularModules)
Settings injected into coreResources bundle as goonjEventRegistration variables; Angular module auto-discovery scans and registers *.ang.php modules with extension attribution.
Angular Module Setup
wp-content/civi-extensions/goonjcustom/ang/goonjEventRegistration.ang.php
Module configuration declares JS entry, CRM dependencies (crmUi, crmUtil, api4), and bundle settings.
Client-Side UI & Form Handling
wp-content/civi-extensions/goonjcustom/ang/goonjEventRegistration.js
Injects event type filter fieldset into Participant1; patches event\_id autocomplete to filter by selection; watches filter changes to clear selections; listens to crmFormSuccess to redirect to duplicate URL when Participant1 created count is zero.

Sequence Diagram

sequenceDiagram
    actor User as User (Browser)
    participant Form as Afform UI<br/>(goonjEventRegistration.js)
    participant API as CRM API
    participant Service as EventRegistrationService
    participant DB as Database

    User->>Form: Submits event registration (Individual + Participants)
    Form->>API: POST /afform/submit (afformGoonjEventRegistration)
    API->>Service: Triggers civi.afform.submit
    Service->>Service: Clear in-request duplicate tracker
    Service->>API: Lookup Contact by email_primary.email
    API->>DB: SELECT contact (email, is_deleted=0)
    DB-->>API: Contact ID (or none)
    API-->>Service: Contact data
    Service->>Service: Set Individual1.id to matched contact_id
    API->>Service: Triggers hook_civicrm_pre (Participant, create)
    Service->>Service: Check if (contact_id, event_id) in in-request pairs
    alt Duplicate in batch
        Service-->>API: CRM_Core_Exception (duplicate_participant_in_batch)
    else Not in batch
        Service->>DB: Query Participant (contact_id, event_id, not cancelled/rejected)
        DB-->>Service: Existing participant (or none)
        alt Duplicate in DB
            Service-->>API: CRM_Core_Exception (duplicate_participant_exists)
        else New participant
            Service->>Service: Track (contact_id, event_id) as seen
            API->>DB: INSERT/UPDATE Participant
        end
    end
    API-->>Form: Response with created Participant count
    Form->>Form: Check if Participant1.created.length === 0
    alt All duplicates
        Form->>User: Redirect to duplicateUrl
    else Some created
        Form->>User: Redirect to successUrl
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Suggested labels

status : ready for review

Suggested reviewers

  • pokhiii

Poem

🎪 A form that filters with finesse,
Duplicates caught, no more mess—
Contacts find their matching face,
Events sorted by type with grace.
Redirects flow to their place! ✨

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 72.73% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'multi event' is vague and generic, failing to convey what specific functionality or changes this PR introduces. Revise the title to be more descriptive, such as 'Add event type filter and duplicate participant handling for afform' or 'Implement multi-event registration with duplicate prevention'.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch Multi-Event

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 PHPStan (2.1.51)

PHPStan was skipped because the sandbox runner could not parse its output.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@wp-content/civi-extensions/goonjcustom/ang/goonjEventRegistration.js`:
- Line 20: The fallback URL string for the successUrl is misspelled; in the
config assignment where successUrl is set (using cfg.successUrl ||
'/event-sucess/'), change the hard-coded fallback to '/event-success/' so it
matches the corrected PHP default; update this exact occurrence and any other
similar occurrences that use the same fallback pattern (look for successUrl or
cfg.successUrl usages) to ensure consistency.

In
`@wp-content/civi-extensions/goonjcustom/settings/GoonjEventRegistration.setting.php`:
- Line 12: In GoonjEventRegistration.setting.php update the default URL value
for the setting: locate the array entry with the 'default' key (currently set to
'/event-sucess/') and correct the typo by changing it to '/event-success/' so
the success redirect path is spelled correctly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: f238c9fa-38e7-4f70-9034-75b42d6fa2f5

📥 Commits

Reviewing files that changed from the base of the PR and between cf2642b and 7d326ff.

📒 Files selected for processing (5)
  • wp-content/civi-extensions/goonjcustom/Civi/EventRegistrationService.php
  • wp-content/civi-extensions/goonjcustom/ang/goonjEventRegistration.ang.php
  • wp-content/civi-extensions/goonjcustom/ang/goonjEventRegistration.js
  • wp-content/civi-extensions/goonjcustom/goonjcustom.php
  • wp-content/civi-extensions/goonjcustom/settings/GoonjEventRegistration.setting.php

function getConfig() {
var cfg = (CRM && CRM.goonjEventRegistration) || {};
return {
successUrl: cfg.successUrl || '/event-sucess/',
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Same typo in fallback URL.

The fallback '/event-sucess/' should be '/event-success/' to match the corrected PHP default. Both locations need the fix.

📝 Proposed fix
-      successUrl: cfg.successUrl || '/event-sucess/',
+      successUrl: cfg.successUrl || '/event-success/',
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
successUrl: cfg.successUrl || '/event-sucess/',
successUrl: cfg.successUrl || '/event-success/',
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@wp-content/civi-extensions/goonjcustom/ang/goonjEventRegistration.js` at line
20, The fallback URL string for the successUrl is misspelled; in the config
assignment where successUrl is set (using cfg.successUrl || '/event-sucess/'),
change the hard-coded fallback to '/event-success/' so it matches the corrected
PHP default; update this exact occurrence and any other similar occurrences that
use the same fallback pattern (look for successUrl or cfg.successUrl usages) to
ensure consistency.

'name' => 'goonj_event_registration_success_url',
'type' => 'String',
'html_type' => 'text',
'default' => '/event-sucess/',
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Typo in default success URL.

The default value '/event-sucess/' should be '/event-success/' (missing 'c').

📝 Proposed fix
-    'default' => '/event-sucess/',
+    'default' => '/event-success/',
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
'default' => '/event-sucess/',
'default' => '/event-success/',
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@wp-content/civi-extensions/goonjcustom/settings/GoonjEventRegistration.setting.php`
at line 12, In GoonjEventRegistration.setting.php update the default URL value
for the setting: locate the array entry with the 'default' key (currently set to
'/event-sucess/') and correct the typo by changing it to '/event-success/' so
the success redirect path is spelled correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant