function _sheetnode_ajax_token in Sheetnode 7.2
Same name and namespace in other branches
- 6 sheetnode.module \_sheetnode_ajax_token()
- 7 sheetnode.module \_sheetnode_ajax_token()
AJAX function to return a token value.
1 string reference to '_sheetnode_ajax_token'
- sheetnode_menu in ./
sheetnode.module - Implements hook_menu().
File
- ./
sheetnode.module, line 1072 - Module file for the sheetnode module.
Code
function _sheetnode_ajax_token($oid = NULL, $entity_type = NULL, $token = NULL) {
if (!$oid) {
$oid = $_REQUEST['oid'];
}
if (!$entity_type) {
$entity_type = $_REQUEST['entity_type'];
}
if (!$token) {
$token = $_REQUEST['token'];
}
$value = NULL;
$entity = _sheetnode_entity_load($entity_type, $oid);
if ($entity) {
// Do the token replacement.
$value = token_replace($token, array(
$entity_type => $entity,
));
// If found, send it back.
if ($value) {
drupal_json_output(array(
'type' => is_numeric($value) ? 'n' : 'th',
'value' => $value,
));
drupal_exit();
}
}
drupal_json_output(array(
'value' => '',
'type' => 'e#NAME?',
));
drupal_exit();
}