mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-02-06 21:40:37 +01:00
handle connection errors by opening wizard and show a fake folder with error message (to not get error from tree and unlock tree again)
This commit is contained in:
parent
e8e3de984a
commit
3d5a2ffc3b
@ -163,9 +163,9 @@ class mail_ui
|
|||||||
*
|
*
|
||||||
* @param string $message
|
* @param string $message
|
||||||
*/
|
*/
|
||||||
static function callWizard($message)
|
static function callWizard($message, $exit=true)
|
||||||
{
|
{
|
||||||
$response = egw_json_response::get();
|
error_log(__METHOD__."('$message', $exit) ".function_backtrace());
|
||||||
$linkData=(self::$icServerID ? array(
|
$linkData=(self::$icServerID ? array(
|
||||||
'menuaction' => 'mail.mail_wizard.edit',
|
'menuaction' => 'mail.mail_wizard.edit',
|
||||||
'acc_id' => self::$icServerID,
|
'acc_id' => self::$icServerID,
|
||||||
@ -174,8 +174,23 @@ class mail_ui
|
|||||||
)) + array(
|
)) + array(
|
||||||
'msg' => $message//.' ('.get_class($e).': '.$e->getCode().')',
|
'msg' => $message//.' ('.get_class($e).': '.$e->getCode().')',
|
||||||
);
|
);
|
||||||
$windowName = "editMailAccount".self::$icServerID;
|
|
||||||
$response->call("egw.open_link",egw::link('/index.php',$linkData,$windowName,"600x480"));
|
if (egw_json_response::isJSONResponse())
|
||||||
|
{
|
||||||
|
$response = egw_json_response::get();
|
||||||
|
$windowName = "editMailAccount".self::$icServerID;
|
||||||
|
$response->call("egw.open_link", egw::link('/index.php', $linkData), $windowName, "600x480");
|
||||||
|
egw_framework::message($message, 'error');
|
||||||
|
if ($exit)
|
||||||
|
{
|
||||||
|
$GLOBALS['egw']->framework->render($message);
|
||||||
|
common::egw_exit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else // regular GET request eg. in idots template
|
||||||
|
{
|
||||||
|
egw_framework::redirect_link('/index.php', $linkData);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -199,12 +214,12 @@ class mail_ui
|
|||||||
/*if (!($this->mail_bo->icServer->_connected == 1))*/
|
/*if (!($this->mail_bo->icServer->_connected == 1))*/
|
||||||
// save session varchar
|
// save session varchar
|
||||||
$oldicServerID =& egw_cache::getSession('mail','activeProfileID');
|
$oldicServerID =& egw_cache::getSession('mail','activeProfileID');
|
||||||
|
if ($oldicServerID <> self::$icServerID) $this->mail_bo->openConnection(self::$icServerID);
|
||||||
|
$oldicServerID = self::$icServerID;
|
||||||
if (!emailadmin_imapbase::storeActiveProfileIDToPref($this->mail_bo->icServer, self::$icServerID, true ))
|
if (!emailadmin_imapbase::storeActiveProfileIDToPref($this->mail_bo->icServer, self::$icServerID, true ))
|
||||||
{
|
{
|
||||||
throw new egw_exception(__METHOD__." failed to change Profile to $_icServerID");
|
throw new egw_exception(__METHOD__." failed to change Profile to $_icServerID");
|
||||||
}
|
}
|
||||||
if ($oldicServerID <> self::$icServerID) $this->mail_bo->openConnection(self::$icServerID);
|
|
||||||
$oldicServerID = self::$icServerID;
|
|
||||||
//$GLOBALS['egw']->preferences->add('mail','ActiveProfileID',self::$icServerID,'user');
|
//$GLOBALS['egw']->preferences->add('mail','ActiveProfileID',self::$icServerID,'user');
|
||||||
//$GLOBALS['egw']->preferences->save_repository(true);
|
//$GLOBALS['egw']->preferences->save_repository(true);
|
||||||
//$GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'] = self::$icServerID;
|
//$GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'] = self::$icServerID;
|
||||||
@ -801,7 +816,7 @@ class mail_ui
|
|||||||
'parent' => ''
|
'parent' => ''
|
||||||
);
|
);
|
||||||
|
|
||||||
self::callWizard($e->getMessage());
|
//self::callWizard($e->getMessage(), false);
|
||||||
|
|
||||||
$this->setOutStructure($oA, $out, self::$delimiter);
|
$this->setOutStructure($oA, $out, self::$delimiter);
|
||||||
if (!is_null($_nodeID) && $_nodeID !=0 && $_returnNodeOnly==true)
|
if (!is_null($_nodeID) && $_nodeID !=0 && $_returnNodeOnly==true)
|
||||||
@ -817,6 +832,7 @@ class mail_ui
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//$starttime = microtime(true);
|
//$starttime = microtime(true);
|
||||||
|
$c = 0;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$folderObjects = $this->mail_bo->getFolderObjects($_subscribedOnly,false,false,$_useCacheIfPossible);
|
$folderObjects = $this->mail_bo->getFolderObjects($_subscribedOnly,false,false,$_useCacheIfPossible);
|
||||||
@ -834,8 +850,10 @@ class mail_ui
|
|||||||
}
|
}
|
||||||
catch (Exception $e)
|
catch (Exception $e)
|
||||||
{
|
{
|
||||||
|
error_log(__LINE__.': '.__METHOD__."() ".$e->getMessage());
|
||||||
$folderObjects=array();
|
$folderObjects=array();
|
||||||
self::callWizard($e->getMessage());
|
// self::callWizard($e->getMessage(), false);
|
||||||
|
$c = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$out = array('id' => 0);
|
$out = array('id' => 0);
|
||||||
@ -862,16 +880,31 @@ class mail_ui
|
|||||||
'im1' => 'thunderbird.png',
|
'im1' => 'thunderbird.png',
|
||||||
'im2' => 'thunderbird.png',
|
'im2' => 'thunderbird.png',
|
||||||
'path'=> array($acc_id),
|
'path'=> array($acc_id),
|
||||||
'child'=> 1, // dynamic loading on unfold
|
'child'=> (int)($acc_id != $_profileID || $folderObjects), // dynamic loading on unfold
|
||||||
'parent' => ''
|
'parent' => ''
|
||||||
);
|
);
|
||||||
$this->setOutStructure($oA, $out, self::$delimiter);
|
$this->setOutStructure($oA, $out, self::$delimiter);
|
||||||
|
|
||||||
|
// create a fake INBOX folder showing connection error (necessary that client UI unlocks tree!)
|
||||||
|
if ($e && $acc_id == $_profileID && !$folderObjects)
|
||||||
|
{
|
||||||
|
$oA = array(
|
||||||
|
'id' => $acc_id.self::$delimiter.'INBOX',
|
||||||
|
'text' => lang($e->getMessage()),
|
||||||
|
'tooltip' => '('.$acc_id.') '.$e->getMessage(),
|
||||||
|
'im0' => "folderNoSelectClosed.gif",
|
||||||
|
'im1' => "folderNoSelectOpen.gif",
|
||||||
|
'im2' => "folderNoSelectClosed.gif",
|
||||||
|
'path'=> array($acc_id, 'INBOX'),
|
||||||
|
'parent' => $acc_id,
|
||||||
|
);
|
||||||
|
$this->setOutStructure($oA, $out, self::$delimiter);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//$endtime = microtime(true) - $starttime;
|
//$endtime = microtime(true) - $starttime;
|
||||||
//error_log(__METHOD__.__LINE__.' Fetching accounts took: '.$endtime);
|
//error_log(__METHOD__.__LINE__.' Fetching accounts took: '.$endtime);
|
||||||
//error_log(__METHOD__.__LINE__.array2string($oA));
|
//error_log(__METHOD__.__LINE__.array2string($oA));
|
||||||
//error_log(__METHOD__.__LINE__.array2string($folderObjects));
|
//error_log(__METHOD__.__LINE__.array2string($folderObjects));
|
||||||
$c = 0;
|
|
||||||
if (!empty($folderObjects))
|
if (!empty($folderObjects))
|
||||||
{
|
{
|
||||||
$delimiter = $this->mail_bo->getHierarchyDelimiter();
|
$delimiter = $this->mail_bo->getHierarchyDelimiter();
|
||||||
@ -1569,7 +1602,7 @@ unset($query['actions']);
|
|||||||
{
|
{
|
||||||
$sortResultwH=array();
|
$sortResultwH=array();
|
||||||
$sR=array();
|
$sR=array();
|
||||||
self::callWizard($e->getMessage());
|
self::callWizard($e->getMessage(), false);
|
||||||
}
|
}
|
||||||
if (is_array($sR) && count($sR)>0)
|
if (is_array($sR) && count($sR)>0)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user