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

Diff of /contributions/modules/url_access/url_access.module

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

revision 1.1.2.1, Mon Dec 10 20:04:10 2007 UTC revision 1.1.2.2, Wed Jun 11 19:08:38 2008 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: url_access.module,v 1.1 2007/08/29 15:05:26 deviantintegral Exp $  // $Id: url_access.module,v 1.1.2.1 2007/12/10 20:04:10 deviantintegral Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 7  Line 7 
7   */   */
8    
9  /**  /**
10   * Implementation of hook_init   * Implementation of hook_menu
11     * Moved from hook_init as user_access isn't available if caching is enabled.
12   */   */
13  function url_access_init() {  function url_access_menu($may_cache) {
14    global $user;    if (!$may_cache) {
15        global $user;
   // Node Administrators can always view nodes  
   if(user_access('administer nodes')) return;  
   
   // If we aren't on a node, return  
   if (arg(0) != 'node') return;  
16    
17    $nid= arg(1);      // Node Administrators can always view nodes
18    if( ! is_numeric( $nid)) return;      if(user_access('administer nodes')) return;
19    
20    $node_info = db_fetch_array(db_query("SELECT n.uid, u.uuid FROM {url_access} u INNER JOIN {node} n ON n.nid=u.nid WHERE u.nid=%d", $nid));      // If we aren't on a node, return
21        if (arg(0) != 'node') return;
22    
23    // Let the author have access      $nid= arg(1);
24    if($user->uid == $node_info['uid']) return;      if( ! is_numeric( $nid)) return;
25    
26    // There's no UUID in the database, so there's nothing to block      $node_info = db_fetch_array(db_query("SELECT n.uid, u.uuid FROM {url_access} u INNER JOIN {node} n ON n.nid=u.nid WHERE u.nid=%d", $nid));
   if (!$node_info['uuid']) return;  
27    
28    $url = explode('/', trim(request_uri(), '/'));      // Let the author have access
29    $url[0]= str_replace( '?q=', '', $url[0]);      if($user->uid == $node_info['uid']) return;
30    
31    if($url[0] == 'protected') {      // There's no UUID in the database, so there's nothing to block
32      $url_uuid = $url[1];      if (!$node_info['uuid']) return;
33      if($url_uuid == $node_info['uuid']) {  
34        return;      $url = explode('/', trim(request_uri(), '/'));
35        $url[0]= str_replace( '?q=', '', $url[0]);
36    
37        if($url[0] == 'protected') {
38          $url_uuid = $url[1];
39          if($url_uuid == $node_info['uuid']) {
40            return;
41          }
42      }      }
43        drupal_access_denied();
44        exit;
45    }    }
   drupal_access_denied();  
   exit;  
46  }  }
47    
48  /**  /**

Legend:
Removed from v.1.1.2.1  
changed lines
  Added in v.1.1.2.2

  ViewVC Help
Powered by ViewVC 1.1.2