Projet

Général

Profil

Paste
Télécharger (21 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / ckeditor / ckeditor.install @ 5a7e6170

1
<?php
2

    
3
/*
4
 * CKEditor - The text editor for the Internet - http://ckeditor.com
5
 * Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
6
 *
7
 * == BEGIN LICENSE ==
8
 *
9
 * Licensed under the terms of any of the following licenses of your
10
 * choice:
11
 *
12
 *  - GNU General Public License Version 2 or later (the "GPL")
13
 *    http://www.gnu.org/licenses/gpl.html
14
 *
15
 *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
16
 *    http://www.gnu.org/licenses/lgpl.html
17
 *
18
 *  - Mozilla Public License Version 1.1 or later (the "MPL")
19
 *    http://www.mozilla.org/MPL/MPL-1.1.html
20
 *
21
 * == END LICENSE ==
22
 *
23
 * @file
24
 * CKEditor Module for Drupal 7.x
25
 *
26
 * This module allows Drupal to replace textarea fields with CKEditor.
27
 *
28
 * CKEditor is an online rich text editor that can be embedded inside web pages.
29
 * It is a WYSIWYG (What You See Is What You Get) editor which means that the
30
 * text edited in it looks as similar as possible to the results end users will
31
 * see after the document gets published. It brings to the Web popular editing
32
 * features found in desktop word processors such as Microsoft Word and
33
 * OpenOffice.org Writer. CKEditor is truly lightweight and does not require any
34
 * kind of installation on the client computer.
35
 */
36

    
37
/*
38
 * Implementation of hook_install().
39
 *
40
 * This will automatically install the database tables for the CKEditor module for both MySQL and PostgreSQL databases.
41
 *
42
 * If you are using another database, you will have to install the tables manually, using the queries below as a reference.
43
 *
44
 * Note that the curly braces around table names are a Drupal-specific feature to allow for automatic database table prefixing,
45
 * and will need to be removed.
46
 */
47

    
48
function ckeditor_install() {
49
  module_load_include('inc', 'ckeditor', 'includes/ckeditor.lib');
50

    
51
  //searching ckeditor.js
52
  $editor_path = _ckeditor_script_path();
53
  //insert default input formats to profiles
54
  db_insert('ckeditor_input_format')->fields(array("name" => "Advanced", "format" => 'filtered_html'))->execute();
55
  db_insert('ckeditor_input_format')->fields(array("name" => "Full", "format" => 'full_html'))->execute();
56

    
57
  //insert settings for default role
58
  $arr = array();
59
  $arr['filebrowser'] = 'none';
60
  $arr['quickupload'] = 'f';
61

    
62
  //security
63
  $arr['ss'] = "2";
64
  $arr['filters']['filter_html'] = 1;
65

    
66
  //appearance
67
  $arr['default'] = "t";
68
  $arr['show_toggle'] = "t";
69
  $arr['popup'] = variable_get('ckeditor_popup', 0) ? "t" : "f";
70
  $arr['toolbar'] = "
71
[
72
    ['Source'],
73
    ['Cut','Copy','Paste','PasteText','PasteFromWord','-','SpellChecker', 'Scayt'],
74
    ['Undo','Redo','Find','Replace','-','SelectAll','RemoveFormat'],
75
    ['Image','Media','Flash','Table','HorizontalRule','Smiley','SpecialChar'],
76
    ['Maximize', 'ShowBlocks'],
77
    '/',
78
    ['Format'],
79
    ['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],
80
    ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
81
    ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','-','BidiLtr','BidiRtl'],
82
    ['Link','Unlink','Anchor', 'Linkit']
83
]
84
    ";
85
  $arr['expand'] = variable_get('ckeditor_toolbar_start_expanded', 1) ? "t" : "f";
86
  $arr['width'] = variable_get("ckeditor_width", "100%");
87
  $arr['lang'] = "en";
88
  $arr['auto_lang'] = "t";
89
  $arr['language_direction'] = "default";
90

    
91
  //output
92
  $arr['enter_mode'] = "p";
93
  $arr['shift_enter_mode'] = "br";
94
  $arr['font_format'] = 'p;div;pre;address;h1;h2;h3;h4;h5;h6';
95
  $arr['format_source'] = "t";
96
  $arr['format_output'] = "t";
97
  $arr['custom_formatting'] = "f";
98
  $arr['formatting']['custom_formatting_options'] = array('indent' => 'indent', 'breakBeforeOpen' => 'breakBeforeOpen', 'breakAfterOpen' => 'breakAfterOpen', 'breakAfterClose' => 'breakAfterClose');
99

    
100
  //css
101
  $arr['css_mode'] = "none";
102
  $arr['css_path'] = variable_get("ckeditor_stylesheet", "");
103

    
104
  //upload
105
  //get permissions here like in _update_role_permissions
106
  $arr['filebrowser'] = "none";
107
  $arr['user_choose'] = "f";
108
  $arr['ckeditor_load_method'] = "ckeditor.js";
109
  $arr['ckeditor_load_time_out'] = 0;
110
  $arr['scayt_autoStartup'] = "f";
111

    
112
  //advanced options
113
  $arr['html_entities'] = "f";
114

    
115
  db_insert('ckeditor_settings')->fields(array("name" => "Advanced", "settings" => serialize($arr)))->execute();
116

    
117
  //insert settings for advanced role
118
  $arr['toolbar'] = "
119
[
120
    ['Source'],
121
    ['Cut','Copy','Paste','PasteText','PasteFromWord','-','SpellChecker', 'Scayt'],
122
    ['Undo','Redo','Find','Replace','-','SelectAll','RemoveFormat'],
123
    ['Image','Media','Flash','Table','HorizontalRule','Smiley','SpecialChar','Iframe'],
124
    '/',
125
    ['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],
126
    ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote','CreateDiv'],
127
    ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','-','BidiLtr','BidiRtl'],
128
    ['Link','Unlink','Anchor', 'Linkit'],
129
    ['DrupalBreak'],
130
    '/',
131
    ['Format','Font','FontSize'],
132
    ['TextColor','BGColor'],
133
    ['Maximize', 'ShowBlocks']
134
]
135
    ";
136

    
137
  $arr['filters'] = array();
138

    
139
  db_insert('ckeditor_settings')->fields(array("name" => "Full", "settings" => serialize($arr)))->execute();
140

    
141
  $arr = array();
142

    
143
  if ($editor_path) {
144
    $arr['ckeditor_path'] = $editor_path;
145
  }
146

    
147
  db_insert('ckeditor_settings')->fields(array("name" => "CKEditor Global Profile", "settings" => serialize($arr)))->execute();
148

    
149
  module_load_include('inc', 'ckeditor', 'includes/ckeditor.admin');
150
}
151

    
152
/**
153
 * Implementation of hook_schema().
154
 */
155
function ckeditor_schema() {
156
  $schema['ckeditor_settings'] = array(
157
    'description' => 'Stores CKEditor profile settings',
158
    'fields' => array(
159
      'name' => array(
160
        'type' => 'varchar',
161
        'not null' => TRUE,
162
        'default' => '',
163
        'length' => 128,
164
        'description' => 'Name of the CKEditor profile',
165
      ),
166
      'settings' => array(
167
        'type' => 'text',
168
        'description' => 'Profile settings',
169
      ),
170
    ),
171
    'primary key' => array('name')
172
  );
173
  $schema['ckeditor_input_format'] = array(
174
    'description' => 'Stores CKEditor input format assignments',
175
    'fields' => array(
176
      'name' => array(
177
        'type' => 'varchar',
178
        'not null' => TRUE,
179
        'default' => '',
180
        'length' => 128,
181
        'description' => 'Name of the CKEditor role',
182
      ),
183
      'format' => array(
184
        'type' => 'varchar',
185
        'not null' => TRUE,
186
        'default' => '',
187
        'length' => 128,
188
        'description' => 'Drupal filter format ID',
189
      )
190
    ),
191
    'primary key' => array('name', 'format'),
192
  );
193

    
194
  return $schema;
195
}
196

    
197
/**
198
 * Implementation of hook_requirements().
199
 *
200
 * This hook will issue warnings if:
201
 * - The CKEditor source files are not found.
202
 * - The CKEditor source files are out of date.
203
 * - Quick upload and/or the built-in file browser are used and $cookie_domain is not set.
204
 */
205
function ckeditor_requirements($phase) {
206
  $requirements = array();
207

    
208
  if ($phase == 'runtime') {
209
    module_load_include('module', 'ckeditor');
210
    module_load_include('inc', 'ckeditor', 'includes/ckeditor.lib');
211
    $requirements['ckeditor'] = array(
212
      'title' => t('CKEditor'),
213
      'value' => t('Unknown'),
214
    );
215

    
216
    $requirements['ckeditor']['severity'] = REQUIREMENT_OK;
217

    
218
    if (!_ckeditor_requirements_isinstalled()) {
219
      $sourcepath = ckeditor_path('local');
220

    
221
      $requirements['ckeditor']['description'] = t('CKEditor was not found in <code>%sourcepath</code>.', array('%sourcepath' => $sourcepath));
222
      $requirements['ckeditor']['severity'] = REQUIREMENT_ERROR;
223
    }
224
    elseif (($installed_version = _ckeditor_requirements_getinstalledversion()) === NULL) {
225
      $requirements['ckeditor']['description'] = t('CKEditor version could not be determined.');
226
      $requirements['ckeditor']['severity'] = REQUIREMENT_INFO;
227
    }
228
    else {
229
      $profile_name = _ckeditor_requirements_ckfinder_filebrowser_enabled();
230
      if ($profile_name !== FALSE) {
231
        if (!_ckeditor_requirements_cookiedomainset()) {
232
          $requirements['ckeditor']['severity'] = REQUIREMENT_ERROR;
233
          $requirements['ckeditor']['description'] = t('You are using a feature that requires <code>$cookie_domain</code> to be set, but it is not set in your <code>settings.php</code> file (CKFinder is enabled in the !profile profile).', array('!profile' => l($profile_name, 'admin/config/content/ckeditor/edit/' . urlencode($profile_name))));
234
        }
235
        elseif ($error = _ckeditor_requirements_ckfinder_config_check($profile_name)) {
236
          $requirements['ckeditor']['severity'] = REQUIREMENT_ERROR;
237
          $requirements['ckeditor']['description'] = $error;
238
        }
239
      }
240
    }
241
    if ((($installed_version = _ckeditor_requirements_getinstalledversion()) !== NULL) && (-1 == version_compare($installed_version, '3.1 SVN')) && $installed_version != '%VERSION%') {
242
      $requirements['ckeditor']['description'] = t('Some features are disabled because you are using an older version of CKEditor. Please upgrade to CKEditor 3.1 (or higher).');
243
      $requirements['ckeditor']['severity'] = REQUIREMENT_INFO;
244
    }
245
    if (!empty($installed_version)) {
246
      if ($installed_version == '%VERSION%') {
247
        $requirements['ckeditor']['value'] = 'GIT version';
248
      }
249
      else {
250
        $requirements['ckeditor']['value'] = $installed_version;
251
      }
252
    }
253
    else {
254
      $requirements['ckeditor']['value'] = t('Not found');
255
    }
256
  }
257

    
258
  return $requirements;
259
}
260

    
261
/**
262
 * Fetches the version of the installed CKEditor sources.
263
 *
264
 * It tries to locate the version of the CKEditor sources in
265
 * ckeditor.js.
266
 *
267
 * Releases have a version number such as "3.0.1".
268
 * SVN nightly releases have a minor version number with SVN appended: "3.0 SVN".
269
 * SVN checkouts have the string "[Development]".
270
 *
271
 * This function is used by ckeditor_requirements().
272
 *
273
 * @return string Version number (eg. 3.0) of CKEditor. Null if not found in ckeditor_basic.js.
274
 */
275
function _ckeditor_requirements_getinstalledversion() {
276
  module_load_include('module', 'ckeditor');
277
  $editor_path = ckeditor_path('local', TRUE);
278
  $jspath = $editor_path . '/ckeditor.js';
279

    
280
  $configcontents = @file_get_contents($jspath);
281
  if (!$configcontents) {
282
    return NULL;
283
  }
284
  $matches = array();
285
  if (preg_match('#,version:[\'\"]{1}(.*?)[\'\"]{1},#', $configcontents, $matches)) {
286
    return $matches[1];
287
  }
288
  return NULL;
289
}
290

    
291
/**
292
 * Executed when the built-in file browser is enabled.
293
 * Returns FALSE if no errors are found in the config.php file, otherwise it returns an error message.
294
 *
295
 * @return string|boolean
296
 */
297
function _ckeditor_requirements_ckfinder_config_check($profile_name) {
298
  global $base_url;
299
  module_load_include('module', 'ckeditor');
300
  $config_path = ckfinder_path('local') . '/config.php';
301

    
302
  if (!file_exists($config_path)) {
303
    return t('!ckfinder is not installed correctly: <code>!config</code> not found. Make sure that you uploaded all files and did not accidentally remove the configuration file. If you installed CKFinder in other location (e.g. in the libraries folder), make sure to update the path to CKFinder in !global.', array(
304
          '!config' => $config_path,
305
          '!ckfinder' => '<a href="http://cksource.com/ckfinder">CKFinder</a>',
306
          '!global' => l(t('CKEditor Global Profile'), 'admin/config/content/ckeditor/editg')
307
        ));
308
  }
309

    
310
  if (!is_readable($config_path)) {
311
    return t('CKEditor needs read permission to the <code>!config</code> file.', array('!config' => $config_path));
312
  }
313

    
314
  $config_contents = file($config_path);
315

    
316
  //not a 100% valid check, but well... let's have at least some error checking
317
  $require_once_found = FALSE;
318
  $require_once_line = 0;
319
  $userfiles_absolute_path_line = 0;
320
  $force_single_extension_line = 0;
321

    
322
  if ($config_contents) {
323
    foreach ($config_contents as $line_num => $line) {
324
      //make sure it doesn't start with a comment, unfortunately we're not protected if code is commented with /* */
325
      if (!$require_once_found && strpos($line, "filemanager.config.php") !== FALSE && !preg_match(",^(?://|\#|\*|/\*),", trim($line))) {
326
        $require_once_found = TRUE;
327
        $require_once_line = $line_num;
328
      }
329
      /**
330
       * @todo Finish this
331
       */
332
      if (!$userfiles_absolute_path_line && strpos($line, '$Config[\'UserFilesAbsolutePath\']') !== FALSE && !preg_match(",^(?://|\#|\*|/\*),", trim($line))) {
333
        $userfiles_absolute_path_line = $line_num;
334
      }
335
      if (!$force_single_extension_line && strpos($line, '$Config[\'ForceSingleExtension\']') !== FALSE && !preg_match(",^(?://|\#|\*|/\*),", trim($line))) {
336
        $force_single_extension_line = $line_num;
337
      }
338
    }
339
  }
340

    
341
  if (!$require_once_found) {
342
    return t('You are using a feature that requires manual integration in the <code>config.php</code> file. Please read the "Installing CKFinder" section in the <code>!readme</code> file carefully and add a <code>require_once ...</code> statement to the <code>%ckfconfig</code> file.', array('%ckfconfig' => $config_path, '!readme' => l(t('README.txt'), $base_url . '/' . drupal_get_path('module', 'ckeditor') . '/README.txt', array('absolute' => TRUE))));
343
  }
344

    
345
  if ($userfiles_absolute_path_line && $force_single_extension_line && (
346
      $require_once_line < $userfiles_absolute_path_line || $require_once_line > $force_single_extension_line)) {
347
    return t('You are using a feature that requires manual integration in the <code>config.php</code> file. You have added a <code>require_once ...</code> statement to the <code>%ckfconfig</code> file, but in the wrong line.', array('%ckfconfig' => $config_path));
348
  }
349

    
350
  return FALSE;
351
}
352

    
353
/**
354
 * Checks if any profile requires an explicit setting of $cookie_domain
355
 * in settings.php.
356
 *
357
 * %cookie_domain is required when the internal file browser or quick upload is used.
358
 *
359
 * This function is used by ckeditor_requirements().
360
 *
361
 * @return boolean True if any profile requires $cookie_domain.
362
 */
363
function _ckeditor_requirements_ckfinder_filebrowser_enabled() {
364
  module_load_include('module', 'ckeditor');
365
  $profiles = ckeditor_profile_load();
366

    
367
  foreach ($profiles as $profile) {
368
    if ((isset($profile->settings['filebrowser']) && $profile->settings['filebrowser'] == 'ckfinder')) {
369
      return $profile->name;
370
    }
371
  }
372

    
373
  return FALSE;
374
}
375

    
376
/**
377
 * Checks if $cookie_domain was set.
378
 *
379
 * It has to include settings.php again because conf_init() sets
380
 * $cookie_domain regardless of its presence in settings.php, so
381
 * simply checking $GLOBALS['cookie_domain'] is not possible.
382
 *
383
 * This function is used by ckeditor_requirements().
384
 *
385
 * @return boolean True if $cookie_domain was set in settings.php.
386
 */
387
function _ckeditor_requirements_cookiedomainset() {
388
  if (file_exists('./' . conf_path() . '/settings.php')) {
389
    $settings = file_get_contents('./' . conf_path() . '/settings.php');
390

    
391
    if (preg_match('#^\s*\$cookie_domain#m', $settings)) {
392
      return TRUE;
393
    }
394
  }
395

    
396
  return FALSE;
397
}
398

    
399
/**
400
 * Updates broken settings for the 'Full' profile. (Resets toolbar to default)
401
 */
402
function ckeditor_update_7000() {
403
  _ckeditor_d6_to_d7_migration();
404
  $result = db_query("SELECT settings FROM {ckeditor_settings} WHERE name = :name", array(':name' => 'Full'))->fetchField();
405
  $settings = unserialize($result);
406
  $settings['toolbar'] = "
407
[
408
    ['Source'],
409
    ['Cut','Copy','Paste','PasteText','PasteFromWord','-','SpellChecker', 'Scayt'],
410
    ['Undo','Redo','Find','Replace','-','SelectAll','RemoveFormat'],
411
    ['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar'],
412
    '/',
413
    ['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],
414
    ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
415
    ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','-','BidiLtr','BidiRtl'],
416
    ['Link','Unlink','Anchor'],
417
    ['DrupalBreak'],
418
    '/',
419
    ['Format','Font','FontSize'],
420
    ['TextColor','BGColor'],
421
    ['Maximize', 'ShowBlocks']
422
]
423
    ";
424

    
425
  $settings = serialize($settings);
426

    
427
  $update = db_update('ckeditor_settings')
428
      ->fields(array(
429
        'settings' => $settings,
430
      ))
431
      ->condition('name', 'Full', '=')
432
      ->execute();
433
}
434

    
435
/**
436
 * Removes the 'DrupalBreak' button from the 'Advanced' profile. (Resets toolbar to default)
437
 */
438
function ckeditor_update_7001() {
439
  $result = db_query("SELECT settings FROM {ckeditor_settings} WHERE name = :name", array(':name' => 'Advanced'))->fetchField();
440
  $settings = unserialize($result);
441
  $settings['toolbar'] = "
442
[
443
    ['Source'],
444
    ['Cut','Copy','Paste','PasteText','PasteFromWord','-','SpellChecker', 'Scayt'],
445
    ['Undo','Redo','Find','Replace','-','SelectAll','RemoveFormat'],
446
    ['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar'],
447
    ['Maximize', 'ShowBlocks'],
448
    '/',
449
    ['Format'],
450
    ['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],
451
    ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
452
    ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','-','BidiLtr','BidiRtl'],
453
    ['Link','Unlink','Anchor']
454
]
455
    ";
456

    
457
  $settings = serialize($settings);
458

    
459
  $update = db_update('ckeditor_settings')
460
      ->fields(array(
461
        'settings' => $settings,
462
      ))
463
      ->condition('name', 'Advanced', '=')
464
      ->execute();
465
}
466

    
467
/**
468
 * Rewrites 'Path to CKEditor' to new flags.
469
 */
470
function ckeditor_update_7002() {
471
  $result = db_query("SELECT settings FROM {ckeditor_settings} WHERE name = :name", array(':name' => 'CKEditor Global Profile'))->fetchField();
472
  $settings = unserialize($result);
473
  if ($settings['ckeditor_path'] == '%b/sites/all/libraries/ckeditor') {
474
    $settings['ckeditor_path'] = '%l/ckeditor';
475
  }
476
  else {
477
    $settings['ckeditor_path'] = str_replace('%b/', '', $settings['ckeditor_path']);
478
    $settings['ckeditor_path'] = str_replace('%b', '', $settings['ckeditor_path']);
479
  }
480

    
481
  $settings = serialize($settings);
482

    
483
  $update = db_update('ckeditor_settings')
484
      ->fields(array(
485
        'settings' => $settings,
486
      ))
487
      ->condition('name', 'CKEditor Global Profile', '=')
488
      ->execute();
489
}
490

    
491
/**
492
 * Fixes static paths to plugin files.
493
 */
494
function ckeditor_update_7003() {
495
  module_load_include('inc', 'ckeditor', 'includes/ckeditor.lib');
496
  module_load_include('module', 'ckeditor');
497

    
498
  _ckeditor_d6_to_d7_migration();
499

    
500
  $render = array();
501
  $render["%base_path%"] = base_path();
502
  $render["%editor_path%"] = ckeditor_path('relative') . '/';
503
  $render["%ckeditor_path%"] = ckeditor_module_path('relative');
504
  $render["%plugin_dir%"] = $render["%module_path%"] . '/plugins/';
505

    
506
  $result = db_query("SELECT * FROM {ckeditor_settings} WHERE name <> :name", array(':name' => 'CKEditor Global Profile'))->fetchAllAssoc('name');
507

    
508
  foreach ((array) $result as $profile) {
509
    $name = $profile->name;
510
    $settings = unserialize($profile->settings);
511

    
512
    foreach ((array) $settings['loadPlugins'] as $i => $plugin) {
513
      $settings['loadPlugins'][$i]['path'] = str_replace(array_values($render), array_keys($render), $plugin['path']);
514
    }
515

    
516
    $settings = serialize($settings);
517

    
518
    $update = db_update('ckeditor_settings')
519
        ->fields(array(
520
          'settings' => $settings,
521
        ))
522
        ->condition('name', $name, '=')
523
        ->execute();
524
  }
525
}
526

    
527
/**
528
 * Minor update for those who have run update.php with problems.
529
 * @see http://drupal.org/node/1347682 for a better explanation.
530
 */
531
function ckeditor_update_7004() {
532
  return _ckeditor_d6_to_d7_migration();
533
}
534

    
535
/**
536
 * Fixes plugin paths stored in database.
537
 * @see http://drupal.org/node/1864760 for more information
538
 */
539
function ckeditor_update_7005() {
540
  $result = db_query("SELECT * FROM {ckeditor_settings} WHERE name <> :name", array(':name' => 'CKEditor Global Profile'))->fetchAllAssoc('name');
541

    
542
  foreach ((array) $result as $profile) {
543
    $name = $profile->name;
544
    $settings = unserialize($profile->settings);
545

    
546
    $replace = array(
547
      "%base_path%%editor_path%" => "%editor_path%",
548
      "%base_path%%module_path%" => "%module_path%",
549
      "%base_path%%plugin_dir%" => "%plugin_dir%",
550
      "%base_path%%plugin_dir_extra%" => "%plugin_dir_extra%"
551
    );
552

    
553
    foreach ((array) $settings['loadPlugins'] as $i => $plugin) {
554
      $settings['loadPlugins'][$i]['path'] = str_replace(array_keys($replace), array_values($replace), $plugin['path']);
555
    }
556

    
557
    $settings = serialize($settings);
558

    
559
    db_update('ckeditor_settings')
560
        ->fields(array(
561
          'settings' => $settings,
562
        ))
563
        ->condition('name', $name, '=')
564
        ->execute();
565
  }
566
}
567

    
568
/**
569
 * Adapts D6 table structure to D7 schema.
570
 */
571
function _ckeditor_d6_to_d7_migration() {
572
  if (db_table_exists('ckeditor_role')) {
573
    db_drop_table('ckeditor_role');
574
  }
575
  if (!db_table_exists('ckeditor_input_format')) {
576
    $ckeditor_input_format = array(
577
      'description' => 'Stores CKEditor input format assignments',
578
      'fields' => array(
579
        'name' => array(
580
          'type' => 'varchar',
581
          'not null' => TRUE,
582
          'default' => '',
583
          'length' => 128,
584
          'description' => 'Name of the CKEditor role',
585
        ),
586
        'format' => array(
587
          'type' => 'varchar',
588
          'not null' => TRUE,
589
          'default' => '',
590
          'length' => 128,
591
          'description' => 'Drupal filter format ID',
592
        )
593
      ),
594
      'primary key' => array('name', 'format'),
595
    );
596
    db_create_table('ckeditor_input_format', $ckeditor_input_format);
597
  }
598
}