Node Access Keys is for Drupal 7.

Node Access Keys helps to grant users temporary view permissions to selected content types on a per user role basis. You can have multiple Access Keys for different content types and user roles.

As an example, this module could be used on a registration site that requires content to be hidden from a non-registrant but visible to users who have registered (not registered through the core user module, I mean register as in submitting a Webform or something). An Access Key could be emailed to them which would grant them view permission to the content types specified. This makes it so users are not required to have individual user accounts.

http://drupal.org/sandbox/danielkorte/1264754

git clone --branch 7.x-1.x http://git.drupal.org/sandbox/danielkorte/1264754.git nodeaccesskeys

Comments

daniel korte’s picture

Issue summary: View changes

Fixed git clone line

daniel korte’s picture

I added a .test file that tests all parts of this module.

klausi’s picture

Status: Needs review » Needs work

* git release branch missing, see http://drupal.org/node/1015226
* remove LICENSE.txt, it is added automatically by drupal.org packaging
* nodeaccesskeys_edit(): doc block @param description indentation is only one space, should be 2. See http://drupal.org/node/1354#functions
* nodeaccesskeys_install(): not need to initialize variables here, variable_get() makes use of default values anyway. Remove the whole function.

Otherwise the code looks very good, seems nearly ready.

daniel korte’s picture

Thank you for your review.

* 7.x-1.x release branch added.
* removed LICENSE.txt
* Fixed @param indentations throughout.
* I'm not sure if I follow, are you suggesting that I set this variable elsewhere? If so, where? Please explain.

daniel korte’s picture

Views integration and settings page added.

daniel korte’s picture

Okay, two things:

I realize variable_get() makes use of default values but my intention is not to get the 'site_403' variable. My intention is to set the 403 page so that my module can present the user with a form granting view access to content (provided that they have the access key) whenever they attempt to view a page that is protected by this module.

Anyways, this module is being used on a live web site rolling out this Monday. I can email someone the development site (with an access key) to see it in use. Just ask.

Sooo.... anyone want to bump me out of sandbox mode??? ;)

daniel korte’s picture

Issue summary: View changes

Fixed git clone line again!

daniel korte’s picture

Status: Needs work » Needs review
patrickd’s picture

Status: Needs review » Needs work

Please fix all code formatting issues, we'll get back to you soon.

Review of the 7.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. Go and review some other project applications, so we can get back to yours sooner.

If you got questions on this, please ask!

daniel korte’s picture

Status: Needs work » Needs review

All code cleaning has been completed.

4 errors remain because the Views api classes don't follow the lowerCamel format.

daniel korte’s picture

Status: Needs review » Fixed

I'm marking this fixed because it is ready to boot.

patrickd’s picture

Status: Fixed » Needs review

There was no manual in-depth review yet.

Please read the documentation about the application workflow: http://drupal.org/node/539608

daniel korte’s picture

Oh shucks. My bad.

misc’s picture

Status: Needs review » Reviewed & tested by the community

Did a manual review of the code, and everything looks okay (as what I know...).
Installed the module, without problems. The setup was easy and the functionality no problem. Thumbs up from here. And a really useful module.

daniel korte’s picture

Yay! Thanks MiSc! Yeah, I couldn't believe that this module didn't exist already.

klausi’s picture

Status: Reviewed & tested by the community » Needs work

manual review:

  • "'access arguments' => array('administer site configuration')": do not use this generic permission, create your own.
  • nodeaccesskeys_menu_local_tasks_alter(): why do you need that function? why can't you use MENU_LOCAL_ACTION on the menu item in hook_menu()?
  • "'#type' => 'hidden',": you should use "value" instead of "hidden" if you do not plan that the user has access to this item. you can also simply store arbitrary variables in $form['#foo'] instead, as long as '#foo' does not conflict with any other internal property of the Form API.
  • "unserialize($record->nodetypes);": instead of serializing yourself you can define your DB field as 'serialize' => TRUE, the the schema API will handle serialization for you.
  • You should mention on the project page that your module works with user sessions, so people running reverse proxies like Varnish for caching might get problems if they cache pages for anonymous users.
  • _nodeaccesskeys_protected_nodes(): you can use array_intersect_keys() then you don't need _nodeaccesskeys_get_role_names().
  • "$types = array_map('filter_xss_admin', $types);": content types and roles are always expected to be plain text, so you should use check_plain() here.
  • "filter_xss_admin($key->accesskey),": same here, shouldn't that be plain text?
  • Why do you have to serialize $_SESSION['nodeaccesskeys_aids']?
  • "$output = '<ul>';": use theme('item_list', ...) instead.

