This module adds a simple block that displays the "last modification" date of the site.
(It shows the date when any node was saved or modified the last time. This is displayed globally, and not per node!)
I needed this feature and could not find any module that achieves this. There are only code fragments at DrupalAnswers and spread somewhere in the internet that try to solve this, sometimes with much DB polling.
Example done wrong
So I implemented this feature, and I want to contribute it as it seems to be needed by more people than myself...
Git clone instructions:
git clone --branch 7.x-1.x http://git.drupal.org/sandbox/droetker/2467991.git last_modification_date
cd last_modification_date
This is my first Drupal project contribution, so no other project applications yet.
Comments
Comment #1
Manjit.Singh@nerdoc Thanks for the contribution :)
Found some coding standard issues in
last_node_modification.module
andlast_node_modification.install
files. Please resolve these.http://pareview.sh/pareview/httpgitdrupalorgsandboxdroetker2467991git
Also Please add review bonus also.
Comment #2
AshwiniPatil CreditAttribution: AshwiniPatil commentedGood Work.
Follow the coding standard.
@file block missing in last_node_modification.install
Comment #3
reinier-V CreditAttribution: reinier-V commentedHi nerdoc,
Seems like a nice tiny feature for some people!
On the other hand, this is possible as well by createing a view block with a contextual filter (this node), and printing some node data.
One major issue imo:
You say the block shows last mod date of any node (I'm reading it as 'with respect to the current requested node').
But since you use hook_node_insert to save the mod-date into a (global) drupal variable, and use it in the block content, you actually always show the date of the last modified node. (So the block will show the same thing, on each page etc).
So this should work different, or maybe it's wise to change the description of your module a bit.
Coding comments:
Regards,
Reinier
Comment #4
nerdoc CreditAttribution: nerdoc commentedEh - yes, maybe this description is a bit misleading. The "last update per node" would be already done by Drupal itself. each node has included this info in the theme AFAIK any you can switch this off and on in the theme settings.
What this module should do is exactly: Show when the site (globally) was updated the last time (except config settings). I'll change the description text.
Your other issues:
Unclear(ed) issues
Comment #5
nerdoc CreditAttribution: nerdoc commentedComment #6
nerdoc CreditAttribution: nerdoc commentedOh, @reinier-V: Yes, this could be done with a view. But IMHO it is heavier than this solution. With this module you don't even need views installed.
And, as I need it on many (similar) multisites, I would have needed to create the view in each single (multi)site again, or create a feature (which is a module as well, and even more overkill).
Comment #7
me-great CreditAttribution: me-great commentedPlease change git instructions to
Also you can optimize your code by using
hook_node_presave
instead ofhook_node_insert
andhook_node_update
with equal code.Regarding uninstall hook, put there variable_del function for other variables that were used in your module
Comment #8
nerdoc CreditAttribution: nerdoc commentedComment #9
nerdoc CreditAttribution: nerdoc commented@Oleksiy Shevchuk - thanks - didn't check the received patch closely enough to delete all set variables again. _presave is also a good idea, implemented thanks.
All PAReview errors ditched.
Comment #10
ajayNimbolkar CreditAttribution: ajayNimbolkar commentedReview of the 7.x-1.x branch (commit e749f7a):
No automated test cases were found, did you consider writing Simpletests or PHPUnit tests? This is not a requirement but encouraged for professional software development.
Manual Review
Individual user account
[Yes: Follows] the guidelines for individual user accounts.
No duplication
[Yes: Does not cause] module duplication and/or fragmentation.
Master Branch
[Yes: Follows] the guidelines for master branch.
Licensing
[Yes: Follows / No: Does not follow] the licensing requirements.
3rd party assets/code
[Yes: Follows ] the guidelines for 3rd party assets/code.
README.txt/README.md
[Yes: Follows] the guidelines for in-project documentation and/or the README Template.
Code long/complex enough for review
[Yes: Follows] the guidelines for project length and complexity.
Secure code
[Yes: Meets the security requirements.]
Coding style & Drupal API usage
[List of identified issues in no particular order. Use (*) and (+) to indicate an issue importance. Replace the text below by the issues themselves:
format_date($last_update_date, variable_get('last_node_modification_date_format', 'medium')), line no 108
as per the above comment the condition change as follow
$date = !empty($last_update_date) ? format_date($last_update_date, variable_get('last_node_modification_date_format')) : t('No recent updates.');
Comment #11
nerdoc CreditAttribution: nerdoc as a volunteer commentedAh, thanks. As you can see, PHP is not my native language ;-)
I'll check that.
Comment #12
nerdoc CreditAttribution: nerdoc as a volunteer commented@ajayNimbolkar: ad 1.: done.
ad 2: I find it more readable to not use the !empty double false condition, so I switched it to
And I think the "medium" default should stay. If a node was saved, but there was any manipulation of the database and the last_node_modification_date_format variable is not present, at least the default 'medium' format is used. Unlikely, but does not harm.
Comment #13
PA robot CreditAttribution: PA robot commentedClosing due to lack of activity. If you are still working on this application, you should fix all known problems and then set the status to "Needs review". (See also the project application workflow).
I'm a robot and this is an automated message from Project Applications Scraper.