From 24676c0a334df338fe22fb458dd557cb1da4699e Mon Sep 17 00:00:00 2001 From: Klaus Leithoff Date: Mon, 13 Jan 2014 17:29:27 +0000 Subject: [PATCH] call counters on index call, but only retrieve them for one level up til the current folder level --- mail/inc/class.mail_ui.inc.php | 22 +++++++++++++++++++--- mail/js/app.js | 2 +- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/mail/inc/class.mail_ui.inc.php b/mail/inc/class.mail_ui.inc.php index e580b4fd91..7e4e0d543c 100644 --- a/mail/inc/class.mail_ui.inc.php +++ b/mail/inc/class.mail_ui.inc.php @@ -184,6 +184,7 @@ class mail_ui */ function index(array $content=null,$msg=null) { + //error_log(__METHOD__.__LINE__.function_backtrace()); $starttime = microtime (true); $this->mail_bo->restoreSessionData(); $sessionFolder = $this->mail_bo->sessionData['mailbox']; @@ -273,7 +274,7 @@ class mail_ui } //$zstarttime = microtime (true); - $sel_options[self::$nm_index]['foldertree'] = $this->getFolderTree(false); + $sel_options[self::$nm_index]['foldertree'] = $this->getFolderTree('initial'); //$zendtime = microtime(true) - $zstarttime; //error_log(__METHOD__.__LINE__. " time used: ".$zendtime); //$this->mail_bo->fetchUnSubscribedFolders(); @@ -604,7 +605,8 @@ class mail_ui /** * getFolderTree, get folders from server and prepare the folder tree - * @param bool $_fetchCounters, wether to fetch extended information on folders + * @param mixed bool/string $_fetchCounters, wether to fetch extended information on folders + * if set to initial, only for initial level of seen (unfolded) folders * @param string $_nodeID, nodeID to fetch and return * @param boolean $_subscribedOnly flag to tell wether to fetch all or only subscribed (default) * @return array something like that: array('id'=>0, @@ -667,9 +669,23 @@ class mail_ui //error_log(__METHOD__.__LINE__.array2string($folderObjects)); $c = 0; + $delimiter = $this->mail_bo->getHierarchyDelimiter(); + $cmb = $this->mail_bo->icServer->getCurrentMailbox(); + $cmblevels = explode($delimiter,$cmb); + $cmblevelsCt = count($cmblevels); + //error_log(__METHOD__.__LINE__.function_backtrace()); foreach($folderObjects as $key => $obj) { - $fS = $this->mail_bo->getFolderStatus($key,false,($_fetchCounters?false:true)); + //error_log(__METHOD__.__LINE__.array2string($key)); + $levels = explode($delimiter,$key); + $levelCt = count($levels); + $fetchCounters = (bool)$_fetchCounters; + if ($_fetchCounters==='initial') + { + if ($levelCt>$cmblevelsCt+1) $fetchCounters=false; + } + //error_log(__METHOD__.__LINE__.' fc:'.$fetchCounters.'/'.$_fetchCounters.'('.$levelCt.'/'.$cmblevelsCt.')'.' for:'.array2string($key)); + $fS = $this->mail_bo->getFolderStatus($key,false,($fetchCounters?false:true)); //_debug_array($fS); //error_log(__METHOD__.__LINE__.array2string($fS)); $fFP = $folderParts = explode($obj->delimiter, $key); diff --git a/mail/js/app.js b/mail/js/app.js index 5b3a19a579..71bf37879c 100644 --- a/mail/js/app.js +++ b/mail/js/app.js @@ -126,7 +126,7 @@ app.classes.mail = AppJS.extend( // Bind to nextmatch refresh to update folder status var nm = this.et2.getWidgetById('nm'); - if(nm != null) + if(nm != null && (typeof jQuery._data(nm).events=='undefined'||typeof jQuery._data(nm).events.refresh == 'undefined')) { var self = this; $j(nm).on('refresh',function() {self.mail_refreshFolderStatus.call(self,undefined,undefined,false);});