From 89d945e6355f137f3352d2fd5eece9a03c2bd134 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Thu, 14 Jun 2012 10:10:52 +0000 Subject: [PATCH] * eSync/eMail: show error in eSync preferences, if non-functioning eMail profile is selected or no Trash or Sent folder --- .../inc/class.felamimail_activesync.inc.php | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/felamimail/inc/class.felamimail_activesync.inc.php b/felamimail/inc/class.felamimail_activesync.inc.php index befafc6ae9..2bf703710d 100644 --- a/felamimail/inc/class.felamimail_activesync.inc.php +++ b/felamimail/inc/class.felamimail_activesync.inc.php @@ -216,6 +216,46 @@ class felamimail_activesync implements activesync_plugin_write, activesync_plugi return $settings; } + /** + * Verify preferences + * + * @param array|string $hook_data + * @return array with error-messages from all plugins + */ + function verify_settings($hook_data) + { + $errors = array(); + + // check if an eSync eMail profile is set (might not be set as default or forced!) + if (isset($hook_data['prefs']['felamimail-ActiveSyncProfileID']) || $hook_data['type'] == 'user') + { + // eSync and eMail translations are not (yet) loaded + translation::add_app('activesync'); + translation::add_app('felamimail'); + + // inject preference to verify and call constructor + $GLOBALS['egw_info']['user']['preferences']['activesync']['felamimail-ActiveSyncProfileID'] = + $hook_data['prefs']['felamimail-ActiveSyncProfileID']; + $this->__construct($this->backend); + + try { + $this->_connect(); + $this->_disconnect(); + + if (!$this->_wasteID) $errors[] = lang('No valid %1 folder configured!', ''.lang('trash').''); + if (!$this->_sentID) $errors[] = lang('No valid %1 folder configured!', ''.lang('send').''); + } + catch(Exception $e) { + $errors[] = lang('Can not open IMAP connection').': '.$this->mail->getErrorMessage(); + } + if ($errors) + { + $errors[] = ''.lang('eSync will FAIL without a working eMail configuration!').''; + } + } + //error_log(__METHOD__.'('.array2string($hook_data).') returning '.array2string($errors)); + return $errors; + } /** * Open IMAP connection