Source for file personal.php

Documentation is available at personal.php

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

Documentation generated on 2020年1月13日 04:25:10 +0100 by phpDocumentor 1.4.3

AltStyle によって変換されたページ (->オリジナル) /