Source for file folders.php

Documentation is available at folders.php

  1. <?php
  2. /**
  3. * folders.php
  4. *
  5. * Handles all interaction between the user and the other folder
  6. * scripts which do most of the work. Also handles the Special
  7. * Folders.
  8. *
  9. * @copyright 1999-2020 The SquirrelMail Project Team
  10. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  11. * @version $Id: folders.php 14840 2020年01月07日 07:42:38Z pdontthink $
  12. * @package squirrelmail
  13. */
  14. /** This is the folders page */
  15. define ('PAGE_NAME', 'folders');
  16. /**
  17. * Path for SquirrelMail required files.
  18. * @ignore
  19. */
  20. define ('SM_PATH','../');
  21. /* SquirrelMail required files. */
  22. require_once(SM_PATH . 'include/validate.php');
  23. require_once(SM_PATH . 'functions/imap.php');
  24. require_once(SM_PATH . 'functions/plugin.php');
  25. require_once(SM_PATH . 'functions/html.php');
  26. require_once(SM_PATH . 'functions/forms.php');
  27. displayPageHeader ($color, 'None');
  28. /* get globals we may need */
  29. sqgetGlobalVar ('username', $username, SQ_SESSION );
  30. sqgetGlobalVar ('key', $key, SQ_COOKIE );
  31. sqgetGlobalVar ('delimiter', $delimiter, SQ_SESSION );
  32. sqgetGlobalVar ('onetimepad', $onetimepad, SQ_SESSION );
  33. sqgetGlobalVar ('success', $success, SQ_GET );
  34. /* end of get globals */
  35. echo '<br />' .
  36. html_tag ( 'table', '', 'center', $color[0], 'width="95%" cellpadding="1" cellspacing="0" border="0"' ) .
  37. html_tag ( 'tr' ) .
  38. html_tag ( 'td', '', 'center' ) . '<b>' . _ ("Folders") . '</b>' .
  39. html_tag ( 'table', '', 'center', '', 'width="100%" cellpadding="5" cellspacing="0" border="0"' ) .
  40. html_tag ( 'tr' ) .
  41. html_tag ( 'td', '', 'center', $color[4] );
  42. if ( isset($success) && $success ) {
  43. $td_str = '<b>';
  44. switch ($success)
  45. {
  46. case 'subscribe':
  47. $td_str .= _ ("Subscribed successfully.");
  48. break;
  49. case 'unsubscribe':
  50. $td_str .= _ ("Unsubscribed successfully.");
  51. break;
  52. case 'delete':
  53. $td_str .= _ ("Deleted folder successfully.");
  54. break;
  55. case 'create':
  56. $td_str .= _ ("Created folder successfully.");
  57. break;
  58. case 'rename':
  59. $td_str .= _ ("Renamed successfully.");
  60. break;
  61. case 'subscribe-doesnotexist':
  62. $td_str .= _ ("Subscription Unsuccessful - Folder does not exist.");
  63. break;
  64. }
  65. $td_str .= '</b><br />';
  66. echo html_tag ( 'table',
  67. html_tag ( 'tr',
  68. html_tag ( 'td', $td_str .
  69. '<a href="../src/left_main.php" target="left">' .
  70. _ ("refresh folder list") . '</a>' ,
  71. 'center' )
  72. ) ,
  73. 'center', '', 'width="100%" cellpadding="4" cellspacing="0" border="0"' );
  74. }
  75. echo "\n<br />";
  76. global $imap_stream_options; // in case not defined in config
  77. $imapConnection = sqimap_login ($username, $key, $imapServerAddress, $imapPort, 0, $imap_stream_options);
  78. // force retrieval of a non cached folderlist
  79. $boxes = sqimap_mailbox_list ($imapConnection,true);
  80. /** CREATING FOLDERS **/
  81. echo html_tag ( 'table', '', 'center', '', 'width="70%" cellpadding="4" cellspacing="0" border="0"' ) .
  82. html_tag ( 'tr',
  83. html_tag ( 'td', '<b>' . _ ("Create Folder") . '</b>', 'center', $color[9] )
  84. ) .
  85. html_tag ( 'tr' ) .
  86. html_tag ( 'td', '', 'center', $color[0] ) .
  87. addForm ('folders_create.php', 'POST', 'cf', '', '', '', TRUE).
  88. addInput ('folder_name', '', 25).
  89. "<br />\n". _ ("as a subfolder of"). '<br />'.
  90. "<tt><select name=\"subfolder\">\n";
  91. $show_selected = array();
  92. $skip_folders = array();
  93. $server_type = strtolower ($imap_server_type);
  94. if ( $server_type == 'courier' ) {
  95. if ( $default_folder_prefix == 'INBOX.' ) {
  96. array_push ($skip_folders, 'INBOX');
  97. }
  98. } elseif ( $server_type == 'bincimap' ) {
  99. if ( $default_folder_prefix == 'INBOX/' ) {
  100. // We don't need INBOX, since it is top folder
  101. array_push ($skip_folders, 'INBOX');
  102. }
  103. }
  104. if ( $default_sub_of_inbox == false ) {
  105. echo '<option selected="selected" value="">[ '._ ("None")." ]</option>\n";
  106. } else {
  107. echo '<option value="">[ '._ ("None")." ]</option>\n";
  108. $show_selected = array('inbox');
  109. }
  110. // Call sqimap_mailbox_option_list, using existing connection to IMAP server,
  111. // the arrays of folders to include or skip (assembled above),
  112. // use 'noinferiors' as a mailbox filter to leave out folders that can not contain other folders.
  113. // use the long format to show subfolders in an intelligible way if parent is missing (special folder)
  114. echo sqimap_mailbox_option_list ($imapConnection, $show_selected, $skip_folders, $boxes, 'noinferiors', true);
  115. echo "</select></tt>\n";
  116. if ($show_contain_subfolders_option) {
  117. echo '<br />'.
  118. addCheckBox ('contain_subs', FALSE, '1') .' &nbsp;'
  119. . _ ("Let this folder contain subfolders")
  120. . '<br />';
  121. }
  122. echo "<input type=\"submit\" value=\""._ ("Create")."\" />\n";
  123. echo "</form></td></tr>\n";
  124. echo html_tag ( 'tr',
  125. html_tag ( 'td', '&nbsp;', 'left', $color[4] )
  126. ) ."\n";
  127. /** count special folders **/
  128. foreach ($boxes as $index => $aBoxData) {
  129. if (! in_array ($aBoxData['unformatted'],$skip_folders) &&
  130. isSpecialMailbox ($aBoxData['unformatted'],false) ) {
  131. $skip_folders[] = $aBoxData['unformatted'];
  132. }
  133. }
  134. /** RENAMING FOLDERS **/
  135. echo html_tag ( 'tr',
  136. html_tag ( 'td', '<b>' . _ ("Rename a Folder") . '</b>', 'center', $color[9] )
  137. ) .
  138. html_tag ( 'tr' ) .
  139. html_tag ( 'td', '', 'center', $color[0] );
  140. if (count ($skip_folders) < count ($boxes)) {
  141. echo addForm ('folders_rename_getname.php')
  142. . "<tt><select name=\"old\">\n"
  143. . ' <option value="">[ ' . _ ("Select a folder") . " ]</option>\n";
  144. // use existing IMAP connection, we have no special values to show,
  145. // but we do include values to skip. Use the pre-created $boxes to save an IMAP query.
  146. // send NULL for the flag - ALL folders are eligible for rename!
  147. // use long format to make sure folder names make sense when parents may be missing.
  148. echo sqimap_mailbox_option_list ($imapConnection, 0, $skip_folders, $boxes, NULL, true);
  149. echo "</select></tt>\n".
  150. '<input type="submit" value="'.
  151. _ ("Rename").
  152. "\" />\n".
  153. "</form></td></tr>\n";
  154. } else {
  155. echo _ ("No folders found") . '<br /><br /></td></tr>';
  156. }
  157. $boxes_sub = $boxes;
  158. echo html_tag ( 'tr',
  159. html_tag ( 'td', '&nbsp;', 'left', $color[4] )
  160. ) ."\n";
  161. /** DELETING FOLDERS **/
  162. echo html_tag ( 'tr',
  163. html_tag ( 'td', '<b>' . _ ("Delete Folder") . '</b>', 'center', $color[9] )
  164. ) .
  165. html_tag ( 'tr' ) .
  166. html_tag ( 'td', '', 'center', $color[0] );
  167. if (count ($skip_folders) < count ($boxes)) {
  168. echo addForm ('folders_delete.php')
  169. . "<tt><select name=\"mailbox\">\n"
  170. . ' <option value="">[ ' . _ ("Select a folder") . " ]</option>\n";
  171. // send NULL for the flag - ALL folders are eligible for delete (except what we've got in skiplist)
  172. // use long format to make sure folder names make sense when parents may be missing.
  173. echo sqimap_mailbox_option_list ($imapConnection, 0, $skip_folders, $boxes, NULL, true);
  174. echo "</select></tt>\n"
  175. . '<input type="submit" value="'
  176. . _ ("Delete")
  177. . "\" />\n"
  178. . "</form></td></tr>\n";
  179. } else {
  180. echo _ ("No folders found") . "<br /><br /></td></tr>";
  181. }
  182. echo html_tag ( 'tr',
  183. html_tag ( 'td', '&nbsp;', 'left', $color[4] )
  184. ) ."</table>\n";
  185. /** UNSUBSCRIBE FOLDERS **/
  186. echo html_tag ( 'table', '', 'center', '', 'width="70%" cellpadding="4" cellspacing="0" border="0"' ) .
  187. html_tag ( 'tr',
  188. html_tag ( 'td', '<b>' . _ ("Unsubscribe") . '/' . _ ("Subscribe") . '</b>', 'center', $color[9], 'colspan="2"' )
  189. ) .
  190. html_tag ( 'tr' ) .
  191. html_tag ( 'td', '', 'center', $color[0], 'width="50%"' );
  192. if (count ($skip_folders) < count ($boxes)) {
  193. echo addForm ('folders_subscribe.php?method=unsub', 'post', '', '', '', '', TRUE)
  194. . "<tt><select name=\"mailbox[]\" multiple=\"multiple\" size=\"8\">\n";
  195. for ($i = 0; $i < count ($boxes); $i++) {
  196. $use_folder = true;
  197. if (! isSpecialMailbox ($boxes[$i]["unformatted"],false)) {
  198. $box = $boxes[$i]["unformatted-dm"];
  199. $box2 = str_replace (array(' ','<','>'), array('&nbsp;','&lt;','&gt;'),
  200. imap_utf7_decode_local ($boxes[$i]["unformatted-disp"]));
  201. echo " <option value=\"$box\">$box2</option>\n";
  202. }
  203. }
  204. echo "</select></tt><br /><br />\n"
  205. . '<input type="submit" value="'
  206. . _ ("Unsubscribe")
  207. . "\" />\n"
  208. . "</form></td>\n";
  209. } else {
  210. echo _ ("No folders were found to unsubscribe from!") . '</td>';
  211. }
  212. $boxes_sub = $boxes;
  213. /** SUBSCRIBE TO FOLDERS **/
  214. echo html_tag ( 'td', '', 'center', $color[0], 'width="50%"' );
  215. if(!$no_list_for_subscribe) {
  216. $boxes_all = sqimap_mailbox_list_all ($imapConnection);
  217. $box = $box2 = array();
  218. for ($i = 0, $q = 0; $i < count ($boxes_all); $i++) {
  219. $use_folder = true;
  220. for ($p = 0; $p < count ($boxes); $p++) {
  221. if ($boxes_all[$i]['unformatted'] == $boxes[$p]['unformatted']) {
  222. $use_folder = false;
  223. continue;
  224. } else if ($boxes_all[$i]['unformatted-dm'] == $folder_prefix) {
  225. $use_folder = false;
  226. }
  227. }
  228. if ($use_folder == true) {
  229. $box[$q] = $boxes_all[$i]['unformatted-dm'];
  230. $box2[$q] = imap_utf7_decode_local ($boxes_all[$i]['unformatted-disp']);
  231. $q++;
  232. }
  233. }
  234. if (count ($box) > 0) {
  235. echo addForm ('folders_subscribe.php?method=sub', 'post', '', '', '', '', TRUE)
  236. . '<tt><select name="mailbox[]" multiple="multiple" size="8">';
  237. for ($q = 0; $q < count ($box); $q++) {
  238. echo ' <option value="' . $box[$q] . '">' .
  239. str_replace (array(' ','<','>'),array('&nbsp;','&lt;','&gt;'),$box2[$q])."</option>\n";
  240. }
  241. echo '</select></tt><br /><br />'
  242. . '<input type="submit" value="'. _ ("Subscribe") . "\" />\n"
  243. . "</form></td></tr></table><br />\n";
  244. } else {
  245. echo _ ("No folders were found to subscribe to!") . '</td></tr></table>';
  246. }
  247. } else {
  248. /* don't perform the list action -- this is much faster */
  249. echo addForm ('folders_subscribe.php?method=sub', 'post', '', '', '', '', TRUE)
  250. . _ ("Subscribe to:") . '<br />'
  251. . '<tt><input type="text" name="mailbox[]" size="35" />'
  252. . '<input type="submit" value="'. _ ("Subscribe") . "\" />\n"
  253. . "</form></td></tr></table>\n";
  254. }
  255. echo "\n<br /><br />\n";
  256. do_hook ('folders_bottom');
  257. ?>
  258. </td></tr>
  259. </table>
  260. </td></tr>
  261. </table>
  262. <?php
  263. sqimap_logout ($imapConnection);
  264. ?>
  265. </body></html>

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

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