You are here

function ckeditor_profile_features_revert in CKEditor - WYSIWYG HTML editor 6

Same name and namespace in other branches
  1. 7 includes/ckeditor.features.inc \ckeditor_profile_features_revert()

Implementation of hook_features_revert()

File

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

Code

function ckeditor_profile_features_revert($module) {
  if ($data = features_get_default('ckeditor_profile', $module)) {
    $roles = user_roles();
    foreach ($data as $name => $profile) {

      // Restore the profile settings
      db_query("DELETE FROM {ckeditor_settings} WHERE name = '%s'", $name);
      db_query("INSERT INTO {ckeditor_settings} (name, settings) VALUES('%s', '%s')", $name, serialize($profile['settings']));

      // Restore the profile roles
      foreach ($roles as $rid => $role_name) {
        if (in_array($role_name, (array) $profile['roles'])) {
          if (!db_result(db_query("SELECT rid FROM {ckeditor_role} WHERE rid = %d AND name = '%s'", $rid, $name))) {
            db_query("INSERT INTO {ckeditor_role} (rid, name) VALUES(%d, '%s')", $rid, $name);
          }
        }
        else {

          // Make sure they don't have access
          db_query("DELETE FROM {ckeditor_role} WHERE rid = %d AND name = '%s'", $rid, $name);
        }
      }
    }
  }
}