function entityform_anonymous_tokens in Entityform 7.2
Implements hook_tokens().
File
- entityform_anonymous/
entityform_anonymous.module, line 46 - Main functions and hook implementations
Code
function entityform_anonymous_tokens($type, $tokens, array $data = array(), array $options = array()) {
$return = array();
if ($type == 'entityform' && !empty($data['entityform'])) {
$entityform = $data['entityform'];
$anonymous_token = _entityform_anonymous_get_token($entityform->entityform_id);
$options = array(
'absolute' => TRUE,
'query' => array(
'token' => $anonymous_token,
'id' => $entityform->entityform_id,
),
);
$provided_tokens = array_keys(_entityform_anonymous_get_provided_tokens());
$entityform_type = entityform_type_load($entityform->type);
foreach ($tokens as $name => $original) {
if (empty($entityform_type->data['anonymous_links'])) {
// If this Entityform Type doesn't support tokens all should be blank.
if (in_array($name, $provided_tokens)) {
$return[$original] = '';
continue;
}
}
switch ($name) {
case 'anonymous_submission_token':
$return[$original] = $anonymous_token;
break;
case 'anonymous_submission_view_link':
$return[$original] = url('entityform/' . $entityform->entityform_id, $options);
break;
case 'anonymous_submission_edit_link':
$return[$original] = url("entityform/{$entityform->entityform_id}/edit", $options);
break;
case 'anonymous_submission_submit_link':
$return[$original] = url("eform/submit/{$entityform->type}", $options);
break;
}
}
}
return $return;
}