You are here

function ckeditor_modules_uninstalled in CKEditor - WYSIWYG HTML editor 7

Implementation of hook_modules_uninstalled().

Remove enabled plugins in CKEditor profiles added by uninstalled modules.

File

./ckeditor.module, line 735
CKEditor - The text editor for the Internet - http://ckeditor.com Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.

Code

function ckeditor_modules_uninstalled($modules) {
  module_load_include('inc', 'ckeditor', 'includes/ckeditor.lib');
  $profiles_list = ckeditor_profile_input_formats();
  $plugins_list = ckeditor_load_plugins();
  foreach ($profiles_list as $_profile => $_inputs) {
    $changed = FALSE;
    $profile = ckeditor_profile_load($_profile);
    if (!isset($profile->settings['loadPlugins'])) {
      continue;
    }
    foreach (array_keys((array) $profile->settings['loadPlugins']) as $plugin_name) {
      if (!array_key_exists($plugin_name, $plugins_list)) {
        unset($profile->settings['loadPlugins'][$plugin_name]);
        $changed = TRUE;
      }
    }
    if ($changed) {
      db_update('ckeditor_settings')
        ->fields(array(
        'settings' => serialize($profile->settings),
      ))
        ->condition('name', $profile->name, '=')
        ->execute();
    }
  }
}