Source for file personal.php

Documentation is available at personal.php

  1. <?php
  2.  
  3. /**
  4.  * options_personal.php
  5.  *
  6.  * Displays all options relating to personal information
  7.  *
  8.  * @copyright 1999-2020 The SquirrelMail Project Team
  9.  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  10.  * @version $Id: personal.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.  
  17. /* Define the group constants for the personal options page. */
  18. define('SMOPT_GRP_CONTACT'0);
  19. define('SMOPT_GRP_REPLY'1);
  20. define('SMOPT_GRP_SIG'2);
  21. define('SMOPT_GRP_TZ'3);
  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 $data_dir$username$edit_identity$edit_name$edit_reply_to,
  37.            $full_name$reply_to$email_address$signature$tzChangeAllowed,
  38.            $color;
  39.  
  40.     /* Set the values of some global variables. */
  41.     $full_name getPref($data_dir$username'full_name');
  42.     $reply_to getPref($data_dir$username'reply_to');
  43.     $email_address  getPref($data_dir$username'email_address');
  44.     $signature  getSig($data_dir$username'g');
  45.  
  46.     /* Build a simple array into which we will build options. */
  47.     $optgrps array();
  48.     $optvals array();
  49.  
  50.     /******************************************************/
  51.     /* LOAD EACH GROUP OF OPTIONS INTO THE OPTIONS ARRAY. */
  52.     /******************************************************/
  53.  
  54.     /*** Load the Contact Information Options into the array ***/
  55.     $optgrps[SMOPT_GRP_CONTACT_("Name and Address Options");
  56.     $optvals[SMOPT_GRP_CONTACTarray();
  57.  
  58.     /* Build a simple array into which we will build options. */
  59.     $optvals array();
  60.  
  61.     if (!isset($edit_identity)) {
  62.         $edit_identity TRUE;
  63.     }
  64.  
  65.     if ($edit_identity || $edit_name{
  66.         $optvals[SMOPT_GRP_CONTACT][array(
  67.             'name'    => 'full_name',
  68.             'caption' => _("Full Name"),
  69.             'type'    => SMOPT_TYPE_STRING,
  70.             'refresh' => SMOPT_REFRESH_NONE,
  71.             'size'    => SMOPT_SIZE_HUGE
  72.         );
  73.     else {
  74.         $optvals[SMOPT_GRP_CONTACT][array(
  75.             'name'    => 'full_name',
  76.             'caption' => _("Full Name"),
  77.             'type'    => SMOPT_TYPE_COMMENT,
  78.             'refresh' => SMOPT_REFRESH_NONE,
  79.             'comment' => $full_name
  80.         );
  81.     }
  82.  
  83.     if ($edit_identity{
  84.         $optvals[SMOPT_GRP_CONTACT][array(
  85.             'name'    => 'email_address',
  86.             'caption' => _("E-mail Address"),
  87.             'type'    => SMOPT_TYPE_STRING,
  88.             'refresh' => SMOPT_REFRESH_NONE,
  89.             'size'    => SMOPT_SIZE_HUGE
  90.         );
  91.     else {
  92.         $optvals[SMOPT_GRP_CONTACT][array(
  93.             'name'    => 'email_address',
  94.             'caption' => _("E-mail Address"),
  95.             'type'    => SMOPT_TYPE_COMMENT,
  96.             'refresh' => SMOPT_REFRESH_NONE,
  97.             'comment' => $email_address
  98.         );
  99.     }
  100.  
  101.     if ($edit_identity || $edit_reply_to{
  102.         $optvals[SMOPT_GRP_CONTACT][array(
  103.             'name'    => 'reply_to',
  104.             'caption' => _("Reply To"),
  105.             'type'    => SMOPT_TYPE_STRING,
  106.             'refresh' => SMOPT_REFRESH_NONE,
  107.             'size'    => SMOPT_SIZE_HUGE
  108.         );
  109.     else {
  110. //TODO: For many users, this is redundant to the email address above, especially if not editable -- so here instead of a comment, we could just hide it... in fact, that's what we'll do, but keep this code for posterity in case someone decides we shouldn't do this
  111. /*
  112.         $optvals[SMOPT_GRP_CONTACT][] = array(
  113.             'name'    => 'reply_to',
  114.             'caption' => _("Reply To"),
  115.             'type'    => SMOPT_TYPE_COMMENT,
  116.             'refresh' => SMOPT_REFRESH_NONE,
  117.             'comment' => $reply_to,
  118.         );
  119. */
  120.     }
  121.  
  122.     $optvals[SMOPT_GRP_CONTACT][array(
  123.         'name'    => 'signature',
  124.         'caption' => _("Signature"),
  125.         'type'    => SMOPT_TYPE_TEXTAREA,
  126.         'refresh' => SMOPT_REFRESH_NONE,
  127.         'size'    => SMOPT_SIZE_MEDIUM,
  128.         'save'    => 'save_option_signature'
  129.     );
  130.  
  131.     $identities_count getPref($data_dir$username'identities'0);
  132.     if ($identities_count || $edit_identity{
  133.         $identities_link_value '<a href="options_identities.php">'
  134.                                . _("Edit Advanced Identities")
  135.                                . '</a> '
  136.                                . _("(discards changes made on this form so far)");
  137.         $optvals[SMOPT_GRP_CONTACT][array(
  138.             'name'    => 'identities_link',
  139.             'caption' => _("Multiple Identities"),
  140.             'type'    => SMOPT_TYPE_COMMENT,
  141.             'refresh' => SMOPT_REFRESH_NONE,
  142.             'comment' =>  $identities_link_value
  143.         );
  144.     }
  145.  
  146.     if $tzChangeAllowed || function_exists('date_default_timezone_set')) {
  147.         $TZ_ARRAY[SMPREF_NONE_("Same as server");
  148.         $tzfile SM_PATH 'locale/timezones.cfg';
  149.         if ((!is_readable($tzfile)) or (!$fd fopen($tzfile,'r'))) {
  150.             $message _("Error opening timezone config, contact administrator.");
  151.         }
  152.  
  153.         // TODO: make error user friendly
  154.         if (isset($message)) {
  155.             plain_error_message($message$color);
  156.             exit;
  157.         }
  158.         while (!feof ($fd)) {
  159.             $zone fgets($fd1024);
  160.             if$zone {
  161.                 $zone trim($zone);
  162.                 $TZ_ARRAY[$zone$zone;
  163.             }
  164.         }
  165.         fclose ($fd);
  166.  
  167.         $optgrps[SMOPT_GRP_TZ_("Timezone Options");
  168.         $optvals[SMOPT_GRP_TZarray();
  169.  
  170.         $optvals[SMOPT_GRP_TZ][array(
  171.             'name'    => 'timezone',
  172.             'caption' => _("Your current timezone"),
  173.             'type'    => SMOPT_TYPE_STRLIST,
  174.             'refresh' => SMOPT_REFRESH_NONE,
  175.             'posvals' => $TZ_ARRAY
  176.         );
  177.     }
  178.  
  179.     /*** Load the Reply Citation Options into the array ***/
  180.     $optgrps[SMOPT_GRP_REPLY_("Reply Citation Options");
  181.     $optvals[SMOPT_GRP_REPLYarray();
  182.  
  183.     $optvals[SMOPT_GRP_REPLY][array(
  184.         'name'    => 'reply_citation_style',
  185.         'caption' => _("Reply Citation Style"),
  186.         'type'    => SMOPT_TYPE_STRLIST,
  187.         'refresh' => SMOPT_REFRESH_NONE,
  188.         'posvals' => array(SMPREF_NONE    => _("No Citation"),
  189.                            'author_said'  => _("AUTHOR Wrote"),
  190.                            'date_time_author' => _("On DATE, AUTHOR Wrote"),
  191.                            'quote_who'    => _("Quote Who XML"),
  192.                            'user-defined' => _("User-Defined"))
  193.     );
  194.  
  195.     $optvals[SMOPT_GRP_REPLY][array(
  196.         'name'    => 'reply_citation_start',
  197.         'caption' => _("User-Defined Citation Start"),
  198.         'type'    => SMOPT_TYPE_STRING,
  199.         'refresh' => SMOPT_REFRESH_NONE,
  200.         'size'    => SMOPT_SIZE_MEDIUM
  201.     );
  202.  
  203.     $optvals[SMOPT_GRP_REPLY][array(
  204.         'name'    => 'reply_citation_end',
  205.         'caption' => _("User-Defined Citation End"),
  206.         'type'    => SMOPT_TYPE_STRING,
  207.         'refresh' => SMOPT_REFRESH_NONE,
  208.         'size'    => SMOPT_SIZE_MEDIUM
  209.     );
  210.  
  211.     /*** Load the Signature Options into the array ***/
  212.     $optgrps[SMOPT_GRP_SIG_("Signature Options");
  213.     $optvals[SMOPT_GRP_SIGarray();
  214.  
  215.     $optvals[SMOPT_GRP_SIG][array(
  216.         'name'    => 'use_signature',
  217.         'caption' => _("Use Signature"),
  218.         'type'    => SMOPT_TYPE_BOOLEAN,
  219.         'refresh' => SMOPT_REFRESH_NONE
  220.     );
  221.  
  222.     $optvals[SMOPT_GRP_SIG][array(
  223.         'name'    => 'prefix_sig',
  224.         'caption' => _("Prefix Signature with '-- ' Line"),
  225.         'type'    => SMOPT_TYPE_BOOLEAN,
  226.         'refresh' => SMOPT_REFRESH_NONE
  227.     );
  228.  
  229.     /* Assemble all this together and return it as our result. */
  230.     $result array(
  231.         'grps' => $optgrps,
  232.         'vals' => $optvals
  233.     );
  234.     return ($result);
  235. }
  236.  
  237. /******************************************************************/
  238. /** Define any specialized save functions for this option page. ***/
  239. /******************************************************************/
  240.  
  241. /**
  242.  * Saves the signature option.
  243.  */
  244. function save_option_signature($option{
  245.     global $data_dir$username;
  246.     setSig($data_dir$username'g'$option->new_value);
  247. }

Documentation generated on Mon, 13 Jan 2020 04:25:10 +0100 by phpDocumentor 1.4.3