several stuff towards a compose window; a testhtmlarea template to test/figure out issues regarding disabled

This commit is contained in:
Klaus Leithoff 2013-08-21 10:47:20 +00:00
parent 1d9589db99
commit 102bc9d6a2
10 changed files with 664 additions and 199 deletions

View File

@ -213,7 +213,7 @@ class mail_bo
else
{
// make sure the prefs are up to date for the profile to load
$loadfailed = false;
$loadfailed = $alreadytriedreloading = false;
self::$instances[$_profileID]->mailPreferences = self::$instances[$_profileID]->bopreferences->getPreferences(true,$_profileID);
//error_log(__METHOD__.__LINE__." ReRead the Prefs for ProfileID ".$_profileID.' called from:'.function_backtrace());
if (self::$instances[$_profileID]->mailPreferences)
@ -228,13 +228,29 @@ class mail_bo
}
else
{
$loadfailed=true;
// first try reloading without restore
if ($_restoreSession==true) self::$instances[$_profileID] = new mail_bo('utf-8',false,$_profileID);
if (!self::$instances[$_profileID]->mailPreferences) {
if (self::$debug) error_log(__METHOD__.__LINE__.' something wrong:'.array2string($_restoreSession).' mailPreferences could not be loaded!');
$loadfailed=$alreadytriedreloading=true;
}
}
if ($_profileID>0 && empty(self::$instances[$_profileID]->icServer->host)&&$alreadytriedreloading==false)
{
if ($_restoreSession==true) self::$instances[$_profileID] = new mail_bo('utf-8',false,$_profileID);
if (empty(self::$instances[$_profileID]->icServer->host))
{
if (self::$debug) error_log(__METHOD__.__LINE__.' something critically wrong for '.$_profileID.' RestoreSession:'.array2string($_restoreSession).'->'.array2string(self::$instances[$_profileID]->icServer).' No Server host set!');
$loadfailed=$alreadytriedreloading=true;
}
}
if ($loadfailed)
{
error_log(__METHOD__.__LINE__." ReRead of the Prefs for ProfileID ".$_profileID.' failed for icServer; trigger new instance. called from:'.function_backtrace());
// restore session seems to provide an incomplete session
self::$instances[$_profileID] = new mail_bo('utf-8',false,$_profileID);
$newprofileID = ($alreadytriedreloading ? emailadmin_bo::getUserDefaultProfileID():$_profileID);
if ($alreadytriedreloading) error_log(__METHOD__.__LINE__." Loading the Profile for ProfileID ".$_profileID.' failed for icServer; trigger new instance for Default-Profile '.$newprofileID.'. called from:'.function_backtrace());
// try loading the default profile for the user
self::$instances[$newprofileID] = new mail_bo('utf-8',false,$newprofileID);
$_profileID = $newprofileID;
}
}
self::$instances[$_profileID]->profileID = $_profileID;
@ -571,7 +587,7 @@ class mail_bo
*/
function closeConnection() {
//if ($icServer->_connected) error_log(__METHOD__.__LINE__.' disconnect from Server');
if ($icServer->_connected) $this->icServer->disconnect();
if ($this->icServer->_connected) $this->icServer->disconnect();
}
/**
@ -1588,8 +1604,18 @@ class mail_bo
{
$rfcAddr = imap_rfc822_parse_adrlist($_string,'');
if (!isset(self::$idna2)) self::$idna2 = new egw_idna;
$stringA = array();
//$_string = str_replace($rfcAddr[0]->host,self::$idna2->decode($rfcAddr[0]->host),$_string);
$_string = imap_rfc822_write_address($rfcAddr[0]->mailbox,self::$idna2->decode($rfcAddr[0]->host),$rfcAddr[0]->personal);
foreach ((array)$rfcAddr as $_rfcAddr)
{
if ($_rfcAddr->host=='.SYNTAX-ERROR.')
{
$stringA = array();
break; // skip idna conversion if we encounter an error here
}
$stringA[] = imap_rfc822_write_address($_rfcAddr->mailbox,self::$idna2->decode($_rfcAddr->host),$_rfcAddr->personal);
}
if (!empty($stringA)) $_string = implode(',',$stringA);
}
if ($_tryIDNConversion==='FORCE')
{
@ -3956,6 +3982,11 @@ class mail_bo
error_log(__METHOD__.__LINE__.array2string($retValue->message));
$retValue = null;
}
// if SUBJECT is an array, use thelast one, as we assume something with the unfolding for the subject did not work
if (is_array($retValue['SUBJECT']))
{
$retValue['SUBJECT'] = $retValue['SUBJECT'][count($retValue['SUBJECT'])-1];
}
return ($decode ? self::decode_header($retValue,true):$retValue);
}
@ -4271,7 +4302,8 @@ class mail_bo
//error_log(__METHOD__.__LINE__.array2string(substr($structure->parameters['NAME'],0,strlen('data:'))));
if (!is_array($structure->parameters['NAME']) && substr($structure->parameters['NAME'],0,strlen('data:'))==='data:') {
$namecounter++;
return lang("unknown").$namecounter.($structure->subType ? ".".$structure->subType : "");
$ext = mime_magic::mime2ext($structure->Type.'/'.$structure->subType);
return lang("unknown").$namecounter.($ext?$ext:($structure->subType ? ".".$structure->subType : ""));
}
if (is_array($structure->parameters['NAME'])) $structure->parameters['NAME'] = implode(' ',$structure->parameters['NAME']);
return rawurldecode(self::decode_header($structure->parameters['NAME']));
@ -4321,7 +4353,8 @@ class mail_bo
}
}
$namecounter++;
return lang("unknown").$namecounter.($structure->subType ? ".".$structure->subType : "");
$ext = mime_magic::mime2ext($structure->Type.'/'.$structure->subType);
return lang("unknown").$namecounter.($ext?$ext:($structure->subType ? ".".$structure->subType : ""));
}
}
@ -4420,7 +4453,8 @@ class mail_bo
{
$attachment = translation::convert($attachment,$structure->parameters['CHARSET'],self::$displayCharset);
}
$ext = mime_magic::mime2ext($structure->type .'/'. $structure->subType);
if ($ext && stripos($filename,'.')===false && stripos($filename,$ext)===false) $filename = trim($filename).'.'.$ext;
$attachmentData = array(
'type' => $structure->type .'/'. $structure->subType,
'filename' => $filename,
@ -4432,6 +4466,8 @@ class mail_bo
if ( $filename == 'winmail.dat' && $_winmail_nr > 0 &&
( $wmattach = $this->decode_winmail( $_uid, $_partID, $_winmail_nr ) ) )
{
$ext = mime_magic::mime2ext($wmattach['type']);
if ($ext && stripos($wmattach['name'],'.')===false && stripos($wmattach['name'],$ext)===false) $wmattach['name'] = trim($wmattach['name']).'.'.$ext;
$attachmentData = array(
'type' => $wmattach['type'],
'filename' => $wmattach['name'],
@ -4670,13 +4706,14 @@ class mail_bo
/**
* createHeaderInfoSection - creates a textual headersection from headerobject
* @param array header headerarray may contain SUBJECT,FROM,SENDER,TO,CC,BCC,DATE,PRIORITY,IMPORTANCE
* @param string headline Text tom use for headline
* @param string headline Text tom use for headline, if SUPPRESS, supress headline and footerline
* @param bool createHTML do it with HTML breaks
* @return string a preformatted string with the information of the header worked into it
*/
static function createHeaderInfoSection($header,$headline='', $createHTML = false)
{
$headdata = null;
//error_log(__METHOD__.__LINE__.array2string($header).function_backtrace());
if ($header['SUBJECT']) $headdata = lang('subject').': '.$header['SUBJECT'].($createHTML?"<br />":"\n");
if ($header['FROM']) $headdata .= lang('from').': '.self::convertAddressArrayToString($header['FROM'], $createHTML).($createHTML?"<br />":"\n");
if ($header['SENDER']) $headdata .= lang('sender').': '.self::convertAddressArrayToString($header['SENDER'], $createHTML).($createHTML?"<br />":"\n");
@ -4689,13 +4726,13 @@ class mail_bo
//if ($mailcontent['headers']['ORGANIZATION']) $headdata .= lang('organization').': '.$mailcontent['headers']['ORGANIZATION']."\
if (!empty($headdata))
{
if (!empty($headline)) $headdata = "---------------------------- $headline ----------------------------".($createHTML?"<br />":"\n").$headdata;
if (empty($headline)) $headdata = "--------------------------------------------------------".($createHTML?"<br />":"\n").$headdata;
$headdata .= "--------------------------------------------------------".($createHTML?"<br />":"\n");
if (!empty($headline) && $headline != 'SUPPRESS') $headdata = "---------------------------- $headline ----------------------------".($createHTML?"<br />":"\n").$headdata;
if (empty($headline)) $headdata = ($headline != 'SUPPRESS'?"--------------------------------------------------------".($createHTML?"<br />":"\n"):'').$headdata;
$headdata .= ($headline != 'SUPPRESS'?"--------------------------------------------------------".($createHTML?"<br />":"\n"):'');
}
else
{
$headdata = "--------------------------------------------------------".($createHTML?"<br />":"\n");
$headdata = ($headline != 'SUPPRESS'?"--------------------------------------------------------".($createHTML?"<br />":"\n"):'');
}
return $headdata;
}
@ -4753,6 +4790,26 @@ class mail_bo
return $returnAddr;
}
/**
* Merges a given content with contact data
*
* @param string $content
* @param array $ids array with contact id(s)
* @param string &$err error-message on error
* @return string/boolean merged content or false on error
*/
function merge($content,$ids,$mimetype='')
{
$contacts = new addressbook_bo();
$mergeobj = new addressbook_merge();
if (empty($mimetype)) $mimetype = (strlen(strip_tags($content)) == strlen($content) ?'text/plain':'text/html');
$rv = $mergeobj->merge_string($content,$ids,$err,$mimetype, array(), self::$displayCharset);
if (empty($rv) && !empty($content) && !empty($err)) $rv = $content;
if (!empty($err) && !empty($content) && !empty($ids)) error_log(__METHOD__.__LINE__.' Merge failed for Ids:'.array2string($ids).' ContentType:'.$mimetype.' Content:'.$content.' Reason:'.array2string($err));
return $rv;
}
/**
* Hook stuff
*/

