From drslump@drslump.biz Sat Jul 14 15:57:32 2007 From: DrSlump To: dev@lists.roundcube.net Subject: patch for subfolders display Date: Tue, 04 Oct 2005 01:03:59 +0200 Message-ID: <4341B8DF.7080601@drslump.biz> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============8719474815412439442==" --===============8719474815412439442== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Hi, I'm playing a bit with this webmail and I've implemented the displaying of subfolders. I've done the patch on the latest release since the CVS source seem to be badly broken when I checked out. I added three new functions to 'program/steps/mail/func.inc' ---- function rcmail_build_folder_tree( &$arrFolders, $folder, $path = '' ) { $pos = strpos($folder, '/'); if ($pos !== false) { $subFolders = substr($folder, $pos+1); $currentFolder = substr($folder, 0, $pos); } else { $subFolders = false; $currentFolder = $folder; } $path .= $currentFolder; if (!isset($arrFolders[ $currentFolder ])) { $arrFolders[ $currentFolder ] = array( 'id' => $path, 'name' => $currentFolder, 'folders' => array(), ); } if (!empty($subFolders)) { rcmail_build_folder_tree( $arrFolders[$currentFolder]['folders'], $subFolders, $path.'/' ); } } function rcmail_render_folder_tree_html( &$arrFolders, &$special, &$mbox, $nestLevel = 0 ) { global $JS_OBJECT_NAME, $IMAP; $idx = 0; $out = ''; foreach ($arrFolders as $key=>$folder) { $zebra_class = ($nestLevel*$idx)%2 ? 'even' : 'odd'; $folder_lc = strtolower($folder['id']); if (in_array($folder_lc, $special)) $foldername = rcube_label($folder_lc); else $foldername = $folder['name']; if ($unread_count = $IMAP->messagecount($folder['id'], 'UNSEEN')) $foldername .= sprintf(' (%d)', $unread_count); $out .= sprintf('
  • %s'."\n", preg_replace('/[^a-z0-9\-_]/', '', $folder_lc), $zebra_class, $unread_count ? ' unread' : '', $folder['id']==$mbox ? ' selected' : '', $folder['id'], $JS_OBJECT_NAME, $folder['id'], $JS_OBJECT_NAME, $folder['id'], rep_specialchars_output($foldername)); if (! empty($folder['folders'])) $out .= '\n"; $out .= "
  • \n"; $idx++; } return $out; } function rcmail_render_folder_tree_select( &$arrFolders, &$special, &$mbox, $nestLevel = 0 ) { global $IMAP; $idx = 0; $out = ''; foreach ($arrFolders as $key=>$folder) { $out .= sprintf(''."\n", $folder['id'], str_pad('', $nestLevel*2*6, ' '), rep_specialchars_output($folder['name'])); if (! empty($folder['folders'])) $out .= rcmail_render_folder_tree_select( $folder['folders'], $special, $mbox, $nestLevel+1 ); $idx++; } return $out; } ------- Then changed quite a bit the function rcmail_mailbox_list() ------- function rcmail_mailbox_list($attrib) { global $IMAP, $CONFIG, $OUTPUT, $JS_OBJECT_NAME, $COMM_PATH; static $s_added_script = FALSE; static $arrFolders; $type = $attrib['type'] ? $attrib['type'] : 'ul'; $add_attrib = $type=='select' ? array('style', 'class', 'id', 'name', 'onchange') : array('style', 'class', 'id'); if ($type=='ul' && !$attrib['id']) $attrib['id'] = 'rcmboxlist'; // allow the following attributes to be added to the