format] = $format->name; // Fetch filters. $result2 = db_query("SELECT module, delta FROM {filters} WHERE format = %d", $format->format); while ($filter = db_fetch_object($result2)) { // If PHP filter is enabled, remove this format. if ($filter->module == 'filter' && $filter->delta == 1) { unset($formats[$format->format]); break; } } } return $formats; } /** * Associate Wysiwyg profiles with input formats. * * Since there was no association yet, we can only assume that there is one * profile only, and that profile must be duplicated and assigned to all input * formats (except PHP code format). Also, input formats already have * titles/names, so Wysiwyg profiles do not need an own. * * Because input formats are already granted to certain user roles only, we can * remove our custom Wysiwyg profile permissions. A 1:1 relationship between * input formats and permissions makes plugin_count obsolete, too. * * Since the resulting table is completely different, a new schema is installed. */ function wysiwyg_update_5001() { $ret = array(); if (db_table_exists('wysiwyg')) { return $ret; } // Install new schema. switch ($GLOBALS['db_type']) { case 'mysql': case 'mysqli': $ret[] = update_sql("CREATE TABLE {wysiwyg} ( format int NOT NULL default '0', editor varchar(128) NOT NULL default '', settings text, PRIMARY KEY (format) ) /*!40100 DEFAULT CHARACTER SET utf8 */"); break; case 'pgsql': $ret[] = update_sql("CREATE TABLE {wysiwyg} ( format int NOT NULL default '0', editor varchar(128) NOT NULL default '', settings text, PRIMARY KEY (format) )"); break; } // Fetch all input formats. $formats = _wysiwyg_install_get_formats(); // Fetch all profiles. $result = db_query("SELECT name, settings FROM {wysiwyg_profile}"); while ($profile = db_fetch_object($result)) { $profile->settings = unserialize($profile->settings); // Extract editor name from profile settings. $profile->editor = $profile->settings['editor']; // Clean-up. unset($profile->settings['editor']); unset($profile->settings['old_name']); unset($profile->settings['name']); unset($profile->settings['rids']); // Sorry. There Can Be Only One. ;) break; } if ($profile) { // Rebuild profiles and associate with input formats. foreach ($formats as $format => $name) { // Insert profiles. // We can't use update_sql() here because of curly braces in serialized // array. db_query("INSERT INTO {wysiwyg} (format, editor, settings) VALUES (%d, '%s', '%s')", $format, $profile->editor, serialize($profile->settings)); $ret[] = array( 'success' => TRUE, 'query' => strtr('Wysiwyg profile %profile converted and associated with input format %format.', array('%profile' => check_plain($profile->name), '%format' => check_plain($name))), ); } } // Drop obsolete tables {wysiwyg_profile} and {wysiwyg_role}. $ret[] = update_sql("DROP TABLE {wysiwyg_profile}"); $ret[] = update_sql("DROP TABLE {wysiwyg_role}"); return $ret; }