You are here

function fckeditor_user_get_profile in FCKeditor - WYSIWYG HTML editor 5.2

Same name and namespace in other branches
  1. 6.2 fckeditor.module \fckeditor_user_get_profile()
  2. 6 fckeditor.module \fckeditor_user_get_profile()
2 calls to fckeditor_user_get_profile()
fckeditor_process_textarea in ./fckeditor.module
This function create the HTML objects required for the FCKeditor
fckeditor_user in ./fckeditor.module
Implementation of hook_user().

File

./fckeditor.module, line 2217
FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2007 Frederico Caldeira Knabben

Code

function fckeditor_user_get_profile($user, $clear = FALSE) {
  static $profile_name = NULL;
  if ($clear === TRUE || $profile_name == NULL) {
    $profile_name = array();
  }

  // Since fckeditor_profile_load() makes a db hit, only call it when we're pretty sure
  // we're gonna render fckeditor.
  if (!isset($profile_name[$user->uid])) {
    $sorted_roles = fckeditor_sorted_roles();
    foreach ($sorted_roles as $rid => $name) {
      if (isset($user->roles[$rid])) {
        break;
      }
    }
    if (isset($user->roles[$rid])) {
      $profile_name[$user->uid] = db_result(db_query("SELECT s.name FROM {fckeditor_settings} s INNER JOIN {fckeditor_role} r ON r.name = s.name WHERE r.rid='%s'", $rid));
    }
    else {
      if ($user->uid == "1") {
        $profile_name[$user->uid] = db_result(db_query_range("SELECT s.name FROM {fckeditor_settings} s INNER JOIN {fckeditor_role} r ON r.name = s.name ORDER BY r.rid DESC", 1));
      }
    }
  }
  if (isset($profile_name[$user->uid]) && $profile_name[$user->uid]) {
    $profile = fckeditor_profile_load($profile_name[$user->uid]);
    return $profile;
  }
  return FALSE;
}