some little additional stuff regarding the signature-selector-placeholder issue in compose

This commit is contained in:
Klaus Leithoff 2014-11-11 14:17:38 +00:00
parent 242d4740df
commit f73d84dd90
2 changed files with 14 additions and 5 deletions

View File

@ -662,19 +662,20 @@ class emailadmin_imapbase
/**
* getAllIdentities - function to gather the identities connected to the current user
* @param string/int $_accountToSearch; null; if set search accounts for user specified
* @param boolean $resolve_placeholders wether or not resolve possible placeholders in identities
* @return array - array(email=>realname)
*/
static function getAllIdentities($_accountToSearch=null) {
static function getAllIdentities($_accountToSearch=null,$resolve_placeholders=false) {
$userEMailAdresses = array();
foreach(emailadmin_account::search($only_current_user=($_accountToSearch?$_accountToSearch:true), $just_name=true) as $acc_id => $identity_name)
{
$acc = emailadmin_account::read($acc_id,($_accountToSearch?$_accountToSearch:null));
$userEMailAdresses[$acc['ident_id']] = array('acc_id'=>$acc_id,'ident_id'=>$acc['ident_id'],'ident_email'=>$acc['ident_email'],'ident_org'=>$acc['ident_org'],'ident_realname'=>$acc['ident_realname'],'ident_signature'=>$acc['ident_signature'],'ident_name'=>$acc['ident_name']);
if (!$resolve_placeholders) $userEMailAdresses[$acc['ident_id']] = array('acc_id'=>$acc_id,'ident_id'=>$acc['ident_id'],'ident_email'=>$acc['ident_email'],'ident_org'=>$acc['ident_org'],'ident_realname'=>$acc['ident_realname'],'ident_signature'=>$acc['ident_signature'],'ident_name'=>$acc['ident_name']);
$identities = $acc->identities($acc_id);
foreach($identities as $ik => $ident) {
//error_log(__METHOD__.' ('.__LINE__.') '.':'.$ik.'->'.array2string($ident));
$identity = emailadmin_account::read_identity($ik);
$identity = emailadmin_account::read_identity($ik,$resolve_placeholders);
//error_log(__METHOD__.' ('.__LINE__.') '.':'.$ik.'->'.array2string($identity));
if (!isset($userEMailAdresses[$identity['ident_id']])) $userEMailAdresses[$identity['ident_id']] = array('acc_id'=>$acc_id,'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'],'ident_name'=>$identity['ident_name']);
}

View File

@ -921,7 +921,7 @@ class mail_compose
*/
// prepare signatures, the selected sig may be used on top of the body
//identities and signature stuff
$allIdentities = mail_bo::getAllIdentities();
$allIdentities = mail_bo::getAllIdentities(null,true);
$selectedMailAccount = ($content['mailaccount']?$content['mailaccount']:$this->mail_bo->profileID);
$acc = emailadmin_account::read($this->mail_bo->profileID);
$selectSignatures = array(
@ -964,6 +964,12 @@ class mail_compose
//if (count($defaultIds)>1) unset($defaultIds[$this->mail_bo->profileID]);
$allSignatures = $this->mail_bo->getAccountIdentities($selectedMailAccount);
$defaultIdentity = 0;
// we want identity info in a length approx between 50 and 100 char
$longestName = 50;
foreach($allSignatures as $key => $singleIdentity) {
if (strlen($singleIdentity['ident_name'])>$longestName) $longestName=strlen($singleIdentity['ident_name']);
}
if ($longestName>100) $longestName=100;
foreach($allSignatures as $key => $singleIdentity) {
//error_log(__METHOD__.__LINE__.array2string($singleIdentity));
//$identities[$singleIdentity['ident_id']] = $singleIdentity['ident_realname'].' <'.$singleIdentity['ident_email'].'>';
@ -976,13 +982,15 @@ class mail_compose
{
$id_prepend = '('.$singleIdentity['ident_id'].') ';
}
$buff='';
if (!empty($singleIdentity['ident_name']) && !in_array(lang('Signature').': '.$id_prepend.$singleIdentity['ident_name'],$selectSignatures))
{
$buff = $singleIdentity['ident_name'];
if (strlen($buff)<$longestName)$buff = $singleIdentity['ident_name'].': '.trim(substr(str_replace(array("\r\n","\r","\n","\t"),array(" "," "," "," "),translation::convertHTMLToText($singleIdentity['ident_signature'])),0,$longestName-strlen($buff)));
}
else
{
$buff = trim(substr(str_replace(array("\r\n","\r","\n","\t"),array(" "," "," "," "),translation::convertHTMLToText($singleIdentity['ident_signature'])),0,50));
$buff = trim(substr(str_replace(array("\r\n","\r","\n","\t"),array(" "," "," "," "),translation::convertHTMLToText($singleIdentity['ident_signature'])),0,$longestName));
}
$sigDesc = $buff?$buff:lang('none');