function rules_modules_disabled

Implements hook_modules_disabled().

File

./rules.module, line 1558

Code

function rules_modules_disabled($modules) {
    // Disable Rules configurations that depend on one of the disabled modules.
    $query = db_select('rules_dependencies', 'rd');
    $query->join('rules_config', 'rc', 'rd.id = rc.id');
    $query->fields('rd', array(
        'id',
    ))
        ->distinct()
        ->condition('rd.module', $modules, 'IN')
        ->condition('rc.dirty', 0);
    $ids = $query->execute()
        ->fetchCol();
    if (!empty($ids)) {
        db_update('rules_config')->fields(array(
            'dirty' => 1,
        ))
            ->condition('id', $ids, 'IN')
            ->execute();
        // Tell the user about enabled rules that have been marked as dirty.
        $count = db_select('rules_config', 'r')->fields('r')
            ->condition('id', $ids, 'IN')
            ->condition('active', 1)
            ->countQuery()
            ->execute()
            ->fetchField();
        if ($count > 0) {
            $message = format_plural($count, '1 Rules configuration requires some of the disabled modules to function and cannot be executed any more.', '@count Rules configurations require some of the disabled modules to function and cannot be executed any more.');
            drupal_set_message($message, 'warning');
        }
    }
    rules_clear_cache();
}