Source for file folders.php

Documentation is available at folders.php

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

Documentation generated on Sat, 07 Oct 2006 16:31:16 +0300 by phpDocumentor 1.3.0RC6