This module uses drupals standard nodes to implement a logbook system.
A logbook entry is a simple entry to add when you want to be able to log what you have done for a particular type of event. This module handles different types of logbooks.
After installing goto 'admin/settings/logbook' where you can add new logbooks. After adding a new logbook you can easier manage the fields (cck) for each logbook type. From here you can even manage the Permissions for logbook node types only (dont have to use the standard drupals permission form).
Once you have created your logbook and and fields that are needed you can then add new logbook entries 'logbook/add'.
Why did I do this??
I am Scout leader and we have to log all the Adventurous Activities (Abseiling, Caving, Kayaking, Bushwalking etc) to show what we have done to keep our qualifications active and I wanted a simple way a user could just click and add an entry plus I wanted any admin to be able to add and manage logbooks with ease.
I have attached what a typical logbook may look like...this module wont create the fields but makes it easy to do from the one place.
http://drupal.org/sandbox/jack_tux/1155956
Reviews of other projects
http://drupal.org/node/1536250
http://drupal.org/node/1057956
http://drupal.org/node/1222472
| Comment | File | Size | Author |
|---|---|---|---|
| Create Bushwalking.png | 32.67 KB | jack_tux |
Comments
Comment #1
jordojuice commentedYou need to fix documentation throughout the module. It is very lacking.
Your hook documentation should say:
Implementation of hook_menu(). ...or... Implements hook_menu().
Not...
Implements hook_menu ...or... implements hook_menu
Most of your functions have no documentation at all and all your functions should be namespaced, even if they're private i do believe. Please review the coding and documentation standards and set this back to 'needs review' once documentation is updated.
Good luck!
Comment #2
jack_tux commentedHi
Thanks for pointing that out...
Have updated the module with more documentation.
You should be able to pull origin 6.x-1.x
Thanks
Comment #3
jack_tux commentedhi just bumping this.
I know guys are busy, so thanks for your time.
Comment #4
jordojuice commentedRight on! I will try to get to this shortly.
Comment #5
jordojuice commentedOkay, so your documentation is indeed improved, but there are still some issues. Comments should always start with a capital letter and end with a period in sentence format. Actually, here is an example of documentation covering most of the bases (from one of your functions, along with pretend parameters and return value):
The example above makes careful uses of many standards. This may seem long and like a lot of unnecessary documentation, but remember that in cases like common hook implementations and functions with $form and similar parameters they don't generally need to be documented in @param, @return, etc. Just use discretion and document what might not be obvious. Some of these documentation standards I noticed were issues in your module, which I'll detail below.
Even hook implementations should be
Implements hook_menu().starting with a capital letter and a period at the end.Inline comments that use
//should start with a space, capital letter, and end with a period like// This item does this.@returndocumentation should be like this as an example:So, we have @return on one line, and the following line, indented two extra spaces, has the information on the returned value.
Similarly, @param documentation is like:
For good examples on documentation standards, refer to core modules.
Aside from these documentation formatting issues, the module looks like it makes proper use of the API, uses placeholders and t(), implements hook_help(). All good.
I haven't tested the module yet, but noticed it has a dependency on CCK. Normally I see this as
dependencies[] = content, does the dependency work properly usingdependencies[] = CCK?Lastly, you should add a README.txt file detailing instructions on installation and configuration of the module.
Thanks again for your contribution and I look forward to continuing the review!
Comment #6
jack_tux commentedOk you are a hard person to please. But am glad for your feedback.
Have hopefully done all the changes and have modified the dependencies (I thought I had already changed them)
Please let me know if I need to modify anything else.
Thanks for your time.
Comment #7
jordojuice commentedActually, it looks great! Nice job. I think your well on your way. I will try out the module soon.
Thanks again for all your hard work. This can be a long and sometimes confusing process.
Comment #8
bfroehle commentedHi Jack,
You can read more about comment formatting conventions at http://drupal.org/node/1354.
I was going to give this module a try, but when I try to enable it says I don't have cck installed. (But I think I do...?). Are you sure 'cck' is a dependency (and not 'content')?
Anyway, after changing the dependency to 'content', things work okay. When I try and edit other CCK content types, I get an error message
"Notice: Undefined index: content_type in logbook_form_alter() (line 300 of /Users/bfroehle/tmp/logbook/logbook.module)."
It'd be nice to have a README or similar so I would know how to get started. (For example, just going to 'logbook/add' didn't present me with any options, so I had to figure out how to go to settings/logbook first.
Comment #9
bfroehle commentedMore comments:
theme('checkbox', ...)instead of'<input checked="true" type="checkbox" name=logbook_add_permissions[] value="' . $drupal_type . ':' . $rid . '">';Overall things are looking pretty good. I love the concept, and the presentation is pretty great.
Comment #10
jordojuice commented@bfroehle did you pull the latest commit? These documentation, dependency, and README issues were fixed as per #5 and I see them in the repository.
Comment #11
bfroehle commented@jordojuice: The author must have done them today. That's fantastic!
Comment #12
jack_tux commentedHi
Thanks for all the tips.
I would like to address #9:
Point 1 - Have replaced checkbox with theme
Point 2 - Because user_admin_perm_submit() removes ALL permissions and replaces will all new ones, this wont work for this application. Because I am only displaying permissions for all logbook types I cant remove ALL permissions as I dont have the other permissions to add them back in... so I use my own function to remove only permissions of logbook type.
Point 3 - Because the form uses checkbox arrays (name='logbook_add_permissions[]') these dont come back in the $form_state['values'] properly but do come back in a nice array in the $form['#post']
Point 4 - Have updated links with l() and replaced with dl (yes better idea)
If you know a better way to do Points 2 and 3 please let me know.
Thanks guys for taking the time in checking the code.
Comment #13
jack_tux commentedComment #14
jordojuice commentedThere are certainly ways to access
$form_state['values']with the form built correctly. I wrote this as a quick example of something that might work properly with a bit of theming (if I'm reading your code correctly). This is a simple list of checkboxes. (didn't test it, but I know this is how it goes, and the point is that it can be done this way.)Comment #15
jack_tux commentedOK... I think i get it now
I need to do a little refactoring, so will be a few days before I get them done.
Thanks for the help
Comment #16
jack_tux commentedHi jordojuice
I have been looking at putting it in a theme like you suggested, but it's turning out to be complicated than the original.
Yes the values do appear in the $form_state['values'], but getting the output to look nice will make the code very complicated to read because I want to group permissions by their content_type and I cant see a way to do this nicely.
I do understand your example, but at the same time I am finding it difficult to do what I want to do.
So if possible can I keep the code the way it is and when I find a better way to do it I will come back to it.
Please let me know if this is going to be OK
Thanks again for taking the time to review my module.
Comment #17
jordojuice commentedIndeed it can be very finicky to work with! I understand. I spent a lot of time working with these types of forms in the module I just released, as well. And without everything fitting together perfectly it often will not work at all. So that should be okay with me. But maybe keep this method in mind for the future or for other applications. It does make good use of the Drupal API, which is mostly the reason i showed you that instead.
I'll have to take another look at this here soon.
Comment #18
jack_tux commentedYeah
I have no intention to "re-invent the wheel" and I will endeavor to use the API as must as possible.
Thanks for taking another look.
Comment #19
jack_tux commentedHi
I am just wondering where this up to at the moment
Thanks
Comment #20
bfroehle commentedI think we were waiting for some improvement to the permissions form handling, like the example posted in #14. I'm not comfortable approving the application until $form_values is used properly.
Some additional comments:
Comment #21
jack_tux commentedHi
Have fix the problems with Coder. You will need to get a new branch (6.x-2.x)
As for the using the $form_values, at this stage I am unable to get them to work properly as per #16 and unable to put in the time to find out the best way to do it.
If this means that this module wont get released then please close this ticket, I will just use my modules internally.
Thanks to those that have taken time to review my code.
Comment #22
jack_tux commentedHi
Can you please let me know if there is any update... mostly in regards to #21
Thanks
Comment #23
klausi* lines in README should not exceed 80 characters
* indentation: always use 2 spaces per level (wrong in logbook_extra_menus())
* don't use /** and */ for comments in function bodies, they are only used function doc blocks. Use // instead.
Comment #24
jack_tux commentedHave done the changes. Please make sure you check out branch 6.x-2.x
Thanks
Comment #25
sreynen commentedHi jack_tux,
Some problems I found:
Everything in this function seems to be unnecessary. There's no schema_logbook() definition, so nothing to uninstall there. There are no calls to variable_set(), so nothing to delete there. And menu_rebuild() is already called from system_modules_submit(), which handles installing and uninstalling modules. logbook_install() also seems to be unnecessary, so you should probably just remove the whole file, unless I'm missing something.
TRUE should be all-caps.
print theme("page", $page);should just bereturn $page;The page wrapper will be added automatically on a return.It's not clear to me what's going on here, but there must be a better way to do this. Have you looked at hook_node_grants()?
Comment #26
jack_tux commentedHave pushed the changes.
As for the regex, it is there to find and remove a specific permission from the permissions table.
In D6 all the permissions for a role are stored as a string for that role....what this function does is to remove only the specified permission ($perm) from all the roles.
I haven't used hook_node_grants() before and I dont think it will do what I am after.
Thanks
Comment #27
klausiComment #28
jack_tux commentedSorry for that, the formatter was set to a new project I am working on.
Should be OK now.
Thanks
Comment #29
klausiComment #30
jack_tux commentedHi
Have fixed the tag issue and removed the old branch... I haven't had luck removing the master files.
Also fixed indent issue...not sure what happend there.
logbook_extra_menu() was just to keep the fixed menu's and dynamic menu separate from each other.
logbook_add_extra() is the page callback for the dynamic menus... I didn't know of any other ways to do this, and also I have nice url's
Fixed false => FALSE, and my coder didn't pick up the problem.
As for the $form_state[] please see my reply #16 and #17. I know it's the "drupal" way but at this stage there is too much work to get it the "right" way. It's one thing I will look at in the future.
Thanks for your time.
Comment #31
jack_tux commentedComment #32
thedut commentedHello Jack_tux,
here is few issues :
A security issue for preventing SQL injection attacks : you don't sanitize datas thats are going to be used on sql query :
To Fix it :
line 202 : _logbook_revoke_permissions(check_plain($revoke));
line 211 : _logbook_add_permission($rid, check_plain($permission));
- in logbook_menu() : don't use t() fonction on the "title" key (reference ) but the untranslated title of the menu item.:
- line 70 and 385 : replace "strtolower" by "drupal_strtolower"
- line 295 : logbook_help() : separate content from presentation like here. Write :
return ("<p>" . t('Select which type of Logbook Entry you would like to make') . "</p>");- factorize code :
become :
I add a coma on line 147 to.
Thanks
Comment #33
jack_tux commentedThanks thedut for finding the security issues.
Have done the other changes and the refactor of the checkbox render.
It's amazing what you can miss, thats why I guess we have to go through this.
Thanks again.
Comment #34
penyaskitoReview of the 6.x-2.x branch:
This automated report was generated with PAReview.sh, your friendly project application review script. Please report any bugs to klausi.
Comment #35
jack_tux commentedHave fixed issues.
Comment #36
klausiComment #37
klausimake sure to enable PHP notices in your php.ini for development, I encountered this one on content type edit page: "notice: Undefined index: content_type in /home/klausi/workspace/drupal-6/sites/all/modules/logbook/logbook.module on line 322.".
and there is a huge list of notices if I just add a Logbook content type and then visit the Permissions page.
And there is a security vulnerability in your permission code. An attacker can easily modify form POST information (I did it with a firefox extension https://addons.mozilla.org/de/firefox/addon/tamper-data/ ) to change the submitted permission string. You must verify the incoming permission string because right now you are writing it as is to the database, which can lead to a permission escalation. I changed "create logbook_test content:2" to "administer nodes:2" in the request and the role got that permission. So everybody with the "manage logbook" permission can assign arbitrary permissions to their own role, which means they can take over your site.
That is exactly the reason why we suggested to use the form API properly with $form_state instead of accessing raw POST data.
Comment #38
jack_tux commentedOK
I found some time to look at this again.
I have moved the permissions to a theme hook and am now using $state_form to get the form values.
Thanks for pointing out the security issue, I tried what you did in #37 and could repeat this (I just learned a new trick :) )
I hope this now meets all the requirements now and I can get it released.
Thanks
Comment #39
jack_tux commentedHi klausi
I was wondering if you have had chance to review this?
Have a good Christmas
Comment #40
jack_tux commentedHi
I am looking at trying to get this module released as son as I can. Would someone please be able to review this please.
I am able to help in any way possible
Thanks for your time
Comment #41
jthorson commentedjack_tux,
Just a heads up ... while it's not a hard-and-fast rule, it is common practice for reviewers to go to the bottom of the queue (i.e. the application which has gone the longest wait without an update) when picking up a new application.
With this in mind, bumping your own issue can actually result in you having to wait longer for reviews; as it brings your issue back to the 'top' of the queue instead of letting it sift down to the bottom (where many reviewers look first for new projects).
Comment #42
themebrain commentedThere are still files other than README.txt in the master branch, make sure to remove them. See also step 5 in http://drupal.org/node/1127732
Review of the 6.x-2.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.
Source: http://ventral.org/pareview - PAReview.sh online service
Manual review:
- Add translation function for the title & description, for example:
- Change to use the @ placeholder for t function
Comment #43
jack_tux commentedHave fixed all the errors
Not sure what you mean about:
Comment #44
jthorson commentedI'm afraid you may have got some misleading advice regarding use of t().
t() should not be used on the 'title' and 'description' parameters within any function implementing hook_menu(), as these will automatically be run through t() by the menu system. However, t() should be left in place for 'title' and 'description' on $form items.
Because $logbook['name'] is a dynamic value which will differ for every logbook created, it is impossible for a translator to anticipate every possible value and provide a translation for it. Because of this, we want to let the translation system know that $logbook['name'] is a placeholder, and only translate the 'permissions' portion of the string. This is done with the following syntax:
'#title' => t("@logbook Permissions", array("@logbook" => $logbook['name'])),The '@' symbol tells t() to run the value through check_plain() for sanitization ... we could also have used '!' to insert the variable as-is (assuming you've sanitized the value elsewhere), or '%' to indicate the variable should be html-escaped and processed with theme('placeholders', ...).
A full description of this pattern can be found at http://api.drupal.org/api/drupal/includes!common.inc/function/t/6
Comment #45
jack_tux commentedThanks for that, makes sense
I think I have done all the changes..
Comment #46
jthorson commented359 $page = "";... Even if $page contained anything, it would be wiped out on by line 360.379 function logbook_form_alter(&$form, &$form_state, $form_id), hook_form_FORM_ID_alter() may be a better choice. Also, can you get your content_type from an arg() parameter instead of $_GET?451 db_query("UPDATE {permission} SET perm = CONCAT(perm,', ','%s') WHERE rid = %d", $permission, $rid);... just to make sure that you aren't somehow passed something like 'administer nodes'. Maybe redundant, but then again, I'm the paranoid type. :)Comment #47
jack_tux commentedYes I would say you are paranoid, but that is not a bad thing.
I have done the changes and fixed up some of the security issues.
Thanks
Comment #48
prashantgoel commentedReview of the 6.x-2.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.
Source: http://ventral.org/pareview - PAReview.sh online service
Comment #49
jack_tux commentedIt's funny how I did all this and there where no errors and now there are.
Anyway have fixed them, ready for review.
Comment #50
jack_tux commentedHave only done code sniffer reviews, but I hope it saves someone else some work.
Comment #51
jack_tux commentedHave added a D7 branch.
Please use the 6.x-2.x version
git clone --branch 6.x-2.x http://git.drupal.org/sandbox/jack_tux/1155956.git logbookComment #52
klausiRemoving review bonus tag, you have not done any manual review as required in #1410826: [META] Review bonus, you just posted the output of an automated review tool.
Comment #53
patrickd commentedYour project page is not very detailed, please have a look at the tips for a great project page, you may also use HTML-tags for better structure. Same with your readme, you may have a look at the common styles for readme's (see guidelines for in-project documentation.)
(mostly 7.x-1.x but should also apply to 6.x-1.x)
package = OtherNot necessary, if you provide no package information it'll be "Other" anywayt($perm)- never do this, it won't work properly anyway as only t('strings') (NOT t($variables)) will be detected and can be translated by the translation system on localize.drupal.org.'false', '4': Have a boolean? - make it a boolean 'false' -> FALSE ;; Have an integer? use it as integer '4' -> 4check_plain('item')there is no need to sanitize hardcoded strings - you have to filter all user input not static stuff (please have a look at writing secure code chapter in documentation)hook_form_alter()just for altering one form, that's unnecessary overhead - whenever possible use hook_form_FORM_ID_alter()$form['submission']['body_label']['#default_value'] = 'Description';you should keep t('Description') translatable hereAfter I installed your module and goto logbook/add it says "Select which type of Logbook Entry you would like to make" - but I haven't created any yet, you should tell me to create a logbook type first and a proper link.
If no logbook was created yet, I get an empty table - why don't you provide a proper message like "No logbook type created yet. Create one now (link)" using the '#empty' property of theme_table ?
I also get
Warning: Invalid argument supplied for foreach() in element_children() (line 6282 of /home/patrickd/www/drupal-7-test/includes/common.inc).because of your theming function (theme_logbook_settings_form()) see dblog.Your printing out the operations without any separation and it'll look like "EditManage FieldsDelete".
Use something like
here instead. (see theme_table documentation)
The security issue mentioned in point 9. is actually not possible, because machine readable names can't contain any harmful stuff - but by your "validation" you make it possible. In _logbook_validate_new() you rewrite the module's machine name with 'logbook' + human readable name! use the machine readable name here properly, so this isn't a security issue anylonger.
Comment #54
klausiClosing due to lack of activity. Feel free to reopen if you are still working on this application.
Comment #54.0
klausiCode Review