Can I be a member of the dev team, please? :\)
[squirrelmail.git] / src / left_main.php
index 194eb5b5a3806a44b5cb7915574a1be4cab287aa..d7feb633f1bada011c795eb1a8614b73f567e6b7 100644 (file)
@@ -28,10 +28,7 @@ define('SM_BOX_UNCOLLAPSED', 0);
 define('SM_BOX_COLLAPSED',   1);
 
 /* get globals */
-sqgetGlobalVar('username', $username, SQ_SESSION);
-sqgetGlobalVar('key', $key, SQ_COOKIE);
 sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION);
-sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION);
 
 sqgetGlobalVar('fold', $fold, SQ_GET);
 sqgetGlobalVar('unfold', $unfold, SQ_GET);
@@ -39,7 +36,7 @@ sqgetGlobalVar('unfold', $unfold, SQ_GET);
 
 // open a connection on the imap port (143)
 // why hide the output?
-$imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, true);
+$imapConnection = sqimap_login($username, false, $imapServerAddress, $imapPort, true);
 
 /**
  * Using stristr since very old preferences may contain "None" and "none".
@@ -56,7 +53,7 @@ if (!empty($left_refresh) &&
 /**
  * Include extra javascript files needed by template
  */
-$js_includes = $oTemplate->getJavascriptIncludes();
+$js_includes = $oTemplate->get_javascript_includes(TRUE);
 foreach ($js_includes as $js_file) {
     $xtra .= '<script src="'.$js_file.'" type="text/javascript"></script>' ."\n";
 }
@@ -65,6 +62,7 @@ foreach ($js_includes as $js_file) {
 $mailboxes=sqimap_get_mailboxes($imapConnection,false,$show_only_subscribed_folders);
 
 displayHtmlHeader( 'SquirrelMail', $xtra );
+$oErrorHandler->setDelayedErrors(true);
 
 sqgetGlobalVar('auto_create_done',$auto_create_done,SQ_SESSION);
 /* If requested and not yet complete, attempt to autocreate folders. */
@@ -73,8 +71,18 @@ if ($auto_create_special && !isset($auto_create_done)) {
     $folders_created = false;
     foreach( $autocreate as $folder ) {
         if (($folder != '') && ($folder != 'none')) {
-            // use $mailboxes array for checking if mailbox exists
-            if ( !sqimap_mailbox_exists($imapConnection, $folder, $mailboxes)) {
+            /**
+             * If $show_only_subscribed_folders is true, don't use 
+             * $mailboxes array for checking if mailbox exists.
+             * Mailbox list contains only subscribed folders. 
+             * sqimap_mailbox_create() will fail, if folder exists.
+             */
+            if ($show_only_subscribed_folders) {
+                $mailbox_cache = false;
+            } else {
+                $mailbox_cache = $mailboxes;
+            }
+            if ( !sqimap_mailbox_exists($imapConnection, $folder, $mailbox_cache)) {
                 sqimap_mailbox_create($imapConnection, $folder, '');
                 $folders_created = true;
             } else {
@@ -183,9 +191,8 @@ $oTemplate->assign('mailboxes', $mailbox_structure);
  * globals, which are dirty, filthy things in templates. :)
  */
 $settings = array();
-$settings['imapConnection'] = $imapConnection;
-$settings['iconThemePath'] = $icon_theme_path;
-$settings['templateDirectory'] = $sTplDir;
+#$settings['imapConnection'] = $imapConnection;
+$settings['templateID'] = $sTemplateID;
 $settings['unreadNotificationEnabled'] = $unseen_notify!=1;
 $settings['unreadNotificationAllFolders'] = $unseen_notify == 3;
 $settings['unreadNotificationDisplayTotal'] = $unseen_type == 2;
@@ -199,4 +206,3 @@ $oTemplate->display('left_main.tpl');
 
 sqimap_logout($imapConnection);
 $oTemplate->display('footer.tpl');
-?>
\ No newline at end of file