function user_external_invite_tokens in User External Invite 7
Same name and namespace in other branches
- 8 user_external_invite.tokens.inc \user_external_invite_tokens()
- 7.2 user_external_invite.module \user_external_invite_tokens()
- 2.0.x user_external_invite.tokens.inc \user_external_invite_tokens()
- 1.0.x user_external_invite.module \user_external_invite_tokens()
Implements hook_tokens().
File
- ./
user_external_invite.module, line 828 - Invites a user to site when connecting via external protocol e.g. LDAP.
Code
function user_external_invite_tokens($type, $tokens, array $data = array(), array $options = array()) {
$replacements = array();
if ($type == 'user_external_invite') {
foreach ($tokens as $name => $original) {
switch ($name) {
case 'invite_role':
$name = _user_external_invite_role_name_from_rid($data['ext-invite']->rid);
$replacements[$original] = $name;
break;
}
switch ($name) {
case 'invite_link':
$hash = _user_external_invite_calculate_hash($data['ext-invite']->rid, $data['ext-invite']->mail, $data['ext-invite']->expire);
$link = url('user-external/accept-invite', array(
'query' => array(
'key' => $hash,
'mail' => $data['ext-invite']->mail,
),
'absolute' => TRUE,
));
$replacements[$original] = $link;
break;
case 'invited_email':
$replacements[$original] = $data['ext-invite']->mail;
break;
case 'invited_emails':
$replacements[$original] = _user_external_invite_load_related_invites($data['ext-invite']);
break;
case 'invite_custom':
$replacements[$original] = $data['ext-invite']->message;
break;
case 'invite_expiration':
$replacements[$original] = date('F j, Y g:i', $data['ext-invite']->expire) . ' ' . date_default_timezone_get();
break;
}
}
}
return $replacements;
}