? .svn
? pcapbt-bugfix-d5.patch
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	7 Nov 2009 02:26:18 -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	7 Nov 2009 02:26:18 -0000
@@ -53,18 +53,31 @@ 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'];
+  $access_term = pcapbt_get_term($node);  // false if pcapbt_vocabulary_id isn't configured 
+  if (!$access_term) {                    // or if node has no terms in that vocab
+    return TRUE;                          // user can access this node
   }
 
-  return user_access(pcapbt_permission_string(pcapbt_get_term($node)));
+/**
+ * for debugging - remove when committing to CVS
+ * 
+  $result = user_access(pcapbt_permission_string($access_term));
+  dpm("pcapbt_permission_string: ".pcapbt_permission_string($access_term));
+  dpm("pcapbt_user_can_access_node - nid $node->nid: ". (string)$result);
+ *
+ */
+
+  return user_access(pcapbt_permission_string($access_term), $account);
 }
 
 /**
@@ -75,15 +88,19 @@ function pcapbt_user_can_access_node($no
  * @param $term Drupal term object to return the permission string for.
  */
 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.
  *
  * @todo Check that the vocabulary is not multiple, nor hierarchical.
  *
  * @param $node Drupal node object.
+ * 
+ * @return boolean FALSE if pcapbt_vocabulary_id variable is not set, or if node has no terms in that vocabulary
+ * @return object $term Taxonomy term object if one is found
+ * 
  */
 function pcapbt_get_term($node) {
   $vid = variable_get('pcapbt_vocabulary_id', false);
@@ -96,6 +113,8 @@ function pcapbt_get_term($node) {
       return $term;
     }
   }
+  
+  return FALSE;   // node has no term in the access vocabulary
 }
 
 /**
@@ -112,7 +131,7 @@ function pcapbt_access_denied($node) {
     $action = $actions[$term->tid];
     switch ($action['behavior']) {
       case 'redirect':
-        drupal_goto($action['path'], 'destination=' . $_GET['q']);
+        drupal_goto($action['path'], 'destination=' . drupal_get_path_alias($_GET['q']));
         break;
     // @todo Add support for more behaviors, e.g. teaser, function callback, not found.
     }
