Hello, i am new to Drupal, and i've been trying to make a web page using Panel and Views modules. I have problem with access control. I want authenticated and anonymous users to see all the data, but i can't do it. Only when i put in access control that they can ADMINISTER NODES they are able to see all the data. If anyone can help me to solve this problem? Thanks

Comments

agentrickard’s picture

This is node data, correct? And users can 'access content'>

It may be that your {node_access} table is corrupt. This is fairly common.

If you are _not_ using any access control modules, take a look at the {node_access} table. It should contain exactly one row:

nid  gid  realm  grant_view  grant_edit  grant_delete
0     0    all       1                 0                0

If this row does _not_ exist, only users with the 'administer nodes' permission can view content.

--
http://ken.blufftontoday.com/
http://new.savannahnow.com/user/2
Search first, ask good questions later.

ilijapasoski’s picture

Thanks a lot for the answer. Sorry, i don't understand what do u mean by question "This is node data".

My idea is for everyone to see all the content as i said, and i am not using any access control modules.

I was looking into directory modules/node, file node.module, and the only code with the row that you wrote was this, i don't know if that is the place where i should look???

if ($grant['grant_view'] || $grant['grant_update'] || $grant['grant_delete']) {
        db_query("INSERT INTO {node_access} (nid, realm, gid, grant_view, grant_update, grant_delete) VALUES (%d, '%s', %d, %d, %d, %d)", $node->nid, $grant['realm'], $grant['gid'], $grant['grant_view'], $grant['grant_update'], $grant['grant_delete']);
      }
    }
  }
}

/**
 * Rebuild the node access database. This is occasionally needed by modules
 * that make system-wide changes to access levels.
 */
function node_access_rebuild() {
  db_query("DELETE FROM {node_access}");
  // only recalculate if site is using a node_access module
  if (count(module_implements('node_grants'))) {
    // If not in 'safe mode', increase the maximum execution time:
    if (!ini_get('safe_mode')) {
      set_time_limit(240);
    }
    $result = db_query("SELECT nid FROM {node}");
    while ($node = db_fetch_object($result)) {
      node_access_acquire_grants(node_load($node->nid));
    }
  }
  else {
    // not using any node_access modules. add the default grant.
    db_query("INSERT INTO {node_access} VALUES (0, 0, 'all', 1, 0, 0)");
  }
  cache_clear_all(); 
agentrickard’s picture

OK. In Drupal terms, node == content. If you post a page, it is node/XXX (this Drupal.org page, for example, is node 197878).

As for the {node_access} table, I mean "does it exist in your database."

We don't need to be looking through code. I suspect you have a minor database issue.

Do you have access to your database tables? Look in the {node_access} table. It must have the row that I mentioned. If it doesn't, run the query:

INSERT INTO node_access VALUES (0, 0, 'all', 1, 0, 0);

if you are using table prefixing, you will need to change the tablename as needed.

--
http://ken.blufftontoday.com/
http://new.savannahnow.com/user/2
Search first, ask good questions later.

ilijapasoski’s picture

Sorry, didn't understand you the first time, now i do. Yeah, i opened a database, found a table {node_access}, and there is the same row that u mentioned, but the values are slightly different.
This is what i get:

nid gid realm grant_view grant_update grant_delete
 3   0     all        1               0                  0

Is that ok, or i should still Insert the line that you wrote into the table of database?
Thanks again!

agentrickard’s picture

OK. Now we are making progress. That line means:

"Show node 3 and only node 3 to all users."

Something in your installation changed the default node access record and is denying access to most of your content. Perhaps you enabled a module such as OG?

Run this SQL and your site will go back to normal:

UPDATE node_access SET nid = 0 WHERE nid = 3;

If you are interested in the technical details of why this happens, see http://api.drupal.org/api/function/node_access/5 and http://api.drupal.org/api/group/node_access/5.

--
http://ken.blufftontoday.com/
http://new.savannahnow.com/user/2
Search first, ask good questions later.

ilijapasoski’s picture

IT WORKS!!!!
Thanks a lot really, i would have never fixed this problem on my own with this much knowledge of Drupal!!!

agentrickard’s picture

If it makes you feel any better, this issue pops up quite frequently and confuses lots of people.

If your content ever 'disappears' check your node access table.

--
http://ken.blufftontoday.com/
http://new.savannahnow.com/user/2
Search first, ask good questions later.