/[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, Wed Aug 29 15:05:26 2007 UTC revision 1.2, Mon Oct 26 19:29:04 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id:$  // $Id: url_access.module,v 1.1.2.2 2008/06/11 19:08:38 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;
16    // Node Administrators can always view nodes  
17    if(user_access('administer nodes')) return;      // Node Administrators can always view nodes
18        if(user_access('administer nodes')) return;
19    // If we aren't on a node, return  
20    if (arg(0) != 'node') return;      // If we aren't on a node, return
21        if (arg(0) != 'node') return;
22    $node = node_load(arg(1));  
23        $nid= arg(1);
24    // Let the author have access      if( ! is_numeric( $nid)) return;
25    if($user->name == $node->name) return;  
26        $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));
27    // There's no UUID in the database, so there's nothing to block  
28    if (!$node->url_access) return;      // Let the author have access
29        if($user->uid == $node_info['uid']) return;
30    $url = explode('/', trim($_SERVER['REQUEST_URI'], '/'));  
31        // There's no UUID in the database, so there's nothing to block
32    if($url[0] == 'protected') {      if (!$node_info['uuid']) return;
33      $url_uuid = $url[1];  
34      if($url_uuid == $node->url_access) {      $url = explode('/', trim(request_uri(), '/'));
35        return;      $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  
changed lines
  Added in v.1.2

  ViewVC Help
Powered by ViewVC 1.1.2