Hello,

I love this tool but maybe you could make it it saves default to view by all and then deselect the people instead of not enabling any by default?

Second, when one of my admins enables an option, it wont save the new permissions while if I do it it will.

Comments

degerrit’s picture

First off, I'm not a NPBR developer...
As for your first problem, normally these permissions should be configured in the http://{site}/admin/settings/content-types/ screen for the content type you need.

However, this seems not to have any effect in 4.7 - on my site users can create nodes which are only editable/viewable by themselves.

Developers:
Here's what I get for a new node:
mysql> select * from node_access where nid=21039;
+-------+-----+--------------------------+------------+--------------+--------------+
| nid | gid | realm | grant_view | grant_update | grant_delete |
+-------+-----+--------------------------+------------+--------------+--------------+
| 21039 | 1 | node_privacy_byrole_role | 0 | 0 | 0 |
| 21039 | 1 | node_privacy_byrole_user | 1 | 0 | 0 |
| 21039 | 2 | node_privacy_byrole_role | 0 | 0 | 0 |
| 21039 | 3 | node_privacy_byrole_role | 0 | 0 | 0 |
| 21039 | 4 | node_privacy_byrole_role | 0 | 0 | 0 |
| 21039 | 5 | node_privacy_byrole_role | 0 | 0 | 0 |
| 21039 | 6 | node_privacy_byrole_role | 0 | 0 | 0 |
+-------+-----+--------------------------+------------+--------------+--------------+

whereas I configured things so authorized users should be able to view as well:
| 21039 | 2 | node_privacy_byrole_role | 1 | 0 | 0 |

A bug in _node_privacy_byrole_set_defaults() ?

degerrit’s picture

I did some poking around and printing out variables, especially $node->node_privacy_byrole_forview_2 which in my case is the problematic one which is never saved.

I see the problem occuring in node_privacy_byrole_nodeapi() - the default node permissions are set correctly earlier on (in case 'validate' for example) but at this point they are lost again:

case 'insert':
if ($user_has_meta_perm) {
node_privacy_byrole_save_permissions($node);
}

Why does $node->node_privacy_byrole_forview_2 (and all the other set permissions) disappear at (or before) this point?
Puzzled.

degerrit’s picture

I'm calling it a day....
I don't know if this is the proper solution but this change seems to work for me (I don't understand why it is needed though):

    case 'insert':
      // copied literally from 'validate'
      if (variable_get('node_privacy_byrole_enabled', FALSE)) {
        _node_privacy_byrole_set_defaults($node, !$user_has_meta_perm);
      }
      if ($node->nid && !user_access('administer nodes')) {
        $result = db_query('SELECT uid FROM {node} WHERE nid = %d', $node->nid);
        if ($row = db_fetch_object($result)) {
          $node->uid = $row->uid;
        }
      }
      // end copy

      if ($user_has_meta_perm) {
        node_privacy_byrole_save_permissions($node);
      }
      else {
        _node_privacy_byrole_set_defaults($node, TRUE);
        node_privacy_byrole_save_permissions($node);
      }
      break;

Strangely, 'update' does not need this fix.

jondoesdrupal’s picture

Status: Active » Closed (fixed)

Tidying up old issues. Focus now is on Drupal 5 version of the module. If there is still demand for this to be resolved and it gets resumbitted then I'll look into finding a solution. I believe this 5.x rewrite should have addressed this though.