Try to catch exceptions from none existing account

This commit is contained in:
Hadi Nategh 2013-12-05 12:32:32 +00:00
parent 0aa23fe1d3
commit fd8b4a72f6
2 changed files with 18 additions and 6 deletions

View File

@ -170,7 +170,7 @@ class mail_bo
* not matching the input profileID, if we can not find a profile matching the given ID
* @return mail_bo
*/
public static function getInstance($_restoreSession=true, $_profileID=0, $_validate=true)
public static function getInstance($_restoreSession=true, &$_profileID=0, $_validate=true)
{
//$_restoreSession=false;
//error_log(__METHOD__.__LINE__.' RestoreSession:'.$_restoreSession.' ProfileId:'.$_profileID.' called from:'.function_backtrace());
@ -261,7 +261,7 @@ class mail_bo
}
if (self::$debug) error_log(__METHOD__."($_acc_id) account NOT valid, no imap-host!");
}
catch (egw_exception_not_found $e) {
catch (Exception $e) {
unset($e);
if (self::$debug) error_log(__METHOD__."($_acc_id) account NOT found!");
}

View File

@ -119,9 +119,15 @@ class mail_hooks
$profileID = 0;
if (isset($GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID']))
$profileID = (int)$GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'];
try
{
$mail_bo = mail_bo::getInstance(true,$profileID);
$profileID = $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'] = $mail_bo->profileID;
} catch (Exception $ex) {
error_log(__METHOD__."()" . $ex->getMessage());
$profileID = null;
}
$mail_bo = mail_bo::getInstance(true,$profileID);
$profileID = $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'] = $mail_bo->profileID;
if($profileID && $mail_bo->openConnection($profileID)) {
$folderObjects = $mail_bo->getFolderObjects(true, false);
foreach($folderObjects as $folderName => $folderInfo) {
@ -732,9 +738,15 @@ class mail_hooks
$profileID = 0;
if (isset($GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID']))
$profileID = (int)$GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'];
try
{
$mail_bo = mail_bo::getInstance(true,$profileID);
$profileID = $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'] = $mail_bo->profileID;
} catch (Exception $ex) {
error_log(__METHOD__."()" . $ex->getMessage());
$profileID = null;
}
$mail_bo = mail_bo::getInstance(true,$profileID);
$profileID = $GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'] = $mail_bo->profileID;
$preferences =& $mail_bo->mailPreferences;
$serverCounter = $sieveEnabledServerCounter = 0;
if (count($preferences->ic_server)) {