You are here

function fckeditor_admin_main in FCKeditor - WYSIWYG HTML editor 6.2

Main administrative page

1 string reference to 'fckeditor_admin_main'
fckeditor_menu in ./fckeditor.module
Implementation of hook_menu().

File

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

Code

function fckeditor_admin_main() {
  $editor_path = fckeditor_path(TRUE);
  $fckconfig_file = $editor_path . '/fckconfig.js';
  if (!file_exists($fckconfig_file)) {
    drupal_set_message(t('The FCKeditor component appears to be not installed correctly, because %checkfile could not be found.', array(
      '%checkfile' => $fckconfig_file,
    )) . '<br/>' . t('Please go to the !fckeditorlink to download the latest version. After that you must extract the files to %fckeditorpath and make sure that the directory %fckeditorsubdir and the file %fckeditorfile exist. Refer to the !readme for more information.', array(
      '!fckeditorlink' => l(t('FCKeditor homepage'), 'http://ckeditor.com/download'),
      '!readme' => l(t('readme.txt'), 'admin/help/fckeditor'),
      '%fckeditorpath' => $editor_path,
      '%fckeditorsubdir' => $editor_path . '/editor',
      '%fckeditorfile' => $editor_path . '/fckeditor.js',
    )), 'error');
    drupal_set_message(t('If you have FCKeditor already installed please edit !editgloballink and update FCKeditor path.', array(
      '!editgloballink' => l(t('FCKeditor Global Profile'), 'admin/settings/fckeditor/editg'),
    )), 'warning');
    return FALSE;
  }
  $access_fckeditor_roles = user_roles(FALSE, 'access fckeditor');
  if (!$access_fckeditor_roles) {
    drupal_set_message(t('There is currently no role with the %accesspermission permission. Visit !permissionslink administration section.', array(
      '%accesspermission' => t('access fckeditor'),
      '!permissionslink' => l(t('permissions'), 'admin/user/permissions'),
    )), 'warning');
  }
  else {
    $result = db_query_range("SELECT name FROM {fckeditor_settings} WHERE name <> 'FCKeditor Global Profile'", 0, 1);
    $has_profiles = FALSE;

    //find profile other than Global
    if ($obj = db_fetch_object($result)) {
      $has_profiles = TRUE;
    }

    //find roles with profiles
    $result = db_query("SELECT rid FROM {fckeditor_role}");
    $rids = array();
    while ($obj = db_fetch_object($result)) {
      $rids[] = $obj->rid;
    }
    $rids = array_unique($rids);
    if (!$has_profiles) {
      drupal_set_message(t('No FCKeditor profiles found. At this moment, nobody is able to use FCKeditor. Create new profile below.'), 'error');
    }
    else {

      //not all roles with access fckeditor has their FCKeditor profile assigned
      $diff = array_diff(array_keys($access_fckeditor_roles), $rids);
      if ($diff) {
        $items = array();
        foreach ($diff as $rid) {
          $items[] = $access_fckeditor_roles[$rid];
        }
        drupal_set_message(t('Not all roles with %accesspermission permission are associated with FCKeditor profiles. As a result, users having the following roles may be unable to use FCKeditor: !list Create new or edit FCKeditor profiles below and in the %basicsetupsection section, check %rolesetting.', array(
          '%accesspermission' => t('access fckeditor'),
          '%basicsetupsection' => t('Basic setup'),
          '%rolesetting' => t('Roles allowed to use this profile'),
          '!list' => theme('item_list', $items),
        )), 'warning');
      }
    }
  }
  return fckeditor_profile_overview();
}