You are here

function fckeditor_user_get_profile in FCKeditor - WYSIWYG HTML editor 6.2

Same name and namespace in other branches
  1. 5.2 fckeditor.module \fckeditor_user_get_profile()
  2. 6 fckeditor.module \fckeditor_user_get_profile()
3 calls to fckeditor_user_get_profile()
fckeditor_filter_xss in ./fckeditor.module
AJAX callback - XSS filter
fckeditor_process_textarea in ./fckeditor.module
This function create the HTML objects required for the FCKeditor
fckeditor_user_delegate in ./fckeditor.user.inc
FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2008 Frederico Caldeira Knabben

File

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

Code

function fckeditor_user_get_profile($user, $element_id = NULL) {
  $rids = array();

  // Since fckeditor_profile_load() makes a db hit, only call it when we're pretty sure
  // we're gonna render fckeditor.
  $sorted_roles = fckeditor_sorted_roles();
  foreach (array_keys($sorted_roles) as $rid) {
    if (isset($user->roles[$rid])) {
      $rids[] = $rid;
    }
  }
  if ($user->uid == 1 && !sizeof($rids)) {
    $r = db_fetch_object(db_query_range("SELECT r.rid FROM {fckeditor_role} r ORDER BY r.rid DESC", 1));
    $rids[] = $r->rid;
  }
  $profile_names = array();
  if (sizeof($rids)) {
    $result = db_query("SELECT r.rid, s.name FROM {fckeditor_settings} s INNER JOIN {fckeditor_role} r ON r.name = s.name WHERE r.rid IN (" . implode(",", $rids) . ")");
    while ($row = db_fetch_array($result)) {
      if (!isset($profile_names[$row['rid']])) {
        $profile_names[$row['rid']] = array();
      }
      array_push($profile_names[$row['rid']], $row['name']);
    }
  }
  foreach ($rids as $rid) {
    if (!empty($profile_names[$rid])) {
      foreach ($profile_names[$rid] as $profile_name) {
        $profile = fckeditor_profile_load($profile_name);
        $conf = $profile->settings;
        $enabled = fckeditor_is_enabled(empty($conf['excl_mode']) ? '0' : $conf['excl_mode'], empty($conf['excl_regex']) ? '' : $conf['excl_regex'], $element_id, $_GET['q']);
        if ($enabled) {
          return $profile;
        }
      }
    }
  }
  return FALSE;
}