Hello,
I have well over a thousand nodes on my installation. I have setup all my defaults as follows:
Anon Users: Deny All by default (only 4 pages or so are actually viewable without logging in)
Auth Users: Blank Everything by default (We have more categorized groups)
Paid Users: View all but NO editing
Site Updaters: View, Update Everything, Delete Permissions, And update roles
SuperUser: Same As above
Is there any way to retroactively go back and set these defaults on all of my current nodes? Or do I have to go one by one on each of these? I previously used Taxonomy Access Module, but that module currently doesn't work with D6, so I moved over to this module.
Thanks,
Ram0135
Comment | File | Size | Author |
---|---|---|---|
#25 | NodePrivacyPerRole.png | 24.42 KB | AlexisWilke |
#7 | rebuild_permissions.patch | 2.7 KB | cYu |
Comments
Comment #1
carnage_ CreditAttribution: carnage_ commentedi believe that going onto administer >> content settings >> post settings and hitting rebuild permissions will apply permissions to nodes based on their defaults.
This is how I've been getting around it on the site I'm building. I don't know how this will work on a live site though, so might be worth testing on a dev copy first.
Comment #2
nicholas.alipaz CreditAttribution: nicholas.alipaz commentedThe rebuild permissions option does not work for forum topics, at least on my site. Anyone have other ideas?
Comment #3
nicholas.alipaz CreditAttribution: nicholas.alipaz commentedWhen looking the table "drup_node_privacy_byrole" I found that about 1000 nodes from before I installed this module had the incorrect permissions applied to them. Rebuilding would not fix the issue.
I ended up just having to write a quick query and run it on the database to fix the issue on my older content. The newer content is getting it's permissions set properly.
Here is one of the queries I ran. I DON'T SUGGEST RUNNING THIS UNLESS YOU KNOW WHAT YOU ARE DOING!
It simply looks at the 'drup_node' table and checks what type it has assigned then sets the permissions in 'drup_node_privacy_byrole'. Of course there are 3 different columns there 'grant_view', 'grant_update', and 'grant_delete' so I had to run the query 3 times for each role and each content type combination I wanted to alter in mass. But it saved me from editing 1000 nodes.
Comment #4
SMonsen CreditAttribution: SMonsen commentedWe have an intranet that has well over 100 posts. I have no idea how to do what nicholas suggested. Is there any other way to update the previous posts?
Comment #5
SMonsen CreditAttribution: SMonsen commentedWe have an intranet that has well over 100 posts. I have no idea how to do what nicholas suggested. Is there any other way to update the previous nodes?
Comment #6
cYu CreditAttribution: cYu commentedThis could be a feature request for Node Privacy By Role to have a utility that restores all existing nodes to the NPBR default permissions or applies default permissions to all existing nodes when it is enabled, but it is by design that Rebuild Permissions does not set all permissions back to defaults.
Rebuild Permissions is important to use if, for instance, you temporarily use any other module which handles node access but then decide to remove it and want to remove all access that it had given. What you won't want in this case, though, is for all non-default NPBR access to be lost.
Comment #7
cYu CreditAttribution: cYu commentedAttached is a patch which adds a checkbox under the 'Rebuild Permissions' button so that you can save a setting which dictates whether or not NPBR permissions will revert to content type defaults or not during a rebuild.
Comment #8
deekayen CreditAttribution: deekayen commentedPatch committed
Comment #10
xarbot CreditAttribution: xarbot commentedSorry but this path don't work for me, I check the button that says When rebuilding permissions, reset the node privacy by role permissions on all nodes to the content type defaults.but it don't do nothing, some suggestion?
Thanks in advanced
Xarbot
Comment #11
deekayen CreditAttribution: deekayen commentedPlease note your Drupal version.
Comment #12
xarbot CreditAttribution: xarbot commentedSorry :P
My Drupal version is 6.10 with npbr last build and with this patch and of course i don't use taxonomy access control ;)
Thanks
Xarbot
Comment #13
cYu CreditAttribution: cYu commentedThis might be a matter of usability. Are you checking the checkbox, saving the settings form, and then clicking Rebuild Permissions? If you check the box and then click Rebuild Permissions it will not work. And when you say "it don't do nothing" what are you expecting to happen that is not happening?
Comment #14
xarbot CreditAttribution: xarbot commentedOk, i don't do it correctly. Now i'm check the checkbox and then save it.
After this i rebuild the permissions and.... the system delete all of the permissions of the nodes! Don't rebuild them in function of the permissions defined in content types!
Thanks in advanced
Xarbot
Comment #15
xarbot CreditAttribution: xarbot commentedI don't know if i explain correctly my problem now....
Thanks
Xarbot
Comment #16
xarbot CreditAttribution: xarbot commentedOk in this function
function node_privacy_byrole_rebuild_submit($form, &$form_state) {
i add this piece of code
$sql = "SELECT * FROM {node}";
$result = db_query($sql);
while ($row = db_fetch_array($result)) {
$default_permsv =NULL;
$default_permse =NULL;
$default_permsd =NULL;
$default_permsv = _node_privacy_byrole_get_default_roles($row["type"], "view");
$default_permse = _node_privacy_byrole_get_default_roles($row["type"], "edit");
$default_permsd = _node_privacy_byrole_get_default_roles($row["type"], "delete");
$sql2 = "SELECT * FROM {role}";
$result2 = db_query($sql2);
while ($row2 = db_fetch_array($result2)) {
if (in_array ($row2["rid"], $default_permsv)){
$view=1;
}else{
$view=0;
}
if (in_array ($row2["rid"], $default_permse)){
$edit=1;
}else{
$edit=0;
}
if (in_array ($row2["rid"], $default_permsd)){
$delete=1;
}else{
$delete=0;
}
$result3 = db_query("INSERT INTO {node_privacy_byrole} (nid,gid,realm,grant_view,grant_update,grant_delete) VALUES
('".$row["nid"]."','".$row2["rid"]."','node_privacy_byrole','".$view."','".$edit."','".$delete."')");
}
}
after the first line of the function. It's this
db_query('DELETE FROM {node_privacy_byrole}');
probably someone could do a more efficient of code, but i'm not an expert of php :)
and i don't know how can i do a patch, so if someone would like to do....
Bye
Xarbot
Comment #17
deekayen CreditAttribution: deekayen commentedneeds code style and sql string replacement
http://drupal.org/patch
http://drupal.org/coding-standards
http://api.drupal.org/api/function/db_query/6
Comment #18
xarbot CreditAttribution: xarbot commentedOk, i do only something to resolve my problem, and if someone could use this code then .... :)
Thanks
Xarbot
Comment #19
cYu CreditAttribution: cYu commentedXarbot, the code you are writing looks like it intends to delete node_privacy_byrole permissions entirely, deleting both the defaults for the content type as well as the permissions applied to individual nodes. If you'd like to do that, you can disable and uninstall the module.
Am I understanding your intentions correctly or is there something else you are trying to do?
Comment #20
xarbot CreditAttribution: xarbot commentedno, the patch submited in this thread delete all the node_privacy_byrole table (see the function node_privacy_byrole_rebuild_submit in the patch).
The only thing i do is rebuild all the table node_privacy_byrole inserting the default values you submit in the content type. I don't know if i explain, my english is not very good :XP
Thanks
Xarbot
Comment #21
xarbot CreditAttribution: xarbot commentedI have a bit of time, so i try to explain the code
I said before. The code could be better, and if someone wants to make a patch based in that, i don't have any problem!
Thanks
Xarbot
Comment #22
rimu CreditAttribution: rimu commentedThank you so much for this feature :) I used to have many many old nodes hidden through my wiki that anonymous users could edit... With predictable problems. No more! :D
Comment #23
ypfuquen CreditAttribution: ypfuquen commentedHey all,
so is there a patch for this problem??
I'm no sure that wnat I want is to restore my permission to default..
My problem : I create some pages.. then I update my permissions, create roles and give them permissions.. Then i create more pages... When my users log , all permission to the recent pages ( the ones I create after configuring permissions ) are working fine.. but old pages( my initial content) seems not to be taken any change at all.. those pages only my admin can edit them..
How do I apply permissions to my old content??
Helpppp...
Comment #24
AlexisWilke CreditAttribution: AlexisWilke commentedHi guys,
Note that in the patch, the
npbr_default_permissions
variable is handled in the form. It is never checked to know whether the permissions should be rebuilt.Also as pointed out the permissions were not rebuilt before. They just get deleted. Then when you edit a node it looks like you've got the default permissions, but you actually need to save to really get the permissions in the database.
In other words, thus far this patch was really bad. 8-)
It looks like #21 is close to what would be necessary.
Outside of that, the error that I just mentioned, the defaults not being shown properly exists whenever you
In other words, you get a totally wrong feedback from the module.
Saving the node at that point fixes the problem. But you'll have to do that for all the nodes, I'm afraid...
Thank you.
Alexis
Comment #25
AlexisWilke CreditAttribution: AlexisWilke commentedJust in case, I am attaching an image when what I see (wrong, on the left side) and what I would expect (since that's what it really is, the users in the marketer role cannot see the nodes until I edit + save them all.)
Thank you.
Alexis
Comment #26
1kenthomas CreditAttribution: 1kenthomas commentedHas there been any progress here?
Has this module been duplicated/overlapped by nodeaccess at this point?
Comment #27
AlexisWilke CreditAttribution: AlexisWilke commented1kenthomas,
Looks like someone's working on a 7.x version, but nothing for 6.x... 8-(
Thank you.
Alexis
Comment #28
apprayo CreditAttribution: apprayo commentedIt seems 6.x-1.6 can set default permission on existing nodes, using these steps: set default permission for a content type, then run "rebuild permission".