| 1 |
<?php
|
| 2 |
// $Id: invite_token.inc,v 1.5 2008/09/02 17:02:14 smk Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* Token integration functions for invite module.
|
| 7 |
*/
|
| 8 |
|
| 9 |
/**
|
| 10 |
* Implementation of hook_token_values().
|
| 11 |
*/
|
| 12 |
function invite_token_values($type = 'all', $object = NULL) {
|
| 13 |
$values = array();
|
| 14 |
if ($type == 'invite' && is_object($object)) {
|
| 15 |
$values['inviter'] = check_plain($object->inviter->name);
|
| 16 |
$values['inviter-raw'] = $object->inviter->name;
|
| 17 |
$values['invite-mail'] = $object->email;
|
| 18 |
$values['invite-message'] = check_plain($object->data['message']);
|
| 19 |
$values['invite-message-raw'] = $object->data['message'];
|
| 20 |
$values['join-link'] = url('invite/accept/'. $object->code, array('absolute' => TRUE));
|
| 21 |
}
|
| 22 |
return $values;
|
| 23 |
}
|
| 24 |
|
| 25 |
/**
|
| 26 |
* Implementation of hook_token_list().
|
| 27 |
*/
|
| 28 |
function invite_token_list($type = 'all') {
|
| 29 |
if ($type == 'invite' || $type == 'all') {
|
| 30 |
$tokens['invite']['inviter'] = t('The user name of the inviter.');
|
| 31 |
$tokens['invite']['inviter-raw'] = t('The user name of the inviter. WARNING - raw user input.');
|
| 32 |
$tokens['invite']['invite-mail'] = t('The e-mail address of the invited user.');
|
| 33 |
$tokens['invite']['invite-message'] = t('The personal message for the invitee.');
|
| 34 |
$tokens['invite']['invite-message-raw'] = t('The personal message for the invitee as unfiltered text. WARNING - raw user input.');
|
| 35 |
$tokens['invite']['join-link'] = t('The link to the registration page, including the invitation code.');
|
| 36 |
return $tokens;
|
| 37 |
}
|
| 38 |
}
|
| 39 |
|
| 40 |
/**
|
| 41 |
* For a given context, builds a formatted list of tokens and descriptions
|
| 42 |
* of their replacement values.
|
| 43 |
*
|
| 44 |
* @param type
|
| 45 |
* The token types to display documentation for. Defaults to 'all'.
|
| 46 |
* @param prefix
|
| 47 |
* The prefix your module will use when parsing tokens. Defaults to '['
|
| 48 |
* @param suffix
|
| 49 |
* The suffix your module will use when parsing tokens. Defaults to ']'
|
| 50 |
* @return
|
| 51 |
* An HTML table containing the formatting docs.
|
| 52 |
*/
|
| 53 |
function theme_invite_token_help($type = 'all', $prefix = '[', $suffix = ']') {
|
| 54 |
token_include();
|
| 55 |
|
| 56 |
// @see http://drupal.org/node/127072
|
| 57 |
$full_list = array();
|
| 58 |
foreach ((array)$type as $t) {
|
| 59 |
$full_list = array_merge($full_list, token_get_list($t));
|
| 60 |
}
|
| 61 |
|
| 62 |
$headers = array(t('Token'), t('Replacement value'));
|
| 63 |
$rows = array();
|
| 64 |
foreach ($full_list as $key => $category) {
|
| 65 |
$rows[] = array(array('data' => drupal_ucfirst($key) .' '. t('tokens'), 'class' => 'region', 'colspan' => 2));
|
| 66 |
foreach ($category as $token => $description) {
|
| 67 |
$row = array();
|
| 68 |
$row[] = $prefix . $token . $suffix;
|
| 69 |
$row[] = $description;
|
| 70 |
$rows[] = $row;
|
| 71 |
}
|
| 72 |
}
|
| 73 |
|
| 74 |
$output = theme('table', $headers, $rows, array('class' => 'description'));
|
| 75 |
return $output;
|
| 76 |
}
|
| 77 |
|