-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add activity for Goonj activity #509
base: develop
Are you sure you want to change the base?
Conversation
WalkthroughThe changes introduce a new class, Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 3
🧹 Outside diff range and nitpick comments (2)
wp-content/civi-extensions/goonjcustom/Civi/GoonjActivitiesService.php (2)
151-217
: MethodcreateActivityForGoonjActivityCollectionCamp
is too long and complexThe method spans over 60 lines and handles multiple responsibilities, including validation, data retrieval, and activity creation. This violates the Single Responsibility Principle and makes the code harder to read and maintain.
Consider refactoring the method into smaller, focused methods. For example:
- Extract a method for validating the operation and object type.
- Extract a method for loading and verifying the collection camp status.
- Extract a method for processing activities and creating new entries.
This will improve readability and maintainability.
100-112
: Duplicate tab titles may cause confusion in the UIBoth the 'monetaryContribution' and 'monetaryContributionForUrbanOps' tabs have the same title 'Monetary Contribution':
// Lines 100-105 'monetaryContribution' => [ 'title' => ts('Monetary Contribution'), // ... ], // Lines 107-112 'monetaryContributionForUrbanOps' => [ 'title' => ts('Monetary Contribution'), // ... ],This could confuse users as they may not distinguish between the two tabs.
Consider giving distinct titles to these tabs to enhance user experience, such as 'Monetary Contribution' and 'Urban Ops Contribution'.
$subtypeId = self::getSubtypeId(); | ||
|
||
return (int) $entitySubtypeValue === $subtypeId; |
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.
Undefined method getSubtypeId()
causes fatal error
The method getSubtypeId()
is called on line 50, but it's not defined within the GoonjActivitiesService
class or inherited from a parent class. This will result in a fatal error during execution.
To fix this issue, define the getSubtypeId()
method or ensure it's properly inherited from a parent class or included via a trait.
$isAdmin = \CRM_Core_Permission::check('admin'); | ||
if ($key == 'monetaryContributionForUrbanOps' && $isAdmin) { | ||
continue; | ||
} |
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
Potentially incorrect permission logic for administrators
The condition on line 117 skips adding the 'monetaryContributionForUrbanOps' tab if the user has 'admin' permissions:
if ($key == 'monetaryContributionForUrbanOps' && $isAdmin) {
continue;
}
This may unintentionally prevent administrators from accessing the 'monetaryContributionForUrbanOps' tab, which might not be the desired behavior.
Consider revising the condition to ensure that administrators have appropriate access, or clarify if administrators should indeed be restricted from this tab.
$startDate = $objectRef['Goonj_Activities.Start_Date']; | ||
$endDate = $objectRef['Goonj_Activities.End_Date']; | ||
$initiator = $objectRef['Collection_Camp_Core_Details.Contact_Id']; | ||
error_log("objectRef: " . print_r($objectRef, TRUE)); |
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
Remove debugging error_log
statement from production code
An error_log
statement is present on line 185:
error_log("objectRef: " . print_r($objectRef, TRUE));
Including debugging code in production can expose sensitive information and clutter log files.
Remove or comment out the error_log
statement before deploying to production.
add activity
Summary by CodeRabbit
GoonjActivitiesService
for managing Goonj activities related to theCollection_Camp
entity.