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

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

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