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 14845 2020-01-07 08:09:34Z pdontthink $
  11.  * @package squirrelmail
  12.  */
  13.  
  14. /** SquirrelMail required files. */
  15. require_once(SM_PATH 'include/timezones.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.            $timeZone$domain;
  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',SMPREF_NONE);
  44.     $signature  getSig($data_dir$username'g');
  45.     
  46.     // set email_address to default value, if it is not set in user's preferences
  47.     if ($email_address == SMPREF_NONE{
  48.         if (preg_match("/(.+)@(.+)/",$username)) {
  49.             $email_address $username;
  50.         else {
  51.             $email_address $username '@' $domain ;
  52.         }
  53.     }
  54.  
  55.     /* Build a simple array into which we will build options. */
  56.     $optgrps array();
  57.     $optvals array();
  58.  
  59.     /******************************************************/
  60.     /* LOAD EACH GROUP OF OPTIONS INTO THE OPTIONS ARRAY. */
  61.     /******************************************************/
  62.  
  63.     /*** Load the Contact Information Options into the array ***/
  64.     $optgrps[SMOPT_GRP_CONTACT_("Name and Address Options");
  65.     $optvals[SMOPT_GRP_CONTACTarray();
  66.  
  67.     /* Build a simple array into which we will build options. */
  68.     $optvals array();
  69.  
  70.     if (!isset($edit_identity)) {
  71.         $edit_identity TRUE;
  72.     }
  73.  
  74.     if ($edit_identity || $edit_name{
  75.         $optvals[SMOPT_GRP_CONTACT][array(
  76.             'name'    => 'full_name',
  77.             'caption' => _("Full Name"),
  78.             'type'    => SMOPT_TYPE_STRING,
  79.             'refresh' => SMOPT_REFRESH_NONE,
  80.             'size'    => SMOPT_SIZE_HUGE
  81.         );
  82.     else {
  83.         $optvals[SMOPT_GRP_CONTACT][array(
  84.             'name'    => 'full_name',
  85.             'caption' => _("Full Name"),
  86.             'type'    => SMOPT_TYPE_COMMENT,
  87.             'refresh' => SMOPT_REFRESH_NONE,
  88.             'comment' => $full_name
  89.         );
  90.     }
  91.  
  92.     if ($edit_identity{
  93.         $optvals[SMOPT_GRP_CONTACT][array(
  94.             'name'    => 'email_address',
  95.             'caption' => _("E-mail Address"),
  96.             'type'    => SMOPT_TYPE_STRING,
  97.             'refresh' => SMOPT_REFRESH_NONE,
  98.             'size'    => SMOPT_SIZE_HUGE
  99.         );
  100.     else {
  101.         $optvals[SMOPT_GRP_CONTACT][array(
  102.             'name'    => 'email_address',
  103.             'caption' => _("E-mail Address"),
  104.             'type'    => SMOPT_TYPE_COMMENT,
  105.             'refresh' => SMOPT_REFRESH_NONE,
  106.             'comment' => sm_encode_html_special_chars($email_address)
  107.         );
  108.     }
  109.  
  110.     if ($edit_identity || $edit_reply_to{
  111.         $optvals[SMOPT_GRP_CONTACT][array(
  112.             'name'    => 'reply_to',
  113.             'caption' => _("Reply To"),
  114.             'type'    => SMOPT_TYPE_STRING,
  115.             'refresh' => SMOPT_REFRESH_NONE,
  116.             'size'    => SMOPT_SIZE_HUGE
  117.         );
  118.     else {
  119. //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
  120. /*
  121.         $optvals[SMOPT_GRP_CONTACT][] = array(
  122.             'name'    => 'reply_to',
  123.             'caption' => _("Reply To"),
  124.             'type'    => SMOPT_TYPE_COMMENT,
  125.             'refresh' => SMOPT_REFRESH_NONE,
  126.             'comment' => sm_encode_html_special_chars($reply_to),
  127.         );
  128. */
  129.     }
  130.  
  131.     $optvals[SMOPT_GRP_CONTACT][array(
  132.         'name'    => 'signature',
  133.         'caption' => _("Signature"),
  134.         'type'    => SMOPT_TYPE_TEXTAREA,
  135.         'refresh' => SMOPT_REFRESH_NONE,
  136.         'size'    => SMOPT_SIZE_MEDIUM,
  137.         'save'    => 'save_option_signature'
  138.     );
  139.  
  140.     if ($edit_identity{
  141.         $identities_link_value '<a href="options_identities.php">'
  142.                                . _("Edit Advanced Identities")
  143.                                . '</a> '
  144.                                . _("(discards changes made on this form so far)");
  145.         $optvals[SMOPT_GRP_CONTACT][array(
  146.             'name'    => 'identities_link',
  147.             'caption' => _("Multiple Identities"),
  148.             'type'    => SMOPT_TYPE_COMMENT,
  149.             'refresh' => SMOPT_REFRESH_NONE,
  150.             'comment' =>  $identities_link_value
  151.         );
  152.     }
  153.  
  154.     if $tzChangeAllowed || function_exists('date_default_timezone_set')) {
  155.         $TZ_ARRAY[SMPREF_NONE_("Same as server");
  156.  
  157.         $aTimeZones sq_get_tz_array();
  158.         unset($message);
  159.         if (empty($aTimeZones)) {
  160.             // check if current timezone is linked to other TZ and update it
  161.             if ($timeZone != SMPREF_NONE && $timeZone != "" &&
  162.                 isset($aTimeZones[$timeZone]['LINK'])) {
  163.                 $timeZone $aTimeZones[$timeZone]['LINK'];
  164.                 // TODO: recheck setting of $timeZone
  165.                 // setPref($data_dir,$username,'timezone',$timeZone);
  166.             }
  167.  
  168.             // sort time zones by name. sq_get_tz_array() returns sorted by key.
  169.             // asort($aTimeZones);
  170.  
  171.             // add all 'TZ' entries to TZ_ARRAY
  172.             foreach ($aTimeZones as $TzKey => $TzData{
  173.                 if (isset($TzData['LINK'])) {
  174.                     // Old display format
  175.                     $TZ_ARRAY[$TzKey$TzKey;
  176.  
  177.                     // US Eastern standard time (America/New_York) - needs asort($aTimeZones)
  178.                     //$TZ_ARRAY[$TzKey] = (isset($TzData['NAME']) ? $TzData['NAME']." ($TzKey)" : "($TzKey)");
  179.  
  180.                     // US Eastern standard time if NAME is present or America/New_York if NAME not present
  181.                     // needs sorting after all data is added or uasort()
  182.                     //$TZ_ARRAY[$TzKey] = (isset($TzData['NAME']) ? $TzData['NAME'] : $TzKey);
  183.  
  184.                     // (America/New_Your) US Eastern standard time
  185.                     //$TZ_ARRAY[$TzKey] = "($TzKey)" . (isset($TzData['NAME']) ? ' '.$TzData['NAME'] : '');
  186.                 }
  187.             }
  188.         else {
  189.             $message _("Error opening timezone config, contact administrator.");
  190.         }
  191.  
  192.         // TODO: make error user friendly
  193.         if (isset($message)) {
  194.             plain_error_message($message);
  195.             exit;
  196.         }
  197.  
  198.         $optgrps[SMOPT_GRP_TZ_("Timezone Options");
  199.         $optvals[SMOPT_GRP_TZarray();
  200.  
  201.         $optvals[SMOPT_GRP_TZ][array(
  202.             'name'    => 'timezone',
  203.             'caption' => _("Your current timezone"),
  204.             'type'    => SMOPT_TYPE_STRLIST,
  205.             'refresh' => SMOPT_REFRESH_NONE,
  206.             'posvals' => $TZ_ARRAY
  207.         );
  208.     }
  209.  
  210.     /*** Load the Reply Citation Options into the array ***/
  211.     $optgrps[SMOPT_GRP_REPLY_("Reply Citation Options");
  212.     $optvals[SMOPT_GRP_REPLYarray();
  213.  
  214.     $optvals[SMOPT_GRP_REPLY][array(
  215.         'name'    => 'reply_citation_style',
  216.         'caption' => _("Reply Citation Style"),
  217.         'type'    => SMOPT_TYPE_STRLIST,
  218.         'refresh' => SMOPT_REFRESH_NONE,
  219.         'posvals' => array(SMPREF_NONE    => _("No Citation"),
  220.                            'author_said'  => _("AUTHOR Wrote"),
  221.                            'date_time_author' => _("On DATE, AUTHOR Wrote"),
  222.                            'quote_who'    => _("Quote Who XML"),
  223.                            'user-defined' => _("User-Defined"))
  224.     );
  225.  
  226.     $optvals[SMOPT_GRP_REPLY][array(
  227.         'name'    => 'reply_citation_start',
  228.         'caption' => _("User-Defined Citation Start"),
  229.         'type'    => SMOPT_TYPE_STRING,
  230.         'refresh' => SMOPT_REFRESH_NONE,
  231.         'size'    => SMOPT_SIZE_MEDIUM
  232.     );
  233.  
  234.     $optvals[SMOPT_GRP_REPLY][array(
  235.         'name'    => 'reply_citation_end',
  236.         'caption' => _("User-Defined Citation End"),
  237.         'type'    => SMOPT_TYPE_STRING,
  238.         'refresh' => SMOPT_REFRESH_NONE,
  239.         'size'    => SMOPT_SIZE_MEDIUM
  240.     );
  241.  
  242.     /*** Load the Signature Options into the array ***/
  243.     $optgrps[SMOPT_GRP_SIG_("Signature Options");
  244.     $optvals[SMOPT_GRP_SIGarray();
  245.  
  246.     $optvals[SMOPT_GRP_SIG][array(
  247.         'name'    => 'use_signature',
  248.         'caption' => _("Use Signature"),
  249.         'type'    => SMOPT_TYPE_BOOLEAN,
  250.         'refresh' => SMOPT_REFRESH_NONE
  251.     );
  252.  
  253.     $optvals[SMOPT_GRP_SIG][array(
  254.         'name'    => 'prefix_sig',
  255.         'caption' => _("Prefix Signature with '-- ' Line"),
  256.         'type'    => SMOPT_TYPE_BOOLEAN,
  257.         'refresh' => SMOPT_REFRESH_NONE
  258.     );
  259.  
  260.     /* Assemble all this together and return it as our result. */
  261.     $result array(
  262.         'grps' => $optgrps,
  263.         'vals' => $optvals
  264.     );
  265.     return ($result);
  266. }
  267.  
  268. /******************************************************************/
  269. /** Define any specialized save functions for this option page. ***/
  270. /******************************************************************/
  271.  
  272. /**
  273.  * Saves the signature option.
  274.  */
  275. function save_option_signature($option{
  276.     global $data_dir$username;
  277.     setSig($data_dir$username'g'$option->new_value);
  278. }

Documentation generated on Mon, 13 Jan 2020 04:23:21 +0100 by phpDocumentor 1.4.3