You are here

function skinr_context_group_delete_multiple in Skinr 7.2

Same name and namespace in other branches
  1. 8.2 skinr_context/skinr_context.module \skinr_context_group_delete_multiple()

Delete multiple skin settings group objects.

Parameters

$gids: An array of skin settings group IDs.

2 calls to skinr_context_group_delete_multiple()
SkinrContextApiTestCase::testSkinrContextGroupLoadSave in skinr_context/tests/skinr_context.test
Test skinr_skin_save() against invalid entries.
skinr_context_group_delete in skinr_context/skinr_context.module
Delete a skin group object.

File

skinr_context/skinr_context.module, line 140
Provides Skinr integration with Context.

Code

function skinr_context_group_delete_multiple($gids) {
  $transaction = db_transaction();
  if (!empty($gids)) {
    $groups = skinr_context_group_load_multiple($gids);
    try {
      foreach ($groups as $gid => $group) {
        module_invoke_all('skinr_context_group_delete', $group);

        // Delete all skin settings associated with this group.
        $params = array(
          'gid' => $gid,
        );
        $sids = skinr_context_group_get_sids($params);
        skinr_skin_delete_multiple($sids);
      }

      // Delete after calling hooks so that they can query node tables as needed.
      db_delete('skinr_groups')
        ->condition('gid', $gids, 'IN')
        ->execute();
    } catch (Exception $e) {
      $transaction
        ->rollback();
      watchdog_exception('skinr', $e);
      throw $e;
    }

    // Clear the skinr_context_group_load_multiple cache.
    drupal_static_reset('skinr_context_group_load_multiple');

    // Clear context's cache.
    context_invalidate_cache();
  }
}