folder.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. <?php
  2. /**
  3. * options_folder.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 folders
  9. *
  10. * @version $Id$
  11. * @package squirrelmail
  12. */
  13. /** SquirrelMail required files. */
  14. require_once(SM_PATH . 'functions/imap.php');
  15. require_once(SM_PATH . 'functions/imap_general.php');
  16. /* Define the group constants for the folder options page. */
  17. define('SMOPT_GRP_SPCFOLDER', 0);
  18. define('SMOPT_GRP_FOLDERLIST', 1);
  19. define('SMOPT_GRP_FOLDERSELECT', 2);
  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_folder() {
  34. global $username, $key, $imapServerAddress, $imapPort;
  35. global $folder_prefix, $default_folder_prefix, $show_prefix_option;
  36. /* Get some imap data we need later. */
  37. $imapConnection =
  38. sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
  39. $boxes = sqimap_mailbox_list($imapConnection);
  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 General Options into the array ***/
  47. $optgrps[SMOPT_GRP_SPCFOLDER] = _("Special Folder Options");
  48. $optvals[SMOPT_GRP_SPCFOLDER] = array();
  49. if (!isset($folder_prefix)) { $folder_prefix = $default_folder_prefix; }
  50. if ($show_prefix_option) {
  51. $optvals[SMOPT_GRP_SPCFOLDER][] = array(
  52. 'name' => 'folder_prefix',
  53. 'caption' => _("Folder Path"),
  54. 'type' => SMOPT_TYPE_STRING,
  55. 'refresh' => SMOPT_REFRESH_FOLDERLIST,
  56. 'size' => SMOPT_SIZE_LARGE
  57. );
  58. }
  59. $trash_folder_values = array(SMPREF_NONE => '[ '._("Do not use Trash").' ]',
  60. 'whatever' => $boxes);
  61. $optvals[SMOPT_GRP_SPCFOLDER][] = array(
  62. 'name' => 'trash_folder',
  63. 'caption' => _("Trash Folder"),
  64. 'type' => SMOPT_TYPE_FLDRLIST,
  65. 'refresh' => SMOPT_REFRESH_FOLDERLIST,
  66. 'posvals' => $trash_folder_values,
  67. 'save' => 'save_option_trash_folder'
  68. );
  69. $draft_folder_values = array(SMPREF_NONE => '[ '._("Do not use Drafts").' ]',
  70. 'whatever' => $boxes);
  71. $optvals[SMOPT_GRP_SPCFOLDER][] = array(
  72. 'name' => 'draft_folder',
  73. 'caption' => _("Draft Folder"),
  74. 'type' => SMOPT_TYPE_FLDRLIST,
  75. 'refresh' => SMOPT_REFRESH_FOLDERLIST,
  76. 'posvals' => $draft_folder_values,
  77. 'save' => 'save_option_draft_folder'
  78. );
  79. $sent_folder_values = array(SMPREF_NONE => '[ '._("Do not use Sent").' ]',
  80. 'whatever' => $boxes);
  81. $optvals[SMOPT_GRP_SPCFOLDER][] = array(
  82. 'name' => 'sent_folder',
  83. 'caption' => _("Sent Folder"),
  84. 'type' => SMOPT_TYPE_FLDRLIST,
  85. 'refresh' => SMOPT_REFRESH_FOLDERLIST,
  86. 'posvals' => $sent_folder_values,
  87. 'save' => 'save_option_sent_folder'
  88. );
  89. $optvals[SMOPT_GRP_SPCFOLDER][] = array(
  90. 'name' => 'save_reply_with_orig',
  91. 'caption' => _("Save Replies with Original Message"),
  92. 'type' => SMOPT_TYPE_BOOLEAN,
  93. 'refresh' => SMOPT_REFRESH_FOLDERLIST
  94. );
  95. /*** Load the General Options into the array ***/
  96. $optgrps[SMOPT_GRP_FOLDERLIST] = _("Folder List Options");
  97. $optvals[SMOPT_GRP_FOLDERLIST] = array();
  98. $optvals[SMOPT_GRP_FOLDERLIST][] = array(
  99. 'name' => 'location_of_bar',
  100. 'caption' => _("Location of Folder List"),
  101. 'type' => SMOPT_TYPE_STRLIST,
  102. 'refresh' => SMOPT_REFRESH_ALL,
  103. 'posvals' => array(SMPREF_LOC_LEFT => _("Left"),
  104. SMPREF_LOC_RIGHT => _("Right"))
  105. );
  106. $left_size_values = array();
  107. for ($lsv = 100; $lsv <= 300; $lsv += 10) {
  108. $left_size_values[$lsv] = "$lsv " . _("pixels");
  109. }
  110. $optvals[SMOPT_GRP_FOLDERLIST][] = array(
  111. 'name' => 'left_size',
  112. 'caption' => _("Width of Folder List"),
  113. 'type' => SMOPT_TYPE_STRLIST,
  114. 'refresh' => SMOPT_REFRESH_ALL,
  115. 'posvals' => $left_size_values
  116. );
  117. $minute_str = _("Minutes");
  118. $left_refresh_values = array(SMPREF_NONE => _("Never"));
  119. foreach (array(30,60,120,180,300,600) as $lr_val) {
  120. if ($lr_val < 60) {
  121. $left_refresh_values[$lr_val] = "$lr_val " . _("Seconds");
  122. } else if ($lr_val == 60) {
  123. $left_refresh_values[$lr_val] = "1 " . _("Minute");
  124. } else {
  125. $left_refresh_values[$lr_val] = ($lr_val/60) . " $minute_str";
  126. }
  127. }
  128. $optvals[SMOPT_GRP_FOLDERLIST][] = array(
  129. 'name' => 'left_refresh',
  130. 'caption' => _("Auto Refresh Folder List"),
  131. 'type' => SMOPT_TYPE_STRLIST,
  132. 'refresh' => SMOPT_REFRESH_FOLDERLIST,
  133. 'posvals' => $left_refresh_values
  134. );
  135. $optvals[SMOPT_GRP_FOLDERLIST][] = array(
  136. 'name' => 'unseen_notify',
  137. 'caption' => _("Enable Unread Message Notification"),
  138. 'type' => SMOPT_TYPE_STRLIST,
  139. 'refresh' => SMOPT_REFRESH_FOLDERLIST,
  140. 'posvals' => array(SMPREF_UNSEEN_NONE => _("No Notification"),
  141. SMPREF_UNSEEN_INBOX => _("Only INBOX"),
  142. SMPREF_UNSEEN_ALL => _("All Folders"))
  143. );
  144. $optvals[SMOPT_GRP_FOLDERLIST][] = array(
  145. 'name' => 'unseen_type',
  146. 'caption' => _("Unread Message Notification Type"),
  147. 'type' => SMOPT_TYPE_STRLIST,
  148. 'refresh' => SMOPT_REFRESH_FOLDERLIST,
  149. 'posvals' => array(SMPREF_UNSEEN_ONLY => _("Only Unseen"),
  150. SMPREF_UNSEEN_TOTAL => _("Unseen and Total"))
  151. );
  152. $optvals[SMOPT_GRP_FOLDERLIST][] = array(
  153. 'name' => 'collapse_folders',
  154. 'caption' => _("Enable Collapsable Folders"),
  155. 'type' => SMOPT_TYPE_BOOLEAN,
  156. 'refresh' => SMOPT_REFRESH_FOLDERLIST
  157. );
  158. $optvals[SMOPT_GRP_FOLDERLIST][] = array(
  159. 'name' => 'unseen_cum',
  160. 'caption' => _("Enable Cumulative Unread Message Notification"),
  161. 'type' => SMOPT_TYPE_BOOLEAN,
  162. 'refresh' => SMOPT_REFRESH_FOLDERLIST
  163. );
  164. $optvals[SMOPT_GRP_FOLDERLIST][] = array(
  165. 'name' => 'date_format',
  166. 'caption' => _("Show Clock on Folders Panel"),
  167. 'type' => SMOPT_TYPE_STRLIST,
  168. 'refresh' => SMOPT_REFRESH_FOLDERLIST,
  169. 'posvals' => array( '0' => _("International date and time"),
  170. '1' => _("American date and time"),
  171. '2' => _("European date and time"),
  172. '3' => _("Show weekday and time"),
  173. '4' => _("Show time with seconds"),
  174. '5' => _("Show time"),
  175. '6' => _("No Clock")),
  176. );
  177. $optvals[SMOPT_GRP_FOLDERLIST][] = array(
  178. 'name' => 'hour_format',
  179. 'caption' => _("Hour Format"),
  180. 'type' => SMOPT_TYPE_STRLIST,
  181. 'refresh' => SMOPT_REFRESH_FOLDERLIST,
  182. 'posvals' => array(SMPREF_TIME_12HR => _("12-hour clock"),
  183. SMPREF_TIME_24HR => _("24-hour clock"))
  184. );
  185. $optvals[SMOPT_GRP_FOLDERLIST][] = array(
  186. 'name' => 'search_memory',
  187. 'caption' => _("Memory Search"),
  188. 'type' => SMOPT_TYPE_STRLIST,
  189. 'refresh' => SMOPT_REFRESH_NONE,
  190. 'posvals' => array( 0 => _("Disabled"),
  191. 1 => '1',
  192. 2 => '2',
  193. 3 => '3',
  194. 4 => '4',
  195. 5 => '5',
  196. 6 => '6',
  197. 7 => '7',
  198. 8 => '8',
  199. 9 => '9')
  200. );
  201. /*** Load the General Options into the array ***/
  202. $optgrps[SMOPT_GRP_FOLDERSELECT] = _("Folder Selection Options");
  203. $optvals[SMOPT_GRP_FOLDERSELECT] = array();
  204. $delim = sqimap_get_delimiter($imapConnection);
  205. $optvals[SMOPT_GRP_FOLDERSELECT][] = array(
  206. 'name' => 'mailbox_select_style',
  207. 'caption' => _("Selection List Style"),
  208. 'type' => SMOPT_TYPE_STRLIST,
  209. 'refresh' => SMOPT_REFRESH_NONE,
  210. 'posvals' => array( 0 => _("Long: ") . '"' . _("Folder") . $delim . _("Subfolder") . '"',
  211. 1 => _("Indented: ") . '"&nbsp;&nbsp;&nbsp;&nbsp;' . _("Subfolder") . '"',
  212. 2 => _("Delimited: ") . '".&nbsp;' . _("Subfolder") . '"')
  213. );
  214. /* Assemble all this together and return it as our result. */
  215. $result = array(
  216. 'grps' => $optgrps,
  217. 'vals' => $optvals
  218. );
  219. sqimap_logout($imapConnection);
  220. return ($result);
  221. }
  222. /******************************************************************/
  223. /** Define any specialized save functions for this option page. ***/
  224. /******************************************************************/
  225. /**
  226. * Saves the trash folder option.
  227. */
  228. function save_option_trash_folder($option) {
  229. global $data_dir, $username;
  230. /* Set move to trash on or off. */
  231. $trash_on = ($option->new_value == SMPREF_NONE ? SMPREF_OFF : SMPREF_ON);
  232. setPref($data_dir, $username, 'move_to_trash', $trash_on);
  233. /* Now just save the option as normal. */
  234. save_option($option);
  235. }
  236. /**
  237. * Saves the sent folder option.
  238. */
  239. function save_option_sent_folder($option) {
  240. global $data_dir, $username;
  241. /* Set move to sent on or off. */
  242. $sent_on = ($option->new_value == SMPREF_NONE ? SMPREF_OFF : SMPREF_ON);
  243. setPref($data_dir, $username, 'move_to_sent', $sent_on);
  244. /* Now just save the option as normal. */
  245. save_option($option);
  246. }
  247. /**
  248. * Saves the draft folder option.
  249. */
  250. function save_option_draft_folder($option) {
  251. global $data_dir, $username;
  252. /* Set move to draft on or off. */
  253. $draft_on = ($option->new_value == SMPREF_NONE ? SMPREF_OFF : SMPREF_ON);
  254. setPref($data_dir, $username, 'save_as_draft', $draft_on);
  255. /* Now just save the option as normal. */
  256. save_option($option);
  257. }
  258. ?>