You are here

function wysiwyg_user_get_status in Wysiwyg 6.2

Same name and namespace in other branches
  1. 5.2 wysiwyg.module \wysiwyg_user_get_status()
  2. 5 wysiwyg.module \wysiwyg_user_get_status()
  3. 6 wysiwyg.module \wysiwyg_user_get_status()
  4. 7.2 wysiwyg.module \wysiwyg_user_get_status()
2 calls to wysiwyg_user_get_status()
wysiwyg_process_form in ./wysiwyg.module
Process a textarea for Wysiwyg Editor.
wysiwyg_user in ./wysiwyg.module
Implementation of hook_user().

File

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

Code

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($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)) {
      $account->wysiwyg_status[$row->format] = $row->status;
    }
  }
  if (!empty($profile->preferences['user_choose']) && isset($account->wysiwyg_status[$profile->format])) {
    $status = $account->wysiwyg_status[$profile->format];
  }
  else {
    $status = isset($profile->preferences['default']) ? $profile->preferences['default'] : TRUE;
  }
  return (bool) $status;
}