* eMail: improvements regarding the handling of no emailprofile available

This commit is contained in:
Klaus Leithoff 2010-11-30 14:22:49 +00:00
parent c676cf3cc3
commit b33ace9bba
5 changed files with 163 additions and 104 deletions

View File

@ -85,8 +85,9 @@
}
}
function bofelamimail($_displayCharset='iso-8859-1',$_restoreSession=true)
function bofelamimail($_displayCharset='iso-8859-1',$_restoreSession=true, $_profileID=0)
{
$this->profileID = $_profileID;
if ($_restoreSession)
{
//error_log(__METHOD__." Session restore ".function_backtrace());
@ -112,8 +113,8 @@
$this->mailPreferences = $this->bopreferences->getPreferences();
if ($this->mailPreferences) {
$this->icServer = $this->mailPreferences->getIncomingServer(0);
$this->ogServer = $this->mailPreferences->getOutgoingServer(0);
$this->icServer = $this->mailPreferences->getIncomingServer($this->profileID);
$this->ogServer = $this->mailPreferences->getOutgoingServer($this->profileID);
$this->htmlOptions = $this->mailPreferences->preferences['htmlOptions'];
}
#_debug_array($this->mailPreferences->preferences);
@ -129,6 +130,8 @@
{
// this should be under user preferences
// sessionData empty
// store active profileID
$this->sessionData['profileID'] = $_profileID;
// no filter active
$this->sessionData['activeFilter'] = "-1";
// default mailbox INBOX
@ -220,7 +223,7 @@
* this function is a wrapper function for emailadmin
*
* @param _hookValues contains the hook values as array
* @returns nothing
* @return nothing
*/
function addAccount($_hookValues)
{
@ -268,7 +271,7 @@
* @param string _body the body of the message
* @param string _flags the imap flags to set for the saved message
*
* @returns the id of the message appended or false
* @return the id of the message appended or false
*/
function appendMessage($_folderName, $_header, $_body, $_flags)
{
@ -291,7 +294,7 @@
* remove any messages from the trashfolder
*
* @param string _folderName the foldername
* @returns nothing
* @return nothing
*/
function compressFolder($_folderName = false)
{
@ -316,7 +319,7 @@
* @param string _folderName the new foldername
* @param bool _subscribe subscribe to the new folder
*
* @returns mixed name of the newly created folder or false on error
* @return mixed name of the newly created folder or false on error
*/
function createFolder($_parent, $_folderName, $_subscribe=false)
{
@ -412,7 +415,7 @@
*
* @param string _folderName the foldername
*
* @returns string the converted foldername
* @return string the converted foldername
*/
function decodeFolderName($_folderName)
{
@ -444,7 +447,7 @@
* decode header (or envelope information
* if array given, note that only values will be converted
* @param $_string mixed input to be converted, if array call decode_header recursively on each value
* @returns mixed - based on the input type
* @return mixed - based on the input type
*/
static function decode_header($_string)
{
@ -552,7 +555,7 @@
*
* @param string _folderName the name of the folder to be deleted
*
* @returns bool true on success, false on failure
* @return bool true on success, false on failure
*/
function deleteFolder($_folderName)
{
@ -657,7 +660,7 @@
*
* @param string _folderName the foldername
*
* @returns string the converted string
* @return string the converted string
*/
function encodeFolderName($_folderName)
{
@ -1137,7 +1140,7 @@
* @param string _partID the id of the part, which holds the attachment
* @param int _winmail_nr winmail.dat attachment nr.
*
* @returns array
* @return array
*/
function getAttachment($_uid, $_partID, $_winmail_nr=0)
{
@ -1255,6 +1258,34 @@
return $attachmentData;
}
/**
* getIdentitiesWithAccounts
*
* @param array reference to pass all identities back
* @return the default Identity (active) or 0
*/
function getIdentitiesWithAccounts(&$identities)
{
// account select box
$selectedID = 0;
if($this->mailPreferences->userDefinedAccounts) $allAccountData = $this->bopreferences->getAllAccountData($this->mailPreferences);
if ($allAccountData) {
foreach ($allAccountData as $tmpkey => $accountData)
{
$identity =& $accountData['identity'];
$icServer =& $accountData['icServer'];
//_debug_array($identity);
//_debug_array($icServer);
if (empty($icServer->host)) continue;
$identities[$identity->id]=$identity->realName.' '.$identity->organization.' <'.$identity->emailAddress.'>';
if (!empty($identity->default)) $selectedID = $identity->id;
}
}
return $selectedID;
}
function getEMailProfile()
{
$config = CreateObject('phpgwapi.config','felamimail');
@ -1282,7 +1313,7 @@
*
* @param _folderName string the foldername
*
* @returns array
* @return array
*/
function getFolderStatus($_folderName)
{
@ -1355,7 +1386,7 @@
* @param _subscribedOnly boolean get subscribed or all folders
* @param _getCounters boolean get get messages counters
*
* @returns array with folder objects. eg.: INBOX => {inbox object}
* @return array with folder objects. eg.: INBOX => {inbox object}
*/
function getFolderObjects($_subscribedOnly=false, $_getCounters=false)
{
@ -1698,8 +1729,8 @@
/**
* getMimePartCharset - fetches the charset mimepart if it exists
* @params $_mimePartObject structure object
* @returns mixed mimepart or false if no CHARSET is found, the missing charset has to be handled somewhere else,
* @param $_mimePartObject structure object
* @return mixed mimepart or false if no CHARSET is found, the missing charset has to be handled somewhere else,
* as we cannot safely assume any charset as we did earlier
*/
function getMimePartCharset($_mimePartObject)
@ -2547,7 +2578,7 @@
/**
* normalizeBodyParts - function to gather and normalize all body Information
* @param _bodyParts - Body Array
* @returns array - a normalized Bodyarray
* @return array - a normalized Bodyarray
*/
static function normalizeBodyParts($_bodyParts)
{
@ -2803,7 +2834,7 @@
* @param string _parent the parent foldername
* @param string _folderName the new foldername
*
* @returns mixed name of the newly created folder or false on error
* @return mixed name of the newly created folder or false on error
*/
function renameFolder($_oldFolderName, $_parent, $_folderName)
{
@ -2987,7 +3018,7 @@
* convert the foldername from display charset to UTF-7
*
* @param string _parent the parent foldername
* @returns ISO-8859-1 / UTF7-IMAP encoded string
* @return ISO-8859-1 / UTF7-IMAP encoded string
*/
function _encodeFolderName($_folderName) {
return $GLOBALS['egw']->translation->convert($_folderName, self::$displayCharset, 'ISO-8859-1');
@ -2998,7 +3029,7 @@
* convert the foldername from UTF-7 to display charset
*
* @param string _parent the parent foldername
* @returns ISO-8859-1 / self::$displayCharset encoded string
* @return ISO-8859-1 / self::$displayCharset encoded string
*/
function _decodeFolderName($_folderName) {
return $GLOBALS['egw']->translation->convert($_folderName, self::$displayCharset, 'ISO-8859-1');
@ -3009,7 +3040,7 @@
* convert the sort value from the gui(integer) into a string
*
* @param int _sort the integer sort order
* @returns the ascii sort string
* @return the ascii sort string
*/
function _getSortString($_sort)
{
@ -3207,7 +3238,7 @@
* detect_encoding - try to detect the encoding
* only to be used if the string in question has no structure that determines his encoding
* @param string - to be evaluated
* @returns mixed string/boolean (encoding or false
* @return mixed string/boolean (encoding or false
*/
static function detect_encoding($string) {
static $list = array('utf-8', 'iso-8859-1', 'windows-1251'); // list may be extended
@ -3382,7 +3413,7 @@
* @param uid the uid of the email to be processed
* @param partid the partid of the email
* @param mailbox the mailbox, that holds the message
* @returns array with 'mailaddress'=>$mailaddress,
* @return array with 'mailaddress'=>$mailaddress,
* 'subject'=>$subject,
* 'message'=>$message,
* 'attachments'=>$attachments,
@ -3469,8 +3500,8 @@
/**
* createHeaderInfoSection - creates a textual headersection from headerobject
* @params header headerarray may contain SUBJECT,FROM,SENDER,TO,CC,BCC,DATE,PRIORITY,IMPORTANCE
* @returns string a preformatted string with the information of the header worked into it
* @param header headerarray may contain SUBJECT,FROM,SENDER,TO,CC,BCC,DATE,PRIORITY,IMPORTANCE
* @return string a preformatted string with the information of the header worked into it
*/
static function createHeaderInfoSection($header,$headline='')
{
@ -3501,8 +3532,8 @@
/**
* getdisplayableBody - creates the bodypart of the email as textual representation
* @param bofelamimail the bofelamimailobject to be used
* @params bodyPorts array with the bodyparts
* @returns string a preformatted string with the mails converted to text
* @param bodyPorts array with the bodyparts
* @return string a preformatted string with the mails converted to text
*/
static function &getdisplayableBody(&$bofelamimail, $bodyParts)
{

View File

@ -477,11 +477,13 @@ class felamimail_hooks
$menu_title = $GLOBALS['egw_info']['apps'][$appname]['title'] . ' '. lang('Menu');
$file = array();
$bofelamimail =& CreateObject('felamimail.bofelamimail',$GLOBALS['egw']->translation->charset());
$preferences = $bofelamimail->mailPreferences;
$preferences =& $bofelamimail->mailPreferences;
$showMainScreenStuff = false;
//error_log(__METHOD__.__LINE__.$_GET['menuaction']);
if(($_GET['menuaction'] == 'felamimail.uifelamimail.viewMainScreen' ||
$_GET['menuaction'] == 'felamimail.uifelamimail.changeFolder' ||
stripos($_GET['menuaction'],'ajax_sidebox') !== false) &&
$_GET['menuaction'] != 'felamimail.uipreferences.editAccountData' &&
$_GET['menuaction'] != 'felamimail.uifelamimail.redirectToPreferences' &&
$_GET['menuaction'] != 'felamimail.uifelamimail.redirectToEmailadmin') {
/* seems to be, its not needed here, as viewMainScreen does it anyway
@ -593,43 +595,26 @@ class felamimail_hooks
'no_lang' => true,
);
*/
// select account box, treeview
if($showMainScreenStuff) {
// select account box, treeview, we use a whileloop as we may want to break out
while($showMainScreenStuff) {
$bofelamimail->restoreSessionData();
$mailbox = $bofelamimail->sessionData['mailbox'];;
//_debug_array($mailbox);
$icServerID = 0;
$icServerID = $bofelamimail->profileID;
if (is_object($preferences))
{
// gather profile data
$imapServer =& $preferences->getIncomingServer($icServerID);
$imapServer =& $bofelamimail->icServer;
// account select box
$selectedID = 0;
if($preferences->userDefinedAccounts) $allAccountData = $bofelamimail->bopreferences->getAllAccountData($preferences);
if ($allAccountData) {
foreach ($allAccountData as $tmpkey => $accountData)
{
$identity =& $accountData['identity'];
$icServer =& $accountData['icServer'];
//_debug_array($identity);
//_debug_array($icServer);
if (empty($icServer->host)) continue;
$identities[$identity->id]=$identity->realName.' '.$identity->organization.' <'.$identity->emailAddress.'>';
if (!empty($identity->default)) $selectedID = $identity->id;
}
}
$selectedID = $bofelamimail->getIdentitiesWithAccounts($identities);
// if nothing valid is found return to user defined account definition
// todo klaus: can you move this redirect out of the sidebox on felamimail/index.php
if (empty($imapServer->host) && count($identities)==0 && $preferences->userDefinedAccounts)
{
// redirect to new personal account
egw::redirect_link('/index.php',array('menuaction'=>'felamimail.uipreferences.editAccountData',
'accountID'=>"new",
'msg' => lang("There is no IMAP Server configured.")." - ".lang("Please configure access to an existing individual IMAP account."),
));
$showMainScreenStuff= false;
break;
}
$activeIdentity =& $preferences->getIdentity($icServerID);
if ($imapServer->_connected != 1) $connectionStatus = $bofelamimail->openConnection($icServerID);
$folderObjects = $bofelamimail->getFolderObjects(true, false);
@ -685,6 +670,7 @@ class felamimail_hooks
'icon' => False,
);
}
break; // kill the while loop as we need only one go
}
// display them all
display_sidebox($appname,$menu_title,$file);

View File

@ -57,8 +57,22 @@
$this->bofilter = CreateObject('felamimail.bofilter',false);
$this->bopreferences =& $this->bofelamimail->bopreferences; //CreateObject('felamimail.bopreferences');
$this->preferences = $this->bopreferences->getPreferences();
$this->preferences =& $this->bofelamimail->mailPreferences;
if (is_object($this->preferences))
{
// account select box
$selectedID = $this->bofelamimail->getIdentitiesWithAccounts($identities);
// if nothing valid is found return to user defined account definition
if (empty($this->bofelamimail->icServer->host) && count($identities)==0 && $this->preferences->userDefinedAccounts)
{
// redirect to new personal account
egw::redirect_link('/index.php',array('menuaction'=>'felamimail.uipreferences.editAccountData',
'accountID'=>"new",
'msg' => lang("There is no IMAP Server configured.")." - ".lang("Please configure access to an existing individual IMAP account."),
));
}
}
$this->bofelamimail->saveSessionData();
$this->mailbox = $this->bofelamimail->sessionData['mailbox'];

View File

@ -1,20 +1,21 @@
<?php
/***************************************************************************\
* eGroupWare - FeLaMiMail *
* http://www.linux-at-work.de *
* http://www.phpgw.de *
* http://www.egroupware.org *
* Written by : Lars Kneschke [lkneschke@linux-at-work.de] *
* ------------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\***************************************************************************/
/**
* EGroupware - FeLaMiMail - preference user interface
*
* @link http://www.egroupware.org
* @package felamimail
* @author Lars Kneschke [lkneschke@linux-at-work.de]
* @author Klaus Leithoff [kl@stylite.de]
* @copyright (c) 2009-10 by Klaus Leithoff <kl-AT-stylite.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
/* $Id$ */
require_once(EGW_INCLUDE_ROOT.'/felamimail/inc/class.felamimail_bosignatures.inc.php');
/**
* FeLaMiMail preference user interface class, provides UI functionality for preferences/actions like
* managing folders, acls, signatures, rules
*/
require_once(EGW_INCLUDE_ROOT.'/felamimail/inc/class.felamimail_bosignatures.inc.php');
class uipreferences
{
@ -37,13 +38,26 @@
{
$this->t = $GLOBALS['egw']->template;
$this->charset = $GLOBALS['egw']->translation->charset();
$this->bofelamimail = CreateObject('felamimail.bofelamimail',$GLOBALS['egw']->translation->charset());
$this->bopreferences = $this->bofelamimail->bopreferences; //CreateObject('felamimail.bopreferences');
$this->bopreferences =& $this->bofelamimail->bopreferences; //CreateObject('felamimail.bopreferences');
$this->uiwidgets = CreateObject('felamimail.uiwidgets');
if (is_object($this->bofelamimail->mailPreferences))
{
// account select box
$selectedID = $this->bofelamimail->getIdentitiesWithAccounts($identities);
// if nothing valid is found return to user defined account definition
if (empty($this->bofelamimail->icServer->host) && count($identities)==0 && $this->bofelamimail->mailPreferences->userDefinedAccounts)
{
// redirect to new personal account
$this->editAccountData(lang("There is no IMAP Server configured.")." - ".lang("Please configure access to an existing individual IMAP account."), 'new');
exit;
}
}
$this->bofelamimail->openConnection();
$this->rowColor[0] = $GLOBALS['egw_info']["theme"]["bg01"];
$this->rowColor[1] = $GLOBALS['egw_info']["theme"]["bg02"];
}
@ -68,30 +82,30 @@
switch($_GET['menuaction'])
{
case 'felamimail.uipreferences.editSignature':
$GLOBALS['egw']->js->validate_file('jscode','listSignatures','felamimail');
egw_framework::validate_file('jscode','listSignatures','felamimail');
egw_framework::validate_file('ckeditor3','ckeditor','phpgwapi');
#$GLOBALS['egw']->js->set_onload('fm_initEditLayout();');
break;
case 'felamimail.uipreferences.listAccountData':
case 'felamimail.uipreferences.editAccountData':
$GLOBALS['egw']->js->validate_file('tabs','tabs');
$GLOBALS['egw']->js->validate_file('jscode','editAccountData','felamimail');
egw_framework::validate_file('tabs','tabs');
egw_framework::validate_file('jscode','editAccountData','felamimail');
$GLOBALS['egw']->js->set_onload('javascript:initEditAccountData();');
$GLOBALS['egw']->js->set_onload('javascript:initTabs();');
break;
case 'felamimail.uipreferences.listSignatures':
$GLOBALS['egw']->js->validate_file('jscode','listSignatures','felamimail');
egw_framework::validate_file('jscode','listSignatures','felamimail');
#$GLOBALS['egw']->js->set_onload('javascript:initEditAccountData();');
break;
case 'felamimail.uipreferences.listFolder':
case 'felamimail.uipreferences.addACL':
case 'felamimail.uipreferences.listSelectFolder':
$GLOBALS['egw']->js->validate_file('tabs','tabs');
$GLOBALS['egw']->js->validate_file('dhtmlxtree','js/dhtmlXCommon');
$GLOBALS['egw']->js->validate_file('dhtmlxtree','js/dhtmlXTree');
$GLOBALS['egw']->js->validate_file('jscode','listFolder','felamimail');
egw_framework::validate_file('tabs','tabs');
egw_framework::validate_file('dhtmlxtree','js/dhtmlXCommon');
egw_framework::validate_file('dhtmlxtree','js/dhtmlXTree');
egw_framework::validate_file('jscode','listFolder','felamimail');
$GLOBALS['egw']->js->set_onload('javascript:initAll();');
break;
}
@ -100,7 +114,7 @@
$GLOBALS['egw']->common->egw_header();
if($_displayNavbar == TRUE)
echo parse_navbar();
echo $GLOBALS['egw']->framework->navbar();
}
function editForwardingAddress()
@ -175,7 +189,7 @@
$this->t->set_var('tinymce',html::fckEditorQuick(
'signature', 'advanced',
$signatureData->fm_signature,
$height)
$height,'100%',false)
);
$this->t->set_var('checkbox_isDefaultSignature',html::checkbox(
@ -187,7 +201,7 @@
);
} else {
$this->t->set_var('description','');
$this->t->set_var('tinymce',html::fckEditorQuick('signature', 'advanced', '', $height));
$this->t->set_var('tinymce',html::fckEditorQuick('signature', 'advanced', '', $height,'100%',false));
$this->t->set_var('checkbox_isDefaultSignature',html::checkbox(
'isDefaultSignature', false, 'true', 'id="isDefaultSignature"'
@ -198,7 +212,7 @@
$this->t->pparse("out","main");
}
function editAccountData($msg='')
function editAccountData($msg='', $account2retrieve='active')
{
if ($_GET['msg']) $msg = html::purify($_GET['msg']);
if (!isset($this->bofelamimail)) $this->bofelamimail = CreateObject('felamimail.bofelamimail',$GLOBALS['egw']->translation->charset());
@ -276,7 +290,7 @@
if($this->bofelamimail->openConnection()) {
$folderObjects = $this->bofelamimail->getFolderObjects();
foreach($folderObjects as $folderName => $folderInfo) {
#_debug_array($folderData);
//_debug_array($folderInfo);
$folderList[$folderName] = $folderInfo->displayName;
}
$this->bofelamimail->closeConnection();
@ -290,7 +304,6 @@
$this->translate();
// if there is no accountID with the call of the edit method, retrieve an active account
$account2retrieve = 'active';
if ((int)$_GET['accountID']) {
$account2retrieve = $_GET['accountID'];
}

View File

@ -61,16 +61,31 @@
$this->displayCharset = $GLOBALS['egw']->translation->charset();
$this->t =& CreateObject('phpgwapi.Template',EGW_APP_TPL);
$this->botranslation = $GLOBALS['egw']->translation;
$this->botranslation =& $GLOBALS['egw']->translation;
$this->bopreferences =& CreateObject('felamimail.bopreferences');
$this->mailPreferences = $this->bopreferences->getPreferences();
$this->bofelamimail = CreateObject('felamimail.bofelamimail',$GLOBALS['egw']->translation->charset());
if (is_object($this->bofelamimail->mailPreferences))
{
// account select box
$selectedID = $this->bofelamimail->getIdentitiesWithAccounts($identities);
// if nothing valid is found return to user defined account definition
if (empty($this->bofelamimail->icServer->host) && count($identities)==0 && $this->bofelamimail->mailPreferences->userDefinedAccounts)
{
// redirect to new personal account
egw::redirect_link('/index.php',array('menuaction'=>'felamimail.uipreferences.editAccountData',
'accountID'=>"new",
'msg' => lang("There is no IMAP Server configured.")." - ".lang("Please configure access to an existing individual IMAP account."),
));
}
}
$this->mailPreferences =& $this->bofelamimail->mailPreferences;
$this->felamimailConfig = config::read('felamimail');
$this->restoreSessionData();
$icServer = $this->mailPreferences->getIncomingServer(0);
$icServer = $this->bofelamimail->icServer;
if(is_a($icServer,'defaultimap') && $icServer->enableSieve) {
$this->bosieve = $icServer;
@ -320,9 +335,9 @@
else
$editMode = 'filter';
$GLOBALS['egw']->js->validate_file('tabs','tabs');
$GLOBALS['egw']->js->validate_file('jscode','editProfile','felamimail');
$GLOBALS['egw']->js->validate_file('jscode','listSieveRules','felamimail');
egw_framework::validate_file('tabs','tabs');
egw_framework::validate_file('jscode','editProfile','felamimail');
egw_framework::validate_file('jscode','listSieveRules','felamimail');
$GLOBALS['egw']->js->set_onload("javascript:initAll('$editMode');");
if($_GET['menuaction'] == 'felamimail.uisieve.editRule') {
$GLOBALS['egw']->js->set_onunload('opener.fm_sieve_cancelReload();');
@ -334,13 +349,13 @@
case 'felamimail.uisieve.editRule':
break;
default:
echo parse_navbar();
echo $GLOBALS['egw']->framework->navbar();
break;
}
}
function displayRule($_ruleID, $_ruleData, $msg='') {
$preferences = $this->mailPreferences;
$preferences =& $this->mailPreferences;
// display the header
$this->display_app_header();
$msg = html::purify($msg);
@ -414,7 +429,7 @@
function editRule()
{
$preferences = $this->mailPreferences;
$preferences =& $this->mailPreferences;
$msg = '';
$error = 0;
$this->getRules(); /* ADDED BY GHORTH */
@ -519,7 +534,7 @@
}
function editVacation() {
$preferences = $this->mailPreferences;
$preferences =& $this->mailPreferences;
if(!(empty($preferences->preferences['prefpreventabsentnotice']) || $preferences->preferences['prefpreventabsentnotice'] == 0))
{
die('You should not be here!');
@ -698,7 +713,7 @@
}
function editEmailNotification() {
$preferences = ExecMethod('felamimail.bopreferences.getPreferences');
$preferences =& $this->mailPreferences;
if(!(empty($preferences->preferences['prefpreventnotificationformailviaemail']) || $preferences->preferences['prefpreventnotificationformailviaemail'] == 0))
die('You should not be here!');
@ -785,7 +800,7 @@
function listRules()
{
$preferences = ExecMethod('felamimail.bopreferences.getPreferences');
$preferences =& $this->mailPreferences;
if(!(empty($preferences->preferences['prefpreventeditfilterrules']) || $preferences->preferences['prefpreventeditfilterrules'] == 0))
die('You should not be here!');
@ -911,12 +926,12 @@
function selectFolder()
{
$GLOBALS['egw']->js->validate_file('dhtmlxtree','js/dhtmlXCommon');
$GLOBALS['egw']->js->validate_file('dhtmlxtree','js/dhtmlXTree');
$GLOBALS['egw']->js->validate_file('jscode','editSieveRule','felamimail');
egw_framework::validate_file('dhtmlxtree','js/dhtmlXCommon');
egw_framework::validate_file('dhtmlxtree','js/dhtmlXTree');
egw_framework::validate_file('jscode','editSieveRule','felamimail');
$GLOBALS['egw']->common->egw_header();
$bofelamimail =& CreateObject('felamimail.bofelamimail',$this->displayCharset);
$bofelamimail =& $this->bofelamimail;
$uiwidgets =& CreateObject('felamimail.uiwidgets');
$connectionStatus = $bofelamimail->openConnection();