signature and identity control on compose; get rid of unsupported stationery-stuff

This commit is contained in:
Klaus Leithoff 2013-11-22 13:55:09 +00:00
parent 6d65b16223
commit e322875350
4 changed files with 163 additions and 102 deletions

View File

@ -2196,7 +2196,7 @@ class mail_bo
function _getSpecialUseFolder($_type, $_checkexistance=TRUE) function _getSpecialUseFolder($_type, $_checkexistance=TRUE)
{ {
static $types = array( static $types = array(
'Drafts'=>array('prefName'=>'draftFolder','profileKey'=>'draftfolder','acc_folder_draft'=>'Drafts'), 'Drafts'=>array('prefName'=>'draftFolder','profileKey'=>'acc_folder_draft','autoFolderName'=>'Drafts'),
'Template'=>array('prefName'=>'templateFolder','profileKey'=>'acc_folder_template','autoFolderName'=>'Templates'), 'Template'=>array('prefName'=>'templateFolder','profileKey'=>'acc_folder_template','autoFolderName'=>'Templates'),
'Trash'=>array('prefName'=>'trashFolder','profileKey'=>'acc_folder_trash','autoFolderName'=>'Trash'), 'Trash'=>array('prefName'=>'trashFolder','profileKey'=>'acc_folder_trash','autoFolderName'=>'Trash'),
'Sent'=>array('prefName'=>'sentFolder','profileKey'=>'acc_folder_sent','autoFolderName'=>'Sent'), 'Sent'=>array('prefName'=>'sentFolder','profileKey'=>'acc_folder_sent','autoFolderName'=>'Sent'),
@ -2209,7 +2209,7 @@ class mail_bo
if (is_null(self::$specialUseFolders) || empty(self::$specialUseFolders)) self::$specialUseFolders = $this->getSpecialUseFolders(); if (is_null(self::$specialUseFolders) || empty(self::$specialUseFolders)) self::$specialUseFolders = $this->getSpecialUseFolders();
//highest precedence //highest precedence
$_folderName = $this->ic_server->$types[$_type]['profileKey']; $_folderName = $this->icServer->$types[$_type]['profileKey'];
//check prefs next //check prefs next
if (empty($_folderName)) $_folderName = $this->mailPreferences[$types[$_type]['prefName']]; if (empty($_folderName)) $_folderName = $this->mailPreferences[$types[$_type]['prefName']];
// does the folder exist??? // does the folder exist???

View File

@ -112,7 +112,7 @@ class mail_compose
if (mail_bo::$debug) error_log(__METHOD__.__LINE__.' Fetched IC Server:'.$this->mail_bo->profileID.':'.function_backtrace()); if (mail_bo::$debug) error_log(__METHOD__.__LINE__.' Fetched IC Server:'.$this->mail_bo->profileID.':'.function_backtrace());
// no icServer Object: something failed big time // no icServer Object: something failed big time
if (!isset($this->mail_bo->icServer)) exit; // ToDo: Exception or the dialog for setting up a server config if (!isset($this->mail_bo->icServer)) exit; // ToDo: Exception or the dialog for setting up a server config
/*if (!($this->mail_bo->icServer->_connected == 1))*/ $this->mail_bo->openConnection($this->mail_bo->profileID); $this->mail_bo->openConnection($this->mail_bo->profileID);
$this->preferences =& $this->mail_bo->mailPreferences; $this->preferences =& $this->mail_bo->mailPreferences;
// we should get away from this $this->preferences->preferences should hold the same info // we should get away from this $this->preferences->preferences should hold the same info
$this->mailPreferences =& $this->mail_bo->mailPreferences; $this->mailPreferences =& $this->mail_bo->mailPreferences;
@ -149,7 +149,7 @@ class mail_compose
} }
} }
$formData['priority'] = $this->stripSlashes($_POST['priority']); $formData['priority'] = $this->stripSlashes($_POST['priority']);
$formData['signatureID'] = (int)$_POST['signatureID']; $formData['signatureid'] = (int)$_POST['signatureid'];
$formData['stationeryID'] = $_POST['stationeryID']; $formData['stationeryID'] = $_POST['stationeryID'];
$formData['mimeType'] = $this->stripSlashes($_POST['mimeType']); $formData['mimeType'] = $this->stripSlashes($_POST['mimeType']);
if ($formData['mimeType'] == 'html' && html::htmlarea_availible()===false) if ($formData['mimeType'] == 'html' && html::htmlarea_availible()===false)
@ -242,7 +242,7 @@ class mail_compose
{ {
//error_log(__METHOD__.__LINE__.array2string($_REQUEST)); //error_log(__METHOD__.__LINE__.array2string($_REQUEST));
//error_log(__METHOD__.__LINE__.array2string($_content).function_backtrace()); //error_log(__METHOD__.__LINE__.array2string($_content).function_backtrace());
$_contenHasSigID = array_key_exists('signatureid',$_content);
if (isset($_GET['reply_id'])) $replyID = $_GET['reply_id']; if (isset($_GET['reply_id'])) $replyID = $_GET['reply_id'];
if (!$replyID && isset($_GET['id'])) $replyID = $_GET['id']; if (!$replyID && isset($_GET['id'])) $replyID = $_GET['id'];
if (isset($_GET['part_id'])) $partID = $_GET['part_id']; if (isset($_GET['part_id'])) $partID = $_GET['part_id'];
@ -402,7 +402,6 @@ class mail_compose
} }
// saving as draft, does not mean closing the message // saving as draft, does not mean closing the message
$messageUid = ($messageUid===true ? $uidNext : $messageUid); $messageUid = ($messageUid===true ? $uidNext : $messageUid);
if (!$this->mail_bo->icServer->_connected) $this->mail_bo->openConnection($this->mail_bo->profileID);
if ($this->mail_bo->getMessageHeader($messageUid)) if ($this->mail_bo->getMessageHeader($messageUid))
{ {
//error_log(__METHOD__.__LINE__.' (re)open drafted message with new UID: '.$messageUid.' in folder:'.$folder); //error_log(__METHOD__.__LINE__.' (re)open drafted message with new UID: '.$messageUid.' in folder:'.$folder);
@ -464,10 +463,10 @@ class mail_compose
unset($_content['mail_plaintext']); unset($_content['mail_plaintext']);
// form was submitted either by clicking a button or by changing one of the triggering selectboxes // form was submitted either by clicking a button or by changing one of the triggering selectboxes
// identity and signatureID; this might trigger that the signature in mail body may have to be altered // identity and signatureid; this might trigger that the signature in mail body may have to be altered
if ( !empty($content['body']) && if ( !empty($content['body']) &&
(!empty($composeCache['identity']) && !empty($_content['identity']) && $_content['identity'] != $composeCache['identity']) || (!empty($composeCache['identity']) && !empty($_content['identity']) && $_content['identity'] != $composeCache['identity']) ||
(!empty($composeCache['signatureID']) && !empty($_content['signatureID']) && $_content['signatureID'] != $composeCache['signatureID']) (!empty($composeCache['signatureid']) && !empty($_content['signatureid']) && $_content['signatureid'] != $composeCache['signatureid'])
) )
{ {
$buttonClicked = true; $buttonClicked = true;
@ -475,33 +474,49 @@ class mail_compose
if (!empty($composeCache['identity']) && !empty($_content['identity']) && $_content['identity'] != $composeCache['identity']) if (!empty($composeCache['identity']) && !empty($_content['identity']) && $_content['identity'] != $composeCache['identity'])
{ {
$Identities = $this->preferences->getIdentity($_content['identity']); $Identities = emailadmin_account::read_identity($_content['identity'],true);
//error_log(__METHOD__.__LINE__.array2string($Identities->signature)); //error_log(__METHOD__.__LINE__.array2string($Identities));
if ($Identities->signature) if ($Identities['ident_id'])
{ {
$newSig = $Identities->signature; $newSig = $Identities['ident_id'];
} }
else else
{ {
$newSig = $this->bosignatures->getDefaultSignature(); $newSig = $this->getDefaultIdentity();
if ($newSig === false) $newSig = -1; if ($newSig === false) $newSig = -2;
} }
} }
$_oldSig = $composeCache['signatureID']; $_oldSig = $composeCache['signatureid'];
$_signatureID = ($newSig?$newSig:$_content['signatureID']); $_signatureid = ($newSig?$newSig:$_content['signatureid']);
$_currentMode = $_content['mimeType']; $_currentMode = $_content['mimeType'];
if ($_oldSig != $_signatureID) if ($_oldSig != $_signatureid)
{ {
if($this->_debug); error_log(__METHOD__.__LINE__.' old,new ->'.$_oldSig.','.$_signatureID.'#'.$content['body']); if($this->_debug) error_log(__METHOD__.__LINE__.' old,new ->'.$_oldSig.','.$_signatureid.'#'.$content['body']);
// prepare signatures, the selected sig may be used on top of the body // prepare signatures, the selected sig may be used on top of the body
$oldSignature = $this->bosignatures->getSignature($_oldSig); try
//error_log(__METHOD__.__LINE__.'Old:'.array2string($oldSignature).'#'); {
$oldSigText = $oldSignature->fm_signature; $oldSignature = emailadmin_account::read_identity($_oldSig,true);
$signature = $this->bosignatures->getSignature($_signatureID); //error_log(__METHOD__.__LINE__.'Old:'.array2string($oldSignature).'#');
//error_log(__METHOD__.__LINE__.'New:'.array2string($signature).'#'); $oldSigText = $oldSignature['ident_signature'];
$sigText = $signature->fm_signature; }
error_log(__METHOD__.'Old:'.$oldSigText.'#'); catch (Exception $e)
error_log(__METHOD__.'New:'.$sigText.'#'); {
$oldSignature=array();
$oldSigText = null;
}
try
{
$signature = emailadmin_account::read_identity($_signatureid,true);
//error_log(__METHOD__.__LINE__.'New:'.array2string($signature).'#');
$sigText = $signature['ident_signature'];
}
catch (Exception $e)
{
$signature=array();
$sigText = null;
}
//error_log(__METHOD__.'Old:'.$oldSigText.'#');
//error_log(__METHOD__.'New:'.$sigText.'#');
if ($_currentMode == 'plain') if ($_currentMode == 'plain')
{ {
$oldSigText = $this->convertHTMLToText($oldSigText,true,true); $oldSigText = $this->convertHTMLToText($oldSigText,true,true);
@ -509,9 +524,9 @@ class mail_compose
if($this->_debug) error_log(__METHOD__." Old signature:".$oldSigText); if($this->_debug) error_log(__METHOD__." Old signature:".$oldSigText);
} }
$oldSigText = mail_bo::merge($oldSigText,array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id'))); //$oldSigText = mail_bo::merge($oldSigText,array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id')));
//error_log(__METHOD__.'Old+:'.$oldSigText.'#'); //error_log(__METHOD__.'Old+:'.$oldSigText.'#');
$sigText = mail_bo::merge($sigText,array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id'))); //$sigText = mail_bo::merge($sigText,array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id')));
//error_log(__METHOD__.'new+:'.$sigText.'#'); //error_log(__METHOD__.'new+:'.$sigText.'#');
$_htmlConfig = mail_bo::$htmLawed_config; $_htmlConfig = mail_bo::$htmLawed_config;
mail_bo::$htmLawed_config['comment'] = 2; mail_bo::$htmLawed_config['comment'] = 2;
@ -534,7 +549,7 @@ class mail_compose
//error_log(__METHOD__."() preg_replace('$reg', '$rep', '$in', -1)='".$content['body']."', replaced=$replaced"); //error_log(__METHOD__."() preg_replace('$reg', '$rep', '$in', -1)='".$content['body']."', replaced=$replaced");
if ($replaced) if ($replaced)
{ {
$content['signatureID'] = $_content['signatureID'] = $presetSig = $_signatureID; $content['signatureid'] = $_content['signatureid'] = $presetSig = $_signatureid;
$found = false; // this way we skip further replacement efforts $found = false; // this way we skip further replacement efforts
} }
else else
@ -569,7 +584,7 @@ class mail_compose
} }
else else
{ {
$content['signatureID'] = $_content['signatureID'] = $presetSig = $_signatureID; $content['signatureid'] = $_content['signatureid'] = $presetSig = $_signatureid;
} }
if ($styles) if ($styles)
{ {
@ -891,8 +906,8 @@ class mail_compose
{ {
$presetSig = (strtolower($_REQUEST['signature']) == 'no' ? -2 : -1); $presetSig = (strtolower($_REQUEST['signature']) == 'no' ? -2 : -1);
} }
if (($suppressSigOnTop || $content['isDraft']) && !empty($content['signatureID'])) $presetSig = (int)$content['signatureID']; if (($suppressSigOnTop || $content['isDraft']) && !empty($content['signatureid'])) $presetSig = (int)$content['signatureid'];
if (($suppressSigOnTop || $content['isDraft']) && !empty($content['stationeryID'])) $presetStationery = $content['stationeryID']; //if (($suppressSigOnTop || $content['isDraft']) && !empty($content['stationeryID'])) $presetStationery = $content['stationeryID'];
$presetId = NULL; $presetId = NULL;
if (($suppressSigOnTop || $content['isDraft']) && !empty($content['identity'])) $presetId = (int)$content['identity']; if (($suppressSigOnTop || $content['isDraft']) && !empty($content['identity'])) $presetId = (int)$content['identity'];
@ -913,7 +928,11 @@ class mail_compose
// prepare signatures, the selected sig may be used on top of the body // prepare signatures, the selected sig may be used on top of the body
//identities and signature stuff //identities and signature stuff
$allIdentities = $this->getAllIdentities(); $allIdentities = $this->getAllIdentities();
unset($allIdentities[0]); $acc = emailadmin_account::read($this->mail_bo->profileID);
$selectSignatures = array(
'-2' => lang('no signature')
);
//unset($allIdentities[0]);
//_debug_array($allIdentities); //_debug_array($allIdentities);
if (is_null(mail_bo::$mailConfig)) mail_bo::$mailConfig = config::read('mail'); if (is_null(mail_bo::$mailConfig)) mail_bo::$mailConfig = config::read('mail');
// not set? -> use default, means full display of all available data // not set? -> use default, means full display of all available data
@ -921,10 +940,10 @@ class mail_compose
$globalIds = 0; $globalIds = 0;
$defaultIds = array(); $defaultIds = array();
foreach($allIdentities as $key => $singleIdentity) { foreach($allIdentities as $key => $singleIdentity) {
if(empty($defaultIds)) if(empty($defaultIds)&& $singleIdentity['ident_id']==$acc['ident_id'])
{ {
$defaultIds[$singleIdentity['id']] = $singleIdentity['id']; $defaultIds[$singleIdentity['ident_id']] = $singleIdentity['ident_id'];
$selectedSender = $singleIdentity['id']; $selectedSender = $singleIdentity['ident_id'];
} }
} }
//error_log(__METHOD__.__LINE__.' Identities regarded/marked as default:'.array2string($defaultIds). ' MailProfileActive:'.$this->mail_bo->profileID); //error_log(__METHOD__.__LINE__.' Identities regarded/marked as default:'.array2string($defaultIds). ' MailProfileActive:'.$this->mail_bo->profileID);
@ -934,7 +953,7 @@ class mail_compose
$defaultIdentity = 0; $defaultIdentity = 0;
$identities = array(); $identities = array();
foreach($allIdentities as $key => $singleIdentity) { foreach($allIdentities as $key => $singleIdentity) {
//$identities[$singleIdentity->id] = $singleIdentity->realName.' <'.$singleIdentity->emailAddress.'>'; //$identities[$singleIdentity['ident_id']] = $singleIdentity['ident_realname'].' <'.$singleIdentity['ident_email'].'>';
$iS = mail_bo::generateIdentityString($singleIdentity); $iS = mail_bo::generateIdentityString($singleIdentity);
if (mail_bo::$mailConfig['how2displayIdentities']=='' || count($allIdentities) ==1 || count($allIdentities) ==$globalIds) if (mail_bo::$mailConfig['how2displayIdentities']=='' || count($allIdentities) ==1 || count($allIdentities) ==$globalIds)
{ {
@ -942,50 +961,48 @@ class mail_compose
} }
else else
{ {
$id_prepend = '('.$singleIdentity->id.') '; $id_prepend = '('.$singleIdentity['ident_id'].') ';
} }
$buff = trim(substr(str_replace(array("\r\n","\r","\n","\t"),array(" "," "," "," "),translation::convertHTMLToText($singleIdentity['ident_signature'])),0,50));
$sigDesc = $buff?$buff:lang('none');
if ($sigDesc == lang('none')) $sigDesc = $singleIdentity['ident_realname'].($singleIdentity['ident_org']?' ('.$singleIdentity['ident_org'].')':'');
$selectSignatures[$singleIdentity['ident_id']] = lang('Signature').': '.$id_prepend.$sigDesc;
//if ($singleIdentity->default) error_log(__METHOD__.__LINE__.':'.$presetId.'->'.$key.'('.$singleIdentity->id.')'.'#'.$iS.'#'); //if ($singleIdentity->default) error_log(__METHOD__.__LINE__.':'.$presetId.'->'.$key.'('.$singleIdentity->id.')'.'#'.$iS.'#');
if (array_search($id_prepend.$iS,$identities)===false) if (array_search($id_prepend.$iS,$identities)===false)
{ {
$identities[$singleIdentity->id] = $id_prepend.$iS; $identities[$singleIdentity['ident_id']] = $id_prepend.$iS;
$sel_options['identity'][$singleIdentity->id] = $id_prepend.$iS; $sel_options['identity'][$singleIdentity['ident_id']] = $id_prepend.$iS;
} }
if(in_array($singleIdentity->id,$defaultIds) && $defaultIdentity==0) if(in_array($singleIdentity['ident_id'],$defaultIds) && $defaultIdentity==0)
{ {
//_debug_array($singleIdentity); //_debug_array($singleIdentity);
$defaultIdentity = $singleIdentity->id; $defaultIdentity = $singleIdentity['ident_id'];
//$defaultIdentity = $key; //$defaultIdentity = $key;
if (empty($content['signatureID'])) $content['signatureID'] = (!empty($singleIdentity->signature) ? $singleIdentity->signature : $content['signatureID']); if (empty($content['signatureid'])) $content['signatureid'] = (!empty($singleIdentity['ident_signature']) ? $singleIdentity['ident_id'] : $content['signatureid']);
} }
} }
// fetch the signature, prepare the select box, ... // fetch the signature, prepare the select box, ...
/* if (empty($content['signatureid'])) {
$boSignatures = new mail_signatures(); $content['signatureid'] = $acc['ident_id'];
$signatures = $boSignatures->getListOfSignatures();
if (empty($content['signatureID'])) {
if ($signatureData = $boSignatures->getDefaultSignature()) {
if (is_array($signatureData)) {
$content['signatureID'] = $signatureData['signatureid'];
} else {
$content['signatureID'] =$signatureData;
}
}
} }
$selectSignatures = array(
'-2' => lang('no signature')
);
foreach($signatures as $signature) {
$selectSignatures[$signature['fm_signatureid']] = lang('Signature').': '.$signature['fm_description'];
}
*/
$disableRuler = false; $disableRuler = false;
// $signature = $boSignatures->getSignature(($presetSig ? $presetSig : $content['signatureID'])); //_debug_array(($presetSig ? $presetSig : $content['signatureid']));
try
{
$signature = emailadmin_account::read_identity(($presetSig ? $presetSig : $content['signatureid']),true);
}
catch (Exception $e)
{
//PROBABLY NOT FOUND
$signature=array();
}
if ((isset($this->preferencesArray['disableRulerForSignatureSeparation']) && if ((isset($this->preferencesArray['disableRulerForSignatureSeparation']) &&
$this->preferencesArray['disableRulerForSignatureSeparation']) || $this->preferencesArray['disableRulerForSignatureSeparation']) ||
empty($signature->fm_signature) || trim($this->convertHTMLToText($signature->fm_signature,true,true)) =='') empty($signature['ident_signature']) || trim($this->convertHTMLToText($signature['ident_signature'],true,true)) =='')
{ {
$disableRuler = true; $disableRuler = true;
} }
@ -1007,7 +1024,7 @@ class mail_compose
) )
{ {
$insertSigOnTop = ($insertSigOnTop?$insertSigOnTop:true); $insertSigOnTop = ($insertSigOnTop?$insertSigOnTop:true);
$sigText = mail_bo::merge($signature->fm_signature,array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id'))); $sigText = mail_bo::merge($signature['ident_signature'],array($GLOBALS['egw']->accounts->id2name($GLOBALS['egw_info']['user']['account_id'],'person_id')));
if ($content['mimeType'] == 'html') if ($content['mimeType'] == 'html')
{ {
$sigTextStartsWithBlockElement = ($disableRuler?false:true); $sigTextStartsWithBlockElement = ($disableRuler?false:true);
@ -1074,19 +1091,21 @@ class mail_compose
} else { } else {
$ishtml=0; $ishtml=0;
} }
// signature stuff set earlier // signature stuff set earlier
$sel_options['signatureID'] = $selectSignatures; //_debug_array($selectSignatures);
$content['signatureID'] = ($presetSig ? $presetSig : $content['signatureID']); $sel_options['signatureid'] = $selectSignatures;
$content['signatureid'] = ($presetSig ? $presetSig : $content['signatureid']);
//_debug_array($sel_options['signatureid'][$content['signatureid']]);
// end signature stuff // end signature stuff
// stationery stuff // stationery stuff; completely abandoned with the new database structure
/*
$bostationery = new emailadmin_bostationery(); $bostationery = new emailadmin_bostationery();
$selectStationeries = array( $selectStationeries = array(
'0' => lang('no stationery') '0' => lang('no stationery')
); );
$showStationaries = false; $showStationaries = false;
// $validStationaries = $bostationery->get_valid_templates(); $validStationaries = $bostationery->get_valid_templates();
if (is_array($validStationaries) && count($validStationaries)>0) if (is_array($validStationaries) && count($validStationaries)>0)
{ {
$showStationaries = true; $showStationaries = true;
@ -1096,6 +1115,7 @@ class mail_compose
$sel_options['stationeryID'] = $selectStationeries; $sel_options['stationeryID'] = $selectStationeries;
// if ID of signature Select Box is set, we allow for changing the sig onChange of the signatueSelect // if ID of signature Select Box is set, we allow for changing the sig onChange of the signatueSelect
$content['stationeryID'] = ($presetStationery ? $presetStationery : 0); $content['stationeryID'] = ($presetStationery ? $presetStationery : 0);
*/
// end stationery stuff // end stationery stuff
//$content['bcc'] = array('kl@stylite.de','kl@leithoff.net'); //$content['bcc'] = array('kl@stylite.de','kl@leithoff.net');
// address stuff like from, to, cc, replyto // address stuff like from, to, cc, replyto
@ -1124,6 +1144,8 @@ class mail_compose
if ($_content) if ($_content)
{ {
//input array of _content had no signature information but was seeded later, and content has a valid setting
if (!$_contenHasSigID && $content['signatureid'] && array_key_exists('signatureid',$_content)) unset($_content['signatureid']);
$content = array_merge($content,$_content); $content = array_merge($content,$_content);
if (!empty($content['folder'])) $sel_options['folder']=$this->ajax_searchFolder(0,true); if (!empty($content['folder'])) $sel_options['folder']=$this->ajax_searchFolder(0,true);
@ -1351,11 +1373,13 @@ class mail_compose
} }
} }
if (!empty($addHeadInfo['X-SIGNATURE'])) { if (!empty($addHeadInfo['X-SIGNATURE'])) {
$this->sessionData['signatureID'] = $addHeadInfo['X-SIGNATURE']; $this->sessionData['signatureid'] = $addHeadInfo['X-SIGNATURE'];
} }
/*
if (!empty($addHeadInfo['X-STATIONERY'])) { if (!empty($addHeadInfo['X-STATIONERY'])) {
$this->sessionData['stationeryID'] = $addHeadInfo['X-STATIONERY']; $this->sessionData['stationeryID'] = $addHeadInfo['X-STATIONERY'];
} }
*/
if (!empty($addHeadInfo['X-IDENTITY'])) { if (!empty($addHeadInfo['X-IDENTITY'])) {
$this->sessionData['identity'] = $addHeadInfo['X-IDENTITY']; $this->sessionData['identity'] = $addHeadInfo['X-IDENTITY'];
} }
@ -1629,6 +1653,21 @@ class mail_compose
return $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. * getReplyData - function to gather the replyData and save it with the session, to be used then.
* @param $_mode can be: * @param $_mode can be:
@ -1985,26 +2024,26 @@ class mail_compose
$_mailObject->IsHTML(true); $_mailObject->IsHTML(true);
if(!empty($signature)) { if(!empty($signature)) {
#$_mailObject->Body = array($_formData['body'], $_signature['signature']); #$_mailObject->Body = array($_formData['body'], $_signature['signature']);
if($_formData['stationeryID']) { //if($_formData['stationeryID']) {
$bostationery = new felamimail_bostationery(); // $bostationery = new felamimail_bostationery();
$_mailObject->Body = $bostationery->render($_formData['stationeryID'],$_formData['body'],$signature); // $_mailObject->Body = $bostationery->render($_formData['stationeryID'],$_formData['body'],$signature);
} else { //} else {
$_mailObject->Body = $_formData['body'] . $_mailObject->Body = $_formData['body'] .
($disableRuler ?'<br>':'<hr style="border:1px dotted silver; width:90%;">'). ($disableRuler ?'<br>':'<hr style="border:1px dotted silver; width:90%;">').
$signature; $signature;
} //}
$_mailObject->AltBody = $this->convertHTMLToText($_formData['body'],true,true). $_mailObject->AltBody = $this->convertHTMLToText($_formData['body'],true,true).
($disableRuler ?"\r\n":"\r\n-- \r\n"). ($disableRuler ?"\r\n":"\r\n-- \r\n").
$this->convertHTMLToText($signature,true,true); $this->convertHTMLToText($signature,true,true);
#print "<pre>$_mailObject->AltBody</pre>"; #print "<pre>$_mailObject->AltBody</pre>";
#print htmlentities($_signature['signature']); #print htmlentities($_signature['signature']);
} else { } else {
if($_formData['stationeryID']) { //if($_formData['stationeryID']) {
$bostationery = new felamimail_bostationery(); // $bostationery = new felamimail_bostationery();
$_mailObject->Body = $bostationery->render($_formData['stationeryID'],$_formData['body']); // $_mailObject->Body = $bostationery->render($_formData['stationeryID'],$_formData['body']);
} else { //} else {
$_mailObject->Body = $_formData['body']; $_mailObject->Body = $_formData['body'];
} //}
$_mailObject->AltBody = $this->convertHTMLToText($_formData['body'],true,true); $_mailObject->AltBody = $this->convertHTMLToText($_formData['body'],true,true);
} }
// convert URL Images to inline images - if possible // convert URL Images to inline images - if possible
@ -2096,11 +2135,18 @@ class mail_compose
// preserve the bcc and if possible the save to folder information // preserve the bcc and if possible the save to folder information
$this->sessionData['folder'] = $_formData['folder']; $this->sessionData['folder'] = $_formData['folder'];
$this->sessionData['bcc'] = $_formData['bcc']; $this->sessionData['bcc'] = $_formData['bcc'];
$this->sessionData['signatureID'] = $_formData['signatureID']; $this->sessionData['signatureid'] = $_formData['signatureid'];
$this->sessionData['stationeryID'] = $_formData['stationeryID']; //$this->sessionData['stationeryID'] = $_formData['stationeryID'];
$this->sessionData['identity'] = $_formData['identity']; $this->sessionData['identity'] = $_formData['identity'];
$this->sessionData['attachments'] = $_formData['attachments']; $this->sessionData['attachments'] = $_formData['attachments'];
$identity = $this->preferences->getIdentity((int)$this->sessionData['identity'],true); try
{
$identity = emailadmin_account::read_identity($this->sessionData['identity'],true);
}
catch (Exception $e)
{
$identity=array();
}
$flags = '\\Seen \\Draft'; $flags = '\\Seen \\Draft';
$BCCmail = ''; $BCCmail = '';
@ -2120,8 +2166,8 @@ class mail_compose
$folders = implode('|',array_unique($this->sessionData['folder'])); $folders = implode('|',array_unique($this->sessionData['folder']));
$mail->AddCustomHeader("X-Mailfolder: $folders"); $mail->AddCustomHeader("X-Mailfolder: $folders");
} }
$mail->AddCustomHeader('X-Signature: '.$this->sessionData['signatureID']); $mail->AddCustomHeader('X-Signature: '.$this->sessionData['signatureid']);
$mail->AddCustomHeader('X-Stationery: '.$this->sessionData['stationeryID']); //$mail->AddCustomHeader('X-Stationery: '.$this->sessionData['stationeryID']);
$mail->AddCustomHeader('X-Identity: '.(int)$this->sessionData['identity']); $mail->AddCustomHeader('X-Identity: '.(int)$this->sessionData['identity']);
// decide where to save the message (default to draft folder, if we find nothing else) // decide where to save the message (default to draft folder, if we find nothing else)
// if the current folder is in draft or template folder save it there // if the current folder is in draft or template folder save it there
@ -2180,8 +2226,8 @@ class mail_compose
$this->sessionData['subject'] = trim($_formData['subject']); $this->sessionData['subject'] = trim($_formData['subject']);
$this->sessionData['body'] = $_formData['body']; $this->sessionData['body'] = $_formData['body'];
$this->sessionData['priority'] = $_formData['priority']; $this->sessionData['priority'] = $_formData['priority'];
$this->sessionData['signatureID'] = $_formData['signatureID']; $this->sessionData['signatureid'] = $_formData['signatureid'];
$this->sessionData['stationeryID'] = $_formData['stationeryID']; //$this->sessionData['stationeryID'] = $_formData['stationeryID'];
$this->sessionData['disposition'] = $_formData['disposition']; $this->sessionData['disposition'] = $_formData['disposition'];
$this->sessionData['mimeType'] = $_formData['mimeType']; $this->sessionData['mimeType'] = $_formData['mimeType'];
$this->sessionData['to_infolog'] = $_formData['to_infolog']; $this->sessionData['to_infolog'] = $_formData['to_infolog'];
@ -2206,8 +2252,22 @@ class mail_compose
$messageIsDraft = true; $messageIsDraft = true;
} }
#error_log(print_r($this->preferences,true)); #error_log(print_r($this->preferences,true));
$identity = array();//$this->preferences->getIdentity((int)$this->sessionData['identity'],true); try
$signature = array();//$this->bosignatures->getSignature((int)$this->sessionData['signatureID']); {
$identity = emailadmin_account::read_identity($this->sessionData['identity'],true);
}
catch (Exception $e)
{
$identity=array();
}
try
{
$signature = emailadmin_account::read_identity((int)$this->sessionData['signatureid'],true);
}
catch (Exception $e)
{
$signature=array();
}
//error_log($this->sessionData['identity']); //error_log($this->sessionData['identity']);
//error_log(print_r($identity,true)); //error_log(print_r($identity,true));
// create the messages // create the messages
@ -2470,10 +2530,9 @@ class mail_compose
function setDefaults($content=array()) function setDefaults($content=array())
{ {
// retrieve the signature accociated with the identity // retrieve the signature accociated with the identity
$id = $this->mail_bo->getIdentitiesWithAccounts($_accountData); $id = $this->getDefaultIdentity();
$accountData = ($_accountData[$this->mail_bo->profileID]?$_accountData[$this->mail_bo->profileID]:$_accountData[$id]); if ((!isset($content['identity']) || empty($content['identity'])) && $id) $content['signatureid'] = $id;
if ((!isset($content['identity']) || empty($content['identity'])) && $accountData['ident_id']) $content['signatureID'] = $accountData['ident_id']; if (!isset($content['signatureid']) || empty($content['signatureid'])) $content['signatureid'] = $id;
if (!isset($content['signatureID']) || empty($content['signatureID'])) $content['signatureID'] = $accountData['ident_id'];
if (!isset($content['mimeType']) || empty($content['mimeType'])) if (!isset($content['mimeType']) || empty($content['mimeType']))
{ {
$content['mimeType'] = 'html'; $content['mimeType'] = 'html';
@ -2500,7 +2559,7 @@ class mail_compose
if (strlen($_searchString)>=$_searchStringLength && isset($this->mail_bo->icServer)) if (strlen($_searchString)>=$_searchStringLength && isset($this->mail_bo->icServer))
{ {
//error_log(__METHOD__.__LINE__.':'.$this->mail_bo->icServer->ImapServerId); //error_log(__METHOD__.__LINE__.':'.$this->mail_bo->icServer->ImapServerId);
if (!($this->mail_bo->icServer->_connected == 1)) $this->mail_bo->openConnection($this->mail_bo->icServer->ImapServerId); $this->mail_bo->openConnection($this->mail_bo->icServer->ImapServerId);
//error_log(__METHOD__.__LINE__.array2string($_searchString).'<->'.$searchString); //error_log(__METHOD__.__LINE__.array2string($_searchString).'<->'.$searchString);
$folderObjects = $this->mail_bo->getFolderObjects(true,false,true,$useCacheIfPossible); $folderObjects = $this->mail_bo->getFolderObjects(true,false,true,$useCacheIfPossible);
if (count($folderObjects)<=1) { if (count($folderObjects)<=1) {

View File

@ -1779,6 +1779,7 @@ app.classes.mail = AppJS.extend(
vfsUploadForImport: function(_egw, _widget, _window) { vfsUploadForImport: function(_egw, _widget, _window) {
//console.log(_egw, _widget, _window); //console.log(_egw, _widget, _window);
if (jQuery.isEmptyObject(_widget)) return;
if (!jQuery.isEmptyObject(_widget.getValue())) if (!jQuery.isEmptyObject(_widget.getValue()))
{ {
this.et2_obj.submit(); this.et2_obj.submit();
@ -1788,6 +1789,7 @@ app.classes.mail = AppJS.extend(
vfsUploadForCompose: function(_egw, _widget, _window) vfsUploadForCompose: function(_egw, _widget, _window)
{ {
//console.log(_egw, _widget, _window); //console.log(_egw, _widget, _window);
if (jQuery.isEmptyObject(_widget)) return;
if (!jQuery.isEmptyObject(_widget.getValue())) if (!jQuery.isEmptyObject(_widget.getValue()))
{ {
this.et2_obj.submit(); this.et2_obj.submit();
@ -1796,9 +1798,12 @@ app.classes.mail = AppJS.extend(
submitOnChange: function(_egw, _widget, _window) { submitOnChange: function(_egw, _widget, _window) {
//console.log(_egw, _widget, _window); //console.log(_egw, _widget, _window);
if (!jQuery.isEmptyObject(_widget.getValue())) if (!jQuery.isEmptyObject(_widget))
{ {
this.et2_obj.submit(); if (!jQuery.isEmptyObject(_widget.getValue()))
{
this.et2_obj.submit();
}
} }
}, },

View File

@ -71,12 +71,9 @@
</hbox> </hbox>
<groupbox class="mailSignature"> <groupbox class="mailSignature">
<menulist> <menulist>
<menupopup id="signatureID" onchange="app.mail.submitOnChange"/> <menupopup id="signatureid" onchange="app.mail.submitOnChange"/>
</menulist>
<description value="Stationery"/>
<menulist>
<menupopup id="stationeryID"/>
</menulist> </menulist>
<description value=" "/>
<description value="Editor type"/> <description value="Editor type"/>
<menulist> <menulist>
<menupopup id="mimeType" onchange="app.mail.submitOnChange"/> <menupopup id="mimeType" onchange="app.mail.submitOnChange"/>