You are here

function mostpopular_block_delete in Drupal Most Popular 7

1 call to mostpopular_block_delete()
mostpopular_blocks_admin_form_submit in ./mostpopular.blocks.inc

File

./mostpopular.module, line 769
The main file for the Most Popular module.

Code

function mostpopular_block_delete($bid) {
  if (empty($bid)) {
    return;
  }
  $services = mostpopular_service_load_by_block($bid, FALSE);
  $intervals = mostpopular_interval_load_by_block($bid);
  db_delete('mostpopular_block')
    ->condition('bid', $bid)
    ->execute();
  db_delete('mostpopular_service')
    ->condition('bid', $bid)
    ->execute();
  db_delete('mostpopular_interval')
    ->condition('bid', $bid)
    ->execute();
  if (!empty($services) && !empty($intervals)) {
    db_delete('mostpopular_item')
      ->condition('sid', array_keys($services))
      ->condition('iid', array_keys($intervals))
      ->execute();
    db_delete('mostpopular_last_run')
      ->condition('sid', array_keys($services))
      ->condition('iid', array_keys($intervals))
      ->execute();
  }
  drupal_set_message(t('Deleted block @bid', array(
    '@bid' => $bid,
  )));
}