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

Documentation generated on Sat, 25 May 2013 04:21:58 +0200 by phpDocumentor 1.4.3