-
Notifications
You must be signed in to change notification settings - Fork 1
Encryption + Decryption #1357
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Encryption + Decryption #1357
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,80 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <?php | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| use Civi\Core\Event\GenericHookEvent; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| use Civi\Core\Service\AutoService; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Provides ability to prefill afform fields from encrypted token. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * @service goonjcustom.afform_prefill | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| class CRM_Goonjcustom_AfformFieldPrefillService extends AutoService { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public static function preprocess(\Civi\Angular\Manager $angular) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Civi::log()->debug('[AfformPrefill] Preprocess started.'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $request = \CRM_Utils_Request::retrieve('token', 'String', CRM_Core_DAO::$_nullObject, FALSE, NULL, 'GET'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!$request) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Civi::log()->warning('[AfformPrefill] No token found in URL.'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $decrypted = CRM_Utils_Crypt::decrypt($request); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $data = json_decode($decrypted, true); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Civi::log()->debug('[AfformPrefill] Token decrypted: ' . print_r($data, true)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } catch (\Exception $e) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Civi::log()->error('[AfformPrefill] Token decryption failed: ' . $e->getMessage()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!is_array($data)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Civi::log()->error('[AfformPrefill] Decrypted token is not valid JSON.'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $changeSet = \Civi\Angular\ChangeSet::create('injectPrefillValues') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ->alterHtml(';\\.aff\\.html$;', function ($doc, $path) use ($data) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Civi::log()->debug("[AfformPrefill] Altering HTML template: {$path}"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| foreach (pq('af-field', $doc) as $afField) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $fieldName = $afField->getAttribute('name'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sanitize field names to prevent potential attacks Field names are used directly without validation, which could lead to security issues if malicious field names are processed. $fieldName = $afField->getAttribute('name');
if (!$fieldName) {
continue;
}
+// Validate field name format
+if (!preg_match('/^[a-zA-Z_][a-zA-Z0-9_\.]*$/', $fieldName)) {
+ Civi::log()->warning("[AfformPrefill] Invalid field name format: {$fieldName}");
+ continue;
+}
if (array_key_exists($fieldName, $data)) {Also applies to: 48-48 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!$fieldName) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| continue; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (array_key_exists($fieldName, $data)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $fieldDefn = self::getFieldDefinition($afField); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!$fieldDefn) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Civi::log()->warning("[AfformPrefill] No field definition for: {$fieldName}"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| continue; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $fieldDefn['afform_default'] = $data[$fieldName]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $fieldDefn['readonly'] = true; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pq($afField)->attr('defn', htmlspecialchars(\CRM_Utils_JS::writeObject($fieldDefn), ENT_COMPAT)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Potential XSS vulnerability in field definition handling The field definition is serialized and inserted into HTML attributes without proper validation of the input data values, which could lead to XSS attacks. +// Sanitize the field value before setting
+$sanitizedValue = is_string($data[$fieldName]) ?
+ htmlspecialchars($data[$fieldName], ENT_QUOTES, 'UTF-8') :
+ $data[$fieldName];
+
+$fieldDefn['afform_default'] = $sanitizedValue;
-$fieldDefn['afform_default'] = $data[$fieldName];
$fieldDefn['readonly'] = true;
pq($afField)->attr('defn', htmlspecialchars(\CRM_Utils_JS::writeObject($fieldDefn), ENT_COMPAT));📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Civi::log()->info("[AfformPrefill] Prefilled field '{$fieldName}' with value: " . json_encode($data[$fieldName])); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Civi::log()->debug("[AfformPrefill] Field '{$fieldName}' not in token data, skipping."); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $angular->add($changeSet); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Civi::log()->debug('[AfformPrefill] ChangeSet injected successfully.'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+37
to
+69
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Break down the monolithic preprocess method This method violates the Single Responsibility Principle by handling token processing, template modification, and field updates all in one place. Consider extracting smaller, focused methods. public function preprocess(\Civi\Angular\Manager $angular) {
- // All the current logic here
+ $data = $this->processToken();
+ if (!$data) {
+ return;
+ }
+
+ $changeSet = $this->createFieldPrefillChangeSet($data);
+ $angular->add($changeSet);
}
+private function processToken() {
+ // Token retrieval and decryption logic
+}
+private function createFieldPrefillChangeSet($data) {
+ // ChangeSet creation and field processing logic
+}
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public static function getFieldDefinition($afField) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $existingFieldDefn = trim(pq($afField)->attr('defn') ?: ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if ($existingFieldDefn && $existingFieldDefn[0] !== '{') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return NULL; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return $existingFieldDefn ? \CRM_Utils_JS::getRawProps($existingFieldDefn) : []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+71
to
+79
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add error handling for field definition parsing The - return $existingFieldDefn ? \CRM_Utils_JS::getRawProps($existingFieldDefn) : [];
+ if (!$existingFieldDefn) {
+ return [];
+ }
+
+ try {
+ return \CRM_Utils_JS::getRawProps($existingFieldDefn);
+ } catch (\Exception $e) {
+ Civi::log()->error('[AfformPrefill] Failed to parse field definition: ' . $e->getMessage());
+ return [];
+ }📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -543,32 +543,51 @@ public static function processDispatchEmail(string $op, string $objectName, $obj | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public static function sendDispatchEmail($email, $initiatorName, $droppingCenterId, $contactId, $goonjOffice, $goonjOfficeName) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $homeUrl = \CRM_Utils_System::baseCMSURL(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $vehicleDispatchFormUrl = $homeUrl . '/vehicle-dispatch/#?Camp_Vehicle_Dispatch.Dropping_Center=' . $droppingCenterId . '&Camp_Vehicle_Dispatch.Filled_by=' . $contactId . '&Camp_Vehicle_Dispatch.To_which_PU_Center_material_is_being_sent=' . $goonjOffice . '&Camp_Vehicle_Dispatch.Goonj_Office_Name=' . $goonjOfficeName . '&Eck_Collection_Camp1=' . $droppingCenterId; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $homeUrl = \CRM_Utils_System::baseCMSURL(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Step 1: Gather data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $dispatchData = [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'Camp_Vehicle_Dispatch.Dropping_Center' => $droppingCenterId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'Camp_Vehicle_Dispatch.Filled_by' => $contactId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'Camp_Vehicle_Dispatch.To_which_PU_Center_material_is_being_sent' => $goonjOffice, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'Camp_Vehicle_Dispatch.Goonj_Office_Name' => $goonjOfficeName, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'Eck_Collection_Camp1' => $droppingCenterId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'id' => $droppingCenterId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+549
to
+557
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Validate input parameters before encryption The method assumes all parameters are valid without verification. This could lead to issues if any required data is missing or malformed. Add validation before constructing the dispatch data: + // Validate required parameters
+ if (empty($droppingCenterId) || empty($contactId) || empty($goonjOffice)) {
+ \Civi::log()->error('Missing required parameters for dispatch email');
+ return;
+ }
+
// Step 1: Gather data
$dispatchData = [
'Camp_Vehicle_Dispatch.Dropping_Center' => $droppingCenterId,🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Step 2: Convert to JSON and encrypt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $json = json_encode($dispatchData); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $token = \CRM_Utils_Crypt::encrypt($json); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+548
to
+561
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add error handling for encryption failures The encryption operation could fail, but there's no error handling. If Wrap the encryption in a try-catch block: - // Step 2: Convert to JSON and encrypt
- $json = json_encode($dispatchData);
- $token = \CRM_Utils_Crypt::encrypt($json);
+ // Step 2: Convert to JSON and encrypt
+ $json = json_encode($dispatchData);
+ try {
+ $token = \CRM_Utils_Crypt::encrypt($json);
+ } catch (\Exception $e) {
+ \Civi::log()->error('Failed to encrypt dispatch data: ' . $e->getMessage());
+ throw new \CRM_Core_Exception('Failed to generate dispatch email');
+ }🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $emailHtml = " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <html> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <body> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Step 3: Generate encrypted URL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $vehicleDispatchFormUrl = $homeUrl . '/vehicle-dispatch/?token=' . urlencode($token); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Step 4: Compose HTML email | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $emailHtml = " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <html> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <body> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <p>Dear {$initiatorName},</p> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <p>Thank you so much for your invaluable efforts in running the Goonj Dropping Center. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Your dedication plays a crucial role in our work, and we deeply appreciate your continued support.</p> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <p>Please fill out this Dispatch Form – <a href='{$vehicleDispatchFormUrl}'>Link</a> once the vehicle is loaded and ready to head to Goonj’s processing center. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| This will help us to verify and acknowledge the materials as soon as they arrive.</p> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <p>We truly appreciate your cooperation and continued commitment to our cause.</p> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <p>Warm Regards,<br>Team Goonj..</p> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </body> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </html> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $from = HelperService::getDefaultFromEmail(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $mailParams = [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'subject' => 'Kindly fill the Dispatch Form for Material Pickup', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'from' => $from, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'toEmail' => $email, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'html' => $emailHtml, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </body> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </html> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+567
to
+579
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Extract email HTML to a template file Inline HTML violates the separation of concerns principle and makes the code harder to maintain. Consider moving this to a Smarty template for better maintainability and localization support. Create a new template file - // Step 4: Compose HTML email
- $emailHtml = "
- <html>
- <body>
- <p>Dear {$initiatorName},</p>
- <p>Thank you so much for your invaluable efforts in running the Goonj Dropping Center.
- Your dedication plays a crucial role in our work, and we deeply appreciate your continued support.</p>
- <p>Please fill out this Dispatch Form – <a href='{$vehicleDispatchFormUrl}'>Link</a> once the vehicle is loaded and ready to head to Goonj's processing center.
- This will help us to verify and acknowledge the materials as soon as they arrive.</p>
- <p>We truly appreciate your cooperation and continued commitment to our cause.</p>
- <p>Warm Regards,<br>Team Goonj..</p>
- </body>
- </html>
- ";
+ // Step 4: Compose HTML email
+ $tplParams = [
+ 'initiatorName' => $initiatorName,
+ 'vehicleDispatchFormUrl' => $vehicleDispatchFormUrl,
+ ];
+ $emailHtml = CRM_Core_Smarty::singleton()->fetchWith('CRM/Goonjcustom/Email/DispatchForm.tpl', $tplParams);📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Step 5: Send email | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $from = HelperService::getDefaultFromEmail(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $mailParams = [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'subject' => 'Kindly fill the Dispatch Form for Material Pickup', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'from' => $from, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'toEmail' => $email, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'html' => $emailHtml, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| \CRM_Utils_Mail::send($mailParams); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| \CRM_Utils_Mail::send($mailParams); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -33,6 +33,13 @@ function goonjcustom_civicrm_config(&$config): void { | |||||||
| \Civi::dispatcher()->addSubscriber(new CRM_Goonjcustom_Token_IndividualGoonjActivities()); | ||||||||
| } | ||||||||
|
|
||||||||
| /** | ||||||||
| * Implements hook_civicrm_alterAngular(). | ||||||||
| */ | ||||||||
| function goonjcustom_civicrm_alterAngular($angular) { | ||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove unused parameter The Apply this diff to remove the unused parameter: -function goonjcustom_civicrm_alterAngular($angular) {
+function goonjcustom_civicrm_alterAngular() {📝 Committable suggestion
Suggested change
🧰 Tools🪛 PHPMD (2.15.0)39-39: Avoid unused parameters such as '$angular'. (Unused Code Rules) (UnusedFormalParameter) 🤖 Prompt for AI Agents |
||||||||
| CRM_Goonjcustom_AfformFieldPrefillService::preprocess($angular); | ||||||||
| } | ||||||||
|
Comment on lines
+36
to
+77
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add token validation and consider splitting responsibilities The function handles multiple responsibilities and lacks token validation:
Consider:
🧰 Tools🪛 PHPMD (2.15.0)39-39: Avoid unused parameters such as '$angular'. (Unused Code Rules) (UnusedFormalParameter) 🤖 Prompt for AI Agents |
||||||||
|
|
||||||||
| /** | ||||||||
| * Implements hook_civicrm_install(). | ||||||||
| * | ||||||||
|
|
||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Avoid static methods for better testability
Static methods make unit testing difficult and violate dependency injection principles. Consider making this an instance method instead.
📝 Committable suggestion
🤖 Prompt for AI Agents