Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I have set up a content type, the nodes of which I would like to protect.
I am trying to use the option of "A default (global) password for nodes of this type ".
This does not seem to protect the nodes, and if I add in protection when creating a new node, it seeks a separate password.
What am I doing wrong?
Comment | File | Size | Author |
---|---|---|---|
#7 | per_content_type_not_working-2171177-7.patch | 6.14 KB | Grimreaper |
#3 | per_content_type_not_working-2171177-3.patch | 8.14 KB | Grimreaper |
Comments
Comment #1
GrimreaperHello,
Did you have read the documentation before ?
What do you mean by "this does not seem to protect the node" ?
Did you have tested with another browser ? Checked the permissions ?
Comment #2
deepsoulstarfish CreditAttribution: deepsoulstarfish commentedThanks for responding so quickly. Yes I checked in another browser and checked permissions.
I read the doc at http://www.m2osw.com/doc-protected-node-node-type which says:
I have followed this procedure, but this node-type global password protection does not seem to function. Maybe I am misunderstanding your documentation.
Protection of nodes is working normally for other nodes. And I can protect a node individually of the new content type by specifying a password for that node. But the "default password" function is not happening.
Am I going wrong somewhere?
Comment #3
GrimreaperOk, not a problem of documentation, a problem of code, there was nothing relative to the per content type password, it exists but was not used.
With this patch, if a content type password exists, the password is no more mandatory on the node form.
And on the password page, it checks first if there is content type password and if it matches.
I want to make refactoring on this module, but i'm waiting for my previous patches to be reviewed.
Thanks for the review.
Comment #4
deepsoulstarfish CreditAttribution: deepsoulstarfish commentedThank you for such a quick solution!
This works. I have set the content type to always protected. New nodes do not require a password to be added, the global password suffices.
Comment #5
izus CreditAttribution: izus commentedThanks for the patch,
The patch is working fine for me and corrects the bug.
Here is my code review :
this doesn't seem to be used
can you please delete this too as it doesn't seem to be used at all
Please don't trust what is in 'input' key, but what is in 'values' key.
$form_state['values']['protected_node_nid'] is used in the line above to define $nid. Please define $protected_node_nid before $nid, and make use of it all over this function.
Can you please delete the Readme in the patch as it is already commited.
Can you please also warn the user that changing the password policy for content types will not have effect on existing protected nodes of that type. (Test it please and add the warning if needed in the content type setting description of protected node)
I saw some ugly code in that function logic making $nid = 1 instead of defining a flag...this is surely something to clean up in the future. i know it's not this issue concern, i'm just sharing my thoughts :)
Comment #6
izus CreditAttribution: izus commentedComment #7
Grimreaper1 : sorry, it was for the dpm
2 : that was already there, I didn't see it was not used. removed now.
3 : done
Readme : sorry, it was there for the issue of the readme (not commit in local) and it was taken in the patch.
$nid / $protected_node_nid : now it uses $protected_node_nid in the function instead of $form_state... etc, but I keep $nid and $protected_node_nid, because I saw something (I don't remember now) when making the patch. Something strange about how the feature was thought. I think it will be cleaned in a refactoring issue.
"
Can you please also warn the user that changing the password policy for content types will not have effect on existing protected nodes of that type. (Test it please and add the warning if needed in the content type setting description of protected node)
"
I test, it's ok :
you protect a node, good
you protect with content type password another node, good
you protect node 2 with it's own password, accessible with the two password
and node 1 also accessible with content type password.
So no need of warning ?
ugly code : yeah I know, and my patch is a quick and dirty patch, I know it, but I want to fix the issues so you can make a tag so I can work on the dev version to make refactoring and cleaning to provide a stable release.
Comment #8
izus CreditAttribution: izus commentedThis is merged now.
Thank you all !