[imp] strange things in summary

Jan Schneider janmailing@gmx.de
Thu, 14 Jun 2001 14:53:06 +0200


---------------------- multipart/mixed attachment
Zitat von Chuck Hagenbuch <chuck@horde.org>:

> Quoting Jan Schneider <janmailing@gmx.de>:
> 
> > But it's vice versa: I get a list, but this list also contains folders that
> 
> > don't exist anymore. I think they are still in the "to-poll-list", where
> they 
> > should be removed from after deleting these folders.
> 
> Yes, that preference needs to be maintained when folders are renamed or 
> deleted. Anyone have a patch?

Appended. 
This patch also checks in api.php if a folder actually exists. This might be 
necessary if you delete a folder not from within imp but with another imap 
client. There should be a smarter way to check nav_poll for nonexisting folders 
but since api.php actually is the only place to loop through nav_poll, this is 
a quick fix.
 
> > And this doesn't gives an answer why I can go to these folders event though
> 
> > they don't exist???
> 
> I worded it sloppily; IMP will currently just present an empty mailbox
> listing 
> if you go to a folder that doesn't exist.
> 
> -chuck
> 
> --
> Charles Hagenbuch, <chuck@horde.org>
> Some fallen angels have their good reasons.
> 
> -- 
> IMP mailing list: http://horde.org/imp/
> Archive: http://marc.theaimsgroup.com/?l=imp&r=1&w=2
> Frequently Asked Questions: http://horde.org/faq/
> To unsubscribe, mail: imp-unsubscribe@lists.horde.org
> 
> 


::::::::::::::::::::::::::::::::::::::::
AMMMa AG - discover your knowledge
:::::::::::::::::::::::::::
Detmolder Str. 25-33 :: D-33604 Bielefeld
fon +49.521.96878-0 :: fax  +49.521.96878-20
http://www.ammma.de
::::::::::::::::::::::::::::::::::::::::::::::
---------------------- multipart/mixed attachment
Index: api.php
===================================================================
RCS file: /cvs/horde/imp/lib/api.php,v
retrieving revision 1.4
diff -u -r1.4 api.php
--- api.php	2001/06/13 13:56:32	1.4
+++ api.php	2001/06/14 12:49:02
@@ -26,19 +26,23 @@
             $folders = array('INBOX' => 1);
         }
             
+        $serverstring = IMP::serverString();
+        $existingfolders = imap_listmailbox($GLOBALS['imp']['stream'], $serverstring, '*');
         foreach ($folders as $folder => $true) {
-            $html .= '<tr><td class="text">';
-            $sts = imap_status($GLOBALS['imp']['stream'], IMP::serverString() . $folder, SA_UNSEEN);
-            if (!empty($sts->unseen)) {
-                $html .= '<b>';
+            if (in_array($serverstring . $folder, $existingfolders)) {
+                $html .= '<tr><td class="text">';
+                $sts = imap_status($GLOBALS['imp']['stream'], $serverstring . $folder, SA_UNSEEN);
+                if (!empty($sts->unseen)) {
+                    $html .= '<b>';
+                }
+                $html .= Horde::link(Horde::applicationUrl('mailbox.php?newmail_popup=no&mailbox=' . urlencode($folder)), IMP::displayFolder($folder)) . IMP::displayFolder($folder) . '</a>';
+                if (!empty($sts->unseen)) {
+                    $html .= '<b>';
+                }
+                $html .= '</td><td class="text">&nbsp;&nbsp;&nbsp;</td><td class="text">';
+                $html .= !empty($sts->unseen) ? '<b>' . $sts->unseen . '</b>' : '0';
+                $html .= '</td></tr>';
             }
-            $html .= Horde::link(Horde::applicationUrl('mailbox.php?newmail_popup=no&mailbox=' . urlencode($folder)), IMP::displayFolder($folder)) . IMP::displayFolder($folder) . '</a>';
-            if (!empty($sts->unseen)) {
-                $html .= '<b>';
-            }
-            $html .= '</td><td class="text">&nbsp;&nbsp;&nbsp;</td><td class="text">';
-            $html .= !empty($sts->unseen) ? '<b>' . $sts->unseen . '</b>' : '0';
-            $html .= '</td></tr>';
         }
     } else {
         $html .= '<tr><td class="text">' . Horde::link(Horde::applicationUrl('login.php'), sprintf(_("Log in to %s"), $GLOBALS['registry']->applications['imp']['name'])) . sprintf(_("Log in to %s"), $GLOBALS['registry']->applications['imp']['name']) . '</a></td></tr>';
Index: Folder.php
===================================================================
RCS file: /cvs/horde/imp/lib/Folder.php,v
retrieving revision 1.40
diff -u -r1.40 Folder.php
--- Folder.php	2001/05/30 14:29:18	1.40
+++ Folder.php	2001/06/14 12:49:02
@@ -218,24 +218,37 @@
      */
     function delete($stream, $folder_array, $subscribe)
     {
+        global $prefs;
+        
         $server = IMP::serverString();
         $return_value = true;
         if ($subscribe) {
             $subscribed_folders = imap_listsubscribed($stream, $server, '*');
         }
         
+        $pollfolders = @unserialize($prefs->getValue('nav_poll'));
         foreach ($folder_array as $folder) {
             if (!imap_deletemailbox($stream, $server . imap_utf7_encode($folder))) {
                 Horde::raiseMessage(sprintf(_("The folder \"%s\" was not deleted. This is what the server said"), IMP::displayFolder($folder)) .
                                     ': <i>' . imap_last_error() . '</i>', HORDE_ERROR);
                 $return_value = false;
-            } elseif ($subscribe && in_array($server . imap_utf7_encode($folder), $subscribed_folders) &&
-                      !imap_unsubscribe($stream, $server . imap_utf7_encode($folder))) {
-                Horde::raiseMessage(sprintf(_("The folder \"%s\" was deleted but you were not unsubscribed from it."), IMP::displayFolder($folder)), HORDE_WARNING);
-                $return_value = false;
             } else {
-                Horde::raiseMessage(sprintf(_("The folder \"%s\" was successfully deleted."), IMP::displayFolder($folder)), HORDE_SUCCESS);
+                if ($subscribe && in_array($server . imap_utf7_encode($folder), $subscribed_folders) &&
+                      !imap_unsubscribe($stream, $server . imap_utf7_encode($folder))) {
+                    Horde::raiseMessage(sprintf(_("The folder \"%s\" was deleted but you were not unsubscribed from it."), IMP::displayFolder($folder)), HORDE_WARNING);
+                    $return_value = false;
+                } else {
+                    Horde::raiseMessage(sprintf(_("The folder \"%s\" was successfully deleted."), IMP::displayFolder($folder)), HORDE_SUCCESS);
+                }
+                if (isset($pollfolders) && is_array($pollfolders)
+                    && in_array($folder, $pollfolders)) {
+                    unset($pollfolders[$folder]);
+                }
             }
+        }
+        if (isset($pollfolders) && is_array($pollfolders)) {
+            $prefs->setValue('nav_poll', serialize($pollfolders));
+            $prefs->store();
         }
         
         return $return_value;

---------------------- multipart/mixed attachment--