/[drupal]/contributions/modules/nodeaccess/nodeaccess.module
ViewVC logotype

Diff of /contributions/modules/nodeaccess/nodeaccess.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.4.2.7.2.7, Mon Apr 30 19:35:18 2007 UTC revision 1.4.2.7.2.8, Fri Jun 8 16:24:51 2007 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: nodeaccess.module,v 1.4.2.7.2.6 2007/04/27 18:47:54 debtman7 Exp $  // $Id: nodeaccess.module,v 1.4.2.7.2.7 2007/04/30 19:35:18 debtman7 Exp $
3    
4  /**  /**
5   * Implementation of hook_help().   * Implementation of hook_help().
# Line 298  function nodeaccess_node_grants($user, $ Line 298  function nodeaccess_node_grants($user, $
298  }  }
299    
300  function nodeaccess_nodeapi(&$node, $op) {  function nodeaccess_nodeapi(&$node, $op) {
   global $user;  
   
301    switch ($op) {    switch ($op) {
     case 'insert':  
     $grants = $user->nodeaccess_defaults ? $user->nodeaccess_defaults : variable_get('nodeaccess_'. $node->type, array());  
   
     // add author grants  
     // this is duplicated below in nodeaccess_node_access_records, probably should fix that huh  
     $author_prefs = variable_get('nodeaccess_authors', array());  
     $agrant = $author_prefs[$node->type];  
     if ($agrant['grant_view'] || $agrant['grant_update'] || $agrant['grant_delete']) {  
       if (variable_get('nodeaccess-priority', 0)) {  
         $priority = 1;  
       }  
       else {  
         $priority = 0;  
       }  
       $grants[] = array(  
         'realm' => 'nodeaccess_author',  
         'gid' => $node->uid,  
         'grant_view' => $agrant['grant_view'],  
         'grant_update' => $agrant['grant_update'],  
         'grant_delete' => $agrant['grant_delete'],  
         'priority' => $priority  
       );  
     }  
   
     node_access_write_grants($node, $grants, 'nodeaccess_rid');  
     break;  
302    case 'delete':    case 'delete':
303      db_query('DELETE FROM {nodeaccess} WHERE nid=%d', $node->nid);      db_query('DELETE FROM {nodeaccess} WHERE nid=%d', $node->nid);
304      break;      break;
# Line 470  function nodeaccess_node_access_records( Line 442  function nodeaccess_node_access_records(
442    $result = db_query("SELECT nid, gid, realm, grant_view, grant_update, grant_delete FROM {nodeaccess} where nid = %d", $node->nid);    $result = db_query("SELECT nid, gid, realm, grant_view, grant_update, grant_delete FROM {nodeaccess} where nid = %d", $node->nid);
443    if (db_num_rows($result) < 1) {    if (db_num_rows($result) < 1) {
444      $grants = $default;      $grants = $default;
445        foreach ($grants as $id => $grant) {
446          $grants[$id]['priority'] = $priority;
447        }
448    }    }
449    else {    else {
450      // this node has a custom access set apart from the defaults, so return that      // this node has a custom access set apart from the defaults, so return that
# Line 544  function nodeaccess_node_type($op, $info Line 519  function nodeaccess_node_type($op, $info
519        break;        break;
520    }    }
521  }  }
522    
523  ?>  ?>

Legend:
Removed from v.1.4.2.7.2.7  
changed lines
  Added in v.1.4.2.7.2.8

  ViewVC Help
Powered by ViewVC 1.1.2