Get a review bonus and we will come back to your application sooner.

daniel korte’s picture

Status: Needs work » Needs review

Thank you klausi! I've made the changes though through my testing it appears that I still have to serialize/unserialize my nodetypes and roles columns even though I've changed the schema to use 'serialize' => TRUE. I'm not sure if I'm missing something but after looking at other modules it appears they also serialize/unserialize when selecting/inserting into the DB...

prashantgoel’s picture

Status: Needs review » Needs work

please visit http://ventral.org/pareview/httpgitdrupalorgsandboxdanielkorte1264754git for the seeing and correcting the list of errors being generated.

patrickd’s picture

Status: Needs work » Needs review

don't set needs work if there are only so few and minor issues found.

daniel korte’s picture

Fixed the issues that I could. The four errors remaining can't be fixed because the function names being overridden are dictated by the Views module.

scot.hubbard’s picture

Hi Daniel,

I have just completed a review of your module and can't find anything major. I can confirm that points raised by klausi have been picked up.

There are no licensing issues as there is no third party code involved.

One suggestion would be to add the configure parameter to your .info file (I know you have a message that appears once the user has enabled the module, but adding the configure link would mean that there is a persisent link to the module's admin page from the admin/modules/list page too).

The module installed and uninstalled cleanly.

Setting to RTBC.

scot.hubbard’s picture

Status: Needs review » Reviewed & tested by the community

Oops - didn't change the status.

daniel korte’s picture

Thanks Scot! I added the configure parameter. I appreciate the suggestion and your review.

patrickd’s picture

Assigned: Unassigned » patrickd
patrickd’s picture

Assigned: patrickd » Unassigned

got to go, will continue later

patrickd’s picture

Issue summary: View changes

Clarified 'registered'

patrickd’s picture

Assigned: Unassigned » patrickd
patrickd’s picture

Assigned: patrickd » Unassigned
Status: Reviewed & tested by the community » Fixed

Please add installation and usage instructions to your project page, also see tips for a great project page.

  1. .install, 66: filter_xss_admin($message): filter_xss() not necessary your just printing out static text, no user values contained - (but better too many filters then too few)
  2. .install: you should set and unset the site_403 variable when enabling/disabling your module as the path you set already won't be reachable after disabling it
  3. views_plugin...inc: return t($this->options['node_type']); don't put variables into t() only strings (t('translate me')) are translatable, also content types are "already translated" as the user enters them
  4. You check_plain() the access key in the node access key list twice, doing it in admin.inc:124 again is not necessary
  5. in drupal7 it's not necessary to check_plain() in #selections, you don't have to check_plain() the content types twice there
  6. $form['accesskey']['#default_value'] = check_plain($record->accesskey) also here's check_plain not necessary - #default_values are check_plain()ed automatically

It seems to me that your often not sure whether you should filter a value or not.
Think about..
1. Does this value come from outside? (User input, Browser data, etc)
-> Yes, save dirty - output with checkplain()
-> No, it's static text in my own source - just print it out
On the other site the are often functions / API's in drupal that already filter for you - therefore you got to pass the raw value to it and eg. the forms api will check_plain() itself.
After some time you will know what to filter or not automatically, until then - find it out by testing:
just replace the variable with eg. xyx"> and search the page dom for xyx
if it was escaped automatically it should be xyx&quot;&gt; and you don't have to care about filtering
otherwise you have to filter it your self

beside that your module looks pretty solid to me!

Thanks for your contribution and 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.

Thanks to the dedicated reviewer(s) as well.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

Added branch to git clone