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

Documentation generated on Sat, 07 Oct 2006 16:11:02 +0300 by phpDocumentor 1.3.0RC6