folder.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. <?php
  2. /**
  3. * options_folder.php
  4. *
  5. * Displays all options relating to folders
  6. *
  7. * @copyright &copy; 1999-2007 The SquirrelMail Project Team
  8. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  9. * @version $Id$
  10. * @package squirrelmail
  11. */
  12. /** SquirrelMail required files. */
  13. include(SM_PATH . 'functions/imap_general.php');
  14. /* Define the group constants for the folder options page. */
  15. define('SMOPT_GRP_SPCFOLDER', 0);
  16. define('SMOPT_GRP_FOLDERLIST', 1);
  17. define('SMOPT_GRP_FOLDERSELECT', 2);
  18. /**
  19. * This function builds an array with all the information about
  20. * the options available to the user, and returns it. The options
  21. * are grouped by the groups in which they are displayed.
  22. * For each option, the following information is stored:
  23. * - name: the internal (variable) name
  24. * - caption: the description of the option in the UI
  25. * - type: one of SMOPT_TYPE_*
  26. * - refresh: one of SMOPT_REFRESH_*
  27. * - size: one of SMOPT_SIZE_*
  28. * - save: the name of a function to call when saving this option
  29. * @return array all option information
  30. */
  31. function load_optpage_data_folder() {
  32. global $username, $imapServerAddress, $imapPort, $oTemplate, $nbsp,
  33. $folder_prefix, $default_folder_prefix, $show_prefix_option;
  34. /* Get some imap data we need later. */
  35. $imapConnection = sqimap_login($username, false, $imapServerAddress, $imapPort, 0);
  36. $boxes = sqimap_mailbox_list($imapConnection);
  37. /* Build a simple array into which we will build options. */
  38. $optgrps = array();
  39. $optvals = array();
  40. /******************************************************/
  41. /* LOAD EACH GROUP OF OPTIONS INTO THE OPTIONS ARRAY. */
  42. /******************************************************/
  43. /*** Load the General Options into the array ***/
  44. $optgrps[SMOPT_GRP_SPCFOLDER] = _("Special Folder Options");
  45. $optvals[SMOPT_GRP_SPCFOLDER] = array();
  46. if (!isset($folder_prefix)) { $folder_prefix = $default_folder_prefix; }
  47. if ($show_prefix_option) {
  48. $optvals[SMOPT_GRP_SPCFOLDER][] = array(
  49. 'name' => 'folder_prefix',
  50. 'caption' => _("Folder Path"),
  51. 'type' => SMOPT_TYPE_STRING,
  52. 'refresh' => SMOPT_REFRESH_FOLDERLIST,
  53. 'size' => SMOPT_SIZE_LARGE
  54. );
  55. }
  56. $trash_folder_values = array(SMPREF_NONE => '[ '._("Do not use Trash").' ]',
  57. 'ignore' => $boxes);
  58. $optvals[SMOPT_GRP_SPCFOLDER][] = array(
  59. 'name' => 'trash_folder',
  60. 'caption' => _("Trash Folder"),
  61. 'type' => SMOPT_TYPE_FLDRLIST,
  62. 'refresh' => SMOPT_REFRESH_FOLDERLIST,
  63. 'posvals' => $trash_folder_values,
  64. 'save' => 'save_option_trash_folder'
  65. );
  66. $draft_folder_values = array(SMPREF_NONE => '[ '._("Do not use Drafts").' ]',
  67. 'ignore' => $boxes);
  68. $optvals[SMOPT_GRP_SPCFOLDER][] = array(
  69. 'name' => 'draft_folder',
  70. 'caption' => _("Draft Folder"),
  71. 'type' => SMOPT_TYPE_FLDRLIST,
  72. 'refresh' => SMOPT_REFRESH_FOLDERLIST,
  73. 'posvals' => $draft_folder_values,
  74. 'save' => 'save_option_draft_folder'
  75. );
  76. $sent_folder_values = array(SMPREF_NONE => '[ '._("Do not use Sent").' ]',
  77. 'ignore' => $boxes);
  78. $optvals[SMOPT_GRP_SPCFOLDER][] = array(
  79. 'name' => 'sent_folder',
  80. 'caption' => _("Sent Folder"),
  81. 'type' => SMOPT_TYPE_FLDRLIST,
  82. 'refresh' => SMOPT_REFRESH_FOLDERLIST,
  83. 'posvals' => $sent_folder_values,
  84. 'save' => 'save_option_sent_folder'
  85. );
  86. $optvals[SMOPT_GRP_SPCFOLDER][] = array(
  87. 'name' => 'translate_special_folders',
  88. 'caption' => _("Translate Special Folders"),
  89. 'type' => SMOPT_TYPE_BOOLEAN,
  90. 'refresh' => SMOPT_REFRESH_FOLDERLIST
  91. );
  92. $optvals[SMOPT_GRP_SPCFOLDER][] = array(
  93. 'name' => 'save_reply_with_orig',
  94. 'caption' => _("Save Replies with Original Message"),
  95. 'type' => SMOPT_TYPE_BOOLEAN,
  96. 'refresh' => SMOPT_REFRESH_FOLDERLIST
  97. );
  98. /*** Load the General Options into the array ***/
  99. $optgrps[SMOPT_GRP_FOLDERLIST] = _("Folder List Options");
  100. $optvals[SMOPT_GRP_FOLDERLIST] = array();
  101. $optvals[SMOPT_GRP_FOLDERLIST][] = array(
  102. 'name' => 'location_of_bar',
  103. 'caption' => _("Location of Folder List"),
  104. 'type' => SMOPT_TYPE_STRLIST,
  105. 'refresh' => SMOPT_REFRESH_ALL,
  106. 'posvals' => array(SMPREF_LOC_LEFT => _("Left"),
  107. SMPREF_LOC_RIGHT => _("Right"))
  108. );
  109. $left_size_values = array();
  110. for ($lsv = 100; $lsv <= 300; $lsv += 10) {
  111. $left_size_values[$lsv] = "$lsv " . _("pixels");
  112. }
  113. $optvals[SMOPT_GRP_FOLDERLIST][] = array(
  114. 'name' => 'left_size',
  115. 'caption' => _("Width of Folder List"),
  116. 'type' => SMOPT_TYPE_STRLIST,
  117. 'refresh' => SMOPT_REFRESH_ALL,
  118. 'posvals' => $left_size_values
  119. );
  120. $left_refresh_values = array(SMPREF_NONE => _("Never"));
  121. foreach (array(30,60,120,180,300,600,1200) as $lr_val) {
  122. if ($lr_val < 60) {
  123. $left_refresh_values[$lr_val] = "$lr_val " . _("Seconds");
  124. } else {
  125. $left_refresh_values[$lr_val] = sprintf(ngettext("%d Minute","%d Minutes",($lr_val/60)),($lr_val/60));
  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' => 'search_memory',
  179. 'caption' => _("Memory Search"),
  180. 'type' => SMOPT_TYPE_STRLIST,
  181. 'refresh' => SMOPT_REFRESH_NONE,
  182. 'posvals' => array( 0 => _("Disabled"),
  183. 1 => '1',
  184. 2 => '2',
  185. 3 => '3',
  186. 4 => '4',
  187. 5 => '5',
  188. 6 => '6',
  189. 7 => '7',
  190. 8 => '8',
  191. 9 => '9')
  192. );
  193. $optvals[SMOPT_GRP_FOLDERLIST][] = array(
  194. 'name' => 'show_only_subscribed_folders',
  195. 'caption' => _("Show only subscribed folders"),
  196. 'type' => SMOPT_TYPE_BOOLEAN,
  197. 'refresh' => SMOPT_REFRESH_FOLDERLIST
  198. );
  199. /*** Load the General Options into the array ***/
  200. $optgrps[SMOPT_GRP_FOLDERSELECT] = _("Folder Selection Options");
  201. $optvals[SMOPT_GRP_FOLDERSELECT] = array();
  202. $delim = sqimap_get_delimiter($imapConnection);
  203. $optvals[SMOPT_GRP_FOLDERSELECT][] = array(
  204. 'name' => 'mailbox_select_style',
  205. 'caption' => _("Selection List Style"),
  206. 'type' => SMOPT_TYPE_STRLIST,
  207. 'refresh' => SMOPT_REFRESH_NONE,
  208. 'posvals' => array(
  209. SMPREF_MAILBOX_SELECT_LONG =>
  210. _("Long:") . ' "' . _("Folder") . $delim . _("Subfolder") . '"',
  211. SMPREF_MAILBOX_SELECT_INDENTED =>
  212. _("Indented:") . " \"$nbsp$nbsp$nbsp$nbsp" . _("Subfolder") . '"',
  213. SMPREF_MAILBOX_SELECT_DELIMITED =>
  214. _("Delimited:") . " \".$nbsp" . _("Subfolder") . '"'),
  215. 'htmlencoded' => true
  216. );
  217. /* Assemble all this together and return it as our result. */
  218. $result = array(
  219. 'grps' => $optgrps,
  220. 'vals' => $optvals
  221. );
  222. sqimap_logout($imapConnection);
  223. return ($result);
  224. }
  225. /******************************************************************/
  226. /** Define any specialized save functions for this option page. ***/
  227. /******************************************************************/
  228. /**
  229. * Saves the trash folder option.
  230. * @param object $option SquirrelOption object
  231. * @since 1.3.2
  232. */
  233. function save_option_trash_folder($option) {
  234. global $data_dir, $username;
  235. if (strtolower($option->new_value)=='inbox') {
  236. // make sure that it is not INBOX
  237. error_option_save(_("You can't select INBOX as Trash folder."));
  238. } else {
  239. /* Set move to trash on or off. */
  240. $trash_on = ($option->new_value == SMPREF_NONE ? SMPREF_OFF : SMPREF_ON);
  241. setPref($data_dir, $username, 'move_to_trash', $trash_on);
  242. /* Now just save the option as normal. */
  243. save_option($option);
  244. }
  245. }
  246. /**
  247. * Saves the sent folder option.
  248. * @param object $option SquirrelOption object
  249. * @since 1.3.2
  250. */
  251. function save_option_sent_folder($option) {
  252. global $data_dir, $username;
  253. if (strtolower($option->new_value)=='inbox') {
  254. // make sure that it is not INBOX
  255. error_option_save(_("You can't select INBOX as Sent folder."));
  256. } else {
  257. /* Set move to sent on or off. */
  258. $sent_on = ($option->new_value == SMPREF_NONE ? SMPREF_OFF : SMPREF_ON);
  259. setPref($data_dir, $username, 'move_to_sent', $sent_on);
  260. /* Now just save the option as normal. */
  261. save_option($option);
  262. }
  263. }
  264. /**
  265. * Saves the draft folder option.
  266. * @param object $option SquirrelOption object
  267. * @since 1.3.2
  268. */
  269. function save_option_draft_folder($option) {
  270. global $data_dir, $username;
  271. if (strtolower($option->new_value)=='inbox') {
  272. // make sure that it is not INBOX
  273. error_option_save(_("You can't select INBOX as Draft folder."));
  274. } else {
  275. /* Set move to draft on or off. */
  276. $draft_on = ($option->new_value == SMPREF_NONE ? SMPREF_OFF : SMPREF_ON);
  277. setPref($data_dir, $username, 'save_as_draft', $draft_on);
  278. /* Now just save the option as normal. */
  279. save_option($option);
  280. }
  281. }