function itoggle_ajax_callback in iToggle 7
Same name and namespace in other branches
- 7.2 itoggle.pages.inc \itoggle_ajax_callback()
Page callback
See also
itoggle_menu().
1 string reference to 'itoggle_ajax_callback'
- itoggle_menu in ./
itoggle.module - Implements hook_menu().
File
- ./
itoggle.module, line 74 - iToggle module.
Code
function itoggle_ajax_callback() {
$token = filter_input(INPUT_POST, 'token');
$type = filter_input(INPUT_POST, 'type');
$property = filter_input(INPUT_POST, 'property');
$id = filter_input(INPUT_POST, 'id');
$value = filter_input(INPUT_POST, 'value');
$scope = filter_input(INPUT_POST, 'scope');
$token_key = "itoggle_{$type}_{$property}_{$id}_{$value}";
if (!empty($token) && drupal_valid_token($token, $token_key)) {
if ($scope === 'entity') {
$ok = _itoggle_ajax_toggle_entity($type, $property, $id, $value);
}
else {
if ($scope === 'field') {
$ok = _itoggle_ajax_toggle_field($type, $property, $id, $value);
}
}
}
// let $ok be undefined so we know the difference between FALSE (error) and UNDEFINDED (invalid type)
drupal_json_output(array(
'ok' => $ok,
));
exit;
}