Source for file display.php

Documentation is available at display.php

  1. <?php
  2.  
  3. /**
  4.  * options_display.php
  5.  *
  6.  * Displays all optinos about display preferences
  7.  *
  8.  * @copyright 1999-2020 The SquirrelMail Project Team
  9.  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  10.  * @version $Id: display.php 14845 2020-01-07 08:09:34Z pdontthink $
  11.  * @package squirrelmail
  12.  */
  13.  
  14. /** Define the group constants for the display options page. */
  15. define('SMOPT_GRP_GENERAL'0);
  16. define('SMOPT_GRP_MAILBOX'1);
  17. define('SMOPT_GRP_MESSAGE'2);
  18. define('SMOPT_GRP_ABOOK'3);
  19.  
  20. global $use_iframe;
  21. if (isset($use_iframe)) $use_iframe=false;
  22.  
  23. /**
  24.  * This function builds an array with all the information about
  25.  * the options available to the user, and returns it. The options
  26.  * are grouped by the groups in which they are displayed.
  27.  * For each option, the following information is stored:
  28.  * - name: the internal (variable) name
  29.  * - caption: the description of the option in the UI
  30.  * - type: one of SMOPT_TYPE_*
  31.  * - refresh: one of SMOPT_REFRESH_*
  32.  * - size: one of SMOPT_SIZE_*
  33.  * - save: the name of a function to call when saving this option
  34.  * @return array all option information
  35.  */
  36.     global $theme$fontsets$language$languages,$aTemplateSet,
  37.     $default_use_mdn$squirrelmail_language$allow_thread_sort,
  38.     $sTemplateID$oTemplate,
  39.     $user_themes$chosen_theme;
  40.  
  41.     /* Build a simple array into which we will build options. */
  42.     $optgrps array();
  43.     $optvals array();
  44.  
  45.     /******************************************************/
  46.     /* LOAD EACH GROUP OF OPTIONS INTO THE OPTIONS ARRAY. */
  47.     /******************************************************/
  48.  
  49.     /*** Load the General Options into the array ***/
  50.     $optgrps[SMOPT_GRP_GENERAL_("General Display Options");
  51.     $optvals[SMOPT_GRP_GENERALarray();
  52.  
  53.     /* load the template set option */
  54.     $templateset_values array();
  55.  
  56.     foreach ($aTemplateSet as $sKey => $aTemplateSetAttributes{
  57.         $templateset_values[$aTemplateSetAttributes['NAME']] $aTemplateSetAttributes['ID'];
  58.     }
  59.     ksort($templateset_values);
  60.     $templateset_values array_flip($templateset_values);
  61.     // display template options only when there is more than one template
  62.     if (count($templateset_values)>1{
  63.         $optvals[SMOPT_GRP_GENERAL][array(
  64.             'name'    => 'sTemplateID',
  65.             'caption' => _("Skin"),
  66.             'type'    => SMOPT_TYPE_STRLIST,
  67.             'refresh' => SMOPT_REFRESH_ALL,
  68.             'posvals' => $templateset_values,
  69.             'save'    => 'save_option_template'
  70.         );
  71.     }
  72.  
  73.     /* Load the theme option. */
  74.     $theme_values array();
  75.     
  76.     // Always provide the template default first.
  77.     $theme_values['none''Template Default Theme';
  78.  
  79.     // List alternate themes provided by templates first
  80.     $template_themes $oTemplate->get_alternative_stylesheets(true);
  81.     asort($template_themes);
  82.     foreach ($template_themes as $sheet=>$name{
  83.         $theme_values[$sheet'Template Theme - '.sm_encode_html_special_chars($name);
  84.     }
  85.     // Next, list user-provided styles
  86.     asort($user_themes);
  87.     foreach ($user_themes as $style{
  88.         if ($style['PATH'== 'none')
  89.             continue;
  90.         $theme_values[$style['PATH']] 'User Theme - '.sm_encode_html_special_chars($style['NAME']);
  91.     }
  92.  
  93.     if (count($user_themescount($template_themes1{
  94.         $optvals[SMOPT_GRP_GENERAL][array(
  95.             'name'    => 'chosen_theme',
  96.             'caption' => _("Theme"),
  97.             'type'    => SMOPT_TYPE_STRLIST,
  98.             'refresh' => SMOPT_REFRESH_ALL,
  99.             'posvals' => $theme_values,
  100.             'save'    => 'css_theme_save'
  101.         );
  102.     }
  103.  
  104.     /* Icon theme selection */
  105.     if ($use_icons{
  106.         global $icon_themes$icon_theme;
  107.  
  108.         $temp array();
  109.         $value 0;
  110.         for ($count 0$count sizeof($icon_themes)$count++{
  111.             $temp[$icon_themes[$count]['PATH']] $icon_themes[$count]['NAME'];
  112.         }
  113.         if (sizeof($icon_themes0{
  114.             $optvals[SMOPT_GRP_GENERAL][array(
  115.                 'name'          => 'icon_theme',
  116.                 'caption'       => _("Icon Theme"),
  117.                 'type'          => SMOPT_TYPE_STRLIST,
  118.                 'refresh'       => SMOPT_REFRESH_NONE,
  119.                 'posvals'       => $temp,
  120.                 'save'          => 'icon_theme_save'
  121.             );
  122.         }
  123.     }
  124.  
  125.     $fontset_values array();
  126.     $fontset_list array();
  127.  
  128.     if (!empty($fontsets&& is_array($fontsets)) {
  129.  
  130.         foreach (array_keys($fontsetsas $fontset_key{
  131.             $fontset_list[$fontset_key]=$fontset_key;
  132.         }
  133.         ksort($fontset_list);
  134.     }
  135.  
  136.     if (count($fontset_list1{
  137.         $fontset_list array_merge(array('' => _("Default font style"))$fontset_list);
  138.         $optvals[SMOPT_GRP_GENERAL][array(
  139.             'name'    => 'chosen_fontset',
  140.             'caption' => _("Font style"),
  141.             'type'    => SMOPT_TYPE_STRLIST,
  142.             'refresh' => SMOPT_REFRESH_ALL,
  143.             'posvals' => $fontset_list
  144.         );
  145.     }
  146.  
  147.     $optvals[SMOPT_GRP_GENERAL][array(
  148.         'name'    => 'chosen_fontsize',
  149.         'caption' => _("Font size"),
  150.         'type'    => SMOPT_TYPE_STRLIST,
  151.         'refresh' => SMOPT_REFRESH_ALL,
  152.         'posvals' => array('' => _("Default font size"),
  153.                            '8' => '8 px',
  154.                            '10' => '10 px',
  155.                            '12' => '12 px',
  156.                            '14' => '14 px')
  157.     );
  158.  
  159.     $language_values array();
  160.     foreach ($languages as $lang_key => $lang_attributes{
  161.         if (isset($lang_attributes['NAME'])) {
  162.             $language_values[$lang_key$lang_attributes['NAME'];
  163.             if isset($show_alternative_names&&
  164.                  $show_alternative_names &&
  165.                  isset($lang_attributes['ALTNAME']) ) {
  166.                 $language_values[$lang_key.= " / " $lang_attributes['ALTNAME'];
  167.             }
  168.         }
  169.     }
  170.  
  171.     asort($language_values);
  172.     $language_values =
  173.         array_merge(array('' => _("Default"))$language_values);
  174.     $language $squirrelmail_language;
  175.  
  176.     // add language selection only when more than 2 languages are available
  177.     // (default, English and some other)
  178.     if (count($language_values)>2{
  179.         $optvals[SMOPT_GRP_GENERAL][array(
  180.             'name'    => 'language',
  181.             'caption' => _("Language"),
  182.             'type'    => SMOPT_TYPE_STRLIST,
  183.             'refresh' => SMOPT_REFRESH_ALL,
  184.             'posvals' => $language_values,
  185.             'htmlencoded' => true
  186.         );
  187.     }
  188.  
  189.     /* Set values for the "use javascript" option. */
  190.     $optvals[SMOPT_GRP_GENERAL][array(
  191.         'name'    => 'javascript_setting',
  192.         'caption' => _("Use Javascript"),
  193.         'type'    => SMOPT_TYPE_STRLIST,
  194.         'refresh' => SMOPT_REFRESH_ALL,
  195.         'posvals' => array(SMPREF_JS_AUTODETECT => _("Autodetect"),
  196.                            SMPREF_JS_ON         => _("Always"),
  197.                            SMPREF_JS_OFF        => _("Never")),
  198.         'save'    => 'save_option_javascript_autodetect',
  199.         'extra_attributes' => array('onclick' => 'document.option_form.new_js_autodetect_results.value = \'' SMPREF_JS_ON '\';'),
  200.     );
  201.  
  202.     $optvals[SMOPT_GRP_GENERAL][array(
  203.         'name'    => 'js_autodetect_results',
  204.         'caption' => '',
  205.         'type'    => SMOPT_TYPE_HIDDEN,
  206.         'refresh' => SMOPT_REFRESH_NONE
  207.         //'post_script' => $js_autodetect_script,
  208.     );
  209.  
  210.     $optvals[SMOPT_GRP_GENERAL][array(
  211.         'name'    => 'hour_format',
  212.         'caption' => _("Hour Format"),
  213.         'type'    => SMOPT_TYPE_STRLIST,
  214.         'refresh' => SMOPT_REFRESH_FOLDERLIST,
  215.         'posvals' => array(SMPREF_TIME_12HR => _("12-hour clock"),
  216.                            SMPREF_TIME_24HR => _("24-hour clock"))
  217.     );
  218.  
  219.     /*** Load the General Options into the array ***/
  220.     $optgrps[SMOPT_GRP_MAILBOX_("Mailbox Display Options");
  221.     $optvals[SMOPT_GRP_MAILBOXarray();
  222.  
  223.     $optvals[SMOPT_GRP_MAILBOX][array(
  224.         'name'    => 'show_num',
  225.         'caption' => _("Number of Messages per Page"),
  226.         'type'    => SMOPT_TYPE_INTEGER,
  227.         'refresh' => SMOPT_REFRESH_NONE,
  228.         'size'    => SMOPT_SIZE_TINY
  229.     );
  230.  
  231.     $optvals[SMOPT_GRP_MAILBOX][array(
  232.         'name'    => 'alt_index_colors',
  233.         'caption' => _("Enable Alternating Row Colors"),
  234.         'type'    => SMOPT_TYPE_BOOLEAN,
  235.         'refresh' => SMOPT_REFRESH_NONE
  236.     );
  237.  
  238.     $optvals[SMOPT_GRP_MAILBOX][array(
  239.         'name'    => 'fancy_index_highlite',
  240.         'caption' => _("Enable Fancy Row Mouseover Highlighting"),
  241.         'type'    => SMOPT_TYPE_BOOLEAN,
  242.         'refresh' => SMOPT_REFRESH_NONE
  243.     );
  244.  
  245.     $optvals[SMOPT_GRP_MAILBOX][array(
  246.         'name'    => 'show_flag_buttons',
  247.         'caption' => _("Show Flag / Unflag Buttons"),
  248.         'type'    => SMOPT_TYPE_BOOLEAN,
  249.         'refresh' => SMOPT_REFRESH_NONE
  250.     );
  251.  
  252.     $optvals[SMOPT_GRP_MAILBOX][array(
  253.         'name'    => 'show_copy_buttons',
  254.         'caption' => _("Enable Message Copy Buttons"),
  255.         'type'    => SMOPT_TYPE_BOOLEAN,
  256.         'refresh' => SMOPT_REFRESH_NONE
  257.     );
  258.  
  259.     $optvals[SMOPT_GRP_MAILBOX][array(
  260.         'name'    => 'page_selector',
  261.         'caption' => _("Enable Page Selector"),
  262.         'type'    => SMOPT_TYPE_BOOLEAN,
  263.         'refresh' => SMOPT_REFRESH_NONE
  264.     );
  265.  
  266.     $optvals[SMOPT_GRP_MAILBOX][array(
  267.         'name'    => 'compact_paginator',
  268.         'caption' => _("Use Compact Page Selector"),
  269.         'type'    => SMOPT_TYPE_BOOLEAN,
  270.         'refresh' => SMOPT_REFRESH_NONE
  271.     );
  272.  
  273.     $optvals[SMOPT_GRP_MAILBOX][array(
  274.         'name'    => 'page_selector_max',
  275.         'caption' => _("Maximum Number of Pages to Show"),
  276.         'type'    => SMOPT_TYPE_INTEGER,
  277.         'refresh' => SMOPT_REFRESH_NONE,
  278.         'size'    => SMOPT_SIZE_TINY
  279.     );
  280.  
  281.     $optvals[SMOPT_GRP_MAILBOX][array(
  282.         'name'    => 'show_personal_names',
  283.         'caption' => _("Show Names Instead of Email Addresses"),
  284.         'type'    => SMOPT_TYPE_BOOLEAN,
  285.         'refresh' => SMOPT_REFRESH_NONE,
  286.     );
  287.  
  288.     $optvals[SMOPT_GRP_MAILBOX][array(
  289.         'name'    => 'show_full_date',
  290.         'caption' => _("Always Show Full Date"),
  291.         'type'    => SMOPT_TYPE_BOOLEAN,
  292.         'refresh' => SMOPT_REFRESH_NONE
  293.     );
  294.  
  295.     $optvals[SMOPT_GRP_MAILBOX][array(
  296.         'name'          => 'custom_date_format',
  297.         'caption'       => _("Custom Date Format"),
  298. //FIXME: need better wording here.  users should be made aware that this is for advanced use.  It might be nice to provide a list of the more common date format characters.  It may be helpful to know that it overrides settings such as the one above show_full_date, and only if kept empty will the other date formats apply.  For non-English users, it also may be helpful to know that the format is still passed through our own date_intl() function which translates things like the day of the week, month names and abbreviations, etc.
  299.         'trailing_text' => ' ' _("(Uses format of PHP date() function)"),
  300.         'type'          => SMOPT_TYPE_STRING,
  301.         'refresh'       => SMOPT_REFRESH_NONE,
  302.         'size'          => SMOPT_SIZE_TINY,
  303.     );
  304.  
  305.     $optvals[SMOPT_GRP_MAILBOX][array(
  306.         'name'    => 'truncate_sender',
  307.         'caption' => _("Length of From/To Field (0 for full)"),
  308.         'type'    => SMOPT_TYPE_INTEGER,
  309.         'refresh' => SMOPT_REFRESH_NONE,
  310.         'size'    => SMOPT_SIZE_TINY
  311.     );
  312.  
  313.     $optvals[SMOPT_GRP_MAILBOX][array(
  314.         'name'    => 'truncate_subject',
  315.         'caption' => _("Length of Subject Field (0 for full)"),
  316.         'type'    => SMOPT_TYPE_INTEGER,
  317.         'refresh' => SMOPT_REFRESH_NONE,
  318.         'size'    => SMOPT_SIZE_TINY
  319.     );
  320. /*
  321. FIXME!
  322.   disabled because the template doesn't support it (yet?)
  323.     $optvals[SMOPT_GRP_MAILBOX][] = array(
  324.         'name'    => 'show_recipient_instead',
  325.         'caption' => _("Show recipient name if the message is from your default identity"),
  326.         'type'    => SMOPT_TYPE_BOOLEAN,
  327.         'refresh' => SMOPT_REFRESH_NONE,
  328.         'size'    => SMOPT_SIZE_TINY
  329.     );
  330. */
  331.  
  332.     if ($allow_thread_sort == TRUE{
  333.         $optvals[SMOPT_GRP_MAILBOX][array(
  334.             'name'    => 'sort_by_ref',
  335.             'caption' => _("Enable Thread Sort by References Header"),
  336.             'type'    => SMOPT_TYPE_BOOLEAN,
  337.             'refresh' => SMOPT_REFRESH_ALL
  338.         );
  339.     }
  340.  
  341.  
  342.  
  343.     /*** Load the General Options into the array ***/
  344.     $optgrps[SMOPT_GRP_MESSAGE_("Message Display Options");
  345.     $optvals[SMOPT_GRP_MESSAGEarray();
  346.  
  347.     $optvals[SMOPT_GRP_MESSAGE][array(
  348.         'name'    => 'wrap_at',
  349.         'caption' => _("Wrap Incoming Text At"),
  350.         'type'    => SMOPT_TYPE_INTEGER,
  351.         'refresh' => SMOPT_REFRESH_NONE,
  352.         'size'    => SMOPT_SIZE_TINY
  353.     );
  354.  
  355.     $optvals[SMOPT_GRP_MESSAGE][array(
  356.         'name'    => 'show_html_default',
  357.         'caption' => _("Show HTML Version by Default"),
  358.         'type'    => SMOPT_TYPE_BOOLEAN,
  359.         'refresh' => SMOPT_REFRESH_NONE
  360.     );
  361.  
  362.     if ($use_iframe{
  363.         // Type is set to string in order to be able to use 100%.
  364.         $optvals[SMOPT_GRP_MESSAGE][array(
  365.             'name'    => 'iframe_height',
  366.             'caption' => _("Height of inline frame"),
  367.             'type'    => SMOPT_TYPE_STRING,
  368.             'size'    => SMOPT_SIZE_TINY,
  369.             'refresh' => SMOPT_REFRESH_NONE
  370.         );
  371.     }
  372.     $optvals[SMOPT_GRP_MESSAGE][array(
  373.         'name'    => 'enable_forward_as_attachment',
  374.         'caption' => _("Enable Forward as Attachment"),
  375.         'type'    => SMOPT_TYPE_BOOLEAN,
  376.         'refresh' => SMOPT_REFRESH_NONE
  377.     );
  378.  
  379.     $optvals[SMOPT_GRP_MESSAGE][array(
  380.         'name'    => 'show_xmailer_default',
  381.         'caption' => _("Enable Mailer Display"),
  382.         'type'    => SMOPT_TYPE_BOOLEAN,
  383.         'refresh' => SMOPT_REFRESH_NONE
  384.     );
  385.  
  386.     $optvals[SMOPT_GRP_MESSAGE][array(
  387.         'name'    => 'attachment_common_show_images',
  388.         'caption' => _("Display Attached Images with Message"),
  389.         'type'    => SMOPT_TYPE_BOOLEAN,
  390.         'refresh' => SMOPT_REFRESH_NONE
  391.     );
  392.  
  393.     if ($default_use_mdn{
  394.         $optvals[SMOPT_GRP_MESSAGE][array(
  395.             'name'    => 'mdn_user_support',
  396.             'caption' => _("Enable Mail Delivery Notification"),
  397.             'type'    => SMOPT_TYPE_BOOLEAN,
  398.             'refresh' => SMOPT_REFRESH_NONE
  399.         );
  400.     }
  401.  
  402.     $optvals[SMOPT_GRP_MESSAGE][array(
  403.         'name'    => 'delete_prev_next_display',
  404.         'caption' => _("Show 'Delete &amp; Prev/Next' Links"),
  405.         'type'    => SMOPT_TYPE_BOOLEAN,
  406.         'refresh' => SMOPT_REFRESH_ALL
  407.     );
  408.  
  409.  
  410.  
  411.     /*** Load the Address Book Options into the array ***/
  412.     $optgrps[SMOPT_GRP_ABOOK_("Address Book Display Options");
  413.     $optvals[SMOPT_GRP_ABOOKarray();
  414.  
  415.     $optvals[SMOPT_GRP_ABOOK][array(
  416.         'name'    => 'abook_show_num',
  417.         'caption' => _("Number of Addresses per Page"),
  418.         'type'    => SMOPT_TYPE_INTEGER,
  419.         'refresh' => SMOPT_REFRESH_NONE,
  420.         'size'    => SMOPT_SIZE_TINY
  421.     );
  422.  
  423.     $optvals[SMOPT_GRP_ABOOK][array(
  424.         'name'    => 'abook_page_selector',
  425.         'caption' => _("Enable Page Selector"),
  426.         'type'    => SMOPT_TYPE_BOOLEAN,
  427.         'refresh' => SMOPT_REFRESH_NONE
  428.     );
  429.  
  430.     $optvals[SMOPT_GRP_ABOOK][array(
  431.         'name'    => 'abook_compact_paginator',
  432.         'caption' => _("Use Compact Page Selector"),
  433.         'type'    => SMOPT_TYPE_BOOLEAN,
  434.         'refresh' => SMOPT_REFRESH_NONE
  435.     );
  436.  
  437.     $optvals[SMOPT_GRP_ABOOK][array(
  438.         'name'    => 'abook_page_selector_max',
  439.         'caption' => _("Maximum Number of Pages to Show"),
  440.         'type'    => SMOPT_TYPE_INTEGER,
  441.         'refresh' => SMOPT_REFRESH_NONE,
  442.         'size'    => SMOPT_SIZE_TINY
  443.     );
  444.  
  445.  
  446.  
  447.     /* Assemble all this together and return it as our result. */
  448.     $result array(
  449.         'grps' => $optgrps,
  450.         'vals' => $optvals
  451.     );
  452.     return ($result);
  453. }
  454.  
  455. /******************************************************************/
  456. /** Define any specialized save functions for this option page. ***/
  457. /******************************************************************/
  458.  
  459. /**
  460.  * This function saves a new template setting.
  461.  * It updates the template array.
  462.  */
  463. function save_option_template($option{
  464.     global $aTemplateSet;
  465.  
  466.     /* Do checking to make sure new template is in the available templates array. */
  467.     $templateset_in_array false;
  468.     for ($i 0$i count($aTemplateSet)++$i{
  469.         if ($aTemplateSet[$i]['ID'== $option->new_value{
  470.             $templateset_in_array true;
  471.             break;
  472.         }
  473.     }
  474.  
  475.     if (!$templateset_in_array{
  476.         $option->new_value '';
  477.     else {
  478.  
  479.         // clear template cache when changing template sets
  480.         // (in order to do so, we have to change the global
  481.         // template set ID now... should not be a problem --
  482.         // in fact, if we don't do it now, very anomalous
  483.         // problems occur)
  484.         //
  485.         global $sTemplateID;
  486.         $sTemplateID $option->new_value;
  487.         Template::cache_template_file_hierarchy($sTemplateIDTRUE);
  488.  
  489.     }
  490.  
  491.     /**
  492.      * TODO: If the template changes and we are using a template provided theme
  493.      * ($user_theme), do we want to reset $user_theme?
  494.      */
  495.     /* Save the option like normal. */
  496.     save_option($option);
  497. }
  498.  
  499. /**
  500.  * This function saves the javascript detection option.
  501.  */
  502. function save_option_javascript_autodetect($option{
  503.     save_option($option);
  504.     checkForJavascript(TRUE);
  505. }
  506.  
  507. /**
  508.  * This function saves the user's icon theme setting
  509.  */
  510. function icon_theme_save($option{
  511.     global $icon_themes;
  512.  
  513.  
  514.     // Don't assume the new value is there, double check
  515.     // and only save if found
  516.     $found false;
  517.     while (!$found && (list($index$dataeach($icon_themes))) {
  518.         if ($data['PATH'== $option->new_value)
  519.             $found true;
  520.     }
  521.     
  522.     if (!$found)
  523.         $option->new_value 'none';
  524.         
  525.     save_option($option);
  526. }
  527.  
  528. function css_theme_save ($option{
  529.     global $user_themes$oTemplate;
  530.  
  531.     // Don't assume the new value is there, double check
  532.     // and only save if found
  533.     $found false;
  534.     reset($user_themes);
  535.     while (!$found && (list($index$dataeach($user_themes))) {
  536.         if ($data['PATH'== $option->new_value)
  537.             $found true;
  538.     }
  539.     
  540.     if (!$found{
  541.         $template_themes $oTemplate->get_alternative_stylesheets(true);
  542.         while (!$found && (list($path$nameeach($template_themes))) {
  543.             if ($path == $option->new_value)
  544.                 $found true;
  545.         }
  546.     }
  547.     
  548.     if (!$found)
  549.         $option->new_value 'none';
  550.         
  551.     save_option($option);
  552. }

Documentation generated on Mon, 13 Jan 2020 04:22:24 +0100 by phpDocumentor 1.4.3