[ Index ]

PHP Cross Reference of Drupal 6 (yi-drupal)

title

Body

[close]

/sites/all/modules/fckeditor/ -> fckeditor.install (source)

   1  <?php
   2  // $Id: fckeditor.install,v 1.2.2.10.2.45 2010/03/08 11:06:44 jorrit Exp $
   3  /*
   4   * FCKeditor - The text editor for Internet - http://www.fckeditor.net
   5   * Copyright (C) 2003-2008 Frederico Caldeira Knabben
   6   *
   7   * == BEGIN LICENSE ==
   8   *
   9   * Licensed under the terms of any of the following licenses at 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   * FCKeditor Module for Drupal 6.x
  25   *
  26   * This module allows Drupal to replace textarea fields with FCKeditor.
  27   *
  28   * This HTML text editor brings to the web many of the powerful functionalities
  29   * of known desktop editors like Word. It's really  lightweight and doesn't
  30   * require any kind of installation on the client computer.
  31   */
  32  
  33  /*
  34   * Implementation of hook_install().
  35   *
  36   * This will automatically install the database tables for the FCKeditor module for both the MySQL and PostgreSQL databases.
  37   *
  38   * If you are using another database, you will have to install the tables by hand, using the queries below as a reference.
  39   *
  40   * Note that the curly braces around table names are a drupal-specific feature to allow for automatic database table prefixing,
  41   * and will need to be removed.
  42   */
  43  function fckeditor_install() {
  44  
  45    drupal_install_schema('fckeditor');
  46  
  47    //create two default roles based on previous settings
  48    db_query("INSERT INTO {fckeditor_role} (name, rid) VALUES ('%s', %d)",
  49    "Default", defined('DRUPAL_ANONYMOUS_RID') ? DRUPAL_ANONYMOUS_RID : 1);
  50    db_query("INSERT INTO {fckeditor_role} (name, rid) VALUES ('%s', %d)",
  51    "Advanced", defined('DRUPAL_AUTHENTICATED_RID') ? DRUPAL_AUTHENTICATED_RID : 2);
  52  
  53    //insert settings for default role
  54    $arr = array();
  55    $arr['allow_user_conf'] = "f";
  56    $arr['min_rows'] = variable_get('fckeditor_minimum_rows', 1);
  57    $arr['excl_mode'] = variable_get('fckeditor_exclude_toggle', 0);
  58    $arr['filebrowser'] = 'none';
  59    $arr['quickupload'] = 'f';
  60  
  61    //security
  62    $arr['ss'] = "2";
  63    $arr['filters']['filter/0'] = 1;
  64  
  65    //appearance
  66    $arr['default'] = "t";
  67    $arr['show_toggle'] = "t";
  68    $arr['popup'] = variable_get('fckeditor_popup', 0) ? "t" : "f";
  69    $arr['skin'] = "default";
  70    $arr['toolbar'] = variable_get('fckeditor_default_toolbar', 'DrupalBasic');
  71    $arr['expand'] = variable_get('fckeditor_toolbar_start_expanded', 1) ? "t" : "f";
  72    $arr['width'] = variable_get("fckeditor_width", "100%");
  73    $arr['lang'] = "en";
  74    $arr['auto_lang'] = "t";
  75  
  76    //output
  77    $arr['enter_mode'] = "p";
  78    $arr['shift_enter_mode'] = "br";
  79    $arr['font_format'] = 'p;div;pre;address;h1;h2;h3;h4;h5;h6';
  80    $arr['format_source'] = "t";
  81    $arr['format_output'] = "t";
  82  
  83    //css
  84    $arr['css_mode'] = "theme";
  85    $arr['css_path'] = variable_get("fckeditor_stylesheet", "");
  86  
  87    //upload
  88    //get permissions here like in _update_role_permissions
  89    $arr['filebrowser'] = "none";
  90    $arr['quickupload'] = "f";
  91    $arr['user_choose'] = "f";
  92    $arr['show_fieldnamehint'] = "t";
  93    $arr['autofixplaintext'] = 'f';
  94  
  95    db_query("INSERT INTO {fckeditor_settings} (name, settings) VALUES ('%s', '%s')", "Default", serialize($arr));
  96  
  97    //insert settings for advanced role
  98    $arr['toolbar'] = variable_get('fckeditor_advanced_toolbar', 'DrupalFiltered');
  99    db_query("INSERT INTO {fckeditor_settings} (name, settings) VALUES ('%s', '%s')", "Advanced", serialize($arr));
 100  
 101    $arr = array();
 102  
 103    //exclude by default some known textareas where HTML is not expected
 104    //edit-recipients //contact module
 105    //edit-reply //contact module
 106    //edit-description //taxonomy module
 107    //edit-synonyms //taxonomy module
 108    //edit-img-assist-textareas //img assist module
 109    $arr['excl_mode'] = 0;
 110    $arr['excl'] = variable_get("fckeditor_exclude",
 111    "admin/user/settings.edit-user-mail-*\n".
 112    "*.edit-pages\n".
 113    "*.edit-pathauto-ignore-words\n".
 114    "*.edit-recipients\n".
 115    "*.edit-reply\n".
 116    "*.edit-description\n".
 117    "*.edit-synonyms\n".
 118    "*.edit-img-assist-textareas\n".
 119    "*.edit-img-assist-paths\n".
 120    "*.edit-nodewords-description\n".
 121    "*.edit-nodewords-description-value\n".
 122    "admin/content/nodewords/global*\n".
 123    "*.edit-relatedlinks-fieldset-relatedlinks\n".
 124    "*.edit-allowed-values-php\n".
 125    "*.edit-allowed-values\n".
 126    "*.edit-update-notify-emails\n".
 127    "*.edit-googleanalytics-*\n".
 128    "*.edit-piwik-*\n".
 129    "*.edit-feedburner-useragents\n".
 130    "*@*.edit-webform-*\n".
 131    "webform@*.edit-extra-items\n".
 132    "admin/*/logintoboggan\n".
 133    "admin/settings/actions/configure/*\n".
 134    "*.edit-target\n"
 135    );
 136  
 137    //force by default simple toolbar on selected textareas
 138    $arr['simple_incl_mode'] = 1;
 139    $arr['simple_incl'] =
 140    "*.edit-signature\n".
 141    "admin/settings/site-information.*\n".
 142    "admin/settings/site-maintenance.*\n".
 143    "*.edit-page-help\n".
 144    "*.edit-user-registration-help\n".
 145    "*.edit-user-picture-guidelines\n";
 146  
 147    db_query("INSERT INTO {fckeditor_settings} (name, settings) VALUES ('%s', '%s')", "FCKeditor Global Profile", serialize($arr));
 148  
 149    module_load_include('inc', 'fckeditor', 'fckeditor.admin');
 150    fckeditor_rebuild_selectors();
 151  }
 152  
 153  /**
 154   * Implementation of hook_schema().
 155   */
 156  function fckeditor_schema() {
 157    $schema['fckeditor_settings'] = array(
 158    'description' => 'Stores FCKeditor profile settings',
 159    'fields' => array(
 160    'name'    => array(
 161    'type' => 'varchar',
 162    'not null' => TRUE,
 163    'default' => '',
 164    'length' => 128,
 165    'description' => 'Name of the FCKeditor profile',
 166      ),
 167      'settings'    => array(
 168        'type' => 'text',
 169        'description' => 'Profile settings',
 170      ),
 171    ),
 172    'primary key' => array('name'),
 173    );
 174    $schema['fckeditor_role'] = array(
 175      'description' => 'Stores FCKeditor profile assignments',
 176      'fields' => array(
 177        'name'    => array(
 178          'type' => 'varchar',
 179          'not null' => TRUE,
 180          'default' => '',
 181          'length' => 128,
 182          'description' => 'Name of the FCKeditor role',
 183        ),
 184        'rid' => array(
 185          'type' => 'int',
 186          'not null' => TRUE,
 187          'default' => 0,
 188          'description' => 'Drupal role id',
 189        ),
 190      ),
 191      'primary key' => array('name', 'rid'),
 192    );
 193  
 194    return $schema;
 195  }
 196  
 197  /**
 198   * Implementation of hook_requirements().
 199   *
 200   * This hook will issue warnings if:
 201   * - The FCKeditor source files are not found
 202   * - The FCKeditor 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 fckeditor_requirements($phase) {
 206    $requirements = array();
 207  
 208    if ($phase == 'runtime') {
 209      $requirements['fckeditor'] = array(
 210      'title' => t('FCKeditor'),
 211      'value' => t('Unknown'),
 212      );
 213  
 214      $requirements['fckeditor']['severity'] = REQUIREMENT_OK;
 215  
 216      if (!_fckeditor_requirements_isinstalled()) {
 217        $sourcepath = fckeditor_path(TRUE);
 218  
 219        $requirements['fckeditor']['description'] = t('FCKeditor was not found at %sourcepath', array('%sourcepath' => $sourcepath));
 220        $requirements['fckeditor']['severity'] = REQUIREMENT_ERROR;
 221      }
 222      elseif (($installed_version = _fckeditor_requirements_getinstalledversion()) === NULL) {
 223        $requirements['fckeditor']['description'] = t('FCKeditor version could not be determined');
 224        $requirements['fckeditor']['severity'] = REQUIREMENT_INFO;
 225      }
 226      //Let's wait with version checking until a formal way of informing about new FCKeditor releases by fckeditor.net site is available
 227      /*
 228      elseif (($available_version = _fckeditor_requirements_getavailableversion($available_version_error)) === NULL) {
 229      $requirements['fckeditor']['description'] = t('The latest available FCKeditor version could not be determined, the HTTP error while fetching the version information was: @error', array('@error' => $available_version_error));
 230      $requirements['fckeditor']['severity'] = REQUIREMENT_INFO;
 231      }
 232      elseif (version_compare($installed_version, $available_version, '<')) {
 233      $requirements['fckeditor']['severity'] = REQUIREMENT_WARNING;
 234      $requirements['fckeditor']['description'] = t('The latest available FCKeditor version is @version. You can download it at !fcklink.', array('@version' => $available_version, '!fcklink' => l('FCKeditor.net', 'http://www.fckeditor.net')));
 235      }
 236      */
 237      else {
 238        $profile_name = _fckeditor_requirements_builtin_filebrowser_enabled();
 239        if ($profile_name !== FALSE) {
 240          if (!_fckeditor_requirements_cookiedomainset()) {
 241            $requirements['fckeditor']['severity'] = REQUIREMENT_ERROR;
 242            $requirements['fckeditor']['description'] = t('You are using a feature that requires $cookie_domain to be set, but it is not set in your settings.php (either built-in filebrowser or quick uploads are enabled in the !profile profile).', array('!profile' => l($profile_name, 'admin/settings/fckeditor/edit/'. urlencode($profile_name))));
 243          }
 244          elseif ($error = _fckeditor_requirements_filemanager_config_check($profile_name)) {
 245            $requirements['fckeditor']['severity'] = REQUIREMENT_ERROR;
 246            $requirements['fckeditor']['description'] = $error;
 247          }
 248        }
 249      }
 250  
 251      // FCKeditor before 2.6.4.1 has a security problem
 252      // check if the version only contains dots and digits
 253      if (!empty($installed_version) && preg_match('#^[\d\.]+$#', $installed_version)) {
 254        if (version_compare($installed_version, '2.6.4.1', '<')) {
 255          $requirements['fckeditor']['severity'] = REQUIREMENT_WARNING;
 256          $requirements['fckeditor']['description'] = t('The installed version of FCKeditor is known to have a security problem. You can download an updated version at !fcklink.', array('!fcklink' => l('FCKeditor.net', 'http://www.fckeditor.net')));
 257        }
 258      }
 259  
 260      if (!empty($installed_version)) {
 261        $requirements['fckeditor']['value'] = $installed_version;
 262      }
 263    }
 264  
 265    return $requirements;
 266  }
 267  
 268  /**
 269   * Determines whether the FCKeditor sources are present
 270   *
 271   * It checks if fckeditor.js is present.
 272   *
 273   * This function is used by fckeditor_requirements()
 274   *
 275   * @return boolean True if FCKeditor is installed
 276   */
 277  function _fckeditor_requirements_isinstalled() {
 278    module_load_include('module', 'fckeditor');
 279    $editor_path = fckeditor_path(TRUE);
 280    $jspath = $editor_path .'/fckeditor.js';
 281  
 282    return file_exists($jspath);
 283  }
 284  
 285  /**
 286   * Fetches the version of the installed FCKeditor sources
 287   *
 288   * It tries to locate the version of the FCKeditor sources in
 289   * fckeditor.js
 290   * 
 291   * Releases have a version number such as "2.6.4.1"
 292   * SVN nightly releases have a minor version number with SVN appended: "2.6 SVN"
 293   * SVN check outs have the string "[Development]"
 294   *
 295   * This function is used by fckeditor_requirements()
 296   *
 297   * @return string Version number (eg. 2.6.2) of FCKeditor. Null if not found in fckeditor.js
 298   */
 299  function _fckeditor_requirements_getinstalledversion() {
 300    module_load_include('module', 'fckeditor');
 301    $editor_path = fckeditor_path(TRUE);
 302    $jspath = $editor_path .'/fckeditor.js';
 303  
 304    $configcontents = file_get_contents($jspath);
 305    $matches = array();
 306    if (preg_match('#FCKeditor\.prototype\.Version\s*=\s*\'([\d\.]+(?: SVN)?|\[Development\])\'\s*;#', $configcontents, $matches)) {
 307      return $matches[1];
 308    }
 309    return NULL;
 310  }
 311  
 312  /**
 313   * Executed when built-in file browser is enabled
 314   * Returns FALSE if no errors are found in config.php file, otherwise it returns an error message.
 315   *
 316   * @return string|boolean
 317   */
 318  function _fckeditor_requirements_filemanager_config_check($profile_name) {
 319    module_load_include('module', 'fckeditor');
 320    $editor_path = fckeditor_path(TRUE);
 321    $config_path = $editor_path .'/editor/filemanager/connectors/php/config.php';
 322  
 323    if (!file_exists($config_path)) {
 324      return t('!config not found. Make sure that you have uploaded all files or didn\'t remove that file accidentally.', array('!config' => 'editor/filemanager/connectors/php/config.php'));
 325    }
 326  
 327    if (!is_readable($config_path)) {
 328      return t('FCKeditor needs read permission to !config.', array('!config' => 'editor/filemanager/connectors/php/config.php'));
 329    }
 330  
 331    $config_contents = file($config_path);
 332  
 333    //not a 100% valid check, but well... let's have at least some error checking
 334    $require_once_found = FALSE;
 335    $require_once_line = 0;
 336    $userfiles_absolute_path_line = 0;
 337    $force_single_extension_line = 0;
 338  
 339    if ($config_contents)
 340    foreach ($config_contents as $line_num => $line) {
 341      //make sure it doesn't start with a comment, unfortunately we're not protected if code is commented with /* */
 342      if (!$require_once_found && strpos($line, "filemanager.config.php") !== FALSE && !preg_match(",^(?://|\#|\*|/\*),", trim($line))) {
 343        $require_once_found = TRUE;
 344        $require_once_line = $line_num;
 345      }
 346      if (!$userfiles_absolute_path_line && strpos($line, '$Config[\'UserFilesAbsolutePath\']') !== FALSE && !preg_match(",^(?://|\#|\*|/\*),", trim($line))) {
 347        $userfiles_absolute_path_line = $line_num;
 348      }
 349      if (!$force_single_extension_line && strpos($line, '$Config[\'ForceSingleExtension\']') !== FALSE && !preg_match(",^(?://|\#|\*|/\*),", trim($line))) {
 350        $force_single_extension_line = $line_num;
 351      }
 352    }
 353  
 354    if (!$require_once_found) {
 355      return t('You are using a feature that requires manual integration into config.php (either built-in filebrowser or quick uploads are enabled in the !profile profile). Read instructions about enabling built-in file browser and add "require_once ..." statement in editor/filemanager/connectors/php/config.php.', array('!profile' => l($profile_name, 'admin/settings/fckeditor/edit/'. urlencode($profile_name))));
 356    }
 357  
 358    if ($userfiles_absolute_path_line && $force_single_extension_line && (
 359    $require_once_line < $userfiles_absolute_path_line || $require_once_line > $force_single_extension_line)) {
 360      return t('You are using a feature that requires manual integration into config.php (either built-in filebrowser or quick uploads are enabled in the !profile profile). You have added "require_once ..." statement in editor/filemanager/connectors/php/config.php, but in the wrong line.', array('!profile' => l($profile_name, 'admin/settings/fckeditor/edit/'. urlencode($profile_name))));
 361    }
 362  
 363    return FALSE;
 364  }
 365  
 366  /**
 367   * Fetches the version of the latest version of FCKeditor available
 368   *
 369   * It tries to locate the latest version of FCKeditor in the source of
 370   * http://fckeditor.net/. It might fail when the connection fails.
 371   *
 372   * This function is used by fckeditor_requirements()
 373   *
 374   * @param $error string This string will be filled with the error reason or be untouched if no error occured
 375   * @return string Version number (eg. 2.6.2) of the latest version of FCKeditor. Null if an error occured
 376   */
 377  function _fckeditor_requirements_getavailableversion(&$error) {
 378    $fckpage = drupal_http_request('http://www.fckeditor.net');
 379    $matches = array();
 380    if (!isset($fckpage->error) && preg_match('#class="release_number">\s*([\d\.]+[ \w]*)<#', $fckpage->data, $matches)) {
 381      return $matches[1];
 382    }
 383    else {
 384      $error = $fckpage->error;
 385    }
 386    return NULL;
 387  }
 388  
 389  /**
 390   * Checks if any profile requires an explicit setting of $cookie_domain
 391   * in settings.php
 392   *
 393   * %cookie_domain is required when the internal filebrowser or quick upload is used
 394   *
 395   * This function is used by fckeditor_requirements()
 396   *
 397   * @return boolean True iff any profile requires $cookie_domain
 398   */
 399  function _fckeditor_requirements_builtin_filebrowser_enabled() {
 400    module_load_include('module', 'fckeditor');
 401    $profiles = fckeditor_profile_load();
 402  
 403    foreach ($profiles as $profile) {
 404      if ((isset($profile->settings['filebrowser']) && $profile->settings['filebrowser'] == 'builtin') || (isset($profile->settings['quickupload']) && $profile->settings['quickupload'] == 't')) {
 405        return $profile->name;
 406      }
 407    }
 408  
 409    return FALSE;
 410  }
 411  
 412  /**
 413   * Checks if $cookie_domain has been set
 414   *
 415   * It has to include settings.php again because conf_init() sets
 416   * $cookie_domain regardless of its presence in settings.php, so
 417   * simply checking $GLOBALS['cookie_domain'] is not possible.
 418   *
 419   * This function is used by fckeditor_requirements()
 420   *
 421   * @return boolean True iff $cookie_domain was set in settings.php
 422   */
 423  function _fckeditor_requirements_cookiedomainset() {
 424    if (file_exists('./'. conf_path() .'/settings.php')) {
 425      $settings = file_get_contents('./'. conf_path() .'/settings.php');
 426  
 427      if (preg_match('#^\s*\$cookie_domain#m', $settings)) {
 428        return TRUE;
 429      }
 430    }
 431  
 432    return FALSE;
 433  }
 434  
 435  /**
 436   * Update from 6.x-1.0 to 6.x-1.1
 437   *
 438   */
 439  function fckeditor_update_6110() {
 440    $ret = array();
 441  
 442    $result = db_query("SELECT * FROM {fckeditor_settings}");
 443    $global_profile_found = FALSE;
 444    while (($data = db_fetch_object($result))) {
 445      if ($data->name == "FCKeditor Global Profile") {
 446        $global_profile_found = TRUE;
 447      }
 448      if ($data->settings) {
 449        $settings = unserialize($data->settings);
 450      }
 451      if (isset($settings['excl_mode'], $settings['excl_list']) && !empty($settings['excl_list'])) {
 452        switch ($settings['excl_mode']) {
 453          case 0:
 454            // normal exclusion based on the id
 455            $settings['excl_fields'] = $settings['excl_list'];
 456            $settings['excl_mode'] = 0;
 457            break;
 458  
 459          case 1:
 460            //normal inclusion based on the id
 461            $settings['excl_fields'] = $settings['excl_list'];
 462            $settings['excl_mode'] = 1;
 463            break;
 464  
 465          case 2:
 466            //path exclusion
 467            $settings['excl_paths'] = $settings['excl_list'];
 468            $settings['excl_mode'] = 0;
 469            break;
 470  
 471          case 3:
 472            //path inclusion
 473            $settings['excl_paths'] = $settings['excl_list'];
 474            $settings['excl_mode'] = 1;
 475            break;
 476        }
 477        unset($settings['excl_list']);
 478      }
 479      if (isset($settings['simple_incl_mode'], $settings['simple_incl_list']) && !empty($settings['simple_incl_list'])) {
 480        switch ($settings['simple_incl_mode']) {
 481          case 1:
 482            //normal inclusion based on the id
 483            $settings['simple_incl_fields'] = $settings['simple_incl_list'];
 484            break;
 485  
 486          case 3:
 487            //path inclusion
 488            $settings['simple_incl_paths'] = $settings['simple_incl_list'];
 489            break;
 490        }
 491        unset($settings['simple_incl_mode']);
 492        unset($settings['simple_incl_list']);
 493      }
 494  
 495      db_query("UPDATE {fckeditor_settings} SET settings='%s' WHERE name='%s'", serialize($settings), $data->name);
 496    }
 497  
 498    if (!$global_profile_found) {
 499      db_query("INSERT INTO {fckeditor_settings} (name, settings) VALUES ('%s', '%s')", "FCKeditor Global Profile", serialize(array()));
 500    }
 501    return $ret;
 502  }
 503  
 504  /**
 505   * Update from 6.x-1.2 to 6.x-1.3
 506   *
 507   * Change file browser selection method
 508   */
 509  function fckeditor_update_6130() {
 510    $ret = array();
 511  
 512    $result = db_query("SELECT * FROM {fckeditor_settings} WHERE name <> 'FCKeditor Global Profile'");
 513    $hasimce = module_exists('imce');
 514    while (($data = db_fetch_object($result))) {
 515      if ($data->settings) {
 516        $settings = unserialize($data->settings);
 517  
 518        // Rewrite imce, upload_basic and upload_advanced settings to filebrowser and quickupload
 519        $imce = ($hasimce && isset($settings['imce']) && $settings['imce'] == 't');
 520        $upload_basic = (isset($settings['upload_basic']) && $settings['upload_basic'] == 't');
 521        $upload_advanced = (isset($settings['upload_advanced']) && $settings['upload_advanced'] == 't');
 522  
 523        if ($imce) {
 524          $settings['filebrowser'] = 'imce';
 525        }
 526        elseif ($upload_advanced) {
 527          $settings['filebrowser'] = 'builtin';
 528        }
 529        else {
 530          $settings['filebrowser'] = 'none';
 531        }
 532  
 533        $settings['quickupload'] = $upload_basic ? 't' : 'f';
 534  
 535        unset($settings['imce'], $settings['upload_basic'], $settings['upload_advanced']);
 536  
 537        // unfortunately, update_sql is not an option, as serialize($settings) will contain curly braces which will
 538        // be replaced. update_sql does not support arguments like db_query() does.
 539  
 540        db_query("UPDATE {fckeditor_settings} SET settings='%s' WHERE name='%s'", serialize($settings), $data->name);
 541      }
 542    }
 543  
 544    return $ret;
 545  }
 546  
 547  /**
 548   * Update from 6.x-1.x to 6.x-2.x
 549   *
 550   * Change storage of exclusion modes
 551   */
 552  function fckeditor_update_6200() {
 553    $ret = array();
 554  
 555    $result = db_query("SELECT * FROM {fckeditor_settings}");
 556    while (($data = db_fetch_object($result))) {
 557      if ($data->settings) {
 558        $settings = unserialize($data->settings);
 559  
 560        foreach (array('simple_incl', 'excl') as $var) {
 561          $paths = preg_split('/[\s,]+/', $settings[$var .'_paths']);
 562          $ids = preg_split('/[\s,]+/', $settings[$var .'_fields']);
 563          $final = array();
 564  
 565          foreach ($paths as $path) {
 566            $path = trim($path);
 567            if (!empty($path)) {
 568              $final[] = $path .'.*';
 569            }
 570          }
 571  
 572          foreach ($ids as $id) {
 573            $id = trim($id);
 574            if (!empty($id)) {
 575              $final[] = '*.'. $id;
 576            }
 577          }
 578  
 579          $settings[$var] = implode("\n", $final);
 580          unset($settings[$var .'_paths'], $settings[$var .'_fields']);
 581        }
 582  
 583        db_query("UPDATE {fckeditor_settings} SET settings='%s' WHERE name='%s'", serialize($settings), $data->name);
 584  
 585        module_load_include('inc', 'fckeditor', 'fckeditor.admin');
 586        fckeditor_rebuild_selectors();
 587      }
 588    }
 589  
 590    return $ret;
 591  }
 592  
 593  /**
 594   * Update from 6.x-1.x to 6.x-2.x
 595   *
 596   * Add show_fieldnamehint setting, defaults to t ( = true)
 597   */
 598  function fckeditor_update_6201() {
 599    $ret = array();
 600  
 601    $result = db_query("SELECT * FROM {fckeditor_settings}");
 602    while (($data = db_fetch_object($result))) {
 603      if ($data->settings) {
 604        $settings = unserialize($data->settings);
 605        $settings['show_fieldnamehint'] = 't';
 606  
 607        db_query("UPDATE {fckeditor_settings} SET settings='%s' WHERE name='%s'", serialize($settings), $data->name);
 608      }
 609    }
 610  
 611    return $ret;
 612  }
 613  
 614  /**
 615    * Add autofixplaintext setting, defaults to f ( = false)
 616   */
 617  function fckeditor_update_6202() {
 618    $ret = array();
 619  
 620    $result = db_query("SELECT * FROM {fckeditor_settings}");
 621    while (($data = db_fetch_object($result))) {
 622      if ($data->settings) {
 623        $settings = unserialize($data->settings);
 624        $settings['autofixplaintext'] = 'f';
 625  
 626        db_query("UPDATE {fckeditor_settings} SET settings='%s' WHERE name='%s'", serialize($settings), $data->name);
 627      }
 628    }
 629  
 630    return $ret;
 631  }
 632  
 633  /**
 634   * Implementation of hook_uninstall().
 635   */
 636  function fckeditor_uninstall() {
 637    drupal_uninstall_schema('fckeditor');
 638  }


Generated: Mon Jul 9 18:01:44 2012 Cross-referenced by PHPXref 0.7