work to get the sieve stuff back on the road. NOTE: uses oldImapServer Object, not cached, no validation regarding getInstance

This commit is contained in:
Klaus Leithoff 2013-12-17 09:55:47 +00:00
parent 19f19f940f
commit d82075e86b
3 changed files with 76 additions and 72 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, $_oldImapServerObject=false)
{
//$_restoreSession=false;
//error_log(__METHOD__.__LINE__.' RestoreSession:'.$_restoreSession.' ProfileId:'.$_profileID.' called from:'.function_backtrace());
@ -188,6 +188,11 @@ class mail_bo
$_profileID=$profileID;
if (self::$debug) error_log(__METHOD__.__LINE__.' called with profileID==0 using '.$profileID.' instead->'.function_backtrace());
}
// no validation or restoreSession for old ImapServer Object, just fetch it and return it
if ($_oldImapServerObject===true)
{
return new mail_bo('utf-8',false,$_profileID,true);
}
if ($_profileID != 0 && $_validate)
{
$profileID = self::validateProfileID($_profileID);
@ -287,8 +292,9 @@ class mail_bo
* @param string $_displayCharset='utf-8'
* @param boolean $_restoreSession=true
* @param int $_profileID=0
* @param boolean $_oldImapServerObject=false
*/
private function __construct($_displayCharset='utf-8',$_restoreSession=true, $_profileID=0)
private function __construct($_displayCharset='utf-8',$_restoreSession=true, $_profileID=0, $_oldImapServerObject=false)
{
if (!empty($_displayCharset)) self::$displayCharset = $_displayCharset;
if ($_restoreSession)
@ -312,7 +318,7 @@ class mail_bo
//error_log(__METHOD__.__LINE__." ProfileID ".$this->profileID.' called from:'.function_backtrace());
$acc = emailadmin_account::read($this->profileID);
//error_log(__METHOD__.__LINE__.array2string($acc->imapServer()));
$this->icServer = $acc->imapServer();
$this->icServer = ($_oldImapServerObject?$acc->oldImapServer():$acc->imapServer());
$this->ogServer = $acc->smtpServer();
// TODO: merge mailprefs into userprefs, for easy treatment
$this->mailPreferences = $GLOBALS['egw_info']['user']['preferences']['mail'];
@ -482,6 +488,59 @@ class mail_bo
return $rv;
}
/**
* getUserEMailAddresses - function to gather the emailadresses connected to the current mail-account
* @return array - array(email=>realname)
*/
function getUserEMailAddresses() {
$acc = emailadmin_account::read($this->profileID);
$identities = $acc->identities();
$userEMailAdresses = array();
foreach($identities as $ik => $ident) {
//error_log(__METHOD__.__LINE__.':'.$ik.'->'.array2string($ident));
$identity = emailadmin_account::read_identity($ik);
$userEMailAdresses[$identity['ident_email']] = $identity['ident_realname'];
}
//error_log(__METHOD__.__LINE__.array2string($userEMailAdresses));
return $userEMailAdresses;
}
/**
* getAllIdentities - function to gather the identities connected to the current user
* @return array - array(email=>realname)
*/
function getAllIdentities() {
$acc = emailadmin_account::read($this->profileID);
$identities = $acc->identities('all');
$userEMailAdresses = array();
foreach($identities as $ik => $ident) {
//error_log(__METHOD__.__LINE__.':'.$ik.'->'.array2string($ident));
$identity = emailadmin_account::read_identity($ik);
$userEMailAdresses[$identity['ident_id']] = array('ident_id'=>$identity['ident_id'],'ident_email'=>$identity['ident_email'],'ident_org'=>$identity['ident_org'],'ident_realname'=>$identity['ident_realname'],'ident_signature'=>$identity['ident_signature']);
}
//error_log(__METHOD__.__LINE__.array2string($userEMailAdresses));
return $userEMailAdresses;
}
/**
* getDefaultIdentity - function to gather the default identitiy connected to the current mailaccount
* @return int - id of the identity
*/
function getDefaultIdentity() {
// retrieve the signature accociated with the identity
$id = $this->getIdentitiesWithAccounts($_accountData);
$acc = emailadmin_account::read($this->profileID);
$accountDataIT = ($_accountData[$this->profileID]?$acc->identities($this->profileID,true,'ident_id'):$acc->identities($_accountData[$id],true,'ident_id'));
foreach($accountDataIT as $it => $accountData)
{
return $accountData['ident_id'];
}
}
/**
* getIdentitiesWithAccounts
*

View File

@ -504,7 +504,7 @@ class mail_compose
}
else
{
$newSig = $this->getDefaultIdentity();
$newSig = $this->mail_bo->getDefaultIdentity();
if ($newSig === false) $newSig = -2;
}
}
@ -949,7 +949,7 @@ class mail_compose
*/
// prepare signatures, the selected sig may be used on top of the body
//identities and signature stuff
$allIdentities = $this->getAllIdentities();
$allIdentities = $this->mail_bo->getAllIdentities();
$acc = emailadmin_account::read($this->mail_bo->profileID);
$selectSignatures = array(
'-2' => lang('no signature')
@ -1362,10 +1362,6 @@ class mail_compose
$mail_bo->openConnection();
$mail_bo->reopen($_folder);
// the array $userEMailAddresses was used for filtering out emailaddresses that are owned by the user, for draft data we should not do this
//$userEMailAddresses = $this->preferences->getUserEMailAddresses();
//error_log(__METHOD__.__LINE__.array2string($userEMailAddresses));
// get message headers for specified message
#$headers = $mail_bo->getMessageHeader($_folder, $_uid);
$headers = $mail_bo->getMessageEnvelope($_uid, $_partID);
@ -1619,59 +1615,6 @@ class mail_compose
return false;
}
/**
* getUserEMailAddresses - function to gather the emailadresses connected to the current mail-account
* @return array - array(email=>realname)
*/
function getUserEMailAddresses() {
$acc = emailadmin_account::read($this->mail_bo->profileID);
$identities = $acc->identities();
$userEMailAdresses = array();
foreach($identities as $ik => $ident) {
//error_log(__METHOD__.__LINE__.':'.$ik.'->'.array2string($ident));
$identity = emailadmin_account::read_identity($ik);
$userEMailAdresses[$identity['ident_email']] = $identity['ident_realname'];
}
//error_log(__METHOD__.__LINE__.array2string($userEMailAdresses));
return $userEMailAdresses;
}
/**
* getAllIdentities - function to gather the identities connected to the current user
* @return array - array(email=>realname)
*/
function getAllIdentities() {
$acc = emailadmin_account::read($this->mail_bo->profileID);
$identities = $acc->identities('all');
$userEMailAdresses = array();
foreach($identities as $ik => $ident) {
//error_log(__METHOD__.__LINE__.':'.$ik.'->'.array2string($ident));
$identity = emailadmin_account::read_identity($ik);
$userEMailAdresses[$identity['ident_id']] = array('ident_id'=>$identity['ident_id'],'ident_email'=>$identity['ident_email'],'ident_org'=>$identity['ident_org'],'ident_realname'=>$identity['ident_realname'],'ident_signature'=>$identity['ident_signature']);
}
//error_log(__METHOD__.__LINE__.array2string($userEMailAdresses));
return $userEMailAdresses;
}
/**
* getDefaultIdentity - function to gather the default identitiy connected to the current mailaccount
* @return int - id of the identity
*/
function getDefaultIdentity() {
// retrieve the signature accociated with the identity
$id = $this->mail_bo->getIdentitiesWithAccounts($_accountData);
$acc = emailadmin_account::read($this->mail_bo->profileID);
$accountDataIT = ($_accountData[$this->mail_bo->profileID]?$acc->identities($this->mail_bo->profileID,true,'ident_id'):$acc->identities($_accountData[$id],true,'ident_id'));
foreach($accountDataIT as $it => $accountData)
{
return $accountData['ident_id'];
}
}
/**
* getReplyData - function to gather the replyData and save it with the session, to be used then.
* @param $_mode can be:
@ -1691,7 +1634,7 @@ class mail_compose
$mail_bo->openConnection();
$mail_bo->reopen($_folder);
$userEMailAddresses = $this->getUserEMailAddresses();
$userEMailAddresses = $mail_bo->getUserEMailAddresses();
// get message headers for specified message
//print "AAAA: $_folder, $_uid, $_partID<br>";
@ -2534,7 +2477,7 @@ class mail_compose
function setDefaults($content=array())
{
// retrieve the signature accociated with the identity
$id = $this->getDefaultIdentity();
$id = $this->mail_bo->getDefaultIdentity();
if ((!isset($content['identity']) || empty($content['identity'])) && $id) $content['signatureid'] = $id;
if (!isset($content['signatureid']) || empty($content['signatureid'])) $content['signatureid'] = $id;
if (!isset($content['mimeType']) || empty($content['mimeType']))

View File

@ -73,9 +73,9 @@ class mail_sieve
$profileID = 0;
if (isset($GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID']))
$profileID = (int)$GLOBALS['egw_info']['user']['preferences']['mail']['ActiveProfileID'];
$this->mailbo = mail_bo::getInstance(true, $profileID);
$this->mailbo = mail_bo::getInstance(false, $profileID, false, $oldIMAPObject=true);
if (is_object($this->mailbo->mailPreferences))
/* if (is_object($this->mailbo->mailPreferences))
{
// account select box
$selectedID = $this->mailbo->getIdentitiesWithAccounts($identities);
@ -90,6 +90,7 @@ class mail_sieve
}
}
*/
$this->mailPreferences =& $this->mailbo->mailPreferences;
$this->mailConfig = config::read('mail');
@ -466,14 +467,15 @@ class mail_sieve
}
$allIdentities = $preferences->getIdentity();
$allIdentities = $this->mailbo->getAllIdentities();
$defaultIdentity = $this->mailbo->getDefaultIdentity();
foreach($allIdentities as $key => $singleIdentity)
{
if((empty($vacation))&& $singleIdentity->default === true)
if((empty($vacation))&& !empty($singleIdentity['ident_email']) && $singleIdentity['ident_email']==$allIdentities[$defaultIdentity]['ident_email'])
{
$selectedAddresses[$singleIdentity->emailAddress] = $singleIdentity->emailAddress;
$selectedAddresses[$singleIdentity['ident_email']] = $singleIdentity['ident_email'];
}
$predefinedAddresses[$singleIdentity->emailAddress] = $singleIdentity->emailAddress;
$predefinedAddresses[$singleIdentity['ident_email']] = $singleIdentity['ident_email'];
}
asort($predefinedAddresses);
@ -1076,8 +1078,8 @@ class mail_sieve
}
}
//error_log(__METHOD__. array2string($rules));
//_debug_array($rules);
//error_log(__METHOD__. array2string($rows));
//_debug_array($rows);
}else
{
//error_log(__METHOD__.'There are no rules or something is went wrong at getRules()!');