Source for file folder.php

Documentation is available at folder.php

  1. <?php
  2. /**
  3. * options_folder.php
  4. *
  5. * Displays all options relating to folders
  6. *
  7. * @copyright 1999-2020 The SquirrelMail Project Team
  8. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  9. * @version $Id: folder.php 14845 2020年01月07日 08:09:34Z pdontthink $
  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. global $username, $imapServerAddress , $imapPort , $imap_stream_options,
  32. $oTemplate, $nbsp, $folder_prefix, $default_folder_prefix ,
  33. /* Get some imap data we need later. */
  34. $imapConnection = sqimap_login ($username, false, $imapServerAddress, $imapPort, 0, $imap_stream_options);
  35. $boxes = sqimap_mailbox_list ($imapConnection);
  36. /* Build a simple array into which we will build options. */
  37. $optgrps = array();
  38. $optvals = array();
  39. /******************************************************/
  40. /* LOAD EACH GROUP OF OPTIONS INTO THE OPTIONS ARRAY. */
  41. /******************************************************/
  42. /*** Load the General Options into the array ***/
  43. $optgrps[SMOPT_GRP_SPCFOLDER ] = _ ("Special Folder Options");
  44. $optvals[SMOPT_GRP_SPCFOLDER ] = array();
  45. if (!isset($folder_prefix)) { $folder_prefix = $default_folder_prefix; }
  46. if ($show_prefix_option) {
  47. $optvals[SMOPT_GRP_SPCFOLDER ][] = array(
  48. 'name' => 'folder_prefix',
  49. 'caption' => _ ("Folder Path"),
  50. 'type' => SMOPT_TYPE_STRING ,
  51. 'refresh' => SMOPT_REFRESH_FOLDERLIST ,
  52. 'size' => SMOPT_SIZE_LARGE
  53. );
  54. }
  55. $trash_folder_values = array(SMPREF_NONE => '[ '._ ("Do not use Trash").' ]',
  56. 'ignore' => $boxes);
  57. $optvals[SMOPT_GRP_SPCFOLDER ][] = array(
  58. 'name' => 'trash_folder',
  59. 'caption' => _ ("Trash Folder"),
  60. 'type' => SMOPT_TYPE_FLDRLIST ,
  61. 'refresh' => SMOPT_REFRESH_FOLDERLIST ,
  62. 'posvals' => $trash_folder_values,
  63. 'save' => 'save_option_trash_folder'
  64. );
  65. $draft_folder_values = array(SMPREF_NONE => '[ '._ ("Do not use Drafts").' ]',
  66. 'ignore' => $boxes);
  67. $optvals[SMOPT_GRP_SPCFOLDER ][] = array(
  68. 'name' => 'draft_folder',
  69. 'caption' => _ ("Draft Folder"),
  70. 'type' => SMOPT_TYPE_FLDRLIST ,
  71. 'refresh' => SMOPT_REFRESH_FOLDERLIST ,
  72. 'posvals' => $draft_folder_values,
  73. 'save' => 'save_option_draft_folder'
  74. );
  75. $sent_folder_values = array(SMPREF_NONE => '[ '._ ("Do not use Sent").' ]',
  76. 'ignore' => $boxes);
  77. $optvals[SMOPT_GRP_SPCFOLDER ][] = array(
  78. 'name' => 'sent_folder',
  79. 'caption' => _ ("Sent Folder"),
  80. 'type' => SMOPT_TYPE_FLDRLIST ,
  81. 'refresh' => SMOPT_REFRESH_FOLDERLIST ,
  82. 'posvals' => $sent_folder_values,
  83. 'save' => 'save_option_sent_folder'
  84. );
  85. $optvals[SMOPT_GRP_SPCFOLDER ][] = array(
  86. 'name' => 'translate_special_folders',
  87. 'caption' => _ ("Translate Special Folders"),
  88. 'type' => SMOPT_TYPE_BOOLEAN ,
  89. );
  90. $optvals[SMOPT_GRP_SPCFOLDER ][] = array(
  91. 'name' => 'save_reply_with_orig',
  92. 'caption' => _ ("Save Replies with Original Message"),
  93. 'type' => SMOPT_TYPE_BOOLEAN ,
  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. $left_refresh_values = array(SMPREF_NONE => _ ("Never"));
  118. foreach (array(30,60,120,180,300,600,1200) as $lr_val) {
  119. if ($lr_val < 60) {
  120. $left_refresh_values[$lr_val] = "$lr_val " . _ ("Seconds");
  121. } else {
  122. $left_refresh_values[$lr_val] = sprintf (ngettext ("%d Minute","%d Minutes",($lr_val/60)),($lr_val/60));
  123. }
  124. }
  125. $optvals[SMOPT_GRP_FOLDERLIST ][] = array(
  126. 'name' => 'left_refresh',
  127. 'caption' => _ ("Auto Refresh Folder List"),
  128. 'type' => SMOPT_TYPE_STRLIST ,
  129. 'refresh' => SMOPT_REFRESH_FOLDERLIST ,
  130. 'posvals' => $left_refresh_values
  131. );
  132. $optvals[SMOPT_GRP_FOLDERLIST ][] = array(
  133. 'name' => 'unseen_notify',
  134. 'caption' => _ ("Enable Unread Message Notification"),
  135. 'type' => SMOPT_TYPE_STRLIST ,
  136. 'refresh' => SMOPT_REFRESH_FOLDERLIST ,
  137. 'posvals' => array(SMPREF_UNSEEN_NONE => _ ("No Notification"),
  138. SMPREF_UNSEEN_INBOX => _ ("Only INBOX"),
  139. SMPREF_UNSEEN_ALL => _ ("All Folders"))
  140. );
  141. $optvals[SMOPT_GRP_FOLDERLIST ][] = array(
  142. 'name' => 'unseen_type',
  143. 'caption' => _ ("Unread Message Notification Type"),
  144. 'type' => SMOPT_TYPE_STRLIST ,
  145. 'refresh' => SMOPT_REFRESH_FOLDERLIST ,
  146. 'posvals' => array(SMPREF_UNSEEN_ONLY => _ ("Only Unseen"),
  147. SMPREF_UNSEEN_TOTAL => _ ("Unseen and Total"))
  148. );
  149. $optvals[SMOPT_GRP_FOLDERLIST ][] = array(
  150. 'name' => 'collapse_folders',
  151. 'caption' => _ ("Enable Collapsable Folders"),
  152. 'type' => SMOPT_TYPE_BOOLEAN ,
  153. );
  154. $optvals[SMOPT_GRP_FOLDERLIST ][] = array(
  155. 'name' => 'unseen_cum',
  156. 'caption' => _ ("Enable Cumulative Unread Message Notification"),
  157. 'type' => SMOPT_TYPE_BOOLEAN ,
  158. );
  159. $optvals[SMOPT_GRP_FOLDERLIST ][] = array(
  160. 'name' => 'date_format',
  161. 'caption' => _ ("Show Clock on Folders Panel"),
  162. 'type' => SMOPT_TYPE_STRLIST ,
  163. 'refresh' => SMOPT_REFRESH_FOLDERLIST ,
  164. 'posvals' => array( '0' => _ ("International date and time"),
  165. '1' => _ ("American date and time"),
  166. '2' => _ ("European date and time"),
  167. '3' => _ ("Show weekday and time"),
  168. '4' => _ ("Show time with seconds"),
  169. '5' => _ ("Show time"),
  170. '6' => _ ("No Clock")),
  171. );
  172. $optvals[SMOPT_GRP_FOLDERLIST ][] = array(
  173. 'name' => 'search_memory',
  174. 'caption' => _ ("Memory Search"),
  175. 'type' => SMOPT_TYPE_STRLIST ,
  176. 'refresh' => SMOPT_REFRESH_NONE ,
  177. 'posvals' => array( 0 => _ ("Disabled"),
  178. 1 => '1',
  179. 2 => '2',
  180. 3 => '3',
  181. 4 => '4',
  182. 5 => '5',
  183. 6 => '6',
  184. 7 => '7',
  185. 8 => '8',
  186. 9 => '9')
  187. );
  188. $optvals[SMOPT_GRP_FOLDERLIST ][] = array(
  189. 'name' => 'show_only_subscribed_folders',
  190. 'caption' => _ ("Show only subscribed folders"),
  191. 'type' => SMOPT_TYPE_BOOLEAN ,
  192. );
  193. /*** Load the General Options into the array ***/
  194. $optgrps[SMOPT_GRP_FOLDERSELECT ] = _ ("Folder Selection Options");
  195. $optvals[SMOPT_GRP_FOLDERSELECT ] = array();
  196. $delim = sqimap_get_delimiter ($imapConnection);
  197. $optvals[SMOPT_GRP_FOLDERSELECT ][] = array(
  198. 'name' => 'mailbox_select_style',
  199. 'caption' => _ ("Selection List Style"),
  200. 'type' => SMOPT_TYPE_STRLIST ,
  201. 'refresh' => SMOPT_REFRESH_NONE ,
  202. 'posvals' => array(
  203. _ ("Long:") . ' "' . _ ("Folder") . $delim . _ ("Subfolder") . '"',
  204. _ ("Indented:") . " \"$nbsp$nbsp$nbsp$nbsp" . _ ("Subfolder") . '"',
  205. _ ("Delimited:") . " \".$nbsp" . _ ("Subfolder") . '"'),
  206. 'htmlencoded' => true
  207. );
  208. /* Assemble all this together and return it as our result. */
  209. $result = array(
  210. 'grps' => $optgrps,
  211. 'vals' => $optvals
  212. );
  213. sqimap_logout ($imapConnection);
  214. return ($result);
  215. }
  216. /******************************************************************/
  217. /** Define any specialized save functions for this option page. ***/
  218. /******************************************************************/
  219. /**
  220. * Saves the trash folder option.
  221. * @param object $option SquirrelOption object
  222. * @since 1.3.2
  223. */
  224. function save_option_trash_folder ($option) {
  225. global $data_dir , $username;
  226. if (strtolower ($option->new_value)=='inbox') {
  227. // make sure that it is not INBOX
  228. error_option_save (_ ("You can't select INBOX as Trash folder."));
  229. } else {
  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. /**
  238. * Saves the sent folder option.
  239. * @param object $option SquirrelOption object
  240. * @since 1.3.2
  241. */
  242. function save_option_sent_folder ($option) {
  243. global $data_dir , $username;
  244. if (strtolower ($option->new_value)=='inbox') {
  245. // make sure that it is not INBOX
  246. error_option_save (_ ("You can't select INBOX as Sent folder."));
  247. } else {
  248. /* Set move to sent on or off. */
  249. $sent_on = ($option->new_value == SMPREF_NONE ? SMPREF_OFF : SMPREF_ON );
  250. setPref ($data_dir, $username, 'move_to_sent', $sent_on);
  251. /* Now just save the option as normal. */
  252. save_option ($option);
  253. }
  254. }
  255. /**
  256. * Saves the draft folder option.
  257. * @param object $option SquirrelOption object
  258. * @since 1.3.2
  259. */
  260. function save_option_draft_folder ($option) {
  261. global $data_dir , $username;
  262. if (strtolower ($option->new_value)=='inbox') {
  263. // make sure that it is not INBOX
  264. error_option_save (_ ("You can't select INBOX as Draft folder."));
  265. } else {
  266. /* Set move to draft on or off. */
  267. $draft_on = ($option->new_value == SMPREF_NONE ? SMPREF_OFF : SMPREF_ON );
  268. setPref ($data_dir, $username, 'save_as_draft', $draft_on);
  269. /* Now just save the option as normal. */
  270. save_option ($option);
  271. }
  272. }

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

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