multi event#1657
Conversation
WalkthroughThis 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. ChangesEvent Registration Feature
Sequence DiagramsequenceDiagram
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
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Review rate limit: 0/1 reviews remaining, refill in 60 minutes.Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (5)
wp-content/civi-extensions/goonjcustom/Civi/EventRegistrationService.phpwp-content/civi-extensions/goonjcustom/ang/goonjEventRegistration.ang.phpwp-content/civi-extensions/goonjcustom/ang/goonjEventRegistration.jswp-content/civi-extensions/goonjcustom/goonjcustom.phpwp-content/civi-extensions/goonjcustom/settings/GoonjEventRegistration.setting.php
| function getConfig() { | ||
| var cfg = (CRM && CRM.goonjEventRegistration) || {}; | ||
| return { | ||
| successUrl: cfg.successUrl || '/event-sucess/', |
There was a problem hiding this comment.
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.
| 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/', |
There was a problem hiding this comment.
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.
| '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.
Summary by CodeRabbit