A module that warns site visitors that the web site will be going down for maintenance at a specified time. The default configuration displays a fixed position red overlay message at the bottom of the browser window with text in the format 'Drupal is going offline for maintenance at Tue Feb 21 14:41:08 2012 -0800'. Module configuration is added to the Site Maintenance administration page (admin/settings/site-maintenance). Settings allow for the modification of: Show warning, off-line date and time, warning message, and off-line action. Off-line action includes an option to set the site offline automatically. There are also advanced settings that control the display format of the date time and warning message.
The Going Down module functions by using hook_footer and hook_cron to trigger display of message and perform actions. The message is displayed on all pages and works with page cache to minimize overhead. Once the warning date time has elapsed the next page request or next cron run (whichever comes first) will trigger the specified off-line action.
Sandbox: http://drupal.org/sandbox/tinker/1449426
GIT: git clone --branch 6.x-1.x http://git.drupal.org/sandbox/tinker/1449426.git going_down
Manual reviews of other projects:
OneAll Social Login
http://drupal.org/node/1455564#comment-5653846
http://drupal.org/node/1455564#comment-5660960
Commerce Giftwrap
http://drupal.org/node/1448144#comment-5653710
http://drupal.org/node/1448144#comment-5660730
http://drupal.org/node/1448144#comment-5674096
Popup Advertisements
http://drupal.org/node/1944884#comment-7232716
http://drupal.org/node/1944884#comment-7219324
| Comment | File | Size | Author |
|---|---|---|---|
| going_down.png | 79.57 KB | tinker |
Comments
Comment #1
mkadin commentedCool module. I can definitely see where this might be useful for users. A few thoughts as I reviewed its code and functionality:
1) In your configuration form's validate function, you are doing a bunch of checks to make sure users have entered required values. You should instead do this by adding '#required' => TRUE, to the form elements. This is the "Drupal Way" and it will include the theme's styling for required fields.
2) The site maintenance configuration page is throwing an error for your implementation of hook_form_FORM_ID_alter(). This hook only takes the first 2 arguments, not the form_id (in Drupal 6).
3) Also in drupal 6, variable_get() requires a 2nd parameter for the default. You're missing it on line 65.
4) Below is the PAReview.sh automatic review script's notes on your module. You should fix up these to meet Drupal's coding standards.
Great start...just some clean up to do :)
Comment #1.0
mkadin commentedAdded Git
Comment #2
tinker commentedThanks for the review. In response to your comments:
I did this because the inputs are conditionally required. If the message is not on then they are not required. I could not see a way of doing this conditional required input using FAPI. Any suggestions? For now I have made them required as you suggested.
Opps used the D7 hook by mistake. Fixed.
Again looking at D7 API. Fixed.
Coding format changes applied and updated in Git. Git branch 6.x-1.x created. Master branch cleared apart from README.txt. Updated Git reference in first post.
Comment #3
mkadin commentedLooks pretty good to me. Good stuff.
As for your question in number 1, hmmm, I'm not totally sure of the best way to do that. Some options:
1) leave it as it is now. Since they are now required, the user will have to enter the values in for those fields when they first turn on Going Down. Then when they turn it off, those values should still be there from your variable_get calls, so it probably won't be an issue. A user would have to delete the required fields and turn off giong_down for the error to throw, which is probably unlikely. It's not totally clean though.
2) In Drupal 7, I might use '#ajax' and and '#states' (http://api.drupal.org/api/drupal/developer!topics!forms_api_reference.ht...) to disable those fields with default unused values when the user disables going_down. Not sure if that's easy to accomplish in Drupal 6, or if that's what the best solution is.
3) Go back to your custom validation implementation, which has higher usability than #1 but lacks visual cues to the user that those fields are required.
Hmmmm...
Also the automated review comes back clean except for one error: The master branch still has files in it besides README.txt. See Step 5 here for instructions on how to remove them: http://drupal.org/node/1127732
Namely, these commands should do it:
Comment #4
maxtorete commentedI vote for go back to custom validation, and show users the validation rules through fields description.
Comment #5
tinker commented@mkadin Yeah I am seeing the master branch error too but I cannot figure out why. I previously followed the same directions you gave. There is only the README.txt file in the master branch (.git is also there). I executed a new clone of the master branch in temp dir and only received the README.txt.
Comment #6
farald commented@tinker I did not get this error. pareview only returns this:
So it seems you're good on the branching part. Also I checked the repository viewer, and all seems good.
Comment #7
tinker commentedUpdated GIT to fix error on line 12. Error on 160 (now on 162) is wrong since there is a newline after the parameter comment. Master branch seems to have worked itself out as I did not change anything.
Comment #8
tinker commentedNo reviewer response in 4 weeks - priority changed to critical
Comment #9
patrickd commentedI'm very sorry for the delay,
as there are currently hundreds of application this is all runnning slow.. :/
We do really need more hands in the application queue and highly recommend to get a review bonus so we will(/can) come back to your application sooner.
Comment #10
firebird commentedHere's my review:
Licensing: No problems found
Module duplication: No module I could find on Drupal.org does what Going Down does.
Overall understanding of Drupal API's: Looks good to me
Security: The unfiltered $style and $message variables that get passed to the templates in the footer hook would be a security risk if the only user that can set them wasn't the admin. That said, it would definitely be Best Practice to check_plain() or check_markup() user entered values, even if the user is the admin.
Code documentation: Functions are documented well enough, and the code is clear and easy to read.
Automated review:
FILE: ...review/sites/all/modules/pareview_temp/test_candidate/going_down.module
--------------------------------------------------------------------------------
FOUND 5 ERROR(S) AFFECTING 5 LINE(S)
--------------------------------------------------------------------------------
17 | ERROR | Additional blank line found at the end of doc comment
162 | ERROR | Last parameter comment requires a blank newline after it
164 | ERROR | Additional blank line found at the end of doc comment
223 | ERROR | Additional blank line found at the end of doc comment
240 | ERROR | Additional blank line found at the end of doc comment
--------------------------------------------------------------------------------
Comment #11
klausiClosing due to lack of activity. Feel free to reopen if you are still working on this application.
Comment #12
tinker commentedFixed security issues from #10
Pareview review is clean
http://ventral.org/pareview/httpgitdrupalorgsandboxtinker1449426
Comment #12.0
tinker commentedSwitched git from master to 6.x-1.x branch
Comment #12.1
tinker commentedAdd reviews of other projects
Comment #13
tinker commentedAdded reviews of other projects and tag.
Comment #14
balintbrewsI went through this project application review checklist, and I think the checkpoints are mostly fulfilled, but I found some issues. Here are my suggestions.
User provided value is passed to
t()In the method
_going_down_get_message()a user provided value is passed tot():This is problematic for many reasons. Please read the section Go the easy way with t() - wreck your ship in Gábor's blogpost for a more detailed explanation.
Variable naming
There are a few variables in the method
_going_down_get_js()which are not named according to the coding standards, such as$messagegoingdownand$messageoffline. These should be corrected with underscores indicating the separated words. Also, the object that you pass to JavaScript as setting should follow the naming conventions described in the JavaScript coding standards, so the keys needs to be lowerCamelCased.Not used
format_date()strftime()is used in many places, but there is a Drupal API method to use for the same purpose:format_date().JavaScript API
The file
going_down.jsdoesn't follow the already mentioned JavaScript coding standards. Please review it and correct the naming of your variables accordingly. Also, please take a look at the Drupal JavaScript API. You can for instance eliminate the$(document).readyusage, since Drupal has its own way to handle the same thing throughDrupal.behaviors.Punctuation in error messages
It's a very minor thing, but the error messages provided in the method
going_down_system_site_maintenence_form_validate()are missing punctuation.Comment #15
tinker commentedThanks for the thorough review @balintk. I learn something new everyday! (re: Drupal JavaScript)
Changes made:
Pareview review is still clean
http://ventral.org/pareview/httpgitdrupalorgsandboxtinker1449426
I appreciate the high quality of user contrib modules so am thankful for the review process. Hopefully my module will benefit some users.
Comment #16
balintbrewsNice progress you made. I have only two remarks.
_going_down_get_html()the default value of the`going_down_message`variable shouldn't be translated witht()either. I would suggest you to useformat_string()it the project were for Drupal 7, but in Drupal 6 you could usesprintf()to get the values replaced (just don't forget about escaping).Drupal.settings.goingDown.remaining). You should never add a function to theDrupal.settingsobject, because it's purpose is to store settings which are globally accessible by any method that is added toDrupal.behaviors. Also, there is no need to wrap all your functionality in a method here, so I think you can just omit that.Comment #17
tinker commented@balintk, Thanks for the remarks.
Pareview review is still clean
http://ventral.org/pareview/httpgitdrupalorgsandboxtinker1449426
Comment #18
balintbrewsValid point. :)
I haven't noticed the
setTimoutcall, sorry. In this case, I would recommend you to declare your method outside ofDrupal.behaviors.goingDown. Also, it's better to create an object for the module insideDrupal, and that can hold all the methods related to the module. E.g.:Drupal.goingDownwould be the object, and your method would beDrupal.goingDown.update().With that said, I'm setting it to RTBC.
Comment #18.0
balintbrewsAdd one more review.
Comment #19
klausiRemoving review bonus tag, you have not done all manual reviews, you just posted the output of an automated review tool. Make sure to read through the source code of the other projects.
Comment #19.0
klausiRemoved automated reviews.
Comment #20
tinker commented@klausi, Sorry I linked the previous list of reviews to the first comment I posted which most of the time was an automated review. I did post subsequent comments which contained manual reviews. I have updated the list to point to the manual review comments.
Comment #20.0
tinker commentedUpdated reviews
Comment #21
klausiReview of the 6.x-1.x branch:
This automated report was generated with PAReview.sh, your friendly project application review script. You can also use the online version to check your project. You have to get a review bonus to get a review from me.
manual review:
But that are not blockers, so ...
Thanks for your contribution, tinker!
I updated your account to let you promote this to a full project and also create new projects as either a sandbox or a "full" project.
Here are some recommended readings to help with excellent maintainership:
You can find lots more contributors chatting on IRC in #drupal-contribute. So, come hang out and get involved!
Thanks, also, for your patience with the review process. Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.
Thanks to the dedicated reviewer(s) as well.
Comment #22.0
(not verified) commentedUpdate git location to use public version