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 &copy; 1999-2006 The SquirrelMail Project Team
  9.  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  10.  * @version $Id: personal.php,v 1.8.2.8 2006/02/03 22:27:51 jervfors Exp $
  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,
  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.     $optvals[SMOPT_GRP_CONTACT][array(
  102.         'name'    => 'reply_to',
  103.         'caption' => _("Reply To"),
  104.         'type'    => SMOPT_TYPE_STRING,
  105.         'refresh' => SMOPT_REFRESH_NONE,
  106.         'size'    => SMOPT_SIZE_HUGE
  107.     );
  108.  
  109.     $optvals[SMOPT_GRP_CONTACT][array(
  110.         'name'    => 'signature',
  111.         'caption' => _("Signature"),
  112.         'type'    => SMOPT_TYPE_TEXTAREA,
  113.         'refresh' => SMOPT_REFRESH_NONE,
  114.         'size'    => SMOPT_SIZE_MEDIUM,
  115.         'save'    => 'save_option_signature'
  116.     );
  117.  
  118.     if ($edit_identity{
  119.         $identities_link_value '<a href="options_identities.php">'
  120.                                . _("Edit Advanced Identities")
  121.                                . '</a> '
  122.                                . _("(discards changes made on this form so far)");
  123.         $optvals[SMOPT_GRP_CONTACT][array(
  124.             'name'    => 'identities_link',
  125.             'caption' => _("Multiple Identities"),
  126.             'type'    => SMOPT_TYPE_COMMENT,
  127.             'refresh' => SMOPT_REFRESH_NONE,
  128.             'comment' =>  $identities_link_value
  129.         );
  130.     }
  131.  
  132.     if $tzChangeAllowed {
  133.         $TZ_ARRAY[SMPREF_NONE_("Same as server");
  134.         $tzfile SM_PATH 'locale/timezones.cfg';
  135.         if ((!is_readable($tzfile)) or (!$fd fopen($tzfile,'r'))) {
  136.             $message _("Error opening timezone config, contact administrator.");
  137.         }
  138.  
  139.         // TODO: make error user friendly
  140.         if (isset($message)) {
  141.             plain_error_message($message$color);
  142.             exit;
  143.         }
  144.         while (!feof ($fd)) {
  145.             $zone fgets($fd1024);
  146.             if$zone {
  147.                 $zone trim($zone);
  148.                 $TZ_ARRAY[$zone$zone;
  149.             }
  150.         }
  151.         fclose ($fd);
  152.  
  153.         $optgrps[SMOPT_GRP_TZ_("Timezone Options");
  154.         $optvals[SMOPT_GRP_TZarray();
  155.  
  156.         $optvals[SMOPT_GRP_TZ][array(
  157.             'name'    => 'timezone',
  158.             'caption' => _("Your current timezone"),
  159.             'type'    => SMOPT_TYPE_STRLIST,
  160.             'refresh' => SMOPT_REFRESH_NONE,
  161.             'posvals' => $TZ_ARRAY
  162.         );
  163.     }
  164.  
  165.     /*** Load the Reply Citation Options into the array ***/
  166.     $optgrps[SMOPT_GRP_REPLY_("Reply Citation Options");
  167.     $optvals[SMOPT_GRP_REPLYarray();
  168.  
  169.     $optvals[SMOPT_GRP_REPLY][array(
  170.         'name'    => 'reply_citation_style',
  171.         'caption' => _("Reply Citation Style"),
  172.         'type'    => SMOPT_TYPE_STRLIST,
  173.         'refresh' => SMOPT_REFRESH_NONE,
  174.         'posvals' => array(SMPREF_NONE    => _("No Citation"),
  175.                            'author_said'  => _("AUTHOR Wrote"),
  176.                            'date_time_author' => _("On DATE, AUTHOR Wrote"),
  177.                            'quote_who'    => _("Quote Who XML"),
  178.                            'user-defined' => _("User-Defined"))
  179.     );
  180.  
  181.     $optvals[SMOPT_GRP_REPLY][array(
  182.         'name'    => 'reply_citation_start',
  183.         'caption' => _("User-Defined Citation Start"),
  184.         'type'    => SMOPT_TYPE_STRING,
  185.         'refresh' => SMOPT_REFRESH_NONE,
  186.         'size'    => SMOPT_SIZE_MEDIUM
  187.     );
  188.  
  189.     $optvals[SMOPT_GRP_REPLY][array(
  190.         'name'    => 'reply_citation_end',
  191.         'caption' => _("User-Defined Citation End"),
  192.         'type'    => SMOPT_TYPE_STRING,
  193.         'refresh' => SMOPT_REFRESH_NONE,
  194.         'size'    => SMOPT_SIZE_MEDIUM
  195.     );
  196.  
  197.     /*** Load the Signature Options into the array ***/
  198.     $optgrps[SMOPT_GRP_SIG_("Signature Options");
  199.     $optvals[SMOPT_GRP_SIGarray();
  200.  
  201.     $optvals[SMOPT_GRP_SIG][array(
  202.         'name'    => 'use_signature',
  203.         'caption' => _("Use Signature"),
  204.         'type'    => SMOPT_TYPE_BOOLEAN,
  205.         'refresh' => SMOPT_REFRESH_NONE
  206.     );
  207.  
  208.     $optvals[SMOPT_GRP_SIG][array(
  209.         'name'    => 'prefix_sig',
  210.         'caption' => _("Prefix Signature with '-- ' Line"),
  211.         'type'    => SMOPT_TYPE_BOOLEAN,
  212.         'refresh' => SMOPT_REFRESH_NONE
  213.     );
  214.  
  215.     /* Assemble all this together and return it as our result. */
  216.     $result array(
  217.         'grps' => $optgrps,
  218.         'vals' => $optvals
  219.     );
  220.     return ($result);
  221. }
  222.  
  223. /******************************************************************/
  224. /** Define any specialized save functions for this option page. ***/
  225. /******************************************************************/
  226.  
  227. /**
  228.  * Saves the signature option.
  229.  */
  230. function save_option_signature($option{
  231.     global $data_dir$username;
  232.     setSig($data_dir$username'g'$option->new_value);
  233. }
  234.  
  235. ?>

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