? .svn
Index: README.txt
===================================================================
RCS file: /cvs/drupal/contributions/modules/pcapbt/README.txt,v
retrieving revision 1.2
diff -u -p -r1.2 README.txt
--- README.txt	6 Nov 2009 15:07:26 -0000	1.2
+++ README.txt	9 Nov 2009 16:52:24 -0000
@@ -3,7 +3,7 @@ Introduction
 
 The Premium Content Access Permissions By Term module allows access to content to be restricted to certain roles by taxonomy term and Drupal role permissions and supports multiple access tiers.
 
-It does not use the node_access table.  It integrates with views via it's use of taxonomy terms.  It is similar but different to the Taxonomy Access Control, TAC Lite, Restricted content and Premium modules.
+It does not use the node_access table.  It integrates with views via its use of taxonomy terms.  It is similar but different to the Taxonomy Access Control, TAC Lite, Restricted content and Premium modules.
 
 When access is denied to a content item it supports redirecting the user to another path, or giving them the access denied page.  Support for more behaviors can be added reasonably easily.
 
@@ -31,7 +31,7 @@ Installation instructions
           ),
         );
 
-  6. Change 456 and 789 to the term IDs for the access level terms you created.  Change 'user/login' and 'node/1' to the Drupal system paths that user's should be redirected to when they need to upgrade their account.  If you don't configure any settings for a term, then it will simply return 403 access denied.  Currently only the 'redirect' behavior is supported, more behaviors can be added in the module, such as 'teaser', 'callback function', 'view', 'panel'.
+  6. Change 456 and 789 to the term IDs for the access level terms you created.  Change 'user/login' and 'node/1' to the Drupal system paths that users should be redirected to when they need to upgrade their account.  If you don't configure any settings for a term, then it will simply return 403 access denied.  Currently only the 'redirect' behavior is supported, more behaviors can be added in the module, such as 'teaser', 'callback function', 'view', 'panel'.
   7. On the permissions page you can now set access permissions for each role and term you created.
 
 Important Note
Index: pcapbt.module
===================================================================
RCS file: /cvs/drupal/contributions/modules/pcapbt/pcapbt.module,v
retrieving revision 1.1
diff -u -p -r1.1 pcapbt.module
--- pcapbt.module	6 Nov 2009 14:33:07 -0000	1.1
+++ pcapbt.module	9 Nov 2009 16:52:24 -0000
@@ -53,42 +53,48 @@ function pcapbt_menu($may_cache) {
  * Determines if a user can access a node or not.
  *
  * @param $node Drupal node ID or object.
- * @param $account Drupal user object to check access for (or null for $GLOBALS['user'])
+ * @param $account Drupal user object to check access for (or null for current user)
+ * @return boolean TRUE if user can access the node, FALSE if not
  */
 function pcapbt_user_can_access_node($node, $account = NULL) {
   if (is_numeric($node)) {
     $node = node_load($node);
   }
 
-  if (!$account) {
-    $account = &$GLOBALS['user'];
+  // First check whether there is any access level restriction for this node type.
+  $access_term = pcapbt_get_term($node);
+  if (!$access_term) {
+    // If no access level restriction term was set, allow access.
+    return TRUE;
   }
 
-  return user_access(pcapbt_permission_string(pcapbt_get_term($node)));
+  return user_access(pcapbt_permission_string($access_term), $account);
 }
 
 /**
  * Creates a string for the permission for a term.
  *
- * @todo Because it uses term name instead of term ID, permissions will need restoring if the term name ever changes.  Find a way to modify the permissions page so that we can use term ID in the permission string and term name on permissions page.
+ * @todo Because it uses term name instead of term ID, permissions will need restoring if the term name ever changes.  Use form_alter() to modify the permissions page so that we can use term ID in the permission string and term name on permissions page.
  *
  * @param $term Drupal term object to return the permission string for.
+ * @return String.
  */
 function pcapbt_permission_string($term) {
-  return "can access {$term->name} content";
+  return "access {$term->name} content";
 }
 
 /**
- * Get's the access level term from the node.  Assumes there is only one term.
+ * Gets the access level term from the node.  Assumes there is only one term in the access level vocabulary on this node.
  *
  * @todo Check that the vocabulary is not multiple, nor hierarchical.
  *
  * @param $node Drupal node object.
+ * @return Drupal term object, or NULL if pcapbt_vocabulary_id variable is not set, or if node has no terms in that vocabulary.
  */
 function pcapbt_get_term($node) {
   $vid = variable_get('pcapbt_vocabulary_id', false);
   if (!$vid) {
-    return FALSE;
+    return;
   }
 
   foreach ($node->taxonomy as $term) {
@@ -108,7 +114,7 @@ function pcapbt_access_denied($node) {
   $actions = variable_get('pcapbt_actions', false);
   $term = pcapbt_get_term($node);
 
-  if ($node and $actions and $term and isset($actions[$term->tid])) {
+  if ($actions and $term and isset($actions[$term->tid])) {
     $action = $actions[$term->tid];
     switch ($action['behavior']) {
       case 'redirect':
@@ -118,6 +124,6 @@ function pcapbt_access_denied($node) {
     }
   }
 
-  // If the action is not supported or not defined or there were other problems, fallback on denying access.
+  // If the action is not supported or not defined or there were other problems, fallback on Drupal's 403 Access Denied page.
   drupal_access_denied();
 }