View File

@ -23,6 +23,7 @@ class mail_compose
(
'action' => True,
'compose' => True,
'testhtmlarea' => True,
'composeFromDraft' => True,
'getAttachment' => True,
'fileSelector' => True,
@ -198,7 +199,7 @@ class mail_compose
if (!$messageUid) {
print "<script type=\"text/javascript\">alert('".lang("Error: Could not save Message as Draft")." ".lang("Trying to recover from session data")."');</script>";
//try to reopen the mail from session data
$this->compose('to',true);
$this->compose(null,null,'to',true);
return;
}
// saving as draft, does not mean closing the message
@ -211,7 +212,7 @@ class mail_compose
{
//error_log(__METHOD__.__LINE__.' (re)open drafted message with new UID: '.$messageUid.' in folder:'.$folder);
$uicompose->bocompose->getDraftData($uicompose->mail_bo->icServer, $folder, $messageUid);
$uicompose->compose('to',true);
$uicompose->compose(null,null,'to',true);
return;
}
} else {
@ -258,25 +259,29 @@ class mail_compose
$this->preferencesArray['message_forwarding'] = $buff;
}
}
$this->compose($_focusElement);
$this->compose(null,null,$_focusElement);
}
/**
* function compose
* this function is used to fill the compose dialog with the content provided by session data
*
* @var content array the etemplate content array
* @var msg string a possible message to be passed and displayed to the userinterface
* @var _focusElement varchar subject, to, body supported
* @var suppressSigOnTop boolean
* @var isReply boolean
*/
function compose($_focusElement='to',$suppressSigOnTop=false, $isReply=false)
function compose(array $content=null,$msg=null, $_focusElement='to',$suppressSigOnTop=false, $isReply=false)
{
//error_log(__METHOD__.__LINE__.array2string($_REQUEST));
error_log(__METHOD__.__LINE__.array2string($content));
if (isset($_GET['reply_id'])) $replyID = $_GET['reply_id'];
// read the data from session
// all values are empty for a new compose window
$insertSigOnTop = false;
$sessionData = $this->getSessionData();
$sessionData = /*$content; // */$this->getSessionData();
$alwaysAttachVCardAtCompose = false; // we use this to eliminate double attachments, if users VCard is already present/attached
if ( isset($GLOBALS['egw_info']['apps']['stylite']) && (isset($this->preferencesArray['attachVCardAtCompose']) &&
$this->preferencesArray['attachVCardAtCompose']))
@ -493,9 +498,6 @@ class mail_compose
if ($_REQUEST['preset'][$name]) $sessionData[$name] = $_REQUEST['preset'][$name];
}
}
$etpl = new etemplate_new('mail.compose');
$content = array();
_debug_array($sessionData);
// is the to address set already?
if (!empty($_REQUEST['send_to']))
{
@ -591,18 +593,6 @@ class mail_compose
if (($suppressSigOnTop || $sessionData['isDraft']) && !empty($sessionData['identity'])) $presetId = (int)$sessionData['identity'];
/*
$this->t->set_file(array("composeForm" => "composeForm.tpl"));
$this->t->set_block('composeForm','header','header');
$this->t->set_block('composeForm','body_input');
$this->t->set_block('composeForm','attachment','attachment');
$this->t->set_block('composeForm','attachment_row','attachment_row');
$this->t->set_block('composeForm','attachment_row_bold');
$this->t->set_block('composeForm','destination_row');
$this->t->set_block('composeForm','simple_text');
$this->translate();
// store the selected Signature
$this->t->set_var("mySigID",($presetSig ? $presetSig : $sessionData['signatureID']));
if ($GLOBALS['egw_info']['user']['apps']['addressbook']) {
$this->t->set_var("link_addressbook",egw::link('/index.php',array(
@ -669,101 +659,11 @@ class mail_compose
$this->t->set_var('errorInfo','&nbsp;');
}
*/
// header
$allIdentities = $this->mailPreferences->getIdentity();
unset($allIdentities[0]);
//_debug_array($allIdentities);
if (is_null(mail_bo::$mailConfig)) mail_bo::$mailConfig = config::read('mail');
// not set? -> use default, means full display of all available data
if (!isset(mail_bo::$mailConfig['how2displayIdentities'])) mail_bo::$mailConfig['how2displayIdentities'] ='';
$globalIds = 0;
$defaultIds = array();
foreach($allIdentities as $key => $singleIdentity) {
if ($singleIdentity->id<0){ $globalIds++; }/*else{ unset($allIdentities[$key]);}*/
// there could be up to 2 default IDS. the activeProfile and another on marking the desired Identity to choose
if(!empty($singleIdentity->default) && $singleIdentity->default==1) $defaultIds[$singleIdentity->id] = $singleIdentity->id;
}
//error_log(__METHOD__.__LINE__.' Identities regarded/marked as default:'.array2string($defaultIds). ' MailProfileActive:'.$this->mail_bo->profileID);
// if there are 2 defaultIDs, its most likely, that the user choose to set
// the one not being the activeServerProfile to be his default Identity
if (count($defaultIds)>1) unset($defaultIds[$this->mail_bo->profileID]);
$defaultIdentity = 0;
$identities = array();
foreach($allIdentities as $key => $singleIdentity) {
//$identities[$singleIdentity->id] = $singleIdentity->realName.' <'.$singleIdentity->emailAddress.'>';
$iS = mail_bo::generateIdentityString($singleIdentity);
if (mail_bo::$mailConfig['how2displayIdentities']=='' || count($allIdentities) ==1 || count($allIdentities) ==$globalIds)
{
$id_prepend ='';
}
else
{
$id_prepend = '('.$singleIdentity->id.') ';
}
//if ($singleIdentity->default) error_log(__METHOD__.__LINE__.':'.$presetId.'->'.$key.'('.$singleIdentity->id.')'.'#'.$iS.'#');
if (array_search($id_prepend.$iS,$identities)===false) $identities[$singleIdentity->id] = $id_prepend.$iS;
if(in_array($singleIdentity->id,$defaultIds) && $defaultIdentity==0)
{
//_debug_array($singleIdentity);
$defaultIdentity = $singleIdentity->id;
//$defaultIdentity = $key;
$sessionData['signatureID'] = (!empty($singleIdentity->signature) ? $singleIdentity->signature : $sessionData['signatureID']);
}
}
$selectFrom = html::select('identity', (!empty($presetId) ? $presetId : $defaultIdentity), $identities, true, "style='width:100%;' onchange='changeIdentity(this);'");
/*
$this->t->set_var('select_from', $selectFrom);
//error_log(__METHOD__.__LINE__.' DefaultIdentity:'.array2string($identities[($presetId ? $presetId : $defaultIdentity)]));
// navbar(, kind of)
$this->t->set_var('img_clear_left', common::image('felamimail','clear_left'));
$this->t->set_var('img_fileopen', common::image('phpgwapi','fileopen'));
$this->t->set_var('img_mail_send', common::image('felamimail','mail_send'));
$this->t->set_var('img_attach_file', common::image('felamimail','attach'));
$this->t->set_var('ajax-loader', common::image('felamimail','ajax-loader'));
$this->t->set_var('img_fileexport', common::image('felamimail','fileexport'));
// prepare print url/button
$this->t->set_var('img_print_it', common::image('felamimail','print'));
$this->t->set_var('lang_print_it', lang('print it'));
$this->t->set_var('print_it', $printURL);
*/
// from, to, cc, replyto
$destinationRows = 0;
foreach(array('to','cc','bcc','replyto','folder') as $destination) {
foreach((array)$sessionData[$destination] as $key => $value) {
if ($value=="NIL@NIL") continue;
if ($destination=='replyto' && str_replace('"','',$value) == str_replace('"','',$identities[($presetId ? $presetId : $defaultIdentity)])) continue;
//error_log(__METHOD__.__LINE__.array2string(array('key'=>$key,'value'=>$value)));
$selectDestination = html::select('destination[]', $destination, $this->destinations, false, "style='width: 100%;' onchange='fm_compose_changeInputType(this)'");
//$this->t->set_var('select_destination', $selectDestination);
$value = htmlspecialchars_decode($value,ENT_COMPAT);
$value = str_replace("\"\"",'"',$value);
$address_array = imap_rfc822_parse_adrlist((get_magic_quotes_gpc()?stripslashes($value):$value), '');
foreach((array)$address_array as $addressObject) {
if ($addressObject->host == '.SYNTAX-ERROR.') continue;
$address = imap_rfc822_write_address($addressObject->mailbox,$addressObject->host,$addressObject->personal);
$address = mail_bo::htmlentities($address, $this->displayCharset);
//$this->t->set_var('address', ($destination=='folder'?$value:$address));
//$this->t->parse('destinationRows','destination_row',True);
$destinationRows++;
}
}
}
while($destinationRows < 3) {
// and always add one empty row
$selectDestination = html::select('destination[]', 'to', $this->destinations, false, "style='width: 100%;' onchange='fm_compose_changeInputType(this)'");
/*
$this->t->set_var('select_destination', $selectDestination);
$this->t->set_var('address', '');
$this->t->parse('destinationRows','destination_row',True);
*/
$destinationRows++;
}
// and always add one empty row
$selectDestination = html::select('destination[]', 'to', $this->destinations, false, "style='width: 100%;' onchange='fm_compose_changeInputType(this)'");
/*
$this->t->set_var('select_destination', $selectDestination);
$this->t->set_var('address', '');
$this->t->parse('destinationRows','destination_row',True);
*/
// handle subject
$subject = mail_bo::htmlentities($sessionData['subject'],$this->displayCharset);
@ -798,11 +698,61 @@ class mail_compose
$this->t->set_var('lang_no_recipient',lang('No recipient address given!'));
$this->t->set_var('lang_no_subject',lang('No subject given!'));
$this->t->set_var('lang_infolog_tracker_not_both',lang("You can either choose to save as infolog OR tracker, not both."));
$this->t->pparse("out","header");
*/
// prepare signatures, the selected sig may be used on top of the body
require_once(EGW_INCLUDE_ROOT.'/felamimail/inc/class.felamimail_bosignatures.inc.php');
$boSignatures = new felamimail_bosignatures();
//identities and signature stuff
$allIdentities = $this->preferences->getIdentity();
unset($allIdentities[0]);
//_debug_array($allIdentities);
if (is_null(mail_bo::$mailConfig)) mail_bo::$mailConfig = config::read('mail');
// not set? -> use default, means full display of all available data
if (!isset(mail_bo::$mailConfig['how2displayIdentities'])) mail_bo::$mailConfig['how2displayIdentities'] ='';
$globalIds = 0;
$defaultIds = array();
foreach($allIdentities as $key => $singleIdentity) {
if ($singleIdentity->id<0){ $globalIds++; }/*else{ unset($allIdentities[$key]);}*/
// there could be up to 2 default IDS. the activeProfile and another on marking the desired Identity to choose
if(!empty($singleIdentity->default) && $singleIdentity->default==1)
{
$defaultIds[$singleIdentity->id] = $singleIdentity->id;
$selectedSender = mail_bo::generateIdentityString($singleIdentity);
}
}
//error_log(__METHOD__.__LINE__.' Identities regarded/marked as default:'.array2string($defaultIds). ' MailProfileActive:'.$this->mail_bo->profileID);
// if there are 2 defaultIDs, its most likely, that the user choose to set
// the one not being the activeServerProfile to be his default Identity
if (count($defaultIds)>1) unset($defaultIds[$this->mail_bo->profileID]);
$defaultIdentity = 0;
$identities = array();
foreach($allIdentities as $key => $singleIdentity) {
//$identities[$singleIdentity->id] = $singleIdentity->realName.' <'.$singleIdentity->emailAddress.'>';
$iS = mail_bo::generateIdentityString($singleIdentity);
$shortIDString = trim(mail_bo::generateIdentityString($singleIdentity,false));
if (mail_bo::$mailConfig['how2displayIdentities']=='' || count($allIdentities) ==1 || count($allIdentities) ==$globalIds)
{
$id_prepend ='';
}
else
{
$id_prepend = '('.$singleIdentity->id.') ';
}
//if ($singleIdentity->default) error_log(__METHOD__.__LINE__.':'.$presetId.'->'.$key.'('.$singleIdentity->id.')'.'#'.$iS.'#');
if (array_search($id_prepend.$iS,$identities)===false)
{
$identities[$singleIdentity->id] = $id_prepend.$iS;
$sel_options['SENDER'][$iS] = $id_prepend.$iS;
}
if(in_array($singleIdentity->id,$defaultIds) && $defaultIdentity==0)
{
//_debug_array($singleIdentity);
$defaultIdentity = $singleIdentity->id;
//$defaultIdentity = $key;
$sessionData['signatureID'] = (!empty($singleIdentity->signature) ? $singleIdentity->signature : $sessionData['signatureID']);
}
}
// fetch the signature, prepare the select box, ...
$boSignatures = new mail_signatures();
$signatures = $boSignatures->getListOfSignatures();
if (empty($sessionData['signatureID'])) {
@ -883,6 +833,7 @@ class mail_compose
$sessionData['body'] = ($font_span?$font_span:'&nbsp;').$sessionData['body'];
}
//error_log(__METHOD__.__LINE__.$sessionData['body']);
// prepare body
// in a way, this tests if we are having real utf-8 (the displayCharset) by now; we should if charsets reported (or detected) are correct
if (strtoupper($this->displayCharset) == 'UTF-8')
@ -922,32 +873,12 @@ class mail_compose
} else {
$border="1px solid gray; margin:1px";
// initalize the CKEditor Object to enable switching back and force
$editor = html::fckEditorQuick('body', 'ascii', $sessionData['body'],'500px','99%',false,$border);
/*
$this->t->set_var('tinymce', $editor); //html::fckEditorQuick('body', 'ascii', $sessionData['body'],'400px','99%'));
$this->t->set_var('mimeType', 'text');
*/
//$editor = html::fckEditorQuick('body', 'ascii', $sessionData['body'],'500px','99%',false,$border);
$ishtml=0;
}
$bostationery = new felamimail_bostationery();
$selectStationeries = array(
'0' => lang('no stationery')
);
$showStationaries = false;
$validStationaries = $bostationery->get_valid_templates();
if (is_array($validStationaries) && count($validStationaries)>0)
{
$showStationaries = true;
$selectStationeries += $validStationaries;
}
// if ID of signature Select Box is set, we allow for changing the sig onChange of the signatueSelect
$selectBoxSignature = html::select('signatureID', ($presetSig ? $presetSig : $sessionData['signatureID']), $selectSignatures, true, ($insertSigOnTop?"id='signatureID'":"")." style='width: 35%;' onchange='fm_compose_changeInputType(this)'");
$selectBoxStationery = html::select('stationeryID', ($presetStationery ? $presetStationery : 0), $selectStationeries, true, "style='width: 35%;'");
/*
$this->t->set_var("select_signature", $selectBoxSignature);
$this->t->set_var("select_stationery", ($showStationaries ? $selectBoxStationery:''));
$this->t->set_var("lang_editormode",lang("Editor type"));
if (html::htmlarea_availible()===false)
{
@ -958,7 +889,6 @@ class mail_compose
// IE seems to need onclick to realize there is a change
$this->t->set_var("toggle_editormode", lang("Editor type").":&nbsp;<span><input name=\"_is_html\" value=\"".$ishtml."\" type=\"hidden\" /><input name=\"_editorselect\" onchange=\"fm_toggle_editor(this)\" onclick=\"fm_toggle_editor(this)\" ".($ishtml ? "checked=\"checked\"" : "")." id=\"_html\" value=\"html\" type=\"radio\"><label for=\"_html\">HTML</label><input name=\"_editorselect\" onchange=\"fm_toggle_editor(this)\" onclick=\"fm_toggle_editor(this)\" ".($ishtml ? "" : "checked=\"checked\"")." id=\"_plain\" value=\"plain\" type=\"radio\"><label for=\"_plain\">Plain text</label></span>");
}
$this->t->pparse("out","body_input");
*/
// attachments
if (is_array($sessionData['attachments']) && count($sessionData['attachments']) > 0)
@ -986,12 +916,89 @@ class mail_compose
// $this->t->set_var('attachment_rows','');
}
// $this->t->pparse("out","attachment");
$content['is_html'] = $this->sessionData['mimeType'] == 'html';
$content['mailtext'] = 'garbage';
// signature stuff set earlier
$sel_options['signatureID'] = $selectSignatures;
$content['signatureID'] = ($presetSig ? $presetSig : $sessionData['signatureID']);
// end signature stuff
// stationery stuff
$bostationery = new emailadmin_bostationery();
$selectStationeries = array(
'0' => lang('no stationery')
);
$showStationaries = false;
$validStationaries = $bostationery->get_valid_templates();
if (is_array($validStationaries) && count($validStationaries)>0)
{
$showStationaries = true;
$selectStationeries += $validStationaries;
}
//_debug_array($selectStationeries);
$sel_options['stationeryID'] = $selectStationeries;
// if ID of signature Select Box is set, we allow for changing the sig onChange of the signatueSelect
$content['stationeryID'] = ($presetStationery ? $presetStationery : 0);
// end stationery stuff
//$sessionData['bcc'] = array('kl@stylite.de','kl@leithoff.net');
// address stuff like from, to, cc, replyto
$destinationRows = 0;
foreach(array('to','cc','bcc','replyto','folder') as $destination) {
foreach((array)$sessionData[$destination] as $key => $value) {
if ($value=="NIL@NIL") continue;
if ($destination=='replyto' && str_replace('"','',$value) == str_replace('"','',$identities[($presetId ? $presetId : $defaultIdentity)])) continue;
//error_log(__METHOD__.__LINE__.array2string(array('key'=>$key,'value'=>$value)));
$selectDestination = html::select('destination[]', $destination, $this->destinations, false, "style='width: 100%;' onchange='fm_compose_changeInputType(this)'");
//$this->t->set_var('select_destination', $selectDestination);
$value = htmlspecialchars_decode($value,ENT_COMPAT);
$value = str_replace("\"\"",'"',$value);
$address_array = imap_rfc822_parse_adrlist((get_magic_quotes_gpc()?stripslashes($value):$value), '');
foreach((array)$address_array as $addressObject) {
if ($addressObject->host == '.SYNTAX-ERROR.') continue;
$address = imap_rfc822_write_address($addressObject->mailbox,$addressObject->host,$addressObject->personal);
//$address = mail_bo::htmlentities($address, $this->displayCharset);
$content[strtoupper($destination)][]=$address;
$destinationRows++;
}
}
}
if ($content)
{
}
else
{
$content['is_html'] = ($this->sessionData['mimeType'] == 'html'?true:'');
$content['is_plain'] = ($this->sessionData['mimeType'] == 'html'?'':true);
//error_log(__METHOD__.__LINE__.array2string(array($sel_options['SENDER'],$selectedSender)));
$content['SENDER'] = ($selectedSender?(array)$selectedSender:'');
//error_log(__METHOD__.__LINE__.$sessionData['body']);
$content['mail_'.($this->sessionData['mimeType'] == 'html'?'html':'plain').'text'] = $sessionData['body'];
}
$etpl = new etemplate_new('mail.compose');
$etpl->exec('mail.mail_compose.compose',$content,$sel_options,$readonlys,$preserv,2);
}
function testhtmlarea($content=null)
{
error_log(__METHOD__.__LINE__.array2string($content));
if ($content)
{
$this->sessionData['mimeType'] = 'plain';
$content['is_html'] = ($this->sessionData['mimeType'] == 'html'?true:'');
$content['is_plain'] = ($this->sessionData['mimeType'] == 'html'?'':true);
}
else
{
$sessionData['body'] = 'bla bla bla';
$content['is_html'] = ($this->sessionData['mimeType'] == 'html'?true:'');
$content['is_plain'] = ($this->sessionData['mimeType'] == 'html'?'':true);
//error_log(__METHOD__.__LINE__.array2string(array($sel_options['SENDER'],$selectedSender)));
$content['SENDER'] = ($selectedSender?(array)$selectedSender:'');
//error_log(__METHOD__.__LINE__.$sessionData['body']);
$content['mail_'.($this->sessionData['mimeType'] == 'html'?'html':'plain').'text'] = $sessionData['body'];
}
$etpl = new etemplate_new('mail.testhtmlarea');
$etpl->exec('mail.mail_compose.testhtmlarea',$content,$sel_options,$readonlys,$preserv,2);
}
function composeFromDraft() {
$icServer = (int)$_GET['icServer'];
$folder = (isset($_GET['folder'])?base64_decode($_GET['folder']):base64_decode($_GET['mailbox']));
@ -2492,6 +2499,34 @@ $content['mailtext'] = 'garbage';
}
function ajax_searchIdentities() {
$_searchString = trim($_REQUEST['query']);
$allIdentities = $this->preferences->getIdentity();
foreach($allIdentities as $key => $singleIdentity)
{
/*
if($singleIdentity->default === true)
{
$selectedAddresses[$singleIdentity->emailAddress] = $singleIdentity->emailAddress;
}
*/
$idString = mail_bo::generateIdentityString($singleIdentity);
$shortIDString = mail_bo::generateIdentityString($singleIdentity,false);
if (empty($_searchString) || ($_searchString && stripos($idString,$_searchString)!==false))
{
//error_log(__METHOD__.__LINE__.$idString.'<->'.$shortIDString);
$predefinedAddresses[$idString] = array(
'id'=>$idString,
'label' => $idString,
// Add just name for nice display, with title for hover
'name' => $shortIDString,
'title' => $idString
);
}
}
if (is_array($predefinedAddresses)) asort($predefinedAddresses);
header('Content-Type: application/json; charset=utf-8');
echo json_encode($predefinedAddresses);
common::egw_exit();
}
function ajax_searchFolder() {
@ -2536,7 +2571,7 @@ $content['mailtext'] = 'garbage';
}
public static function ajax_searchAddress() {
error_log(__METHOD__. "request from seachAddress" . $_REQUEST['query']);
//error_log(__METHOD__. "request from seachAddress " . $_REQUEST['query']);
$_searchString = trim($_REQUEST['query']);
if ($GLOBALS['egw_info']['user']['apps']['addressbook']) {
//error_log(__METHOD__.__LINE__.array2string($_searchString));

View File

@ -799,6 +799,12 @@ class mail_hooks
'link'=>false,
'icon' => false
);
$file[] = array(
'no_lang' => true,
'text'=>'<span id="mail-index_buttontesthtmlarea" class="button" />',
'link'=>false,
'icon' => false
);
$file[] = array(
'no_lang' => true,
'text'=>'<span id="mail-tree_target" class="dtree" />',

View File

@ -0,0 +1,296 @@
<?php
/**
* EGroupware - Mail - interface class for compose mails in popup
*
* @link http://www.egroupware.org
* @package mail
* @author Klaus Leithoff [kl@stylite.de]
* @copyright (c) 2013 by Klaus Leithoff <kl-AT-stylite.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
class mail_signatures
{
var $tableName = 'egw_felamimail_signatures';
var $fm_signatureid = NULL;
var $fm_description = NULL;
var $fm_signature = NULL;
var $fm_defaultsignature = NULL;
var $boemailadmin;
var $profileData;
function mail_signatures($_signatureID = NULL) {
$this->accountID = $GLOBALS['egw_info']['user']['account_id'];
if($_signatureID !== NULL) {
$this->read($_signatureID);
}
$this->boemailadmin = new emailadmin_bo();
$this->profileData = $this->boemailadmin->getUserProfile('felamimail');
}
function getDefaultSignature() {
$db = clone($GLOBALS['egw']->db);
$db->set_app('felamimail');
$where = array(
'fm_accountid' => $this->accountID,
'fm_defaultsignature' => true
);
$db->select($this->tableName,'fm_signatureid,fm_description,fm_signature,fm_defaultsignature',
$where, __LINE__, __FILE__);
if(($row = $db->row(true))) {
return $row['fm_signatureid'];
}
return false;
}
function read($_signatureID) {
$db = clone($GLOBALS['egw']->db);
$db->set_app('felamimail');
$where = array(
'fm_accountid' => $this->accountID,
'fm_signatureid' => $_signatureID
);
$db->select($this->tableName,'fm_signatureid,fm_description,fm_signature,fm_defaultsignature',
$where, __LINE__, __FILE__);
if(($data = $db->row(true))) {
if (empty($data['fm_description']))
{
$buff = trim(substr(str_replace(array("\r\n","\r","\n","\t"),array(" "," "," "," "),translation::convertHTMLToText($data['fm_signature'])),0,100));
$data['fm_description'] = $buff?$buff:lang('none');
}
$this->fm_signatureid = $data['fm_signatureid'];
$this->fm_description = $data['fm_description'];
$this->fm_signature = $data['fm_signature'];
$this->fm_defaultsignature = (bool)$data['fm_defaultsignature'];
return TRUE;
}
return FALSE;
}
function deleteSignatures($_signatureID)
{
if(!is_array($_signatureID)) {
return false;
}
foreach($_signatureID as $signatureID) {
#error_log("$signatureID");
$this->delete($signatureID);
}
}
private function delete($_signatureID = FALSE) {
$db = clone($GLOBALS['egw']->db);
$db->set_app('felamimail');
if($_signatureID !== FALSE) {
$signatureID = (int)$_signatureID;
} else {
$signatureID = (int)$this->fm_signatureid;
}
$where = array(
'fm_accountid' => $this->accountID,
'fm_signatureid' => $signatureID
);
$db->delete($this->tableName, $where, __LINE__, __FILE__);
if ($db->affected_rows() === 0) {
return false;
}
return true;
}
function saveSignature($_signatureID, $_description, $_signature, $_isDefaultSignature)
{
if($_signatureID == -1) {
// the systemwide profile
// can only be made the default profile
return -1;
} else {
if($this->profileData->ea_user_defined_signatures == false) {
return false;
}
$this->fm_description = $_description;
$this->fm_signature = $_signature;
$this->fm_defaultsignature = (bool)$_isDefaultSignature;
if((int)$_signatureID > 0) {
$this->fm_signatureid = (int)$_signatureID;
}
$this->save();
return $this->fm_signatureid;
}
}
private function save() {
$db = clone($GLOBALS['egw']->db);
$db->set_app('felamimail');
// reset fm_defaultsignature in all other rows to false
if($this->fm_defaultsignature === true) {
$where = array(
'fm_accountid' => $this->accountID,
);
$data = array(
'fm_defaultsignature' => false,
);
$db->update($this->tableName, $data, $where, __LINE__, __FILE__);
}
if (empty($this->fm_description))
{
$buff = trim(substr(str_replace(array("\r\n","\r","\n","\t"),array(" "," "," "," "),translation::convertHTMLToText($this->fm_signature)),0,100));
$this->fm_description = $buff?$buff:lang('none');
}
$data = array(
'fm_accountid' => $this->accountID,
'fm_signature' => $this->fm_signature,
'fm_description' => $this->fm_description,
'fm_defaultsignature' => $this->fm_defaultsignature,
);
if($this->fm_signatureid === NULL) {
$db->insert($this->tableName, $data, '', __LINE__, __FILE__);
$this->fm_signatureid = $db->get_last_insert_id($this->tableName,'fm_signatureid');
return TRUE;
} else {
$where = array(
'fm_accountid' => $this->accountID,
'fm_signatureid' => $this->fm_signatureid,
);
$db->update($this->tableName, $data, $where, __LINE__, __FILE__);
return TRUE;
}
}
function search() {
$signatures = array();
$db = clone($GLOBALS['egw']->db);
$db->set_app('felamimail');
$where = array(
'fm_accountid' => $this->accountID
);
$db->select($this->tableName,'fm_signatureid,fm_description,fm_signature,fm_defaultsignature',
$where, __LINE__, __FILE__);
while ($data = $db->row(true)) {
if (empty($data['fm_description']))
{
$buff = trim(substr(str_replace(array("\r\n","\r","\n","\t"),array(" "," "," "," "),translation::convertHTMLToText($data['fm_signature'])),0,100));
$data['fm_description'] = $buff?$buff:lang('none');
}
$signatureData = array(
'fm_signatureid' => $data['fm_signatureid'],
'fm_description' => $data['fm_description'],
'fm_signature' => $data['fm_signature'],
'fm_defaultsignature' => (bool)$data['fm_defaultsignature'],
);
$signatures[$data['fm_signatureid']] = $signatureData;
}
return $signatures;
}
function getListOfSignatures() {
//$fmSignatures = new felamimail_signatures();
#$profileData = $boemailadmin->getUserProfile('felamimail');
$systemSignatures = array();
if(!empty($this->profileData->ea_default_signature)) {
$systemSignatures[-1] = array(
'fm_signatureid' => -1,
'fm_description' => lang('system signature'),
'fm_defaultsignature' => FALSE,
);
if($this->profileData->ea_user_defined_signatures != true) {
$systemSignatures[-1]['fm_defaultsignature'] = TRUE;
}
}
// return only systemsignature, if no user defined signatures are enabled
if($this->profileData->ea_user_defined_signatures != true) {
return $systemSignatures;
}
$signatures = $this->search();
if(count($signatures) == 0 &&
!isset($GLOBALS['egw_info']['user']['preferences']['mail']['email_sig_copied']) &&
!empty($GLOBALS['egw_info']['user']['preferences']['mail']['email_sig'])) {
$GLOBALS['egw']->preferences->read_repository();
$newSignature = new mail_signatures();
$newSignature->fm_description = lang('default signature');
$newSignature->fm_signature = nl2br($GLOBALS['egw_info']['user']['preferences']['felamimail']['email_sig']);
$newSignature->fm_defaultsignature = true;
$newSignature->save();
$GLOBALS['egw']->preferences->add('mail', 'email_sig_copied', true);
$GLOBALS['egw']->preferences->save_repository();
$signatures = $this->search();
}
// make systemsignature the default, if no other signature is defined as default signature
if($this->getDefaultSignature() === false) {
$systemSignatures[-1]['fm_defaultsignature'] = TRUE;
}
$signatures = array_merge($systemSignatures, $signatures);
#_debug_array($signatures);
return $signatures;
}
function getSignature($_signatureID, $_unparsed = false)
{
if($_signatureID == -1) {
$systemSignatureIsDefaultSignature = $this->getDefaultSignature();
$signature = new mail_signatures();
$signature->fm_signatureid = -1;
$signature->fm_description = 'eGroupWare '. lang('default signature');
$signature->fm_signature = ($_unparsed === true ? $this->profileData->ea_default_signature : $GLOBALS['egw']->preferences->parse_notify($this->profileData->ea_default_signature));
$signature->fm_defaultsignature = $systemSignatureIsDefaultSignature;
return $signature;
} else {
$signature = new mail_signatures($_signatureID);
if($_unparsed === false) {
$signature->fm_signature = ($_unparsed === true ? $this->profileData->ea_default_signature : $GLOBALS['egw']->preferences->parse_notify($signature->fm_signature));
}
return $signature;
}
}
}
?>

View File

@ -51,6 +51,13 @@ class mail_ui
*/
static $delimiter = '::';
/**
* nextMatch name for index
*
* @var string
*/
static $nm_index = 'nm';
/**
* instance of mail_bo
*
@ -157,11 +164,11 @@ class mail_ui
if (!is_array($content))
{
$content = array(
'nm' => egw_session::appsession('index','mail'),
self::$nm_index => egw_session::appsession('index','mail'),
);
if (!is_array($content['nm']))
if (!is_array($content[self::$nm_index]))
{
$content['nm'] = array(
$content[self::$nm_index] = array(
'get_rows' => 'mail.mail_ui.get_rows', // I method/callback to request the data for the rows eg. 'notes.bo.get_rows'
'filter' => 'any', // filter is used to choose the mailbox
'no_filter2' => false, // I disable the 2. filter (params are the same as for filter)
@ -178,10 +185,10 @@ class mail_ui
'actions' => self::get_actions(),
'row_id' => 'row_id', // is a concatenation of trim($GLOBALS['egw_info']['user']['account_id']):profileID:base64_encode(FOLDERNAME):uid
);
//$content['nm']['path'] = self::get_home_dir();
//$content[self::$nm_index]['path'] = self::get_home_dir();
}
}
$content['nm']['csv_fields'] = false;
$content[self::$nm_index]['csv_fields'] = false;
if ($msg)
{
$content['msg'] = $msg;
@ -195,9 +202,9 @@ class mail_ui
$this->mail_bo->restoreSessionData();
// filter is used to choose the mailbox
//if (!isset($content['nm']['foldertree'])) // maybe we fetch the folder here
//if (!isset($content[self::$nm_index]['foldertree'])) // maybe we fetch the folder here
/*
$sel_options['nm']['foldertree'] = array('id' => 0, 'item' => array(
$sel_options[self::$nm_index]['foldertree'] = array('id' => 0, 'item' => array(
array('id' => '/INBOX', 'text' => 'INBOX', 'im0' => 'kfm_home.png', 'child' => '1', 'item' => array(
array('id' => '/INBOX/sub', 'text' => 'sub'),
array('id' => '/INBOX/sub2', 'text' => 'sub2'),
@ -207,15 +214,15 @@ class mail_ui
)),
));
$content['nm']['foldertree'] = '/INBOX/sub';
$content[self::$nm_index]['foldertree'] = '/INBOX/sub';
*/
$sel_options['nm']['foldertree'] = $this->getFolderTree(false);
$sel_options[self::$nm_index]['foldertree'] = $this->getFolderTree(false);
$sessionFolder = $this->mail_bo->sessionData['maibox'];
if ($this->mail_bo->folderExists($sessionFolder))
{
$content['nm']['selectedFolder'] = $this->mail_bo->profileID.self::$delimiter.$this->mail_bo->sessionData['maibox'];
$content[self::$nm_index]['selectedFolder'] = $this->mail_bo->profileID.self::$delimiter.$this->mail_bo->sessionData['maibox'];
$this->mail_bo->reopen($sessionFolder); // needed to fetch full set of capabilities
}
// since we are connected,(and selected the folder) we check for capabilities SUPPORTS_KEYWORDS to eventually add the keyword filters
@ -230,19 +237,18 @@ class mail_ui
));
}
if (!isset($content['nm']['foldertree'])) $content['nm']['foldertree'] = $this->mail_bo->profileID.self::$delimiter.'INBOX';
if (!isset($content['nm']['selectedFolder'])) $content['nm']['selectedFolder'] = $this->mail_bo->profileID.self::$delimiter.'INBOX';
$content['nm']['foldertree'] = $content['nm']['selectedFolder'];
if (!isset($content[self::$nm_index]['foldertree'])) $content[self::$nm_index]['foldertree'] = $this->mail_bo->profileID.self::$delimiter.'INBOX';
if (!isset($content[self::$nm_index]['selectedFolder'])) $content[self::$nm_index]['selectedFolder'] = $this->mail_bo->profileID.self::$delimiter.'INBOX';
$content[self::$nm_index]['foldertree'] = $content[self::$nm_index]['selectedFolder'];
//$sel_options['cat_id'] = array(1=>'none');
$sel_options['filter2'] = $this->searchTypes;
$sel_options['filter'] = $this->statusTypes;
//if (!isset($content['nm']['cat_id'])) $content['nm']['cat_id'] = 'All';
//if (!isset($content[self::$nm_index]['cat_id'])) $content[self::$nm_index]['cat_id'] = 'All';
$etpl = new etemplate_new('mail.index');
// Set tree actions
$etpl->set_cell_attribute('nm[foldertree]','actions', array(
$etpl->setElementAttribute(self::$nm_index.'[foldertree]','actions', array(
'drop_move_mail' => array(
'type' => 'drop',
'acceptedTypes' => 'mail',
@ -277,7 +283,7 @@ class mail_ui
)
));
//error_log(__METHOD__.__LINE__.array2string($content));
if (empty($content['nm']['filter2']) || empty($content['nm']['search'])) $content['nm']['filter2']='quick';
if (empty($content[self::$nm_index]['filter2']) || empty($content[self::$nm_index]['search'])) $content[self::$nm_index]['filter2']='quick';
$readonlys = $preserv = $sel_options;
return $etpl->exec('mail.mail_ui.index',$content,$sel_options,$readonlys,$preserv);
}
@ -686,7 +692,7 @@ class mail_ui
/**
* Get actions / context menu for index
*
* Changes here, require to log out, as $content['nm'] get stored in session!
* Changes here, require to log out, as $content[self::$nm_index] get stored in session!
* @var &$action_links
*
* @return array see nextmatch_widget::egw_actions()
@ -1593,9 +1599,13 @@ unset($query['actions']);
),
));
*/
egw_framework::set_onload("");
$subject = mail_bo::htmlspecialchars($this->mail_bo->decode_subject(preg_replace($nonDisplayAbleCharacters,'',$envelope['SUBJECT']),false),
mail_bo::$displayCharset);
egw_framework::set_onload('$j(document).ready(function() {
var subject = etemplate2.getByApplication(\'mail\')[0].widgetContainer.getWidgetById(\'mail_displaysubject\');
var body = etemplate2.getByApplication(\'mail\')[0].widgetContainer.getWidgetById(\'mail_displaybody\');
body.node.parentNode.style.top=subject.node.offsetTop+40+\'px\';
});');
$subject = /*mail_bo::htmlspecialchars(*/$this->mail_bo->decode_subject(preg_replace($nonDisplayAbleCharacters,'',$envelope['SUBJECT']),false)/*,
mail_bo::$displayCharset)*/;
if($envelope['FROM'][0] != $envelope['SENDER'][0]) {
$content['mail_displayfromaddress'] = self::emailAddressToHTML($envelope['SENDER'],'',false,true,false);
$content['mail_displayonbehalfofaddress'] = self::emailAddressToHTML($envelope['FROM'], $organization,false,true,false);
@ -2158,8 +2168,22 @@ unset($query['actions']);
!fwrite($fp,$message))
{
$err .= 'alert("'.addslashes(lang('Error saving %1!',$file)).'");';
$succeeded = false;
}
else
{
$succeeded = true;
}
if ($fp) fclose($fp);
if ($succeeded)
{
translation::add_app('mail');
$headers = $this->bmail_bo->getMessageHeader($uid,$partID,true);
unset($headers['SUBJECT']);//already in filename
$infoSection = mail_bo::createHeaderInfoSection($headers, 'SUPPRESS', false);
$props = array(array('name' => 'comment','val' => $infoSection));
egw_vfs::proppatch($file,$props);
}
}
//$this->mail_bo->closeConnection();

View File

@ -11,6 +11,7 @@
app.mail = AppJS.extend(
{
appname: 'mail',
/**
* et2 widget container
*/
@ -26,6 +27,8 @@ app.mail = AppJS.extend(
mail_currentlyFocussed: '',
mail_previewAreaActive: true, // we start with the area active
nm_index: 'nm', // nm nome of index
/**
* Initialize javascript for this application
*
@ -87,7 +90,7 @@ app.mail = AppJS.extend(
{
if (_reset == true)
{
//var nm = etemplate2.getByApplication('mail')[0].widgetContainer.getWidgetById('nm');
//var nm = etemplate2.getByApplication('mail')[0].widgetContainer.getWidgetById(nm_index);
//if (this.mail_currentlyFocussed!='') nm.refresh([this.mail_currentlyFocussed],'delete');//egw.dataDeleteUID(this.mail_currentlyFocussed);
if (this.mail_currentlyFocussed!='') egw.dataDeleteUID(this.mail_currentlyFocussed);
for(var k = 0; k < this.mail_selectedMails.length; k++) egw.dataDeleteUID(this.mail_selectedMails[k]);
@ -233,6 +236,19 @@ app.mail = AppJS.extend(
}
},
/**
* Compose, reply or forward a message
*
* @param _action _action.id is 'compose', 'composeasnew', 'reply', 'reply_all' or 'forward' (forward can be multiple messages)
* @param _elems _elems[0].id is the row-id
*/
mail_testhtmlarea: function(_action, _elems)
{
var url = window.egw_webserverUrl+'/index.php?';
url += 'menuaction=mail.mail_compose.testhtmlarea';
egw_openWindowCentered(url);
},
/**
* Compose, reply or forward a message
*
@ -414,7 +430,7 @@ app.mail = AppJS.extend(
}
try
{
var tree_wdg = etemplate2.getByApplication('mail')[0].widgetContainer.getWidgetById('nm[foldertree]');
var tree_wdg = etemplate2.getByApplication('mail')[0].widgetContainer.getWidgetById(this.nm_index+'[foldertree]');
var activeFolders = tree_wdg.getTreeNodeOpenItems(nodeToRefresh,mode2use);
//alert(activeFolders.join('#,#'));
@ -456,7 +472,7 @@ app.mail = AppJS.extend(
* mail_setFolderStatus, function to set the status for the visible folders
*/
mail_setFolderStatus: function(_status) {
var ftree = etemplate2.getByApplication('mail')[0].widgetContainer.getWidgetById('nm[foldertree]');
var ftree = etemplate2.getByApplication('mail')[0].widgetContainer.getWidgetById(this.nm_index+'[foldertree]');
for (var i in _status) ftree.setLabel(i,_status[i]);//alert(i +'->'+_status[i]);
},
@ -468,7 +484,7 @@ app.mail = AppJS.extend(
*/
mail_setLeaf: function(_status) {
//console.log('mail_setLeaf',_status);
var ftree = etemplate2.getByApplication('mail')[0].widgetContainer.getWidgetById('nm[foldertree]');
var ftree = etemplate2.getByApplication('mail')[0].widgetContainer.getWidgetById(this.nm_index+'[foldertree]');
var selectedNode = ftree.getSelectedNode();
for (var i in _status)
{
@ -478,7 +494,7 @@ app.mail = AppJS.extend(
//alert(i +'->'+_status[i]['id']+'+'+_status[i]['desc']);
if (_status[i]['id']==selectedNode.id)
{
var nm = etemplate2.getByApplication('mail')[0].widgetContainer.getWidgetById('nm');
var nm = etemplate2.getByApplication('mail')[0].widgetContainer.getWidgetById(this.nm_index);
nm.activeFilters["selectedFolder"] = _status[i]['id'];
nm.applyFilters();
}
@ -493,7 +509,7 @@ app.mail = AppJS.extend(
*/
mail_removeLeaf: function(_status) {
//console.log('mail_removeLeaf',_status);
var ftree = etemplate2.getByApplication('mail')[0].widgetContainer.getWidgetById('nm[foldertree]');
var ftree = etemplate2.getByApplication('mail')[0].widgetContainer.getWidgetById(this.nm_index+'[foldertree]');
var selectedNode = ftree.getSelectedNode();
for (var i in _status)
{
@ -504,7 +520,7 @@ app.mail = AppJS.extend(
//alert(i +'->'+_status[i]['id']+'+'+_status[i]['desc']);
if (selectedNodeAfter.id!=selectedNode.id && selectedNode.id==i)
{
var nm = etemplate2.getByApplication('mail')[0].widgetContainer.getWidgetById('nm');
var nm = etemplate2.getByApplication('mail')[0].widgetContainer.getWidgetById(this.nm_index);
nm.activeFilters["selectedFolder"] = selectedNodeAfter.id;
nm.applyFilters();
}
@ -519,7 +535,7 @@ app.mail = AppJS.extend(
*/
mail_reloadNode: function(_status) {
//console.log('mail_reloadNode',_status);
var ftree = etemplate2.getByApplication('mail')[0].widgetContainer.getWidgetById('nm[foldertree]');
var ftree = etemplate2.getByApplication('mail')[0].widgetContainer.getWidgetById(this.nm_index+'[foldertree]');
var selectedNode = ftree.getSelectedNode();
for (var i in _status)
{
@ -530,7 +546,7 @@ app.mail = AppJS.extend(
//alert(i +'->'+_status[i]['id']+'+'+_status[i]['desc']);
if (selectedNodeAfter.id!=selectedNode.id && selectedNode.id==i)
{
var nm = etemplate2.getByApplication('mail')[0].widgetContainer.getWidgetById('nm');
var nm = etemplate2.getByApplication('mail')[0].widgetContainer.getWidgetById(this.nm_index);
nm.activeFilters["selectedFolder"] = selectedNodeAfter.id;
nm.applyFilters();
}
@ -541,7 +557,7 @@ app.mail = AppJS.extend(
* mail_refreshMessageGrid, function to call to reread ofthe current folder
*/
mail_refreshMessageGrid: function() {
var nm = etemplate2.getByApplication('mail')[0].widgetContainer.getWidgetById('nm');
var nm = etemplate2.getByApplication('mail')[0].widgetContainer.getWidgetById(this.nm_index);
nm.applyFilters(); // this should refresh the active folder
},
@ -744,7 +760,7 @@ app.mail = AppJS.extend(
_widget.set_value('');
}
}
var nm = _widget.getRoot().getWidgetById('nm');
var nm = _widget.getRoot().getWidgetById(this.nm_index);
nm.activeFilters["selectedFolder"] = folder;
//nm.applyFilters();// its done in refrefreshMessageGrid
var msg = _widget.getRoot().getWidgetById('msg');
@ -983,7 +999,7 @@ app.mail = AppJS.extend(
}
else
{
var nm = etemplate2.getByApplication('mail')[0].widgetContainer.getWidgetById('nm');
var nm = etemplate2.getByApplication('mail')[0].widgetContainer.getWidgetById(this.nm_index);
var aO = nm.controller._objectManager.selectedChildren;
for (var i = 0; i < _actionObjects['msg'].length; i++)
{
@ -1028,7 +1044,7 @@ app.mail = AppJS.extend(
// as the "onNodeSelect" function!
var request = new egw_json_request('mail.mail_ui.ajax_moveMessages',[target, messages]);
request.sendRequest(false);
var nm = etemplate2.getByApplication('mail')[0].widgetContainer.getWidgetById('nm');
var nm = etemplate2.getByApplication('mail')[0].widgetContainer.getWidgetById(this.nm_index);
this.mail_setRowClass(_senders,'deleted');
nm.refresh(messages['msg'],'delete')
//for (var i = 0; i < messages['msg'].length; i++) egw.dataDeleteUID(messages['msg'][i]);
@ -1063,7 +1079,7 @@ app.mail = AppJS.extend(
//console.log(action,_senders);
//action.id == 'add'
//_senders.iface.id == target leaf / leaf to edit
var ftree = etemplate2.getByApplication('mail')[0].widgetContainer.getWidgetById('nm[foldertree]');
var ftree = etemplate2.getByApplication('mail')[0].widgetContainer.getWidgetById(this.nm_index+'[foldertree]');
OldFolderName = ftree.getLabel(_senders[0].iface.id);
if (jQuery(OldFolderName).text().length>0) OldFolderName = jQuery(OldFolderName).text();
OldFolderName = OldFolderName.trim();
@ -1090,7 +1106,7 @@ app.mail = AppJS.extend(
//console.log(action,_senders);
//action.id == 'rename'
//_senders.iface.id == target leaf / leaf to edit
var ftree = etemplate2.getByApplication('mail')[0].widgetContainer.getWidgetById('nm[foldertree]');
var ftree = etemplate2.getByApplication('mail')[0].widgetContainer.getWidgetById(this.nm_index+'[foldertree]');
OldFolderName = ftree.getLabel(_senders[0].iface.id);
if (jQuery(OldFolderName).text().length>0) OldFolderName = jQuery(OldFolderName).text();
OldFolderName = OldFolderName.trim();
@ -1117,7 +1133,7 @@ app.mail = AppJS.extend(
//console.log(action,_senders);
//action.id == 'delete'
//_senders.iface.id == target leaf / leaf to edit
var ftree = etemplate2.getByApplication('mail')[0].widgetContainer.getWidgetById('nm[foldertree]');
var ftree = etemplate2.getByApplication('mail')[0].widgetContainer.getWidgetById(this.nm_index+'[foldertree]');
OldFolderName = ftree.getLabel(_senders[0].iface.id);
if (jQuery(OldFolderName).text().length>0) OldFolderName = jQuery(OldFolderName).text();
OldFolderName = OldFolderName.trim();

View File

@ -6,7 +6,10 @@
<vbox class="mailCompose mailComposeHeaderSection" width="100%">
<hbox class="mailComposeHeaders" width="99%">
<description value="Identity"/>
<taglist-email id="SENDER" width="88%" allowFreeEntries="false" maxSelection="1" onclick="app.mail.address_click"/>
<taglist-email id="SENDER" width="88%" allowFreeEntries="false" maxSelection="1" autocomplete_url="mail.mail_compose.ajax_searchIdentities" onclick="app.mail.address_click"/>
</hbox>
<hbox>
<button label="Submit" id="button[apply]"/><button label="Save" id="button[save]"/>
</hbox>
<hbox class="mailComposeHeaders" width="99%">
<description value="To"/>
@ -22,7 +25,7 @@
</hbox>
<hbox class="mailComposeHeaders" width="99%">
<description value="Reply To"/>
<taglist-email id="REPLYTO" width="88%" onclick="app.mail.address_click"/>
<taglist-email id="REPLYTO" width="88%" maxSelection="1" onclick="app.mail.address_click"/>
</hbox>
<hbox class="mailComposeHeaders" width="99%">
<description value="Store to Folder"/>
@ -37,12 +40,22 @@
</hbox>
</vbox>
<vbox class="mailComposeBodySection" width="99%">
<hbox disabled="!@is_html" class="mailComposeBody">
<htmlarea span="all" id="mailtext" mode="$cont[rtfEditorFeatures]" height="320px" width="100%" toolbar="true" base_href="$cont[upload_dir]"/>
<hbox disabled="@is_plain" class="mailComposeBody">
<htmlarea span="all" name="mail_htmltext" id="mail_htmltext" mode="$cont[rtfEditorFeatures]" height="320px" width="100%" toolbar="true" base_href="$cont[upload_dir]"/>
</hbox>
<hbox disabled="@is_html" class="mailComposeBody">
<textbox multiline="true" rows="15" cols="120" width="99%" span="all" id="mailtext"/>
<textbox multiline="true" rows="15" cols="120" width="99%" span="all" name="mail_plaintext" id="mail_plaintext"/>
</hbox>
<box class="mailSignature">
<menulist>
<menupopup id="signatureID"/>
</menulist>
<description value="Stationery"/>
<menulist>
<menupopup id="stationeryID"/>
</menulist>
</box>
<box class="mailComposeAttachments">
<html id="mail_composeattachments"/>
</box>

View File

@ -40,6 +40,7 @@
<template id="mail.index" template="" lang="" group="0" version="1.9.001">
<tree autoloading="mail.mail_ui.ajax_foldertree" id="nm[foldertree]" onclick="app.mail.mail_changeFolder(widget.event_args[0],widget);" parent_node="mail-tree_target"/>
<buttononly id="button[mailcreate]" onclick="app.mail.mail_compose(false);" label="Compose" parent_node="mail-index_buttonmailcreate"/>
<buttononly id="button[testhtmlarea]" onclick="app.mail.mail_testhtmlarea(false);" label="Test HTML Area" parent_node="mail-index_buttontesthtmlarea"/>
<html id="msg"/>
<split dock_side="bottomDock" id="mailSplitter" orientation="h">
<nextmatch id="nm" onselect="app.mail.mail_preview" template="mail.index.rows"/>

View File

@ -14,7 +14,7 @@
<description value="Status"/>
<description value="rules"/>
</row>
<row class="mail_sieve_$row_count[status]" >
<row class="tr" >
<description id="${row}[ruleID]" />
<menulist>
<menupopup id="${row}[status]" readonly= "true"/>
@ -40,4 +40,4 @@
</rows>
</grid>
</template>
</overlay>
</overlay>

View File

@ -0,0 +1,17 @@
<?xml version="1.0"?>
<!-- $Id$ -->
<overlay>
<template id="mail.testhtmlarea" template="" lang="" group="0" version="1.9.001">
<hbox>
<button label="Submit" id="button[apply]"/><button label="Save" id="button[save]"/>
</hbox>
<vbox class="mailComposeBodySection" width="99%">
<hbox disabled="@is_plain" class="mailComposeBody">
<htmlarea span="all" name="mail_htmltext" id="mail_htmltext" mode="$cont[rtfEditorFeatures]" height="320px" width="100%" toolbar="true" base_href="$cont[upload_dir]"/>
</hbox>
<hbox disabled="@is_html" class="mailComposeBody">
<textbox multiline="true" rows="15" cols="120" width="99%" span="all" name="mail_plaintext" id="mail_plaintext"/>
</hbox>
</vbox>
</template>
</overlay>