From c8a21d646ca96aaf00867b90b582a6572c591ee2 Mon Sep 17 00:00:00 2001 From: thomascube <thomas@roundcube.net> Date: Fri, 05 Sep 2008 03:27:23 -0400 Subject: [PATCH] Killed one more global var + log logins to a separate file (not console) --- program/include/main.inc | 54 +++++++++++++++++++++++++++++++++--------------------- 1 files changed, 33 insertions(+), 21 deletions(-) diff --git a/program/include/main.inc b/program/include/main.inc index 2b47978..a6ad93d 100644 --- a/program/include/main.inc +++ b/program/include/main.inc @@ -317,7 +317,7 @@ $is_iso_8859_1 = true; } if (!$enctype) - $enctype = $GLOBALS['OUTPUT_TYPE']; + $enctype = $OUTPUT->type; // encode for plaintext if ($enctype=='text') @@ -706,9 +706,13 @@ return ''; // get user's timezone - $tz = $CONFIG['timezone']; - if ($CONFIG['dst_active']) - $tz++; + if ($CONFIG['timezone'] === 'auto') + $tz = isset($_SESSION['timezone']) ? $_SESSION['timezone'] : date('Z')/3600; + else { + $tz = $CONFIG['timezone']; + if ($CONFIG['dst_active']) + $tz++; + } // convert time to user's timezone $timestamp = $ts - date('Z', $ts) + ($tz * 3600); @@ -792,19 +796,20 @@ * * @param mixed Debug message or data */ -function console($msg) +function console() { - if (!is_string($msg)) - $msg = var_export($msg, true); + $msg = array(); + foreach (func_get_args() as $arg) + $msg[] = !is_string($arg) ? var_export($arg, true) : $arg; if (!($GLOBALS['CONFIG']['debug_level'] & 4)) - write_log('console', $msg); + write_log('console', join(";\n", $msg)); else if ($GLOBALS['OUTPUT']->ajax_call) - print "/*\n $msg \n*/\n"; + print "/*\n " . join(";\n", $msg) . " \n*/\n"; else { print '<div style="background:#eee; border:1px solid #ccc; margin-bottom:3px; padding:6px"><pre>'; - print $msg; + print join(";<br/>\n", $msg); print "</pre></div>\n"; } } @@ -884,7 +889,7 @@ */ function rcmail_mailbox_list($attrib) { - global $IMAP, $OUTPUT; + global $RCMAIL; static $a_mailboxes; $attrib += array('maxlength' => 100, 'relanames' => false); @@ -900,13 +905,13 @@ $attrib['id'] = 'rcmboxlist'; // get mailbox list - $mbox_name = $IMAP->get_mailbox_name(); + $mbox_name = $RCMAIL->imap->get_mailbox_name(); // build the folders tree if (empty($a_mailboxes)) { // get mailbox list - $a_folders = $IMAP->list_mailboxes(); - $delimiter = $IMAP->get_hierarchy_delimiter(); + $a_folders = $RCMAIL->imap->list_mailboxes(); + $delimiter = $RCMAIL->imap->get_hierarchy_delimiter(); $a_mailboxes = array(); foreach ($a_folders as $folder) @@ -927,8 +932,10 @@ $out = html::tag('ul', $attrib, rcmail_render_folder_tree_html($a_mailboxes, $mbox_name, $attrib['maxlength'], $attrib['realnames']), html::$common_attrib); } - if ($type=='ul') - $OUTPUT->add_gui_object('mailboxlist', $attrib['id']); + if ($type=='ul') { + $RCMAIL->output->add_gui_object('mailboxlist', $attrib['id']); + $RCMAIL->output->set_env('collapsed_folders', $RCMAIL->config->get('collapsed_folders')); + } return $out; } @@ -1000,7 +1007,7 @@ */ function rcmail_render_folder_tree_html(&$arrFolders, &$mbox_name, $maxlength, $realnames=false, $nestLevel=0) { - global $COMM_PATH, $IMAP, $CONFIG, $OUTPUT; + global $RCMAIL, $CONFIG; $idx = 0; $out = ''; @@ -1046,6 +1053,8 @@ if ($folder['id'] == $mbox_name) $classes[] = 'selected'; + $collapsed = preg_match('/&'.rawurlencode($folder['id']).'&/', $RCMAIL->config->get('collapsed_folders')); + $js_name = JQ($folder['id']); $out .= html::tag('li', array( 'id' => "rcmli".$folder_id, @@ -1058,10 +1067,15 @@ 'onmouseout' => sprintf("return %s.unfocus_folder('%s')", JS_OBJECT_NAME, $js_name), 'onmouseup' => sprintf("return %s.folder_mouse_up('%s')", JS_OBJECT_NAME, $js_name), 'title' => $title, - ), Q($foldername))); + ), Q($foldername)) . + (!empty($folder['folders']) ? html::div(array( + 'class' => ($collapsed ? 'collapsed' : 'expanded'), + 'style' => "position:absolute", + 'onclick' => sprintf("%s.command('collapse-folder', '%s')", JS_OBJECT_NAME, $js_name) + ), ' ') : '')); if (!empty($folder['folders'])) - $out .= "\n<ul>\n" . rcmail_render_folder_tree_html($folder['folders'], $mbox_name, $maxlength, $realnames, $nestLevel+1) . "</ul>\n"; + $out .= "\n<ul" . ($collapsed ? " style=\"display: none;\"" : "") . ">\n" . rcmail_render_folder_tree_html($folder['folders'], $mbox_name, $maxlength, $realnames, $nestLevel+1) . "</ul>\n"; $out .= "</li>\n"; $idx++; @@ -1077,8 +1091,6 @@ */ function rcmail_render_folder_tree_select(&$arrFolders, &$mbox_name, $maxlength, &$select, $realnames=false, $nestLevel=0) { - global $IMAP, $OUTPUT; - $idx = 0; $out = ''; foreach ($arrFolders as $key=>$folder) -- Gitblit v1.9.1