Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I've created a hook_default_user_stats hook in order to provide additional user statistics within the framework of this module.
I've attached two files:
- A .patch file demonstrating the change inside user_stats_get_stats()
- A new user_stats.api.php file outlining how to use this new hook (I'm still fuzzy on creating a new file via patches)
Please take this functionality into consideration as it can be very helpful and adds minimal complexity, because the current caching system is very flexible already.
Thanks,
Erik
Comment | File | Size | Author |
---|---|---|---|
#2 | 887966-add-hook-default-user-stats.patch | 2.52 KB | erikwebb |
user_stats.api_.php_.zip | 399 bytes | erikwebb | |
user_stats-add-custom-stats-hook.patch | 1.4 KB | erikwebb |
Comments
Comment #1
Liam McDermott CreditAttribution: Liam McDermott commentedThis patch looks great!. Do you think it would be too much of a performance hit to get rid of that monolithic
switch case
statement and make all statistics work this way?Also, I'm going to make User Stats object oriented for Drupal 7 and am thinking this work will fit quite nicely with that. Does that make sense, or would there be a better way in light of that?
About new files:
You can use
cvsdo
to make CVS think new files are already in the repository. It only works on new files and not directories, or new files inside directories.My workflow for adding new files looks like:
Comment #2
erikwebb CreditAttribution: erikwebb commentedHere's a re-rolled CVS patch with the proper add. I think removing the
switch case
statement would be cleaner, but I don't think it's as important as releasing the ability for others to add their own stats.Honestly, I haven't jumped into D7 development much yet, so I can't comment on how to move this to OOP.
Comment #3
Liam McDermott CreditAttribution: Liam McDermott commentedSorry for not committing this sooner, but hopefully I can make up for that by committing it now. :)
Great idea, good work by the way. Thank you very much.