function purge_item_action_callback in Purge 7.2
Callback for enable/disable.
Calls the confirmation form if the bundle doesn't validate after.
1 string reference to 'purge_item_action_callback'
- purge_menu in ./
purge_ui.module - Implements hook_menu().
File
- includes/
purge_ui.inc, line 530 - Provides administrative interface for the Purge module.
Code
function purge_item_action_callback($item_type, $item_name, $action) {
// Get the bundle and the item.
$bundle = new PurgePurgerBundleAPI();
$item = $bundle->{$item_type}[$item_name];
$access = FALSE;
// Check if we can enable/disable this item.
if ($action == 'enable' || $action == 'disable') {
if (in_array(PURGE_ACCESS_ENABLE, $item->access) || in_array(PURGE_ACCESS_FULL, $item->access)) {
$access = TRUE;
if ($action == 'enable') {
$actioned = t('enabled');
// Check if the item is already enabled.
if ($item->enabled == 1) {
drupal_set_message(t('@item_name is already enabled.'), array(
'@item_name' => $item->name,
));
drupal_goto('admin/config/system/purge');
return;
}
else {
// Enable the tiem.
$item->enabled = 1;
}
}
if ($action == 'disable') {
$actioned = t('disabled');
if ($item->enabled == 0) {
drupal_set_message(t('@item_type @item_name is already disabled.', array(
'@item_type' => $bundle->type[$item_type]->name,
'@item_name' => $item->name,
)));
drupal_goto('admin/config/system/purge');
return;
}
else {
// Disable the item.
$item->enabled = 0;
}
}
}
}
else {
return;
}
$bundle
->save();
drupal_set_message('Saved');
drupal_goto('admin/config/system/purge');
}