You are here

function tinymce_user in TinyMCE 6

Same name and namespace in other branches
  1. 5.2 tinymce.module \tinymce_user()
  2. 5 tinymce.module \tinymce_user()
  3. 6.2 tinymce.module \tinymce_user()

Implementation of hook_user().

File

./tinymce.module, line 266
Integrate the TinyMCE editor (http://tinymce.moxiecode.com/) into Drupal.

Code

function tinymce_user($type, &$edit, &$user, $category = NULL) {
  if ($type == 'form' && $category == 'account' && user_access('access tinymce')) {
    $profile = tinymce_user_get_profile($user);

    // because the settings are saved as strings we need to test for the string 'true'
    if ($profile->settings['user_choose'] == 'true') {
      $form['tinymce'] = array(
        '#type' => 'fieldset',
        '#title' => t('TinyMCE rich-text settings'),
        '#weight' => 10,
        '#collapsible' => TRUE,
        '#collapsed' => TRUE,
      );
      $form['tinymce']['tinymce_status'] = array(
        '#type' => 'select',
        '#title' => t('Default state'),
        '#default_value' => isset($user->tinymce_status) ? $user->tinymce_status : (isset($profile->settings['default']) ? $profile->settings['default'] : 'false'),
        '#options' => array(
          'false' => t('disabled'),
          'true' => t('enabled'),
        ),
        '#description' => t('Should rich-text editing be enabled or disabled by default in textarea fields?'),
      );
      return array(
        'tinymce' => $form,
      );
    }
  }
  if ($type == 'validate') {
    return array(
      'tinymce_status' => $edit['tinymce_status'],
    );
  }
}