123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533 |
- <?php
- /**
- * options_display.php
- *
- * Copyright (c) 1999-2004 The SquirrelMail Project Team
- * Licensed under the GNU GPL. For full terms see the file COPYING.
- *
- * Displays all optinos about display preferences
- *
- * @version $Id$
- * @package squirrelmail
- */
- /** Define the group constants for the display options page. */
- define('SMOPT_GRP_GENERAL', 0);
- define('SMOPT_GRP_MAILBOX', 1);
- define('SMOPT_GRP_MESSAGE', 2);
- // load icon themes if in use
- global $use_icons;
- if ($use_icons) {
- global $icon_themes;
- $dirName = SM_PATH . 'images/themes';
- if (is_readable($dirName) && is_dir($dirName)) {
- $d = dir($dirName);
- while($dir = $d->read()) {
- if ($dir != "." && $dir != "..") {
- if (is_dir($dirName."/".$dir) && file_exists("$dirName/$dir/theme.php"))
- include("$dirName/$dir/theme.php");
- }
- }
- }
- }
- /**
- * This function builds an array with all the information about
- * the options available to the user, and returns it. The options
- * are grouped by the groups in which they are displayed.
- * For each option, the following information is stored:
- * - name: the internal (variable) name
- * - caption: the description of the option in the UI
- * - type: one of SMOPT_TYPE_*
- * - refresh: one of SMOPT_REFRESH_*
- * - size: one of SMOPT_SIZE_*
- * - save: the name of a function to call when saving this option
- * @return array all option information
- */
- function load_optpage_data_display() {
- global $theme, $language, $languages, $js_autodetect_results, $javascript_setting,
- $compose_new_win, $default_use_mdn, $squirrelmail_language, $allow_thread_sort,
- $optmode, $show_alternative_names, $available_languages, $use_icons;
- /* Build a simple array into which we will build options. */
- $optgrps = array();
- $optvals = array();
- /******************************************************/
- /* LOAD EACH GROUP OF OPTIONS INTO THE OPTIONS ARRAY. */
- /******************************************************/
- /*** Load the General Options into the array ***/
- $optgrps[SMOPT_GRP_GENERAL] = _("General Display Options");
- $optvals[SMOPT_GRP_GENERAL] = array();
- /* Load the theme option. */
- $theme_values = array();
- foreach ($theme as $theme_key => $theme_attributes) {
- $theme_values[$theme_attributes['NAME']] = $theme_attributes['PATH'];
- }
- ksort($theme_values);
- $theme_values = array_flip($theme_values);
- $optvals[SMOPT_GRP_GENERAL][] = array(
- 'name' => 'chosen_theme',
- 'caption' => _("Theme"),
- 'type' => SMOPT_TYPE_STRLIST,
- 'refresh' => SMOPT_REFRESH_ALL,
- 'posvals' => $theme_values,
- 'save' => 'save_option_theme'
- );
- $css_values = array( 'none' => _("Default" ) );
- if (is_readable(SM_PATH . 'themes/css') && is_dir(SM_PATH . 'themes/css')) {
- $handle=opendir(SM_PATH . 'themes/css');
- while ($file = readdir($handle) ) {
- if ( substr( $file, -4 ) == '.css' ) {
- $css_values[$file] = substr( $file, 0, strlen( $file ) - 4 );
- }
- }
- closedir($handle);
- }
- if ( count( $css_values ) > 1 ) {
- $optvals[SMOPT_GRP_GENERAL][] = array(
- 'name' => 'custom_css',
- 'caption' => _("Custom Stylesheet"),
- 'type' => SMOPT_TYPE_STRLIST,
- 'refresh' => SMOPT_REFRESH_ALL,
- 'posvals' => $css_values
- );
- }
- // config.php can be unupdated.
- if (! isset($available_languages) || $available_languages=="" ) {
- $available_languages="ALL"; }
- $language_values = array();
- if ( strtoupper($available_languages)=='ALL') {
- foreach ($languages as $lang_key => $lang_attributes) {
- if (isset($lang_attributes['NAME'])) {
- $language_values[$lang_key] = $lang_attributes['NAME'];
- if ( isset($show_alternative_names) &&
- $show_alternative_names &&
- isset($lang_attributes['ALTNAME']) ) {
- $language_values[$lang_key] .= " / " . $lang_attributes['ALTNAME'];
- }
- }
- }
- } else if (strtoupper($available_languages)!='NONE') {
- // admin can set list of available languages in config
- $available_languages_array=explode (" ",$available_languages);
- foreach ($available_languages_array as $lang_key ) {
- if (isset($languages[$lang_key]['NAME'])) {
- $language_values[$lang_key] = $languages[$lang_key]['NAME'];
- if ( isset($show_alternative_names) &&
- $show_alternative_names &&
- isset($languages[$lang_key]['ALTNAME']) ) {
- $language_values[$lang_key] .= " / " . $languages[$lang_key]['ALTNAME'];
- }
- }
- }
- }
- asort($language_values);
- $language_values =
- array_merge(array('' => _("Default")), $language_values);
- $language = $squirrelmail_language;
- if (strtoupper($available_languages)!='NONE') {
- // if set to 'none', interface will use only default language
- $optvals[SMOPT_GRP_GENERAL][] = array(
- 'name' => 'language',
- 'caption' => _("Language"),
- 'type' => SMOPT_TYPE_STRLIST,
- 'refresh' => SMOPT_REFRESH_ALL,
- 'posvals' => $language_values
- );
- }
- /* Set values for the "use javascript" option. */
- $optvals[SMOPT_GRP_GENERAL][] = array(
- 'name' => 'javascript_setting',
- 'caption' => _("Use Javascript"),
- 'type' => SMOPT_TYPE_STRLIST,
- 'refresh' => SMOPT_REFRESH_ALL,
- 'posvals' => array(SMPREF_JS_AUTODETECT => _("Autodetect"),
- SMPREF_JS_ON => _("Always"),
- SMPREF_JS_OFF => _("Never")),
- 'save' => 'save_option_javascript_autodetect',
- 'script' => 'onclick="document.forms[0].new_js_autodetect_results.value = \'' . SMPREF_JS_ON . '\';"'
- );
- $optvals[SMOPT_GRP_GENERAL][] = array(
- 'name' => 'js_autodetect_results',
- 'caption' => '',
- 'type' => SMOPT_TYPE_HIDDEN,
- 'refresh' => SMOPT_REFRESH_NONE
- //'post_script' => $js_autodetect_script,
- );
- /*** Load the General Options into the array ***/
- $optgrps[SMOPT_GRP_MAILBOX] = _("Mailbox Display Options");
- $optvals[SMOPT_GRP_MAILBOX] = array();
- $optvals[SMOPT_GRP_MAILBOX][] = array(
- 'name' => 'show_num',
- 'caption' => _("Number of Messages to Index"),
- 'type' => SMOPT_TYPE_INTEGER,
- 'refresh' => SMOPT_REFRESH_NONE,
- 'size' => SMOPT_SIZE_TINY
- );
- $optvals[SMOPT_GRP_MAILBOX][] = array(
- 'name' => 'alt_index_colors',
- 'caption' => _("Enable Alternating Row Colors"),
- 'type' => SMOPT_TYPE_BOOLEAN,
- 'refresh' => SMOPT_REFRESH_NONE
- );
- if ($use_icons) {
- global $icon_themes, $icon_theme;
- $temp = array();
- for ($count = 0; $count < sizeof($icon_themes); $count++) {
- $temp[$count] = $icon_themes[$count]['NAME'];
- if ($icon_theme == $icon_themes[$count]['PATH'])
- $value = $count;
- }
- if (sizeof($icon_themes) > 0) {
- $optvals[SMOPT_GRP_MAILBOX][] = array(
- 'name' => 'icon_theme',
- 'caption' => _("Message Flags Icon Theme"),
- 'type' => SMOPT_TYPE_STRLIST,
- 'refresh' => SMOPT_REFRESH_NONE,
- 'posvals' => $temp,
- 'initial_value' => $value,
- 'save' => 'icon_theme_save'
- );
- }
- }
- $optvals[SMOPT_GRP_MAILBOX][] = array(
- 'name' => 'show_flag_buttons',
- 'caption' => _("Show Flag / Unflag Buttons"),
- 'type' => SMOPT_TYPE_BOOLEAN,
- 'refresh' => SMOPT_REFRESH_NONE
- );
- $optvals[SMOPT_GRP_MAILBOX][] = array(
- 'name' => 'page_selector',
- 'caption' => _("Enable Page Selector"),
- 'type' => SMOPT_TYPE_BOOLEAN,
- 'refresh' => SMOPT_REFRESH_NONE
- );
- $optvals[SMOPT_GRP_MAILBOX][] = array(
- 'name' => 'page_selector_max',
- 'caption' => _("Maximum Number of Pages to Show"),
- 'type' => SMOPT_TYPE_INTEGER,
- 'refresh' => SMOPT_REFRESH_NONE,
- 'size' => SMOPT_SIZE_TINY
- );
- $optvals[SMOPT_GRP_MAILBOX][] = array(
- 'name' => 'show_full_date',
- 'caption' => _("Always Show Full Date"),
- 'type' => SMOPT_TYPE_BOOLEAN,
- 'refresh' => SMOPT_REFRESH_NONE
- );
- $optvals[SMOPT_GRP_MAILBOX][] = array(
- 'name' => 'truncate_sender',
- 'caption' => _("Length of From/To Field (0 for full)"),
- 'type' => SMOPT_TYPE_INTEGER,
- 'refresh' => SMOPT_REFRESH_NONE,
- 'size' => SMOPT_SIZE_TINY
- );
- $optvals[SMOPT_GRP_MAILBOX][] = array(
- 'name' => 'truncate_subject',
- 'caption' => _("Length of Subject Field (0 for full)"),
- 'type' => SMOPT_TYPE_INTEGER,
- 'refresh' => SMOPT_REFRESH_NONE,
- 'size' => SMOPT_SIZE_TINY
- );
- $optvals[SMOPT_GRP_MAILBOX][] = array(
- 'name' => 'show_recipient_instead',
- 'caption' => _("Show recipient name if the message is from your default identity"),
- 'type' => SMOPT_TYPE_BOOLEAN,
- 'refresh' => SMOPT_REFRESH_NONE,
- 'size' => SMOPT_SIZE_TINY
- );
- /*** Load the General Options into the array ***/
- $optgrps[SMOPT_GRP_MESSAGE] = _("Message Display and Composition");
- $optvals[SMOPT_GRP_MESSAGE] = array();
- $optvals[SMOPT_GRP_MESSAGE][] = array(
- 'name' => 'wrap_at',
- 'caption' => _("Wrap Incoming Text At"),
- 'type' => SMOPT_TYPE_INTEGER,
- 'refresh' => SMOPT_REFRESH_NONE,
- 'size' => SMOPT_SIZE_TINY
- );
- $optvals[SMOPT_GRP_MESSAGE][] = array(
- 'name' => 'editor_size',
- 'caption' => _("Width of Editor Window"),
- 'type' => SMOPT_TYPE_INTEGER,
- 'refresh' => SMOPT_REFRESH_NONE,
- 'size' => SMOPT_SIZE_TINY
- );
- $optvals[SMOPT_GRP_MESSAGE][] = array(
- 'name' => 'editor_height',
- 'caption' => _("Height of Editor Window"),
- 'type' => SMOPT_TYPE_INTEGER,
- 'refresh' => SMOPT_REFRESH_NONE,
- 'size' => SMOPT_SIZE_TINY
- );
- $optvals[SMOPT_GRP_MESSAGE][] = array(
- 'name' => 'location_of_buttons',
- 'caption' => _("Location of Buttons when Composing"),
- 'type' => SMOPT_TYPE_STRLIST,
- 'refresh' => SMOPT_REFRESH_NONE,
- 'posvals' => array(SMPREF_LOC_TOP => _("Before headers"),
- SMPREF_LOC_BETWEEN => _("Between headers and message body"),
- SMPREF_LOC_BOTTOM => _("After message body"))
- );
- $optvals[SMOPT_GRP_MESSAGE][] = array(
- 'name' => 'use_javascript_addr_book',
- 'caption' => _("Addressbook Display Format"),
- 'type' => SMOPT_TYPE_STRLIST,
- 'refresh' => SMOPT_REFRESH_NONE,
- 'posvals' => array('1' => _("Javascript"),
- '0' => _("HTML"))
- );
- $optvals[SMOPT_GRP_MESSAGE][] = array(
- 'name' => 'show_html_default',
- 'caption' => _("Show HTML Version by Default"),
- 'type' => SMOPT_TYPE_BOOLEAN,
- 'refresh' => SMOPT_REFRESH_NONE
- );
- $optvals[SMOPT_GRP_MESSAGE][] = array(
- 'name' => 'enable_forward_as_attachment',
- 'caption' => _("Enable Forward as Attachment"),
- 'type' => SMOPT_TYPE_BOOLEAN,
- 'refresh' => SMOPT_REFRESH_NONE
- );
- $optvals[SMOPT_GRP_MESSAGE][] = array(
- 'name' => 'forward_cc',
- 'caption' => _("Include CCs when Forwarding Messages"),
- 'type' => SMOPT_TYPE_BOOLEAN,
- 'refresh' => SMOPT_REFRESH_NONE
- );
- $optvals[SMOPT_GRP_MESSAGE][] = array(
- 'name' => 'include_self_reply_all',
- 'caption' => _("Include Me in CC when I Reply All"),
- 'type' => SMOPT_TYPE_BOOLEAN,
- 'refresh' => SMOPT_REFRESH_NONE
- );
- $optvals[SMOPT_GRP_MESSAGE][] = array(
- 'name' => 'show_xmailer_default',
- 'caption' => _("Enable Mailer Display"),
- 'type' => SMOPT_TYPE_BOOLEAN,
- 'refresh' => SMOPT_REFRESH_NONE
- );
- $optvals[SMOPT_GRP_MESSAGE][] = array(
- 'name' => 'attachment_common_show_images',
- 'caption' => _("Display Attached Images with Message"),
- 'type' => SMOPT_TYPE_BOOLEAN,
- 'refresh' => SMOPT_REFRESH_NONE
- );
- $optvals[SMOPT_GRP_MESSAGE][] = array(
- 'name' => 'pf_cleandisplay',
- 'caption' => _("Enable Printer Friendly Clean Display"),
- 'type' => SMOPT_TYPE_BOOLEAN,
- 'refresh' => SMOPT_REFRESH_NONE
- );
- if ($default_use_mdn) {
- $optvals[SMOPT_GRP_MESSAGE][] = array(
- 'name' => 'mdn_user_support',
- 'caption' => _("Enable Mail Delivery Notification"),
- 'type' => SMOPT_TYPE_BOOLEAN,
- 'refresh' => SMOPT_REFRESH_NONE
- );
- }
- $optvals[SMOPT_GRP_MESSAGE][] = array(
- 'name' => 'compose_new_win',
- 'caption' => _("Compose Messages in New Window"),
- 'type' => SMOPT_TYPE_BOOLEAN,
- 'refresh' => SMOPT_REFRESH_ALL
- );
- $optvals[SMOPT_GRP_MESSAGE][] = array(
- 'name' => 'compose_width',
- 'caption' => _("Width of Compose Window"),
- 'type' => SMOPT_TYPE_INTEGER,
- 'refresh' => SMOPT_REFRESH_ALL,
- 'size' => SMOPT_SIZE_TINY
- );
- $optvals[SMOPT_GRP_MESSAGE][] = array(
- 'name' => 'compose_height',
- 'caption' => _("Height of Compose Window"),
- 'type' => SMOPT_TYPE_INTEGER,
- 'refresh' => SMOPT_REFRESH_ALL,
- 'size' => SMOPT_SIZE_TINY
- );
- $optvals[SMOPT_GRP_MESSAGE][] = array(
- 'name' => 'sig_first',
- 'caption' => _("Append Signature before Reply/Forward Text"),
- 'type' => SMOPT_TYPE_BOOLEAN,
- 'refresh' => SMOPT_REFRESH_NONE
- );
- $optvals[SMOPT_GRP_MESSAGE][] = array(
- 'name' => 'body_quote',
- 'caption' => _("Prefix for Original Message when Replying"),
- 'type' => SMOPT_TYPE_STRING,
- 'refresh' => SMOPT_REFRESH_NONE,
- 'size' => SMOPT_SIZE_TINY,
- 'save' => 'save_option_reply_prefix'
- );
- $optvals[SMOPT_GRP_MESSAGE][] = array(
- 'name' => 'reply_focus',
- 'caption' => _("Cursor Position when Replying"),
- 'type' => SMOPT_TYPE_STRLIST,
- 'refresh' => SMOPT_REFRESH_NONE,
- 'posvals' => array('' => _("To: field"),
- 'focus' => _("Focus in body"),
- 'select' => _("Select body"),
- 'none' => _("No focus"))
- );
- $optvals[SMOPT_GRP_MESSAGE][] = array(
- 'name' => 'strip_sigs',
- 'caption' => _("Strip signature when replying"),
- 'type' => SMOPT_TYPE_BOOLEAN,
- 'refresh' => SMOPT_REFRESH_NONE
- );
- $optvals[SMOPT_GRP_MESSAGE][] = array(
- 'name' => 'internal_date_sort',
- 'caption' => _("Enable Sort by of Receive Date"),
- 'type' => SMOPT_TYPE_BOOLEAN,
- 'refresh' => SMOPT_REFRESH_ALL
- );
- if ($allow_thread_sort == TRUE) {
- $optvals[SMOPT_GRP_MESSAGE][] = array(
- 'name' => 'sort_by_ref',
- 'caption' => _("Enable Thread Sort by References Header"),
- 'type' => SMOPT_TYPE_BOOLEAN,
- 'refresh' => SMOPT_REFRESH_ALL
- );
- $optvals[SMOPT_GRP_MESSAGE][] = array(
- 'name' => 'delete_prev_next_display',
- 'caption' => _("Show 'Delete & Prev/Next' Links"),
- 'type' => SMOPT_TYPE_BOOLEAN,
- 'refresh' => SMOPT_REFRESH_ALL
- );
- }
- /* Assemble all this together and return it as our result. */
- $result = array(
- 'grps' => $optgrps,
- 'vals' => $optvals
- );
- return ($result);
- }
- /******************************************************************/
- /** Define any specialized save functions for this option page. ***/
- /******************************************************************/
- function save_option_header($option) {
- }
- /**
- * This function saves a new theme setting.
- * It updates the theme array.
- */
- function save_option_theme($option) {
- global $theme;
- /* Do checking to make sure $new_theme is in the array. */
- $theme_in_array = false;
- for ($i = 0; $i < count($theme); ++$i) {
- if ($theme[$i]['PATH'] == $option->new_value) {
- $theme_in_array = true;
- break;
- }
- }
- if (!$theme_in_array) {
- $option->new_value = '';
- }
- /* Save the option like normal. */
- save_option($option);
- }
- /**
- * This function saves the javascript detection option.
- */
- function save_option_javascript_autodetect($option) {
- global $data_dir, $username;
- save_option($option);
- checkForJavascript(TRUE);
- }
- /**
- * This function saves the user's icon theme setting
- */
- function icon_theme_save($option) {
- global $icon_themes, $data_dir, $username;
- // Don't assume the new value is there, double check
- // and only save if found
- //
- if (isset($icon_themes[$option->new_value]['PATH']))
- setPref($data_dir, $username, 'icon_theme', $icon_themes[$option->new_value]['PATH']);
- else
- setPref($data_dir, $username, 'icon_theme', 'none');
- }
- /**
- * This function saves the reply prefix (body_quote) character(s)
- */
- function save_option_reply_prefix($option) {
- global $data_dir, $username, $new_javascript_setting;
- // save as "NONE" if it was blanked out
- //
- if (empty($option->new_value)) $option->new_value = 'NONE';
- // Save the option like normal.
- //
- save_option($option);
- }
- ?>
|