function optimizely_delete_page_confirm_submit in Optimizely 7.3
Same name and namespace in other branches
- 7.2 optimizely.admin.inc \optimizely_delete_page_confirm_submit()
Submit function for the confirm deletion form. Delete the entry in the database and return the user to the Project listing page.
File
- ./
optimizely.admin.inc, line 553 - Admin page callback for the Optimizely module.
Code
function optimizely_delete_page_confirm_submit($form, &$form_state) {
// target $oid
$oid = $form_state['values']['oid'];
// Lookup entry details before delete
$query = db_select('optimizely', 'o', array(
'target' => 'slave',
))
->fields('o', array(
'path',
'enabled',
))
->condition('o.oid', $oid, '=');
$record = $query
->execute()
->fetchObject();
// Delete entry in database based on the target $oid
$query = db_delete('optimizely')
->condition('oid', $oid);
$query
->execute();
// Only clear page cache for entries that are active when deleted
if ($record->enabled) {
// Always serialized when saved
$path_array = unserialize($record->path);
optimizely_refresh_cache($path_array);
}
// Inform the user of the entry being deleted and return them to the
// listing page.
drupal_set_message(t('The project entry has been deleted.'), 'status');
drupal_goto('/admin/config/system/optimizely');
}