mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-08 00:54:50 +01:00
* Mail: skip accounts with no imap server set for notification and foldertree
This commit is contained in:
parent
c912849bd5
commit
b69e147247
@ -637,8 +637,9 @@ class mail_hooks
|
|||||||
*/
|
*/
|
||||||
static function notification_check_mailbox()
|
static function notification_check_mailbox()
|
||||||
{
|
{
|
||||||
$accountsToSearch = emailadmin_account::search($only_current_user=true, $just_name=true);
|
$accountsToSearchObj = emailadmin_account::search($only_current_user=true, $just_name=true);
|
||||||
foreach($accountsToSearch as $acc_id => $identity_name)
|
|
||||||
|
foreach($accountsToSearchObj as $acc_id => $identity_name)
|
||||||
{
|
{
|
||||||
//error_log(__METHOD__.__LINE__.' '.$acc_id.':'.$identity_name);
|
//error_log(__METHOD__.__LINE__.' '.$acc_id.':'.$identity_name);
|
||||||
$folders2notify[$acc_id] = emailadmin_notifications::read($acc_id);// read all, even those set for acc_id 0 (folders for all acounts?)
|
$folders2notify[$acc_id] = emailadmin_notifications::read($acc_id);// read all, even those set for acc_id 0 (folders for all acounts?)
|
||||||
@ -648,18 +649,33 @@ class mail_hooks
|
|||||||
//error_log(__METHOD__.__LINE__.array2string($notified_mail_uidsCache));
|
//error_log(__METHOD__.__LINE__.array2string($notified_mail_uidsCache));
|
||||||
|
|
||||||
foreach ($folders2notify as $nFKey =>$notifyfolders)
|
foreach ($folders2notify as $nFKey =>$notifyfolders)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
$currentRecipient = (object)$GLOBALS['egw']->accounts->read(($notifyfolders['notify_account_id']?$notifyfolders['notify_account_id']:$GLOBALS['egw_info']['user']['account_id']));
|
$currentRecipient = (object)$GLOBALS['egw']->accounts->read(($notifyfolders['notify_account_id']?$notifyfolders['notify_account_id']:$GLOBALS['egw_info']['user']['account_id']));
|
||||||
//error_log(__METHOD__.__LINE__.' '.$nFKey.' =>'.array2string($notifyfolders));
|
|
||||||
$notify_folders = $notifyfolders['notify_folders'];
|
$notify_folders = $notifyfolders['notify_folders'];
|
||||||
if(count($notify_folders) == 0) {
|
if(count($notify_folders) == 0) {
|
||||||
continue; //no folders configured for notifying
|
continue; //no folders configured for notifying
|
||||||
}
|
}
|
||||||
|
//error_log(__METHOD__.__LINE__.' '.$nFKey.' =>'.array2string($notifyfolders));
|
||||||
$activeProfile = $nFKey;
|
$activeProfile = $nFKey;
|
||||||
//error_log(__METHOD__.__LINE__.' (user: '.$currentRecipient->account_lid.') Active Profile:'.$activeProfile);
|
//error_log(__METHOD__.__LINE__.' (user: '.$currentRecipient->account_lid.') Active Profile:'.$activeProfile);
|
||||||
$bomail = mail_bo::getInstance(false, $activeProfile);
|
try
|
||||||
// buffer mail sessiondata, as they are needed for information exchange by the app itself
|
{
|
||||||
//$bufferFMailSession = $bomail->sessionData;
|
$bomail = mail_bo::getInstance(false, $activeProfile,false);
|
||||||
|
} catch (Exception $e)
|
||||||
|
{
|
||||||
|
error_log(__METHOD__.__LINE__.' (user: '.$currentRecipient->account_lid.') notification for Profile:'.$activeProfile.' failed.'.$e->getMessage());
|
||||||
|
continue; //fail silently
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
error_log(__METHOD__.__LINE__.' '.$nFKey.' =>'.array2string($bomail->icServer));
|
||||||
|
if (empty($bomail->icServer->acc_imap_host))
|
||||||
|
{
|
||||||
|
error_log(__METHOD__.__LINE__.' (user: '.$currentRecipient->account_lid.') notification for Profile:'.$activeProfile.' failed: NO IMAP HOST configured!');
|
||||||
|
continue; //fail silently
|
||||||
|
}
|
||||||
|
*/
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$bomail->openConnection($activeProfile);
|
$bomail->openConnection($activeProfile);
|
||||||
@ -703,19 +719,18 @@ class mail_hooks
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//error_log(__METHOD__.__LINE__.' Found Messages for Profile'.$activeProfile.':'.array2string($recent_messages).'<->'.array2string($notified_mail_uidsCache[$activeProfile]));
|
//error_log(__METHOD__.__LINE__.' Found Messages for Profile'.$activeProfile.':'.array2string($recent_messages).'<->'.array2string($notified_mail_uidsCache[$activeProfile]));
|
||||||
// restore the mail session data, as they are needed by the app itself
|
|
||||||
if(count($recent_messages) > 0) {
|
if(count($recent_messages) > 0) {
|
||||||
// create notify message
|
// create notify message
|
||||||
$notification_subject = lang("You've got new mail").':'.$accountsToSearchArray[$activeProfile];
|
$notification_subject = lang("You've got new mail").':'.$accountsToSearchArray[$activeProfile];
|
||||||
$values = array();
|
$values = array();
|
||||||
$values[] = array(); // content array starts at index 1
|
$values[] = array(); // content array starts at index 1
|
||||||
foreach($recent_messages as $id=>$recent_message) {
|
foreach($recent_messages as $id=>$recent_message) {
|
||||||
error_log(__METHOD__.__LINE__.' Found Message for Profile '.$activeProfile.':'.array2string($recent_message));
|
//error_log(__METHOD__.__LINE__.' Found Message for Profile '.$activeProfile.':'.array2string($recent_message));
|
||||||
$values[] = array(
|
$values[] = array(
|
||||||
'mail_uid' => $recent_message['uid'],
|
'mail_uid' => $recent_message['uid'],
|
||||||
'mail_folder' => $recent_message['folder_display_name'],
|
'mail_folder' => $recent_message['folder_display_name'],
|
||||||
'mail_folder_base64' => $recent_message['folder_base64'],
|
'mail_folder_base64' => $recent_message['folder_base64'],
|
||||||
'mail_subject' => $recent_message['subject'],
|
'mail_subject' => mail_bo::adaptSubjectForImport($recent_message['subject']),
|
||||||
'mail_from' => !empty($recent_message['sender_name']) ? $recent_message['sender_name'] : $recent_message['sender_address'],
|
'mail_from' => !empty($recent_message['sender_name']) ? $recent_message['sender_name'] : $recent_message['sender_address'],
|
||||||
'mail_received' => $recent_message['date'],
|
'mail_received' => $recent_message['date'],
|
||||||
);
|
);
|
||||||
@ -737,6 +752,10 @@ class mail_hooks
|
|||||||
$notification->send();
|
$notification->send();
|
||||||
}
|
}
|
||||||
egw_cache::setCache(egw_cache::INSTANCE,'email','notified_mail_uids'.trim($GLOBALS['egw_info']['user']['account_id']),$notified_mail_uidsCache, $expiration=60*60*24*2);
|
egw_cache::setCache(egw_cache::INSTANCE,'email','notified_mail_uids'.trim($GLOBALS['egw_info']['user']['account_id']),$notified_mail_uidsCache, $expiration=60*60*24*2);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
// fail silently per server, if possible
|
||||||
|
error_log(__METHOD__.__LINE__.' Notification on new messages for Profile '.$activeProfile.' ('.$accountsToSearchArray[$activeProfile].') failed:'.$e->getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//error_log(__METHOD__.__LINE__.array2string($notified_mail_uidsCache));
|
//error_log(__METHOD__.__LINE__.array2string($notified_mail_uidsCache));
|
||||||
return true;
|
return true;
|
||||||
|
@ -763,10 +763,20 @@ class mail_ui
|
|||||||
$out = array('id' => 0);
|
$out = array('id' => 0);
|
||||||
|
|
||||||
//$starttime = microtime(true);
|
//$starttime = microtime(true);
|
||||||
foreach(emailadmin_account::search($only_current_user=true, $just_name=true) as $acc_id => $identity_name)
|
foreach(emailadmin_account::search($only_current_user=true, $just_name=false) as $acc_id => $accountObj)
|
||||||
{
|
{
|
||||||
if ($_profileID && $acc_id != $_profileID) continue;
|
if ($_profileID && $acc_id != $_profileID)
|
||||||
|
{
|
||||||
|
//error_log(__METHOD__.__LINE__.' Fetching accounts '." $acc_id != $_profileID ".'->'.$identity_name);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//error_log(__METHOD__.__LINE__.array2string($accountObj));
|
||||||
|
if (empty($accountObj->acc_imap_host))
|
||||||
|
{
|
||||||
|
// not to be used for IMAP Foldertree, as there is no Imap host
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$identity_name = emailadmin_account::identity_name($accountObj);
|
||||||
$oA = array('id' => $acc_id,
|
$oA = array('id' => $acc_id,
|
||||||
'text' => str_replace(array('<','>'),array('[',']'),$identity_name),// as angle brackets are quoted, display in Javascript messages when used is ugly, so use square brackets instead
|
'text' => str_replace(array('<','>'),array('[',']'),$identity_name),// as angle brackets are quoted, display in Javascript messages when used is ugly, so use square brackets instead
|
||||||
'tooltip' => '('.$acc_id.') '.htmlspecialchars_decode($identity_name),
|
'tooltip' => '('.$acc_id.') '.htmlspecialchars_decode($identity_name),
|
||||||
|
Loading…
Reference in New Issue
Block a user