I was needing integration with the token module so I could automatically email the node password to specified users. Here it is if it's useful for anyone else.

Here's what I came up with:

nodeaccess_password.token.inc

<?php

function nodeaccess_password_token_list($type = 'all') {
  $tokens = array();
  if ($type == 'node' || $type == 'all') {
    $tokens['node']['nodeaccess-password']=t('The Node Access Passwords.');
    return $tokens;
  }
}

function nodeaccess_password_token_values($type, $object = NULL, $options = array()) {
  $values = array();
  switch ($type) {
    case 'node':
                $node = $object;
                $thenode = node_load($node->nid);
                foreach ($thenode->nodeaccess_password as $realm => $password) {
                        $values['nodeaccess-password'] .= $realm . " password : " . $password . "\n";
                }
      break;
  }
  return $values;
}

added to nodeaccess_password.module:

/**
 * Implementation of hook_init().
 */

function nodeaccess_password_init() {
  if (module_exists('token') && !function_exists('nodeaccess_password_token_values')) {
    module_load_include('inc', 'nodeaccess_password', 'nodeaccess_password.token');
  }
}

Comments

danielb’s picture

Awesome dude, I've never integrated with token before, so I don't really understand this. Are those 2 functions some sort of token hooks? If so we probably don't need the conditional init stuff to add them in.

danielb’s picture

Status: Active » Postponed (maintainer needs more info)

I'm concerned about the security issue of having a token available that shows you the passwords of the node, and all at once? Can any member with access to tokens use these tokens to discover a password they shouldn't?

danielb’s picture

Status: Postponed (maintainer needs more info) » Closed (won't fix)

Unless someone can address the security concerns I don't think this is a viable addition to the module.