From af3c045ecf4865361981f4c9aa392dfe1f93ac90 Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Fri, 03 Dec 2010 05:58:40 -0500
Subject: [PATCH] - New Folder Manager UI - Fix invalid Request when creating a folder (#1487443) - Add folder size and quota indicator in folder manager (#1485780) - Add possibility to move a subfolder into root folder (#1486791)

---
 program/include/main.inc |   68 +++++++++++++++++++++++++++++++++-
 1 files changed, 66 insertions(+), 2 deletions(-)

diff --git a/program/include/main.inc b/program/include/main.inc
index 7ea4ae2..6d4e19c 100644
--- a/program/include/main.inc
+++ b/program/include/main.inc
@@ -1314,8 +1314,13 @@
   
   $p += array('maxlength' => 100, 'realnames' => false);
   $a_mailboxes = array();
-  
-  foreach ($RCMAIL->imap->list_mailboxes() as $folder)
+
+  if ($p['unsubscribed'])
+    $list = $RCMAIL->imap->list_unsubscribed();
+  else
+    $list = $RCMAIL->imap->list_mailboxes();
+
+  foreach ($list as $folder)
     if (empty($p['exceptions']) || !in_array($folder, $p['exceptions']))
       rcmail_build_folder_tree($a_mailboxes, $folder, $RCMAIL->imap->get_hierarchy_delimiter());
 
@@ -1551,6 +1556,65 @@
 }
 
 
+function rcmail_quota_display($attrib)
+{
+  global $OUTPUT;
+
+  if (!$attrib['id'])
+    $attrib['id'] = 'rcmquotadisplay';
+
+  if(isset($attrib['display']))
+    $_SESSION['quota_display'] = $attrib['display'];
+
+  $OUTPUT->add_gui_object('quotadisplay', $attrib['id']);
+
+  $quota = rcmail_quota_content($attrib);
+
+  $OUTPUT->add_script('$(document).ready(function(){
+	rcmail.set_quota('.json_serialize($quota).')});', 'foot');
+
+  return html::span($attrib, '');
+}
+
+
+function rcmail_quota_content($attrib=NULL)
+{
+  global $RCMAIL;
+
+  $quota = $RCMAIL->imap->get_quota();
+  $quota = $RCMAIL->plugins->exec_hook('quota', $quota);
+
+  $quota_result = (array) $quota;
+  $quota_result['type'] = isset($_SESSION['quota_display']) ? $_SESSION['quota_display'] : '';
+
+  if (!$quota['total'] && $RCMAIL->config->get('quota_zero_as_unlimited')) {
+    $quota_result['title'] = rcube_label('unlimited');
+    $quota_result['percent'] = 0;
+  }
+  else if ($quota['total']) {
+    if (!isset($quota['percent']))
+      $quota_result['percent'] = min(100, round(($quota['used']/max(1,$quota['total']))*100));
+
+    $title = sprintf('%s / %s (%.0f%%)',
+        show_bytes($quota['used'] * 1024), show_bytes($quota['total'] * 1024),
+        $quota_result['percent']);
+
+    $quota_result['title'] = $title;
+
+    if ($attrib['width'])
+      $quota_result['width'] = $attrib['width'];
+    if ($attrib['height'])
+      $quota_result['height']	= $attrib['height'];
+  }
+  else {
+    $quota_result['title'] = rcube_label('unknown');
+    $quota_result['percent'] = 0;
+  }
+
+  return $quota_result;
+}
+
+
 /**
  * Output HTML editor scripts
  *

--
Gitblit v1.9.1