Sandbox URL: http://drupal.org/sandbox/yogesh1110/1155096
Hi,I want to contribute a user_access_ban module, which include the below functionality.
The module should allow users with the appropriate permission, to visit a user's profile and then, in addition to "Blocking" them, it should allow for the user to set a no of days when the "Blocking" automatically expires.
The current user edit form includes the following section.
1. Blocked
2. Active
My suggestion would be to add a text-field that allows the administrator to define the number of days until the "Block" is automatically removed. As seen below.
1. Blocked
2. Active
3. Remove block in [3] days
Additionally, there should be 2 permissions added to the Drupal Permissions table. admin/user/permissions
1. Temporarily Ban users - Allows for the selection of which roles can use this functionality
2. Exclude From Temporary Bans - Allows for certain roles to be excluded from banning. This is so an "Admin" or similar role cannot be banned by a lesser privileged role.
Lastly, there should ideally be a table that shows a listing of all users that are currently temporarily banned. Much like the default user table admin/user/user.
As an optional item, when a user who is temporarily banned attempts to login, the could be presented with a message informing them with a message like: "Your account is temporarily banned. You will be able to access the site again on 27, February 2011"
Final note: I think the bans should be removed on Cron run. So it should be easy enough to simply set the expiration as a unix time stamp. Then, when Cron runs, all it has to do is look for time stamps that are lower than the current time. It then removes the bans.
Please review and provide me CVS account access.
Thanks
Yogesh Saini
Comments
Comment #1
pwaterz commentedYou need to write the module first before appling for a cvs account. Once its done please upload it here. Also make sure there are no similar modules that already exist.
Comment #2
yogesh1110 commentedI am in process of development of module. I did not know that we need to apply for cvs account once module is ready. I will upload the module once it is complete.
Comment #3
pwaterz commentedComment #4
arianek commentedHi. Please read all the following and the links provided as this is very important information about your CVS Application:
Drupal.org has moved from CVS to Git! This is a very significant change for the Drupal community and for your application. Please read the following documentation on how this affects and benefits you and the application process:
Migrating from CVS Applications to (Git) Full Project Applications
Comment #5
yogesh1110 commentedI have submitted the project to sandbox and URL is: http://drupal.org/sandbox/yogesh1110/1155096
I need further instructions.
Comment #6
jthorson commentedyogesh1110,
Please check out the 'Migrating from CVS Applications to (Git) Full Project Applications' link that arianek posted, and specifically Step 5 on that page. If all that has been done, it's simply a waiting game until someone is able to pick up your issue in the project applications queue (http://drupal.org/project/issues/projectapplications).
Comment #7
jthorson commentedUpdating Issue title/queue/status as per the 'Migrating from CVS to Full Project Applications' instructions provided on the referenced page.
Comment #8
yogesh1110 commentedThis module allow users with the appropriate permission, to visit a user's profile and then, in addition to "Blocking" them, it should allow for the user to set 'Temporary Block' for a duration that automatically expires.
I have submitted the project to sandbox and URL is: http://drupal.org/sandbox/yogesh1110/1155096
Please review it.
Comment #9
jthorson commentedUpdating priority according to the new project application priority guidelines. The application's priority should be set back to normal once a reviewer responds to your application and the application review process has continued.
Comment #10
Mikey Bunny commentedOk, this is just a quick pass to get things moving. I haven't tried using the module yet:
To tidy up your project file structure:
- Remove $Id at the top of the files as these are no longer needed (and ignore coder's warnings that these are missing if it gives them)
- Remove the LICENSE.TXT file as this will automatically be added.
- Go to admin/build/modules and select the (Code Review) link next to the names of your modules
- Open the “Selection form” fieldset and select “minor (most)” and tick “internationalization
- Submit the form
- Fix the errors ignoring any reports.
Comment #11
yogesh1110 commentedHi Mikey,
Thanks for your update.
I have removed $ID from all files and deleted the License.txt file. I have check the code from coder module also and fixed the errors.
Please update me further instructions.
Comment #12
Mikey Bunny commentedHi Yogesh
I just want you to know that I'm not ignoring you. I've been extremely busy day and night and weekend over the last few weeks. I now have have a major issues with the VM that was providing my web services on this machine at present and can't currently run any code during the day. I'll pull down the latest version of your module just as soon as I can get things working again and catch up with what I should have been doing for the past few days.
MB
Comment #13
yogesh1110 commentedHi Mikey,
Ok, I understand the things that's are moving around you. Anyway, I will be waiting for your response soon.
Yogesh Saini
Comment #14
pwaterz commentedyogesh, go on IRC and go to the room #drupal-contribute and ask someone to look at your module in there. I found it can speed up the processes.
Comment #15
yogesh1110 commentedpwaterz, sure I will try to do this as soon as possible.
Comment #16
Mikey Bunny commentedHi Yoesh. Apologies for disappearing, my machine died and then I got very ill for a few weeks. Here's some more feedback for you.
When the module is enabled I get the following warning:
Date Popup dependency: Although I was able to install your modules once I had the date picker installed I then got the following message when editing a user page:
You may want to raise a ticket against Date Picker to add this as a dependency on their module. I'm not sure why they are doing it as a drupal message rather than a dependency, maybe they have a good reason for this?
The menu under “User management” is called “Temporarily user block”. In fitting with your module and better use of English this would be better renamed “Temporarily block users”. I will help you with the English and grammar later on if you need me to once we have everything else working.
I can see no mention of the “Temporarily user block” menu in your README.txt. It would be useful for user of the module to know about it in advance rather than just stumble across is.
user/tbu/settings Add the missing “.” to the end of the description and correct the typos, you are missing a few words like "is" and "the".
user/tbu/settings I’m not quite sure what the following is supposed to mean?
Should this be "Block users by role"?
user/tbu/settings - "Block users by roles wise" - This section seems unfinished. I can only see block all users. I would suggest that you either remove this or pupulate the list with all user roles. A brief description here explaining what this is for would also be helpful.
Please can you indicate where I can temporarily block users? I can see no option for this at /user/user/list or on the user edit pages.
There is a lack of comments in your code (functions) explaining what you are doing and why. For the benefit of yourself and others I recommend that you go through your functions and add comments to explain what you are doing and why. I have included an example of a commented function below:
Missing use of whitespace: You are missing some white space around the conditional items in if statements etc. Here's an example from check_user_block():
change this to:
You will need to check and correct his throughout your code. You will find more information on spacing and layout at http://drupal.org/coding-standards#comment.
temporarily_block_users.info description: "Temporarily Block User Wise." does not make sense. Please let me know what you are trying to say here?
Line length: I'm not sure that there is a definition for the general maximum line length in Drupal (someone please point this out if there is) but I can see lots of discussions on it. Comments should definitely not extend more than 80 characters per line, see http://drupal.org/node/1354. Many posts seem to recommend 80 characters for general code. I myself would say anthing up to 100 characters unless someone else can point out the relevant section in the Drupal standards?
Here's an example of how to break your long lines up taken from theme_temporarily_block_users_settings():
Indent the content by 2 spaces and align them as follows:
Also in temporarily_block_users_list()
Would would be more readable as something like:
You will find more information on spacing and layout at http://drupal.org/coding-standards#comment and general coding standards via http://drupal.org/coding-standards.
Doxygen coding standards:
It's great to see you adding header comments to your functions. Please take a look at http://drupal.org/node/1354 to see how you should add the addtional tags like @param, @return, @ingroup and @see. Also, treat your comments as English and start them with capital letters and end them with full stops.
check_role_block() missing function header comment.
SQL Query Standards:
Reserved words in your queries should be in uppercase. See http://drupal.org/node/2497 for full details.
Typo in functiion "user_blocked_excluled" should be "user_blocked_excluded".
temporarily_block_users_init() - This function and the functions that it call are not clear to me. For example, I'm not sure that you should be checking for the admin user rather than looking at permissions. However, I could be wrong and this may make more sense once you have added comments in your functions to explain what and why you are doing things.
Comment #17
yogesh1110 commentedHi Mikey,
Thanks for your valuable comments on my module. These is a big list error in my code :(
I will reply you my comments with each of your points soon.
Thanks again.
Comment #18
misc commentedThe applicant has been contacted to ask if the application is abandoned.
Comment #19
misc commentedThe application has been closed. If you would like to reopen it, you are free to do so.
See http://drupal.org/node/894256
Comment #20
yogesh1110 commentedHello Mikey Bunny and MiSc,
I want to open this issue again and want to make my module live on drupal.org.
I have worked accordingly point no #16. Please check it again and let me know your feedback.
Thank
Comment #21
yogesh1110 commentedComment #22
misc commentedIt could not be marked as critical as it was just reopened.
Comment #23
yogesh1110 commentedok, noted Misc. Expecting the feedback ASAP. Thanks
Comment #24
stborchertHi.
The module itself sounds really usefull (thought about creating something like this some time ago :)).
Quick review:
You are working in the "master" branch in git. You should really be working in a version specific branch. The most direct documentation on this is Moving from a master branch to a version branch. For additional resources please see the documentation about release naming conventions and creating a branch in git.
(At least this has to be done before switching back to needs review)
For an in-depth review please look at the results on http://ventral.org/pareview/httpgitdrupalorgsandboxyogesh11101155096git.
There are several notices and errors you'll need to resolve.
Comment #25
yogesh1110 commentedHello stBorchert,
Thanks for your quick review and appreciating module thoughts. I have work according to your feedback. Please check below URL for updates:
http://ventral.org/pareview/httpgitdrupalorgsandboxyogesh11101155096git
In this I have used module name as prefix but even then its showing error and another point is that spacing at '&' but this is am using as reference so can't remove it.
Thanks and waiting for again quick review...:)
Comment #26
stborchertHi.
Actually, I just wanted to make a quick review, but somehow it has become a little more detailed :)
(This is no functional review, just code.)
First, set your default branch to 6.x-1.x and remove your master branch.
If you're doing so, you may delete the branch 6.x-1.0-dev as well as its no valid branch name (see Release Naming Conventions).
// README.txt,v 1.5.2.6 ...) and the next blank line. This is a relict from old times (CVS) we do not use anymore.Additionally it is a major performance impact, as you are calling this on every init.
FALSE.<?php global $user; return $user->uid == 1;?>$user_account = user_load($user_uid);is unnecessary because user_access() uses the current user if the second argument is empty.user_access('exclude temporarily_block_users');* "access temporarily_block_users" is the permission to administrate the settings so it should be named "administer temporary_block_users"
* "exclude temporarily_block_users" is the permission to ignore the block so it should be named "ignore temporary_block_users"
$base_urlis not needed. Simply use<?php l(t('date format administration'), 'admin/settings/date-time/formats'); ?>arg().$res_ex_user = ...:<?php $user_blocked_until = db_result(db_query("SELECT block_date FROM {temporarily_block_users} WHERE uid = %d ORDER BY block_date DESC LIMIT 1", $uid)); ?>This way you can remove the while-loop and the unused variable
$count.user_load()as well.TRUEandFALSEinstead of numeric values for properties "#collapsible" and "#collapsed".$form['#validate'][0], use<?php $form['#validate'][] = 'temporarily_block_users_login_validate'; ?>to add your validation function. If the function should run before all others, use<?php array_unshift($form['#validate'], 'temporarily_block_users_login_validate') ?>user_login_name_validate()(see above; its not needed anymore).$formnor$form_stateis a reference.$countis not needed, you can use<?php count($rows); ?>to get the number of blocked users.$countis not needed, you can use<?php count($rows); ?>to get the number of blocked users.var ab = ...;).$form['#validate'] = array('temporarily_block_users_settings_validate');. This removes all other validation functions. Use<?php $form['#validate'][] = '...'; ?>orarray_unshift().user_not_admin()is not defined.$output(or change ".=" to "=" in the first line).Comment #27
yogesh1110 commentedHello stBorchert,
I have worked according to your feedback. Below points are not done:
1. Date Popup dependancy: Here I have not changed it because in this I am taking time also and if I take simple text field then lots of problem will come to take date and time data and also with the validation. I want to make this live asap.
2. menu_get_object() function is not returning any thing as I am using this in form_alter hook. So, I have leave this.
3. temporarily_block_users_user_excluded: I have used $uname instead of $uid because in validation case I have only user name so I have used here but in init function I can use $uid but to keep same function I have used same uname.
Please check and provide your feedback. I am eager to make it live asap.
Thanks
Comment #28
d2ev commentedhi ... you need to check Drupal coding standard at http://ventral.org/pareview/httpgitdrupalorgsandboxyogesh11101155096git
1. temporarily_block_users.module: Try to write your code in Drupal way -
- Define variable at the top of your function.
- user module_load_include() instead include_once like
2.
i hope you can simple append it instead array_unshift().
3. temporarily_block_roles.module : Don't forget to delete variable you defined for your module in uninstall hook.
4. temporarily_block_roles.module : This doesn't make sense.
5. temporarily_block_users.js : Drupal will not recognize '$' for jQuery in many situations:
You can wrap your jQuery in this to 'fix' it to work like it should from the start:
Comment #29
stborchertHave a look at the api documentation of menu_get_object(). If you call it with "user" as first parameter drupal tries to extract the uid from the URL and returns the user object. It works.
This leads to lots of unnecessary code and function calls. Its much cleaner to rely on the uid here (you're saving the uid so you need extra function calls to query the user, etc.) ...
Comment #30
yogesh1110 commentedHello D2ev,
I have taken care of your points as my below comments:
1. Drupal coding standard: I have checked this earlier also. Earlier I was using Implements hook_foo() but later on Mr. stBorchert told to use 'Implementation of ' so I have changed it as he suggested. Please let me know what is the final one.
2. 1st point done.
3. array_unshift() is used because I need to run my validate function at first call.
4. delete variable: I am already doing this.
5. 4th point I have removed that code.
6. 5th point is pending.
7. menu_get_object(): I have checked again this function with 'user' argument but still its not returning any value. I am using this in form alter hook. I have checked all documentation also.
8. name instead of uid: In this function temporarily_block_users_login_validate, I am not getting user id and only username only getting so, m using this.
Thanks
Comment #31
yogesh1110 commentedHello D2ev/stBorchert ,
It's long time now. Any further feedback for me, I am much curious to make it live ASAP.
Thanks
Comment #32
yogesh1110 commentedHello D2ev/stBorchert ,
It's long time now. Any further feedback for me, I am much curious to make it live ASAP.
Thanks
Comment #33
yogesh1110 commentedComment #34
yogesh1110 commentedComment #35
yogesh1110 commentedComment #36
paravibe commentedHello,
Remove "project" from the info file, it will be added by drupal.org packaging automatically.
All functions should be prefixed with your module name.
And automated test find some errors. See http://ventral.org/pareview/httpgitdrupalorgsandboxyogesh11101155096git
Comment #37
yogesh1110 commentedHello drupalrv,
I have follow your instruction and submitted back. Regarding module name prefix, I am already using it but don't know why it showing there error even.
Please check it and let me know your further feedback. I am very much curious to make it live.
Thanks
Comment #38
paravibe commentedHello yogesh1110,
I have checked prefixes of your module and all is OK for me.
Also I reviewed your code a little and don’t found any problems.
Please participate in bonus review program and klausi will write to your soon.
Comment #39
yogesh1110 commentedHello drupalrv,
Thanks for positive feedback. I will check that program and responds to you.
Thanks again
Yogesh
Comment #40
devin carlson commentedI couldn't find any real issues outside of some code spacing or variable naming.
My one suggestion would be to drop the requirement for the Date Popup module (which would require you to enable multiple modules from the Date package) and simple provide an enhanced date input form item if the Date Popup module is installed.
You should be able to do a simple
module_exists()around:And if the Date Popup module is unavailable simply provide a more basic form item based on the core
'#type' => 'date'form type.Comment #41
stborchertOne quick note:
in function temporarily_block_users_form_alter () you are using
<?php '#default_value' => (time() > $user_blocked_until)? NOW : date('Y-m-d H:i', $user_blocked_until), ?>. Did you intend to use "NOW" as a constant (it is not defined) or as a string (quotes missing)?Since we are currently quite busy with all the project applications it would be great if you can review some other project applications and get some review bonus.
Comment #42
stborchertThanks for your contribution, Yogesh!
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 #44
yogesh1110 commentedHello stBorchert,
Thank you so much for approving my module. This is my first project to be on drupal.org. I am very much very much happy on this. Thanks you once again. Sorry for late reply as I have not checked the site due to some other reason.
Thanks again.
Yogesh saini
Comment #44.0
yogesh1110 commentedAdded correct sanbox url to make it easier for others to review.
Comment #45
avpaderno