personal.php 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. <?php
  2. /**
  3. * options_personal.php
  4. *
  5. * Copyright (c) 1999-2004 The SquirrelMail Project Team
  6. * Licensed under the GNU GPL. For full terms see the file COPYING.
  7. *
  8. * Displays all options relating to personal information
  9. *
  10. * @version $Id$
  11. * @package squirrelmail
  12. */
  13. /** SquirrelMail required files. */
  14. require_once(SM_PATH . 'functions/imap.php');
  15. /* Define the group constants for the personal options page. */
  16. define('SMOPT_GRP_CONTACT', 0);
  17. define('SMOPT_GRP_REPLY', 1);
  18. define('SMOPT_GRP_SIG', 2);
  19. define('SMOPT_GRP_TZ', 3);
  20. /**
  21. * This function builds an array with all the information about
  22. * the options available to the user, and returns it. The options
  23. * are grouped by the groups in which they are displayed.
  24. * For each option, the following information is stored:
  25. * - name: the internal (variable) name
  26. * - caption: the description of the option in the UI
  27. * - type: one of SMOPT_TYPE_*
  28. * - refresh: one of SMOPT_REFRESH_*
  29. * - size: one of SMOPT_SIZE_*
  30. * - save: the name of a function to call when saving this option
  31. * @return array all option information
  32. */
  33. function load_optpage_data_personal() {
  34. global $data_dir, $username, $edit_identity, $edit_name,
  35. $full_name, $reply_to, $email_address, $signature, $tzChangeAllowed,
  36. $color;
  37. /* Set the values of some global variables. */
  38. $full_name = getPref($data_dir, $username, 'full_name');
  39. $reply_to = getPref($data_dir, $username, 'reply_to');
  40. $email_address = getPref($data_dir, $username, 'email_address');
  41. $signature = getSig($data_dir, $username, 'g');
  42. /* Build a simple array into which we will build options. */
  43. $optgrps = array();
  44. $optvals = array();
  45. /******************************************************/
  46. /* LOAD EACH GROUP OF OPTIONS INTO THE OPTIONS ARRAY. */
  47. /******************************************************/
  48. /*** Load the Contact Information Options into the array ***/
  49. $optgrps[SMOPT_GRP_CONTACT] = _("Name and Address Options");
  50. $optvals[SMOPT_GRP_CONTACT] = array();
  51. /* Build a simple array into which we will build options. */
  52. $optvals = array();
  53. if (!isset($edit_identity)) {
  54. $edit_identity = TRUE;
  55. }
  56. if ($edit_identity || $edit_name) {
  57. $optvals[SMOPT_GRP_CONTACT][] = array(
  58. 'name' => 'full_name',
  59. 'caption' => _("Full Name"),
  60. 'type' => SMOPT_TYPE_STRING,
  61. 'refresh' => SMOPT_REFRESH_NONE,
  62. 'size' => SMOPT_SIZE_HUGE
  63. );
  64. } else {
  65. $optvals[SMOPT_GRP_CONTACT][] = array(
  66. 'name' => 'full_name',
  67. 'caption' => _("Full Name"),
  68. 'type' => SMOPT_TYPE_COMMENT,
  69. 'refresh' => SMOPT_REFRESH_NONE,
  70. 'comment' => $full_name
  71. );
  72. }
  73. if ($edit_identity) {
  74. $optvals[SMOPT_GRP_CONTACT][] = array(
  75. 'name' => 'email_address',
  76. 'caption' => _("Email Address"),
  77. 'type' => SMOPT_TYPE_STRING,
  78. 'refresh' => SMOPT_REFRESH_NONE,
  79. 'size' => SMOPT_SIZE_HUGE
  80. );
  81. } else {
  82. $optvals[SMOPT_GRP_CONTACT][] = array(
  83. 'name' => 'email_address',
  84. 'caption' => _("Email Address"),
  85. 'type' => SMOPT_TYPE_COMMENT,
  86. 'refresh' => SMOPT_REFRESH_NONE,
  87. 'comment' => $email_address
  88. );
  89. }
  90. $optvals[SMOPT_GRP_CONTACT][] = array(
  91. 'name' => 'reply_to',
  92. 'caption' => _("Reply To"),
  93. 'type' => SMOPT_TYPE_STRING,
  94. 'refresh' => SMOPT_REFRESH_NONE,
  95. 'size' => SMOPT_SIZE_HUGE
  96. );
  97. $optvals[SMOPT_GRP_CONTACT][] = array(
  98. 'name' => 'signature',
  99. 'caption' => _("Signature"),
  100. 'type' => SMOPT_TYPE_TEXTAREA,
  101. 'refresh' => SMOPT_REFRESH_NONE,
  102. 'size' => SMOPT_SIZE_MEDIUM,
  103. 'save' => 'save_option_signature'
  104. );
  105. if ($edit_identity) {
  106. $identities_link_value = '<A HREF="options_identities.php">'
  107. . _("Edit Advanced Identities")
  108. . '</A> '
  109. . _("(discards changes made on this form so far)");
  110. $optvals[SMOPT_GRP_CONTACT][] = array(
  111. 'name' => 'identities_link',
  112. 'caption' => _("Multiple Identities"),
  113. 'type' => SMOPT_TYPE_COMMENT,
  114. 'refresh' => SMOPT_REFRESH_NONE,
  115. 'comment' => $identities_link_value
  116. );
  117. }
  118. if ( $tzChangeAllowed ) {
  119. $TZ_ARRAY[SMPREF_NONE] = _("Same as server");
  120. $tzfile = SM_PATH . 'locale/timezones.cfg';
  121. if ((!is_readable($tzfile)) or (!$fd = fopen($tzfile,'r'))) {
  122. $message = _("Error opening timezone config, contact administrator.");
  123. }
  124. if (isset($message)) {
  125. plain_error_message($message, $color);
  126. exit;
  127. }
  128. while (!feof ($fd)) {
  129. $zone = fgets($fd, 1024);
  130. if( $zone ) {
  131. $zone = trim($zone);
  132. $TZ_ARRAY[$zone] = $zone;
  133. }
  134. }
  135. fclose ($fd);
  136. $optgrps[SMOPT_GRP_TZ] = _("Timezone Options");
  137. $optvals[SMOPT_GRP_TZ] = array();
  138. $optvals[SMOPT_GRP_TZ][] = array(
  139. 'name' => 'timezone',
  140. 'caption' => _("Your current timezone"),
  141. 'type' => SMOPT_TYPE_STRLIST,
  142. 'refresh' => SMOPT_REFRESH_NONE,
  143. 'posvals' => $TZ_ARRAY
  144. );
  145. }
  146. /*** Load the Reply Citation Options into the array ***/
  147. $optgrps[SMOPT_GRP_REPLY] = _("Reply Citation Options");
  148. $optvals[SMOPT_GRP_REPLY] = array();
  149. $optvals[SMOPT_GRP_REPLY][] = array(
  150. 'name' => 'reply_citation_style',
  151. 'caption' => _("Reply Citation Style"),
  152. 'type' => SMOPT_TYPE_STRLIST,
  153. 'refresh' => SMOPT_REFRESH_NONE,
  154. 'posvals' => array(SMPREF_NONE => _("No Citation"),
  155. 'author_said' => _("AUTHOR Said"),
  156. 'date_time_author' => _("On DATE, AUTHOR Said"),
  157. 'quote_who' => _("Quote Who XML"),
  158. 'user-defined' => _("User-Defined"))
  159. );
  160. $optvals[SMOPT_GRP_REPLY][] = array(
  161. 'name' => 'reply_citation_start',
  162. 'caption' => _("User-Defined Citation Start"),
  163. 'type' => SMOPT_TYPE_STRING,
  164. 'refresh' => SMOPT_REFRESH_NONE,
  165. 'size' => SMOPT_SIZE_MEDIUM
  166. );
  167. $optvals[SMOPT_GRP_REPLY][] = array(
  168. 'name' => 'reply_citation_end',
  169. 'caption' => _("User-Defined Citation End"),
  170. 'type' => SMOPT_TYPE_STRING,
  171. 'refresh' => SMOPT_REFRESH_NONE,
  172. 'size' => SMOPT_SIZE_MEDIUM
  173. );
  174. /*** Load the Signature Options into the array ***/
  175. $optgrps[SMOPT_GRP_SIG] = _("Signature Options");
  176. $optvals[SMOPT_GRP_SIG] = array();
  177. $optvals[SMOPT_GRP_SIG][] = array(
  178. 'name' => 'use_signature',
  179. 'caption' => _("Use Signature"),
  180. 'type' => SMOPT_TYPE_BOOLEAN,
  181. 'refresh' => SMOPT_REFRESH_NONE
  182. );
  183. $optvals[SMOPT_GRP_SIG][] = array(
  184. 'name' => 'prefix_sig',
  185. 'caption' => _("Prefix Signature with '-- ' Line"),
  186. 'type' => SMOPT_TYPE_BOOLEAN,
  187. 'refresh' => SMOPT_REFRESH_NONE
  188. );
  189. /* Assemble all this together and return it as our result. */
  190. $result = array(
  191. 'grps' => $optgrps,
  192. 'vals' => $optvals
  193. );
  194. return ($result);
  195. }
  196. /******************************************************************/
  197. /** Define any specialized save functions for this option page. ***/
  198. /******************************************************************/
  199. /**
  200. * Saves the signature option.
  201. */
  202. function save_option_signature($option) {
  203. global $data_dir, $username;
  204. setSig($data_dir, $username, 'g', $option->new_value);
  205. }
  206. ?>