You are here

function ckeditor_user_get_profile in CKEditor - WYSIWYG HTML editor 6

4 calls to ckeditor_user_get_profile()
ckeditor_filter_xss in includes/ckeditor.page.inc
AJAX callback - XSS filter
ckeditor_get_settings in ./ckeditor.module
ckeditor_process_textarea in ./ckeditor.module
This function creates the HTML objects required for CKEditor.
ckeditor_user_delegate in includes/ckeditor.user.inc
CKEditor - The text editor for the Internet - http://ckeditor.com Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.

File

includes/ckeditor.lib.inc, line 509
CKEditor - The text editor for the Internet - http://ckeditor.com Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.

Code

function ckeditor_user_get_profile($user, $element_id = 'edit-body', $url = NULL) {
  $rids = array();
  if (is_null($url)) {
    $url = $_GET['q'];
  }

  // Since ckeditor_profile_load() makes a db hit, only call it when we're pretty sure
  // we're gonna render ckeditor.
  $sorted_roles = ckeditor_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 {ckeditor_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 {ckeditor_settings} s INNER JOIN {ckeditor_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 = ckeditor_profile_load($profile_name);
        $conf = $profile->settings;
        $enabled = ckeditor_is_enabled(empty($conf['excl_mode']) ? '0' : $conf['excl_mode'], empty($conf['excl_regex']) ? '' : $conf['excl_regex'], $element_id, $url);
        if ($enabled) {
          return $profile;
        }
      }
    }
  }
  return FALSE;
}