Index: wysiwyg.install =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/wysiwyg/wysiwyg.install,v retrieving revision 1.4.2.5 diff -u -p -r1.4.2.5 wysiwyg.install --- wysiwyg.install 6 Jan 2011 00:42:47 -0000 1.4.2.5 +++ wysiwyg.install 6 Jan 2011 01:45:09 -0000 @@ -11,6 +11,7 @@ function wysiwyg_schema() { 'format' => array( 'description' => 'The {filter_formats}.format of the text format.', 'type' => 'int', + // Primary keys are implicitly not null. 'not null' => TRUE, 'default' => 0, ), @@ -48,8 +49,7 @@ function wysiwyg_schema() { 'format' => array( 'description' => 'The {filter_formats}.format of the text format.', 'type' => 'int', - 'not null' => TRUE, - 'default' => 0, + 'not null' => FALSE, ), 'status' => array( 'description' => 'Boolean indicating whether the format is enabled by default.', @@ -248,17 +248,16 @@ function wysiwyg_update_6201() { 'description' => 'Stores user preferences for wysiwyg profiles.', 'fields' => array( 'uid' => array( + 'description' => 'The {users}.uid of the user.', 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, - 'description' => 'The {users}.uid of the user.', ), 'format' => array( 'description' => 'The {filter_formats}.format of the text format.', 'type' => 'int', - 'not null' => TRUE, - 'default' => 0, + 'not null' => FALSE, ), 'status' => array( 'description' => 'Boolean indicating whether the format is enabled by default.', Index: wysiwyg.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/wysiwyg/wysiwyg.module,v retrieving revision 1.33.2.13 diff -u -p -r1.33.2.13 wysiwyg.module --- wysiwyg.module 5 Jan 2011 00:45:57 -0000 1.33.2.13 +++ wysiwyg.module 6 Jan 2011 01:48:22 -0000 @@ -626,7 +626,7 @@ function wysiwyg_profile_load_all() { /** * Implementation of hook_user(). */ -function wysiwyg_user($op, &$edit, &$user, $category = NULL) { +function wysiwyg_user($op, &$edit, $account, $category = NULL) { if ($op == 'form' && $category == 'account') { $user_formats = filter_formats(); $options = array(); @@ -634,28 +634,28 @@ function wysiwyg_user($op, &$edit, &$use foreach (wysiwyg_profile_load_all() as $format => $profile) { // Only show profiles that have user_choose enabled. if (!empty($profile->settings['user_choose']) && isset($user_formats[$format])) { - $options[$format] = $user_formats[$format]->name; - if (wysiwyg_user_get_status($profile)) { + $options[$format] = check_plain($user_formats[$format]->name); + if (wysiwyg_user_get_status($profile, $account)) { $options_default[] = $format; } } } if (!empty($options)) { - $form['wysiwyg_status'] = array( + $form['wysiwyg']['wysiwyg_status'] = array( '#type' => 'checkboxes', - '#title' => t('Input formats enabled for rich-text editing'), - '#default_value' => $options_default, + '#title' => t('Text formats enabled for rich-text editing'), '#options' => $options, + '#default_value' => $options_default, ); - return array('wysiwyg' => $form); + return $form; } } elseif ($op == 'insert' || $op == 'update') { if (isset($edit['wysiwyg_status'])) { - db_query("DELETE FROM {wysiwyg_user} WHERE uid = %d", $user->uid); + db_query("DELETE FROM {wysiwyg_user} WHERE uid = %d", $account->uid); foreach ($edit['wysiwyg_status'] as $format => $status) { db_query("INSERT INTO {wysiwyg_user} (uid, format, status) VALUES (%d, %d, %d)", array( - $user->uid, + $account->uid, $format, (int) (bool) $status, )); @@ -664,21 +664,25 @@ function wysiwyg_user($op, &$edit, &$use } } -function wysiwyg_user_get_status($profile) { +function wysiwyg_user_get_status($profile, $account = NULL) { global $user; + if (!isset($account)) { + $account = $user; + } + // Default wysiwyg editor status information is only required on forms, so we // do not pre-emptively load and attach this information on every user_load(). - if (!isset($user->wysiwyg_status)) { - $user->wysiwyg_status = array(); - $result = db_query("SELECT format, status FROM {wysiwyg_user} WHERE uid = %d", $user->uid); + if (!isset($account->wysiwyg_status)) { + $account->wysiwyg_status = array(); + $result = db_query("SELECT format, status FROM {wysiwyg_user} WHERE uid = %d", $account->uid); while ($row = db_fetch_object($result)) { - $user->wysiwyg_status[$row->format] = $row->status; + $account->wysiwyg_status[$row->format] = $row->status; } } - if (!empty($profile->settings['user_choose']) && isset($user->wysiwyg_status[$profile->format])) { - $status = $user->wysiwyg_status[$profile->format]; + if (!empty($profile->settings['user_choose']) && isset($account->wysiwyg_status[$profile->format])) { + $status = $account->wysiwyg_status[$profile->format]; } else { $status = isset($profile->settings['default']) ? $profile->settings['default'] : TRUE;