mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-02-02 19:39:26 +01:00
* email: caching of folderObjects for session under certain conditions, to speed up email module access
managing session cache for cached folderObjects; attempt to introduce better sorting for folderObjects in shared/other namespace (if available); removal of obsolete code
This commit is contained in:
parent
4300e20195
commit
a2b4861dc4
@ -607,6 +607,10 @@ class emailadmin_bo extends so_sql
|
|||||||
unset($structure[$_profileID]);
|
unset($structure[$_profileID]);
|
||||||
egw_cache::setCache(egw_cache::INSTANCE,'email','structureCache'.trim($GLOBALS['egw_info']['user']['account_id']),$structure, $expiration=60*60*1);
|
egw_cache::setCache(egw_cache::INSTANCE,'email','structureCache'.trim($GLOBALS['egw_info']['user']['account_id']),$structure, $expiration=60*60*1);
|
||||||
}
|
}
|
||||||
|
//reset cache, to trigger reload
|
||||||
|
$folders2return =& egw_cache::getSession('felamimail','folderObjects');
|
||||||
|
if (isset($folders2return[$this->bofelamimail->icServer->ImapServerId])) unset($folders2return[$this->bofelamimail->icServer->ImapServerId]);
|
||||||
|
|
||||||
$nameSpace = egw_cache::getSession('email','defaultimap_nameSpace');
|
$nameSpace = egw_cache::getSession('email','defaultimap_nameSpace');
|
||||||
if (isset($nameSpace[$_profileID]))
|
if (isset($nameSpace[$_profileID]))
|
||||||
{
|
{
|
||||||
|
@ -102,7 +102,10 @@ class ajaxfelamimail
|
|||||||
$newSubFolder = $this->_encodeDisplayFolderName($newSubFolder);
|
$newSubFolder = $this->_encodeDisplayFolderName($newSubFolder);
|
||||||
$response->addScript("tree.insertNewItem('$parentFolder','$folderName','$newSubFolder',onNodeSelect,'folderClosed.gif',0,0,'CHILD,CHECKED');");
|
$response->addScript("tree.insertNewItem('$parentFolder','$folderName','$newSubFolder',onNodeSelect,'folderClosed.gif',0,0,'CHILD,CHECKED');");
|
||||||
}
|
}
|
||||||
|
//reset cache, to trigger reload
|
||||||
|
$folders2return =& egw_cache::getSession('felamimail','folderObjects');
|
||||||
|
if (isset($folders2return[$this->bofelamimail->icServer->ImapServerId])) unset($folders2return[$this->bofelamimail->icServer->ImapServerId]);
|
||||||
|
//reset Form
|
||||||
$response->addAssign("newSubFolder", "value", '');
|
$response->addAssign("newSubFolder", "value", '');
|
||||||
|
|
||||||
return $response->getXML();
|
return $response->getXML();
|
||||||
@ -426,6 +429,9 @@ class ajaxfelamimail
|
|||||||
$folderName = $this->_encodeFolderName($folderName);
|
$folderName = $this->_encodeFolderName($folderName);
|
||||||
$response->addScript("tree.deleteItem('$folderName',1);");
|
$response->addScript("tree.deleteItem('$folderName',1);");
|
||||||
}
|
}
|
||||||
|
//reset cache, to trigger reload
|
||||||
|
$folders2return =& egw_cache::getSession('felamimail','folderObjects');
|
||||||
|
if (isset($folders2return[$this->bofelamimail->icServer->ImapServerId])) unset($folders2return[$this->bofelamimail->icServer->ImapServerId]);
|
||||||
|
|
||||||
return $response->getXML();
|
return $response->getXML();
|
||||||
}
|
}
|
||||||
@ -1315,6 +1321,10 @@ class ajaxfelamimail
|
|||||||
$response->addScript("window.tree.insertNewItem('$_parentFolder','$newFolderName','$folderName',onNodeSelect,'MailFolderPlain.png',0,0,'CHILD,CHECKED,SELECT,CALL');");
|
$response->addScript("window.tree.insertNewItem('$_parentFolder','$newFolderName','$folderName',onNodeSelect,'MailFolderPlain.png',0,0,'CHILD,CHECKED,SELECT,CALL');");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//reset cache, to trigger reload
|
||||||
|
$folders2return =& egw_cache::getSession('felamimail','folderObjects');
|
||||||
|
if (isset($folders2return[$this->bofelamimail->icServer->ImapServerId])) unset($folders2return[$this->bofelamimail->icServer->ImapServerId]);
|
||||||
|
|
||||||
return $response->getXML();
|
return $response->getXML();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1588,6 +1598,9 @@ class ajaxfelamimail
|
|||||||
$status = (bool)$_status;
|
$status = (bool)$_status;
|
||||||
|
|
||||||
$this->bofelamimail->subscribe($folderName, $status);
|
$this->bofelamimail->subscribe($folderName, $status);
|
||||||
|
//reset cache, to trigger reload
|
||||||
|
$folders2return =& egw_cache::getSession('felamimail','folderObjects');
|
||||||
|
if (isset($folders2return[$this->bofelamimail->icServer->ImapServerId])) unset($folders2return[$this->bofelamimail->icServer->ImapServerId]);
|
||||||
|
|
||||||
$response = new xajaxResponse();
|
$response = new xajaxResponse();
|
||||||
return $response->getXML();
|
return $response->getXML();
|
||||||
|
@ -1812,7 +1812,7 @@ class felamimail_bo
|
|||||||
*
|
*
|
||||||
* returns an array of IMAP folder objects. Put INBOX folder in first
|
* returns an array of IMAP folder objects. Put INBOX folder in first
|
||||||
* position. Preserves the folder seperator for later use. The returned
|
* position. Preserves the folder seperator for later use. The returned
|
||||||
* array is indexed using the foldername.
|
* array is indexed using the foldername. Use cachedObjects when retrieving subscribedFolders
|
||||||
*
|
*
|
||||||
* @param _subscribedOnly boolean get subscribed or all folders
|
* @param _subscribedOnly boolean get subscribed or all folders
|
||||||
* @param _getCounters boolean get get messages counters
|
* @param _getCounters boolean get get messages counters
|
||||||
@ -1823,6 +1823,17 @@ class felamimail_bo
|
|||||||
*/
|
*/
|
||||||
function getFolderObjects($_subscribedOnly=false, $_getCounters=false, $_alwaysGetDefaultFolders=false)
|
function getFolderObjects($_subscribedOnly=false, $_getCounters=false, $_alwaysGetDefaultFolders=false)
|
||||||
{
|
{
|
||||||
|
if (self::$debug) error_log(__METHOD__.__LINE__.' '."subscribedOnly:$_subscribedOnly, getCounters:$_getCounters, alwaysGetDefaultFolders:$_alwaysGetDefaultFolders");
|
||||||
|
static $folders2return;
|
||||||
|
if ($_subscribedOnly && $_getCounters===false)
|
||||||
|
{
|
||||||
|
if (is_null($folders2return)) $folders2return =& egw_cache::getSession('felamimail','folderObjects');
|
||||||
|
if (isset($folders2return[$this->icServer->ImapServerId]))
|
||||||
|
{
|
||||||
|
//error_log(__METHOD__.__LINE__.' using Cached folderObjects');
|
||||||
|
return $folders2return[$this->icServer->ImapServerId];
|
||||||
|
}
|
||||||
|
}
|
||||||
$isUWIMAP = false;
|
$isUWIMAP = false;
|
||||||
|
|
||||||
$delimiter = $this->getHierarchyDelimiter();
|
$delimiter = $this->getHierarchyDelimiter();
|
||||||
@ -2075,6 +2086,7 @@ class felamimail_bo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#echo "<br>FolderNameSpace To Process:";_debug_array($foldersNameSpace);
|
#echo "<br>FolderNameSpace To Process:";_debug_array($foldersNameSpace);
|
||||||
|
$autoFolderObjects = array();
|
||||||
foreach( array('personal', 'others', 'shared') as $type) {
|
foreach( array('personal', 'others', 'shared') as $type) {
|
||||||
if(isset($foldersNameSpace[$type])) {
|
if(isset($foldersNameSpace[$type])) {
|
||||||
if($_subscribedOnly) {
|
if($_subscribedOnly) {
|
||||||
@ -2102,18 +2114,6 @@ class felamimail_bo
|
|||||||
}
|
}
|
||||||
|
|
||||||
if($_getCounters == true) {
|
if($_getCounters == true) {
|
||||||
/*
|
|
||||||
$folderStatus = $this->_getStatus($folderName);
|
|
||||||
#echo "<br> FolderStatus:";_debug_array($folderStatus);
|
|
||||||
if(is_array($folderStatus)) {
|
|
||||||
$status = new stdClass;
|
|
||||||
$status->messages = $folderStatus['MESSAGES'];
|
|
||||||
$status->unseen = $folderStatus['UNSEEN'];
|
|
||||||
$status->recent = $folderStatus['RECENT'];
|
|
||||||
|
|
||||||
$folderObject->counter = $status;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
$folderObject->counter = $this->bofelamimail->getMailBoxCounters($folderName);
|
$folderObject->counter = $this->bofelamimail->getMailBoxCounters($folderName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2135,8 +2135,8 @@ class felamimail_bo
|
|||||||
$folderObject->displayName = $this->encodeFolderName($folderObject->folderName);
|
$folderObject->displayName = $this->encodeFolderName($folderObject->folderName);
|
||||||
$folderObject->shortDisplayName = $this->encodeFolderName($shortName);
|
$folderObject->shortDisplayName = $this->encodeFolderName($shortName);
|
||||||
}
|
}
|
||||||
$folderName = $folderName;
|
//$folderName = $folderName;
|
||||||
if (in_array($shortName,self::$autoFolders)) {
|
if (in_array($shortName,self::$autoFolders)&&self::searchValueInFolderObjects($shortName,$autoFolderObjects)===false) {
|
||||||
$autoFolderObjects[$folderName] = $folderObject;
|
$autoFolderObjects[$folderName] = $folderObject;
|
||||||
} else {
|
} else {
|
||||||
$folders[$folderName] = $folderObject;
|
$folders[$folderName] = $folderObject;
|
||||||
@ -2144,13 +2144,24 @@ class felamimail_bo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (is_array($autoFolderObjects)) {
|
if (is_array($autoFolderObjects) && !empty($autoFolderObjects)) {
|
||||||
uasort($autoFolderObjects,array($this,"sortByAutoFolderPos"));
|
uasort($autoFolderObjects,array($this,"sortByAutoFolderPos"));
|
||||||
}
|
}
|
||||||
if (is_array($folders)) uasort($folders,array($this,"sortByDisplayName"));
|
if (is_array($folders)) uasort($folders,array($this,"sortByDisplayName"));
|
||||||
//$folders2return = array_merge($autoFolderObjects,$folders);
|
//$folders2return = array_merge($autoFolderObjects,$folders);
|
||||||
//_debug_array($folders2return); #exit;
|
//_debug_array($folders2return); #exit;
|
||||||
return array_merge($inboxFolderObject,(array)$autoFolderObjects,(array)$folders);
|
$folders2return[$this->icServer->ImapServerId] = array_merge($inboxFolderObject,$autoFolderObjects,(array)$folders);
|
||||||
|
return $folders2return[$this->icServer->ImapServerId];
|
||||||
|
}
|
||||||
|
|
||||||
|
static function searchValueInFolderObjects($needle, $haystack)
|
||||||
|
{
|
||||||
|
$rv = false;
|
||||||
|
foreach ($haystack as $k => $v)
|
||||||
|
{
|
||||||
|
foreach($v as $sk => $sv) if (trim($sv)==trim($needle)) return $k;
|
||||||
|
}
|
||||||
|
return $rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
function sortByDisplayName($a,$b)
|
function sortByDisplayName($a,$b)
|
||||||
@ -2162,8 +2173,8 @@ class felamimail_bo
|
|||||||
function sortByAutoFolderPos($a,$b)
|
function sortByAutoFolderPos($a,$b)
|
||||||
{
|
{
|
||||||
// 0, 1 und -1
|
// 0, 1 und -1
|
||||||
$pos1 = array_search($a->shortFolderName,self::$autoFolders);
|
$pos1 = array_search(trim($a->shortFolderName),self::$autoFolders);
|
||||||
$pos2 = array_search($b->shortFolderName,self::$autoFolders);
|
$pos2 = array_search(trim($b->shortFolderName),self::$autoFolders);
|
||||||
if ($pos1 == $pos2) return 0;
|
if ($pos1 == $pos2) return 0;
|
||||||
return ($pos1 < $pos2) ? -1 : 1;
|
return ($pos1 < $pos2) ? -1 : 1;
|
||||||
}
|
}
|
||||||
|
@ -25,8 +25,6 @@ class uifelamimail
|
|||||||
'compressFolder' => True,
|
'compressFolder' => True,
|
||||||
'importMessage' => True,
|
'importMessage' => True,
|
||||||
'importMessageFromVFS2DraftAndDisplay' => True,
|
'importMessageFromVFS2DraftAndDisplay' => True,
|
||||||
'deleteMessage' => True,
|
|
||||||
'undeleteMessage' => True,
|
|
||||||
'hookAdmin' => True,
|
'hookAdmin' => True,
|
||||||
'toggleFilter' => True,
|
'toggleFilter' => True,
|
||||||
'viewMainScreen' => True,
|
'viewMainScreen' => True,
|
||||||
@ -675,44 +673,6 @@ class uifelamimail
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteMessage()
|
|
||||||
{
|
|
||||||
//error_log(__METHOD__." called from:".function_backtrace());
|
|
||||||
$message[] = $_GET["message"];
|
|
||||||
$mailfolder = NULL;
|
|
||||||
if (!empty($_GET['folder'])) $mailfolder = base64_decode($_GET['folder']);
|
|
||||||
|
|
||||||
$this->bofelamimail->deleteMessages($message,$mailfolder);
|
|
||||||
|
|
||||||
// set the url to open when refreshing
|
|
||||||
$linkData = array
|
|
||||||
(
|
|
||||||
'menuaction' => 'felamimail.uifelamimail.viewMainScreen'
|
|
||||||
);
|
|
||||||
$refreshURL = $GLOBALS['egw']->link('/index.php',$linkData);
|
|
||||||
|
|
||||||
print "<script type=\"text/javascript\">
|
|
||||||
opener.location.href = '" .$refreshURL. "';
|
|
||||||
window.close();</script>";
|
|
||||||
}
|
|
||||||
|
|
||||||
function undeleteMessage()
|
|
||||||
{ // only for messages marked as deleted
|
|
||||||
$message[] = $_GET["message"];
|
|
||||||
$mailfolder = NULL;
|
|
||||||
if (!empty($_GET['folder'])) $mailfolder = base64_decode($_GET['folder']);
|
|
||||||
$this->bofelamimail->flagMessages('undelete',$message,$mailfolder);
|
|
||||||
// set the url to open when refreshing
|
|
||||||
$linkData = array
|
|
||||||
(
|
|
||||||
'menuaction' => 'felamimail.uifelamimail.viewMainScreen'
|
|
||||||
);
|
|
||||||
$refreshURL = $GLOBALS['egw']->link('/index.php',$linkData);
|
|
||||||
print "<script type=\"text/javascript\">
|
|
||||||
opener.location.href = '" .$refreshURL. "';
|
|
||||||
window.close();</script>";
|
|
||||||
}
|
|
||||||
|
|
||||||
function display_app_header($includeFMStuff=true)
|
function display_app_header($includeFMStuff=true)
|
||||||
{
|
{
|
||||||
if ($includeFMStuff)
|
if ($includeFMStuff)
|
||||||
|
Loading…
Reference in New Issue
Block a user