--- d:\Ken's Documents\Web Stuff\cck\content.module 2006-05-22 02:01:45.000000000 +0100 +++ modules\cck\content.module 2006-06-11 18:42:21.218750000 +0100 @@ -38,7 +38,10 @@ function content_perm() { $perms = array('administer content types'); foreach (content_types() as $name => $type) { $perms[] = 'create '. $name .' content'; + $perms[] = 'view '. $name .' content'; $perms[] = 'edit own '. $name .' content'; + $perms[] = 'edit any '. $name .' content'; + $perms[] = 'delete '. $name .' content'; } return $perms; } @@ -198,10 +201,45 @@ function content_access($op, $node) { return user_access('create '. $type .' content'); } - if ($op == 'update' || $op == 'delete') { + if ($op == 'view') { + return user_access('view '. $type .' content'); + } + + if ($op == 'update') { if (user_access('edit own '. $type .' content') && ($user->uid == $node->uid)) { return TRUE; } + elseif (user_access('edit all '. $type .' content')) { + return TRUE; + } + } + + if ($op == 'delete') { + if (user_access('delete '. $type .' content')) { + return user_access('delete '. $type .' content'); + } + } +} + +/** + * Implementation of hook_db_rewrite_sql + */ +function content_db_rewrite_sql($query, $primary_table, $primary_field, $args) { + global $user; + switch ($primary_field) { + case 'nid': + if ($user->uid != 1) { + $return = array(); + $where = array("n.type <> ''"); + foreach (content_types() as $name => $type) { + if (!user_access('view '. $name .' content')) { + $where[] = "n.type <> '$name'"; + } + } + $return['where'] = join(' AND ', $where); + return $return; + } + break; } }