diff options
Diffstat (limited to 'program/steps/mail')
-rw-r--r-- | program/steps/mail/func.inc | 217 |
1 files changed, 1 insertions, 216 deletions
diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc index 4267b48fe..8c5f987c3 100644 --- a/program/steps/mail/func.inc +++ b/program/steps/mail/func.inc @@ -76,221 +76,6 @@ if (!$OUTPUT->ajax_call) rcube_add_label('checkingmail'); -// return the mailboxlist in HTML -function rcmail_mailbox_list($attrib) - { - global $IMAP, $CONFIG, $OUTPUT, $COMM_PATH; - static $s_added_script = FALSE; - static $a_mailboxes; - - // add some labels to client - rcube_add_label('purgefolderconfirm'); - rcube_add_label('deletemessagesconfirm'); - -// $mboxlist_start = rcube_timer(); - - $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 <ul> tag - $attrib_str = create_attrib_string($attrib, $add_attrib); - - $out = '<' . $type . $attrib_str . ">\n"; - - // add no-selection option - if ($type=='select' && $attrib['noselection']) - $out .= sprintf('<option value="0">%s</option>'."\n", - rcube_label($attrib['noselection'])); - - // get mailbox list - $mbox_name = $IMAP->get_mailbox_name(); - - // for these mailboxes we have localized labels - $special_mailboxes = array('inbox', 'sent', 'drafts', 'trash', 'junk'); - - - // build the folders tree - if (empty($a_mailboxes)) - { - // get mailbox list - $a_folders = $IMAP->list_mailboxes(); - $delimiter = $IMAP->get_hierarchy_delimiter(); - $a_mailboxes = array(); - -// rcube_print_time($mboxlist_start, 'list_mailboxes()'); - - foreach ($a_folders as $folder) - rcmail_build_folder_tree($a_mailboxes, $folder, $delimiter); - } - -// var_dump($a_mailboxes); - - if ($type=='select') - $out .= rcmail_render_folder_tree_select($a_mailboxes, $special_mailboxes, $mbox_name, $attrib['maxlength']); - else - $out .= rcmail_render_folder_tree_html($a_mailboxes, $special_mailboxes, $mbox_name, $attrib['maxlength']); - -// rcube_print_time($mboxlist_start, 'render_folder_tree()'); - - - if ($type=='ul') - $OUTPUT->add_gui_object('mailboxlist', $attrib['id']); - - return $out . "</$type>"; - } - - - - -// create a hierarchical array of the mailbox list -function rcmail_build_folder_tree(&$arrFolders, $folder, $delm='/', $path='') - { - $pos = strpos($folder, $delm); - 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' => rcube_charset_convert($currentFolder, 'UTF-7'), - 'folders' => array()); - } - - if (!empty($subFolders)) - rcmail_build_folder_tree($arrFolders[$currentFolder]['folders'], $subFolders, $delm, $path.$delm); - } - - -// return html for a structured list <ul> for the mailbox tree -function rcmail_render_folder_tree_html(&$arrFolders, &$special, &$mbox_name, $maxlength, $nestLevel=0) - { - global $COMM_PATH, $IMAP, $CONFIG, $OUTPUT; - - $idx = 0; - $out = ''; - foreach ($arrFolders as $key => $folder) - { - $zebra_class = ($nestLevel*$idx)%2 ? 'even' : 'odd'; - $title = ''; - - $folder_lc = strtolower($folder['id']); - if (in_array($folder_lc, $special)) - $foldername = rcube_label($folder_lc); - else - { - $foldername = $folder['name']; - - // shorten the folder name to a given length - if ($maxlength && $maxlength>1) - { - $fname = abbrevate_string($foldername, $maxlength); - if ($fname != $foldername) - $title = ' title="'.Q($foldername).'"'; - $foldername = $fname; - } - } - - // add unread message count display - if ($unread_count = $IMAP->messagecount($folder['id'], 'RECENT', ($folder['id']==$mbox_name))) - $foldername .= sprintf(' (%d)', $unread_count); - - // make folder name safe for ids and class names - $folder_id = preg_replace('/[^A-Za-z0-9\-_]/', '', $folder['id']); - $class_name = preg_replace('/[^a-z0-9\-_]/', '', $folder_lc); - - // set special class for Sent, Drafts, Trash and Junk - if ($folder['id']==$CONFIG['sent_mbox']) - $class_name = 'sent'; - else if ($folder['id']==$CONFIG['drafts_mbox']) - $class_name = 'drafts'; - else if ($folder['id']==$CONFIG['trash_mbox']) - $class_name = 'trash'; - else if ($folder['id']==$CONFIG['junk_mbox']) - $class_name = 'junk'; - - $js_name = htmlspecialchars(JQ($folder['id'])); - $out .= sprintf('<li id="rcmli%s" class="mailbox %s %s%s%s"><a href="%s"'. - ' onclick="return %s.command(\'list\',\'%s\',this)"'. - ' onmouseover="return %s.focus_folder(\'%s\')"' . - ' onmouseout="return %s.unfocus_folder(\'%s\')"' . - ' onmouseup="return %s.folder_mouse_up(\'%s\')"%s>%s</a>', - $folder_id, - $class_name, - $zebra_class, - $unread_count ? ' unread' : '', - $folder['id']==$mbox_name ? ' selected' : '', - Q(rcmail_url('', array('_mbox' => $folder['id']))), - JS_OBJECT_NAME, - $js_name, - JS_OBJECT_NAME, - $js_name, - JS_OBJECT_NAME, - $js_name, - JS_OBJECT_NAME, - $js_name, - $title, - Q($foldername)); - - if (!empty($folder['folders'])) - $out .= "\n<ul>\n" . rcmail_render_folder_tree_html($folder['folders'], $special, $mbox_name, $maxlength, $nestLevel+1) . "</ul>\n"; - - $out .= "</li>\n"; - $idx++; - } - - return $out; - } - - -// return html for a flat list <select> for the mailbox tree -function rcmail_render_folder_tree_select(&$arrFolders, &$special, &$mbox_name, $maxlength, $nestLevel=0) - { - global $IMAP, $OUTPUT; - - $idx = 0; - $out = ''; - foreach ($arrFolders as $key=>$folder) - { - $folder_lc = strtolower($folder['id']); - if (in_array($folder_lc, $special)) - $foldername = rcube_label($folder_lc); - else - { - $foldername = $folder['name']; - - // shorten the folder name to a given length - if ($maxlength && $maxlength>1) - $foldername = abbrevate_string($foldername, $maxlength); - } - - $out .= sprintf('<option value="%s">%s%s</option>'."\n", - htmlspecialchars($folder['id']), - str_repeat(' ', $nestLevel*4), - Q($foldername)); - - if (!empty($folder['folders'])) - $out .= rcmail_render_folder_tree_select($folder['folders'], $special, $mbox_name, $maxlength, $nestLevel+1); - - $idx++; - } - - return $out; - } - // return the message list as HTML table function rcmail_message_list($attrib) @@ -1492,4 +1277,4 @@ $OUTPUT->add_handlers(array( 'searchform' => 'rcmail_search_form' )); -?>
\ No newline at end of file +?> |