CVS edit link for Kevin Quillen
I want to contribute a module that was developed for a website of the US Travel government organization. I did some research first and found no module to suit my needs.
This module allows a user with the proper permissions to create an 'alert message', which displays at the top of the site, like CNN Breaking News. When enabled, this module sets a cookie to track that user, so when they close a message, they don't see it again.
Example of what this module does: http://blog.melissahie.com/wp-content/uploads/2009/06/michaeljackson-cnn...
Comments
Comment #1
kevinquillen commentedWorking code posted.
How to use:
Enable the module, and assign the User Alert block to a region of your choice. Create a User Alert node, and it will display until either you close it or the time limit for the message expires. There are settings to allow you to change the display label from User Alert to something else, as well as set a expiration time for messages (1, 3, 6, 9, 12, 24 hours or never).
Right now it will also unpublish any published alert when a new one is created or updated to published, to avoid having a bunch of messages show up.
Comment #2
avpadernoHello, and thanks for applying for a CVS account.
May you describe a bit more the proposed module, and make a comparison with existing solutions?
Comment #3
kevinquillen commentedSure.
I am filling a gap wherein the admin or someone with permission can create an 'Alert', which is basically a short direct message at the top of the screen. The best comparison of the functionality is a BREAKING NEWS flash on a news site. A user can X out the message and it goes away. drupal_set_message didn't satisfy my use case to also allow tpl/css overrides, and a click to close functionality.
I looked at admin_message (http://drupal.org/project/admin_message) but this was architected for logged in users only, and has a different purpose in mind. My module uses a cookie to track a visitor (assigning a UUID), and not rely on the Drupal user object which does not store data about an anonymous user, as not all sites will have users log in. This way, anyone coming to the website can see the urgent message, regardless if they are logged in or not, which satisfies my use case in providing the functionality that you would see on CNN or even Facebook.
Beyond that one module, I did not see anything close to what I wanted to achieve.
Comment #4
kevinquillen commentedFixed a slight bug in the cron hook.
Comment #5
avpadernoThank you for your reply.
Comment #6
kevinquillen commentedHi guys any update here?
Comment #7
kevinquillen commentedI have added this module into GitHub for time being so I can track my changes. Please let me know of an update when you can would love to have it on drupal.org.
Comment #8
kevinquillen commentedRemoved the drupal_goto in the init(). I implemented that prior to having AJAX method of closing the message. The drupal_goto interfered with crawlers.
Comment #9
avpadernoI will review the code tomorrow morning.
Comment #10
kevinquillen commentedThank you
Comment #11
avpadernoNeither the functions are implementations of a hook.
The coding standards report there should not be any empty lines between the documentation comment and the function.
The return statement in the last function is not required.
The default package is Other; there is no need to declare it.
hook_install().None of the Drupal core modules removes nodes of the content type they define.
AFAIK, the permissions to edit any node of a content type, to edit own nodes of a content type, to delete any nodes of a content type, and to delete own nodes of a content type are already defined from the node module. See the permissions defined in book_perm(), which doesn't define the permission , in example.
The first argument of
t()is a literal string, not a concatenation of strings. The script used to create the translation template is not able to handle any dynamic value, even in the case of code similar tot($variable); this means that if the argument of the function is not a literal string, it will not appear in the translation template.Comment #12
kevinquillen commentedOkay, I will address these. A few I was not aware of and was just following the lead of other modules I have seen.
About #4 though, why would Drupal not want a module to clean up its data? I can see the drawbacks, but at the same time, if you really wanted something out of the system, shouldn't it do that? That is what I thought anyway.
Comment #13
avpadernoI can see a reason why book.module, in example, doesn't delete any book pages, when it is removed.
With few exceptions, Drupal core code is usually the reference code to use to write your own code; the exceptions are, in example, the name to give to the functions, and the use of functions with a name starting with _.
Comment #14
kevinquillen commentedGotcha. Changed _form to _admin_settings and removed submit handler. Reformatted a majority of my comments to the coding standards page, removed the node deletion on uninstall, removed the variable sets in the install, removed the t() on variable output, removed package declaration, removed all perms other than 'administer user alert'.
Comment #15
kevinquillen commentedComment #16
avpadernoThank you for your contribution! I am going to update your account.
These are some recommended readings to help with excellent maintainership:
You can find more contributors chatting on the IRC #drupal-contribute channel. So, come hang out and stay involved.
Thank you, 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.
I thank all the dedicated reviewers as well.
Comment #19
avpaderno