You are here

function wysiwyg_user in Wysiwyg 6.2

Same name and namespace in other branches
  1. 5.2 wysiwyg.module \wysiwyg_user()
  2. 5 wysiwyg.module \wysiwyg_user()
  3. 6 wysiwyg.module \wysiwyg_user()

Implementation of hook_user().

2 string references to 'wysiwyg_user'
wysiwyg_update_6201 in ./wysiwyg.install
Create the {wysiwyg_user} table.
wysiwyg_update_6204 in ./wysiwyg.install
Add primary index to {wysiwyg_user}.

File

./wysiwyg.module, line 859
Integrates client-side editors with Drupal.

Code

function wysiwyg_user($op, &$edit, $account, $category = NULL) {
  if ($op == 'form' && $category == 'account') {
    $user_formats = filter_formats();
    $options = array();
    $options_default = array();
    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] = check_plain($user_formats[$format]->name);
        if (wysiwyg_user_get_status($profile, $account)) {
          $options_default[] = $format;
        }
      }
    }
    if (!empty($options)) {
      $form['wysiwyg']['wysiwyg_status'] = array(
        '#type' => 'checkboxes',
        '#title' => t('Text formats enabled for rich-text editing'),
        '#options' => $options,
        '#default_value' => $options_default,
      );
      return $form;
    }
  }
  elseif ($op == 'insert' || $op == 'update') {
    if (isset($edit['wysiwyg_status'])) {
      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(
          $account->uid,
          $format,
          (int) (bool) $status,
        ));
      }
    }
  }
}