[dev] imp folder prefix

Egan egan@sevenkings.net
Mon, 28 May 2001 19:44:00 -0400


---------------------- multipart/mixed attachment
On Mon, 28 May 2001 12:50:07 -0400, Chuck Hagenbuch <chuck@horde.org>
wrote:

>Sounds like you pretty much have it thought out - the tricky part is to keep 
>the prefix in the hierarchy somewhere to avoid errors with folder subscriptions 
>and such.

Yes, I can see what you mean.  So I patched the presentation, and left
the hierarchy unchanged.

In folders.php, I copy $mailbox['level'] to a temporary variable
called $indent_level, which is then used by row.inc.

I look to see if we have a prefix, and if so, subtract 1 from the
indent_level.  That way, the entire hierarchy will be shifted up for
display purposes.  If the indent level is negative, that means it is
the prefix, and it is not displayed (except for INBOX, which is a
special case).

When you have a prefix, it seems to work, except when collapsing all
folders.  Then you are left with nothing but the INBOX.  Looks like
some other section of code will need patching to handle that.

I did not have time to look at that today -- I've attached the patch
for what I've done so far.





---------------------- multipart/mixed attachment
--- horde/imp/folders.php	Sun May 27 11:05:43 2001
+++ horde/imp/folders.php	Mon May 28 17:34:34 2001
@@ -248,6 +248,10 @@
 
 /* Start iterating through the list of mailboxes, displaying them */
 $mailbox = $imaptree->head();
+if (isset($imaptree->prefix) && strlen($imaptree->prefix) > 0)
+    $upshift_prefix = true;
+else
+    $upshift_prefix = false;
 
 while (isset($mailbox) && is_array($mailbox)) {
 
@@ -341,8 +345,13 @@
         $navclass = ($rowct = !$rowct) ? 'list' : 'listlt';
     }
 
-    include $conf['paths']['templates'] . '/folders/row.inc';
-    $i++;
+    $indent_level = $mailbox['level'];
+    if ($upshift_prefix && $mailbox['value'] != 'INBOX')
+        $indent_level--;
+    if ($indent_level >= 0) {
+        include $conf['paths']['templates'] . '/folders/row.inc';
+        $i++;
+    }    
     
     if ($imaptree->isOpen($mailbox)) {
         $mailbox = $imaptree->next();
--- horde/imp/lib/Tree.php	Sun Apr 29 13:00:18 2001
+++ horde/imp/lib/Tree.php	Mon May 28 17:53:20 2001
@@ -312,22 +312,26 @@
     function pickle () {
         $pickle = array();
         $pickle['tree'] = base64_encode(serialize($this->tree));
-        $pickle['first'] = $this->first;
         $pickle['cur'] = $this->cur;
+        $pickle['first'] = $this->first;
         $pickle['delimiter'] = $this->delimiter;
-        $pickle['server'] = $this->server;
         $pickle['listcmd'] = $this->listcmd;
+        $pickle['prefix'] = $this->prefix;
+        $pickle['offset'] = $this->offset;
+        $pickle['server'] = $this->server;
         return $pickle;
     } // pickle()
     
     // rebuild oneself from a serialized string
     function unpickle ($pickle) {
         $this->tree = unserialize(base64_decode($pickle['tree']));
-        $this->first = $pickle['first'];
         $this->cur = $pickle['cur'];
+        $this->first = $pickle['first'];
         $this->delimiter = $pickle['delimiter'];
-        $this->server = $pickle['server'];
         $this->listcmd = $pickle['listcmd'];
+        $this->prefix = $pickle['prefix'];
+        $this->offset = $pickle['offset'];
+        $this->server = $pickle['server'];
     }
     
     
--- horde/imp/templates/folders/row.inc	Mon May 28 17:57:53 2001
+++ horde/imp/templates/folders/row.inc	Mon May 28 17:55:46 2001
@@ -1,7 +1,7 @@
 <tr class="<?= $navclass ?>">
  <td class="<?= $navclass ?>">
   <input class="<?= $navclass ?>" type="checkbox" name="folder_list[]" value="<?= str_replace('"', '\"', $mailbox['value']) ?>" /> 
-  <?php Horde::pimg('/folders/spacer.gif', 'height="1" width="' . $mailbox['level'] * 18 . '"') ?>
+  <?php Horde::pimg('/folders/spacer.gif', 'height="1" width="' . $indent_level * 18 . '"') ?>
  <?= $dir . '&nbsp;&nbsp;' . $name ?>
  </td>
  <td align="center"><?= $msgs ?></td>



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