First login is a simple utility module which enables the use of "first logins" for users. With this module the site admin can enable content or do things that appear only on the first login for users. Admin can set a maximum number of logins that are considered as "first" and thus enabling other modules to present content on those first logins.
First login will integrate nicely with Views and core Block module. Also it's very easy for custom modules to use first_login.
First login also provides a couple utility functions to set and get first login data. Initial data found is either "status" or "count".
This is a simple module and I was suprised I didn't find this functionality anywhere. So now there's a module for that... :)
Link to project: http://drupal.org/sandbox/afox/1166844
Project reviews
http://drupal.org/node/1247488
http://drupal.org/node/1397230
http://drupal.org/node/1372462
http://drupal.org/node/1412024
| Comment | File | Size | Author |
|---|---|---|---|
| #14 | drupalcs-result.txt | 1.38 KB | klausi |
Comments
Comment #1
joachim commentedIt's an interesting idea, but I'm seeing a few problems in the implementation.
- always wrap your ifs and elses in {}, even single lines.
- run through Coder module for formatting.
- when do first_login_set_data / first_login_get_data get called?
- user_save() takes two parameters IIRC.
- $user = user_load($uid);
I can't tell as I don't see where you're calling this, but if this is switching users, it's insecure.
- * Function first_login_get_data()
That does not count as documentation! ;)
Took me a while to figure this out... you're setting some PHP code into the visibility field...???
This does really not look good to me. What if the admin user already put something there? This is really hacky I'm afraid.
Overall, I think this would be a very handy feature for a lot of sites, but I think it would be better done a by providing a reaction plugin for Context module. A clean method of turning blocks on and off would be already provided for you, and you'd just need to let the API know the current user's status.
Comment #2
afox commentedThanks for the comments. I committed a new version with your suggestions (accidentally committed under a different name, now I gotta learn how to rename the commit...).
Here's some answers to your questions:
set_data is just a helper function that is useful for developers. I use it when disabling first login even if the counter is not full yet. Get_data is called in views handlers.
It was called when user passes only $uid in first_login_get_data. Using $user variable was a bad choice, I changed it to $account.
That block visibility wasn't actually of my doing, I needed a quick method to control the block visibility and didn't have the time to learn context plugins yet. Grabbed it from another module somewhere. Definitely was hacky... :) Thanks for making me change it. I removed the block-module integration and changed it to support context. I don't know how you meant it to be used as a reaction plugin, but now it's a condition plugin. How could it be implemented as a reaction?
Comment #3
joachim commented> I don't know how you meant it to be used as a reaction plugin, but now it's a condition plugin.
Nice job!
> How could it be implemented as a reaction?
I meant condition... sorry, was being dense :/
Comment #4
afox commentedOk, so is there anything else that still needs to be done? I'm itching to get mi project released... :)
Comment #5
jordojuice commentedDon't get too anxious! Looks like the queue is way backed up, but best to ensure quality rather than a speedy process. My project has been in the queue for about a month now. I've learned a lot watching and reviewing other projects though.
Comment #6
afox commentedThat's a good idea jordojuice! I'll go and give a hand with the reviews.
But one can't be blamed for wanting to contribute! :)
Comment #7
jordojuice commentedAgreed. Good job!
Comment #8
joachim commentedSorry for the delay...
This seems to be coming along very nicely.
Something that may require work has come up though...
I was having a poke around in your Views handlers, and noticed that they are fake fields, in the sense that they don't add anything to the view's query, but do a first_login_get_data() which in turn does a user_load(). This isn't the best way to do things. A better way would be for the handler to add the 'data' DB field to the query, and then deal with unpacking its data (here it *would* be sensible to use a helper function in the module).
This got me thinking... would storing the login count in a table be better? Which got me wondering how come nobody had done this already. Well, it turns out they have: http://drupal.org/project/user_stats.
So it seemed to me that it would be better to depend on a single module for handling login counts and all that.
However... looking at that module right now, I'm going 'WTF' at its data structure defined in its hook_schema. See for yourself: http://drupalcode.org/project/user_stats.git/blob/refs/heads/6.x-1.x:/us...
A blobby table like this is just crazy, especially when every single property that the module stores is one-to-one with a user.
So my recommendation with regard to data storage is keep doing what you're doing, and consider depending on user_stats in the future, when/if its data storage is cleaned up.
On to some simpler matters...
- first_login.context.inc
I don't think you need an inc file for just two API functions, it's the same as putting the views_api hook in the main module code. Do remember to give them docblock headers though!
- check blank lines. The end of every file should have an empty newline; there should be no blank line between docblock and function declaration.
- as previously mentioned, I think your Views handlers need to be changed.
Don't put a fieldset around the entire form.
Comment #9
tim.plunkettClosing due to inactivity, feel free to re-open if this was a mistake.
Comment #10
afox commentedI'm re-opening this as I've finally had the chance to get back to module development. I'm now finishing up my modules for distribution and additional development.
I've pushed new code to the sandbox. It includes the changes suggested by @joachim in #8 with the following additions:
- fixed context-module support. I noticed some flaws in it, now it's better.
- fixed some counting and setting issues in the main module file
- switched from using user_load into a smaller db query
@joachim (or whoever will continue reviewing this):
About the views field integration... as I'm using the users table's data -field, views integration becomes quite tricky. As you know, the data-field is serialized and thus makes querying it quite difficult. The way I've implemented views field (as a fake field, no query additions) is actually the way merlinofchaos himself suggests doing in this case. (see http://drupal.org/node/763452#comment-2812692).
This solution makes views integration a bit lacking, but currently I resent more to creating a separate table for this data. As the magic mostly happens in hook_user, using the already loaded user data is appropriate IMO. I can review this later and make changes if module users want better views support (with filters and sorting).
Comment #11
peterx commentedI am reviewing the module description for comparisons to other modules. Would I select the module for evaluation after reading the description?
The legal module lets you push the terms and conditions in front of other users at login. The condition is reset when the T&C changes. Will your "first time" condition allow for resetting and treating all people as first time if there is a major change to the site?
Could first time trigger a rule or add a role at the start of the first time period then trigger a rule or delete the role at the end? Hook first time start? Hook first time end?
Like you, I searched for something similar. In my case I wanted last-few-weeks-before-subscription-expired and first-few-weeks-after-subscription-starts. I wrote something that connects to everything else by adding a last-few role then a first-few role. A number of other modules and CSS can occur based on the roles. Ubercart roles does something similar for subscriptions. Based on your description of your module, I cannot see how it will connect to other modules, control the appearance of blocks, and CSS.
Comment #12
afox commentedThanks peterx for your comment,
as the project description states, this module integrates with Context as a condition plugin. Context-module is the de facto solution currently to provide changes to the site. For example block visibility and CSS changes (via adding classes) are easily achieved to any or all pages in the first login state with context and first_login enabled.
The module does not currently have Rules integration nor is it content aware, but they sound like a good feature requests for the future of the module. ;) however it does give couple functions to set and get the current "first login" status and login count. These can be used by other modules of course.
Although this goes OT with my application issue, what you've done with your subscription-issue would've been easiest to implement as a context condition, I think. :)
Comment #13
afox commented+ PAReview: review bonus tag
Comment #14
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. Get a review bonus and we will come back to your application sooner.
manual review:
But that are just minor issues, otherwise I think this is RTBC. Removing review bonus tag, if there are still changes required you can add it again if you have done another 3 reviews of other projects.
Comment #15
tim.plunkettThanks for your contribution! Welcome to the community of project contributors on drupal.org.
I've granted you the git vetted user role which will let you promote this to a full project and also create new projects as either sandbox or "full" projects depending on which you feel is best.
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.
As you continue to work on your module, keep in mind: Commit messages - providing history and credit and Release naming conventions.
Comment #16.0
(not verified) commentedAdded project review links.