Added individual signatures for every identity.

This commit is contained in:
RainLoop Team 2015-02-08 05:11:13 +04:00
parent 996703311b
commit 1119022916
45 changed files with 1353 additions and 337 deletions

View file

@ -2098,13 +2098,14 @@ class Actions
{
$sOrder = $this->StorageProvider()->Get($oAccount,
\RainLoop\Providers\Storage\Enumerations\StorageType::CONFIG,
'accounts_order'
'accounts_identities_order'
);
$aOrder = empty($sOrder) ? array() : @\json_decode($sOrder, true);
if (\is_array($aAccounts) && \is_array($aOrder) && 0 < \count($aOrder))
if (isset($aOrder['Accounts']) && \is_array($aOrder['Accounts']) &&
1 < \count($aOrder['Accounts']))
{
$aAccounts = \array_merge(\array_flip($aOrder), $aAccounts);
$aAccounts = \array_merge(\array_flip($aOrder['Accounts']), $aAccounts);
}
}
@ -2174,6 +2175,24 @@ class Actions
\array_unshift($aIdentities,
\RainLoop\Model\Identity::NewInstanceFromAccount($oAccount));
}
if (1 < \count($aIdentities))
{
$sOrder = $this->StorageProvider()->Get($oAccount,
\RainLoop\Providers\Storage\Enumerations\StorageType::CONFIG,
'accounts_identities_order'
);
$aOrder = empty($sOrder) ? array() : @\json_decode($sOrder, true);
if (isset($aOrder['Identities']) && \is_array($aOrder['Identities']) &&
1 < \count($aOrder['Identities']))
{
$aList = $aOrder['Identities'];
\usort($aIdentities, function ($a, $b) use ($aList) {
return \array_search($a->Id(), $aList) < \array_search($b->Id(), $aList) ? -1 : 1;
});
}
}
}
return $aIdentities;
@ -2483,19 +2502,24 @@ class Actions
*
* @throws \MailSo\Base\Exceptions\Exception
*/
public function DoAccountSortOrder()
public function DoAccountsAndIdentitiesSortOrder()
{
$oAccount = $this->getAccountFromToken();
$aList = $this->GetActionParam('Accounts', null);
if (!\is_array($aList) || 2 > \count($aList))
$aAccounts = $this->GetActionParam('Accounts', null);
$aIdentities = $this->GetActionParam('Identities', null);
if (!\is_array($aAccounts) || !\is_array($aIdentities))
{
return $this->FalseResponse(__FUNCTION__);
}
return $this->DefaultResponse(__FUNCTION__, $this->StorageProvider()->Put($oAccount,
\RainLoop\Providers\Storage\Enumerations\StorageType::CONFIG, 'accounts_order',
\json_encode($aList)
\RainLoop\Providers\Storage\Enumerations\StorageType::CONFIG, 'accounts_identities_order',
\json_encode(array(
'Accounts' => $aAccounts,
'Identities' => $aIdentities
))
));
}
@ -4952,6 +4976,7 @@ class Actions
'IsSeen' => in_array('\\seen', $aLowerFlags),
'IsFlagged' => in_array('\\flagged', $aLowerFlags),
'IsAnswered' => in_array('\\answered', $aLowerFlags),
'IsDeleted' => in_array('\\deleted', $aLowerFlags),
'IsForwarded' => 0 < strlen($sForwardedFlag) && in_array(strtolower($sForwardedFlag), $aLowerFlags),
'IsReadReceipt' => 0 < strlen($sReadReceiptFlag) && in_array(strtolower($sReadReceiptFlag), $aLowerFlags)
);
@ -8503,6 +8528,7 @@ class Actions
$mResult['IsSeen'] = \in_array('\\seen', $aFlags);
$mResult['IsFlagged'] = \in_array('\\flagged', $aFlags);
$mResult['IsAnswered'] = \in_array('\\answered', $aFlags);
$mResult['IsDeleted'] = \in_array('\\deleted', $aFlags);
$sForwardedFlag = $this->Config()->Get('labs', 'imap_forwarded_flag', '');
$sReadReceiptFlag = $this->Config()->Get('labs', 'imap_read_receipt_flag', '');

View file

