Storm nodes appear in the #drupal_install#/node page even when user has no permission to view them.

CommentFileSizeAuthor
#7 Screenshot - Mozilla Firefox-1.png57.09 KBcatorghans

Comments

Roberto Gerola’s picture

I see.
The access hook isn't considered on this page.

Roberto Gerola’s picture

Not sure there is a clean way to prevent this.
At now I found this solution :

function stormorganization_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  switch ($op) {
    case 'view':
      global $user;      
      if (!stormorganization_access('view', $node, $user)) {
        $node = NULL;
      }
      break;
  }
}
catorghans’s picture

Doesn't work with me.

The anonymous user has "access content" permission but no permission for any of the storm permission items.
But if I logout and watch the default front page (the same as #drupal_install#/node) I see all created storm nodes as a teaser.

Hans

Roberto Gerola’s picture

And, with this function in storm.module file ?

function storm_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  switch ($op) {
    case 'view':
      global $user;      
      if (!node_access('view', $node, $user)) {
        $node=NULL;
      }
      break;
  }
}
catorghans’s picture

Yes!

stormorganization_nodeapi had no effect, not even for organization nodes, but storm_nodeapi does work for all de storm nodes.

Roberto Gerola’s picture

Status: Active » Fixed
catorghans’s picture

StatusFileSize
new57.09 KB

minor detail: the nodes are not shown, but are occupying some space, even a pager is shown.

Roberto Gerola’s picture

Status: Fixed » Active

Yes, but it's not possible to do something more.
It would be necessary to rewrite the Drupal routine that creates the /node page.

rmiddle’s picture

I haven't had a change to look at the code yet but my guess is if you remove bit for the front page the issue would go away.

thanks
Robert

catorghans’s picture

Roberto is right.

Off course you can uncheck "Promoted to front page" on the storm content types.

Roberto Gerola’s picture

Status: Active » Closed (won't fix)
Roberto Gerola’s picture

I had to remove the nodeapi hook implementantion.
It caused problems with other modules.

I'll figure out a different solution.

Roberto Gerola’s picture

Assigned: Unassigned » Roberto Gerola
Status: Closed (won't fix) » Active

I figured out a way to fix this in the correct way and to work everywhere and also
in conjunction with others node access control systems.

It involves the use only of some sql code, in the hook db_rewrite_sql.

Here there is the idea :

select * from node n
where
(
case n.type
when 'stormproject' then (select if(spr.organization_nid=5 and n.uid=1,0,1) from stormproject spr where spr.vid=n.vid)
else
0
end
)=0

Roberto Gerola’s picture

Status: Active » Fixed

Implemented for MySQL in the version 1.6.

catorghans’s picture

It seems that this solution gives a problem when a view is displayed (5.x-1.11).

In a view the "#prefix#node" is called "node" and not "n".

It doesn't seem right that this db_rewrite_sql hook is used in a "view".

I get then the next warning:
Unknown table 'n' in where clause query: SELECT DISTINCT(node.nid), node.created AS node_created_created FROM ct_node node INNER JOIN ct_node_access na ON na.nid = node.nid WHERE (na.grant_view >= 1 AND ((na.gid = 0 AND na.realm = 'all') OR (na.gid = 0 AND na.realm = 'og_public'))) AND ((case n.type WHEN 'stormexpense' THEN 0 WHEN 'storminvoice' THEN 0 WHEN 'storminvoiceitem' THEN 0 WHEN 'stormknowledgebase' THEN 0 WHEN 'stormnote' THEN 0 WHEN 'stormorganization' THEN 0 WHEN 'stormperson' THEN 0 WHEN 'stormproject' THEN 0 WHEN 'stormtask' THEN 0 WHEN 'stormticket' THEN 0 WHEN 'stormtimetracking' THEN 0 else 1 end)=1)
...

Roberto Gerola’s picture

Status: Fixed » Active

So, the view is using "node" as primary table but is passing "n" as primary table to db_rewrite_sql api.
I'll take a look at node_access system to understand how it is able to correctly use the alias name.

Roberto Gerola’s picture

Version: 6.x-1.x-dev » 5.x-1.11

Just tried with frontpage standard view under D5.
It seems to me to work correctly.

Are you using some custom code ?

catorghans’s picture

nope, a pretty standard view which displays all "blog" nodes as teasers in a "block" in the "content" area on the front page.

Roberto Gerola’s picture

I think I have figured out what was happening.
It should be fixed now in the latest storm.module file in cvs.

Can you test it ? Thanks.

Roberto Gerola’s picture

Status: Active » Fixed
Anonymous’s picture

Status: Fixed » Closed (fixed)

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