display.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  1. <?php
  2. /**
  3. * options_display.php
  4. *
  5. * Copyright (c) 1999-2003 The SquirrelMail Project Team
  6. * Licensed under the GNU GPL. For full terms see the file COPYING.
  7. *
  8. * Displays all optinos about display preferences
  9. *
  10. * $Id$
  11. */
  12. /* Define the group constants for the display options page. */
  13. define('SMOPT_GRP_GENERAL', 0);
  14. define('SMOPT_GRP_MAILBOX', 1);
  15. define('SMOPT_GRP_MESSAGE', 2);
  16. /* Define the optpage load function for the display options page. */
  17. function load_optpage_data_display() {
  18. global $theme, $language, $languages, $js_autodetect_results,
  19. $compose_new_win, $default_use_mdn, $squirrelmail_language, $allow_thread_sort;
  20. /* Build a simple array into which we will build options. */
  21. $optgrps = array();
  22. $optvals = array();
  23. /******************************************************/
  24. /* LOAD EACH GROUP OF OPTIONS INTO THE OPTIONS ARRAY. */
  25. /******************************************************/
  26. /*** Load the General Options into the array ***/
  27. $optgrps[SMOPT_GRP_GENERAL] = _("General Display Options");
  28. $optvals[SMOPT_GRP_GENERAL] = array();
  29. /* Load the theme option. */
  30. $theme_values = array();
  31. foreach ($theme as $theme_key => $theme_attributes) {
  32. $theme_values[$theme_attributes['NAME']] = $theme_attributes['PATH'];
  33. }
  34. ksort($theme_values);
  35. $theme_values = array_flip($theme_values);
  36. $optvals[SMOPT_GRP_GENERAL][] = array(
  37. 'name' => 'chosen_theme',
  38. 'caption' => _("Theme"),
  39. 'type' => SMOPT_TYPE_STRLIST,
  40. 'refresh' => SMOPT_REFRESH_ALL,
  41. 'posvals' => $theme_values,
  42. 'save' => 'save_option_theme'
  43. );
  44. $css_values = array( 'none' => _("Default" ) );
  45. $handle=opendir('../themes/css/');
  46. while ($file = readdir($handle) ) {
  47. if ( substr( $file, -4 ) == '.css' ) {
  48. $css_values[$file] = substr( $file, 0, strlen( $file ) - 4 );
  49. }
  50. }
  51. closedir($handle);
  52. if ( count( $css_values ) > 1 ) {
  53. $optvals[SMOPT_GRP_GENERAL][] = array(
  54. 'name' => 'custom_css',
  55. 'caption' => _("Custom Stylesheet"),
  56. 'type' => SMOPT_TYPE_STRLIST,
  57. 'refresh' => SMOPT_REFRESH_ALL,
  58. 'posvals' => $css_values
  59. );
  60. }
  61. $language_values = array();
  62. foreach ($languages as $lang_key => $lang_attributes) {
  63. if (isset($lang_attributes['NAME'])) {
  64. $language_values[$lang_key] = $lang_attributes['NAME'];
  65. }
  66. }
  67. asort($language_values);
  68. $language_values =
  69. array_merge(array('' => _("Default")), $language_values);
  70. $language = $squirrelmail_language;
  71. $optvals[SMOPT_GRP_GENERAL][] = array(
  72. 'name' => 'language',
  73. 'caption' => _("Language"),
  74. 'type' => SMOPT_TYPE_STRLIST,
  75. 'refresh' => SMOPT_REFRESH_ALL,
  76. 'posvals' => $language_values
  77. );
  78. /* Set values for the "use javascript" option. */
  79. $optvals[SMOPT_GRP_GENERAL][] = array(
  80. 'name' => 'javascript_setting',
  81. 'caption' => _("Use Javascript"),
  82. 'type' => SMOPT_TYPE_STRLIST,
  83. 'refresh' => SMOPT_REFRESH_ALL,
  84. 'posvals' => array(SMPREF_JS_AUTODETECT => _("Autodetect"),
  85. SMPREF_JS_ON => _("Always"),
  86. SMPREF_JS_OFF => _("Never"))
  87. );
  88. $js_autodetect_script =
  89. "<SCRIPT LANGUAGE=\"JavaScript\" TYPE=\"text/javascript\"><!--\n".
  90. "document.forms[0].new_js_autodetect_results.value = '" . SMPREF_JS_ON . "';\n".
  91. "// --></SCRIPT>\n";
  92. $js_autodetect_results = SMPREF_JS_OFF;
  93. $optvals[SMOPT_GRP_GENERAL][] = array(
  94. 'name' => 'js_autodetect_results',
  95. 'caption' => '',
  96. 'type' => SMOPT_TYPE_HIDDEN,
  97. 'refresh' => SMOPT_REFRESH_NONE,
  98. 'post_script' => $js_autodetect_script,
  99. 'save' => 'save_option_javascript_autodetect'
  100. );
  101. /*** Load the General Options into the array ***/
  102. $optgrps[SMOPT_GRP_MAILBOX] = _("Mailbox Display Options");
  103. $optvals[SMOPT_GRP_MAILBOX] = array();
  104. $optvals[SMOPT_GRP_MAILBOX][] = array(
  105. 'name' => 'show_num',
  106. 'caption' => _("Number of Messages to Index"),
  107. 'type' => SMOPT_TYPE_INTEGER,
  108. 'refresh' => SMOPT_REFRESH_NONE,
  109. 'size' => SMOPT_SIZE_TINY
  110. );
  111. $optvals[SMOPT_GRP_MAILBOX][] = array(
  112. 'name' => 'alt_index_colors',
  113. 'caption' => _("Enable Alternating Row Colors"),
  114. 'type' => SMOPT_TYPE_BOOLEAN,
  115. 'refresh' => SMOPT_REFRESH_NONE
  116. );
  117. $optvals[SMOPT_GRP_MAILBOX][] = array(
  118. 'name' => 'page_selector',
  119. 'caption' => _("Enable Page Selector"),
  120. 'type' => SMOPT_TYPE_BOOLEAN,
  121. 'refresh' => SMOPT_REFRESH_NONE
  122. );
  123. $optvals[SMOPT_GRP_MAILBOX][] = array(
  124. 'name' => 'page_selector_max',
  125. 'caption' => _("Maximum Number of Pages to Show"),
  126. 'type' => SMOPT_TYPE_INTEGER,
  127. 'refresh' => SMOPT_REFRESH_NONE,
  128. 'size' => SMOPT_SIZE_TINY
  129. );
  130. $optvals[SMOPT_GRP_MAILBOX][] = array(
  131. 'name' => 'show_full_date',
  132. 'caption' => _("Always Show Full Date"),
  133. 'type' => SMOPT_TYPE_BOOLEAN,
  134. 'refresh' => SMOPT_REFRESH_NONE
  135. );
  136. $optvals[SMOPT_GRP_MAILBOX][] = array(
  137. 'name' => 'truncate_sender',
  138. 'caption' => _("Length of From/To Field (0 for full)"),
  139. 'type' => SMOPT_TYPE_INTEGER,
  140. 'refresh' => SMOPT_REFRESH_NONE,
  141. 'size' => SMOPT_SIZE_TINY
  142. );
  143. /*** Load the General Options into the array ***/
  144. $optgrps[SMOPT_GRP_MESSAGE] = _("Message Display and Composition");
  145. $optvals[SMOPT_GRP_MESSAGE] = array();
  146. $optvals[SMOPT_GRP_MESSAGE][] = array(
  147. 'name' => 'wrap_at',
  148. 'caption' => _("Wrap Incoming Text At"),
  149. 'type' => SMOPT_TYPE_INTEGER,
  150. 'refresh' => SMOPT_REFRESH_NONE,
  151. 'size' => SMOPT_SIZE_TINY
  152. );
  153. $optvals[SMOPT_GRP_MESSAGE][] = array(
  154. 'name' => 'editor_size',
  155. 'caption' => _("Size of Editor Window"),
  156. 'type' => SMOPT_TYPE_INTEGER,
  157. 'refresh' => SMOPT_REFRESH_NONE,
  158. 'size' => SMOPT_SIZE_TINY
  159. );
  160. $optvals[SMOPT_GRP_MESSAGE][] = array(
  161. 'name' => 'location_of_buttons',
  162. 'caption' => _("Location of Buttons when Composing"),
  163. 'type' => SMOPT_TYPE_STRLIST,
  164. 'refresh' => SMOPT_REFRESH_NONE,
  165. 'posvals' => array(SMPREF_LOC_TOP => _("Before headers"),
  166. SMPREF_LOC_BETWEEN => _("Between headers and message body"),
  167. SMPREF_LOC_BOTTOM => _("After message body"))
  168. );
  169. $optvals[SMOPT_GRP_MESSAGE][] = array(
  170. 'name' => 'use_javascript_addr_book',
  171. 'caption' => _("Addressbook Display Format"),
  172. 'type' => SMOPT_TYPE_STRLIST,
  173. 'refresh' => SMOPT_REFRESH_NONE,
  174. 'posvals' => array('1' => _("Javascript"),
  175. '0' => _("HTML"))
  176. );
  177. $optvals[SMOPT_GRP_MESSAGE][] = array(
  178. 'name' => 'show_html_default',
  179. 'caption' => _("Show HTML Version by Default"),
  180. 'type' => SMOPT_TYPE_BOOLEAN,
  181. 'refresh' => SMOPT_REFRESH_NONE
  182. );
  183. $optvals[SMOPT_GRP_MESSAGE][] = array(
  184. 'name' => 'enable_forward_as_attachment',
  185. 'caption' => _("Enable Forward as Attachment"),
  186. 'type' => SMOPT_TYPE_BOOLEAN,
  187. 'refresh' => SMOPT_REFRESH_NONE
  188. );
  189. $optvals[SMOPT_GRP_MESSAGE][] = array(
  190. 'name' => 'forward_cc',
  191. 'caption' => _("Include CCs when Forwarding Messages"),
  192. 'type' => SMOPT_TYPE_BOOLEAN,
  193. 'refresh' => SMOPT_REFRESH_NONE
  194. );
  195. $optvals[SMOPT_GRP_MESSAGE][] = array(
  196. 'name' => 'include_self_reply_all',
  197. 'caption' => _("Include Me in CC when I Reply All"),
  198. 'type' => SMOPT_TYPE_BOOLEAN,
  199. 'refresh' => SMOPT_REFRESH_NONE
  200. );
  201. $optvals[SMOPT_GRP_MESSAGE][] = array(
  202. 'name' => 'show_xmailer_default',
  203. 'caption' => _("Enable Mailer Display"),
  204. 'type' => SMOPT_TYPE_BOOLEAN,
  205. 'refresh' => SMOPT_REFRESH_NONE
  206. );
  207. $optvals[SMOPT_GRP_MESSAGE][] = array(
  208. 'name' => 'attachment_common_show_images',
  209. 'caption' => _("Display Attached Images with Message"),
  210. 'type' => SMOPT_TYPE_BOOLEAN,
  211. 'refresh' => SMOPT_REFRESH_NONE
  212. );
  213. $optvals[SMOPT_GRP_MESSAGE][] = array(
  214. 'name' => 'pf_cleandisplay',
  215. 'caption' => _("Enable Printer Friendly Clean Display"),
  216. 'type' => SMOPT_TYPE_BOOLEAN,
  217. 'refresh' => SMOPT_REFRESH_NONE
  218. );
  219. if ($default_use_mdn) {
  220. $optvals[SMOPT_GRP_MESSAGE][] = array(
  221. 'name' => 'mdn_user_support',
  222. 'caption' => _("Enable Mail Delivery Notification"),
  223. 'type' => SMOPT_TYPE_BOOLEAN,
  224. 'refresh' => SMOPT_REFRESH_NONE
  225. );
  226. }
  227. $optvals[SMOPT_GRP_MESSAGE][] = array(
  228. 'name' => 'compose_new_win',
  229. 'caption' => _("Compose Messages in New Window"),
  230. 'type' => SMOPT_TYPE_BOOLEAN,
  231. 'refresh' => SMOPT_REFRESH_ALL
  232. );
  233. $optvals[SMOPT_GRP_MESSAGE][] = array(
  234. 'name' => 'compose_width',
  235. 'caption' => _("Width of Compose Window"),
  236. 'type' => SMOPT_TYPE_INTEGER,
  237. 'refresh' => SMOPT_REFRESH_ALL,
  238. 'size' => SMOPT_SIZE_TINY
  239. );
  240. $optvals[SMOPT_GRP_MESSAGE][] = array(
  241. 'name' => 'compose_height',
  242. 'caption' => _("Height of Compose Window"),
  243. 'type' => SMOPT_TYPE_INTEGER,
  244. 'refresh' => SMOPT_REFRESH_ALL,
  245. 'size' => SMOPT_SIZE_TINY
  246. );
  247. $optvals[SMOPT_GRP_MESSAGE][] = array(
  248. 'name' => 'sig_first',
  249. 'caption' => _("Append Signature before Reply/Forward Text"),
  250. 'type' => SMOPT_TYPE_BOOLEAN,
  251. 'refresh' => SMOPT_REFRESH_NONE
  252. );
  253. $optvals[SMOPT_GRP_MESSAGE][] = array(
  254. 'name' => 'strip_sigs',
  255. 'caption' => _("Strip signature when replying"),
  256. 'type' => SMOPT_TYPE_BOOLEAN,
  257. 'refresh' => SMOPT_REFRESH_NONE
  258. );
  259. $optvals[SMOPT_GRP_MESSAGE][] = array(
  260. 'name' => 'internal_date_sort',
  261. 'caption' => _("Enable Sort by of Receive Date"),
  262. 'type' => SMOPT_TYPE_BOOLEAN,
  263. 'refresh' => SMOPT_REFRESH_ALL
  264. );
  265. if ($allow_thread_sort == TRUE) {
  266. $optvals[SMOPT_GRP_MESSAGE][] = array(
  267. 'name' => 'sort_by_ref',
  268. 'caption' => _("Enable Thread Sort by References Header"),
  269. 'type' => SMOPT_TYPE_BOOLEAN,
  270. 'refresh' => SMOPT_REFRESH_ALL
  271. );
  272. }
  273. /* Assemble all this together and return it as our result. */
  274. $result = array(
  275. 'grps' => $optgrps,
  276. 'vals' => $optvals
  277. );
  278. return ($result);
  279. }
  280. /******************************************************************/
  281. /** Define any specialized save functions for this option page. ***/
  282. /******************************************************************/
  283. function save_option_theme($option) {
  284. global $theme;
  285. /* Do checking to make sure $new_theme is in the array. */
  286. $theme_in_array = false;
  287. for ($i = 0; $i < count($theme); ++$i) {
  288. if ($theme[$i]['PATH'] == $option->new_value) {
  289. $theme_in_array = true;
  290. break;
  291. }
  292. }
  293. if (!$theme_in_array) {
  294. $option->new_value = '';
  295. }
  296. /* Save the option like normal. */
  297. save_option($option);
  298. }
  299. function save_option_javascript_autodetect($option) {
  300. global $data_dir, $username, $new_javascript_setting;
  301. /* Set javascript either on or off. */
  302. if ($new_javascript_setting == SMPREF_JS_AUTODETECT) {
  303. if ($option->new_value == SMPREF_JS_ON) {
  304. setPref($data_dir, $username, 'javascript_on', SMPREF_JS_ON);
  305. } else {
  306. setPref($data_dir, $username, 'javascript_on', SMPREF_JS_OFF);
  307. }
  308. } else {
  309. setPref($data_dir, $username, 'javascript_on', $new_javascript_setting);
  310. }
  311. }
  312. ?>