@ -29,6 +29,16 @@ class Identity
*/
private $sBcc;
/**
* @var string
*/
private $sSignature;
/**
* @var bool
*/
private $bSignatureInsertBefore;
/**
* @param string $sId = ''
* @param string $sEmail = ''
@ -42,6 +52,8 @@ class Identity
$this->sName = '';
$this->sReplyTo = '';
$this->sBcc = '';
$this->sSignature = '';
$this->bSignatureInsertBefore = false;
}
/**
@ -114,6 +126,22 @@ class Identity
return $this->sBcc;
}
/**
* @return string
*/
public function Signature()
{
return $this->sSignature;
}
/**
* @return bool
*/
public function SignatureInsertBefore()
{
return $this->bSignatureInsertBefore;
}
/**
* @param array $aData
* @param bool $bAjax = false
@ -129,6 +157,9 @@ class Identity
$this->sName = isset($aData['Name']) ? $aData['Name'] : '';
$this->sReplyTo = !empty($aData['ReplyTo']) ? $aData['ReplyTo'] : '';
$this->sBcc = !empty($aData['Bcc']) ? $aData['Bcc'] : '';
$this->sSignature = !empty($aData['Signature']) ? $aData['Signature'] : '';
$this->bSignatureInsertBefore = isset($aData['SignatureInsertBefore']) ?
($bAjax ? '1' === $aData['SignatureInsertBefore'] : !!$aData['SignatureInsertBefore']) : true;
return true;
}
@ -148,7 +179,9 @@ class Identity
'Email' => $bAjax ? \MailSo\Base\Utils::IdnToUtf8($this->Email()) : $this->Email(),
'Name' => $this->Name(),
'ReplyTo' => $this->ReplyTo(),
'Bcc' => $this->Bcc()
'Bcc' => $this->Bcc(),
'Signature' => $this->Signature(),
'SignatureInsertBefore' => $this->SignatureInsertBefore()
);
}

View file

@ -1,4 +1,4 @@
<div class="messageListItem" data-bind="css: lineAsCcc()">
<div class="messageListItem" data-bind="css: lineAsCss()">
<div class="sidebarParent">
&nbsp;
</div>

View file

@ -1,4 +1,4 @@
<div class="messageListItem e-single-line" data-bind="css: lineAsCcc()">
<div class="messageListItem e-single-line" data-bind="css: lineAsCss()">
<div class="sidebarParent">
&nbsp;
</div>

View file

@ -258,7 +258,7 @@
</div>
</div>
</div>
<div class="messageItem fixIndex" data-bind="css: viewLineAsCcc(), nano: true, attr: {'style': 'top:' + viewBodyTopValue() + 'px' }">
<div class="messageItem fixIndex" data-bind="css: viewLineAsCss(), nano: true, attr: {'style': 'top:' + viewBodyTopValue() + 'px' }">
<div class="content g-scrollbox" tabindex="0" data-bind="hasfocus: messageDomFocused">
<div class="content-wrapper">
<div>

View file

@ -11,12 +11,10 @@
&nbsp;&nbsp;
<span class="i18n" data-i18n-text="COMPOSE/BUTTON_SAVE"></span>
</a>
<a class="btn button-close pull-right" data-tooltip-placement="bottom" data-bind="click: tryToClosePopup, tooltip: 'COMPOSE/BUTTON_CANCEL'">
<i class="icon-remove"></i>
</a>
<a class="btn button-skip pull-right" data-tooltip-placement="bottom" data-bind="command: skipCommand, tooltip: 'COMPOSE/BUTTON_MINIMIZE'">
<i class="icon-down"></i>
</a>
<a class="close-custom" data-tooltip-placement="bottom" data-bind="click: tryToClosePopup, tooltip: 'COMPOSE/BUTTON_CANCEL'">&times;</a>
<a class="minimize-custom" data-tooltip-placement="bottom" data-bind="click: skipCommand, tooltip: 'COMPOSE/BUTTON_MINIMIZE'"></a>
<a class="btn btn-danger button-delete button-delete-transitions" data-bind="command: deleteCommand">
<i class="icon-trash icon-white"></i>
</a>

View file

@ -89,7 +89,7 @@
<span class="i18n" data-i18n-text="CONTACTS/EMPTY_SEARCH"></span>
</div>
<div class="e-contact-foreach g-ui-user-select-none" data-bind="foreach: contacts, visible: 0 < contacts().length">
<div class="e-contact-item g-ui-user-select-none" data-bind="css: lineAsCcc()">
<div class="e-contact-item g-ui-user-select-none" data-bind="css: lineAsCss()">
<div class="sidebarParent">
&nbsp;
</div>

View file

@ -18,7 +18,7 @@
<div class="control-group" data-bind="visible: !owner(), css: {'error': email.hasError}">
<label class="i18n control-label" data-i18n-text="POPUPS_IDENTITIES/LABEL_EMAIL"></label>
<div class="controls">
<input type="email" class="inputEmail input-large"
<input type="email" class="inputEmail input-xlarge"
autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"
data-bind="value: email, onEnter: addOrEditIdentityCommand, hasfocus: email.focused" />
</div>
@ -32,27 +32,55 @@
<div class="control-group">
<label class="i18n control-label" data-i18n-text="POPUPS_IDENTITIES/LABEL_NAME"></label>
<div class="controls">
<input type="text" class="inputName input-large"
<input type="text" class="inputName input-xlarge"
autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"
data-bind="value: name, onEnter: addOrEditIdentityCommand, hasfocus: name.focused" />
</div>
</div>
<div class="control-group" data-bind="css: {'error': replyTo.hasError}">
<div class="control-group" data-bind="visible: showReplyTo, css: {'error': replyTo.hasError}">
<label class="i18n control-label" data-i18n-text="POPUPS_IDENTITIES/LABEL_REPLY_TO"></label>
<div class="controls">
<input type="text" class="inputReplyTo input-large"
<input type="text" class="inputReplyTo input-xlarge"
autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"
data-bind="value: replyTo, onEnter: addOrEditIdentityCommand, hasfocus: replyTo.focused" />
</div>
</div>
<div class="control-group" data-bind="css: {'error': bcc.hasError}">
<div class="control-group" data-bind="visible: showBcc, css: {'error': bcc.hasError}">
<label class="i18n control-label" data-i18n-text="POPUPS_IDENTITIES/LABEL_BCC"></label>
<div class="controls">
<input type="text" class="inputBcc input-large"
<input type="text" class="inputBcc input-xlarge"
autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"
data-bind="value: bcc, onEnter: addOrEditIdentityCommand, hasfocus: bcc.focused" />
</div>
</div>
<div class="control-group" data-bind="visible: !showReplyTo() || !showBcc()">
<div class="controls">
<span data-bind="visible: !showReplyTo()">
<span class="i18n g-ui-link" data-i18n-text="POPUPS_IDENTITIES/LABEL_REPLY_TO"
data-bind="click: function () { showReplyTo(true); }"></span>
&nbsp;&nbsp;
</span>
<span data-bind="visible: !showBcc()">
<span class="i18n g-ui-link" data-i18n-text="POPUPS_IDENTITIES/LABEL_BCC"
data-bind="click: function () { showBcc(true); }"></span>
</span>
</div>
</div>
<hr />
<div class="control-group">
<div class="controls">
<div data-bind="component: {
name: 'Checkbox',
params: {
label: 'POPUPS_IDENTITIES/LABEL_SIGNATURE_INSERT_BEFORE',
value: signatureInsertBefore
}
}"></div>
</div>
</div>
<div class="control-group">
<div class="e-signature-place" data-bind="initDom: signatureDom"></div>
</div>
</div>
</div>
<div class="modal-footer">

View file

@ -0,0 +1,40 @@
<div class="popups">
<div class="modal hide b-template-add-content g-ui-user-select-none" data-bind="modal: modalVisibility">
<div>
<div class="modal-header">
<button type="button" class="close" data-bind="command: cancelCommand">&times;</button>
<h3>
<span data-bind="visible: '' === id()" class="i18n" data-i18n-text="POPUPS_ADD_TEMPLATE/TITLE_ADD_TEMPLATE"></span>
<span data-bind="visible: '' !== id()" class="i18n" data-i18n-text="POPUPS_ADD_TEMPLATE/TITLE_UPDATE_TEMPLATE"></span>
</h3>
</div>
<div class="modal-body">
<div class="form-horizontal">
<div class="alert" data-bind="visible: '' !== submitError()">
<button type="button" class="close" data-bind="click: function () { submitError('') }">&times;</button>
<span data-bind="text: submitError"></span>
</div>
<br />
<div class="control-group" data-bind="css: {'error': name.error}">
<label class="i18n" data-i18n-text="POPUPS_ADD_TEMPLATE/LABEL_NAME"></label>
<input type="text" class="inputName span6" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"
data-bind="textInput: name, onEnter: addTemplateCommand, hasfocus: name.focus" />
</div>
<div class="control-group" data-bind="css: {'error': body.error}">
<label class="i18n" data-i18n-text="POPUPS_ADD_TEMPLATE/LABEL_TEXT"></label>
<div class="e-body-place" data-bind="initDom: signatureDom"></div>
</div>
</div>
</div>
<div class="modal-footer">
<a class="btn buttonAddAccount" data-bind="command: addTemplateCommand">
<i data-bind="visible: '' == id(), css: {'icon-user-add': !submitRequest(), 'icon-spinner animated': submitRequest()}"></i>
<i data-bind="visible: '' !== id(), css: {'icon-ok': !submitRequest(), 'icon-spinner animated': submitRequest()}"></i>
&nbsp;&nbsp;
<span data-bind="visible: '' == id()" class="i18n" data-i18n-text="POPUPS_ADD_TEMPLATE/BUTTON_ADD_TEMPLATE"></span>
<span data-bind="visible: '' !== id()" class="i18n" data-i18n-text="POPUPS_ADD_TEMPLATE/BUTTON_UPDATE_TEMPLATE"></span>
</a>
</div>
</div>
</div>
</div>

View file

@ -26,7 +26,7 @@
<col style="width: 150px" />
<col style="width: 1%" />
</colgroup>
<tbody data-bind="sortable: {data: accounts, options: scrollableOptions()}">
<tbody data-bind="sortable: {data: accounts, options: scrollableOptions(), afterMove: accountsAndIdentitiesAfterMove}">
<tr class="account-item">
<td class="e-action" data-bind="css: {'e-action': canBeEdit}">
<span class="account-img icon-user"></span>
@ -49,17 +49,17 @@
</tbody>
</table>
<br />
<br />
<table class="table table-hover list-table identities-list" data-bind="i18nUpdate: identities">
<colgroup>
<col />
<col style="width: 150px" />
<col style="width: 1%" />
</colgroup>
<tbody data-bind="foreach: identities">
<tbody data-bind="sortable: {data: identities, options: scrollableOptions(), afterMove: accountsAndIdentitiesAfterMove}">
<tr class="identity-item">
<td class="e-action">
<span class="identity-img icon-user"></span>
<i class="icon-braille drag-handle"></i>
&nbsp;&nbsp;
<span class="identity-name" data-bind="text: formattedName()"></span>
</td>

View file

@ -138,7 +138,7 @@
}
}"></div>
&nbsp;&nbsp;
<span data-bind="click: testSoundNotification" style="color:red;cursor:pointer">
<span data-bind="click: testSoundNotification" style="color:green;cursor:pointer">
<i class="icon-right-dir iconsize20"></i>
</span>
</div>

View file

@ -0,0 +1,44 @@
<div class="b-settings-templates g-ui-user-select-none">
<div class="form-horizontal">
<div class="legend">
<span class="i18n" data-i18n-text="SETTINGS_TEMPLATES/LEGEND_TEMPLATES"></span>
</div>
</div>
<a class="btn" data-bind="click: addNewTemplate">
<i class="icon-user-add"></i>
&nbsp;&nbsp;
<span class="i18n" data-i18n-text="SETTINGS_TEMPLATES/BUTTON_ADD_TEMPLATE"></span>
</a>
<div class="process-place" data-bind="style: {'visibility': visibility }">
<i class="icon-spinner animated"></i>
&nbsp;&nbsp;
<span data-bind="text: processText"></span>
</div>
<table class="table table-hover list-table templates-list" data-bind="i18nUpdate: templates">
<colgroup>
<col />
<col style="width: 150px" />
<col style="width: 1%" />
</colgroup>
<tbody data-bind="sortable: {data: templates, options: scrollableOptions()}">
<tr class="template-item">
<td class="e-action">
<span class="template-img icon-user"></span>
<i class="icon-braille drag-handle"></i>
&nbsp;&nbsp;
<span class="template-name" data-bind="text: name"></span>
</td>
<td>
<a class="btn btn-small btn-small-small btn-danger pull-right button-delete button-delete-transitions" data-bind="css: {'delete-access': deleteAccess}, click: function(oTemplate) { $root.deleteTemplate(oTemplate); }">
<span class="i18n" data-i18n-text="SETTINGS_TEMPLATES/DELETING_ASK"></span>
</a>
</td>
<td>
<span class="delete-template" data-bind="visible: !deleteAccess(), click: function (oTemplate) { $root.templateForDeletion(oTemplate); }">
<i class="icon-trash"></i>
</span>
</td>
</tr>
</tbody>
</table>
</div>

View file

@ -249,6 +249,14 @@ BUTTON_ADD_ACCOUNT = "Add"
TITLE_UPDATE_ACCOUNT = "Update Account?"
BUTTON_UPDATE_ACCOUNT = "Update"
[POPUPS_ADD_TEMPLATE]
TITLE_ADD_TEMPLATE = "Add Template?"
BUTTON_ADD_TEMPLATE = "Add"
TITLE_UPDATE_TEMPLATE = "Update Template?"
BUTTON_UPDATE_TEMPLATE = "Update"
LABEL_NAME = "Name"
LABEL_TEXT = "Text"
[POPUPS_IDENTITIES]
TITLE_ADD_IDENTITY = "Add Identity?"
TITLE_UPDATE_IDENTITY = "Update Identity?"
@ -260,6 +268,7 @@ LABEL_REPLY_TO = "Reply-To"
LABEL_SIGNATURE = "Signature"
LABEL_CC = "Cc"
LABEL_BCC = "Bcc"
LABEL_SIGNATURE_INSERT_BEFORE = "Insert this signature before quoted text in replies"
[POPUPS_CREATE_FOLDER]
TITLE_CREATE_FOLDER = "Create a folder?"
@ -401,6 +410,7 @@ LABEL_ACCOUNTS_NAME = "Accounts"
LABEL_IDENTITY_NAME = "Identity"
LABEL_IDENTITIES_NAME = "Identities"
LABEL_FILTERS_NAME = "Filters"
LABEL_TEMPLATES_NAME = "Templates"
LABEL_SECURITY_NAME = "Security"
LABEL_SOCIAL_NAME = "Social"
LABEL_THEMES_NAME = "Themes"
@ -538,6 +548,13 @@ BUTTON_DELETE = "Delete"
LOADING_PROCESS = "Updating..."
DELETING_ASK = "Are you sure?"
[SETTINGS_TEMPLATES]
LEGEND_TEMPLATES = "Templates"
BUTTON_ADD_TEMPLATE = "Add a Template"
BUTTON_DELETE = "Delete"
LOADING_PROCESS = "Updating..."
DELETING_ASK = "Are you sure?"
[SETTINGS_IDENTITIES]
LEGEND_IDENTITY = "Identity"
LEGEND_IDENTITIES = "Additional Identities"

View file

@ -53,6 +53,17 @@
if (editor.elementMode === CKEDITOR.ELEMENT_MODE_INLINE)
return;
editor.__plainUtils = {
plainToHtml: function(data) {
return window.rainloop_Utils_plainToHtml ?
window.rainloop_Utils_plainToHtml(data, true) : simplePlainToHtml(data);
},
htmlToPlain: function(data) {
return window.rainloop_Utils_htmlToPlain ?
window.rainloop_Utils_htmlToPlain(data, true) : simpleHtmlToPlain(data);
}
};
var plain = CKEDITOR.plugins.plain;
editor.addMode('plain', function(callback) {
@ -124,9 +135,7 @@
base: CKEDITOR.editable,
proto: {
setData: function(data) {
this.setValue(window.rainloop_Utils_htmlToPlain ?
window.rainloop_Utils_htmlToPlain(data) : simpleHtmlToPlain(data));
this.setValue(this.editor.__plainUtils.htmlToPlain(data));
this.editor.fire('dataReady');
},
setRawData: function(data) {
@ -134,8 +143,7 @@
this.editor.fire('dataReady');
},
getData: function() {
return window.rainloop_Utils_plainToHtml ?
window.rainloop_Utils_plainToHtml(this.getValue(), true) : simplePlainToHtml(this.getValue());
return this.editor.__plainUtils.plainToHtml(this.getValue());
},
getRawData: function() {
return this.getValue();

View file

@ -0,0 +1,97 @@
rl_signature_replacer = function (editor, sText, sSignature, bHtml, bInsertBefore)
{
var
bEmptyText = '' === $.trim(sText),
sNewLine = (bHtml ? '<br />' : "\n"),
sS1 = "\u0002\u0002",
sE1 = "\u0003\u0003",
sSS1 = '---1beg1---',
sEE1 = '---1end1---',
sS2 = "\u0004\u0004",
sE2 = "\u0005\u0005",
sSS2 = '---2beg2---',
sEE2 = '---2end2---'
;
if (!bEmptyText && bHtml)
{
bEmptyText = '' !== $.trim(editor.__plainUtils.htmlToPlain(sText));
}
sText = sText.replace(sS1, sSS1).replace(sS1, sSS1).replace(sS1, sSS1).replace(sS1, sSS1);
sText = sText.replace(sE1, sEE1).replace(sE1, sEE1).replace(sE1, sEE1).replace(sE1, sEE1);
sText = sText.replace(sS2, sSS2).replace(sS2, sSS2).replace(sS2, sSS2).replace(sS2, sSS2);
sText = sText.replace(sE2, sEE2).replace(sE2, sEE2).replace(sE2, sEE2).replace(sE2, sEE2);
if (!/---1beg1---/gm.test(sText))
{
sText = sSS1 + sEE1 + sText;
}
if (!/---2beg2---/gm.test(sText))
{
sText = sText + sSS2 + sEE2;
}
if (bInsertBefore)
{
sText = sText.replace(/---1beg1---[\s\S]*---1end1---/gm, sSS1 + sSignature + sNewLine + sEE1);
sText = sText.replace(/---2beg2---[\s\S]*---2end2---/gm, sSS2 + '' + sEE2);
}
else
{
sText = sText.replace(/---1beg1---[\s\S]*---1end1---/gm, sSS1 + '' + sEE1);
sText = sText.replace(/---2beg2---[\s\S]*---2end2---/gm, sSS2 + (bEmptyText ? '' : sNewLine) + sSignature + sEE2);
}
sText = sText.replace(/---1beg1---/g, sS1);
sText = sText.replace(/---1end1---/g, sE1);
sText = sText.replace(/---2beg2---/g, sS2);
sText = sText.replace(/---2end2---/g, sE2);
return sText;
};
CKEDITOR.plugins.add('signature', {
init: function(editor) {
editor.addCommand('insertSignature', {
modes: { wysiwyg: 1, plain: 1 },
exec: function (editor, cfg) {
var
bIsHtml = false,
bInsertBefore = false,
sSignature = ''
;
if (cfg) {
bIsHtml = undefined === cfg.isHtml ? false : !!cfg.isHtml;
bInsertBefore = undefined === cfg.insertBefore ? false : !!cfg.insertBefore;
sSignature = undefined === cfg.signature ? '' : cfg.signature;
}
try {
if ('plain' === editor.mode && editor.__plain && editor.__plainUtils) {
if (bIsHtml && editor.__plainUtils.htmlToPlain) {
sSignature = editor.__plainUtils.htmlToPlain(sSignature);
}
editor.__plain.setRawData(
rl_signature_replacer(editor,
editor.__plain.getRawData(), sSignature, false, bInsertBefore));
} else {
if (!bIsHtml && editor.__plainUtils && editor.__plainUtils.plainToHtml) {
sSignature = editor.__plainUtils.plainToHtml(sSignature);
}
editor.setData(
rl_signature_replacer(editor,
editor.getData(), sSignature, true, bInsertBefore));
}
} catch (e) {}
}
});
}
});