Experimental project

This is a sandbox project, which contains experimental code for developer use only.

IP Subscription

Grant anonymous and authenticated users access to content, based on the users IP address.

Version 2 includes Google Analytics integration which requires:

Token
Google Analytics
Google Analytics Reports

NOTE: these modules have their own dependencies. Also the latest stable releases may be quite old, in which case the -dev release is recommended.

Configuring Google Analytics

Custom variables

Slot: 1
Name: ip_sub
Value: [ip_subscription_uid]
Scope: Session

Also file extensions to track may need to be extended.

Anonymous user roles

The key to granting user roles to anonymous users is the permissions cache - this is a cache mapping user ids to permissions. The issue is that we need multiple anonymous users to have individual permissions. So we need to prevent these from being cached.

This can be achieved by modifying the appropriate call to user_access().

--- return user_access($string, $account);
+++ return user_access($string, $account, true);

The 'true' argument resets the cache.

For example, to allow access to CCK fields we need to modify:

/sites/all/modules/cck/modules/content_permissions/content_permissions.module

function content_permissions_field_access($op, $field, $account, $node = NULL) {
  switch ($op) {
    case 'view':
    case 'edit':
      return user_access($op .' '. $field['field_name'], $account, true);
  }
  return TRUE;
}

Use the following GIT command to download the project:

git clone http://git.drupal.org/sandbox/djroshi/1642418.git ip_subscription

Project information

  • Created by djroshi on , updated