Source for file folder.php

Documentation is available at folder.php

  1. <?php
  2.  
  3. /**
  4.  * options_folder.php
  5.  *
  6.  * Displays all options relating to folders
  7.  *
  8.  * @copyright 1999-2020 The SquirrelMail Project Team
  9.  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  10.  * @version $Id: folder.php 14840 2020-01-07 07:42:38Z pdontthink $
  11.  * @package squirrelmail
  12.  */
  13.  
  14. /** SquirrelMail required files. */
  15. require_once(SM_PATH 'functions/imap.php');
  16. require_once(SM_PATH 'functions/imap_general.php');
  17.  
  18. /* Define the group constants for the folder options page. */
  19. define('SMOPT_GRP_SPCFOLDER'0);
  20. define('SMOPT_GRP_FOLDERLIST'1);
  21. define('SMOPT_GRP_FOLDERSELECT'2);
  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 $username$key$imapServerAddress$imapPort$imap_stream_options;
  37.     global $folder_prefix$default_folder_prefix$show_prefix_option;
  38.  
  39.     /* Get some imap data we need later. */
  40.     $imapConnection =
  41.         sqimap_login($username$key$imapServerAddress$imapPort0$imap_stream_options);
  42.     $boxes sqimap_mailbox_list($imapConnection);
  43.  
  44.     /* Build a simple array into which we will build options. */
  45.     $optgrps array();
  46.     $optvals array();
  47.  
  48.     /******************************************************/
  49.     /* LOAD EACH GROUP OF OPTIONS INTO THE OPTIONS ARRAY. */
  50.     /******************************************************/
  51.  
  52.     /*** Load the General Options into the array ***/
  53.     $optgrps[SMOPT_GRP_SPCFOLDER_("Special Folder Options");
  54.     $optvals[SMOPT_GRP_SPCFOLDERarray();
  55.  
  56.     if (!isset($folder_prefix)) $folder_prefix $default_folder_prefix}
  57.     if ($show_prefix_option{
  58.         $optvals[SMOPT_GRP_SPCFOLDER][array(
  59.             'name'    => 'folder_prefix',
  60.             'caption' => _("Folder Path"),
  61.             'type'    => SMOPT_TYPE_STRING,
  62.             'refresh' => SMOPT_REFRESH_FOLDERLIST,
  63.             'size'    => SMOPT_SIZE_LARGE
  64.         );
  65.     }
  66.  
  67.     $trash_folder_values array(SMPREF_NONE => '[ '._("Do not use Trash").' ]',
  68.                                  'whatever'  => $boxes);
  69.     $optvals[SMOPT_GRP_SPCFOLDER][array(
  70.         'name'    => 'trash_folder',
  71.         'caption' => _("Trash Folder"),
  72.         'type'    => SMOPT_TYPE_FLDRLIST,
  73.         'refresh' => SMOPT_REFRESH_FOLDERLIST,
  74.         'posvals' => $trash_folder_values,
  75.         'save'    => 'save_option_trash_folder'
  76.     );
  77.  
  78.     $draft_folder_values array(SMPREF_NONE => '[ '._("Do not use Drafts").' ]',
  79.                                  'whatever'  => $boxes);
  80.     $optvals[SMOPT_GRP_SPCFOLDER][array(
  81.         'name'    => 'draft_folder',
  82.         'caption' => _("Draft Folder"),
  83.         'type'    => SMOPT_TYPE_FLDRLIST,
  84.         'refresh' => SMOPT_REFRESH_FOLDERLIST,
  85.         'posvals' => $draft_folder_values,
  86.         'save'    => 'save_option_draft_folder'
  87.     );
  88.  
  89.     $sent_folder_values array(SMPREF_NONE => '[ '._("Do not use Sent").' ]',
  90.                                 'whatever'  => $boxes);
  91.     $optvals[SMOPT_GRP_SPCFOLDER][array(
  92.         'name'    => 'sent_folder',
  93.         'caption' => _("Sent Folder"),
  94.         'type'    => SMOPT_TYPE_FLDRLIST,
  95.         'refresh' => SMOPT_REFRESH_FOLDERLIST,
  96.         'posvals' => $sent_folder_values,
  97.         'save'    => 'save_option_sent_folder'
  98.     );
  99.  
  100.     /*** Load the General Options into the array ***/
  101.     $optgrps[SMOPT_GRP_FOLDERLIST_("Folder List Options");
  102.     $optvals[SMOPT_GRP_FOLDERLISTarray();
  103.  
  104.     $optvals[SMOPT_GRP_FOLDERLIST][array(
  105.         'name'    => 'location_of_bar',
  106.         'caption' => _("Location of Folder List"),
  107.         'type'    => SMOPT_TYPE_STRLIST,
  108.         'refresh' => SMOPT_REFRESH_ALL,
  109.         'posvals' => array(SMPREF_LOC_LEFT  => _("Left"),
  110.                            SMPREF_LOC_RIGHT => _("Right"))
  111.     );
  112.  
  113.     $left_size_values array();
  114.     for ($lsv 100$lsv <= 300$lsv += 10{
  115.         $left_size_values[$lsv"$lsv _("pixels");
  116.     }
  117.     $optvals[SMOPT_GRP_FOLDERLIST][array(
  118.         'name'    => 'left_size',
  119.         'caption' => _("Width of Folder List"),
  120.         'type'    => SMOPT_TYPE_STRLIST,
  121.         'refresh' => SMOPT_REFRESH_ALL,
  122.         'posvals' => $left_size_values
  123.     );
  124.  
  125.     $minute_str _("Minutes");
  126.     $left_refresh_values array(SMPREF_NONE => _("Never"));
  127.     foreach (array(30,60,120,180,300,600,1200as $lr_val{
  128.         if ($lr_val 60{
  129.             $left_refresh_values[$lr_val"$lr_val _("Seconds");
  130.         else if ($lr_val == 60{
  131.             $left_refresh_values[$lr_val"1 " _("Minute");
  132.         else {
  133.             $left_refresh_values[$lr_val($lr_val/60" $minute_str";
  134.         }
  135.     }
  136.     $optvals[SMOPT_GRP_FOLDERLIST][array(
  137.         'name'    => 'left_refresh',
  138.         'caption' => _("Auto Refresh Folder List"),
  139.         'type'    => SMOPT_TYPE_STRLIST,
  140.         'refresh' => SMOPT_REFRESH_FOLDERLIST,
  141.         'posvals' => $left_refresh_values
  142.     );
  143.  
  144.     $optvals[SMOPT_GRP_FOLDERLIST][array(
  145.         'name'    => 'unseen_notify',
  146.         'caption' => _("Enable Unread Message Notification"),
  147.         'type'    => SMOPT_TYPE_STRLIST,
  148.         'refresh' => SMOPT_REFRESH_FOLDERLIST,
  149.         'posvals' => array(SMPREF_UNSEEN_NONE  => _("No Notification"),
  150.                            SMPREF_UNSEEN_INBOX => _("Only INBOX"),
  151.                            SMPREF_UNSEEN_ALL   => _("All Folders"))
  152.     );
  153.  
  154.     $optvals[SMOPT_GRP_FOLDERLIST][array(
  155.         'name'    => 'unseen_type',
  156.         'caption' => _("Unread Message Notification Type"),
  157.         'type'    => SMOPT_TYPE_STRLIST,
  158.         'refresh' => SMOPT_REFRESH_FOLDERLIST,
  159.         'posvals' => array(SMPREF_UNSEEN_ONLY  => _("Only Unseen"),
  160.                            SMPREF_UNSEEN_TOTAL => _("Unseen and Total"))
  161.     );
  162.  
  163.     $optvals[SMOPT_GRP_FOLDERLIST][array(
  164.         'name'    => 'collapse_folders',
  165.         'caption' => _("Enable Collapsable Folders"),
  166.         'type'    => SMOPT_TYPE_BOOLEAN,
  167.         'refresh' => SMOPT_REFRESH_FOLDERLIST
  168.     );
  169.  
  170.     $optvals[SMOPT_GRP_FOLDERLIST][array(
  171.         'name'    => 'unseen_cum',
  172.         'caption' => _("Enable Cumulative Unread Message Notification"),
  173.         'type'    => SMOPT_TYPE_BOOLEAN,
  174.         'refresh' => SMOPT_REFRESH_FOLDERLIST
  175.     );
  176.  
  177.  
  178.     $optvals[SMOPT_GRP_FOLDERLIST][array(
  179.         'name'    => 'date_format',
  180.         'caption' => _("Show Clock on Folders Panel"),
  181.         'type'    => SMOPT_TYPE_STRLIST,
  182.         'refresh' => SMOPT_REFRESH_FOLDERLIST,
  183.         'posvals' => array'0' => _("International date and time"),
  184.                             '1' => _("American date and time"),
  185.                             '2' => _("European date and time"),
  186.                             '3' => _("Show weekday and time"),
  187.                             '4' => _("Show time with seconds"),
  188.                             '5' => _("Show time"),
  189.                             '6' => _("No Clock")),
  190.     );
  191.  
  192.     $optvals[SMOPT_GRP_FOLDERLIST][array(
  193.         'name'    => 'hour_format',
  194.         'caption' => _("Hour Format"),
  195.         'type'    => SMOPT_TYPE_STRLIST,
  196.         'refresh' => SMOPT_REFRESH_FOLDERLIST,
  197.         'posvals' => array(SMPREF_TIME_12HR => _("12-hour clock"),
  198.                            SMPREF_TIME_24HR => _("24-hour clock"))
  199.     );
  200.  
  201.     $optvals[SMOPT_GRP_FOLDERLIST][array(
  202.         'name'    => 'search_memory',
  203.         'caption' => _("Memory Search"),
  204.         'type'    => SMOPT_TYPE_STRLIST,
  205.         'refresh' => SMOPT_REFRESH_NONE,
  206.         'posvals' => array=> _("Disabled"),
  207.                             => '1',
  208.                             => '2',
  209.                             => '3',
  210.                             => '4',
  211.                             => '5',
  212.                             => '6',
  213.                             => '7',
  214.                             => '8',
  215.                             => '9')
  216.     );
  217.  
  218.  
  219.     /*** Load the General Options into the array ***/
  220.     $optgrps[SMOPT_GRP_FOLDERSELECT_("Folder Selection Options");
  221.     $optvals[SMOPT_GRP_FOLDERSELECTarray();
  222.  
  223.     $delim sqimap_get_delimiter($imapConnection);
  224.     $optvals[SMOPT_GRP_FOLDERSELECT][array(
  225.         'name'    => 'mailbox_select_style',
  226.         'caption' => _("Selection List Style"),
  227.         'type'    => SMOPT_TYPE_STRLIST,
  228.         'refresh' => SMOPT_REFRESH_NONE,
  229.         'posvals' => array=> _("Long:"' "' _("Folder"$delim _("Subfolder"'"',
  230.                             => _("Indented:"' "&nbsp;&nbsp;&nbsp;&nbsp;' _("Subfolder"'"',
  231.                             => _("Delimited:"' ".&nbsp;' _("Subfolder"'"'),
  232.         'htmlencoded' => true
  233.     );
  234.  
  235.     /* Assemble all this together and return it as our result. */
  236.     $result array(
  237.         'grps' => $optgrps,
  238.         'vals' => $optvals
  239.     );
  240.     sqimap_logout($imapConnection);
  241.     return ($result);
  242. }
  243.  
  244. /******************************************************************/
  245. /** Define any specialized save functions for this option page. ***/
  246. /******************************************************************/
  247.  
  248. /**
  249.  * Saves the trash folder option.
  250.  * @param object $option SquirrelOption object
  251.  * @since 1.3.2
  252.  */
  253. function save_option_trash_folder($option{
  254.     global $data_dir$username;
  255.  
  256.     if (strtolower($option->new_value)=='inbox'{
  257.         // make sure that it is not INBOX
  258.         error_option_save(_("You can't select INBOX as Trash folder."));
  259.     else {
  260.         /* Set move to trash on or off. */
  261.         $trash_on ($option->new_value == SMPREF_NONE SMPREF_OFF SMPREF_ON);
  262.         setPref($data_dir$username'move_to_trash'$trash_on);
  263.  
  264.         /* Now just save the option as normal. */
  265.         save_option($option);
  266.     }
  267. }
  268.  
  269. /**
  270.  * Saves the sent folder option.
  271.  * @param object $option SquirrelOption object
  272.  * @since 1.3.2
  273.  */
  274. function save_option_sent_folder($option{
  275.     global $data_dir$username;
  276.  
  277.     if (strtolower($option->new_value)=='inbox'{
  278.         // make sure that it is not INBOX
  279.         error_option_save(_("You can't select INBOX as Sent folder."));
  280.     else {
  281.         /* Set move to sent on or off. */
  282.         $sent_on ($option->new_value == SMPREF_NONE SMPREF_OFF SMPREF_ON);
  283.         setPref($data_dir$username'move_to_sent'$sent_on);
  284.  
  285.         /* Now just save the option as normal. */
  286.         save_option($option);
  287.     }
  288. }
  289.  
  290. /**
  291.  * Saves the draft folder option.
  292.  * @param object $option SquirrelOption object
  293.  * @since 1.3.2
  294.  */
  295. function save_option_draft_folder($option{
  296.     global $data_dir$username;
  297.  
  298.     if (strtolower($option->new_value)=='inbox'{
  299.         // make sure that it is not INBOX
  300.         error_option_save(_("You can't select INBOX as Draft folder."));
  301.     else {
  302.         /* Set move to draft on or off. */
  303.         $draft_on ($option->new_value == SMPREF_NONE SMPREF_OFF SMPREF_ON);
  304.         setPref($data_dir$username'save_as_draft'$draft_on);
  305.  
  306.         /* Now just save the option as normal. */
  307.         save_option($option);
  308.     }
  309. }

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