mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-27 00:58:55 +01:00
stuff, to be able to do a server roundtrip for saving as draft; using vfs-file widget for compose AND import now. some removal of obsolete code; initialize quota bar
This commit is contained in:
parent
2f39c7b4dd
commit
0cea524cd7
@ -701,6 +701,33 @@ class mail_bo
|
||||
return $tretval;
|
||||
}
|
||||
|
||||
/**
|
||||
* getQuotaRoot
|
||||
* return the qouta of the users INBOX
|
||||
*
|
||||
* @return mixed array/boolean
|
||||
*/
|
||||
function getQuotaRoot()
|
||||
{
|
||||
static $quota;
|
||||
if (isset($quota)) return $quota;
|
||||
if(!$this->icServer->hasCapability('QUOTA')) {
|
||||
$quota = false;
|
||||
return false;
|
||||
}
|
||||
$quota = $this->icServer->getStorageQuotaRoot('INBOX');
|
||||
//error_log(__METHOD__.__LINE__.array2string($quota));
|
||||
if(is_array($quota)) {
|
||||
$quota = array(
|
||||
'usage' => $quota['USED'],
|
||||
'limit' => $quota['QMAX'],
|
||||
);
|
||||
} else {
|
||||
$quota = false;
|
||||
}
|
||||
return $quota;
|
||||
}
|
||||
|
||||
/**
|
||||
* getTimeOut
|
||||
*
|
||||
|
@ -284,6 +284,7 @@ class mail_compose
|
||||
// VFS Selector was used
|
||||
if (is_array($_content['selectFromVFSForCompose']))
|
||||
{
|
||||
$suppressSigOnTop = true;
|
||||
foreach ($_content['selectFromVFSForCompose'] as $i => $path)
|
||||
{
|
||||
$_content['uploadForCompose'][] = array(
|
||||
@ -298,6 +299,7 @@ class mail_compose
|
||||
// check everything that was uploaded
|
||||
if (is_array($_content['uploadForCompose']))
|
||||
{
|
||||
$suppressSigOnTop = true;
|
||||
foreach ($_content['uploadForCompose'] as $i => &$upload)
|
||||
{
|
||||
if (!isset($upload['file'])) $upload['file'] = $upload['tmp_name'];
|
||||
@ -318,6 +320,7 @@ class mail_compose
|
||||
$keysToDelete = array();
|
||||
if (!empty($_content['attachments']['delete']))
|
||||
{
|
||||
$suppressSigOnTop = true;
|
||||
$toDelete = $_content['attachments']['delete'];
|
||||
unset($_content['attachments']['delete']);
|
||||
$attachments = $_content['attachments'];
|
||||
@ -334,8 +337,10 @@ class mail_compose
|
||||
}
|
||||
$CAtFStart = array2string($_content);
|
||||
// someone clicked something like send, or saveAsDraft
|
||||
$buttonClicked = false;
|
||||
if ($_content['button']['send'])
|
||||
{
|
||||
$buttonClicked = $suppressSigOnTop = true;
|
||||
$sendOK = true;
|
||||
try
|
||||
{
|
||||
@ -352,6 +357,7 @@ $CAtFStart = array2string($_content);
|
||||
}
|
||||
if ($_content['button']['saveAsDraft'])
|
||||
{
|
||||
$buttonClicked = $suppressSigOnTop = true;
|
||||
$savedOK = true;
|
||||
try
|
||||
{
|
||||
@ -366,8 +372,12 @@ $CAtFStart = array2string($_content);
|
||||
}
|
||||
}
|
||||
// all values are empty for a new compose window
|
||||
if ($buttonClicked = false)
|
||||
{
|
||||
}
|
||||
$insertSigOnTop = false;
|
||||
$content = (is_array($_content)?$_content:array());
|
||||
$content['body'] = ($content['body'] ? $content['body'] : $content['mail_'.($content['mimeType'] == 'html'?'html':'plain').'text']);
|
||||
$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']))
|
||||
@ -750,10 +760,8 @@ $CAtFStart = array2string($_content);
|
||||
//error_log(__METHOD__.__LINE__.' DefaultIdentity:'.array2string($identities[($presetId ? $presetId : $defaultIdentity)]));
|
||||
// navbar(, kind of)
|
||||
*/
|
||||
// handle subject
|
||||
$subject = mail_bo::htmlentities($content['subject'],$this->displayCharset);
|
||||
|
||||
/*
|
||||
$this->t->set_var("subject",$subject);
|
||||
|
||||
if ($GLOBALS['egw_info']['user']['apps']['addressbook']) {
|
||||
$this->t->set_var('addressbookButton','<button class="menuButton" type="button" onclick="addybook();" title="'.lang('addressbook').'">
|
||||
@ -1017,25 +1025,23 @@ $CAtFStart = array2string($_content);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($_content)
|
||||
{
|
||||
$content = array_merge($content,$_content);
|
||||
|
||||
if (!empty($content['FOLDER'])) $sel_options['FOLDER']=$this->ajax_searchFolder(0,true);
|
||||
$content['SENDER'] = (empty($content['SENDER'])?($selectedSender?(array)$selectedSender:''):$content['SENDER']);
|
||||
$content['is_html'] = ($content['mimeType'] == 'html'?true:'');
|
||||
$content['is_plain'] = ($content['mimeType'] == 'html'?'':true);
|
||||
$content['mail_'.($content['mimeType'] == 'html'?'html':'plain').'text'] =($content['body']?$content['body']:$content['mail_'.($this->content['mimeType'] == 'html'?'html':'plain').'text']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$content['is_html'] = ($content['mimeType'] == 'html'?true:'');
|
||||
$content['is_plain'] = ($content['mimeType'] == 'html'?'':true);
|
||||
//error_log(__METHOD__.__LINE__.array2string(array($sel_options['SENDER'],$selectedSender)));
|
||||
$content['SENDER'] = ($selectedSender?(array)$selectedSender:'');
|
||||
//error_log(__METHOD__.__LINE__.$content['body']);
|
||||
$content['mail_'.($content['mimeType'] == 'html'?'html':'plain').'text'] = $content['body'];
|
||||
}
|
||||
$content['is_html'] = ($content['mimeType'] == 'html'?true:'');
|
||||
$content['is_plain'] = ($content['mimeType'] == 'html'?'':true);
|
||||
$content['mail_'.($content['mimeType'] == 'html'?'html':'plain').'text'] =$content['body'];
|
||||
$content['showtempname']=0;
|
||||
if (is_array($content['attachments']))error_log(__METHOD__.__LINE__.'before merging content with uploadforCompose:'.array2string($content['attachments']));
|
||||
$content['attachments']=(is_array($content['attachments'])&&is_array($content['uploadForCompose'])?array_merge($content['attachments'],(!empty($content['uploadForCompose'])?$content['uploadForCompose']:array())):(is_array($content['uploadForCompose'])?$content['uploadForCompose']:(is_array($content['attachments'])?$content['attachments']:null)));
|
||||
@ -1046,6 +1052,7 @@ if (is_array($content['attachments']))error_log(__METHOD__.__LINE__.'before merg
|
||||
if (is_array($content['attachments']))error_log(__METHOD__.__LINE__.' Attachments:'.array2string($content['attachments']));
|
||||
$preserv['is_html'] = $content['is_html'];
|
||||
$preserv['is_plain'] = $content['is_plain'];
|
||||
if (isset($content['mimeType'])) $preserv['mimeType'] = $content['mimeType'];
|
||||
$etpl = new etemplate_new('mail.compose');
|
||||
|
||||
$etpl->exec('mail.mail_compose.compose',$content,$sel_options,$readonlys,$preserv,2);
|
||||
|
@ -222,6 +222,21 @@ class mail_ui
|
||||
$content[self::$nm_index]['foldertree'] = '/INBOX/sub';
|
||||
*/
|
||||
|
||||
if($this->mail_bo->connectionStatus !== false) {
|
||||
$quota = $this->mail_bo->getQuotaRoot();
|
||||
} else {
|
||||
$quota['limit'] = 'NOT SET';
|
||||
}
|
||||
|
||||
if($quota !== false && $quota['limit'] != 'NOT SET') {
|
||||
$quotainfo = $this->quotaDisplay($quota['usage'], $quota['limit']);
|
||||
$content[self::$nm_index]['quota'] = $sel_options[self::$nm_index]['quota'] = $quotainfo['text'];
|
||||
$content[self::$nm_index]['quotainpercent'] = $sel_options[self::$nm_index]['quotainpercent'] = (string)$quotainfo['percent'];
|
||||
$content[self::$nm_index]['quotaclass'] = $sel_options[self::$nm_index]['quotaclass'] = $quotainfo['class'];
|
||||
} else {
|
||||
$content[self::$nm_index]['quota'] = $sel_options[self::$nm_index]['quota'] = lang("Quota not provided by server");
|
||||
}
|
||||
|
||||
$sel_options[self::$nm_index]['foldertree'] = $this->getFolderTree(false);
|
||||
|
||||
//$sessionFolder = $this->mail_bo->sessionData['maibox'];// already set and tested this earlier
|
||||
@ -1066,6 +1081,7 @@ unset($query['actions']);
|
||||
//save selected Folder to sessionData (mailbox)->currentFolder
|
||||
if (isset($query['selectedFolder'])) $this->mail_bo->sessionData['maibox']=$_folderName;
|
||||
$this->mail_bo->saveSessionData();
|
||||
|
||||
$rowsFetched['messages'] = null;
|
||||
$offset = $query['start']+1; // we always start with 1
|
||||
$maxMessages = $query['num_rows'];
|
||||
@ -1839,6 +1855,11 @@ unset($query['actions']);
|
||||
return $attachmentHTMLBlock;
|
||||
}
|
||||
|
||||
/**
|
||||
* emailAddressToHTML
|
||||
*
|
||||
*
|
||||
*/
|
||||
static function emailAddressToHTML($_emailAddress, $_organisation='', $allwaysShowMailAddress=false, $showAddToAdrdessbookLink=true, $decode=true) {
|
||||
//_debug_array($_emailAddress);
|
||||
// create some nice formated HTML for senderaddress
|
||||
@ -1969,6 +1990,47 @@ unset($query['actions']);
|
||||
return $_emailAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* display image
|
||||
*
|
||||
*
|
||||
*/
|
||||
function quotaDisplay($_usage, $_limit)
|
||||
{
|
||||
|
||||
if($_limit == 0) {
|
||||
$quotaPercent=100;
|
||||
} else {
|
||||
$quotaPercent=round(($_usage*100)/$_limit);
|
||||
}
|
||||
|
||||
$quotaLimit=mail_bo::show_readable_size($_limit*1024);
|
||||
$quotaUsage=mail_bo::show_readable_size($_usage*1024);
|
||||
|
||||
|
||||
if($quotaPercent > 90 && $_limit>0) {
|
||||
$quotaBG='mail-index_QuotaRed';
|
||||
} elseif($quotaPercent > 80 && $_limit>0) {
|
||||
$quotaBG='mail-index_QuotaYellow';
|
||||
} else {
|
||||
$quotaBG='mail-index_QuotaGreen';
|
||||
}
|
||||
|
||||
if($_limit > 0) {
|
||||
$quotaText = $quotaUsage .'/'.$quotaLimit;
|
||||
} else {
|
||||
$quotaText = $quotaUsage;
|
||||
}
|
||||
|
||||
if($quotaPercent > 50) {
|
||||
} else {
|
||||
}
|
||||
$quota['class'] = $quotaBG;
|
||||
$quota['text'] = $quotaText;
|
||||
$quota['percent'] = (string)($_usage/$_limit*100);
|
||||
return $quota;
|
||||
}
|
||||
|
||||
/**
|
||||
* display image
|
||||
*
|
||||
@ -2708,11 +2770,6 @@ blockquote[type=cite] {
|
||||
return 'background="'.$imageURL.'"';
|
||||
}
|
||||
|
||||
function setImportMessageFromVFS($target, $path=null)
|
||||
{
|
||||
return "opener.app.mail.import_closeVfsSelector('$path');";
|
||||
}
|
||||
|
||||
/**
|
||||
* importMessage
|
||||
*/
|
||||
|
@ -1184,58 +1184,6 @@ app.mail = AppJS.extend(
|
||||
}
|
||||
},
|
||||
|
||||
import_displayVfsSelector: function(_ref) {
|
||||
//var ref = this.et2.getWidgetById(_ref);
|
||||
//console.log(ref);
|
||||
cInst= this.et2.getInstanceManager();
|
||||
console.log(cInst);
|
||||
this.mail_fileSelectorWindow = egw().open_link(egw.link('/index.php', {
|
||||
menuaction: 'filemanager.filemanager_select.select',
|
||||
mode: (_ref=='import'?'open':'open-multiple'),
|
||||
method: (_ref=='import'?'mail.mail_ui.setImportMessageFromVFS':'mail.mail_compose.attachFromVFS'),
|
||||
id: _ref,//represents the target where to import to
|
||||
}), 'mail_'+(_ref=='import'?'import':'compose')+'_vfsSelector', '640x580');
|
||||
},
|
||||
|
||||
import_closeVfsSelector: function(_ref) {
|
||||
// names used here to access the popupwindows must be available, else it fails
|
||||
// names used here are assigned in app.mail.import_displayVfsSelector and class.mail_hooks.inc.php
|
||||
this.mail_fileSelectorWindow = window.open('','mail_import_vfsSelector');
|
||||
importMessageDialog = window.open('','importMessageDialog');
|
||||
var vfsfile = importMessageDialog.app.mail.et2.getWidgetById('vfsfile');
|
||||
//console.log(vfsfile);
|
||||
vfsfile.input[0].value=_ref;
|
||||
var folder = importMessageDialog.app.mail.et2.getWidgetById('FOLDER');
|
||||
//console.log(vfsfile.input[0].value,folder.value[0]);
|
||||
importMessageDialog = egw().open_link(egw.link('/index.php', {
|
||||
menuaction: 'mail.mail_ui.importMessage',
|
||||
file: vfsfile.input[0].value,
|
||||
folder: folder.value[0]
|
||||
}), 'importMessageDialog', '640x580');
|
||||
this.mail_fileSelectorWindow.close();
|
||||
importMessageDialog.focus();
|
||||
//vfsfile._parent._parent._parent.parentNode.et2_obj.submit();
|
||||
},
|
||||
|
||||
compose_closeVfsSelector: function(_ref) {
|
||||
// names used here to access the popupwindows must be available, else it fails
|
||||
// names used here are assigned in app.mail.import_displayVfsSelector and class.mail_hooks.inc.php
|
||||
this.mail_fileSelectorWindow = window.open('','mail_compose_vfsSelector');
|
||||
this.mail_fileSelectorWindow.close();
|
||||
|
||||
var vfsfile = this.et2.getWidgetById('vfsfile');
|
||||
console.log(vfsfile);
|
||||
console.log(_ref);
|
||||
//vfsfile.input[0].value=_ref;
|
||||
//console.log(vfsfile.input[0].value,folder.value[0]);
|
||||
//composeMessageDialog = egw().open_link(egw.link('/index.php', {
|
||||
// menuaction: 'mail.mail_compose.compose',
|
||||
// file: vfsfile.input[0].value
|
||||
//}), 'importMessageDialog', '640x580');
|
||||
//composeMessageDialog.focus();
|
||||
//vfsfile._parent._parent._parent.parentNode.et2_obj.submit();
|
||||
},
|
||||
|
||||
/**
|
||||
* Send names of uploaded files (again) to server, to process them: either copy to vfs or ask overwrite/rename
|
||||
*
|
||||
@ -1288,6 +1236,14 @@ app.mail = AppJS.extend(
|
||||
}
|
||||
},
|
||||
|
||||
vfsUploadForImport: function(_egw, _widget, _window) {
|
||||
console.log(_egw, _widget, _window);
|
||||
if (!jQuery.isEmptyObject(_widget.getValue()))
|
||||
{
|
||||
this.et2_obj.submit();
|
||||
}
|
||||
},
|
||||
|
||||
vfsUploadForCompose: function(_egw, _widget, _window)
|
||||
{
|
||||
console.log(_egw, _widget, _window);
|
||||
|
@ -283,6 +283,32 @@ pre {
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
}
|
||||
#mail-index {
|
||||
position: relative
|
||||
}
|
||||
.mail-index_quotabox {
|
||||
position: absolute;
|
||||
top:8px;
|
||||
right:74px;
|
||||
width:200px !important;
|
||||
z-index:99;
|
||||
}
|
||||
.mail-index_QuotaGreen, .mail-index_QuotaYellow, .mail-index_QuotaRed {
|
||||
height:12px !important;
|
||||
width:100px !important;
|
||||
}
|
||||
.mail-index_QuotaGreen > div {
|
||||
background-color: green !important;
|
||||
height:11px !important;
|
||||
}
|
||||
.mail-index_QuotaYellow > div {
|
||||
background-color: yellow !important;
|
||||
height:11px !important;
|
||||
}
|
||||
.mail-index_QuotaRed > div {
|
||||
background-color: red !important;
|
||||
height:11px !important;
|
||||
}
|
||||
/*
|
||||
influence the tree display and scrolling behavior
|
||||
*/
|
||||
|
@ -35,7 +35,7 @@
|
||||
</hbox>
|
||||
<hbox class="mailComposeHeaders" width="99%">
|
||||
<description value="Subject"/>
|
||||
<textbox align="left" width="88%" id="mail_composesubject"/>
|
||||
<textbox align="left" width="88%" id="subject"/>
|
||||
</hbox>
|
||||
<hbox class="mail_Composeicons">
|
||||
<html id="mail_composeicons"/>
|
||||
|
@ -7,15 +7,8 @@
|
||||
<hbox span="all">
|
||||
<description value="Store to Folder"/>
|
||||
<taglist id="FOLDER" width="50%" autocomplete_url='mail.mail_compose.ajax_searchFolder' autocomplete_params='' maxSelection="1" allowFreeEntries="false" onclick="app.mail.address_click"/>
|
||||
</hbox>
|
||||
<hbox span="all">
|
||||
<description value="Local Filestore"/>
|
||||
<vfs-select id="vfsfile" mode="open" mime="message/rfc822" onchange="app.mail.vfsUploadForImport"/>
|
||||
<file statustext="Select file to import into Folder" onFinish="app.mail.uploadForImport" mime="/^message\//i" id="uploadForImport" drop_target ="mail-importMessage_divImportArea"/>
|
||||
<description value="or"/>
|
||||
</hbox>
|
||||
<hbox span="all">
|
||||
<description value="Select from EGroupware Filestore"/> <textbox align="left" width="30%" id="vfsfile" />
|
||||
<buttononly id="selectFromVFSForImport" value="Select" image="filemanager/navbar" onclick="app.mail.import_displayVfsSelector('import')" />
|
||||
</hbox>
|
||||
</vbox>>
|
||||
</template>
|
||||
|
@ -39,9 +39,10 @@
|
||||
</template>
|
||||
<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"/>
|
||||
<html id="msg"/>
|
||||
<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"/>
|
||||
<hbox class="mail-index_quotabox"><description value="Quota"/><progress id="nm[quotainpercent]" label="@nm[quota]" class="@nm[quotaclass]"/></hbox>
|
||||
<split dock_side="bottomDock" id="mailSplitter" orientation="h">
|
||||
<nextmatch id="nm" onselect="app.mail.mail_preview" template="mail.index.rows"/>
|
||||
<vbox id="mailPreview" width="100%">
|
||||
|
Loading…
Reference in New Issue
Block a user