Closed (won't fix)
Project:
Node access password
Version:
6.x-2.1
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
9 Sep 2009 at 16:04 UTC
Updated:
1 Feb 2010 at 02:40 UTC
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
Comment #1
danielb commentedAwesome 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.
Comment #2
danielb commentedI'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?
Comment #3
danielb commentedUnless someone can address the security concerns I don't think this is a viable addition to the module.